plugin-tls 5.1.0 → 5.2.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 (34) hide show
  1. package/dist/{createTierModeOptionsPluginHost-D-fKYlcA.js → createTierModeOptionsPluginHost-Bvne8SqN.js} +90 -58
  2. package/dist/createTierModeOptionsPluginHost-D2REw5Vz.cjs +1 -0
  3. package/dist/index-node.cjs +1 -1
  4. package/dist/index-node.js +30 -14
  5. package/dist/index-web.cjs +1 -1
  6. package/dist/index-web.js +80 -64
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +2 -2
  11. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts +9 -2
  12. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts.map +1 -1
  13. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts +7 -1
  14. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts.map +1 -1
  15. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts +7 -1
  16. package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts.map +1 -1
  17. package/dist/options/options-plugin-host/tier-mode-options/createTierModeOptionsPluginHost.d.ts +7 -1
  18. package/dist/options/options-plugin-host/tier-mode-options/createTierModeOptionsPluginHost.d.ts.map +1 -1
  19. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts +12 -5
  20. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts.map +1 -1
  21. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts +7 -1
  22. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts.map +1 -1
  23. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts +7 -1
  24. package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts.map +1 -1
  25. package/dist/options/options-plugin-host/tier-options/createTierOptionsPluginHost.d.ts +7 -1
  26. package/dist/options/options-plugin-host/tier-options/createTierOptionsPluginHost.d.ts.map +1 -1
  27. package/dist/plugin-host/PluginHost.d.ts +0 -1
  28. package/dist/plugin-host/PluginHost.d.ts.map +1 -1
  29. package/dist/type.d.ts +2 -0
  30. package/dist/type.d.ts.map +1 -0
  31. package/package.json +2 -2
  32. package/dist/createTierModeOptionsPluginHost-DyDtXKNW.cjs +0 -1
  33. package/dist/index-com.d.ts +0 -3
  34. package/dist/index-com.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-tls",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "plugin-tls 是插件系统相应的工具,可快速地让任何模块具备插件机制",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -64,7 +64,7 @@
64
64
  "vite-node": "latest"
65
65
  },
66
66
  "dependencies": {
67
- "@gby/destroyable": "^5.2.0",
67
+ "@gby/destroyable": "^5.2.1",
68
68
  "com-tools": "^2.22.1",
69
69
  "deepmerge-ts": "^7.1.5",
70
70
  "type-tls": "^3.11.0"
@@ -1 +0,0 @@
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,3 +0,0 @@
1
- export * from "./plugin-manager/index";
2
- export * from "./properties";
3
- //# sourceMappingURL=index-com.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-com.d.ts","sourceRoot":"","sources":["../src/index-com.ts"],"names":[],"mappings":"AAEA,cAAc,wBAAwB,CAAA;AACtC,cAAc,cAAc,CAAA"}