@wordpress/data 10.41.0 → 10.41.1-next.v.202603161435.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 (213) hide show
  1. package/README.md +20 -28
  2. package/build/components/async-mode-provider/context.cjs +1 -1
  3. package/build/components/async-mode-provider/context.cjs.map +3 -3
  4. package/build/components/async-mode-provider/index.cjs +1 -1
  5. package/build/components/async-mode-provider/index.cjs.map +1 -1
  6. package/build/components/async-mode-provider/use-async-mode.cjs +1 -1
  7. package/build/components/async-mode-provider/use-async-mode.cjs.map +3 -3
  8. package/build/components/registry-provider/context.cjs +1 -1
  9. package/build/components/registry-provider/context.cjs.map +1 -1
  10. package/build/components/registry-provider/index.cjs +1 -1
  11. package/build/components/registry-provider/index.cjs.map +1 -1
  12. package/build/components/registry-provider/use-registry.cjs +1 -1
  13. package/build/components/registry-provider/use-registry.cjs.map +3 -3
  14. package/build/components/use-dispatch/index.cjs +1 -1
  15. package/build/components/use-dispatch/index.cjs.map +1 -1
  16. package/build/components/use-dispatch/use-dispatch-with-map.cjs +1 -1
  17. package/build/components/use-dispatch/use-dispatch-with-map.cjs.map +3 -3
  18. package/build/components/use-dispatch/use-dispatch.cjs +1 -1
  19. package/build/components/use-dispatch/use-dispatch.cjs.map +3 -3
  20. package/build/components/use-select/index.cjs +2 -2
  21. package/build/components/use-select/index.cjs.map +3 -3
  22. package/build/components/with-dispatch/index.cjs +1 -1
  23. package/build/components/with-dispatch/index.cjs.map +3 -3
  24. package/build/components/with-registry/index.cjs +1 -1
  25. package/build/components/with-registry/index.cjs.map +3 -3
  26. package/build/components/with-select/index.cjs +1 -1
  27. package/build/components/with-select/index.cjs.map +3 -3
  28. package/build/controls.cjs +7 -6
  29. package/build/controls.cjs.map +3 -3
  30. package/build/default-registry.cjs +3 -2
  31. package/build/default-registry.cjs.map +3 -3
  32. package/build/dispatch.cjs +3 -1
  33. package/build/dispatch.cjs.map +2 -2
  34. package/build/factory.cjs.map +2 -2
  35. package/build/index.cjs +9 -8
  36. package/build/index.cjs.map +3 -3
  37. package/build/plugins/index.cjs +1 -1
  38. package/build/plugins/index.cjs.map +1 -1
  39. package/build/plugins/persistence/index.cjs +13 -8
  40. package/build/plugins/persistence/index.cjs.map +3 -3
  41. package/build/plugins/persistence/storage/default.cjs +1 -1
  42. package/build/plugins/persistence/storage/default.cjs.map +3 -3
  43. package/build/plugins/persistence/storage/object.cjs +1 -1
  44. package/build/plugins/persistence/storage/object.cjs.map +3 -3
  45. package/build/promise-middleware.cjs +2 -1
  46. package/build/promise-middleware.cjs.map +3 -3
  47. package/build/redux-store/index.cjs +32 -16
  48. package/build/redux-store/index.cjs.map +3 -3
  49. package/build/redux-store/metadata/selectors.cjs +1 -1
  50. package/build/redux-store/metadata/selectors.cjs.map +3 -3
  51. package/build/redux-store/metadata/types.cjs +19 -0
  52. package/build/redux-store/metadata/types.cjs.map +7 -0
  53. package/build/registry.cjs +11 -7
  54. package/build/registry.cjs.map +3 -3
  55. package/build/resolvers-cache-middleware.cjs +6 -3
  56. package/build/resolvers-cache-middleware.cjs.map +3 -3
  57. package/build/select.cjs +3 -1
  58. package/build/select.cjs.map +2 -2
  59. package/build/store/index.cjs +1 -1
  60. package/build/store/index.cjs.map +3 -3
  61. package/build/types.cjs.map +1 -1
  62. package/build-module/components/async-mode-provider/context.mjs +1 -1
  63. package/build-module/components/async-mode-provider/context.mjs.map +3 -3
  64. package/build-module/components/async-mode-provider/index.mjs +1 -1
  65. package/build-module/components/async-mode-provider/index.mjs.map +1 -1
  66. package/build-module/components/async-mode-provider/use-async-mode.mjs +1 -1
  67. package/build-module/components/async-mode-provider/use-async-mode.mjs.map +3 -3
  68. package/build-module/components/registry-provider/context.mjs +1 -1
  69. package/build-module/components/registry-provider/context.mjs.map +1 -1
  70. package/build-module/components/registry-provider/index.mjs +1 -1
  71. package/build-module/components/registry-provider/index.mjs.map +1 -1
  72. package/build-module/components/registry-provider/use-registry.mjs +1 -1
  73. package/build-module/components/registry-provider/use-registry.mjs.map +3 -3
  74. package/build-module/components/use-dispatch/index.mjs +1 -1
  75. package/build-module/components/use-dispatch/index.mjs.map +1 -1
  76. package/build-module/components/use-dispatch/use-dispatch-with-map.mjs +1 -1
  77. package/build-module/components/use-dispatch/use-dispatch-with-map.mjs.map +3 -3
  78. package/build-module/components/use-dispatch/use-dispatch.mjs +1 -1
  79. package/build-module/components/use-dispatch/use-dispatch.mjs.map +3 -3
  80. package/build-module/components/use-select/index.mjs +2 -2
  81. package/build-module/components/use-select/index.mjs.map +3 -3
  82. package/build-module/components/with-dispatch/index.mjs +1 -1
  83. package/build-module/components/with-dispatch/index.mjs.map +3 -3
  84. package/build-module/components/with-registry/index.mjs +1 -1
  85. package/build-module/components/with-registry/index.mjs.map +3 -3
  86. package/build-module/components/with-select/index.mjs +1 -1
  87. package/build-module/components/with-select/index.mjs.map +3 -3
  88. package/build-module/controls.mjs +7 -6
  89. package/build-module/controls.mjs.map +3 -3
  90. package/build-module/default-registry.mjs +3 -2
  91. package/build-module/default-registry.mjs.map +3 -3
  92. package/build-module/dispatch.mjs +3 -1
  93. package/build-module/dispatch.mjs.map +2 -2
  94. package/build-module/factory.mjs.map +2 -2
  95. package/build-module/index.mjs +4 -3
  96. package/build-module/index.mjs.map +2 -2
  97. package/build-module/plugins/index.mjs +1 -1
  98. package/build-module/plugins/index.mjs.map +1 -1
  99. package/build-module/plugins/persistence/index.mjs +13 -8
  100. package/build-module/plugins/persistence/index.mjs.map +3 -3
  101. package/build-module/plugins/persistence/storage/default.mjs +1 -1
  102. package/build-module/plugins/persistence/storage/default.mjs.map +3 -3
  103. package/build-module/plugins/persistence/storage/object.mjs +1 -1
  104. package/build-module/plugins/persistence/storage/object.mjs.map +3 -3
  105. package/build-module/promise-middleware.mjs +2 -1
  106. package/build-module/promise-middleware.mjs.map +3 -3
  107. package/build-module/redux-store/index.mjs +32 -16
  108. package/build-module/redux-store/index.mjs.map +3 -3
  109. package/build-module/redux-store/metadata/selectors.mjs +1 -1
  110. package/build-module/redux-store/metadata/selectors.mjs.map +3 -3
  111. package/build-module/redux-store/metadata/types.mjs +1 -0
  112. package/build-module/redux-store/metadata/types.mjs.map +7 -0
  113. package/build-module/registry.mjs +11 -7
  114. package/build-module/registry.mjs.map +3 -3
  115. package/build-module/resolvers-cache-middleware.mjs +6 -3
  116. package/build-module/resolvers-cache-middleware.mjs.map +3 -3
  117. package/build-module/select.mjs +3 -1
  118. package/build-module/select.mjs.map +2 -2
  119. package/build-module/store/index.mjs +1 -1
  120. package/build-module/store/index.mjs.map +3 -3
  121. package/build-types/components/async-mode-provider/context.d.ts +37 -3
  122. package/build-types/components/async-mode-provider/context.d.ts.map +1 -1
  123. package/build-types/components/async-mode-provider/index.d.ts +2 -2
  124. package/build-types/components/async-mode-provider/index.d.ts.map +1 -1
  125. package/build-types/components/async-mode-provider/use-async-mode.d.ts.map +1 -1
  126. package/build-types/components/registry-provider/context.d.ts +10 -3
  127. package/build-types/components/registry-provider/context.d.ts.map +1 -1
  128. package/build-types/components/registry-provider/index.d.ts +2 -2
  129. package/build-types/components/registry-provider/index.d.ts.map +1 -1
  130. package/build-types/components/registry-provider/use-registry.d.ts +3 -2
  131. package/build-types/components/registry-provider/use-registry.d.ts.map +1 -1
  132. package/build-types/components/use-dispatch/index.d.ts +2 -2
  133. package/build-types/components/use-dispatch/index.d.ts.map +1 -1
  134. package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts +11 -9
  135. package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts.map +1 -1
  136. package/build-types/components/use-dispatch/use-dispatch.d.ts +10 -19
  137. package/build-types/components/use-dispatch/use-dispatch.d.ts.map +1 -1
  138. package/build-types/components/use-select/index.d.ts +24 -28
  139. package/build-types/components/use-select/index.d.ts.map +1 -1
  140. package/build-types/components/with-dispatch/index.d.ts +10 -11
  141. package/build-types/components/with-dispatch/index.d.ts.map +1 -1
  142. package/build-types/components/with-registry/index.d.ts +2 -6
  143. package/build-types/components/with-registry/index.d.ts.map +1 -1
  144. package/build-types/components/with-select/index.d.ts +7 -8
  145. package/build-types/components/with-select/index.d.ts.map +1 -1
  146. package/build-types/controls.d.ts +57 -44
  147. package/build-types/controls.d.ts.map +1 -1
  148. package/build-types/default-registry.d.ts +2 -2
  149. package/build-types/default-registry.d.ts.map +1 -1
  150. package/build-types/dispatch.d.ts +4 -0
  151. package/build-types/dispatch.d.ts.map +1 -1
  152. package/build-types/factory.d.ts +2 -1
  153. package/build-types/factory.d.ts.map +1 -1
  154. package/build-types/index.d.ts.map +1 -1
  155. package/build-types/plugins/index.d.ts +1 -1
  156. package/build-types/plugins/index.d.ts.map +1 -1
  157. package/build-types/plugins/persistence/index.d.ts +38 -27
  158. package/build-types/plugins/persistence/index.d.ts.map +1 -1
  159. package/build-types/plugins/persistence/storage/default.d.ts +7 -1
  160. package/build-types/plugins/persistence/storage/default.d.ts.map +1 -1
  161. package/build-types/plugins/persistence/storage/object.d.ts +4 -5
  162. package/build-types/plugins/persistence/storage/object.d.ts.map +1 -1
  163. package/build-types/promise-middleware.d.ts +6 -4
  164. package/build-types/promise-middleware.d.ts.map +1 -1
  165. package/build-types/redux-store/index.d.ts +12 -15
  166. package/build-types/redux-store/index.d.ts.map +1 -1
  167. package/build-types/redux-store/metadata/selectors.d.ts +45 -50
  168. package/build-types/redux-store/metadata/selectors.d.ts.map +1 -1
  169. package/build-types/redux-store/metadata/types.d.ts +48 -0
  170. package/build-types/redux-store/metadata/types.d.ts.map +1 -0
  171. package/build-types/registry.d.ts +5 -49
  172. package/build-types/registry.d.ts.map +1 -1
  173. package/build-types/resolvers-cache-middleware.d.ts +13 -7
  174. package/build-types/resolvers-cache-middleware.d.ts.map +1 -1
  175. package/build-types/select.d.ts +3 -0
  176. package/build-types/select.d.ts.map +1 -1
  177. package/build-types/store/index.d.ts +5 -12
  178. package/build-types/store/index.d.ts.map +1 -1
  179. package/build-types/types.d.ts +201 -10
  180. package/build-types/types.d.ts.map +1 -1
  181. package/package.json +9 -9
  182. package/src/components/async-mode-provider/{context.js → context.ts} +0 -1
  183. package/src/components/async-mode-provider/{use-async-mode.js → use-async-mode.ts} +1 -1
  184. package/src/components/registry-provider/{use-registry.js → use-registry.ts} +3 -2
  185. package/src/components/use-dispatch/{use-dispatch-with-map.js → use-dispatch-with-map.ts} +18 -9
  186. package/src/components/use-dispatch/{use-dispatch.js → use-dispatch.ts} +25 -20
  187. package/src/components/use-select/{index.js → index.ts} +84 -70
  188. package/src/components/with-dispatch/{index.js → index.tsx} +20 -13
  189. package/src/components/with-registry/{index.js → index.tsx} +1 -5
  190. package/src/components/with-select/{index.js → index.tsx} +17 -10
  191. package/src/{controls.js → controls.ts} +53 -26
  192. package/src/{default-registry.js → default-registry.ts} +3 -1
  193. package/src/dispatch.ts +7 -1
  194. package/src/factory.ts +4 -3
  195. package/src/index.ts +4 -8
  196. package/src/plugins/persistence/{index.js → index.ts} +93 -54
  197. package/src/plugins/persistence/storage/{default.js → default.ts} +3 -2
  198. package/src/plugins/persistence/storage/object.ts +25 -0
  199. package/src/{promise-middleware.js → promise-middleware.ts} +3 -3
  200. package/src/redux-store/{index.js → index.ts} +218 -131
  201. package/src/redux-store/metadata/{selectors.js → selectors.ts} +83 -54
  202. package/src/redux-store/metadata/types.ts +100 -0
  203. package/src/{registry.js → registry.ts} +98 -88
  204. package/src/{resolvers-cache-middleware.js → resolvers-cache-middleware.ts} +22 -7
  205. package/src/select.ts +6 -1
  206. package/src/store/{index.js → index.ts} +13 -8
  207. package/src/types.ts +263 -24
  208. package/src/plugins/persistence/storage/object.js +0 -23
  209. /package/src/components/async-mode-provider/{index.js → index.ts} +0 -0
  210. /package/src/components/registry-provider/{context.js → context.ts} +0 -0
  211. /package/src/components/registry-provider/{index.js → index.ts} +0 -0
  212. /package/src/components/use-dispatch/{index.js → index.ts} +0 -0
  213. /package/src/plugins/{index.js → index.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/types.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { combineReducers as reduxCombineReducers } from 'redux';\n\ntype MapOf< T > = { [ name: string ]: T };\n\nexport type ActionCreator = ( ...args: any[] ) => any | Generator;\nexport type Resolver = Function | Generator;\nexport type Selector = Function;\n\nexport type AnyConfig = ReduxStoreConfig< any, any, any >;\n\nexport interface StoreInstance< Config extends AnyConfig > {\n\tgetSelectors: () => SelectorsOf< Config >;\n\tgetActions: () => ActionCreatorsOf< Config >;\n\tsubscribe: ( listener: () => void ) => () => void;\n}\n\nexport interface StoreDescriptor< Config extends AnyConfig = AnyConfig > {\n\t/**\n\t * Store Name\n\t */\n\tname: string;\n\n\t/**\n\t * Creates a store instance\n\t */\n\tinstantiate: ( registry: DataRegistry ) => StoreInstance< Config >;\n}\n\nexport interface ReduxStoreConfig<\n\tState,\n\tActionCreators extends MapOf< ActionCreator >,\n\tSelectors,\n> {\n\tinitialState?: State;\n\treducer: ( state: any, action: any ) => any;\n\tactions?: ActionCreators;\n\tresolvers?: MapOf< Resolver >;\n\tselectors?: Selectors;\n\tcontrols?: MapOf< Function >;\n}\n\n// Return type for the useSelect() hook.\nexport type UseSelectReturn< F extends MapSelect | StoreDescriptor< any > > =\n\tF extends MapSelect\n\t\t? ReturnType< F >\n\t\t: F extends StoreDescriptor< any >\n\t\t? CurriedSelectorsOf< F >\n\t\t: never;\n\n// Return type for the useDispatch() hook.\nexport type UseDispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: StoreNameOrDescriptor extends undefined\n\t\t? DispatchFunction\n\t\t: any;\n\nexport type DispatchFunction = < StoreNameOrDescriptor >(\n\tstore: StoreNameOrDescriptor\n) => DispatchReturn< StoreNameOrDescriptor >;\n\nexport type DispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< ConfigOf< StoreNameOrDescriptor > >\n\t\t: unknown;\n\nexport type MapSelect = (\n\tselect: SelectFunction,\n\tregistry: DataRegistry\n) => any;\n\nexport type SelectFunction = < S >( store: S ) => CurriedSelectorsOf< S >;\n\n/**\n * Callback for store's `subscribe()` method that\n * runs when the store data has changed.\n */\nexport type ListenerFunction = () => void;\n\nexport type CurriedSelectorsOf< S > = S extends StoreDescriptor<\n\tReduxStoreConfig< any, any, infer Selectors >\n>\n\t? { [ key in keyof Selectors ]: CurriedState< Selectors[ key ] > }\n\t: never;\n\n/**\n * Like CurriedState but wraps the return type in a Promise.\n * Used for resolveSelect where selectors return promises.\n *\n * For generic selectors that define PromiseCurriedSignature, that signature\n * is used directly to preserve generic type parameters (which would otherwise\n * be lost when using `infer`).\n */\ntype CurriedStateWithPromise< F > =\n\tF extends SelectorWithCustomCurrySignature & {\n\t\tPromiseCurriedSignature: infer S;\n\t}\n\t\t? S\n\t\t: F extends SelectorWithCustomCurrySignature & {\n\t\t\t\tCurriedSignature: ( ...args: infer P ) => infer R;\n\t\t }\n\t\t? ( ...args: P ) => Promise< R >\n\t\t: F extends ( state: any, ...args: infer P ) => infer R\n\t\t? ( ...args: P ) => Promise< R >\n\t\t: F;\n\n/**\n * Like CurriedSelectorsOf but each selector returns a Promise.\n * Used for resolveSelect.\n */\nexport type CurriedSelectorsResolveOf< S > = S extends StoreDescriptor<\n\tReduxStoreConfig< any, any, infer Selectors >\n>\n\t? {\n\t\t\t[ key in keyof Selectors ]: CurriedStateWithPromise<\n\t\t\t\tSelectors[ key ]\n\t\t\t>;\n\t }\n\t: never;\n\n/**\n * Removes the first argument from a function.\n *\n * By default, it removes the `state` parameter from\n * registered selectors since that argument is supplied\n * by the editor when calling `select(\u2026)`.\n *\n * For functions with no arguments, which some selectors\n * are free to define, returns the original function.\n *\n * It is possible to manually provide a custom curried signature\n * and avoid the automatic inference. When the\n * F generic argument passed to this helper extends the\n * SelectorWithCustomCurrySignature type, the F['CurriedSignature']\n * property is used verbatim.\n *\n * This is useful because TypeScript does not correctly remove\n * arguments from complex function signatures constrained by\n * interdependent generic parameters.\n * For more context, see https://github.com/WordPress/gutenberg/pull/41578\n */\ntype CurriedState< F > = F extends SelectorWithCustomCurrySignature\n\t? F[ 'CurriedSignature' ]\n\t: F extends ( state: any, ...args: infer P ) => infer R\n\t? ( ...args: P ) => R\n\t: F;\n\n/**\n * Utility to manually specify curried selector signatures.\n *\n * It comes handy when TypeScript can't automatically produce the\n * correct curried function signature. For example:\n *\n * ```ts\n * type BadlyInferredSignature = CurriedState<\n * <K extends string | number>(\n * state: any,\n * kind: K,\n * key: K extends string ? 'one value' : false\n * ) => K\n * >\n * // BadlyInferredSignature evaluates to:\n * // (kind: string number, key: false \"one value\") => string number\n * ```\n *\n * With SelectorWithCustomCurrySignature, we can provide a custom\n * signature and avoid relying on TypeScript inference:\n * ```ts\n * interface MySelectorSignature extends SelectorWithCustomCurrySignature {\n * <K extends string | number>(\n * state: any,\n * kind: K,\n * key: K extends string ? 'one value' : false\n * ): K;\n *\n * CurriedSignature: <K extends string | number>(\n * kind: K,\n * key: K extends string ? 'one value' : false\n * ): K;\n * }\n * type CorrectlyInferredSignature = CurriedState<MySelectorSignature>\n * // <K extends string | number>(kind: K, key: K extends string ? 'one value' : false): K;\n *\n * For even more context, see https://github.com/WordPress/gutenberg/pull/41578\n * ```\n */\nexport interface SelectorWithCustomCurrySignature {\n\tCurriedSignature: Function;\n\tPromiseCurriedSignature?: Function;\n}\n\nexport interface DataRegistry {\n\tregister: ( store: StoreDescriptor< any > ) => void;\n\tdispatch: < S extends StoreDescriptor< any > >(\n\t\tstore: S\n\t) => ActionCreatorsOf< ConfigOf< S > >;\n}\n\n// Type Helpers.\n\nexport type ConfigOf< S > = S extends StoreDescriptor< infer C > ? C : never;\n\nexport type ActionCreatorsOf< Config extends AnyConfig > =\n\tConfig extends ReduxStoreConfig< any, infer ActionCreators, any >\n\t\t? PromisifiedActionCreators< ActionCreators >\n\t\t: never;\n\n// Takes an object containing all action creators for a store and updates the\n// return type of each action creator to account for internal registry details --\n// for example, dispatched actions are wrapped with a Promise.\nexport type PromisifiedActionCreators<\n\tActionCreators extends MapOf< ActionCreator >,\n> = {\n\t[ Action in keyof ActionCreators ]: PromisifyActionCreator<\n\t\tActionCreators[ Action ]\n\t>;\n};\n\n// Wraps action creator return types with a Promise and handles thunks.\nexport type PromisifyActionCreator< Action extends ActionCreator > = (\n\t...args: Parameters< Action >\n) => Promise<\n\tReturnType< Action > extends ( ..._args: any[] ) => any\n\t\t? ThunkReturnType< Action >\n\t\t: ReturnType< Action >\n>;\n\n// A thunk is an action creator which returns a function, which can optionally\n// return a Promise. The double ReturnType unwraps the innermost function's\n// return type, and Awaited gets the type the Promise resolves to. If the return\n// type is not a Promise, Awaited returns that original type.\nexport type ThunkReturnType< Action extends ActionCreator > = Awaited<\n\tReturnType< ReturnType< Action > >\n>;\n\ntype SelectorsOf< Config extends AnyConfig > = Config extends ReduxStoreConfig<\n\tany,\n\tany,\n\tinfer Selectors\n>\n\t? { [ name in keyof Selectors ]: Function }\n\t: never;\n\nexport type combineReducers = typeof reduxCombineReducers;\n"],
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< S extends StoreDescriptor = StoreDescriptor > {\n\tdispatch: ActionCreatorsOf< S > &\n\t\t( ( action: Record< string, unknown > | Function ) => unknown );\n\tselect: CurriedSelectorsOf< S >;\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,4 +1,4 @@
1
- // packages/data/src/components/async-mode-provider/context.js
1
+ // packages/data/src/components/async-mode-provider/context.ts
2
2
  import { createContext } from "@wordpress/element";
3
3
  var Context = createContext(false);
4
4
  Context.displayName = "AsyncModeContext";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/async-mode-provider/context.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const Context = createContext( false );\nContext.displayName = 'AsyncModeContext';\n\nconst { Consumer, Provider } = Context;\n\nexport const AsyncModeConsumer = Consumer;\n\n/**\n * Context Provider Component used to switch the data module component rerendering\n * between Sync and Async modes.\n *\n * @example\n *\n * ```js\n * import { useSelect, AsyncModeProvider } from '@wordpress/data';\n * import { store as blockEditorStore } from '@wordpress/block-editor';\n *\n * function BlockCount() {\n * const count = useSelect( ( select ) => {\n * return select( blockEditorStore ).getBlockCount()\n * }, [] );\n *\n * return count;\n * }\n *\n * function App() {\n * return (\n * <AsyncModeProvider value={ true }>\n * <BlockCount />\n * </AsyncModeProvider>\n * );\n * }\n * ```\n *\n * In this example, the BlockCount component is rerendered asynchronously.\n * It means if a more critical task is being performed (like typing in an input),\n * the rerendering is delayed until the browser becomes IDLE.\n * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior.\n *\n * @param {boolean} props.value Enable Async Mode.\n * @return {Component} The component to be rendered.\n */\nexport default Provider;\n"],
5
- "mappings": ";AAGA,SAAS,qBAAqB;AAEvB,IAAM,UAAU,cAAe,KAAM;AAC5C,QAAQ,cAAc;AAEtB,IAAM,EAAE,UAAU,SAAS,IAAI;AAExB,IAAM,oBAAoB;AAqCjC,IAAO,kBAAQ;",
3
+ "sources": ["../../../src/components/async-mode-provider/context.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const Context = createContext( false );\nContext.displayName = 'AsyncModeContext';\n\nconst { Consumer, Provider } = Context;\n\nexport const AsyncModeConsumer = Consumer;\n\n/**\n * Context Provider Component used to switch the data module component rerendering\n * between Sync and Async modes.\n *\n * @example\n *\n * ```js\n * import { useSelect, AsyncModeProvider } from '@wordpress/data';\n * import { store as blockEditorStore } from '@wordpress/block-editor';\n *\n * function BlockCount() {\n * const count = useSelect( ( select ) => {\n * return select( blockEditorStore ).getBlockCount()\n * }, [] );\n *\n * return count;\n * }\n *\n * function App() {\n * return (\n * <AsyncModeProvider value={ true }>\n * <BlockCount />\n * </AsyncModeProvider>\n * );\n * }\n * ```\n *\n * In this example, the BlockCount component is rerendered asynchronously.\n * It means if a more critical task is being performed (like typing in an input),\n * the rerendering is delayed until the browser becomes IDLE.\n * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior.\n *\n * @param {boolean} props.value Enable Async Mode.\n */\nexport default Provider;\n"],
5
+ "mappings": ";AAGA,SAAS,qBAAqB;AAEvB,IAAM,UAAU,cAAe,KAAM;AAC5C,QAAQ,cAAc;AAEtB,IAAM,EAAE,UAAU,SAAS,IAAI;AAExB,IAAM,oBAAoB;AAoCjC,IAAO,kBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/async-mode-provider/index.js
1
+ // packages/data/src/components/async-mode-provider/index.ts
2
2
  import { default as default2 } from "./use-async-mode.mjs";
3
3
  import { default as default3, AsyncModeConsumer } from "./context.mjs";
4
4
  export {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/async-mode-provider/index.js"],
3
+ "sources": ["../../../src/components/async-mode-provider/index.ts"],
4
4
  "sourcesContent": ["export { default as useAsyncMode } from './use-async-mode';\nexport { default as AsyncModeProvider, AsyncModeConsumer } from './context';\n"],
5
5
  "mappings": ";AAAA,SAAoB,WAAXA,gBAA+B;AACxC,SAAoB,WAAXA,UAA8B,yBAAyB;",
6
6
  "names": ["default"]
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/async-mode-provider/use-async-mode.js
1
+ // packages/data/src/components/async-mode-provider/use-async-mode.ts
2
2
  import { useContext } from "@wordpress/element";
3
3
  import { Context } from "./context.mjs";
4
4
  function useAsyncMode() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/async-mode-provider/use-async-mode.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\n\nexport default function useAsyncMode() {\n\treturn useContext( Context );\n}\n"],
5
- "mappings": ";AAGA,SAAS,kBAAkB;AAK3B,SAAS,eAAe;AAET,SAAR,eAAgC;AACtC,SAAO,WAAY,OAAQ;AAC5B;",
3
+ "sources": ["../../../src/components/async-mode-provider/use-async-mode.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\n\nexport default function useAsyncMode(): boolean {\n\treturn useContext( Context );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,kBAAkB;AAK3B,SAAS,eAAe;AAET,SAAR,eAAyC;AAC/C,SAAO,WAAY,OAAQ;AAC5B;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/registry-provider/context.js
1
+ // packages/data/src/components/registry-provider/context.ts
2
2
  import { createContext } from "@wordpress/element";
3
3
  import defaultRegistry from "../../default-registry.mjs";
4
4
  var Context = createContext(defaultRegistry);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/registry-provider/context.js"],
3
+ "sources": ["../../../src/components/registry-provider/context.ts"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport defaultRegistry from '../../default-registry';\n\nexport const Context = createContext( defaultRegistry );\nContext.displayName = 'RegistryProviderContext';\n\nconst { Consumer, Provider } = Context;\n\n/**\n * A custom react Context consumer exposing the provided `registry` to\n * children components. Used along with the RegistryProvider.\n *\n * You can read more about the react context api here:\n * https://react.dev/learn/passing-data-deeply-with-context#step-3-provide-the-context\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * RegistryConsumer,\n * createRegistry\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const App = ( { props } ) => {\n * return <RegistryProvider value={ registry }>\n * <div>Hello There</div>\n * <RegistryConsumer>\n * { ( registry ) => (\n * <ComponentUsingRegistry\n * \t\t{ ...props }\n * \t registry={ registry }\n * ) }\n * </RegistryConsumer>\n * </RegistryProvider>\n * }\n * ```\n */\nexport const RegistryConsumer = Consumer;\n\n/**\n * A custom Context provider for exposing the provided `registry` to children\n * components via a consumer.\n *\n * See <a name=\"#RegistryConsumer\">RegistryConsumer</a> documentation for\n * example.\n */\nexport default Provider;\n"],
5
5
  "mappings": ";AAGA,SAAS,qBAAqB;AAK9B,OAAO,qBAAqB;AAErB,IAAM,UAAU,cAAe,eAAgB;AACtD,QAAQ,cAAc;AAEtB,IAAM,EAAE,UAAU,SAAS,IAAI;AAiCxB,IAAM,mBAAmB;AAShC,IAAO,kBAAQ;",
6
6
  "names": []
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/registry-provider/index.js
1
+ // packages/data/src/components/registry-provider/index.ts
2
2
  import { default as default2, RegistryConsumer } from "./context.mjs";
3
3
  import { default as default3 } from "./use-registry.mjs";
4
4
  export {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/registry-provider/index.js"],
3
+ "sources": ["../../../src/components/registry-provider/index.ts"],
4
4
  "sourcesContent": ["export { default as RegistryProvider, RegistryConsumer } from './context';\nexport { default as useRegistry } from './use-registry';\n"],
5
5
  "mappings": ";AAAA,SAAoB,WAAXA,UAA6B,wBAAwB;AAC9D,SAAoB,WAAXA,gBAA8B;",
6
6
  "names": ["default"]
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/registry-provider/use-registry.js
1
+ // packages/data/src/components/registry-provider/use-registry.ts
2
2
  import { useContext } from "@wordpress/element";
3
3
  import { Context } from "./context.mjs";
4
4
  function useRegistry() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/registry-provider/use-registry.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\n\n/**\n * A custom react hook exposing the registry context for use.\n *\n * This exposes the `registry` value provided via the\n * <a href=\"#RegistryProvider\">Registry Provider</a> to a component implementing\n * this hook.\n *\n * It acts similarly to the `useContext` react hook.\n *\n * Note: Generally speaking, `useRegistry` is a low level hook that in most cases\n * won't be needed for implementation. Most interactions with the `@wordpress/data`\n * API can be performed via the `useSelect` hook, or the `withSelect` and\n * `withDispatch` higher order components.\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * createRegistry,\n * useRegistry,\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const SomeChildUsingRegistry = ( props ) => {\n * const registry = useRegistry();\n * // ...logic implementing the registry in other react hooks.\n * };\n *\n *\n * const ParentProvidingRegistry = ( props ) => {\n * return <RegistryProvider value={ registry }>\n * <SomeChildUsingRegistry { ...props } />\n * </RegistryProvider>\n * };\n * ```\n *\n * @return {import('../../types').DataRegistry} A custom react hook exposing the registry context value.\n */\nexport default function useRegistry() {\n\treturn useContext( Context );\n}\n"],
5
- "mappings": ";AAGA,SAAS,kBAAkB;AAK3B,SAAS,eAAe;AAyCT,SAAR,cAA+B;AACrC,SAAO,WAAY,OAAQ;AAC5B;",
3
+ "sources": ["../../../src/components/registry-provider/use-registry.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Context } from './context';\nimport type { DataRegistry } from '../../types';\n\n/**\n * A custom react hook exposing the registry context for use.\n *\n * This exposes the `registry` value provided via the\n * <a href=\"#RegistryProvider\">Registry Provider</a> to a component implementing\n * this hook.\n *\n * It acts similarly to the `useContext` react hook.\n *\n * Note: Generally speaking, `useRegistry` is a low level hook that in most cases\n * won't be needed for implementation. Most interactions with the `@wordpress/data`\n * API can be performed via the `useSelect` hook, or the `withSelect` and\n * `withDispatch` higher order components.\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * createRegistry,\n * useRegistry,\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const SomeChildUsingRegistry = ( props ) => {\n * const registry = useRegistry();\n * // ...logic implementing the registry in other react hooks.\n * };\n *\n *\n * const ParentProvidingRegistry = ( props ) => {\n * return <RegistryProvider value={ registry }>\n * <SomeChildUsingRegistry { ...props } />\n * </RegistryProvider>\n * };\n * ```\n *\n * @return A custom react hook exposing the registry context value.\n */\nexport default function useRegistry(): DataRegistry {\n\treturn useContext( Context );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,kBAAkB;AAK3B,SAAS,eAAe;AA0CT,SAAR,cAA6C;AACnD,SAAO,WAAY,OAAQ;AAC5B;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/use-dispatch/index.js
1
+ // packages/data/src/components/use-dispatch/index.ts
2
2
  import { default as default2 } from "./use-dispatch.mjs";
3
3
  import { default as default3 } from "./use-dispatch-with-map.mjs";
4
4
  export {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/use-dispatch/index.js"],
3
+ "sources": ["../../../src/components/use-dispatch/index.ts"],
4
4
  "sourcesContent": ["export { default as useDispatch } from './use-dispatch';\nexport { default as useDispatchWithMap } from './use-dispatch-with-map';\n"],
5
5
  "mappings": ";AAAA,SAAoB,WAAXA,gBAA8B;AACvC,SAAoB,WAAXA,gBAAqC;",
6
6
  "names": ["default"]
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/use-dispatch/use-dispatch-with-map.js
1
+ // packages/data/src/components/use-dispatch/use-dispatch-with-map.ts
2
2
  import { useMemo, useRef } from "@wordpress/element";
3
3
  import { useIsomorphicLayoutEffect } from "@wordpress/compose";
4
4
  import useRegistry from "../registry-provider/use-registry.mjs";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/use-dispatch/use-dispatch-with-map.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\n\n/**\n * Custom react hook for returning aggregate dispatch actions using the provided\n * dispatchMap.\n *\n * Currently this is an internal api only and is implemented by `withDispatch`\n *\n * @param {Function} dispatchMap Receives the `registry.dispatch` function as\n * the first argument and the `registry` object\n * as the second argument. Should return an\n * object mapping props to functions.\n * @param {Array} deps An array of dependencies for the hook.\n * @return {Object} An object mapping props to functions created by the passed\n * in dispatchMap.\n */\nconst useDispatchWithMap = ( dispatchMap, deps ) => {\n\tconst registry = useRegistry();\n\tconst currentDispatchMapRef = useRef( dispatchMap );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tcurrentDispatchMapRef.current = dispatchMap;\n\t} );\n\n\treturn useMemo( () => {\n\t\tconst currentDispatchProps = currentDispatchMapRef.current(\n\t\t\tregistry.dispatch,\n\t\t\tregistry\n\t\t);\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( currentDispatchProps ).map(\n\t\t\t\t( [ propName, dispatcher ] ) => {\n\t\t\t\t\tif ( typeof dispatcher !== 'function' ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`Property ${ propName } returned from dispatchMap in useDispatchWithMap must be a function.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn [\n\t\t\t\t\t\tpropName,\n\t\t\t\t\t\t( ...args ) =>\n\t\t\t\t\t\t\tcurrentDispatchMapRef\n\t\t\t\t\t\t\t\t.current( registry.dispatch, registry )\n\t\t\t\t\t\t\t\t[ propName ]( ...args ),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t}, [ registry, ...deps ] );\n};\n\nexport default useDispatchWithMap;\n"],
5
- "mappings": ";AAGA,SAAS,SAAS,cAAc;AAChC,SAAS,iCAAiC;AAK1C,OAAO,iBAAiB;AAgBxB,IAAM,qBAAqB,CAAE,aAAa,SAAU;AACnD,QAAM,WAAW,YAAY;AAC7B,QAAM,wBAAwB,OAAQ,WAAY;AAElD,4BAA2B,MAAM;AAChC,0BAAsB,UAAU;AAAA,EACjC,CAAE;AAEF,SAAO,QAAS,MAAM;AACrB,UAAM,uBAAuB,sBAAsB;AAAA,MAClD,SAAS;AAAA,MACT;AAAA,IACD;AACA,WAAO,OAAO;AAAA,MACb,OAAO,QAAS,oBAAqB,EAAE;AAAA,QACtC,CAAE,CAAE,UAAU,UAAW,MAAO;AAC/B,cAAK,OAAO,eAAe,YAAa;AAEvC,oBAAQ;AAAA,cACP,YAAa,QAAS;AAAA,YACvB;AAAA,UACD;AACA,iBAAO;AAAA,YACN;AAAA,YACA,IAAK,SACJ,sBACE,QAAS,SAAS,UAAU,QAAS,EACpC,QAAS,EAAG,GAAG,IAAK;AAAA,UACzB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,CAAE,UAAU,GAAG,IAAK,CAAE;AAC1B;AAEA,IAAO,gCAAQ;",
3
+ "sources": ["../../../src/components/use-dispatch/use-dispatch-with-map.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useIsomorphicLayoutEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport type { DataRegistry } from '../../types';\n\ntype DispatchMap = (\n\tdispatch: DataRegistry[ 'dispatch' ],\n\tregistry: DataRegistry\n) => Record< string, ( ...args: unknown[] ) => unknown >;\n\n/**\n * Custom react hook for returning aggregate dispatch actions using the provided\n * dispatchMap.\n *\n * Currently this is an internal api only and is implemented by `withDispatch`\n *\n * @param dispatchMap Receives the `registry.dispatch` function as\n * the first argument and the `registry` object\n * as the second argument. Should return an\n * object mapping props to functions.\n * @param deps An array of dependencies for the hook.\n * @return An object mapping props to functions created by the passed\n * in dispatchMap.\n */\nconst useDispatchWithMap = (\n\tdispatchMap: DispatchMap,\n\tdeps: unknown[]\n): Record< string, ( ...args: unknown[] ) => unknown > => {\n\tconst registry = useRegistry();\n\tconst currentDispatchMapRef = useRef( dispatchMap );\n\n\tuseIsomorphicLayoutEffect( () => {\n\t\tcurrentDispatchMapRef.current = dispatchMap;\n\t} );\n\n\treturn useMemo( () => {\n\t\tconst currentDispatchProps = currentDispatchMapRef.current(\n\t\t\tregistry.dispatch,\n\t\t\tregistry\n\t\t);\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( currentDispatchProps ).map(\n\t\t\t\t( [ propName, dispatcher ] ) => {\n\t\t\t\t\tif ( typeof dispatcher !== 'function' ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`Property ${ propName } returned from dispatchMap in useDispatchWithMap must be a function.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn [\n\t\t\t\t\t\tpropName,\n\t\t\t\t\t\t( ...args: unknown[] ) =>\n\t\t\t\t\t\t\tcurrentDispatchMapRef\n\t\t\t\t\t\t\t\t.current( registry.dispatch, registry )\n\t\t\t\t\t\t\t\t[ propName ]( ...args ),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t}, [ registry, ...deps ] );\n};\n\nexport default useDispatchWithMap;\n"],
5
+ "mappings": ";AAGA,SAAS,SAAS,cAAc;AAChC,SAAS,iCAAiC;AAK1C,OAAO,iBAAiB;AAsBxB,IAAM,qBAAqB,CAC1B,aACA,SACyD;AACzD,QAAM,WAAW,YAAY;AAC7B,QAAM,wBAAwB,OAAQ,WAAY;AAElD,4BAA2B,MAAM;AAChC,0BAAsB,UAAU;AAAA,EACjC,CAAE;AAEF,SAAO,QAAS,MAAM;AACrB,UAAM,uBAAuB,sBAAsB;AAAA,MAClD,SAAS;AAAA,MACT;AAAA,IACD;AACA,WAAO,OAAO;AAAA,MACb,OAAO,QAAS,oBAAqB,EAAE;AAAA,QACtC,CAAE,CAAE,UAAU,UAAW,MAAO;AAC/B,cAAK,OAAO,eAAe,YAAa;AAEvC,oBAAQ;AAAA,cACP,YAAa,QAAS;AAAA,YACvB;AAAA,UACD;AACA,iBAAO;AAAA,YACN;AAAA,YACA,IAAK,SACJ,sBACE,QAAS,SAAS,UAAU,QAAS,EACpC,QAAS,EAAG,GAAG,IAAK;AAAA,UACzB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,CAAE,UAAU,GAAG,IAAK,CAAE;AAC1B;AAEA,IAAO,gCAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/use-dispatch/use-dispatch.js
1
+ // packages/data/src/components/use-dispatch/use-dispatch.ts
2
2
  import useRegistry from "../registry-provider/use-registry.mjs";
3
3
  var useDispatch = (storeNameOrDescriptor) => {
4
4
  const { dispatch } = useRegistry();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/use-dispatch/use-dispatch.js"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\n\n/**\n * @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor\n * @template {import('../../types').AnyConfig} StoreConfig\n */\n/**\n * @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn\n * @template StoreNameOrDescriptor\n */\n\n/**\n * A custom react hook returning the current registry dispatch actions creators.\n *\n * Note: The component using this hook must be within the context of a\n * RegistryProvider.\n *\n * @template {undefined | string | StoreDescriptor<any>} StoreNameOrDescriptor\n * @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the\n * store or its descriptor from which to\n * retrieve action creators. If not\n * provided, the registry.dispatch\n * function is returned instead.\n *\n * @example\n * This illustrates a pattern where you may need to retrieve dynamic data from\n * the server via the `useSelect` hook to use in combination with the dispatch\n * action.\n *\n * ```jsx\n * import { useCallback } from 'react';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>\n * }\n *\n * const SaleButton = ( { children } ) => {\n * const { stockNumber } = useSelect(\n * ( select ) => select( myCustomStore ).getStockNumber(),\n * []\n * );\n * const { startSale } = useDispatch( myCustomStore );\n * const onClick = useCallback( () => {\n * const discountPercent = stockNumber > 50 ? 10: 20;\n * startSale( discountPercent );\n * }, [ stockNumber ] );\n * return <Button onClick={ onClick }>{ children }</Button>\n * }\n *\n * // Rendered somewhere in the application:\n * //\n * // <SaleButton>Start Sale!</SaleButton>\n * ```\n * @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook.\n */\nconst useDispatch = ( storeNameOrDescriptor ) => {\n\tconst { dispatch } = useRegistry();\n\treturn storeNameOrDescriptor === void 0\n\t\t? dispatch\n\t\t: dispatch( storeNameOrDescriptor );\n};\n\nexport default useDispatch;\n"],
5
- "mappings": ";AAGA,OAAO,iBAAiB;AAyDxB,IAAM,cAAc,CAAE,0BAA2B;AAChD,QAAM,EAAE,SAAS,IAAI,YAAY;AACjC,SAAO,0BAA0B,SAC9B,WACA,SAAU,qBAAsB;AACpC;AAEA,IAAO,uBAAQ;",
3
+ "sources": ["../../../src/components/use-dispatch/use-dispatch.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport type {\n\tStoreDescriptor,\n\tAnyConfig,\n\tUseDispatchReturn,\n} from '../../types';\n\n/**\n * A custom react hook returning the current registry dispatch actions creators.\n *\n * Note: The component using this hook must be within the context of a\n * RegistryProvider.\n *\n * @param storeNameOrDescriptor Optionally provide the name of the\n * store or its descriptor from which to\n * retrieve action creators. If not\n * provided, the registry.dispatch\n * function is returned instead.\n *\n * @example\n * This illustrates a pattern where you may need to retrieve dynamic data from\n * the server via the `useSelect` hook to use in combination with the dispatch\n * action.\n *\n * ```jsx\n * import { useCallback } from 'react';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>\n * }\n *\n * const SaleButton = ( { children } ) => {\n * const { stockNumber } = useSelect(\n * ( select ) => select( myCustomStore ).getStockNumber(),\n * []\n * );\n * const { startSale } = useDispatch( myCustomStore );\n * const onClick = useCallback( () => {\n * const discountPercent = stockNumber > 50 ? 10: 20;\n * startSale( discountPercent );\n * }, [ stockNumber ] );\n * return <Button onClick={ onClick }>{ children }</Button>\n * }\n *\n * // Rendered somewhere in the application:\n * //\n * // <SaleButton>Start Sale!</SaleButton>\n * ```\n *\n * @return The dispatch function or action creators for the store.\n */\nconst useDispatch = <\n\tStoreNameOrDescriptor extends\n\t\t| undefined\n\t\t| string\n\t\t| StoreDescriptor< AnyConfig > = undefined,\n>(\n\tstoreNameOrDescriptor?: StoreNameOrDescriptor\n): UseDispatchReturn< StoreNameOrDescriptor > => {\n\tconst { dispatch } = useRegistry();\n\treturn (\n\t\tstoreNameOrDescriptor === void 0\n\t\t\t? dispatch\n\t\t\t: dispatch( storeNameOrDescriptor as StoreDescriptor< AnyConfig > )\n\t) as UseDispatchReturn< StoreNameOrDescriptor >;\n};\n\nexport default useDispatch;\n"],
5
+ "mappings": ";AAGA,OAAO,iBAAiB;AAqDxB,IAAM,cAAc,CAMnB,0BACgD;AAChD,QAAM,EAAE,SAAS,IAAI,YAAY;AACjC,SACC,0BAA0B,SACvB,WACA,SAAU,qBAAsD;AAErE;AAEA,IAAO,uBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/use-select/index.js
1
+ // packages/data/src/components/use-select/index.ts
2
2
  import { createQueue } from "@wordpress/priority-queue";
3
3
  import {
4
4
  useRef,
@@ -89,7 +89,7 @@ function Store(registry, suspense) {
89
89
  return (mapSelect, isAsync) => {
90
90
  function updateValue() {
91
91
  if (lastMapResultValid && mapSelect === lastMapSelect) {
92
- return lastMapResult;
92
+ return;
93
93
  }
94
94
  const listeningStores = { current: null };
95
95
  const mapResult = registry.__unstableMarkListeningStores(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/use-select/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\n\nconst renderQueue = createQueue();\n\nfunction warnOnUnstableReference( a, b ) {\n\tif ( ! a || ! b ) {\n\t\treturn;\n\t}\n\n\tconst keys =\n\t\ttypeof a === 'object' && typeof b === 'object'\n\t\t\t? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] )\n\t\t\t: [];\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn(\n\t\t'The `useSelect` hook returns different values when called with the same state and parameters.\\n' +\n\t\t\t'This can lead to unnecessary re-renders and performance issues if not fixed.\\n\\n' +\n\t\t\t'Non-equal value keys: %s\\n\\n',\n\t\tkeys.join( ', ' )\n\t);\n}\n\n/**\n * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../../types').AnyConfig} C\n */\n/**\n * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../../types').ActionCreator>} Actions\n * @template Selectors\n */\n/** @typedef {import('../../types').MapSelect} MapSelect */\n/**\n * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn\n * @template {MapSelect|StoreDescriptor<any>} T\n */\n\nfunction Store( registry, suspense ) {\n\tconst select = suspense ? registry.suspendSelect : registry.select;\n\tconst queueContext = {};\n\tlet lastMapSelect;\n\tlet lastMapResult;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync;\n\tlet subscriber;\n\tlet didWarnUnstableReference;\n\tconst storeStatesOnMount = new Map();\n\n\tfunction getStoreState( name ) {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores ) => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set();\n\n\t\tfunction subscribe( listener ) {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs = [];\n\t\t\tfunction subscribeStore( storeName ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect, isAsync ) => {\n\t\tfunction updateValue() {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn lastMapResult;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( globalThis.SCRIPT_DEBUG ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\twarnOnUnstableReference( mapResult, secondMapResult );\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect( suspense, mapSelect, deps ) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @template {MapSelect | StoreDescriptor<any>} T\n * @param {T} mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param {unknown[]=} deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n * @return {UseSelectReturn<T>} A custom react hook.\n */\nexport default function useSelect( mapSelect, deps ) {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\treturn staticSelectMode\n\t\t? _useStaticSelect( mapSelect )\n\t\t: _useMappingSelect( false, mapSelect, deps );\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @template {MapSelect} T\n * @param {T} mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param {Array} deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @throws {Promise} A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return {ReturnType<T>} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\treturn _useMappingSelect( true, mapSelect, deps );\n}\n"],
5
- "mappings": "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",
3
+ "sources": ["../../../src/components/use-select/index.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createQueue } from '@wordpress/priority-queue';\nimport {\n\tuseRef,\n\tuseCallback,\n\tuseMemo,\n\tuseSyncExternalStore,\n\tuseDebugValue,\n} from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useRegistry from '../registry-provider/use-registry';\nimport useAsyncMode from '../async-mode-provider/use-async-mode';\nimport type {\n\tMapSelect,\n\tSelectFunction,\n\tStoreDescriptor,\n\tAnyConfig,\n\tUseSelectReturn,\n\tDataRegistry,\n} from '../../types';\n\nconst renderQueue = createQueue();\n\nfunction warnOnUnstableReference(\n\ta: Record< string, unknown >,\n\tb: Record< string, unknown >\n): void {\n\tif ( ! a || ! b ) {\n\t\treturn;\n\t}\n\n\tconst keys =\n\t\ttypeof a === 'object' && typeof b === 'object'\n\t\t\t? Object.keys( a ).filter( ( k ) => a[ k ] !== b[ k ] )\n\t\t\t: [];\n\n\t// eslint-disable-next-line no-console\n\tconsole.warn(\n\t\t'The `useSelect` hook returns different values when called with the same state and parameters.\\n' +\n\t\t\t'This can lead to unnecessary re-renders and performance issues if not fixed.\\n\\n' +\n\t\t\t'Non-equal value keys: %s\\n\\n',\n\t\tkeys.join( ', ' )\n\t);\n}\n\ninterface StoreSubscriber {\n\tsubscribe: ( listener: () => void ) => () => void;\n\tupdateStores: ( newStores: string[] ) => void;\n}\n\nfunction Store( registry: DataRegistry, suspense: boolean ) {\n\tconst select = ( suspense\n\t\t? registry.suspendSelect\n\t\t: registry.select ) as unknown as SelectFunction;\n\tconst queueContext = {};\n\tlet lastMapSelect: MapSelect | undefined;\n\tlet lastMapResult: unknown;\n\tlet lastMapResultValid = false;\n\tlet lastIsAsync: boolean | undefined;\n\tlet subscriber: StoreSubscriber | undefined;\n\tlet didWarnUnstableReference: boolean | undefined;\n\tconst storeStatesOnMount = new Map< string, unknown >();\n\n\tfunction getStoreState( name: string ): unknown {\n\t\t// If there's no store property (custom generic store), return an empty\n\t\t// object. When comparing the state, the empty objects will cause the\n\t\t// equality check to fail, setting `lastMapResultValid` to false.\n\t\treturn registry.stores[ name ]?.store?.getState?.() ?? {};\n\t}\n\n\tconst createSubscriber = ( stores: string[] ): StoreSubscriber => {\n\t\t// The set of stores the `subscribe` function is supposed to subscribe to. Here it is\n\t\t// initialized, and then the `updateStores` function can add new stores to it.\n\t\tconst activeStores = [ ...stores ];\n\n\t\t// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could\n\t\t// be called multiple times to establish multiple subscriptions. That's why we need to\n\t\t// keep a set of active subscriptions;\n\t\tconst activeSubscriptions = new Set< ( storeName: string ) => void >();\n\n\t\tfunction subscribe( listener: () => void ): () => void {\n\t\t\t// Maybe invalidate the value right after subscription was created.\n\t\t\t// React will call `getValue` after subscribing, to detect store\n\t\t\t// updates that happened in the interval between the `getValue` call\n\t\t\t// during render and creating the subscription, which is slightly\n\t\t\t// delayed. We need to ensure that this second `getValue` call will\n\t\t\t// compute a fresh value only if any of the store states have\n\t\t\t// changed in the meantime.\n\t\t\tif ( lastMapResultValid ) {\n\t\t\t\tfor ( const name of activeStores ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tstoreStatesOnMount.get( name ) !== getStoreState( name )\n\t\t\t\t\t) {\n\t\t\t\t\t\tlastMapResultValid = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstoreStatesOnMount.clear();\n\n\t\t\tconst onStoreChange = () => {\n\t\t\t\t// Invalidate the value on store update, so that a fresh value is computed.\n\t\t\t\tlastMapResultValid = false;\n\t\t\t\tlistener();\n\t\t\t};\n\n\t\t\tconst onChange = () => {\n\t\t\t\tif ( lastIsAsync ) {\n\t\t\t\t\trenderQueue.add( queueContext, onStoreChange );\n\t\t\t\t} else {\n\t\t\t\t\tonStoreChange();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst unsubs: Array< VoidFunction > = [];\n\t\t\tfunction subscribeStore( storeName: string ) {\n\t\t\t\tunsubs.push( registry.subscribe( onChange, storeName ) );\n\t\t\t}\n\n\t\t\tfor ( const storeName of activeStores ) {\n\t\t\t\tsubscribeStore( storeName );\n\t\t\t}\n\n\t\t\tactiveSubscriptions.add( subscribeStore );\n\n\t\t\treturn () => {\n\t\t\t\tactiveSubscriptions.delete( subscribeStore );\n\n\t\t\t\tfor ( const unsub of unsubs.values() ) {\n\t\t\t\t\t// The return value of the subscribe function could be undefined if the store is a custom generic store.\n\t\t\t\t\tunsub?.();\n\t\t\t\t}\n\t\t\t\t// Cancel existing store updates that were already scheduled.\n\t\t\t\trenderQueue.cancel( queueContext );\n\t\t\t};\n\t\t}\n\n\t\t// Check if `newStores` contains some stores we're not subscribed to yet, and add them.\n\t\tfunction updateStores( newStores: string[] ) {\n\t\t\tfor ( const newStore of newStores ) {\n\t\t\t\tif ( activeStores.includes( newStore ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// New `subscribe` calls will subscribe to `newStore`, too.\n\t\t\t\tactiveStores.push( newStore );\n\n\t\t\t\t// Add `newStore` to existing subscriptions.\n\t\t\t\tfor ( const subscription of activeSubscriptions ) {\n\t\t\t\t\tsubscription( newStore );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { subscribe, updateStores };\n\t};\n\n\treturn ( mapSelect: MapSelect, isAsync: boolean ) => {\n\t\tfunction updateValue(): void {\n\t\t\t// If the last value is valid, and the `mapSelect` callback hasn't changed,\n\t\t\t// then we can safely return the cached value. The value can change only on\n\t\t\t// store update, and in that case value will be invalidated by the listener.\n\t\t\tif ( lastMapResultValid && mapSelect === lastMapSelect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst listeningStores = { current: null as string[] | null };\n\t\t\tconst mapResult = registry.__unstableMarkListeningStores(\n\t\t\t\t() => mapSelect( select, registry ),\n\t\t\t\tlisteningStores\n\t\t\t);\n\n\t\t\tif ( ( globalThis as any ).SCRIPT_DEBUG ) {\n\t\t\t\tif ( ! didWarnUnstableReference ) {\n\t\t\t\t\tconst secondMapResult = mapSelect( select, registry );\n\t\t\t\t\tif ( ! isShallowEqual( mapResult, secondMapResult ) ) {\n\t\t\t\t\t\twarnOnUnstableReference( mapResult, secondMapResult );\n\t\t\t\t\t\tdidWarnUnstableReference = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! subscriber ) {\n\t\t\t\tfor ( const name of listeningStores.current! ) {\n\t\t\t\t\tstoreStatesOnMount.set( name, getStoreState( name ) );\n\t\t\t\t}\n\t\t\t\tsubscriber = createSubscriber( listeningStores.current! );\n\t\t\t} else {\n\t\t\t\tsubscriber.updateStores( listeningStores.current! );\n\t\t\t}\n\n\t\t\t// If the new value is shallow-equal to the old one, keep the old one so\n\t\t\t// that we don't trigger unwanted updates that do a `===` check.\n\t\t\tif ( ! isShallowEqual( lastMapResult, mapResult ) ) {\n\t\t\t\tlastMapResult = mapResult;\n\t\t\t}\n\t\t\tlastMapSelect = mapSelect;\n\t\t\tlastMapResultValid = true;\n\t\t}\n\n\t\tfunction getValue() {\n\t\t\t// Update the value in case it's been invalidated or `mapSelect` has changed.\n\t\t\tupdateValue();\n\t\t\treturn lastMapResult;\n\t\t}\n\n\t\t// When transitioning from async to sync mode, cancel existing store updates\n\t\t// that have been scheduled, and invalidate the value so that it's freshly\n\t\t// computed. It might have been changed by the update we just cancelled.\n\t\tif ( lastIsAsync && ! isAsync ) {\n\t\t\tlastMapResultValid = false;\n\t\t\trenderQueue.cancel( queueContext );\n\t\t}\n\n\t\tupdateValue();\n\n\t\tlastIsAsync = isAsync;\n\n\t\t// Return a pair of functions that can be passed to `useSyncExternalStore`.\n\t\treturn { subscribe: subscriber!.subscribe, getValue };\n\t};\n}\n\nfunction _useStaticSelect( storeName: StoreDescriptor< AnyConfig > | string ) {\n\treturn useRegistry().select( storeName );\n}\n\nfunction _useMappingSelect(\n\tsuspense: boolean,\n\tmapSelect: MapSelect,\n\tdeps: unknown[]\n) {\n\tconst registry = useRegistry();\n\tconst isAsync = useAsyncMode();\n\tconst store = useMemo(\n\t\t() => Store( registry, suspense ),\n\t\t[ registry, suspense ]\n\t);\n\n\t// These are \"pass-through\" dependencies from the parent hook,\n\t// and the parent should catch any hook rule violations.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst selector = useCallback( mapSelect, deps );\n\tconst { subscribe, getValue } = store( selector, isAsync );\n\tconst result = useSyncExternalStore( subscribe, getValue, getValue );\n\tuseDebugValue( result );\n\treturn result;\n}\n\n/**\n * Custom react hook for retrieving props from registered selectors.\n *\n * In general, this custom React hook follows the\n * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks).\n *\n * @param mapSelect Function called on every state change. The returned value is\n * exposed to the component implementing this hook. The function\n * receives the `registry.select` method on the first argument\n * and the `registry` on the second argument.\n * When a store key is passed, all selectors for the store will be\n * returned. This is only meant for usage of these selectors in event\n * callbacks, not for data needed to create the element tree.\n * @param deps If provided, this memoizes the mapSelect so the same `mapSelect` is\n * invoked on every state change unless the dependencies change.\n *\n * @example\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function HammerPriceDisplay( { currency } ) {\n * const price = useSelect( ( select ) => {\n * return select( myCustomStore ).getPrice( 'hammer', currency );\n * }, [ currency ] );\n * return new Intl.NumberFormat( 'en-US', {\n * style: 'currency',\n * currency,\n * } ).format( price );\n * }\n *\n * // Rendered in the application:\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n *\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, the price will be retrieved from the store state using the\n * `mapSelect` callback on `useSelect`. If the currency prop changes then\n * any price in the state for that currency is retrieved. If the currency prop\n * doesn't change and other props are passed in that do change, the price will\n * not change because the dependency is just the currency.\n *\n * When data is only used in an event callback, the data should not be retrieved\n * on render, so it may be useful to get the selectors function instead.\n *\n * **Don't use `useSelect` this way when calling the selectors in the render\n * function because your component won't re-render on a data change.**\n *\n * ```js\n * import { useSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function Paste( { children } ) {\n * const { getSettings } = useSelect( myCustomStore );\n * function onPaste() {\n * // Do something with the settings.\n * const settings = getSettings();\n * }\n * return <div onPaste={ onPaste }>{ children }</div>;\n * }\n * ```\n *\n * @return The selected data or store selectors.\n */\nexport default function useSelect<\n\tT extends MapSelect | StoreDescriptor< AnyConfig >,\n>( mapSelect: T, deps?: unknown[] ): UseSelectReturn< T > {\n\t// On initial call, on mount, determine the mode of this `useSelect` call\n\t// and then never allow it to change on subsequent updates.\n\tconst staticSelectMode = typeof mapSelect !== 'function';\n\tconst staticSelectModeRef = useRef( staticSelectMode );\n\n\tif ( staticSelectMode !== staticSelectModeRef.current ) {\n\t\tconst prevMode = staticSelectModeRef.current ? 'static' : 'mapping';\n\t\tconst nextMode = staticSelectMode ? 'static' : 'mapping';\n\t\tthrow new Error(\n\t\t\t`Switching useSelect from ${ prevMode } to ${ nextMode } is not allowed`\n\t\t);\n\t}\n\n\t// `staticSelectMode` is not allowed to change during the hook instance's,\n\t// lifetime, so the rules of hooks are not really violated.\n\n\treturn (\n\t\tstaticSelectMode\n\t\t\t? _useStaticSelect( mapSelect as StoreDescriptor< AnyConfig > )\n\t\t\t: _useMappingSelect( false, mapSelect as MapSelect, deps! )\n\t) as UseSelectReturn< T >;\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but is a compatible\n * Suspense-enabled data source.\n *\n * @param mapSelect Function called on every state change. The\n * returned value is exposed to the component\n * using this hook. The function receives the\n * `registry.suspendSelect` method as the first\n * argument and the `registry` as the second one.\n * @param deps A dependency array used to memoize the `mapSelect`\n * so that the same `mapSelect` is invoked on every\n * state change unless the dependencies change.\n *\n * @throws A suspense Promise that is thrown if any of the called\n * selectors is in an unresolved state.\n *\n * @return Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect< T extends MapSelect >(\n\tmapSelect: T,\n\tdeps: unknown[]\n): ReturnType< T > {\n\treturn _useMappingSelect( true, mapSelect, deps ) as ReturnType< T >;\n}\n"],
5
+ "mappings": "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",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/with-dispatch/index.js
1
+ // packages/data/src/components/with-dispatch/index.tsx
2
2
  import { createHigherOrderComponent } from "@wordpress/compose";
3
3
  import { useDispatchWithMap } from "../use-dispatch/index.mjs";
4
4
  import { jsx } from "react/jsx-runtime";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/with-dispatch/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useDispatchWithMap } from '../use-dispatch';\n\n/** @typedef {React.ComponentType} ComponentType */\n\n/**\n * Higher-order component used to add dispatch props using registered action\n * creators.\n *\n * @param {Function} mapDispatchToProps A function of returning an object of\n * prop names where value is a\n * dispatch-bound action creator, or a\n * function to be called with the\n * component's props and returning an\n * action creator.\n *\n * @example\n * ```jsx\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>;\n * }\n *\n * import { withDispatch } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * const SaleButton = withDispatch( ( dispatch, ownProps ) => {\n * const { startSale } = dispatch( myCustomStore );\n * const { discountPercent } = ownProps;\n *\n * return {\n * onClick() {\n * startSale( discountPercent );\n * },\n * };\n * } )( Button );\n *\n * // Rendered in the application:\n * //\n * // <SaleButton discountPercent=\"20\">Start Sale!</SaleButton>\n * ```\n *\n * @example\n * In the majority of cases, it will be sufficient to use only two first params\n * passed to `mapDispatchToProps` as illustrated in the previous example.\n * However, there might be some very advanced use cases where using the\n * `registry` object might be used as a tool to optimize the performance of\n * your component. Using `select` function from the registry might be useful\n * when you need to fetch some dynamic data from the store at the time when the\n * event is fired, but at the same time, you never use it to render your\n * component. In such scenario, you can avoid using the `withSelect` higher\n * order component to compute such prop, which might lead to unnecessary\n * re-renders of your component caused by its frequent value change.\n * Keep in mind, that `mapDispatchToProps` must return an object with functions\n * only.\n *\n * ```jsx\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>;\n * }\n *\n * import { withDispatch } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {\n * // Stock number changes frequently.\n * const { getStockNumber } = select( myCustomStore );\n * const { startSale } = dispatch( myCustomStore );\n * return {\n * onClick() {\n * const discountPercent = getStockNumber() > 50 ? 10 : 20;\n * startSale( discountPercent );\n * },\n * };\n * } )( Button );\n *\n * // Rendered in the application:\n * //\n * // <SaleButton>Start Sale!</SaleButton>\n * ```\n *\n * _Note:_ It is important that the `mapDispatchToProps` function always\n * returns an object with the same keys. For example, it should not contain\n * conditions under which a different value would be returned.\n *\n * @return {ComponentType} Enhanced component with merged dispatcher props.\n */\nconst withDispatch = ( mapDispatchToProps ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( ownProps ) => {\n\t\t\tconst mapDispatch = ( dispatch, registry ) =>\n\t\t\t\tmapDispatchToProps( dispatch, ownProps, registry );\n\t\t\tconst dispatchProps = useDispatchWithMap( mapDispatch, [] );\n\t\t\treturn <WrappedComponent { ...ownProps } { ...dispatchProps } />;\n\t\t},\n\t\t'withDispatch'\n\t);\n\nexport default withDispatch;\n"],
5
- "mappings": ";AAGA,SAAS,kCAAkC;AAK3C,SAAS,0BAA0B;AA2FzB;AANV,IAAM,eAAe,CAAE,uBACtB;AAAA,EACC,CAAE,qBAAsB,CAAE,aAAc;AACvC,UAAM,cAAc,CAAE,UAAU,aAC/B,mBAAoB,UAAU,UAAU,QAAS;AAClD,UAAM,gBAAgB,mBAAoB,aAAa,CAAC,CAAE;AAC1D,WAAO,oBAAC,oBAAmB,GAAG,UAAa,GAAG,eAAgB;AAAA,EAC/D;AAAA,EACA;AACD;AAED,IAAO,wBAAQ;",
3
+ "sources": ["../../../src/components/with-dispatch/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useDispatchWithMap } from '../use-dispatch';\nimport type { DataRegistry } from '../../types';\n\n/**\n * Higher-order component used to add dispatch props using registered action\n * creators.\n *\n * @param mapDispatchToProps A function of returning an object of\n * prop names where value is a\n * dispatch-bound action creator, or a\n * function to be called with the\n * component's props and returning an\n * action creator.\n *\n * @example\n * ```jsx\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>;\n * }\n *\n * import { withDispatch } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * const SaleButton = withDispatch( ( dispatch, ownProps ) => {\n * const { startSale } = dispatch( myCustomStore );\n * const { discountPercent } = ownProps;\n *\n * return {\n * onClick() {\n * startSale( discountPercent );\n * },\n * };\n * } )( Button );\n *\n * // Rendered in the application:\n * //\n * // <SaleButton discountPercent=\"20\">Start Sale!</SaleButton>\n * ```\n *\n * @example\n * In the majority of cases, it will be sufficient to use only two first params\n * passed to `mapDispatchToProps` as illustrated in the previous example.\n * However, there might be some very advanced use cases where using the\n * `registry` object might be used as a tool to optimize the performance of\n * your component. Using `select` function from the registry might be useful\n * when you need to fetch some dynamic data from the store at the time when the\n * event is fired, but at the same time, you never use it to render your\n * component. In such scenario, you can avoid using the `withSelect` higher\n * order component to compute such prop, which might lead to unnecessary\n * re-renders of your component caused by its frequent value change.\n * Keep in mind, that `mapDispatchToProps` must return an object with functions\n * only.\n *\n * ```jsx\n * function Button( { onClick, children } ) {\n * return <button type=\"button\" onClick={ onClick }>{ children }</button>;\n * }\n *\n * import { withDispatch } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {\n * // Stock number changes frequently.\n * const { getStockNumber } = select( myCustomStore );\n * const { startSale } = dispatch( myCustomStore );\n * return {\n * onClick() {\n * const discountPercent = getStockNumber() > 50 ? 10 : 20;\n * startSale( discountPercent );\n * },\n * };\n * } )( Button );\n *\n * // Rendered in the application:\n * //\n * // <SaleButton>Start Sale!</SaleButton>\n * ```\n *\n * _Note:_ It is important that the `mapDispatchToProps` function always\n * returns an object with the same keys. For example, it should not contain\n * conditions under which a different value would be returned.\n *\n * @return Enhanced component with merged dispatcher props.\n */\nconst withDispatch = (\n\tmapDispatchToProps: (\n\t\tdispatch: DataRegistry[ 'dispatch' ],\n\t\townProps: Record< string, unknown >,\n\t\tregistry: DataRegistry\n\t) => Record< string, ( ...args: unknown[] ) => unknown >\n) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( ownProps: Record< string, unknown > ) => {\n\t\t\tconst mapDispatch = (\n\t\t\t\tdispatch: DataRegistry[ 'dispatch' ],\n\t\t\t\tregistry: DataRegistry\n\t\t\t) => mapDispatchToProps( dispatch, ownProps, registry );\n\t\t\tconst dispatchProps = useDispatchWithMap( mapDispatch, [] );\n\t\t\treturn <WrappedComponent { ...ownProps } { ...dispatchProps } />;\n\t\t},\n\t\t'withDispatch'\n\t);\n\nexport default withDispatch;\n"],
5
+ "mappings": ";AAGA,SAAS,kCAAkC;AAK3C,SAAS,0BAA0B;AAkGzB;AAdV,IAAM,eAAe,CACpB,uBAMA;AAAA,EACC,CAAE,qBAAsB,CAAE,aAAyC;AAClE,UAAM,cAAc,CACnB,UACA,aACI,mBAAoB,UAAU,UAAU,QAAS;AACtD,UAAM,gBAAgB,mBAAoB,aAAa,CAAC,CAAE;AAC1D,WAAO,oBAAC,oBAAmB,GAAG,UAAa,GAAG,eAAgB;AAAA,EAC/D;AAAA,EACA;AACD;AAED,IAAO,wBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/with-registry/index.js
1
+ // packages/data/src/components/with-registry/index.tsx
2
2
  import { createHigherOrderComponent } from "@wordpress/compose";
3
3
  import { RegistryConsumer } from "../registry-provider/index.mjs";
4
4
  import { jsx } from "react/jsx-runtime";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/with-registry/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { RegistryConsumer } from '../registry-provider';\n\n/**\n * Higher-order component which renders the original component with the current\n * registry context passed as its `registry` prop.\n *\n * @param {Component} OriginalComponent Original component.\n *\n * @return {Component} Enhanced component.\n */\nconst withRegistry = createHigherOrderComponent(\n\t( OriginalComponent ) => ( props ) => (\n\t\t<RegistryConsumer>\n\t\t\t{ ( registry ) => (\n\t\t\t\t<OriginalComponent { ...props } registry={ registry } />\n\t\t\t) }\n\t\t</RegistryConsumer>\n\t),\n\t'withRegistry'\n);\n\nexport default withRegistry;\n"],
5
- "mappings": ";AAGA,SAAS,kCAAkC;AAK3C,SAAS,wBAAwB;AAc7B;AAJJ,IAAM,eAAe;AAAA,EACpB,CAAE,sBAAuB,CAAE,UAC1B,oBAAC,oBACE,WAAE,aACH,oBAAC,qBAAoB,GAAG,OAAQ,UAAsB,GAExD;AAAA,EAED;AACD;AAEA,IAAO,wBAAQ;",
3
+ "sources": ["../../../src/components/with-registry/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { RegistryConsumer } from '../registry-provider';\n\n/**\n * Higher-order component which renders the original component with the current\n * registry context passed as its `registry` prop.\n */\nconst withRegistry = createHigherOrderComponent(\n\t( OriginalComponent ) => ( props: Record< string, unknown > ) => (\n\t\t<RegistryConsumer>\n\t\t\t{ ( registry ) => (\n\t\t\t\t<OriginalComponent { ...props } registry={ registry } />\n\t\t\t) }\n\t\t</RegistryConsumer>\n\t),\n\t'withRegistry'\n);\n\nexport default withRegistry;\n"],
5
+ "mappings": ";AAGA,SAAS,kCAAkC;AAK3C,SAAS,wBAAwB;AAU7B;AAJJ,IAAM,eAAe;AAAA,EACpB,CAAE,sBAAuB,CAAE,UAC1B,oBAAC,oBACE,WAAE,aACH,oBAAC,qBAAoB,GAAG,OAAQ,UAAsB,GAExD;AAAA,EAED;AACD;AAEA,IAAO,wBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/data/src/components/with-select/index.js
1
+ // packages/data/src/components/with-select/index.tsx
2
2
  import { createHigherOrderComponent, pure } from "@wordpress/compose";
3
3
  import useSelect from "../use-select/index.mjs";
4
4
  import { jsx } from "react/jsx-runtime";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/with-select/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, pure } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useSelect from '../use-select';\n\n/** @typedef {React.ComponentType} ComponentType */\n\n/**\n * Higher-order component used to inject state-derived props using registered\n * selectors.\n *\n * @param {Function} mapSelectToProps Function called on every state change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @example\n * ```js\n * import { withSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function PriceDisplay( { price, currency } ) {\n * \treturn new Intl.NumberFormat( 'en-US', {\n * \t\tstyle: 'currency',\n * \t\tcurrency,\n * \t} ).format( price );\n * }\n *\n * const HammerPriceDisplay = withSelect( ( select, ownProps ) => {\n * \tconst { getPrice } = select( myCustomStore );\n * \tconst { currency } = ownProps;\n *\n * \treturn {\n * \t\tprice: getPrice( 'hammer', currency ),\n * \t};\n * } )( PriceDisplay );\n *\n * // Rendered in the application:\n * //\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, it will pass the price into the underlying `PriceDisplay`\n * component and update automatically if the price of a hammer ever changes in\n * the store.\n *\n * @return {ComponentType} Enhanced component with merged state data props.\n */\nconst withSelect = ( mapSelectToProps ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) =>\n\t\t\tpure( ( ownProps ) => {\n\t\t\t\tconst mapSelect = ( select, registry ) =>\n\t\t\t\t\tmapSelectToProps( select, ownProps, registry );\n\t\t\t\tconst mergeProps = useSelect( mapSelect );\n\t\t\t\treturn <WrappedComponent { ...ownProps } { ...mergeProps } />;\n\t\t\t} ),\n\t\t'withSelect'\n\t);\n\nexport default withSelect;\n"],
5
- "mappings": ";AAGA,SAAS,4BAA4B,YAAY;AAKjD,OAAO,eAAe;AAmDX;AAPX,IAAM,aAAa,CAAE,qBACpB;AAAA,EACC,CAAE,qBACD,KAAM,CAAE,aAAc;AACrB,UAAM,YAAY,CAAE,QAAQ,aAC3B,iBAAkB,QAAQ,UAAU,QAAS;AAC9C,UAAM,aAAa,UAAW,SAAU;AACxC,WAAO,oBAAC,oBAAmB,GAAG,UAAa,GAAG,YAAa;AAAA,EAC5D,CAAE;AAAA,EACH;AACD;AAED,IAAO,sBAAQ;",
3
+ "sources": ["../../../src/components/with-select/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, pure } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useSelect from '../use-select';\nimport type { SelectFunction, DataRegistry } from '../../types';\n\n/**\n * Higher-order component used to inject state-derived props using registered\n * selectors.\n *\n * @param mapSelectToProps Function called on every state change,\n * expected to return object of props to\n * merge with the component's own props.\n *\n * @example\n * ```js\n * import { withSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * function PriceDisplay( { price, currency } ) {\n * \treturn new Intl.NumberFormat( 'en-US', {\n * \t\tstyle: 'currency',\n * \t\tcurrency,\n * \t} ).format( price );\n * }\n *\n * const HammerPriceDisplay = withSelect( ( select, ownProps ) => {\n * \tconst { getPrice } = select( myCustomStore );\n * \tconst { currency } = ownProps;\n *\n * \treturn {\n * \t\tprice: getPrice( 'hammer', currency ),\n * \t};\n * } )( PriceDisplay );\n *\n * // Rendered in the application:\n * //\n * // <HammerPriceDisplay currency=\"USD\" />\n * ```\n * In the above example, when `HammerPriceDisplay` is rendered into an\n * application, it will pass the price into the underlying `PriceDisplay`\n * component and update automatically if the price of a hammer ever changes in\n * the store.\n *\n * @return Enhanced component with merged state data props.\n */\nconst withSelect = (\n\tmapSelectToProps: (\n\t\tselect: SelectFunction,\n\t\townProps: Record< string, unknown >,\n\t\tregistry: DataRegistry\n\t) => Record< string, unknown >\n) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) =>\n\t\t\tpure( ( ownProps: Record< string, unknown > ) => {\n\t\t\t\tconst mapSelect = (\n\t\t\t\t\tselect: SelectFunction,\n\t\t\t\t\tregistry: DataRegistry\n\t\t\t\t) => mapSelectToProps( select, ownProps, registry );\n\t\t\t\tconst mergeProps = useSelect( mapSelect );\n\t\t\t\treturn <WrappedComponent { ...ownProps } { ...mergeProps } />;\n\t\t\t} ),\n\t\t'withSelect'\n\t);\n\nexport default withSelect;\n"],
5
+ "mappings": ";AAGA,SAAS,4BAA4B,YAAY;AAKjD,OAAO,eAAe;AA0DX;AAfX,IAAM,aAAa,CAClB,qBAMA;AAAA,EACC,CAAE,qBACD,KAAM,CAAE,aAAyC;AAChD,UAAM,YAAY,CACjB,QACA,aACI,iBAAkB,QAAQ,UAAU,QAAS;AAClD,UAAM,aAAa,UAAW,SAAU;AACxC,WAAO,oBAAC,oBAAmB,GAAG,UAAa,GAAG,YAAa;AAAA,EAC5D,CAAE;AAAA,EACH;AACD;AAED,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,15 +1,15 @@
1
- // packages/data/src/controls.js
1
+ // packages/data/src/controls.ts
2
2
  import { createRegistryControl } from "./factory.mjs";
3
3
  var SELECT = "@@data/SELECT";
4
4
  var RESOLVE_SELECT = "@@data/RESOLVE_SELECT";
5
5
  var DISPATCH = "@@data/DISPATCH";
6
- function isObject(object) {
6
+ function isStoreDescriptor(object) {
7
7
  return object !== null && typeof object === "object";
8
8
  }
9
9
  function select(storeNameOrDescriptor, selectorName, ...args) {
10
10
  return {
11
11
  type: SELECT,
12
- storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
12
+ storeKey: isStoreDescriptor(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
13
13
  selectorName,
14
14
  args
15
15
  };
@@ -17,7 +17,7 @@ function select(storeNameOrDescriptor, selectorName, ...args) {
17
17
  function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
18
18
  return {
19
19
  type: RESOLVE_SELECT,
20
- storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
20
+ storeKey: isStoreDescriptor(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
21
21
  selectorName,
22
22
  args
23
23
  };
@@ -25,7 +25,7 @@ function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
25
25
  function dispatch(storeNameOrDescriptor, actionName, ...args) {
26
26
  return {
27
27
  type: DISPATCH,
28
- storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
28
+ storeKey: isStoreDescriptor(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
29
29
  actionName,
30
30
  args
31
31
  };
@@ -37,7 +37,8 @@ var builtinControls = {
37
37
  ),
38
38
  [RESOLVE_SELECT]: createRegistryControl(
39
39
  (registry) => ({ storeKey, selectorName, args }) => {
40
- const method = registry.select(storeKey)[selectorName].hasResolver ? "resolveSelect" : "select";
40
+ const selector = registry.select(storeKey)[selectorName];
41
+ const method = selector.hasResolver ? "resolveSelect" : "select";
41
42
  return registry[method](storeKey)[selectorName](
42
43
  ...args
43
44
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/controls.js"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { createRegistryControl } from './factory';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nconst SELECT = '@@data/SELECT';\nconst RESOLVE_SELECT = '@@data/RESOLVE_SELECT';\nconst DISPATCH = '@@data/DISPATCH';\n\nfunction isObject( object ) {\n\treturn object !== null && typeof object === 'object';\n}\n\n/**\n * Dispatches a control action for triggering a synchronous registry select.\n *\n * Note: This control synchronously returns the current selector value, triggering the\n * resolution, but not waiting for it.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector.\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using `select`.\n * export function* myAction() {\n * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );\n * // Do stuff with the result from the `select`.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction select( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering and resolving a registry select.\n *\n * Note: when this control action is handled, it automatically considers\n * selectors that may have a resolver. In such case, it will return a `Promise` that resolves\n * after the selector finishes resolving, with the final result value.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using resolveSelect\n * export function* myAction() {\n * \tconst isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );\n * \t// do stuff with the result from the select.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction resolveSelect( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: RESOLVE_SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering a registry dispatch.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} actionName The name of the action to dispatch\n * @param {Array} args Arguments for the dispatch action.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data-controls';\n *\n * // Action generator using dispatch\n * export function* myAction() {\n * yield controls.dispatch( 'core/editor', 'togglePublishSidebar' );\n * // do some other things.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction dispatch( storeNameOrDescriptor, actionName, ...args ) {\n\treturn {\n\t\ttype: DISPATCH,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tactionName,\n\t\targs,\n\t};\n}\n\nexport const controls = { select, resolveSelect, dispatch };\n\nexport const builtinControls = {\n\t[ SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) =>\n\t\t\t\tregistry.select( storeKey )[ selectorName ]( ...args )\n\t),\n\t[ RESOLVE_SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) => {\n\t\t\t\tconst method = registry.select( storeKey )[ selectorName ]\n\t\t\t\t\t.hasResolver\n\t\t\t\t\t? 'resolveSelect'\n\t\t\t\t\t: 'select';\n\t\t\t\treturn registry[ method ]( storeKey )[ selectorName ](\n\t\t\t\t\t...args\n\t\t\t\t);\n\t\t\t}\n\t),\n\t[ DISPATCH ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, actionName, args } ) =>\n\t\t\t\tregistry.dispatch( storeKey )[ actionName ]( ...args )\n\t),\n};\n"],
5
- "mappings": ";AAGA,SAAS,6BAA6B;AAItC,IAAM,SAAS;AACf,IAAM,iBAAiB;AACvB,IAAM,WAAW;AAEjB,SAAS,SAAU,QAAS;AAC3B,SAAO,WAAW,QAAQ,OAAO,WAAW;AAC7C;AAyBA,SAAS,OAAQ,uBAAuB,iBAAiB,MAAO;AAC/D,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU,SAAU,qBAAsB,IACvC,sBAAsB,OACtB;AAAA,IACH;AAAA,IACA;AAAA,EACD;AACD;AA0BA,SAAS,cAAe,uBAAuB,iBAAiB,MAAO;AACtE,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU,SAAU,qBAAsB,IACvC,sBAAsB,OACtB;AAAA,IACH;AAAA,IACA;AAAA,EACD;AACD;AAsBA,SAAS,SAAU,uBAAuB,eAAe,MAAO;AAC/D,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU,SAAU,qBAAsB,IACvC,sBAAsB,OACtB;AAAA,IACH;AAAA,IACA;AAAA,EACD;AACD;AAEO,IAAM,WAAW,EAAE,QAAQ,eAAe,SAAS;AAEnD,IAAM,kBAAkB;AAAA,EAC9B,CAAE,MAAO,GAAG;AAAA,IACX,CAAE,aACD,CAAE,EAAE,UAAU,cAAc,KAAK,MAChC,SAAS,OAAQ,QAAS,EAAG,YAAa,EAAG,GAAG,IAAK;AAAA,EACxD;AAAA,EACA,CAAE,cAAe,GAAG;AAAA,IACnB,CAAE,aACD,CAAE,EAAE,UAAU,cAAc,KAAK,MAAO;AACvC,YAAM,SAAS,SAAS,OAAQ,QAAS,EAAG,YAAa,EACvD,cACC,kBACA;AACH,aAAO,SAAU,MAAO,EAAG,QAAS,EAAG,YAAa;AAAA,QACnD,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,EACF;AAAA,EACA,CAAE,QAAS,GAAG;AAAA,IACb,CAAE,aACD,CAAE,EAAE,UAAU,YAAY,KAAK,MAC9B,SAAS,SAAU,QAAS,EAAG,UAAW,EAAG,GAAG,IAAK;AAAA,EACxD;AACD;",
3
+ "sources": ["../src/controls.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { createRegistryControl } from './factory';\nimport type { StoreDescriptor } from './types';\n\nconst SELECT = '@@data/SELECT';\nconst RESOLVE_SELECT = '@@data/RESOLVE_SELECT';\nconst DISPATCH = '@@data/DISPATCH';\n\nfunction isStoreDescriptor( object: unknown ): object is StoreDescriptor {\n\treturn object !== null && typeof object === 'object';\n}\n\n/**\n * Dispatches a control action for triggering a synchronous registry select.\n *\n * Note: This control synchronously returns the current selector value, triggering the\n * resolution, but not waiting for it.\n *\n * @param storeNameOrDescriptor Unique namespace identifier for the store\n * @param selectorName The name of the selector.\n * @param args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using `select`.\n * export function* myAction() {\n * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );\n * // Do stuff with the result from the `select`.\n * }\n * ```\n *\n * @return The control descriptor.\n */\nfunction select(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: unknown[]\n) {\n\treturn {\n\t\ttype: SELECT,\n\t\tstoreKey: isStoreDescriptor( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering and resolving a registry select.\n *\n * Note: when this control action is handled, it automatically considers\n * selectors that may have a resolver. In such case, it will return a `Promise` that resolves\n * after the selector finishes resolving, with the final result value.\n *\n * @param storeNameOrDescriptor Unique namespace identifier for the store\n * @param selectorName The name of the selector\n * @param args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using resolveSelect\n * export function* myAction() {\n * \tconst isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );\n * \t// do stuff with the result from the select.\n * }\n * ```\n *\n * @return The control descriptor.\n */\nfunction resolveSelect(\n\tstoreNameOrDescriptor: string | StoreDescriptor< any >,\n\tselectorName: string,\n\t...args: any[]\n) {\n\treturn {\n\t\ttype: RESOLVE_SELECT,\n\t\tstoreKey: isStoreDescriptor( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering a registry dispatch.\n *\n * @param storeNameOrDescriptor Unique namespace identifier for the store\n * @param actionName The name of the action to dispatch\n * @param args Arguments for the dispatch action.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data-controls';\n *\n * // Action generator using dispatch\n * export function* myAction() {\n * yield controls.dispatch( 'core/editor', 'togglePublishSidebar' );\n * // do some other things.\n * }\n * ```\n *\n * @return The control descriptor.\n */\nfunction dispatch(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tactionName: string,\n\t...args: unknown[]\n) {\n\treturn {\n\t\ttype: DISPATCH,\n\t\tstoreKey: isStoreDescriptor( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tactionName,\n\t\targs,\n\t};\n}\n\nexport const controls = { select, resolveSelect, dispatch };\n\ntype SelectorControlArgs = {\n\tstoreKey: string;\n\tselectorName: string;\n\targs: unknown[];\n};\n\ntype ActionControlArgs = {\n\tstoreKey: string;\n\tactionName: string;\n\targs: unknown[];\n};\n\nexport const builtinControls = {\n\t[ SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args }: SelectorControlArgs ) =>\n\t\t\t\tregistry.select( storeKey )[ selectorName ]( ...args )\n\t),\n\t[ RESOLVE_SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args }: SelectorControlArgs ) => {\n\t\t\t\tconst selector = registry.select( storeKey )[\n\t\t\t\t\tselectorName\n\t\t\t\t] as ( ( ...a: any[] ) => any ) & {\n\t\t\t\t\thasResolver?: boolean;\n\t\t\t\t};\n\t\t\t\tconst method = selector.hasResolver\n\t\t\t\t\t? 'resolveSelect'\n\t\t\t\t\t: 'select';\n\t\t\t\treturn registry[ method ]( storeKey )[ selectorName ](\n\t\t\t\t\t...args\n\t\t\t\t);\n\t\t\t}\n\t),\n\t[ DISPATCH ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, actionName, args }: ActionControlArgs ) =>\n\t\t\t\tregistry.dispatch( storeKey )[ actionName ]( ...args )\n\t),\n};\n"],
5
+ "mappings": ";AAGA,SAAS,6BAA6B;AAGtC,IAAM,SAAS;AACf,IAAM,iBAAiB;AACvB,IAAM,WAAW;AAEjB,SAAS,kBAAmB,QAA6C;AACxE,SAAO,WAAW,QAAQ,OAAO,WAAW;AAC7C;AAyBA,SAAS,OACR,uBACA,iBACG,MACF;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU,kBAAmB,qBAAsB,IAChD,sBAAsB,OACtB;AAAA,IACH;AAAA,IACA;AAAA,EACD;AACD;AA0BA,SAAS,cACR,uBACA,iBACG,MACF;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU,kBAAmB,qBAAsB,IAChD,sBAAsB,OACtB;AAAA,IACH;AAAA,IACA;AAAA,EACD;AACD;AAsBA,SAAS,SACR,uBACA,eACG,MACF;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU,kBAAmB,qBAAsB,IAChD,sBAAsB,OACtB;AAAA,IACH;AAAA,IACA;AAAA,EACD;AACD;AAEO,IAAM,WAAW,EAAE,QAAQ,eAAe,SAAS;AAcnD,IAAM,kBAAkB;AAAA,EAC9B,CAAE,MAAO,GAAG;AAAA,IACX,CAAE,aACD,CAAE,EAAE,UAAU,cAAc,KAAK,MAChC,SAAS,OAAQ,QAAS,EAAG,YAAa,EAAG,GAAG,IAAK;AAAA,EACxD;AAAA,EACA,CAAE,cAAe,GAAG;AAAA,IACnB,CAAE,aACD,CAAE,EAAE,UAAU,cAAc,KAAK,MAA4B;AAC5D,YAAM,WAAW,SAAS,OAAQ,QAAS,EAC1C,YACD;AAGA,YAAM,SAAS,SAAS,cACrB,kBACA;AACH,aAAO,SAAU,MAAO,EAAG,QAAS,EAAG,YAAa;AAAA,QACnD,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,EACF;AAAA,EACA,CAAE,QAAS,GAAG;AAAA,IACb,CAAE,aACD,CAAE,EAAE,UAAU,YAAY,KAAK,MAC9B,SAAS,SAAU,QAAS,EAAG,UAAW,EAAG,GAAG,IAAK;AAAA,EACxD;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,7 @@
1
- // packages/data/src/default-registry.js
1
+ // packages/data/src/default-registry.ts
2
2
  import { createRegistry } from "./registry.mjs";
3
- var default_registry_default = createRegistry();
3
+ var defaultRegistry = createRegistry();
4
+ var default_registry_default = defaultRegistry;
4
5
  export {
5
6
  default_registry_default as default
6
7
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/default-registry.js"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { createRegistry } from './registry';\n\nexport default createRegistry();\n"],
5
- "mappings": ";AAGA,SAAS,sBAAsB;AAE/B,IAAO,2BAAQ,eAAe;",
3
+ "sources": ["../src/default-registry.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { createRegistry } from './registry';\n\nconst defaultRegistry = createRegistry();\n\nexport default defaultRegistry;\n"],
5
+ "mappings": ";AAGA,SAAS,sBAAsB;AAE/B,IAAM,kBAAkB,eAAe;AAEvC,IAAO,2BAAQ;",
6
6
  "names": []
7
7
  }