@wordpress/data 9.4.0 → 9.5.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 (50) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/use-dispatch/use-dispatch-with-map.js +2 -6
  3. package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  4. package/build/components/use-select/index.js +1 -1
  5. package/build/components/use-select/index.js.map +1 -1
  6. package/build/controls.js +18 -37
  7. package/build/controls.js.map +1 -1
  8. package/build/factory.js +1 -3
  9. package/build/factory.js.map +1 -1
  10. package/build/redux-store/index.js +100 -197
  11. package/build/redux-store/index.js.map +1 -1
  12. package/build/redux-store/metadata/reducer.js +2 -8
  13. package/build/redux-store/metadata/reducer.js.map +1 -1
  14. package/build/redux-store/metadata/selectors.js +5 -15
  15. package/build/redux-store/metadata/selectors.js.map +1 -1
  16. package/build/redux-store/metadata/utils.js +1 -3
  17. package/build/redux-store/metadata/utils.js.map +1 -1
  18. package/build/registry.js +8 -18
  19. package/build/registry.js.map +1 -1
  20. package/build/resolvers-cache-middleware.js +3 -6
  21. package/build/resolvers-cache-middleware.js.map +1 -1
  22. package/build/store/index.js +2 -10
  23. package/build/store/index.js.map +1 -1
  24. package/build-module/components/use-dispatch/use-dispatch-with-map.js +2 -6
  25. package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
  26. package/build-module/components/use-select/index.js +1 -1
  27. package/build-module/components/use-select/index.js.map +1 -1
  28. package/build-module/controls.js +18 -37
  29. package/build-module/controls.js.map +1 -1
  30. package/build-module/factory.js +1 -3
  31. package/build-module/factory.js.map +1 -1
  32. package/build-module/redux-store/index.js +100 -197
  33. package/build-module/redux-store/index.js.map +1 -1
  34. package/build-module/redux-store/metadata/reducer.js +2 -8
  35. package/build-module/redux-store/metadata/reducer.js.map +1 -1
  36. package/build-module/redux-store/metadata/selectors.js +5 -15
  37. package/build-module/redux-store/metadata/selectors.js.map +1 -1
  38. package/build-module/redux-store/metadata/utils.js +1 -3
  39. package/build-module/redux-store/metadata/utils.js.map +1 -1
  40. package/build-module/registry.js +8 -18
  41. package/build-module/registry.js.map +1 -1
  42. package/build-module/resolvers-cache-middleware.js +3 -6
  43. package/build-module/resolvers-cache-middleware.js.map +1 -1
  44. package/build-module/store/index.js +2 -10
  45. package/build-module/store/index.js.map +1 -1
  46. package/build-types/redux-store/index.d.ts.map +1 -1
  47. package/package.json +9 -9
  48. package/src/redux-store/index.js +129 -208
  49. package/src/test/privateAPIs.js +31 -0
  50. package/tsconfig.tsbuildinfo +1 -1
