@wordpress/data-controls 3.2.0 → 3.4.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.4.0 (2023-06-07)
6
+
7
+ ## 3.3.0 (2023-05-24)
8
+
5
9
  ## 3.2.0 (2023-05-10)
6
10
 
7
11
  ## 3.1.0 (2023-04-26)
package/build/index.js CHANGED
@@ -57,16 +57,11 @@ function apiFetch(request) {
57
57
  */
58
58
 
59
59
 
60
- function select(storeNameOrDescriptor, selectorName) {
60
+ function select(storeNameOrDescriptor, selectorName, ...args) {
61
61
  (0, _deprecated.default)('`select` control in `@wordpress/data-controls`', {
62
62
  since: '5.7',
63
63
  alternative: 'built-in `resolveSelect` control in `@wordpress/data`'
64
64
  });
65
-
66
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
67
- args[_key - 2] = arguments[_key];
68
- }
69
-
70
65
  return _data.controls.resolveSelect(storeNameOrDescriptor, selectorName, ...args);
71
66
  }
72
67
  /**
@@ -79,16 +74,11 @@ function select(storeNameOrDescriptor, selectorName) {
79
74
  */
80
75
 
81
76
 
82
- function syncSelect(storeNameOrDescriptor, selectorName) {
77
+ function syncSelect(storeNameOrDescriptor, selectorName, ...args) {
83
78
  (0, _deprecated.default)('`syncSelect` control in `@wordpress/data-controls`', {
84
79
  since: '5.7',
85
80
  alternative: 'built-in `select` control in `@wordpress/data`'
86
81
  });
87
-
88
- for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
89
- args[_key2 - 2] = arguments[_key2];
90
- }
91
-
92
82
  return _data.controls.select(storeNameOrDescriptor, selectorName, ...args);
93
83
  }
94
84
  /**
@@ -101,16 +91,11 @@ function syncSelect(storeNameOrDescriptor, selectorName) {
101
91
  */
102
92
 
103
93
 
104
- function dispatch(storeNameOrDescriptor, actionName) {
94
+ function dispatch(storeNameOrDescriptor, actionName, ...args) {
105
95
  (0, _deprecated.default)('`dispatch` control in `@wordpress/data-controls`', {
106
96
  since: '5.7',
107
97
  alternative: 'built-in `dispatch` control in `@wordpress/data`'
108
98
  });
109
-
110
- for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
111
- args[_key3 - 2] = arguments[_key3];
112
- }
113
-
114
99
  return _data.controls.dispatch(storeNameOrDescriptor, actionName, ...args);
115
100
  }
116
101
  /**
@@ -171,17 +156,13 @@ const __unstableAwaitPromise = function (promise) {
171
156
 
172
157
  exports.__unstableAwaitPromise = __unstableAwaitPromise;
173
158
  const controls = {
174
- AWAIT_PROMISE: _ref => {
175
- let {
176
- promise
177
- } = _ref;
178
- return promise;
179
- },
180
-
181
- API_FETCH(_ref2) {
182
- let {
183
- request
184
- } = _ref2;
159
+ AWAIT_PROMISE: ({
160
+ promise
161
+ }) => promise,
162
+
163
+ API_FETCH({
164
+ request
165
+ }) {
185
166
  return (0, _apiFetch.default)(request);
186
167
  }
187
168
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data-controls/src/index.ts"],"names":["apiFetch","request","type","select","storeNameOrDescriptor","selectorName","since","alternative","args","dataControls","resolveSelect","syncSelect","dispatch","actionName","__unstableAwaitPromise","promise","controls","AWAIT_PROMISE","API_FETCH"],"mappings":";;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CAAmBC,OAAnB,EAA8C;AACpD,SAAO;AACNC,IAAAA,IAAI,EAAE,WADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,MAAT,CACNC,qBADM,EAENC,YAFM,EAIL;AACD,2BAAY,gDAAZ,EAA8D;AAC7DC,IAAAA,KAAK,EAAE,KADsD;AAE7DC,IAAAA,WAAW,EAAE;AAFgD,GAA9D;;AADC,oCADEC,IACF;AADEA,IAAAA,IACF;AAAA;;AAMD,SAAOC,eAAaC,aAAb,CACNN,qBADM,EAENC,YAFM,EAGN,GAAGG,IAHG,CAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,UAAT,CACNP,qBADM,EAENC,YAFM,EAIL;AACD,2BAAY,oDAAZ,EAAkE;AACjEC,IAAAA,KAAK,EAAE,KAD0D;AAEjEC,IAAAA,WAAW,EAAE;AAFoD,GAAlE;;AADC,qCADEC,IACF;AADEA,IAAAA,IACF;AAAA;;AAMD,SAAOC,eAAaN,MAAb,CAAqBC,qBAArB,EAA4CC,YAA5C,EAA0D,GAAGG,IAA7D,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,QAAT,CACNR,qBADM,EAENS,UAFM,EAIL;AACD,2BAAY,kDAAZ,EAAgE;AAC/DP,IAAAA,KAAK,EAAE,KADwD;AAE/DC,IAAAA,WAAW,EAAE;AAFkD,GAAhE;;AADC,qCADEC,IACF;AADEA,IAAAA,IACF;AAAA;;AAMD,SAAOC,eAAaG,QAAb,CAAuBR,qBAAvB,EAA8CS,UAA9C,EAA0D,GAAGL,IAA7D,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMM,sBAAsB,GAAG,UAAgBC,OAAhB,EAAwC;AAC7E,SAAO;AACNb,IAAAA,IAAI,EAAE,eADA;AAENa,IAAAA;AAFM,GAAP;AAIA,CALM;AAOP;AACA;AACA;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,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,aAAa,EAAE;AAAA,QAAO;AAAEF,MAAAA;AAAF,KAAP;AAAA,WAAmDA,OAAnD;AAAA,GADQ;;AAEvBG,EAAAA,SAAS,QAA8C;AAAA,QAA5C;AAAEjB,MAAAA;AAAF,KAA4C;AACtD,WAAO,uBAAcA,OAAd,CAAP;AACA;;AAJsB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport triggerFetch from '@wordpress/api-fetch';\nimport { controls as dataControls } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport type { StoreDescriptor } from '@wordpress/data';\nimport type { APIFetchOptions } from '@wordpress/api-fetch';\n\n/**\n * Dispatches a control action for triggering an api fetch call.\n *\n * @param {Object} request Arguments for the fetch request.\n *\n * @example\n * ```js\n * import { apiFetch } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst path = '/v2/my-api/items';\n * \tconst items = yield apiFetch( { path } );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport function apiFetch( request: APIFetchOptions ) {\n\treturn {\n\t\ttype: 'API_FETCH',\n\t\trequest,\n\t};\n}\n\n/**\n * Control for resolving a selector in a registered data store.\n * Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function select(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`select` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `resolveSelect` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.resolveSelect(\n\t\tstoreNameOrDescriptor,\n\t\tselectorName,\n\t\t...args\n\t);\n}\n\n/**\n * Control for calling a selector in a registered data store.\n * Alias for the `select` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function syncSelect(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`syncSelect` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `select` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.select( storeNameOrDescriptor, selectorName, ...args );\n}\n\n/**\n * Control for dispatching an action in a registered data store.\n * Alias for the `dispatch` control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param actionName The action name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function dispatch(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tactionName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`dispatch` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `dispatch` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.dispatch( storeNameOrDescriptor, actionName, ...args );\n}\n\n/**\n * Dispatches a control action for awaiting on a promise to be resolved.\n *\n * @param {Object} promise Promise to wait for.\n *\n * @example\n * ```js\n * import { __unstableAwaitPromise } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst promise = getItemsAsync();\n * \tconst items = yield __unstableAwaitPromise( promise );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport const __unstableAwaitPromise = function < T >( promise: Promise< T > ) {\n\treturn {\n\t\ttype: 'AWAIT_PROMISE',\n\t\tpromise,\n\t};\n};\n\n/**\n * The default export is what you use to register the controls with your custom\n * store.\n *\n * @example\n * ```js\n * // WordPress dependencies\n * import { controls } from '@wordpress/data-controls';\n * import { registerStore } from '@wordpress/data';\n *\n * // Internal dependencies\n * import reducer from './reducer';\n * import * as selectors from './selectors';\n * import * as actions from './actions';\n * import * as resolvers from './resolvers';\n *\n * registerStore( 'my-custom-store', {\n * reducer,\n * controls,\n * actions,\n * selectors,\n * resolvers,\n * } );\n * ```\n * @return {Object} An object for registering the default controls with the\n * store.\n */\nexport const controls = {\n\tAWAIT_PROMISE: < T >( { promise }: { promise: Promise< T > } ) => promise,\n\tAPI_FETCH( { request }: { request: APIFetchOptions } ) {\n\t\treturn triggerFetch( request );\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/data-controls/src/index.ts"],"names":["apiFetch","request","type","select","storeNameOrDescriptor","selectorName","args","since","alternative","dataControls","resolveSelect","syncSelect","dispatch","actionName","__unstableAwaitPromise","promise","controls","AWAIT_PROMISE","API_FETCH"],"mappings":";;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CAAmBC,OAAnB,EAA8C;AACpD,SAAO;AACNC,IAAAA,IAAI,EAAE,WADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,MAAT,CACNC,qBADM,EAENC,YAFM,EAGN,GAAGC,IAHG,EAIL;AACD,2BAAY,gDAAZ,EAA8D;AAC7DC,IAAAA,KAAK,EAAE,KADsD;AAE7DC,IAAAA,WAAW,EAAE;AAFgD,GAA9D;AAKA,SAAOC,eAAaC,aAAb,CACNN,qBADM,EAENC,YAFM,EAGN,GAAGC,IAHG,CAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,UAAT,CACNP,qBADM,EAENC,YAFM,EAGN,GAAGC,IAHG,EAIL;AACD,2BAAY,oDAAZ,EAAkE;AACjEC,IAAAA,KAAK,EAAE,KAD0D;AAEjEC,IAAAA,WAAW,EAAE;AAFoD,GAAlE;AAKA,SAAOC,eAAaN,MAAb,CAAqBC,qBAArB,EAA4CC,YAA5C,EAA0D,GAAGC,IAA7D,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASM,QAAT,CACNR,qBADM,EAENS,UAFM,EAGN,GAAGP,IAHG,EAIL;AACD,2BAAY,kDAAZ,EAAgE;AAC/DC,IAAAA,KAAK,EAAE,KADwD;AAE/DC,IAAAA,WAAW,EAAE;AAFkD,GAAhE;AAKA,SAAOC,eAAaG,QAAb,CAAuBR,qBAAvB,EAA8CS,UAA9C,EAA0D,GAAGP,IAA7D,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMQ,sBAAsB,GAAG,UAAgBC,OAAhB,EAAwC;AAC7E,SAAO;AACNb,IAAAA,IAAI,EAAE,eADA;AAENa,IAAAA;AAFM,GAAP;AAIA,CALM;AAOP;AACA;AACA;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,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,aAAa,EAAE,CAAO;AAAEF,IAAAA;AAAF,GAAP,KAAmDA,OAD3C;;AAEvBG,EAAAA,SAAS,CAAE;AAAEjB,IAAAA;AAAF,GAAF,EAA8C;AACtD,WAAO,uBAAcA,OAAd,CAAP;AACA;;AAJsB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport triggerFetch from '@wordpress/api-fetch';\nimport { controls as dataControls } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport type { StoreDescriptor } from '@wordpress/data';\nimport type { APIFetchOptions } from '@wordpress/api-fetch';\n\n/**\n * Dispatches a control action for triggering an api fetch call.\n *\n * @param {Object} request Arguments for the fetch request.\n *\n * @example\n * ```js\n * import { apiFetch } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst path = '/v2/my-api/items';\n * \tconst items = yield apiFetch( { path } );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport function apiFetch( request: APIFetchOptions ) {\n\treturn {\n\t\ttype: 'API_FETCH',\n\t\trequest,\n\t};\n}\n\n/**\n * Control for resolving a selector in a registered data store.\n * Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function select(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`select` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `resolveSelect` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.resolveSelect(\n\t\tstoreNameOrDescriptor,\n\t\tselectorName,\n\t\t...args\n\t);\n}\n\n/**\n * Control for calling a selector in a registered data store.\n * Alias for the `select` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function syncSelect(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`syncSelect` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `select` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.select( storeNameOrDescriptor, selectorName, ...args );\n}\n\n/**\n * Control for dispatching an action in a registered data store.\n * Alias for the `dispatch` control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param actionName The action name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function dispatch(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tactionName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`dispatch` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `dispatch` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.dispatch( storeNameOrDescriptor, actionName, ...args );\n}\n\n/**\n * Dispatches a control action for awaiting on a promise to be resolved.\n *\n * @param {Object} promise Promise to wait for.\n *\n * @example\n * ```js\n * import { __unstableAwaitPromise } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst promise = getItemsAsync();\n * \tconst items = yield __unstableAwaitPromise( promise );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport const __unstableAwaitPromise = function < T >( promise: Promise< T > ) {\n\treturn {\n\t\ttype: 'AWAIT_PROMISE',\n\t\tpromise,\n\t};\n};\n\n/**\n * The default export is what you use to register the controls with your custom\n * store.\n *\n * @example\n * ```js\n * // WordPress dependencies\n * import { controls } from '@wordpress/data-controls';\n * import { registerStore } from '@wordpress/data';\n *\n * // Internal dependencies\n * import reducer from './reducer';\n * import * as selectors from './selectors';\n * import * as actions from './actions';\n * import * as resolvers from './resolvers';\n *\n * registerStore( 'my-custom-store', {\n * reducer,\n * controls,\n * actions,\n * selectors,\n * resolvers,\n * } );\n * ```\n * @return {Object} An object for registering the default controls with the\n * store.\n */\nexport const controls = {\n\tAWAIT_PROMISE: < T >( { promise }: { promise: Promise< T > } ) => promise,\n\tAPI_FETCH( { request }: { request: APIFetchOptions } ) {\n\t\treturn triggerFetch( request );\n\t},\n};\n"]}
@@ -39,16 +39,11 @@ export function apiFetch(request) {
39
39
  * @param args Arguments passed without change to the `@wordpress/data` control.
40
40
  */
41
41
 
42
- export function select(storeNameOrDescriptor, selectorName) {
42
+ export function select(storeNameOrDescriptor, selectorName, ...args) {
43
43
  deprecated('`select` control in `@wordpress/data-controls`', {
44
44
  since: '5.7',
45
45
  alternative: 'built-in `resolveSelect` control in `@wordpress/data`'
46
46
  });
47
-
48
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
49
- args[_key - 2] = arguments[_key];
50
- }
51
-
52
47
  return dataControls.resolveSelect(storeNameOrDescriptor, selectorName, ...args);
53
48
  }
54
49
  /**
@@ -60,16 +55,11 @@ export function select(storeNameOrDescriptor, selectorName) {
60
55
  * @param args Arguments passed without change to the `@wordpress/data` control.
61
56
  */
62
57
 
63
- export function syncSelect(storeNameOrDescriptor, selectorName) {
58
+ export function syncSelect(storeNameOrDescriptor, selectorName, ...args) {
64
59
  deprecated('`syncSelect` control in `@wordpress/data-controls`', {
65
60
  since: '5.7',
66
61
  alternative: 'built-in `select` control in `@wordpress/data`'
67
62
  });
68
-
69
- for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
70
- args[_key2 - 2] = arguments[_key2];
71
- }
72
-
73
63
  return dataControls.select(storeNameOrDescriptor, selectorName, ...args);
74
64
  }
75
65
  /**
@@ -81,16 +71,11 @@ export function syncSelect(storeNameOrDescriptor, selectorName) {
81
71
  * @param args Arguments passed without change to the `@wordpress/data` control.
82
72
  */
83
73
 
84
- export function dispatch(storeNameOrDescriptor, actionName) {
74
+ export function dispatch(storeNameOrDescriptor, actionName, ...args) {
85
75
  deprecated('`dispatch` control in `@wordpress/data-controls`', {
86
76
  since: '5.7',
87
77
  alternative: 'built-in `dispatch` control in `@wordpress/data`'
88
78
  });
89
-
90
- for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
91
- args[_key3 - 2] = arguments[_key3];
92
- }
93
-
94
79
  return dataControls.dispatch(storeNameOrDescriptor, actionName, ...args);
95
80
  }
96
81
  /**
@@ -148,17 +133,13 @@ export const __unstableAwaitPromise = function (promise) {
148
133
  */
149
134
 
150
135
  export const controls = {
151
- AWAIT_PROMISE: _ref => {
152
- let {
153
- promise
154
- } = _ref;
155
- return promise;
156
- },
136
+ AWAIT_PROMISE: ({
137
+ promise
138
+ }) => promise,
157
139
 
158
- API_FETCH(_ref2) {
159
- let {
160
- request
161
- } = _ref2;
140
+ API_FETCH({
141
+ request
142
+ }) {
162
143
  return triggerFetch(request);
163
144
  }
164
145
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/data-controls/src/index.ts"],"names":["triggerFetch","controls","dataControls","deprecated","apiFetch","request","type","select","storeNameOrDescriptor","selectorName","since","alternative","args","resolveSelect","syncSelect","dispatch","actionName","__unstableAwaitPromise","promise","AWAIT_PROMISE","API_FETCH"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,YAAP,MAAyB,sBAAzB;AACA,SAASC,QAAQ,IAAIC,YAArB,QAAyC,iBAAzC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAT,CAAmBC,OAAnB,EAA8C;AACpD,SAAO;AACNC,IAAAA,IAAI,EAAE,WADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,MAAT,CACNC,qBADM,EAENC,YAFM,EAIL;AACDN,EAAAA,UAAU,CAAE,gDAAF,EAAoD;AAC7DO,IAAAA,KAAK,EAAE,KADsD;AAE7DC,IAAAA,WAAW,EAAE;AAFgD,GAApD,CAAV;;AADC,oCADEC,IACF;AADEA,IAAAA,IACF;AAAA;;AAMD,SAAOV,YAAY,CAACW,aAAb,CACNL,qBADM,EAENC,YAFM,EAGN,GAAGG,IAHG,CAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,UAAT,CACNN,qBADM,EAENC,YAFM,EAIL;AACDN,EAAAA,UAAU,CAAE,oDAAF,EAAwD;AACjEO,IAAAA,KAAK,EAAE,KAD0D;AAEjEC,IAAAA,WAAW,EAAE;AAFoD,GAAxD,CAAV;;AADC,qCADEC,IACF;AADEA,IAAAA,IACF;AAAA;;AAMD,SAAOV,YAAY,CAACK,MAAb,CAAqBC,qBAArB,EAA4CC,YAA5C,EAA0D,GAAGG,IAA7D,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,QAAT,CACNP,qBADM,EAENQ,UAFM,EAIL;AACDb,EAAAA,UAAU,CAAE,kDAAF,EAAsD;AAC/DO,IAAAA,KAAK,EAAE,KADwD;AAE/DC,IAAAA,WAAW,EAAE;AAFkD,GAAtD,CAAV;;AADC,qCADEC,IACF;AADEA,IAAAA,IACF;AAAA;;AAMD,SAAOV,YAAY,CAACa,QAAb,CAAuBP,qBAAvB,EAA8CQ,UAA9C,EAA0D,GAAGJ,IAA7D,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMK,sBAAsB,GAAG,UAAgBC,OAAhB,EAAwC;AAC7E,SAAO;AACNZ,IAAAA,IAAI,EAAE,eADA;AAENY,IAAAA;AAFM,GAAP;AAIA,CALM;AAOP;AACA;AACA;AACA;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,MAAMjB,QAAQ,GAAG;AACvBkB,EAAAA,aAAa,EAAE;AAAA,QAAO;AAAED,MAAAA;AAAF,KAAP;AAAA,WAAmDA,OAAnD;AAAA,GADQ;;AAEvBE,EAAAA,SAAS,QAA8C;AAAA,QAA5C;AAAEf,MAAAA;AAAF,KAA4C;AACtD,WAAOL,YAAY,CAAEK,OAAF,CAAnB;AACA;;AAJsB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport triggerFetch from '@wordpress/api-fetch';\nimport { controls as dataControls } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport type { StoreDescriptor } from '@wordpress/data';\nimport type { APIFetchOptions } from '@wordpress/api-fetch';\n\n/**\n * Dispatches a control action for triggering an api fetch call.\n *\n * @param {Object} request Arguments for the fetch request.\n *\n * @example\n * ```js\n * import { apiFetch } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst path = '/v2/my-api/items';\n * \tconst items = yield apiFetch( { path } );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport function apiFetch( request: APIFetchOptions ) {\n\treturn {\n\t\ttype: 'API_FETCH',\n\t\trequest,\n\t};\n}\n\n/**\n * Control for resolving a selector in a registered data store.\n * Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function select(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`select` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `resolveSelect` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.resolveSelect(\n\t\tstoreNameOrDescriptor,\n\t\tselectorName,\n\t\t...args\n\t);\n}\n\n/**\n * Control for calling a selector in a registered data store.\n * Alias for the `select` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function syncSelect(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`syncSelect` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `select` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.select( storeNameOrDescriptor, selectorName, ...args );\n}\n\n/**\n * Control for dispatching an action in a registered data store.\n * Alias for the `dispatch` control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param actionName The action name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function dispatch(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tactionName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`dispatch` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `dispatch` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.dispatch( storeNameOrDescriptor, actionName, ...args );\n}\n\n/**\n * Dispatches a control action for awaiting on a promise to be resolved.\n *\n * @param {Object} promise Promise to wait for.\n *\n * @example\n * ```js\n * import { __unstableAwaitPromise } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst promise = getItemsAsync();\n * \tconst items = yield __unstableAwaitPromise( promise );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport const __unstableAwaitPromise = function < T >( promise: Promise< T > ) {\n\treturn {\n\t\ttype: 'AWAIT_PROMISE',\n\t\tpromise,\n\t};\n};\n\n/**\n * The default export is what you use to register the controls with your custom\n * store.\n *\n * @example\n * ```js\n * // WordPress dependencies\n * import { controls } from '@wordpress/data-controls';\n * import { registerStore } from '@wordpress/data';\n *\n * // Internal dependencies\n * import reducer from './reducer';\n * import * as selectors from './selectors';\n * import * as actions from './actions';\n * import * as resolvers from './resolvers';\n *\n * registerStore( 'my-custom-store', {\n * reducer,\n * controls,\n * actions,\n * selectors,\n * resolvers,\n * } );\n * ```\n * @return {Object} An object for registering the default controls with the\n * store.\n */\nexport const controls = {\n\tAWAIT_PROMISE: < T >( { promise }: { promise: Promise< T > } ) => promise,\n\tAPI_FETCH( { request }: { request: APIFetchOptions } ) {\n\t\treturn triggerFetch( request );\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/data-controls/src/index.ts"],"names":["triggerFetch","controls","dataControls","deprecated","apiFetch","request","type","select","storeNameOrDescriptor","selectorName","args","since","alternative","resolveSelect","syncSelect","dispatch","actionName","__unstableAwaitPromise","promise","AWAIT_PROMISE","API_FETCH"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,YAAP,MAAyB,sBAAzB;AACA,SAASC,QAAQ,IAAIC,YAArB,QAAyC,iBAAzC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAT,CAAmBC,OAAnB,EAA8C;AACpD,SAAO;AACNC,IAAAA,IAAI,EAAE,WADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,MAAT,CACNC,qBADM,EAENC,YAFM,EAGN,GAAGC,IAHG,EAIL;AACDP,EAAAA,UAAU,CAAE,gDAAF,EAAoD;AAC7DQ,IAAAA,KAAK,EAAE,KADsD;AAE7DC,IAAAA,WAAW,EAAE;AAFgD,GAApD,CAAV;AAKA,SAAOV,YAAY,CAACW,aAAb,CACNL,qBADM,EAENC,YAFM,EAGN,GAAGC,IAHG,CAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,UAAT,CACNN,qBADM,EAENC,YAFM,EAGN,GAAGC,IAHG,EAIL;AACDP,EAAAA,UAAU,CAAE,oDAAF,EAAwD;AACjEQ,IAAAA,KAAK,EAAE,KAD0D;AAEjEC,IAAAA,WAAW,EAAE;AAFoD,GAAxD,CAAV;AAKA,SAAOV,YAAY,CAACK,MAAb,CAAqBC,qBAArB,EAA4CC,YAA5C,EAA0D,GAAGC,IAA7D,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,QAAT,CACNP,qBADM,EAENQ,UAFM,EAGN,GAAGN,IAHG,EAIL;AACDP,EAAAA,UAAU,CAAE,kDAAF,EAAsD;AAC/DQ,IAAAA,KAAK,EAAE,KADwD;AAE/DC,IAAAA,WAAW,EAAE;AAFkD,GAAtD,CAAV;AAKA,SAAOV,YAAY,CAACa,QAAb,CAAuBP,qBAAvB,EAA8CQ,UAA9C,EAA0D,GAAGN,IAA7D,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMO,sBAAsB,GAAG,UAAgBC,OAAhB,EAAwC;AAC7E,SAAO;AACNZ,IAAAA,IAAI,EAAE,eADA;AAENY,IAAAA;AAFM,GAAP;AAIA,CALM;AAOP;AACA;AACA;AACA;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,MAAMjB,QAAQ,GAAG;AACvBkB,EAAAA,aAAa,EAAE,CAAO;AAAED,IAAAA;AAAF,GAAP,KAAmDA,OAD3C;;AAEvBE,EAAAA,SAAS,CAAE;AAAEf,IAAAA;AAAF,GAAF,EAA8C;AACtD,WAAOL,YAAY,CAAEK,OAAF,CAAnB;AACA;;AAJsB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport triggerFetch from '@wordpress/api-fetch';\nimport { controls as dataControls } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport type { StoreDescriptor } from '@wordpress/data';\nimport type { APIFetchOptions } from '@wordpress/api-fetch';\n\n/**\n * Dispatches a control action for triggering an api fetch call.\n *\n * @param {Object} request Arguments for the fetch request.\n *\n * @example\n * ```js\n * import { apiFetch } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst path = '/v2/my-api/items';\n * \tconst items = yield apiFetch( { path } );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport function apiFetch( request: APIFetchOptions ) {\n\treturn {\n\t\ttype: 'API_FETCH',\n\t\trequest,\n\t};\n}\n\n/**\n * Control for resolving a selector in a registered data store.\n * Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function select(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`select` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `resolveSelect` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.resolveSelect(\n\t\tstoreNameOrDescriptor,\n\t\tselectorName,\n\t\t...args\n\t);\n}\n\n/**\n * Control for calling a selector in a registered data store.\n * Alias for the `select` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function syncSelect(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`syncSelect` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `select` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.select( storeNameOrDescriptor, selectorName, ...args );\n}\n\n/**\n * Control for dispatching an action in a registered data store.\n * Alias for the `dispatch` control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param actionName The action name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function dispatch(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tactionName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`dispatch` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `dispatch` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.dispatch( storeNameOrDescriptor, actionName, ...args );\n}\n\n/**\n * Dispatches a control action for awaiting on a promise to be resolved.\n *\n * @param {Object} promise Promise to wait for.\n *\n * @example\n * ```js\n * import { __unstableAwaitPromise } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst promise = getItemsAsync();\n * \tconst items = yield __unstableAwaitPromise( promise );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport const __unstableAwaitPromise = function < T >( promise: Promise< T > ) {\n\treturn {\n\t\ttype: 'AWAIT_PROMISE',\n\t\tpromise,\n\t};\n};\n\n/**\n * The default export is what you use to register the controls with your custom\n * store.\n *\n * @example\n * ```js\n * // WordPress dependencies\n * import { controls } from '@wordpress/data-controls';\n * import { registerStore } from '@wordpress/data';\n *\n * // Internal dependencies\n * import reducer from './reducer';\n * import * as selectors from './selectors';\n * import * as actions from './actions';\n * import * as resolvers from './resolvers';\n *\n * registerStore( 'my-custom-store', {\n * reducer,\n * controls,\n * actions,\n * selectors,\n * resolvers,\n * } );\n * ```\n * @return {Object} An object for registering the default controls with the\n * store.\n */\nexport const controls = {\n\tAWAIT_PROMISE: < T >( { promise }: { promise: Promise< T > } ) => promise,\n\tAPI_FETCH( { request }: { request: APIFetchOptions } ) {\n\t\treturn triggerFetch( request );\n\t},\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/data-controls",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "A set of common controls for the @wordpress/data api.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -28,12 +28,12 @@
28
28
  "types": "build-types",
29
29
  "dependencies": {
30
30
  "@babel/runtime": "^7.16.0",
31
- "@wordpress/api-fetch": "^6.30.0",
32
- "@wordpress/data": "^9.3.0",
33
- "@wordpress/deprecated": "^3.33.0"
31
+ "@wordpress/api-fetch": "^6.32.0",
32
+ "@wordpress/data": "^9.5.0",
33
+ "@wordpress/deprecated": "^3.35.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "e936127e1e13881f1a940b7bd1593a9e500147f3"
38
+ "gitHead": "a92f606309b1541b834ff9b0a76ed2a466fc45ed"
39
39
  }