plugin-tls 4.5.0 → 4.7.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.
@@ -0,0 +1 @@
1
+ "use strict";const x=require("@gby/destroyable"),h=require("deepmerge-ts"),m=require("type-tls"),p=require("com-tools");function u(i,...e){for(const t of e){const n=Object.getOwnPropertyDescriptors(t);Object.defineProperties(i,n)}return i}function E(i,e,t){let n=Object.getOwnPropertyDescriptors(e);return t&&p.omitMembers(n,t),Object.defineProperties(i,n),i}function V(i,e,t){let n=Object.getOwnPropertyDescriptors(e);return t?Object.defineProperties(i,p.removeUndefined(p.pickMembers(n,t))):Object.defineProperties(i,n),i}function N(i,e){return e}function v(i){return function(t){return t}}function H(i,e){return u(i,e),e}function I(i){return function(t){return u(i,t),t}}function k(i,e){return u(i,e),i}function C(i){return function(t){return u(i,t),i}}const T=["onCreate","onInit","onDestroy"];function j(i){const e={...i};for(const t of T)typeof e[t]=="function"&&delete e[t];return e}function U(i,e){let t=Object.getOwnPropertyDescriptors(e);for(const n of T)typeof e[n]=="function"&&delete t[n];return Object.defineProperties(i,t),i}function S(i,e){return e}function B(i){return function(t){return t}}function R(i,e){return u(i.prototype,e),e}function A(i){return function(t){return u(i.prototype,t),t}}function q(i,e){return u(i.prototype,e),i}function z(i){return function(t){return u(i.prototype,t),i}}function F(i){return i&&typeof i.onUse=="function"}const d=Symbol("extend");class g extends x.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)}isPlugin(e){return this.hasUsed(e)?this.getUseReturn(e)!==d:F(e)}useExtend(e){return this.hasUsed(e)||(U(this.host.prototype,e),this.plugins.set(e,d)),e}instUseExtend(e,t,...n){return this.hasUsed(t)||(this.useExtend(t),t.onCreate?.call(e,e,...n)),t}usePlugin(e,...t){if(this.hasUsed(e))return this.getUseReturn(e);const n=e.onUse(this.host,...t);return this.plugins.set(e,n),n}instUsePlugin(e,t,...n){if(this.hasUsed(t))return this.getUseReturn(t);const s=this.usePlugin(t,...n);return t.onCreate?.(e),s}onCreate(e,...t){const n=this.parent?.onCreate(e,...t),s=[];for(const[r,o]of this.plugins)if(r.onCreate){const a=o===d?r.onCreate:r.onCreate.bind(r);s.push(a)}return m.waitAsyncable(n,()=>p.serialCallFuns(s,e,[e,...t]))}onInit(e,...t){const n=this.parent?.onInit(e,...t),s=[];for(const[r,o]of this.plugins)if(r.onInit){const a=o===d?r.onInit:r.onInit.bind(r);s.push(a)}return m.waitAsyncable(n,()=>p.serialCallFuns(s,e,[e,...t]))}onDestroy(e){const t=[];for(const[r,o]of this.plugins)if(r.onDestroy){const a=o===d?r.onDestroy:r.onDestroy.bind(r);t.push(a)}t.reverse();const n=p.serialCallFuns(t,e,[e]),{parent:s}=this;return s?m.waitAsyncable(n,()=>s.onDestroy(e)):n}}function y(i){const e=i.split(".");return e[0]===""&&e.shift(),e}function O(i,e){for(const t of e)if(i=i[t],i==null)return;return i}function K(i,e){return O(i,y(e))}function P(i,e,t){const n=e.pop(),s=e.length;let r=0;for(;r<s;){const o=i[e[r]];if(o==null)break;i=o,r++}e=e.slice(r);for(const o of e)i=i[o]={};return i[n]=t,i}function $(i,e,t){return P(i,y(e),t)}const M={UndefinedAndNull:function(e){return e==null},Undefined:function(e){return e===void 0},Null:function(e){return e===null}};class w{freezeMember=!0;fullOption=new Proxy(this,{get:function(e,t,n){const s=e.plainFullOption[t];return e.freezeMember?Object.freeze(s):s},set:function(e,t,n,s){return e.setMember(t,n,!1),!0},has:function(e,t){return t in e.plainFullOption},getOwnPropertyDescriptor:function(e,t){return Object.getOwnPropertyDescriptor(e.plainFullOption,t)},ownKeys:function(e){return Reflect.ownKeys(e.plainFullOption)},deleteProperty:function(e,t){return e.setMember(t,void 0),!0},defineProperty:function(e,t,n){return Object.defineProperty(e.option,t,n),!0}});setOption(e,t){const n=t?h.deepmergeInto(this.option,e):Object.assign(this.option,e);return this.updateFullOption(),n}get undefinedValue(){return this._undefinedValue}set undefinedValue(e){this._undefinedValue=e,this.isUndefined=M[e]||M.UndefinedAndNull}_undefinedValue="UndefinedAndNull";isUndefined=M.UndefinedAndNull;getMember(e){return this.option[e]}setMember(e,t,n){const s=this.option;if(t===void 0)delete s[e];else{const r=s[e];n&&r&&typeof r=="object"?h.deepmergeInto(r,t):s[e]=t}this.updateFullOption()}getValue(e){return O(this.option,e)}setValue(e,t,n){const s=this.option;let r;n&&(r=O(s,e))&&typeof r=="object"?h.deepmergeInto(r,t):P(this.option,e,t),this.updateFullOption()}}class l extends w{constructor(e,t){super(),e&&(this.option=e),t&&(this.extends=t)}get extends(){return this._extends}set extends(e){this._extends=e,this.updateFullOption()}_extends=null;option={};get plainFullOption(){let e=this._plainFullOption;if(e)return e;const{extends:t,option:n}=this;if(e=n,t){const s=t.plainFullOption;e=h.deepmerge(s,n)}return this._plainFullOption=e}_plainFullOption=null;updateFullOption(){this._plainFullOption=null}getMember(e){const t=this.option[e];if(!this.isUndefined(t))return t;const n=this.extends;if(n)return n.getMember(e)}getValue(e){const t=super.getValue(e);if(!this.isUndefined(t))return t;const n=this.extends;if(n)return n.getValue(e)}}function L(i,e){const{name:t}=e,n=`_${t}`;return{get:function(){return this[n]||(this[n]=new l(void 0,this.constructor[t]))}}}class D extends w{constructor(e,t){super(),t&&this.setModeOption(e,t),this.mode=e}modes={};get mode(){return this._mode||(this.mode=this.modeNames[0])}set mode(e){this._mode=e,this.hasMode(e)||this.setModeOption(e,{}),this.updateFullOption()}_mode;get modeNames(){return this._modeNames||(this._modeNames=this.getModeNames())}_modeNames=null;getModeNames(){return Object.keys(this.modes)}hasMode(e){return!!this.modes[e]}get optionManager(){return this.modes[this.mode]}get option(){return this.optionManager.option}get plainFullOption(){return this._plainFullOption??(this._plainFullOption=this.getFullModeOption(this.mode))}_plainFullOption=null;updateFullOption(){this._plainFullOption=null,this._modeNames=null}getModeOption(e){return this.modes[e].option}getFullModeOption(e){return this.modes[e]?.plainFullOption}setModeOption(e,t,n,s){const{modes:r}=this,o=r[e]||(r[e]=new l);if(o.setOption(t,n),s){const a=r[s];a&&(o.extends=a)}return this.updateFullOption(),o}}class c extends D{constructor(e,t,n){super(e,t),n&&(this.extends=n)}get extends(){return this._extends}set extends(e){this._extends=e,this.updateFullOption()}_extends=null;getFullModeOption(e){const{modes:t,extends:n}=this,s=t[e]?.plainFullOption;if(n){const r=n.getFullModeOption(e);return s?h.deepmerge(r,s):r}return s}getModeNames(){const{modes:e,extends:t}=this,n=Object.keys(e);if(!t)return n;const s=t.getModeNames();return[...new Set([...n,...s])]}hasModeOnTier(e){if(this.hasMode(e))return!0;const t=this.extends;return t?t.hasModeOnTier(e):!1}get optionManager(){return this.getModeOptionManager(this.mode)}getModeOptionManager(e){const t=this.modes[e];return t||(this.extends?.getModeOptionManager(e)?this.setModeOption(e,{}):null)}getMember(e){const t=this.optionManager.getMember(e);if(!this.isUndefined(t))return t;const n=this.extends;if(n)return n.getMember(e)}getValue(e){const t=this.optionManager.getValue(e);if(!this.isUndefined(t))return t;const n=this.extends;if(n)return n.getValue(e)}}function G(i,e){const{name:t}=e,n=`_${t}`;return{get:function(){return this[n]||(this[n]=new c(this.constructor[t].mode,void 0,this.constructor[t]))}}}class _ extends x.Destroyable{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new g(this,this._pluginManager)),this._pluginManager}static _pluginManager=new g(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(e,...t){return this.pluginManager.usePlugin(e,...t)}static useExtend(e){return this.pluginManager.useExtend(e)}static hasUsed(e){return this.pluginManager.hasUsed(e)}usePlugin(e,...t){return this.pluginManager.instUsePlugin(this,e,...t)}useExtend(e,...t){return this.pluginManager.instUseExtend(this,e,...t)}init(...e){return this.pluginManager.onInit(this,...e)}destroyThis(){const e=this.pluginManager.onDestroy(this);return e instanceof Promise?e.finally(()=>super.destroyThis()):super.destroyThis()}}class J extends _{static defaultOptions=new l;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new l(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(e){super(),this.defaultOptions.option=e}}function b(i){const e=x.createDestroyableSubClass(i);return class extends e{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new g(this,this._pluginManager)),this._pluginManager}static _pluginManager=new g(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(n,...s){return this.pluginManager.usePlugin(n,...s)}static useExtend(n){return this.pluginManager.useExtend(n)}static hasUsed(n){return this.pluginManager.hasUsed(n)}usePlugin(n,...s){return this.pluginManager.instUsePlugin(this,n,...s)}useExtend(n,...s){return this.pluginManager.instUseExtend(this,n,...s)}init(...n){return this.pluginManager.onInit(this,...n)}destroyThis(){const n=this.pluginManager.onDestroy(this);return n instanceof Promise?n.finally(()=>super.destroyThis()):super.destroyThis()}}}function Q(i){const e=b(i);return class extends e{static defaultOptions=new l;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new l(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(n){super(),this.defaultOptions.option=n}}}const f="common";class W extends _{static modeOptions=new c(f);get modeOptions(){return this._modeOptions||(this._modeOptions=new c(f,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(e){this.modeOptions.mode=e}get options(){return this.modeOptions.plainFullOption}constructor(e){super(),this.modeOptions.setOption(e)}}function X(i){const e=b(i);return class extends e{static modeOptions=new c(f);get modeOptions(){return this._modeOptions||(this._modeOptions=new c(f,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(n){this.modeOptions.mode=n}get options(){return this.modeOptions.plainFullOption}constructor(n){super(),this.modeOptions.setOption(n)}}}exports.ModeOptions=D;exports.PluginExtendManager=g;exports.PluginHost=_;exports.TierModeOptions=c;exports.TierModeOptionsPluginHost=W;exports.TierOptions=l;exports.TierOptionsPluginHost=J;exports.commonModeName=f;exports.createDefineIExtend=B;exports.createDefineMixin=v;exports.createIExtendTarget=z;exports.createMixinTarget=C;exports.createPluginHost=b;exports.createTargetIExtend=A;exports.createTargetMixin=I;exports.createTierModeOptionsPluginHost=X;exports.createTierOptionsPluginHost=Q;exports.defineIExtend=S;exports.defineMixin=N;exports.extendMark=d;exports.getPropertyValue=O;exports.getPropertyValueByPath=K;exports.iextendTarget=q;exports.isPlugin=F;exports.mixin=u;exports.mixinByOmit=E;exports.mixinByPick=V;exports.mixinIExtend=U;exports.mixinTarget=k;exports.parsePropertyPath=y;exports.pickHostExtendMembers=j;exports.setPropertyValue=P;exports.setPropertyValueByPath=$;exports.targetIExtend=R;exports.targetMixin=H;exports.tierModeOptionsDecorator=G;exports.tierOptionsDecorator=L;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./Destroyable-BqvuD4gL-Cmk1ocqj.cjs"),a=require("node:events"),d=require("com-tools"),s=require("./createTierModeOptionsPluginHost-C3kmxB00.cjs");class l extends a.EventEmitter{refCount=0;get isDestroyed(){return this._isDestroyed}_isDestroyed=!1;get canDestroy(){return!this.isDestroyed&&this.refCount<=0}_destroyers=[];disposeFun(t){return this._destroyers.push(t),t}cancelDisposeFun(t){const e=this._destroyers.indexOf(t);return this._destroyers.splice(e,1),t}disposeObj(t,e){const i=e?function(){return t.destroySync()}:function(){return t.destroy()};return this.disposeFun(i),t.__destroyable_destroyer=i,t}cancelDisposeObj(t){const e=t.__destroyable_destroyer;return e&&this.cancelDisposeFun(e),t}dispose(t,e){return typeof t=="function"?this.disposeFun(t):this.disposeObj(t,e)}cancelDispose(t){return typeof t=="function"?this.cancelDisposeFun(t):this.cancelDisposeObj(t)}destroyThis(){}destroySync(){if(!this.canDestroy)return this.isDestroyed;let t=this._destroyers.length;for(;--t>=0;){const e=this._destroyers[t];try{e()}catch(i){console.error("销毁函数在同步销毁时出错",this,e,i)}}this._destroyers.length=0;try{this.destroyThis()}catch(e){console.error("destroyThis 在异步销毁时出错",this,e)}return r.i(this),!0}destroy(){if(!this.canDestroy)return this.isDestroyed;const t=this._destroyers.toReversed();t.push(this.destroyThis),this._destroyers.length=0;const e=d.serialCallAllFuns(t,this,null,(i,u)=>{console.error("销毁函数在串行销毁时出错",this,u,i)});return e instanceof Promise?e.then(()=>(r.i(this),!0)):(r.i(this),!0)}}class o extends l{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new s.PluginExtendManager(this)),this._pluginManager}static _pluginManager=new s.PluginExtendManager(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(t,...e){return this.pluginManager.usePlugin(t,...e)}static useExtend(t){return this.pluginManager.useExtend(t)}static hasUsed(t){return this.pluginManager.hasUsed(t)}usePlugin(t,...e){return this.pluginManager.instUsePlugin(this,t,...e)}useExtend(t,...e){return this.pluginManager.instUseExtend(this,t,...e)}init(...t){return this.pluginManager.onInit(this,...t)}destroyThis(){const t=this.pluginManager.onDestroy(this);return t instanceof Promise?t.finally(()=>super.destroyThis()):super.destroyThis()}}class h extends o{static modeOptions=new s.TierModeOptions(s.commonModeName);get modeOptions(){return this._modeOptions||(this._modeOptions=new s.TierModeOptions(s.commonModeName,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(t){this.modeOptions.mode=t}get options(){return this.modeOptions.plainFullOption}constructor(t){super(),this.modeOptions.setOption(t)}}class c extends o{static defaultOptions=new s.TierOptions;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new s.TierOptions(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(t){super(),this.defaultOptions.option=t}}exports.TierModeOptionsPluginHost=s.TierModeOptionsPluginHost;exports.TierOptionsPluginHost=s.TierOptionsPluginHost;exports.commonModeName=s.commonModeName;exports.createTierModeOptionsPluginHost=s.createTierModeOptionsPluginHost;exports.createTierOptionsPluginHost=s.createTierOptionsPluginHost;exports.PluginHostEventEmitter=o;exports.TierModeOptionsPluginHostEventEmitter=h;exports.TierOptionsPluginHostEventEmitter=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./Destroyable-BqvuD4gL-Cmk1ocqj.cjs"),a=require("node:events"),d=require("com-tools"),s=require("./createTierModeOptionsPluginHost-DyDtXKNW.cjs");class l extends a.EventEmitter{refCount=0;get isDestroyed(){return this._isDestroyed}_isDestroyed=!1;get canDestroy(){return!this.isDestroyed&&this.refCount<=0}_destroyers=[];disposeFun(t){return this._destroyers.push(t),t}cancelDisposeFun(t){const e=this._destroyers.indexOf(t);return this._destroyers.splice(e,1),t}disposeObj(t,e){const i=e?function(){return t.destroySync()}:function(){return t.destroy()};return this.disposeFun(i),t.__destroyable_destroyer=i,t}cancelDisposeObj(t){const e=t.__destroyable_destroyer;return e&&this.cancelDisposeFun(e),t}dispose(t,e){return typeof t=="function"?this.disposeFun(t):this.disposeObj(t,e)}cancelDispose(t){return typeof t=="function"?this.cancelDisposeFun(t):this.cancelDisposeObj(t)}destroyThis(){}destroySync(){if(!this.canDestroy)return this.isDestroyed;let t=this._destroyers.length;for(;--t>=0;){const e=this._destroyers[t];try{e()}catch(i){console.error("销毁函数在同步销毁时出错",this,e,i)}}this._destroyers.length=0;try{this.destroyThis()}catch(e){console.error("destroyThis 在异步销毁时出错",this,e)}return r.i(this),!0}destroy(){if(!this.canDestroy)return this.isDestroyed;const t=this._destroyers.toReversed();t.push(this.destroyThis),this._destroyers.length=0;const e=d.serialCallAllFuns(t,this,null,(i,u)=>{console.error("销毁函数在串行销毁时出错",this,u,i)});return e instanceof Promise?e.then(()=>(r.i(this),!0)):(r.i(this),!0)}}class o extends l{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new s.PluginExtendManager(this,this._pluginManager)),this._pluginManager}static _pluginManager=new s.PluginExtendManager(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(t,...e){return this.pluginManager.usePlugin(t,...e)}static useExtend(t){return this.pluginManager.useExtend(t)}static hasUsed(t){return this.pluginManager.hasUsed(t)}usePlugin(t,...e){return this.pluginManager.instUsePlugin(this,t,...e)}useExtend(t,...e){return this.pluginManager.instUseExtend(this,t,...e)}init(...t){return this.pluginManager.onInit(this,...t)}destroyThis(){const t=this.pluginManager.onDestroy(this);return t instanceof Promise?t.finally(()=>super.destroyThis()):super.destroyThis()}}class h extends o{static modeOptions=new s.TierModeOptions(s.commonModeName);get modeOptions(){return this._modeOptions||(this._modeOptions=new s.TierModeOptions(s.commonModeName,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(t){this.modeOptions.mode=t}get options(){return this.modeOptions.plainFullOption}constructor(t){super(),this.modeOptions.setOption(t)}}class p extends o{static defaultOptions=new s.TierOptions;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new s.TierOptions(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(t){super(),this.defaultOptions.option=t}}exports.TierModeOptionsPluginHost=s.TierModeOptionsPluginHost;exports.TierOptionsPluginHost=s.TierOptionsPluginHost;exports.commonModeName=s.commonModeName;exports.createTierModeOptionsPluginHost=s.createTierModeOptionsPluginHost;exports.createTierOptionsPluginHost=s.createTierOptionsPluginHost;exports.PluginHostEventEmitter=o;exports.TierModeOptionsPluginHostEventEmitter=h;exports.TierOptionsPluginHostEventEmitter=p;
@@ -1,9 +1,9 @@
1
1
  import { i as n } from "./Destroyable-BqvuD4gL-D50ZO9eN.js";
2
- import { EventEmitter as l } from "node:events";
3
- import { serialCallAllFuns as p } from "com-tools";
4
- import { P as r, T as o, c as u, a } from "./createTierModeOptionsPluginHost-CeND_z6P.js";
5
- import { d as D, e as T, g as E, h as x } from "./createTierModeOptionsPluginHost-CeND_z6P.js";
6
- class c extends l {
2
+ import { EventEmitter as p } from "node:events";
3
+ import { serialCallAllFuns as l } from "com-tools";
4
+ import { P as r, T as o, c as u, d as a } from "./createTierModeOptionsPluginHost-D-fKYlcA.js";
5
+ import { f as D, g as T, p as E, q as x } from "./createTierModeOptionsPluginHost-D-fKYlcA.js";
6
+ class c extends p {
7
7
  /**
8
8
  * 引用计数
9
9
  * @remarks
@@ -114,7 +114,7 @@ class c extends l {
114
114
  if (!this.canDestroy) return this.isDestroyed;
115
115
  const t = this._destroyers.toReversed();
116
116
  t.push(this.destroyThis), this._destroyers.length = 0;
117
- const s = p(t, this, null, (e, h) => {
117
+ const s = l(t, this, null, (e, h) => {
118
118
  console.error("销毁函数在串行销毁时出错", this, h, e);
119
119
  });
120
120
  return s instanceof Promise ? s.then(() => (n(this), !0)) : (n(this), !0);
@@ -130,7 +130,7 @@ class d extends c {
130
130
  * 插件管理器
131
131
  */
132
132
  static get pluginManager() {
133
- return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new r(this)), this._pluginManager;
133
+ return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new r(this, this._pluginManager)), this._pluginManager;
134
134
  }
135
135
  static _pluginManager = new r(this);
136
136
  /**
@@ -203,7 +203,7 @@ class d extends c {
203
203
  return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
204
204
  }
205
205
  }
206
- class f extends d {
206
+ class m extends d {
207
207
  /**
208
208
  * 全局级别的默认选项
209
209
  */
@@ -247,7 +247,7 @@ class _ extends d {
247
247
  export {
248
248
  d as PluginHostEventEmitter,
249
249
  D as TierModeOptionsPluginHost,
250
- f as TierModeOptionsPluginHostEventEmitter,
250
+ m as TierModeOptionsPluginHostEventEmitter,
251
251
  T as TierOptionsPluginHost,
252
252
  _ as TierOptionsPluginHostEventEmitter,
253
253
  u as commonModeName,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./Destroyable-BqvuD4gL-Cmk1ocqj.cjs"),c=require("com-tools"),n=require("./createTierModeOptionsPluginHost-C3kmxB00.cjs");if(!globalThis.CustomEvent){class i extends Event{detail;constructor(e,s){super(e,s),this.detail=s?.detail}}globalThis.CustomEvent=i}class h extends EventTarget{addEventListener(t,e,s){const r=s?.times;if(r){const o=typeof e=="function"?e:e?.handleEvent;if(o)return this.multipleListen(t,o,r)}return super.addEventListener(t,e,s),()=>{this.removeEventListener(t,e,s)}}dispatchEvent(t,e){const s=t instanceof Event?t:new CustomEvent(t,{detail:e,bubbles:!1,cancelable:!0,composed:!1});return super.dispatchEvent(s)}onceListen(t,e,s){return this.addEventListener(t,e,{...s,once:!0})}multipleListen(t,e,s){let r=0;const o=new AbortController,l=o.signal;return super.addEventListener(t,d=>{++r>=s&&o.abort(),e.call(this,d)},{signal:l}),function(){o.abort()}}}class p extends h{refCount=0;get isDestroyed(){return this._isDestroyed}_isDestroyed=!1;get canDestroy(){return!this.isDestroyed&&this.refCount<=0}_destroyers=[];disposeFun(t){return this._destroyers.push(t),t}cancelDisposeFun(t){const e=this._destroyers.indexOf(t);return this._destroyers.splice(e,1),t}disposeObj(t,e){const s=e?function(){return t.destroySync()}:function(){return t.destroy()};return this.disposeFun(s),t.__destroyable_destroyer=s,t}cancelDisposeObj(t){const e=t.__destroyable_destroyer;return e&&this.cancelDisposeFun(e),t}dispose(t,e){return typeof t=="function"?this.disposeFun(t):this.disposeObj(t,e)}cancelDispose(t){return typeof t=="function"?this.cancelDisposeFun(t):this.cancelDisposeObj(t)}destroyThis(){}destroySync(){if(!this.canDestroy)return this.isDestroyed;let t=this._destroyers.length;for(;--t>=0;){const e=this._destroyers[t];try{e()}catch(s){console.error("销毁函数在同步销毁时出错",this,e,s)}}this._destroyers.length=0;try{this.destroyThis()}catch(e){console.error("destroyThis 在异步销毁时出错",this,e)}return u.i(this),!0}destroy(){if(!this.canDestroy)return this.isDestroyed;const t=this._destroyers.toReversed();t.push(this.destroyThis),this._destroyers.length=0;const e=c.serialCallAllFuns(t,this,null,(s,r)=>{console.error("销毁函数在串行销毁时出错",this,r,s)});return e instanceof Promise?e.then(()=>(u.i(this),!0)):(u.i(this),!0)}}class a extends p{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new n.PluginExtendManager(this)),this._pluginManager}static _pluginManager=new n.PluginExtendManager(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(t,...e){return this.pluginManager.usePlugin(t,...e)}static useExtend(t){return this.pluginManager.useExtend(t)}static hasUsed(t){return this.pluginManager.hasUsed(t)}usePlugin(t,...e){return this.pluginManager.instUsePlugin(this,t,...e)}useExtend(t,...e){return this.pluginManager.instUseExtend(this,t,...e)}init(...t){return this.pluginManager.onInit(this,...t)}destroyThis(){const t=this.pluginManager.onDestroy(this);return t instanceof Promise?t.finally(()=>super.destroyThis()):super.destroyThis()}}class g extends a{static modeOptions=new n.TierModeOptions(n.commonModeName);get modeOptions(){return this._modeOptions||(this._modeOptions=new n.TierModeOptions(n.commonModeName,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(t){this.modeOptions.mode=t}get options(){return this.modeOptions.plainFullOption}constructor(t){super(),this.modeOptions.setOption(t)}}class y extends a{static defaultOptions=new n.TierOptions;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new n.TierOptions(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(t){super(),this.defaultOptions.option=t}}exports.TierModeOptionsPluginHost=n.TierModeOptionsPluginHost;exports.TierOptionsPluginHost=n.TierOptionsPluginHost;exports.commonModeName=n.commonModeName;exports.createTierModeOptionsPluginHost=n.createTierModeOptionsPluginHost;exports.createTierOptionsPluginHost=n.createTierOptionsPluginHost;exports.PluginHostEventTarget=a;exports.TierModeOptionsPluginHostEventTarget=g;exports.TierOptionsPluginHostEventTarget=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./Destroyable-BqvuD4gL-Cmk1ocqj.cjs"),c=require("com-tools"),n=require("./createTierModeOptionsPluginHost-DyDtXKNW.cjs");if(!globalThis.CustomEvent){class i extends Event{detail;constructor(e,s){super(e,s),this.detail=s?.detail}}globalThis.CustomEvent=i}class h extends EventTarget{addEventListener(t,e,s){const r=s?.times;if(r){const o=typeof e=="function"?e:e?.handleEvent;if(o)return this.multipleListen(t,o,r)}return super.addEventListener(t,e,s),()=>{this.removeEventListener(t,e,s)}}dispatchEvent(t,e){const s=t instanceof Event?t:new CustomEvent(t,{detail:e,bubbles:!1,cancelable:!0,composed:!1});return super.dispatchEvent(s)}onceListen(t,e,s){return this.addEventListener(t,e,{...s,once:!0})}multipleListen(t,e,s){let r=0;const o=new AbortController,l=o.signal;return super.addEventListener(t,d=>{++r>=s&&o.abort(),e.call(this,d)},{signal:l}),function(){o.abort()}}}class p extends h{refCount=0;get isDestroyed(){return this._isDestroyed}_isDestroyed=!1;get canDestroy(){return!this.isDestroyed&&this.refCount<=0}_destroyers=[];disposeFun(t){return this._destroyers.push(t),t}cancelDisposeFun(t){const e=this._destroyers.indexOf(t);return this._destroyers.splice(e,1),t}disposeObj(t,e){const s=e?function(){return t.destroySync()}:function(){return t.destroy()};return this.disposeFun(s),t.__destroyable_destroyer=s,t}cancelDisposeObj(t){const e=t.__destroyable_destroyer;return e&&this.cancelDisposeFun(e),t}dispose(t,e){return typeof t=="function"?this.disposeFun(t):this.disposeObj(t,e)}cancelDispose(t){return typeof t=="function"?this.cancelDisposeFun(t):this.cancelDisposeObj(t)}destroyThis(){}destroySync(){if(!this.canDestroy)return this.isDestroyed;let t=this._destroyers.length;for(;--t>=0;){const e=this._destroyers[t];try{e()}catch(s){console.error("销毁函数在同步销毁时出错",this,e,s)}}this._destroyers.length=0;try{this.destroyThis()}catch(e){console.error("destroyThis 在异步销毁时出错",this,e)}return u.i(this),!0}destroy(){if(!this.canDestroy)return this.isDestroyed;const t=this._destroyers.toReversed();t.push(this.destroyThis),this._destroyers.length=0;const e=c.serialCallAllFuns(t,this,null,(s,r)=>{console.error("销毁函数在串行销毁时出错",this,r,s)});return e instanceof Promise?e.then(()=>(u.i(this),!0)):(u.i(this),!0)}}class a extends p{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,...e){return this.pluginManager.usePlugin(t,...e)}static useExtend(t){return this.pluginManager.useExtend(t)}static hasUsed(t){return this.pluginManager.hasUsed(t)}usePlugin(t,...e){return this.pluginManager.instUsePlugin(this,t,...e)}useExtend(t,...e){return this.pluginManager.instUseExtend(this,t,...e)}init(...t){return this.pluginManager.onInit(this,...t)}destroyThis(){const t=this.pluginManager.onDestroy(this);return t instanceof Promise?t.finally(()=>super.destroyThis()):super.destroyThis()}}class g extends a{static modeOptions=new n.TierModeOptions(n.commonModeName);get modeOptions(){return this._modeOptions||(this._modeOptions=new n.TierModeOptions(n.commonModeName,void 0,this.constructor.modeOptions))}_modeOptions;get mode(){return this.modeOptions.mode}set mode(t){this.modeOptions.mode=t}get options(){return this.modeOptions.plainFullOption}constructor(t){super(),this.modeOptions.setOption(t)}}class y extends a{static defaultOptions=new n.TierOptions;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new n.TierOptions(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(t){super(),this.defaultOptions.option=t}}exports.TierModeOptionsPluginHost=n.TierModeOptionsPluginHost;exports.TierOptionsPluginHost=n.TierOptionsPluginHost;exports.commonModeName=n.commonModeName;exports.createTierModeOptionsPluginHost=n.createTierModeOptionsPluginHost;exports.createTierOptionsPluginHost=n.createTierOptionsPluginHost;exports.PluginHostEventTarget=a;exports.TierModeOptionsPluginHostEventTarget=g;exports.TierOptionsPluginHostEventTarget=y;
package/dist/index-web.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { i as o } from "./Destroyable-BqvuD4gL-D50ZO9eN.js";
2
2
  import { serialCallAllFuns as g } from "com-tools";
3
- import { P as a, T as u, c as l, a as d } from "./createTierModeOptionsPluginHost-CeND_z6P.js";
4
- import { d as P, e as D, g as b, h as x } from "./createTierModeOptionsPluginHost-CeND_z6P.js";
3
+ import { P as a, T as u, c as l, d } from "./createTierModeOptionsPluginHost-D-fKYlcA.js";
4
+ import { f as P, g as D, p as b, q as x } from "./createTierModeOptionsPluginHost-D-fKYlcA.js";
5
5
  if (!globalThis.CustomEvent) {
6
6
  class n extends Event {
7
7
  detail;
@@ -200,7 +200,7 @@ class h extends f {
200
200
  * 插件管理器
201
201
  */
202
202
  static get pluginManager() {
203
- return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new a(this)), this._pluginManager;
203
+ return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new a(this, this._pluginManager)), this._pluginManager;
204
204
  }
205
205
  static _pluginManager = new a(this);
206
206
  /**
@@ -273,7 +273,7 @@ class h extends f {
273
273
  return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
274
274
  }
275
275
  }
276
- class E extends h {
276
+ class M extends h {
277
277
  /**
278
278
  * 全局级别的默认选项
279
279
  */
@@ -298,7 +298,7 @@ class E extends h {
298
298
  super(), this.modeOptions.setOption(t);
299
299
  }
300
300
  }
301
- class M extends h {
301
+ class E extends h {
302
302
  /**
303
303
  * 全局级别的默认选项
304
304
  */
@@ -317,9 +317,9 @@ class M extends h {
317
317
  export {
318
318
  h as PluginHostEventTarget,
319
319
  P as TierModeOptionsPluginHost,
320
- E as TierModeOptionsPluginHostEventTarget,
320
+ M as TierModeOptionsPluginHostEventTarget,
321
321
  D as TierOptionsPluginHost,
322
- M as TierOptionsPluginHostEventTarget,
322
+ E as TierOptionsPluginHostEventTarget,
323
323
  l as commonModeName,
324
324
  b as createTierModeOptionsPluginHost,
325
325
  x as createTierOptionsPluginHost
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@gby/destroyable"),c=require("com-tools"),s=require("./createTierModeOptionsPluginHost-C3kmxB00.cjs");function u(n,...t){for(const e of t){const i=Object.getOwnPropertyDescriptors(e);Object.defineProperties(n,i)}return n}function P(n,t,e){let i=Object.getOwnPropertyDescriptors(t);return e&&c.omitMembers(i,e),Object.defineProperties(n,i),n}function m(n,t,e){let i=Object.getOwnPropertyDescriptors(t);return e?Object.defineProperties(n,c.removeUndefined(c.pickMembers(i,e))):Object.defineProperties(n,i),n}function x(n,t){return t}function y(n){return function(e){return e}}function T(n,t){return u(n,t),t}function b(n){return function(e){return u(n,e),e}}function a(n,t){return u(n,t),n}function E(n){return function(e){return u(n,e),n}}function w(n,t){return t}function D(n){return function(e){return e}}function H(n,t){return u(n.prototype,t),t}function C(n){return function(e){return u(n.prototype,e),e}}function _(n,t){return u(n.prototype,t),n}function U(n){return function(e){return u(n.prototype,e),n}}class j extends h.Destroyable{host;plugins=new Map;constructor(t){super(),t&&(this.host=t)}destroyThis(){return this.plugins.clear(),this.host=null,super.destroyThis()}hasUsed(t){return this.plugins.has(t)}use(t,...e){const{plugins:i}=this;if(i.has(t))return i.get(t);const r=t.onUse(this.host,...e);return i.set(t,r),r}instUse(t,e,...i){const{plugins:r}=this;if(r.has(e))return r.get(e);const o=this.use(e,...i);return e.onCreate?.(t),o}onCreate(t,...e){const i=[];for(const[r]of this.plugins)r.onCreate&&i.push(r.onCreate.bind(r));return c.serialCallFuns(i,void 0,[t,...e])}onInit(t,...e){const i=[];for(const[r]of this.plugins)r.onInit&&i.push(r.onInit.bind(r));return c.serialCallFuns(i,void 0,[t,...e])}onDestroy(t){const e=[];for(const[i]of this.plugins)i.onDestroy&&e.push(i.onDestroy.bind(i));return e.reverse(),c.serialCallFuns(e,void 0,[t])}}class v extends h.Destroyable{host;plugins=new Set;constructor(t){super(),t&&(this.host=t)}destroyThis(){return this.plugins.clear(),this.host=null,super.destroyThis()}hasUsed(t){return this.plugins.has(t)}use(t){const{plugins:e}=this;return e.has(t)||(s.mixinIExtend(this.host.prototype,t),e.add(t)),t}instUse(t,e,...i){const{plugins:r}=this;return r.has(e)||(this.use(e),e.onCreate?.call(t,t,...i)),e}onCreate(t,...e){const i=[];for(const r of this.plugins)r.onCreate&&i.push(r.onCreate);return c.serialCallFuns(i,t,[t,...e])}onInit(t,...e){const i=[];for(const r of this.plugins)r.onInit&&i.push(r.onInit);return c.serialCallFuns(i,t,[t,...e])}onDestroy(t){const e=[];for(const i of this.plugins)i.onDestroy&&e.push(i.onDestroy);return e.reverse(),c.serialCallFuns(e,t,[t])}}function f(n,t){const e=[{target:n,props:t}];let i;for(;i=e.shift();){const{target:r,props:o}=i;for(const[g,p]of Object.entries(o)){if(p!=null&&typeof p=="object"&&(!p.constructor||p.constructor===Object)){e.push({target:r[g],props:p});continue}r[g]=p}}return n}function O(n,t){const e={},i=[{target:n,props:t,targetProps:e}];let r;for(;r=i.shift();){const{target:o,props:g,targetProps:p}=r;for(const[d,l]of Object.entries(g)){if(l!=null&&typeof l=="object"&&(!l.constructor||l.constructor===Object)){i.push({target:o[d],props:l,targetProps:p[d]={}});continue}p[d]=o[d]}}return e}function I(n,t){const e=O(n,t);function i(){f(n,t)}function r(){f(n,e)}return{set:i,unset:r}}function k(n,t){const e=t??"defaultOptions",i=`_${e}`;return function(o){const g=a(o,{get[e](){return n}});a(g.prototype,{get[e](){return this[i]||(this[i]=structuredClone(g.defaultOptions))}})}}function B(n,t,e){const i=`_${t}`;return a(n.prototype,{get[t](){return this[i]||(this[i]=structuredClone(n[t]))}}),e}function V(n,t,e){const i=a(n,{modeOptions:new s.TierModeOptions(t,e)});return a(i.prototype,{get modeOptions(){return this._modeOptions||(this._modeOptions=new s.TierModeOptions(t,void 0,this.constructor.modeOptions))},get mode(){return this.modeOptions.mode},set mode(r){this.modeOptions.mode=r},get options(){return this.modeOptions.fullOption}}),n}const F={onUse(n,t,e){const i=t??s.commonModeName;u(n,{modeOptions:new s.TierModeOptions(i,void 0,e)}),u(n.prototype,{get modeOptions(){const r=this,o=n;return r._modeOptions||(r._modeOptions=new s.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(n,t){n.modeOptions.setOption(t)}},N={onUse(n,t,e){u(n,{defaultOptions:new s.TierOptions(t,e)}),u(n.prototype,{get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new s.TierOptions(void 0,n.defaultOptions))}})},onCreate(n,t){n.defaultOptions.option=t}};function q(n,t){const e=a(n,{defaultOptions:new s.TierOptions(t)});return a(e.prototype,{get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new s.TierOptions(void 0,this.constructor.defaultOptions))}}),n}function M(n){const t=a(n,{isolatedPluginManager:!1,get pluginManager(){return(!this._pluginManager||this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager"))&&(this._pluginManager=new s.PluginExtendManager(this)),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 a(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()}}),n}function S(n){const t=M(n);return new Proxy(t,{construct:function(e,i,r){const o=new e(...i);return t.pluginManager.onCreate(this,...i),o}})}function $(n){return class extends n{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new s.PluginExtendManager(this)),this._pluginManager}static _pluginManager=new s.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=s.ModeOptions;exports.PluginExtendManager=s.PluginExtendManager;exports.PluginHost=s.PluginHost;exports.TierModeOptions=s.TierModeOptions;exports.TierModeOptionsPluginHost=s.TierModeOptionsPluginHost;exports.TierOptions=s.TierOptions;exports.TierOptionsPluginHost=s.TierOptionsPluginHost;exports.commonModeName=s.commonModeName;exports.createPluginHost=s.createPluginHost;exports.createTierModeOptionsPluginHost=s.createTierModeOptionsPluginHost;exports.createTierOptionsPluginHost=s.createTierOptionsPluginHost;exports.extendMark=s.extendMark;exports.getPropertyValue=s.getPropertyValue;exports.getPropertyValueByPath=s.getPropertyValueByPath;exports.isPlugin=s.isPlugin;exports.mixinIExtend=s.mixinIExtend;exports.parsePropertyPath=s.parsePropertyPath;exports.pickHostExtendMembers=s.pickHostExtendMembers;exports.setPropertyValue=s.setPropertyValue;exports.setPropertyValueByPath=s.setPropertyValueByPath;exports.tierModeOptionsDecorator=s.tierModeOptionsDecorator;exports.tierOptionsDecorator=s.tierOptionsDecorator;exports.ExtendManager=v;exports.PluginManager=j;exports.addDefaultOptions=k;exports.addInstOptions=B;exports.becomePluginHost=M;exports.becomePluginHost_Extends=$;exports.becomePluginHost_Proxy=S;exports.becomeTierModeOptionsHost=V;exports.becomeTierOptionsHost=q;exports.createDefineExtend=D;exports.createDefineMixin=y;exports.createExtendTarget=U;exports.createMixinTarget=E;exports.createPropertySetter=I;exports.createTargetExtend=C;exports.createTargetMixin=b;exports.defineExtend=w;exports.defineMixin=x;exports.extendTarget=_;exports.getTargetProperties=O;exports.mergeProperties=f;exports.mixin=u;exports.mixinByOmit=P;exports.mixinByPick=m;exports.mixinTarget=a;exports.targetExtend=H;exports.targetMixin=T;exports.tierModeOptionsPlugin=F;exports.tierOptionsPlugin=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@gby/destroyable"),p=require("com-tools"),n=require("./createTierModeOptionsPluginHost-DyDtXKNW.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;