phecda-core 1.2.0 → 1.3.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 CHANGED
@@ -10,7 +10,6 @@ interface PhecdaHandler {
10
10
  }
11
11
  interface Phecda {
12
12
  _namespace: {
13
- __TAG__: string;
14
13
  __INIT_EVENT__: Set<PropertyKey>;
15
14
  __EXPOSE_VAR__: Set<PropertyKey>;
16
15
  __IGNORE_VAR__: Set<PropertyKey>;
@@ -102,25 +101,6 @@ declare function getState(target: Phecda, key: PropertyKey): Object | undefined;
102
101
  declare function register(instance: Phecda): void;
103
102
  declare function registerAsync(instance: Phecda): Promise<void>;
104
103
 
105
- declare function isArray(info?: string): (obj: any, key: PropertyKey) => void;
106
- declare function isBoolean(info?: string): (obj: any, key: PropertyKey) => void;
107
- declare function isNumber(info?: string): (obj: any, key: PropertyKey) => void;
108
- declare function isString(info?: string): (obj: any, key: PropertyKey) => void;
109
- declare function isObject(info?: string): (obj: any, key: PropertyKey) => void;
110
- declare function isMobile(info?: string): (obj: any, key: PropertyKey) => void;
111
- declare function isLandline(info?: string): (obj: any, key: PropertyKey) => void;
112
- declare function isMailBox(info?: string): (obj: any, key: PropertyKey) => void;
113
- declare function isIdCard(info?: string): (obj: any, key: PropertyKey) => void;
114
- declare function isCnName(info?: string): (obj: any, key: PropertyKey) => void;
115
- declare function isEnName(info?: string): (obj: any, key: PropertyKey) => void;
116
- declare function isDate(info?: string): (obj: any, key: PropertyKey) => void;
117
- declare function isWechat(info?: string): (obj: any, key: PropertyKey) => void;
118
- declare function isHexColor(info?: string): (obj: any, key: PropertyKey) => void;
119
- declare function isPostalCode(info?: string): (obj: any, key: PropertyKey) => void;
120
-
121
- declare function toNumber(): (obj: any, key: PropertyKey) => void;
122
- declare function toString(): (obj: any, key: PropertyKey) => void;
123
-
124
104
  declare const activeInstance: Record<string, any>;
125
105
  declare function injectProperty(key: string, value: any): Record<string, any>;
126
106
  declare function getProperty(key: string): any;
@@ -130,4 +110,4 @@ declare function Watcher(eventName: keyof PhecdaEvents, options?: {
130
110
  }): (obj: any, key: string) => void;
131
111
  declare function Storage(storeKey?: string): (target: any, key?: PropertyKey) => void;
132
112
 
133
- export { ClassValue, Clear, Err, Global, Ignore, Init, P, Phecda, PhecdaEvents, PhecdaHandler, PhecdaNameSpace, Pipe, Rule, Storage, Tag, UsePipeOptions, Watcher, activeInstance, addDecoToClass, classToValue, getExposeKey, getHandler, getIgnoreKey, getInitEvent, getModelState, getProperty, getState, getTag, init, injectProperty, isArray, isBoolean, isCnName, isDate, isEnName, isHexColor, isIdCard, isLandline, isMailBox, isMobile, isNumber, isObject, isPhecda, isPostalCode, isString, isWechat, mergeOptions, mergeState, plainToClass, regisHandler, regisInitEvent, register, registerAsync, setExposeKey, setIgnoreKey, setModalVar, snapShot, to, toNumber, toString, validate };
113
+ export { ClassValue, Clear, Err, Global, Ignore, Init, P, Phecda, PhecdaEvents, PhecdaHandler, PhecdaNameSpace, 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 };
@@ -0,0 +1,434 @@
1
+ "use strict";
2
+ var Phecda = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to2, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to2, key) && key !== except)
16
+ __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to2;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/index.ts
23
+ var src_exports = {};
24
+ __export(src_exports, {
25
+ Clear: () => Clear,
26
+ Err: () => Err,
27
+ Global: () => Global,
28
+ Ignore: () => Ignore,
29
+ Init: () => Init,
30
+ P: () => P,
31
+ Pipe: () => Pipe,
32
+ Rule: () => Rule,
33
+ Storage: () => Storage,
34
+ Tag: () => Tag,
35
+ Watcher: () => Watcher,
36
+ activeInstance: () => activeInstance,
37
+ addDecoToClass: () => addDecoToClass,
38
+ classToValue: () => classToValue,
39
+ getExposeKey: () => getExposeKey,
40
+ getHandler: () => getHandler,
41
+ getIgnoreKey: () => getIgnoreKey,
42
+ getInitEvent: () => getInitEvent,
43
+ getModelState: () => getModelState,
44
+ getProperty: () => getProperty,
45
+ getState: () => getState,
46
+ getTag: () => getTag,
47
+ init: () => init,
48
+ injectProperty: () => injectProperty,
49
+ isPhecda: () => isPhecda,
50
+ mergeOptions: () => mergeOptions,
51
+ mergeState: () => mergeState,
52
+ plainToClass: () => plainToClass,
53
+ regisHandler: () => regisHandler,
54
+ regisInitEvent: () => regisInitEvent,
55
+ register: () => register,
56
+ registerAsync: () => registerAsync,
57
+ setExposeKey: () => setExposeKey,
58
+ setIgnoreKey: () => setIgnoreKey,
59
+ setModalVar: () => setModalVar,
60
+ snapShot: () => snapShot,
61
+ to: () => to,
62
+ validate: () => validate
63
+ });
64
+
65
+ // src/utils.ts
66
+ async function validate(p, v) {
67
+ if (typeof p === "string" || typeof p === "number") {
68
+ if (v === p)
69
+ return true;
70
+ }
71
+ if (typeof p === "function")
72
+ return p(v);
73
+ if (p instanceof RegExp)
74
+ return p.test(v);
75
+ return false;
76
+ }
77
+ __name(validate, "validate");
78
+ function getTag(Model) {
79
+ return Model.prototype?.__TAG__;
80
+ }
81
+ __name(getTag, "getTag");
82
+ function mergeOptions(obj1, obj2) {
83
+ if (!obj2)
84
+ return obj1;
85
+ for (const i in obj2) {
86
+ if (isObject(obj1[i]) && isObject(obj2[i])) {
87
+ mergeOptions(obj1[i], obj2[i]);
88
+ continue;
89
+ }
90
+ if (Array.isArray(obj1[i]) && Array.isArray(obj2[i])) {
91
+ obj1[i].push(...obj2[i].filter((item) => !obj1[i].includes(item)));
92
+ continue;
93
+ }
94
+ obj1[i] = obj2[i];
95
+ }
96
+ return obj1;
97
+ }
98
+ __name(mergeOptions, "mergeOptions");
99
+ function isObject(obj) {
100
+ return Object.prototype.toString.call(obj) === "[object Object]";
101
+ }
102
+ __name(isObject, "isObject");
103
+
104
+ // src/core.ts
105
+ function isPhecda(target) {
106
+ return target && !!target.prototype._namespace;
107
+ }
108
+ __name(isPhecda, "isPhecda");
109
+ function init(target) {
110
+ if (!target._namespace) {
111
+ target._namespace = {
112
+ __INIT_EVENT__: /* @__PURE__ */ new Set(),
113
+ __EXPOSE_VAR__: /* @__PURE__ */ new Set(),
114
+ __IGNORE_VAR__: /* @__PURE__ */ new Set(),
115
+ __STATE_VAR__: /* @__PURE__ */ new Set(),
116
+ __STATE_HANDLER__: /* @__PURE__ */ new Map(),
117
+ __STATE_NAMESPACE__: /* @__PURE__ */ new Map()
118
+ };
119
+ }
120
+ }
121
+ __name(init, "init");
122
+ function regisInitEvent(target, key) {
123
+ init(target);
124
+ target._namespace.__INIT_EVENT__.add(key);
125
+ }
126
+ __name(regisInitEvent, "regisInitEvent");
127
+ function getInitEvent(target) {
128
+ init(target);
129
+ return [
130
+ ...target._namespace.__INIT_EVENT__
131
+ ];
132
+ }
133
+ __name(getInitEvent, "getInitEvent");
134
+ function setModalVar(target, key) {
135
+ init(target);
136
+ target._namespace.__STATE_VAR__.add(key);
137
+ setExposeKey(target, key);
138
+ }
139
+ __name(setModalVar, "setModalVar");
140
+ function setExposeKey(target, key) {
141
+ init(target);
142
+ target._namespace.__EXPOSE_VAR__.add(key);
143
+ }
144
+ __name(setExposeKey, "setExposeKey");
145
+ function setIgnoreKey(target, key) {
146
+ init(target);
147
+ target._namespace.__IGNORE_VAR__.add(key);
148
+ }
149
+ __name(setIgnoreKey, "setIgnoreKey");
150
+ function getModelState(target) {
151
+ init(target);
152
+ return [
153
+ ...target._namespace.__STATE_VAR__
154
+ ];
155
+ }
156
+ __name(getModelState, "getModelState");
157
+ function getExposeKey(target) {
158
+ init(target);
159
+ return [
160
+ ...target._namespace.__EXPOSE_VAR__
161
+ ].filter((item) => !target._namespace.__IGNORE_VAR__.has(item));
162
+ }
163
+ __name(getExposeKey, "getExposeKey");
164
+ function getIgnoreKey(target) {
165
+ init(target);
166
+ return [
167
+ ...target._namespace.__IGNORE_VAR__
168
+ ];
169
+ }
170
+ __name(getIgnoreKey, "getIgnoreKey");
171
+ function regisHandler(target, key, handler) {
172
+ init(target);
173
+ if (!target._namespace.__STATE_HANDLER__.has(key))
174
+ target._namespace.__STATE_HANDLER__.set(key, [
175
+ handler
176
+ ]);
177
+ else
178
+ target._namespace.__STATE_HANDLER__.get(key).push(handler);
179
+ }
180
+ __name(regisHandler, "regisHandler");
181
+ function getHandler(target, key) {
182
+ return target._namespace.__STATE_HANDLER__.get(key) || [];
183
+ }
184
+ __name(getHandler, "getHandler");
185
+ function mergeState(target, key, state) {
186
+ const namespace = target._namespace.__STATE_NAMESPACE__;
187
+ if (!namespace.has(key))
188
+ namespace.set(key, state);
189
+ else
190
+ mergeOptions(namespace.get(key), state);
191
+ }
192
+ __name(mergeState, "mergeState");
193
+ function getState(target, key) {
194
+ const namespace = target._namespace.__STATE_NAMESPACE__;
195
+ if (namespace)
196
+ return namespace.get(key);
197
+ }
198
+ __name(getState, "getState");
199
+ function register(instance) {
200
+ const stateVars = getExposeKey(instance);
201
+ for (const item of stateVars) {
202
+ const handlers = getHandler(instance, item);
203
+ for (const hanlder of handlers)
204
+ hanlder.init?.(instance);
205
+ }
206
+ }
207
+ __name(register, "register");
208
+ async function registerAsync(instance) {
209
+ const stateVars = getExposeKey(instance);
210
+ for (const item of stateVars) {
211
+ const handlers = getHandler(instance, item);
212
+ for (const hanlder of handlers)
213
+ await hanlder.init?.(instance);
214
+ }
215
+ }
216
+ __name(registerAsync, "registerAsync");
217
+
218
+ // src/decorators.ts
219
+ function Init(target, key) {
220
+ setModalVar(target, key);
221
+ regisHandler(target, key, {
222
+ async init(instance) {
223
+ instance[key]();
224
+ }
225
+ });
226
+ }
227
+ __name(Init, "Init");
228
+ function Rule(rule, info, meta) {
229
+ return (obj, key) => {
230
+ setModalVar(obj, key);
231
+ regisHandler(obj, key, {
232
+ rule,
233
+ info,
234
+ meta
235
+ });
236
+ };
237
+ }
238
+ __name(Rule, "Rule");
239
+ function Ignore(target, key) {
240
+ setIgnoreKey(target, key);
241
+ }
242
+ __name(Ignore, "Ignore");
243
+ function Clear(target, key) {
244
+ init(target);
245
+ target._namespace.__INIT_EVENT__.delete(key);
246
+ target._namespace.__EXPOSE_VAR__.delete(key);
247
+ target._namespace.__IGNORE_VAR__.delete(key);
248
+ target._namespace.__STATE_VAR__.delete(key);
249
+ target._namespace.__STATE_HANDLER__.delete(key);
250
+ target._namespace.__STATE_NAMESPACE__.delete(key);
251
+ }
252
+ __name(Clear, "Clear");
253
+ function Err(cb) {
254
+ return (target, key) => {
255
+ setModalVar(target, key);
256
+ regisHandler(target, key, {
257
+ error: cb
258
+ });
259
+ };
260
+ }
261
+ __name(Err, "Err");
262
+ function P(target, key) {
263
+ setExposeKey(target, key);
264
+ }
265
+ __name(P, "P");
266
+ function Pipe(v) {
267
+ return (obj, key) => {
268
+ setModalVar(obj, key);
269
+ regisHandler(obj, key, {
270
+ async pipe(instance) {
271
+ const tasks = v.value;
272
+ for (const task of tasks)
273
+ instance[key] = await task(instance[key]);
274
+ }
275
+ });
276
+ };
277
+ }
278
+ __name(Pipe, "Pipe");
279
+ function Tag(tag) {
280
+ return (target) => {
281
+ target.prototype.__TAG__ = tag;
282
+ };
283
+ }
284
+ __name(Tag, "Tag");
285
+ function Global(target) {
286
+ if (!globalThis.__PHECDA__)
287
+ globalThis.__PHECDA__ = {};
288
+ const tag = target.prototype.__TAG__;
289
+ if (tag)
290
+ globalThis.__PHECDA__[tag] = target;
291
+ }
292
+ __name(Global, "Global");
293
+
294
+ // src/helper.ts
295
+ async function plainToClass(Model, input, options = {}) {
296
+ const data = new Model();
297
+ const err = [];
298
+ const stateVars = getModelState(data);
299
+ for (const item of stateVars) {
300
+ data[item] = input[item];
301
+ const handlers = getHandler(data, item);
302
+ if (handlers) {
303
+ if (options.collectError !== false) {
304
+ for (const handler of handlers) {
305
+ const rule = handler.rule;
306
+ if (rule && !await validate(rule, data[item])) {
307
+ err.push(handler.info || "");
308
+ if (!options.collectError)
309
+ break;
310
+ }
311
+ }
312
+ }
313
+ if (err.length > 0 && !options.transform)
314
+ return {
315
+ err,
316
+ data
317
+ };
318
+ if (options.transform !== false) {
319
+ for (const handler of handlers)
320
+ await handler.pipe?.(data);
321
+ }
322
+ }
323
+ }
324
+ return {
325
+ data,
326
+ err
327
+ };
328
+ }
329
+ __name(plainToClass, "plainToClass");
330
+ function classToValue(instance) {
331
+ const data = {};
332
+ const exposeVar = getExposeKey(instance);
333
+ for (const item of exposeVar)
334
+ data[item] = instance[item];
335
+ return data;
336
+ }
337
+ __name(classToValue, "classToValue");
338
+ function to(task, oldTasks) {
339
+ const tasks = oldTasks || [];
340
+ tasks.push(task);
341
+ return {
342
+ to: (task2) => to(task2, tasks),
343
+ value: tasks
344
+ };
345
+ }
346
+ __name(to, "to");
347
+ function snapShot(data) {
348
+ const snap = {};
349
+ for (const i in data)
350
+ snap[i] = data[i];
351
+ return {
352
+ data,
353
+ clear() {
354
+ for (const i in snap)
355
+ delete data[i];
356
+ },
357
+ apply() {
358
+ for (const i in snap)
359
+ data[i] = snap[i];
360
+ }
361
+ };
362
+ }
363
+ __name(snapShot, "snapShot");
364
+ function addDecoToClass(c, key, handler, type = "normal") {
365
+ handler(type === "normal" ? c.prototype : c, key);
366
+ }
367
+ __name(addDecoToClass, "addDecoToClass");
368
+
369
+ // src/namespace.ts
370
+ var activeInstance = {};
371
+ function injectProperty(key, value) {
372
+ activeInstance[key] = value;
373
+ return activeInstance;
374
+ }
375
+ __name(injectProperty, "injectProperty");
376
+ function getProperty(key) {
377
+ return activeInstance[key];
378
+ }
379
+ __name(getProperty, "getProperty");
380
+
381
+ // src/custom/decorator.ts
382
+ function Watcher(eventName, options) {
383
+ return (obj, key) => {
384
+ setModalVar(obj, key);
385
+ regisHandler(obj, key, {
386
+ init(instance) {
387
+ getProperty("watcher")?.({
388
+ eventName,
389
+ instance,
390
+ key,
391
+ options
392
+ });
393
+ }
394
+ });
395
+ };
396
+ }
397
+ __name(Watcher, "Watcher");
398
+ function Storage(storeKey) {
399
+ return (target, key) => {
400
+ let tag;
401
+ if (key) {
402
+ init(target);
403
+ tag = storeKey || target.__TAG__;
404
+ const uniTag = Symbol(tag);
405
+ setModalVar(target, uniTag);
406
+ regisHandler(target, uniTag, {
407
+ init: (instance) => {
408
+ getProperty("storage")?.({
409
+ instance,
410
+ key,
411
+ tag
412
+ });
413
+ }
414
+ });
415
+ } else {
416
+ init(target.prototype);
417
+ tag = storeKey || `${target.prototype.__TAG__}_${key}`;
418
+ const uniTag = Symbol(tag);
419
+ setModalVar(target.prototype, uniTag);
420
+ regisHandler(target.prototype, uniTag, {
421
+ init: (instance) => {
422
+ getProperty("storage")?.({
423
+ instance,
424
+ key: "",
425
+ tag
426
+ });
427
+ }
428
+ });
429
+ }
430
+ };
431
+ }
432
+ __name(Storage, "Storage");
433
+ return __toCommonJS(src_exports);
434
+ })();
package/dist/index.js CHANGED
@@ -45,22 +45,7 @@ __export(src_exports, {
45
45
  getTag: () => getTag,
46
46
  init: () => init,
47
47
  injectProperty: () => injectProperty,
48
- isArray: () => isArray,
49
- isBoolean: () => isBoolean,
50
- isCnName: () => isCnName,
51
- isDate: () => isDate,
52
- isEnName: () => isEnName,
53
- isHexColor: () => isHexColor,
54
- isIdCard: () => isIdCard,
55
- isLandline: () => isLandline,
56
- isMailBox: () => isMailBox,
57
- isMobile: () => isMobile,
58
- isNumber: () => isNumber,
59
- isObject: () => isObject2,
60
48
  isPhecda: () => isPhecda,
61
- isPostalCode: () => isPostalCode,
62
- isString: () => isString,
63
- isWechat: () => isWechat,
64
49
  mergeOptions: () => mergeOptions,
65
50
  mergeState: () => mergeState,
66
51
  plainToClass: () => plainToClass,
@@ -73,8 +58,6 @@ __export(src_exports, {
73
58
  setModalVar: () => setModalVar,
74
59
  snapShot: () => snapShot,
75
60
  to: () => to,
76
- toNumber: () => toNumber,
77
- toString: () => toString,
78
61
  validate: () => validate
79
62
  });
80
63
  module.exports = __toCommonJS(src_exports);
@@ -93,7 +76,7 @@ async function validate(p, v) {
93
76
  }
94
77
  __name(validate, "validate");
95
78
  function getTag(Model) {
96
- return Model.prototype?._namespace?.__TAG__;
79
+ return Model.prototype?.__TAG__;
97
80
  }
98
81
  __name(getTag, "getTag");
99
82
  function mergeOptions(obj1, obj2) {
@@ -126,7 +109,6 @@ __name(isPhecda, "isPhecda");
126
109
  function init(target) {
127
110
  if (!target._namespace) {
128
111
  target._namespace = {
129
- __TAG__: "",
130
112
  __INIT_EVENT__: /* @__PURE__ */ new Set(),
131
113
  __EXPOSE_VAR__: /* @__PURE__ */ new Set(),
132
114
  __IGNORE_VAR__: /* @__PURE__ */ new Set(),
@@ -296,15 +278,14 @@ function Pipe(v) {
296
278
  __name(Pipe, "Pipe");
297
279
  function Tag(tag) {
298
280
  return (target) => {
299
- init(target.prototype);
300
- target.prototype._namespace.__TAG__ = tag;
281
+ target.prototype.__TAG__ = tag;
301
282
  };
302
283
  }
303
284
  __name(Tag, "Tag");
304
285
  function Global(target) {
305
286
  if (!globalThis.__PHECDA__)
306
287
  globalThis.__PHECDA__ = {};
307
- const tag = target.prototype._namespace.__TAG__;
288
+ const tag = target.prototype.__TAG__;
308
289
  if (tag)
309
290
  globalThis.__PHECDA__[tag] = target;
310
291
  }
@@ -385,83 +366,6 @@ function addDecoToClass(c, key, handler, type = "normal") {
385
366
  }
386
367
  __name(addDecoToClass, "addDecoToClass");
387
368
 
388
- // src/preset/rule.ts
389
- function isArray(info) {
390
- return Rule((param) => Array.isArray(param), info || "it should be an array");
391
- }
392
- __name(isArray, "isArray");
393
- function isBoolean(info) {
394
- return Rule((param) => [
395
- true,
396
- false
397
- ].includes(param), info || "it should be true or false");
398
- }
399
- __name(isBoolean, "isBoolean");
400
- function isNumber(info) {
401
- return Rule((param) => typeof param === "number", info || "it should be true or false");
402
- }
403
- __name(isNumber, "isNumber");
404
- function isString(info) {
405
- return Rule((param) => typeof param === "string", info || "it should be a string");
406
- }
407
- __name(isString, "isString");
408
- function isObject2(info) {
409
- return Rule((param) => {
410
- return Object.prototype.toString.call(param) === "[object Object]";
411
- }, info || "it should be an object");
412
- }
413
- __name(isObject2, "isObject");
414
- function isMobile(info) {
415
- return Rule(/^((\+|00)86)?1((3[\d])|(4[5,6,7,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[\d])|(9[1,8,9]))\d{8}$/, info || "it should be a mobile phone number");
416
- }
417
- __name(isMobile, "isMobile");
418
- function isLandline(info) {
419
- return Rule(/\d{3}-\d{8}|\d{4}-\d{7}/, info || "it should be a mobile phone number");
420
- }
421
- __name(isLandline, "isLandline");
422
- function isMailBox(info) {
423
- return Rule(/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, info || "it should be a mailbox number");
424
- }
425
- __name(isMailBox, "isMailBox");
426
- function isIdCard(info) {
427
- return Rule(/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/, info || "it should be an identity card number");
428
- }
429
- __name(isIdCard, "isIdCard");
430
- function isCnName(info) {
431
- return Rule(/^([\u4E00-\u9FA5·]{2,16})$/, info || "\u9700\u8981\u662F\u4E00\u4E2A\u5408\u7406\u7684\u4E2D\u6587\u540D\u5B57");
432
- }
433
- __name(isCnName, "isCnName");
434
- function isEnName(info) {
435
- return Rule(/(^[a-zA-Z]{1}[a-zA-Z\s]{0,20}[a-zA-Z]{1}$)/, info || "it should be a valid en-name");
436
- }
437
- __name(isEnName, "isEnName");
438
- function isDate(info) {
439
- return Rule(/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/, info || "it should be a valid date");
440
- }
441
- __name(isDate, "isDate");
442
- function isWechat(info) {
443
- return Rule(/^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/, info || "it should be a valid date");
444
- }
445
- __name(isWechat, "isWechat");
446
- function isHexColor(info) {
447
- return Rule(/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, info || "it should be a valid hex-color");
448
- }
449
- __name(isHexColor, "isHexColor");
450
- function isPostalCode(info) {
451
- return Rule(/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/, info || "it should be a valid postal code");
452
- }
453
- __name(isPostalCode, "isPostalCode");
454
-
455
- // src/preset/pipe.ts
456
- function toNumber() {
457
- return Pipe(to((param) => Number(param)));
458
- }
459
- __name(toNumber, "toNumber");
460
- function toString() {
461
- return Pipe(to((param) => String(param)));
462
- }
463
- __name(toString, "toString");
464
-
465
369
  // src/namespace.ts
466
370
  var activeInstance = {};
467
371
  function injectProperty(key, value) {
@@ -496,7 +400,7 @@ function Storage(storeKey) {
496
400
  let tag;
497
401
  if (key) {
498
402
  init(target);
499
- tag = storeKey || target._namespace.__TAG__;
403
+ tag = storeKey || target.__TAG__;
500
404
  const uniTag = Symbol(tag);
501
405
  setModalVar(target, uniTag);
502
406
  regisHandler(target, uniTag, {
@@ -510,7 +414,7 @@ function Storage(storeKey) {
510
414
  });
511
415
  } else {
512
416
  init(target.prototype);
513
- tag = storeKey || `${target.prototype._namespace.__TAG__}_${key}`;
417
+ tag = storeKey || `${target.prototype.__TAG__}_${key}`;
514
418
  const uniTag = Symbol(tag);
515
419
  setModalVar(target.prototype, uniTag);
516
420
  regisHandler(target.prototype, uniTag, {
@@ -552,22 +456,7 @@ __name(Storage, "Storage");
552
456
  getTag,
553
457
  init,
554
458
  injectProperty,
555
- isArray,
556
- isBoolean,
557
- isCnName,
558
- isDate,
559
- isEnName,
560
- isHexColor,
561
- isIdCard,
562
- isLandline,
563
- isMailBox,
564
- isMobile,
565
- isNumber,
566
- isObject,
567
459
  isPhecda,
568
- isPostalCode,
569
- isString,
570
- isWechat,
571
460
  mergeOptions,
572
461
  mergeState,
573
462
  plainToClass,
@@ -580,7 +469,5 @@ __name(Storage, "Storage");
580
469
  setModalVar,
581
470
  snapShot,
582
471
  to,
583
- toNumber,
584
- toString,
585
472
  validate
586
473
  });