@wirestate/react 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/LICENSE +21 -0
  3. package/README.md +319 -0
  4. package/cjs/development/index.js +395 -0
  5. package/cjs/development/index.js.map +1 -0
  6. package/cjs/development/lib.js +64 -0
  7. package/cjs/development/lib.js.map +1 -0
  8. package/cjs/development/test-utils.js +1075 -0
  9. package/cjs/development/test-utils.js.map +1 -0
  10. package/cjs/production/index.js +1 -0
  11. package/cjs/production/index.js.map +1 -0
  12. package/cjs/production/lib.js +1 -0
  13. package/cjs/production/lib.js.map +1 -0
  14. package/cjs/production/test-utils.js +1 -0
  15. package/cjs/production/test-utils.js.map +1 -0
  16. package/esm/development/wirestate-core/bind/bind-constant.js +19 -0
  17. package/esm/development/wirestate-core/bind/bind-constant.js.map +1 -0
  18. package/esm/development/wirestate-core/bind/bind-dynamic-value.js +28 -0
  19. package/esm/development/wirestate-core/bind/bind-dynamic-value.js.map +1 -0
  20. package/esm/development/wirestate-core/bind/bind-entry.js +39 -0
  21. package/esm/development/wirestate-core/bind/bind-entry.js.map +1 -0
  22. package/esm/development/wirestate-core/bind/bind-service.js +253 -0
  23. package/esm/development/wirestate-core/bind/bind-service.js.map +1 -0
  24. package/esm/development/wirestate-core/bind/get-entry-token.js +14 -0
  25. package/esm/development/wirestate-core/bind/get-entry-token.js.map +1 -0
  26. package/esm/development/wirestate-core/commands/command-bus.js +112 -0
  27. package/esm/development/wirestate-core/commands/command-bus.js.map +1 -0
  28. package/esm/development/wirestate-core/commands/get-command-handler-metadata.js +27 -0
  29. package/esm/development/wirestate-core/commands/get-command-handler-metadata.js.map +1 -0
  30. package/esm/development/wirestate-core/container/create-ioc-container.js +35 -0
  31. package/esm/development/wirestate-core/container/create-ioc-container.js.map +1 -0
  32. package/esm/development/wirestate-core/container/wire-scope.js +151 -0
  33. package/esm/development/wirestate-core/container/wire-scope.js.map +1 -0
  34. package/esm/development/wirestate-core/error/error-code.js +10 -0
  35. package/esm/development/wirestate-core/error/error-code.js.map +1 -0
  36. package/esm/development/wirestate-core/error/wirestate-error.js +29 -0
  37. package/esm/development/wirestate-core/error/wirestate-error.js.map +1 -0
  38. package/esm/development/wirestate-core/events/build-event-dispatcher.js +39 -0
  39. package/esm/development/wirestate-core/events/build-event-dispatcher.js.map +1 -0
  40. package/esm/development/wirestate-core/events/event-bus.js +52 -0
  41. package/esm/development/wirestate-core/events/event-bus.js.map +1 -0
  42. package/esm/development/wirestate-core/events/get-event-handler-metadata.js +27 -0
  43. package/esm/development/wirestate-core/events/get-event-handler-metadata.js.map +1 -0
  44. package/esm/development/wirestate-core/queries/get-query-handler-metadata.js +27 -0
  45. package/esm/development/wirestate-core/queries/get-query-handler-metadata.js.map +1 -0
  46. package/esm/development/wirestate-core/queries/query-bus.js +99 -0
  47. package/esm/development/wirestate-core/queries/query-bus.js.map +1 -0
  48. package/esm/development/wirestate-core/registry.js +56 -0
  49. package/esm/development/wirestate-core/registry.js.map +1 -0
  50. package/esm/development/wirestate-core/service/get-activated-handler-metadata.js +27 -0
  51. package/esm/development/wirestate-core/service/get-activated-handler-metadata.js.map +1 -0
  52. package/esm/development/wirestate-core/service/get-deactivation-handler-metadata.js +27 -0
  53. package/esm/development/wirestate-core/service/get-deactivation-handler-metadata.js.map +1 -0
  54. package/esm/development/wirestate-core/test-utils/mock-bind-entry.js +24 -0
  55. package/esm/development/wirestate-core/test-utils/mock-bind-entry.js.map +1 -0
  56. package/esm/development/wirestate-core/test-utils/mock-container.js +52 -0
  57. package/esm/development/wirestate-core/test-utils/mock-container.js.map +1 -0
  58. package/esm/development/wirestate-core/types/commands.js +12 -0
  59. package/esm/development/wirestate-core/types/commands.js.map +1 -0
  60. package/esm/development/wirestate-react/commands/use-command-caller.js +18 -0
  61. package/esm/development/wirestate-react/commands/use-command-caller.js.map +1 -0
  62. package/esm/development/wirestate-react/commands/use-command-handler.js +28 -0
  63. package/esm/development/wirestate-react/commands/use-command-handler.js.map +1 -0
  64. package/esm/development/wirestate-react/commands/use-optional-command-caller.js +19 -0
  65. package/esm/development/wirestate-react/commands/use-optional-command-caller.js.map +1 -0
  66. package/esm/development/wirestate-react/error/error-code.js +6 -0
  67. package/esm/development/wirestate-react/error/error-code.js.map +1 -0
  68. package/esm/development/wirestate-react/events/use-event-emitter.js +22 -0
  69. package/esm/development/wirestate-react/events/use-event-emitter.js.map +1 -0
  70. package/esm/development/wirestate-react/events/use-event.js +30 -0
  71. package/esm/development/wirestate-react/events/use-event.js.map +1 -0
  72. package/esm/development/wirestate-react/events/use-events-handler.js +25 -0
  73. package/esm/development/wirestate-react/events/use-events-handler.js.map +1 -0
  74. package/esm/development/wirestate-react/events/use-events.js +31 -0
  75. package/esm/development/wirestate-react/events/use-events.js.map +1 -0
  76. package/esm/development/wirestate-react/index.js +19 -0
  77. package/esm/development/wirestate-react/index.js.map +1 -0
  78. package/esm/development/wirestate-react/provision/create-injectables-provider.js +101 -0
  79. package/esm/development/wirestate-react/provision/create-injectables-provider.js.map +1 -0
  80. package/esm/development/wirestate-react/provision/ioc-context.js +11 -0
  81. package/esm/development/wirestate-react/provision/ioc-context.js.map +1 -0
  82. package/esm/development/wirestate-react/provision/ioc-provider.js +50 -0
  83. package/esm/development/wirestate-react/provision/ioc-provider.js.map +1 -0
  84. package/esm/development/wirestate-react/provision/use-container-revision.js +13 -0
  85. package/esm/development/wirestate-react/provision/use-container-revision.js.map +1 -0
  86. package/esm/development/wirestate-react/provision/use-container.js +13 -0
  87. package/esm/development/wirestate-react/provision/use-container.js.map +1 -0
  88. package/esm/development/wirestate-react/provision/use-injection.js +22 -0
  89. package/esm/development/wirestate-react/provision/use-injection.js.map +1 -0
  90. package/esm/development/wirestate-react/provision/use-ioc-context.js +21 -0
  91. package/esm/development/wirestate-react/provision/use-ioc-context.js.map +1 -0
  92. package/esm/development/wirestate-react/provision/use-optional-injection.js +29 -0
  93. package/esm/development/wirestate-react/provision/use-optional-injection.js.map +1 -0
  94. package/esm/development/wirestate-react/queries/use-optional-query-caller.js +19 -0
  95. package/esm/development/wirestate-react/queries/use-optional-query-caller.js.map +1 -0
  96. package/esm/development/wirestate-react/queries/use-optional-sync-query-caller.js +19 -0
  97. package/esm/development/wirestate-react/queries/use-optional-sync-query-caller.js.map +1 -0
  98. package/esm/development/wirestate-react/queries/use-query-caller.js +18 -0
  99. package/esm/development/wirestate-react/queries/use-query-caller.js.map +1 -0
  100. package/esm/development/wirestate-react/queries/use-query-handler.js +27 -0
  101. package/esm/development/wirestate-react/queries/use-query-handler.js.map +1 -0
  102. package/esm/development/wirestate-react/queries/use-sync-query-caller.js +20 -0
  103. package/esm/development/wirestate-react/queries/use-sync-query-caller.js.map +1 -0
  104. package/esm/development/wirestate-react/test-utils/with-ioc-provider.js +30 -0
  105. package/esm/development/wirestate-react/test-utils/with-ioc-provider.js.map +1 -0
  106. package/esm/development/wirestate-react/test-utils.js +2 -0
  107. package/esm/development/wirestate-react/test-utils.js.map +1 -0
  108. package/esm/production/wirestate-core/bind/bind-constant.js +1 -0
  109. package/esm/production/wirestate-core/bind/bind-constant.js.map +1 -0
  110. package/esm/production/wirestate-core/bind/bind-dynamic-value.js +1 -0
  111. package/esm/production/wirestate-core/bind/bind-dynamic-value.js.map +1 -0
  112. package/esm/production/wirestate-core/bind/bind-entry.js +1 -0
  113. package/esm/production/wirestate-core/bind/bind-entry.js.map +1 -0
  114. package/esm/production/wirestate-core/bind/bind-service.js +1 -0
  115. package/esm/production/wirestate-core/bind/bind-service.js.map +1 -0
  116. package/esm/production/wirestate-core/bind/get-entry-token.js +1 -0
  117. package/esm/production/wirestate-core/bind/get-entry-token.js.map +1 -0
  118. package/esm/production/wirestate-core/commands/command-bus.js +1 -0
  119. package/esm/production/wirestate-core/commands/command-bus.js.map +1 -0
  120. package/esm/production/wirestate-core/commands/get-command-handler-metadata.js +1 -0
  121. package/esm/production/wirestate-core/commands/get-command-handler-metadata.js.map +1 -0
  122. package/esm/production/wirestate-core/container/create-ioc-container.js +1 -0
  123. package/esm/production/wirestate-core/container/create-ioc-container.js.map +1 -0
  124. package/esm/production/wirestate-core/container/wire-scope.js +1 -0
  125. package/esm/production/wirestate-core/container/wire-scope.js.map +1 -0
  126. package/esm/production/wirestate-core/error/error-code.js +1 -0
  127. package/esm/production/wirestate-core/error/error-code.js.map +1 -0
  128. package/esm/production/wirestate-core/error/wirestate-error.js +1 -0
  129. package/esm/production/wirestate-core/error/wirestate-error.js.map +1 -0
  130. package/esm/production/wirestate-core/events/build-event-dispatcher.js +1 -0
  131. package/esm/production/wirestate-core/events/build-event-dispatcher.js.map +1 -0
  132. package/esm/production/wirestate-core/events/event-bus.js +1 -0
  133. package/esm/production/wirestate-core/events/event-bus.js.map +1 -0
  134. package/esm/production/wirestate-core/events/get-event-handler-metadata.js +1 -0
  135. package/esm/production/wirestate-core/events/get-event-handler-metadata.js.map +1 -0
  136. package/esm/production/wirestate-core/queries/get-query-handler-metadata.js +1 -0
  137. package/esm/production/wirestate-core/queries/get-query-handler-metadata.js.map +1 -0
  138. package/esm/production/wirestate-core/queries/query-bus.js +1 -0
  139. package/esm/production/wirestate-core/queries/query-bus.js.map +1 -0
  140. package/esm/production/wirestate-core/registry.js +1 -0
  141. package/esm/production/wirestate-core/registry.js.map +1 -0
  142. package/esm/production/wirestate-core/service/get-activated-handler-metadata.js +1 -0
  143. package/esm/production/wirestate-core/service/get-activated-handler-metadata.js.map +1 -0
  144. package/esm/production/wirestate-core/service/get-deactivation-handler-metadata.js +1 -0
  145. package/esm/production/wirestate-core/service/get-deactivation-handler-metadata.js.map +1 -0
  146. package/esm/production/wirestate-core/test-utils/mock-bind-entry.js +1 -0
  147. package/esm/production/wirestate-core/test-utils/mock-bind-entry.js.map +1 -0
  148. package/esm/production/wirestate-core/test-utils/mock-container.js +1 -0
  149. package/esm/production/wirestate-core/test-utils/mock-container.js.map +1 -0
  150. package/esm/production/wirestate-core/types/commands.js +1 -0
  151. package/esm/production/wirestate-core/types/commands.js.map +1 -0
  152. package/esm/production/wirestate-react/commands/use-command-caller.js +1 -0
  153. package/esm/production/wirestate-react/commands/use-command-caller.js.map +1 -0
  154. package/esm/production/wirestate-react/commands/use-command-handler.js +1 -0
  155. package/esm/production/wirestate-react/commands/use-command-handler.js.map +1 -0
  156. package/esm/production/wirestate-react/commands/use-optional-command-caller.js +1 -0
  157. package/esm/production/wirestate-react/commands/use-optional-command-caller.js.map +1 -0
  158. package/esm/production/wirestate-react/error/error-code.js +1 -0
  159. package/esm/production/wirestate-react/error/error-code.js.map +1 -0
  160. package/esm/production/wirestate-react/events/use-event-emitter.js +1 -0
  161. package/esm/production/wirestate-react/events/use-event-emitter.js.map +1 -0
  162. package/esm/production/wirestate-react/events/use-event.js +1 -0
  163. package/esm/production/wirestate-react/events/use-event.js.map +1 -0
  164. package/esm/production/wirestate-react/events/use-events-handler.js +1 -0
  165. package/esm/production/wirestate-react/events/use-events-handler.js.map +1 -0
  166. package/esm/production/wirestate-react/events/use-events.js +1 -0
  167. package/esm/production/wirestate-react/events/use-events.js.map +1 -0
  168. package/esm/production/wirestate-react/index.js +1 -0
  169. package/esm/production/wirestate-react/index.js.map +1 -0
  170. package/esm/production/wirestate-react/provision/create-injectables-provider.js +1 -0
  171. package/esm/production/wirestate-react/provision/create-injectables-provider.js.map +1 -0
  172. package/esm/production/wirestate-react/provision/ioc-context.js +1 -0
  173. package/esm/production/wirestate-react/provision/ioc-context.js.map +1 -0
  174. package/esm/production/wirestate-react/provision/ioc-provider.js +1 -0
  175. package/esm/production/wirestate-react/provision/ioc-provider.js.map +1 -0
  176. package/esm/production/wirestate-react/provision/use-container-revision.js +1 -0
  177. package/esm/production/wirestate-react/provision/use-container-revision.js.map +1 -0
  178. package/esm/production/wirestate-react/provision/use-container.js +1 -0
  179. package/esm/production/wirestate-react/provision/use-container.js.map +1 -0
  180. package/esm/production/wirestate-react/provision/use-injection.js +1 -0
  181. package/esm/production/wirestate-react/provision/use-injection.js.map +1 -0
  182. package/esm/production/wirestate-react/provision/use-ioc-context.js +1 -0
  183. package/esm/production/wirestate-react/provision/use-ioc-context.js.map +1 -0
  184. package/esm/production/wirestate-react/provision/use-optional-injection.js +1 -0
  185. package/esm/production/wirestate-react/provision/use-optional-injection.js.map +1 -0
  186. package/esm/production/wirestate-react/queries/use-optional-query-caller.js +1 -0
  187. package/esm/production/wirestate-react/queries/use-optional-query-caller.js.map +1 -0
  188. package/esm/production/wirestate-react/queries/use-optional-sync-query-caller.js +1 -0
  189. package/esm/production/wirestate-react/queries/use-optional-sync-query-caller.js.map +1 -0
  190. package/esm/production/wirestate-react/queries/use-query-caller.js +1 -0
  191. package/esm/production/wirestate-react/queries/use-query-caller.js.map +1 -0
  192. package/esm/production/wirestate-react/queries/use-query-handler.js +1 -0
  193. package/esm/production/wirestate-react/queries/use-query-handler.js.map +1 -0
  194. package/esm/production/wirestate-react/queries/use-sync-query-caller.js +1 -0
  195. package/esm/production/wirestate-react/queries/use-sync-query-caller.js.map +1 -0
  196. package/esm/production/wirestate-react/test-utils/with-ioc-provider.js +1 -0
  197. package/esm/production/wirestate-react/test-utils/with-ioc-provider.js.map +1 -0
  198. package/esm/production/wirestate-react/test-utils.js +1 -0
  199. package/esm/production/wirestate-react/test-utils.js.map +1 -0
  200. package/index.d.ts +218 -0
  201. package/package.json +62 -0
  202. package/test-utils.d.ts +18 -0
