@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/index.js"],"names":["combineReducers","turboCombineReducers","resolveSelect","defaultRegistry","suspendSelect","subscribe","registerGenericStore","registerStore","use","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;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,MAAMA,eAAe,GAAGC,6BAAxB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,aAAa,GAAGC,yBAAgBD,aAAtC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,aAAa,GAAGD,yBAAgBC,aAAtC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,SAAS,GAAGF,yBAAgBE,SAAlC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,oBAAoB,GAAGH,yBAAgBG,oBAA7C;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,aAAa,GAAGJ,yBAAgBI,aAAtC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,GAAG,GAAGL,yBAAgBK,GAA5B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,QAAQ,GAAGN,yBAAgBM,QAAjC","sourcesContent":["/**\n * External dependencies\n */\nimport turboCombineReducers from 'turbo-combine-reducers';\n\n/**\n * Internal dependencies\n */\nimport defaultRegistry from './default-registry';\nimport * as plugins from './plugins';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nexport { default as withSelect } from './components/with-select';\nexport { default as withDispatch } from './components/with-dispatch';\nexport { default as withRegistry } from './components/with-registry';\nexport {\n\tRegistryProvider,\n\tRegistryConsumer,\n\tuseRegistry,\n} from './components/registry-provider';\nexport {\n\tdefault as useSelect,\n\tuseSuspenseSelect,\n} from './components/use-select';\nexport { useDispatch } from './components/use-dispatch';\nexport { AsyncModeProvider } from './components/async-mode-provider';\nexport { createRegistry } from './registry';\nexport { createRegistrySelector, createRegistryControl } from './factory';\nexport { controls } from './controls';\nexport { default as createReduxStore } from './redux-store';\nexport { dispatch } from './dispatch';\nexport { select } from './select';\n\n/**\n * Object of available plugins to use with a registry.\n *\n * @see [use](#use)\n *\n * @type {Object}\n */\nexport { plugins };\n\n/**\n * The combineReducers helper function turns an object whose values are different\n * reducing functions into a single reducing function you can pass to registerReducer.\n *\n * @type {import('./types').combineReducers}\n * @param {Object} reducers An object whose values correspond to different reducing\n * functions that need to be combined into one.\n *\n * @example\n * ```js\n * import { combineReducers, createReduxStore, register } from '@wordpress/data';\n *\n * const prices = ( state = {}, action ) => {\n * \treturn action.type === 'SET_PRICE' ?\n * \t\t{\n * \t\t\t...state,\n * \t\t\t[ action.item ]: action.price,\n * \t\t} :\n * \t\tstate;\n * };\n *\n * const discountPercent = ( state = 0, action ) => {\n * \treturn action.type === 'START_SALE' ?\n * \t\taction.discountPercent :\n * \t\tstate;\n * };\n *\n * const store = createReduxStore( 'my-shop', {\n * \treducer: combineReducers( {\n * \t\tprices,\n * \t\tdiscountPercent,\n * \t} ),\n * } );\n * register( store );\n * ```\n *\n * @return {Function} A reducer that invokes every reducer inside the reducers\n * object, and constructs a state object with the same shape.\n */\nexport const combineReducers = turboCombineReducers;\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors pre-bound to state\n * so that you only need to supply additional arguments, and modified so that they return promises\n * that resolve to their eventual values, after any resolvers have ran.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @example\n * ```js\n * import { resolveSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log)\n * ```\n *\n * @return {Object} Object containing the store's promise-wrapped selectors.\n */\nexport const resolveSelect = defaultRegistry.resolveSelect;\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors pre-bound to state\n * so that you only need to supply additional arguments, and modified so that they throw promises\n * in case the selector is not resolved yet.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @return {Object} Object containing the store's suspense-wrapped selectors.\n */\nexport const suspendSelect = defaultRegistry.suspendSelect;\n\n/**\n * Given a listener function, the function will be called any time the state value\n * of one of the registered stores has changed. If you specify the optional\n * `storeNameOrDescriptor` parameter, the listener function will be called only\n * on updates on that one specific registered store.\n *\n * This function returns an `unsubscribe` function used to stop the subscription.\n *\n * @param {Function} listener Callback function.\n * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n *\n * @example\n * ```js\n * import { subscribe } from '@wordpress/data';\n *\n * const unsubscribe = subscribe( () => {\n * \t// You could use this opportunity to test whether the derived result of a\n * \t// selector has subsequently changed as the result of a state update.\n * } );\n *\n * // Later, if necessary...\n * unsubscribe();\n * ```\n */\nexport const subscribe = defaultRegistry.subscribe;\n\n/**\n * Registers a generic store instance.\n *\n * @deprecated Use `register( storeDescriptor )` instead.\n *\n * @param {string} name Store registry name.\n * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).\n */\nexport const registerGenericStore = defaultRegistry.registerGenericStore;\n\n/**\n * Registers a standard `@wordpress/data` store.\n *\n * @deprecated Use `register` instead.\n *\n * @param {string} storeName Unique namespace identifier for the store.\n * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n *\n * @return {Object} Registered store object.\n */\nexport const registerStore = defaultRegistry.registerStore;\n\n/**\n * Extends a registry to inherit functionality provided by a given plugin. A\n * plugin is an object with properties aligning to that of a registry, merged\n * to extend the default registry behavior.\n *\n * @param {Object} plugin Plugin object.\n */\nexport const use = defaultRegistry.use;\n\n/**\n * Registers a standard `@wordpress/data` store descriptor.\n *\n * @example\n * ```js\n * import { createReduxStore, register } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * register( store );\n * ```\n *\n * @param {StoreDescriptor} store Store descriptor.\n */\nexport const register = defaultRegistry.register;\n"]}
1
+ {"version":3,"names":["_turboCombineReducers","_interopRequireDefault","require","_defaultRegistry","plugins","_interopRequireWildcard","exports","_withSelect","_withDispatch","_withRegistry","_registryProvider","_useSelect","_useDispatch","_asyncModeProvider","_registry","_factory","_controls","_reduxStore","_dispatch","_select","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","combineReducers","turboCombineReducers","resolveSelect","defaultRegistry","suspendSelect","subscribe","registerGenericStore","registerStore","use","register"],"sources":["@wordpress/data/src/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport turboCombineReducers from 'turbo-combine-reducers';\n\n/**\n * Internal dependencies\n */\nimport defaultRegistry from './default-registry';\nimport * as plugins from './plugins';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nexport { default as withSelect } from './components/with-select';\nexport { default as withDispatch } from './components/with-dispatch';\nexport { default as withRegistry } from './components/with-registry';\nexport {\n\tRegistryProvider,\n\tRegistryConsumer,\n\tuseRegistry,\n} from './components/registry-provider';\nexport {\n\tdefault as useSelect,\n\tuseSuspenseSelect,\n} from './components/use-select';\nexport { useDispatch } from './components/use-dispatch';\nexport { AsyncModeProvider } from './components/async-mode-provider';\nexport { createRegistry } from './registry';\nexport { createRegistrySelector, createRegistryControl } from './factory';\nexport { controls } from './controls';\nexport { default as createReduxStore } from './redux-store';\nexport { dispatch } from './dispatch';\nexport { select } from './select';\n\n/**\n * Object of available plugins to use with a registry.\n *\n * @see [use](#use)\n *\n * @type {Object}\n */\nexport { plugins };\n\n/**\n * The combineReducers helper function turns an object whose values are different\n * reducing functions into a single reducing function you can pass to registerReducer.\n *\n * @type {import('./types').combineReducers}\n * @param {Object} reducers An object whose values correspond to different reducing\n * functions that need to be combined into one.\n *\n * @example\n * ```js\n * import { combineReducers, createReduxStore, register } from '@wordpress/data';\n *\n * const prices = ( state = {}, action ) => {\n * \treturn action.type === 'SET_PRICE' ?\n * \t\t{\n * \t\t\t...state,\n * \t\t\t[ action.item ]: action.price,\n * \t\t} :\n * \t\tstate;\n * };\n *\n * const discountPercent = ( state = 0, action ) => {\n * \treturn action.type === 'START_SALE' ?\n * \t\taction.discountPercent :\n * \t\tstate;\n * };\n *\n * const store = createReduxStore( 'my-shop', {\n * \treducer: combineReducers( {\n * \t\tprices,\n * \t\tdiscountPercent,\n * \t} ),\n * } );\n * register( store );\n * ```\n *\n * @return {Function} A reducer that invokes every reducer inside the reducers\n * object, and constructs a state object with the same shape.\n */\nexport const combineReducers = turboCombineReducers;\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors pre-bound to state\n * so that you only need to supply additional arguments, and modified so that they return promises\n * that resolve to their eventual values, after any resolvers have ran.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @example\n * ```js\n * import { resolveSelect } from '@wordpress/data';\n * import { store as myCustomStore } from 'my-custom-store';\n *\n * resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log)\n * ```\n *\n * @return {Object} Object containing the store's promise-wrapped selectors.\n */\nexport const resolveSelect = defaultRegistry.resolveSelect;\n\n/**\n * Given a store descriptor, returns an object containing the store's selectors pre-bound to state\n * so that you only need to supply additional arguments, and modified so that they throw promises\n * in case the selector is not resolved yet.\n *\n * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n * convention of passing the store name is\n * also supported.\n *\n * @return {Object} Object containing the store's suspense-wrapped selectors.\n */\nexport const suspendSelect = defaultRegistry.suspendSelect;\n\n/**\n * Given a listener function, the function will be called any time the state value\n * of one of the registered stores has changed. If you specify the optional\n * `storeNameOrDescriptor` parameter, the listener function will be called only\n * on updates on that one specific registered store.\n *\n * This function returns an `unsubscribe` function used to stop the subscription.\n *\n * @param {Function} listener Callback function.\n * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.\n *\n * @example\n * ```js\n * import { subscribe } from '@wordpress/data';\n *\n * const unsubscribe = subscribe( () => {\n * \t// You could use this opportunity to test whether the derived result of a\n * \t// selector has subsequently changed as the result of a state update.\n * } );\n *\n * // Later, if necessary...\n * unsubscribe();\n * ```\n */\nexport const subscribe = defaultRegistry.subscribe;\n\n/**\n * Registers a generic store instance.\n *\n * @deprecated Use `register( storeDescriptor )` instead.\n *\n * @param {string} name Store registry name.\n * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).\n */\nexport const registerGenericStore = defaultRegistry.registerGenericStore;\n\n/**\n * Registers a standard `@wordpress/data` store.\n *\n * @deprecated Use `register` instead.\n *\n * @param {string} storeName Unique namespace identifier for the store.\n * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n *\n * @return {Object} Registered store object.\n */\nexport const registerStore = defaultRegistry.registerStore;\n\n/**\n * Extends a registry to inherit functionality provided by a given plugin. A\n * plugin is an object with properties aligning to that of a registry, merged\n * to extend the default registry behavior.\n *\n * @param {Object} plugin Plugin object.\n */\nexport const use = defaultRegistry.use;\n\n/**\n * Registers a standard `@wordpress/data` store descriptor.\n *\n * @example\n * ```js\n * import { createReduxStore, register } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * register( store );\n * ```\n *\n * @param {StoreDescriptor} store Store descriptor.\n */\nexport const register = defaultRegistry.register;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAqCI,OAAA,CAAAF,OAAA,GAAAA,OAAA;AAIrC,IAAAG,WAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,aAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,aAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AAKA,IAAAS,UAAA,GAAAN,uBAAA,CAAAH,OAAA;AAIA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,kBAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,GAAAZ,OAAA;AACA,IAAAa,QAAA,GAAAb,OAAA;AACA,IAAAc,SAAA,GAAAd,OAAA;AACA,IAAAe,WAAA,GAAAhB,sBAAA,CAAAC,OAAA;AACA,IAAAgB,SAAA,GAAAhB,OAAA;AACA,IAAAiB,OAAA,GAAAjB,OAAA;AAAkC,SAAAkB,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAhB,wBAAAoB,GA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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlBArC,OAAA,CAAAoC,eAAA,GAAAA,eAAA;AAmBO,MAAME,aAAa,GAAGC,wBAAe,CAACD,aAAa;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVAtC,OAAA,CAAAsC,aAAA,GAAAA,aAAA;AAWO,MAAME,aAAa,GAAGD,wBAAe,CAACC,aAAa;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAvBAxC,OAAA,CAAAwC,aAAA,GAAAA,aAAA;AAwBO,MAAMC,SAAS,GAAGF,wBAAe,CAACE,SAAS;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAzC,OAAA,CAAAyC,SAAA,GAAAA,SAAA;AAQO,MAAMC,oBAAoB,GAAGH,wBAAe,CAACG,oBAAoB;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATA1C,OAAA,CAAA0C,oBAAA,GAAAA,oBAAA;AAUO,MAAMC,aAAa,GAAGJ,wBAAe,CAACI,aAAa;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AANA3C,OAAA,CAAA2C,aAAA,GAAAA,aAAA;AAOO,MAAMC,GAAG,GAAGL,wBAAe,CAACK,GAAG;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAjBA5C,OAAA,CAAA4C,GAAA,GAAAA,GAAA;AAkBO,MAAMC,QAAQ,GAAGN,wBAAe,CAACM,QAAQ;AAAC7C,OAAA,CAAA6C,QAAA,GAAAA,QAAA"}
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.unlock = exports.lock = void 0;
7
-
8
7
  var _privateApis = require("@wordpress/private-apis");
9
-
10
8
  /**
11
9
  * WordPress dependencies
12
10
  */
11
+
13
12
  const {
14
13
  lock,
15
14
  unlock
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/lock-unlock.js"],"names":["lock","unlock"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAM;AAAEA,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ,mEACC,8GADD,EAEC,iBAFD,CADM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/data'\n\t);\n"]}
1
+ {"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/data/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/data'\n\t);\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5B,IAAAC,6DAAgD,EAC/C,8GAA8G,EAC9G,iBACD,CAAC;AAACC,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA"}
@@ -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
  });
