@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
package/README.md CHANGED
@@ -308,10 +308,6 @@ _Parameters_
308
308
 
309
309
  - _props.value_ `boolean`: Enable Async Mode.
310
310
 
311
- _Returns_
312
-
313
- - `Component`: The component to be rendered.
314
-
315
311
  ### combineReducers
316
312
 
317
313
  The combineReducers helper function turns an object whose values are different reducing functions into a single reducing function you can pass to registerReducer.
@@ -379,11 +375,11 @@ const store = createReduxStore( 'demo', {
379
375
  _Parameters_
380
376
 
381
377
  - _key_ `string`: Unique namespace identifier.
382
- - _options_ `ReduxStoreConfig<State,Actions,Selectors>`: Registered store options, with properties describing reducer, actions, selectors, and resolvers.
378
+ - _options_ `ReduxStoreConfig< State, Actions, Selectors >`: Registered store options, with properties describing reducer, actions, selectors, and resolvers.
383
379
 
384
380
  _Returns_
385
381
 
386
- - `StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>`: Store Object.
382
+ - `StoreDescriptor< ReduxStoreConfig< State, Actions, Selectors > >`: Store Object.
387
383
 
388
384
  ### createRegistry
389
385
 
@@ -391,12 +387,12 @@ Creates a new store registry, given an optional object of initial store configur
391
387
 
392
388
  _Parameters_
393
389
 
394
- - _storeConfigs_ `Object`: Initial store configurations.
395
- - _parent_ `?Object`: Parent registry.
390
+ - _storeConfigs_ `Record< string, ReduxStoreConfig< any, any, any > >`: Initial store configurations.
391
+ - _parent_ `DataRegistry | null`: Parent registry.
396
392
 
397
393
  _Returns_
398
394
 
399
- - `WPDataRegistry`: Data registry.
395
+ - `DataRegistry`: Data registry.
400
396
 
401
397
  ### createRegistryControl
402
398
 
@@ -491,6 +487,8 @@ Given a store descriptor, returns an object of the store's action creators. Call
491
487
 
492
488
  Note: Action creators returned by the dispatch will return a promise when they are called.
493
489
 
490
+ Warning: This global `dispatch` function only works with the default registry. It will not work with custom `RegistryProvider` or `BlockEditorProvider` contexts. In React components, prefer the `useDispatch` hook instead, which is registry-aware.
491
+
494
492
  _Usage_
495
493
 
496
494
  ```js
@@ -626,6 +624,8 @@ _Returns_
626
624
 
627
625
  Given a store descriptor, returns an object of the store's selectors. The selector functions are been pre-bound to pass the current state automatically. As a consumer, you need only pass arguments of the selector, if applicable.
628
626
 
627
+ Warning: This global `select` function only works with the default registry. It will not work with custom `RegistryProvider` or `BlockEditorProvider` contexts. In React components, prefer the `useSelect` hook instead, which is registry-aware.
628
+
629
629
  _Usage_
630
630
 
631
631
  ```js
@@ -733,11 +733,11 @@ const SaleButton = ( { children } ) => {
733
733
 
734
734
  _Parameters_
735
735
 
736
- - _storeNameOrDescriptor_ `[StoreNameOrDescriptor]`: Optionally provide the name of the store or its descriptor from which to retrieve action creators. If not provided, the registry.dispatch function is returned instead.
736
+ - _storeNameOrDescriptor_ `StoreNameOrDescriptor`: Optionally provide the name of the store or its descriptor from which to retrieve action creators. If not provided, the registry.dispatch function is returned instead.
737
737
 
738
738
  _Returns_
739
739
 
740
- - `UseDispatchReturn<StoreNameOrDescriptor>`: A custom react hook.
740
+ - `UseDispatchReturn< StoreNameOrDescriptor >`: The dispatch function or action creators for the store.
741
741
 
742
742
  ### useRegistry
743
743
 
@@ -772,7 +772,7 @@ const ParentProvidingRegistry = ( props ) => {
772
772
 
773
773
  _Returns_
774
774
 
775
- - `import('../../types').DataRegistry`: A custom react hook exposing the registry context value.
775
+ - `DataRegistry`: A custom react hook exposing the registry context value.
776
776
 
777
777
  ### useSelect
778
778
 
@@ -833,11 +833,11 @@ function Paste( { children } ) {
833
833
  _Parameters_
834
834
 
835
835
  - _mapSelect_ `T`: Function called on every state change. The returned value is exposed to the component implementing this hook. The function receives the `registry.select` method on the first argument and the `registry` on the second argument. When a store key is passed, all selectors for the store will be returned. This is only meant for usage of these selectors in event callbacks, not for data needed to create the element tree.
836
- - _deps_ `unknown[]=`: If provided, this memoizes the mapSelect so the same `mapSelect` is invoked on every state change unless the dependencies change.
836
+ - _deps_ `unknown[]`: If provided, this memoizes the mapSelect so the same `mapSelect` is invoked on every state change unless the dependencies change.
837
837
 
838
838
  _Returns_
839
839
 
840
- - `UseSelectReturn<T>`: A custom react hook.
840
+ - `UseSelectReturn< T >`: The selected data or store selectors.
841
841
 
842
842
  ### useSuspenseSelect
843
843
 
@@ -846,11 +846,11 @@ A variant of the `useSelect` hook that has the same API, but is a compatible Sus
846
846
  _Parameters_
847
847
 
848
848
  - _mapSelect_ `T`: Function called on every state change. The returned value is exposed to the component using this hook. The function receives the `registry.suspendSelect` method as the first argument and the `registry` as the second one.
849
- - _deps_ `Array`: A dependency array used to memoize the `mapSelect` so that the same `mapSelect` is invoked on every state change unless the dependencies change.
849
+ - _deps_ `unknown[]`: A dependency array used to memoize the `mapSelect` so that the same `mapSelect` is invoked on every state change unless the dependencies change.
850
850
 
851
851
  _Returns_
852
852
 
853
- - `ReturnType<T>`: Data object returned by the `mapSelect` function.
853
+ - `ReturnType< T >`: Data object returned by the `mapSelect` function.
854
854
 
855
855
  ### withDispatch
856
856
 
@@ -934,24 +934,16 @@ conditions under which a different value would be returned.
934
934
 
935
935
  _Parameters_
936
936
 
937
- - _mapDispatchToProps_ `Function`: A function of returning an object of prop names where value is a dispatch-bound action creator, or a function to be called with the component's props and returning an action creator.
937
+ - _mapDispatchToProps_ `( dispatch: DataRegistry[ 'dispatch' ], ownProps: Record< string, unknown >, registry: DataRegistry ) => Record< string, ( , ...args: unknown[] ) => unknown >`: A function of returning an object of prop names where value is a dispatch-bound action creator, or a function to be called with the component's props and returning an action creator.
938
938
 
939
939
  _Returns_
940
940
 
941
- - `ComponentType`: Enhanced component with merged dispatcher props.
941
+ - Enhanced component with merged dispatcher props.
942
942
 
943
943
  ### withRegistry
944
944
 
945
945
  Higher-order component which renders the original component with the current registry context passed as its `registry` prop.
946
946
 
947
- _Parameters_
948
-
949
- - _OriginalComponent_ `Component`: Original component.
950
-
951
- _Returns_
952
-
953
- - `Component`: Enhanced component.
954
-
955
947
  ### withSelect
956
948
 
957
949
  Higher-order component used to inject state-derived props using registered selectors.
@@ -990,11 +982,11 @@ the store.
990
982
 
991
983
  _Parameters_
992
984
 
993
- - _mapSelectToProps_ `Function`: Function called on every state change, expected to return object of props to merge with the component's own props.
985
+ - _mapSelectToProps_ `( select: SelectFunction, ownProps: Record< string, unknown >, registry: DataRegistry ) => Record< string, unknown >`: Function called on every state change, expected to return object of props to merge with the component's own props.
994
986
 
995
987
  _Returns_
996
988
 
997
- - `ComponentType`: Enhanced component with merged state data props.
989
+ - Enhanced component with merged state data props.
998
990
 
999
991
  <!-- END TOKEN(Autogenerated API docs) -->
1000
992
 
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/data/src/components/async-mode-provider/context.js
20
+ // packages/data/src/components/async-mode-provider/context.ts
21
21
  var context_exports = {};
22
22
  __export(context_exports, {
23
23
  AsyncModeConsumer: () => AsyncModeConsumer,
@@ -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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAEvB,IAAM,cAAU,8BAAe,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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAEvB,IAAM,cAAU,8BAAe,KAAM;AAC5C,QAAQ,cAAc;AAEtB,IAAM,EAAE,UAAU,SAAS,IAAI;AAExB,IAAM,oBAAoB;AAoCjC,IAAO,kBAAQ;",
6
6
  "names": []
7
7
  }
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/data/src/components/async-mode-provider/index.js
30
+ // packages/data/src/components/async-mode-provider/index.ts
31
31
  var async_mode_provider_exports = {};
32
32
  __export(async_mode_provider_exports, {
33
33
  AsyncModeConsumer: () => import_context.AsyncModeConsumer,
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAwC;AACxC,qBAAgE;",
6
6
  "names": []
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/data/src/components/async-mode-provider/use-async-mode.js
20
+ // packages/data/src/components/async-mode-provider/use-async-mode.ts
21
21
  var use_async_mode_exports = {};
22
22
  __export(use_async_mode_exports, {
23
23
  default: () => 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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2B;AAK3B,qBAAwB;AAET,SAAR,eAAgC;AACtC,aAAO,2BAAY,sBAAQ;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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2B;AAK3B,qBAAwB;AAET,SAAR,eAAyC;AAC/C,aAAO,2BAAY,sBAAQ;AAC5B;",
6
6
  "names": []
7
7
  }
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/data/src/components/registry-provider/context.js
30
+ // packages/data/src/components/registry-provider/context.ts
31
31
  var context_exports = {};
32
32
  __export(context_exports, {
33
33
  Context: () => Context,
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAK9B,8BAA4B;AAErB,IAAM,cAAU,8BAAe,wBAAAA,OAAgB;AACtD,QAAQ,cAAc;AAEtB,IAAM,EAAE,UAAU,SAAS,IAAI;AAiCxB,IAAM,mBAAmB;AAShC,IAAO,kBAAQ;",
6
6
  "names": ["defaultRegistry"]
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/data/src/components/registry-provider/index.js
30
+ // packages/data/src/components/registry-provider/index.ts
31
31
  var registry_provider_exports = {};
32
32
  __export(registry_provider_exports, {
33
33
  RegistryConsumer: () => import_context.RegistryConsumer,
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8D;AAC9D,0BAAuC;",
6
6
  "names": []
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/data/src/components/registry-provider/use-registry.js
20
+ // packages/data/src/components/registry-provider/use-registry.ts
21
21
  var use_registry_exports = {};
22
22
  __export(use_registry_exports, {
23
23
  default: () => 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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2B;AAK3B,qBAAwB;AAyCT,SAAR,cAA+B;AACrC,aAAO,2BAAY,sBAAQ;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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2B;AAK3B,qBAAwB;AA0CT,SAAR,cAA6C;AACnD,aAAO,2BAAY,sBAAQ;AAC5B;",
6
6
  "names": []
7
7
  }
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/data/src/components/use-dispatch/index.js
30
+ // packages/data/src/components/use-dispatch/index.ts
31
31
  var use_dispatch_exports = {};
32
32
  __export(use_dispatch_exports, {
33
33
  useDispatch: () => import_use_dispatch.default,
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAuC;AACvC,mCAA8C;",
6
6
  "names": []
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/data/src/components/use-dispatch/use-dispatch-with-map.js
30
+ // packages/data/src/components/use-dispatch/use-dispatch-with-map.ts
31
31
  var use_dispatch_with_map_exports = {};
32
32
  __export(use_dispatch_with_map_exports, {
33
33
  default: () => use_dispatch_with_map_default
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAgC;AAChC,qBAA0C;AAK1C,0BAAwB;AAgBxB,IAAM,qBAAqB,CAAE,aAAa,SAAU;AACnD,QAAM,eAAW,oBAAAA,SAAY;AAC7B,QAAM,4BAAwB,uBAAQ,WAAY;AAElD,gDAA2B,MAAM;AAChC,0BAAsB,UAAU;AAAA,EACjC,CAAE;AAEF,aAAO,wBAAS,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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAgC;AAChC,qBAA0C;AAK1C,0BAAwB;AAsBxB,IAAM,qBAAqB,CAC1B,aACA,SACyD;AACzD,QAAM,eAAW,oBAAAA,SAAY;AAC7B,QAAM,4BAAwB,uBAAQ,WAAY;AAElD,gDAA2B,MAAM;AAChC,0BAAsB,UAAU;AAAA,EACjC,CAAE;AAEF,aAAO,wBAAS,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": ["useRegistry"]
7
7
  }
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/data/src/components/use-dispatch/use-dispatch.js
30
+ // packages/data/src/components/use-dispatch/use-dispatch.ts
31
31
  var use_dispatch_exports = {};
32
32
  __export(use_dispatch_exports, {
33
33
  default: () => use_dispatch_default
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAwB;AAyDxB,IAAM,cAAc,CAAE,0BAA2B;AAChD,QAAM,EAAE,SAAS,QAAI,oBAAAA,SAAY;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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAwB;AAqDxB,IAAM,cAAc,CAMnB,0BACgD;AAChD,QAAM,EAAE,SAAS,QAAI,oBAAAA,SAAY;AACjC,SACC,0BAA0B,SACvB,WACA,SAAU,qBAAsD;AAErE;AAEA,IAAO,uBAAQ;",
6
6
  "names": ["useRegistry"]
7
7
  }
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/data/src/components/use-select/index.js
30
+ // packages/data/src/components/use-select/index.ts
31
31
  var use_select_exports = {};
32
32
  __export(use_select_exports, {
33
33
  default: () => useSelect,
@@ -118,7 +118,7 @@ function Store(registry, suspense) {
118
118
  return (mapSelect, isAsync) => {
119
119
  function updateValue() {
120
120
  if (lastMapResultValid && mapSelect === lastMapSelect) {
121
- return lastMapResult;
121
+ return;
122
122
  }
123
123
  const listeningStores = { current: null };
124
124
  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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA4B;AAC5B,qBAMO;AACP,8BAA+B;AAK/B,0BAAwB;AACxB,4BAAyB;AAEzB,IAAM,kBAAc,mCAAY;AAEhC,SAAS,wBAAyB,GAAG,GAA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EA,aAAS,WAAW;AAEnB,kBAAY;AACZ,aAAO;AAAA,IACR;AAKA,QAAK,eAAe,CAAE,SAAU;AAC/B,2BAAqB;AACrB,kBAAY,OAAQ,YAAa;AAAA,IAClC;AAEA,gBAAY;AAEZ,kBAAc;AAGd,WAAO,EAAE,WAAW,WAAW,WAAW,SAAS;AAAA,EACpD;AACD;AAEA,SAAS,iBAAkB,WAAY;AACtC,aAAO,oBAAAA,SAAY,EAAE,OAAQ,SAAU;AACxC;AAEA,SAAS,kBAAmB,UAAU,WAAW,MAAO;AACvD,QAAM,eAAW,oBAAAA,SAAY;AAC7B,QAAM,cAAU,sBAAAC,SAAa;AAC7B,QAAM,YAAQ;AAAA,IACb,MAAM,MAAO,UAAU,QAAS;AAAA,IAChC,CAAE,UAAU,QAAS;AAAA,EACtB;AAIA,QAAM,eAAW,4BAAa,WAAW,IAAK;AAC9C,QAAM,EAAE,WAAW,SAAS,IAAI,MAAO,UAAU,OAAQ;AACzD,QAAM,aAAS,qCAAsB,WAAW,UAAU,QAAS;AACnE,oCAAe,MAAO;AACtB,SAAO;AACR;AAkEe,SAAR,UAA4B,WAAW,MAAO;AAGpD,QAAM,mBAAmB,OAAO,cAAc;AAC9C,QAAM,0BAAsB,uBAAQ,gBAAiB;AAErD,MAAK,qBAAqB,oBAAoB,SAAU;AACvD,UAAM,WAAW,oBAAoB,UAAU,WAAW;AAC1D,UAAM,WAAW,mBAAmB,WAAW;AAC/C,UAAM,IAAI;AAAA,MACT,4BAA6B,QAAS,OAAQ,QAAS;AAAA,IACxD;AAAA,EACD;AAIA,SAAO,mBACJ,iBAAkB,SAAU,IAC5B,kBAAmB,OAAO,WAAW,IAAK;AAC9C;AAqBO,SAAS,kBAAmB,WAAW,MAAO;AACpD,SAAO,kBAAmB,MAAM,WAAW,IAAK;AACjD;",
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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IAAM;AAE7D;AAoBO,SAAS,kBACf,WACA,MACkB;AAClB,SAAO,kBAAmB,MAAM,WAAW,IAAK;AACjD;",
6
6
  "names": ["useRegistry", "useAsyncMode"]
7
7
  }
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/data/src/components/with-dispatch/index.js
20
+ // packages/data/src/components/with-dispatch/index.tsx
21
21
  var with_dispatch_exports = {};
22
22
  __export(with_dispatch_exports, {
23
23
  default: () => with_dispatch_default
@@ -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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2C;AAK3C,0BAAmC;AA2FzB;AANV,IAAM,eAAe,CAAE,2BACtB;AAAA,EACC,CAAE,qBAAsB,CAAE,aAAc;AACvC,UAAM,cAAc,CAAE,UAAU,aAC/B,mBAAoB,UAAU,UAAU,QAAS;AAClD,UAAM,oBAAgB,wCAAoB,aAAa,CAAC,CAAE;AAC1D,WAAO,4CAAC,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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2C;AAK3C,0BAAmC;AAkGzB;AAdV,IAAM,eAAe,CACpB,2BAMA;AAAA,EACC,CAAE,qBAAsB,CAAE,aAAyC;AAClE,UAAM,cAAc,CACnB,UACA,aACI,mBAAoB,UAAU,UAAU,QAAS;AACtD,UAAM,oBAAgB,wCAAoB,aAAa,CAAC,CAAE;AAC1D,WAAO,4CAAC,oBAAmB,GAAG,UAAa,GAAG,eAAgB;AAAA,EAC/D;AAAA,EACA;AACD;AAED,IAAO,wBAAQ;",
6
6
  "names": []
7
7
  }
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/data/src/components/with-registry/index.js
20
+ // packages/data/src/components/with-registry/index.tsx
21
21
  var with_registry_exports = {};
22
22
  __export(with_registry_exports, {
23
23
  default: () => with_registry_default
@@ -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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2C;AAK3C,+BAAiC;AAc7B;AAJJ,IAAM,mBAAe;AAAA,EACpB,CAAE,sBAAuB,CAAE,UAC1B,4CAAC,6CACE,WAAE,aACH,4CAAC,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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2C;AAK3C,+BAAiC;AAU7B;AAJJ,IAAM,mBAAe;AAAA,EACpB,CAAE,sBAAuB,CAAE,UAC1B,4CAAC,6CACE,WAAE,aACH,4CAAC,qBAAoB,GAAG,OAAQ,UAAsB,GAExD;AAAA,EAED;AACD;AAEA,IAAO,wBAAQ;",
6
6
  "names": []
7
7
  }
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/data/src/components/with-select/index.js
30
+ // packages/data/src/components/with-select/index.tsx
31
31
  var with_select_exports = {};
32
32
  __export(with_select_exports, {
33
33
  default: () => with_select_default
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAiD;AAKjD,wBAAsB;AAmDX;AAPX,IAAM,aAAa,CAAE,yBACpB;AAAA,EACC,CAAE,yBACD,qBAAM,CAAE,aAAc;AACrB,UAAM,YAAY,CAAE,QAAQ,aAC3B,iBAAkB,QAAQ,UAAU,QAAS;AAC9C,UAAM,iBAAa,kBAAAA,SAAW,SAAU;AACxC,WAAO,4CAAC,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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAiD;AAKjD,wBAAsB;AA0DX;AAfX,IAAM,aAAa,CAClB,yBAMA;AAAA,EACC,CAAE,yBACD,qBAAM,CAAE,aAAyC;AAChD,UAAM,YAAY,CACjB,QACA,aACI,iBAAkB,QAAQ,UAAU,QAAS;AAClD,UAAM,iBAAa,kBAAAA,SAAW,SAAU;AACxC,WAAO,4CAAC,oBAAmB,GAAG,UAAa,GAAG,YAAa;AAAA,EAC5D,CAAE;AAAA,EACH;AACD;AAED,IAAO,sBAAQ;",
6
6
  "names": ["useSelect"]
7
7
  }