plugin-tls 0.0.0 → 1.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/README.md +5 -5
- package/dist/index.d.ts +251 -19
- package/dist/plugin-tls.d.ts +273 -0
- package/dist/plugin-tls.mjs +155 -0
- package/dist/plugin-tls.umd.js +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/doc/{index.md → api/index.md} +1 -1
- package/doc/{plugin-tls.adddefaultoptions.md → api/plugin-tls.adddefaultoptions.md} +0 -0
- package/doc/{plugin-tls.addinstoptions.md → api/plugin-tls.addinstoptions.md} +0 -0
- package/doc/api/plugin-tls.createoptionspluginhost.md +29 -0
- package/doc/{plugin-tls.createpluginhost.md → api/plugin-tls.createpluginhost.md} +7 -7
- package/doc/{plugin-tls.hostinst.md → api/plugin-tls.hostinst.md} +0 -0
- package/doc/{plugin-tls.idefaultoptionshost.defaultoptions.md → api/plugin-tls.idefaultoptionshost.defaultoptions.md} +0 -0
- package/doc/{plugin-tls.idefaultoptionshost.md → api/plugin-tls.idefaultoptionshost.md} +0 -0
- package/doc/{plugin-tls.iidefaultoptionshostconstructor.md → api/plugin-tls.iidefaultoptionshostconstructor.md} +0 -0
- package/doc/{plugin-tls.ioptionspluginhost.defaultoptions.md → api/plugin-tls.ioptionspluginhost.defaultoptions.md} +0 -0
- package/doc/{plugin-tls.ioptionspluginhost.md → api/plugin-tls.ioptionspluginhost.md} +1 -1
- package/doc/{plugin-tls.ioptionspluginhostconstructor.md → api/plugin-tls.ioptionspluginhostconstructor.md} +1 -1
- package/doc/{plugin-tls.iplugin.created.md → api/plugin-tls.iplugin.created.md} +0 -0
- package/doc/{plugin-tls.iplugin.md → api/plugin-tls.iplugin.md} +0 -0
- package/doc/{plugin-tls.iplugin.used.md → api/plugin-tls.iplugin.used.md} +0 -0
- package/doc/{plugin-tls.ipluginhost.md → api/plugin-tls.ipluginhost.md} +0 -0
- package/doc/{plugin-tls.ipluginhost.use.md → api/plugin-tls.ipluginhost.use.md} +0 -0
- package/doc/{plugin-tls.ipluginhostconstructor.md → api/plugin-tls.ipluginhostconstructor.md} +0 -0
- package/doc/{plugin-tls.ipluginhostconstructor.use.md → api/plugin-tls.ipluginhostconstructor.use.md} +0 -0
- package/doc/{plugin-tls.md → api/plugin-tls.md} +0 -8
- package/doc/{plugin-tls.optionspluginhost._defaultoptions.md → api/plugin-tls.optionspluginhost._defaultoptions.md} +0 -0
- package/doc/{plugin-tls.optionspluginhost.defaultoptions.md → api/plugin-tls.optionspluginhost.defaultoptions.md} +0 -0
- package/doc/{plugin-tls.optionspluginhost.md → api/plugin-tls.optionspluginhost.md} +0 -0
- package/doc/{plugin-tls.plugincreatedreturntype.md → api/plugin-tls.plugincreatedreturntype.md} +0 -0
- package/doc/{plugin-tls.pluginhost._constructor_.md → api/plugin-tls.pluginhost._constructor_.md} +0 -0
- package/doc/{plugin-tls.pluginhost._pluginmanager.md → api/plugin-tls.pluginhost._pluginmanager.md} +0 -0
- package/doc/{plugin-tls.pluginhost.md → api/plugin-tls.pluginhost.md} +0 -0
- package/doc/{plugin-tls.pluginhost.pluginmanager.md → api/plugin-tls.pluginhost.pluginmanager.md} +0 -0
- package/doc/{plugin-tls.pluginhost.use.md → api/plugin-tls.pluginhost.use.md} +0 -0
- package/doc/{plugin-tls.pluginmanager.created.md → api/plugin-tls.pluginmanager.created.md} +0 -0
- package/doc/{plugin-tls.pluginmanager.host.md → api/plugin-tls.pluginmanager.host.md} +0 -0
- package/doc/{plugin-tls.pluginmanager.instuse.md → api/plugin-tls.pluginmanager.instuse.md} +0 -0
- package/doc/{plugin-tls.pluginmanager.md → api/plugin-tls.pluginmanager.md} +0 -0
- package/doc/{plugin-tls.pluginmanager.pluginoptsmap.md → api/plugin-tls.pluginmanager.pluginoptsmap.md} +0 -0
- package/doc/{plugin-tls.pluginmanager.plugins.md → api/plugin-tls.pluginmanager.plugins.md} +0 -0
- package/doc/{plugin-tls.pluginmanager.use.md → api/plugin-tls.pluginmanager.use.md} +0 -0
- package/doc/{plugin-tls.pluginoptions.md → api/plugin-tls.pluginoptions.md} +0 -0
- package/doc/{plugin-tls.pluginusereturntype.md → api/plugin-tls.pluginusereturntype.md} +0 -0
- package/package.json +6 -6
- package/dist/OptionsPluginHost.d.ts +0 -49
- package/dist/PluginHost.d.ts +0 -96
- package/dist/PluginManager.d.ts +0 -76
- package/dist/defaultOptions.d.ts +0 -33
- package/dist/plugin-tls.es.js +0 -170
- package/doc/plugin-tls.createoptionspluginhost.md +0 -29
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var M = (e, n, t) => n in e ? h(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
3
|
+
var i = (e, n, t) => (M(e, typeof n != "symbol" ? n + "" : n, t), t);
|
|
4
|
+
import { mixinTarget as a, extendTarget as p } from "type-tls";
|
|
5
|
+
import { deepCopy as l } from "@gby/deep-copy";
|
|
6
|
+
class g {
|
|
7
|
+
constructor() {
|
|
8
|
+
i(this, "host");
|
|
9
|
+
i(this, "pluginOptsMap", /* @__PURE__ */ new Map());
|
|
10
|
+
i(this, "plugins", []);
|
|
11
|
+
}
|
|
12
|
+
use(n, t) {
|
|
13
|
+
const s = this.pluginOptsMap;
|
|
14
|
+
if (!s.has(n))
|
|
15
|
+
return this.plugins.push(n), s.set(n, t), n.used(this.host, t);
|
|
16
|
+
}
|
|
17
|
+
created(n) {
|
|
18
|
+
var t;
|
|
19
|
+
for (const s of this.plugins) {
|
|
20
|
+
const u = this.pluginOptsMap.get(s);
|
|
21
|
+
(t = s.created) == null || t.call(s, n, u);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
instUse(n, t, s) {
|
|
25
|
+
var r;
|
|
26
|
+
if (!this.pluginOptsMap.has(t))
|
|
27
|
+
return this.use(t, s), (r = t.created) == null ? void 0 : r.call(t, n, s);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
class c {
|
|
31
|
+
static get pluginManager() {
|
|
32
|
+
let n = this._pluginManager;
|
|
33
|
+
return n || (n = new g(), n.host = this, this._pluginManager = n), n;
|
|
34
|
+
}
|
|
35
|
+
get pluginManager() {
|
|
36
|
+
return this.constructor.pluginManager;
|
|
37
|
+
}
|
|
38
|
+
static use(n, t) {
|
|
39
|
+
return this.pluginManager.use(n, t);
|
|
40
|
+
}
|
|
41
|
+
constructor() {
|
|
42
|
+
this.pluginManager.created(this);
|
|
43
|
+
}
|
|
44
|
+
use(n, t) {
|
|
45
|
+
return this.constructor.pluginManager.instUse(this, n, t);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
i(c, "_pluginManager");
|
|
49
|
+
function d() {
|
|
50
|
+
var e;
|
|
51
|
+
return e = class {
|
|
52
|
+
static get pluginManager() {
|
|
53
|
+
let t = this._pluginManager;
|
|
54
|
+
return t || (t = new g(), t.host = this, this._pluginManager = t), t;
|
|
55
|
+
}
|
|
56
|
+
get pluginManager() {
|
|
57
|
+
return this.constructor.pluginManager;
|
|
58
|
+
}
|
|
59
|
+
static use(t, s) {
|
|
60
|
+
return this.pluginManager.use(t, s);
|
|
61
|
+
}
|
|
62
|
+
constructor() {
|
|
63
|
+
this.pluginManager.created(
|
|
64
|
+
this
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
use(t, s) {
|
|
68
|
+
return this.pluginManager.instUse(this, t, s);
|
|
69
|
+
}
|
|
70
|
+
}, i(e, "_pluginManager"), e;
|
|
71
|
+
}
|
|
72
|
+
function x(e) {
|
|
73
|
+
const n = a(e, {
|
|
74
|
+
get pluginManager() {
|
|
75
|
+
let t = this._pluginManager;
|
|
76
|
+
return t || (t = new g(), t.host = this, this._pluginManager = t), t;
|
|
77
|
+
},
|
|
78
|
+
use(t, s) {
|
|
79
|
+
return this.pluginManager.use(t, s);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return a(n.prototype, {
|
|
83
|
+
get pluginManager() {
|
|
84
|
+
return this.constructor.pluginManager;
|
|
85
|
+
},
|
|
86
|
+
use(t, s) {
|
|
87
|
+
return this.pluginManager.instUse(this, t, s);
|
|
88
|
+
}
|
|
89
|
+
}), new Proxy(e, {
|
|
90
|
+
construct: function(t, s, u) {
|
|
91
|
+
const r = new t(...s);
|
|
92
|
+
return n.pluginManager.created(this), r;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
class f extends c {
|
|
97
|
+
constructor() {
|
|
98
|
+
super(...arguments);
|
|
99
|
+
i(this, "_defaultOptions");
|
|
100
|
+
}
|
|
101
|
+
get defaultOptions() {
|
|
102
|
+
return this._defaultOptions || (this._defaultOptions = l(
|
|
103
|
+
this.constructor.defaultOptions
|
|
104
|
+
));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
i(f, "defaultOptions", {});
|
|
108
|
+
function m() {
|
|
109
|
+
var n;
|
|
110
|
+
const e = d();
|
|
111
|
+
return n = class extends e {
|
|
112
|
+
constructor() {
|
|
113
|
+
super(...arguments);
|
|
114
|
+
i(this, "_defaultOptions");
|
|
115
|
+
}
|
|
116
|
+
get defaultOptions() {
|
|
117
|
+
return this._defaultOptions || (this._defaultOptions = l(
|
|
118
|
+
this.constructor.defaultOptions
|
|
119
|
+
));
|
|
120
|
+
}
|
|
121
|
+
}, i(n, "defaultOptions", {}), n;
|
|
122
|
+
}
|
|
123
|
+
function T(e, n) {
|
|
124
|
+
const t = n != null ? n : "defaultOptions", s = `_${t}`;
|
|
125
|
+
return function(r) {
|
|
126
|
+
const o = a(r, {
|
|
127
|
+
get [t]() {
|
|
128
|
+
return e;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
p(o, {
|
|
132
|
+
get [t]() {
|
|
133
|
+
return this[s] || (this[s] = structuredClone(o.defaultOptions));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function U(e, n, t) {
|
|
139
|
+
const s = `_${n}`;
|
|
140
|
+
return p(e, {
|
|
141
|
+
get [n]() {
|
|
142
|
+
return this[s] || (this[s] = structuredClone(e[n]));
|
|
143
|
+
}
|
|
144
|
+
}), t;
|
|
145
|
+
}
|
|
146
|
+
export {
|
|
147
|
+
f as OptionsPluginHost,
|
|
148
|
+
c as PluginHost,
|
|
149
|
+
g as PluginManager,
|
|
150
|
+
T as addDefaultOptions,
|
|
151
|
+
U as addInstOptions,
|
|
152
|
+
m as createOptionsPluginHost,
|
|
153
|
+
d as createPluginHost,
|
|
154
|
+
x as pluginHost
|
|
155
|
+
};
|
package/dist/plugin-tls.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,i){typeof exports=="object"&&typeof module
|
|
1
|
+
(function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("type-tls"),require("@gby/deep-copy")):typeof define=="function"&&define.amd?define(["exports","type-tls","@gby/deep-copy"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s.PluginTls={},s.typeTls,s.deepCopy))})(this,function(s,i,a){"use strict";var P=Object.defineProperty;var H=(s,i,a)=>i in s?P(s,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[i]=a;var r=(s,i,a)=>(H(s,typeof i!="symbol"?i+"":i,a),a);class o{constructor(){r(this,"host");r(this,"pluginOptsMap",new Map);r(this,"plugins",[])}use(n,t){const e=this.pluginOptsMap;if(!e.has(n))return this.plugins.push(n),e.set(n,t),n.used(this.host,t)}created(n){var t;for(const e of this.plugins){const p=this.pluginOptsMap.get(e);(t=e.created)==null||t.call(e,n,p)}}instUse(n,t,e){var g;if(!this.pluginOptsMap.has(t))return this.use(t,e),(g=t.created)==null?void 0:g.call(t,n,e)}}class l{static get pluginManager(){let n=this._pluginManager;return n||(n=new o,n.host=this,this._pluginManager=n),n}get pluginManager(){return this.constructor.pluginManager}static use(n,t){return this.pluginManager.use(n,t)}constructor(){this.pluginManager.created(this)}use(n,t){return this.constructor.pluginManager.instUse(this,n,t)}}r(l,"_pluginManager");function c(){var u;return u=class{static get pluginManager(){let t=this._pluginManager;return t||(t=new o,t.host=this,this._pluginManager=t),t}get pluginManager(){return this.constructor.pluginManager}static use(t,e){return this.pluginManager.use(t,e)}constructor(){this.pluginManager.created(this)}use(t,e){return this.pluginManager.instUse(this,t,e)}},r(u,"_pluginManager"),u}function f(u){const n=i.mixinTarget(u,{get pluginManager(){let t=this._pluginManager;return t||(t=new o,t.host=this,this._pluginManager=t),t},use(t,e){return this.pluginManager.use(t,e)}});return i.mixinTarget(n.prototype,{get pluginManager(){return this.constructor.pluginManager},use(t,e){return this.pluginManager.instUse(this,t,e)}}),new Proxy(u,{construct:function(t,e,p){const g=new t(...e);return n.pluginManager.created(this),g}})}class h extends l{constructor(){super(...arguments);r(this,"_defaultOptions")}get defaultOptions(){return this._defaultOptions||(this._defaultOptions=a.deepCopy(this.constructor.defaultOptions))}}r(h,"defaultOptions",{});function M(){var n;const u=c();return n=class extends u{constructor(){super(...arguments);r(this,"_defaultOptions")}get defaultOptions(){return this._defaultOptions||(this._defaultOptions=a.deepCopy(this.constructor.defaultOptions))}},r(n,"defaultOptions",{}),n}function O(u,n){const t=n!=null?n:"defaultOptions",e=`_${t}`;return function(g){const d=i.mixinTarget(g,{get[t](){return u}});i.extendTarget(d,{get[t](){return this[e]||(this[e]=structuredClone(d.defaultOptions))}})}}function _(u,n,t){const e=`_${n}`;return i.extendTarget(u,{get[n](){return this[e]||(this[e]=structuredClone(u[n]))}}),t}s.OptionsPluginHost=h,s.PluginHost=l,s.PluginManager=o,s.addDefaultOptions=O,s.addInstOptions=_,s.createOptionsPluginHost=M,s.createPluginHost=c,s.pluginHost=f,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.29.5"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [plugin-tls](./plugin-tls.md) > [createOptionsPluginHost](./plugin-tls.createoptionspluginhost.md)
|
|
4
|
+
|
|
5
|
+
## createOptionsPluginHost() function
|
|
6
|
+
|
|
7
|
+
创建带有选项机制的插件宿主类 比 直接使用 OptionsPluginHost 提供了完善的类型推导
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare function createOptionsPluginHost<HOST, Options>(): {
|
|
13
|
+
new (): {
|
|
14
|
+
readonly defaultOptions: Options;
|
|
15
|
+
_defaultOptions: Options;
|
|
16
|
+
readonly pluginManager: PluginManager<HOST>;
|
|
17
|
+
use<Options_1 extends unknown, Plugin_1 extends IPlugin<HOST, Options_1>>(plugin: Plugin_1, options?: Options_1 | undefined): PluginCreatedReturnType<Plugin_1> | undefined;
|
|
18
|
+
};
|
|
19
|
+
readonly defaultOptions: Options;
|
|
20
|
+
readonly pluginManager: PluginManager<HOST>;
|
|
21
|
+
_pluginManager: PluginManager<HOST>;
|
|
22
|
+
use<Options_2>(plugin: IPlugin<HOST, Options_2>, options: Options_2): any;
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
<b>Returns:</b>
|
|
26
|
+
|
|
27
|
+
{ new (): { readonly defaultOptions: Options; \_defaultOptions: Options; readonly pluginManager: [PluginManager](./plugin-tls.pluginmanager.md)<!-- --><HOST>; use<Options\_1 extends unknown, Plugin\_1 extends [IPlugin](./plugin-tls.iplugin.md)<!-- --><HOST, Options\_1>>(plugin: Plugin\_1, options?: Options\_1 \| undefined): [PluginCreatedReturnType](./plugin-tls.plugincreatedreturntype.md)<!-- --><Plugin\_1> \| undefined; }; readonly defaultOptions: Options; readonly pluginManager: [PluginManager](./plugin-tls.pluginmanager.md)<!-- --><HOST>; \_pluginManager: [PluginManager](./plugin-tls.pluginmanager.md)<!-- --><HOST>; use<Options\_2>(plugin: [IPlugin](./plugin-tls.iplugin.md)<!-- --><HOST, Options\_2>, options: Options\_2): any; }
|
|
28
|
+
|
|
29
|
+
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
export declare function createPluginHost<HOST>(): {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
new (): {
|
|
14
|
+
readonly pluginManager: PluginManager<HOST>;
|
|
15
|
+
use<Options extends unknown, Plugin_1 extends IPlugin<HOST, Options>>(plugin: Plugin_1, options?: Options | undefined): PluginCreatedReturnType<Plugin_1> | undefined;
|
|
16
|
+
};
|
|
17
|
+
readonly pluginManager: PluginManager<HOST>;
|
|
18
|
+
_pluginManager: PluginManager<HOST>;
|
|
19
|
+
use<Options_1>(plugin: IPlugin<HOST, Options_1>, options: Options_1): any;
|
|
20
20
|
};
|
|
21
21
|
```
|
|
22
22
|
<b>Returns:</b>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
```typescript
|
|
12
12
|
export interface IOptionsPluginHost<Options, HOST> extends IPluginHost<HOST>
|
|
13
13
|
```
|
|
14
|
-
<b>Extends:</b> [IPluginHost](./plugin-tls.ipluginhost.md)
|
|
14
|
+
<b>Extends:</b> [IPluginHost](./plugin-tls.ipluginhost.md)<!-- --><HOST>
|
|
15
15
|
|
|
16
16
|
## Properties
|
|
17
17
|
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
```typescript
|
|
12
12
|
export interface IOptionsPluginHostConstructor<Options, HOST> extends IPluginHostConstructor<HOST>
|
|
13
13
|
```
|
|
14
|
-
<b>Extends:</b> [IPluginHostConstructor](./plugin-tls.ipluginhostconstructor.md)
|
|
14
|
+
<b>Extends:</b> [IPluginHostConstructor](./plugin-tls.ipluginhostconstructor.md)<!-- --><HOST>
|
|
15
15
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/doc/{plugin-tls.ipluginhostconstructor.md → api/plugin-tls.ipluginhostconstructor.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/doc/{plugin-tls.plugincreatedreturntype.md → api/plugin-tls.plugincreatedreturntype.md}
RENAMED
|
File without changes
|
package/doc/{plugin-tls.pluginhost._constructor_.md → api/plugin-tls.pluginhost._constructor_.md}
RENAMED
|
File without changes
|
package/doc/{plugin-tls.pluginhost._pluginmanager.md → api/plugin-tls.pluginhost._pluginmanager.md}
RENAMED
|
File without changes
|
|
File without changes
|
package/doc/{plugin-tls.pluginhost.pluginmanager.md → api/plugin-tls.pluginhost.pluginmanager.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plugin-tls",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "plugin-tls 是插件系统相应的工具,可快速地让任何模块具备插件机制",
|
|
5
5
|
"main": "dist/plugin-tls.umd.js",
|
|
6
|
-
"module": "dist/plugin-tls.
|
|
6
|
+
"module": "dist/plugin-tls.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"homepage": "https://github.com/GuoBinyong/plugin-tls#readme",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"@microsoft/api-extractor": "^7.24.1",
|
|
40
40
|
"build-tls": "^1.3.11",
|
|
41
41
|
"dts-bundle-generator": "^6.12.0",
|
|
42
|
-
"package-tls": "^1.
|
|
42
|
+
"package-tls": "^1.3.1",
|
|
43
43
|
"typescript": "^4.5.4",
|
|
44
|
-
"vite": "^
|
|
44
|
+
"vite": "^3.0.9"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@gby/deep-copy": "^4.0.0",
|
|
48
|
-
"type-tls": "^2.
|
|
48
|
+
"type-tls": "^2.4.3"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"dev": "vite",
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"stage": "vite build --mode stage",
|
|
54
54
|
"preview": "vite preview",
|
|
55
55
|
"api": "api-extractor run -c api-extractor.jsonc -l -v",
|
|
56
|
-
"doc": "npm run api ; api-documenter markdown -i ./temp -o doc"
|
|
56
|
+
"doc": "npm run api ; api-documenter markdown -i ./temp -o doc/api"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { PluginHost, IPluginHost, IPluginHostConstructor } from "./PluginHost";
|
|
2
|
-
/**
|
|
3
|
-
* 选项插件宿主接口
|
|
4
|
-
*/
|
|
5
|
-
export interface IOptionsPluginHost<Options, HOST> extends IPluginHost<HOST> {
|
|
6
|
-
readonly defaultOptions: Options;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* 选项插件宿主的构建函数接口
|
|
10
|
-
*/
|
|
11
|
-
export interface IOptionsPluginHostConstructor<Options, HOST> extends IPluginHostConstructor<HOST> {
|
|
12
|
-
get defaultOptions(): Options;
|
|
13
|
-
}
|
|
14
|
-
export declare class OptionsPluginHost<Options = any> extends PluginHost {
|
|
15
|
-
/**
|
|
16
|
-
* 全局级别的默认选项
|
|
17
|
-
*/
|
|
18
|
-
static readonly defaultOptions: any;
|
|
19
|
-
/**
|
|
20
|
-
* 实例级的默认选项
|
|
21
|
-
*/
|
|
22
|
-
get defaultOptions(): Options;
|
|
23
|
-
protected _defaultOptions: Options;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 创建带有选项机制的插件宿主类
|
|
27
|
-
* @remakers
|
|
28
|
-
* 比 直接使用 OptionsPluginHost 提供了完善的类型推导
|
|
29
|
-
*
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
32
|
-
export declare function createOptionsPluginHost<HOST, Options>(): {
|
|
33
|
-
new (): {
|
|
34
|
-
/**
|
|
35
|
-
* 实例级的默认选项
|
|
36
|
-
*/
|
|
37
|
-
readonly defaultOptions: Options;
|
|
38
|
-
_defaultOptions: Options;
|
|
39
|
-
readonly pluginManager: import("./PluginManager").PluginManager<HOST>;
|
|
40
|
-
use<Options_1 extends unknown, Plugin_1 extends import("./PluginManager").IPlugin<HOST, Options_1>>(plugin: Plugin_1, options?: Options_1 | undefined): import("./PluginManager").PluginCreatedReturnType<Plugin_1> | undefined;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* 全局级别的默认选项
|
|
44
|
-
*/
|
|
45
|
-
readonly defaultOptions: Options;
|
|
46
|
-
readonly pluginManager: import("./PluginManager").PluginManager<HOST>;
|
|
47
|
-
_pluginManager: import("./PluginManager").PluginManager<HOST>;
|
|
48
|
-
use<Options_2>(plugin: import("./PluginManager").IPlugin<HOST, Options_2>, options: Options_2): any;
|
|
49
|
-
};
|
package/dist/PluginHost.d.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { PluginManager, IPlugin, PluginOptions, PluginCreatedReturnType, PluginUseReturnType } from "./PluginManager";
|
|
2
|
-
/**
|
|
3
|
-
* 插件宿主的接口
|
|
4
|
-
*/
|
|
5
|
-
export interface IPluginHost<HOST> {
|
|
6
|
-
/**
|
|
7
|
-
* PluginHost 的插件管理器
|
|
8
|
-
*/
|
|
9
|
-
get pluginManager(): PluginManager<HOST>;
|
|
10
|
-
/**
|
|
11
|
-
* 实例的注册插件的方法
|
|
12
|
-
* @param plugin
|
|
13
|
-
* @param options
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
use<Options extends PluginOptions, Plugin extends IPlugin<HOST, Options>>(plugin: Plugin, options?: Options): PluginCreatedReturnType<Plugin> | undefined;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* 插件宿主构造函数的接口
|
|
20
|
-
*/
|
|
21
|
-
export interface IPluginHostConstructor<HOST> {
|
|
22
|
-
/**
|
|
23
|
-
* PluginHost 的插件管理器
|
|
24
|
-
*/
|
|
25
|
-
get pluginManager(): PluginManager<HOST>;
|
|
26
|
-
/**
|
|
27
|
-
* {@inheritDoc PluginManager.use}
|
|
28
|
-
*/
|
|
29
|
-
use<Plugin extends IPlugin<HOST, Options>, Options>(plugin: Plugin, options: Options): PluginUseReturnType<Plugin> | undefined;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* 插件的宿主
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* 插件宿主 就是 拥有插件机制的宿主
|
|
36
|
-
*/
|
|
37
|
-
export declare class PluginHost {
|
|
38
|
-
/**
|
|
39
|
-
* 插件管理器
|
|
40
|
-
*/
|
|
41
|
-
static get pluginManager(): PluginManager<any>;
|
|
42
|
-
static _pluginManager: PluginManager<any>;
|
|
43
|
-
/**
|
|
44
|
-
* 插件管理器 {@link PluginHost.pluginManager}
|
|
45
|
-
*/
|
|
46
|
-
get pluginManager(): PluginManager<any>;
|
|
47
|
-
/**
|
|
48
|
-
* {@inheritDoc PluginManager.use}
|
|
49
|
-
*/
|
|
50
|
-
static use<Plugin extends IPlugin<HOST, Options>, Options extends PluginOptions, HOST = typeof PluginHost>(plugin: Plugin, options: Options): ReturnType<Plugin["used"]> | undefined;
|
|
51
|
-
constructor();
|
|
52
|
-
/**
|
|
53
|
-
* 实例的注册插件的方法
|
|
54
|
-
* @param plugin
|
|
55
|
-
* @param options
|
|
56
|
-
* @returns
|
|
57
|
-
*/
|
|
58
|
-
use<Options extends PluginOptions, Plugin extends IPlugin<typeof PluginHost, Options>>(plugin: Plugin, options?: Options): PluginCreatedReturnType<Plugin> | undefined;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* 创建插件的缩主类
|
|
62
|
-
*
|
|
63
|
-
* @remarks
|
|
64
|
-
* 比 直接使用 PluginHost 提供了完善的类型推导
|
|
65
|
-
* @returns
|
|
66
|
-
*/
|
|
67
|
-
export declare function createPluginHost<HOST>(): {
|
|
68
|
-
new (): {
|
|
69
|
-
/**
|
|
70
|
-
* 插件管理器 {@link CEarth.pluginManager}
|
|
71
|
-
*/
|
|
72
|
-
readonly pluginManager: PluginManager<HOST>;
|
|
73
|
-
/**
|
|
74
|
-
* 实例的注册插件的方法
|
|
75
|
-
* @param plugin
|
|
76
|
-
* @param options
|
|
77
|
-
* @returns
|
|
78
|
-
*/
|
|
79
|
-
use<Options extends unknown, Plugin_1 extends IPlugin<HOST, Options>>(plugin: Plugin_1, options?: Options | undefined): PluginCreatedReturnType<Plugin_1> | undefined;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* PluginHost 的插件管理器
|
|
83
|
-
*/
|
|
84
|
-
readonly pluginManager: PluginManager<HOST>;
|
|
85
|
-
_pluginManager: PluginManager<HOST>;
|
|
86
|
-
/**
|
|
87
|
-
* {@inheritDoc PluginManager.use}
|
|
88
|
-
*/
|
|
89
|
-
use<Options_1>(plugin: IPlugin<HOST, Options_1>, options: Options_1): any;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* 插件缩主类的装饰器
|
|
93
|
-
* @param target
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
export declare function pluginHost<HOST extends new (...args: any) => any>(target: HOST): HOST;
|
package/dist/PluginManager.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AnyFunction } from "type-tls";
|
|
2
|
-
/**
|
|
3
|
-
* 插件宿主的实例类型
|
|
4
|
-
*/
|
|
5
|
-
export declare type HostInst<H> = H extends new (...args: any) => any ? InstanceType<H> : H;
|
|
6
|
-
/**
|
|
7
|
-
* 插件的接口
|
|
8
|
-
*
|
|
9
|
-
* @typeParam HOST - 插件宿主的类类型
|
|
10
|
-
* @typeParam Options - 插件的选项类型
|
|
11
|
-
*/
|
|
12
|
-
export interface IPlugin<HOST, Options = any> {
|
|
13
|
-
/**
|
|
14
|
-
* 当插件被注册时调用
|
|
15
|
-
* @param Host - 宿主的类型
|
|
16
|
-
* @param options - 注册插件时的选项
|
|
17
|
-
*/
|
|
18
|
-
used(Host: HOST, options?: Options): any;
|
|
19
|
-
/**
|
|
20
|
-
* 当宿主实例被创建时调用
|
|
21
|
-
* @param host - 新建的宿主实例
|
|
22
|
-
* @param options - 注册插件时的选项
|
|
23
|
-
*/
|
|
24
|
-
created?(host: HostInst<HOST>, options?: Options): any;
|
|
25
|
-
}
|
|
26
|
-
export declare type PluginOptions = any;
|
|
27
|
-
/**
|
|
28
|
-
* 插件的 used 方法的返回值类型
|
|
29
|
-
*/
|
|
30
|
-
export declare type PluginUseReturnType<P extends IPlugin<any>> = ReturnType<P["used"]>;
|
|
31
|
-
/**
|
|
32
|
-
* 插件的 created 方法的返回值类型
|
|
33
|
-
*/
|
|
34
|
-
export declare type PluginCreatedReturnType<P extends IPlugin<any>> = P["created"] extends AnyFunction ? ReturnType<P["created"]> : void;
|
|
35
|
-
/**
|
|
36
|
-
* 插件管理者
|
|
37
|
-
*
|
|
38
|
-
* @remarks
|
|
39
|
-
* 负责管理插件的注册、应用 等
|
|
40
|
-
*/
|
|
41
|
-
export declare class PluginManager<HOST> {
|
|
42
|
-
/**
|
|
43
|
-
* 插件的宿主
|
|
44
|
-
*/
|
|
45
|
-
host: HOST;
|
|
46
|
-
/**
|
|
47
|
-
* 插件与插件选项的映射
|
|
48
|
-
*/
|
|
49
|
-
pluginOptsMap: Map<IPlugin<HOST, any>, any>;
|
|
50
|
-
/**
|
|
51
|
-
* 注册的插件
|
|
52
|
-
*/
|
|
53
|
-
plugins: IPlugin<HOST>[];
|
|
54
|
-
/**
|
|
55
|
-
* 使用插件、注册插件
|
|
56
|
-
* @param plugin - 插件
|
|
57
|
-
* @param options - 传递给插件的选项
|
|
58
|
-
*/
|
|
59
|
-
use<Options extends PluginOptions, Plugin extends IPlugin<HOST, Options>>(plugin: Plugin, options?: Options): PluginUseReturnType<Plugin> | undefined;
|
|
60
|
-
/**
|
|
61
|
-
* 插件宿主创建实例时调用
|
|
62
|
-
*
|
|
63
|
-
* @remarks
|
|
64
|
-
* 会调用每个插件的 {@link IPlugin.created | IPlugin.created()} 方法
|
|
65
|
-
* @param hostInst - 插件宿主的新实例
|
|
66
|
-
*/
|
|
67
|
-
created(hostInst: HostInst<HOST>): void;
|
|
68
|
-
/**
|
|
69
|
-
* 插件宿主实例的注册插件的方法
|
|
70
|
-
*
|
|
71
|
-
* @remarks
|
|
72
|
-
* 会调用每个插件的 {@link IPlugin.created | IPlugin.created()} 方法
|
|
73
|
-
* @param hostInst - 插件宿主的新实例
|
|
74
|
-
*/
|
|
75
|
-
instUse<Options extends PluginOptions, Plugin extends IPlugin<HOST, Options>>(hostInst: HostInst<HOST>, plugin: Plugin, options?: Options): PluginCreatedReturnType<Plugin> | undefined;
|
|
76
|
-
}
|
package/dist/defaultOptions.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Optional } from "type-tls";
|
|
2
|
-
/**
|
|
3
|
-
* 默认选项宿主接口
|
|
4
|
-
*/
|
|
5
|
-
export interface IDefaultOptionsHost<Options> {
|
|
6
|
-
readonly defaultOptions: Options;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* 默认选项宿主的构建函数接口
|
|
10
|
-
*/
|
|
11
|
-
export interface IIDefaultOptionsHostConstructor<Options> {
|
|
12
|
-
get defaultOptions(): Options;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* 创建增加带有选项机制的装饰器
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* 类装饰器的工厂函数
|
|
19
|
-
*
|
|
20
|
-
* @param options - 选项内容
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
export declare function addDefaultOptions<Options>(options: Options, name?: Optional<string>): <Clas extends new (...args: any) => any>(target: Clas) => void;
|
|
24
|
-
/**
|
|
25
|
-
* 创建增加带有选项机制的装饰器
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* 静态属性装饰器
|
|
29
|
-
*
|
|
30
|
-
* @param options - 选项内容
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
export declare function addInstOptions<Clas extends new (...args: any) => any>(target: Clas, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
|