@@ -36,11 +36,7 @@ function isObject(object) {
36
36
  */
37
37
 
38
38
 
39
- function select(storeNameOrDescriptor, selectorName) {
40
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
41
- args[_key - 2] = arguments[_key];
42
- }
43
-
39
+ function select(storeNameOrDescriptor, selectorName, ...args) {
44
40
  return {
45
41
  type: SELECT,
46
42
  storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
@@ -74,11 +70,7 @@ function select(storeNameOrDescriptor, selectorName) {
74
70
  */
75
71
 
76
72
 
77
- function resolveSelect(storeNameOrDescriptor, selectorName) {
78
- for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
79
- args[_key2 - 2] = arguments[_key2];
80
- }
81
-
73
+ function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
82
74
  return {
83
75
  type: RESOLVE_SELECT,
84
76
  storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
@@ -108,11 +100,7 @@ function resolveSelect(storeNameOrDescriptor, selectorName) {
108
100
  */
109
101
 
110
102
 
111
- function dispatch(storeNameOrDescriptor, actionName) {
112
- for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
113
- args[_key3 - 2] = arguments[_key3];
114
- }
115
-
103
+ function dispatch(storeNameOrDescriptor, actionName, ...args) {
116
104
  return {
117
105
  type: DISPATCH,
118
106
  storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
@@ -127,30 +115,23 @@ export const controls = {
127
115
  dispatch
128
116
  };
129
117
  export const builtinControls = {
130
- [SELECT]: createRegistryControl(registry => _ref => {
131
- let {
132
- storeKey,
133
- selectorName,
134
- args
135
- } = _ref;
136
- return registry.select(storeKey)[selectorName](...args);
137
- }),
138
- [RESOLVE_SELECT]: createRegistryControl(registry => _ref2 => {
139
- let {
140
- storeKey,
141
- selectorName,
142
- args
143
- } = _ref2;
118
+ [SELECT]: createRegistryControl(registry => ({
119
+ storeKey,
120
+ selectorName,
121
+ args
122
+ }) => registry.select(storeKey)[selectorName](...args)),
123
+ [RESOLVE_SELECT]: createRegistryControl(registry => ({
124
+ storeKey,
125
+ selectorName,
126
+ args
127
+ }) => {
144
128
  const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select';
145
129
  return registry[method](storeKey)[selectorName](...args);
146
130
  }),
147
- [DISPATCH]: createRegistryControl(registry => _ref3 => {
148
- let {
149
- storeKey,
150
- actionName,
151
- args
152
- } = _ref3;
153
- return registry.dispatch(storeKey)[actionName](...args);
154
- })
131
+ [DISPATCH]: createRegistryControl(registry => ({
132
+ storeKey,
133
+ actionName,
134
+ args
135
+ }) => registry.dispatch(storeKey)[actionName](...args))
155
136
  };
156
137
  //# sourceMappingURL=controls.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/controls.js"],"names":["createRegistryControl","SELECT","RESOLVE_SELECT","DISPATCH","isObject","object","select","storeNameOrDescriptor","selectorName","args","type","storeKey","name","resolveSelect","dispatch","actionName","controls","builtinControls","registry","method","hasResolver"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,qBAAT,QAAsC,WAAtC;AAEA;;AAEA,MAA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port { createRegistryControl } from './factory';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nconst SELECT = '@@data/SELECT';\nconst RESOLVE_SELECT = '@@data/RESOLVE_SELECT';\nconst DISPATCH = '@@data/DISPATCH';\n\nfunction isObject( object ) {\n\treturn object !== null && typeof object === 'object';\n}\n\n/**\n * Dispatches a control action for triggering a synchronous registry select.\n *\n * Note: This control synchronously returns the current selector value, triggering the\n * resolution, but not waiting for it.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector.\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using `select`.\n * export function* myAction() {\n * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );\n * // Do stuff with the result from the `select`.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction select( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering and resolving a registry select.\n *\n * Note: when this control action is handled, it automatically considers\n * selectors that may have a resolver. In such case, it will return a `Promise` that resolves\n * after the selector finishes resolving, with the final result value.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using resolveSelect\n * export function* myAction() {\n * \tconst isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );\n * \t// do stuff with the result from the select.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction resolveSelect( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: RESOLVE_SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering a registry dispatch.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} actionName The name of the action to dispatch\n * @param {Array} args Arguments for the dispatch action.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data-controls';\n *\n * // Action generator using dispatch\n * export function* myAction() {\n * yield controls.dispatch( 'core/edit-post', 'togglePublishSidebar' );\n * // do some other things.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction dispatch( storeNameOrDescriptor, actionName, ...args ) {\n\treturn {\n\t\ttype: DISPATCH,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tactionName,\n\t\targs,\n\t};\n}\n\nexport const controls = { select, resolveSelect, dispatch };\n\nexport const builtinControls = {\n\t[ SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) =>\n\t\t\t\tregistry.select( storeKey )[ selectorName ]( ...args )\n\t),\n\t[ RESOLVE_SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) => {\n\t\t\t\tconst method = registry.select( storeKey )[ selectorName ]\n\t\t\t\t\t.hasResolver\n\t\t\t\t\t? 'resolveSelect'\n\t\t\t\t\t: 'select';\n\t\t\t\treturn registry[ method ]( storeKey )[ selectorName ](\n\t\t\t\t\t...args\n\t\t\t\t);\n\t\t\t}\n\t),\n\t[ DISPATCH ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, actionName, args } ) =>\n\t\t\t\tregistry.dispatch( storeKey )[ actionName ]( ...args )\n\t),\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/data/src/controls.js"],"names":["createRegistryControl","SELECT","RESOLVE_SELECT","DISPATCH","isObject","object","select","storeNameOrDescriptor","selectorName","args","type","storeKey","name","resolveSelect","dispatch","actionName","controls","builtinControls","registry","method","hasResolver"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,qBAAT,QAAsC,WAAtC;AAEA;;AAEA,MAAMC,MAAM,GAAG,eAAf;AACA,MAAMC,cAAc,GAAG,uBAAvB;AACA,MAAMC,QAAQ,GAAG,iBAAjB;;AAEA,SAASC,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,SAAOA,MAAM,KAAK,IAAX,IAAmB,OAAOA,MAAP,KAAkB,QAA5C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,MAAT,CAAiBC,qBAAjB,EAAwCC,YAAxC,EAAsD,GAAGC,IAAzD,EAAgE;AAC/D,SAAO;AACNC,IAAAA,IAAI,EAAET,MADA;AAENU,IAAAA,QAAQ,EAAEP,QAAQ,CAAEG,qBAAF,CAAR,GACPA,qBAAqB,CAACK,IADf,GAEPL,qBAJG;AAKNC,IAAAA,YALM;AAMNC,IAAAA;AANM,GAAP;AAQA;AAED;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,aAAT,CAAwBN,qBAAxB,EAA+CC,YAA/C,EAA6D,GAAGC,IAAhE,EAAuE;AACtE,SAAO;AACNC,IAAAA,IAAI,EAAER,cADA;AAENS,IAAAA,QAAQ,EAAEP,QAAQ,CAAEG,qBAAF,CAAR,GACPA,qBAAqB,CAACK,IADf,GAEPL,qBAJG;AAKNC,IAAAA,YALM;AAMNC,IAAAA;AANM,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AAhD,CAHgC;AAlBL,CAAxB","sourcesContent":["/**\n * Internal dependencies\n */\nimport { createRegistryControl } from './factory';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\n\nconst SELECT = '@@data/SELECT';\nconst RESOLVE_SELECT = '@@data/RESOLVE_SELECT';\nconst DISPATCH = '@@data/DISPATCH';\n\nfunction isObject( object ) {\n\treturn object !== null && typeof object === 'object';\n}\n\n/**\n * Dispatches a control action for triggering a synchronous registry select.\n *\n * Note: This control synchronously returns the current selector value, triggering the\n * resolution, but not waiting for it.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector.\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using `select`.\n * export function* myAction() {\n * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );\n * // Do stuff with the result from the `select`.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction select( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering and resolving a registry select.\n *\n * Note: when this control action is handled, it automatically considers\n * selectors that may have a resolver. In such case, it will return a `Promise` that resolves\n * after the selector finishes resolving, with the final result value.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} selectorName The name of the selector\n * @param {Array} args Arguments for the selector.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data';\n *\n * // Action generator using resolveSelect\n * export function* myAction() {\n * \tconst isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );\n * \t// do stuff with the result from the select.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction resolveSelect( storeNameOrDescriptor, selectorName, ...args ) {\n\treturn {\n\t\ttype: RESOLVE_SELECT,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tselectorName,\n\t\targs,\n\t};\n}\n\n/**\n * Dispatches a control action for triggering a registry dispatch.\n *\n * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n * @param {string} actionName The name of the action to dispatch\n * @param {Array} args Arguments for the dispatch action.\n *\n * @example\n * ```js\n * import { controls } from '@wordpress/data-controls';\n *\n * // Action generator using dispatch\n * export function* myAction() {\n * yield controls.dispatch( 'core/edit-post', 'togglePublishSidebar' );\n * // do some other things.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nfunction dispatch( storeNameOrDescriptor, actionName, ...args ) {\n\treturn {\n\t\ttype: DISPATCH,\n\t\tstoreKey: isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor,\n\t\tactionName,\n\t\targs,\n\t};\n}\n\nexport const controls = { select, resolveSelect, dispatch };\n\nexport const builtinControls = {\n\t[ SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) =>\n\t\t\t\tregistry.select( storeKey )[ selectorName ]( ...args )\n\t),\n\t[ RESOLVE_SELECT ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, selectorName, args } ) => {\n\t\t\t\tconst method = registry.select( storeKey )[ selectorName ]\n\t\t\t\t\t.hasResolver\n\t\t\t\t\t? 'resolveSelect'\n\t\t\t\t\t: 'select';\n\t\t\t\treturn registry[ method ]( storeKey )[ selectorName ](\n\t\t\t\t\t...args\n\t\t\t\t);\n\t\t\t}\n\t),\n\t[ DISPATCH ]: createRegistryControl(\n\t\t( registry ) =>\n\t\t\t( { storeKey, actionName, args } ) =>\n\t\t\t\tregistry.dispatch( storeKey )[ actionName ]( ...args )\n\t),\n};\n"]}
@@ -42,9 +42,7 @@ export function createRegistrySelector(registrySelector) {
42
42
  // Create a selector function that is bound to the registry referenced by `selector.registry`
43
43
  // and that has the same API as a regular selector. Binding it in such a way makes it
44
44
  // possible to call the selector directly from another selector.
45
- const selector = function () {
46
- return registrySelector(selector.registry.select)(...arguments);
47
- };
45
+ const selector = (...args) => registrySelector(selector.registry.select)(...args);
48
46
  /**
49
47
  * Flag indicating that the selector is a registry selector that needs the correct registry
50
48
  * reference to be assigned to `selecto.registry` to make it work correctly.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data/src/factory.js"],"names":["createRegistrySelector","registrySelector","selector","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;AACA,OAAO,SAASA,sBAAT,CAAiCC,gBAAjC,EAAoD;AAC1D;AACA;AACA;AACA,QAAMC,QAAQ,GAAG;AAAA,WAChBD,gBAAgB,CAAEC,QAAQ,CAACC,QAAT,CAAkBC,MAApB,CAAhB,CAA8C,YAA9C,CADgB;AAAA,GAAjB;AAGA;AACD;AACA;AACA;AACA;AACA;AACA;;;AACCF,EAAAA,QAAQ,CAACG,kBAAT,GAA8B,IAA9B;AAEA,SAAOH,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,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 `selecto.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,"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;AACA,OAAO,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;;AACA,OAAO,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 `selecto.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"]}
@@ -57,12 +57,7 @@ const trimUndefinedValues = array => {
57
57
  */
58
58
 
59
59
 
60
- const mapValues = (obj, callback) => Object.entries(obj !== null && obj !== void 0 ? obj : {}).reduce((acc, _ref) => {
61
- let [key, value] = _ref;
62
- return { ...acc,
63
- [key]: callback(value, key)
64
- };
65
- }, {}); // Convert Map objects to plain objects
60
+ const mapValues = (obj, callback) => Object.fromEntries(Object.entries(obj !== null && obj !== void 0 ? obj : {}).map(([key, value]) => [key, callback(value, key)])); // Convert Map objects to plain objects
66
61
 
67
62
 
68
63
  const mapToObject = (key, state) => {
@@ -168,60 +163,63 @@ export default function createReduxStore(key, options) {
168
163
 
169
164
  lock(store, privateRegistrationFunctions);
170
165
  const resolversCache = createResolversCache();
171
- let resolvers;
172
- const actions = mapActions({ ...metadataActions,
173
- ...options.actions
174
- }, store);
166
+
167
+ function bindAction(action) {
168
+ return (...args) => Promise.resolve(store.dispatch(action(...args)));
169
+ }
170
+
171
+ const actions = { ...mapValues(metadataActions, bindAction),
172
+ ...mapValues(options.actions, bindAction)
173
+ };
175
174
  lock(actions, new Proxy(privateActions, {
176
175
  get: (target, prop) => {
177
- return mapActions(privateActions, store)[prop] || actions[prop];
176
+ const privateAction = privateActions[prop];
177
+ return privateAction ? bindAction(privateAction) : actions[prop];
178
178
  }
179
179
  }));
180
- let selectors = mapSelectors({ ...mapValues(metadataSelectors, selector => function (state) {
181
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
182
- args[_key - 1] = arguments[_key];
183
- }
180
+
181
+ function bindSelector(selector) {
182
+ if (selector.isRegistrySelector) {
183
+ selector.registry = registry;
184
+ }
185
+
186
+ const boundSelector = (...args) => {
187
+ const state = store.__unstableOriginalGetState();
188
+
189
+ return selector(state.root, ...args);
190
+ };
191
+
192
+ boundSelector.hasResolver = false;
193
+ return boundSelector;
194
+ }
195
+
196
+ function bindMetadataSelector(selector) {
197
+ const boundSelector = (...args) => {
198
+ const state = store.__unstableOriginalGetState();
184
199
 
185
200
  return selector(state.metadata, ...args);
186
- }),
187
- ...mapValues(options.selectors, selector => {
188
- if (selector.isRegistrySelector) {
189
- selector.registry = registry;
190
- }
201
+ };
191
202
 
192
- return function (state) {
193
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
194
- args[_key2 - 1] = arguments[_key2];
195
- }
203
+ boundSelector.hasResolver = false;
204
+ return boundSelector;
205
+ }
196
206
 
197
- return selector(state.root, ...args);
198
- };
199
- })
200
- }, store);
201
- lock(selectors, new Proxy(privateSelectors, {
202
- get: (target, prop) => {
203
- return mapSelectors(mapValues(privateSelectors, selector => {
204
- if (selector.isRegistrySelector) {
205
- selector.registry = registry;
206
- }
207
-
208
- return function (state) {
209
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
210
- args[_key3 - 1] = arguments[_key3];
211
- }
212
-
213
- return selector(state.root, ...args);
214
- };
215
- }), store)[prop] || selectors[prop];
216
- }
217
- }));
207
+ let selectors = { ...mapValues(metadataSelectors, bindMetadataSelector),
208
+ ...mapValues(options.selectors, bindSelector)
209
+ };
210
+ let resolvers;
218
211
 
219
212
  if (options.resolvers) {
220
- const result = mapResolvers(options.resolvers, selectors, store, resolversCache);
221
- resolvers = result.resolvers;
222
- selectors = result.selectors;
213
+ resolvers = mapResolvers(options.resolvers);
214
+ selectors = mapSelectorsWithResolvers(selectors, resolvers, store, resolversCache);
223
215
  }
224
216
 
217
+ lock(selectors, new Proxy(privateSelectors, {
218
+ get: (target, prop) => {
219
+ const privateSelector = privateSelectors[prop];
220
+ return privateSelector ? bindSelector(privateSelector) : selectors[prop];
221
+ }
222
+ }));
225
223
  const resolveSelectors = mapResolveSelectors(selectors, store);
226
224
  const suspendSelectors = mapSuspendSelectors(selectors, store);
227
225
 
@@ -321,61 +319,6 @@ function instantiateReduxStore(key, options, registry, thunkArgs) {
321
319
  root: initialState
322
320
  }, compose(enhancers));
323
321
  }
324
- /**
325
- * Maps selectors to a store.
326
- *
327
- * @param {Object} selectors Selectors to register. Keys will be used as the
328
- * public facing API. Selectors will get passed the
329
- * state as first argument.
330
- * @param {Object} store The store to which the selectors should be mapped.
331
- * @return {Object} Selectors mapped to the provided store.
332
- */
333
-
334
-
335
- function mapSelectors(selectors, store) {
336
- const createStateSelector = registrySelector => {
337
- const selector = function runSelector() {
338
- // This function is an optimized implementation of:
339
- //
340
- // selector( store.getState(), ...arguments )
341
- //
342
- // Where the above would incur an `Array#concat` in its application,
343
- // the logic here instead efficiently constructs an arguments array via
344
- // direct assignment.
345
- const argsLength = arguments.length;
346
- const args = new Array(argsLength + 1);
347
- args[0] = store.__unstableOriginalGetState();
348
-
349
- for (let i = 0; i < argsLength; i++) {
350
- args[i + 1] = arguments[i];
351
- }
352
-
353
- return registrySelector(...args);
354
- };
355
-
356
- selector.hasResolver = false;
357
- return selector;
358
- };
359
-
360
- return mapValues(selectors, createStateSelector);
361
- }
362
- /**
363
- * Maps actions to dispatch from a given store.
364
- *
365
- * @param {Object} actions Actions to register.
366
- * @param {Object} store The redux store to which the actions should be mapped.
367
- *
368
- * @return {Object} Actions mapped to the redux store provided.
369
- */
370
-
371
-
372
- function mapActions(actions, store) {
373
- const createBoundAction = action => function () {
374
- return Promise.resolve(store.dispatch(action(...arguments)));
375
- };
376
-
377
- return mapValues(actions, createBoundAction);
378
- }
379
322
  /**
380
323
  * Maps selectors to functions that return a resolution promise for them
381
324
  *
@@ -402,20 +345,10 @@ function mapResolveSelectors(selectors, store) {
402
345
  // If the selector doesn't have a resolver, just convert the return value
403
346
  // (including exceptions) to a Promise, no additional extra behavior is needed.
404
347
  if (!selector.hasResolver) {
405
- return async function () {
406
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
407
- args[_key4] = arguments[_key4];
408
- }
409
-
410
- return selector.apply(null, args);
411
- };
348
+ return async (...args) => selector.apply(null, args);
412
349
  }
413
350
 
414
- return function () {
415
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
416
- args[_key5] = arguments[_key5];
417
- }
418
-
351
+ return (...args) => {
419
352
  return new Promise((resolve, reject) => {
420
353
  const hasFinished = () => selectors.hasFinishedResolution(selectorName, args);
421
354
 
@@ -466,11 +399,7 @@ function mapSuspendSelectors(selectors, store) {
466
399
  return selector;
467
400
  }
468
401
 
469
- return function () {
470
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
471
- args[_key6] = arguments[_key6];
472
- }
473
-
402
+ return (...args) => {
474
403
  const result = selector.apply(null, args);
475
404
 
476
405
  if (selectors.hasFinishedResolution(selectorName, args)) {
@@ -493,22 +422,15 @@ function mapSuspendSelectors(selectors, store) {
493
422
  });
494
423
  }
495
424
  /**
496
- * Returns resolvers with matched selectors for a given namespace.
497
- * Resolvers are side effects invoked once per argument set of a given selector call,
498
- * used in ensuring that the data needs for the selector are satisfied.
425
+ * Convert resolvers to a normalized form, an object with `fulfill` method and
426
+ * optional methods like `isFulfilled`.
499
427
  *
500
- * @param {Object} resolvers Resolvers to register.
501
- * @param {Object} selectors The current selectors to be modified.
502
- * @param {Object} store The redux store to which the resolvers should be mapped.
503
- * @param {Object} resolversCache Resolvers Cache.
428
+ * @param {Object} resolvers Resolver to convert
504
429
  */
505
430
 
506
431
 
507
- function mapResolvers(resolvers, selectors, store, resolversCache) {
508
- // The `resolver` can be either a function that does the resolution, or, in more advanced
509
- // cases, an object with a `fullfill` method and other optional methods like `isFulfilled`.
510
- // Here we normalize the `resolver` function to an object with `fulfill` method.
511
- const mappedResolvers = mapValues(resolvers, resolver => {
432
+ function mapResolvers(resolvers) {
433
+ return mapValues(resolvers, resolver => {
512
434
  if (resolver.fulfill) {
513
435
  return resolver;
514
436
  }
@@ -519,87 +441,68 @@ function mapResolvers(resolvers, selectors, store, resolversCache) {
519
441
 
520
442
  };
521
443
  });
444
+ }
445
+ /**
446
+ * Returns resolvers with matched selectors for a given namespace.
447
+ * Resolvers are side effects invoked once per argument set of a given selector call,
448
+ * used in ensuring that the data needs for the selector are satisfied.
449
+ *
450
+ * @param {Object} selectors The current selectors to be modified.
451
+ * @param {Object} resolvers Resolvers to register.
452
+ * @param {Object} store The redux store to which the resolvers should be mapped.
453
+ * @param {Object} resolversCache Resolvers Cache.
454
+ */
522
455
 
523
- const mapSelector = (selector, selectorName) => {
524
- const resolver = resolvers[selectorName];
525
456
 
526
- if (!resolver) {
527
- selector.hasResolver = false;
528
- return selector;
457
+ function mapSelectorsWithResolvers(selectors, resolvers, store, resolversCache) {
458
+ function fulfillSelector(resolver, selectorName, args) {
459
+ const state = store.getState();
460
+
461
+ if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) {
462
+ return;
529
463
  }
530
464
 
531
- const selectorResolver = function () {
532
- for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
533
- args[_key7] = arguments[_key7];
534
- }
465
+ const {
466
+ metadata
467
+ } = store.__unstableOriginalGetState();
535
468
 
536
- async function fulfillSelector() {
537
- const state = store.getState();
469
+ if (metadataSelectors.hasStartedResolution(metadata, selectorName, args)) {
470
+ return;
471
+ }
538
472
 
539
- if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) {
540
- return;
541
- }
473
+ resolversCache.markAsRunning(selectorName, args);
474
+ setTimeout(async () => {
475
+ resolversCache.clear(selectorName, args);
476
+ store.dispatch(metadataActions.startResolution(selectorName, args));
542
477
 
543
- const {
544
- metadata
545
- } = store.__unstableOriginalGetState();
478
+ try {
479
+ const action = resolver.fulfill(...args);
546
480
 
547
- if (metadataSelectors.hasStartedResolution(metadata, selectorName, args)) {
548
- return;
481
+ if (action) {
482
+ await store.dispatch(action);
549
483
  }
550
484
 
551
- resolversCache.markAsRunning(selectorName, args);
552
- setTimeout(async () => {
553
- resolversCache.clear(selectorName, args);
554
- store.dispatch(metadataActions.startResolution(selectorName, args));
555
-
556
- try {
557
- await fulfillResolver(store, mappedResolvers, selectorName, ...args);
558
- store.dispatch(metadataActions.finishResolution(selectorName, args));
559
- } catch (error) {
560
- store.dispatch(metadataActions.failResolution(selectorName, args, error));
561
- }
562
- });
485
+ store.dispatch(metadataActions.finishResolution(selectorName, args));
486
+ } catch (error) {
487
+ store.dispatch(metadataActions.failResolution(selectorName, args, error));
563
488
  }
489
+ }, 0);
490
+ }
491
+
492
+ return mapValues(selectors, (selector, selectorName) => {
493
+ const resolver = resolvers[selectorName];
494
+
495
+ if (!resolver) {
496
+ return selector;
497
+ }
564
498
 
565
- fulfillSelector(...args);
499
+ const selectorResolver = (...args) => {
500
+ fulfillSelector(resolver, selectorName, args);
566
501
  return selector(...args);
567
502
  };
568
503
 
569
504
  selectorResolver.hasResolver = true;
570
505
  return selectorResolver;
571
- };
572
-
573
- return {
574
- resolvers: mappedResolvers,
575
- selectors: mapValues(selectors, mapSelector)
576
- };
577
- }
578
- /**
579
- * Calls a resolver given arguments
580
- *
581
- * @param {Object} store Store reference, for fulfilling via resolvers
582
- * @param {Object} resolvers Store Resolvers
583
- * @param {string} selectorName Selector name to fulfill.
584
- * @param {Array} args Selector Arguments.
585
- */
586
-
587
-
588
- async function fulfillResolver(store, resolvers, selectorName) {
589
- const resolver = resolvers[selectorName];
590
-
591
- if (!resolver) {
592
- return;
593
- }
594
-
595
- for (var _len8 = arguments.length, args = new Array(_len8 > 3 ? _len8 - 3 : 0), _key8 = 3; _key8 < _len8; _key8++) {
596
- args[_key8 - 3] = arguments[_key8];
597
- }
598
-
599
- const action = resolver.fulfill(...args);
600
-
601
- if (action) {
602
- await store.dispatch(action);
603
- }
506
+ });
604
507
  }
605
508
  //# sourceMappingURL=index.js.map