@wordpress/data 9.8.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 (157) hide show
  1. package/CHANGELOG.md +17 -4
  2. package/README.md +101 -2
  3. package/build/components/async-mode-provider/context.js +2 -3
  4. package/build/components/async-mode-provider/context.js.map +1 -1
  5. package/build/components/async-mode-provider/index.js +0 -5
  6. package/build/components/async-mode-provider/index.js.map +1 -1
  7. package/build/components/async-mode-provider/use-async-mode.js +1 -3
  8. package/build/components/async-mode-provider/use-async-mode.js.map +1 -1
  9. package/build/components/registry-provider/context.js +3 -6
  10. package/build/components/registry-provider/context.js.map +1 -1
  11. package/build/components/registry-provider/index.js +0 -5
  12. package/build/components/registry-provider/index.js.map +1 -1
  13. package/build/components/registry-provider/use-registry.js +0 -3
  14. package/build/components/registry-provider/use-registry.js.map +1 -1
  15. package/build/components/use-dispatch/index.js +0 -3
  16. package/build/components/use-dispatch/index.js.map +1 -1
  17. package/build/components/use-dispatch/use-dispatch-with-map.js +0 -7
  18. package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  19. package/build/components/use-dispatch/use-dispatch.js +0 -5
  20. package/build/components/use-dispatch/use-dispatch.js.map +1 -1
  21. package/build/components/use-select/index.js +35 -53
  22. package/build/components/use-select/index.js.map +1 -1
  23. package/build/components/with-dispatch/index.js +2 -7
  24. package/build/components/with-dispatch/index.js.map +1 -1
  25. package/build/components/with-registry/index.js +2 -5
  26. package/build/components/with-registry/index.js.map +1 -1
  27. package/build/components/with-select/index.js +2 -8
  28. package/build/components/with-select/index.js.map +1 -1
  29. package/build/controls.js +4 -10
  30. package/build/controls.js.map +1 -1
  31. package/build/default-registry.js +0 -3
  32. package/build/default-registry.js.map +1 -1
  33. package/build/dispatch.js +0 -3
  34. package/build/dispatch.js.map +1 -1
  35. package/build/factory.js +2 -5
  36. package/build/factory.js.map +1 -1
  37. package/build/index.js +7 -28
  38. package/build/index.js.map +1 -1
  39. package/build/lock-unlock.js +1 -2
  40. package/build/lock-unlock.js.map +1 -1
  41. package/build/plugins/index.js +0 -2
  42. package/build/plugins/index.js.map +1 -1
  43. package/build/plugins/persistence/index.js +13 -37
  44. package/build/plugins/persistence/index.js.map +1 -1
  45. package/build/plugins/persistence/storage/default.js +1 -5
  46. package/build/plugins/persistence/storage/default.js.map +1 -1
  47. package/build/plugins/persistence/storage/object.js +0 -5
  48. package/build/plugins/persistence/storage/object.js.map +1 -1
  49. package/build/promise-middleware.js +0 -5
  50. package/build/promise-middleware.js.map +1 -1
  51. package/build/redux-store/index.js +36 -117
  52. package/build/redux-store/index.js.map +1 -1
  53. package/build/redux-store/metadata/actions.js +8 -17
  54. package/build/redux-store/metadata/actions.js.map +1 -1
  55. package/build/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
  56. package/build/redux-store/metadata/reducer.js +1 -23
  57. package/build/redux-store/metadata/reducer.js.map +1 -1
  58. package/build/redux-store/metadata/selectors.js +8 -22
  59. package/build/redux-store/metadata/selectors.js.map +1 -1
  60. package/build/redux-store/metadata/utils.js +6 -14
  61. package/build/redux-store/metadata/utils.js.map +1 -1
  62. package/build/redux-store/thunk-middleware.js +0 -2
  63. package/build/redux-store/thunk-middleware.js.map +1 -1
  64. package/build/registry.js +29 -73
  65. package/build/registry.js.map +1 -1
  66. package/build/resolvers-cache-middleware.js +2 -8
  67. package/build/resolvers-cache-middleware.js.map +1 -1
  68. package/build/select.js +0 -3
  69. package/build/select.js.map +1 -1
  70. package/build/store/index.js +0 -7
  71. package/build/store/index.js.map +1 -1
  72. package/build/types.js.map +1 -1
  73. package/build/utils/emitter.js +2 -11
  74. package/build/utils/emitter.js.map +1 -1
  75. package/build-module/components/async-mode-provider/context.js +1 -1
  76. package/build-module/components/async-mode-provider/context.js.map +1 -1
  77. package/build-module/components/async-mode-provider/index.js.map +1 -1
  78. package/build-module/components/async-mode-provider/use-async-mode.js +1 -1
  79. package/build-module/components/async-mode-provider/use-async-mode.js.map +1 -1
  80. package/build-module/components/registry-provider/context.js +3 -3
  81. package/build-module/components/registry-provider/context.js.map +1 -1
  82. package/build-module/components/registry-provider/index.js.map +1 -1
  83. package/build-module/components/registry-provider/use-registry.js +2 -2
  84. package/build-module/components/registry-provider/use-registry.js.map +1 -1
  85. package/build-module/components/use-dispatch/index.js.map +1 -1
  86. package/build-module/components/use-dispatch/use-dispatch-with-map.js +2 -4
  87. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  88. package/build-module/components/use-dispatch/use-dispatch.js +1 -3
  89. package/build-module/components/use-dispatch/use-dispatch.js.map +1 -1
  90. package/build-module/components/use-select/index.js +35 -46
  91. package/build-module/components/use-select/index.js.map +1 -1
  92. package/build-module/components/with-dispatch/index.js +4 -6
  93. package/build-module/components/with-dispatch/index.js.map +1 -1
  94. package/build-module/components/with-registry/index.js +4 -4
  95. package/build-module/components/with-registry/index.js.map +1 -1
  96. package/build-module/components/with-select/index.js +4 -6
  97. package/build-module/components/with-select/index.js.map +1 -1
  98. package/build-module/controls.js +4 -8
  99. package/build-module/controls.js.map +1 -1
  100. package/build-module/default-registry.js.map +1 -1
  101. package/build-module/dispatch.js +2 -1
  102. package/build-module/dispatch.js.map +1 -1
  103. package/build-module/factory.js +2 -3
  104. package/build-module/factory.js.map +1 -1
  105. package/build-module/index.js +11 -10
  106. package/build-module/index.js.map +1 -1
  107. package/build-module/lock-unlock.js.map +1 -1
  108. package/build-module/plugins/index.js.map +1 -1
  109. package/build-module/plugins/persistence/index.js +15 -30
  110. package/build-module/plugins/persistence/index.js.map +1 -1
  111. package/build-module/plugins/persistence/storage/default.js +0 -2
  112. package/build-module/plugins/persistence/storage/default.js.map +1 -1
  113. package/build-module/plugins/persistence/storage/object.js +0 -5
  114. package/build-module/plugins/persistence/storage/object.js.map +1 -1
  115. package/build-module/promise-middleware.js +1 -3
  116. package/build-module/promise-middleware.js.map +1 -1
  117. package/build-module/redux-store/index.js +38 -101
  118. package/build-module/redux-store/index.js.map +1 -1
  119. package/build-module/redux-store/metadata/actions.js +8 -8
  120. package/build-module/redux-store/metadata/actions.js.map +1 -1
  121. package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +1 -1
  122. package/build-module/redux-store/metadata/reducer.js +1 -21
  123. package/build-module/redux-store/metadata/reducer.js.map +1 -1
  124. package/build-module/redux-store/metadata/selectors.js +9 -13
  125. package/build-module/redux-store/metadata/selectors.js.map +1 -1
  126. package/build-module/redux-store/metadata/utils.js +6 -11
  127. package/build-module/redux-store/metadata/utils.js.map +1 -1
  128. package/build-module/redux-store/thunk-middleware.js +0 -1
  129. package/build-module/redux-store/thunk-middleware.js.map +1 -1
  130. package/build-module/registry.js +30 -67
  131. package/build-module/registry.js.map +1 -1
  132. package/build-module/resolvers-cache-middleware.js +3 -6
  133. package/build-module/resolvers-cache-middleware.js.map +1 -1
  134. package/build-module/select.js +2 -1
  135. package/build-module/select.js.map +1 -1
  136. package/build-module/store/index.js +0 -7
  137. package/build-module/store/index.js.map +1 -1
  138. package/build-module/types.js.map +1 -1
  139. package/build-module/utils/emitter.js +2 -10
  140. package/build-module/utils/emitter.js.map +1 -1
  141. package/build-types/components/use-select/index.d.ts.map +1 -1
  142. package/build-types/dispatch.d.ts +2 -2
  143. package/build-types/dispatch.d.ts.map +1 -1
  144. package/build-types/index.d.ts +1 -1
  145. package/build-types/index.d.ts.map +1 -1
  146. package/build-types/plugins/persistence/index.d.ts.map +1 -1
  147. package/build-types/private-apis.d.ts +3 -0
  148. package/build-types/private-apis.d.ts.map +1 -0
  149. package/build-types/store/index.d.ts +1 -1
  150. package/build-types/types.d.ts +9 -3
  151. package/build-types/types.d.ts.map +1 -1
  152. package/package.json +9 -9
  153. package/src/components/use-select/index.js +14 -0
  154. package/src/dispatch.ts +6 -9
  155. package/src/plugins/persistence/index.js +0 -1
  156. package/src/types.ts +38 -5
  157. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/dispatch.ts"],"names":["dispatch","storeNameOrDescriptor","defaultRegistry"],"mappings":";;;;;;;;;AASA;;AATA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CACNC,qBADM,EAE8B;AACpC,SAAOC,yBAAgBF,QAAhB,CAA0BC,qBAA1B,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tActionCreatorsOf,\n\tAnyConfig,\n\tConfigOf,\n\tStoreDescriptor,\n} 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< T extends StoreDescriptor< AnyConfig > >(\n\tstoreNameOrDescriptor: string | T\n): ActionCreatorsOf< ConfigOf< T > > {\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;
@@ -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,gBAA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GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAhClC;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,MAAMW,eAAe,GAAGC,6BAAoB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,OAArC,EAA+C;AACrD,QAAM;AAAEC,IAAAA,OAAO,GAAGV,eAAZ;AAA6BW,IAAAA,UAAU,GAAGT;AAA1C,MACLO,OADD;AAGA,MAAIG,IAAJ;AAEA;AACD;AACA;AACA;AACA;;AACC,WAASC,OAAT,GAAmB;AAClB,QAAKD,IAAI,KAAKE,SAAd,EAA0B;AACzB;AACA;AACA,YAAMC,SAAS,GAAGL,OAAO,CAACM,OAAR,CAAiBL,UAAjB,CAAlB;;AACA,UAAKI,SAAS,KAAK,IAAnB,EAA0B;AACzBH,QAAAA,IAAI,GAAG,EAAP;AACA,OAFD,MAEO;AACN,YAAI;AACHA,UAAA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AAY,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,IAAA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vB,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"}