plugin-tls 3.6.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/Destroyable-BqvuD4gL-Cmk1ocqj.cjs +1 -0
  2. package/dist/Destroyable-BqvuD4gL-D50ZO9eN.js +129 -0
  3. package/dist/createTierModeOptionsPluginHost-C3kmxB00.cjs +1 -0
  4. package/dist/createTierModeOptionsPluginHost-CeND_z6P.js +852 -0
  5. package/dist/index-node.cjs +1 -1
  6. package/dist/index-node.d.ts +0 -1
  7. package/dist/index-node.d.ts.map +1 -1
  8. package/dist/index-node.js +254 -56
  9. package/dist/index-web.cjs +1 -1
  10. package/dist/index-web.d.ts +0 -1
  11. package/dist/index-web.d.ts.map +1 -1
  12. package/dist/index-web.js +324 -56
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.d.ts +4 -5
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +628 -60
  17. package/dist/options/index-node.d.ts +0 -1
  18. package/dist/options/index-node.d.ts.map +1 -1
  19. package/dist/options/index-web.d.ts +0 -1
  20. package/dist/options/index-web.d.ts.map +1 -1
  21. package/dist/options/{index-com.d.ts → index.d.ts} +1 -1
  22. package/dist/options/index.d.ts.map +1 -0
  23. package/dist/options/plugins/tier-mode-options/type.d.ts +1 -1
  24. package/dist/options/plugins/tier-mode-options/type.d.ts.map +1 -1
  25. package/dist/options/plugins/tier-options/type.d.ts +1 -1
  26. package/dist/options/plugins/tier-options/type.d.ts.map +1 -1
  27. package/dist/plugin-host/PluginHostEventEmitter.d.ts +2 -2
  28. package/dist/plugin-host/PluginHostEventEmitter.d.ts.map +1 -1
  29. package/dist/plugin-host/PluginHostEventTarget.d.ts +1 -1
  30. package/dist/plugin-host/PluginHostEventTarget.d.ts.map +1 -1
  31. package/dist/plugin-host/index-node.d.ts +0 -1
  32. package/dist/plugin-host/index-node.d.ts.map +1 -1
  33. package/dist/plugin-host/index-web.d.ts +0 -1
  34. package/dist/plugin-host/index-web.d.ts.map +1 -1
  35. package/dist/plugin-host/{index-com.d.ts → index.d.ts} +1 -1
  36. package/dist/plugin-host/index.d.ts.map +1 -0
  37. package/package.json +2 -7
  38. package/dist/TierOptionsPluginHostEventEmitter-BjGVIRN6.cjs +0 -1
  39. package/dist/TierOptionsPluginHostEventEmitter-DXTNpSmS.js +0 -131
  40. package/dist/TierOptionsPluginHostEventTarget-Bok_zzQ1.js +0 -131
  41. package/dist/TierOptionsPluginHostEventTarget-DqfVEP_L.cjs +0 -1
  42. package/dist/decorator-Culqv4k6.js +0 -1454
  43. package/dist/decorator-Wf_x4qDo.cjs +0 -1
  44. package/dist/options/index-com.d.ts.map +0 -1
  45. package/dist/plugin-host/index-com.d.ts.map +0 -1
