phecda-core 1.4.0 → 1.5.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 +4 -2
- package/dist/index.global.js +26 -3
- package/dist/index.js +29 -4
- package/dist/index.mjs +26 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ type ClassValue<I> = {
|
|
|
24
24
|
interface Events {
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
declare function getBind<M extends new (...args: any) => any>(Model: M): any;
|
|
27
28
|
declare function plainToClass<M extends new (...args: any) => any, Data extends Record<PropertyKey, any>>(Model: M, input: Data, options?: UsePipeOptions): Promise<{
|
|
28
29
|
err: string[];
|
|
29
30
|
data: InstanceType<M>;
|
|
@@ -71,11 +72,12 @@ declare function snapShot<T extends new (...args: any) => any>(data: InstanceTyp
|
|
|
71
72
|
declare function addDecoToClass<M extends new (...args: any) => any>(c: M, key: keyof InstanceType<M> | string, handler: ((target: any, key: PropertyKey) => void), type?: 'static' | 'class' | 'normal'): void;
|
|
72
73
|
|
|
73
74
|
declare function Init(target: any, key: PropertyKey): void;
|
|
75
|
+
declare function Bind(value: any): (target: any, k: PropertyKey) => void;
|
|
74
76
|
declare function Rule(rule: RegExp | string | Function | number, info: string, meta?: any): (obj: any, key: PropertyKey) => void;
|
|
75
77
|
declare function Ignore(target: any, key: PropertyKey): void;
|
|
76
78
|
declare function Clear(target: any, key: PropertyKey): void;
|
|
77
79
|
declare function Err<Fn extends (...args: any) => any>(cb: Fn): (target: any, key: PropertyKey) => void;
|
|
78
|
-
declare function
|
|
80
|
+
declare function Expose(target: any, key: PropertyKey): void;
|
|
79
81
|
declare function Pipe(v: ReturnType<typeof to>): (obj: any, key: PropertyKey) => void;
|
|
80
82
|
declare function Tag(tag: string): (target: any) => void;
|
|
81
83
|
declare function Assign(cb: (instance?: any) => any): (target: any) => void;
|
|
@@ -111,4 +113,4 @@ declare function Watcher(eventName: keyof Events, options?: {
|
|
|
111
113
|
}): (obj: any, key: string) => void;
|
|
112
114
|
declare function Storage(storeKey?: string): (target: any, key?: PropertyKey) => void;
|
|
113
115
|
|
|
114
|
-
export { Assign, ClassValue, Clear, Err, Events, Global, Ignore, Init, NameSpace,
|
|
116
|
+
export { Assign, Bind, ClassValue, Clear, Err, Events, Expose, Global, Ignore, Init, NameSpace, Phecda, PhecdaHandler, Pipe, Rule, Storage, Tag, UsePipeOptions, Watcher, activeInstance, addDecoToClass, classToValue, getBind, 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
|
@@ -23,12 +23,13 @@ var Phecda = (() => {
|
|
|
23
23
|
var src_exports = {};
|
|
24
24
|
__export(src_exports, {
|
|
25
25
|
Assign: () => Assign,
|
|
26
|
+
Bind: () => Bind,
|
|
26
27
|
Clear: () => Clear,
|
|
27
28
|
Err: () => Err,
|
|
29
|
+
Expose: () => Expose,
|
|
28
30
|
Global: () => Global,
|
|
29
31
|
Ignore: () => Ignore,
|
|
30
32
|
Init: () => Init,
|
|
31
|
-
P: () => P,
|
|
32
33
|
Pipe: () => Pipe,
|
|
33
34
|
Rule: () => Rule,
|
|
34
35
|
Storage: () => Storage,
|
|
@@ -37,6 +38,7 @@ var Phecda = (() => {
|
|
|
37
38
|
activeInstance: () => activeInstance,
|
|
38
39
|
addDecoToClass: () => addDecoToClass,
|
|
39
40
|
classToValue: () => classToValue,
|
|
41
|
+
getBind: () => getBind,
|
|
40
42
|
getExposeKey: () => getExposeKey,
|
|
41
43
|
getHandler: () => getHandler,
|
|
42
44
|
getIgnoreKey: () => getIgnoreKey,
|
|
@@ -226,6 +228,15 @@ var Phecda = (() => {
|
|
|
226
228
|
});
|
|
227
229
|
}
|
|
228
230
|
__name(Init, "Init");
|
|
231
|
+
function Bind(value) {
|
|
232
|
+
return (target, k) => {
|
|
233
|
+
setModalVar(target, k);
|
|
234
|
+
mergeState(target, k, {
|
|
235
|
+
value
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
__name(Bind, "Bind");
|
|
229
240
|
function Rule(rule, info, meta) {
|
|
230
241
|
return (obj, key) => {
|
|
231
242
|
setModalVar(obj, key);
|
|
@@ -260,10 +271,10 @@ var Phecda = (() => {
|
|
|
260
271
|
};
|
|
261
272
|
}
|
|
262
273
|
__name(Err, "Err");
|
|
263
|
-
function
|
|
274
|
+
function Expose(target, key) {
|
|
264
275
|
setExposeKey(target, key);
|
|
265
276
|
}
|
|
266
|
-
__name(
|
|
277
|
+
__name(Expose, "Expose");
|
|
267
278
|
function Pipe(v) {
|
|
268
279
|
return (obj, key) => {
|
|
269
280
|
setModalVar(obj, key);
|
|
@@ -309,6 +320,18 @@ var Phecda = (() => {
|
|
|
309
320
|
__name(Global, "Global");
|
|
310
321
|
|
|
311
322
|
// src/helper.ts
|
|
323
|
+
function getBind(Model) {
|
|
324
|
+
const instance = new Model();
|
|
325
|
+
const keys = getModelState(instance);
|
|
326
|
+
const ret = {};
|
|
327
|
+
for (const item of keys) {
|
|
328
|
+
const state = getState(instance, item);
|
|
329
|
+
if (state.value)
|
|
330
|
+
ret[item] = state.value;
|
|
331
|
+
}
|
|
332
|
+
return ret;
|
|
333
|
+
}
|
|
334
|
+
__name(getBind, "getBind");
|
|
312
335
|
async function plainToClass(Model, input, options = {}) {
|
|
313
336
|
const data = new Model();
|
|
314
337
|
const err = [];
|
package/dist/index.js
CHANGED
|
@@ -22,12 +22,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var src_exports = {};
|
|
23
23
|
__export(src_exports, {
|
|
24
24
|
Assign: () => Assign,
|
|
25
|
+
Bind: () => Bind,
|
|
25
26
|
Clear: () => Clear,
|
|
26
27
|
Err: () => Err,
|
|
28
|
+
Expose: () => Expose,
|
|
27
29
|
Global: () => Global,
|
|
28
30
|
Ignore: () => Ignore,
|
|
29
31
|
Init: () => Init,
|
|
30
|
-
P: () => P,
|
|
31
32
|
Pipe: () => Pipe,
|
|
32
33
|
Rule: () => Rule,
|
|
33
34
|
Storage: () => Storage,
|
|
@@ -36,6 +37,7 @@ __export(src_exports, {
|
|
|
36
37
|
activeInstance: () => activeInstance,
|
|
37
38
|
addDecoToClass: () => addDecoToClass,
|
|
38
39
|
classToValue: () => classToValue,
|
|
40
|
+
getBind: () => getBind,
|
|
39
41
|
getExposeKey: () => getExposeKey,
|
|
40
42
|
getHandler: () => getHandler,
|
|
41
43
|
getIgnoreKey: () => getIgnoreKey,
|
|
@@ -226,6 +228,15 @@ function Init(target, key) {
|
|
|
226
228
|
});
|
|
227
229
|
}
|
|
228
230
|
__name(Init, "Init");
|
|
231
|
+
function Bind(value) {
|
|
232
|
+
return (target, k) => {
|
|
233
|
+
setModalVar(target, k);
|
|
234
|
+
mergeState(target, k, {
|
|
235
|
+
value
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
__name(Bind, "Bind");
|
|
229
240
|
function Rule(rule, info, meta) {
|
|
230
241
|
return (obj, key) => {
|
|
231
242
|
setModalVar(obj, key);
|
|
@@ -260,10 +271,10 @@ function Err(cb) {
|
|
|
260
271
|
};
|
|
261
272
|
}
|
|
262
273
|
__name(Err, "Err");
|
|
263
|
-
function
|
|
274
|
+
function Expose(target, key) {
|
|
264
275
|
setExposeKey(target, key);
|
|
265
276
|
}
|
|
266
|
-
__name(
|
|
277
|
+
__name(Expose, "Expose");
|
|
267
278
|
function Pipe(v) {
|
|
268
279
|
return (obj, key) => {
|
|
269
280
|
setModalVar(obj, key);
|
|
@@ -309,6 +320,18 @@ function Global(target) {
|
|
|
309
320
|
__name(Global, "Global");
|
|
310
321
|
|
|
311
322
|
// src/helper.ts
|
|
323
|
+
function getBind(Model) {
|
|
324
|
+
const instance = new Model();
|
|
325
|
+
const keys = getModelState(instance);
|
|
326
|
+
const ret = {};
|
|
327
|
+
for (const item of keys) {
|
|
328
|
+
const state = getState(instance, item);
|
|
329
|
+
if (state.value)
|
|
330
|
+
ret[item] = state.value;
|
|
331
|
+
}
|
|
332
|
+
return ret;
|
|
333
|
+
}
|
|
334
|
+
__name(getBind, "getBind");
|
|
312
335
|
async function plainToClass(Model, input, options = {}) {
|
|
313
336
|
const data = new Model();
|
|
314
337
|
const err = [];
|
|
@@ -450,12 +473,13 @@ __name(Storage, "Storage");
|
|
|
450
473
|
// Annotate the CommonJS export names for ESM import in node:
|
|
451
474
|
0 && (module.exports = {
|
|
452
475
|
Assign,
|
|
476
|
+
Bind,
|
|
453
477
|
Clear,
|
|
454
478
|
Err,
|
|
479
|
+
Expose,
|
|
455
480
|
Global,
|
|
456
481
|
Ignore,
|
|
457
482
|
Init,
|
|
458
|
-
P,
|
|
459
483
|
Pipe,
|
|
460
484
|
Rule,
|
|
461
485
|
Storage,
|
|
@@ -464,6 +488,7 @@ __name(Storage, "Storage");
|
|
|
464
488
|
activeInstance,
|
|
465
489
|
addDecoToClass,
|
|
466
490
|
classToValue,
|
|
491
|
+
getBind,
|
|
467
492
|
getExposeKey,
|
|
468
493
|
getHandler,
|
|
469
494
|
getIgnoreKey,
|
package/dist/index.mjs
CHANGED
|
@@ -164,6 +164,15 @@ function Init(target, key) {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
__name(Init, "Init");
|
|
167
|
+
function Bind(value) {
|
|
168
|
+
return (target, k) => {
|
|
169
|
+
setModalVar(target, k);
|
|
170
|
+
mergeState(target, k, {
|
|
171
|
+
value
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
__name(Bind, "Bind");
|
|
167
176
|
function Rule(rule, info, meta) {
|
|
168
177
|
return (obj, key) => {
|
|
169
178
|
setModalVar(obj, key);
|
|
@@ -198,10 +207,10 @@ function Err(cb) {
|
|
|
198
207
|
};
|
|
199
208
|
}
|
|
200
209
|
__name(Err, "Err");
|
|
201
|
-
function
|
|
210
|
+
function Expose(target, key) {
|
|
202
211
|
setExposeKey(target, key);
|
|
203
212
|
}
|
|
204
|
-
__name(
|
|
213
|
+
__name(Expose, "Expose");
|
|
205
214
|
function Pipe(v) {
|
|
206
215
|
return (obj, key) => {
|
|
207
216
|
setModalVar(obj, key);
|
|
@@ -247,6 +256,18 @@ function Global(target) {
|
|
|
247
256
|
__name(Global, "Global");
|
|
248
257
|
|
|
249
258
|
// src/helper.ts
|
|
259
|
+
function getBind(Model) {
|
|
260
|
+
const instance = new Model();
|
|
261
|
+
const keys = getModelState(instance);
|
|
262
|
+
const ret = {};
|
|
263
|
+
for (const item of keys) {
|
|
264
|
+
const state = getState(instance, item);
|
|
265
|
+
if (state.value)
|
|
266
|
+
ret[item] = state.value;
|
|
267
|
+
}
|
|
268
|
+
return ret;
|
|
269
|
+
}
|
|
270
|
+
__name(getBind, "getBind");
|
|
250
271
|
async function plainToClass(Model, input, options = {}) {
|
|
251
272
|
const data = new Model();
|
|
252
273
|
const err = [];
|
|
@@ -387,12 +408,13 @@ function Storage(storeKey) {
|
|
|
387
408
|
__name(Storage, "Storage");
|
|
388
409
|
export {
|
|
389
410
|
Assign,
|
|
411
|
+
Bind,
|
|
390
412
|
Clear,
|
|
391
413
|
Err,
|
|
414
|
+
Expose,
|
|
392
415
|
Global,
|
|
393
416
|
Ignore,
|
|
394
417
|
Init,
|
|
395
|
-
P,
|
|
396
418
|
Pipe,
|
|
397
419
|
Rule,
|
|
398
420
|
Storage,
|
|
@@ -401,6 +423,7 @@ export {
|
|
|
401
423
|
activeInstance,
|
|
402
424
|
addDecoToClass,
|
|
403
425
|
classToValue,
|
|
426
|
+
getBind,
|
|
404
427
|
getExposeKey,
|
|
405
428
|
getHandler,
|
|
406
429
|
getIgnoreKey,
|