@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,101 @@
1
+ import { getEntryToken, WirestateError, applySeeds, bindEntry, unapplySeeds } from '@wirestate/core';
2
+ import { useContext, useState, useMemo, useEffect } from 'react';
3
+ import { ERROR_CODE_VALIDATION_ERROR, ERROR_CODE_INVALID_CONTEXT } from '../error/error-code.js';
4
+ import { IocContext } from './ioc-context.js';
5
+
6
+ /**
7
+ * Creates a component that manages injectable lifetimes for its subtree.
8
+ *
9
+ * @param entries - service classes or injectable descriptors to bind
10
+ * @param options - provider configuration
11
+ * @returns injectables provider component
12
+ */
13
+ function createInjectablesProvider(entries, options) {
14
+ if (options === void 0) {
15
+ options = {};
16
+ }
17
+ var activate = options.activate;
18
+ if (activate && activate.length > 0) {
19
+ var entryTokens = entries.map(getEntryToken);
20
+ for (var _i = 0, activate_1 = activate; _i < activate_1.length; _i++) {
21
+ var eager = activate_1[_i];
22
+ if (!entryTokens.includes(eager)) {
23
+ throw new WirestateError(ERROR_CODE_VALIDATION_ERROR, "createInjectablesProvider: '".concat(String(eager), "' is listed in 'activate' but was not provided in 'entries'."));
24
+ }
25
+ }
26
+ }
27
+ function InjectablesProviderComponent(props) {
28
+ var iocContext = useContext(IocContext);
29
+ if (!iocContext) {
30
+ throw new WirestateError(ERROR_CODE_INVALID_CONTEXT, "<InjectablesProvider> must be rendered inside an <IocProvider> React subtree.");
31
+ }
32
+ // Snapshot props on mount to ensure binding stability.
33
+ // useState lazy initializer ensures it only runs once.
34
+ var initialPropsSnapshot = useState(function () {
35
+ return props;
36
+ })[0];
37
+ useMemo(function () {
38
+ // Seed must be applied BEFORE binding so @Inject(INITIAL_STATE_TOKEN) works during activation.
39
+ if (initialPropsSnapshot.seeds) {
40
+ applySeeds(iocContext.container, initialPropsSnapshot.seeds);
41
+ }
42
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
43
+ var entry = entries_1[_i];
44
+ if (!iocContext.container.isBound(getEntryToken(entry))) {
45
+ bindEntry(iocContext.container, entry);
46
+ }
47
+ }
48
+ if (activate) {
49
+ for (var _a = 0, activate_2 = activate; _a < activate_2.length; _a++) {
50
+ var eager = activate_2[_a];
51
+ iocContext.container.get(eager);
52
+ }
53
+ }
54
+ }, entries);
55
+ useEffect(function () {
56
+ // Re-apply state and re-bind if container was reset (e.g. StrictMode remount or HMR).
57
+ var didRebind = false;
58
+ if (initialPropsSnapshot.seeds) {
59
+ applySeeds(iocContext.container, initialPropsSnapshot.seeds);
60
+ }
61
+ for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
62
+ var entry = entries_2[_i];
63
+ if (!iocContext.container.isBound(getEntryToken(entry))) {
64
+ didRebind = true;
65
+ bindEntry(iocContext.container, entry);
66
+ }
67
+ }
68
+ if (activate) {
69
+ for (var _a = 0, activate_3 = activate; _a < activate_3.length; _a++) {
70
+ var eager = activate_3[_a];
71
+ iocContext.container.get(eager);
72
+ }
73
+ }
74
+ // Increment revision to invalidate stale injection caches.
75
+ if (didRebind) {
76
+ iocContext.setRevision(function (r) {
77
+ return r + 1;
78
+ });
79
+ }
80
+ return function () {
81
+ for (var _i = 0, entries_3 = entries; _i < entries_3.length; _i++) {
82
+ var entry = entries_3[_i];
83
+ var token = getEntryToken(entry);
84
+ if (iocContext.container.isBound(token)) {
85
+ iocContext.container.unbind(token);
86
+ }
87
+ }
88
+ // Remove only this provider's targeted initial state entries.
89
+ if (initialPropsSnapshot.seeds) {
90
+ unapplySeeds(iocContext.container, initialPropsSnapshot.seeds);
91
+ }
92
+ };
93
+ }, entries);
94
+ return props.children;
95
+ }
96
+ InjectablesProviderComponent.displayName = "InjectablesProvider";
97
+ return InjectablesProviderComponent;
98
+ }
99
+
100
+ export { createInjectablesProvider };
101
+ //# sourceMappingURL=create-injectables-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-injectables-provider.js","sources":["../../../../../../../../../src/wirestate-react/provision/create-injectables-provider.ts"],"sourcesContent":[null],"names":["createInjectablesProvider","entries","options","activate","length","entryTokens","map","getEntryToken","_i","activate_1","eager","includes","WirestateError","ERROR_CODE_VALIDATION_ERROR","concat","String","InjectablesProviderComponent","props","iocContext","useContext","IocContext","ERROR_CODE_INVALID_CONTEXT","initialPropsSnapshot","useState","useMemo","seeds","applySeeds","container","entries_1","entry","isBound","bindEntry","_a","activate_2","get","useEffect","didRebind","entries_2","activate_3","setRevision","r","entries_3","token","unbind","unapplySeeds","children","displayName"],"mappings":";;;;;AAkDA;;;;;;AAMG;AACG,SAAUA,yBAAyBA,CACvCC,OAA8D,EAC9DC,OAA+C,EAAA;AAA/C,EAAA,IAAAA,OAAA,KA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ooks to access services.
6
+ */
7
+ var IocContext = createContext(null);
8
+ IocContext.displayName = "IocContext";
9
+
10
+ export { IocContext };
11
+ //# sourceMappingURL=ioc-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ioc-context.js","sources":["../../../../../../../../../src/wirestate-react/provision/ioc-context.ts"],"sourcesContent":[null],"names":["IocContext","createContext","displayName"],"mappings":";;AAuBA;;;AAGG;IACUA,UAAU,GAAmCC,aAAa,CAAwB,IAAI;AAEnGD,UAAU,CAACE,WAAW,GAAG,YAAY;;;;"}
@@ -0,0 +1,50 @@
1
+ import { createIocContainer, WirestateError, applySharedSeed } from '@wirestate/core';
2
+ import { useState, useMemo, useEffect, createElement } from 'react';
3
+ import { ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER } from '../error/error-code.js';
4
+ import { IocContext } from './ioc-context.js';
5
+
6
+ /**
7
+ * Provides an IoC container to the component tree.
8
+ *
9
+ * @param props - component props
10
+ * @param props.container - external container instance
11
+ * @param props.seed - shared seed across the container
12
+ * @param props.children - components to wrap
13
+ * @returns provider element
14
+ */
15
+ function IocProvider(_a) {
16
+ var externalContainer = _a.container,
17
+ seed = _a.seed,
18
+ children = _a.children;
19
+ // Incremented on binding changes to invalidate descendant caches (e.g., useInjection).
20
+ var _b = useState(1),
21
+ revision = _b[0],
22
+ setRevision = _b[1];
23
+ // Lazy initialize owned container if no external container is provided.
24
+ var ownedContainer = useState(function () {
25
+ return externalContainer ? null : createIocContainer();
26
+ })[0];
27
+ var container = externalContainer !== null && externalContainer !== void 0 ? externalContainer : ownedContainer;
28
+ if (!container) {
29
+ throw new WirestateError(ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER, "IocProvider failed to resolve a container instance.");
30
+ }
31
+ // Context value is stable unless the container or revision changes.
32
+ var value = useMemo(function () {
33
+ return {
34
+ container: container,
35
+ revision: revision,
36
+ setRevision: setRevision
37
+ };
38
+ }, [container, revision]);
39
+ useEffect(function () {
40
+ if (seed) {
41
+ applySharedSeed(container, seed);
42
+ }
43
+ }, [container]);
44
+ return createElement(IocContext.Provider, {
45
+ value: value
46
+ }, children);
47
+ }
48
+
49
+ export { IocProvider };
50
+ //# sourceMappingURL=ioc-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ioc-provider.js","sources":["../../../../../../../../../src/wirestate-react/provision/ioc-provider.ts"],"sourcesContent":[null],"names":["IocProvider","_a","externalContainer","seed","children","_b","useState","revision","setRevision","ownedContainer","createIocContainer","container","WirestateError","ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER","value","useMemo","useEffect","applySharedSeed","createElement","IocContext","Provider"],"mappings":";;;;;AAoBA;;;;;;;;AAQG;AACG,SAAUA,WAAWA,CAACC,EAAmE,EAAA;AAAtD,EAAA,IAAAC,iBAAiB,eAAA;IAAEC,IAAI,GAAAF,EAAA,CAAAE,IAAA;IAAEC,QAAQ,GAAAH,EAAA,CAAAG,QAAA;AACxE;AACM,EAAA,IAAAC,EAAA,GAA0BC,QAAQ,CAAS,CAAC,CAAC;AAA5CC,IAAAA,QAAQ,GAAAF,EAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,WAAW,GAAAH,EAAA,CAAA,CAAA,CAAuB;AACnD;AACO,EAAA,IAAAI,cAAc,GAAIH,QAAQ,CAAmB;AAAM,IAAA,OAACJ,iBAAiB,GAAG,IAAI,GAAGQ,kBAAkB,EAAE;EAAhD,CAAiD,CAAC,CAAA,CAAA,CAAvF;AAErB,EAAA,IAAMC,SAAS,GAAGT,iBAAiB,KAAA,IAAA,IAAjBA,iBAAiB,KAAA,MAAA,GAAjBA,iBAAiB,GAAIO,cAAc;EAErD,IAAI,CAACE,SAAS,EAAE;AACd,IAAA,MAAM,IAAIC,cAAc,CACtBC,0CAA0C,EAC1C,qDAAqD,CACtD;AACH,EAAA;AAEA;AACA,EAAA,IAAMC,KAAK,GAAgBC,OAAO,CAAc,YAAA;IAAM,OAAC;AAAEJ,MAAAA,SAAS,EAAAA,SAAA;AAAEJ,MAAAA,QAAQ,EAAAA,QAAA;AAAEC,MAAAA,WAAW,EAAAA;KAAE;AAArC,EAAA,CAAsC,EAAE,CAACG,SAAS,EAAEJ,QAAQ,CAAC,CAAC;AAEpHS,EAAAA,SAAS,CAAC,YAAA;AACR,IAAA,IAAIb,IAAI,EAAE;AACRc,MAAAA,eAAe,CAACN,SAAS,EAAER,IAAI,CAAC;AAClC,IAAA;AACF,EAAA,CAAC,EAAE,CAACQ,SAAS,CAAC,CAAC;AAEf,EAAA,OAAOO,aAAa,CAACC,UAAU,CAACC,QAAQ,EAAE;AAAEN,IAAAA,KAAK,EAAAA;GAAE,EAAEV,QAAQ,CAAC;AAChE;;;;"}
@@ -0,0 +1,13 @@
1
+ import { useIocContext } from './use-ioc-context.js';
2
+
3
+ /**
4
+ * Returns the current container revision.
5
+ *
6
+ * @returns revision number
7
+ */
8
+ function useContainerRevision() {
9
+ return useIocContext().revision;
10
+ }
11
+
12
+ export { useContainerRevision };
13
+ //# sourceMappingURL=use-container-revision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-container-revision.js","sources":["../../../../../../../../../src/wirestate-react/provision/use-container-revision.ts"],"sourcesContent":[null],"names":["useContainerRevision","useIocContext","revision"],"mappings":";;AAEA;;;;AAIG;SACaA,oBAAoBA,GAAA;AAClC,EAAA,OAAOC,aAAa,EAAE,CAACC,QAAQ;AACjC;;;;"}
@@ -0,0 +1,13 @@
1
+ import { useIocContext } from './use-ioc-context.js';
2
+
3
+ /**
4
+ * Returns the active IoC container.
5
+ *
6
+ * @returns active Inversify container
7
+ */
8
+ function useContainer() {
9
+ return useIocContext().container;
10
+ }
11
+
12
+ export { useContainer };
13
+ //# sourceMappingURL=use-container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-container.js","sources":["../../../../../../../../../src/wirestate-react/provision/use-container.ts"],"sourcesContent":[null],"names":["useContainer","useIocContext","container"],"mappings":";;AAIA;;;;AAIG;SACaA,YAAYA,GAAA;AAC1B,EAAA,OAAOC,aAAa,EAAE,CAACC,SAAS;AAClC;;;;"}
@@ -0,0 +1,22 @@
1
+ import { useMemo } from 'react';
2
+ import { useIocContext } from './use-ioc-context.js';
3
+
4
+ /**
5
+ * Resolves a value from the container - constant or service.
6
+ * Automatically re-resolves if the container is reset or services are rebound.
7
+ *
8
+ * @param injectionId - injection identifier
9
+ * @returns resolved value
10
+ */
11
+ function useInjection(injectionId) {
12
+ var _a = useIocContext(),
13
+ container = _a.container,
14
+ revision = _a.revision;
15
+ // Revision bump causes a container reset; force re-resolution to drop stale instances.
16
+ return useMemo(function () {
17
+ return container.get(injectionId);
18
+ }, [container, revision, injectionId]);
19
+ }
20
+
21
+ export { useInjection };
22
+ //# sourceMappingURL=use-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-injection.js","sources":["../../../../../../../../../src/wirestate-react/provision/use-injection.ts"],"sourcesContent":[null],"names":["useInjection","injectionId","_a","useIocContext","container","revision","useMemo","get"],"mappings":";;;AASA;;;;;;AAMG;AACG,SAAUA,YAAYA,CAAIC,WAAiC,EAAA;AACzD,EAAA,IAAAC,EAAA,GAA0BC,aAAa,EAAE;IAAvCC,SAAS,GAAAF,EAAA,CAAAE,SAAA;IAAEC,QAAQ,GAAAH,EAAA,CAAAG,QAAoB;AAE/C;EACA,OAAOC,OAAO,CAAC,YAAA;AAQb,IAAA,OAAOF,SAAS,CAACG,GAAG,CAAIN,WAAW,CAAC;EACtC,CAAC,EAAE,CAACG,SAAS,EAAEC,QAAQ,EAAEJ,WAAW,CAAC,CAAC;AACxC;;;;"}
@@ -0,0 +1,21 @@
1
+ import { WirestateError } from '@wirestate/core';
2
+ import { useContext } from 'react';
3
+ import { ERROR_CODE_INVALID_CONTEXT } from '../error/error-code.js';
4
+ import { IocContext } from './ioc-context.js';
5
+
6
+ /**
7
+ * Returns the full IoC context.
8
+ *
9
+ * @returns active IoC context
10
+ * @internal
11
+ */
12
+ function useIocContext() {
13
+ var value = useContext(IocContext);
14
+ if (!value) {
15
+ throw new WirestateError(ERROR_CODE_INVALID_CONTEXT, "Trying to access IOC context from React subtree not wrapped in <IocProvider>.");
16
+ }
17
+ return value;
18
+ }
19
+
20
+ export { useIocContext };
21
+ //# sourceMappingURL=use-ioc-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-ioc-context.js","sources":["../../../../../../../../../src/wirestate-react/provision/use-ioc-context.ts"],"sourcesContent":[null],"names":["useIocContext","value","useContext","IocContext","WirestateError","ERROR_CODE_INVALID_CONTEXT"],"mappings":";;;;;AAMA;;;;;AAKG;SACaA,aAAaA,GAAA;AAC3B,EAAA,IAAMC,KAAK,GAAGC,UAAU,CAACC,UAAU,CAAC;EAEpC,IAAI,CAACF,KAAK,EAAE;AACV,IAAA,MAAM,IAAIG,cAAc,CACtBC,0BAA0B,EAC1B,+EAA+E,CAChF;AACH,EAAA;AAEA,EAAA,OAAOJ,KAAK;AACd;;;;"}
@@ -0,0 +1,29 @@
1
+ import { useMemo } from 'react';
2
+ import { useIocContext } from './use-ioc-context.js';
3
+
4
+ /**
5
+ * Resolves a value from the container if bound, returning null otherwise.
6
+ * Unlike {@link useInjection}, this hook does not throw when the token is not bound.
7
+ *
8
+ * @param injectionId - injection identifier
9
+ * @param onFallback - optional callback to handle cases when dependency was not resolved
10
+ * @returns resolved value, result of optional fallback handler or null
11
+ */
12
+ function useOptionalInjection(injectionId, onFallback) {
13
+ var _a = useIocContext(),
14
+ container = _a.container,
15
+ revision = _a.revision;
16
+ // Revision bump forces a container reset; force re-resolution to drop stale instances.
17
+ return useMemo(function () {
18
+ if (container.isBound(injectionId)) {
19
+ return container.get(injectionId);
20
+ } else if (onFallback) {
21
+ return onFallback(container);
22
+ } else {
23
+ return null;
24
+ }
25
+ }, [container, revision, injectionId]);
26
+ }
27
+
28
+ export { useOptionalInjection };
29
+ //# sourceMappingURL=use-optional-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-optional-injection.js","sources":["../../../../../../../../../src/wirestate-react/provision/use-optional-injection.ts"],"sourcesContent":[null],"names":["useOptionalInjection","injectionId","onFallback","_a","useIocContext","container","revision","useMemo","isBound","get"],"mappings":";;;AASA;;;;;;;AAOG;AACG,SAAUA,oBAAoBA,CAClCC,WAAiC,EACjCC,UAAwC,EAAA;AAElC,EAAA,IAAAC,EAAA,GAA0BC,aAAa,EAAE;IAAvCC,SAAS,GAAAF,EAAA,CAAAE,SAAA;IAAEC,QAAQ,GAAAH,EAAA,CAAAG,QAAoB;AAE/C;EACA,OAAOC,OAAO,CAAC,YAAA;AACb,IAAA,IAAIF,SAAS,CAACG,OAAO,CAACP,WAAW,CAAC,EAAE;AASlC,MAAA,OAAOI,SAAS,CAACI,GAAG,CAAIR,WAAW,CAAC;IACtC,CAAC,MAAM,IAAIC,UAAU,EAAE;MASrB,OAAOA,UAAU,CAACG,SAAS,CAAC;AAC9B,IAAA,CAAC,MAAM;AASL,MAAA,OAAO,IAAI;AACb,IAAA;EACF,CAAC,EAAE,CAACA,SAAS,EAAEC,QAAQ,EAAEL,WAAW,CAAC,CAAC;AACxC;;;;"}
@@ -0,0 +1,19 @@
1
+ import { QueryBus } 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 queries on the active container.
7
+ * Returns null instead of throwing when no handler is registered.
8
+ *
9
+ * @returns optional query dispatcher
10
+ */
11
+ function useOptionalQueryCaller() {
12
+ var container = useContainer();
13
+ return useCallback(function (type, data) {
14
+ return container.get(QueryBus).queryOptional(type, data);
15
+ }, [container]);
16
+ }
17
+
18
+ export { useOptionalQueryCaller };
19
+ //# sourceMappingURL=use-optional-query-caller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-optional-query-caller.js","sources":["../../../../../../../../../src/wirestate-react/queries/use-optional-query-caller.ts"],"sourcesContent":[null],"names":["useOptionalQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","queryOptional"],"mappings":";;;;AAQA;;;;;AAKG;SACaA,sBAAsBA,GAAA;AACpC,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAACC,IAAe,EAAEC,IAAc,EAAA;AAM9B,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,QAAQ,CAAC,CAACC,aAAa,CAACJ,IAAI,EAAEC,IAAI,CAAC;AAC1D,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACW;AAC1B;;;;"}
@@ -0,0 +1,19 @@
1
+ import { QueryBus } from '@wirestate/core';
2
+ import { useCallback } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+
5
+ /**
6
+ * Returns a stable function to dispatch synchronous optional queries.
7
+ * Returns null instead of throwing when no handler is registered.
8
+ *
9
+ * @returns optional sync query dispatcher
10
+ */
11
+ function useOptionalSyncQueryCaller() {
12
+ var container = useContainer();
13
+ return useCallback(function (type, data) {
14
+ return container.get(QueryBus).queryOptional(type, data);
15
+ }, [container]);
16
+ }
17
+
18
+ export { useOptionalSyncQueryCaller };
19
+ //# sourceMappingURL=use-optional-sync-query-caller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-optional-sync-query-caller.js","sources":["../../../../../../../../../src/wirestate-react/queries/use-optional-sync-query-caller.ts"],"sourcesContent":[null],"names":["useOptionalSyncQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","queryOptional"],"mappings":";;;;AAQA;;;;;AAKG;SACaA,0BAA0BA,GAAA;AACxC,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAACC,IAAe,EAAEC,IAAc,EAAA;AAM9B,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,QAAQ,CAAC,CAACC,aAAa,CAACJ,IAAI,EAAEC,IAAI,CAAC;AAC1D,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACe;AAC9B;;;;"}
@@ -0,0 +1,18 @@
1
+ import { QueryBus } from '@wirestate/core';
2
+ import { useCallback } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+
5
+ /**
6
+ * Returns a function to dispatch queries on the active container.
7
+ *
8
+ * @returns query dispatcher
9
+ */
10
+ function useQueryCaller() {
11
+ var container = useContainer();
12
+ return useCallback(function (type, data) {
13
+ return container.get(QueryBus).query(type, data);
14
+ }, [container]);
15
+ }
16
+
17
+ export { useQueryCaller };
18
+ //# sourceMappingURL=use-query-caller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-query-caller.js","sources":["../../../../../../../../../src/wirestate-react/queries/use-query-caller.ts"],"sourcesContent":[null],"names":["useQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","query"],"mappings":";;;;AAQA;;;;AAIG;SACaA,cAAcA,GAAA;AAC5B,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAACC,IAAe,EAAEC,IAAc,EAAA;AAM9B,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,QAAQ,CAAC,CAACC,KAAK,CAACJ,IAAI,EAAEC,IAAI,CAAC;AAClD,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACG;AAClB;;;;"}
@@ -0,0 +1,27 @@
1
+ import { QueryBus } from '@wirestate/core';
2
+ import { useRef, useEffect } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+
5
+ /**
6
+ * Registers a query 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 - query type
11
+ * @param handler - query handler function
12
+ */
13
+ function useQueryHandler(type, handler) {
14
+ var container = useContainer();
15
+ var handlerRef = useRef(handler);
16
+ useEffect(function () {
17
+ handlerRef.current = handler;
18
+ });
19
+ useEffect(function () {
20
+ return container.get(QueryBus).register(type, function (data) {
21
+ return handlerRef.current(data);
22
+ });
23
+ }, [container, type]);
24
+ }
25
+
26
+ export { useQueryHandler };
27
+ //# sourceMappingURL=use-query-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-query-handler.js","sources":["../../../../../../../../../src/wirestate-react/queries/use-query-handler.ts"],"sourcesContent":[null],"names":["useQueryHandler","type","handler","container","useContainer","handlerRef","useRef","useEffect","current","get","QueryBus","register","data"],"mappings":";;;;AAKA;;;;;;;AAOG;AACG,SAAUA,eAAeA,CAC7BC,IAAO,EACPC,OAA2B,EAAA;AAE3B,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAC3C,EAAA,IAAMC,UAAU,GAAGC,MAAM,CAAqBJ,OAAO,CAAC;AAEtDK,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,QAAQ,CAAC,CAACC,QAAQ,CAAOV,IAAI,EAAE,UAACW,IAAI,EAAA;AAAK,MAAA,OAAAP,UAAU,CAACG,OAAO,CAACI,IAAI,CAAC;AAAxB,IAAA,CAAwB,CAAC;AACzF,EAAA,CAAC,EAAE,CAACT,SAAS,EAAEF,IAAI,CAAC,CAAC;AACvB;;;;"}
@@ -0,0 +1,20 @@
1
+ import { QueryBus } from '@wirestate/core';
2
+ import { useCallback } from 'react';
3
+ import { useContainer } from '../provision/use-container.js';
4
+
5
+ /**
6
+ * Returns a stable function to dispatch synchronous queries.
7
+ * Returns the value directly from the handler.
8
+ *
9
+ * @returns sync query dispatcher
10
+ */
11
+ function useSyncQueryCaller() {
12
+ var container = useContainer();
13
+ return useCallback(function (type, data) {
14
+ // Access the container-scoped QueryBus and execute the query.
15
+ return container.get(QueryBus).query(type, data);
16
+ }, [container]);
17
+ }
18
+
19
+ export { useSyncQueryCaller };
20
+ //# sourceMappingURL=use-sync-query-caller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-sync-query-caller.js","sources":["../../../../../../../../../src/wirestate-react/queries/use-sync-query-caller.ts"],"sourcesContent":[null],"names":["useSyncQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","query"],"mappings":";;;;AAQA;;;;;AAKG;SACaA,kBAAkBA,GAAA;AAChC,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAACC,IAAe,EAAEC,IAAc,EAAA;AAM9B;AACA,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,QAAQ,CAAC,CAACC,KAAK,CAACJ,IAAI,EAAEC,IAAI,CAAC;AAClD,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACO;AACtB;;;;"}
@@ -0,0 +1,30 @@
1
+ import '../../wirestate-core/commands/command-bus.js';
2
+ import '../../wirestate-core/container/wire-scope.js';
3
+ import '../../wirestate-core/events/event-bus.js';
4
+ import '../../wirestate-core/queries/query-bus.js';
5
+ import 'inversify';
6
+ import '../../wirestate-core/error/wirestate-error.js';
7
+ import { mockContainer } from '../../wirestate-core/test-utils/mock-container.js';
8
+ import { createElement } from 'react';
9
+ import { IocProvider } from '../provision/ioc-provider.js';
10
+
11
+ /**
12
+ * Wraps a component with IocProvider for testing.
13
+ *
14
+ * @param children - components to wrap
15
+ * @param container - optional custom container
16
+ * @param seed - optional shared seed object
17
+ * @returns wrapped components
18
+ */
19
+ function withIocProvider(children, container, seed) {
20
+ if (container === void 0) {
21
+ container = mockContainer();
22
+ }
23
+ return createElement(IocProvider, {
24
+ container: container,
25
+ seed: seed
26
+ }, children);
27
+ }
28
+
29
+ export { withIocProvider };
30
+ //# sourceMappingURL=with-ioc-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-ioc-provider.js","sources":["../../../../../../../../../src/wirestate-react/test-utils/with-ioc-provider.ts"],"sourcesContent":[null],"names":["withIocProvider","children","container","seed","mockContainer","createElement","IocProvider"],"mappings":";;;;;;;;;;AAMA;;;;;;;AAOG;SACaA,eAAeA,CAC7BC,QAAmB,EACnBC,SAAsC,EACtCC,IAA8B,EAAA;AAD9B,EAAA,IAAAD,SAAA,KAAA,MAAA,EAAA;IAAAA,SAAA,GAAuBE,aAAa,EAAE;AAAA,EAAA;EAGtC,OAAOC,aAAa,CAACC,WAAW,EAAE;AAAEJ,IAAAA,SAAS,EAAAA,SAAA;AAAEC,IAAAA,IAAI,EAAAA;GAAE,EAAEF,QAAQ,CAAC;AAClE;;;;"}
@@ -0,0 +1,2 @@
1
+ export { withIocProvider } from './test-utils/with-ioc-provider.js';
2
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ import{bindingScopeValues as r}from"inversify";import{ERROR_CODE_BINDING_SCOPE as e}from"../error/error-code.js";import{WirestateError as o}from"../error/wirestate-error.js";function i(i,n){if(n.scopeBindingType&&n.scopeBindingType!==r.Singleton)throw new o(e,"Provided unexpected binding scope for constant value.");i.bind(n.id).toConstantValue(n.value)}export{i as bindConstant};//# sourceMappingURL=bind-constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind-constant.js","sources":["../../../../../../../../../src/wirestate-core/bind/bind-constant.ts"],"sourcesContent":[null],"names":["bindingScopeValues","ERROR_CODE_BINDING_SCOPE","WirestateError","bindConstant","container","entry","scopeBindingType","ScopeBindingType","Singleton","bind","id","toConstantValue","value"],"mappings":"6BAUAA,MAAA,+CAAAC,MAAA,kDAAAC,MAAA,8BAMM,SAAUC,EAAgBC,EAAsBC,GAQpD,GAAIA,EAAMC,kBAAoBD,EAAMC,mBAAqBC,EAAiBC,UACxE,MAAM,IAAIN,EAAeD,EAA0B,yDAGrDG,EAAUK,KAAQJ,EAAMK,IAA4BC,gBAAgBN,EAAMO,MAC5E,QAAAT"}
@@ -0,0 +1 @@
1
+ import{bindingScopeValues as n}from"inversify";function e(e,i){var o=e.bind(i.id).toDynamicValue((function(){return i.factory?i.factory():i.value}));i.scopeBindingType&&(i.scopeBindingType===n.Transient?o.inTransientScope():i.scopeBindingType===n.Request?o.inRequestScope():o.inSingletonScope())}export{e as bindDynamicValue};//# sourceMappingURL=bind-dynamic-value.js.map
@@ -0,0 +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,YAMM,SAAUC,EAAiBC,EAAsBC,GAMrD,IAAMC,EAA6CF,EAAUG,KAAKF,EAAMG,IAAIC,gBAAe,WACzF,OAAIJ,EAAMK,QACDL,EAAMK,UAGRL,EAAMM,KACf,IAEKN,EAAMO,mBAEAP,EAAMO,mBAAqBV,EAAmBW,UACvDP,EAAQQ,mBACCT,EAAMO,mBAAqBV,EAAmBa,QACvDT,EAAQU,iBAERV,EAAQW,mBAEZ,QAAAd"}
@@ -0,0 +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 r(r,t,m){return void 0===m&&(m={}),"function"==typeof t?e(r,t,m):t.bindingType&&t.bindingType!==i.ConstantValue?t.bindingType===i.DynamicValue?o(r,t):e(r,t.value,m):n(r,t)}export{r as bindEntry};//# sourceMappingURL=bind-entry.js.map
@@ -0,0 +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":"4BAiBAA,MAAA,mCAAAC,MAAA,gDAAAC,MAAA,gDAAAC,MAAA,6BAegBC,EACdC,EACAC,EACAC,GAEA,YAFA,IAAAA,IAAAA,EAAA,CAAA,GAEqB,mBAAVD,EACFH,EAAYE,EAAWC,EAAOC,GAGlCD,EAAME,aAAeF,EAAME,cAAgBR,EAAkBS,cAI9DH,EAAME,cAAgBR,EAAkBU,aAMnCR,EAAiBG,EAAWC,GAS9BH,EAAYE,EAAWC,EAAMK,MAAgCJ,GAlB3DN,EAAaI,EAAWC,EAmBnC,QAAAF"}
@@ -0,0 +1 @@
1
+ import{CommandBus as e}from"../commands/command-bus.js";import{getCommandHandlerMetadata as t}from"../commands/get-command-handler-metadata.js";import{WireScope as r}from"../container/wire-scope.js";import{buildEventDispatcher as n}from"../events/build-event-dispatcher.js";import{EventBus as o}from"../events/event-bus.js";import{getQueryHandlerMetadata as i}from"../queries/get-query-handler-metadata.js";import{QueryBus as a}from"../queries/query-bus.js";import{CONTAINER_REFS_BY_SERVICE as f,WIRE_SCOPES_BY_SERVICE as c,EVENT_UNSUBSCRIBERS_BY_SERVICE as s,QUERY_UNREGISTERS_BY_SERVICE as u,COMMAND_UNREGISTERS_BY_SERVICE as v}from"../registry.js";import{getActivatedHandlerMetadata as l}from"../service/get-activated-handler-metadata.js";import{getDeactivationHandlerMetadata as m}from"../service/get-deactivation-handler-metadata.js";function d(d,h,y){var j=d.bind(h).to(h).inSingletonScope();j.onActivation((function(u,v){v.IS_DISPOSED=!1,f.set(v,d),function(e,t){var n=Reflect.getMetadata("design:paramtypes",t);if(!(null==n?void 0:n.some((function(e){return e===r}))))return;for(var o=[],i=0,a=Object.getOwnPropertyNames(e);i<a.length;i++){var f=e[a[i]];(null==f?void 0:f.constructor)===r&&o.push(f)}o.length>0&&c.set(e,o)}(v,h);var m=n(v);m&&function(e,t){var r,n=null===(r=f.get(e))||void 0===r?void 0:r.get(o);n&&s.set(e,n.subscribe(t))}(v,m);for(var j=d.get(a),b=0,S=i(v);b<S.length;b++){var D=S[b];if("function"==typeof(N=v[D.methodName])){var I=j.register(D.type,N.bind(v));g(v,I)}}for(var O=d.get(e),q=0,w=t(v);q<w.length;q++){var N;D=w[q];if("function"==typeof(N=v[D.methodName])){I=O.register(D.type,N.bind(v));p(v,I)}}if(null==y?void 0:y.isWithIgnoreLifecycle);else for(var P=function(e){var t=v[e];if("function"!=typeof t)return"continue";var r=t.call(v);r&&"function"==typeof r.then&&r.catch((function(t){console.error("[wirestate] @OnActivated rejected for:",h.name,String(e),t)}))},A=0,E=l(v);A<E.length;A++){P(E[A])}return v})),j.onDeactivation((function(e){if(null==y?void 0:y.isWithIgnoreLifecycle);else for(var t=0,r=m(e);t<r.length;t++){var n=e[r[t]];"function"==typeof n&&n.call(e)}var o,i;e.IS_DISPOSED=!0,function(e){var t=c.get(e);if(!t)return;for(var r=0,n=t;r<n.length;r++){var o=n[r];o.isDisposed=!0,o.container=null}c.delete(e)}(e),function(e){var t=v.get(e);if(!t)return;for(var r=0,n=t;r<n.length;r++){(0,n[r])()}v.delete(e)}(e),function(e){var t=u.get(e);if(!t)return;for(var r=0,n=t;r<n.length;r++){(0,n[r])()}u.delete(e)}(e),o=e,(i=s.get(o))&&(i(),s.delete(o)),f.delete(e)}))}function g(e,t){var r=u.get(e);r||(r=[],u.set(e,r)),r.push(t)}function p(e,t){var r=v.get(e);r||(r=[],v.set(e,r)),r.push(t)}export{d as bindService};//# sourceMappingURL=bind-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind-service.js","sources":["../../../../../../../../../src/wirestate-core/bind/bind-service.ts"],"sourcesContent":[null],"names":["CommandBus","getCommandHandlerMetadata","WireScope","buildEventDispatcher","EventBus","getQueryHandlerMetadata","QueryBus","CONTAINER_REFS_BY_SERVICE","WIRE_SCOPES_BY_SERVICE","EVENT_UNSUBSCRIBERS_BY_SERVICE","QUERY_UNREGISTERS_BY_SERVICE","COMMAND_UNREGISTERS_BY_SERVICE","getActivatedHandlerMetadata","getDeactivationHandlerMetadata","bindService","container","entry","options","whenBind","bind","to","inSingletonScope","onActivation","context","instance","IS_DISPOSED","set","service","Service","paramTypes","Reflect","getMetadata","some","type","scopes","_i","_a","Object","getOwnPropertyNames","length","value","constructor","push","attachWireScopes","dispatcher","handler","bus","get","subscribe","attachEventsSubscription","queryBus","meta","method","methodName","unregister","register","attachQueryUnregister","commandBus","_b","_c","attachCommandUnregister","isWithIgnoreLifecycle","result","call","then","catch","error","console","name","String","_d","_e","onDeactivation","unsubscribe","scopes_1","scope","isDisposed","delete","detachWireScopes","list","list_2","detachCommandUnregister","list_1","detachQueryUnregister"],"mappings":"qBA8BAA,MAAA,iEAAAC,MAAA,kEAAAC,MAAA,4DAAAC,MAAA,yDAAAC,MAAA,2DAAAC,MAAA,8DAAAC,MAAA,8DAAAC,4BAAAC,oCAAAC,kCAAAC,oCAAAC,MAAA,uDAAAC,MAAA,wFAAAC,MAAA,2DAQgBC,EACdC,EACAC,EACAC,GAaA,IAAMC,EAAsCH,EAAUI,KAAQH,GAAOI,GAAGJ,GAAOK,mBAE/EH,EAASI,cAAa,SAACC,EAASC,GAW7BA,EAAsCC,aAAc,EAErDlB,EAA0BmB,IAAIF,EAAUT,GA4O5C,SAA4CY,EAAYC,GACtD,IAAMC,EAAaC,QAAQC,YAAY,oBAAqBH,GAE5D,KAAKC,aAAU,EAAVA,EAAYG,MAAK,SAACC,GAAS,OAAAA,IAAS/B,CAAT,KAC9B,OAKF,IAFA,IAAMgC,EAA2B,GAEfC,EAAA,EAAAC,EAAAC,OAAOC,oBAAoBX,GAA3BQ,EAAAC,EAAAG,OAAAJ,IAAqC,CAAlD,IACGK,EAASb,EADHS,EAAAD,KAGPK,aAAK,EAALA,EAA4BC,eAAgBvC,GAC/CgC,EAAOQ,KAAKF,EAEhB,CAEIN,EAAOK,OAAS,GAClB/B,EAAuBkB,IAAIC,EAASO,EAExC,CA/PIS,CAAiBnB,EAAUR,GAI3B,IAAM4B,EAAsCzC,EAAqBqB,GAE7DoB,GAuHR,SAAoDjB,EAAYkB,SACxDC,EAA6D,QAAtCV,EAAA7B,EAA0BwC,IAAIpB,UA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,EAAKrC,KAAKY,EACZ,CA6BA,SAASM,EAA0CjC,EAAY2B,GAC7D,IAAIyB,EAAyCpE,EAA+BoC,IAAIpB,GAE3EoD,IACHA,EAAO,GACPpE,EAA+Be,IAAIC,EAASoD,IAG9CA,EAAKrC,KAAKY,EACZ,QA6EAxC"}
@@ -0,0 +1 @@
1
+ function n(n){return"function"==typeof n?n:n.id}export{n as getEntryToken};//# sourceMappingURL=get-entry-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-entry-token.js","sources":["../../../../../../../../../src/wirestate-core/bind/get-entry-token.ts"],"sourcesContent":[null],"names":["getEntryToken","entry","id"],"mappings":"AAYM,SAAUA,EAAyCC,GACvD,MAAwB,mBAAVA,EAAuBA,EAAQA,EAAMC,EACrD,QAAAF"}
@@ -0,0 +1 @@
1
+ import{ERROR_CODE_FAILED_TO_RESOLVE_COMMAND_HANDLER as t}from"../error/error-code.js";import{WirestateError as r}from"../error/wirestate-error.js";import{ECommandStatus as n}from"../types/commands.js";var e=function(){function e(){this.handlers=new Map}return e.prototype.register=function(t,r){var n=this,e=this.handlers.get(t);return e||(e=[],this.handlers.set(t,e)),e.push(r),function(){var e=n.handlers.get(t);if(e){var o=e.indexOf(r);o>=0&&e.splice(o,1),0===e.length&&n.handlers.delete(t)}}},e.prototype.command=function(e,o){var s=this.handlers.get(e);if(!(null==s?void 0:s.length))throw new r(t,"No command handler registered in container for type: '".concat(String(e),"'."));var i=s[s.length-1],a={task:null,status:n.PENDING};return a.task=Promise.resolve().then((function(){return i(o)})).then((function(t){return a.status=n.SETTLED,t})).catch((function(t){throw a.status=n.ERROR,t})),a},e.prototype.commandOptional=function(t,r){var n=this.handlers.get(t);return(null==n?void 0:n.length)?this.command(t,r):null},e.prototype.has=function(t){var r;return Boolean(null===(r=this.handlers.get(t))||void 0===r?void 0:r.length)},e.prototype.clear=function(){this.handlers.clear()},e}();export{e as CommandBus};//# sourceMappingURL=command-bus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-bus.js","sources":["../../../../../../../../../src/wirestate-core/commands/command-bus.ts"],"sourcesContent":[null],"names":["ERROR_CODE_FAILED_TO_RESOLVE_COMMAND_HANDLER","WirestateError","ECommandStatus","CommandBus","this","handlers","Map","prototype","register","type","handler","_this","stack","get","set","push","current","index","indexOf","splice","length","delete","command","data","concat","String","descriptor","task","status","PENDING","Promise","resolve","then","result","SETTLED","catch","error","ERROR","commandOptional","has","Boolean","_a","clear"],"mappings":"uDAcAA,MAAA,kDAAAC,MAAA,uDAAAC,MAAA,uBAMA,IAAAC,EAAA,WAAA,SAAAA,IAKmBC,KAAAC,SAAsD,IAAIC,GA4H7E,CAAA,OAlHSH,EAAAI,UAAAC,SAAP,SAA0CC,EAAoBC,GAA9D,IAAAC,EAAAP,KAOMQ,EAAuCR,KAAKC,SAASQ,IAAIJ,GAS7D,OAPKG,IACHA,EAAQ,GACRR,KAAKC,SAASS,IAAIL,EAAMG,IAG1BA,EAAMG,KAAKL,GAEJ,WAOL,IAAMM,EAAyCL,EAAKN,SAASQ,IAAIJ,GAEjE,GAAKO,EAAL,CAIA,IAAMC,EAAgBD,EAAQE,QAAQR,GAElCO,GAAS,GACXD,EAAQG,OAAOF,EAAO,GAID,IAAnBD,EAAQI,QACVT,EAAKN,SAASgB,OAAOZ,EAVvB,CAYF,CACF,EAYON,EAAAI,UAAAe,QAAP,SAAyCb,EAAoBc,GAC3D,IAAMX,EAAuCR,KAAKC,SAASQ,IAAIJ,GAE/D,KAAKG,aAAK,EAALA,EAAOQ,QACV,MAAM,IAAInB,EACRD,EACA,yDAAAwB,OAAyDC,OAAOhB,GAAK,OAIzE,IAAMC,EAAUE,EAAMA,EAAMQ,OAAS,GAE/BM,EAAoC,CACxCC,KAAM,KACNC,OAAQ1B,EAAe2B,SAgBzB,OAbCH,EAAoCC,KAAOG,QAAQC,UACjDC,MAAK,WAAM,OAAAtB,EAAQa,EAAR,IACXS,MAAK,SAACC,GAGL,OAFCP,EAA0CE,OAAS1B,EAAegC,QAE5DD,CACT,IACCE,OAAM,SAACC,GAGN,MAFCV,EAA0CE,OAAS1B,EAAemC,MAE7DD,CACR,IAEKV,CACT,EASOvB,EAAAI,UAAA+B,gBAAP,SAAiD7B,EAAoBc,GACnE,IAAMX,EAAuCR,KAAKC,SAASQ,IAAIJ,GAE/D,OAAOG,eAAAA,EAAOQ,QAAShB,KAAKkB,QAAcb,EAAMc,GAAQ,IAC1D,EAQOpB,EAAAI,UAAAgC,IAAP,SAAW9B,SACT,OAAO+B,QAA+B,QAAvBC,EAAArC,KAAKC,SAASQ,IAAIJ,UAAK,IAAAgC,OAAA,EAAAA,EAAErB,OAC1C,EAKOjB,EAAAI,UAAAmC,MAAP,WACEtC,KAAKC,SAASqC,OAChB,EACFvC,CAAA,CAjIA,UAiICA"}
@@ -0,0 +1 @@
1
+ import{COMMAND_HANDLER_METADATA as t}from"../registry.js";function r(r){for(var e=r.constructor,o=[];"function"==typeof e&&e!==Object&&e!==Function.prototype;){var n=t.get(e);n&&n.length>0&&o.push(n),e=Object.getPrototypeOf(e)}return o.reverse().flat()}export{r as getCommandHandlerMetadata};//# sourceMappingURL=get-command-handler-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-command-handler-metadata.js","sources":["../../../../../../../../../src/wirestate-core/commands/get-command-handler-metadata.ts"],"sourcesContent":[null],"names":["COMMAND_HANDLER_METADATA","getCommandHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","get","length","push","getPrototypeOf","reverse","flat"],"mappings":"mCAOAA,MAAA,iBAQM,SAAUC,EAA0BC,GAWxC,IALA,IAAIC,EAAuBD,EAASC,YAE9BC,EAA+C,GAGvB,mBAAhBD,GAA8BA,IAAgBE,QAAUF,IAAgBG,SAASC,WAAW,CACxG,IAAMC,EAA6CR,EAAyBS,IAAIN,GAE5EK,GAAOA,EAAIE,OAAS,GACtBN,EAAMO,KAAKH,GAGbL,EAAcE,OAAOO,eAAeT,EACtC,CASA,OAAOC,EAAMS,UAAUC,MACzB,QAAAb"}
@@ -0,0 +1 @@
1
+ import{Container as n}from"inversify";import{CommandBus as e}from"../commands/command-bus.js";import{WireScope as o}from"./wire-scope.js";import{EventBus as t}from"../events/event-bus.js";import{QueryBus as r}from"../queries/query-bus.js";import{SEEDS_TOKEN as i,SEED_TOKEN as s}from"../registry.js";function a(a){var u;void 0===a&&(a={});var m=new n({defaultScope:"Singleton",parent:a.parent});return m.bind(t).toConstantValue(new t),m.bind(r).toConstantValue(new r),m.bind(e).toConstantValue(new e),m.bind(i).toConstantValue(new Map),m.bind(s).toConstantValue(null!==(u=a.seed)&&void 0!==u?u:{}),m.bind(o).toResolvedValue((function(){return new o(m)})).inTransientScope(),m}export{a as createIocContainer};//# sourceMappingURL=create-ioc-container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-ioc-container.js","sources":["../../../../../../../../../src/wirestate-core/container/create-ioc-container.ts"],"sourcesContent":[null],"names":["Container","CommandBus","WireScope","EventBus","QueryBus","SEEDS_TOKEN","SEED_TOKEN","createIocContainer","options","container","defaultScope","parent","bind","toConstantValue","Map","_a","seed","toResolvedValue","inTransientScope"],"mappings":"oBAwBAA,MAAA,iCAAAC,MAAA,iDAAAC,MAAA,qCAAAC,MAAA,4CAAAC,MAAA,gDAAAC,gBAAAC,MAAA,iBAMM,SAAUC,EAAmBC,cAAA,IAAAA,IAAAA,EAAA,CAAA,GAGjC,IAAMC,EAAuB,IAAIT,EAAU,CACzCU,aAAc,YACdC,OAAQH,EAAQG,SAgBlB,OAbAF,EAAUG,KAAKT,GAAUU,gBAAgB,IAAIV,GAC7CM,EAAUG,KAAKR,GAAUS,gBAAgB,IAAIT,GAC7CK,EAAUG,KAAKX,GAAYY,gBAAgB,IAAIZ,GAC/CQ,EAAUG,KAAKP,GAAaQ,gBAAgB,IAAIC,KAChDL,EAAUG,KAAKN,GAAYO,gBAA4B,QAAZE,EAAAP,EAAQQ,YAAI,IAAAD,EAAAA,EAAI,CAAA,GAE3DN,EACGG,KAAKV,GACLe,iBAAgB,WAAiB,OAAA,IAAIf,EAAUO,EAAd,IACjCS,mBAIIT,CACT,QAAAF"}
@@ -0,0 +1 @@
1
+ import{__decorate as t,__metadata as e}from"tslib";import{injectable as r}from"inversify";import{CommandBus as o}from"../commands/command-bus.js";import{ERROR_CODE_ACCESS_AFTER_DISPOSAL as n,ERROR_CODE_ACCESS_BEFORE_ACTIVATION as i}from"../error/error-code.js";import{WirestateError as s}from"../error/wirestate-error.js";import{EventBus as a}from"../events/event-bus.js";import{QueryBus as p}from"../queries/query-bus.js";import{SEEDS_TOKEN as u,SEED_TOKEN as c}from"../registry.js";var m=function(){function m(t){this.container=t,this.isDisposed=!1}return m.prototype.getContainer=function(){if(this.container)return this.container;throw this.isDisposed?new s(n,"WireScope::container accessed after deactivation. Ensure service is properly disposed."):new s(i,"WireScope::container accessed before activation. Ensure service is bound to container and is properly resolved.")},m.prototype.resolve=function(t){return this.getContainer().get(t)},m.prototype.resolveOptional=function(t){var e=this.getContainer();return e.isBound(t)?e.get(t):null},m.prototype.emitEvent=function(t,e,r){this.getContainer().get(a).emit({type:t,payload:e,from:void 0===r?this:r})},m.prototype.queryData=function(t,e){return this.getContainer().get(p).query(t,e)},m.prototype.queryOptionalData=function(t,e){return this.getContainer().get(p).queryOptional(t,e)},m.prototype.executeCommand=function(t,e){return this.getContainer().get(o).command(t,e)},m.prototype.executeOptionalCommand=function(t,e){return this.getContainer().get(o).commandOptional(t,e)},m.prototype.getSeed=function(t){return t?this.getContainer().get(u).get(t)||null:this.getContainer().get(c)},m=t([r(),e("design:paramtypes",[Object])],m)}();export{m as WireScope};//# sourceMappingURL=wire-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-scope.js","sources":["../../../../../../../../../src/wirestate-core/container/wire-scope.ts"],"sourcesContent":[null],"names":["__decorate","__metadata","injectable","CommandBus","ERROR_CODE_ACCESS_AFTER_DISPOSAL","ERROR_CODE_ACCESS_BEFORE_ACTIVATION","WirestateError","EventBus","QueryBus","SEEDS_TOKEN","SEED_TOKEN","WireScope","container","this","isDisposed","prototype","getContainer","resolve","injectionId","get","resolveOptional","isBound","emitEvent","type","payload","from","emit","undefined","queryData","data","query","queryOptionalData","queryOptional","executeCommand","command","executeOptionalCommand","commandOptional","getSeed","seed"],"mappings":"qBAoBAA,gBAAAC,MAAA,6BAAAC,MAAA,iCAAAC,MAAA,wEAAAC,yCAAAC,MAAA,kDAAAC,MAAA,iDAAAC,MAAA,4CAAAC,MAAA,gDAAAC,gBAAAC,MAAA,iBAMA,IAAAC,EAAA,WAME,SAAAA,EAAoCC,GAAAC,KAAAD,UAAAA,EAFpBC,KAAAC,YAAsB,CAE+B,CA0LvE,OAhLSH,EAAAI,UAAAC,aAAP,WACE,GAAIH,KAAKD,UACP,OAAOC,KAAKD,UAGd,MAAIC,KAAKC,WACD,IAAIR,EACRF,EACA,0FAGI,IAAIE,EACRD,EACA,kHAIN,EAYOM,EAAAI,UAAAE,QAAP,SAAkBC,GAMhB,OAAOL,KAAKG,eAAeG,IAAOD,EACpC,EAYOP,EAAAI,UAAAK,gBAAP,SAA0BF,GAMxB,IAAMN,EAAuBC,KAAKG,eAElC,OAAOJ,EAAUS,QAAQH,GAAeN,EAAUO,IAAOD,GAAe,IAC1E,EAYOP,EAAAI,UAAAO,UAAP,SAAuDC,EAASC,EAAaC,GAO3EZ,KAAKG,eACFG,IAAIZ,GACJmB,KAAK,CACJH,KAAIA,EACJC,QAAOA,EACPC,UAAeE,IAATF,EAAqBZ,KAAOY,GAExC,EAYOd,EAAAI,UAAAa,UAAP,SAA8EL,EAASM,GAGrF,OAAOhB,KAAKG,eAAeG,IAAIX,GAAUsB,MAAYP,EAAMM,EAC7D,EAUOlB,EAAAI,UAAAgB,kBAAP,SACER,EACAM,GAIA,OAAOhB,KAAKG,eAAeG,IAAIX,GAAUwB,cAAoBT,EAAMM,EACrE,EAYOlB,EAAAI,UAAAkB,eAAP,SACEV,EACAM,GAIA,OAAOhB,KAAKG,eAAeG,IAAIhB,GAAY+B,QAAcX,EAAMM,EACjE,EAUOlB,EAAAI,UAAAoB,uBAAP,SACEZ,EACAM,GAIA,OAAOhB,KAAKG,eAAeG,IAAIhB,GAAYiC,gBAAsBb,EAAMM,EACzE,EAeOlB,EAAAI,UAAAsB,QAAP,SAAqCC,GAKnC,OAAOA,EACFzB,KAAKG,eAAeG,IAAeV,GAAaU,IAAImB,IAAe,KACpEzB,KAAKG,eAAeG,IAAOT,EACjC,EA/LWC,EAASX,EAAA,CADrBE,qCACYS,EAgMZ,CAhMD,UADAA"}
@@ -0,0 +1 @@
1
+ var r=1,a=51,e=52,o=101,p=102,t=200,v=201;export{v as ERROR_CODE_ACCESS_AFTER_DISPOSAL,t as ERROR_CODE_ACCESS_BEFORE_ACTIVATION,e as ERROR_CODE_BINDING_SCOPE,p as ERROR_CODE_FAILED_TO_RESOLVE_COMMAND_HANDLER,o as ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER,r as ERROR_CODE_GENERIC,a as ERROR_CODE_INVALID_ARGUMENTS};//# sourceMappingURL=error-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-code.js","sources":["../../../../../../../../../src/wirestate-core/error/error-code.ts"],"sourcesContent":[null],"names":["ERROR_CODE_GENERIC","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,IAAMA,EAA6B,EAG7BC,EAAuC,GACvCC,EAAmC,GAGnCC,EAAqD,IACrDC,EAAuD,IAEvDC,EAA8C,IAC9CC,EAA2C,WAAAA,sCAAAD,yCAAAH,8BAAAE,kDAAAD,gDAAAH,wBAAAC"}
@@ -0,0 +1 @@
1
+ import{__extends as r}from"tslib";import{ERROR_CODE_GENERIC as e}from"./error-code.js";var o=function(o){function t(r,t){void 0===r&&(r=e);var i=o.call(this)||this;return i.name="WirestateError",i.code=r,i.message=t||"Wirestate error.",i}return r(t,o),t}(Error);export{o as WirestateError};//# sourceMappingURL=wirestate-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wirestate-error.js","sources":["../../../../../../../../../src/wirestate-core/error/wirestate-error.ts"],"sourcesContent":[null],"names":["__extends","ERROR_CODE_GENERIC","WirestateError","_super","code","detail","_this","this","name","message","Error"],"mappings":"oBAEAA,MAAA,qCAAAC,MAAA,kBAMA,IAAAC,EAAA,SAAAC,GAcE,SAAAD,EAAmBE,EAAmCC,QAAnC,IAAAD,IAAAA,EAAAH,GACjB,IAAAK,EAAAH,cAAOI,YAXOD,EAAAE,KAAe,iBAa7BF,EAAKF,KAAOA,EACZE,EAAKG,QAAUJ,GAAU,oBAC3B,CACF,OApBoCL,EAAAE,EAAAC,GAoBpCD,CAAA,CApBA,CAAoCQ,cAAKR"}
@@ -0,0 +1 @@
1
+ import{getEventHandlerMetadata as e}from"./get-event-handler-metadata.js";function t(t){for(var n=[],r=0,a=e(t);r<a.length;r++){var l=a[r],o=t[l.methodName];"function"==typeof o&&n.push({types:l.types,handler:o.bind(t)})}return n.length?function(e){for(var t=0,r=n;t<r.length;t++){var a=r[t];(null===a.types||a.types.includes(e.type))&&a.handler(e)}}:null}export{t as buildEventDispatcher};//# sourceMappingURL=build-event-dispatcher.js.map