phecda-core 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.
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +22 -5
- package/dist/index.mjs +22 -5
- package/package.json +15 -2
package/dist/index.d.mts
CHANGED
|
@@ -110,7 +110,7 @@ declare function isAsyncFunc(fn: Function): boolean;
|
|
|
110
110
|
declare function invoke(instance: any, key: string, ...params: any): Promise<PromiseSettledResult<any>[]>;
|
|
111
111
|
declare function invokeInit(instance: any): Promise<PromiseSettledResult<any>[]>;
|
|
112
112
|
declare function invokeUnmount(instance: any): Promise<PromiseSettledResult<any>[]>;
|
|
113
|
-
declare function If(value: Boolean, ...decorators:
|
|
113
|
+
declare function If(value: Boolean, ...decorators: ClassDecorator[] | PropertyDecorator[] | ParameterDecorator[]): (...args: any[]) => void;
|
|
114
114
|
declare function getMergedMeta(target: any, property?: PropertyKey, index?: number, merger?: (prev: any, cur: any) => any): any;
|
|
115
115
|
declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
|
|
116
116
|
declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new () => Obj;
|
|
@@ -119,7 +119,7 @@ declare function omit<Class extends Construct, Key extends keyof InstanceType<Cl
|
|
|
119
119
|
declare function pick<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Pick<InstanceType<Class>, Key>>;
|
|
120
120
|
declare function partial<Class extends Construct>(classFn: Class): Construct<Partial<InstanceType<Class>>>;
|
|
121
121
|
declare function partial<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Partial<Pick<InstanceType<Class>, Key>> & Omit<InstanceType<Class>, Key>>;
|
|
122
|
-
declare function override<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...
|
|
122
|
+
declare function override<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ..._properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
123
123
|
|
|
124
124
|
declare const DataMap: InjectData;
|
|
125
125
|
declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ declare function isAsyncFunc(fn: Function): boolean;
|
|
|
110
110
|
declare function invoke(instance: any, key: string, ...params: any): Promise<PromiseSettledResult<any>[]>;
|
|
111
111
|
declare function invokeInit(instance: any): Promise<PromiseSettledResult<any>[]>;
|
|
112
112
|
declare function invokeUnmount(instance: any): Promise<PromiseSettledResult<any>[]>;
|
|
113
|
-
declare function If(value: Boolean, ...decorators:
|
|
113
|
+
declare function If(value: Boolean, ...decorators: ClassDecorator[] | PropertyDecorator[] | ParameterDecorator[]): (...args: any[]) => void;
|
|
114
114
|
declare function getMergedMeta(target: any, property?: PropertyKey, index?: number, merger?: (prev: any, cur: any) => any): any;
|
|
115
115
|
declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
|
|
116
116
|
declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new () => Obj;
|
|
@@ -119,7 +119,7 @@ declare function omit<Class extends Construct, Key extends keyof InstanceType<Cl
|
|
|
119
119
|
declare function pick<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Pick<InstanceType<Class>, Key>>;
|
|
120
120
|
declare function partial<Class extends Construct>(classFn: Class): Construct<Partial<InstanceType<Class>>>;
|
|
121
121
|
declare function partial<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Partial<Pick<InstanceType<Class>, Key>> & Omit<InstanceType<Class>, Key>>;
|
|
122
|
-
declare function override<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...
|
|
122
|
+
declare function override<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ..._properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
123
123
|
|
|
124
124
|
declare const DataMap: InjectData;
|
|
125
125
|
declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
|
package/dist/index.js
CHANGED
|
@@ -92,9 +92,9 @@ module.exports = __toCommonJS(index_exports);
|
|
|
92
92
|
__reExport(index_exports, require("reflect-metadata"), module.exports);
|
|
93
93
|
|
|
94
94
|
// src/core.ts
|
|
95
|
-
var SHARE_KEY = Symbol("phecda[share]");
|
|
96
|
-
var CLEAR_KEY = Symbol("phecda[clear]");
|
|
97
|
-
var PHECDA_KEY = Symbol("phecda");
|
|
95
|
+
var SHARE_KEY = /* @__PURE__ */ Symbol("phecda[share]");
|
|
96
|
+
var CLEAR_KEY = /* @__PURE__ */ Symbol("phecda[clear]");
|
|
97
|
+
var PHECDA_KEY = /* @__PURE__ */ Symbol("phecda");
|
|
98
98
|
function isPhecda(model) {
|
|
99
99
|
if (typeof model === "function") return !!model.prototype[PHECDA_KEY];
|
|
100
100
|
return false;
|
|
@@ -231,6 +231,7 @@ __name(get, "get");
|
|
|
231
231
|
// src/decorators/core.ts
|
|
232
232
|
function Init(proto, property) {
|
|
233
233
|
setMeta(proto, property, void 0, {
|
|
234
|
+
__NAME__: "Init",
|
|
234
235
|
async init(instance) {
|
|
235
236
|
return instance[property]();
|
|
236
237
|
}
|
|
@@ -239,6 +240,7 @@ function Init(proto, property) {
|
|
|
239
240
|
__name(Init, "Init");
|
|
240
241
|
function Unmount(proto, property) {
|
|
241
242
|
setMeta(proto, property, void 0, {
|
|
243
|
+
__NAME__: "Unmount",
|
|
242
244
|
async unmount(instance) {
|
|
243
245
|
return instance[property]();
|
|
244
246
|
}
|
|
@@ -286,9 +288,24 @@ function isAsyncFunc(fn) {
|
|
|
286
288
|
__name(isAsyncFunc, "isAsyncFunc");
|
|
287
289
|
function invoke(instance, key, ...params) {
|
|
288
290
|
const metaKeys = getMetaKey(instance);
|
|
291
|
+
const names = [];
|
|
289
292
|
return Promise.allSettled(metaKeys.map((k) => {
|
|
290
293
|
return getMeta(instance, k);
|
|
291
|
-
}).flat().filter((item) =>
|
|
294
|
+
}).flat().filter((item) => {
|
|
295
|
+
if (typeof item[key] === "function") {
|
|
296
|
+
if (item.__NAME__) {
|
|
297
|
+
if (names.includes(item.__NAME__)) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
names.push(item.__NAME__);
|
|
301
|
+
return true;
|
|
302
|
+
} else {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
}).map((item) => item[key](instance, ...params))).then((res) => {
|
|
292
309
|
res.filter((item) => item.status === "rejected").forEach((item) => {
|
|
293
310
|
console.error(item.reason);
|
|
294
311
|
});
|
|
@@ -434,7 +451,7 @@ function partial(classFn, ...properties) {
|
|
|
434
451
|
return newClass;
|
|
435
452
|
}
|
|
436
453
|
__name(partial, "partial");
|
|
437
|
-
function override(classFn, ...
|
|
454
|
+
function override(classFn, ..._properties) {
|
|
438
455
|
return classFn;
|
|
439
456
|
}
|
|
440
457
|
__name(override, "override");
|
package/dist/index.mjs
CHANGED
|
@@ -5,9 +5,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
5
5
|
export * from "reflect-metadata";
|
|
6
6
|
|
|
7
7
|
// src/core.ts
|
|
8
|
-
var SHARE_KEY = Symbol("phecda[share]");
|
|
9
|
-
var CLEAR_KEY = Symbol("phecda[clear]");
|
|
10
|
-
var PHECDA_KEY = Symbol("phecda");
|
|
8
|
+
var SHARE_KEY = /* @__PURE__ */ Symbol("phecda[share]");
|
|
9
|
+
var CLEAR_KEY = /* @__PURE__ */ Symbol("phecda[clear]");
|
|
10
|
+
var PHECDA_KEY = /* @__PURE__ */ Symbol("phecda");
|
|
11
11
|
function isPhecda(model) {
|
|
12
12
|
if (typeof model === "function") return !!model.prototype[PHECDA_KEY];
|
|
13
13
|
return false;
|
|
@@ -144,6 +144,7 @@ __name(get, "get");
|
|
|
144
144
|
// src/decorators/core.ts
|
|
145
145
|
function Init(proto, property) {
|
|
146
146
|
setMeta(proto, property, void 0, {
|
|
147
|
+
__NAME__: "Init",
|
|
147
148
|
async init(instance) {
|
|
148
149
|
return instance[property]();
|
|
149
150
|
}
|
|
@@ -152,6 +153,7 @@ function Init(proto, property) {
|
|
|
152
153
|
__name(Init, "Init");
|
|
153
154
|
function Unmount(proto, property) {
|
|
154
155
|
setMeta(proto, property, void 0, {
|
|
156
|
+
__NAME__: "Unmount",
|
|
155
157
|
async unmount(instance) {
|
|
156
158
|
return instance[property]();
|
|
157
159
|
}
|
|
@@ -199,9 +201,24 @@ function isAsyncFunc(fn) {
|
|
|
199
201
|
__name(isAsyncFunc, "isAsyncFunc");
|
|
200
202
|
function invoke(instance, key, ...params) {
|
|
201
203
|
const metaKeys = getMetaKey(instance);
|
|
204
|
+
const names = [];
|
|
202
205
|
return Promise.allSettled(metaKeys.map((k) => {
|
|
203
206
|
return getMeta(instance, k);
|
|
204
|
-
}).flat().filter((item) =>
|
|
207
|
+
}).flat().filter((item) => {
|
|
208
|
+
if (typeof item[key] === "function") {
|
|
209
|
+
if (item.__NAME__) {
|
|
210
|
+
if (names.includes(item.__NAME__)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
names.push(item.__NAME__);
|
|
214
|
+
return true;
|
|
215
|
+
} else {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
}).map((item) => item[key](instance, ...params))).then((res) => {
|
|
205
222
|
res.filter((item) => item.status === "rejected").forEach((item) => {
|
|
206
223
|
console.error(item.reason);
|
|
207
224
|
});
|
|
@@ -347,7 +364,7 @@ function partial(classFn, ...properties) {
|
|
|
347
364
|
return newClass;
|
|
348
365
|
}
|
|
349
366
|
__name(partial, "partial");
|
|
350
|
-
function override(classFn, ...
|
|
367
|
+
function override(classFn, ..._properties) {
|
|
351
368
|
return classFn;
|
|
352
369
|
}
|
|
353
370
|
__name(override, "override");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "provide base function and abstract limit to other phecda module ",
|
|
5
5
|
"author": "fgsreally",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,14 +9,27 @@
|
|
|
9
9
|
"phecda",
|
|
10
10
|
"core"
|
|
11
11
|
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
|
+
"import": "./dist/index.mjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
12
18
|
"main": "dist/index.js",
|
|
13
19
|
"module": "dist/index.mjs",
|
|
14
20
|
"types": "dist/index.d.ts",
|
|
21
|
+
"typesVersions": {
|
|
22
|
+
"*": {
|
|
23
|
+
".": [
|
|
24
|
+
"dist/index.d.ts"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
15
28
|
"files": [
|
|
16
29
|
"dist"
|
|
17
30
|
],
|
|
18
31
|
"devDependencies": {
|
|
19
|
-
"tsup": "^8.
|
|
32
|
+
"tsup": "^8.5.0"
|
|
20
33
|
},
|
|
21
34
|
"dependencies": {
|
|
22
35
|
"reflect-metadata": "^0.1.14"
|