plugin-tls 5.3.0 → 5.5.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 (43) hide show
  1. package/dist/createTierModeOptionsPluginHost-B8wx-Fm2.cjs +1 -0
  2. package/dist/{createTierModeOptionsPluginHost-DWMl3oQA.js → createTierModeOptionsPluginHost-Ctr7S9XZ.js} +133 -110
  3. package/dist/index-node.cjs +1 -1
  4. package/dist/index-node.js +4 -4
  5. package/dist/index-web.cjs +1 -1
  6. package/dist/index-web.js +50 -50
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.js +154 -121
  9. package/dist/options/options-manager/ModeOptions.d.ts +1 -1
  10. package/dist/options/options-manager/ModeOptions.d.ts.map +1 -1
  11. package/dist/options/options-manager/OptionsManager.d.ts +36 -0
  12. package/dist/options/options-manager/OptionsManager.d.ts.map +1 -1
  13. package/dist/options/options-manager/TierModeOptions.d.ts +1 -1
  14. package/dist/options/options-manager/TierModeOptions.d.ts.map +1 -1
  15. package/dist/options/options-manager/tools.d.ts +22 -0
  16. package/dist/options/options-manager/tools.d.ts.map +1 -1
  17. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts +1 -1
  18. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts.map +1 -1
  19. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts +1 -1
  20. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts.map +1 -1
  21. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts +1 -1
  22. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts.map +1 -1
  23. package/dist/options/options-plugin-host/tier-mode-options/createTierModeOptionsPluginHost.d.ts +1 -1
  24. package/dist/options/options-plugin-host/tier-mode-options/createTierModeOptionsPluginHost.d.ts.map +1 -1
  25. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts +1 -1
  26. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts.map +1 -1
  27. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts +1 -1
  28. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts.map +1 -1
  29. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts +1 -1
  30. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts.map +1 -1
  31. package/dist/options/options-plugin-host/tier-options/createTierOptionsPluginHost.d.ts +1 -1
  32. package/dist/options/options-plugin-host/tier-options/createTierOptionsPluginHost.d.ts.map +1 -1
  33. package/dist/options/plugins/tier-mode-options/decorator.d.ts.map +1 -1
  34. package/dist/options/plugins/tier-mode-options/plugin.d.ts.map +1 -1
  35. package/dist/options/plugins/tier-mode-options/type.d.ts +5 -0
  36. package/dist/options/plugins/tier-mode-options/type.d.ts.map +1 -1
  37. package/dist/options/plugins/tier-options/decorator.d.ts +2 -1
  38. package/dist/options/plugins/tier-options/decorator.d.ts.map +1 -1
  39. package/dist/options/plugins/tier-options/plugin.d.ts.map +1 -1
  40. package/dist/options/plugins/tier-options/type.d.ts +13 -8
  41. package/dist/options/plugins/tier-options/type.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/createTierModeOptionsPluginHost-C-if5dn9.cjs +0 -1
package/dist/index-web.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { a as o } from "./Destroyable-mrBsNabq-D6TYs3Zn.js";
2
2
  import { serialCallAllFuns as g } from "com-tools";
