@wordpress/data 10.36.1-next.8b30e05b0.0 → 10.36.1-next.8fd3f8831.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/README.md +2 -2
- package/build/components/async-mode-provider/{context.js → context.cjs} +1 -1
- package/build/components/async-mode-provider/{index.js → index.cjs} +3 -3
- package/build/components/async-mode-provider/{use-async-mode.js → use-async-mode.cjs} +2 -2
- package/build/components/registry-provider/{context.js → context.cjs} +2 -2
- package/build/components/registry-provider/{index.js → index.cjs} +3 -3
- package/build/components/registry-provider/{use-registry.js → use-registry.cjs} +2 -2
- package/build/components/registry-provider/{use-registry.js.map → use-registry.cjs.map} +1 -1
- package/build/components/use-dispatch/{index.js → index.cjs} +3 -3
- package/build/components/use-dispatch/{use-dispatch-with-map.js → use-dispatch-with-map.cjs} +2 -2
- package/build/components/use-dispatch/{use-dispatch.js → use-dispatch.cjs} +2 -2
- package/build/components/use-select/{index.js → index.cjs} +6 -6
- package/build/components/use-select/index.cjs.map +7 -0
- package/build/components/with-dispatch/{index.js → index.cjs} +2 -2
- package/build/components/with-registry/{index.js → index.cjs} +2 -2
- package/build/components/with-select/{index.js → index.cjs} +2 -2
- package/build/{controls.js → controls.cjs} +2 -2
- package/build/{create-selector.js → create-selector.cjs} +2 -2
- package/build/{default-registry.js → default-registry.cjs} +2 -2
- package/build/{dispatch.js → dispatch.cjs} +2 -2
- package/build/{factory.js → factory.cjs} +1 -1
- package/build/{index.js → index.cjs} +22 -23
- package/build/index.cjs.map +7 -0
- package/build/{lock-unlock.js → lock-unlock.cjs} +1 -1
- package/build/plugins/{index.js → index.cjs} +2 -2
- package/build/plugins/persistence/{index.js → index.cjs} +4 -4
- package/build/plugins/persistence/storage/{default.js → default.cjs} +2 -2
- package/build/plugins/persistence/storage/{object.js → object.cjs} +1 -1
- package/build/{promise-middleware.js → promise-middleware.cjs} +2 -2
- package/build/redux-store/{combine-reducers.js → combine-reducers.cjs} +1 -1
- package/build/redux-store/{index.js → index.cjs} +19 -20
- package/build/redux-store/{index.js.map → index.cjs.map} +2 -2
- package/build/redux-store/metadata/{actions.js → actions.cjs} +1 -1
- package/build/redux-store/metadata/equivalent-key-map.d.cjs +2 -0
- package/build/redux-store/metadata/{reducer.js → reducer.cjs} +3 -3
- package/build/redux-store/metadata/{selectors.js → selectors.cjs} +4 -4
- package/build/redux-store/metadata/{utils.js → utils.cjs} +1 -1
- package/build/redux-store/{thunk-middleware.js → thunk-middleware.cjs} +1 -1
- package/build/{registry.js → registry.cjs} +6 -6
- package/build/{resolvers-cache-middleware.js → resolvers-cache-middleware.cjs} +1 -1
- package/build/{select.js → select.cjs} +2 -2
- package/build/store/{index.js → index.cjs} +1 -1
- package/build/{types.js → types.cjs} +1 -1
- package/build/types.cjs.map +7 -0
- package/build/utils/{emitter.js → emitter.cjs} +1 -1
- package/build-module/components/async-mode-provider/index.js +2 -2
- package/build-module/components/async-mode-provider/use-async-mode.js +1 -1
- package/build-module/components/registry-provider/context.js +1 -1
- package/build-module/components/registry-provider/index.js +2 -2
- package/build-module/components/registry-provider/use-registry.js +1 -1
- package/build-module/components/registry-provider/use-registry.js.map +1 -1
- package/build-module/components/use-dispatch/index.js +2 -2
- package/build-module/components/use-dispatch/use-dispatch-with-map.js +1 -1
- package/build-module/components/use-dispatch/use-dispatch.js +1 -1
- package/build-module/components/use-select/index.js +3 -3
- package/build-module/components/use-select/index.js.map +2 -2
- package/build-module/components/with-dispatch/index.js +1 -1
- package/build-module/components/with-registry/index.js +1 -1
- package/build-module/components/with-select/index.js +1 -1
- package/build-module/controls.js +1 -1
- package/build-module/default-registry.js +1 -1
- package/build-module/dispatch.js +1 -1
- package/build-module/index.js +20 -19
- package/build-module/index.js.map +2 -2
- package/build-module/plugins/index.js +1 -1
- package/build-module/plugins/persistence/index.js +2 -2
- package/build-module/plugins/persistence/storage/default.js +1 -1
- package/build-module/redux-store/index.js +16 -17
- package/build-module/redux-store/index.js.map +2 -2
- package/build-module/redux-store/metadata/reducer.js +1 -1
- package/build-module/redux-store/metadata/selectors.js +2 -2
- package/build-module/registry.js +4 -4
- package/build-module/select.js +1 -1
- package/build-types/components/registry-provider/use-registry.d.ts +2 -2
- package/build-types/components/registry-provider/use-registry.d.ts.map +1 -1
- package/build-types/index.d.ts +4 -4
- package/build-types/index.d.ts.map +1 -1
- package/build-types/types.d.ts +22 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +19 -11
- package/src/components/registry-provider/use-registry.js +1 -1
- package/src/components/use-select/index.js +1 -1
- package/src/index.ts +9 -7
- package/src/redux-store/index.js +8 -12
- package/src/redux-store/test/index.js +137 -0
- package/src/types.ts +39 -0
- package/build/components/use-select/index.js.map +0 -7
- package/build/index.js.map +0 -7
- package/build/redux-store/metadata/equivalent-key-map.d.js +0 -2
- package/build/types.js.map +0 -7
- package/tsconfig.json +0 -16
- package/tsconfig.tsbuildinfo +0 -1
- /package/build/components/async-mode-provider/{context.js.map → context.cjs.map} +0 -0
- /package/build/components/async-mode-provider/{index.js.map → index.cjs.map} +0 -0
- /package/build/components/async-mode-provider/{use-async-mode.js.map → use-async-mode.cjs.map} +0 -0
- /package/build/components/registry-provider/{context.js.map → context.cjs.map} +0 -0
- /package/build/components/registry-provider/{index.js.map → index.cjs.map} +0 -0
- /package/build/components/use-dispatch/{index.js.map → index.cjs.map} +0 -0
- /package/build/components/use-dispatch/{use-dispatch-with-map.js.map → use-dispatch-with-map.cjs.map} +0 -0
- /package/build/components/use-dispatch/{use-dispatch.js.map → use-dispatch.cjs.map} +0 -0
- /package/build/components/with-dispatch/{index.js.map → index.cjs.map} +0 -0
- /package/build/components/with-registry/{index.js.map → index.cjs.map} +0 -0
- /package/build/components/with-select/{index.js.map → index.cjs.map} +0 -0
- /package/build/{controls.js.map → controls.cjs.map} +0 -0
- /package/build/{create-selector.js.map → create-selector.cjs.map} +0 -0
- /package/build/{default-registry.js.map → default-registry.cjs.map} +0 -0
- /package/build/{dispatch.js.map → dispatch.cjs.map} +0 -0
- /package/build/{factory.js.map → factory.cjs.map} +0 -0
- /package/build/{lock-unlock.js.map → lock-unlock.cjs.map} +0 -0
- /package/build/plugins/{index.js.map → index.cjs.map} +0 -0
- /package/build/plugins/persistence/{index.js.map → index.cjs.map} +0 -0
- /package/build/plugins/persistence/storage/{default.js.map → default.cjs.map} +0 -0
- /package/build/plugins/persistence/storage/{object.js.map → object.cjs.map} +0 -0
- /package/build/{promise-middleware.js.map → promise-middleware.cjs.map} +0 -0
- /package/build/redux-store/{combine-reducers.js.map → combine-reducers.cjs.map} +0 -0
- /package/build/redux-store/metadata/{actions.js.map → actions.cjs.map} +0 -0
- /package/build/redux-store/metadata/{equivalent-key-map.d.js.map → equivalent-key-map.d.cjs.map} +0 -0
- /package/build/redux-store/metadata/{reducer.js.map → reducer.cjs.map} +0 -0
- /package/build/redux-store/metadata/{selectors.js.map → selectors.cjs.map} +0 -0
- /package/build/redux-store/metadata/{utils.js.map → utils.cjs.map} +0 -0
- /package/build/redux-store/{thunk-middleware.js.map → thunk-middleware.cjs.map} +0 -0
- /package/build/{registry.js.map → registry.cjs.map} +0 -0
- /package/build/{resolvers-cache-middleware.js.map → resolvers-cache-middleware.cjs.map} +0 -0
- /package/build/{select.js.map → select.cjs.map} +0 -0
- /package/build/store/{index.js.map → index.cjs.map} +0 -0
- /package/build/utils/{emitter.js.map → emitter.cjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/redux-store/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { combineReducers } from './combine-reducers';\nimport { builtinControls } from '../controls';\nimport { lock } from '../lock-unlock';\nimport promise from '../promise-middleware';\nimport createResolversCacheMiddleware from '../resolvers-cache-middleware';\nimport createThunkMiddleware from './thunk-middleware';\nimport metadataReducer from './metadata/reducer';\nimport * as metadataSelectors from './metadata/selectors';\nimport * as metadataActions from './metadata/actions';\n\nexport { combineReducers };\n\n/** @typedef {import('../types').DataRegistry} DataRegistry */\n/** @typedef {import('../types').ListenerFunction} ListenerFunction */\n/**\n * @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../types').AnyConfig} C\n */\n/**\n * @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../types').ActionCreator>} Actions\n * @template 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 * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param {Object} obj The object to transform.\n * @param {Function} callback The function to transform each object value.\n * @return {Array} Transformed object.\n */\nconst mapValues = ( obj, callback ) =>\n\tObject.fromEntries(\n\t\tObject.entries( obj ?? {} ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tcallback( value, key ),\n\t\t] )\n\t);\n\n// Convert non serializable types to plain objects\nconst devToolsReplacer = ( key, state ) => {\n\tif ( state instanceof Map ) {\n\t\treturn Object.fromEntries( state );\n\t}\n\n\tif ( state instanceof window.HTMLElement ) {\n\t\treturn null;\n\t}\n\n\treturn state;\n};\n\n/**\n * Create a cache to track whether resolvers started running or not.\n *\n * @return {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\nfunction createBindingCache( getItem, bindItem ) {\n\tconst cache = new WeakMap();\n\n\treturn {\n\t\tget( itemName ) {\n\t\t\tconst item = getItem( itemName );\n\t\t\tif ( ! item ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet boundItem = cache.get( item );\n\t\t\tif ( ! boundItem ) {\n\t\t\t\tboundItem = bindItem( item, itemName );\n\t\t\t\tcache.set( item, boundItem );\n\t\t\t}\n\t\t\treturn boundItem;\n\t\t},\n\t};\n}\n\nfunction createPrivateProxy( publicItems, privateItems ) {\n\treturn new Proxy( publicItems, {\n\t\tget: ( target, itemName ) =>\n\t\t\tprivateItems.get( itemName ) || Reflect.get( target, itemName ),\n\t} );\n}\n\n/**\n * Creates a data store descriptor for the provided Redux store configuration containing\n * properties describing reducer, actions, selectors, controls and resolvers.\n *\n * @example\n * ```js\n * import { createReduxStore } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * ```\n *\n * @template State\n * @template {Record<string,import('../types').ActionCreator>} Actions\n * @template 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\tconst privateActions = {};\n\tconst privateSelectors = {};\n\tconst privateRegistrationFunctions = {\n\t\tprivateActions,\n\t\tregisterPrivateActions: ( actions ) => {\n\t\t\tObject.assign( privateActions, actions );\n\t\t},\n\t\tprivateSelectors,\n\t\tregisterPrivateSelectors: ( selectors ) => {\n\t\t\tObject.assign( privateSelectors, selectors );\n\t\t},\n\t};\n\tconst storeDescriptor = {\n\t\tname: key,\n\t\tinstantiate: ( registry ) => {\n\t\t\t/**\n\t\t\t * Stores listener functions registered with `subscribe()`.\n\t\t\t *\n\t\t\t * When functions register to listen to store changes with\n\t\t\t * `subscribe()` they get added here. Although Redux offers\n\t\t\t * its own `subscribe()` function directly, by wrapping the\n\t\t\t * subscription in this store instance it's possible to\n\t\t\t * optimize checking if the state has changed before calling\n\t\t\t * each listener.\n\t\t\t *\n\t\t\t * @type {Set<ListenerFunction>}\n\t\t\t */\n\t\t\tconst listeners = new Set();\n\t\t\tconst reducer = options.reducer;\n\n\t\t\t// Object that every thunk function receives as the first argument. It contains the\n\t\t\t// `registry`, `dispatch`, `select` and `resolveSelect` fields. Some of them are\n\t\t\t// constructed as getters to avoid circular dependencies.\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn thunkDispatch;\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn thunkSelect;\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn resolveSelectors;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst store = instantiateReduxStore(\n\t\t\t\tkey,\n\t\t\t\toptions,\n\t\t\t\tregistry,\n\t\t\t\tthunkArgs\n\t\t\t);\n\n\t\t\t// Expose the private registration functions on the store\n\t\t\t// so they can be copied to a sub registry in registry.js.\n\t\t\tlock( store, privateRegistrationFunctions );\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\t// Binds an action creator (`action`) to the `store`, making it a callable function.\n\t\t\t// These are the functions that are returned by `useDispatch`, for example.\n\t\t\t// It always returns a `Promise`, although actions are not always async. That's an\n\t\t\t// unfortunate backward compatibility measure.\n\t\t\tfunction bindAction( action ) {\n\t\t\t\treturn ( ...args ) =>\n\t\t\t\t\tPromise.resolve( store.dispatch( action( ...args ) ) );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Object with all public actions, both metadata and store actions.\n\t\t\t */\n\t\t\tconst actions = {\n\t\t\t\t...mapValues( metadataActions, bindAction ),\n\t\t\t\t...mapValues( options.actions, bindAction ),\n\t\t\t};\n\n\t\t\t// Object with both public and private actions. Private actions are accessed through a proxy,\n\t\t\t// which looks them up in real time on the `privateActions` object. That's because private\n\t\t\t// actions can be registered at any time with `registerPrivateActions`. Also once a private\n\t\t\t// action creator is bound to the store, it is cached to give it a stable identity.\n\t\t\tconst allActions = createPrivateProxy(\n\t\t\t\tactions,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => privateActions[ name ],\n\t\t\t\t\tbindAction\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// An object that implements the `dispatch` object that is passed to thunk functions.\n\t\t\t// It is callable (`dispatch( action )`) and also has methods (`dispatch.foo()`) that\n\t\t\t// correspond to bound registered actions, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allActions`.\n\t\t\tconst thunkDispatch = new Proxy(\n\t\t\t\t( action ) => store.dispatch( action ),\n\t\t\t\t{ get: ( target, name ) => allActions[ name ] }\n\t\t\t);\n\n\t\t\t// To the public `actions` object, add the \"locked\" `allActions` object. When used,\n\t\t\t// `unlock( actions )` will return `allActions`, implementing a way how to get at the private actions.\n\t\t\tlock( actions, allActions );\n\n\t\t\t// If we have selector resolvers, convert them to a normalized form.\n\t\t\tconst resolvers = options.resolvers\n\t\t\t\t? mapValues( options.resolvers, mapResolver )\n\t\t\t\t: {};\n\n\t\t\t// Bind a selector to the store. Call the selector with the current state, correct registry,\n\t\t\t// and if there is a resolver, attach the resolver logic to the selector.\n\t\t\tfunction bindSelector( selector, selectorName ) {\n\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\tselector.registry = registry;\n\t\t\t\t}\n\t\t\t\tconst boundSelector = ( ...args ) => {\n\t\t\t\t\targs = normalize( selector, args );\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t// Before calling the selector, switch to the correct registry.\n\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t}\n\t\t\t\t\treturn selector( state.root, ...args );\n\t\t\t\t};\n\n\t\t\t\t// Expose normalization method on the bound selector\n\t\t\t\t// in order that it can be called when fulfilling\n\t\t\t\t// the resolver.\n\t\t\t\tboundSelector.__unstableNormalizeArgs =\n\t\t\t\t\tselector.__unstableNormalizeArgs;\n\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\n\t\t\t\tif ( ! resolver ) {\n\t\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\t\treturn boundSelector;\n\t\t\t\t}\n\n\t\t\t\treturn mapSelectorWithResolver(\n\t\t\t\t\tboundSelector,\n\t\t\t\t\tselectorName,\n\t\t\t\t\tresolver,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache,\n\t\t\t\t\tboundMetadataSelectors\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Metadata selectors are bound differently: different state (`state.metadata`), no resolvers,\n\t\t\t// normalization depending on the target selector.\n\t\t\tfunction bindMetadataSelector( metaDataSelector ) {\n\t\t\t\tconst boundSelector = (\n\t\t\t\t\tselectorName,\n\t\t\t\t\tselectorArgs,\n\t\t\t\t\t...args\n\t\t\t\t) => {\n\t\t\t\t\t// Normalize the arguments passed to the target selector.\n\t\t\t\t\tif ( selectorName ) {\n\t\t\t\t\t\tconst targetSelector =\n\t\t\t\t\t\t\toptions.selectors?.[ selectorName ];\n\t\t\t\t\t\tif ( targetSelector ) {\n\t\t\t\t\t\t\tselectorArgs = normalize(\n\t\t\t\t\t\t\t\ttargetSelector,\n\t\t\t\t\t\t\t\tselectorArgs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\n\t\t\t\t\treturn metaDataSelector(\n\t\t\t\t\t\tstate.metadata,\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tselectorArgs,\n\t\t\t\t\t\t...args\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\treturn boundSelector;\n\t\t\t}\n\n\t\t\t// Perform binding of both metadata and store selectors and combine them in one\n\t\t\t// `selectors` object. These are all public selectors of the store.\n\t\t\tconst boundMetadataSelectors = mapValues(\n\t\t\t\tmetadataSelectors,\n\t\t\t\tbindMetadataSelector\n\t\t\t);\n\n\t\t\tconst boundSelectors = mapValues( options.selectors, bindSelector );\n\n\t\t\tconst selectors = {\n\t\t\t\t...boundMetadataSelectors,\n\t\t\t\t...boundSelectors,\n\t\t\t};\n\n\t\t\t// Cache of bould private selectors. They are bound only when first accessed, because\n\t\t\t// new private selectors can be registered at any time (with `registerPrivateSelectors`).\n\t\t\t// Once bound, they are cached to give them a stable identity.\n\t\t\tconst boundPrivateSelectors = createBindingCache(\n\t\t\t\t( name ) => privateSelectors[ name ],\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst allSelectors = createPrivateProxy(\n\t\t\t\tselectors,\n\t\t\t\tboundPrivateSelectors\n\t\t\t);\n\n\t\t\t// Pre-bind the private selectors that have been registered by the time of\n\t\t\t// instantiation, so that registry selectors are bound to the registry.\n\t\t\tfor ( const selectorName of Object.keys( privateSelectors ) ) {\n\t\t\t\tboundPrivateSelectors.get( selectorName );\n\t\t\t}\n\n\t\t\t// An object that implements the `select` object that is passed to thunk functions.\n\t\t\t// It is callable (`select( selector )`) and also has methods (`select.foo()`) that\n\t\t\t// correspond to bound registered selectors, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allSelectors`.\n\t\t\tconst thunkSelect = new Proxy(\n\t\t\t\t( selector ) => selector( store.__unstableOriginalGetState() ),\n\t\t\t\t{ get: ( target, name ) => allSelectors[ name ] }\n\t\t\t);\n\n\t\t\t// To the public `selectors` object, add the \"locked\" `allSelectors` object. When used,\n\t\t\t// `unlock( selectors )` will return `allSelectors`, implementing a way how to get at the private selectors.\n\t\t\tlock( selectors, allSelectors );\n\n\t\t\t// For each selector, create a function that calls the selector, waits for resolution and returns\n\t\t\t// a promise that resolves when the resolution is finished.\n\t\t\tconst bindResolveSelector = mapResolveSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\t// Now apply this function to all bound selectors, public and private. We are excluding\n\t\t\t// metadata selectors because they don't have resolvers.\n\t\t\tconst resolveSelectors = mapValues(\n\t\t\t\tboundSelectors,\n\t\t\t\tbindResolveSelector\n\t\t\t);\n\n\t\t\tconst allResolveSelectors = createPrivateProxy(\n\t\t\t\tresolveSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => boundPrivateSelectors.get( name ),\n\t\t\t\t\tbindResolveSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( resolveSelectors )` returns `allResolveSelectors`.\n\t\t\tlock( resolveSelectors, allResolveSelectors );\n\n\t\t\t// Now, in a way very similar to `bindResolveSelector`, we create a function that maps\n\t\t\t// selectors to functions that throw a suspense promise if not yet resolved.\n\t\t\tconst bindSuspendSelector = mapSuspendSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\tconst suspendSelectors = {\n\t\t\t\t...boundMetadataSelectors, // no special suspense behavior\n\t\t\t\t...mapValues( boundSelectors, bindSuspendSelector ),\n\t\t\t};\n\n\t\t\tconst allSuspendSelectors = createPrivateProxy(\n\t\t\t\tsuspendSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => boundPrivateSelectors.get( name ),\n\t\t\t\t\tbindSuspendSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( suspendSelectors )` returns 'allSuspendSelectors`.\n\t\t\tlock( suspendSelectors, allSuspendSelectors );\n\n\t\t\tconst getSelectors = () => selectors;\n\t\t\tconst getActions = () => actions;\n\t\t\tconst getResolveSelectors = () => resolveSelectors;\n\t\t\tconst getSuspendSelectors = () => suspendSelectors;\n\n\t\t\t// We have some modules monkey-patching the store object\n\t\t\t// It's wrong to do so but until we refactor all of our effects to controls\n\t\t\t// We need to keep the same \"store\" instance here.\n\t\t\tstore.__unstableOriginalGetState = store.getState;\n\t\t\tstore.getState = () => store.__unstableOriginalGetState().root;\n\n\t\t\t// Customize subscribe behavior to call listeners only on effective change,\n\t\t\t// not on every dispatch.\n\t\t\tconst subscribe =\n\t\t\t\tstore &&\n\t\t\t\t( ( listener ) => {\n\t\t\t\t\tlisteners.add( listener );\n\n\t\t\t\t\treturn () => listeners.delete( listener );\n\t\t\t\t} );\n\n\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\tstore.subscribe( () => {\n\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\tlastState = state;\n\n\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\tfor ( const listener of listeners ) {\n\t\t\t\t\t\tlistener();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// This can be simplified to just { subscribe, getSelectors, getActions }\n\t\t\t// Once we remove the use function.\n\t\t\treturn {\n\t\t\t\treducer,\n\t\t\t\tstore,\n\t\t\t\tactions,\n\t\t\t\tselectors,\n\t\t\t\tresolvers,\n\t\t\t\tgetSelectors,\n\t\t\t\tgetResolveSelectors,\n\t\t\t\tgetSuspendSelectors,\n\t\t\t\tgetActions,\n\t\t\t\tsubscribe,\n\t\t\t};\n\t\t},\n\t};\n\n\t// Expose the private registration functions on the store\n\t// descriptor. That's a natural choice since that's where the\n\t// public actions and selectors are stored.\n\tlock( storeDescriptor, privateRegistrationFunctions );\n\n\treturn storeDescriptor;\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\tserialize: {\n\t\t\t\t\treplacer: devToolsReplacer,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst { reducer, initialState } = options;\n\tconst enhancedReducer = combineReducers( {\n\t\tmetadata: metadataReducer,\n\t\troot: reducer,\n\t} );\n\n\treturn createStore(\n\t\tenhancedReducer,\n\t\t{ root: initialState },\n\t\tcompose( enhancers )\n\t);\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them.\n *\n * @param {Object} store The redux store the selectors are bound to.\n * @param {Object} boundMetadataSelectors The bound metadata selectors.\n *\n * @return {Function} Function that maps selectors to resolvers.\n */\nfunction mapResolveSelector( store, boundMetadataSelectors ) {\n\treturn ( 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\tnew Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () => {\n\t\t\t\t\treturn boundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst finalize = ( result ) => {\n\t\t\t\t\tconst hasFailed =\n\t\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve( result );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst getResult = () => selector.apply( null, args );\n\n\t\t\t\t// Trigger the selector (to trigger the resolver)\n\t\t\t\tconst result = getResult();\n\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\treturn finalize( result );\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\tfinalize( getResult() );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t};\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param {Object} store The redux store the selectors select from.\n * @param {Object} boundMetadataSelectors The bound metadata selectors.\n *\n * @return {Function} Function that maps selectors to their suspending versions.\n */\nfunction mapSuspendSelector( store, boundMetadataSelectors ) {\n\treturn ( 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 (\n\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\tselectorName,\n\t\t\t\t\targs\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t};\n}\n\n/**\n * Convert a resolver to a normalized form, an object with `fulfill` method and\n * optional methods like `isFulfilled`.\n *\n * @param {Function} resolver Resolver to convert\n */\nfunction mapResolver( resolver ) {\n\tif ( resolver.fulfill ) {\n\t\treturn resolver;\n\t}\n\n\treturn {\n\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\tfulfill: resolver, // Add the fulfill method.\n\t};\n}\n\n/**\n * Returns a selector with a matched resolver.\n * Resolvers are side effects invoked once per argument set of a given selector call,\n * used in ensuring that the data needs for the selector are satisfied.\n *\n * @param {Object} selector The selector function to be bound.\n * @param {string} selectorName The selector name.\n * @param {Object} resolver Resolver to call.\n * @param {Object} store The redux store to which the resolvers should be mapped.\n * @param {Object} resolversCache Resolvers Cache.\n * @param {Object} boundMetadataSelectors The bound metadata selectors.\n */\nfunction mapSelectorWithResolver(\n\tselector,\n\tselectorName,\n\tresolver,\n\tstore,\n\tresolversCache,\n\tboundMetadataSelectors\n) {\n\tfunction fulfillSelector( args ) {\n\t\tconst state = store.getState();\n\n\t\tif (\n\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\tresolver.isFulfilled( state, ...args ) )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tboundMetadataSelectors.hasStartedResolution( selectorName, args )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\tsetTimeout( async () => {\n\t\t\tresolversCache.clear( selectorName, args );\n\t\t\tstore.dispatch(\n\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tconst action = resolver.fulfill( ...args );\n\t\t\t\tif ( action ) {\n\t\t\t\t\tawait store.dispatch( action );\n\t\t\t\t}\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.finishResolution( selectorName, args )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.failResolution( selectorName, args, error )\n\t\t\t\t);\n\t\t\t}\n\t\t}, 0 );\n\t}\n\n\tconst selectorResolver = ( ...args ) => {\n\t\targs = normalize( selector, args );\n\t\tfulfillSelector( args );\n\t\treturn selector( ...args );\n\t};\n\tselectorResolver.hasResolver = true;\n\treturn selectorResolver;\n}\n\n/**\n * Applies selector's normalization function to the given arguments\n * if it exists.\n *\n * @param {Object} selector The selector potentially with a normalization method property.\n * @param {Array} args selector arguments to normalize.\n * @return {Array} Potentially normalized arguments.\n */\nfunction normalize( selector, args ) {\n\tif (\n\t\tselector.__unstableNormalizeArgs &&\n\t\ttypeof selector.__unstableNormalizeArgs === 'function' &&\n\t\targs?.length\n\t) {\n\t\treturn selector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**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { combineReducers } from './combine-reducers';\nimport { builtinControls } from '../controls';\nimport { lock } from '../lock-unlock';\nimport promise from '../promise-middleware';\nimport createResolversCacheMiddleware from '../resolvers-cache-middleware';\nimport createThunkMiddleware from './thunk-middleware';\nimport metadataReducer from './metadata/reducer';\nimport * as metadataSelectors from './metadata/selectors';\nimport * as metadataActions from './metadata/actions';\n\nexport { combineReducers };\n\n/** @typedef {import('../types').DataRegistry} DataRegistry */\n/** @typedef {import('../types').ListenerFunction} ListenerFunction */\n/**\n * @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../types').AnyConfig} C\n */\n/**\n * @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../types').ActionCreator>} Actions\n * @template 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 * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param {Object} obj The object to transform.\n * @param {Function} callback The function to transform each object value.\n * @return {Array} Transformed object.\n */\nconst mapValues = ( obj, callback ) =>\n\tObject.fromEntries(\n\t\tObject.entries( obj ?? {} ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tcallback( value, key ),\n\t\t] )\n\t);\n\n// Convert non serializable types to plain objects\nconst devToolsReplacer = ( key, state ) => {\n\tif ( state instanceof Map ) {\n\t\treturn Object.fromEntries( state );\n\t}\n\n\tif ( state instanceof window.HTMLElement ) {\n\t\treturn null;\n\t}\n\n\treturn state;\n};\n\n/**\n * Create a cache to track whether resolvers started running or not.\n *\n * @return {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\nfunction createBindingCache( getItem, bindItem ) {\n\tconst cache = new WeakMap();\n\n\treturn {\n\t\tget( itemName ) {\n\t\t\tconst item = getItem( itemName );\n\t\t\tif ( ! item ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet boundItem = cache.get( item );\n\t\t\tif ( ! boundItem ) {\n\t\t\t\tboundItem = bindItem( item, itemName );\n\t\t\t\tcache.set( item, boundItem );\n\t\t\t}\n\t\t\treturn boundItem;\n\t\t},\n\t};\n}\n\nfunction createPrivateProxy( publicItems, privateItems ) {\n\treturn new Proxy( publicItems, {\n\t\tget: ( target, itemName ) =>\n\t\t\tprivateItems.get( itemName ) || Reflect.get( target, itemName ),\n\t} );\n}\n\n/**\n * Creates a data store descriptor for the provided Redux store configuration containing\n * properties describing reducer, actions, selectors, controls and resolvers.\n *\n * @example\n * ```js\n * import { createReduxStore } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * ```\n *\n * @template State\n * @template {Record<string,import('../types').ActionCreator>} Actions\n * @template 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\tconst privateActions = {};\n\tconst privateSelectors = {};\n\tconst privateRegistrationFunctions = {\n\t\tprivateActions,\n\t\tregisterPrivateActions: ( actions ) => {\n\t\t\tObject.assign( privateActions, actions );\n\t\t},\n\t\tprivateSelectors,\n\t\tregisterPrivateSelectors: ( selectors ) => {\n\t\t\tObject.assign( privateSelectors, selectors );\n\t\t},\n\t};\n\tconst storeDescriptor = {\n\t\tname: key,\n\t\tinstantiate: ( registry ) => {\n\t\t\t/**\n\t\t\t * Stores listener functions registered with `subscribe()`.\n\t\t\t *\n\t\t\t * When functions register to listen to store changes with\n\t\t\t * `subscribe()` they get added here. Although Redux offers\n\t\t\t * its own `subscribe()` function directly, by wrapping the\n\t\t\t * subscription in this store instance it's possible to\n\t\t\t * optimize checking if the state has changed before calling\n\t\t\t * each listener.\n\t\t\t *\n\t\t\t * @type {Set<ListenerFunction>}\n\t\t\t */\n\t\t\tconst listeners = new Set();\n\t\t\tconst reducer = options.reducer;\n\n\t\t\t// Object that every thunk function receives as the first argument. It contains the\n\t\t\t// `registry`, `dispatch`, `select` and `resolveSelect` fields. Some of them are\n\t\t\t// constructed as getters to avoid circular dependencies.\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn thunkDispatch;\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn thunkSelect;\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn resolveSelectors;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst store = instantiateReduxStore(\n\t\t\t\tkey,\n\t\t\t\toptions,\n\t\t\t\tregistry,\n\t\t\t\tthunkArgs\n\t\t\t);\n\n\t\t\t// Expose the private registration functions on the store\n\t\t\t// so they can be copied to a sub registry in registry.js.\n\t\t\tlock( store, privateRegistrationFunctions );\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\t// Binds an action creator (`action`) to the `store`, making it a callable function.\n\t\t\t// These are the functions that are returned by `useDispatch`, for example.\n\t\t\t// It always returns a `Promise`, although actions are not always async. That's an\n\t\t\t// unfortunate backward compatibility measure.\n\t\t\tfunction bindAction( action ) {\n\t\t\t\treturn ( ...args ) =>\n\t\t\t\t\tPromise.resolve( store.dispatch( action( ...args ) ) );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Object with all public actions, both metadata and store actions.\n\t\t\t */\n\t\t\tconst actions = {\n\t\t\t\t...mapValues( metadataActions, bindAction ),\n\t\t\t\t...mapValues( options.actions, bindAction ),\n\t\t\t};\n\n\t\t\t// Object with both public and private actions. Private actions are accessed through a proxy,\n\t\t\t// which looks them up in real time on the `privateActions` object. That's because private\n\t\t\t// actions can be registered at any time with `registerPrivateActions`. Also once a private\n\t\t\t// action creator is bound to the store, it is cached to give it a stable identity.\n\t\t\tconst allActions = createPrivateProxy(\n\t\t\t\tactions,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => privateActions[ name ],\n\t\t\t\t\tbindAction\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// An object that implements the `dispatch` object that is passed to thunk functions.\n\t\t\t// It is callable (`dispatch( action )`) and also has methods (`dispatch.foo()`) that\n\t\t\t// correspond to bound registered actions, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allActions`.\n\t\t\tconst thunkDispatch = new Proxy(\n\t\t\t\t( action ) => store.dispatch( action ),\n\t\t\t\t{ get: ( target, name ) => allActions[ name ] }\n\t\t\t);\n\n\t\t\t// To the public `actions` object, add the \"locked\" `allActions` object. When used,\n\t\t\t// `unlock( actions )` will return `allActions`, implementing a way how to get at the private actions.\n\t\t\tlock( actions, allActions );\n\n\t\t\t// If we have selector resolvers, convert them to a normalized form.\n\t\t\tconst resolvers = options.resolvers\n\t\t\t\t? mapValues( options.resolvers, mapResolver )\n\t\t\t\t: {};\n\n\t\t\t// Bind a selector to the store. Call the selector with the current state, correct registry,\n\t\t\t// and if there is a resolver, attach the resolver logic to the selector.\n\t\t\tfunction bindSelector( selector, selectorName ) {\n\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\tselector.registry = registry;\n\t\t\t\t}\n\t\t\t\tconst boundSelector = ( ...args ) => {\n\t\t\t\t\targs = normalize( selector, args );\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t// Before calling the selector, switch to the correct registry.\n\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t}\n\t\t\t\t\treturn selector( state.root, ...args );\n\t\t\t\t};\n\n\t\t\t\t// Expose normalization method on the bound selector\n\t\t\t\t// in order that it can be called when fulfilling\n\t\t\t\t// the resolver.\n\t\t\t\tboundSelector.__unstableNormalizeArgs =\n\t\t\t\t\tselector.__unstableNormalizeArgs;\n\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\n\t\t\t\tif ( ! resolver ) {\n\t\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\t\treturn boundSelector;\n\t\t\t\t}\n\n\t\t\t\treturn mapSelectorWithResolver(\n\t\t\t\t\tboundSelector,\n\t\t\t\t\tselectorName,\n\t\t\t\t\tresolver,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache,\n\t\t\t\t\tboundMetadataSelectors\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Metadata selectors are bound differently: different state (`state.metadata`), no resolvers,\n\t\t\t// normalization depending on the target selector.\n\t\t\tfunction bindMetadataSelector( metaDataSelector ) {\n\t\t\t\tconst boundSelector = (\n\t\t\t\t\tselectorName,\n\t\t\t\t\tselectorArgs,\n\t\t\t\t\t...args\n\t\t\t\t) => {\n\t\t\t\t\t// Normalize the arguments passed to the target selector.\n\t\t\t\t\tif ( selectorName ) {\n\t\t\t\t\t\tconst targetSelector =\n\t\t\t\t\t\t\toptions.selectors?.[ selectorName ];\n\t\t\t\t\t\tif ( targetSelector ) {\n\t\t\t\t\t\t\tselectorArgs = normalize(\n\t\t\t\t\t\t\t\ttargetSelector,\n\t\t\t\t\t\t\t\tselectorArgs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\n\t\t\t\t\treturn metaDataSelector(\n\t\t\t\t\t\tstate.metadata,\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tselectorArgs,\n\t\t\t\t\t\t...args\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\treturn boundSelector;\n\t\t\t}\n\n\t\t\t// Perform binding of both metadata and store selectors and combine them in one\n\t\t\t// `selectors` object. These are all public selectors of the store.\n\t\t\tconst boundMetadataSelectors = mapValues(\n\t\t\t\tmetadataSelectors,\n\t\t\t\tbindMetadataSelector\n\t\t\t);\n\n\t\t\tconst boundSelectors = mapValues( options.selectors, bindSelector );\n\n\t\t\tconst selectors = {\n\t\t\t\t...boundMetadataSelectors,\n\t\t\t\t...boundSelectors,\n\t\t\t};\n\n\t\t\t// Cache of bould private selectors. They are bound only when first accessed, because\n\t\t\t// new private selectors can be registered at any time (with `registerPrivateSelectors`).\n\t\t\t// Once bound, they are cached to give them a stable identity.\n\t\t\tconst boundPrivateSelectors = createBindingCache(\n\t\t\t\t( name ) => privateSelectors[ name ],\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst allSelectors = createPrivateProxy(\n\t\t\t\tselectors,\n\t\t\t\tboundPrivateSelectors\n\t\t\t);\n\n\t\t\t// Pre-bind the private selectors that have been registered by the time of\n\t\t\t// instantiation, so that registry selectors are bound to the registry.\n\t\t\tfor ( const selectorName of Object.keys( privateSelectors ) ) {\n\t\t\t\tboundPrivateSelectors.get( selectorName );\n\t\t\t}\n\n\t\t\t// An object that implements the `select` object that is passed to thunk functions.\n\t\t\t// It is callable (`select( selector )`) and also has methods (`select.foo()`) that\n\t\t\t// correspond to bound registered selectors, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allSelectors`.\n\t\t\tconst thunkSelect = new Proxy(\n\t\t\t\t( selector ) => selector( store.__unstableOriginalGetState() ),\n\t\t\t\t{ get: ( target, name ) => allSelectors[ name ] }\n\t\t\t);\n\n\t\t\t// To the public `selectors` object, add the \"locked\" `allSelectors` object. When used,\n\t\t\t// `unlock( selectors )` will return `allSelectors`, implementing a way how to get at the private selectors.\n\t\t\tlock( selectors, allSelectors );\n\n\t\t\t// For each selector, create a function that calls the selector, waits for resolution and returns\n\t\t\t// a promise that resolves when the resolution is finished.\n\t\t\tconst bindResolveSelector = mapResolveSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\t// Now apply this function to all bound selectors, public and private. We are excluding\n\t\t\t// metadata selectors because they don't have resolvers.\n\t\t\tconst resolveSelectors = mapValues(\n\t\t\t\tboundSelectors,\n\t\t\t\tbindResolveSelector\n\t\t\t);\n\n\t\t\tconst allResolveSelectors = createPrivateProxy(\n\t\t\t\tresolveSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => boundPrivateSelectors.get( name ),\n\t\t\t\t\tbindResolveSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( resolveSelectors )` returns `allResolveSelectors`.\n\t\t\tlock( resolveSelectors, allResolveSelectors );\n\n\t\t\t// Now, in a way very similar to `bindResolveSelector`, we create a function that maps\n\t\t\t// selectors to functions that throw a suspense promise if not yet resolved.\n\t\t\tconst bindSuspendSelector = mapSuspendSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\tconst suspendSelectors = {\n\t\t\t\t...boundMetadataSelectors, // no special suspense behavior\n\t\t\t\t...mapValues( boundSelectors, bindSuspendSelector ),\n\t\t\t};\n\n\t\t\tconst allSuspendSelectors = createPrivateProxy(\n\t\t\t\tsuspendSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => boundPrivateSelectors.get( name ),\n\t\t\t\t\tbindSuspendSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( suspendSelectors )` returns 'allSuspendSelectors`.\n\t\t\tlock( suspendSelectors, allSuspendSelectors );\n\n\t\t\tconst getSelectors = () => selectors;\n\t\t\tconst getActions = () => actions;\n\t\t\tconst getResolveSelectors = () => resolveSelectors;\n\t\t\tconst getSuspendSelectors = () => suspendSelectors;\n\n\t\t\t// We have some modules monkey-patching the store object\n\t\t\t// It's wrong to do so but until we refactor all of our effects to controls\n\t\t\t// We need to keep the same \"store\" instance here.\n\t\t\tstore.__unstableOriginalGetState = store.getState;\n\t\t\tstore.getState = () => store.__unstableOriginalGetState().root;\n\n\t\t\t// Customize subscribe behavior to call listeners only on effective change,\n\t\t\t// not on every dispatch.\n\t\t\tconst subscribe =\n\t\t\t\tstore &&\n\t\t\t\t( ( listener ) => {\n\t\t\t\t\tlisteners.add( listener );\n\n\t\t\t\t\treturn () => listeners.delete( listener );\n\t\t\t\t} );\n\n\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\tstore.subscribe( () => {\n\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\tlastState = state;\n\n\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\tfor ( const listener of listeners ) {\n\t\t\t\t\t\tlistener();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// This can be simplified to just { subscribe, getSelectors, getActions }\n\t\t\t// Once we remove the use function.\n\t\t\treturn {\n\t\t\t\treducer,\n\t\t\t\tstore,\n\t\t\t\tactions,\n\t\t\t\tselectors,\n\t\t\t\tresolvers,\n\t\t\t\tgetSelectors,\n\t\t\t\tgetResolveSelectors,\n\t\t\t\tgetSuspendSelectors,\n\t\t\t\tgetActions,\n\t\t\t\tsubscribe,\n\t\t\t};\n\t\t},\n\t};\n\n\t// Expose the private registration functions on the store\n\t// descriptor. That's a natural choice since that's where the\n\t// public actions and selectors are stored.\n\tlock( storeDescriptor, privateRegistrationFunctions );\n\n\treturn storeDescriptor;\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\tserialize: {\n\t\t\t\t\treplacer: devToolsReplacer,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst { reducer, initialState } = options;\n\tconst enhancedReducer = combineReducers( {\n\t\tmetadata: metadataReducer,\n\t\troot: reducer,\n\t} );\n\n\treturn createStore(\n\t\tenhancedReducer,\n\t\t{ root: initialState },\n\t\tcompose( enhancers )\n\t);\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them.\n *\n * @param {Object} store The redux store the selectors are bound to.\n * @param {Object} boundMetadataSelectors The bound metadata selectors.\n *\n * @return {Function} Function that maps selectors to resolvers.\n */\nfunction mapResolveSelector( store, boundMetadataSelectors ) {\n\treturn ( 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\tnew Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () => {\n\t\t\t\t\treturn boundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst finalize = ( result ) => {\n\t\t\t\t\tconst hasFailed =\n\t\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve( result );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst getResult = () => selector.apply( null, args );\n\n\t\t\t\t// Trigger the selector (to trigger the resolver)\n\t\t\t\tconst result = getResult();\n\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\treturn finalize( result );\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\tfinalize( getResult() );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t};\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param {Object} store The redux store the selectors select from.\n * @param {Object} boundMetadataSelectors The bound metadata selectors.\n *\n * @return {Function} Function that maps selectors to their suspending versions.\n */\nfunction mapSuspendSelector( store, boundMetadataSelectors ) {\n\treturn ( 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 (\n\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\tselectorName,\n\t\t\t\t\targs\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t};\n}\n\n/**\n * Convert a resolver to a normalized form, an object with `fulfill` method and\n * optional methods like `isFulfilled`.\n *\n * @param {Function} resolver Resolver to convert\n */\nfunction mapResolver( resolver ) {\n\tif ( resolver.fulfill ) {\n\t\treturn resolver;\n\t}\n\n\treturn {\n\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\tfulfill: resolver, // Add the fulfill method.\n\t};\n}\n\n/**\n * Returns a selector with a matched resolver.\n * Resolvers are side effects invoked once per argument set of a given selector call,\n * used in ensuring that the data needs for the selector are satisfied.\n *\n * @param {Object} selector The selector function to be bound.\n * @param {string} selectorName The selector name.\n * @param {Object} resolver Resolver to call.\n * @param {Object} store The redux store to which the resolvers should be mapped.\n * @param {Object} resolversCache Resolvers Cache.\n * @param {Object} boundMetadataSelectors The bound metadata selectors.\n */\nfunction mapSelectorWithResolver(\n\tselector,\n\tselectorName,\n\tresolver,\n\tstore,\n\tresolversCache,\n\tboundMetadataSelectors\n) {\n\tfunction fulfillSelector( args ) {\n\t\tif (\n\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\tboundMetadataSelectors.hasStartedResolution( selectorName, args )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\tsetTimeout( async () => {\n\t\t\tresolversCache.clear( selectorName, args );\n\t\t\tstore.dispatch(\n\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tconst isFulfilled =\n\t\t\t\t\ttypeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\tresolver.isFulfilled( store.getState(), ...args );\n\t\t\t\tif ( ! isFulfilled ) {\n\t\t\t\t\tconst action = resolver.fulfill( ...args );\n\t\t\t\t\tif ( action ) {\n\t\t\t\t\t\tawait store.dispatch( action );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.finishResolution( selectorName, args )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.failResolution( selectorName, args, error )\n\t\t\t\t);\n\t\t\t}\n\t\t}, 0 );\n\t}\n\n\tconst selectorResolver = ( ...args ) => {\n\t\targs = normalize( selector, args );\n\t\tfulfillSelector( args );\n\t\treturn selector( ...args );\n\t};\n\tselectorResolver.hasResolver = true;\n\treturn selectorResolver;\n}\n\n/**\n * Applies selector's normalization function to the given arguments\n * if it exists.\n *\n * @param {Object} selector The selector potentially with a normalization method property.\n * @param {Array} args selector arguments to normalize.\n * @return {Array} Potentially normalized arguments.\n */\nfunction normalize( selector, args ) {\n\tif (\n\t\tselector.__unstableNormalizeArgs &&\n\t\ttypeof selector.__unstableNormalizeArgs === 'function' &&\n\t\targs?.length\n\t) {\n\t\treturn selector.__unstableNormalizeArgs( args );\n\t}\n\treturn args;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA6C;AAC7C,gCAA6B;AAK7B,2BAAyC;AACzC,qBAAwB;AAKxB,8BAAgC;AAChC,sBAAgC;AAChC,yBAAqB;AACrB,gCAAoB;AACpB,wCAA2C;AAC3C,8BAAkC;AAClC,qBAA4B;AAC5B,wBAAmC;AACnC,sBAAiC;AAiBjC,IAAM,sBAAsB,CAAE,UAAW;AACxC,QAAM,SAAS,CAAE,GAAG,KAAM;AAC1B,WAAU,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,KAAM;AAC9C,QAAK,OAAQ,CAAE,MAAM,QAAY;AAChC,aAAO,OAAQ,GAAG,CAAE;AAAA,IACrB;AAAA,EACD;AACA,SAAO;AACR;AAUA,IAAM,YAAY,CAAE,KAAK,aACxB,OAAO;AAAA,EACN,OAAO,QAAS,OAAO,CAAC,CAAE,EAAE,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO;AAAA,IACtD;AAAA,IACA,SAAU,OAAO,GAAI;AAAA,EACtB,CAAE;AACH;AAGD,IAAM,mBAAmB,CAAE,KAAK,UAAW;AAC1C,MAAK,iBAAiB,KAAM;AAC3B,WAAO,OAAO,YAAa,KAAM;AAAA,EAClC;AAEA,MAAK,iBAAiB,OAAO,aAAc;AAC1C,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAOA,SAAS,uBAAuB;AAC/B,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Map", "createResolversCacheMiddleware", "promise", "createReduxRoutineMiddleware", "createThunkMiddleware", "metadataReducer", "result"]
|
|
7
7
|
}
|
|
@@ -33,8 +33,8 @@ __export(reducer_exports, {
|
|
|
33
33
|
default: () => reducer_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(reducer_exports);
|
|
36
|
-
var import_equivalent_key_map = __toESM(require("equivalent-key-map"));
|
|
37
|
-
var import_utils = require("./utils");
|
|
36
|
+
var import_equivalent_key_map = __toESM(require("equivalent-key-map"), 1);
|
|
37
|
+
var import_utils = require("./utils.cjs");
|
|
38
38
|
var subKeysIsResolved = (0, import_utils.onSubKey)("selectorName")((state = new import_equivalent_key_map.default(), action) => {
|
|
39
39
|
switch (action.type) {
|
|
40
40
|
case "START_RESOLUTION": {
|
|
@@ -129,4 +129,4 @@ var isResolved = (state = {}, action) => {
|
|
|
129
129
|
return state;
|
|
130
130
|
};
|
|
131
131
|
var reducer_default = isResolved;
|
|
132
|
-
//# sourceMappingURL=reducer.
|
|
132
|
+
//# sourceMappingURL=reducer.cjs.map
|
|
@@ -42,9 +42,9 @@ __export(selectors_exports, {
|
|
|
42
42
|
isResolving: () => isResolving
|
|
43
43
|
});
|
|
44
44
|
module.exports = __toCommonJS(selectors_exports);
|
|
45
|
-
var import_deprecated = __toESM(require("@wordpress/deprecated"));
|
|
46
|
-
var import_create_selector = require("../../create-selector");
|
|
47
|
-
var import_utils = require("./utils");
|
|
45
|
+
var import_deprecated = __toESM(require("@wordpress/deprecated"), 1);
|
|
46
|
+
var import_create_selector = require("../../create-selector.cjs");
|
|
47
|
+
var import_utils = require("./utils.cjs");
|
|
48
48
|
function getResolutionState(state, selectorName, args) {
|
|
49
49
|
const map = state[selectorName];
|
|
50
50
|
if (!map) {
|
|
@@ -137,4 +137,4 @@ var countSelectorsByStatus = (0, import_create_selector.createSelector)(
|
|
|
137
137
|
hasStartedResolution,
|
|
138
138
|
isResolving
|
|
139
139
|
});
|
|
140
|
-
//# sourceMappingURL=selectors.
|
|
140
|
+
//# sourceMappingURL=selectors.cjs.map
|
|
@@ -33,11 +33,11 @@ __export(registry_exports, {
|
|
|
33
33
|
createRegistry: () => createRegistry
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(registry_exports);
|
|
36
|
-
var import_deprecated = __toESM(require("@wordpress/deprecated"));
|
|
37
|
-
var import_redux_store = __toESM(require("./redux-store"));
|
|
38
|
-
var import_store = __toESM(require("./store"));
|
|
39
|
-
var import_emitter = require("./utils/emitter");
|
|
40
|
-
var import_lock_unlock = require("./lock-unlock");
|
|
36
|
+
var import_deprecated = __toESM(require("@wordpress/deprecated"), 1);
|
|
37
|
+
var import_redux_store = __toESM(require("./redux-store/index.cjs"), 1);
|
|
38
|
+
var import_store = __toESM(require("./store/index.cjs"), 1);
|
|
39
|
+
var import_emitter = require("./utils/emitter.cjs");
|
|
40
|
+
var import_lock_unlock = require("./lock-unlock.cjs");
|
|
41
41
|
function getStoreName(storeNameOrDescriptor) {
|
|
42
42
|
return typeof storeNameOrDescriptor === "string" ? storeNameOrDescriptor : storeNameOrDescriptor.name;
|
|
43
43
|
}
|
|
@@ -262,4 +262,4 @@ function createRegistry(storeConfigs = {}, parent = null) {
|
|
|
262
262
|
0 && (module.exports = {
|
|
263
263
|
createRegistry
|
|
264
264
|
});
|
|
265
|
-
//# sourceMappingURL=registry.
|
|
265
|
+
//# sourceMappingURL=registry.cjs.map
|
|
@@ -47,4 +47,4 @@ var createResolversCacheMiddleware = (registry, storeName) => () => (next) => (a
|
|
|
47
47
|
return next(action);
|
|
48
48
|
};
|
|
49
49
|
var resolvers_cache_middleware_default = createResolversCacheMiddleware;
|
|
50
|
-
//# sourceMappingURL=resolvers-cache-middleware.
|
|
50
|
+
//# sourceMappingURL=resolvers-cache-middleware.cjs.map
|
|
@@ -33,7 +33,7 @@ __export(select_exports, {
|
|
|
33
33
|
select: () => select
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(select_exports);
|
|
36
|
-
var import_default_registry = __toESM(require("./default-registry"));
|
|
36
|
+
var import_default_registry = __toESM(require("./default-registry.cjs"), 1);
|
|
37
37
|
function select(storeNameOrDescriptor) {
|
|
38
38
|
return import_default_registry.default.select(storeNameOrDescriptor);
|
|
39
39
|
}
|
|
@@ -41,4 +41,4 @@ function select(storeNameOrDescriptor) {
|
|
|
41
41
|
0 && (module.exports = {
|
|
42
42
|
select
|
|
43
43
|
});
|
|
44
|
-
//# sourceMappingURL=select.
|
|
44
|
+
//# sourceMappingURL=select.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { combineReducers as reduxCombineReducers } from 'redux';\n\ntype MapOf< T > = { [ name: string ]: T };\n\nexport type ActionCreator = ( ...args: any[] ) => any | Generator;\nexport type Resolver = Function | Generator;\nexport type Selector = Function;\n\nexport type AnyConfig = ReduxStoreConfig< any, any, any >;\n\nexport interface StoreInstance< Config extends AnyConfig > {\n\tgetSelectors: () => SelectorsOf< Config >;\n\tgetActions: () => ActionCreatorsOf< Config >;\n\tsubscribe: ( listener: () => void ) => () => void;\n}\n\nexport interface StoreDescriptor< Config extends AnyConfig = AnyConfig > {\n\t/**\n\t * Store Name\n\t */\n\tname: string;\n\n\t/**\n\t * Creates a store instance\n\t */\n\tinstantiate: ( registry: DataRegistry ) => StoreInstance< Config >;\n}\n\nexport interface ReduxStoreConfig<\n\tState,\n\tActionCreators extends MapOf< ActionCreator >,\n\tSelectors,\n> {\n\tinitialState?: State;\n\treducer: ( state: any, action: any ) => any;\n\tactions?: ActionCreators;\n\tresolvers?: MapOf< Resolver >;\n\tselectors?: Selectors;\n\tcontrols?: MapOf< Function >;\n}\n\n// Return type for the useSelect() hook.\nexport type UseSelectReturn< F extends MapSelect | StoreDescriptor< any > > =\n\tF extends MapSelect\n\t\t? ReturnType< F >\n\t\t: F extends StoreDescriptor< any >\n\t\t? CurriedSelectorsOf< F >\n\t\t: never;\n\n// Return type for the useDispatch() hook.\nexport type UseDispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: StoreNameOrDescriptor extends undefined\n\t\t? DispatchFunction\n\t\t: any;\n\nexport type DispatchFunction = < StoreNameOrDescriptor >(\n\tstore: StoreNameOrDescriptor\n) => DispatchReturn< StoreNameOrDescriptor >;\n\nexport type DispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: unknown;\n\nexport type MapSelect = (\n\tselect: SelectFunction,\n\tregistry: DataRegistry\n) => any;\n\nexport type SelectFunction = < S >( store: S ) => CurriedSelectorsOf< S >;\n\n/**\n * Callback for store's `subscribe()` method that\n * runs when the store data has changed.\n */\nexport type ListenerFunction = () => void;\n\nexport type CurriedSelectorsOf< S > = S extends StoreDescriptor<\n\tReduxStoreConfig< any, any, infer Selectors >\n>\n\t? { [ key in keyof Selectors ]: CurriedState< Selectors[ key ] > }\n\t: never;\n\n/**\n * Like CurriedState but wraps the return type in a Promise.\n * Used for resolveSelect where selectors return promises.\n *\n * For generic selectors that define PromiseCurriedSignature, that signature\n * is used directly to preserve generic type parameters (which would otherwise\n * be lost when using `infer`).\n */\ntype CurriedStateWithPromise< F > =\n\tF extends SelectorWithCustomCurrySignature & {\n\t\tPromiseCurriedSignature: infer S;\n\t}\n\t\t? S\n\t\t: F extends SelectorWithCustomCurrySignature & {\n\t\t\t\tCurriedSignature: ( ...args: infer P ) => infer R;\n\t\t }\n\t\t? ( ...args: P ) => Promise< R >\n\t\t: F extends ( state: any, ...args: infer P ) => infer R\n\t\t? ( ...args: P ) => Promise< R >\n\t\t: F;\n\n/**\n * Like CurriedSelectorsOf but each selector returns a Promise.\n * Used for resolveSelect.\n */\nexport type CurriedSelectorsResolveOf< S > = S extends StoreDescriptor<\n\tReduxStoreConfig< any, any, infer Selectors >\n>\n\t? {\n\t\t\t[ key in keyof Selectors ]: CurriedStateWithPromise<\n\t\t\t\tSelectors[ key ]\n\t\t\t>;\n\t }\n\t: never;\n\n/**\n * Removes the first argument from a function.\n *\n * By default, it removes the `state` parameter from\n * registered selectors since that argument is supplied\n * by the editor when calling `select(\u2026)`.\n *\n * For functions with no arguments, which some selectors\n * are free to define, returns the original function.\n *\n * It is possible to manually provide a custom curried signature\n * and avoid the automatic inference. When the\n * F generic argument passed to this helper extends the\n * SelectorWithCustomCurrySignature type, the F['CurriedSignature']\n * property is used verbatim.\n *\n * This is useful because TypeScript does not correctly remove\n * arguments from complex function signatures constrained by\n * interdependent generic parameters.\n * For more context, see https://github.com/WordPress/gutenberg/pull/41578\n */\ntype CurriedState< F > = F extends SelectorWithCustomCurrySignature\n\t? F[ 'CurriedSignature' ]\n\t: F extends ( state: any, ...args: infer P ) => infer R\n\t? ( ...args: P ) => R\n\t: F;\n\n/**\n * Utility to manually specify curried selector signatures.\n *\n * It comes handy when TypeScript can't automatically produce the\n * correct curried function signature. For example:\n *\n * ```ts\n * type BadlyInferredSignature = CurriedState<\n * <K extends string | number>(\n * state: any,\n * kind: K,\n * key: K extends string ? 'one value' : false\n * ) => K\n * >\n * // BadlyInferredSignature evaluates to:\n * // (kind: string number, key: false \"one value\") => string number\n * ```\n *\n * With SelectorWithCustomCurrySignature, we can provide a custom\n * signature and avoid relying on TypeScript inference:\n * ```ts\n * interface MySelectorSignature extends SelectorWithCustomCurrySignature {\n * <K extends string | number>(\n * state: any,\n * kind: K,\n * key: K extends string ? 'one value' : false\n * ): K;\n *\n * CurriedSignature: <K extends string | number>(\n * kind: K,\n * key: K extends string ? 'one value' : false\n * ): K;\n * }\n * type CorrectlyInferredSignature = CurriedState<MySelectorSignature>\n * // <K extends string | number>(kind: K, key: K extends string ? 'one value' : false): K;\n *\n * For even more context, see https://github.com/WordPress/gutenberg/pull/41578\n * ```\n */\nexport interface SelectorWithCustomCurrySignature {\n\tCurriedSignature: Function;\n\tPromiseCurriedSignature?: Function;\n}\n\nexport interface DataRegistry {\n\tregister: ( store: StoreDescriptor< any > ) => void;\n\tdispatch: < S extends StoreDescriptor< any > >(\n\t\tstore: S\n\t) => ActionCreatorsOf< ConfigOf< S > >;\n}\n\n// Type Helpers.\n\nexport type ConfigOf< S > = S extends StoreDescriptor< infer C > ? C : never;\n\nexport type ActionCreatorsOf< Config extends AnyConfig > =\n\tConfig extends ReduxStoreConfig< any, infer ActionCreators, any >\n\t\t? PromisifiedActionCreators< ActionCreators >\n\t\t: never;\n\n// Takes an object containing all action creators for a store and updates the\n// return type of each action creator to account for internal registry details --\n// for example, dispatched actions are wrapped with a Promise.\nexport type PromisifiedActionCreators<\n\tActionCreators extends MapOf< ActionCreator >,\n> = {\n\t[ Action in keyof ActionCreators ]: PromisifyActionCreator<\n\t\tActionCreators[ Action ]\n\t>;\n};\n\n// Wraps action creator return types with a Promise and handles thunks.\nexport type PromisifyActionCreator< Action extends ActionCreator > = (\n\t...args: Parameters< Action >\n) => Promise<\n\tReturnType< Action > extends ( ..._args: any[] ) => any\n\t\t? ThunkReturnType< Action >\n\t\t: ReturnType< Action >\n>;\n\n// A thunk is an action creator which returns a function, which can optionally\n// return a Promise. The double ReturnType unwraps the innermost function's\n// return type, and Awaited gets the type the Promise resolves to. If the return\n// type is not a Promise, Awaited returns that original type.\nexport type ThunkReturnType< Action extends ActionCreator > = Awaited<\n\tReturnType< ReturnType< Action > >\n>;\n\ntype SelectorsOf< Config extends AnyConfig > = Config extends ReduxStoreConfig<\n\tany,\n\tany,\n\tinfer Selectors\n>\n\t? { [ name in keyof Selectors ]: Function }\n\t: never;\n\nexport type combineReducers = typeof reduxCombineReducers;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/data/src/components/async-mode-provider/index.js
|
|
2
|
-
import { default as default2 } from "./use-async-mode";
|
|
3
|
-
import { default as default3, AsyncModeConsumer } from "./context";
|
|
2
|
+
import { default as default2 } from "./use-async-mode.js";
|
|
3
|
+
import { default as default3, AsyncModeConsumer } from "./context.js";
|
|
4
4
|
export {
|
|
5
5
|
AsyncModeConsumer,
|
|
6
6
|
default3 as AsyncModeProvider,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/data/src/components/registry-provider/context.js
|
|
2
2
|
import { createContext } from "@wordpress/element";
|
|
3
|
-
import defaultRegistry from "../../default-registry";
|
|
3
|
+
import defaultRegistry from "../../default-registry.js";
|
|
4
4
|
var Context = createContext(defaultRegistry);
|
|
5
5
|
Context.displayName = "RegistryProviderContext";
|
|
6
6
|
var { Consumer, Provider } = Context;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/data/src/components/registry-provider/index.js
|
|
2
|
-
import { default as default2, RegistryConsumer } from "./context";
|
|
3
|
-
import { default as default3 } from "./use-registry";
|
|
2
|
+
import { default as default2, RegistryConsumer } from "./context.js";
|
|
3
|
+
import { default as default3 } from "./use-registry.js";
|
|
4
4
|
export {
|
|
5
5
|
RegistryConsumer,
|
|
6
6
|
default2 as RegistryProvider,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/registry-provider/use-registry.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\n\n/**\n * A custom react hook exposing the registry context for use.\n *\n * This exposes the `registry` value provided via the\n * <a href=\"#RegistryProvider\">Registry Provider</a> to a component implementing\n * this hook.\n *\n * It acts similarly to the `useContext` react hook.\n *\n * Note: Generally speaking, `useRegistry` is a low level hook that in most cases\n * won't be needed for implementation. Most interactions with the `@wordpress/data`\n * API can be performed via the `useSelect` hook, or the `withSelect` and\n * `withDispatch` higher order components.\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * createRegistry,\n * useRegistry,\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const SomeChildUsingRegistry = ( props ) => {\n * const registry = useRegistry();\n * // ...logic implementing the registry in other react hooks.\n * };\n *\n *\n * const ParentProvidingRegistry = ( props ) => {\n * return <RegistryProvider value={ registry }>\n * <SomeChildUsingRegistry { ...props } />\n * </RegistryProvider>\n * };\n * ```\n *\n * @return {
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\n\n/**\n * A custom react hook exposing the registry context for use.\n *\n * This exposes the `registry` value provided via the\n * <a href=\"#RegistryProvider\">Registry Provider</a> to a component implementing\n * this hook.\n *\n * It acts similarly to the `useContext` react hook.\n *\n * Note: Generally speaking, `useRegistry` is a low level hook that in most cases\n * won't be needed for implementation. Most interactions with the `@wordpress/data`\n * API can be performed via the `useSelect` hook, or the `withSelect` and\n * `withDispatch` higher order components.\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * createRegistry,\n * useRegistry,\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const SomeChildUsingRegistry = ( props ) => {\n * const registry = useRegistry();\n * // ...logic implementing the registry in other react hooks.\n * };\n *\n *\n * const ParentProvidingRegistry = ( props ) => {\n * return <RegistryProvider value={ registry }>\n * <SomeChildUsingRegistry { ...props } />\n * </RegistryProvider>\n * };\n * ```\n *\n * @return {import('../../types').DataRegistry} A custom react hook exposing the registry context value.\n */\nexport default function useRegistry() {\n\treturn useContext( Context );\n}\n"],
|
|
5
5
|
"mappings": ";AAGA,SAAS,kBAAkB;AAK3B,SAAS,eAAe;AAyCT,SAAR,cAA+B;AACrC,SAAO,WAAY,OAAQ;AAC5B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/data/src/components/use-dispatch/index.js
|
|
2
|
-
import { default as default2 } from "./use-dispatch";
|
|
3
|
-
import { default as default3 } from "./use-dispatch-with-map";
|
|
2
|
+
import { default as default2 } from "./use-dispatch.js";
|
|
3
|
+
import { default as default3 } from "./use-dispatch-with-map.js";
|
|
4
4
|
export {
|
|
5
5
|
default2 as useDispatch,
|
|
6
6
|
default3 as useDispatchWithMap
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// packages/data/src/components/use-dispatch/use-dispatch-with-map.js
|
|
2
2
|
import { useMemo, useRef } from "@wordpress/element";
|
|
3
3
|
import { useIsomorphicLayoutEffect } from "@wordpress/compose";
|
|
4
|
-
import useRegistry from "../registry-provider/use-registry";
|
|
4
|
+
import useRegistry from "../registry-provider/use-registry.js";
|
|
5
5
|
var useDispatchWithMap = (dispatchMap, deps) => {
|
|
6
6
|
const registry = useRegistry();
|
|
7
7
|
const currentDispatchMapRef = useRef(dispatchMap);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/data/src/components/use-dispatch/use-dispatch.js
|
|
2
|
-
import useRegistry from "../registry-provider/use-registry";
|
|
2
|
+
import useRegistry from "../registry-provider/use-registry.js";
|
|
3
3
|
var useDispatch = (storeNameOrDescriptor) => {
|
|
4
4
|
const { dispatch } = useRegistry();
|
|
5
5
|
return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor);
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
useSyncExternalStore,
|
|
8
8
|
useDebugValue
|
|
9
9
|
} from "@wordpress/element";
|
|
10
|
-
import isShallowEqual from "@wordpress/is-shallow-equal";
|
|
11
|
-
import useRegistry from "../registry-provider/use-registry";
|
|
12
|
-
import useAsyncMode from "../async-mode-provider/use-async-mode";
|
|
10
|
+
import { isShallowEqual } from "@wordpress/is-shallow-equal";
|
|
11
|
+
import useRegistry from "../registry-provider/use-registry.js";
|
|
12
|
+
import useAsyncMode from "../async-mode-provider/use-async-mode.js";
|
|
13
13
|
var renderQueue = createQueue();
|
|
14
14
|
function warnOnUnstableReference(a, b) {
|
|
15
15
|
if (!a || !b) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/use-select/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst renderQueue = createQueue();\n\nfunction warnOnUnstableReference( a, b ) {\n\tif ( ! a || ! b ) {\n\t\treturn;\n\t}\n\n\tconst keys =\n\t\ttypeof a === 'object' && typeof b === 'object'\n\t\t\t? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] )\n\t\t\t: [];\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn(\n\t\t'The `useSelect` hook returns different values when called with the same state and parameters.\\n' +\n\t\t\t'This can lead to unnecessary re-renders and performance issues if not fixed.\\n\\n' +\n\t\t\t'Non-equal value keys: %s\\n\\n',\n\t\tkeys.join( ', ' )\n\t);\n}\n\n/**\n * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../../types').AnyConfig} C\n */\n/**\n * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../../types').ActionCreator>} Actions\n * @template Selectors\n */\n/** @typedef {import('../../types').MapSelect} MapSelect */\n/**\n * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn\n * @template {MapSelect|StoreDescriptor<any>} T\n */\n\nfunction Store( registry, suspense ) {\n\tconst select = suspense ? registry.suspendSelect : registry.select;\n\tconst queueContext = {};\n\tlet lastMapSelect;\n\tlet lastMapResult;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync;\n\tlet subscriber;\n\tlet didWarnUnstableReference;\n\tconst storeStatesOnMount = new Map();\n\n\tfunction getStoreState( name ) {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores ) => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set();\n\n\t\tfunction subscribe( listener ) {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs = [];\n\t\t\tfunction subscribeStore( storeName ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect, isAsync ) => {\n\t\tfunction updateValue() {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn lastMapResult;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( globalThis.SCRIPT_DEBUG ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\twarnOnUnstableReference( mapResult, secondMapResult );\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect( suspense, mapSelect, deps ) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @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 * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n * @return {UseSelectReturn<T>} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\treturn staticSelectMode\n\t\t? _useStaticSelect( mapSelect )\n\t\t: _useMappingSelect( false, mapSelect, deps );\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @template {MapSelect} T\n * @param {T} 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 * @throws {Promise} A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return {ReturnType<T>} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\treturn _useMappingSelect( true, mapSelect, deps );\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst renderQueue = createQueue();\n\nfunction warnOnUnstableReference( a, b ) {\n\tif ( ! a || ! b ) {\n\t\treturn;\n\t}\n\n\tconst keys =\n\t\ttypeof a === 'object' && typeof b === 'object'\n\t\t\t? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] )\n\t\t\t: [];\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn(\n\t\t'The `useSelect` hook returns different values when called with the same state and parameters.\\n' +\n\t\t\t'This can lead to unnecessary re-renders and performance issues if not fixed.\\n\\n' +\n\t\t\t'Non-equal value keys: %s\\n\\n',\n\t\tkeys.join( ', ' )\n\t);\n}\n\n/**\n * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../../types').AnyConfig} C\n */\n/**\n * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../../types').ActionCreator>} Actions\n * @template Selectors\n */\n/** @typedef {import('../../types').MapSelect} MapSelect */\n/**\n * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn\n * @template {MapSelect|StoreDescriptor<any>} T\n */\n\nfunction Store( registry, suspense ) {\n\tconst select = suspense ? registry.suspendSelect : registry.select;\n\tconst queueContext = {};\n\tlet lastMapSelect;\n\tlet lastMapResult;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync;\n\tlet subscriber;\n\tlet didWarnUnstableReference;\n\tconst storeStatesOnMount = new Map();\n\n\tfunction getStoreState( name ) {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores ) => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set();\n\n\t\tfunction subscribe( listener ) {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs = [];\n\t\t\tfunction subscribeStore( storeName ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect, isAsync ) => {\n\t\tfunction updateValue() {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn lastMapResult;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( globalThis.SCRIPT_DEBUG ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\twarnOnUnstableReference( mapResult, secondMapResult );\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect( suspense, mapSelect, deps ) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @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 * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n * @return {UseSelectReturn<T>} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\treturn staticSelectMode\n\t\t? _useStaticSelect( mapSelect )\n\t\t: _useMappingSelect( false, mapSelect, deps );\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @template {MapSelect} T\n * @param {T} 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 * @throws {Promise} A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return {ReturnType<T>} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\treturn _useMappingSelect( true, mapSelect, deps );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA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;AACjD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/data/src/components/with-dispatch/index.js
|
|
2
2
|
import { createHigherOrderComponent } from "@wordpress/compose";
|
|
3
|
-
import { useDispatchWithMap } from "../use-dispatch";
|
|
3
|
+
import { useDispatchWithMap } from "../use-dispatch/index.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
var withDispatch = (mapDispatchToProps) => createHigherOrderComponent(
|
|
6
6
|
(WrappedComponent) => (ownProps) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/data/src/components/with-registry/index.js
|
|
2
2
|
import { createHigherOrderComponent } from "@wordpress/compose";
|
|
3
|
-
import { RegistryConsumer } from "../registry-provider";
|
|
3
|
+
import { RegistryConsumer } from "../registry-provider/index.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
var withRegistry = createHigherOrderComponent(
|
|
6
6
|
(OriginalComponent) => (props) => /* @__PURE__ */ jsx(RegistryConsumer, { children: (registry) => /* @__PURE__ */ jsx(OriginalComponent, { ...props, registry }) }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/data/src/components/with-select/index.js
|
|
2
2
|
import { createHigherOrderComponent, pure } from "@wordpress/compose";
|
|
3
|
-
import useSelect from "../use-select";
|
|
3
|
+
import useSelect from "../use-select/index.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
var withSelect = (mapSelectToProps) => createHigherOrderComponent(
|
|
6
6
|
(WrappedComponent) => pure((ownProps) => {
|
package/build-module/controls.js
CHANGED
package/build-module/dispatch.js
CHANGED