plugin-tls 3.0.0 → 3.1.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.
Files changed (123) hide show
  1. package/dist/index.d.ts +1 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +632 -400
  4. package/dist/index.umd.cjs +1 -1
  5. package/dist/options/index.d.ts +4 -0
  6. package/dist/options/index.d.ts.map +1 -0
  7. package/dist/options/options-manager/ModeOptions.d.ts.map +1 -0
  8. package/dist/options/options-manager/OptionsManager.d.ts.map +1 -0
  9. package/dist/options/options-manager/TierModeOptions.d.ts.map +1 -0
  10. package/dist/options/options-manager/TierOptions.d.ts.map +1 -0
  11. package/dist/options/options-manager/defaultOptions.d.ts.map +1 -0
  12. package/dist/options/options-manager/index.d.ts.map +1 -0
  13. package/dist/options/options-manager/tools.d.ts.map +1 -0
  14. package/dist/options/options-plugin-host/index.d.ts.map +1 -0
  15. package/dist/{options-plugin-host → options/options-plugin-host}/tier-mode-options/TierModeOptionsPluginHost.d.ts +3 -3
  16. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts.map +1 -0
  17. package/dist/{options-plugin-host → options/options-plugin-host}/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts +4 -4
  18. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts.map +1 -0
  19. package/dist/{options-plugin-host → options/options-plugin-host}/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts +3 -3
  20. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts.map +1 -0
  21. package/dist/{options-plugin-host → options/options-plugin-host}/tier-mode-options/createTierModeOptionsPluginHost.d.ts +12 -10
  22. package/dist/options/options-plugin-host/tier-mode-options/createTierModeOptionsPluginHost.d.ts.map +1 -0
  23. package/dist/options/options-plugin-host/tier-mode-options/index.d.ts.map +1 -0
  24. package/dist/options/options-plugin-host/tier-mode-options/type.d.ts.map +1 -0
  25. package/dist/{options-plugin-host → options/options-plugin-host}/tier-options/TierOptionsPluginHost.d.ts +3 -3
  26. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts.map +1 -0
  27. package/dist/{options-plugin-host → options/options-plugin-host}/tier-options/TierOptionsPluginHostEventEmitter.d.ts +4 -4
  28. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts.map +1 -0
  29. package/dist/{options-plugin-host → options/options-plugin-host}/tier-options/TierOptionsPluginHostEventTarget.d.ts +3 -3
  30. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts.map +1 -0
  31. package/dist/{options-plugin-host → options/options-plugin-host}/tier-options/createTierOptionsPluginHost.d.ts +12 -10
  32. package/dist/options/options-plugin-host/tier-options/createTierOptionsPluginHost.d.ts.map +1 -0
  33. package/dist/options/options-plugin-host/tier-options/index.d.ts.map +1 -0
  34. package/dist/options/plugins/index.d.ts.map +1 -0
  35. package/dist/{plugins → options/plugins}/tier-mode-options/decorator.d.ts +1 -1
  36. package/dist/options/plugins/tier-mode-options/decorator.d.ts.map +1 -0
  37. package/dist/options/plugins/tier-mode-options/plugin.d.ts +3 -0
  38. package/dist/options/plugins/tier-mode-options/plugin.d.ts.map +1 -0
  39. package/dist/{plugins → options/plugins}/tier-mode-options/type.d.ts +4 -4
  40. package/dist/options/plugins/tier-mode-options/type.d.ts.map +1 -0
  41. package/dist/options/plugins/tier-mode-options-plugin.d.ts.map +1 -0
  42. package/dist/{plugins → options/plugins}/tier-options/decorator.d.ts +1 -1
  43. package/dist/options/plugins/tier-options/decorator.d.ts.map +1 -0
  44. package/dist/{plugins → options/plugins}/tier-options/plugin.d.ts +1 -1
  45. package/dist/options/plugins/tier-options/plugin.d.ts.map +1 -0
  46. package/dist/{plugins → options/plugins}/tier-options/type.d.ts +4 -4
  47. package/dist/options/plugins/tier-options/type.d.ts.map +1 -0
  48. package/dist/options/plugins/tier-options-plugin.d.ts.map +1 -0
  49. package/dist/plugin-host/PluginHost.d.ts +21 -13
  50. package/dist/plugin-host/PluginHost.d.ts.map +1 -1
  51. package/dist/plugin-host/PluginHostEventEmitter.d.ts +21 -13
  52. package/dist/plugin-host/PluginHostEventEmitter.d.ts.map +1 -1
  53. package/dist/plugin-host/PluginHostEventTarget.d.ts +21 -13
  54. package/dist/plugin-host/PluginHostEventTarget.d.ts.map +1 -1
  55. package/dist/plugin-host/createPluginHost.d.ts +22 -14
  56. package/dist/plugin-host/createPluginHost.d.ts.map +1 -1
  57. package/dist/plugin-host/decorator.d.ts +59 -62
  58. package/dist/plugin-host/decorator.d.ts.map +1 -1
  59. package/dist/plugin-host/type.d.ts +21 -8
  60. package/dist/plugin-host/type.d.ts.map +1 -1
  61. package/dist/plugin-manager/ExtendManager.d.ts +66 -0
  62. package/dist/plugin-manager/ExtendManager.d.ts.map +1 -0
  63. package/dist/plugin-manager/IExtend.d.ts +64 -0
  64. package/dist/plugin-manager/IExtend.d.ts.map +1 -0
  65. package/dist/plugin-manager/IPlugin.d.ts +13 -4
  66. package/dist/plugin-manager/IPlugin.d.ts.map +1 -1
  67. package/dist/plugin-manager/PluginExtendManager.d.ts +92 -0
  68. package/dist/plugin-manager/PluginExtendManager.d.ts.map +1 -0
  69. package/dist/plugin-manager/PluginManager.d.ts +14 -14
  70. package/dist/plugin-manager/PluginManager.d.ts.map +1 -1
  71. package/dist/plugin-manager/index.d.ts +5 -1
  72. package/dist/plugin-manager/index.d.ts.map +1 -1
  73. package/dist/plugin-manager/mixin.d.ts.map +1 -0
  74. package/package.json +4 -3
  75. package/dist/extend/extend.d.ts +0 -214
  76. package/dist/extend/extend.d.ts.map +0 -1
  77. package/dist/extend/index.d.ts +0 -3
  78. package/dist/extend/index.d.ts.map +0 -1
  79. package/dist/extend/mixin.d.ts.map +0 -1
  80. package/dist/options-manager/ModeOptions.d.ts.map +0 -1
  81. package/dist/options-manager/OptionsManager.d.ts.map +0 -1
  82. package/dist/options-manager/TierModeOptions.d.ts.map +0 -1
  83. package/dist/options-manager/TierOptions.d.ts.map +0 -1
  84. package/dist/options-manager/defaultOptions.d.ts.map +0 -1
  85. package/dist/options-manager/index.d.ts.map +0 -1
  86. package/dist/options-manager/tools.d.ts.map +0 -1
  87. package/dist/options-plugin-host/index.d.ts.map +0 -1
  88. package/dist/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts.map +0 -1
  89. package/dist/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts.map +0 -1
  90. package/dist/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts.map +0 -1
  91. package/dist/options-plugin-host/tier-mode-options/createTierModeOptionsPluginHost.d.ts.map +0 -1
  92. package/dist/options-plugin-host/tier-mode-options/index.d.ts.map +0 -1
  93. package/dist/options-plugin-host/tier-mode-options/type.d.ts.map +0 -1
  94. package/dist/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts.map +0 -1
  95. package/dist/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts.map +0 -1
  96. package/dist/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts.map +0 -1
  97. package/dist/options-plugin-host/tier-options/createTierOptionsPluginHost.d.ts.map +0 -1
  98. package/dist/options-plugin-host/tier-options/index.d.ts.map +0 -1
  99. package/dist/plugins/index.d.ts.map +0 -1
  100. package/dist/plugins/tier-mode-options/decorator.d.ts.map +0 -1
  101. package/dist/plugins/tier-mode-options/plugin.d.ts +0 -3
  102. package/dist/plugins/tier-mode-options/plugin.d.ts.map +0 -1
  103. package/dist/plugins/tier-mode-options/type.d.ts.map +0 -1
  104. package/dist/plugins/tier-mode-options-plugin.d.ts.map +0 -1
  105. package/dist/plugins/tier-options/decorator.d.ts.map +0 -1
  106. package/dist/plugins/tier-options/plugin.d.ts.map +0 -1
  107. package/dist/plugins/tier-options/type.d.ts.map +0 -1
  108. package/dist/plugins/tier-options-plugin.d.ts.map +0 -1
  109. /package/dist/{options-manager → options/options-manager}/ModeOptions.d.ts +0 -0
  110. /package/dist/{options-manager → options/options-manager}/OptionsManager.d.ts +0 -0
  111. /package/dist/{options-manager → options/options-manager}/TierModeOptions.d.ts +0 -0
  112. /package/dist/{options-manager → options/options-manager}/TierOptions.d.ts +0 -0
  113. /package/dist/{options-manager → options/options-manager}/defaultOptions.d.ts +0 -0
  114. /package/dist/{options-manager → options/options-manager}/index.d.ts +0 -0
  115. /package/dist/{options-manager → options/options-manager}/tools.d.ts +0 -0
  116. /package/dist/{options-plugin-host → options/options-plugin-host}/index.d.ts +0 -0
  117. /package/dist/{options-plugin-host → options/options-plugin-host}/tier-mode-options/index.d.ts +0 -0
  118. /package/dist/{options-plugin-host → options/options-plugin-host}/tier-mode-options/type.d.ts +0 -0
  119. /package/dist/{options-plugin-host → options/options-plugin-host}/tier-options/index.d.ts +0 -0
  120. /package/dist/{plugins → options/plugins}/index.d.ts +0 -0
  121. /package/dist/{plugins → options/plugins}/tier-mode-options-plugin.d.ts +0 -0
  122. /package/dist/{plugins → options/plugins}/tier-options-plugin.d.ts +0 -0
  123. /package/dist/{extend → plugin-manager}/mixin.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,98 +1,51 @@
