mirror of
				https://github.com/1disk/edp445.git
				synced 2024-08-14 22:47:02 +00:00 
			
		
		
		
	Changed alot of things.
This commit is contained in:
		
							parent
							
								
									a5a0523e5a
								
							
						
					
					
						commit
						3513d5390c
					
				
					 2016 changed files with 336930 additions and 9 deletions
				
			
		
							
								
								
									
										22
									
								
								node_modules/event-target-shim/LICENSE
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								node_modules/event-target-shim/LICENSE
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| The MIT License (MIT) | ||||
| 
 | ||||
| Copyright (c) 2015 Toru Nagashima | ||||
| 
 | ||||
| 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. | ||||
| 
 | ||||
							
								
								
									
										293
									
								
								node_modules/event-target-shim/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										293
									
								
								node_modules/event-target-shim/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,293 @@ | |||
| # event-target-shim | ||||
| 
 | ||||
| [](https://www.npmjs.com/package/event-target-shim) | ||||
| [](http://www.npmtrends.com/event-target-shim) | ||||
| [](https://travis-ci.org/mysticatea/event-target-shim) | ||||
| [](https://codecov.io/gh/mysticatea/event-target-shim) | ||||
| [](https://david-dm.org/mysticatea/event-target-shim) | ||||
| 
 | ||||
| An implementation of [WHATWG EventTarget interface](https://dom.spec.whatwg.org/#interface-eventtarget), plus few extensions. | ||||
| 
 | ||||
| - This provides `EventTarget` constructor that can inherit for your custom object. | ||||
| - This provides an utility that defines properties of attribute listeners (e.g. `obj.onclick`). | ||||
| 
 | ||||
| ```js | ||||
| import {EventTarget, defineEventAttribute} from "event-target-shim" | ||||
| 
 | ||||
| class Foo extends EventTarget { | ||||
|     // ... | ||||
| } | ||||
| 
 | ||||
| // Define `foo.onhello` property. | ||||
| defineEventAttribute(Foo.prototype, "hello") | ||||
| 
 | ||||
| // Use | ||||
| const foo = new Foo() | ||||
| foo.addEventListener("hello", e => console.log("hello", e)) | ||||
| foo.onhello = e => console.log("onhello:", e) | ||||
| foo.dispatchEvent(new CustomEvent("hello")) | ||||
| ``` | ||||
| 
 | ||||
| ## 💿 Installation | ||||
| 
 | ||||
| Use [npm](https://www.npmjs.com/) to install then use a bundler. | ||||
| 
 | ||||
| ``` | ||||
| npm install event-target-shim | ||||
| ``` | ||||
| 
 | ||||
| Or download from [`dist` directory](./dist). | ||||
| 
 | ||||
| - [dist/event-target-shim.mjs](dist/event-target-shim.mjs) ... ES modules version. | ||||
| - [dist/event-target-shim.js](dist/event-target-shim.js) ... Common JS version. | ||||
| - [dist/event-target-shim.umd.js](dist/event-target-shim.umd.js) ... UMD (Universal Module Definition) version. This is transpiled by [Babel](https://babeljs.io/) for IE 11. | ||||
| 
 | ||||
| ## 📖 Usage | ||||
| 
 | ||||
| ```js | ||||
| import {EventTarget, defineEventAttribute} from "event-target-shim" | ||||
| // or | ||||
| const {EventTarget, defineEventAttribute} = require("event-target-shim") | ||||
| 
 | ||||
| // or UMD version defines a global variable: | ||||
| const {EventTarget, defineEventAttribute} = window.EventTargetShim | ||||
| ``` | ||||
| 
 | ||||
| ### EventTarget | ||||
| 
 | ||||
| > https://dom.spec.whatwg.org/#interface-eventtarget | ||||
| 
 | ||||
| #### eventTarget.addEventListener(type, callback, options) | ||||
| 
 | ||||
| Register an event listener. | ||||
| 
 | ||||
| - `type` is a string. This is the event name to register. | ||||
| - `callback` is a function. This is the event listener to register. | ||||
| - `options` is a boolean or an object `{ capture?: boolean, passive?: boolean, once?: boolean }`. If this is a boolean, it's same meaning as `{ capture: options }`. | ||||
|     - `capture` is the flag to register the event listener for capture phase. | ||||
|     - `passive` is the flag to ignore `event.preventDefault()` method in the event listener. | ||||
|     - `once` is the flag to remove the event listener automatically after the first call. | ||||
| 
 | ||||
| #### eventTarget.removeEventListener(type, callback, options) | ||||
| 
 | ||||
| Unregister an event listener. | ||||
| 
 | ||||
| - `type` is a string. This is the event name to unregister. | ||||
| - `callback` is a function. This is the event listener to unregister. | ||||
| - `options` is a boolean or an object `{ capture?: boolean }`. If this is a boolean, it's same meaning as `{ capture: options }`. | ||||
|     - `capture` is the flag to register the event listener for capture phase. | ||||
| 
 | ||||
| #### eventTarget.dispatchEvent(event) | ||||
| 
 | ||||
| Dispatch an event. | ||||
| 
 | ||||
| - `event` is a [Event](https://dom.spec.whatwg.org/#event) object or an object `{ type: string, [key: string]: any }`. The latter is non-standard but useful. In both cases, listeners receive the event as implementing [Event](https://dom.spec.whatwg.org/#event) interface. | ||||
| 
 | ||||
| ### defineEventAttribute(proto, type) | ||||
| 
 | ||||
| Define an event attribute (e.g. `onclick`) to `proto`. This is non-standard. | ||||
| 
 | ||||
| - `proto` is an object (assuming it's a prototype object). This function defines a getter/setter pair for the event attribute. | ||||
| - `type` is a string. This is the event name to define. | ||||
| 
 | ||||
| For example: | ||||
| 
 | ||||
| ```js | ||||
| class AbortSignal extends EventTarget { | ||||
|     constructor() { | ||||
|         this.aborted = false | ||||
|     } | ||||
| } | ||||
| // Define `onabort` property. | ||||
| defineEventAttribute(AbortSignal.prototype, "abort") | ||||
| ``` | ||||
| 
 | ||||
| ### EventTarget(types) | ||||
| 
 | ||||
| Define a custom `EventTarget` class with event attributes. This is non-standard. | ||||
| 
 | ||||
| - `types` is a string or an array of strings. This is the event name to define. | ||||
| 
 | ||||
| For example: | ||||
| 
 | ||||
| ```js | ||||
| // This has `onabort` property. | ||||
| class AbortSignal extends EventTarget("abort") { | ||||
|     constructor() { | ||||
|         this.aborted = false | ||||
|     } | ||||
| } | ||||
| ``` | ||||
| 
 | ||||
| ## 📚 Examples | ||||
| 
 | ||||
| ### ES2015 and later | ||||
| 
 | ||||
| > https://jsfiddle.net/636vea92/ | ||||
| 
 | ||||
| ```js | ||||
| const {EventTarget, defineEventAttribute} = EventTargetShim | ||||
| 
 | ||||
| // Define a derived class. | ||||
| class Foo extends EventTarget { | ||||
|     // ... | ||||
| } | ||||
| 
 | ||||
| // Define `foo.onhello` property. | ||||
| defineEventAttribute(Foo.prototype, "hello") | ||||
| 
 | ||||
| // Register event listeners. | ||||
| const foo = new Foo() | ||||
| foo.addEventListener("hello", (e) => { | ||||
|     console.log("hello", e) | ||||
| }) | ||||
| foo.onhello = (e) => { | ||||
|     console.log("onhello", e) | ||||
| } | ||||
| 
 | ||||
| // Dispatching events | ||||
| foo.dispatchEvent(new CustomEvent("hello", { detail: "detail" })) | ||||
| ``` | ||||
| 
 | ||||
| ### Typescript | ||||
| 
 | ||||
| ```ts | ||||
| import { EventTarget, defineEventAttribute } from "event-target-shim"; | ||||
| 
 | ||||
| // Define events | ||||
| type FooEvents = { | ||||
|     hello: CustomEvent | ||||
| } | ||||
| type FooEventAttributes = { | ||||
|     onhello: CustomEvent | ||||
| } | ||||
| 
 | ||||
| // Define a derived class. | ||||
| class Foo extends EventTarget<FooEvents, FooEventAttributes> { | ||||
|     // ... | ||||
| } | ||||
| // Define `foo.onhello` property's implementation. | ||||
| defineEventAttribute(Foo.prototype, "hello") | ||||
| 
 | ||||
| // Register event listeners. | ||||
| const foo = new Foo() | ||||
| foo.addEventListener("hello", (e) => { | ||||
|     console.log("hello", e.detail) | ||||
| }) | ||||
| foo.onhello = (e) => { | ||||
|     console.log("onhello", e.detail) | ||||
| } | ||||
| 
 | ||||
| // Dispatching events | ||||
| foo.dispatchEvent(new CustomEvent("hello", { detail: "detail" })) | ||||
| ``` | ||||
| 
 | ||||
| Unfortunately, both `FooEvents` and `FooEventAttributes` are needed because TypeScript doesn't allow the mutation of string literal types. If TypeScript allowed us to compute `"onhello"` from `"hello"` in types, `FooEventAttributes` will be optional. | ||||
| 
 | ||||
| This `EventTarget` type is compatible with `EventTarget` interface of `lib.dom.d.ts`. | ||||
| 
 | ||||
| #### To disallow unknown events | ||||
| 
 | ||||
| By default, methods such as `addEventListener` accept unknown events. You can disallow unknown events by the third type parameter `"strict"`. | ||||
| 
 | ||||
| ```ts | ||||
| type FooEvents = { | ||||
|     hello: CustomEvent | ||||
| } | ||||
| class Foo extends EventTarget<FooEvents, {}, "strict"> { | ||||
|     // ... | ||||
| } | ||||
| 
 | ||||
| // OK because `hello` is defined in FooEvents. | ||||
| foo.addEventListener("hello", (e) => { | ||||
| }) | ||||
| // Error because `unknown` is not defined in FooEvents. | ||||
| foo.addEventListener("unknown", (e) => { | ||||
| }) | ||||
| ``` | ||||
| 
 | ||||
| However, if you use `"strict"` parameter, it loses compatibility with `EventTarget` interface of `lib.dom.d.ts`. | ||||
| 
 | ||||
| #### To infer the type of `dispatchEvent()` method | ||||
| 
 | ||||
| TypeScript cannot infer the event type of `dispatchEvent()` method properly from the argument in most cases. You can improve this behavior with the following steps: | ||||
| 
 | ||||
| 1. Use the third type parameter `"strict"`. This prevents inferring to `dispatchEvent<string>()`. | ||||
| 2. Make the `type` property of event definitions stricter. | ||||
| 
 | ||||
| ```ts | ||||
| type FooEvents = { | ||||
|     hello: CustomEvent & { type: "hello" } | ||||
|     hey: Event & { type: "hey" } | ||||
| } | ||||
| class Foo extends EventTarget<FooEvents, {}, "strict"> { | ||||
|     // ... | ||||
| } | ||||
| 
 | ||||
| // Error because `detail` property is lacking. | ||||
| foo.dispatchEvent({ type: "hello" }) | ||||
| ``` | ||||
| 
 | ||||
| ### ES5 | ||||
| 
 | ||||
| > https://jsfiddle.net/522zc9de/ | ||||
| 
 | ||||
| ```js | ||||
| // Define a derived class. | ||||
| function Foo() { | ||||
|     EventTarget.call(this) | ||||
| } | ||||
| Foo.prototype = Object.create(EventTarget.prototype, { | ||||
|     constructor: { value: Foo, configurable: true, writable: true } | ||||
|     // ... | ||||
| }) | ||||
| 
 | ||||
| // Define `foo.onhello` property. | ||||
| defineEventAttribute(Foo.prototype, "hello") | ||||
| 
 | ||||
| // Register event listeners. | ||||
| var foo = new Foo() | ||||
| foo.addEventListener("hello", function(e) { | ||||
|     console.log("hello", e) | ||||
| }) | ||||
| foo.onhello = function(e) { | ||||
|     console.log("onhello", e) | ||||
| } | ||||
| 
 | ||||
| // Dispatching events | ||||
| function isSupportEventConstrucor() { // IE does not support. | ||||
|     try { | ||||
|         new CusomEvent("hello") | ||||
|         return true | ||||
|     } catch (_err) { | ||||
|         return false | ||||
|     } | ||||
| } | ||||
| if (isSupportEventConstrucor()) { | ||||
|     foo.dispatchEvent(new CustomEvent("hello", { detail: "detail" })) | ||||
| } else { | ||||
|     var e = document.createEvent("CustomEvent") | ||||
|     e.initCustomEvent("hello", false, false, "detail") | ||||
|     foo.dispatchEvent(e) | ||||
| } | ||||
| ``` | ||||
| 
 | ||||
| ## 📰 Changelog | ||||
| 
 | ||||
| - See [GitHub releases](https://github.com/mysticatea/event-target-shim/releases). | ||||
| 
 | ||||
| ## 🍻 Contributing | ||||
| 
 | ||||
| Contributing is welcome ❤️ | ||||
| 
 | ||||
| Please use GitHub issues/PRs. | ||||
| 
 | ||||
| ### Development tools | ||||
| 
 | ||||
| - `npm install` installs dependencies for development. | ||||
| - `npm test` runs tests and measures code coverage. | ||||
| - `npm run clean` removes temporary files of tests. | ||||
| - `npm run coverage` opens code coverage of the previous test with your default browser. | ||||
| - `npm run lint` runs ESLint. | ||||
| - `npm run build` generates `dist` codes. | ||||
| - `npm run watch` runs tests on each file change. | ||||
							
								
								
									
										871
									
								
								node_modules/event-target-shim/dist/event-target-shim.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										871
									
								
								node_modules/event-target-shim/dist/event-target-shim.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,871 @@ | |||
| /** | ||||
|  * @author Toru Nagashima <https://github.com/mysticatea>
 | ||||
|  * @copyright 2015 Toru Nagashima. All rights reserved. | ||||
|  * See LICENSE file in root directory for full license. | ||||
|  */ | ||||
| 'use strict'; | ||||
| 
 | ||||
| Object.defineProperty(exports, '__esModule', { value: true }); | ||||
| 
 | ||||
| /** | ||||
|  * @typedef {object} PrivateData | ||||
|  * @property {EventTarget} eventTarget The event target. | ||||
|  * @property {{type:string}} event The original event object. | ||||
|  * @property {number} eventPhase The current event phase. | ||||
|  * @property {EventTarget|null} currentTarget The current event target. | ||||
|  * @property {boolean} canceled The flag to prevent default. | ||||
|  * @property {boolean} stopped The flag to stop propagation. | ||||
|  * @property {boolean} immediateStopped The flag to stop propagation immediately. | ||||
|  * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null. | ||||
|  * @property {number} timeStamp The unix time. | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * Private data for event wrappers. | ||||
|  * @type {WeakMap<Event, PrivateData>} | ||||
|  * @private | ||||
|  */ | ||||
| const privateData = new WeakMap(); | ||||
| 
 | ||||
| /** | ||||
|  * Cache for wrapper classes. | ||||
|  * @type {WeakMap<Object, Function>} | ||||
|  * @private | ||||
|  */ | ||||
| const wrappers = new WeakMap(); | ||||
| 
 | ||||
| /** | ||||
|  * Get private data. | ||||
|  * @param {Event} event The event object to get private data. | ||||
|  * @returns {PrivateData} The private data of the event. | ||||
|  * @private | ||||
|  */ | ||||
| function pd(event) { | ||||
|     const retv = privateData.get(event); | ||||
|     console.assert( | ||||
|         retv != null, | ||||
|         "'this' is expected an Event object, but got", | ||||
|         event | ||||
|     ); | ||||
|     return retv | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * https://dom.spec.whatwg.org/#set-the-canceled-flag
 | ||||
|  * @param data {PrivateData} private data. | ||||
|  */ | ||||
| function setCancelFlag(data) { | ||||
|     if (data.passiveListener != null) { | ||||
|         if ( | ||||
|             typeof console !== "undefined" && | ||||
|             typeof console.error === "function" | ||||
|         ) { | ||||
|             console.error( | ||||
|                 "Unable to preventDefault inside passive event listener invocation.", | ||||
|                 data.passiveListener | ||||
|             ); | ||||
|         } | ||||
|         return | ||||
|     } | ||||
|     if (!data.event.cancelable) { | ||||
|         return | ||||
|     } | ||||
| 
 | ||||
|     data.canceled = true; | ||||
|     if (typeof data.event.preventDefault === "function") { | ||||
|         data.event.preventDefault(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * @see https://dom.spec.whatwg.org/#interface-event
 | ||||
|  * @private | ||||
|  */ | ||||
| /** | ||||
|  * The event wrapper. | ||||
|  * @constructor | ||||
|  * @param {EventTarget} eventTarget The event target of this dispatching. | ||||
|  * @param {Event|{type:string}} event The original event to wrap. | ||||
|  */ | ||||
| function Event(eventTarget, event) { | ||||
|     privateData.set(this, { | ||||
|         eventTarget, | ||||
|         event, | ||||
|         eventPhase: 2, | ||||
|         currentTarget: eventTarget, | ||||
|         canceled: false, | ||||
|         stopped: false, | ||||
|         immediateStopped: false, | ||||
|         passiveListener: null, | ||||
|         timeStamp: event.timeStamp || Date.now(), | ||||
|     }); | ||||
| 
 | ||||
|     // https://heycam.github.io/webidl/#Unforgeable
 | ||||
|     Object.defineProperty(this, "isTrusted", { value: false, enumerable: true }); | ||||
| 
 | ||||
|     // Define accessors
 | ||||
|     const keys = Object.keys(event); | ||||
|     for (let i = 0; i < keys.length; ++i) { | ||||
|         const key = keys[i]; | ||||
|         if (!(key in this)) { | ||||
|             Object.defineProperty(this, key, defineRedirectDescriptor(key)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| // Should be enumerable, but class methods are not enumerable.
 | ||||
| Event.prototype = { | ||||
|     /** | ||||
|      * The type of this event. | ||||
|      * @type {string} | ||||
|      */ | ||||
|     get type() { | ||||
|         return pd(this).event.type | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      * @type {EventTarget} | ||||
|      */ | ||||
|     get target() { | ||||
|         return pd(this).eventTarget | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      * @type {EventTarget} | ||||
|      */ | ||||
|     get currentTarget() { | ||||
|         return pd(this).currentTarget | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * @returns {EventTarget[]} The composed path of this event. | ||||
|      */ | ||||
|     composedPath() { | ||||
|         const currentTarget = pd(this).currentTarget; | ||||
|         if (currentTarget == null) { | ||||
|             return [] | ||||
|         } | ||||
|         return [currentTarget] | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of NONE. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get NONE() { | ||||
|         return 0 | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of CAPTURING_PHASE. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get CAPTURING_PHASE() { | ||||
|         return 1 | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of AT_TARGET. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get AT_TARGET() { | ||||
|         return 2 | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of BUBBLING_PHASE. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get BUBBLING_PHASE() { | ||||
|         return 3 | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get eventPhase() { | ||||
|         return pd(this).eventPhase | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Stop event bubbling. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     stopPropagation() { | ||||
|         const data = pd(this); | ||||
| 
 | ||||
|         data.stopped = true; | ||||
|         if (typeof data.event.stopPropagation === "function") { | ||||
|             data.event.stopPropagation(); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Stop event bubbling. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     stopImmediatePropagation() { | ||||
|         const data = pd(this); | ||||
| 
 | ||||
|         data.stopped = true; | ||||
|         data.immediateStopped = true; | ||||
|         if (typeof data.event.stopImmediatePropagation === "function") { | ||||
|             data.event.stopImmediatePropagation(); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to be bubbling. | ||||
|      * @type {boolean} | ||||
|      */ | ||||
|     get bubbles() { | ||||
|         return Boolean(pd(this).event.bubbles) | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to be cancelable. | ||||
|      * @type {boolean} | ||||
|      */ | ||||
|     get cancelable() { | ||||
|         return Boolean(pd(this).event.cancelable) | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Cancel this event. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     preventDefault() { | ||||
|         setCancelFlag(pd(this)); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to indicate cancellation state. | ||||
|      * @type {boolean} | ||||
|      */ | ||||
|     get defaultPrevented() { | ||||
|         return pd(this).canceled | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to be composed. | ||||
|      * @type {boolean} | ||||
|      */ | ||||
|     get composed() { | ||||
|         return Boolean(pd(this).event.composed) | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The unix time of this event. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get timeStamp() { | ||||
|         return pd(this).timeStamp | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      * @type {EventTarget} | ||||
|      * @deprecated | ||||
|      */ | ||||
|     get srcElement() { | ||||
|         return pd(this).eventTarget | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to stop event bubbling. | ||||
|      * @type {boolean} | ||||
|      * @deprecated | ||||
|      */ | ||||
|     get cancelBubble() { | ||||
|         return pd(this).stopped | ||||
|     }, | ||||
|     set cancelBubble(value) { | ||||
|         if (!value) { | ||||
|             return | ||||
|         } | ||||
|         const data = pd(this); | ||||
| 
 | ||||
|         data.stopped = true; | ||||
|         if (typeof data.event.cancelBubble === "boolean") { | ||||
|             data.event.cancelBubble = true; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to indicate cancellation state. | ||||
|      * @type {boolean} | ||||
|      * @deprecated | ||||
|      */ | ||||
|     get returnValue() { | ||||
|         return !pd(this).canceled | ||||
|     }, | ||||
|     set returnValue(value) { | ||||
|         if (!value) { | ||||
|             setCancelFlag(pd(this)); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Initialize this event object. But do nothing under event dispatching. | ||||
|      * @param {string} type The event type. | ||||
|      * @param {boolean} [bubbles=false] The flag to be possible to bubble up. | ||||
|      * @param {boolean} [cancelable=false] The flag to be possible to cancel. | ||||
|      * @deprecated | ||||
|      */ | ||||
|     initEvent() { | ||||
|         // Do nothing.
 | ||||
|     }, | ||||
| }; | ||||
| 
 | ||||
| // `constructor` is not enumerable.
 | ||||
| Object.defineProperty(Event.prototype, "constructor", { | ||||
|     value: Event, | ||||
|     configurable: true, | ||||
|     writable: true, | ||||
| }); | ||||
| 
 | ||||
| // Ensure `event instanceof window.Event` is `true`.
 | ||||
| if (typeof window !== "undefined" && typeof window.Event !== "undefined") { | ||||
|     Object.setPrototypeOf(Event.prototype, window.Event.prototype); | ||||
| 
 | ||||
|     // Make association for wrappers.
 | ||||
|     wrappers.set(window.Event.prototype, Event); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the property descriptor to redirect a given property. | ||||
|  * @param {string} key Property name to define property descriptor. | ||||
|  * @returns {PropertyDescriptor} The property descriptor to redirect the property. | ||||
|  * @private | ||||
|  */ | ||||
| function defineRedirectDescriptor(key) { | ||||
|     return { | ||||
|         get() { | ||||
|             return pd(this).event[key] | ||||
|         }, | ||||
|         set(value) { | ||||
|             pd(this).event[key] = value; | ||||
|         }, | ||||
|         configurable: true, | ||||
|         enumerable: true, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the property descriptor to call a given method property. | ||||
|  * @param {string} key Property name to define property descriptor. | ||||
|  * @returns {PropertyDescriptor} The property descriptor to call the method property. | ||||
|  * @private | ||||
|  */ | ||||
| function defineCallDescriptor(key) { | ||||
|     return { | ||||
|         value() { | ||||
|             const event = pd(this).event; | ||||
|             return event[key].apply(event, arguments) | ||||
|         }, | ||||
|         configurable: true, | ||||
|         enumerable: true, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Define new wrapper class. | ||||
|  * @param {Function} BaseEvent The base wrapper class. | ||||
|  * @param {Object} proto The prototype of the original event. | ||||
|  * @returns {Function} The defined wrapper class. | ||||
|  * @private | ||||
|  */ | ||||
| function defineWrapper(BaseEvent, proto) { | ||||
|     const keys = Object.keys(proto); | ||||
|     if (keys.length === 0) { | ||||
|         return BaseEvent | ||||
|     } | ||||
| 
 | ||||
|     /** CustomEvent */ | ||||
|     function CustomEvent(eventTarget, event) { | ||||
|         BaseEvent.call(this, eventTarget, event); | ||||
|     } | ||||
| 
 | ||||
|     CustomEvent.prototype = Object.create(BaseEvent.prototype, { | ||||
|         constructor: { value: CustomEvent, configurable: true, writable: true }, | ||||
|     }); | ||||
| 
 | ||||
|     // Define accessors.
 | ||||
|     for (let i = 0; i < keys.length; ++i) { | ||||
|         const key = keys[i]; | ||||
|         if (!(key in BaseEvent.prototype)) { | ||||
|             const descriptor = Object.getOwnPropertyDescriptor(proto, key); | ||||
|             const isFunc = typeof descriptor.value === "function"; | ||||
|             Object.defineProperty( | ||||
|                 CustomEvent.prototype, | ||||
|                 key, | ||||
|                 isFunc | ||||
|                     ? defineCallDescriptor(key) | ||||
|                     : defineRedirectDescriptor(key) | ||||
|             ); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return CustomEvent | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the wrapper class of a given prototype. | ||||
|  * @param {Object} proto The prototype of the original event to get its wrapper. | ||||
|  * @returns {Function} The wrapper class. | ||||
|  * @private | ||||
|  */ | ||||
| function getWrapper(proto) { | ||||
|     if (proto == null || proto === Object.prototype) { | ||||
|         return Event | ||||
|     } | ||||
| 
 | ||||
|     let wrapper = wrappers.get(proto); | ||||
|     if (wrapper == null) { | ||||
|         wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto); | ||||
|         wrappers.set(proto, wrapper); | ||||
|     } | ||||
|     return wrapper | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Wrap a given event to management a dispatching. | ||||
|  * @param {EventTarget} eventTarget The event target of this dispatching. | ||||
|  * @param {Object} event The event to wrap. | ||||
|  * @returns {Event} The wrapper instance. | ||||
|  * @private | ||||
|  */ | ||||
| function wrapEvent(eventTarget, event) { | ||||
|     const Wrapper = getWrapper(Object.getPrototypeOf(event)); | ||||
|     return new Wrapper(eventTarget, event) | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the immediateStopped flag of a given event. | ||||
|  * @param {Event} event The event to get. | ||||
|  * @returns {boolean} The flag to stop propagation immediately. | ||||
|  * @private | ||||
|  */ | ||||
| function isStopped(event) { | ||||
|     return pd(event).immediateStopped | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Set the current event phase of a given event. | ||||
|  * @param {Event} event The event to set current target. | ||||
|  * @param {number} eventPhase New event phase. | ||||
|  * @returns {void} | ||||
|  * @private | ||||
|  */ | ||||
| function setEventPhase(event, eventPhase) { | ||||
|     pd(event).eventPhase = eventPhase; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Set the current target of a given event. | ||||
|  * @param {Event} event The event to set current target. | ||||
|  * @param {EventTarget|null} currentTarget New current target. | ||||
|  * @returns {void} | ||||
|  * @private | ||||
|  */ | ||||
| function setCurrentTarget(event, currentTarget) { | ||||
|     pd(event).currentTarget = currentTarget; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Set a passive listener of a given event. | ||||
|  * @param {Event} event The event to set current target. | ||||
|  * @param {Function|null} passiveListener New passive listener. | ||||
|  * @returns {void} | ||||
|  * @private | ||||
|  */ | ||||
| function setPassiveListener(event, passiveListener) { | ||||
|     pd(event).passiveListener = passiveListener; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * @typedef {object} ListenerNode | ||||
|  * @property {Function} listener | ||||
|  * @property {1|2|3} listenerType | ||||
|  * @property {boolean} passive | ||||
|  * @property {boolean} once | ||||
|  * @property {ListenerNode|null} next | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * @type {WeakMap<object, Map<string, ListenerNode>>} | ||||
|  * @private | ||||
|  */ | ||||
| const listenersMap = new WeakMap(); | ||||
| 
 | ||||
| // Listener types
 | ||||
| const CAPTURE = 1; | ||||
| const BUBBLE = 2; | ||||
| const ATTRIBUTE = 3; | ||||
| 
 | ||||
| /** | ||||
|  * Check whether a given value is an object or not. | ||||
|  * @param {any} x The value to check. | ||||
|  * @returns {boolean} `true` if the value is an object. | ||||
|  */ | ||||
| function isObject(x) { | ||||
|     return x !== null && typeof x === "object" //eslint-disable-line no-restricted-syntax
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get listeners. | ||||
|  * @param {EventTarget} eventTarget The event target to get. | ||||
|  * @returns {Map<string, ListenerNode>} The listeners. | ||||
|  * @private | ||||
|  */ | ||||
| function getListeners(eventTarget) { | ||||
|     const listeners = listenersMap.get(eventTarget); | ||||
|     if (listeners == null) { | ||||
|         throw new TypeError( | ||||
|             "'this' is expected an EventTarget object, but got another value." | ||||
|         ) | ||||
|     } | ||||
|     return listeners | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the property descriptor for the event attribute of a given event. | ||||
|  * @param {string} eventName The event name to get property descriptor. | ||||
|  * @returns {PropertyDescriptor} The property descriptor. | ||||
|  * @private | ||||
|  */ | ||||
| function defineEventAttributeDescriptor(eventName) { | ||||
|     return { | ||||
|         get() { | ||||
|             const listeners = getListeners(this); | ||||
|             let node = listeners.get(eventName); | ||||
|             while (node != null) { | ||||
|                 if (node.listenerType === ATTRIBUTE) { | ||||
|                     return node.listener | ||||
|                 } | ||||
|                 node = node.next; | ||||
|             } | ||||
|             return null | ||||
|         }, | ||||
| 
 | ||||
|         set(listener) { | ||||
|             if (typeof listener !== "function" && !isObject(listener)) { | ||||
|                 listener = null; // eslint-disable-line no-param-reassign
 | ||||
|             } | ||||
|             const listeners = getListeners(this); | ||||
| 
 | ||||
|             // Traverse to the tail while removing old value.
 | ||||
|             let prev = null; | ||||
|             let node = listeners.get(eventName); | ||||
|             while (node != null) { | ||||
|                 if (node.listenerType === ATTRIBUTE) { | ||||
|                     // Remove old value.
 | ||||
|                     if (prev !== null) { | ||||
|                         prev.next = node.next; | ||||
|                     } else if (node.next !== null) { | ||||
|                         listeners.set(eventName, node.next); | ||||
|                     } else { | ||||
|                         listeners.delete(eventName); | ||||
|                     } | ||||
|                 } else { | ||||
|                     prev = node; | ||||
|                 } | ||||
| 
 | ||||
|                 node = node.next; | ||||
|             } | ||||
| 
 | ||||
|             // Add new value.
 | ||||
|             if (listener !== null) { | ||||
|                 const newNode = { | ||||
|                     listener, | ||||
|                     listenerType: ATTRIBUTE, | ||||
|                     passive: false, | ||||
|                     once: false, | ||||
|                     next: null, | ||||
|                 }; | ||||
|                 if (prev === null) { | ||||
|                     listeners.set(eventName, newNode); | ||||
|                 } else { | ||||
|                     prev.next = newNode; | ||||
|                 } | ||||
|             } | ||||
|         }, | ||||
|         configurable: true, | ||||
|         enumerable: true, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Define an event attribute (e.g. `eventTarget.onclick`). | ||||
|  * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite. | ||||
|  * @param {string} eventName The event name to define. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function defineEventAttribute(eventTargetPrototype, eventName) { | ||||
|     Object.defineProperty( | ||||
|         eventTargetPrototype, | ||||
|         `on${eventName}`, | ||||
|         defineEventAttributeDescriptor(eventName) | ||||
|     ); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Define a custom EventTarget with event attributes. | ||||
|  * @param {string[]} eventNames Event names for event attributes. | ||||
|  * @returns {EventTarget} The custom EventTarget. | ||||
|  * @private | ||||
|  */ | ||||
| function defineCustomEventTarget(eventNames) { | ||||
|     /** CustomEventTarget */ | ||||
|     function CustomEventTarget() { | ||||
|         EventTarget.call(this); | ||||
|     } | ||||
| 
 | ||||
|     CustomEventTarget.prototype = Object.create(EventTarget.prototype, { | ||||
|         constructor: { | ||||
|             value: CustomEventTarget, | ||||
|             configurable: true, | ||||
|             writable: true, | ||||
|         }, | ||||
|     }); | ||||
| 
 | ||||
|     for (let i = 0; i < eventNames.length; ++i) { | ||||
|         defineEventAttribute(CustomEventTarget.prototype, eventNames[i]); | ||||
|     } | ||||
| 
 | ||||
|     return CustomEventTarget | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * EventTarget. | ||||
|  * | ||||
|  * - This is constructor if no arguments. | ||||
|  * - This is a function which returns a CustomEventTarget constructor if there are arguments. | ||||
|  * | ||||
|  * For example: | ||||
|  * | ||||
|  *     class A extends EventTarget {} | ||||
|  *     class B extends EventTarget("message") {} | ||||
|  *     class C extends EventTarget("message", "error") {} | ||||
|  *     class D extends EventTarget(["message", "error"]) {} | ||||
|  */ | ||||
| function EventTarget() { | ||||
|     /*eslint-disable consistent-return */ | ||||
|     if (this instanceof EventTarget) { | ||||
|         listenersMap.set(this, new Map()); | ||||
|         return | ||||
|     } | ||||
|     if (arguments.length === 1 && Array.isArray(arguments[0])) { | ||||
|         return defineCustomEventTarget(arguments[0]) | ||||
|     } | ||||
|     if (arguments.length > 0) { | ||||
|         const types = new Array(arguments.length); | ||||
|         for (let i = 0; i < arguments.length; ++i) { | ||||
|             types[i] = arguments[i]; | ||||
|         } | ||||
|         return defineCustomEventTarget(types) | ||||
|     } | ||||
|     throw new TypeError("Cannot call a class as a function") | ||||
|     /*eslint-enable consistent-return */ | ||||
| } | ||||
| 
 | ||||
| // Should be enumerable, but class methods are not enumerable.
 | ||||
| EventTarget.prototype = { | ||||
|     /** | ||||
|      * Add a given listener to this event target. | ||||
|      * @param {string} eventName The event name to add. | ||||
|      * @param {Function} listener The listener to add. | ||||
|      * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     addEventListener(eventName, listener, options) { | ||||
|         if (listener == null) { | ||||
|             return | ||||
|         } | ||||
|         if (typeof listener !== "function" && !isObject(listener)) { | ||||
|             throw new TypeError("'listener' should be a function or an object.") | ||||
|         } | ||||
| 
 | ||||
|         const listeners = getListeners(this); | ||||
|         const optionsIsObj = isObject(options); | ||||
|         const capture = optionsIsObj | ||||
|             ? Boolean(options.capture) | ||||
|             : Boolean(options); | ||||
|         const listenerType = capture ? CAPTURE : BUBBLE; | ||||
|         const newNode = { | ||||
|             listener, | ||||
|             listenerType, | ||||
|             passive: optionsIsObj && Boolean(options.passive), | ||||
|             once: optionsIsObj && Boolean(options.once), | ||||
|             next: null, | ||||
|         }; | ||||
| 
 | ||||
|         // Set it as the first node if the first node is null.
 | ||||
|         let node = listeners.get(eventName); | ||||
|         if (node === undefined) { | ||||
|             listeners.set(eventName, newNode); | ||||
|             return | ||||
|         } | ||||
| 
 | ||||
|         // Traverse to the tail while checking duplication..
 | ||||
|         let prev = null; | ||||
|         while (node != null) { | ||||
|             if ( | ||||
|                 node.listener === listener && | ||||
|                 node.listenerType === listenerType | ||||
|             ) { | ||||
|                 // Should ignore duplication.
 | ||||
|                 return | ||||
|             } | ||||
|             prev = node; | ||||
|             node = node.next; | ||||
|         } | ||||
| 
 | ||||
|         // Add it.
 | ||||
|         prev.next = newNode; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Remove a given listener from this event target. | ||||
|      * @param {string} eventName The event name to remove. | ||||
|      * @param {Function} listener The listener to remove. | ||||
|      * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     removeEventListener(eventName, listener, options) { | ||||
|         if (listener == null) { | ||||
|             return | ||||
|         } | ||||
| 
 | ||||
|         const listeners = getListeners(this); | ||||
|         const capture = isObject(options) | ||||
|             ? Boolean(options.capture) | ||||
|             : Boolean(options); | ||||
|         const listenerType = capture ? CAPTURE : BUBBLE; | ||||
| 
 | ||||
|         let prev = null; | ||||
|         let node = listeners.get(eventName); | ||||
|         while (node != null) { | ||||
|             if ( | ||||
|                 node.listener === listener && | ||||
|                 node.listenerType === listenerType | ||||
|             ) { | ||||
|                 if (prev !== null) { | ||||
|                     prev.next = node.next; | ||||
|                 } else if (node.next !== null) { | ||||
|                     listeners.set(eventName, node.next); | ||||
|                 } else { | ||||
|                     listeners.delete(eventName); | ||||
|                 } | ||||
|                 return | ||||
|             } | ||||
| 
 | ||||
|             prev = node; | ||||
|             node = node.next; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Dispatch a given event. | ||||
|      * @param {Event|{type:string}} event The event to dispatch. | ||||
|      * @returns {boolean} `false` if canceled. | ||||
|      */ | ||||
|     dispatchEvent(event) { | ||||
|         if (event == null || typeof event.type !== "string") { | ||||
|             throw new TypeError('"event.type" should be a string.') | ||||
|         } | ||||
| 
 | ||||
|         // If listeners aren't registered, terminate.
 | ||||
|         const listeners = getListeners(this); | ||||
|         const eventName = event.type; | ||||
|         let node = listeners.get(eventName); | ||||
|         if (node == null) { | ||||
|             return true | ||||
|         } | ||||
| 
 | ||||
|         // Since we cannot rewrite several properties, so wrap object.
 | ||||
|         const wrappedEvent = wrapEvent(this, event); | ||||
| 
 | ||||
|         // This doesn't process capturing phase and bubbling phase.
 | ||||
|         // This isn't participating in a tree.
 | ||||
|         let prev = null; | ||||
|         while (node != null) { | ||||
|             // Remove this listener if it's once
 | ||||
|             if (node.once) { | ||||
|                 if (prev !== null) { | ||||
|                     prev.next = node.next; | ||||
|                 } else if (node.next !== null) { | ||||
|                     listeners.set(eventName, node.next); | ||||
|                 } else { | ||||
|                     listeners.delete(eventName); | ||||
|                 } | ||||
|             } else { | ||||
|                 prev = node; | ||||
|             } | ||||
| 
 | ||||
|             // Call this listener
 | ||||
|             setPassiveListener( | ||||
|                 wrappedEvent, | ||||
|                 node.passive ? node.listener : null | ||||
|             ); | ||||
|             if (typeof node.listener === "function") { | ||||
|                 try { | ||||
|                     node.listener.call(this, wrappedEvent); | ||||
|                 } catch (err) { | ||||
|                     if ( | ||||
|                         typeof console !== "undefined" && | ||||
|                         typeof console.error === "function" | ||||
|                     ) { | ||||
|                         console.error(err); | ||||
|                     } | ||||
|                 } | ||||
|             } else if ( | ||||
|                 node.listenerType !== ATTRIBUTE && | ||||
|                 typeof node.listener.handleEvent === "function" | ||||
|             ) { | ||||
|                 node.listener.handleEvent(wrappedEvent); | ||||
|             } | ||||
| 
 | ||||
|             // Break if `event.stopImmediatePropagation` was called.
 | ||||
|             if (isStopped(wrappedEvent)) { | ||||
|                 break | ||||
|             } | ||||
| 
 | ||||
|             node = node.next; | ||||
|         } | ||||
|         setPassiveListener(wrappedEvent, null); | ||||
|         setEventPhase(wrappedEvent, 0); | ||||
|         setCurrentTarget(wrappedEvent, null); | ||||
| 
 | ||||
|         return !wrappedEvent.defaultPrevented | ||||
|     }, | ||||
| }; | ||||
| 
 | ||||
| // `constructor` is not enumerable.
 | ||||
| Object.defineProperty(EventTarget.prototype, "constructor", { | ||||
|     value: EventTarget, | ||||
|     configurable: true, | ||||
|     writable: true, | ||||
| }); | ||||
| 
 | ||||
| // Ensure `eventTarget instanceof window.EventTarget` is `true`.
 | ||||
| if ( | ||||
|     typeof window !== "undefined" && | ||||
|     typeof window.EventTarget !== "undefined" | ||||
| ) { | ||||
|     Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype); | ||||
| } | ||||
| 
 | ||||
| exports.defineEventAttribute = defineEventAttribute; | ||||
| exports.EventTarget = EventTarget; | ||||
| exports.default = EventTarget; | ||||
| 
 | ||||
| module.exports = EventTarget | ||||
| module.exports.EventTarget = module.exports["default"] = EventTarget | ||||
| module.exports.defineEventAttribute = defineEventAttribute | ||||
| //# sourceMappingURL=event-target-shim.js.map
 | ||||
							
								
								
									
										1
									
								
								node_modules/event-target-shim/dist/event-target-shim.js.map
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/event-target-shim/dist/event-target-shim.js.map
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										862
									
								
								node_modules/event-target-shim/dist/event-target-shim.mjs
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										862
									
								
								node_modules/event-target-shim/dist/event-target-shim.mjs
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,862 @@ | |||
| /** | ||||
|  * @author Toru Nagashima <https://github.com/mysticatea>
 | ||||
|  * @copyright 2015 Toru Nagashima. All rights reserved. | ||||
|  * See LICENSE file in root directory for full license. | ||||
|  */ | ||||
| /** | ||||
|  * @typedef {object} PrivateData | ||||
|  * @property {EventTarget} eventTarget The event target. | ||||
|  * @property {{type:string}} event The original event object. | ||||
|  * @property {number} eventPhase The current event phase. | ||||
|  * @property {EventTarget|null} currentTarget The current event target. | ||||
|  * @property {boolean} canceled The flag to prevent default. | ||||
|  * @property {boolean} stopped The flag to stop propagation. | ||||
|  * @property {boolean} immediateStopped The flag to stop propagation immediately. | ||||
|  * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null. | ||||
|  * @property {number} timeStamp The unix time. | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * Private data for event wrappers. | ||||
|  * @type {WeakMap<Event, PrivateData>} | ||||
|  * @private | ||||
|  */ | ||||
| const privateData = new WeakMap(); | ||||
| 
 | ||||
| /** | ||||
|  * Cache for wrapper classes. | ||||
|  * @type {WeakMap<Object, Function>} | ||||
|  * @private | ||||
|  */ | ||||
| const wrappers = new WeakMap(); | ||||
| 
 | ||||
| /** | ||||
|  * Get private data. | ||||
|  * @param {Event} event The event object to get private data. | ||||
|  * @returns {PrivateData} The private data of the event. | ||||
|  * @private | ||||
|  */ | ||||
| function pd(event) { | ||||
|     const retv = privateData.get(event); | ||||
|     console.assert( | ||||
|         retv != null, | ||||
|         "'this' is expected an Event object, but got", | ||||
|         event | ||||
|     ); | ||||
|     return retv | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * https://dom.spec.whatwg.org/#set-the-canceled-flag
 | ||||
|  * @param data {PrivateData} private data. | ||||
|  */ | ||||
| function setCancelFlag(data) { | ||||
|     if (data.passiveListener != null) { | ||||
|         if ( | ||||
|             typeof console !== "undefined" && | ||||
|             typeof console.error === "function" | ||||
|         ) { | ||||
|             console.error( | ||||
|                 "Unable to preventDefault inside passive event listener invocation.", | ||||
|                 data.passiveListener | ||||
|             ); | ||||
|         } | ||||
|         return | ||||
|     } | ||||
|     if (!data.event.cancelable) { | ||||
|         return | ||||
|     } | ||||
| 
 | ||||
|     data.canceled = true; | ||||
|     if (typeof data.event.preventDefault === "function") { | ||||
|         data.event.preventDefault(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * @see https://dom.spec.whatwg.org/#interface-event
 | ||||
|  * @private | ||||
|  */ | ||||
| /** | ||||
|  * The event wrapper. | ||||
|  * @constructor | ||||
|  * @param {EventTarget} eventTarget The event target of this dispatching. | ||||
|  * @param {Event|{type:string}} event The original event to wrap. | ||||
|  */ | ||||
| function Event(eventTarget, event) { | ||||
|     privateData.set(this, { | ||||
|         eventTarget, | ||||
|         event, | ||||
|         eventPhase: 2, | ||||
|         currentTarget: eventTarget, | ||||
|         canceled: false, | ||||
|         stopped: false, | ||||
|         immediateStopped: false, | ||||
|         passiveListener: null, | ||||
|         timeStamp: event.timeStamp || Date.now(), | ||||
|     }); | ||||
| 
 | ||||
|     // https://heycam.github.io/webidl/#Unforgeable
 | ||||
|     Object.defineProperty(this, "isTrusted", { value: false, enumerable: true }); | ||||
| 
 | ||||
|     // Define accessors
 | ||||
|     const keys = Object.keys(event); | ||||
|     for (let i = 0; i < keys.length; ++i) { | ||||
|         const key = keys[i]; | ||||
|         if (!(key in this)) { | ||||
|             Object.defineProperty(this, key, defineRedirectDescriptor(key)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| // Should be enumerable, but class methods are not enumerable.
 | ||||
| Event.prototype = { | ||||
|     /** | ||||
|      * The type of this event. | ||||
|      * @type {string} | ||||
|      */ | ||||
|     get type() { | ||||
|         return pd(this).event.type | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      * @type {EventTarget} | ||||
|      */ | ||||
|     get target() { | ||||
|         return pd(this).eventTarget | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      * @type {EventTarget} | ||||
|      */ | ||||
|     get currentTarget() { | ||||
|         return pd(this).currentTarget | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * @returns {EventTarget[]} The composed path of this event. | ||||
|      */ | ||||
|     composedPath() { | ||||
|         const currentTarget = pd(this).currentTarget; | ||||
|         if (currentTarget == null) { | ||||
|             return [] | ||||
|         } | ||||
|         return [currentTarget] | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of NONE. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get NONE() { | ||||
|         return 0 | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of CAPTURING_PHASE. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get CAPTURING_PHASE() { | ||||
|         return 1 | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of AT_TARGET. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get AT_TARGET() { | ||||
|         return 2 | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of BUBBLING_PHASE. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get BUBBLING_PHASE() { | ||||
|         return 3 | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get eventPhase() { | ||||
|         return pd(this).eventPhase | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Stop event bubbling. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     stopPropagation() { | ||||
|         const data = pd(this); | ||||
| 
 | ||||
|         data.stopped = true; | ||||
|         if (typeof data.event.stopPropagation === "function") { | ||||
|             data.event.stopPropagation(); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Stop event bubbling. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     stopImmediatePropagation() { | ||||
|         const data = pd(this); | ||||
| 
 | ||||
|         data.stopped = true; | ||||
|         data.immediateStopped = true; | ||||
|         if (typeof data.event.stopImmediatePropagation === "function") { | ||||
|             data.event.stopImmediatePropagation(); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to be bubbling. | ||||
|      * @type {boolean} | ||||
|      */ | ||||
|     get bubbles() { | ||||
|         return Boolean(pd(this).event.bubbles) | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to be cancelable. | ||||
|      * @type {boolean} | ||||
|      */ | ||||
|     get cancelable() { | ||||
|         return Boolean(pd(this).event.cancelable) | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Cancel this event. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     preventDefault() { | ||||
|         setCancelFlag(pd(this)); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to indicate cancellation state. | ||||
|      * @type {boolean} | ||||
|      */ | ||||
|     get defaultPrevented() { | ||||
|         return pd(this).canceled | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to be composed. | ||||
|      * @type {boolean} | ||||
|      */ | ||||
|     get composed() { | ||||
|         return Boolean(pd(this).event.composed) | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The unix time of this event. | ||||
|      * @type {number} | ||||
|      */ | ||||
|     get timeStamp() { | ||||
|         return pd(this).timeStamp | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      * @type {EventTarget} | ||||
|      * @deprecated | ||||
|      */ | ||||
|     get srcElement() { | ||||
|         return pd(this).eventTarget | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to stop event bubbling. | ||||
|      * @type {boolean} | ||||
|      * @deprecated | ||||
|      */ | ||||
|     get cancelBubble() { | ||||
|         return pd(this).stopped | ||||
|     }, | ||||
|     set cancelBubble(value) { | ||||
|         if (!value) { | ||||
|             return | ||||
|         } | ||||
|         const data = pd(this); | ||||
| 
 | ||||
|         data.stopped = true; | ||||
|         if (typeof data.event.cancelBubble === "boolean") { | ||||
|             data.event.cancelBubble = true; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to indicate cancellation state. | ||||
|      * @type {boolean} | ||||
|      * @deprecated | ||||
|      */ | ||||
|     get returnValue() { | ||||
|         return !pd(this).canceled | ||||
|     }, | ||||
|     set returnValue(value) { | ||||
|         if (!value) { | ||||
|             setCancelFlag(pd(this)); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Initialize this event object. But do nothing under event dispatching. | ||||
|      * @param {string} type The event type. | ||||
|      * @param {boolean} [bubbles=false] The flag to be possible to bubble up. | ||||
|      * @param {boolean} [cancelable=false] The flag to be possible to cancel. | ||||
|      * @deprecated | ||||
|      */ | ||||
|     initEvent() { | ||||
|         // Do nothing.
 | ||||
|     }, | ||||
| }; | ||||
| 
 | ||||
| // `constructor` is not enumerable.
 | ||||
| Object.defineProperty(Event.prototype, "constructor", { | ||||
|     value: Event, | ||||
|     configurable: true, | ||||
|     writable: true, | ||||
| }); | ||||
| 
 | ||||
| // Ensure `event instanceof window.Event` is `true`.
 | ||||
| if (typeof window !== "undefined" && typeof window.Event !== "undefined") { | ||||
|     Object.setPrototypeOf(Event.prototype, window.Event.prototype); | ||||
| 
 | ||||
|     // Make association for wrappers.
 | ||||
|     wrappers.set(window.Event.prototype, Event); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the property descriptor to redirect a given property. | ||||
|  * @param {string} key Property name to define property descriptor. | ||||
|  * @returns {PropertyDescriptor} The property descriptor to redirect the property. | ||||
|  * @private | ||||
|  */ | ||||
| function defineRedirectDescriptor(key) { | ||||
|     return { | ||||
|         get() { | ||||
|             return pd(this).event[key] | ||||
|         }, | ||||
|         set(value) { | ||||
|             pd(this).event[key] = value; | ||||
|         }, | ||||
|         configurable: true, | ||||
|         enumerable: true, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the property descriptor to call a given method property. | ||||
|  * @param {string} key Property name to define property descriptor. | ||||
|  * @returns {PropertyDescriptor} The property descriptor to call the method property. | ||||
|  * @private | ||||
|  */ | ||||
| function defineCallDescriptor(key) { | ||||
|     return { | ||||
|         value() { | ||||
|             const event = pd(this).event; | ||||
|             return event[key].apply(event, arguments) | ||||
|         }, | ||||
|         configurable: true, | ||||
|         enumerable: true, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Define new wrapper class. | ||||
|  * @param {Function} BaseEvent The base wrapper class. | ||||
|  * @param {Object} proto The prototype of the original event. | ||||
|  * @returns {Function} The defined wrapper class. | ||||
|  * @private | ||||
|  */ | ||||
| function defineWrapper(BaseEvent, proto) { | ||||
|     const keys = Object.keys(proto); | ||||
|     if (keys.length === 0) { | ||||
|         return BaseEvent | ||||
|     } | ||||
| 
 | ||||
|     /** CustomEvent */ | ||||
|     function CustomEvent(eventTarget, event) { | ||||
|         BaseEvent.call(this, eventTarget, event); | ||||
|     } | ||||
| 
 | ||||
|     CustomEvent.prototype = Object.create(BaseEvent.prototype, { | ||||
|         constructor: { value: CustomEvent, configurable: true, writable: true }, | ||||
|     }); | ||||
| 
 | ||||
|     // Define accessors.
 | ||||
|     for (let i = 0; i < keys.length; ++i) { | ||||
|         const key = keys[i]; | ||||
|         if (!(key in BaseEvent.prototype)) { | ||||
|             const descriptor = Object.getOwnPropertyDescriptor(proto, key); | ||||
|             const isFunc = typeof descriptor.value === "function"; | ||||
|             Object.defineProperty( | ||||
|                 CustomEvent.prototype, | ||||
|                 key, | ||||
|                 isFunc | ||||
|                     ? defineCallDescriptor(key) | ||||
|                     : defineRedirectDescriptor(key) | ||||
|             ); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return CustomEvent | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the wrapper class of a given prototype. | ||||
|  * @param {Object} proto The prototype of the original event to get its wrapper. | ||||
|  * @returns {Function} The wrapper class. | ||||
|  * @private | ||||
|  */ | ||||
| function getWrapper(proto) { | ||||
|     if (proto == null || proto === Object.prototype) { | ||||
|         return Event | ||||
|     } | ||||
| 
 | ||||
|     let wrapper = wrappers.get(proto); | ||||
|     if (wrapper == null) { | ||||
|         wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto); | ||||
|         wrappers.set(proto, wrapper); | ||||
|     } | ||||
|     return wrapper | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Wrap a given event to management a dispatching. | ||||
|  * @param {EventTarget} eventTarget The event target of this dispatching. | ||||
|  * @param {Object} event The event to wrap. | ||||
|  * @returns {Event} The wrapper instance. | ||||
|  * @private | ||||
|  */ | ||||
| function wrapEvent(eventTarget, event) { | ||||
|     const Wrapper = getWrapper(Object.getPrototypeOf(event)); | ||||
|     return new Wrapper(eventTarget, event) | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the immediateStopped flag of a given event. | ||||
|  * @param {Event} event The event to get. | ||||
|  * @returns {boolean} The flag to stop propagation immediately. | ||||
|  * @private | ||||
|  */ | ||||
| function isStopped(event) { | ||||
|     return pd(event).immediateStopped | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Set the current event phase of a given event. | ||||
|  * @param {Event} event The event to set current target. | ||||
|  * @param {number} eventPhase New event phase. | ||||
|  * @returns {void} | ||||
|  * @private | ||||
|  */ | ||||
| function setEventPhase(event, eventPhase) { | ||||
|     pd(event).eventPhase = eventPhase; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Set the current target of a given event. | ||||
|  * @param {Event} event The event to set current target. | ||||
|  * @param {EventTarget|null} currentTarget New current target. | ||||
|  * @returns {void} | ||||
|  * @private | ||||
|  */ | ||||
| function setCurrentTarget(event, currentTarget) { | ||||
|     pd(event).currentTarget = currentTarget; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Set a passive listener of a given event. | ||||
|  * @param {Event} event The event to set current target. | ||||
|  * @param {Function|null} passiveListener New passive listener. | ||||
|  * @returns {void} | ||||
|  * @private | ||||
|  */ | ||||
| function setPassiveListener(event, passiveListener) { | ||||
|     pd(event).passiveListener = passiveListener; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * @typedef {object} ListenerNode | ||||
|  * @property {Function} listener | ||||
|  * @property {1|2|3} listenerType | ||||
|  * @property {boolean} passive | ||||
|  * @property {boolean} once | ||||
|  * @property {ListenerNode|null} next | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * @type {WeakMap<object, Map<string, ListenerNode>>} | ||||
|  * @private | ||||
|  */ | ||||
| const listenersMap = new WeakMap(); | ||||
| 
 | ||||
| // Listener types
 | ||||
| const CAPTURE = 1; | ||||
| const BUBBLE = 2; | ||||
| const ATTRIBUTE = 3; | ||||
| 
 | ||||
| /** | ||||
|  * Check whether a given value is an object or not. | ||||
|  * @param {any} x The value to check. | ||||
|  * @returns {boolean} `true` if the value is an object. | ||||
|  */ | ||||
| function isObject(x) { | ||||
|     return x !== null && typeof x === "object" //eslint-disable-line no-restricted-syntax
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get listeners. | ||||
|  * @param {EventTarget} eventTarget The event target to get. | ||||
|  * @returns {Map<string, ListenerNode>} The listeners. | ||||
|  * @private | ||||
|  */ | ||||
| function getListeners(eventTarget) { | ||||
|     const listeners = listenersMap.get(eventTarget); | ||||
|     if (listeners == null) { | ||||
|         throw new TypeError( | ||||
|             "'this' is expected an EventTarget object, but got another value." | ||||
|         ) | ||||
|     } | ||||
|     return listeners | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Get the property descriptor for the event attribute of a given event. | ||||
|  * @param {string} eventName The event name to get property descriptor. | ||||
|  * @returns {PropertyDescriptor} The property descriptor. | ||||
|  * @private | ||||
|  */ | ||||
| function defineEventAttributeDescriptor(eventName) { | ||||
|     return { | ||||
|         get() { | ||||
|             const listeners = getListeners(this); | ||||
|             let node = listeners.get(eventName); | ||||
|             while (node != null) { | ||||
|                 if (node.listenerType === ATTRIBUTE) { | ||||
|                     return node.listener | ||||
|                 } | ||||
|                 node = node.next; | ||||
|             } | ||||
|             return null | ||||
|         }, | ||||
| 
 | ||||
|         set(listener) { | ||||
|             if (typeof listener !== "function" && !isObject(listener)) { | ||||
|                 listener = null; // eslint-disable-line no-param-reassign
 | ||||
|             } | ||||
|             const listeners = getListeners(this); | ||||
| 
 | ||||
|             // Traverse to the tail while removing old value.
 | ||||
|             let prev = null; | ||||
|             let node = listeners.get(eventName); | ||||
|             while (node != null) { | ||||
|                 if (node.listenerType === ATTRIBUTE) { | ||||
|                     // Remove old value.
 | ||||
|                     if (prev !== null) { | ||||
|                         prev.next = node.next; | ||||
|                     } else if (node.next !== null) { | ||||
|                         listeners.set(eventName, node.next); | ||||
|                     } else { | ||||
|                         listeners.delete(eventName); | ||||
|                     } | ||||
|                 } else { | ||||
|                     prev = node; | ||||
|                 } | ||||
| 
 | ||||
|                 node = node.next; | ||||
|             } | ||||
| 
 | ||||
|             // Add new value.
 | ||||
|             if (listener !== null) { | ||||
|                 const newNode = { | ||||
|                     listener, | ||||
|                     listenerType: ATTRIBUTE, | ||||
|                     passive: false, | ||||
|                     once: false, | ||||
|                     next: null, | ||||
|                 }; | ||||
|                 if (prev === null) { | ||||
|                     listeners.set(eventName, newNode); | ||||
|                 } else { | ||||
|                     prev.next = newNode; | ||||
|                 } | ||||
|             } | ||||
|         }, | ||||
|         configurable: true, | ||||
|         enumerable: true, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Define an event attribute (e.g. `eventTarget.onclick`). | ||||
|  * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite. | ||||
|  * @param {string} eventName The event name to define. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function defineEventAttribute(eventTargetPrototype, eventName) { | ||||
|     Object.defineProperty( | ||||
|         eventTargetPrototype, | ||||
|         `on${eventName}`, | ||||
|         defineEventAttributeDescriptor(eventName) | ||||
|     ); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Define a custom EventTarget with event attributes. | ||||
|  * @param {string[]} eventNames Event names for event attributes. | ||||
|  * @returns {EventTarget} The custom EventTarget. | ||||
|  * @private | ||||
|  */ | ||||
| function defineCustomEventTarget(eventNames) { | ||||
|     /** CustomEventTarget */ | ||||
|     function CustomEventTarget() { | ||||
|         EventTarget.call(this); | ||||
|     } | ||||
| 
 | ||||
|     CustomEventTarget.prototype = Object.create(EventTarget.prototype, { | ||||
|         constructor: { | ||||
|             value: CustomEventTarget, | ||||
|             configurable: true, | ||||
|             writable: true, | ||||
|         }, | ||||
|     }); | ||||
| 
 | ||||
|     for (let i = 0; i < eventNames.length; ++i) { | ||||
|         defineEventAttribute(CustomEventTarget.prototype, eventNames[i]); | ||||
|     } | ||||
| 
 | ||||
|     return CustomEventTarget | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * EventTarget. | ||||
|  * | ||||
|  * - This is constructor if no arguments. | ||||
|  * - This is a function which returns a CustomEventTarget constructor if there are arguments. | ||||
|  * | ||||
|  * For example: | ||||
|  * | ||||
|  *     class A extends EventTarget {} | ||||
|  *     class B extends EventTarget("message") {} | ||||
|  *     class C extends EventTarget("message", "error") {} | ||||
|  *     class D extends EventTarget(["message", "error"]) {} | ||||
|  */ | ||||
| function EventTarget() { | ||||
|     /*eslint-disable consistent-return */ | ||||
|     if (this instanceof EventTarget) { | ||||
|         listenersMap.set(this, new Map()); | ||||
|         return | ||||
|     } | ||||
|     if (arguments.length === 1 && Array.isArray(arguments[0])) { | ||||
|         return defineCustomEventTarget(arguments[0]) | ||||
|     } | ||||
|     if (arguments.length > 0) { | ||||
|         const types = new Array(arguments.length); | ||||
|         for (let i = 0; i < arguments.length; ++i) { | ||||
|             types[i] = arguments[i]; | ||||
|         } | ||||
|         return defineCustomEventTarget(types) | ||||
|     } | ||||
|     throw new TypeError("Cannot call a class as a function") | ||||
|     /*eslint-enable consistent-return */ | ||||
| } | ||||
| 
 | ||||
| // Should be enumerable, but class methods are not enumerable.
 | ||||
| EventTarget.prototype = { | ||||
|     /** | ||||
|      * Add a given listener to this event target. | ||||
|      * @param {string} eventName The event name to add. | ||||
|      * @param {Function} listener The listener to add. | ||||
|      * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     addEventListener(eventName, listener, options) { | ||||
|         if (listener == null) { | ||||
|             return | ||||
|         } | ||||
|         if (typeof listener !== "function" && !isObject(listener)) { | ||||
|             throw new TypeError("'listener' should be a function or an object.") | ||||
|         } | ||||
| 
 | ||||
|         const listeners = getListeners(this); | ||||
|         const optionsIsObj = isObject(options); | ||||
|         const capture = optionsIsObj | ||||
|             ? Boolean(options.capture) | ||||
|             : Boolean(options); | ||||
|         const listenerType = capture ? CAPTURE : BUBBLE; | ||||
|         const newNode = { | ||||
|             listener, | ||||
|             listenerType, | ||||
|             passive: optionsIsObj && Boolean(options.passive), | ||||
|             once: optionsIsObj && Boolean(options.once), | ||||
|             next: null, | ||||
|         }; | ||||
| 
 | ||||
|         // Set it as the first node if the first node is null.
 | ||||
|         let node = listeners.get(eventName); | ||||
|         if (node === undefined) { | ||||
|             listeners.set(eventName, newNode); | ||||
|             return | ||||
|         } | ||||
| 
 | ||||
|         // Traverse to the tail while checking duplication..
 | ||||
|         let prev = null; | ||||
|         while (node != null) { | ||||
|             if ( | ||||
|                 node.listener === listener && | ||||
|                 node.listenerType === listenerType | ||||
|             ) { | ||||
|                 // Should ignore duplication.
 | ||||
|                 return | ||||
|             } | ||||
|             prev = node; | ||||
|             node = node.next; | ||||
|         } | ||||
| 
 | ||||
|         // Add it.
 | ||||
|         prev.next = newNode; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Remove a given listener from this event target. | ||||
|      * @param {string} eventName The event name to remove. | ||||
|      * @param {Function} listener The listener to remove. | ||||
|      * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. | ||||
|      * @returns {void} | ||||
|      */ | ||||
|     removeEventListener(eventName, listener, options) { | ||||
|         if (listener == null) { | ||||
|             return | ||||
|         } | ||||
| 
 | ||||
|         const listeners = getListeners(this); | ||||
|         const capture = isObject(options) | ||||
|             ? Boolean(options.capture) | ||||
|             : Boolean(options); | ||||
|         const listenerType = capture ? CAPTURE : BUBBLE; | ||||
| 
 | ||||
|         let prev = null; | ||||
|         let node = listeners.get(eventName); | ||||
|         while (node != null) { | ||||
|             if ( | ||||
|                 node.listener === listener && | ||||
|                 node.listenerType === listenerType | ||||
|             ) { | ||||
|                 if (prev !== null) { | ||||
|                     prev.next = node.next; | ||||
|                 } else if (node.next !== null) { | ||||
|                     listeners.set(eventName, node.next); | ||||
|                 } else { | ||||
|                     listeners.delete(eventName); | ||||
|                 } | ||||
|                 return | ||||
|             } | ||||
| 
 | ||||
|             prev = node; | ||||
|             node = node.next; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Dispatch a given event. | ||||
|      * @param {Event|{type:string}} event The event to dispatch. | ||||
|      * @returns {boolean} `false` if canceled. | ||||
|      */ | ||||
|     dispatchEvent(event) { | ||||
|         if (event == null || typeof event.type !== "string") { | ||||
|             throw new TypeError('"event.type" should be a string.') | ||||
|         } | ||||
| 
 | ||||
|         // If listeners aren't registered, terminate.
 | ||||
|         const listeners = getListeners(this); | ||||
|         const eventName = event.type; | ||||
|         let node = listeners.get(eventName); | ||||
|         if (node == null) { | ||||
|             return true | ||||
|         } | ||||
| 
 | ||||
|         // Since we cannot rewrite several properties, so wrap object.
 | ||||
|         const wrappedEvent = wrapEvent(this, event); | ||||
| 
 | ||||
|         // This doesn't process capturing phase and bubbling phase.
 | ||||
|         // This isn't participating in a tree.
 | ||||
|         let prev = null; | ||||
|         while (node != null) { | ||||
|             // Remove this listener if it's once
 | ||||
|             if (node.once) { | ||||
|                 if (prev !== null) { | ||||
|                     prev.next = node.next; | ||||
|                 } else if (node.next !== null) { | ||||
|                     listeners.set(eventName, node.next); | ||||
|                 } else { | ||||
|                     listeners.delete(eventName); | ||||
|                 } | ||||
|             } else { | ||||
|                 prev = node; | ||||
|             } | ||||
| 
 | ||||
|             // Call this listener
 | ||||
|             setPassiveListener( | ||||
|                 wrappedEvent, | ||||
|                 node.passive ? node.listener : null | ||||
|             ); | ||||
|             if (typeof node.listener === "function") { | ||||
|                 try { | ||||
|                     node.listener.call(this, wrappedEvent); | ||||
|                 } catch (err) { | ||||
|                     if ( | ||||
|                         typeof console !== "undefined" && | ||||
|                         typeof console.error === "function" | ||||
|                     ) { | ||||
|                         console.error(err); | ||||
|                     } | ||||
|                 } | ||||
|             } else if ( | ||||
|                 node.listenerType !== ATTRIBUTE && | ||||
|                 typeof node.listener.handleEvent === "function" | ||||
|             ) { | ||||
|                 node.listener.handleEvent(wrappedEvent); | ||||
|             } | ||||
| 
 | ||||
|             // Break if `event.stopImmediatePropagation` was called.
 | ||||
|             if (isStopped(wrappedEvent)) { | ||||
|                 break | ||||
|             } | ||||
| 
 | ||||
|             node = node.next; | ||||
|         } | ||||
|         setPassiveListener(wrappedEvent, null); | ||||
|         setEventPhase(wrappedEvent, 0); | ||||
|         setCurrentTarget(wrappedEvent, null); | ||||
| 
 | ||||
|         return !wrappedEvent.defaultPrevented | ||||
|     }, | ||||
| }; | ||||
| 
 | ||||
| // `constructor` is not enumerable.
 | ||||
| Object.defineProperty(EventTarget.prototype, "constructor", { | ||||
|     value: EventTarget, | ||||
|     configurable: true, | ||||
|     writable: true, | ||||
| }); | ||||
| 
 | ||||
| // Ensure `eventTarget instanceof window.EventTarget` is `true`.
 | ||||
| if ( | ||||
|     typeof window !== "undefined" && | ||||
|     typeof window.EventTarget !== "undefined" | ||||
| ) { | ||||
|     Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype); | ||||
| } | ||||
| 
 | ||||
| export default EventTarget; | ||||
| export { defineEventAttribute, EventTarget }; | ||||
| //# sourceMappingURL=event-target-shim.mjs.map
 | ||||
							
								
								
									
										1
									
								
								node_modules/event-target-shim/dist/event-target-shim.mjs.map
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/event-target-shim/dist/event-target-shim.mjs.map
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										6
									
								
								node_modules/event-target-shim/dist/event-target-shim.umd.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								node_modules/event-target-shim/dist/event-target-shim.umd.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										1
									
								
								node_modules/event-target-shim/dist/event-target-shim.umd.js.map
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/event-target-shim/dist/event-target-shim.umd.js.map
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										399
									
								
								node_modules/event-target-shim/index.d.ts
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										399
									
								
								node_modules/event-target-shim/index.d.ts
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,399 @@ | |||
| export as namespace EventTargetShim | ||||
| 
 | ||||
| /** | ||||
|  * `Event` interface. | ||||
|  * @see https://dom.spec.whatwg.org/#event
 | ||||
|  */ | ||||
| export interface Event { | ||||
|     /** | ||||
|      * The type of this event. | ||||
|      */ | ||||
|     readonly type: string | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      */ | ||||
|     readonly target: EventTarget<{}, {}, "standard"> | null | ||||
| 
 | ||||
|     /** | ||||
|      * The current target of this event. | ||||
|      */ | ||||
|     readonly currentTarget: EventTarget<{}, {}, "standard"> | null | ||||
| 
 | ||||
|     /** | ||||
|      * The target of this event. | ||||
|      * @deprecated | ||||
|      */ | ||||
|     readonly srcElement: any | null | ||||
| 
 | ||||
|     /** | ||||
|      * The composed path of this event. | ||||
|      */ | ||||
|     composedPath(): EventTarget<{}, {}, "standard">[] | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of NONE. | ||||
|      */ | ||||
|     readonly NONE: number | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of CAPTURING_PHASE. | ||||
|      */ | ||||
|     readonly CAPTURING_PHASE: number | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of BUBBLING_PHASE. | ||||
|      */ | ||||
|     readonly BUBBLING_PHASE: number | ||||
| 
 | ||||
|     /** | ||||
|      * Constant of AT_TARGET. | ||||
|      */ | ||||
|     readonly AT_TARGET: number | ||||
| 
 | ||||
|     /** | ||||
|      * Indicates which phase of the event flow is currently being evaluated. | ||||
|      */ | ||||
|     readonly eventPhase: number | ||||
| 
 | ||||
|     /** | ||||
|      * Stop event bubbling. | ||||
|      */ | ||||
|     stopPropagation(): void | ||||
| 
 | ||||
|     /** | ||||
|      * Stop event bubbling. | ||||
|      */ | ||||
|     stopImmediatePropagation(): void | ||||
| 
 | ||||
|     /** | ||||
|      * Initialize event. | ||||
|      * @deprecated | ||||
|      */ | ||||
|     initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void | ||||
| 
 | ||||
|     /** | ||||
|      * The flag indicating bubbling. | ||||
|      */ | ||||
|     readonly bubbles: boolean | ||||
| 
 | ||||
|     /** | ||||
|      * Stop event bubbling. | ||||
|      * @deprecated | ||||
|      */ | ||||
|     cancelBubble: boolean | ||||
| 
 | ||||
|     /** | ||||
|      * Set or get cancellation flag. | ||||
|      * @deprecated | ||||
|      */ | ||||
|     returnValue: boolean | ||||
| 
 | ||||
|     /** | ||||
|      * The flag indicating whether the event can be canceled. | ||||
|      */ | ||||
|     readonly cancelable: boolean | ||||
| 
 | ||||
|     /** | ||||
|      * Cancel this event. | ||||
|      */ | ||||
|     preventDefault(): void | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to indicating whether the event was canceled. | ||||
|      */ | ||||
|     readonly defaultPrevented: boolean | ||||
| 
 | ||||
|     /** | ||||
|      * The flag to indicating if event is composed. | ||||
|      */ | ||||
|     readonly composed: boolean | ||||
| 
 | ||||
|     /** | ||||
|      * Indicates whether the event was dispatched by the user agent. | ||||
|      */ | ||||
|     readonly isTrusted: boolean | ||||
| 
 | ||||
|     /** | ||||
|      * The unix time of this event. | ||||
|      */ | ||||
|     readonly timeStamp: number | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * The constructor of `EventTarget` interface. | ||||
|  */ | ||||
| export type EventTargetConstructor< | ||||
|     TEvents extends EventTarget.EventDefinition = {}, | ||||
|     TEventAttributes extends EventTarget.EventDefinition = {}, | ||||
|     TMode extends EventTarget.Mode = "loose" | ||||
| > = { | ||||
|     prototype: EventTarget<TEvents, TEventAttributes, TMode> | ||||
|     new(): EventTarget<TEvents, TEventAttributes, TMode> | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * `EventTarget` interface. | ||||
|  * @see https://dom.spec.whatwg.org/#interface-eventtarget
 | ||||
|  */ | ||||
| export type EventTarget< | ||||
|     TEvents extends EventTarget.EventDefinition = {}, | ||||
|     TEventAttributes extends EventTarget.EventDefinition = {}, | ||||
|     TMode extends EventTarget.Mode = "loose" | ||||
| > = EventTarget.EventAttributes<TEventAttributes> & { | ||||
|     /** | ||||
|      * Add a given listener to this event target. | ||||
|      * @param eventName The event name to add. | ||||
|      * @param listener The listener to add. | ||||
|      * @param options The options for this listener. | ||||
|      */ | ||||
|     addEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>( | ||||
|         type: TEventType, | ||||
|         listener: | ||||
|             | EventTarget.Listener<EventTarget.PickEvent<TEvents, TEventType>> | ||||
|             | null, | ||||
|         options?: boolean | EventTarget.AddOptions | ||||
|     ): void | ||||
| 
 | ||||
|     /** | ||||
|      * Remove a given listener from this event target. | ||||
|      * @param eventName The event name to remove. | ||||
|      * @param listener The listener to remove. | ||||
|      * @param options The options for this listener. | ||||
|      */ | ||||
|     removeEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>( | ||||
|         type: TEventType, | ||||
|         listener: | ||||
|             | EventTarget.Listener<EventTarget.PickEvent<TEvents, TEventType>> | ||||
|             | null, | ||||
|         options?: boolean | EventTarget.RemoveOptions | ||||
|     ): void | ||||
| 
 | ||||
|     /** | ||||
|      * Dispatch a given event. | ||||
|      * @param event The event to dispatch. | ||||
|      * @returns `false` if canceled. | ||||
|      */ | ||||
|     dispatchEvent<TEventType extends EventTarget.EventType<TEvents, TMode>>( | ||||
|         event: EventTarget.EventData<TEvents, TEventType, TMode> | ||||
|     ): boolean | ||||
| } | ||||
| 
 | ||||
| export const EventTarget: EventTargetConstructor & { | ||||
|     /** | ||||
|      * Create an `EventTarget` instance with detailed event definition. | ||||
|      * | ||||
|      * The detailed event definition requires to use `defineEventAttribute()` | ||||
|      * function later. | ||||
|      * | ||||
|      * Unfortunately, the second type parameter `TEventAttributes` was needed | ||||
|      * because we cannot compute string literal types. | ||||
|      * | ||||
|      * @example | ||||
|      * const signal = new EventTarget<{ abort: Event }, { onabort: Event }>() | ||||
|      * defineEventAttribute(signal, "abort") | ||||
|      */ | ||||
|     new < | ||||
|         TEvents extends EventTarget.EventDefinition, | ||||
|         TEventAttributes extends EventTarget.EventDefinition, | ||||
|         TMode extends EventTarget.Mode = "loose" | ||||
|     >(): EventTarget<TEvents, TEventAttributes, TMode> | ||||
| 
 | ||||
|     /** | ||||
|      * Define an `EventTarget` constructor with attribute events and detailed event definition. | ||||
|      * | ||||
|      * Unfortunately, the second type parameter `TEventAttributes` was needed | ||||
|      * because we cannot compute string literal types. | ||||
|      * | ||||
|      * @example | ||||
|      * class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") { | ||||
|      *      abort(): void {} | ||||
|      * } | ||||
|      * | ||||
|      * @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype). | ||||
|      */ | ||||
|     < | ||||
|         TEvents extends EventTarget.EventDefinition = {}, | ||||
|         TEventAttributes extends EventTarget.EventDefinition = {}, | ||||
|         TMode extends EventTarget.Mode = "loose" | ||||
|     >(events: string[]): EventTargetConstructor< | ||||
|         TEvents, | ||||
|         TEventAttributes, | ||||
|         TMode | ||||
|     > | ||||
| 
 | ||||
|     /** | ||||
|      * Define an `EventTarget` constructor with attribute events and detailed event definition. | ||||
|      * | ||||
|      * Unfortunately, the second type parameter `TEventAttributes` was needed | ||||
|      * because we cannot compute string literal types. | ||||
|      * | ||||
|      * @example | ||||
|      * class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") { | ||||
|      *      abort(): void {} | ||||
|      * } | ||||
|      * | ||||
|      * @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype). | ||||
|      */ | ||||
|     < | ||||
|         TEvents extends EventTarget.EventDefinition = {}, | ||||
|         TEventAttributes extends EventTarget.EventDefinition = {}, | ||||
|         TMode extends EventTarget.Mode = "loose" | ||||
|     >(event0: string, ...events: string[]): EventTargetConstructor< | ||||
|         TEvents, | ||||
|         TEventAttributes, | ||||
|         TMode | ||||
|     > | ||||
| } | ||||
| 
 | ||||
| export namespace EventTarget { | ||||
|     /** | ||||
|      * Options of `removeEventListener()` method. | ||||
|      */ | ||||
|     export interface RemoveOptions { | ||||
|         /** | ||||
|          * The flag to indicate that the listener is for the capturing phase. | ||||
|          */ | ||||
|         capture?: boolean | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Options of `addEventListener()` method. | ||||
|      */ | ||||
|     export interface AddOptions extends RemoveOptions { | ||||
|         /** | ||||
|          * The flag to indicate that the listener doesn't support | ||||
|          * `event.preventDefault()` operation. | ||||
|          */ | ||||
|         passive?: boolean | ||||
|         /** | ||||
|          * The flag to indicate that the listener will be removed on the first | ||||
|          * event. | ||||
|          */ | ||||
|         once?: boolean | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * The type of regular listeners. | ||||
|      */ | ||||
|     export interface FunctionListener<TEvent> { | ||||
|         (event: TEvent): void | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * The type of object listeners. | ||||
|      */ | ||||
|     export interface ObjectListener<TEvent> { | ||||
|         handleEvent(event: TEvent): void | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * The type of listeners. | ||||
|      */ | ||||
|     export type Listener<TEvent> = | ||||
|         | FunctionListener<TEvent> | ||||
|         | ObjectListener<TEvent> | ||||
| 
 | ||||
|     /** | ||||
|      * Event definition. | ||||
|      */ | ||||
|     export type EventDefinition = { | ||||
|         readonly [key: string]: Event | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Mapped type for event attributes. | ||||
|      */ | ||||
|     export type EventAttributes<TEventAttributes extends EventDefinition> = { | ||||
|         [P in keyof TEventAttributes]: | ||||
|             | FunctionListener<TEventAttributes[P]> | ||||
|             | null | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * The type of event data for `dispatchEvent()` method. | ||||
|      */ | ||||
|     export type EventData< | ||||
|         TEvents extends EventDefinition, | ||||
|         TEventType extends keyof TEvents | string, | ||||
|         TMode extends Mode | ||||
|     > = | ||||
|         TEventType extends keyof TEvents | ||||
|             ? ( | ||||
|                 // Require properties which are not generated automatically.
 | ||||
|                 & Pick< | ||||
|                     TEvents[TEventType], | ||||
|                     Exclude<keyof TEvents[TEventType], OmittableEventKeys> | ||||
|                 > | ||||
|                 // Properties which are generated automatically are optional.
 | ||||
|                 & Partial<Pick<Event, OmittableEventKeys>> | ||||
|             ) | ||||
|             : ( | ||||
|                 TMode extends "standard" | ||||
|                     ? Event | ||||
|                     : Event | NonStandardEvent | ||||
|             ) | ||||
| 
 | ||||
|     /** | ||||
|      * The string literal types of the properties which are generated | ||||
|      * automatically in `dispatchEvent()` method. | ||||
|      */ | ||||
|     export type OmittableEventKeys = Exclude<keyof Event, "type"> | ||||
| 
 | ||||
|     /** | ||||
|      * The type of event data. | ||||
|      */ | ||||
|     export type NonStandardEvent = { | ||||
|         [key: string]: any | ||||
|         type: string | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * The type of listeners. | ||||
|      */ | ||||
|     export type PickEvent< | ||||
|         TEvents extends EventDefinition, | ||||
|         TEventType extends keyof TEvents | string, | ||||
|     > = | ||||
|         TEventType extends keyof TEvents | ||||
|             ? TEvents[TEventType] | ||||
|             : Event | ||||
| 
 | ||||
|     /** | ||||
|      * Event type candidates. | ||||
|      */ | ||||
|     export type EventType< | ||||
|         TEvents extends EventDefinition, | ||||
|         TMode extends Mode | ||||
|     > = | ||||
|         TMode extends "strict" | ||||
|             ? keyof TEvents | ||||
|             : keyof TEvents | string | ||||
| 
 | ||||
|     /** | ||||
|      * - `"strict"` ..... Methods don't accept unknown events. | ||||
|      *                    `dispatchEvent()` accepts partial objects. | ||||
|      * - `"loose"` ...... Methods accept unknown events. | ||||
|      *                    `dispatchEvent()` accepts partial objects. | ||||
|      * - `"standard"` ... Methods accept unknown events. | ||||
|      *                    `dispatchEvent()` doesn't accept partial objects. | ||||
|      */ | ||||
|     export type Mode = "strict" | "standard" | "loose" | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Specialized `type` property. | ||||
|  */ | ||||
| export type Type<T extends string> = { type: T } | ||||
| 
 | ||||
| /** | ||||
|  * Define an event attribute (e.g. `eventTarget.onclick`). | ||||
|  * @param prototype The event target prototype to define an event attribute. | ||||
|  * @param eventName The event name to define. | ||||
|  */ | ||||
| export function defineEventAttribute( | ||||
|     prototype: EventTarget, | ||||
|     eventName: string | ||||
| ): void | ||||
| 
 | ||||
| export default EventTarget | ||||
							
								
								
									
										82
									
								
								node_modules/event-target-shim/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								node_modules/event-target-shim/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,82 @@ | |||
| { | ||||
|   "name": "event-target-shim", | ||||
|   "version": "5.0.1", | ||||
|   "description": "An implementation of WHATWG EventTarget interface.", | ||||
|   "main": "dist/event-target-shim", | ||||
|   "types": "index.d.ts", | ||||
|   "files": [ | ||||
|     "dist", | ||||
|     "index.d.ts" | ||||
|   ], | ||||
|   "engines": { | ||||
|     "node": ">=6" | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "preversion": "npm test", | ||||
|     "version": "npm run build && git add dist/*", | ||||
|     "postversion": "git push && git push --tags", | ||||
|     "clean": "rimraf .nyc_output coverage", | ||||
|     "coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html", | ||||
|     "lint": "eslint src test scripts --ext .js,.mjs", | ||||
|     "build": "rollup -c scripts/rollup.config.js", | ||||
|     "pretest": "npm run lint", | ||||
|     "test": "run-s test:*", | ||||
|     "test:mocha": "nyc --require ./scripts/babel-register mocha test/*.mjs", | ||||
|     "test:karma": "karma start scripts/karma.conf.js --single-run", | ||||
|     "watch": "run-p watch:*", | ||||
|     "watch:mocha": "mocha test/*.mjs --require ./scripts/babel-register --watch --watch-extensions js,mjs --growl", | ||||
|     "watch:karma": "karma start scripts/karma.conf.js --watch", | ||||
|     "codecov": "codecov" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@babel/core": "^7.2.2", | ||||
|     "@babel/plugin-transform-modules-commonjs": "^7.2.0", | ||||
|     "@babel/preset-env": "^7.2.3", | ||||
|     "@babel/register": "^7.0.0", | ||||
|     "@mysticatea/eslint-plugin": "^8.0.1", | ||||
|     "@mysticatea/spy": "^0.1.2", | ||||
|     "assert": "^1.4.1", | ||||
|     "codecov": "^3.1.0", | ||||
|     "eslint": "^5.12.1", | ||||
|     "karma": "^3.1.4", | ||||
|     "karma-chrome-launcher": "^2.2.0", | ||||
|     "karma-coverage": "^1.1.2", | ||||
|     "karma-firefox-launcher": "^1.0.0", | ||||
|     "karma-growl-reporter": "^1.0.0", | ||||
|     "karma-ie-launcher": "^1.0.0", | ||||
|     "karma-mocha": "^1.3.0", | ||||
|     "karma-rollup-preprocessor": "^7.0.0-rc.2", | ||||
|     "mocha": "^5.2.0", | ||||
|     "npm-run-all": "^4.1.5", | ||||
|     "nyc": "^13.1.0", | ||||
|     "opener": "^1.5.1", | ||||
|     "rimraf": "^2.6.3", | ||||
|     "rollup": "^1.1.1", | ||||
|     "rollup-plugin-babel": "^4.3.2", | ||||
|     "rollup-plugin-babel-minify": "^7.0.0", | ||||
|     "rollup-plugin-commonjs": "^9.2.0", | ||||
|     "rollup-plugin-json": "^3.1.0", | ||||
|     "rollup-plugin-node-resolve": "^4.0.0", | ||||
|     "rollup-watch": "^4.3.1", | ||||
|     "type-tester": "^1.0.0", | ||||
|     "typescript": "^3.2.4" | ||||
|   }, | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "https://github.com/mysticatea/event-target-shim.git" | ||||
|   }, | ||||
|   "keywords": [ | ||||
|     "w3c", | ||||
|     "whatwg", | ||||
|     "eventtarget", | ||||
|     "event", | ||||
|     "events", | ||||
|     "shim" | ||||
|   ], | ||||
|   "author": "Toru Nagashima", | ||||
|   "license": "MIT", | ||||
|   "bugs": { | ||||
|     "url": "https://github.com/mysticatea/event-target-shim/issues" | ||||
|   }, | ||||
|   "homepage": "https://github.com/mysticatea/event-target-shim" | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue