@wordpress/data 9.9.0 → 9.10.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 (150) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/async-mode-provider/context.js +2 -3
  3. package/build/components/async-mode-provider/context.js.map +1 -1
  4. package/build/components/async-mode-provider/index.js +0 -5
  5. package/build/components/async-mode-provider/index.js.map +1 -1
  6. package/build/components/async-mode-provider/use-async-mode.js +1 -3
  7. package/build/components/async-mode-provider/use-async-mode.js.map +1 -1
  8. package/build/components/registry-provider/context.js +3 -6
  9. package/build/components/registry-provider/context.js.map +1 -1
  10. package/build/components/registry-provider/index.js +0 -5
  11. package/build/components/registry-provider/index.js.map +1 -1
  12. package/build/components/registry-provider/use-registry.js +0 -3
  13. package/build/components/registry-provider/use-registry.js.map +1 -1
  14. package/build/components/use-dispatch/index.js +0 -3
  15. package/build/components/use-dispatch/index.js.map +1 -1
  16. package/build/components/use-dispatch/use-dispatch-with-map.js +0 -7
  17. package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  18. package/build/components/use-dispatch/use-dispatch.js +0 -5
  19. package/build/components/use-dispatch/use-dispatch.js.map +1 -1
  20. package/build/components/use-select/index.js +35 -53
  21. package/build/components/use-select/index.js.map +1 -1
  22. package/build/components/with-dispatch/index.js +2 -7
  23. package/build/components/with-dispatch/index.js.map +1 -1
  24. package/build/components/with-registry/index.js +2 -5
  25. package/build/components/with-registry/index.js.map +1 -1
  26. package/build/components/with-select/index.js +2 -8
  27. package/build/components/with-select/index.js.map +1 -1
  28. package/build/controls.js +4 -10
  29. package/build/controls.js.map +1 -1
  30. package/build/default-registry.js +0 -3
  31. package/build/default-registry.js.map +1 -1
  32. package/build/dispatch.js +0 -3
  33. package/build/dispatch.js.map +1 -1
  34. package/build/factory.js +2 -5
  35. package/build/factory.js.map +1 -1
  36. package/build/index.js +7 -28
  37. package/build/index.js.map +1 -1
  38. package/build/lock-unlock.js +1 -2
  39. package/build/lock-unlock.js.map +1 -1
  40. package/build/plugins/index.js +0 -2
  41. package/build/plugins/index.js.map +1 -1
  42. package/build/plugins/persistence/index.js +13 -37
  43. package/build/plugins/persistence/index.js.map +1 -1
  44. package/build/plugins/persistence/storage/default.js +1 -5
  45. package/build/plugins/persistence/storage/default.js.map +1 -1
  46. package/build/plugins/persistence/storage/object.js +0 -5
  47. package/build/plugins/persistence/storage/object.js.map +1 -1
  48. package/build/promise-middleware.js +0 -5
  49. package/build/promise-middleware.js.map +1 -1
  50. package/build/redux-store/index.js +36 -117
  51. package/build/redux-store/index.js.map +1 -1
  52. package/build/redux-store/metadata/actions.js +8 -17
  53. package/build/redux-store/metadata/actions.js.map +1 -1
  54. package/build/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
  55. package/build/redux-store/metadata/reducer.js +1 -23
  56. package/build/redux-store/metadata/reducer.js.map +1 -1
  57. package/build/redux-store/metadata/selectors.js +8 -22
  58. package/build/redux-store/metadata/selectors.js.map +1 -1
  59. package/build/redux-store/metadata/utils.js +6 -14
  60. package/build/redux-store/metadata/utils.js.map +1 -1
  61. package/build/redux-store/thunk-middleware.js +0 -2
  62. package/build/redux-store/thunk-middleware.js.map +1 -1
  63. package/build/registry.js +29 -73
  64. package/build/registry.js.map +1 -1
  65. package/build/resolvers-cache-middleware.js +2 -8
  66. package/build/resolvers-cache-middleware.js.map +1 -1
  67. package/build/select.js +0 -3
  68. package/build/select.js.map +1 -1
  69. package/build/store/index.js +0 -7
  70. package/build/store/index.js.map +1 -1
  71. package/build/types.js.map +1 -1
  72. package/build/utils/emitter.js +2 -11
  73. package/build/utils/emitter.js.map +1 -1
  74. package/build-module/components/async-mode-provider/context.js +1 -1
  75. package/build-module/components/async-mode-provider/context.js.map +1 -1
  76. package/build-module/components/async-mode-provider/index.js.map +1 -1
  77. package/build-module/components/async-mode-provider/use-async-mode.js +1 -1
  78. package/build-module/components/async-mode-provider/use-async-mode.js.map +1 -1
  79. package/build-module/components/registry-provider/context.js +3 -3
  80. package/build-module/components/registry-provider/context.js.map +1 -1
  81. package/build-module/components/registry-provider/index.js.map +1 -1
  82. package/build-module/components/registry-provider/use-registry.js +2 -2
  83. package/build-module/components/registry-provider/use-registry.js.map +1 -1
  84. package/build-module/components/use-dispatch/index.js.map +1 -1
  85. package/build-module/components/use-dispatch/use-dispatch-with-map.js +2 -4
  86. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  87. package/build-module/components/use-dispatch/use-dispatch.js +1 -3
  88. package/build-module/components/use-dispatch/use-dispatch.js.map +1 -1
  89. package/build-module/components/use-select/index.js +35 -46
  90. package/build-module/components/use-select/index.js.map +1 -1
  91. package/build-module/components/with-dispatch/index.js +4 -6
  92. package/build-module/components/with-dispatch/index.js.map +1 -1
  93. package/build-module/components/with-registry/index.js +4 -4
  94. package/build-module/components/with-registry/index.js.map +1 -1
  95. package/build-module/components/with-select/index.js +4 -6
  96. package/build-module/components/with-select/index.js.map +1 -1
  97. package/build-module/controls.js +4 -8
  98. package/build-module/controls.js.map +1 -1
  99. package/build-module/default-registry.js.map +1 -1
  100. package/build-module/dispatch.js +2 -1
  101. package/build-module/dispatch.js.map +1 -1
  102. package/build-module/factory.js +2 -3
  103. package/build-module/factory.js.map +1 -1
  104. package/build-module/index.js +11 -10
  105. package/build-module/index.js.map +1 -1
  106. package/build-module/lock-unlock.js.map +1 -1
  107. package/build-module/plugins/index.js.map +1 -1
  108. package/build-module/plugins/persistence/index.js +15 -30
  109. package/build-module/plugins/persistence/index.js.map +1 -1
  110. package/build-module/plugins/persistence/storage/default.js +0 -2
  111. package/build-module/plugins/persistence/storage/default.js.map +1 -1
  112. package/build-module/plugins/persistence/storage/object.js +0 -5
  113. package/build-module/plugins/persistence/storage/object.js.map +1 -1
  114. package/build-module/promise-middleware.js +1 -3
  115. package/build-module/promise-middleware.js.map +1 -1
  116. package/build-module/redux-store/index.js +38 -101
  117. package/build-module/redux-store/index.js.map +1 -1
  118. package/build-module/redux-store/metadata/actions.js +8 -8
  119. package/build-module/redux-store/metadata/actions.js.map +1 -1
  120. package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
  121. package/build-module/redux-store/metadata/reducer.js +1 -21
  122. package/build-module/redux-store/metadata/reducer.js.map +1 -1
  123. package/build-module/redux-store/metadata/selectors.js +9 -13
  124. package/build-module/redux-store/metadata/selectors.js.map +1 -1
  125. package/build-module/redux-store/metadata/utils.js +6 -11
  126. package/build-module/redux-store/metadata/utils.js.map +1 -1
  127. package/build-module/redux-store/thunk-middleware.js +0 -1
  128. package/build-module/redux-store/thunk-middleware.js.map +1 -1
  129. package/build-module/registry.js +30 -67
  130. package/build-module/registry.js.map +1 -1
  131. package/build-module/resolvers-cache-middleware.js +3 -6
  132. package/build-module/resolvers-cache-middleware.js.map +1 -1
  133. package/build-module/select.js +2 -1
  134. package/build-module/select.js.map +1 -1
  135. package/build-module/store/index.js +0 -7
  136. package/build-module/store/index.js.map +1 -1
  137. package/build-module/types.js.map +1 -1
  138. package/build-module/utils/emitter.js +2 -10
  139. package/build-module/utils/emitter.js.map +1 -1
  140. package/build-types/components/use-select/index.d.ts.map +1 -1
  141. package/build-types/index.d.ts +1 -1
  142. package/build-types/index.d.ts.map +1 -1
  143. package/build-types/plugins/persistence/index.d.ts.map +1 -1
  144. package/build-types/private-apis.d.ts +3 -0
  145. package/build-types/private-apis.d.ts.map +1 -0
  146. package/build-types/store/index.d.ts +1 -1
  147. package/package.json +9 -9
  148. package/src/components/use-select/index.js +14 -0
  149. package/src/plugins/persistence/index.js +0 -1
  150. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/components/use-select/index.js"],"names":["renderQueue","Store","registry","suspense","select","suspendSelect","queueContext","lastMapSelect","lastMapResult","lastMapResultValid","lastIsAsync","subscriber","createSubscriber","stores","activeStores","activeSubscriptions","Set","subscribe","listener","onStoreChange","onChange","add","unsubs","subscribeStore","storeName","push","delete","unsub","values","cancel","updateStores","newStores","newStore","includes","subscription","mapSelect","isAsync","updateValue","listeningStores","current","mapResult","__unstableMarkListeningStores","getValue","useStaticSelect","useMappingSelect","deps","store","selector","result","useSelect","staticSelectMode","staticSelectModeRef","prevMode","nextMode","Error","useSuspenseSelect"],"mappings":";;;;;;;;;;AAGA;;AACA;;AAOA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAWA;AACA;AACA;AAIA,MAAMA,WAAW,GAAG,iCAApB;AAEA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;;AACA;AACA;AACA;AACA;;AAEA,SAASC,KAAT,CAAgBC,QAAhB,EAA0BC,QAA1B,EAAqC;AACpC,QAAMC,MAAM,GAAGD,QAAQ,GAAGD,QAAQ,CAACG,aAAZ,GAA4BH,QAAQ,CAACE,MAA5D;AACA,QAAME,YAAY,GAAG,EAArB;AACA,MAAIC,aAAJ;AACA,MAAIC,aAAJ;AACA,MAAIC,kBAAkB,GAAG,KAAzB;AACA,MAAIC,WAAJ;AACA,MAAIC,UAAJ;;AAEA,QAAMC,gBAAgB,GAAKC,MAAF,IAAc;AACtC;AACA;AACA,UAAMC,YAAY,GAAG,CAAE,GAAGD,MAAL,CAArB,CAHsC,CAKtC;AACA;AACA;;AACA,UAAME,mBAAmB,GAAG,IAAIC,GAAJ,EAA5B;;AAEA,aAASC,SAAT,CAAoBC,QAApB,EAA+B;AAC9B;AACA;AACA;AACA;AACA;AACAT,MAAAA,kBAAkB,GAAG,KAArB;;AAEA,YAAMU,aAAa,GAAG,MAAM;AAC3B;AACAV,QAAAA,kBAAkB,GAAG,KAArB;AACAS,QAAAA,QAAQ;AACR,OAJD;;AAMA,YAAME,QAAQ,GAAG,MAAM;AACtB,YAAKV,WAAL,EAAmB;AAClBV,UAAAA,WAAW,CAACqB,GAAZ,CAAiBf,YAAjB,EAA+Ba,aAA/B;AACA,SAFD,MAEO;AACNA,UAAAA,aAAa;AACb;AACD,OAND;;AAQA,YAAMG,MAA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CAFnB;AAGA;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASU,iBAAT,CAA4BpB,SAA5B,EAAuCU,IAAvC,EAA8C;AACpD,SAAOD,gBAAgB,CAAE,IAAF,EAAQT,SAAR,EAAmBU,IAAnB,CAAvB;AACA","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\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\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// Invalidate the value right after subscription was created. React will\n\t\t\t// call `getValue` after subscribing, to detect store updates that happened\n\t\t\t// in the interval between the `getValue` call during render and creating\n\t\t\t// the subscription, which is slightly delayed. We need to ensure that this\n\t\t\t// second `getValue` call will compute a fresh value.\n\t\t\tlastMapResultValid = false;\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 ( ! subscriber ) {\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( () => Store( registry, suspense ), [ registry ] );\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://reactjs.org/docs/hooks-rules.html).\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/* eslint-disable react-hooks/rules-of-hooks */\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\t/* eslint-enable react-hooks/rules-of-hooks */\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but will throw a\n * suspense Promise if any of the called selectors is in an unresolved state.\n *\n * @param {Function} 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 * @return {Object} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\treturn useMappingSelect( true, mapSelect, deps );\n}\n"]}
