plugin-tls 5.3.0 → 5.5.0
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/createTierModeOptionsPluginHost-B8wx-Fm2.cjs +1 -0
- package/dist/{createTierModeOptionsPluginHost-DWMl3oQA.js → createTierModeOptionsPluginHost-Ctr7S9XZ.js} +133 -110
- package/dist/index-node.cjs +1 -1
- package/dist/index-node.js +4 -4
- package/dist/index-web.cjs +1 -1
- package/dist/index-web.js +50 -50
- package/dist/index.cjs +1 -1
- package/dist/index.js +154 -121
- package/dist/options/options-manager/ModeOptions.d.ts +1 -1
- package/dist/options/options-manager/ModeOptions.d.ts.map +1 -1
- package/dist/options/options-manager/OptionsManager.d.ts +36 -0
- package/dist/options/options-manager/OptionsManager.d.ts.map +1 -1
- package/dist/options/options-manager/TierModeOptions.d.ts +1 -1
- package/dist/options/options-manager/TierModeOptions.d.ts.map +1 -1
- package/dist/options/options-manager/tools.d.ts +22 -0
- package/dist/options/options-manager/tools.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/createTierModeOptionsPluginHost.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/createTierModeOptionsPluginHost.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-options/createTierOptionsPluginHost.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-options/createTierOptionsPluginHost.d.ts.map +1 -1
- package/dist/options/plugins/tier-mode-options/decorator.d.ts.map +1 -1
- package/dist/options/plugins/tier-mode-options/plugin.d.ts.map +1 -1
- package/dist/options/plugins/tier-mode-options/type.d.ts +5 -0
- package/dist/options/plugins/tier-mode-options/type.d.ts.map +1 -1
- package/dist/options/plugins/tier-options/decorator.d.ts +2 -1
- package/dist/options/plugins/tier-options/decorator.d.ts.map +1 -1
- package/dist/options/plugins/tier-options/plugin.d.ts.map +1 -1
- package/dist/options/plugins/tier-options/type.d.ts +13 -8
- package/dist/options/plugins/tier-options/type.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/createTierModeOptionsPluginHost-C-if5dn9.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const M=require("@gby/destroyable"),b=require("deepmerge-ts"),O=require("type-tls"),h=require("com-tools");function a(i,...e){for(const t of e){const n=Object.getOwnPropertyDescriptors(t);Object.defineProperties(i,n)}return i}function V(i,e,t){let n=Object.getOwnPropertyDescriptors(e);return t&&h.omitMembers(n,t),Object.defineProperties(i,n),i}function v(i,e,t){let n=Object.getOwnPropertyDescriptors(e);return t?Object.defineProperties(i,h.removeUndefined(h.pickMembers(n,t))):Object.defineProperties(i,n),i}function N(i,e){return e}function H(i){return function(t){return t}}function k(i,e){return a(i,e),e}function C(i){return function(t){return a(i,t),t}}function S(i,e){return a(i,e),i}function j(i){return function(t){return a(i,t),i}}const T=["onCreate","onInit","onDestroy"];function A(i){const e={...i};for(const t of T)typeof e[t]=="function"&&delete e[t];return e}function U(i,e){let t=Object.getOwnPropertyDescriptors(e);for(const n of T)typeof e[n]=="function"&&delete t[n];return Object.defineProperties(i,t),i}function B(i,e){return e}function R(i){return function(t){return t}}function q(i,e){return a(i.prototype,e),e}function z(i){return function(t){return a(i.prototype,t),t}}function K(i,e){return a(i.prototype,e),i}function $(i){return function(t){return a(i.prototype,t),i}}function w(i){return i&&typeof i.onUse=="function"}const c=Symbol("extend");class g extends M.Destroyable{parent;host;plugins=new Map;constructor(e,t){super(),this.parent=t,e&&(this.host=e)}destroyThis(){return this.plugins.clear(),this.host=null,super.destroyThis()}hasUsed(e){return this.parent?.hasUsed(e)||this.plugins.has(e)}getUseReturn(e){const{parent:t}=this;return t?.hasUsed(e)?t.getUseReturn(e):this.plugins.get(e)}isPlugin(e){return this.hasUsed(e)?this.getUseReturn(e)!==c:w(e)}useExtend(e){return this.hasUsed(e)||(U(this.host.prototype,e),this.plugins.set(e,c)),e}instUseExtend(e,t,...n){return this.hasUsed(t)||(this.useExtend(t),t.onCreate?.call(e,e,...n)),t}usePlugin(e,...t){if(this.hasUsed(e))return this.getUseReturn(e);const n=e.onUse(this.host,...t);return this.plugins.set(e,n),n}instUsePlugin(e,t,...n){if(this.hasUsed(t))return this.getUseReturn(t);const s=this.usePlugin(t,...n);return t.onCreate?.(e),s}onCreate(e,...t){const n=this.parent?.onCreate(e,...t),s=[];for(const[r,o]of this.plugins)if(r.onCreate){const d=o===c?r.onCreate:r.onCreate.bind(r);s.push(d)}return O.waitAsyncable(n,()=>h.serialCallFuns(s,e,[e,...t]))}onInit(e,...t){const n=this.parent?.onInit(e,...t),s=[];for(const[r,o]of this.plugins)if(r.onInit){const d=o===c?r.onInit:r.onInit.bind(r);s.push(d)}return O.waitAsyncable(n,()=>h.serialCallFuns(s,e,[e,...t]))}onDestroy(e){const t=[];for(const[r,o]of this.plugins)if(r.onDestroy){const d=o===c?r.onDestroy:r.onDestroy.bind(r);t.push(d)}t.reverse();const n=h.serialCallFuns(t,e,[e]),{parent:s}=this;return s?O.waitAsyncable(n,()=>s.onDestroy(e)):n}}const F=b.deepmergeIntoCustom({mergeArrays:!1,mergeSets:!1}),D=b.deepmergeCustom({mergeArrays:!1,mergeSets:!1});function x(i){const e=i.split(".");return e[0]===""&&e.shift(),e}function f(i,e){for(const t of e)if(i=i[t],i==null)return;return i}function L(i,e){return f(i,x(e))}function y(i,e,t){const n=e.pop(),s=e.length;let r=0;for(;r<s;){const o=i[e[r]];if(o==null)break;i=o,r++}e=e.slice(r);for(const o of e)i=i[o]={};return i[n]=t,i}function G(i,e,t){return y(i,x(e),t)}const m={UndefinedAndNull:function(e){return e==null},Undefined:function(e){return e===void 0},Null:function(e){return e===null}};class E{static deepmergeInto=F;static deepmerge=D;get deepmergeInto(){return this.constructor.deepmergeInto}get deepmerge(){return this.constructor.deepmerge}freezeMember=!0;fullOption=new Proxy(this,{get:function(e,t,n){const s=e.plainFullOption[t];return e.freezeMember?Object.freeze(s):s},set:function(e,t,n,s){return e.setMember(t,n,!1),!0},has:function(e,t){return t in e.plainFullOption},getOwnPropertyDescriptor:function(e,t){return Object.getOwnPropertyDescriptor(e.plainFullOption,t)},ownKeys:function(e){return Reflect.ownKeys(e.plainFullOption)},deleteProperty:function(e,t){return e.setMember(t,void 0),!0},defineProperty:function(e,t,n){return Object.defineProperty(e.option,t,n),!0}});setOption(e,t){const n=t?this.deepmergeInto(this.option,e):Object.assign(this.option,e);return this.updateFullOption(),n}get undefinedValue(){return this._undefinedValue}set undefinedValue(e){this._undefinedValue=e,this.isUndefined=m[e]||m.UndefinedAndNull}_undefinedValue="UndefinedAndNull";isUndefined=m.UndefinedAndNull;getMember(e){return this.option[e]}setMember(e,t,n){const s=this.option;if(t===void 0)delete s[e];else{const r=s[e];n&&r&&typeof r=="object"?this.deepmergeInto(r,t):s[e]=t}this.updateFullOption()}getValue(e){return f(this.option,e)}setValue(e,t,n){const s=this.option;let r;n&&(r=f(s,e))&&typeof r=="object"?this.deepmergeInto(r,t):y(this.option,e,t),this.updateFullOption()}}class u extends E{constructor(e,t){super(),e&&(this.option=e),t&&(this.extends=t)}get extends(){return this._extends}set extends(e){this._extends=e,this.updateFullOption()}_extends=null;option={};get plainFullOption(){let e=this._plainFullOption;if(e)return e;const{extends:t,option:n}=this;if(e=n,t){const s=t.plainFullOption;e=this.deepmerge(s,n)}return this._plainFullOption=e}_plainFullOption=null;updateFullOption(){this._plainFullOption=null}getMember(e){const t=this.option[e];if(!this.isUndefined(t))return t;const n=this.extends;if(n)return n.getMember(e)}getValue(e){const t=super.getValue(e);if(!this.isUndefined(t))return t;const n=this.extends;if(n)return n.getValue(e)}}function J(i,e){const{name:t}=e,n=`_${t}`;return{get:function(){return this[n]||(this[n]=new u(void 0,this.constructor[t]))}}}class I extends E{constructor(e,t){super(),t&&this.setModeOption(e,t),this.mode=e}modes={};get mode(){return this._mode||(this.mode=this.modeNames[0])}set mode(e){this._mode=e,this.hasMode(e)||this.setModeOption(e,{}),this.updateFullOption()}_mode;get modeNames(){return this._modeNames||(this._modeNames=this.getModeNames())}_modeNames=null;getModeNames(){return Object.keys(this.modes)}hasMode(e){return!!this.modes[e]}get optionManager(){return this.modes[this.mode]}get option(){return this.optionManager.option}get plainFullOption(){return this._plainFullOption??(this._plainFullOption=this.getFullModeOption(this.mode))}_plainFullOption=null;updateFullOption(){this._plainFullOption=null,this._modeNames=null}getModeOption(e){return this.modes[e].option}getFullModeOption(e){return this.modes[e]?.plainFullOption}setModeOption(e,t,n,s){const{modes:r}=this,o=r[e]||(r[e]=new u);if(o.setOption(t,n),s){const d=r[s];d&&(o.extends=d)}return this.updateFullOption(),o}}class l extends I{constructor(e,t,n){super(e,t),n&&(this.extends=n)}get extends(){return this._extends}set extends(e){this._extends=e,this.updateFullOption()}_extends=null;getFullModeOption(e){const{modes:t,extends:n}=this,s=t[e]?.plainFullOption;if(n){const r=n.getFullModeOption(e);return s?this.deepmerge(r,s):r}return s}getModeNames(){const{modes:e,extends:t}=this,n=Object.keys(e);if(!t)return n;const s=t.getModeNames();return[...new Set([...n,...s])]}hasModeOnTier(e){if(this.hasMode(e))return!0;const t=this.extends;return t?t.hasModeOnTier(e):!1}get optionManager(){return this.getModeOptionManager(this.mode)}getModeOptionManager(e){const t=this.modes[e];return t||(this.extends?.getModeOptionManager(e)?this.setModeOption(e,{}):null)}getMember(e){const t=this.optionManager.getMember(e);if(!this.isUndefined(t))return t;const n=this.extends;if(n)return n.getMember(e)}getValue(e){const t=this.optionManager.getValue(e);if(!this.isUndefined(t))return t;const n=this.extends;if(n)return n.getValue(e)}}function Q(i,e){const{name:t}=e,n=`_${t}`;return{get:function(){return this[n]||(this[n]=new l(this.constructor[t].mode,void 0,this.constructor[t]))}}}class P extends M.Destroyable{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new g(this,this._pluginManager)),this._pluginManager}static _pluginManager=new g(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(e,...t){return this.pluginManager.usePlugin(e,...t)}static useExtend(e){return this.pluginManager.useExtend(e)}static hasUsed(e){return this.pluginManager.hasUsed(e)}usePlugin(e,...t){return this.pluginManager.instUsePlugin(this,e,...t)}useExtend(e,...t){return this.pluginManager.instUseExtend(this,e,...t)}init(...e){return this.pluginManager.onInit(this,...e)}destroyThis(){const e=this.pluginManager.onDestroy(this);return e instanceof Promise?e.finally(()=>super.destroyThis()):super.destroyThis()}}class W extends P{static isolatedOptions=!1;static get defaultOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_defaultOptions")&&(this._defaultOptions=new u(void 0,this._defaultOptions)),this._defaultOptions}static _defaultOptions=new u;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new u(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(e){super(),e&&(this.defaultOptions.option=e)}}function _(i){const e=M.createDestroyableSubClass(i);return class extends e{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new g(this,this._pluginManager)),this._pluginManager}static _pluginManager=new g(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(n,...s){return this.pluginManager.usePlugin(n,...s)}static useExtend(n){return this.pluginManager.useExtend(n)}static hasUsed(n){return this.pluginManager.hasUsed(n)}usePlugin(n,...s){return this.pluginManager.instUsePlugin(this,n,...s)}useExtend(n,...s){return this.pluginManager.instUseExtend(this,n,...s)}init(...n){return this.pluginManager.onInit(this,...n)}destroyThis(){const n=this.pluginManager.onDestroy(this);return n instanceof Promise?n.finally(()=>super.destroyThis()):super.destroyThis()}}}function X(i){const e=_(i);return class extends e{static isolatedOptions=!1;static get defaultOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_defaultOptions")&&(this._defaultOptions=new u(void 0,this._defaultOptions)),this._defaultOptions}static _defaultOptions=new u;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new u(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(n){super(),n&&(this.defaultOptions.option=n)}}}const p="common";class Y extends P{static isolatedOptions=!1;static get modeOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_modeOptions")&&(this._modeOptions=new l(p,null,this._modeOptions)),this._modeOptions}static _modeOptions=new l(p);get modeOptions(){return this._modeOptions||(this._modeOptions=new l(p,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(e){this.modeOptions.mode=e}get options(){return this.modeOptions.plainFullOption}constructor(e){super(),e&&this.modeOptions.setOption(e)}}function Z(i){const e=_(i);return class extends e{static isolatedOptions=!1;static get modeOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_modeOptions")&&(this._modeOptions=new l(p,null,this._modeOptions)),this._modeOptions}static _modeOptions=new l(p);get modeOptions(){return this._modeOptions||(this._modeOptions=new l(p,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(n){this.modeOptions.mode=n}get options(){return this.modeOptions.plainFullOption}constructor(n){super(),n&&this.modeOptions.setOption(n)}}}exports.ModeOptions=I;exports.PluginExtendManager=g;exports.PluginHost=P;exports.TierModeOptions=l;exports.TierModeOptionsPluginHost=Y;exports.TierOptions=u;exports.TierOptionsPluginHost=W;exports.commonModeName=p;exports.createDefineIExtend=R;exports.createDefineMixin=H;exports.createIExtendTarget=$;exports.createMixinTarget=j;exports.createPluginHost=_;exports.createTargetIExtend=z;exports.createTargetMixin=C;exports.createTierModeOptionsPluginHost=Z;exports.createTierOptionsPluginHost=X;exports.deepmerge=D;exports.deepmergeInto=F;exports.defineIExtend=B;exports.defineMixin=N;exports.extendMark=c;exports.getPropertyValue=f;exports.getPropertyValueByPath=L;exports.iextendTarget=K;exports.isPlugin=w;exports.mixin=a;exports.mixinByOmit=V;exports.mixinByPick=v;exports.mixinIExtend=U;exports.mixinTarget=S;exports.parsePropertyPath=x;exports.pickHostExtendMembers=A;exports.setPropertyValue=y;exports.setPropertyValueByPath=G;exports.targetIExtend=q;exports.targetMixin=k;exports.tierModeOptionsDecorator=Q;exports.tierOptionsDecorator=J;
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { Destroyable as
|
|
2
|
-
import {
|
|
3
|
-
import { waitAsyncable as
|
|
4
|
-
import { omitMembers as D, removeUndefined as v, pickMembers as E, serialCallFuns as
|
|
5
|
-
function
|
|
1
|
+
import { Destroyable as M, createDestroyableSubClass as w } from "@gby/destroyable";
|
|
2
|
+
import { deepmergeCustom as F, deepmergeIntoCustom as T } from "deepmerge-ts";
|
|
3
|
+
import { waitAsyncable as f } from "type-tls";
|
|
4
|
+
import { omitMembers as D, removeUndefined as v, pickMembers as E, serialCallFuns as g } from "com-tools";
|
|
5
|
+
function d(s, ...t) {
|
|
6
6
|
for (const e of t) {
|
|
7
7
|
const n = Object.getOwnPropertyDescriptors(e);
|
|
8
8
|
Object.defineProperties(s, n);
|
|
9
9
|
}
|
|
10
10
|
return s;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function R(s, t, e) {
|
|
13
13
|
let n = Object.getOwnPropertyDescriptors(t);
|
|
14
14
|
return e && D(n, e), Object.defineProperties(s, n), s;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function B(s, t, e) {
|
|
17
17
|
let n = Object.getOwnPropertyDescriptors(t);
|
|
18
18
|
return e ? Object.defineProperties(s, v(E(n, e))) : Object.defineProperties(s, n), s;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function z(s, t) {
|
|
21
21
|
return t;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function K(s) {
|
|
24
24
|
return function(e) {
|
|
25
25
|
return e;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
28
|
+
function $(s, t) {
|
|
29
|
+
return d(s, t), t;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function q(s) {
|
|
32
32
|
return function(e) {
|
|
33
|
-
return
|
|
33
|
+
return d(s, e), e;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function G(s, t) {
|
|
37
|
+
return d(s, t), s;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function J(s) {
|
|
40
40
|
return function(e) {
|
|
41
|
-
return
|
|
41
|
+
return d(s, e), s;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
function
|
|
44
|
+
const x = ["onCreate", "onInit", "onDestroy"];
|
|
45
|
+
function L(s) {
|
|
46
46
|
const t = { ...s };
|
|
47
|
-
for (const e of
|
|
47
|
+
for (const e of x)
|
|
48
48
|
typeof t[e] == "function" && delete t[e];
|
|
49
49
|
return t;
|
|
50
50
|
}
|
|
51
51
|
function N(s, t) {
|
|
52
52
|
let e = Object.getOwnPropertyDescriptors(t);
|
|
53
|
-
for (const n of
|
|
53
|
+
for (const n of x)
|
|
54
54
|
typeof t[n] == "function" && delete e[n];
|
|
55
55
|
return Object.defineProperties(s, e), s;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function Q(s, t) {
|
|
58
58
|
return t;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function W(s) {
|
|
61
61
|
return function(e) {
|
|
62
62
|
return e;
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
65
|
+
function X(s, t) {
|
|
66
|
+
return d(s.prototype, t), t;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function Y(s) {
|
|
69
69
|
return function(e) {
|
|
70
|
-
return
|
|
70
|
+
return d(s.prototype, e), e;
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
73
|
+
function Z(s, t) {
|
|
74
|
+
return d(s.prototype, t), s;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function tt(s) {
|
|
77
77
|
return function(e) {
|
|
78
|
-
return
|
|
78
|
+
return d(s.prototype, e), s;
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
function V(s) {
|
|
82
82
|
return s && typeof s.onUse == "function";
|
|
83
83
|
}
|
|
84
84
|
const c = /* @__PURE__ */ Symbol("extend");
|
|
85
|
-
class h extends
|
|
85
|
+
class h extends M {
|
|
86
86
|
/**
|
|
87
87
|
* 父级插件管理者
|
|
88
88
|
*
|
|
@@ -187,7 +187,7 @@ class h extends x {
|
|
|
187
187
|
const u = o === c ? r.onCreate : r.onCreate.bind(r);
|
|
188
188
|
i.push(u);
|
|
189
189
|
}
|
|
190
|
-
return
|
|
190
|
+
return f(n, () => g(i, t, [t, ...e]));
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
193
|
* 插件宿主创建实例时调用
|
|
@@ -204,7 +204,7 @@ class h extends x {
|
|
|
204
204
|
const u = o === c ? r.onInit : r.onInit.bind(r);
|
|
205
205
|
i.push(u);
|
|
206
206
|
}
|
|
207
|
-
return
|
|
207
|
+
return f(n, () => g(i, t, [t, ...e]));
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
210
210
|
* 插件宿主被销毁时调用
|
|
@@ -221,23 +221,24 @@ class h extends x {
|
|
|
221
221
|
e.push(u);
|
|
222
222
|
}
|
|
223
223
|
e.reverse();
|
|
224
|
-
const n =
|
|
225
|
-
return i ?
|
|
224
|
+
const n = g(e, t, [t]), { parent: i } = this;
|
|
225
|
+
return i ? f(n, () => i.onDestroy(t)) : n;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
const I = T({ mergeArrays: !1, mergeSets: !1 }), C = F({ mergeArrays: !1, mergeSets: !1 });
|
|
229
|
+
function _(s) {
|
|
229
230
|
const t = s.split(".");
|
|
230
231
|
return t[0] === "" && t.shift(), t;
|
|
231
232
|
}
|
|
232
|
-
function
|
|
233
|
+
function m(s, t) {
|
|
233
234
|
for (const e of t)
|
|
234
235
|
if (s = s[e], s == null) return;
|
|
235
236
|
return s;
|
|
236
237
|
}
|
|
237
|
-
function
|
|
238
|
-
return
|
|
238
|
+
function et(s, t) {
|
|
239
|
+
return m(s, _(t));
|
|
239
240
|
}
|
|
240
|
-
function
|
|
241
|
+
function y(s, t, e) {
|
|
241
242
|
const n = t.pop(), i = t.length;
|
|
242
243
|
let r = 0;
|
|
243
244
|
for (; r < i; ) {
|
|
@@ -250,10 +251,10 @@ function b(s, t, e) {
|
|
|
250
251
|
s = s[o] = {};
|
|
251
252
|
return s[n] = e, s;
|
|
252
253
|
}
|
|
253
|
-
function
|
|
254
|
-
return
|
|
254
|
+
function nt(s, t, e) {
|
|
255
|
+
return y(s, _(t), e);
|
|
255
256
|
}
|
|
256
|
-
const
|
|
257
|
+
const O = {
|
|
257
258
|
UndefinedAndNull: function(t) {
|
|
258
259
|
return t == null;
|
|
259
260
|
},
|
|
@@ -264,7 +265,27 @@ const m = {
|
|
|
264
265
|
return t === null;
|
|
265
266
|
}
|
|
266
267
|
};
|
|
267
|
-
class
|
|
268
|
+
class P {
|
|
269
|
+
/**
|
|
270
|
+
* 深度合并到目标对象
|
|
271
|
+
*/
|
|
272
|
+
static deepmergeInto = I;
|
|
273
|
+
/**
|
|
274
|
+
* 深度合并
|
|
275
|
+
*/
|
|
276
|
+
static deepmerge = C;
|
|
277
|
+
/**
|
|
278
|
+
* 深度合并到目标对象
|
|
279
|
+
*/
|
|
280
|
+
get deepmergeInto() {
|
|
281
|
+
return this.constructor.deepmergeInto;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* 深度合并
|
|
285
|
+
*/
|
|
286
|
+
get deepmerge() {
|
|
287
|
+
return this.constructor.deepmerge;
|
|
288
|
+
}
|
|
268
289
|
/**
|
|
269
290
|
* 是否要冻结 fullOption 的成员
|
|
270
291
|
* @remarks
|
|
@@ -316,7 +337,7 @@ class U {
|
|
|
316
337
|
* @param deep - 是否要进行深度合并
|
|
317
338
|
*/
|
|
318
339
|
setOption(t, e) {
|
|
319
|
-
const n = e ?
|
|
340
|
+
const n = e ? this.deepmergeInto(this.option, t) : Object.assign(this.option, t);
|
|
320
341
|
return this.updateFullOption(), n;
|
|
321
342
|
}
|
|
322
343
|
/**
|
|
@@ -326,13 +347,13 @@ class U {
|
|
|
326
347
|
return this._undefinedValue;
|
|
327
348
|
}
|
|
328
349
|
set undefinedValue(t) {
|
|
329
|
-
this._undefinedValue = t, this.isUndefined =
|
|
350
|
+
this._undefinedValue = t, this.isUndefined = O[t] || O.UndefinedAndNull;
|
|
330
351
|
}
|
|
331
352
|
_undefinedValue = "UndefinedAndNull";
|
|
332
353
|
/**
|
|
333
354
|
* 未定义值的判断函数
|
|
334
355
|
*/
|
|
335
|
-
isUndefined =
|
|
356
|
+
isUndefined = O.UndefinedAndNull;
|
|
336
357
|
/**
|
|
337
358
|
* 获取选项成员
|
|
338
359
|
* @param key
|
|
@@ -353,7 +374,7 @@ class U {
|
|
|
353
374
|
delete i[t];
|
|
354
375
|
else {
|
|
355
376
|
const r = i[t];
|
|
356
|
-
n && r && typeof r == "object" ?
|
|
377
|
+
n && r && typeof r == "object" ? this.deepmergeInto(r, e) : i[t] = e;
|
|
357
378
|
}
|
|
358
379
|
this.updateFullOption();
|
|
359
380
|
}
|
|
@@ -363,7 +384,7 @@ class U {
|
|
|
363
384
|
* @returns
|
|
364
385
|
*/
|
|
365
386
|
getValue(t) {
|
|
366
|
-
return
|
|
387
|
+
return m(this.option, t);
|
|
367
388
|
}
|
|
368
389
|
/**
|
|
369
390
|
* 设置属性路径对应的值
|
|
@@ -375,10 +396,10 @@ class U {
|
|
|
375
396
|
setValue(t, e, n) {
|
|
376
397
|
const i = this.option;
|
|
377
398
|
let r;
|
|
378
|
-
n && (r =
|
|
399
|
+
n && (r = m(i, t)) && typeof r == "object" ? this.deepmergeInto(r, e) : y(this.option, t, e), this.updateFullOption();
|
|
379
400
|
}
|
|
380
401
|
}
|
|
381
|
-
class a extends
|
|
402
|
+
class a extends P {
|
|
382
403
|
constructor(t, e) {
|
|
383
404
|
super(), t && (this.option = t), e && (this.extends = e);
|
|
384
405
|
}
|
|
@@ -407,7 +428,7 @@ class a extends U {
|
|
|
407
428
|
const { extends: e, option: n } = this;
|
|
408
429
|
if (t = n, e) {
|
|
409
430
|
const i = e.plainFullOption;
|
|
410
|
-
t =
|
|
431
|
+
t = this.deepmerge(i, n);
|
|
411
432
|
}
|
|
412
433
|
return this._plainFullOption = t;
|
|
413
434
|
}
|
|
@@ -443,7 +464,7 @@ class a extends U {
|
|
|
443
464
|
return n.getValue(t);
|
|
444
465
|
}
|
|
445
466
|
}
|
|
446
|
-
function
|
|
467
|
+
function st(s, t) {
|
|
447
468
|
const { name: e } = t, n = `_${e}`;
|
|
448
469
|
return {
|
|
449
470
|
get: function() {
|
|
@@ -451,7 +472,7 @@ function et(s, t) {
|
|
|
451
472
|
}
|
|
452
473
|
};
|
|
453
474
|
}
|
|
454
|
-
class k extends
|
|
475
|
+
class k extends P {
|
|
455
476
|
constructor(t, e) {
|
|
456
477
|
super(), e && this.setModeOption(t, e), this.mode = t;
|
|
457
478
|
}
|
|
@@ -549,7 +570,7 @@ class k extends U {
|
|
|
549
570
|
return this.updateFullOption(), o;
|
|
550
571
|
}
|
|
551
572
|
}
|
|
552
|
-
class
|
|
573
|
+
class l extends k {
|
|
553
574
|
constructor(t, e, n) {
|
|
554
575
|
super(t, e), n && (this.extends = n);
|
|
555
576
|
}
|
|
@@ -574,7 +595,7 @@ class d extends k {
|
|
|
574
595
|
const { modes: e, extends: n } = this, i = e[t]?.plainFullOption;
|
|
575
596
|
if (n) {
|
|
576
597
|
const r = n.getFullModeOption(t);
|
|
577
|
-
return i ?
|
|
598
|
+
return i ? this.deepmerge(r, i) : r;
|
|
578
599
|
}
|
|
579
600
|
return i;
|
|
580
601
|
}
|
|
@@ -638,15 +659,15 @@ class d extends k {
|
|
|
638
659
|
return n.getValue(t);
|
|
639
660
|
}
|
|
640
661
|
}
|
|
641
|
-
function
|
|
662
|
+
function it(s, t) {
|
|
642
663
|
const { name: e } = t, n = `_${e}`;
|
|
643
664
|
return {
|
|
644
665
|
get: function() {
|
|
645
|
-
return this[n] || (this[n] = new
|
|
666
|
+
return this[n] || (this[n] = new l(this.constructor[e].mode, void 0, this.constructor[e]));
|
|
646
667
|
}
|
|
647
668
|
};
|
|
648
669
|
}
|
|
649
|
-
class
|
|
670
|
+
class b extends M {
|
|
650
671
|
/**
|
|
651
672
|
* 是否使用独立的插件管理器
|
|
652
673
|
* @defaultValue false
|
|
@@ -729,7 +750,7 @@ class w extends x {
|
|
|
729
750
|
return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
|
|
730
751
|
}
|
|
731
752
|
}
|
|
732
|
-
class
|
|
753
|
+
class rt extends b {
|
|
733
754
|
/**
|
|
734
755
|
* 是否使用独立的选项
|
|
735
756
|
* @defaultValue false
|
|
@@ -750,11 +771,11 @@ class st extends w {
|
|
|
750
771
|
}
|
|
751
772
|
_defaultOptions;
|
|
752
773
|
constructor(t) {
|
|
753
|
-
super(), this.defaultOptions.option = t;
|
|
774
|
+
super(), t && (this.defaultOptions.option = t);
|
|
754
775
|
}
|
|
755
776
|
}
|
|
756
|
-
function
|
|
757
|
-
const t =
|
|
777
|
+
function U(s) {
|
|
778
|
+
const t = w(s);
|
|
758
779
|
return class extends t {
|
|
759
780
|
/**
|
|
760
781
|
* 是否使用独立的插件管理器
|
|
@@ -838,8 +859,8 @@ function F(s) {
|
|
|
838
859
|
}
|
|
839
860
|
};
|
|
840
861
|
}
|
|
841
|
-
function
|
|
842
|
-
const t =
|
|
862
|
+
function at(s) {
|
|
863
|
+
const t = U(s);
|
|
843
864
|
return class extends t {
|
|
844
865
|
/**
|
|
845
866
|
* 是否使用独立的选项
|
|
@@ -861,12 +882,12 @@ function ot(s) {
|
|
|
861
882
|
}
|
|
862
883
|
_defaultOptions;
|
|
863
884
|
constructor(n) {
|
|
864
|
-
super(), this.defaultOptions.option = n;
|
|
885
|
+
super(), n && (this.defaultOptions.option = n);
|
|
865
886
|
}
|
|
866
887
|
};
|
|
867
888
|
}
|
|
868
889
|
const p = "common";
|
|
869
|
-
class
|
|
890
|
+
class dt extends b {
|
|
870
891
|
/**
|
|
871
892
|
* 是否使用独立的选项
|
|
872
893
|
* @defaultValue false
|
|
@@ -876,14 +897,14 @@ class ut extends w {
|
|
|
876
897
|
* 全局级别的默认选项
|
|
877
898
|
*/
|
|
878
899
|
static get modeOptions() {
|
|
879
|
-
return this.isolatedOptions && !this.hasOwnProperty("_modeOptions") && (this._modeOptions = new
|
|
900
|
+
return this.isolatedOptions && !this.hasOwnProperty("_modeOptions") && (this._modeOptions = new l(p, null, this._modeOptions)), this._modeOptions;
|
|
880
901
|
}
|
|
881
|
-
static _modeOptions = new
|
|
902
|
+
static _modeOptions = new l(p);
|
|
882
903
|
/**
|
|
883
904
|
* 实例级的默认选项
|
|
884
905
|
*/
|
|
885
906
|
get modeOptions() {
|
|
886
|
-
return this._modeOptions || (this._modeOptions = new
|
|
907
|
+
return this._modeOptions || (this._modeOptions = new l(p, void 0, this.constructor.modeOptions));
|
|
887
908
|
}
|
|
888
909
|
_modeOptions;
|
|
889
910
|
get mode() {
|
|
@@ -896,11 +917,11 @@ class ut extends w {
|
|
|
896
917
|
return this.modeOptions.plainFullOption;
|
|
897
918
|
}
|
|
898
919
|
constructor(t) {
|
|
899
|
-
super(), this.modeOptions.setOption(t);
|
|
920
|
+
super(), t && this.modeOptions.setOption(t);
|
|
900
921
|
}
|
|
901
922
|
}
|
|
902
|
-
function
|
|
903
|
-
const t =
|
|
923
|
+
function pt(s) {
|
|
924
|
+
const t = U(s);
|
|
904
925
|
return class extends t {
|
|
905
926
|
/**
|
|
906
927
|
* 是否使用独立的选项
|
|
@@ -911,14 +932,14 @@ function lt(s) {
|
|
|
911
932
|
* 全局级别的默认选项
|
|
912
933
|
*/
|
|
913
934
|
static get modeOptions() {
|
|
914
|
-
return this.isolatedOptions && !this.hasOwnProperty("_modeOptions") && (this._modeOptions = new
|
|
935
|
+
return this.isolatedOptions && !this.hasOwnProperty("_modeOptions") && (this._modeOptions = new l(p, null, this._modeOptions)), this._modeOptions;
|
|
915
936
|
}
|
|
916
|
-
static _modeOptions = new
|
|
937
|
+
static _modeOptions = new l(p);
|
|
917
938
|
/**
|
|
918
939
|
* 实例级的默认选项
|
|
919
940
|
*/
|
|
920
941
|
get modeOptions() {
|
|
921
|
-
return this._modeOptions || (this._modeOptions = new
|
|
942
|
+
return this._modeOptions || (this._modeOptions = new l(p, void 0, this.constructor.modeOptions));
|
|
922
943
|
}
|
|
923
944
|
_modeOptions;
|
|
924
945
|
get mode() {
|
|
@@ -931,46 +952,48 @@ function lt(s) {
|
|
|
931
952
|
return this.modeOptions.plainFullOption;
|
|
932
953
|
}
|
|
933
954
|
constructor(n) {
|
|
934
|
-
super(), this.modeOptions.setOption(n);
|
|
955
|
+
super(), n && this.modeOptions.setOption(n);
|
|
935
956
|
}
|
|
936
957
|
};
|
|
937
958
|
}
|
|
938
959
|
export {
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
960
|
+
R as A,
|
|
961
|
+
B,
|
|
962
|
+
_ as C,
|
|
963
|
+
L as D,
|
|
964
|
+
y as E,
|
|
965
|
+
nt as F,
|
|
966
|
+
X as G,
|
|
967
|
+
$ as H,
|
|
968
|
+
it as I,
|
|
969
|
+
st as J,
|
|
947
970
|
k as M,
|
|
948
971
|
h as P,
|
|
949
|
-
|
|
972
|
+
l as T,
|
|
950
973
|
N as a,
|
|
951
|
-
|
|
974
|
+
G as b,
|
|
952
975
|
p as c,
|
|
953
976
|
a as d,
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
977
|
+
b as e,
|
|
978
|
+
dt as f,
|
|
979
|
+
rt as g,
|
|
980
|
+
W as h,
|
|
981
|
+
K as i,
|
|
982
|
+
tt as j,
|
|
983
|
+
J as k,
|
|
984
|
+
U as l,
|
|
985
|
+
d as m,
|
|
986
|
+
Y as n,
|
|
987
|
+
q as o,
|
|
988
|
+
pt as p,
|
|
989
|
+
at as q,
|
|
990
|
+
C as r,
|
|
991
|
+
I as s,
|
|
992
|
+
Q as t,
|
|
993
|
+
z as u,
|
|
994
|
+
c as v,
|
|
995
|
+
m as w,
|
|
996
|
+
et as x,
|
|
997
|
+
Z as y,
|
|
998
|
+
V as z
|
|
976
999
|
};
|
package/dist/index-node.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./Destroyable-mrBsNabq-IFFuYfKS.cjs"),u=require("com-tools"),a=require("node:events"),s=require("./createTierModeOptionsPluginHost-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./Destroyable-mrBsNabq-IFFuYfKS.cjs"),u=require("com-tools"),a=require("node:events"),s=require("./createTierModeOptionsPluginHost-B8wx-Fm2.cjs");var d=class extends a.EventEmitter{refCount=0;get isDestroyed(){return this._isDestroyed}_isDestroyed=!1;get canDestroy(){return!this.isDestroyed&&this.refCount<=0}_destroyers=[];disposeFun(e){return this._destroyers.push(e),e}cancelDisposeFun(e){let t=this._destroyers.indexOf(e);return this._destroyers.splice(t,1),e}disposeObj(e,t){let i=t?function(){return e.destroySync()}:function(){return e.destroy()};return this.disposeFun(i),e.__destroyable_destroyer=i,e}cancelDisposeObj(e){let t=e.__destroyable_destroyer;return t&&this.cancelDisposeFun(t),e}dispose(e,t){return typeof e=="function"?this.disposeFun(e):this.disposeObj(e,t)}cancelDispose(e){return typeof e=="function"?this.cancelDisposeFun(e):this.cancelDisposeObj(e)}destroyThis(){}destroySync(){if(!this.canDestroy)return this.isDestroyed;let e=this._destroyers.length;for(;--e>=0;){let t=this._destroyers[e];try{t()}catch(i){console.error("销毁函数在同步销毁时出错",this,t,i)}}this._destroyers.length=0;try{this.destroyThis()}catch(t){console.error("destroyThis 在异步销毁时出错",this,t)}return n.a(this),!0}destroy(){if(!this.canDestroy)return this.isDestroyed;let e=this._destroyers.toReversed();e.push(this.destroyThis),this._destroyers.length=0;let t=u.serialCallAllFuns(e,this,null,(i,r)=>{console.error("销毁函数在串行销毁时出错",this,r,i)});return t instanceof Promise?t.then(()=>(n.a(this),!0)):(n.a(this),!0)}};class o extends d{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new s.PluginExtendManager(this,this._pluginManager)),this._pluginManager}static _pluginManager=new s.PluginExtendManager(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(t,...i){return this.pluginManager.usePlugin(t,...i)}static useExtend(t){return this.pluginManager.useExtend(t)}static hasUsed(t){return this.pluginManager.hasUsed(t)}usePlugin(t,...i){return this.pluginManager.instUsePlugin(this,t,...i)}useExtend(t,...i){return this.pluginManager.instUseExtend(this,t,...i)}init(...t){return this.pluginManager.onInit(this,...t)}destroyThis(){const t=this.pluginManager.onDestroy(this);return t instanceof Promise?t.finally(()=>super.destroyThis()):super.destroyThis()}}class l extends o{static isolatedOptions=!1;static get modeOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_modeOptions")&&(this._modeOptions=new s.TierModeOptions(s.commonModeName,null,this._modeOptions)),this._modeOptions}static _modeOptions=new s.TierModeOptions(s.commonModeName);get modeOptions(){return this._modeOptions||(this._modeOptions=new s.TierModeOptions(s.commonModeName,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(t){this.modeOptions.mode=t}get options(){return this.modeOptions.plainFullOption}constructor(t){super(),t&&this.modeOptions.setOption(t)}}class p extends o{static isolatedOptions=!1;static get defaultOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_defaultOptions")&&(this._defaultOptions=new s.TierOptions(void 0,this._defaultOptions)),this._defaultOptions}static _defaultOptions=new s.TierOptions;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new s.TierOptions(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(t){super(),t&&(this.defaultOptions.option=t)}}exports.TierModeOptionsPluginHost=s.TierModeOptionsPluginHost;exports.TierOptionsPluginHost=s.TierOptionsPluginHost;exports.commonModeName=s.commonModeName;exports.createTierModeOptionsPluginHost=s.createTierModeOptionsPluginHost;exports.createTierOptionsPluginHost=s.createTierOptionsPluginHost;exports.PluginHostEventEmitter=o;exports.TierModeOptionsPluginHostEventEmitter=l;exports.TierOptionsPluginHostEventEmitter=p;
|
package/dist/index-node.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as i } from "./Destroyable-mrBsNabq-D6TYs3Zn.js";
|
|
2
2
|
import { serialCallAllFuns as l } from "com-tools";
|
|
3
3
|
import { EventEmitter as h } from "node:events";
|
|
4
|
-
import { P as a, T as n, c as r, d as o } from "./createTierModeOptionsPluginHost-
|
|
5
|
-
import { f as P, g as D, p as T, q as E } from "./createTierModeOptionsPluginHost-
|
|
4
|
+
import { P as a, T as n, c as r, d as o } from "./createTierModeOptionsPluginHost-Ctr7S9XZ.js";
|
|
5
|
+
import { f as P, g as D, p as T, q as E } from "./createTierModeOptionsPluginHost-Ctr7S9XZ.js";
|
|
6
6
|
var p = class extends h {
|
|
7
7
|
refCount = 0;
|
|
8
8
|
get isDestroyed() {
|
|
@@ -182,7 +182,7 @@ class f extends u {
|
|
|
182
182
|
return this.modeOptions.plainFullOption;
|
|
183
183
|
}
|
|
184
184
|
constructor(t) {
|
|
185
|
-
super(), this.modeOptions.setOption(t);
|
|
185
|
+
super(), t && this.modeOptions.setOption(t);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
class _ extends u {
|
|
@@ -206,7 +206,7 @@ class _ extends u {
|
|
|
206
206
|
}
|
|
207
207
|
_defaultOptions;
|
|
208
208
|
constructor(t) {
|
|
209
|
-
super(), this.defaultOptions.option = t;
|
|
209
|
+
super(), t && (this.defaultOptions.option = t);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
export {
|
package/dist/index-web.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./Destroyable-mrBsNabq-IFFuYfKS.cjs"),p=require("com-tools"),i=require("./createTierModeOptionsPluginHost-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./Destroyable-mrBsNabq-IFFuYfKS.cjs"),p=require("com-tools"),i=require("./createTierModeOptionsPluginHost-B8wx-Fm2.cjs");if(!globalThis.CustomEvent){class e extends Event{detail;constructor(s,n){super(s,n),this.detail=n?.detail}}globalThis.CustomEvent=e}class h extends EventTarget{addEventListener(t,s,n){const o=n?.times;if(o){const r=typeof s=="function"?s:s?.handleEvent;if(r)return this.multipleListen(t,r,o)}return super.addEventListener(t,s,n),()=>{this.removeEventListener(t,s,n)}}dispatchEvent(t,s){const n=t instanceof Event?t:new CustomEvent(t,{detail:s,bubbles:!1,cancelable:!0,composed:!1});return super.dispatchEvent(n)}onceListen(t,s,n){return this.addEventListener(t,s,{...n,once:!0})}multipleListen(t,s,n){let o=0;const r=new AbortController,l=r.signal;return super.addEventListener(t,d=>{++o>=n&&r.abort(),s.call(this,d)},{signal:l}),function(){r.abort()}}}var c=class extends h{refCount=0;get isDestroyed(){return this._isDestroyed}_isDestroyed=!1;get canDestroy(){return!this.isDestroyed&&this.refCount<=0}_destroyers=[];disposeFun(e){return this._destroyers.push(e),e}cancelDisposeFun(e){let t=this._destroyers.indexOf(e);return this._destroyers.splice(t,1),e}disposeObj(e,t){let s=t?function(){return e.destroySync()}:function(){return e.destroy()};return this.disposeFun(s),e.__destroyable_destroyer=s,e}cancelDisposeObj(e){let t=e.__destroyable_destroyer;return t&&this.cancelDisposeFun(t),e}dispose(e,t){return typeof e=="function"?this.disposeFun(e):this.disposeObj(e,t)}cancelDispose(e){return typeof e=="function"?this.cancelDisposeFun(e):this.cancelDisposeObj(e)}destroyThis(){}destroySync(){if(!this.canDestroy)return this.isDestroyed;let e=this._destroyers.length;for(;--e>=0;){let t=this._destroyers[e];try{t()}catch(s){console.error("销毁函数在同步销毁时出错",this,t,s)}}this._destroyers.length=0;try{this.destroyThis()}catch(t){console.error("destroyThis 在异步销毁时出错",this,t)}return a.a(this),!0}destroy(){if(!this.canDestroy)return this.isDestroyed;let e=this._destroyers.toReversed();e.push(this.destroyThis),this._destroyers.length=0;let t=p.serialCallAllFuns(e,this,null,(s,n)=>{console.error("销毁函数在串行销毁时出错",this,n,s)});return t instanceof Promise?t.then(()=>(a.a(this),!0)):(a.a(this),!0)}};class u extends c{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new i.PluginExtendManager(this,this._pluginManager)),this._pluginManager}static _pluginManager=new i.PluginExtendManager(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(t,...s){return this.pluginManager.usePlugin(t,...s)}static useExtend(t){return this.pluginManager.useExtend(t)}static hasUsed(t){return this.pluginManager.hasUsed(t)}usePlugin(t,...s){return this.pluginManager.instUsePlugin(this,t,...s)}useExtend(t,...s){return this.pluginManager.instUseExtend(this,t,...s)}init(...t){return this.pluginManager.onInit(this,...t)}destroyThis(){const t=this.pluginManager.onDestroy(this);return t instanceof Promise?t.finally(()=>super.destroyThis()):super.destroyThis()}}class g extends u{static isolatedOptions=!1;static get modeOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_modeOptions")&&(this._modeOptions=new i.TierModeOptions(i.commonModeName,null,this._modeOptions)),this._modeOptions}static _modeOptions=new i.TierModeOptions(i.commonModeName);get modeOptions(){return this._modeOptions||(this._modeOptions=new i.TierModeOptions(i.commonModeName,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(t){this.modeOptions.mode=t}get options(){return this.modeOptions.plainFullOption}constructor(t){super(),t&&this.modeOptions.setOption(t)}}class O extends u{static isolatedOptions=!1;static get defaultOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_defaultOptions")&&(this._defaultOptions=new i.TierOptions(void 0,this._defaultOptions)),this._defaultOptions}static _defaultOptions=new i.TierOptions;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new i.TierOptions(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(t){super(),t&&(this.defaultOptions.option=t)}}exports.TierModeOptionsPluginHost=i.TierModeOptionsPluginHost;exports.TierOptionsPluginHost=i.TierOptionsPluginHost;exports.commonModeName=i.commonModeName;exports.createTierModeOptionsPluginHost=i.createTierModeOptionsPluginHost;exports.createTierOptionsPluginHost=i.createTierOptionsPluginHost;exports.PluginHostEventTarget=u;exports.TierModeOptionsPluginHostEventTarget=g;exports.TierOptionsPluginHostEventTarget=O;
|