@wordpress/data 10.32.0 → 10.32.1-next.ff1cebbba.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/build/components/async-mode-provider/context.js +35 -54
  2. package/build/components/async-mode-provider/context.js.map +7 -1
  3. package/build/components/async-mode-provider/index.js +40 -25
  4. package/build/components/async-mode-provider/index.js.map +7 -1
  5. package/build/components/async-mode-provider/use-async-mode.js +25 -16
  6. package/build/components/async-mode-provider/use-async-mode.js.map +7 -1
  7. package/build/components/registry-provider/context.js +46 -64
  8. package/build/components/registry-provider/context.js.map +7 -1
  9. package/build/components/registry-provider/index.js +40 -25
  10. package/build/components/registry-provider/index.js.map +7 -1
  11. package/build/components/registry-provider/use-registry.js +25 -55
  12. package/build/components/registry-provider/use-registry.js.map +7 -1
  13. package/build/components/use-dispatch/index.js +38 -17
  14. package/build/components/use-dispatch/index.js.map +7 -1
  15. package/build/components/use-dispatch/use-dispatch-with-map.js +59 -44
  16. package/build/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  17. package/build/components/use-dispatch/use-dispatch.js +36 -71
  18. package/build/components/use-dispatch/use-dispatch.js.map +7 -1
  19. package/build/components/use-select/index.js +79 -208
  20. package/build/components/use-select/index.js.map +7 -1
  21. package/build/components/with-dispatch/index.js +34 -107
  22. package/build/components/with-dispatch/index.js.map +7 -1
  23. package/build/components/with-registry/index.js +30 -30
  24. package/build/components/with-registry/index.js.map +7 -1
  25. package/build/components/with-select/index.js +44 -67
  26. package/build/components/with-select/index.js.map +7 -1
  27. package/build/controls.js +49 -110
  28. package/build/controls.js.map +7 -1
  29. package/build/create-selector.js +36 -11
  30. package/build/create-selector.js.map +7 -1
  31. package/build/default-registry.js +24 -10
  32. package/build/default-registry.js.map +7 -1
  33. package/build/dispatch.js +38 -31
  34. package/build/dispatch.js.map +7 -1
  35. package/build/factory.js +29 -85
  36. package/build/factory.js.map +7 -1
  37. package/build/index.js +114 -301
  38. package/build/index.js.map +7 -1
  39. package/build/lock-unlock.js +31 -14
  40. package/build/lock-unlock.js.map +7 -1
  41. package/build/plugins/index.js +36 -11
  42. package/build/plugins/index.js.map +7 -1
  43. package/build/plugins/persistence/index.js +74 -139
  44. package/build/plugins/persistence/index.js.map +7 -1
  45. package/build/plugins/persistence/storage/default.js +37 -18
  46. package/build/plugins/persistence/storage/default.js.map +7 -1
  47. package/build/plugins/persistence/storage/object.js +24 -7
  48. package/build/plugins/persistence/storage/object.js.map +7 -1
  49. package/build/promise-middleware.js +37 -20
  50. package/build/promise-middleware.js.map +7 -1
  51. package/build/redux-store/combine-reducers.js +26 -5
  52. package/build/redux-store/combine-reducers.js.map +7 -1
  53. package/build/redux-store/index.js +221 -331
  54. package/build/redux-store/index.js.map +7 -1
  55. package/build/redux-store/metadata/actions.js +51 -112
  56. package/build/redux-store/metadata/actions.js.map +7 -1
  57. package/build/redux-store/metadata/equivalent-key-map.d.js +1 -1
  58. package/build/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  59. package/build/redux-store/metadata/reducer.js +111 -115
  60. package/build/redux-store/metadata/reducer.js.map +7 -1
  61. package/build/redux-store/metadata/selectors.js +109 -181
  62. package/build/redux-store/metadata/selectors.js.map +7 -1
  63. package/build/redux-store/metadata/utils.js +32 -35
  64. package/build/redux-store/metadata/utils.js.map +7 -1
  65. package/build/redux-store/thunk-middleware.js +24 -7
  66. package/build/redux-store/thunk-middleware.js.map +7 -1
  67. package/build/registry.js +94 -198
  68. package/build/registry.js.map +7 -1
  69. package/build/resolvers-cache-middleware.js +26 -27
  70. package/build/resolvers-cache-middleware.js.map +7 -1
  71. package/build/select.js +38 -31
  72. package/build/select.js.map +7 -1
  73. package/build/store/index.js +52 -16
  74. package/build/store/index.js.map +7 -1
  75. package/build/types.js +16 -5
  76. package/build/types.js.map +7 -1
  77. package/build/utils/emitter.js +33 -16
  78. package/build/utils/emitter.js.map +7 -1
  79. package/build-module/components/async-mode-provider/context.js +12 -49
  80. package/build-module/components/async-mode-provider/context.js.map +7 -1
  81. package/build-module/components/async-mode-provider/index.js +8 -3
  82. package/build-module/components/async-mode-provider/index.js.map +7 -1
  83. package/build-module/components/async-mode-provider/use-async-mode.js +7 -11
  84. package/build-module/components/async-mode-provider/use-async-mode.js.map +7 -1
  85. package/build-module/components/registry-provider/context.js +13 -58
  86. package/build-module/components/registry-provider/context.js.map +7 -1
  87. package/build-module/components/registry-provider/index.js +8 -3
  88. package/build-module/components/registry-provider/index.js.map +7 -1
  89. package/build-module/components/registry-provider/use-registry.js +7 -51
  90. package/build-module/components/registry-provider/use-registry.js.map +7 -1
  91. package/build-module/components/use-dispatch/index.js +7 -3
  92. package/build-module/components/use-dispatch/index.js.map +7 -1
  93. package/build-module/components/use-dispatch/use-dispatch-with-map.js +27 -35
  94. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +7 -1
  95. package/build-module/components/use-dispatch/use-dispatch.js +8 -66
  96. package/build-module/components/use-dispatch/use-dispatch.js.map +7 -1
  97. package/build-module/components/use-select/index.js +45 -193
  98. package/build-module/components/use-select/index.js.map +7 -1
  99. package/build-module/components/with-dispatch/index.js +16 -104
  100. package/build-module/components/with-dispatch/index.js.map +7 -1
  101. package/build-module/components/with-registry/index.js +12 -27
  102. package/build-module/components/with-registry/index.js.map +7 -1
  103. package/build-module/components/with-select/index.js +16 -63
  104. package/build-module/components/with-select/index.js.map +7 -1
  105. package/build-module/controls.js +25 -105
  106. package/build-module/controls.js.map +7 -1
  107. package/build-module/create-selector.js +5 -8
  108. package/build-module/create-selector.js.map +7 -1
  109. package/build-module/default-registry.js +6 -6
  110. package/build-module/default-registry.js.map +7 -1
  111. package/build-module/dispatch.js +6 -27
  112. package/build-module/dispatch.js.map +7 -1
  113. package/build-module/factory.js +8 -82
  114. package/build-module/factory.js.map +7 -1
  115. package/build-module/index.js +62 -185
  116. package/build-module/index.js.map +7 -1
  117. package/build-module/lock-unlock.js +8 -7
  118. package/build-module/lock-unlock.js.map +7 -1
  119. package/build-module/plugins/index.js +5 -2
  120. package/build-module/plugins/index.js.map +7 -1
  121. package/build-module/plugins/persistence/index.js +38 -129
  122. package/build-module/plugins/persistence/index.js.map +7 -1
  123. package/build-module/plugins/persistence/storage/default.js +8 -11
  124. package/build-module/plugins/persistence/storage/default.js.map +7 -1
  125. package/build-module/plugins/persistence/storage/object.js +6 -3
  126. package/build-module/plugins/persistence/storage/object.js.map +7 -1
  127. package/build-module/promise-middleware.js +8 -14
  128. package/build-module/promise-middleware.js.map +7 -1
  129. package/build-module/redux-store/combine-reducers.js +5 -2
  130. package/build-module/redux-store/combine-reducers.js.map +7 -1
  131. package/build-module/redux-store/index.js +180 -310
  132. package/build-module/redux-store/index.js.map +7 -1
  133. package/build-module/redux-store/metadata/actions.js +30 -109
  134. package/build-module/redux-store/metadata/actions.js.map +7 -1
  135. package/build-module/redux-store/metadata/equivalent-key-map.d.js +1 -2
  136. package/build-module/redux-store/metadata/equivalent-key-map.d.js.map +7 -1
  137. package/build-module/redux-store/metadata/reducer.js +83 -108
  138. package/build-module/redux-store/metadata/reducer.js.map +7 -1
  139. package/build-module/redux-store/metadata/selectors.js +76 -175
  140. package/build-module/redux-store/metadata/selectors.js.map +7 -1
  141. package/build-module/redux-store/metadata/utils.js +10 -30
  142. package/build-module/redux-store/metadata/utils.js.map +7 -1
  143. package/build-module/redux-store/thunk-middleware.js +7 -4
  144. package/build-module/redux-store/thunk-middleware.js.map +7 -1
  145. package/build-module/registry.js +56 -187
  146. package/build-module/registry.js.map +7 -1
  147. package/build-module/resolvers-cache-middleware.js +8 -23
  148. package/build-module/resolvers-cache-middleware.js.map +7 -1
  149. package/build-module/select.js +6 -27
  150. package/build-module/select.js.map +7 -1
  151. package/build-module/store/index.js +34 -12
  152. package/build-module/store/index.js.map +7 -1
  153. package/build-module/types.js +1 -2
  154. package/build-module/types.js.map +7 -1
  155. package/build-module/utils/emitter.js +12 -13
  156. package/build-module/utils/emitter.js.map +7 -1
  157. package/package.json +17 -10
