phecda-core 1.3.0 → 1.4.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.ts +5 -4
- package/dist/index.global.js +17 -0
- package/dist/index.js +18 -0
- package/dist/index.mjs +17 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface NameSpace {
|
|
2
2
|
[name: string]: Phecda;
|
|
3
3
|
}
|
|
4
4
|
interface UsePipeOptions {
|
|
@@ -21,7 +21,7 @@ interface Phecda {
|
|
|
21
21
|
type ClassValue<I> = {
|
|
22
22
|
[P in keyof I]: I[P] extends Function ? undefined : I[P];
|
|
23
23
|
};
|
|
24
|
-
interface
|
|
24
|
+
interface Events {
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
declare function plainToClass<M extends new (...args: any) => any, Data extends Record<PropertyKey, any>>(Model: M, input: Data, options?: UsePipeOptions): Promise<{
|
|
@@ -78,6 +78,7 @@ declare function Err<Fn extends (...args: any) => any>(cb: Fn): (target: any, ke
|
|
|
78
78
|
declare function P(target: any, key: PropertyKey): void;
|
|
79
79
|
declare function Pipe(v: ReturnType<typeof to>): (obj: any, key: PropertyKey) => void;
|
|
80
80
|
declare function Tag(tag: string): (target: any) => void;
|
|
81
|
+
declare function Assign(cb: (instance?: any) => any): (target: any) => void;
|
|
81
82
|
declare function Global(target: any): void;
|
|
82
83
|
|
|
83
84
|
declare function validate(p: RegExp | string | Function | Object | Number, v: any): Promise<any>;
|
|
@@ -105,9 +106,9 @@ declare const activeInstance: Record<string, any>;
|
|
|
105
106
|
declare function injectProperty(key: string, value: any): Record<string, any>;
|
|
106
107
|
declare function getProperty(key: string): any;
|
|
107
108
|
|
|
108
|
-
declare function Watcher(eventName: keyof
|
|
109
|
+
declare function Watcher(eventName: keyof Events, options?: {
|
|
109
110
|
once: boolean;
|
|
110
111
|
}): (obj: any, key: string) => void;
|
|
111
112
|
declare function Storage(storeKey?: string): (target: any, key?: PropertyKey) => void;
|
|
112
113
|
|
|
113
|
-
export { ClassValue, Clear, Err, Global, Ignore, Init, P, Phecda,
|
|
114
|
+
export { Assign, ClassValue, Clear, Err, Events, Global, Ignore, Init, NameSpace, P, Phecda, PhecdaHandler, Pipe, Rule, Storage, Tag, UsePipeOptions, Watcher, activeInstance, addDecoToClass, classToValue, getExposeKey, getHandler, getIgnoreKey, getInitEvent, getModelState, getProperty, getState, getTag, init, injectProperty, isPhecda, mergeOptions, mergeState, plainToClass, regisHandler, regisInitEvent, register, registerAsync, setExposeKey, setIgnoreKey, setModalVar, snapShot, to, validate };
|
package/dist/index.global.js
CHANGED
|
@@ -22,6 +22,7 @@ var Phecda = (() => {
|
|
|
22
22
|
// src/index.ts
|
|
23
23
|
var src_exports = {};
|
|
24
24
|
__export(src_exports, {
|
|
25
|
+
Assign: () => Assign,
|
|
25
26
|
Clear: () => Clear,
|
|
26
27
|
Err: () => Err,
|
|
27
28
|
Global: () => Global,
|
|
@@ -282,6 +283,22 @@ var Phecda = (() => {
|
|
|
282
283
|
};
|
|
283
284
|
}
|
|
284
285
|
__name(Tag, "Tag");
|
|
286
|
+
function Assign(cb) {
|
|
287
|
+
return (target) => {
|
|
288
|
+
init(target.prototype);
|
|
289
|
+
setModalVar(target.prototype, "__CLASS");
|
|
290
|
+
regisHandler(target.prototype, "__CLASS", {
|
|
291
|
+
init: async (instance) => {
|
|
292
|
+
const value = await cb(instance);
|
|
293
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
294
|
+
for (const i in value)
|
|
295
|
+
instance[i] = value[i];
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
__name(Assign, "Assign");
|
|
285
302
|
function Global(target) {
|
|
286
303
|
if (!globalThis.__PHECDA__)
|
|
287
304
|
globalThis.__PHECDA__ = {};
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var src_exports = {};
|
|
23
23
|
__export(src_exports, {
|
|
24
|
+
Assign: () => Assign,
|
|
24
25
|
Clear: () => Clear,
|
|
25
26
|
Err: () => Err,
|
|
26
27
|
Global: () => Global,
|
|
@@ -282,6 +283,22 @@ function Tag(tag) {
|
|
|
282
283
|
};
|
|
283
284
|
}
|
|
284
285
|
__name(Tag, "Tag");
|
|
286
|
+
function Assign(cb) {
|
|
287
|
+
return (target) => {
|
|
288
|
+
init(target.prototype);
|
|
289
|
+
setModalVar(target.prototype, "__CLASS");
|
|
290
|
+
regisHandler(target.prototype, "__CLASS", {
|
|
291
|
+
init: async (instance) => {
|
|
292
|
+
const value = await cb(instance);
|
|
293
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
294
|
+
for (const i in value)
|
|
295
|
+
instance[i] = value[i];
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
__name(Assign, "Assign");
|
|
285
302
|
function Global(target) {
|
|
286
303
|
if (!globalThis.__PHECDA__)
|
|
287
304
|
globalThis.__PHECDA__ = {};
|
|
@@ -432,6 +449,7 @@ function Storage(storeKey) {
|
|
|
432
449
|
__name(Storage, "Storage");
|
|
433
450
|
// Annotate the CommonJS export names for ESM import in node:
|
|
434
451
|
0 && (module.exports = {
|
|
452
|
+
Assign,
|
|
435
453
|
Clear,
|
|
436
454
|
Err,
|
|
437
455
|
Global,
|
package/dist/index.mjs
CHANGED
|
@@ -221,6 +221,22 @@ function Tag(tag) {
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
__name(Tag, "Tag");
|
|
224
|
+
function Assign(cb) {
|
|
225
|
+
return (target) => {
|
|
226
|
+
init(target.prototype);
|
|
227
|
+
setModalVar(target.prototype, "__CLASS");
|
|
228
|
+
regisHandler(target.prototype, "__CLASS", {
|
|
229
|
+
init: async (instance) => {
|
|
230
|
+
const value = await cb(instance);
|
|
231
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
232
|
+
for (const i in value)
|
|
233
|
+
instance[i] = value[i];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
__name(Assign, "Assign");
|
|
224
240
|
function Global(target) {
|
|
225
241
|
if (!globalThis.__PHECDA__)
|
|
226
242
|
globalThis.__PHECDA__ = {};
|
|
@@ -370,6 +386,7 @@ function Storage(storeKey) {
|
|
|
370
386
|
}
|
|
371
387
|
__name(Storage, "Storage");
|
|
372
388
|
export {
|
|
389
|
+
Assign,
|
|
373
390
|
Clear,
|
|
374
391
|
Err,
|
|
375
392
|
Global,
|