@wordpress/data 10.48.1 → 10.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 10.49.0 (2026-06-24)
6
+
5
7
  ## 10.48.1 (2026-06-16)
6
8
 
7
9
  ## 10.48.0 (2026-06-10)
package/README.md CHANGED
@@ -500,9 +500,11 @@ _Returns_
500
500
 
501
501
  Creates a memoized selector that caches the computed values according to the array of "dependants" and the selector parameters, and recomputes the values only when any of them changes.
502
502
 
503
- _Related_
503
+ See The documentation for the `rememo` package from which the `createSelector` function is reexported.
504
+
505
+ _Type_
504
506
 
505
- - The documentation for the `rememo` package from which the `createSelector` function is reexported.
507
+ - `( selector: S, getDependants: GetDependants ) => S & EnhancedSelector`
506
508
 
507
509
  ### dispatch
508
510
 
@@ -529,6 +531,14 @@ _Returns_
529
531
 
530
532
  - `DispatchReturn< StoreNameOrDescriptor >`: Object containing the action creators.
531
533
 
534
+ ### EnhancedSelector
535
+
536
+ Undocumented declaration.
537
+
538
+ ### GetDependants
539
+
540
+ Undocumented declaration.
541
+
532
542
  ### keyedReducer
533
543
 
534
544
  Higher-order reducer creator which creates a combined reducer object, keyed by a property on the action object.
@@ -30,10 +30,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // packages/data/src/create-selector.ts
31
31
  var create_selector_exports = {};
32
32
  __export(create_selector_exports, {
33
- createSelector: () => import_rememo.default
33
+ createSelector: () => createSelector
34
34
  });
35
35
  module.exports = __toCommonJS(create_selector_exports);
36
36
  var import_rememo = __toESM(require("rememo"));
37
+ var createSelector = import_rememo.default;
37
38
  // Annotate the CommonJS export names for ESM import in node:
