plugin-tls 1.1.1 → 2.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 (122) hide show
  1. package/dist/extend/extend.d.ts +8 -8
  2. package/dist/extend/extend.d.ts.map +1 -1
  3. package/dist/extend/mixin.d.ts.map +1 -1
  4. package/dist/index.js +1038 -0
  5. package/dist/index.umd.cjs +1 -0
  6. package/dist/options-manager/ModeOptions.d.ts.map +1 -1
  7. package/dist/options-manager/OptionsManager.d.ts.map +1 -1
  8. package/dist/options-manager/TierOptions.d.ts.map +1 -1
  9. package/dist/options-manager/defaultOptions.d.ts +2 -2
  10. package/dist/options-manager/defaultOptions.d.ts.map +1 -1
  11. package/dist/plugin-host/PluginHost.d.ts +97 -20
  12. package/dist/plugin-host/PluginHost.d.ts.map +1 -1
  13. package/dist/plugin-host/TierModeOptionsPluginHost.d.ts +83 -18
  14. package/dist/plugin-host/TierModeOptionsPluginHost.d.ts.map +1 -1
  15. package/dist/plugin-host/TierOptionsPluginHost.d.ts +80 -10
  16. package/dist/plugin-host/TierOptionsPluginHost.d.ts.map +1 -1
  17. package/dist/plugin-manager/PluginManager.d.ts +1 -1
  18. package/dist/plugin-manager/PluginManager.d.ts.map +1 -1
  19. package/doc/api/index.md +23 -3
  20. package/doc/api/plugin-tls.adddefaultoptions.md +51 -6
  21. package/doc/api/plugin-tls.addinstoptions.md +60 -6
  22. package/doc/api/plugin-tls.allfunctionapply.md +59 -5
  23. package/doc/api/plugin-tls.becomepluginhost.md +1 -1
  24. package/doc/api/plugin-tls.becomepluginhost_extends.md +45 -11
  25. package/doc/api/plugin-tls.becomepluginhost_proxy.md +32 -4
  26. package/doc/api/plugin-tls.becometiermodeoptionshost.md +1 -1
  27. package/doc/api/plugin-tls.becometieroptionshost.md +1 -1
  28. package/doc/api/plugin-tls.classextender.md +1 -1
  29. package/doc/api/plugin-tls.classextenderprivatemember.md +65 -5
  30. package/doc/api/plugin-tls.classextenderprivatememberwithinit.md +44 -4
  31. package/doc/api/plugin-tls.classextenderwithinit.md +1 -1
  32. package/doc/api/plugin-tls.classtype._new_.md +31 -3
  33. package/doc/api/plugin-tls.classtype.md +21 -3
  34. package/doc/api/plugin-tls.createcallerofprivatememberofextend.md +31 -3
  35. package/doc/api/plugin-tls.createextendtarget.md +33 -3
  36. package/doc/api/plugin-tls.createextendtargetwithinit.md +35 -5
  37. package/doc/api/plugin-tls.createmixintarget.md +31 -3
  38. package/doc/api/plugin-tls.createpluginhost.md +114 -9
  39. package/doc/api/plugin-tls.createpropertysetter.md +45 -4
  40. package/doc/api/plugin-tls.createtargetextend.md +33 -3
  41. package/doc/api/plugin-tls.createtargetextendwithinit.md +35 -5
  42. package/doc/api/plugin-tls.createtargetmixin.md +33 -3
  43. package/doc/api/plugin-tls.createtiermodeoptionspluginhost.md +117 -11
  44. package/doc/api/plugin-tls.createtieroptionspluginhost.md +114 -9
  45. package/doc/api/plugin-tls.defineextend.md +49 -4
  46. package/doc/api/plugin-tls.defineextendwithinit.md +49 -4
  47. package/doc/api/plugin-tls.definemixin.md +49 -4
  48. package/doc/api/plugin-tls.extendtarget.md +49 -4
  49. package/doc/api/plugin-tls.extendtargetwithinit.md +49 -4
  50. package/doc/api/plugin-tls.getpropertyvalue.md +45 -4
  51. package/doc/api/plugin-tls.getpropertyvaluebypath.md +45 -4
  52. package/doc/api/plugin-tls.gettargetproperties.md +45 -4
  53. package/doc/api/plugin-tls.hostinst.md +1 -1
  54. package/doc/api/plugin-tls.idefaultoptionshost.md +41 -3
  55. package/doc/api/plugin-tls.iplugin.created.md +49 -4
  56. package/doc/api/plugin-tls.iplugin.destroyed.md +49 -4
  57. package/doc/api/plugin-tls.iplugin.md +45 -5
  58. package/doc/api/plugin-tls.iplugin.used.md +49 -4
  59. package/doc/api/plugin-tls.ipluginhost.md +23 -3
  60. package/doc/api/plugin-tls.ipluginhost.use.md +45 -4
  61. package/doc/api/plugin-tls.ipluginhostconstructor.md +23 -3
  62. package/doc/api/plugin-tls.ipluginhostconstructor.use.md +49 -4
  63. package/doc/api/plugin-tls.ipluginwithinit.inited.md +49 -4
  64. package/doc/api/plugin-tls.ipluginwithinit.md +23 -3
  65. package/doc/api/plugin-tls.itiermodeoptionshost.md +58 -4
  66. package/doc/api/plugin-tls.itieroptionshost.md +41 -3
  67. package/doc/api/plugin-tls.md +960 -92
  68. package/doc/api/plugin-tls.mergeproperties.md +45 -4
  69. package/doc/api/plugin-tls.mixin_4.md +49 -4
  70. package/doc/api/plugin-tls.mixintarget.md +49 -4
  71. package/doc/api/plugin-tls.modeoptions._constructor_.md +31 -3
  72. package/doc/api/plugin-tls.modeoptions._constructor__1.md +47 -4
  73. package/doc/api/plugin-tls.modeoptions.getfullmodeoption.md +31 -3
  74. package/doc/api/plugin-tls.modeoptions.getmodeoption.md +31 -3
  75. package/doc/api/plugin-tls.modeoptions.hasmode.md +31 -3
  76. package/doc/api/plugin-tls.modeoptions.md +347 -23
  77. package/doc/api/plugin-tls.modeoptions.setmodeoption.md +77 -6
  78. package/doc/api/plugin-tls.parsepropertypath.md +31 -3
  79. package/doc/api/{plugin-tls.pluginhost.destroy.md → plugin-tls.pluginhost.destroythis.md} +3 -3
  80. package/doc/api/plugin-tls.pluginhost.md +150 -11
  81. package/doc/api/plugin-tls.pluginhost.use.md +49 -4
  82. package/doc/api/plugin-tls.pluginmanager._constructor_.md +33 -3
  83. package/doc/api/plugin-tls.pluginmanager.created.md +33 -3
  84. package/doc/api/plugin-tls.pluginmanager.destroyed.md +33 -3
  85. package/doc/api/plugin-tls.pluginmanager.instuse.md +61 -5
  86. package/doc/api/plugin-tls.pluginmanager.md +187 -14
  87. package/doc/api/plugin-tls.pluginmanager.use.md +49 -4
  88. package/doc/api/plugin-tls.pluginmanagerwithinit.inited.md +33 -3
  89. package/doc/api/plugin-tls.pluginmanagerwithinit.md +31 -3
  90. package/doc/api/plugin-tls.privatememberofextend._constructor.md +31 -3
  91. package/doc/api/plugin-tls.privatememberofextend.md +35 -5
  92. package/doc/api/plugin-tls.privatememberofextendwithinit._init.md +31 -3
  93. package/doc/api/plugin-tls.privatememberofextendwithinit.md +24 -4
  94. package/doc/api/plugin-tls.setpropertyvalue.md +59 -5
  95. package/doc/api/plugin-tls.setpropertyvaluebypath.md +59 -5
  96. package/doc/api/plugin-tls.targetextend.md +49 -4
  97. package/doc/api/plugin-tls.targetextendwithinit.md +49 -4
  98. package/doc/api/plugin-tls.targetmixin.md +49 -4
  99. package/doc/api/plugin-tls.tiermodeoptions._constructor_.md +31 -3
  100. package/doc/api/plugin-tls.tiermodeoptions._constructor__1.md +63 -5
  101. package/doc/api/plugin-tls.tiermodeoptions.getfullmodeoption.md +31 -3
  102. package/doc/api/plugin-tls.tiermodeoptions.getmember.md +31 -3
  103. package/doc/api/plugin-tls.tiermodeoptions.getmodeoptionmanager.md +31 -3
  104. package/doc/api/plugin-tls.tiermodeoptions.getvalue.md +31 -3
  105. package/doc/api/plugin-tls.tiermodeoptions.hasmodeontier.md +31 -3
  106. package/doc/api/plugin-tls.tiermodeoptions.md +227 -17
  107. package/doc/api/plugin-tls.tiermodeoptionsdecorator.md +45 -4
  108. package/doc/api/plugin-tls.tiermodeoptionspluginhost._constructor_.md +31 -3
  109. package/doc/api/plugin-tls.tiermodeoptionspluginhost.md +152 -10
  110. package/doc/api/plugin-tls.tieroptions._constructor_.md +49 -4
  111. package/doc/api/plugin-tls.tieroptions.getmember.md +31 -3
  112. package/doc/api/plugin-tls.tieroptions.getvalue.md +31 -3
  113. package/doc/api/plugin-tls.tieroptions.md +209 -15
  114. package/doc/api/plugin-tls.tieroptionsdecorator.md +45 -4
  115. package/doc/api/plugin-tls.tieroptionspluginhost._constructor_.md +31 -3
  116. package/doc/api/plugin-tls.tieroptionspluginhost.md +116 -8
  117. package/package.json +29 -20
  118. package/dist/plugin-tls.d.ts +0 -1329
  119. package/dist/plugin-tls.iife.js +0 -1
  120. package/dist/plugin-tls.mjs +0 -1064
  121. package/dist/plugin-tls.umd.js +0 -1
  122. package/dist/tsdoc-metadata.json +0 -11