package/build/controls.js CHANGED
@@ -1,46 +1,34 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var controls_exports = {};
20
+ __export(controls_exports, {
21
+ builtinControls: () => builtinControls,
22
+ controls: () => controls
5
23
  });
6
- exports.controls = exports.builtinControls = void 0;
7
- var _factory = require("./factory");
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
13
-
14
- const SELECT = '@@data/SELECT';
15
- const RESOLVE_SELECT = '@@data/RESOLVE_SELECT';
16
- const DISPATCH = '@@data/DISPATCH';
24
+ module.exports = __toCommonJS(controls_exports);
25
+ var import_factory = require("./factory");
26
+ const SELECT = "@@data/SELECT";
27
+ const RESOLVE_SELECT = "@@data/RESOLVE_SELECT";
28
+ const DISPATCH = "@@data/DISPATCH";
17
29
  function isObject(object) {
18
- return object !== null && typeof object === 'object';
30
+ return object !== null && typeof object === "object";
19
31
  }
20
-
21
- /**
22
- * Dispatches a control action for triggering a synchronous registry select.
23
- *
24
- * Note: This control synchronously returns the current selector value, triggering the
25
- * resolution, but not waiting for it.
26
- *
27
- * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
28
- * @param {string} selectorName The name of the selector.
29
- * @param {Array} args Arguments for the selector.
30
- *
31
- * @example
32
- * ```js
33
- * import { controls } from '@wordpress/data';
34
- *
35
- * // Action generator using `select`.
36
- * export function* myAction() {
37
- * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );
38
- * // Do stuff with the result from the `select`.
39
- * }
40
- * ```
41
- *
42
- * @return {Object} The control descriptor.
43
- */
44
32
  function select(storeNameOrDescriptor, selectorName, ...args) {
45
33
  return {
46
34
  type: SELECT,
@@ -49,31 +37,6 @@ function select(storeNameOrDescriptor, selectorName, ...args) {
49
37
  args
50
38
  };
51
39
  }
52
-
53
- /**
54
- * Dispatches a control action for triggering and resolving a registry select.
55
- *
56
- * Note: when this control action is handled, it automatically considers
57
- * selectors that may have a resolver. In such case, it will return a `Promise` that resolves
58
- * after the selector finishes resolving, with the final result value.
59
- *
60
- * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
61
- * @param {string} selectorName The name of the selector
62
- * @param {Array} args Arguments for the selector.
63
- *
64
- * @example
65
- * ```js
66
- * import { controls } from '@wordpress/data';
67
- *
68
- * // Action generator using resolveSelect
69
- * export function* myAction() {
70
- * const isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );
71
- * // do stuff with the result from the select.
72
- * }
73
- * ```
74
- *
75
- * @return {Object} The control descriptor.
76
- */
77
40
  function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
78
41
  return {
79
42
  type: RESOLVE_SELECT,
@@ -82,27 +45,6 @@ function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
82
45
  args
83
46
  };
84
47
  }
