Remove deprecated scripts for adding head-matter to wt_config.xml, including Python and Bash implementations, to streamline configuration management.
This commit is contained in:
201
node_modules/bare-events/LICENSE
generated
vendored
Normal file
201
node_modules/bare-events/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
25
node_modules/bare-events/README.md
generated
vendored
Normal file
25
node_modules/bare-events/README.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# bare-events
|
||||
|
||||
Event emitters for JavaScript.
|
||||
|
||||
```
|
||||
npm install bare-events
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const EventEmitter = require('bare-events')
|
||||
|
||||
const e = new EventEmitter()
|
||||
|
||||
e.on('hello', function (data) {
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
e.emit('hello', 'world')
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
15
node_modules/bare-events/global.d.ts
generated
vendored
Normal file
15
node_modules/bare-events/global.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as events from './web'
|
||||
|
||||
type EventConstructor = typeof events.Event
|
||||
type CustomEventConstructor = typeof events.CustomEvent
|
||||
type EventTargetConstructor = typeof events.EventTarget
|
||||
|
||||
declare global {
|
||||
type Event = events.Event
|
||||
type CustomEvent<T = any> = events.CustomEvent<T>
|
||||
type EventTarget = events.EventTarget
|
||||
|
||||
const Event: EventConstructor
|
||||
const CustomEvent: CustomEventConstructor
|
||||
const EventTarget: EventTargetConstructor
|
||||
}
|
||||
5
node_modules/bare-events/global.js
generated
vendored
Normal file
5
node_modules/bare-events/global.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
const events = require('./web')
|
||||
|
||||
global.Event = events.Event
|
||||
global.CustomEvent = events.CustomEvent
|
||||
global.EventTarget = events.EventTarget
|
||||
81
node_modules/bare-events/index.d.ts
generated
vendored
Normal file
81
node_modules/bare-events/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
import { AbortSignal } from 'bare-abort-controller'
|
||||
|
||||
interface EventMap {
|
||||
[event: string | symbol]: unknown[]
|
||||
}
|
||||
|
||||
interface EventHandler<in A extends unknown[] = unknown[], out R = unknown> {
|
||||
(...args: A): R
|
||||
}
|
||||
|
||||
declare class EventEmitterError extends Error {
|
||||
static OPERATION_ABORTED(cause: Error, msg?: string): EventEmitterError
|
||||
static UNHANDLED_ERROR(cause: Error, msg?: string): EventEmitterError
|
||||
}
|
||||
|
||||
interface EventEmitter<in out M extends EventMap = EventMap> {
|
||||
addListener<E extends keyof M, R>(name: E, fn: EventHandler<M[E], R>): this
|
||||
|
||||
addOnceListener<E extends keyof M, R>(name: E, fn: EventHandler<M[E], R>): this
|
||||
|
||||
prependListener<E extends keyof M, R>(name: E, fn: EventHandler<M[E], R>): this
|
||||
|
||||
prependOnceListener<E extends keyof M, R>(name: E, fn: EventHandler<M[E], R>): this
|
||||
|
||||
removeListener<E extends keyof M, R>(name: E, fn: EventHandler<M[E], R>): this
|
||||
|
||||
removeAllListeners<E extends keyof M>(name?: E): this
|
||||
|
||||
on<E extends keyof M, R>(name: E, fn: EventHandler<M[E], R>): this
|
||||
|
||||
once<E extends keyof M, R>(name: E, fn: EventHandler<M[E], R>): this
|
||||
|
||||
off<E extends keyof M, R>(name: E, fn: EventHandler<M[E], R>): this
|
||||
|
||||
emit<E extends keyof M>(name: E, ...args: M[E]): boolean
|
||||
|
||||
listeners<E extends keyof M, R>(name: E): EventHandler<M[E], R>
|
||||
|
||||
listenerCount<E extends keyof M>(name: E): number
|
||||
|
||||
getMaxListeners(): number
|
||||
setMaxListeners(n: number): void
|
||||
}
|
||||
|
||||
declare class EventEmitter<in out M extends EventMap = EventMap> {}
|
||||
|
||||
declare namespace EventEmitter {
|
||||
export function on<M extends EventMap, E extends keyof M>(
|
||||
emitter: EventEmitter<M>,
|
||||
name: E,
|
||||
opts?: { signal?: AbortSignal }
|
||||
): AsyncIterableIterator<M[E]>
|
||||
|
||||
export function once<M extends EventMap, E extends keyof M>(
|
||||
emitter: EventEmitter<M>,
|
||||
name: E,
|
||||
opts?: { signal?: AbortSignal }
|
||||
): Promise<M[E]>
|
||||
|
||||
export function forward<F extends EventMap, E extends keyof F, T extends Pick<F, E>>(
|
||||
from: EventEmitter<F>,
|
||||
to: EventEmitter<T>,
|
||||
names: E | E[],
|
||||
opts?: { emit?: (name: E, ...args: T[E]) => void }
|
||||
): void
|
||||
|
||||
export function listenerCount<M extends EventMap, E extends keyof M>(
|
||||
emitter: EventEmitter<M>,
|
||||
name: E
|
||||
): number
|
||||
|
||||
export function getMaxListeners(emitter: EventEmitter): number
|
||||
|
||||
export function setMaxListeners(n: number, ...emitters: EventEmitter[]): void
|
||||
|
||||
export let defaultMaxListeners: number
|
||||
|
||||
export { EventEmitter, EventEmitterError as errors, EventMap, EventHandler }
|
||||
}
|
||||
|
||||
export = EventEmitter
|
||||
367
node_modules/bare-events/index.js
generated
vendored
Normal file
367
node_modules/bare-events/index.js
generated
vendored
Normal file
@@ -0,0 +1,367 @@
|
||||
const errors = require('./lib/errors')
|
||||
|
||||
class EventListener {
|
||||
constructor() {
|
||||
this.list = []
|
||||
this.count = 0
|
||||
}
|
||||
|
||||
append(ctx, name, fn, once) {
|
||||
this.count++
|
||||
ctx.emit('newListener', name, fn) // Emit BEFORE adding
|
||||
this.list.push([fn, once])
|
||||
}
|
||||
|
||||
prepend(ctx, name, fn, once) {
|
||||
this.count++
|
||||
ctx.emit('newListener', name, fn) // Emit BEFORE adding
|
||||
this.list.unshift([fn, once])
|
||||
}
|
||||
|
||||
remove(ctx, name, fn) {
|
||||
for (let i = 0, n = this.list.length; i < n; i++) {
|
||||
const l = this.list[i]
|
||||
|
||||
if (l[0] === fn) {
|
||||
this.list.splice(i, 1)
|
||||
|
||||
if (this.count === 1) delete ctx._events[name]
|
||||
|
||||
ctx.emit('removeListener', name, fn) // Emit AFTER removing
|
||||
|
||||
this.count--
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeAll(ctx, name) {
|
||||
const list = [...this.list]
|
||||
this.list = []
|
||||
|
||||
if (this.count === list.length) delete ctx._events[name]
|
||||
|
||||
for (let i = list.length - 1; i >= 0; i--) {
|
||||
ctx.emit('removeListener', name, list[i][0]) // Emit AFTER removing
|
||||
}
|
||||
|
||||
this.count -= list.length
|
||||
}
|
||||
|
||||
emit(ctx, name, ...args) {
|
||||
const list = [...this.list]
|
||||
|
||||
for (let i = 0, n = list.length; i < n; i++) {
|
||||
const l = list[i]
|
||||
|
||||
if (l[1] === true) this.remove(ctx, name, l[0])
|
||||
|
||||
Reflect.apply(l[0], ctx, args)
|
||||
}
|
||||
|
||||
return list.length > 0
|
||||
}
|
||||
}
|
||||
|
||||
function appendListener(ctx, name, fn, once) {
|
||||
if (ctx._events === undefined) ctx._events = Object.create(null)
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener())
|
||||
e.append(ctx, name, fn, once)
|
||||
return ctx
|
||||
}
|
||||
|
||||
function prependListener(ctx, name, fn, once) {
|
||||
if (ctx._events === undefined) ctx._events = Object.create(null)
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener())
|
||||
e.prepend(ctx, name, fn, once)
|
||||
return ctx
|
||||
}
|
||||
|
||||
function removeListener(ctx, name, fn) {
|
||||
if (ctx._events === undefined) return ctx
|
||||
const e = ctx._events[name]
|
||||
if (e !== undefined) e.remove(ctx, name, fn)
|
||||
return ctx
|
||||
}
|
||||
|
||||
function throwUnhandledError(...args) {
|
||||
let err
|
||||
|
||||
if (args.length > 0) err = args[0]
|
||||
|
||||
if (err instanceof Error === false) err = errors.UNHANDLED_ERROR(err)
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(err, exports.prototype.emit)
|
||||
}
|
||||
|
||||
queueMicrotask(() => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = exports = class EventEmitter {
|
||||
constructor() {
|
||||
this._events = Object.create(null)
|
||||
}
|
||||
|
||||
addListener(name, fn) {
|
||||
return appendListener(this, name, fn, false)
|
||||
}
|
||||
|
||||
addOnceListener(name, fn) {
|
||||
return appendListener(this, name, fn, true)
|
||||
}
|
||||
|
||||
prependListener(name, fn) {
|
||||
return prependListener(this, name, fn, false)
|
||||
}
|
||||
|
||||
prependOnceListener(name, fn) {
|
||||
return prependListener(this, name, fn, true)
|
||||
}
|
||||
|
||||
removeListener(name, fn) {
|
||||
return removeListener(this, name, fn)
|
||||
}
|
||||
|
||||
on(name, fn) {
|
||||
return appendListener(this, name, fn, false)
|
||||
}
|
||||
|
||||
once(name, fn) {
|
||||
return appendListener(this, name, fn, true)
|
||||
}
|
||||
|
||||
off(name, fn) {
|
||||
return removeListener(this, name, fn)
|
||||
}
|
||||
|
||||
emit(name, ...args) {
|
||||
if (name === 'error' && this._events !== undefined && this._events.error === undefined) {
|
||||
throwUnhandledError(...args)
|
||||
}
|
||||
|
||||
if (this._events === undefined) return false
|
||||
const e = this._events[name]
|
||||
return e === undefined ? false : e.emit(this, name, ...args)
|
||||
}
|
||||
|
||||
listeners(name) {
|
||||
if (this._events === undefined) return []
|
||||
const e = this._events[name]
|
||||
return e === undefined ? [] : [...e.list]
|
||||
}
|
||||
|
||||
listenerCount(name) {
|
||||
if (this._events === undefined) return 0
|
||||
const e = this._events[name]
|
||||
return e === undefined ? 0 : e.list.length
|
||||
}
|
||||
|
||||
getMaxListeners() {
|
||||
return EventEmitter.defaultMaxListeners
|
||||
}
|
||||
|
||||
setMaxListeners(n) {}
|
||||
|
||||
removeAllListeners(name) {
|
||||
if (arguments.length === 0) {
|
||||
for (const key of Reflect.ownKeys(this._events)) {
|
||||
if (key === 'removeListener') continue
|
||||
this.removeAllListeners(key)
|
||||
}
|
||||
this.removeAllListeners('removeListener')
|
||||
} else {
|
||||
const e = this._events[name]
|
||||
if (e !== undefined) e.removeAll(this, name)
|
||||
}
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
exports.EventEmitter = exports
|
||||
|
||||
exports.errors = errors
|
||||
|
||||
exports.defaultMaxListeners = 10
|
||||
|
||||
exports.on = function on(emitter, name, opts = {}) {
|
||||
const { signal } = opts
|
||||
|
||||
if (signal && signal.aborted) {
|
||||
throw errors.OPERATION_ABORTED(signal.reason)
|
||||
}
|
||||
|
||||
let error = null
|
||||
let done = false
|
||||
|
||||
const events = []
|
||||
const promises = []
|
||||
|
||||
if (name !== 'error') emitter.on('error', onerror)
|
||||
|
||||
if (signal) signal.addEventListener('abort', onabort)
|
||||
|
||||
emitter.on(name, onevent)
|
||||
|
||||
return {
|
||||
next() {
|
||||
if (events.length) {
|
||||
return Promise.resolve({ value: events.shift(), done: false })
|
||||
}
|
||||
|
||||
if (error) {
|
||||
const err = error
|
||||
|
||||
error = null
|
||||
|
||||
return Promise.reject(err)
|
||||
}
|
||||
|
||||
if (done) return onclose()
|
||||
|
||||
return new Promise((resolve, reject) => promises.push({ resolve, reject }))
|
||||
},
|
||||
|
||||
return() {
|
||||
return onclose()
|
||||
},
|
||||
|
||||
throw(err) {
|
||||
return onerror(err)
|
||||
},
|
||||
|
||||
[Symbol.asyncIterator]() {
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
function onevent(...args) {
|
||||
if (promises.length) {
|
||||
promises.shift().resolve({ value: args, done: false })
|
||||
} else {
|
||||
events.push(args)
|
||||
}
|
||||
}
|
||||
|
||||
function onerror(err) {
|
||||
emitter.off(name, onevent).off('error', onerror)
|
||||
|
||||
if (promises.length) {
|
||||
promises.shift().reject(err)
|
||||
} else {
|
||||
error = err
|
||||
}
|
||||
|
||||
return Promise.resolve({ done: true })
|
||||
}
|
||||
|
||||
function onabort() {
|
||||
signal.removeEventListener('abort', onabort)
|
||||
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason))
|
||||
}
|
||||
|
||||
function onclose() {
|
||||
emitter.off(name, onevent)
|
||||
|
||||
if (name !== 'error') emitter.off('error', onerror)
|
||||
|
||||
if (signal) signal.removeEventListener('abort', onabort)
|
||||
|
||||
done = true
|
||||
|
||||
if (promises.length) promises.shift().resolve({ done: true })
|
||||
|
||||
return Promise.resolve({ done: true })
|
||||
}
|
||||
}
|
||||
|
||||
exports.once = function once(emitter, name, opts = {}) {
|
||||
const { signal } = opts
|
||||
|
||||
if (signal && signal.aborted) {
|
||||
return Promise.reject(errors.OPERATION_ABORTED(signal.reason))
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (name !== 'error') emitter.on('error', onerror)
|
||||
|
||||
if (signal) signal.addEventListener('abort', onabort)
|
||||
|
||||
emitter.once(name, onevent)
|
||||
|
||||
function onevent(...args) {
|
||||
if (name !== 'error') emitter.off('error', onerror)
|
||||
|
||||
if (signal) signal.removeEventListener('abort', onabort)
|
||||
|
||||
resolve(args)
|
||||
}
|
||||
|
||||
function onerror(err) {
|
||||
emitter.off(name, onevent)
|
||||
|
||||
if (name !== 'error') emitter.off('error', onerror)
|
||||
|
||||
reject(err)
|
||||
}
|
||||
|
||||
function onabort() {
|
||||
signal.removeEventListener('abort', onabort)
|
||||
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
exports.forward = function forward(from, to, names, opts = {}) {
|
||||
if (typeof names === 'string') names = [names]
|
||||
|
||||
const { emit = to.emit.bind(to) } = opts
|
||||
|
||||
const listeners = names.map(
|
||||
(name) =>
|
||||
function onevent(...args) {
|
||||
emit(name, ...args)
|
||||
}
|
||||
)
|
||||
|
||||
to.on('newListener', (name) => {
|
||||
const i = names.indexOf(name)
|
||||
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.on(name, listeners[i])
|
||||
}
|
||||
}).on('removeListener', (name) => {
|
||||
const i = names.indexOf(name)
|
||||
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.off(name, listeners[i])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
exports.listenerCount = function listenerCount(emitter, name) {
|
||||
return emitter.listenerCount(name)
|
||||
}
|
||||
|
||||
exports.getMaxListeners = function getMaxListeners(emitter) {
|
||||
if (typeof emitter.getMaxListeners === 'function') {
|
||||
return emitter.getMaxListeners()
|
||||
}
|
||||
|
||||
return exports.defaultMaxListeners
|
||||
}
|
||||
|
||||
exports.setMaxListeners = function setMaxListeners(n, ...emitters) {
|
||||
if (emitters.length === 0) exports.defaultMaxListeners = n
|
||||
else {
|
||||
for (const emitter of emitters) {
|
||||
if (typeof emitter.setMaxListeners === 'function') {
|
||||
emitter.setMaxListeners(n)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
node_modules/bare-events/lib/errors.js
generated
vendored
Normal file
26
node_modules/bare-events/lib/errors.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
module.exports = class EventEmitterError extends Error {
|
||||
constructor(msg, code, fn = EventEmitterError, opts) {
|
||||
super(`${code}: ${msg}`, opts)
|
||||
this.code = code
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn)
|
||||
}
|
||||
}
|
||||
|
||||
get name() {
|
||||
return 'EventEmitterError'
|
||||
}
|
||||
|
||||
static OPERATION_ABORTED(cause, msg = 'Operation aborted') {
|
||||
return new EventEmitterError(msg, 'OPERATION_ABORTED', EventEmitterError.OPERATION_ABORTED, {
|
||||
cause
|
||||
})
|
||||
}
|
||||
|
||||
static UNHANDLED_ERROR(cause, msg = 'Unhandled error') {
|
||||
return new EventEmitterError(msg, 'UNHANDLED_ERROR', EventEmitterError.UNHANDLED_ERROR, {
|
||||
cause
|
||||
})
|
||||
}
|
||||
}
|
||||
61
node_modules/bare-events/package.json
generated
vendored
Normal file
61
node_modules/bare-events/package.json
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "bare-events",
|
||||
"version": "2.8.2",
|
||||
"description": "Event emitters for JavaScript",
|
||||
"exports": {
|
||||
"./package": "./package.json",
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./global": {
|
||||
"types": "./global.d.ts",
|
||||
"default": "./global.js"
|
||||
},
|
||||
"./web": {
|
||||
"types": "./web.d.ts",
|
||||
"default": "./web.js"
|
||||
},
|
||||
"./errors": "./lib/errors.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"global.js",
|
||||
"global.d.ts",
|
||||
"web.js",
|
||||
"web.d.ts",
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run lint && npm run test:bare && npm run test:node",
|
||||
"test:bare": "bare test.js",
|
||||
"test:node": "node test.js",
|
||||
"lint": "prettier . --check"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/holepunchto/bare-events.git"
|
||||
},
|
||||
"author": "Holepunch",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/holepunchto/bare-events/issues"
|
||||
},
|
||||
"homepage": "https://github.com/holepunchto/bare-events#readme",
|
||||
"devDependencies": {
|
||||
"bare-abort-controller": "^1.0.0",
|
||||
"brittle": "^3.3.2",
|
||||
"prettier": "^3.4.2",
|
||||
"prettier-config-holepunch": "^2.0.0",
|
||||
"uncaughts": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bare-abort-controller": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bare-abort-controller": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
79
node_modules/bare-events/web.d.ts
generated
vendored
Normal file
79
node_modules/bare-events/web.d.ts
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
interface AbortSignal extends EventTarget {}
|
||||
|
||||
export interface EventOptions {
|
||||
bubbles?: boolean
|
||||
cancelable?: boolean
|
||||
composed?: boolean
|
||||
}
|
||||
|
||||
export interface Event {
|
||||
readonly type: string
|
||||
readonly target: EventTarget | null
|
||||
readonly currentTarget: EventTarget | null
|
||||
readonly bubbles: boolean
|
||||
readonly cancelable: boolean
|
||||
readonly composed: boolean
|
||||
readonly defaultPrevented: boolean
|
||||
readonly isTrusted: boolean
|
||||
|
||||
preventDefault(): void
|
||||
stopPropagation(): void
|
||||
stopImmediatePropagation(): void
|
||||
}
|
||||
|
||||
export class Event {
|
||||
constructor(type: string, options?: EventOptions)
|
||||
}
|
||||
|
||||
export interface CustomEventOptions<T = any> extends EventOptions {
|
||||
detail?: T
|
||||
}
|
||||
|
||||
export interface CustomEvent<T = any> extends Event {
|
||||
readonly detail: T
|
||||
}
|
||||
|
||||
export class CustomEvent<T = any> {
|
||||
constructor(type: string, options?: CustomEventOptions<T>)
|
||||
}
|
||||
|
||||
export interface AddEventListenerOptions {
|
||||
capture?: boolean
|
||||
passive?: boolean
|
||||
once?: boolean
|
||||
signal?: AbortSignal | null
|
||||
}
|
||||
|
||||
export interface RemoveEventListenerOptions {
|
||||
capture?: boolean
|
||||
}
|
||||
|
||||
export interface EventTarget {
|
||||
addEventListener(
|
||||
type: string,
|
||||
callback: EventListener,
|
||||
options?: AddEventListenerOptions | boolean
|
||||
): void
|
||||
|
||||
removeEventListener(
|
||||
type: string,
|
||||
callback: EventListener,
|
||||
options?: RemoveEventListenerOptions | boolean
|
||||
): void
|
||||
|
||||
dispatchEvent(event: Event): boolean
|
||||
}
|
||||
|
||||
export class EventTarget {
|
||||
constructor()
|
||||
}
|
||||
|
||||
export type EventListener = EventCallback | EventHandler
|
||||
|
||||
export interface EventCallback {
|
||||
(event: Event): void
|
||||
}
|
||||
|
||||
export interface EventHandler {
|
||||
handleEvent(event: Event): void
|
||||
}
|
||||
335
node_modules/bare-events/web.js
generated
vendored
Normal file
335
node_modules/bare-events/web.js
generated
vendored
Normal file
@@ -0,0 +1,335 @@
|
||||
// Event state
|
||||
const BUBBLES = 0x1
|
||||
const CANCELABLE = 0x2
|
||||
const COMPOSED = 0x4
|
||||
const CANCELED = 0x8
|
||||
const DISPATCH = 0x10
|
||||
const STOP = 0x20
|
||||
|
||||
// EventTarget state
|
||||
const CAPTURE = 0x1
|
||||
const PASSIVE = 0x2
|
||||
const ONCE = 0x4
|
||||
|
||||
// https://dom.spec.whatwg.org/#event
|
||||
class Event {
|
||||
// https://dom.spec.whatwg.org/#dom-event-event
|
||||
constructor(type, options = {}) {
|
||||
const { bubbles = false, cancelable = false, composed = false } = options
|
||||
|
||||
this._type = type
|
||||
this._target = null
|
||||
this._state = 0
|
||||
|
||||
if (bubbles) this._state |= BUBBLES
|
||||
if (cancelable) this._state |= CANCELABLE
|
||||
if (composed) this._state |= COMPOSED
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-type
|
||||
get type() {
|
||||
return this._type
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-target
|
||||
get target() {
|
||||
return this._target
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
||||
get currentTarget() {
|
||||
return null
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-bubbles
|
||||
get bubbles() {
|
||||
return (this._state & BUBBLES) !== 0
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-cancelable
|
||||
get cancelable() {
|
||||
return (this._state & CANCELABLE) !== 0
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-composed
|
||||
get composed() {
|
||||
return (this._state & COMPOSED) !== 0
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
||||
get defaultPrevented() {
|
||||
return (this._state & CANCELED) !== 0
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-istrusted
|
||||
get isTrusted() {
|
||||
return false
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-preventdefault
|
||||
preventDefault() {
|
||||
if (this._state & CANCELABLE) this._state |= CANCELED
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-stoppropagation
|
||||
stopPropagation() {}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
|
||||
stopImmediatePropagation() {
|
||||
this._state |= STOP
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
target: this.target,
|
||||
bubbles: this.bubbles,
|
||||
cancelable: this.cancelable,
|
||||
composed: this.composed,
|
||||
defaultPrevented: this.defaultPrevented,
|
||||
isTrusted: this.isTrusted
|
||||
}
|
||||
}
|
||||
|
||||
[Symbol.for('bare.inspect')]() {
|
||||
return {
|
||||
__proto__: { constructor: Event },
|
||||
|
||||
type: this.type,
|
||||
target: this.target,
|
||||
bubbles: this.bubbles,
|
||||
cancelable: this.cancelable,
|
||||
composed: this.composed,
|
||||
defaultPrevented: this.defaultPrevented,
|
||||
isTrusted: this.isTrusted
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.Event = Event
|
||||
|
||||
// https://dom.spec.whatwg.org/#customevent
|
||||
exports.CustomEvent = class CustomEvent extends Event {
|
||||
constructor(type, options = {}) {
|
||||
super(type, options)
|
||||
|
||||
const { detail = null } = options
|
||||
|
||||
this._detail = detail
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-customevent-detail
|
||||
get detail() {
|
||||
return this._detail
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#eventtarget
|
||||
exports.EventTarget = class EventTarget {
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-eventtarget
|
||||
constructor() {
|
||||
this._listeners = new Map()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
|
||||
addEventListener(type, callback = null, options = {}) {
|
||||
if (typeof options === 'boolean') options = { capture: options }
|
||||
|
||||
const { capture = false, passive = false, once = false, signal = null } = options
|
||||
|
||||
if (signal !== null && signal.aborted) return
|
||||
if (callback === null) return
|
||||
|
||||
const listener = new EventListener(type, callback, capture, passive, once, signal)
|
||||
|
||||
const listeners = this._listeners.get(type)
|
||||
|
||||
if (listeners === undefined) this._listeners.set(type, listener)
|
||||
else {
|
||||
for (const existing of listeners) {
|
||||
if (callback === existing.callback && capture === existing.capture) {
|
||||
return // Duplicate listener
|
||||
}
|
||||
}
|
||||
|
||||
listener.link(listeners)
|
||||
|
||||
if (signal !== null) {
|
||||
signal.addEventListener('abort', onabort)
|
||||
|
||||
function onabort() {
|
||||
listener.unlink()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
||||
removeEventListener(type, callback = null, options = {}) {
|
||||
if (typeof options === 'boolean') options = { capture: options }
|
||||
|
||||
const { capture = false } = options
|
||||
|
||||
const listeners = this._listeners.get(type)
|
||||
|
||||
if (listeners === undefined) return
|
||||
|
||||
for (const existing of listeners) {
|
||||
if (callback === existing.callback && capture === existing.capture) {
|
||||
const next = existing.unlink()
|
||||
|
||||
if (listeners === existing) this._listeners.set(type, next)
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
|
||||
dispatchEvent(event) {
|
||||
event._target = this
|
||||
event._state |= DISPATCH
|
||||
|
||||
const listeners = this._listeners.get(event.type)
|
||||
|
||||
try {
|
||||
if (listeners === undefined) return true
|
||||
|
||||
for (const listener of listeners) {
|
||||
// https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke
|
||||
|
||||
if (listener.once) listener.unlink()
|
||||
|
||||
let callback = listener.callback
|
||||
let context = this
|
||||
|
||||
if (typeof callback === 'object') {
|
||||
context = callback
|
||||
callback = callback.handleEvent
|
||||
}
|
||||
|
||||
Reflect.apply(callback, context, [event])
|
||||
|
||||
if (event._state & STOP) break
|
||||
}
|
||||
|
||||
return (event._state & CANCELED) === 0
|
||||
} finally {
|
||||
event._state &= ~DISPATCH
|
||||
event._state &= ~STOP
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {}
|
||||
}
|
||||
|
||||
[Symbol.for('bare.inspect')]() {
|
||||
return {
|
||||
__proto__: { constructor: EventTarget }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-listener
|
||||
class EventListener {
|
||||
constructor(type, callback, capture, passive, once, signal) {
|
||||
this._type = type
|
||||
this._callback = callback
|
||||
this._signal = signal
|
||||
this._state = 0
|
||||
|
||||
if (capture) this._state |= CAPTURE
|
||||
if (passive) this._state |= PASSIVE
|
||||
if (once) this._state |= ONCE
|
||||
|
||||
this._previous = this
|
||||
this._next = this
|
||||
}
|
||||
|
||||
get type() {
|
||||
return this._type
|
||||
}
|
||||
|
||||
get callback() {
|
||||
return this._callback
|
||||
}
|
||||
|
||||
get capture() {
|
||||
return (this._state & CAPTURE) !== 0
|
||||
}
|
||||
|
||||
get passive() {
|
||||
return (this._state & PASSIVE) !== 0
|
||||
}
|
||||
|
||||
get once() {
|
||||
return (this._state & ONCE) !== 0
|
||||
}
|
||||
|
||||
get removed() {
|
||||
return this._previous === this && this._next === this
|
||||
}
|
||||
|
||||
link(listener) {
|
||||
const next = this._next
|
||||
const previous = listener._previous
|
||||
|
||||
this._next = listener
|
||||
listener._previous = this
|
||||
|
||||
previous._next = next
|
||||
next._previous = previous
|
||||
|
||||
return listener
|
||||
}
|
||||
|
||||
unlink() {
|
||||
if (this.removed) return this
|
||||
|
||||
const next = this._next
|
||||
const previous = this._previous
|
||||
|
||||
this._next = this
|
||||
this._previous = this
|
||||
|
||||
previous._next = next
|
||||
next._previous = previous
|
||||
|
||||
return next
|
||||
}
|
||||
|
||||
*[Symbol.iterator]() {
|
||||
let current = this
|
||||
|
||||
while (true) {
|
||||
const next = current._next
|
||||
yield current
|
||||
if (next === this) break
|
||||
current = next
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
capture: this.capture,
|
||||
passive: this.passive,
|
||||
once: this.once,
|
||||
removed: this.removed
|
||||
}
|
||||
}
|
||||
|
||||
[Symbol.for('bare.inspect')]() {
|
||||
return {
|
||||
__proto__: { constructor: EventListener },
|
||||
|
||||
type: this.type,
|
||||
callback: this.callback,
|
||||
capture: this.capture,
|
||||
passive: this.passive,
|
||||
once: this.once,
|
||||
removed: this.removed
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user