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