@@ -0,0 +1,99 @@
1
+ import { ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER } from '../error/error-code.js';
2
+ import { WirestateError } from '../error/wirestate-error.js';
3
+
4
+ /**
5
+ * Dispatches queries to handlers.
6
+ */
7
+ var QueryBus = /** @class */function () {
8
+ function QueryBus() {
9
+ /**
10
+ * Internal handler storage.
11
+ * Uses a stack for each query type to support shadowing (e.g., component-level vs service-level).
12
+ */
13
+ this.handlers = new Map();
14
+ }
15
+ /**
16
+ * Registers a query handler.
17
+ * Returns an unregister function.
18
+ *
19
+ * @param type - query type
20
+ * @param handler - handler function
21
+ * @returns unregister function
22
+ */
23
+ QueryBus.prototype.register = function (type, handler) {
24
+ var _this = this;
25
+ var stack = this.handlers.get(type);
26
+ if (!stack) {
27
+ stack = [];
28
+ this.handlers.set(type, stack);
29
+ }
30
+ stack.push(handler);
31
+ return function () {
32
+ var current = _this.handlers.get(type);
33
+ if (!current) {
34
+ return;
35
+ }
36
+ var index = current.indexOf(handler);
37
+ if (index >= 0) {
38
+ current.splice(index, 1);
39
+ }
40
+ // Clean empty stacks.
41
+ if (current.length === 0) {
42
+ _this.handlers.delete(type);
43
+ }
44
+ };
45
+ };
46
+ /**
47
+ * Dispatches a query to the last registered handler.
48
+ *
49
+ * @param type - query type
50
+ * @param data - query payload
51
+ * @returns query result
52
+ *
53
+ * @throws if no handler is registered
54
+ */
55
+ QueryBus.prototype.query = function (type, data) {
56
+ var stack = this.handlers.get(type);
57
+ // Always use the top of the stack (most recent registration) if handlers are available.
58
+ if (stack === null || stack === void 0 ? void 0 : stack.length) {
59
+ return stack[stack.length - 1](data);
60
+ }
61
+ throw new WirestateError(ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER, "No query handler registered in container for type: '".concat(String(type), "'."));
62
+ };
63
+ /**
64
+ * Dispatches a query to the last registered handler, returning null if no handler exists.
65
+ *
66
+ * @param type - query type
67
+ * @param data - query payload
68
+ * @returns query result or null if no handler is registered
69
+ */
70
+ QueryBus.prototype.queryOptional = function (type, data) {
71
+ var stack = this.handlers.get(type);
72
+ if (stack === null || stack === void 0 ? void 0 : stack.length) {
73
+ return stack[stack.length - 1](data);
74
+ }
75
+ return null;
76
+ };
77
+ /**
78
+ * Checks if a handler is registered for the given type.
79
+ *
80
+ * @param type - query type
81
+ * @returns true if handler exists
82
+ */
83
+ QueryBus.prototype.has = function (type) {
84
+ var stack = this.handlers.get(type);
85
+ return Boolean(stack && stack.length);
86
+ };
87
+ /**
88
+ * Removes all registered handlers.
89
+ *
90
+ * @internal
91
+ */
92
+ QueryBus.prototype.clear = function () {
93
+ this.handlers.clear();
94
+ };
95
+ return QueryBus;
96
+ }();
97
+
98
+ export { QueryBus };
99
+ //# sourceMappingURL=query-bus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-bus.js","sources":["../../../../../../../../../src/wirestate-core/queries/query-bus.ts"],"sourcesContent":[null],"names":["QueryBus","handlers","Map","prototype","register","type","handler","_this","stack","get","set","push","current","index","indexOf","splice","length","delete","query","data","WirestateError","ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER","concat","String","queryOptional","has","Boolean","clear"],"mappings":"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"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Token for the container-scoped seeds map.
3
+ */
4
+ var SEEDS_TOKEN = Symbol("@wirestate/seeds");
5
+ /**
6
+ * Token for the container-scoped shared seed object.
7
+ */
8
+ var SEED_TOKEN = Symbol("@wirestate/seed");
9
+ /**
10
+ * Map of class constructors to their declared query handlers.
11
+ * Inherited via a prototype chain at resolve time.
12
+ */
13
+ var QUERY_HANDLER_METADATA = new WeakMap();
14
+ /**
15
+ * Map of class constructors to their declared command handlers.
16
+ * Inherited via a prototype chain at resolve time.
17
+ */
18
+ var COMMAND_HANDLER_METADATA = new WeakMap();
19
+ /**
20
+ * Map of class constructors to their `@OnActivated`-decorated method names.
21
+ * Inherited via a prototype chain at resolve time.
22
+ */
23
+ var ACTIVATED_HANDLER_METADATA = new WeakMap();
24
+ /**
25
+ * Map of class constructors to their `@OnDeactivation`-decorated method names.
26
+ * Inherited via a prototype chain at resolve time.
27
+ */
28
+ var DEACTIVATION_HANDLER_METADATA = new WeakMap();
29
+ /**
30
+ * Map of class constructors for their declared event handlers.
31
+ * Inherited via a prototype chain at resolve time.
32
+ */
33
+ var EVENT_HANDLER_METADATA = new WeakMap();
34
+ /**
35
+ * Private storage for service-to-container references.
36
+ */
37
+ var CONTAINER_REFS_BY_SERVICE = new WeakMap();
38
+ /**
39
+ * Private storage for injected WireScope instances per service.
40
+ */
41
+ var WIRE_SCOPES_BY_SERVICE = new WeakMap();
42
+ /**
43
+ * Private storage for service event unsubscribers.
44
+ */
45
+ var EVENT_UNSUBSCRIBERS_BY_SERVICE = new WeakMap();
46
+ /**
47
+ * Private storage for service query unregisters.
48
+ */
49
+ var QUERY_UNREGISTERS_BY_SERVICE = new WeakMap();
50
+ /**
51
+ * Private storage for service command unregisters.
52
+ */
53
+ var COMMAND_UNREGISTERS_BY_SERVICE = new WeakMap();
54
+
55
+ 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, SEEDS_TOKEN, SEED_TOKEN, WIRE_SCOPES_BY_SERVICE };
56
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sources":["../../../../../../../../src/wirestate-core/registry.ts"],"sourcesContent":[null],"names":["SEEDS_TOKEN","Symbol","SEED_TOKEN","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;;AAEG;IACUA,WAAW,GAAkBC,MAAM,CAAC,kBAAkB;AAEnE;;AAEG;IACUC,UAAU,GAAkBD,MAAM,CAAC,iBAAiB;AAEjE;;;AAGG;IACUE,sBAAsB,GAAkD,IAAIC,OAAO;AAEhG;;;AAGG;IACUC,wBAAwB,GAAoD,IAAID,OAAO;AAEpG;;;AAGG;IACUE,0BAA0B,GAA4C,IAAIF,OAAO;AAE9F;;;AAGG;IACUG,6BAA6B,GAA4C,IAAIH,OAAO;AAEjG;;;AAGG;IACUI,sBAAsB,GAAkD,IAAIJ,OAAO;AAEhG;;AAEG;IACUK,yBAAyB,GAA+B,IAAIL,OAAO;AAEhF;;AAEG;IACUM,sBAAsB,GAAsC,IAAIN,OAAO;AAEpF;;AAEG;IACUO,8BAA8B,GAAwC,IAAIP,OAAO;AAE9F;;AAEG;IACUQ,4BAA4B,GAA6C,IAAIR,OAAO;AAEjG;;AAEG;IACUS,8BAA8B,GAA+C,IAAIT,OAAO;;;;"}
@@ -0,0 +1,27 @@
1
+ import { ACTIVATED_HANDLER_METADATA } from '../registry.js';
2
+
3
+ /**
4
+ * Retrieves `@OnActivated` method names from the class hierarchy.
5
+ * Returns method names ordered from base to derived class.
6
+ *
7
+ * @param instance - service instance
8
+ * @returns list of method names
9
+ * @internal
10
+ */
11
+ function getActivatedHandlerMetadata(instance) {
12
+ var constructor = instance.constructor;
13
+ var chain = [];
14
+ // Traverse prototype chain up to Object/Function.
15
+ while (typeof constructor === "function" && constructor !== Object && constructor !== Function.prototype) {
16
+ var own = ACTIVATED_HANDLER_METADATA.get(constructor);
17
+ if (own && own.length > 0) {
18
+ chain.push(own);
19
+ }
20
+ constructor = Object.getPrototypeOf(constructor);
21
+ }
22
+ // Reverse to ensure parent-first execution order.
23
+ return chain.reverse().flat();
24
+ }
25
+
26
+ export { getActivatedHandlerMetadata };
27
+ //# sourceMappingURL=get-activated-handler-metadata.js.map
@@ -0,0 +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;;;;;;;AAOG;AACG,SAAUA,2BAA2BA,CAACC,QAAgB,EAAA;AAG1D,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,IAAMC,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,IAAMC,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;;;;"}
@@ -0,0 +1,27 @@
1
+ import { DEACTIVATION_HANDLER_METADATA } from '../registry.js';
2
+
3
+ /**
4
+ * Retrieves `@OnDeactivation` method names from the class hierarchy.
5
+ * Returns method names ordered from base to derived class.
6
+ *
7
+ * @param instance - service instance
8
+ * @returns list of method names
9
+ * @internal
10
+ */
11
+ function getDeactivationHandlerMetadata(instance) {
12
+ var constructor = instance.constructor;
13
+ var chain = [];
14
+ // Traverse prototype chain up to Object/Function.
15
+ while (typeof constructor === "function" && constructor !== Object && constructor !== Function.prototype) {
16
+ var own = DEACTIVATION_HANDLER_METADATA.get(constructor);
17
+ if (own && own.length > 0) {
18
+ chain.push(own);
19
+ }
20
+ constructor = Object.getPrototypeOf(constructor);
21
+ }
22
+ // Reverse to ensure parent-first execution order.
23
+ return chain.reverse().flat();
24
+ }
25
+
26
+ export { getDeactivationHandlerMetadata };
27
+ //# sourceMappingURL=get-deactivation-handler-metadata.js.map
@@ -0,0 +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;;;;;;;AAOG;AACG,SAAUA,8BAA8BA,CAACC,QAAgB,EAAA;AAG7D,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,IAAMC,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,IAAMC,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;;;;"}
@@ -0,0 +1,24 @@
1
+ import { bindEntry } from '../bind/bind-entry.js';
2
+
3
+ /**
4
+ * Binds a service entry to the IoC container for testing purposes.
5
+ * This utility uses {@link bindEntry} internally.
6
+ * It supports both service classes and injectable descriptors (constants, dynamic values, etc.).
7
+ *
8
+ * @param container - the IoC container to bind the entry to
9
+ * @param entry - the service class or injectable descriptor to bind
10
+ * @param options - optional binding configuration
11
+ * @returns void
12
+ */
13
+ function mockBindEntry(container, entry, options) {
14
+ if (options === void 0) {
15
+ options = {};
16
+ }
17
+ var skipLifecycle = options.skipLifecycle;
18
+ return bindEntry(container, entry, {
19
+ isWithIgnoreLifecycle: skipLifecycle
20
+ });
21
+ }
22
+
23
+ export { mockBindEntry };
24
+ //# sourceMappingURL=mock-bind-entry.js.map
@@ -0,0 +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":";;AAiBA;;;;;;;;;AASG;SACaA,aAAaA,CAC3BC,SAAoB,EACpBC,KAAyC,EACzCC,OAAmC,EAAA;AAAnC,EAAA,IAAAA,OAAA,KAAA,MAAA,EAAA;IAAAA,OAAA,GAAA,EAAmC;AAAA,EAAA;AAE3B,EAAA,IAAAC,aAAa,GAAKD,OAAO,CAAAC,aAAZ;AAErB,EAAA,OAAOC,SAAS,CAACJ,SAAS,EAAEC,KAAK,EAAE;AACjCI,IAAAA,qBAAqB,EAAEF;AACxB,GAAA,CAAC;AACJ;;;;"}
@@ -0,0 +1,52 @@
1
+ import { getEntryToken } from '../bind/get-entry-token.js';
2
+ import { createIocContainer } from '../container/create-ioc-container.js';
3
+ import { ERROR_CODE_INVALID_ARGUMENTS } from '../error/error-code.js';
4
+ import { WirestateError } from '../error/wirestate-error.js';
5
+ import { mockBindEntry } from './mock-bind-entry.js';
6
+
7
+ /**
8
+ * Creates and configures a mock IoC container for testing.
9
+ * This utility initializes a new container and binds the provided services or descriptors using {@link mockBindEntry}.
10
+ * It also supports optional immediate activation of services.
11
+ *
12
+ * @param options - configuration options for the mock container
13
+ * @returns a configured InversifyJS {@link Container}
14
+ *
15
+ * @throws {WirestateError} if an identifier in `activate` is not found in `services`
16
+ */
17
+ function mockContainer(options) {
18
+ if (options === void 0) {
19
+ options = {};
20
+ }
21
+ var _a = options.activate,
22
+ activate = _a === void 0 ? [] : _a,
23
+ _b = options.entries,
24
+ entries = _b === void 0 ? [] : _b,
25
+ skipLifecycle = options.skipLifecycle;
26
+ if (activate.length) {
27
+ var serviceTokens = entries.map(function (s) {
28
+ return getEntryToken(s);
29
+ });
30
+ for (var _i = 0, activate_1 = activate; _i < activate_1.length; _i++) {
31
+ var token = activate_1[_i];
32
+ if (!serviceTokens.includes(token)) {
33
+ throw new WirestateError(ERROR_CODE_INVALID_ARGUMENTS, "Provided services for activation not matching list of services to bind.");
34
+ }
35
+ }
36
+ }
37
+ var container = createIocContainer();
38
+ for (var _c = 0, entries_1 = entries; _c < entries_1.length; _c++) {
39
+ var it_1 = entries_1[_c];
40
+ mockBindEntry(container, it_1, {
41
+ skipLifecycle: skipLifecycle
42
+ });
43
+ }
44
+ for (var _d = 0, activate_2 = activate; _d < activate_2.length; _d++) {
45
+ var it_2 = activate_2[_d];
46
+ container.get(it_2);
47
+ }
48
+ return container;
49
+ }
50
+
51
+ export { mockContainer };
52
+ //# sourceMappingURL=mock-container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-container.js","sources":["../../../../../../../../../src/wirestate-core/test-utils/mock-container.ts"],"sourcesContent":[null],"names":["mockContainer","options","_a","activate","_b","entries","skipLifecycle","length","serviceTokens","map","s","getEntryToken","_i","activate_1","token","includes","WirestateError","ERROR_CODE_INVALID_ARGUMENTS","container","createIocContainer","_c","entries_1","it_1","mockBindEntry","_d","activate_2","it_2","get"],"mappings":";;;;;;AA6BA;;;;;;;;;AASG;AACG,SAAUA,aAAaA,CAACC,OAAmC,EAAA;AAAnC,EAAA,IAAAA,OAAA,KAAA,MAAA,EAAA;IAAAA,OAAA,GAAA,EAAmC;AAAA,EAAA;AACvD,EAAA,IAAAC,EAAA,GAA+CD,OAAO,CAAAE,QAAzC;IAAbA,QAAQ,GAAAD,EAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,EAAA;IAAEE,EAAA,GAAgCH,OAAO,QAA3B;IAAZI,OAAO,mBAAG,EAAE,GAAAD,EAAA;IAAEE,aAAa,GAAKL,OAAO,CAAAK,aAAZ;EAElD,IAAIH,QAAQ,CAACI,MAAM,EAAE;IACnB,IAAMC,aAAa,GAA6BH,OAAO,CAACI,GAAG,CAAC,UAACC,CAAC,EAAA;MAAK,OAAAC,aAAa,CAACD,CAAC,CAAC;AAAhB,IAAA,CAAgB,CAAC;AAEpF,IAAA,KAAoB,IAAAE,EAAA,GAAA,CAAQ,EAARC,UAAA,GAAAV,QAAQ,EAARS,sBAAQ,EAARA,EAAA,EAAQ,EAAE;AAAzB,MAAA,IAAME,KAAK,GAAAD,UAAA,CAAAD,EAAA,CAAA;AACd,MAAA,IAAI,CAACJ,aAAa,CAACO,QAAQ,CAACD,KAAK,CAAC,EAAE;AAClC,QAAA,MAAM,IAAIE,cAAc,CACtBC,4BAA4B,EAC5B,yEAAyE,CAC1E;AACH,MAAA;AACF,IAAA;AACF,EAAA;AAEA,EAAA,IAAMC,SAAS,GAAcC,kBAAkB,EAAE;AAEjD,EAAA,KAAiB,IAAAC,EAAA,GAAA,CAAO,EAAPC,SAAA,GAAAhB,OAAO,EAAPe,qBAAO,EAAPA,EAAA,EAAO,EAAE;AAArB,IAAA,IAAME,IAAE,GAAAD,SAAA,CAAAD,EAAA,CAAA;AACXG,IAAAA,aAAa,CAACL,SAAS,EAAEI,IAAE,EAAE;AAAEhB,MAAAA,aAAa,EAAEA;AAAa,KAAE,CAAC;AAChE,EAAA;AAEA,EAAA,KAAiB,IAAAkB,EAAA,GAAA,CAAQ,EAARC,UAAA,GAAAtB,QAAQ,EAARqB,sBAAQ,EAARA,EAAA,EAAQ,EAAE;AAAtB,IAAA,IAAME,IAAE,GAAAD,UAAA,CAAAD,EAAA,CAAA;AACXN,IAAAA,SAAS,CAACS,GAAG,CAACD,IAAE,CAAC;AACnB,EAAA;AAEA,EAAA,OAAOR,SAAS;AAClB;;;;"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Command execution status.
3
+ */
4
+ var ECommandStatus;
5
+ (function (ECommandStatus) {
6
+ ECommandStatus["PENDING"] = "pending";
7
+ ECommandStatus["SETTLED"] = "settled";
8
+ ECommandStatus["ERROR"] = "error";
9
+ })(ECommandStatus || (ECommandStatus = {}));
10
+
11
+ export { ECommandStatus };
12
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sources":["../../../../../../../../../src/wirestate-core/types/commands.ts"],"sourcesContent":[null],"names":["ECommandStatus"],"mappings":"AA2CA;;AAEG;IACSA;AAAZ,CAAA,UAAYA,cAAc,EAAA;AACxBA,EAAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnBA,EAAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnBA,EAAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACjB,CAAC,EAJWA,cAAc,KAAdA,cAAc,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -0,0 +1,18 @@
1
+ import { CommandBus } from '@wirestate/core';
2
+ import { useCallback } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+
5
+ /**
6
+ * Returns a function to dispatch commands on the active container.
7
+ *
8
+ * @returns command dispatcher
9
+ */
10
+ function useCommandCaller() {
11
+ var container = useContainer();
12
+ return useCallback(function (type, data) {
13
+ return container.get(CommandBus).command(type, data);
14
+ }, [container]);
15
+ }
16
+
17
+ export { useCommandCaller };
18
+ //# sourceMappingURL=use-command-caller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-command-caller.js","sources":["../../../../../../../../../src/wirestate-react/commands/use-command-caller.ts"],"sourcesContent":[null],"names":["useCommandCaller","container","useContainer","useCallback","type","data","get","CommandBus","command"],"mappings":";;;;AAQA;;;;AAIG;SACaA,gBAAgBA,GAAA;AAC9B,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAAgEC,IAAO,EAAEC,IAAQ,EAAA;AAM/E,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,UAAU,CAAC,CAACC,OAAO,CAAOJ,IAAI,EAAEC,IAAI,CAAC;AAC5D,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACZ;AACH;;;;"}
@@ -0,0 +1,28 @@
1
+ import { CommandBus } from '@wirestate/core';
2
+ import { useRef, useEffect } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+
5
+ /**
6
+ * Registers a command handler for the component's lifetime.
7
+ * The handler is stored in a ref to avoid manual memoization.
8
+ * Only one handler is active per type; newer registrations shadow older ones.
9
+ *
10
+ * @param type - command type
11
+ * @param handler - command handler function
12
+ */
13
+ function useCommandHandler(type, handler) {
14
+ var container = useContainer();
15
+ var handlerRef = useRef(handler);
16
+ // Sync ref with the latest closure on every render.
17
+ useEffect(function () {
18
+ handlerRef.current = handler;
19
+ });
20
+ useEffect(function () {
21
+ return container.get(CommandBus).register(type, function (data) {
22
+ return handlerRef.current(data);
23
+ });
24
+ }, [container, type]);
25
+ }
26
+
27
+ export { useCommandHandler };
28
+ //# sourceMappingURL=use-command-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-command-handler.js","sources":["../../../../../../../../../src/wirestate-react/commands/use-command-handler.ts"],"sourcesContent":[null],"names":["useCommandHandler","type","handler","container","useContainer","handlerRef","useRef","useEffect","current","get","CommandBus","register","data"],"mappings":";;;;AAKA;;;;;;;AAOG;AACG,SAAUA,iBAAiBA,CAA2BC,IAAiB,EAAEC,OAA6B,EAAA;AAC1G,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAC3C,EAAA,IAAMC,UAAU,GAAGC,MAAM,CAAuBJ,OAAO,CAAC;AAExD;AACAK,EAAAA,SAAS,CAAC,YAAA;IACRF,UAAU,CAACG,OAAO,GAAGN,OAAO;AAC9B,EAAA,CAAC,CAAC;AAEFK,EAAAA,SAAS,CAAC,YAAA;AACR,IAAA,OAAOJ,SAAS,CAACM,GAAG,CAACC,UAAU,CAAC,CAACC,QAAQ,CAAOV,IAAI,EAAE,UAACW,IAAI,EAAA;AAAK,MAAA,OAAAP,UAAU,CAACG,OAAO,CAACI,IAAI,CAAC;AAAxB,IAAA,CAAwB,CAAC;AAC3F,EAAA,CAAC,EAAE,CAACT,SAAS,EAAEF,IAAI,CAAC,CAAC;AACvB;;;;"}
@@ -0,0 +1,19 @@
1
+ import { CommandBus } from '@wirestate/core';
2
+ import { useCallback } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+
5
+ /**
6
+ * Returns a function to dispatch optional commands on the active container.
7
+ * Returns null instead of throwing when no handler is registered.
8
+ *
9
+ * @returns optional command dispatcher
10
+ */
11
+ function useOptionalCommandCaller() {
12
+ var container = useContainer();
13
+ return useCallback(function (type, data) {
14
+ return container.get(CommandBus).commandOptional(type, data);
15
+ }, [container]);
16
+ }
17
+
18
+ export { useOptionalCommandCaller };
19
+ //# sourceMappingURL=use-optional-command-caller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-optional-command-caller.js","sources":["../../../../../../../../../src/wirestate-react/commands/use-optional-command-caller.ts"],"sourcesContent":[null],"names":["useOptionalCommandCaller","container","useContainer","useCallback","type","data","get","CommandBus","commandOptional"],"mappings":";;;;AAQA;;;;;AAKG;SACaA,wBAAwBA,GAAA;AACtC,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAAgEC,IAAO,EAAEC,IAAQ,EAAA;AAM/E,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,UAAU,CAAC,CAACC,eAAe,CAAOJ,IAAI,EAAEC,IAAI,CAAC;AACpE,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACZ;AACH;;;;"}
@@ -0,0 +1,6 @@
1
+ var ERROR_CODE_VALIDATION_ERROR = 1050;
2
+ var ERROR_CODE_INVALID_CONTEXT = 1052;
3
+ var ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER = 1101;
4
+
5
+ export { ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER, ERROR_CODE_INVALID_CONTEXT, ERROR_CODE_VALIDATION_ERROR };
6
+ //# sourceMappingURL=error-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-code.js","sources":["../../../../../../../../../src/wirestate-react/error/error-code.ts"],"sourcesContent":[null],"names":["ERROR_CODE_VALIDATION_ERROR","ERROR_CODE_INVALID_CONTEXT","ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER"],"mappings":"AAAO,IAAMA,2BAA2B,GAAW;AAC5C,IAAMC,0BAA0B,GAAW;AAE3C,IAAMC,0CAA0C,GAAW;;;;"}
@@ -0,0 +1,22 @@
1
+ import { EventBus } from '@wirestate/core';
2
+ import { useCallback } from 'react';
3
+ import { useIocContext } from '../provision/use-ioc-context.js';
4
+
5
+ /**
6
+ * Returns a stable function to emit events.
7
+ *
8
+ * @returns event emitter
9
+ */
10
+ function useEventEmitter() {
11
+ var container = useIocContext().container;
12
+ return useCallback(function (type, payload, from) {
13
+ container.get(EventBus).emit({
14
+ type: type,
15
+ payload: payload,
16
+ from: from
17
+ });
18
+ }, [container]);
19
+ }
20
+
21
+ export { useEventEmitter };
22
+ //# sourceMappingURL=use-event-emitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-event-emitter.js","sources":["../../../../../../../../../src/wirestate-react/events/use-event-emitter.ts"],"sourcesContent":[null],"names":["useEventEmitter","container","useIocContext","useCallback","type","payload","from","get","EventBus","emit"],"mappings":";;;;AAQA;;;;AAIG;SACaA,eAAeA,GAAA;AAC7B,EAAA,IAAMC,SAAS,GAAcC,aAAa,EAAE,CAACD,SAAS;EAEtD,OAAOE,WAAW,CAChB,UAAyBC,IAAO,EAAEC,OAAW,EAAEC,IAAc,EAAA;AAO3DL,IAAAA,SAAS,CAACM,GAAG,CAACC,QAAQ,CAAC,CAACC,IAAI,CAAC;AAAEL,MAAAA,IAAI,EAAAA,IAAA;AAAEC,MAAAA,OAAO,EAAAA,OAAA;AAAEC,MAAAA,IAAI,EAAAA;AAAA,KAAE,CAAC;AACvD,EAAA,CAAC,EACD,CAACL,SAAS,CAAC,CACZ;AACH;;;;"}
@@ -0,0 +1,30 @@
1
+ import { EventBus } from '@wirestate/core';
2
+ import { useRef, useEffect } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+
5
+ /**
6
+ * Subscribes a component to events.
7
+ *
8
+ * @param type - event type to listen to
9
+ * @param handler - event handler to invoke when event is emitted
10
+ */
11
+ function useEvent(type, handler) {
12
+ var typeRef = useRef(type);
13
+ var handlerRef = useRef(handler);
14
+ var container = useContainer();
15
+ useEffect(function () {
16
+ typeRef.current = type;
17
+ handlerRef.current = handler;
18
+ });
19
+ useEffect(function () {
20
+ return container.get(EventBus).subscribe(function (event) {
21
+ var _a;
22
+ if (event.type === typeRef.current) {
23
+ (_a = handlerRef.current) === null || _a === void 0 ? void 0 : _a.call(handlerRef, event);
24
+ }
25
+ });
26
+ }, [container, type]);
27
+ }
28
+
29
+ export { useEvent };
30
+ //# sourceMappingURL=use-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-event.js","sources":["../../../../../../../../../src/wirestate-react/events/use-event.ts"],"sourcesContent":[null],"names":["useEvent","type","handler","typeRef","useRef","handlerRef","container","useContainer","useEffect","current","get","EventBus","subscribe","event","_a","call"],"mappings":";;;;AAKA;;;;;AAKG;AACG,SAAUA,QAAQA,CAACC,IAAe,EAAEC,OAAqB,EAAA;AAC7D,EAAA,IAAMC,OAAO,GAAgCC,MAAM,CAACH,IAAI,CAAC;AACzD,EAAA,IAAMI,UAAU,GAAmCD,MAAM,CAACF,OAAO,CAAC;AAClE,EAAA,IAAMI,SAAS,GAAcC,YAAY,EAAE;AAE3CC,EAAAA,SAAS,CAAC,YAAA;IACRL,OAAO,CAACM,OAAO,GAAGR,IAAI;IACtBI,UAAU,CAACI,OAAO,GAAGP,OAAO;AAC9B,EAAA,CAAC,CAAC;AAEFM,EAAAA,SAAS,CAAC,YAAA;IACR,OAAOF,SAAS,CAACI,GAAG,CAACC,QAAQ,CAAC,CAACC,SAAS,CAAC,UAACC,KAAK,EAAA;;AAC7C,MAAA,IAAIA,KAAK,CAACZ,IAAI,KAAKE,OAAO,CAACM,OAAO,EAAE;QAClC,CAAAK,EAAA,GAAAT,UAAU,CAACI,OAAO,MAAA,IAAA,IAAAK,EAAA,KAAA,MAAA,GAAA,MAAA,GAAAA,EAAA,CAAAC,IAAA,CAAAV,UAAA,EAAGQ,KAAK,CAAC;AAC7B,MAAA;AACF,IAAA,CAAC,CAAC;AACJ,EAAA,CAAC,EAAE,CAACP,SAAS,EAAEL,IAAI,CAAC,CAAC;AACvB;;;;"}
@@ -0,0 +1,25 @@
1
+ import { EventBus } from '@wirestate/core';
2
+ import { useRef, useEffect } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+
5
+ /**
6
+ * Subscribes a component to all events without type filtering.
7
+ *
8
+ * @param handler - event handler invoked for every emitted event
9
+ */
10
+ function useEventsHandler(handler) {
11
+ var handlerRef = useRef(handler);
12
+ var container = useContainer();
13
+ useEffect(function () {
14
+ handlerRef.current = handler;
15
+ });
16
+ useEffect(function () {
17
+ return container.get(EventBus).subscribe(function (event) {
18
+ var _a;
19
+ (_a = handlerRef.current) === null || _a === void 0 ? void 0 : _a.call(handlerRef, event);
20
+ });
21
+ }, [container]);
22
+ }
23
+
24
+ export { useEventsHandler };
25
+ //# sourceMappingURL=use-events-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-events-handler.js","sources":["../../../../../../../../../src/wirestate-react/events/use-events-handler.ts"],"sourcesContent":[null],"names":["useEventsHandler","handler","handlerRef","useRef","container","useContainer","useEffect","current","get","EventBus","subscribe","event","_a","call"],"mappings":";;;;AAMA;;;;AAIG;AACG,SAAUA,gBAAgBA,CAACC,OAAqB,EAAA;AACpD,EAAA,IAAMC,UAAU,GAA0CC,MAAM,CAACF,OAAO,CAAC;AACzE,EAAA,IAAMG,SAAS,GAAcC,YAAY,EAAE;AAE3CC,EAAAA,SAAS,CAAC,YAAA;IACRJ,UAAU,CAACK,OAAO,GAAGN,OAAO;AAC9B,EAAA,CAAC,CAAC;AAEFK,EAAAA,SAAS,CAAC,YAAA;IACR,OAAOF,SAAS,CAACI,GAAG,CAACC,QAAQ,CAAC,CAACC,SAAS,CAAC,UAACC,KAAK,EAAA;;MAC7C,CAAAC,EAAA,GAAAV,UAAU,CAACK,OAAO,MAAA,IAAA,IAAAK,EAAA,KAAA,MAAA,GAAA,MAAA,GAAAA,EAAA,CAAAC,IAAA,CAAAX,UAAA,EAAGS,KAAK,CAAC;AAC7B,IAAA,CAAC,CAAC;AACJ,EAAA,CAAC,EAAE,CAACP,SAAS,CAAC,CAAC;AACjB;;;;"}
@@ -0,0 +1,31 @@
1
+ import { EventBus } from '@wirestate/core';
2
+ import { useRef, useEffect } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+ import '../provision/ioc-context.js';
5
+
6
+ /**
7
+ * Subscribes a component to multiple event types.
8
+ *
9
+ * @param types - event types to filter by
10
+ * @param handler - events handler
11
+ */
12
+ function useEvents(types, handler) {
13
+ var typesRef = useRef(types);
14
+ var handlerRef = useRef(handler);
15
+ var container = useContainer();
16
+ useEffect(function () {
17
+ typesRef.current = types;
18
+ handlerRef.current = handler;
19
+ });
20
+ useEffect(function () {
21
+ return container.get(EventBus).subscribe(function (event) {
22
+ var _a;
23
+ if (typesRef.current.includes(event.type)) {
24
+ (_a = handlerRef.current) === null || _a === void 0 ? void 0 : _a.call(handlerRef, event);
25
+ }
26
+ });
27
+ }, [container]);
28
+ }
29
+
30
+ export { useEvents };
31
+ //# sourceMappingURL=use-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-events.js","sources":["../../../../../../../../../src/wirestate-react/events/use-events.ts"],"sourcesContent":[null],"names":["useEvents","types","handler","typesRef","useRef","handlerRef","container","useContainer","useEffect","current","get","EventBus","subscribe","event","includes","type","_a","call"],"mappings":";;;;;AAKA;;;;;AAKG;AACG,SAAUA,SAASA,CAACC,KAA+B,EAAEC,OAAqB,EAAA;AAC9E,EAAA,IAAMC,QAAQ,GAA+CC,MAAM,CAACH,KAAK,CAAC;AAC1E,EAAA,IAAMI,UAAU,GAAmCD,MAAM,CAACF,OAAO,CAAC;AAClE,EAAA,IAAMI,SAAS,GAAcC,YAAY,EAAE;AAE3CC,EAAAA,SAAS,CAAC,YAAA;IACRL,QAAQ,CAACM,OAAO,GAAGR,KAAK;IACxBI,UAAU,CAACI,OAAO,GAAGP,OAAO;AAC9B,EAAA,CAAC,CAAC;AAEFM,EAAAA,SAAS,CAAC,YAAA;IACR,OAAOF,SAAS,CAACI,GAAG,CAACC,QAAQ,CAAC,CAACC,SAAS,CAAC,UAACC,KAAK,EAAA;;MAC7C,IAAIV,QAAQ,CAACM,OAAO,CAACK,QAAQ,CAACD,KAAK,CAACE,IAAI,CAAC,EAAE;QACzC,CAAAC,EAAA,GAAAX,UAAU,CAACI,OAAO,MAAA,IAAA,IAAAO,EAAA,KAAA,MAAA,GAAA,MAAA,GAAAA,EAAA,CAAAC,IAAA,CAAAZ,UAAA,EAAGQ,KAAK,CAAC;AAC7B,MAAA;AACF,IAAA,CAAC,CAAC;AACJ,EAAA,CAAC,EAAE,CAACP,SAAS,CAAC,CAAC;AACjB;;;;"}
@@ -0,0 +1,19 @@
1
+ export { useCommandCaller } from './commands/use-command-caller.js';
2
+ export { useOptionalCommandCaller } from './commands/use-optional-command-caller.js';
3
+ export { useCommandHandler } from './commands/use-command-handler.js';
4
+ export { useQueryCaller } from './queries/use-query-caller.js';
5
+ export { useOptionalQueryCaller } from './queries/use-optional-query-caller.js';
6
+ export { useQueryHandler } from './queries/use-query-handler.js';
7
+ export { useSyncQueryCaller } from './queries/use-sync-query-caller.js';
8
+ export { useOptionalSyncQueryCaller } from './queries/use-optional-sync-query-caller.js';
9
+ export { useInjection } from './provision/use-injection.js';
10
+ export { useOptionalInjection } from './provision/use-optional-injection.js';
11
+ export { createInjectablesProvider } from './provision/create-injectables-provider.js';
12
+ export { IocProvider } from './provision/ioc-provider.js';
13
+ export { useContainer } from './provision/use-container.js';
14
+ export { useContainerRevision } from './provision/use-container-revision.js';
15
+ export { useEvent } from './events/use-event.js';
16
+ export { useEvents } from './events/use-events.js';
17
+ export { useEventsHandler } from './events/use-events-handler.js';
18
+ export { useEventEmitter } from './events/use-event-emitter.js';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}