UNPKG

gs-events

Version:

事件分发器(同步)

1,631 lines (1,630 loc) 141 kB
{ "type": "File", "start": 0, "end": 3579, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 84, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 3579, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 84, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 2394, "end": 2422, "loc": { "start": { "line": 38, "column": 0 }, "end": { "line": 38, "column": 28 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 2401, "end": 2406, "loc": { "start": { "line": 38, "column": 7 }, "end": { "line": 38, "column": 12 } }, "local": { "type": "Identifier", "start": 2401, "end": 2406, "loc": { "start": { "line": 38, "column": 7 }, "end": { "line": 38, "column": 12 }, "identifierName": "Event" }, "name": "Event", "leadingComments": null }, "leadingComments": null } ], "source": { "type": "StringLiteral", "start": 2412, "end": 2421, "loc": { "start": { "line": 38, "column": 18 }, "end": { "line": 38, "column": 27 } }, "extra": { "rawValue": "./Event", "raw": "\"./Event\"" }, "value": "./Event" }, "leadingComments": [ { "type": "CommentLine", "value": "/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", "start": 0, "end": 78, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 78 } } }, { "type": "CommentLine", "value": "/ @Copyright ~2018 ☜Samlv9☞ and other contributors", "start": 79, "end": 131, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 52 } } }, { "type": "CommentLine", "value": "/ @MIT-LICENSE | 1.0.0 | https://api.guless.com/", "start": 132, "end": 182, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 50 } } }, { "type": "CommentLine", "value": "/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", "start": 183, "end": 261, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 78 } } }, { "type": "CommentLine", "value": "/ }|", "start": 262, "end": 313, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 51 } } }, { "type": "CommentLine", "value": "/ }|", "start": 314, "end": 365, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 51 } } }, { "type": "CommentLine", "value": "/ }|   へ    /| ", "start": 366, "end": 435, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 69 } } }, { "type": "CommentLine", "value": "/ _______ _______ ______ }| / │   / /", "start": 436, "end": 502, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 66 } } }, { "type": "CommentLine", "value": "/ / ___ | |_ __ \\ .' ____ '. }| │ Z _,< /   /`ヽ", "start": 503, "end": 574, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 71 } } }, { "type": "CommentLine", "value": "/ | (__ \\_| | |__) | | (____) | }| │     ヽ   /  〉", "start": 575, "end": 645, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 70 } } }, { "type": "CommentLine", "value": "/ '.___`-. | __ / '_.____. | }| Y     `  /  /", "start": 646, "end": 716, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 70 } } }, { "type": "CommentLine", "value": "/ |`\\____) | _| | \\ \\_ | \\____| | }| イ● 、 ●  ⊂⊃〈  /", "start": 717, "end": 786, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 12, "column": 69 } } }, { "type": "CommentLine", "value": "/ |_______.' |____| |___| \\______,' }| ()  v    | \〈", "start": 787, "end": 855, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 13, "column": 68 } } }, { "type": "CommentLine", "value": "/ |=========================================\\|  >ー 、_  ィ  │ //", "start": 856, "end": 926, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 14, "column": 70 } } }, { "type": "CommentLine", "value": "/ |> LESS IS MORE || / へ   / ノ<|\\", "start": 927, "end": 996, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 15, "column": 69 } } }, { "type": "CommentLine", "value": "/ `=========================================/| ヽ_ノ  (_/  │//", "start": 997, "end": 1065, "loc": { "start": { "line": 16, "column": 0 }, "end": { "line": 16, "column": 68 } } }, { "type": "CommentLine", "value": "/ }| 7       |/", "start": 1066, "end": 1133, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 17, "column": 67 } } }, { "type": "CommentLine", "value": "/ }| >―r ̄ ̄`ー―_`", "start": 1134, "end": 1200, "loc": { "start": { "line": 18, "column": 0 }, "end": { "line": 18, "column": 66 } } }, { "type": "CommentLine", "value": "/ }|", "start": 1201, "end": 1252, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 19, "column": 51 } } }, { "type": "CommentLine", "value": "/ }|", "start": 1253, "end": 1304, "loc": { "start": { "line": 20, "column": 0 }, "end": { "line": 20, "column": 51 } } }, { "type": "CommentLine", "value": "/ Permission is hereby granted, free of charge, to any person obtaining a copy", "start": 1305, "end": 1385, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 21, "column": 80 } } }, { "type": "CommentLine", "value": "/ of this software and associated documentation files (the \"Software\"), to deal", "start": 1386, "end": 1467, "loc": { "start": { "line": 22, "column": 0 }, "end": { "line": 22, "column": 81 } } }, { "type": "CommentLine", "value": "/ in the Software without restriction, including without limitation the rights", "start": 1468, "end": 1548, "loc": { "start": { "line": 23, "column": 0 }, "end": { "line": 23, "column": 80 } } }, { "type": "CommentLine", "value": "/ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell", "start": 1549, "end": 1626, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 24, "column": 77 } } }, { "type": "CommentLine", "value": "/ copies of the Software, and to permit persons to whom the Software is", "start": 1627, "end": 1700, "loc": { "start": { "line": 25, "column": 0 }, "end": { "line": 25, "column": 73 } } }, { "type": "CommentLine", "value": "/ furnished to do so, subject to the following conditions:", "start": 1701, "end": 1761, "loc": { "start": { "line": 26, "column": 0 }, "end": { "line": 26, "column": 60 } } }, { "type": "CommentLine", "value": "/", "start": 1762, "end": 1765, "loc": { "start": { "line": 27, "column": 0 }, "end": { "line": 27, "column": 3 } } }, { "type": "CommentLine", "value": "/ The above copyright notice and this permission notice shall be included in all", "start": 1766, "end": 1848, "loc": { "start": { "line": 28, "column": 0 }, "end": { "line": 28, "column": 82 } } }, { "type": "CommentLine", "value": "/ copies or substantial portions of the Software.", "start": 1849, "end": 1900, "loc": { "start": { "line": 29, "column": 0 }, "end": { "line": 29, "column": 51 } } }, { "type": "CommentLine", "value": "/", "start": 1901, "end": 1904, "loc": { "start": { "line": 30, "column": 0 }, "end": { "line": 30, "column": 3 } } }, { "type": "CommentLine", "value": "/ THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", "start": 1905, "end": 1983, "loc": { "start": { "line": 31, "column": 0 }, "end": { "line": 31, "column": 78 } } }, { "type": "CommentLine", "value": "/ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", "start": 1984, "end": 2060, "loc": { "start": { "line": 32, "column": 0 }, "end": { "line": 32, "column": 76 } } }, { "type": "CommentLine", "value": "/ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", "start": 2061, "end": 2140, "loc": { "start": { "line": 33, "column": 0 }, "end": { "line": 33, "column": 79 } } }, { "type": "CommentLine", "value": "/ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", "start": 2141, "end": 2215, "loc": { "start": { "line": 34, "column": 0 }, "end": { "line": 34, "column": 74 } } }, { "type": "CommentLine", "value": "/ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", "start": 2216, "end": 2297, "loc": { "start": { "line": 35, "column": 0 }, "end": { "line": 35, "column": 81 } } }, { "type": "CommentLine", "value": "/ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN", "start": 2298, "end": 2375, "loc": { "start": { "line": 36, "column": 0 }, "end": { "line": 36, "column": 77 } } }, { "type": "CommentLine", "value": "/ THE SOFTWARE.", "start": 2376, "end": 2393, "loc": { "start": { "line": 37, "column": 0 }, "end": { "line": 37, "column": 17 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * 定义携带自定义数据的事件对象。\n * @see {@link Event}\n * @since 1.0.9\n ", "start": 2424, "end": 2488, "loc": { "start": { "line": 40, "column": 0 }, "end": { "line": 44, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 2489, "end": 3579, "loc": { "start": { "line": 45, "column": 0 }, "end": { "line": 84, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 2504, "end": 3579, "loc": { "start": { "line": 45, "column": 15 }, "end": { "line": 84, "column": 1 } }, "id": { "type": "Identifier", "start": 2510, "end": 2521, "loc": { "start": { "line": 45, "column": 21 }, "end": { "line": 45, "column": 32 }, "identifierName": "CustomEvent" }, "name": "CustomEvent", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 2530, "end": 2535, "loc": { "start": { "line": 45, "column": 41 }, "end": { "line": 45, "column": 46 }, "identifierName": "Event" }, "name": "Event" }, "body": { "type": "ClassBody", "start": 2536, "end": 3579, "loc": { "start": { "line": 45, "column": 47 }, "end": { "line": 84, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 2820, "end": 2965, "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 58, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 2820, "end": 2831, "loc": { "start": { "line": 55, "column": 4 }, "end": { "line": 55, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 2833, "end": 2837, "loc": { "start": { "line": 55, "column": 17 }, "end": { "line": 55, "column": 21 }, "identifierName": "type" }, "name": "type" }, { "type": "AssignmentPattern", "start": 2839, "end": 2850, "loc": { "start": { "line": 55, "column": 23 }, "end": { "line": 55, "column": 34 } }, "left": { "type": "Identifier", "start": 2839, "end": 2843, "loc": { "start": { "line": 55, "column": 23 }, "end": { "line": 55, "column": 27 }, "identifierName": "data" }, "name": "data" }, "right": { "type": "NullLiteral", "start": 2846, "end": 2850, "loc": { "start": { "line": 55, "column": 30 }, "end": { "line": 55, "column": 34 } } } }, { "type": "AssignmentPattern", "start": 2852, "end": 2867, "loc": { "start": { "line": 55, "column": 36 }, "end": { "line": 55, "column": 51 } }, "left": { "type": "Identifier", "start": 2852, "end": 2859, "loc": { "start": { "line": 55, "column": 36 }, "end": { "line": 55, "column": 43 }, "identifierName": "bubbles" }, "name": "bubbles" }, "right": { "type": "BooleanLiteral", "start": 2862, "end": 2867, "loc": { "start": { "line": 55, "column": 46 }, "end": { "line": 55, "column": 51 } }, "value": false } }, { "type": "AssignmentPattern", "start": 2869, "end": 2886, "loc": { "start": { "line": 55, "column": 53 }, "end": { "line": 55, "column": 70 } }, "left": { "type": "Identifier", "start": 2869, "end": 2879, "loc": { "start": { "line": 55, "column": 53 }, "end": { "line": 55, "column": 63 }, "identifierName": "cancelable" }, "name": "cancelable" }, "right": { "type": "BooleanLiteral", "start": 2882, "end": 2886, "loc": { "start": { "line": 55, "column": 66 }, "end": { "line": 55, "column": 70 } }, "value": true } } ], "body": { "type": "BlockStatement", "start": 2889, "end": 2965, "loc": { "start": { "line": 55, "column": 73 }, "end": { "line": 58, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 2899, "end": 2932, "loc": { "start": { "line": 56, "column": 8 }, "end": { "line": 56, "column": 41 } }, "expression": { "type": "CallExpression", "start": 2899, "end": 2931, "loc": { "start": { "line": 56, "column": 8 }, "end": { "line": 56, "column": 40 } }, "callee": { "type": "Super", "start": 2899, "end": 2904, "loc": { "start": { "line": 56, "column": 8 }, "end": { "line": 56, "column": 13 } } }, "arguments": [ { "type": "Identifier", "start": 2905, "end": 2909, "loc": { "start": { "line": 56, "column": 14 }, "end": { "line": 56, "column": 18 }, "identifierName": "type" }, "name": "type" }, { "type": "Identifier", "start": 2911, "end": 2918, "loc": { "start": { "line": 56, "column": 20 }, "end": { "line": 56, "column": 27 }, "identifierName": "bubbles" }, "name": "bubbles" }, { "type": "Identifier", "start": 2920, "end": 2930, "loc": { "start": { "line": 56, "column": 29 }, "end": { "line": 56, "column": 39 }, "identifierName": "cancelable" }, "name": "cancelable" } ] } }, { "type": "ExpressionStatement", "start": 2941, "end": 2959, "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 26 } }, "expression": { "type": "AssignmentExpression", "start": 2941, "end": 2958, "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 25 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 2941, "end": 2951, "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 18 } }, "object": { "type": "ThisExpression", "start": 2941, "end": 2945, "loc": { "start": { "line": 57, "column": 8 }, "end": { "line": 57, "column": 12 } } }, "property": { "type": "Identifier", "start": 2946, "end": 2951, "loc": { "start": { "line": 57, "column": 13 }, "end": { "line": 57, "column": 18 }, "identifierName": "_data" }, "name": "_data" }, "computed": false }, "right": { "type": "Identifier", "start": 2954, "end": 2958, "loc": { "start": { "line": 57, "column": 21 }, "end": { "line": 57, "column": 25 }, "identifierName": "data" }, "name": "data" } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * 创建一个支持自定义数据的事件对象。\n * \n * @param {String|Symbol} type - 事件类型。\n * @param {any} [data=null] - 指定附加到事件对象的数据。\n * @param {Boolean} [bubbles=false] - 指示该事件是否参与冒泡行为。\n * @param {Boolean} [cancelable=true] - 指示该事件是否可以取消默认行为。\n * @since 1.0.9\n ", "start": 2542, "end": 2815, "loc": { "start": { "line": 46, "column": 4 }, "end": { "line": 54, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * 重置事件状态(允许外部复用事件对象)。\n * \n * @param {String|Symbol} type - 事件类型。\n * @param {any} [data=null] - 指定附加到事件对象的数据。\n * @param {Boolean} [bubbles=false] - 指示该事件是否参与冒泡行为。\n * @param {Boolean} [cancelable=true] - 指示该事件是否可以取消默认行为。\n * @returns {this}\n * @since 1.0.11\n ", "start": 2975, "end": 3274, "loc": { "start": { "line": 60, "column": 4 }, "end": { "line": 69, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 3279, "end": 3446, "loc": { "start": { "line": 70, "column": 4 }, "end": { "line": 74, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 3279, "end": 3284, "loc": { "start": { "line": 70, "column": 4 }, "end": { "line": 70, "column": 9 }, "identifierName": "reset" }, "name": "reset", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 3286, "end": 3290, "loc": { "start": { "line": 70, "column": 11 }, "end": { "line": 70, "column": 15 }, "identifierName": "type" }, "name": "type" }, { "type": "AssignmentPattern", "start": 3292, "end": 3303, "loc": { "start": { "line": 70, "column": 17 }, "end": { "line": 70, "column": 28 } }, "left": { "type": "Identifier", "start": 3292, "end": 3296, "loc": { "start": { "line": 70, "column": 17 }, "end": { "line": 70, "column": 21 }, "identifierName": "data" }, "name": "data" }, "right": { "type": "NullLiteral", "start": 3299, "end": 3303, "loc": { "start": { "line": 70, "column": 24 }, "end": { "line": 70, "column": 28 } } } }, { "type": "AssignmentPattern", "start": 3305, "end": 3320, "loc": { "start": { "line": 70, "column": 30 }, "end": { "line": 70, "column": 45 } }, "left": { "type": "Identifier", "start": 3305, "end": 3312, "loc": { "start": { "line": 70, "column": 30 }, "end": { "line": 70, "column": 37 }, "identifierName": "bubbles" }, "name": "bubbles" }, "right": { "type": "BooleanLiteral", "start": 3315, "end": 3320, "loc": { "start": { "line": 70, "column": 40 }, "end": { "line": 70, "column": 45 } }, "value": false } }, { "type": "AssignmentPattern", "start": 3322, "end": 3340, "loc": { "start": { "line": 70, "column": 47 }, "end": { "line": 70, "column": 65 } }, "left": { "type": "Identifier", "start": 3322, "end": 3332, "loc": { "start": { "line": 70, "column": 47 }, "end": { "line": 70, "column": 57 }, "identifierName": "cancelable" }, "name": "cancelable" }, "right": { "type": "BooleanLiteral", "start": 3335, "end": 3340, "loc": { "start": { "line": 70, "column": 60 }, "end": { "line": 70, "column": 65 } }, "value": false } } ], "body": { "type": "BlockStatement", "start": 3343, "end": 3446, "loc": { "start": { "line": 70, "column": 68 }, "end": { "line": 74, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 3353, "end": 3392, "loc": { "start": { "line": 71, "column": 8 }, "end": { "line": 71, "column": 47 } }, "expression": { "type": "CallExpression", "start": 3353, "end": 3391, "loc": { "start": { "line": 71, "column": 8 }, "end": { "line": 71, "column": 46 } }, "callee": { "type": "MemberExpression", "start": 3353, "end": 3364, "loc": { "start": { "line": 71, "column": 8 }, "end": { "line": 71, "column": 19 } }, "object": { "type": "Super", "start": 3353, "end": 3358, "loc": { "start": { "line": 71, "column": 8 }, "end": { "line": 71, "column": 13 } } }, "property": { "type": "Identifier", "start": 3359, "end": 3364, "loc": { "start": { "line": 71, "column": 14 }, "end": { "line": 71, "column": 19 }, "identifierName": "reset" }, "name": "reset" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 3365, "end": 3369, "loc": { "start": { "line": 71, "column": 20 }, "end": { "line": 71, "column": 24 }, "identifierName": "type" }, "name": "type" }, { "type": "Identifier", "start": 3371, "end": 3378, "loc": { "start": { "line": 71, "column": 26 }, "end": { "line": 71, "column": 33 }, "identifierName": "bubbles" }, "name": "bubbles" }, { "type": "Identifier", "start": 3380, "end": 3390, "loc": { "start": { "line": 71, "column": 35 }, "end": { "line": 71, "column": 45 }, "identifierName": "cancelable" }, "name": "cancelable" } ] } }, { "type": "ExpressionStatement", "start": 3401, "end": 3419, "loc": { "start": { "line": 72, "column": 8 }, "end": { "line": 72, "column": 26 } }, "expression": { "type": "AssignmentExpression", "start": 3401, "end": 3418, "loc": { "start": { "line": 72, "column": 8 }, "end": { "line": 72, "column": 25 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 3401, "end": 3411, "loc": { "start": { "line": 72, "column": 8 }, "end": { "line": 72, "column": 18