@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
|
@@ -12,14 +12,12 @@ import { WirestateError } from '../error/wirestate-error.js';
|
|
|
12
12
|
*
|
|
13
13
|
* @group Queries
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.handlers = new Map();
|
|
22
|
-
}
|
|
15
|
+
class QueryBus {
|
|
16
|
+
/**
|
|
17
|
+
* Internal handler storage.
|
|
18
|
+
* Uses a stack for each query type to support shadowing (e.g., component-level vs service-level).
|
|
19
|
+
*/
|
|
20
|
+
handlers = new Map();
|
|
23
21
|
/**
|
|
24
22
|
* Registers a handler for a specific query type.
|
|
25
23
|
*
|
|
@@ -39,18 +37,15 @@ var QueryBus = /** @class */function () {
|
|
|
39
37
|
* const unregister: QueryUnregister = queryBus.register("GET_NOW", () => Date.now());
|
|
40
38
|
* ```
|
|
41
39
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var stack = this.handlers.get(type);
|
|
40
|
+
register(type, handler) {
|
|
41
|
+
let stack = this.handlers.get(type);
|
|
45
42
|
if (!stack) {
|
|
46
43
|
stack = [];
|
|
47
44
|
this.handlers.set(type, stack);
|
|
48
45
|
}
|
|
49
46
|
stack.push(handler);
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
};
|
|
47
|
+
return () => this.unregister(type, handler);
|
|
48
|
+
}
|
|
54
49
|
/**
|
|
55
50
|
* Removes a previously registered query handler.
|
|
56
51
|
*
|
|
@@ -63,12 +58,12 @@ var QueryBus = /** @class */function () {
|
|
|
63
58
|
* @param type - Unique query identifier.
|
|
64
59
|
* @param handler - The handler function instance to remove.
|
|
65
60
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
unregister(type, handler) {
|
|
62
|
+
const current = this.handlers.get(type);
|
|
68
63
|
if (!current) {
|
|
69
64
|
return;
|
|
70
65
|
}
|
|
71
|
-
|
|
66
|
+
const index = current.indexOf(handler);
|
|
72
67
|
if (index >= 0) {
|
|
73
68
|
current.splice(index, 1);
|
|
74
69
|
}
|
|
@@ -76,7 +71,7 @@ var QueryBus = /** @class */function () {
|
|
|
76
71
|
if (current.length === 0) {
|
|
77
72
|
this.handlers.delete(type);
|
|
78
73
|
}
|
|
79
|
-
}
|
|
74
|
+
}
|
|
80
75
|
/**
|
|
81
76
|
* Dispatches a query to the last registered handler and returns the result.
|
|
82
77
|
*
|
|
@@ -99,14 +94,14 @@ var QueryBus = /** @class */function () {
|
|
|
99
94
|
* const user: User = await queryBus.query<User, string>("FIND_USER", "user-id-123");
|
|
100
95
|
* ```
|
|
101
96
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
query(type, data) {
|
|
98
|
+
const stack = this.handlers.get(type);
|
|
104
99
|
// Always use the top of the stack (most recent registration) if handlers are available.
|
|
105
|
-
if (stack
|
|
100
|
+
if (stack?.length) {
|
|
106
101
|
return stack[stack.length - 1](data);
|
|
107
102
|
}
|
|
108
|
-
throw new WirestateError(ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER,
|
|
109
|
-
}
|
|
103
|
+
throw new WirestateError(ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER, `No query handler registered in container for type: '${String(type)}'.`);
|
|
104
|
+
}
|
|
110
105
|
/**
|
|
111
106
|
* Dispatches a query if a handler exists, otherwise returns null.
|
|
112
107
|
*
|
|
@@ -118,33 +113,32 @@ var QueryBus = /** @class */function () {
|
|
|
118
113
|
* @param data - Optional input data for the handler.
|
|
119
114
|
* @returns The query result, or `null` if no handler is found.
|
|
120
115
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (stack
|
|
116
|
+
queryOptional(type, data) {
|
|
117
|
+
const stack = this.handlers.get(type);
|
|
118
|
+
if (stack?.length) {
|
|
124
119
|
return stack[stack.length - 1](data);
|
|
125
120
|
}
|
|
126
121
|
return null;
|
|
127
|
-
}
|
|
122
|
+
}
|
|
128
123
|
/**
|
|
129
124
|
* Checks if at least one handler is registered for the given query type.
|
|
130
125
|
*
|
|
131
126
|
* @param type - Unique query identifier.
|
|
132
127
|
* @returns `true` if a handler is available, `false` otherwise.
|
|
133
128
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
has(type) {
|
|
130
|
+
const stack = this.handlers.get(type);
|
|
136
131
|
return Boolean(stack && stack.length);
|
|
137
|
-
}
|
|
132
|
+
}
|
|
138
133
|
/**
|
|
139
134
|
* Removes all registered query handlers from the bus.
|
|
140
135
|
*
|
|
141
136
|
* @internal
|
|
142
137
|
*/
|
|
143
|
-
|
|
138
|
+
clear() {
|
|
144
139
|
this.handlers.clear();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
}();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
148
142
|
|
|
149
143
|
export { QueryBus };
|
|
150
144
|
//# sourceMappingURL=query-bus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-bus.js","sources":["../../../../../../../../src/wirestate-core/queries/query-bus.ts"],"sourcesContent":[null],"names":["QueryBus","handlers","Map","
|
|
1
|
+
{"version":3,"file":"query-bus.js","sources":["../../../../../../../../src/wirestate-core/queries/query-bus.ts"],"sourcesContent":[null],"names":["QueryBus","handlers","Map","register","type","handler","stack","get","set","push","unregister","current","index","indexOf","splice","length","delete","query","data","WirestateError","ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER","String","queryOptional","has","Boolean","clear"],"mappings":";;;AAQA;;;;;;;;;;AAUG;MACUA,QAAQ,CAAA;AACnB;;;AAGG;AACcC,EAAAA,QAAQ,GAAwC,IAAIC,GAAG,EAAE;AAE1E;;;;;;;;;;;;;;;;;;AAkBG;AACIC,EAAAA,QAAQA,CAA2BC,IAAe,EAAEC,OAA2B,EAAA;IAOpF,IAAIC,KAAK,GAA+B,IAAI,CAACL,QAAQ,CAACM,GAAG,CAACH,IAAI,CAAC;IAE/D,IAAI,CAACE,KAAK,EAAE;AACVA,MAAAA,KAAK,GAAG,EAAE;MACV,IAAI,CAACL,QAAQ,CAACO,GAAG,CAACJ,IAAI,EAAEE,KAAK,CAAC;AAChC,IAAA;AAEAA,IAAAA,KAAK,CAACG,IAAI,CAACJ,OAAuB,CAAC;IAEnC,OAAO,MAAM,IAAI,CAACK,UAAU,CAACN,IAAI,EAAEC,OAAuB,CAAC;AAC7D,EAAA;AAEA;;;;;;;;;;;AAWG;AACIK,EAAAA,UAAUA,CAA2BN,IAAe,EAAEC,OAA2B,EAAA;IAOtF,MAAMM,OAAO,GAA+B,IAAI,CAACV,QAAQ,CAACM,GAAG,CAACH,IAAI,CAAC;IAEnE,IAAI,CAACO,OAAO,EAAE;AACZ,MAAA;AACF,IAAA;AAEA,IAAA,MAAMC,KAAK,GAAWD,OAAO,CAACE,OAAO,CAACR,OAAuB,CAAC;IAE9D,IAAIO,KAAK,IAAI,CAAC,EAAE;AACdD,MAAAA,OAAO,CAACG,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;AAC1B,IAAA;AAEA;AACA,IAAA,IAAID,OAAO,CAACI,MAAM,KAAK,CAAC,EAAE;AACxB,MAAA,IAAI,CAACd,QAAQ,CAACe,MAAM,CAACZ,IAAI,CAAC;AAC5B,IAAA;AACF,EAAA;AAEA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACIa,EAAAA,KAAKA,CAA4Db,IAAO,EAAEc,IAAQ,EAAA;IACvF,MAAMZ,KAAK,GAA+B,IAAI,CAACL,QAAQ,CAACM,GAAG,CAACH,IAAI,CAAC;AAEjE;IACA,IAAIE,KAAK,EAAES,MAAM,EAAE;MACjB,OAAQT,KAAK,CAACA,KAAK,CAACS,MAAM,GAAG,CAAC,CAAwB,CAACG,IAAS,CAAC;AACnE,IAAA;IAEA,MAAM,IAAIC,cAAc,CACtBC,0CAA0C,EAC1C,CAAA,oDAAA,EAAuDC,MAAM,CAACjB,IAAI,CAAC,CAAA,EAAA,CAAI,CACxE;AACH,EAAA;AAEA;;;;;;;;;;AAUG;AACIkB,EAAAA,aAAaA,CAClBlB,IAAO,EACPc,IAAQ,EAAA;IAER,MAAMZ,KAAK,GAA+B,IAAI,CAACL,QAAQ,CAACM,GAAG,CAACH,IAAI,CAAC;IAEjE,IAAIE,KAAK,EAAES,MAAM,EAAE;MACjB,OAAQT,KAAK,CAACA,KAAK,CAACS,MAAM,GAAG,CAAC,CAAwB,CAACG,IAAS,CAAC;AACnE,IAAA;AAEA,IAAA,OAAO,IAAI;AACb,EAAA;AAEA;;;;;AAKG;EACIK,GAAGA,CAACnB,IAAe,EAAA;IACxB,MAAME,KAAK,GAA+B,IAAI,CAACL,QAAQ,CAACM,GAAG,CAACH,IAAI,CAAC;AAEjE,IAAA,OAAOoB,OAAO,CAAClB,KAAK,IAAIA,KAAK,CAACS,MAAM,CAAC;AACvC,EAAA;AAEA;;;;AAIG;AACIU,EAAAA,KAAKA,GAAA;AACV,IAAA,IAAI,CAACxB,QAAQ,CAACwB,KAAK,EAAE;AACvB,EAAA;AACD;;;;"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @group Queries
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
const QUERY_HANDLER_METADATA = new WeakMap();
|
|
12
12
|
/**
|
|
13
13
|
* Registry of class constructors to their declared command handlers.
|
|
14
14
|
*
|
|
@@ -19,7 +19,7 @@ var QUERY_HANDLER_METADATA = new WeakMap();
|
|
|
19
19
|
* @group Commands
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
const COMMAND_HANDLER_METADATA = new WeakMap();
|
|
23
23
|
/**
|
|
24
24
|
* Registry of class constructors to their `@OnActivated`-decorated method names.
|
|
25
25
|
*
|
|
@@ -30,7 +30,7 @@ var COMMAND_HANDLER_METADATA = new WeakMap();
|
|
|
30
30
|
* @group Service
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
const ACTIVATED_HANDLER_METADATA = new WeakMap();
|
|
34
34
|
/**
|
|
35
35
|
* Registry of class constructors to their `@OnDeactivation`-decorated method names.
|
|
36
36
|
*
|
|
@@ -41,7 +41,7 @@ var ACTIVATED_HANDLER_METADATA = new WeakMap();
|
|
|
41
41
|
* @group Service
|
|
42
42
|
* @internal
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
const DEACTIVATION_HANDLER_METADATA = new WeakMap();
|
|
45
45
|
/**
|
|
46
46
|
* Registry of class constructors to their declared event handlers.
|
|
47
47
|
*
|
|
@@ -52,7 +52,7 @@ var DEACTIVATION_HANDLER_METADATA = new WeakMap();
|
|
|
52
52
|
* @group Events
|
|
53
53
|
* @internal
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
const EVENT_HANDLER_METADATA = new WeakMap();
|
|
56
56
|
/**
|
|
57
57
|
* Internal storage for mapping service instances to their originating Inversify containers.
|
|
58
58
|
*
|
|
@@ -63,7 +63,7 @@ var EVENT_HANDLER_METADATA = new WeakMap();
|
|
|
63
63
|
* @group Bind
|
|
64
64
|
* @internal
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
const CONTAINER_REFS_BY_SERVICE = new WeakMap();
|
|
67
67
|
/**
|
|
68
68
|
* Internal storage for managing injected {@link WireScope} instances per service.
|
|
69
69
|
*
|
|
@@ -74,7 +74,7 @@ var CONTAINER_REFS_BY_SERVICE = new WeakMap();
|
|
|
74
74
|
* @group Container
|
|
75
75
|
* @internal
|
|
76
76
|
*/
|
|
77
|
-
|
|
77
|
+
const WIRE_SCOPES_BY_SERVICE = new WeakMap();
|
|
78
78
|
/**
|
|
79
79
|
* Internal storage for service event unsubscribers.
|
|
80
80
|
*
|
|
@@ -85,7 +85,7 @@ var WIRE_SCOPES_BY_SERVICE = new WeakMap();
|
|
|
85
85
|
* @group Events
|
|
86
86
|
* @internal
|
|
87
87
|
*/
|
|
88
|
-
|
|
88
|
+
const EVENT_UNSUBSCRIBERS_BY_SERVICE = new WeakMap();
|
|
89
89
|
/**
|
|
90
90
|
* Internal storage for service query unregisters.
|
|
91
91
|
*
|
|
@@ -96,7 +96,7 @@ var EVENT_UNSUBSCRIBERS_BY_SERVICE = new WeakMap();
|
|
|
96
96
|
* @group Queries
|
|
97
97
|
* @internal
|
|
98
98
|
*/
|
|
99
|
-
|
|
99
|
+
const QUERY_UNREGISTERS_BY_SERVICE = new WeakMap();
|
|
100
100
|
/**
|
|
101
101
|
* Internal storage for service command unregisters.
|
|
102
102
|
*
|
|
@@ -107,7 +107,7 @@ var QUERY_UNREGISTERS_BY_SERVICE = new WeakMap();
|
|
|
107
107
|
* @group Commands
|
|
108
108
|
* @internal
|
|
109
109
|
*/
|
|
110
|
-
|
|
110
|
+
const COMMAND_UNREGISTERS_BY_SERVICE = new WeakMap();
|
|
111
111
|
|
|
112
112
|
export { ACTIVATED_HANDLER_METADATA, COMMAND_HANDLER_METADATA, COMMAND_UNREGISTERS_BY_SERVICE, CONTAINER_REFS_BY_SERVICE, DEACTIVATION_HANDLER_METADATA, EVENT_HANDLER_METADATA, EVENT_UNSUBSCRIBERS_BY_SERVICE, QUERY_HANDLER_METADATA, QUERY_UNREGISTERS_BY_SERVICE, WIRE_SCOPES_BY_SERVICE };
|
|
113
113
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sources":["../../../../../../../src/wirestate-core/registry.ts"],"sourcesContent":[null],"names":["QUERY_HANDLER_METADATA","WeakMap","COMMAND_HANDLER_METADATA","ACTIVATED_HANDLER_METADATA","DEACTIVATION_HANDLER_METADATA","EVENT_HANDLER_METADATA","CONTAINER_REFS_BY_SERVICE","WIRE_SCOPES_BY_SERVICE","EVENT_UNSUBSCRIBERS_BY_SERVICE","QUERY_UNREGISTERS_BY_SERVICE","COMMAND_UNREGISTERS_BY_SERVICE"],"mappings":"AAOA;;;;;;;;;AASG;
|
|
1
|
+
{"version":3,"file":"registry.js","sources":["../../../../../../../src/wirestate-core/registry.ts"],"sourcesContent":[null],"names":["QUERY_HANDLER_METADATA","WeakMap","COMMAND_HANDLER_METADATA","ACTIVATED_HANDLER_METADATA","DEACTIVATION_HANDLER_METADATA","EVENT_HANDLER_METADATA","CONTAINER_REFS_BY_SERVICE","WIRE_SCOPES_BY_SERVICE","EVENT_UNSUBSCRIBERS_BY_SERVICE","QUERY_UNREGISTERS_BY_SERVICE","COMMAND_UNREGISTERS_BY_SERVICE"],"mappings":"AAOA;;;;;;;;;AASG;MACUA,sBAAsB,GAAiD,IAAIC,OAAO;AAE/F;;;;;;;;;AASG;MACUC,wBAAwB,GAAmD,IAAID,OAAO;AAEnG;;;;;;;;;AASG;MACUE,0BAA0B,GAA4C,IAAIF,OAAO;AAE9F;;;;;;;;;AASG;MACUG,6BAA6B,GAA4C,IAAIH,OAAO;AAEjG;;;;;;;;;AASG;MACUI,sBAAsB,GAAiD,IAAIJ,OAAO;AAE/F;;;;;;;;;AASG;MACUK,yBAAyB,GAA+B,IAAIL,OAAO;AAEhF;;;;;;;;;AASG;MACUM,sBAAsB,GAAsC,IAAIN,OAAO;AAEpF;;;;;;;;;AASG;MACUO,8BAA8B,GAAuC,IAAIP,OAAO;AAE7F;;;;;;;;;AASG;MACUQ,4BAA4B,GAA4C,IAAIR,OAAO;AAEhG;;;;;;;;;AASG;MACUS,8BAA8B,GAA8C,IAAIT,OAAO;;;;"}
|
|
@@ -22,11 +22,8 @@ import { SEEDS_TOKEN } from './tokens.js';
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
function applySeeds(container, seeds) {
|
|
25
|
-
|
|
26
|
-
for (
|
|
27
|
-
var _a = seeds_1[_i],
|
|
28
|
-
key = _a[0],
|
|
29
|
-
state = _a[1];
|
|
25
|
+
const existing = container.get(SEEDS_TOKEN);
|
|
26
|
+
for (const [key, state] of seeds) {
|
|
30
27
|
existing.set(key, state);
|
|
31
28
|
}
|
|
32
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-seeds.js","sources":["../../../../../../../../src/wirestate-core/seeds/apply-seeds.ts"],"sourcesContent":[null],"names":["applySeeds","container","seeds","existing","get","SEEDS_TOKEN","
|
|
1
|
+
{"version":3,"file":"apply-seeds.js","sources":["../../../../../../../../src/wirestate-core/seeds/apply-seeds.ts"],"sourcesContent":[null],"names":["applySeeds","container","seeds","existing","get","SEEDS_TOKEN","key","state","set"],"mappings":";;AASA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAUA,UAAUA,CAACC,SAAoB,EAAEC,KAAkB,EAAA;AACjE,EAAA,MAAMC,QAAQ,GAAaF,SAAS,CAACG,GAAG,CAACC,WAAW,CAAC;EAIrD,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIL,KAAK,EAAE;AAChCC,IAAAA,QAAQ,CAACK,GAAG,CAACF,GAAG,EAAEC,KAAK,CAAC;AAC1B,EAAA;AACF;;;;"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* const seedsMap: SeedsMap = container.get(SEEDS_TOKEN);
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
const SEEDS_TOKEN = Symbol("@wirestate/core/seeds");
|
|
15
15
|
/**
|
|
16
16
|
* Unique symbol used as a token for the container-scoped shared seed object.
|
|
17
17
|
*
|
|
@@ -25,7 +25,7 @@ var SEEDS_TOKEN = Symbol("@wirestate/core/seeds");
|
|
|
25
25
|
* const sharedSeed: AnyObject = container.get(SEED_TOKEN);
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
const SEED_TOKEN = Symbol("@wirestate/core/seed");
|
|
29
29
|
|
|
30
30
|
export { SEEDS_TOKEN, SEED_TOKEN };
|
|
31
31
|
//# sourceMappingURL=tokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sources":["../../../../../../../../src/wirestate-core/seeds/tokens.ts"],"sourcesContent":[null],"names":["SEEDS_TOKEN","Symbol","SEED_TOKEN"],"mappings":"AAAA;;;;;;;;;;;;AAYG;
|
|
1
|
+
{"version":3,"file":"tokens.js","sources":["../../../../../../../../src/wirestate-core/seeds/tokens.ts"],"sourcesContent":[null],"names":["SEEDS_TOKEN","Symbol","SEED_TOKEN"],"mappings":"AAAA;;;;;;;;;;;;AAYG;MACUA,WAAW,GAAkBC,MAAM,CAAC,uBAAuB;AAExE;;;;;;;;;;;;AAYG;MACUC,UAAU,GAAkBD,MAAM,CAAC,sBAAsB;;;;"}
|
|
@@ -19,9 +19,8 @@ import { SEEDS_TOKEN } from './tokens.js';
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
function unapplySeeds(container, seeds) {
|
|
22
|
-
|
|
23
|
-
for (
|
|
24
|
-
var key = seeds_1[_i][0];
|
|
22
|
+
const existing = container.get(SEEDS_TOKEN);
|
|
23
|
+
for (const [key] of seeds) {
|
|
25
24
|
existing.delete(key);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unapply-seeds.js","sources":["../../../../../../../../src/wirestate-core/seeds/unapply-seeds.ts"],"sourcesContent":[null],"names":["unapplySeeds","container","seeds","existing","get","SEEDS_TOKEN","
|
|
1
|
+
{"version":3,"file":"unapply-seeds.js","sources":["../../../../../../../../src/wirestate-core/seeds/unapply-seeds.ts"],"sourcesContent":[null],"names":["unapplySeeds","container","seeds","existing","get","SEEDS_TOKEN","key","delete"],"mappings":";;AASA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAUA,YAAYA,CAACC,SAAoB,EAAEC,KAAkB,EAAA;AACnE,EAAA,MAAMC,QAAQ,GAAaF,SAAS,CAACG,GAAG,CAACC,WAAW,CAAC;AAIrD,EAAA,KAAK,MAAM,CAACC,GAAG,CAAC,IAAIJ,KAAK,EAAE;AACzBC,IAAAA,QAAQ,CAACI,MAAM,CAACD,GAAG,CAAC;AACtB,EAAA;AACF;;;;"}
|
|
@@ -21,11 +21,11 @@ import { ACTIVATED_HANDLER_METADATA } from '../registry.js';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
function getActivatedHandlerMetadata(instance) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let constructor = instance.constructor;
|
|
25
|
+
const chain = [];
|
|
26
26
|
// Traverse prototype chain up to Object/Function.
|
|
27
27
|
while (typeof constructor === "function" && constructor !== Object && constructor !== Function.prototype) {
|
|
28
|
-
|
|
28
|
+
const own = ACTIVATED_HANDLER_METADATA.get(constructor);
|
|
29
29
|
if (own && own.length > 0) {
|
|
30
30
|
chain.push(own);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-activated-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/service/get-activated-handler-metadata.ts"],"sourcesContent":[null],"names":["getActivatedHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","ACTIVATED_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,2BAA2BA,CAACC,QAAgB,EAAA;AAG1D,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,
|
|
1
|
+
{"version":3,"file":"get-activated-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/service/get-activated-handler-metadata.ts"],"sourcesContent":[null],"names":["getActivatedHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","ACTIVATED_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,2BAA2BA,CAACC,QAAgB,EAAA;AAG1D,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,MAAMC,KAAK,GAAkC,EAAE;AAE/C;AACA,EAAA,OAAO,OAAOD,WAAW,KAAK,UAAU,IAAIA,WAAW,KAAKE,MAAM,IAAIF,WAAW,KAAKG,QAAQ,CAACC,SAAS,EAAE;AACxG,IAAA,MAAMC,GAAG,GAAkCC,0BAA0B,CAACC,GAAG,CAACP,WAAqB,CAAC;AAEhG,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;AAIA;EACA,OAAOC,KAAK,CAACU,OAAO,EAAE,CAACC,IAAI,EAAE;AAC/B;;;;"}
|
|
@@ -21,11 +21,11 @@ import { DEACTIVATION_HANDLER_METADATA } from '../registry.js';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
function getDeactivationHandlerMetadata(instance) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let constructor = instance.constructor;
|
|
25
|
+
const chain = [];
|
|
26
26
|
// Traverse prototype chain up to Object/Function.
|
|
27
27
|
while (typeof constructor === "function" && constructor !== Object && constructor !== Function.prototype) {
|
|
28
|
-
|
|
28
|
+
const own = DEACTIVATION_HANDLER_METADATA.get(constructor);
|
|
29
29
|
if (own && own.length > 0) {
|
|
30
30
|
chain.push(own);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-deactivation-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/service/get-deactivation-handler-metadata.ts"],"sourcesContent":[null],"names":["getDeactivationHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","DEACTIVATION_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,8BAA8BA,CAACC,QAAgB,EAAA;AAG7D,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,
|
|
1
|
+
{"version":3,"file":"get-deactivation-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/service/get-deactivation-handler-metadata.ts"],"sourcesContent":[null],"names":["getDeactivationHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","DEACTIVATION_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,8BAA8BA,CAACC,QAAgB,EAAA;AAG7D,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,MAAMC,KAAK,GAAkC,EAAE;AAE/C;AACA,EAAA,OAAO,OAAOD,WAAW,KAAK,UAAU,IAAIA,WAAW,KAAKE,MAAM,IAAIF,WAAW,KAAKG,QAAQ,CAACC,SAAS,EAAE;AACxG,IAAA,MAAMC,GAAG,GAAkCC,6BAA6B,CAACC,GAAG,CAACP,WAAqB,CAAC;AAEnG,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;;;;"}
|
|
@@ -26,9 +26,9 @@ import { ACTIVATED_HANDLER_METADATA } from '../registry.js';
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
function OnActivated() {
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return (target, propertyKey) => {
|
|
30
|
+
const constructor = target.constructor;
|
|
31
|
+
let list = ACTIVATED_HANDLER_METADATA.get(constructor);
|
|
32
32
|
if (!list) {
|
|
33
33
|
list = [];
|
|
34
34
|
ACTIVATED_HANDLER_METADATA.set(constructor, list);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-activated.js","sources":["../../../../../../../../src/wirestate-core/service/on-activated.ts"],"sourcesContent":[null],"names":["OnActivated","target","propertyKey","constructor","list","ACTIVATED_HANDLER_METADATA","get","set","push"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;SACaA,WAAWA,GAAA;AACzB,EAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"on-activated.js","sources":["../../../../../../../../src/wirestate-core/service/on-activated.ts"],"sourcesContent":[null],"names":["OnActivated","target","propertyKey","constructor","list","ACTIVATED_HANDLER_METADATA","get","set","push"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;SACaA,WAAWA,GAAA;AACzB,EAAA,OAAO,CAACC,MAAM,EAAEC,WAAW,KAAI;AAQ7B,IAAA,MAAMC,WAAW,GAAIF,MAAiB,CAACE,WAAW;AAElD,IAAA,IAAIC,IAAI,GAAkCC,0BAA0B,CAACC,GAAG,CAACH,WAAW,CAAC;IAErF,IAAI,CAACC,IAAI,EAAE;AACTA,MAAAA,IAAI,GAAG,EAAE;AACTC,MAAAA,0BAA0B,CAACE,GAAG,CAACJ,WAAW,EAAEC,IAAI,CAAC;AACnD,IAAA;AAEAA,IAAAA,IAAI,CAACI,IAAI,CAACN,WAAW,CAAC;EACxB,CAAC;AACH;;;;"}
|
|
@@ -26,9 +26,9 @@ import { DEACTIVATION_HANDLER_METADATA } from '../registry.js';
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
function OnDeactivation() {
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return (target, propertyKey) => {
|
|
30
|
+
const constructor = target.constructor;
|
|
31
|
+
let list = DEACTIVATION_HANDLER_METADATA.get(constructor);
|
|
32
32
|
if (!list) {
|
|
33
33
|
list = [];
|
|
34
34
|
DEACTIVATION_HANDLER_METADATA.set(constructor, list);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-deactivation.js","sources":["../../../../../../../../src/wirestate-core/service/on-deactivation.ts"],"sourcesContent":[null],"names":["OnDeactivation","target","propertyKey","constructor","list","DEACTIVATION_HANDLER_METADATA","get","set","push"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;SACaA,cAAcA,GAAA;AAC5B,EAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"on-deactivation.js","sources":["../../../../../../../../src/wirestate-core/service/on-deactivation.ts"],"sourcesContent":[null],"names":["OnDeactivation","target","propertyKey","constructor","list","DEACTIVATION_HANDLER_METADATA","get","set","push"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;SACaA,cAAcA,GAAA;AAC5B,EAAA,OAAO,CAACC,MAAM,EAAEC,WAAW,KAAI;AAQ7B,IAAA,MAAMC,WAAW,GAAIF,MAAiB,CAACE,WAAW;AAElD,IAAA,IAAIC,IAAI,GAAkCC,6BAA6B,CAACC,GAAG,CAACH,WAAW,CAAC;IAExF,IAAI,CAACC,IAAI,EAAE;AACTA,MAAAA,IAAI,GAAG,EAAE;AACTC,MAAAA,6BAA6B,CAACE,GAAG,CAACJ,WAAW,EAAEC,IAAI,CAAC;AACtD,IAAA;AAEAA,IAAAA,IAAI,CAACI,IAAI,CAACN,WAAW,CAAC;EACxB,CAAC;AACH;;;;"}
|
|
@@ -20,11 +20,10 @@ import { bindEntry } from '../bind/bind-entry.js';
|
|
|
20
20
|
* mockBindEntry(container, UserService, { skipLifecycle: true });
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
function mockBindEntry(container, entry, options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
var skipLifecycle = options.skipLifecycle;
|
|
23
|
+
function mockBindEntry(container, entry, options = {}) {
|
|
24
|
+
const {
|
|
25
|
+
skipLifecycle
|
|
26
|
+
} = options;
|
|
28
27
|
bindEntry(container, entry, {
|
|
29
28
|
isWithIgnoreLifecycle: skipLifecycle
|
|
30
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-bind-entry.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-bind-entry.ts"],"sourcesContent":[null],"names":["mockBindEntry","container","entry","options","skipLifecycle","bindEntry","isWithIgnoreLifecycle"],"mappings":";;AAuBA;;;;;;;;;;;;;;;;;;;AAmBG;
|
|
1
|
+
{"version":3,"file":"mock-bind-entry.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-bind-entry.ts"],"sourcesContent":[null],"names":["mockBindEntry","container","entry","options","skipLifecycle","bindEntry","isWithIgnoreLifecycle"],"mappings":";;AAuBA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,aAAaA,CAC3BC,SAAoB,EACpBC,KAAwC,EACxCC,UAAgC,EAAE,EAAA;EAElC,MAAM;AAAEC,IAAAA;AAAa,GAAE,GAAGD,OAAO;AAEjCE,EAAAA,SAAS,CAACJ,SAAS,EAAEC,KAAK,EAAE;AAC1BI,IAAAA,qBAAqB,EAAEF;AACxB,GAAA,CAAC;AACJ;;;;"}
|
|
@@ -20,11 +20,10 @@ import { bindService } from '../bind/bind-service.js';
|
|
|
20
20
|
* mockBindService(container, AnalyticsService);
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
function mockBindService(container, ServiceClass, options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
var skipLifecycle = options.skipLifecycle;
|
|
23
|
+
function mockBindService(container, ServiceClass, options = {}) {
|
|
24
|
+
const {
|
|
25
|
+
skipLifecycle
|
|
26
|
+
} = options;
|
|
28
27
|
bindService(container, ServiceClass, {
|
|
29
28
|
isWithIgnoreLifecycle: skipLifecycle
|
|
30
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-bind-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-bind-service.ts"],"sourcesContent":[null],"names":["mockBindService","container","ServiceClass","options","skipLifecycle","bindService","isWithIgnoreLifecycle"],"mappings":";;AAqBA;;;;;;;;;;;;;;;;;;;AAmBG;
|
|
1
|
+
{"version":3,"file":"mock-bind-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-bind-service.ts"],"sourcesContent":[null],"names":["mockBindService","container","ServiceClass","options","skipLifecycle","bindService","isWithIgnoreLifecycle"],"mappings":";;AAqBA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,eAAeA,CAC7BC,SAAoB,EACpBC,YAAwB,EACxBC,UAAkC,EAAE,EAAA;EAEpC,MAAM;AAAEC,IAAAA;AAAa,GAAE,GAAGD,OAAO;AAEjCE,EAAAA,WAAW,CAACJ,SAAS,EAAEC,YAAY,EAAE;AACnCI,IAAAA,qBAAqB,EAAEF;AACxB,GAAA,CAAC;AACJ;;;;"}
|
|
@@ -27,40 +27,32 @@ import { mockBindEntry } from './mock-bind-entry.js';
|
|
|
27
27
|
* });
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
function mockContainer(options) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_b = options.entries,
|
|
37
|
-
entries = _b === void 0 ? [] : _b,
|
|
38
|
-
skipLifecycle = options.skipLifecycle;
|
|
30
|
+
function mockContainer(options = {}) {
|
|
31
|
+
const {
|
|
32
|
+
activate = [],
|
|
33
|
+
entries = [],
|
|
34
|
+
skipLifecycle
|
|
35
|
+
} = options;
|
|
39
36
|
if (activate.length) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
for (var _i = 0, activate_1 = activate; _i < activate_1.length; _i++) {
|
|
44
|
-
var token = activate_1[_i];
|
|
37
|
+
const serviceTokens = entries.map(s => getEntryToken(s));
|
|
38
|
+
for (const token of activate) {
|
|
45
39
|
if (!serviceTokens.includes(token)) {
|
|
46
40
|
throw new WirestateError(ERROR_CODE_INVALID_ARGUMENTS, "Provided services for activation not matching list of services to bind.");
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
43
|
}
|
|
50
|
-
|
|
44
|
+
const container = createContainer({
|
|
51
45
|
parent: options.parent,
|
|
52
46
|
seeds: options.seeds,
|
|
53
47
|
seed: options.seed
|
|
54
48
|
});
|
|
55
|
-
for (
|
|
56
|
-
|
|
57
|
-
mockBindEntry(container, it_1, {
|
|
49
|
+
for (const it of entries) {
|
|
50
|
+
mockBindEntry(container, it, {
|
|
58
51
|
skipLifecycle: skipLifecycle
|
|
59
52
|
});
|
|
60
53
|
}
|
|
61
|
-
for (
|
|
62
|
-
|
|
63
|
-
container.get(it_2);
|
|
54
|
+
for (const it of activate) {
|
|
55
|
+
container.get(it);
|
|
64
56
|
}
|
|
65
57
|
return container;
|
|
66
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-container.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-container.ts"],"sourcesContent":[null],"names":["mockContainer","options","
|
|
1
|
+
{"version":3,"file":"mock-container.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-container.ts"],"sourcesContent":[null],"names":["mockContainer","options","activate","entries","skipLifecycle","length","serviceTokens","map","s","getEntryToken","token","includes","WirestateError","ERROR_CODE_INVALID_ARGUMENTS","container","createContainer","parent","seeds","seed","it","mockBindEntry","get"],"mappings":";;;;;;AA8DA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAUA,aAAaA,CAACC,OAAA,GAAgC,EAAE,EAAA;EAC9D,MAAM;AAAEC,IAAAA,QAAQ,GAAG,EAAE;AAAEC,IAAAA,OAAO,GAAG,EAAE;AAAEC,IAAAA;AAAa,GAAE,GAAGH,OAAO;EAE9D,IAAIC,QAAQ,CAACG,MAAM,EAAE;AACnB,IAAA,MAAMC,aAAa,GAA6BH,OAAO,CAACI,GAAG,CAAEC,CAAC,IAAKC,aAAa,CAACD,CAAC,CAAC,CAAC;AAEpF,IAAA,KAAK,MAAME,KAAK,IAAIR,QAAQ,EAAE;AAC5B,MAAA,IAAI,CAACI,aAAa,CAACK,QAAQ,CAACD,KAAK,CAAC,EAAE;AAClC,QAAA,MAAM,IAAIE,cAAc,CACtBC,4BAA4B,EAC5B,yEAAyE,CAC1E;AACH,MAAA;AACF,IAAA;AACF,EAAA;EAEA,MAAMC,SAAS,GAAcC,eAAe,CAAC;IAAEC,MAAM,EAAEf,OAAO,CAACe,MAAM;IAAEC,KAAK,EAAEhB,OAAO,CAACgB,KAAK;IAAEC,IAAI,EAAEjB,OAAO,CAACiB;AAAI,GAAE,CAAC;AAElH,EAAA,KAAK,MAAMC,EAAE,IAAIhB,OAAO,EAAE;AACxBiB,IAAAA,aAAa,CAACN,SAAS,EAAEK,EAAE,EAAE;AAAEf,MAAAA,aAAa,EAAEA;AAAa,KAAE,CAAC;AAChE,EAAA;AAEA,EAAA,KAAK,MAAMe,EAAE,IAAIjB,QAAQ,EAAE;AACzBY,IAAAA,SAAS,CAACO,GAAG,CAACF,EAAE,CAAC;AACnB,EAAA;AAEA,EAAA,OAAOL,SAAS;AAClB;;;;"}
|
|
@@ -22,13 +22,7 @@ import { mockContainer } from './mock-container.js';
|
|
|
22
22
|
* const service: MyService = mockService(MyService);
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
function mockService(service, container, options) {
|
|
26
|
-
if (container === void 0) {
|
|
27
|
-
container = mockContainer();
|
|
28
|
-
}
|
|
29
|
-
if (options === void 0) {
|
|
30
|
-
options = {};
|
|
31
|
-
}
|
|
25
|
+
function mockService(service, container = mockContainer(), options = {}) {
|
|
32
26
|
mockBindService(container, service, {
|
|
33
27
|
skipLifecycle: options.skipLifecycle
|
|
34
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-service.ts"],"sourcesContent":[null],"names":["mockService","service","container","
|
|
1
|
+
{"version":3,"file":"mock-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-service.ts"],"sourcesContent":[null],"names":["mockService","service","container","mockContainer","options","mockBindService","skipLifecycle","get"],"mappings":";;;AAmBA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAUA,WAAWA,CACzBC,OAAmB,EACnBC,SAAS,GAAGC,aAAa,EAAE,EAC3BC,OAAA,GAA8B,EAAE,EAAA;AAEhCC,EAAAA,eAAe,CAACH,SAAS,EAAED,OAAO,EAAE;IAClCK,aAAa,EAAEF,OAAO,CAACE;AACxB,GAAA,CAAC;AAEF,EAAA,OAAOJ,SAAS,CAACK,GAAG,CAACN,OAAO,CAAM;AACpC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bindingScopeValues as n}from"inversify";function e(e,i){
|
|
1
|
+
import{bindingScopeValues as n}from"inversify";function e(e,i){const o=e.bind(i.id).toDynamicValue((()=>i.factory?i.factory():i.value));return i.scopeBindingType?i.scopeBindingType===n.Transient?o.inTransientScope():i.scopeBindingType===n.Request?o.inRequestScope():o.inSingletonScope():o}export{e as bindDynamicValue};//# sourceMappingURL=bind-dynamic-value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-dynamic-value.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-dynamic-value.ts"],"sourcesContent":[null],"names":["bindingScopeValues","bindDynamicValue","container","entry","binding","bind","id","toDynamicValue","factory","value","scopeBindingType","Transient","inTransientScope","Request","inRequestScope","inSingletonScope"],"mappings":"6BAOAA,MAAA,YA0BM,SAAUC,EAAoBC,EAAsBC,GAMxD,
|
|
1
|
+
{"version":3,"file":"bind-dynamic-value.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-dynamic-value.ts"],"sourcesContent":[null],"names":["bindingScopeValues","bindDynamicValue","container","entry","binding","bind","id","toDynamicValue","factory","value","scopeBindingType","Transient","inTransientScope","Request","inRequestScope","inSingletonScope"],"mappings":"6BAOAA,MAAA,YA0BM,SAAUC,EAAoBC,EAAsBC,GAMxD,MAAMC,EAAuCF,EAAUG,KAAKF,EAAMG,IAAIC,gBAAe,IAC/EJ,EAAMK,QACDL,EAAMK,UAGRL,EAAMM,QAGf,OAAKN,EAAMO,iBAEAP,EAAMO,mBAAqBV,EAAmBW,UAChDP,EAAQQ,mBACNT,EAAMO,mBAAqBV,EAAmBa,QAChDT,EAAQU,iBAERV,EAAQW,mBANRX,CAQX,QAAAH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bindingTypeValues as i}from"inversify";import{bindConstant as n}from"./bind-constant.js";import{bindDynamicValue as o}from"./bind-dynamic-value.js";import{bindService as e}from"./bind-service.js";function t(t,r,m
|
|
1
|
+
import{bindingTypeValues as i}from"inversify";import{bindConstant as n}from"./bind-constant.js";import{bindDynamicValue as o}from"./bind-dynamic-value.js";import{bindService as e}from"./bind-service.js";function t(t,r,m={}){"function"!=typeof r?r.bindingType&&r.bindingType!==i.ConstantValue?r.bindingType!==i.DynamicValue?e(t,r.value,m):o(t,r):n(t,r):e(t,r,m)}export{t as bindEntry};//# sourceMappingURL=bind-entry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-entry.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-entry.ts"],"sourcesContent":[null],"names":["bindingTypeValues","bindConstant","bindDynamicValue","bindService","bindEntry","container","entry","options","bindingType","ConstantValue","DynamicValue","value"],"mappings":"4BA0BAA,MAAA,mCAAAC,MAAA,gDAAAC,MAAA,gDAAAC,MAAA,
|
|
1
|
+
{"version":3,"file":"bind-entry.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-entry.ts"],"sourcesContent":[null],"names":["bindingTypeValues","bindConstant","bindDynamicValue","bindService","bindEntry","container","entry","options","bindingType","ConstantValue","DynamicValue","value"],"mappings":"4BA0BAA,MAAA,mCAAAC,MAAA,gDAAAC,MAAA,gDAAAC,MAAA,oBA6CM,SAAUC,EACdC,EACAC,EACAC,EAA4B,CAAA,GAEP,mBAAVD,EAMNA,EAAME,aAAeF,EAAME,cAAgBR,EAAkBS,cAM9DH,EAAME,cAAgBR,EAAkBU,aAiB5CP,EAAYE,EAAWC,EAAMK,MAAgCJ,GAX3DL,EAAiBG,EAAWC,GAX5BL,EAAaI,EAAWC,GANxBH,EAAYE,EAAWC,EAAOC,EA6BlC,QAAAH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CommandBus as
|
|
1
|
+
import{CommandBus as t}from"../commands/command-bus.js";import{getCommandHandlerMetadata as e}from"../commands/get-command-handler-metadata.js";import{WireScope as o}from"../container/wire-scope.js";import{buildEventDispatcher as n}from"../events/build-event-dispatcher.js";import{EventBus as s}from"../events/event-bus.js";import{getQueryHandlerMetadata as r}from"../queries/get-query-handler-metadata.js";import{QueryBus as c}from"../queries/query-bus.js";import{CONTAINER_REFS_BY_SERVICE as i,WIRE_SCOPES_BY_SERVICE as f,EVENT_UNSUBSCRIBERS_BY_SERVICE as a,QUERY_UNREGISTERS_BY_SERVICE as m,COMMAND_UNREGISTERS_BY_SERVICE as u}from"../registry.js";import{getActivatedHandlerMetadata as d}from"../service/get-activated-handler-metadata.js";import{getDeactivationHandlerMetadata as p}from"../service/get-deactivation-handler-metadata.js";function l(l,y,j){const v=l.bind(y).to(y).inSingletonScope();v.onActivation(((m,u)=>{u.IS_DISPOSED=!1,i.set(u,l),function(t,e){const n=Reflect.getMetadata("design:paramtypes",e);if(!n?.some((t=>t===o)))return;const s=[];for(const e of Object.getOwnPropertyNames(t)){const n=t[e];n?.constructor===o&&s.push(n)}s.length>0&&f.set(t,s)}(u,y);const p=n(u);p&&function(t,e){const o=i.get(t)?.get(s);o&&a.set(t,o.subscribe(e))}(u,p);const v=l.get(c);for(const t of r(u)){const e=u[t.methodName];if("function"!=typeof e)continue;g(u,v.register(t.type,e.bind(u)))}const b=l.get(t);for(const t of e(u)){const e=u[t.methodName];if("function"!=typeof e)continue;h(u,b.register(t.type,e.bind(u)))}if(j?.isWithIgnoreLifecycle);else for(const t of d(u)){const e=u[t];if("function"!=typeof e)continue;const o=e.call(u);o&&"function"==typeof o.then&&o.catch((e=>{console.error("[wirestate] @OnActivated rejected for:",y.name,String(t),e)}))}return u})),v.onDeactivation((t=>{if(j?.isWithIgnoreLifecycle);else for(const e of p(t)){const o=t[e];"function"==typeof o&&o.call(t)}t.IS_DISPOSED=!0,function(t){const e=f.get(t);if(!e)return;for(const t of e)t.isDisposed=!0,t.container=null;f.delete(t)}(t),function(t){const e=u.get(t);if(!e)return;for(const t of e)t();u.delete(t)}(t),function(t){const e=m.get(t);if(!e)return;for(const t of e)t();m.delete(t)}(t),function(t){const e=a.get(t);e&&(e(),a.delete(t))}(t),i.delete(t)}))}function g(t,e){let o=m.get(t);o||(o=[],m.set(t,o)),o.push(e)}function h(t,e){let o=u.get(t);o||(o=[],u.set(t,o)),o.push(e)}export{l as bindService};//# sourceMappingURL=bind-service.js.map
|