phecda-core 5.1.1 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -6
- package/dist/index.mjs +26 -6
- package/package.json +1 -1
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
|
}
|
|
@@ -287,8 +289,26 @@ __name(isAsyncFunc, "isAsyncFunc");
|
|
|
287
289
|
function invoke(instance, key, ...params) {
|
|
288
290
|
const metaKeys = getMetaKey(instance);
|
|
289
291
|
return Promise.allSettled(metaKeys.map((k) => {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
+
const names = [];
|
|
293
|
+
const meta = getMeta(instance, k);
|
|
294
|
+
return meta.filter((item) => {
|
|
295
|
+
if (item.__NAME__) {
|
|
296
|
+
if (names.includes(item.__NAME__)) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
names.push(item.__NAME__);
|
|
300
|
+
return true;
|
|
301
|
+
} else {
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}).flat().filter((item) => {
|
|
306
|
+
if (typeof item[key] === "function") {
|
|
307
|
+
return true;
|
|
308
|
+
} else {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}).map((item) => item[key](instance, ...params))).then((res) => {
|
|
292
312
|
res.filter((item) => item.status === "rejected").forEach((item) => {
|
|
293
313
|
console.error(item.reason);
|
|
294
314
|
});
|
|
@@ -434,7 +454,7 @@ function partial(classFn, ...properties) {
|
|
|
434
454
|
return newClass;
|
|
435
455
|
}
|
|
436
456
|
__name(partial, "partial");
|
|
437
|
-
function override(classFn, ...
|
|
457
|
+
function override(classFn, ..._properties) {
|
|
438
458
|
return classFn;
|
|
439
459
|
}
|
|
440
460
|
__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
|
}
|
|
@@ -200,8 +202,26 @@ __name(isAsyncFunc, "isAsyncFunc");
|
|
|
200
202
|
function invoke(instance, key, ...params) {
|
|
201
203
|
const metaKeys = getMetaKey(instance);
|
|
202
204
|
return Promise.allSettled(metaKeys.map((k) => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
const names = [];
|
|
206
|
+
const meta = getMeta(instance, k);
|
|
207
|
+
return meta.filter((item) => {
|
|
208
|
+
if (item.__NAME__) {
|
|
209
|
+
if (names.includes(item.__NAME__)) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
names.push(item.__NAME__);
|
|
213
|
+
return true;
|
|
214
|
+
} else {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}).flat().filter((item) => {
|
|
219
|
+
if (typeof item[key] === "function") {
|
|
220
|
+
return true;
|
|
221
|
+
} else {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}).map((item) => item[key](instance, ...params))).then((res) => {
|
|
205
225
|
res.filter((item) => item.status === "rejected").forEach((item) => {
|
|
206
226
|
console.error(item.reason);
|
|
207
227
|
});
|
|
@@ -347,7 +367,7 @@ function partial(classFn, ...properties) {
|
|
|
347
367
|
return newClass;
|
|
348
368
|
}
|
|
349
369
|
__name(partial, "partial");
|
|
350
|
-
function override(classFn, ...
|
|
370
|
+
function override(classFn, ..._properties) {
|
|
351
371
|
return classFn;
|
|
352
372
|
}
|
|
353
373
|
__name(override, "override");
|