quidproquo-web-react 0.1.12 → 0.1.13

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 (242) hide show
  1. package/lib/commonjs/hooks/index.d.ts +0 -1
  2. package/lib/commonjs/hooks/index.js +0 -1
  3. package/lib/commonjs/hooks/index.js.map +1 -1
  4. package/lib/commonjs/hooks/useQpq.js +2 -2
  5. package/lib/commonjs/hooks/useQpq.js.map +1 -1
  6. package/lib/commonjs/index.d.ts +3 -0
  7. package/lib/commonjs/index.js +3 -0
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/{hooks/asmj → qpqContext}/QpqContextProvider.d.ts +3 -5
  10. package/lib/commonjs/qpqContext/QpqContextProvider.js +16 -0
  11. package/lib/commonjs/qpqContext/QpqContextProvider.js.map +1 -0
  12. package/lib/commonjs/qpqContext/index.d.ts +3 -0
  13. package/lib/commonjs/qpqContext/index.js +20 -0
  14. package/lib/commonjs/qpqContext/index.js.map +1 -0
  15. package/lib/commonjs/qpqContext/qpqReactContext.d.ts +2 -0
  16. package/lib/commonjs/qpqContext/qpqReactContext.js +6 -0
  17. package/lib/commonjs/qpqContext/qpqReactContext.js.map +1 -0
  18. package/lib/commonjs/qpqContext/useQpqContextValue.d.ts +2 -0
  19. package/lib/commonjs/qpqContext/useQpqContextValue.js +10 -0
  20. package/lib/commonjs/qpqContext/useQpqContextValue.js.map +1 -0
  21. package/lib/commonjs/qpqContext/useQpqContextValues.d.ts +2 -0
  22. package/lib/commonjs/qpqContext/useQpqContextValues.js +10 -0
  23. package/lib/commonjs/qpqContext/useQpqContextValues.js.map +1 -0
  24. package/lib/commonjs/runtime/ActionProcessorListResolverFactory.d.ts +3 -0
  25. package/lib/commonjs/runtime/ActionProcessorListResolverFactory.js +3 -0
  26. package/lib/commonjs/runtime/ActionProcessorListResolverFactory.js.map +1 -0
  27. package/lib/commonjs/runtime/BubbleReducerDispatchContext.d.ts +1 -0
  28. package/lib/commonjs/runtime/BubbleReducerDispatchContext.js +9 -0
  29. package/lib/commonjs/runtime/BubbleReducerDispatchContext.js.map +1 -0
  30. package/lib/commonjs/runtime/QpqBubbleReducer.d.ts +1 -0
  31. package/lib/commonjs/runtime/QpqBubbleReducer.js +3 -0
  32. package/lib/commonjs/runtime/QpqBubbleReducer.js.map +1 -0
  33. package/lib/commonjs/runtime/QpqMappedApi.js.map +1 -0
  34. package/lib/commonjs/runtime/QpqRuntimeEffectCatcher.d.ts +9 -0
  35. package/lib/commonjs/runtime/QpqRuntimeEffectCatcher.js +13 -0
  36. package/lib/commonjs/runtime/QpqRuntimeEffectCatcher.js.map +1 -0
  37. package/lib/commonjs/runtime/actionProcessor/getStateDispatchActionProcessor.js.map +1 -0
  38. package/lib/commonjs/runtime/actionProcessor/getStateReadActionProcessor.js.map +1 -0
  39. package/lib/commonjs/runtime/actionProcessor/index.js.map +1 -0
  40. package/lib/commonjs/runtime/createQpqRuntimeComputed.d.ts +7 -0
  41. package/lib/commonjs/runtime/createQpqRuntimeComputed.js +7 -0
  42. package/lib/commonjs/runtime/createQpqRuntimeComputed.js.map +1 -0
  43. package/lib/commonjs/runtime/createQpqRuntimeDefinition.d.ts +16 -0
  44. package/lib/commonjs/runtime/createQpqRuntimeDefinition.js +10 -0
  45. package/lib/commonjs/runtime/createQpqRuntimeDefinition.js.map +1 -0
  46. package/lib/commonjs/runtime/getQpqRuntimeAreaKey.d.ts +3 -0
  47. package/lib/commonjs/runtime/getQpqRuntimeAreaKey.js +6 -0
  48. package/lib/commonjs/runtime/getQpqRuntimeAreaKey.js.map +1 -0
  49. package/lib/commonjs/runtime/index.d.ts +12 -0
  50. package/lib/commonjs/{hooks/asmj → runtime}/index.js +6 -2
  51. package/lib/commonjs/runtime/index.js.map +1 -0
  52. package/lib/commonjs/{hooks/asmj → runtime}/useBubbleReducer.d.ts +1 -1
  53. package/lib/commonjs/{hooks/asmj → runtime}/useBubbleReducer.js +2 -2
  54. package/lib/commonjs/runtime/useBubbleReducer.js.map +1 -0
  55. package/lib/commonjs/runtime/useQpqAreaBinding.d.ts +11 -0
  56. package/lib/commonjs/runtime/useQpqAreaBinding.js +81 -0
  57. package/lib/commonjs/runtime/useQpqAreaBinding.js.map +1 -0
  58. package/lib/commonjs/runtime/useQpqRuntime.d.ts +4 -0
  59. package/lib/commonjs/runtime/useQpqRuntime.js +28 -0
  60. package/lib/commonjs/runtime/useQpqRuntime.js.map +1 -0
  61. package/lib/commonjs/runtime/useQpqRuntimeComputed.d.ts +2 -0
  62. package/lib/commonjs/runtime/useQpqRuntimeComputed.js +26 -0
  63. package/lib/commonjs/runtime/useQpqRuntimeComputed.js.map +1 -0
  64. package/lib/commonjs/store/QpqStoreProvider.d.ts +8 -0
  65. package/lib/commonjs/store/QpqStoreProvider.js +13 -0
  66. package/lib/commonjs/store/QpqStoreProvider.js.map +1 -0
  67. package/lib/commonjs/store/connectQpqStoreToReduxDevTools.d.ts +2 -0
  68. package/lib/commonjs/store/connectQpqStoreToReduxDevTools.js +144 -0
  69. package/lib/commonjs/store/connectQpqStoreToReduxDevTools.js.map +1 -0
  70. package/lib/commonjs/store/createQpqStore.d.ts +22 -0
  71. package/lib/commonjs/store/createQpqStore.js +160 -0
  72. package/lib/commonjs/store/createQpqStore.js.map +1 -0
  73. package/lib/commonjs/store/index.d.ts +5 -0
  74. package/lib/commonjs/store/index.js +22 -0
  75. package/lib/commonjs/store/index.js.map +1 -0
  76. package/lib/commonjs/store/qpqStoreContext.d.ts +3 -0
  77. package/lib/commonjs/store/qpqStoreContext.js +6 -0
  78. package/lib/commonjs/store/qpqStoreContext.js.map +1 -0
  79. package/lib/commonjs/store/useQpqStore.d.ts +2 -0
  80. package/lib/commonjs/store/useQpqStore.js +14 -0
  81. package/lib/commonjs/store/useQpqStore.js.map +1 -0
  82. package/lib/commonjs/useFieldBinding/useFieldBinding.d.ts +1 -1
  83. package/lib/commonjs/useFieldBinding/useFieldBinding.js +2 -2
  84. package/lib/commonjs/useFieldBinding/useFieldBinding.js.map +1 -1
  85. package/lib/commonjs/useSharedQueryParams/sharedQueryParamsRuntime.d.ts +1 -1
  86. package/lib/commonjs/useSharedQueryParams/sharedQueryParamsRuntime.js +7 -2
  87. package/lib/commonjs/useSharedQueryParams/sharedQueryParamsRuntime.js.map +1 -1
  88. package/lib/commonjs/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.d.ts +4 -5
  89. package/lib/commonjs/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.js +3 -3
  90. package/lib/commonjs/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.js.map +1 -1
  91. package/lib/commonjs/webSocketQueue/hooks/useWebsocketQueueSendEvent.js +8 -1
  92. package/lib/commonjs/webSocketQueue/hooks/useWebsocketQueueSendEvent.js.map +1 -1
  93. package/lib/esm/hooks/index.d.ts +0 -1
  94. package/lib/esm/hooks/index.js +0 -1
  95. package/lib/esm/hooks/index.js.map +1 -1
  96. package/lib/esm/hooks/useQpq.js +1 -1
  97. package/lib/esm/hooks/useQpq.js.map +1 -1
  98. package/lib/esm/index.d.ts +3 -0
  99. package/lib/esm/index.js +3 -0
  100. package/lib/esm/index.js.map +1 -1
  101. package/lib/esm/{hooks/asmj → qpqContext}/QpqContextProvider.d.ts +3 -5
  102. package/lib/esm/{hooks/asmj → qpqContext}/QpqContextProvider.js +2 -10
  103. package/lib/esm/qpqContext/QpqContextProvider.js.map +1 -0
  104. package/lib/esm/qpqContext/index.d.ts +3 -0
  105. package/lib/esm/qpqContext/index.js +4 -0
  106. package/lib/esm/qpqContext/index.js.map +1 -0
  107. package/lib/esm/qpqContext/qpqReactContext.d.ts +2 -0
  108. package/lib/esm/qpqContext/qpqReactContext.js +3 -0
  109. package/lib/esm/qpqContext/qpqReactContext.js.map +1 -0
  110. package/lib/esm/qpqContext/useQpqContextValue.d.ts +2 -0
  111. package/lib/esm/qpqContext/useQpqContextValue.js +6 -0
  112. package/lib/esm/qpqContext/useQpqContextValue.js.map +1 -0
  113. package/lib/esm/qpqContext/useQpqContextValues.d.ts +2 -0
  114. package/lib/esm/qpqContext/useQpqContextValues.js +6 -0
  115. package/lib/esm/qpqContext/useQpqContextValues.js.map +1 -0
  116. package/lib/esm/runtime/ActionProcessorListResolverFactory.d.ts +3 -0
  117. package/lib/esm/runtime/ActionProcessorListResolverFactory.js +2 -0
  118. package/lib/esm/runtime/ActionProcessorListResolverFactory.js.map +1 -0
  119. package/lib/esm/runtime/BubbleReducerDispatchContext.d.ts +1 -0
  120. package/lib/esm/runtime/BubbleReducerDispatchContext.js +6 -0
  121. package/lib/esm/runtime/BubbleReducerDispatchContext.js.map +1 -0
  122. package/lib/esm/runtime/QpqBubbleReducer.d.ts +1 -0
  123. package/lib/esm/runtime/QpqBubbleReducer.js +2 -0
  124. package/lib/esm/runtime/QpqBubbleReducer.js.map +1 -0
  125. package/lib/esm/runtime/QpqMappedApi.js.map +1 -0
  126. package/lib/esm/runtime/QpqRuntimeEffectCatcher.d.ts +9 -0
  127. package/lib/esm/{hooks/asmj → runtime}/QpqRuntimeEffectCatcher.js +3 -3
  128. package/lib/esm/runtime/QpqRuntimeEffectCatcher.js.map +1 -0
  129. package/lib/esm/runtime/actionProcessor/getStateDispatchActionProcessor.js.map +1 -0
  130. package/lib/esm/runtime/actionProcessor/getStateReadActionProcessor.js.map +1 -0
  131. package/lib/esm/runtime/actionProcessor/index.js.map +1 -0
  132. package/lib/esm/runtime/createQpqRuntimeComputed.d.ts +7 -0
  133. package/lib/esm/runtime/createQpqRuntimeComputed.js +4 -0
  134. package/lib/esm/runtime/createQpqRuntimeComputed.js.map +1 -0
  135. package/lib/esm/runtime/createQpqRuntimeDefinition.d.ts +16 -0
  136. package/lib/esm/runtime/createQpqRuntimeDefinition.js +10 -0
  137. package/lib/esm/runtime/createQpqRuntimeDefinition.js.map +1 -0
  138. package/lib/esm/runtime/getQpqRuntimeAreaKey.d.ts +3 -0
  139. package/lib/esm/runtime/getQpqRuntimeAreaKey.js +2 -0
  140. package/lib/esm/runtime/getQpqRuntimeAreaKey.js.map +1 -0
  141. package/lib/esm/runtime/index.d.ts +12 -0
  142. package/lib/esm/runtime/index.js +13 -0
  143. package/lib/esm/runtime/index.js.map +1 -0
  144. package/lib/esm/{hooks/asmj → runtime}/useBubbleReducer.d.ts +1 -1
  145. package/lib/esm/{hooks/asmj → runtime}/useBubbleReducer.js +1 -1
  146. package/lib/esm/runtime/useBubbleReducer.js.map +1 -0
  147. package/lib/esm/runtime/useQpqAreaBinding.d.ts +11 -0
  148. package/lib/esm/runtime/useQpqAreaBinding.js +68 -0
  149. package/lib/esm/runtime/useQpqAreaBinding.js.map +1 -0
  150. package/lib/esm/runtime/useQpqRuntime.d.ts +4 -0
  151. package/lib/esm/runtime/useQpqRuntime.js +25 -0
  152. package/lib/esm/runtime/useQpqRuntime.js.map +1 -0
  153. package/lib/esm/runtime/useQpqRuntimeComputed.d.ts +2 -0
  154. package/lib/esm/runtime/useQpqRuntimeComputed.js +23 -0
  155. package/lib/esm/runtime/useQpqRuntimeComputed.js.map +1 -0
  156. package/lib/esm/store/QpqStoreProvider.d.ts +8 -0
  157. package/lib/esm/store/QpqStoreProvider.js +9 -0
  158. package/lib/esm/store/QpqStoreProvider.js.map +1 -0
  159. package/lib/esm/store/connectQpqStoreToReduxDevTools.d.ts +2 -0
  160. package/lib/esm/store/connectQpqStoreToReduxDevTools.js +137 -0
  161. package/lib/esm/store/connectQpqStoreToReduxDevTools.js.map +1 -0
  162. package/lib/esm/store/createQpqStore.d.ts +22 -0
  163. package/lib/esm/store/createQpqStore.js +156 -0
  164. package/lib/esm/store/createQpqStore.js.map +1 -0
  165. package/lib/esm/store/index.d.ts +5 -0
  166. package/lib/esm/store/index.js +6 -0
  167. package/lib/esm/store/index.js.map +1 -0
  168. package/lib/esm/store/qpqStoreContext.d.ts +3 -0
  169. package/lib/esm/store/qpqStoreContext.js +3 -0
  170. package/lib/esm/store/qpqStoreContext.js.map +1 -0
  171. package/lib/esm/store/useQpqStore.d.ts +2 -0
  172. package/lib/esm/store/useQpqStore.js +10 -0
  173. package/lib/esm/store/useQpqStore.js.map +1 -0
  174. package/lib/esm/useFieldBinding/useFieldBinding.d.ts +1 -1
  175. package/lib/esm/useFieldBinding/useFieldBinding.js +1 -1
  176. package/lib/esm/useFieldBinding/useFieldBinding.js.map +1 -1
  177. package/lib/esm/useSharedQueryParams/sharedQueryParamsRuntime.d.ts +1 -1
  178. package/lib/esm/useSharedQueryParams/sharedQueryParamsRuntime.js +7 -2
  179. package/lib/esm/useSharedQueryParams/sharedQueryParamsRuntime.js.map +1 -1
  180. package/lib/esm/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.d.ts +4 -5
  181. package/lib/esm/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.js +3 -3
  182. package/lib/esm/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.js.map +1 -1
  183. package/lib/esm/webSocketQueue/hooks/useWebsocketQueueSendEvent.js +8 -1
  184. package/lib/esm/webSocketQueue/hooks/useWebsocketQueueSendEvent.js.map +1 -1
  185. package/package.json +8 -9
  186. package/lib/commonjs/hooks/asmj/QpqContextProvider.js +0 -26
  187. package/lib/commonjs/hooks/asmj/QpqContextProvider.js.map +0 -1
  188. package/lib/commonjs/hooks/asmj/QpqMappedApi.js.map +0 -1
  189. package/lib/commonjs/hooks/asmj/QpqRuntimeEffectCatcher.d.ts +0 -14
  190. package/lib/commonjs/hooks/asmj/QpqRuntimeEffectCatcher.js +0 -14
  191. package/lib/commonjs/hooks/asmj/QpqRuntimeEffectCatcher.js.map +0 -1
  192. package/lib/commonjs/hooks/asmj/actionProcessor/getStateDispatchActionProcessor.js.map +0 -1
  193. package/lib/commonjs/hooks/asmj/actionProcessor/getStateReadActionProcessor.js.map +0 -1
  194. package/lib/commonjs/hooks/asmj/actionProcessor/index.js.map +0 -1
  195. package/lib/commonjs/hooks/asmj/bubbleReducer.d.ts +0 -5
  196. package/lib/commonjs/hooks/asmj/bubbleReducer.js +0 -29
  197. package/lib/commonjs/hooks/asmj/bubbleReducer.js.map +0 -1
  198. package/lib/commonjs/hooks/asmj/createQpqRuntimeDefinition.d.ts +0 -22
  199. package/lib/commonjs/hooks/asmj/createQpqRuntimeDefinition.js +0 -53
  200. package/lib/commonjs/hooks/asmj/createQpqRuntimeDefinition.js.map +0 -1
  201. package/lib/commonjs/hooks/asmj/index.d.ts +0 -8
  202. package/lib/commonjs/hooks/asmj/index.js.map +0 -1
  203. package/lib/commonjs/hooks/asmj/useBubbleReducer.js.map +0 -1
  204. package/lib/commonjs/hooks/asmj/useQpqRuntime.d.ts +0 -6
  205. package/lib/commonjs/hooks/asmj/useQpqRuntime.js +0 -49
  206. package/lib/commonjs/hooks/asmj/useQpqRuntime.js.map +0 -1
  207. package/lib/esm/hooks/asmj/QpqContextProvider.js.map +0 -1
  208. package/lib/esm/hooks/asmj/QpqMappedApi.js.map +0 -1
  209. package/lib/esm/hooks/asmj/QpqRuntimeEffectCatcher.d.ts +0 -14
  210. package/lib/esm/hooks/asmj/QpqRuntimeEffectCatcher.js.map +0 -1
  211. package/lib/esm/hooks/asmj/actionProcessor/getStateDispatchActionProcessor.js.map +0 -1
  212. package/lib/esm/hooks/asmj/actionProcessor/getStateReadActionProcessor.js.map +0 -1
  213. package/lib/esm/hooks/asmj/actionProcessor/index.js.map +0 -1
  214. package/lib/esm/hooks/asmj/bubbleReducer.d.ts +0 -5
  215. package/lib/esm/hooks/asmj/bubbleReducer.js +0 -25
  216. package/lib/esm/hooks/asmj/bubbleReducer.js.map +0 -1
  217. package/lib/esm/hooks/asmj/createQpqRuntimeDefinition.d.ts +0 -22
  218. package/lib/esm/hooks/asmj/createQpqRuntimeDefinition.js +0 -47
  219. package/lib/esm/hooks/asmj/createQpqRuntimeDefinition.js.map +0 -1
  220. package/lib/esm/hooks/asmj/index.d.ts +0 -8
  221. package/lib/esm/hooks/asmj/index.js +0 -9
  222. package/lib/esm/hooks/asmj/index.js.map +0 -1
  223. package/lib/esm/hooks/asmj/useBubbleReducer.js.map +0 -1
  224. package/lib/esm/hooks/asmj/useQpqRuntime.d.ts +0 -6
  225. package/lib/esm/hooks/asmj/useQpqRuntime.js +0 -38
  226. package/lib/esm/hooks/asmj/useQpqRuntime.js.map +0 -1
  227. /package/lib/commonjs/{hooks/asmj → runtime}/QpqMappedApi.d.ts +0 -0
  228. /package/lib/commonjs/{hooks/asmj → runtime}/QpqMappedApi.js +0 -0
  229. /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.d.ts +0 -0
  230. /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.js +0 -0
  231. /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateReadActionProcessor.d.ts +0 -0
  232. /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateReadActionProcessor.js +0 -0
  233. /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/index.d.ts +0 -0
  234. /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/index.js +0 -0
  235. /package/lib/esm/{hooks/asmj → runtime}/QpqMappedApi.d.ts +0 -0
  236. /package/lib/esm/{hooks/asmj → runtime}/QpqMappedApi.js +0 -0
  237. /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.d.ts +0 -0
  238. /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.js +0 -0
  239. /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/getStateReadActionProcessor.d.ts +0 -0
  240. /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/getStateReadActionProcessor.js +0 -0
  241. /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/index.d.ts +0 -0
  242. /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/index.js +0 -0