1
+ {"version":3,"names":["_priorityQueue","require","_element","_isShallowEqual","_interopRequireDefault","_useRegistry","_useAsyncMode","renderQueue","createQueue","Store","registry","suspense","select","suspendSelect","queueContext","lastMapSelect","lastMapResult","lastMapResultValid","lastIsAsync","subscriber","didWarnUnstableReference","createSubscriber","stores","activeStores","activeSubscriptions","Set","subscribe","listener","onStoreChange","onChange","add","unsubs","subscribeStore","storeName","push","delete","unsub","values","cancel","updateStores","newStores","newStore","includes","subscription","mapSelect","isAsync","updateValue","listeningStores","current","mapResult","__unstableMarkListeningStores","process","env","NODE_ENV","secondMapResult","isShallowEqual","console","warn","getValue","useStaticSelect","useRegistry","useMappingSelect","deps","useAsyncMode","store","useMemo","selector","useCallback","result","useSyncExternalStore","useDebugValue","useSelect","staticSelectMode","staticSelectModeRef","useRef","prevMode","nextMode","Error","useSuspenseSelect"],"sources":["@wordpress/data/src/components/use-select/index.js"],"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\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\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// Invalidate the value right after subscription was created. React will\n\t\t\t// call `getValue` after subscribing, to detect store updates that happened\n\t\t\t// in the interval between the `getValue` call during render and creating\n\t\t\t// the subscription, which is slightly delayed. We need to ensure that this\n\t\t\t// second `getValue` call will compute a fresh value.\n\t\t\tlastMapResultValid = false;\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 ( process.env.NODE_ENV === 'development' ) {\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\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`The 'useSelect' hook returns different values when called with the same state and parameters. This can lead to unnecessary rerenders.`\n\t\t\t\t\t\t);\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\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( () => Store( registry, suspense ), [ registry ] );\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://reactjs.org/docs/hooks-rules.html).\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/* eslint-disable react-hooks/rules-of-hooks */\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\t/* eslint-enable react-hooks/rules-of-hooks */\n}\n\n/**\n * A variant of the `useSelect` hook that has the same API, but will throw a\n * suspense Promise if any of the called selectors is in an unresolved state.\n *\n * @param {Function} 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 * @return {Object} Data object returned by the `mapSelect` function.\n */\nexport function useSuspenseSelect( mapSelect, deps ) {\n\treturn useMappingSelect( true, mapSelect, deps );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,eAAA,GAAAC,sBAAA,CAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,aAAA,GAAAF,sBAAA,CAAAH,OAAA;AAjBA;AACA;AACA;;AAWA;AACA;AACA;;AAIA,MAAMM,WAAW,GAAG,IAAAC,0BAAW,EAAC,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASC,KAAKA,CAAEC,QAAQ,EAAEC,QAAQ,EAAG;EACpC,MAAMC,MAAM,GAAGD,QAAQ,GAAGD,QAAQ,CAACG,aAAa,GAAGH,QAAQ,CAACE,MAAM;EAClE,MAAME,YAAY,GAAG,CAAC,CAAC;EACvB,IAAIC,aAAa;EACjB,IAAIC,aAAa;EACjB,IAAIC,kBAAkB,GAAG,KAAK;EAC9B,IAAIC,WAAW;EACf,I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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,SAASA,CAAE3B,SAAS,EAAEkB,IAAI,EAAG;EACpD;EACA;EACA,MAAMU,gBAAgB,GAAG,OAAO5B,SAAS,KAAK,UAAU;EACxD,MAAM6B,mBAAmB,GAAG,IAAAC,eAAM,EAAEF,gBAAiB,CAAC;EAEtD,IAAKA,gBAAgB,KAAKC,mBAAmB,CAACzB,OAAO,EAAG;IACvD,MAAM2B,QAAQ,GAAGF,mBAAmB,CAACzB,OAAO,GAAG,QAAQ,GAAG,SAAS;IACnE,MAAM4B,QAAQ,GAAGJ,gBAAgB,GAAG,QAAQ,GAAG,SAAS;IACxD,MAAM,IAAIK,KAAK,CACb,4BAA4BF,QAAU,OAAOC,QAAU,iBACzD,CAAC;EACF;;EAEA;EACA;EACA;EACA,OAAOJ,gBAAgB,GACpBb,eAAe,CAAEf,SAAU,CAAC,GAC5BiB,gBAAgB,CAAE,KAAK,EAAEjB,SAAS,EAAEkB,IAAK,CAAC;EAC7C;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASgB,iBAAiBA,CAAElC,SAAS,EAAEkB,IAAI,EAAG;EACpD,OAAOD,gBAAgB,CAAE,IAAI,EAAEjB,SAAS,EAAEkB,IAAK,CAAC;AACjD"}
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _element = require("@wordpress/element");
9
-
10
8
  var _compose = require("@wordpress/compose");