85
-
86
- /**
87
- * Dispatches a control action for triggering a registry dispatch.
88
- *
89
- * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
90
- * @param {string} actionName The name of the action to dispatch
91
- * @param {Array} args Arguments for the dispatch action.
92
- *
93
- * @example
94
- * ```js
95
- * import { controls } from '@wordpress/data-controls';
96
- *
97
- * // Action generator using dispatch
98
- * export function* myAction() {
99
- * yield controls.dispatch( 'core/editor', 'togglePublishSidebar' );
100
- * // do some other things.
101
- * }
102
- * ```
103
- *
104
- * @return {Object} The control descriptor.
105
- */
106
48
  function dispatch(storeNameOrDescriptor, actionName, ...args) {
107
49
  return {
108
50
  type: DISPATCH,
@@ -111,29 +53,26 @@ function dispatch(storeNameOrDescriptor, actionName, ...args) {
111
53
  args
112
54
  };
113
55
  }
114
- const controls = exports.controls = {
115
- select,
116
- resolveSelect,
117
- dispatch
118
- };
119
- const builtinControls = exports.builtinControls = {
120
- [SELECT]: (0, _factory.createRegistryControl)(registry => ({
121
- storeKey,
122
- selectorName,
123
- args
124
- }) => registry.select(storeKey)[selectorName](...args)),
125
- [RESOLVE_SELECT]: (0, _factory.createRegistryControl)(registry => ({
126
- storeKey,
127
- selectorName,
128
- args
129
- }) => {
130
- const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select';
131
- return registry[method](storeKey)[selectorName](...args);
132
- }),
133
- [DISPATCH]: (0, _factory.createRegistryControl)(registry => ({
134
- storeKey,
135
- actionName,
136
- args
137
- }) => registry.dispatch(storeKey)[actionName](...args))
56
+ const controls = { select, resolveSelect, dispatch };
57
+ const builtinControls = {
58
+ [SELECT]: (0, import_factory.createRegistryControl)(
59
+ (registry) => ({ storeKey, selectorName, args }) => registry.select(storeKey)[selectorName](...args)
60
+ ),
61
+ [RESOLVE_SELECT]: (0, import_factory.createRegistryControl)(
62
+ (registry) => ({ storeKey, selectorName, args }) => {
63
+ const method = registry.select(storeKey)[selectorName].hasResolver ? "resolveSelect" : "select";
64
+ return registry[method](storeKey)[selectorName](
65
+ ...args
66
+ );
67
+ }
68
+ ),
69
+ [DISPATCH]: (0, import_factory.createRegistryControl)(
70
+ (registry) => ({ storeKey, actionName, args }) => registry.dispatch(storeKey)[actionName](...args)
71
+ )
138
72
  };
139
- //# sourceMappingURL=controls.js.map
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ builtinControls,
76
+ controls
77
+ });
78
+ //# sourceMappingURL=controls.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_factory","require","SELECT","RESOLVE_SELECT","DISPATCH","isObject","object","select","storeNameOrDescriptor","selectorName","args","type","storeKey","name","resolveSelect","dispatch","actionName","controls","exports","builtinControls","createRegistryControl","registry","method","hasResolver"],"sources":["@wordpress/data/src/controls.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createRegistryControl } from './factory';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nconst SELECT = '@@data/SELECT';\nconst RESOLVE_SELECT = '@@data/RESOLVE_SELECT';\nconst DISPATCH = '@@data/DISPATCH';\n\nfunction isObject( object ) {\n\treturn object !== null && typeof object === 'object';\n}\n\n/**\n * Dispatches a control action for triggering a synchronous registry select.\n *\n * Note: This control synchronously returns the current selector value, triggering the\n * resolution, but not waiting for it.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector.\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using `select`.\n * export function* myAction() {\n * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );\n * // Do stuff with the result from the `select`.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction select( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering and resolving a registry select.\n *\n * Note: when this control action is handled, it automatically considers\n * selectors that may have a resolver. In such case, it will return a `Promise` that resolves\n * after the selector finishes resolving, with the final result value.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using resolveSelect\n * export function* myAction() {\n * \tconst isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );\n * \t// do stuff with the result from the select.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction resolveSelect( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: RESOLVE_SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering a registry dispatch.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} actionName The name of the action to dispatch\n * @param {Array} args Arguments for the dispatch action.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data-controls';\n *\n * // Action generator using dispatch\n * export function* myAction() {\n * yield controls.dispatch( 'core/editor', 'togglePublishSidebar' );\n * // do some other things.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction dispatch( storeNameOrDescriptor, actionName, ...args ) {\n\treturn {\n\t\ttype: DISPATCH,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tactionName,\n\t\targs,\n\t};\n}\n\nexport const controls = { select, resolveSelect, dispatch };\n\nexport const builtinControls = {\n\t[ SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) =>\n\t\t\t\tregistry.select( storeKey )[ selectorName ]( ...args )\n\t),\n\t[ RESOLVE_SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) => {\n\t\t\t\tconst method = registry.select( storeKey )[ selectorName ]\n\t\t\t\t\t.hasResolver\n\t\t\t\t\t? 'resolveSelect'\n\t\t\t\t\t: 'select';\n\t\t\t\treturn registry[ method ]( storeKey )[ selectorName ](\n\t\t\t\t\t...args\n\t\t\t\t);\n\t\t\t}\n\t),\n\t[ DISPATCH ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, actionName, args } ) =>\n\t\t\t\tregistry.dispatch( storeKey )[ actionName ]( ...args )\n\t),\n};\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;;AAEA,MAAMC,MAAM,GAAG,eAAe;AAC9B,MAAMC,cAAc,GAAG,uBAAuB;AAC9C,MAAMC,QAAQ,GAAG,iBAAiB;AAElC,SAASC,QAAQA,CAAEC,MAAM,EAAG;EAC3B,OAAOA,MAAM,KAAK,IAAI,IAAI,OAAOA,MAAM,KAAK,QAAQ;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,MAAMA,CAAEC,qBAAqB,EAAEC,YAAY,EAAE,GAAGC,IAAI,EAAG;EAC/D,OAAO;IACNC,IAAI,EAAET,MAAM;IACZU,QAAQ,EAAEP,QAAQ,CAAEG,qBAAsB,CAAC,GACxCA,qBAAqB,CAACK,IAAI,GAC1BL,qBAAqB;IACxBC,YAAY;IACZC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,aAAaA,CAAEN,qBAAqB,EAAEC,YAAY,EAAE,GAAGC,IAAI,EAAG;EACtE,OAAO;IACNC,IAAI,EAAER,cAAc;IACpBS,QAAQ,EAAEP,QAAQ,CAAEG,qBAAsB,CAAC,GACxCA,qBAAqB,CAACK,IAAI,GAC1BL,qBAAqB;IACxBC,YAAY;IACZC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,QAAQA,CAAEP,qBAAqB,EAAEQ,UAAU,EAAE,GAAGN,IAAI,EAAG;EAC/D,OAAO;IACNC,IAAI,EAAEP,QAAQ;IACdQ,QAAQ,EAAEP,QAAQ,CAAEG,qBAAsB,CAAC,GACxCA,qBAAqB,CAACK,IAAI,GAC1BL,qBAAqB;IACxBQ,UAAU;IACVN;EACD,CAAC;AACF;AAEO,MAAMO,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG;EAAEV,MAAM;EAAEO,aAAa;EAAEC;AAAS,CAAC;AAEpD,MAAMI,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAG;EAC9B,CAAEjB,MAAM,GAAI,IAAAkB,8BAAqB,EAC9BC,QAAQ,IACT,CAAE;IAAET,QAAQ;IAAEH,YAAY;IAAEC;EAAK,CAAC,KACjCW,QAAQ,CAACd,MAAM,CAAEK,QAAS,CAAC,CAAEH,YAAY,CAAE,CAAE,GAAGC,IAAK,CACxD,CAAC;EACD,CAAEP,cAAc,GAAI,IAAAiB,8BAAqB,EACtCC,QAAQ,IACT,CAAE;IAAET,QAAQ;IAAEH,YAAY;IAAEC;EAAK,CAAC,KAAM;IACvC,MAAMY,MAAM,GAAGD,QAAQ,CAACd,MAAM,CAAEK,QAAS,CAAC,CAAEH,YAAY,CAAE,CACxDc,WAAW,GACV,eAAe,GACf,QAAQ;IACX,OAAOF,QAAQ,CAAEC,MAAM,CAAE,CAAEV,QAAS,CAAC,CAAEH,YAAY,CAAE,CACpD,GAAGC,IACJ,CAAC;EACF,CACF,CAAC;EACD,CAAEN,QAAQ,GAAI,IAAAgB,8BAAqB,EAChCC,QAAQ,IACT,CAAE;IAAET,QAAQ;IAAEI,UAAU;IAAEN;EAAK,CAAC,KAC/BW,QAAQ,CAACN,QAAQ,CAAEH,QAAS,CAAC,CAAEI,UAAU,CAAE,CAAE,GAAGN,IAAK,CACxD;AACD,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/controls.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { createRegistryControl } from './factory';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nconst SELECT = '@@data/SELECT';\nconst RESOLVE_SELECT = '@@data/RESOLVE_SELECT';\nconst DISPATCH = '@@data/DISPATCH';\n\nfunction isObject( object ) {\n\treturn object !== null && typeof object === 'object';\n}\n\n/**\n * Dispatches a control action for triggering a synchronous registry select.\n *\n * Note: This control synchronously returns the current selector value, triggering the\n * resolution, but not waiting for it.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector.\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using `select`.\n * export function* myAction() {\n * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );\n * // Do stuff with the result from the `select`.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction select( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering and resolving a registry select.\n *\n * Note: when this control action is handled, it automatically considers\n * selectors that may have a resolver. In such case, it will return a `Promise` that resolves\n * after the selector finishes resolving, with the final result value.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using resolveSelect\n * export function* myAction() {\n * \tconst isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );\n * \t// do stuff with the result from the select.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction resolveSelect( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: RESOLVE_SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering a registry dispatch.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} actionName The name of the action to dispatch\n * @param {Array} args Arguments for the dispatch action.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data-controls';\n *\n * // Action generator using dispatch\n * export function* myAction() {\n * yield controls.dispatch( 'core/editor', 'togglePublishSidebar' );\n * // do some other things.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction dispatch( storeNameOrDescriptor, actionName, ...args ) {\n\treturn {\n\t\ttype: DISPATCH,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tactionName,\n\t\targs,\n\t};\n}\n\nexport const controls = { select, resolveSelect, dispatch };\n\nexport const builtinControls = {\n\t[ SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) =>\n\t\t\t\tregistry.select( storeKey )[ selectorName ]( ...args )\n\t),\n\t[ RESOLVE_SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) => {\n\t\t\t\tconst method = registry.select( storeKey )[ selectorName ]\n\t\t\t\t\t.hasResolver\n\t\t\t\t\t? 'resolveSelect'\n\t\t\t\t\t: 'select';\n\t\t\t\treturn registry[ method ]( storeKey )[ selectorName ](\n\t\t\t\t\t...args\n\t\t\t\t);\n\t\t\t}\n\t),\n\t[ DISPATCH ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, actionName, args } ) =>\n\t\t\t\tregistry.dispatch( storeKey )[ actionName ]( ...args )\n\t),\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAsC;AAItC,MAAM,SAAS;AACf,MAAM,iBAAiB;AACvB,MAAM,WAAW;AAEjB,SAAS,SAAU,QAAS;AAC3B,SAAO,WAAW,QAAQ,OAAO,WAAW;AAC7C;AAyBA,SAAS,OAAQ,uBAAuB,iBAAiB,MAAO;AAC/D,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU,SAAU,qBAAsB,IACvC,sBAAsB,OACtB;AAAA,IACH;AAAA,IACA;AAAA,EACD;AACD;AA0BA,SAAS,cAAe,uBAAuB,iBAAiB,MAAO;AACtE,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU,SAAU,qBAAsB,IACvC,sBAAsB,OACtB;AAAA,IACH;AAAA,IACA;AAAA,EACD;AACD;AAsBA,SAAS,SAAU,uBAAuB,eAAe,MAAO;AAC/D,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU,SAAU,qBAAsB,IACvC,sBAAsB,OACtB;AAAA,IACH;AAAA,IACA;AAAA,EACD;AACD;AAEO,MAAM,WAAW,EAAE,QAAQ,eAAe,SAAS;AAEnD,MAAM,kBAAkB;AAAA,EAC9B,CAAE,MAAO,OAAG;AAAA,IACX,CAAE,aACD,CAAE,EAAE,UAAU,cAAc,KAAK,MAChC,SAAS,OAAQ,QAAS,EAAG,YAAa,EAAG,GAAG,IAAK;AAAA,EACxD;AAAA,EACA,CAAE,cAAe,OAAG;AAAA,IACnB,CAAE,aACD,CAAE,EAAE,UAAU,cAAc,KAAK,MAAO;AACvC,YAAM,SAAS,SAAS,OAAQ,QAAS,EAAG,YAAa,EACvD,cACC,kBACA;AACH,aAAO,SAAU,MAAO,EAAG,QAAS,EAAG,YAAa;AAAA,QACnD,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,EACF;AAAA,EACA,CAAE,QAAS,OAAG;AAAA,IACb,CAAE,aACD,CAAE,EAAE,UAAU,YAAY,KAAK,MAC9B,SAAS,SAAU,QAAS,EAAG,UAAW,EAAG,GAAG,IAAK;AAAA,EACxD;AACD;",
6
+ "names": []
7
+ }
@@ -1,14 +1,39 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "createSelector", {
8
- enumerable: true,
9
- get: function () {
10
- return _rememo.default;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var create_selector_exports = {};
30
+ __export(create_selector_exports, {
31
+ createSelector: () => import_rememo.default
32
+ });
33
+ module.exports = __toCommonJS(create_selector_exports);
34
+ var import_rememo = __toESM(require("rememo"));
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ createSelector
12
38
  });
