plugin-tls 3.6.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Destroyable-BqvuD4gL-Cmk1ocqj.cjs +1 -0
- package/dist/Destroyable-BqvuD4gL-D50ZO9eN.js +129 -0
- package/dist/createTierModeOptionsPluginHost-C3kmxB00.cjs +1 -0
- package/dist/createTierModeOptionsPluginHost-CeND_z6P.js +852 -0
- package/dist/index-node.cjs +1 -1
- package/dist/index-node.d.ts +0 -1
- package/dist/index-node.d.ts.map +1 -1
- package/dist/index-node.js +254 -56
- package/dist/index-web.cjs +1 -1
- package/dist/index-web.d.ts +0 -1
- package/dist/index-web.d.ts.map +1 -1
- package/dist/index-web.js +324 -56
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +628 -60
- package/dist/options/index-node.d.ts +0 -1
- package/dist/options/index-node.d.ts.map +1 -1
- package/dist/options/index-web.d.ts +0 -1
- package/dist/options/index-web.d.ts.map +1 -1
- package/dist/options/{index-com.d.ts → index.d.ts} +1 -1
- package/dist/options/index.d.ts.map +1 -0
- package/dist/options/plugins/tier-mode-options/type.d.ts +1 -1
- package/dist/options/plugins/tier-mode-options/type.d.ts.map +1 -1
- package/dist/options/plugins/tier-options/type.d.ts +1 -1
- package/dist/options/plugins/tier-options/type.d.ts.map +1 -1
- package/dist/plugin-host/PluginHostEventEmitter.d.ts +2 -2
- package/dist/plugin-host/PluginHostEventEmitter.d.ts.map +1 -1
- package/dist/plugin-host/PluginHostEventTarget.d.ts +1 -1
- package/dist/plugin-host/PluginHostEventTarget.d.ts.map +1 -1
- package/dist/plugin-host/index-node.d.ts +0 -1
- package/dist/plugin-host/index-node.d.ts.map +1 -1
- package/dist/plugin-host/index-web.d.ts +0 -1
- package/dist/plugin-host/index-web.d.ts.map +1 -1
- package/dist/plugin-host/{index-com.d.ts → index.d.ts} +1 -1
- package/dist/plugin-host/index.d.ts.map +1 -0
- package/package.json +2 -7
- package/dist/TierOptionsPluginHostEventEmitter-BjGVIRN6.cjs +0 -1
- package/dist/TierOptionsPluginHostEventEmitter-DXTNpSmS.js +0 -131
- package/dist/TierOptionsPluginHostEventTarget-Bok_zzQ1.js +0 -131
- package/dist/TierOptionsPluginHostEventTarget-DqfVEP_L.cjs +0 -1
- package/dist/decorator-Culqv4k6.js +0 -1454
- package/dist/decorator-Wf_x4qDo.cjs +0 -1
- package/dist/options/index-com.d.ts.map +0 -1
- package/dist/plugin-host/index-com.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const M=require("@gby/destroyable"),l=require("com-tools"),m=require("deepmerge-ts");function u(i,...t){for(const e of t){const n=Object.getOwnPropertyDescriptors(e);Object.defineProperties(i,n)}return i}function V(i,t,e){let n=Object.getOwnPropertyDescriptors(t);return e&&l.omitMembers(n,e),Object.defineProperties(i,n),i}function k(i,t,e){let n=Object.getOwnPropertyDescriptors(t);return e?Object.defineProperties(i,l.removeUndefined(l.pickMembers(n,e))):Object.defineProperties(i,n),i}function j(i,t){return t}function I(){return function(t){return t}}function S(i,t){return u(i,t),t}function B(i){return function(e){return u(i,e),e}}function d(i,t){return u(i,t),i}function q(i){return function(e){return u(i,e),i}}function A(i,t){return t}function $(){return function(t){return t}}function z(i,t){return u(i.prototype,t),t}function K(i){return function(e){return u(i.prototype,e),e}}function R(i,t){return u(i.prototype,t),i}function W(i){return function(e){return u(i.prototype,e),i}}const F=["onCreate","onInit","onDestroy"];function G(i){const t={...i};for(const e of F)typeof t[e]=="function"&&delete t[e];return t}function b(i,t){let e=Object.getOwnPropertyDescriptors(t);for(const n of F)typeof t[n]=="function"&&delete e[n];return Object.defineProperties(i,e),i}function D(i){return i&&typeof i.onUse=="function"}class J extends M.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:n}=this;if(n.has(t))return n.get(t);const s=t.onUse(this.host,...e);return n.set(t,s),s}instUse(t,e,...n){const{plugins:s}=this;if(s.has(e))return s.get(e);const r=this.use(e,...n);return e.onCreate?.(t),r}onCreate(t,...e){const n=[];for(const[s]of this.plugins)s.onCreate&&n.push(s.onCreate.bind(s));return l.serialCallFuns(n,void 0,[t,...e])}onInit(t,...e){const n=[];for(const[s]of this.plugins)s.onInit&&n.push(s.onInit.bind(s));return l.serialCallFuns(n,void 0,[t,...e])}onDestroy(t){const e=[];for(const[n]of this.plugins)n.onDestroy&&e.push(n.onDestroy.bind(n));return e.reverse(),l.serialCallFuns(e,void 0,[t])}}class L extends M.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)||(b(this.host.prototype,t),e.add(t)),t}instUse(t,e,...n){const{plugins:s}=this;return s.has(e)||(this.use(e),e.onCreate?.call(t,t,...n)),e}onCreate(t,...e){const n=[];for(const s of this.plugins)s.onCreate&&n.push(s.onCreate);return l.serialCallFuns(n,t,[t,...e])}onInit(t,...e){const n=[];for(const s of this.plugins)s.onInit&&n.push(s.onInit);return l.serialCallFuns(n,t,[t,...e])}onDestroy(t){const e=[];for(const n of this.plugins)n.onDestroy&&e.push(n.onDestroy);return e.reverse(),l.serialCallFuns(e,t,[t])}}const h=Symbol("extend");class g extends M.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)}isPlugin(t){const{plugins:e}=this;return e.has(t)?e.get(t)!==h:D(t)}useExtend(t){const{plugins:e}=this;return e.has(t)?e.get(t):(b(this.host.prototype,t),e.set(t,h),t)}instUseExtend(t,e,...n){const{plugins:s}=this;return s.has(e)?s.get(e):(this.useExtend(e),e.onCreate?.call(t,t,...n),e)}usePlugin(t,...e){const{plugins:n}=this;if(n.has(t))return n.get(t);const s=t.onUse(this.host,...e);return n.set(t,s),s}instUsePlugin(t,e,...n){const{plugins:s}=this;if(s.has(e))return s.get(e);const r=this.usePlugin(e,...n);return e.onCreate?.(t),r}onCreate(t,...e){const n=[];for(const[s,r]of this.plugins)if(s.onCreate){const o=r===h?s.onCreate:s.onCreate.bind(s);n.push(o)}return l.serialCallFuns(n,t,[t,...e])}onInit(t,...e){const n=[];for(const[s,r]of this.plugins)if(s.onInit){const o=r===h?s.onInit:s.onInit.bind(s);n.push(o)}return l.serialCallFuns(n,t,[t,...e])}onDestroy(t){const e=[];for(const[n,s]of this.plugins)if(n.onDestroy){const r=s===h?n.onDestroy:n.onDestroy.bind(n);e.push(r)}return e.reverse(),l.serialCallFuns(e,t,[t])}}function _(i,t){const e=[{target:i,props:t}];let n;for(;n=e.shift();){const{target:s,props:r}=n;for(const[o,a]of Object.entries(r)){if(a!=null&&typeof a=="object"&&(!a.constructor||a.constructor===Object)){e.push({target:s[o],props:a});continue}s[o]=a}}return i}function v(i,t){const e={},n=[{target:i,props:t,targetProps:e}];let s;for(;s=n.shift();){const{target:r,props:o,targetProps:a}=s;for(const[P,O]of Object.entries(o)){if(O!=null&&typeof O=="object"&&(!O.constructor||O.constructor===Object)){n.push({target:r[P],props:O,targetProps:a[P]={}});continue}a[P]=r[P]}}return e}function Q(i,t){const e=v(i,t);function n(){_(i,t)}function s(){_(i,e)}return{set:n,unset:s}}function X(i,t){const e=t??"defaultOptions",n=`_${e}`;return function(r){const o=d(r,{get[e](){return i}});d(o.prototype,{get[e](){return this[n]||(this[n]=structuredClone(o.defaultOptions))}})}}function Y(i,t,e){const n=`_${t}`;return d(i.prototype,{get[t](){return this[n]||(this[n]=structuredClone(i[t]))}}),e}function T(i){const t=i.split(".");return t[0]===""&&t.shift(),t}function x(i,t){for(const e of t)if(i=i[e],i==null)return;return i}function Z(i,t){return x(i,T(t))}function w(i,t,e){const n=t.pop(),s=t.length;let r=0;for(;r<s;){const o=i[t[r]];if(o==null)break;i=o,r++}t=t.slice(r);for(const o of t)i=i[o]={};return i[n]=e,i}function tt(i,t,e){return w(i,T(t),e)}const y={UndefinedAndNull:function(t){return t==null},Undefined:function(t){return t===void 0},Null:function(t){return t===null}};class C{freezeMember=!0;fullOption=new Proxy(this,{get:function(t,e,n){const s=t.plainFullOption[e];return t.freezeMember?Object.freeze(s):s},set:function(t,e,n,s){return t.setMember(e,n,!1),!0},has:function(t,e){return e in t.plainFullOption},getOwnPropertyDescriptor:function(t,e){return Object.getOwnPropertyDescriptor(t.plainFullOption,e)},ownKeys:function(t){return Reflect.ownKeys(t.plainFullOption)},deleteProperty:function(t,e){return t.setMember(e,void 0),!0},defineProperty:function(t,e,n){return Object.defineProperty(t.option,e,n),!0}});setOption(t,e){const n=e?m.deepmergeInto(this.option,t):Object.assign(this.option,t);return this.updateFullOption(),n}get undefinedValue(){return this._undefinedValue}set undefinedValue(t){this._undefinedValue=t,this.isUndefined=y[t]||y.UndefinedAndNull}_undefinedValue="UndefinedAndNull";isUndefined=y.UndefinedAndNull;getMember(t){return this.option[t]}setMember(t,e,n){const s=this.option;if(e===void 0)delete s[t];else{const r=s[t];n&&r&&typeof r=="object"?m.deepmergeInto(r,e):s[t]=e}this.updateFullOption()}getValue(t){return x(this.option,t)}setValue(t,e,n){const s=this.option;let r;n&&(r=x(s,t))&&typeof r=="object"?m.deepmergeInto(r,e):w(this.option,t,e),this.updateFullOption()}}class p extends C{constructor(t,e){super(),t&&(this.option=t),e&&(this.extends=e)}get extends(){return this._extends}set extends(t){this._extends=t,this.updateFullOption()}_extends=null;option={};get plainFullOption(){let t=this._plainFullOption;if(t)return t;const{extends:e,option:n}=this;if(t=n,e){const s=e.plainFullOption;t=m.deepmerge(s,n)}return this._plainFullOption=t}_plainFullOption=null;updateFullOption(){this._plainFullOption=null}getMember(t){const e=this.option[t];if(!this.isUndefined(e))return e;const n=this.extends;if(n)return n.getMember(t)}getValue(t){const e=super.getValue(t);if(!this.isUndefined(e))return e;const n=this.extends;if(n)return n.getValue(t)}}function et(i,t){const{name:e}=t,n=`_${e}`;return{get:function(){return this[n]||(this[n]=new p(void 0,this.constructor[e]))}}}class H extends C{constructor(t,e){super(),e&&this.setModeOption(t,e),this.mode=t}modes={};get mode(){return this._mode||(this.mode=this.modeNames[0])}set mode(t){this._mode=t,this.hasMode(t)||this.setModeOption(t,{}),this.updateFullOption()}_mode;get modeNames(){return this._modeNames||(this._modeNames=this.getModeNames())}_modeNames=null;getModeNames(){return Object.keys(this.modes)}hasMode(t){return!!this.modes[t]}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(t){return this.modes[t].option}getFullModeOption(t){return this.modes[t]?.plainFullOption}setModeOption(t,e,n,s){const{modes:r}=this,o=r[t]||(r[t]=new p);if(o.setOption(e,n),s){const a=r[s];a&&(o.extends=a)}return this.updateFullOption(),o}}class c extends H{constructor(t,e,n){super(t,e),n&&(this.extends=n)}get extends(){return this._extends}set extends(t){this._extends=t,this.updateFullOption()}_extends=null;getFullModeOption(t){const{modes:e,extends:n}=this,s=e[t]?.plainFullOption;if(n){const r=n.getFullModeOption(t);return s?m.deepmerge(r,s):r}return s}getModeNames(){const{modes:t,extends:e}=this,n=Object.keys(t);if(!e)return n;const s=e.getModeNames();return[...new Set([...n,...s])]}hasModeOnTier(t){if(this.hasMode(t))return!0;const e=this.extends;return e?e.hasModeOnTier(t):!1}get optionManager(){return this.getModeOptionManager(this.mode)}getModeOptionManager(t){const e=this.modes[t];return e||(this.extends?.getModeOptionManager(t)?this.setModeOption(t,{}):null)}getMember(t){const e=this.optionManager.getMember(t);if(!this.isUndefined(e))return e;const n=this.extends;if(n)return n.getMember(t)}getValue(t){const e=this.optionManager.getValue(t);if(!this.isUndefined(e))return e;const n=this.extends;if(n)return n.getValue(t)}}function nt(i,t){const{name:e}=t,n=`_${e}`;return{get:function(){return this[n]||(this[n]=new c(this.constructor[e].mode,void 0,this.constructor[e]))}}}class U extends M.Destroyable{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new g(this)),this._pluginManager}static _pluginManager=new g(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 it extends U{static defaultOptions=new p;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new p(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(t){super(),this.defaultOptions.option=t}}function E(i){const t=M.createDestroyableSubClass(i);return class extends t{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new g(this)),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 st(i){const t=E(i);return class extends t{static defaultOptions=new p;get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new p(void 0,this.constructor.defaultOptions))}_defaultOptions;constructor(n){super(),this.defaultOptions.option=n}}}const f="common";class rt extends U{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(t){this.modeOptions.mode=t}get options(){return this.modeOptions.plainFullOption}constructor(t){super(),this.modeOptions.setOption(t)}}function ot(i){const t=E(i);return class extends t{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)}}}function ut(i,t,e){const n=d(i,{modeOptions:new c(t,e)});return d(n.prototype,{get modeOptions(){return this._modeOptions||(this._modeOptions=new c(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}}),i}const at={onUse(i,t,e){const n=t??f;u(i,{modeOptions:new c(n,void 0,e)}),u(i.prototype,{get modeOptions(){const s=this,r=i;return s._modeOptions||(s._modeOptions=new c(r.modeOptions.mode,void 0,r.modeOptions))},get mode(){return this.modeOptions.mode},set mode(s){const r=this;r.modeOptions.mode=s},get options(){return this.modeOptions.plainFullOption}})},onCreate(i,t){i.modeOptions.setOption(t)}},lt={onUse(i,t,e){u(i,{defaultOptions:new p(t,e)}),u(i.prototype,{get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new p(void 0,i.defaultOptions))}})},onCreate(i,t){i.defaultOptions.option=t}};function pt(i,t){const e=d(i,{defaultOptions:new p(t)});return d(e.prototype,{get defaultOptions(){return this._defaultOptions||(this._defaultOptions=new p(void 0,this.constructor.defaultOptions))}}),i}function N(i){const t=d(i,{isolatedPluginManager:!1,get pluginManager(){return(!this._pluginManager||this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager"))&&(this._pluginManager=new g(this)),this._pluginManager},usePlugin(e,...n){return this.pluginManager.usePlugin(e,...n)},useExtend(e){return this.pluginManager.useExtend(e)},hasUsed(e){return this.pluginManager.hasUsed(e)}});return d(t.prototype,{get pluginManager(){return this.constructor.pluginManager},usePlugin(e,...n){return this.pluginManager.instUsePlugin(this,e,...n)},useExtend(e,...n){return this.pluginManager.instUseExtend(this,e,...n)},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()}}),i}function dt(i){const t=N(i);return new Proxy(t,{construct:function(e,n,s){const r=new e(...n);return t.pluginManager.onCreate(this,...n),r}})}function ct(i){return class extends i{static isolatedPluginManager=!1;static get pluginManager(){return this.isolatedPluginManager&&!this.hasOwnProperty("_pluginManager")&&(this._pluginManager=new g(this)),this._pluginManager}static _pluginManager=new g(this);get pluginManager(){return this.constructor.pluginManager}static usePlugin(e,...n){return this.pluginManager.usePlugin(e,...n)}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,...n){return this.pluginManager.instUsePlugin(this,e,...n)}useExtend(e,...n){return this.pluginManager.instUseExtend(this,e,...n)}init(...e){if(super.init){const n=super.init(...e);if(n instanceof Promise)return n.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.ExtendManager=L;exports.ModeOptions=H;exports.PluginExtendManager=g;exports.PluginHost=U;exports.PluginManager=J;exports.TierModeOptions=c;exports.TierModeOptionsPluginHost=rt;exports.TierOptions=p;exports.TierOptionsPluginHost=it;exports.addDefaultOptions=X;exports.addInstOptions=Y;exports.becomePluginHost=N;exports.becomePluginHost_Extends=ct;exports.becomePluginHost_Proxy=dt;exports.becomeTierModeOptionsHost=ut;exports.becomeTierOptionsHost=pt;exports.commonModeName=f;exports.createDefineExtend=$;exports.createDefineMixin=I;exports.createExtendTarget=W;exports.createMixinTarget=q;exports.createPluginHost=E;exports.createPropertySetter=Q;exports.createTargetExtend=K;exports.createTargetMixin=B;exports.createTierModeOptionsPluginHost=ot;exports.createTierOptionsPluginHost=st;exports.defineExtend=A;exports.defineMixin=j;exports.extendMark=h;exports.extendTarget=R;exports.getPropertyValue=x;exports.getPropertyValueByPath=Z;exports.getTargetProperties=v;exports.isPlugin=D;exports.mergeProperties=_;exports.mixin=u;exports.mixinByOmit=V;exports.mixinByPick=k;exports.mixinIExtend=b;exports.mixinTarget=d;exports.parsePropertyPath=T;exports.pickHostExtendMembers=G;exports.setPropertyValue=w;exports.setPropertyValueByPath=tt;exports.targetExtend=z;exports.targetMixin=S;exports.tierModeOptionsDecorator=nt;exports.tierModeOptionsPlugin=at;exports.tierOptionsDecorator=et;exports.tierOptionsPlugin=lt;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-com.d.ts","sourceRoot":"","sources":["../../src/options/index-com.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iBAAiB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-com.d.ts","sourceRoot":"","sources":["../../src/plugin-host/index-com.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|