@wordpress/data 10.45.1-next.v.202604201441.0 → 10.45.1-next.v.202605131006.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/README.md +23 -0
- package/build/components/use-select/index.cjs.map +1 -1
- package/build/redux-store/index.cjs +8 -9
- package/build/redux-store/index.cjs.map +2 -2
- package/build-module/components/use-select/index.mjs.map +1 -1
- package/build-module/redux-store/index.mjs +8 -9
- package/build-module/redux-store/index.mjs.map +2 -2
- package/build-types/components/async-mode-provider/context.d.ts.map +1 -1
- package/build-types/components/registry-provider/context.d.ts.map +1 -1
- package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts.map +1 -1
- package/build-types/components/use-dispatch/use-dispatch.d.ts.map +1 -1
- package/build-types/components/with-dispatch/index.d.ts +1 -1
- package/build-types/components/with-dispatch/index.d.ts.map +1 -1
- package/build-types/components/with-registry/index.d.ts.map +1 -1
- package/build-types/components/with-select/index.d.ts.map +1 -1
- package/build-types/default-registry.d.ts.map +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/plugins/persistence/index.d.ts +3 -0
- package/build-types/plugins/persistence/index.d.ts.map +1 -1
- package/build-types/plugins/persistence/storage/default.d.ts.map +1 -1
- package/build-types/plugins/persistence/storage/object.d.ts.map +1 -1
- package/build-types/promise-middleware.d.ts.map +1 -1
- package/build-types/redux-store/index.d.ts.map +1 -1
- package/build-types/redux-store/keyed-reducer.d.ts.map +1 -1
- package/build-types/redux-store/metadata/actions.d.ts +9 -9
- package/build-types/redux-store/metadata/actions.d.ts.map +1 -1
- package/build-types/redux-store/metadata/reducer.d.ts.map +1 -1
- package/build-types/resolvers-cache-middleware.d.ts.map +1 -1
- package/build-types/store/index.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/components/use-select/index.ts +2 -2
- package/src/redux-store/index.ts +17 -12
- package/src/redux-store/test/index.js +32 -44
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -122,6 +122,29 @@ The `resolvers` option should be passed as an object where each key is the name
|
|
|
122
122
|
|
|
123
123
|
Resolvers, in combination with [thunks](https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/thunks.md#thunks-can-be-async), can be used to implement asynchronous data flows for your store.
|
|
124
124
|
|
|
125
|
+
##### Object-form resolvers
|
|
126
|
+
|
|
127
|
+
A resolver can be defined as an object with a `fulfill` method and optional `isFulfilled` and `shouldInvalidate` methods:
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
resolvers: {
|
|
131
|
+
getPage: {
|
|
132
|
+
fulfill: ( id ) => async ( { dispatch } ) => {
|
|
133
|
+
const data = await fetchPage( id );
|
|
134
|
+
dispatch( { type: 'RECEIVE_PAGE', id, data } );
|
|
135
|
+
},
|
|
136
|
+
isFulfilled: ( state, id ) => !! state.pages[ id ],
|
|
137
|
+
shouldInvalidate: ( action, id ) => action.type === 'INVALIDATE_PAGE' && action.id === id,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
A resolver can also be a plain function with `isFulfilled` or `shouldInvalidate` assigned as properties. It will be normalized into the `{ fulfill, isFulfilled, shouldInvalidate }` object form internally.
|
|
143
|
+
|
|
144
|
+
**`isFulfilled( state, ...args )`** lets you override the `hasFinishedResolution` meta selector for a given set of args. Normally, a resolver is skipped only when the resolution metadata records that it has already run for those args. With `isFulfilled`, you can look at the actual store state and decide that the data is already there: for example because it was loaded by a different resolver or preloaded server-side. When `isFulfilled` returns `true`, the `fulfill` method is not called and no resolution metadata is written.
|
|
145
|
+
|
|
146
|
+
**`shouldInvalidate( action, ...args )`** is called on every dispatched action for each set of args that has already been resolved. If it returns `true`, the resolution for those args is invalidated, causing the resolver to run again on the next selector call. This is useful for automatically re-fetching data when a related action signals that the cached result may be stale.
|
|
147
|
+
|
|
125
148
|
#### `controls` (deprecated)
|
|
126
149
|
|
|
127
150
|
To handle asynchronous data flows, it is recommended to use [thunks](https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/thunks.md#thunks-can-be-async) instead of `controls`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/use-select/index.ts"],
|
|
4
|
-
"sourcesContent": ["// useSelect is a low-level hook that intentionally breaks rules-of-hooks\n// in its internal helpers (_useStaticSelect, _useMappingSelect) where\n// hooks are called inside non-hook functions and conditionally dispatched.\n/* eslint-disable react-hooks/rules-of-hooks, react-compiler/react-compiler */\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\nimport type {\n\tMapSelect,\n\tSelectFunction,\n\tStoreDescriptor,\n\tAnyConfig,\n\tUseSelectReturn,\n\tDataRegistry,\n} from '../../types';\n\nconst renderQueue = createQueue();\n\nfunction warnOnUnstableReference(\n\ta: Record< string, unknown >,\n\tb: Record< string, unknown >\n): void {\n\tif ( ! a || ! b ) {\n\t\treturn;\n\t}\n\n\tconst keys =\n\t\ttypeof a === 'object' && typeof b === 'object'\n\t\t\t? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] )\n\t\t\t: [];\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn(\n\t\t'The `useSelect` hook returns different values when called with the same state and parameters.\\n' +\n\t\t\t'This can lead to unnecessary re-renders and performance issues if not fixed.\\n\\n' +\n\t\t\t'Non-equal value keys: %s\\n\\n',\n\t\tkeys.join( ', ' )\n\t);\n}\n\ninterface StoreSubscriber {\n\tsubscribe: ( listener: () => void ) => () => void;\n\tupdateStores: ( newStores: string[] ) => void;\n}\n\nfunction Store( registry: DataRegistry, suspense: boolean ) {\n\tconst select = ( suspense\n\t\t? registry.suspendSelect\n\t\t: registry.select ) as unknown as SelectFunction;\n\tconst queueContext = {};\n\tlet lastMapSelect: MapSelect | undefined;\n\tlet lastMapResult: unknown;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync: boolean | undefined;\n\tlet subscriber: StoreSubscriber | undefined;\n\tlet didWarnUnstableReference: boolean | undefined;\n\tconst storeStatesOnMount = new Map< string, unknown >();\n\n\tfunction getStoreState( name: string ): unknown {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores: string[] ): StoreSubscriber => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set< ( storeName: string ) => void >();\n\n\t\tfunction subscribe( listener: () => void ): () => void {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs: Array< VoidFunction > = [];\n\t\t\tfunction subscribeStore( storeName: string ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores: string[] ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect: MapSelect, isAsync: boolean ) => {\n\t\tfunction updateValue(): void {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null as string[] | null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( ( globalThis as any ).SCRIPT_DEBUG ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\twarnOnUnstableReference( mapResult, secondMapResult );\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current! ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current! );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current! );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber!.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName: StoreDescriptor< AnyConfig > | string ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect(\n\tsuspense: boolean,\n\tmapSelect: MapSelect,\n\tdeps: unknown[]\n) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @param mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n *\n * @return The selected data or store selectors.\n */\nexport default function useSelect<\n\tT extends MapSelect | StoreDescriptor< AnyConfig >,\n>( mapSelect: T, deps?: unknown[] ): UseSelectReturn< T > {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\n\treturn (\n\t\tstaticSelectMode\n\t\t\t? _useStaticSelect( mapSelect as StoreDescriptor< AnyConfig > )\n\t\t\t: _useMappingSelect( false, mapSelect as MapSelect, deps! )\n\t) as UseSelectReturn< T >;\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @param mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @throws A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect< T extends MapSelect >(\n\tmapSelect: T,\n\tdeps: unknown[]\n): ReturnType< T > {\n\treturn _useMappingSelect( true, mapSelect, deps ) as ReturnType< T >;\n}\n/* eslint-enable react-hooks/rules-of-hooks, react-compiler/react-compiler */\n"],
|
|
4
|
+
"sourcesContent": ["// useSelect is a low-level hook that intentionally breaks rules-of-hooks\n// in its internal helpers (_useStaticSelect, _useMappingSelect) where\n// hooks are called inside non-hook functions and conditionally dispatched.\n/* eslint-disable react-hooks/rules-of-hooks */\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\nimport type {\n\tMapSelect,\n\tSelectFunction,\n\tStoreDescriptor,\n\tAnyConfig,\n\tUseSelectReturn,\n\tDataRegistry,\n} from '../../types';\n\nconst renderQueue = createQueue();\n\nfunction warnOnUnstableReference(\n\ta: Record< string, unknown >,\n\tb: Record< string, unknown >\n): void {\n\tif ( ! a || ! b ) {\n\t\treturn;\n\t}\n\n\tconst keys =\n\t\ttypeof a === 'object' && typeof b === 'object'\n\t\t\t? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] )\n\t\t\t: [];\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn(\n\t\t'The `useSelect` hook returns different values when called with the same state and parameters.\\n' +\n\t\t\t'This can lead to unnecessary re-renders and performance issues if not fixed.\\n\\n' +\n\t\t\t'Non-equal value keys: %s\\n\\n',\n\t\tkeys.join( ', ' )\n\t);\n}\n\ninterface StoreSubscriber {\n\tsubscribe: ( listener: () => void ) => () => void;\n\tupdateStores: ( newStores: string[] ) => void;\n}\n\nfunction Store( registry: DataRegistry, suspense: boolean ) {\n\tconst select = ( suspense\n\t\t? registry.suspendSelect\n\t\t: registry.select ) as unknown as SelectFunction;\n\tconst queueContext = {};\n\tlet lastMapSelect: MapSelect | undefined;\n\tlet lastMapResult: unknown;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync: boolean | undefined;\n\tlet subscriber: StoreSubscriber | undefined;\n\tlet didWarnUnstableReference: boolean | undefined;\n\tconst storeStatesOnMount = new Map< string, unknown >();\n\n\tfunction getStoreState( name: string ): unknown {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores: string[] ): StoreSubscriber => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set< ( storeName: string ) => void >();\n\n\t\tfunction subscribe( listener: () => void ): () => void {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs: Array< VoidFunction > = [];\n\t\t\tfunction subscribeStore( storeName: string ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores: string[] ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect: MapSelect, isAsync: boolean ) => {\n\t\tfunction updateValue(): void {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null as string[] | null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( ( globalThis as any ).SCRIPT_DEBUG ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\twarnOnUnstableReference( mapResult, secondMapResult );\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current! ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current! );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current! );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber!.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName: StoreDescriptor< AnyConfig > | string ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect(\n\tsuspense: boolean,\n\tmapSelect: MapSelect,\n\tdeps: unknown[]\n) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @param mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n *\n * @return The selected data or store selectors.\n */\nexport default function useSelect<\n\tT extends MapSelect | StoreDescriptor< AnyConfig >,\n>( mapSelect: T, deps?: unknown[] ): UseSelectReturn< T > {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\n\treturn (\n\t\tstaticSelectMode\n\t\t\t? _useStaticSelect( mapSelect as StoreDescriptor< AnyConfig > )\n\t\t\t: _useMappingSelect( false, mapSelect as MapSelect, deps! )\n\t) as UseSelectReturn< T >;\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @param mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @throws A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect< T extends MapSelect >(\n\tmapSelect: T,\n\tdeps: unknown[]\n): ReturnType< T > {\n\treturn _useMappingSelect( true, mapSelect, deps ) as ReturnType< T >;\n}\n/* eslint-enable react-hooks/rules-of-hooks */\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,4BAA4B;AAC5B,qBAMO;AACP,8BAA+B;AAK/B,0BAAwB;AACxB,4BAAyB;AAUzB,IAAM,kBAAc,mCAAY;AAEhC,SAAS,wBACR,GACA,GACO;AACP,MAAK,CAAE,KAAK,CAAE,GAAI;AACjB;AAAA,EACD;AAEA,QAAM,OACL,OAAO,MAAM,YAAY,OAAO,MAAM,WACnC,OAAO,KAAM,CAAE,EAAE,OAAQ,CAAE,MAAO,EAAG,CAAE,MAAM,EAAG,CAAE,CAAE,IACpD,CAAC;AAGL,UAAQ;AAAA,IACP;AAAA,IAGA,KAAK,KAAM,IAAK;AAAA,EACjB;AACD;AAOA,SAAS,MAAO,UAAwB,UAAoB;AAC3D,QAAM,SAAW,WACd,SAAS,gBACT,S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C;AACD,QAAM,eAAW,oBAAAA,SAAY;AAC7B,QAAM,cAAU,sBAAAC,SAAa;AAC7B,QAAM,YAAQ;AAAA,IACb,MAAM,MAAO,UAAU,QAAS;AAAA,IAChC,CAAE,UAAU,QAAS;AAAA,EACtB;AAKA,QAAM,eAAW,4BAAa,WAAW,IAAK;AAC9C,QAAM,EAAE,WAAW,SAAS,IAAI,MAAO,UAAU,OAAQ;AACzD,QAAM,aAAS,qCAAsB,WAAW,UAAU,QAAS;AACnE,oCAAe,MAAO;AACtB,SAAO;AACR;AAkEe,SAAR,UAEJ,WAAc,MAAyC;AAGzD,QAAM,mBAAmB,OAAO,cAAc;AAC9C,QAAM,0BAAsB,uBAAQ,gBAAiB;AAErD,MAAK,qBAAqB,oBAAoB,SAAU;AACvD,UAAM,WAAW,oBAAoB,UAAU,WAAW;AAC1D,UAAM,WAAW,mBAAmB,WAAW;AAC/C,UAAM,IAAI;AAAA,MACT,4BAA6B,QAAS,OAAQ,QAAS;AAAA,IACxD;AAAA,EACD;AAKA,SACC,mBACG,iBAAkB,SAA0C,IAC5D,kBAAmB,OAAO,WAAwB,IAAM;AAE7D;AAoBO,SAAS,kBACf,WACA,MACkB;AAClB,SAAO,kBAAmB,MAAM,WAAW,IAAK;AACjD;",
|
|
6
6
|
"names": ["useRegistry", "useAsyncMode"]
|
|
7
7
|
}
|
|
@@ -262,6 +262,7 @@ function createReduxStore(key, options) {
|
|
|
262
262
|
(0, import_lock_unlock.lock)(selectors, allSelectors);
|
|
263
263
|
const bindResolveSelector = mapResolveSelector(
|
|
264
264
|
store,
|
|
265
|
+
resolvers,
|
|
265
266
|
boundMetadataSelectors
|
|
266
267
|
);
|
|
267
268
|
const resolveSelectors = mapValues(
|
|
@@ -369,17 +370,18 @@ function instantiateReduxStore(key, options, registry, thunkArgs) {
|
|
|
369
370
|
(0, import_compose.compose)(...enhancers)
|
|
370
371
|
);
|
|
371
372
|
}
|
|
372
|
-
function mapResolveSelector(store, boundMetadataSelectors) {
|
|
373
|
+
function mapResolveSelector(store, resolvers, boundMetadataSelectors) {
|
|
373
374
|
return (selector, selectorName) => {
|
|
374
375
|
if (!selector.hasResolver) {
|
|
375
376
|
return async (...args) => selector(...args);
|
|
376
377
|
}
|
|
377
378
|
return (...args) => new Promise((resolve, reject) => {
|
|
379
|
+
const resolver = resolvers[selectorName];
|
|
378
380
|
const hasFinished = () => {
|
|
379
381
|
return boundMetadataSelectors.hasFinishedResolution(
|
|
380
382
|
selectorName,
|
|
381
383
|
args
|
|
382
|
-
);
|
|
384
|
+
) || typeof resolver.isFulfilled === "function" && resolver.isFulfilled(store.getState(), ...args);
|
|
383
385
|
};
|
|
384
386
|
const finalize = (result2) => {
|
|
385
387
|
const hasFailed = boundMetadataSelectors.hasResolutionFailed(
|
|
@@ -459,7 +461,7 @@ function mapResolver(resolver) {
|
|
|
459
461
|
}
|
|
460
462
|
function mapSelectorWithResolver(selector, selectorName, resolver, store, resolversCache, boundMetadataSelectors) {
|
|
461
463
|
function fulfillSelector(args) {
|
|
462
|
-
if (resolversCache.isRunning(selectorName, args) || boundMetadataSelectors.hasStartedResolution(selectorName, args)) {
|
|
464
|
+
if (resolversCache.isRunning(selectorName, args) || boundMetadataSelectors.hasStartedResolution(selectorName, args) || typeof resolver.isFulfilled === "function" && resolver.isFulfilled(store.getState(), ...args)) {
|
|
463
465
|
return;
|
|
464
466
|
}
|
|
465
467
|
resolversCache.markAsRunning(selectorName, args);
|
|
@@ -469,12 +471,9 @@ function mapSelectorWithResolver(selector, selectorName, resolver, store, resolv
|
|
|
469
471
|
metadataActions.startResolution(selectorName, args)
|
|
470
472
|
);
|
|
471
473
|
try {
|
|
472
|
-
const
|
|
473
|
-
if (
|
|
474
|
-
|
|
475
|
-
if (action) {
|
|
476
|
-
await store.dispatch(action);
|
|
477
|
-
}
|
|
474
|
+
const action = resolver.fulfill(...args);
|
|
475
|
+
if (action) {
|
|
476
|
+
await store.dispatch(action);
|
|
478
477
|
}
|
|
479
478
|
store.dispatch(
|
|
480
479
|
metadataActions.finishResolution(selectorName, args)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/redux-store/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport type { Store as ReduxStore, StoreEnhancer } from 'redux';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { combineReducers } from './combine-reducers';\nimport { builtinControls } from '../controls';\nimport { lock } from '../lock-unlock';\nimport promise from '../promise-middleware';\nimport createResolversCacheMiddleware from '../resolvers-cache-middleware';\nimport createThunkMiddleware from './thunk-middleware';\nimport metadataReducer from './metadata/reducer';\nimport * as metadataSelectors from './metadata/selectors';\nimport * as metadataActions from './metadata/actions';\nimport type {\n\tDataRegistry,\n\tListenerFunction,\n\tStoreDescriptor,\n\tReduxStoreConfig,\n\tActionCreator,\n\tNormalizedResolver,\n} from '../types';\n\nexport { combineReducers };\n\n/**\n * Augment the Redux store with internal properties used by the data module.\n */\ninterface AugmentedReduxStore extends ReduxStore {\n\t__unstableOriginalGetState: ReduxStore[ 'getState' ];\n}\n\ninterface ResolversCache {\n\tisRunning: ( selectorName: string, args: unknown[] ) => boolean;\n\tclear: ( selectorName: string, args: unknown[] ) => void;\n\tmarkAsRunning: ( selectorName: string, args: unknown[] ) => void;\n}\n\ninterface BindingCache {\n\tget: ( itemName: string ) => ( ( ...args: unknown[] ) => unknown ) | null;\n}\n\ninterface SelectorLike {\n\t( ...args: any[] ): any;\n\thasResolver?: boolean;\n\tisRegistrySelector?: boolean;\n\tregistry?: DataRegistry;\n\t__unstableNormalizeArgs?: ( args: unknown[] ) => unknown[];\n}\n\nconst trimUndefinedValues = ( array: unknown[] ): unknown[] => {\n\tconst result = [ ...array ];\n\tfor ( let i = result.length - 1; i >= 0; i-- ) {\n\t\tif ( result[ i ] === undefined ) {\n\t\t\tresult.splice( i, 1 );\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param obj The object to transform.\n * @param callback The function to transform each object value.\n * @return Transformed object.\n */\nconst mapValues = < T, U >(\n\tobj: Record< string, T > | undefined,\n\tcallback: ( value: T, key: string ) => U\n): Record< string, U > =>\n\tObject.fromEntries(\n\t\tObject.entries( obj ?? {} ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tcallback( value, key ),\n\t\t] )\n\t);\n\n// Convert non serializable types to plain objects\nconst devToolsReplacer = ( _key: string, state: unknown ): unknown => {\n\tif ( state instanceof Map ) {\n\t\treturn Object.fromEntries( state );\n\t}\n\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\tstate instanceof window.HTMLElement\n\t) {\n\t\treturn null;\n\t}\n\n\treturn state;\n};\n\n/**\n * Create a cache to track whether resolvers started running or not.\n *\n * @return Resolvers Cache.\n */\nfunction createResolversCache(): ResolversCache {\n\tconst cache: Record< string, EquivalentKeyMap< unknown[], boolean > > = {};\n\treturn {\n\t\tisRunning( selectorName: string, args: unknown[] ): boolean {\n\t\t\treturn !! (\n\t\t\t\tcache[ selectorName ] &&\n\t\t\t\tcache[ selectorName ].get( trimUndefinedValues( args ) )\n\t\t\t);\n\t\t},\n\n\t\tclear( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ].delete( trimUndefinedValues( args ) );\n\t\t\t}\n\t\t},\n\n\t\tmarkAsRunning( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( ! cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ] = new EquivalentKeyMap();\n\t\t\t}\n\n\t\t\tcache[ selectorName ].set( trimUndefinedValues( args ), true );\n\t\t},\n\t};\n}\n\nfunction createBindingCache(\n\tgetItem: ( name: string ) => ( ( ...args: any[] ) => any ) | undefined,\n\tbindItem: (\n\t\titem: ( ...args: any[] ) => any,\n\t\tname: string\n\t) => ( ...args: unknown[] ) => unknown\n): BindingCache {\n\tconst cache = new WeakMap<\n\t\t( ...args: any[] ) => any,\n\t\t( ...args: unknown[] ) => unknown\n\t>();\n\n\treturn {\n\t\tget( itemName: string ) {\n\t\t\tconst item = getItem( itemName );\n\t\t\tif ( ! item ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet boundItem = cache.get( item );\n\t\t\tif ( ! boundItem ) {\n\t\t\t\tboundItem = bindItem( item, itemName );\n\t\t\t\tcache.set( item, boundItem );\n\t\t\t}\n\t\t\treturn boundItem;\n\t\t},\n\t};\n}\n\nfunction createPrivateProxy< T extends Record< string, any > >(\n\tpublicItems: T,\n\tprivateItems: BindingCache\n): T {\n\treturn new Proxy( publicItems, {\n\t\tget: ( target, itemName: string ) =>\n\t\t\tprivateItems.get( itemName ) || Reflect.get( target, itemName ),\n\t} );\n}\n\n/**\n * Creates a data store descriptor for the provided Redux store configuration containing\n * properties describing reducer, actions, selectors, controls and resolvers.\n *\n * @example\n * ```js\n * import { createReduxStore } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * ```\n *\n * @param key Unique namespace identifier.\n * @param options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return Store Object.\n */\nexport default function createReduxStore< State, Actions, Selectors >(\n\tkey: string,\n\toptions: ReduxStoreConfig< State, Actions, Selectors >\n): StoreDescriptor< ReduxStoreConfig< State, Actions, Selectors > > {\n\tconst privateActions: Record< string, ActionCreator > = {};\n\tconst privateSelectors: Record< string, SelectorLike > = {};\n\tconst privateRegistrationFunctions = {\n\t\tprivateActions,\n\t\tregisterPrivateActions: (\n\t\t\tactions: Record< string, ActionCreator >\n\t\t) => {\n\t\t\tObject.assign( privateActions, actions );\n\t\t},\n\t\tprivateSelectors,\n\t\tregisterPrivateSelectors: (\n\t\t\tselectors: Record< string, SelectorLike >\n\t\t) => {\n\t\t\tObject.assign( privateSelectors, selectors );\n\t\t},\n\t};\n\tconst storeDescriptor = {\n\t\tname: key,\n\t\tinstantiate: ( registry: DataRegistry ) => {\n\t\t\t/**\n\t\t\t * Stores listener functions registered with `subscribe()`.\n\t\t\t *\n\t\t\t * When functions register to listen to store changes with\n\t\t\t * `subscribe()` they get added here. Although Redux offers\n\t\t\t * its own `subscribe()` function directly, by wrapping the\n\t\t\t * subscription in this store instance it's possible to\n\t\t\t * optimize checking if the state has changed before calling\n\t\t\t * each listener.\n\t\t\t */\n\t\t\tconst listeners = new Set< ListenerFunction >();\n\t\t\tconst reducer = options.reducer;\n\n\t\t\t// Object that every thunk function receives as the first argument. It contains the\n\t\t\t// `registry`, `dispatch`, `select` and `resolveSelect` fields. Some of them are\n\t\t\t// constructed as getters to avoid circular dependencies.\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn thunkDispatch;\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn thunkSelect;\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn resolveSelectors;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst store = instantiateReduxStore(\n\t\t\t\tkey,\n\t\t\t\toptions,\n\t\t\t\tregistry,\n\t\t\t\tthunkArgs\n\t\t\t) as AugmentedReduxStore;\n\n\t\t\t// Expose the private registration functions on the store\n\t\t\t// so they can be copied to a sub registry in registry.js.\n\t\t\tlock( store, privateRegistrationFunctions );\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\t// Binds an action creator (`action`) to the `store`, making it a callable function.\n\t\t\t// These are the functions that are returned by `useDispatch`, for example.\n\t\t\t// It always returns a `Promise`, although actions are not always async. That's an\n\t\t\t// unfortunate backward compatibility measure.\n\t\t\tfunction bindAction( action: ( ...args: any[] ) => any ) {\n\t\t\t\treturn ( ...args: unknown[] ) =>\n\t\t\t\t\tPromise.resolve( store.dispatch( action( ...args ) ) );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Object with all public actions, both metadata and store actions.\n\t\t\t */\n\t\t\tconst actions = {\n\t\t\t\t...mapValues(\n\t\t\t\t\tmetadataActions as Record< string, ActionCreator >,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t\t...mapValues(\n\t\t\t\t\toptions.actions as\n\t\t\t\t\t\t| Record< string, ActionCreator >\n\t\t\t\t\t\t| undefined,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t};\n\n\t\t\t// Object with both public and private actions. Private actions are accessed through a proxy,\n\t\t\t// which looks them up in real time on the `privateActions` object. That's because private\n\t\t\t// actions can be registered at any time with `registerPrivateActions`. Also once a private\n\t\t\t// action creator is bound to the store, it is cached to give it a stable identity.\n\t\t\tconst allActions = createPrivateProxy(\n\t\t\t\tactions,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => privateActions[ name ],\n\t\t\t\t\tbindAction\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// An object that implements the `dispatch` object that is passed to thunk functions.\n\t\t\t// It is callable (`dispatch( action )`) and also has methods (`dispatch.foo()`) that\n\t\t\t// correspond to bound registered actions, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allActions`.\n\t\t\tconst thunkDispatch = new Proxy(\n\t\t\t\t( action: any ) => store.dispatch( action ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allActions[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `actions` object, add the \"locked\" `allActions` object. When used,\n\t\t\t// `unlock( actions )` will return `allActions`, implementing a way how to get at the private actions.\n\t\t\tlock( actions, allActions );\n\n\t\t\t// If we have selector resolvers, convert them to a normalized form.\n\t\t\tconst resolvers: Record< string, NormalizedResolver > =\n\t\t\t\toptions.resolvers\n\t\t\t\t\t? mapValues(\n\t\t\t\t\t\t\toptions.resolvers as Record< string, any >,\n\t\t\t\t\t\t\tmapResolver\n\t\t\t\t\t )\n\t\t\t\t\t: {};\n\n\t\t\t// Bind a selector to the store. Call the selector with the current state, correct registry,\n\t\t\t// and if there is a resolver, attach the resolver logic to the selector.\n\t\t\tfunction bindSelector(\n\t\t\t\tselector: SelectorLike,\n\t\t\t\tselectorName: string\n\t\t\t): SelectorLike {\n\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\tselector.registry = registry;\n\t\t\t\t}\n\t\t\t\tconst boundSelector: SelectorLike = ( ...args: any[] ) => {\n\t\t\t\t\targs = normalize( selector, args );\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t// Before calling the selector, switch to the correct registry.\n\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t}\n\t\t\t\t\treturn selector( state.root, ...args );\n\t\t\t\t};\n\n\t\t\t\t// Expose normalization method on the bound selector\n\t\t\t\t// in order that it can be called when fulfilling\n\t\t\t\t// the resolver.\n\t\t\t\tboundSelector.__unstableNormalizeArgs =\n\t\t\t\t\tselector.__unstableNormalizeArgs;\n\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\n\t\t\t\tif ( ! resolver ) {\n\t\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\t\treturn boundSelector;\n\t\t\t\t}\n\n\t\t\t\treturn mapSelectorWithResolver(\n\t\t\t\t\tboundSelector,\n\t\t\t\t\tselectorName,\n\t\t\t\t\tresolver,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache,\n\t\t\t\t\tboundMetadataSelectors\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Metadata selectors are bound differently: different state (`state.metadata`), no resolvers,\n\t\t\t// normalization depending on the target selector.\n\t\t\tfunction bindMetadataSelector(\n\t\t\t\tmetaDataSelector: ( ...args: any[] ) => any\n\t\t\t): SelectorLike {\n\t\t\t\tconst boundSelector: SelectorLike = (\n\t\t\t\t\tselectorName: string,\n\t\t\t\t\tselectorArgs: unknown[],\n\t\t\t\t\t...args: unknown[]\n\t\t\t\t) => {\n\t\t\t\t\t// Normalize the arguments passed to the target selector.\n\t\t\t\t\tif ( selectorName ) {\n\t\t\t\t\t\tconst targetSelector = ( options.selectors as any )?.[\n\t\t\t\t\t\t\tselectorName\n\t\t\t\t\t\t];\n\t\t\t\t\t\tif ( targetSelector ) {\n\t\t\t\t\t\t\tselectorArgs = normalize(\n\t\t\t\t\t\t\t\ttargetSelector,\n\t\t\t\t\t\t\t\tselectorArgs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\n\t\t\t\t\treturn metaDataSelector(\n\t\t\t\t\t\tstate.metadata,\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tselectorArgs,\n\t\t\t\t\t\t...args\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\treturn boundSelector;\n\t\t\t}\n\n\t\t\t// Perform binding of both metadata and store selectors and combine them in one\n\t\t\t// `selectors` object. These are all public selectors of the store.\n\t\t\tconst boundMetadataSelectors = mapValues(\n\t\t\t\tmetadataSelectors as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\t( ...args: any[] ) => any\n\t\t\t\t>,\n\t\t\t\tbindMetadataSelector\n\t\t\t);\n\n\t\t\tconst boundSelectors = mapValues(\n\t\t\t\toptions.selectors as Record< string, SelectorLike > | undefined,\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst selectors = {\n\t\t\t\t...boundMetadataSelectors,\n\t\t\t\t...boundSelectors,\n\t\t\t};\n\n\t\t\t// Cache of bound private selectors. They are bound only when first accessed, because\n\t\t\t// new private selectors can be registered at any time (with `registerPrivateSelectors`).\n\t\t\t// Once bound, they are cached to give them a stable identity.\n\t\t\tconst boundPrivateSelectors = createBindingCache(\n\t\t\t\t( name ) => privateSelectors[ name ],\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst allSelectors = createPrivateProxy(\n\t\t\t\tselectors,\n\t\t\t\tboundPrivateSelectors\n\t\t\t);\n\n\t\t\t// Pre-bind the private selectors that have been registered by the time of\n\t\t\t// instantiation, so that registry selectors are bound to the registry.\n\t\t\tfor ( const selectorName of Object.keys( privateSelectors ) ) {\n\t\t\t\tboundPrivateSelectors.get( selectorName );\n\t\t\t}\n\n\t\t\t// An object that implements the `select` object that is passed to thunk functions.\n\t\t\t// It is callable (`select( selector )`) and also has methods (`select.foo()`) that\n\t\t\t// correspond to bound registered selectors, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allSelectors`.\n\t\t\tconst thunkSelect = new Proxy(\n\t\t\t\t( selector: ( state: any ) => any ) =>\n\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allSelectors[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `selectors` object, add the \"locked\" `allSelectors` object. When used,\n\t\t\t// `unlock( selectors )` will return `allSelectors`, implementing a way how to get at the private selectors.\n\t\t\tlock( selectors, allSelectors );\n\n\t\t\t// For each selector, create a function that calls the selector, waits for resolution and returns\n\t\t\t// a promise that resolves when the resolution is finished.\n\t\t\tconst bindResolveSelector = mapResolveSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\t// Now apply this function to all bound selectors, public and private. We are excluding\n\t\t\t// metadata selectors because they don't have resolvers.\n\t\t\tconst resolveSelectors = mapValues(\n\t\t\t\tboundSelectors,\n\t\t\t\tbindResolveSelector\n\t\t\t);\n\n\t\t\tconst allResolveSelectors = createPrivateProxy(\n\t\t\t\tresolveSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindResolveSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( resolveSelectors )` returns `allResolveSelectors`.\n\t\t\tlock( resolveSelectors, allResolveSelectors );\n\n\t\t\t// Now, in a way very similar to `bindResolveSelector`, we create a function that maps\n\t\t\t// selectors to functions that throw a suspense promise if not yet resolved.\n\t\t\tconst bindSuspendSelector = mapSuspendSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\tconst suspendSelectors = {\n\t\t\t\t...boundMetadataSelectors, // no special suspense behavior\n\t\t\t\t...mapValues( boundSelectors, bindSuspendSelector ),\n\t\t\t};\n\n\t\t\tconst allSuspendSelectors = createPrivateProxy(\n\t\t\t\tsuspendSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindSuspendSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( suspendSelectors )` returns 'allSuspendSelectors`.\n\t\t\tlock( suspendSelectors, allSuspendSelectors );\n\n\t\t\tconst getSelectors = () => selectors;\n\t\t\tconst getActions = () => actions;\n\t\t\tconst getResolveSelectors = () => resolveSelectors;\n\t\t\tconst getSuspendSelectors = () => suspendSelectors;\n\n\t\t\t// We have some modules monkey-patching the store object\n\t\t\t// It's wrong to do so but until we refactor all of our effects to controls\n\t\t\t// We need to keep the same \"store\" instance here.\n\t\t\tstore.__unstableOriginalGetState = store.getState;\n\t\t\tstore.getState = () => store.__unstableOriginalGetState().root;\n\n\t\t\t// Customize subscribe behavior to call listeners only on effective change,\n\t\t\t// not on every dispatch.\n\t\t\tconst subscribe = ( listener: ListenerFunction ) => {\n\t\t\t\tlisteners.add( listener );\n\n\t\t\t\treturn () => listeners.delete( listener );\n\t\t\t};\n\n\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\tstore.subscribe( () => {\n\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\tlastState = state;\n\n\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\tfor ( const listener of listeners ) {\n\t\t\t\t\t\tlistener();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// This can be simplified to just { subscribe, getSelectors, getActions }\n\t\t\t// Once we remove the use function.\n\t\t\treturn {\n\t\t\t\treducer,\n\t\t\t\tstore,\n\t\t\t\tactions,\n\t\t\t\tselectors,\n\t\t\t\tresolvers,\n\t\t\t\tgetSelectors,\n\t\t\t\tgetResolveSelectors,\n\t\t\t\tgetSuspendSelectors,\n\t\t\t\tgetActions,\n\t\t\t\tsubscribe,\n\t\t\t};\n\t\t},\n\t};\n\n\t// Expose the private registration functions on the store\n\t// descriptor. That's a natural choice since that's where the\n\t// public actions and selectors are stored.\n\tlock( storeDescriptor, privateRegistrationFunctions );\n\n\treturn storeDescriptor as unknown as StoreDescriptor<\n\t\tReduxStoreConfig< State, Actions, Selectors >\n\t>;\n}\n\n/**\n * Creates a redux store for a namespace.\n *\n * @param key Unique namespace identifier.\n * @param options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param registry Registry reference.\n * @param thunkArgs Argument object for the thunk middleware.\n * @return Newly created redux store.\n */\nfunction instantiateReduxStore(\n\tkey: string,\n\toptions: ReduxStoreConfig< any, any, any >,\n\tregistry: DataRegistry,\n\tthunkArgs: unknown\n): ReduxStore {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control: any ) =>\n\t\tcontrol.isRegistryControl ? control( registry ) : control\n\t);\n\n\tconst middlewares = [\n\t\tcreateResolversCacheMiddleware( registry, key ),\n\t\tpromise,\n\t\tcreateReduxRoutineMiddleware( normalizedControls ),\n\t\tcreateThunkMiddleware( thunkArgs ),\n\t];\n\n\tconst enhancers: StoreEnhancer[] = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\n\t\t\t\tserialize: {\n\t\t\t\t\treplacer: devToolsReplacer,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst { reducer, initialState } = options;\n\tconst enhancedReducer = combineReducers( {\n\t\tmetadata: metadataReducer,\n\t\troot: reducer,\n\t} );\n\n\treturn createStore(\n\t\tenhancedReducer,\n\t\t{ root: initialState } as any,\n\t\tcompose( ...enhancers ) as unknown as StoreEnhancer\n\t);\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them.\n *\n * @param store The redux store the selectors are bound to.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to resolvers.\n */\nfunction mapResolveSelector(\n\tstore: ReduxStore,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// If the selector doesn't have a resolver, just convert the return value\n\t\t// (including exceptions) to a Promise, no additional extra behavior is needed.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn async ( ...args: unknown[] ) => selector( ...args );\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) =>\n\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () => {\n\t\t\t\t\treturn boundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst finalize = ( result: unknown ) => {\n\t\t\t\t\tconst hasFailed =\n\t\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve( result );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst getResult = () => selector( ...args );\n\n\t\t\t\t// Trigger the selector (to trigger the resolver)\n\t\t\t\tconst result = getResult();\n\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\treturn finalize( result );\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\tfinalize( getResult() );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t};\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param store The redux store the selectors select from.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to their suspending versions.\n */\nfunction mapSuspendSelector(\n\tstore: ReduxStore,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// Selector without a resolver doesn't have any extra suspense behavior.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn selector;\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) => {\n\t\t\tconst result = selector( ...args );\n\n\t\t\tif (\n\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\tselectorName,\n\t\t\t\t\targs\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise< void >( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t};\n}\n\n/**\n * Convert a resolver to a normalized form, an object with `fulfill` method and\n * optional methods like `isFulfilled`.\n *\n * @param resolver Resolver to convert\n */\nfunction mapResolver( resolver: any ): NormalizedResolver {\n\tif ( resolver.fulfill ) {\n\t\treturn resolver;\n\t}\n\n\treturn {\n\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\tfulfill: resolver, // Add the fulfill method.\n\t};\n}\n\n/**\n * Returns a selector with a matched resolver.\n * Resolvers are side effects invoked once per argument set of a given selector call,\n * used in ensuring that the data needs for the selector are satisfied.\n *\n * @param selector The selector function to be bound.\n * @param selectorName The selector name.\n * @param resolver Resolver to call.\n * @param store The redux store to which the resolvers should be mapped.\n * @param resolversCache Resolvers Cache.\n * @param boundMetadataSelectors The bound metadata selectors.\n */\nfunction mapSelectorWithResolver(\n\tselector: SelectorLike,\n\tselectorName: string,\n\tresolver: NormalizedResolver,\n\tstore: AugmentedReduxStore,\n\tresolversCache: ResolversCache,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n): SelectorLike {\n\tfunction fulfillSelector( args: unknown[] ): void {\n\t\tif (\n\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\tboundMetadataSelectors.hasStartedResolution( selectorName, args )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\tsetTimeout( async () => {\n\t\t\tresolversCache.clear( selectorName, args );\n\t\t\tstore.dispatch(\n\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tconst isFulfilled =\n\t\t\t\t\ttypeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\tresolver.isFulfilled( store.getState(), ...args );\n\t\t\t\tif ( ! isFulfilled ) {\n\t\t\t\t\tconst action = resolver.fulfill( ...args );\n\t\t\t\t\tif ( action ) {\n\t\t\t\t\t\tawait store.dispatch( action );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.finishResolution( selectorName, args )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.failResolution( selectorName, args, error )\n\t\t\t\t);\n\t\t\t}\n\t\t}, 0 );\n\t}\n\n\tconst selectorResolver: SelectorLike = ( ...args: unknown[] ) => {\n\t\targs = normalize( selector, args );\n\t\tfulfillSelector( args );\n\t\treturn selector( ...args );\n\t};\n\tselectorResolver.hasResolver = true;\n\treturn selectorResolver;\n}\n\n/**\n * Applies selector's normalization function to the given arguments\n * if it exists.\n *\n * @param selector The selector potentially with a normalization method property.\n * @param args selector arguments to normalize.\n * @return Potentially normalized arguments.\n */\nfunction normalize( selector: SelectorLike, args: unknown[] ): unknown[] {\n\tif (\n\t\tselector.__unstableNormalizeArgs &&\n\t\ttypeof selector.__unstableNormalizeArgs === 'function' &&\n\t\targs?.length\n\t) {\n\t\treturn selector.__unstableNormalizeArgs( args );\n\t}\n\treturn args;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA6C;AAE7C,gCAA6B;AAK7B,2BAAyC;AACzC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D;AAEA,QAAM,cAAc;AAAA,QACnB,kCAAAC,SAAgC,UAAU,GAAI;AAAA,IAC9C,0BAAAC;AAAA,QACA,qBAAAC,SAA8B,kBAAmB;AAAA,QACjD,wBAAAC,SAAuB,SAAU;AAAA,EAClC;AAEA,QAAM,YAA6B,KAAE,8BAAiB,GAAG,WAAY,CAAE;AACvE,MACC,OAAO,WAAW,eAChB,OAAgB,8BACjB;AACD,cAAU;AAAA,MACP,OAAgB,6BAA8B;AAAA,QAC/C,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,WAAW;AAAA,UACV,UAAU;AAAA,QACX;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAEA,QAAM,EAAE,SAAS,aAAa,IAAI;AAClC,QAAM,sBAAkB,yCAAiB;AAAA,IACxC,UAAU,eAAAC;AAAA,IACV,MAAM;AAAA,EACP,CAAE;AAEF,aAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,aAAa;AAAA,QACrB,wBAAS,GAAG,SAAU;AAAA,EACvB;AACD;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport type { Store as ReduxStore, StoreEnhancer } from 'redux';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { combineReducers } from './combine-reducers';\nimport { builtinControls } from '../controls';\nimport { lock } from '../lock-unlock';\nimport promise from '../promise-middleware';\nimport createResolversCacheMiddleware from '../resolvers-cache-middleware';\nimport createThunkMiddleware from './thunk-middleware';\nimport metadataReducer from './metadata/reducer';\nimport * as metadataSelectors from './metadata/selectors';\nimport * as metadataActions from './metadata/actions';\nimport type {\n\tDataRegistry,\n\tListenerFunction,\n\tStoreDescriptor,\n\tReduxStoreConfig,\n\tActionCreator,\n\tNormalizedResolver,\n} from '../types';\n\nexport { combineReducers };\n\n/**\n * Augment the Redux store with internal properties used by the data module.\n */\ninterface AugmentedReduxStore extends ReduxStore {\n\t__unstableOriginalGetState: ReduxStore[ 'getState' ];\n}\n\ninterface ResolversCache {\n\tisRunning: ( selectorName: string, args: unknown[] ) => boolean;\n\tclear: ( selectorName: string, args: unknown[] ) => void;\n\tmarkAsRunning: ( selectorName: string, args: unknown[] ) => void;\n}\n\ninterface BindingCache {\n\tget: ( itemName: string ) => ( ( ...args: unknown[] ) => unknown ) | null;\n}\n\ninterface SelectorLike {\n\t( ...args: any[] ): any;\n\thasResolver?: boolean;\n\tisRegistrySelector?: boolean;\n\tregistry?: DataRegistry;\n\t__unstableNormalizeArgs?: ( args: unknown[] ) => unknown[];\n}\n\nconst trimUndefinedValues = ( array: unknown[] ): unknown[] => {\n\tconst result = [ ...array ];\n\tfor ( let i = result.length - 1; i >= 0; i-- ) {\n\t\tif ( result[ i ] === undefined ) {\n\t\t\tresult.splice( i, 1 );\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param obj The object to transform.\n * @param callback The function to transform each object value.\n * @return Transformed object.\n */\nconst mapValues = < T, U >(\n\tobj: Record< string, T > | undefined,\n\tcallback: ( value: T, key: string ) => U\n): Record< string, U > =>\n\tObject.fromEntries(\n\t\tObject.entries( obj ?? {} ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tcallback( value, key ),\n\t\t] )\n\t);\n\n// Convert non serializable types to plain objects\nconst devToolsReplacer = ( _key: string, state: unknown ): unknown => {\n\tif ( state instanceof Map ) {\n\t\treturn Object.fromEntries( state );\n\t}\n\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\tstate instanceof window.HTMLElement\n\t) {\n\t\treturn null;\n\t}\n\n\treturn state;\n};\n\n/**\n * Create a cache to track whether resolvers started running or not.\n *\n * @return Resolvers Cache.\n */\nfunction createResolversCache(): ResolversCache {\n\tconst cache: Record< string, EquivalentKeyMap< unknown[], boolean > > = {};\n\treturn {\n\t\tisRunning( selectorName: string, args: unknown[] ): boolean {\n\t\t\treturn !! (\n\t\t\t\tcache[ selectorName ] &&\n\t\t\t\tcache[ selectorName ].get( trimUndefinedValues( args ) )\n\t\t\t);\n\t\t},\n\n\t\tclear( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ].delete( trimUndefinedValues( args ) );\n\t\t\t}\n\t\t},\n\n\t\tmarkAsRunning( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( ! cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ] = new EquivalentKeyMap();\n\t\t\t}\n\n\t\t\tcache[ selectorName ].set( trimUndefinedValues( args ), true );\n\t\t},\n\t};\n}\n\nfunction createBindingCache(\n\tgetItem: ( name: string ) => ( ( ...args: any[] ) => any ) | undefined,\n\tbindItem: (\n\t\titem: ( ...args: any[] ) => any,\n\t\tname: string\n\t) => ( ...args: unknown[] ) => unknown\n): BindingCache {\n\tconst cache = new WeakMap<\n\t\t( ...args: any[] ) => any,\n\t\t( ...args: unknown[] ) => unknown\n\t>();\n\n\treturn {\n\t\tget( itemName: string ) {\n\t\t\tconst item = getItem( itemName );\n\t\t\tif ( ! item ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet boundItem = cache.get( item );\n\t\t\tif ( ! boundItem ) {\n\t\t\t\tboundItem = bindItem( item, itemName );\n\t\t\t\tcache.set( item, boundItem );\n\t\t\t}\n\t\t\treturn boundItem;\n\t\t},\n\t};\n}\n\nfunction createPrivateProxy< T extends Record< string, any > >(\n\tpublicItems: T,\n\tprivateItems: BindingCache\n): T {\n\treturn new Proxy( publicItems, {\n\t\tget: ( target, itemName: string ) =>\n\t\t\tprivateItems.get( itemName ) || Reflect.get( target, itemName ),\n\t} );\n}\n\n/**\n * Creates a data store descriptor for the provided Redux store configuration containing\n * properties describing reducer, actions, selectors, controls and resolvers.\n *\n * @example\n * ```js\n * import { createReduxStore } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * ```\n *\n * @param key Unique namespace identifier.\n * @param options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return Store Object.\n */\nexport default function createReduxStore< State, Actions, Selectors >(\n\tkey: string,\n\toptions: ReduxStoreConfig< State, Actions, Selectors >\n): StoreDescriptor< ReduxStoreConfig< State, Actions, Selectors > > {\n\tconst privateActions: Record< string, ActionCreator > = {};\n\tconst privateSelectors: Record< string, SelectorLike > = {};\n\tconst privateRegistrationFunctions = {\n\t\tprivateActions,\n\t\tregisterPrivateActions: (\n\t\t\tactions: Record< string, ActionCreator >\n\t\t) => {\n\t\t\tObject.assign( privateActions, actions );\n\t\t},\n\t\tprivateSelectors,\n\t\tregisterPrivateSelectors: (\n\t\t\tselectors: Record< string, SelectorLike >\n\t\t) => {\n\t\t\tObject.assign( privateSelectors, selectors );\n\t\t},\n\t};\n\tconst storeDescriptor = {\n\t\tname: key,\n\t\tinstantiate: ( registry: DataRegistry ) => {\n\t\t\t/**\n\t\t\t * Stores listener functions registered with `subscribe()`.\n\t\t\t *\n\t\t\t * When functions register to listen to store changes with\n\t\t\t * `subscribe()` they get added here. Although Redux offers\n\t\t\t * its own `subscribe()` function directly, by wrapping the\n\t\t\t * subscription in this store instance it's possible to\n\t\t\t * optimize checking if the state has changed before calling\n\t\t\t * each listener.\n\t\t\t */\n\t\t\tconst listeners = new Set< ListenerFunction >();\n\t\t\tconst reducer = options.reducer;\n\n\t\t\t// Object that every thunk function receives as the first argument. It contains the\n\t\t\t// `registry`, `dispatch`, `select` and `resolveSelect` fields. Some of them are\n\t\t\t// constructed as getters to avoid circular dependencies.\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn thunkDispatch;\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn thunkSelect;\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn resolveSelectors;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst store = instantiateReduxStore(\n\t\t\t\tkey,\n\t\t\t\toptions,\n\t\t\t\tregistry,\n\t\t\t\tthunkArgs\n\t\t\t) as AugmentedReduxStore;\n\n\t\t\t// Expose the private registration functions on the store\n\t\t\t// so they can be copied to a sub registry in registry.js.\n\t\t\tlock( store, privateRegistrationFunctions );\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\t// Binds an action creator (`action`) to the `store`, making it a callable function.\n\t\t\t// These are the functions that are returned by `useDispatch`, for example.\n\t\t\t// It always returns a `Promise`, although actions are not always async. That's an\n\t\t\t// unfortunate backward compatibility measure.\n\t\t\tfunction bindAction( action: ( ...args: any[] ) => any ) {\n\t\t\t\treturn ( ...args: unknown[] ) =>\n\t\t\t\t\tPromise.resolve( store.dispatch( action( ...args ) ) );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Object with all public actions, both metadata and store actions.\n\t\t\t */\n\t\t\tconst actions = {\n\t\t\t\t...mapValues(\n\t\t\t\t\tmetadataActions as Record< string, ActionCreator >,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t\t...mapValues(\n\t\t\t\t\toptions.actions as\n\t\t\t\t\t\t| Record< string, ActionCreator >\n\t\t\t\t\t\t| undefined,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t};\n\n\t\t\t// Object with both public and private actions. Private actions are accessed through a proxy,\n\t\t\t// which looks them up in real time on the `privateActions` object. That's because private\n\t\t\t// actions can be registered at any time with `registerPrivateActions`. Also once a private\n\t\t\t// action creator is bound to the store, it is cached to give it a stable identity.\n\t\t\tconst allActions = createPrivateProxy(\n\t\t\t\tactions,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => privateActions[ name ],\n\t\t\t\t\tbindAction\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// An object that implements the `dispatch` object that is passed to thunk functions.\n\t\t\t// It is callable (`dispatch( action )`) and also has methods (`dispatch.foo()`) that\n\t\t\t// correspond to bound registered actions, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allActions`.\n\t\t\tconst thunkDispatch = new Proxy(\n\t\t\t\t( action: any ) => store.dispatch( action ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allActions[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `actions` object, add the \"locked\" `allActions` object. When used,\n\t\t\t// `unlock( actions )` will return `allActions`, implementing a way how to get at the private actions.\n\t\t\tlock( actions, allActions );\n\n\t\t\t// If we have selector resolvers, convert them to a normalized form.\n\t\t\tconst resolvers: Record< string, NormalizedResolver > =\n\t\t\t\toptions.resolvers\n\t\t\t\t\t? mapValues(\n\t\t\t\t\t\t\toptions.resolvers as Record< string, any >,\n\t\t\t\t\t\t\tmapResolver\n\t\t\t\t\t )\n\t\t\t\t\t: {};\n\n\t\t\t// Bind a selector to the store. Call the selector with the current state, correct registry,\n\t\t\t// and if there is a resolver, attach the resolver logic to the selector.\n\t\t\tfunction bindSelector(\n\t\t\t\tselector: SelectorLike,\n\t\t\t\tselectorName: string\n\t\t\t): SelectorLike {\n\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\tselector.registry = registry;\n\t\t\t\t}\n\t\t\t\tconst boundSelector: SelectorLike = ( ...args: any[] ) => {\n\t\t\t\t\targs = normalize( selector, args );\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t// Before calling the selector, switch to the correct registry.\n\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t}\n\t\t\t\t\treturn selector( state.root, ...args );\n\t\t\t\t};\n\n\t\t\t\t// Expose normalization method on the bound selector\n\t\t\t\t// in order that it can be called when fulfilling\n\t\t\t\t// the resolver.\n\t\t\t\tboundSelector.__unstableNormalizeArgs =\n\t\t\t\t\tselector.__unstableNormalizeArgs;\n\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\n\t\t\t\tif ( ! resolver ) {\n\t\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\t\treturn boundSelector;\n\t\t\t\t}\n\n\t\t\t\treturn mapSelectorWithResolver(\n\t\t\t\t\tboundSelector,\n\t\t\t\t\tselectorName,\n\t\t\t\t\tresolver,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache,\n\t\t\t\t\tboundMetadataSelectors\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Metadata selectors are bound differently: different state (`state.metadata`), no resolvers,\n\t\t\t// normalization depending on the target selector.\n\t\t\tfunction bindMetadataSelector(\n\t\t\t\tmetaDataSelector: ( ...args: any[] ) => any\n\t\t\t): SelectorLike {\n\t\t\t\tconst boundSelector: SelectorLike = (\n\t\t\t\t\tselectorName: string,\n\t\t\t\t\tselectorArgs: unknown[],\n\t\t\t\t\t...args: unknown[]\n\t\t\t\t) => {\n\t\t\t\t\t// Normalize the arguments passed to the target selector.\n\t\t\t\t\tif ( selectorName ) {\n\t\t\t\t\t\tconst targetSelector = ( options.selectors as any )?.[\n\t\t\t\t\t\t\tselectorName\n\t\t\t\t\t\t];\n\t\t\t\t\t\tif ( targetSelector ) {\n\t\t\t\t\t\t\tselectorArgs = normalize(\n\t\t\t\t\t\t\t\ttargetSelector,\n\t\t\t\t\t\t\t\tselectorArgs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\n\t\t\t\t\treturn metaDataSelector(\n\t\t\t\t\t\tstate.metadata,\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tselectorArgs,\n\t\t\t\t\t\t...args\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\treturn boundSelector;\n\t\t\t}\n\n\t\t\t// Perform binding of both metadata and store selectors and combine them in one\n\t\t\t// `selectors` object. These are all public selectors of the store.\n\t\t\tconst boundMetadataSelectors = mapValues(\n\t\t\t\tmetadataSelectors as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\t( ...args: any[] ) => any\n\t\t\t\t>,\n\t\t\t\tbindMetadataSelector\n\t\t\t);\n\n\t\t\tconst boundSelectors = mapValues(\n\t\t\t\toptions.selectors as Record< string, SelectorLike > | undefined,\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst selectors = {\n\t\t\t\t...boundMetadataSelectors,\n\t\t\t\t...boundSelectors,\n\t\t\t};\n\n\t\t\t// Cache of bound private selectors. They are bound only when first accessed, because\n\t\t\t// new private selectors can be registered at any time (with `registerPrivateSelectors`).\n\t\t\t// Once bound, they are cached to give them a stable identity.\n\t\t\tconst boundPrivateSelectors = createBindingCache(\n\t\t\t\t( name ) => privateSelectors[ name ],\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst allSelectors = createPrivateProxy(\n\t\t\t\tselectors,\n\t\t\t\tboundPrivateSelectors\n\t\t\t);\n\n\t\t\t// Pre-bind the private selectors that have been registered by the time of\n\t\t\t// instantiation, so that registry selectors are bound to the registry.\n\t\t\tfor ( const selectorName of Object.keys( privateSelectors ) ) {\n\t\t\t\tboundPrivateSelectors.get( selectorName );\n\t\t\t}\n\n\t\t\t// An object that implements the `select` object that is passed to thunk functions.\n\t\t\t// It is callable (`select( selector )`) and also has methods (`select.foo()`) that\n\t\t\t// correspond to bound registered selectors, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allSelectors`.\n\t\t\tconst thunkSelect = new Proxy(\n\t\t\t\t( selector: ( state: any ) => any ) =>\n\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allSelectors[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `selectors` object, add the \"locked\" `allSelectors` object. When used,\n\t\t\t// `unlock( selectors )` will return `allSelectors`, implementing a way how to get at the private selectors.\n\t\t\tlock( selectors, allSelectors );\n\n\t\t\t// For each selector, create a function that calls the selector, waits for resolution and returns\n\t\t\t// a promise that resolves when the resolution is finished.\n\t\t\tconst bindResolveSelector = mapResolveSelector(\n\t\t\t\tstore,\n\t\t\t\tresolvers,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\t// Now apply this function to all bound selectors, public and private. We are excluding\n\t\t\t// metadata selectors because they don't have resolvers.\n\t\t\tconst resolveSelectors = mapValues(\n\t\t\t\tboundSelectors,\n\t\t\t\tbindResolveSelector\n\t\t\t);\n\n\t\t\tconst allResolveSelectors = createPrivateProxy(\n\t\t\t\tresolveSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindResolveSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( resolveSelectors )` returns `allResolveSelectors`.\n\t\t\tlock( resolveSelectors, allResolveSelectors );\n\n\t\t\t// Now, in a way very similar to `bindResolveSelector`, we create a function that maps\n\t\t\t// selectors to functions that throw a suspense promise if not yet resolved.\n\t\t\tconst bindSuspendSelector = mapSuspendSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\tconst suspendSelectors = {\n\t\t\t\t...boundMetadataSelectors, // no special suspense behavior\n\t\t\t\t...mapValues( boundSelectors, bindSuspendSelector ),\n\t\t\t};\n\n\t\t\tconst allSuspendSelectors = createPrivateProxy(\n\t\t\t\tsuspendSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindSuspendSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( suspendSelectors )` returns 'allSuspendSelectors`.\n\t\t\tlock( suspendSelectors, allSuspendSelectors );\n\n\t\t\tconst getSelectors = () => selectors;\n\t\t\tconst getActions = () => actions;\n\t\t\tconst getResolveSelectors = () => resolveSelectors;\n\t\t\tconst getSuspendSelectors = () => suspendSelectors;\n\n\t\t\t// We have some modules monkey-patching the store object\n\t\t\t// It's wrong to do so but until we refactor all of our effects to controls\n\t\t\t// We need to keep the same \"store\" instance here.\n\t\t\tstore.__unstableOriginalGetState = store.getState;\n\t\t\tstore.getState = () => store.__unstableOriginalGetState().root;\n\n\t\t\t// Customize subscribe behavior to call listeners only on effective change,\n\t\t\t// not on every dispatch.\n\t\t\tconst subscribe = ( listener: ListenerFunction ) => {\n\t\t\t\tlisteners.add( listener );\n\n\t\t\t\treturn () => listeners.delete( listener );\n\t\t\t};\n\n\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\tstore.subscribe( () => {\n\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\tlastState = state;\n\n\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\tfor ( const listener of listeners ) {\n\t\t\t\t\t\tlistener();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// This can be simplified to just { subscribe, getSelectors, getActions }\n\t\t\t// Once we remove the use function.\n\t\t\treturn {\n\t\t\t\treducer,\n\t\t\t\tstore,\n\t\t\t\tactions,\n\t\t\t\tselectors,\n\t\t\t\tresolvers,\n\t\t\t\tgetSelectors,\n\t\t\t\tgetResolveSelectors,\n\t\t\t\tgetSuspendSelectors,\n\t\t\t\tgetActions,\n\t\t\t\tsubscribe,\n\t\t\t};\n\t\t},\n\t};\n\n\t// Expose the private registration functions on the store\n\t// descriptor. That's a natural choice since that's where the\n\t// public actions and selectors are stored.\n\tlock( storeDescriptor, privateRegistrationFunctions );\n\n\treturn storeDescriptor as unknown as StoreDescriptor<\n\t\tReduxStoreConfig< State, Actions, Selectors >\n\t>;\n}\n\n/**\n * Creates a redux store for a namespace.\n *\n * @param key Unique namespace identifier.\n * @param options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param registry Registry reference.\n * @param thunkArgs Argument object for the thunk middleware.\n * @return Newly created redux store.\n */\nfunction instantiateReduxStore(\n\tkey: string,\n\toptions: ReduxStoreConfig< any, any, any >,\n\tregistry: DataRegistry,\n\tthunkArgs: unknown\n): ReduxStore {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control: any ) =>\n\t\tcontrol.isRegistryControl ? control( registry ) : control\n\t);\n\n\tconst middlewares = [\n\t\tcreateResolversCacheMiddleware( registry, key ),\n\t\tpromise,\n\t\tcreateReduxRoutineMiddleware( normalizedControls ),\n\t\tcreateThunkMiddleware( thunkArgs ),\n\t];\n\n\tconst enhancers: StoreEnhancer[] = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\n\t\t\t\tserialize: {\n\t\t\t\t\treplacer: devToolsReplacer,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst { reducer, initialState } = options;\n\tconst enhancedReducer = combineReducers( {\n\t\tmetadata: metadataReducer,\n\t\troot: reducer,\n\t} );\n\n\treturn createStore(\n\t\tenhancedReducer,\n\t\t{ root: initialState } as any,\n\t\tcompose( ...enhancers ) as unknown as StoreEnhancer\n\t);\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them.\n *\n * @param store The redux store the selectors are bound to.\n * @param resolvers The normalized resolvers for the store.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to resolvers.\n */\nfunction mapResolveSelector(\n\tstore: ReduxStore,\n\tresolvers: Record< string, NormalizedResolver >,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// If the selector doesn't have a resolver, just convert the return value\n\t\t// (including exceptions) to a Promise, no additional extra behavior is needed.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn async ( ...args: unknown[] ) => selector( ...args );\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) =>\n\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\t\t\t\tconst hasFinished = () => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\t\t\tresolver.isFulfilled( store.getState(), ...args ) )\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst finalize = ( result: unknown ) => {\n\t\t\t\t\tconst hasFailed =\n\t\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve( result );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst getResult = () => selector( ...args );\n\n\t\t\t\t// Trigger the selector (to trigger the resolver)\n\t\t\t\tconst result = getResult();\n\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\treturn finalize( result );\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\tfinalize( getResult() );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t};\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param store The redux store the selectors select from.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to their suspending versions.\n */\nfunction mapSuspendSelector(\n\tstore: ReduxStore,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// Selector without a resolver doesn't have any extra suspense behavior.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn selector;\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) => {\n\t\t\tconst result = selector( ...args );\n\n\t\t\tif (\n\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\tselectorName,\n\t\t\t\t\targs\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise< void >( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t};\n}\n\n/**\n * Convert a resolver to a normalized form, an object with `fulfill` method and\n * optional methods like `isFulfilled`.\n *\n * @param resolver Resolver to convert\n */\nfunction mapResolver( resolver: any ): NormalizedResolver {\n\tif ( resolver.fulfill ) {\n\t\treturn resolver;\n\t}\n\n\treturn {\n\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\tfulfill: resolver, // Add the fulfill method.\n\t};\n}\n\n/**\n * Returns a selector with a matched resolver.\n * Resolvers are side effects invoked once per argument set of a given selector call,\n * used in ensuring that the data needs for the selector are satisfied.\n *\n * @param selector The selector function to be bound.\n * @param selectorName The selector name.\n * @param resolver Resolver to call.\n * @param store The redux store to which the resolvers should be mapped.\n * @param resolversCache Resolvers Cache.\n * @param boundMetadataSelectors The bound metadata selectors.\n */\nfunction mapSelectorWithResolver(\n\tselector: SelectorLike,\n\tselectorName: string,\n\tresolver: NormalizedResolver,\n\tstore: AugmentedReduxStore,\n\tresolversCache: ResolversCache,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n): SelectorLike {\n\tfunction fulfillSelector( args: unknown[] ): void {\n\t\tif (\n\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\tboundMetadataSelectors.hasStartedResolution( selectorName, args ) ||\n\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\tresolver.isFulfilled( store.getState(), ...args ) )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\tsetTimeout( async () => {\n\t\t\tresolversCache.clear( selectorName, args );\n\t\t\tstore.dispatch(\n\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tconst action = resolver.fulfill( ...args );\n\t\t\t\tif ( action ) {\n\t\t\t\t\tawait store.dispatch( action );\n\t\t\t\t}\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.finishResolution( selectorName, args )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.failResolution( selectorName, args, error )\n\t\t\t\t);\n\t\t\t}\n\t\t}, 0 );\n\t}\n\n\tconst selectorResolver: SelectorLike = ( ...args: unknown[] ) => {\n\t\targs = normalize( selector, args );\n\t\tfulfillSelector( args );\n\t\treturn selector( ...args );\n\t};\n\tselectorResolver.hasResolver = true;\n\treturn selectorResolver;\n}\n\n/**\n * Applies selector's normalization function to the given arguments\n * if it exists.\n *\n * @param selector The selector potentially with a normalization method property.\n * @param args selector arguments to normalize.\n * @return Potentially normalized arguments.\n */\nfunction normalize( selector: SelectorLike, args: unknown[] ): unknown[] {\n\tif (\n\t\tselector.__unstableNormalizeArgs &&\n\t\ttypeof selector.__unstableNormalizeArgs === 'function' &&\n\t\targs?.length\n\t) {\n\t\treturn selector.__unstableNormalizeArgs( args );\n\t}\n\treturn args;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA6C;AAE7C,gCAA6B;AAK7B,2BAAyC;AACzC,qBAAwB;AAKxB,8BAAgC;AAChC,sBAAgC;AAChC,yBAAqB;AACrB,gCAAoB;AACpB,wCAA2C;AAC3C,8BAAkC;AAClC,qBAA4B;AAC5B,wBAAmC;AACnC,sBAAiC;AAqCjC,IAAM,sBAAsB,CAAE,UAAiC;AAC9D,QAAM,SAAS,CAAE,GAAG,KAAM;AAC1B,WAAU,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,KAAM;AAC9C,QAAK,OAAQ,CAAE,MAAM,QAAY;AAChC,aAAO,OAAQ,GAAG,CAAE;AAAA,IACrB;AAAA,EACD;AACA,SAAO;AACR;AAUA,IAAM,YAAY,CACjB,KACA,aAEA,OAAO;AAAA,EACN,OAAO,QAAS,OAAO,CAAC,CAAE,EAAE,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO;AAAA,IACtD;AAAA,IACA,SAAU,OAAO,GAAI;AAAA,EACtB,CAAE;AACH;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AM,mBAAiC,IAAK,SAAqB;AAChE,WAAO,UAAW,UAAU,IAAK;AACjC,oBAAiB,IAAK;AACtB,WAAO,SAAU,GAAG,IAAK;AAAA,EAC1B;AACA,mBAAiB,cAAc;AAC/B,SAAO;AACR;AAUA,SAAS,UAAW,UAAwB,MAA6B;AACxE,MACC,SAAS,2BACT,OAAO,SAAS,4BAA4B,cAC5C,MAAM,QACL;AACD,WAAO,SAAS,wBAAyB,IAAK;AAAA,EAC/C;AACA,SAAO;AACR;",
|
|
6
6
|
"names": ["EquivalentKeyMap", "createResolversCacheMiddleware", "promise", "createReduxRoutineMiddleware", "createThunkMiddleware", "metadataReducer", "result"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/use-select/index.ts"],
|
|
4
|
-
"sourcesContent": ["// useSelect is a low-level hook that intentionally breaks rules-of-hooks\n// in its internal helpers (_useStaticSelect, _useMappingSelect) where\n// hooks are called inside non-hook functions and conditionally dispatched.\n/* eslint-disable react-hooks/rules-of-hooks, react-compiler/react-compiler */\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\nimport type {\n\tMapSelect,\n\tSelectFunction,\n\tStoreDescriptor,\n\tAnyConfig,\n\tUseSelectReturn,\n\tDataRegistry,\n} from '../../types';\n\nconst renderQueue = createQueue();\n\nfunction warnOnUnstableReference(\n\ta: Record< string, unknown >,\n\tb: Record< string, unknown >\n): void {\n\tif ( ! a || ! b ) {\n\t\treturn;\n\t}\n\n\tconst keys =\n\t\ttypeof a === 'object' && typeof b === 'object'\n\t\t\t? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] )\n\t\t\t: [];\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn(\n\t\t'The `useSelect` hook returns different values when called with the same state and parameters.\\n' +\n\t\t\t'This can lead to unnecessary re-renders and performance issues if not fixed.\\n\\n' +\n\t\t\t'Non-equal value keys: %s\\n\\n',\n\t\tkeys.join( ', ' )\n\t);\n}\n\ninterface StoreSubscriber {\n\tsubscribe: ( listener: () => void ) => () => void;\n\tupdateStores: ( newStores: string[] ) => void;\n}\n\nfunction Store( registry: DataRegistry, suspense: boolean ) {\n\tconst select = ( suspense\n\t\t? registry.suspendSelect\n\t\t: registry.select ) as unknown as SelectFunction;\n\tconst queueContext = {};\n\tlet lastMapSelect: MapSelect | undefined;\n\tlet lastMapResult: unknown;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync: boolean | undefined;\n\tlet subscriber: StoreSubscriber | undefined;\n\tlet didWarnUnstableReference: boolean | undefined;\n\tconst storeStatesOnMount = new Map< string, unknown >();\n\n\tfunction getStoreState( name: string ): unknown {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores: string[] ): StoreSubscriber => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set< ( storeName: string ) => void >();\n\n\t\tfunction subscribe( listener: () => void ): () => void {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs: Array< VoidFunction > = [];\n\t\t\tfunction subscribeStore( storeName: string ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores: string[] ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect: MapSelect, isAsync: boolean ) => {\n\t\tfunction updateValue(): void {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null as string[] | null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( ( globalThis as any ).SCRIPT_DEBUG ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\twarnOnUnstableReference( mapResult, secondMapResult );\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current! ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current! );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current! );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber!.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName: StoreDescriptor< AnyConfig > | string ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect(\n\tsuspense: boolean,\n\tmapSelect: MapSelect,\n\tdeps: unknown[]\n) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @param mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n *\n * @return The selected data or store selectors.\n */\nexport default function useSelect<\n\tT extends MapSelect | StoreDescriptor< AnyConfig >,\n>( mapSelect: T, deps?: unknown[] ): UseSelectReturn< T > {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\n\treturn (\n\t\tstaticSelectMode\n\t\t\t? _useStaticSelect( mapSelect as StoreDescriptor< AnyConfig > )\n\t\t\t: _useMappingSelect( false, mapSelect as MapSelect, deps! )\n\t) as UseSelectReturn< T >;\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @param mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @throws A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect< T extends MapSelect >(\n\tmapSelect: T,\n\tdeps: unknown[]\n): ReturnType< T > {\n\treturn _useMappingSelect( true, mapSelect, deps ) as ReturnType< T >;\n}\n/* eslint-enable react-hooks/rules-of-hooks, react-compiler/react-compiler */\n"],
|
|
4
|
+
"sourcesContent": ["// useSelect is a low-level hook that intentionally breaks rules-of-hooks\n// in its internal helpers (_useStaticSelect, _useMappingSelect) where\n// hooks are called inside non-hook functions and conditionally dispatched.\n/* eslint-disable react-hooks/rules-of-hooks */\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\nimport type {\n\tMapSelect,\n\tSelectFunction,\n\tStoreDescriptor,\n\tAnyConfig,\n\tUseSelectReturn,\n\tDataRegistry,\n} from '../../types';\n\nconst renderQueue = createQueue();\n\nfunction warnOnUnstableReference(\n\ta: Record< string, unknown >,\n\tb: Record< string, unknown >\n): void {\n\tif ( ! a || ! b ) {\n\t\treturn;\n\t}\n\n\tconst keys =\n\t\ttypeof a === 'object' && typeof b === 'object'\n\t\t\t? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] )\n\t\t\t: [];\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn(\n\t\t'The `useSelect` hook returns different values when called with the same state and parameters.\\n' +\n\t\t\t'This can lead to unnecessary re-renders and performance issues if not fixed.\\n\\n' +\n\t\t\t'Non-equal value keys: %s\\n\\n',\n\t\tkeys.join( ', ' )\n\t);\n}\n\ninterface StoreSubscriber {\n\tsubscribe: ( listener: () => void ) => () => void;\n\tupdateStores: ( newStores: string[] ) => void;\n}\n\nfunction Store( registry: DataRegistry, suspense: boolean ) {\n\tconst select = ( suspense\n\t\t? registry.suspendSelect\n\t\t: registry.select ) as unknown as SelectFunction;\n\tconst queueContext = {};\n\tlet lastMapSelect: MapSelect | undefined;\n\tlet lastMapResult: unknown;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync: boolean | undefined;\n\tlet subscriber: StoreSubscriber | undefined;\n\tlet didWarnUnstableReference: boolean | undefined;\n\tconst storeStatesOnMount = new Map< string, unknown >();\n\n\tfunction getStoreState( name: string ): unknown {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores: string[] ): StoreSubscriber => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set< ( storeName: string ) => void >();\n\n\t\tfunction subscribe( listener: () => void ): () => void {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs: Array< VoidFunction > = [];\n\t\t\tfunction subscribeStore( storeName: string ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores: string[] ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect: MapSelect, isAsync: boolean ) => {\n\t\tfunction updateValue(): void {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null as string[] | null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( ( globalThis as any ).SCRIPT_DEBUG ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\twarnOnUnstableReference( mapResult, secondMapResult );\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current! ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current! );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current! );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber!.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName: StoreDescriptor< AnyConfig > | string ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect(\n\tsuspense: boolean,\n\tmapSelect: MapSelect,\n\tdeps: unknown[]\n) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @param mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n *\n * @return The selected data or store selectors.\n */\nexport default function useSelect<\n\tT extends MapSelect | StoreDescriptor< AnyConfig >,\n>( mapSelect: T, deps?: unknown[] ): UseSelectReturn< T > {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\n\treturn (\n\t\tstaticSelectMode\n\t\t\t? _useStaticSelect( mapSelect as StoreDescriptor< AnyConfig > )\n\t\t\t: _useMappingSelect( false, mapSelect as MapSelect, deps! )\n\t) as UseSelectReturn< T >;\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @param mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @throws A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect< T extends MapSelect >(\n\tmapSelect: T,\n\tdeps: unknown[]\n): ReturnType< T > {\n\treturn _useMappingSelect( true, mapSelect, deps ) as ReturnType< T >;\n}\n/* eslint-enable react-hooks/rules-of-hooks */\n"],
|
|
5
5
|
"mappings": ";AAQA,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,sBAAsB;AAK/B,OAAO,iBAAiB;AACxB,OAAO,kBAAkB;AAUzB,IAAM,cAAc,YAAY;AAEhC,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indResolveSelector = mapResolveSelector(
|
|
229
229
|
store,
|
|
230
|
+
resolvers,
|
|
230
231
|
boundMetadataSelectors
|
|
231
232
|
);
|
|
232
233
|
const resolveSelectors = mapValues(
|
|
@@ -334,17 +335,18 @@ function instantiateReduxStore(key, options, registry, thunkArgs) {
|
|
|
334
335
|
compose(...enhancers)
|
|
335
336
|
);
|
|
336
337
|
}
|
|
337
|
-
function mapResolveSelector(store, boundMetadataSelectors) {
|
|
338
|
+
function mapResolveSelector(store, resolvers, boundMetadataSelectors) {
|
|
338
339
|
return (selector, selectorName) => {
|
|
339
340
|
if (!selector.hasResolver) {
|
|
340
341
|
return async (...args) => selector(...args);
|
|
341
342
|
}
|
|
342
343
|
return (...args) => new Promise((resolve, reject) => {
|
|
344
|
+
const resolver = resolvers[selectorName];
|
|
343
345
|
const hasFinished = () => {
|
|
344
346
|
return boundMetadataSelectors.hasFinishedResolution(
|
|
345
347
|
selectorName,
|
|
346
348
|
args
|
|
347
|
-
);
|
|
349
|
+
) || typeof resolver.isFulfilled === "function" && resolver.isFulfilled(store.getState(), ...args);
|
|
348
350
|
};
|
|
349
351
|
const finalize = (result2) => {
|
|
350
352
|
const hasFailed = boundMetadataSelectors.hasResolutionFailed(
|
|
@@ -424,7 +426,7 @@ function mapResolver(resolver) {
|
|
|
424
426
|
}
|
|
425
427
|
function mapSelectorWithResolver(selector, selectorName, resolver, store, resolversCache, boundMetadataSelectors) {
|
|
426
428
|
function fulfillSelector(args) {
|
|
427
|
-
if (resolversCache.isRunning(selectorName, args) || boundMetadataSelectors.hasStartedResolution(selectorName, args)) {
|
|
429
|
+
if (resolversCache.isRunning(selectorName, args) || boundMetadataSelectors.hasStartedResolution(selectorName, args) || typeof resolver.isFulfilled === "function" && resolver.isFulfilled(store.getState(), ...args)) {
|
|
428
430
|
return;
|
|
429
431
|
}
|
|
430
432
|
resolversCache.markAsRunning(selectorName, args);
|
|
@@ -434,12 +436,9 @@ function mapSelectorWithResolver(selector, selectorName, resolver, store, resolv
|
|
|
434
436
|
metadataActions.startResolution(selectorName, args)
|
|
435
437
|
);
|
|
436
438
|
try {
|
|
437
|
-
const
|
|
438
|
-
if (
|
|
439
|
-
|
|
440
|
-
if (action) {
|
|
441
|
-
await store.dispatch(action);
|
|
442
|
-
}
|
|
439
|
+
const action = resolver.fulfill(...args);
|
|
440
|
+
if (action) {
|
|
441
|
+
await store.dispatch(action);
|
|
443
442
|
}
|
|
444
443
|
store.dispatch(
|
|
445
444
|
metadataActions.finishResolution(selectorName, args)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/redux-store/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport type { Store as ReduxStore, StoreEnhancer } from 'redux';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { combineReducers } from './combine-reducers';\nimport { builtinControls } from '../controls';\nimport { lock } from '../lock-unlock';\nimport promise from '../promise-middleware';\nimport createResolversCacheMiddleware from '../resolvers-cache-middleware';\nimport createThunkMiddleware from './thunk-middleware';\nimport metadataReducer from './metadata/reducer';\nimport * as metadataSelectors from './metadata/selectors';\nimport * as metadataActions from './metadata/actions';\nimport type {\n\tDataRegistry,\n\tListenerFunction,\n\tStoreDescriptor,\n\tReduxStoreConfig,\n\tActionCreator,\n\tNormalizedResolver,\n} from '../types';\n\nexport { combineReducers };\n\n/**\n * Augment the Redux store with internal properties used by the data module.\n */\ninterface AugmentedReduxStore extends ReduxStore {\n\t__unstableOriginalGetState: ReduxStore[ 'getState' ];\n}\n\ninterface ResolversCache {\n\tisRunning: ( selectorName: string, args: unknown[] ) => boolean;\n\tclear: ( selectorName: string, args: unknown[] ) => void;\n\tmarkAsRunning: ( selectorName: string, args: unknown[] ) => void;\n}\n\ninterface BindingCache {\n\tget: ( itemName: string ) => ( ( ...args: unknown[] ) => unknown ) | null;\n}\n\ninterface SelectorLike {\n\t( ...args: any[] ): any;\n\thasResolver?: boolean;\n\tisRegistrySelector?: boolean;\n\tregistry?: DataRegistry;\n\t__unstableNormalizeArgs?: ( args: unknown[] ) => unknown[];\n}\n\nconst trimUndefinedValues = ( array: unknown[] ): unknown[] => {\n\tconst result = [ ...array ];\n\tfor ( let i = result.length - 1; i >= 0; i-- ) {\n\t\tif ( result[ i ] === undefined ) {\n\t\t\tresult.splice( i, 1 );\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param obj The object to transform.\n * @param callback The function to transform each object value.\n * @return Transformed object.\n */\nconst mapValues = < T, U >(\n\tobj: Record< string, T > | undefined,\n\tcallback: ( value: T, key: string ) => U\n): Record< string, U > =>\n\tObject.fromEntries(\n\t\tObject.entries( obj ?? {} ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tcallback( value, key ),\n\t\t] )\n\t);\n\n// Convert non serializable types to plain objects\nconst devToolsReplacer = ( _key: string, state: unknown ): unknown => {\n\tif ( state instanceof Map ) {\n\t\treturn Object.fromEntries( state );\n\t}\n\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\tstate instanceof window.HTMLElement\n\t) {\n\t\treturn null;\n\t}\n\n\treturn state;\n};\n\n/**\n * Create a cache to track whether resolvers started running or not.\n *\n * @return Resolvers Cache.\n */\nfunction createResolversCache(): ResolversCache {\n\tconst cache: Record< string, EquivalentKeyMap< unknown[], boolean > > = {};\n\treturn {\n\t\tisRunning( selectorName: string, args: unknown[] ): boolean {\n\t\t\treturn !! (\n\t\t\t\tcache[ selectorName ] &&\n\t\t\t\tcache[ selectorName ].get( trimUndefinedValues( args ) )\n\t\t\t);\n\t\t},\n\n\t\tclear( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ].delete( trimUndefinedValues( args ) );\n\t\t\t}\n\t\t},\n\n\t\tmarkAsRunning( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( ! cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ] = new EquivalentKeyMap();\n\t\t\t}\n\n\t\t\tcache[ selectorName ].set( trimUndefinedValues( args ), true );\n\t\t},\n\t};\n}\n\nfunction createBindingCache(\n\tgetItem: ( name: string ) => ( ( ...args: any[] ) => any ) | undefined,\n\tbindItem: (\n\t\titem: ( ...args: any[] ) => any,\n\t\tname: string\n\t) => ( ...args: unknown[] ) => unknown\n): BindingCache {\n\tconst cache = new WeakMap<\n\t\t( ...args: any[] ) => any,\n\t\t( ...args: unknown[] ) => unknown\n\t>();\n\n\treturn {\n\t\tget( itemName: string ) {\n\t\t\tconst item = getItem( itemName );\n\t\t\tif ( ! item ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet boundItem = cache.get( item );\n\t\t\tif ( ! boundItem ) {\n\t\t\t\tboundItem = bindItem( item, itemName );\n\t\t\t\tcache.set( item, boundItem );\n\t\t\t}\n\t\t\treturn boundItem;\n\t\t},\n\t};\n}\n\nfunction createPrivateProxy< T extends Record< string, any > >(\n\tpublicItems: T,\n\tprivateItems: BindingCache\n): T {\n\treturn new Proxy( publicItems, {\n\t\tget: ( target, itemName: string ) =>\n\t\t\tprivateItems.get( itemName ) || Reflect.get( target, itemName ),\n\t} );\n}\n\n/**\n * Creates a data store descriptor for the provided Redux store configuration containing\n * properties describing reducer, actions, selectors, controls and resolvers.\n *\n * @example\n * ```js\n * import { createReduxStore } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * ```\n *\n * @param key Unique namespace identifier.\n * @param options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return Store Object.\n */\nexport default function createReduxStore< State, Actions, Selectors >(\n\tkey: string,\n\toptions: ReduxStoreConfig< State, Actions, Selectors >\n): StoreDescriptor< ReduxStoreConfig< State, Actions, Selectors > > {\n\tconst privateActions: Record< string, ActionCreator > = {};\n\tconst privateSelectors: Record< string, SelectorLike > = {};\n\tconst privateRegistrationFunctions = {\n\t\tprivateActions,\n\t\tregisterPrivateActions: (\n\t\t\tactions: Record< string, ActionCreator >\n\t\t) => {\n\t\t\tObject.assign( privateActions, actions );\n\t\t},\n\t\tprivateSelectors,\n\t\tregisterPrivateSelectors: (\n\t\t\tselectors: Record< string, SelectorLike >\n\t\t) => {\n\t\t\tObject.assign( privateSelectors, selectors );\n\t\t},\n\t};\n\tconst storeDescriptor = {\n\t\tname: key,\n\t\tinstantiate: ( registry: DataRegistry ) => {\n\t\t\t/**\n\t\t\t * Stores listener functions registered with `subscribe()`.\n\t\t\t *\n\t\t\t * When functions register to listen to store changes with\n\t\t\t * `subscribe()` they get added here. Although Redux offers\n\t\t\t * its own `subscribe()` function directly, by wrapping the\n\t\t\t * subscription in this store instance it's possible to\n\t\t\t * optimize checking if the state has changed before calling\n\t\t\t * each listener.\n\t\t\t */\n\t\t\tconst listeners = new Set< ListenerFunction >();\n\t\t\tconst reducer = options.reducer;\n\n\t\t\t// Object that every thunk function receives as the first argument. It contains the\n\t\t\t// `registry`, `dispatch`, `select` and `resolveSelect` fields. Some of them are\n\t\t\t// constructed as getters to avoid circular dependencies.\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn thunkDispatch;\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn thunkSelect;\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn resolveSelectors;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst store = instantiateReduxStore(\n\t\t\t\tkey,\n\t\t\t\toptions,\n\t\t\t\tregistry,\n\t\t\t\tthunkArgs\n\t\t\t) as AugmentedReduxStore;\n\n\t\t\t// Expose the private registration functions on the store\n\t\t\t// so they can be copied to a sub registry in registry.js.\n\t\t\tlock( store, privateRegistrationFunctions );\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\t// Binds an action creator (`action`) to the `store`, making it a callable function.\n\t\t\t// These are the functions that are returned by `useDispatch`, for example.\n\t\t\t// It always returns a `Promise`, although actions are not always async. That's an\n\t\t\t// unfortunate backward compatibility measure.\n\t\t\tfunction bindAction( action: ( ...args: any[] ) => any ) {\n\t\t\t\treturn ( ...args: unknown[] ) =>\n\t\t\t\t\tPromise.resolve( store.dispatch( action( ...args ) ) );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Object with all public actions, both metadata and store actions.\n\t\t\t */\n\t\t\tconst actions = {\n\t\t\t\t...mapValues(\n\t\t\t\t\tmetadataActions as Record< string, ActionCreator >,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t\t...mapValues(\n\t\t\t\t\toptions.actions as\n\t\t\t\t\t\t| Record< string, ActionCreator >\n\t\t\t\t\t\t| undefined,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t};\n\n\t\t\t// Object with both public and private actions. Private actions are accessed through a proxy,\n\t\t\t// which looks them up in real time on the `privateActions` object. That's because private\n\t\t\t// actions can be registered at any time with `registerPrivateActions`. Also once a private\n\t\t\t// action creator is bound to the store, it is cached to give it a stable identity.\n\t\t\tconst allActions = createPrivateProxy(\n\t\t\t\tactions,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => privateActions[ name ],\n\t\t\t\t\tbindAction\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// An object that implements the `dispatch` object that is passed to thunk functions.\n\t\t\t// It is callable (`dispatch( action )`) and also has methods (`dispatch.foo()`) that\n\t\t\t// correspond to bound registered actions, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allActions`.\n\t\t\tconst thunkDispatch = new Proxy(\n\t\t\t\t( action: any ) => store.dispatch( action ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allActions[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `actions` object, add the \"locked\" `allActions` object. When used,\n\t\t\t// `unlock( actions )` will return `allActions`, implementing a way how to get at the private actions.\n\t\t\tlock( actions, allActions );\n\n\t\t\t// If we have selector resolvers, convert them to a normalized form.\n\t\t\tconst resolvers: Record< string, NormalizedResolver > =\n\t\t\t\toptions.resolvers\n\t\t\t\t\t? mapValues(\n\t\t\t\t\t\t\toptions.resolvers as Record< string, any >,\n\t\t\t\t\t\t\tmapResolver\n\t\t\t\t\t )\n\t\t\t\t\t: {};\n\n\t\t\t// Bind a selector to the store. Call the selector with the current state, correct registry,\n\t\t\t// and if there is a resolver, attach the resolver logic to the selector.\n\t\t\tfunction bindSelector(\n\t\t\t\tselector: SelectorLike,\n\t\t\t\tselectorName: string\n\t\t\t): SelectorLike {\n\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\tselector.registry = registry;\n\t\t\t\t}\n\t\t\t\tconst boundSelector: SelectorLike = ( ...args: any[] ) => {\n\t\t\t\t\targs = normalize( selector, args );\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t// Before calling the selector, switch to the correct registry.\n\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t}\n\t\t\t\t\treturn selector( state.root, ...args );\n\t\t\t\t};\n\n\t\t\t\t// Expose normalization method on the bound selector\n\t\t\t\t// in order that it can be called when fulfilling\n\t\t\t\t// the resolver.\n\t\t\t\tboundSelector.__unstableNormalizeArgs =\n\t\t\t\t\tselector.__unstableNormalizeArgs;\n\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\n\t\t\t\tif ( ! resolver ) {\n\t\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\t\treturn boundSelector;\n\t\t\t\t}\n\n\t\t\t\treturn mapSelectorWithResolver(\n\t\t\t\t\tboundSelector,\n\t\t\t\t\tselectorName,\n\t\t\t\t\tresolver,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache,\n\t\t\t\t\tboundMetadataSelectors\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Metadata selectors are bound differently: different state (`state.metadata`), no resolvers,\n\t\t\t// normalization depending on the target selector.\n\t\t\tfunction bindMetadataSelector(\n\t\t\t\tmetaDataSelector: ( ...args: any[] ) => any\n\t\t\t): SelectorLike {\n\t\t\t\tconst boundSelector: SelectorLike = (\n\t\t\t\t\tselectorName: string,\n\t\t\t\t\tselectorArgs: unknown[],\n\t\t\t\t\t...args: unknown[]\n\t\t\t\t) => {\n\t\t\t\t\t// Normalize the arguments passed to the target selector.\n\t\t\t\t\tif ( selectorName ) {\n\t\t\t\t\t\tconst targetSelector = ( options.selectors as any )?.[\n\t\t\t\t\t\t\tselectorName\n\t\t\t\t\t\t];\n\t\t\t\t\t\tif ( targetSelector ) {\n\t\t\t\t\t\t\tselectorArgs = normalize(\n\t\t\t\t\t\t\t\ttargetSelector,\n\t\t\t\t\t\t\t\tselectorArgs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\n\t\t\t\t\treturn metaDataSelector(\n\t\t\t\t\t\tstate.metadata,\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tselectorArgs,\n\t\t\t\t\t\t...args\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\treturn boundSelector;\n\t\t\t}\n\n\t\t\t// Perform binding of both metadata and store selectors and combine them in one\n\t\t\t// `selectors` object. These are all public selectors of the store.\n\t\t\tconst boundMetadataSelectors = mapValues(\n\t\t\t\tmetadataSelectors as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\t( ...args: any[] ) => any\n\t\t\t\t>,\n\t\t\t\tbindMetadataSelector\n\t\t\t);\n\n\t\t\tconst boundSelectors = mapValues(\n\t\t\t\toptions.selectors as Record< string, SelectorLike > | undefined,\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst selectors = {\n\t\t\t\t...boundMetadataSelectors,\n\t\t\t\t...boundSelectors,\n\t\t\t};\n\n\t\t\t// Cache of bound private selectors. They are bound only when first accessed, because\n\t\t\t// new private selectors can be registered at any time (with `registerPrivateSelectors`).\n\t\t\t// Once bound, they are cached to give them a stable identity.\n\t\t\tconst boundPrivateSelectors = createBindingCache(\n\t\t\t\t( name ) => privateSelectors[ name ],\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst allSelectors = createPrivateProxy(\n\t\t\t\tselectors,\n\t\t\t\tboundPrivateSelectors\n\t\t\t);\n\n\t\t\t// Pre-bind the private selectors that have been registered by the time of\n\t\t\t// instantiation, so that registry selectors are bound to the registry.\n\t\t\tfor ( const selectorName of Object.keys( privateSelectors ) ) {\n\t\t\t\tboundPrivateSelectors.get( selectorName );\n\t\t\t}\n\n\t\t\t// An object that implements the `select` object that is passed to thunk functions.\n\t\t\t// It is callable (`select( selector )`) and also has methods (`select.foo()`) that\n\t\t\t// correspond to bound registered selectors, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allSelectors`.\n\t\t\tconst thunkSelect = new Proxy(\n\t\t\t\t( selector: ( state: any ) => any ) =>\n\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allSelectors[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `selectors` object, add the \"locked\" `allSelectors` object. When used,\n\t\t\t// `unlock( selectors )` will return `allSelectors`, implementing a way how to get at the private selectors.\n\t\t\tlock( selectors, allSelectors );\n\n\t\t\t// For each selector, create a function that calls the selector, waits for resolution and returns\n\t\t\t// a promise that resolves when the resolution is finished.\n\t\t\tconst bindResolveSelector = mapResolveSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\t// Now apply this function to all bound selectors, public and private. We are excluding\n\t\t\t// metadata selectors because they don't have resolvers.\n\t\t\tconst resolveSelectors = mapValues(\n\t\t\t\tboundSelectors,\n\t\t\t\tbindResolveSelector\n\t\t\t);\n\n\t\t\tconst allResolveSelectors = createPrivateProxy(\n\t\t\t\tresolveSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindResolveSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( resolveSelectors )` returns `allResolveSelectors`.\n\t\t\tlock( resolveSelectors, allResolveSelectors );\n\n\t\t\t// Now, in a way very similar to `bindResolveSelector`, we create a function that maps\n\t\t\t// selectors to functions that throw a suspense promise if not yet resolved.\n\t\t\tconst bindSuspendSelector = mapSuspendSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\tconst suspendSelectors = {\n\t\t\t\t...boundMetadataSelectors, // no special suspense behavior\n\t\t\t\t...mapValues( boundSelectors, bindSuspendSelector ),\n\t\t\t};\n\n\t\t\tconst allSuspendSelectors = createPrivateProxy(\n\t\t\t\tsuspendSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindSuspendSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( suspendSelectors )` returns 'allSuspendSelectors`.\n\t\t\tlock( suspendSelectors, allSuspendSelectors );\n\n\t\t\tconst getSelectors = () => selectors;\n\t\t\tconst getActions = () => actions;\n\t\t\tconst getResolveSelectors = () => resolveSelectors;\n\t\t\tconst getSuspendSelectors = () => suspendSelectors;\n\n\t\t\t// We have some modules monkey-patching the store object\n\t\t\t// It's wrong to do so but until we refactor all of our effects to controls\n\t\t\t// We need to keep the same \"store\" instance here.\n\t\t\tstore.__unstableOriginalGetState = store.getState;\n\t\t\tstore.getState = () => store.__unstableOriginalGetState().root;\n\n\t\t\t// Customize subscribe behavior to call listeners only on effective change,\n\t\t\t// not on every dispatch.\n\t\t\tconst subscribe = ( listener: ListenerFunction ) => {\n\t\t\t\tlisteners.add( listener );\n\n\t\t\t\treturn () => listeners.delete( listener );\n\t\t\t};\n\n\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\tstore.subscribe( () => {\n\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\tlastState = state;\n\n\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\tfor ( const listener of listeners ) {\n\t\t\t\t\t\tlistener();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// This can be simplified to just { subscribe, getSelectors, getActions }\n\t\t\t// Once we remove the use function.\n\t\t\treturn {\n\t\t\t\treducer,\n\t\t\t\tstore,\n\t\t\t\tactions,\n\t\t\t\tselectors,\n\t\t\t\tresolvers,\n\t\t\t\tgetSelectors,\n\t\t\t\tgetResolveSelectors,\n\t\t\t\tgetSuspendSelectors,\n\t\t\t\tgetActions,\n\t\t\t\tsubscribe,\n\t\t\t};\n\t\t},\n\t};\n\n\t// Expose the private registration functions on the store\n\t// descriptor. That's a natural choice since that's where the\n\t// public actions and selectors are stored.\n\tlock( storeDescriptor, privateRegistrationFunctions );\n\n\treturn storeDescriptor as unknown as StoreDescriptor<\n\t\tReduxStoreConfig< State, Actions, Selectors >\n\t>;\n}\n\n/**\n * Creates a redux store for a namespace.\n *\n * @param key Unique namespace identifier.\n * @param options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param registry Registry reference.\n * @param thunkArgs Argument object for the thunk middleware.\n * @return Newly created redux store.\n */\nfunction instantiateReduxStore(\n\tkey: string,\n\toptions: ReduxStoreConfig< any, any, any >,\n\tregistry: DataRegistry,\n\tthunkArgs: unknown\n): ReduxStore {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control: any ) =>\n\t\tcontrol.isRegistryControl ? control( registry ) : control\n\t);\n\n\tconst middlewares = [\n\t\tcreateResolversCacheMiddleware( registry, key ),\n\t\tpromise,\n\t\tcreateReduxRoutineMiddleware( normalizedControls ),\n\t\tcreateThunkMiddleware( thunkArgs ),\n\t];\n\n\tconst enhancers: StoreEnhancer[] = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\n\t\t\t\tserialize: {\n\t\t\t\t\treplacer: devToolsReplacer,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst { reducer, initialState } = options;\n\tconst enhancedReducer = combineReducers( {\n\t\tmetadata: metadataReducer,\n\t\troot: reducer,\n\t} );\n\n\treturn createStore(\n\t\tenhancedReducer,\n\t\t{ root: initialState } as any,\n\t\tcompose( ...enhancers ) as unknown as StoreEnhancer\n\t);\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them.\n *\n * @param store The redux store the selectors are bound to.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to resolvers.\n */\nfunction mapResolveSelector(\n\tstore: ReduxStore,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// If the selector doesn't have a resolver, just convert the return value\n\t\t// (including exceptions) to a Promise, no additional extra behavior is needed.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn async ( ...args: unknown[] ) => selector( ...args );\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) =>\n\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () => {\n\t\t\t\t\treturn boundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst finalize = ( result: unknown ) => {\n\t\t\t\t\tconst hasFailed =\n\t\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve( result );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst getResult = () => selector( ...args );\n\n\t\t\t\t// Trigger the selector (to trigger the resolver)\n\t\t\t\tconst result = getResult();\n\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\treturn finalize( result );\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\tfinalize( getResult() );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t};\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param store The redux store the selectors select from.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to their suspending versions.\n */\nfunction mapSuspendSelector(\n\tstore: ReduxStore,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// Selector without a resolver doesn't have any extra suspense behavior.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn selector;\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) => {\n\t\t\tconst result = selector( ...args );\n\n\t\t\tif (\n\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\tselectorName,\n\t\t\t\t\targs\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise< void >( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t};\n}\n\n/**\n * Convert a resolver to a normalized form, an object with `fulfill` method and\n * optional methods like `isFulfilled`.\n *\n * @param resolver Resolver to convert\n */\nfunction mapResolver( resolver: any ): NormalizedResolver {\n\tif ( resolver.fulfill ) {\n\t\treturn resolver;\n\t}\n\n\treturn {\n\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\tfulfill: resolver, // Add the fulfill method.\n\t};\n}\n\n/**\n * Returns a selector with a matched resolver.\n * Resolvers are side effects invoked once per argument set of a given selector call,\n * used in ensuring that the data needs for the selector are satisfied.\n *\n * @param selector The selector function to be bound.\n * @param selectorName The selector name.\n * @param resolver Resolver to call.\n * @param store The redux store to which the resolvers should be mapped.\n * @param resolversCache Resolvers Cache.\n * @param boundMetadataSelectors The bound metadata selectors.\n */\nfunction mapSelectorWithResolver(\n\tselector: SelectorLike,\n\tselectorName: string,\n\tresolver: NormalizedResolver,\n\tstore: AugmentedReduxStore,\n\tresolversCache: ResolversCache,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n): SelectorLike {\n\tfunction fulfillSelector( args: unknown[] ): void {\n\t\tif (\n\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\tboundMetadataSelectors.hasStartedResolution( selectorName, args )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\tsetTimeout( async () => {\n\t\t\tresolversCache.clear( selectorName, args );\n\t\t\tstore.dispatch(\n\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tconst isFulfilled =\n\t\t\t\t\ttypeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\tresolver.isFulfilled( store.getState(), ...args );\n\t\t\t\tif ( ! isFulfilled ) {\n\t\t\t\t\tconst action = resolver.fulfill( ...args );\n\t\t\t\t\tif ( action ) {\n\t\t\t\t\t\tawait store.dispatch( action );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.finishResolution( selectorName, args )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.failResolution( selectorName, args, error )\n\t\t\t\t);\n\t\t\t}\n\t\t}, 0 );\n\t}\n\n\tconst selectorResolver: SelectorLike = ( ...args: unknown[] ) => {\n\t\targs = normalize( selector, args );\n\t\tfulfillSelector( args );\n\t\treturn selector( ...args );\n\t};\n\tselectorResolver.hasResolver = true;\n\treturn selectorResolver;\n}\n\n/**\n * Applies selector's normalization function to the given arguments\n * if it exists.\n *\n * @param selector The selector potentially with a normalization method property.\n * @param args selector arguments to normalize.\n * @return Potentially normalized arguments.\n */\nfunction normalize( selector: SelectorLike, args: unknown[] ): unknown[] {\n\tif (\n\t\tselector.__unstableNormalizeArgs &&\n\t\ttypeof selector.__unstableNormalizeArgs === 'function' &&\n\t\targs?.length\n\t) {\n\t\treturn selector.__unstableNormalizeArgs( args );\n\t}\n\treturn args;\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,aAAa,uBAAuB;AAE7C,OAAO,sBAAsB;AAK7B,OAAO,kCAAkC;AACzC,SAAS,eAAe;AAKxB,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,OAAO,aAAa;AACpB,OAAO,oCAAoC;AAC3C,OAAO,2BAA2B;AAClC,OAAO,qBAAqB;AAC5B,YAAY,uBAAuB;AACnC,YAAY,qBAAqB;AAqCjC,IAAM,sBAAsB,CAAE,UAAiC;AAC9D,QAAM,SAAS,CAAE,GAAG,KAAM;AAC1B,WAAU,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,KAAM;AAC9C,QAAK,OAAQ,CAAE,MAAM,QAAY;AAChC,aAAO,OAAQ,GAAG,CAAE;AAAA,IACrB;AAAA,EACD;AACA,SAAO;AACR;AAUA,IAAM,YAAY,CACjB,KACA,aAEA,OAAO;AAAA,EACN,OAAO,QAAS,OAAO,CAAC,CAAE,EAAE,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO;AAAA,IACtD;AAAA,IACA,SAAU,OAAO,GAAI;AAAA,EACtB,CAAE;AACH;AAGD,IAAM,mBAAmB,CAAE,MAAc,UAA6B;AACrE,MAAK,iBAAiB,KAAM;AAC3B,WAAO,OAAO,YAAa,KAAM;AAAA,EAClC;AAEA,MACC,OAAO,WAAW,eAClB,iBAAiB,OAAO,aACvB;AACD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAOA,SAAS,uBAAuC;AAC/C,QAAM,QAAkE,CAAC;AACzE,SAAO;AAAA,IACN,UAAW,cAAsB,MAA2B;AAC3D,aAAO,CAAC,EACP,MAAO,YAAa,KACpB,MAAO,YAAa,EAAE,IAAK,oBAAqB,IAAK,CAAE;AA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,IACD;AAAA,EACD;AAKA,OAAM,iBAAiB,4BAA6B;AAEpD,SAAO;AAGR;AAaA,SAAS,sBACR,KACA,SACA,UACA,WACa;AACb,QAAM,WAAW;AAAA,IAChB,GAAG,QAAQ;AAAA,IACX,GAAG;AAAA,EACJ;AAEA,QAAM,qBAAqB;AAAA,IAAW;AAAA,IAAU,CAAE,YACjD,QAAQ,oBAAoB,QAAS,QAAS,IAAI;AAAA,EACnD;AAEA,QAAM,cAAc;AAAA,IACnB,+BAAgC,UAAU,GAAI;AAAA,IAC9C;AAAA,IACA,6BAA8B,kBAAmB;AAAA,IACjD,sBAAuB,SAAU;AAAA,EAClC;AAEA,QAAM,YAA6B,CAAE,gBAAiB,GAAG,WAAY,CAAE;AACvE,MACC,OAAO,WAAW,eAChB,OAAgB,8BACjB;AACD,cAAU;AAAA,MACP,OAAgB,6BAA8B;AAAA,QAC/C,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,WAAW;AAAA,UACV,UAAU;AAAA,QACX;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAEA,QAAM,EAAE,SAAS,aAAa,IAAI;AAClC,QAAM,kBAAkB,gBAAiB;AAAA,IACxC,UAAU;AAAA,IACV,MAAM;AAAA,EACP,CAAE;AAEF,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,aAAa;AAAA,IACrB,QAAS,GAAG,SAAU;AAAA,EACvB;AACD;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport type { Store as ReduxStore, StoreEnhancer } from 'redux';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { combineReducers } from './combine-reducers';\nimport { builtinControls } from '../controls';\nimport { lock } from '../lock-unlock';\nimport promise from '../promise-middleware';\nimport createResolversCacheMiddleware from '../resolvers-cache-middleware';\nimport createThunkMiddleware from './thunk-middleware';\nimport metadataReducer from './metadata/reducer';\nimport * as metadataSelectors from './metadata/selectors';\nimport * as metadataActions from './metadata/actions';\nimport type {\n\tDataRegistry,\n\tListenerFunction,\n\tStoreDescriptor,\n\tReduxStoreConfig,\n\tActionCreator,\n\tNormalizedResolver,\n} from '../types';\n\nexport { combineReducers };\n\n/**\n * Augment the Redux store with internal properties used by the data module.\n */\ninterface AugmentedReduxStore extends ReduxStore {\n\t__unstableOriginalGetState: ReduxStore[ 'getState' ];\n}\n\ninterface ResolversCache {\n\tisRunning: ( selectorName: string, args: unknown[] ) => boolean;\n\tclear: ( selectorName: string, args: unknown[] ) => void;\n\tmarkAsRunning: ( selectorName: string, args: unknown[] ) => void;\n}\n\ninterface BindingCache {\n\tget: ( itemName: string ) => ( ( ...args: unknown[] ) => unknown ) | null;\n}\n\ninterface SelectorLike {\n\t( ...args: any[] ): any;\n\thasResolver?: boolean;\n\tisRegistrySelector?: boolean;\n\tregistry?: DataRegistry;\n\t__unstableNormalizeArgs?: ( args: unknown[] ) => unknown[];\n}\n\nconst trimUndefinedValues = ( array: unknown[] ): unknown[] => {\n\tconst result = [ ...array ];\n\tfor ( let i = result.length - 1; i >= 0; i-- ) {\n\t\tif ( result[ i ] === undefined ) {\n\t\t\tresult.splice( i, 1 );\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param obj The object to transform.\n * @param callback The function to transform each object value.\n * @return Transformed object.\n */\nconst mapValues = < T, U >(\n\tobj: Record< string, T > | undefined,\n\tcallback: ( value: T, key: string ) => U\n): Record< string, U > =>\n\tObject.fromEntries(\n\t\tObject.entries( obj ?? {} ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tcallback( value, key ),\n\t\t] )\n\t);\n\n// Convert non serializable types to plain objects\nconst devToolsReplacer = ( _key: string, state: unknown ): unknown => {\n\tif ( state instanceof Map ) {\n\t\treturn Object.fromEntries( state );\n\t}\n\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\tstate instanceof window.HTMLElement\n\t) {\n\t\treturn null;\n\t}\n\n\treturn state;\n};\n\n/**\n * Create a cache to track whether resolvers started running or not.\n *\n * @return Resolvers Cache.\n */\nfunction createResolversCache(): ResolversCache {\n\tconst cache: Record< string, EquivalentKeyMap< unknown[], boolean > > = {};\n\treturn {\n\t\tisRunning( selectorName: string, args: unknown[] ): boolean {\n\t\t\treturn !! (\n\t\t\t\tcache[ selectorName ] &&\n\t\t\t\tcache[ selectorName ].get( trimUndefinedValues( args ) )\n\t\t\t);\n\t\t},\n\n\t\tclear( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ].delete( trimUndefinedValues( args ) );\n\t\t\t}\n\t\t},\n\n\t\tmarkAsRunning( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( ! cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ] = new EquivalentKeyMap();\n\t\t\t}\n\n\t\t\tcache[ selectorName ].set( trimUndefinedValues( args ), true );\n\t\t},\n\t};\n}\n\nfunction createBindingCache(\n\tgetItem: ( name: string ) => ( ( ...args: any[] ) => any ) | undefined,\n\tbindItem: (\n\t\titem: ( ...args: any[] ) => any,\n\t\tname: string\n\t) => ( ...args: unknown[] ) => unknown\n): BindingCache {\n\tconst cache = new WeakMap<\n\t\t( ...args: any[] ) => any,\n\t\t( ...args: unknown[] ) => unknown\n\t>();\n\n\treturn {\n\t\tget( itemName: string ) {\n\t\t\tconst item = getItem( itemName );\n\t\t\tif ( ! item ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet boundItem = cache.get( item );\n\t\t\tif ( ! boundItem ) {\n\t\t\t\tboundItem = bindItem( item, itemName );\n\t\t\t\tcache.set( item, boundItem );\n\t\t\t}\n\t\t\treturn boundItem;\n\t\t},\n\t};\n}\n\nfunction createPrivateProxy< T extends Record< string, any > >(\n\tpublicItems: T,\n\tprivateItems: BindingCache\n): T {\n\treturn new Proxy( publicItems, {\n\t\tget: ( target, itemName: string ) =>\n\t\t\tprivateItems.get( itemName ) || Reflect.get( target, itemName ),\n\t} );\n}\n\n/**\n * Creates a data store descriptor for the provided Redux store configuration containing\n * properties describing reducer, actions, selectors, controls and resolvers.\n *\n * @example\n * ```js\n * import { createReduxStore } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * ```\n *\n * @param key Unique namespace identifier.\n * @param options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return Store Object.\n */\nexport default function createReduxStore< State, Actions, Selectors >(\n\tkey: string,\n\toptions: ReduxStoreConfig< State, Actions, Selectors >\n): StoreDescriptor< ReduxStoreConfig< State, Actions, Selectors > > {\n\tconst privateActions: Record< string, ActionCreator > = {};\n\tconst privateSelectors: Record< string, SelectorLike > = {};\n\tconst privateRegistrationFunctions = {\n\t\tprivateActions,\n\t\tregisterPrivateActions: (\n\t\t\tactions: Record< string, ActionCreator >\n\t\t) => {\n\t\t\tObject.assign( privateActions, actions );\n\t\t},\n\t\tprivateSelectors,\n\t\tregisterPrivateSelectors: (\n\t\t\tselectors: Record< string, SelectorLike >\n\t\t) => {\n\t\t\tObject.assign( privateSelectors, selectors );\n\t\t},\n\t};\n\tconst storeDescriptor = {\n\t\tname: key,\n\t\tinstantiate: ( registry: DataRegistry ) => {\n\t\t\t/**\n\t\t\t * Stores listener functions registered with `subscribe()`.\n\t\t\t *\n\t\t\t * When functions register to listen to store changes with\n\t\t\t * `subscribe()` they get added here. Although Redux offers\n\t\t\t * its own `subscribe()` function directly, by wrapping the\n\t\t\t * subscription in this store instance it's possible to\n\t\t\t * optimize checking if the state has changed before calling\n\t\t\t * each listener.\n\t\t\t */\n\t\t\tconst listeners = new Set< ListenerFunction >();\n\t\t\tconst reducer = options.reducer;\n\n\t\t\t// Object that every thunk function receives as the first argument. It contains the\n\t\t\t// `registry`, `dispatch`, `select` and `resolveSelect` fields. Some of them are\n\t\t\t// constructed as getters to avoid circular dependencies.\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn thunkDispatch;\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn thunkSelect;\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn resolveSelectors;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst store = instantiateReduxStore(\n\t\t\t\tkey,\n\t\t\t\toptions,\n\t\t\t\tregistry,\n\t\t\t\tthunkArgs\n\t\t\t) as AugmentedReduxStore;\n\n\t\t\t// Expose the private registration functions on the store\n\t\t\t// so they can be copied to a sub registry in registry.js.\n\t\t\tlock( store, privateRegistrationFunctions );\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\t// Binds an action creator (`action`) to the `store`, making it a callable function.\n\t\t\t// These are the functions that are returned by `useDispatch`, for example.\n\t\t\t// It always returns a `Promise`, although actions are not always async. That's an\n\t\t\t// unfortunate backward compatibility measure.\n\t\t\tfunction bindAction( action: ( ...args: any[] ) => any ) {\n\t\t\t\treturn ( ...args: unknown[] ) =>\n\t\t\t\t\tPromise.resolve( store.dispatch( action( ...args ) ) );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Object with all public actions, both metadata and store actions.\n\t\t\t */\n\t\t\tconst actions = {\n\t\t\t\t...mapValues(\n\t\t\t\t\tmetadataActions as Record< string, ActionCreator >,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t\t...mapValues(\n\t\t\t\t\toptions.actions as\n\t\t\t\t\t\t| Record< string, ActionCreator >\n\t\t\t\t\t\t| undefined,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t};\n\n\t\t\t// Object with both public and private actions. Private actions are accessed through a proxy,\n\t\t\t// which looks them up in real time on the `privateActions` object. That's because private\n\t\t\t// actions can be registered at any time with `registerPrivateActions`. Also once a private\n\t\t\t// action creator is bound to the store, it is cached to give it a stable identity.\n\t\t\tconst allActions = createPrivateProxy(\n\t\t\t\tactions,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => privateActions[ name ],\n\t\t\t\t\tbindAction\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// An object that implements the `dispatch` object that is passed to thunk functions.\n\t\t\t// It is callable (`dispatch( action )`) and also has methods (`dispatch.foo()`) that\n\t\t\t// correspond to bound registered actions, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allActions`.\n\t\t\tconst thunkDispatch = new Proxy(\n\t\t\t\t( action: any ) => store.dispatch( action ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allActions[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `actions` object, add the \"locked\" `allActions` object. When used,\n\t\t\t// `unlock( actions )` will return `allActions`, implementing a way how to get at the private actions.\n\t\t\tlock( actions, allActions );\n\n\t\t\t// If we have selector resolvers, convert them to a normalized form.\n\t\t\tconst resolvers: Record< string, NormalizedResolver > =\n\t\t\t\toptions.resolvers\n\t\t\t\t\t? mapValues(\n\t\t\t\t\t\t\toptions.resolvers as Record< string, any >,\n\t\t\t\t\t\t\tmapResolver\n\t\t\t\t\t )\n\t\t\t\t\t: {};\n\n\t\t\t// Bind a selector to the store. Call the selector with the current state, correct registry,\n\t\t\t// and if there is a resolver, attach the resolver logic to the selector.\n\t\t\tfunction bindSelector(\n\t\t\t\tselector: SelectorLike,\n\t\t\t\tselectorName: string\n\t\t\t): SelectorLike {\n\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\tselector.registry = registry;\n\t\t\t\t}\n\t\t\t\tconst boundSelector: SelectorLike = ( ...args: any[] ) => {\n\t\t\t\t\targs = normalize( selector, args );\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t// Before calling the selector, switch to the correct registry.\n\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t}\n\t\t\t\t\treturn selector( state.root, ...args );\n\t\t\t\t};\n\n\t\t\t\t// Expose normalization method on the bound selector\n\t\t\t\t// in order that it can be called when fulfilling\n\t\t\t\t// the resolver.\n\t\t\t\tboundSelector.__unstableNormalizeArgs =\n\t\t\t\t\tselector.__unstableNormalizeArgs;\n\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\n\t\t\t\tif ( ! resolver ) {\n\t\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\t\treturn boundSelector;\n\t\t\t\t}\n\n\t\t\t\treturn mapSelectorWithResolver(\n\t\t\t\t\tboundSelector,\n\t\t\t\t\tselectorName,\n\t\t\t\t\tresolver,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache,\n\t\t\t\t\tboundMetadataSelectors\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Metadata selectors are bound differently: different state (`state.metadata`), no resolvers,\n\t\t\t// normalization depending on the target selector.\n\t\t\tfunction bindMetadataSelector(\n\t\t\t\tmetaDataSelector: ( ...args: any[] ) => any\n\t\t\t): SelectorLike {\n\t\t\t\tconst boundSelector: SelectorLike = (\n\t\t\t\t\tselectorName: string,\n\t\t\t\t\tselectorArgs: unknown[],\n\t\t\t\t\t...args: unknown[]\n\t\t\t\t) => {\n\t\t\t\t\t// Normalize the arguments passed to the target selector.\n\t\t\t\t\tif ( selectorName ) {\n\t\t\t\t\t\tconst targetSelector = ( options.selectors as any )?.[\n\t\t\t\t\t\t\tselectorName\n\t\t\t\t\t\t];\n\t\t\t\t\t\tif ( targetSelector ) {\n\t\t\t\t\t\t\tselectorArgs = normalize(\n\t\t\t\t\t\t\t\ttargetSelector,\n\t\t\t\t\t\t\t\tselectorArgs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\n\t\t\t\t\treturn metaDataSelector(\n\t\t\t\t\t\tstate.metadata,\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tselectorArgs,\n\t\t\t\t\t\t...args\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\treturn boundSelector;\n\t\t\t}\n\n\t\t\t// Perform binding of both metadata and store selectors and combine them in one\n\t\t\t// `selectors` object. These are all public selectors of the store.\n\t\t\tconst boundMetadataSelectors = mapValues(\n\t\t\t\tmetadataSelectors as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\t( ...args: any[] ) => any\n\t\t\t\t>,\n\t\t\t\tbindMetadataSelector\n\t\t\t);\n\n\t\t\tconst boundSelectors = mapValues(\n\t\t\t\toptions.selectors as Record< string, SelectorLike > | undefined,\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst selectors = {\n\t\t\t\t...boundMetadataSelectors,\n\t\t\t\t...boundSelectors,\n\t\t\t};\n\n\t\t\t// Cache of bound private selectors. They are bound only when first accessed, because\n\t\t\t// new private selectors can be registered at any time (with `registerPrivateSelectors`).\n\t\t\t// Once bound, they are cached to give them a stable identity.\n\t\t\tconst boundPrivateSelectors = createBindingCache(\n\t\t\t\t( name ) => privateSelectors[ name ],\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst allSelectors = createPrivateProxy(\n\t\t\t\tselectors,\n\t\t\t\tboundPrivateSelectors\n\t\t\t);\n\n\t\t\t// Pre-bind the private selectors that have been registered by the time of\n\t\t\t// instantiation, so that registry selectors are bound to the registry.\n\t\t\tfor ( const selectorName of Object.keys( privateSelectors ) ) {\n\t\t\t\tboundPrivateSelectors.get( selectorName );\n\t\t\t}\n\n\t\t\t// An object that implements the `select` object that is passed to thunk functions.\n\t\t\t// It is callable (`select( selector )`) and also has methods (`select.foo()`) that\n\t\t\t// correspond to bound registered selectors, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allSelectors`.\n\t\t\tconst thunkSelect = new Proxy(\n\t\t\t\t( selector: ( state: any ) => any ) =>\n\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allSelectors[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `selectors` object, add the \"locked\" `allSelectors` object. When used,\n\t\t\t// `unlock( selectors )` will return `allSelectors`, implementing a way how to get at the private selectors.\n\t\t\tlock( selectors, allSelectors );\n\n\t\t\t// For each selector, create a function that calls the selector, waits for resolution and returns\n\t\t\t// a promise that resolves when the resolution is finished.\n\t\t\tconst bindResolveSelector = mapResolveSelector(\n\t\t\t\tstore,\n\t\t\t\tresolvers,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\t// Now apply this function to all bound selectors, public and private. We are excluding\n\t\t\t// metadata selectors because they don't have resolvers.\n\t\t\tconst resolveSelectors = mapValues(\n\t\t\t\tboundSelectors,\n\t\t\t\tbindResolveSelector\n\t\t\t);\n\n\t\t\tconst allResolveSelectors = createPrivateProxy(\n\t\t\t\tresolveSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindResolveSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( resolveSelectors )` returns `allResolveSelectors`.\n\t\t\tlock( resolveSelectors, allResolveSelectors );\n\n\t\t\t// Now, in a way very similar to `bindResolveSelector`, we create a function that maps\n\t\t\t// selectors to functions that throw a suspense promise if not yet resolved.\n\t\t\tconst bindSuspendSelector = mapSuspendSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\tconst suspendSelectors = {\n\t\t\t\t...boundMetadataSelectors, // no special suspense behavior\n\t\t\t\t...mapValues( boundSelectors, bindSuspendSelector ),\n\t\t\t};\n\n\t\t\tconst allSuspendSelectors = createPrivateProxy(\n\t\t\t\tsuspendSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindSuspendSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( suspendSelectors )` returns 'allSuspendSelectors`.\n\t\t\tlock( suspendSelectors, allSuspendSelectors );\n\n\t\t\tconst getSelectors = () => selectors;\n\t\t\tconst getActions = () => actions;\n\t\t\tconst getResolveSelectors = () => resolveSelectors;\n\t\t\tconst getSuspendSelectors = () => suspendSelectors;\n\n\t\t\t// We have some modules monkey-patching the store object\n\t\t\t// It's wrong to do so but until we refactor all of our effects to controls\n\t\t\t// We need to keep the same \"store\" instance here.\n\t\t\tstore.__unstableOriginalGetState = store.getState;\n\t\t\tstore.getState = () => store.__unstableOriginalGetState().root;\n\n\t\t\t// Customize subscribe behavior to call listeners only on effective change,\n\t\t\t// not on every dispatch.\n\t\t\tconst subscribe = ( listener: ListenerFunction ) => {\n\t\t\t\tlisteners.add( listener );\n\n\t\t\t\treturn () => listeners.delete( listener );\n\t\t\t};\n\n\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\tstore.subscribe( () => {\n\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\tlastState = state;\n\n\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\tfor ( const listener of listeners ) {\n\t\t\t\t\t\tlistener();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// This can be simplified to just { subscribe, getSelectors, getActions }\n\t\t\t// Once we remove the use function.\n\t\t\treturn {\n\t\t\t\treducer,\n\t\t\t\tstore,\n\t\t\t\tactions,\n\t\t\t\tselectors,\n\t\t\t\tresolvers,\n\t\t\t\tgetSelectors,\n\t\t\t\tgetResolveSelectors,\n\t\t\t\tgetSuspendSelectors,\n\t\t\t\tgetActions,\n\t\t\t\tsubscribe,\n\t\t\t};\n\t\t},\n\t};\n\n\t// Expose the private registration functions on the store\n\t// descriptor. That's a natural choice since that's where the\n\t// public actions and selectors are stored.\n\tlock( storeDescriptor, privateRegistrationFunctions );\n\n\treturn storeDescriptor as unknown as StoreDescriptor<\n\t\tReduxStoreConfig< State, Actions, Selectors >\n\t>;\n}\n\n/**\n * Creates a redux store for a namespace.\n *\n * @param key Unique namespace identifier.\n * @param options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param registry Registry reference.\n * @param thunkArgs Argument object for the thunk middleware.\n * @return Newly created redux store.\n */\nfunction instantiateReduxStore(\n\tkey: string,\n\toptions: ReduxStoreConfig< any, any, any >,\n\tregistry: DataRegistry,\n\tthunkArgs: unknown\n): ReduxStore {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control: any ) =>\n\t\tcontrol.isRegistryControl ? control( registry ) : control\n\t);\n\n\tconst middlewares = [\n\t\tcreateResolversCacheMiddleware( registry, key ),\n\t\tpromise,\n\t\tcreateReduxRoutineMiddleware( normalizedControls ),\n\t\tcreateThunkMiddleware( thunkArgs ),\n\t];\n\n\tconst enhancers: StoreEnhancer[] = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\n\t\t\t\tserialize: {\n\t\t\t\t\treplacer: devToolsReplacer,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst { reducer, initialState } = options;\n\tconst enhancedReducer = combineReducers( {\n\t\tmetadata: metadataReducer,\n\t\troot: reducer,\n\t} );\n\n\treturn createStore(\n\t\tenhancedReducer,\n\t\t{ root: initialState } as any,\n\t\tcompose( ...enhancers ) as unknown as StoreEnhancer\n\t);\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them.\n *\n * @param store The redux store the selectors are bound to.\n * @param resolvers The normalized resolvers for the store.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to resolvers.\n */\nfunction mapResolveSelector(\n\tstore: ReduxStore,\n\tresolvers: Record< string, NormalizedResolver >,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// If the selector doesn't have a resolver, just convert the return value\n\t\t// (including exceptions) to a Promise, no additional extra behavior is needed.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn async ( ...args: unknown[] ) => selector( ...args );\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) =>\n\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\t\t\t\tconst hasFinished = () => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\t\t\tresolver.isFulfilled( store.getState(), ...args ) )\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst finalize = ( result: unknown ) => {\n\t\t\t\t\tconst hasFailed =\n\t\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve( result );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst getResult = () => selector( ...args );\n\n\t\t\t\t// Trigger the selector (to trigger the resolver)\n\t\t\t\tconst result = getResult();\n\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\treturn finalize( result );\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\tfinalize( getResult() );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t};\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param store The redux store the selectors select from.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to their suspending versions.\n */\nfunction mapSuspendSelector(\n\tstore: ReduxStore,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// Selector without a resolver doesn't have any extra suspense behavior.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn selector;\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) => {\n\t\t\tconst result = selector( ...args );\n\n\t\t\tif (\n\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\tselectorName,\n\t\t\t\t\targs\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise< void >( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t};\n}\n\n/**\n * Convert a resolver to a normalized form, an object with `fulfill` method and\n * optional methods like `isFulfilled`.\n *\n * @param resolver Resolver to convert\n */\nfunction mapResolver( resolver: any ): NormalizedResolver {\n\tif ( resolver.fulfill ) {\n\t\treturn resolver;\n\t}\n\n\treturn {\n\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\tfulfill: resolver, // Add the fulfill method.\n\t};\n}\n\n/**\n * Returns a selector with a matched resolver.\n * Resolvers are side effects invoked once per argument set of a given selector call,\n * used in ensuring that the data needs for the selector are satisfied.\n *\n * @param selector The selector function to be bound.\n * @param selectorName The selector name.\n * @param resolver Resolver to call.\n * @param store The redux store to which the resolvers should be mapped.\n * @param resolversCache Resolvers Cache.\n * @param boundMetadataSelectors The bound metadata selectors.\n */\nfunction mapSelectorWithResolver(\n\tselector: SelectorLike,\n\tselectorName: string,\n\tresolver: NormalizedResolver,\n\tstore: AugmentedReduxStore,\n\tresolversCache: ResolversCache,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n): SelectorLike {\n\tfunction fulfillSelector( args: unknown[] ): void {\n\t\tif (\n\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\tboundMetadataSelectors.hasStartedResolution( selectorName, args ) ||\n\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\tresolver.isFulfilled( store.getState(), ...args ) )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\tsetTimeout( async () => {\n\t\t\tresolversCache.clear( selectorName, args );\n\t\t\tstore.dispatch(\n\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tconst action = resolver.fulfill( ...args );\n\t\t\t\tif ( action ) {\n\t\t\t\t\tawait store.dispatch( action );\n\t\t\t\t}\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.finishResolution( selectorName, args )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.failResolution( selectorName, args, error )\n\t\t\t\t);\n\t\t\t}\n\t\t}, 0 );\n\t}\n\n\tconst selectorResolver: SelectorLike = ( ...args: unknown[] ) => {\n\t\targs = normalize( selector, args );\n\t\tfulfillSelector( args );\n\t\treturn selector( ...args );\n\t};\n\tselectorResolver.hasResolver = true;\n\treturn selectorResolver;\n}\n\n/**\n * Applies selector's normalization function to the given arguments\n * if it exists.\n *\n * @param selector The selector potentially with a normalization method property.\n * @param args selector arguments to normalize.\n * @return Potentially normalized arguments.\n */\nfunction normalize( selector: SelectorLike, args: unknown[] ): unknown[] {\n\tif (\n\t\tselector.__unstableNormalizeArgs &&\n\t\ttypeof selector.__unstableNormalizeArgs === 'function' &&\n\t\targs?.length\n\t) {\n\t\treturn selector.__unstableNormalizeArgs( args );\n\t}\n\treturn args;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,aAAa,uBAAuB;AAE7C,OAAO,sBAAsB;AAK7B,OAAO,kCAAkC;AACzC,SAAS,eAAe;AAKxB,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,OAAO,aAAa;AACpB,OAAO,oCAAoC;AAC3C,OAAO,2BAA2B;AAClC,OAAO,qBAAqB;AAC5B,YAAY,uBAAuB;AACnC,YAAY,qBAAqB;AAqCjC,IAAM,sBAAsB,CAAE,UAAiC;AAC9D,QAAM,SAAS,CAAE,GAAG,KAAM;AAC1B,WAAU,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,KAAM;AAC9C,QAAK,OAAQ,CAAE,MAAM,QAAY;AAChC,aAAO,OAAQ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AAM;AAAA,UACW,iCAAkB,cAAc,IAAK;AAAA,QACtD;AAAA,MACD,SAAU,OAAQ;AACjB,cAAM;AAAA,UACW,+BAAgB,cAAc,MAAM,KAAM;AAAA,QAC3D;AAAA,MACD;AAAA,IACD,GAAG,CAAE;AAAA,EACN;AAEA,QAAM,mBAAiC,IAAK,SAAqB;AAChE,WAAO,UAAW,UAAU,IAAK;AACjC,oBAAiB,IAAK;AACtB,WAAO,SAAU,GAAG,IAAK;AAAA,EAC1B;AACA,mBAAiB,cAAc;AAC/B,SAAO;AACR;AAUA,SAAS,UAAW,UAAwB,MAA6B;AACxE,MACC,SAAS,2BACT,OAAO,SAAS,4BAA4B,cAC5C,MAAM,QACL;AACD,WAAO,SAAS,wBAAyB,IAAK;AAAA,EAC/C;AACA,SAAO;AACR;",
|
|
6
6
|
"names": ["result"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/async-mode-provider/context.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,kCAAyB,CAAC;AAG9C,QAAA,MAAkB,QAAQ,mCAAY,CAAC;AAEvC,eAAO,MAAM,iBAAiB,mCAAW,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/async-mode-provider/context.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,kCAAyB,CAAC;AAG9C,QAAA,MAAkB,QAAQ,mCAAY,CAAC;AAEvC,eAAO,MAAM,iBAAiB,mCAAW,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;eACY,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/registry-provider/context.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,OAAO,uDAAmC,CAAC;AAGxD,QAAA,MAAkB,QAAQ,wDAAY,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,gBAAgB,wDAAW,CAAC;AAEzC;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/registry-provider/context.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,OAAO,uDAAmC,CAAC;AAGxD,QAAA,MAAkB,QAAQ,wDAAY,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,gBAAgB,wDAAW,CAAC;AAEzC;;;;;;GAMG;eACY,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dispatch-with-map.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch-with-map.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,KAAK,WAAW,GAAG,CAClB,QAAQ,EAAE,YAAY,CAAE,UAAU,CAAE,EACpC,QAAQ,EAAE,YAAY,KAClB,MAAM,CAAE,MAAM,EAAE,CAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAM,OAAO,CAAE,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"use-dispatch-with-map.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch-with-map.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,KAAK,WAAW,GAAG,CAClB,QAAQ,EAAE,YAAY,CAAE,UAAU,CAAE,EACpC,QAAQ,EAAE,YAAY,KAClB,MAAM,CAAE,MAAM,EAAE,CAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAM,OAAO,CAAE,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,kBAAkB,gBACV,WAAW,QAClB,OAAO,EAAE,KACb,MAAM,CAAE,MAAM,EAAE,CAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAM,OAAO,CAiCnD,CAAC;eAEa,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dispatch.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,QAAA,MAAM,WAAW,GAChB,qBAAqB,SAClB,SAAS,GACT,MAAM,GACN,eAAe,CAAE,SAAS,CAAE,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"use-dispatch.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,QAAA,MAAM,WAAW,GAChB,qBAAqB,SAClB,SAAS,GACT,MAAM,GACN,eAAe,CAAE,SAAS,CAAE,GAAG,SAAS,0BAEnB,qBAAqB,KAC3C,iBAAiB,CAAE,qBAAqB,CAO1C,CAAC;eAEa,WAAW"}
|
|
@@ -80,6 +80,6 @@ import type { DataRegistry } from '../../types';
|
|
|
80
80
|
*
|
|
81
81
|
* @return Enhanced component with merged dispatcher props.
|
|
82
82
|
*/
|
|
83
|
-
declare const withDispatch: (mapDispatchToProps: (dispatch: DataRegistry[
|
|
83
|
+
declare const withDispatch: (mapDispatchToProps: (dispatch: DataRegistry['dispatch'], ownProps: Record<string, unknown>, registry: DataRegistry) => Record<string, (...args: unknown[]) => unknown>) => (Inner: import("react").ComponentType<any>) => (ownProps: Record<string, unknown>) => import("react").JSX.Element;
|
|
84
84
|
export default withDispatch;
|
|
85
85
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/with-dispatch/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,QAAA,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/with-dispatch/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,QAAA,MAAM,YAAY,uBACG,CACnB,QAAQ,EAAE,YAAY,CAAE,UAAU,CAAE,EACpC,QAAQ,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,EACnC,QAAQ,EAAE,YAAY,KAClB,MAAM,CAAE,MAAM,EAAE,CAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAM,OAAO,CAAE,+DAGnB,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,gCAS7D,CAAC;eAEY,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/with-registry/index.tsx"],"names":[],"mappings":"AAUA;;;GAGG;AACH,QAAA,MAAM,YAAY,yDACiB,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,gCAQ3D,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/with-registry/index.tsx"],"names":[],"mappings":"AAUA;;;GAGG;AACH,QAAA,MAAM,YAAY,yDACiB,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,gCAQ3D,CAAC;eAEa,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/with-select/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,QAAA,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/with-select/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,QAAA,MAAM,UAAU,qBACG,CACjB,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,EACnC,QAAQ,EAAE,YAAY,KAClB,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,0GAa7B,CAAC;eAEY,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-registry.d.ts","sourceRoot":"","sources":["../src/default-registry.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,eAAe,gCAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"default-registry.d.ts","sourceRoot":"","sources":["../src/default-registry.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,eAAe,gCAAmB,CAAC;eAE1B,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAGrC,OAAO,KAAK,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AU,CAAC;AAElC,mBAAmB,SAAS,CAAC;AAE7B;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,eAAe,EACS,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAE,CAAC,SAAS,eAAe,CAAE,SAAS,CAAE,EACpE,qBAAqB,EAAE,CAAC,GAAG,MAAM,GAC/B,yBAAyB,CAAE,CAAC,CAAE,CAIhC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,0BAEtB,MAAM,GACN,eAAe,CAAE,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,CAAE,KACrD,GAA6D,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,SAAS,aACX,MAAM,IAAI,0BAEjB,MAAM,GACN,eAAe,CAAE,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,CAAE,KACrD,CAAE,MAAM,IAAI,CAC8C,CAAC;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,QACE,CAAC;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,QAAwC,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,EAAE,GAAyB,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,QAAQ,UACb,eAAe,CAAE,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,CAAE,KACzD,IAAyC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/persistence/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/persistence/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,KAAK,EACX,YAAY,EAEZ,gBAAgB,EAChB,MAAM,aAAa,CAAC;AAErB,UAAU,wBAAwB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,oBAAoB;IAC7B,GAAG,EAAE,MAAM,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;IACrC,GAAG,EAAE,CAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAM,IAAI,CAAC;CAC7C;AAYD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,YAClB,CAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAM,GAAG,aACpC,OAAO,UAAU;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAM/C,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,wBAAwB,GAC/B,oBAAoB,CA+CtB;AAED;;;;;;;GAOG;AACH,iBAAS,iBAAiB,CACzB,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,wBAAwB,GACrC,OAAO,CAAE,YAAY,CAAE,CA8HzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/plugins/persistence/storage/default.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,QAAA,IAAI,OAAO,EAAE,gBAAgB,GAAG;IAAE,UAAU,CAAC,EAAE,CAAE,GAAG,EAAE,MAAM,KAAM,IAAI,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/plugins/persistence/storage/default.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,QAAA,IAAI,OAAO,EAAE,gBAAgB,GAAG;IAAE,UAAU,CAAC,EAAE,CAAE,GAAG,EAAE,MAAM,KAAM,IAAI,CAAA;CAAE,CAAC;eAa1D,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../../src/plugins/persistence/storage/object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,QAAA,MAAM,OAAO,EAAE,gBAAgB,GAAG;IAAE,KAAK,EAAE,YAAY,CAAA;CAkBtD,CAAC;
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../../src/plugins/persistence/storage/object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,QAAA,MAAM,OAAO,EAAE,gBAAgB,GAAG;IAAE,KAAK,EAAE,YAAY,CAAA;CAkBtD,CAAC;eAEa,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise-middleware.d.ts","sourceRoot":"","sources":["../src/promise-middleware.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGxC;;GAEG;AACH,QAAA,MAAM,iBAAiB,EAAE,UAWxB,CAAC;
|
|
1
|
+
{"version":3,"file":"promise-middleware.d.ts","sourceRoot":"","sources":["../src/promise-middleware.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGxC;;GAEG;AACH,QAAA,MAAM,iBAAiB,EAAE,UAWxB,CAAC;eAEa,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redux-store/index.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AASrD,OAAO,KAAK,EAGX,eAAe,EACf,gBAAgB,EAGhB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAE,CAAC;AA6I3B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAClE,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,gBAAgB,CAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAE,GACpD,eAAe,CAAE,gBAAgB,CAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAE,CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redux-store/index.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AASrD,OAAO,KAAK,EAGX,eAAe,EACf,gBAAgB,EAGhB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAE,CAAC;AA6I3B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAClE,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,gBAAgB,CAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAE,GACpD,eAAe,CAAE,gBAAgB,CAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAE,CAAE,CA+WlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyed-reducer.d.ts","sourceRoot":"","sources":["../../src/redux-store/keyed-reducer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,GACtB,MAAM,SAAS,OAAO,EAAE,OAAO,SAAS,SAAS,
|
|
1
|
+
{"version":3,"file":"keyed-reducer.d.ts","sourceRoot":"","sources":["../../src/redux-store/keyed-reducer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,GACtB,MAAM,SAAS,OAAO,EAAE,OAAO,SAAS,SAAS,kBAClC,MAAM,eAGb,OAAO,CAAE,MAAM,EAAE,OAAO,CAAE,KACjC,OAAO,CAAE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,EAAE,OAAO,CAoB5C,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @return Action object.
|
|
9
9
|
*/
|
|
10
10
|
export declare function startResolution(selectorName: string, args: unknown[]): {
|
|
11
|
-
readonly type:
|
|
11
|
+
readonly type: 'START_RESOLUTION';
|
|
12
12
|
readonly selectorName: string;
|
|
13
13
|
readonly args: unknown[];
|
|
14
14
|
};
|
|
@@ -22,7 +22,7 @@ export declare function startResolution(selectorName: string, args: unknown[]):
|
|
|
22
22
|
* @return Action object.
|
|
23
23
|
*/
|
|
24
24
|
export declare function finishResolution(selectorName: string, args: unknown[]): {
|
|
25
|
-
readonly type:
|
|
25
|
+
readonly type: 'FINISH_RESOLUTION';
|
|
26
26
|
readonly selectorName: string;
|
|
27
27
|
readonly args: unknown[];
|
|
28
28
|
};
|
|
@@ -37,7 +37,7 @@ export declare function finishResolution(selectorName: string, args: unknown[]):
|
|
|
37
37
|
* @return Action object.
|
|
38
38
|
*/
|
|
39
39
|
export declare function failResolution(selectorName: string, args: unknown[], error: Error | unknown): {
|
|
40
|
-
readonly type:
|
|
40
|
+
readonly type: 'FAIL_RESOLUTION';
|
|
41
41
|
readonly selectorName: string;
|
|
42
42
|
readonly args: unknown[];
|
|
43
43
|
readonly error: unknown;
|
|
@@ -53,7 +53,7 @@ export declare function failResolution(selectorName: string, args: unknown[], er
|
|
|
53
53
|
* @return Action object.
|
|
54
54
|
*/
|
|
55
55
|
export declare function startResolutions(selectorName: string, args: unknown[][]): {
|
|
56
|
-
readonly type:
|
|
56
|
+
readonly type: 'START_RESOLUTIONS';
|
|
57
57
|
readonly selectorName: string;
|
|
58
58
|
readonly args: unknown[][];
|
|
59
59
|
};
|
|
@@ -68,7 +68,7 @@ export declare function startResolutions(selectorName: string, args: unknown[][]
|
|
|
68
68
|
* @return Action object.
|
|
69
69
|
*/
|
|
70
70
|
export declare function finishResolutions(selectorName: string, args: unknown[][]): {
|
|
71
|
-
readonly type:
|
|
71
|
+
readonly type: 'FINISH_RESOLUTIONS';
|
|
72
72
|
readonly selectorName: string;
|
|
73
73
|
readonly args: unknown[][];
|
|
74
74
|
};
|
|
@@ -84,7 +84,7 @@ export declare function finishResolutions(selectorName: string, args: unknown[][
|
|
|
84
84
|
* @return Action object.
|
|
85
85
|
*/
|
|
86
86
|
export declare function failResolutions(selectorName: string, args: unknown[], errors: (Error | unknown)[]): {
|
|
87
|
-
readonly type:
|
|
87
|
+
readonly type: 'FAIL_RESOLUTIONS';
|
|
88
88
|
readonly selectorName: string;
|
|
89
89
|
readonly args: unknown[];
|
|
90
90
|
readonly errors: unknown[];
|
|
@@ -98,7 +98,7 @@ export declare function failResolutions(selectorName: string, args: unknown[], e
|
|
|
98
98
|
* @return Action object.
|
|
99
99
|
*/
|
|
100
100
|
export declare function invalidateResolution(selectorName: string, args: unknown[]): {
|
|
101
|
-
readonly type:
|
|
101
|
+
readonly type: 'INVALIDATE_RESOLUTION';
|
|
102
102
|
readonly selectorName: string;
|
|
103
103
|
readonly args: unknown[];
|
|
104
104
|
};
|
|
@@ -109,7 +109,7 @@ export declare function invalidateResolution(selectorName: string, args: unknown
|
|
|
109
109
|
* @return Action object.
|
|
110
110
|
*/
|
|
111
111
|
export declare function invalidateResolutionForStore(): {
|
|
112
|
-
readonly type:
|
|
112
|
+
readonly type: 'INVALIDATE_RESOLUTION_FOR_STORE';
|
|
113
113
|
};
|
|
114
114
|
/**
|
|
115
115
|
* Returns an action object used in signalling that the resolution cache for a
|
|
@@ -121,7 +121,7 @@ export declare function invalidateResolutionForStore(): {
|
|
|
121
121
|
* @return Action object.
|
|
122
122
|
*/
|
|
123
123
|
export declare function invalidateResolutionForStoreSelector(selectorName: string): {
|
|
124
|
-
readonly type:
|
|
124
|
+
readonly type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR';
|
|
125
125
|
readonly selectorName: string;
|
|
126
126
|
};
|
|
127
127
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;mBAE9D,kBAAkB;;;EAIzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;mBAE/D,mBAAmB;;;EAI1B;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EAAE,EACf,KAAK,EAAE,KAAK,GAAG,OAAO;mBAGf,iBAAiB;;;;EAKxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;mB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nB;IAAE,MAAM,EAAE,WAAW,GAAG,UAAU,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAA;CAAE,CAAC;AAE/C,MAAM,MAAM,MAAM,GAAG,UAAU,CAAE,QAAQ,CAAE,CAAC;AAC5C,MAAM,MAAM,KAAK,GAAG,gBAAgB,CAAE,QAAQ,EAAE,UAAU,CAAE,CAAC;AAqF7D;;;;;;;;;GASG;AACH,QAAA,MAAM,UAAU,UAAY,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,sBAAe,MAAM,0BAyBvE,CAAC;eAEa,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers-cache-middleware.d.ts","sourceRoot":"","sources":["../src/resolvers-cache-middleware.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAExC;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;GAOG;AACH,QAAA,MAAM,8BAA8B,
|
|
1
|
+
{"version":3,"file":"resolvers-cache-middleware.d.ts","sourceRoot":"","sources":["../src/resolvers-cache-middleware.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAExC;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;GAOG;AACH,QAAA,MAAM,8BAA8B,aACvB,YAAY,aAAa,MAAM,KAAI,UAyC9C,CAAC;eAEY,8BAA8B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAgB,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,QAAA,MAAM,aAAa,EAAE,eAAe,CAAE,SAAS,CAuD9C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAgB,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzE,QAAA,MAAM,aAAa,EAAE,eAAe,CAAE,SAAS,CAuD9C,CAAC;eAEa,aAAa"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/data",
|
|
3
|
-
"version": "10.45.1-next.v.
|
|
3
|
+
"version": "10.45.1-next.v.202605131006.0+2a3d07cab",
|
|
4
4
|
"description": "Data module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"types": "build-types",
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@wordpress/compose": "^7.
|
|
49
|
-
"@wordpress/deprecated": "^4.
|
|
50
|
-
"@wordpress/element": "^6.
|
|
51
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
52
|
-
"@wordpress/priority-queue": "^3.
|
|
53
|
-
"@wordpress/private-apis": "^1.
|
|
54
|
-
"@wordpress/redux-routine": "^5.
|
|
48
|
+
"@wordpress/compose": "^7.45.1-next.v.202605131006.0+2a3d07cab",
|
|
49
|
+
"@wordpress/deprecated": "^4.45.1-next.v.202605131006.0+2a3d07cab",
|
|
50
|
+
"@wordpress/element": "^6.45.1-next.v.202605131006.0+2a3d07cab",
|
|
51
|
+
"@wordpress/is-shallow-equal": "^5.45.1-next.v.202605131006.0+2a3d07cab",
|
|
52
|
+
"@wordpress/priority-queue": "^3.45.1-next.v.202605131006.0+2a3d07cab",
|
|
53
|
+
"@wordpress/private-apis": "^1.45.1-next.v.202605131006.0+2a3d07cab",
|
|
54
|
+
"@wordpress/redux-routine": "^5.45.1-next.v.202605131006.0+2a3d07cab",
|
|
55
55
|
"deepmerge": "^4.3.0",
|
|
56
56
|
"equivalent-key-map": "^0.2.2",
|
|
57
57
|
"is-plain-object": "^5.0.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "8804fa29bc78a1d98e5a4d40c3e180ddd907016c"
|
|
73
73
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// useSelect is a low-level hook that intentionally breaks rules-of-hooks
|
|
2
2
|
// in its internal helpers (_useStaticSelect, _useMappingSelect) where
|
|
3
3
|
// hooks are called inside non-hook functions and conditionally dispatched.
|
|
4
|
-
/* eslint-disable react-hooks/rules-of-hooks
|
|
4
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -372,4 +372,4 @@ export function useSuspenseSelect< T extends MapSelect >(
|
|
|
372
372
|
): ReturnType< T > {
|
|
373
373
|
return _useMappingSelect( true, mapSelect, deps ) as ReturnType< T >;
|
|
374
374
|
}
|
|
375
|
-
/* eslint-enable react-hooks/rules-of-hooks
|
|
375
|
+
/* eslint-enable react-hooks/rules-of-hooks */
|
package/src/redux-store/index.ts
CHANGED
|
@@ -458,6 +458,7 @@ export default function createReduxStore< State, Actions, Selectors >(
|
|
|
458
458
|
// a promise that resolves when the resolution is finished.
|
|
459
459
|
const bindResolveSelector = mapResolveSelector(
|
|
460
460
|
store,
|
|
461
|
+
resolvers,
|
|
461
462
|
boundMetadataSelectors
|
|
462
463
|
);
|
|
463
464
|
|
|
@@ -633,12 +634,14 @@ function instantiateReduxStore(
|
|
|
633
634
|
* Maps selectors to functions that return a resolution promise for them.
|
|
634
635
|
*
|
|
635
636
|
* @param store The redux store the selectors are bound to.
|
|
637
|
+
* @param resolvers The normalized resolvers for the store.
|
|
636
638
|
* @param boundMetadataSelectors The bound metadata selectors.
|
|
637
639
|
*
|
|
638
640
|
* @return Function that maps selectors to resolvers.
|
|
639
641
|
*/
|
|
640
642
|
function mapResolveSelector(
|
|
641
643
|
store: ReduxStore,
|
|
644
|
+
resolvers: Record< string, NormalizedResolver >,
|
|
642
645
|
boundMetadataSelectors: Record< string, SelectorLike >
|
|
643
646
|
) {
|
|
644
647
|
return ( selector: SelectorLike, selectorName: string ) => {
|
|
@@ -650,10 +653,15 @@ function mapResolveSelector(
|
|
|
650
653
|
|
|
651
654
|
return ( ...args: unknown[] ) =>
|
|
652
655
|
new Promise( ( resolve, reject ) => {
|
|
656
|
+
const resolver = resolvers[ selectorName ];
|
|
653
657
|
const hasFinished = () => {
|
|
654
|
-
return
|
|
655
|
-
|
|
656
|
-
|
|
658
|
+
return (
|
|
659
|
+
boundMetadataSelectors.hasFinishedResolution(
|
|
660
|
+
selectorName,
|
|
661
|
+
args
|
|
662
|
+
) ||
|
|
663
|
+
( typeof resolver.isFulfilled === 'function' &&
|
|
664
|
+
resolver.isFulfilled( store.getState(), ...args ) )
|
|
657
665
|
);
|
|
658
666
|
};
|
|
659
667
|
const finalize = ( result: unknown ) => {
|
|
@@ -789,7 +797,9 @@ function mapSelectorWithResolver(
|
|
|
789
797
|
function fulfillSelector( args: unknown[] ): void {
|
|
790
798
|
if (
|
|
791
799
|
resolversCache.isRunning( selectorName, args ) ||
|
|
792
|
-
boundMetadataSelectors.hasStartedResolution( selectorName, args )
|
|
800
|
+
boundMetadataSelectors.hasStartedResolution( selectorName, args ) ||
|
|
801
|
+
( typeof resolver.isFulfilled === 'function' &&
|
|
802
|
+
resolver.isFulfilled( store.getState(), ...args ) )
|
|
793
803
|
) {
|
|
794
804
|
return;
|
|
795
805
|
}
|
|
@@ -802,14 +812,9 @@ function mapSelectorWithResolver(
|
|
|
802
812
|
metadataActions.startResolution( selectorName, args )
|
|
803
813
|
);
|
|
804
814
|
try {
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
if ( ! isFulfilled ) {
|
|
809
|
-
const action = resolver.fulfill( ...args );
|
|
810
|
-
if ( action ) {
|
|
811
|
-
await store.dispatch( action );
|
|
812
|
-
}
|
|
815
|
+
const action = resolver.fulfill( ...args );
|
|
816
|
+
if ( action ) {
|
|
817
|
+
await store.dispatch( action );
|
|
813
818
|
}
|
|
814
819
|
store.dispatch(
|
|
815
820
|
metadataActions.finishResolution( selectorName, args )
|
|
@@ -306,8 +306,7 @@ describe( 'resolveSelect', () => {
|
|
|
306
306
|
},
|
|
307
307
|
} );
|
|
308
308
|
|
|
309
|
-
const
|
|
310
|
-
const result = await promise;
|
|
309
|
+
const result = await registry.resolveSelect( 'demo' ).getItems();
|
|
311
310
|
expect( result ).toEqual( [ 'item' ] );
|
|
312
311
|
} );
|
|
313
312
|
|
|
@@ -332,15 +331,13 @@ describe( 'resolveSelect', () => {
|
|
|
332
331
|
},
|
|
333
332
|
} );
|
|
334
333
|
|
|
335
|
-
const
|
|
336
|
-
const result1 = await promise1;
|
|
334
|
+
const result1 = await registry.resolveSelect( 'demo' ).getPage( 1 );
|
|
337
335
|
expect( result1 ).toEqual( {
|
|
338
336
|
title: 'Page 1',
|
|
339
337
|
content: 'Content 1',
|
|
340
338
|
} );
|
|
341
339
|
|
|
342
|
-
const
|
|
343
|
-
const result2 = await promise2;
|
|
340
|
+
const result2 = await registry.resolveSelect( 'demo' ).getPage( 2 );
|
|
344
341
|
expect( result2 ).toEqual( {
|
|
345
342
|
title: 'Page 2',
|
|
346
343
|
content: 'Content 2',
|
|
@@ -350,53 +347,41 @@ describe( 'resolveSelect', () => {
|
|
|
350
347
|
expect( fulfilledResolver ).not.toHaveBeenCalled();
|
|
351
348
|
} );
|
|
352
349
|
|
|
353
|
-
it( '
|
|
354
|
-
const fulfill = jest.fn()
|
|
355
|
-
|
|
356
|
-
data: 'resolved data',
|
|
357
|
-
} ) );
|
|
358
|
-
const isFulfilled = jest.fn( ( state ) => state.hasData );
|
|
350
|
+
it( 'does not change Redux state when isFulfilled returns true', async () => {
|
|
351
|
+
const fulfill = jest.fn();
|
|
352
|
+
const isFulfilled = () => true;
|
|
359
353
|
|
|
360
354
|
registry.registerStore( 'demo', {
|
|
361
|
-
reducer: ( state = {
|
|
362
|
-
if ( action.type === 'SET_DATA' ) {
|
|
363
|
-
return { hasData: true, data: action.data };
|
|
364
|
-
}
|
|
365
|
-
return state;
|
|
366
|
-
},
|
|
355
|
+
reducer: ( state = { items: [ 'item' ] } ) => state,
|
|
367
356
|
selectors: {
|
|
368
|
-
|
|
357
|
+
getItems: ( state ) => state.items,
|
|
369
358
|
},
|
|
370
359
|
resolvers: {
|
|
371
|
-
|
|
360
|
+
getItems: { fulfill, isFulfilled },
|
|
372
361
|
},
|
|
373
362
|
} );
|
|
374
363
|
|
|
375
|
-
const
|
|
376
|
-
const
|
|
364
|
+
const listener = jest.fn();
|
|
365
|
+
const unsubscribe = registry.subscribe( listener );
|
|
377
366
|
|
|
378
|
-
//
|
|
379
|
-
|
|
380
|
-
expect( fulfill ).toHaveBeenCalledTimes( 1 );
|
|
381
|
-
expect( result ).toBe( 'resolved data' );
|
|
367
|
+
// Call the selector — isFulfilled is true, so no resolution should happen.
|
|
368
|
+
registry.select( 'demo' ).getItems();
|
|
382
369
|
|
|
383
|
-
//
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
expect(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
370
|
+
// Wait long enough for any setTimeout(0) resolver to have fired.
|
|
371
|
+
await new Promise( ( resolve ) => setTimeout( resolve, 10 ) );
|
|
372
|
+
|
|
373
|
+
expect( fulfill ).not.toHaveBeenCalled();
|
|
374
|
+
expect( listener ).not.toHaveBeenCalled();
|
|
375
|
+
|
|
376
|
+
unsubscribe();
|
|
390
377
|
} );
|
|
391
378
|
|
|
392
|
-
it( '
|
|
379
|
+
it( 'calls resolver when isFulfilled returns false', async () => {
|
|
393
380
|
const fulfill = jest.fn().mockImplementation( () => ( {
|
|
394
381
|
type: 'SET_DATA',
|
|
395
382
|
data: 'resolved data',
|
|
396
383
|
} ) );
|
|
397
|
-
const isFulfilled = jest.fn( () =>
|
|
398
|
-
throw new Error( 'isFulfilled error' );
|
|
399
|
-
} );
|
|
384
|
+
const isFulfilled = jest.fn( ( state ) => state.hasData );
|
|
400
385
|
|
|
401
386
|
registry.registerStore( 'demo', {
|
|
402
387
|
reducer: ( state = { hasData: false }, action ) => {
|
|
@@ -413,14 +398,17 @@ describe( 'resolveSelect', () => {
|
|
|
413
398
|
},
|
|
414
399
|
} );
|
|
415
400
|
|
|
416
|
-
const
|
|
417
|
-
await expect( promise ).rejects.toThrow( 'isFulfilled error' );
|
|
401
|
+
const result = await registry.resolveSelect( 'demo' ).getData();
|
|
418
402
|
|
|
419
|
-
|
|
420
|
-
expect( fulfill ).
|
|
421
|
-
expect(
|
|
422
|
-
|
|
423
|
-
|
|
403
|
+
// Initial state has hasData: false, so resolver should be called
|
|
404
|
+
expect( fulfill ).toHaveBeenCalledTimes( 1 );
|
|
405
|
+
expect( result ).toBe( 'resolved data' );
|
|
406
|
+
|
|
407
|
+
// Subsequent call should use cached result, not calling `fulfill` again
|
|
408
|
+
const result2 = await registry.resolveSelect( 'demo' ).getData();
|
|
409
|
+
expect( result2 ).toBe( 'resolved data' );
|
|
410
|
+
// `fulfill` is only called once since resolution is already marked as finished
|
|
411
|
+
expect( fulfill ).toHaveBeenCalledTimes( 1 );
|
|
424
412
|
} );
|
|
425
413
|
} );
|
|
426
414
|
|