13
- var _rememo = _interopRequireDefault(require("rememo"));
14
- //# sourceMappingURL=create-selector.js.map
39
+ //# sourceMappingURL=create-selector.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_rememo","_interopRequireDefault","require"],"sources":["@wordpress/data/src/create-selector.ts"],"sourcesContent":["/**\n * Creates a memoized selector that caches the computed values according to the array of \"dependants\"\n * and the selector parameters, and recomputes the values only when any of them changes.\n *\n * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.\n */\nexport { default as createSelector } from 'rememo';\n"],"mappings":";;;;;;;;;;;;AAMA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/create-selector.ts"],
4
+ "sourcesContent": ["/**\n * Creates a memoized selector that caches the computed values according to the array of \"dependants\"\n * and the selector parameters, and recomputes the values only when any of them changes.\n *\n * @see The documentation for the `rememo` package from which the `createSelector` function is reexported.\n */\nexport { default as createSelector } from 'rememo';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAA0C;",
6
+ "names": []
7
+ }
@@ -1,12 +1,26 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var default_registry_exports = {};
20
+ __export(default_registry_exports, {
21
+ default: () => default_registry_default
5
22
  });
6
- exports.default = void 0;
7
- var _registry = require("./registry");
8
- /**
9
- * Internal dependencies
10
- */
11
- var _default = exports.default = (0, _registry.createRegistry)();
12
- //# sourceMappingURL=default-registry.js.map
23
+ module.exports = __toCommonJS(default_registry_exports);
24
+ var import_registry = require("./registry");
25
+ var default_registry_default = (0, import_registry.createRegistry)();
26
+ //# sourceMappingURL=default-registry.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_registry","require","_default","exports","default","createRegistry"],"sources":["@wordpress/data/src/default-registry.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createRegistry } from './registry';\n\nexport default createRegistry();\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAHA;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAKe,IAAAC,wBAAc,EAAC,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/default-registry.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { createRegistry } from './registry';\n\nexport default createRegistry();\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAA+B;AAE/B,IAAO,+BAAQ,gCAAe;",
6
+ "names": []
7
+ }
package/build/dispatch.js CHANGED
@@ -1,35 +1,42 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var dispatch_exports = {};
30
+ __export(dispatch_exports, {
31
+ dispatch: () => dispatch
6
32
  });
