phecda-core 3.0.0-alpha.8 → 3.0.0-alpha.9
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 +2 -4
- package/dist/index.js +7 -28
- package/dist/index.mjs +5 -24
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -74,9 +74,7 @@ declare function getHandler(instance: Phecda, key: PropertyKey): any[];
|
|
|
74
74
|
declare function setState(proto: Phecda, key: PropertyKey, state: Record<string, any>): void;
|
|
75
75
|
declare function getOwnState(instance: Phecda, key: PropertyKey): Object;
|
|
76
76
|
declare function getState(instance: Phecda, key: PropertyKey): any;
|
|
77
|
-
declare function
|
|
78
|
-
declare function registerSerial(instance: Phecda): Promise<void>;
|
|
79
|
-
declare function unmountParallel(instance: Phecda): Promise<any[]>;
|
|
77
|
+
declare function invokeHandler(event: string, instance: Phecda): Promise<any[]>;
|
|
80
78
|
|
|
81
79
|
declare const activeInstance: Record<string, any>;
|
|
82
80
|
declare function injectProperty(key: string, value: any): Record<string, any>;
|
|
@@ -87,4 +85,4 @@ declare function Watcher(eventName: keyof Events, options?: {
|
|
|
87
85
|
declare function Effect(eventName: string, options?: any): (proto: any, key: string) => void;
|
|
88
86
|
declare function Storage(storeKey?: string): (proto: any, key?: PropertyKey) => void;
|
|
89
87
|
|
|
90
|
-
export { AbConstruct, Assign, Bind, ClassValue, Clear, Construct, DataMap, Effect, Empty, Err, Events, Expose, Global, Handler, Ignore, Init, Inject, InjectData, Isolate, NameSpace, Nested, Phecda, Pipeline, Provide, SHARE_KEY, Storage, Tag, To, Unique, Unmount, Watcher, activeInstance, addDecoToClass, classToValue, getBind, getExposeKey, getHandler, getModuleState, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnModuleState, getOwnState, getProperty, getState, getTag, init, injectProperty, isPhecda, plainToClass, regisHandler,
|
|
88
|
+
export { AbConstruct, Assign, Bind, ClassValue, Clear, Construct, DataMap, Effect, Empty, Err, Events, Expose, Global, Handler, Ignore, Init, Inject, InjectData, Isolate, NameSpace, Nested, Phecda, Pipeline, Provide, SHARE_KEY, Storage, Tag, To, Unique, Unmount, Watcher, activeInstance, addDecoToClass, classToValue, getBind, getExposeKey, getHandler, getModuleState, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnModuleState, getOwnState, getProperty, getState, getTag, init, injectProperty, invokeHandler, isPhecda, plainToClass, regisHandler, setExposeKey, setIgnoreKey, setState, setVar, snapShot, transformClass };
|
package/dist/index.js
CHANGED
|
@@ -61,18 +61,16 @@ __export(src_exports, {
|
|
|
61
61
|
getTag: () => getTag,
|
|
62
62
|
init: () => init,
|
|
63
63
|
injectProperty: () => injectProperty,
|
|
64
|
+
invokeHandler: () => invokeHandler,
|
|
64
65
|
isPhecda: () => isPhecda,
|
|
65
66
|
plainToClass: () => plainToClass,
|
|
66
67
|
regisHandler: () => regisHandler,
|
|
67
|
-
registerParallel: () => registerParallel,
|
|
68
|
-
registerSerial: () => registerSerial,
|
|
69
68
|
setExposeKey: () => setExposeKey,
|
|
70
69
|
setIgnoreKey: () => setIgnoreKey,
|
|
71
70
|
setState: () => setState,
|
|
72
71
|
setVar: () => setVar,
|
|
73
72
|
snapShot: () => snapShot,
|
|
74
|
-
transformClass: () => transformClass
|
|
75
|
-
unmountParallel: () => unmountParallel
|
|
73
|
+
transformClass: () => transformClass
|
|
76
74
|
});
|
|
77
75
|
module.exports = __toCommonJS(src_exports);
|
|
78
76
|
|
|
@@ -216,31 +214,14 @@ function getState(instance, key) {
|
|
|
216
214
|
return ret;
|
|
217
215
|
}
|
|
218
216
|
__name(getState, "getState");
|
|
219
|
-
function
|
|
217
|
+
function invokeHandler(event, instance) {
|
|
220
218
|
const stateVars = getExposeKey(instance);
|
|
221
219
|
const initHandlers = stateVars.map((item) => {
|
|
222
|
-
return getHandler(instance, item).filter((h) => h
|
|
220
|
+
return getHandler(instance, item).filter((h) => h[event]).map((h) => h[event](instance));
|
|
223
221
|
}).flat();
|
|
224
222
|
return Promise.all(initHandlers);
|
|
225
223
|
}
|
|
226
|
-
__name(
|
|
227
|
-
async function registerSerial(instance) {
|
|
228
|
-
const stateVars = getExposeKey(instance);
|
|
229
|
-
for (const item of stateVars) {
|
|
230
|
-
const handlers = getHandler(instance, item);
|
|
231
|
-
for (const hanlder of handlers)
|
|
232
|
-
await hanlder.init?.(instance);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
__name(registerSerial, "registerSerial");
|
|
236
|
-
function unmountParallel(instance) {
|
|
237
|
-
const stateVars = getExposeKey(instance);
|
|
238
|
-
const initHandlers = stateVars.map((item) => {
|
|
239
|
-
return getHandler(instance, item).filter((h) => h.unmount).map((h) => h.init(instance));
|
|
240
|
-
}).flat();
|
|
241
|
-
return Promise.all(initHandlers);
|
|
242
|
-
}
|
|
243
|
-
__name(unmountParallel, "unmountParallel");
|
|
224
|
+
__name(invokeHandler, "invokeHandler");
|
|
244
225
|
|
|
245
226
|
// src/helper.ts
|
|
246
227
|
function getTag(moduleOrInstance) {
|
|
@@ -607,16 +588,14 @@ __name(Storage, "Storage");
|
|
|
607
588
|
getTag,
|
|
608
589
|
init,
|
|
609
590
|
injectProperty,
|
|
591
|
+
invokeHandler,
|
|
610
592
|
isPhecda,
|
|
611
593
|
plainToClass,
|
|
612
594
|
regisHandler,
|
|
613
|
-
registerParallel,
|
|
614
|
-
registerSerial,
|
|
615
595
|
setExposeKey,
|
|
616
596
|
setIgnoreKey,
|
|
617
597
|
setState,
|
|
618
598
|
setVar,
|
|
619
599
|
snapShot,
|
|
620
|
-
transformClass
|
|
621
|
-
unmountParallel
|
|
600
|
+
transformClass
|
|
622
601
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -141,31 +141,14 @@ function getState(instance, key) {
|
|
|
141
141
|
return ret;
|
|
142
142
|
}
|
|
143
143
|
__name(getState, "getState");
|
|
144
|
-
function
|
|
144
|
+
function invokeHandler(event, instance) {
|
|
145
145
|
const stateVars = getExposeKey(instance);
|
|
146
146
|
const initHandlers = stateVars.map((item) => {
|
|
147
|
-
return getHandler(instance, item).filter((h) => h
|
|
147
|
+
return getHandler(instance, item).filter((h) => h[event]).map((h) => h[event](instance));
|
|
148
148
|
}).flat();
|
|
149
149
|
return Promise.all(initHandlers);
|
|
150
150
|
}
|
|
151
|
-
__name(
|
|
152
|
-
async function registerSerial(instance) {
|
|
153
|
-
const stateVars = getExposeKey(instance);
|
|
154
|
-
for (const item of stateVars) {
|
|
155
|
-
const handlers = getHandler(instance, item);
|
|
156
|
-
for (const hanlder of handlers)
|
|
157
|
-
await hanlder.init?.(instance);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
__name(registerSerial, "registerSerial");
|
|
161
|
-
function unmountParallel(instance) {
|
|
162
|
-
const stateVars = getExposeKey(instance);
|
|
163
|
-
const initHandlers = stateVars.map((item) => {
|
|
164
|
-
return getHandler(instance, item).filter((h) => h.unmount).map((h) => h.init(instance));
|
|
165
|
-
}).flat();
|
|
166
|
-
return Promise.all(initHandlers);
|
|
167
|
-
}
|
|
168
|
-
__name(unmountParallel, "unmountParallel");
|
|
151
|
+
__name(invokeHandler, "invokeHandler");
|
|
169
152
|
|
|
170
153
|
// src/helper.ts
|
|
171
154
|
function getTag(moduleOrInstance) {
|
|
@@ -531,16 +514,14 @@ export {
|
|
|
531
514
|
getTag,
|
|
532
515
|
init,
|
|
533
516
|
injectProperty,
|
|
517
|
+
invokeHandler,
|
|
534
518
|
isPhecda,
|
|
535
519
|
plainToClass,
|
|
536
520
|
regisHandler,
|
|
537
|
-
registerParallel,
|
|
538
|
-
registerSerial,
|
|
539
521
|
setExposeKey,
|
|
540
522
|
setIgnoreKey,
|
|
541
523
|
setState,
|
|
542
524
|
setVar,
|
|
543
525
|
snapShot,
|
|
544
|
-
transformClass
|
|
545
|
-
unmountParallel
|
|
526
|
+
transformClass
|
|
546
527
|
};
|