@@ -1,4 +1,3 @@
1
- export * from './asmj';
2
1
  export * from './useAsyncEffect';
3
2
  export * from './useComputed';
4
3
  export * from './useEffectCallback';
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./asmj"), exports);
18
17
  __exportStar(require("./useAsyncEffect"), exports);
19
18
  __exportStar(require("./useComputed"), exports);
20
19
  __exportStar(require("./useEffectCallback"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,mDAAiC;AACjC,gDAA8B;AAC9B,sDAAoC;AACpC,oDAAkC;AAClC,gDAA8B;AAC9B,uDAAqC;AACrC,2CAAyB;AACzB,gDAA8B;AAC9B,qDAAmC;AACnC,iDAA+B","sourcesContent":["export * from './asmj';\nexport * from './useAsyncEffect';\nexport * from './useComputed';\nexport * from './useEffectCallback';\nexport * from './useFastCallback';\nexport * from './useMetadata';\nexport * from './useOnKeyDownEffect';\nexport * from './useQpq';\nexport * from './useRunEvery';\nexport * from './useThrottledMemo';\nexport * from './useZipArrays';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,gDAA8B;AAC9B,sDAAoC;AACpC,oDAAkC;AAClC,gDAA8B;AAC9B,uDAAqC;AACrC,2CAAyB;AACzB,gDAA8B;AAC9B,qDAAmC;AACnC,iDAA+B","sourcesContent":["export * from './useAsyncEffect';\nexport * from './useComputed';\nexport * from './useEffectCallback';\nexport * from './useFastCallback';\nexport * from './useMetadata';\nexport * from './useOnKeyDownEffect';\nexport * from './useQpq';\nexport * from './useRunEvery';\nexport * from './useThrottledMemo';\nexport * from './useZipArrays';\n"]}
@@ -14,7 +14,7 @@ const quidproquo_actionprocessor_web_1 = require("quidproquo-actionprocessor-web
14
14
  const quidproquo_core_1 = require("quidproquo-core");
15
15
  const react_1 = require("react");
16
16
  const actionProcessor_1 = require("../actionProcessor");
17
- const QpqContextProvider_1 = require("./asmj/QpqContextProvider");
17
+ const useQpqContextValues_1 = require("../qpqContext/useQpqContextValues");
18
18
  const useEffectCallback_1 = require("./useEffectCallback");
19
19
  function* withVersionCheck(story, versionRef, capturedVersion) {
20
20
  let nextValue = undefined;
@@ -38,7 +38,7 @@ const logger = {
38
38
  moveToPermanentStorage: () => __awaiter(void 0, void 0, void 0, function* () { }),
39
39
  };
40
40
  function useQpq(getActionProcessors = () => __awaiter(this, void 0, void 0, function* () { return ({}); })) {
41
- const qpqContextValues = (0, QpqContextProvider_1.useQpqContextValues)();
41
+ const qpqContextValues = (0, useQpqContextValues_1.useQpqContextValues)();
42
42
  const contextGetActionProcessors = (0, actionProcessor_1.useActionProcessors)();
43
43
  const versionRef = (0, react_1.useRef)(0);
44
44
  (0, react_1.useEffect)(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"useQpq.js","sourceRoot":"","sources":["../../../src/hooks/useQpq.ts"],"names":[],"mappings":"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","sourcesContent":["import { getWebActionProcessors } from 'quidproquo-actionprocessor-web';\nimport {\n ActionProcessorListResolver,\n AskResponse,\n AskResponseReturnType,\n createRuntime,\n defineModule,\n QpqFunctionRuntime,\n QpqRuntimeType,\n Story,\n StoryResolver,\n} from 'quidproquo-core';\n\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { useActionProcessors } from '../actionProcessor';\nimport { useQpqContextValues } from './asmj/QpqContextProvider';\nimport { useEffectCallback } from './useEffectCallback';\n\nfunction* withVersionCheck<R>(story: AskResponse<R>, versionRef: React.RefObject<number>, capturedVersion: number): AskResponse<R | undefined> {\n let nextValue: any = undefined;\n\n while (true) {\n if (versionRef.current !== capturedVersion) {\n return undefined;\n }\n\n const { value, done } = story.next(nextValue);\n\n if (done) {\n return value;\n }\n\n nextValue = yield value;\n }\n}\n\n// WIP ~ useFastCallback, wack things like loggers in a context, try to only make once instance of the runtime.\n// Also don't create every refresh.. useMemo / useCallback etc\n\nconst logger = {\n enableLogs: async () => {},\n log: async () => {},\n waitToFinishWriting: async () => {},\n moveToPermanentStorage: async () => {},\n};\n\nexport function useQpq(getActionProcessors: ActionProcessorListResolver = async () => ({})): StoryResolver {\n const qpqContextValues = useQpqContextValues();\n const contextGetActionProcessors = useActionProcessors();\n const versionRef = useRef(0);\n\n useEffect(() => {\n const capturedVersionRef = versionRef;\n return () => {\n capturedVersionRef.current++;\n };\n }, []);\n\n // Stable identities so the runtime memo can list them as dependencies\n // without being recreated every render — the runtime always calls the\n // latest processors through these wrappers.\n const stableContextGetActionProcessors = useEffectCallback(contextGetActionProcessors);\n const stableGetActionProcessors = useEffectCallback(getActionProcessors);\n\n const resolveStory = useMemo(\n () =>\n createRuntime(\n [defineModule('UI')],\n {\n depth: 0,\n context: qpqContextValues,\n },\n async (qpqConfig, dynamicModuleLoader) => ({\n ...(await getWebActionProcessors(qpqConfig, dynamicModuleLoader)),\n ...(await stableContextGetActionProcessors(qpqConfig, dynamicModuleLoader)),\n ...(await stableGetActionProcessors(qpqConfig, dynamicModuleLoader)),\n }),\n () => new Date().toISOString(),\n logger,\n `frontend::${'uuid'}`,\n QpqRuntimeType.UI,\n async (_runtime: QpqFunctionRuntime) => {\n // noop\n },\n ),\n [qpqContextValues, stableContextGetActionProcessors, stableGetActionProcessors],\n );\n\n const qpq = useCallback(\n function getStoryExecutor<S extends Story<any, any>>(story: S): (...args: Parameters<S>) => Promise<AskResponseReturnType<ReturnType<S>>> {\n return async (...args: Parameters<S>) => {\n const capturedVersion = versionRef.current;\n const wrappedStory = (...storyArgs: Parameters<S>) => withVersionCheck(story(...storyArgs), versionRef, capturedVersion);\n const result = await resolveStory(wrappedStory, args);\n\n if (result.error) {\n throw new Error(result.error.errorText);\n }\n\n return result.result;\n };\n },\n [resolveStory],\n );\n\n return qpq;\n}\n"]}
1
+ {"version":3,"file":"useQpq.js","sourceRoot":"","sources":["../../../src/hooks/useQpq.ts"],"names":[],"mappings":"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","sourcesContent":["import { getWebActionProcessors } from 'quidproquo-actionprocessor-web';\nimport {\n ActionProcessorListResolver,\n AskResponse,\n AskResponseReturnType,\n createRuntime,\n defineModule,\n QpqFunctionRuntime,\n QpqRuntimeType,\n Story,\n StoryResolver,\n} from 'quidproquo-core';\n\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { useActionProcessors } from '../actionProcessor';\nimport { useQpqContextValues } from '../qpqContext/useQpqContextValues';\nimport { useEffectCallback } from './useEffectCallback';\n\nfunction* withVersionCheck<R>(story: AskResponse<R>, versionRef: React.RefObject<number>, capturedVersion: number): AskResponse<R | undefined> {\n let nextValue: any = undefined;\n\n while (true) {\n if (versionRef.current !== capturedVersion) {\n return undefined;\n }\n\n const { value, done } = story.next(nextValue);\n\n if (done) {\n return value;\n }\n\n nextValue = yield value;\n }\n}\n\n// WIP ~ useFastCallback, wack things like loggers in a context, try to only make once instance of the runtime.\n// Also don't create every refresh.. useMemo / useCallback etc\n\nconst logger = {\n enableLogs: async () => {},\n log: async () => {},\n waitToFinishWriting: async () => {},\n moveToPermanentStorage: async () => {},\n};\n\nexport function useQpq(getActionProcessors: ActionProcessorListResolver = async () => ({})): StoryResolver {\n const qpqContextValues = useQpqContextValues();\n const contextGetActionProcessors = useActionProcessors();\n const versionRef = useRef(0);\n\n useEffect(() => {\n const capturedVersionRef = versionRef;\n return () => {\n capturedVersionRef.current++;\n };\n }, []);\n\n // Stable identities so the runtime memo can list them as dependencies\n // without being recreated every render — the runtime always calls the\n // latest processors through these wrappers.\n const stableContextGetActionProcessors = useEffectCallback(contextGetActionProcessors);\n const stableGetActionProcessors = useEffectCallback(getActionProcessors);\n\n const resolveStory = useMemo(\n () =>\n createRuntime(\n [defineModule('UI')],\n {\n depth: 0,\n context: qpqContextValues,\n },\n async (qpqConfig, dynamicModuleLoader) => ({\n ...(await getWebActionProcessors(qpqConfig, dynamicModuleLoader)),\n ...(await stableContextGetActionProcessors(qpqConfig, dynamicModuleLoader)),\n ...(await stableGetActionProcessors(qpqConfig, dynamicModuleLoader)),\n }),\n () => new Date().toISOString(),\n logger,\n `frontend::${'uuid'}`,\n QpqRuntimeType.UI,\n async (_runtime: QpqFunctionRuntime) => {\n // noop\n },\n ),\n [qpqContextValues, stableContextGetActionProcessors, stableGetActionProcessors],\n );\n\n const qpq = useCallback(\n function getStoryExecutor<S extends Story<any, any>>(story: S): (...args: Parameters<S>) => Promise<AskResponseReturnType<ReturnType<S>>> {\n return async (...args: Parameters<S>) => {\n const capturedVersion = versionRef.current;\n const wrappedStory = (...storyArgs: Parameters<S>) => withVersionCheck(story(...storyArgs), versionRef, capturedVersion);\n const result = await resolveStory(wrappedStory, args);\n\n if (result.error) {\n throw new Error(result.error.errorText);\n }\n\n return result.result;\n };\n },\n [resolveStory],\n );\n\n return qpq;\n}\n"]}
@@ -5,7 +5,10 @@ export * from './auth';
5
5
  export * from './baseUrl';
6
6
  export * from './dateTime';
7
7
  export * from './hooks';
8
+ export * from './qpqContext';
9
+ export * from './runtime';
8
10
  export * from './state';
11
+ export * from './store';
9
12
  export * from './useFieldBinding';
10
13
  export * from './useSharedQueryParams';
11
14
  export * from './websocket';
@@ -21,7 +21,10 @@ __exportStar(require("./auth"), exports);
21
21
  __exportStar(require("./baseUrl"), exports);
22
22
  __exportStar(require("./dateTime"), exports);
23
23
  __exportStar(require("./hooks"), exports);
24
+ __exportStar(require("./qpqContext"), exports);
25
+ __exportStar(require("./runtime"), exports);
24
26
  __exportStar(require("./state"), exports);
27
+ __exportStar(require("./store"), exports);
25
28
  __exportStar(require("./useFieldBinding"), exports);
26
29
  __exportStar(require("./useSharedQueryParams"), exports);
27
30
  __exportStar(require("./websocket"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6BAA2B;AAE3B,oDAAkC;AAClC,wCAAsB;AACtB,yCAAuB;AACvB,4CAA0B;AAC1B,6CAA2B;AAC3B,0CAAwB;AACxB,0CAAwB;AACxB,oDAAkC;AAClC,yDAAuC;AACvC,8CAA4B;AAC5B,mDAAiC","sourcesContent":["import 'symbol-observable';\n\nexport * from './actionProcessor';\nexport * from './api';\nexport * from './auth';\nexport * from './baseUrl';\nexport * from './dateTime';\nexport * from './hooks';\nexport * from './state';\nexport * from './useFieldBinding';\nexport * from './useSharedQueryParams';\nexport * from './websocket';\nexport * from './webSocketQueue';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6BAA2B;AAE3B,oDAAkC;AAClC,wCAAsB;AACtB,yCAAuB;AACvB,4CAA0B;AAC1B,6CAA2B;AAC3B,0CAAwB;AACxB,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB;AACxB,oDAAkC;AAClC,yDAAuC;AACvC,8CAA4B;AAC5B,mDAAiC","sourcesContent":["import 'symbol-observable';\n\nexport * from './actionProcessor';\nexport * from './api';\nexport * from './auth';\nexport * from './baseUrl';\nexport * from './dateTime';\nexport * from './hooks';\nexport * from './qpqContext';\nexport * from './runtime';\nexport * from './state';\nexport * from './store';\nexport * from './useFieldBinding';\nexport * from './useSharedQueryParams';\nexport * from './websocket';\nexport * from './webSocketQueue';\n"]}
@@ -1,11 +1,9 @@
1
- import { QpqContext, QpqContextIdentifier } from 'quidproquo-core';
1
+ import { QpqContextIdentifier } from 'quidproquo-core';
2
2
  import { ReactNode } from 'react';
3
- interface QpqContextProviderProps<T> {
3
+ type QpqContextProviderProps<T> = {
4
4
  contextIdentifier: QpqContextIdentifier<T>;
5
5
  value: T;
6
6
  children: ReactNode;
7
- }
8
- export declare const useQpqContextValues: () => QpqContext<any>;
9
- export declare const useQpqContextValue: <T>(contextIdentifier: QpqContextIdentifier<T>) => T;
7
+ };
10
8
  export declare const QpqContextProvider: <T>({ contextIdentifier, value, children }: QpqContextProviderProps<T>) => import("react").JSX.Element;
11
9
  export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QpqContextProvider = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const qpqReactContext_1 = require("./qpqReactContext");
7
+ const QpqContextProvider = ({ contextIdentifier, value, children }) => {
8
+ // Get the parent context value
9
+ const parentContext = (0, react_1.useContext)(qpqReactContext_1.qpqReactContext);
10
+ // Merge parent and current value
11
+ const mergedContext = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, parentContext), { [contextIdentifier.uniqueName]: value })), [parentContext, contextIdentifier.uniqueName, value]);
12
+ // Provide the merged context down
13
+ return (0, jsx_runtime_1.jsx)(qpqReactContext_1.qpqReactContext.Provider, { value: mergedContext, children: children });
14
+ };
15
+ exports.QpqContextProvider = QpqContextProvider;
16
+ //# sourceMappingURL=QpqContextProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QpqContextProvider.js","sourceRoot":"","sources":["../../../src/qpqContext/QpqContextProvider.tsx"],"names":[],"mappings":";;;;AAEA,iCAAuD;AAEvD,uDAAoD;AAQ7C,MAAM,kBAAkB,GAAG,CAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAA8B,EAAE,EAAE;IAC3G,+BAA+B;IAC/B,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,iCAAe,CAAC,CAAC;IAElD,iCAAiC;IACjC,MAAM,aAAa,GAAG,IAAA,eAAO,EAC3B,GAAG,EAAE,CAAC,iCAAM,aAAa,KAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,KAAK,IAAG,EACnE,CAAC,aAAa,EAAE,iBAAiB,CAAC,UAAU,EAAE,KAAK,CAAC,CACrD,CAAC;IAEF,kCAAkC;IAClC,OAAO,uBAAC,iCAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAAG,QAAQ,GAA4B,CAAC;AAC/F,CAAC,CAAC;AAZW,QAAA,kBAAkB,sBAY7B","sourcesContent":["import { QpqContextIdentifier } from 'quidproquo-core';\n\nimport { ReactNode, useContext, useMemo } from 'react';\n\nimport { qpqReactContext } from './qpqReactContext';\n\ntype QpqContextProviderProps<T> = {\n contextIdentifier: QpqContextIdentifier<T>; // Ensures the identifier carries the type of the value\n value: T; // The value must match the type expected by the identifier\n children: ReactNode;\n};\n\nexport const QpqContextProvider = <T,>({ contextIdentifier, value, children }: QpqContextProviderProps<T>) => {\n // Get the parent context value\n const parentContext = useContext(qpqReactContext);\n\n // Merge parent and current value\n const mergedContext = useMemo(\n () => ({ ...parentContext, [contextIdentifier.uniqueName]: value }),\n [parentContext, contextIdentifier.uniqueName, value],\n );\n\n // Provide the merged context down\n return <qpqReactContext.Provider value={mergedContext}>{children}</qpqReactContext.Provider>;\n};\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './QpqContextProvider';
2
+ export * from './useQpqContextValue';
3
+ export * from './useQpqContextValues';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./QpqContextProvider"), exports);
18
+ __exportStar(require("./useQpqContextValue"), exports);
19
+ __exportStar(require("./useQpqContextValues"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/qpqContext/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,uDAAqC;AACrC,wDAAsC","sourcesContent":["export * from './QpqContextProvider';\nexport * from './useQpqContextValue';\nexport * from './useQpqContextValues';\n"]}
@@ -0,0 +1,2 @@
1
+ import { QpqContext } from 'quidproquo-core';
2
+ export declare const qpqReactContext: import("react").Context<QpqContext<any>>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.qpqReactContext = void 0;
4
+ const react_1 = require("react");
5
+ exports.qpqReactContext = (0, react_1.createContext)({});
6
+ //# sourceMappingURL=qpqReactContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qpqReactContext.js","sourceRoot":"","sources":["../../../src/qpqContext/qpqReactContext.ts"],"names":[],"mappings":";;;AAEA,iCAAsC;AAEzB,QAAA,eAAe,GAAG,IAAA,qBAAa,EAAkB,EAAE,CAAC,CAAC","sourcesContent":["import { QpqContext } from 'quidproquo-core';\n\nimport { createContext } from 'react';\n\nexport const qpqReactContext = createContext<QpqContext<any>>({});\n"]}
@@ -0,0 +1,2 @@
1
+ import { QpqContextIdentifier } from 'quidproquo-core';
2
+ export declare const useQpqContextValue: <T>(contextIdentifier: QpqContextIdentifier<T>) => T;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useQpqContextValue = void 0;
4
+ const useQpqContextValues_1 = require("./useQpqContextValues");
5
+ const useQpqContextValue = (contextIdentifier) => {
6
+ const context = (0, useQpqContextValues_1.useQpqContextValues)();
7
+ return contextIdentifier.uniqueName in context ? context[contextIdentifier.uniqueName] : contextIdentifier.defaultValue;
8
+ };
9
+ exports.useQpqContextValue = useQpqContextValue;
10
+ //# sourceMappingURL=useQpqContextValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQpqContextValue.js","sourceRoot":"","sources":["../../../src/qpqContext/useQpqContextValue.ts"],"names":[],"mappings":";;;AAEA,+DAA4D;AAErD,MAAM,kBAAkB,GAAG,CAAI,iBAA0C,EAAK,EAAE;IACrF,MAAM,OAAO,GAAG,IAAA,yCAAmB,GAAE,CAAC;IAEtC,OAAO,iBAAiB,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,YAAY,CAAC;AAC1H,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B","sourcesContent":["import { QpqContextIdentifier } from 'quidproquo-core';\n\nimport { useQpqContextValues } from './useQpqContextValues';\n\nexport const useQpqContextValue = <T>(contextIdentifier: QpqContextIdentifier<T>): T => {\n const context = useQpqContextValues();\n\n return contextIdentifier.uniqueName in context ? context[contextIdentifier.uniqueName] : contextIdentifier.defaultValue;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ import { QpqContext } from 'quidproquo-core';
2
+ export declare const useQpqContextValues: () => QpqContext<any>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useQpqContextValues = void 0;
4
+ const react_1 = require("react");
5
+ const qpqReactContext_1 = require("./qpqReactContext");
6
+ const useQpqContextValues = () => {
7
+ return (0, react_1.useContext)(qpqReactContext_1.qpqReactContext);
8
+ };
9
+ exports.useQpqContextValues = useQpqContextValues;
10
+ //# sourceMappingURL=useQpqContextValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQpqContextValues.js","sourceRoot":"","sources":["../../../src/qpqContext/useQpqContextValues.ts"],"names":[],"mappings":";;;AAEA,iCAAmC;AAEnC,uDAAoD;AAE7C,MAAM,mBAAmB,GAAG,GAAoB,EAAE;IACvD,OAAO,IAAA,kBAAU,EAAC,iCAAe,CAAC,CAAC;AACrC,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B","sourcesContent":["import { QpqContext } from 'quidproquo-core';\n\nimport { useContext } from 'react';\n\nimport { qpqReactContext } from './qpqReactContext';\n\nexport const useQpqContextValues = (): QpqContext<any> => {\n return useContext(qpqReactContext);\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import { ActionProcessorListResolver } from 'quidproquo-core';
2
+ import { Dispatch } from 'react';
3
+ export type ActionProcessorListResolverFactory<TState = any> = (dispatch: Dispatch<any>, getCurrentState: () => TState) => ActionProcessorListResolver;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ActionProcessorListResolverFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionProcessorListResolverFactory.js","sourceRoot":"","sources":["../../../src/runtime/ActionProcessorListResolverFactory.ts"],"names":[],"mappings":"","sourcesContent":["import { ActionProcessorListResolver } from 'quidproquo-core';\n\nimport { Dispatch } from 'react';\n\nexport type ActionProcessorListResolverFactory<TState = any> = (\n dispatch: Dispatch<any>,\n getCurrentState: () => TState,\n) => ActionProcessorListResolver;\n"]}
@@ -0,0 +1 @@
1
+ export declare const BubbleReducerDispatchContext: import("react").Context<(action: any) => void>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BubbleReducerDispatchContext = void 0;
4
+ const react_1 = require("react");
5
+ // Default NOOP dispatcher: an action that bubbles past the root is dropped.
6
+ exports.BubbleReducerDispatchContext = (0, react_1.createContext)((_action) => {
7
+ // NOOP
8
+ });
9
+ //# sourceMappingURL=BubbleReducerDispatchContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BubbleReducerDispatchContext.js","sourceRoot":"","sources":["../../../src/runtime/BubbleReducerDispatchContext.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AAEtC,4EAA4E;AAC/D,QAAA,4BAA4B,GAAG,IAAA,qBAAa,EAAwB,CAAC,OAAY,EAAQ,EAAE;IACtG,OAAO;AACT,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from 'react';\n\n// Default NOOP dispatcher: an action that bubbles past the root is dropped.\nexport const BubbleReducerDispatchContext = createContext<(action: any) => void>((_action: any): void => {\n // NOOP\n});\n"]}
@@ -0,0 +1 @@
1
+ export type QpqBubbleReducer<S, A> = (prevState: S, action: A) => [S, boolean];
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=QpqBubbleReducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QpqBubbleReducer.js","sourceRoot":"","sources":["../../../src/runtime/QpqBubbleReducer.ts"],"names":[],"mappings":"","sourcesContent":["// Reduces an action into [newState, handled]. Unhandled actions bubble up the\n// component tree to the nearest QpqRuntimeEffectCatcher.\nexport type QpqBubbleReducer<S, A> = (prevState: S, action: A) => [S, boolean];\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QpqMappedApi.js","sourceRoot":"","sources":["../../../src/runtime/QpqMappedApi.ts"],"names":[],"mappings":";;;AAiBO,MAAM,cAAc,GAAG,CAA6C,IAAW,EAAE,IAAW,EAAiB,EAAE;IACpH,uCAAY,IAAI,GAAK,IAAI,EAAG;AAC9B,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB","sourcesContent":["import { AskResponse, AskResponseReturnType, Story } from 'quidproquo-core';\n\n// Helper type to remap keys from \"askXyz\" to \"xyz\" (with lowercase first letter)\nexport type RemoveQpqAskPrefix<K extends string> = K extends `ask${infer R}` ? Uncapitalize<R> : never;\n\nexport type QpqApi = Record<`ask${string}`, Story<any, any>>;\n\n// Define the mapped API type.\n// We extract only string keys and then use a conditional type to infer parameters and return type.\nexport type QpqMappedApi<TApi extends QpqApi> = {\n [K in Extract<keyof TApi, string> as RemoveQpqAskPrefix<K>]: TApi[K] extends (...args: infer P) => infer R\n ? R extends AskResponse<any>\n ? (...args: P) => Promise<AskResponseReturnType<R>>\n : never\n : never;\n};\n\nexport const combineQpqApis = <TApiA extends QpqApi, TApiB extends QpqApi>(apiA: TApiA, apiB: TApiB): TApiA & TApiB => {\n return { ...apiA, ...apiB };\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';
3
+ type QpqRuntimeEffectCatcherProps = {
4
+ runtime: QpqRuntimeDefinition<any, any, any>;
5
+ name?: string;
6
+ children: ReactNode;
7
+ };
8
+ export declare const QpqRuntimeEffectCatcher: import("react").MemoExoticComponent<({ children, runtime, name }: QpqRuntimeEffectCatcherProps) => import("react").JSX.Element>;
9
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QpqRuntimeEffectCatcher = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const BubbleReducerDispatchContext_1 = require("./BubbleReducerDispatchContext");
7
+ const useQpqRuntime_1 = require("./useQpqRuntime");
8
+ const QpqRuntimeEffectCatcherComponent = ({ children, runtime, name }) => {
9
+ const [, , dispatch] = (0, useQpqRuntime_1.useQpqRuntime)(runtime, name);
10
+ return (0, jsx_runtime_1.jsx)(BubbleReducerDispatchContext_1.BubbleReducerDispatchContext.Provider, { value: dispatch, children: children });
11
+ };
12
+ exports.QpqRuntimeEffectCatcher = (0, react_1.memo)(QpqRuntimeEffectCatcherComponent);
13
+ //# sourceMappingURL=QpqRuntimeEffectCatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QpqRuntimeEffectCatcher.js","sourceRoot":"","sources":["../../../src/runtime/QpqRuntimeEffectCatcher.tsx"],"names":[],"mappings":";;;;AAAA,iCAAwC;AAExC,iFAA8E;AAE9E,mDAAgD;AAQhD,MAAM,gCAAgC,GAAG,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAgC,EAAE,EAAE;IACrG,MAAM,CAAC,EAAE,AAAD,EAAG,QAAQ,CAAC,GAAG,IAAA,6BAAa,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAEpD,OAAO,uBAAC,2DAA4B,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAyC,CAAC;AACpH,CAAC,CAAC;AAEW,QAAA,uBAAuB,GAAG,IAAA,YAAI,EAAC,gCAAgC,CAAC,CAAC","sourcesContent":["import { memo, ReactNode } from 'react';\n\nimport { BubbleReducerDispatchContext } from './BubbleReducerDispatchContext';\nimport { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';\nimport { useQpqRuntime } from './useQpqRuntime';\n\ntype QpqRuntimeEffectCatcherProps = {\n runtime: QpqRuntimeDefinition<any, any, any>;\n name?: string;\n children: ReactNode;\n};\n\nconst QpqRuntimeEffectCatcherComponent = ({ children, runtime, name }: QpqRuntimeEffectCatcherProps) => {\n const [, , dispatch] = useQpqRuntime(runtime, name);\n\n return <BubbleReducerDispatchContext.Provider value={dispatch}>{children}</BubbleReducerDispatchContext.Provider>;\n};\n\nexport const QpqRuntimeEffectCatcher = memo(QpqRuntimeEffectCatcherComponent);\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getStateDispatchActionProcessor.js","sourceRoot":"","sources":["../../../../src/runtime/actionProcessor/getStateDispatchActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAgJ;AAIhJ,MAAM,uBAAuB,GAC3B,CAAC,QAAuB,EAAqC,EAAE,CAC/D,KAAmB,EAAE,4CAAd,EAAE,MAAM,EAAE;IACf,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEjB,OAAO,IAAA,8BAAY,EAAC,SAAS,CAAC,CAAC;AACjC,CAAC,CAAA,CAAC;AAEG,MAAM,kCAAkC,GAC7C,CAAC,QAAuB,EAA+B,EAAE,CACzD,CAAO,UAAU,EAAE,oBAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QACzE,CAAC,iCAAe,CAAC,QAAQ,CAAC,EAAE,uBAAuB,CAAC,QAAQ,CAAC;KAC9D,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,kCAAkC,sCAI1C","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, actionResult, StateActionType, StateDispatchActionProcessor } from 'quidproquo-core';\n\nimport { Dispatch } from 'react';\n\nconst getProcessStateDispatch =\n (dispatch: Dispatch<any>): StateDispatchActionProcessor<any> =>\n async ({ action }) => {\n dispatch(action);\n\n return actionResult(undefined);\n };\n\nexport const getStateDispatchActionListResolver =\n (dispatch: Dispatch<any>): ActionProcessorListResolver =>\n async (_qpqConfig, _dynamicModuleLoader): Promise<ActionProcessorList> => ({\n [StateActionType.Dispatch]: getProcessStateDispatch(dispatch),\n });\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getStateReadActionProcessor.js","sourceRoot":"","sources":["../../../../src/runtime/actionProcessor/getStateReadActionProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA4I;AAE5I,MAAM,mBAAmB,GACvB,CAAQ,eAA4B,EAAiC,EAAE,CACvE,GAAS,EAAE;IACT,OAAO,IAAA,8BAAY,EAAC,eAAe,EAAE,CAAC,CAAC;AACzC,CAAC,CAAA,CAAC;AAEG,MAAM,8BAA8B,GACzC,CAAQ,eAA4B,EAA+B,EAAE,CACrE,CAAO,UAAU,EAAE,oBAAoB,EAAgC,EAAE;IAAC,OAAA,CAAC;QACzE,CAAC,iCAAe,CAAC,IAAI,CAAC,EAAE,mBAAmB,CAAC,eAAe,CAAC;KAC7D,CAAC,CAAA;EAAA,CAAC;AAJQ,QAAA,8BAA8B,kCAItC","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, actionResult, StateActionType, StateReadActionProcessor } from 'quidproquo-core';\n\nconst getProcessStateRead =\n <State>(getCurrentState: () => State): StateReadActionProcessor<any> =>\n async () => {\n return actionResult(getCurrentState());\n };\n\nexport const getStateReadActionListResolver =\n <State>(getCurrentState: () => State): ActionProcessorListResolver =>\n async (_qpqConfig, _dynamicModuleLoader): Promise<ActionProcessorList> => ({\n [StateActionType.Read]: getProcessStateRead(getCurrentState),\n });\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/runtime/actionProcessor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,uFAAuF;AACvF,+EAA+E;AAExE,MAAM,uBAAuB,GAClC,CAAQ,QAAuB,EAAE,eAA4B,EAA+B,EAAE,CAC9F,CAAO,SAAoB,EAAE,mBAAwC,EAAgC,EAAE;IAAC,OAAA,iCACnG,CAAC,MAAM,IAAA,oEAAkC,EAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,GACpF,CAAC,MAAM,IAAA,4DAA8B,EAAC,eAAe,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,EAC1F,CAAA;EAAA,CAAC;AALQ,QAAA,uBAAuB,2BAK/B","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nimport { Dispatch } from 'react';\n\nimport { getStateDispatchActionListResolver } from './getStateDispatchActionProcessor';\nimport { getStateReadActionListResolver } from './getStateReadActionProcessor';\n\nexport const getStateActionProcessor =\n <State>(dispatch: Dispatch<any>, getCurrentState: () => State): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig, dynamicModuleLoader: DynamicModuleLoader): Promise<ActionProcessorList> => ({\n ...(await getStateDispatchActionListResolver(dispatch)(qpqConfig, dynamicModuleLoader)),\n ...(await getStateReadActionListResolver(getCurrentState)(qpqConfig, dynamicModuleLoader)),\n });\n"]}
@@ -0,0 +1,7 @@
1
+ import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';
2
+ import { QpqApi } from './QpqMappedApi';
3
+ export type QpqRuntimeComputed<TState, TSlice> = {
4
+ definition: QpqRuntimeDefinition<TState, any, any>;
5
+ compute: (state: TState) => TSlice;
6
+ };
7
+ export declare function createQpqRuntimeComputed<TState, TAction, TApi extends QpqApi, TSlice>(definition: QpqRuntimeDefinition<TState, TAction, TApi>, compute: (state: TState) => TSlice): QpqRuntimeComputed<TState, TSlice>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createQpqRuntimeComputed = createQpqRuntimeComputed;
4
+ function createQpqRuntimeComputed(definition, compute) {
5
+ return { definition, compute };
6
+ }
7
+ //# sourceMappingURL=createQpqRuntimeComputed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createQpqRuntimeComputed.js","sourceRoot":"","sources":["../../../src/runtime/createQpqRuntimeComputed.ts"],"names":[],"mappings":";;AAQA,4DAKC;AALD,SAAgB,wBAAwB,CACtC,UAAuD,EACvD,OAAkC;IAElC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';\nimport { QpqApi } from './QpqMappedApi';\n\nexport type QpqRuntimeComputed<TState, TSlice> = {\n definition: QpqRuntimeDefinition<TState, any, any>;\n compute: (state: TState) => TSlice;\n};\n\nexport function createQpqRuntimeComputed<TState, TAction, TApi extends QpqApi, TSlice>(\n definition: QpqRuntimeDefinition<TState, TAction, TApi>,\n compute: (state: TState) => TSlice,\n): QpqRuntimeComputed<TState, TSlice> {\n return { definition, compute };\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { Story } from 'quidproquo-core';
2
+ import { ActionProcessorListResolverFactory } from './ActionProcessorListResolverFactory';
3
+ import { QpqBubbleReducer } from './QpqBubbleReducer';
4
+ import { QpqApi } from './QpqMappedApi';
5
+ export type QpqRuntimeDefinition<TState, TAction, TApi extends QpqApi> = {
6
+ uniqueName: string;
7
+ api: TApi;
8
+ initialState: TState;
9
+ reducer: QpqBubbleReducer<TState, TAction>;
10
+ onInit?: Story<any, any>;
11
+ getActionProcessors?: ActionProcessorListResolverFactory<TState>;
12
+ };
13
+ export type QpqRuntimeDefinitionOptions<TState, TAction, TApi extends QpqApi> = Omit<QpqRuntimeDefinition<TState, TAction, TApi>, 'reducer'> & {
14
+ reducer?: QpqBubbleReducer<TState, TAction>;
15
+ };
16
+ export declare function createQpqRuntimeDefinition<TState, TAction, TApi extends QpqApi>(options: QpqRuntimeDefinitionOptions<TState, TAction, TApi>): QpqRuntimeDefinition<TState, TAction, TApi>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createQpqRuntimeDefinition = createQpqRuntimeDefinition;
4
+ // Everything bubbles when no reducer is given, so a definition can exist just
5
+ // to name an area and expose an api.
6
+ const bubbleEverythingReducer = (state, _action) => [state, false];
7
+ function createQpqRuntimeDefinition(options) {
8
+ return Object.assign({ reducer: bubbleEverythingReducer }, options);
9
+ }
10
+ //# sourceMappingURL=createQpqRuntimeDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createQpqRuntimeDefinition.js","sourceRoot":"","sources":["../../../src/runtime/createQpqRuntimeDefinition.ts"],"names":[],"mappings":";;AAgCA,gEAOC;AAXD,8EAA8E;AAC9E,qCAAqC;AACrC,MAAM,uBAAuB,GAAG,CAAkB,KAAa,EAAE,OAAgB,EAAqB,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAExH,SAAgB,0BAA0B,CACxC,OAA2D;IAE3D,uBACE,OAAO,EAAE,uBAAuB,IAC7B,OAAO,EACV;AACJ,CAAC","sourcesContent":["import { Story } from 'quidproquo-core';\n\nimport { ActionProcessorListResolverFactory } from './ActionProcessorListResolverFactory';\nimport { QpqBubbleReducer } from './QpqBubbleReducer';\nimport { QpqApi } from './QpqMappedApi';\n\nexport type QpqRuntimeDefinition<TState, TAction, TApi extends QpqApi> = {\n // Area key prefix in the qpq store. Names are the sharing contract:\n // federated modules that bind the same name share the same state, so\n // namespace it to your app ('qpq/admin/auth', 'shell/tabLayout').\n uniqueName: string;\n api: TApi;\n initialState: TState;\n reducer: QpqBubbleReducer<TState, TAction>;\n\n // Runs once per area, on the first bind (count 0 -> 1), never on later binds.\n onInit?: Story<any, any>;\n\n // Extra processors every binder of this runtime gets. Processors the onInit\n // story needs belong here, not on the hook: React fires child effects before\n // parent ones, so any binder in the tree can be the one that runs onInit.\n getActionProcessors?: ActionProcessorListResolverFactory<TState>;\n};\n\nexport type QpqRuntimeDefinitionOptions<TState, TAction, TApi extends QpqApi> = Omit<QpqRuntimeDefinition<TState, TAction, TApi>, 'reducer'> & {\n reducer?: QpqBubbleReducer<TState, TAction>;\n};\n\n// Everything bubbles when no reducer is given, so a definition can exist just\n// to name an area and expose an api.\nconst bubbleEverythingReducer = <TState, TAction>(state: TState, _action: TAction): [TState, boolean] => [state, false];\n\nexport function createQpqRuntimeDefinition<TState, TAction, TApi extends QpqApi>(\n options: QpqRuntimeDefinitionOptions<TState, TAction, TApi>,\n): QpqRuntimeDefinition<TState, TAction, TApi> {\n return {\n reducer: bubbleEverythingReducer,\n ...options,\n };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';
2
+ import { QpqApi } from './QpqMappedApi';
3
+ export declare const getQpqRuntimeAreaKey: <TState, TAction, TApi extends QpqApi>(definition: QpqRuntimeDefinition<TState, TAction, TApi>, instanceName?: string) => string;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getQpqRuntimeAreaKey = void 0;
4
+ const getQpqRuntimeAreaKey = (definition, instanceName) => (instanceName ? `${definition.uniqueName}:${instanceName}` : definition.uniqueName);
5
+ exports.getQpqRuntimeAreaKey = getQpqRuntimeAreaKey;
6
+ //# sourceMappingURL=getQpqRuntimeAreaKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getQpqRuntimeAreaKey.js","sourceRoot":"","sources":["../../../src/runtime/getQpqRuntimeAreaKey.ts"],"names":[],"mappings":";;;AAGO,MAAM,oBAAoB,GAAG,CAClC,UAAuD,EACvD,YAAqB,EACb,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,UAAU,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAHpF,QAAA,oBAAoB,wBAGgE","sourcesContent":["import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';\nimport { QpqApi } from './QpqMappedApi';\n\nexport const getQpqRuntimeAreaKey = <TState, TAction, TApi extends QpqApi>(\n definition: QpqRuntimeDefinition<TState, TAction, TApi>,\n instanceName?: string,\n): string => (instanceName ? `${definition.uniqueName}:${instanceName}` : definition.uniqueName);\n"]}
@@ -0,0 +1,12 @@
1
+ export * from './actionProcessor';
2
+ export * from './ActionProcessorListResolverFactory';
3
+ export * from './BubbleReducerDispatchContext';
4
+ export * from './createQpqRuntimeComputed';
5
+ export * from './createQpqRuntimeDefinition';
6
+ export * from './getQpqRuntimeAreaKey';
7
+ export * from './QpqBubbleReducer';
8
+ export * from './QpqMappedApi';
9
+ export * from './QpqRuntimeEffectCatcher';
10
+ export * from './useBubbleReducer';
11
+ export * from './useQpqRuntime';
12
+ export * from './useQpqRuntimeComputed';
@@ -15,11 +15,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./actionProcessor"), exports);
18
- __exportStar(require("./bubbleReducer"), exports);
18
+ __exportStar(require("./ActionProcessorListResolverFactory"), exports);
19
+ __exportStar(require("./BubbleReducerDispatchContext"), exports);
20
+ __exportStar(require("./createQpqRuntimeComputed"), exports);
19
21
  __exportStar(require("./createQpqRuntimeDefinition"), exports);
20
- __exportStar(require("./QpqContextProvider"), exports);
22
+ __exportStar(require("./getQpqRuntimeAreaKey"), exports);
23
+ __exportStar(require("./QpqBubbleReducer"), exports);
21
24
  __exportStar(require("./QpqMappedApi"), exports);
22
25
  __exportStar(require("./QpqRuntimeEffectCatcher"), exports);
23
26
  __exportStar(require("./useBubbleReducer"), exports);
24
27
  __exportStar(require("./useQpqRuntime"), exports);
28
+ __exportStar(require("./useQpqRuntimeComputed"), exports);
25
29
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,uEAAqD;AACrD,iEAA+C;AAC/C,6DAA2C;AAC3C,+DAA6C;AAC7C,yDAAuC;AACvC,qDAAmC;AACnC,iDAA+B;AAC/B,4DAA0C;AAC1C,qDAAmC;AACnC,kDAAgC;AAChC,0DAAwC","sourcesContent":["export * from './actionProcessor';\nexport * from './ActionProcessorListResolverFactory';\nexport * from './BubbleReducerDispatchContext';\nexport * from './createQpqRuntimeComputed';\nexport * from './createQpqRuntimeDefinition';\nexport * from './getQpqRuntimeAreaKey';\nexport * from './QpqBubbleReducer';\nexport * from './QpqMappedApi';\nexport * from './QpqRuntimeEffectCatcher';\nexport * from './useBubbleReducer';\nexport * from './useQpqRuntime';\nexport * from './useQpqRuntimeComputed';\n"]}
@@ -1,2 +1,2 @@
1
- import { QpqBubbleReducer } from './bubbleReducer';
1
+ import { QpqBubbleReducer } from './QpqBubbleReducer';
2
2
  export declare const useBubbleReducer: <TState>(reducer: QpqBubbleReducer<TState, any>, initialState: TState | (() => TState)) => [TState, (action: unknown) => void];
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useBubbleReducer = void 0;
4
4
  const react_1 = require("react");
5
- const bubbleReducer_1 = require("./bubbleReducer");
5
+ const BubbleReducerDispatchContext_1 = require("./BubbleReducerDispatchContext");
6
6
  const useBubbleReducer = (reducer, initialState) => {
7
- const parentDispatch = (0, react_1.useContext)(bubbleReducer_1.BubbleReducerDispatchContext);
7
+ const parentDispatch = (0, react_1.useContext)(BubbleReducerDispatchContext_1.BubbleReducerDispatchContext);
8
8
  const [state, setState] = (0, react_1.useState)(initialState);
9
9
  const stateRef = (0, react_1.useRef)(state);
10
10
  stateRef.current = state;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBubbleReducer.js","sourceRoot":"","sources":["../../../src/runtime/useBubbleReducer.ts"],"names":[],"mappings":";;;AAAA,iCAAkE;AAElE,iFAA8E;AAGvE,MAAM,gBAAgB,GAAG,CAC9B,OAAsC,EACtC,YAAqC,EACA,EAAE;IACvC,MAAM,cAAc,GAAG,IAAA,kBAAU,EAAC,2DAA4B,CAAC,CAAC;IAChE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,YAAY,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;IAC/B,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;IAEzB,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAC1B,CAAC,MAAe,EAAE,EAAE;QAClB,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAEpE,IAAI,aAAa,EAAE,CAAC;YAClB,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,EACD,CAAC,cAAc,EAAE,OAAO,CAAC,CAC1B,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC,CAAC;AAvBW,QAAA,gBAAgB,oBAuB3B","sourcesContent":["import { useCallback, useContext, useRef, useState } from 'react';\n\nimport { BubbleReducerDispatchContext } from './BubbleReducerDispatchContext';\nimport { QpqBubbleReducer } from './QpqBubbleReducer';\n\nexport const useBubbleReducer = <TState>(\n reducer: QpqBubbleReducer<TState, any>,\n initialState: TState | (() => TState),\n): [TState, (action: unknown) => void] => {\n const parentDispatch = useContext(BubbleReducerDispatchContext);\n const [state, setState] = useState(initialState);\n const stateRef = useRef(state);\n stateRef.current = state;\n\n const dispatch = useCallback(\n (action: unknown) => {\n const [newState, preventBubble] = reducer(stateRef.current, action);\n\n if (preventBubble) {\n setState(newState);\n } else {\n parentDispatch(action);\n }\n },\n [parentDispatch, reducer],\n );\n\n return [state, dispatch];\n};\n"]}
@@ -0,0 +1,11 @@
1
+ import { StoryResolver } from 'quidproquo-core';
2
+ import { ActionProcessorListResolverFactory } from './ActionProcessorListResolverFactory';
3
+ import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';
4
+ import { QpqApi } from './QpqMappedApi';
5
+ export type QpqAreaBinding<TState, TAction> = {
6
+ subscribe: (listener: () => void) => () => void;
7
+ getCurrentState: () => TState;
8
+ dispatch: (action: TAction) => void;
9
+ resolver: StoryResolver;
10
+ };
11
+ export declare function useQpqAreaBinding<TState, TAction, TApi extends QpqApi>(definition: QpqRuntimeDefinition<TState, TAction, TApi>, instanceName?: string, getActionProcessors?: ActionProcessorListResolverFactory<TState>): QpqAreaBinding<TState, TAction>;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.useQpqAreaBinding = useQpqAreaBinding;
13
+ const react_1 = require("react");
14
+ const useEffectCallback_1 = require("../hooks/useEffectCallback");
15
+ const useQpq_1 = require("../hooks/useQpq");
16
+ const useQpqStore_1 = require("../store/useQpqStore");
17
+ const actionProcessor_1 = require("./actionProcessor");
18
+ const BubbleReducerDispatchContext_1 = require("./BubbleReducerDispatchContext");
19
+ const getQpqRuntimeAreaKey_1 = require("./getQpqRuntimeAreaKey");
20
+ // Shared by every hook that reads an area (full runtime and selectors alike):
21
+ // all readers refcount the area and any of them can be the first bind that
22
+ // seeds initial state and runs onInit.
23
+ function useQpqAreaBinding(definition, instanceName, getActionProcessors) {
24
+ const store = (0, useQpqStore_1.useQpqStore)();
25
+ const areaKey = (0, getQpqRuntimeAreaKey_1.getQpqRuntimeAreaKey)(definition, instanceName);
26
+ // Before the bind effect fires (or after a late unbind) the area does not
27
+ // exist yet; render against the definition's initial state.
28
+ const getCurrentState = (0, useEffectCallback_1.useEffectCallback)(() => store.hasArea(areaKey) ? store.getAreaState(areaKey) : definition.initialState);
29
+ const parentDispatch = (0, react_1.useContext)(BubbleReducerDispatchContext_1.BubbleReducerDispatchContext);
30
+ // Reduce with the module's reducer; handled effects publish the new state to
31
+ // the store, unhandled ones bubble up the component tree.
32
+ const dispatchThroughReducer = (action) => {
33
+ const [newState, handled] = definition.reducer(getCurrentState(), action);
34
+ if (handled) {
35
+ store.setAreaState(areaKey, newState);
36
+ }
37
+ else {
38
+ parentDispatch(action);
39
+ }
40
+ };
41
+ const dispatch = (0, useEffectCallback_1.useEffectCallback)(dispatchThroughReducer);
42
+ // State processors always; then the definition's processors (needed by
43
+ // onInit regardless of which binder runs it); then per-binding extras.
44
+ const mergedProcessors = (qpqConfig, dynamicModuleLoader) => __awaiter(this, void 0, void 0, function* () {
45
+ var _a;
46
+ const resolvers = [
47
+ (0, actionProcessor_1.getStateActionProcessor)(dispatch, getCurrentState),
48
+ (_a = definition.getActionProcessors) === null || _a === void 0 ? void 0 : _a.call(definition, dispatch, getCurrentState),
49
+ getActionProcessors === null || getActionProcessors === void 0 ? void 0 : getActionProcessors(dispatch, getCurrentState),
50
+ ];
51
+ let processors = {};
52
+ for (const resolver of resolvers) {
53
+ if (resolver) {
54
+ processors = Object.assign(Object.assign({}, processors), (yield resolver(qpqConfig, dynamicModuleLoader)));
55
+ }
56
+ }
57
+ return processors;
58
+ });
59
+ const resolver = (0, useQpq_1.useQpq)(mergedProcessors);
60
+ const runInitStory = (0, useEffectCallback_1.useEffectCallback)(() => {
61
+ if (definition.onInit) {
62
+ resolver(definition.onInit)();
63
+ }
64
+ });
65
+ // Identity must change with the area so useSyncExternalStore resubscribes.
66
+ const subscribe = (0, react_1.useCallback)((listener) => store.subscribe(areaKey, listener), [store, areaKey]);
67
+ (0, react_1.useEffect)(() => {
68
+ const isFirstBind = store.bindArea(areaKey, definition.initialState);
69
+ // A frozen store means devtools time travel: components popping in while
70
+ // scrubbing must render the restored moment, not fetch the present.
71
+ if (isFirstBind && !store.isFrozen()) {
72
+ runInitStory();
73
+ }
74
+ return () => store.unbindArea(areaKey);
75
+ // Rebind only when the target area changes; resolver or definition
76
+ // identity churn must not unbind (and wipe) live state.
77
+ // eslint-disable-next-line react-hooks/exhaustive-deps
78
+ }, [store, areaKey]);
79
+ return { subscribe, getCurrentState, dispatch, resolver };
80
+ }
81
+ //# sourceMappingURL=useQpqAreaBinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQpqAreaBinding.js","sourceRoot":"","sources":["../../../src/runtime/useQpqAreaBinding.ts"],"names":[],"mappings":"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","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, StoryResolver } from 'quidproquo-core';\n\nimport { useCallback, useContext, useEffect } from 'react';\n\nimport { useEffectCallback } from '../hooks/useEffectCallback';\nimport { useQpq } from '../hooks/useQpq';\nimport { useQpqStore } from '../store/useQpqStore';\nimport { getStateActionProcessor } from './actionProcessor';\nimport { ActionProcessorListResolverFactory } from './ActionProcessorListResolverFactory';\nimport { BubbleReducerDispatchContext } from './BubbleReducerDispatchContext';\nimport { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';\nimport { getQpqRuntimeAreaKey } from './getQpqRuntimeAreaKey';\nimport { QpqApi } from './QpqMappedApi';\n\nexport type QpqAreaBinding<TState, TAction> = {\n subscribe: (listener: () => void) => () => void;\n getCurrentState: () => TState;\n dispatch: (action: TAction) => void;\n resolver: StoryResolver;\n};\n\n// Shared by every hook that reads an area (full runtime and selectors alike):\n// all readers refcount the area and any of them can be the first bind that\n// seeds initial state and runs onInit.\nexport function useQpqAreaBinding<TState, TAction, TApi extends QpqApi>(\n definition: QpqRuntimeDefinition<TState, TAction, TApi>,\n instanceName?: string,\n getActionProcessors?: ActionProcessorListResolverFactory<TState>,\n): QpqAreaBinding<TState, TAction> {\n const store = useQpqStore();\n const areaKey = getQpqRuntimeAreaKey(definition, instanceName);\n\n // Before the bind effect fires (or after a late unbind) the area does not\n // exist yet; render against the definition's initial state.\n const getCurrentState = useEffectCallback((): TState =>\n store.hasArea(areaKey) ? (store.getAreaState(areaKey) as TState) : definition.initialState,\n );\n\n const parentDispatch = useContext(BubbleReducerDispatchContext);\n\n // Reduce with the module's reducer; handled effects publish the new state to\n // the store, unhandled ones bubble up the component tree.\n const dispatchThroughReducer = (action: TAction): void => {\n const [newState, handled] = definition.reducer(getCurrentState(), action);\n\n if (handled) {\n store.setAreaState(areaKey, newState);\n } else {\n parentDispatch(action);\n }\n };\n const dispatch = useEffectCallback(dispatchThroughReducer);\n\n // State processors always; then the definition's processors (needed by\n // onInit regardless of which binder runs it); then per-binding extras.\n const mergedProcessors: ActionProcessorListResolver = async (qpqConfig, dynamicModuleLoader) => {\n const resolvers = [\n getStateActionProcessor(dispatch, getCurrentState),\n definition.getActionProcessors?.(dispatch, getCurrentState),\n getActionProcessors?.(dispatch, getCurrentState),\n ];\n\n let processors: ActionProcessorList = {};\n for (const resolver of resolvers) {\n if (resolver) {\n processors = { ...processors, ...(await resolver(qpqConfig, dynamicModuleLoader)) };\n }\n }\n\n return processors;\n };\n\n const resolver = useQpq(mergedProcessors);\n\n const runInitStory = useEffectCallback(() => {\n if (definition.onInit) {\n resolver(definition.onInit)();\n }\n });\n\n // Identity must change with the area so useSyncExternalStore resubscribes.\n const subscribe = useCallback((listener: () => void) => store.subscribe(areaKey, listener), [store, areaKey]);\n\n useEffect(() => {\n const isFirstBind = store.bindArea(areaKey, definition.initialState);\n\n // A frozen store means devtools time travel: components popping in while\n // scrubbing must render the restored moment, not fetch the present.\n if (isFirstBind && !store.isFrozen()) {\n runInitStory();\n }\n\n return () => store.unbindArea(areaKey);\n // Rebind only when the target area changes; resolver or definition\n // identity churn must not unbind (and wipe) live state.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [store, areaKey]);\n\n return { subscribe, getCurrentState, dispatch, resolver };\n}\n"]}