7
- exports.dispatch = dispatch;
8
- var _defaultRegistry = _interopRequireDefault(require("./default-registry"));
9
- /**
10
- * Internal dependencies
11
- */
12
-
13
- /**
14
- * Given a store descriptor, returns an object of the store's action creators.
15
- * Calling an action creator will cause it to be dispatched, updating the state value accordingly.
16
- *
17
- * Note: Action creators returned by the dispatch will return a promise when
18
- * they are called.
19
- *
20
- * @param storeNameOrDescriptor The store descriptor. The legacy calling convention of passing
21
- * the store name is also supported.
22
- *
23
- * @example
24
- * ```js
25
- * import { dispatch } from '@wordpress/data';
26
- * import { store as myCustomStore } from 'my-custom-store';
27
- *
28
- * dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
29
- * ```
30
- * @return Object containing the action creators.
31
- */
33
+ module.exports = __toCommonJS(dispatch_exports);
34
+ var import_default_registry = __toESM(require("./default-registry"));
32
35
  function dispatch(storeNameOrDescriptor) {
33
- return _defaultRegistry.default.dispatch(storeNameOrDescriptor);
36
+ return import_default_registry.default.dispatch(storeNameOrDescriptor);
34
37
  }
35
- //# sourceMappingURL=dispatch.js.map
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ dispatch
41
+ });
42
+ //# sourceMappingURL=dispatch.js.map
@@ -1 +1,7 @@
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","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/dispatch.ts"],
4
+ "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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAA4B;AAqBrB,SAAS,SAGf,uBAC0C;AAC1C,SAAO,wBAAAA,QAAgB,SAAU,qBAAsB;AACxD;",
6
+ "names": ["defaultRegistry"]
7
+ }
package/build/factory.js CHANGED
@@ -1,103 +1,47 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var factory_exports = {};
20
+ __export(factory_exports, {
21
+ createRegistryControl: () => createRegistryControl,
22
+ createRegistrySelector: () => createRegistrySelector
5
23
  });
