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,25 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, useMemo } from 'react';
|
|
2
|
-
import { useFastCallback } from '../useFastCallback';
|
|
3
|
-
import { useQpqRuntimeState } from './createQpqRuntimeDefinition';
|
|
4
|
-
// Create a context with a default NOOP dispatcher
|
|
5
|
-
export const BubbleReducerDispatchContext = createContext((_action) => {
|
|
6
|
-
// NOOP
|
|
7
|
-
});
|
|
8
|
-
export const useQpqRuntimeBubblingReducer = (runtimeDefinition, name) => {
|
|
9
|
-
const runtimeDefinitionInfo = useMemo(() => runtimeDefinition(name), [runtimeDefinition, name]);
|
|
10
|
-
const [state, setState, getState] = useQpqRuntimeState(runtimeDefinition, name);
|
|
11
|
-
// Get the parent dispatch from the context
|
|
12
|
-
const parentDispatch = useContext(BubbleReducerDispatchContext);
|
|
13
|
-
// Custom Dispatch using functional updates
|
|
14
|
-
const dispatch = useFastCallback((action) => {
|
|
15
|
-
const [newState, preventBubble] = runtimeDefinitionInfo.reducer(getState(), action);
|
|
16
|
-
if (preventBubble) {
|
|
17
|
-
setState(newState);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
parentDispatch(action);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return [state, dispatch, getState];
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=bubbleReducer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bubbleReducer.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/bubbleReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAwB,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAMxF,kDAAkD;AAClD,MAAM,CAAC,MAAM,4BAA4B,GAAG,aAAa,CAAwB,CAAC,OAAY,EAAQ,EAAE;IACtG,OAAO;AACT,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,iBAA8D,EAC9D,IAAa,EACsC,EAAE;IACrD,MAAM,qBAAqB,GAAG,OAAO,CAAC,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,kBAAkB,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAEhF,2CAA2C;IAC3C,MAAM,cAAc,GAAG,UAAU,CAAC,4BAA4B,CAAC,CAAC;IAEhE,2CAA2C;IAC3C,MAAM,QAAQ,GAAG,eAAe,CAAC,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","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,47 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import { atom, useAtom } from 'jotai';
|
|
3
|
-
import { selectAtom } from 'jotai/utils';
|
|
4
|
-
export function createQpqRuntimeDefinition(api, initialState, reducer = (s) => [s, false]) {
|
|
5
|
-
const namedAtoms = new Map();
|
|
6
|
-
const getCustomNamedAtom = (name) => {
|
|
7
|
-
const actualName = name ? name : '$$qpq-default$$';
|
|
8
|
-
if (!namedAtoms.has(actualName)) {
|
|
9
|
-
const winAtom = {
|
|
10
|
-
atom: atom(initialState),
|
|
11
|
-
reducer,
|
|
12
|
-
initialState,
|
|
13
|
-
api: api,
|
|
14
|
-
state: initialState,
|
|
15
|
-
};
|
|
16
|
-
namedAtoms.set(actualName, winAtom);
|
|
17
|
-
}
|
|
18
|
-
return namedAtoms.get(actualName);
|
|
19
|
-
};
|
|
20
|
-
return getCustomNamedAtom;
|
|
21
|
-
}
|
|
22
|
-
export function createQpqRuntimeComputed(atom, compute) {
|
|
23
|
-
return (name) => {
|
|
24
|
-
const info = atom(name);
|
|
25
|
-
return selectAtom(info.atom, compute);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export function useQpqRuntimeState(atom, name) {
|
|
29
|
-
const actualAtom = useMemo(() => atom(name).atom, [atom, name]);
|
|
30
|
-
const [state, setState] = useAtom(actualAtom);
|
|
31
|
-
const setStateWrapper = useCallback((newState) => {
|
|
32
|
-
const info = atom(name);
|
|
33
|
-
info.state = newState;
|
|
34
|
-
setState(newState);
|
|
35
|
-
}, [atom, name, setState]);
|
|
36
|
-
const getState = useCallback(() => {
|
|
37
|
-
const state = atom(name).state;
|
|
38
|
-
return state;
|
|
39
|
-
}, [atom, name]);
|
|
40
|
-
return [state, setStateWrapper, getState];
|
|
41
|
-
}
|
|
42
|
-
export function useQpqRuntimeComputed(computedAtom, name) {
|
|
43
|
-
const computedAtomValue = useMemo(() => computedAtom(name), [computedAtom, name]);
|
|
44
|
-
const [state] = useAtom(computedAtomValue);
|
|
45
|
-
return state;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=createQpqRuntimeDefinition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createQpqRuntimeDefinition.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/createQpqRuntimeDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsBzC,MAAM,UAAU,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,IAAI,CAAC,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,MAAM,UAAU,wBAAwB,CACtC,IAAiD,EACjD,OAAkC;IAElC,OAAO,CAAC,IAAa,EAA2C,EAAE;QAChE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,IAAiD,EACjD,IAAa;IAEb,MAAM,UAAU,GAAG,OAAO,CAAC,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,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9C,MAAM,eAAe,GAAG,WAAW,CACjC,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,WAAW,CAAC,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,MAAM,UAAU,qBAAqB,CAAiB,YAAgD,EAAE,IAAa;IACnH,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IAElF,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,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,9 +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';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC","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,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,4BAA4B,EAAoB,MAAM,iBAAiB,CAAC;AAEjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAsC,EACtC,YAAqC,EACA,EAAE;IACvC,MAAM,cAAc,GAAG,UAAU,CAAC,4BAA4B,CAAC,CAAC;IAChE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;IAEzB,MAAM,QAAQ,GAAG,WAAW,CAC1B,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","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,38 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { useQpq } from '../useQpq';
|
|
3
|
-
import { getStateActionProcessor } from './actionProcessor';
|
|
4
|
-
import { useQpqRuntimeBubblingReducer } from './bubbleReducer';
|
|
5
|
-
export function useQpqRuntime(atom, mainStory, name, getActionProcessors = () => async () => ({})) {
|
|
6
|
-
const atomInfo = useMemo(() => atom(name), [atom, name]);
|
|
7
|
-
const [state, dispatch, getCurrentState] = useQpqRuntimeBubblingReducer(atom, name);
|
|
8
|
-
// Api generators are memoized to prevent unnecessary re-renders.
|
|
9
|
-
const [memoedApiGenerators] = useState(() => atomInfo.api);
|
|
10
|
-
const mergedProcessors = async (qpqConfig, dynamicModuleLoader) => ({
|
|
11
|
-
...(await getStateActionProcessor(dispatch, getCurrentState)(qpqConfig, dynamicModuleLoader)),
|
|
12
|
-
...(await getActionProcessors(dispatch, getCurrentState)(qpqConfig, dynamicModuleLoader)),
|
|
13
|
-
});
|
|
14
|
-
const resolver = useQpq(mergedProcessors);
|
|
15
|
-
// Wrap and remap each API generator using the resolver.
|
|
16
|
-
const api = useMemo(() => {
|
|
17
|
-
const wrapped = {};
|
|
18
|
-
for (const key in memoedApiGenerators) {
|
|
19
|
-
if (Object.prototype.hasOwnProperty.call(memoedApiGenerators, key)) {
|
|
20
|
-
// Remove the 'ask' prefix and lower-case the first character.
|
|
21
|
-
const withoutAsk = key.slice(3); // e.g., "FetchTodos"
|
|
22
|
-
const newKey = withoutAsk.charAt(0).toLowerCase() + withoutAsk.slice(1); // "fetchTodos"
|
|
23
|
-
// We know newKey matches our mapped type so we can assign.
|
|
24
|
-
// (A type assertion is used here to quiet the compiler.)
|
|
25
|
-
wrapped[newKey] = resolver(memoedApiGenerators[key]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return wrapped;
|
|
29
|
-
}, [resolver, memoedApiGenerators]);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (mainStory) {
|
|
32
|
-
resolver(mainStory)();
|
|
33
|
-
}
|
|
34
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
-
}, []);
|
|
36
|
-
return [api, state, dispatch];
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=useQpqRuntime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useQpqRuntime.js","sourceRoot":"","sources":["../../../../src/hooks/asmj/useQpqRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAS/D,MAAM,UAAU,aAAa,CAM3B,IAAiD,EACjD,SAA2B,EAC3B,IAAa,EACb,sBAAkE,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IAExF,MAAM,QAAQ,GAAG,OAAO,CAAC,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,4BAA4B,CAAwB,IAAI,EAAE,IAAI,CAAC,CAAC;IAE3G,iEAAiE;IACjE,MAAM,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE3D,MAAM,gBAAgB,GAAgC,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC/F,GAAG,CAAC,MAAM,uBAAuB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAC7F,GAAG,CAAC,MAAM,mBAAmB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;KAC1F,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAE1C,wDAAwD;IACxD,MAAM,GAAG,GAAG,OAAO,CAAC,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,SAAS,CAAC,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"]}
|
|
File without changes
|
|
File without changes
|
/package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.d.ts
RENAMED
|
File without changes
|
/package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.js
RENAMED
|
File without changes
|
/package/lib/commonjs/{hooks/asmj → runtime}/actionProcessor/getStateReadActionProcessor.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/esm/{hooks/asmj → runtime}/actionProcessor/getStateDispatchActionProcessor.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|