phecda-core 1.4.1 → 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 +3 -1
- package/dist/index.global.js +23 -0
- package/dist/index.js +25 -0
- package/dist/index.mjs +23 -0
- 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,6 +72,7 @@ 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;
|
|
@@ -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, Expose, Global, Ignore, Init, NameSpace, 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 };
|
|
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,6 +23,7 @@ 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,
|
|
28
29
|
Expose: () => Expose,
|
|
@@ -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);
|
|
@@ -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,6 +22,7 @@ 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,
|
|
27
28
|
Expose: () => Expose,
|
|
@@ -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);
|
|
@@ -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,6 +473,7 @@ __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,
|
|
455
479
|
Expose,
|
|
@@ -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);
|
|
@@ -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,6 +408,7 @@ function Storage(storeKey) {
|
|
|
387
408
|
__name(Storage, "Storage");
|
|
388
409
|
export {
|
|
389
410
|
Assign,
|
|
411
|
+
Bind,
|
|
390
412
|
Clear,
|
|
391
413
|
Err,
|
|
392
414
|
Expose,
|
|
@@ -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,
|