11
-
12
9
  var _useDispatch = require("../use-dispatch");
13
-
14
10
  /**
15
11
  * WordPress dependencies
16
12
  */
@@ -104,13 +100,12 @@ var _useDispatch = require("../use-dispatch");
104
100
  */
105
101
  const withDispatch = mapDispatchToProps => (0, _compose.createHigherOrderComponent)(WrappedComponent => ownProps => {
106
102
  const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry);
107
-
108
103
  const dispatchProps = (0, _useDispatch.useDispatchWithMap)(mapDispatch, []);
109
- return (0, _element.createElement)(WrappedComponent, { ...ownProps,
104
+ return (0, _element.createElement)(WrappedComponent, {
105
+ ...ownProps,
110
106
  ...dispatchProps
111
107
  });
112
108
  }, 'withDispatch');
113
-
114
109
  var _default = withDispatch;
115
110
  exports.default = _default;
116
111
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/components/with-dispatch/index.js"],"names":["withDispatch","mapDispatchToProps","WrappedComponent","ownProps","mapDispatch","dispatch","registry","dispatchProps"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAKC,kBAAF,IACpB,yCACGC,gBAAF,IAA0BC,QAAF,IAAgB;AACvC,QAAMC,WAAW,GAAG,CAAEC,QAAF,EAAYC,QAAZ,KACnBL,kBAAkB,CAAEI,QAAF,EAAYF,QAAZ,EAAsBG,QAAtB,CADnB;;AAEA,QAAMC,aAAa,GAAG,qCAAoBH,WAApB,EAAiC,EAAjC,CAAtB;AACA,SAAO,4BAAC,gBAAD,OAAuBD,QAAvB;AAAA,OAAuCI;AAAvC,IAAP;AACA,CANF,EAOC,cAPD,CADD;;eAWeP,Y","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useDispatchWithMap } from '../use-dispatch';\n\n/** @typedef {import('@wordpress/element').WPComponent} WPComponent */\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 {WPComponent} 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"]}
1
+ {"version":3,"names":["_compose","require","_useDispatch","withDispatch","mapDispatchToProps","createHigherOrderComponent","WrappedComponent","ownProps","mapDispatch","dispatch","registry","dispatchProps","useDispatchWithMap","_element","createElement","_default","exports","default"],"sources":["@wordpress/data/src/components/with-dispatch/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useDispatchWithMap } from '../use-dispatch';\n\n/** @typedef {import('@wordpress/element').WPComponent} WPComponent */\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 {WPComponent} 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"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,YAAY,GAAKC,kBAAkB,IACxC,IAAAC,mCAA0B,EACvBC,gBAAgB,IAAQC,QAAQ,IAAM;EACvC,MAAMC,WAAW,GAAGA,CAAEC,QAAQ,EAAEC,QAAQ,KACvCN,kBAAkB,CAAEK,QAAQ,EAAEF,QAAQ,EAAEG,QAAS,CAAC;EACnD,MAAMC,aAAa,GAAG,IAAAC,+BAAkB,EAAEJ,WAAW,EAAE,EAAG,CAAC;EAC3D,OAAO,IAAAK,QAAA,CAAAC,aAAA,EAACR,gBAAgB;IAAA,GAAMC,QAAQ;IAAA,GAAQI;EAAa,CAAI,CAAC;AACjE,CAAC,EACD,cACD,CAAC;AAAC,IAAAI,QAAA,GAEYZ,YAAY;AAAAa,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _element = require("@wordpress/element");
9
-
10
8
  var _compose = require("@wordpress/compose");
11
-
12
9
  var _registryProvider = require("../registry-provider");
13
-
14
10
  /**
15
11
  * WordPress dependencies
16
12
  */
@@ -27,7 +23,8 @@ var _registryProvider = require("../registry-provider");
27
23
  *
28
24
  * @return {WPComponent} Enhanced component.
29
25
  */
30
- const withRegistry = (0, _compose.createHigherOrderComponent)(OriginalComponent => props => (0, _element.createElement)(_registryProvider.RegistryConsumer, null, registry => (0, _element.createElement)(OriginalComponent, { ...props,
26
+ const withRegistry = (0, _compose.createHigherOrderComponent)(OriginalComponent => props => (0, _element.createElement)(_registryProvider.RegistryConsumer, null, registry => (0, _element.createElement)(OriginalComponent, {
27
+ ...props,
31
28
  registry: registry
32
29
  })), 'withRegistry');
33
30
  var _default = withRegistry;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/components/with-registry/index.js"],"names":["withRegistry","OriginalComponent","props","registry"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,yCAClBC,iBAAF,IAA2BC,KAAF,IAEvB,4BAAC,kCAAD,QACKC,QAAF,IACD,4BAAC,iBAAD,OAAwBD,KAAxB;AAAgC,EAAA,QAAQ,EAAGC;AAA3C,EAFF,CAHkB,EASpB,cAToB,CAArB;eAYeH,Y","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 {WPComponent} OriginalComponent Original component.\n *\n * @return {WPComponent} Enhanced component.\n */\nconst withRegistry = createHigherOrderComponent(\n\t( OriginalComponent ) => ( props ) =>\n\t\t(\n\t\t\t<RegistryConsumer>\n\t\t\t\t{ ( registry ) => (\n\t\t\t\t\t<OriginalComponent { ...props } registry={ registry } />\n\t\t\t\t) }\n\t\t\t</RegistryConsumer>\n\t\t),\n\t'withRegistry'\n);\n\nexport default withRegistry;\n"]}
1
+ {"version":3,"names":["_compose","require","_registryProvider","withRegistry","createHigherOrderComponent","OriginalComponent","props","_element","createElement","RegistryConsumer","registry","_default","exports","default"],"sources":["@wordpress/data/src/components/with-registry/index.js"],"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 {WPComponent} OriginalComponent Original component.\n *\n * @return {WPComponent} Enhanced component.\n */\nconst withRegistry = createHigherOrderComponent(\n\t( OriginalComponent ) => ( props ) =>\n\t\t(\n\t\t\t<RegistryConsumer>\n\t\t\t\t{ ( registry ) => (\n\t\t\t\t\t<OriginalComponent { ...props } registry={ registry } />\n\t\t\t\t) }\n\t\t\t</RegistryConsumer>\n\t\t),\n\t'withRegistry'\n);\n\nexport default withRegistry;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,YAAY,GAAG,IAAAC,mCAA0B,EAC5CC,iBAAiB,IAAQC,KAAK,IAE9B,IAAAC,QAAA,CAAAC,aAAA,EAACN,iBAAA,CAAAO,gBAAgB,QACZC,QAAQ,IACX,IAAAH,QAAA,CAAAC,aAAA,EAACH,iBAAiB;EAAA,GAAMC,KAAK;EAAGI,QAAQ,EAAGA;AAAU,CAAE,CAEvC,CAClB,EACF,cACD,CAAC;AAAC,IAAAC,QAAA,GAEaR,YAAY;AAAAS,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _element = require("@wordpress/element");
11
-
12
9
  var _compose = require("@wordpress/compose");
13
-
14
10
  var _useSelect = _interopRequireDefault(require("../use-select"));
15
-
16
11
  /**
17
12
  * WordPress dependencies
18
13
  */
@@ -65,13 +60,12 @@ var _useSelect = _interopRequireDefault(require("../use-select"));
65
60
  */
66
61
  const withSelect = mapSelectToProps => (0, _compose.createHigherOrderComponent)(WrappedComponent => (0, _compose.pure)(ownProps => {
67
62
  const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry);
68
-
69
63
  const mergeProps = (0, _useSelect.default)(mapSelect);
70
- return (0, _element.createElement)(WrappedComponent, { ...ownProps,
64
+ return (0, _element.createElement)(WrappedComponent, {
65
+ ...ownProps,
71
66
  ...mergeProps
72
67
  });
73
68
  }), 'withSelect');
74
-
75
69
  var _default = withSelect;
76
70
  exports.default = _default;
77
71
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/components/with-select/index.js"],"names":["withSelect","mapSelectToProps","WrappedComponent","ownProps","mapSelect","select","registry","mergeProps"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,UAAU,GAAKC,gBAAF,IAClB,yCACGC,gBAAF,IACC,mBAAQC,QAAF,IAAgB;AACrB,QAAMC,SAAS,GAAG,CAAEC,MAAF,EAAUC,QAAV,KACjBL,gBAAgB,CAAEI,MAAF,EAAUF,QAAV,EAAoBG,QAApB,CADjB;;AAEA,QAAMC,UAAU,GAAG,wBAAWH,SAAX,CAAnB;AACA,SAAO,4BAAC,gBAAD,OAAuBD,QAAvB;AAAA,OAAuCI;AAAvC,IAAP;AACA,CALD,CAFF,EAQC,YARD,CADD;;eAYeP,U","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 {import('@wordpress/element').WPComponent} WPComponent */\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 {WPComponent} 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"]}
1
+ {"version":3,"names":["_compose","require","_useSelect","_interopRequireDefault","withSelect","mapSelectToProps","createHigherOrderComponent","WrappedComponent","pure","ownProps","mapSelect","select","registry","mergeProps","useSelect","_element","createElement","_default","exports","default"],"sources":["@wordpress/data/src/components/with-select/index.js"],"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 {import('@wordpress/element').WPComponent} WPComponent */\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 {WPComponent} 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"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,UAAU,GAAKC,gBAAgB,IACpC,IAAAC,mCAA0B,EACvBC,gBAAgB,IACjB,IAAAC,aAAI,EAAIC,QAAQ,IAAM;EACrB,MAAMC,SAAS,GAAGA,CAAEC,MAAM,EAAEC,QAAQ,KACnCP,gBAAgB,CAAEM,MAAM,EAAEF,QAAQ,EAAEG,QAAS,CAAC;EAC/C,MAAMC,UAAU,GAAG,IAAAC,kBAAS,EAAEJ,SAAU,CAAC;EACzC,OAAO,IAAAK,QAAA,CAAAC,aAAA,EAACT,gBAAgB;IAAA,GAAME,QAAQ;IAAA,GAAQI;EAAU,CAAI,CAAC;AAC9D,CAAE,CAAC,EACJ,YACD,CAAC;AAAC,IAAAI,QAAA,GAEYb,UAAU;AAAAc,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
package/build/controls.js CHANGED
@@ -4,21 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.controls = exports.builtinControls = void 0;
7
-
8
7
  var _factory = require("./factory");
9
-
10
8
  /**
11
9
  * Internal dependencies
12
10
  */
13
11
 
14
12
  /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
13
+
15
14
  const SELECT = '@@data/SELECT';
16
15
  const RESOLVE_SELECT = '@@data/RESOLVE_SELECT';
17
16
  const DISPATCH = '@@data/DISPATCH';
18
-
19
17
  function isObject(object) {
20
18
  return object !== null && typeof object === 'object';
21
19
  }
20
+
22
21
  /**
23
22
  * Dispatches a control action for triggering a synchronous registry select.
24
23
  *
@@ -42,8 +41,6 @@ function isObject(object) {
42
41
  *
43
42
  * @return {Object} The control descriptor.
44
43
  */
45
-
46
-
47
44
  function select(storeNameOrDescriptor, selectorName, ...args) {
48
45
  return {
49
46
  type: SELECT,
@@ -52,6 +49,7 @@ function select(storeNameOrDescriptor, selectorName, ...args) {
52
49
  args
53
50
  };
54
51
  }
52
+
55
53
  /**
56
54
  * Dispatches a control action for triggering and resolving a registry select.
57
55
  *
@@ -76,8 +74,6 @@ function select(storeNameOrDescriptor, selectorName, ...args) {
76
74
  *
77
75
  * @return {Object} The control descriptor.
78
76
  */
79
-
80
-
81
77
  function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
82
78
  return {
83
79
  type: RESOLVE_SELECT,
@@ -86,6 +82,7 @@ function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
86
82
  args
87
83
  };
88
84
  }
85
+
89
86
  /**
90
87
  * Dispatches a control action for triggering a registry dispatch.
91
88
  *
@@ -106,8 +103,6 @@ function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
106
103
  *
107
104
  * @return {Object} The control descriptor.
108
105
  */
109
-
110
-
111
106
  function dispatch(storeNameOrDescriptor, actionName, ...args) {
112
107
  return {
113
108
  type: DISPATCH,
@@ -116,7 +111,6 @@ function dispatch(storeNameOrDescriptor, actionName, ...args) {
116
111
  args
117
112
  };
118
113
  }
119
-
120
114
  const controls = {
121
115
  select,
122
116
  resolveSelect,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/controls.js"],"names":["SELECT","RESOLVE_SELECT","DISPATCH","isObject","object","select","storeNameOrDescriptor","selectorName","args","type","storeKey","name","resolveSelect","dispatch","actionName","controls","builtinControls","registry","method","hasResolver"],"mappings":"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","sourcesContent":["/**\n * Internal dependencies\n */\nimport { createRegistryControl } from './factory';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nconst SELECT = '@@data/SELECT';\nconst RESOLVE_SELECT = '@@data/RESOLVE_SELECT';\nconst DISPATCH = '@@data/DISPATCH';\n\nfunction isObject( object ) {\n\treturn object !== null && typeof object === 'object';\n}\n\n/**\n * Dispatches a control action for triggering a synchronous registry select.\n *\n * Note: This control synchronously returns the current selector value, triggering the\n * resolution, but not waiting for it.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector.\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using `select`.\n * export function* myAction() {\n * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );\n * // Do stuff with the result from the `select`.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction select( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering and resolving a registry select.\n *\n * Note: when this control action is handled, it automatically considers\n * selectors that may have a resolver. In such case, it will return a `Promise` that resolves\n * after the selector finishes resolving, with the final result value.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using resolveSelect\n * export function* myAction() {\n * \tconst isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );\n * \t// do stuff with the result from the select.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction resolveSelect( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: RESOLVE_SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering a registry dispatch.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} actionName The name of the action to dispatch\n * @param {Array} args Arguments for the dispatch action.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data-controls';\n *\n * // Action generator using dispatch\n * export function* myAction() {\n * yield controls.dispatch( 'core/edit-post', 'togglePublishSidebar' );\n * // do some other things.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction dispatch( storeNameOrDescriptor, actionName, ...args ) {\n\treturn {\n\t\ttype: DISPATCH,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tactionName,\n\t\targs,\n\t};\n}\n\nexport const controls = { select, resolveSelect, dispatch };\n\nexport const builtinControls = {\n\t[ SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) =>\n\t\t\t\tregistry.select( storeKey )[ selectorName ]( ...args )\n\t),\n\t[ RESOLVE_SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) => {\n\t\t\t\tconst method = registry.select( storeKey )[ selectorName ]\n\t\t\t\t\t.hasResolver\n\t\t\t\t\t? 'resolveSelect'\n\t\t\t\t\t: 'select';\n\t\t\t\treturn registry[ method ]( storeKey )[ selectorName ](\n\t\t\t\t\t...args\n\t\t\t\t);\n\t\t\t}\n\t),\n\t[ DISPATCH ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, actionName, args } ) =>\n\t\t\t\tregistry.dispatch( storeKey )[ actionName ]( ...args )\n\t),\n};\n"]}
1
+ {"version":3,"names":["_factory","require","SELECT","RESOLVE_SELECT","DISPATCH","isObject","object","select","storeNameOrDescriptor","selectorName","args","type","storeKey","name","resolveSelect","dispatch","actionName","controls","exports","builtinControls","createRegistryControl","registry","method","hasResolver"],"sources":["@wordpress/data/src/controls.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createRegistryControl } from './factory';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nconst SELECT = '@@data/SELECT';\nconst RESOLVE_SELECT = '@@data/RESOLVE_SELECT';\nconst DISPATCH = '@@data/DISPATCH';\n\nfunction isObject( object ) {\n\treturn object !== null && typeof object === 'object';\n}\n\n/**\n * Dispatches a control action for triggering a synchronous registry select.\n *\n * Note: This control synchronously returns the current selector value, triggering the\n * resolution, but not waiting for it.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector.\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using `select`.\n * export function* myAction() {\n * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );\n * // Do stuff with the result from the `select`.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction select( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering and resolving a registry select.\n *\n * Note: when this control action is handled, it automatically considers\n * selectors that may have a resolver. In such case, it will return a `Promise` that resolves\n * after the selector finishes resolving, with the final result value.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using resolveSelect\n * export function* myAction() {\n * \tconst isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );\n * \t// do stuff with the result from the select.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction resolveSelect( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: RESOLVE_SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering a registry dispatch.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} actionName The name of the action to dispatch\n * @param {Array} args Arguments for the dispatch action.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data-controls';\n *\n * // Action generator using dispatch\n * export function* myAction() {\n * yield controls.dispatch( 'core/edit-post', 'togglePublishSidebar' );\n * // do some other things.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction dispatch( storeNameOrDescriptor, actionName, ...args ) {\n\treturn {\n\t\ttype: DISPATCH,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tactionName,\n\t\targs,\n\t};\n}\n\nexport const controls = { select, resolveSelect, dispatch };\n\nexport const builtinControls = {\n\t[ SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) =>\n\t\t\t\tregistry.select( storeKey )[ selectorName ]( ...args )\n\t),\n\t[ RESOLVE_SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) => {\n\t\t\t\tconst method = registry.select( storeKey )[ selectorName ]\n\t\t\t\t\t.hasResolver\n\t\t\t\t\t? 'resolveSelect'\n\t\t\t\t\t: 'select';\n\t\t\t\treturn registry[ method ]( storeKey )[ selectorName ](\n\t\t\t\t\t...args\n\t\t\t\t);\n\t\t\t}\n\t),\n\t[ DISPATCH ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, actionName, args } ) =>\n\t\t\t\tregistry.dispatch( storeKey )[ actionName ]( ...args )\n\t),\n};\n"],"mappings":"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"}
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _registry = require("./registry");
9
-
10
8
  /**
11
9
  * Internal dependencies
12
10
  */
13
11
  var _default = (0, _registry.createRegistry)();
14
-
15
12
  exports.default = _default;
16
13
  //# sourceMappingURL=default-registry.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/default-registry.js"],"names":[],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;eAGe,+B","sourcesContent":["/**\n * Internal dependencies\n */\nimport { createRegistry } from './registry';\n\nexport default createRegistry();\n"]}
1
+ {"version":3,"names":["_registry","require","_default","createRegistry","exports","default"],"sources":["@wordpress/data/src/default-registry.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createRegistry } from './registry';\n\nexport default createRegistry();\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAHA;AACA;AACA;AAFA,IAAAC,QAAA,GAKe,IAAAC,wBAAc,EAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
package/build/dispatch.js CHANGED
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.dispatch = dispatch;
9
-
10
8
  var _defaultRegistry = _interopRequireDefault(require("./default-registry"));
11
-
12
9
  /**
13
10
  * Internal dependencies
14
11
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/dispatch.ts"],"names":["dispatch","storeNameOrDescriptor","defaultRegistry"],"mappings":";;;;;;;;;AAIA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CAGNC,qBAHM,EAIoC;AAC1C,SAAOC,yBAAgBF,QAAhB,CAA0BC,qBAA1B,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { AnyConfig, StoreDescriptor, DispatchReturn } from './types';\nimport defaultRegistry from './default-registry';\n\n/**\n * Given a store descriptor, returns an object of the store's action creators.\n * Calling an action creator will cause it to be dispatched, updating the state value accordingly.\n *\n * Note: Action creators returned by the dispatch will return a promise when\n * they are called.\n *\n * @param storeNameOrDescriptor The store descriptor. The legacy calling convention of passing\n * the store name is also supported.\n *\n * @example\n * ```js\n * import { dispatch } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );\n * ```\n * @return Object containing the action creators.\n */\nexport function dispatch<\n\tStoreNameOrDescriptor extends StoreDescriptor< AnyConfig > | string\n>(\n\tstoreNameOrDescriptor: StoreNameOrDescriptor\n): DispatchReturn< StoreNameOrDescriptor > {\n\treturn defaultRegistry.dispatch( storeNameOrDescriptor );\n}\n"]}
1
+ {"version":3,"names":["_defaultRegistry","_interopRequireDefault","require","dispatch","storeNameOrDescriptor","defaultRegistry"],"sources":["@wordpress/data/src/dispatch.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { AnyConfig, StoreDescriptor, DispatchReturn } from './types';\nimport defaultRegistry from './default-registry';\n\n/**\n * Given a store descriptor, returns an object of the store's action creators.\n * Calling an action creator will cause it to be dispatched, updating the state value accordingly.\n *\n * Note: Action creators returned by the dispatch will return a promise when\n * they are called.\n *\n * @param storeNameOrDescriptor The store descriptor. The legacy calling convention of passing\n * the store name is also supported.\n *\n * @example\n * ```js\n * import { dispatch } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );\n * ```\n * @return Object containing the action creators.\n */\nexport function dispatch<\n\tStoreNameOrDescriptor extends StoreDescriptor< AnyConfig > | string\n>(\n\tstoreNameOrDescriptor: StoreNameOrDescriptor\n): DispatchReturn< StoreNameOrDescriptor > {\n\treturn defaultRegistry.dispatch( storeNameOrDescriptor );\n}\n"],"mappings":";;;;;;;AAIA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAGvBC,qBAA4C,EACF;EAC1C,OAAOC,wBAAe,CAACF,QAAQ,CAAEC,qBAAsB,CAAC;AACzD"}
package/build/factory.js CHANGED
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createRegistryControl = createRegistryControl;
7
7
  exports.createRegistrySelector = createRegistrySelector;
8
-
9
8
  /**
10
9
  * Creates a selector function that takes additional curried argument with the
11
10
  * registry `select` function. While a regular selector has signature
@@ -51,6 +50,7 @@ function createRegistrySelector(registrySelector) {
51
50
  // and that has the same API as a regular selector. Binding it in such a way makes it
52
51
  // possible to call the selector directly from another selector.
53
52
  const selector = (...args) => registrySelector(selector.registry.select)(...args);
53
+
54
54
  /**
55
55
  * Flag indicating that the selector is a registry selector that needs the correct registry
56
56
  * reference to be assigned to `selector.registry` to make it work correctly.
@@ -58,11 +58,10 @@ function createRegistrySelector(registrySelector) {
58
58
  *
59
59
  * @type {boolean}
60
60
  */
61
-
62
-
63
61
  selector.isRegistrySelector = true;
64
62
  return selector;
65
63
  }
64
+
66
65
  /**
67
66
  * Creates a control function that takes additional curried argument with the `registry` object.
68
67
  * While a regular control has signature
@@ -83,8 +82,6 @@ function createRegistrySelector(registrySelector) {
83
82
  *
84
83
  * @return {Function} Registry control that can be registered with a store.
85
84
  */
86
-
87
-
88
85
  function createRegistryControl(registryControl) {
89
86
  registryControl.isRegistryControl = true;
90
87
  return registryControl;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/factory.js"],"names":["createRegistrySelector","registrySelector","selector","args","registry","select","isRegistrySelector","createRegistryControl","registryControl","isRegistryControl"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAT,CAAiCC,gBAAjC,EAAoD;AAC1D;AACA;AACA;AACA,QAAMC,QAAQ,GAAG,CAAE,GAAGC,IAAL,KAChBF,gBAAgB,CAAEC,QAAQ,CAACE,QAAT,CAAkBC,MAApB,CAAhB,CAA8C,GAAGF,IAAjD,CADD;AAGA;AACD;AACA;AACA;AACA;AACA;AACA;;;AACCD,EAAAA,QAAQ,CAACI,kBAAT,GAA8B,IAA9B;AAEA,SAAOJ,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,qBAAT,CAAgCC,eAAhC,EAAkD;AACxDA,EAAAA,eAAe,CAACC,iBAAhB,GAAoC,IAApC;AAEA,SAAOD,eAAP;AACA","sourcesContent":["/**\n * Creates a selector function that takes additional curried argument with the\n * registry `select` function. While a regular selector has signature\n * ```js\n * ( state, ...selectorArgs ) => ( result )\n * ```\n * that allows to select data from the store's `state`, a registry selector\n * has signature:\n * ```js\n * ( select ) => ( state, ...selectorArgs ) => ( result )\n * ```\n * that supports also selecting from other registered stores.\n *\n * @example\n * ```js\n * import { store as coreStore } from '@wordpress/core-data';\n * import { store as editorStore } from '@wordpress/editor';\n *\n * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => {\n * return select( editorStore ).getCurrentPostId();\n * } );\n *\n * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {\n * // calling another registry selector just like any other function\n * const postType = getCurrentPostType( state );\n * const postId = getCurrentPostId( state );\n *\t return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId );\n * } );\n * ```\n *\n * Note how the `getCurrentPostId` selector can be called just like any other function,\n * (it works even inside a regular non-registry selector) and we don't need to pass the\n * registry as argument. The registry binding happens automatically when registering the selector\n * with a store.\n *\n * @param {Function} registrySelector Function receiving a registry `select`\n * function and returning a state selector.\n *\n * @return {Function} Registry selector that can be registered with a store.\n */\nexport function createRegistrySelector( registrySelector ) {\n\t// Create a selector function that is bound to the registry referenced by `selector.registry`\n\t// and that has the same API as a regular selector. Binding it in such a way makes it\n\t// possible to call the selector directly from another selector.\n\tconst selector = ( ...args ) =>\n\t\tregistrySelector( selector.registry.select )( ...args );\n\n\t/**\n\t * Flag indicating that the selector is a registry selector that needs the correct registry\n\t * reference to be assigned to `selector.registry` to make it work correctly.\n\t * be mapped as a registry selector.\n\t *\n\t * @type {boolean}\n\t */\n\tselector.isRegistrySelector = true;\n\n\treturn selector;\n}\n\n/**\n * Creates a control function that takes additional curried argument with the `registry` object.\n * While a regular control has signature\n * ```js\n * ( action ) => ( iteratorOrPromise )\n * ```\n * where the control works with the `action` that it's bound to, a registry control has signature:\n * ```js\n * ( registry ) => ( action ) => ( iteratorOrPromise )\n * ```\n * A registry control is typically used to select data or dispatch an action to a registered\n * store.\n *\n * When registering a control created with `createRegistryControl` with a store, the store\n * knows which calling convention to use when executing the control.\n *\n * @param {Function} registryControl Function receiving a registry object and returning a control.\n *\n * @return {Function} Registry control that can be registered with a store.\n */\nexport function createRegistryControl( registryControl ) {\n\tregistryControl.isRegistryControl = true;\n\n\treturn registryControl;\n}\n"]}
1
+ {"version":3,"names":["createRegistrySelector","registrySelector","selector","args","registry","select","isRegistrySelector","createRegistryControl","registryControl","isRegistryControl"],"sources":["@wordpress/data/src/factory.js"],"sourcesContent":["/**\n * Creates a selector function that takes additional curried argument with the\n * registry `select` function. While a regular selector has signature\n * ```js\n * ( state, ...selectorArgs ) => ( result )\n * ```\n * that allows to select data from the store's `state`, a registry selector\n * has signature:\n * ```js\n * ( select ) => ( state, ...selectorArgs ) => ( result )\n * ```\n * that supports also selecting from other registered stores.\n *\n * @example\n * ```js\n * import { store as coreStore } from '@wordpress/core-data';\n * import { store as editorStore } from '@wordpress/editor';\n *\n * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => {\n * return select( editorStore ).getCurrentPostId();\n * } );\n *\n * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {\n * // calling another registry selector just like any other function\n * const postType = getCurrentPostType( state );\n * const postId = getCurrentPostId( state );\n *\t return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId );\n * } );\n * ```\n *\n * Note how the `getCurrentPostId` selector can be called just like any other function,\n * (it works even inside a regular non-registry selector) and we don't need to pass the\n * registry as argument. The registry binding happens automatically when registering the selector\n * with a store.\n *\n * @param {Function} registrySelector Function receiving a registry `select`\n * function and returning a state selector.\n *\n * @return {Function} Registry selector that can be registered with a store.\n */\nexport function createRegistrySelector( registrySelector ) {\n\t// Create a selector function that is bound to the registry referenced by `selector.registry`\n\t// and that has the same API as a regular selector. Binding it in such a way makes it\n\t// possible to call the selector directly from another selector.\n\tconst selector = ( ...args ) =>\n\t\tregistrySelector( selector.registry.select )( ...args );\n\n\t/**\n\t * Flag indicating that the selector is a registry selector that needs the correct registry\n\t * reference to be assigned to `selector.registry` to make it work correctly.\n\t * be mapped as a registry selector.\n\t *\n\t * @type {boolean}\n\t */\n\tselector.isRegistrySelector = true;\n\n\treturn selector;\n}\n\n/**\n * Creates a control function that takes additional curried argument with the `registry` object.\n * While a regular control has signature\n * ```js\n * ( action ) => ( iteratorOrPromise )\n * ```\n * where the control works with the `action` that it's bound to, a registry control has signature:\n * ```js\n * ( registry ) => ( action ) => ( iteratorOrPromise )\n * ```\n * A registry control is typically used to select data or dispatch an action to a registered\n * store.\n *\n * When registering a control created with `createRegistryControl` with a store, the store\n * knows which calling convention to use when executing the control.\n *\n * @param {Function} registryControl Function receiving a registry object and returning a control.\n *\n * @return {Function} Registry control that can be registered with a store.\n */\nexport function createRegistryControl( registryControl ) {\n\tregistryControl.isRegistryControl = true;\n\n\treturn registryControl;\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAsBA,CAAEC,gBAAgB,EAAG;EAC1D;EACA;EACA;EACA,MAAMC,QAAQ,GAAGA,CAAE,GAAGC,IAAI,KACzBF,gBAAgB,CAAEC,QAAQ,CAACE,QAAQ,CAACC,MAAO,CAAC,CAAE,GAAGF,IAAK,CAAC;;EAExD;AACD;AACA;AACA;AACA;AACA;AACA;EACCD,QAAQ,CAACI,kBAAkB,GAAG,IAAI;EAElC,OAAOJ,QAAQ;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,qBAAqBA,CAAEC,eAAe,EAAG;EACxDA,eAAe,CAACC,iBAAiB,GAAG,IAAI;EAExC,OAAOD,eAAe;AACvB"}
package/build/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -110,45 +109,25 @@ Object.defineProperty(exports, "withSelect", {
110
109
  return _withSelect.default;
111
110
  }
112
111
  });
113
-
114
112
  var _turboCombineReducers = _interopRequireDefault(require("turbo-combine-reducers"));
115
-
116
113
  var _defaultRegistry = _interopRequireDefault(require("./default-registry"));
117
-
118
114
  var plugins = _interopRequireWildcard(require("./plugins"));
119
-
120
115
  exports.plugins = plugins;
121
-
122
116
  var _withSelect = _interopRequireDefault(require("./components/with-select"));
123
-
124
117
  var _withDispatch = _interopRequireDefault(require("./components/with-dispatch"));
125
-
126
118
  var _withRegistry = _interopRequireDefault(require("./components/with-registry"));
127
-
128
119
  var _registryProvider = require("./components/registry-provider");
129
-
130
120
  var _useSelect = _interopRequireWildcard(require("./components/use-select"));
131
-
132
121
  var _useDispatch = require("./components/use-dispatch");
133
-
134
122
  var _asyncModeProvider = require("./components/async-mode-provider");
135
-
136
123
  var _registry = require("./registry");
137
-
138
124
  var _factory = require("./factory");
139
-
140
125
  var _controls = require("./controls");
141
-
142
126
  var _reduxStore = _interopRequireDefault(require("./redux-store"));
143
-
144
127
  var _dispatch = require("./dispatch");
145
-
146
128
  var _select = require("./select");
147
-
148
129
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
149
-
150
130
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
151
-
152
131
  /**
153
132
  * External dependencies
154
133
  */
@@ -207,6 +186,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
207
186
  * object, and constructs a state object with the same shape.
208
187
  */
209
188
  const combineReducers = _turboCombineReducers.default;
189
+
210
190
  /**
211
191
  * Given a store descriptor, returns an object containing the store's selectors pre-bound to state
212
192
  * so that you only need to supply additional arguments, and modified so that they return promises
@@ -226,9 +206,9 @@ const combineReducers = _turboCombineReducers.default;
226
206
  *
227
207
  * @return {Object} Object containing the store's promise-wrapped selectors.
228
208
  */
229
-
230
209
  exports.combineReducers = combineReducers;
231
210
  const resolveSelect = _defaultRegistry.default.resolveSelect;
211
+
232
212
  /**
233
213
  * Given a store descriptor, returns an object containing the store's selectors pre-bound to state
234
214
  * so that you only need to supply additional arguments, and modified so that they throw promises
@@ -240,9 +220,9 @@ const resolveSelect = _defaultRegistry.default.resolveSelect;
240
220
  *
241
221
  * @return {Object} Object containing the store's suspense-wrapped selectors.
242
222
  */
243
-
244
223
  exports.resolveSelect = resolveSelect;
245
224
  const suspendSelect = _defaultRegistry.default.suspendSelect;
225
+
246
226
  /**
247
227
  * Given a listener function, the function will be called any time the state value
248
228
  * of one of the registered stores has changed. If you specify the optional
@@ -267,9 +247,9 @@ const suspendSelect = _defaultRegistry.default.suspendSelect;
267
247
  * unsubscribe();
268
248
  * ```
269
249
  */
270
-
271
250
  exports.suspendSelect = suspendSelect;
272
251
  const subscribe = _defaultRegistry.default.subscribe;
252
+
273
253
  /**
274
254
  * Registers a generic store instance.
275
255
  *
@@ -278,9 +258,9 @@ const subscribe = _defaultRegistry.default.subscribe;
278
258
  * @param {string} name Store registry name.
279
259
  * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).
280
260
  */
281
-
282
261
  exports.subscribe = subscribe;
283
262
  const registerGenericStore = _defaultRegistry.default.registerGenericStore;
263
+
284
264
  /**
285
265
  * Registers a standard `@wordpress/data` store.
286
266
  *
@@ -291,9 +271,9 @@ const registerGenericStore = _defaultRegistry.default.registerGenericStore;
291
271
  *
292
272
  * @return {Object} Registered store object.
293
273
  */
294
-
295
274
  exports.registerGenericStore = registerGenericStore;
296
275
  const registerStore = _defaultRegistry.default.registerStore;
276
+
297
277
  /**
298
278
  * Extends a registry to inherit functionality provided by a given plugin. A
299
279
  * plugin is an object with properties aligning to that of a registry, merged
@@ -301,9 +281,9 @@ const registerStore = _defaultRegistry.default.registerStore;
301
281
  *
302
282
  * @param {Object} plugin Plugin object.
303
283
  */
304
-
305
284
  exports.registerStore = registerStore;
306
285
  const use = _defaultRegistry.default.use;
286
+
307
287
  /**
308
288
  * Registers a standard `@wordpress/data` store descriptor.
309
289
  *
@@ -322,7 +302,6 @@ const use = _defaultRegistry.default.use;
322
302
  *
323
303
  * @param {StoreDescriptor} store Store descriptor.
324
304
  */
325
-
326
305
  exports.use = use;
327
306
  const register = _defaultRegistry.default.register;
328
307
  exports.register = register;