@wordpress/data 9.25.0 → 9.26.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +20 -3
  3. package/build/components/async-mode-provider/context.js.map +1 -1
  4. package/build/components/async-mode-provider/index.js +1 -1
  5. package/build/components/async-mode-provider/index.js.map +1 -1
  6. package/build/components/async-mode-provider/use-async-mode.js.map +1 -1
  7. package/build/components/registry-provider/context.js.map +1 -1
  8. package/build/components/registry-provider/index.js +1 -1
  9. package/build/components/registry-provider/index.js.map +1 -1
  10. package/build/components/registry-provider/use-registry.js.map +1 -1
  11. package/build/components/use-dispatch/index.js.map +1 -1
  12. package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  13. package/build/components/use-dispatch/use-dispatch.js.map +1 -1
  14. package/build/components/use-select/index.js +15 -11
  15. package/build/components/use-select/index.js.map +1 -1
  16. package/build/components/with-dispatch/index.js.map +1 -1
  17. package/build/components/with-registry/index.js.map +1 -1
  18. package/build/components/with-select/index.js.map +1 -1
  19. package/build/controls.js.map +1 -1
  20. package/build/create-selector.js +14 -0
  21. package/build/create-selector.js.map +1 -0
  22. package/build/default-registry.js.map +1 -1
  23. package/build/dispatch.js.map +1 -1
  24. package/build/factory.js.map +1 -1
  25. package/build/index.js +8 -1
  26. package/build/index.js.map +1 -1
  27. package/build/lock-unlock.js.map +1 -1
  28. package/build/plugins/index.js.map +1 -1
  29. package/build/plugins/persistence/index.js.map +1 -1
  30. package/build/plugins/persistence/storage/default.js.map +1 -1
  31. package/build/plugins/persistence/storage/object.js.map +1 -1
  32. package/build/promise-middleware.js.map +1 -1
  33. package/build/redux-store/combine-reducers.js.map +1 -1
  34. package/build/redux-store/index.js +1 -1
  35. package/build/redux-store/index.js.map +1 -1
  36. package/build/redux-store/metadata/actions.js.map +1 -1
  37. package/build/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
  38. package/build/redux-store/metadata/reducer.js.map +1 -1
  39. package/build/redux-store/metadata/selectors.js +2 -6
  40. package/build/redux-store/metadata/selectors.js.map +1 -1
  41. package/build/redux-store/metadata/utils.js.map +1 -1
  42. package/build/redux-store/thunk-middleware.js.map +1 -1
  43. package/build/registry.js.map +1 -1
  44. package/build/resolvers-cache-middleware.js.map +1 -1
  45. package/build/select.js.map +1 -1
  46. package/build/store/index.js.map +1 -1
  47. package/build/types.js.map +1 -1
  48. package/build/utils/emitter.js.map +1 -1
  49. package/build-module/components/async-mode-provider/context.js.map +1 -1
  50. package/build-module/components/async-mode-provider/index.js.map +1 -1
  51. package/build-module/components/async-mode-provider/use-async-mode.js.map +1 -1
  52. package/build-module/components/registry-provider/context.js.map +1 -1
  53. package/build-module/components/registry-provider/index.js.map +1 -1
  54. package/build-module/components/registry-provider/use-registry.js.map +1 -1
  55. package/build-module/components/use-dispatch/index.js.map +1 -1
  56. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  57. package/build-module/components/use-dispatch/use-dispatch.js.map +1 -1
  58. package/build-module/components/use-select/index.js +15 -11
  59. package/build-module/components/use-select/index.js.map +1 -1
  60. package/build-module/components/with-dispatch/index.js.map +1 -1
  61. package/build-module/components/with-registry/index.js.map +1 -1
  62. package/build-module/components/with-select/index.js.map +1 -1
  63. package/build-module/controls.js.map +1 -1
  64. package/build-module/create-selector.js +12 -0
  65. package/build-module/create-selector.js.map +1 -0
  66. package/build-module/default-registry.js.map +1 -1
  67. package/build-module/dispatch.js.map +1 -1
  68. package/build-module/factory.js.map +1 -1
  69. package/build-module/index.js +1 -0
  70. package/build-module/index.js.map +1 -1
  71. package/build-module/lock-unlock.js.map +1 -1
  72. package/build-module/plugins/index.js.map +1 -1
  73. package/build-module/plugins/persistence/index.js.map +1 -1
  74. package/build-module/plugins/persistence/storage/default.js.map +1 -1
  75. package/build-module/plugins/persistence/storage/object.js.map +1 -1
  76. package/build-module/promise-middleware.js.map +1 -1
  77. package/build-module/redux-store/combine-reducers.js.map +1 -1
  78. package/build-module/redux-store/index.js.map +1 -1
  79. package/build-module/redux-store/metadata/actions.js.map +1 -1
  80. package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
  81. package/build-module/redux-store/metadata/reducer.js.map +1 -1
  82. package/build-module/redux-store/metadata/selectors.js +1 -5
  83. package/build-module/redux-store/metadata/selectors.js.map +1 -1
  84. package/build-module/redux-store/metadata/utils.js.map +1 -1
  85. package/build-module/redux-store/thunk-middleware.js.map +1 -1
  86. package/build-module/registry.js.map +1 -1
  87. package/build-module/resolvers-cache-middleware.js.map +1 -1
  88. package/build-module/select.js.map +1 -1
  89. package/build-module/store/index.js.map +1 -1
  90. package/build-module/types.js.map +1 -1
  91. package/build-module/utils/emitter.js.map +1 -1
  92. package/build-types/components/use-select/index.d.ts +16 -12
  93. package/build-types/components/use-select/index.d.ts.map +1 -1
  94. package/build-types/create-selector.d.ts +2 -0
  95. package/build-types/create-selector.d.ts.map +1 -0
  96. package/build-types/index.d.ts +1 -0
  97. package/build-types/index.d.ts.map +1 -1
  98. package/build-types/redux-store/metadata/reducer.d.ts +1 -0
  99. package/build-types/redux-store/metadata/reducer.d.ts.map +1 -1
  100. package/build-types/redux-store/metadata/selectors.d.ts.map +1 -1
  101. package/build-types/redux-store/metadata/utils.d.ts.map +1 -1
  102. package/package.json +9 -9
  103. package/src/components/use-select/index.js +15 -11
  104. package/src/create-selector.js +11 -0
  105. package/src/index.js +1 -0
  106. package/src/redux-store/metadata/selectors.js +1 -5
  107. package/src/test/registry-selectors.js +1 -5
  108. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["deprecated","createReduxStore","coreDataStore","createEmitter","lock","unlock","getStoreName","storeNameOrDescriptor","name","createRegistry","storeConfigs","parent","stores","emitter","listeningStores","globalListener","emit","subscribe","listener","storeName","store","select","add","getSelectors","__unstableMarkListeningStores","callback","ref","Set","call","current","Array","from","resolveSelect","getResolveSelectors","suspendSelect","getSuspendSelectors","dispatch","getActions","withPlugins","attributes","Object","fromEntries","entries","map","key","attribute","registry","apply","arguments","registerStoreInstance","createStore","console","error","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","registerPrivateActions","privateActionsOf","registerPrivateSelectors","privateSelectorsOf","e","register","instantiate","registerGenericStore","since","alternative","registerStore","options","reducer","batch","pause","values","forEach","resume","namespaces","use","plugin","config","registryWithPlugins","privateActions","privateSelectors"],"sources":["@wordpress/data/src/registry.js"],"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';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\n/**\n * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.\n *\n * @property {Function} registerGenericStore Given a namespace key and settings\n * object, registers a new generic\n * store.\n * @property {Function} registerStore Given a namespace key and settings\n * object, registers a new namespace\n * store.\n * @property {Function} subscribe Given a function callback, invokes\n * the callback on any change to state\n * within any registered store.\n * @property {Function} select Given a namespace key, returns an\n * object of the store's registered\n * selectors.\n * @property {Function} dispatch Given a namespace key, returns an\n * object of the store's registered\n * action dispatchers.\n */\n\n/**\n * @typedef {Object} WPDataPlugin An object of registry function overrides.\n *\n * @property {Function} registerStore registers store.\n */\n\nfunction getStoreName( storeNameOrDescriptor ) {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param {Object} storeConfigs Initial store configurations.\n * @param {Object?} parent Parent registry.\n *\n * @return {WPDataRegistry} Data registry.\n */\nexport function createRegistry( storeConfigs = {}, parent = null ) {\n\tconst stores = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores = 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 {Function} listener Listener function.\n\t * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n\t *\n\t * @return {Function} Unsubscribe function.\n\t */\n\tconst subscribe = ( listener, storeNameOrDescriptor ) => {\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 {string|StoreDescriptor} 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 ) {\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( callback, ref ) {\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 {StoreDescriptor|string} 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} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( 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 {StoreDescriptor|string} 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} Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( 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 {string|StoreDescriptor} 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 ) {\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( attributes ) {\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\tfunction () {\n\t\t\t\t\t\treturn registry[ key ].apply( null, arguments );\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 {string} name Store registry name.\n\t * @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, createStore ) {\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 = createStore();\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 ) => {\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 ( e ) {\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 {StoreDescriptor} store Store descriptor.\n\t */\n\tfunction register( store ) {\n\t\tregisterStoreInstance( store.name, () =>\n\t\t\tstore.instantiate( registry )\n\t\t);\n\t}\n\n\tfunction registerGenericStore( name, store ) {\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 {string} storeName Unique namespace identifier.\n\t * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return {Object} Registered store object.\n\t */\n\tfunction registerStore( storeName, options ) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance( storeName, () =>\n\t\t\tcreateReduxStore( storeName, options ).instantiate( registry )\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback ) {\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\tcallback();\n\t\temitter.resume();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.resume() );\n\t}\n\n\tlet registry = {\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};\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, options ) {\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( registry );\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch ( e ) {\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 ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,eAAe;AAC5C,OAAOC,aAAa,MAAM,SAAS;AACnC,SAASC,aAAa,QAAQ,iBAAiB;A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CAAEO,MAAM,CAAEJ,IAAI,CAAE,CAACY,KAAM,CAAC,CAAC6D,cAAc;MACrD,CAAC,CAAC,OAAQnB,CAAC,EAAG;QACb;QACA;QACA,OAAO,CAAC,CAAC;MACV;IACD,CAAC;IACDD,kBAAkB,EAAIrD,IAAI,IAAM;MAC/B,IAAI;QACH,OAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAI,CAAE,CAACY,KAAM,CAAC,CAAC8D,gBAAgB;MACvD,CAAC,CAAC,OAAQpB,CAAC,EAAG;QACb,OAAO,CAAC,CAAC;MACV;IACD;EACD,CAAE,CAAC;EACH,OAAOkB,mBAAmB;AAC3B"}
