phecda-core 2.1.2-alpha.0 → 3.0.0-alpha.10
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 +65 -47
- package/dist/index.js +190 -200
- package/dist/index.mjs +182 -191
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2,19 +2,18 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/core.ts
|
|
5
|
-
function isPhecda(
|
|
6
|
-
if (typeof
|
|
7
|
-
return !!
|
|
8
|
-
}
|
|
5
|
+
function isPhecda(module) {
|
|
6
|
+
if (typeof module === "function")
|
|
7
|
+
return !!module.prototype?._namespace;
|
|
9
8
|
return false;
|
|
10
9
|
}
|
|
11
10
|
__name(isPhecda, "isPhecda");
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
var SHARE_KEY = Symbol("phecda-core");
|
|
12
|
+
function init(proto) {
|
|
13
|
+
if (!proto)
|
|
14
14
|
return;
|
|
15
|
-
if (!
|
|
16
|
-
|
|
17
|
-
__INIT_EVENT__: /* @__PURE__ */ new Set(),
|
|
15
|
+
if (!proto.hasOwnProperty("_namespace")) {
|
|
16
|
+
proto._namespace = {
|
|
18
17
|
__EXPOSE_VAR__: /* @__PURE__ */ new Set(),
|
|
19
18
|
__IGNORE_VAR__: /* @__PURE__ */ new Set(),
|
|
20
19
|
__STATE_VAR__: /* @__PURE__ */ new Set(),
|
|
@@ -24,56 +23,31 @@ function init(target) {
|
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
__name(init, "init");
|
|
27
|
-
function
|
|
28
|
-
init(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
__name(regisInitEvent, "regisInitEvent");
|
|
32
|
-
function getOwnInitEvent(target) {
|
|
33
|
-
if (!target?._namespace)
|
|
34
|
-
return [];
|
|
35
|
-
return [
|
|
36
|
-
...target._namespace.__INIT_EVENT__
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
__name(getOwnInitEvent, "getOwnInitEvent");
|
|
40
|
-
function getInitEvent(target) {
|
|
41
|
-
let proto = Object.getPrototypeOf(target);
|
|
42
|
-
const set = /* @__PURE__ */ new Set();
|
|
43
|
-
while (proto?._namespace) {
|
|
44
|
-
proto._namespace.__INIT_EVENT__.forEach((item) => set.add(item));
|
|
45
|
-
proto = Object.getPrototypeOf(proto);
|
|
46
|
-
}
|
|
47
|
-
return [
|
|
48
|
-
...set
|
|
49
|
-
];
|
|
26
|
+
function setVar(proto, key) {
|
|
27
|
+
init(proto);
|
|
28
|
+
proto._namespace.__STATE_VAR__.add(key);
|
|
29
|
+
setExposeKey(proto, key);
|
|
50
30
|
}
|
|
51
|
-
__name(
|
|
52
|
-
function
|
|
53
|
-
init(
|
|
54
|
-
|
|
55
|
-
setExposeKey(target, key);
|
|
56
|
-
}
|
|
57
|
-
__name(setModelVar, "setModelVar");
|
|
58
|
-
function setExposeKey(target, key) {
|
|
59
|
-
init(target);
|
|
60
|
-
target._namespace.__EXPOSE_VAR__.add(key);
|
|
31
|
+
__name(setVar, "setVar");
|
|
32
|
+
function setExposeKey(proto, key) {
|
|
33
|
+
init(proto);
|
|
34
|
+
proto._namespace.__EXPOSE_VAR__.add(key);
|
|
61
35
|
}
|
|
62
36
|
__name(setExposeKey, "setExposeKey");
|
|
63
|
-
function setIgnoreKey(
|
|
64
|
-
init(
|
|
65
|
-
|
|
37
|
+
function setIgnoreKey(proto, key) {
|
|
38
|
+
init(proto);
|
|
39
|
+
proto._namespace.__IGNORE_VAR__.add(key);
|
|
66
40
|
}
|
|
67
41
|
__name(setIgnoreKey, "setIgnoreKey");
|
|
68
|
-
function
|
|
69
|
-
|
|
42
|
+
function getOwnModuleState(instance) {
|
|
43
|
+
instance = Object.getPrototypeOf(instance);
|
|
70
44
|
return [
|
|
71
|
-
...
|
|
45
|
+
...instance._namespace.__STATE_VAR__
|
|
72
46
|
];
|
|
73
47
|
}
|
|
74
|
-
__name(
|
|
75
|
-
function
|
|
76
|
-
let proto = Object.getPrototypeOf(
|
|
48
|
+
__name(getOwnModuleState, "getOwnModuleState");
|
|
49
|
+
function getModuleState(instance) {
|
|
50
|
+
let proto = Object.getPrototypeOf(instance);
|
|
77
51
|
const set = /* @__PURE__ */ new Set();
|
|
78
52
|
while (proto?._namespace) {
|
|
79
53
|
proto._namespace.__STATE_VAR__.forEach((item) => set.add(item));
|
|
@@ -83,16 +57,16 @@ function getModelState(target) {
|
|
|
83
57
|
...set
|
|
84
58
|
];
|
|
85
59
|
}
|
|
86
|
-
__name(
|
|
87
|
-
function getOwnExposeKey(
|
|
88
|
-
|
|
60
|
+
__name(getModuleState, "getModuleState");
|
|
61
|
+
function getOwnExposeKey(instance) {
|
|
62
|
+
instance = Object.getPrototypeOf(instance);
|
|
89
63
|
return [
|
|
90
|
-
...
|
|
91
|
-
].filter((item) => !
|
|
64
|
+
...instance._namespace.__EXPOSE_VAR__
|
|
65
|
+
].filter((item) => !instance._namespace.__IGNORE_VAR__.has(item));
|
|
92
66
|
}
|
|
93
67
|
__name(getOwnExposeKey, "getOwnExposeKey");
|
|
94
|
-
function getExposeKey(
|
|
95
|
-
let proto = Object.getPrototypeOf(
|
|
68
|
+
function getExposeKey(instance) {
|
|
69
|
+
let proto = Object.getPrototypeOf(instance);
|
|
96
70
|
const set = /* @__PURE__ */ new Set();
|
|
97
71
|
while (proto?._namespace) {
|
|
98
72
|
[
|
|
@@ -105,32 +79,32 @@ function getExposeKey(target) {
|
|
|
105
79
|
];
|
|
106
80
|
}
|
|
107
81
|
__name(getExposeKey, "getExposeKey");
|
|
108
|
-
function getOwnIgnoreKey(
|
|
109
|
-
if (!
|
|
82
|
+
function getOwnIgnoreKey(instance) {
|
|
83
|
+
if (!instance?._namespace)
|
|
110
84
|
return [];
|
|
111
85
|
return [
|
|
112
|
-
...
|
|
86
|
+
...instance._namespace.__IGNORE_VAR__
|
|
113
87
|
];
|
|
114
88
|
}
|
|
115
89
|
__name(getOwnIgnoreKey, "getOwnIgnoreKey");
|
|
116
|
-
function regisHandler(
|
|
117
|
-
init(
|
|
118
|
-
if (!
|
|
119
|
-
|
|
90
|
+
function regisHandler(proto, key, handler) {
|
|
91
|
+
init(proto);
|
|
92
|
+
if (!proto._namespace.__STATE_HANDLER__.has(key))
|
|
93
|
+
proto._namespace.__STATE_HANDLER__.set(key, [
|
|
120
94
|
handler
|
|
121
95
|
]);
|
|
122
96
|
else
|
|
123
|
-
|
|
97
|
+
proto._namespace.__STATE_HANDLER__.get(key).push(handler);
|
|
124
98
|
}
|
|
125
99
|
__name(regisHandler, "regisHandler");
|
|
126
|
-
function getOwnHandler(
|
|
127
|
-
if (!
|
|
100
|
+
function getOwnHandler(instance, key) {
|
|
101
|
+
if (!instance?._namespace)
|
|
128
102
|
return [];
|
|
129
|
-
return
|
|
103
|
+
return instance._namespace.__STATE_HANDLER__.get(key) || [];
|
|
130
104
|
}
|
|
131
105
|
__name(getOwnHandler, "getOwnHandler");
|
|
132
|
-
function getHandler(
|
|
133
|
-
let proto = Object.getPrototypeOf(
|
|
106
|
+
function getHandler(instance, key) {
|
|
107
|
+
let proto = Object.getPrototypeOf(instance);
|
|
134
108
|
const set = /* @__PURE__ */ new Set();
|
|
135
109
|
while (proto?._namespace) {
|
|
136
110
|
proto._namespace.__STATE_HANDLER__.get(key)?.forEach((item) => set.add(item));
|
|
@@ -141,19 +115,19 @@ function getHandler(target, key) {
|
|
|
141
115
|
];
|
|
142
116
|
}
|
|
143
117
|
__name(getHandler, "getHandler");
|
|
144
|
-
function setState(
|
|
145
|
-
init(
|
|
146
|
-
const namespace =
|
|
118
|
+
function setState(proto, key, state) {
|
|
119
|
+
init(proto);
|
|
120
|
+
const namespace = proto._namespace.__STATE_NAMESPACE__;
|
|
147
121
|
namespace.set(key, state);
|
|
148
122
|
}
|
|
149
123
|
__name(setState, "setState");
|
|
150
|
-
function getOwnState(
|
|
151
|
-
|
|
152
|
-
return
|
|
124
|
+
function getOwnState(instance, key) {
|
|
125
|
+
instance = Object.getPrototypeOf(instance);
|
|
126
|
+
return instance._namespace.__STATE_NAMESPACE__.get(key) || {};
|
|
153
127
|
}
|
|
154
128
|
__name(getOwnState, "getOwnState");
|
|
155
|
-
function getState(
|
|
156
|
-
let proto = Object.getPrototypeOf(
|
|
129
|
+
function getState(instance, key) {
|
|
130
|
+
let proto = Object.getPrototypeOf(instance);
|
|
157
131
|
let ret = {};
|
|
158
132
|
while (proto?._namespace) {
|
|
159
133
|
const state = proto._namespace.__STATE_NAMESPACE__.get(key);
|
|
@@ -167,38 +141,25 @@ function getState(target, key) {
|
|
|
167
141
|
return ret;
|
|
168
142
|
}
|
|
169
143
|
__name(getState, "getState");
|
|
170
|
-
function
|
|
144
|
+
function invokeHandler(event, instance) {
|
|
171
145
|
const stateVars = getExposeKey(instance);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
146
|
+
const initHandlers = stateVars.map((item) => {
|
|
147
|
+
return getHandler(instance, item).filter((h) => !!h[event]).map((h) => h[event](instance));
|
|
148
|
+
}).flat();
|
|
149
|
+
return Promise.all(initHandlers);
|
|
177
150
|
}
|
|
178
|
-
__name(
|
|
179
|
-
async function registerAsync(instance) {
|
|
180
|
-
const stateVars = getExposeKey(instance);
|
|
181
|
-
for (const item of stateVars) {
|
|
182
|
-
const handlers = getHandler(instance, item);
|
|
183
|
-
for (const hanlder of handlers)
|
|
184
|
-
await hanlder.init?.(instance);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
__name(registerAsync, "registerAsync");
|
|
151
|
+
__name(invokeHandler, "invokeHandler");
|
|
188
152
|
|
|
189
153
|
// src/helper.ts
|
|
190
|
-
function
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
function getBind(Model) {
|
|
200
|
-
const instance = new Model();
|
|
201
|
-
const keys = getModelState(instance);
|
|
154
|
+
function getTag2(moduleOrInstance) {
|
|
155
|
+
if (typeof moduleOrInstance === "object")
|
|
156
|
+
moduleOrInstance = moduleOrInstance.constructor;
|
|
157
|
+
return moduleOrInstance.prototype?.__TAG__ || moduleOrInstance.name;
|
|
158
|
+
}
|
|
159
|
+
__name(getTag2, "getTag");
|
|
160
|
+
function getBind(module) {
|
|
161
|
+
const instance = new module();
|
|
162
|
+
const keys = getModuleState(instance);
|
|
202
163
|
const ret = {};
|
|
203
164
|
for (const item of keys) {
|
|
204
165
|
const state = getState(instance, item);
|
|
@@ -208,8 +169,8 @@ function getBind(Model) {
|
|
|
208
169
|
return ret;
|
|
209
170
|
}
|
|
210
171
|
__name(getBind, "getBind");
|
|
211
|
-
function plainToClass(
|
|
212
|
-
const instance = new
|
|
172
|
+
function plainToClass(module, input) {
|
|
173
|
+
const instance = new module();
|
|
213
174
|
const keys = getExposeKey(instance);
|
|
214
175
|
for (const item of keys)
|
|
215
176
|
instance[item] = input[item];
|
|
@@ -218,7 +179,7 @@ function plainToClass(Model, input) {
|
|
|
218
179
|
__name(plainToClass, "plainToClass");
|
|
219
180
|
async function transformClass(instance, force = false) {
|
|
220
181
|
const err = [];
|
|
221
|
-
const stateVars =
|
|
182
|
+
const stateVars = getModuleState(instance);
|
|
222
183
|
for (const item of stateVars) {
|
|
223
184
|
const handlers = getHandler(instance, item);
|
|
224
185
|
if (handlers) {
|
|
@@ -262,8 +223,8 @@ function snapShot(data) {
|
|
|
262
223
|
};
|
|
263
224
|
}
|
|
264
225
|
__name(snapShot, "snapShot");
|
|
265
|
-
function addDecoToClass(c, key, handler, type = "
|
|
266
|
-
handler(type === "
|
|
226
|
+
function addDecoToClass(c, key, handler, type = "class") {
|
|
227
|
+
handler(type === "class" ? c.prototype : c, key);
|
|
267
228
|
}
|
|
268
229
|
__name(addDecoToClass, "addDecoToClass");
|
|
269
230
|
function Pipeline(...decos) {
|
|
@@ -275,74 +236,90 @@ function Pipeline(...decos) {
|
|
|
275
236
|
__name(Pipeline, "Pipeline");
|
|
276
237
|
|
|
277
238
|
// src/decorators.ts
|
|
278
|
-
function Init(
|
|
279
|
-
|
|
280
|
-
regisHandler(
|
|
239
|
+
function Init(proto, key) {
|
|
240
|
+
setVar(proto, key);
|
|
241
|
+
regisHandler(proto, key, {
|
|
281
242
|
async init(instance) {
|
|
282
|
-
instance[key]();
|
|
243
|
+
return instance[key]();
|
|
283
244
|
}
|
|
284
245
|
});
|
|
285
246
|
}
|
|
286
247
|
__name(Init, "Init");
|
|
248
|
+
function Unmount(proto, key) {
|
|
249
|
+
setVar(proto, key);
|
|
250
|
+
regisHandler(proto, key, {
|
|
251
|
+
async unmount(instance) {
|
|
252
|
+
return instance[key]();
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
__name(Unmount, "Unmount");
|
|
287
257
|
function Bind(value) {
|
|
288
|
-
return (
|
|
289
|
-
|
|
290
|
-
setState(
|
|
258
|
+
return (proto, k) => {
|
|
259
|
+
setVar(proto, k);
|
|
260
|
+
setState(proto, k, {
|
|
291
261
|
value
|
|
292
262
|
});
|
|
293
263
|
};
|
|
294
264
|
}
|
|
295
265
|
__name(Bind, "Bind");
|
|
296
|
-
function Ignore(
|
|
297
|
-
setIgnoreKey(
|
|
266
|
+
function Ignore(proto, key) {
|
|
267
|
+
setIgnoreKey(proto, key);
|
|
298
268
|
}
|
|
299
269
|
__name(Ignore, "Ignore");
|
|
300
|
-
function Clear(
|
|
301
|
-
init(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
target._namespace.__STATE_NAMESPACE__.delete(key);
|
|
270
|
+
function Clear(proto, key) {
|
|
271
|
+
init(proto);
|
|
272
|
+
proto._namespace.__EXPOSE_VAR__.delete(key);
|
|
273
|
+
proto._namespace.__IGNORE_VAR__.delete(key);
|
|
274
|
+
proto._namespace.__STATE_VAR__.delete(key);
|
|
275
|
+
proto._namespace.__STATE_HANDLER__.delete(key);
|
|
276
|
+
proto._namespace.__STATE_NAMESPACE__.delete(key);
|
|
308
277
|
}
|
|
309
278
|
__name(Clear, "Clear");
|
|
310
279
|
function Err(cb) {
|
|
311
|
-
return (
|
|
312
|
-
|
|
313
|
-
regisHandler(
|
|
280
|
+
return (proto, key) => {
|
|
281
|
+
setVar(proto, key);
|
|
282
|
+
regisHandler(proto, key, {
|
|
314
283
|
error: cb
|
|
315
284
|
});
|
|
316
285
|
};
|
|
317
286
|
}
|
|
318
287
|
__name(Err, "Err");
|
|
319
|
-
function Expose(
|
|
320
|
-
setExposeKey(
|
|
288
|
+
function Expose(proto, key) {
|
|
289
|
+
setExposeKey(proto, key);
|
|
321
290
|
}
|
|
322
291
|
__name(Expose, "Expose");
|
|
323
|
-
function To(
|
|
324
|
-
return (
|
|
325
|
-
|
|
326
|
-
regisHandler(
|
|
292
|
+
function To(...callbacks) {
|
|
293
|
+
return (proto, key) => {
|
|
294
|
+
setVar(proto, key);
|
|
295
|
+
regisHandler(proto, key, {
|
|
327
296
|
async pipe(instance) {
|
|
328
|
-
|
|
297
|
+
for (const cb of callbacks)
|
|
298
|
+
instance[key] = await cb(instance[key], instance, key);
|
|
329
299
|
}
|
|
330
300
|
});
|
|
331
301
|
};
|
|
332
302
|
}
|
|
333
303
|
__name(To, "To");
|
|
334
304
|
function Tag(tag) {
|
|
335
|
-
return (
|
|
336
|
-
init(
|
|
337
|
-
|
|
305
|
+
return (module) => {
|
|
306
|
+
init(module.prototype);
|
|
307
|
+
module.prototype.__TAG__ = tag;
|
|
338
308
|
};
|
|
339
309
|
}
|
|
340
310
|
__name(Tag, "Tag");
|
|
311
|
+
function Unique(desc) {
|
|
312
|
+
return (module) => {
|
|
313
|
+
init(module.prototype);
|
|
314
|
+
module.prototype.__TAG__ = Symbol(desc || module.name);
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
__name(Unique, "Unique");
|
|
341
318
|
function Assign(cb) {
|
|
342
|
-
return (
|
|
343
|
-
init(
|
|
344
|
-
|
|
345
|
-
regisHandler(
|
|
319
|
+
return (module) => {
|
|
320
|
+
init(module.prototype);
|
|
321
|
+
setVar(module.prototype, SHARE_KEY);
|
|
322
|
+
regisHandler(module.prototype, SHARE_KEY, {
|
|
346
323
|
init: async (instance) => {
|
|
347
324
|
const value = await cb(instance);
|
|
348
325
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -354,10 +331,10 @@ function Assign(cb) {
|
|
|
354
331
|
};
|
|
355
332
|
}
|
|
356
333
|
__name(Assign, "Assign");
|
|
357
|
-
function Global(
|
|
358
|
-
init(
|
|
359
|
-
|
|
360
|
-
regisHandler(
|
|
334
|
+
function Global(module) {
|
|
335
|
+
init(module.prototype);
|
|
336
|
+
setVar(module.prototype, SHARE_KEY);
|
|
337
|
+
regisHandler(module.prototype, SHARE_KEY, {
|
|
361
338
|
init: async (instance) => {
|
|
362
339
|
const tag = instance.__TAG__;
|
|
363
340
|
if (!tag)
|
|
@@ -369,8 +346,8 @@ function Global(target) {
|
|
|
369
346
|
});
|
|
370
347
|
}
|
|
371
348
|
__name(Global, "Global");
|
|
372
|
-
function Empty(
|
|
373
|
-
init(
|
|
349
|
+
function Empty(module) {
|
|
350
|
+
init(module.prototype);
|
|
374
351
|
}
|
|
375
352
|
__name(Empty, "Empty");
|
|
376
353
|
var DataMap = {};
|
|
@@ -387,9 +364,9 @@ function Inject(key) {
|
|
|
387
364
|
return DataMap[key] || EmptyProxy;
|
|
388
365
|
}
|
|
389
366
|
__name(Inject, "Inject");
|
|
390
|
-
function Nested(
|
|
367
|
+
function Nested(module) {
|
|
391
368
|
return To(async (property) => {
|
|
392
|
-
const instance = plainToClass(
|
|
369
|
+
const instance = plainToClass(module, property);
|
|
393
370
|
const err = await transformClass(instance);
|
|
394
371
|
if (err.length > 0)
|
|
395
372
|
throw new Error(err[0]);
|
|
@@ -397,8 +374,15 @@ function Nested(Model) {
|
|
|
397
374
|
});
|
|
398
375
|
}
|
|
399
376
|
__name(Nested, "Nested");
|
|
377
|
+
function Isolate() {
|
|
378
|
+
return (target) => {
|
|
379
|
+
init(target.prototype);
|
|
380
|
+
target.prototype.__ISOLATE__ = true;
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
__name(Isolate, "Isolate");
|
|
400
384
|
|
|
401
|
-
// src/
|
|
385
|
+
// src/custom/decorator.ts
|
|
402
386
|
var activeInstance = {};
|
|
403
387
|
function injectProperty(key, value) {
|
|
404
388
|
activeInstance[key] = value;
|
|
@@ -409,28 +393,30 @@ function getProperty(key) {
|
|
|
409
393
|
return activeInstance[key];
|
|
410
394
|
}
|
|
411
395
|
__name(getProperty, "getProperty");
|
|
412
|
-
|
|
413
|
-
// src/custom/decorator.ts
|
|
414
396
|
function Watcher(eventName, options) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
397
|
+
let cb;
|
|
398
|
+
return (proto, key) => {
|
|
399
|
+
setVar(proto, key);
|
|
400
|
+
regisHandler(proto, key, {
|
|
418
401
|
init(instance) {
|
|
419
|
-
getProperty("watcher")?.({
|
|
402
|
+
return cb = getProperty("watcher")?.({
|
|
420
403
|
eventName,
|
|
421
404
|
instance,
|
|
422
405
|
key,
|
|
423
406
|
options
|
|
424
407
|
});
|
|
408
|
+
},
|
|
409
|
+
unmount() {
|
|
410
|
+
return cb?.();
|
|
425
411
|
}
|
|
426
412
|
});
|
|
427
413
|
};
|
|
428
414
|
}
|
|
429
415
|
__name(Watcher, "Watcher");
|
|
430
416
|
function Effect(eventName, options) {
|
|
431
|
-
return (
|
|
432
|
-
|
|
433
|
-
regisHandler(
|
|
417
|
+
return (proto, key) => {
|
|
418
|
+
setVar(proto, key);
|
|
419
|
+
regisHandler(proto, key, {
|
|
434
420
|
init(instance) {
|
|
435
421
|
instance[`$_${key}`] = instance[key];
|
|
436
422
|
Object.defineProperty(instance, key, {
|
|
@@ -453,34 +439,40 @@ function Effect(eventName, options) {
|
|
|
453
439
|
};
|
|
454
440
|
}
|
|
455
441
|
__name(Effect, "Effect");
|
|
456
|
-
function Storage(storeKey) {
|
|
457
|
-
|
|
442
|
+
function Storage({ key: storeKey, toJSON, toString } = {}) {
|
|
443
|
+
if (!toJSON)
|
|
444
|
+
toJSON = /* @__PURE__ */ __name((v) => JSON.parse(v), "toJSON");
|
|
445
|
+
if (!toString)
|
|
446
|
+
toString = /* @__PURE__ */ __name((v) => JSON.stringify(v), "toString");
|
|
447
|
+
return (proto, key) => {
|
|
458
448
|
let tag;
|
|
459
449
|
if (key) {
|
|
460
|
-
init(
|
|
461
|
-
tag = storeKey ||
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
regisHandler(target, uniTag, {
|
|
450
|
+
init(proto);
|
|
451
|
+
tag = storeKey || `${getTag(proto)}_${key}`;
|
|
452
|
+
setVar(proto, key);
|
|
453
|
+
regisHandler(proto, key, {
|
|
465
454
|
init: (instance) => {
|
|
466
|
-
getProperty("storage")?.({
|
|
455
|
+
return getProperty("storage")?.({
|
|
467
456
|
instance,
|
|
468
457
|
key,
|
|
469
|
-
tag
|
|
458
|
+
tag,
|
|
459
|
+
toJSON,
|
|
460
|
+
toString
|
|
470
461
|
});
|
|
471
462
|
}
|
|
472
463
|
});
|
|
473
464
|
} else {
|
|
474
|
-
init(
|
|
475
|
-
tag = storeKey ||
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
regisHandler(target.prototype, uniTag, {
|
|
465
|
+
init(proto.prototype);
|
|
466
|
+
tag = storeKey || getTag(proto);
|
|
467
|
+
setVar(proto.prototype, SHARE_KEY);
|
|
468
|
+
regisHandler(proto.prototype, SHARE_KEY, {
|
|
479
469
|
init: (instance) => {
|
|
480
|
-
getProperty("storage")?.({
|
|
470
|
+
return getProperty("storage")?.({
|
|
481
471
|
instance,
|
|
482
|
-
key
|
|
483
|
-
tag
|
|
472
|
+
key,
|
|
473
|
+
tag,
|
|
474
|
+
toJSON,
|
|
475
|
+
toString
|
|
484
476
|
});
|
|
485
477
|
}
|
|
486
478
|
});
|
|
@@ -501,12 +493,16 @@ export {
|
|
|
501
493
|
Ignore,
|
|
502
494
|
Init,
|
|
503
495
|
Inject,
|
|
496
|
+
Isolate,
|
|
504
497
|
Nested,
|
|
505
498
|
Pipeline,
|
|
506
499
|
Provide,
|
|
500
|
+
SHARE_KEY,
|
|
507
501
|
Storage,
|
|
508
502
|
Tag,
|
|
509
503
|
To,
|
|
504
|
+
Unique,
|
|
505
|
+
Unmount,
|
|
510
506
|
Watcher,
|
|
511
507
|
activeInstance,
|
|
512
508
|
addDecoToClass,
|
|
@@ -514,30 +510,25 @@ export {
|
|
|
514
510
|
getBind,
|
|
515
511
|
getExposeKey,
|
|
516
512
|
getHandler,
|
|
517
|
-
|
|
518
|
-
getModelState,
|
|
513
|
+
getModuleState,
|
|
519
514
|
getOwnExposeKey,
|
|
520
515
|
getOwnHandler,
|
|
521
516
|
getOwnIgnoreKey,
|
|
522
|
-
|
|
523
|
-
getOwnModelState,
|
|
517
|
+
getOwnModuleState,
|
|
524
518
|
getOwnState,
|
|
525
519
|
getProperty,
|
|
526
520
|
getState,
|
|
527
|
-
|
|
528
|
-
getTag,
|
|
521
|
+
getTag2 as getTag,
|
|
529
522
|
init,
|
|
530
523
|
injectProperty,
|
|
524
|
+
invokeHandler,
|
|
531
525
|
isPhecda,
|
|
532
526
|
plainToClass,
|
|
533
527
|
regisHandler,
|
|
534
|
-
regisInitEvent,
|
|
535
|
-
register,
|
|
536
|
-
registerAsync,
|
|
537
528
|
setExposeKey,
|
|
538
529
|
setIgnoreKey,
|
|
539
|
-
setModelVar,
|
|
540
530
|
setState,
|
|
531
|
+
setVar,
|
|
541
532
|
snapShot,
|
|
542
533
|
transformClass
|
|
543
534
|
};
|