phecda-core 1.0.2 → 1.0.4
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 +14 -11
- package/dist/index.js +35 -0
- package/dist/index.mjs +30 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,17 +6,13 @@ interface UsePipeOptions {
|
|
|
6
6
|
collectError: boolean;
|
|
7
7
|
}
|
|
8
8
|
interface PhecdaHandler {
|
|
9
|
-
init?: (instance:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
watch?: any;
|
|
14
|
-
rule?: any;
|
|
15
|
-
info?: any;
|
|
16
|
-
ignore?: boolean;
|
|
9
|
+
init?: (instance: any) => any;
|
|
10
|
+
pipe?: (instance: any) => void;
|
|
11
|
+
rule?: RegExp | string | Function | number;
|
|
12
|
+
info?: string;
|
|
17
13
|
meta?: any;
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
error?: any;
|
|
15
|
+
http?: any;
|
|
20
16
|
}
|
|
21
17
|
interface Phecda {
|
|
22
18
|
_namespace: {
|
|
@@ -89,6 +85,7 @@ declare function Tag(tag: string): (target: any) => void;
|
|
|
89
85
|
declare function Storage(target: any): void;
|
|
90
86
|
|
|
91
87
|
declare function validate(p: RegExp | string | Function | Object | Number, v: any): Promise<any>;
|
|
88
|
+
declare function getTag<M extends new (...args: any) => any>(Model: M): any;
|
|
92
89
|
|
|
93
90
|
declare function init(target: Phecda): void;
|
|
94
91
|
declare function regisInitEvent(target: Phecda, key: string): void;
|
|
@@ -122,4 +119,10 @@ declare function isPostalCode(info?: string): (obj: any, key: PropertyKey) => vo
|
|
|
122
119
|
declare function toNumber(): (obj: any, key: PropertyKey) => void;
|
|
123
120
|
declare function toString(): (obj: any, key: PropertyKey) => void;
|
|
124
121
|
|
|
125
|
-
|
|
122
|
+
declare const activeInstance: Record<string, any>;
|
|
123
|
+
declare function injectProperty(key: string, value: any): Record<string, any>;
|
|
124
|
+
declare function getProperty(key: string): any;
|
|
125
|
+
|
|
126
|
+
declare function Watcher(eventName: string): (obj: any, key: string) => void;
|
|
127
|
+
|
|
128
|
+
export { ClassValue, Clear, Err, Get, Ignore, Init, Phecda, PhecdaHandler, PhecdaNameSpace, Pipe, Rule, Storage, Tag, UsePipeOptions, Watcher, activeInstance, addDecoToClass, classToValue, getExposeKey, getHandler, getIgnoreKey, getInitEvent, getModelState, getProperty, getTag, init, injectProperty, isArray, isBoolean, isCnName, isDate, isEnName, isHexColor, isIdCard, isLandline, isMailBox, isMobile, isNumber, isObject, isPostalCode, isString, isWechat, plainToClass, regisHandler, regisInitEvent, register, setExposeKey, setIgnoreKey, setModalState, snapShot, to, toNumber, toString, validate };
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,8 @@ __export(src_exports, {
|
|
|
29
29
|
Rule: () => Rule,
|
|
30
30
|
Storage: () => Storage,
|
|
31
31
|
Tag: () => Tag,
|
|
32
|
+
Watcher: () => Watcher,
|
|
33
|
+
activeInstance: () => activeInstance,
|
|
32
34
|
addDecoToClass: () => addDecoToClass,
|
|
33
35
|
classToValue: () => classToValue,
|
|
34
36
|
getExposeKey: () => getExposeKey,
|
|
@@ -36,7 +38,10 @@ __export(src_exports, {
|
|
|
36
38
|
getIgnoreKey: () => getIgnoreKey,
|
|
37
39
|
getInitEvent: () => getInitEvent,
|
|
38
40
|
getModelState: () => getModelState,
|
|
41
|
+
getProperty: () => getProperty,
|
|
42
|
+
getTag: () => getTag,
|
|
39
43
|
init: () => init,
|
|
44
|
+
injectProperty: () => injectProperty,
|
|
40
45
|
isArray: () => isArray,
|
|
41
46
|
isBoolean: () => isBoolean,
|
|
42
47
|
isCnName: () => isCnName,
|
|
@@ -226,6 +231,9 @@ async function validate(p, v) {
|
|
|
226
231
|
return p.test(v);
|
|
227
232
|
return false;
|
|
228
233
|
}
|
|
234
|
+
function getTag(Model) {
|
|
235
|
+
return Model.prototype?._namespace?.__TAG__;
|
|
236
|
+
}
|
|
229
237
|
|
|
230
238
|
// src/helper.ts
|
|
231
239
|
async function plainToClass(Model, input, options = {}) {
|
|
@@ -379,6 +387,28 @@ function toNumber() {
|
|
|
379
387
|
function toString() {
|
|
380
388
|
return Pipe(to((param) => String(param)));
|
|
381
389
|
}
|
|
390
|
+
|
|
391
|
+
// src/namespace.ts
|
|
392
|
+
var activeInstance = {};
|
|
393
|
+
function injectProperty(key, value) {
|
|
394
|
+
activeInstance[key] = value;
|
|
395
|
+
return activeInstance;
|
|
396
|
+
}
|
|
397
|
+
function getProperty(key) {
|
|
398
|
+
return activeInstance[key];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// src/custom/decorator.ts
|
|
402
|
+
function Watcher(eventName) {
|
|
403
|
+
return (obj, key) => {
|
|
404
|
+
setModalState(obj, key);
|
|
405
|
+
regisHandler(obj, key, {
|
|
406
|
+
init(instance) {
|
|
407
|
+
getProperty("watcher")?.({ eventName, instance, key });
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
};
|
|
411
|
+
}
|
|
382
412
|
// Annotate the CommonJS export names for ESM import in node:
|
|
383
413
|
0 && (module.exports = {
|
|
384
414
|
Clear,
|
|
@@ -390,6 +420,8 @@ function toString() {
|
|
|
390
420
|
Rule,
|
|
391
421
|
Storage,
|
|
392
422
|
Tag,
|
|
423
|
+
Watcher,
|
|
424
|
+
activeInstance,
|
|
393
425
|
addDecoToClass,
|
|
394
426
|
classToValue,
|
|
395
427
|
getExposeKey,
|
|
@@ -397,7 +429,10 @@ function toString() {
|
|
|
397
429
|
getIgnoreKey,
|
|
398
430
|
getInitEvent,
|
|
399
431
|
getModelState,
|
|
432
|
+
getProperty,
|
|
433
|
+
getTag,
|
|
400
434
|
init,
|
|
435
|
+
injectProperty,
|
|
401
436
|
isArray,
|
|
402
437
|
isBoolean,
|
|
403
438
|
isCnName,
|
package/dist/index.mjs
CHANGED
|
@@ -157,6 +157,9 @@ async function validate(p, v) {
|
|
|
157
157
|
return p.test(v);
|
|
158
158
|
return false;
|
|
159
159
|
}
|
|
160
|
+
function getTag(Model) {
|
|
161
|
+
return Model.prototype?._namespace?.__TAG__;
|
|
162
|
+
}
|
|
160
163
|
|
|
161
164
|
// src/helper.ts
|
|
162
165
|
async function plainToClass(Model, input, options = {}) {
|
|
@@ -310,6 +313,28 @@ function toNumber() {
|
|
|
310
313
|
function toString() {
|
|
311
314
|
return Pipe(to((param) => String(param)));
|
|
312
315
|
}
|
|
316
|
+
|
|
317
|
+
// src/namespace.ts
|
|
318
|
+
var activeInstance = {};
|
|
319
|
+
function injectProperty(key, value) {
|
|
320
|
+
activeInstance[key] = value;
|
|
321
|
+
return activeInstance;
|
|
322
|
+
}
|
|
323
|
+
function getProperty(key) {
|
|
324
|
+
return activeInstance[key];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/custom/decorator.ts
|
|
328
|
+
function Watcher(eventName) {
|
|
329
|
+
return (obj, key) => {
|
|
330
|
+
setModalState(obj, key);
|
|
331
|
+
regisHandler(obj, key, {
|
|
332
|
+
init(instance) {
|
|
333
|
+
getProperty("watcher")?.({ eventName, instance, key });
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
}
|
|
313
338
|
export {
|
|
314
339
|
Clear,
|
|
315
340
|
Err,
|
|
@@ -320,6 +345,8 @@ export {
|
|
|
320
345
|
Rule,
|
|
321
346
|
Storage,
|
|
322
347
|
Tag,
|
|
348
|
+
Watcher,
|
|
349
|
+
activeInstance,
|
|
323
350
|
addDecoToClass,
|
|
324
351
|
classToValue,
|
|
325
352
|
getExposeKey,
|
|
@@ -327,7 +354,10 @@ export {
|
|
|
327
354
|
getIgnoreKey,
|
|
328
355
|
getInitEvent,
|
|
329
356
|
getModelState,
|
|
357
|
+
getProperty,
|
|
358
|
+
getTag,
|
|
330
359
|
init,
|
|
360
|
+
injectProperty,
|
|
331
361
|
isArray,
|
|
332
362
|
isBoolean,
|
|
333
363
|
isCnName,
|