1
- import { deepmergeInto as m, deepmerge as P } from "deepmerge-ts";
2
- import { Destroyable as T, DestroyableEventEmitter as V, DestroyableEventTarget as I, createDestroyableSubClass as C } from "@gby/destroyable";
3
- function d(n, ...t) {
1
+ import { Destroyable as M, DestroyableEventEmitter as N, DestroyableEventTarget as H, createDestroyableSubClass as V } from "@gby/destroyable";
2
+ import { serialCallFuns as g } from "com-tools";
3
+ import { deepmergeInto as P, deepmerge as w } from "deepmerge-ts";
4
+ function d(s, ...t) {
4
5
  for (const e of t) {
5
- const i = Object.getOwnPropertyDescriptors(e);
6
- Object.defineProperties(n, i);
6
+ const n = Object.getOwnPropertyDescriptors(e);
7
+ Object.defineProperties(s, n);
7
8
  }
8
- return n;
9
+ return s;
9
10
  }
10
- function z(n, t) {
11
+ function B(s, t) {
11
12
  return t;
12
13
  }
13
- function $() {
14
+ function K() {
14
15
  return function(t, e) {
15
16
  return e;
16
17
  };
17
18
  }
18
- function q(n, t) {
19
- return d(n, t), t;
19
+ function R(s, t) {
20
+ return d(s, t), t;
20
21
  }
21
- function B(n) {
22
+ function W(s) {
22
23
  return function(e) {
23
- return d(n, e), e;
24
+ return d(s, e), e;
24
25
  };
25
26
  }
26
- function g(n, t) {
27
- return d(n, t), n;
27
+ function c(s, t) {
28
+ return d(s, t), s;
28
29
  }
29
- function K(n) {
30
+ function G(s) {
30
31
  return function(e) {
31
- return d(n, e), n;
32
+ return d(s, e), s;
32
33
  };
33
34
  }
34
- function R(n, t) {
35
+ const k = ["onCreate", "onInit", "onDestroy"];
36
+ function T(s) {
37
+ const t = { ...s };
38
+ for (const e of k)
39
+ typeof t[e] == "function" && delete t[e];
35
40
  return t;
36
41
  }
37
- function O(n, t) {
38
- d(n.prototype, t);
39
- const e = t._constructor;
40
- typeof e == "function" && (n._constructors ?? (n._constructors = [])).push(e);
41
- const i = t._destroy;
42
- return typeof i == "function" && (n._destroys ?? (n._destroys = [])).push(i), t;
43
- }
44
- function G(n) {
45
- return function(e) {
46
- return O(n, e), e;
47
- };
48
- }
49
- function b(n, t) {
50
- return O(n, t), n;
51
- }
52
- function J(n) {
53
- return function(e) {
54
- return O(n, e), n;
55
- };
56
- }
57
- function M(n, t, e) {
58
- for (const i of n)
59
- i.apply(t, e);
60
- }
61
- function Q(n) {
62
- return {
63
- constructed: function(t, e) {
64
- M(n._constructors ?? [], t, e);
65
- },
66
- initialized: function(t, e) {
67
- M(n._inits ?? [], t, e);
68
- },
69
- destroyed: function(t, e) {
70
- M(n._destroys ?? [], t, e);
71
- }
72
- };
73
- }
74
- function X(n, t) {
42
+ function J(s, t) {
75
43
  return t;
76
44
  }
77
- function x(n, t) {
78
- O(n, t);
79
- const e = t._init;
80
- return typeof e == "function" && (n._inits ?? (n._inits = [])).push(e), t;
45
+ function I(s) {
46
+ return s && typeof s.onUse == "function";
81
47
  }
82
- function Y(n) {
83
- return function(e) {
84
- return x(n, e), e;
85
- };
86
- }
87
- function Z(n, t) {
88
- return x(n, t), n;
89
- }
90
- function L(n) {
91
- return function(e) {
92
- return x(n, e), n;
93
- };
94
- }
95
- class l extends T {
48
+ class L extends M {
96
49
  /**
97
50
  * 插件的宿主
98
51
  */
@@ -108,7 +61,7 @@ class l extends T {
108
61
  super(), t && (this.host = t);
109
62
  }
110
63
  destroyThis() {
111
- return this.plugins.clear(), super.destroyThis();
64
+ return this.plugins.clear(), this.host = null, super.destroyThis();
112
65
  }
113
66
  /**
114
67
  * 使用插件、注册插件
@@ -116,10 +69,23 @@ class l extends T {
116
69
  * @param args - 传递给插件的选项
117
70
  */
118
71
  use(t, ...e) {
72
+ const { plugins: n } = this;
73
+ if (n.has(t)) return n.get(t);
74
+ const i = t.onUse(this.host, ...e);
75
+ return n.set(t, i), i;
76
+ }
77
+ /**
78
+ * 插件宿主实例的注册插件的方法
79
+ *
80
+ * @remarks
81
+ * 会调用每个插件的 {@link IPlugin.use } 方法
82
+ * @param hostInst - 插件宿主的新实例
83
+ */
84
+ instUse(t, e, ...n) {
119
85
  const { plugins: i } = this;
120
- if (i.has(t)) return i.get(t);
121
- const s = t.onUse(this.host, ...e);
122
- return i.set(t, s), s;
86
+ if (i.has(e)) return i.get(e);
87
+ const o = this.use(e, ...n);
88
+ return e.onCreate?.(t), o;
123
89
  }
124
90
  /**
125
91
  * 插件宿主创建实例时调用
@@ -129,11 +95,11 @@ class l extends T {
129
95
  * 如果插件的 created 方法返回 Promise,则会等待 Promise resolve
130
96
  * @param hostInst - 插件宿主的新实例
131
97
  */
132
- async onCreate(t, ...e) {
133
- for (const [i] of this.plugins) {
134
- const s = i.onCreate?.(t, ...e);
135
- s instanceof Promise && await s;
136
- }
98
+ onCreate(t, ...e) {
99
+ const n = [];
100
+ for (const [i] of this.plugins)
101
+ i.onCreate && n.push(i.onCreate.bind(i));
102
+ return g(n, void 0, [t, ...e]);
137
103
  }
138
104
  /**
139
105
  * 插件宿主创建实例时调用
@@ -143,11 +109,11 @@ class l extends T {
143
109
  * @param hostInst - 插件宿主的新实例
144
110
  * @param args - 初始化宿主实例时的参数
145
111
  */
146
- async onInit(t, ...e) {
147
- for (const [i] of this.plugins) {
148
- const s = i.onInit?.(t, ...e);
149
- s instanceof Promise && await s;
150
- }
112
+ onInit(t, ...e) {
113
+ const n = [];
114
+ for (const [i] of this.plugins)
115
+ i.onInit && n.push(i.onInit.bind(i));
116
+ return g(n, void 0, [t, ...e]);
151
117
  }
152
118
  /**
153
119
  * 插件宿主被销毁时调用
@@ -156,11 +122,151 @@ class l extends T {
156
122
  * 会调用每个插件的 {@link IPlugin.onDestroy} 方法
157
123
  * @param hostInst - 被销毁的插件实例
158
124
  */
159
- async onDestroy(t) {
160
- for (const [e] of this.plugins) {
161
- const i = e.onDestroy?.(t);
162
- i instanceof Promise && await i;
163
- }
125
+ onDestroy(t) {
126
+ const e = [];
127
+ for (const [n] of this.plugins)
128
+ n.onDestroy && e.push(n.onDestroy.bind(n));
129
+ return e.reverse(), g(e, void 0, [t]);
130
+ }
131
+ }
132
+ class Q extends M {
133
+ /**
134
+ * 插件的宿主
135
+ */
136
+ host;
137
+ /**
138
+ * 所有注册的插件
139
+ */
140
+ plugins = /* @__PURE__ */ new Set();
141
+ /**
142
+ * @param host - 插件的宿主
143
+ */
144
+ constructor(t) {
145
+ super(), t && (this.host = t);
146
+ }
147
+ destroyThis() {
148
+ return this.plugins.clear(), this.host = null, super.destroyThis();
149
+ }
150
+ /**
151
+ * 使用插件、注册插件
152
+ * @param plugin - 插件
153
+ * @param args - 传递给插件的选项
154
+ */
155
+ use(t) {
156
+ const { plugins: e } = this;
157
+ return e.has(t) ? !1 : (d(this.host.prototype, T(t)), e.add(t), !0);
158
+ }
159
+ /**
160
+ * 插件宿主实例的注册插件的方法
161
+ *
162
+ * @remarks
163
+ * 会调用每个插件的 {@link IExtend.use } 方法
164
+ * @param hostInst - 插件宿主的新实例
165
+ */
166
+ instUse(t, e, ...n) {
167
+ const { plugins: i } = this;
168
+ return i.has(e) ? !1 : (this.use(e), e.onCreate?.call(t, t, ...n), !0);
169
+ }
170
+ /**
171
+ * 插件宿主创建实例时调用
172
+ *
173
+ * @remarks
174
+ * 会调用每个插件的 {@link IExtend.onCreate} 方法
175
+ * 如果插件的 created 方法返回 Promise,则会等待 Promise resolve
176
+ * @param hostInst - 插件宿主的新实例
177
+ */
178
+ onCreate(t, ...e) {
179
+ const n = [];
180
+ for (const i of this.plugins)
181
+ i.onCreate && n.push(i.onCreate);
182
+ return g(n, t, [t, ...e]);
183
+ }
184
+ /**
185
+ * 插件宿主创建实例时调用
186
+ *
187
+ * @remarks
188
+ * 会调用每个插件的 {@link IExtend.onCreate } 方法
189
+ * @param hostInst - 插件宿主的新实例
190
+ * @param args - 初始化宿主实例时的参数
191
+ */
192
+ onInit(t, ...e) {
193
+ const n = [];
194
+ for (const i of this.plugins)
195
+ i.onInit && n.push(i.onInit);
196
+ return g(n, t, [t, ...e]);
197
+ }
198
+ /**
199
+ * 插件宿主被销毁时调用
200
+ *
201
+ * @remarks
202
+ * 会调用每个插件的 {@link IExtend.onDestroy} 方法
203
+ * @param hostInst - 被销毁的插件实例
204
+ */
205
+ onDestroy(t) {
206
+ const e = [];
207
+ for (const n of this.plugins)
208
+ n.onDestroy && e.push(n.onDestroy);
209
+ return e.reverse(), g(e, t, [t]);
210
+ }
211
+ }
212
+ const O = /* @__PURE__ */ Symbol("extend");
213
+ class p extends M {
214
+ /**
215
+ * 插件的宿主
216
+ */
217
+ host;
218
+ /**
219
+ * 所有注册的插件
220
+ */
221
+ plugins = /* @__PURE__ */ new Map();
222
+ /**
223
+ * @param host - 插件的宿主
224
+ */
225
+ constructor(t) {
226
+ super(), t && (this.host = t);
227
+ }
228
+ destroyThis() {
229
+ return this.plugins.clear(), this.host = null, super.destroyThis();
230
+ }
231
+ /**
232
+ * 判断一个对象是否是插件
233
+ * @param target
234
+ * @returns
235
+ */
236
+ isPlugin(t) {
237
+ const { plugins: e } = this;
238
+ return e.has(t) ? e.get(t) !== O : I(t);
239
+ }
240
+ /**
241
+ * 使用插件、注册插件
242
+ * @param ext - 插件
243
+ * @param args - 传递给插件的选项
244
+ */
245
+ useExtend(t) {
246
+ const { plugins: e } = this;
247
+ return e.has(t) ? !1 : (d(this.host.prototype, T(t)), e.set(t, O), !0);
248
+ }
249
+ /**
250
+ * 插件宿主实例的注册插件的方法
251
+ *
252
+ * @remarks
253
+ * 会调用每个插件的 {@link IExtend.use } 方法
254
+ * @param hostInst - 插件宿主的新实例
255
+ */
256
+ instUseExtend(t, e, ...n) {
257
+ const { plugins: i } = this;
258
+ return i.has(e) ? !1 : (this.useExtend(e), e.onCreate?.call(t, t, ...n), !0);
259
+ }
260
+ /**
261
+ * 使用插件、注册插件
262
+ * @param plugin - 插件
263
+ * @param args - 传递给插件的选项
264
+ */
265
+ usePlugin(t, ...e) {
266
+ const { plugins: n } = this;
267
+ if (n.has(t)) return n.get(t);
268
+ const i = t.onUse(this.host, ...e);
269
+ return n.set(t, i), i;
164
270
  }
165
271
  /**
166
272
  * 插件宿主实例的注册插件的方法
@@ -169,74 +275,124 @@ class l extends T {
169
275
  * 会调用每个插件的 {@link IPlugin.use } 方法
170
276
  * @param hostInst - 插件宿主的新实例
171
277
  */
172
- instUse(t, e, ...i) {
173
- const { plugins: s } = this;
174
- if (s.has(e)) return s.get(e);
175
- const o = this.use(e, ...i);
278
+ instUsePlugin(t, e, ...n) {
279
+ const { plugins: i } = this;
280
+ if (i.has(e)) return i.get(e);
281
+ const o = this.usePlugin(e, ...n);
176
282
  return e.onCreate?.(t), o;
177
283
  }
284
+ /**
285
+ * 插件宿主创建实例时调用
286
+ *
287
+ * @remarks
288
+ * 会调用每个插件的 {@link IPlugin.onCreate} 方法
289
+ * 如果插件的 created 方法返回 Promise,则会等待 Promise resolve
290
+ * @param hostInst - 插件宿主的新实例
291
+ */
292
+ onCreate(t, ...e) {
293
+ const n = [];
294
+ for (const [i, o] of this.plugins)
295
+ if (i.onCreate) {
296
+ const r = o === O ? i.onCreate : i.onCreate.bind(i);
297
+ n.push(r);
298
+ }
299
+ return g(n, t, [t, ...e]);
300
+ }
301
+ /**
302
+ * 插件宿主创建实例时调用
303
+ *
304
+ * @remarks
305
+ * 会调用每个插件的 {@link IPlugin.onCreate } 方法
306
+ * @param hostInst - 插件宿主的新实例
307
+ * @param args - 初始化宿主实例时的参数
308
+ */
309
+ onInit(t, ...e) {
310
+ const n = [];
311
+ for (const [i, o] of this.plugins)
312
+ if (i.onInit) {
313
+ const r = o === O ? i.onInit : i.onInit.bind(i);
314
+ n.push(r);
315
+ }
316
+ return g(n, t, [t, ...e]);
317
+ }
318
+ /**
319
+ * 插件宿主被销毁时调用
320
+ *
321
+ * @remarks
322
+ * 会调用每个插件的 {@link IPlugin.onDestroy} 方法
323
+ * @param hostInst - 被销毁的插件实例
324
+ */
325
+ onDestroy(t) {
326
+ const e = [];
327
+ for (const [n, i] of this.plugins)
328
+ if (n.onDestroy) {
329
+ const o = i === O ? n.onDestroy : n.onDestroy.bind(n);
330
+ e.push(o);
331
+ }
332
+ return e.reverse(), g(e, t, [t]);
333
+ }
178
334
  }
179
- function tt(n, t) {
180
- const e = t ?? "defaultOptions", i = `_${e}`;
335
+ function X(s, t) {
336
+ const e = t ?? "defaultOptions", n = `_${e}`;
181
337
  return function(o) {
182
- const r = g(o, {
338
+ const r = c(o, {
183
339
  /**
184
340
  * 全局级别的默认选项
185
341
  */
186
342
  get [e]() {
187
- return n;
343
+ return s;
188
344
  }
189
345
  });
190
- b(r, {
346
+ c(r.prototype, {
191
347
  /**
192
348
  * 实例级的默认选项
193
349
  */
194
350
  get [e]() {
195
- return this[i] || (this[i] = structuredClone(r.defaultOptions));
351
+ return this[n] || (this[n] = structuredClone(r.defaultOptions));
196
352
  }
197
353
  });
198
354
  };
199
355
  }
200
- function et(n, t, e) {
201
- const i = `_${t}`;
202
- return b(n, {
356
+ function Y(s, t, e) {
357
+ const n = `_${t}`;
358
+ return c(s.prototype, {
203
359
  /**
204
360
  * 实例级的默认选项
205
361
  */
206
362
  get [t]() {
207
- return this[i] || (this[i] = structuredClone(n[t]));
363
+ return this[n] || (this[n] = structuredClone(s[t]));
208
364
  }
209
365
  }), e;
210
366
  }
211
- function v(n) {
212
- const t = n.split(".");
367
+ function b(s) {
368
+ const t = s.split(".");
213
369
  return t[0] === "" && t.shift(), t;
214
370
  }
215
- function y(n, t) {
371
+ function y(s, t) {
216
372
  for (const e of t)
217
- if (n = n[e], n == null) return;
218
- return n;
373
+ if (s = s[e], s == null) return;
374
+ return s;
219
375
  }
220
- function nt(n, t) {
221
- return y(n, v(t));
376
+ function Z(s, t) {
377
+ return y(s, b(t));
222
378
  }
223
- function F(n, t, e) {
224
- const i = t.pop(), s = t.length;
379
+ function E(s, t, e) {
380
+ const n = t.pop(), i = t.length;
225
381
  let o = 0;
226
- for (; o < s; ) {
227
- const r = n[t[o]];
382
+ for (; o < i; ) {
383
+ const r = s[t[o]];
228
384
  if (r == null) break;
229
- n = r, o++;
385
+ s = r, o++;
230
386
  }
231
387
  t = t.slice(o);
232
388
  for (const r of t)
233
- n = n[r] = {};
234
- return n[i] = e, n;
389
+ s = s[r] = {};
390
+ return s[n] = e, s;
235
391
  }
236
- function it(n, t, e) {
237
- return F(n, v(t), e);
392
+ function tt(s, t, e) {
393
+ return E(s, b(t), e);
238
394
  }
239
- const _ = {
395
+ const x = {
240
396
  UndefinedAndNull: function(t) {
241
397
  return t == null;
242
398
  },
@@ -247,7 +403,7 @@ const _ = {
247
403
  return t === null;
248
404
  }
249
405
  };
250
- class E {
406
+ class v {
251
407
  /**
252
408
  * 是否要冻结 fullOption 的成员
253
409
  * @remarks
@@ -262,13 +418,13 @@ class E {
262
418
  */
263
419
  fullOption = new Proxy(this, {
264
420
  // @ts-ignore
265
- get: function(t, e, i) {
266
- const s = t.plainFullOption[e];
267
- return t.freezeMember ? Object.freeze(s) : s;
421
+ get: function(t, e, n) {
422
+ const i = t.plainFullOption[e];
423
+ return t.freezeMember ? Object.freeze(i) : i;
268
424
  },
269
425
  // @ts-ignore
270
- set: function(t, e, i, s) {
271
- return t.setMember(e, i, !1), !0;
426
+ set: function(t, e, n, i) {
427
+ return t.setMember(e, n, !1), !0;
272
428
  },
273
429
  // @ts-ignore
274
430
  has: function(t, e) {
@@ -287,8 +443,8 @@ class E {
287
443
  return t.setMember(e, void 0), !0;
288
444
  },
289
445
  // @ts-ignore
290
- defineProperty: function(t, e, i) {
291
- return Object.defineProperty(t.option, e, i), !0;
446
+ defineProperty: function(t, e, n) {
447
+ return Object.defineProperty(t.option, e, n), !0;
292
448
  }
293
449
  });
294
450
  /**
@@ -299,8 +455,8 @@ class E {
299
455
  * @param deep - 是否要进行深度合并
300
456
  */
301
457
  setOption(t, e) {
302
- const i = e ? m(this.option, t) : Object.assign(this.option, t);
303
- return this.updateFullOption(), i;
458
+ const n = e ? P(this.option, t) : Object.assign(this.option, t);
459
+ return this.updateFullOption(), n;
304
460
  }
305
461
  /**
306
462
  * 未定义值的类型
@@ -309,13 +465,13 @@ class E {
309
465
  return this._undefinedValue;
310
466
  }
311
467
  set undefinedValue(t) {
312
- this._undefinedValue = t, this.isUndefined = _[t] || _.UndefinedAndNull;
468
+ this._undefinedValue = t, this.isUndefined = x[t] || x.UndefinedAndNull;
313
469
  }
314
470
  _undefinedValue = "UndefinedAndNull";
315
471
  /**
316
472
  * 未定义值的判断函数
317
473
  */
318
- isUndefined = _.UndefinedAndNull;
474
+ isUndefined = x.UndefinedAndNull;
319
475
  /**
320
476
  * 获取选项成员
321
477
  * @param key
@@ -330,13 +486,13 @@ class E {
330
486
  * @param value
331
487
  * @param deep - 是否要进行深度合并
332
488
  */
333
- setMember(t, e, i) {
334
- const s = this.option;
489
+ setMember(t, e, n) {
490
+ const i = this.option;
335
491
  if (e === void 0)
336
- delete s[t];
492
+ delete i[t];
337
493
  else {
338
- const o = s[t];
339
- i && o && typeof o == "object" ? m(o, e) : s[t] = e;
494
+ const o = i[t];
495
+ n && o && typeof o == "object" ? P(o, e) : i[t] = e;
340
496
  }
341
497
  this.updateFullOption();
342
498
  }
@@ -355,13 +511,13 @@ class E {
355
511
  * @param deep - 是否要进行深度合并
356
512
  * @returns
357
513
  */
358
- setValue(t, e, i) {
359
- const s = this.option;
514
+ setValue(t, e, n) {
515
+ const i = this.option;
360
516
  let o;
361
- i && (o = y(s, t)) && typeof o == "object" ? m(o, e) : F(this.option, t, e), this.updateFullOption();
517
+ n && (o = y(i, t)) && typeof o == "object" ? P(o, e) : E(this.option, t, e), this.updateFullOption();
362
518
  }
363
519
  }
364
- class u extends E {
520
+ class u extends v {
365
521
  constructor(t, e) {
366
522
  super(), t && (this.option = t), e && (this.extends = e);
367
523
  }
@@ -387,10 +543,10 @@ class u extends E {
387
543
  get plainFullOption() {
388
544
  let t = this._plainFullOption;
389
545
  if (t) return t;
390
- const { extends: e, option: i } = this;
391
- if (t = i, e) {
392
- const s = e.plainFullOption;
393
- t = P(s, i);
546
+ const { extends: e, option: n } = this;
547
+ if (t = n, e) {
548
+ const i = e.plainFullOption;
549
+ t = w(i, n);
394
550
  }
395
551
  return this._plainFullOption = t;
396
552
  }
@@ -409,9 +565,9 @@ class u extends E {
409
565
  getMember(t) {
410
566
  const e = this.option[t];
411
567
  if (!this.isUndefined(e)) return e;
412
- const i = this.extends;
413
- if (i)
414
- return i.getMember(t);
568
+ const n = this.extends;
569
+ if (n)
570
+ return n.getMember(t);
415
571
  }
416
572
  /**
417
573
  * 获取属性路径对应的值
@@ -421,20 +577,20 @@ class u extends E {
421
577
  getValue(t) {
422
578
  const e = super.getValue(t);
423
579
  if (!this.isUndefined(e)) return e;
424
- const i = this.extends;
425
- if (i)
426
- return i.getValue(t);
580
+ const n = this.extends;
581
+ if (n)
582
+ return n.getValue(t);
427
583
  }
428
584
  }
429
- function st(n, t) {
430
- const { name: e } = t, i = `_${e}`;
585
+ function et(s, t) {
586
+ const { name: e } = t, n = `_${e}`;
431
587
  return {
432
588
  get: function() {
433
- return this[i] || (this[i] = new u(void 0, this.constructor[e]));
589
+ return this[n] || (this[n] = new u(void 0, this.constructor[e]));
434
590
  }
435
591
  };
436
592
  }
437
- class j extends E {
593
+ class S extends v {
438
594
  constructor(t, e) {
439
595
  super(), e && this.setModeOption(t, e), this.mode = t;
440
596
  }
@@ -523,18 +679,18 @@ class j extends E {
523
679
  * @param deep - 是否要进行深度合并
524
680
  * @param extend - 继承哪个模式
525
681
  */
526
- setModeOption(t, e, i, s) {
682
+ setModeOption(t, e, n, i) {
527
683
  const { modes: o } = this, r = o[t] || (o[t] = new u());
528
- if (r.setOption(e, i), s) {
529
- const p = o[s];
530
- p && (r.extends = p);
684
+ if (r.setOption(e, n), i) {
685
+ const l = o[i];
686
+ l && (r.extends = l);
531
687
  }
532
688
  return this.updateFullOption(), r;
533
689
  }
534
690
  }
535
- class a extends j {
536
- constructor(t, e, i) {
537
- super(t, e), i && (this.extends = i);
691
+ class a extends S {
692
+ constructor(t, e, n) {
693
+ super(t, e), n && (this.extends = n);
538
694
  }
539
695
  /**
540
696
  * 继承的选项
@@ -554,22 +710,22 @@ class a extends j {
554
710
  * @returns
555
711
  */
556
712
  getFullModeOption(t) {
557
- const { modes: e, extends: i } = this, s = e[t]?.plainFullOption;
558
- if (i) {
559
- const o = i.getFullModeOption(t);
560
- return s ? P(o, s) : o;
713
+ const { modes: e, extends: n } = this, i = e[t]?.plainFullOption;
714
+ if (n) {
715
+ const o = n.getFullModeOption(t);
716
+ return i ? w(o, i) : o;
561
717
  }
562
- return s;
718
+ return i;
563
719
  }
564
720
  /**
565
721
  * 获取所有的模式名字
566
722
  * @returns
567
723
  */
568
724
  getModeNames() {
569
- const { modes: t, extends: e } = this, i = Object.keys(t);
570
- if (!e) return i;
571
- const s = e.getModeNames();
572
- return [.../* @__PURE__ */ new Set([...i, ...s])];
725
+ const { modes: t, extends: e } = this, n = Object.keys(t);
726
+ if (!e) return n;
727
+ const i = e.getModeNames();
728
+ return [.../* @__PURE__ */ new Set([...n, ...i])];
573
729
  }
574
730
  /**
575
731
  * 在整个层级上判断是否有某个模式
@@ -604,9 +760,9 @@ class a extends j {
604
760
  getMember(t) {
605
761
  const e = this.optionManager.getMember(t);
606
762
  if (!this.isUndefined(e)) return e;
607
- const i = this.extends;
608
- if (i)
609
- return i.getMember(t);
763
+ const n = this.extends;
764
+ if (n)
765
+ return n.getMember(t);
610
766
  }
611
767
  /**
612
768
  * 获取属性路径对应的值
@@ -616,20 +772,20 @@ class a extends j {
616
772
  getValue(t) {
617
773
  const e = this.optionManager.getValue(t);
618
774
  if (!this.isUndefined(e)) return e;
619
- const i = this.extends;
620
- if (i)
621
- return i.getValue(t);
775
+ const n = this.extends;
776
+ if (n)
777
+ return n.getValue(t);
622
778
  }
623
779
  }
624
- function ot(n, t) {
625
- const { name: e } = t, i = `_${e}`;
780
+ function nt(s, t) {
781
+ const { name: e } = t, n = `_${e}`;
626
782
  return {
627
783
  get: function() {
628
- return this[i] || (this[i] = new a(this.constructor[e].mode, void 0, this.constructor[e]));
784
+ return this[n] || (this[n] = new a(this.constructor[e].mode, void 0, this.constructor[e]));
629
785
  }
630
786
  };
631
787
  }
632
- class U extends T {
788
+ class F extends M {
633
789
  /**
634
790
  * 是否使用独立的插件管理器
635
791
  * @defaultValue false
@@ -639,9 +795,9 @@ class U extends T {
639
795
  * 插件管理器
640
796
  */
641
797
  static get pluginManager() {
642
- return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new l(this)), this._pluginManager;
798
+ return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new p(this)), this._pluginManager;
643
799
  }
644
- static _pluginManager = new l(this);
800
+ static _pluginManager = new p(this);
645
801
  /**
646
802
  * 插件管理器 {@link PluginHost.pluginManager}
647
803
  */
@@ -649,10 +805,16 @@ class U extends T {
649
805
  return this.constructor.pluginManager;
650
806
  }
651
807
  /**
652
- * {@inheritDoc PluginManager.use}
808
+ * {@inheritDoc PluginExtendManager.usePlugin}
653
809
  */
654
- static use(t, ...e) {
655
- return this.pluginManager.use(t, ...e);
810
+ static usePlugin(t, ...e) {
811
+ return this.pluginManager.usePlugin(t, ...e);
812
+ }
813
+ /**
814
+ * {@inheritDoc PluginExtendManager.useExtend}
815
+ */
816
+ static useExtend(t) {
817
+ return this.pluginManager.useExtend(t);
656
818
  }
657
819
  /**
658
820
  * 需要在子类中调用
@@ -671,13 +833,19 @@ class U extends T {
671
833
  * @param args
672
834
  * @returns
673
835
  */
674
- use(t, ...e) {
675
- return this.pluginManager.instUse(this, t, ...e);
836
+ usePlugin(t, ...e) {
837
+ return this.pluginManager.instUsePlugin(this, t, ...e);
838
+ }
839
+ /**
840
+ * {@inheritDoc PluginExtendManager.useExtend}
841
+ */
842
+ useExtend(t, ...e) {
843
+ return this.pluginManager.instUseExtend(this, t, ...e);
676
844
  }
677
845
  /**
678
846
  * 初始化实例
679
847
  * @remarks
680
- * 会调用 {@link PluginManager.onInit}
848
+ * 会调用 {@link PluginExtendManager.onInit}
681
849
  * @param args
682
850
  */
683
851
  init(...t) {
@@ -687,11 +855,12 @@ class U extends T {
687
855
  * 销毁实例
688
856
  * @returns
689
857
  */
690
- async destroyThis() {
691
- return await this.pluginManager.onDestroy(this), super.destroyThis();
858
+ destroyThis() {
859
+ const t = this.pluginManager.onDestroy(this);
860
+ return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
692
861
  }
693
862
  }
694
- class N extends V {
863
+ class U extends N {
695
864
  /**
696
865
  * 是否使用独立的插件管理器
697
866
  * @defaultValue false
@@ -701,9 +870,9 @@ class N extends V {
701
870
  * 插件管理器
702
871
  */
703
872
  static get pluginManager() {
704
- return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new l(this)), this._pluginManager;
873
+ return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new p(this)), this._pluginManager;
705
874
  }
706
- static _pluginManager = new l(this);
875
+ static _pluginManager = new p(this);
707
876
  /**
708
877
  * 插件管理器 {@link PluginHost.pluginManager}
709
878
  */
@@ -711,10 +880,16 @@ class N extends V {
711
880
  return this.constructor.pluginManager;
712
881
  }
713
882
  /**
714
- * {@inheritDoc PluginManager.use}
883
+ * {@inheritDoc PluginExtendManager.usePlugin}
715
884
  */
716
- static use(t, ...e) {
717
- return this.pluginManager.use(t, ...e);
885
+ static usePlugin(t, ...e) {
886
+ return this.pluginManager.usePlugin(t, ...e);
887
+ }
888
+ /**
889
+ * {@inheritDoc PluginExtendManager.useExtend}
890
+ */
891
+ static useExtend(t) {
892
+ return this.pluginManager.useExtend(t);
718
893
  }
719
894
  /**
720
895
  * 需要在子类中调用
@@ -733,13 +908,19 @@ class N extends V {
733
908
  * @param args
734
909
  * @returns
735
910
  */
736
- use(t, ...e) {
737
- return this.pluginManager.instUse(this, t, ...e);
911
+ usePlugin(t, ...e) {
912
+ return this.pluginManager.instUsePlugin(this, t, ...e);
913
+ }
914
+ /**
915
+ * {@inheritDoc PluginExtendManager.useExtend}
916
+ */
917
+ useExtend(t, ...e) {
918
+ return this.pluginManager.instUseExtend(this, t, ...e);
738
919
  }
739
920
  /**
740
921
  * 初始化实例
741
922
  * @remarks
742
- * 会调用 {@link PluginManager.onInit}
923
+ * 会调用 {@link PluginExtendManager.onInit}
743
924
  * @param args
744
925
  */
745
926
  init(...t) {
@@ -749,11 +930,12 @@ class N extends V {
749
930
  * 销毁实例
750
931
  * @returns
751
932
  */
752
- async destroyThis() {
753
- return await this.pluginManager.onDestroy(this), super.destroyThis();
933
+ destroyThis() {
934
+ const t = this.pluginManager.onDestroy(this);
935
+ return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
754
936
  }
755
937
  }
756
- class D extends I {
938
+ class D extends H {
757
939
  /**
758
940
  * 是否使用独立的插件管理器
759
941
  * @defaultValue false
@@ -763,9 +945,9 @@ class D extends I {
763
945
  * 插件管理器
764
946
  */
765
947
  static get pluginManager() {
766
- return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new l(this)), this._pluginManager;
948
+ return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new p(this)), this._pluginManager;
767
949
  }
768
- static _pluginManager = new l(this);
950
+ static _pluginManager = new p(this);
769
951
  /**
770
952
  * 插件管理器 {@link PluginHost.pluginManager}
771
953
  */
@@ -773,10 +955,16 @@ class D extends I {
773
955
  return this.constructor.pluginManager;
774
956
  }
775
957
  /**
776
- * {@inheritDoc PluginManager.use}
958
+ * {@inheritDoc PluginExtendManager.usePlugin}
777
959
  */
778
- static use(t, ...e) {
779
- return this.pluginManager.use(t, ...e);
960
+ static usePlugin(t, ...e) {
961
+ return this.pluginManager.usePlugin(t, ...e);
962
+ }
963
+ /**
964
+ * {@inheritDoc PluginExtendManager.useExtend}
965
+ */
966
+ static useExtend(t) {
967
+ return this.pluginManager.useExtend(t);
780
968
  }
781
969
  /**
782
970
  * 需要在子类中调用
@@ -795,13 +983,19 @@ class D extends I {
795
983
  * @param args
796
984
  * @returns
797
985
  */
798
- use(t, ...e) {
799
- return this.pluginManager.instUse(this, t, ...e);
986
+ usePlugin(t, ...e) {
987
+ return this.pluginManager.instUsePlugin(this, t, ...e);
988
+ }
989
+ /**
990
+ * {@inheritDoc PluginExtendManager.useExtend}
991
+ */
992
+ useExtend(t, ...e) {
993
+ return this.pluginManager.instUseExtend(this, t, ...e);
800
994
  }
801
995
  /**
802
996
  * 初始化实例
803
997
  * @remarks
804
- * 会调用 {@link PluginManager.onInit}
998
+ * 会调用 {@link PluginExtendManager.onInit}
805
999
  * @param args
806
1000
  */
807
1001
  init(...t) {
@@ -811,12 +1005,13 @@ class D extends I {
811
1005
  * 销毁实例
812
1006
  * @returns
813
1007
  */
814
- async destroyThis() {
815
- return await this.pluginManager.onDestroy(this), super.destroyThis();
1008
+ destroyThis() {
1009
+ const t = this.pluginManager.onDestroy(this);
1010
+ return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
816
1011
  }
817
1012
  }
818
- function H(n) {
819
- const t = C(n);
1013
+ function C(s) {
1014
+ const t = V(s);
820
1015
  return class extends t {
821
1016
  /**
822
1017
  * 是否使用独立的插件管理器
@@ -827,9 +1022,9 @@ function H(n) {
827
1022
  * 插件管理器
828
1023
  */
829
1024
  static get pluginManager() {
830
- return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new l(this)), this._pluginManager;
1025
+ return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new p(this)), this._pluginManager;
831
1026
  }
832
- static _pluginManager = new l(this);
1027
+ static _pluginManager = new p(this);
833
1028
  /**
834
1029
  * 插件管理器 {@link PluginHostSub.pluginManager}
835
1030
  */
@@ -837,10 +1032,16 @@ function H(n) {
837
1032
  return this.constructor.pluginManager;
838
1033
  }
839
1034
  /**
840
- * {@inheritDoc PluginManager.use}
1035
+ * {@inheritDoc PluginExtendManager.usePlugin}
1036
+ */
1037
+ static usePlugin(n, ...i) {
1038
+ return this.pluginManager.usePlugin(n, ...i);
1039
+ }
1040
+ /**
1041
+ * {@inheritDoc PluginExtendManager.useExtend}
841
1042
  */
842
- static use(i, ...s) {
843
- return this.pluginManager.use(i, ...s);
1043
+ static useExtend(n) {
1044
+ return this.pluginManager.useExtend(n);
844
1045
  }
845
1046
  /**
846
1047
  * 需要在子类中调用
@@ -858,29 +1059,36 @@ function H(n) {
858
1059
  * @param args
859
1060
  * @returns
860
1061
  */
861
- use(i, ...s) {
862
- return this.pluginManager.instUse(this, i, ...s);
1062
+ usePlugin(n, ...i) {
1063
+ return this.pluginManager.instUsePlugin(this, n, ...i);
1064
+ }
1065
+ /**
1066
+ * {@inheritDoc PluginExtendManager.useExtend}
1067
+ */
1068
+ useExtend(n, ...i) {
1069
+ return this.pluginManager.instUseExtend(this, n, ...i);
863
1070
  }
864
1071
  /**
865
1072
  * 初始化实例
866
1073
  * @remarks
867
- * 会调用 {@link PluginManager.onInit}
1074
+ * 会调用 {@link PluginExtendManager.onInit}
868
1075
  * @param args
869
1076
  */
870
- init(...i) {
871
- return this.pluginManager.onInit(this, ...i);
1077
+ init(...n) {
1078
+ return this.pluginManager.onInit(this, ...n);
872
1079
  }
873
1080
  /**
874
1081
  * 销毁实例
875
1082
  * @returns
876
1083
  */
877
- async destroyThis() {
878
- return await this.pluginManager.onDestroy(this), super.destroyThis();
1084
+ destroyThis() {
1085
+ const n = this.pluginManager.onDestroy(this);
1086
+ return n instanceof Promise ? n.finally(() => super.destroyThis()) : super.destroyThis();
879
1087
  }
880
1088
  };
881
1089
  }
882
- function S(n) {
883
- const t = g(n, {
1090
+ function j(s) {
1091
+ const t = c(s, {
884
1092
  /**
885
1093
  * 是否使用独立的插件管理器
886
1094
  * @defaultValue false
@@ -890,17 +1098,23 @@ function S(n) {
890
1098
  * PluginHost 的插件管理器
891
1099
  */
892
1100
  get pluginManager() {
893
- return (!this._pluginManager || this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager")) && (this._pluginManager = new l(this)), this._pluginManager;
1101
+ return (!this._pluginManager || this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager")) && (this._pluginManager = new p(this)), this._pluginManager;
894
1102
  },
895
1103
  // _pluginManager: PluginManager<HOST,Plugin>;
896
1104
  /**
897
- * {@inheritDoc PluginManager.use}
1105
+ * {@inheritDoc PluginExtendManager.usePlugin}
898
1106
  */
899
- use(e, ...i) {
900
- return this.pluginManager.use(e, ...i);
1107
+ usePlugin(e, ...n) {
1108
+ return this.pluginManager.usePlugin(e, ...n);
1109
+ },
1110
+ /**
1111
+ * {@inheritDoc PluginExtendManager.useExtend}
1112
+ */
1113
+ useExtend(e) {
1114
+ return this.pluginManager.useExtend(e);
901
1115
  }
902
1116
  });
903
- return g(t.prototype, {
1117
+ return c(t.prototype, {
904
1118
  /**
905
1119
  * 插件管理器
906
1120
  */
@@ -913,8 +1127,14 @@ function S(n) {
913
1127
  * @param options
914
1128
  * @returns
915
1129
  */
916
- use(e, ...i) {
917
- return this.pluginManager.instUse(this, e, ...i);
1130
+ usePlugin(e, ...n) {
1131
+ return this.pluginManager.instUsePlugin(this, e, ...n);
1132
+ },
1133
+ /**
1134
+ * {@inheritDoc PluginExtendManager.useExtend}
1135
+ */
1136
+ useExtend(e, ...n) {
1137
+ return this.pluginManager.instUseExtend(this, e, ...n);
918
1138
  },
919
1139
  /**
920
1140
  * 初始化实例
@@ -930,19 +1150,19 @@ function S(n) {
930
1150
  async destroy() {
931
1151
  if (await this.pluginManager.onDestroy(this), super.destroy) return super.destroy();
932
1152
  }
933
- }), n;
1153
+ }), s;
934
1154
  }
935
- function ut(n) {
936
- const t = S(n);
1155
+ function it(s) {
1156
+ const t = j(s);
937
1157
  return new Proxy(t, {
938
- construct: function(e, i, s) {
939
- const o = new e(...i);
940
- return t.pluginManager.onCreate(this, ...i), o;
1158
+ construct: function(e, n, i) {
1159
+ const o = new e(...n);
1160
+ return t.pluginManager.onCreate(this, ...n), o;
941
1161
  }
942
1162
  });
943
1163
  }
944
- function pt(n) {
945
- return class extends n {
1164
+ function rt(s) {
1165
+ return class extends s {
946
1166
  /**
947
1167
  * 是否使用独立的插件管理器
948
1168
  * @defaultValue false
@@ -952,9 +1172,9 @@ function pt(n) {
952
1172
  * 插件管理器
953
1173
  */
954
1174
  static get pluginManager() {
955
- return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new l(this)), this._pluginManager;
1175
+ return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new p(this)), this._pluginManager;
956
1176
  }
957
- static _pluginManager = new l(this);
1177
+ static _pluginManager = new p(this);
958
1178
  /**
959
1179
  * 插件管理器 {@link PluginHostExtends.pluginManager}
960
1180
  */
@@ -962,10 +1182,16 @@ function pt(n) {
962
1182
  return this.constructor.pluginManager;
963
1183
  }
964
1184
  /**
965
- * {@inheritDoc PluginManager.use}
1185
+ * {@inheritDoc PluginExtendManager.usePlugin}
1186
+ */
1187
+ static usePlugin(e, ...n) {
1188
+ return this.pluginManager.usePlugin(e, ...n);
1189
+ }
1190
+ /**
1191
+ * {@inheritDoc PluginExtendManager.useExtend}
966
1192
  */
967
- static use(e, ...i) {
968
- return this.pluginManager.use(e, ...i);
1193
+ static useExtend(e) {
1194
+ return this.pluginManager.useExtend(e);
969
1195
  }
970
1196
  constructor(...e) {
971
1197
  super(...e), this.pluginManager.onCreate(this, ...e);
@@ -976,28 +1202,40 @@ function pt(n) {
976
1202
  * @param args
977
1203
  * @returns
978
1204
  */
979
- use(e, ...i) {
980
- return this.pluginManager.instUse(this, e, ...i);
1205
+ usePlugin(e, ...n) {
1206
+ return this.pluginManager.instUsePlugin(this, e, ...n);
1207
+ }
1208
+ /**
1209
+ * {@inheritDoc PluginExtendManager.useExtend}
1210
+ */
1211
+ useExtend(e, ...n) {
1212
+ return this.pluginManager.instUseExtend(this, e, ...n);
981
1213
  }
982
1214
  /**
983
1215
  * 初始化实例
984
1216
  * @remarks
985
- * 会调用 {@link PluginManager.onInit}
1217
+ * 会调用 {@link PluginExtendManager.onInit}
986
1218
  * @param args
987
1219
  */
988
- async init(...e) {
989
- return super.init && await super.init(...e), this.pluginManager.onInit(this, ...e);
1220
+ init(...e) {
1221
+ if (super.init) {
1222
+ const n = super.init(...e);
1223
+ if (n instanceof Promise)
1224
+ return n.then(() => this.pluginManager.onInit(this, ...e));
1225
+ }
1226
+ return this.pluginManager.onInit(this, ...e);
990
1227
  }
991
1228
  /**
992
1229
  * 销毁实例
993
1230
  * @returns
994
1231
  */
995
- async destroy() {
996
- if (await this.pluginManager.onDestroy(this), super.destroy) return super.destroy();
1232
+ destroy() {
1233
+ const e = this.pluginManager.onDestroy(this);
1234
+ return super.destroy ? e instanceof Promise ? e.finally(() => super.destroy()) : super.destroy() : e;
997
1235
  }
998
1236
  };
999
1237
  }
1000
- class lt extends U {
1238
+ class ut extends F {
1001
1239
  /**
1002
1240
  * 全局级别的默认选项
1003
1241
  */
@@ -1013,7 +1251,7 @@ class lt extends U {
1013
1251
  super(), this.defaultOptions.option = t;
1014
1252
  }
1015
1253
  }
1016
- class dt extends N {
1254
+ class at extends U {
1017
1255
  /**
1018
1256
  * 全局级别的默认选项
1019
1257
  */
@@ -1029,7 +1267,7 @@ class dt extends N {
1029
1267
  super(), this.defaultOptions.option = t;
1030
1268
  }
1031
1269
  }
1032
- class ct extends D {
1270
+ class lt extends D {
1033
1271
  /**
1034
1272
  * 全局级别的默认选项
1035
1273
  */
@@ -1045,8 +1283,8 @@ class ct extends D {
1045
1283
  super(), this.defaultOptions.option = t;
1046
1284
  }
1047
1285
  }
1048
- function ht(n) {
1049
- const t = H(n);
1286
+ function dt(s) {
1287
+ const t = C(s);
1050
1288
  return class extends t {
1051
1289
  /**
1052
1290
  * 全局级别的默认选项
@@ -1059,22 +1297,22 @@ function ht(n) {
1059
1297
  return this._defaultOptions || (this._defaultOptions = new u(void 0, this.constructor.defaultOptions));
1060
1298
  }
1061
1299
  _defaultOptions;
1062
- constructor(i) {
1063
- super(), this.defaultOptions.option = i;
1300
+ constructor(n) {
1301
+ super(), this.defaultOptions.option = n;
1064
1302
  }
1065
1303
  };
1066
1304
  }
1067
- const c = "common";
1068
- class ft extends U {
1305
+ const h = "common";
1306
+ class gt extends F {
1069
1307
  /**
1070
1308
  * 全局级别的默认选项
1071
1309
  */
1072
- static modeOptions = new a(c);
1310
+ static modeOptions = new a(h);
1073
1311
  /**
1074
1312
  * 实例级的默认选项
1075
1313
  */
1076
1314
  get modeOptions() {
1077
- return this._modeOptions || (this._modeOptions = new a(c, void 0, this.constructor.modeOptions));
1315
+ return this._modeOptions || (this._modeOptions = new a(h, void 0, this.constructor.modeOptions));
1078
1316
  }
1079
1317
  _modeOptions;
1080
1318
  get mode() {
@@ -1090,16 +1328,16 @@ class ft extends U {
1090
1328
  super(), this.modeOptions.setOption(t);
1091
1329
  }
1092
1330
  }
1093
- class Ot extends N {
1331
+ class ct extends U {
1094
1332
  /**
1095
1333
  * 全局级别的默认选项
1096
1334
  */
1097
- static modeOptions = new a(c);
1335
+ static modeOptions = new a(h);
1098
1336
  /**
1099
1337
  * 实例级的默认选项
1100
1338
  */
1101
1339
  get modeOptions() {
1102
- return this._modeOptions || (this._modeOptions = new a(c, void 0, this.constructor.modeOptions));
1340
+ return this._modeOptions || (this._modeOptions = new a(h, void 0, this.constructor.modeOptions));
1103
1341
  }
1104
1342
  _modeOptions;
1105
1343
  get mode() {
@@ -1115,16 +1353,16 @@ class Ot extends N {
1115
1353
  super(), this.modeOptions.setOption(t);
1116
1354
  }
1117
1355
  }
1118
- class mt extends D {
1356
+ class ht extends D {
1119
1357
  /**
1120
1358
  * 全局级别的默认选项
1121
1359
  */
1122
- static modeOptions = new a(c);
1360
+ static modeOptions = new a(h);
1123
1361
  /**
1124
1362
  * 实例级的默认选项
1125
1363
  */
1126
1364
  get modeOptions() {
1127
- return this._modeOptions || (this._modeOptions = new a(c, void 0, this.constructor.modeOptions));
1365
+ return this._modeOptions || (this._modeOptions = new a(h, void 0, this.constructor.modeOptions));
1128
1366
  }
1129
1367
  _modeOptions;
1130
1368
  get mode() {
@@ -1140,82 +1378,42 @@ class mt extends D {
1140
1378
  super(), this.modeOptions.setOption(t);
1141
1379
  }
1142
1380
  }
1143
- function _t(n) {
1144
- const t = H(n);
1381
+ function Ot(s) {
1382
+ const t = C(s);
1145
1383
  return class extends t {
1146
1384
  /**
1147
1385
  * 全局级别的默认选项
1148
1386
  */
1149
- static modeOptions = new a(c);
1387
+ static modeOptions = new a(h);
1150
1388
  /**
1151
1389
  * 实例级的默认选项
1152
1390
  */
1153
1391
  get modeOptions() {
1154
- return this._modeOptions || (this._modeOptions = new a(c, void 0, this.constructor.modeOptions));
1392
+ return this._modeOptions || (this._modeOptions = new a(h, void 0, this.constructor.modeOptions));
1155
1393
  }
1156
1394
  _modeOptions;
1157
1395
  get mode() {
1158
1396
  return this.modeOptions.mode;
1159
1397
  }
1160
- set mode(i) {
1161
- this.modeOptions.mode = i;
1398
+ set mode(n) {
1399
+ this.modeOptions.mode = n;
1162
1400
  }
1163
1401
  get options() {
1164
1402
  return this.modeOptions.plainFullOption;
1165
1403
  }
1166
- constructor(i) {
1167
- super(), this.modeOptions.setOption(i);
1404
+ constructor(n) {
1405
+ super(), this.modeOptions.setOption(n);
1168
1406
  }
1169
1407
  };
1170
1408
  }
1171
- function w(n, t) {
1172
- const e = [{ target: n, props: t }];
1173
- let i;
1174
- for (; i = e.shift(); ) {
1175
- const { target: s, props: o } = i;
1176
- for (const [r, p] of Object.entries(o)) {
1177
- if (p != null && typeof p == "object" && (!p.constructor || p.constructor === Object)) {
1178
- e.push({ target: s[r], props: p });
1179
- continue;
1180
- }
1181
- s[r] = p;
1182
- }
1183
- }
1184
- return n;
1185
- }
1186
- function W(n, t) {
1187
- const e = {}, i = [{ target: n, props: t, targetProps: e }];
1188
- let s;
1189
- for (; s = i.shift(); ) {
1190
- const { target: o, props: r, targetProps: p } = s;
1191
- for (const [f, h] of Object.entries(r)) {
1192
- if (h != null && typeof h == "object" && (!h.constructor || h.constructor === Object)) {
1193
- i.push({ target: o[f], props: h, targetProps: p[f] = {} });
1194
- continue;
1195
- }
1196
- p[f] = o[f];
1197
- }
1198
- }
1199
- return e;
1200
- }
1201
- function yt(n, t) {
1202
- const e = W(n, t);
1203
- function i() {
1204
- w(n, t);
1205
- }
1206
- function s() {
1207
- w(n, e);
1208
- }
1209
- return { set: i, unset: s };
1210
- }
1211
- function xt(n, t, e) {
1212
- const i = g(n, {
1409
+ function mt(s, t, e) {
1410
+ const n = c(s, {
1213
1411
  /**
1214
1412
  * 全局级别的默认选项
1215
1413
  */
1216
1414
  modeOptions: new a(t, e)
1217
1415
  });
1218
- return g(i.prototype, {
1416
+ return c(n.prototype, {
1219
1417
  /**
1220
1418
  * 实例级的默认选项
1221
1419
  */
@@ -1225,27 +1423,27 @@ function xt(n, t, e) {
1225
1423
  get mode() {
1226
1424
  return this.modeOptions.mode;
1227
1425
  },
1228
- set mode(s) {
1229
- this.modeOptions.mode = s;
1426
+ set mode(i) {
1427
+ this.modeOptions.mode = i;
1230
1428
  },
1231
1429
  get options() {
1232
1430
  return this.modeOptions.fullOption;
1233
1431
  }
1234
- }), n;
1432
+ }), s;
1235
1433
  }
1236
- const wt = {
1237
- onUse(n, t, e) {
1238
- const i = t ?? c;
1239
- d(n, {
1434
+ const Mt = {
1435
+ onUse(s, t, e) {
1436
+ const n = t ?? h;
1437
+ d(s, {
1240
1438
  modeOptions: new a(
1241
- i,
1439
+ n,
1242
1440
  void 0,
1243
1441
  e
1244
1442
  )
1245
- }), d(n.prototype, {
1443
+ }), d(s.prototype, {
1246
1444
  get modeOptions() {
1247
- const s = this, o = n;
1248
- return s._modeOptions || (s._modeOptions = new a(
1445
+ const i = this, o = s;
1446
+ return i._modeOptions || (i._modeOptions = new a(
1249
1447
  o.modeOptions.mode,
1250
1448
  void 0,
1251
1449
  o.modeOptions
@@ -1254,108 +1452,142 @@ const wt = {
1254
1452
  get mode() {
1255
1453
  return this.modeOptions.mode;
1256
1454
  },
1257
- set mode(s) {
1455
+ set mode(i) {
1258
1456
  const o = this;
1259
- o.modeOptions.mode = s;
1457
+ o.modeOptions.mode = i;
1260
1458
  },
1261
1459
  get options() {
1262
1460
  return this.modeOptions.plainFullOption;
1263
1461
  }
1264
1462
  });
1265
1463
  },
1266
- onCreate(n, t) {
1267
- n.modeOptions.setOption(t);
1464
+ onCreate(s, t) {
1465
+ s.modeOptions.setOption(t);
1268
1466
  }
1269
1467
  }, Pt = {
1270
- onUse(n, t, e) {
1271
- d(n, {
1468
+ onUse(s, t, e) {
1469
+ d(s, {
1272
1470
  /**
1273
1471
  * 全局级别的默认选项
1274
1472
  */
1275
1473
  defaultOptions: new u(t, e)
1276
- }), d(n.prototype, {
1474
+ }), d(s.prototype, {
1277
1475
  /**
1278
1476
  * 实例级的默认选项
1279
1477
  */
1280
1478
  get defaultOptions() {
1281
- return this._defaultOptions || (this._defaultOptions = new u(void 0, n.defaultOptions));
1479
+ return this._defaultOptions || (this._defaultOptions = new u(void 0, s.defaultOptions));
1282
1480
  }
1283
1481
  });
1284
1482
  },
1285
- onCreate(n, t) {
1286
- n.defaultOptions.option = t;
1483
+ onCreate(s, t) {
1484
+ s.defaultOptions.option = t;
1287
1485
  }
1288
1486
  };
1289
- function Tt(n, t) {
1290
- const e = g(n, {
1487
+ function xt(s, t) {
1488
+ const e = c(s, {
1291
1489
  /**
1292
1490
  * 全局级别的默认选项
1293
1491
  */
1294
1492
  defaultOptions: new u(t)
1295
1493
  });
1296
- return g(e.prototype, {
1494
+ return c(e.prototype, {
1297
1495
  /**
1298
1496
  * 实例级的默认选项
1299
1497
  */
1300
1498
  get defaultOptions() {
1301
1499
  return this._defaultOptions || (this._defaultOptions = new u(void 0, this.constructor.defaultOptions));
1302
1500
  }
1303
- }), n;
1501
+ }), s;
1502
+ }
1503
+ function _(s, t) {
1504
+ const e = [{ target: s, props: t }];
1505
+ let n;
1506
+ for (; n = e.shift(); ) {
1507
+ const { target: i, props: o } = n;
1508
+ for (const [r, l] of Object.entries(o)) {
1509
+ if (l != null && typeof l == "object" && (!l.constructor || l.constructor === Object)) {
1510
+ e.push({ target: i[r], props: l });
1511
+ continue;
1512
+ }
1513
+ i[r] = l;
1514
+ }
1515
+ }
1516
+ return s;
1517
+ }
1518
+ function A(s, t) {
1519
+ const e = {}, n = [{ target: s, props: t, targetProps: e }];
1520
+ let i;
1521
+ for (; i = n.shift(); ) {
1522
+ const { target: o, props: r, targetProps: l } = i;
1523
+ for (const [m, f] of Object.entries(r)) {
1524
+ if (f != null && typeof f == "object" && (!f.constructor || f.constructor === Object)) {
1525
+ n.push({ target: o[m], props: f, targetProps: l[m] = {} });
1526
+ continue;
1527
+ }
1528
+ l[m] = o[m];
1529
+ }
1530
+ }
1531
+ return e;
1532
+ }
1533
+ function yt(s, t) {
1534
+ const e = A(s, t);
1535
+ function n() {
1536
+ _(s, t);
1537
+ }
1538
+ function i() {
1539
+ _(s, e);
1540
+ }
1541
+ return { set: n, unset: i };
1304
1542
  }
1305
1543
  export {
1306
- j as ModeOptions,
1307
- U as PluginHost,
1308
- N as PluginHostEventEmitter,
1544
+ Q as ExtendManager,
1545
+ S as ModeOptions,
1546
+ p as PluginExtendManager,
1547
+ F as PluginHost,
1548
+ U as PluginHostEventEmitter,
1309
1549
  D as PluginHostEventTarget,
1310
- l as PluginManager,
1550
+ L as PluginManager,
1311
1551
  a as TierModeOptions,
1312
- ft as TierModeOptionsPluginHost,
1313
- Ot as TierModeOptionsPluginHostEventEmitter,
1314
- mt as TierModeOptionsPluginHostEventTarget,
1552
+ gt as TierModeOptionsPluginHost,
1553
+ ct as TierModeOptionsPluginHostEventEmitter,
1554
+ ht as TierModeOptionsPluginHostEventTarget,
1315
1555
  u as TierOptions,
1316
- lt as TierOptionsPluginHost,
1317
- dt as TierOptionsPluginHostEventEmitter,
1318
- ct as TierOptionsPluginHostEventTarget,
1319
- tt as addDefaultOptions,
1320
- et as addInstOptions,
1321
- M as allFunctionApply,
1322
- S as becomePluginHost,
1323
- pt as becomePluginHost_Extends,
1324
- ut as becomePluginHost_Proxy,
1325
- xt as becomeTierModeOptionsHost,
1326
- Tt as becomeTierOptionsHost,
1327
- c as commonModeName,
1328
- Q as createCallerOfPrivateMemberOfExtend,
1329
- $ as createDefineMixin,
1330
- J as createExtendTarget,
1331
- L as createExtendTargetWithInit,
1332
- K as createMixinTarget,
1333
- H as createPluginHost,
1556
+ ut as TierOptionsPluginHost,
1557
+ at as TierOptionsPluginHostEventEmitter,
1558
+ lt as TierOptionsPluginHostEventTarget,
1559
+ X as addDefaultOptions,
1560
+ Y as addInstOptions,
1561
+ j as becomePluginHost,
1562
+ rt as becomePluginHost_Extends,
1563
+ it as becomePluginHost_Proxy,
1564
+ mt as becomeTierModeOptionsHost,
1565
+ xt as becomeTierOptionsHost,
1566
+ h as commonModeName,
1567
+ K as createDefineMixin,
1568
+ G as createMixinTarget,
1569
+ C as createPluginHost,
1334
1570
  yt as createPropertySetter,
1335
- G as createTargetExtend,
1336
- Y as createTargetExtendWithInit,
1337
- B as createTargetMixin,
1338
- _t as createTierModeOptionsPluginHost,
1339
- ht as createTierOptionsPluginHost,
1340
- R as defineExtend,
1341
- X as defineExtendWithInit,
1342
- z as defineMixin,
1343
- b as extendTarget,
1344
- Z as extendTargetWithInit,
1571
+ W as createTargetMixin,
1572
+ Ot as createTierModeOptionsPluginHost,
1573
+ dt as createTierOptionsPluginHost,
1574
+ J as defineExtend,
1575
+ B as defineMixin,
1576
+ O as extendMark,
1345
1577
  y as getPropertyValue,
1346
- nt as getPropertyValueByPath,
1347
- W as getTargetProperties,
1348
- w as mergeProperties,
1578
+ Z as getPropertyValueByPath,
1579
+ A as getTargetProperties,
1580
+ I as isPlugin,
1581
+ _ as mergeProperties,
1349
1582
  d as mixin,
1350
- g as mixinTarget,
1351
- v as parsePropertyPath,
1352
- F as setPropertyValue,
1353
- it as setPropertyValueByPath,
1354
- O as targetExtend,
1355
- x as targetExtendWithInit,
1356
- q as targetMixin,
1357
- ot as tierModeOptionsDecorator,
1358
- wt as tierModeOptionsPlugin,
1359
- st as tierOptionsDecorator,
1583
+ c as mixinTarget,
1584
+ b as parsePropertyPath,
1585
+ T as pickHostExtendMembers,
1586
+ E as setPropertyValue,
1587
+ tt as setPropertyValueByPath,
1588
+ R as targetMixin,
1589
+ nt as tierModeOptionsDecorator,
1590
+ Mt as tierModeOptionsPlugin,
1591
+ et as tierOptionsDecorator,
1360
1592
  Pt as tierOptionsPlugin
1361
1593
  };