@@ -11,6 +10,5 @@ Object.defineProperty(exports, "persistence", {
11
10
  return _persistence.default;
12
11
  }
13
12
  });
14
-
15
13
  var _persistence = _interopRequireDefault(require("./persistence"));
16
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/plugins/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default as persistence } from './persistence';\n"]}
1
+ {"version":3,"names":["_persistence","_interopRequireDefault","require"],"sources":["@wordpress/data/src/plugins/index.js"],"sourcesContent":["export { default as persistence } from './persistence';\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA"}
@@ -1,21 +1,15 @@
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.createPersistenceInterface = createPersistenceInterface;
9
8
  exports.withLazySameState = exports.default = void 0;
10
-
11
9
  var _isPlainObject = require("is-plain-object");
12
-
13
10
  var _deepmerge = _interopRequireDefault(require("deepmerge"));
14
-
15
11
  var _default2 = _interopRequireDefault(require("./storage/default"));
16
-
17
12
  var _ = require("../../");
18
-
19
13
  /**
20
14
  * External dependencies
21
15
  */
@@ -35,7 +29,6 @@ var _ = require("../../");
35
29
  * at least implement `getItem` and `setItem` of
36
30
  * the Web Storage API.
37
31
  * @property {string} storageKey Key on which to set in persistent storage.
38
- *
39
32
  */
40
33
 
41
34
  /**
@@ -44,13 +37,14 @@ var _ = require("../../");
44
37
  * @type {Storage}
45
38
  */
46
39
  const DEFAULT_STORAGE = _default2.default;
40
+
47
41
  /**
48
42
  * Default plugin storage key.
49
43
  *
50
44
  * @type {string}
51
45
  */
52
-
53
46
  const DEFAULT_STORAGE_KEY = 'WP_DATA';
47
+
54
48
  /**
55
49
  * Higher-order reducer which invokes the original reducer only if state is
56
50
  * inequal from that of the action's `nextState` property, otherwise returning
@@ -60,14 +54,13 @@ const DEFAULT_STORAGE_KEY = 'WP_DATA';
60
54
  *
61
55
  * @return {Function} Enhanced reducer.
62
56
  */
63
-
64
57
  const withLazySameState = reducer => (state, action) => {
65
58
  if (action.nextState === state) {
66
59
  return state;
67
60
  }
68
-
69
61
  return reducer(state, action);
70
62
  };
63
+
71
64
  /**
72
65
  * Creates a persistence interface, exposing getter and setter methods (`get`
73
66
  * and `set` respectively).
@@ -76,28 +69,24 @@ const withLazySameState = reducer => (state, action) => {
76
69
  *
77
70
  * @return {Object} Persistence interface.
78
71
  */
79
-
80
-
81
72
  exports.withLazySameState = withLazySameState;
82
-
83
73
  function createPersistenceInterface(options) {
84
74
  const {
85
75
  storage = DEFAULT_STORAGE,
86
76
  storageKey = DEFAULT_STORAGE_KEY
87
77
  } = options;
88
78
  let data;
79
+
89
80
  /**
90
81
  * Returns the persisted data as an object, defaulting to an empty object.
91
82
  *
92
83
  * @return {Object} Persisted data.
93
84
  */
94
-
95
85
  function getData() {
96
86
  if (data === undefined) {
97
87
  // If unset, getItem is expected to return null. Fall back to
98
88
  // empty object.
99
89
  const persisted = storage.getItem(storageKey);
100
-
101
90
  if (persisted === null) {
102
91
  data = {};
103
92
  } else {
@@ -110,29 +99,28 @@ function createPersistenceInterface(options) {
110
99
  }
111
100
  }
112
101
  }
113
-
114
102
  return data;
115
103
  }
104
+
116
105
  /**
117
106
  * Merges an updated reducer state into the persisted data.
118
107
  *
119
108
  * @param {string} key Key to update.
120
109
  * @param {*} value Updated value.
121
110
  */
122
-
123
-
124
111
  function setData(key, value) {
125
- data = { ...data,
112
+ data = {
113
+ ...data,
126
114
  [key]: value
127
115
  };
128
116
  storage.setItem(storageKey, JSON.stringify(data));
129
117
  }
130
-
131
118
  return {
132
119
  get: getData,
133
120
  set: setData
134
121
  };
135
122
  }
123
+
136
124
  /**
137
125
  * Data plugin to persist store state into a single storage key.
138
126
  *
@@ -141,10 +129,9 @@ function createPersistenceInterface(options) {
141
129
  *
142
130
  * @return {WPDataPlugin} Data plugin.
143
131
  */
144
-
145
-
146
132
  function persistencePlugin(registry, pluginOptions) {
147
133
  const persistence = createPersistenceInterface(pluginOptions);
134
+
148
135
  /**
149
136
  * Creates an enhanced store dispatch function, triggering the state of the
150
137
  * given store name to be persisted when changed.
@@ -155,10 +142,8 @@ function persistencePlugin(registry, pluginOptions) {
155
142
  *
156
143
  * @return {Function} Enhanced dispatch function.
157
144
  */
158
-
159
145
  function createPersistOnChange(getState, storeName, keys) {
160
146
  let getPersistedState;
161
-
162
147
  if (Array.isArray(keys)) {
163
148
  // Given keys, the persisted state should by produced as an object
164
149
  // of the subset of keys. This implementation uses combineReducers
@@ -172,7 +157,6 @@ function persistencePlugin(registry, pluginOptions) {
172
157
  } else {
173
158
  getPersistedState = (state, action) => action.nextState;
174
159
  }
175
-
176
160
  let lastState = getPersistedState(undefined, {
177
161
  nextState: getState()
178
162
  });
@@ -180,28 +164,24 @@ function persistencePlugin(registry, pluginOptions) {
180
164
  const state = getPersistedState(lastState, {
181
165
  nextState: getState()
182
166
  });
183
-
184
167
  if (state !== lastState) {
185
168
  persistence.set(storeName, state);
186
169
  lastState = state;
187
170
  }
188
171
  };
189
172
  }
190
-
191
173
  return {
192
174
  registerStore(storeName, options) {
193
175
  if (!options.persist) {
194
176
  return registry.registerStore(storeName, options);
195
- } // Load from persistence to use as initial state.
196
-
177
+ }
197
178
 
179
+ // Load from persistence to use as initial state.
198
180
  const persistedState = persistence.get()[storeName];
199
-
200
181
  if (persistedState !== undefined) {
201
182
  let initialState = options.reducer(options.initialState, {
202
183
  type: '@@WP/PERSISTENCE_RESTORE'
203
184
  });
204
-
205
185
  if ((0, _isPlainObject.isPlainObject)(initialState) && (0, _isPlainObject.isPlainObject)(persistedState)) {
206
186
  // If state is an object, ensure that:
207
187
  // - Other keys are left intact when persisting only a
@@ -216,22 +196,18 @@ function persistencePlugin(registry, pluginOptions) {
216
196
  // initial or persisted state, defer to persisted value.
217
197
  initialState = persistedState;
218
198
  }
219
-
220
- options = { ...options,
199
+ options = {
200
+ ...options,
221
201
  initialState
222
202
  };
223
203
  }
224
-
225
204
  const store = registry.registerStore(storeName, options);
226
205
  store.subscribe(createPersistOnChange(store.getState, storeName, options.persist));
227
206
  return store;
228
207
  }
229
-
230
208
  };
231
209
  }
232
-
233
210
  persistencePlugin.__unstableMigrate = () => {};
234
-
235
211
  var _default = persistencePlugin;
236
212
  exports.default = _default;
237
213
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/plugins/persistence/index.js"],"names":["DEFAULT_STORAGE","defaultStorage","DEFAULT_STORAGE_KEY","withLazySameState","reducer","state","action","nextState","createPersistenceInterface","options","storage","storageKey","data","getData","undefined","persisted","getItem","JSON","parse","error","setData","key","value","setItem","stringify","get","set","persistencePlugin","registry","pluginOptions","persistence","createPersistOnChange","getState","storeName","keys","getPersistedState","Array","isArray","reducers","reduce","accumulator","Object","assign","lastState","registerStore","persist","persistedState","initialState","type","isMergeableObject","isPlainObject","store","subscribe","__unstableMigrate"],"mappings":";;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMA,eAAe,GAAGC,iBAAxB;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG,SAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,iBAAiB,GAAKC,OAAF,IAAe,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACpE,MAAKA,MAAM,CAACC,SAAP,KAAqBF,KAA1B,EAAkC;AACjC,WAAOA,KAAP;AACA;;AAED,SAAOD,OAAO,CAAEC,KAAF,EAASC,MAAT,CAAd;AACA,CANM;AAQP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASE,0BAAT,CAAqCC,O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A,UAAKa,cAAc,KAAKhC,SAAxB,EAAoC;AACnC,YAAIiC,YAAY,GAAGtC,OAAO,CAACL,OAAR,CAAiBK,OAAO,CAACsC,YAAzB,EAAuC;AACzDC,UAAAA,IAAI,EAAE;AADmD,SAAvC,CAAnB;;AAIA,YACC,kCAAeD,YAAf,KACA,kCAAeD,cAAf,CAFD,EAGE;AACD;AACA;AACA;AACA;AACA;AACAC,UAAAA,YAAY,GAAG,wBAAWA,YAAX,EAAyBD,cAAzB,EAAyC;AACvDG,YAAAA,iBAAiB,EAAEC;AADoC,WAAzC,CAAf;AAGA,SAZD,MAYO;AACN;AACA;AACAH,UAAAA,YAAY,GAAGD,cAAf;AACA;;AAEDrC,QAAAA,OAAO,GAAG,EACT,GAAGA,OADM;AAETsC,UAAAA;AAFS,SAAV;AAIA;;AAED,YAAMI,KAAK,GAAGvB,QAAQ,CAACgB,aAAT,CAAwBX,SAAxB,EAAmCxB,OAAnC,CAAd;AAEA0C,MAAAA,KAAK,CAACC,SAAN,CACCrB,qBAAqB,CACpBoB,KAAK,CAACnB,QADc,EAEpBC,SAFoB,EAGpBxB,OAAO,CAACoC,OAHY,CADtB;AAQA,aAAOM,KAAP;AACA;;AAhDK,GAAP;AAkDA;;AAEDxB,iBAAiB,CAAC0B,iBAAlB,GAAsC,MAAM,CAAE,CAA9C;;eAEe1B,iB","sourcesContent":["/**\n * External dependencies\n */\nimport { isPlainObject } from 'is-plain-object';\nimport deepmerge from 'deepmerge';\n\n/**\n * Internal dependencies\n */\nimport defaultStorage from './storage/default';\nimport { combineReducers } from '../../';\n\n/** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */\n\n/** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */\n\n/**\n * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.\n *\n * @property {Storage} storage Persistent storage implementation. This must\n * at least implement `getItem` and `setItem` of\n * the Web Storage API.\n * @property {string} storageKey Key on which to set in persistent storage.\n *\n */\n\n/**\n * Default plugin storage.\n *\n * @type {Storage}\n */\nconst DEFAULT_STORAGE = defaultStorage;\n\n/**\n * Default plugin storage key.\n *\n * @type {string}\n */\nconst DEFAULT_STORAGE_KEY = 'WP_DATA';\n\n/**\n * Higher-order reducer which invokes the original reducer only if state is\n * inequal from that of the action's `nextState` property, otherwise returning\n * the original state reference.\n *\n * @param {Function} reducer Original reducer.\n *\n * @return {Function} Enhanced reducer.\n */\nexport const withLazySameState = ( reducer ) => ( state, action ) => {\n\tif ( action.nextState === state ) {\n\t\treturn state;\n\t}\n\n\treturn reducer( state, action );\n};\n\n/**\n * Creates a persistence interface, exposing getter and setter methods (`get`\n * and `set` respectively).\n *\n * @param {WPDataPersistencePluginOptions} options Plugin options.\n *\n * @return {Object} Persistence interface.\n */\nexport function createPersistenceInterface( options ) {\n\tconst { storage = DEFAULT_STORAGE, storageKey = DEFAULT_STORAGE_KEY } =\n\t\toptions;\n\n\tlet data;\n\n\t/**\n\t * Returns the persisted data as an object, defaulting to an empty object.\n\t *\n\t * @return {Object} Persisted data.\n\t */\n\tfunction getData() {\n\t\tif ( data === undefined ) {\n\t\t\t// If unset, getItem is expected to return null. Fall back to\n\t\t\t// empty object.\n\t\t\tconst persisted = storage.getItem( storageKey );\n\t\t\tif ( persisted === null ) {\n\t\t\t\tdata = {};\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( persisted );\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\t// Similarly, should any error be thrown during parse of\n\t\t\t\t\t// the string (malformed JSON), fall back to empty object.\n\t\t\t\t\tdata = {};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Merges an updated reducer state into the persisted data.\n\t *\n\t * @param {string} key Key to update.\n\t * @param {*} value Updated value.\n\t */\n\tfunction setData( key, value ) {\n\t\tdata = { ...data, [ key ]: value };\n\t\tstorage.setItem( storageKey, JSON.stringify( data ) );\n\t}\n\n\treturn {\n\t\tget: getData,\n\t\tset: setData,\n\t};\n}\n\n/**\n * Data plugin to persist store state into a single storage key.\n *\n * @param {WPDataRegistry} registry Data registry.\n * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.\n *\n * @return {WPDataPlugin} Data plugin.\n */\nfunction persistencePlugin( registry, pluginOptions ) {\n\tconst persistence = createPersistenceInterface( pluginOptions );\n\n\t/**\n\t * Creates an enhanced store dispatch function, triggering the state of the\n\t * given store name to be persisted when changed.\n\t *\n\t * @param {Function} getState Function which returns current state.\n\t * @param {string} storeName Store name.\n\t * @param {?Array<string>} keys Optional subset of keys to save.\n\t *\n\t * @return {Function} Enhanced dispatch function.\n\t */\n\tfunction createPersistOnChange( getState, storeName, keys ) {\n\t\tlet getPersistedState;\n\t\tif ( Array.isArray( keys ) ) {\n\t\t\t// Given keys, the persisted state should by produced as an object\n\t\t\t// of the subset of keys. This implementation uses combineReducers\n\t\t\t// to leverage its behavior of returning the same object when none\n\t\t\t// of the property values changes. This allows a strict reference\n\t\t\t// equality to bypass a persistence set on an unchanging state.\n\t\t\tconst reducers = keys.reduce(\n\t\t\t\t( accumulator, key ) =>\n\t\t\t\t\tObject.assign( accumulator, {\n\t\t\t\t\t\t[ key ]: ( state, action ) => action.nextState[ key ],\n\t\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tgetPersistedState = withLazySameState(\n\t\t\t\tcombineReducers( reducers )\n\t\t\t);\n\t\t} else {\n\t\t\tgetPersistedState = ( state, action ) => action.nextState;\n\t\t}\n\n\t\tlet lastState = getPersistedState( undefined, {\n\t\t\tnextState: getState(),\n\t\t} );\n\n\t\treturn () => {\n\t\t\tconst state = getPersistedState( lastState, {\n\t\t\t\tnextState: getState(),\n\t\t\t} );\n\t\t\tif ( state !== lastState ) {\n\t\t\t\tpersistence.set( storeName, state );\n\t\t\t\tlastState = state;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn {\n\t\tregisterStore( storeName, options ) {\n\t\t\tif ( ! options.persist ) {\n\t\t\t\treturn registry.registerStore( storeName, options );\n\t\t\t}\n\n\t\t\t// Load from persistence to use as initial state.\n\t\t\tconst persistedState = persistence.get()[ storeName ];\n\t\t\tif ( persistedState !== undefined ) {\n\t\t\t\tlet initialState = options.reducer( options.initialState, {\n\t\t\t\t\ttype: '@@WP/PERSISTENCE_RESTORE',\n\t\t\t\t} );\n\n\t\t\t\tif (\n\t\t\t\t\tisPlainObject( initialState ) &&\n\t\t\t\t\tisPlainObject( persistedState )\n\t\t\t\t) {\n\t\t\t\t\t// If state is an object, ensure that:\n\t\t\t\t\t// - Other keys are left intact when persisting only a\n\t\t\t\t\t// subset of keys.\n\t\t\t\t\t// - New keys in what would otherwise be used as initial\n\t\t\t\t\t// state are deeply merged as base for persisted value.\n\t\t\t\t\tinitialState = deepmerge( initialState, persistedState, {\n\t\t\t\t\t\tisMergeableObject: isPlainObject,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\t// If there is a mismatch in object-likeness of default\n\t\t\t\t\t// initial or persisted state, defer to persisted value.\n\t\t\t\t\tinitialState = persistedState;\n\t\t\t\t}\n\n\t\t\t\toptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tinitialState,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst store = registry.registerStore( storeName, options );\n\n\t\t\tstore.subscribe(\n\t\t\t\tcreatePersistOnChange(\n\t\t\t\t\tstore.getState,\n\t\t\t\t\tstoreName,\n\t\t\t\t\toptions.persist\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn store;\n\t\t},\n\t};\n}\n\npersistencePlugin.__unstableMigrate = () => {};\n\nexport default persistencePlugin;\n"]}
1
+ {"version":3,"names":["_isPlainObject","require","_deepmerge","_interopRequireDefault","_default2","_","DEFAULT_STORAGE","defaultStorage","DEFAULT_STORAGE_KEY","withLazySameState","reducer","state","action","nextState","exports","createPersistenceInterface","options","storage","storageKey","data","getData","undefined","persisted","getItem","JSON","parse","error","setData","key","value","setItem","stringify","get","set","persistencePlugin","registry","pluginOptions","persistence","createPersistOnChange","getState","storeName","keys","getPersistedState","Array","isArray","reducers","reduce","accumulator","Object","assign","combineReducers","lastState","registerStore","persist","persistedState","initialState","type","isPlainObject","deepmerge","isMergeableObject","store","subscribe","__unstableMigrate","_default","default"],"sources":["@wordpress/data/src/plugins/persistence/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { isPlainObject } from 'is-plain-object';\nimport deepmerge from 'deepmerge';\n\n/**\n * Internal dependencies\n */\nimport defaultStorage from './storage/default';\nimport { combineReducers } from '../../';\n\n/** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */\n\n/** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */\n\n/**\n * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.\n *\n * @property {Storage} storage Persistent storage implementation. This must\n * at least implement `getItem` and `setItem` of\n * the Web Storage API.\n * @property {string} storageKey Key on which to set in persistent storage.\n */\n\n/**\n * Default plugin storage.\n *\n * @type {Storage}\n */\nconst DEFAULT_STORAGE = defaultStorage;\n\n/**\n * Default plugin storage key.\n *\n * @type {string}\n */\nconst DEFAULT_STORAGE_KEY = 'WP_DATA';\n\n/**\n * Higher-order reducer which invokes the original reducer only if state is\n * inequal from that of the action's `nextState` property, otherwise returning\n * the original state reference.\n *\n * @param {Function} reducer Original reducer.\n *\n * @return {Function} Enhanced reducer.\n */\nexport const withLazySameState = ( reducer ) => ( state, action ) => {\n\tif ( action.nextState === state ) {\n\t\treturn state;\n\t}\n\n\treturn reducer( state, action );\n};\n\n/**\n * Creates a persistence interface, exposing getter and setter methods (`get`\n * and `set` respectively).\n *\n * @param {WPDataPersistencePluginOptions} options Plugin options.\n *\n * @return {Object} Persistence interface.\n */\nexport function createPersistenceInterface( options ) {\n\tconst { storage = DEFAULT_STORAGE, storageKey = DEFAULT_STORAGE_KEY } =\n\t\toptions;\n\n\tlet data;\n\n\t/**\n\t * Returns the persisted data as an object, defaulting to an empty object.\n\t *\n\t * @return {Object} Persisted data.\n\t */\n\tfunction getData() {\n\t\tif ( data === undefined ) {\n\t\t\t// If unset, getItem is expected to return null. Fall back to\n\t\t\t// empty object.\n\t\t\tconst persisted = storage.getItem( storageKey );\n\t\t\tif ( persisted === null ) {\n\t\t\t\tdata = {};\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( persisted );\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\t// Similarly, should any error be thrown during parse of\n\t\t\t\t\t// the string (malformed JSON), fall back to empty object.\n\t\t\t\t\tdata = {};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Merges an updated reducer state into the persisted data.\n\t *\n\t * @param {string} key Key to update.\n\t * @param {*} value Updated value.\n\t */\n\tfunction setData( key, value ) {\n\t\tdata = { ...data, [ key ]: value };\n\t\tstorage.setItem( storageKey, JSON.stringify( data ) );\n\t}\n\n\treturn {\n\t\tget: getData,\n\t\tset: setData,\n\t};\n}\n\n/**\n * Data plugin to persist store state into a single storage key.\n *\n * @param {WPDataRegistry} registry Data registry.\n * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.\n *\n * @return {WPDataPlugin} Data plugin.\n */\nfunction persistencePlugin( registry, pluginOptions ) {\n\tconst persistence = createPersistenceInterface( pluginOptions );\n\n\t/**\n\t * Creates an enhanced store dispatch function, triggering the state of the\n\t * given store name to be persisted when changed.\n\t *\n\t * @param {Function} getState Function which returns current state.\n\t * @param {string} storeName Store name.\n\t * @param {?Array<string>} keys Optional subset of keys to save.\n\t *\n\t * @return {Function} Enhanced dispatch function.\n\t */\n\tfunction createPersistOnChange( getState, storeName, keys ) {\n\t\tlet getPersistedState;\n\t\tif ( Array.isArray( keys ) ) {\n\t\t\t// Given keys, the persisted state should by produced as an object\n\t\t\t// of the subset of keys. This implementation uses combineReducers\n\t\t\t// to leverage its behavior of returning the same object when none\n\t\t\t// of the property values changes. This allows a strict reference\n\t\t\t// equality to bypass a persistence set on an unchanging state.\n\t\t\tconst reducers = keys.reduce(\n\t\t\t\t( accumulator, key ) =>\n\t\t\t\t\tObject.assign( accumulator, {\n\t\t\t\t\t\t[ key ]: ( state, action ) => action.nextState[ key ],\n\t\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tgetPersistedState = withLazySameState(\n\t\t\t\tcombineReducers( reducers )\n\t\t\t);\n\t\t} else {\n\t\t\tgetPersistedState = ( state, action ) => action.nextState;\n\t\t}\n\n\t\tlet lastState = getPersistedState( undefined, {\n\t\t\tnextState: getState(),\n\t\t} );\n\n\t\treturn () => {\n\t\t\tconst state = getPersistedState( lastState, {\n\t\t\t\tnextState: getState(),\n\t\t\t} );\n\t\t\tif ( state !== lastState ) {\n\t\t\t\tpersistence.set( storeName, state );\n\t\t\t\tlastState = state;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn {\n\t\tregisterStore( storeName, options ) {\n\t\t\tif ( ! options.persist ) {\n\t\t\t\treturn registry.registerStore( storeName, options );\n\t\t\t}\n\n\t\t\t// Load from persistence to use as initial state.\n\t\t\tconst persistedState = persistence.get()[ storeName ];\n\t\t\tif ( persistedState !== undefined ) {\n\t\t\t\tlet initialState = options.reducer( options.initialState, {\n\t\t\t\t\ttype: '@@WP/PERSISTENCE_RESTORE',\n\t\t\t\t} );\n\n\t\t\t\tif (\n\t\t\t\t\tisPlainObject( initialState ) &&\n\t\t\t\t\tisPlainObject( persistedState )\n\t\t\t\t) {\n\t\t\t\t\t// If state is an object, ensure that:\n\t\t\t\t\t// - Other keys are left intact when persisting only a\n\t\t\t\t\t// subset of keys.\n\t\t\t\t\t// - New keys in what would otherwise be used as initial\n\t\t\t\t\t// state are deeply merged as base for persisted value.\n\t\t\t\t\tinitialState = deepmerge( initialState, persistedState, {\n\t\t\t\t\t\tisMergeableObject: isPlainObject,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\t// If there is a mismatch in object-likeness of default\n\t\t\t\t\t// initial or persisted state, defer to persisted value.\n\t\t\t\t\tinitialState = persistedState;\n\t\t\t\t}\n\n\t\t\t\toptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tinitialState,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst store = registry.registerStore( storeName, options );\n\n\t\t\tstore.subscribe(\n\t\t\t\tcreatePersistOnChange(\n\t\t\t\t\tstore.getState,\n\t\t\t\t\tstoreName,\n\t\t\t\t\toptions.persist\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn store;\n\t\t},\n\t};\n}\n\npersistencePlugin.__unstableMigrate = () => {};\n\nexport default persistencePlugin;\n"],"mappings":";;;;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,SAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,CAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMK,eAAe,GAAGC,iBAAc;;AAEtC;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAG,SAAS;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAAKC,OAAO,IAAM,CAAEC,KAAK,EAAEC,MAAM,KAAM;EACpE,IAAKA,MAAM,CAACC,SAAS,KAAKF,KAAK,EAAG;IACjC,OAAOA,KAAK;EACb;EAEA,OAAOD,OAAO,CAAEC,KAAK,EAAEC,MAAO,CAAC;AAChC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAE,OAAA,CAAAL,iBAAA,GAAAA,iBAAA;AAQO,SAASM,0BAA0BA,CAAEC,OAAO,EAAG;EACrD,MAAM;IAAEC,OAAO,GAAGX,eAAe;IAAEY,UAAU,GAAGV;EAAoB,CAAC,GACpEQ,OAAO;EAER,IAA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AAAE,4BAAa,EAAEH,cAAe,CAAC,EAC9B;UACD;UACA;UACA;UACA;UACA;UACAC,YAAY,GAAG,IAAAG,kBAAS,EAAEH,YAAY,EAAED,cAAc,EAAE;YACvDK,iBAAiB,EAAEF;UACpB,CAAE,CAAC;QACJ,CAAC,MAAM;UACN;UACA;UACAF,YAAY,GAAGD,cAAc;QAC9B;QAEAtC,OAAO,GAAG;UACT,GAAGA,OAAO;UACVuC;QACD,CAAC;MACF;MAEA,MAAMK,KAAK,GAAGzB,QAAQ,CAACiB,aAAa,CAAEZ,SAAS,EAAExB,OAAQ,CAAC;MAE1D4C,KAAK,CAACC,SAAS,CACdvB,qBAAqB,CACpBsB,KAAK,CAACrB,QAAQ,EACdC,SAAS,EACTxB,OAAO,CAACqC,OACT,CACD,CAAC;MAED,OAAOO,KAAK;IACb;EACD,CAAC;AACF;AAEA1B,iBAAiB,CAAC4B,iBAAiB,GAAG,MAAM,CAAC,CAAC;AAAC,IAAAC,QAAA,GAEhC7B,iBAAiB;AAAApB,OAAA,CAAAkD,OAAA,GAAAD,QAAA"}
@@ -1,19 +1,16 @@
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 _object = _interopRequireDefault(require("./object"));
11
-
12
9
  /**
13
10
  * Internal dependencies
14
11
  */
15
- let storage;
16
12
 
13
+ let storage;
17
14
  try {
18
15
  // Private Browsing in Safari 10 and earlier will throw an error when
19
16
  // attempting to set into localStorage. The test here is intentional in
@@ -24,7 +21,6 @@ try {
24
21
  } catch (error) {
25
22
  storage = _object.default;
26
23
  }
27
-
28
24
  var _default = storage;
29
25
  exports.default = _default;
30
26
  //# sourceMappingURL=default.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/plugins/persistence/storage/default.js"],"names":["storage","window","localStorage","setItem","removeItem","error","objectStorage"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,IAAIA,OAAJ;;AAEA,IAAI;AACH;AACA;AACA;AACAA,EAAAA,OAAO,GAAGC,MAAM,CAACC,YAAjB;AACAF,EAAAA,OAAO,CAACG,OAAR,CAAiB,0BAAjB,EAA6C,EAA7C;AACAH,EAAAA,OAAO,CAACI,UAAR,CAAoB,0BAApB;AACA,CAPD,CAOE,OAAQC,KAAR,EAAgB;AACjBL,EAAAA,OAAO,GAAGM,eAAV;AACA;;eAEcN,O","sourcesContent":["/**\n * Internal dependencies\n */\nimport objectStorage from './object';\n\nlet storage;\n\ntry {\n\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t// attempting to set into localStorage. The test here is intentional in\n\t// causing a thrown error as condition for using fallback object storage.\n\tstorage = window.localStorage;\n\tstorage.setItem( '__wpDataTestLocalStorage', '' );\n\tstorage.removeItem( '__wpDataTestLocalStorage' );\n} catch ( error ) {\n\tstorage = objectStorage;\n}\n\nexport default storage;\n"]}
1
+ {"version":3,"names":["_object","_interopRequireDefault","require","storage","window","localStorage","setItem","removeItem","error","objectStorage","_default","exports","default"],"sources":["@wordpress/data/src/plugins/persistence/storage/default.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport objectStorage from './object';\n\nlet storage;\n\ntry {\n\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t// attempting to set into localStorage. The test here is intentional in\n\t// causing a thrown error as condition for using fallback object storage.\n\tstorage = window.localStorage;\n\tstorage.setItem( '__wpDataTestLocalStorage', '' );\n\tstorage.removeItem( '__wpDataTestLocalStorage' );\n} catch ( error ) {\n\tstorage = objectStorage;\n}\n\nexport default storage;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA,IAAIC,OAAO;AAEX,IAAI;EACH;EACA;EACA;EACAA,OAAO,GAAGC,MAAM,CAACC,YAAY;EAC7BF,OAAO,CAACG,OAAO,CAAE,0BAA0B,EAAE,EAAG,CAAC;EACjDH,OAAO,CAACI,UAAU,CAAE,0BAA2B,CAAC;AACjD,CAAC,CAAC,OAAQC,KAAK,EAAG;EACjBL,OAAO,GAAGM,eAAa;AACxB;AAAC,IAAAC,QAAA,GAEcP,OAAO;AAAAQ,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -10,22 +10,17 @@ const storage = {
10
10
  if (!objectStorage || !objectStorage[key]) {
11
11
  return null;
12
12
  }
13
-
14
13
  return objectStorage[key];
15
14
  },
16
-
17
15
  setItem(key, value) {
18
16
  if (!objectStorage) {
19
17
  storage.clear();
20
18
  }
21
-
22
19
  objectStorage[key] = String(value);
23
20
  },
24
-
25
21
  clear() {
26
22
  objectStorage = Object.create(null);
27
23
  }
28
-
29
24
  };
30
25
  var _default = storage;
31
26
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/plugins/persistence/storage/object.js"],"names":["objectStorage","storage","getItem","key","setItem","value","clear","String","Object","create"],"mappings":";;;;;;AAAA,IAAIA,aAAJ;AAEA,MAAMC,OAAO,GAAG;AACfC,EAAAA,OAAO,CAAEC,GAAF,EAAQ;AACd,QAAK,CAAEH,aAAF,IAAmB,CAAEA,aAAa,CAAEG,GAAF,CAAvC,EAAiD;AAChD,aAAO,IAAP;AACA;;AAED,WAAOH,aAAa,CAAEG,GAAF,CAApB;AACA,GAPc;;AAQfC,EAAAA,OAAO,CAAED,GAAF,EAAOE,KAAP,EAAe;AACrB,QAAK,CAAEL,aAAP,EAAuB;AACtBC,MAAAA,OAAO,CAACK,KAAR;AACA;;AAEDN,IAAAA,aAAa,CAAEG,GAAF,CAAb,GAAuBI,MAAM,CAAEF,KAAF,CAA7B;AACA,GAdc;;AAefC,EAAAA,KAAK,GAAG;AACPN,IAAAA,aAAa,GAAGQ,MAAM,CAACC,MAAP,CAAe,IAAf,CAAhB;AACA;;AAjBc,CAAhB;eAoBeR,O","sourcesContent":["let objectStorage;\n\nconst storage = {\n\tgetItem( key ) {\n\t\tif ( ! objectStorage || ! objectStorage[ key ] ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn objectStorage[ key ];\n\t},\n\tsetItem( key, value ) {\n\t\tif ( ! objectStorage ) {\n\t\t\tstorage.clear();\n\t\t}\n\n\t\tobjectStorage[ key ] = String( value );\n\t},\n\tclear() {\n\t\tobjectStorage = Object.create( null );\n\t},\n};\n\nexport default storage;\n"]}
1
+ {"version":3,"names":["objectStorage","storage","getItem","key","setItem","value","clear","String","Object","create","_default","exports","default"],"sources":["@wordpress/data/src/plugins/persistence/storage/object.js"],"sourcesContent":["let objectStorage;\n\nconst storage = {\n\tgetItem( key ) {\n\t\tif ( ! objectStorage || ! objectStorage[ key ] ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn objectStorage[ key ];\n\t},\n\tsetItem( key, value ) {\n\t\tif ( ! objectStorage ) {\n\t\t\tstorage.clear();\n\t\t}\n\n\t\tobjectStorage[ key ] = String( value );\n\t},\n\tclear() {\n\t\tobjectStorage = Object.create( null );\n\t},\n};\n\nexport default storage;\n"],"mappings":";;;;;;AAAA,IAAIA,aAAa;AAEjB,MAAMC,OAAO,GAAG;EACfC,OAAOA,CAAEC,GAAG,EAAG;IACd,IAAK,CAAEH,aAAa,IAAI,CAAEA,aAAa,CAAEG,GAAG,CAAE,EAAG;MAChD,OAAO,IAAI;IACZ;IAEA,OAAOH,aAAa,CAAEG,GAAG,CAAE;EAC5B,CAAC;EACDC,OAAOA,CAAED,GAAG,EAAEE,KAAK,EAAG;IACrB,IAAK,CAAEL,aAAa,EAAG;MACtBC,OAAO,CAACK,KAAK,CAAC,CAAC;IAChB;IAEAN,aAAa,CAAEG,GAAG,CAAE,GAAGI,MAAM,CAAEF,KAAM,CAAC;EACvC,CAAC;EACDC,KAAKA,CAAA,EAAG;IACPN,aAAa,GAAGQ,MAAM,CAACC,MAAM,CAAE,IAAK,CAAC;EACtC;AACD,CAAC;AAAC,IAAAC,QAAA,GAEaT,OAAO;AAAAU,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -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.default = void 0;
9
-
10
8
  var _isPromise = _interopRequireDefault(require("is-promise"));
11
-
12
9
  /**
13
10
  * External dependencies
14
11
  */
@@ -26,10 +23,8 @@ const promiseMiddleware = () => next => action => {
26
23
  }
27
24
  });
28
25
  }
29
-
30
26
  return next(action);
31
27
  };
32
-
33
28
  var _default = promiseMiddleware;
34
29
  exports.default = _default;
35
30
  //# sourceMappingURL=promise-middleware.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/promise-middleware.js"],"names":["promiseMiddleware","next","action","then","resolvedAction"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMA,iBAAiB,GAAG,MAAQC,IAAF,IAAcC,MAAF,IAAc;AACzD,MAAK,wBAAWA,MAAX,CAAL,EAA2B;AAC1B,WAAOA,MAAM,CAACC,IAAP,CAAeC,cAAF,IAAsB;AACzC,UAAKA,cAAL,EAAsB;AACrB,eAAOH,IAAI,CAAEG,cAAF,CAAX;AACA;AACD,KAJM,CAAP;AAKA;;AAED,SAAOH,IAAI,CAAEC,MAAF,CAAX;AACA,CAVD;;eAYeF,iB","sourcesContent":["/**\n * External dependencies\n */\nimport isPromise from 'is-promise';\n\n/**\n * Simplest possible promise redux middleware.\n *\n * @type {import('redux').Middleware}\n */\nconst promiseMiddleware = () => ( next ) => ( action ) => {\n\tif ( isPromise( action ) ) {\n\t\treturn action.then( ( resolvedAction ) => {\n\t\t\tif ( resolvedAction ) {\n\t\t\t\treturn next( resolvedAction );\n\t\t\t}\n\t\t} );\n\t}\n\n\treturn next( action );\n};\n\nexport default promiseMiddleware;\n"]}
1
+ {"version":3,"names":["_isPromise","_interopRequireDefault","require","promiseMiddleware","next","action","isPromise","then","resolvedAction","_default","exports","default"],"sources":["@wordpress/data/src/promise-middleware.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport isPromise from 'is-promise';\n\n/**\n * Simplest possible promise redux middleware.\n *\n * @type {import('redux').Middleware}\n */\nconst promiseMiddleware = () => ( next ) => ( action ) => {\n\tif ( isPromise( action ) ) {\n\t\treturn action.then( ( resolvedAction ) => {\n\t\t\tif ( resolvedAction ) {\n\t\t\t\treturn next( resolvedAction );\n\t\t\t}\n\t\t} );\n\t}\n\n\treturn next( action );\n};\n\nexport default promiseMiddleware;\n"],"mappings":";;;;;;;AAGA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAGA,CAAA,KAAQC,IAAI,IAAQC,MAAM,IAAM;EACzD,IAAK,IAAAC,kBAAS,EAAED,MAAO,CAAC,EAAG;IAC1B,OAAOA,MAAM,CAACE,IAAI,CAAIC,cAAc,IAAM;MACzC,IAAKA,cAAc,EAAG;QACrB,OAAOJ,IAAI,CAAEI,cAAe,CAAC;MAC9B;IACD,CAAE,CAAC;EACJ;EAEA,OAAOJ,IAAI,CAAEC,MAAO,CAAC;AACtB,CAAC;AAAC,IAAAI,QAAA,GAEaN,iBAAiB;AAAAO,OAAA,CAAAC,OAAA,GAAAF,QAAA"}