@wordpress/data 6.11.0 → 6.12.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 +2 -0
- package/README.md +5 -5
- package/build/components/use-select/index.js +27 -17
- package/build/components/use-select/index.js.map +1 -1
- package/build/redux-store/index.js +14 -7
- package/build/redux-store/index.js.map +1 -1
- package/build-module/components/use-select/index.js +27 -17
- package/build-module/components/use-select/index.js.map +1 -1
- package/build-module/redux-store/index.js +14 -7
- package/build-module/redux-store/index.js.map +1 -1
- package/build-types/types.d.ts +18 -1
- package/build-types/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/use-select/index.js +24 -17
- package/src/redux-store/index.js +14 -7
- package/src/test/registry.js +13 -16
- package/src/types.ts +35 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -374,11 +374,11 @@ const store = createReduxStore( 'demo', {
|
|
|
374
374
|
_Parameters_
|
|
375
375
|
|
|
376
376
|
- _key_ `string`: Unique namespace identifier.
|
|
377
|
-
- _options_ `ReduxStoreConfig
|
|
377
|
+
- _options_ `ReduxStoreConfig<State,Actions,Selectors>`: Registered store options, with properties describing reducer, actions, selectors, and resolvers.
|
|
378
378
|
|
|
379
379
|
_Returns_
|
|
380
380
|
|
|
381
|
-
- `StoreDescriptor
|
|
381
|
+
- `StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>`: Store Object.
|
|
382
382
|
|
|
383
383
|
### createRegistry
|
|
384
384
|
|
|
@@ -841,12 +841,12 @@ function Paste( { children } ) {
|
|
|
841
841
|
|
|
842
842
|
_Parameters_
|
|
843
843
|
|
|
844
|
-
- _mapSelect_ `
|
|
845
|
-
- _deps_ `
|
|
844
|
+
- _mapSelect_ `T`: Function called on every state change. The returned value is exposed to the component implementing this hook. The function receives the `registry.select` method on the first argument and the `registry` on the second argument. When a store key is passed, all selectors for the store will be returned. This is only meant for usage of these selectors in event callbacks, not for data needed to create the element tree.
|
|
845
|
+
- _deps_ `unknown[]`: If provided, this memoizes the mapSelect so the same `mapSelect` is invoked on every state change unless the dependencies change.
|
|
846
846
|
|
|
847
847
|
_Returns_
|
|
848
848
|
|
|
849
|
-
- `
|
|
849
|
+
- `UseSelectReturn<T>`: A custom react hook.
|
|
850
850
|
|
|
851
851
|
### useSuspenseSelect
|
|
852
852
|
|
|
@@ -36,7 +36,22 @@ var _useAsyncMode = _interopRequireDefault(require("../async-mode-provider/use-a
|
|
|
36
36
|
const noop = () => {};
|
|
37
37
|
|
|
38
38
|
const renderQueue = (0, _priorityQueue.createQueue)();
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
|
|
41
|
+
* @template C
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
|
|
46
|
+
* @template State,Actions,Selectors
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
|
|
51
|
+
* @template T
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/** @typedef {import('../../types').MapSelect} MapSelect */
|
|
40
55
|
|
|
41
56
|
/**
|
|
42
57
|
* Custom react hook for retrieving props from registered selectors.
|
|
@@ -44,20 +59,16 @@ const renderQueue = (0, _priorityQueue.createQueue)();
|
|
|
44
59
|
* In general, this custom React hook follows the
|
|
45
60
|
* [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
|
|
46
61
|
*
|
|
47
|
-
* @
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* element tree.
|
|
58
|
-
* @param {Array} deps If provided, this memoizes the mapSelect so the
|
|
59
|
-
* same `mapSelect` is invoked on every state
|
|
60
|
-
* change unless the dependencies change.
|
|
62
|
+
* @template {MapSelect | StoreDescriptor<any>} T
|
|
63
|
+
* @param {T} mapSelect Function called on every state change. The returned value is
|
|
64
|
+
* exposed to the component implementing this hook. The function
|
|
65
|
+
* receives the `registry.select` method on the first argument
|
|
66
|
+
* and the `registry` on the second argument.
|
|
67
|
+
* When a store key is passed, all selectors for the store will be
|
|
68
|
+
* returned. This is only meant for usage of these selectors in event
|
|
69
|
+
* callbacks, not for data needed to create the element tree.
|
|
70
|
+
* @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is
|
|
71
|
+
* invoked on every state change unless the dependencies change.
|
|
61
72
|
*
|
|
62
73
|
* @example
|
|
63
74
|
* ```js
|
|
@@ -102,8 +113,7 @@ const renderQueue = (0, _priorityQueue.createQueue)();
|
|
|
102
113
|
* return <div onPaste={ onPaste }>{ children }</div>;
|
|
103
114
|
* }
|
|
104
115
|
* ```
|
|
105
|
-
*
|
|
106
|
-
* @return {Function} A custom react hook.
|
|
116
|
+
* @return {UseSelectReturn<T>} A custom react hook.
|
|
107
117
|
*/
|
|
108
118
|
|
|
109
119
|
function useSelect(mapSelect, deps) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/components/use-select/index.js"],"names":["noop","renderQueue","useSelect","mapSelect","deps","hasMappingFunction","callbackMapper","_mapSelect","registry","isAsync","latestRegistry","latestMapSelect","latestIsAsync","latestMapOutput","latestMapOutputError","listeningStores","wrapSelect","callback","__unstableMarkListeningStores","select","depsChangedFlag","mapOutput","current","hasReplacedRegistry","hasReplacedMapSelect","hasLeftAsyncMode","lastMapSelectFailed","error","errorMessage","message","stack","console","undefined","queueContext","queue","forceRender","s","isMounted","onStoreChange","newMapOutput","onChange","add","unsubscribers","map","storeName","__unstableSubscribeStore","forEach","unsubscribe","cancel","useSuspenseSelect","suspendSelect","mapOutputError"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,WAAW,GAAG,iCAApB;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,SAAT,CAAoBC,SAApB,EAA+BC,IAA/B,EAAsC;AACpD,QAAMC,kBAAkB,GAAG,eAAe,OAAOF,SAAjD,CADoD,CAGpD;AACA;AACA;;AACA,MAAK,CAAEE,kBAAP,EAA4B;AAC3BD,IAAAA,IAAI,GAAG,EAAP;AACA,GARmD,CAUpD;AACA;AACA;AACA;AACA;;;AACA,QAAME,cAAc,GAAG,0BACtBD,kBAAkB,GAAGF,SAAH,GAAeH,IADX,EAEtBI,IAFsB,CAAvB;;AAIA,QAAMG,UAAU,GAAGF,kBAAkB,GAAGC,cAAH,GAAoB,IAAzD;;AAEA,QAAME,QAAQ,GAAG,2BAAjB;AACA,QAAMC,OAAO,GAAG,4BAAhB;AAEA,QAAMC,cAAc,GAAG,qBAAQF,QAAR,CAAvB;AACA,QAAMG,eAAe,GAAG,sBAAxB;AACA,QAAMC,aAAa,GAAG,qBAAQH,OAAR,CAAtB;AACA,QAAMI,eAAe,GAAG,sBAAxB;AACA,QAAMC,oBAAoB,GAAG,sBAA7B,CA5BoD,CA8BpD;AACA;;AACA,QAAMC,eAAe,GAAG,qBAAQ,EAAR,CAAxB;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5CD,EA4CG,CAAEd,QAAF,EAAYQ,UAAZ,EAAwBI,eAAxB,CA5CH;;AA8CA,MAAK+B,cAAL,EAAsB;AACrB,UAAMA,cAAN;AACA;;AAED,SAAO9B,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport { useRef, useCallback, useMemo, useReducer } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst noop = () => {};\nconst renderQueue = createQueue();\n\n/** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */\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://reactjs.org/docs/hooks-rules.html).\n *\n * @param {Function|StoreDescriptor|string} mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * implementing this hook. The function receives\n * the `registry.select` method on the first\n * argument and the `registry` on the second\n * argument.\n * When a store key is passed, all selectors for\n * the store will be returned. This is only meant\n * for usage of these selectors in event\n * callbacks, not for data needed to create the\n * element tree.\n * @param {Array} deps If provided, this memoizes the mapSelect so the\n * same `mapSelect` is invoked on every state\n * change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( 'my-shop' ).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 *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( 'my-shop' );\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 {Function} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\tconst hasMappingFunction = 'function' === typeof mapSelect;\n\n\t// If we're recalling a store by its name or by\n\t// its descriptor then we won't be caching the\n\t// calls to `mapSelect` because we won't be calling it.\n\tif ( ! hasMappingFunction ) {\n\t\tdeps = [];\n\t}\n\n\t// Because of the \"rule of hooks\" we have to call `useCallback`\n\t// on every invocation whether or not we have a real function\n\t// for `mapSelect`. we'll create this intermediate variable to\n\t// fulfill that need and then reference it with our \"real\"\n\t// `_mapSelect` if we can.\n\tconst callbackMapper = useCallback(\n\t\thasMappingFunction ? mapSelect : noop,\n\t\tdeps\n\t);\n\tconst _mapSelect = hasMappingFunction ? callbackMapper : null;\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\n\tconst latestRegistry = useRef( registry );\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\n\t// Keep track of the stores being selected in the _mapSelect function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst wrapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__unstableMarkListeningStores(\n\t\t\t\t() => callback( registry.select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput;\n\n\tif ( _mapSelect ) {\n\t\tmapOutput = latestMapOutput.current;\n\t\tconst hasReplacedRegistry = latestRegistry.current !== registry;\n\t\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\t\tconst hasLeftAsyncMode = latestIsAsync.current && ! isAsync;\n\t\tconst lastMapSelectFailed = !! latestMapOutputError.current;\n\n\t\tif (\n\t\t\thasReplacedRegistry ||\n\t\t\thasReplacedMapSelect ||\n\t\t\thasLeftAsyncMode ||\n\t\t\tlastMapSelectFailed\n\t\t) {\n\t\t\ttry {\n\t\t\t\tmapOutput = wrapSelect( _mapSelect );\n\t\t\t} catch ( error ) {\n\t\t\t\tlet errorMessage = `An error occurred while running 'mapSelect': ${ error.message }`;\n\n\t\t\t\tif ( latestMapOutputError.current ) {\n\t\t\t\t\terrorMessage += `\\nThe error may be correlated with this previous error:\\n`;\n\t\t\t\t\terrorMessage += `${ latestMapOutputError.current.stack }\\n\\n`;\n\t\t\t\t\terrorMessage += 'Original stack trace:';\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error( errorMessage );\n\t\t\t}\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlatestRegistry.current = registry;\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestIsAsync.current = isAsync;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = undefined;\n\t} );\n\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\tconst isMounted = useRef( false );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onStoreChange = () => {\n\t\t\ttry {\n\t\t\t\tconst newMapOutput = wrapSelect( latestMapSelect.current );\n\n\t\t\t\tif ( isShallowEqual( latestMapOutput.current, newMapOutput ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t} catch ( error ) {\n\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t}\n\t\t\tforceRender();\n\t\t};\n\n\t\tconst onChange = () => {\n\t\t\tif ( ! isMounted.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\t// Catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tonStoreChange();\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__unstableSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\tisMounted.current = true;\n\n\t\treturn () => {\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.cancel( queueContext );\n\t\t\tisMounted.current = false;\n\t\t};\n\t\t// If you're tempted to eliminate the spread dependencies below don't do it!\n\t\t// We're passing these in from the calling function and want to make sure we're\n\t\t// examining every individual value inside the `deps` array.\n\t}, [ registry, wrapSelect, hasMappingFunction, depsChangedFlag ] );\n\n\treturn hasMappingFunction ? mapOutput : registry.select( mapSelect );\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but will throw a\n * suspense Promise if any of the called selectors is in an unresolved state.\n *\n * @param {Function} 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 {Array} 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 * @return {Object} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\tconst _mapSelect = useCallback( mapSelect, deps );\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\n\tconst latestRegistry = useRef( registry );\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\n\t// Keep track of the stores being selected in the `mapSelect` function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst wrapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__unstableMarkListeningStores(\n\t\t\t\t() => callback( registry.suspendSelect, registry ),\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput = latestMapOutput.current;\n\tlet mapOutputError = latestMapOutputError.current;\n\n\tconst hasReplacedRegistry = latestRegistry.current !== registry;\n\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\tconst hasLeftAsyncMode = latestIsAsync.current && ! isAsync;\n\n\tif ( hasReplacedRegistry || hasReplacedMapSelect || hasLeftAsyncMode ) {\n\t\ttry {\n\t\t\tmapOutput = wrapSelect( _mapSelect );\n\t\t} catch ( error ) {\n\t\t\tmapOutputError = error;\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tlatestRegistry.current = registry;\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestIsAsync.current = isAsync;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = mapOutputError;\n\t} );\n\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\tconst isMounted = useRef( false );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tconst onStoreChange = () => {\n\t\t\ttry {\n\t\t\t\tconst newMapOutput = wrapSelect( latestMapSelect.current );\n\n\t\t\t\tif ( isShallowEqual( latestMapOutput.current, newMapOutput ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t} catch ( error ) {\n\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t}\n\n\t\t\tforceRender();\n\t\t};\n\n\t\tconst onChange = () => {\n\t\t\tif ( ! isMounted.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\t// catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tonStoreChange();\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__unstableSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\tisMounted.current = true;\n\n\t\treturn () => {\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.cancel( queueContext );\n\t\t\tisMounted.current = false;\n\t\t};\n\t}, [ registry, wrapSelect, depsChangedFlag ] );\n\n\tif ( mapOutputError ) {\n\t\tthrow mapOutputError;\n\t}\n\n\treturn mapOutput;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/components/use-select/index.js"],"names":["noop","renderQueue","useSelect","mapSelect","deps","hasMappingFunction","callbackMapper","_mapSelect","registry","isAsync","latestRegistry","latestMapSelect","latestIsAsync","latestMapOutput","latestMapOutputError","listeningStores","wrapSelect","callback","__unstableMarkListeningStores","select","depsChangedFlag","mapOutput","current","hasReplacedRegistry","hasReplacedMapSelect","hasLeftAsyncMode","lastMapSelectFailed","error","errorMessage","message","stack","console","undefined","queueContext","queue","forceRender","s","isMounted","onStoreChange","newMapOutput","onChange","add","unsubscribers","map","storeName","__unstableSubscribeStore","forEach","unsubscribe","cancel","useSuspenseSelect","suspendSelect","mapOutputError"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,WAAW,GAAG,iCAApB;AAEA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,SAAT,CAAoBC,SAApB,EAA+BC,IAA/B,EAAsC;AACpD,QAAMC,kBAAkB,GAAG,eAAe,OAAOF,SAAjD,CADoD,CAGpD;AACA;AACA;;AACA,MAAK,CAAEE,kBAAP,EAA4B;AAC3BD,IAAAA,IAAI,GAAG,EAAP;AACA,GARmD,CAUpD;AACA;AACA;AACA;AACA;;;AACA,QAAME,cAAc,GAAG,0BACtBD,kBAAkB,GAAGF,SAAH,GAAeH,IADX,EAEtBI,IAFsB,CAAvB;;AAIA,QAAMG,UAAU,GAAGF,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SAAF,IAClDpC,QAAQ,CAACqC,wBAAT,CAAmCD,SAAnC,EAA8CJ,QAA9C,CADqB,CAAtB;AAIAH,IAAAA,SAAS,CAACf,OAAV,GAAoB,IAApB;AAEA,WAAO,MAAM;AACZ;AACAoB,MAAAA,aAAa,CAACI,OAAd,CAAyBC,WAAF,IAAmBA,WAAnB,aAAmBA,WAAnB,uBAAmBA,WAAW,EAArD;AACA9C,MAAAA,WAAW,CAAC+C,MAAZ,CAAoBf,YAApB;AACAI,MAAAA,SAAS,CAACf,OAAV,GAAoB,KAApB;AACA,KALD;AAMA,GA5CD,EA4CG,CAAEd,QAAF,EAAYQ,UAAZ,EAAwBI,eAAxB,CA5CH;;AA8CA,MAAK+B,cAAL,EAAsB;AACrB,UAAMA,cAAN;AACA;;AAED,SAAO9B,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport { useRef, useCallback, useMemo, useReducer } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst noop = () => {};\nconst renderQueue = createQueue();\n\n/**\n * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor\n * @template C\n */\n/**\n * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State,Actions,Selectors\n */\n/**\n * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn\n * @template T\n */\n/** @typedef {import('../../types').MapSelect} MapSelect */\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://reactjs.org/docs/hooks-rules.html).\n *\n * @template {MapSelect | StoreDescriptor<any>} T\n * @param {T} 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 {unknown[]} 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 *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( 'my-shop' ).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 *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( 'my-shop' );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n * @return {UseSelectReturn<T>} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\tconst hasMappingFunction = 'function' === typeof mapSelect;\n\n\t// If we're recalling a store by its name or by\n\t// its descriptor then we won't be caching the\n\t// calls to `mapSelect` because we won't be calling it.\n\tif ( ! hasMappingFunction ) {\n\t\tdeps = [];\n\t}\n\n\t// Because of the \"rule of hooks\" we have to call `useCallback`\n\t// on every invocation whether or not we have a real function\n\t// for `mapSelect`. we'll create this intermediate variable to\n\t// fulfill that need and then reference it with our \"real\"\n\t// `_mapSelect` if we can.\n\tconst callbackMapper = useCallback(\n\t\thasMappingFunction ? mapSelect : noop,\n\t\tdeps\n\t);\n\tconst _mapSelect = hasMappingFunction ? callbackMapper : null;\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\n\tconst latestRegistry = useRef( registry );\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\n\t// Keep track of the stores being selected in the _mapSelect function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst wrapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__unstableMarkListeningStores(\n\t\t\t\t() => callback( registry.select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput;\n\n\tif ( _mapSelect ) {\n\t\tmapOutput = latestMapOutput.current;\n\t\tconst hasReplacedRegistry = latestRegistry.current !== registry;\n\t\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\t\tconst hasLeftAsyncMode = latestIsAsync.current && ! isAsync;\n\t\tconst lastMapSelectFailed = !! latestMapOutputError.current;\n\n\t\tif (\n\t\t\thasReplacedRegistry ||\n\t\t\thasReplacedMapSelect ||\n\t\t\thasLeftAsyncMode ||\n\t\t\tlastMapSelectFailed\n\t\t) {\n\t\t\ttry {\n\t\t\t\tmapOutput = wrapSelect( _mapSelect );\n\t\t\t} catch ( error ) {\n\t\t\t\tlet errorMessage = `An error occurred while running 'mapSelect': ${ error.message }`;\n\n\t\t\t\tif ( latestMapOutputError.current ) {\n\t\t\t\t\terrorMessage += `\\nThe error may be correlated with this previous error:\\n`;\n\t\t\t\t\terrorMessage += `${ latestMapOutputError.current.stack }\\n\\n`;\n\t\t\t\t\terrorMessage += 'Original stack trace:';\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error( errorMessage );\n\t\t\t}\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlatestRegistry.current = registry;\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestIsAsync.current = isAsync;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = undefined;\n\t} );\n\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\tconst isMounted = useRef( false );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onStoreChange = () => {\n\t\t\ttry {\n\t\t\t\tconst newMapOutput = wrapSelect( latestMapSelect.current );\n\n\t\t\t\tif ( isShallowEqual( latestMapOutput.current, newMapOutput ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t} catch ( error ) {\n\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t}\n\t\t\tforceRender();\n\t\t};\n\n\t\tconst onChange = () => {\n\t\t\tif ( ! isMounted.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\t// Catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tonStoreChange();\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__unstableSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\tisMounted.current = true;\n\n\t\treturn () => {\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.cancel( queueContext );\n\t\t\tisMounted.current = false;\n\t\t};\n\t\t// If you're tempted to eliminate the spread dependencies below don't do it!\n\t\t// We're passing these in from the calling function and want to make sure we're\n\t\t// examining every individual value inside the `deps` array.\n\t}, [ registry, wrapSelect, hasMappingFunction, depsChangedFlag ] );\n\n\treturn hasMappingFunction ? mapOutput : registry.select( mapSelect );\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but will throw a\n * suspense Promise if any of the called selectors is in an unresolved state.\n *\n * @param {Function} 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 {Array} 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 * @return {Object} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\tconst _mapSelect = useCallback( mapSelect, deps );\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\n\tconst latestRegistry = useRef( registry );\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\n\t// Keep track of the stores being selected in the `mapSelect` function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst wrapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__unstableMarkListeningStores(\n\t\t\t\t() => callback( registry.suspendSelect, registry ),\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput = latestMapOutput.current;\n\tlet mapOutputError = latestMapOutputError.current;\n\n\tconst hasReplacedRegistry = latestRegistry.current !== registry;\n\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\tconst hasLeftAsyncMode = latestIsAsync.current && ! isAsync;\n\n\tif ( hasReplacedRegistry || hasReplacedMapSelect || hasLeftAsyncMode ) {\n\t\ttry {\n\t\t\tmapOutput = wrapSelect( _mapSelect );\n\t\t} catch ( error ) {\n\t\t\tmapOutputError = error;\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tlatestRegistry.current = registry;\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestIsAsync.current = isAsync;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = mapOutputError;\n\t} );\n\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\tconst isMounted = useRef( false );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tconst onStoreChange = () => {\n\t\t\ttry {\n\t\t\t\tconst newMapOutput = wrapSelect( latestMapSelect.current );\n\n\t\t\t\tif ( isShallowEqual( latestMapOutput.current, newMapOutput ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t} catch ( error ) {\n\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t}\n\n\t\t\tforceRender();\n\t\t};\n\n\t\tconst onChange = () => {\n\t\t\tif ( ! isMounted.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\t// catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tonStoreChange();\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__unstableSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\tisMounted.current = true;\n\n\t\treturn () => {\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.cancel( queueContext );\n\t\t\tisMounted.current = false;\n\t\t};\n\t}, [ registry, wrapSelect, depsChangedFlag ] );\n\n\tif ( mapOutputError ) {\n\t\tthrow mapOutputError;\n\t}\n\n\treturn mapOutput;\n}\n"]}
|
|
@@ -49,9 +49,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
49
49
|
|
|
50
50
|
/** @typedef {import('../types').DataRegistry} DataRegistry */
|
|
51
51
|
|
|
52
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor
|
|
54
|
+
* @template C
|
|
55
|
+
*/
|
|
53
56
|
|
|
54
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
|
|
59
|
+
* @template State,Actions,Selectors
|
|
60
|
+
*/
|
|
55
61
|
const trimUndefinedValues = array => {
|
|
56
62
|
const result = [...array];
|
|
57
63
|
|
|
@@ -109,12 +115,13 @@ function createResolversCache() {
|
|
|
109
115
|
* } );
|
|
110
116
|
* ```
|
|
111
117
|
*
|
|
112
|
-
* @
|
|
113
|
-
* @param {
|
|
114
|
-
*
|
|
115
|
-
*
|
|
118
|
+
* @template State,Actions,Selectors
|
|
119
|
+
* @param {string} key Unique namespace identifier.
|
|
120
|
+
* @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties
|
|
121
|
+
* describing reducer, actions, selectors,
|
|
122
|
+
* and resolvers.
|
|
116
123
|
*
|
|
117
|
-
* @return
|
|
124
|
+
* @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.
|
|
118
125
|
*/
|
|
119
126
|
|
|
120
127
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/redux-store/index.js"],"names":["trimUndefinedValues","array","result","i","length","undefined","splice","createResolversCache","cache","isRunning","selectorName","args","get","clear","delete","markAsRunning","EquivalentKeyMap","set","createReduxStore","key","options","name","instantiate","registry","reducer","thunkArgs","dispatch","Object","assign","action","store","getActions","select","selector","__unstableOriginalGetState","getSelectors","resolveSelect","getResolveSelectors","instantiateReduxStore","resolversCache","resolvers","actions","mapActions","metadataActions","selectors","mapSelectors","metadataSelectors","state","metadata","isRegistrySelector","root","mapResolvers","resolveSelectors","mapResolveSelectors","suspendSelectors","mapSuspendSelectors","getSuspendSelectors","getState","subscribe","listener","lastState","hasChanged","controls","builtinControls","normalizedControls","control","isRegistryControl","middlewares","promise","enhancers","window","__REDUX_DEVTOOLS_EXTENSION__","push","instanceId","initialState","enhancedReducer","metadataReducer","createStateSelector","registrySelector","runSelector","argsLength","arguments","Array","hasResolver","createBoundAction","Promise","resolve","storeSelectors","apply","reject","hasFinished","hasFinishedResolution","finalize","hasFailed","hasResolutionFailed","error","getResolutionError","getResult","unsubscribe","mappedResolvers","resolver","fulfill","mapSelector","selectorResolver","fulfillSelector","isFulfilled","hasStartedResolution","setTimeout","startResolution","fulfillResolver","finishResolution","failResolution"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAtBA;AACA;AACA;;AAMA;AACA;AACA;;AAGA;AACA;AACA;;AASA;;AACA;;AACA;AAEA,MAAMA,mBAAmB,GAAKC,KAAF,IAAa;AACxC,QAAMC,MAAM,GAAG,CAAE,GAAGD,KAAL,CAAf;;AACA,OAAM,IAA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A,SAAS,EAAE,uBAAWA,SAAX,EAAsB0D,WAAtB;AAFL,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAeO,eAAf,CAAgC/E,KAAhC,EAAuCU,SAAvC,EAAkD9B,YAAlD,EAA0E;AACzE,QAAM0F,QAAQ,GAAG,iBAAK5D,SAAL,EAAgB,CAAE9B,YAAF,CAAhB,CAAjB;;AACA,MAAK,CAAE0F,QAAP,EAAkB;AACjB;AACA;;AAJwE,qCAAPzF,IAAO;AAAPA,IAAAA,IAAO;AAAA;;AAMzE,QAAMkB,MAAM,GAAGuE,QAAQ,CAACC,OAAT,CAAkB,GAAG1F,IAArB,CAAf;;AACA,MAAKkB,MAAL,EAAc;AACb,UAAMC,KAAK,CAACJ,QAAN,CAAgBG,MAAhB,CAAN;AACA;AACD","sourcesContent":["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport { flowRight, get, mapValues, omit } from 'lodash';\nimport combineReducers from 'turbo-combine-reducers';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\n\n/**\n * Internal dependencies\n */\nimport { builtinControls } from '../controls';\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';\n\n/** @typedef {import('../types').DataRegistry} DataRegistry */\n/** @typedef {import('../types').StoreDescriptor} StoreDescriptor */\n/** @typedef {import('../types').ReduxStoreConfig} ReduxStoreConfig */\n\nconst trimUndefinedValues = ( array ) => {\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 * Create a cache to track whether resolvers started running or not.\n *\n * @return {Object} Resolvers Cache.\n */\nfunction createResolversCache() {\n\tconst cache = {};\n\treturn {\n\t\tisRunning( selectorName, args ) {\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, args ) {\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, args ) {\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\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 {string} key Unique namespace identifier.\n * @param {ReduxStoreConfig} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return {StoreDescriptor} Store Object.\n */\nexport default function createReduxStore( key, options ) {\n\treturn {\n\t\tname: key,\n\t\tinstantiate: ( registry ) => {\n\t\t\tconst reducer = options.reducer;\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn Object.assign(\n\t\t\t\t\t\t( action ) => store.dispatch( action ),\n\t\t\t\t\t\tgetActions()\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn Object.assign(\n\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t\t\t\tgetSelectors()\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn getResolveSelectors();\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);\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\tlet resolvers;\n\t\t\tconst actions = mapActions(\n\t\t\t\t{\n\t\t\t\t\t...metadataActions,\n\t\t\t\t\t...options.actions,\n\t\t\t\t},\n\t\t\t\tstore\n\t\t\t);\n\n\t\t\tlet selectors = mapSelectors(\n\t\t\t\t{\n\t\t\t\t\t...mapValues(\n\t\t\t\t\t\tmetadataSelectors,\n\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\t( state, ...args ) =>\n\t\t\t\t\t\t\t\tselector( state.metadata, ...args )\n\t\t\t\t\t),\n\t\t\t\t\t...mapValues( options.selectors, ( selector ) => {\n\t\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn ( state, ...args ) =>\n\t\t\t\t\t\t\tselector( state.root, ...args );\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\tstore\n\t\t\t);\n\t\t\tif ( options.resolvers ) {\n\t\t\t\tconst result = mapResolvers(\n\t\t\t\t\toptions.resolvers,\n\t\t\t\t\tselectors,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache\n\t\t\t\t);\n\t\t\t\tresolvers = result.resolvers;\n\t\t\t\tselectors = result.selectors;\n\t\t\t}\n\n\t\t\tconst resolveSelectors = mapResolveSelectors( selectors, store );\n\t\t\tconst suspendSelectors = mapSuspendSelectors( selectors, store );\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 =\n\t\t\t\tstore &&\n\t\t\t\t( ( listener ) => {\n\t\t\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\t\t\treturn store.subscribe( () => {\n\t\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\t\t\tlastState = state;\n\n\t\t\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\t\t\tlistener();\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\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\n/**\n * Creates a redux store for a namespace.\n *\n * @param {string} key Unique namespace identifier.\n * @param {Object} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param {DataRegistry} registry Registry reference.\n * @param {Object} thunkArgs Argument object for the thunk middleware.\n * @return {Object} Newly created redux store.\n */\nfunction instantiateReduxStore( key, options, registry, thunkArgs ) {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control ) =>\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 = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\twindow.__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\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 },\n\t\tflowRight( enhancers )\n\t);\n}\n\n/**\n * Maps selectors to a store.\n *\n * @param {Object} selectors Selectors to register. Keys will be used as the\n * public facing API. Selectors will get passed the\n * state as first argument.\n * @param {Object} store The store to which the selectors should be mapped.\n * @return {Object} Selectors mapped to the provided store.\n */\nfunction mapSelectors( selectors, store ) {\n\tconst createStateSelector = ( registrySelector ) => {\n\t\tconst selector = function runSelector() {\n\t\t\t// This function is an optimized implementation of:\n\t\t\t//\n\t\t\t// selector( store.getState(), ...arguments )\n\t\t\t//\n\t\t\t// Where the above would incur an `Array#concat` in its application,\n\t\t\t// the logic here instead efficiently constructs an arguments array via\n\t\t\t// direct assignment.\n\t\t\tconst argsLength = arguments.length;\n\t\t\tconst args = new Array( argsLength + 1 );\n\t\t\targs[ 0 ] = store.__unstableOriginalGetState();\n\t\t\tfor ( let i = 0; i < argsLength; i++ ) {\n\t\t\t\targs[ i + 1 ] = arguments[ i ];\n\t\t\t}\n\n\t\t\treturn registrySelector( ...args );\n\t\t};\n\t\tselector.hasResolver = false;\n\t\treturn selector;\n\t};\n\n\treturn mapValues( selectors, createStateSelector );\n}\n\n/**\n * Maps actions to dispatch from a given store.\n *\n * @param {Object} actions Actions to register.\n * @param {Object} store The redux store to which the actions should be mapped.\n *\n * @return {Object} Actions mapped to the redux store provided.\n */\nfunction mapActions( actions, store ) {\n\tconst createBoundAction =\n\t\t( action ) =>\n\t\t( ...args ) => {\n\t\t\treturn Promise.resolve( store.dispatch( action( ...args ) ) );\n\t\t};\n\n\treturn mapValues( actions, createBoundAction );\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their resolution functions.\n */\nfunction mapResolveSelectors( selectors, store ) {\n\tconst storeSelectors = omit( selectors, [\n\t\t'getIsResolving',\n\t\t'hasStartedResolution',\n\t\t'hasFinishedResolution',\n\t\t'hasResolutionFailed',\n\t\t'isResolving',\n\t\t'getCachedResolvers',\n\t\t'getResolutionState',\n\t\t'getResolutionError',\n\t] );\n\n\treturn mapValues( storeSelectors, ( selector, selectorName ) => {\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 ) => selector.apply( null, args );\n\t\t}\n\n\t\treturn ( ...args ) => {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () =>\n\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args );\n\t\t\t\tconst finalize = ( result ) => {\n\t\t\t\t\tconst hasFailed = selectors.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\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = selectors.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.apply( null, args );\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\t};\n\t} );\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their suspense functions.\n */\nfunction mapSuspendSelectors( selectors, store ) {\n\treturn mapValues( selectors, ( selector, selectorName ) => {\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 ) => {\n\t\t\tconst result = selector.apply( null, args );\n\n\t\t\tif ( selectors.hasFinishedResolution( selectorName, args ) ) {\n\t\t\t\tif ( selectors.hasResolutionFailed( selectorName, args ) ) {\n\t\t\t\t\tthrow selectors.getResolutionError( selectorName, args );\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args )\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 * Returns resolvers with matched selectors for a given namespace.\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 {Object} resolvers Resolvers to register.\n * @param {Object} selectors The current selectors to be modified.\n * @param {Object} store The redux store to which the resolvers should be mapped.\n * @param {Object} resolversCache Resolvers Cache.\n */\nfunction mapResolvers( resolvers, selectors, store, resolversCache ) {\n\t// The `resolver` can be either a function that does the resolution, or, in more advanced\n\t// cases, an object with a `fullfill` method and other optional methods like `isFulfilled`.\n\t// Here we normalize the `resolver` function to an object with `fulfill` method.\n\tconst mappedResolvers = mapValues( resolvers, ( resolver ) => {\n\t\tif ( resolver.fulfill ) {\n\t\t\treturn resolver;\n\t\t}\n\n\t\treturn {\n\t\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\t\tfulfill: resolver, // Add the fulfill method.\n\t\t};\n\t} );\n\n\tconst mapSelector = ( selector, selectorName ) => {\n\t\tconst resolver = resolvers[ selectorName ];\n\t\tif ( ! resolver ) {\n\t\t\tselector.hasResolver = false;\n\t\t\treturn selector;\n\t\t}\n\n\t\tconst selectorResolver = ( ...args ) => {\n\t\t\tasync function fulfillSelector() {\n\t\t\t\tconst state = store.getState();\n\n\t\t\t\tif (\n\t\t\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\t\tresolver.isFulfilled( state, ...args ) )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { metadata } = store.__unstableOriginalGetState();\n\n\t\t\t\tif (\n\t\t\t\t\tmetadataSelectors.hasStartedResolution(\n\t\t\t\t\t\tmetadata,\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\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\t\t\tsetTimeout( async () => {\n\t\t\t\t\tresolversCache.clear( selectorName, args );\n\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t\t\t);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fulfillResolver(\n\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\tmappedResolvers,\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t...args\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\t\tmetadataActions.finishResolution(\n\t\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t\targs\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch ( error ) {\n\t\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\t\tmetadataActions.failResolution(\n\t\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t\targs,\n\t\t\t\t\t\t\t\terror\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfulfillSelector( ...args );\n\t\t\treturn selector( ...args );\n\t\t};\n\t\tselectorResolver.hasResolver = true;\n\t\treturn selectorResolver;\n\t};\n\n\treturn {\n\t\tresolvers: mappedResolvers,\n\t\tselectors: mapValues( selectors, mapSelector ),\n\t};\n}\n\n/**\n * Calls a resolver given arguments\n *\n * @param {Object} store Store reference, for fulfilling via resolvers\n * @param {Object} resolvers Store Resolvers\n * @param {string} selectorName Selector name to fulfill.\n * @param {Array} args Selector Arguments.\n */\nasync function fulfillResolver( store, resolvers, selectorName, ...args ) {\n\tconst resolver = get( resolvers, [ selectorName ] );\n\tif ( ! resolver ) {\n\t\treturn;\n\t}\n\n\tconst action = resolver.fulfill( ...args );\n\tif ( action ) {\n\t\tawait store.dispatch( action );\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/redux-store/index.js"],"names":["trimUndefinedValues","array","result","i","length","undefined","splice","createResolversCache","cache","isRunning","selectorName","args","get","clear","delete","markAsRunning","EquivalentKeyMap","set","createReduxStore","key","options","name","instantiate","registry","reducer","thunkArgs","dispatch","Object","assign","action","store","getActions","select","selector","__unstableOriginalGetState","getSelectors","resolveSelect","getResolveSelectors","instantiateReduxStore","resolversCache","resolvers","actions","mapActions","metadataActions","selectors","mapSelectors","metadataSelectors","state","metadata","isRegistrySelector","root","mapResolvers","resolveSelectors","mapResolveSelectors","suspendSelectors","mapSuspendSelectors","getSuspendSelectors","getState","subscribe","listener","lastState","hasChanged","controls","builtinControls","normalizedControls","control","isRegistryControl","middlewares","promise","enhancers","window","__REDUX_DEVTOOLS_EXTENSION__","push","instanceId","initialState","enhancedReducer","metadataReducer","createStateSelector","registrySelector","runSelector","argsLength","arguments","Array","hasResolver","createBoundAction","Promise","resolve","storeSelectors","apply","reject","hasFinished","hasFinishedResolution","finalize","hasFailed","hasResolutionFailed","error","getResolutionError","getResult","unsubscribe","mappedResolvers","resolver","fulfill","mapSelector","selectorResolver","fulfillSelector","isFulfilled","hasStartedResolution","setTimeout","startResolution","fulfillResolver","finishResolution","failResolution"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAtBA;AACA;AACA;;AAMA;AACA;AACA;;AAGA;AACA;AACA;;AASA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AAEA,MAAMA,mBAAmB,GAAKC,KAAF,IAAa;AACxC,QAAMC,MAAM,GAAG,CAAE,GAAGD,KAAL,CAAf;;AACA,OAAM,IAAIE,CAAC,GAAGD,MAAM,CAACE,MAAP,GAAgB,CAA9B,EAAiCD,CAAC,IAAI,CAAtC,EAAyCA,CAAC,EAA1C,EAA+C;AAC9C,QAAKD,MAAM,CAAEC,CAAF,CAAN,KAAgBE,SAArB,EAAiC;AAChCH,MAAAA,MAAM,CAACI,MAAP,CAAeH,CAAf,EAAkB,CAAlB;AACA;AACD;;AACD,SAAOD,MAAP;AACA,CARD;AAUA;AACA;AACA;AACA;AACA;;;AACA,SAASK,oBAAT,GAAgC;AAC/B,QAAMC,KAAK,GAAG,EAAd;AACA,SAAO;AACNC,IAAAA,SAAS,CAAEC,YAAF,EAAgBC,IAAhB,EAAuB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GAAG1F,IAArB,CAAf;;AACA,MAAKkB,MAAL,EAAc;AACb,UAAMC,KAAK,CAACJ,QAAN,CAAgBG,MAAhB,CAAN;AACA;AACD","sourcesContent":["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport { flowRight, get, mapValues, omit } from 'lodash';\nimport combineReducers from 'turbo-combine-reducers';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\n\n/**\n * Internal dependencies\n */\nimport { builtinControls } from '../controls';\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';\n\n/** @typedef {import('../types').DataRegistry} DataRegistry */\n/**\n * @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor\n * @template C\n */\n/**\n * @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State,Actions,Selectors\n */\n\nconst trimUndefinedValues = ( array ) => {\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 * Create a cache to track whether resolvers started running or not.\n *\n * @return {Object} Resolvers Cache.\n */\nfunction createResolversCache() {\n\tconst cache = {};\n\treturn {\n\t\tisRunning( selectorName, args ) {\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, args ) {\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, args ) {\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\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 * @template State,Actions,Selectors\n * @param {string} key Unique namespace identifier.\n * @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.\n */\nexport default function createReduxStore( key, options ) {\n\treturn {\n\t\tname: key,\n\t\tinstantiate: ( registry ) => {\n\t\t\tconst reducer = options.reducer;\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn Object.assign(\n\t\t\t\t\t\t( action ) => store.dispatch( action ),\n\t\t\t\t\t\tgetActions()\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn Object.assign(\n\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t\t\t\tgetSelectors()\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn getResolveSelectors();\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);\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\tlet resolvers;\n\t\t\tconst actions = mapActions(\n\t\t\t\t{\n\t\t\t\t\t...metadataActions,\n\t\t\t\t\t...options.actions,\n\t\t\t\t},\n\t\t\t\tstore\n\t\t\t);\n\n\t\t\tlet selectors = mapSelectors(\n\t\t\t\t{\n\t\t\t\t\t...mapValues(\n\t\t\t\t\t\tmetadataSelectors,\n\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\t( state, ...args ) =>\n\t\t\t\t\t\t\t\tselector( state.metadata, ...args )\n\t\t\t\t\t),\n\t\t\t\t\t...mapValues( options.selectors, ( selector ) => {\n\t\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn ( state, ...args ) =>\n\t\t\t\t\t\t\tselector( state.root, ...args );\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\tstore\n\t\t\t);\n\t\t\tif ( options.resolvers ) {\n\t\t\t\tconst result = mapResolvers(\n\t\t\t\t\toptions.resolvers,\n\t\t\t\t\tselectors,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache\n\t\t\t\t);\n\t\t\t\tresolvers = result.resolvers;\n\t\t\t\tselectors = result.selectors;\n\t\t\t}\n\n\t\t\tconst resolveSelectors = mapResolveSelectors( selectors, store );\n\t\t\tconst suspendSelectors = mapSuspendSelectors( selectors, store );\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 =\n\t\t\t\tstore &&\n\t\t\t\t( ( listener ) => {\n\t\t\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\t\t\treturn store.subscribe( () => {\n\t\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\t\t\tlastState = state;\n\n\t\t\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\t\t\tlistener();\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\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\n/**\n * Creates a redux store for a namespace.\n *\n * @param {string} key Unique namespace identifier.\n * @param {Object} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param {DataRegistry} registry Registry reference.\n * @param {Object} thunkArgs Argument object for the thunk middleware.\n * @return {Object} Newly created redux store.\n */\nfunction instantiateReduxStore( key, options, registry, thunkArgs ) {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control ) =>\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 = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\twindow.__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\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 },\n\t\tflowRight( enhancers )\n\t);\n}\n\n/**\n * Maps selectors to a store.\n *\n * @param {Object} selectors Selectors to register. Keys will be used as the\n * public facing API. Selectors will get passed the\n * state as first argument.\n * @param {Object} store The store to which the selectors should be mapped.\n * @return {Object} Selectors mapped to the provided store.\n */\nfunction mapSelectors( selectors, store ) {\n\tconst createStateSelector = ( registrySelector ) => {\n\t\tconst selector = function runSelector() {\n\t\t\t// This function is an optimized implementation of:\n\t\t\t//\n\t\t\t// selector( store.getState(), ...arguments )\n\t\t\t//\n\t\t\t// Where the above would incur an `Array#concat` in its application,\n\t\t\t// the logic here instead efficiently constructs an arguments array via\n\t\t\t// direct assignment.\n\t\t\tconst argsLength = arguments.length;\n\t\t\tconst args = new Array( argsLength + 1 );\n\t\t\targs[ 0 ] = store.__unstableOriginalGetState();\n\t\t\tfor ( let i = 0; i < argsLength; i++ ) {\n\t\t\t\targs[ i + 1 ] = arguments[ i ];\n\t\t\t}\n\n\t\t\treturn registrySelector( ...args );\n\t\t};\n\t\tselector.hasResolver = false;\n\t\treturn selector;\n\t};\n\n\treturn mapValues( selectors, createStateSelector );\n}\n\n/**\n * Maps actions to dispatch from a given store.\n *\n * @param {Object} actions Actions to register.\n * @param {Object} store The redux store to which the actions should be mapped.\n *\n * @return {Object} Actions mapped to the redux store provided.\n */\nfunction mapActions( actions, store ) {\n\tconst createBoundAction =\n\t\t( action ) =>\n\t\t( ...args ) => {\n\t\t\treturn Promise.resolve( store.dispatch( action( ...args ) ) );\n\t\t};\n\n\treturn mapValues( actions, createBoundAction );\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their resolution functions.\n */\nfunction mapResolveSelectors( selectors, store ) {\n\tconst storeSelectors = omit( selectors, [\n\t\t'getIsResolving',\n\t\t'hasStartedResolution',\n\t\t'hasFinishedResolution',\n\t\t'hasResolutionFailed',\n\t\t'isResolving',\n\t\t'getCachedResolvers',\n\t\t'getResolutionState',\n\t\t'getResolutionError',\n\t] );\n\n\treturn mapValues( storeSelectors, ( selector, selectorName ) => {\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 ) => selector.apply( null, args );\n\t\t}\n\n\t\treturn ( ...args ) => {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () =>\n\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args );\n\t\t\t\tconst finalize = ( result ) => {\n\t\t\t\t\tconst hasFailed = selectors.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\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = selectors.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.apply( null, args );\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\t};\n\t} );\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their suspense functions.\n */\nfunction mapSuspendSelectors( selectors, store ) {\n\treturn mapValues( selectors, ( selector, selectorName ) => {\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 ) => {\n\t\t\tconst result = selector.apply( null, args );\n\n\t\t\tif ( selectors.hasFinishedResolution( selectorName, args ) ) {\n\t\t\t\tif ( selectors.hasResolutionFailed( selectorName, args ) ) {\n\t\t\t\t\tthrow selectors.getResolutionError( selectorName, args );\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args )\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 * Returns resolvers with matched selectors for a given namespace.\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 {Object} resolvers Resolvers to register.\n * @param {Object} selectors The current selectors to be modified.\n * @param {Object} store The redux store to which the resolvers should be mapped.\n * @param {Object} resolversCache Resolvers Cache.\n */\nfunction mapResolvers( resolvers, selectors, store, resolversCache ) {\n\t// The `resolver` can be either a function that does the resolution, or, in more advanced\n\t// cases, an object with a `fullfill` method and other optional methods like `isFulfilled`.\n\t// Here we normalize the `resolver` function to an object with `fulfill` method.\n\tconst mappedResolvers = mapValues( resolvers, ( resolver ) => {\n\t\tif ( resolver.fulfill ) {\n\t\t\treturn resolver;\n\t\t}\n\n\t\treturn {\n\t\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\t\tfulfill: resolver, // Add the fulfill method.\n\t\t};\n\t} );\n\n\tconst mapSelector = ( selector, selectorName ) => {\n\t\tconst resolver = resolvers[ selectorName ];\n\t\tif ( ! resolver ) {\n\t\t\tselector.hasResolver = false;\n\t\t\treturn selector;\n\t\t}\n\n\t\tconst selectorResolver = ( ...args ) => {\n\t\t\tasync function fulfillSelector() {\n\t\t\t\tconst state = store.getState();\n\n\t\t\t\tif (\n\t\t\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\t\tresolver.isFulfilled( state, ...args ) )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { metadata } = store.__unstableOriginalGetState();\n\n\t\t\t\tif (\n\t\t\t\t\tmetadataSelectors.hasStartedResolution(\n\t\t\t\t\t\tmetadata,\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\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\t\t\tsetTimeout( async () => {\n\t\t\t\t\tresolversCache.clear( selectorName, args );\n\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t\t\t);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fulfillResolver(\n\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\tmappedResolvers,\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t...args\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\t\tmetadataActions.finishResolution(\n\t\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t\targs\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch ( error ) {\n\t\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\t\tmetadataActions.failResolution(\n\t\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t\targs,\n\t\t\t\t\t\t\t\terror\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfulfillSelector( ...args );\n\t\t\treturn selector( ...args );\n\t\t};\n\t\tselectorResolver.hasResolver = true;\n\t\treturn selectorResolver;\n\t};\n\n\treturn {\n\t\tresolvers: mappedResolvers,\n\t\tselectors: mapValues( selectors, mapSelector ),\n\t};\n}\n\n/**\n * Calls a resolver given arguments\n *\n * @param {Object} store Store reference, for fulfilling via resolvers\n * @param {Object} resolvers Store Resolvers\n * @param {string} selectorName Selector name to fulfill.\n * @param {Array} args Selector Arguments.\n */\nasync function fulfillResolver( store, resolvers, selectorName, ...args ) {\n\tconst resolver = get( resolvers, [ selectorName ] );\n\tif ( ! resolver ) {\n\t\treturn;\n\t}\n\n\tconst action = resolver.fulfill( ...args );\n\tif ( action ) {\n\t\tawait store.dispatch( action );\n\t}\n}\n"]}
|
|
@@ -20,7 +20,22 @@ import useAsyncMode from '../async-mode-provider/use-async-mode';
|
|
|
20
20
|
const noop = () => {};
|
|
21
21
|
|
|
22
22
|
const renderQueue = createQueue();
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
|
|
25
|
+
* @template C
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
|
|
30
|
+
* @template State,Actions,Selectors
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
|
|
35
|
+
* @template T
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** @typedef {import('../../types').MapSelect} MapSelect */
|
|
24
39
|
|
|
25
40
|
/**
|
|
26
41
|
* Custom react hook for retrieving props from registered selectors.
|
|
@@ -28,20 +43,16 @@ const renderQueue = createQueue();
|
|
|
28
43
|
* In general, this custom React hook follows the
|
|
29
44
|
* [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
|
|
30
45
|
*
|
|
31
|
-
* @
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* element tree.
|
|
42
|
-
* @param {Array} deps If provided, this memoizes the mapSelect so the
|
|
43
|
-
* same `mapSelect` is invoked on every state
|
|
44
|
-
* change unless the dependencies change.
|
|
46
|
+
* @template {MapSelect | StoreDescriptor<any>} T
|
|
47
|
+
* @param {T} mapSelect Function called on every state change. The returned value is
|
|
48
|
+
* exposed to the component implementing this hook. The function
|
|
49
|
+
* receives the `registry.select` method on the first argument
|
|
50
|
+
* and the `registry` on the second argument.
|
|
51
|
+
* When a store key is passed, all selectors for the store will be
|
|
52
|
+
* returned. This is only meant for usage of these selectors in event
|
|
53
|
+
* callbacks, not for data needed to create the element tree.
|
|
54
|
+
* @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is
|
|
55
|
+
* invoked on every state change unless the dependencies change.
|
|
45
56
|
*
|
|
46
57
|
* @example
|
|
47
58
|
* ```js
|
|
@@ -86,8 +97,7 @@ const renderQueue = createQueue();
|
|
|
86
97
|
* return <div onPaste={ onPaste }>{ children }</div>;
|
|
87
98
|
* }
|
|
88
99
|
* ```
|
|
89
|
-
*
|
|
90
|
-
* @return {Function} A custom react hook.
|
|
100
|
+
* @return {UseSelectReturn<T>} A custom react hook.
|
|
91
101
|
*/
|
|
92
102
|
|
|
93
103
|
export default function useSelect(mapSelect, deps) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/components/use-select/index.js"],"names":["useMemoOne","createQueue","useRef","useCallback","useMemo","useReducer","isShallowEqual","useIsomorphicLayoutEffect","useRegistry","useAsyncMode","noop","renderQueue","useSelect","mapSelect","deps","hasMappingFunction","callbackMapper","_mapSelect","registry","isAsync","latestRegistry","latestMapSelect","latestIsAsync","latestMapOutput","latestMapOutputError","listeningStores","wrapSelect","callback","__unstableMarkListeningStores","select","depsChangedFlag","mapOutput","current","hasReplacedRegistry","hasReplacedMapSelect","hasLeftAsyncMode","lastMapSelectFailed","error","errorMessage","message","stack","console","undefined","queueContext","queue","forceRender","s","isMounted","onStoreChange","newMapOutput","onChange","add","unsubscribers","map","storeName","__unstableSubscribeStore","forEach","unsubscribe","cancel","useSuspenseSelect","suspendSelect","mapOutputError"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,cAA3B;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,2BAA5B;AACA,SAASC,MAAT,EAAiBC,WAAjB,EAA8BC,OAA9B,EAAuCC,UAAvC,QAAyD,oBAAzD;AACA,OAAOC,cAAP,MAA2B,6BAA3B;AACA,SAASC,yBAAT,QAA0C,oBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,mCAAxB;AACA,OAAOC,YAAP,MAAyB,uCAAzB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,WAAW,GAAGV,WAAW,EAA/B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASW,SAAT,CAAoBC,SAApB,EA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K1B,cAAc,CAAEiB,eAAe,CAACS,OAAlB,EAA2BiB,YAA3B,CAAnB,EAA+D;AAC9D;AACA;;AACD1B,QAAAA,eAAe,CAACS,OAAhB,GAA0BiB,YAA1B;AACA,OAPD,CAOE,OAAQZ,KAAR,EAAgB;AACjBb,QAAAA,oBAAoB,CAACQ,OAArB,GAA+BK,KAA/B;AACA;;AAEDQ,MAAAA,WAAW;AACX,KAbD;;AAeA,UAAMK,QAAQ,GAAG,MAAM;AACtB,UAAK,CAAEH,SAAS,CAACf,OAAjB,EAA2B;AAC1B;AACA;;AAED,UAAKV,aAAa,CAACU,OAAnB,EAA6B;AAC5BrB,QAAAA,WAAW,CAACwC,GAAZ,CAAiBR,YAAjB,EAA+BK,aAA/B;AACA,OAFD,MAEO;AACNA,QAAAA,aAAa;AACb;AACD,KAVD,CAhBgC,CA4BhC;AACA;;;AACAA,IAAAA,aAAa;AAEb,UAAMI,aAAa,GAAG3B,eAAe,CAACO,OAAhB,CAAwBqB,GAAxB,CAA+BC,SAAF,IAClDpC,QAAQ,CAACqC,wBAAT,CAAmCD,SAAnC,EAA8CJ,QAA9C,CADqB,CAAtB;AAIAH,IAAAA,SAAS,CAACf,OAAV,GAAoB,IAApB;AAEA,WAAO,MAAM;AACZ;AACAoB,MAAAA,aAAa,CAACI,OAAd,CAAyBC,WAAF,IAAmBA,WAAnB,aAAmBA,WAAnB,uBAAmBA,WAAW,EAArD;AACA9C,MAAAA,WAAW,CAAC+C,MAAZ,CAAoBf,YAApB;AACAI,MAAAA,SAAS,CAACf,OAAV,GAAoB,KAApB;AACA,KALD;AAMA,GA5CwB,EA4CtB,CAAEd,QAAF,EAAYQ,UAAZ,EAAwBI,eAAxB,CA5CsB,CAAzB;;AA8CA,MAAK+B,cAAL,EAAsB;AACrB,UAAMA,cAAN;AACA;;AAED,SAAO9B,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport { useRef, useCallback, useMemo, useReducer } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst noop = () => {};\nconst renderQueue = createQueue();\n\n/** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */\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://reactjs.org/docs/hooks-rules.html).\n *\n * @param {Function|StoreDescriptor|string} mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * implementing this hook. The function receives\n * the `registry.select` method on the first\n * argument and the `registry` on the second\n * argument.\n * When a store key is passed, all selectors for\n * the store will be returned. This is only meant\n * for usage of these selectors in event\n * callbacks, not for data needed to create the\n * element tree.\n * @param {Array} deps If provided, this memoizes the mapSelect so the\n * same `mapSelect` is invoked on every state\n * change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( 'my-shop' ).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 *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( 'my-shop' );\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 {Function} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\tconst hasMappingFunction = 'function' === typeof mapSelect;\n\n\t// If we're recalling a store by its name or by\n\t// its descriptor then we won't be caching the\n\t// calls to `mapSelect` because we won't be calling it.\n\tif ( ! hasMappingFunction ) {\n\t\tdeps = [];\n\t}\n\n\t// Because of the \"rule of hooks\" we have to call `useCallback`\n\t// on every invocation whether or not we have a real function\n\t// for `mapSelect`. we'll create this intermediate variable to\n\t// fulfill that need and then reference it with our \"real\"\n\t// `_mapSelect` if we can.\n\tconst callbackMapper = useCallback(\n\t\thasMappingFunction ? mapSelect : noop,\n\t\tdeps\n\t);\n\tconst _mapSelect = hasMappingFunction ? callbackMapper : null;\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\n\tconst latestRegistry = useRef( registry );\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\n\t// Keep track of the stores being selected in the _mapSelect function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst wrapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__unstableMarkListeningStores(\n\t\t\t\t() => callback( registry.select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput;\n\n\tif ( _mapSelect ) {\n\t\tmapOutput = latestMapOutput.current;\n\t\tconst hasReplacedRegistry = latestRegistry.current !== registry;\n\t\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\t\tconst hasLeftAsyncMode = latestIsAsync.current && ! isAsync;\n\t\tconst lastMapSelectFailed = !! latestMapOutputError.current;\n\n\t\tif (\n\t\t\thasReplacedRegistry ||\n\t\t\thasReplacedMapSelect ||\n\t\t\thasLeftAsyncMode ||\n\t\t\tlastMapSelectFailed\n\t\t) {\n\t\t\ttry {\n\t\t\t\tmapOutput = wrapSelect( _mapSelect );\n\t\t\t} catch ( error ) {\n\t\t\t\tlet errorMessage = `An error occurred while running 'mapSelect': ${ error.message }`;\n\n\t\t\t\tif ( latestMapOutputError.current ) {\n\t\t\t\t\terrorMessage += `\\nThe error may be correlated with this previous error:\\n`;\n\t\t\t\t\terrorMessage += `${ latestMapOutputError.current.stack }\\n\\n`;\n\t\t\t\t\terrorMessage += 'Original stack trace:';\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error( errorMessage );\n\t\t\t}\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlatestRegistry.current = registry;\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestIsAsync.current = isAsync;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = undefined;\n\t} );\n\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\tconst isMounted = useRef( false );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onStoreChange = () => {\n\t\t\ttry {\n\t\t\t\tconst newMapOutput = wrapSelect( latestMapSelect.current );\n\n\t\t\t\tif ( isShallowEqual( latestMapOutput.current, newMapOutput ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t} catch ( error ) {\n\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t}\n\t\t\tforceRender();\n\t\t};\n\n\t\tconst onChange = () => {\n\t\t\tif ( ! isMounted.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\t// Catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tonStoreChange();\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__unstableSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\tisMounted.current = true;\n\n\t\treturn () => {\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.cancel( queueContext );\n\t\t\tisMounted.current = false;\n\t\t};\n\t\t// If you're tempted to eliminate the spread dependencies below don't do it!\n\t\t// We're passing these in from the calling function and want to make sure we're\n\t\t// examining every individual value inside the `deps` array.\n\t}, [ registry, wrapSelect, hasMappingFunction, depsChangedFlag ] );\n\n\treturn hasMappingFunction ? mapOutput : registry.select( mapSelect );\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but will throw a\n * suspense Promise if any of the called selectors is in an unresolved state.\n *\n * @param {Function} 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 {Array} 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 * @return {Object} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\tconst _mapSelect = useCallback( mapSelect, deps );\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\n\tconst latestRegistry = useRef( registry );\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\n\t// Keep track of the stores being selected in the `mapSelect` function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst wrapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__unstableMarkListeningStores(\n\t\t\t\t() => callback( registry.suspendSelect, registry ),\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput = latestMapOutput.current;\n\tlet mapOutputError = latestMapOutputError.current;\n\n\tconst hasReplacedRegistry = latestRegistry.current !== registry;\n\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\tconst hasLeftAsyncMode = latestIsAsync.current && ! isAsync;\n\n\tif ( hasReplacedRegistry || hasReplacedMapSelect || hasLeftAsyncMode ) {\n\t\ttry {\n\t\t\tmapOutput = wrapSelect( _mapSelect );\n\t\t} catch ( error ) {\n\t\t\tmapOutputError = error;\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tlatestRegistry.current = registry;\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestIsAsync.current = isAsync;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = mapOutputError;\n\t} );\n\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\tconst isMounted = useRef( false );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tconst onStoreChange = () => {\n\t\t\ttry {\n\t\t\t\tconst newMapOutput = wrapSelect( latestMapSelect.current );\n\n\t\t\t\tif ( isShallowEqual( latestMapOutput.current, newMapOutput ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t} catch ( error ) {\n\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t}\n\n\t\t\tforceRender();\n\t\t};\n\n\t\tconst onChange = () => {\n\t\t\tif ( ! isMounted.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\t// catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tonStoreChange();\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__unstableSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\tisMounted.current = true;\n\n\t\treturn () => {\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.cancel( queueContext );\n\t\t\tisMounted.current = false;\n\t\t};\n\t}, [ registry, wrapSelect, depsChangedFlag ] );\n\n\tif ( mapOutputError ) {\n\t\tthrow mapOutputError;\n\t}\n\n\treturn mapOutput;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/components/use-select/index.js"],"names":["useMemoOne","createQueue","useRef","useCallback","useMemo","useReducer","isShallowEqual","useIsomorphicLayoutEffect","useRegistry","useAsyncMode","noop","renderQueue","useSelect","mapSelect","deps","hasMappingFunction","callbackMapper","_mapSelect","registry","isAsync","latestRegistry","latestMapSelect","latestIsAsync","latestMapOutput","latestMapOutputError","listeningStores","wrapSelect","callback","__unstableMarkListeningStores","select","depsChangedFlag","mapOutput","current","hasReplacedRegistry","hasReplacedMapSelect","hasLeftAsyncMode","lastMapSelectFailed","error","errorMessage","message","stack","console","undefined","queueContext","queue","forceRender","s","isMounted","onStoreChange","newMapOutput","onChange","add","unsubscribers","map","storeName","__unstableSubscribeStore","forEach","unsubscribe","cancel","useSuspenseSelect","suspendSelect","mapOutputError"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,cAA3B;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,2BAA5B;AACA,SAASC,MAAT,EAAiBC,WAAjB,EAA8BC,OAA9B,EAAuCC,UAAvC,QAAyD,oBAAzD;AACA,OAAOC,cAAP,MAA2B,6BAA3B;AACA,SAASC,yBAAT,QAA0C,oBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,mCAAxB;AACA,OAAOC,YAAP,MAAyB,uCAAzB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,WAAW,GAAGV,WAAW,EAA/B;AAEA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASW,SAAT,CAAoBC,SAApB,EAA+BC,IAA/B,EAAsC;AACpD,QAAMC,kBAAkB,GAAG,eAAe,OAAOF,SAAjD,CADoD,CAGpD;AACA;AACA;;AACA,MAAK,CAAEE,kBAAP,EAA4B;AAC3BD,IAAAA,IAAI,GAAG,EAAP;AACA,GARmD,CAUpD;AACA;AACA;AACA;AACA;;;AACA,QAAME,cAAc,GAAGb,WA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ACA;;AAEDQ,MAAAA,WAAW;AACX,KAbD;;AAeA,UAAMK,QAAQ,GAAG,MAAM;AACtB,UAAK,CAAEH,SAAS,CAACf,OAAjB,EAA2B;AAC1B;AACA;;AAED,UAAKV,aAAa,CAACU,OAAnB,EAA6B;AAC5BrB,QAAAA,WAAW,CAACwC,GAAZ,CAAiBR,YAAjB,EAA+BK,aAA/B;AACA,OAFD,MAEO;AACNA,QAAAA,aAAa;AACb;AACD,KAVD,CAhBgC,CA4BhC;AACA;;;AACAA,IAAAA,aAAa;AAEb,UAAMI,aAAa,GAAG3B,eAAe,CAACO,OAAhB,CAAwBqB,GAAxB,CAA+BC,SAAF,IAClDpC,QAAQ,CAACqC,wBAAT,CAAmCD,SAAnC,EAA8CJ,QAA9C,CADqB,CAAtB;AAIAH,IAAAA,SAAS,CAACf,OAAV,GAAoB,IAApB;AAEA,WAAO,MAAM;AACZ;AACAoB,MAAAA,aAAa,CAACI,OAAd,CAAyBC,WAAF,IAAmBA,WAAnB,aAAmBA,WAAnB,uBAAmBA,WAAW,EAArD;AACA9C,MAAAA,WAAW,CAAC+C,MAAZ,CAAoBf,YAApB;AACAI,MAAAA,SAAS,CAACf,OAAV,GAAoB,KAApB;AACA,KALD;AAMA,GA5CwB,EA4CtB,CAAEd,QAAF,EAAYQ,UAAZ,EAAwBI,eAAxB,CA5CsB,CAAzB;;AA8CA,MAAK+B,cAAL,EAAsB;AACrB,UAAMA,cAAN;AACA;;AAED,SAAO9B,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport { useRef, useCallback, useMemo, useReducer } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst noop = () => {};\nconst renderQueue = createQueue();\n\n/**\n * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor\n * @template C\n */\n/**\n * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State,Actions,Selectors\n */\n/**\n * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn\n * @template T\n */\n/** @typedef {import('../../types').MapSelect} MapSelect */\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://reactjs.org/docs/hooks-rules.html).\n *\n * @template {MapSelect | StoreDescriptor<any>} T\n * @param {T} 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 {unknown[]} 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 *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( 'my-shop' ).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 *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( 'my-shop' );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n * @return {UseSelectReturn<T>} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\tconst hasMappingFunction = 'function' === typeof mapSelect;\n\n\t// If we're recalling a store by its name or by\n\t// its descriptor then we won't be caching the\n\t// calls to `mapSelect` because we won't be calling it.\n\tif ( ! hasMappingFunction ) {\n\t\tdeps = [];\n\t}\n\n\t// Because of the \"rule of hooks\" we have to call `useCallback`\n\t// on every invocation whether or not we have a real function\n\t// for `mapSelect`. we'll create this intermediate variable to\n\t// fulfill that need and then reference it with our \"real\"\n\t// `_mapSelect` if we can.\n\tconst callbackMapper = useCallback(\n\t\thasMappingFunction ? mapSelect : noop,\n\t\tdeps\n\t);\n\tconst _mapSelect = hasMappingFunction ? callbackMapper : null;\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\n\tconst latestRegistry = useRef( registry );\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\n\t// Keep track of the stores being selected in the _mapSelect function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst wrapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__unstableMarkListeningStores(\n\t\t\t\t() => callback( registry.select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput;\n\n\tif ( _mapSelect ) {\n\t\tmapOutput = latestMapOutput.current;\n\t\tconst hasReplacedRegistry = latestRegistry.current !== registry;\n\t\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\t\tconst hasLeftAsyncMode = latestIsAsync.current && ! isAsync;\n\t\tconst lastMapSelectFailed = !! latestMapOutputError.current;\n\n\t\tif (\n\t\t\thasReplacedRegistry ||\n\t\t\thasReplacedMapSelect ||\n\t\t\thasLeftAsyncMode ||\n\t\t\tlastMapSelectFailed\n\t\t) {\n\t\t\ttry {\n\t\t\t\tmapOutput = wrapSelect( _mapSelect );\n\t\t\t} catch ( error ) {\n\t\t\t\tlet errorMessage = `An error occurred while running 'mapSelect': ${ error.message }`;\n\n\t\t\t\tif ( latestMapOutputError.current ) {\n\t\t\t\t\terrorMessage += `\\nThe error may be correlated with this previous error:\\n`;\n\t\t\t\t\terrorMessage += `${ latestMapOutputError.current.stack }\\n\\n`;\n\t\t\t\t\terrorMessage += 'Original stack trace:';\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.error( errorMessage );\n\t\t\t}\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlatestRegistry.current = registry;\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestIsAsync.current = isAsync;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = undefined;\n\t} );\n\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\tconst isMounted = useRef( false );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tif ( ! hasMappingFunction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onStoreChange = () => {\n\t\t\ttry {\n\t\t\t\tconst newMapOutput = wrapSelect( latestMapSelect.current );\n\n\t\t\t\tif ( isShallowEqual( latestMapOutput.current, newMapOutput ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t} catch ( error ) {\n\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t}\n\t\t\tforceRender();\n\t\t};\n\n\t\tconst onChange = () => {\n\t\t\tif ( ! isMounted.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\t// Catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tonStoreChange();\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__unstableSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\tisMounted.current = true;\n\n\t\treturn () => {\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.cancel( queueContext );\n\t\t\tisMounted.current = false;\n\t\t};\n\t\t// If you're tempted to eliminate the spread dependencies below don't do it!\n\t\t// We're passing these in from the calling function and want to make sure we're\n\t\t// examining every individual value inside the `deps` array.\n\t}, [ registry, wrapSelect, hasMappingFunction, depsChangedFlag ] );\n\n\treturn hasMappingFunction ? mapOutput : registry.select( mapSelect );\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but will throw a\n * suspense Promise if any of the called selectors is in an unresolved state.\n *\n * @param {Function} 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 {Array} 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 * @return {Object} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\tconst _mapSelect = useCallback( mapSelect, deps );\n\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\n\tconst latestRegistry = useRef( registry );\n\tconst latestMapSelect = useRef();\n\tconst latestIsAsync = useRef( isAsync );\n\tconst latestMapOutput = useRef();\n\tconst latestMapOutputError = useRef();\n\n\t// Keep track of the stores being selected in the `mapSelect` function,\n\t// and only subscribe to those stores later.\n\tconst listeningStores = useRef( [] );\n\tconst wrapSelect = useCallback(\n\t\t( callback ) =>\n\t\t\tregistry.__unstableMarkListeningStores(\n\t\t\t\t() => callback( registry.suspendSelect, registry ),\n\t\t\t\tlisteningStores\n\t\t\t),\n\t\t[ registry ]\n\t);\n\n\t// Generate a \"flag\" for used in the effect dependency array.\n\t// It's different than just using `mapSelect` since deps could be undefined,\n\t// in that case, we would still want to memoize it.\n\tconst depsChangedFlag = useMemo( () => ( {} ), deps || [] );\n\n\tlet mapOutput = latestMapOutput.current;\n\tlet mapOutputError = latestMapOutputError.current;\n\n\tconst hasReplacedRegistry = latestRegistry.current !== registry;\n\tconst hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;\n\tconst hasLeftAsyncMode = latestIsAsync.current && ! isAsync;\n\n\tif ( hasReplacedRegistry || hasReplacedMapSelect || hasLeftAsyncMode ) {\n\t\ttry {\n\t\t\tmapOutput = wrapSelect( _mapSelect );\n\t\t} catch ( error ) {\n\t\t\tmapOutputError = error;\n\t\t}\n\t}\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tlatestRegistry.current = registry;\n\t\tlatestMapSelect.current = _mapSelect;\n\t\tlatestIsAsync.current = isAsync;\n\t\tlatestMapOutput.current = mapOutput;\n\t\tlatestMapOutputError.current = mapOutputError;\n\t} );\n\n\t// React can sometimes clear the `useMemo` cache.\n\t// We use the cache-stable `useMemoOne` to avoid\n\t// losing queues.\n\tconst queueContext = useMemoOne( () => ( { queue: true } ), [ registry ] );\n\tconst [ , forceRender ] = useReducer( ( s ) => s + 1, 0 );\n\tconst isMounted = useRef( false );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tconst onStoreChange = () => {\n\t\t\ttry {\n\t\t\t\tconst newMapOutput = wrapSelect( latestMapSelect.current );\n\n\t\t\t\tif ( isShallowEqual( latestMapOutput.current, newMapOutput ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatestMapOutput.current = newMapOutput;\n\t\t\t} catch ( error ) {\n\t\t\t\tlatestMapOutputError.current = error;\n\t\t\t}\n\n\t\t\tforceRender();\n\t\t};\n\n\t\tconst onChange = () => {\n\t\t\tif ( ! isMounted.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( latestIsAsync.current ) {\n\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t} else {\n\t\t\t\tonStoreChange();\n\t\t\t}\n\t\t};\n\n\t\t// catch any possible state changes during mount before the subscription\n\t\t// could be set.\n\t\tonStoreChange();\n\n\t\tconst unsubscribers = listeningStores.current.map( ( storeName ) =>\n\t\t\tregistry.__unstableSubscribeStore( storeName, onChange )\n\t\t);\n\n\t\tisMounted.current = true;\n\n\t\treturn () => {\n\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe?.() );\n\t\t\trenderQueue.cancel( queueContext );\n\t\t\tisMounted.current = false;\n\t\t};\n\t}, [ registry, wrapSelect, depsChangedFlag ] );\n\n\tif ( mapOutputError ) {\n\t\tthrow mapOutputError;\n\t}\n\n\treturn mapOutput;\n}\n"]}
|
|
@@ -23,9 +23,15 @@ import * as metadataSelectors from './metadata/selectors';
|
|
|
23
23
|
import * as metadataActions from './metadata/actions';
|
|
24
24
|
/** @typedef {import('../types').DataRegistry} DataRegistry */
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor
|
|
28
|
+
* @template C
|
|
29
|
+
*/
|
|
27
30
|
|
|
28
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
|
|
33
|
+
* @template State,Actions,Selectors
|
|
34
|
+
*/
|
|
29
35
|
|
|
30
36
|
const trimUndefinedValues = array => {
|
|
31
37
|
const result = [...array];
|
|
@@ -84,12 +90,13 @@ function createResolversCache() {
|
|
|
84
90
|
* } );
|
|
85
91
|
* ```
|
|
86
92
|
*
|
|
87
|
-
* @
|
|
88
|
-
* @param {
|
|
89
|
-
*
|
|
90
|
-
*
|
|
93
|
+
* @template State,Actions,Selectors
|
|
94
|
+
* @param {string} key Unique namespace identifier.
|
|
95
|
+
* @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties
|
|
96
|
+
* describing reducer, actions, selectors,
|
|
97
|
+
* and resolvers.
|
|
91
98
|
*
|
|
92
|
-
* @return
|
|
99
|
+
* @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.
|
|
93
100
|
*/
|
|
94
101
|
|
|
95
102
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/redux-store/index.js"],"names":["createStore","applyMiddleware","flowRight","get","mapValues","omit","combineReducers","EquivalentKeyMap","createReduxRoutineMiddleware","builtinControls","promise","createResolversCacheMiddleware","createThunkMiddleware","metadataReducer","metadataSelectors","metadataActions","trimUndefinedValues","array","result","i","length","undefined","splice","createResolversCache","cache","isRunning","selectorName","args","clear","delete","markAsRunning","set","createReduxStore","key","options","name","instantiate","registry","reducer","thunkArgs","dispatch","Object","assign","action","store","getActions","select","selector","__unstableOriginalGetState","getSelectors","resolveSelect","getResolveSelectors","instantiateReduxStore","resolversCache","resolvers","actions","mapActions","selectors","mapSelectors","state","metadata","isRegistrySelector","root","mapResolvers","resolveSelectors","mapResolveSelectors","suspendSelectors","mapSuspendSelectors","getSuspendSelectors","getState","subscribe","listener","lastState","hasChanged","controls","normalizedControls","control","isRegistryControl","middlewares","enhancers","window","__REDUX_DEVTOOLS_EXTENSION__","push","instanceId","initialState","enhancedReducer","createStateSelector","registrySelector","runSelector","argsLength","arguments","Array","hasResolver","createBoundAction","Promise","resolve","storeSelectors","apply","reject","hasFinished","hasFinishedResolution","finalize","hasFailed","hasResolutionFailed","error","getResolutionError","getResult","unsubscribe","mappedResolvers","resolver","fulfill","mapSelector","selectorResolver","fulfillSelector","isFulfilled","hasStartedResolution","setTimeout","startResolution","fulfillResolver","finishResolution","failResolution"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,eAAtB,QAA6C,OAA7C;AACA,SAASC,SAAT,EAAoBC,GAApB,EAAyBC,SAAzB,EAAoCC,IAApC,QAAgD,QAAhD;AACA,OAAOC,eAAP,MAA4B,wBAA5B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,4BAAP,MAAyC,0BAAzC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,aAAhC;AACA,OAAOC,OAAP,MAAoB,uBAApB;AACA,OAAOC,8BAAP,MAA2C,+BAA3C;AACA,OAAOC,qBAAP,MAAkC,oBAAlC;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,sBAAnC;AACA,OAAO,KAAKC,eAAZ,MAAiC,oBAAjC;AAEA;;AACA;;AACA;;AAEA,MAAMC,mBAAmB,GAAKC,KAAF,IAAa;AACxC,QAAMC,MAAM,GAAG,CAAE,GAAGD,KAAL,CAAf;;AACA,OAAM,IAAIE,CAAC,GAAGD,MAAM,CAACE,MAAP,GAAgB,CAA9B,EAAiCD,CAAC,IAAI,CAAtC,EAAyCA,CAAC,EAA1C,EAA+C;AAC9C,QAAKD,MAAM,CAAEC,CAAF,CAAN,KAAgBE,SAArB,EAAiC;AAChCH,MAAAA,MAAM,CAACI,MAAP,CAAeH,CAAf,EAAkB,CAAlB;AACA;AACD;;AACD,SAAOD,MAAP;AACA,CARD;AAUA;AACA;AACA;AACA;AACA;;;AACA,SAASK,oBAAT,GAAgC;AAC/B,QAAMC,KAAK,GAAG,EA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AAF,EAAa,CAAE5B,YAAF,CAAb,CAApB;;AACA,MAAK,CAAEmF,QAAP,EAAkB;AACjB;AACA;;AAJwE,qCAAPlF,IAAO;AAAPA,IAAAA,IAAO;AAAA;;AAMzE,QAAMgB,MAAM,GAAGkE,QAAQ,CAACC,OAAT,CAAkB,GAAGnF,IAArB,CAAf;;AACA,MAAKgB,MAAL,EAAc;AACb,UAAMC,KAAK,CAACJ,QAAN,CAAgBG,MAAhB,CAAN;AACA;AACD","sourcesContent":["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport { flowRight, get, mapValues, omit } from 'lodash';\nimport combineReducers from 'turbo-combine-reducers';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\n\n/**\n * Internal dependencies\n */\nimport { builtinControls } from '../controls';\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';\n\n/** @typedef {import('../types').DataRegistry} DataRegistry */\n/** @typedef {import('../types').StoreDescriptor} StoreDescriptor */\n/** @typedef {import('../types').ReduxStoreConfig} ReduxStoreConfig */\n\nconst trimUndefinedValues = ( array ) => {\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 * Create a cache to track whether resolvers started running or not.\n *\n * @return {Object} Resolvers Cache.\n */\nfunction createResolversCache() {\n\tconst cache = {};\n\treturn {\n\t\tisRunning( selectorName, args ) {\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, args ) {\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, args ) {\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\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 {string} key Unique namespace identifier.\n * @param {ReduxStoreConfig} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return {StoreDescriptor} Store Object.\n */\nexport default function createReduxStore( key, options ) {\n\treturn {\n\t\tname: key,\n\t\tinstantiate: ( registry ) => {\n\t\t\tconst reducer = options.reducer;\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn Object.assign(\n\t\t\t\t\t\t( action ) => store.dispatch( action ),\n\t\t\t\t\t\tgetActions()\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn Object.assign(\n\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t\t\t\tgetSelectors()\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn getResolveSelectors();\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);\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\tlet resolvers;\n\t\t\tconst actions = mapActions(\n\t\t\t\t{\n\t\t\t\t\t...metadataActions,\n\t\t\t\t\t...options.actions,\n\t\t\t\t},\n\t\t\t\tstore\n\t\t\t);\n\n\t\t\tlet selectors = mapSelectors(\n\t\t\t\t{\n\t\t\t\t\t...mapValues(\n\t\t\t\t\t\tmetadataSelectors,\n\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\t( state, ...args ) =>\n\t\t\t\t\t\t\t\tselector( state.metadata, ...args )\n\t\t\t\t\t),\n\t\t\t\t\t...mapValues( options.selectors, ( selector ) => {\n\t\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn ( state, ...args ) =>\n\t\t\t\t\t\t\tselector( state.root, ...args );\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\tstore\n\t\t\t);\n\t\t\tif ( options.resolvers ) {\n\t\t\t\tconst result = mapResolvers(\n\t\t\t\t\toptions.resolvers,\n\t\t\t\t\tselectors,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache\n\t\t\t\t);\n\t\t\t\tresolvers = result.resolvers;\n\t\t\t\tselectors = result.selectors;\n\t\t\t}\n\n\t\t\tconst resolveSelectors = mapResolveSelectors( selectors, store );\n\t\t\tconst suspendSelectors = mapSuspendSelectors( selectors, store );\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 =\n\t\t\t\tstore &&\n\t\t\t\t( ( listener ) => {\n\t\t\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\t\t\treturn store.subscribe( () => {\n\t\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\t\t\tlastState = state;\n\n\t\t\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\t\t\tlistener();\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\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\n/**\n * Creates a redux store for a namespace.\n *\n * @param {string} key Unique namespace identifier.\n * @param {Object} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param {DataRegistry} registry Registry reference.\n * @param {Object} thunkArgs Argument object for the thunk middleware.\n * @return {Object} Newly created redux store.\n */\nfunction instantiateReduxStore( key, options, registry, thunkArgs ) {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control ) =>\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 = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\twindow.__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\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 },\n\t\tflowRight( enhancers )\n\t);\n}\n\n/**\n * Maps selectors to a store.\n *\n * @param {Object} selectors Selectors to register. Keys will be used as the\n * public facing API. Selectors will get passed the\n * state as first argument.\n * @param {Object} store The store to which the selectors should be mapped.\n * @return {Object} Selectors mapped to the provided store.\n */\nfunction mapSelectors( selectors, store ) {\n\tconst createStateSelector = ( registrySelector ) => {\n\t\tconst selector = function runSelector() {\n\t\t\t// This function is an optimized implementation of:\n\t\t\t//\n\t\t\t// selector( store.getState(), ...arguments )\n\t\t\t//\n\t\t\t// Where the above would incur an `Array#concat` in its application,\n\t\t\t// the logic here instead efficiently constructs an arguments array via\n\t\t\t// direct assignment.\n\t\t\tconst argsLength = arguments.length;\n\t\t\tconst args = new Array( argsLength + 1 );\n\t\t\targs[ 0 ] = store.__unstableOriginalGetState();\n\t\t\tfor ( let i = 0; i < argsLength; i++ ) {\n\t\t\t\targs[ i + 1 ] = arguments[ i ];\n\t\t\t}\n\n\t\t\treturn registrySelector( ...args );\n\t\t};\n\t\tselector.hasResolver = false;\n\t\treturn selector;\n\t};\n\n\treturn mapValues( selectors, createStateSelector );\n}\n\n/**\n * Maps actions to dispatch from a given store.\n *\n * @param {Object} actions Actions to register.\n * @param {Object} store The redux store to which the actions should be mapped.\n *\n * @return {Object} Actions mapped to the redux store provided.\n */\nfunction mapActions( actions, store ) {\n\tconst createBoundAction =\n\t\t( action ) =>\n\t\t( ...args ) => {\n\t\t\treturn Promise.resolve( store.dispatch( action( ...args ) ) );\n\t\t};\n\n\treturn mapValues( actions, createBoundAction );\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their resolution functions.\n */\nfunction mapResolveSelectors( selectors, store ) {\n\tconst storeSelectors = omit( selectors, [\n\t\t'getIsResolving',\n\t\t'hasStartedResolution',\n\t\t'hasFinishedResolution',\n\t\t'hasResolutionFailed',\n\t\t'isResolving',\n\t\t'getCachedResolvers',\n\t\t'getResolutionState',\n\t\t'getResolutionError',\n\t] );\n\n\treturn mapValues( storeSelectors, ( selector, selectorName ) => {\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 ) => selector.apply( null, args );\n\t\t}\n\n\t\treturn ( ...args ) => {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () =>\n\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args );\n\t\t\t\tconst finalize = ( result ) => {\n\t\t\t\t\tconst hasFailed = selectors.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\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = selectors.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.apply( null, args );\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\t};\n\t} );\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their suspense functions.\n */\nfunction mapSuspendSelectors( selectors, store ) {\n\treturn mapValues( selectors, ( selector, selectorName ) => {\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 ) => {\n\t\t\tconst result = selector.apply( null, args );\n\n\t\t\tif ( selectors.hasFinishedResolution( selectorName, args ) ) {\n\t\t\t\tif ( selectors.hasResolutionFailed( selectorName, args ) ) {\n\t\t\t\t\tthrow selectors.getResolutionError( selectorName, args );\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args )\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 * Returns resolvers with matched selectors for a given namespace.\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 {Object} resolvers Resolvers to register.\n * @param {Object} selectors The current selectors to be modified.\n * @param {Object} store The redux store to which the resolvers should be mapped.\n * @param {Object} resolversCache Resolvers Cache.\n */\nfunction mapResolvers( resolvers, selectors, store, resolversCache ) {\n\t// The `resolver` can be either a function that does the resolution, or, in more advanced\n\t// cases, an object with a `fullfill` method and other optional methods like `isFulfilled`.\n\t// Here we normalize the `resolver` function to an object with `fulfill` method.\n\tconst mappedResolvers = mapValues( resolvers, ( resolver ) => {\n\t\tif ( resolver.fulfill ) {\n\t\t\treturn resolver;\n\t\t}\n\n\t\treturn {\n\t\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\t\tfulfill: resolver, // Add the fulfill method.\n\t\t};\n\t} );\n\n\tconst mapSelector = ( selector, selectorName ) => {\n\t\tconst resolver = resolvers[ selectorName ];\n\t\tif ( ! resolver ) {\n\t\t\tselector.hasResolver = false;\n\t\t\treturn selector;\n\t\t}\n\n\t\tconst selectorResolver = ( ...args ) => {\n\t\t\tasync function fulfillSelector() {\n\t\t\t\tconst state = store.getState();\n\n\t\t\t\tif (\n\t\t\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\t\tresolver.isFulfilled( state, ...args ) )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { metadata } = store.__unstableOriginalGetState();\n\n\t\t\t\tif (\n\t\t\t\t\tmetadataSelectors.hasStartedResolution(\n\t\t\t\t\t\tmetadata,\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\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\t\t\tsetTimeout( async () => {\n\t\t\t\t\tresolversCache.clear( selectorName, args );\n\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t\t\t);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fulfillResolver(\n\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\tmappedResolvers,\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t...args\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\t\tmetadataActions.finishResolution(\n\t\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t\targs\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch ( error ) {\n\t\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\t\tmetadataActions.failResolution(\n\t\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t\targs,\n\t\t\t\t\t\t\t\terror\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfulfillSelector( ...args );\n\t\t\treturn selector( ...args );\n\t\t};\n\t\tselectorResolver.hasResolver = true;\n\t\treturn selectorResolver;\n\t};\n\n\treturn {\n\t\tresolvers: mappedResolvers,\n\t\tselectors: mapValues( selectors, mapSelector ),\n\t};\n}\n\n/**\n * Calls a resolver given arguments\n *\n * @param {Object} store Store reference, for fulfilling via resolvers\n * @param {Object} resolvers Store Resolvers\n * @param {string} selectorName Selector name to fulfill.\n * @param {Array} args Selector Arguments.\n */\nasync function fulfillResolver( store, resolvers, selectorName, ...args ) {\n\tconst resolver = get( resolvers, [ selectorName ] );\n\tif ( ! resolver ) {\n\t\treturn;\n\t}\n\n\tconst action = resolver.fulfill( ...args );\n\tif ( action ) {\n\t\tawait store.dispatch( action );\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/redux-store/index.js"],"names":["createStore","applyMiddleware","flowRight","get","mapValues","omit","combineReducers","EquivalentKeyMap","createReduxRoutineMiddleware","builtinControls","promise","createResolversCacheMiddleware","createThunkMiddleware","metadataReducer","metadataSelectors","metadataActions","trimUndefinedValues","array","result","i","length","undefined","splice","createResolversCache","cache","isRunning","selectorName","args","clear","delete","markAsRunning","set","createReduxStore","key","options","name","instantiate","registry","reducer","thunkArgs","dispatch","Object","assign","action","store","getActions","select","selector","__unstableOriginalGetState","getSelectors","resolveSelect","getResolveSelectors","instantiateReduxStore","resolversCache","resolvers","actions","mapActions","selectors","mapSelectors","state","metadata","isRegistrySelector","root","mapResolvers","resolveSelectors","mapResolveSelectors","suspendSelectors","mapSuspendSelectors","getSuspendSelectors","getState","subscribe","listener","lastState","hasChanged","controls","normalizedControls","control","isRegistryControl","middlewares","enhancers","window","__REDUX_DEVTOOLS_EXTENSION__","push","instanceId","initialState","enhancedReducer","createStateSelector","registrySelector","runSelector","argsLength","arguments","Array","hasResolver","createBoundAction","Promise","resolve","storeSelectors","apply","reject","hasFinished","hasFinishedResolution","finalize","hasFailed","hasResolutionFailed","error","getResolutionError","getResult","unsubscribe","mappedResolvers","resolver","fulfill","mapSelector","selectorResolver","fulfillSelector","isFulfilled","hasStartedResolution","setTimeout","startResolution","fulfillResolver","finishResolution","failResolution"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,eAAtB,QAA6C,OAA7C;AACA,SAASC,SAAT,EAAoBC,GAApB,EAAyBC,SAAzB,EAAoCC,IAApC,QAAgD,QAAhD;AACA,OAAOC,eAAP,MAA4B,wBAA5B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,4BAAP,MAAyC,0BAAzC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,aAAhC;AACA,OAAOC,OAAP,MAAoB,uBAApB;AACA,OAAOC,8BAAP,MAA2C,+BAA3C;AACA,OAAOC,qBAAP,MAAkC,oBAAlC;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,sBAAnC;AACA,OAAO,KAAKC,eAAZ,MAAiC,oBAAjC;AAEA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;AAEA,MAAMC,mBAAmB,GAAKC,KAAF,IAAa;AACxC,QAAMC,MAAM,GAAG,CAAE,GAAGD,KAAL,CAAf;;AACA,OAAM,IAAIE,CAAC,GAAGD,MAAM,CAACE,MAAP,GAAgB,CAA9B,EAAiCD,CAAC,IAAI,CAAtC,EAAyCA,CAAC,EAA1C,EAA+C;AAC9C,QAAKD,MAAM,CAAEC,CAAF,CAAN,KAAgBE,SAArB,EAAiC;AA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Ab;AAFd,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAeO,eAAf,CAAgC1E,KAAhC,EAAuCU,SAAvC,EAAkD5B,YAAlD,EAA0E;AACzE,QAAMmF,QAAQ,GAAG1G,GAAG,CAAEmD,SAAF,EAAa,CAAE5B,YAAF,CAAb,CAApB;;AACA,MAAK,CAAEmF,QAAP,EAAkB;AACjB;AACA;;AAJwE,qCAAPlF,IAAO;AAAPA,IAAAA,IAAO;AAAA;;AAMzE,QAAMgB,MAAM,GAAGkE,QAAQ,CAACC,OAAT,CAAkB,GAAGnF,IAArB,CAAf;;AACA,MAAKgB,MAAL,EAAc;AACb,UAAMC,KAAK,CAACJ,QAAN,CAAgBG,MAAhB,CAAN;AACA;AACD","sourcesContent":["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport { flowRight, get, mapValues, omit } from 'lodash';\nimport combineReducers from 'turbo-combine-reducers';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\n\n/**\n * Internal dependencies\n */\nimport { builtinControls } from '../controls';\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';\n\n/** @typedef {import('../types').DataRegistry} DataRegistry */\n/**\n * @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor\n * @template C\n */\n/**\n * @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State,Actions,Selectors\n */\n\nconst trimUndefinedValues = ( array ) => {\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 * Create a cache to track whether resolvers started running or not.\n *\n * @return {Object} Resolvers Cache.\n */\nfunction createResolversCache() {\n\tconst cache = {};\n\treturn {\n\t\tisRunning( selectorName, args ) {\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, args ) {\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, args ) {\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\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 * @template State,Actions,Selectors\n * @param {string} key Unique namespace identifier.\n * @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.\n */\nexport default function createReduxStore( key, options ) {\n\treturn {\n\t\tname: key,\n\t\tinstantiate: ( registry ) => {\n\t\t\tconst reducer = options.reducer;\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn Object.assign(\n\t\t\t\t\t\t( action ) => store.dispatch( action ),\n\t\t\t\t\t\tgetActions()\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn Object.assign(\n\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t\t\t\tgetSelectors()\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn getResolveSelectors();\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);\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\tlet resolvers;\n\t\t\tconst actions = mapActions(\n\t\t\t\t{\n\t\t\t\t\t...metadataActions,\n\t\t\t\t\t...options.actions,\n\t\t\t\t},\n\t\t\t\tstore\n\t\t\t);\n\n\t\t\tlet selectors = mapSelectors(\n\t\t\t\t{\n\t\t\t\t\t...mapValues(\n\t\t\t\t\t\tmetadataSelectors,\n\t\t\t\t\t\t( selector ) =>\n\t\t\t\t\t\t\t( state, ...args ) =>\n\t\t\t\t\t\t\t\tselector( state.metadata, ...args )\n\t\t\t\t\t),\n\t\t\t\t\t...mapValues( options.selectors, ( selector ) => {\n\t\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn ( state, ...args ) =>\n\t\t\t\t\t\t\tselector( state.root, ...args );\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\tstore\n\t\t\t);\n\t\t\tif ( options.resolvers ) {\n\t\t\t\tconst result = mapResolvers(\n\t\t\t\t\toptions.resolvers,\n\t\t\t\t\tselectors,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache\n\t\t\t\t);\n\t\t\t\tresolvers = result.resolvers;\n\t\t\t\tselectors = result.selectors;\n\t\t\t}\n\n\t\t\tconst resolveSelectors = mapResolveSelectors( selectors, store );\n\t\t\tconst suspendSelectors = mapSuspendSelectors( selectors, store );\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 =\n\t\t\t\tstore &&\n\t\t\t\t( ( listener ) => {\n\t\t\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\t\t\treturn store.subscribe( () => {\n\t\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\t\t\tlastState = state;\n\n\t\t\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\t\t\tlistener();\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\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\n/**\n * Creates a redux store for a namespace.\n *\n * @param {string} key Unique namespace identifier.\n * @param {Object} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param {DataRegistry} registry Registry reference.\n * @param {Object} thunkArgs Argument object for the thunk middleware.\n * @return {Object} Newly created redux store.\n */\nfunction instantiateReduxStore( key, options, registry, thunkArgs ) {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control ) =>\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 = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\twindow.__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\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 },\n\t\tflowRight( enhancers )\n\t);\n}\n\n/**\n * Maps selectors to a store.\n *\n * @param {Object} selectors Selectors to register. Keys will be used as the\n * public facing API. Selectors will get passed the\n * state as first argument.\n * @param {Object} store The store to which the selectors should be mapped.\n * @return {Object} Selectors mapped to the provided store.\n */\nfunction mapSelectors( selectors, store ) {\n\tconst createStateSelector = ( registrySelector ) => {\n\t\tconst selector = function runSelector() {\n\t\t\t// This function is an optimized implementation of:\n\t\t\t//\n\t\t\t// selector( store.getState(), ...arguments )\n\t\t\t//\n\t\t\t// Where the above would incur an `Array#concat` in its application,\n\t\t\t// the logic here instead efficiently constructs an arguments array via\n\t\t\t// direct assignment.\n\t\t\tconst argsLength = arguments.length;\n\t\t\tconst args = new Array( argsLength + 1 );\n\t\t\targs[ 0 ] = store.__unstableOriginalGetState();\n\t\t\tfor ( let i = 0; i < argsLength; i++ ) {\n\t\t\t\targs[ i + 1 ] = arguments[ i ];\n\t\t\t}\n\n\t\t\treturn registrySelector( ...args );\n\t\t};\n\t\tselector.hasResolver = false;\n\t\treturn selector;\n\t};\n\n\treturn mapValues( selectors, createStateSelector );\n}\n\n/**\n * Maps actions to dispatch from a given store.\n *\n * @param {Object} actions Actions to register.\n * @param {Object} store The redux store to which the actions should be mapped.\n *\n * @return {Object} Actions mapped to the redux store provided.\n */\nfunction mapActions( actions, store ) {\n\tconst createBoundAction =\n\t\t( action ) =>\n\t\t( ...args ) => {\n\t\t\treturn Promise.resolve( store.dispatch( action( ...args ) ) );\n\t\t};\n\n\treturn mapValues( actions, createBoundAction );\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their resolution functions.\n */\nfunction mapResolveSelectors( selectors, store ) {\n\tconst storeSelectors = omit( selectors, [\n\t\t'getIsResolving',\n\t\t'hasStartedResolution',\n\t\t'hasFinishedResolution',\n\t\t'hasResolutionFailed',\n\t\t'isResolving',\n\t\t'getCachedResolvers',\n\t\t'getResolutionState',\n\t\t'getResolutionError',\n\t] );\n\n\treturn mapValues( storeSelectors, ( selector, selectorName ) => {\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 ) => selector.apply( null, args );\n\t\t}\n\n\t\treturn ( ...args ) => {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () =>\n\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args );\n\t\t\t\tconst finalize = ( result ) => {\n\t\t\t\t\tconst hasFailed = selectors.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\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = selectors.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.apply( null, args );\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\t};\n\t} );\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their suspense functions.\n */\nfunction mapSuspendSelectors( selectors, store ) {\n\treturn mapValues( selectors, ( selector, selectorName ) => {\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 ) => {\n\t\t\tconst result = selector.apply( null, args );\n\n\t\t\tif ( selectors.hasFinishedResolution( selectorName, args ) ) {\n\t\t\t\tif ( selectors.hasResolutionFailed( selectorName, args ) ) {\n\t\t\t\t\tthrow selectors.getResolutionError( selectorName, args );\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args )\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 * Returns resolvers with matched selectors for a given namespace.\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 {Object} resolvers Resolvers to register.\n * @param {Object} selectors The current selectors to be modified.\n * @param {Object} store The redux store to which the resolvers should be mapped.\n * @param {Object} resolversCache Resolvers Cache.\n */\nfunction mapResolvers( resolvers, selectors, store, resolversCache ) {\n\t// The `resolver` can be either a function that does the resolution, or, in more advanced\n\t// cases, an object with a `fullfill` method and other optional methods like `isFulfilled`.\n\t// Here we normalize the `resolver` function to an object with `fulfill` method.\n\tconst mappedResolvers = mapValues( resolvers, ( resolver ) => {\n\t\tif ( resolver.fulfill ) {\n\t\t\treturn resolver;\n\t\t}\n\n\t\treturn {\n\t\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\t\tfulfill: resolver, // Add the fulfill method.\n\t\t};\n\t} );\n\n\tconst mapSelector = ( selector, selectorName ) => {\n\t\tconst resolver = resolvers[ selectorName ];\n\t\tif ( ! resolver ) {\n\t\t\tselector.hasResolver = false;\n\t\t\treturn selector;\n\t\t}\n\n\t\tconst selectorResolver = ( ...args ) => {\n\t\t\tasync function fulfillSelector() {\n\t\t\t\tconst state = store.getState();\n\n\t\t\t\tif (\n\t\t\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\t\tresolver.isFulfilled( state, ...args ) )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { metadata } = store.__unstableOriginalGetState();\n\n\t\t\t\tif (\n\t\t\t\t\tmetadataSelectors.hasStartedResolution(\n\t\t\t\t\t\tmetadata,\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\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\t\t\tsetTimeout( async () => {\n\t\t\t\t\tresolversCache.clear( selectorName, args );\n\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t\t\t);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait fulfillResolver(\n\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\tmappedResolvers,\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t...args\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\t\tmetadataActions.finishResolution(\n\t\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t\targs\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch ( error ) {\n\t\t\t\t\t\tstore.dispatch(\n\t\t\t\t\t\t\tmetadataActions.failResolution(\n\t\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\t\targs,\n\t\t\t\t\t\t\t\terror\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfulfillSelector( ...args );\n\t\t\treturn selector( ...args );\n\t\t};\n\t\tselectorResolver.hasResolver = true;\n\t\treturn selectorResolver;\n\t};\n\n\treturn {\n\t\tresolvers: mappedResolvers,\n\t\tselectors: mapValues( selectors, mapSelector ),\n\t};\n}\n\n/**\n * Calls a resolver given arguments\n *\n * @param {Object} store Store reference, for fulfilling via resolvers\n * @param {Object} resolvers Store Resolvers\n * @param {string} selectorName Selector name to fulfill.\n * @param {Array} args Selector Arguments.\n */\nasync function fulfillResolver( store, resolvers, selectorName, ...args ) {\n\tconst resolver = get( resolvers, [ selectorName ] );\n\tif ( ! resolver ) {\n\t\treturn;\n\t}\n\n\tconst action = resolver.fulfill( ...args );\n\tif ( action ) {\n\t\tawait store.dispatch( action );\n\t}\n}\n"]}
|
package/build-types/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface StoreDescriptor<Config extends AnyConfig> {
|
|
|
20
20
|
*/
|
|
21
21
|
instantiate: (registry: DataRegistry) => StoreInstance<Config>;
|
|
22
22
|
}
|
|
23
|
-
export interface ReduxStoreConfig<State, ActionCreators extends MapOf<ActionCreator>, Selectors
|
|
23
|
+
export interface ReduxStoreConfig<State, ActionCreators extends MapOf<ActionCreator>, Selectors> {
|
|
24
24
|
initialState?: State;
|
|
25
25
|
reducer: (state: any, action: any) => any;
|
|
26
26
|
actions?: ActionCreators;
|
|
@@ -28,6 +28,23 @@ export interface ReduxStoreConfig<State, ActionCreators extends MapOf<ActionCrea
|
|
|
28
28
|
selectors?: Selectors;
|
|
29
29
|
controls?: MapOf<Function>;
|
|
30
30
|
}
|
|
31
|
+
export declare type UseSelectReturn<F extends MapSelect | StoreDescriptor<any>> = F extends MapSelect ? ReturnType<F> : F extends StoreDescriptor<any> ? CurriedSelectorsOf<F> : never;
|
|
32
|
+
export declare type MapSelect = (select: SelectFunction) => any;
|
|
33
|
+
export declare type SelectFunction = <S>(store: S) => CurriedSelectorsOf<S>;
|
|
34
|
+
export declare type CurriedSelectorsOf<S> = S extends StoreDescriptor<ReduxStoreConfig<any, any, infer Selectors>> ? {
|
|
35
|
+
[key in keyof Selectors]: CurriedState<Selectors[key]>;
|
|
36
|
+
} : never;
|
|
37
|
+
/**
|
|
38
|
+
* Removes the first argument from a function
|
|
39
|
+
*
|
|
40
|
+
* This is designed to remove the `state` parameter from
|
|
41
|
+
* registered selectors since that argument is supplied
|
|
42
|
+
* by the editor when calling `select(…)`.
|
|
43
|
+
*
|
|
44
|
+
* For functions with no arguments, which some selectors
|
|
45
|
+
* are free to define, returns the original function.
|
|
46
|
+
*/
|
|
47
|
+
export declare type CurriedState<F> = F extends (state: any, ...args: infer P) => infer R ? (...args: P) => R : F;
|
|
31
48
|
export interface DataRegistry {
|
|
32
49
|
register: (store: StoreDescriptor<any>) => void;
|
|
33
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,aAAK,KAAK,CAAE,CAAC,IAAK;IAAE,CAAE,IAAI,EAAE,MAAM,GAAI,CAAC,CAA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.0",
|
|
4
4
|
"description": "Data module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.16.0",
|
|
31
|
-
"@wordpress/compose": "^5.
|
|
32
|
-
"@wordpress/deprecated": "^3.
|
|
33
|
-
"@wordpress/element": "^4.
|
|
34
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
35
|
-
"@wordpress/priority-queue": "^2.
|
|
36
|
-
"@wordpress/redux-routine": "^4.
|
|
31
|
+
"@wordpress/compose": "^5.10.0",
|
|
32
|
+
"@wordpress/deprecated": "^3.12.0",
|
|
33
|
+
"@wordpress/element": "^4.10.0",
|
|
34
|
+
"@wordpress/is-shallow-equal": "^4.12.0",
|
|
35
|
+
"@wordpress/priority-queue": "^2.12.0",
|
|
36
|
+
"@wordpress/redux-routine": "^4.12.0",
|
|
37
37
|
"equivalent-key-map": "^0.2.2",
|
|
38
38
|
"is-promise": "^4.0.0",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "a80eeb62ec7cb1418b9915c277e084a29d6665e3"
|
|
51
51
|
}
|
|
@@ -20,7 +20,19 @@ import useAsyncMode from '../async-mode-provider/use-async-mode';
|
|
|
20
20
|
const noop = () => {};
|
|
21
21
|
const renderQueue = createQueue();
|
|
22
22
|
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
|
|
25
|
+
* @template C
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
|
|
29
|
+
* @template State,Actions,Selectors
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
|
|
33
|
+
* @template T
|
|
34
|
+
*/
|
|
35
|
+
/** @typedef {import('../../types').MapSelect} MapSelect */
|
|
24
36
|
|
|
25
37
|
/**
|
|
26
38
|
* Custom react hook for retrieving props from registered selectors.
|
|
@@ -28,20 +40,16 @@ const renderQueue = createQueue();
|
|
|
28
40
|
* In general, this custom React hook follows the
|
|
29
41
|
* [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
|
|
30
42
|
*
|
|
31
|
-
* @
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* element tree.
|
|
42
|
-
* @param {Array} deps If provided, this memoizes the mapSelect so the
|
|
43
|
-
* same `mapSelect` is invoked on every state
|
|
44
|
-
* change unless the dependencies change.
|
|
43
|
+
* @template {MapSelect | StoreDescriptor<any>} T
|
|
44
|
+
* @param {T} mapSelect Function called on every state change. The returned value is
|
|
45
|
+
* exposed to the component implementing this hook. The function
|
|
46
|
+
* receives the `registry.select` method on the first argument
|
|
47
|
+
* and the `registry` on the second argument.
|
|
48
|
+
* When a store key is passed, all selectors for the store will be
|
|
49
|
+
* returned. This is only meant for usage of these selectors in event
|
|
50
|
+
* callbacks, not for data needed to create the element tree.
|
|
51
|
+
* @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is
|
|
52
|
+
* invoked on every state change unless the dependencies change.
|
|
45
53
|
*
|
|
46
54
|
* @example
|
|
47
55
|
* ```js
|
|
@@ -86,8 +94,7 @@ const renderQueue = createQueue();
|
|
|
86
94
|
* return <div onPaste={ onPaste }>{ children }</div>;
|
|
87
95
|
* }
|
|
88
96
|
* ```
|
|
89
|
-
*
|
|
90
|
-
* @return {Function} A custom react hook.
|
|
97
|
+
* @return {UseSelectReturn<T>} A custom react hook.
|
|
91
98
|
*/
|
|
92
99
|
export default function useSelect( mapSelect, deps ) {
|
|
93
100
|
const hasMappingFunction = 'function' === typeof mapSelect;
|
package/src/redux-store/index.js
CHANGED
|
@@ -23,8 +23,14 @@ import * as metadataSelectors from './metadata/selectors';
|
|
|
23
23
|
import * as metadataActions from './metadata/actions';
|
|
24
24
|
|
|
25
25
|
/** @typedef {import('../types').DataRegistry} DataRegistry */
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor
|
|
28
|
+
* @template C
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
|
|
32
|
+
* @template State,Actions,Selectors
|
|
33
|
+
*/
|
|
28
34
|
|
|
29
35
|
const trimUndefinedValues = ( array ) => {
|
|
30
36
|
const result = [ ...array ];
|
|
@@ -83,12 +89,13 @@ function createResolversCache() {
|
|
|
83
89
|
* } );
|
|
84
90
|
* ```
|
|
85
91
|
*
|
|
86
|
-
* @
|
|
87
|
-
* @param {
|
|
88
|
-
*
|
|
89
|
-
*
|
|
92
|
+
* @template State,Actions,Selectors
|
|
93
|
+
* @param {string} key Unique namespace identifier.
|
|
94
|
+
* @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties
|
|
95
|
+
* describing reducer, actions, selectors,
|
|
96
|
+
* and resolvers.
|
|
90
97
|
*
|
|
91
|
-
* @return
|
|
98
|
+
* @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.
|
|
92
99
|
*/
|
|
93
100
|
export default function createReduxStore( key, options ) {
|
|
94
101
|
return {
|
package/src/test/registry.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { castArray, mapValues } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
@@ -30,7 +25,7 @@ describe( 'createRegistry', () => {
|
|
|
30
25
|
return unsubscribe;
|
|
31
26
|
}
|
|
32
27
|
function subscribeUntil( predicates ) {
|
|
33
|
-
predicates =
|
|
28
|
+
predicates = Array.from( predicates );
|
|
34
29
|
|
|
35
30
|
return new Promise( ( resolve ) => {
|
|
36
31
|
subscribeWithUnsubscribe( () => {
|
|
@@ -749,16 +744,18 @@ describe( 'createRegistry', () => {
|
|
|
749
744
|
// representation of the object, the latter applying its
|
|
750
745
|
// function proxying.
|
|
751
746
|
expect( _registry ).toMatchObject(
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
747
|
+
Object.fromEntries(
|
|
748
|
+
Object.entries( registry ).map( ( [ key ] ) => {
|
|
749
|
+
if ( key === 'stores' ) {
|
|
750
|
+
return [ key, expect.any( Object ) ];
|
|
751
|
+
}
|
|
752
|
+
// TODO: Remove this after namsespaces is removed.
|
|
753
|
+
if ( key === 'namespaces' ) {
|
|
754
|
+
return [ key, registry.stores ];
|
|
755
|
+
}
|
|
756
|
+
return [ key, expect.any( Function ) ];
|
|
757
|
+
} )
|
|
758
|
+
)
|
|
762
759
|
);
|
|
763
760
|
|
|
764
761
|
actualOptions = options;
|
package/src/types.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface StoreDescriptor< Config extends AnyConfig > {
|
|
|
27
27
|
export interface ReduxStoreConfig<
|
|
28
28
|
State,
|
|
29
29
|
ActionCreators extends MapOf< ActionCreator >,
|
|
30
|
-
Selectors
|
|
30
|
+
Selectors
|
|
31
31
|
> {
|
|
32
32
|
initialState?: State;
|
|
33
33
|
reducer: ( state: any, action: any ) => any;
|
|
@@ -37,6 +37,40 @@ export interface ReduxStoreConfig<
|
|
|
37
37
|
controls?: MapOf< Function >;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export type UseSelectReturn< F extends MapSelect | StoreDescriptor< any > > =
|
|
41
|
+
F extends MapSelect
|
|
42
|
+
? ReturnType< F >
|
|
43
|
+
: F extends StoreDescriptor< any >
|
|
44
|
+
? CurriedSelectorsOf< F >
|
|
45
|
+
: never;
|
|
46
|
+
|
|
47
|
+
export type MapSelect = ( select: SelectFunction ) => any;
|
|
48
|
+
|
|
49
|
+
export type SelectFunction = < S >( store: S ) => CurriedSelectorsOf< S >;
|
|
50
|
+
|
|
51
|
+
export type CurriedSelectorsOf< S > = S extends StoreDescriptor<
|
|
52
|
+
ReduxStoreConfig< any, any, infer Selectors >
|
|
53
|
+
>
|
|
54
|
+
? { [ key in keyof Selectors ]: CurriedState< Selectors[ key ] > }
|
|
55
|
+
: never;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Removes the first argument from a function
|
|
59
|
+
*
|
|
60
|
+
* This is designed to remove the `state` parameter from
|
|
61
|
+
* registered selectors since that argument is supplied
|
|
62
|
+
* by the editor when calling `select(…)`.
|
|
63
|
+
*
|
|
64
|
+
* For functions with no arguments, which some selectors
|
|
65
|
+
* are free to define, returns the original function.
|
|
66
|
+
*/
|
|
67
|
+
export type CurriedState< F > = F extends (
|
|
68
|
+
state: any,
|
|
69
|
+
...args: infer P
|
|
70
|
+
) => infer R
|
|
71
|
+
? ( ...args: P ) => R
|
|
72
|
+
: F;
|
|
73
|
+
|
|
40
74
|
export interface DataRegistry {
|
|
41
75
|
register: ( store: StoreDescriptor< any > ) => void;
|
|
42
76
|
}
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","./src/redux-store/metadata/actions.js","./src/redux-store/metadata/equivalent-key-map.d.ts","../../node_modules/@types/lodash/common/common.d.ts","../../node_modules/@types/lodash/common/array.d.ts","../../node_modules/@types/lodash/common/collection.d.ts","../../node_modules/@types/lodash/common/date.d.ts","../../node_modules/@types/lodash/common/function.d.ts","../../node_modules/@types/lodash/common/lang.d.ts","../../node_modules/@types/lodash/common/math.d.ts","../../node_modules/@types/lodash/common/number.d.ts","../../node_modules/@types/lodash/common/object.d.ts","../../node_modules/@types/lodash/common/seq.d.ts","../../node_modules/@types/lodash/common/string.d.ts","../../node_modules/@types/lodash/common/util.d.ts","../../node_modules/@types/lodash/index.d.ts","../../node_modules/redux/index.d.ts","./src/redux-store/metadata/utils.ts","./src/redux-store/metadata/reducer.ts","./src/redux-store/metadata/selectors.js","../../node_modules/is-promise/index.d.ts","./src/promise-middleware.js","./src/types.ts","./src/utils/emitter.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"c67951274199df6c887191adafac1c605901c3f6ce123351225e2e93c4282de4","8eed414bd2305e20163d35205b450204002bf20e14c7241d7fec46bb18f174d2","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","438284c7c455a29b9c0e2d1e72abc62ee93d9a163029ffe918a34c5db3b92da2","0c75b204aed9cf6ff1c7b4bed87a3ece0d9d6fc857a6350c0c95ed0c38c814e8","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","82251920b05f30981c9a4109cb5f3169dce4b477effc845c6d781044a30e7672","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","9fa6b83a35e897f340858995ca5d77e901d89fd18644cd4c9e8a4afe0b2e6363",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},{"version":"8f19251323456195ec9236df857bac3b8f97b73b540ef06ead2ceccc3884954f","affectsGlobalScope":true},"318affc58742934c99481fcb8043bba8b5a5caaf07f5971c34d00b5dc154da66","c79043d0c35ecd15afb17e476816872357df76446071c6b754828dea6e910ab7","ffb454554054fdfa52dbe72f6a0f5320cfeff52452f4e8deddcfc3f5bba80f82","5ac6404ddc5d622905e131dbc5da0362a82e89d1cb97cc8256bf06ca9fad4b24","9fcfbc2dd0c0614b3a25d41e4425dd86cdfa574a9e7d2febffc85badcee1a0b8","5b3fd806ef40b87048042c7039f1f7520fb378886dc8a565d5428a6085e8d1ae","412e9398be155d644b609b06bb2d0b6f99d86bf3d7db81b27a357ad8df07e0c0"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":false,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[47,49,50,51,52,53,54,55,56,57,58,59],[47,48,50,51,52,53,54,55,56,57,58,59],[48,49,50,51,52,53,54,55,56,57,58,59],[47,48,49,51,52,53,54,55,56,57,58,59],[47,48,49,50,52,53,54,55,56,57,58,59],[47,48,49,50,51,53,54,55,56,57,58,59],[47,48,49,50,51,52,54,55,56,57,58,59],[47,48,49,50,51,52,53,55,56,57,58,59],[47,48,49,50,51,52,53,54,56,57,58,59],[47,48,49,50,51,52,53,54,55,57,58,59],[47,48,49,50,51,52,53,54,55,56,58,59],[47,48,49,50,51,52,53,54,55,56,57,59],[47,48,49,50,51,52,53,54,55,56,57,58],[60,64],[45,46,59,60,61],[59,61,62],[60],[66]],"referencedMap":[[48,1],[49,2],[47,3],[50,4],[51,5],[52,6],[53,7],[54,8],[55,9],[56,10],[57,11],[58,12],[59,13],[65,14],[62,15],[63,16],[61,17],[67,18]],"exportedModulesMap":[[48,1],[49,2],[47,3],[50,4],[51,5],[52,6],[53,7],[54,8],[55,9],[56,10],[57,11],[58,12],[59,13],[65,14],[62,15],[63,16],[61,17],[67,18]],"semanticDiagnosticsPerFile":[48,49,47,50,51,52,53,54,55,56,57,58,59,64,60,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,65,45,46,62,63,61,66,67]},"version":"4.4.2"}
|
|
1
|
+
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","./src/redux-store/metadata/actions.js","./src/redux-store/metadata/equivalent-key-map.d.ts","../../node_modules/@types/lodash/common/common.d.ts","../../node_modules/@types/lodash/common/array.d.ts","../../node_modules/@types/lodash/common/collection.d.ts","../../node_modules/@types/lodash/common/date.d.ts","../../node_modules/@types/lodash/common/function.d.ts","../../node_modules/@types/lodash/common/lang.d.ts","../../node_modules/@types/lodash/common/math.d.ts","../../node_modules/@types/lodash/common/number.d.ts","../../node_modules/@types/lodash/common/object.d.ts","../../node_modules/@types/lodash/common/seq.d.ts","../../node_modules/@types/lodash/common/string.d.ts","../../node_modules/@types/lodash/common/util.d.ts","../../node_modules/@types/lodash/index.d.ts","../../node_modules/redux/index.d.ts","./src/redux-store/metadata/utils.ts","./src/redux-store/metadata/reducer.ts","./src/redux-store/metadata/selectors.js","../../node_modules/is-promise/index.d.ts","./src/promise-middleware.js","./src/types.ts","./src/utils/emitter.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"c67951274199df6c887191adafac1c605901c3f6ce123351225e2e93c4282de4","8eed414bd2305e20163d35205b450204002bf20e14c7241d7fec46bb18f174d2","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","438284c7c455a29b9c0e2d1e72abc62ee93d9a163029ffe918a34c5db3b92da2","0c75b204aed9cf6ff1c7b4bed87a3ece0d9d6fc857a6350c0c95ed0c38c814e8","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","82251920b05f30981c9a4109cb5f3169dce4b477effc845c6d781044a30e7672","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","9fa6b83a35e897f340858995ca5d77e901d89fd18644cd4c9e8a4afe0b2e6363",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},{"version":"8f19251323456195ec9236df857bac3b8f97b73b540ef06ead2ceccc3884954f","affectsGlobalScope":true},"318affc58742934c99481fcb8043bba8b5a5caaf07f5971c34d00b5dc154da66","c79043d0c35ecd15afb17e476816872357df76446071c6b754828dea6e910ab7","ffb454554054fdfa52dbe72f6a0f5320cfeff52452f4e8deddcfc3f5bba80f82","5ac6404ddc5d622905e131dbc5da0362a82e89d1cb97cc8256bf06ca9fad4b24","9fcfbc2dd0c0614b3a25d41e4425dd86cdfa574a9e7d2febffc85badcee1a0b8","f7370e01b0727e06d4e1e43ef4614daa21165f9bd7ad52c0f88bbe7378a6afff","412e9398be155d644b609b06bb2d0b6f99d86bf3d7db81b27a357ad8df07e0c0"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":false,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[47,49,50,51,52,53,54,55,56,57,58,59],[47,48,50,51,52,53,54,55,56,57,58,59],[48,49,50,51,52,53,54,55,56,57,58,59],[47,48,49,51,52,53,54,55,56,57,58,59],[47,48,49,50,52,53,54,55,56,57,58,59],[47,48,49,50,51,53,54,55,56,57,58,59],[47,48,49,50,51,52,54,55,56,57,58,59],[47,48,49,50,51,52,53,55,56,57,58,59],[47,48,49,50,51,52,53,54,56,57,58,59],[47,48,49,50,51,52,53,54,55,57,58,59],[47,48,49,50,51,52,53,54,55,56,58,59],[47,48,49,50,51,52,53,54,55,56,57,59],[47,48,49,50,51,52,53,54,55,56,57,58],[60,64],[45,46,59,60,61],[59,61,62],[60],[66]],"referencedMap":[[48,1],[49,2],[47,3],[50,4],[51,5],[52,6],[53,7],[54,8],[55,9],[56,10],[57,11],[58,12],[59,13],[65,14],[62,15],[63,16],[61,17],[67,18]],"exportedModulesMap":[[48,1],[49,2],[47,3],[50,4],[51,5],[52,6],[53,7],[54,8],[55,9],[56,10],[57,11],[58,12],[59,13],[65,14],[62,15],[63,16],[61,17],[67,18]],"semanticDiagnosticsPerFile":[48,49,47,50,51,52,53,54,55,56,57,58,59,64,60,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,65,45,46,62,63,61,66,67]},"version":"4.4.2"}
|