3
- import { P as d, T as a, c as u, d as l } from "./createTierModeOptionsPluginHost-DWMl3oQA.js";
4
- import { f as P, g as D, p as b, q as x } from "./createTierModeOptionsPluginHost-DWMl3oQA.js";
3
+ import { P as d, T as a, c as u, d as l } from "./createTierModeOptionsPluginHost-Ctr7S9XZ.js";
4
+ import { f as P, g as D, p as b, q as x } from "./createTierModeOptionsPluginHost-Ctr7S9XZ.js";
5
5
  if (!globalThis.CustomEvent) {
6
- class s extends Event {
6
+ class e extends Event {
7
7
  detail;
8
- constructor(e, i) {
9
- super(e, i), this.detail = i?.detail;
8
+ constructor(s, i) {
9
+ super(s, i), this.detail = i?.detail;
10
10
  }
11
11
  }
12
- globalThis.CustomEvent = s;
12
+ globalThis.CustomEvent = e;
13
13
  }
14
14
  class f extends EventTarget {
15
15
  /**
@@ -23,19 +23,19 @@ class f extends EventTarget {
23
23
  * @param options - 选项
24
24
  * @returns 返回用于移除事件监听器的函数; 也可以通过 `EventTarget#removeEventListener` 方法移除
25
25
  */
26
- addEventListener(t, e, i) {
26
+ addEventListener(t, s, i) {
27
27
  const r = i?.times;
28
28
  if (r) {
29
- const n = typeof e == "function" ? e : e?.handleEvent;
29
+ const n = typeof s == "function" ? s : s?.handleEvent;
30
30
  if (n)
31
31
  return this.multipleListen(t, n, r);
32
32
  }
33
- return super.addEventListener(t, e, i), () => {
34
- this.removeEventListener(t, e, i);
33
+ return super.addEventListener(t, s, i), () => {
34
+ this.removeEventListener(t, s, i);
35
35
  };
36
36
  }
37
- dispatchEvent(t, e) {
38
- const i = t instanceof Event ? t : new CustomEvent(t, { detail: e, bubbles: !1, cancelable: !0, composed: !1 });
37
+ dispatchEvent(t, s) {
38
+ const i = t instanceof Event ? t : new CustomEvent(t, { detail: s, bubbles: !1, cancelable: !0, composed: !1 });
39
39
  return super.dispatchEvent(i);
40
40
  }
41
41
  /**
@@ -49,8 +49,8 @@ class f extends EventTarget {
49
49
  * @param options - 选项
50
50
  * @returns removeEventListener():void; 返回用于移除一次性事件监听器的函数; 也可以通过 EventTarget 的 removeEventListener 方法移除
51
51
  */
52
- onceListen(t, e, i) {
53
- return this.addEventListener(t, e, { ...i, once: !0 });
52
+ onceListen(t, s, i) {
53
+ return this.addEventListener(t, s, { ...i, once: !0 });
54
54
  }
55
55
  /**
56
56
  * 添加监听指定次数的事件监听器;
@@ -63,11 +63,11 @@ class f extends EventTarget {
63
63
  * @param times 需要监听的次数,如果小于 1 ,永远不会自动移除事件监听器,需要手动移除
64
64
  * @returns removeEventListener():void; 返回用于移除事件监听器的函数; 不能通过 EventTarget 的 removeEventListener 方法移除
65
65
  */
66
- multipleListen(t, e, i) {
66
+ multipleListen(t, s, i) {
67
67
  let r = 0;
68
68
  const n = new AbortController(), p = n.signal;
69
69
  return super.addEventListener(t, (c) => {
70
- ++r >= i && n.abort(), e.call(this, c);
70
+ ++r >= i && n.abort(), s.call(this, c);
71
71
  }, { signal: p }), function() {
72
72
  n.abort();
73
73
  };
@@ -83,42 +83,42 @@ var O = class extends f {
83
83
  return !this.isDestroyed && this.refCount <= 0;
84
84
  }
85
85
  _destroyers = [];
86
- disposeFun(s) {
87
- return this._destroyers.push(s), s;
86
+ disposeFun(e) {
87
+ return this._destroyers.push(e), e;
88
88
  }
89
- cancelDisposeFun(s) {
90
- let t = this._destroyers.indexOf(s);
91
- return this._destroyers.splice(t, 1), s;
89
+ cancelDisposeFun(e) {
90
+ let t = this._destroyers.indexOf(e);
91
+ return this._destroyers.splice(t, 1), e;
92
92
  }
93
- disposeObj(s, t) {
94
- let e = t ? function() {
95
- return s.destroySync();
93
+ disposeObj(e, t) {
94
+ let s = t ? function() {
95
+ return e.destroySync();
96
96
  } : function() {
97
- return s.destroy();
97
+ return e.destroy();
98
98
  };
99
- return this.disposeFun(e), s.__destroyable_destroyer = e, s;
99
+ return this.disposeFun(s), e.__destroyable_destroyer = s, e;
100
100
  }
101
- cancelDisposeObj(s) {
102
- let t = s.__destroyable_destroyer;
103
- return t && this.cancelDisposeFun(t), s;
101
+ cancelDisposeObj(e) {
102
+ let t = e.__destroyable_destroyer;
103
+ return t && this.cancelDisposeFun(t), e;
104
104
  }
105
- dispose(s, t) {
106
- return typeof s == "function" ? this.disposeFun(s) : this.disposeObj(s, t);
105
+ dispose(e, t) {
106
+ return typeof e == "function" ? this.disposeFun(e) : this.disposeObj(e, t);
107
107
  }
108
- cancelDispose(s) {
109
- return typeof s == "function" ? this.cancelDisposeFun(s) : this.cancelDisposeObj(s);
108
+ cancelDispose(e) {
109
+ return typeof e == "function" ? this.cancelDisposeFun(e) : this.cancelDisposeObj(e);
110
110
  }
111
111
  destroyThis() {
112
112
  }
113
113
  destroySync() {
114
114
  if (!this.canDestroy) return this.isDestroyed;
115
- let s = this._destroyers.length;
116
- for (; --s >= 0; ) {
117
- let t = this._destroyers[s];
115
+ let e = this._destroyers.length;
116
+ for (; --e >= 0; ) {
117
+ let t = this._destroyers[e];
118
118
  try {
119
119
  t();
120
- } catch (e) {
121
- console.error("销毁函数在同步销毁时出错", this, t, e);
120
+ } catch (s) {
121
+ console.error("销毁函数在同步销毁时出错", this, t, s);
122
122
  }
123
123
  }
124
124
  this._destroyers.length = 0;
@@ -131,10 +131,10 @@ var O = class extends f {
131
131
  }
132
132
  destroy() {
133
133
  if (!this.canDestroy) return this.isDestroyed;
134
- let s = this._destroyers.toReversed();
135
- s.push(this.destroyThis), this._destroyers.length = 0;
136
- let t = g(s, this, null, (e, i) => {
137
- console.error("销毁函数在串行销毁时出错", this, i, e);
134
+ let e = this._destroyers.toReversed();
135
+ e.push(this.destroyThis), this._destroyers.length = 0;
136
+ let t = g(e, this, null, (s, i) => {
137
+ console.error("销毁函数在串行销毁时出错", this, i, s);
138
138
  });
139
139
  return t instanceof Promise ? t.then(() => (o(this), !0)) : (o(this), !0);
140
140
  }
@@ -161,8 +161,8 @@ class h extends O {
161
161
  /**
162
162
  * {@inheritDoc PluginExtendManager.usePlugin}
163
163
  */
164
- static usePlugin(t, ...e) {
165
- return this.pluginManager.usePlugin(t, ...e);
164
+ static usePlugin(t, ...s) {
165
+ return this.pluginManager.usePlugin(t, ...s);
166
166
  }
167
167
  /**
168
168
  * {@inheritDoc PluginExtendManager.useExtend}
@@ -195,14 +195,14 @@ class h extends O {
195
195
  * @param args
196
196
  * @returns
197
197
  */
198
- usePlugin(t, ...e) {
199
- return this.pluginManager.instUsePlugin(this, t, ...e);
198
+ usePlugin(t, ...s) {
199
+ return this.pluginManager.instUsePlugin(this, t, ...s);
200
200
  }
201
201
  /**
202
202
  * {@inheritDoc PluginExtendManager.useExtend}
203
203
  */
204
- useExtend(t, ...e) {
205
- return this.pluginManager.instUseExtend(this, t, ...e);
204
+ useExtend(t, ...s) {
205
+ return this.pluginManager.instUseExtend(this, t, ...s);
206
206
  }
207
207
  /**
208
208
  * 初始化实例
@@ -252,7 +252,7 @@ class v extends h {
252
252
  return this.modeOptions.plainFullOption;
253
253
  }
254
254
  constructor(t) {
255
- super(), this.modeOptions.setOption(t);
255
+ super(), t && this.modeOptions.setOption(t);
256
256
  }
257
257
  }
258
258
  class M extends h {
@@ -276,7 +276,7 @@ class M extends h {
276
276
  }
277
277
  _defaultOptions;
278
278
  constructor(t) {
279
- super(), this.defaultOptions.option = t;
279
+ super(), t && (this.defaultOptions.option = t);
280
280
  }
281
281
  }
282
282
  export {
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@gby/destroyable"),p=require("com-tools"),n=require("./createTierModeOptionsPluginHost-C-if5dn9.cjs"),g=require("type-tls");function m(r,t){return t}function M(r){return function(e){return e}}function O(r,t){return n.mixin(r.prototype,t),t}function P(r){return function(e){return n.mixin(r.prototype,e),e}}function y(r,t){return n.mixin(r.prototype,t),r}function T(r){return function(e){return n.mixin(r.prototype,e),r}}class E extends h.Destroyable{parent;host;plugins=new Map;constructor(t,e){super(),this.parent=e,t&&(this.host=t)}destroyThis(){return this.plugins.clear(),this.host=null,super.destroyThis()}hasUsed(t){return this.parent?.hasUsed(t)||this.plugins.has(t)}getUseReturn(t){const{parent:e}=this;return e?.hasUsed(t)?e.getUseReturn(t):this.plugins.get(t)}use(t,...e){if(this.hasUsed(t))return this.getUseReturn(t);const i=t.onUse(this.host,...e);return this.plugins.set(t,i),i}instUse(t,e,...i){const{plugins:s}=this;if(this.hasUsed(e))return this.getUseReturn(e);const o=this.use(e,...i);return e.onCreate?.(t),o}onCreate(t,...e){const i=this.parent?.onCreate(t,...e),s=[];for(const[o]of this.plugins)o.onCreate&&s.push(o.onCreate.bind(o));return g.waitAsyncable(i,()=>p.serialCallFuns(s,void 0,[t,...e]))}onInit(t,...e){const i=this.parent?.onInit(t,...e),s=[];for(const[o]of this.plugins)o.onInit&&s.push(o.onInit.bind(o));return g.waitAsyncable(i,()=>p.serialCallFuns(s,void 0,[t,...e]))}onDestroy(t){const e=[];for(const[o]of this.plugins)o.onDestroy&&e.push(o.onDestroy.bind(o));e.reverse();const i=p.serialCallFuns(e,void 0,[t]),{parent:s}=this;return s?g.waitAsyncable(i,()=>s.onDestroy(t)):i}}class b extends h.Destroyable{parent;host;plugins=new Set;constructor(t,e){super(),this.parent=e,t&&(this.host=t)}destroyThis(){return this.plugins.clear(),this.host=null,super.destroyThis()}hasUsed(t){return this.parent?.hasUsed(t)||this.plugins.has(t)}use(t){return this.hasUsed(t)||(n.mixinIExtend(this.host.prototype,t),this.plugins.add(t)),t}instUse(t,e,...i){return this.hasUsed(e)||(this.use(e),e.onCreate?.call(t,t,...i)),e}onCreate(t,...e){const i=this.parent?.onCreate(t,...e),s=[];for(const o of this.plugins)o.onCreate&&s.push(o.onCreate);return g.waitAsyncable(i,()=>p.serialCallFuns(s,t,[t,...e]))}onInit(t,...e){const i=this.parent?.onInit(t,...e),s=[];for(const o of this.plugins)o.onInit&&s.push(o.onInit);return g.waitAsyncable(i,()=>p.serialCallFuns(s,t,[t,...e]))}onDestroy(t){const e=[];for(const o of this.plugins)o.onDestroy&&e.push(o.onDestroy);e.reverse();const i=p.serialCallFuns(e,t,[t]),{parent:s}=this;return s?g.waitAsyncable(i,()=>s.onDestroy(t)):i}}function d(r,t){const e=[{target:r,props:t}];let i;for(;i=e.shift();){const{target:s,props:o}=i;for(const[u,a]of Object.entries(o)){if(a!=null&&typeof a=="object"&&(!a.constructor||a.constructor===Object)){e.push({target:s[u],props:a});continue}s[u]=a}}return r}function f(r,t){const e={},i=[{target:r,props:t,targetProps:e}];let s;for(;s=i.shift();){const{target:o,props:u,targetProps:a}=s;for(const[c,l]of Object.entries(u)){if(l!=null&&typeof l=="object"&&(!l.constructor||l.constructor===Object)){i.push({target:o[c],props:l,targetProps:a[c]={}});continue}a[c]=o[c]}}return e}function w(r,t){const e=f(r,t);function i(){d(r,t)}function s(){d(r,e)}return{set:i,unset:s}}function U(r,t){const e=t??"defaultOptions",i=`_${e}`;return function(o){const u=n.mixinTarget(o,{get[e](){return r}});n.mixinTarget(u.prototype,{get[e](){return this[i]||(this[i]=structuredClone(u.defaultOptions))}})}}function C(r,t,e){const i=`_${t}`;return n.mixinTarget(r.prototype,{get[t](){return this[i]||(this[i]=structuredClone(r[t]))}}),e}function D(r,t,e){const i=n.mixinTarget(r,{modeOptions:new n.TierModeOptions(t,e)});return n.mixinTarget(i.prototype,{get modeOptions(){return this._modeOptions||(this._modeOptions=new n.TierModeOptions(t,void 0,this.constructor.modeOptions))},get mode(){return this.modeOptions.mode},set mode(s){this.modeOptions.mode=s},get options(){return this.modeOptions.fullOption}}),r}const _={onUse(r,t,e){const i=t??n.commonModeName;n.mixin(r,{modeOptions:new n.TierModeOptions(i,void 0,e)}),n.mixin(r.prototype,{get modeOptions(){const s=this,o=r;return s._modeOptions||(s._modeOptions=new n.TierModeOptions(o.modeOptions.mode,void 0,o.modeOptions))},get mode(){return this.modeOptions.mode},set mode(s){const o=this;o.modeOptions.mode=s},get options(){return this.modeOptions.plainFullOption}})},onCreate(r,t){r.modeOptions.setOption(t)}},H={onUse(r,t,e){n.mixin(r,{defaultOptions:new n.TierOptions(t,e)}),n.mixin(r.prototype,{get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new n.TierOptions(void 0,r.defaultOptions))}})},onCreate(r,t){r.defaultOptions.option=t}};function I(r,t){const e=n.mixinTarget(r,{defaultOptions:new n.TierOptions(t)});return n.mixinTarget(e.prototype,{get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new n.TierOptions(void 0,this.constructor.defaultOptions))}}),r}function x(r){const t=n.mixinTarget(r,{isolatedPluginManager:!1,get pluginManager(){return(!this._pluginManager||this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager"))&&(this._pluginManager=new n.PluginExtendManager(this,this._pluginManager)),this._pluginManager},usePlugin(e,...i){return this.pluginManager.usePlugin(e,...i)},useExtend(e){return this.pluginManager.useExtend(e)},hasUsed(e){return this.pluginManager.hasUsed(e)}});return n.mixinTarget(t.prototype,{get pluginManager(){return this.constructor.pluginManager},usePlugin(e,...i){return this.pluginManager.instUsePlugin(this,e,...i)},useExtend(e,...i){return this.pluginManager.instUseExtend(this,e,...i)},async init(...e){return super.init&&await super.init(...e),this.pluginManager.onInit(this,...e)},async destroy(){if(await this.pluginManager.onDestroy(this),super.destroy)return super.destroy()}}),r}function v(r){const t=x(r);return new Proxy(t,{construct:function(e,i,s){const o=new e(...i);return t.pluginManager.onCreate(this,...i),o}})}function j(r){return class extends r{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new n.PluginExtendManager(this,this._pluginManager)),this._pluginManager}static _pluginManager=new n.PluginExtendManager(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(e,...i){return this.pluginManager.usePlugin(e,...i)}static useExtend(e){return this.pluginManager.useExtend(e)}static hasUsed(e){return this.pluginManager.hasUsed(e)}constructor(...e){super(...e),this.pluginManager.onCreate(this,...e)}usePlugin(e,...i){return this.pluginManager.instUsePlugin(this,e,...i)}useExtend(e,...i){return this.pluginManager.instUseExtend(this,e,...i)}init(...e){if(super.init){const i=super.init(...e);if(i instanceof Promise)return i.then(()=>this.pluginManager.onInit(this,...e))}return this.pluginManager.onInit(this,...e)}destroy(){const e=this.pluginManager.onDestroy(this);return super.destroy?e instanceof Promise?e.finally(()=>super.destroy()):super.destroy():e}}}exports.ModeOptions=n.ModeOptions;exports.PluginExtendManager=n.PluginExtendManager;exports.PluginHost=n.PluginHost;exports.TierModeOptions=n.TierModeOptions;exports.TierModeOptionsPluginHost=n.TierModeOptionsPluginHost;exports.TierOptions=n.TierOptions;exports.TierOptionsPluginHost=n.TierOptionsPluginHost;exports.commonModeName=n.commonModeName;exports.createDefineIExtend=n.createDefineIExtend;exports.createDefineMixin=n.createDefineMixin;exports.createIExtendTarget=n.createIExtendTarget;exports.createMixinTarget=n.createMixinTarget;exports.createPluginHost=n.createPluginHost;exports.createTargetIExtend=n.createTargetIExtend;exports.createTargetMixin=n.createTargetMixin;exports.createTierModeOptionsPluginHost=n.createTierModeOptionsPluginHost;exports.createTierOptionsPluginHost=n.createTierOptionsPluginHost;exports.defineIExtend=n.defineIExtend;exports.defineMixin=n.defineMixin;exports.extendMark=n.extendMark;exports.getPropertyValue=n.getPropertyValue;exports.getPropertyValueByPath=n.getPropertyValueByPath;exports.iextendTarget=n.iextendTarget;exports.isPlugin=n.isPlugin;exports.mixin=n.mixin;exports.mixinByOmit=n.mixinByOmit;exports.mixinByPick=n.mixinByPick;exports.mixinIExtend=n.mixinIExtend;exports.mixinTarget=n.mixinTarget;exports.parsePropertyPath=n.parsePropertyPath;exports.pickHostExtendMembers=n.pickHostExtendMembers;exports.setPropertyValue=n.setPropertyValue;exports.setPropertyValueByPath=n.setPropertyValueByPath;exports.targetIExtend=n.targetIExtend;exports.targetMixin=n.targetMixin;exports.tierModeOptionsDecorator=n.tierModeOptionsDecorator;exports.tierOptionsDecorator=n.tierOptionsDecorator;exports.ExtendManager=b;exports.PluginManager=E;exports.addDefaultOptions=U;exports.addInstOptions=C;exports.becomePluginHost=x;exports.becomePluginHost_Extends=j;exports.becomePluginHost_Proxy=v;exports.becomeTierModeOptionsHost=D;exports.becomeTierOptionsHost=I;exports.createDefineExtend=M;exports.createExtendTarget=T;exports.createPropertySetter=w;exports.createTargetExtend=P;exports.defineExtend=m;exports.extendTarget=y;exports.getTargetProperties=f;exports.mergeProperties=d;exports.targetExtend=O;exports.tierModeOptionsPlugin=_;exports.tierOptionsPlugin=H;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@gby/destroyable"),p=require("com-tools"),n=require("./createTierModeOptionsPluginHost-B8wx-Fm2.cjs"),d=require("type-tls");function m(s,e){return e}function x(s){return function(t){return t}}function M(s,e){return n.mixin(s.prototype,e),e}function P(s){return function(t){return n.mixin(s.prototype,t),t}}function y(s,e){return n.mixin(s.prototype,e),s}function T(s){return function(t){return n.mixin(s.prototype,t),s}}class E extends h.Destroyable{parent;host;plugins=new Map;constructor(e,t){super(),this.parent=t,e&&(this.host=e)}destroyThis(){return this.plugins.clear(),this.host=null,super.destroyThis()}hasUsed(e){return this.parent?.hasUsed(e)||this.plugins.has(e)}getUseReturn(e){const{parent:t}=this;return t?.hasUsed(e)?t.getUseReturn(e):this.plugins.get(e)}use(e,...t){if(this.hasUsed(e))return this.getUseReturn(e);const i=e.onUse(this.host,...t);return this.plugins.set(e,i),i}instUse(e,t,...i){const{plugins:r}=this;if(this.hasUsed(t))return this.getUseReturn(t);const o=this.use(t,...i);return t.onCreate?.(e),o}onCreate(e,...t){const i=this.parent?.onCreate(e,...t),r=[];for(const[o]of this.plugins)o.onCreate&&r.push(o.onCreate.bind(o));return d.waitAsyncable(i,()=>p.serialCallFuns(r,void 0,[e,...t]))}onInit(e,...t){const i=this.parent?.onInit(e,...t),r=[];for(const[o]of this.plugins)o.onInit&&r.push(o.onInit.bind(o));return d.waitAsyncable(i,()=>p.serialCallFuns(r,void 0,[e,...t]))}onDestroy(e){const t=[];for(const[o]of this.plugins)o.onDestroy&&t.push(o.onDestroy.bind(o));t.reverse();const i=p.serialCallFuns(t,void 0,[e]),{parent:r}=this;return r?d.waitAsyncable(i,()=>r.onDestroy(e)):i}}class _ extends h.Destroyable{parent;host;plugins=new Set;constructor(e,t){super(),this.parent=t,e&&(this.host=e)}destroyThis(){return this.plugins.clear(),this.host=null,super.destroyThis()}hasUsed(e){return this.parent?.hasUsed(e)||this.plugins.has(e)}use(e){return this.hasUsed(e)||(n.mixinIExtend(this.host.prototype,e),this.plugins.add(e)),e}instUse(e,t,...i){return this.hasUsed(t)||(this.use(t),t.onCreate?.call(e,e,...i)),t}onCreate(e,...t){const i=this.parent?.onCreate(e,...t),r=[];for(const o of this.plugins)o.onCreate&&r.push(o.onCreate);return d.waitAsyncable(i,()=>p.serialCallFuns(r,e,[e,...t]))}onInit(e,...t){const i=this.parent?.onInit(e,...t),r=[];for(const o of this.plugins)o.onInit&&r.push(o.onInit);return d.waitAsyncable(i,()=>p.serialCallFuns(r,e,[e,...t]))}onDestroy(e){const t=[];for(const o of this.plugins)o.onDestroy&&t.push(o.onDestroy);t.reverse();const i=p.serialCallFuns(t,e,[e]),{parent:r}=this;return r?d.waitAsyncable(i,()=>r.onDestroy(e)):i}}function c(s,e){const t=[{target:s,props:e}];let i;for(;i=t.shift();){const{target:r,props:o}=i;for(const[u,a]of Object.entries(o)){if(a!=null&&typeof a=="object"&&(!a.constructor||a.constructor===Object)){t.push({target:r[u],props:a});continue}r[u]=a}}return s}function f(s,e){const t={},i=[{target:s,props:e,targetProps:t}];let r;for(;r=i.shift();){const{target:o,props:u,targetProps:a}=r;for(const[g,l]of Object.entries(u)){if(l!=null&&typeof l=="object"&&(!l.constructor||l.constructor===Object)){i.push({target:o[g],props:l,targetProps:a[g]={}});continue}a[g]=o[g]}}return t}function w(s,e){const t=f(s,e);function i(){c(s,e)}function r(){c(s,t)}return{set:i,unset:r}}function b(s,e){const t=e??"defaultOptions",i=`_${t}`;return function(o){const u=n.mixinTarget(o,{get[t](){return s}});n.mixinTarget(u.prototype,{get[t](){return this[i]||(this[i]=structuredClone(u.defaultOptions))}})}}function U(s,e,t){const i=`_${e}`;return n.mixinTarget(s.prototype,{get[e](){return this[i]||(this[i]=structuredClone(s[e]))}}),t}function C(s,e,t){const i=n.mixinTarget(s,{isolatedOptions:!1,get modeOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_modeOptions")&&(this._modeOptions=new n.TierModeOptions(e,null,this._modeOptions)),this._modeOptions},_modeOptions:new n.TierModeOptions(e,t)});return n.mixinTarget(i.prototype,{get modeOptions(){return this._modeOptions||(this._modeOptions=new n.TierModeOptions(e,void 0,this.constructor.modeOptions))},get mode(){return this.modeOptions.mode},set mode(r){this.modeOptions.mode=r},get options(){return this.modeOptions.fullOption}}),s}const D={onUse(s,e,t){const i=e??n.commonModeName;n.mixin(s,{isolatedOptions:!1,get modeOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_modeOptions")&&(this._modeOptions=new n.TierModeOptions(i,null,this._modeOptions)),this._modeOptions},_modeOptions:new n.TierModeOptions(i,void 0,t)}),n.mixin(s.prototype,{get modeOptions(){const r=this,o=s;return r._modeOptions||(r._modeOptions=new n.TierModeOptions(o.modeOptions.mode,void 0,o.modeOptions))},get mode(){return this.modeOptions.mode},set mode(r){const o=this;o.modeOptions.mode=r},get options(){return this.modeOptions.plainFullOption}})},onCreate(s,e){e&&s.modeOptions.setOption(e)}},H={onUse(s,e,t){n.mixin(s,{isolatedOptions:!1,get defaultOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_defaultOptions")&&(this._defaultOptions=new n.TierOptions(void 0,this._defaultOptions)),this._defaultOptions},_defaultOptions:new n.TierOptions(e,t)}),n.mixin(s.prototype,{get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new n.TierOptions(void 0,s.defaultOptions))}})},onCreate(s,e){e&&(s.defaultOptions.option=e)}};function I(s,e,t){const i=n.mixinTarget(s,{isolatedOptions:!1,get defaultOptions(){return this.isolatedOptions&&!this.hasOwnProperty("_defaultOptions")&&(this._defaultOptions=new n.TierOptions(void 0,this._defaultOptions)),this._defaultOptions},_defaultOptions:new n.TierOptions(e,t)});return n.mixinTarget(i.prototype,{get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new n.TierOptions(void 0,this.constructor.defaultOptions))}}),s}function O(s){const e=n.mixinTarget(s,{isolatedPluginManager:!1,get pluginManager(){return(!this._pluginManager||this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager"))&&(this._pluginManager=new n.PluginExtendManager(this,this._pluginManager)),this._pluginManager},usePlugin(t,...i){return this.pluginManager.usePlugin(t,...i)},useExtend(t){return this.pluginManager.useExtend(t)},hasUsed(t){return this.pluginManager.hasUsed(t)}});return n.mixinTarget(e.prototype,{get pluginManager(){return this.constructor.pluginManager},usePlugin(t,...i){return this.pluginManager.instUsePlugin(this,t,...i)},useExtend(t,...i){return this.pluginManager.instUseExtend(this,t,...i)},async init(...t){return super.init&&await super.init(...t),this.pluginManager.onInit(this,...t)},async destroy(){if(await this.pluginManager.onDestroy(this),super.destroy)return super.destroy()}}),s}function v(s){const e=O(s);return new Proxy(e,{construct:function(t,i,r){const o=new t(...i);return e.pluginManager.onCreate(this,...i),o}})}function j(s){return class extends s{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new n.PluginExtendManager(this,this._pluginManager)),this._pluginManager}static _pluginManager=new n.PluginExtendManager(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(t,...i){return this.pluginManager.usePlugin(t,...i)}static useExtend(t){return this.pluginManager.useExtend(t)}static hasUsed(t){return this.pluginManager.hasUsed(t)}constructor(...t){super(...t),this.pluginManager.onCreate(this,...t)}usePlugin(t,...i){return this.pluginManager.instUsePlugin(this,t,...i)}useExtend(t,...i){return this.pluginManager.instUseExtend(this,t,...i)}init(...t){if(super.init){const i=super.init(...t);if(i instanceof Promise)return i.then(()=>this.pluginManager.onInit(this,...t))}return this.pluginManager.onInit(this,...t)}destroy(){const t=this.pluginManager.onDestroy(this);return super.destroy?t instanceof Promise?t.finally(()=>super.destroy()):super.destroy():t}}}exports.ModeOptions=n.ModeOptions;exports.PluginExtendManager=n.PluginExtendManager;exports.PluginHost=n.PluginHost;exports.TierModeOptions=n.TierModeOptions;exports.TierModeOptionsPluginHost=n.TierModeOptionsPluginHost;exports.TierOptions=n.TierOptions;exports.TierOptionsPluginHost=n.TierOptionsPluginHost;exports.commonModeName=n.commonModeName;exports.createDefineIExtend=n.createDefineIExtend;exports.createDefineMixin=n.createDefineMixin;exports.createIExtendTarget=n.createIExtendTarget;exports.createMixinTarget=n.createMixinTarget;exports.createPluginHost=n.createPluginHost;exports.createTargetIExtend=n.createTargetIExtend;exports.createTargetMixin=n.createTargetMixin;exports.createTierModeOptionsPluginHost=n.createTierModeOptionsPluginHost;exports.createTierOptionsPluginHost=n.createTierOptionsPluginHost;exports.deepmerge=n.deepmerge;exports.deepmergeInto=n.deepmergeInto;exports.defineIExtend=n.defineIExtend;exports.defineMixin=n.defineMixin;exports.extendMark=n.extendMark;exports.getPropertyValue=n.getPropertyValue;exports.getPropertyValueByPath=n.getPropertyValueByPath;exports.iextendTarget=n.iextendTarget;exports.isPlugin=n.isPlugin;exports.mixin=n.mixin;exports.mixinByOmit=n.mixinByOmit;exports.mixinByPick=n.mixinByPick;exports.mixinIExtend=n.mixinIExtend;exports.mixinTarget=n.mixinTarget;exports.parsePropertyPath=n.parsePropertyPath;exports.pickHostExtendMembers=n.pickHostExtendMembers;exports.setPropertyValue=n.setPropertyValue;exports.setPropertyValueByPath=n.setPropertyValueByPath;exports.targetIExtend=n.targetIExtend;exports.targetMixin=n.targetMixin;exports.tierModeOptionsDecorator=n.tierModeOptionsDecorator;exports.tierOptionsDecorator=n.tierOptionsDecorator;exports.ExtendManager=_;exports.PluginManager=E;exports.addDefaultOptions=b;exports.addInstOptions=U;exports.becomePluginHost=O;exports.becomePluginHost_Extends=j;exports.becomePluginHost_Proxy=v;exports.becomeTierModeOptionsHost=C;exports.becomeTierOptionsHost=I;exports.createDefineExtend=x;exports.createExtendTarget=T;exports.createPropertySetter=w;exports.createTargetExtend=P;exports.defineExtend=m;exports.extendTarget=y;exports.getTargetProperties=f;exports.mergeProperties=c;exports.targetExtend=M;exports.tierModeOptionsPlugin=D;exports.tierOptionsPlugin=H;