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