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.
- package/lib/commonjs/hooks/index.d.ts +0 -1
- package/lib/commonjs/hooks/index.js +0 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useQpq.js +2 -2
- package/lib/commonjs/hooks/useQpq.js.map +1 -1
- package/lib/commonjs/index.d.ts +3 -0
- package/lib/commonjs/index.js +3 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/{hooks/asmj → qpqContext}/QpqContextProvider.d.ts +3 -5
- package/lib/commonjs/qpqContext/QpqContextProvider.js +16 -0
- package/lib/commonjs/qpqContext/QpqContextProvider.js.map +1 -0
- package/lib/commonjs/qpqContext/index.d.ts +3 -0
- package/lib/commonjs/qpqContext/index.js +20 -0
- package/lib/commonjs/qpqContext/index.js.map +1 -0
- package/lib/commonjs/qpqContext/qpqReactContext.d.ts +2 -0
- package/lib/commonjs/qpqContext/qpqReactContext.js +6 -0
- package/lib/commonjs/qpqContext/qpqReactContext.js.map +1 -0
- package/lib/commonjs/qpqContext/useQpqContextValue.d.ts +2 -0
- package/lib/commonjs/qpqContext/useQpqContextValue.js +10 -0
- package/lib/commonjs/qpqContext/useQpqContextValue.js.map +1 -0
- package/lib/commonjs/qpqContext/useQpqContextValues.d.ts +2 -0
- package/lib/commonjs/qpqContext/useQpqContextValues.js +10 -0
- package/lib/commonjs/qpqContext/useQpqContextValues.js.map +1 -0
- package/lib/commonjs/runtime/ActionProcessorListResolverFactory.d.ts +3 -0
- package/lib/commonjs/runtime/ActionProcessorListResolverFactory.js +3 -0
- package/lib/commonjs/runtime/ActionProcessorListResolverFactory.js.map +1 -0
- package/lib/commonjs/runtime/BubbleReducerDispatchContext.d.ts +1 -0
- package/lib/commonjs/runtime/BubbleReducerDispatchContext.js +9 -0
- package/lib/commonjs/runtime/BubbleReducerDispatchContext.js.map +1 -0
- package/lib/commonjs/runtime/QpqBubbleReducer.d.ts +1 -0
- package/lib/commonjs/runtime/QpqBubbleReducer.js +3 -0
- package/lib/commonjs/runtime/QpqBubbleReducer.js.map +1 -0
- package/lib/commonjs/runtime/QpqMappedApi.js.map +1 -0
- package/lib/commonjs/runtime/QpqRuntimeEffectCatcher.d.ts +9 -0
- package/lib/commonjs/runtime/QpqRuntimeEffectCatcher.js +13 -0
- package/lib/commonjs/runtime/QpqRuntimeEffectCatcher.js.map +1 -0
- package/lib/commonjs/runtime/actionProcessor/getStateDispatchActionProcessor.js.map +1 -0
- package/lib/commonjs/runtime/actionProcessor/getStateReadActionProcessor.js.map +1 -0
- package/lib/commonjs/runtime/actionProcessor/index.js.map +1 -0
- package/lib/commonjs/runtime/createQpqRuntimeComputed.d.ts +7 -0
- package/lib/commonjs/runtime/createQpqRuntimeComputed.js +7 -0
- package/lib/commonjs/runtime/createQpqRuntimeComputed.js.map +1 -0
- package/lib/commonjs/runtime/createQpqRuntimeDefinition.d.ts +16 -0
- package/lib/commonjs/runtime/createQpqRuntimeDefinition.js +10 -0
- package/lib/commonjs/runtime/createQpqRuntimeDefinition.js.map +1 -0
- package/lib/commonjs/runtime/getQpqRuntimeAreaKey.d.ts +3 -0
- package/lib/commonjs/runtime/getQpqRuntimeAreaKey.js +6 -0
- package/lib/commonjs/runtime/getQpqRuntimeAreaKey.js.map +1 -0
- package/lib/commonjs/runtime/index.d.ts +12 -0
- package/lib/commonjs/{hooks/asmj → runtime}/index.js +6 -2
- package/lib/commonjs/runtime/index.js.map +1 -0
- package/lib/commonjs/{hooks/asmj → runtime}/useBubbleReducer.d.ts +1 -1
- package/lib/commonjs/{hooks/asmj → runtime}/useBubbleReducer.js +2 -2
- package/lib/commonjs/runtime/useBubbleReducer.js.map +1 -0
- package/lib/commonjs/runtime/useQpqAreaBinding.d.ts +11 -0
- package/lib/commonjs/runtime/useQpqAreaBinding.js +81 -0
- package/lib/commonjs/runtime/useQpqAreaBinding.js.map +1 -0
- package/lib/commonjs/runtime/useQpqRuntime.d.ts +4 -0
- package/lib/commonjs/runtime/useQpqRuntime.js +28 -0
- package/lib/commonjs/runtime/useQpqRuntime.js.map +1 -0
- package/lib/commonjs/runtime/useQpqRuntimeComputed.d.ts +2 -0
- package/lib/commonjs/runtime/useQpqRuntimeComputed.js +26 -0
- package/lib/commonjs/runtime/useQpqRuntimeComputed.js.map +1 -0
- package/lib/commonjs/store/QpqStoreProvider.d.ts +8 -0
- package/lib/commonjs/store/QpqStoreProvider.js +13 -0
- package/lib/commonjs/store/QpqStoreProvider.js.map +1 -0
- package/lib/commonjs/store/connectQpqStoreToReduxDevTools.d.ts +2 -0
- package/lib/commonjs/store/connectQpqStoreToReduxDevTools.js +144 -0
- package/lib/commonjs/store/connectQpqStoreToReduxDevTools.js.map +1 -0
- package/lib/commonjs/store/createQpqStore.d.ts +22 -0
- package/lib/commonjs/store/createQpqStore.js +160 -0
- package/lib/commonjs/store/createQpqStore.js.map +1 -0
- package/lib/commonjs/store/index.d.ts +5 -0
- package/lib/commonjs/store/index.js +22 -0
- package/lib/commonjs/store/index.js.map +1 -0
- package/lib/commonjs/store/qpqStoreContext.d.ts +3 -0
- package/lib/commonjs/store/qpqStoreContext.js +6 -0
- package/lib/commonjs/store/qpqStoreContext.js.map +1 -0
- package/lib/commonjs/store/useQpqStore.d.ts +2 -0
- package/lib/commonjs/store/useQpqStore.js +14 -0
- package/lib/commonjs/store/useQpqStore.js.map +1 -0
- package/lib/commonjs/useFieldBinding/useFieldBinding.d.ts +1 -1
- package/lib/commonjs/useFieldBinding/useFieldBinding.js +2 -2
- package/lib/commonjs/useFieldBinding/useFieldBinding.js.map +1 -1
- package/lib/commonjs/useSharedQueryParams/sharedQueryParamsRuntime.d.ts +1 -1
- package/lib/commonjs/useSharedQueryParams/sharedQueryParamsRuntime.js +7 -2
- package/lib/commonjs/useSharedQueryParams/sharedQueryParamsRuntime.js.map +1 -1
- package/lib/commonjs/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.d.ts +4 -5
- package/lib/commonjs/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.js +3 -3
- package/lib/commonjs/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.js.map +1 -1
- package/lib/commonjs/webSocketQueue/hooks/useWebsocketQueueSendEvent.js +8 -1
- package/lib/commonjs/webSocketQueue/hooks/useWebsocketQueueSendEvent.js.map +1 -1
- package/lib/esm/hooks/index.d.ts +0 -1
- package/lib/esm/hooks/index.js +0 -1
- package/lib/esm/hooks/index.js.map +1 -1
- package/lib/esm/hooks/useQpq.js +1 -1
- package/lib/esm/hooks/useQpq.js.map +1 -1
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/{hooks/asmj → qpqContext}/QpqContextProvider.d.ts +3 -5
- package/lib/esm/{hooks/asmj → qpqContext}/QpqContextProvider.js +2 -10
- package/lib/esm/qpqContext/QpqContextProvider.js.map +1 -0
- package/lib/esm/qpqContext/index.d.ts +3 -0
- package/lib/esm/qpqContext/index.js +4 -0
- package/lib/esm/qpqContext/index.js.map +1 -0
- package/lib/esm/qpqContext/qpqReactContext.d.ts +2 -0
- package/lib/esm/qpqContext/qpqReactContext.js +3 -0
- package/lib/esm/qpqContext/qpqReactContext.js.map +1 -0
- package/lib/esm/qpqContext/useQpqContextValue.d.ts +2 -0
- package/lib/esm/qpqContext/useQpqContextValue.js +6 -0
- package/lib/esm/qpqContext/useQpqContextValue.js.map +1 -0
- package/lib/esm/qpqContext/useQpqContextValues.d.ts +2 -0
- package/lib/esm/qpqContext/useQpqContextValues.js +6 -0
- package/lib/esm/qpqContext/useQpqContextValues.js.map +1 -0
- package/lib/esm/runtime/ActionProcessorListResolverFactory.d.ts +3 -0
- package/lib/esm/runtime/ActionProcessorListResolverFactory.js +2 -0
- package/lib/esm/runtime/ActionProcessorListResolverFactory.js.map +1 -0
- package/lib/esm/runtime/BubbleReducerDispatchContext.d.ts +1 -0
- package/lib/esm/runtime/BubbleReducerDispatchContext.js +6 -0
- package/lib/esm/runtime/BubbleReducerDispatchContext.js.map +1 -0
- package/lib/esm/runtime/QpqBubbleReducer.d.ts +1 -0
- package/lib/esm/runtime/QpqBubbleReducer.js +2 -0
- package/lib/esm/runtime/QpqBubbleReducer.js.map +1 -0
- package/lib/esm/runtime/QpqMappedApi.js.map +1 -0
- package/lib/esm/runtime/QpqRuntimeEffectCatcher.d.ts +9 -0
- package/lib/esm/{hooks/asmj → runtime}/QpqRuntimeEffectCatcher.js +3 -3
- package/lib/esm/runtime/QpqRuntimeEffectCatcher.js.map +1 -0
- package/lib/esm/runtime/actionProcessor/getStateDispatchActionProcessor.js.map +1 -0
- package/lib/esm/runtime/actionProcessor/getStateReadActionProcessor.js.map +1 -0
- package/lib/esm/runtime/actionProcessor/index.js.map +1 -0
- package/lib/esm/runtime/createQpqRuntimeComputed.d.ts +7 -0
- package/lib/esm/runtime/createQpqRuntimeComputed.js +4 -0
- package/lib/esm/runtime/createQpqRuntimeComputed.js.map +1 -0
- package/lib/esm/runtime/createQpqRuntimeDefinition.d.ts +16 -0
- package/lib/esm/runtime/createQpqRuntimeDefinition.js +10 -0
- package/lib/esm/runtime/createQpqRuntimeDefinition.js.map +1 -0
- package/lib/esm/runtime/getQpqRuntimeAreaKey.d.ts +3 -0
- package/lib/esm/runtime/getQpqRuntimeAreaKey.js +2 -0
- package/lib/esm/runtime/getQpqRuntimeAreaKey.js.map +1 -0
- package/lib/esm/runtime/index.d.ts +12 -0
- package/lib/esm/runtime/index.js +13 -0
- package/lib/esm/runtime/index.js.map +1 -0
- package/lib/esm/{hooks/asmj → runtime}/useBubbleReducer.d.ts +1 -1
- package/lib/esm/{hooks/asmj → runtime}/useBubbleReducer.js +1 -1
- package/lib/esm/runtime/useBubbleReducer.js.map +1 -0
- package/lib/esm/runtime/useQpqAreaBinding.d.ts +11 -0
- package/lib/esm/runtime/useQpqAreaBinding.js +68 -0
- package/lib/esm/runtime/useQpqAreaBinding.js.map +1 -0
- package/lib/esm/runtime/useQpqRuntime.d.ts +4 -0
- package/lib/esm/runtime/useQpqRuntime.js +25 -0
- package/lib/esm/runtime/useQpqRuntime.js.map +1 -0
- package/lib/esm/runtime/useQpqRuntimeComputed.d.ts +2 -0
- package/lib/esm/runtime/useQpqRuntimeComputed.js +23 -0
- package/lib/esm/runtime/useQpqRuntimeComputed.js.map +1 -0
- package/lib/esm/store/QpqStoreProvider.d.ts +8 -0
- package/lib/esm/store/QpqStoreProvider.js +9 -0
- package/lib/esm/store/QpqStoreProvider.js.map +1 -0
- package/lib/esm/store/connectQpqStoreToReduxDevTools.d.ts +2 -0
- package/lib/esm/store/connectQpqStoreToReduxDevTools.js +137 -0
- package/lib/esm/store/connectQpqStoreToReduxDevTools.js.map +1 -0
- package/lib/esm/store/createQpqStore.d.ts +22 -0
- package/lib/esm/store/createQpqStore.js +156 -0
- package/lib/esm/store/createQpqStore.js.map +1 -0
- package/lib/esm/store/index.d.ts +5 -0
- package/lib/esm/store/index.js +6 -0
- package/lib/esm/store/index.js.map +1 -0
- package/lib/esm/store/qpqStoreContext.d.ts +3 -0
- package/lib/esm/store/qpqStoreContext.js +3 -0
- package/lib/esm/store/qpqStoreContext.js.map +1 -0
- package/lib/esm/store/useQpqStore.d.ts +2 -0
- package/lib/esm/store/useQpqStore.js +10 -0
- package/lib/esm/store/useQpqStore.js.map +1 -0
- package/lib/esm/useFieldBinding/useFieldBinding.d.ts +1 -1
- package/lib/esm/useFieldBinding/useFieldBinding.js +1 -1
- package/lib/esm/useFieldBinding/useFieldBinding.js.map +1 -1
- package/lib/esm/useSharedQueryParams/sharedQueryParamsRuntime.d.ts +1 -1
- package/lib/esm/useSharedQueryParams/sharedQueryParamsRuntime.js +7 -2
- package/lib/esm/useSharedQueryParams/sharedQueryParamsRuntime.js.map +1 -1
- package/lib/esm/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.d.ts +4 -5
- package/lib/esm/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.js +3 -3
- package/lib/esm/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.js.map +1 -1
- package/lib/esm/webSocketQueue/hooks/useWebsocketQueueSendEvent.js +8 -1
- package/lib/esm/webSocketQueue/hooks/useWebsocketQueueSendEvent.js.map +1 -1
- package/package.json +8 -9
- package/lib/commonjs/hooks/asmj/QpqContextProvider.js +0 -26
- package/lib/commonjs/hooks/asmj/QpqContextProvider.js.map +0 -1
- package/lib/commonjs/hooks/asmj/QpqMappedApi.js.map +0 -1
- package/lib/commonjs/hooks/asmj/QpqRuntimeEffectCatcher.d.ts +0 -14
- package/lib/commonjs/hooks/asmj/QpqRuntimeEffectCatcher.js +0 -14
- package/lib/commonjs/hooks/asmj/QpqRuntimeEffectCatcher.js.map +0 -1
- package/lib/commonjs/hooks/asmj/actionProcessor/getStateDispatchActionProcessor.js.map +0 -1
- package/lib/commonjs/hooks/asmj/actionProcessor/getStateReadActionProcessor.js.map +0 -1
- package/lib/commonjs/hooks/asmj/actionProcessor/index.js.map +0 -1
- package/lib/commonjs/hooks/asmj/bubbleReducer.d.ts +0 -5
- package/lib/commonjs/hooks/asmj/bubbleReducer.js +0 -29
- package/lib/commonjs/hooks/asmj/bubbleReducer.js.map +0 -1
- package/lib/commonjs/hooks/asmj/createQpqRuntimeDefinition.d.ts +0 -22
- package/lib/commonjs/hooks/asmj/createQpqRuntimeDefinition.js +0 -53
- package/lib/commonjs/hooks/asmj/createQpqRuntimeDefinition.js.map +0 -1
- package/lib/commonjs/hooks/asmj/index.d.ts +0 -8
- package/lib/commonjs/hooks/asmj/index.js.map +0 -1
- package/lib/commonjs/hooks/asmj/useBubbleReducer.js.map +0 -1
- package/lib/commonjs/hooks/asmj/useQpqRuntime.d.ts +0 -6
- package/lib/commonjs/hooks/asmj/useQpqRuntime.js +0 -49
- package/lib/commonjs/hooks/asmj/useQpqRuntime.js.map +0 -1
- package/lib/esm/hooks/asmj/QpqContextProvider.js.map +0 -1
- package/lib/esm/hooks/asmj/QpqMappedApi.js.map +0 -1
- package/lib/esm/hooks/asmj/QpqRuntimeEffectCatcher.d.ts +0 -14
- package/lib/esm/hooks/asmj/QpqRuntimeEffectCatcher.js.map +0 -1
- package/lib/esm/hooks/asmj/actionProcessor/getStateDispatchActionProcessor.js.map +0 -1
- package/lib/esm/hooks/asmj/actionProcessor/getStateReadActionProcessor.js.map +0 -1
- package/lib/esm/hooks/asmj/actionProcessor/index.js.map +0 -1
- package/lib/esm/hooks/asmj/bubbleReducer.d.ts +0 -5
- package/lib/esm/hooks/asmj/bubbleReducer.js +0 -25
- package/lib/esm/hooks/asmj/bubbleReducer.js.map +0 -1
- package/lib/esm/hooks/asmj/createQpqRuntimeDefinition.d.ts +0 -22
- package/lib/esm/hooks/asmj/createQpqRuntimeDefinition.js +0 -47
- package/lib/esm/hooks/asmj/createQpqRuntimeDefinition.js.map +0 -1
- package/lib/esm/hooks/asmj/index.d.ts +0 -8
- package/lib/esm/hooks/asmj/index.js +0 -9
- package/lib/esm/hooks/asmj/index.js.map +0 -1
- package/lib/esm/hooks/asmj/useBubbleReducer.js.map +0 -1
- package/lib/esm/hooks/asmj/useQpqRuntime.d.ts +0 -6
- package/lib/esm/hooks/asmj/useQpqRuntime.js +0 -38
- package/lib/esm/hooks/asmj/useQpqRuntime.js.map +0 -1
- /package/lib/commonjs/{hooks/asmj → runtime}/QpqMappedApi.d.ts +0 -0
- /package/lib/commonjs/{hooks/asmj → runtime}/QpqMappedApi.js +0 -0
- /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.d.ts +0 -0
- /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.js +0 -0
- /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateReadActionProcessor.d.ts +0 -0
- /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateReadActionProcessor.js +0 -0
- /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/index.d.ts +0 -0
- /package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/index.js +0 -0
- /package/lib/esm/{hooks/asmj → runtime}/QpqMappedApi.d.ts +0 -0
- /package/lib/esm/{hooks/asmj → runtime}/QpqMappedApi.js +0 -0
- /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.d.ts +0 -0
- /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.js +0 -0
- /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/getStateReadActionProcessor.d.ts +0 -0
- /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/getStateReadActionProcessor.js +0 -0
- /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/index.d.ts +0 -0
- /package/lib/esm/{hooks/asmj → runtime}/actionProcessor/index.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldBinding.js","sourceRoot":"","sources":["../../../src/useFieldBinding/useFieldBinding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useFieldBinding.js","sourceRoot":"","sources":["../../../src/useFieldBinding/useFieldBinding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,YAA2C,EAC3C,UAA8C,EAC9C,cAAgD,EACP,EAAE;IAC3C,MAAM,aAAa,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAE1D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAI,aAAa,CAAC,CAAC;IAErD,MAAM,YAAY,GAAG,CAAC,KAAQ,EAAE,GAAG,IAAW,EAAE,EAAE;QAChD,MAAM,QAAQ,GAAM,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAE,KAAa,CAAC,MAAM,CAAC,KAAK,CAAC;QAClG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,uEAAuE;QACvE,0EAA0E;QAC1E,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC1B,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { QpqRuntimeComputed } from '../runtime/createQpqRuntimeComputed';\nimport { useQpqRuntimeComputed } from '../runtime/useQpqRuntimeComputed';\n\nexport const useFieldBinding = <TState, V, E = any>(\n computedAtom: QpqRuntimeComputed<TState, V>,\n someSetter: (value: V) => Promise<void> | void,\n valueExtractor?: (event: E, ...args: any[]) => V,\n): [V, (event: E, ...args: any[]) => void] => {\n const computedValue = useQpqRuntimeComputed(computedAtom);\n\n const [value, setValue] = useState<V>(computedValue);\n\n const handleChange = (event: E, ...args: any[]) => {\n const newValue: V = valueExtractor ? valueExtractor(event, ...args) : (event as any).target.value;\n setValue(newValue);\n someSetter(newValue);\n };\n\n useEffect(() => {\n // React bails out when the value is unchanged, so no equality guard is\n // needed — and local edits (which also change `value`) don't re-run this.\n setValue(computedValue);\n }, [computedValue]);\n\n return [value, handleChange];\n};\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const sharedQueryParamsRuntime: import("../
|
|
1
|
+
export declare const sharedQueryParamsRuntime: import("../runtime/createQpqRuntimeDefinition").QpqRuntimeDefinition<import("./logic").SharedQueryParamsState, import("./logic").SharedQueryParamsSetParamEffect, {
|
|
2
2
|
askSetParam: typeof import("./logic/runtime/askSetParam").askSetParam;
|
|
3
3
|
}>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { createQpqRuntimeDefinition } from '../
|
|
1
|
+
import { createQpqRuntimeDefinition } from '../runtime/createQpqRuntimeDefinition';
|
|
2
2
|
import { sharedQueryParamsLogic } from './logic/runtime';
|
|
3
3
|
import { sharedQueryParamsInitalState, sharedQueryParamsReducer } from './logic';
|
|
4
|
-
export const sharedQueryParamsRuntime = createQpqRuntimeDefinition(
|
|
4
|
+
export const sharedQueryParamsRuntime = createQpqRuntimeDefinition({
|
|
5
|
+
uniqueName: 'qpq/web-react/sharedQueryParams',
|
|
6
|
+
api: sharedQueryParamsLogic,
|
|
7
|
+
initialState: sharedQueryParamsInitalState,
|
|
8
|
+
reducer: sharedQueryParamsReducer,
|
|
9
|
+
});
|
|
5
10
|
//# sourceMappingURL=sharedQueryParamsRuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedQueryParamsRuntime.js","sourceRoot":"","sources":["../../../src/useSharedQueryParams/sharedQueryParamsRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sharedQueryParamsRuntime.js","sourceRoot":"","sources":["../../../src/useSharedQueryParams/sharedQueryParamsRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEjF,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;IACjE,UAAU,EAAE,iCAAiC;IAC7C,GAAG,EAAE,sBAAsB;IAC3B,YAAY,EAAE,4BAA4B;IAC1C,OAAO,EAAE,wBAAwB;CAClC,CAAC,CAAC","sourcesContent":["import { createQpqRuntimeDefinition } from '../runtime/createQpqRuntimeDefinition';\nimport { sharedQueryParamsLogic } from './logic/runtime';\nimport { sharedQueryParamsInitalState, sharedQueryParamsReducer } from './logic';\n\nexport const sharedQueryParamsRuntime = createQpqRuntimeDefinition({\n uniqueName: 'qpq/web-react/sharedQueryParams',\n api: sharedQueryParamsLogic,\n initialState: sharedQueryParamsInitalState,\n reducer: sharedQueryParamsReducer,\n});\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Story } from 'quidproquo-core';
|
|
2
1
|
import { AnyWebSocketQueueEventMessageWithCorrelation } from 'quidproquo-features';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export declare function useQpqWebsocketQueueRuntime<TState, TAction, TApi extends QpqApi>(
|
|
2
|
+
import { ActionProcessorListResolverFactory } from '../../runtime/ActionProcessorListResolverFactory';
|
|
3
|
+
import { QpqRuntimeDefinition } from '../../runtime/createQpqRuntimeDefinition';
|
|
4
|
+
import { QpqApi, QpqMappedApi } from '../../runtime/QpqMappedApi';
|
|
5
|
+
export declare function useQpqWebsocketQueueRuntime<TState, TAction, TApi extends QpqApi>(definition: QpqRuntimeDefinition<TState, TAction, TApi>, instanceName?: string, getActionProcessors?: ActionProcessorListResolverFactory<TState>): [QpqMappedApi<TApi>, TState, (action: any) => void, (event: Omit<AnyWebSocketQueueEventMessageWithCorrelation, 'correlationId'>) => Promise<any>];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WebSocketQueueServerMessageEventType } from 'quidproquo-features';
|
|
2
2
|
import { useRef } from 'react';
|
|
3
|
-
import { useQpqRuntime } from '../../
|
|
3
|
+
import { useQpqRuntime } from '../../runtime/useQpqRuntime';
|
|
4
4
|
import { getServiceRequestActionProcessor } from './actionProcessor/getServiceRequestActionProcessor';
|
|
5
5
|
import { useWebsocketQueueSendEvent } from './useWebsocketQueueSendEvent';
|
|
6
|
-
export function useQpqWebsocketQueueRuntime(
|
|
6
|
+
export function useQpqWebsocketQueueRuntime(definition, instanceName, getActionProcessors) {
|
|
7
7
|
const sendEventRef = useRef(null);
|
|
8
8
|
const mergedFactory = (dispatch, getCurrentState) => {
|
|
9
9
|
const serviceResolver = async () => getServiceRequestActionProcessor(sendEventRef);
|
|
@@ -13,7 +13,7 @@ export function useQpqWebsocketQueueRuntime(atom, mainStory, name, getActionProc
|
|
|
13
13
|
...(callerResolver ? await callerResolver(qpqConfig, dynamicModuleLoader) : {}),
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
const [api, state, dispatch] = useQpqRuntime(
|
|
16
|
+
const [api, state, dispatch] = useQpqRuntime(definition, instanceName, mergedFactory);
|
|
17
17
|
const sendEvent = useWebsocketQueueSendEvent((event) => {
|
|
18
18
|
if (event.type === WebSocketQueueServerMessageEventType.StateDispatch) {
|
|
19
19
|
dispatch(event.payload);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQpqWebsocketQueueRuntime.js","sourceRoot":"","sources":["../../../../src/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQpqWebsocketQueueRuntime.js","sourceRoot":"","sources":["../../../../src/webSocketQueue/hooks/useQpqWebsocketQueueRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,oCAAoC,EAAE,MAAM,qBAAqB,CAAC;AAEzH,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gCAAgC,EAAE,MAAM,oDAAoD,CAAC;AACtG,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,MAAM,UAAU,2BAA2B,CACzC,UAAuD,EACvD,YAAqB,EACrB,mBAAgE;IAEhE,MAAM,YAAY,GAAG,MAAM,CAAwG,IAAI,CAAC,CAAC;IAEzI,MAAM,aAAa,GAA+C,CAAC,QAAQ,EAAE,eAAe,EAAE,EAAE;QAC9F,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE,CAAC,gCAAgC,CAAC,YAAY,CAAC,CAAC;QACnF,MAAM,cAAc,GAAG,mBAAmB,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAExE,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAAE,CAAC,CAAC;YAChD,GAAG,CAAC,MAAM,eAAe,EAAE,CAAC;YAC5B,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,cAAc,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAChF,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,UAAU,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;IAEtF,MAAM,SAAS,GAAG,0BAA0B,CAAC,CAAC,KAAK,EAAE,EAAE;QACrD,IAAI,KAAK,CAAC,IAAI,KAAK,oCAAoC,CAAC,aAAa,EAAE,CAAC;YACtE,QAAQ,CAAE,KAAa,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;IAEjC,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { AnyWebSocketQueueEventMessageWithCorrelation, WebSocketQueueServerMessageEventType } from 'quidproquo-features';\n\nimport { useRef } from 'react';\n\nimport { ActionProcessorListResolverFactory } from '../../runtime/ActionProcessorListResolverFactory';\nimport { QpqRuntimeDefinition } from '../../runtime/createQpqRuntimeDefinition';\nimport { QpqApi, QpqMappedApi } from '../../runtime/QpqMappedApi';\nimport { useQpqRuntime } from '../../runtime/useQpqRuntime';\nimport { getServiceRequestActionProcessor } from './actionProcessor/getServiceRequestActionProcessor';\nimport { useWebsocketQueueSendEvent } from './useWebsocketQueueSendEvent';\n\nexport function useQpqWebsocketQueueRuntime<TState, TAction, TApi extends QpqApi>(\n definition: QpqRuntimeDefinition<TState, TAction, TApi>,\n instanceName?: string,\n getActionProcessors?: ActionProcessorListResolverFactory<TState>,\n): [QpqMappedApi<TApi>, TState, (action: any) => void, (event: Omit<AnyWebSocketQueueEventMessageWithCorrelation, 'correlationId'>) => Promise<any>] {\n const sendEventRef = useRef<((event: Omit<AnyWebSocketQueueEventMessageWithCorrelation, 'correlationId'>) => Promise<any>) | null>(null);\n\n const mergedFactory: ActionProcessorListResolverFactory<TState> = (dispatch, getCurrentState) => {\n const serviceResolver = async () => getServiceRequestActionProcessor(sendEventRef);\n const callerResolver = getActionProcessors?.(dispatch, getCurrentState);\n\n return async (qpqConfig, dynamicModuleLoader) => ({\n ...(await serviceResolver()),\n ...(callerResolver ? await callerResolver(qpqConfig, dynamicModuleLoader) : {}),\n });\n };\n\n const [api, state, dispatch] = useQpqRuntime(definition, instanceName, mergedFactory);\n\n const sendEvent = useWebsocketQueueSendEvent((event) => {\n if (event.type === WebSocketQueueServerMessageEventType.StateDispatch) {\n dispatch((event as any).payload);\n }\n });\n\n sendEventRef.current = sendEvent;\n\n return [api, state, dispatch, sendEvent];\n}\n"]}
|
|
@@ -20,8 +20,15 @@ export const useWebsocketQueueSendEvent = (onCorrelatedMessage) => {
|
|
|
20
20
|
const resolve = pendingResolversRef.current.get(parsed.correlationId);
|
|
21
21
|
if (resolve) {
|
|
22
22
|
resolve(parsed.payload);
|
|
23
|
+
// Only the resolver is retired: it has done its job, and a promise settles once.
|
|
24
|
+
//
|
|
25
|
+
// The CORRELATION deliberately stays active. It is a subscription, not a request,
|
|
26
|
+
// and it is live for as long as the component that opened it is mounted. Retiring
|
|
27
|
+
// it here used to be invisible because a response was always the last message sent,
|
|
28
|
+
// but a handler that responds first and keeps streaming (a batch that reports
|
|
29
|
+
// progress per record, say) would have every later message silently dropped by the
|
|
30
|
+
// guard above.
|
|
23
31
|
pendingResolversRef.current.delete(parsed.correlationId);
|
|
24
|
-
activeCorrelationsRef.current.delete(parsed.correlationId);
|
|
25
32
|
}
|
|
26
33
|
}
|
|
27
34
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebsocketQueueSendEvent.js","sourceRoot":"","sources":["../../../../src/webSocketQueue/hooks/useWebsocketQueueSendEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oCAAoC,GACrC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAoB,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,mBAAmF,EACnF,EAAE;IACF,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,MAAM,qBAAqB,GAAG,MAAM,CAAc,IAAI,GAAG,EAAE,CAAC,CAAC;IAC7D,MAAM,mBAAmB,GAAG,MAAM,CAAsC,IAAI,GAAG,EAAE,CAAC,CAAC;IAEnF,6DAA6D;IAC7D,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,GAAqB,EAAE,QAAgB,EAAE,EAAE;QAChF,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,IAAI,CAAC;YACH,MAAM,MAAM,GAAiD,IAAI,CAAC,KAAK,CAAE,QAAyB,CAAC,IAAI,CAAC,CAAC;YACzG,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;gBACtF,OAAO;YACT,CAAC;YAED,IAAI,MAAM,CAAC,IAAI,KAAK,oCAAoC,CAAC,sBAAsB,EAAE,CAAC;gBAChF,MAAM,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBACtE,IAAI,OAAO,EAAE,CAAC;oBACZ,OAAO,CAAE,MAAiE,CAAC,OAAO,CAAC,CAAC;oBAEpF,
|
|
1
|
+
{"version":3,"file":"useWebsocketQueueSendEvent.js","sourceRoot":"","sources":["../../../../src/webSocketQueue/hooks/useWebsocketQueueSendEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oCAAoC,GACrC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAoB,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,mBAAmF,EACnF,EAAE;IACF,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,MAAM,qBAAqB,GAAG,MAAM,CAAc,IAAI,GAAG,EAAE,CAAC,CAAC;IAC7D,MAAM,mBAAmB,GAAG,MAAM,CAAsC,IAAI,GAAG,EAAE,CAAC,CAAC;IAEnF,6DAA6D;IAC7D,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,GAAqB,EAAE,QAAgB,EAAE,EAAE;QAChF,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,IAAI,CAAC;YACH,MAAM,MAAM,GAAiD,IAAI,CAAC,KAAK,CAAE,QAAyB,CAAC,IAAI,CAAC,CAAC;YACzG,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;gBACtF,OAAO;YACT,CAAC;YAED,IAAI,MAAM,CAAC,IAAI,KAAK,oCAAoC,CAAC,sBAAsB,EAAE,CAAC;gBAChF,MAAM,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBACtE,IAAI,OAAO,EAAE,CAAC;oBACZ,OAAO,CAAE,MAAiE,CAAC,OAAO,CAAC,CAAC;oBAEpF,iFAAiF;oBACjF,EAAE;oBACF,kFAAkF;oBAClF,kFAAkF;oBAClF,oFAAoF;oBACpF,8EAA8E;oBAC9E,mFAAmF;oBACnF,eAAe;oBACf,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,mBAAmB,EAAE,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,2CAA2C;QAC7C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,uBAAuB,CAAC,qBAAqB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAEtE,gEAAgE;IAChE,MAAM,SAAS,GAAG,eAAe,CAAC,CAAC,KAAmC,EAAgB,EAAE;QACtF,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1C,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAEjD,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;QAEtE,IAAI,gBAAgB,EAAE,CAAC;YACrB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAM,CAAC,OAAO,EAAE,EAAE;gBAC3C,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;YAEH,YAAY,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,aAAa,EAAW,CAAC,CAAC;YAE7D,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,YAAY,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,aAAa,EAAW,CAAC,CAAC;QAE7D,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import {\n AnyWebSocketQueueEventMessageWithCorrelation,\n WebSocketQueueServerEventMessageServiceRequestResponse,\n WebSocketQueueServerMessageEventType,\n} from 'quidproquo-features';\nimport { WebsocketService, WebsocketServiceEvent } from 'quidproquo-web';\n\nimport { useRef } from 'react';\n\nimport { useFastCallback } from '../../hooks';\nimport { useSubscribeToWebsocket, useWebsocketApi } from '../../websocket';\n\nexport const useWebsocketQueueSendEvent = <TSend extends AnyWebSocketQueueEventMessageWithCorrelation>(\n onCorrelatedMessage?: (event: AnyWebSocketQueueEventMessageWithCorrelation) => void,\n) => {\n const websocketApi = useWebsocketApi();\n const activeCorrelationsRef = useRef<Set<string>>(new Set());\n const pendingResolversRef = useRef<Map<string, (payload: any) => void>>(new Map());\n\n // Subscribe to ALL messages, filter by active correlationIds\n const handleMessage = useFastCallback((_ws: WebsocketService, rawEvent?: Event) => {\n if (!rawEvent) return;\n\n try {\n const parsed: AnyWebSocketQueueEventMessageWithCorrelation = JSON.parse((rawEvent as MessageEvent).data);\n if (!parsed.correlationId || !activeCorrelationsRef.current.has(parsed.correlationId)) {\n return;\n }\n\n if (parsed.type === WebSocketQueueServerMessageEventType.ServiceRequestResponse) {\n const resolve = pendingResolversRef.current.get(parsed.correlationId);\n if (resolve) {\n resolve((parsed as WebSocketQueueServerEventMessageServiceRequestResponse).payload);\n\n // Only the resolver is retired: it has done its job, and a promise settles once.\n //\n // The CORRELATION deliberately stays active. It is a subscription, not a request,\n // and it is live for as long as the component that opened it is mounted. Retiring\n // it here used to be invisible because a response was always the last message sent,\n // but a handler that responds first and keeps streaming (a batch that reports\n // progress per record, say) would have every later message silently dropped by the\n // guard above.\n pendingResolversRef.current.delete(parsed.correlationId);\n }\n } else {\n onCorrelatedMessage?.(parsed);\n }\n } catch {\n // Not JSON or not a queue message — ignore\n }\n });\n\n useSubscribeToWebsocket(WebsocketServiceEvent.MESSAGE, handleMessage);\n\n // Send with auto-generated correlationId, register it as active\n const sendEvent = useFastCallback((event: Omit<TSend, 'correlationId'>): Promise<any> => {\n if (!websocketApi) {\n return Promise.resolve(undefined);\n }\n\n const correlationId = crypto.randomUUID();\n activeCorrelationsRef.current.add(correlationId);\n\n const isServiceRequest = event.type.startsWith('qpq/serviceRequest/');\n\n if (isServiceRequest) {\n const promise = new Promise<any>((resolve) => {\n pendingResolversRef.current.set(correlationId, resolve);\n });\n\n websocketApi.sendEvent({ ...event, correlationId } as TSend);\n\n return promise;\n }\n\n websocketApi.sendEvent({ ...event, correlationId } as TSend);\n\n return Promise.resolve(undefined);\n });\n\n return sendEvent;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-web-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -34,20 +34,19 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@testing-library/dom": "^10.4.1",
|
|
36
36
|
"@testing-library/react": "^16.3.2",
|
|
37
|
-
"quidproquo-core": "0.1.
|
|
38
|
-
"quidproquo-tsconfig": "0.1.
|
|
37
|
+
"quidproquo-core": "0.1.13",
|
|
38
|
+
"quidproquo-tsconfig": "0.1.13",
|
|
39
39
|
"typescript": "^5.8.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": ">=18.3.1"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"
|
|
46
|
-
"quidproquo-actionprocessor-
|
|
47
|
-
"quidproquo-
|
|
48
|
-
"quidproquo-
|
|
49
|
-
"quidproquo-
|
|
50
|
-
"quidproquo-webserver": "0.1.12",
|
|
45
|
+
"quidproquo-actionprocessor-node": "0.1.13",
|
|
46
|
+
"quidproquo-actionprocessor-web": "0.1.13",
|
|
47
|
+
"quidproquo-features": "0.1.13",
|
|
48
|
+
"quidproquo-web": "0.1.13",
|
|
49
|
+
"quidproquo-webserver": "0.1.13",
|
|
51
50
|
"symbol-observable": "^4.0.0"
|
|
52
51
|
}
|
|
53
52
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QpqContextProvider = exports.useQpqContextValue = exports.useQpqContextValues = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
// Define a generic type for the React Context
|
|
7
|
-
const qpqReactContext = (0, react_1.createContext)({});
|
|
8
|
-
const useQpqContextValues = () => {
|
|
9
|
-
return (0, react_1.useContext)(qpqReactContext);
|
|
10
|
-
};
|
|
11
|
-
exports.useQpqContextValues = useQpqContextValues;
|
|
12
|
-
const useQpqContextValue = (contextIdentifier) => {
|
|
13
|
-
const context = (0, exports.useQpqContextValues)();
|
|
14
|
-
return contextIdentifier.uniqueName in context ? context[contextIdentifier.uniqueName] : contextIdentifier.defaultValue;
|
|
15
|
-
};
|
|
16
|
-
exports.useQpqContextValue = useQpqContextValue;
|
|
17
|
-
const QpqContextProvider = ({ contextIdentifier, value, children }) => {
|
|
18
|
-
// Get the parent context value
|
|
19
|
-
const parentContext = (0, react_1.useContext)(qpqReactContext);
|
|
20
|
-
// Merge parent and current value
|
|
21
|
-
const mergedContext = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, parentContext), { [contextIdentifier.uniqueName]: value })), [parentContext, contextIdentifier.uniqueName, value]);
|
|
22
|
-
// Provide the merged context down
|
|
23
|
-
return (0, jsx_runtime_1.jsx)(qpqReactContext.Provider, { value: mergedContext, children: children });
|
|
24
|
-
};
|
|
25
|
-
exports.QpqContextProvider = QpqContextProvider;
|
|
26
|
-
//# sourceMappingURL=QpqContextProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QpqContextProvider.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/QpqContextProvider.tsx"],"names":[],"mappings":";;;;AAEA,iCAAsE;AAEtE,8CAA8C;AAC9C,MAAM,eAAe,GAAG,IAAA,qBAAa,EAAkB,EAAE,CAAC,CAAC;AAQpD,MAAM,mBAAmB,GAAG,GAAoB,EAAE;IACvD,OAAO,IAAA,kBAAU,EAAC,eAAe,CAAC,CAAC;AACrC,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B;AAEK,MAAM,kBAAkB,GAAG,CAAK,iBAA0C,EAAK,EAAE;IACtF,MAAM,OAAO,GAAG,IAAA,2BAAmB,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;AAEK,MAAM,kBAAkB,GAAG,CAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAA8B,EAAE,EAAE;IAC3G,+BAA+B;IAC/B,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,eAAe,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,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAAG,QAAQ,GAA4B,CAAC;AAC/F,CAAC,CAAC;AAZW,QAAA,kBAAkB,sBAY7B","sourcesContent":["import { QpqContext, QpqContextIdentifier } from 'quidproquo-core';\n\nimport { createContext, ReactNode, useContext, useMemo } from 'react';\n\n// Define a generic type for the React Context\nconst qpqReactContext = createContext<QpqContext<any>>({});\n\ninterface 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 useQpqContextValues = (): QpqContext<any> => {\n return useContext(qpqReactContext);\n};\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\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QpqMappedApi.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/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"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';
|
|
3
|
-
import { QpqApi } from './QpqMappedApi';
|
|
4
|
-
type QpqRuntimeEffectCatcher = {
|
|
5
|
-
runtime: QpqRuntimeDefinition<any, any, any>;
|
|
6
|
-
name?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const QpqRuntimeEffectCatcherComponent: <TState, TAction, TApi extends QpqApi>({ children, runtime, name, }: QpqRuntimeEffectCatcher & {
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
}) => import("react").JSX.Element;
|
|
11
|
-
export declare const QpqRuntimeEffectCatcher: import("react").MemoExoticComponent<(<TState, TAction, TApi extends QpqApi>({ children, runtime, name, }: QpqRuntimeEffectCatcher & {
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
}) => import("react").JSX.Element)>;
|
|
14
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QpqRuntimeEffectCatcher = exports.QpqRuntimeEffectCatcherComponent = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const bubbleReducer_1 = require("./bubbleReducer");
|
|
7
|
-
const useQpqRuntime_1 = require("./useQpqRuntime");
|
|
8
|
-
const QpqRuntimeEffectCatcherComponent = ({ children, runtime, name, }) => {
|
|
9
|
-
const [api, state, dispatch] = (0, useQpqRuntime_1.useQpqRuntime)(runtime, undefined, name);
|
|
10
|
-
return (0, jsx_runtime_1.jsx)(bubbleReducer_1.BubbleReducerDispatchContext.Provider, { value: dispatch, children: children });
|
|
11
|
-
};
|
|
12
|
-
exports.QpqRuntimeEffectCatcherComponent = QpqRuntimeEffectCatcherComponent;
|
|
13
|
-
exports.QpqRuntimeEffectCatcher = (0, react_1.memo)(exports.QpqRuntimeEffectCatcherComponent);
|
|
14
|
-
//# sourceMappingURL=QpqRuntimeEffectCatcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QpqRuntimeEffectCatcher.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/QpqRuntimeEffectCatcher.tsx"],"names":[],"mappings":";;;;AAAA,iCAAwC;AAExC,mDAA+D;AAG/D,mDAAgD;AAOzC,MAAM,gCAAgC,GAAG,CAAuC,EACrF,QAAQ,EACR,OAAO,EACP,IAAI,GAGL,EAAE,EAAE;IACH,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,6BAAa,EAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAEvE,OAAO,uBAAC,4CAA4B,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAyC,CAAC;AACpH,CAAC,CAAC;AAVW,QAAA,gCAAgC,oCAU3C;AAEW,QAAA,uBAAuB,GAAG,IAAA,YAAI,EAAC,wCAAgC,CAAC,CAAC","sourcesContent":["import { memo, ReactNode } from 'react';\n\nimport { BubbleReducerDispatchContext } from './bubbleReducer';\nimport { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';\nimport { QpqApi } from './QpqMappedApi';\nimport { useQpqRuntime } from './useQpqRuntime';\n\ntype QpqRuntimeEffectCatcher = {\n runtime: QpqRuntimeDefinition<any, any, any>;\n name?: string;\n};\n\nexport const QpqRuntimeEffectCatcherComponent = <TState, TAction, TApi extends QpqApi>({\n children,\n runtime,\n name,\n}: QpqRuntimeEffectCatcher & {\n children: ReactNode;\n}) => {\n const [api, state, dispatch] = useQpqRuntime(runtime, undefined, name);\n\n return <BubbleReducerDispatchContext.Provider value={dispatch}>{children}</BubbleReducerDispatchContext.Provider>;\n};\n\nexport const QpqRuntimeEffectCatcher = memo(QpqRuntimeEffectCatcherComponent);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStateDispatchActionProcessor.js","sourceRoot":"","sources":["../../../../../src/hooks/asmj/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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStateReadActionProcessor.js","sourceRoot":"","sources":["../../../../../src/hooks/asmj/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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/hooks/asmj/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"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';
|
|
2
|
-
import { QpqApi } from './QpqMappedApi';
|
|
3
|
-
export type QpqBubbleReducer<S, A> = (prevState: S, action: A) => [S, boolean];
|
|
4
|
-
export declare const BubbleReducerDispatchContext: import("react").Context<(action: any) => void>;
|
|
5
|
-
export declare const useQpqRuntimeBubblingReducer: <TState, TAction, TApi extends QpqApi>(runtimeDefinition: QpqRuntimeDefinition<TState, TAction, TApi>, name?: string) => [TState, (action: TAction) => void, () => TState];
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useQpqRuntimeBubblingReducer = exports.BubbleReducerDispatchContext = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useFastCallback_1 = require("../useFastCallback");
|
|
6
|
-
const createQpqRuntimeDefinition_1 = require("./createQpqRuntimeDefinition");
|
|
7
|
-
// Create a context with a default NOOP dispatcher
|
|
8
|
-
exports.BubbleReducerDispatchContext = (0, react_1.createContext)((_action) => {
|
|
9
|
-
// NOOP
|
|
10
|
-
});
|
|
11
|
-
const useQpqRuntimeBubblingReducer = (runtimeDefinition, name) => {
|
|
12
|
-
const runtimeDefinitionInfo = (0, react_1.useMemo)(() => runtimeDefinition(name), [runtimeDefinition, name]);
|
|
13
|
-
const [state, setState, getState] = (0, createQpqRuntimeDefinition_1.useQpqRuntimeState)(runtimeDefinition, name);
|
|
14
|
-
// Get the parent dispatch from the context
|
|
15
|
-
const parentDispatch = (0, react_1.useContext)(exports.BubbleReducerDispatchContext);
|
|
16
|
-
// Custom Dispatch using functional updates
|
|
17
|
-
const dispatch = (0, useFastCallback_1.useFastCallback)((action) => {
|
|
18
|
-
const [newState, preventBubble] = runtimeDefinitionInfo.reducer(getState(), action);
|
|
19
|
-
if (preventBubble) {
|
|
20
|
-
setState(newState);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
parentDispatch(action);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return [state, dispatch, getState];
|
|
27
|
-
};
|
|
28
|
-
exports.useQpqRuntimeBubblingReducer = useQpqRuntimeBubblingReducer;
|
|
29
|
-
//# sourceMappingURL=bubbleReducer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bubbleReducer.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/bubbleReducer.ts"],"names":[],"mappings":";;;AAAA,iCAA2D;AAE3D,wDAAqD;AACrD,6EAAwF;AAMxF,kDAAkD;AACrC,QAAA,4BAA4B,GAAG,IAAA,qBAAa,EAAwB,CAAC,OAAY,EAAQ,EAAE;IACtG,OAAO;AACT,CAAC,CAAC,CAAC;AAEI,MAAM,4BAA4B,GAAG,CAC1C,iBAA8D,EAC9D,IAAa,EACsC,EAAE;IACrD,MAAM,qBAAqB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC;IAEhG,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,IAAA,+CAAkB,EAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAEhF,2CAA2C;IAC3C,MAAM,cAAc,GAAG,IAAA,kBAAU,EAAC,oCAA4B,CAAC,CAAC;IAEhE,2CAA2C;IAC3C,MAAM,QAAQ,GAAG,IAAA,iCAAe,EAAC,CAAC,MAAe,EAAQ,EAAE;QACzD,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,qBAAqB,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;QAEpF,IAAI,aAAa,EAAE,CAAC;YAClB,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAC;AAvBW,QAAA,4BAA4B,gCAuBvC","sourcesContent":["import { createContext, useContext, useMemo } from 'react';\n\nimport { useFastCallback } from '../useFastCallback';\nimport { QpqRuntimeDefinition, useQpqRuntimeState } from './createQpqRuntimeDefinition';\nimport { QpqApi } from './QpqMappedApi';\n\n// Define the bubble reducer type\nexport type QpqBubbleReducer<S, A> = (prevState: S, action: A) => [S, boolean];\n\n// Create a context with a default NOOP dispatcher\nexport const BubbleReducerDispatchContext = createContext<(action: any) => void>((_action: any): void => {\n // NOOP\n});\n\nexport const useQpqRuntimeBubblingReducer = <TState, TAction, TApi extends QpqApi>(\n runtimeDefinition: QpqRuntimeDefinition<TState, TAction, TApi>,\n name?: string,\n): [TState, (action: TAction) => void, () => TState] => {\n const runtimeDefinitionInfo = useMemo(() => runtimeDefinition(name), [runtimeDefinition, name]);\n\n const [state, setState, getState] = useQpqRuntimeState(runtimeDefinition, name);\n\n // Get the parent dispatch from the context\n const parentDispatch = useContext(BubbleReducerDispatchContext);\n\n // Custom Dispatch using functional updates\n const dispatch = useFastCallback((action: TAction): void => {\n const [newState, preventBubble] = runtimeDefinitionInfo.reducer(getState(), action);\n\n if (preventBubble) {\n setState(newState);\n } else {\n parentDispatch(action);\n }\n });\n\n return [state, dispatch, getState];\n};\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { atom } from 'jotai';
|
|
2
|
-
import { selectAtom } from 'jotai/utils';
|
|
3
|
-
import { QpqBubbleReducer } from './bubbleReducer';
|
|
4
|
-
import { QpqApi } from './QpqMappedApi';
|
|
5
|
-
type CustomJotaiReducerAtom<TState> = ReturnType<typeof atom<TState>>;
|
|
6
|
-
type CustomJotaiComputedAtom<TState, TSlice> = ReturnType<typeof selectAtom<TState, TSlice>>;
|
|
7
|
-
export type QpqAsmjState<TState, TAction, TApi extends QpqApi> = {
|
|
8
|
-
atom: CustomJotaiReducerAtom<TState>;
|
|
9
|
-
reducer: QpqBubbleReducer<TState, TAction>;
|
|
10
|
-
initialState: TState;
|
|
11
|
-
api: TApi;
|
|
12
|
-
state: TState;
|
|
13
|
-
};
|
|
14
|
-
type AsmjStateGetter<TState, TAction, TApi extends QpqApi> = (name?: string) => QpqAsmjState<TState, TAction, TApi>;
|
|
15
|
-
type AsmjStateComputer<TState, TSlice> = (name?: string) => CustomJotaiComputedAtom<TState, TSlice>;
|
|
16
|
-
export type QpqRuntimeDefinition<TState, TAction, TApi extends QpqApi> = AsmjStateGetter<TState, TAction, TApi>;
|
|
17
|
-
export type QpqRuntimeComputed<TState, TSlice> = AsmjStateComputer<TState, TSlice>;
|
|
18
|
-
export declare function createQpqRuntimeDefinition<TState, TAction, TApi extends QpqApi>(api: TApi, initialState: TState, reducer?: QpqBubbleReducer<TState, TAction>): QpqRuntimeDefinition<TState, TAction, TApi>;
|
|
19
|
-
export declare function createQpqRuntimeComputed<TState, TAction, TApi extends QpqApi, TSlice>(atom: QpqRuntimeDefinition<TState, TAction, TApi>, compute: (state: TState) => TSlice): QpqRuntimeComputed<TState, TSlice>;
|
|
20
|
-
export declare function useQpqRuntimeState<TState, TAction, TApi extends QpqApi>(atom: QpqRuntimeDefinition<TState, TAction, TApi>, name?: string): [TState, (newState: TState) => void, () => TState];
|
|
21
|
-
export declare function useQpqRuntimeComputed<TState, TSlice>(computedAtom: QpqRuntimeComputed<TState, TSlice>, name?: string): TSlice;
|
|
22
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createQpqRuntimeDefinition = createQpqRuntimeDefinition;
|
|
4
|
-
exports.createQpqRuntimeComputed = createQpqRuntimeComputed;
|
|
5
|
-
exports.useQpqRuntimeState = useQpqRuntimeState;
|
|
6
|
-
exports.useQpqRuntimeComputed = useQpqRuntimeComputed;
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const jotai_1 = require("jotai");
|
|
9
|
-
const utils_1 = require("jotai/utils");
|
|
10
|
-
function createQpqRuntimeDefinition(api, initialState, reducer = (s) => [s, false]) {
|
|
11
|
-
const namedAtoms = new Map();
|
|
12
|
-
const getCustomNamedAtom = (name) => {
|
|
13
|
-
const actualName = name ? name : '$$qpq-default$$';
|
|
14
|
-
if (!namedAtoms.has(actualName)) {
|
|
15
|
-
const winAtom = {
|
|
16
|
-
atom: (0, jotai_1.atom)(initialState),
|
|
17
|
-
reducer,
|
|
18
|
-
initialState,
|
|
19
|
-
api: api,
|
|
20
|
-
state: initialState,
|
|
21
|
-
};
|
|
22
|
-
namedAtoms.set(actualName, winAtom);
|
|
23
|
-
}
|
|
24
|
-
return namedAtoms.get(actualName);
|
|
25
|
-
};
|
|
26
|
-
return getCustomNamedAtom;
|
|
27
|
-
}
|
|
28
|
-
function createQpqRuntimeComputed(atom, compute) {
|
|
29
|
-
return (name) => {
|
|
30
|
-
const info = atom(name);
|
|
31
|
-
return (0, utils_1.selectAtom)(info.atom, compute);
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function useQpqRuntimeState(atom, name) {
|
|
35
|
-
const actualAtom = (0, react_1.useMemo)(() => atom(name).atom, [atom, name]);
|
|
36
|
-
const [state, setState] = (0, jotai_1.useAtom)(actualAtom);
|
|
37
|
-
const setStateWrapper = (0, react_1.useCallback)((newState) => {
|
|
38
|
-
const info = atom(name);
|
|
39
|
-
info.state = newState;
|
|
40
|
-
setState(newState);
|
|
41
|
-
}, [atom, name, setState]);
|
|
42
|
-
const getState = (0, react_1.useCallback)(() => {
|
|
43
|
-
const state = atom(name).state;
|
|
44
|
-
return state;
|
|
45
|
-
}, [atom, name]);
|
|
46
|
-
return [state, setStateWrapper, getState];
|
|
47
|
-
}
|
|
48
|
-
function useQpqRuntimeComputed(computedAtom, name) {
|
|
49
|
-
const computedAtomValue = (0, react_1.useMemo)(() => computedAtom(name), [computedAtom, name]);
|
|
50
|
-
const [state] = (0, jotai_1.useAtom)(computedAtomValue);
|
|
51
|
-
return state;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=createQpqRuntimeDefinition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createQpqRuntimeDefinition.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/createQpqRuntimeDefinition.ts"],"names":[],"mappings":";;AAwBA,gEAyBC;AAED,4DAQC;AAED,gDAwBC;AAED,sDAMC;AA7FD,iCAA6C;AAC7C,iCAAsC;AACtC,uCAAyC;AAsBzC,SAAgB,0BAA0B,CACxC,GAAS,EACT,YAAoB,EACpB,UAA6C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;IAE9D,MAAM,UAAU,GAAG,IAAI,GAAG,EAA+C,CAAC;IAE1E,MAAM,kBAAkB,GAA2C,CAAC,IAAa,EAAuC,EAAE;QACxH,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC;QACnD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAChC,MAAM,OAAO,GAAwC;gBACnD,IAAI,EAAE,IAAA,YAAI,EAAC,YAAY,CAAC;gBACxB,OAAO;gBACP,YAAY;gBACZ,GAAG,EAAE,GAAG;gBACR,KAAK,EAAE,YAAY;aACpB,CAAC;YAEF,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,UAAU,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC;IACrC,CAAC,CAAC;IAEF,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,SAAgB,wBAAwB,CACtC,IAAiD,EACjD,OAAkC;IAElC,OAAO,CAAC,IAAa,EAA2C,EAAE;QAChE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,IAAA,kBAAU,EAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAChC,IAAiD,EACjD,IAAa;IAEb,MAAM,UAAU,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEhE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,eAAO,EAAC,UAAU,CAAC,CAAC;IAE9C,MAAM,eAAe,GAAG,IAAA,mBAAW,EACjC,CAAC,QAAgB,EAAE,EAAE;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;QAEtB,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,EACD,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CACvB,CAAC;IAEF,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,GAAW,EAAE;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEjB,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED,SAAgB,qBAAqB,CAAiB,YAAgD,EAAE,IAAa;IACnH,MAAM,iBAAiB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IAElF,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,eAAO,EAAC,iBAAiB,CAAC,CAAC;IAE3C,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { atom, useAtom } from 'jotai';\nimport { selectAtom } from 'jotai/utils';\n\nimport { QpqBubbleReducer } from './bubbleReducer';\nimport { QpqApi } from './QpqMappedApi';\n\n// Define the function type for retrieving atoms\ntype CustomJotaiReducerAtom<TState> = ReturnType<typeof atom<TState>>;\ntype CustomJotaiComputedAtom<TState, TSlice> = ReturnType<typeof selectAtom<TState, TSlice>>;\n\nexport type QpqAsmjState<TState, TAction, TApi extends QpqApi> = {\n atom: CustomJotaiReducerAtom<TState>;\n reducer: QpqBubbleReducer<TState, TAction>;\n initialState: TState;\n api: TApi;\n state: TState;\n};\ntype AsmjStateGetter<TState, TAction, TApi extends QpqApi> = (name?: string) => QpqAsmjState<TState, TAction, TApi>;\ntype AsmjStateComputer<TState, TSlice> = (name?: string) => CustomJotaiComputedAtom<TState, TSlice>;\n\nexport type QpqRuntimeDefinition<TState, TAction, TApi extends QpqApi> = AsmjStateGetter<TState, TAction, TApi>;\nexport type QpqRuntimeComputed<TState, TSlice> = AsmjStateComputer<TState, TSlice>;\n\nexport function createQpqRuntimeDefinition<TState, TAction, TApi extends QpqApi>(\n api: TApi,\n initialState: TState,\n reducer: QpqBubbleReducer<TState, TAction> = (s) => [s, false],\n): QpqRuntimeDefinition<TState, TAction, TApi> {\n const namedAtoms = new Map<string, QpqAsmjState<TState, TAction, TApi>>();\n\n const getCustomNamedAtom: AsmjStateGetter<TState, TAction, TApi> = (name?: string): QpqAsmjState<TState, TAction, TApi> => {\n const actualName = name ? name : '$$qpq-default$$';\n if (!namedAtoms.has(actualName)) {\n const winAtom: QpqAsmjState<TState, TAction, TApi> = {\n atom: atom(initialState),\n reducer,\n initialState,\n api: api,\n state: initialState,\n };\n\n namedAtoms.set(actualName, winAtom);\n }\n\n return namedAtoms.get(actualName)!;\n };\n\n return getCustomNamedAtom;\n}\n\nexport function createQpqRuntimeComputed<TState, TAction, TApi extends QpqApi, TSlice>(\n atom: QpqRuntimeDefinition<TState, TAction, TApi>,\n compute: (state: TState) => TSlice,\n): QpqRuntimeComputed<TState, TSlice> {\n return (name?: string): CustomJotaiComputedAtom<TState, TSlice> => {\n const info = atom(name);\n return selectAtom(info.atom, compute);\n };\n}\n\nexport function useQpqRuntimeState<TState, TAction, TApi extends QpqApi>(\n atom: QpqRuntimeDefinition<TState, TAction, TApi>,\n name?: string,\n): [TState, (newState: TState) => void, () => TState] {\n const actualAtom = useMemo(() => atom(name).atom, [atom, name]);\n\n const [state, setState] = useAtom(actualAtom);\n\n const setStateWrapper = useCallback(\n (newState: TState) => {\n const info = atom(name);\n info.state = newState;\n\n setState(newState);\n },\n [atom, name, setState],\n );\n\n const getState = useCallback((): TState => {\n const state = atom(name).state;\n return state;\n }, [atom, name]);\n\n return [state, setStateWrapper, getState];\n}\n\nexport function useQpqRuntimeComputed<TState, TSlice>(computedAtom: QpqRuntimeComputed<TState, TSlice>, name?: string): TSlice {\n const computedAtomValue = useMemo(() => computedAtom(name), [computedAtom, name]);\n\n const [state] = useAtom(computedAtomValue);\n\n return state;\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './actionProcessor';
|
|
2
|
-
export * from './bubbleReducer';
|
|
3
|
-
export * from './createQpqRuntimeDefinition';
|
|
4
|
-
export * from './QpqContextProvider';
|
|
5
|
-
export * from './QpqMappedApi';
|
|
6
|
-
export * from './QpqRuntimeEffectCatcher';
|
|
7
|
-
export * from './useBubbleReducer';
|
|
8
|
-
export * from './useQpqRuntime';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,kDAAgC;AAChC,+DAA6C;AAC7C,uDAAqC;AACrC,iDAA+B;AAC/B,4DAA0C;AAC1C,qDAAmC;AACnC,kDAAgC","sourcesContent":["export * from './actionProcessor';\nexport * from './bubbleReducer';\nexport * from './createQpqRuntimeDefinition';\nexport * from './QpqContextProvider';\nexport * from './QpqMappedApi';\nexport * from './QpqRuntimeEffectCatcher';\nexport * from './useBubbleReducer';\nexport * from './useQpqRuntime';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBubbleReducer.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/useBubbleReducer.ts"],"names":[],"mappings":";;;AAAA,iCAAkE;AAElE,mDAAiF;AAE1E,MAAM,gBAAgB,GAAG,CAC9B,OAAsC,EACtC,YAAqC,EACA,EAAE;IACvC,MAAM,cAAc,GAAG,IAAA,kBAAU,EAAC,4CAA4B,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, QpqBubbleReducer } from './bubbleReducer';\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"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ActionProcessorListResolver, Story } from 'quidproquo-core';
|
|
2
|
-
import { Dispatch } from 'react';
|
|
3
|
-
import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';
|
|
4
|
-
import { QpqApi, QpqMappedApi } from './QpqMappedApi';
|
|
5
|
-
export type ActionProcessorListResolverFactory<TState = any> = (dispatch: Dispatch<any>, getCurrentState: () => TState) => ActionProcessorListResolver;
|
|
6
|
-
export declare function useQpqRuntime<TState, TAction, TApi extends QpqApi>(atom: QpqRuntimeDefinition<TState, TAction, TApi>, mainStory?: Story<any, any>, name?: string, getActionProcessors?: ActionProcessorListResolverFactory<TState>): [QpqMappedApi<TApi>, TState, (action: any) => void];
|
|
@@ -1,49 +0,0 @@
|
|
|
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.useQpqRuntime = useQpqRuntime;
|
|
13
|
-
const react_1 = require("react");
|
|
14
|
-
const useQpq_1 = require("../useQpq");
|
|
15
|
-
const actionProcessor_1 = require("./actionProcessor");
|
|
16
|
-
const bubbleReducer_1 = require("./bubbleReducer");
|
|
17
|
-
function useQpqRuntime(atom, mainStory, name, getActionProcessors = () => () => __awaiter(this, void 0, void 0, function* () { return ({}); })) {
|
|
18
|
-
const atomInfo = (0, react_1.useMemo)(() => atom(name), [atom, name]);
|
|
19
|
-
const [state, dispatch, getCurrentState] = (0, bubbleReducer_1.useQpqRuntimeBubblingReducer)(atom, name);
|
|
20
|
-
// Api generators are memoized to prevent unnecessary re-renders.
|
|
21
|
-
const [memoedApiGenerators] = (0, react_1.useState)(() => atomInfo.api);
|
|
22
|
-
const mergedProcessors = (qpqConfig, dynamicModuleLoader) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
return (Object.assign(Object.assign({}, (yield (0, actionProcessor_1.getStateActionProcessor)(dispatch, getCurrentState)(qpqConfig, dynamicModuleLoader))), (yield getActionProcessors(dispatch, getCurrentState)(qpqConfig, dynamicModuleLoader))));
|
|
24
|
-
});
|
|
25
|
-
const resolver = (0, useQpq_1.useQpq)(mergedProcessors);
|
|
26
|
-
// Wrap and remap each API generator using the resolver.
|
|
27
|
-
const api = (0, react_1.useMemo)(() => {
|
|
28
|
-
const wrapped = {};
|
|
29
|
-
for (const key in memoedApiGenerators) {
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(memoedApiGenerators, key)) {
|
|
31
|
-
// Remove the 'ask' prefix and lower-case the first character.
|
|
32
|
-
const withoutAsk = key.slice(3); // e.g., "FetchTodos"
|
|
33
|
-
const newKey = withoutAsk.charAt(0).toLowerCase() + withoutAsk.slice(1); // "fetchTodos"
|
|
34
|
-
// We know newKey matches our mapped type so we can assign.
|
|
35
|
-
// (A type assertion is used here to quiet the compiler.)
|
|
36
|
-
wrapped[newKey] = resolver(memoedApiGenerators[key]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return wrapped;
|
|
40
|
-
}, [resolver, memoedApiGenerators]);
|
|
41
|
-
(0, react_1.useEffect)(() => {
|
|
42
|
-
if (mainStory) {
|
|
43
|
-
resolver(mainStory)();
|
|
44
|
-
}
|
|
45
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
-
}, []);
|
|
47
|
-
return [api, state, dispatch];
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=useQpqRuntime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useQpqRuntime.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/useQpqRuntime.ts"],"names":[],"mappings":";;;;;;;;;;;AAeA,sCAiDC;AA9DD,iCAA+D;AAE/D,sCAAmC;AACnC,uDAA4D;AAC5D,mDAA+D;AAS/D,SAAgB,aAAa,CAM3B,IAAiD,EACjD,SAA2B,EAC3B,IAAa,EACb,sBAAkE,GAAG,EAAE,CAAC,GAAS,EAAE,gDAAC,OAAA,CAAC,EAAE,CAAC,CAAA,GAAA;IAExF,MAAM,QAAQ,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzD,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,IAAA,4CAA4B,EAAwB,IAAI,EAAE,IAAI,CAAC,CAAC;IAE3G,iEAAiE;IACjE,MAAM,CAAC,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE3D,MAAM,gBAAgB,GAAgC,CAAO,SAAS,EAAE,mBAAmB,EAAE,EAAE;QAAC,OAAA,iCAC3F,CAAC,MAAM,IAAA,yCAAuB,EAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,GAC1F,CAAC,MAAM,mBAAmB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,EACzF,CAAA;MAAA,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAA,eAAM,EAAC,gBAAgB,CAAC,CAAC;IAE1C,wDAAwD;IACxD,MAAM,GAAG,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACvB,MAAM,OAAO,GAAwB,EAAE,CAAC;QACxC,KAAK,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;YACtC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAAC,EAAE,CAAC;gBACnE,8DAA8D;gBAC9D,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB;gBACtD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe;gBACxF,2DAA2D;gBAC3D,yDAAyD;gBACzD,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,mBAAmB,CAAC,GAAU,CAAC,CAAQ,CAAC;YACrE,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEpC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,SAAS,EAAE,CAAC;YACd,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACxB,CAAC;QACD,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,GAAyB,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { ActionProcessorListResolver, Story } from 'quidproquo-core';\n\nimport { Dispatch, useEffect, useMemo, useState } from 'react';\n\nimport { useQpq } from '../useQpq';\nimport { getStateActionProcessor } from './actionProcessor';\nimport { useQpqRuntimeBubblingReducer } from './bubbleReducer';\nimport { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';\nimport { QpqApi, QpqMappedApi } from './QpqMappedApi';\n\nexport type ActionProcessorListResolverFactory<TState = any> = (\n dispatch: Dispatch<any>,\n getCurrentState: () => TState,\n) => ActionProcessorListResolver;\n\nexport function useQpqRuntime<\n TState,\n TAction,\n // Constrain TApi so that all keys must start with \"ask\"\n TApi extends QpqApi,\n>(\n atom: QpqRuntimeDefinition<TState, TAction, TApi>,\n mainStory?: Story<any, any>,\n name?: string,\n getActionProcessors: ActionProcessorListResolverFactory<TState> = () => async () => ({}),\n): [QpqMappedApi<TApi>, TState, (action: any) => void] {\n const atomInfo = useMemo(() => atom(name), [atom, name]);\n\n const [state, dispatch, getCurrentState] = useQpqRuntimeBubblingReducer<TState, TAction, TApi>(atom, name);\n\n // Api generators are memoized to prevent unnecessary re-renders.\n const [memoedApiGenerators] = useState(() => atomInfo.api);\n\n const mergedProcessors: ActionProcessorListResolver = async (qpqConfig, dynamicModuleLoader) => ({\n ...(await getStateActionProcessor(dispatch, getCurrentState)(qpqConfig, dynamicModuleLoader)),\n ...(await getActionProcessors(dispatch, getCurrentState)(qpqConfig, dynamicModuleLoader)),\n });\n\n const resolver = useQpq(mergedProcessors);\n\n // Wrap and remap each API generator using the resolver.\n const api = useMemo(() => {\n const wrapped: Record<string, any> = {};\n for (const key in memoedApiGenerators) {\n if (Object.prototype.hasOwnProperty.call(memoedApiGenerators, key)) {\n // Remove the 'ask' prefix and lower-case the first character.\n const withoutAsk = key.slice(3); // e.g., \"FetchTodos\"\n const newKey = withoutAsk.charAt(0).toLowerCase() + withoutAsk.slice(1); // \"fetchTodos\"\n // We know newKey matches our mapped type so we can assign.\n // (A type assertion is used here to quiet the compiler.)\n wrapped[newKey] = resolver(memoedApiGenerators[key as any]) as any;\n }\n }\n return wrapped;\n }, [resolver, memoedApiGenerators]);\n\n useEffect(() => {\n if (mainStory) {\n resolver(mainStory)();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return [api as QpqMappedApi<TApi>, state, dispatch];\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QpqContextProvider.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/QpqContextProvider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAa,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEtE,8CAA8C;AAC9C,MAAM,eAAe,GAAG,aAAa,CAAkB,EAAE,CAAC,CAAC;AAQ3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAoB,EAAE;IACvD,OAAO,UAAU,CAAC,eAAe,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAK,iBAA0C,EAAK,EAAE;IACtF,MAAM,OAAO,GAAG,mBAAmB,EAAE,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;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAA8B,EAAE,EAAE;IAC3G,+BAA+B;IAC/B,MAAM,aAAa,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAElD,iCAAiC;IACjC,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,EACnE,CAAC,aAAa,EAAE,iBAAiB,CAAC,UAAU,EAAE,KAAK,CAAC,CACrD,CAAC;IAEF,kCAAkC;IAClC,OAAO,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAAG,QAAQ,GAA4B,CAAC;AAC/F,CAAC,CAAC","sourcesContent":["import { QpqContext, QpqContextIdentifier } from 'quidproquo-core';\n\nimport { createContext, ReactNode, useContext, useMemo } from 'react';\n\n// Define a generic type for the React Context\nconst qpqReactContext = createContext<QpqContext<any>>({});\n\ninterface 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 useQpqContextValues = (): QpqContext<any> => {\n return useContext(qpqReactContext);\n};\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\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QpqMappedApi.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/QpqMappedApi.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,cAAc,GAAG,CAA6C,IAAW,EAAE,IAAW,EAAiB,EAAE;IACpH,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;AAC9B,CAAC,CAAC","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"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';
|
|
3
|
-
import { QpqApi } from './QpqMappedApi';
|
|
4
|
-
type QpqRuntimeEffectCatcher = {
|
|
5
|
-
runtime: QpqRuntimeDefinition<any, any, any>;
|
|
6
|
-
name?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const QpqRuntimeEffectCatcherComponent: <TState, TAction, TApi extends QpqApi>({ children, runtime, name, }: QpqRuntimeEffectCatcher & {
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
}) => import("react").JSX.Element;
|
|
11
|
-
export declare const QpqRuntimeEffectCatcher: import("react").MemoExoticComponent<(<TState, TAction, TApi extends QpqApi>({ children, runtime, name, }: QpqRuntimeEffectCatcher & {
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
}) => import("react").JSX.Element)>;
|
|
14
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QpqRuntimeEffectCatcher.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/QpqRuntimeEffectCatcher.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAa,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAuC,EACrF,QAAQ,EACR,OAAO,EACP,IAAI,GAGL,EAAE,EAAE;IACH,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAEvE,OAAO,KAAC,4BAA4B,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAyC,CAAC;AACpH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC,gCAAgC,CAAC,CAAC","sourcesContent":["import { memo, ReactNode } from 'react';\n\nimport { BubbleReducerDispatchContext } from './bubbleReducer';\nimport { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';\nimport { QpqApi } from './QpqMappedApi';\nimport { useQpqRuntime } from './useQpqRuntime';\n\ntype QpqRuntimeEffectCatcher = {\n runtime: QpqRuntimeDefinition<any, any, any>;\n name?: string;\n};\n\nexport const QpqRuntimeEffectCatcherComponent = <TState, TAction, TApi extends QpqApi>({\n children,\n runtime,\n name,\n}: QpqRuntimeEffectCatcher & {\n children: ReactNode;\n}) => {\n const [api, state, dispatch] = useQpqRuntime(runtime, undefined, name);\n\n return <BubbleReducerDispatchContext.Provider value={dispatch}>{children}</BubbleReducerDispatchContext.Provider>;\n};\n\nexport const QpqRuntimeEffectCatcher = memo(QpqRuntimeEffectCatcherComponent);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStateDispatchActionProcessor.js","sourceRoot":"","sources":["../../../../../src/hooks/asmj/actionProcessor/getStateDispatchActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,YAAY,EAAE,eAAe,EAAgC,MAAM,iBAAiB,CAAC;AAIhJ,MAAM,uBAAuB,GAC3B,CAAC,QAAuB,EAAqC,EAAE,CAC/D,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACnB,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEjB,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,kCAAkC,GAC7C,CAAC,QAAuB,EAA+B,EAAE,CACzD,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAgC,EAAE,CAAC,CAAC;IACzE,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,uBAAuB,CAAC,QAAQ,CAAC;CAC9D,CAAC,CAAC","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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStateReadActionProcessor.js","sourceRoot":"","sources":["../../../../../src/hooks/asmj/actionProcessor/getStateReadActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,YAAY,EAAE,eAAe,EAA4B,MAAM,iBAAiB,CAAC;AAE5I,MAAM,mBAAmB,GACvB,CAAQ,eAA4B,EAAiC,EAAE,CACvE,KAAK,IAAI,EAAE;IACT,OAAO,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC;AACzC,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,8BAA8B,GACzC,CAAQ,eAA4B,EAA+B,EAAE,CACrE,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAgC,EAAE,CAAC,CAAC;IACzE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,mBAAmB,CAAC,eAAe,CAAC;CAC7D,CAAC,CAAC","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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/hooks/asmj/actionProcessor/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAE/E,MAAM,CAAC,MAAM,uBAAuB,GAClC,CAAQ,QAAuB,EAAE,eAA4B,EAA+B,EAAE,CAC9F,KAAK,EAAE,SAAoB,EAAE,mBAAwC,EAAgC,EAAE,CAAC,CAAC;IACvG,GAAG,CAAC,MAAM,kCAAkC,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACvF,GAAG,CAAC,MAAM,8BAA8B,CAAC,eAAe,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CAC3F,CAAC,CAAC","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"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { QpqRuntimeDefinition } from './createQpqRuntimeDefinition';
|
|
2
|
-
import { QpqApi } from './QpqMappedApi';
|
|
3
|
-
export type QpqBubbleReducer<S, A> = (prevState: S, action: A) => [S, boolean];
|
|
4
|
-
export declare const BubbleReducerDispatchContext: import("react").Context<(action: any) => void>;
|
|
5
|
-
export declare const useQpqRuntimeBubblingReducer: <TState, TAction, TApi extends QpqApi>(runtimeDefinition: QpqRuntimeDefinition<TState, TAction, TApi>, name?: string) => [TState, (action: TAction) => void, () => TState];
|