You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
7.3 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ "use strict";
  3. /******/ // The require scope
  4. /******/ var __webpack_require__ = {};
  5. /******/
  6. /************************************************************************/
  7. /******/ /* webpack/runtime/compat get default export */
  8. /******/ !function() {
  9. /******/ // getDefaultExport function for compatibility with non-harmony modules
  10. /******/ __webpack_require__.n = function(module) {
  11. /******/ var getter = module && module.__esModule ?
  12. /******/ function() { return module['default']; } :
  13. /******/ function() { return module; };
  14. /******/ __webpack_require__.d(getter, { a: getter });
  15. /******/ return getter;
  16. /******/ };
  17. /******/ }();
  18. /******/
  19. /******/ /* webpack/runtime/define property getters */
  20. /******/ !function() {
  21. /******/ // define getter functions for harmony exports
  22. /******/ __webpack_require__.d = function(exports, definition) {
  23. /******/ for(var key in definition) {
  24. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  25. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  26. /******/ }
  27. /******/ }
  28. /******/ };
  29. /******/ }();
  30. /******/
  31. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  32. /******/ !function() {
  33. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  34. /******/ }();
  35. /******/
  36. /******/ /* webpack/runtime/make namespace object */
  37. /******/ !function() {
  38. /******/ // define __esModule on exports
  39. /******/ __webpack_require__.r = function(exports) {
  40. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  41. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  42. /******/ }
  43. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  44. /******/ };
  45. /******/ }();
  46. /******/
  47. /************************************************************************/
  48. var __webpack_exports__ = {};
  49. // ESM COMPAT FLAG
  50. __webpack_require__.r(__webpack_exports__);
  51. // EXPORTS
  52. __webpack_require__.d(__webpack_exports__, {
  53. __unstableAwaitPromise: function() { return /* binding */ __unstableAwaitPromise; },
  54. apiFetch: function() { return /* binding */ apiFetch; },
  55. controls: function() { return /* binding */ controls; },
  56. dispatch: function() { return /* binding */ dispatch; },
  57. select: function() { return /* binding */ build_module_select; },
  58. syncSelect: function() { return /* binding */ syncSelect; }
  59. });
  60. ;// CONCATENATED MODULE: external ["wp","apiFetch"]
  61. var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  62. var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  63. ;// CONCATENATED MODULE: external ["wp","data"]
  64. var external_wp_data_namespaceObject = window["wp"]["data"];
  65. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  66. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  67. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  68. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data-controls/build-module/index.js
  69. /**
  70. * WordPress dependencies
  71. */
  72. /**
  73. * Dispatches a control action for triggering an api fetch call.
  74. *
  75. * @param {Object} request Arguments for the fetch request.
  76. *
  77. * @example
  78. * ```js
  79. * import { apiFetch } from '@wordpress/data-controls';
  80. *
  81. * // Action generator using apiFetch
  82. * export function* myAction() {
  83. * const path = '/v2/my-api/items';
  84. * const items = yield apiFetch( { path } );
  85. * // do something with the items.
  86. * }
  87. * ```
  88. *
  89. * @return {Object} The control descriptor.
  90. */
  91. function apiFetch(request) {
  92. return {
  93. type: 'API_FETCH',
  94. request
  95. };
  96. }
  97. /**
  98. * Control for resolving a selector in a registered data store.
  99. * Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.
  100. *
  101. * @param storeNameOrDescriptor The store object or identifier.
  102. * @param selectorName The selector name.
  103. * @param args Arguments passed without change to the `@wordpress/data` control.
  104. */
  105. function build_module_select(storeNameOrDescriptor, selectorName, ...args) {
  106. external_wp_deprecated_default()('`select` control in `@wordpress/data-controls`', {
  107. since: '5.7',
  108. alternative: 'built-in `resolveSelect` control in `@wordpress/data`'
  109. });
  110. return external_wp_data_namespaceObject.controls.resolveSelect(storeNameOrDescriptor, selectorName, ...args);
  111. }
  112. /**
  113. * Control for calling a selector in a registered data store.
  114. * Alias for the `select` built-in control in the `@wordpress/data` package.
  115. *
  116. * @param storeNameOrDescriptor The store object or identifier.
  117. * @param selectorName The selector name.
  118. * @param args Arguments passed without change to the `@wordpress/data` control.
  119. */
  120. function syncSelect(storeNameOrDescriptor, selectorName, ...args) {
  121. external_wp_deprecated_default()('`syncSelect` control in `@wordpress/data-controls`', {
  122. since: '5.7',
  123. alternative: 'built-in `select` control in `@wordpress/data`'
  124. });
  125. return external_wp_data_namespaceObject.controls.select(storeNameOrDescriptor, selectorName, ...args);
  126. }
  127. /**
  128. * Control for dispatching an action in a registered data store.
  129. * Alias for the `dispatch` control in the `@wordpress/data` package.
  130. *
  131. * @param storeNameOrDescriptor The store object or identifier.
  132. * @param actionName The action name.
  133. * @param args Arguments passed without change to the `@wordpress/data` control.
  134. */
  135. function dispatch(storeNameOrDescriptor, actionName, ...args) {
  136. external_wp_deprecated_default()('`dispatch` control in `@wordpress/data-controls`', {
  137. since: '5.7',
  138. alternative: 'built-in `dispatch` control in `@wordpress/data`'
  139. });
  140. return external_wp_data_namespaceObject.controls.dispatch(storeNameOrDescriptor, actionName, ...args);
  141. }
  142. /**
  143. * Dispatches a control action for awaiting on a promise to be resolved.
  144. *
  145. * @param {Object} promise Promise to wait for.
  146. *
  147. * @example
  148. * ```js
  149. * import { __unstableAwaitPromise } from '@wordpress/data-controls';
  150. *
  151. * // Action generator using apiFetch
  152. * export function* myAction() {
  153. * const promise = getItemsAsync();
  154. * const items = yield __unstableAwaitPromise( promise );
  155. * // do something with the items.
  156. * }
  157. * ```
  158. *
  159. * @return {Object} The control descriptor.
  160. */
  161. const __unstableAwaitPromise = function (promise) {
  162. return {
  163. type: 'AWAIT_PROMISE',
  164. promise
  165. };
  166. };
  167. /**
  168. * The default export is what you use to register the controls with your custom
  169. * store.
  170. *
  171. * @example
  172. * ```js
  173. * // WordPress dependencies
  174. * import { controls } from '@wordpress/data-controls';
  175. * import { registerStore } from '@wordpress/data';
  176. *
  177. * // Internal dependencies
  178. * import reducer from './reducer';
  179. * import * as selectors from './selectors';
  180. * import * as actions from './actions';
  181. * import * as resolvers from './resolvers';
  182. *
  183. * registerStore( 'my-custom-store', {
  184. * reducer,
  185. * controls,
  186. * actions,
  187. * selectors,
  188. * resolvers,
  189. * } );
  190. * ```
  191. * @return {Object} An object for registering the default controls with the
  192. * store.
  193. */
  194. const controls = {
  195. AWAIT_PROMISE: ({
  196. promise
  197. }) => promise,
  198. API_FETCH({
  199. request
  200. }) {
  201. return external_wp_apiFetch_default()(request);
  202. }
  203. };
  204. (window.wp = window.wp || {}).dataControls = __webpack_exports__;
  205. /******/ })()
  206. ;