module-develop-kit 1.2.4 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs-virtual-dir/_commonjsHelpers.js +3 -28
- package/dist/commonjs-virtual-dir/index2.js +5 -3
- package/dist/commonjs-virtual-dir/index3.js +3 -5
- package/dist/src/outside-call/utils.js +1 -1
- package/dist/src/shield/crypto/sm4.js +1 -1
- package/dist/src/vite-plugins/generateSriHash.js +26 -0
- package/dist/src/vite-plugins/vite-plugin-sri/config.js +8 -0
- package/dist/src/vite-plugins/vite-plugin-sri/index.js +128 -0
- package/dist/src/vite-plugins/vite-plugin-sri/internal.js +1172 -0
- package/dist/vendor/file-type/source/detectors/ebml.js +1 -1
- package/dist/vendor/file-type/source/detectors/zip.js +1 -1
- package/dist/vendor/file-type/source/index.js +1 -1
- package/dist/vendor/file-type/source/tokens.js +1 -1
- package/dist/vendor/gm-crypt/src/crypt.js +1 -1
- package/dist/vendor/jssip/lib-es5/Message.js +11 -11
- package/dist/vendor/jssip/lib-es5/Options.js +13 -13
- package/dist/vendor/jssip/lib-es5/RTCSession/DTMF.js +4 -4
- package/dist/vendor/jssip/lib-es5/RTCSession/Info.js +12 -12
- package/dist/vendor/jssip/lib-es5/RTCSession/ReferSubscriber.js +7 -7
- package/dist/vendor/jssip/lib-es5/RTCSession.js +2 -2
- package/dist/vendor/jssip/lib-es5/Transactions.js +15 -15
- package/dist/vendor/jssip/lib-es5/UA.js +5 -5
- package/dist/vendor/parse5/dist/common/doctype.js +98 -0
- package/dist/vendor/parse5/dist/common/error-codes.js +7 -0
- package/dist/vendor/parse5/dist/common/foreign-content.js +210 -0
- package/dist/vendor/parse5/dist/common/html.js +261 -0
- package/dist/vendor/parse5/dist/common/token.js +14 -0
- package/dist/vendor/parse5/dist/common/unicode.js +73 -0
- package/dist/vendor/parse5/dist/index.js +18 -0
- package/dist/vendor/parse5/dist/parser/formatting-element-list.js +84 -0
- package/dist/vendor/parse5/dist/parser/index.js +2271 -0
- package/dist/vendor/parse5/dist/parser/open-element-stack.js +240 -0
- package/dist/vendor/parse5/dist/serializer/index.js +85 -0
- package/dist/vendor/parse5/dist/tokenizer/index.js +1940 -0
- package/dist/vendor/parse5/dist/tokenizer/preprocessor.js +88 -0
- package/dist/vendor/parse5/dist/tree-adapters/default.js +162 -0
- package/dist/vendor/parse5/node_modules/entities/dist/decode-codepoint.js +37 -0
- package/dist/vendor/parse5/node_modules/entities/dist/decode.js +270 -0
- package/dist/vendor/parse5/node_modules/entities/dist/escape.js +22 -0
- package/dist/vendor/parse5/node_modules/entities/dist/generated/decode-data-html.js +5 -0
- package/dist/vendor/parse5/node_modules/entities/dist/internal/bin-trie-flags.js +7 -0
- package/dist/vendor/parse5/node_modules/entities/dist/internal/decode-shared.js +11 -0
- package/dist/vite-plugins/index.d.ts +161 -0
- package/dist/vite-plugins/index.js +14 -6
- package/package.json +2 -1
- package/dist/commonjs-virtual-dir/___vite-browser-external.js +0 -6
- package/dist/commonjs-virtual-dir/__vite-browser-external.js +0 -4
- package/dist/commonjs-virtual-dir/events.js +0 -4
- package/dist/vendor/events/events.js +0 -216
|
@@ -3,6 +3,79 @@ import { Options } from '@vitejs/plugin-legacy';
|
|
|
3
3
|
import { Plugin as Plugin_2 } from 'vite';
|
|
4
4
|
import { PluginOption } from 'vite';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Builds the self-contained runtime statement that is prepended to entry
|
|
8
|
+
* chunks. The runtime is shipped by serializing `installSriRuntime` with
|
|
9
|
+
* `.toString()` and embedding the source into the consumer's bundle.
|
|
10
|
+
*
|
|
11
|
+
* The plugin itself is bundled with esbuild (via tsup), whose `keepNames`
|
|
12
|
+
* transform can wrap named function expressions in a module-scoped
|
|
13
|
+
* `__name(fn, "name")` helper. That helper lives at the top of the plugin's
|
|
14
|
+
* own output — NOT inside the serialized function — so the injected copy
|
|
15
|
+
* references an `__name` that is undefined in the consumer bundle. Because the
|
|
16
|
+
* runtime guards its setup in a best-effort `try/catch`, the resulting
|
|
17
|
+
* `ReferenceError: __name is not defined` is swallowed and
|
|
18
|
+
* `globalThis.__sriImport` is never installed; every rewritten dynamic import
|
|
19
|
+
* then fails with "`__sriImport` is not defined" (issue #30).
|
|
20
|
+
*
|
|
21
|
+
* To keep the injected runtime correct regardless of how the plugin is
|
|
22
|
+
* bundled, the serialized function is evaluated inside a wrapper that defines a
|
|
23
|
+
* local `__name` shim in its lexical scope. `__name` only needs to return its
|
|
24
|
+
* first argument; the function-name assignment it performs is cosmetic.
|
|
25
|
+
*
|
|
26
|
+
* `opts.base` is the resolved Vite `base` (defaults to "/"). It is forwarded
|
|
27
|
+
* to the runtime so integrity lookups can strip the base prefix from URLs
|
|
28
|
+
* observed at runtime — the integrity map keys are '/'-rooted bundle file
|
|
29
|
+
* names that never include the base.
|
|
30
|
+
*
|
|
31
|
+
* @param runtime - Either the runtime function (serialized here via
|
|
32
|
+
* `.toString()`) or already-serialized source. The plugin passes source that
|
|
33
|
+
* has been through `minifyRuntimeSource` first, which is why this accepts a
|
|
34
|
+
* string; passing the function directly yields the unminified form.
|
|
35
|
+
* @returns The complete statement to prepend to an entry chunk.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildSriRuntimeCode(runtime: ((sriByPathname: Record<string, string>, opts?: Record<string, unknown>) => void) | string, sriByPathname: Record<string, string>, opts: {
|
|
38
|
+
crossorigin: "anonymous" | "use-credentials" | undefined;
|
|
39
|
+
skipResources: string[];
|
|
40
|
+
enforceDynamicImports: boolean;
|
|
41
|
+
base?: string;
|
|
42
|
+
}): string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 为文件内容生成 SRI hash
|
|
46
|
+
* @param content 文件内容(字符串或 Buffer)
|
|
47
|
+
* @param algorithm 哈希算法,默认 sha384
|
|
48
|
+
* @returns SRI hash 字符串,如 "sha384-xxx"
|
|
49
|
+
*/
|
|
50
|
+
export declare function generateSriHash(content: string | Buffer, algorithm?: SriAlgorithm): string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 为本地文件生成 SRI hash
|
|
54
|
+
* @param filePath 文件路径(相对或绝对)
|
|
55
|
+
* @param algorithm 哈希算法,默认 sha384
|
|
56
|
+
* @returns SRI hash 字符串,如 "sha384-xxx"
|
|
57
|
+
*/
|
|
58
|
+
export declare function generateSriHashFromFile(filePath: string, algorithm?: SriAlgorithm): Promise<string>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 为多个文件生成 SRI hash 映射
|
|
62
|
+
* @param files 文件路径数组或映射对象
|
|
63
|
+
* @param algorithm 哈希算法,默认 sha384
|
|
64
|
+
* @returns SRI hash 映射对象
|
|
65
|
+
* @example
|
|
66
|
+
* // 传入数组
|
|
67
|
+
* await generateSriHashMap(['dist/app.js', 'dist/vendor.js'])
|
|
68
|
+
* // 返回: { 'dist/app.js': 'sha384-xxx', 'dist/vendor.js': 'sha384-yyy' }
|
|
69
|
+
*
|
|
70
|
+
* // 传入映射对象(key 为最终使用的路径)
|
|
71
|
+
* await generateSriHashMap({
|
|
72
|
+
* '/assets/app-123.js': 'dist/app.js',
|
|
73
|
+
* '*legacy-polyfills*.js': 'dist/legacy-polyfills.js'
|
|
74
|
+
* })
|
|
75
|
+
* // 返回: { '/assets/app-123.js': 'sha384-xxx', '*legacy-polyfills*.js': 'sha384-yyy' }
|
|
76
|
+
*/
|
|
77
|
+
export declare function generateSriHashMap(files: string[] | Record<string, string>, algorithm?: SriAlgorithm): Promise<Record<string, string>>;
|
|
78
|
+
|
|
6
79
|
/**
|
|
7
80
|
* 获取legacy/兼容性检测相关插件
|
|
8
81
|
* @param options
|
|
@@ -34,6 +107,85 @@ export declare interface IVitePluginLegacyOptions extends Options {
|
|
|
34
107
|
detectionConfig?: IVitePluginCompatibilityDetectionOptions;
|
|
35
108
|
}
|
|
36
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Rewrites every dynamic `import(...)` call expression in a chunk to
|
|
112
|
+
* `__sriImport(import.meta.url, ...)` so the runtime-injected JS-level
|
|
113
|
+
* verifier can enforce integrity before executing the module. The original
|
|
114
|
+
* `import(` syntax inside the runtime itself is preserved because the runtime
|
|
115
|
+
* is concatenated AFTER this rewrite step.
|
|
116
|
+
*
|
|
117
|
+
* `import.meta.url` is threaded through as the first argument because native
|
|
118
|
+
* `import()` resolves relative specifiers against the IMPORTING MODULE's URL,
|
|
119
|
+
* not the document URL. Rollup emits inter-chunk dynamic imports as
|
|
120
|
+
* module-relative specifiers (e.g. `import('./asset.js')` from a chunk in
|
|
121
|
+
* `assets/js/`), so without the importer's URL the runtime would resolve the
|
|
122
|
+
* specifier against `location.href` and look up the wrong pathname
|
|
123
|
+
* (issue #32). The injected `import.meta.url` text is never re-matched by the
|
|
124
|
+
* rewrite regex: `import` there is followed by `.`, not `(`.
|
|
125
|
+
*/
|
|
126
|
+
export declare function rewriteDynamicImports(code: string): string;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 支持的 SRI 算法
|
|
130
|
+
*/
|
|
131
|
+
export declare type SriAlgorithm = "sha256" | "sha384" | "sha512";
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Configuration options for the SRI plugin.
|
|
135
|
+
* Defines all available settings for customizing SRI generation behavior.
|
|
136
|
+
*/
|
|
137
|
+
export declare interface SriPluginOptions {
|
|
138
|
+
/** The hashing algorithm to use for generating SRI hashes. */
|
|
139
|
+
algorithm?: "sha256" | "sha384" | "sha512";
|
|
140
|
+
/** The CORS setting to use for fetched scripts and styles. */
|
|
141
|
+
crossorigin?: "anonymous" | "use-credentials";
|
|
142
|
+
/** Enable in-memory caching for remote fetches. Default: true */
|
|
143
|
+
fetchCache?: boolean;
|
|
144
|
+
/** Abort remote fetches after the given milliseconds. Default: 5000 (0 disables). */
|
|
145
|
+
fetchTimeoutMs?: number;
|
|
146
|
+
/** Add rel="modulepreload" with integrity for discovered dynamic chunks. Default: true */
|
|
147
|
+
preloadDynamicChunks?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Deliver module-graph integrity via an inline `<script type="importmap">`.
|
|
150
|
+
* Default: true.
|
|
151
|
+
*
|
|
152
|
+
* Import maps must be inline — the HTML spec forbids `src` on
|
|
153
|
+
* `<script type="importmap">` — so a `script-src` without `'unsafe-inline'`,
|
|
154
|
+
* a matching hash, or a nonce will block the map. A blocked map delivers no
|
|
155
|
+
* integrity, silently.
|
|
156
|
+
*
|
|
157
|
+
* Set to false for strict-CSP deployments: no inline script is emitted, and
|
|
158
|
+
* the same hashes are delivered as `<link rel="modulepreload" integrity>`
|
|
159
|
+
* instead, which needs no CSP cooperation. Coverage is preserved — the
|
|
160
|
+
* preload set widens to the full module graph so chunks reached only by a
|
|
161
|
+
* static import inside a lazy chunk stay verified. Those chunks are then
|
|
162
|
+
* fetched eagerly rather than on demand.
|
|
163
|
+
*
|
|
164
|
+
* Requires `preloadDynamicChunks` (the default) to remain enabled — that is
|
|
165
|
+
* the channel the hashes move to. With both off, chunks reached only by a
|
|
166
|
+
* static import inside a lazy chunk have no channel at all and the build
|
|
167
|
+
* warns.
|
|
168
|
+
*
|
|
169
|
+
* The widened set is bundle-wide, not per page, so in a multi-page build
|
|
170
|
+
* every HTML file preloads every module-graph chunk, including chunks
|
|
171
|
+
* private to other pages.
|
|
172
|
+
*/
|
|
173
|
+
importMapIntegrity?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Inject a tiny runtime that sets integrity on dynamically inserted
|
|
176
|
+
* <script>/<link>. Default: true.
|
|
177
|
+
*
|
|
178
|
+
* The runtime is minified before injection, independently of how the rest of
|
|
179
|
+
* the bundle is built, because it is added after the minification stage runs.
|
|
180
|
+
* Setting Vite's `build.minify: false` opts it out along with everything else.
|
|
181
|
+
*/
|
|
182
|
+
runtimePatchDynamicLinks?: boolean;
|
|
183
|
+
/** Skip SRI generation for resources matching these patterns. Supports exact matches and simple glob patterns with '*'. */
|
|
184
|
+
skipResources?: string[];
|
|
185
|
+
/** Enable verbose build logging. When false (default), only warnings, errors, and a completion summary are shown. */
|
|
186
|
+
verboseLogging?: boolean;
|
|
187
|
+
}
|
|
188
|
+
|
|
37
189
|
/**
|
|
38
190
|
* 兼容性检测
|
|
39
191
|
* @param options 可以选择自定义插入内容
|
|
@@ -42,4 +194,13 @@ export declare const vitePluginCompatibilityDetection: (options?: IVitePluginCom
|
|
|
42
194
|
|
|
43
195
|
export declare const vitePluginRouterRandomParams: () => Plugin_2;
|
|
44
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Vite plugin to add Subresource Integrity (SRI) attributes to external assets in index.html
|
|
199
|
+
* ESM-only, requires Node 18+ (uses global fetch)
|
|
200
|
+
*
|
|
201
|
+
* @param options - Configuration options for the plugin
|
|
202
|
+
* @returns Vite plugin with SRI processing capabilities
|
|
203
|
+
*/
|
|
204
|
+
export declare function vitePluginSri(options?: SriPluginOptions): PluginOption;
|
|
205
|
+
|
|
45
206
|
export { }
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { generateSriHash as r, generateSriHashFromFile as t, generateSriHashMap as o } from "../src/vite-plugins/generateSriHash.js";
|
|
2
|
+
import { getCompatibilityPlugins as m } from "../src/vite-plugins/getCompatibilityPlugins.js";
|
|
3
|
+
import { buildSriRuntimeCode as p, rewriteDynamicImports as g, vitePluginSri as l } from "../src/vite-plugins/vite-plugin-sri/index.js";
|
|
4
|
+
import { vitePluginCompatibilityDetection as s } from "../src/vite-plugins/vitePluginCompatibilityDetection.js";
|
|
5
|
+
import { vitePluginRouterRandomParams as x } from "../src/vite-plugins/vitePluginRouterRandomParams.js";
|
|
4
6
|
export {
|
|
5
|
-
|
|
6
|
-
r as
|
|
7
|
-
|
|
7
|
+
p as buildSriRuntimeCode,
|
|
8
|
+
r as generateSriHash,
|
|
9
|
+
t as generateSriHashFromFile,
|
|
10
|
+
o as generateSriHashMap,
|
|
11
|
+
m as getCompatibilityPlugins,
|
|
12
|
+
g as rewriteDynamicImports,
|
|
13
|
+
s as vitePluginCompatibilityDetection,
|
|
14
|
+
x as vitePluginRouterRandomParams,
|
|
15
|
+
l as vitePluginSri
|
|
8
16
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "module-develop-kit",
|
|
3
3
|
"author": "Front-End team",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "前端项目通用工具包",
|
|
7
7
|
"module": "dist/main.js",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"cross-env": "^10.0.0",
|
|
49
49
|
"eslint": "^9.35.0",
|
|
50
50
|
"jsdom": "^27.0.0",
|
|
51
|
+
"parse5": "^8.0.1",
|
|
51
52
|
"prettier": "^3.6.2",
|
|
52
53
|
"sdp-transform": "^2.15.0",
|
|
53
54
|
"terser": "^5.44.0",
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { __module as p } from "../../commonjs-virtual-dir/events.js";
|
|
2
|
-
var x;
|
|
3
|
-
function F() {
|
|
4
|
-
if (x) return p.exports;
|
|
5
|
-
x = 1;
|
|
6
|
-
var a = typeof Reflect == "object" ? Reflect : null, d = a && typeof a.apply == "function" ? a.apply : function(e, n, r) {
|
|
7
|
-
return Function.prototype.apply.call(e, n, r);
|
|
8
|
-
}, l;
|
|
9
|
-
a && typeof a.ownKeys == "function" ? l = a.ownKeys : Object.getOwnPropertySymbols ? l = function(e) {
|
|
10
|
-
return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
|
|
11
|
-
} : l = function(e) {
|
|
12
|
-
return Object.getOwnPropertyNames(e);
|
|
13
|
-
};
|
|
14
|
-
function C(t) {
|
|
15
|
-
console && console.warn && console.warn(t);
|
|
16
|
-
}
|
|
17
|
-
var h = Number.isNaN || function(e) {
|
|
18
|
-
return e !== e;
|
|
19
|
-
};
|
|
20
|
-
function o() {
|
|
21
|
-
o.init.call(this);
|
|
22
|
-
}
|
|
23
|
-
p.exports = o, p.exports.once = M, o.EventEmitter = o, o.prototype._events = void 0, o.prototype._eventsCount = 0, o.prototype._maxListeners = void 0;
|
|
24
|
-
var m = 10;
|
|
25
|
-
function v(t) {
|
|
26
|
-
if (typeof t != "function")
|
|
27
|
-
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof t);
|
|
28
|
-
}
|
|
29
|
-
Object.defineProperty(o, "defaultMaxListeners", {
|
|
30
|
-
enumerable: !0,
|
|
31
|
-
get: function() {
|
|
32
|
-
return m;
|
|
33
|
-
},
|
|
34
|
-
set: function(t) {
|
|
35
|
-
if (typeof t != "number" || t < 0 || h(t))
|
|
36
|
-
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + t + ".");
|
|
37
|
-
m = t;
|
|
38
|
-
}
|
|
39
|
-
}), o.init = function() {
|
|
40
|
-
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
41
|
-
}, o.prototype.setMaxListeners = function(e) {
|
|
42
|
-
if (typeof e != "number" || e < 0 || h(e))
|
|
43
|
-
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + e + ".");
|
|
44
|
-
return this._maxListeners = e, this;
|
|
45
|
-
};
|
|
46
|
-
function L(t) {
|
|
47
|
-
return t._maxListeners === void 0 ? o.defaultMaxListeners : t._maxListeners;
|
|
48
|
-
}
|
|
49
|
-
o.prototype.getMaxListeners = function() {
|
|
50
|
-
return L(this);
|
|
51
|
-
}, o.prototype.emit = function(e) {
|
|
52
|
-
for (var n = [], r = 1; r < arguments.length; r++) n.push(arguments[r]);
|
|
53
|
-
var i = e === "error", f = this._events;
|
|
54
|
-
if (f !== void 0)
|
|
55
|
-
i = i && f.error === void 0;
|
|
56
|
-
else if (!i)
|
|
57
|
-
return !1;
|
|
58
|
-
if (i) {
|
|
59
|
-
var s;
|
|
60
|
-
if (n.length > 0 && (s = n[0]), s instanceof Error)
|
|
61
|
-
throw s;
|
|
62
|
-
var u = new Error("Unhandled error." + (s ? " (" + s.message + ")" : ""));
|
|
63
|
-
throw u.context = s, u;
|
|
64
|
-
}
|
|
65
|
-
var c = f[e];
|
|
66
|
-
if (c === void 0)
|
|
67
|
-
return !1;
|
|
68
|
-
if (typeof c == "function")
|
|
69
|
-
d(c, this, n);
|
|
70
|
-
else
|
|
71
|
-
for (var O = c.length, P = b(c, O), r = 0; r < O; ++r)
|
|
72
|
-
d(P[r], this, n);
|
|
73
|
-
return !0;
|
|
74
|
-
};
|
|
75
|
-
function y(t, e, n, r) {
|
|
76
|
-
var i, f, s;
|
|
77
|
-
if (v(n), f = t._events, f === void 0 ? (f = t._events = /* @__PURE__ */ Object.create(null), t._eventsCount = 0) : (f.newListener !== void 0 && (t.emit(
|
|
78
|
-
"newListener",
|
|
79
|
-
e,
|
|
80
|
-
n.listener ? n.listener : n
|
|
81
|
-
), f = t._events), s = f[e]), s === void 0)
|
|
82
|
-
s = f[e] = n, ++t._eventsCount;
|
|
83
|
-
else if (typeof s == "function" ? s = f[e] = r ? [n, s] : [s, n] : r ? s.unshift(n) : s.push(n), i = L(t), i > 0 && s.length > i && !s.warned) {
|
|
84
|
-
s.warned = !0;
|
|
85
|
-
var u = new Error("Possible EventEmitter memory leak detected. " + s.length + " " + String(e) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
86
|
-
u.name = "MaxListenersExceededWarning", u.emitter = t, u.type = e, u.count = s.length, C(u);
|
|
87
|
-
}
|
|
88
|
-
return t;
|
|
89
|
-
}
|
|
90
|
-
o.prototype.addListener = function(e, n) {
|
|
91
|
-
return y(this, e, n, !1);
|
|
92
|
-
}, o.prototype.on = o.prototype.addListener, o.prototype.prependListener = function(e, n) {
|
|
93
|
-
return y(this, e, n, !0);
|
|
94
|
-
};
|
|
95
|
-
function R() {
|
|
96
|
-
if (!this.fired)
|
|
97
|
-
return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
98
|
-
}
|
|
99
|
-
function g(t, e, n) {
|
|
100
|
-
var r = { fired: !1, wrapFn: void 0, target: t, type: e, listener: n }, i = R.bind(r);
|
|
101
|
-
return i.listener = n, r.wrapFn = i, i;
|
|
102
|
-
}
|
|
103
|
-
o.prototype.once = function(e, n) {
|
|
104
|
-
return v(n), this.on(e, g(this, e, n)), this;
|
|
105
|
-
}, o.prototype.prependOnceListener = function(e, n) {
|
|
106
|
-
return v(n), this.prependListener(e, g(this, e, n)), this;
|
|
107
|
-
}, o.prototype.removeListener = function(e, n) {
|
|
108
|
-
var r, i, f, s, u;
|
|
109
|
-
if (v(n), i = this._events, i === void 0)
|
|
110
|
-
return this;
|
|
111
|
-
if (r = i[e], r === void 0)
|
|
112
|
-
return this;
|
|
113
|
-
if (r === n || r.listener === n)
|
|
114
|
-
--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete i[e], i.removeListener && this.emit("removeListener", e, r.listener || n));
|
|
115
|
-
else if (typeof r != "function") {
|
|
116
|
-
for (f = -1, s = r.length - 1; s >= 0; s--)
|
|
117
|
-
if (r[s] === n || r[s].listener === n) {
|
|
118
|
-
u = r[s].listener, f = s;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
if (f < 0)
|
|
122
|
-
return this;
|
|
123
|
-
f === 0 ? r.shift() : j(r, f), r.length === 1 && (i[e] = r[0]), i.removeListener !== void 0 && this.emit("removeListener", e, u || n);
|
|
124
|
-
}
|
|
125
|
-
return this;
|
|
126
|
-
}, o.prototype.off = o.prototype.removeListener, o.prototype.removeAllListeners = function(e) {
|
|
127
|
-
var n, r, i;
|
|
128
|
-
if (r = this._events, r === void 0)
|
|
129
|
-
return this;
|
|
130
|
-
if (r.removeListener === void 0)
|
|
131
|
-
return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : r[e] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete r[e]), this;
|
|
132
|
-
if (arguments.length === 0) {
|
|
133
|
-
var f = Object.keys(r), s;
|
|
134
|
-
for (i = 0; i < f.length; ++i)
|
|
135
|
-
s = f[i], s !== "removeListener" && this.removeAllListeners(s);
|
|
136
|
-
return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
|
|
137
|
-
}
|
|
138
|
-
if (n = r[e], typeof n == "function")
|
|
139
|
-
this.removeListener(e, n);
|
|
140
|
-
else if (n !== void 0)
|
|
141
|
-
for (i = n.length - 1; i >= 0; i--)
|
|
142
|
-
this.removeListener(e, n[i]);
|
|
143
|
-
return this;
|
|
144
|
-
};
|
|
145
|
-
function _(t, e, n) {
|
|
146
|
-
var r = t._events;
|
|
147
|
-
if (r === void 0)
|
|
148
|
-
return [];
|
|
149
|
-
var i = r[e];
|
|
150
|
-
return i === void 0 ? [] : typeof i == "function" ? n ? [i.listener || i] : [i] : n ? N(i) : b(i, i.length);
|
|
151
|
-
}
|
|
152
|
-
o.prototype.listeners = function(e) {
|
|
153
|
-
return _(this, e, !0);
|
|
154
|
-
}, o.prototype.rawListeners = function(e) {
|
|
155
|
-
return _(this, e, !1);
|
|
156
|
-
}, o.listenerCount = function(t, e) {
|
|
157
|
-
return typeof t.listenerCount == "function" ? t.listenerCount(e) : w.call(t, e);
|
|
158
|
-
}, o.prototype.listenerCount = w;
|
|
159
|
-
function w(t) {
|
|
160
|
-
var e = this._events;
|
|
161
|
-
if (e !== void 0) {
|
|
162
|
-
var n = e[t];
|
|
163
|
-
if (typeof n == "function")
|
|
164
|
-
return 1;
|
|
165
|
-
if (n !== void 0)
|
|
166
|
-
return n.length;
|
|
167
|
-
}
|
|
168
|
-
return 0;
|
|
169
|
-
}
|
|
170
|
-
o.prototype.eventNames = function() {
|
|
171
|
-
return this._eventsCount > 0 ? l(this._events) : [];
|
|
172
|
-
};
|
|
173
|
-
function b(t, e) {
|
|
174
|
-
for (var n = new Array(e), r = 0; r < e; ++r)
|
|
175
|
-
n[r] = t[r];
|
|
176
|
-
return n;
|
|
177
|
-
}
|
|
178
|
-
function j(t, e) {
|
|
179
|
-
for (; e + 1 < t.length; e++)
|
|
180
|
-
t[e] = t[e + 1];
|
|
181
|
-
t.pop();
|
|
182
|
-
}
|
|
183
|
-
function N(t) {
|
|
184
|
-
for (var e = new Array(t.length), n = 0; n < e.length; ++n)
|
|
185
|
-
e[n] = t[n].listener || t[n];
|
|
186
|
-
return e;
|
|
187
|
-
}
|
|
188
|
-
function M(t, e) {
|
|
189
|
-
return new Promise(function(n, r) {
|
|
190
|
-
function i(s) {
|
|
191
|
-
t.removeListener(e, f), r(s);
|
|
192
|
-
}
|
|
193
|
-
function f() {
|
|
194
|
-
typeof t.removeListener == "function" && t.removeListener("error", i), n([].slice.call(arguments));
|
|
195
|
-
}
|
|
196
|
-
E(t, e, f, { once: !0 }), e !== "error" && A(t, i, { once: !0 });
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
function A(t, e, n) {
|
|
200
|
-
typeof t.on == "function" && E(t, "error", e, n);
|
|
201
|
-
}
|
|
202
|
-
function E(t, e, n, r) {
|
|
203
|
-
if (typeof t.on == "function")
|
|
204
|
-
r.once ? t.once(e, n) : t.on(e, n);
|
|
205
|
-
else if (typeof t.addEventListener == "function")
|
|
206
|
-
t.addEventListener(e, function i(f) {
|
|
207
|
-
r.once && t.removeEventListener(e, i), n(f);
|
|
208
|
-
});
|
|
209
|
-
else
|
|
210
|
-
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof t);
|
|
211
|
-
}
|
|
212
|
-
return p.exports;
|
|
213
|
-
}
|
|
214
|
-
export {
|
|
215
|
-
F as __require
|
|
216
|
-
};
|