1
+ {"version":3,"names":["deprecated","createReduxStore","coreDataStore","createEmitter","lock","unlock","getStoreName","storeNameOrDescriptor","name","createRegistry","storeConfigs","parent","stores","emitter","listeningStores","globalListener","emit","subscribe","listener","storeName","store","select","add","getSelectors","__unstableMarkListeningStores","callback","ref","Set","call","current","Array","from","resolveSelect","getResolveSelectors","suspendSelect","getSuspendSelectors","dispatch","getActions","withPlugins","attributes","Object","fromEntries","entries","map","key","attribute","registry","apply","arguments","registerStoreInstance","createStore","console","error","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","registerPrivateActions","privateActionsOf","registerPrivateSelectors","privateSelectorsOf","e","register","instantiate","registerGenericStore","since","alternative","registerStore","options","reducer","batch","pause","values","forEach","resume","namespaces","use","plugin","config","registryWithPlugins","privateActions","privateSelectors"],"sources":["@wordpress/data/src/registry.js"],"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';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\n/**\n * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.\n *\n * @property {Function} registerGenericStore Given a namespace key and settings\n * object, registers a new generic\n * store.\n * @property {Function} registerStore Given a namespace key and settings\n * object, registers a new namespace\n * store.\n * @property {Function} subscribe Given a function callback, invokes\n * the callback on any change to state\n * within any registered store.\n * @property {Function} select Given a namespace key, returns an\n * object of the store's registered\n * selectors.\n * @property {Function} dispatch Given a namespace key, returns an\n * object of the store's registered\n * action dispatchers.\n */\n\n/**\n * @typedef {Object} WPDataPlugin An object of registry function overrides.\n *\n * @property {Function} registerStore registers store.\n */\n\nfunction getStoreName( storeNameOrDescriptor ) {\n\treturn typeof storeNameOrDescriptor === 'string'\n\t\t? storeNameOrDescriptor\n\t\t: storeNameOrDescriptor.name;\n}\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param {Object} storeConfigs Initial store configurations.\n * @param {Object?} parent Parent registry.\n *\n * @return {WPDataRegistry} Data registry.\n */\nexport function createRegistry( storeConfigs = {}, parent = null ) {\n\tconst stores = {};\n\tconst emitter = createEmitter();\n\tlet listeningStores = 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 {Function} listener Listener function.\n\t * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n\t *\n\t * @return {Function} Unsubscribe function.\n\t */\n\tconst subscribe = ( listener, storeNameOrDescriptor ) => {\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 {string|StoreDescriptor} 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 ) {\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( callback, ref ) {\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 {StoreDescriptor|string} 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} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( 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 {StoreDescriptor|string} 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} Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( 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 {string|StoreDescriptor} 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 ) {\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( attributes ) {\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\tfunction () {\n\t\t\t\t\t\treturn registry[ key ].apply( null, arguments );\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 {string} name Store registry name.\n\t * @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, createStore ) {\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 = createStore();\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 ) => {\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 ( e ) {\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 {StoreDescriptor} store Store descriptor.\n\t */\n\tfunction register( store ) {\n\t\tregisterStoreInstance( store.name, () =>\n\t\t\tstore.instantiate( registry )\n\t\t);\n\t}\n\n\tfunction registerGenericStore( name, store ) {\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 {string} storeName Unique namespace identifier.\n\t * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return {Object} Registered store object.\n\t */\n\tfunction registerStore( storeName, options ) {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = registerStoreInstance( storeName, () =>\n\t\t\tcreateReduxStore( storeName, options ).instantiate( registry )\n\t\t);\n\n\t\treturn store.store;\n\t}\n\n\tfunction batch( callback ) {\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\tcallback();\n\t\temitter.resume();\n\t\tObject.values( stores ).forEach( ( store ) => store.emitter.resume() );\n\t}\n\n\tlet registry = {\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};\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, options ) {\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( registry );\n\tlock( registryWithPlugins, {\n\t\tprivateActionsOf: ( name ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateActions;\n\t\t\t} catch ( e ) {\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 ) => {\n\t\t\ttry {\n\t\t\t\treturn unlock( stores[ name ].store ).privateSelectors;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t},\n\t} );\n\treturn registryWithPlugins;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,eAAe;AAC5C,OAAOC,aAAa,MAAM,SAAS;AACnC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,IAAI,EAAEC,MAAM,QAAQ,eAAe;;AAE5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,SAASC,YAAYA,CAAEC,qBAAqB,EAAG;EAC9C,OAAO,OAAOA,qBAAqB,KAAK,QAAQ,GAC7CA,qBAAqB,GACrBA,qBAAqB,CAACC,IAAI;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAEC,YAAY,GAAG,CAAC,CAAC,EAAEC,MAAM,GAAG,IAAI,EAAG;EAClE,MAAMC,MAAM,GAAG,CAAC,CAAC;EACjB,MAAMC,OAAO,GAAGV,aAAa,CAAC,CAAC;EAC/B,IAAIW,eAAe,GAAG,IAAI;;EAE1B;AACD;AACA;EACC,SAASC,cAAcA,CAAA,EAAG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AAG;MACf;IACD;IAEAhC,QAAQ,GAAG;MACV,GAAGA,QAAQ;MACX,GAAGgC,MAAM,CAAEhC,QAAQ,EAAEuB,OAAQ;IAC9B,CAAC;IAED,OAAOvB,QAAQ;EAChB;EAEAA,QAAQ,CAACiB,QAAQ,CAAE7D,aAAc,CAAC;EAElC,KAAM,MAAM,CAAEM,IAAI,EAAEuE,MAAM,CAAE,IAAIvC,MAAM,CAACE,OAAO,CAAEhC,YAAa,CAAC,EAAG;IAChEoC,QAAQ,CAACiB,QAAQ,CAAE9D,gBAAgB,CAAEO,IAAI,EAAEuE,MAAO,CAAE,CAAC;EACtD;EAEA,IAAKpE,MAAM,EAAG;IACbA,MAAM,CAACM,SAAS,CAAEF,cAAe,CAAC;EACnC;EAEA,MAAMiE,mBAAmB,GAAG1C,WAAW,CAAEQ,QAAS,CAAC;EACnD1C,IAAI,CAAE4E,mBAAmB,EAAE;IAC1BrB,gBAAgB,EAAInD,IAAI,IAAM;MAC7B,IAAI;QACH,OAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAI,CAAE,CAACY,KAAM,CAAC,CAAC6D,cAAc;MACrD,CAAC,CAAC,OAAQnB,CAAC,EAAG;QACb;QACA;QACA,OAAO,CAAC,CAAC;MACV;IACD,CAAC;IACDD,kBAAkB,EAAIrD,IAAI,IAAM;MAC/B,IAAI;QACH,OAAOH,MAAM,CAAEO,MAAM,CAAEJ,IAAI,CAAE,CAACY,KAAM,CAAC,CAAC8D,gBAAgB;MACvD,CAAC,CAAC,OAAQpB,CAAC,EAAG;QACb,OAAO,CAAC,CAAC;MACV;IACD;EACD,CAAE,CAAC;EACH,OAAOkB,mBAAmB;AAC3B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["createResolversCacheMiddleware","registry","storeName","next","action","resolvers","select","getCachedResolvers","resolverEntries","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","undefined","status","dispatch","invalidateResolution"],"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"sourcesContent":["/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */\n\n/**\n * Creates a middleware handling resolvers cache invalidation.\n *\n * @param {WPDataRegistry} registry Registry for which to create the middleware.\n * @param {string} storeName Name of the store for which to create the middleware.\n *\n * @return {Function} Middleware function.\n */\nconst createResolversCacheMiddleware =\n\t( registry, storeName ) => () => ( next ) => ( action ) => {\n\t\tconst resolvers = registry.select( storeName ).getCachedResolvers();\n\t\tconst resolverEntries = Object.entries( resolvers );\n\t\tresolverEntries.forEach( ( [ selectorName, resolversByArgs ] ) => {\n\t\t\tconst resolver =\n\t\t\t\tregistry.stores[ storeName ]?.resolvers?.[ selectorName ];\n\t\t\tif ( ! resolver || ! resolver.shouldInvalidate ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolversByArgs.forEach( ( value, args ) => {\n\t\t\t\t// Works around a bug in `EquivalentKeyMap` where `map.delete` merely sets an entry value\n\t\t\t\t// to `undefined` and `map.forEach` then iterates also over these orphaned entries.\n\t\t\t\tif ( value === undefined ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.\n\t\t\t\t// If the value is \"finished\" or \"error\" it means this resolver has finished its resolution which means we need\n\t\t\t\t// to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.\n\t\t\t\tif ( value.status !== 'finished' && value.status !== 'error' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! resolver.shouldInvalidate( action, ...args ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Trigger cache invalidation\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( storeName )\n\t\t\t\t\t.invalidateResolution( selectorName, args );\n\t\t\t} );\n\t\t} );\n\t\treturn next( action );\n\t};\n\nexport default createResolversCacheMiddleware;\n"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,8BAA8B,GACnCA,CAAEC,QAAQ,EAAEC,SAAS,KAAM,MAAQC,IAAI,IAAQC,MAAM,IAAM;EAC1D,MAAMC,SAAS,GAAGJ,QAAQ,CAACK,MAAM,CAAEJ,SAAU,CAAC,CAACK,kBAAkB,CAAC,CAAC;EACnE,MAAMC,eAAe,GAAGC,MAAM,CAACC,OAAO,CAAEL,SAAU,CAAC;EACnDG,eAAe,CAACG,OAAO,CAAE,CAAE,CAAEC,YAAY,EAAEC,eAAe,CAAE,KAAM;IACjE,MAAMC,QAAQ,GACbb,QAAQ,CAACc,MAAM,CAAEb,SAAS,CAAE,EAAEG,SAAS,GAAIO,YAAY,CAAE;IAC1D,IAAK,CAAEE,QAAQ,IAAI,CAAEA,QAAQ,CAACE,gBAAgB,EAAG;MAChD;IACD;IACAH,eAAe,CAACF,OAAO,CAAE,CAAEM,KAAK,EAAEC,IAAI,KAAM;MAC3C;MACA;MACA,IAAKD,KAAK,KAAKE,SAAS,EAAG;QAC1B;MACD;;MAEA;MACA;MACA;MACA,IAAKF,KAAK,CAACG,MAAM,KAAK,UAAU,IAAIH,KAAK,CAACG,MAAM,KAAK,OAAO,EAAG;QAC9D;MACD;MAEA,IAAK,CAAEN,QAAQ,CAACE,gBAAgB,CAAEZ,MAAM,EAAE,GAAGc,IAAK,CAAC,EAAG;QACrD;MACD;;MAEA;MACAjB,QAAQ,CACNoB,QAAQ,CAAEnB,SAAU,CAAC,CACrBoB,oBAAoB,CAAEV,YAAY,EAAEM,IAAK,CAAC;IAC7C,CAAE,CAAC;EACJ,CAAE,CAAC;EACH,OAAOf,IAAI,CAAEC,MAAO,CAAC;AACtB,CAAC;AAEF,eAAeJ,8BAA8B"}
1
+ {"version":3,"names":["createResolversCacheMiddleware","registry","storeName","next","action","resolvers","select","getCachedResolvers","resolverEntries","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","undefined","status","dispatch","invalidateResolution"],"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"sourcesContent":["/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */\n\n/**\n * Creates a middleware handling resolvers cache invalidation.\n *\n * @param {WPDataRegistry} registry Registry for which to create the middleware.\n * @param {string} storeName Name of the store for which to create the middleware.\n *\n * @return {Function} Middleware function.\n */\nconst createResolversCacheMiddleware =\n\t( registry, storeName ) => () => ( next ) => ( action ) => {\n\t\tconst resolvers = registry.select( storeName ).getCachedResolvers();\n\t\tconst resolverEntries = Object.entries( resolvers );\n\t\tresolverEntries.forEach( ( [ selectorName, resolversByArgs ] ) => {\n\t\t\tconst resolver =\n\t\t\t\tregistry.stores[ storeName ]?.resolvers?.[ selectorName ];\n\t\t\tif ( ! resolver || ! resolver.shouldInvalidate ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolversByArgs.forEach( ( value, args ) => {\n\t\t\t\t// Works around a bug in `EquivalentKeyMap` where `map.delete` merely sets an entry value\n\t\t\t\t// to `undefined` and `map.forEach` then iterates also over these orphaned entries.\n\t\t\t\tif ( value === undefined ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.\n\t\t\t\t// If the value is \"finished\" or \"error\" it means this resolver has finished its resolution which means we need\n\t\t\t\t// to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.\n\t\t\t\tif ( value.status !== 'finished' && value.status !== 'error' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! resolver.shouldInvalidate( action, ...args ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Trigger cache invalidation\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( storeName )\n\t\t\t\t\t.invalidateResolution( selectorName, args );\n\t\t\t} );\n\t\t} );\n\t\treturn next( action );\n\t};\n\nexport default createResolversCacheMiddleware;\n"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,8BAA8B,GACnCA,CAAEC,QAAQ,EAAEC,SAAS,KAAM,MAAQC,IAAI,IAAQC,MAAM,IAAM;EAC1D,MAAMC,SAAS,GAAGJ,QAAQ,CAACK,MAAM,CAAEJ,SAAU,CAAC,CAACK,kBAAkB,CAAC,CAAC;EACnE,MAAMC,eAAe,GAAGC,MAAM,CAACC,OAAO,CAAEL,SAAU,CAAC;EACnDG,eAAe,CAACG,OAAO,CAAE,CAAE,CAAEC,YAAY,EAAEC,eAAe,CAAE,KAAM;IACjE,MAAMC,QAAQ,GACbb,QAAQ,CAACc,MAAM,CAAEb,SAAS,CAAE,EAAEG,SAAS,GAAIO,YAAY,CAAE;IAC1D,IAAK,CAAEE,QAAQ,IAAI,CAAEA,QAAQ,CAACE,gBAAgB,EAAG;MAChD;IACD;IACAH,eAAe,CAACF,OAAO,CAAE,CAAEM,KAAK,EAAEC,IAAI,KAAM;MAC3C;MACA;MACA,IAAKD,KAAK,KAAKE,SAAS,EAAG;QAC1B;MACD;;MAEA;MACA;MACA;MACA,IAAKF,KAAK,CAACG,MAAM,KAAK,UAAU,IAAIH,KAAK,CAACG,MAAM,KAAK,OAAO,EAAG;QAC9D;MACD;MAEA,IAAK,CAAEN,QAAQ,CAACE,gBAAgB,CAAEZ,MAAM,EAAE,GAAGc,IAAK,CAAC,EAAG;QACrD;MACD;;MAEA;MACAjB,QAAQ,CACNoB,QAAQ,CAAEnB,SAAU,CAAC,CACrBoB,oBAAoB,CAAEV,YAAY,EAAEM,IAAK,CAAC;IAC7C,CAAE,CAAC;EACJ,CAAE,CAAC;EACH,OAAOf,IAAI,CAAEC,MAAO,CAAC;AACtB,CAAC;AAEF,eAAeJ,8BAA8B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["defaultRegistry","select","storeNameOrDescriptor"],"sources":["@wordpress/data/src/select.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { AnyConfig, CurriedSelectorsOf, StoreDescriptor } from './types';\nimport defaultRegistry from './default-registry';\n\n/**\n * Given a store descriptor, returns an object of the store's selectors.\n * The selector functions are been pre-bound to pass the current state automatically.\n * As a consumer, you need only pass arguments of the selector, if applicable.\n *\n *\n * @param storeNameOrDescriptor The store descriptor. The legacy calling convention\n * of passing the store name is also supported.\n *\n * @example\n * ```js\n * import { select } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * select( myCustomStore ).getPrice( 'hammer' );\n * ```\n *\n * @return Object containing the store's selectors.\n */\nexport function select< T extends StoreDescriptor< AnyConfig > >(\n\tstoreNameOrDescriptor: string | T\n): CurriedSelectorsOf< T > {\n\treturn defaultRegistry.select( storeNameOrDescriptor );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAOA,eAAe,MAAM,oBAAoB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CACrBC,qBAAiC,EACP;EAC1B,OAAOF,eAAe,CAACC,MAAM,CAAEC,qBAAsB,CAAC;AACvD"}
1
+ {"version":3,"names":["defaultRegistry","select","storeNameOrDescriptor"],"sources":["@wordpress/data/src/select.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { AnyConfig, CurriedSelectorsOf, StoreDescriptor } from './types';\nimport defaultRegistry from './default-registry';\n\n/**\n * Given a store descriptor, returns an object of the store's selectors.\n * The selector functions are been pre-bound to pass the current state automatically.\n * As a consumer, you need only pass arguments of the selector, if applicable.\n *\n *\n * @param storeNameOrDescriptor The store descriptor. The legacy calling convention\n * of passing the store name is also supported.\n *\n * @example\n * ```js\n * import { select } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * select( myCustomStore ).getPrice( 'hammer' );\n * ```\n *\n * @return Object containing the store's selectors.\n */\nexport function select< T extends StoreDescriptor< AnyConfig > >(\n\tstoreNameOrDescriptor: string | T\n): CurriedSelectorsOf< T > {\n\treturn defaultRegistry.select( storeNameOrDescriptor );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAOA,eAAe,MAAM,oBAAoB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CACrBC,qBAAiC,EACP;EAC1B,OAAOF,eAAe,CAACC,MAAM,CAAEC,qBAAsB,CAAC;AACvD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["coreDataStore","name","instantiate","registry","getCoreDataSelector","selectorName","key","args","select","getCoreDataAction","actionName","dispatch","getSelectors","Object","fromEntries","map","getActions","subscribe"],"sources":["@wordpress/data/src/store/index.js"],"sourcesContent":["const coreDataStore = {\n\tname: 'core/data',\n\tinstantiate( registry ) {\n\t\tconst getCoreDataSelector =\n\t\t\t( selectorName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.select( key )[ selectorName ]( ...args );\n\t\t\t};\n\n\t\tconst getCoreDataAction =\n\t\t\t( actionName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.dispatch( key )[ actionName ]( ...args );\n\t\t\t};\n\n\t\treturn {\n\t\t\tgetSelectors() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'getIsResolving',\n\t\t\t\t\t\t'hasStartedResolution',\n\t\t\t\t\t\t'hasFinishedResolution',\n\t\t\t\t\t\t'isResolving',\n\t\t\t\t\t\t'getCachedResolvers',\n\t\t\t\t\t].map( ( selectorName ) => [\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tgetCoreDataSelector( selectorName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tgetActions() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'startResolution',\n\t\t\t\t\t\t'finishResolution',\n\t\t\t\t\t\t'invalidateResolution',\n\t\t\t\t\t\t'invalidateResolutionForStore',\n\t\t\t\t\t\t'invalidateResolutionForStoreSelector',\n\t\t\t\t\t].map( ( actionName ) => [\n\t\t\t\t\t\tactionName,\n\t\t\t\t\t\tgetCoreDataAction( actionName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tsubscribe() {\n\t\t\t\t// There's no reasons to trigger any listener when we subscribe to this store\n\t\t\t\t// because there's no state stored in this store that need to retrigger selectors\n\t\t\t\t// if a change happens, the corresponding store where the tracking stated live\n\t\t\t\t// would have already triggered a \"subscribe\" call.\n\t\t\t\treturn () => () => {};\n\t\t\t},\n\t\t};\n\t},\n};\n\nexport default coreDataStore;\n"],"mappings":"AAAA,MAAMA,aAAa,GAAG;EACrBC,IAAI,EAAE,WAAW;EACjBC,WAAWA,CAAEC,QAAQ,EAAG;IACvB,MAAMC,mBAAmB,GACtBC,YAAY,IACd,CAAEC,GAAG,EAAE,GAAGC,IAAI,KAAM;MACnB,OAAOJ,QAAQ,CAACK,MAAM,CAAEF,GAAI,CAAC,CAAED,YAAY,CAAE,CAAE,GAAGE,IAAK,CAAC;IACzD,CAAC;IAEF,MAAME,iBAAiB,GACpBC,UAAU,IACZ,CAAEJ,GAAG,EAAE,GAAGC,IAAI,KAAM;MACnB,OAAOJ,QAAQ,CAACQ,QAAQ,CAAEL,GAAI,CAAC,CAAEI,UAAU,CAAE,CAAE,GAAGH,IAAK,CAAC;IACzD,CAAC;IAEF,OAAO;MACNK,YAAYA,CAAA,EAAG;QACd,OAAOC,MAAM,CAACC,WAAW,CACxB,CACC,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,oBAAoB,CACpB,CAACC,GAAG,CAAIV,YAAY,IAAM,CAC1BA,YAAY,EACZD,mBAAmB,CAAEC,YAAa,CAAC,CAClC,CACH,CAAC;MACF,CAAC;MAEDW,UAAUA,CAAA,EAAG;QACZ,OAAOH,MAAM,CAACC,WAAW,CACxB,CACC,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,8BAA8B,EAC9B,sCAAsC,CACtC,CAACC,GAAG,CAAIL,UAAU,IAAM,CACxBA,UAAU,EACVD,iBAAiB,CAAEC,UAAW,CAAC,CAC9B,CACH,CAAC;MACF,CAAC;MAEDO,SAASA,CAAA,EAAG;QACX;QACA;QACA;QACA;QACA,OAAO,MAAM,MAAM,CAAC,CAAC;MACtB;IACD,CAAC;EACF;AACD,CAAC;AAED,eAAejB,aAAa"}
1
+ {"version":3,"names":["coreDataStore","name","instantiate","registry","getCoreDataSelector","selectorName","key","args","select","getCoreDataAction","actionName","dispatch","getSelectors","Object","fromEntries","map","getActions","subscribe"],"sources":["@wordpress/data/src/store/index.js"],"sourcesContent":["const coreDataStore = {\n\tname: 'core/data',\n\tinstantiate( registry ) {\n\t\tconst getCoreDataSelector =\n\t\t\t( selectorName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.select( key )[ selectorName ]( ...args );\n\t\t\t};\n\n\t\tconst getCoreDataAction =\n\t\t\t( actionName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.dispatch( key )[ actionName ]( ...args );\n\t\t\t};\n\n\t\treturn {\n\t\t\tgetSelectors() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'getIsResolving',\n\t\t\t\t\t\t'hasStartedResolution',\n\t\t\t\t\t\t'hasFinishedResolution',\n\t\t\t\t\t\t'isResolving',\n\t\t\t\t\t\t'getCachedResolvers',\n\t\t\t\t\t].map( ( selectorName ) => [\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tgetCoreDataSelector( selectorName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tgetActions() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'startResolution',\n\t\t\t\t\t\t'finishResolution',\n\t\t\t\t\t\t'invalidateResolution',\n\t\t\t\t\t\t'invalidateResolutionForStore',\n\t\t\t\t\t\t'invalidateResolutionForStoreSelector',\n\t\t\t\t\t].map( ( actionName ) => [\n\t\t\t\t\t\tactionName,\n\t\t\t\t\t\tgetCoreDataAction( actionName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tsubscribe() {\n\t\t\t\t// There's no reasons to trigger any listener when we subscribe to this store\n\t\t\t\t// because there's no state stored in this store that need to retrigger selectors\n\t\t\t\t// if a change happens, the corresponding store where the tracking stated live\n\t\t\t\t// would have already triggered a \"subscribe\" call.\n\t\t\t\treturn () => () => {};\n\t\t\t},\n\t\t};\n\t},\n};\n\nexport default coreDataStore;\n"],"mappings":"AAAA,MAAMA,aAAa,GAAG;EACrBC,IAAI,EAAE,WAAW;EACjBC,WAAWA,CAAEC,QAAQ,EAAG;IACvB,MAAMC,mBAAmB,GACtBC,YAAY,IACd,CAAEC,GAAG,EAAE,GAAGC,IAAI,KAAM;MACnB,OAAOJ,QAAQ,CAACK,MAAM,CAAEF,GAAI,CAAC,CAAED,YAAY,CAAE,CAAE,GAAGE,IAAK,CAAC;IACzD,CAAC;IAEF,MAAME,iBAAiB,GACpBC,UAAU,IACZ,CAAEJ,GAAG,EAAE,GAAGC,IAAI,KAAM;MACnB,OAAOJ,QAAQ,CAACQ,QAAQ,CAAEL,GAAI,CAAC,CAAEI,UAAU,CAAE,CAAE,GAAGH,IAAK,CAAC;IACzD,CAAC;IAEF,OAAO;MACNK,YAAYA,CAAA,EAAG;QACd,OAAOC,MAAM,CAACC,WAAW,CACxB,CACC,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,oBAAoB,CACpB,CAACC,GAAG,CAAIV,YAAY,IAAM,CAC1BA,YAAY,EACZD,mBAAmB,CAAEC,YAAa,CAAC,CAClC,CACH,CAAC;MACF,CAAC;MAEDW,UAAUA,CAAA,EAAG;QACZ,OAAOH,MAAM,CAACC,WAAW,CACxB,CACC,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,8BAA8B,EAC9B,sCAAsC,CACtC,CAACC,GAAG,CAAIL,UAAU,IAAM,CACxBA,UAAU,EACVD,iBAAiB,CAAEC,UAAW,CAAC,CAC9B,CACH,CAAC;MACF,CAAC;MAEDO,SAASA,CAAA,EAAG;QACX;QACA;QACA;QACA;QACA,OAAO,MAAM,MAAM,CAAC,CAAC;MACtB;IACD,CAAC;EACF;AACD,CAAC;AAED,eAAejB,aAAa","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/data/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { combineReducers as reduxCombineReducers } from 'redux';\n\ntype MapOf< T > = { [ name: string ]: T };\n\nexport type ActionCreator = ( ...args: any[] ) => any | Generator;\nexport type Resolver = Function | Generator;\nexport type Selector = Function;\n\nexport type AnyConfig = ReduxStoreConfig< any, any, any >;\n\nexport interface StoreInstance< Config extends AnyConfig > {\n\tgetSelectors: () => SelectorsOf< Config >;\n\tgetActions: () => ActionCreatorsOf< Config >;\n\tsubscribe: ( listener: () => void ) => () => void;\n}\n\nexport interface StoreDescriptor< Config extends AnyConfig > {\n\t/**\n\t * Store Name\n\t */\n\tname: string;\n\n\t/**\n\t * Creates a store instance\n\t */\n\tinstantiate: ( registry: DataRegistry ) => StoreInstance< Config >;\n}\n\nexport interface ReduxStoreConfig<\n\tState,\n\tActionCreators extends MapOf< ActionCreator >,\n\tSelectors,\n> {\n\tinitialState?: State;\n\treducer: ( state: any, action: any ) => any;\n\tactions?: ActionCreators;\n\tresolvers?: MapOf< Resolver >;\n\tselectors?: Selectors;\n\tcontrols?: MapOf< Function >;\n}\n\n// Return type for the useSelect() hook.\nexport type UseSelectReturn< F extends MapSelect | StoreDescriptor< any > > =\n\tF extends MapSelect\n\t\t? ReturnType< F >\n\t\t: F extends StoreDescriptor< any >\n\t\t? CurriedSelectorsOf< F >\n\t\t: never;\n\n// Return type for the useDispatch() hook.\nexport type UseDispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: StoreNameOrDescriptor extends undefined\n\t\t? DispatchFunction\n\t\t: any;\n\nexport type DispatchFunction = < StoreNameOrDescriptor >(\n\tstore: StoreNameOrDescriptor\n) => DispatchReturn< StoreNameOrDescriptor >;\n\nexport type DispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: unknown;\n\nexport type MapSelect = (\n\tselect: SelectFunction,\n\tregistry: DataRegistry\n) => any;\n\nexport type SelectFunction = < S >( store: S ) => CurriedSelectorsOf< S >;\n\n/**\n * Callback for store's `subscribe()` method that\n * runs when the store data has changed.\n */\nexport type ListenerFunction = () => void;\n\nexport type CurriedSelectorsOf< S > = S extends StoreDescriptor<\n\tReduxStoreConfig< any, any, infer Selectors >\n>\n\t? { [ key in keyof Selectors ]: CurriedState< Selectors[ key ] > }\n\t: never;\n\n/**\n * 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}\n\nexport interface DataRegistry {\n\tregister: ( store: StoreDescriptor< any > ) => void;\n}\n\nexport interface DataEmitter {\n\temit: () => void;\n\tsubscribe: ( listener: () => void ) => () => void;\n\tpause: () => void;\n\tresume: () => void;\n\tisPaused: boolean;\n}\n\n// Type Helpers.\n\nexport type ConfigOf< S > = S extends StoreDescriptor< infer C > ? C : never;\n\nexport type ActionCreatorsOf< Config extends AnyConfig > =\n\tConfig extends ReduxStoreConfig< any, infer ActionCreators, any >\n\t\t? PromisifiedActionCreators< ActionCreators >\n\t\t: never;\n\n// Takes an object containing all action creators for a store and updates the\n// return type of each action creator to account for internal registry details --\n// for example, dispatched actions are wrapped with a Promise.\nexport type PromisifiedActionCreators<\n\tActionCreators extends MapOf< ActionCreator >,\n> = {\n\t[ Action in keyof ActionCreators ]: PromisifyActionCreator<\n\t\tActionCreators[ Action ]\n\t>;\n};\n\n// Wraps action creator return types with a Promise and handles thunks.\nexport type PromisifyActionCreator< Action extends ActionCreator > = (\n\t...args: Parameters< Action >\n) => Promise<\n\tReturnType< Action > extends ( ..._args: any[] ) => any\n\t\t? ThunkReturnType< Action >\n\t\t: ReturnType< Action >\n>;\n\n// A thunk is an action creator which returns a function, which can optionally\n// return a Promise. The double ReturnType unwraps the innermost function's\n// return type, and Awaited gets the type the Promise resolves to. If the return\n// type is not a Promise, Awaited returns that original type.\nexport type ThunkReturnType< Action extends ActionCreator > = Awaited<\n\tReturnType< ReturnType< Action > >\n>;\n\ntype SelectorsOf< Config extends AnyConfig > = Config extends ReduxStoreConfig<\n\tany,\n\tany,\n\tinfer Selectors\n>\n\t? { [ name in keyof Selectors ]: Function }\n\t: never;\n\nexport type combineReducers = typeof reduxCombineReducers;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["@wordpress/data/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { combineReducers as reduxCombineReducers } from 'redux';\n\ntype MapOf< T > = { [ name: string ]: T };\n\nexport type ActionCreator = ( ...args: any[] ) => any | Generator;\nexport type Resolver = Function | Generator;\nexport type Selector = Function;\n\nexport type AnyConfig = ReduxStoreConfig< any, any, any >;\n\nexport interface StoreInstance< Config extends AnyConfig > {\n\tgetSelectors: () => SelectorsOf< Config >;\n\tgetActions: () => ActionCreatorsOf< Config >;\n\tsubscribe: ( listener: () => void ) => () => void;\n}\n\nexport interface StoreDescriptor< Config extends AnyConfig > {\n\t/**\n\t * Store Name\n\t */\n\tname: string;\n\n\t/**\n\t * Creates a store instance\n\t */\n\tinstantiate: ( registry: DataRegistry ) => StoreInstance< Config >;\n}\n\nexport interface ReduxStoreConfig<\n\tState,\n\tActionCreators extends MapOf< ActionCreator >,\n\tSelectors,\n> {\n\tinitialState?: State;\n\treducer: ( state: any, action: any ) => any;\n\tactions?: ActionCreators;\n\tresolvers?: MapOf< Resolver >;\n\tselectors?: Selectors;\n\tcontrols?: MapOf< Function >;\n}\n\n// Return type for the useSelect() hook.\nexport type UseSelectReturn< F extends MapSelect | StoreDescriptor< any > > =\n\tF extends MapSelect\n\t\t? ReturnType< F >\n\t\t: F extends StoreDescriptor< any >\n\t\t? CurriedSelectorsOf< F >\n\t\t: never;\n\n// Return type for the useDispatch() hook.\nexport type UseDispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: StoreNameOrDescriptor extends undefined\n\t\t? DispatchFunction\n\t\t: any;\n\nexport type DispatchFunction = < StoreNameOrDescriptor >(\n\tstore: StoreNameOrDescriptor\n) => DispatchReturn< StoreNameOrDescriptor >;\n\nexport type DispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: unknown;\n\nexport type MapSelect = (\n\tselect: SelectFunction,\n\tregistry: DataRegistry\n) => any;\n\nexport type SelectFunction = < S >( store: S ) => CurriedSelectorsOf< S >;\n\n/**\n * Callback for store's `subscribe()` method that\n * runs when the store data has changed.\n */\nexport type ListenerFunction = () => void;\n\nexport type CurriedSelectorsOf< S > = S extends StoreDescriptor<\n\tReduxStoreConfig< any, any, infer Selectors >\n>\n\t? { [ key in keyof Selectors ]: CurriedState< Selectors[ key ] > }\n\t: never;\n\n/**\n * 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}\n\nexport interface DataRegistry {\n\tregister: ( store: StoreDescriptor< any > ) => void;\n}\n\nexport interface DataEmitter {\n\temit: () => void;\n\tsubscribe: ( listener: () => void ) => () => void;\n\tpause: () => void;\n\tresume: () => void;\n\tisPaused: boolean;\n}\n\n// Type Helpers.\n\nexport type ConfigOf< S > = S extends StoreDescriptor< infer C > ? C : never;\n\nexport type ActionCreatorsOf< Config extends AnyConfig > =\n\tConfig extends ReduxStoreConfig< any, infer ActionCreators, any >\n\t\t? PromisifiedActionCreators< ActionCreators >\n\t\t: never;\n\n// Takes an object containing all action creators for a store and updates the\n// return type of each action creator to account for internal registry details --\n// for example, dispatched actions are wrapped with a Promise.\nexport type PromisifiedActionCreators<\n\tActionCreators extends MapOf< ActionCreator >,\n> = {\n\t[ Action in keyof ActionCreators ]: PromisifyActionCreator<\n\t\tActionCreators[ Action ]\n\t>;\n};\n\n// Wraps action creator return types with a Promise and handles thunks.\nexport type PromisifyActionCreator< Action extends ActionCreator > = (\n\t...args: Parameters< Action >\n) => Promise<\n\tReturnType< Action > extends ( ..._args: any[] ) => any\n\t\t? ThunkReturnType< Action >\n\t\t: ReturnType< Action >\n>;\n\n// A thunk is an action creator which returns a function, which can optionally\n// return a Promise. The double ReturnType unwraps the innermost function's\n// return type, and Awaited gets the type the Promise resolves to. If the return\n// type is not a Promise, Awaited returns that original type.\nexport type ThunkReturnType< Action extends ActionCreator > = Awaited<\n\tReturnType< ReturnType< Action > >\n>;\n\ntype SelectorsOf< Config extends AnyConfig > = Config extends ReduxStoreConfig<\n\tany,\n\tany,\n\tinfer Selectors\n>\n\t? { [ name in keyof Selectors ]: Function }\n\t: never;\n\nexport type combineReducers = typeof reduxCombineReducers;\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["createEmitter","isPaused","isPending","listeners","Set","notifyListeners","Array","from","forEach","listener","subscribe","add","delete","pause","resume","emit"],"sources":["@wordpress/data/src/utils/emitter.js"],"sourcesContent":["/**\n * Create an event emitter.\n *\n * @return {import(\"../types\").DataEmitter} Emitter.\n */\nexport function createEmitter() {\n\tlet isPaused = false;\n\tlet isPending = false;\n\tconst listeners = new Set();\n\tconst notifyListeners = () =>\n\t\t// We use Array.from to clone the listeners Set\n\t\t// This ensures that we don't run a listener\n\t\t// that was added as a response to another listener.\n\t\tArray.from( listeners ).forEach( ( listener ) => listener() );\n\n\treturn {\n\t\tget isPaused() {\n\t\t\treturn isPaused;\n\t\t},\n\n\t\tsubscribe( listener ) {\n\t\t\tlisteners.add( listener );\n\t\t\treturn () => listeners.delete( listener );\n\t\t},\n\n\t\tpause() {\n\t\t\tisPaused = true;\n\t\t},\n\n\t\tresume() {\n\t\t\tisPaused = false;\n\t\t\tif ( isPending ) {\n\t\t\t\tisPending = false;\n\t\t\t\tnotifyListeners();\n\t\t\t}\n\t\t},\n\n\t\temit() {\n\t\t\tif ( isPaused ) {\n\t\t\t\tisPending = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnotifyListeners();\n\t\t},\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAaA,CAAA,EAAG;EAC/B,IAAIC,QAAQ,GAAG,KAAK;EACpB,IAAIC,SAAS,GAAG,KAAK;EACrB,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;EAC3B,MAAMC,eAAe,GAAGA,CAAA;EACvB;EACA;EACA;EACAC,KAAK,CAACC,IAAI,CAAEJ,SAAU,CAAC,CAACK,OAAO,CAAIC,QAAQ,IAAMA,QAAQ,CAAC,CAAE,CAAC;EAE9D,OAAO;IACN,IAAIR,QAAQA,CAAA,EAAG;MACd,OAAOA,QAAQ;IAChB,CAAC;IAEDS,SAASA,CAAED,QAAQ,EAAG;MACrBN,SAAS,CAACQ,GAAG,CAAEF,QAAS,CAAC;MACzB,OAAO,MAAMN,SAAS,CAACS,MAAM,CAAEH,QAAS,CAAC;IAC1C,CAAC;IAEDI,KAAKA,CAAA,EAAG;MACPZ,QAAQ,GAAG,IAAI;IAChB,CAAC;IAEDa,MAAMA,CAAA,EAAG;MACRb,QAAQ,GAAG,KAAK;MAChB,IAAKC,SAAS,EAAG;QAChBA,SAAS,GAAG,KAAK;QACjBG,eAAe,CAAC,CAAC;MAClB;IACD,CAAC;IAEDU,IAAIA,CAAA,EAAG;MACN,IAAKd,QAAQ,EAAG;QACfC,SAAS,GAAG,IAAI;QAChB;MACD;MACAG,eAAe,CAAC,CAAC;IAClB;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["createEmitter","isPaused","isPending","listeners","Set","notifyListeners","Array","from","forEach","listener","subscribe","add","delete","pause","resume","emit"],"sources":["@wordpress/data/src/utils/emitter.js"],"sourcesContent":["/**\n * Create an event emitter.\n *\n * @return {import(\"../types\").DataEmitter} Emitter.\n */\nexport function createEmitter() {\n\tlet isPaused = false;\n\tlet isPending = false;\n\tconst listeners = new Set();\n\tconst notifyListeners = () =>\n\t\t// We use Array.from to clone the listeners Set\n\t\t// This ensures that we don't run a listener\n\t\t// that was added as a response to another listener.\n\t\tArray.from( listeners ).forEach( ( listener ) => listener() );\n\n\treturn {\n\t\tget isPaused() {\n\t\t\treturn isPaused;\n\t\t},\n\n\t\tsubscribe( listener ) {\n\t\t\tlisteners.add( listener );\n\t\t\treturn () => listeners.delete( listener );\n\t\t},\n\n\t\tpause() {\n\t\t\tisPaused = true;\n\t\t},\n\n\t\tresume() {\n\t\t\tisPaused = false;\n\t\t\tif ( isPending ) {\n\t\t\t\tisPending = false;\n\t\t\t\tnotifyListeners();\n\t\t\t}\n\t\t},\n\n\t\temit() {\n\t\t\tif ( isPaused ) {\n\t\t\t\tisPending = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnotifyListeners();\n\t\t},\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAaA,CAAA,EAAG;EAC/B,IAAIC,QAAQ,GAAG,KAAK;EACpB,IAAIC,SAAS,GAAG,KAAK;EACrB,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;EAC3B,MAAMC,eAAe,GAAGA,CAAA;EACvB;EACA;EACA;EACAC,KAAK,CAACC,IAAI,CAAEJ,SAAU,CAAC,CAACK,OAAO,CAAIC,QAAQ,IAAMA,QAAQ,CAAC,CAAE,CAAC;EAE9D,OAAO;IACN,IAAIR,QAAQA,CAAA,EAAG;MACd,OAAOA,QAAQ;IAChB,CAAC;IAEDS,SAASA,CAAED,QAAQ,EAAG;MACrBN,SAAS,CAACQ,GAAG,CAAEF,QAAS,CAAC;MACzB,OAAO,MAAMN,SAAS,CAACS,MAAM,CAAEH,QAAS,CAAC;IAC1C,CAAC;IAEDI,KAAKA,CAAA,EAAG;MACPZ,QAAQ,GAAG,IAAI;IAChB,CAAC;IAEDa,MAAMA,CAAA,EAAG;MACRb,QAAQ,GAAG,KAAK;MAChB,IAAKC,SAAS,EAAG;QAChBA,SAAS,GAAG,KAAK;QACjBG,eAAe,CAAC,CAAC;MAClB;IACD,CAAC;IAEDU,IAAIA,CAAA,EAAG;MACN,IAAKd,QAAQ,EAAG;QACfC,SAAS,GAAG,IAAI;QAChB;MACD;MACAG,eAAe,CAAC,CAAC;IAClB;EACD,CAAC;AACF","ignoreList":[]}
@@ -64,21 +64,25 @@
64
64
  */
65
65
  export default function useSelect<T extends import("../../types").MapSelect | import("../../types").StoreDescriptor<any>>(mapSelect: T, deps: unknown[]): import("../../types").UseSelectReturn<T>;
66
66
  /**
67
- * A variant of the `useSelect` hook that has the same API, but will throw a
68
- * suspense Promise if any of the called selectors is in an unresolved state.
67
+ * A variant of the `useSelect` hook that has the same API, but is a compatible
68
+ * Suspense-enabled data source.
69
69
  *
70
- * @param {Function} mapSelect Function called on every state change. The
71
- * returned value is exposed to the component
72
- * using this hook. The function receives the
73
- * `registry.suspendSelect` method as the first
74
- * argument and the `registry` as the second one.
75
- * @param {Array} deps A dependency array used to memoize the `mapSelect`
76
- * so that the same `mapSelect` is invoked on every
77
- * state change unless the dependencies change.
70
+ * @template {MapSelect} T
71
+ * @param {T} mapSelect Function called on every state change. The
72
+ * returned value is exposed to the component
73
+ * using this hook. The function receives the
74
+ * `registry.suspendSelect` method as the first
75
+ * argument and the `registry` as the second one.
76
+ * @param {Array} deps A dependency array used to memoize the `mapSelect`
77
+ * so that the same `mapSelect` is invoked on every
78
+ * state change unless the dependencies change.
78
79
  *
79
- * @return {Object} Data object returned by the `mapSelect` function.
80
+ * @throws {Promise} A suspense Promise that is thrown if any of the called
81
+ * selectors is in an unresolved state.
82
+ *
83
+ * @return {ReturnType<T>} Data object returned by the `mapSelect` function.
80
84
  */
81
- export function useSuspenseSelect(mapSelect: Function, deps: any[]): Object;
85
+ export function useSuspenseSelect<T extends import("../../types").MapSelect>(mapSelect: T, deps: any[]): ReturnType<T>;
82
86
  export type StoreDescriptor<C extends import("../../types").AnyConfig> = import('../../types').StoreDescriptor<C>;
83
87
  export type ReduxStoreConfig<State, Actions extends Record<string, import("../../types").ActionCreator>, Selectors> = import('../../types').ReduxStoreConfig<State, Actions, Selectors>;
84
88
  export type MapSelect = import('../../types').MapSelect;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/use-select/index.js"],"names":[],"mappings":"AAyOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,8IAlDW,OAAO,EAAE,4CAuEnB;AAED;;;;;;;;;;;;;;GAcG;AACH,qEAFY,MAAM,CAIjB;yEA3TY,OAAO,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;sHAIxC,OAAO,aAAa,EAAE,gBAAgB,CAAC,KAAK,EAAC,OAAO,EAAC,SAAS,CAAC;wBAK9D,OAAO,aAAa,EAAE,SAAS;sHAEhC,OAAO,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/use-select/index.js"],"names":[],"mappings":"AAyOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,8IAlDW,OAAO,EAAE,4CAuEnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,uHAEC;yEA/TY,OAAO,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;sHAIxC,OAAO,aAAa,EAAE,gBAAgB,CAAC,KAAK,EAAC,OAAO,EAAC,SAAS,CAAC;wBAK9D,OAAO,aAAa,EAAE,SAAS;sHAEhC,OAAO,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as createSelector } from "rememo";
2
+ //# sourceMappingURL=create-selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-selector.d.ts","sourceRoot":"","sources":["../src/create-selector.js"],"names":[],"mappings":""}
@@ -4,6 +4,7 @@ export { default as withRegistry } from "./components/with-registry";
4
4
  export { useDispatch } from "./components/use-dispatch";
5
5
  export { AsyncModeProvider } from "./components/async-mode-provider";
6
6
  export { createRegistry } from "./registry";
7
+ export { createSelector } from "./create-selector";
7
8
  export { controls } from "./controls";
8
9
  export { default as createReduxStore } from "./redux-store";
9
10
  export { dispatch } from "./dispatch";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;AAuCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,8BAnCW,OAAO,SAAS,EAAE,eAAe,CAmCS;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,gCAA2D;AAE3D;;;;;;;;;;GAUG;AACH,gCAA2D;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iCAAmD;AAEnD;;;;;;;GAOG;AACH,4CAAyE;AAEzE;;;;;;;;;GASG;AACH,qCAA2D;AAE3D;;;;;;GAMG;AACH,sBAAuC;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACH,2BAAiD;;yBAzLxB,WAAW"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,8BAnCW,OAAO,SAAS,EAAE,eAAe,CAmCS;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,gCAA2D;AAE3D;;;;;;;;;;GAUG;AACH,gCAA2D;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iCAAmD;AAEnD;;;;;;;GAOG;AACH,4CAAyE;AAEzE;;;;;;;;;GASG;AACH,qCAA2D;AAE3D;;;;;;GAMG;AACH,sBAAuC;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACH,2BAAiD;;yBA1LxB,WAAW"}
@@ -1,3 +1,4 @@
1
+ /// <reference path="../../../src/redux-store/metadata/equivalent-key-map.d.ts" />
1
2
  /**
2
3
  * External dependencies
3
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/reducer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAQlD,KAAK,MAAM,GACR,UAAU,CAAE,cAAc,WAAW,EAAE,eAAe,CAAE,GACxD,UAAU,CAAE,cAAc,WAAW,EAAE,gBAAgB,CAAE,GACzD,UAAU,CAAE,cAAc,WAAW,EAAE,cAAc,CAAE,GACvD,UAAU,CAAE,cAAc,WAAW,EAAE,gBAAgB,CAAE,GACzD,UAAU,CAAE,cAAc,WAAW,EAAE,iBAAiB,CAAE,GAC1D,UAAU,CAAE,cAAc,WAAW,EAAE,eAAe,CAAE,GACxD,UAAU,CAAE,cAAc,WAAW,EAAE,oBAAoB,CAAE,GAC7D,UAAU,CAAE,cAAc,WAAW,EAAE,4BAA4B,CAAE,GACrE,UAAU,CACV,cAAc,WAAW,EAAE,oCAAoC,CAC9D,CAAC;AAEL,KAAK,QAAQ,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC;AACpC,MAAM,MAAM,UAAU,GACnB;IAAE,MAAM,EAAE,WAAW,GAAG,UAAU,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAA;CAAE,CAAC;AAE/C,MAAM,MAAM,MAAM,GAAG,UAAU,CAAE,QAAQ,CAAE,CAAC;AAC5C,MAAM,MAAM,KAAK,GAAG,gBAAgB,CAAE,QAAQ,EAAE,UAAU,CAAE,CAAC;AAkF7D;;;;;;;;;GASG;AACH,QAAA,MAAM,UAAU,qDAAkD,MAAM,0BAwBvE,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/reducer.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAQlD,KAAK,MAAM,GACR,UAAU,CAAE,cAAc,WAAW,EAAE,eAAe,CAAE,GACxD,UAAU,CAAE,cAAc,WAAW,EAAE,gBAAgB,CAAE,GACzD,UAAU,CAAE,cAAc,WAAW,EAAE,cAAc,CAAE,GACvD,UAAU,CAAE,cAAc,WAAW,EAAE,gBAAgB,CAAE,GACzD,UAAU,CAAE,cAAc,WAAW,EAAE,iBAAiB,CAAE,GAC1D,UAAU,CAAE,cAAc,WAAW,EAAE,eAAe,CAAE,GACxD,UAAU,CAAE,cAAc,WAAW,EAAE,oBAAoB,CAAE,GAC7D,UAAU,CAAE,cAAc,WAAW,EAAE,4BAA4B,CAAE,GACrE,UAAU,CACV,cAAc,WAAW,EAAE,oCAAoC,CAC9D,CAAC;AAEL,KAAK,QAAQ,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC;AACpC,MAAM,MAAM,UAAU,GACnB;IAAE,MAAM,EAAE,WAAW,GAAG,UAAU,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAA;CAAE,CAAC;AAE/C,MAAM,MAAM,MAAM,GAAG,UAAU,CAAE,QAAQ,CAAE,CAAC;AAC5C,MAAM,MAAM,KAAK,GAAG,gBAAgB,CAAE,QAAQ,EAAE,UAAU,CAAE,CAAC;AAkF7D;;;;;;;;;GASG;AACH,QAAA,MAAM,UAAU,qDAAkD,MAAM,0BAwBvE,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/selectors.js"],"names":[],"mappings":";AAeA,iEAAiE;AACjE,2DAA2D;AAC3D,mDAAmD;AAEnD;;;;;;;;;;;GAWG;AACH,0CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,UAAU,GAAC,SAAS,CAS/B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,sCANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,GAAG,SAAS,CAW9B;AAED;;;;;;;;;GASG;AACH,4CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAIlB;AAED;;;;;;;;;GASG;AACH,6CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAKlB;AAED;;;;;;;;;GASG;AACH,2CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAIlB;AAED;;;;;;;;;;GAUG;AACH,0CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,KAAK,GAAC,OAAO,CAKxB;AAED;;;;;;;;;GASG;AACH,mCANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAMlB;AAED;;;;;;GAMG;AACH,0CAJW,KAAK,GAEJ,KAAK,CAIhB;AAED;;;;;;GAMG;AACH,6CAJW,KAAK,GAEJ,OAAO,CAelB;AAED;;;;;;GAMG;AACH,8FA0BE;oBAnMY,OAAO,MAAM,EAAE,OAAO,WAAW,EAAE,KAAK,CAAC;yBACzC,OAAO,WAAW,EAAE,UAAU;qBAC9B,OAAO,WAAW,EAAE,MAAM"}
1
+ {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/selectors.js"],"names":[],"mappings":";AAWA,iEAAiE;AACjE,2DAA2D;AAC3D,mDAAmD;AAEnD;;;;;;;;;;;GAWG;AACH,0CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,UAAU,GAAC,SAAS,CAS/B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,sCANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,GAAG,SAAS,CAW9B;AAED;;;;;;;;;GASG;AACH,4CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAIlB;AAED;;;;;;;;;GASG;AACH,6CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAKlB;AAED;;;;;;;;;GASG;AACH,2CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAIlB;AAED;;;;;;;;;;GAUG;AACH,0CANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,KAAK,GAAC,OAAO,CAKxB;AAED;;;;;;;;;GASG;AACH,mCANW,KAAK,gBACL,MAAM,QACN,OAAO,EAAE,UAER,OAAO,CAMlB;AAED;;;;;;GAMG;AACH,0CAJW,KAAK,GAEJ,KAAK,CAIhB;AAED;;;;;;GAMG;AACH,6CAJW,KAAK,GAEJ,OAAO,CAelB;AAED;;;;;;GAMG;AACH,8FA0BE;oBAnMY,OAAO,MAAM,EAAE,OAAO,WAAW,EAAE,KAAK,CAAC;yBACzC,OAAO,WAAW,EAAE,UAAU;qBAC9B,OAAO,WAAW,EAAE,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,sEAEH,MAAM,oFAwBtB,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,aAWzE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/redux-store/metadata/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,sEAEH,MAAM,eAGb,QAAS,MAAM,EAAE,OAAO,CAAE,KACjC,QAAS,OAAQ,MAAM,EAAE,MAAM,CAAE,EAAE,OAAO,CAoB5C,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,aAWzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/data",
3
- "version": "9.25.0",
3
+ "version": "9.26.0",
4
4
  "description": "Data module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -29,13 +29,13 @@
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.16.0",
32
- "@wordpress/compose": "^6.32.0",
33
- "@wordpress/deprecated": "^3.55.0",
34
- "@wordpress/element": "^5.32.0",
35
- "@wordpress/is-shallow-equal": "^4.55.0",
36
- "@wordpress/priority-queue": "^2.55.0",
37
- "@wordpress/private-apis": "^0.37.0",
38
- "@wordpress/redux-routine": "^4.55.0",
32
+ "@wordpress/compose": "^6.33.0",
33
+ "@wordpress/deprecated": "^3.56.0",
34
+ "@wordpress/element": "^5.33.0",
35
+ "@wordpress/is-shallow-equal": "^4.56.0",
36
+ "@wordpress/priority-queue": "^2.56.0",
37
+ "@wordpress/private-apis": "^0.38.0",
38
+ "@wordpress/redux-routine": "^4.56.0",
39
39
  "deepmerge": "^4.3.0",
40
40
  "equivalent-key-map": "^0.2.2",
41
41
  "is-plain-object": "^5.0.0",
@@ -50,5 +50,5 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "ac2b13783c28f959770cf029a797a712f59e1958"
53
+ "gitHead": "280403b4c1cf6cc2c55a6c4d56f9ef91145e4191"
54
54
  }
@@ -319,19 +319,23 @@ export default function useSelect( mapSelect, deps ) {
319
319
  }
320
320
 
321
321
  /**
322
- * A variant of the `useSelect` hook that has the same API, but will throw a
323
- * suspense Promise if any of the called selectors is in an unresolved state.
322
+ * A variant of the `useSelect` hook that has the same API, but is a compatible
323
+ * Suspense-enabled data source.
324
324
  *
325
- * @param {Function} mapSelect Function called on every state change. The
326
- * returned value is exposed to the component
327
- * using this hook. The function receives the
328
- * `registry.suspendSelect` method as the first
329
- * argument and the `registry` as the second one.
330
- * @param {Array} deps A dependency array used to memoize the `mapSelect`
331
- * so that the same `mapSelect` is invoked on every
332
- * state change unless the dependencies change.
325
+ * @template {MapSelect} T
326
+ * @param {T} mapSelect Function called on every state change. The
327
+ * returned value is exposed to the component
328
+ * using this hook. The function receives the
329
+ * `registry.suspendSelect` method as the first
330
+ * argument and the `registry` as the second one.
331
+ * @param {Array} deps A dependency array used to memoize the `mapSelect`
332
+ * so that the same `mapSelect` is invoked on every
333
+ * state change unless the dependencies change.
333
334
  *
334
- * @return {Object} Data object returned by the `mapSelect` function.
335
+ * @throws {Promise} A suspense Promise that is thrown if any of the called
336
+ * selectors is in an unresolved state.
337
+ *
338
+ * @return {ReturnType<T>} Data object returned by the `mapSelect` function.
335
339
  */
336
340
  export function useSuspenseSelect( mapSelect, deps ) {
337
341
  return useMappingSelect( true, mapSelect, deps );
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Creates a memoized selector that caches the computed values according to the array of "dependants"
3
+ * and the selector parameters, and recomputes the values only when any of them changes.
4
+ *
5
+ * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.
6
+ *
7
+ * @param {Function} selector Selector function that calculates a value from state and parameters.
8
+ * @param {Function} getDependants Function that returns an array of "dependant" objects.
9
+ * @return {Function} A memoized version of `selector` that caches the calculated return values.
10
+ */
11
+ export { default as createSelector } from 'rememo';
package/src/index.js CHANGED
@@ -23,6 +23,7 @@ export { useDispatch } from './components/use-dispatch';
23
23
  export { AsyncModeProvider } from './components/async-mode-provider';
24
24
  export { createRegistry } from './registry';
25
25
  export { createRegistrySelector, createRegistryControl } from './factory';
26
+ export { createSelector } from './create-selector';
26
27
  export { controls } from './controls';
27
28
  export { default as createReduxStore } from './redux-store';
28
29
  export { dispatch } from './dispatch';
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import createSelector from 'rememo';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -11,6 +6,7 @@ import deprecated from '@wordpress/deprecated';
11
6
  /**
12
7
  * Internal dependencies
13
8
  */
9
+ import { createSelector } from '../../create-selector';
14
10
  import { selectorArgsToStateKey } from './utils';
15
11
 
16
12
  /** @typedef {Record<string, import('./reducer').State>} State */
@@ -1,13 +1,9 @@
1
- /**
2
- * External dependencies
3
- */
4
- import createSelector from 'rememo';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
9
4
  import { createRegistry } from '../registry';
10
5
  import { createRegistrySelector } from '../factory';
6
+ import { createSelector } from '..';
11
7
  import createReduxStore from '../redux-store';
12
8
 
13
9
  const getElementCount = createRegistrySelector( ( select ) => () => {