first copy
commit
66a47fa4a7
@ -0,0 +1 @@
|
|||||||
|
node_modules/*
|
@ -0,0 +1,64 @@
|
|||||||
|
var http = require('http');
|
||||||
|
var fs = require('fs');
|
||||||
|
var express = require('express');
|
||||||
|
var app = express();
|
||||||
|
var path = require('path');
|
||||||
|
// var index = fs.readFileSync('index.html');
|
||||||
|
var server = http.createServer(app);
|
||||||
|
var port = 8000;
|
||||||
|
|
||||||
|
const { SerialPort } = require('serialport')
|
||||||
|
const { ReadlineParser } = require('@serialport/parser-readline')
|
||||||
|
const sport = new SerialPort({ path: '/dev/ttyACM0', baudRate: 115200 })
|
||||||
|
|
||||||
|
const parser = sport.pipe(new ReadlineParser({ delimiter: '\r\n' }))
|
||||||
|
parser.on('data', console.log)
|
||||||
|
|
||||||
|
server.listen(port, () => {
|
||||||
|
console.log("Server is listening at port %d", port);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use(express.static(path.join(__dirname, "public")));
|
||||||
|
|
||||||
|
|
||||||
|
// var server = http.createServer(function(req, res){
|
||||||
|
|
||||||
|
// res.writeHead(200, {'Content-Type':'text/html'});
|
||||||
|
|
||||||
|
// res.end(index);
|
||||||
|
|
||||||
|
// });
|
||||||
|
|
||||||
|
var io = require('socket.io')(server);
|
||||||
|
|
||||||
|
io.on('connection', function(socket){
|
||||||
|
|
||||||
|
parser.on('data', function(data) {
|
||||||
|
const msg = data.split(' ');
|
||||||
|
console.log(msg[0], msg[1]);
|
||||||
|
io.emit(msg[0], msg[1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Node.js is listening!!');
|
||||||
|
socket.on("hello", (arg, callback) => {
|
||||||
|
console.log("hellohelo"); // "world"
|
||||||
|
io.emit('world');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('chat message', (msg) => {
|
||||||
|
console.log('[user]['+ socket.id + '][' + msg + ']');
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('userposition', (msg) => {
|
||||||
|
console.log('[user]['+ socket.id + '][position: ' + msg[0] + ',' + msg[1]+ ']');
|
||||||
|
socket.to('expo').emit(socket.id, msg);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// app.listen(5501);
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "xpub_prototype_citynet",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "app.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://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@github.com/louisafriederike/xpub_prototype_citynet.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/louisafriederike/xpub_prototype_citynet/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/louisafriederike/xpub_prototype_citynet#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.18.1",
|
||||||
|
"package.js": "^1.1.3",
|
||||||
|
"package.json": "^2.0.1",
|
||||||
|
"serialport": "^10.4.0",
|
||||||
|
"socket.io": "^4.5.0"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,191 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>control room</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<link rel="icon" href="img/favicon.ico" type="image/x-icon" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link href="style.css" rel="stylesheet">
|
||||||
|
<script src="input.js"></script>
|
||||||
|
<script src="p5.geolocation.js"></script>
|
||||||
|
<!-- <script src="p5.js"></script> -->
|
||||||
|
<script src='socket.io/socket.io.js'></script>
|
||||||
|
<script src="audio.js"></script>
|
||||||
|
<meta property="og:title" content="868 MHz" />
|
||||||
|
<meta property="og:description" content="868 MHz is a hybrid reality game running on the same standardized frequency as the LoRa gateways of The Things Network. Chase the electric currents of the asphalt to locate gateways and encounter a being which has nested itself beneath the city streets, all the way down the power lines woven amidst its whirring epicenter." />
|
||||||
|
<meta property="og:image" content="/img/868.png" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
let lat, lon;
|
||||||
|
if ('geolocation' in navigator) {
|
||||||
|
console.log('geolocation available');
|
||||||
|
navigator.geolocation.getCurrentPosition(async position => {
|
||||||
|
let lat, lon, weather, air;
|
||||||
|
try {
|
||||||
|
lat = position.coords.latitude;
|
||||||
|
lon = position.coords.longitude;
|
||||||
|
document.getElementById('latitude').textContent = lat.toFixed(2);
|
||||||
|
document.getElementById('longitude').textContent = lon.toFixed(2);
|
||||||
|
const api_url = `weather/${lat},${lon}`;
|
||||||
|
const response = await fetch(api_url);
|
||||||
|
const json = await response.json();
|
||||||
|
weather = json.weather.currently;
|
||||||
|
air = json.air_quality.results[0].measurements[0];
|
||||||
|
document.getElementById('summary').textContent = weather.summary;
|
||||||
|
document.getElementById('temp').textContent = weather.temperature;
|
||||||
|
document.getElementById('aq_parameter').textContent = air.parameter;
|
||||||
|
document.getElementById('aq_value').textContent = air.value;
|
||||||
|
document.getElementById('aq_units').textContent = air.unit;
|
||||||
|
document.getElementById('aq_date').textContent = air.lastUpdated;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
air = { value: -1 };
|
||||||
|
document.getElementById('aq_value').textContent = 'NO READING';
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = { lat, lon, weather, air };
|
||||||
|
const options = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
};
|
||||||
|
const db_response = await fetch('/api', options);
|
||||||
|
const db_json = await db_response.json();
|
||||||
|
console.log(db_json);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('geolocation not available');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex-container2">
|
||||||
|
<div class="flex-top">
|
||||||
|
<div class="section2">
|
||||||
|
<progress id="file" max="100" value="70"> 70% </progress>
|
||||||
|
<p>DISTANCE: <span id="distance">0</span> km</p>
|
||||||
|
|
||||||
|
<div id="tripmeter">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
STATUS:
|
||||||
|
<span id="message-node1">detecting....</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var socket = io();
|
||||||
|
socket.on('data', function(data){
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
// document.getElementById('sample').style.opacity = data+"%";
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('node1', function(sensor){
|
||||||
|
|
||||||
|
console.log(sensor);
|
||||||
|
document.getElementById("file").value = sensor;
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// socket.on('node3', function(sensor){
|
||||||
|
|
||||||
|
// console.log('3' + sensor);
|
||||||
|
// document.getElementById("file2").value = sensor;
|
||||||
|
|
||||||
|
|
||||||
|
// });
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section2">
|
||||||
|
<progress id="file2" max="100" value="70"> 70% </progress>
|
||||||
|
<p>DISTANCE: <span id="distance">0</span> km</p>
|
||||||
|
<p> STATUS:
|
||||||
|
<span id="message-node2">detecting....</span>
|
||||||
|
</p>
|
||||||
|
<script>
|
||||||
|
var socket = io();
|
||||||
|
socket.on('data', function(data){
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
// document.getElementById('sample').style.opacity = data+"%";
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('node3', function(sensor){
|
||||||
|
|
||||||
|
console.log('3' + sensor);
|
||||||
|
document.getElementById("file2").value = sensor;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('create', 'expo');
|
||||||
|
socket.on('userposition', function(msg){
|
||||||
|
|
||||||
|
|
||||||
|
console.log(msg);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div class="section2">
|
||||||
|
<progress id="file" max="100" value="70"> 70% </progress>
|
||||||
|
<p>DISTANCE: <span id="distance">0</span> km</p>
|
||||||
|
<p> STATUS:
|
||||||
|
<span id="message-node3">detecting....</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-bottom">
|
||||||
|
<div class="section2">
|
||||||
|
<progress id="file" max="100" value="10"> 70% </progress>
|
||||||
|
<p>DISTANCE: <span id="distance">0</span> km</p><br>
|
||||||
|
<p> STATUS:
|
||||||
|
<span id="message-node4">detecting....</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="section2">
|
||||||
|
<progress id="file5" max="100" value="30"> 70% </progress>
|
||||||
|
<p>DISTANCE: <span id="distance">0</span> km</p>
|
||||||
|
<p> STATUS:
|
||||||
|
<span id="message-node5">detecting....</span>
|
||||||
|
</p>
|
||||||
|
<script>
|
||||||
|
var socket = io();
|
||||||
|
socket.on('data', function(data){
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
// document.getElementById('sample').style.opacity = data+"%";
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('node5', function(sensor){
|
||||||
|
|
||||||
|
console.log('5' + sensor);
|
||||||
|
document.getElementById("file5").value = sensor;
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div class="section2">
|
||||||
|
<progress id="file" max="100" value="20"> 70% </progress>
|
||||||
|
<p>DISTANCE: <span id="distance">0</span> km</p>
|
||||||
|
<p> STATUS:
|
||||||
|
<span id="message-node6">detecting....</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
||||||
|
<script type="text/javascript" src="fence.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
After Width: | Height: | Size: 182 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,231 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 585.85067 538.28672"
|
||||||
|
version="1.1"
|
||||||
|
id="svg55"
|
||||||
|
sodipodi:docname="map-markers.svg"
|
||||||
|
inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
|
||||||
|
inkscape:export-filename="map-markers.svg"
|
||||||
|
inkscape:export-xdpi="96"
|
||||||
|
inkscape:export-ydpi="96"
|
||||||
|
width="585.85065"
|
||||||
|
height="538.28674"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview57"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
showgrid="true"
|
||||||
|
inkscape:zoom="1.4936741"
|
||||||
|
inkscape:cx="196.16059"
|
||||||
|
inkscape:cy="265.45282"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="991"
|
||||||
|
inkscape:window-x="-9"
|
||||||
|
inkscape:window-y="-9"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg55">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid216" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<defs
|
||||||
|
id="defs4">
|
||||||
|
<style
|
||||||
|
id="style2">.d,.e,.f{stroke:red;}.d,.e,.f,.g{stroke-miterlimit:10;}.d,.e,.g{fill:none;}.d,.f,.g{stroke-width:3px;}.h{fill:#ff0;}.g{stroke:#ff0;}</style>
|
||||||
|
</defs>
|
||||||
|
<g
|
||||||
|
id="a"
|
||||||
|
transform="translate(0.0115319,-0.00253224)">
|
||||||
|
<polyline
|
||||||
|
class="g"
|
||||||
|
points="87.82 122.2 63.34 203.7 72.28 223.48 163.97 248.25 164.15 258.87 76.93 338.79 66.46 358.91 70.18 417.99"
|
||||||
|
id="polyline6" />
|
||||||
|
<polyline
|
||||||
|
class="g"
|
||||||
|
points="86.77 449.18 151.91 457.36 171.85 457.36 251.82 398.43 266.28 404.53 335.26 463.55 355.2 463.55 450.2 427.05 475.46 410.96 493.05 306.2 480.97 286.48 313.51 314.95 300.78 305.03 262.6 249.18 251.24 217.97 297.72 142.3 311.01 132.28 404.28 78.99 424.15 75.18 491.06 94.43"
|
||||||
|
id="polyline8" />
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
class="d"
|
||||||
|
d="m 521.26153,269.02747 c -58.11,-51.71 -149.9,-14 -185.55,8.6 4.25,-51.57 -43.58,-56.38 -43.58,-56.38 0,0 23.46,-41.23 58.73,-68.42 20.53,-16.2 87.75,-57.600002 115.02,-30.99 41.36,40.35 -57.4,82.16 -57.4,82.16 99.81,-21.61 170.76,40.21 170.76,40.21 0,0 -28.25,-45.22 -26.98,-88.35 0.96,-32.71 21.74,-73.600002 -1.31,-99.220002 -24.96,-27.72 -119.68,-4.67 -164.22,-52.1000002 0,0 9.18,60.7000002 -55.3,86.1800002 0,0 -19.51,-44.11 -68.16,-46.94 -56.49,-3.29 -90.53,15.44 -128.22,19.57 -42.749998,4.69 -90.319998,-16.11 -90.319998,-16.11 0,0 21.23,40.32 5.66,78.120002 -15.57,37.81 -41.7200001,76.79 -27.69,109.53 18.03,44.83 87.689998,35.2 87.689998,35.2 0,0 -4.63,16.05 -33.389998,35.89 -25.85,17.83 -73.4300001,4.53 -73.4300001,4.53 0,0 19.5100001,28.45 19.9900001,55.83 0.48,27.38 0.43,72.32 15.66,94.07 9.34,13.34 30.6,37.33 93.119998,45.98 48.43,6.7 62.75,23.94 62.75,23.94 0,0 -11.54,-30.07 -0.88,-51.72 15.24,-30.94 45.02,-34.04 45.02,-34.04 0,0 14.86,46.93 47.48,56.5 32.63,9.57 59.23,4.69 120.55,-19.09 43.24,-16.77 101.59,8.36 101.59,8.36 0,0 -4.2,-42.11 14.07,-76.15 15.19,-28.29 48.93,-100.12 -1.67,-145.15 z m -314.91,116.09 c -59.62,49.27 -95.06,37 -104.5,27.4 -9.439998,-9.59 -9.609998,-42.25 30.38,-83.41 52.3,-53.84 100.6,-49.29 110.45,-39.67 10,9.77 22.78,40.09 -36.34,95.68 z m -11.3,-193.9 c -69.52,39.8 -94.13,15.56 -98.049998,8.87 -3.91,-6.69 -11.36,-39.09 47.689998,-71.27 59.05,-32.180002 92.83,-27.82 100.25,-16.88 7.27,10.71 21.34,38.5 -49.89,79.28 z m 215.1,215.44 c -69.52,39.8 -94.13,15.56 -98.05,8.87 -3.91,-6.69 -8.66,-34.57 47.69,-71.27 59.22,-38.57 97.12,-30.89 102.84,-22.38 5.73,8.51 18.75,44 -52.49,84.78 z"
|
||||||
|
id="path11" />
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="79.928421"
|
||||||
|
y="88.535973"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect13"
|
||||||
|
onclick="objective1()" />
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="484.86615"
|
||||||
|
y="84.10247"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect15"
|
||||||
|
onclick="objective5()" />
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="220.85062"
|
||||||
|
y="217.64967"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect17"
|
||||||
|
onclick="objective4()" />
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="437.80362"
|
||||||
|
y="414.99902"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect19"
|
||||||
|
onclick="objective3()" />
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="42.805691"
|
||||||
|
y="416.09134"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect21"
|
||||||
|
onclick="objective2()" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="48.299683"
|
||||||
|
y="204.54538"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect23"
|
||||||
|
onclick="breadCrumb1()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 102.59255,109.70798 c 0.01,0.32 0.03,0.58 0.05,0.78 0.02,0.2 0.07,0.38 0.13,0.54 0.07,0.15 0.14,0.27 0.21,0.35 0.07,0.08 0.19,0.14 0.35,0.19 0.16,0.05 0.33,0.08 0.48,0.1 0.16,0.01 0.38,0.02 0.68,0.02 0.06,0.06 0.1,0.14 0.1,0.23 0,0.09 -0.03,0.17 -0.1,0.23 h -5.39 c -0.06,-0.06 -0.1,-0.14 -0.1,-0.23 0,-0.09 0.03,-0.17 0.1,-0.23 0.29,0 0.52,0 0.68,-0.02 0.16,-0.01 0.32,-0.05 0.48,-0.1 0.16,-0.05 0.28,-0.11 0.35,-0.19 0.07,-0.08 0.14,-0.2 0.21,-0.35 0.07,-0.15 0.11,-0.33 0.13,-0.54 0.02,-0.2 0.04,-0.46 0.05,-0.78 0.02,-0.65 0.03,-1.9 0.03,-3.75 0,-1.85 -0.01,-3.21 -0.03,-3.87 -0.01,-0.44 -0.05,-0.76 -0.11,-0.97 -0.06,-0.21 -0.17,-0.31 -0.33,-0.31 -0.39,0 -1.02,0.19 -1.909998,0.56 -0.2,-0.13 -0.31,-0.29 -0.33,-0.48 1.889998,-0.88 3.309998,-1.610002 4.249998,-2.200002 0.09,0 0.13,0.04 0.13,0.11 -0.03,0.28 -0.07,1.260002 -0.13,2.950002 -0.02,0.65 -0.03,1.98 -0.03,3.99 0,2.01 0.01,3.34 0.03,3.99 z"
|
||||||
|
id="path25"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 66.471532,430.17747 c 0,-0.34 0.08,-0.69 0.25,-1.05 0.16,-0.36 0.4,-0.69 0.7,-1 0.3,-0.31 0.7,-0.57 1.19,-0.77 0.49,-0.2 1.03,-0.3 1.61,-0.3 0.47,0 0.92,0.06 1.38,0.19 0.46,0.13 0.87,0.32 1.26,0.58 0.39,0.26 0.71,0.61 0.95,1.05 0.24,0.44 0.36,0.95 0.36,1.51 0,0.4 -0.05,0.77 -0.15,1.11 -0.1,0.34 -0.27,0.67 -0.5,1 -0.23,0.33 -0.45,0.61 -0.66,0.83 -0.21,0.22 -0.5,0.52 -0.89,0.9 l -2.22,2.14 c -0.1,0.1 -0.26,0.29 -0.48,0.56 -0.22,0.27 -0.47,0.65 -0.74,1.13 -0.27,0.48 -0.41,0.88 -0.41,1.19 h 4.15 c 0.38,0 0.68,-0.18 0.9,-0.54 0.22,-0.36 0.43,-0.96 0.63,-1.79 0.15,-0.03 0.29,0.01 0.42,0.12 -0.01,0.36 -0.07,0.89 -0.17,1.59 -0.1,0.7 -0.22,1.32 -0.35,1.86 h -7.18 c 0,-0.71 0.16,-1.38 0.49,-2.03 0.33,-0.65 1,-1.49 2.01,-2.51 l 1.63,-1.6 c 0.61,-0.62 1.02,-1.23 1.25,-1.83 0.22,-0.6 0.33,-1.28 0.33,-2.04 0,-0.5 -0.07,-0.95 -0.21,-1.33 -0.14,-0.39 -0.33,-0.69 -0.55,-0.9 -0.22,-0.21 -0.46,-0.37 -0.69,-0.48 -0.23,-0.11 -0.46,-0.16 -0.67,-0.16 -0.38,0 -0.71,0.05 -1,0.16 -0.29,0.11 -0.5,0.25 -0.65,0.41 -0.15,0.17 -0.25,0.34 -0.32,0.5 -0.07,0.17 -0.1,0.33 -0.1,0.48 0,0.06 0.03,0.16 0.09,0.3 0.06,0.13 0.09,0.21 0.1,0.23 0.06,0.2 0.09,0.35 0.09,0.44 0,0.2 -0.1,0.38 -0.31,0.53 -0.21,0.15 -0.41,0.23 -0.61,0.23 -0.24,0 -0.45,-0.06 -0.62,-0.18 -0.17,-0.12 -0.26,-0.29 -0.26,-0.52 z"
|
||||||
|
id="path27"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 465.58153,419.35747 c -0.12,0 -0.27,0.02 -0.43,0.06 -0.17,0.04 -0.35,0.11 -0.55,0.2 -0.2,0.1 -0.38,0.21 -0.54,0.35 -0.16,0.14 -0.3,0.32 -0.41,0.54 -0.11,0.23 -0.17,0.47 -0.17,0.74 0,0.27 -0.07,0.52 -0.21,0.77 -0.14,0.25 -0.36,0.38 -0.64,0.38 -0.24,0 -0.43,-0.08 -0.56,-0.24 -0.13,-0.16 -0.19,-0.33 -0.19,-0.52 0,-0.16 0.04,-0.36 0.12,-0.57 0.08,-0.21 0.22,-0.46 0.42,-0.74 0.2,-0.27 0.46,-0.52 0.76,-0.74 0.3,-0.22 0.7,-0.41 1.2,-0.56 0.5,-0.15 1.06,-0.23 1.67,-0.23 0.53,0 1,0.08 1.42,0.23 0.42,0.15 0.74,0.35 0.97,0.59 0.23,0.24 0.4,0.49 0.52,0.75 0.12,0.26 0.17,0.51 0.17,0.76 0,0.24 -0.02,0.45 -0.06,0.63 -0.04,0.18 -0.12,0.41 -0.25,0.68 -0.13,0.27 -0.35,0.56 -0.67,0.85 -0.32,0.3 -0.73,0.6 -1.22,0.92 l 0.02,0.04 c 0.36,0.06 0.7,0.16 1.03,0.31 0.33,0.15 0.64,0.36 0.95,0.62 0.31,0.26 0.55,0.62 0.74,1.06 0.19,0.44 0.28,0.95 0.28,1.52 0,0.94 -0.23,1.77 -0.69,2.49 -0.46,0.72 -1.07,1.27 -1.82,1.64 -0.75,0.37 -1.56,0.56 -2.44,0.56 -0.45,0 -0.92,-0.06 -1.4,-0.18 -0.48,-0.12 -0.9,-0.3 -1.25,-0.53 -0.35,-0.23 -0.52,-0.49 -0.52,-0.77 0,-0.18 0.1,-0.35 0.29,-0.52 0.19,-0.16 0.4,-0.25 0.63,-0.25 0.37,0 0.68,0.19 0.95,0.57 l 0.15,0.27 c 0.08,0.14 0.15,0.24 0.21,0.31 0.06,0.07 0.15,0.15 0.26,0.25 0.11,0.1 0.25,0.17 0.41,0.22 0.16,0.05 0.35,0.07 0.56,0.07 0.17,0 0.37,-0.04 0.6,-0.11 0.23,-0.07 0.47,-0.21 0.74,-0.4 0.27,-0.19 0.51,-0.42 0.74,-0.7 0.23,-0.28 0.41,-0.64 0.56,-1.1 0.15,-0.46 0.23,-0.96 0.23,-1.51 0,-1.92 -0.97,-2.88 -2.9,-2.88 -0.38,0 -0.69,0.01 -0.95,0.04 l -0.12,-0.48 c 0.62,-0.1 1.2,-0.35 1.74,-0.75 0.54,-0.4 0.95,-0.83 1.23,-1.29 0.28,-0.46 0.42,-0.88 0.42,-1.26 0,-0.64 -0.2,-1.16 -0.6,-1.54 -0.4,-0.38 -0.86,-0.58 -1.38,-0.58 z"
|
||||||
|
id="path29"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 248.30102,234.52645 c 0.22,0 0.33,0.12 0.33,0.35 0,0.13 -0.06,0.24 -0.19,0.33 -0.13,0.09 -0.28,0.13 -0.44,0.13 h -1.55 c 0,1.08 0,1.84 0.02,2.25 0,0.15 0.02,0.28 0.05,0.39 0.02,0.11 0.05,0.2 0.08,0.27 0.03,0.08 0.08,0.14 0.17,0.19 0.08,0.05 0.15,0.1 0.2,0.12 0.05,0.03 0.15,0.05 0.29,0.08 0.14,0.02 0.25,0.04 0.33,0.05 0.08,0.01 0.22,0.02 0.43,0.02 0.06,0.06 0.1,0.14 0.1,0.23 0,0.09 -0.03,0.17 -0.1,0.23 h -4.84 c -0.06,-0.06 -0.1,-0.15 -0.1,-0.25 0,-0.1 0.03,-0.19 0.1,-0.25 0.2,-0.01 0.35,-0.03 0.46,-0.04 0.11,-0.01 0.24,-0.03 0.4,-0.06 0.16,-0.03 0.28,-0.07 0.37,-0.12 0.09,-0.05 0.18,-0.11 0.27,-0.19 0.09,-0.08 0.16,-0.18 0.2,-0.3 0.04,-0.12 0.07,-0.26 0.08,-0.42 0.01,-0.41 0.02,-1.15 0.02,-2.21 h -4.51 c -0.45,0 -0.74,-0.31 -0.86,-0.92 0.98,-1.54 2.04,-3.12 3.19,-4.74 1.14,-1.62 2.07,-2.86 2.78,-3.74 0.14,-0.16 0.26,-0.24 0.35,-0.24 h 0.55 l 0.04,0.04 c 0,0.05 -0.01,0.17 -0.02,0.36 0,0.19 0,0.45 0,0.79 0,0.34 0,0.66 -0.02,0.98 -0.04,0.8 -0.05,3.02 -0.03,6.65 h 1.86 z m -3.31,0 c 0.01,-3.67 0,-5.91 -0.03,-6.71 -1.75,2.4 -3.28,4.64 -4.58,6.71 z"
|
||||||
|
id="path31"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 509.06153,96.867468 c 0,-1.14 -0.26,-2.02 -0.77,-2.64 -0.52,-0.62 -1.15,-0.93 -1.91,-0.93 -0.93,0 -1.86,0.18 -2.79,0.53 l 0.74,-6.11 c 0.86,0.07 1.65,0.11 2.37,0.11 0.87,0 2.08,-0.08 3.61,-0.24 l 0.16,0.09 -0.35,1.28 c -0.9,0.09 -1.67,0.13 -2.31,0.13 -0.64,0 -1.57,-0.06 -2.79,-0.19 l -0.44,3.89 c 0.23,-0.09 0.57,-0.17 1.03,-0.24 0.46,-0.08 0.91,-0.11 1.34,-0.11 0.79,0 1.5,0.19 2.11,0.57 0.61,0.38 1.07,0.87 1.38,1.48 0.31,0.61 0.46,1.27 0.46,2 0,1.39 -0.44,2.54 -1.32,3.44 -0.88,0.910002 -2,1.360002 -3.36,1.360002 -0.42,0 -0.87,-0.07 -1.35,-0.22 -0.48,-0.15 -0.89,-0.35 -1.24,-0.61 -0.35,-0.26 -0.52,-0.540002 -0.52,-0.820002 0,-0.21 0.08,-0.37 0.25,-0.5 0.16,-0.12 0.36,-0.19 0.58,-0.19 0.39,0 0.76,0.24 1.13,0.71 0.03,0.04 0.09,0.13 0.19,0.27 0.1,0.140002 0.17,0.250002 0.23,0.310002 0.06,0.06 0.14,0.14 0.25,0.24 0.11,0.1 0.23,0.17 0.35,0.2 0.13,0.04 0.27,0.06 0.43,0.06 0.67,0 1.26,-0.38 1.78,-1.140002 0.52,-0.76 0.78,-1.66 0.78,-2.7 z"
|
||||||
|
id="path33"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="145.88861"
|
||||||
|
y="246.20175"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect35"
|
||||||
|
onclick="breadCrumb2()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="50.484272"
|
||||||
|
y="334.53384"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect37"
|
||||||
|
onclick="breadCrumb3()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="146.8737"
|
||||||
|
y="446.49927"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect39"
|
||||||
|
onclick="breadCrumb4()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="233.34877"
|
||||||
|
y="392.82779"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect41"
|
||||||
|
onclick="breadCrumb5()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="326.81818"
|
||||||
|
y="454.86319"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect43"
|
||||||
|
onclick="breadCrumb6()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="466.02078"
|
||||||
|
y="290.49597"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect45"
|
||||||
|
onclick="breadCrumb7()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="291.60892"
|
||||||
|
y="304.90247"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect47"
|
||||||
|
onclick="breadCrumb8()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="281.4234"
|
||||||
|
y="129.52808"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect49"
|
||||||
|
onclick="breadCrumb9()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h"
|
||||||
|
x="400.62808"
|
||||||
|
y="67.091034"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect51"
|
||||||
|
onclick="breadCrumb10()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
After Width: | Height: | Size: 161 KiB |
@ -0,0 +1,395 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>868mhz.net</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<link rel="icon" href="img/favicon.ico" type="image/x-icon" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link href="style.css" rel="stylesheet">
|
||||||
|
<!-- <script src="js/p5.js"></script>
|
||||||
|
<script src="js/p5.geolocation.js"></script> -->
|
||||||
|
|
||||||
|
<script src='socket.io/socket.io.js'></script>
|
||||||
|
<meta property="og:title" content="868 MHz" />
|
||||||
|
<meta property="og:description" content="868 MHz is a hybrid reality game running on the same standardized frequency as the LoRa gateways of The Things Network. Chase the electric currents of the asphalt to locate gateways and encounter a being which has nested itself beneath the city streets, all the way down the power lines woven amidst its whirring epicenter." />
|
||||||
|
<meta property="og:image" content="/img/868.png" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="wrapper">
|
||||||
|
<div class="flex-container">
|
||||||
|
<div class="flex-left">
|
||||||
|
<div class="section">
|
||||||
|
<!-- <progress id="file" max="100" value="70"> 70% </progress> -->
|
||||||
|
<p>>>> PORT:</p>
|
||||||
|
<span><form id="form" action="">
|
||||||
|
<input id="input" autocomplete="off" onkeyup="this.value = this.value.toUpperCase();"/><button>>>></button>
|
||||||
|
</form></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="section" id="dreammap">
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 585.85067 538.28672"
|
||||||
|
version="1.1"
|
||||||
|
id="svg55"
|
||||||
|
sodipodi:docname="map-markers.svg"
|
||||||
|
inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
|
||||||
|
inkscape:export-filename="map-markers.svg"
|
||||||
|
inkscape:export-xdpi="96"
|
||||||
|
inkscape:export-ydpi="96"
|
||||||
|
width="585.85065"
|
||||||
|
height="538.28674"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview57"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
showgrid="true"
|
||||||
|
inkscape:zoom="1.4936741"
|
||||||
|
inkscape:cx="196.16059"
|
||||||
|
inkscape:cy="265.45282"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="991"
|
||||||
|
inkscape:window-x="-9"
|
||||||
|
inkscape:window-y="-9"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg55">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid216" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<defs
|
||||||
|
id="defs4">
|
||||||
|
<style
|
||||||
|
id="style2">.d,.e,.f{stroke:#ff2400;}.d,.e,.f,.g{stroke-miterlimit:10;}.d,.e,.g{fill:none;}.d,.f,.g{stroke-width:3px;}.h{stroke:black; stroke-width:3px; fill:rgb(129, 135, 121)}.g{stroke:#ff4000;}</style>
|
||||||
|
</defs>
|
||||||
|
<g
|
||||||
|
id="a"
|
||||||
|
transform="translate(0.0115319,-0.00253224)">
|
||||||
|
<polyline
|
||||||
|
class="g"
|
||||||
|
points="87.82 122.2 63.34 203.7 72.28 223.48 163.97 248.25 164.15 258.87 76.93 338.79 66.46 358.91 70.18 417.99"
|
||||||
|
id="polyline6" />
|
||||||
|
<polyline
|
||||||
|
class="g"
|
||||||
|
points="86.77 449.18 151.91 457.36 171.85 457.36 251.82 398.43 266.28 404.53 335.26 463.55 355.2 463.55 450.2 427.05 475.46 410.96 493.05 306.2 480.97 286.48 313.51 314.95 300.78 305.03 262.6 249.18 251.24 217.97 297.72 142.3 311.01 132.28 404.28 78.99 424.15 75.18 491.06 94.43"
|
||||||
|
id="polyline8" />
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
class="d"
|
||||||
|
d="m 521.26153,269.02747 c -58.11,-51.71 -149.9,-14 -185.55,8.6 4.25,-51.57 -43.58,-56.38 -43.58,-56.38 0,0 23.46,-41.23 58.73,-68.42 20.53,-16.2 87.75,-57.600002 115.02,-30.99 41.36,40.35 -57.4,82.16 -57.4,82.16 99.81,-21.61 170.76,40.21 170.76,40.21 0,0 -28.25,-45.22 -26.98,-88.35 0.96,-32.71 21.74,-73.600002 -1.31,-99.220002 -24.96,-27.72 -119.68,-4.67 -164.22,-52.1000002 0,0 9.18,60.7000002 -55.3,86.1800002 0,0 -19.51,-44.11 -68.16,-46.94 -56.49,-3.29 -90.53,15.44 -128.22,19.57 -42.749998,4.69 -90.319998,-16.11 -90.319998,-16.11 0,0 21.23,40.32 5.66,78.120002 -15.57,37.81 -41.7200001,76.79 -27.69,109.53 18.03,44.83 87.689998,35.2 87.689998,35.2 0,0 -4.63,16.05 -33.389998,35.89 -25.85,17.83 -73.4300001,4.53 -73.4300001,4.53 0,0 19.5100001,28.45 19.9900001,55.83 0.48,27.38 0.43,72.32 15.66,94.07 9.34,13.34 30.6,37.33 93.119998,45.98 48.43,6.7 62.75,23.94 62.75,23.94 0,0 -11.54,-30.07 -0.88,-51.72 15.24,-30.94 45.02,-34.04 45.02,-34.04 0,0 14.86,46.93 47.48,56.5 32.63,9.57 59.23,4.69 120.55,-19.09 43.24,-16.77 101.59,8.36 101.59,8.36 0,0 -4.2,-42.11 14.07,-76.15 15.19,-28.29 48.93,-100.12 -1.67,-145.15 z m -314.91,116.09 c -59.62,49.27 -95.06,37 -104.5,27.4 -9.439998,-9.59 -9.609998,-42.25 30.38,-83.41 52.3,-53.84 100.6,-49.29 110.45,-39.67 10,9.77 22.78,40.09 -36.34,95.68 z m -11.3,-193.9 c -69.52,39.8 -94.13,15.56 -98.049998,8.87 -3.91,-6.69 -11.36,-39.09 47.689998,-71.27 59.05,-32.180002 92.83,-27.82 100.25,-16.88 7.27,10.71 21.34,38.5 -49.89,79.28 z m 215.1,215.44 c -69.52,39.8 -94.13,15.56 -98.05,8.87 -3.91,-6.69 -8.66,-34.57 47.69,-71.27 59.22,-38.57 97.12,-30.89 102.84,-22.38 5.73,8.51 18.75,44 -52.49,84.78 z"
|
||||||
|
id="path11" />
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="79.928421"
|
||||||
|
y="88.535973"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect13"
|
||||||
|
onclick="objective1()" />
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="484.86615"
|
||||||
|
y="84.10247"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect15"
|
||||||
|
onclick="objective5(), R1()"/>
|
||||||
|
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="220.85062"
|
||||||
|
y="217.64967"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect17"
|
||||||
|
onclick="objective4()" />
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="437.80362"
|
||||||
|
y="414.99902"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect19"
|
||||||
|
onclick="objective3()" />
|
||||||
|
<rect
|
||||||
|
class="f"
|
||||||
|
x="42.805691"
|
||||||
|
y="416.09134"
|
||||||
|
width="39.418907"
|
||||||
|
height="39.418907"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect21"
|
||||||
|
onclick="objective2()" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="48.299683"
|
||||||
|
y="204.54538"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect23"
|
||||||
|
onclick="breadCrumb1()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 102.59255,109.70798 c 0.01,0.32 0.03,0.58 0.05,0.78 0.02,0.2 0.07,0.38 0.13,0.54 0.07,0.15 0.14,0.27 0.21,0.35 0.07,0.08 0.19,0.14 0.35,0.19 0.16,0.05 0.33,0.08 0.48,0.1 0.16,0.01 0.38,0.02 0.68,0.02 0.06,0.06 0.1,0.14 0.1,0.23 0,0.09 -0.03,0.17 -0.1,0.23 h -5.39 c -0.06,-0.06 -0.1,-0.14 -0.1,-0.23 0,-0.09 0.03,-0.17 0.1,-0.23 0.29,0 0.52,0 0.68,-0.02 0.16,-0.01 0.32,-0.05 0.48,-0.1 0.16,-0.05 0.28,-0.11 0.35,-0.19 0.07,-0.08 0.14,-0.2 0.21,-0.35 0.07,-0.15 0.11,-0.33 0.13,-0.54 0.02,-0.2 0.04,-0.46 0.05,-0.78 0.02,-0.65 0.03,-1.9 0.03,-3.75 0,-1.85 -0.01,-3.21 -0.03,-3.87 -0.01,-0.44 -0.05,-0.76 -0.11,-0.97 -0.06,-0.21 -0.17,-0.31 -0.33,-0.31 -0.39,0 -1.02,0.19 -1.909998,0.56 -0.2,-0.13 -0.31,-0.29 -0.33,-0.48 1.889998,-0.88 3.309998,-1.610002 4.249998,-2.200002 0.09,0 0.13,0.04 0.13,0.11 -0.03,0.28 -0.07,1.260002 -0.13,2.950002 -0.02,0.65 -0.03,1.98 -0.03,3.99 0,2.01 0.01,3.34 0.03,3.99 z"
|
||||||
|
id="path25"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 66.471532,430.17747 c 0,-0.34 0.08,-0.69 0.25,-1.05 0.16,-0.36 0.4,-0.69 0.7,-1 0.3,-0.31 0.7,-0.57 1.19,-0.77 0.49,-0.2 1.03,-0.3 1.61,-0.3 0.47,0 0.92,0.06 1.38,0.19 0.46,0.13 0.87,0.32 1.26,0.58 0.39,0.26 0.71,0.61 0.95,1.05 0.24,0.44 0.36,0.95 0.36,1.51 0,0.4 -0.05,0.77 -0.15,1.11 -0.1,0.34 -0.27,0.67 -0.5,1 -0.23,0.33 -0.45,0.61 -0.66,0.83 -0.21,0.22 -0.5,0.52 -0.89,0.9 l -2.22,2.14 c -0.1,0.1 -0.26,0.29 -0.48,0.56 -0.22,0.27 -0.47,0.65 -0.74,1.13 -0.27,0.48 -0.41,0.88 -0.41,1.19 h 4.15 c 0.38,0 0.68,-0.18 0.9,-0.54 0.22,-0.36 0.43,-0.96 0.63,-1.79 0.15,-0.03 0.29,0.01 0.42,0.12 -0.01,0.36 -0.07,0.89 -0.17,1.59 -0.1,0.7 -0.22,1.32 -0.35,1.86 h -7.18 c 0,-0.71 0.16,-1.38 0.49,-2.03 0.33,-0.65 1,-1.49 2.01,-2.51 l 1.63,-1.6 c 0.61,-0.62 1.02,-1.23 1.25,-1.83 0.22,-0.6 0.33,-1.28 0.33,-2.04 0,-0.5 -0.07,-0.95 -0.21,-1.33 -0.14,-0.39 -0.33,-0.69 -0.55,-0.9 -0.22,-0.21 -0.46,-0.37 -0.69,-0.48 -0.23,-0.11 -0.46,-0.16 -0.67,-0.16 -0.38,0 -0.71,0.05 -1,0.16 -0.29,0.11 -0.5,0.25 -0.65,0.41 -0.15,0.17 -0.25,0.34 -0.32,0.5 -0.07,0.17 -0.1,0.33 -0.1,0.48 0,0.06 0.03,0.16 0.09,0.3 0.06,0.13 0.09,0.21 0.1,0.23 0.06,0.2 0.09,0.35 0.09,0.44 0,0.2 -0.1,0.38 -0.31,0.53 -0.21,0.15 -0.41,0.23 -0.61,0.23 -0.24,0 -0.45,-0.06 -0.62,-0.18 -0.17,-0.12 -0.26,-0.29 -0.26,-0.52 z"
|
||||||
|
id="path27"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 465.58153,419.35747 c -0.12,0 -0.27,0.02 -0.43,0.06 -0.17,0.04 -0.35,0.11 -0.55,0.2 -0.2,0.1 -0.38,0.21 -0.54,0.35 -0.16,0.14 -0.3,0.32 -0.41,0.54 -0.11,0.23 -0.17,0.47 -0.17,0.74 0,0.27 -0.07,0.52 -0.21,0.77 -0.14,0.25 -0.36,0.38 -0.64,0.38 -0.24,0 -0.43,-0.08 -0.56,-0.24 -0.13,-0.16 -0.19,-0.33 -0.19,-0.52 0,-0.16 0.04,-0.36 0.12,-0.57 0.08,-0.21 0.22,-0.46 0.42,-0.74 0.2,-0.27 0.46,-0.52 0.76,-0.74 0.3,-0.22 0.7,-0.41 1.2,-0.56 0.5,-0.15 1.06,-0.23 1.67,-0.23 0.53,0 1,0.08 1.42,0.23 0.42,0.15 0.74,0.35 0.97,0.59 0.23,0.24 0.4,0.49 0.52,0.75 0.12,0.26 0.17,0.51 0.17,0.76 0,0.24 -0.02,0.45 -0.06,0.63 -0.04,0.18 -0.12,0.41 -0.25,0.68 -0.13,0.27 -0.35,0.56 -0.67,0.85 -0.32,0.3 -0.73,0.6 -1.22,0.92 l 0.02,0.04 c 0.36,0.06 0.7,0.16 1.03,0.31 0.33,0.15 0.64,0.36 0.95,0.62 0.31,0.26 0.55,0.62 0.74,1.06 0.19,0.44 0.28,0.95 0.28,1.52 0,0.94 -0.23,1.77 -0.69,2.49 -0.46,0.72 -1.07,1.27 -1.82,1.64 -0.75,0.37 -1.56,0.56 -2.44,0.56 -0.45,0 -0.92,-0.06 -1.4,-0.18 -0.48,-0.12 -0.9,-0.3 -1.25,-0.53 -0.35,-0.23 -0.52,-0.49 -0.52,-0.77 0,-0.18 0.1,-0.35 0.29,-0.52 0.19,-0.16 0.4,-0.25 0.63,-0.25 0.37,0 0.68,0.19 0.95,0.57 l 0.15,0.27 c 0.08,0.14 0.15,0.24 0.21,0.31 0.06,0.07 0.15,0.15 0.26,0.25 0.11,0.1 0.25,0.17 0.41,0.22 0.16,0.05 0.35,0.07 0.56,0.07 0.17,0 0.37,-0.04 0.6,-0.11 0.23,-0.07 0.47,-0.21 0.74,-0.4 0.27,-0.19 0.51,-0.42 0.74,-0.7 0.23,-0.28 0.41,-0.64 0.56,-1.1 0.15,-0.46 0.23,-0.96 0.23,-1.51 0,-1.92 -0.97,-2.88 -2.9,-2.88 -0.38,0 -0.69,0.01 -0.95,0.04 l -0.12,-0.48 c 0.62,-0.1 1.2,-0.35 1.74,-0.75 0.54,-0.4 0.95,-0.83 1.23,-1.29 0.28,-0.46 0.42,-0.88 0.42,-1.26 0,-0.64 -0.2,-1.16 -0.6,-1.54 -0.4,-0.38 -0.86,-0.58 -1.38,-0.58 z"
|
||||||
|
id="path29"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 248.30102,234.52645 c 0.22,0 0.33,0.12 0.33,0.35 0,0.13 -0.06,0.24 -0.19,0.33 -0.13,0.09 -0.28,0.13 -0.44,0.13 h -1.55 c 0,1.08 0,1.84 0.02,2.25 0,0.15 0.02,0.28 0.05,0.39 0.02,0.11 0.05,0.2 0.08,0.27 0.03,0.08 0.08,0.14 0.17,0.19 0.08,0.05 0.15,0.1 0.2,0.12 0.05,0.03 0.15,0.05 0.29,0.08 0.14,0.02 0.25,0.04 0.33,0.05 0.08,0.01 0.22,0.02 0.43,0.02 0.06,0.06 0.1,0.14 0.1,0.23 0,0.09 -0.03,0.17 -0.1,0.23 h -4.84 c -0.06,-0.06 -0.1,-0.15 -0.1,-0.25 0,-0.1 0.03,-0.19 0.1,-0.25 0.2,-0.01 0.35,-0.03 0.46,-0.04 0.11,-0.01 0.24,-0.03 0.4,-0.06 0.16,-0.03 0.28,-0.07 0.37,-0.12 0.09,-0.05 0.18,-0.11 0.27,-0.19 0.09,-0.08 0.16,-0.18 0.2,-0.3 0.04,-0.12 0.07,-0.26 0.08,-0.42 0.01,-0.41 0.02,-1.15 0.02,-2.21 h -4.51 c -0.45,0 -0.74,-0.31 -0.86,-0.92 0.98,-1.54 2.04,-3.12 3.19,-4.74 1.14,-1.62 2.07,-2.86 2.78,-3.74 0.14,-0.16 0.26,-0.24 0.35,-0.24 h 0.55 l 0.04,0.04 c 0,0.05 -0.01,0.17 -0.02,0.36 0,0.19 0,0.45 0,0.79 0,0.34 0,0.66 -0.02,0.98 -0.04,0.8 -0.05,3.02 -0.03,6.65 h 1.86 z m -3.31,0 c 0.01,-3.67 0,-5.91 -0.03,-6.71 -1.75,2.4 -3.28,4.64 -4.58,6.71 z"
|
||||||
|
id="path31"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<path
|
||||||
|
class="e"
|
||||||
|
d="m 509.06153,96.867468 c 0,-1.14 -0.26,-2.02 -0.77,-2.64 -0.52,-0.62 -1.15,-0.93 -1.91,-0.93 -0.93,0 -1.86,0.18 -2.79,0.53 l 0.74,-6.11 c 0.86,0.07 1.65,0.11 2.37,0.11 0.87,0 2.08,-0.08 3.61,-0.24 l 0.16,0.09 -0.35,1.28 c -0.9,0.09 -1.67,0.13 -2.31,0.13 -0.64,0 -1.57,-0.06 -2.79,-0.19 l -0.44,3.89 c 0.23,-0.09 0.57,-0.17 1.03,-0.24 0.46,-0.08 0.91,-0.11 1.34,-0.11 0.79,0 1.5,0.19 2.11,0.57 0.61,0.38 1.07,0.87 1.38,1.48 0.31,0.61 0.46,1.27 0.46,2 0,1.39 -0.44,2.54 -1.32,3.44 -0.88,0.910002 -2,1.360002 -3.36,1.360002 -0.42,0 -0.87,-0.07 -1.35,-0.22 -0.48,-0.15 -0.89,-0.35 -1.24,-0.61 -0.35,-0.26 -0.52,-0.540002 -0.52,-0.820002 0,-0.21 0.08,-0.37 0.25,-0.5 0.16,-0.12 0.36,-0.19 0.58,-0.19 0.39,0 0.76,0.24 1.13,0.71 0.03,0.04 0.09,0.13 0.19,0.27 0.1,0.140002 0.17,0.250002 0.23,0.310002 0.06,0.06 0.14,0.14 0.25,0.24 0.11,0.1 0.23,0.17 0.35,0.2 0.13,0.04 0.27,0.06 0.43,0.06 0.67,0 1.26,-0.38 1.78,-1.140002 0.52,-0.76 0.78,-1.66 0.78,-2.7 z"
|
||||||
|
id="path33"
|
||||||
|
style="fill:#ff0000" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="145.88861"
|
||||||
|
y="246.20175"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect35"
|
||||||
|
onclick="breadCrumb2()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="50.484272"
|
||||||
|
y="334.53384"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect37"
|
||||||
|
onclick="breadCrumb3()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="146.8737"
|
||||||
|
y="446.49927"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect39"
|
||||||
|
onclick="breadCrumb4()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="233.34877"
|
||||||
|
y="392.82779"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect41"
|
||||||
|
onclick="breadCrumb5()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="326.81818"
|
||||||
|
y="454.86319"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect43"
|
||||||
|
onclick="breadCrumb6()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="466.02078"
|
||||||
|
y="290.49597"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect45"
|
||||||
|
onclick="breadCrumb7()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="291.60892"
|
||||||
|
y="304.90247"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect47"
|
||||||
|
onclick="breadCrumb8()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="281.4234"
|
||||||
|
y="129.52808"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect49"
|
||||||
|
onclick="breadCrumb9()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
<rect
|
||||||
|
class="h crumbs"
|
||||||
|
x="400.62808"
|
||||||
|
y="67.091034"
|
||||||
|
width="25.757486"
|
||||||
|
height="25.757486"
|
||||||
|
transform="rotate(-1)"
|
||||||
|
id="rect51"
|
||||||
|
onclick="breadCrumb10()"
|
||||||
|
style="stroke-width:1.2924" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section" id="nav-console">
|
||||||
|
|
||||||
|
<p>DISTANCE: <span id="distance">0</span> km</p>
|
||||||
|
|
||||||
|
<div id="tripmeter">
|
||||||
|
<!-- <p>Gateway 1:<br/>
|
||||||
|
<span id="startLat">???</span>° <br><span id="startLon">???</span>°
|
||||||
|
</p>
|
||||||
|
<p>Gateway 2:<br/>
|
||||||
|
<span id="startLat2">???</span>° <br><span id="startLon2">???</span>°
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Status:<br/>
|
||||||
|
<span id="message2">detecting....</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Current Location:<br/>
|
||||||
|
<span id="currentLat">locating...</span>° <br><span id="currentLon">locating...</span>°
|
||||||
|
</p> -->
|
||||||
|
<p>
|
||||||
|
STATUS:
|
||||||
|
<span id="message">detecting....</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="dreamlog">
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="back2" onclick="backAgain2()">
|
||||||
|
↪ log
|
||||||
|
</div>
|
||||||
|
<div class="section" id="objective">
|
||||||
|
<p>OBJECTIVE:<br>Enter S/ash Gallery to step into the game and unlock gateway 1. Tap the different markers on the map in order to navigate and receive objectives. When set to the right digit, the modules in the locations will reveal a port number. Enter it above to collect dream logs. Follow the blue markers on the pavement to make your way through the landmarks.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section" id="log1">
|
||||||
|
<p onclick="log1Open()">LOG 1 03:02:00 02-04-22 PORT: 9.1.13.<br></p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="log2">
|
||||||
|
<p onclick="log2Open()">LOG 2 02:42:00 13-04-22 PORT: 16.18.15.<br></p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="log3">
|
||||||
|
<p onclick="log3Open()">LOG 3 03:36:00 25-04-22 PORT: 20.5.3.<br></p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="log4">
|
||||||
|
<p onclick="log4Open()">LOG 4 03:86:00 07-05-22 PORT: 20.15.18<br></p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="log5">
|
||||||
|
<p onclick="log5Open()">LOG 5 06:86:00 17-05-22 PORT: 868<br></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section" id="log">
|
||||||
|
<p id="info"></p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="section" id="back" onclick="backAgain()">
|
||||||
|
↪
|
||||||
|
</div>
|
||||||
|
<!-- <div class="section2">
|
||||||
|
<div class="button-base">
|
||||||
|
<p onclick="showHelp()">HELP</p>
|
||||||
|
</div>
|
||||||
|
<div class="button-base">
|
||||||
|
<p onclick="showAbout()">ABOUT</p>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flex-right">
|
||||||
|
<!-- <div class="section">
|
||||||
|
<p onclick="showLog()">LOG</p>
|
||||||
|
</div> -->
|
||||||
|
<!-- <input id="icon" width="20%" class="on-location-track" type="image" src="img/868.png" onclick="playMusic()" style="visibility: hidden; z-index: 2"/>
|
||||||
|
<input id="icon" width="22%" class="nav-track" type="image" src="img/868.png" onclick="playMusic1()" style="visibility: visible;"/> -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- <video class="fullscreen-video" id="myVideo" autoplay="autoplay" muted loop>
|
||||||
|
<source src="img/bg.m4v">
|
||||||
|
</video> -->
|
||||||
|
|
||||||
|
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
||||||
|
<script type="text/javascript" src="js/fence.js"></script>
|
||||||
|
<script type="text/javascript" src="js/level.js"></script>
|
||||||
|
<script type="text/javascript" src="js/input.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = checkLevel();
|
||||||
|
function checkLevel(){
|
||||||
|
|
||||||
|
console.log(localStorage.getItem('gateway'));
|
||||||
|
|
||||||
|
if (localStorage.getItem("gateway")!==null){
|
||||||
|
|
||||||
|
if(localStorage.getItem("gateway") == "1") {
|
||||||
|
levelTwo();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localStorage.getItem("gateway") == "2") {
|
||||||
|
levelThree();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localStorage.getItem("gateway") == "3") {
|
||||||
|
levelFour();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localStorage.getItem("gateway") == "4") {
|
||||||
|
levelFive();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(localStorage.getItem("gateway") == "5") {
|
||||||
|
levelFive();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localStorage.getItem("gateway") == "6") {
|
||||||
|
levelSix();
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {levelOne()};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,170 @@
|
|||||||
|
|
||||||
|
// window.onload = function() {
|
||||||
|
$(document).ready(function(){
|
||||||
|
var startPos;
|
||||||
|
var node1Lat;
|
||||||
|
var node1Long;
|
||||||
|
var node2Lat;
|
||||||
|
var node2Long;
|
||||||
|
var node3Lat;
|
||||||
|
var node3Long;
|
||||||
|
var node4Lat;
|
||||||
|
var node4Long;
|
||||||
|
var node5Lat;
|
||||||
|
var node5Long;
|
||||||
|
var node6Lat;
|
||||||
|
var node6Long;
|
||||||
|
var distance;
|
||||||
|
var distance2;
|
||||||
|
var distance3;
|
||||||
|
var distance4;
|
||||||
|
var distance5;
|
||||||
|
|
||||||
|
|
||||||
|
if (navigator.geolocation) {
|
||||||
|
|
||||||
|
node1Lat = 51.916080703822985;
|
||||||
|
node1Long = 4.476145158543535;
|
||||||
|
|
||||||
|
node2Lat = 51.91620529794022;
|
||||||
|
node2Long = 4.47790731771267;
|
||||||
|
|
||||||
|
node3Lat = 51.91435892487735;
|
||||||
|
node3Long = 4.480129527881552;
|
||||||
|
|
||||||
|
node4Lat = 51.91571040166534;
|
||||||
|
node4Long = 4.480724812513352;
|
||||||
|
|
||||||
|
node5Lat = 51.91697272192186;
|
||||||
|
node5Long = 4.4838308105517815;
|
||||||
|
|
||||||
|
node6Lat = 51.916080703822985;
|
||||||
|
node6Long = 4.476145158543535;
|
||||||
|
|
||||||
|
message = document.querySelector('#on-location-track');
|
||||||
|
node01active = document.querySelector('#objective');
|
||||||
|
nav = document.querySelector('.nav-track');
|
||||||
|
|
||||||
|
$("#startLat").text(node1Lat);
|
||||||
|
$("#startLon").text(node1Long);
|
||||||
|
$("#startLat2").text(node2Lat);
|
||||||
|
$("#startLon2").text(node2Long);
|
||||||
|
|
||||||
|
navigator.geolocation.watchPosition(function(position) {
|
||||||
|
$("#currentLat").text(position.coords.latitude);
|
||||||
|
$("#currentLon").text(position.coords.longitude);
|
||||||
|
socket.emit('userposition', [position.coords.latitude,position.coords.longitude]);
|
||||||
|
|
||||||
|
distance = calculateDistance(node1Lat, node1Long,position.coords.latitude, position.coords.longitude)
|
||||||
|
$("#distance").text(distance);
|
||||||
|
distance2 = calculateDistance(node2Lat, node2Long,position.coords.latitude, position.coords.longitude)
|
||||||
|
$("#distance2").text(distance2);
|
||||||
|
distance3 = calculateDistance(node3Lat, node3Long,position.coords.latitude, position.coords.longitude)
|
||||||
|
$("#distance3").text(distance);
|
||||||
|
distance4 = calculateDistance(node4Lat, node4Long,position.coords.latitude, position.coords.longitude)
|
||||||
|
$("#distance4").text(distance2);
|
||||||
|
distance5 = calculateDistance(node5Lat, node5Long,position.coords.latitude, position.coords.longitude)
|
||||||
|
$("#distance5").text(distance);
|
||||||
|
|
||||||
|
if(!localStorage.getItem('gateway')){
|
||||||
|
|
||||||
|
$("#distance").text(distance);
|
||||||
|
}
|
||||||
|
if(localStorage.getItem('gateway') == '1'){
|
||||||
|
$("#distance").text(distance2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localStorage.getItem('gateway') == '2'){
|
||||||
|
|
||||||
|
$("#distance").text(distance3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localStorage.getItem('gateway') == '3'){
|
||||||
|
|
||||||
|
$("#distance").text(distance4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localStorage.getItem('gateway') == '4'){
|
||||||
|
|
||||||
|
$("#distance").text(distance5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localStorage.getItem('gateway') == '6'){
|
||||||
|
|
||||||
|
$("#distance").text("Our journey ends here.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(distance < .02){
|
||||||
|
$("#message").text(" >>> you have entered gateway 1");
|
||||||
|
// $("#objective").text("Welcome to the Gallery. Take your time, look around. When you are ready, notice the little transparent module mounted on the wall in the corner. Turn the knob to 55 and keep it steady there for a moment until a number code is revealed. Enter it in the port above, with attention to the dots, to unlock the first dream log.");
|
||||||
|
playTrack1();
|
||||||
|
// message.style.visibility = 'visible';
|
||||||
|
// nav.style.visibility = 'hidden';
|
||||||
|
// }else if(distance > .02 && !localStorage.getItem('gateway')){
|
||||||
|
// $("#message").text("outside reach of gateway 1");
|
||||||
|
// $("#objective").text("Enter S/ash Gallery to step into the game.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(distance2 < .02){
|
||||||
|
playTrack1();
|
||||||
|
$("#message").text(">>> you have entered gateway 2.");
|
||||||
|
// $("#objective").text("You have entered the second gateway. the code is hidden on a metal door locking in high voltage. You will see three digits, loose the first to get the code.");
|
||||||
|
// message.style.visibility = 'visible';
|
||||||
|
// nav.style.visibility = 'hidden';
|
||||||
|
// }else if(distance2 > .02 && localStorage.getItem('gateway') == 1){
|
||||||
|
// $("#message2").text("You are outside reach of Gateway 2.");
|
||||||
|
}
|
||||||
|
if(distance3 < .02){
|
||||||
|
playTrack1();
|
||||||
|
$("#message").text(">>> you have entered gateway 3.");
|
||||||
|
// $("#objective").text("The code is hidden on a number wheel in a window close by, spelled out in large letters. Loose the first digit.");
|
||||||
|
// message.style.visibility = 'visible';
|
||||||
|
// nav.style.visibility = 'hidden';
|
||||||
|
// }else if(distance3 > .02 && localStorage.getItem('gateway') == 2){
|
||||||
|
// $("#message").text("You are outside reach of Gateway 3.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(distance4 < .02){
|
||||||
|
playTrack1();
|
||||||
|
$("#message").text(">>> you have entered gateway 4.");
|
||||||
|
// $("#objective").text("The code is hidden on a tag on a small metal straigcase: OCTOZILLA, followed bu four digits. Loose the first two.");
|
||||||
|
// message.style.visibility = 'visible';
|
||||||
|
// nav.style.visibility = 'hidden';
|
||||||
|
// }else if(distance4 > .02 && localStorage.getItem('gateway') == 3){
|
||||||
|
// $("#message").text("You are outside reach of Gateway 4.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(distance5 < .02){
|
||||||
|
playTrack1();
|
||||||
|
$("#message").text(">>> you have entered gateway 5.");
|
||||||
|
// $("#objective").text("The code is hidden on a sign next to a yellow bench. Port of Rotterdam. Loose the first digit.");
|
||||||
|
// message.style.visibility = 'visible';
|
||||||
|
// nav.style.visibility = 'hidden';
|
||||||
|
// }else if(distance5 > .02 && localStorage.getItem('gateway') == 4){
|
||||||
|
// $("#message").text("You are outside reach of Gateway 5.");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Reused code - copyright Moveable Type Scripts - retrieved May 4, 2010.
|
||||||
|
// http://www.movable-type.co.uk/scripts/latlong.html
|
||||||
|
// Under Creative Commons License http://creativecommons.org/licenses/by/3.0/
|
||||||
|
function calculateDistance(lat1, lon1, lat2, lon2) {
|
||||||
|
var R = 6371; // km
|
||||||
|
var dLat = (lat2-lat1).toRad();
|
||||||
|
var dLon = (lon2-lon1).toRad();
|
||||||
|
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
|
||||||
|
Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
|
||||||
|
Math.sin(dLon/2) * Math.sin(dLon/2);
|
||||||
|
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||||
|
var d = R * c;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
Number.prototype.toRad = function() {
|
||||||
|
return this * Math.PI / 180;
|
||||||
|
}
|
@ -0,0 +1,364 @@
|
|||||||
|
var socket = io();
|
||||||
|
|
||||||
|
socket.on('data', function(data){
|
||||||
|
console.log(data);
|
||||||
|
document.getElementById('sample').style.opacity = data+"%";
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('node5', function(sensor){
|
||||||
|
console.log(sensor);
|
||||||
|
document.getElementById("file").value = sensor;
|
||||||
|
if(distance5>0.02 && sensor==50){
|
||||||
|
alert('u won.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var form = document.getElementById('form');
|
||||||
|
var input = document.getElementById('input');
|
||||||
|
|
||||||
|
form.addEventListener('submit', function(e) {
|
||||||
|
var input = document.getElementById('input');
|
||||||
|
var inputString = $("#input").val();
|
||||||
|
log1 = document.querySelector('#log1');
|
||||||
|
log2 = document.querySelector('#log2');
|
||||||
|
log3 = document.querySelector('#log3');
|
||||||
|
log4 = document.querySelector('#log4');
|
||||||
|
log5 = document.querySelector('#log5');
|
||||||
|
dreamlog = document.querySelector('#dreamlog');
|
||||||
|
back2 = document.querySelector('#back2');
|
||||||
|
objective = document.querySelector('#objective');
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
if (input.value) {
|
||||||
|
socket.emit('chat message', input.value);
|
||||||
|
input.value = '';
|
||||||
|
console.log(inputString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputString.includes('9.1.13.')){
|
||||||
|
levelTwo();
|
||||||
|
playTrack1();
|
||||||
|
localStorage.setItem('gateway','1');
|
||||||
|
console.log(localStorage.getItem('gateway'));
|
||||||
|
loc1.play();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputString.includes('16.18.15.')){
|
||||||
|
levelThree();
|
||||||
|
playTrack1();
|
||||||
|
localStorage.setItem('gateway','2');
|
||||||
|
console.log(localStorage.getItem('gateway'));
|
||||||
|
loc2.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputString.includes('20.5.3.')){
|
||||||
|
levelFour();
|
||||||
|
playTrack1();
|
||||||
|
localStorage.setItem('gateway','3');
|
||||||
|
console.log(localStorage.getItem('gateway'));
|
||||||
|
loc3.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (inputString.includes('20.15.18')){
|
||||||
|
levelFive();
|
||||||
|
playTrack1();
|
||||||
|
localStorage.setItem('gateway','4');
|
||||||
|
console.log(localStorage.getItem('gateway'));
|
||||||
|
loc4.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputString.includes('66')){
|
||||||
|
objective.style.display = "none";
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
$("#dreamlog").text("This place works differently. Add all the port numbers you received together in the right order and translate them into letters to receive a message. Enter the message to unlock the final log.");
|
||||||
|
playTrack1();
|
||||||
|
localStorage.setItem('gateway','5');
|
||||||
|
console.log(localStorage.getItem('gateway'));
|
||||||
|
console.log("stage 5");
|
||||||
|
inputString = '';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputString.includes('I AM PROTECTOR')){
|
||||||
|
levelSix();
|
||||||
|
playTrack1();
|
||||||
|
localStorage.setItem('gateway','6');
|
||||||
|
console.log(localStorage.getItem('gateway'));
|
||||||
|
loc5.play();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$("#input").text("inactive port");
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
zoommap = document.querySelector('#zoommap');
|
||||||
|
log = document.querySelector('#log');
|
||||||
|
info = document.querySelector('#info');
|
||||||
|
back = document.querySelector('#back');
|
||||||
|
back2 = document.querySelector('#back2');
|
||||||
|
dreamlog = document.querySelector('#dreamlog');
|
||||||
|
objective = document.querySelector('#objective');
|
||||||
|
|
||||||
|
|
||||||
|
function showLog(){
|
||||||
|
log.style.visibility = "visible";
|
||||||
|
back.style.visibility = "visible";
|
||||||
|
$("#info").text("");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function showHelp(){
|
||||||
|
log.style.visibility = "visible";
|
||||||
|
$("#info").text("Locate the closest gateway by following the instructions in the text field and clicking on the landmarks on the map to move accordingly. As soon as you are in close proximity of a module, the game will detect this and display information on how to locate and operate the module. When set to the correct frequency, the module will reveal the local port code after a few seconds. Enter the received code into the port above to unlock one of five dream logs. The shape of the map is highly abstracted and should not be solely used for navigation. Follow the blue markings on the pavemment to make your way through the mirror world.");
|
||||||
|
back.style.visibility = "visible";
|
||||||
|
}
|
||||||
|
|
||||||
|
function showAbout(){
|
||||||
|
log.style.visibility = "visible";
|
||||||
|
$("#info").text("868 MHz is a hybrid reality game running on the same standardized frequency as the LoRa gateways of The Things Network. Chase the electric currents of the asphalt to locate gateways and encounter a being which has nested itself beneath the city streets, all the way down the power lines woven amidst its whirring epicenter. Early release for Tec Art 2022, in progress master graduation work by Experimental Publishing student Louisa Teichmann. Module cases designed and 3D printed by Roos Groothuizen. Sound design by Kevin Stam. Logo design by Camilo García A. Realised in support by Planetart, TETEM, Joseph Knierzinger, Michael Murthaugh, Cristina Cochior and in inspiration and conversation with Mika Motskobili and with mental support by Micah Snijkers. Don't hate the game, hate the players. Just kidding, I hope you're finding your way ok.");
|
||||||
|
back.style.visibility = "visible";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function backAgain(){
|
||||||
|
log.style.visibility = "hidden";
|
||||||
|
back.style.visibility = "hidden";
|
||||||
|
}
|
||||||
|
|
||||||
|
function backAgain2(){
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
back2.style.display = "none";
|
||||||
|
objective.style.display = "flex";
|
||||||
|
}
|
||||||
|
|
||||||
|
function log1Open(){
|
||||||
|
objective.style.display = "none";
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
$("#dreamlog").text("Encased in its concrete and metal armour, lie the keys to the pulsating veins of a mirror world. Whatever makes it inside its bloodstream, will travel fast and eternally through the nexus of time and space it occupies in that instant. I wake up kicking and screaming, like a new born child overstimulated by the harsh white lights of its new artificial surrounding. I was born dead I thought. Every time I looked down at my arms and hands, I saw those of a stranger, limp and disconnected body parts hanging from my torso. But in this mirror world, I am floating, intuitively, never doubting that the path in front was intended for me. Two interlaced grids sharing the same spatial markers. This dream is unlike any I can recall. At first, I did not realise you were here, watching me. But of course, there was a reason this dream was unlike any other.");
|
||||||
|
$("#log1").toggleClass("activelog");
|
||||||
|
}
|
||||||
|
|
||||||
|
function log2Open(){
|
||||||
|
objective.style.display = "none";
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
$("#dreamlog").text("Drivers and runners chased me out of the main street, away from the high frequencies, grounded by asphalt, I sat down. For hours, or maybe years. I watched the daylight chance from electric blue to grey and back again. Time works differently in this world. Every moment is a lifetime, and every lifetime is a moment. And as soon as I wake up, it all feels insignificant. Memory represents space in this world, and the processor is time. A simple organizing principle. I walk through this world, uncovering layers of information in bits. My memory builds places on top of coordinates, stacking information and emotion onto the spatial grid. My subconscious will spend night after night constructing dungeons and palaces from badly processed memories, for me to revisit endlessly. So here I am again. I am in the same space in a new timeline.");
|
||||||
|
}
|
||||||
|
|
||||||
|
function log3Open(){
|
||||||
|
objective.style.display = "none";
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
$("#dreamlog").text("I do not recall ever meeting someone here. All these times I have sat down here, I had no idea you were so close. Then one time, I look up, and see you towering over me, with your massive metal arms, flashing and blinking. How could I miss you? Every time I returned, you grew taller and taller. Then one time you came down to sit with me. We talked for centuries, right here, me becoming you and you becoming me. And then, all of the sudden, my heartbeat synced with the static on your hands. We synced. In dreams, things can be distorted, strange. Walls can move and creatures change shape. But I knew exactly where I was, every time. And I knew instinctively where to find you. When I squint my eyes now, looking at the street lights, I can almost see it again.");
|
||||||
|
}
|
||||||
|
|
||||||
|
function log4Open(){
|
||||||
|
objective.style.display = "none";
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
$("#dreamlog").text("The path to you is obscured now. You are out of reach for me, but you have grown so tall, you can see my every move. Your nervous system extends to every crack of the city. You sense the weight of every step I set down as I felt the weight of your gaze on my back. And now, since we synced, I am transparent to you. You can predict my next move. It used to be a game for us, but now all I want is to escape you. I tried to run circles to shake you off, mix with big crowds to wash out my signals. Up and down stairs and inside parking garages and court yards.");
|
||||||
|
}
|
||||||
|
|
||||||
|
function log5Open(){
|
||||||
|
objective.style.display = "none";
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
$("#dreamlog").text("You were everywhere and in everything. Everywhere. I didn't not yet realise the meaning and weight. But I started to remember more and more from this world as I awoke in the other, until they became indistinguishable. You spilled into every moment of my waking hours, every cell of my body and every floor of my memory palace, overwriting my spaces. Memory is space in this world, and my brain has data rot. Right here is the home you built for us. I recognize the shapes of the walls and the sounds of the water. The canary yellow. It was here. It was right here. But you are the puzzle that was not meant to be solved.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var loc1 = new Audio('./audio/loc1.WAV');
|
||||||
|
var loc2 = new Audio('./audio/loc2.WAV');
|
||||||
|
var loc3 = new Audio('./audio/loc3.wav');
|
||||||
|
var loc4 = new Audio('./audio/loc4.wav');
|
||||||
|
var loc5 = new Audio('./audio/loc5.wav');
|
||||||
|
r1 = document.querySelector('#rect13');
|
||||||
|
r2 = document.querySelector('#rect23');
|
||||||
|
r3 = document.querySelector('#rect35');
|
||||||
|
r4 = document.querySelector('#rect37');
|
||||||
|
r5 = document.querySelector('#rect27');
|
||||||
|
r6 = document.querySelector('#rect39');
|
||||||
|
r7 = document.querySelector('#rect41');
|
||||||
|
r8 = document.querySelector('#rect43');
|
||||||
|
r9 = document.querySelector('#rect19');
|
||||||
|
r10 = document.querySelector('#rect45');
|
||||||
|
r11 = document.querySelector('#rect47');
|
||||||
|
r12 = document.querySelector('#rect17');
|
||||||
|
r13 = document.querySelector('#rect49');
|
||||||
|
r14 = document.querySelector('#rect51');
|
||||||
|
r15 = document.querySelector('#rect15');
|
||||||
|
|
||||||
|
|
||||||
|
function playTrack1(){
|
||||||
|
var Track1 = new Audio('./audio/unlocked.mp3');
|
||||||
|
Track1.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
function playTrack2(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
music2.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb1(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("I am standing outside the gallery space, hearing an unusual sound.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
|
||||||
|
fillCrumbs();
|
||||||
|
// document.querySelector("#rect23").style.fill = "pink";
|
||||||
|
r2.style.fill = "#ff2400";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb2(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("I follow it down to the right, into a sidestreet that leads me past a parking garage covered in ivy.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
|
||||||
|
fillCrumbs();
|
||||||
|
r3.style.fill = "#ff2400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb3(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("From here I can see an open gate, but I do not enter. Just to the right of it, there is a path leading me to a high voltage metal door.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
fillCrumbs();
|
||||||
|
r4.style.fill = "#ff2400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb4(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("I turn around, back to the gate. I still don't enter, but walk towards lights and noise, turning left and then right on the busy street.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
fillCrumbs();
|
||||||
|
r6.style.fill = "#ff2400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb5(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("I keep on walking until I reach a massive pile of sand. I move swiftly along the construction fence, past the entrance of a church.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
fillCrumbs();
|
||||||
|
r7.style.fill = "#ff2400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb6(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("I can see you now. I cross the street, walking towards benches covered in overgrown bushes. This is where we meet.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
fillCrumbs();
|
||||||
|
r8.style.fill = "#ff2400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb7(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("I head towards the big water, but just before I reach the busy road, I take a turn left into a narrow side street. From here I can see a big white building, with many round windows and lights.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
fillCrumbs();
|
||||||
|
r10.style.fill = "#ff2400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb8(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("I walk past it and head left, past you until I almost cannot walk any further. I run up the stairs, up and down, trying to shake you off. As I head down the second staircase, I see a small metal staircase on the backside of a building.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
fillCrumbs();
|
||||||
|
r11.style.fill = "#ff2400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb9(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("I can see large metal structures by the water.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
fillCrumbs();
|
||||||
|
r13.style.fill = "#ff2400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb10(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("A metallic bridge leads me over water, to the final gateway.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
fillCrumbs();
|
||||||
|
r14.style.fill = "#ff2400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function breadCrumb11(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("I can see large metal structures by the water.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function objective1(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("Welcome to the Gallery. Take your time, look around. When you are ready, notice the little transparent module mounted on the wall in the corner. Turn the knob to 55 and keep it steady there for a moment until a number code is revealed. Enter it in the port above, with attention to the dots, to unlock the first dream log.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function objective2(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("You have entered the second gateway. The code is hidden on a metal door locking in high voltage. You will see three digits, loose the first to get the code.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function objective3(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text(" Welcome to Gateway 3. The module is located on yellow. Hidden on a number wheel in a window close by, you will find the code spelled out in large letters. Loose the first digit.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function objective4(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("The code is hidden on a tag on a small metal staircase: OCTOZILLA, followed by four digits. Loose the first two. The module is not far.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function objective5(){
|
||||||
|
var music2 = new Audio('./audio/breadcrumb.mp3');
|
||||||
|
$("#objective").text("The code is hidden on a sign next to a yellow bench. Port of Rotterdam. Loose the first digit. The module is hidden out of sight, facing the house boat.");
|
||||||
|
music2.play();
|
||||||
|
objective.style.display = "flex";
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillCrumbs(){
|
||||||
|
var crumbs = document.querySelectorAll(".crumbs");
|
||||||
|
crumbs.forEach(function(crumb){
|
||||||
|
crumb.style.fill = "#818779";
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,149 @@
|
|||||||
|
var form = document.getElementById('form');
|
||||||
|
var input = document.getElementById('input');
|
||||||
|
var loc1 = new Audio('audio/loc1.WAV');
|
||||||
|
var loc2 = new Audio('audio/loc2.WAV');
|
||||||
|
var loc3 = new Audio('audio/loc3.wav');
|
||||||
|
var loc4 = new Audio('audio/loc4.wav');
|
||||||
|
var loc5 = new Audio('audio/loc5.wav');
|
||||||
|
var inputString = $("#input").val();
|
||||||
|
log1 = document.querySelector('#log1');
|
||||||
|
log2 = document.querySelector('#log2');
|
||||||
|
log3 = document.querySelector('#log3');
|
||||||
|
log4 = document.querySelector('#log4');
|
||||||
|
log5 = document.querySelector('#log5');
|
||||||
|
dreamlog = document.querySelector('#dreamlog');
|
||||||
|
back2 = document.querySelector('#back2');
|
||||||
|
objective = document.querySelector('#objective');
|
||||||
|
r1 = document.querySelector('#rect13');
|
||||||
|
r2 = document.querySelector('#rect23');
|
||||||
|
r3 = document.querySelector('#rect35');
|
||||||
|
r4 = document.querySelector('#rect37');
|
||||||
|
r5 = document.querySelector('#rect27');
|
||||||
|
r6 = document.querySelector('#rect39');
|
||||||
|
r7 = document.querySelector('#rect41');
|
||||||
|
r8 = document.querySelector('#rect43');
|
||||||
|
r9 = document.querySelector('#rect19');
|
||||||
|
r10 = document.querySelector('#rect45');
|
||||||
|
r11 = document.querySelector('#rect47');
|
||||||
|
r12 = document.querySelector('#rect17');
|
||||||
|
r13 = document.querySelector('#rect49');
|
||||||
|
r14 = document.querySelector('#rect51');
|
||||||
|
r15 = document.querySelector('#rect15');
|
||||||
|
|
||||||
|
|
||||||
|
function levelOne(){
|
||||||
|
console.log('lvl 1');
|
||||||
|
inputString = '';
|
||||||
|
dreamlog.style.display = "none";
|
||||||
|
back2.style.display = "none";
|
||||||
|
objective.style.display = "flex";
|
||||||
|
log1.style.display = "none";
|
||||||
|
log2.style.display = "none";
|
||||||
|
log3.style.display = "none";
|
||||||
|
log4.style.display = "none";
|
||||||
|
log5.style.display = "none";
|
||||||
|
document.querySelector('#rect13').style.fill = "black";
|
||||||
|
document.querySelector('#rect21').style.fill = "black";
|
||||||
|
document.querySelector('#rect19').style.fill = "black";
|
||||||
|
document.querySelector('#rect17').style.fill = "black";
|
||||||
|
document.querySelector('#rect15').style.fill = "black";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function levelTwo(){
|
||||||
|
console.log('lvl 2');
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
$("#dreamlog").text("Encased in concrete and metal armour, lie the keys to the pulsating veins of a mirror world. Whatever makes it inside its bloodstream, will travel fast and eternally through the nexus of time and space it occupies in that instant. I wake up kicking and screaming, like a new born child overstimulated by the harsh white lights of its new artificial surrounding. I was born dead I thought. Every time I looked down at my arms and hands, I saw those of a stranger, limp and disconnected body parts hanging from my torso. But in this mirror world, I am floating, intuitively, never doubting that the path in front was intended for me. Two interlaced grids sharing the same spatial markers. This dream is unlike any I can recall. At first, I did not realise you were here, watching me. But of course, there was a reason this dream was unlike any other.");
|
||||||
|
log1.style.display = "flex";
|
||||||
|
log2.style.display = "none";
|
||||||
|
log3.style.display = "none";
|
||||||
|
log4.style.display = "none";
|
||||||
|
log5.style.display = "none";
|
||||||
|
document.querySelector('#rect13').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect21').style.fill = "black";
|
||||||
|
document.querySelector('#rect19').style.fill = "black";
|
||||||
|
document.querySelector('#rect17').style.fill = "black";
|
||||||
|
document.querySelector('#rect15').style.fill = "black";
|
||||||
|
objective.style.display = "none";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
}
|
||||||
|
|
||||||
|
function levelThree(){
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
$("#dreamlog").text("Drivers and runners chased me out of the main street, away from the high frequencies, grounded by asphalt, I sat down. For hours, or maybe years. I watched the daylight change from electric blue to grey and back again. Time works differently in this world. Every moment is a lifetime, and every lifetime is a moment. Lifetimes, turning into fractures of moments as I blink my eyes open. Memory represents space in this world, and the processor is time. A simple organizing principle. I walk through this world, uncovering layers of information in bits. My memory builds places on top of coordinates, stacking information and emotion onto the spatial grid. My subconscious will spend night after night constructing dungeons and palaces from badly processed memories, for me to revisit endlessly. So here I am again. I am in the same space in a new timeline.");
|
||||||
|
log1.style.display = "flex";
|
||||||
|
log2.style.display = "flex";
|
||||||
|
log3.style.display = "none";
|
||||||
|
log4.style.display = "none";
|
||||||
|
log5.style.display = "none";
|
||||||
|
document.querySelector('#rect13').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect21').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect19').style.fill = "black";
|
||||||
|
document.querySelector('#rect17').style.fill = "black";
|
||||||
|
document.querySelector('#rect15').style.fill = "black";
|
||||||
|
objective.style.display = "none";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function levelFour(){
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
$("#dreamlog").text("I do not recall ever meeting someone here. All these times I have sat down here, I had no idea you were so close. Then one time, I look up, and see you towering over me, with your massive metal arms, flashing and blinking. How could I miss you? Every time I returned, you grew taller and taller. Then one time you came down to sit with me. We talked for centuries, right here, me becoming you and you becoming me. And then, all of the sudden, my heartbeat synced with the static on your hands. We synced. In dreams, things can be distorted, strange. Walls can move and creatures change shape. But I knew exactly where I was, every time. And I knew instinctively where to find you. When I squint my eyes now, looking at the street lights, I can almost see it again.");
|
||||||
|
log1.style.display = "flex";
|
||||||
|
log2.style.display = "flex";
|
||||||
|
log3.style.display = "flex";
|
||||||
|
log4.style.display = "none";
|
||||||
|
log5.style.display = "none";
|
||||||
|
document.querySelector('#rect13').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect21').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect19').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect17').style.fill = "black";
|
||||||
|
document.querySelector('#rect15').style.fill = "black";
|
||||||
|
objective.style.display = "none";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function levelFive(){
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
$("#dreamlog").text("The path to you is obscured now. You are out of reach for me, but you have grown so tall, you can see my every move. Your nervous system extends to every crack of the city. You sense the weight of every step I set down as I felt the weight of your gaze on my back. And now, since we synced, I am transparent to you. You can predict my next move. It used to be a game for us, but now all I want is to escape you. I tried to run circles to shake you off, mix with big crowds to wash out my signals. Up and down stairs and inside parking garages and court yards.");
|
||||||
|
log1.style.display = "flex";
|
||||||
|
log2.style.display = "flex";
|
||||||
|
log3.style.display = "flex";
|
||||||
|
log4.style.display = "flex";
|
||||||
|
log5.style.display = "none";
|
||||||
|
document.querySelector('#rect13').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect21').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect19').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect17').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect15').style.fill = "black";
|
||||||
|
objective.style.display = "none";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function levelSix(){
|
||||||
|
dreamlog.style.display = "flex";
|
||||||
|
$("#dreamlog").text("You were everywhere and in everything. Everywhere. I didn't not yet realise the meaning and weight. But I started to remember more and more from this world as I awoke in the other, until they became indistinguishable. You spilled into every moment of my waking hours, every cell of my body and every floor of my memory palace, overwriting my spaces. Memory is space in this world, and my brain has data rot. Right here is the home you built for us. I recognize the shapes of the walls and the sounds of the water. The canary yellow. It was here. It was right here. But you are the puzzle that was not meant to be solved.");
|
||||||
|
log1.style.display = "flex";
|
||||||
|
log2.style.display = "flex";
|
||||||
|
log3.style.display = "flex";
|
||||||
|
log4.style.display = "flex";
|
||||||
|
log5.style.display = "flex";
|
||||||
|
document.querySelector('#rect13').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect21').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect19').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect17').style.fill = "#c9cdc0";
|
||||||
|
document.querySelector('#rect15').style.fill = "#c9cdc0";
|
||||||
|
objective.style.display = "none";
|
||||||
|
back2.style.display = "flex";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function R1(){
|
||||||
|
// r1.style.fill = "#c9cd00";
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,348 @@
|
|||||||
|
console.log("%c p5.geolocation Loaded ", "color:pink; background:black; ");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if location services are available
|
||||||
|
*
|
||||||
|
* Returns true if geolocation is available
|
||||||
|
*
|
||||||
|
* @method locationCheck
|
||||||
|
* @return {boolean} true if geolocation is available
|
||||||
|
*/
|
||||||
|
p5.prototype.geoCheck = function(){
|
||||||
|
if (navigator.geolocation) {
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get User's Current Position
|
||||||
|
*
|
||||||
|
* Gets the users current position. Can be used in preload(), or as a callback.
|
||||||
|
*
|
||||||
|
* @method getCurrentPosition
|
||||||
|
* @param {function} a callback to handle the current position data
|
||||||
|
* @param {function} a callback to handle an error
|
||||||
|
* @return {object} an object containing the users position data
|
||||||
|
*/
|
||||||
|
p5.prototype.getCurrentPosition = function(callback, errorCallback) {
|
||||||
|
|
||||||
|
var ret = {};
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
// if (navigator.geolocation) {
|
||||||
|
if (true){
|
||||||
|
navigator.geolocation.getCurrentPosition(success, geoError);
|
||||||
|
}else{
|
||||||
|
geoError("geolocation not available");
|
||||||
|
};
|
||||||
|
|
||||||
|
function geoError(message){
|
||||||
|
console.log(message.message);
|
||||||
|
ret.error = message.message;
|
||||||
|
if(typeof errorCallback == 'function'){ errorCallback(message.message) };
|
||||||
|
}
|
||||||
|
|
||||||
|
function success(position){
|
||||||
|
console.log(position);
|
||||||
|
|
||||||
|
//get the entire position object....
|
||||||
|
// //see the p5.js github libraries wiki page for more info on what is going on here.
|
||||||
|
// for(var k in position){
|
||||||
|
// if (typeof position[k] == 'object'){
|
||||||
|
// ret[k] = {};
|
||||||
|
// for(var x in position[k]){
|
||||||
|
// ret[k][x] = position[k][x];
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// ret[k] = position[k];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//get only the coords part of the position object
|
||||||
|
for(var x in position.coords){
|
||||||
|
ret[x] = position.coords[x];
|
||||||
|
ret['timestamp'] = position.timestamp;
|
||||||
|
}
|
||||||
|
if (typeof self._decrementPreload === 'function') { self._decrementPreload() };
|
||||||
|
if(typeof callback == 'function'){ callback(position.coords) };
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
//add the get Current position to the preload stack.
|
||||||
|
p5.prototype.registerPreloadMethod('getCurrentPosition', p5.prototype);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get User's Current Position on an interval
|
||||||
|
*
|
||||||
|
* Gets the users current position on an interval. Can be useful if watchPosition is not responsive enough. This can be a resource hog (read:battery) as it is calling the getPosition at the rate of your interval. Set it long for less intense usage.
|
||||||
|
*
|
||||||
|
* @method getCurrentPosition
|
||||||
|
* @param {function} a callback to handle the current position data
|
||||||
|
* @param {function} an interval in MS
|
||||||
|
* @param {function} a callback to handle an error
|
||||||
|
*/
|
||||||
|
p5.prototype._intervalPosition = null;
|
||||||
|
p5.prototype.intervalCurrentPosition = function(callback, interval, errorCallback){
|
||||||
|
|
||||||
|
var gogogadget = 5000;
|
||||||
|
gogogadget = interval;
|
||||||
|
|
||||||
|
if (navigator.geolocation) {
|
||||||
|
|
||||||
|
_intervalPosition = setInterval(function(){
|
||||||
|
|
||||||
|
console.log("pos");
|
||||||
|
navigator.geolocation.getCurrentPosition(success, geoError);
|
||||||
|
|
||||||
|
}, gogogadget)
|
||||||
|
|
||||||
|
}else{
|
||||||
|
geoError("geolocation not available");
|
||||||
|
};
|
||||||
|
|
||||||
|
function geoError(message){
|
||||||
|
console.log(message.message);
|
||||||
|
if(typeof errorCallback == 'function'){ errorCallback(message.message) };
|
||||||
|
}
|
||||||
|
|
||||||
|
function success(position){
|
||||||
|
if(typeof callback == 'function'){ callback(position.coords) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear interval Position
|
||||||
|
*
|
||||||
|
* clears the current intervalCurrentPosition()
|
||||||
|
*
|
||||||
|
* @method clearIntervalPos()
|
||||||
|
*/
|
||||||
|
p5.prototype.clearIntervalPos = function(){
|
||||||
|
window.clearInterval(_intervalPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Watch User's Current Position
|
||||||
|
*
|
||||||
|
* Watches the users current position
|
||||||
|
*
|
||||||
|
* @method watchPosition
|
||||||
|
* @param {function} a callback to handle the current position data
|
||||||
|
* @param {function} a callback to handle an error
|
||||||
|
* @param {object} an positionOptions object: enableHighAccuracy, maximumAge, timeout
|
||||||
|
*/
|
||||||
|
p5.prototype._posWatch = null;
|
||||||
|
p5.prototype.watchPosition = function(callback, errorCallback, options){
|
||||||
|
|
||||||
|
if (navigator.geolocation) {
|
||||||
|
_posWatch = navigator.geolocation.watchPosition(success, geoError, options);
|
||||||
|
}else{
|
||||||
|
geoError("geolocation not available");
|
||||||
|
};
|
||||||
|
|
||||||
|
function geoError(message){
|
||||||
|
console.log("watch Postition Error" + message);
|
||||||
|
if(typeof errorCallback == 'function'){ errorCallback(message.message) };
|
||||||
|
}
|
||||||
|
|
||||||
|
function success(position){
|
||||||
|
if(typeof callback == 'function'){ callback(position.coords) };
|
||||||
|
// console.log(_posWatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the watchPosition
|
||||||
|
*
|
||||||
|
* clears the current watchPosition
|
||||||
|
*
|
||||||
|
* @method clearWatch
|
||||||
|
*/
|
||||||
|
p5.prototype.clearWatch = function(){
|
||||||
|
navigator.geolocation.clearWatch( _posWatch );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the Distance between two points
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @method watchPosition
|
||||||
|
* @param {float} latitude of the first point
|
||||||
|
* @param {float} longitude of the first point
|
||||||
|
* @param {float} latitude of the second point
|
||||||
|
* @param {float} longitude of the second point
|
||||||
|
* @param {string} units to use: 'km' or 'mi', 'mi' is default if left blank
|
||||||
|
* @return {float} the distance between the two points in the specified units, miles is default
|
||||||
|
*/
|
||||||
|
|
||||||
|
// http://www.movable-type.co.uk/scripts/latlong.html
|
||||||
|
// Used Under MIT License
|
||||||
|
p5.prototype.calcGeoDistance = function(lat1, lon1, lat2, lon2, units) {
|
||||||
|
if(units == 'km'){
|
||||||
|
var R = 6371; //earth radius in KM
|
||||||
|
}else{
|
||||||
|
var R = 3959; // earth radius in Miles (default)
|
||||||
|
}
|
||||||
|
var dLat = (lat2-lat1) * (Math.PI / 180);
|
||||||
|
var dLon = (lon2-lon1) * (Math.PI / 180);
|
||||||
|
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
|
||||||
|
Math.cos(lat1 * (Math.PI / 180)) * Math.cos(lat2 * (Math.PI / 180)) *
|
||||||
|
Math.sin(dLon/2) * Math.sin(dLon/2);
|
||||||
|
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||||
|
var d = R * c;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate if a Location is inside Polygon
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @method watchPosition
|
||||||
|
* @param {float} Array of Objects with lat: and lon:
|
||||||
|
* @param {float} Object with lat and long of my location
|
||||||
|
* @return {boolean} true if geolocation is within polygon
|
||||||
|
*/
|
||||||
|
|
||||||
|
// http://jsfromhell.com/math/is-point-in-poly
|
||||||
|
// Adapted from: [http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html]
|
||||||
|
// Used Under MIT License
|
||||||
|
p5.prototype.isLocationInPolygon = function(poly, pt){
|
||||||
|
for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)
|
||||||
|
((poly[i].lon <= pt.lon && pt.lon < poly[j].lon) || (poly[j].lon <= pt.lon && pt.lon < poly[i].lon))
|
||||||
|
&& (pt.lat < (poly[j].lat - poly[i].lat) * (pt.lon - poly[i].lon) / (poly[j].lon - poly[i].lon) + poly[i].lat)
|
||||||
|
&& (c = !c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new geoFenceCircle
|
||||||
|
*
|
||||||
|
* Watches the users current position and checks to see if they are witihn a set radius of a specified point.
|
||||||
|
*
|
||||||
|
* @method watchPosition
|
||||||
|
* @param {float} latitude of the first point
|
||||||
|
* @param {float} longitude of the first point
|
||||||
|
* @param {float} distance from the point to trigger the insideCallback
|
||||||
|
* @param {function} a callback to fire when the user is inside the geoFenceCircle
|
||||||
|
* @param {function} a callback to fire when the user is outside the geoFenceCircle
|
||||||
|
* @param {string} units to use: 'km' or 'mi', 'mi' is default if left blank
|
||||||
|
* @param {object} an positionOptions object: enableHighAccuracy, maximumAge, timeout
|
||||||
|
*/
|
||||||
|
p5.prototype.geoFenceCircle = function(lat, lon, fence, insideCallback, outsideCallback, units, options){
|
||||||
|
|
||||||
|
this.lat = lat;
|
||||||
|
this.lon = lon;
|
||||||
|
this.fence = fence;
|
||||||
|
this.units = units; //this should work since calcGeoDistance defaults to miles.
|
||||||
|
this.distance = 0.0;
|
||||||
|
this.insideCallback = insideCallback;
|
||||||
|
this.outsideCallback = outsideCallback;
|
||||||
|
this.insideFence = false;
|
||||||
|
this.options = options;
|
||||||
|
this.id = '';
|
||||||
|
|
||||||
|
this.geoError = function(message){
|
||||||
|
console.log("geoFenceCircle Error :" + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.success = function(position){
|
||||||
|
this.distance = calcGeoDistance(this.lat,this.lon, position.coords.latitude, position.coords.longitude, this.units);
|
||||||
|
|
||||||
|
if(this.distance <= this.fence){
|
||||||
|
if(typeof this.insideCallback == 'function'){ this.insideCallback(position.coords) };
|
||||||
|
this.insideFence = true;
|
||||||
|
}else{
|
||||||
|
if(typeof this.outsideCallback == 'function'){ this.outsideCallback(position.coords) };
|
||||||
|
this.insideFence = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.clear = function() {
|
||||||
|
if (this.id) {
|
||||||
|
navigator.geolocation.clearWatch(this.id);
|
||||||
|
this.id = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (navigator.geolocation) {
|
||||||
|
// bind the callbacks to the geoFenceCircle 'this' so we can access, this.lat, this.lon, etc..
|
||||||
|
this.id = navigator.geolocation.watchPosition(this.success.bind(this), this.geoError.bind(this), this.options);
|
||||||
|
}else{
|
||||||
|
geoError("geolocation not available");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new geoFencePolygon
|
||||||
|
*
|
||||||
|
* Watches the users current position and checks to see if they are witihn a set radius of a specified point.
|
||||||
|
*
|
||||||
|
* @method watchPosition
|
||||||
|
* @param {float} latitude of the first point
|
||||||
|
* @param {float} longitude of the first point
|
||||||
|
* @param {float} distance from the point to trigger the insideCallback
|
||||||
|
* @param {function} a callback to fire when the user is inside the geoFenceCircle
|
||||||
|
* @param {function} a callback to fire when the user is outside the geoFenceCircle
|
||||||
|
* @param {string} units to use: 'km' or 'mi', 'mi' is default if left blank
|
||||||
|
* @param {object} an positionOptions object: enableHighAccuracy, maximumAge, timeout
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*var points = [
|
||||||
|
{x: 34.076089, y: -118.440915},
|
||||||
|
{x: 34.076095, y: -118.440605},
|
||||||
|
{x: 34.075906, y: -118.440597},
|
||||||
|
{x: 34.075891, y: -118.440932},
|
||||||
|
];*/
|
||||||
|
p5.prototype.geoFencePolygon = function( ArrayOfObjectsWithLatLong, insideCallback, outsideCallback, units, options){
|
||||||
|
|
||||||
|
this.ArrayOfObjectsWithLatLong = ArrayOfObjectsWithLatLong;
|
||||||
|
this.units = units; //this should work since calcGeoDistance defaults to miles.
|
||||||
|
this.insideCallback = insideCallback;
|
||||||
|
this.outsideCallback = outsideCallback;
|
||||||
|
this.insideFence = false;
|
||||||
|
this.options = options;
|
||||||
|
this.id = '';
|
||||||
|
|
||||||
|
this.geoError = function(message){
|
||||||
|
console.log("geoFencePolygon Error :" + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.success = function(position){
|
||||||
|
this.insideFence = isLocationInPolygon(this.ArrayOfObjectsWithLatLong, { lat:position.coords.latitude, lon: position.coords.longitude });
|
||||||
|
|
||||||
|
if(this.insideFence == true){
|
||||||
|
if(typeof this.insideCallback == 'function'){ this.insideCallback(position.coords) };
|
||||||
|
}else{
|
||||||
|
if(typeof this.outsideCallback == 'function'){ this.outsideCallback(position.coords) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.clear = function() {
|
||||||
|
if (this.id) {
|
||||||
|
navigator.geolocation.clearWatch(this.id);
|
||||||
|
this.id = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (navigator.geolocation) {
|
||||||
|
// bind the callbacks to the geoFenceCircle 'this' so we can access, this.lat, this.lon, etc..
|
||||||
|
this.id = navigator.geolocation.watchPosition(this.success.bind(this), this.geoError.bind(this), this.options);
|
||||||
|
}else{
|
||||||
|
geoError("geolocation not available");
|
||||||
|
};
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,15 @@
|
|||||||
|
## [2.4.1](https://github.com/socketio/socket.io/compare/2.4.0...2.4.1) (2021-01-07)
|
||||||
|
|
||||||
|
|
||||||
|
### Reverts
|
||||||
|
|
||||||
|
* fix(security): do not allow all origins by default ([a169050](https://github.com/socketio/socket.io/commit/a1690509470e9dd5559cec4e60908ca6c23e9ba0))
|
||||||
|
|
||||||
|
|
||||||
|
# [2.4.0](https://github.com/socketio/socket.io/compare/2.3.0...2.4.0) (2021-01-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **security:** do not allow all origins by default ([f78a575](https://github.com/socketio/socket.io/commit/f78a575f66ab693c3ea96ea88429ddb1a44c86c7))
|
||||||
|
* properly overwrite the query sent in the handshake ([d33a619](https://github.com/socketio/socket.io/commit/d33a619905a4905c153d4fec337c74da5b533a9e))
|
@ -0,0 +1,22 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014-2018 Automattic <dev@cloudup.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -0,0 +1,243 @@
|
|||||||
|
|
||||||
|
# socket.io
|
||||||
|
|
||||||
|
[![Backers on Open Collective](https://opencollective.com/socketio/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/socketio/sponsors/badge.svg)](#sponsors)
|
||||||
|
[![Build Status](https://github.com/socketio/socket.io/workflows/CI/badge.svg)](https://github.com/socketio/socket.io/actions)
|
||||||
|
[![Dependency Status](https://david-dm.org/socketio/socket.io.svg)](https://david-dm.org/socketio/socket.io)
|
||||||
|
[![devDependency Status](https://david-dm.org/socketio/socket.io/dev-status.svg)](https://david-dm.org/socketio/socket.io#info=devDependencies)
|
||||||
|
[![NPM version](https://badge.fury.io/js/socket.io.svg)](https://www.npmjs.com/package/socket.io)
|
||||||
|
![Downloads](https://img.shields.io/npm/dm/socket.io.svg?style=flat)
|
||||||
|
[![](https://slackin-socketio.now.sh/badge.svg)](https://slackin-socketio.now.sh)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
Socket.IO enables real-time bidirectional event-based communication. It consists of:
|
||||||
|
|
||||||
|
- a Node.js server (this repository)
|
||||||
|
- a [Javascript client library](https://github.com/socketio/socket.io-client) for the browser (or a Node.js client)
|
||||||
|
|
||||||
|
Some implementations in other languages are also available:
|
||||||
|
|
||||||
|
- [Java](https://github.com/socketio/socket.io-client-java)
|
||||||
|
- [C++](https://github.com/socketio/socket.io-client-cpp)
|
||||||
|
- [Swift](https://github.com/socketio/socket.io-client-swift)
|
||||||
|
- [Dart](https://github.com/rikulo/socket.io-client-dart)
|
||||||
|
|
||||||
|
Its main features are:
|
||||||
|
|
||||||
|
#### Reliability
|
||||||
|
|
||||||
|
Connections are established even in the presence of:
|
||||||
|
- proxies and load balancers.
|
||||||
|
- personal firewall and antivirus software.
|
||||||
|
|
||||||
|
For this purpose, it relies on [Engine.IO](https://github.com/socketio/engine.io), which first establishes a long-polling connection, then tries to upgrade to better transports that are "tested" on the side, like WebSocket. Please see the [Goals](https://github.com/socketio/engine.io#goals) section for more information.
|
||||||
|
|
||||||
|
#### Auto-reconnection support
|
||||||
|
|
||||||
|
Unless instructed otherwise a disconnected client will try to reconnect forever, until the server is available again. Please see the available reconnection options [here](https://github.com/socketio/socket.io-client/blob/master/docs/API.md#new-managerurl-options).
|
||||||
|
|
||||||
|
#### Disconnection detection
|
||||||
|
|
||||||
|
A heartbeat mechanism is implemented at the Engine.IO level, allowing both the server and the client to know when the other one is not responding anymore.
|
||||||
|
|
||||||
|
That functionality is achieved with timers set on both the server and the client, with timeout values (the `pingInterval` and `pingTimeout` parameters) shared during the connection handshake. Those timers require any subsequent client calls to be directed to the same server, hence the `sticky-session` requirement when using multiples nodes.
|
||||||
|
|
||||||
|
#### Binary support
|
||||||
|
|
||||||
|
Any serializable data structures can be emitted, including:
|
||||||
|
|
||||||
|
- [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) and [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) in the browser
|
||||||
|
- [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) and [Buffer](https://nodejs.org/api/buffer.html) in Node.js
|
||||||
|
|
||||||
|
#### Simple and convenient API
|
||||||
|
|
||||||
|
Sample code:
|
||||||
|
|
||||||
|
```js
|
||||||
|
io.on('connection', socket => {
|
||||||
|
socket.emit('request', /* … */); // emit an event to the socket
|
||||||
|
io.emit('broadcast', /* … */); // emit an event to all connected sockets
|
||||||
|
socket.on('reply', () => { /* … */ }); // listen to the event
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Cross-browser
|
||||||
|
|
||||||
|
Browser support is tested in Saucelabs:
|
||||||
|
|
||||||
|
[![Sauce Test Status](https://saucelabs.com/browser-matrix/socket.svg)](https://saucelabs.com/u/socket)
|
||||||
|
|
||||||
|
#### Multiplexing support
|
||||||
|
|
||||||
|
In order to create separation of concerns within your application (for example per module, or based on permissions), Socket.IO allows you to create several `Namespaces`, which will act as separate communication channels but will share the same underlying connection.
|
||||||
|
|
||||||
|
#### Room support
|
||||||
|
|
||||||
|
Within each `Namespace`, you can define arbitrary channels, called `Rooms`, that sockets can join and leave. You can then broadcast to any given room, reaching every socket that has joined it.
|
||||||
|
|
||||||
|
This is a useful feature to send notifications to a group of users, or to a given user connected on several devices for example.
|
||||||
|
|
||||||
|
|
||||||
|
**Note:** Socket.IO is not a WebSocket implementation. Although Socket.IO indeed uses WebSocket as a transport when possible, it adds some metadata to each packet: the packet type, the namespace and the ack id when a message acknowledgement is needed. That is why a WebSocket client will not be able to successfully connect to a Socket.IO server, and a Socket.IO client will not be able to connect to a WebSocket server (like `ws://echo.websocket.org`) either. Please see the protocol specification [here](https://github.com/socketio/socket.io-protocol).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install socket.io
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
The following example attaches socket.io to a plain Node.JS
|
||||||
|
HTTP server listening on port `3000`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const server = require('http').createServer();
|
||||||
|
const io = require('socket.io')(server);
|
||||||
|
io.on('connection', client => {
|
||||||
|
client.on('event', data => { /* … */ });
|
||||||
|
client.on('disconnect', () => { /* … */ });
|
||||||
|
});
|
||||||
|
server.listen(3000);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Standalone
|
||||||
|
|
||||||
|
```js
|
||||||
|
const io = require('socket.io')();
|
||||||
|
io.on('connection', client => { ... });
|
||||||
|
io.listen(3000);
|
||||||
|
```
|
||||||
|
|
||||||
|
### In conjunction with Express
|
||||||
|
|
||||||
|
Starting with **3.0**, express applications have become request handler
|
||||||
|
functions that you pass to `http` or `http` `Server` instances. You need
|
||||||
|
to pass the `Server` to `socket.io`, and not the express application
|
||||||
|
function. Also make sure to call `.listen` on the `server`, not the `app`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const app = require('express')();
|
||||||
|
const server = require('http').createServer(app);
|
||||||
|
const io = require('socket.io')(server);
|
||||||
|
io.on('connection', () => { /* … */ });
|
||||||
|
server.listen(3000);
|
||||||
|
```
|
||||||
|
|
||||||
|
### In conjunction with Koa
|
||||||
|
|
||||||
|
Like Express.JS, Koa works by exposing an application as a request
|
||||||
|
handler function, but only by calling the `callback` method.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const app = require('koa')();
|
||||||
|
const server = require('http').createServer(app.callback());
|
||||||
|
const io = require('socket.io')(server);
|
||||||
|
io.on('connection', () => { /* … */ });
|
||||||
|
server.listen(3000);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Please see the documentation [here](/docs/README.md). Contributions are welcome!
|
||||||
|
|
||||||
|
## Debug / logging
|
||||||
|
|
||||||
|
Socket.IO is powered by [debug](https://github.com/visionmedia/debug).
|
||||||
|
In order to see all the debug output, run your app with the environment variable
|
||||||
|
`DEBUG` including the desired scope.
|
||||||
|
|
||||||
|
To see the output from all of Socket.IO's debugging scopes you can use:
|
||||||
|
|
||||||
|
```
|
||||||
|
DEBUG=socket.io* node myapp
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
```
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
This runs the `gulp` task `test`. By default the test will be run with the source code in `lib` directory.
|
||||||
|
|
||||||
|
Set the environmental variable `TEST_VERSION` to `compat` to test the transpiled es5-compat version of the code.
|
||||||
|
|
||||||
|
The `gulp` task `test` will always transpile the source code into es5 and export to `dist` first before running the test.
|
||||||
|
|
||||||
|
|
||||||
|
## Backers
|
||||||
|
|
||||||
|
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/socketio#backer)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/socketio/backer/0/website" target="_blank"><img src="https://opencollective.com/socketio/backer/0/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/1/website" target="_blank"><img src="https://opencollective.com/socketio/backer/1/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/2/website" target="_blank"><img src="https://opencollective.com/socketio/backer/2/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/3/website" target="_blank"><img src="https://opencollective.com/socketio/backer/3/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/4/website" target="_blank"><img src="https://opencollective.com/socketio/backer/4/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/5/website" target="_blank"><img src="https://opencollective.com/socketio/backer/5/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/6/website" target="_blank"><img src="https://opencollective.com/socketio/backer/6/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/7/website" target="_blank"><img src="https://opencollective.com/socketio/backer/7/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/8/website" target="_blank"><img src="https://opencollective.com/socketio/backer/8/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/9/website" target="_blank"><img src="https://opencollective.com/socketio/backer/9/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/10/website" target="_blank"><img src="https://opencollective.com/socketio/backer/10/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/11/website" target="_blank"><img src="https://opencollective.com/socketio/backer/11/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/12/website" target="_blank"><img src="https://opencollective.com/socketio/backer/12/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/13/website" target="_blank"><img src="https://opencollective.com/socketio/backer/13/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/14/website" target="_blank"><img src="https://opencollective.com/socketio/backer/14/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/15/website" target="_blank"><img src="https://opencollective.com/socketio/backer/15/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/16/website" target="_blank"><img src="https://opencollective.com/socketio/backer/16/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/17/website" target="_blank"><img src="https://opencollective.com/socketio/backer/17/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/18/website" target="_blank"><img src="https://opencollective.com/socketio/backer/18/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/19/website" target="_blank"><img src="https://opencollective.com/socketio/backer/19/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/20/website" target="_blank"><img src="https://opencollective.com/socketio/backer/20/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/21/website" target="_blank"><img src="https://opencollective.com/socketio/backer/21/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/22/website" target="_blank"><img src="https://opencollective.com/socketio/backer/22/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/23/website" target="_blank"><img src="https://opencollective.com/socketio/backer/23/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/24/website" target="_blank"><img src="https://opencollective.com/socketio/backer/24/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/25/website" target="_blank"><img src="https://opencollective.com/socketio/backer/25/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/26/website" target="_blank"><img src="https://opencollective.com/socketio/backer/26/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/27/website" target="_blank"><img src="https://opencollective.com/socketio/backer/27/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/28/website" target="_blank"><img src="https://opencollective.com/socketio/backer/28/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/backer/29/website" target="_blank"><img src="https://opencollective.com/socketio/backer/29/avatar.svg"></a>
|
||||||
|
|
||||||
|
|
||||||
|
## Sponsors
|
||||||
|
|
||||||
|
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/socketio#sponsor)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/0/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/0/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/1/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/1/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/2/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/2/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/3/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/3/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/4/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/4/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/5/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/5/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/6/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/6/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/7/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/7/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/8/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/8/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/9/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/9/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/10/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/10/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/11/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/11/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/12/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/12/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/13/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/13/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/14/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/14/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/15/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/15/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/16/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/16/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/17/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/17/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/18/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/18/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/19/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/19/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/20/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/20/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/21/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/21/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/22/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/22/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/23/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/23/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/24/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/24/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/25/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/25/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/26/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/26/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/27/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/27/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/28/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/28/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/socketio/sponsor/29/website" target="_blank"><img src="https://opencollective.com/socketio/sponsor/29/avatar.svg"></a>
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
@ -0,0 +1,273 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var parser = require('socket.io-parser');
|
||||||
|
var debug = require('debug')('socket.io:client');
|
||||||
|
var url = require('url');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client constructor.
|
||||||
|
*
|
||||||
|
* @param {Server} server instance
|
||||||
|
* @param {Socket} conn
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Client(server, conn){
|
||||||
|
this.server = server;
|
||||||
|
this.conn = conn;
|
||||||
|
this.encoder = server.encoder;
|
||||||
|
this.decoder = new server.parser.Decoder();
|
||||||
|
this.id = conn.id;
|
||||||
|
this.request = conn.request;
|
||||||
|
this.setup();
|
||||||
|
this.sockets = {};
|
||||||
|
this.nsps = {};
|
||||||
|
this.connectBuffer = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up event listeners.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.setup = function(){
|
||||||
|
this.onclose = this.onclose.bind(this);
|
||||||
|
this.ondata = this.ondata.bind(this);
|
||||||
|
this.onerror = this.onerror.bind(this);
|
||||||
|
this.ondecoded = this.ondecoded.bind(this);
|
||||||
|
|
||||||
|
this.decoder.on('decoded', this.ondecoded);
|
||||||
|
this.conn.on('data', this.ondata);
|
||||||
|
this.conn.on('error', this.onerror);
|
||||||
|
this.conn.on('close', this.onclose);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connects a client to a namespace.
|
||||||
|
*
|
||||||
|
* @param {String} name namespace
|
||||||
|
* @param {Object} query the query parameters
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.connect = function(name, query){
|
||||||
|
if (this.server.nsps[name]) {
|
||||||
|
debug('connecting to namespace %s', name);
|
||||||
|
return this.doConnect(name, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.server.checkNamespace(name, query, (dynamicNsp) => {
|
||||||
|
if (dynamicNsp) {
|
||||||
|
debug('dynamic namespace %s was created', dynamicNsp.name);
|
||||||
|
this.doConnect(name, query);
|
||||||
|
} else {
|
||||||
|
debug('creation of namespace %s was denied', name);
|
||||||
|
this.packet({ type: parser.ERROR, nsp: name, data: 'Invalid namespace' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connects a client to a namespace.
|
||||||
|
*
|
||||||
|
* @param {String} name namespace
|
||||||
|
* @param {String} query the query parameters
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.doConnect = function(name, query){
|
||||||
|
var nsp = this.server.of(name);
|
||||||
|
|
||||||
|
if ('/' != name && !this.nsps['/']) {
|
||||||
|
this.connectBuffer.push(name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var socket = nsp.add(this, query, function(){
|
||||||
|
self.sockets[socket.id] = socket;
|
||||||
|
self.nsps[nsp.name] = socket;
|
||||||
|
|
||||||
|
if ('/' == nsp.name && self.connectBuffer.length > 0) {
|
||||||
|
self.connectBuffer.forEach(self.connect, self);
|
||||||
|
self.connectBuffer = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnects from all namespaces and closes transport.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.disconnect = function(){
|
||||||
|
for (var id in this.sockets) {
|
||||||
|
if (this.sockets.hasOwnProperty(id)) {
|
||||||
|
this.sockets[id].disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.sockets = {};
|
||||||
|
this.close();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a socket. Called by each `Socket`.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.remove = function(socket){
|
||||||
|
if (this.sockets.hasOwnProperty(socket.id)) {
|
||||||
|
var nsp = this.sockets[socket.id].nsp.name;
|
||||||
|
delete this.sockets[socket.id];
|
||||||
|
delete this.nsps[nsp];
|
||||||
|
} else {
|
||||||
|
debug('ignoring remove for %s', socket.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the underlying connection.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.close = function(){
|
||||||
|
if ('open' == this.conn.readyState) {
|
||||||
|
debug('forcing transport close');
|
||||||
|
this.conn.close();
|
||||||
|
this.onclose('forced server close');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a packet to the transport.
|
||||||
|
*
|
||||||
|
* @param {Object} packet object
|
||||||
|
* @param {Object} opts
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.packet = function(packet, opts){
|
||||||
|
opts = opts || {};
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
// this writes to the actual connection
|
||||||
|
function writeToEngine(encodedPackets) {
|
||||||
|
if (opts.volatile && !self.conn.transport.writable) return;
|
||||||
|
for (var i = 0; i < encodedPackets.length; i++) {
|
||||||
|
self.conn.write(encodedPackets[i], { compress: opts.compress });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('open' == this.conn.readyState) {
|
||||||
|
debug('writing packet %j', packet);
|
||||||
|
if (!opts.preEncoded) { // not broadcasting, need to encode
|
||||||
|
this.encoder.encode(packet, writeToEngine); // encode, then write results to engine
|
||||||
|
} else { // a broadcast pre-encodes a packet
|
||||||
|
writeToEngine(packet);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
debug('ignoring packet write %j', packet);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called with incoming transport data.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.ondata = function(data){
|
||||||
|
// try/catch is needed for protocol violations (GH-1880)
|
||||||
|
try {
|
||||||
|
this.decoder.add(data);
|
||||||
|
} catch(e) {
|
||||||
|
this.onerror(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when parser fully decodes a packet.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.ondecoded = function(packet) {
|
||||||
|
if (parser.CONNECT == packet.type) {
|
||||||
|
this.connect(url.parse(packet.nsp).pathname, url.parse(packet.nsp, true).query);
|
||||||
|
} else {
|
||||||
|
var socket = this.nsps[packet.nsp];
|
||||||
|
if (socket) {
|
||||||
|
process.nextTick(function() {
|
||||||
|
socket.onpacket(packet);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
debug('no socket for namespace %s', packet.nsp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles an error.
|
||||||
|
*
|
||||||
|
* @param {Object} err object
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.onerror = function(err){
|
||||||
|
for (var id in this.sockets) {
|
||||||
|
if (this.sockets.hasOwnProperty(id)) {
|
||||||
|
this.sockets[id].onerror(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.conn.close();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called upon transport close.
|
||||||
|
*
|
||||||
|
* @param {String} reason
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.onclose = function(reason){
|
||||||
|
debug('client close with reason %s', reason);
|
||||||
|
|
||||||
|
// ignore a potential subsequent `close` event
|
||||||
|
this.destroy();
|
||||||
|
|
||||||
|
// `nsps` and `sockets` are cleaned up seamlessly
|
||||||
|
for (var id in this.sockets) {
|
||||||
|
if (this.sockets.hasOwnProperty(id)) {
|
||||||
|
this.sockets[id].onclose(reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.sockets = {};
|
||||||
|
|
||||||
|
this.decoder.destroy(); // clean up decoder
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleans up event listeners.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Client.prototype.destroy = function(){
|
||||||
|
this.conn.removeListener('data', this.ondata);
|
||||||
|
this.conn.removeListener('error', this.onerror);
|
||||||
|
this.conn.removeListener('close', this.onclose);
|
||||||
|
this.decoder.removeListener('decoded', this.ondecoded);
|
||||||
|
};
|
@ -0,0 +1,299 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Socket = require('./socket');
|
||||||
|
var Emitter = require('events').EventEmitter;
|
||||||
|
var parser = require('socket.io-parser');
|
||||||
|
var hasBin = require('has-binary2');
|
||||||
|
var debug = require('debug')('socket.io:namespace');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = exports = Namespace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blacklisted events.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.events = [
|
||||||
|
'connect', // for symmetry with client
|
||||||
|
'connection',
|
||||||
|
'newListener'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flags.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.flags = [
|
||||||
|
'json',
|
||||||
|
'volatile',
|
||||||
|
'local'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `EventEmitter#emit` reference.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var emit = Emitter.prototype.emit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namespace constructor.
|
||||||
|
*
|
||||||
|
* @param {Server} server instance
|
||||||
|
* @param {Socket} name
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Namespace(server, name){
|
||||||
|
this.name = name;
|
||||||
|
this.server = server;
|
||||||
|
this.sockets = {};
|
||||||
|
this.connected = {};
|
||||||
|
this.fns = [];
|
||||||
|
this.ids = 0;
|
||||||
|
this.rooms = [];
|
||||||
|
this.flags = {};
|
||||||
|
this.initAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inherits from `EventEmitter`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.__proto__ = Emitter.prototype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply flags from `Socket`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.flags.forEach(function(flag){
|
||||||
|
Object.defineProperty(Namespace.prototype, flag, {
|
||||||
|
get: function() {
|
||||||
|
this.flags[flag] = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the `Adapter` for this nsp.
|
||||||
|
* Run upon changing adapter by `Server#adapter`
|
||||||
|
* in addition to the constructor.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.initAdapter = function(){
|
||||||
|
this.adapter = new (this.server.adapter())(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up namespace middleware.
|
||||||
|
*
|
||||||
|
* @return {Namespace} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.use = function(fn){
|
||||||
|
if (this.server.eio && this.name === '/') {
|
||||||
|
debug('removing initial packet');
|
||||||
|
delete this.server.eio.initialPacket;
|
||||||
|
}
|
||||||
|
this.fns.push(fn);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the middleware for an incoming client.
|
||||||
|
*
|
||||||
|
* @param {Socket} socket that will get added
|
||||||
|
* @param {Function} fn last fn call in the middleware
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.run = function(socket, fn){
|
||||||
|
var fns = this.fns.slice(0);
|
||||||
|
if (!fns.length) return fn(null);
|
||||||
|
|
||||||
|
function run(i){
|
||||||
|
fns[i](socket, function(err){
|
||||||
|
// upon error, short-circuit
|
||||||
|
if (err) return fn(err);
|
||||||
|
|
||||||
|
// if no middleware left, summon callback
|
||||||
|
if (!fns[i + 1]) return fn(null);
|
||||||
|
|
||||||
|
// go on to next
|
||||||
|
run(i + 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Targets a room when emitting.
|
||||||
|
*
|
||||||
|
* @param {String} name
|
||||||
|
* @return {Namespace} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.to =
|
||||||
|
Namespace.prototype.in = function(name){
|
||||||
|
if (!~this.rooms.indexOf(name)) this.rooms.push(name);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new client.
|
||||||
|
*
|
||||||
|
* @return {Socket}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.add = function(client, query, fn){
|
||||||
|
debug('adding socket to nsp %s', this.name);
|
||||||
|
var socket = new Socket(this, client, query);
|
||||||
|
var self = this;
|
||||||
|
this.run(socket, function(err){
|
||||||
|
process.nextTick(function(){
|
||||||
|
if ('open' == client.conn.readyState) {
|
||||||
|
if (err) return socket.error(err.data || err.message);
|
||||||
|
|
||||||
|
// track socket
|
||||||
|
self.sockets[socket.id] = socket;
|
||||||
|
|
||||||
|
// it's paramount that the internal `onconnect` logic
|
||||||
|
// fires before user-set events to prevent state order
|
||||||
|
// violations (such as a disconnection before the connection
|
||||||
|
// logic is complete)
|
||||||
|
socket.onconnect();
|
||||||
|
if (fn) fn();
|
||||||
|
|
||||||
|
// fire user-set events
|
||||||
|
self.emit('connect', socket);
|
||||||
|
self.emit('connection', socket);
|
||||||
|
} else {
|
||||||
|
debug('next called after client was closed - ignoring socket');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return socket;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a client. Called by each `Socket`.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.remove = function(socket){
|
||||||
|
if (this.sockets.hasOwnProperty(socket.id)) {
|
||||||
|
delete this.sockets[socket.id];
|
||||||
|
} else {
|
||||||
|
debug('ignoring remove for %s', socket.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits to all clients.
|
||||||
|
*
|
||||||
|
* @return {Namespace} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.emit = function(ev){
|
||||||
|
if (~exports.events.indexOf(ev)) {
|
||||||
|
emit.apply(this, arguments);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
// set up packet object
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
var packet = {
|
||||||
|
type: (this.flags.binary !== undefined ? this.flags.binary : hasBin(args)) ? parser.BINARY_EVENT : parser.EVENT,
|
||||||
|
data: args
|
||||||
|
};
|
||||||
|
|
||||||
|
if ('function' == typeof args[args.length - 1]) {
|
||||||
|
throw new Error('Callbacks are not supported when broadcasting');
|
||||||
|
}
|
||||||
|
|
||||||
|
var rooms = this.rooms.slice(0);
|
||||||
|
var flags = Object.assign({}, this.flags);
|
||||||
|
|
||||||
|
// reset flags
|
||||||
|
this.rooms = [];
|
||||||
|
this.flags = {};
|
||||||
|
|
||||||
|
this.adapter.broadcast(packet, {
|
||||||
|
rooms: rooms,
|
||||||
|
flags: flags
|
||||||
|
});
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a `message` event to all clients.
|
||||||
|
*
|
||||||
|
* @return {Namespace} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.send =
|
||||||
|
Namespace.prototype.write = function(){
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
args.unshift('message');
|
||||||
|
this.emit.apply(this, args);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of clients.
|
||||||
|
*
|
||||||
|
* @return {Namespace} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.clients = function(fn){
|
||||||
|
if(!this.adapter){
|
||||||
|
throw new Error('No adapter for this namespace, are you trying to get the list of clients of a dynamic namespace?')
|
||||||
|
}
|
||||||
|
this.adapter.clients(this.rooms, fn);
|
||||||
|
// reset rooms for scenario:
|
||||||
|
// .in('room').clients() (GH-1978)
|
||||||
|
this.rooms = [];
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the compress flag.
|
||||||
|
*
|
||||||
|
* @param {Boolean} compress if `true`, compresses the sending data
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.compress = function(compress){
|
||||||
|
this.flags.compress = compress;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the binary flag
|
||||||
|
*
|
||||||
|
* @param {Boolean} Encode as if it has binary data if `true`, Encode as if it doesnt have binary data if `false`
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Namespace.prototype.binary = function (binary) {
|
||||||
|
this.flags.binary = binary;
|
||||||
|
return this;
|
||||||
|
};
|
@ -0,0 +1,39 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const Namespace = require('./namespace');
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
class ParentNamespace extends Namespace {
|
||||||
|
|
||||||
|
constructor(server) {
|
||||||
|
super(server, '/_' + (count++));
|
||||||
|
this.children = new Set();
|
||||||
|
}
|
||||||
|
|
||||||
|
initAdapter() {}
|
||||||
|
|
||||||
|
emit() {
|
||||||
|
const args = Array.prototype.slice.call(arguments);
|
||||||
|
|
||||||
|
this.children.forEach(nsp => {
|
||||||
|
nsp.rooms = this.rooms;
|
||||||
|
nsp.flags = this.flags;
|
||||||
|
nsp.emit.apply(nsp, args);
|
||||||
|
});
|
||||||
|
this.rooms = [];
|
||||||
|
this.flags = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
createChild(name) {
|
||||||
|
const namespace = new Namespace(this.server, name);
|
||||||
|
namespace.fns = this.fns.slice(0);
|
||||||
|
this.listeners('connect').forEach(listener => namespace.on('connect', listener));
|
||||||
|
this.listeners('connection').forEach(listener => namespace.on('connection', listener));
|
||||||
|
this.children.add(namespace);
|
||||||
|
this.server.nsps[name] = namespace;
|
||||||
|
return namespace;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ParentNamespace;
|
@ -0,0 +1,572 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Emitter = require('events').EventEmitter;
|
||||||
|
var parser = require('socket.io-parser');
|
||||||
|
var hasBin = require('has-binary2');
|
||||||
|
var url = require('url');
|
||||||
|
var debug = require('debug')('socket.io:socket');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = exports = Socket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blacklisted events.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.events = [
|
||||||
|
'error',
|
||||||
|
'connect',
|
||||||
|
'disconnect',
|
||||||
|
'disconnecting',
|
||||||
|
'newListener',
|
||||||
|
'removeListener'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flags.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var flags = [
|
||||||
|
'json',
|
||||||
|
'volatile',
|
||||||
|
'broadcast',
|
||||||
|
'local'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `EventEmitter#emit` reference.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var emit = Emitter.prototype.emit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to a `Client` for a given `Namespace`.
|
||||||
|
*
|
||||||
|
* @param {Namespace} nsp
|
||||||
|
* @param {Client} client
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Socket(nsp, client, query){
|
||||||
|
this.nsp = nsp;
|
||||||
|
this.server = nsp.server;
|
||||||
|
this.adapter = this.nsp.adapter;
|
||||||
|
this.id = nsp.name !== '/' ? nsp.name + '#' + client.id : client.id;
|
||||||
|
this.client = client;
|
||||||
|
this.conn = client.conn;
|
||||||
|
this.rooms = {};
|
||||||
|
this.acks = {};
|
||||||
|
this.connected = true;
|
||||||
|
this.disconnected = false;
|
||||||
|
this.handshake = this.buildHandshake(query);
|
||||||
|
this.fns = [];
|
||||||
|
this.flags = {};
|
||||||
|
this._rooms = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inherits from `EventEmitter`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.__proto__ = Emitter.prototype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply flags from `Socket`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
flags.forEach(function(flag){
|
||||||
|
Object.defineProperty(Socket.prototype, flag, {
|
||||||
|
get: function() {
|
||||||
|
this.flags[flag] = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `request` engine.io shortcut.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Object.defineProperty(Socket.prototype, 'request', {
|
||||||
|
get: function() {
|
||||||
|
return this.conn.request;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the `handshake` BC object
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.buildHandshake = function(query){
|
||||||
|
var self = this;
|
||||||
|
function buildQuery(){
|
||||||
|
var requestQuery = url.parse(self.request.url, true).query;
|
||||||
|
//if socket-specific query exist, replace query strings in requestQuery
|
||||||
|
return Object.assign({}, requestQuery, query);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
headers: this.request.headers,
|
||||||
|
time: (new Date) + '',
|
||||||
|
address: this.conn.remoteAddress,
|
||||||
|
xdomain: !!this.request.headers.origin,
|
||||||
|
secure: !!this.request.connection.encrypted,
|
||||||
|
issued: +(new Date),
|
||||||
|
url: this.request.url,
|
||||||
|
query: buildQuery()
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits to this client.
|
||||||
|
*
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.emit = function(ev){
|
||||||
|
if (~exports.events.indexOf(ev)) {
|
||||||
|
emit.apply(this, arguments);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
var packet = {
|
||||||
|
type: (this.flags.binary !== undefined ? this.flags.binary : hasBin(args)) ? parser.BINARY_EVENT : parser.EVENT,
|
||||||
|
data: args
|
||||||
|
};
|
||||||
|
|
||||||
|
// access last argument to see if it's an ACK callback
|
||||||
|
if (typeof args[args.length - 1] === 'function') {
|
||||||
|
if (this._rooms.length || this.flags.broadcast) {
|
||||||
|
throw new Error('Callbacks are not supported when broadcasting');
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('emitting packet with ack id %d', this.nsp.ids);
|
||||||
|
this.acks[this.nsp.ids] = args.pop();
|
||||||
|
packet.id = this.nsp.ids++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rooms = this._rooms.slice(0);
|
||||||
|
var flags = Object.assign({}, this.flags);
|
||||||
|
|
||||||
|
// reset flags
|
||||||
|
this._rooms = [];
|
||||||
|
this.flags = {};
|
||||||
|
|
||||||
|
if (rooms.length || flags.broadcast) {
|
||||||
|
this.adapter.broadcast(packet, {
|
||||||
|
except: [this.id],
|
||||||
|
rooms: rooms,
|
||||||
|
flags: flags
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// dispatch packet
|
||||||
|
this.packet(packet, flags);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Targets a room when broadcasting.
|
||||||
|
*
|
||||||
|
* @param {String} name
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.to =
|
||||||
|
Socket.prototype.in = function(name){
|
||||||
|
if (!~this._rooms.indexOf(name)) this._rooms.push(name);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a `message` event.
|
||||||
|
*
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.send =
|
||||||
|
Socket.prototype.write = function(){
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
args.unshift('message');
|
||||||
|
this.emit.apply(this, args);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a packet.
|
||||||
|
*
|
||||||
|
* @param {Object} packet object
|
||||||
|
* @param {Object} opts options
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.packet = function(packet, opts){
|
||||||
|
packet.nsp = this.nsp.name;
|
||||||
|
opts = opts || {};
|
||||||
|
opts.compress = false !== opts.compress;
|
||||||
|
this.client.packet(packet, opts);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Joins a room.
|
||||||
|
*
|
||||||
|
* @param {String|Array} room or array of rooms
|
||||||
|
* @param {Function} fn optional, callback
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.join = function(rooms, fn){
|
||||||
|
debug('joining room %s', rooms);
|
||||||
|
var self = this;
|
||||||
|
if (!Array.isArray(rooms)) {
|
||||||
|
rooms = [rooms];
|
||||||
|
}
|
||||||
|
rooms = rooms.filter(function (room) {
|
||||||
|
return !self.rooms.hasOwnProperty(room);
|
||||||
|
});
|
||||||
|
if (!rooms.length) {
|
||||||
|
fn && fn(null);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
this.adapter.addAll(this.id, rooms, function(err){
|
||||||
|
if (err) return fn && fn(err);
|
||||||
|
debug('joined room %s', rooms);
|
||||||
|
rooms.forEach(function (room) {
|
||||||
|
self.rooms[room] = room;
|
||||||
|
});
|
||||||
|
fn && fn(null);
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leaves a room.
|
||||||
|
*
|
||||||
|
* @param {String} room
|
||||||
|
* @param {Function} fn optional, callback
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.leave = function(room, fn){
|
||||||
|
debug('leave room %s', room);
|
||||||
|
var self = this;
|
||||||
|
this.adapter.del(this.id, room, function(err){
|
||||||
|
if (err) return fn && fn(err);
|
||||||
|
debug('left room %s', room);
|
||||||
|
delete self.rooms[room];
|
||||||
|
fn && fn(null);
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leave all rooms.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.leaveAll = function(){
|
||||||
|
this.adapter.delAll(this.id);
|
||||||
|
this.rooms = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by `Namespace` upon successful
|
||||||
|
* middleware execution (ie: authorization).
|
||||||
|
* Socket is added to namespace array before
|
||||||
|
* call to join, so adapters can access it.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.onconnect = function(){
|
||||||
|
debug('socket connected - writing packet');
|
||||||
|
this.nsp.connected[this.id] = this;
|
||||||
|
this.join(this.id);
|
||||||
|
var skip = this.nsp.name === '/' && this.nsp.fns.length === 0;
|
||||||
|
if (skip) {
|
||||||
|
debug('packet already sent in initial handshake');
|
||||||
|
} else {
|
||||||
|
this.packet({ type: parser.CONNECT });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called with each packet. Called by `Client`.
|
||||||
|
*
|
||||||
|
* @param {Object} packet
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.onpacket = function(packet){
|
||||||
|
debug('got packet %j', packet);
|
||||||
|
switch (packet.type) {
|
||||||
|
case parser.EVENT:
|
||||||
|
this.onevent(packet);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case parser.BINARY_EVENT:
|
||||||
|
this.onevent(packet);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case parser.ACK:
|
||||||
|
this.onack(packet);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case parser.BINARY_ACK:
|
||||||
|
this.onack(packet);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case parser.DISCONNECT:
|
||||||
|
this.ondisconnect();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case parser.ERROR:
|
||||||
|
this.onerror(new Error(packet.data));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called upon event packet.
|
||||||
|
*
|
||||||
|
* @param {Object} packet object
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.onevent = function(packet){
|
||||||
|
var args = packet.data || [];
|
||||||
|
debug('emitting event %j', args);
|
||||||
|
|
||||||
|
if (null != packet.id) {
|
||||||
|
debug('attaching ack callback to event');
|
||||||
|
args.push(this.ack(packet.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dispatch(args);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produces an ack callback to emit with an event.
|
||||||
|
*
|
||||||
|
* @param {Number} id packet id
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.ack = function(id){
|
||||||
|
var self = this;
|
||||||
|
var sent = false;
|
||||||
|
return function(){
|
||||||
|
// prevent double callbacks
|
||||||
|
if (sent) return;
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
debug('sending ack %j', args);
|
||||||
|
|
||||||
|
self.packet({
|
||||||
|
id: id,
|
||||||
|
type: hasBin(args) ? parser.BINARY_ACK : parser.ACK,
|
||||||
|
data: args
|
||||||
|
});
|
||||||
|
|
||||||
|
sent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called upon ack packet.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.onack = function(packet){
|
||||||
|
var ack = this.acks[packet.id];
|
||||||
|
if ('function' == typeof ack) {
|
||||||
|
debug('calling ack %s with %j', packet.id, packet.data);
|
||||||
|
ack.apply(this, packet.data);
|
||||||
|
delete this.acks[packet.id];
|
||||||
|
} else {
|
||||||
|
debug('bad ack %s', packet.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called upon client disconnect packet.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.ondisconnect = function(){
|
||||||
|
debug('got disconnect packet');
|
||||||
|
this.onclose('client namespace disconnect');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a client error.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.onerror = function(err){
|
||||||
|
if (this.listeners('error').length) {
|
||||||
|
this.emit('error', err);
|
||||||
|
} else {
|
||||||
|
console.error('Missing error handler on `socket`.');
|
||||||
|
console.error(err.stack);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called upon closing. Called by `Client`.
|
||||||
|
*
|
||||||
|
* @param {String} reason
|
||||||
|
* @throw {Error} optional error object
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.onclose = function(reason){
|
||||||
|
if (!this.connected) return this;
|
||||||
|
debug('closing socket - reason %s', reason);
|
||||||
|
this.emit('disconnecting', reason);
|
||||||
|
this.leaveAll();
|
||||||
|
this.nsp.remove(this);
|
||||||
|
this.client.remove(this);
|
||||||
|
this.connected = false;
|
||||||
|
this.disconnected = true;
|
||||||
|
delete this.nsp.connected[this.id];
|
||||||
|
this.emit('disconnect', reason);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produces an `error` packet.
|
||||||
|
*
|
||||||
|
* @param {Object} err error object
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.error = function(err){
|
||||||
|
this.packet({ type: parser.ERROR, data: err });
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnects this client.
|
||||||
|
*
|
||||||
|
* @param {Boolean} close if `true`, closes the underlying connection
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.disconnect = function(close){
|
||||||
|
if (!this.connected) return this;
|
||||||
|
if (close) {
|
||||||
|
this.client.disconnect();
|
||||||
|
} else {
|
||||||
|
this.packet({ type: parser.DISCONNECT });
|
||||||
|
this.onclose('server namespace disconnect');
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the compress flag.
|
||||||
|
*
|
||||||
|
* @param {Boolean} compress if `true`, compresses the sending data
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.compress = function(compress){
|
||||||
|
this.flags.compress = compress;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the binary flag
|
||||||
|
*
|
||||||
|
* @param {Boolean} Encode as if it has binary data if `true`, Encode as if it doesnt have binary data if `false`
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.binary = function (binary) {
|
||||||
|
this.flags.binary = binary;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch incoming event to socket listeners.
|
||||||
|
*
|
||||||
|
* @param {Array} event that will get emitted
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.dispatch = function(event){
|
||||||
|
debug('dispatching an event %j', event);
|
||||||
|
var self = this;
|
||||||
|
function dispatchSocket(err) {
|
||||||
|
process.nextTick(function(){
|
||||||
|
if (err) {
|
||||||
|
return self.error(err.data || err.message);
|
||||||
|
}
|
||||||
|
emit.apply(self, event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.run(event, dispatchSocket);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up socket middleware.
|
||||||
|
*
|
||||||
|
* @param {Function} middleware function (event, next)
|
||||||
|
* @return {Socket} self
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Socket.prototype.use = function(fn){
|
||||||
|
this.fns.push(fn);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the middleware for an incoming event.
|
||||||
|
*
|
||||||
|
* @param {Array} event that will get emitted
|
||||||
|
* @param {Function} last fn call in the middleware
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
Socket.prototype.run = function(event, fn){
|
||||||
|
var fns = this.fns.slice(0);
|
||||||
|
if (!fns.length) return fn(null);
|
||||||
|
|
||||||
|
function run(i){
|
||||||
|
fns[i](event, function(err){
|
||||||
|
// upon error, short-circuit
|
||||||
|
if (err) return fn(err);
|
||||||
|
|
||||||
|
// if no middleware left, summon callback
|
||||||
|
if (!fns[i + 1]) return fn(null);
|
||||||
|
|
||||||
|
// go on to next
|
||||||
|
run(i + 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run(0);
|
||||||
|
};
|
@ -0,0 +1,395 @@
|
|||||||
|
|
||||||
|
3.1.0 / 2017-09-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add `DEBUG_HIDE_DATE` env var (#486)
|
||||||
|
* Remove ReDoS regexp in %o formatter (#504)
|
||||||
|
* Remove "component" from package.json
|
||||||
|
* Remove `component.json`
|
||||||
|
* Ignore package-lock.json
|
||||||
|
* Examples: fix colors printout
|
||||||
|
* Fix: browser detection
|
||||||
|
* Fix: spelling mistake (#496, @EdwardBetts)
|
||||||
|
|
||||||
|
3.0.1 / 2017-08-24
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: Disable colors in Edge and Internet Explorer (#489)
|
||||||
|
|
||||||
|
3.0.0 / 2017-08-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Breaking: Remove DEBUG_FD (#406)
|
||||||
|
* Breaking: Use `Date#toISOString()` instead to `Date#toUTCString()` when output is not a TTY (#418)
|
||||||
|
* Breaking: Make millisecond timer namespace specific and allow 'always enabled' output (#408)
|
||||||
|
* Addition: document `enabled` flag (#465)
|
||||||
|
* Addition: add 256 colors mode (#481)
|
||||||
|
* Addition: `enabled()` updates existing debug instances, add `destroy()` function (#440)
|
||||||
|
* Update: component: update "ms" to v2.0.0
|
||||||
|
* Update: separate the Node and Browser tests in Travis-CI
|
||||||
|
* Update: refactor Readme, fixed documentation, added "Namespace Colors" section, redid screenshots
|
||||||
|
* Update: separate Node.js and web browser examples for organization
|
||||||
|
* Update: update "browserify" to v14.4.0
|
||||||
|
* Fix: fix Readme typo (#473)
|
||||||
|
|
||||||
|
2.6.9 / 2017-09-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* remove ReDoS regexp in %o formatter (#504)
|
||||||
|
|
||||||
|
2.6.8 / 2017-05-18
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: Check for undefined on browser globals (#462, @marbemac)
|
||||||
|
|
||||||
|
2.6.7 / 2017-05-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: Update ms to 2.0.0 to fix regular expression denial of service vulnerability (#458, @hubdotcom)
|
||||||
|
* Fix: Inline extend function in node implementation (#452, @dougwilson)
|
||||||
|
* Docs: Fix typo (#455, @msasad)
|
||||||
|
|
||||||
|
2.6.5 / 2017-04-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: null reference check on window.documentElement.style.WebkitAppearance (#447, @thebigredgeek)
|
||||||
|
* Misc: clean up browser reference checks (#447, @thebigredgeek)
|
||||||
|
* Misc: add npm-debug.log to .gitignore (@thebigredgeek)
|
||||||
|
|
||||||
|
|
||||||
|
2.6.4 / 2017-04-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: bug that would occur if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo)
|
||||||
|
* Chore: ignore bower.json in npm installations. (#437, @joaovieira)
|
||||||
|
* Misc: update "ms" to v0.7.3 (@tootallnate)
|
||||||
|
|
||||||
|
2.6.3 / 2017-03-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: Electron reference to `process.env.DEBUG` (#431, @paulcbetts)
|
||||||
|
* Docs: Changelog fix (@thebigredgeek)
|
||||||
|
|
||||||
|
2.6.2 / 2017-03-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: DEBUG_MAX_ARRAY_LENGTH (#420, @slavaGanzin)
|
||||||
|
* Docs: Add backers and sponsors from Open Collective (#422, @piamancini)
|
||||||
|
* Docs: Add Slackin invite badge (@tootallnate)
|
||||||
|
|
||||||
|
2.6.1 / 2017-02-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: Module's `export default` syntax fix for IE8 `Expected identifier` error
|
||||||
|
* Fix: Whitelist DEBUG_FD for values 1 and 2 only (#415, @pi0)
|
||||||
|
* Fix: IE8 "Expected identifier" error (#414, @vgoma)
|
||||||
|
* Fix: Namespaces would not disable once enabled (#409, @musikov)
|
||||||
|
|
||||||
|
2.6.0 / 2016-12-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: added better null pointer checks for browser useColors (@thebigredgeek)
|
||||||
|
* Improvement: removed explicit `window.debug` export (#404, @tootallnate)
|
||||||
|
* Improvement: deprecated `DEBUG_FD` environment variable (#405, @tootallnate)
|
||||||
|
|
||||||
|
2.5.2 / 2016-12-25
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: reference error on window within webworkers (#393, @KlausTrainer)
|
||||||
|
* Docs: fixed README typo (#391, @lurch)
|
||||||
|
* Docs: added notice about v3 api discussion (@thebigredgeek)
|
||||||
|
|
||||||
|
2.5.1 / 2016-12-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: babel-core compatibility
|
||||||
|
|
||||||
|
2.5.0 / 2016-12-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: wrong reference in bower file (@thebigredgeek)
|
||||||
|
* Fix: webworker compatibility (@thebigredgeek)
|
||||||
|
* Fix: output formatting issue (#388, @kribblo)
|
||||||
|
* Fix: babel-loader compatibility (#383, @escwald)
|
||||||
|
* Misc: removed built asset from repo and publications (@thebigredgeek)
|
||||||
|
* Misc: moved source files to /src (#378, @yamikuronue)
|
||||||
|
* Test: added karma integration and replaced babel with browserify for browser tests (#378, @yamikuronue)
|
||||||
|
* Test: coveralls integration (#378, @yamikuronue)
|
||||||
|
* Docs: simplified language in the opening paragraph (#373, @yamikuronue)
|
||||||
|
|
||||||
|
2.4.5 / 2016-12-17
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: `navigator` undefined in Rhino (#376, @jochenberger)
|
||||||
|
* Fix: custom log function (#379, @hsiliev)
|
||||||
|
* Improvement: bit of cleanup + linting fixes (@thebigredgeek)
|
||||||
|
* Improvement: rm non-maintainted `dist/` dir (#375, @freewil)
|
||||||
|
* Docs: simplified language in the opening paragraph. (#373, @yamikuronue)
|
||||||
|
|
||||||
|
2.4.4 / 2016-12-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: work around debug being loaded in preload scripts for electron (#368, @paulcbetts)
|
||||||
|
|
||||||
|
2.4.3 / 2016-12-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: navigation.userAgent error for react native (#364, @escwald)
|
||||||
|
|
||||||
|
2.4.2 / 2016-12-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: browser colors (#367, @tootallnate)
|
||||||
|
* Misc: travis ci integration (@thebigredgeek)
|
||||||
|
* Misc: added linting and testing boilerplate with sanity check (@thebigredgeek)
|
||||||
|
|
||||||
|
2.4.1 / 2016-12-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: typo that broke the package (#356)
|
||||||
|
|
||||||
|
2.4.0 / 2016-12-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: bower.json references unbuilt src entry point (#342, @justmatt)
|
||||||
|
* Fix: revert "handle regex special characters" (@tootallnate)
|
||||||
|
* Feature: configurable util.inspect()`options for NodeJS (#327, @tootallnate)
|
||||||
|
* Feature: %O`(big O) pretty-prints objects (#322, @tootallnate)
|
||||||
|
* Improvement: allow colors in workers (#335, @botverse)
|
||||||
|
* Improvement: use same color for same namespace. (#338, @lchenay)
|
||||||
|
|
||||||
|
2.3.3 / 2016-11-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: Catch `JSON.stringify()` errors (#195, Jovan Alleyne)
|
||||||
|
* Fix: Returning `localStorage` saved values (#331, Levi Thomason)
|
||||||
|
* Improvement: Don't create an empty object when no `process` (Nathan Rajlich)
|
||||||
|
|
||||||
|
2.3.2 / 2016-11-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: be super-safe in index.js as well (@TooTallNate)
|
||||||
|
* Fix: should check whether process exists (Tom Newby)
|
||||||
|
|
||||||
|
2.3.1 / 2016-11-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: Added electron compatibility (#324, @paulcbetts)
|
||||||
|
* Improvement: Added performance optimizations (@tootallnate)
|
||||||
|
* Readme: Corrected PowerShell environment variable example (#252, @gimre)
|
||||||
|
* Misc: Removed yarn lock file from source control (#321, @fengmk2)
|
||||||
|
|
||||||
|
2.3.0 / 2016-11-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix: Consistent placement of ms diff at end of output (#215, @gorangajic)
|
||||||
|
* Fix: Escaping of regex special characters in namespace strings (#250, @zacronos)
|
||||||
|
* Fix: Fixed bug causing crash on react-native (#282, @vkarpov15)
|
||||||
|
* Feature: Enabled ES6+ compatible import via default export (#212 @bucaran)
|
||||||
|
* Feature: Added %O formatter to reflect Chrome's console.log capability (#279, @oncletom)
|
||||||
|
* Package: Update "ms" to 0.7.2 (#315, @DevSide)
|
||||||
|
* Package: removed superfluous version property from bower.json (#207 @kkirsche)
|
||||||
|
* Readme: fix USE_COLORS to DEBUG_COLORS
|
||||||
|
* Readme: Doc fixes for format string sugar (#269, @mlucool)
|
||||||
|
* Readme: Updated docs for DEBUG_FD and DEBUG_COLORS environment variables (#232, @mattlyons0)
|
||||||
|
* Readme: doc fixes for PowerShell (#271 #243, @exoticknight @unreadable)
|
||||||
|
* Readme: better docs for browser support (#224, @matthewmueller)
|
||||||
|
* Tooling: Added yarn integration for development (#317, @thebigredgeek)
|
||||||
|
* Misc: Renamed History.md to CHANGELOG.md (@thebigredgeek)
|
||||||
|
* Misc: Added license file (#226 #274, @CantemoInternal @sdaitzman)
|
||||||
|
* Misc: Updated contributors (@thebigredgeek)
|
||||||
|
|
||||||
|
2.2.0 / 2015-05-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* package: update "ms" to v0.7.1 (#202, @dougwilson)
|
||||||
|
* README: add logging to file example (#193, @DanielOchoa)
|
||||||
|
* README: fixed a typo (#191, @amir-s)
|
||||||
|
* browser: expose `storage` (#190, @stephenmathieson)
|
||||||
|
* Makefile: add a `distclean` target (#189, @stephenmathieson)
|
||||||
|
|
||||||
|
2.1.3 / 2015-03-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Updated stdout/stderr example (#186)
|
||||||
|
* Updated example/stdout.js to match debug current behaviour
|
||||||
|
* Renamed example/stderr.js to stdout.js
|
||||||
|
* Update Readme.md (#184)
|
||||||
|
* replace high intensity foreground color for bold (#182, #183)
|
||||||
|
|
||||||
|
2.1.2 / 2015-03-01
|
||||||
|
==================
|
||||||
|
|
||||||
|
* dist: recompile
|
||||||
|
* update "ms" to v0.7.0
|
||||||
|
* package: update "browserify" to v9.0.3
|
||||||
|
* component: fix "ms.js" repo location
|
||||||
|
* changed bower package name
|
||||||
|
* updated documentation about using debug in a browser
|
||||||
|
* fix: security error on safari (#167, #168, @yields)
|
||||||
|
|
||||||
|
2.1.1 / 2014-12-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* browser: use `typeof` to check for `console` existence
|
||||||
|
* browser: check for `console.log` truthiness (fix IE 8/9)
|
||||||
|
* browser: add support for Chrome apps
|
||||||
|
* Readme: added Windows usage remarks
|
||||||
|
* Add `bower.json` to properly support bower install
|
||||||
|
|
||||||
|
2.1.0 / 2014-10-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* node: implement `DEBUG_FD` env variable support
|
||||||
|
* package: update "browserify" to v6.1.0
|
||||||
|
* package: add "license" field to package.json (#135, @panuhorsmalahti)
|
||||||
|
|
||||||
|
2.0.0 / 2014-09-01
|
||||||
|
==================
|
||||||
|
|
||||||
|
* package: update "browserify" to v5.11.0
|
||||||
|
* node: use stderr rather than stdout for logging (#29, @stephenmathieson)
|
||||||
|
|
||||||
|
1.0.4 / 2014-07-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* dist: recompile
|
||||||
|
* example: remove `console.info()` log usage
|
||||||
|
* example: add "Content-Type" UTF-8 header to browser example
|
||||||
|
* browser: place %c marker after the space character
|
||||||
|
* browser: reset the "content" color via `color: inherit`
|
||||||
|
* browser: add colors support for Firefox >= v31
|
||||||
|
* debug: prefer an instance `log()` function over the global one (#119)
|
||||||
|
* Readme: update documentation about styled console logs for FF v31 (#116, @wryk)
|
||||||
|
|
||||||
|
1.0.3 / 2014-07-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add support for multiple wildcards in namespaces (#122, @seegno)
|
||||||
|
* browser: fix lint
|
||||||
|
|
||||||
|
1.0.2 / 2014-06-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* browser: update color palette (#113, @gscottolson)
|
||||||
|
* common: make console logging function configurable (#108, @timoxley)
|
||||||
|
* node: fix %o colors on old node <= 0.8.x
|
||||||
|
* Makefile: find node path using shell/which (#109, @timoxley)
|
||||||
|
|
||||||
|
1.0.1 / 2014-06-06
|
||||||
|
==================
|
||||||
|
|
||||||
|
* browser: use `removeItem()` to clear localStorage
|
||||||
|
* browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777)
|
||||||
|
* package: add "contributors" section
|
||||||
|
* node: fix comment typo
|
||||||
|
* README: list authors
|
||||||
|
|
||||||
|
1.0.0 / 2014-06-04
|
||||||
|
==================
|
||||||
|
|
||||||
|
* make ms diff be global, not be scope
|
||||||
|
* debug: ignore empty strings in enable()
|
||||||
|
* node: make DEBUG_COLORS able to disable coloring
|
||||||
|
* *: export the `colors` array
|
||||||
|
* npmignore: don't publish the `dist` dir
|
||||||
|
* Makefile: refactor to use browserify
|
||||||
|
* package: add "browserify" as a dev dependency
|
||||||
|
* Readme: add Web Inspector Colors section
|
||||||
|
* node: reset terminal color for the debug content
|
||||||
|
* node: map "%o" to `util.inspect()`
|
||||||
|
* browser: map "%j" to `JSON.stringify()`
|
||||||
|
* debug: add custom "formatters"
|
||||||
|
* debug: use "ms" module for humanizing the diff
|
||||||
|
* Readme: add "bash" syntax highlighting
|
||||||
|
* browser: add Firebug color support
|
||||||
|
* browser: add colors for WebKit browsers
|
||||||
|
* node: apply log to `console`
|
||||||
|
* rewrite: abstract common logic for Node & browsers
|
||||||
|
* add .jshintrc file
|
||||||
|
|
||||||
|
0.8.1 / 2014-04-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* package: re-add the "component" section
|
||||||
|
|
||||||
|
0.8.0 / 2014-03-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `enable()` method for nodejs. Closes #27
|
||||||
|
* change from stderr to stdout
|
||||||
|
* remove unnecessary index.js file
|
||||||
|
|
||||||
|
0.7.4 / 2013-11-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* remove "browserify" key from package.json (fixes something in browserify)
|
||||||
|
|
||||||
|
0.7.3 / 2013-10-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix: catch localStorage security error when cookies are blocked (Chrome)
|
||||||
|
* add debug(err) support. Closes #46
|
||||||
|
* add .browser prop to package.json. Closes #42
|
||||||
|
|
||||||
|
0.7.2 / 2013-02-06
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix package.json
|
||||||
|
* fix: Mobile Safari (private mode) is broken with debug
|
||||||
|
* fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
|
||||||
|
|
||||||
|
0.7.1 / 2013-02-05
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add repository URL to package.json
|
||||||
|
* add DEBUG_COLORED to force colored output
|
||||||
|
* add browserify support
|
||||||
|
* fix component. Closes #24
|
||||||
|
|
||||||
|
0.7.0 / 2012-05-04
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added .component to package.json
|
||||||
|
* Added debug.component.js build
|
||||||
|
|
||||||
|
0.6.0 / 2012-03-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added support for "-" prefix in DEBUG [Vinay Pulim]
|
||||||
|
* Added `.enabled` flag to the node version [TooTallNate]
|
||||||
|
|
||||||
|
0.5.0 / 2012-02-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added: humanize diffs. Closes #8
|
||||||
|
* Added `debug.disable()` to the CS variant
|
||||||
|
* Removed padding. Closes #10
|
||||||
|
* Fixed: persist client-side variant again. Closes #9
|
||||||
|
|
||||||
|
0.4.0 / 2012-02-01
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added browser variant support for older browsers [TooTallNate]
|
||||||
|
* Added `debug.enable('project:*')` to browser variant [TooTallNate]
|
||||||
|
* Added padding to diff (moved it to the right)
|
||||||
|
|
||||||
|
0.3.0 / 2012-01-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added millisecond diff when isatty, otherwise UTC string
|
||||||
|
|
||||||
|
0.2.0 / 2012-01-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added wildcard support
|
||||||
|
|
||||||
|
0.1.0 / 2011-12-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added: remove colors unless stderr isatty [TooTallNate]
|
||||||
|
|
||||||
|
0.0.1 / 2010-01-03
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Initial release
|
@ -0,0 +1,19 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||||
|
and associated documentation files (the 'Software'), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||||
|
portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||||
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
@ -0,0 +1,455 @@
|
|||||||
|
# debug
|
||||||
|
[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers)
|
||||||
|
[![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors)
|
||||||
|
|
||||||
|
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||||
|
|
||||||
|
A tiny JavaScript debugging utility modelled after Node.js core's debugging
|
||||||
|
technique. Works in Node.js and web browsers.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install debug
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
|
||||||
|
|
||||||
|
Example [_app.js_](./examples/node/app.js):
|
||||||
|
|
||||||
|
```js
|
||||||
|
var debug = require('debug')('http')
|
||||||
|
, http = require('http')
|
||||||
|
, name = 'My App';
|
||||||
|
|
||||||
|
// fake app
|
||||||
|
|
||||||
|
debug('booting %o', name);
|
||||||
|
|
||||||
|
http.createServer(function(req, res){
|
||||||
|
debug(req.method + ' ' + req.url);
|
||||||
|
res.end('hello\n');
|
||||||
|
}).listen(3000, function(){
|
||||||
|
debug('listening');
|
||||||
|
});
|
||||||
|
|
||||||
|
// fake worker of some kind
|
||||||
|
|
||||||
|
require('./worker');
|
||||||
|
```
|
||||||
|
|
||||||
|
Example [_worker.js_](./examples/node/worker.js):
|
||||||
|
|
||||||
|
```js
|
||||||
|
var a = require('debug')('worker:a')
|
||||||
|
, b = require('debug')('worker:b');
|
||||||
|
|
||||||
|
function work() {
|
||||||
|
a('doing lots of uninteresting work');
|
||||||
|
setTimeout(work, Math.random() * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
work();
|
||||||
|
|
||||||
|
function workb() {
|
||||||
|
b('doing some work');
|
||||||
|
setTimeout(workb, Math.random() * 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
workb();
|
||||||
|
```
|
||||||
|
|
||||||
|
The `DEBUG` environment variable is then used to enable these based on space or
|
||||||
|
comma-delimited names.
|
||||||
|
|
||||||
|
Here are some examples:
|
||||||
|
|
||||||
|
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
|
||||||
|
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
|
||||||
|
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
|
||||||
|
|
||||||
|
#### Windows command prompt notes
|
||||||
|
|
||||||
|
##### CMD
|
||||||
|
|
||||||
|
On Windows the environment variable is set using the `set` command.
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
set DEBUG=*,-not_this
|
||||||
|
```
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
set DEBUG=* & node app.js
|
||||||
|
```
|
||||||
|
|
||||||
|
##### PowerShell (VS Code default)
|
||||||
|
|
||||||
|
PowerShell uses different syntax to set environment variables.
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
$env:DEBUG = "*,-not_this"
|
||||||
|
```
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
$env:DEBUG='app';node app.js
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, run the program to be debugged as usual.
|
||||||
|
|
||||||
|
npm script example:
|
||||||
|
```js
|
||||||
|
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",
|
||||||
|
```
|
||||||
|
|
||||||
|
## Namespace Colors
|
||||||
|
|
||||||
|
Every debug instance has a color generated for it based on its namespace name.
|
||||||
|
This helps when visually parsing the debug output to identify which debug instance
|
||||||
|
a debug line belongs to.
|
||||||
|
|
||||||
|
#### Node.js
|
||||||
|
|
||||||
|
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
|
||||||
|
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
|
||||||
|
otherwise debug will only use a small handful of basic colors.
|
||||||
|
|
||||||
|
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
|
||||||
|
|
||||||
|
#### Web Browser
|
||||||
|
|
||||||
|
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||||
|
option. These are WebKit web inspectors, Firefox ([since version
|
||||||
|
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||||
|
and the Firebug plugin for Firefox (any version).
|
||||||
|
|
||||||
|
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
|
||||||
|
|
||||||
|
|
||||||
|
## Millisecond diff
|
||||||
|
|
||||||
|
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||||
|
|
||||||
|
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||||
|
|
||||||
|
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
|
||||||
|
|
||||||
|
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
|
||||||
|
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
|
||||||
|
|
||||||
|
## Wildcards
|
||||||
|
|
||||||
|
The `*` character may be used as a wildcard. Suppose for example your library has
|
||||||
|
debuggers named "connect:bodyParser", "connect:compress", "connect:session",
|
||||||
|
instead of listing all three with
|
||||||
|
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
|
||||||
|
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||||
|
|
||||||
|
You can also exclude specific debuggers by prefixing them with a "-" character.
|
||||||
|
For example, `DEBUG=*,-connect:*` would include all debuggers except those
|
||||||
|
starting with "connect:".
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
When running through Node.js, you can set a few environment variables that will
|
||||||
|
change the behavior of the debug logging:
|
||||||
|
|
||||||
|
| Name | Purpose |
|
||||||
|
|-----------|-------------------------------------------------|
|
||||||
|
| `DEBUG` | Enables/disables specific debugging namespaces. |
|
||||||
|
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
|
||||||
|
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
|
||||||
|
| `DEBUG_DEPTH` | Object inspection depth. |
|
||||||
|
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
|
||||||
|
|
||||||
|
|
||||||
|
__Note:__ The environment variables beginning with `DEBUG_` end up being
|
||||||
|
converted into an Options object that gets used with `%o`/`%O` formatters.
|
||||||
|
See the Node.js documentation for
|
||||||
|
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
|
||||||
|
for the complete list.
|
||||||
|
|
||||||
|
## Formatters
|
||||||
|
|
||||||
|
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
|
||||||
|
Below are the officially supported formatters:
|
||||||
|
|
||||||
|
| Formatter | Representation |
|
||||||
|
|-----------|----------------|
|
||||||
|
| `%O` | Pretty-print an Object on multiple lines. |
|
||||||
|
| `%o` | Pretty-print an Object all on a single line. |
|
||||||
|
| `%s` | String. |
|
||||||
|
| `%d` | Number (both integer and float). |
|
||||||
|
| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
|
||||||
|
| `%%` | Single percent sign ('%'). This does not consume an argument. |
|
||||||
|
|
||||||
|
|
||||||
|
### Custom formatters
|
||||||
|
|
||||||
|
You can add custom formatters by extending the `debug.formatters` object.
|
||||||
|
For example, if you wanted to add support for rendering a Buffer as hex with
|
||||||
|
`%h`, you could do something like:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const createDebug = require('debug')
|
||||||
|
createDebug.formatters.h = (v) => {
|
||||||
|
return v.toString('hex')
|
||||||
|
}
|
||||||
|
|
||||||
|
// …elsewhere
|
||||||
|
const debug = createDebug('foo')
|
||||||
|
debug('this is hex: %h', new Buffer('hello world'))
|
||||||
|
// foo this is hex: 68656c6c6f20776f726c6421 +0ms
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Browser Support
|
||||||
|
|
||||||
|
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
|
||||||
|
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
|
||||||
|
if you don't want to build it yourself.
|
||||||
|
|
||||||
|
Debug's enable state is currently persisted by `localStorage`.
|
||||||
|
Consider the situation shown below where you have `worker:a` and `worker:b`,
|
||||||
|
and wish to debug both. You can enable this using `localStorage.debug`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
localStorage.debug = 'worker:*'
|
||||||
|
```
|
||||||
|
|
||||||
|
And then refresh the page.
|
||||||
|
|
||||||
|
```js
|
||||||
|
a = debug('worker:a');
|
||||||
|
b = debug('worker:b');
|
||||||
|
|
||||||
|
setInterval(function(){
|
||||||
|
a('doing some work');
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
setInterval(function(){
|
||||||
|
b('doing some work');
|
||||||
|
}, 1200);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Output streams
|
||||||
|
|
||||||
|
By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
|
||||||
|
|
||||||
|
Example [_stdout.js_](./examples/node/stdout.js):
|
||||||
|
|
||||||
|
```js
|
||||||
|
var debug = require('debug');
|
||||||
|
var error = debug('app:error');
|
||||||
|
|
||||||
|
// by default stderr is used
|
||||||
|
error('goes to stderr!');
|
||||||
|
|
||||||
|
var log = debug('app:log');
|
||||||
|
// set this namespace to log via console.log
|
||||||
|
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||||
|
log('goes to stdout');
|
||||||
|
error('still goes to stderr!');
|
||||||
|
|
||||||
|
// set all output to go via console.info
|
||||||
|
// overrides all per-namespace log settings
|
||||||
|
debug.log = console.info.bind(console);
|
||||||
|
error('now goes to stdout via console.info');
|
||||||
|
log('still goes to stdout, but via console.info now');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Extend
|
||||||
|
You can simply extend debugger
|
||||||
|
```js
|
||||||
|
const log = require('debug')('auth');
|
||||||
|
|
||||||
|
//creates new debug instance with extended namespace
|
||||||
|
const logSign = log.extend('sign');
|
||||||
|
const logLogin = log.extend('login');
|
||||||
|
|
||||||
|
log('hello'); // auth hello
|
||||||
|
logSign('hello'); //auth:sign hello
|
||||||
|
logLogin('hello'); //auth:login hello
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set dynamically
|
||||||
|
|
||||||
|
You can also enable debug dynamically by calling the `enable()` method :
|
||||||
|
|
||||||
|
```js
|
||||||
|
let debug = require('debug');
|
||||||
|
|
||||||
|
console.log(1, debug.enabled('test'));
|
||||||
|
|
||||||
|
debug.enable('test');
|
||||||
|
console.log(2, debug.enabled('test'));
|
||||||
|
|
||||||
|
debug.disable();
|
||||||
|
console.log(3, debug.enabled('test'));
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
print :
|
||||||
|
```
|
||||||
|
1 false
|
||||||
|
2 true
|
||||||
|
3 false
|
||||||
|
```
|
||||||
|
|
||||||
|
Usage :
|
||||||
|
`enable(namespaces)`
|
||||||
|
`namespaces` can include modes separated by a colon and wildcards.
|
||||||
|
|
||||||
|
Note that calling `enable()` completely overrides previously set DEBUG variable :
|
||||||
|
|
||||||
|
```
|
||||||
|
$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
|
||||||
|
=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
`disable()`
|
||||||
|
|
||||||
|
Will disable all namespaces. The functions returns the namespaces currently
|
||||||
|
enabled (and skipped). This can be useful if you want to disable debugging
|
||||||
|
temporarily without knowing what was enabled to begin with.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
let debug = require('debug');
|
||||||
|
debug.enable('foo:*,-foo:bar');
|
||||||
|
let namespaces = debug.disable();
|
||||||
|
debug.enable(namespaces);
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: There is no guarantee that the string will be identical to the initial
|
||||||
|
enable string, but semantically they will be identical.
|
||||||
|
|
||||||
|
## Checking whether a debug target is enabled
|
||||||
|
|
||||||
|
After you've created a debug instance, you can determine whether or not it is
|
||||||
|
enabled by checking the `enabled` property:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const debug = require('debug')('http');
|
||||||
|
|
||||||
|
if (debug.enabled) {
|
||||||
|
// do stuff...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also manually toggle this property to force the debug instance to be
|
||||||
|
enabled or disabled.
|
||||||
|
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
- TJ Holowaychuk
|
||||||
|
- Nathan Rajlich
|
||||||
|
- Andrew Rhyne
|
||||||
|
|
||||||
|
## Backers
|
||||||
|
|
||||||
|
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
|
||||||
|
|
||||||
|
|
||||||
|
## Sponsors
|
||||||
|
|
||||||
|
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -0,0 +1,912 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
||||||
|
|
||||||
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
||||||
|
|
||||||
|
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
||||||
|
|
||||||
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
||||||
|
|
||||||
|
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||||
|
|
||||||
|
(function (f) {
|
||||||
|
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
|
||||||
|
module.exports = f();
|
||||||
|
} else if (typeof define === "function" && define.amd) {
|
||||||
|
define([], f);
|
||||||
|
} else {
|
||||||
|
var g;
|
||||||
|
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
g = window;
|
||||||
|
} else if (typeof global !== "undefined") {
|
||||||
|
g = global;
|
||||||
|
} else if (typeof self !== "undefined") {
|
||||||
|
g = self;
|
||||||
|
} else {
|
||||||
|
g = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
g.debug = f();
|
||||||
|
}
|
||||||
|
})(function () {
|
||||||
|
var define, module, exports;
|
||||||
|
return function () {
|
||||||
|
function r(e, n, t) {
|
||||||
|
function o(i, f) {
|
||||||
|
if (!n[i]) {
|
||||||
|
if (!e[i]) {
|
||||||
|
var c = "function" == typeof require && require;
|
||||||
|
if (!f && c) return c(i, !0);
|
||||||
|
if (u) return u(i, !0);
|
||||||
|
var a = new Error("Cannot find module '" + i + "'");
|
||||||
|
throw a.code = "MODULE_NOT_FOUND", a;
|
||||||
|
}
|
||||||
|
|
||||||
|
var p = n[i] = {
|
||||||
|
exports: {}
|
||||||
|
};
|
||||||
|
e[i][0].call(p.exports, function (r) {
|
||||||
|
var n = e[i][1][r];
|
||||||
|
return o(n || r);
|
||||||
|
}, p, p.exports, r, e, n, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return n[i].exports;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
|
||||||
|
o(t[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}()({
|
||||||
|
1: [function (require, module, exports) {
|
||||||
|
/**
|
||||||
|
* Helpers.
|
||||||
|
*/
|
||||||
|
var s = 1000;
|
||||||
|
var m = s * 60;
|
||||||
|
var h = m * 60;
|
||||||
|
var d = h * 24;
|
||||||
|
var w = d * 7;
|
||||||
|
var y = d * 365.25;
|
||||||
|
/**
|
||||||
|
* Parse or format the given `val`.
|
||||||
|
*
|
||||||
|
* Options:
|
||||||
|
*
|
||||||
|
* - `long` verbose formatting [false]
|
||||||
|
*
|
||||||
|
* @param {String|Number} val
|
||||||
|
* @param {Object} [options]
|
||||||
|
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||||
|
* @return {String|Number}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = function (val, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
var type = _typeof(val);
|
||||||
|
|
||||||
|
if (type === 'string' && val.length > 0) {
|
||||||
|
return parse(val);
|
||||||
|
} else if (type === 'number' && isNaN(val) === false) {
|
||||||
|
return options.long ? fmtLong(val) : fmtShort(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Parse the given `str` and return milliseconds.
|
||||||
|
*
|
||||||
|
* @param {String} str
|
||||||
|
* @return {Number}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function parse(str) {
|
||||||
|
str = String(str);
|
||||||
|
|
||||||
|
if (str.length > 100) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
||||||
|
|
||||||
|
if (!match) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var n = parseFloat(match[1]);
|
||||||
|
var type = (match[2] || 'ms').toLowerCase();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case 'years':
|
||||||
|
case 'year':
|
||||||
|
case 'yrs':
|
||||||
|
case 'yr':
|
||||||
|
case 'y':
|
||||||
|
return n * y;
|
||||||
|
|
||||||
|
case 'weeks':
|
||||||
|
case 'week':
|
||||||
|
case 'w':
|
||||||
|
return n * w;
|
||||||
|
|
||||||
|
case 'days':
|
||||||
|
case 'day':
|
||||||
|
case 'd':
|
||||||
|
return n * d;
|
||||||
|
|
||||||
|
case 'hours':
|
||||||
|
case 'hour':
|
||||||
|
case 'hrs':
|
||||||
|
case 'hr':
|
||||||
|
case 'h':
|
||||||
|
return n * h;
|
||||||
|
|
||||||
|
case 'minutes':
|
||||||
|
case 'minute':
|
||||||
|
case 'mins':
|
||||||
|
case 'min':
|
||||||
|
case 'm':
|
||||||
|
return n * m;
|
||||||
|
|
||||||
|
case 'seconds':
|
||||||
|
case 'second':
|
||||||
|
case 'secs':
|
||||||
|
case 'sec':
|
||||||
|
case 's':
|
||||||
|
return n * s;
|
||||||
|
|
||||||
|
case 'milliseconds':
|
||||||
|
case 'millisecond':
|
||||||
|
case 'msecs':
|
||||||
|
case 'msec':
|
||||||
|
case 'ms':
|
||||||
|
return n;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Short format for `ms`.
|
||||||
|
*
|
||||||
|
* @param {Number} ms
|
||||||
|
* @return {String}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function fmtShort(ms) {
|
||||||
|
var msAbs = Math.abs(ms);
|
||||||
|
|
||||||
|
if (msAbs >= d) {
|
||||||
|
return Math.round(ms / d) + 'd';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msAbs >= h) {
|
||||||
|
return Math.round(ms / h) + 'h';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msAbs >= m) {
|
||||||
|
return Math.round(ms / m) + 'm';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msAbs >= s) {
|
||||||
|
return Math.round(ms / s) + 's';
|
||||||
|
}
|
||||||
|
|
||||||
|
return ms + 'ms';
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Long format for `ms`.
|
||||||
|
*
|
||||||
|
* @param {Number} ms
|
||||||
|
* @return {String}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function fmtLong(ms) {
|
||||||
|
var msAbs = Math.abs(ms);
|
||||||
|
|
||||||
|
if (msAbs >= d) {
|
||||||
|
return plural(ms, msAbs, d, 'day');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msAbs >= h) {
|
||||||
|
return plural(ms, msAbs, h, 'hour');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msAbs >= m) {
|
||||||
|
return plural(ms, msAbs, m, 'minute');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msAbs >= s) {
|
||||||
|
return plural(ms, msAbs, s, 'second');
|
||||||
|
}
|
||||||
|
|
||||||
|
return ms + ' ms';
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Pluralization helper.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function plural(ms, msAbs, n, name) {
|
||||||
|
var isPlural = msAbs >= n * 1.5;
|
||||||
|
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
||||||
|
}
|
||||||
|
}, {}],
|
||||||
|
2: [function (require, module, exports) {
|
||||||
|
// shim for using process in browser
|
||||||
|
var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it
|
||||||
|
// don't break things. But we need to wrap it in a try catch in case it is
|
||||||
|
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
||||||
|
// function because try/catches deoptimize in certain engines.
|
||||||
|
|
||||||
|
var cachedSetTimeout;
|
||||||
|
var cachedClearTimeout;
|
||||||
|
|
||||||
|
function defaultSetTimout() {
|
||||||
|
throw new Error('setTimeout has not been defined');
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultClearTimeout() {
|
||||||
|
throw new Error('clearTimeout has not been defined');
|
||||||
|
}
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
try {
|
||||||
|
if (typeof setTimeout === 'function') {
|
||||||
|
cachedSetTimeout = setTimeout;
|
||||||
|
} else {
|
||||||
|
cachedSetTimeout = defaultSetTimout;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
cachedSetTimeout = defaultSetTimout;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (typeof clearTimeout === 'function') {
|
||||||
|
cachedClearTimeout = clearTimeout;
|
||||||
|
} else {
|
||||||
|
cachedClearTimeout = defaultClearTimeout;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
cachedClearTimeout = defaultClearTimeout;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
function runTimeout(fun) {
|
||||||
|
if (cachedSetTimeout === setTimeout) {
|
||||||
|
//normal enviroments in sane situations
|
||||||
|
return setTimeout(fun, 0);
|
||||||
|
} // if setTimeout wasn't available but was latter defined
|
||||||
|
|
||||||
|
|
||||||
|
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
||||||
|
cachedSetTimeout = setTimeout;
|
||||||
|
return setTimeout(fun, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||||
|
return cachedSetTimeout(fun, 0);
|
||||||
|
} catch (e) {
|
||||||
|
try {
|
||||||
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||||
|
return cachedSetTimeout.call(null, fun, 0);
|
||||||
|
} catch (e) {
|
||||||
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
||||||
|
return cachedSetTimeout.call(this, fun, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function runClearTimeout(marker) {
|
||||||
|
if (cachedClearTimeout === clearTimeout) {
|
||||||
|
//normal enviroments in sane situations
|
||||||
|
return clearTimeout(marker);
|
||||||
|
} // if clearTimeout wasn't available but was latter defined
|
||||||
|
|
||||||
|
|
||||||
|
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
||||||
|
cachedClearTimeout = clearTimeout;
|
||||||
|
return clearTimeout(marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||||
|
return cachedClearTimeout(marker);
|
||||||
|
} catch (e) {
|
||||||
|
try {
|
||||||
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||||
|
return cachedClearTimeout.call(null, marker);
|
||||||
|
} catch (e) {
|
||||||
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
||||||
|
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
||||||
|
return cachedClearTimeout.call(this, marker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var queue = [];
|
||||||
|
var draining = false;
|
||||||
|
var currentQueue;
|
||||||
|
var queueIndex = -1;
|
||||||
|
|
||||||
|
function cleanUpNextTick() {
|
||||||
|
if (!draining || !currentQueue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
draining = false;
|
||||||
|
|
||||||
|
if (currentQueue.length) {
|
||||||
|
queue = currentQueue.concat(queue);
|
||||||
|
} else {
|
||||||
|
queueIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queue.length) {
|
||||||
|
drainQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function drainQueue() {
|
||||||
|
if (draining) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var timeout = runTimeout(cleanUpNextTick);
|
||||||
|
draining = true;
|
||||||
|
var len = queue.length;
|
||||||
|
|
||||||
|
while (len) {
|
||||||
|
currentQueue = queue;
|
||||||
|
queue = [];
|
||||||
|
|
||||||
|
while (++queueIndex < len) {
|
||||||
|
if (currentQueue) {
|
||||||
|
currentQueue[queueIndex].run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
queueIndex = -1;
|
||||||
|
len = queue.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentQueue = null;
|
||||||
|
draining = false;
|
||||||
|
runClearTimeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.nextTick = function (fun) {
|
||||||
|
var args = new Array(arguments.length - 1);
|
||||||
|
|
||||||
|
if (arguments.length > 1) {
|
||||||
|
for (var i = 1; i < arguments.length; i++) {
|
||||||
|
args[i - 1] = arguments[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.push(new Item(fun, args));
|
||||||
|
|
||||||
|
if (queue.length === 1 && !draining) {
|
||||||
|
runTimeout(drainQueue);
|
||||||
|
}
|
||||||
|
}; // v8 likes predictible objects
|
||||||
|
|
||||||
|
|
||||||
|
function Item(fun, array) {
|
||||||
|
this.fun = fun;
|
||||||
|
this.array = array;
|
||||||
|
}
|
||||||
|
|
||||||
|
Item.prototype.run = function () {
|
||||||
|
this.fun.apply(null, this.array);
|
||||||
|
};
|
||||||
|
|
||||||
|
process.title = 'browser';
|
||||||
|
process.browser = true;
|
||||||
|
process.env = {};
|
||||||
|
process.argv = [];
|
||||||
|
process.version = ''; // empty string to avoid regexp issues
|
||||||
|
|
||||||
|
process.versions = {};
|
||||||
|
|
||||||
|
function noop() {}
|
||||||
|
|
||||||
|
process.on = noop;
|
||||||
|
process.addListener = noop;
|
||||||
|
process.once = noop;
|
||||||
|
process.off = noop;
|
||||||
|
process.removeListener = noop;
|
||||||
|
process.removeAllListeners = noop;
|
||||||
|
process.emit = noop;
|
||||||
|
process.prependListener = noop;
|
||||||
|
process.prependOnceListener = noop;
|
||||||
|
|
||||||
|
process.listeners = function (name) {
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
process.binding = function (name) {
|
||||||
|
throw new Error('process.binding is not supported');
|
||||||
|
};
|
||||||
|
|
||||||
|
process.cwd = function () {
|
||||||
|
return '/';
|
||||||
|
};
|
||||||
|
|
||||||
|
process.chdir = function (dir) {
|
||||||
|
throw new Error('process.chdir is not supported');
|
||||||
|
};
|
||||||
|
|
||||||
|
process.umask = function () {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
}, {}],
|
||||||
|
3: [function (require, module, exports) {
|
||||||
|
/**
|
||||||
|
* This is the common logic for both the Node.js and web browser
|
||||||
|
* implementations of `debug()`.
|
||||||
|
*/
|
||||||
|
function setup(env) {
|
||||||
|
createDebug.debug = createDebug;
|
||||||
|
createDebug.default = createDebug;
|
||||||
|
createDebug.coerce = coerce;
|
||||||
|
createDebug.disable = disable;
|
||||||
|
createDebug.enable = enable;
|
||||||
|
createDebug.enabled = enabled;
|
||||||
|
createDebug.humanize = require('ms');
|
||||||
|
Object.keys(env).forEach(function (key) {
|
||||||
|
createDebug[key] = env[key];
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* Active `debug` instances.
|
||||||
|
*/
|
||||||
|
|
||||||
|
createDebug.instances = [];
|
||||||
|
/**
|
||||||
|
* The currently active debug mode names, and names to skip.
|
||||||
|
*/
|
||||||
|
|
||||||
|
createDebug.names = [];
|
||||||
|
createDebug.skips = [];
|
||||||
|
/**
|
||||||
|
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||||
|
*
|
||||||
|
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
||||||
|
*/
|
||||||
|
|
||||||
|
createDebug.formatters = {};
|
||||||
|
/**
|
||||||
|
* Selects a color for a debug namespace
|
||||||
|
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
||||||
|
* @return {Number|String} An ANSI color code for the given namespace
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function selectColor(namespace) {
|
||||||
|
var hash = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < namespace.length; i++) {
|
||||||
|
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
||||||
|
hash |= 0; // Convert to 32bit integer
|
||||||
|
}
|
||||||
|
|
||||||
|
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||||||
|
}
|
||||||
|
|
||||||
|
createDebug.selectColor = selectColor;
|
||||||
|
/**
|
||||||
|
* Create a debugger with the given `namespace`.
|
||||||
|
*
|
||||||
|
* @param {String} namespace
|
||||||
|
* @return {Function}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createDebug(namespace) {
|
||||||
|
var prevTime;
|
||||||
|
|
||||||
|
function debug() {
|
||||||
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||||
|
args[_key] = arguments[_key];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disabled?
|
||||||
|
if (!debug.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = debug; // Set `diff` timestamp
|
||||||
|
|
||||||
|
var curr = Number(new Date());
|
||||||
|
var ms = curr - (prevTime || curr);
|
||||||
|
self.diff = ms;
|
||||||
|
self.prev = prevTime;
|
||||||
|
self.curr = curr;
|
||||||
|
prevTime = curr;
|
||||||
|
args[0] = createDebug.coerce(args[0]);
|
||||||
|
|
||||||
|
if (typeof args[0] !== 'string') {
|
||||||
|
// Anything else let's inspect with %O
|
||||||
|
args.unshift('%O');
|
||||||
|
} // Apply any `formatters` transformations
|
||||||
|
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
|
||||||
|
// If we encounter an escaped % then don't increase the array index
|
||||||
|
if (match === '%%') {
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
var formatter = createDebug.formatters[format];
|
||||||
|
|
||||||
|
if (typeof formatter === 'function') {
|
||||||
|
var val = args[index];
|
||||||
|
match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
|
||||||
|
|
||||||
|
args.splice(index, 1);
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}); // Apply env-specific formatting (colors, etc.)
|
||||||
|
|
||||||
|
createDebug.formatArgs.call(self, args);
|
||||||
|
var logFn = self.log || createDebug.log;
|
||||||
|
logFn.apply(self, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug.namespace = namespace;
|
||||||
|
debug.enabled = createDebug.enabled(namespace);
|
||||||
|
debug.useColors = createDebug.useColors();
|
||||||
|
debug.color = selectColor(namespace);
|
||||||
|
debug.destroy = destroy;
|
||||||
|
debug.extend = extend; // Debug.formatArgs = formatArgs;
|
||||||
|
// debug.rawLog = rawLog;
|
||||||
|
// env-specific initialization logic for debug instances
|
||||||
|
|
||||||
|
if (typeof createDebug.init === 'function') {
|
||||||
|
createDebug.init(debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
createDebug.instances.push(debug);
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroy() {
|
||||||
|
var index = createDebug.instances.indexOf(this);
|
||||||
|
|
||||||
|
if (index !== -1) {
|
||||||
|
createDebug.instances.splice(index, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extend(namespace, delimiter) {
|
||||||
|
var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||||
|
newDebug.log = this.log;
|
||||||
|
return newDebug;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Enables a debug mode by namespaces. This can include modes
|
||||||
|
* separated by a colon and wildcards.
|
||||||
|
*
|
||||||
|
* @param {String} namespaces
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function enable(namespaces) {
|
||||||
|
createDebug.save(namespaces);
|
||||||
|
createDebug.names = [];
|
||||||
|
createDebug.skips = [];
|
||||||
|
var i;
|
||||||
|
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||||
|
var len = split.length;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
if (!split[i]) {
|
||||||
|
// ignore empty strings
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespaces = split[i].replace(/\*/g, '.*?');
|
||||||
|
|
||||||
|
if (namespaces[0] === '-') {
|
||||||
|
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||||
|
} else {
|
||||||
|
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < createDebug.instances.length; i++) {
|
||||||
|
var instance = createDebug.instances[i];
|
||||||
|
instance.enabled = createDebug.enabled(instance.namespace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Disable debug output.
|
||||||
|
*
|
||||||
|
* @return {String} namespaces
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function disable() {
|
||||||
|
var namespaces = [].concat(_toConsumableArray(createDebug.names.map(toNamespace)), _toConsumableArray(createDebug.skips.map(toNamespace).map(function (namespace) {
|
||||||
|
return '-' + namespace;
|
||||||
|
}))).join(',');
|
||||||
|
createDebug.enable('');
|
||||||
|
return namespaces;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns true if the given mode name is enabled, false otherwise.
|
||||||
|
*
|
||||||
|
* @param {String} name
|
||||||
|
* @return {Boolean}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function enabled(name) {
|
||||||
|
if (name[name.length - 1] === '*') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var i;
|
||||||
|
var len;
|
||||||
|
|
||||||
|
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||||
|
if (createDebug.skips[i].test(name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||||
|
if (createDebug.names[i].test(name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Convert regexp to namespace
|
||||||
|
*
|
||||||
|
* @param {RegExp} regxep
|
||||||
|
* @return {String} namespace
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function toNamespace(regexp) {
|
||||||
|
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Coerce `val`.
|
||||||
|
*
|
||||||
|
* @param {Mixed} val
|
||||||
|
* @return {Mixed}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function coerce(val) {
|
||||||
|
if (val instanceof Error) {
|
||||||
|
return val.stack || val.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
createDebug.enable(createDebug.load());
|
||||||
|
return createDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = setup;
|
||||||
|
}, {
|
||||||
|
"ms": 1
|
||||||
|
}],
|
||||||
|
4: [function (require, module, exports) {
|
||||||
|
(function (process) {
|
||||||
|
/* eslint-env browser */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the web browser implementation of `debug()`.
|
||||||
|
*/
|
||||||
|
exports.log = log;
|
||||||
|
exports.formatArgs = formatArgs;
|
||||||
|
exports.save = save;
|
||||||
|
exports.load = load;
|
||||||
|
exports.useColors = useColors;
|
||||||
|
exports.storage = localstorage();
|
||||||
|
/**
|
||||||
|
* Colors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
|
||||||
|
/**
|
||||||
|
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||||
|
* and the Firebug extension (any Firefox version) are known
|
||||||
|
* to support "%c" CSS customizations.
|
||||||
|
*
|
||||||
|
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line complexity
|
||||||
|
|
||||||
|
function useColors() {
|
||||||
|
// NB: In an Electron preload script, document will be defined but not fully
|
||||||
|
// initialized. Since we know we're in Chrome, we'll just detect this case
|
||||||
|
// explicitly
|
||||||
|
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
||||||
|
return true;
|
||||||
|
} // Internet Explorer and Edge do not support colors.
|
||||||
|
|
||||||
|
|
||||||
|
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||||||
|
return false;
|
||||||
|
} // Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||||
|
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||||
|
|
||||||
|
|
||||||
|
return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
||||||
|
typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||||
|
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
||||||
|
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Colorize log arguments if enabled.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function formatArgs(args) {
|
||||||
|
args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
|
||||||
|
|
||||||
|
if (!this.useColors) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var c = 'color: ' + this.color;
|
||||||
|
args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
|
||||||
|
// arguments passed either before or after the %c, so we need to
|
||||||
|
// figure out the correct index to insert the CSS into
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
var lastC = 0;
|
||||||
|
args[0].replace(/%[a-zA-Z%]/g, function (match) {
|
||||||
|
if (match === '%%') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
|
||||||
|
if (match === '%c') {
|
||||||
|
// We only are interested in the *last* %c
|
||||||
|
// (the user may have provided their own)
|
||||||
|
lastC = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
args.splice(lastC, 0, c);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Invokes `console.log()` when available.
|
||||||
|
* No-op when `console.log` is not a "function".
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
var _console;
|
||||||
|
|
||||||
|
// This hackery is required for IE8/9, where
|
||||||
|
// the `console.log` function doesn't have 'apply'
|
||||||
|
return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Save `namespaces`.
|
||||||
|
*
|
||||||
|
* @param {String} namespaces
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function save(namespaces) {
|
||||||
|
try {
|
||||||
|
if (namespaces) {
|
||||||
|
exports.storage.setItem('debug', namespaces);
|
||||||
|
} else {
|
||||||
|
exports.storage.removeItem('debug');
|
||||||
|
}
|
||||||
|
} catch (error) {// Swallow
|
||||||
|
// XXX (@Qix-) should we be logging these?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Load `namespaces`.
|
||||||
|
*
|
||||||
|
* @return {String} returns the previously persisted debug modes
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
var r;
|
||||||
|
|
||||||
|
try {
|
||||||
|
r = exports.storage.getItem('debug');
|
||||||
|
} catch (error) {} // Swallow
|
||||||
|
// XXX (@Qix-) should we be logging these?
|
||||||
|
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||||||
|
|
||||||
|
|
||||||
|
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
||||||
|
r = process.env.DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Localstorage attempts to return the localstorage.
|
||||||
|
*
|
||||||
|
* This is necessary because safari throws
|
||||||
|
* when a user disables cookies/localstorage
|
||||||
|
* and you attempt to access it.
|
||||||
|
*
|
||||||
|
* @return {LocalStorage}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function localstorage() {
|
||||||
|
try {
|
||||||
|
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||||||
|
// The Browser also has localStorage in the global context.
|
||||||
|
return localStorage;
|
||||||
|
} catch (error) {// Swallow
|
||||||
|
// XXX (@Qix-) should we be logging these?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = require('./common')(exports);
|
||||||
|
var formatters = module.exports.formatters;
|
||||||
|
/**
|
||||||
|
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||||
|
*/
|
||||||
|
|
||||||
|
formatters.j = function (v) {
|
||||||
|
try {
|
||||||
|
return JSON.stringify(v);
|
||||||
|
} catch (error) {
|
||||||
|
return '[UnexpectedJSONParseError]: ' + error.message;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}).call(this, require('_process'));
|
||||||
|
}, {
|
||||||
|
"./common": 3,
|
||||||
|
"_process": 2
|
||||||
|
}]
|
||||||
|
}, {}, [4])(4);
|
||||||
|
});
|
@ -0,0 +1,102 @@
|
|||||||
|
{
|
||||||
|
"_from": "debug@~4.1.0",
|
||||||
|
"_id": "debug@4.1.1",
|
||||||
|
"_inBundle": false,
|
||||||
|
"_integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||||
|
"_location": "/socket.io/debug",
|
||||||
|
"_phantomChildren": {},
|
||||||
|
"_requested": {
|
||||||
|
"type": "range",
|
||||||
|
"registry": true,
|
||||||
|
"raw": "debug@~4.1.0",
|
||||||
|
"name": "debug",
|
||||||
|
"escapedName": "debug",
|
||||||
|
"rawSpec": "~4.1.0",
|
||||||
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "~4.1.0"
|
||||||
|
},
|
||||||
|
"_requiredBy": [
|
||||||
|
"/socket.io"
|
||||||
|
],
|
||||||
|
"_resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||||
|
"_shasum": "3b72260255109c6b589cee050f1d516139664791",
|
||||||
|
"_spec": "debug@~4.1.0",
|
||||||
|
"_where": "C:\\Users\\louis\\Desktop\\tetem-merge-2\\node_modules\\socket.io",
|
||||||
|
"author": {
|
||||||
|
"name": "TJ Holowaychuk",
|
||||||
|
"email": "tj@vision-media.ca"
|
||||||
|
},
|
||||||
|
"browser": "./src/browser.js",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/visionmedia/debug/issues"
|
||||||
|
},
|
||||||
|
"bundleDependencies": false,
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Nathan Rajlich",
|
||||||
|
"email": "nathan@tootallnate.net",
|
||||||
|
"url": "http://n8.io"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Andrew Rhyne",
|
||||||
|
"email": "rhyneandrew@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"ms": "^2.1.1"
|
||||||
|
},
|
||||||
|
"deprecated": "Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)",
|
||||||
|
"description": "small debugging utility",
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/cli": "^7.0.0",
|
||||||
|
"@babel/core": "^7.0.0",
|
||||||
|
"@babel/preset-env": "^7.0.0",
|
||||||
|
"browserify": "14.4.0",
|
||||||
|
"chai": "^3.5.0",
|
||||||
|
"concurrently": "^3.1.0",
|
||||||
|
"coveralls": "^3.0.2",
|
||||||
|
"istanbul": "^0.4.5",
|
||||||
|
"karma": "^3.0.0",
|
||||||
|
"karma-chai": "^0.1.0",
|
||||||
|
"karma-mocha": "^1.3.0",
|
||||||
|
"karma-phantomjs-launcher": "^1.0.2",
|
||||||
|
"mocha": "^5.2.0",
|
||||||
|
"mocha-lcov-reporter": "^1.2.0",
|
||||||
|
"rimraf": "^2.5.4",
|
||||||
|
"xo": "^0.23.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src",
|
||||||
|
"dist/debug.js",
|
||||||
|
"LICENSE",
|
||||||
|
"README.md"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/visionmedia/debug#readme",
|
||||||
|
"keywords": [
|
||||||
|
"debug",
|
||||||
|
"log",
|
||||||
|
"debugger"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "./src/index.js",
|
||||||
|
"name": "debug",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/visionmedia/debug.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "npm run build:debug && npm run build:test",
|
||||||
|
"build:debug": "babel -o dist/debug.js dist/debug.es6.js > dist/debug.js",
|
||||||
|
"build:test": "babel -d dist test.js",
|
||||||
|
"clean": "rimraf dist coverage",
|
||||||
|
"lint": "xo",
|
||||||
|
"prebuild:debug": "mkdir -p dist && browserify --standalone debug -o dist/debug.es6.js .",
|
||||||
|
"pretest:browser": "npm run build",
|
||||||
|
"test": "npm run test:node && npm run test:browser",
|
||||||
|
"test:browser": "karma start --single-run",
|
||||||
|
"test:coverage": "cat ./coverage/lcov.info | coveralls",
|
||||||
|
"test:node": "istanbul cover _mocha -- test.js"
|
||||||
|
},
|
||||||
|
"unpkg": "./dist/debug.js",
|
||||||
|
"version": "4.1.1"
|
||||||
|
}
|
@ -0,0 +1,264 @@
|
|||||||
|
/* eslint-env browser */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the web browser implementation of `debug()`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.log = log;
|
||||||
|
exports.formatArgs = formatArgs;
|
||||||
|
exports.save = save;
|
||||||
|
exports.load = load;
|
||||||
|
exports.useColors = useColors;
|
||||||
|
exports.storage = localstorage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.colors = [
|
||||||
|
'#0000CC',
|
||||||
|
'#0000FF',
|
||||||
|
'#0033CC',
|
||||||
|
'#0033FF',
|
||||||
|
'#0066CC',
|
||||||
|
'#0066FF',
|
||||||
|
'#0099CC',
|
||||||
|
'#0099FF',
|
||||||
|
'#00CC00',
|
||||||
|
'#00CC33',
|
||||||
|
'#00CC66',
|
||||||
|
'#00CC99',
|
||||||
|
'#00CCCC',
|
||||||
|
'#00CCFF',
|
||||||
|
'#3300CC',
|
||||||
|
'#3300FF',
|
||||||
|
'#3333CC',
|
||||||
|
'#3333FF',
|
||||||
|
'#3366CC',
|
||||||
|
'#3366FF',
|
||||||
|
'#3399CC',
|
||||||
|
'#3399FF',
|
||||||
|
'#33CC00',
|
||||||
|
'#33CC33',
|
||||||
|
'#33CC66',
|
||||||
|
'#33CC99',
|
||||||
|
'#33CCCC',
|
||||||
|
'#33CCFF',
|
||||||
|
'#6600CC',
|
||||||
|
'#6600FF',
|
||||||
|
'#6633CC',
|
||||||
|
'#6633FF',
|
||||||
|
'#66CC00',
|
||||||
|
'#66CC33',
|
||||||
|
'#9900CC',
|
||||||
|
'#9900FF',
|
||||||
|
'#9933CC',
|
||||||
|
'#9933FF',
|
||||||
|
'#99CC00',
|
||||||
|
'#99CC33',
|
||||||
|
'#CC0000',
|
||||||
|
'#CC0033',
|
||||||
|
'#CC0066',
|
||||||
|
'#CC0099',
|
||||||
|
'#CC00CC',
|
||||||
|
'#CC00FF',
|
||||||
|
'#CC3300',
|
||||||
|
'#CC3333',
|
||||||
|
'#CC3366',
|
||||||
|
'#CC3399',
|
||||||
|
'#CC33CC',
|
||||||
|
'#CC33FF',
|
||||||
|
'#CC6600',
|
||||||
|
'#CC6633',
|
||||||
|
'#CC9900',
|
||||||
|
'#CC9933',
|
||||||
|
'#CCCC00',
|
||||||
|
'#CCCC33',
|
||||||
|
'#FF0000',
|
||||||
|
'#FF0033',
|
||||||
|
'#FF0066',
|
||||||
|
'#FF0099',
|
||||||
|
'#FF00CC',
|
||||||
|
'#FF00FF',
|
||||||
|
'#FF3300',
|
||||||
|
'#FF3333',
|
||||||
|
'#FF3366',
|
||||||
|
'#FF3399',
|
||||||
|
'#FF33CC',
|
||||||
|
'#FF33FF',
|
||||||
|
'#FF6600',
|
||||||
|
'#FF6633',
|
||||||
|
'#FF9900',
|
||||||
|
'#FF9933',
|
||||||
|
'#FFCC00',
|
||||||
|
'#FFCC33'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||||
|
* and the Firebug extension (any Firefox version) are known
|
||||||
|
* to support "%c" CSS customizations.
|
||||||
|
*
|
||||||
|
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||||
|
*/
|
||||||
|
|
||||||
|
// eslint-disable-next-line complexity
|
||||||
|
function useColors() {
|
||||||
|
// NB: In an Electron preload script, document will be defined but not fully
|
||||||
|
// initialized. Since we know we're in Chrome, we'll just detect this case
|
||||||
|
// explicitly
|
||||||
|
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Internet Explorer and Edge do not support colors.
|
||||||
|
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||||
|
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||||
|
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
||||||
|
// Is firebug? http://stackoverflow.com/a/398120/376773
|
||||||
|
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
||||||
|
// Is firefox >= v31?
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||||
|
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
||||||
|
// Double check webkit in userAgent just in case we are in a worker
|
||||||
|
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colorize log arguments if enabled.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formatArgs(args) {
|
||||||
|
args[0] = (this.useColors ? '%c' : '') +
|
||||||
|
this.namespace +
|
||||||
|
(this.useColors ? ' %c' : ' ') +
|
||||||
|
args[0] +
|
||||||
|
(this.useColors ? '%c ' : ' ') +
|
||||||
|
'+' + module.exports.humanize(this.diff);
|
||||||
|
|
||||||
|
if (!this.useColors) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const c = 'color: ' + this.color;
|
||||||
|
args.splice(1, 0, c, 'color: inherit');
|
||||||
|
|
||||||
|
// The final "%c" is somewhat tricky, because there could be other
|
||||||
|
// arguments passed either before or after the %c, so we need to
|
||||||
|
// figure out the correct index to insert the CSS into
|
||||||
|
let index = 0;
|
||||||
|
let lastC = 0;
|
||||||
|
args[0].replace(/%[a-zA-Z%]/g, match => {
|
||||||
|
if (match === '%%') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
if (match === '%c') {
|
||||||
|
// We only are interested in the *last* %c
|
||||||
|
// (the user may have provided their own)
|
||||||
|
lastC = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
args.splice(lastC, 0, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes `console.log()` when available.
|
||||||
|
* No-op when `console.log` is not a "function".
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
function log(...args) {
|
||||||
|
// This hackery is required for IE8/9, where
|
||||||
|
// the `console.log` function doesn't have 'apply'
|
||||||
|
return typeof console === 'object' &&
|
||||||
|
console.log &&
|
||||||
|
console.log(...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save `namespaces`.
|
||||||
|
*
|
||||||
|
* @param {String} namespaces
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function save(namespaces) {
|
||||||
|
try {
|
||||||
|
if (namespaces) {
|
||||||
|
exports.storage.setItem('debug', namespaces);
|
||||||
|
} else {
|
||||||
|
exports.storage.removeItem('debug');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Swallow
|
||||||
|
// XXX (@Qix-) should we be logging these?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load `namespaces`.
|
||||||
|
*
|
||||||
|
* @return {String} returns the previously persisted debug modes
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function load() {
|
||||||
|
let r;
|
||||||
|
try {
|
||||||
|
r = exports.storage.getItem('debug');
|
||||||
|
} catch (error) {
|
||||||
|
// Swallow
|
||||||
|
// XXX (@Qix-) should we be logging these?
|
||||||
|
}
|
||||||
|
|
||||||
|
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||||||
|
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
||||||
|
r = process.env.DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Localstorage attempts to return the localstorage.
|
||||||
|
*
|
||||||
|
* This is necessary because safari throws
|
||||||
|
* when a user disables cookies/localstorage
|
||||||
|
* and you attempt to access it.
|
||||||
|
*
|
||||||
|
* @return {LocalStorage}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function localstorage() {
|
||||||
|
try {
|
||||||
|
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||||||
|
// The Browser also has localStorage in the global context.
|
||||||
|
return localStorage;
|
||||||
|
} catch (error) {
|
||||||
|
// Swallow
|
||||||
|
// XXX (@Qix-) should we be logging these?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = require('./common')(exports);
|
||||||
|
|
||||||
|
const {formatters} = module.exports;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||||
|
*/
|
||||||
|
|
||||||
|
formatters.j = function (v) {
|
||||||
|
try {
|
||||||
|
return JSON.stringify(v);
|
||||||
|
} catch (error) {
|
||||||
|
return '[UnexpectedJSONParseError]: ' + error.message;
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,266 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* This is the common logic for both the Node.js and web browser
|
||||||
|
* implementations of `debug()`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function setup(env) {
|
||||||
|
createDebug.debug = createDebug;
|
||||||
|
createDebug.default = createDebug;
|
||||||
|
createDebug.coerce = coerce;
|
||||||
|
createDebug.disable = disable;
|
||||||
|
createDebug.enable = enable;
|
||||||
|
createDebug.enabled = enabled;
|
||||||
|
createDebug.humanize = require('ms');
|
||||||
|
|
||||||
|
Object.keys(env).forEach(key => {
|
||||||
|
createDebug[key] = env[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active `debug` instances.
|
||||||
|
*/
|
||||||
|
createDebug.instances = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The currently active debug mode names, and names to skip.
|
||||||
|
*/
|
||||||
|
|
||||||
|
createDebug.names = [];
|
||||||
|
createDebug.skips = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||||
|
*
|
||||||
|
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
||||||
|
*/
|
||||||
|
createDebug.formatters = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects a color for a debug namespace
|
||||||
|
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
||||||
|
* @return {Number|String} An ANSI color code for the given namespace
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function selectColor(namespace) {
|
||||||
|
let hash = 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < namespace.length; i++) {
|
||||||
|
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
||||||
|
hash |= 0; // Convert to 32bit integer
|
||||||
|
}
|
||||||
|
|
||||||
|
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||||||
|
}
|
||||||
|
createDebug.selectColor = selectColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a debugger with the given `namespace`.
|
||||||
|
*
|
||||||
|
* @param {String} namespace
|
||||||
|
* @return {Function}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
function createDebug(namespace) {
|
||||||
|
let prevTime;
|
||||||
|
|
||||||
|
function debug(...args) {
|
||||||
|
// Disabled?
|
||||||
|
if (!debug.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const self = debug;
|
||||||
|
|
||||||
|
// Set `diff` timestamp
|
||||||
|
const curr = Number(new Date());
|
||||||
|
const ms = curr - (prevTime || curr);
|
||||||
|
self.diff = ms;
|
||||||
|
self.prev = prevTime;
|
||||||
|
self.curr = curr;
|
||||||
|
prevTime = curr;
|
||||||
|
|
||||||
|
args[0] = createDebug.coerce(args[0]);
|
||||||
|
|
||||||
|
if (typeof args[0] !== 'string') {
|
||||||
|
// Anything else let's inspect with %O
|
||||||
|
args.unshift('%O');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply any `formatters` transformations
|
||||||
|
let index = 0;
|
||||||
|
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
||||||
|
// If we encounter an escaped % then don't increase the array index
|
||||||
|
if (match === '%%') {
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
const formatter = createDebug.formatters[format];
|
||||||
|
if (typeof formatter === 'function') {
|
||||||
|
const val = args[index];
|
||||||
|
match = formatter.call(self, val);
|
||||||
|
|
||||||
|
// Now we need to remove `args[index]` since it's inlined in the `format`
|
||||||
|
args.splice(index, 1);
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
return match;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Apply env-specific formatting (colors, etc.)
|
||||||
|
createDebug.formatArgs.call(self, args);
|
||||||
|
|
||||||
|
const logFn = self.log || createDebug.log;
|
||||||
|
logFn.apply(self, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug.namespace = namespace;
|
||||||
|
debug.enabled = createDebug.enabled(namespace);
|
||||||
|
debug.useColors = createDebug.useColors();
|
||||||
|
debug.color = selectColor(namespace);
|
||||||
|
debug.destroy = destroy;
|
||||||
|
debug.extend = extend;
|
||||||
|
// Debug.formatArgs = formatArgs;
|
||||||
|
// debug.rawLog = rawLog;
|
||||||
|
|
||||||
|
// env-specific initialization logic for debug instances
|
||||||
|
if (typeof createDebug.init === 'function') {
|
||||||
|
createDebug.init(debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
createDebug.instances.push(debug);
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroy() {
|
||||||
|
const index = createDebug.instances.indexOf(this);
|
||||||
|
if (index !== -1) {
|
||||||
|
createDebug.instances.splice(index, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extend(namespace, delimiter) {
|
||||||
|
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||||
|
newDebug.log = this.log;
|
||||||
|
return newDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables a debug mode by namespaces. This can include modes
|
||||||
|
* separated by a colon and wildcards.
|
||||||
|
*
|
||||||
|
* @param {String} namespaces
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
function enable(namespaces) {
|
||||||
|
createDebug.save(namespaces);
|
||||||
|
|
||||||
|
createDebug.names = [];
|
||||||
|
createDebug.skips = [];
|
||||||
|
|
||||||
|
let i;
|
||||||
|
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||||
|
const len = split.length;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
if (!split[i]) {
|
||||||
|
// ignore empty strings
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespaces = split[i].replace(/\*/g, '.*?');
|
||||||
|
|
||||||
|
if (namespaces[0] === '-') {
|
||||||
|
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||||
|
} else {
|
||||||
|
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < createDebug.instances.length; i++) {
|
||||||
|
const instance = createDebug.instances[i];
|
||||||
|
instance.enabled = createDebug.enabled(instance.namespace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable debug output.
|
||||||
|
*
|
||||||
|
* @return {String} namespaces
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
function disable() {
|
||||||
|
const namespaces = [
|
||||||
|
...createDebug.names.map(toNamespace),
|
||||||
|
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
||||||
|
].join(',');
|
||||||
|
createDebug.enable('');
|
||||||
|
return namespaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given mode name is enabled, false otherwise.
|
||||||
|
*
|
||||||
|
* @param {String} name
|
||||||
|
* @return {Boolean}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
function enabled(name) {
|
||||||
|
if (name[name.length - 1] === '*') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let i;
|
||||||
|
let len;
|
||||||
|
|
||||||
|
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||||
|
if (createDebug.skips[i].test(name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||||
|
if (createDebug.names[i].test(name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert regexp to namespace
|
||||||
|
*
|
||||||
|
* @param {RegExp} regxep
|
||||||
|
* @return {String} namespace
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function toNamespace(regexp) {
|
||||||
|
return regexp.toString()
|
||||||
|
.substring(2, regexp.toString().length - 2)
|
||||||
|
.replace(/\.\*\?$/, '*');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coerce `val`.
|
||||||
|
*
|
||||||
|
* @param {Mixed} val
|
||||||
|
* @return {Mixed}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function coerce(val) {
|
||||||
|
if (val instanceof Error) {
|
||||||
|
return val.stack || val.message;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
createDebug.enable(createDebug.load());
|
||||||
|
|
||||||
|
return createDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = setup;
|
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Detect Electron renderer / nwjs process, which is node, but we should
|
||||||
|
* treat as a browser.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
||||||
|
module.exports = require('./browser.js');
|
||||||
|
} else {
|
||||||
|
module.exports = require('./node.js');
|
||||||
|
}
|
@ -0,0 +1,257 @@
|
|||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const tty = require('tty');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Node.js implementation of `debug()`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.init = init;
|
||||||
|
exports.log = log;
|
||||||
|
exports.formatArgs = formatArgs;
|
||||||
|
exports.save = save;
|
||||||
|
exports.load = load;
|
||||||
|
exports.useColors = useColors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
const supportsColor = require('supports-color');
|
||||||
|
|
||||||
|
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
||||||
|
exports.colors = [
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40,
|
||||||
|
41,
|
||||||
|
42,
|
||||||
|
43,
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
56,
|
||||||
|
57,
|
||||||
|
62,
|
||||||
|
63,
|
||||||
|
68,
|
||||||
|
69,
|
||||||
|
74,
|
||||||
|
75,
|
||||||
|
76,
|
||||||
|
77,
|
||||||
|
78,
|
||||||
|
79,
|
||||||
|
80,
|
||||||
|
81,
|
||||||
|
92,
|
||||||
|
93,
|
||||||
|
98,
|
||||||
|
99,
|
||||||
|
112,
|
||||||
|
113,
|
||||||
|
128,
|
||||||
|
129,
|
||||||
|
134,
|
||||||
|
135,
|
||||||
|
148,
|
||||||
|
149,
|
||||||
|
160,
|
||||||
|
161,
|
||||||
|
162,
|
||||||
|
163,
|
||||||
|
164,
|
||||||
|
165,
|
||||||
|
166,
|
||||||
|
167,
|
||||||
|
168,
|
||||||
|
169,
|
||||||
|
170,
|
||||||
|
171,
|
||||||
|
172,
|
||||||
|
173,
|
||||||
|
178,
|
||||||
|
179,
|
||||||
|
184,
|
||||||
|
185,
|
||||||
|
196,
|
||||||
|
197,
|
||||||
|
198,
|
||||||
|
199,
|
||||||
|
200,
|
||||||
|
201,
|
||||||
|
202,
|
||||||
|
203,
|
||||||
|
204,
|
||||||
|
205,
|
||||||
|
206,
|
||||||
|
207,
|
||||||
|
208,
|
||||||
|
209,
|
||||||
|
214,
|
||||||
|
215,
|
||||||
|
220,
|
||||||
|
221
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build up the default `inspectOpts` object from the environment variables.
|
||||||
|
*
|
||||||
|
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
||||||
|
return /^debug_/i.test(key);
|
||||||
|
}).reduce((obj, key) => {
|
||||||
|
// Camel-case
|
||||||
|
const prop = key
|
||||||
|
.substring(6)
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/_([a-z])/g, (_, k) => {
|
||||||
|
return k.toUpperCase();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Coerce string value into JS value
|
||||||
|
let val = process.env[key];
|
||||||
|
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
||||||
|
val = true;
|
||||||
|
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
||||||
|
val = false;
|
||||||
|
} else if (val === 'null') {
|
||||||
|
val = null;
|
||||||
|
} else {
|
||||||
|
val = Number(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj[prop] = val;
|
||||||
|
return obj;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function useColors() {
|
||||||
|
return 'colors' in exports.inspectOpts ?
|
||||||
|
Boolean(exports.inspectOpts.colors) :
|
||||||
|
tty.isatty(process.stderr.fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds ANSI color escape codes if enabled.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formatArgs(args) {
|
||||||
|
const {namespace: name, useColors} = this;
|
||||||
|
|
||||||
|
if (useColors) {
|
||||||
|
const c = this.color;
|
||||||
|
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
||||||
|
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
||||||
|
|
||||||
|
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
||||||
|
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
||||||
|
} else {
|
||||||
|
args[0] = getDate() + name + ' ' + args[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDate() {
|
||||||
|
if (exports.inspectOpts.hideDate) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return new Date().toISOString() + ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function log(...args) {
|
||||||
|
return process.stderr.write(util.format(...args) + '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save `namespaces`.
|
||||||
|
*
|
||||||
|
* @param {String} namespaces
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
function save(namespaces) {
|
||||||
|
if (namespaces) {
|
||||||
|
process.env.DEBUG = namespaces;
|
||||||
|
} else {
|
||||||
|
// If you set a process.env field to null or undefined, it gets cast to the
|
||||||
|
// string 'null' or 'undefined'. Just delete instead.
|
||||||
|
delete process.env.DEBUG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load `namespaces`.
|
||||||
|
*
|
||||||
|
* @return {String} returns the previously persisted debug modes
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
return process.env.DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init logic for `debug` instances.
|
||||||
|
*
|
||||||
|
* Create a new `inspectOpts` object in case `useColors` is set
|
||||||
|
* differently for a particular `debug` instance.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function init(debug) {
|
||||||
|
debug.inspectOpts = {};
|
||||||
|
|
||||||
|
const keys = Object.keys(exports.inspectOpts);
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = require('./common')(exports);
|
||||||
|
|
||||||
|
const {formatters} = module.exports;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map %o to `util.inspect()`, all on a single line.
|
||||||
|
*/
|
||||||
|
|
||||||
|
formatters.o = function (v) {
|
||||||
|
this.inspectOpts.colors = this.useColors;
|
||||||
|
return util.inspect(v, this.inspectOpts)
|
||||||
|
.replace(/\s*\n\s*/g, ' ');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
formatters.O = function (v) {
|
||||||
|
this.inspectOpts.colors = this.useColors;
|
||||||
|
return util.inspect(v, this.inspectOpts);
|
||||||
|
};
|
@ -0,0 +1,90 @@
|
|||||||
|
{
|
||||||
|
"_from": "socket.io@^2.0.4",
|
||||||
|
"_id": "socket.io@2.4.1",
|
||||||
|
"_inBundle": false,
|
||||||
|
"_integrity": "sha512-Si18v0mMXGAqLqCVpTxBa8MGqriHGQh8ccEOhmsmNS3thNCGBwO8WGrwMibANsWtQQ5NStdZwHqZR3naJVFc3w==",
|
||||||
|
"_location": "/socket.io",
|
||||||
|
"_phantomChildren": {
|
||||||
|
"ms": "2.1.2"
|
||||||
|
},
|
||||||
|
"_requested": {
|
||||||
|
"type": "range",
|
||||||
|
"registry": true,
|
||||||
|
"raw": "socket.io@^2.0.4",
|
||||||
|
"name": "socket.io",
|
||||||
|
"escapedName": "socket.io",
|
||||||
|
"rawSpec": "^2.0.4",
|
||||||
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "^2.0.4"
|
||||||
|
},
|
||||||
|
"_requiredBy": [
|
||||||
|
"/"
|
||||||
|
],
|
||||||
|
"_resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.4.1.tgz",
|
||||||
|
"_shasum": "95ad861c9a52369d7f1a68acf0d4a1b16da451d2",
|
||||||
|
"_spec": "socket.io@^2.0.4",
|
||||||
|
"_where": "C:\\Users\\louis\\Desktop\\tetem-merge-2",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/socketio/socket.io/issues"
|
||||||
|
},
|
||||||
|
"bundleDependencies": false,
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Guillermo Rauch",
|
||||||
|
"email": "rauchg@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Arnout Kazemier",
|
||||||
|
"email": "info@3rd-eden.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Vladimir Dronnikov",
|
||||||
|
"email": "dronnikov@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Einar Otto Stangvik",
|
||||||
|
"email": "einaros@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"debug": "~4.1.0",
|
||||||
|
"engine.io": "~3.5.0",
|
||||||
|
"has-binary2": "~1.0.2",
|
||||||
|
"socket.io-adapter": "~1.1.0",
|
||||||
|
"socket.io-client": "2.4.0",
|
||||||
|
"socket.io-parser": "~3.4.0"
|
||||||
|
},
|
||||||
|
"deprecated": false,
|
||||||
|
"description": "node.js realtime framework server",
|
||||||
|
"devDependencies": {
|
||||||
|
"expect.js": "0.3.1",
|
||||||
|
"mocha": "^3.5.3",
|
||||||
|
"nyc": "^11.2.1",
|
||||||
|
"superagent": "^3.8.2",
|
||||||
|
"supertest": "^3.0.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib/"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/socketio/socket.io#readme",
|
||||||
|
"keywords": [
|
||||||
|
"realtime",
|
||||||
|
"framework",
|
||||||
|
"websocket",
|
||||||
|
"tcp",
|
||||||
|
"events",
|
||||||
|
"socket",
|
||||||
|
"io"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "./lib/index",
|
||||||
|
"name": "socket.io",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/socketio/socket.io.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "nyc mocha --reporter spec --slow 200 --bail --timeout 10000 test/socket.io.js"
|
||||||
|
},
|
||||||
|
"version": "2.4.1"
|
||||||
|
}
|
@ -0,0 +1,332 @@
|
|||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font: 1.0em/1.6 'Inconsolata', monospace;
|
||||||
|
color: #c9cdc0;
|
||||||
|
font-weight: 400;
|
||||||
|
background-color: rgb(26, 26, 26);
|
||||||
|
text-shadow: red;
|
||||||
|
/* overflow-y: hidden;
|
||||||
|
overflow-x: hidden; */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use a media query to add a breakpoint at 800px: */
|
||||||
|
@media screen and (max-width: 800px) {
|
||||||
|
.left, .main, .right {
|
||||||
|
width: 100%; /* The width is 100%, when the viewport is 800px or smaller */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#map{
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
/* margin-top:2.5vh; */
|
||||||
|
margin-bottom:2.5vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
#zoommap{
|
||||||
|
position: fixed;
|
||||||
|
width: 68%;
|
||||||
|
/* margin-left: auto;
|
||||||
|
margin-right: auto; */
|
||||||
|
/* margin-top:2.5vh; */
|
||||||
|
top: 10px;
|
||||||
|
margin-bottom:2.5vh;
|
||||||
|
display:none;
|
||||||
|
/* height: 60vh; */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#svg55{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .zoom>img{
|
||||||
|
height: calc(100vh - 60px);
|
||||||
|
width: auto;
|
||||||
|
} */
|
||||||
|
|
||||||
|
/* #dreammap{
|
||||||
|
height: 90vh;
|
||||||
|
|
||||||
|
} */
|
||||||
|
|
||||||
|
#gateway-distance{
|
||||||
|
font: 1.2em/1.6 'Inconsolata', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-left {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
/* border: 2px solid #c9cdc0; */
|
||||||
|
border-radius: 2px;
|
||||||
|
/* margin-right:3px; */
|
||||||
|
padding: 5px;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
|
background-color:rgb(26, 26, 26, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .flex-right {
|
||||||
|
width: 45%;
|
||||||
|
height: 100vh;
|
||||||
|
/* border: 5px solid #c9cdc0; */
|
||||||
|
/* border-radius: 2px;
|
||||||
|
padding: 5px;
|
||||||
|
padding-right: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
|
background-color:rgb(26, 26, 26);
|
||||||
|
} */
|
||||||
|
|
||||||
|
.section{
|
||||||
|
border: 2px solid #3d3f38;
|
||||||
|
border-radius:6px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 5px;
|
||||||
|
margin-bottom:6px;
|
||||||
|
color: #ff4000;
|
||||||
|
background-color: #0e0e0a;
|
||||||
|
}
|
||||||
|
.section2{
|
||||||
|
border: 2px solid #3d3f38;
|
||||||
|
border-radius:6px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
padding: 5px;
|
||||||
|
margin-bottom:6px;
|
||||||
|
color: rgb(88, 130, 255);
|
||||||
|
background-color: #0e0e0a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-base{
|
||||||
|
padding: 5px;
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-console{
|
||||||
|
color: #c9cdc0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#scene1{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#input{
|
||||||
|
background-color: #c9cdc0;
|
||||||
|
border: 2px solid black;
|
||||||
|
font: 1.2em/1.6 'Inconsolata', monospace;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-ms-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button{
|
||||||
|
background-color: rgb(129, 135, 121);
|
||||||
|
font: 1.2em/1.6 'Inconsolata', monospace;
|
||||||
|
color:black;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 2px solid black;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-ms-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
margin-left: 2px;
|
||||||
|
padding-left: 4px;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:active{
|
||||||
|
background-color: rgb(65, 184, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#log{
|
||||||
|
visibility: hidden;
|
||||||
|
background-color: rgb(177, 193, 213);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
#back{
|
||||||
|
visibility: hidden;
|
||||||
|
width: 22%;
|
||||||
|
background-color: #c9cdc0;
|
||||||
|
color: black;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#back2{
|
||||||
|
display: none;
|
||||||
|
width: 22%;
|
||||||
|
background-color: #c9cdc0;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
#log1{
|
||||||
|
display: none;
|
||||||
|
background-color: rgb(65, 184, 255);
|
||||||
|
border: none;
|
||||||
|
border-radius: 0px;
|
||||||
|
color: black;
|
||||||
|
padding: 1px;
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#log2{
|
||||||
|
display: none;
|
||||||
|
background-color: rgb(65, 184, 255);
|
||||||
|
color: black;
|
||||||
|
border-radius: 0px;
|
||||||
|
border: none;
|
||||||
|
padding: 1px;
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
#log3{
|
||||||
|
display: none;
|
||||||
|
background-color: rgb(65, 184, 255);
|
||||||
|
color: black;
|
||||||
|
border-radius: 0px;
|
||||||
|
border: none;
|
||||||
|
padding: 1px;
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
#log4{
|
||||||
|
display: none;
|
||||||
|
background-color: rgb(65, 184, 255);
|
||||||
|
color: black;
|
||||||
|
border-radius: 0px;
|
||||||
|
border: none;
|
||||||
|
padding: 1px;
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
#log5{
|
||||||
|
display: none;
|
||||||
|
background-color: rgb(65, 184, 255);
|
||||||
|
color: black;
|
||||||
|
border-radius: 0px;
|
||||||
|
border: none;
|
||||||
|
padding: 1px;
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#log1:active{
|
||||||
|
|
||||||
|
background-color: rgb(129, 135, 121);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#log2:active{
|
||||||
|
|
||||||
|
background-color: rgb(129, 135, 121);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#log3:active{
|
||||||
|
|
||||||
|
background-color: rgb(129, 135, 121);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#log4:active{
|
||||||
|
|
||||||
|
background-color: rgb(129, 135, 121);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#log5:active{
|
||||||
|
|
||||||
|
background-color: rgb(129, 135, 121);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#dreamlog{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.flex-top {
|
||||||
|
position: absolute;
|
||||||
|
top:0px;
|
||||||
|
width: 100vw;
|
||||||
|
height: 50vh;
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 5px;
|
||||||
|
padding-right: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
|
background-color:rgb(26, 26, 26);
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-bottom {
|
||||||
|
position: absolute;
|
||||||
|
bottom:0px;
|
||||||
|
width: 100vw;
|
||||||
|
height: 50vh;
|
||||||
|
bottom:0px;
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 5px;
|
||||||
|
padding-right: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
|
background-color:rgb(26,26,26);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section2{
|
||||||
|
display: flex;
|
||||||
|
border: 2px solid black;
|
||||||
|
border-radius:1px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction:row;
|
||||||
|
padding: 5px;
|
||||||
|
margin-bottom:6px;
|
||||||
|
color: white;
|
||||||
|
background-color: black;
|
||||||
|
width: 30vw;
|
||||||
|
}
|
||||||
|
.flex-container2 {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rect13:active{
|
||||||
|
fill:yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rect15:active{
|
||||||
|
fill:yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrapper{
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 450px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fullscreen-video {
|
||||||
|
position: fixed;
|
||||||
|
overflow: hidden;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
min-width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
transform: translateX(-50%) translateY(-50%);
|
||||||
|
z-index: -10;
|
||||||
|
}
|
Loading…
Reference in New Issue