plugin-tls 5.1.0 → 5.2.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-D-fKYlcA.js → createTierModeOptionsPluginHost-Bvne8SqN.js} +90 -58
- package/dist/createTierModeOptionsPluginHost-D2REw5Vz.cjs +1 -0
- package/dist/index-node.cjs +1 -1
- package/dist/index-node.js +30 -14
- package/dist/index-web.cjs +1 -1
- package/dist/index-web.js +80 -64
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts +9 -2
- 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 +7 -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 +7 -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 +7 -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 +12 -5
- 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 +7 -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 +7 -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 +7 -1
- package/dist/options/options-plugin-host/tier-options/createTierOptionsPluginHost.d.ts.map +1 -1
- package/dist/plugin-host/PluginHost.d.ts +0 -1
- package/dist/plugin-host/PluginHost.d.ts.map +1 -1
- package/dist/type.d.ts +2 -0
- package/dist/type.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/createTierModeOptionsPluginHost-DyDtXKNW.cjs +0 -1
- package/dist/index-com.d.ts +0 -3
- package/dist/index-com.d.ts.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Destroyable as x, createDestroyableSubClass as T } from "@gby/destroyable";
|
|
2
|
-
import { deepmergeInto as f, deepmerge as
|
|
2
|
+
import { deepmergeInto as f, deepmerge as _ } from "deepmerge-ts";
|
|
3
3
|
import { waitAsyncable as g } from "type-tls";
|
|
4
4
|
import { omitMembers as D, removeUndefined as E, pickMembers as v, serialCallFuns as O } from "com-tools";
|
|
5
|
-
function
|
|
5
|
+
function l(s, ...t) {
|
|
6
6
|
for (const e of t) {
|
|
7
7
|
const n = Object.getOwnPropertyDescriptors(e);
|
|
8
8
|
Object.defineProperties(s, n);
|
|
@@ -26,31 +26,31 @@ function B(s) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
function z(s, t) {
|
|
29
|
-
return
|
|
29
|
+
return l(s, t), t;
|
|
30
30
|
}
|
|
31
31
|
function K(s) {
|
|
32
32
|
return function(e) {
|
|
33
|
-
return
|
|
33
|
+
return l(s, e), e;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function $(s, t) {
|
|
37
|
-
return
|
|
37
|
+
return l(s, t), s;
|
|
38
38
|
}
|
|
39
39
|
function q(s) {
|
|
40
40
|
return function(e) {
|
|
41
|
-
return
|
|
41
|
+
return l(s, e), s;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const y = ["onCreate", "onInit", "onDestroy"];
|
|
45
45
|
function G(s) {
|
|
46
46
|
const t = { ...s };
|
|
47
|
-
for (const e of
|
|
47
|
+
for (const e of y)
|
|
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 y)
|
|
54
54
|
typeof t[n] == "function" && delete e[n];
|
|
55
55
|
return Object.defineProperties(s, e), s;
|
|
56
56
|
}
|
|
@@ -63,26 +63,26 @@ function J(s) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
function Q(s, t) {
|
|
66
|
-
return
|
|
66
|
+
return l(s.prototype, t), t;
|
|
67
67
|
}
|
|
68
68
|
function W(s) {
|
|
69
69
|
return function(e) {
|
|
70
|
-
return
|
|
70
|
+
return l(s.prototype, e), e;
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
function X(s, t) {
|
|
74
|
-
return
|
|
74
|
+
return l(s.prototype, t), s;
|
|
75
75
|
}
|
|
76
76
|
function Y(s) {
|
|
77
77
|
return function(e) {
|
|
78
|
-
return
|
|
78
|
+
return l(s.prototype, e), s;
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
function V(s) {
|
|
82
82
|
return s && typeof s.onUse == "function";
|
|
83
83
|
}
|
|
84
|
-
const
|
|
85
|
-
class
|
|
84
|
+
const c = /* @__PURE__ */ Symbol("extend");
|
|
85
|
+
class h extends x {
|
|
86
86
|
/**
|
|
87
87
|
* 父级插件管理者
|
|
88
88
|
*
|
|
@@ -130,7 +130,7 @@ class c extends x {
|
|
|
130
130
|
* @returns
|
|
131
131
|
*/
|
|
132
132
|
isPlugin(t) {
|
|
133
|
-
return this.hasUsed(t) ? this.getUseReturn(t) !==
|
|
133
|
+
return this.hasUsed(t) ? this.getUseReturn(t) !== c : V(t);
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* 使用插件、注册插件
|
|
@@ -138,7 +138,7 @@ class c extends x {
|
|
|
138
138
|
* @param args - 传递给插件的选项
|
|
139
139
|
*/
|
|
140
140
|
useExtend(t) {
|
|
141
|
-
return this.hasUsed(t) || (N(this.host.prototype, t), this.plugins.set(t,
|
|
141
|
+
return this.hasUsed(t) || (N(this.host.prototype, t), this.plugins.set(t, c)), t;
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* 插件宿主实例的注册插件的方法
|
|
@@ -184,7 +184,7 @@ class c extends x {
|
|
|
184
184
|
const n = this.parent?.onCreate(t, ...e), i = [];
|
|
185
185
|
for (const [r, o] of this.plugins)
|
|
186
186
|
if (r.onCreate) {
|
|
187
|
-
const u = o ===
|
|
187
|
+
const u = o === c ? r.onCreate : r.onCreate.bind(r);
|
|
188
188
|
i.push(u);
|
|
189
189
|
}
|
|
190
190
|
return g(n, () => O(i, t, [t, ...e]));
|
|
@@ -201,7 +201,7 @@ class c extends x {
|
|
|
201
201
|
const n = this.parent?.onInit(t, ...e), i = [];
|
|
202
202
|
for (const [r, o] of this.plugins)
|
|
203
203
|
if (r.onInit) {
|
|
204
|
-
const u = o ===
|
|
204
|
+
const u = o === c ? r.onInit : r.onInit.bind(r);
|
|
205
205
|
i.push(u);
|
|
206
206
|
}
|
|
207
207
|
return g(n, () => O(i, t, [t, ...e]));
|
|
@@ -217,7 +217,7 @@ class c extends x {
|
|
|
217
217
|
const e = [];
|
|
218
218
|
for (const [r, o] of this.plugins)
|
|
219
219
|
if (r.onDestroy) {
|
|
220
|
-
const u = o ===
|
|
220
|
+
const u = o === c ? r.onDestroy : r.onDestroy.bind(r);
|
|
221
221
|
e.push(u);
|
|
222
222
|
}
|
|
223
223
|
e.reverse();
|
|
@@ -225,7 +225,7 @@ class c extends x {
|
|
|
225
225
|
return i ? g(n, () => i.onDestroy(t)) : n;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function P(s) {
|
|
229
229
|
const t = s.split(".");
|
|
230
230
|
return t[0] === "" && t.shift(), t;
|
|
231
231
|
}
|
|
@@ -235,7 +235,7 @@ function M(s, t) {
|
|
|
235
235
|
return s;
|
|
236
236
|
}
|
|
237
237
|
function Z(s, t) {
|
|
238
|
-
return M(s,
|
|
238
|
+
return M(s, P(t));
|
|
239
239
|
}
|
|
240
240
|
function b(s, t, e) {
|
|
241
241
|
const n = t.pop(), i = t.length;
|
|
@@ -251,7 +251,7 @@ function b(s, t, e) {
|
|
|
251
251
|
return s[n] = e, s;
|
|
252
252
|
}
|
|
253
253
|
function tt(s, t, e) {
|
|
254
|
-
return b(s,
|
|
254
|
+
return b(s, P(t), e);
|
|
255
255
|
}
|
|
256
256
|
const m = {
|
|
257
257
|
UndefinedAndNull: function(t) {
|
|
@@ -378,7 +378,7 @@ class U {
|
|
|
378
378
|
n && (r = M(i, t)) && typeof r == "object" ? f(r, e) : b(this.option, t, e), this.updateFullOption();
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
class
|
|
381
|
+
class a extends U {
|
|
382
382
|
constructor(t, e) {
|
|
383
383
|
super(), t && (this.option = t), e && (this.extends = e);
|
|
384
384
|
}
|
|
@@ -407,7 +407,7 @@ class l extends U {
|
|
|
407
407
|
const { extends: e, option: n } = this;
|
|
408
408
|
if (t = n, e) {
|
|
409
409
|
const i = e.plainFullOption;
|
|
410
|
-
t =
|
|
410
|
+
t = _(i, n);
|
|
411
411
|
}
|
|
412
412
|
return this._plainFullOption = t;
|
|
413
413
|
}
|
|
@@ -447,7 +447,7 @@ function et(s, t) {
|
|
|
447
447
|
const { name: e } = t, n = `_${e}`;
|
|
448
448
|
return {
|
|
449
449
|
get: function() {
|
|
450
|
-
return this[n] || (this[n] = new
|
|
450
|
+
return this[n] || (this[n] = new a(void 0, this.constructor[e]));
|
|
451
451
|
}
|
|
452
452
|
};
|
|
453
453
|
}
|
|
@@ -541,7 +541,7 @@ class k extends U {
|
|
|
541
541
|
* @param extend - 继承哪个模式
|
|
542
542
|
*/
|
|
543
543
|
setModeOption(t, e, n, i) {
|
|
544
|
-
const { modes: r } = this, o = r[t] || (r[t] = new
|
|
544
|
+
const { modes: r } = this, o = r[t] || (r[t] = new a());
|
|
545
545
|
if (o.setOption(e, n), i) {
|
|
546
546
|
const u = r[i];
|
|
547
547
|
u && (o.extends = u);
|
|
@@ -549,7 +549,7 @@ class k extends U {
|
|
|
549
549
|
return this.updateFullOption(), o;
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
class
|
|
552
|
+
class d extends k {
|
|
553
553
|
constructor(t, e, n) {
|
|
554
554
|
super(t, e), n && (this.extends = n);
|
|
555
555
|
}
|
|
@@ -574,7 +574,7 @@ class p extends k {
|
|
|
574
574
|
const { modes: e, extends: n } = this, i = e[t]?.plainFullOption;
|
|
575
575
|
if (n) {
|
|
576
576
|
const r = n.getFullModeOption(t);
|
|
577
|
-
return i ?
|
|
577
|
+
return i ? _(r, i) : r;
|
|
578
578
|
}
|
|
579
579
|
return i;
|
|
580
580
|
}
|
|
@@ -642,11 +642,11 @@ function nt(s, t) {
|
|
|
642
642
|
const { name: e } = t, n = `_${e}`;
|
|
643
643
|
return {
|
|
644
644
|
get: function() {
|
|
645
|
-
return this[n] || (this[n] = new
|
|
645
|
+
return this[n] || (this[n] = new d(this.constructor[e].mode, void 0, this.constructor[e]));
|
|
646
646
|
}
|
|
647
647
|
};
|
|
648
648
|
}
|
|
649
|
-
class
|
|
649
|
+
class w extends x {
|
|
650
650
|
/**
|
|
651
651
|
* 是否使用独立的插件管理器
|
|
652
652
|
* @defaultValue false
|
|
@@ -656,9 +656,9 @@ class F extends x {
|
|
|
656
656
|
* 插件管理器
|
|
657
657
|
*/
|
|
658
658
|
static get pluginManager() {
|
|
659
|
-
return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new
|
|
659
|
+
return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new h(this, this._pluginManager)), this._pluginManager;
|
|
660
660
|
}
|
|
661
|
-
static _pluginManager = new
|
|
661
|
+
static _pluginManager = new h(this);
|
|
662
662
|
/**
|
|
663
663
|
* 插件管理器 {@link PluginHost.pluginManager}
|
|
664
664
|
*/
|
|
@@ -729,23 +729,31 @@ class F extends x {
|
|
|
729
729
|
return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
|
-
class st extends
|
|
732
|
+
class st extends w {
|
|
733
|
+
/**
|
|
734
|
+
* 是否使用独立的选项
|
|
735
|
+
* @defaultValue false
|
|
736
|
+
*/
|
|
737
|
+
static isolatedOptions = !1;
|
|
733
738
|
/**
|
|
734
739
|
* 全局级别的默认选项
|
|
735
740
|
*/
|
|
736
|
-
static defaultOptions
|
|
741
|
+
static get defaultOptions() {
|
|
742
|
+
return this.isolatedOptions && !this.hasOwnProperty("_defaultOptions") && (this._defaultOptions = new a(this, this._defaultOptions)), this._defaultOptions;
|
|
743
|
+
}
|
|
744
|
+
static _defaultOptions = new a();
|
|
737
745
|
/**
|
|
738
746
|
* 实例级的默认选项
|
|
739
747
|
*/
|
|
740
748
|
get defaultOptions() {
|
|
741
|
-
return this._defaultOptions || (this._defaultOptions = new
|
|
749
|
+
return this._defaultOptions || (this._defaultOptions = new a(void 0, this.constructor.defaultOptions));
|
|
742
750
|
}
|
|
743
751
|
_defaultOptions;
|
|
744
752
|
constructor(t) {
|
|
745
753
|
super(), this.defaultOptions.option = t;
|
|
746
754
|
}
|
|
747
755
|
}
|
|
748
|
-
function
|
|
756
|
+
function F(s) {
|
|
749
757
|
const t = T(s);
|
|
750
758
|
return class extends t {
|
|
751
759
|
/**
|
|
@@ -757,9 +765,9 @@ function w(s) {
|
|
|
757
765
|
* 插件管理器
|
|
758
766
|
*/
|
|
759
767
|
static get pluginManager() {
|
|
760
|
-
return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new
|
|
768
|
+
return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new h(this, this._pluginManager)), this._pluginManager;
|
|
761
769
|
}
|
|
762
|
-
static _pluginManager = new
|
|
770
|
+
static _pluginManager = new h(this);
|
|
763
771
|
/**
|
|
764
772
|
* 插件管理器 {@link PluginHostSub.pluginManager}
|
|
765
773
|
*/
|
|
@@ -831,17 +839,25 @@ function w(s) {
|
|
|
831
839
|
};
|
|
832
840
|
}
|
|
833
841
|
function ot(s) {
|
|
834
|
-
const t =
|
|
842
|
+
const t = F(s);
|
|
835
843
|
return class extends t {
|
|
844
|
+
/**
|
|
845
|
+
* 是否使用独立的选项
|
|
846
|
+
* @defaultValue false
|
|
847
|
+
*/
|
|
848
|
+
static isolatedOptions = !1;
|
|
836
849
|
/**
|
|
837
850
|
* 全局级别的默认选项
|
|
838
851
|
*/
|
|
839
|
-
static defaultOptions
|
|
852
|
+
static get defaultOptions() {
|
|
853
|
+
return this.isolatedOptions && !this.hasOwnProperty("_defaultOptions") && (this._defaultOptions = new a(this, this._defaultOptions)), this._defaultOptions;
|
|
854
|
+
}
|
|
855
|
+
static _defaultOptions = new a();
|
|
840
856
|
/**
|
|
841
857
|
* 实例级的默认选项
|
|
842
858
|
*/
|
|
843
859
|
get defaultOptions() {
|
|
844
|
-
return this._defaultOptions || (this._defaultOptions = new
|
|
860
|
+
return this._defaultOptions || (this._defaultOptions = new a(void 0, this.constructor.defaultOptions));
|
|
845
861
|
}
|
|
846
862
|
_defaultOptions;
|
|
847
863
|
constructor(n) {
|
|
@@ -849,17 +865,25 @@ function ot(s) {
|
|
|
849
865
|
}
|
|
850
866
|
};
|
|
851
867
|
}
|
|
852
|
-
const
|
|
853
|
-
class ut extends
|
|
868
|
+
const p = "common";
|
|
869
|
+
class ut extends w {
|
|
870
|
+
/**
|
|
871
|
+
* 是否使用独立的选项
|
|
872
|
+
* @defaultValue false
|
|
873
|
+
*/
|
|
874
|
+
static isolatedOptions = !1;
|
|
854
875
|
/**
|
|
855
876
|
* 全局级别的默认选项
|
|
856
877
|
*/
|
|
857
|
-
static modeOptions
|
|
878
|
+
static get modeOptions() {
|
|
879
|
+
return this.isolatedOptions && !this.hasOwnProperty("_modeOptions") && (this._modeOptions = new d(p, null, this._modeOptions)), this._modeOptions;
|
|
880
|
+
}
|
|
881
|
+
static _modeOptions = new d(p);
|
|
858
882
|
/**
|
|
859
883
|
* 实例级的默认选项
|
|
860
884
|
*/
|
|
861
885
|
get modeOptions() {
|
|
862
|
-
return this._modeOptions || (this._modeOptions = new p
|
|
886
|
+
return this._modeOptions || (this._modeOptions = new d(p, void 0, this.constructor.modeOptions));
|
|
863
887
|
}
|
|
864
888
|
_modeOptions;
|
|
865
889
|
get mode() {
|
|
@@ -876,17 +900,25 @@ class ut extends F {
|
|
|
876
900
|
}
|
|
877
901
|
}
|
|
878
902
|
function lt(s) {
|
|
879
|
-
const t =
|
|
903
|
+
const t = F(s);
|
|
880
904
|
return class extends t {
|
|
905
|
+
/**
|
|
906
|
+
* 是否使用独立的选项
|
|
907
|
+
* @defaultValue false
|
|
908
|
+
*/
|
|
909
|
+
static isolatedOptions = !1;
|
|
881
910
|
/**
|
|
882
911
|
* 全局级别的默认选项
|
|
883
912
|
*/
|
|
884
|
-
static modeOptions
|
|
913
|
+
static get modeOptions() {
|
|
914
|
+
return this.isolatedOptions && !this.hasOwnProperty("_modeOptions") && (this._modeOptions = new d(p, null, this._modeOptions)), this._modeOptions;
|
|
915
|
+
}
|
|
916
|
+
static _modeOptions = new d(p);
|
|
885
917
|
/**
|
|
886
918
|
* 实例级的默认选项
|
|
887
919
|
*/
|
|
888
920
|
get modeOptions() {
|
|
889
|
-
return this._modeOptions || (this._modeOptions = new p
|
|
921
|
+
return this._modeOptions || (this._modeOptions = new d(p, void 0, this.constructor.modeOptions));
|
|
890
922
|
}
|
|
891
923
|
_modeOptions;
|
|
892
924
|
get mode() {
|
|
@@ -904,7 +936,7 @@ function lt(s) {
|
|
|
904
936
|
};
|
|
905
937
|
}
|
|
906
938
|
export {
|
|
907
|
-
|
|
939
|
+
P as A,
|
|
908
940
|
G as B,
|
|
909
941
|
b as C,
|
|
910
942
|
tt as D,
|
|
@@ -913,28 +945,28 @@ export {
|
|
|
913
945
|
nt as G,
|
|
914
946
|
et as H,
|
|
915
947
|
k as M,
|
|
916
|
-
|
|
917
|
-
|
|
948
|
+
h as P,
|
|
949
|
+
d as T,
|
|
918
950
|
N as a,
|
|
919
951
|
$ as b,
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
952
|
+
p as c,
|
|
953
|
+
a as d,
|
|
954
|
+
w as e,
|
|
923
955
|
ut as f,
|
|
924
956
|
st as g,
|
|
925
957
|
J as h,
|
|
926
958
|
B as i,
|
|
927
959
|
Y as j,
|
|
928
960
|
q as k,
|
|
929
|
-
|
|
930
|
-
|
|
961
|
+
F as l,
|
|
962
|
+
l as m,
|
|
931
963
|
W as n,
|
|
932
964
|
K as o,
|
|
933
965
|
lt as p,
|
|
934
966
|
ot as q,
|
|
935
967
|
L as r,
|
|
936
968
|
A as s,
|
|
937
|
-
|
|
969
|
+
c as t,
|
|
938
970
|
M as u,
|
|
939
971
|
Z as v,
|
|
940
972
|
X as w,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const x=require("@gby/destroyable"),f=require("deepmerge-ts"),m=require("type-tls"),h=require("com-tools");function a(i,...t){for(const e of t){const n=Object.getOwnPropertyDescriptors(e);Object.defineProperties(i,n)}return i}function E(i,t,e){let n=Object.getOwnPropertyDescriptors(t);return e&&h.omitMembers(n,e),Object.defineProperties(i,n),i}function V(i,t,e){let n=Object.getOwnPropertyDescriptors(t);return e?Object.defineProperties(i,h.removeUndefined(h.pickMembers(n,e))):Object.defineProperties(i,n),i}function N(i,t){return t}function v(i){return function(e){return e}}function H(i,t){return a(i,t),t}function I(i){return function(e){return a(i,e),e}}function k(i,t){return a(i,t),i}function C(i){return function(e){return a(i,e),i}}const T=["onCreate","onInit","onDestroy"];function j(i){const t={...i};for(const e of T)typeof t[e]=="function"&&delete t[e];return t}function U(i,t){let e=Object.getOwnPropertyDescriptors(t);for(const n of T)typeof t[n]=="function"&&delete e[n];return Object.defineProperties(i,e),i}function S(i,t){return t}function B(i){return function(e){return e}}function R(i,t){return a(i.prototype,t),t}function A(i){return function(e){return a(i.prototype,e),e}}function q(i,t){return a(i.prototype,t),i}function z(i){return function(e){return a(i.prototype,e),i}}function w(i){return i&&typeof i.onUse=="function"}const c=Symbol("extend");class g extends x.Destroyable{parent;host;plugins=new Map;constructor(t,e){super(),this.parent=e,t&&(this.host=t)}destroyThis(){return this.plugins.clear(),this.host=null,super.destroyThis()}hasUsed(t){return this.parent?.hasUsed(t)||this.plugins.has(t)}getUseReturn(t){const{parent:e}=this;return e?.hasUsed(t)?e.getUseReturn(t):this.plugins.get(t)}isPlugin(t){return this.hasUsed(t)?this.getUseReturn(t)!==c:w(t)}useExtend(t){return this.hasUsed(t)||(U(this.host.prototype,t),this.plugins.set(t,c)),t}instUseExtend(t,e,...n){return this.hasUsed(e)||(this.useExtend(e),e.onCreate?.call(t,t,...n)),e}usePlugin(t,...e){if(this.hasUsed(t))return this.getUseReturn(t);const n=t.onUse(this.host,...e);return this.plugins.set(t,n),n}instUsePlugin(t,e,...n){if(this.hasUsed(e))return this.getUseReturn(e);const s=this.usePlugin(e,...n);return e.onCreate?.(t),s}onCreate(t,...e){const n=this.parent?.onCreate(t,...e),s=[];for(const[r,o]of this.plugins)if(r.onCreate){const l=o===c?r.onCreate:r.onCreate.bind(r);s.push(l)}return m.waitAsyncable(n,()=>h.serialCallFuns(s,t,[t,...e]))}onInit(t,...e){const n=this.parent?.onInit(t,...e),s=[];for(const[r,o]of this.plugins)if(r.onInit){const l=o===c?r.onInit:r.onInit.bind(r);s.push(l)}return m.waitAsyncable(n,()=>h.serialCallFuns(s,t,[t,...e]))}onDestroy(t){const e=[];for(const[r,o]of this.plugins)if(r.onDestroy){const l=o===c?r.onDestroy:r.onDestroy.bind(r);e.push(l)}e.reverse();const n=h.serialCallFuns(e,t,[t]),{parent:s}=this;return s?m.waitAsyncable(n,()=>s.onDestroy(t)):n}}function y(i){const t=i.split(".");return t[0]===""&&t.shift(),t}function O(i,t){for(const e of t)if(i=i[e],i==null)return;return i}function K(i,t){return O(i,y(t))}function P(i,t,e){const n=t.pop(),s=t.length;let r=0;for(;r<s;){const o=i[t[r]];if(o==null)break;i=o,r++}t=t.slice(r);for(const o of t)i=i[o]={};return i[n]=e,i}function $(i,t,e){return P(i,y(t),e)}const M={UndefinedAndNull:function(t){return t==null},Undefined:function(t){return t===void 0},Null:function(t){return t===null}};class F{freezeMember=!0;fullOption=new Proxy(this,{get:function(t,e,n){const s=t.plainFullOption[e];return t.freezeMember?Object.freeze(s):s},set:function(t,e,n,s){return t.setMember(e,n,!1),!0},has:function(t,e){return e in t.plainFullOption},getOwnPropertyDescriptor:function(t,e){return Object.getOwnPropertyDescriptor(t.plainFullOption,e)},ownKeys:function(t){return Reflect.ownKeys(t.plainFullOption)},deleteProperty:function(t,e){return t.setMember(e,void 0),!0},defineProperty:function(t,e,n){return Object.defineProperty(t.option,e,n),!0}});setOption(t,e){const n=e?f.deepmergeInto(this.option,t):Object.assign(this.option,t);return this.updateFullOption(),n}get undefinedValue(){return this._undefinedValue}set undefinedValue(t){this._undefinedValue=t,this.isUndefined=M[t]||M.UndefinedAndNull}_undefinedValue="UndefinedAndNull";isUndefined=M.UndefinedAndNull;getMember(t){return this.option[t]}setMember(t,e,n){const s=this.option;if(e===void 0)delete s[t];else{const r=s[t];n&&r&&typeof r=="object"?f.deepmergeInto(r,e):s[t]=e}this.updateFullOption()}getValue(t){return O(this.option,t)}setValue(t,e,n){const s=this.option;let r;n&&(r=O(s,t))&&typeof r=="object"?f.deepmergeInto(r,e):P(this.option,t,e),this.updateFullOption()}}class u extends F{constructor(t,e){super(),t&&(this.option=t),e&&(this.extends=e)}get extends(){return this._extends}set extends(t){this._extends=t,this.updateFullOption()}_extends=null;option={};get plainFullOption(){let t=this._plainFullOption;if(t)return t;const{extends:e,option:n}=this;if(t=n,e){const s=e.plainFullOption;t=f.deepmerge(s,n)}return this._plainFullOption=t}_plainFullOption=null;updateFullOption(){this._plainFullOption=null}getMember(t){const e=this.option[t];if(!this.isUndefined(e))return e;const n=this.extends;if(n)return n.getMember(t)}getValue(t){const e=super.getValue(t);if(!this.isUndefined(e))return e;const n=this.extends;if(n)return n.getValue(t)}}function L(i,t){const{name:e}=t,n=`_${e}`;return{get:function(){return this[n]||(this[n]=new u(void 0,this.constructor[e]))}}}class D extends F{constructor(t,e){super(),e&&this.setModeOption(t,e),this.mode=t}modes={};get mode(){return this._mode||(this.mode=this.modeNames[0])}set mode(t){this._mode=t,this.hasMode(t)||this.setModeOption(t,{}),this.updateFullOption()}_mode;get modeNames(){return this._modeNames||(this._modeNames=this.getModeNames())}_modeNames=null;getModeNames(){return Object.keys(this.modes)}hasMode(t){return!!this.modes[t]}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(t){return this.modes[t].option}getFullModeOption(t){return this.modes[t]?.plainFullOption}setModeOption(t,e,n,s){const{modes:r}=this,o=r[t]||(r[t]=new u);if(o.setOption(e,n),s){const l=r[s];l&&(o.extends=l)}return this.updateFullOption(),o}}class d extends D{constructor(t,e,n){super(t,e),n&&(this.extends=n)}get extends(){return this._extends}set extends(t){this._extends=t,this.updateFullOption()}_extends=null;getFullModeOption(t){const{modes:e,extends:n}=this,s=e[t]?.plainFullOption;if(n){const r=n.getFullModeOption(t);return s?f.deepmerge(r,s):r}return s}getModeNames(){const{modes:t,extends:e}=this,n=Object.keys(t);if(!e)return n;const s=e.getModeNames();return[...new Set([...n,...s])]}hasModeOnTier(t){if(this.hasMode(t))return!0;const e=this.extends;return e?e.hasModeOnTier(t):!1}get optionManager(){return this.getModeOptionManager(this.mode)}getModeOptionManager(t){const e=this.modes[t];return e||(this.extends?.getModeOptionManager(t)?this.setModeOption(t,{}):null)}getMember(t){const e=this.optionManager.getMember(t);if(!this.isUndefined(e))return e;const n=this.extends;if(n)return n.getMember(t)}getValue(t){const e=this.optionManager.getValue(t);if(!this.isUndefined(e))return e;const n=this.extends;if(n)return n.getValue(t)}}function G(i,t){const{name:e}=t,n=`_${e}`;return{get:function(){return this[n]||(this[n]=new d(this.constructor[e].mode,void 0,this.constructor[e]))}}}class _ extends x.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(t,...e){return this.pluginManager.usePlugin(t,...e)}static useExtend(t){return this.pluginManager.useExtend(t)}static hasUsed(t){return this.pluginManager.hasUsed(t)}usePlugin(t,...e){return this.pluginManager.instUsePlugin(this,t,...e)}useExtend(t,...e){return this.pluginManager.instUseExtend(this,t,...e)}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 J extends _{static isolatedOptions=!1;static get defaultOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_defaultOptions")&&(this._defaultOptions=new u(this,this._defaultOptions)),this._defaultOptions}static _defaultOptions=new u;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new u(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(t){super(),this.defaultOptions.option=t}}function b(i){const t=x.createDestroyableSubClass(i);return class extends t{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 Q(i){const t=b(i);return class extends t{static isolatedOptions=!1;static get defaultOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_defaultOptions")&&(this._defaultOptions=new u(this,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(),this.defaultOptions.option=n}}}const p="common";class W extends _{static isolatedOptions=!1;static get modeOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_modeOptions")&&(this._modeOptions=new d(p,null,this._modeOptions)),this._modeOptions}static _modeOptions=new d(p);get modeOptions(){return this._modeOptions||(this._modeOptions=new d(p,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(),this.modeOptions.setOption(t)}}function X(i){const t=b(i);return class extends t{static isolatedOptions=!1;static get modeOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_modeOptions")&&(this._modeOptions=new d(p,null,this._modeOptions)),this._modeOptions}static _modeOptions=new d(p);get modeOptions(){return this._modeOptions||(this._modeOptions=new d(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(),this.modeOptions.setOption(n)}}}exports.ModeOptions=D;exports.PluginExtendManager=g;exports.PluginHost=_;exports.TierModeOptions=d;exports.TierModeOptionsPluginHost=W;exports.TierOptions=u;exports.TierOptionsPluginHost=J;exports.commonModeName=p;exports.createDefineIExtend=B;exports.createDefineMixin=v;exports.createIExtendTarget=z;exports.createMixinTarget=C;exports.createPluginHost=b;exports.createTargetIExtend=A;exports.createTargetMixin=I;exports.createTierModeOptionsPluginHost=X;exports.createTierOptionsPluginHost=Q;exports.defineIExtend=S;exports.defineMixin=N;exports.extendMark=c;exports.getPropertyValue=O;exports.getPropertyValueByPath=K;exports.iextendTarget=q;exports.isPlugin=w;exports.mixin=a;exports.mixinByOmit=E;exports.mixinByPick=V;exports.mixinIExtend=U;exports.mixinTarget=k;exports.parsePropertyPath=y;exports.pickHostExtendMembers=j;exports.setPropertyValue=P;exports.setPropertyValueByPath=$;exports.targetIExtend=R;exports.targetMixin=H;exports.tierModeOptionsDecorator=G;exports.tierOptionsDecorator=L;
|
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-D2REw5Vz.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(),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(this,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(),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
|
|
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-Bvne8SqN.js";
|
|
5
|
+
import { f as P, g as D, p as T, q as E } from "./createTierModeOptionsPluginHost-Bvne8SqN.js";
|
|
6
6
|
var p = class extends h {
|
|
7
7
|
refCount = 0;
|
|
8
8
|
get isDestroyed() {
|
|
@@ -69,7 +69,7 @@ var p = class extends h {
|
|
|
69
69
|
return t instanceof Promise ? t.then(() => (i(this), !0)) : (i(this), !0);
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
class
|
|
72
|
+
class u extends p {
|
|
73
73
|
/**
|
|
74
74
|
* 是否使用独立的插件管理器
|
|
75
75
|
* @defaultValue false
|
|
@@ -79,9 +79,9 @@ class a extends p {
|
|
|
79
79
|
* 插件管理器
|
|
80
80
|
*/
|
|
81
81
|
static get pluginManager() {
|
|
82
|
-
return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new
|
|
82
|
+
return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new a(this, this._pluginManager)), this._pluginManager;
|
|
83
83
|
}
|
|
84
|
-
static _pluginManager = new
|
|
84
|
+
static _pluginManager = new a(this);
|
|
85
85
|
/**
|
|
86
86
|
* 插件管理器 {@link PluginHost.pluginManager}
|
|
87
87
|
*/
|
|
@@ -152,16 +152,24 @@ class a extends p {
|
|
|
152
152
|
return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
class f extends
|
|
155
|
+
class f extends u {
|
|
156
|
+
/**
|
|
157
|
+
* 是否使用独立的选项
|
|
158
|
+
* @defaultValue false
|
|
159
|
+
*/
|
|
160
|
+
static isolatedOptions = !1;
|
|
156
161
|
/**
|
|
157
162
|
* 全局级别的默认选项
|
|
158
163
|
*/
|
|
159
|
-
static modeOptions
|
|
164
|
+
static get modeOptions() {
|
|
165
|
+
return this.isolatedOptions && !this.hasOwnProperty("_modeOptions") && (this._modeOptions = new n(r, null, this._modeOptions)), this._modeOptions;
|
|
166
|
+
}
|
|
167
|
+
static _modeOptions = new n(r);
|
|
160
168
|
/**
|
|
161
169
|
* 实例级的默认选项
|
|
162
170
|
*/
|
|
163
171
|
get modeOptions() {
|
|
164
|
-
return this._modeOptions || (this._modeOptions = new n(
|
|
172
|
+
return this._modeOptions || (this._modeOptions = new n(r, void 0, this.constructor.modeOptions));
|
|
165
173
|
}
|
|
166
174
|
_modeOptions;
|
|
167
175
|
get mode() {
|
|
@@ -177,16 +185,24 @@ class f extends a {
|
|
|
177
185
|
super(), this.modeOptions.setOption(t);
|
|
178
186
|
}
|
|
179
187
|
}
|
|
180
|
-
class
|
|
188
|
+
class _ extends u {
|
|
189
|
+
/**
|
|
190
|
+
* 是否使用独立的选项
|
|
191
|
+
* @defaultValue false
|
|
192
|
+
*/
|
|
193
|
+
static isolatedOptions = !1;
|
|
181
194
|
/**
|
|
182
195
|
* 全局级别的默认选项
|
|
183
196
|
*/
|
|
184
|
-
static defaultOptions
|
|
197
|
+
static get defaultOptions() {
|
|
198
|
+
return this.isolatedOptions && !this.hasOwnProperty("_defaultOptions") && (this._defaultOptions = new o(this, this._defaultOptions)), this._defaultOptions;
|
|
199
|
+
}
|
|
200
|
+
static _defaultOptions = new o();
|
|
185
201
|
/**
|
|
186
202
|
* 实例级的默认选项
|
|
187
203
|
*/
|
|
188
204
|
get defaultOptions() {
|
|
189
|
-
return this._defaultOptions || (this._defaultOptions = new
|
|
205
|
+
return this._defaultOptions || (this._defaultOptions = new o(void 0, this.constructor.defaultOptions));
|
|
190
206
|
}
|
|
191
207
|
_defaultOptions;
|
|
192
208
|
constructor(t) {
|
|
@@ -194,12 +210,12 @@ class m extends a {
|
|
|
194
210
|
}
|
|
195
211
|
}
|
|
196
212
|
export {
|
|
197
|
-
|
|
213
|
+
u as PluginHostEventEmitter,
|
|
198
214
|
P as TierModeOptionsPluginHost,
|
|
199
215
|
f as TierModeOptionsPluginHostEventEmitter,
|
|
200
216
|
D as TierOptionsPluginHost,
|
|
201
|
-
|
|
202
|
-
|
|
217
|
+
_ as TierOptionsPluginHostEventEmitter,
|
|
218
|
+
r as commonModeName,
|
|
203
219
|
T as createTierModeOptionsPluginHost,
|
|
204
220
|
E as createTierOptionsPluginHost
|
|
205
221
|
};
|
package/dist/index-web.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./Destroyable-mrBsNabq-IFFuYfKS.cjs"),p=require("com-tools"),i=require("./createTierModeOptionsPluginHost-D2REw5Vz.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 r=n?.times;if(r){const o=typeof s=="function"?s:s?.handleEvent;if(o)return this.multipleListen(t,o,r)}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 r=0;const o=new AbortController,l=o.signal;return super.addEventListener(t,d=>{++r>=n&&o.abort(),s.call(this,d)},{signal:l}),function(){o.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(),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(this,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(),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;
|