UNPKG

oxygen-core

Version:

Oxygen game engine (Xenon Core for browsers)

1,494 lines (1,493 loc) 343 kB
{ "type": "File", "start": 0, "end": 3118, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 136, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 3118, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 136, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 37, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 37 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 13, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 13 } }, "local": { "type": "Identifier", "start": 7, "end": 13, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 13 }, "identifierName": "Events" }, "name": "Events" } } ], "source": { "type": "StringLiteral", "start": 19, "end": 36, "loc": { "start": { "line": 1, "column": 19 }, "end": { "line": 1, "column": 36 } }, "extra": { "rawValue": "../utils/Events", "raw": "'../utils/Events'" }, "value": "../utils/Events" } }, { "type": "ImportDeclaration", "start": 39, "end": 84, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 45 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 48, "end": 65, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 26 } }, "imported": { "type": "Identifier", "start": 48, "end": 65, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 26 }, "identifierName": "findMapKeyOfValue" }, "name": "findMapKeyOfValue" }, "local": { "type": "Identifier", "start": 48, "end": 65, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 26 }, "identifierName": "findMapKeyOfValue" }, "name": "findMapKeyOfValue" } } ], "source": { "type": "StringLiteral", "start": 73, "end": 83, "loc": { "start": { "line": 2, "column": 34 }, "end": { "line": 2, "column": 44 } }, "extra": { "rawValue": "../utils", "raw": "'../utils'" }, "value": "../utils" } }, { "type": "VariableDeclaration", "start": 88, "end": 115, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 27 } }, "declarations": [ { "type": "VariableDeclarator", "start": 94, "end": 114, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 26 } }, "id": { "type": "Identifier", "start": 94, "end": 102, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 14 }, "identifierName": "_systems" }, "name": "_systems" }, "init": { "type": "NewExpression", "start": 105, "end": 114, "loc": { "start": { "line": 4, "column": 17 }, "end": { "line": 4, "column": 26 } }, "callee": { "type": "Identifier", "start": 109, "end": 112, "loc": { "start": { "line": 4, "column": 21 }, "end": { "line": 4, "column": 24 }, "identifierName": "Map" }, "name": "Map" }, "arguments": [] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 117, "end": 146, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 29 } }, "declarations": [ { "type": "VariableDeclarator", "start": 123, "end": 145, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 28 } }, "id": { "type": "Identifier", "start": 123, "end": 130, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 13 }, "identifierName": "_events" }, "name": "_events" }, "init": { "type": "NewExpression", "start": 133, "end": 145, "loc": { "start": { "line": 5, "column": 16 }, "end": { "line": 5, "column": 28 } }, "callee": { "type": "Identifier", "start": 137, "end": 143, "loc": { "start": { "line": 5, "column": 20 }, "end": { "line": 5, "column": 26 }, "identifierName": "Events" }, "name": "Events" }, "arguments": [] } } ], "kind": "const", "trailingComments": [ { "type": "CommentBlock", "value": "*\r\n * System base class.\r\n * Every Oxygen Core system extends this class.\r\n ", "start": 150, "end": 230, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 10, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 232, "end": 3116, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 135, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 247, "end": 3116, "loc": { "start": { "line": 11, "column": 15 }, "end": { "line": 135, "column": 1 } }, "id": { "type": "Identifier", "start": 253, "end": 259, "loc": { "start": { "line": 11, "column": 21 }, "end": { "line": 11, "column": 27 }, "identifierName": "System" }, "name": "System", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 260, "end": 3116, "loc": { "start": { "line": 11, "column": 28 }, "end": { "line": 135, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 287, "end": 445, "loc": { "start": { "line": 14, "column": 2 }, "end": { "line": 22, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 298, "end": 305, "loc": { "start": { "line": 14, "column": 13 }, "end": { "line": 14, "column": 20 }, "identifierName": "systems" }, "name": "systems" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 308, "end": 445, "loc": { "start": { "line": 14, "column": 23 }, "end": { "line": 22, "column": 3 } }, "body": [ { "type": "VariableDeclaration", "start": 315, "end": 333, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 15, "column": 22 } }, "declarations": [ { "type": "VariableDeclarator", "start": 321, "end": 332, "loc": { "start": { "line": 15, "column": 10 }, "end": { "line": 15, "column": 21 } }, "id": { "type": "Identifier", "start": 321, "end": 327, "loc": { "start": { "line": 15, "column": 10 }, "end": { "line": 15, "column": 16 }, "identifierName": "result" }, "name": "result" }, "init": { "type": "ObjectExpression", "start": 330, "end": 332, "loc": { "start": { "line": 15, "column": 19 }, "end": { "line": 15, "column": 21 } }, "properties": [] } } ], "kind": "const" }, { "type": "ForOfStatement", "start": 341, "end": 418, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 19, "column": 5 } }, "left": { "type": "VariableDeclaration", "start": 346, "end": 366, "loc": { "start": { "line": 17, "column": 9 }, "end": { "line": 17, "column": 29 } }, "declarations": [ { "type": "VariableDeclarator", "start": 352, "end": 366, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 17, "column": 29 } }, "id": { "type": "ArrayPattern", "start": 352, "end": 366, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 17, "column": 29 } }, "elements": [ { "type": "Identifier", "start": 353, "end": 357, "loc": { "start": { "line": 17, "column": 16 }, "end": { "line": 17, "column": 20 }, "identifierName": "name" }, "name": "name" }, { "type": "Identifier", "start": 359, "end": 365, "loc": { "start": { "line": 17, "column": 22 }, "end": { "line": 17, "column": 28 }, "identifierName": "system" }, "name": "system" } ] }, "init": null } ], "kind": "const" }, "right": { "type": "Identifier", "start": 370, "end": 378, "loc": { "start": { "line": 17, "column": 33 }, "end": { "line": 17, "column": 41 }, "identifierName": "_systems" }, "name": "_systems" }, "body": { "type": "BlockStatement", "start": 380, "end": 418, "loc": { "start": { "line": 17, "column": 43 }, "end": { "line": 19, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 389, "end": 411, "loc": { "start": { "line": 18, "column": 6 }, "end": { "line": 18, "column": 28 } }, "expression": { "type": "AssignmentExpression", "start": 389, "end": 410, "loc": { "start": { "line": 18, "column": 6 }, "end": { "line": 18, "column": 27 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 389, "end": 401, "loc": { "start": { "line": 18, "column": 6 }, "end": { "line": 18, "column": 18 } }, "object": { "type": "Identifier", "start": 389, "end": 395, "loc": { "start": { "line": 18, "column": 6 }, "end": { "line": 18, "column": 12 }, "identifierName": "result" }, "name": "result" }, "property": { "type": "Identifier", "start": 396, "end": 400, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 17 }, "identifierName": "name" }, "name": "name" }, "computed": true }, "right": { "type": "Identifier", "start": 404, "end": 410, "loc": { "start": { "line": 18, "column": 21 }, "end": { "line": 18, "column": 27 }, "identifierName": "system" }, "name": "system" } } } ], "directives": [] } }, { "type": "ReturnStatement", "start": 426, "end": 440, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 18 } }, "argument": { "type": "Identifier", "start": 433, "end": 439, "loc": { "start": { "line": 21, "column": 11 }, "end": { "line": 21, "column": 17 }, "identifierName": "result" }, "name": "result" } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {*} ", "start": 267, "end": 283, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 18 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Events} ", "start": 451, "end": 472, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 24, "column": 23 } } } ] }, { "type": "ClassMethod", "start": 476, "end": 523, "loc": { "start": { "line": 25, "column": 2 }, "end": { "line": 27, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 487, "end": 493, "loc": { "start": { "line": 25, "column": 13 }, "end": { "line": 25, "column": 19 }, "identifierName": "events" }, "name": "events" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 496, "end": 523, "loc": { "start": { "line": 25, "column": 22 }, "end": { "line": 27, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 503, "end": 518, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 26, "column": 19 } }, "argument": { "type": "Identifier", "start": 510, "end": 517, "loc": { "start": { "line": 26, "column": 11 }, "end": { "line": 26, "column": 18 }, "identifierName": "_events" }, "name": "_events" } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Events} ", "start": 451, "end": 472, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 24, "column": 23 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\r\n * Register new system instance under given name.\r\n *\r\n * @param {string}\ttypename - System type name.\r\n * @param {System}\tsystem - System instance.\r\n *\r\n * @return {System} Registered system instance.\r\n *\r\n * @example\r\n * class MySystem extends System {}\r\n * System.register('MySystem', new MySystem());\r\n * const { MySystem } = System.systems;\r\n ", "start": 529, "end": 908, "loc": { "start": { "line": 29, "column": 2 }, "end": { "line": 41, "column": 5 } } } ] }, { "type": "ClassMethod", "start": 912, "end": 1376, "loc": { "start": { "line": 42, "column": 2 }, "end": { "line": 57, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 919, "end": 927, "loc": { "start": { "line": 42, "column": 9 }, "end": { "line": 42, "column": 17 }, "identifierName": "register" }, "name": "register" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 928, "end": 936, "loc": { "start": { "line": 42, "column": 18 }, "end": { "line": 42, "column": 26 }, "identifierName": "typename" }, "name": "typename" }, { "type": "Identifier", "start": 938, "end": 944, "loc": { "start": { "line": 42, "column": 28 }, "end": { "line": 42, "column": 34 }, "identifierName": "system" }, "name": "system" } ], "body": { "type": "BlockStatement", "start": 946, "end": 1376, "loc": { "start": { "line": 42, "column": 36 }, "end": { "line": 57, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 953, "end": 1056, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 45, "column": 5 } }, "test": { "type": "BinaryExpression", "start": 957, "end": 985, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 36 } }, "left": { "type": "UnaryExpression", "start": 957, "end": 972, "loc": { "start": { "line": 43, "column": 8 }, "end": { "line": 43, "column": 23 } }, "operator": "typeof", "prefix": true, "argument": { "type": "Identifier", "start": 964, "end": 972, "loc": { "start": { "line": 43, "column": 15 }, "end": { "line": 43, "column": 23 }, "identifierName": "typename" }, "name": "typename" }, "extra": { "parenthesizedArgument": false } }, "operator": "!==", "right": { "type": "StringLiteral", "start": 977, "end": 985, "loc": { "start": { "line": 43, "column": 28 }, "end": { "line": 43, "column": 36 } }, "extra": { "rawValue": "string", "raw": "'string'" }, "value": "string" } }, "consequent": { "type": "BlockStatement", "start": 987, "end": 1056, "loc": { "start": { "line": 43, "column": 38 }, "end": { "line": 45, "column": 5 } }, "body": [ { "type": "ThrowStatement", "start": 996, "end": 1049, "loc": { "start": { "line": 44, "column": 6 }, "end": { "line": 44, "column": 59 } }, "argument": { "type": "NewExpression", "start": 1002, "end": 1048, "loc": { "start": { "line": 44, "column": 12 }, "end": { "line": 44, "column": 58 } }, "callee": { "type": "Identifier", "start": 1006, "end": 1011, "loc": { "start": { "line": 44, "column": 16 }, "end": { "line": 44, "column": 21 }, "identifierName": "Error" }, "name": "Error" }, "arguments": [ { "type": "StringLiteral", "start": 1012, "end": 1047, "loc": { "start": { "line": 44, "column": 22 }, "end": { "line": 44, "column": 57 } }, "extra": { "rawValue": "`typename` is not type of String!", "raw": "'`typename` is not type of String!'" }, "value": "`typename` is not type of String!" } ] } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 1062, "end": 1162, "loc": { "start": { "line": 46, "column": 4 }, "end": { "line": 48, "column": 5 } }, "test": { "type": "UnaryExpression", "start": 1066, "end": 1093, "loc": { "start": { "line": 46, "column": 8 }, "end": { "line": 46, "column": 35 } }, "operator": "!", "prefix": true, "argument": { "type": "BinaryExpression", "start": 1068, "end": 1092, "loc": { "start": { "line": 46, "column": 10 }, "end": { "line": 46, "column": 34 } }, "left": { "type": "Identifier", "start": 1068, "end": 1074, "loc": { "start": { "line": 46, "column": 10 }, "end": { "line": 46, "column": 16 }, "identifierName": "system" }, "name": "system" }, "operator": "instanceof", "right": { "type": "Identifier", "start": 1086, "end": 1092, "loc": { "start": { "line": 46, "column": 28 }, "end": { "line": 46, "column": 34 }, "identifierName": "System" }, "name": "System" }, "extra": { "parenthesized": true, "parenStart": 1067 } }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 1095, "end": 1162, "loc": { "start": { "line": 46, "column": 37 }, "end": { "line": 48, "column": 5 } }, "body": [ { "type": "ThrowStatement", "start": 1104, "end": 1155, "loc": { "start": { "line": 47, "column": 6 }, "end": { "line": 47, "column": 57 } }, "argument": { "type": "NewExpression", "start": 1110, "end": 1154, "loc": { "start": { "line": 47, "column": 12 }, "end": { "line": 47, "column": 56 } }, "callee": { "type": "Identifier", "start": 1114, "end": 1119, "loc": { "start": { "line": 47, "column": 16 }, "end": { "line": 47, "column": 21 }, "identifierName": "Error" }, "name": "Error" }, "arguments": [ { "type": "StringLiteral", "start": 1120, "end": 1153, "loc": { "start": { "line": 47, "column": 22 }, "end": { "line": 47, "column": 55 } }, "extra": { "rawValue": "`system` is not type of System!", "raw": "'`system` is not type of System!'" }, "value": "`system` is not type of System!" } ] } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 1170, "end": 1286, "loc": { "start": { "line": 50, "column": 4 }, "end": { "line": 52, "column": 5 } }, "test": { "type": "CallExpression", "start": 1174, "end": 1196, "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 30 } }, "callee": { "type": "MemberExpression", "start": 1174, "end": 1186, "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 20 } }, "object": { "type": "Identifier", "start": 1174, "end": 1182, "loc": { "start": { "line": 50, "column": 8 }, "end": { "line": 50, "column": 16 }, "identifierName": "_systems" }, "name": "_systems" }, "property": { "type": "Identifier", "start": 1183, "end": 1186, "loc": { "start": { "line": 50, "column": 17