package/dist/index.js ADDED
@@ -0,0 +1,1038 @@
1
+ import { deepmergeInto as M, deepmerge as w } from "deepmerge-ts";
2
+ import { WebDestroyable as V, createDestroyableSubClass as H } from "@gby/destroyable";
3
+ function l(n, ...t) {
4
+ for (const e of t) {
5
+ const i = Object.getOwnPropertyDescriptors(e);
6
+ Object.defineProperties(n, i);
7
+ }
8
+ return n;
9
+ }
10
+ function A(n, t) {
11
+ return t;
12
+ }
13
+ function k() {
14
+ return function(t, e) {
15
+ return e;
16
+ };
17
+ }
18
+ function z(n, t) {
19
+ return l(n, t), t;
20
+ }
21
+ function C(n) {
22
+ return function(e) {
23
+ return l(n, e), e;
24
+ };
25
+ }
26
+ function a(n, t) {
27
+ return l(n, t), n;
28
+ }
29
+ function $(n) {
30
+ return function(e) {
31
+ return l(n, e), n;
32
+ };
33
+ }
34
+ function S(n, t) {
35
+ return t;
36
+ }
37
+ function O(n, t) {
38
+ l(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 q(n) {
45
+ return function(e) {
46
+ return O(n, e), e;
47
+ };
48
+ }
49
+ function T(n, t) {
50
+ return O(n, t), n;
51
+ }
52
+ function B(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 K(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 R(n, t) {
75
+ return t;
76
+ }
77
+ function y(n, t) {
78
+ O(n, t);
79
+ const e = t._init;
80
+ return typeof e == "function" && (n._inits ?? (n._inits = [])).push(e), t;
81
+ }
82
+ function G(n) {
83
+ return function(e) {
84
+ return y(n, e), e;
85
+ };
86
+ }
87
+ function J(n, t) {
88
+ return y(n, t), n;
89
+ }
90
+ function L(n) {
91
+ return function(e) {
92
+ return y(n, e), n;
93
+ };
94
+ }
95
+ class g {
96
+ /**
97
+ * 插件的宿主
98
+ */
99
+ host;
100
+ /**
101
+ * 插件与插件选项的映射
102
+ */
103
+ pluginOptsMap = /* @__PURE__ */ new Map();
104
+ /**
105
+ * 注册的插件
106
+ */
107
+ plugins = [];
108
+ /**
109
+ * @param host - 插件的宿主
110
+ */
111
+ constructor(t) {
112
+ t && (this.host = t);
113
+ }
114
+ /**
115
+ * 使用插件、注册插件
116
+ * @param plugin - 插件
117
+ * @param options - 传递给插件的选项
118
+ */
119
+ use(t, ...e) {
120
+ const { pluginOptsMap: i, plugins: s, host: o } = this;
121
+ if (!s.includes(t))
122
+ return s.push(t), i.set(t, e[0]), t.used(o, e[0]);
123
+ }
124
+ /**
125
+ * 插件宿主创建实例时调用
126
+ *
127
+ * @remarks
128
+ * 会调用每个插件的 {@link IPlugin.created} 方法
129
+ * @param hostInst - 插件宿主的新实例
130
+ */
131
+ created(t) {
132
+ const { plugins: e, pluginOptsMap: i } = this;
133
+ for (const s of e) {
134
+ const o = i.get(s);
135
+ s.created?.(t, o);
136
+ }
137
+ }
138
+ /**
139
+ * 插件宿主被销毁时调用
140
+ *
141
+ * @remarks
142
+ * 会调用每个插件的 {@link IPlugin.destroyed} 方法
143
+ * @param hostInst - 被销毁的插件实例
144
+ */
145
+ destroyed(t) {
146
+ const { plugins: e, pluginOptsMap: i } = this;
147
+ for (const s of e) {
148
+ const o = i.get(s);
149
+ s.destroyed?.(t, o);
150
+ }
151
+ }
152
+ /**
153
+ * 插件宿主实例的注册插件的方法
154
+ *
155
+ * @remarks
156
+ * 会调用每个插件的 {@link IPlugin.use | IPlugin.created()} 方法
157
+ * @param hostInst - 插件宿主的新实例
158
+ */
159
+ instUse(t, e, ...i) {
160
+ if (!this.pluginOptsMap.has(e))
161
+ return this.use(e, ...i), e.created?.(t, ...i);
162
+ }
163
+ }
164
+ class Q extends g {
165
+ /**
166
+ * 插件宿主创建实例时调用
167
+ *
168
+ * @remarks
169
+ * 会调用每个插件的 {@link IPlugin.created | IPlugin.created()} 方法
170
+ * @param hostInst - 插件宿主的新实例
171
+ */
172
+ inited(t) {
173
+ const { plugins: e, pluginOptsMap: i } = this;
174
+ for (const s of e) {
175
+ const o = i.get(s);
176
+ s.inited?.(t, o);
177
+ }
178
+ }
179
+ }
180
+ function X(n, t) {
181
+ const e = t ?? "defaultOptions", i = `_${e}`;
182
+ return function(o) {
183
+ const r = a(o, {
184
+ /**
185
+ * 全局级别的默认选项
186
+ */
187
+ get [e]() {
188
+ return n;
189
+ }
190
+ });
191
+ T(r, {
192
+ /**
193
+ * 实例级的默认选项
194
+ */
195
+ get [e]() {
196
+ return this[i] || (this[i] = structuredClone(r.defaultOptions));
197
+ }
198
+ });
199
+ };
200
+ }
201
+ function Y(n, t, e) {
202
+ const i = `_${t}`;
203
+ return T(n, {
204
+ /**
205
+ * 实例级的默认选项
206
+ */
207
+ get [t]() {
208
+ return this[i] || (this[i] = structuredClone(n[t]));
209
+ }
210
+ }), e;
211
+ }
212
+ function F(n) {
213
+ const t = n.split(".");
214
+ return t[0] === "" && t.shift(), t;
215
+ }
216
+ function x(n, t) {
217
+ for (const e of t)
218
+ if (n = n[e], n == null) return;
219
+ return n;
220
+ }
221
+ function Z(n, t) {
222
+ return x(n, F(t));
223
+ }
224
+ function b(n, t, e) {
225
+ const i = t.pop(), s = t.length;
226
+ let o = 0;
227
+ for (; o < s; ) {
228
+ const r = n[t[o]];
229
+ if (r == null) break;
230
+ n = r, o++;
231
+ }
232
+ t = t.slice(o);
233
+ for (const r of t)
234
+ n = n[r] = {};
235
+ return n[i] = e, n;
236
+ }
237
+ function tt(n, t, e) {
238
+ return b(n, F(t), e);
239
+ }
240
+ const _ = {
241
+ UndefinedAndNull: function(t) {
242
+ return t == null;
243
+ },
244
+ Undefined: function(t) {
245
+ return t === void 0;
246
+ },
247
+ Null: function(t) {
248
+ return t === null;
249
+ }
250
+ };
251
+ class v {
252
+ /**
253
+ * 是否要冻结 fullOption 的成员
254
+ * @remarks
255
+ * 只会冻结 fullOption 的直接成员的值,不会冻结 fullOption 孙子成员的值
256
+ */
257
+ freezeMember = !0;
258
+ /**
259
+ * 可更新顶级成员值的完整的选项
260
+ * @remarks
261
+ * 合并后的选项;
262
+ * plainFullOption 的代理对象,自动监听了顶层成员的屐;所以可以更改顶级成员的值,不可以更改非顶级成员的值;
263
+ */
264
+ fullOption = new Proxy(this, {
265
+ // @ts-ignore
266
+ get: function(t, e, i) {
267
+ const s = t.plainFullOption[e];
268
+ return t.freezeMember ? Object.freeze(s) : s;
269
+ },
270
+ // @ts-ignore
271
+ set: function(t, e, i, s) {
272
+ return t.setMember(e, i, !1), !0;
273
+ },
274
+ // @ts-ignore
275
+ has: function(t, e) {
276
+ return e in t.plainFullOption;
277
+ },
278
+ // @ts-ignore
279
+ getOwnPropertyDescriptor: function(t, e) {
280
+ return Object.getOwnPropertyDescriptor(t.plainFullOption, e);
281
+ },
282
+ // @ts-ignore
283
+ ownKeys: function(t) {
284
+ return Reflect.ownKeys(t.plainFullOption);
285
+ },
286
+ // @ts-ignore
287
+ deleteProperty: function(t, e) {
288
+ return t.setMember(e, void 0), !0;
289
+ },
290
+ // @ts-ignore
291
+ defineProperty: function(t, e, i) {
292
+ return Object.defineProperty(t.option, e, i), !0;
293
+ }
294
+ });
295
+ /**
296
+ * 设置选项
297
+ * @remarks
298
+ * 会将被设置的选项浅合并进当前选项中
299
+ * @param option
300
+ * @param deep - 是否要进行深度合并
301
+ */
302
+ setOption(t, e) {
303
+ const i = e ? M(this.option, t) : Object.assign(this.option, t);
304
+ return this.updateFullOption(), i;
305
+ }
306
+ /**
307
+ * 未定义值的类型
308
+ */
309
+ get undefinedValue() {
310
+ return this._undefinedValue;
311
+ }
312
+ set undefinedValue(t) {
313
+ this._undefinedValue = t, this.isUndefined = _[t] || _.UndefinedAndNull;
314
+ }
315
+ _undefinedValue = "UndefinedAndNull";
316
+ /**
317
+ * 未定义值的判断函数
318
+ */
319
+ isUndefined = _.UndefinedAndNull;
320
+ /**
321
+ * 获取选项成员
322
+ * @param key
323
+ * @returns
324
+ */
325
+ getMember(t) {
326
+ return this.option[t];
327
+ }
328
+ /**
329
+ * 设置选项成员
330
+ * @param key
331
+ * @param value
332
+ * @param deep - 是否要进行深度合并
333
+ */
334
+ setMember(t, e, i) {
335
+ const s = this.option;
336
+ if (e === void 0)
337
+ delete s[t];
338
+ else {
339
+ const o = s[t];
340
+ i && o && typeof o == "object" ? M(o, e) : s[t] = e;
341
+ }
342
+ this.updateFullOption();
343
+ }
344
+ /**
345
+ * 获取属性路径对应的值
346
+ * @param propPath
347
+ * @returns
348
+ */
349
+ getValue(t) {
350
+ return x(this.option, t);
351
+ }
352
+ /**
353
+ * 设置属性路径对应的值
354
+ * @param propPath
355
+ * @param value
356
+ * @param deep - 是否要进行深度合并
357
+ * @returns
358
+ */
359
+ setValue(t, e, i) {
360
+ const s = this.option;
361
+ let o;
362
+ i && (o = x(s, t)) && typeof o == "object" ? M(o, e) : b(this.option, t, e), this.updateFullOption();
363
+ }
364
+ }
365
+ class p extends v {
366
+ constructor(t, e) {
367
+ super(), t && (this.option = t), e && (this.extends = e);
368
+ }
369
+ /**
370
+ * 继承的选项
371
+ */
372
+ get extends() {
373
+ return this._extends;
374
+ }
375
+ set extends(t) {
376
+ this._extends = t, this.updateFullOption();
377
+ }
378
+ _extends = null;
379
+ /**
380
+ * 选项
381
+ */
382
+ option = {};
383
+ /**
384
+ * 获取完整的选项
385
+ * @remarks
386
+ * 会与继承来的选项进行合并
387
+ */
388
+ get plainFullOption() {
389
+ let t = this._plainFullOption;
390
+ if (t) return t;
391
+ const { extends: e, option: i } = this;
392
+ if (t = i, e) {
393
+ const s = e.plainFullOption;
394
+ t = w(s, i);
395
+ }
396
+ return this._plainFullOption = t;
397
+ }
398
+ _plainFullOption = null;
399
+ /**
400
+ * 更新
401
+ */
402
+ updateFullOption() {
403
+ this._plainFullOption = null;
404
+ }
405
+ /**
406
+ * 获取选项成员
407
+ * @param key
408
+ * @returns
409
+ */
410
+ getMember(t) {
411
+ const e = this.option[t];
412
+ if (!this.isUndefined(e)) return e;
413
+ const i = this.extends;
414
+ if (i)
415
+ return i.getMember(t);
416
+ }
417
+ /**
418
+ * 获取属性路径对应的值
419
+ * @param propPath
420
+ * @returns
421
+ */
422
+ getValue(t) {
423
+ const e = super.getValue(t);
424
+ if (!this.isUndefined(e)) return e;
425
+ const i = this.extends;
426
+ if (i)
427
+ return i.getValue(t);
428
+ }
429
+ }
430
+ function et(n, t) {
431
+ const { name: e } = t, i = `_${e}`;
432
+ return {
433
+ get: function() {
434
+ return this[i] || (this[i] = new p(void 0, this.constructor[e]));
435
+ }
436
+ };
437
+ }
438
+ class E extends v {
439
+ constructor(t, e) {
440
+ super(), e && this.setModeOption(t, e), this.mode = t;
441
+ }
442
+ /**
443
+ * 模式的配置
444
+ */
445
+ modes = {};
446
+ /**
447
+ * 当前模式
448
+ */
449
+ get mode() {
450
+ return this._mode || (this.mode = this.modeNames[0]);
451
+ }
452
+ set mode(t) {
453
+ this._mode = t, this.hasMode(t) || this.setModeOption(t, {}), this.updateFullOption();
454
+ }
455
+ _mode;
456
+ /**
457
+ * 所有的模式名字
458
+ */
459
+ get modeNames() {
460
+ return this._modeNames || (this._modeNames = this.getModeNames());
461
+ }
462
+ _modeNames = null;
463
+ /**
464
+ * 获取所有的模式名字
465
+ * @returns
466
+ */
467
+ getModeNames() {
468
+ return Object.keys(this.modes);
469
+ }
470
+ /**
471
+ * 判断是否有某个模式
472
+ * @param mode
473
+ * @returns
474
+ */
475
+ hasMode(t) {
476
+ return !!this.modes[t];
477
+ }
478
+ /**
479
+ * 当前模式的选项
480
+ */
481
+ get optionManager() {
482
+ return this.modes[this.mode];
483
+ }
484
+ /**
485
+ * 当前模式对应的选项
486
+ */
487
+ get option() {
488
+ return this.optionManager.option;
489
+ }
490
+ get plainFullOption() {
491
+ return this._plainFullOption ?? (this._plainFullOption = this.getFullModeOption(this.mode));
492
+ }
493
+ _plainFullOption = null;
494
+ /**
495
+ * 更新
496
+ */
497
+ updateFullOption() {
498
+ this._plainFullOption = null, this._modeNames = null;
499
+ }
500
+ /**
501
+ * 返回已合并继承选项的选项
502
+ * @remarks
503
+ * 与继承选项只是浅合并
504
+ * @param mode
505
+ * @returns
506
+ */
507
+ getModeOption(t) {
508
+ return this.modes[t].option;
509
+ }
510
+ /**
511
+ * 返回已合并继承选项的完整选项
512
+ * @remarks
513
+ * 与继承选项合并
514
+ * @param mode
515
+ * @returns
516
+ */
517
+ getFullModeOption(t) {
518
+ return this.modes[t]?.plainFullOption;
519
+ }
520
+ /**
521
+ * 给模式设置选项
522
+ * @param mode
523
+ * @param option
524
+ * @param deep - 是否要进行深度合并
525
+ * @param extend - 继承哪个模式
526
+ */
527
+ setModeOption(t, e, i, s) {
528
+ const { modes: o } = this, r = o[t] || (o[t] = new p());
529
+ if (r.setOption(e, i), s) {
530
+ const u = o[s];
531
+ u && (r.extends = u);
532
+ }
533
+ return this.updateFullOption(), r;
534
+ }
535
+ }
536
+ class c extends E {
537
+ constructor(t, e, i) {
538
+ super(t, e), i && (this.extends = i);
539
+ }
540
+ /**
541
+ * 继承的选项
542
+ */
543
+ get extends() {
544
+ return this._extends;
545
+ }
546
+ set extends(t) {
547
+ this._extends = t, this.updateFullOption();
548
+ }
549
+ _extends = null;
550
+ /**
551
+ * 返回已合并继承选项的最终选项
552
+ * @remarks
553
+ * 与继承选项只是浅合并
554
+ * @param mode
555
+ * @returns
556
+ */
557
+ getFullModeOption(t) {
558
+ const { modes: e, extends: i } = this, s = e[t]?.plainFullOption;
559
+ if (i) {
560
+ const o = i.getFullModeOption(t);
561
+ return s ? w(o, s) : o;
562
+ }
563
+ return s;
564
+ }
565
+ /**
566
+ * 获取所有的模式名字
567
+ * @returns
568
+ */
569
+ getModeNames() {
570
+ const { modes: t, extends: e } = this, i = Object.keys(t);
571
+ if (!e) return i;
572
+ const s = e.getModeNames();
573
+ return [.../* @__PURE__ */ new Set([...i, ...s])];
574
+ }
575
+ /**
576
+ * 在整个层级上判断是否有某个模式
577
+ * @param mode
578
+ * @returns
579
+ */
580
+ hasModeOnTier(t) {
581
+ if (this.hasMode(t)) return !0;
582
+ const e = this.extends;
583
+ return e ? e.hasModeOnTier(t) : !1;
584
+ }
585
+ /**
586
+ * 当前模式的选项
587
+ */
588
+ get optionManager() {
589
+ return this.getModeOptionManager(this.mode);
590
+ }
591
+ /**
592
+ * 获取模式对应的选项管理器
593
+ * @param mode
594
+ * @returns
595
+ */
596
+ getModeOptionManager(t) {
597
+ const e = this.modes[t];
598
+ return e || (this.extends?.getModeOptionManager(t) ? this.setModeOption(t, {}) : null);
599
+ }
600
+ /**
601
+ * 获取选项成员
602
+ * @param key
603
+ * @returns
604
+ */
605
+ getMember(t) {
606
+ const e = this.optionManager.getMember(t);
607
+ if (!this.isUndefined(e)) return e;
608
+ const i = this.extends;
609
+ if (i)
610
+ return i.getMember(t);
611
+ }
612
+ /**
613
+ * 获取属性路径对应的值
614
+ * @param propPath
615
+ * @returns
616
+ */
617
+ getValue(t) {
618
+ const e = this.optionManager.getValue(t);
619
+ if (!this.isUndefined(e)) return e;
620
+ const i = this.extends;
621
+ if (i)
622
+ return i.getValue(t);
623
+ }
624
+ }
625
+ function nt(n, t) {
626
+ const { name: e } = t, i = `_${e}`;
627
+ return {
628
+ get: function() {
629
+ return this[i] || (this[i] = new c(this.constructor[e].mode, void 0, this.constructor[e]));
630
+ }
631
+ };
632
+ }
633
+ class N extends V {
634
+ /**
635
+ * 插件管理器
636
+ */
637
+ static get pluginManager() {
638
+ let t = this._pluginManager;
639
+ return t || (t = this._pluginManager = new g(this)), t;
640
+ }
641
+ static _pluginManager;
642
+ /**
643
+ * 插件管理器 {@link PluginHost.pluginManager}
644
+ */
645
+ get pluginManager() {
646
+ return this.constructor.pluginManager;
647
+ }
648
+ /**
649
+ * {@inheritDoc PluginManager.use}
650
+ */
651
+ static use(t, ...e) {
652
+ return this.pluginManager.use(t, ...e);
653
+ }
654
+ /**
655
+ * 需要在子类中调用
656
+ *
657
+ * 之所以没写在该类中的函数中,是因为 `this.pluginManager.created(this)` 通常会在构建函数执行的最后时才调用;
658
+ * 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.created(this)` 不是在最后的执行;
659
+ */
660
+ // constructor() {
661
+ // this.pluginManager.created(this);
662
+ // }
663
+ /**
664
+ * 实例的注册插件的方法
665
+ * @param plugin
666
+ * @param options
667
+ * @returns
668
+ */
669
+ use(t, ...e) {
670
+ return this.pluginManager.instUse(this, t, ...e);
671
+ }
672
+ /**
673
+ * 销毁实例
674
+ * @returns
675
+ */
676
+ destroyThis() {
677
+ return this.pluginManager.destroyed(this), super.destroyThis();
678
+ }
679
+ }
680
+ function U(n) {
681
+ const t = H(n);
682
+ return class extends t {
683
+ /**
684
+ * PluginHost 的插件管理器
685
+ */
686
+ static get pluginManager() {
687
+ let i = this._pluginManager;
688
+ return i || (i = this._pluginManager = new g(this)), i;
689
+ }
690
+ static _pluginManager;
691
+ /**
692
+ * 插件管理器 {@link CEarth.pluginManager}
693
+ */
694
+ get pluginManager() {
695
+ return this.constructor.pluginManager;
696
+ }
697
+ /**
698
+ * {@inheritDoc PluginManager.use}
699
+ */
700
+ static use(i, ...s) {
701
+ return this.pluginManager.use(i, ...s);
702
+ }
703
+ // constructor() {
704
+ // this.pluginManager.created(this as HostInst<PHOST>);
705
+ // }
706
+ /**
707
+ /**
708
+ * 实例的注册插件的方法
709
+ * @param plugin
710
+ * @param options
711
+ * @returns
712
+ */
713
+ use(i, ...s) {
714
+ return this.pluginManager.instUse(this, i, ...s);
715
+ }
716
+ /**
717
+ * 销毁实例
718
+ * @returns
719
+ */
720
+ destroyThis() {
721
+ return this.pluginManager.destroyed(this), super.destroyThis();
722
+ }
723
+ };
724
+ }
725
+ function D(n) {
726
+ const t = a(n, {
727
+ /**
728
+ * PluginHost 的插件管理器
729
+ */
730
+ get pluginManager() {
731
+ let e = this._pluginManager;
732
+ return e || (e = this._pluginManager = new g(this)), e;
733
+ },
734
+ // _pluginManager: PluginManager<HOST,Plugin>;
735
+ /**
736
+ * {@inheritDoc PluginManager.use}
737
+ */
738
+ use(e, i) {
739
+ return this.pluginManager.use(e, i);
740
+ }
741
+ });
742
+ return a(t.prototype, {
743
+ /**
744
+ * 插件管理器
745
+ */
746
+ get pluginManager() {
747
+ return this.constructor.pluginManager;
748
+ },
749
+ /**
750
+ * 实例的注册插件的方法
751
+ * @param plugin
752
+ * @param options
753
+ * @returns
754
+ */
755
+ use(e, i) {
756
+ return this.pluginManager.instUse(this, e, i);
757
+ },
758
+ /**
759
+ * 销毁实例
760
+ * @returns
761
+ */
762
+ destroy() {
763
+ return this.pluginManager.destroyed(this);
764
+ }
765
+ }), n;
766
+ }
767
+ function st(n) {
768
+ const t = D(n);
769
+ return new Proxy(n, {
770
+ construct: function(e, i, s) {
771
+ const o = new e(...i);
772
+ return t.pluginManager.created(this), o;
773
+ }
774
+ });
775
+ }
776
+ function rt(n) {
777
+ return class extends n {
778
+ /**
779
+ * 插件管理器
780
+ */
781
+ static get pluginManager() {
782
+ let e = this._pluginManager;
783
+ return e || (e = this._pluginManager = new g(this)), e;
784
+ }
785
+ static _pluginManager;
786
+ /**
787
+ * 插件管理器 {@link PluginHost.pluginManager}
788
+ */
789
+ get pluginManager() {
790
+ return this.constructor.pluginManager;
791
+ }
792
+ /**
793
+ * {@inheritDoc PluginManager.use}
794
+ */
795
+ static use(e, ...i) {
796
+ return this.pluginManager.use(e, ...i);
797
+ }
798
+ constructor(...e) {
799
+ super(...e), this.pluginManager.created(this);
800
+ }
801
+ /**
802
+ * 实例的注册插件的方法
803
+ * @param plugin
804
+ * @param options
805
+ * @returns
806
+ */
807
+ use(e, ...i) {
808
+ return this.pluginManager.instUse(this, e, ...i);
809
+ }
810
+ /**
811
+ * 销毁实例
812
+ * @returns
813
+ */
814
+ destroy() {
815
+ return this.pluginManager.destroyed(this);
816
+ }
817
+ };
818
+ }
819
+ class ut extends N {
820
+ /**
821
+ * 全局级别的默认选项
822
+ */
823
+ static defaultOptions = new p();
824
+ /**
825
+ * 实例级的默认选项
826
+ */
827
+ get defaultOptions() {
828
+ return this._defaultOptions || (this._defaultOptions = new p(void 0, this.constructor.defaultOptions));
829
+ }
830
+ _defaultOptions;
831
+ constructor(t) {
832
+ super(), this.defaultOptions.option = t;
833
+ }
834
+ }
835
+ function at(n) {
836
+ const t = U(n);
837
+ return class extends t {
838
+ /**
839
+ * 全局级别的默认选项
840
+ */
841
+ static defaultOptions = new p();
842
+ /**
843
+ * 实例级的默认选项
844
+ */
845
+ get defaultOptions() {
846
+ return this._defaultOptions || (this._defaultOptions = new p(void 0, this.constructor.defaultOptions));
847
+ }
848
+ _defaultOptions;
849
+ constructor(i) {
850
+ super(), this.defaultOptions.option = i;
851
+ }
852
+ };
853
+ }
854
+ function ct(n, t) {
855
+ const e = a(n, {
856
+ /**
857
+ * 全局级别的默认选项
858
+ */
859
+ defaultOptions: new p(t)
860
+ });
861
+ return a(e.prototype, {
862
+ /**
863
+ * 实例级的默认选项
864
+ */
865
+ get defaultOptions() {
866
+ return this._defaultOptions || (this._defaultOptions = new p(void 0, this.constructor.defaultOptions));
867
+ }
868
+ }), n;
869
+ }
870
+ const h = "common";
871
+ class dt extends N {
872
+ /**
873
+ * 全局级别的默认选项
874
+ */
875
+ static modeOptions = new c(h);
876
+ /**
877
+ * 实例级的默认选项
878
+ */
879
+ get modeOptions() {
880
+ return this._modeOptions || (this._modeOptions = new c(h, void 0, this.constructor.modeOptions));
881
+ }
882
+ _modeOptions;
883
+ get mode() {
884
+ return this.modeOptions.mode;
885
+ }
886
+ set mode(t) {
887
+ this.modeOptions.mode = t;
888
+ }
889
+ get options() {
890
+ return this.modeOptions.plainFullOption;
891
+ }
892
+ constructor(t) {
893
+ super(), this.modeOptions.setOption(t);
894
+ }
895
+ }
896
+ function gt(n) {
897
+ const t = U(n);
898
+ return class extends t {
899
+ /**
900
+ * 全局级别的默认选项
901
+ */
902
+ static modeOptions = new c(h);
903
+ /**
904
+ * 实例级的默认选项
905
+ */
906
+ get modeOptions() {
907
+ return this._modeOptions || (this._modeOptions = new c(h, void 0, this.constructor.modeOptions));
908
+ }
909
+ _modeOptions;
910
+ get mode() {
911
+ return this.modeOptions.mode;
912
+ }
913
+ set mode(i) {
914
+ this.modeOptions.mode = i;
915
+ }
916
+ get options() {
917
+ return this.modeOptions.plainFullOption;
918
+ }
919
+ constructor(i) {
920
+ super(), this.modeOptions.setOption(i);
921
+ }
922
+ };
923
+ }
924
+ function ft(n, t, e) {
925
+ const i = a(n, {
926
+ /**
927
+ * 全局级别的默认选项
928
+ */
929
+ modeOptions: new c(t, e)
930
+ });
931
+ return a(i.prototype, {
932
+ /**
933
+ * 实例级的默认选项
934
+ */
935
+ get modeOptions() {
936
+ return this._modeOptions || (this._modeOptions = new c(t, void 0, this.constructor.modeOptions));
937
+ },
938
+ get mode() {
939
+ return this.modeOptions.mode;
940
+ },
941
+ set mode(s) {
942
+ this.modeOptions.mode = s;
943
+ },
944
+ get options() {
945
+ return this.modeOptions.fullOption;
946
+ }
947
+ }), n;
948
+ }
949
+ function P(n, t) {
950
+ const e = [{ target: n, props: t }];
951
+ let i;
952
+ for (; i = e.shift(); ) {
953
+ const { target: s, props: o } = i;
954
+ for (const [r, u] of Object.entries(o)) {
955
+ if (u != null && typeof u == "object" && (!u.constructor || u.constructor === Object)) {
956
+ e.push({ target: s[r], props: u });
957
+ continue;
958
+ }
959
+ s[r] = u;
960
+ }
961
+ }
962
+ return n;
963
+ }
964
+ function j(n, t) {
965
+ const e = {}, i = [{ target: n, props: t, targetProps: e }];
966
+ let s;
967
+ for (; s = i.shift(); ) {
968
+ const { target: o, props: r, targetProps: u } = s;
969
+ for (const [f, d] of Object.entries(r)) {
970
+ if (d != null && typeof d == "object" && (!d.constructor || d.constructor === Object)) {
971
+ i.push({ target: o[f], props: d, targetProps: u[f] = {} });
972
+ continue;
973
+ }
974
+ u[f] = o[f];
975
+ }
976
+ }
977
+ return e;
978
+ }
979
+ function ht(n, t) {
980
+ const e = j(n, t);
981
+ function i() {
982
+ P(n, t);
983
+ }
984
+ function s() {
985
+ P(n, e);
986
+ }
987
+ return { set: i, unset: s };
988
+ }
989
+ export {
990
+ E as ModeOptions,
991
+ N as PluginHost,
992
+ g as PluginManager,
993
+ Q as PluginManagerWithInit,
994
+ c as TierModeOptions,
995
+ dt as TierModeOptionsPluginHost,
996
+ p as TierOptions,
997
+ ut as TierOptionsPluginHost,
998
+ X as addDefaultOptions,
999
+ Y as addInstOptions,
1000
+ m as allFunctionApply,
1001
+ D as becomePluginHost,
1002
+ rt as becomePluginHost_Extends,
1003
+ st as becomePluginHost_Proxy,
1004
+ ft as becomeTierModeOptionsHost,
1005
+ ct as becomeTierOptionsHost,
1006
+ h as commonModeName,
1007
+ K as createCallerOfPrivateMemberOfExtend,
1008
+ k as createDefineMixin,
1009
+ B as createExtendTarget,
1010
+ L as createExtendTargetWithInit,
1011
+ $ as createMixinTarget,
1012
+ U as createPluginHost,
1013
+ ht as createPropertySetter,
1014
+ q as createTargetExtend,
1015
+ G as createTargetExtendWithInit,
1016
+ C as createTargetMixin,
1017
+ gt as createTierModeOptionsPluginHost,
1018
+ at as createTierOptionsPluginHost,
1019
+ S as defineExtend,
1020
+ R as defineExtendWithInit,
1021
+ A as defineMixin,
1022
+ T as extendTarget,
1023
+ J as extendTargetWithInit,
1024
+ x as getPropertyValue,
1025
+ Z as getPropertyValueByPath,
1026
+ j as getTargetProperties,
1027
+ P as mergeProperties,
1028
+ l as mixin,
1029
+ a as mixinTarget,
1030
+ F as parsePropertyPath,
1031
+ b as setPropertyValue,
1032
+ tt as setPropertyValueByPath,
1033
+ O as targetExtend,
1034
+ y as targetExtendWithInit,
1035
+ z as targetMixin,
1036
+ nt as tierModeOptionsDecorator,
1037
+ et as tierOptionsDecorator
1038
+ };