UNPKG

@theopenweb/js-sensor

Version:

JavaScript sensor library for native input sensors.

884 lines (883 loc) 969 kB
{ "type": "File", "start": 0, "end": 6752, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 162, "column": 34 } }, "program": { "type": "Program", "start": 0, "end": 6752, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 162, "column": 34 } }, "sourceType": "module", "body": [ { "type": "ClassDeclaration", "start": 190, "end": 6714, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 160, "column": 1 } }, "id": { "type": "Identifier", "start": 196, "end": 212, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 22 }, "identifierName": "RawSensorWatcher" }, "name": "RawSensorWatcher", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 213, "end": 6714, "loc": { "start": { "line": 6, "column": 23 }, "end": { "line": 160, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 222, "end": 4652, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 90, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 222, "end": 233, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 8, "column": 15 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 235, "end": 4652, "loc": { "start": { "line": 8, "column": 17 }, "end": { "line": 90, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 557, "end": 4645, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 89, "column": 10 } }, "expression": { "type": "AssignmentExpression", "start": 557, "end": 4644, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 89, "column": 9 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 557, "end": 575, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 26 } }, "object": { "type": "ThisExpression", "start": 557, "end": 561, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 562, "end": 575, "loc": { "start": { "line": 15, "column": 13 }, "end": { "line": 15, "column": 26 }, "identifierName": "sensorHandles" }, "name": "sensorHandles" }, "computed": false, "leadingComments": null }, "right": { "type": "ObjectExpression", "start": 578, "end": 4644, "loc": { "start": { "line": 15, "column": 29 }, "end": { "line": 89, "column": 9 } }, "properties": [ { "type": "ObjectProperty", "start": 596, "end": 1319, "loc": { "start": { "line": 16, "column": 15 }, "end": { "line": 30, "column": 16 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 596, "end": 609, "loc": { "start": { "line": 16, "column": 15 }, "end": { "line": 16, "column": 28 }, "identifierName": "watchPosition" }, "name": "watchPosition" }, "value": { "type": "ObjectExpression", "start": 611, "end": 1319, "loc": { "start": { "line": 16, "column": 30 }, "end": { "line": 30, "column": 16 } }, "properties": [ { "type": "ObjectProperty", "start": 633, "end": 1201, "loc": { "start": { "line": 17, "column": 19 }, "end": { "line": 28, "column": 21 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 633, "end": 638, "loc": { "start": { "line": 17, "column": 19 }, "end": { "line": 17, "column": 24 }, "identifierName": "start" }, "name": "start" }, "value": { "type": "ArrowFunctionExpression", "start": 640, "end": 1201, "loc": { "start": { "line": 17, "column": 26 }, "end": { "line": 28, "column": 21 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 641, "end": 648, "loc": { "start": { "line": 17, "column": 27 }, "end": { "line": 17, "column": 34 }, "identifierName": "options" }, "name": "options" } ], "body": { "type": "BlockStatement", "start": 651, "end": 1201, "loc": { "start": { "line": 17, "column": 37 }, "end": { "line": 28, "column": 21 } }, "body": [ { "type": "VariableDeclaration", "start": 677, "end": 717, "loc": { "start": { "line": 18, "column": 23 }, "end": { "line": 18, "column": 63 } }, "declarations": [ { "type": "VariableDeclarator", "start": 681, "end": 716, "loc": { "start": { "line": 18, "column": 27 }, "end": { "line": 18, "column": 62 } }, "id": { "type": "Identifier", "start": 681, "end": 694, "loc": { "start": { "line": 18, "column": 27 }, "end": { "line": 18, "column": 40 }, "identifierName": "eventListener" }, "name": "eventListener" }, "init": { "type": "MemberExpression", "start": 697, "end": 716, "loc": { "start": { "line": 18, "column": 43 }, "end": { "line": 18, "column": 62 } }, "object": { "type": "MemberExpression", "start": 697, "end": 711, "loc": { "start": { "line": 18, "column": 43 }, "end": { "line": 18, "column": 57 } }, "object": { "type": "Identifier", "start": 697, "end": 704, "loc": { "start": { "line": 18, "column": 43 }, "end": { "line": 18, "column": 50 }, "identifierName": "options" }, "name": "options" }, "property": { "type": "Identifier", "start": 705, "end": 711, "loc": { "start": { "line": 18, "column": 51 }, "end": { "line": 18, "column": 57 }, "identifierName": "events" }, "name": "events" }, "computed": false }, "property": { "type": "Identifier", "start": 712, "end": 716, "loc": { "start": { "line": 18, "column": 58 }, "end": { "line": 18, "column": 62 }, "identifierName": "data" }, "name": "data" }, "computed": false } } ], "kind": "let" }, { "type": "ReturnStatement", "start": 742, "end": 1178, "loc": { "start": { "line": 19, "column": 23 }, "end": { "line": 27, "column": 27 } }, "argument": { "type": "NewExpression", "start": 749, "end": 1177, "loc": { "start": { "line": 19, "column": 30 }, "end": { "line": 27, "column": 26 } }, "callee": { "type": "Identifier", "start": 753, "end": 760, "loc": { "start": { "line": 19, "column": 34 }, "end": { "line": 19, "column": 41 }, "identifierName": "Promise" }, "name": "Promise" }, "arguments": [ { "type": "ArrowFunctionExpression", "start": 761, "end": 1176, "loc": { "start": { "line": 19, "column": 42 }, "end": { "line": 27, "column": 25 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 762, "end": 769, "loc": { "start": { "line": 19, "column": 43 }, "end": { "line": 19, "column": 50 }, "identifierName": "resolve" }, "name": "resolve" }, { "type": "Identifier", "start": 771, "end": 777, "loc": { "start": { "line": 19, "column": 52 }, "end": { "line": 19, "column": 58 }, "identifierName": "reject" }, "name": "reject" } ], "body": { "type": "BlockStatement", "start": 780, "end": 1176, "loc": { "start": { "line": 19, "column": 61 }, "end": { "line": 27, "column": 25 } }, "body": [ { "type": "VariableDeclaration", "start": 810, "end": 1105, "loc": { "start": { "line": 20, "column": 27 }, "end": { "line": 25, "column": 30 } }, "declarations": [ { "type": "VariableDeclarator", "start": 814, "end": 1104, "loc": { "start": { "line": 20, "column": 31 }, "end": { "line": 25, "column": 29 } }, "id": { "type": "Identifier", "start": 814, "end": 816, "loc": { "start": { "line": 20, "column": 31 }, "end": { "line": 20, "column": 33 }, "identifierName": "id" }, "name": "id" }, "init": { "type": "CallExpression", "start": 819, "end": 1104, "loc": { "start": { "line": 20, "column": 36 }, "end": { "line": 25, "column": 29 } }, "callee": { "type": "MemberExpression", "start": 819, "end": 854, "loc": { "start": { "line": 20, "column": 36 }, "end": { "line": 20, "column": 71 } }, "object": { "type": "MemberExpression", "start": 819, "end": 840, "loc": { "start": { "line": 20, "column": 36 }, "end": { "line": 20, "column": 57 } }, "object": { "type": "Identifier", "start": 819, "end": 828, "loc": { "start": { "line": 20, "column": 36 }, "end": { "line": 20, "column": 45 }, "identifierName": "navigator" }, "name": "navigator" }, "property": { "type": "Identifier", "start": 829, "end": 840, "loc": { "start": { "line": 20, "column": 46 }, "end": { "line": 20, "column": 57 }, "identifierName": "geolocation" }, "name": "geolocation" }, "computed": false }, "property": { "type": "Identifier", "start": 841, "end": 854, "loc": { "start": { "line": 20, "column": 58 }, "end": { "line": 20, "column": 71 }, "identifierName": "watchPosition" }, "name": "watchPosition" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 888, "end": 901, "loc": { "start": { "line": 21, "column": 31 }, "end": { "line": 21, "column": 44 }, "identifierName": "eventListener" }, "name": "eventListener" }, { "type": "ArrowFunctionExpression", "start": 935, "end": 1073, "loc": { "start": { "line": 22, "column": 31 }, "end": { "line": 24, "column": 33 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 936, "end": 939, "loc": { "start": { "line": 22, "column": 32 }, "end": { "line": 22, "column": 35 }, "identifierName": "err" }, "name": "err" } ], "body": { "type": "BlockStatement", "start": 942, "end": 1073, "loc": { "start": { "line": 22, "column": 38 }, "end": { "line": 24, "column": 33 } }, "body": [ { "type": "ReturnStatement", "start": 980, "end": 1038, "loc": { "start": { "line": 23, "column": 35 }, "end": { "line": 23, "column": 93 } }, "argument": { "type": "CallExpression", "start": 987, "end": 1037, "loc": { "start": { "line": 23, "column": 42 }, "end": { "line": 23, "column": 92 } }, "callee": { "type": "Identifier", "start": 987, "end": 993, "loc": { "start": { "line": 23, "column": 42 }, "end": { "line": 23, "column": 48 }, "identifierName": "reject" }, "name": "reject" }, "arguments": [ { "type": "CallExpression", "start": 994, "end": 1036, "loc": { "start": { "line": 23, "column": 49 }, "end": { "line": 23, "column": 91 } }, "callee": {