plugin-tls 3.5.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-com.d.ts +3 -0
- package/dist/index-com.d.ts.map +1 -0
- package/dist/index-node.cjs +1 -0
- package/dist/index-node.d.ts +3 -0
- package/dist/index-node.d.ts.map +1 -0
- package/dist/index-node.js +256 -0
- package/dist/index-web.cjs +1 -0
- package/dist/index-web.d.ts +3 -0
- package/dist/index-web.d.ts.map +1 -0
- package/dist/index-web.js +326 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +388 -1466
- package/dist/options/index-node.d.ts +2 -0
- package/dist/options/index-node.d.ts.map +1 -0
- package/dist/options/index-web.d.ts +2 -0
- package/dist/options/index-web.d.ts.map +1 -0
- package/dist/options/index.d.ts +3 -3
- package/dist/options/index.d.ts.map +1 -1
- package/dist/options/options-plugin-host/{index.d.ts → index-com.d.ts} +1 -1
- package/dist/options/options-plugin-host/index-com.d.ts.map +1 -0
- package/dist/options/options-plugin-host/index-node.d.ts +4 -0
- package/dist/options/options-plugin-host/index-node.d.ts.map +1 -0
- package/dist/options/options-plugin-host/index-web.d.ts +4 -0
- package/dist/options/options-plugin-host/index-web.d.ts.map +1 -0
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHost.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts +2 -2
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventEmitter.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/TierModeOptionsPluginHostEventTarget.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-mode-options/index.d.ts +0 -2
- package/dist/options/options-plugin-host/tier-mode-options/index.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHost.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts +2 -2
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventEmitter.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts +1 -1
- package/dist/options/options-plugin-host/tier-options/TierOptionsPluginHostEventTarget.d.ts.map +1 -1
- package/dist/options/options-plugin-host/tier-options/index.d.ts +0 -2
- package/dist/options/options-plugin-host/tier-options/index.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 +2 -0
- package/dist/plugin-host/index-node.d.ts.map +1 -0
- package/dist/plugin-host/index-web.d.ts +2 -0
- package/dist/plugin-host/index-web.d.ts.map +1 -0
- package/dist/plugin-host/index.d.ts +0 -2
- package/dist/plugin-host/index.d.ts.map +1 -1
- package/dist/plugin-manager/IExtend.d.ts +3 -0
- package/dist/plugin-manager/IExtend.d.ts.map +1 -1
- package/dist/plugin-manager/mixin.d.ts +4 -0
- package/dist/plugin-manager/mixin.d.ts.map +1 -1
- package/package.json +23 -6
- package/dist/index.umd.cjs +0 -1
- package/dist/options/options-plugin-host/index.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-com.d.ts","sourceRoot":"","sources":["../src/index-com.ts"],"names":[],"mappings":"AAEA,cAAc,wBAAwB,CAAA;AACtC,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../src/index-node.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,256 @@
|
|
|
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 {
|
|
7
|
+
/**
|
|
8
|
+
* 引用计数
|
|
9
|
+
* @remarks
|
|
10
|
+
* 引用计数为 0 时,对象才会被销毁
|
|
11
|
+
*/
|
|
12
|
+
refCount = 0;
|
|
13
|
+
/**
|
|
14
|
+
* 是否已经销毁
|
|
15
|
+
*/
|
|
16
|
+
get isDestroyed() {
|
|
17
|
+
return this._isDestroyed;
|
|
18
|
+
}
|
|
19
|
+
_isDestroyed = !1;
|
|
20
|
+
/**
|
|
21
|
+
* 是否可以销毁
|
|
22
|
+
*/
|
|
23
|
+
get canDestroy() {
|
|
24
|
+
return !this.isDestroyed && this.refCount <= 0;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 销毁者
|
|
28
|
+
*/
|
|
29
|
+
_destroyers = [];
|
|
30
|
+
/**
|
|
31
|
+
* 添加销毁者
|
|
32
|
+
* @param fun
|
|
33
|
+
* @returns 返回销毁者的顺序
|
|
34
|
+
*/
|
|
35
|
+
disposeFun(t) {
|
|
36
|
+
return this._destroyers.push(t), t;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 取消销毁者函数
|
|
40
|
+
* @param fun
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
cancelDisposeFun(t) {
|
|
44
|
+
const s = this._destroyers.indexOf(t);
|
|
45
|
+
return this._destroyers.splice(s, 1), t;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 添加销毁对象
|
|
49
|
+
* @param obj
|
|
50
|
+
* @param sync - 表示是否使用 `obj.destroySync()` 方法进行销毁;默认使用 `obj.destroy()` 方法进行销毁
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
disposeObj(t, s) {
|
|
54
|
+
const e = s ? function() {
|
|
55
|
+
return t.destroySync();
|
|
56
|
+
} : function() {
|
|
57
|
+
return t.destroy();
|
|
58
|
+
};
|
|
59
|
+
return this.disposeFun(e), t.__destroyable_destroyer = e, t;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 取消销毁者函数
|
|
63
|
+
* @param fun
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
cancelDisposeObj(t) {
|
|
67
|
+
const s = t.__destroyable_destroyer;
|
|
68
|
+
return s && this.cancelDisposeFun(s), t;
|
|
69
|
+
}
|
|
70
|
+
dispose(t, s) {
|
|
71
|
+
return typeof t == "function" ? this.disposeFun(t) : this.disposeObj(t, s);
|
|
72
|
+
}
|
|
73
|
+
cancelDispose(t) {
|
|
74
|
+
return typeof t == "function" ? this.cancelDisposeFun(t) : this.cancelDisposeObj(t);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 自己的销毁方法
|
|
78
|
+
* @remarks
|
|
79
|
+
* 子类根据需要进行重载
|
|
80
|
+
*/
|
|
81
|
+
destroyThis() {
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 同步销毁
|
|
85
|
+
* @remarks
|
|
86
|
+
* 会逆序依次同步调用所有销毁函数,并不会等待上一个销毁函数异步执行完成
|
|
87
|
+
*/
|
|
88
|
+
destroySync() {
|
|
89
|
+
if (!this.canDestroy) return this.isDestroyed;
|
|
90
|
+
let t = this._destroyers.length;
|
|
91
|
+
for (; --t >= 0; ) {
|
|
92
|
+
const s = this._destroyers[t];
|
|
93
|
+
try {
|
|
94
|
+
s();
|
|
95
|
+
} catch (e) {
|
|
96
|
+
console.error("销毁函数在同步销毁时出错", this, s, e);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this._destroyers.length = 0;
|
|
100
|
+
try {
|
|
101
|
+
this.destroyThis();
|
|
102
|
+
} catch (s) {
|
|
103
|
+
console.error("destroyThis 在异步销毁时出错", this, s);
|
|
104
|
+
}
|
|
105
|
+
return n(this), !0;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 串行销毁
|
|
109
|
+
* @remarks
|
|
110
|
+
* 会逆序依次执行销毁,并且只有上一个销毁完成之后才会执行下一个销毁
|
|
111
|
+
* @returns 如果所有的销毁函数都是同步的,那么返回 true;如果有任何一个销毁函数是异步的,那么返回一个 Promise 对象
|
|
112
|
+
*/
|
|
113
|
+
destroy() {
|
|
114
|
+
if (!this.canDestroy) return this.isDestroyed;
|
|
115
|
+
const t = this._destroyers.toReversed();
|
|
116
|
+
t.push(this.destroyThis), this._destroyers.length = 0;
|
|
117
|
+
const s = p(t, this, null, (e, h) => {
|
|
118
|
+
console.error("销毁函数在串行销毁时出错", this, h, e);
|
|
119
|
+
});
|
|
120
|
+
return s instanceof Promise ? s.then(() => (n(this), !0)) : (n(this), !0);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
class d extends c {
|
|
124
|
+
/**
|
|
125
|
+
* 是否使用独立的插件管理器
|
|
126
|
+
* @defaultValue false
|
|
127
|
+
*/
|
|
128
|
+
static isolatedPluginManager = !1;
|
|
129
|
+
/**
|
|
130
|
+
* 插件管理器
|
|
131
|
+
*/
|
|
132
|
+
static get pluginManager() {
|
|
133
|
+
return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new r(this)), this._pluginManager;
|
|
134
|
+
}
|
|
135
|
+
static _pluginManager = new r(this);
|
|
136
|
+
/**
|
|
137
|
+
* 插件管理器 {@link PluginHost.pluginManager}
|
|
138
|
+
*/
|
|
139
|
+
get pluginManager() {
|
|
140
|
+
return this.constructor.pluginManager;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* {@inheritDoc PluginExtendManager.usePlugin}
|
|
144
|
+
*/
|
|
145
|
+
static usePlugin(t, ...s) {
|
|
146
|
+
return this.pluginManager.usePlugin(t, ...s);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* {@inheritDoc PluginExtendManager.useExtend}
|
|
150
|
+
*/
|
|
151
|
+
static useExtend(t) {
|
|
152
|
+
return this.pluginManager.useExtend(t);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 是否注册了插件 或 扩展
|
|
156
|
+
* @param plugin - 插件 或 扩展
|
|
157
|
+
* @returns 是否注册了插件 或 扩展
|
|
158
|
+
*/
|
|
159
|
+
static hasUsed(t) {
|
|
160
|
+
return this.pluginManager.hasUsed(t);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 需要在子类中调用
|
|
164
|
+
*
|
|
165
|
+
* 之所以没写在该类中的函数中,是因为 `this.pluginManager.onCreate(this,...args)` 通常会在构建函数执行的最后时才调用;
|
|
166
|
+
* 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.onCreate(this,...args)` 不是在最后的执行;
|
|
167
|
+
*/
|
|
168
|
+
// constructor(...args:any) {
|
|
169
|
+
// super();
|
|
170
|
+
// // @ts-ignore
|
|
171
|
+
// this.pluginManager.onCreate(this,...args);
|
|
172
|
+
// }
|
|
173
|
+
/**
|
|
174
|
+
* 实例的注册插件的方法
|
|
175
|
+
* @param plugin
|
|
176
|
+
* @param args
|
|
177
|
+
* @returns
|
|
178
|
+
*/
|
|
179
|
+
usePlugin(t, ...s) {
|
|
180
|
+
return this.pluginManager.instUsePlugin(this, t, ...s);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* {@inheritDoc PluginExtendManager.useExtend}
|
|
184
|
+
*/
|
|
185
|
+
useExtend(t, ...s) {
|
|
186
|
+
return this.pluginManager.instUseExtend(this, t, ...s);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 初始化实例
|
|
190
|
+
* @remarks
|
|
191
|
+
* 会调用 {@link PluginExtendManager.onInit}
|
|
192
|
+
* @param args
|
|
193
|
+
*/
|
|
194
|
+
init(...t) {
|
|
195
|
+
return this.pluginManager.onInit(this, ...t);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* 销毁实例
|
|
199
|
+
* @returns
|
|
200
|
+
*/
|
|
201
|
+
destroyThis() {
|
|
202
|
+
const t = this.pluginManager.onDestroy(this);
|
|
203
|
+
return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
class f extends d {
|
|
207
|
+
/**
|
|
208
|
+
* 全局级别的默认选项
|
|
209
|
+
*/
|
|
210
|
+
static modeOptions = new o(u);
|
|
211
|
+
/**
|
|
212
|
+
* 实例级的默认选项
|
|
213
|
+
*/
|
|
214
|
+
get modeOptions() {
|
|
215
|
+
return this._modeOptions || (this._modeOptions = new o(u, void 0, this.constructor.modeOptions));
|
|
216
|
+
}
|
|
217
|
+
_modeOptions;
|
|
218
|
+
get mode() {
|
|
219
|
+
return this.modeOptions.mode;
|
|
220
|
+
}
|
|
221
|
+
set mode(t) {
|
|
222
|
+
this.modeOptions.mode = t;
|
|
223
|
+
}
|
|
224
|
+
get options() {
|
|
225
|
+
return this.modeOptions.plainFullOption;
|
|
226
|
+
}
|
|
227
|
+
constructor(t) {
|
|
228
|
+
super(), this.modeOptions.setOption(t);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
class _ extends d {
|
|
232
|
+
/**
|
|
233
|
+
* 全局级别的默认选项
|
|
234
|
+
*/
|
|
235
|
+
static defaultOptions = new a();
|
|
236
|
+
/**
|
|
237
|
+
* 实例级的默认选项
|
|
238
|
+
*/
|
|
239
|
+
get defaultOptions() {
|
|
240
|
+
return this._defaultOptions || (this._defaultOptions = new a(void 0, this.constructor.defaultOptions));
|
|
241
|
+
}
|
|
242
|
+
_defaultOptions;
|
|
243
|
+
constructor(t) {
|
|
244
|
+
super(), this.defaultOptions.option = t;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
export {
|
|
248
|
+
d as PluginHostEventEmitter,
|
|
249
|
+
D as TierModeOptionsPluginHost,
|
|
250
|
+
f as TierModeOptionsPluginHostEventEmitter,
|
|
251
|
+
T as TierOptionsPluginHost,
|
|
252
|
+
_ as TierOptionsPluginHostEventEmitter,
|
|
253
|
+
u as commonModeName,
|
|
254
|
+
E as createTierModeOptionsPluginHost,
|
|
255
|
+
x as createTierOptionsPluginHost
|
|
256
|
+
};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-web.d.ts","sourceRoot":"","sources":["../src/index-web.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { i as o } from "./Destroyable-BqvuD4gL-D50ZO9eN.js";
|
|
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";
|
|
5
|
+
if (!globalThis.CustomEvent) {
|
|
6
|
+
class n extends Event {
|
|
7
|
+
detail;
|
|
8
|
+
constructor(s, e) {
|
|
9
|
+
super(s, e), this.detail = e?.detail;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
globalThis.CustomEvent = n;
|
|
13
|
+
}
|
|
14
|
+
class y extends EventTarget {
|
|
15
|
+
/**
|
|
16
|
+
* 添加事件监听器;会返回一个用于移除事件监听器的函数;
|
|
17
|
+
* @remarks
|
|
18
|
+
* 当没有指定 times 选项时,也可以通过 EventTarget 的 removeEventListener 方法移除;
|
|
19
|
+
* 当指定 times 选项时,只能通过 返回的函数移除监听器
|
|
20
|
+
*
|
|
21
|
+
* @param type - 事件名字、事件类型
|
|
22
|
+
* @param callback - 事件监听器,触发事件时会调用此函数
|
|
23
|
+
* @param options - 选项
|
|
24
|
+
* @returns 返回用于移除事件监听器的函数; 也可以通过 `EventTarget#removeEventListener` 方法移除
|
|
25
|
+
*/
|
|
26
|
+
addEventListener(t, s, e) {
|
|
27
|
+
const i = e?.times;
|
|
28
|
+
if (i) {
|
|
29
|
+
const r = typeof s == "function" ? s : s?.handleEvent;
|
|
30
|
+
if (r)
|
|
31
|
+
return this.multipleListen(t, r, i);
|
|
32
|
+
}
|
|
33
|
+
return super.addEventListener(t, s, e), () => {
|
|
34
|
+
this.removeEventListener(t, s, e);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
dispatchEvent(t, s) {
|
|
38
|
+
const e = t instanceof Event ? t : new CustomEvent(t, { detail: s, bubbles: !1, cancelable: !0, composed: !1 });
|
|
39
|
+
return super.dispatchEvent(e);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 添加一次性的事件监听器;
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* 会返回一个用于移除一次性事件监听器的函数; 也可以通过 EventTarget 的 removeEventListener 方法移除
|
|
46
|
+
*
|
|
47
|
+
* @param type - 事件名字、事件类型
|
|
48
|
+
* @param callback - 事件监听器,触发事件时会调用此函数
|
|
49
|
+
* @param options - 选项
|
|
50
|
+
* @returns removeEventListener():void; 返回用于移除一次性事件监听器的函数; 也可以通过 EventTarget 的 removeEventListener 方法移除
|
|
51
|
+
*/
|
|
52
|
+
onceListen(t, s, e) {
|
|
53
|
+
return this.addEventListener(t, s, { ...e, once: !0 });
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 添加监听指定次数的事件监听器;
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* 当事件触发指定次数后,会自动移除监听器;会返回一个用于移除事件监听器的函数; 不能通过 EventTarget 的 removeEventListener 方法移除
|
|
60
|
+
*
|
|
61
|
+
* @param type - 事件名字、事件类型
|
|
62
|
+
* @param callback - 事件监听器,触发事件时会调用此函数
|
|
63
|
+
* @param times 需要监听的次数,如果小于 1 ,永远不会自动移除事件监听器,需要手动移除
|
|
64
|
+
* @returns removeEventListener():void; 返回用于移除事件监听器的函数; 不能通过 EventTarget 的 removeEventListener 方法移除
|
|
65
|
+
*/
|
|
66
|
+
multipleListen(t, s, e) {
|
|
67
|
+
let i = 0;
|
|
68
|
+
const r = new AbortController(), c = r.signal;
|
|
69
|
+
return super.addEventListener(t, (p) => {
|
|
70
|
+
++i >= e && r.abort(), s.call(this, p);
|
|
71
|
+
}, { signal: c }), function() {
|
|
72
|
+
r.abort();
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class f extends y {
|
|
77
|
+
/**
|
|
78
|
+
* 引用计数
|
|
79
|
+
* @remarks
|
|
80
|
+
* 引用计数为 0 时,对象才会被销毁
|
|
81
|
+
*/
|
|
82
|
+
refCount = 0;
|
|
83
|
+
/**
|
|
84
|
+
* 是否已经销毁
|
|
85
|
+
*/
|
|
86
|
+
get isDestroyed() {
|
|
87
|
+
return this._isDestroyed;
|
|
88
|
+
}
|
|
89
|
+
_isDestroyed = !1;
|
|
90
|
+
/**
|
|
91
|
+
* 是否可以销毁
|
|
92
|
+
*/
|
|
93
|
+
get canDestroy() {
|
|
94
|
+
return !this.isDestroyed && this.refCount <= 0;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 销毁者
|
|
98
|
+
*/
|
|
99
|
+
_destroyers = [];
|
|
100
|
+
/**
|
|
101
|
+
* 添加销毁者
|
|
102
|
+
* @param fun
|
|
103
|
+
* @returns 返回销毁者的顺序
|
|
104
|
+
*/
|
|
105
|
+
disposeFun(t) {
|
|
106
|
+
return this._destroyers.push(t), t;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 取消销毁者函数
|
|
110
|
+
* @param fun
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
cancelDisposeFun(t) {
|
|
114
|
+
const s = this._destroyers.indexOf(t);
|
|
115
|
+
return this._destroyers.splice(s, 1), t;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 添加销毁对象
|
|
119
|
+
* @param obj
|
|
120
|
+
* @param sync - 表示是否使用 `obj.destroySync()` 方法进行销毁;默认使用 `obj.destroy()` 方法进行销毁
|
|
121
|
+
* @returns
|
|
122
|
+
*/
|
|
123
|
+
disposeObj(t, s) {
|
|
124
|
+
const e = s ? function() {
|
|
125
|
+
return t.destroySync();
|
|
126
|
+
} : function() {
|
|
127
|
+
return t.destroy();
|
|
128
|
+
};
|
|
129
|
+
return this.disposeFun(e), t.__destroyable_destroyer = e, t;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 取消销毁者函数
|
|
133
|
+
* @param fun
|
|
134
|
+
* @returns
|
|
135
|
+
*/
|
|
136
|
+
cancelDisposeObj(t) {
|
|
137
|
+
const s = t.__destroyable_destroyer;
|
|
138
|
+
return s && this.cancelDisposeFun(s), t;
|
|
139
|
+
}
|
|
140
|
+
dispose(t, s) {
|
|
141
|
+
return typeof t == "function" ? this.disposeFun(t) : this.disposeObj(t, s);
|
|
142
|
+
}
|
|
143
|
+
cancelDispose(t) {
|
|
144
|
+
return typeof t == "function" ? this.cancelDisposeFun(t) : this.cancelDisposeObj(t);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 自己的销毁方法
|
|
148
|
+
* @remarks
|
|
149
|
+
* 子类根据需要进行重载
|
|
150
|
+
*/
|
|
151
|
+
destroyThis() {
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* 同步销毁
|
|
155
|
+
* @remarks
|
|
156
|
+
* 会逆序依次同步调用所有销毁函数,并不会等待上一个销毁函数异步执行完成
|
|
157
|
+
*/
|
|
158
|
+
destroySync() {
|
|
159
|
+
if (!this.canDestroy) return this.isDestroyed;
|
|
160
|
+
let t = this._destroyers.length;
|
|
161
|
+
for (; --t >= 0; ) {
|
|
162
|
+
const s = this._destroyers[t];
|
|
163
|
+
try {
|
|
164
|
+
s();
|
|
165
|
+
} catch (e) {
|
|
166
|
+
console.error("销毁函数在同步销毁时出错", this, s, e);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
this._destroyers.length = 0;
|
|
170
|
+
try {
|
|
171
|
+
this.destroyThis();
|
|
172
|
+
} catch (s) {
|
|
173
|
+
console.error("destroyThis 在异步销毁时出错", this, s);
|
|
174
|
+
}
|
|
175
|
+
return o(this), !0;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 串行销毁
|
|
179
|
+
* @remarks
|
|
180
|
+
* 会逆序依次执行销毁,并且只有上一个销毁完成之后才会执行下一个销毁
|
|
181
|
+
* @returns 如果所有的销毁函数都是同步的,那么返回 true;如果有任何一个销毁函数是异步的,那么返回一个 Promise 对象
|
|
182
|
+
*/
|
|
183
|
+
destroy() {
|
|
184
|
+
if (!this.canDestroy) return this.isDestroyed;
|
|
185
|
+
const t = this._destroyers.toReversed();
|
|
186
|
+
t.push(this.destroyThis), this._destroyers.length = 0;
|
|
187
|
+
const s = g(t, this, null, (e, i) => {
|
|
188
|
+
console.error("销毁函数在串行销毁时出错", this, i, e);
|
|
189
|
+
});
|
|
190
|
+
return s instanceof Promise ? s.then(() => (o(this), !0)) : (o(this), !0);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
class h extends f {
|
|
194
|
+
/**
|
|
195
|
+
* 是否使用独立的插件管理器
|
|
196
|
+
* @defaultValue false
|
|
197
|
+
*/
|
|
198
|
+
static isolatedPluginManager = !1;
|
|
199
|
+
/**
|
|
200
|
+
* 插件管理器
|
|
201
|
+
*/
|
|
202
|
+
static get pluginManager() {
|
|
203
|
+
return this.isolatedPluginManager && !this.hasOwnProperty("_pluginManager") && (this._pluginManager = new a(this)), this._pluginManager;
|
|
204
|
+
}
|
|
205
|
+
static _pluginManager = new a(this);
|
|
206
|
+
/**
|
|
207
|
+
* 插件管理器 {@link PluginHost.pluginManager}
|
|
208
|
+
*/
|
|
209
|
+
get pluginManager() {
|
|
210
|
+
return this.constructor.pluginManager;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* {@inheritDoc PluginExtendManager.usePlugin}
|
|
214
|
+
*/
|
|
215
|
+
static usePlugin(t, ...s) {
|
|
216
|
+
return this.pluginManager.usePlugin(t, ...s);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* {@inheritDoc PluginExtendManager.useExtend}
|
|
220
|
+
*/
|
|
221
|
+
static useExtend(t) {
|
|
222
|
+
return this.pluginManager.useExtend(t);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 是否注册了插件 或 扩展
|
|
226
|
+
* @param plugin - 插件 或 扩展
|
|
227
|
+
* @returns 是否注册了插件 或 扩展
|
|
228
|
+
*/
|
|
229
|
+
static hasUsed(t) {
|
|
230
|
+
return this.pluginManager.hasUsed(t);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* 需要在子类中调用
|
|
234
|
+
*
|
|
235
|
+
* 之所以没写在该类中的函数中,是因为 `this.pluginManager.onCreate(this,...args)` 通常会在构建函数执行的最后时才调用;
|
|
236
|
+
* 如果像下面写在该类的构建函数中,然后子类通过 `super()` 来调用,这样就会导致 `this.pluginManager.onCreate(this,...args)` 不是在最后的执行;
|
|
237
|
+
*/
|
|
238
|
+
// constructor(...args:any) {
|
|
239
|
+
// super();
|
|
240
|
+
// // @ts-ignore
|
|
241
|
+
// this.pluginManager.onCreate(this,...args);
|
|
242
|
+
// }
|
|
243
|
+
/**
|
|
244
|
+
* 实例的注册插件的方法
|
|
245
|
+
* @param plugin
|
|
246
|
+
* @param args
|
|
247
|
+
* @returns
|
|
248
|
+
*/
|
|
249
|
+
usePlugin(t, ...s) {
|
|
250
|
+
return this.pluginManager.instUsePlugin(this, t, ...s);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* {@inheritDoc PluginExtendManager.useExtend}
|
|
254
|
+
*/
|
|
255
|
+
useExtend(t, ...s) {
|
|
256
|
+
return this.pluginManager.instUseExtend(this, t, ...s);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* 初始化实例
|
|
260
|
+
* @remarks
|
|
261
|
+
* 会调用 {@link PluginExtendManager.onInit}
|
|
262
|
+
* @param args
|
|
263
|
+
*/
|
|
264
|
+
init(...t) {
|
|
265
|
+
return this.pluginManager.onInit(this, ...t);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* 销毁实例
|
|
269
|
+
* @returns
|
|
270
|
+
*/
|
|
271
|
+
destroyThis() {
|
|
272
|
+
const t = this.pluginManager.onDestroy(this);
|
|
273
|
+
return t instanceof Promise ? t.finally(() => super.destroyThis()) : super.destroyThis();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
class E extends h {
|
|
277
|
+
/**
|
|
278
|
+
* 全局级别的默认选项
|
|
279
|
+
*/
|
|
280
|
+
static modeOptions = new u(l);
|
|
281
|
+
/**
|
|
282
|
+
* 实例级的默认选项
|
|
283
|
+
*/
|
|
284
|
+
get modeOptions() {
|
|
285
|
+
return this._modeOptions || (this._modeOptions = new u(l, void 0, this.constructor.modeOptions));
|
|
286
|
+
}
|
|
287
|
+
_modeOptions;
|
|
288
|
+
get mode() {
|
|
289
|
+
return this.modeOptions.mode;
|
|
290
|
+
}
|
|
291
|
+
set mode(t) {
|
|
292
|
+
this.modeOptions.mode = t;
|
|
293
|
+
}
|
|
294
|
+
get options() {
|
|
295
|
+
return this.modeOptions.plainFullOption;
|
|
296
|
+
}
|
|
297
|
+
constructor(t) {
|
|
298
|
+
super(), this.modeOptions.setOption(t);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
class M extends h {
|
|
302
|
+
/**
|
|
303
|
+
* 全局级别的默认选项
|
|
304
|
+
*/
|
|
305
|
+
static defaultOptions = new d();
|
|
306
|
+
/**
|
|
307
|
+
* 实例级的默认选项
|
|
308
|
+
*/
|
|
309
|
+
get defaultOptions() {
|
|
310
|
+
return this._defaultOptions || (this._defaultOptions = new d(void 0, this.constructor.defaultOptions));
|
|
311
|
+
}
|
|
312
|
+
_defaultOptions;
|
|
313
|
+
constructor(t) {
|
|
314
|
+
super(), this.defaultOptions.option = t;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
export {
|
|
318
|
+
h as PluginHostEventTarget,
|
|
319
|
+
P as TierModeOptionsPluginHost,
|
|
320
|
+
E as TierModeOptionsPluginHostEventTarget,
|
|
321
|
+
D as TierOptionsPluginHost,
|
|
322
|
+
M as TierOptionsPluginHostEventTarget,
|
|
323
|
+
l as commonModeName,
|
|
324
|
+
b as createTierModeOptionsPluginHost,
|
|
325
|
+
x as createTierOptionsPluginHost
|
|
326
|
+
};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +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(){return function(t){return t}}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(){return function(t){return t}}function H(n,t){return u(n.prototype,t),t}function _(n){return function(e){return u(n.prototype,e),e}}function C(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=_;exports.createTargetMixin=b;exports.defineExtend=w;exports.defineMixin=x;exports.extendTarget=C;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;
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,cAAc,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,cAAc,wBAAwB,CAAA;AACtC,cAAc,cAAc,CAAA;AAE5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
|