6
- exports.createRegistryControl = createRegistryControl;
7
- exports.createRegistrySelector = createRegistrySelector;
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- /**
13
- * Creates a selector function that takes additional curried argument with the
14
- * registry `select` function. While a regular selector has signature
15
- * ```js
16
- * ( state, ...selectorArgs ) => ( result )
17
- * ```
18
- * that allows to select data from the store's `state`, a registry selector
19
- * has signature:
20
- * ```js
21
- * ( select ) => ( state, ...selectorArgs ) => ( result )
22
- * ```
23
- * that supports also selecting from other registered stores.
24
- *
25
- * @example
26
- * ```js
27
- * import { store as coreStore } from '@wordpress/core-data';
28
- * import { store as editorStore } from '@wordpress/editor';
29
- *
30
- * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => {
31
- * return select( editorStore ).getCurrentPostId();
32
- * } );
33
- *
34
- * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {
35
- * // calling another registry selector just like any other function
36
- * const postType = getCurrentPostType( state );
37
- * const postId = getCurrentPostId( state );
38
- * return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId );
39
- * } );
40
- * ```
41
- *
42
- * Note how the `getCurrentPostId` selector can be called just like any other function,
43
- * (it works even inside a regular non-registry selector) and we don't need to pass the
44
- * registry as argument. The registry binding happens automatically when registering the selector
45
- * with a store.
46
- *
47
- * @param registrySelector Function receiving a registry `select`
48
- * function and returning a state selector.
49
- *
50
- * @return Registry selector that can be registered with a store.
51
- */
24
+ module.exports = __toCommonJS(factory_exports);
52
25
  function createRegistrySelector(registrySelector) {
53
- const selectorsByRegistry = new WeakMap();
54
- // Create a selector function that is bound to the registry referenced by `selector.registry`
55
- // and that has the same API as a regular selector. Binding it in such a way makes it
56
- // possible to call the selector directly from another selector.
26
+ const selectorsByRegistry = /* @__PURE__ */ new WeakMap();
57
27
  const wrappedSelector = (...args) => {
58
28
  let selector = selectorsByRegistry.get(wrappedSelector.registry);
59
- // We want to make sure the cache persists even when new registry
60
- // instances are created. For example patterns create their own editors
61
- // with their own core/block-editor stores, so we should keep track of
62
- // the cache for each registry instance.
63
29
  if (!selector) {
64
30
  selector = registrySelector(wrappedSelector.registry.select);
65
31
  selectorsByRegistry.set(wrappedSelector.registry, selector);
66
32
  }
67
33
  return selector(...args);
68
34
  };
69
-
70
- /**
71
- * Flag indicating that the selector is a registry selector that needs the correct registry
72
- * reference to be assigned to `selector.registry` to make it work correctly.
73
- * be mapped as a registry selector.
74
- */
75
35
  wrappedSelector.isRegistrySelector = true;
76
36
  return wrappedSelector;
77
37
  }