@@ -0,0 +1,852 @@
1
+ import { Destroyable as m, createDestroyableSubClass as U } from "@gby/destroyable";
2
+ import { deepmergeInto as c, deepmerge as M } from "deepmerge-ts";
3
+ import { serialCallFuns as h } from "com-tools";
4
+ const x = ["onCreate", "onInit", "onDestroy"];
5
+ function E(i) {
6
+ const t = { ...i };
7
+ for (const e of x)
8
+ typeof t[e] == "function" && delete t[e];
9
+ return t;
10
+ }
11
+ function w(i, t) {
12
+ let e = Object.getOwnPropertyDescriptors(t);
13
+ for (const n of x)
14
+ typeof t[n] == "function" && delete e[n];
15
+ return Object.defineProperties(i, e), i;
16
+ }
17
+ function N(i) {
18
+ return i && typeof i.onUse == "function";
19
+ }
20
+ const a = /* @__PURE__ */ Symbol("extend");
21
+ class d extends m {
22
+ /**
23
+ * 插件的宿主
24
+ */
25
+ host;
26
+ /**
27
+ * 所有注册的插件
28
+ */
29
+ plugins = /* @__PURE__ */ new Map();
30
+ /**
31
+ * @param host - 插件的宿主
32
+ */
33
+ constructor(t) {
34
+ super(), t && (this.host = t);
35
+ }
36
+ destroyThis() {
37
+ return this.plugins.clear(), this.host = null, super.destroyThis();
38
+ }
39
+ /**
40
+ * 是否注册了插件 或 扩展
41
+ * @param plugin - 插件 或 扩展
42
+ * @returns 是否注册了插件 或 扩展
43
+ */
44
+ hasUsed(t) {
45
+ return this.plugins.has(t);
46
+ }
47
+ /**
48
+ * 判断一个对象是否是插件
49
+ * @param target
50
+ * @returns
51
+ */
52
+ isPlugin(t) {
53
+ const { plugins: e } = this;
54
+ return e.has(t) ? e.get(t) !== a : N(t);
55
+ }
56
+ /**
57
+ * 使用插件、注册插件
58
+ * @param ext - 插件
59
+ * @param args - 传递给插件的选项
60
+ */
61
+ useExtend(t) {
62
+ const { plugins: e } = this;
63
+ return e.has(t) ? e.get(t) : (w(this.host.prototype, t), e.set(t, a), t);
64
+ }
65
+ /**
66
+ * 插件宿主实例的注册插件的方法
67
+ *
68
+ * @remarks
69
+ * 会调用每个插件的 {@link IExtend.use } 方法
70
+ * @param hostInst - 插件宿主的新实例
71
+ */
72
+ instUseExtend(t, e, ...n) {
73
+ const { plugins: s } = this;
74
+ return s.has(e) ? s.get(e) : (this.useExtend(e), e.onCreate?.call(t, t, ...n), e);
75
+ }
76
+ /**
77
+ * 使用插件、注册插件
78
+ * @param plugin - 插件
79
+ * @param args - 传递给插件的选项
80
+ */
81
+ usePlugin(t, ...e) {
82
+ const { plugins: n } = this;
83
+ if (n.has(t)) return n.get(t);
84
+ const s = t.onUse(this.host, ...e);
85
+ return n.set(t, s), s;
86
+ }
87
+ /**
88
+ * 插件宿主实例的注册插件的方法
89
+ *
90
+ * @remarks
91
+ * 会调用每个插件的 {@link IPlugin.use } 方法
92
+ * @param hostInst - 插件宿主的新实例
93
+ */
94
+ instUsePlugin(t, e, ...n) {
95
+ const { plugins: s } = this;
96
+ if (s.has(e)) return s.get(e);
97
+ const o = this.usePlugin(e, ...n);
98
+ return e.onCreate?.(t), o;
99
+ }
100
+ /**
101
+ * 插件宿主创建实例时调用
102
+ *
103
+ * @remarks
104
+ * 会调用每个插件的 {@link IPlugin.onCreate} 方法
105
+ * 如果插件的 created 方法返回 Promise,则会等待 Promise resolve
106
+ * @param hostInst - 插件宿主的新实例
107
+ */
108
+ onCreate(t, ...e) {
109
+ const n = [];
110
+ for (const [s, o] of this.plugins)
111
+ if (s.onCreate) {
112
+ const r = o === a ? s.onCreate : s.onCreate.bind(s);
113
+ n.push(r);
114
+ }
115
+ return h(n, t, [t, ...e]);
116
+ }
117
+ /**
118
+ * 插件宿主创建实例时调用
119
+ *
120
+ * @remarks
121
+ * 会调用每个插件的 {@link IPlugin.onCreate } 方法
122
+ * @param hostInst - 插件宿主的新实例
123
+ * @param args - 初始化宿主实例时的参数
124
+ */
125
+ onInit(t, ...e) {
126
+ const n = [];
127
+ for (const [s, o] of this.plugins)
128
+ if (s.onInit) {
129
+ const r = o === a ? s.onInit : s.onInit.bind(s);
130
+ n.push(r);
131
+ }
132
+ return h(n, t, [t, ...e]);
133
+ }
134
+ /**
135
+ * 插件宿主被销毁时调用
136
+ *
137
+ * @remarks
138
+ * 会调用每个插件的 {@link IPlugin.onDestroy} 方法
139
+ * @param hostInst - 被销毁的插件实例
140
+ */
141
+ onDestroy(t) {
142
+ const e = [];
143
+ for (const [n, s] of this.plugins)
144
+ if (n.onDestroy) {
145
+ const o = s === a ? n.onDestroy : n.onDestroy.bind(n);
146
+ e.push(o);
147
+ }
148
+ return e.reverse(), h(e, t, [t]);
149
+ }
150
+ }
151
+ function y(i) {
152
+ const t = i.split(".");
153
+ return t[0] === "" && t.shift(), t;
154
+ }
155
+ function f(i, t) {
156
+ for (const e of t)
157
+ if (i = i[e], i == null) return;
158
+ return i;
159
+ }
160
+ function k(i, t) {
161
+ return f(i, y(t));
162
+ }
163
+ function P(i, t, e) {
164
+ const n = t.pop(), s = t.length;
165
+ let o = 0;
166
+ for (; o < s; ) {
167
+ const r = i[t[o]];
168
+ if (r == null) break;
169
+ i = r, o++;
170
+ }
171
+ t = t.slice(o);
172
+ for (const r of t)
173
+ i = i[r] = {};
174
+ return i[n] = e, i;
175
+ }
176
+ function H(i, t, e) {
177
+ return P(i, y(t), e);
178
+ }
179
+ const g = {
180
+ UndefinedAndNull: function(t) {
181
+ return t == null;
182
+ },
183
+ Undefined: function(t) {
184
+ return t === void 0;
185
+ },
186
+ Null: function(t) {
187
+ return t === null;
188
+ }
189
+ };
190
+ class _ {
191
+ /**
192
+ * 是否要冻结 fullOption 的成员
193
+ * @remarks
194
+ * 只会冻结 fullOption 的直接成员的值,不会冻结 fullOption 孙子成员的值
195
+ */
196
+ freezeMember = !0;
197
+ /**
198
+ * 可更新顶级成员值的完整的选项
199
+ * @remarks
200
+ * 合并后的选项;
201
+ * plainFullOption 的代理对象,自动监听了顶层成员的屐;所以可以更改顶级成员的值,不可以更改非顶级成员的值;
202
+ */
203
+ fullOption = new Proxy(this, {
204
+ // @ts-ignore
205
+ get: function(t, e, n) {
206
+ const s = t.plainFullOption[e];
207
+ return t.freezeMember ? Object.freeze(s) : s;
208
+ },
209
+ // @ts-ignore
210
+ set: function(t, e, n, s) {
211
+ return t.setMember(e, n, !1), !0;
212
+ },
213
+ // @ts-ignore
214
+ has: function(t, e) {
215
+ return e in t.plainFullOption;
216
+ },
217
+ // @ts-ignore
218
+ getOwnPropertyDescriptor: function(t, e) {
219
+ return Object.getOwnPropertyDescriptor(t.plainFullOption, e);
220
+ },
221
+ // @ts-ignore
222
+ ownKeys: function(t) {
223
+ return Reflect.ownKeys(t.plainFullOption);
224
+ },
225
+ // @ts-ignore
226
+ deleteProperty: function(t, e) {
227
+ return t.setMember(e, void 0), !0;
228
+ },
229
+ // @ts-ignore
230
+ defineProperty: function(t, e, n) {
231
+ return Object.defineProperty(t.option, e, n), !0;
232
+ }
233
+ });
234
+ /**
235
+ * 设置选项
236
+ * @remarks
237
+ * 会将被设置的选项浅合并进当前选项中
238
+ * @param option
239
+ * @param deep - 是否要进行深度合并
240
+ */
241
+ setOption(t, e) {
242
+ const n = e ? c(this.option, t) : Object.assign(this.option, t);
243
+ return this.updateFullOption(), n;
244
+ }
245
+ /**
246
+ * 未定义值的类型
247
+ */
248
+ get undefinedValue() {
249
+ return this._undefinedValue;
250
+ }
251
+ set undefinedValue(t) {
252
+ this._undefinedValue = t, this.isUndefined = g[t] || g.UndefinedAndNull;
253
+ }
254
+ _undefinedValue = "UndefinedAndNull";
255
+ /**
256
+ * 未定义值的判断函数
257
+ */
258
+ isUndefined = g.UndefinedAndNull;
259
+ /**
260
+ * 获取选项成员
261
+ * @param key
262
+ * @returns
263
+ */
264
+ getMember(t) {
265
+ return this.option[t];
266
+ }
267
+ /**
268
+ * 设置选项成员
269
+ * @param key
270
+ * @param value
271
+ * @param deep - 是否要进行深度合并
272
+ */
273
+ setMember(t, e, n) {
274
+ const s = this.option;
275
+ if (e === void 0)
276
+ delete s[t];
277
+ else {
278
+ const o = s[t];
279
+ n && o && typeof o == "object" ? c(o, e) : s[t] = e;
280
+ }
281
+ this.updateFullOption();
282
+ }
283
+ /**
284
+ * 获取属性路径对应的值
285
+ * @param propPath
286
+ * @returns
287
+ */
288
+ getValue(t) {
289
+ return f(this.option, t);
290
+ }
291
+ /**
292
+ * 设置属性路径对应的值
293
+ * @param propPath
294
+ * @param value
295
+ * @param deep - 是否要进行深度合并
296
+ * @returns
297
+ */
298
+ setValue(t, e, n) {
299
+ const s = this.option;
300
+ let o;
301
+ n && (o = f(s, t)) && typeof o == "object" ? c(o, e) : P(this.option, t, e), this.updateFullOption();
302
+ }
303
+ }
304
+ class u extends _ {
305
+ constructor(t, e) {
306
+ super(), t && (this.option = t), e && (this.extends = e);
307
+ }
308
+ /**
309
+ * 继承的选项
310
+ */
311
+ get extends() {
312
+ return this._extends;
313
+ }
314
+ set extends(t) {
315
+ this._extends = t, this.updateFullOption();
316
+ }
317
+ _extends = null;
318
+ /**
319
+ * 选项
320
+ */
321
+ option = {};
322
+ /**
323
+ * 获取完整的选项
324
+ * @remarks
325
+ * 会与继承来的选项进行合并
326
+ */
327
+ get plainFullOption() {
328
+ let t = this._plainFullOption;
329
+ if (t) return t;
330
+ const { extends: e, option: n } = this;
331
+ if (t = n, e) {
332
+ const s = e.plainFullOption;
333
+ t = M(s, n);
334
+ }
335
+ return this._plainFullOption = t;
336
+ }
337
+ _plainFullOption = null;
338
+ /**
339
+ * 更新
340
+ */
341
+ updateFullOption() {
342
+ this._plainFullOption = null;
343
+ }
344
+ /**
345
+ * 获取选项成员
346
+ * @param key
347
+ * @returns
348
+ */
349
+ getMember(t) {
350
+ const e = this.option[t];
351
+ if (!this.isUndefined(e)) return e;
352
+ const n = this.extends;
353
+ if (n)
354
+ return n.getMember(t);
355
+ }
356
+ /**
357
+ * 获取属性路径对应的值
358
+ * @param propPath
359
+ * @returns
360
+ */
361
+ getValue(t) {
362
+ const e = super.getValue(t);
363
+ if (!this.isUndefined(e)) return e;
364
+ const n = this.extends;
365
+ if (n)
366
+ return n.getValue(t);
367
+ }
368
+ }
369
+ function C(i, t) {
370
+ const { name: e } = t, n = `_${e}`;
371
+ return {
372
+ get: function() {
373
+ return this[n] || (this[n] = new u(void 0, this.constructor[e]));
374
+ }
375
+ };
376
+ }
377
+ class T extends _ {
378
+ constructor(t, e) {
379
+ super(), e && this.setModeOption(t, e), this.mode = t;
380
+ }
381
+ /**
382
+ * 模式的配置
383
+ */
384
+ modes = {};
385
+ /**
386
+ * 当前模式
387
+ */
388
+ get mode() {
389
+ return this._mode || (this.mode = this.modeNames[0]);
390
+ }
391
+ set mode(t) {
392
+ this._mode = t, this.hasMode(t) || this.setModeOption(t, {}), this.updateFullOption();
393
+ }
394
+ _mode;
395
+ /**
396
+ * 所有的模式名字
397
+ */
398
+ get modeNames() {
399
+ return this._modeNames || (this._modeNames = this.getModeNames());
400
+ }
401
+ _modeNames = null;
402
+ /**
403
+ * 获取所有的模式名字
404
+ * @returns
405
+ */
406
+ getModeNames() {
407
+ return Object.keys(this.modes);
408
+ }
409
+ /**
410
+ * 判断是否有某个模式
411
+ * @param mode
412
+ * @returns
413
+ */
414
+ hasMode(t) {
415
+ return !!this.modes[t];
416
+ }
417
+ /**
418
+ * 当前模式的选项
419
+ */
420
+ get optionManager() {
421
+ return this.modes[this.mode];
422
+ }
423
+ /**
424
+ * 当前模式对应的选项
425
+ */
426
+ get option() {
427
+ return this.optionManager.option;
428
+ }
429
+ get plainFullOption() {
430
+ return this._plainFullOption ?? (this._plainFullOption = this.getFullModeOption(this.mode));
431
+ }
432
+ _plainFullOption = null;
433
+ /**
434
+ * 更新
435
+ */
436
+ updateFullOption() {
437
+ this._plainFullOption = null, this._modeNames = null;
438
+ }
439
+ /**
440
+ * 返回已合并继承选项的选项
441
+ * @remarks
442
+ * 与继承选项只是浅合并
443
+ * @param mode
444
+ * @returns
445
+ */
446
+ getModeOption(t) {
447
+ return this.modes[t].option;
448
+ }
449
+ /**
450
+ * 返回已合并继承选项的完整选项
451
+ * @remarks
452
+ * 与继承选项合并
453
+ * @param mode
454
+ * @returns
455
+ */
456
+ getFullModeOption(t) {
457
+ return this.modes[t]?.plainFullOption;
458
+ }
459
+ /**
460
+ * 给模式设置选项
461
+ * @param mode
462
+ * @param option
463
+ * @param deep - 是否要进行深度合并
464
+ * @param extend - 继承哪个模式
465
+ */
466
+ setModeOption(t, e, n, s) {
467
+ const { modes: o } = this, r = o[t] || (o[t] = new u());
468
+ if (r.setOption(e, n), s) {
469
+ const O = o[s];
470
+ O && (r.extends = O);
471
+ }
472
+ return this.updateFullOption(), r;
473
+ }
474
+ }
475
+ class l extends T {
476
+ constructor(t, e, n) {
477
+ super(t, e), n && (this.extends = n);
478
+ }
479
+ /**
480
+ * 继承的选项
481
+ */
482
+ get extends() {
483
+ return this._extends;
484
+ }
485
+ set extends(t) {
486
+ this._extends = t, this.updateFullOption();
487
+ }
488
+ _extends = null;
489
+ /**
490
+ * 返回已合并继承选项的最终选项
491
+ * @remarks
492
+ * 与继承选项只是浅合并
493
+ * @param mode
494
+ * @returns
495
+ */
496
+ getFullModeOption(t) {
497
+ const { modes: e, extends: n } = this, s = e[t]?.plainFullOption;
498
+ if (n) {
499
+ const o = n.getFullModeOption(t);
500
+ return s ? M(o, s) : o;
501
+ }
502
+ return s;
503
+ }
504
+ /**
505
+ * 获取所有的模式名字
506
+ * @returns
507
+ */
508
+ getModeNames() {
509
+ const { modes: t, extends: e } = this, n = Object.keys(t);
510
+ if (!e) return n;
511
+ const s = e.getModeNames();
512
+ return [.../* @__PURE__ */ new Set([...n, ...s])];
513
+ }
514
+ /**
515
+ * 在整个层级上判断是否有某个模式
516
+ * @param mode
517
+ * @returns
518
+ */
519
+ hasModeOnTier(t) {
520
+ if (this.hasMode(t)) return !0;
521
+ const e = this.extends;
522
+ return e ? e.hasModeOnTier(t) : !1;
523
+ }
524
+ /**
525
+ * 当前模式的选项
526
+ */
527
+ get optionManager() {
528
+ return this.getModeOptionManager(this.mode);
529
+ }
530
+ /**
531
+ * 获取模式对应的选项管理器
532
+ * @param mode
533
+ * @returns
534
+ */
535
+ getModeOptionManager(t) {
536
+ const e = this.modes[t];
537
+ return e || (this.extends?.getModeOptionManager(t) ? this.setModeOption(t, {}) : null);
538
+ }
539
+ /**
540
+ * 获取选项成员
541
+ * @param key
542
+ * @returns
543
+ */
544
+ getMember(t) {
545
+ const e = this.optionManager.getMember(t);
546
+ if (!this.isUndefined(e)) return e;
547
+ const n = this.extends;
548
+ if (n)
549
+ return n.getMember(t);
550
+ }
551
+ /**
552
+ * 获取属性路径对应的值
553
+ * @param propPath
554
+ * @returns
555
+ */
556
+ getValue(t) {
557
+ const e = this.optionManager.getValue(t);
558
+ if (!this.isUndefined(e)) return e;
559
+ const n = this.extends;
560
+ if (n)
561
+ return n.getValue(t);
562
+ }
563
+ }
564
+ function S(i, t) {
565
+ const { name: e } = t, n = `_${e}`;
566
+ return {
567
+ get: function() {
568
+ return this[n] || (this[n] = new l(this.constructor[e].mode, void 0, this.constructor[e]));
569
+ }
570
+ };
571
+ }
572
+ class F extends m {
573
+ /**
574
+ * 是否使用独立的插件管理器
575
+ * @defaultValue false
576
+ */
577
+ static isolatedPluginManager = !1;
578
+ /**
579
+ * 插件管理器
580
+ */
581
+ static get pluginManager() {
582
+ return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new d(this)), this._pluginManager;
583
+ }
584
+ static _pluginManager = new d(this);
585
+ /**
586
+ * 插件管理器 {@link PluginHost.pluginManager}
587
+ */
588
+ get pluginManager() {
589
+ return this.constructor.pluginManager;
590
+ }
591
+ /**
592
+ * {@inheritDoc PluginExtendManager.usePlugin}
593
+ */
594
+ static usePlugin(t, ...e) {
595
+ return this.pluginManager.usePlugin(t, ...e);
596
+ }
597
+ /**
598
+ * {@inheritDoc PluginExtendManager.useExtend}
599
+ */
600
+ static useExtend(t) {
601
+ return this.pluginManager.useExtend(t);
602
+ }
603
+ /**
604
+ * 是否注册了插件 或 扩展
605
+ * @param plugin - 插件 或 扩展
606
+ * @returns 是否注册了插件 或 扩展
607
+ */
608
+ static hasUsed(t) {
609
+ return this.pluginManager.hasUsed(t);
610
+ }
611
+ /**
612
+ * 需要在子类中调用
613
+ *
614
+ * 之所以没写在该类中的函数中,是因为 `this.pluginManager.onCreate(this,...args)` 通常会在构建函数执行的最后时才调用;
615
+ * 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.onCreate(this,...args)` 不是在最后的执行;
616
+ */
617
+ // constructor(...args:any) {
618
+ // super();
619
+ // // @ts-ignore
620
+ // this.pluginManager.onCreate(this,...args);
621
+ // }
622
+ /**
623
+ * 实例的注册插件的方法
624
+ * @param plugin
625
+ * @param args
626
+ * @returns
627
+ */
628
+ usePlugin(t, ...e) {
629
+ return this.pluginManager.instUsePlugin(this, t, ...e);
630
+ }
631
+ /**
632
+ * {@inheritDoc PluginExtendManager.useExtend}
633
+ */
634
+ useExtend(t, ...e) {
635
+ return this.pluginManager.instUseExtend(this, t, ...e);
636
+ }
637
+ /**
638
+ * 初始化实例
639
+ * @remarks
640
+ * 会调用 {@link PluginExtendManager.onInit}
641
+ * @param args
642
+ */
643
+ init(...t) {
644
+ return this.pluginManager.onInit(this, ...t);
645
+ }
646
+ /**
647
+ * 销毁实例
648
+ * @returns
649
+ */
650
+ destroyThis() {
651
+ const t = this.pluginManager.onDestroy(this);
652
+ return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
653
+ }
654
+ }
655
+ class I extends F {
656
+ /**
657
+ * 全局级别的默认选项
658
+ */
659
+ static defaultOptions = new u();
660
+ /**
661
+ * 实例级的默认选项
662
+ */
663
+ get defaultOptions() {
664
+ return this._defaultOptions || (this._defaultOptions = new u(void 0, this.constructor.defaultOptions));
665
+ }
666
+ _defaultOptions;
667
+ constructor(t) {
668
+ super(), this.defaultOptions.option = t;
669
+ }
670
+ }
671
+ function b(i) {
672
+ const t = U(i);
673
+ return class extends t {
674
+ /**
675
+ * 是否使用独立的插件管理器
676
+ * @defaultValue false
677
+ */
678
+ static isolatedPluginManager = !1;
679
+ /**
680
+ * 插件管理器
681
+ */
682
+ static get pluginManager() {
683
+ return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new d(this)), this._pluginManager;
684
+ }
685
+ static _pluginManager = new d(this);
686
+ /**
687
+ * 插件管理器 {@link PluginHostSub.pluginManager}
688
+ */
689
+ get pluginManager() {
690
+ return this.constructor.pluginManager;
691
+ }
692
+ /**
693
+ * {@inheritDoc PluginExtendManager.usePlugin}
694
+ */
695
+ static usePlugin(n, ...s) {
696
+ return this.pluginManager.usePlugin(n, ...s);
697
+ }
698
+ /**
699
+ * {@inheritDoc PluginExtendManager.useExtend}
700
+ */
701
+ static useExtend(n) {
702
+ return this.pluginManager.useExtend(n);
703
+ }
704
+ /**
705
+ * 是否注册了插件 或 扩展
706
+ * @param plugin - 插件 或 扩展
707
+ * @returns 是否注册了插件 或 扩展
708
+ */
709
+ static hasUsed(n) {
710
+ return this.pluginManager.hasUsed(n);
711
+ }
712
+ /**
713
+ * 需要在子类中调用
714
+ *
715
+ * 之所以没写在该类中的函数中,是因为 `this.pluginManager.onCreate(this)` 通常会在构建函数执行的最后时才调用;
716
+ * 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.onCreate(this)` 不是在最后的执行;
717
+ */
718
+ // constructor() {
719
+ // super();
720
+ // this.pluginManager.onCreate(this);
721
+ // }
722
+ /**
723
+ * 实例的注册插件的方法
724
+ * @param plugin
725
+ * @param args
726
+ * @returns
727
+ */
728
+ usePlugin(n, ...s) {
729
+ return this.pluginManager.instUsePlugin(this, n, ...s);
730
+ }
731
+ /**
732
+ * {@inheritDoc PluginExtendManager.useExtend}
733
+ */
734
+ useExtend(n, ...s) {
735
+ return this.pluginManager.instUseExtend(this, n, ...s);
736
+ }
737
+ /**
738
+ * 初始化实例
739
+ * @remarks
740
+ * 会调用 {@link PluginExtendManager.onInit}
741
+ * @param args
742
+ */
743
+ init(...n) {
744
+ return this.pluginManager.onInit(this, ...n);
745
+ }
746
+ /**
747
+ * 销毁实例
748
+ * @returns
749
+ */
750
+ destroyThis() {
751
+ const n = this.pluginManager.onDestroy(this);
752
+ return n instanceof Promise ? n.finally(() => super.destroyThis()) : super.destroyThis();
753
+ }
754
+ };
755
+ }
756
+ function z(i) {
757
+ const t = b(i);
758
+ return class extends t {
759
+ /**
760
+ * 全局级别的默认选项
761
+ */
762
+ static defaultOptions = new u();
763
+ /**
764
+ * 实例级的默认选项
765
+ */
766
+ get defaultOptions() {
767
+ return this._defaultOptions || (this._defaultOptions = new u(void 0, this.constructor.defaultOptions));
768
+ }
769
+ _defaultOptions;
770
+ constructor(n) {
771
+ super(), this.defaultOptions.option = n;
772
+ }
773
+ };
774
+ }
775
+ const p = "common";
776
+ class K extends F {
777
+ /**
778
+ * 全局级别的默认选项
779
+ */
780
+ static modeOptions = new l(p);
781
+ /**
782
+ * 实例级的默认选项
783
+ */
784
+ get modeOptions() {
785
+ return this._modeOptions || (this._modeOptions = new l(p, void 0, this.constructor.modeOptions));
786
+ }
787
+ _modeOptions;
788
+ get mode() {
789
+ return this.modeOptions.mode;
790
+ }
791
+ set mode(t) {
792
+ this.modeOptions.mode = t;
793
+ }
794
+ get options() {
795
+ return this.modeOptions.plainFullOption;
796
+ }
797
+ constructor(t) {
798
+ super(), this.modeOptions.setOption(t);
799
+ }
800
+ }
801
+ function $(i) {
802
+ const t = b(i);
803
+ return class extends t {
804
+ /**
805
+ * 全局级别的默认选项
806
+ */
807
+ static modeOptions = new l(p);
808
+ /**
809
+ * 实例级的默认选项
810
+ */
811
+ get modeOptions() {
812
+ return this._modeOptions || (this._modeOptions = new l(p, void 0, this.constructor.modeOptions));
813
+ }
814
+ _modeOptions;
815
+ get mode() {
816
+ return this.modeOptions.mode;
817
+ }
818
+ set mode(n) {
819
+ this.modeOptions.mode = n;
820
+ }
821
+ get options() {
822
+ return this.modeOptions.plainFullOption;
823
+ }
824
+ constructor(n) {
825
+ super(), this.modeOptions.setOption(n);
826
+ }
827
+ };
828
+ }
829
+ export {
830
+ T as M,
831
+ d as P,
832
+ l as T,
833
+ u as a,
834
+ F as b,
835
+ p as c,
836
+ K as d,
837
+ I as e,
838
+ b as f,
839
+ $ as g,
840
+ z as h,
841
+ a as i,
842
+ f as j,
843
+ k,
844
+ N as l,
845
+ w as m,
846
+ E as n,
847
+ H as o,
848
+ y as p,
849
+ C as q,
850
+ P as s,
851
+ S as t
852
+ };