@wirestate/core 0.7.0-experimental.1 → 0.7.0-experimental.3
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/CHANGELOG.md +8 -2
- package/README.md +2 -2
- package/cjs/development/index.js +28 -26
- package/cjs/development/index.js.map +1 -1
- package/cjs/development/lib.js +234 -288
- package/cjs/development/lib.js.map +1 -1
- package/cjs/development/test-utils.js +22 -38
- package/cjs/development/test-utils.js.map +1 -1
- package/cjs/production/index.js +1 -1
- package/cjs/production/index.js.map +1 -1
- package/cjs/production/lib.js +1 -1
- package/cjs/production/lib.js.map +1 -1
- package/cjs/production/test-utils.js +1 -1
- package/cjs/production/test-utils.js.map +1 -1
- package/esm/development/bind/bind-dynamic-value.js +1 -1
- package/esm/development/bind/bind-dynamic-value.js.map +1 -1
- package/esm/development/bind/bind-entry.js +1 -4
- package/esm/development/bind/bind-entry.js.map +1 -1
- package/esm/development/bind/bind-service.js +40 -54
- package/esm/development/bind/bind-service.js.map +1 -1
- package/esm/development/commands/command-bus.js +33 -42
- package/esm/development/commands/command-bus.js.map +1 -1
- package/esm/development/commands/get-command-handler-metadata.js +3 -3
- package/esm/development/commands/get-command-handler-metadata.js.map +1 -1
- package/esm/development/commands/on-command.js +4 -4
- package/esm/development/commands/on-command.js.map +1 -1
- package/esm/development/container/create-base-container.js +2 -3
- package/esm/development/container/create-base-container.js.map +1 -1
- package/esm/development/container/create-container.js +10 -19
- package/esm/development/container/create-container.js.map +1 -1
- package/esm/development/container/wire-scope.js +41 -42
- package/esm/development/container/wire-scope.js.map +1 -1
- package/esm/development/error/error-code.js +8 -8
- package/esm/development/error/error-code.js.map +1 -1
- package/esm/development/error/wirestate-error.js +18 -17
- package/esm/development/error/wirestate-error.js.map +1 -1
- package/esm/development/events/build-event-dispatcher.js +5 -7
- package/esm/development/events/build-event-dispatcher.js.map +1 -1
- package/esm/development/events/emit-event.js +3 -3
- package/esm/development/events/emit-event.js.map +1 -1
- package/esm/development/events/event-bus.js +16 -23
- package/esm/development/events/event-bus.js.map +1 -1
- package/esm/development/events/get-event-handler-metadata.js +3 -3
- package/esm/development/events/get-event-handler-metadata.js.map +1 -1
- package/esm/development/events/on-event.js +4 -5
- package/esm/development/events/on-event.js.map +1 -1
- package/esm/development/queries/get-query-handler-metadata.js +3 -3
- package/esm/development/queries/get-query-handler-metadata.js.map +1 -1
- package/esm/development/queries/on-query.js +4 -4
- package/esm/development/queries/on-query.js.map +1 -1
- package/esm/development/queries/query-bus.js +29 -35
- package/esm/development/queries/query-bus.js.map +1 -1
- package/esm/development/registry.js +10 -10
- package/esm/development/registry.js.map +1 -1
- package/esm/development/seeds/apply-seeds.js +2 -5
- package/esm/development/seeds/apply-seeds.js.map +1 -1
- package/esm/development/seeds/tokens.js +2 -2
- package/esm/development/seeds/tokens.js.map +1 -1
- package/esm/development/seeds/unapply-seeds.js +2 -3
- package/esm/development/seeds/unapply-seeds.js.map +1 -1
- package/esm/development/service/get-activated-handler-metadata.js +3 -3
- package/esm/development/service/get-activated-handler-metadata.js.map +1 -1
- package/esm/development/service/get-deactivation-handler-metadata.js +3 -3
- package/esm/development/service/get-deactivation-handler-metadata.js.map +1 -1
- package/esm/development/service/on-activated.js +3 -3
- package/esm/development/service/on-activated.js.map +1 -1
- package/esm/development/service/on-deactivation.js +3 -3
- package/esm/development/service/on-deactivation.js.map +1 -1
- package/esm/development/test-utils/mock-bind-entry.js +4 -5
- package/esm/development/test-utils/mock-bind-entry.js.map +1 -1
- package/esm/development/test-utils/mock-bind-service.js +4 -5
- package/esm/development/test-utils/mock-bind-service.js.map +1 -1
- package/esm/development/test-utils/mock-container.js +13 -21
- package/esm/development/test-utils/mock-container.js.map +1 -1
- package/esm/development/test-utils/mock-service.js +1 -7
- package/esm/development/test-utils/mock-service.js.map +1 -1
- package/esm/production/bind/bind-dynamic-value.js +1 -1
- package/esm/production/bind/bind-dynamic-value.js.map +1 -1
- package/esm/production/bind/bind-entry.js +1 -1
- package/esm/production/bind/bind-entry.js.map +1 -1
- package/esm/production/bind/bind-service.js +1 -1
- package/esm/production/bind/bind-service.js.map +1 -1
- package/esm/production/commands/command-bus.js +1 -1
- package/esm/production/commands/command-bus.js.map +1 -1
- package/esm/production/commands/get-command-handler-metadata.js +1 -1
- package/esm/production/commands/get-command-handler-metadata.js.map +1 -1
- package/esm/production/commands/on-command.js +1 -1
- package/esm/production/commands/on-command.js.map +1 -1
- package/esm/production/container/create-base-container.js +1 -1
- package/esm/production/container/create-base-container.js.map +1 -1
- package/esm/production/container/create-container.js +1 -1
- package/esm/production/container/create-container.js.map +1 -1
- package/esm/production/container/wire-scope.js +1 -1
- package/esm/production/container/wire-scope.js.map +1 -1
- package/esm/production/error/error-code.js +1 -1
- package/esm/production/error/error-code.js.map +1 -1
- package/esm/production/error/wirestate-error.js +1 -1
- package/esm/production/error/wirestate-error.js.map +1 -1
- package/esm/production/events/build-event-dispatcher.js +1 -1
- package/esm/production/events/build-event-dispatcher.js.map +1 -1
- package/esm/production/events/emit-event.js.map +1 -1
- package/esm/production/events/event-bus.js +1 -1
- package/esm/production/events/event-bus.js.map +1 -1
- package/esm/production/events/get-event-handler-metadata.js +1 -1
- package/esm/production/events/get-event-handler-metadata.js.map +1 -1
- package/esm/production/events/on-event.js +1 -1
- package/esm/production/events/on-event.js.map +1 -1
- package/esm/production/queries/get-query-handler-metadata.js +1 -1
- package/esm/production/queries/get-query-handler-metadata.js.map +1 -1
- package/esm/production/queries/on-query.js +1 -1
- package/esm/production/queries/on-query.js.map +1 -1
- package/esm/production/queries/query-bus.js +1 -1
- package/esm/production/queries/query-bus.js.map +1 -1
- package/esm/production/registry.js +1 -1
- package/esm/production/registry.js.map +1 -1
- package/esm/production/seeds/apply-seeds.js +1 -1
- package/esm/production/seeds/apply-seeds.js.map +1 -1
- package/esm/production/seeds/tokens.js +1 -1
- package/esm/production/seeds/tokens.js.map +1 -1
- package/esm/production/seeds/unapply-seeds.js +1 -1
- package/esm/production/seeds/unapply-seeds.js.map +1 -1
- package/esm/production/service/get-activated-handler-metadata.js +1 -1
- package/esm/production/service/get-activated-handler-metadata.js.map +1 -1
- package/esm/production/service/get-deactivation-handler-metadata.js +1 -1
- package/esm/production/service/get-deactivation-handler-metadata.js.map +1 -1
- package/esm/production/service/on-activated.js +1 -1
- package/esm/production/service/on-activated.js.map +1 -1
- package/esm/production/service/on-deactivation.js +1 -1
- package/esm/production/service/on-deactivation.js.map +1 -1
- package/esm/production/test-utils/mock-bind-entry.js +1 -1
- package/esm/production/test-utils/mock-bind-entry.js.map +1 -1
- package/esm/production/test-utils/mock-bind-service.js +1 -1
- package/esm/production/test-utils/mock-bind-service.js.map +1 -1
- package/esm/production/test-utils/mock-container.js +1 -1
- package/esm/production/test-utils/mock-container.js.map +1 -1
- package/esm/production/test-utils/mock-service.js +1 -1
- package/esm/production/test-utils/mock-service.js.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -18,13 +18,13 @@ import { SEEDS_TOKEN, SEED_TOKEN } from '../seeds/tokens.js';
|
|
|
18
18
|
*
|
|
19
19
|
* @group Container
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
let WireScope = class WireScope {
|
|
22
|
+
/**
|
|
23
|
+
* Whether the scope was deactivated and disposed from the container.
|
|
24
|
+
*/
|
|
25
|
+
isDisposed = false;
|
|
26
|
+
constructor(container) {
|
|
23
27
|
this.container = container;
|
|
24
|
-
/**
|
|
25
|
-
* Whether the scope was deactivated and disposed from the container.
|
|
26
|
-
*/
|
|
27
|
-
this.isDisposed = false;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Provides direct access to the underlying Inversify {@link Container}.
|
|
@@ -40,7 +40,7 @@ var WireScope = /** @class */function () {
|
|
|
40
40
|
* container.bind("TOKEN").toConstantValue(42);
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
getContainer() {
|
|
44
44
|
if (this.container) {
|
|
45
45
|
return this.container;
|
|
46
46
|
}
|
|
@@ -49,7 +49,7 @@ var WireScope = /** @class */function () {
|
|
|
49
49
|
} else {
|
|
50
50
|
throw new WirestateError(ERROR_CODE_ACCESS_BEFORE_ACTIVATION, "WireScope::container accessed before activation. " + "Ensure service is bound to container and is properly resolved.");
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|
|
53
53
|
/**
|
|
54
54
|
* Lazily resolves a service or value from the container.
|
|
55
55
|
*
|
|
@@ -69,9 +69,9 @@ var WireScope = /** @class */function () {
|
|
|
69
69
|
* const service: MyService = scope.resolve(MyService);
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
resolve(injectionId) {
|
|
73
73
|
return this.getContainer().get(injectionId);
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
75
|
/**
|
|
76
76
|
* Lazily resolves a service if it is bound, otherwise returns null.
|
|
77
77
|
*
|
|
@@ -89,10 +89,10 @@ var WireScope = /** @class */function () {
|
|
|
89
89
|
* logger?.info("Resolved optionally");
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
resolveOptional(injectionId) {
|
|
93
|
+
const container = this.getContainer();
|
|
94
94
|
return container.isBound(injectionId) ? container.get(injectionId) : null;
|
|
95
|
-
}
|
|
95
|
+
}
|
|
96
96
|
/**
|
|
97
97
|
* Dispatches an event to the {@link EventBus}.
|
|
98
98
|
*
|
|
@@ -110,13 +110,13 @@ var WireScope = /** @class */function () {
|
|
|
110
110
|
* scope.emitEvent("VALUE_CHANGED", { value: "abcd" });
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
113
|
-
|
|
113
|
+
emitEvent(type, payload, from) {
|
|
114
114
|
this.getContainer().get(EventBus).emit({
|
|
115
|
-
type
|
|
116
|
-
payload
|
|
115
|
+
type,
|
|
116
|
+
payload,
|
|
117
117
|
from: from === undefined ? this : from
|
|
118
118
|
});
|
|
119
|
-
}
|
|
119
|
+
}
|
|
120
120
|
/**
|
|
121
121
|
* Subscribes to all events on the {@link EventBus}.
|
|
122
122
|
*
|
|
@@ -132,9 +132,9 @@ var WireScope = /** @class */function () {
|
|
|
132
132
|
* });
|
|
133
133
|
* ```
|
|
134
134
|
*/
|
|
135
|
-
|
|
135
|
+
subscribeToEvent(handler) {
|
|
136
136
|
return this.getContainer().get(EventBus).subscribe(handler);
|
|
137
|
-
}
|
|
137
|
+
}
|
|
138
138
|
/**
|
|
139
139
|
* Unsubscribes a specific handler from the {@link EventBus}.
|
|
140
140
|
*
|
|
@@ -147,9 +147,9 @@ var WireScope = /** @class */function () {
|
|
|
147
147
|
* scope.unsubscribeFromEvent(this.onEvent);
|
|
148
148
|
* ```
|
|
149
149
|
*/
|
|
150
|
-
|
|
150
|
+
unsubscribeFromEvent(handler) {
|
|
151
151
|
this.getContainer().get(EventBus).unsubscribe(handler);
|
|
152
|
-
}
|
|
152
|
+
}
|
|
153
153
|
/**
|
|
154
154
|
* Dispatches a query and waits for the result.
|
|
155
155
|
*
|
|
@@ -169,9 +169,9 @@ var WireScope = /** @class */function () {
|
|
|
169
169
|
* const user: User = await scope.queryData("GET_USER", { id: 1 });
|
|
170
170
|
* ```
|
|
171
171
|
*/
|
|
172
|
-
|
|
172
|
+
queryData(type, data) {
|
|
173
173
|
return this.getContainer().get(QueryBus).query(type, data);
|
|
174
|
-
}
|
|
174
|
+
}
|
|
175
175
|
/**
|
|
176
176
|
* Dispatches a query and returns the result, or null if no handler is registered.
|
|
177
177
|
*
|
|
@@ -190,9 +190,9 @@ var WireScope = /** @class */function () {
|
|
|
190
190
|
* const config: Config | null = await scope.queryOptionalData("GET_CONFIG");
|
|
191
191
|
* ```
|
|
192
192
|
*/
|
|
193
|
-
|
|
193
|
+
queryOptionalData(type, data) {
|
|
194
194
|
return this.getContainer().get(QueryBus).queryOptional(type, data);
|
|
195
|
-
}
|
|
195
|
+
}
|
|
196
196
|
/**
|
|
197
197
|
* Registers a handler for a specific query type.
|
|
198
198
|
*
|
|
@@ -210,9 +210,9 @@ var WireScope = /** @class */function () {
|
|
|
210
210
|
* scope.registerQueryHandler("GET_DATE_NOW", () => new Date());
|
|
211
211
|
* ```
|
|
212
212
|
*/
|
|
213
|
-
|
|
213
|
+
registerQueryHandler(type, handler) {
|
|
214
214
|
return this.getContainer().get(QueryBus).register(type, handler);
|
|
215
|
-
}
|
|
215
|
+
}
|
|
216
216
|
/**
|
|
217
217
|
* Removes a specific query handler registration.
|
|
218
218
|
*
|
|
@@ -229,9 +229,9 @@ var WireScope = /** @class */function () {
|
|
|
229
229
|
* scope.unregisterQueryHandler("GET_DATE_NOW", this.onGetDateNow);
|
|
230
230
|
* ```
|
|
231
231
|
*/
|
|
232
|
-
|
|
232
|
+
unregisterQueryHandler(type, handler) {
|
|
233
233
|
this.getContainer().get(QueryBus).unregister(type, handler);
|
|
234
|
-
}
|
|
234
|
+
}
|
|
235
235
|
/**
|
|
236
236
|
* Dispatches a command and returns a descriptor to track its progress.
|
|
237
237
|
*
|
|
@@ -253,9 +253,9 @@ var WireScope = /** @class */function () {
|
|
|
253
253
|
* await descriptor.task;
|
|
254
254
|
* ```
|
|
255
255
|
*/
|
|
256
|
-
|
|
256
|
+
executeCommand(type, data) {
|
|
257
257
|
return this.getContainer().get(CommandBus).command(type, data);
|
|
258
|
-
}
|
|
258
|
+
}
|
|
259
259
|
/**
|
|
260
260
|
* Dispatches a command if a handler is registered, otherwise returns null.
|
|
261
261
|
*
|
|
@@ -278,9 +278,9 @@ var WireScope = /** @class */function () {
|
|
|
278
278
|
* }
|
|
279
279
|
* ```
|
|
280
280
|
*/
|
|
281
|
-
|
|
281
|
+
executeOptionalCommand(type, data) {
|
|
282
282
|
return this.getContainer().get(CommandBus).commandOptional(type, data);
|
|
283
|
-
}
|
|
283
|
+
}
|
|
284
284
|
/**
|
|
285
285
|
* Registers a handler for a specific command type.
|
|
286
286
|
*
|
|
@@ -300,9 +300,9 @@ var WireScope = /** @class */function () {
|
|
|
300
300
|
* });
|
|
301
301
|
* ```
|
|
302
302
|
*/
|
|
303
|
-
|
|
303
|
+
registerCommandHandler(type, handler) {
|
|
304
304
|
return this.getContainer().get(CommandBus).register(type, handler);
|
|
305
|
-
}
|
|
305
|
+
}
|
|
306
306
|
/**
|
|
307
307
|
* Removes a specific command handler registration.
|
|
308
308
|
*
|
|
@@ -319,15 +319,14 @@ var WireScope = /** @class */function () {
|
|
|
319
319
|
* scope.unregisterCommandHandler("LOG_ERROR", this.handleLogError);
|
|
320
320
|
* ```
|
|
321
321
|
*/
|
|
322
|
-
|
|
322
|
+
unregisterCommandHandler(type, handler) {
|
|
323
323
|
this.getContainer().get(CommandBus).unregister(type, handler);
|
|
324
|
-
}
|
|
325
|
-
|
|
324
|
+
}
|
|
325
|
+
getSeed(seed) {
|
|
326
326
|
return seed ? this.getContainer().get(SEEDS_TOKEN).get(seed) || null : this.getContainer().get(SEED_TOKEN);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}();
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
WireScope = __decorate([injectable(), __metadata("design:paramtypes", [Object])], WireScope);
|
|
331
330
|
|
|
332
331
|
export { WireScope };
|
|
333
332
|
//# sourceMappingURL=wire-scope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-scope.js","sources":["../../../../../../../../src/wirestate-core/container/wire-scope.ts"],"sourcesContent":[null],"names":["WireScope","
|
|
1
|
+
{"version":3,"file":"wire-scope.js","sources":["../../../../../../../../src/wirestate-core/container/wire-scope.ts"],"sourcesContent":[null],"names":["WireScope","isDisposed","constructor","container","getContainer","WirestateError","ERROR_CODE_ACCESS_AFTER_DISPOSAL","ERROR_CODE_ACCESS_BEFORE_ACTIVATION","resolve","injectionId","get","resolveOptional","isBound","emitEvent","type","payload","from","EventBus","emit","undefined","subscribeToEvent","handler","subscribe","unsubscribeFromEvent","unsubscribe","queryData","data","QueryBus","query","queryOptionalData","queryOptional","registerQueryHandler","register","unregisterQueryHandler","unregister","executeCommand","CommandBus","command","executeOptionalCommand","commandOptional","registerCommandHandler","unregisterCommandHandler","getSeed","seed","SEEDS_TOKEN","SEED_TOKEN","__decorate","injectable"],"mappings":";;;;;;;;;AAiBA;;;;;;;;;;AAUG;AAEI,IAAMA,SAAS,GAAf,MAAMA,SAAS,CAAA;AACpB;;AAEG;AACaC,EAAAA,UAAU,GAAY,KAAK;EAE3CC,WAAAA,CAAoCC,SAA8B,EAAA;IAA9B,IAAA,CAAAA,SAAS,GAATA,SAAS;AAAwB,EAAA;AAErE;;;;;;;;;;;;;AAaG;AACIC,EAAAA,YAAYA,GAAA;IACjB,IAAI,IAAI,CAACD,SAAS,EAAE;MAClB,OAAO,IAAI,CAACA,SAAS;AACvB,IAAA;IAEA,IAAI,IAAI,CAACF,UAAU,EAAE;AACnB,MAAA,MAAM,IAAII,cAAc,CACtBC,gCAAgC,EAChC,wFAAwF,CACzF;AACH,IAAA,CAAC,MAAM;MACL,MAAM,IAAID,cAAc,CACtBE,mCAAmC,EACnC,mDAAmD,GACjD,gEAAgE,CACnE;AACH,IAAA;AACF,EAAA;AAEA;;;;;;;;;;;;;;;;;;AAkBG;EACIC,OAAOA,CAAIC,WAAiC,EAAA;IAMjD,OAAO,IAAI,CAACL,YAAY,EAAE,CAACM,GAAG,CAAID,WAAW,CAAC;AAChD,EAAA;AAEA;;;;;;;;;;;;;;;;AAgBG;EACIE,eAAeA,CAAIF,WAAiC,EAAA;AAMzD,IAAA,MAAMN,SAAS,GAAc,IAAI,CAACC,YAAY,EAAE;AAEhD,IAAA,OAAOD,SAAS,CAACS,OAAO,CAACH,WAAW,CAAC,GAAGN,SAAS,CAACO,GAAG,CAAID,WAAW,CAAC,GAAG,IAAI;AAC9E,EAAA;AAEA;;;;;;;;;;;;;;;;AAgBG;AACII,EAAAA,SAASA,CAAqCC,IAAO,EAAEC,OAAW,EAAEC,IAAc,EAAA;IAOvF,IAAI,CAACZ,YAAY,EAAE,CAChBM,GAAG,CAACO,QAAQ,CAAC,CACbC,IAAI,CAAC;MACJJ,IAAI;MACJC,OAAO;AACPC,MAAAA,IAAI,EAAEA,IAAI,KAAKG,SAAS,GAAG,IAAI,GAAGH;AACnC,KAAA,CAAC;AACN,EAAA;AAEA;;;;;;;;;;;;;;AAcG;EACII,gBAAgBA,CAACC,OAAqB,EAAA;AAG3C,IAAA,OAAO,IAAI,CAACjB,YAAY,EAAE,CAACM,GAAG,CAACO,QAAQ,CAAC,CAACK,SAAS,CAACD,OAAO,CAAC;AAC7D,EAAA;AAEA;;;;;;;;;;;AAWG;EACIE,oBAAoBA,CAACF,OAAqB,EAAA;AAG/C,IAAA,IAAI,CAACjB,YAAY,EAAE,CAACM,GAAG,CAACO,QAAQ,CAAC,CAACO,WAAW,CAACH,OAAO,CAAC;AACxD,EAAA;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACII,EAAAA,SAASA,CAA4DX,IAAO,EAAEY,IAAQ,EAAA;AAG3F,IAAA,OAAO,IAAI,CAACtB,YAAY,EAAE,CAACM,GAAG,CAACiB,QAAQ,CAAC,CAACC,KAAK,CAAOd,IAAI,EAAEY,IAAI,CAAC;AAClE,EAAA;AAEA;;;;;;;;;;;;;;;;;AAiBG;AACIG,EAAAA,iBAAiBA,CACtBf,IAAO,EACPY,IAAQ,EAAA;AAIR,IAAA,OAAO,IAAI,CAACtB,YAAY,EAAE,CAACM,GAAG,CAACiB,QAAQ,CAAC,CAACG,aAAa,CAAOhB,IAAI,EAAEY,IAAI,CAAC;AAC1E,EAAA;AAEA;;;;;;;;;;;;;;;;AAgBG;AACIK,EAAAA,oBAAoBA,CAA2BjB,IAAe,EAAEO,OAA2B,EAAA;AAGhG,IAAA,OAAO,IAAI,CAACjB,YAAY,EAAE,CAACM,GAAG,CAACiB,QAAQ,CAAC,CAACK,QAAQ,CAAClB,IAAI,EAAEO,OAAO,CAAC;AAClE,EAAA;AAEA;;;;;;;;;;;;;;;AAeG;AACIY,EAAAA,sBAAsBA,CAA2BnB,IAAe,EAAEO,OAA2B,EAAA;AAGlG,IAAA,IAAI,CAACjB,YAAY,EAAE,CAACM,GAAG,CAACiB,QAAQ,CAAC,CAACO,UAAU,CAACpB,IAAI,EAAEO,OAAO,CAAC;AAC7D,EAAA;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACIc,EAAAA,cAAcA,CACnBrB,IAAO,EACPY,IAAQ,EAAA;AAIR,IAAA,OAAO,IAAI,CAACtB,YAAY,EAAE,CAACM,GAAG,CAAC0B,UAAU,CAAC,CAACC,OAAO,CAAOvB,IAAI,EAAEY,IAAI,CAAC;AACtE,EAAA;AAEA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACIY,EAAAA,sBAAsBA,CAC3BxB,IAAO,EACPY,IAAQ,EAAA;AAIR,IAAA,OAAO,IAAI,CAACtB,YAAY,EAAE,CAACM,GAAG,CAAC0B,UAAU,CAAC,CAACG,eAAe,CAAOzB,IAAI,EAAEY,IAAI,CAAC;AAC9E,EAAA;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACIc,EAAAA,sBAAsBA,CAC3B1B,IAAiB,EACjBO,OAA6B,EAAA;AAI7B,IAAA,OAAO,IAAI,CAACjB,YAAY,EAAE,CAACM,GAAG,CAAC0B,UAAU,CAAC,CAACJ,QAAQ,CAAClB,IAAI,EAAEO,OAAO,CAAC;AACpE,EAAA;AAEA;;;;;;;;;;;;;;;AAeG;AACIoB,EAAAA,wBAAwBA,CAA2B3B,IAAiB,EAAEO,OAA6B,EAAA;AAGxG,IAAA,IAAI,CAACjB,YAAY,EAAE,CAACM,GAAG,CAAC0B,UAAU,CAAC,CAACF,UAAU,CAACpB,IAAI,EAAEO,OAAO,CAAC;AAC/D,EAAA;EA2COqB,OAAOA,CAAIC,IAAc,EAAA;AAK9B,IAAA,OAAOA,IAAI,GACN,IAAI,CAACvC,YAAY,EAAE,CAACM,GAAG,CAAWkC,WAAW,CAAC,CAAClC,GAAG,CAACiC,IAAI,CAAO,IAAI,IAAI,GACvE,IAAI,CAACvC,YAAY,EAAE,CAACM,GAAG,CAAImC,UAAU,CAAC;AAC5C,EAAA;;AA1aW7C,SAAS,GAAA8C,UAAA,CAAA,CADrBC,UAAU,EAAE,4CACA,EAAA/C,SAAS,CA2arB;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const ERROR_CODE_GENERIC = 1;
|
|
2
|
+
const ERROR_CODE_VALIDATION_ERROR = 50;
|
|
3
|
+
const ERROR_CODE_INVALID_ARGUMENTS = 51;
|
|
4
|
+
const ERROR_CODE_BINDING_SCOPE = 52;
|
|
5
|
+
const ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER = 101;
|
|
6
|
+
const ERROR_CODE_FAILED_TO_RESOLVE_COMMAND_HANDLER = 102;
|
|
7
|
+
const ERROR_CODE_ACCESS_BEFORE_ACTIVATION = 200;
|
|
8
|
+
const ERROR_CODE_ACCESS_AFTER_DISPOSAL = 201;
|
|
9
9
|
|
|
10
10
|
export { ERROR_CODE_ACCESS_AFTER_DISPOSAL, ERROR_CODE_ACCESS_BEFORE_ACTIVATION, ERROR_CODE_BINDING_SCOPE, ERROR_CODE_FAILED_TO_RESOLVE_COMMAND_HANDLER, ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER, ERROR_CODE_GENERIC, ERROR_CODE_INVALID_ARGUMENTS, ERROR_CODE_VALIDATION_ERROR };
|
|
11
11
|
//# sourceMappingURL=error-code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-code.js","sources":["../../../../../../../../src/wirestate-core/error/error-code.ts"],"sourcesContent":[null],"names":["ERROR_CODE_GENERIC","ERROR_CODE_VALIDATION_ERROR","ERROR_CODE_INVALID_ARGUMENTS","ERROR_CODE_BINDING_SCOPE","ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER","ERROR_CODE_FAILED_TO_RESOLVE_COMMAND_HANDLER","ERROR_CODE_ACCESS_BEFORE_ACTIVATION","ERROR_CODE_ACCESS_AFTER_DISPOSAL"],"mappings":"AAAO,
|
|
1
|
+
{"version":3,"file":"error-code.js","sources":["../../../../../../../../src/wirestate-core/error/error-code.ts"],"sourcesContent":[null],"names":["ERROR_CODE_GENERIC","ERROR_CODE_VALIDATION_ERROR","ERROR_CODE_INVALID_ARGUMENTS","ERROR_CODE_BINDING_SCOPE","ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER","ERROR_CODE_FAILED_TO_RESOLVE_COMMAND_HANDLER","ERROR_CODE_ACCESS_BEFORE_ACTIVATION","ERROR_CODE_ACCESS_AFTER_DISPOSAL"],"mappings":"AAAO,MAAMA,kBAAkB,GAAW;AAEnC,MAAMC,2BAA2B,GAAW;AAC5C,MAAMC,4BAA4B,GAAW;AAC7C,MAAMC,wBAAwB,GAAW;AAGzC,MAAMC,0CAA0C,GAAW;AAC3D,MAAMC,4CAA4C,GAAW;AAE7D,MAAMC,mCAAmC,GAAW;AACpD,MAAMC,gCAAgC,GAAW;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __extends } from 'tslib';
|
|
2
1
|
import { ERROR_CODE_GENERIC } from './error-code.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -22,29 +21,31 @@ import { ERROR_CODE_GENERIC } from './error-code.js';
|
|
|
22
21
|
* }
|
|
23
22
|
* ```
|
|
24
23
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
class WirestateError extends Error {
|
|
25
|
+
/**
|
|
26
|
+
* The name of the error class, useful for identification in minified environments.
|
|
27
|
+
*/
|
|
28
|
+
name = "WirestateError";
|
|
29
|
+
/**
|
|
30
|
+
* Numeric error code identifying the specific failure type.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Human-readable description of the error.
|
|
35
|
+
*/
|
|
36
|
+
|
|
27
37
|
/**
|
|
28
38
|
* Creates a new instance of WirestateError.
|
|
29
39
|
*
|
|
30
40
|
* @param code - Numeric identifier for the error (defaults to ERROR_CODE_GENERIC).
|
|
31
41
|
* @param detail - Optional descriptive message.
|
|
32
42
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var _this = _super.call(this) || this;
|
|
38
|
-
/**
|
|
39
|
-
* The name of the error class, useful for identification in minified environments.
|
|
40
|
-
*/
|
|
41
|
-
_this.name = "WirestateError";
|
|
42
|
-
_this.code = code;
|
|
43
|
-
_this.message = detail || "Wirestate error.";
|
|
44
|
-
return _this;
|
|
43
|
+
constructor(code = ERROR_CODE_GENERIC, detail) {
|
|
44
|
+
super();
|
|
45
|
+
this.code = code;
|
|
46
|
+
this.message = detail || "Wirestate error.";
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
}(Error);
|
|
48
|
+
}
|
|
48
49
|
|
|
49
50
|
export { WirestateError };
|
|
50
51
|
//# sourceMappingURL=wirestate-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wirestate-error.js","sources":["../../../../../../../../src/wirestate-core/error/wirestate-error.ts"],"sourcesContent":[null],"names":["WirestateError","
|
|
1
|
+
{"version":3,"file":"wirestate-error.js","sources":["../../../../../../../../src/wirestate-core/error/wirestate-error.ts"],"sourcesContent":[null],"names":["WirestateError","Error","name","constructor","code","ERROR_CODE_GENERIC","detail","message"],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,MAAOA,cAAe,SAAQC,KAAK,CAAA;AACvC;;AAEG;AACaC,EAAAA,IAAI,GAAW,gBAAgB;AAC/C;;AAEG;;AAEH;;AAEG;;AAGH;;;;;AAKG;AACHC,EAAAA,WAAAA,CAAmBC,IAAA,GAAeC,kBAAkB,EAAEC,MAAe,EAAA;AACnE,IAAA,KAAK,EAAE;IAEP,IAAI,CAACF,IAAI,GAAGA,IAAI;AAChB,IAAA,IAAI,CAACG,OAAO,GAAGD,MAAM,IAAI,kBAAkB;AAC7C,EAAA;AACD;;;;"}
|
|
@@ -26,11 +26,10 @@ import { getEventHandlerMetadata } from './get-event-handler-metadata.js';
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
function buildEventDispatcher(instance) {
|
|
29
|
-
|
|
29
|
+
const entries = [];
|
|
30
30
|
// Register methods decorated with @OnEvent.
|
|
31
|
-
for (
|
|
32
|
-
|
|
33
|
-
var method = instance[meta.methodName];
|
|
31
|
+
for (const meta of getEventHandlerMetadata(instance)) {
|
|
32
|
+
const method = instance[meta.methodName];
|
|
34
33
|
if (typeof method === "function") {
|
|
35
34
|
entries.push({
|
|
36
35
|
types: meta.types,
|
|
@@ -39,10 +38,9 @@ function buildEventDispatcher(instance) {
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
if (entries.length) {
|
|
42
|
-
return
|
|
41
|
+
return event => {
|
|
43
42
|
// Fan out events to all matching handlers.
|
|
44
|
-
for (
|
|
45
|
-
var entry = entries_1[_i];
|
|
43
|
+
for (const entry of entries) {
|
|
46
44
|
if (entry.types === null || entry.types.includes(event.type)) {
|
|
47
45
|
entry.handler(event);
|
|
48
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-event-dispatcher.js","sources":["../../../../../../../../src/wirestate-core/events/build-event-dispatcher.ts"],"sourcesContent":[null],"names":["buildEventDispatcher","instance","entries","
|
|
1
|
+
{"version":3,"file":"build-event-dispatcher.js","sources":["../../../../../../../../src/wirestate-core/events/build-event-dispatcher.ts"],"sourcesContent":[null],"names":["buildEventDispatcher","instance","entries","meta","getEventHandlerMetadata","method","methodName","push","types","handler","bind","length","event","entry","includes","type"],"mappings":";;AAQA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACG,SAAUA,oBAAoBA,CAAmBC,QAAW,EAAA;EAGhE,MAAMC,OAAO,GAA8B,EAAE;AAE7C;AACA,EAAA,KAAK,MAAMC,IAAI,IAAIC,uBAAuB,CAACH,QAAQ,CAAC,EAAE;AACpD,IAAA,MAAMI,MAAM,GAAIJ,QAAwD,CAACE,IAAI,CAACG,UAAU,CAAC;AAEzF,IAAA,IAAI,OAAOD,MAAM,KAAK,UAAU,EAAE;MAChCH,OAAO,CAACK,IAAI,CAAC;QACXC,KAAK,EAAEL,IAAI,CAACK,KAAK;AACjBC,QAAAA,OAAO,EAAGJ,MAAuB,CAACK,IAAI,CAACT,QAAQ;AAChD,OAAA,CAAC;AACJ,IAAA;AACF,EAAA;EAEA,IAAIC,OAAO,CAACS,MAAM,EAAE;AAOlB,IAAA,OAAQC,KAAK,IAAI;AACf;AACA,MAAA,KAAK,MAAMC,KAAK,IAAIX,OAAO,EAAE;AAC3B,QAAA,IAAIW,KAAK,CAACL,KAAK,KAAK,IAAI,IAAIK,KAAK,CAACL,KAAK,CAACM,QAAQ,CAACF,KAAK,CAACG,IAAI,CAAC,EAAE;AAC5DF,UAAAA,KAAK,CAACJ,OAAO,CAACG,KAAK,CAAC;AACtB,QAAA;AACF,MAAA;IACF,CAAC;AACH,EAAA,CAAC,MAAM;AAOL,IAAA,OAAO,IAAI;AACb,EAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-event.js","sources":["../../../../../../../../src/wirestate-core/events/emit-event.ts"],"sourcesContent":[null],"names":["emitEvent","container","type","payload","from","get","EventBus","emit"],"mappings":";;AASA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAUA,SAASA,CAAyBC,SAAoB,EAAEC,IAAO,EAAEC,OAAW,EAAEC,IAAc,EAAA;AAG1GH,EAAAA,SAAS,CAACI,GAAG,CAACC,QAAQ,CAAC,CAACC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"emit-event.js","sources":["../../../../../../../../src/wirestate-core/events/emit-event.ts"],"sourcesContent":[null],"names":["emitEvent","container","type","payload","from","get","EventBus","emit"],"mappings":";;AASA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAUA,SAASA,CAAyBC,SAAoB,EAAEC,IAAO,EAAEC,OAAW,EAAEC,IAAc,EAAA;AAG1GH,EAAAA,SAAS,CAACI,GAAG,CAACC,QAAQ,CAAC,CAACC,IAAI,CAAC;IAAEL,IAAI;IAAEC,OAAO;AAAEC,IAAAA;AAAI,GAAE,CAAC;AACvD;;;;"}
|
|
@@ -8,10 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @group Events
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.handlers = new Set();
|
|
14
|
-
}
|
|
11
|
+
class EventBus {
|
|
12
|
+
handlers = new Set();
|
|
15
13
|
/**
|
|
16
14
|
* Broadcasts an event to all registered subscribers.
|
|
17
15
|
*
|
|
@@ -34,11 +32,10 @@ var EventBus = /** @class */function () {
|
|
|
34
32
|
* });
|
|
35
33
|
* ```
|
|
36
34
|
*/
|
|
37
|
-
|
|
35
|
+
emit(event) {
|
|
38
36
|
// Snapshot prevents concurrent modification errors if handlers sub/unsub during emit.
|
|
39
|
-
|
|
40
|
-
for (
|
|
41
|
-
var handler = snapshot_1[_i];
|
|
37
|
+
const snapshot = Array.from(this.handlers);
|
|
38
|
+
for (const handler of snapshot) {
|
|
42
39
|
try {
|
|
43
40
|
handler(event);
|
|
44
41
|
} catch (error) {
|
|
@@ -46,7 +43,7 @@ var EventBus = /** @class */function () {
|
|
|
46
43
|
console.error("[wirestate] Event handler threw:", error);
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
|
-
}
|
|
46
|
+
}
|
|
50
47
|
/**
|
|
51
48
|
* Registers a handler to receive all broadcasted events.
|
|
52
49
|
*
|
|
@@ -60,13 +57,10 @@ var EventBus = /** @class */function () {
|
|
|
60
57
|
* });
|
|
61
58
|
* ```
|
|
62
59
|
*/
|
|
63
|
-
|
|
64
|
-
var _this = this;
|
|
60
|
+
subscribe(handler) {
|
|
65
61
|
this.handlers.add(handler);
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
};
|
|
62
|
+
return () => this.unsubscribe(handler);
|
|
63
|
+
}
|
|
70
64
|
/**
|
|
71
65
|
* Removes a previously registered event handler.
|
|
72
66
|
*
|
|
@@ -75,27 +69,26 @@ var EventBus = /** @class */function () {
|
|
|
75
69
|
*
|
|
76
70
|
* @param handler - The handler function instance to remove.
|
|
77
71
|
*/
|
|
78
|
-
|
|
72
|
+
unsubscribe(handler) {
|
|
79
73
|
this.handlers.delete(handler);
|
|
80
|
-
}
|
|
74
|
+
}
|
|
81
75
|
/**
|
|
82
76
|
* Checks if the bus has any active subscribers.
|
|
83
77
|
*
|
|
84
78
|
* @returns `true` if at least one handler is registered, `false` otherwise.
|
|
85
79
|
*/
|
|
86
|
-
|
|
80
|
+
has() {
|
|
87
81
|
return this.handlers.size > 0;
|
|
88
|
-
}
|
|
82
|
+
}
|
|
89
83
|
/**
|
|
90
84
|
* Removes all registered handlers from the bus.
|
|
91
85
|
*
|
|
92
86
|
* @internal
|
|
93
87
|
*/
|
|
94
|
-
|
|
88
|
+
clear() {
|
|
95
89
|
this.handlers.clear();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
}();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
99
92
|
|
|
100
93
|
export { EventBus };
|
|
101
94
|
//# sourceMappingURL=event-bus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus.js","sources":["../../../../../../../../src/wirestate-core/events/event-bus.ts"],"sourcesContent":[null],"names":["EventBus","handlers","Set","
|
|
1
|
+
{"version":3,"file":"event-bus.js","sources":["../../../../../../../../src/wirestate-core/events/event-bus.ts"],"sourcesContent":[null],"names":["EventBus","handlers","Set","emit","event","snapshot","Array","from","handler","error","console","subscribe","add","unsubscribe","delete","has","size","clear"],"mappings":"AAKA;;;;;;;;;AASG;MACUA,QAAQ,CAAA;AACFC,EAAAA,QAAQ,GAAsB,IAAIC,GAAG,EAAE;AAExD;;;;;;;;;;;;;;;;;;;;;AAqBG;EACIC,IAAIA,CAA4DC,KAAqB,EAAA;AAC1F;IACA,MAAMC,QAAQ,GAAwBC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACN,QAAQ,CAAC;AAE/D,IAAA,KAAK,MAAMO,OAAO,IAAIH,QAAQ,EAAE;MAC9B,IAAI;QACFG,OAAO,CAACJ,KAAK,CAAC;MAChB,CAAC,CAAC,OAAOK,KAAK,EAAE;AACd;AACAC,QAAAA,OAAO,CAACD,KAAK,CAAC,kCAAkC,EAAEA,KAAK,CAAC;AAC1D,MAAA;AACF,IAAA;AACF,EAAA;AAEA;;;;;;;;;;;;AAYG;EACIE,SAASA,CAACH,OAAqB,EAAA;AAMpC,IAAA,IAAI,CAACP,QAAQ,CAACW,GAAG,CAACJ,OAAO,CAAC;AAE1B,IAAA,OAAO,MAAM,IAAI,CAACK,WAAW,CAACL,OAAO,CAAC;AACxC,EAAA;AAEA;;;;;;;AAOG;EACIK,WAAWA,CAACL,OAAqB,EAAA;AAMtC,IAAA,IAAI,CAACP,QAAQ,CAACa,MAAM,CAACN,OAAO,CAAC;AAC/B,EAAA;AAEA;;;;AAIG;AACIO,EAAAA,GAAGA,GAAA;AACR,IAAA,OAAO,IAAI,CAACd,QAAQ,CAACe,IAAI,GAAG,CAAC;AAC/B,EAAA;AAEA;;;;AAIG;AACIC,EAAAA,KAAKA,GAAA;AACV,IAAA,IAAI,CAAChB,QAAQ,CAACgB,KAAK,EAAE;AACvB,EAAA;AACD;;;;"}
|
|
@@ -24,11 +24,11 @@ import { EVENT_HANDLER_METADATA } from '../registry.js';
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
function getEventHandlerMetadata(instance) {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
let constructor = instance.constructor;
|
|
28
|
+
const chain = [];
|
|
29
29
|
// Traverse prototype chain up to Object/Function
|
|
30
30
|
while (typeof constructor === "function" && constructor !== Object && constructor !== Function.prototype) {
|
|
31
|
-
|
|
31
|
+
const own = EVENT_HANDLER_METADATA.get(constructor);
|
|
32
32
|
if (own && own.length > 0) {
|
|
33
33
|
chain.push(own);
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-event-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/events/get-event-handler-metadata.ts"],"sourcesContent":[null],"names":["getEventHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","EVENT_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAUA,uBAAuBA,CAACC,QAAgB,EAAA;AAGtD,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,
|
|
1
|
+
{"version":3,"file":"get-event-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/events/get-event-handler-metadata.ts"],"sourcesContent":[null],"names":["getEventHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","EVENT_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAUA,uBAAuBA,CAACC,QAAgB,EAAA;AAGtD,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,MAAMC,KAAK,GAAuC,EAAE;AAEpD;AACA,EAAA,OAAO,OAAOD,WAAW,KAAK,UAAU,IAAIA,WAAW,KAAKE,MAAM,IAAIF,WAAW,KAAKG,QAAQ,CAACC,SAAS,EAAE;AACxG,IAAA,MAAMC,GAAG,GAAuCC,sBAAsB,CAACC,GAAG,CAACP,WAAqB,CAAC;AAEjG,IAAA,IAAIK,GAAG,IAAIA,GAAG,CAACG,MAAM,GAAG,CAAC,EAAE;AACzBP,MAAAA,KAAK,CAACQ,IAAI,CAACJ,GAAG,CAAC;AACjB,IAAA;AAEAL,IAAAA,WAAW,GAAGE,MAAM,CAACQ,cAAc,CAACV,WAAW,CAAC;AAClD,EAAA;AAQA;EACA,OAAOC,KAAK,CAACU,OAAO,EAAE,CAACC,IAAI,EAAE;AAC/B;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __spreadArray } from 'tslib';
|
|
2
1
|
import { EVENT_HANDLER_METADATA } from '../registry.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -38,10 +37,10 @@ import { EVENT_HANDLER_METADATA } from '../registry.js';
|
|
|
38
37
|
*/
|
|
39
38
|
function OnEvent(types) {
|
|
40
39
|
// Normalize types to an array or null for catch-all.
|
|
41
|
-
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const normalized = types === undefined ? null : Array.isArray(types) ? [...types] : [types];
|
|
41
|
+
return (target, propertyKey) => {
|
|
42
|
+
const constructor = target.constructor;
|
|
43
|
+
let list = EVENT_HANDLER_METADATA.get(constructor);
|
|
45
44
|
if (!list) {
|
|
46
45
|
list = [];
|
|
47
46
|
EVENT_HANDLER_METADATA.set(constructor, list);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-event.js","sources":["../../../../../../../../src/wirestate-core/events/on-event.ts"],"sourcesContent":[null],"names":["OnEvent","types","normalized","undefined","Array","isArray","
|
|
1
|
+
{"version":3,"file":"on-event.js","sources":["../../../../../../../../src/wirestate-core/events/on-event.ts"],"sourcesContent":[null],"names":["OnEvent","types","normalized","undefined","Array","isArray","target","propertyKey","constructor","list","EVENT_HANDLER_METADATA","get","set","push","methodName"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCG;AACG,SAAUA,OAAOA,CAACC,KAA4C,EAAA;AAClE;EACA,MAAMC,UAAU,GACdD,KAAK,KAAKE,SAAS,GAAG,IAAI,GAAGC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,GAAG,CAAC,GAAIA,KAAkC,CAAC,GAAG,CAACA,KAAkB,CAAC;AAErH,EAAA,OAAO,CAACK,MAAM,EAAEC,WAAW,KAAI;AAS7B,IAAA,MAAMC,WAAW,GAAGF,MAAM,CAACE,WAAW;AAEtC,IAAA,IAAIC,IAAI,GAAuCC,sBAAsB,CAACC,GAAG,CAACH,WAAW,CAAC;IAEtF,IAAI,CAACC,IAAI,EAAE;AACTA,MAAAA,IAAI,GAAG,EAAE;AACTC,MAAAA,sBAAsB,CAACE,GAAG,CAACJ,WAAW,EAAEC,IAAI,CAAC;AAC/C,IAAA;AAEA;IACAA,IAAI,CAACI,IAAI,CAAC;AAAEC,MAAAA,UAAU,EAAEP,WAAW;AAAEN,MAAAA,KAAK,EAAEC;AAAU,KAAE,CAAC;EAC3D,CAAC;AACH;;;;"}
|
|
@@ -25,11 +25,11 @@ import { QUERY_HANDLER_METADATA } from '../registry.js';
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
function getQueryHandlerMetadata(instance) {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let constructor = instance.constructor;
|
|
29
|
+
const chain = [];
|
|
30
30
|
// Traverse prototype chain up to Object/Function
|
|
31
31
|
while (typeof constructor === "function" && constructor !== Object && constructor !== Function.prototype) {
|
|
32
|
-
|
|
32
|
+
const own = QUERY_HANDLER_METADATA.get(constructor);
|
|
33
33
|
if (own && own.length > 0) {
|
|
34
34
|
chain.push(own);
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-query-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/queries/get-query-handler-metadata.ts"],"sourcesContent":[null],"names":["getQueryHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","QUERY_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAUA,uBAAuBA,CAACC,QAAgB,EAAA;AAGtD,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,
|
|
1
|
+
{"version":3,"file":"get-query-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/queries/get-query-handler-metadata.ts"],"sourcesContent":[null],"names":["getQueryHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","QUERY_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAUA,uBAAuBA,CAACC,QAAgB,EAAA;AAGtD,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,MAAMC,KAAK,GAAuC,EAAE;AAEpD;AACA,EAAA,OAAO,OAAOD,WAAW,KAAK,UAAU,IAAIA,WAAW,KAAKE,MAAM,IAAIF,WAAW,KAAKG,QAAQ,CAACC,SAAS,EAAE;AACxG,IAAA,MAAMC,GAAG,GAAuCC,sBAAsB,CAACC,GAAG,CAACP,WAAqB,CAAC;AAEjG,IAAA,IAAIK,GAAG,IAAIA,GAAG,CAACG,MAAM,GAAG,CAAC,EAAE;AACzBP,MAAAA,KAAK,CAACQ,IAAI,CAACJ,GAAG,CAAC;AACjB,IAAA;AAEAL,IAAAA,WAAW,GAAGE,MAAM,CAACQ,cAAc,CAACV,WAAW,CAAC;AAClD,EAAA;AAQA;EACA,OAAOC,KAAK,CAACU,OAAO,EAAE,CAACC,IAAI,EAAE;AAC/B;;;;"}
|
|
@@ -29,9 +29,9 @@ import { QUERY_HANDLER_METADATA } from '../registry.js';
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
function OnQuery(type) {
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
return (target, propertyKey) => {
|
|
33
|
+
const constructor = target.constructor;
|
|
34
|
+
let list = QUERY_HANDLER_METADATA.get(constructor);
|
|
35
35
|
if (!list) {
|
|
36
36
|
list = [];
|
|
37
37
|
QUERY_HANDLER_METADATA.set(constructor, list);
|
|
@@ -39,7 +39,7 @@ function OnQuery(type) {
|
|
|
39
39
|
// Register handler metadata for prototype-based retrieval.
|
|
40
40
|
list.push({
|
|
41
41
|
methodName: propertyKey,
|
|
42
|
-
type
|
|
42
|
+
type
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-query.js","sources":["../../../../../../../../src/wirestate-core/queries/on-query.ts"],"sourcesContent":[null],"names":["OnQuery","type","target","propertyKey","constructor","list","QUERY_HANDLER_METADATA","get","set","push","methodName"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACG,SAAUA,OAAOA,CAACC,IAAe,EAAA;AACrC,EAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"on-query.js","sources":["../../../../../../../../src/wirestate-core/queries/on-query.ts"],"sourcesContent":[null],"names":["OnQuery","type","target","propertyKey","constructor","list","QUERY_HANDLER_METADATA","get","set","push","methodName"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACG,SAAUA,OAAOA,CAACC,IAAe,EAAA;AACrC,EAAA,OAAO,CAACC,MAAM,EAAEC,WAAW,KAAI;AAS7B,IAAA,MAAMC,WAAW,GAAGF,MAAM,CAACE,WAAW;AAEtC,IAAA,IAAIC,IAAI,GAAuCC,sBAAsB,CAACC,GAAG,CAACH,WAAW,CAAC;IAEtF,IAAI,CAACC,IAAI,EAAE;AACTA,MAAAA,IAAI,GAAG,EAAE;AACTC,MAAAA,sBAAsB,CAACE,GAAG,CAACJ,WAAW,EAAEC,IAAI,CAAC;AAC/C,IAAA;AAEA;IACAA,IAAI,CAACI,IAAI,CAAC;AAAEC,MAAAA,UAAU,EAAEP,WAAW;AAAEF,MAAAA;AAAI,KAAE,CAAC;EAC9C,CAAC;AACH;;;;"}
|