78
-
79
- /**
80
- * Creates a control function that takes additional curried argument with the `registry` object.
81
- * While a regular control has signature
82
- * ```js
83
- * ( action ) => ( iteratorOrPromise )
84
- * ```
85
- * where the control works with the `action` that it's bound to, a registry control has signature:
86
- * ```js
87
- * ( registry ) => ( action ) => ( iteratorOrPromise )
88
- * ```
89
- * A registry control is typically used to select data or dispatch an action to a registered
90
- * store.
91
- *
92
- * When registering a control created with `createRegistryControl` with a store, the store
93
- * knows which calling convention to use when executing the control.
94
- *
95
- * @param registryControl Function receiving a registry object and returning a control.
96
- *
97
- * @return Registry control that can be registered with a store.
98
- */
99
38
  function createRegistryControl(registryControl) {
100
39
  registryControl.isRegistryControl = true;
101
40
  return registryControl;
102
41
  }
103
- //# sourceMappingURL=factory.js.map
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ createRegistryControl,
45
+ createRegistrySelector
46
+ });
47
+ //# sourceMappingURL=factory.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createRegistrySelector","registrySelector","selectorsByRegistry","WeakMap","wrappedSelector","args","selector","get","registry","select","set","isRegistrySelector","createRegistryControl","registryControl","isRegistryControl"],"sources":["@wordpress/data/src/factory.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { select as globalSelect } from './select';\n\ntype RegistrySelector< Selector extends ( ...args: any[] ) => any > = {\n\t( ...args: Parameters< Selector > ): ReturnType< Selector >;\n\tisRegistrySelector?: boolean;\n\tregistry?: any;\n};\n\n/**\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 registrySelector Function receiving a registry `select`\n * function and returning a state selector.\n *\n * @return Registry selector that can be registered with a store.\n */\nexport function createRegistrySelector<\n\tSelector extends ( ...args: any[] ) => any,\n>(\n\tregistrySelector: ( select: typeof globalSelect ) => Selector\n): RegistrySelector< Selector > {\n\tconst selectorsByRegistry = new WeakMap();\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 wrappedSelector: RegistrySelector< Selector > = ( ...args ) => {\n\t\tlet selector = selectorsByRegistry.get( wrappedSelector.registry );\n\t\t// We want to make sure the cache persists even when new registry\n\t\t// instances are created. For example patterns create their own editors\n\t\t// with their own core/block-editor stores, so we should keep track of\n\t\t// the cache for each registry instance.\n\t\tif ( ! selector ) {\n\t\t\tselector = registrySelector( wrappedSelector.registry.select );\n\t\t\tselectorsByRegistry.set( wrappedSelector.registry, selector );\n\t\t}\n\t\treturn selector( ...args );\n\t};\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\twrappedSelector.isRegistrySelector = true;\n\n\treturn wrappedSelector;\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 registryControl Function receiving a registry object and returning a control.\n *\n * @return Registry control that can be registered with a store.\n */\nexport function createRegistryControl< T extends ( ...args: any ) => any >(\n\tregistryControl: T & { isRegistryControl?: boolean }\n) {\n\tregistryControl.isRegistryControl = true;\n\n\treturn registryControl;\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,CAGrCC,gBAA6D,EAC9B;EAC/B,MAAMC,mBAAmB,GAAG,IAAIC,OAAO,CAAC,CAAC;EACzC;EACA;EACA;EACA,MAAMC,eAA6C,GAAGA,CAAE,GAAGC,IAAI,KAAM;IACpE,IAAIC,QAAQ,GAAGJ,mBAAmB,CAACK,GAAG,CAAEH,eAAe,CAACI,QAAS,CAAC;IAClE;IACA;IACA;IACA;IACA,IAAK,CAAEF,QAAQ,EAAG;MACjBA,QAAQ,GAAGL,gBAAgB,CAAEG,eAAe,CAACI,QAAQ,CAACC,MAAO,CAAC;MAC9DP,mBAAmB,CAACQ,GAAG,CAAEN,eAAe,CAACI,QAAQ,EAAEF,QAAS,CAAC;IAC9D;IACA,OAAOA,QAAQ,CAAE,GAAGD,IAAK,CAAC;EAC3B,CAAC;;EAED;AACD;AACA;AACA;AACA;EACCD,eAAe,CAACO,kBAAkB,GAAG,IAAI;EAEzC,OAAOP,eAAe;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,qBAAqBA,CACpCC,eAAoD,EACnD;EACDA,eAAe,CAACC,iBAAiB,GAAG,IAAI;EAExC,OAAOD,eAAe;AACvB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/factory.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { select as globalSelect } from './select';\n\ntype RegistrySelector< Selector extends ( ...args: any[] ) => any > = {\n\t( ...args: Parameters< Selector > ): ReturnType< Selector >;\n\tisRegistrySelector?: boolean;\n\tregistry?: any;\n};\n\n/**\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 registrySelector Function receiving a registry `select`\n * function and returning a state selector.\n *\n * @return Registry selector that can be registered with a store.\n */\nexport function createRegistrySelector<\n\tSelector extends ( ...args: any[] ) => any,\n>(\n\tregistrySelector: ( select: typeof globalSelect ) => Selector\n): RegistrySelector< Selector > {\n\tconst selectorsByRegistry = new WeakMap();\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 wrappedSelector: RegistrySelector< Selector > = ( ...args ) => {\n\t\tlet selector = selectorsByRegistry.get( wrappedSelector.registry );\n\t\t// We want to make sure the cache persists even when new registry\n\t\t// instances are created. For example patterns create their own editors\n\t\t// with their own core/block-editor stores, so we should keep track of\n\t\t// the cache for each registry instance.\n\t\tif ( ! selector ) {\n\t\t\tselector = registrySelector( wrappedSelector.registry.select );\n\t\t\tselectorsByRegistry.set( wrappedSelector.registry, selector );\n\t\t}\n\t\treturn selector( ...args );\n\t};\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\twrappedSelector.isRegistrySelector = true;\n\n\treturn wrappedSelector;\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 registryControl Function receiving a registry object and returning a control.\n *\n * @return Registry control that can be registered with a store.\n */\nexport function createRegistryControl< T extends ( ...args: any ) => any >(\n\tregistryControl: T & { isRegistryControl?: boolean }\n) {\n\tregistryControl.isRegistryControl = true;\n\n\treturn registryControl;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDO,SAAS,uBAGf,kBAC+B;AAC/B,QAAM,sBAAsB,oBAAI,QAAQ;AAIxC,QAAM,kBAAgD,IAAK,SAAU;AACpE,QAAI,WAAW,oBAAoB,IAAK,gBAAgB,QAAS;AAKjE,QAAK,CAAE,UAAW;AACjB,iBAAW,iBAAkB,gBAAgB,SAAS,MAAO;AAC7D,0BAAoB,IAAK,gBAAgB,UAAU,QAAS;AAAA,IAC7D;AACA,WAAO,SAAU,GAAG,IAAK;AAAA,EAC1B;AAOA,kBAAgB,qBAAqB;AAErC,SAAO;AACR;AAsBO,SAAS,sBACf,iBACC;AACD,kBAAgB,oBAAoB;AAEpC,SAAO;AACR;",
6
+ "names": []
7
+ }