phecda-core 1.0.2 → 1.0.5
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 +15 -11
- package/dist/index.js +44 -0
- package/dist/index.mjs +38 -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: {
|
|
@@ -87,8 +83,10 @@ declare function Get(target: any, key: PropertyKey): void;
|
|
|
87
83
|
declare function Pipe(v: ReturnType<typeof to>): (obj: any, key: PropertyKey) => void;
|
|
88
84
|
declare function Tag(tag: string): (target: any) => void;
|
|
89
85
|
declare function Storage(target: any): void;
|
|
86
|
+
declare function Window(target: any): void;
|
|
90
87
|
|
|
91
88
|
declare function validate(p: RegExp | string | Function | Object | Number, v: any): Promise<any>;
|
|
89
|
+
declare function getTag<M extends new (...args: any) => any>(Model: M): any;
|
|
92
90
|
|
|
93
91
|
declare function init(target: Phecda): void;
|
|
94
92
|
declare function regisInitEvent(target: Phecda, key: string): void;
|
|
@@ -122,4 +120,10 @@ declare function isPostalCode(info?: string): (obj: any, key: PropertyKey) => vo
|
|
|
122
120
|
declare function toNumber(): (obj: any, key: PropertyKey) => void;
|
|
123
121
|
declare function toString(): (obj: any, key: PropertyKey) => void;
|
|
124
122
|
|
|
125
|
-
|
|
123
|
+
declare const activeInstance: Record<string, any>;
|
|
124
|
+
declare function injectProperty(key: string, value: any): Record<string, any>;
|
|
125
|
+
declare function getProperty(key: string): any;
|
|
126
|
+
|
|
127
|
+
declare function Watcher(eventName: string): (obj: any, key: string) => void;
|
|
128
|
+
|
|
129
|
+
export { ClassValue, Clear, Err, Get, Ignore, Init, Phecda, PhecdaHandler, PhecdaNameSpace, Pipe, Rule, Storage, Tag, UsePipeOptions, Watcher, Window, 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,9 @@ __export(src_exports, {
|
|
|
29
29
|
Rule: () => Rule,
|
|
30
30
|
Storage: () => Storage,
|
|
31
31
|
Tag: () => Tag,
|
|
32
|
+
Watcher: () => Watcher,
|
|
33
|
+
Window: () => Window,
|
|
34
|
+
activeInstance: () => activeInstance,
|
|
32
35
|
addDecoToClass: () => addDecoToClass,
|
|
33
36
|
classToValue: () => classToValue,
|
|
34
37
|
getExposeKey: () => getExposeKey,
|
|
@@ -36,7 +39,10 @@ __export(src_exports, {
|
|
|
36
39
|
getIgnoreKey: () => getIgnoreKey,
|
|
37
40
|
getInitEvent: () => getInitEvent,
|
|
38
41
|
getModelState: () => getModelState,
|
|
42
|
+
getProperty: () => getProperty,
|
|
43
|
+
getTag: () => getTag,
|
|
39
44
|
init: () => init,
|
|
45
|
+
injectProperty: () => injectProperty,
|
|
40
46
|
isArray: () => isArray,
|
|
41
47
|
isBoolean: () => isBoolean,
|
|
42
48
|
isCnName: () => isCnName,
|
|
@@ -213,6 +219,13 @@ function Storage(target) {
|
|
|
213
219
|
}
|
|
214
220
|
});
|
|
215
221
|
}
|
|
222
|
+
function Window(target) {
|
|
223
|
+
if (!window.__PHECDA__)
|
|
224
|
+
window.__PHECDA__ = {};
|
|
225
|
+
const tag = target.prototype._namespace.__TAG__;
|
|
226
|
+
if (tag)
|
|
227
|
+
window.__PHECDA__[tag] = target;
|
|
228
|
+
}
|
|
216
229
|
|
|
217
230
|
// src/utils.ts
|
|
218
231
|
async function validate(p, v) {
|
|
@@ -226,6 +239,9 @@ async function validate(p, v) {
|
|
|
226
239
|
return p.test(v);
|
|
227
240
|
return false;
|
|
228
241
|
}
|
|
242
|
+
function getTag(Model) {
|
|
243
|
+
return Model.prototype?._namespace?.__TAG__;
|
|
244
|
+
}
|
|
229
245
|
|
|
230
246
|
// src/helper.ts
|
|
231
247
|
async function plainToClass(Model, input, options = {}) {
|
|
@@ -379,6 +395,28 @@ function toNumber() {
|
|
|
379
395
|
function toString() {
|
|
380
396
|
return Pipe(to((param) => String(param)));
|
|
381
397
|
}
|
|
398
|
+
|
|
399
|
+
// src/namespace.ts
|
|
400
|
+
var activeInstance = {};
|
|
401
|
+
function injectProperty(key, value) {
|
|
402
|
+
activeInstance[key] = value;
|
|
403
|
+
return activeInstance;
|
|
404
|
+
}
|
|
405
|
+
function getProperty(key) {
|
|
406
|
+
return activeInstance[key];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/custom/decorator.ts
|
|
410
|
+
function Watcher(eventName) {
|
|
411
|
+
return (obj, key) => {
|
|
412
|
+
setModalState(obj, key);
|
|
413
|
+
regisHandler(obj, key, {
|
|
414
|
+
init(instance) {
|
|
415
|
+
getProperty("watcher")?.({ eventName, instance, key });
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
}
|
|
382
420
|
// Annotate the CommonJS export names for ESM import in node:
|
|
383
421
|
0 && (module.exports = {
|
|
384
422
|
Clear,
|
|
@@ -390,6 +428,9 @@ function toString() {
|
|
|
390
428
|
Rule,
|
|
391
429
|
Storage,
|
|
392
430
|
Tag,
|
|
431
|
+
Watcher,
|
|
432
|
+
Window,
|
|
433
|
+
activeInstance,
|
|
393
434
|
addDecoToClass,
|
|
394
435
|
classToValue,
|
|
395
436
|
getExposeKey,
|
|
@@ -397,7 +438,10 @@ function toString() {
|
|
|
397
438
|
getIgnoreKey,
|
|
398
439
|
getInitEvent,
|
|
399
440
|
getModelState,
|
|
441
|
+
getProperty,
|
|
442
|
+
getTag,
|
|
400
443
|
init,
|
|
444
|
+
injectProperty,
|
|
401
445
|
isArray,
|
|
402
446
|
isBoolean,
|
|
403
447
|
isCnName,
|
package/dist/index.mjs
CHANGED
|
@@ -144,6 +144,13 @@ function Storage(target) {
|
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
+
function Window(target) {
|
|
148
|
+
if (!window.__PHECDA__)
|
|
149
|
+
window.__PHECDA__ = {};
|
|
150
|
+
const tag = target.prototype._namespace.__TAG__;
|
|
151
|
+
if (tag)
|
|
152
|
+
window.__PHECDA__[tag] = target;
|
|
153
|
+
}
|
|
147
154
|
|
|
148
155
|
// src/utils.ts
|
|
149
156
|
async function validate(p, v) {
|
|
@@ -157,6 +164,9 @@ async function validate(p, v) {
|
|
|
157
164
|
return p.test(v);
|
|
158
165
|
return false;
|
|
159
166
|
}
|
|
167
|
+
function getTag(Model) {
|
|
168
|
+
return Model.prototype?._namespace?.__TAG__;
|
|
169
|
+
}
|
|
160
170
|
|
|
161
171
|
// src/helper.ts
|
|
162
172
|
async function plainToClass(Model, input, options = {}) {
|
|
@@ -310,6 +320,28 @@ function toNumber() {
|
|
|
310
320
|
function toString() {
|
|
311
321
|
return Pipe(to((param) => String(param)));
|
|
312
322
|
}
|
|
323
|
+
|
|
324
|
+
// src/namespace.ts
|
|
325
|
+
var activeInstance = {};
|
|
326
|
+
function injectProperty(key, value) {
|
|
327
|
+
activeInstance[key] = value;
|
|
328
|
+
return activeInstance;
|
|
329
|
+
}
|
|
330
|
+
function getProperty(key) {
|
|
331
|
+
return activeInstance[key];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/custom/decorator.ts
|
|
335
|
+
function Watcher(eventName) {
|
|
336
|
+
return (obj, key) => {
|
|
337
|
+
setModalState(obj, key);
|
|
338
|
+
regisHandler(obj, key, {
|
|
339
|
+
init(instance) {
|
|
340
|
+
getProperty("watcher")?.({ eventName, instance, key });
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
};
|
|
344
|
+
}
|
|
313
345
|
export {
|
|
314
346
|
Clear,
|
|
315
347
|
Err,
|
|
@@ -320,6 +352,9 @@ export {
|
|
|
320
352
|
Rule,
|
|
321
353
|
Storage,
|
|
322
354
|
Tag,
|
|
355
|
+
Watcher,
|
|
356
|
+
Window,
|
|
357
|
+
activeInstance,
|
|
323
358
|
addDecoToClass,
|
|
324
359
|
classToValue,
|
|
325
360
|
getExposeKey,
|
|
@@ -327,7 +362,10 @@ export {
|
|
|
327
362
|
getIgnoreKey,
|
|
328
363
|
getInitEvent,
|
|
329
364
|
getModelState,
|
|
365
|
+
getProperty,
|
|
366
|
+
getTag,
|
|
330
367
|
init,
|
|
368
|
+
injectProperty,
|
|
331
369
|
isArray,
|
|
332
370
|
isBoolean,
|
|
333
371
|
isCnName,
|