38
39
  0 && (module.exports = {
39
40
  createSelector
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/create-selector.ts"],
4
- "sourcesContent": ["/**\n * Creates a memoized selector that caches the computed values according to the array of \"dependants\"\n * and the selector parameters, and recomputes the values only when any of them changes.\n *\n * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.\n */\nexport { default as createSelector } from 'rememo';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAA0C;",
6
- "names": []
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport memoize from 'rememo';\n\n/**\n * Returns the array of immutable references on which a memoized selector\n * depends for computing its result. The memoize cache is preserved only as\n * long as those dependant references remain the same.\n */\nexport type GetDependants = ( ...args: any[] ) => any[];\n\n/**\n * The memoization methods a selector returned by `createSelector` is\n * enhanced with.\n */\nexport interface EnhancedSelector {\n\tgetDependants: GetDependants;\n\n\t/**\n\t * Clears the memoization cache.\n\t */\n\tclear: () => void;\n}\n\n/*\n * The signature mirrors `rememo`'s, but is declared here so that consumers'\n * emitted declarations reference `@wordpress/data` rather than `rememo`,\n * which they do not declare as a dependency.\n */\n\n/**\n * Creates a memoized selector that caches the computed values according to the array of \"dependants\"\n * and the selector parameters, and recomputes the values only when any of them changes.\n *\n * See The documentation for the `rememo` package from which the `createSelector` function is reexported.\n */\nexport const createSelector: < S extends ( ...args: any[] ) => any >(\n\tselector: S,\n\tgetDependants?: GetDependants\n) => S & EnhancedSelector = memoize;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAoB;AAkCb,IAAM,iBAGe,cAAAA;",
6
+ "names": ["memoize"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport defaultRegistry from './default-registry';\nimport * as plugins from './plugins';\nimport { combineReducers as combineReducersModule } from './redux-store';\n\nimport type {\n\tStoreDescriptor,\n\tReduxStoreConfig,\n\tcombineReducers as CombineReducers,\n\tAnyConfig,\n\tCurriedSelectorsResolveOf,\n} from './types';\n\nexport { default as withSelect } from './components/with-select';\nexport { default as withDispatch } from './components/with-dispatch';\nexport { default as withRegistry } from './components/with-registry';\nexport {\n\tRegistryProvider,\n\tRegistryConsumer,\n\tuseRegistry,\n} from './components/registry-provider';\nexport {\n\tdefault as useSelect,\n\tuseSuspenseSelect,\n} from './components/use-select';\nexport { useDispatch } from './components/use-dispatch';\nexport { AsyncModeProvider } from './components/async-mode-provider';\nexport { createRegistry } from './registry';\nexport { createRegistrySelector, createRegistryControl } from './factory';\nexport { createSelector } from './create-selector';\nexport { controls } from './controls';\nexport { default as createReduxStore } from './redux-store';\nexport { keyedReducer } from './redux-store/keyed-reducer';\nexport { dispatch } from './dispatch';\nexport { select } from './select';\n\nexport type * from './types';\n\n/**\n * Object of available plugins to use with a registry.\n *\n * @see [use](#use)\n */\nexport { plugins };\n\n/**\n * The combineReducers helper function turns an object whose values are different\n * reducing functions into a single reducing function you can pass to registerReducer.\n *\n * @type {import('./types').combineReducers}\n * @param {Object} reducers An object whose values correspond to different reducing\n * functions that need to be combined into one.\n *\n * @example\n * ```js\n * import { combineReducers, createReduxStore, register } from '@wordpress/data';\n *\n * const prices = ( state = {}, action ) => {\n * \treturn action.type === 'SET_PRICE' ?\n * \t\t{\n * \t\t\t...state,\n * \t\t\t[ action.item ]: action.price,\n * \t\t} :\n * \t\tstate;\n * };\n *\n * const discountPercent = ( state = 0, action ) => {\n * \treturn action.type === 'START_SALE' ?\n * \t\taction.discountPercent :\n * \t\tstate;\n * };\n *\n * const store = createReduxStore( 'my-shop', {\n * \treducer: combineReducers( {\n * \t\tprices,\n * \t\tdiscountPercent,\n * \t} ),\n * } );\n * register( store );\n * ```\n *\n * @return {Function} A reducer that invokes every reducer inside the reducers\n * object, and constructs a state object with the same shape.\n */\nexport const combineReducers =\n\tcombineReducersModule as unknown as CombineReducers;\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors\n * pre-bound to state so that you only need to supply additional arguments, and\n * modified so that they return promises that resolve to their eventual values,\n * after any resolvers have ran.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @example\n * ```js\n * import { resolveSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log)\n * ```\n *\n * @return Object containing the store's promise-wrapped selectors.\n */\nexport function resolveSelect< T extends StoreDescriptor< AnyConfig > >(\n\tstoreNameOrDescriptor: T | string\n): CurriedSelectorsResolveOf< T > {\n\treturn defaultRegistry.resolveSelect(\n\t\tstoreNameOrDescriptor\n\t) as CurriedSelectorsResolveOf< T >;\n}\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors pre-bound to state\n * so that you only need to supply additional arguments, and modified so that they throw promises\n * in case the selector is not resolved yet.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @return {Object} Object containing the store's suspense-wrapped selectors.\n */\nexport const suspendSelect = (\n\tstoreNameOrDescriptor:\n\t\t| string\n\t\t| StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): any => defaultRegistry.suspendSelect( storeNameOrDescriptor );\n\n/**\n * Given a listener function, the function will be called any time the state value\n * of one of the registered stores has changed. If you specify the optional\n * `storeNameOrDescriptor` parameter, the listener function will be called only\n * on updates on that one specific registered store.\n *\n * This function returns an `unsubscribe` function used to stop the subscription.\n *\n * @param {Function} listener Callback function.\n * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n *\n * @example\n * ```js\n * import { subscribe } from '@wordpress/data';\n *\n * const unsubscribe = subscribe( () => {\n * \t// You could use this opportunity to test whether the derived result of a\n * \t// selector has subsequently changed as the result of a state update.\n * } );\n *\n * // Later, if necessary...\n * unsubscribe();\n * ```\n */\nexport const subscribe = (\n\tlistener: () => void,\n\tstoreNameOrDescriptor?:\n\t\t| string\n\t\t| StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): ( () => void ) =>\n\tdefaultRegistry.subscribe( listener, storeNameOrDescriptor );\n\n/**\n * Registers a generic store instance.\n *\n * @deprecated Use `register( storeDescriptor )` instead.\n *\n * @param {string} name Store registry name.\n * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).\n */\nexport const registerGenericStore: Function =\n\tdefaultRegistry.registerGenericStore;\n\n/**\n * Registers a standard `@wordpress/data` store.\n *\n * @deprecated Use `register` instead.\n *\n * @param {string} storeName Unique namespace identifier for the store.\n * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n *\n * @return {Object} Registered store object.\n */\nexport const registerStore: Function = defaultRegistry.registerStore;\n\n/**\n * Extends a registry to inherit functionality provided by a given plugin. A\n * plugin is an object with properties aligning to that of a registry, merged\n * to extend the default registry behavior.\n *\n * @param {Object} plugin Plugin object.\n */\nexport const use: any = defaultRegistry.use;\n\n/**\n * Registers a standard `@wordpress/data` store descriptor.\n *\n * @example\n * ```js\n * import { createReduxStore, register } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * register( store );\n * ```\n *\n * @param {StoreDescriptor} store Store descriptor.\n */\nexport const register = (\n\tstore: StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): void => defaultRegistry.register( store );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAA4B;AAC5B,cAAyB;AACzB,yBAAyD;AAUzD,yBAAsC;AACtC,2BAAwC;AACxC,2BAAwC;AACxC,+BAIO;AACP,wBAGO;AACP,0BAA4B;AAC5B,iCAAkC;AAClC,sBAA+B;AAC/B,qBAA8D;AAC9D,6BAA+B;AAC/B,sBAAyB;AACzB,IAAAA,sBAA4C;AAC5C,2BAA6B;AAC7B,sBAAyB;AACzB,oBAAuB;AAkDhB,IAAM,kBACZ,mBAAAC;AAsBM,SAAS,cACf,uBACiC;AACjC,SAAO,wBAAAC,QAAgB;AAAA,IACtB;AAAA,EACD;AACD;AAaO,IAAM,gBAAgB,CAC5B,0BAGS,wBAAAA,QAAgB,cAAe,qBAAsB;AA0BxD,IAAM,YAAY,CACxB,UACA,0BAIA,wBAAAA,QAAgB,UAAW,UAAU,qBAAsB;AAUrD,IAAM,uBACZ,wBAAAA,QAAgB;AAYV,IAAM,gBAA0B,wBAAAA,QAAgB;AAShD,IAAM,MAAW,wBAAAA,QAAgB;AAoBjC,IAAM,WAAW,CACvB,UACU,wBAAAA,QAAgB,SAAU,KAAM;",
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport defaultRegistry from './default-registry';\nimport * as plugins from './plugins';\nimport { combineReducers as combineReducersModule } from './redux-store';\n\nimport type {\n\tStoreDescriptor,\n\tReduxStoreConfig,\n\tcombineReducers as CombineReducers,\n\tAnyConfig,\n\tCurriedSelectorsResolveOf,\n} from './types';\n\nexport { default as withSelect } from './components/with-select';\nexport { default as withDispatch } from './components/with-dispatch';\nexport { default as withRegistry } from './components/with-registry';\nexport {\n\tRegistryProvider,\n\tRegistryConsumer,\n\tuseRegistry,\n} from './components/registry-provider';\nexport {\n\tdefault as useSelect,\n\tuseSuspenseSelect,\n} from './components/use-select';\nexport { useDispatch } from './components/use-dispatch';\nexport { AsyncModeProvider } from './components/async-mode-provider';\nexport { createRegistry } from './registry';\nexport { createRegistrySelector, createRegistryControl } from './factory';\nexport { createSelector } from './create-selector';\nexport type { EnhancedSelector, GetDependants } from './create-selector';\nexport { controls } from './controls';\nexport { default as createReduxStore } from './redux-store';\nexport { keyedReducer } from './redux-store/keyed-reducer';\nexport { dispatch } from './dispatch';\nexport { select } from './select';\n\nexport type * from './types';\n\n/**\n * Object of available plugins to use with a registry.\n *\n * @see [use](#use)\n */\nexport { plugins };\n\n/**\n * The combineReducers helper function turns an object whose values are different\n * reducing functions into a single reducing function you can pass to registerReducer.\n *\n * @type {import('./types').combineReducers}\n * @param {Object} reducers An object whose values correspond to different reducing\n * functions that need to be combined into one.\n *\n * @example\n * ```js\n * import { combineReducers, createReduxStore, register } from '@wordpress/data';\n *\n * const prices = ( state = {}, action ) => {\n * \treturn action.type === 'SET_PRICE' ?\n * \t\t{\n * \t\t\t...state,\n * \t\t\t[ action.item ]: action.price,\n * \t\t} :\n * \t\tstate;\n * };\n *\n * const discountPercent = ( state = 0, action ) => {\n * \treturn action.type === 'START_SALE' ?\n * \t\taction.discountPercent :\n * \t\tstate;\n * };\n *\n * const store = createReduxStore( 'my-shop', {\n * \treducer: combineReducers( {\n * \t\tprices,\n * \t\tdiscountPercent,\n * \t} ),\n * } );\n * register( store );\n * ```\n *\n * @return {Function} A reducer that invokes every reducer inside the reducers\n * object, and constructs a state object with the same shape.\n */\nexport const combineReducers =\n\tcombineReducersModule as unknown as CombineReducers;\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors\n * pre-bound to state so that you only need to supply additional arguments, and\n * modified so that they return promises that resolve to their eventual values,\n * after any resolvers have ran.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @example\n * ```js\n * import { resolveSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log)\n * ```\n *\n * @return Object containing the store's promise-wrapped selectors.\n */\nexport function resolveSelect< T extends StoreDescriptor< AnyConfig > >(\n\tstoreNameOrDescriptor: T | string\n): CurriedSelectorsResolveOf< T > {\n\treturn defaultRegistry.resolveSelect(\n\t\tstoreNameOrDescriptor\n\t) as CurriedSelectorsResolveOf< T >;\n}\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors pre-bound to state\n * so that you only need to supply additional arguments, and modified so that they throw promises\n * in case the selector is not resolved yet.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @return {Object} Object containing the store's suspense-wrapped selectors.\n */\nexport const suspendSelect = (\n\tstoreNameOrDescriptor:\n\t\t| string\n\t\t| StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): any => defaultRegistry.suspendSelect( storeNameOrDescriptor );\n\n/**\n * Given a listener function, the function will be called any time the state value\n * of one of the registered stores has changed. If you specify the optional\n * `storeNameOrDescriptor` parameter, the listener function will be called only\n * on updates on that one specific registered store.\n *\n * This function returns an `unsubscribe` function used to stop the subscription.\n *\n * @param {Function} listener Callback function.\n * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n *\n * @example\n * ```js\n * import { subscribe } from '@wordpress/data';\n *\n * const unsubscribe = subscribe( () => {\n * \t// You could use this opportunity to test whether the derived result of a\n * \t// selector has subsequently changed as the result of a state update.\n * } );\n *\n * // Later, if necessary...\n * unsubscribe();\n * ```\n */\nexport const subscribe = (\n\tlistener: () => void,\n\tstoreNameOrDescriptor?:\n\t\t| string\n\t\t| StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): ( () => void ) =>\n\tdefaultRegistry.subscribe( listener, storeNameOrDescriptor );\n\n/**\n * Registers a generic store instance.\n *\n * @deprecated Use `register( storeDescriptor )` instead.\n *\n * @param {string} name Store registry name.\n * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).\n */\nexport const registerGenericStore: Function =\n\tdefaultRegistry.registerGenericStore;\n\n/**\n * Registers a standard `@wordpress/data` store.\n *\n * @deprecated Use `register` instead.\n *\n * @param {string} storeName Unique namespace identifier for the store.\n * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n *\n * @return {Object} Registered store object.\n */\nexport const registerStore: Function = defaultRegistry.registerStore;\n\n/**\n * Extends a registry to inherit functionality provided by a given plugin. A\n * plugin is an object with properties aligning to that of a registry, merged\n * to extend the default registry behavior.\n *\n * @param {Object} plugin Plugin object.\n */\nexport const use: any = defaultRegistry.use;\n\n/**\n * Registers a standard `@wordpress/data` store descriptor.\n *\n * @example\n * ```js\n * import { createReduxStore, register } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * register( store );\n * ```\n *\n * @param {StoreDescriptor} store Store descriptor.\n */\nexport const register = (\n\tstore: StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): void => defaultRegistry.register( store );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAA4B;AAC5B,cAAyB;AACzB,yBAAyD;AAUzD,yBAAsC;AACtC,2BAAwC;AACxC,2BAAwC;AACxC,+BAIO;AACP,wBAGO;AACP,0BAA4B;AAC5B,iCAAkC;AAClC,sBAA+B;AAC/B,qBAA8D;AAC9D,6BAA+B;AAE/B,sBAAyB;AACzB,IAAAA,sBAA4C;AAC5C,2BAA6B;AAC7B,sBAAyB;AACzB,oBAAuB;AAkDhB,IAAM,kBACZ,mBAAAC;AAsBM,SAAS,cACf,uBACiC;AACjC,SAAO,wBAAAC,QAAgB;AAAA,IACtB;AAAA,EACD;AACD;AAaO,IAAM,gBAAgB,CAC5B,0BAGS,wBAAAA,QAAgB,cAAe,qBAAsB;AA0BxD,IAAM,YAAY,CACxB,UACA,0BAIA,wBAAAA,QAAgB,UAAW,UAAU,qBAAsB;AAUrD,IAAM,uBACZ,wBAAAA,QAAgB;AAYV,IAAM,gBAA0B,wBAAAA,QAAgB;AAShD,IAAM,MAAW,wBAAAA,QAAgB;AAoBjC,IAAM,WAAW,CACvB,UACU,wBAAAA,QAAgB,SAAU,KAAM;",
6
6
  "names": ["import_redux_store", "combineReducersModule", "defaultRegistry"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/registry.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\nimport { lock, unlock } from './lock-unlock';\nimport type {\n\tStoreDescriptor,\n\tStoreNameOrDescriptor,\n\tDataRegistry,\n\tDataPlugin,\n\tInternalStoreInstance,\n\tAnyConfig,\n\tReduxStoreConfig,\n} from './types';\n\nfunction getStoreName( storeNameOrDescriptor: StoreNameOrDescriptor ): string {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param storeConfigs Initial store configurations.\n * @param parent Parent registry.\n *\n * @return Data registry.\n */\nexport function createRegistry(\n\tstoreConfigs: Record< string, ReduxStoreConfig< any, any, any > > = {},\n\tparent: DataRegistry | null = null\n): DataRegistry {\n\tconst stores: Record< string, InternalStoreInstance > = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores: Set< string > | null = null;\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data, either in all stores in registry, or\n\t * in one specific store.\n\t *\n\t * @param listener Listener function.\n\t * @param storeNameOrDescriptor Optional store name.\n\t *\n\t * @return Unsubscribe function.\n\t */\n\tconst subscribe = (\n\t\tlistener: () => void,\n\t\tstoreNameOrDescriptor?: StoreNameOrDescriptor\n\t): ( () => void ) => {\n\t\t// subscribe to all stores\n\t\tif ( ! storeNameOrDescriptor ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\t// subscribe to one store\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.subscribe( listener );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to global `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\treturn parent.subscribe( listener, storeNameOrDescriptor );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores< T >(\n\t\tthis: DataRegistry,\n\t\tcallback: () => T,\n\t\tref: { current: string[] | null }\n\t): T {\n\t\tlisteningStores = new Set();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t\tlisteningStores = null;\n\t\t}\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they return\n\t * promises that resolve to their eventual values, after any resolvers have ran.\n\t *\n\t * @param storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors!();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they throw\n\t * promises in case the selector is not resolved yet.\n\t *\n\t * @param storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors!();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\tfunction withPlugins(\n\t\tattributes: Record< string, unknown >\n\t): Record< string, unknown > {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( attributes ).map( ( [ key, attribute ] ) => {\n\t\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\t\treturn [ key, attribute ];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tkey,\n\t\t\t\t\t( ...args: unknown[] ) => {\n\t\t\t\t\t\treturn ( registry as any )[ key ]( ...args );\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t} )\n\t\t);\n\t}\n\n\t/**\n\t * Registers a store instance.\n\t *\n\t * @param name Store registry name.\n\t * @param createStoreFunc Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance(\n\t\tname: string,\n\t\tcreateStoreFunc: () => InternalStoreInstance\n\t): InternalStoreInstance {\n\t\tif ( stores[ name ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'Store \"' + name + '\" is already registered.' );\n\t\t\treturn stores[ name ];\n\t\t}\n\n\t\tconst store: any = createStoreFunc();\n\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener: () => void ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\n\t\t// Copy private actions and selectors from the parent store.\n\t\tif ( parent ) {\n\t\t\ttry {\n\t\t\t\tunlock( store.store ).registerPrivateActions(\n\t\t\t\t\tunlock( parent ).privateActionsOf( name )\n\t\t\t\t);\n\t\t\t\tunlock( store.store ).registerPrivateSelectors(\n\t\t\t\t\tunlock( parent ).privateSelectorsOf( name )\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\t// unlock() throws if store.store was not locked.\n\t\t\t\t// The error indicates there's nothing to do here so let's\n\t\t\t\t// ignore it.\n\t\t\t}\n\t\t}\n\n\t\treturn store;\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param store Store descriptor.\n\t */\n\tfunction register( store: StoreDescriptor< AnyConfig > ) {\n\t\tregisterStoreInstance(\n\t\t\tstore.name,\n\t\t\t() => store.instantiate( registry ) as InternalStoreInstance\n\t\t);\n\t}\n\n\tfunction registerGenericStore(\n\t\tname: string,\n\t\tstore: InternalStoreInstance\n\t) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, () => store );\n\t}\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param storeName Unique namespace identifier.\n\t * @param options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return Registered store object.\n\t */\n\tfunction registerStore(\n\t\tstoreName: string,\n\t\toptions: ReduxStoreConfig< any, any, any >\n\t) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance(\n\t\t\tstoreName,\n\t\t\t() =>\n\t\t\t\tcreateReduxStore( storeName, options ).instantiate(\n\t\t\t\t\tregistry\n\t\t\t\t) as InternalStoreInstance\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback: () => void ) {\n\t\t// If we're already batching, just call the callback.\n\t\tif ( emitter.isPaused ) {\n\t\t\tcallback();\n\t\t\treturn;\n\t\t}\n\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\temitter.resume();\n\t\t\tObject.values( stores ).forEach( ( store ) =>\n\t\t\t\tstore.emitter.resume()\n\t\t\t);\n\t\t}\n\t}\n\n\tlet registry: DataRegistry = {\n\t\tbatch,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t} as DataRegistry;\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\tfunction use( plugin: DataPlugin, options?: Record< string, unknown > ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( name, config ) );\n\t}\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\tconst registryWithPlugins = withPlugins(\n\t\tregistry as unknown as Record< string, unknown >\n\t);\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name: string ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch {\n\t\t\t\t// unlock() throws an error the store was not locked \u2013 this means\n\t\t\t\t// there no private actions are available\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t\tprivateSelectorsOf: ( name: string ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins as unknown as DataRegistry;\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\nimport { lock, unlock } from './lock-unlock';\nimport type {\n\tStoreDescriptor,\n\tStoreNameOrDescriptor,\n\tDataRegistry,\n\tDataPlugin,\n\tInternalStoreInstance,\n\tAnyConfig,\n\tReduxStoreConfig,\n} from './types';\n\nfunction getStoreName( storeNameOrDescriptor: StoreNameOrDescriptor ): string {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param storeConfigs Initial store configurations.\n * @param parent Parent registry.\n *\n * @return Data registry.\n */\nexport function createRegistry(\n\tstoreConfigs: Record< string, ReduxStoreConfig< any, any, any > > = {},\n\tparent: DataRegistry | null = null\n): DataRegistry {\n\tconst stores: Record< string, InternalStoreInstance > = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores: Set< string > | null = null;\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data, either in all stores in registry, or\n\t * in one specific store.\n\t *\n\t * @param listener Listener function.\n\t * @param storeNameOrDescriptor Optional store name.\n\t *\n\t * @return Unsubscribe function.\n\t */\n\tconst subscribe = (\n\t\tlistener: () => void,\n\t\tstoreNameOrDescriptor?: StoreNameOrDescriptor\n\t): ( () => void ) => {\n\t\t// subscribe to all stores\n\t\tif ( ! storeNameOrDescriptor ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\t// subscribe to one store\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.subscribe( listener );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to global `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\treturn parent.subscribe( listener, storeNameOrDescriptor );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores< T >(\n\t\tthis: DataRegistry,\n\t\tcallback: () => T,\n\t\tref: { current: string[] | null }\n\t): T {\n\t\tlisteningStores = new Set();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t\tlisteningStores = null;\n\t\t}\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they return\n\t * promises that resolve to their eventual values, after any resolvers have ran.\n\t *\n\t * @param storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors!();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they throw\n\t * promises in case the selector is not resolved yet.\n\t *\n\t * @param storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors!();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\tfunction withPlugins(\n\t\tattributes: Record< string, unknown >\n\t): Record< string, unknown > {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( attributes ).map( ( [ key, attribute ] ) => {\n\t\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\t\treturn [ key, attribute ];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tkey,\n\t\t\t\t\t( ...args: unknown[] ) => {\n\t\t\t\t\t\treturn ( registry as any )[ key ]( ...args );\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t} )\n\t\t);\n\t}\n\n\t/**\n\t * Registers a store instance.\n\t *\n\t * @param name Store registry name.\n\t * @param createStoreFunc Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance(\n\t\tname: string,\n\t\tcreateStoreFunc: () => InternalStoreInstance\n\t): InternalStoreInstance {\n\t\tif ( stores[ name ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'Store \"' + name + '\" is already registered.' );\n\t\t\treturn stores[ name ];\n\t\t}\n\n\t\tconst store: any = createStoreFunc();\n\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener: () => void ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\n\t\t// Copy private actions and selectors from the parent store.\n\t\tif ( parent ) {\n\t\t\ttry {\n\t\t\t\tunlock( store.store ).registerPrivateActions(\n\t\t\t\t\tunlock( parent ).privateActionsOf( name )\n\t\t\t\t);\n\t\t\t\tunlock( store.store ).registerPrivateSelectors(\n\t\t\t\t\tunlock( parent ).privateSelectorsOf( name )\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\t// unlock() throws if store.store was not locked.\n\t\t\t\t// The error indicates there's nothing to do here so let's\n\t\t\t\t// ignore it.\n\t\t\t}\n\t\t}\n\n\t\treturn store;\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param store Store descriptor.\n\t */\n\tfunction register( store: StoreDescriptor< AnyConfig > ) {\n\t\tregisterStoreInstance(\n\t\t\tstore.name,\n\t\t\t() => store.instantiate( registry ) as InternalStoreInstance\n\t\t);\n\t}\n\n\tfunction registerGenericStore(\n\t\tname: string,\n\t\tstore: InternalStoreInstance\n\t) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, () => store );\n\t}\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param storeName Unique namespace identifier.\n\t * @param options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return Registered store object.\n\t */\n\tfunction registerStore(\n\t\tstoreName: string,\n\t\toptions: ReduxStoreConfig< any, any, any >\n\t) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance(\n\t\t\tstoreName,\n\t\t\t() =>\n\t\t\t\tcreateReduxStore( storeName, options ).instantiate(\n\t\t\t\t\tregistry\n\t\t\t\t) as InternalStoreInstance\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback: () => void ) {\n\t\t// If we're already batching, just call the callback.\n\t\tif ( emitter.isPaused ) {\n\t\t\tcallback();\n\t\t\treturn;\n\t\t}\n\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\temitter.resume();\n\t\t\tObject.values( stores ).forEach( ( store ) =>\n\t\t\t\tstore.emitter.resume()\n\t\t\t);\n\t\t}\n\t}\n\n\tlet registry: DataRegistry = {\n\t\tbatch,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t} as DataRegistry;\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\tfunction use( plugin: DataPlugin, options?: Record< string, unknown > ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( name, config ) );\n\t}\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\tconst registryWithPlugins = withPlugins(\n\t\tregistry as unknown as Record< string, unknown >\n\t);\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name: string ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch {\n\t\t\t\t// unlock() throws an error the store was not locked – this means\n\t\t\t\t// there no private actions are available\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t\tprivateSelectorsOf: ( name: string ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins as unknown as DataRegistry;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAuB;AAKvB,yBAA6B;AAC7B,mBAA0B;AAC1B,qBAA8B;A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  "names": ["deprecated", "createReduxStore", "coreDataStore"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/types.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\n\nimport type {\n\t// eslint-disable-next-line no-restricted-imports\n\tcombineReducers as reduxCombineReducers,\n\tStore as ReduxStore,\n} from 'redux';\n\n/**\n * Internal dependencies\n */\nimport type { DataEmitter } from './utils/emitter';\nimport type {\n\tMetadataSelectors,\n\tMetadataActions,\n} from './redux-store/metadata/types';\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< State, ActionCreators, Selectors > {\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< 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< 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? {\n\t\t\t[ key in keyof Selectors ]: CurriedState< Selectors[ key ] >;\n\t } & MetadataSelectors< S >\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\n/**\n * A store name or store descriptor, used throughout the API.\n */\nexport type StoreNameOrDescriptor = string | StoreDescriptor;\n\n/**\n * An isolated orchestrator of store registrations.\n *\n * Returned by `createRegistry`. Provides methods to register stores,\n * select data, dispatch actions, and subscribe to changes.\n */\nexport interface DataRegistry {\n\tbatch: ( callback: () => void ) => void;\n\tstores: Record< string, InternalStoreInstance >;\n\tnamespaces: Record< string, InternalStoreInstance >;\n\tsubscribe: (\n\t\tlistener: ListenerFunction,\n\t\tstoreNameOrDescriptor?: StoreNameOrDescriptor\n\t) => () => void;\n\tselect: {\n\t\t< S extends StoreDescriptor< any > >(\n\t\t\tstore: S\n\t\t): CurriedSelectorsOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => any >;\n\t};\n\tresolveSelect: {\n\t\t< S extends StoreDescriptor< any > >(\n\t\t\tstore: S\n\t\t): CurriedSelectorsResolveOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => Promise< any > >;\n\t};\n\tsuspendSelect: {\n\t\t< S extends StoreDescriptor< any > >(\n\t\t\tstore: S\n\t\t): CurriedSelectorsOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => any >;\n\t};\n\tdispatch: {\n\t\t< S extends StoreDescriptor< any > >( store: S ): ActionCreatorsOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => any >;\n\t};\n\tuse: (\n\t\tplugin: DataPlugin,\n\t\toptions?: Record< string, unknown >\n\t) => DataRegistry;\n\tregister: ( store: StoreDescriptor< any > ) => void;\n\tregisterGenericStore: (\n\t\tname: string,\n\t\tstore: StoreInstance< AnyConfig >\n\t) => void;\n\tregisterStore: (\n\t\tstoreName: string,\n\t\toptions: ReduxStoreConfig< any, any, any >\n\t) => ReduxStore;\n\t__unstableMarkListeningStores: < T >(\n\t\tcallback: () => T,\n\t\tref: { current: string[] | null }\n\t) => T;\n}\n\n/**\n * The plugin function signature.\n */\nexport type DataPlugin = (\n\tregistry: DataRegistry,\n\toptions?: Record< string, unknown >\n) => Partial< DataRegistry >;\n\n/**\n * Status of a selector resolution.\n */\nexport type ResolutionStatus = 'resolving' | 'finished' | 'error';\n\n/**\n * State value for a single resolution.\n */\nexport type ResolutionState =\n\t| { status: 'resolving' }\n\t| { status: 'finished' }\n\t| { status: 'error'; error: Error | unknown };\n\n/**\n * A normalized resolver with a `fulfill` method and optional `isFulfilled`.\n */\nexport interface NormalizedResolver {\n\t/**\n\t * The function to call to fulfill the resolver.\n\t */\n\tfulfill: ( ...args: any[] ) => any;\n\t/**\n\t * Optional function to check if the resolver is already fulfilled.\n\t */\n\tisFulfilled?: ( state: any, ...args: any[] ) => boolean;\n\t/**\n\t * Optional function to check if the resolver should be invalidated.\n\t */\n\tshouldInvalidate?: ( action: any, ...args: any[] ) => boolean;\n}\n\n/**\n * A bound selector with optional resolver metadata.\n */\nexport interface BoundSelector {\n\t( ...args: any[] ): any;\n\t/**\n\t * Whether this selector has a resolver attached.\n\t */\n\thasResolver: boolean;\n\t/**\n\t * Optional function to normalize the arguments.\n\t */\n\t__unstableNormalizeArgs?: ( args: any[] ) => any[];\n\t/**\n\t * Whether this selector is a registry selector.\n\t */\n\tisRegistrySelector?: boolean;\n\t/**\n\t * The registry instance this selector is bound to.\n\t */\n\tregistry?: DataRegistry;\n}\n\n/**\n * The shape of a store instance as seen internally by the registry.\n * Extends the public StoreInstance with additional internal properties.\n */\nexport interface InternalStoreInstance< Config extends AnyConfig = AnyConfig >\n\textends StoreInstance< Config > {\n\t/**\n\t * The Redux store instance (only for Redux-based stores).\n\t */\n\tstore?: ReduxStore;\n\t/**\n\t * The internal emitter for pause/resume batching.\n\t */\n\temitter: DataEmitter;\n\t/**\n\t * The combined reducer.\n\t */\n\treducer?: ( state: any, action: any ) => any;\n\t/**\n\t * Bound actions object.\n\t */\n\tactions?: Record< string, ActionCreator >;\n\t/**\n\t * Bound selectors object.\n\t */\n\tselectors?: Record< string, Selector >;\n\t/**\n\t * Resolver definitions.\n\t */\n\tresolvers?: Record< string, NormalizedResolver >;\n\t/**\n\t * Returns resolve-wrapped selectors.\n\t */\n\tgetResolveSelectors?: () => Record<\n\t\tstring,\n\t\t( ...args: any[] ) => Promise< any >\n\t>;\n\t/**\n\t * Returns suspense-wrapped selectors.\n\t */\n\tgetSuspendSelectors?: () => Record< string, ( ...args: any[] ) => any >;\n}\n\n/**\n * Control descriptor for the controls system.\n */\nexport interface ControlDescriptor {\n\t/**\n\t * The type of the control action.\n\t */\n\ttype: string;\n\t/**\n\t * The store key to target.\n\t */\n\tstoreKey: string;\n\t/**\n\t * The name of the selector (for select/resolveSelect controls).\n\t */\n\tselectorName?: string;\n\t/**\n\t * The name of the action (for dispatch controls).\n\t */\n\tactionName?: string;\n\t/**\n\t * Arguments for the selector or action.\n\t */\n\targs: any[];\n}\n\n/**\n * Storage interface (Web Storage API subset).\n */\nexport interface StorageInterface {\n\tgetItem: ( key: string ) => string | null;\n\tsetItem: ( key: string, value: string ) => void;\n\tremoveItem?: ( key: string ) => void;\n\tclear?: VoidFunction;\n}\n\n// Type Helpers.\n\nexport type ConfigOf< S > = S extends StoreDescriptor< infer C > ? C : never;\n\nexport type ActionCreatorsOf< T > = T extends StoreDescriptor<\n\tReduxStoreConfig< any, infer ActionCreators, any >\n>\n\t? PromisifiedActionCreators< ActionCreators > & MetadataActions< T >\n\t: T extends ReduxStoreConfig< any, infer ActionCreators, any >\n\t? PromisifiedActionCreators< ActionCreators >\n\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< ActionCreators > = {\n\t[ Action in keyof ActionCreators ]: ActionCreators[ Action ] extends ActionCreator\n\t\t? PromisifyActionCreator< ActionCreators[ Action ] >\n\t\t: ActionCreators[ Action ];\n};\n\n// Wraps action creator return types with a Promise and handles thunks and generators.\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 > extends Generator< any, infer TReturn, any >\n\t\t? TReturn\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\n/**\n * The argument object passed to every thunk function. When parameterized with\n * a store descriptor, `dispatch`, `select`, and `resolveSelect` are fully\n * typed against that store's actions and selectors.\n *\n * @example\n * ```ts\n * const myAction =\n * ( id: number ) =>\n * async ( { dispatch, select }: ThunkArgs< typeof myStore > ) => {\n * const record = select.getRecord( id );\n * dispatch.setLoading( true );\n * };\n * ```\n */\nexport interface ThunkArgs<\n\tS extends StoreDescriptor = StoreDescriptor,\n\tPrivateSelectors extends Record< string, Function > = {},\n\tPrivateActions extends Record< string, ActionCreator > = {},\n> {\n\tdispatch: ActionCreatorsOf< S > &\n\t\tPromisifiedActionCreators< PrivateActions > & {\n\t\t\t< R >( thunk: ( ...args: any[] ) => R ): R;\n\t\t\t( action: Record< string, unknown > ): unknown;\n\t\t};\n\tselect: CurriedSelectorsOf< S > & {\n\t\t[ key in keyof PrivateSelectors ]: CurriedState<\n\t\t\tPrivateSelectors[ key ]\n\t\t>;\n\t};\n\tresolveSelect: CurriedSelectorsResolveOf< S >;\n\tregistry: DataRegistry;\n}\n\nexport type combineReducers = typeof reduxCombineReducers;\n"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\n\nimport type {\n\t// eslint-disable-next-line no-restricted-imports\n\tcombineReducers as reduxCombineReducers,\n\tStore as ReduxStore,\n} from 'redux';\n\n/**\n * Internal dependencies\n */\nimport type { DataEmitter } from './utils/emitter';\nimport type {\n\tMetadataSelectors,\n\tMetadataActions,\n} from './redux-store/metadata/types';\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< State, ActionCreators, Selectors > {\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< 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< 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? {\n\t\t\t[ key in keyof Selectors ]: CurriedState< Selectors[ key ] >;\n\t } & MetadataSelectors< S >\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(…)`.\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\n/**\n * A store name or store descriptor, used throughout the API.\n */\nexport type StoreNameOrDescriptor = string | StoreDescriptor;\n\n/**\n * An isolated orchestrator of store registrations.\n *\n * Returned by `createRegistry`. Provides methods to register stores,\n * select data, dispatch actions, and subscribe to changes.\n */\nexport interface DataRegistry {\n\tbatch: ( callback: () => void ) => void;\n\tstores: Record< string, InternalStoreInstance >;\n\tnamespaces: Record< string, InternalStoreInstance >;\n\tsubscribe: (\n\t\tlistener: ListenerFunction,\n\t\tstoreNameOrDescriptor?: StoreNameOrDescriptor\n\t) => () => void;\n\tselect: {\n\t\t< S extends StoreDescriptor< any > >(\n\t\t\tstore: S\n\t\t): CurriedSelectorsOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => any >;\n\t};\n\tresolveSelect: {\n\t\t< S extends StoreDescriptor< any > >(\n\t\t\tstore: S\n\t\t): CurriedSelectorsResolveOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => Promise< any > >;\n\t};\n\tsuspendSelect: {\n\t\t< S extends StoreDescriptor< any > >(\n\t\t\tstore: S\n\t\t): CurriedSelectorsOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => any >;\n\t};\n\tdispatch: {\n\t\t< S extends StoreDescriptor< any > >( store: S ): ActionCreatorsOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => any >;\n\t};\n\tuse: (\n\t\tplugin: DataPlugin,\n\t\toptions?: Record< string, unknown >\n\t) => DataRegistry;\n\tregister: ( store: StoreDescriptor< any > ) => void;\n\tregisterGenericStore: (\n\t\tname: string,\n\t\tstore: StoreInstance< AnyConfig >\n\t) => void;\n\tregisterStore: (\n\t\tstoreName: string,\n\t\toptions: ReduxStoreConfig< any, any, any >\n\t) => ReduxStore;\n\t__unstableMarkListeningStores: < T >(\n\t\tcallback: () => T,\n\t\tref: { current: string[] | null }\n\t) => T;\n}\n\n/**\n * The plugin function signature.\n */\nexport type DataPlugin = (\n\tregistry: DataRegistry,\n\toptions?: Record< string, unknown >\n) => Partial< DataRegistry >;\n\n/**\n * Status of a selector resolution.\n */\nexport type ResolutionStatus = 'resolving' | 'finished' | 'error';\n\n/**\n * State value for a single resolution.\n */\nexport type ResolutionState =\n\t| { status: 'resolving' }\n\t| { status: 'finished' }\n\t| { status: 'error'; error: Error | unknown };\n\n/**\n * A normalized resolver with a `fulfill` method and optional `isFulfilled`.\n */\nexport interface NormalizedResolver {\n\t/**\n\t * The function to call to fulfill the resolver.\n\t */\n\tfulfill: ( ...args: any[] ) => any;\n\t/**\n\t * Optional function to check if the resolver is already fulfilled.\n\t */\n\tisFulfilled?: ( state: any, ...args: any[] ) => boolean;\n\t/**\n\t * Optional function to check if the resolver should be invalidated.\n\t */\n\tshouldInvalidate?: ( action: any, ...args: any[] ) => boolean;\n}\n\n/**\n * A bound selector with optional resolver metadata.\n */\nexport interface BoundSelector {\n\t( ...args: any[] ): any;\n\t/**\n\t * Whether this selector has a resolver attached.\n\t */\n\thasResolver: boolean;\n\t/**\n\t * Optional function to normalize the arguments.\n\t */\n\t__unstableNormalizeArgs?: ( args: any[] ) => any[];\n\t/**\n\t * Whether this selector is a registry selector.\n\t */\n\tisRegistrySelector?: boolean;\n\t/**\n\t * The registry instance this selector is bound to.\n\t */\n\tregistry?: DataRegistry;\n}\n\n/**\n * The shape of a store instance as seen internally by the registry.\n * Extends the public StoreInstance with additional internal properties.\n */\nexport interface InternalStoreInstance< Config extends AnyConfig = AnyConfig >\n\textends StoreInstance< Config > {\n\t/**\n\t * The Redux store instance (only for Redux-based stores).\n\t */\n\tstore?: ReduxStore;\n\t/**\n\t * The internal emitter for pause/resume batching.\n\t */\n\temitter: DataEmitter;\n\t/**\n\t * The combined reducer.\n\t */\n\treducer?: ( state: any, action: any ) => any;\n\t/**\n\t * Bound actions object.\n\t */\n\tactions?: Record< string, ActionCreator >;\n\t/**\n\t * Bound selectors object.\n\t */\n\tselectors?: Record< string, Selector >;\n\t/**\n\t * Resolver definitions.\n\t */\n\tresolvers?: Record< string, NormalizedResolver >;\n\t/**\n\t * Returns resolve-wrapped selectors.\n\t */\n\tgetResolveSelectors?: () => Record<\n\t\tstring,\n\t\t( ...args: any[] ) => Promise< any >\n\t>;\n\t/**\n\t * Returns suspense-wrapped selectors.\n\t */\n\tgetSuspendSelectors?: () => Record< string, ( ...args: any[] ) => any >;\n}\n\n/**\n * Control descriptor for the controls system.\n */\nexport interface ControlDescriptor {\n\t/**\n\t * The type of the control action.\n\t */\n\ttype: string;\n\t/**\n\t * The store key to target.\n\t */\n\tstoreKey: string;\n\t/**\n\t * The name of the selector (for select/resolveSelect controls).\n\t */\n\tselectorName?: string;\n\t/**\n\t * The name of the action (for dispatch controls).\n\t */\n\tactionName?: string;\n\t/**\n\t * Arguments for the selector or action.\n\t */\n\targs: any[];\n}\n\n/**\n * Storage interface (Web Storage API subset).\n */\nexport interface StorageInterface {\n\tgetItem: ( key: string ) => string | null;\n\tsetItem: ( key: string, value: string ) => void;\n\tremoveItem?: ( key: string ) => void;\n\tclear?: VoidFunction;\n}\n\n// Type Helpers.\n\nexport type ConfigOf< S > = S extends StoreDescriptor< infer C > ? C : never;\n\nexport type ActionCreatorsOf< T > = T extends StoreDescriptor<\n\tReduxStoreConfig< any, infer ActionCreators, any >\n>\n\t? PromisifiedActionCreators< ActionCreators > & MetadataActions< T >\n\t: T extends ReduxStoreConfig< any, infer ActionCreators, any >\n\t? PromisifiedActionCreators< ActionCreators >\n\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< ActionCreators > = {\n\t[ Action in keyof ActionCreators ]: ActionCreators[ Action ] extends ActionCreator\n\t\t? PromisifyActionCreator< ActionCreators[ Action ] >\n\t\t: ActionCreators[ Action ];\n};\n\n// Wraps action creator return types with a Promise and handles thunks and generators.\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 > extends Generator< any, infer TReturn, any >\n\t\t? TReturn\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\n/**\n * The argument object passed to every thunk function. When parameterized with\n * a store descriptor, `dispatch`, `select`, and `resolveSelect` are fully\n * typed against that store's actions and selectors.\n *\n * @example\n * ```ts\n * const myAction =\n * ( id: number ) =>\n * async ( { dispatch, select }: ThunkArgs< typeof myStore > ) => {\n * const record = select.getRecord( id );\n * dispatch.setLoading( true );\n * };\n * ```\n */\nexport interface ThunkArgs<\n\tS extends StoreDescriptor = StoreDescriptor,\n\tPrivateSelectors extends Record< string, Function > = {},\n\tPrivateActions extends Record< string, ActionCreator > = {},\n> {\n\tdispatch: ActionCreatorsOf< S > &\n\t\tPromisifiedActionCreators< PrivateActions > & {\n\t\t\t< R >( thunk: ( ...args: any[] ) => R ): R;\n\t\t\t( action: Record< string, unknown > ): unknown;\n\t\t};\n\tselect: CurriedSelectorsOf< S > & {\n\t\t[ key in keyof PrivateSelectors ]: CurriedState<\n\t\t\tPrivateSelectors[ key ]\n\t\t>;\n\t};\n\tresolveSelect: CurriedSelectorsResolveOf< S >;\n\tregistry: DataRegistry;\n}\n\nexport type combineReducers = typeof reduxCombineReducers;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,7 @@
1
1
  // packages/data/src/create-selector.ts
2
- import { default as default2 } from "rememo";
2
+ import memoize from "rememo";
3
+ var createSelector = memoize;
3
4
  export {
4
- default2 as createSelector
5
+ createSelector
5
6
  };
6
7
  //# sourceMappingURL=create-selector.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/create-selector.ts"],
4
- "sourcesContent": ["/**\n * Creates a memoized selector that caches the computed values according to the array of \"dependants\"\n * and the selector parameters, and recomputes the values only when any of them changes.\n *\n * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.\n */\nexport { default as createSelector } from 'rememo';\n"],
5
- "mappings": ";AAMA,SAAoB,WAAXA,gBAAiC;",
6
- "names": ["default"]
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport memoize from 'rememo';\n\n/**\n * Returns the array of immutable references on which a memoized selector\n * depends for computing its result. The memoize cache is preserved only as\n * long as those dependant references remain the same.\n */\nexport type GetDependants = ( ...args: any[] ) => any[];\n\n/**\n * The memoization methods a selector returned by `createSelector` is\n * enhanced with.\n */\nexport interface EnhancedSelector {\n\tgetDependants: GetDependants;\n\n\t/**\n\t * Clears the memoization cache.\n\t */\n\tclear: () => void;\n}\n\n/*\n * The signature mirrors `rememo`'s, but is declared here so that consumers'\n * emitted declarations reference `@wordpress/data` rather than `rememo`,\n * which they do not declare as a dependency.\n */\n\n/**\n * Creates a memoized selector that caches the computed values according to the array of \"dependants\"\n * and the selector parameters, and recomputes the values only when any of them changes.\n *\n * See The documentation for the `rememo` package from which the `createSelector` function is reexported.\n */\nexport const createSelector: < S extends ( ...args: any[] ) => any >(\n\tselector: S,\n\tgetDependants?: GetDependants\n) => S & EnhancedSelector = memoize;\n"],
5
+ "mappings": ";AAGA,OAAO,aAAa;AAkCb,IAAM,iBAGe;",
6
+ "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport defaultRegistry from './default-registry';\nimport * as plugins from './plugins';\nimport { combineReducers as combineReducersModule } from './redux-store';\n\nimport type {\n\tStoreDescriptor,\n\tReduxStoreConfig,\n\tcombineReducers as CombineReducers,\n\tAnyConfig,\n\tCurriedSelectorsResolveOf,\n} from './types';\n\nexport { default as withSelect } from './components/with-select';\nexport { default as withDispatch } from './components/with-dispatch';\nexport { default as withRegistry } from './components/with-registry';\nexport {\n\tRegistryProvider,\n\tRegistryConsumer,\n\tuseRegistry,\n} from './components/registry-provider';\nexport {\n\tdefault as useSelect,\n\tuseSuspenseSelect,\n} from './components/use-select';\nexport { useDispatch } from './components/use-dispatch';\nexport { AsyncModeProvider } from './components/async-mode-provider';\nexport { createRegistry } from './registry';\nexport { createRegistrySelector, createRegistryControl } from './factory';\nexport { createSelector } from './create-selector';\nexport { controls } from './controls';\nexport { default as createReduxStore } from './redux-store';\nexport { keyedReducer } from './redux-store/keyed-reducer';\nexport { dispatch } from './dispatch';\nexport { select } from './select';\n\nexport type * from './types';\n\n/**\n * Object of available plugins to use with a registry.\n *\n * @see [use](#use)\n */\nexport { plugins };\n\n/**\n * The combineReducers helper function turns an object whose values are different\n * reducing functions into a single reducing function you can pass to registerReducer.\n *\n * @type {import('./types').combineReducers}\n * @param {Object} reducers An object whose values correspond to different reducing\n * functions that need to be combined into one.\n *\n * @example\n * ```js\n * import { combineReducers, createReduxStore, register } from '@wordpress/data';\n *\n * const prices = ( state = {}, action ) => {\n * \treturn action.type === 'SET_PRICE' ?\n * \t\t{\n * \t\t\t...state,\n * \t\t\t[ action.item ]: action.price,\n * \t\t} :\n * \t\tstate;\n * };\n *\n * const discountPercent = ( state = 0, action ) => {\n * \treturn action.type === 'START_SALE' ?\n * \t\taction.discountPercent :\n * \t\tstate;\n * };\n *\n * const store = createReduxStore( 'my-shop', {\n * \treducer: combineReducers( {\n * \t\tprices,\n * \t\tdiscountPercent,\n * \t} ),\n * } );\n * register( store );\n * ```\n *\n * @return {Function} A reducer that invokes every reducer inside the reducers\n * object, and constructs a state object with the same shape.\n */\nexport const combineReducers =\n\tcombineReducersModule as unknown as CombineReducers;\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors\n * pre-bound to state so that you only need to supply additional arguments, and\n * modified so that they return promises that resolve to their eventual values,\n * after any resolvers have ran.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @example\n * ```js\n * import { resolveSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log)\n * ```\n *\n * @return Object containing the store's promise-wrapped selectors.\n */\nexport function resolveSelect< T extends StoreDescriptor< AnyConfig > >(\n\tstoreNameOrDescriptor: T | string\n): CurriedSelectorsResolveOf< T > {\n\treturn defaultRegistry.resolveSelect(\n\t\tstoreNameOrDescriptor\n\t) as CurriedSelectorsResolveOf< T >;\n}\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors pre-bound to state\n * so that you only need to supply additional arguments, and modified so that they throw promises\n * in case the selector is not resolved yet.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @return {Object} Object containing the store's suspense-wrapped selectors.\n */\nexport const suspendSelect = (\n\tstoreNameOrDescriptor:\n\t\t| string\n\t\t| StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): any => defaultRegistry.suspendSelect( storeNameOrDescriptor );\n\n/**\n * Given a listener function, the function will be called any time the state value\n * of one of the registered stores has changed. If you specify the optional\n * `storeNameOrDescriptor` parameter, the listener function will be called only\n * on updates on that one specific registered store.\n *\n * This function returns an `unsubscribe` function used to stop the subscription.\n *\n * @param {Function} listener Callback function.\n * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n *\n * @example\n * ```js\n * import { subscribe } from '@wordpress/data';\n *\n * const unsubscribe = subscribe( () => {\n * \t// You could use this opportunity to test whether the derived result of a\n * \t// selector has subsequently changed as the result of a state update.\n * } );\n *\n * // Later, if necessary...\n * unsubscribe();\n * ```\n */\nexport const subscribe = (\n\tlistener: () => void,\n\tstoreNameOrDescriptor?:\n\t\t| string\n\t\t| StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): ( () => void ) =>\n\tdefaultRegistry.subscribe( listener, storeNameOrDescriptor );\n\n/**\n * Registers a generic store instance.\n *\n * @deprecated Use `register( storeDescriptor )` instead.\n *\n * @param {string} name Store registry name.\n * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).\n */\nexport const registerGenericStore: Function =\n\tdefaultRegistry.registerGenericStore;\n\n/**\n * Registers a standard `@wordpress/data` store.\n *\n * @deprecated Use `register` instead.\n *\n * @param {string} storeName Unique namespace identifier for the store.\n * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n *\n * @return {Object} Registered store object.\n */\nexport const registerStore: Function = defaultRegistry.registerStore;\n\n/**\n * Extends a registry to inherit functionality provided by a given plugin. A\n * plugin is an object with properties aligning to that of a registry, merged\n * to extend the default registry behavior.\n *\n * @param {Object} plugin Plugin object.\n */\nexport const use: any = defaultRegistry.use;\n\n/**\n * Registers a standard `@wordpress/data` store descriptor.\n *\n * @example\n * ```js\n * import { createReduxStore, register } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * register( store );\n * ```\n *\n * @param {StoreDescriptor} store Store descriptor.\n */\nexport const register = (\n\tstore: StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): void => defaultRegistry.register( store );\n"],
5
- "mappings": ";AAGA,OAAO,qBAAqB;AAC5B,YAAY,aAAa;AACzB,SAAS,mBAAmB,6BAA6B;AAUzD,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAA+B;AACxC,SAAoB,WAAXA,gBAA+B;AACxC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB,6BAA6B;AAC9D,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAoB,WAAXA,gBAAmC;AAC5C,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAkDhB,IAAM,kBACZ;AAsBM,SAAS,cACf,uBACiC;AACjC,SAAO,gBAAgB;AAAA,IACtB;AAAA,EACD;AACD;AAaO,IAAM,gBAAgB,CAC5B,0BAGS,gBAAgB,cAAe,qBAAsB;AA0BxD,IAAM,YAAY,CACxB,UACA,0BAIA,gBAAgB,UAAW,UAAU,qBAAsB;AAUrD,IAAM,uBACZ,gBAAgB;AAYV,IAAM,gBAA0B,gBAAgB;AAShD,IAAM,MAAW,gBAAgB;AAoBjC,IAAM,WAAW,CACvB,UACU,gBAAgB,SAAU,KAAM;",
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport defaultRegistry from './default-registry';\nimport * as plugins from './plugins';\nimport { combineReducers as combineReducersModule } from './redux-store';\n\nimport type {\n\tStoreDescriptor,\n\tReduxStoreConfig,\n\tcombineReducers as CombineReducers,\n\tAnyConfig,\n\tCurriedSelectorsResolveOf,\n} from './types';\n\nexport { default as withSelect } from './components/with-select';\nexport { default as withDispatch } from './components/with-dispatch';\nexport { default as withRegistry } from './components/with-registry';\nexport {\n\tRegistryProvider,\n\tRegistryConsumer,\n\tuseRegistry,\n} from './components/registry-provider';\nexport {\n\tdefault as useSelect,\n\tuseSuspenseSelect,\n} from './components/use-select';\nexport { useDispatch } from './components/use-dispatch';\nexport { AsyncModeProvider } from './components/async-mode-provider';\nexport { createRegistry } from './registry';\nexport { createRegistrySelector, createRegistryControl } from './factory';\nexport { createSelector } from './create-selector';\nexport type { EnhancedSelector, GetDependants } from './create-selector';\nexport { controls } from './controls';\nexport { default as createReduxStore } from './redux-store';\nexport { keyedReducer } from './redux-store/keyed-reducer';\nexport { dispatch } from './dispatch';\nexport { select } from './select';\n\nexport type * from './types';\n\n/**\n * Object of available plugins to use with a registry.\n *\n * @see [use](#use)\n */\nexport { plugins };\n\n/**\n * The combineReducers helper function turns an object whose values are different\n * reducing functions into a single reducing function you can pass to registerReducer.\n *\n * @type {import('./types').combineReducers}\n * @param {Object} reducers An object whose values correspond to different reducing\n * functions that need to be combined into one.\n *\n * @example\n * ```js\n * import { combineReducers, createReduxStore, register } from '@wordpress/data';\n *\n * const prices = ( state = {}, action ) => {\n * \treturn action.type === 'SET_PRICE' ?\n * \t\t{\n * \t\t\t...state,\n * \t\t\t[ action.item ]: action.price,\n * \t\t} :\n * \t\tstate;\n * };\n *\n * const discountPercent = ( state = 0, action ) => {\n * \treturn action.type === 'START_SALE' ?\n * \t\taction.discountPercent :\n * \t\tstate;\n * };\n *\n * const store = createReduxStore( 'my-shop', {\n * \treducer: combineReducers( {\n * \t\tprices,\n * \t\tdiscountPercent,\n * \t} ),\n * } );\n * register( store );\n * ```\n *\n * @return {Function} A reducer that invokes every reducer inside the reducers\n * object, and constructs a state object with the same shape.\n */\nexport const combineReducers =\n\tcombineReducersModule as unknown as CombineReducers;\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors\n * pre-bound to state so that you only need to supply additional arguments, and\n * modified so that they return promises that resolve to their eventual values,\n * after any resolvers have ran.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @example\n * ```js\n * import { resolveSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log)\n * ```\n *\n * @return Object containing the store's promise-wrapped selectors.\n */\nexport function resolveSelect< T extends StoreDescriptor< AnyConfig > >(\n\tstoreNameOrDescriptor: T | string\n): CurriedSelectorsResolveOf< T > {\n\treturn defaultRegistry.resolveSelect(\n\t\tstoreNameOrDescriptor\n\t) as CurriedSelectorsResolveOf< T >;\n}\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors pre-bound to state\n * so that you only need to supply additional arguments, and modified so that they throw promises\n * in case the selector is not resolved yet.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @return {Object} Object containing the store's suspense-wrapped selectors.\n */\nexport const suspendSelect = (\n\tstoreNameOrDescriptor:\n\t\t| string\n\t\t| StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): any => defaultRegistry.suspendSelect( storeNameOrDescriptor );\n\n/**\n * Given a listener function, the function will be called any time the state value\n * of one of the registered stores has changed. If you specify the optional\n * `storeNameOrDescriptor` parameter, the listener function will be called only\n * on updates on that one specific registered store.\n *\n * This function returns an `unsubscribe` function used to stop the subscription.\n *\n * @param {Function} listener Callback function.\n * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n *\n * @example\n * ```js\n * import { subscribe } from '@wordpress/data';\n *\n * const unsubscribe = subscribe( () => {\n * \t// You could use this opportunity to test whether the derived result of a\n * \t// selector has subsequently changed as the result of a state update.\n * } );\n *\n * // Later, if necessary...\n * unsubscribe();\n * ```\n */\nexport const subscribe = (\n\tlistener: () => void,\n\tstoreNameOrDescriptor?:\n\t\t| string\n\t\t| StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): ( () => void ) =>\n\tdefaultRegistry.subscribe( listener, storeNameOrDescriptor );\n\n/**\n * Registers a generic store instance.\n *\n * @deprecated Use `register( storeDescriptor )` instead.\n *\n * @param {string} name Store registry name.\n * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).\n */\nexport const registerGenericStore: Function =\n\tdefaultRegistry.registerGenericStore;\n\n/**\n * Registers a standard `@wordpress/data` store.\n *\n * @deprecated Use `register` instead.\n *\n * @param {string} storeName Unique namespace identifier for the store.\n * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n *\n * @return {Object} Registered store object.\n */\nexport const registerStore: Function = defaultRegistry.registerStore;\n\n/**\n * Extends a registry to inherit functionality provided by a given plugin. A\n * plugin is an object with properties aligning to that of a registry, merged\n * to extend the default registry behavior.\n *\n * @param {Object} plugin Plugin object.\n */\nexport const use: any = defaultRegistry.use;\n\n/**\n * Registers a standard `@wordpress/data` store descriptor.\n *\n * @example\n * ```js\n * import { createReduxStore, register } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * register( store );\n * ```\n *\n * @param {StoreDescriptor} store Store descriptor.\n */\nexport const register = (\n\tstore: StoreDescriptor< ReduxStoreConfig< any, any, any > >\n): void => defaultRegistry.register( store );\n"],
5
+ "mappings": ";AAGA,OAAO,qBAAqB;AAC5B,YAAY,aAAa;AACzB,SAAS,mBAAmB,6BAA6B;AAUzD,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAA+B;AACxC,SAAoB,WAAXA,gBAA+B;AACxC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB,6BAA6B;AAC9D,SAAS,sBAAsB;AAE/B,SAAS,gBAAgB;AACzB,SAAoB,WAAXA,gBAAmC;AAC5C,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAkDhB,IAAM,kBACZ;AAsBM,SAAS,cACf,uBACiC;AACjC,SAAO,gBAAgB;AAAA,IACtB;AAAA,EACD;AACD;AAaO,IAAM,gBAAgB,CAC5B,0BAGS,gBAAgB,cAAe,qBAAsB;AA0BxD,IAAM,YAAY,CACxB,UACA,0BAIA,gBAAgB,UAAW,UAAU,qBAAsB;AAUrD,IAAM,uBACZ,gBAAgB;AAYV,IAAM,gBAA0B,gBAAgB;AAShD,IAAM,MAAW,gBAAgB;AAoBjC,IAAM,WAAW,CACvB,UACU,gBAAgB,SAAU,KAAM;",
6
6
  "names": ["default"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/registry.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\nimport { lock, unlock } from './lock-unlock';\nimport type {\n\tStoreDescriptor,\n\tStoreNameOrDescriptor,\n\tDataRegistry,\n\tDataPlugin,\n\tInternalStoreInstance,\n\tAnyConfig,\n\tReduxStoreConfig,\n} from './types';\n\nfunction getStoreName( storeNameOrDescriptor: StoreNameOrDescriptor ): string {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param storeConfigs Initial store configurations.\n * @param parent Parent registry.\n *\n * @return Data registry.\n */\nexport function createRegistry(\n\tstoreConfigs: Record< string, ReduxStoreConfig< any, any, any > > = {},\n\tparent: DataRegistry | null = null\n): DataRegistry {\n\tconst stores: Record< string, InternalStoreInstance > = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores: Set< string > | null = null;\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data, either in all stores in registry, or\n\t * in one specific store.\n\t *\n\t * @param listener Listener function.\n\t * @param storeNameOrDescriptor Optional store name.\n\t *\n\t * @return Unsubscribe function.\n\t */\n\tconst subscribe = (\n\t\tlistener: () => void,\n\t\tstoreNameOrDescriptor?: StoreNameOrDescriptor\n\t): ( () => void ) => {\n\t\t// subscribe to all stores\n\t\tif ( ! storeNameOrDescriptor ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\t// subscribe to one store\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.subscribe( listener );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to global `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\treturn parent.subscribe( listener, storeNameOrDescriptor );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores< T >(\n\t\tthis: DataRegistry,\n\t\tcallback: () => T,\n\t\tref: { current: string[] | null }\n\t): T {\n\t\tlisteningStores = new Set();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t\tlisteningStores = null;\n\t\t}\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they return\n\t * promises that resolve to their eventual values, after any resolvers have ran.\n\t *\n\t * @param storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors!();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they throw\n\t * promises in case the selector is not resolved yet.\n\t *\n\t * @param storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors!();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\tfunction withPlugins(\n\t\tattributes: Record< string, unknown >\n\t): Record< string, unknown > {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( attributes ).map( ( [ key, attribute ] ) => {\n\t\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\t\treturn [ key, attribute ];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tkey,\n\t\t\t\t\t( ...args: unknown[] ) => {\n\t\t\t\t\t\treturn ( registry as any )[ key ]( ...args );\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t} )\n\t\t);\n\t}\n\n\t/**\n\t * Registers a store instance.\n\t *\n\t * @param name Store registry name.\n\t * @param createStoreFunc Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance(\n\t\tname: string,\n\t\tcreateStoreFunc: () => InternalStoreInstance\n\t): InternalStoreInstance {\n\t\tif ( stores[ name ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'Store \"' + name + '\" is already registered.' );\n\t\t\treturn stores[ name ];\n\t\t}\n\n\t\tconst store: any = createStoreFunc();\n\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener: () => void ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\n\t\t// Copy private actions and selectors from the parent store.\n\t\tif ( parent ) {\n\t\t\ttry {\n\t\t\t\tunlock( store.store ).registerPrivateActions(\n\t\t\t\t\tunlock( parent ).privateActionsOf( name )\n\t\t\t\t);\n\t\t\t\tunlock( store.store ).registerPrivateSelectors(\n\t\t\t\t\tunlock( parent ).privateSelectorsOf( name )\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\t// unlock() throws if store.store was not locked.\n\t\t\t\t// The error indicates there's nothing to do here so let's\n\t\t\t\t// ignore it.\n\t\t\t}\n\t\t}\n\n\t\treturn store;\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param store Store descriptor.\n\t */\n\tfunction register( store: StoreDescriptor< AnyConfig > ) {\n\t\tregisterStoreInstance(\n\t\t\tstore.name,\n\t\t\t() => store.instantiate( registry ) as InternalStoreInstance\n\t\t);\n\t}\n\n\tfunction registerGenericStore(\n\t\tname: string,\n\t\tstore: InternalStoreInstance\n\t) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, () => store );\n\t}\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param storeName Unique namespace identifier.\n\t * @param options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return Registered store object.\n\t */\n\tfunction registerStore(\n\t\tstoreName: string,\n\t\toptions: ReduxStoreConfig< any, any, any >\n\t) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance(\n\t\t\tstoreName,\n\t\t\t() =>\n\t\t\t\tcreateReduxStore( storeName, options ).instantiate(\n\t\t\t\t\tregistry\n\t\t\t\t) as InternalStoreInstance\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback: () => void ) {\n\t\t// If we're already batching, just call the callback.\n\t\tif ( emitter.isPaused ) {\n\t\t\tcallback();\n\t\t\treturn;\n\t\t}\n\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\temitter.resume();\n\t\t\tObject.values( stores ).forEach( ( store ) =>\n\t\t\t\tstore.emitter.resume()\n\t\t\t);\n\t\t}\n\t}\n\n\tlet registry: DataRegistry = {\n\t\tbatch,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t} as DataRegistry;\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\tfunction use( plugin: DataPlugin, options?: Record< string, unknown > ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( name, config ) );\n\t}\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\tconst registryWithPlugins = withPlugins(\n\t\tregistry as unknown as Record< string, unknown >\n\t);\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name: string ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch {\n\t\t\t\t// unlock() throws an error the store was not locked \u2013 this means\n\t\t\t\t// there no private actions are available\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t\tprivateSelectorsOf: ( name: string ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins as unknown as DataRegistry;\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\nimport { lock, unlock } from './lock-unlock';\nimport type {\n\tStoreDescriptor,\n\tStoreNameOrDescriptor,\n\tDataRegistry,\n\tDataPlugin,\n\tInternalStoreInstance,\n\tAnyConfig,\n\tReduxStoreConfig,\n} from './types';\n\nfunction getStoreName( storeNameOrDescriptor: StoreNameOrDescriptor ): string {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param storeConfigs Initial store configurations.\n * @param parent Parent registry.\n *\n * @return Data registry.\n */\nexport function createRegistry(\n\tstoreConfigs: Record< string, ReduxStoreConfig< any, any, any > > = {},\n\tparent: DataRegistry | null = null\n): DataRegistry {\n\tconst stores: Record< string, InternalStoreInstance > = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores: Set< string > | null = null;\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data, either in all stores in registry, or\n\t * in one specific store.\n\t *\n\t * @param listener Listener function.\n\t * @param storeNameOrDescriptor Optional store name.\n\t *\n\t * @return Unsubscribe function.\n\t */\n\tconst subscribe = (\n\t\tlistener: () => void,\n\t\tstoreNameOrDescriptor?: StoreNameOrDescriptor\n\t): ( () => void ) => {\n\t\t// subscribe to all stores\n\t\tif ( ! storeNameOrDescriptor ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\t// subscribe to one store\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.subscribe( listener );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to global `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn emitter.subscribe( listener );\n\t\t}\n\n\t\treturn parent.subscribe( listener, storeNameOrDescriptor );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores< T >(\n\t\tthis: DataRegistry,\n\t\tcallback: () => T,\n\t\tref: { current: string[] | null }\n\t): T {\n\t\tlisteningStores = new Set();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t\tlisteningStores = null;\n\t\t}\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they return\n\t * promises that resolve to their eventual values, after any resolvers have ran.\n\t *\n\t * @param storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors!();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they throw\n\t * promises in case the selector is not resolved yet.\n\t *\n\t * @param storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tlisteningStores?.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors!();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor: StoreNameOrDescriptor ) {\n\t\tconst storeName = getStoreName( storeNameOrDescriptor );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\tfunction withPlugins(\n\t\tattributes: Record< string, unknown >\n\t): Record< string, unknown > {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( attributes ).map( ( [ key, attribute ] ) => {\n\t\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\t\treturn [ key, attribute ];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tkey,\n\t\t\t\t\t( ...args: unknown[] ) => {\n\t\t\t\t\t\treturn ( registry as any )[ key ]( ...args );\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t} )\n\t\t);\n\t}\n\n\t/**\n\t * Registers a store instance.\n\t *\n\t * @param name Store registry name.\n\t * @param createStoreFunc Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance(\n\t\tname: string,\n\t\tcreateStoreFunc: () => InternalStoreInstance\n\t): InternalStoreInstance {\n\t\tif ( stores[ name ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'Store \"' + name + '\" is already registered.' );\n\t\t\treturn stores[ name ];\n\t\t}\n\n\t\tconst store: any = createStoreFunc();\n\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener: () => void ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\n\t\t// Copy private actions and selectors from the parent store.\n\t\tif ( parent ) {\n\t\t\ttry {\n\t\t\t\tunlock( store.store ).registerPrivateActions(\n\t\t\t\t\tunlock( parent ).privateActionsOf( name )\n\t\t\t\t);\n\t\t\t\tunlock( store.store ).registerPrivateSelectors(\n\t\t\t\t\tunlock( parent ).privateSelectorsOf( name )\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\t// unlock() throws if store.store was not locked.\n\t\t\t\t// The error indicates there's nothing to do here so let's\n\t\t\t\t// ignore it.\n\t\t\t}\n\t\t}\n\n\t\treturn store;\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param store Store descriptor.\n\t */\n\tfunction register( store: StoreDescriptor< AnyConfig > ) {\n\t\tregisterStoreInstance(\n\t\t\tstore.name,\n\t\t\t() => store.instantiate( registry ) as InternalStoreInstance\n\t\t);\n\t}\n\n\tfunction registerGenericStore(\n\t\tname: string,\n\t\tstore: InternalStoreInstance\n\t) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, () => store );\n\t}\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param storeName Unique namespace identifier.\n\t * @param options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return Registered store object.\n\t */\n\tfunction registerStore(\n\t\tstoreName: string,\n\t\toptions: ReduxStoreConfig< any, any, any >\n\t) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance(\n\t\t\tstoreName,\n\t\t\t() =>\n\t\t\t\tcreateReduxStore( storeName, options ).instantiate(\n\t\t\t\t\tregistry\n\t\t\t\t) as InternalStoreInstance\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback: () => void ) {\n\t\t// If we're already batching, just call the callback.\n\t\tif ( emitter.isPaused ) {\n\t\t\tcallback();\n\t\t\treturn;\n\t\t}\n\n\t\temitter.pause();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.pause() );\n\t\ttry {\n\t\t\tcallback();\n\t\t} finally {\n\t\t\temitter.resume();\n\t\t\tObject.values( stores ).forEach( ( store ) =>\n\t\t\t\tstore.emitter.resume()\n\t\t\t);\n\t\t}\n\t}\n\n\tlet registry: DataRegistry = {\n\t\tbatch,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t} as DataRegistry;\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\tfunction use( plugin: DataPlugin, options?: Record< string, unknown > ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( name, config ) );\n\t}\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\tconst registryWithPlugins = withPlugins(\n\t\tregistry as unknown as Record< string, unknown >\n\t);\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name: string ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch {\n\t\t\t\t// unlock() throws an error the store was not locked – this means\n\t\t\t\t// there no private actions are available\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t\tprivateSelectorsOf: ( name: string ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins as unknown as DataRegistry;\n}\n"],
5
5
  "mappings": ";AAGA,OAAO,gBAAgB;AAKvB,OAAO,sBAAsB;AAC7B,OAAO,mBAAmB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,MAAM,cAAc;AAW7B,SAAS,aAAc,uBAAuD;AAC7E,SAAO,OAAO,0BAA0B,WACrC,wBACA,sBAAsB;AAC1B;AAWO,SAAS,eACf,eAAoE,CAAC,GACrE,SAA8B,MACf;AACf,QAAM,SAAkD,CAAC;AACzD,QAAM,UAAU,cAAc;AAC9B,MAAI,kBAAwC;AAK5C,WAAS,iBAAiB;AACzB,YAAQ,KAAK;AAAA,EACd;AAWA,QAAM,YAAY,CACjB,UACA,0BACoB;AAEpB,QAAK,CAAE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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAKA,WAAS,IAAK,QAAoB,SAAsC;AACvE,QAAK,CAAE,QAAS;AACf;AAAA,IACD;AAEA,eAAW;AAAA,MACV,GAAG;AAAA,MACH,GAAG,OAAQ,UAAU,OAAQ;AAAA,IAC9B;AAEA,WAAO;AAAA,EACR;AAEA,WAAS,SAAU,aAAc;AAEjC,aAAY,CAAE,MAAM,MAAO,KAAK,OAAO,QAAS,YAAa,GAAI;AAChE,aAAS,SAAU,iBAAkB,MAAM,MAAO,CAAE;AAAA,EACrD;AAEA,MAAK,QAAS;AACb,WAAO,UAAW,cAAe;AAAA,EAClC;AAEA,QAAM,sBAAsB;AAAA,IAC3B;AAAA,EACD;AACA,OAAM,qBAAqB;AAAA,IAC1B,kBAAkB,CAAE,SAAkB;AACrC,UAAI;AACH,eAAO,OAAQ,OAAQ,IAAK,EAAE,KAAM,EAAE;AAAA,MACvC,QAAQ;AAGP,eAAO,CAAC;AAAA,MACT;AAAA,IACD;AAAA,IACA,oBAAoB,CAAE,SAAkB;AACvC,UAAI;AACH,eAAO,OAAQ,OAAQ,IAAK,EAAE,KAAM,EAAE;AAAA,MACvC,QAAQ;AACP,eAAO,CAAC;AAAA,MACT;AAAA,IACD;AAAA,EACD,CAAE;AACF,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,25 @@
1
+ /**
2
+ * Returns the array of immutable references on which a memoized selector
3
+ * depends for computing its result. The memoize cache is preserved only as
4
+ * long as those dependant references remain the same.
5
+ */
6
+ export type GetDependants = (...args: any[]) => any[];
7
+ /**
8
+ * The memoization methods a selector returned by `createSelector` is
9
+ * enhanced with.
10
+ */
11
+ export interface EnhancedSelector {
12
+ getDependants: GetDependants;
13
+ /**
14
+ * Clears the memoization cache.
15
+ */
16
+ clear: () => void;
17
+ }
1
18
  /**
2
19
  * Creates a memoized selector that caches the computed values according to the array of "dependants"
3
20
  * and the selector parameters, and recomputes the values only when any of them changes.
4
21
  *
5
- * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.
22
+ * See The documentation for the `rememo` package from which the `createSelector` function is reexported.
6
23
  */
7
- export { default as createSelector } from 'rememo';
24
+ export declare const createSelector: <S extends (...args: any[]) => any>(selector: S, getDependants?: GetDependants) => S & EnhancedSelector;
8
25
  //# sourceMappingURL=create-selector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-selector.d.ts","sourceRoot":"","sources":["../src/create-selector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"create-selector.d.ts","sourceRoot":"","sources":["../src/create-selector.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAM,GAAG,EAAE,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,aAAa,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CAClB;AAQD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,CAAE,CAAC,SAAS,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAM,GAAG,EACjE,QAAQ,EAAE,CAAC,EACX,aAAa,CAAC,EAAE,aAAa,KACzB,CAAC,GAAG,gBAA0B,CAAC"}
@@ -10,6 +10,7 @@ export { AsyncModeProvider } from './components/async-mode-provider';
10
10
  export { createRegistry } from './registry';
11
11
  export { createRegistrySelector, createRegistryControl } from './factory';
12
12
  export { createSelector } from './create-selector';
13
+ export type { EnhancedSelector, GetDependants } from './create-selector';
13
14
  export { controls } from './controls';
14
15
  export { default as createReduxStore } from './redux-store';
15
16
  export { keyedReducer } from './redux-store/keyed-reducer';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRo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Ae,CAAE,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,CAAE,KACrD,GAA6D,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,SAAS,aACX,MAAM,IAAI,0BAEjB,MAAM,GACN,eAAe,CAAE,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,CAAE,KACrD,CAAE,MAAM,IAAI,CAC8C,CAAC;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,QACE,CAAC;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,QAAwC,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,EAAE,GAAyB,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,QAAQ,UACb,eAAe,CAAE,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,CAAE,KACzD,IAAyC,CAAC"}
@@ -110,5 +110,5 @@ export declare function hasResolvingSelectors(state: Record<string, State>): boo
110
110
  *
111
111
  * @return Object, containing selector totals by status.
112
112
  */
113
- export declare const countSelectorsByStatus: ((state: Record<string, State>) => Record<string, number>) & import("rememo").EnhancedSelector;
113
+ export declare const countSelectorsByStatus: ((state: Record<string, State>) => Record<string, number>) & import("../..").EnhancedSelector;
114
114
  //# sourceMappingURL=selectors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/selectors.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,EAC9B,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,GAC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CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,GACrB,OAAO,CAGT;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,EAC9B,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,GACrB,OAAO,CAET;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,EAC9B,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,GACrB,KAAK,GAAG,OAAO,CAGjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,EAC9B,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,GACrB,OAAO,CAIT;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,GAC5B,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,GAC5B,OAAO,CAaT;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,WACzB,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,KAAI,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,oCAyB5D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/data",
3
- "version": "10.48.1",
3
+ "version": "10.49.0",
4
4
  "description": "Data module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -44,14 +44,13 @@
44
44
  "types": "build-types",
45
45
  "sideEffects": false,
46
46
  "dependencies": {
47
- "@types/react": "^18.3.27",
48
- "@wordpress/compose": "^8.1.1",
49
- "@wordpress/deprecated": "^4.48.1",
50
- "@wordpress/element": "^8.0.1",
51
- "@wordpress/is-shallow-equal": "^5.48.1",
52
- "@wordpress/priority-queue": "^3.48.1",
53
- "@wordpress/private-apis": "^1.48.1",
54
- "@wordpress/redux-routine": "^5.48.1",
47
+ "@wordpress/compose": "^8.2.0",
48
+ "@wordpress/deprecated": "^4.49.0",
49
+ "@wordpress/element": "^8.1.0",
50
+ "@wordpress/is-shallow-equal": "^5.49.0",
51
+ "@wordpress/priority-queue": "^3.49.0",
52
+ "@wordpress/private-apis": "^1.49.0",
53
+ "@wordpress/redux-routine": "^5.49.0",
55
54
  "deepmerge": "^4.3.1",
56
55
  "equivalent-key-map": "^0.2.2",
57
56
  "is-plain-object": "^5.0.0",
@@ -67,10 +66,16 @@
67
66
  "deep-freeze": "^0.0.1"
68
67
  },
69
68
  "peerDependencies": {
69
+ "@types/react": "^18.3.27",
70
70
  "react": "^18.0.0"
71
71
  },
72
+ "peerDependenciesMeta": {
73
+ "@types/react": {
74
+ "optional": true
75
+ }
76
+ },
72
77
  "publishConfig": {
73
78
  "access": "public"
74
79
  },
75
- "gitHead": "99df7432c5c7cb83ba41146fd1f57f3c19004305"
80
+ "gitHead": "0e7112a4f4fde4ea15bd9060489b8f6fe11eb6ca"
76
81
  }
@@ -1,7 +1,41 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import memoize from 'rememo';
5
+
6
+ /**
7
+ * Returns the array of immutable references on which a memoized selector
8
+ * depends for computing its result. The memoize cache is preserved only as
9
+ * long as those dependant references remain the same.
10
+ */
11
+ export type GetDependants = ( ...args: any[] ) => any[];
12
+
13
+ /**
14
+ * The memoization methods a selector returned by `createSelector` is
15
+ * enhanced with.
16
+ */
17
+ export interface EnhancedSelector {
18
+ getDependants: GetDependants;
19
+
20
+ /**
21
+ * Clears the memoization cache.
22
+ */
23
+ clear: () => void;
24
+ }
25
+
26
+ /*
27
+ * The signature mirrors `rememo`'s, but is declared here so that consumers'
28
+ * emitted declarations reference `@wordpress/data` rather than `rememo`,
29
+ * which they do not declare as a dependency.
30
+ */
31
+
1
32
  /**
2
33
  * Creates a memoized selector that caches the computed values according to the array of "dependants"
3
34
  * and the selector parameters, and recomputes the values only when any of them changes.
4
35
  *
5
- * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.
36
+ * See The documentation for the `rememo` package from which the `createSelector` function is reexported.
6
37
  */
7
- export { default as createSelector } from 'rememo';
38
+ export const createSelector: < S extends ( ...args: any[] ) => any >(
39
+ selector: S,
40
+ getDependants?: GetDependants
41
+ ) => S & EnhancedSelector = memoize;
package/src/index.ts CHANGED
@@ -30,6 +30,7 @@ export { AsyncModeProvider } from './components/async-mode-provider';
30
30
  export { createRegistry } from './registry';
31
31
  export { createRegistrySelector, createRegistryControl } from './factory';
32
32
  export { createSelector } from './create-selector';
33
+ export type { EnhancedSelector, GetDependants } from './create-selector';
33
34
  export { controls } from './controls';
34
35
  export { default as createReduxStore } from './redux-store';
35
36
  export { keyedReducer } from './redux-store/keyed-reducer';