93 (function() { module.exports = this["wp"]["i18n"]; }()); |
93 (function() { module.exports = this["wp"]["i18n"]; }()); |
94 |
94 |
95 /***/ }), |
95 /***/ }), |
96 |
96 |
97 /***/ 15: |
97 /***/ 15: |
|
98 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
99 |
|
100 "use strict"; |
|
101 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; }); |
|
102 /* harmony import */ var _objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(41); |
|
103 |
|
104 function _objectWithoutProperties(source, excluded) { |
|
105 if (source == null) return {}; |
|
106 var target = Object(_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(source, excluded); |
|
107 var key, i; |
|
108 |
|
109 if (Object.getOwnPropertySymbols) { |
|
110 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); |
|
111 |
|
112 for (i = 0; i < sourceSymbolKeys.length; i++) { |
|
113 key = sourceSymbolKeys[i]; |
|
114 if (excluded.indexOf(key) >= 0) continue; |
|
115 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; |
|
116 target[key] = source[key]; |
|
117 } |
|
118 } |
|
119 |
|
120 return target; |
|
121 } |
|
122 |
|
123 /***/ }), |
|
124 |
|
125 /***/ 24: |
|
126 /***/ (function(module, exports) { |
|
127 |
|
128 (function() { module.exports = this["regeneratorRuntime"]; }()); |
|
129 |
|
130 /***/ }), |
|
131 |
|
132 /***/ 31: |
|
133 /***/ (function(module, exports) { |
|
134 |
|
135 (function() { module.exports = this["wp"]["url"]; }()); |
|
136 |
|
137 /***/ }), |
|
138 |
|
139 /***/ 41: |
|
140 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
141 |
|
142 "use strict"; |
|
143 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutPropertiesLoose; }); |
|
144 function _objectWithoutPropertiesLoose(source, excluded) { |
|
145 if (source == null) return {}; |
|
146 var target = {}; |
|
147 var sourceKeys = Object.keys(source); |
|
148 var key, i; |
|
149 |
|
150 for (i = 0; i < sourceKeys.length; i++) { |
|
151 key = sourceKeys[i]; |
|
152 if (excluded.indexOf(key) >= 0) continue; |
|
153 target[key] = source[key]; |
|
154 } |
|
155 |
|
156 return target; |
|
157 } |
|
158 |
|
159 /***/ }), |
|
160 |
|
161 /***/ 451: |
|
162 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
163 |
|
164 "use strict"; |
|
165 // ESM COMPAT FLAG |
|
166 __webpack_require__.r(__webpack_exports__); |
|
167 |
|
168 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
|
169 var defineProperty = __webpack_require__(5); |
|
170 |
|
171 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js |
|
172 var objectWithoutProperties = __webpack_require__(15); |
|
173 |
|
174 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
|
175 var external_this_wp_i18n_ = __webpack_require__(1); |
|
176 |
|
177 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/nonce.js |
|
178 |
|
179 |
|
180 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
181 |
|
182 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
183 |
|
184 function createNonceMiddleware(nonce) { |
|
185 function middleware(options, next) { |
|
186 var _options$headers = options.headers, |
|
187 headers = _options$headers === void 0 ? {} : _options$headers; // If an 'X-WP-Nonce' header (or any case-insensitive variation |
|
188 // thereof) was specified, no need to add a nonce header. |
|
189 |
|
190 for (var headerName in headers) { |
|
191 if (headerName.toLowerCase() === 'x-wp-nonce') { |
|
192 return next(options); |
|
193 } |
|
194 } |
|
195 |
|
196 return next(_objectSpread({}, options, { |
|
197 headers: _objectSpread({}, headers, { |
|
198 'X-WP-Nonce': middleware.nonce |
|
199 }) |
|
200 })); |
|
201 } |
|
202 |
|
203 middleware.nonce = nonce; |
|
204 return middleware; |
|
205 } |
|
206 |
|
207 /* harmony default export */ var nonce = (createNonceMiddleware); |
|
208 |
|
209 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/namespace-endpoint.js |
|
210 |
|
211 |
|
212 function namespace_endpoint_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
213 |
|
214 function namespace_endpoint_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { namespace_endpoint_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { namespace_endpoint_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
215 |
|
216 var namespaceAndEndpointMiddleware = function namespaceAndEndpointMiddleware(options, next) { |
|
217 var path = options.path; |
|
218 var namespaceTrimmed, endpointTrimmed; |
|
219 |
|
220 if (typeof options.namespace === 'string' && typeof options.endpoint === 'string') { |
|
221 namespaceTrimmed = options.namespace.replace(/^\/|\/$/g, ''); |
|
222 endpointTrimmed = options.endpoint.replace(/^\//, ''); |
|
223 |
|
224 if (endpointTrimmed) { |
|
225 path = namespaceTrimmed + '/' + endpointTrimmed; |
|
226 } else { |
|
227 path = namespaceTrimmed; |
|
228 } |
|
229 } |
|
230 |
|
231 delete options.namespace; |
|
232 delete options.endpoint; |
|
233 return next(namespace_endpoint_objectSpread({}, options, { |
|
234 path: path |
|
235 })); |
|
236 }; |
|
237 |
|
238 /* harmony default export */ var namespace_endpoint = (namespaceAndEndpointMiddleware); |
|
239 |
|
240 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/root-url.js |
|
241 |
|
242 |
|
243 function root_url_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
244 |
|
245 function root_url_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { root_url_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { root_url_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
246 |
|
247 /** |
|
248 * Internal dependencies |
|
249 */ |
|
250 |
|
251 |
|
252 var root_url_createRootURLMiddleware = function createRootURLMiddleware(rootURL) { |
|
253 return function (options, next) { |
|
254 return namespace_endpoint(options, function (optionsWithPath) { |
|
255 var url = optionsWithPath.url; |
|
256 var path = optionsWithPath.path; |
|
257 var apiRoot; |
|
258 |
|
259 if (typeof path === 'string') { |
|
260 apiRoot = rootURL; |
|
261 |
|
262 if (-1 !== rootURL.indexOf('?')) { |
|
263 path = path.replace('?', '&'); |
|
264 } |
|
265 |
|
266 path = path.replace(/^\//, ''); // API root may already include query parameter prefix if site is |
|
267 // configured to use plain permalinks. |
|
268 |
|
269 if ('string' === typeof apiRoot && -1 !== apiRoot.indexOf('?')) { |
|
270 path = path.replace('?', '&'); |
|
271 } |
|
272 |
|
273 url = apiRoot + path; |
|
274 } |
|
275 |
|
276 return next(root_url_objectSpread({}, optionsWithPath, { |
|
277 url: url |
|
278 })); |
|
279 }); |
|
280 }; |
|
281 }; |
|
282 |
|
283 /* harmony default export */ var root_url = (root_url_createRootURLMiddleware); |
|
284 |
|
285 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/preloading.js |
|
286 /** |
|
287 * Given a path, returns a normalized path where equal query parameter values |
|
288 * will be treated as identical, regardless of order they appear in the original |
|
289 * text. |
|
290 * |
|
291 * @param {string} path Original path. |
|
292 * |
|
293 * @return {string} Normalized path. |
|
294 */ |
|
295 function getStablePath(path) { |
|
296 var splitted = path.split('?'); |
|
297 var query = splitted[1]; |
|
298 var base = splitted[0]; |
|
299 |
|
300 if (!query) { |
|
301 return base; |
|
302 } // 'b=1&c=2&a=5' |
|
303 |
|
304 |
|
305 return base + '?' + query // [ 'b=1', 'c=2', 'a=5' ] |
|
306 .split('&') // [ [ 'b, '1' ], [ 'c', '2' ], [ 'a', '5' ] ] |
|
307 .map(function (entry) { |
|
308 return entry.split('='); |
|
309 }) // [ [ 'a', '5' ], [ 'b, '1' ], [ 'c', '2' ] ] |
|
310 .sort(function (a, b) { |
|
311 return a[0].localeCompare(b[0]); |
|
312 }) // [ 'a=5', 'b=1', 'c=2' ] |
|
313 .map(function (pair) { |
|
314 return pair.join('='); |
|
315 }) // 'a=5&b=1&c=2' |
|
316 .join('&'); |
|
317 } |
|
318 |
|
319 function createPreloadingMiddleware(preloadedData) { |
|
320 var cache = Object.keys(preloadedData).reduce(function (result, path) { |
|
321 result[getStablePath(path)] = preloadedData[path]; |
|
322 return result; |
|
323 }, {}); |
|
324 return function (options, next) { |
|
325 var _options$parse = options.parse, |
|
326 parse = _options$parse === void 0 ? true : _options$parse; |
|
327 |
|
328 if (typeof options.path === 'string') { |
|
329 var method = options.method || 'GET'; |
|
330 var path = getStablePath(options.path); |
|
331 |
|
332 if (parse && 'GET' === method && cache[path]) { |
|
333 return Promise.resolve(cache[path].body); |
|
334 } else if ('OPTIONS' === method && cache[method] && cache[method][path]) { |
|
335 return Promise.resolve(cache[method][path]); |
|
336 } |
|
337 } |
|
338 |
|
339 return next(options); |
|
340 }; |
|
341 } |
|
342 |
|
343 /* harmony default export */ var preloading = (createPreloadingMiddleware); |
|
344 |
|
345 // EXTERNAL MODULE: external {"this":"regeneratorRuntime"} |
|
346 var external_this_regeneratorRuntime_ = __webpack_require__(24); |
|
347 var external_this_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_this_regeneratorRuntime_); |
|
348 |
|
349 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js |
|
350 var asyncToGenerator = __webpack_require__(50); |
|
351 |
|
352 // EXTERNAL MODULE: external {"this":["wp","url"]} |
|
353 var external_this_wp_url_ = __webpack_require__(31); |
|
354 |
|
355 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/fetch-all-middleware.js |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 function fetch_all_middleware_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
362 |
|
363 function fetch_all_middleware_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { fetch_all_middleware_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { fetch_all_middleware_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
364 |
|
365 /** |
|
366 * WordPress dependencies |
|
367 */ |
|
368 |
|
369 /** |
|
370 * Internal dependencies |
|
371 */ |
|
372 |
|
373 // Apply query arguments to both URL and Path, whichever is present. |
|
374 |
|
375 var fetch_all_middleware_modifyQuery = function modifyQuery(_ref, queryArgs) { |
|
376 var path = _ref.path, |
|
377 url = _ref.url, |
|
378 options = Object(objectWithoutProperties["a" /* default */])(_ref, ["path", "url"]); |
|
379 |
|
380 return fetch_all_middleware_objectSpread({}, options, { |
|
381 url: url && Object(external_this_wp_url_["addQueryArgs"])(url, queryArgs), |
|
382 path: path && Object(external_this_wp_url_["addQueryArgs"])(path, queryArgs) |
|
383 }); |
|
384 }; // Duplicates parsing functionality from apiFetch. |
|
385 |
|
386 |
|
387 var parseResponse = function parseResponse(response) { |
|
388 return response.json ? response.json() : Promise.reject(response); |
|
389 }; |
|
390 |
|
391 var parseLinkHeader = function parseLinkHeader(linkHeader) { |
|
392 if (!linkHeader) { |
|
393 return {}; |
|
394 } |
|
395 |
|
396 var match = linkHeader.match(/<([^>]+)>; rel="next"/); |
|
397 return match ? { |
|
398 next: match[1] |
|
399 } : {}; |
|
400 }; |
|
401 |
|
402 var getNextPageUrl = function getNextPageUrl(response) { |
|
403 var _parseLinkHeader = parseLinkHeader(response.headers.get('link')), |
|
404 next = _parseLinkHeader.next; |
|
405 |
|
406 return next; |
|
407 }; |
|
408 |
|
409 var requestContainsUnboundedQuery = function requestContainsUnboundedQuery(options) { |
|
410 var pathIsUnbounded = options.path && options.path.indexOf('per_page=-1') !== -1; |
|
411 var urlIsUnbounded = options.url && options.url.indexOf('per_page=-1') !== -1; |
|
412 return pathIsUnbounded || urlIsUnbounded; |
|
413 }; // The REST API enforces an upper limit on the per_page option. To handle large |
|
414 // collections, apiFetch consumers can pass `per_page=-1`; this middleware will |
|
415 // then recursively assemble a full response array from all available pages. |
|
416 |
|
417 |
|
418 var fetchAllMiddleware = /*#__PURE__*/function () { |
|
419 var _ref2 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee(options, next) { |
|
420 var response, results, nextPage, mergedResults, nextResponse, nextResults; |
|
421 return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context) { |
|
422 while (1) { |
|
423 switch (_context.prev = _context.next) { |
|
424 case 0: |
|
425 if (!(options.parse === false)) { |
|
426 _context.next = 2; |
|
427 break; |
|
428 } |
|
429 |
|
430 return _context.abrupt("return", next(options)); |
|
431 |
|
432 case 2: |
|
433 if (requestContainsUnboundedQuery(options)) { |
|
434 _context.next = 4; |
|
435 break; |
|
436 } |
|
437 |
|
438 return _context.abrupt("return", next(options)); |
|
439 |
|
440 case 4: |
|
441 _context.next = 6; |
|
442 return build_module(fetch_all_middleware_objectSpread({}, fetch_all_middleware_modifyQuery(options, { |
|
443 per_page: 100 |
|
444 }), { |
|
445 // Ensure headers are returned for page 1. |
|
446 parse: false |
|
447 })); |
|
448 |
|
449 case 6: |
|
450 response = _context.sent; |
|
451 _context.next = 9; |
|
452 return parseResponse(response); |
|
453 |
|
454 case 9: |
|
455 results = _context.sent; |
|
456 |
|
457 if (Array.isArray(results)) { |
|
458 _context.next = 12; |
|
459 break; |
|
460 } |
|
461 |
|
462 return _context.abrupt("return", results); |
|
463 |
|
464 case 12: |
|
465 nextPage = getNextPageUrl(response); |
|
466 |
|
467 if (nextPage) { |
|
468 _context.next = 15; |
|
469 break; |
|
470 } |
|
471 |
|
472 return _context.abrupt("return", results); |
|
473 |
|
474 case 15: |
|
475 // Iteratively fetch all remaining pages until no "next" header is found. |
|
476 mergedResults = [].concat(results); |
|
477 |
|
478 case 16: |
|
479 if (!nextPage) { |
|
480 _context.next = 27; |
|
481 break; |
|
482 } |
|
483 |
|
484 _context.next = 19; |
|
485 return build_module(fetch_all_middleware_objectSpread({}, options, { |
|
486 // Ensure the URL for the next page is used instead of any provided path. |
|
487 path: undefined, |
|
488 url: nextPage, |
|
489 // Ensure we still get headers so we can identify the next page. |
|
490 parse: false |
|
491 })); |
|
492 |
|
493 case 19: |
|
494 nextResponse = _context.sent; |
|
495 _context.next = 22; |
|
496 return parseResponse(nextResponse); |
|
497 |
|
498 case 22: |
|
499 nextResults = _context.sent; |
|
500 mergedResults = mergedResults.concat(nextResults); |
|
501 nextPage = getNextPageUrl(nextResponse); |
|
502 _context.next = 16; |
|
503 break; |
|
504 |
|
505 case 27: |
|
506 return _context.abrupt("return", mergedResults); |
|
507 |
|
508 case 28: |
|
509 case "end": |
|
510 return _context.stop(); |
|
511 } |
|
512 } |
|
513 }, _callee); |
|
514 })); |
|
515 |
|
516 return function fetchAllMiddleware(_x, _x2) { |
|
517 return _ref2.apply(this, arguments); |
|
518 }; |
|
519 }(); |
|
520 |
|
521 /* harmony default export */ var fetch_all_middleware = (fetchAllMiddleware); |
|
522 |
|
523 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/http-v1.js |
|
524 |
|
525 |
|
526 function http_v1_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
527 |
|
528 function http_v1_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { http_v1_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { http_v1_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
529 |
|
530 /** |
|
531 * Set of HTTP methods which are eligible to be overridden. |
|
532 * |
|
533 * @type {Set} |
|
534 */ |
|
535 var OVERRIDE_METHODS = new Set(['PATCH', 'PUT', 'DELETE']); |
|
536 /** |
|
537 * Default request method. |
|
538 * |
|
539 * "A request has an associated method (a method). Unless stated otherwise it |
|
540 * is `GET`." |
|
541 * |
|
542 * @see https://fetch.spec.whatwg.org/#requests |
|
543 * |
|
544 * @type {string} |
|
545 */ |
|
546 |
|
547 var DEFAULT_METHOD = 'GET'; |
|
548 /** |
|
549 * API Fetch middleware which overrides the request method for HTTP v1 |
|
550 * compatibility leveraging the REST API X-HTTP-Method-Override header. |
|
551 * |
|
552 * @param {Object} options Fetch options. |
|
553 * @param {Function} next [description] |
|
554 * |
|
555 * @return {*} The evaluated result of the remaining middleware chain. |
|
556 */ |
|
557 |
|
558 function httpV1Middleware(options, next) { |
|
559 var _options = options, |
|
560 _options$method = _options.method, |
|
561 method = _options$method === void 0 ? DEFAULT_METHOD : _options$method; |
|
562 |
|
563 if (OVERRIDE_METHODS.has(method.toUpperCase())) { |
|
564 options = http_v1_objectSpread({}, options, { |
|
565 headers: http_v1_objectSpread({}, options.headers, { |
|
566 'X-HTTP-Method-Override': method, |
|
567 'Content-Type': 'application/json' |
|
568 }), |
|
569 method: 'POST' |
|
570 }); |
|
571 } |
|
572 |
|
573 return next(options, next); |
|
574 } |
|
575 |
|
576 /* harmony default export */ var http_v1 = (httpV1Middleware); |
|
577 |
|
578 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/user-locale.js |
|
579 /** |
|
580 * WordPress dependencies |
|
581 */ |
|
582 |
|
583 |
|
584 function userLocaleMiddleware(options, next) { |
|
585 if (typeof options.url === 'string' && !Object(external_this_wp_url_["hasQueryArg"])(options.url, '_locale')) { |
|
586 options.url = Object(external_this_wp_url_["addQueryArgs"])(options.url, { |
|
587 _locale: 'user' |
|
588 }); |
|
589 } |
|
590 |
|
591 if (typeof options.path === 'string' && !Object(external_this_wp_url_["hasQueryArg"])(options.path, '_locale')) { |
|
592 options.path = Object(external_this_wp_url_["addQueryArgs"])(options.path, { |
|
593 _locale: 'user' |
|
594 }); |
|
595 } |
|
596 |
|
597 return next(options, next); |
|
598 } |
|
599 |
|
600 /* harmony default export */ var user_locale = (userLocaleMiddleware); |
|
601 |
|
602 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/utils/response.js |
|
603 /** |
|
604 * WordPress dependencies |
|
605 */ |
|
606 |
|
607 /** |
|
608 * Parses the apiFetch response. |
|
609 * |
|
610 * @param {Response} response |
|
611 * @param {boolean} shouldParseResponse |
|
612 * |
|
613 * @return {Promise} Parsed response |
|
614 */ |
|
615 |
|
616 var response_parseResponse = function parseResponse(response) { |
|
617 var shouldParseResponse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; |
|
618 |
|
619 if (shouldParseResponse) { |
|
620 if (response.status === 204) { |
|
621 return null; |
|
622 } |
|
623 |
|
624 return response.json ? response.json() : Promise.reject(response); |
|
625 } |
|
626 |
|
627 return response; |
|
628 }; |
|
629 |
|
630 var response_parseJsonAndNormalizeError = function parseJsonAndNormalizeError(response) { |
|
631 var invalidJsonError = { |
|
632 code: 'invalid_json', |
|
633 message: Object(external_this_wp_i18n_["__"])('The response is not a valid JSON response.') |
|
634 }; |
|
635 |
|
636 if (!response || !response.json) { |
|
637 throw invalidJsonError; |
|
638 } |
|
639 |
|
640 return response.json().catch(function () { |
|
641 throw invalidJsonError; |
|
642 }); |
|
643 }; |
|
644 /** |
|
645 * Parses the apiFetch response properly and normalize response errors. |
|
646 * |
|
647 * @param {Response} response |
|
648 * @param {boolean} shouldParseResponse |
|
649 * |
|
650 * @return {Promise} Parsed response. |
|
651 */ |
|
652 |
|
653 |
|
654 var parseResponseAndNormalizeError = function parseResponseAndNormalizeError(response) { |
|
655 var shouldParseResponse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; |
|
656 return Promise.resolve(response_parseResponse(response, shouldParseResponse)).catch(function (res) { |
|
657 return parseAndThrowError(res, shouldParseResponse); |
|
658 }); |
|
659 }; |
|
660 function parseAndThrowError(response) { |
|
661 var shouldParseResponse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; |
|
662 |
|
663 if (!shouldParseResponse) { |
|
664 throw response; |
|
665 } |
|
666 |
|
667 return response_parseJsonAndNormalizeError(response).then(function (error) { |
|
668 var unknownError = { |
|
669 code: 'unknown_error', |
|
670 message: Object(external_this_wp_i18n_["__"])('An unknown error occurred.') |
|
671 }; |
|
672 throw error || unknownError; |
|
673 }); |
|
674 } |
|
675 |
|
676 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/media-upload.js |
|
677 |
|
678 |
|
679 function media_upload_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
680 |
|
681 function media_upload_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { media_upload_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { media_upload_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
682 |
|
683 /** |
|
684 * WordPress dependencies |
|
685 */ |
|
686 |
|
687 /** |
|
688 * Internal dependencies |
|
689 */ |
|
690 |
|
691 |
|
692 /** |
|
693 * Middleware handling media upload failures and retries. |
|
694 * |
|
695 * @param {Object} options Fetch options. |
|
696 * @param {Function} next [description] |
|
697 * |
|
698 * @return {*} The evaluated result of the remaining middleware chain. |
|
699 */ |
|
700 |
|
701 function mediaUploadMiddleware(options, next) { |
|
702 var isMediaUploadRequest = options.path && options.path.indexOf('/wp/v2/media') !== -1 || options.url && options.url.indexOf('/wp/v2/media') !== -1; |
|
703 |
|
704 if (!isMediaUploadRequest) { |
|
705 return next(options, next); |
|
706 } |
|
707 |
|
708 var retries = 0; |
|
709 var maxRetries = 5; |
|
710 |
|
711 var postProcess = function postProcess(attachmentId) { |
|
712 retries++; |
|
713 return next({ |
|
714 path: "/wp/v2/media/".concat(attachmentId, "/post-process"), |
|
715 method: 'POST', |
|
716 data: { |
|
717 action: 'create-image-subsizes' |
|
718 }, |
|
719 parse: false |
|
720 }).catch(function () { |
|
721 if (retries < maxRetries) { |
|
722 return postProcess(attachmentId); |
|
723 } |
|
724 |
|
725 next({ |
|
726 path: "/wp/v2/media/".concat(attachmentId, "?force=true"), |
|
727 method: 'DELETE' |
|
728 }); |
|
729 return Promise.reject(); |
|
730 }); |
|
731 }; |
|
732 |
|
733 return next(media_upload_objectSpread({}, options, { |
|
734 parse: false |
|
735 })).catch(function (response) { |
|
736 var attachmentId = response.headers.get('x-wp-upload-attachment-id'); |
|
737 |
|
738 if (response.status >= 500 && response.status < 600 && attachmentId) { |
|
739 return postProcess(attachmentId).catch(function () { |
|
740 if (options.parse !== false) { |
|
741 return Promise.reject({ |
|
742 code: 'post_process', |
|
743 message: Object(external_this_wp_i18n_["__"])('Media upload failed. If this is a photo or a large image, please scale it down and try again.') |
|
744 }); |
|
745 } |
|
746 |
|
747 return Promise.reject(response); |
|
748 }); |
|
749 } |
|
750 |
|
751 return parseAndThrowError(response, options.parse); |
|
752 }).then(function (response) { |
|
753 return parseResponseAndNormalizeError(response, options.parse); |
|
754 }); |
|
755 } |
|
756 |
|
757 /* harmony default export */ var media_upload = (mediaUploadMiddleware); |
|
758 |
|
759 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/index.js |
|
760 |
|
761 |
|
762 |
|
763 function build_module_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
764 |
|
765 function build_module_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { build_module_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { build_module_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
766 |
|
767 /** |
|
768 * WordPress dependencies |
|
769 */ |
|
770 |
|
771 /** |
|
772 * Internal dependencies |
|
773 */ |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 /** |
|
785 * Default set of header values which should be sent with every request unless |
|
786 * explicitly provided through apiFetch options. |
|
787 * |
|
788 * @type {Object} |
|
789 */ |
|
790 |
|
791 var DEFAULT_HEADERS = { |
|
792 // The backend uses the Accept header as a condition for considering an |
|
793 // incoming request as a REST request. |
|
794 // |
|
795 // See: https://core.trac.wordpress.org/ticket/44534 |
|
796 Accept: 'application/json, */*;q=0.1' |
|
797 }; |
|
798 /** |
|
799 * Default set of fetch option values which should be sent with every request |
|
800 * unless explicitly provided through apiFetch options. |
|
801 * |
|
802 * @type {Object} |
|
803 */ |
|
804 |
|
805 var DEFAULT_OPTIONS = { |
|
806 credentials: 'include' |
|
807 }; |
|
808 var middlewares = [user_locale, namespace_endpoint, http_v1, fetch_all_middleware]; |
|
809 |
|
810 function registerMiddleware(middleware) { |
|
811 middlewares.unshift(middleware); |
|
812 } |
|
813 |
|
814 var checkStatus = function checkStatus(response) { |
|
815 if (response.status >= 200 && response.status < 300) { |
|
816 return response; |
|
817 } |
|
818 |
|
819 throw response; |
|
820 }; |
|
821 |
|
822 var build_module_defaultFetchHandler = function defaultFetchHandler(nextOptions) { |
|
823 var url = nextOptions.url, |
|
824 path = nextOptions.path, |
|
825 data = nextOptions.data, |
|
826 _nextOptions$parse = nextOptions.parse, |
|
827 parse = _nextOptions$parse === void 0 ? true : _nextOptions$parse, |
|
828 remainingOptions = Object(objectWithoutProperties["a" /* default */])(nextOptions, ["url", "path", "data", "parse"]); |
|
829 |
|
830 var body = nextOptions.body, |
|
831 headers = nextOptions.headers; // Merge explicitly-provided headers with default values. |
|
832 |
|
833 headers = build_module_objectSpread({}, DEFAULT_HEADERS, {}, headers); // The `data` property is a shorthand for sending a JSON body. |
|
834 |
|
835 if (data) { |
|
836 body = JSON.stringify(data); |
|
837 headers['Content-Type'] = 'application/json'; |
|
838 } |
|
839 |
|
840 var responsePromise = window.fetch(url || path, build_module_objectSpread({}, DEFAULT_OPTIONS, {}, remainingOptions, { |
|
841 body: body, |
|
842 headers: headers |
|
843 })); |
|
844 return responsePromise // Return early if fetch errors. If fetch error, there is most likely no |
|
845 // network connection. Unfortunately fetch just throws a TypeError and |
|
846 // the message might depend on the browser. |
|
847 .then(function (value) { |
|
848 return Promise.resolve(value).then(checkStatus).catch(function (response) { |
|
849 return parseAndThrowError(response, parse); |
|
850 }).then(function (response) { |
|
851 return parseResponseAndNormalizeError(response, parse); |
|
852 }); |
|
853 }, function () { |
|
854 throw { |
|
855 code: 'fetch_error', |
|
856 message: Object(external_this_wp_i18n_["__"])('You are probably offline.') |
|
857 }; |
|
858 }); |
|
859 }; |
|
860 |
|
861 var fetchHandler = build_module_defaultFetchHandler; |
|
862 /** |
|
863 * Defines a custom fetch handler for making the requests that will override |
|
864 * the default one using window.fetch |
|
865 * |
|
866 * @param {Function} newFetchHandler The new fetch handler |
|
867 */ |
|
868 |
|
869 function setFetchHandler(newFetchHandler) { |
|
870 fetchHandler = newFetchHandler; |
|
871 } |
|
872 |
|
873 function apiFetch(options) { |
|
874 var steps = [].concat(middlewares, [fetchHandler]); |
|
875 |
|
876 var createRunStep = function createRunStep(index) { |
|
877 return function (workingOptions) { |
|
878 var step = steps[index]; |
|
879 |
|
880 if (index === steps.length - 1) { |
|
881 return step(workingOptions); |
|
882 } |
|
883 |
|
884 var next = createRunStep(index + 1); |
|
885 return step(workingOptions, next); |
|
886 }; |
|
887 }; |
|
888 |
|
889 return new Promise(function (resolve, reject) { |
|
890 createRunStep(0)(options).then(resolve).catch(function (error) { |
|
891 if (error.code !== 'rest_cookie_invalid_nonce') { |
|
892 return reject(error); |
|
893 } // If the nonce is invalid, refresh it and try again. |
|
894 |
|
895 |
|
896 window.fetch(apiFetch.nonceEndpoint).then(checkStatus).then(function (data) { |
|
897 return data.text(); |
|
898 }).then(function (text) { |
|
899 apiFetch.nonceMiddleware.nonce = text; |
|
900 apiFetch(options).then(resolve).catch(reject); |
|
901 }).catch(reject); |
|
902 }); |
|
903 }); |
|
904 } |
|
905 |
|
906 apiFetch.use = registerMiddleware; |
|
907 apiFetch.setFetchHandler = setFetchHandler; |
|
908 apiFetch.createNonceMiddleware = nonce; |
|
909 apiFetch.createPreloadingMiddleware = preloading; |
|
910 apiFetch.createRootURLMiddleware = root_url; |
|
911 apiFetch.fetchAllMiddleware = fetch_all_middleware; |
|
912 apiFetch.mediaUploadMiddleware = media_upload; |
|
913 /* harmony default export */ var build_module = __webpack_exports__["default"] = (apiFetch); |
|
914 |
|
915 |
|
916 /***/ }), |
|
917 |
|
918 /***/ 5: |
98 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
919 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
99 |
920 |
100 "use strict"; |
921 "use strict"; |
101 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
922 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
102 function _defineProperty(obj, key, value) { |
923 function _defineProperty(obj, key, value) { |
114 return obj; |
935 return obj; |
115 } |
936 } |
116 |
937 |
117 /***/ }), |
938 /***/ }), |
118 |
939 |
119 /***/ 21: |
940 /***/ 50: |
120 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
121 |
|
122 "use strict"; |
|
123 |
|
124 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js |
|
125 function _objectWithoutPropertiesLoose(source, excluded) { |
|
126 if (source == null) return {}; |
|
127 var target = {}; |
|
128 var sourceKeys = Object.keys(source); |
|
129 var key, i; |
|
130 |
|
131 for (i = 0; i < sourceKeys.length; i++) { |
|
132 key = sourceKeys[i]; |
|
133 if (excluded.indexOf(key) >= 0) continue; |
|
134 target[key] = source[key]; |
|
135 } |
|
136 |
|
137 return target; |
|
138 } |
|
139 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js |
|
140 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; }); |
|
141 |
|
142 function _objectWithoutProperties(source, excluded) { |
|
143 if (source == null) return {}; |
|
144 var target = _objectWithoutPropertiesLoose(source, excluded); |
|
145 var key, i; |
|
146 |
|
147 if (Object.getOwnPropertySymbols) { |
|
148 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); |
|
149 |
|
150 for (i = 0; i < sourceSymbolKeys.length; i++) { |
|
151 key = sourceSymbolKeys[i]; |
|
152 if (excluded.indexOf(key) >= 0) continue; |
|
153 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; |
|
154 target[key] = source[key]; |
|
155 } |
|
156 } |
|
157 |
|
158 return target; |
|
159 } |
|
160 |
|
161 /***/ }), |
|
162 |
|
163 /***/ 23: |
|
164 /***/ (function(module, exports, __webpack_require__) { |
|
165 |
|
166 module.exports = __webpack_require__(54); |
|
167 |
|
168 |
|
169 /***/ }), |
|
170 |
|
171 /***/ 25: |
|
172 /***/ (function(module, exports) { |
|
173 |
|
174 (function() { module.exports = this["wp"]["url"]; }()); |
|
175 |
|
176 /***/ }), |
|
177 |
|
178 /***/ 369: |
|
179 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
180 |
|
181 "use strict"; |
|
182 __webpack_require__.r(__webpack_exports__); |
|
183 |
|
184 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js |
|
185 var objectSpread = __webpack_require__(7); |
|
186 |
|
187 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js + 1 modules |
|
188 var objectWithoutProperties = __webpack_require__(21); |
|
189 |
|
190 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
|
191 var external_this_wp_i18n_ = __webpack_require__(1); |
|
192 |
|
193 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/nonce.js |
|
194 |
|
195 |
|
196 function createNonceMiddleware(nonce) { |
|
197 function middleware(options, next) { |
|
198 var _options$headers = options.headers, |
|
199 headers = _options$headers === void 0 ? {} : _options$headers; // If an 'X-WP-Nonce' header (or any case-insensitive variation |
|
200 // thereof) was specified, no need to add a nonce header. |
|
201 |
|
202 for (var headerName in headers) { |
|
203 if (headerName.toLowerCase() === 'x-wp-nonce') { |
|
204 return next(options); |
|
205 } |
|
206 } |
|
207 |
|
208 return next(Object(objectSpread["a" /* default */])({}, options, { |
|
209 headers: Object(objectSpread["a" /* default */])({}, headers, { |
|
210 'X-WP-Nonce': middleware.nonce |
|
211 }) |
|
212 })); |
|
213 } |
|
214 |
|
215 middleware.nonce = nonce; |
|
216 return middleware; |
|
217 } |
|
218 |
|
219 /* harmony default export */ var middlewares_nonce = (createNonceMiddleware); |
|
220 |
|
221 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/namespace-endpoint.js |
|
222 |
|
223 |
|
224 var namespace_endpoint_namespaceAndEndpointMiddleware = function namespaceAndEndpointMiddleware(options, next) { |
|
225 var path = options.path; |
|
226 var namespaceTrimmed, endpointTrimmed; |
|
227 |
|
228 if (typeof options.namespace === 'string' && typeof options.endpoint === 'string') { |
|
229 namespaceTrimmed = options.namespace.replace(/^\/|\/$/g, ''); |
|
230 endpointTrimmed = options.endpoint.replace(/^\//, ''); |
|
231 |
|
232 if (endpointTrimmed) { |
|
233 path = namespaceTrimmed + '/' + endpointTrimmed; |
|
234 } else { |
|
235 path = namespaceTrimmed; |
|
236 } |
|
237 } |
|
238 |
|
239 delete options.namespace; |
|
240 delete options.endpoint; |
|
241 return next(Object(objectSpread["a" /* default */])({}, options, { |
|
242 path: path |
|
243 })); |
|
244 }; |
|
245 |
|
246 /* harmony default export */ var namespace_endpoint = (namespace_endpoint_namespaceAndEndpointMiddleware); |
|
247 |
|
248 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/root-url.js |
|
249 |
|
250 |
|
251 /** |
|
252 * Internal dependencies |
|
253 */ |
|
254 |
|
255 |
|
256 var root_url_createRootURLMiddleware = function createRootURLMiddleware(rootURL) { |
|
257 return function (options, next) { |
|
258 return namespace_endpoint(options, function (optionsWithPath) { |
|
259 var url = optionsWithPath.url; |
|
260 var path = optionsWithPath.path; |
|
261 var apiRoot; |
|
262 |
|
263 if (typeof path === 'string') { |
|
264 apiRoot = rootURL; |
|
265 |
|
266 if (-1 !== rootURL.indexOf('?')) { |
|
267 path = path.replace('?', '&'); |
|
268 } |
|
269 |
|
270 path = path.replace(/^\//, ''); // API root may already include query parameter prefix if site is |
|
271 // configured to use plain permalinks. |
|
272 |
|
273 if ('string' === typeof apiRoot && -1 !== apiRoot.indexOf('?')) { |
|
274 path = path.replace('?', '&'); |
|
275 } |
|
276 |
|
277 url = apiRoot + path; |
|
278 } |
|
279 |
|
280 return next(Object(objectSpread["a" /* default */])({}, optionsWithPath, { |
|
281 url: url |
|
282 })); |
|
283 }); |
|
284 }; |
|
285 }; |
|
286 |
|
287 /* harmony default export */ var root_url = (root_url_createRootURLMiddleware); |
|
288 |
|
289 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/preloading.js |
|
290 var createPreloadingMiddleware = function createPreloadingMiddleware(preloadedData) { |
|
291 return function (options, next) { |
|
292 function getStablePath(path) { |
|
293 var splitted = path.split('?'); |
|
294 var query = splitted[1]; |
|
295 var base = splitted[0]; |
|
296 |
|
297 if (!query) { |
|
298 return base; |
|
299 } // 'b=1&c=2&a=5' |
|
300 |
|
301 |
|
302 return base + '?' + query // [ 'b=1', 'c=2', 'a=5' ] |
|
303 .split('&') // [ [ 'b, '1' ], [ 'c', '2' ], [ 'a', '5' ] ] |
|
304 .map(function (entry) { |
|
305 return entry.split('='); |
|
306 }) // [ [ 'a', '5' ], [ 'b, '1' ], [ 'c', '2' ] ] |
|
307 .sort(function (a, b) { |
|
308 return a[0].localeCompare(b[0]); |
|
309 }) // [ 'a=5', 'b=1', 'c=2' ] |
|
310 .map(function (pair) { |
|
311 return pair.join('='); |
|
312 }) // 'a=5&b=1&c=2' |
|
313 .join('&'); |
|
314 } |
|
315 |
|
316 var _options$parse = options.parse, |
|
317 parse = _options$parse === void 0 ? true : _options$parse; |
|
318 |
|
319 if (typeof options.path === 'string') { |
|
320 var method = options.method || 'GET'; |
|
321 var path = getStablePath(options.path); |
|
322 |
|
323 if (parse && 'GET' === method && preloadedData[path]) { |
|
324 return Promise.resolve(preloadedData[path].body); |
|
325 } else if ('OPTIONS' === method && preloadedData[method] && preloadedData[method][path]) { |
|
326 return Promise.resolve(preloadedData[method][path]); |
|
327 } |
|
328 } |
|
329 |
|
330 return next(options); |
|
331 }; |
|
332 }; |
|
333 |
|
334 /* harmony default export */ var preloading = (createPreloadingMiddleware); |
|
335 |
|
336 // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js |
|
337 var regenerator = __webpack_require__(23); |
|
338 var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator); |
|
339 |
|
340 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js |
|
341 var asyncToGenerator = __webpack_require__(44); |
|
342 |
|
343 // EXTERNAL MODULE: external {"this":["wp","url"]} |
|
344 var external_this_wp_url_ = __webpack_require__(25); |
|
345 |
|
346 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/fetch-all-middleware.js |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 /** |
|
353 * WordPress dependencies |
|
354 */ |
|
355 // Apply query arguments to both URL and Path, whichever is present. |
|
356 |
|
357 var fetch_all_middleware_modifyQuery = function modifyQuery(_ref, queryArgs) { |
|
358 var path = _ref.path, |
|
359 url = _ref.url, |
|
360 options = Object(objectWithoutProperties["a" /* default */])(_ref, ["path", "url"]); |
|
361 |
|
362 return Object(objectSpread["a" /* default */])({}, options, { |
|
363 url: url && Object(external_this_wp_url_["addQueryArgs"])(url, queryArgs), |
|
364 path: path && Object(external_this_wp_url_["addQueryArgs"])(path, queryArgs) |
|
365 }); |
|
366 }; // Duplicates parsing functionality from apiFetch. |
|
367 |
|
368 |
|
369 var fetch_all_middleware_parseResponse = function parseResponse(response) { |
|
370 return response.json ? response.json() : Promise.reject(response); |
|
371 }; |
|
372 |
|
373 var parseLinkHeader = function parseLinkHeader(linkHeader) { |
|
374 if (!linkHeader) { |
|
375 return {}; |
|
376 } |
|
377 |
|
378 var match = linkHeader.match(/<([^>]+)>; rel="next"/); |
|
379 return match ? { |
|
380 next: match[1] |
|
381 } : {}; |
|
382 }; |
|
383 |
|
384 var getNextPageUrl = function getNextPageUrl(response) { |
|
385 var _parseLinkHeader = parseLinkHeader(response.headers.get('link')), |
|
386 next = _parseLinkHeader.next; |
|
387 |
|
388 return next; |
|
389 }; |
|
390 |
|
391 var requestContainsUnboundedQuery = function requestContainsUnboundedQuery(options) { |
|
392 var pathIsUnbounded = options.path && options.path.indexOf('per_page=-1') !== -1; |
|
393 var urlIsUnbounded = options.url && options.url.indexOf('per_page=-1') !== -1; |
|
394 return pathIsUnbounded || urlIsUnbounded; |
|
395 }; // The REST API enforces an upper limit on the per_page option. To handle large |
|
396 // collections, apiFetch consumers can pass `per_page=-1`; this middleware will |
|
397 // then recursively assemble a full response array from all available pages. |
|
398 |
|
399 |
|
400 var fetchAllMiddleware = |
|
401 /*#__PURE__*/ |
|
402 function () { |
|
403 var _ref2 = Object(asyncToGenerator["a" /* default */])( |
|
404 /*#__PURE__*/ |
|
405 regenerator_default.a.mark(function _callee(options, next) { |
|
406 var response, results, nextPage, mergedResults, nextResponse, nextResults; |
|
407 return regenerator_default.a.wrap(function _callee$(_context) { |
|
408 while (1) { |
|
409 switch (_context.prev = _context.next) { |
|
410 case 0: |
|
411 if (!(options.parse === false)) { |
|
412 _context.next = 2; |
|
413 break; |
|
414 } |
|
415 |
|
416 return _context.abrupt("return", next(options)); |
|
417 |
|
418 case 2: |
|
419 if (requestContainsUnboundedQuery(options)) { |
|
420 _context.next = 4; |
|
421 break; |
|
422 } |
|
423 |
|
424 return _context.abrupt("return", next(options)); |
|
425 |
|
426 case 4: |
|
427 _context.next = 6; |
|
428 return next(Object(objectSpread["a" /* default */])({}, fetch_all_middleware_modifyQuery(options, { |
|
429 per_page: 100 |
|
430 }), { |
|
431 // Ensure headers are returned for page 1. |
|
432 parse: false |
|
433 })); |
|
434 |
|
435 case 6: |
|
436 response = _context.sent; |
|
437 _context.next = 9; |
|
438 return fetch_all_middleware_parseResponse(response); |
|
439 |
|
440 case 9: |
|
441 results = _context.sent; |
|
442 |
|
443 if (Array.isArray(results)) { |
|
444 _context.next = 12; |
|
445 break; |
|
446 } |
|
447 |
|
448 return _context.abrupt("return", results); |
|
449 |
|
450 case 12: |
|
451 nextPage = getNextPageUrl(response); |
|
452 |
|
453 if (nextPage) { |
|
454 _context.next = 15; |
|
455 break; |
|
456 } |
|
457 |
|
458 return _context.abrupt("return", results); |
|
459 |
|
460 case 15: |
|
461 // Iteratively fetch all remaining pages until no "next" header is found. |
|
462 mergedResults = [].concat(results); |
|
463 |
|
464 case 16: |
|
465 if (!nextPage) { |
|
466 _context.next = 27; |
|
467 break; |
|
468 } |
|
469 |
|
470 _context.next = 19; |
|
471 return next(Object(objectSpread["a" /* default */])({}, options, { |
|
472 // Ensure the URL for the next page is used instead of any provided path. |
|
473 path: undefined, |
|
474 url: nextPage, |
|
475 // Ensure we still get headers so we can identify the next page. |
|
476 parse: false |
|
477 })); |
|
478 |
|
479 case 19: |
|
480 nextResponse = _context.sent; |
|
481 _context.next = 22; |
|
482 return fetch_all_middleware_parseResponse(nextResponse); |
|
483 |
|
484 case 22: |
|
485 nextResults = _context.sent; |
|
486 mergedResults = mergedResults.concat(nextResults); |
|
487 nextPage = getNextPageUrl(nextResponse); |
|
488 _context.next = 16; |
|
489 break; |
|
490 |
|
491 case 27: |
|
492 return _context.abrupt("return", mergedResults); |
|
493 |
|
494 case 28: |
|
495 case "end": |
|
496 return _context.stop(); |
|
497 } |
|
498 } |
|
499 }, _callee, this); |
|
500 })); |
|
501 |
|
502 return function fetchAllMiddleware(_x, _x2) { |
|
503 return _ref2.apply(this, arguments); |
|
504 }; |
|
505 }(); |
|
506 |
|
507 /* harmony default export */ var fetch_all_middleware = (fetchAllMiddleware); |
|
508 |
|
509 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/http-v1.js |
|
510 |
|
511 |
|
512 /** |
|
513 * Set of HTTP methods which are eligible to be overridden. |
|
514 * |
|
515 * @type {Set} |
|
516 */ |
|
517 var OVERRIDE_METHODS = new Set(['PATCH', 'PUT', 'DELETE']); |
|
518 /** |
|
519 * Default request method. |
|
520 * |
|
521 * "A request has an associated method (a method). Unless stated otherwise it |
|
522 * is `GET`." |
|
523 * |
|
524 * @see https://fetch.spec.whatwg.org/#requests |
|
525 * |
|
526 * @type {string} |
|
527 */ |
|
528 |
|
529 var DEFAULT_METHOD = 'GET'; |
|
530 /** |
|
531 * API Fetch middleware which overrides the request method for HTTP v1 |
|
532 * compatibility leveraging the REST API X-HTTP-Method-Override header. |
|
533 * |
|
534 * @param {Object} options Fetch options. |
|
535 * @param {Function} next [description] |
|
536 * |
|
537 * @return {*} The evaluated result of the remaining middleware chain. |
|
538 */ |
|
539 |
|
540 function httpV1Middleware(options, next) { |
|
541 var _options = options, |
|
542 _options$method = _options.method, |
|
543 method = _options$method === void 0 ? DEFAULT_METHOD : _options$method; |
|
544 |
|
545 if (OVERRIDE_METHODS.has(method.toUpperCase())) { |
|
546 options = Object(objectSpread["a" /* default */])({}, options, { |
|
547 headers: Object(objectSpread["a" /* default */])({}, options.headers, { |
|
548 'X-HTTP-Method-Override': method, |
|
549 'Content-Type': 'application/json' |
|
550 }), |
|
551 method: 'POST' |
|
552 }); |
|
553 } |
|
554 |
|
555 return next(options, next); |
|
556 } |
|
557 |
|
558 /* harmony default export */ var http_v1 = (httpV1Middleware); |
|
559 |
|
560 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/user-locale.js |
|
561 /** |
|
562 * WordPress dependencies |
|
563 */ |
|
564 |
|
565 |
|
566 function userLocaleMiddleware(options, next) { |
|
567 if (typeof options.url === 'string' && !Object(external_this_wp_url_["hasQueryArg"])(options.url, '_locale')) { |
|
568 options.url = Object(external_this_wp_url_["addQueryArgs"])(options.url, { |
|
569 _locale: 'user' |
|
570 }); |
|
571 } |
|
572 |
|
573 if (typeof options.path === 'string' && !Object(external_this_wp_url_["hasQueryArg"])(options.path, '_locale')) { |
|
574 options.path = Object(external_this_wp_url_["addQueryArgs"])(options.path, { |
|
575 _locale: 'user' |
|
576 }); |
|
577 } |
|
578 |
|
579 return next(options, next); |
|
580 } |
|
581 |
|
582 /* harmony default export */ var user_locale = (userLocaleMiddleware); |
|
583 |
|
584 // CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/index.js |
|
585 |
|
586 |
|
587 |
|
588 /** |
|
589 * WordPress dependencies |
|
590 */ |
|
591 |
|
592 /** |
|
593 * Internal dependencies |
|
594 */ |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 /** |
|
604 * Default set of header values which should be sent with every request unless |
|
605 * explicitly provided through apiFetch options. |
|
606 * |
|
607 * @type {Object} |
|
608 */ |
|
609 |
|
610 var DEFAULT_HEADERS = { |
|
611 // The backend uses the Accept header as a condition for considering an |
|
612 // incoming request as a REST request. |
|
613 // |
|
614 // See: https://core.trac.wordpress.org/ticket/44534 |
|
615 Accept: 'application/json, */*;q=0.1' |
|
616 }; |
|
617 /** |
|
618 * Default set of fetch option values which should be sent with every request |
|
619 * unless explicitly provided through apiFetch options. |
|
620 * |
|
621 * @type {Object} |
|
622 */ |
|
623 |
|
624 var DEFAULT_OPTIONS = { |
|
625 credentials: 'include' |
|
626 }; |
|
627 var middlewares = [user_locale, namespace_endpoint, http_v1, fetch_all_middleware]; |
|
628 |
|
629 function registerMiddleware(middleware) { |
|
630 middlewares.unshift(middleware); |
|
631 } |
|
632 |
|
633 var build_module_defaultFetchHandler = function defaultFetchHandler(nextOptions) { |
|
634 var url = nextOptions.url, |
|
635 path = nextOptions.path, |
|
636 data = nextOptions.data, |
|
637 _nextOptions$parse = nextOptions.parse, |
|
638 parse = _nextOptions$parse === void 0 ? true : _nextOptions$parse, |
|
639 remainingOptions = Object(objectWithoutProperties["a" /* default */])(nextOptions, ["url", "path", "data", "parse"]); |
|
640 |
|
641 var body = nextOptions.body, |
|
642 headers = nextOptions.headers; // Merge explicitly-provided headers with default values. |
|
643 |
|
644 headers = Object(objectSpread["a" /* default */])({}, DEFAULT_HEADERS, headers); // The `data` property is a shorthand for sending a JSON body. |
|
645 |
|
646 if (data) { |
|
647 body = JSON.stringify(data); |
|
648 headers['Content-Type'] = 'application/json'; |
|
649 } |
|
650 |
|
651 var responsePromise = window.fetch(url || path, Object(objectSpread["a" /* default */])({}, DEFAULT_OPTIONS, remainingOptions, { |
|
652 body: body, |
|
653 headers: headers |
|
654 })); |
|
655 |
|
656 var checkStatus = function checkStatus(response) { |
|
657 if (response.status >= 200 && response.status < 300) { |
|
658 return response; |
|
659 } |
|
660 |
|
661 throw response; |
|
662 }; |
|
663 |
|
664 var parseResponse = function parseResponse(response) { |
|
665 if (parse) { |
|
666 if (response.status === 204) { |
|
667 return null; |
|
668 } |
|
669 |
|
670 return response.json ? response.json() : Promise.reject(response); |
|
671 } |
|
672 |
|
673 return response; |
|
674 }; |
|
675 |
|
676 return responsePromise.then(checkStatus).then(parseResponse).catch(function (response) { |
|
677 if (!parse) { |
|
678 throw response; |
|
679 } |
|
680 |
|
681 var invalidJsonError = { |
|
682 code: 'invalid_json', |
|
683 message: Object(external_this_wp_i18n_["__"])('The response is not a valid JSON response.') |
|
684 }; |
|
685 |
|
686 if (!response || !response.json) { |
|
687 throw invalidJsonError; |
|
688 } |
|
689 |
|
690 return response.json().catch(function () { |
|
691 throw invalidJsonError; |
|
692 }).then(function (error) { |
|
693 var unknownError = { |
|
694 code: 'unknown_error', |
|
695 message: Object(external_this_wp_i18n_["__"])('An unknown error occurred.') |
|
696 }; |
|
697 throw error || unknownError; |
|
698 }); |
|
699 }); |
|
700 }; |
|
701 |
|
702 var fetchHandler = build_module_defaultFetchHandler; |
|
703 /** |
|
704 * Defines a custom fetch handler for making the requests that will override |
|
705 * the default one using window.fetch |
|
706 * |
|
707 * @param {Function} newFetchHandler The new fetch handler |
|
708 */ |
|
709 |
|
710 function setFetchHandler(newFetchHandler) { |
|
711 fetchHandler = newFetchHandler; |
|
712 } |
|
713 |
|
714 function apiFetch(options) { |
|
715 var steps = [].concat(middlewares, [fetchHandler]); |
|
716 |
|
717 var createRunStep = function createRunStep(index) { |
|
718 return function (workingOptions) { |
|
719 var step = steps[index]; |
|
720 |
|
721 if (index === steps.length - 1) { |
|
722 return step(workingOptions); |
|
723 } |
|
724 |
|
725 var next = createRunStep(index + 1); |
|
726 return step(workingOptions, next); |
|
727 }; |
|
728 }; |
|
729 |
|
730 return createRunStep(0)(options); |
|
731 } |
|
732 |
|
733 apiFetch.use = registerMiddleware; |
|
734 apiFetch.setFetchHandler = setFetchHandler; |
|
735 apiFetch.createNonceMiddleware = middlewares_nonce; |
|
736 apiFetch.createPreloadingMiddleware = preloading; |
|
737 apiFetch.createRootURLMiddleware = root_url; |
|
738 apiFetch.fetchAllMiddleware = fetch_all_middleware; |
|
739 /* harmony default export */ var build_module = __webpack_exports__["default"] = (apiFetch); |
|
740 |
|
741 |
|
742 /***/ }), |
|
743 |
|
744 /***/ 44: |
|
745 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
941 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
746 |
942 |
747 "use strict"; |
943 "use strict"; |
748 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; }); |
944 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; }); |
749 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
945 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
780 _next(undefined); |
976 _next(undefined); |
781 }); |
977 }); |
782 }; |
978 }; |
783 } |
979 } |
784 |
980 |
785 /***/ }), |
|
786 |
|
787 /***/ 54: |
|
788 /***/ (function(module, exports, __webpack_require__) { |
|
789 |
|
790 /** |
|
791 * Copyright (c) 2014-present, Facebook, Inc. |
|
792 * |
|
793 * This source code is licensed under the MIT license found in the |
|
794 * LICENSE file in the root directory of this source tree. |
|
795 */ |
|
796 |
|
797 // This method of obtaining a reference to the global object needs to be |
|
798 // kept identical to the way it is obtained in runtime.js |
|
799 var g = (function() { |
|
800 return this || (typeof self === "object" && self); |
|
801 })() || Function("return this")(); |
|
802 |
|
803 // Use `getOwnPropertyNames` because not all browsers support calling |
|
804 // `hasOwnProperty` on the global `self` object in a worker. See #183. |
|
805 var hadRuntime = g.regeneratorRuntime && |
|
806 Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; |
|
807 |
|
808 // Save the old regeneratorRuntime in case it needs to be restored later. |
|
809 var oldRuntime = hadRuntime && g.regeneratorRuntime; |
|
810 |
|
811 // Force reevalutation of runtime.js. |
|
812 g.regeneratorRuntime = undefined; |
|
813 |
|
814 module.exports = __webpack_require__(55); |
|
815 |
|
816 if (hadRuntime) { |
|
817 // Restore the original runtime. |
|
818 g.regeneratorRuntime = oldRuntime; |
|
819 } else { |
|
820 // Remove the global property added by runtime.js. |
|
821 try { |
|
822 delete g.regeneratorRuntime; |
|
823 } catch(e) { |
|
824 g.regeneratorRuntime = undefined; |
|
825 } |
|
826 } |
|
827 |
|
828 |
|
829 /***/ }), |
|
830 |
|
831 /***/ 55: |
|
832 /***/ (function(module, exports) { |
|
833 |
|
834 /** |
|
835 * Copyright (c) 2014-present, Facebook, Inc. |
|
836 * |
|
837 * This source code is licensed under the MIT license found in the |
|
838 * LICENSE file in the root directory of this source tree. |
|
839 */ |
|
840 |
|
841 !(function(global) { |
|
842 "use strict"; |
|
843 |
|
844 var Op = Object.prototype; |
|
845 var hasOwn = Op.hasOwnProperty; |
|
846 var undefined; // More compressible than void 0. |
|
847 var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
|
848 var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
|
849 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
|
850 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
|
851 |
|
852 var inModule = typeof module === "object"; |
|
853 var runtime = global.regeneratorRuntime; |
|
854 if (runtime) { |
|
855 if (inModule) { |
|
856 // If regeneratorRuntime is defined globally and we're in a module, |
|
857 // make the exports object identical to regeneratorRuntime. |
|
858 module.exports = runtime; |
|
859 } |
|
860 // Don't bother evaluating the rest of this file if the runtime was |
|
861 // already defined globally. |
|
862 return; |
|
863 } |
|
864 |
|
865 // Define the runtime globally (as expected by generated code) as either |
|
866 // module.exports (if we're in a module) or a new, empty object. |
|
867 runtime = global.regeneratorRuntime = inModule ? module.exports : {}; |
|
868 |
|
869 function wrap(innerFn, outerFn, self, tryLocsList) { |
|
870 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. |
|
871 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
|
872 var generator = Object.create(protoGenerator.prototype); |
|
873 var context = new Context(tryLocsList || []); |
|
874 |
|
875 // The ._invoke method unifies the implementations of the .next, |
|
876 // .throw, and .return methods. |
|
877 generator._invoke = makeInvokeMethod(innerFn, self, context); |
|
878 |
|
879 return generator; |
|
880 } |
|
881 runtime.wrap = wrap; |
|
882 |
|
883 // Try/catch helper to minimize deoptimizations. Returns a completion |
|
884 // record like context.tryEntries[i].completion. This interface could |
|
885 // have been (and was previously) designed to take a closure to be |
|
886 // invoked without arguments, but in all the cases we care about we |
|
887 // already have an existing method we want to call, so there's no need |
|
888 // to create a new function object. We can even get away with assuming |
|
889 // the method takes exactly one argument, since that happens to be true |
|
890 // in every case, so we don't have to touch the arguments object. The |
|
891 // only additional allocation required is the completion record, which |
|
892 // has a stable shape and so hopefully should be cheap to allocate. |
|
893 function tryCatch(fn, obj, arg) { |
|
894 try { |
|
895 return { type: "normal", arg: fn.call(obj, arg) }; |
|
896 } catch (err) { |
|
897 return { type: "throw", arg: err }; |
|
898 } |
|
899 } |
|
900 |
|
901 var GenStateSuspendedStart = "suspendedStart"; |
|
902 var GenStateSuspendedYield = "suspendedYield"; |
|
903 var GenStateExecuting = "executing"; |
|
904 var GenStateCompleted = "completed"; |
|
905 |
|
906 // Returning this object from the innerFn has the same effect as |
|
907 // breaking out of the dispatch switch statement. |
|
908 var ContinueSentinel = {}; |
|
909 |
|
910 // Dummy constructor functions that we use as the .constructor and |
|
911 // .constructor.prototype properties for functions that return Generator |
|
912 // objects. For full spec compliance, you may wish to configure your |
|
913 // minifier not to mangle the names of these two functions. |
|
914 function Generator() {} |
|
915 function GeneratorFunction() {} |
|
916 function GeneratorFunctionPrototype() {} |
|
917 |
|
918 // This is a polyfill for %IteratorPrototype% for environments that |
|
919 // don't natively support it. |
|
920 var IteratorPrototype = {}; |
|
921 IteratorPrototype[iteratorSymbol] = function () { |
|
922 return this; |
|
923 }; |
|
924 |
|
925 var getProto = Object.getPrototypeOf; |
|
926 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
|
927 if (NativeIteratorPrototype && |
|
928 NativeIteratorPrototype !== Op && |
|
929 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { |
|
930 // This environment has a native %IteratorPrototype%; use it instead |
|
931 // of the polyfill. |
|
932 IteratorPrototype = NativeIteratorPrototype; |
|
933 } |
|
934 |
|
935 var Gp = GeneratorFunctionPrototype.prototype = |
|
936 Generator.prototype = Object.create(IteratorPrototype); |
|
937 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; |
|
938 GeneratorFunctionPrototype.constructor = GeneratorFunction; |
|
939 GeneratorFunctionPrototype[toStringTagSymbol] = |
|
940 GeneratorFunction.displayName = "GeneratorFunction"; |
|
941 |
|
942 // Helper for defining the .next, .throw, and .return methods of the |
|
943 // Iterator interface in terms of a single ._invoke method. |
|
944 function defineIteratorMethods(prototype) { |
|
945 ["next", "throw", "return"].forEach(function(method) { |
|
946 prototype[method] = function(arg) { |
|
947 return this._invoke(method, arg); |
|
948 }; |
|
949 }); |
|
950 } |
|
951 |
|
952 runtime.isGeneratorFunction = function(genFun) { |
|
953 var ctor = typeof genFun === "function" && genFun.constructor; |
|
954 return ctor |
|
955 ? ctor === GeneratorFunction || |
|
956 // For the native GeneratorFunction constructor, the best we can |
|
957 // do is to check its .name property. |
|
958 (ctor.displayName || ctor.name) === "GeneratorFunction" |
|
959 : false; |
|
960 }; |
|
961 |
|
962 runtime.mark = function(genFun) { |
|
963 if (Object.setPrototypeOf) { |
|
964 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
|
965 } else { |
|
966 genFun.__proto__ = GeneratorFunctionPrototype; |
|
967 if (!(toStringTagSymbol in genFun)) { |
|
968 genFun[toStringTagSymbol] = "GeneratorFunction"; |
|
969 } |
|
970 } |
|
971 genFun.prototype = Object.create(Gp); |
|
972 return genFun; |
|
973 }; |
|
974 |
|
975 // Within the body of any async function, `await x` is transformed to |
|
976 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test |
|
977 // `hasOwn.call(value, "__await")` to determine if the yielded value is |
|
978 // meant to be awaited. |
|
979 runtime.awrap = function(arg) { |
|
980 return { __await: arg }; |
|
981 }; |
|
982 |
|
983 function AsyncIterator(generator) { |
|
984 function invoke(method, arg, resolve, reject) { |
|
985 var record = tryCatch(generator[method], generator, arg); |
|
986 if (record.type === "throw") { |
|
987 reject(record.arg); |
|
988 } else { |
|
989 var result = record.arg; |
|
990 var value = result.value; |
|
991 if (value && |
|
992 typeof value === "object" && |
|
993 hasOwn.call(value, "__await")) { |
|
994 return Promise.resolve(value.__await).then(function(value) { |
|
995 invoke("next", value, resolve, reject); |
|
996 }, function(err) { |
|
997 invoke("throw", err, resolve, reject); |
|
998 }); |
|
999 } |
|
1000 |
|
1001 return Promise.resolve(value).then(function(unwrapped) { |
|
1002 // When a yielded Promise is resolved, its final value becomes |
|
1003 // the .value of the Promise<{value,done}> result for the |
|
1004 // current iteration. |
|
1005 result.value = unwrapped; |
|
1006 resolve(result); |
|
1007 }, function(error) { |
|
1008 // If a rejected Promise was yielded, throw the rejection back |
|
1009 // into the async generator function so it can be handled there. |
|
1010 return invoke("throw", error, resolve, reject); |
|
1011 }); |
|
1012 } |
|
1013 } |
|
1014 |
|
1015 var previousPromise; |
|
1016 |
|
1017 function enqueue(method, arg) { |
|
1018 function callInvokeWithMethodAndArg() { |
|
1019 return new Promise(function(resolve, reject) { |
|
1020 invoke(method, arg, resolve, reject); |
|
1021 }); |
|
1022 } |
|
1023 |
|
1024 return previousPromise = |
|
1025 // If enqueue has been called before, then we want to wait until |
|
1026 // all previous Promises have been resolved before calling invoke, |
|
1027 // so that results are always delivered in the correct order. If |
|
1028 // enqueue has not been called before, then it is important to |
|
1029 // call invoke immediately, without waiting on a callback to fire, |
|
1030 // so that the async generator function has the opportunity to do |
|
1031 // any necessary setup in a predictable way. This predictability |
|
1032 // is why the Promise constructor synchronously invokes its |
|
1033 // executor callback, and why async functions synchronously |
|
1034 // execute code before the first await. Since we implement simple |
|
1035 // async functions in terms of async generators, it is especially |
|
1036 // important to get this right, even though it requires care. |
|
1037 previousPromise ? previousPromise.then( |
|
1038 callInvokeWithMethodAndArg, |
|
1039 // Avoid propagating failures to Promises returned by later |
|
1040 // invocations of the iterator. |
|
1041 callInvokeWithMethodAndArg |
|
1042 ) : callInvokeWithMethodAndArg(); |
|
1043 } |
|
1044 |
|
1045 // Define the unified helper method that is used to implement .next, |
|
1046 // .throw, and .return (see defineIteratorMethods). |
|
1047 this._invoke = enqueue; |
|
1048 } |
|
1049 |
|
1050 defineIteratorMethods(AsyncIterator.prototype); |
|
1051 AsyncIterator.prototype[asyncIteratorSymbol] = function () { |
|
1052 return this; |
|
1053 }; |
|
1054 runtime.AsyncIterator = AsyncIterator; |
|
1055 |
|
1056 // Note that simple async functions are implemented on top of |
|
1057 // AsyncIterator objects; they just return a Promise for the value of |
|
1058 // the final result produced by the iterator. |
|
1059 runtime.async = function(innerFn, outerFn, self, tryLocsList) { |
|
1060 var iter = new AsyncIterator( |
|
1061 wrap(innerFn, outerFn, self, tryLocsList) |
|
1062 ); |
|
1063 |
|
1064 return runtime.isGeneratorFunction(outerFn) |
|
1065 ? iter // If outerFn is a generator, return the full iterator. |
|
1066 : iter.next().then(function(result) { |
|
1067 return result.done ? result.value : iter.next(); |
|
1068 }); |
|
1069 }; |
|
1070 |
|
1071 function makeInvokeMethod(innerFn, self, context) { |
|
1072 var state = GenStateSuspendedStart; |
|
1073 |
|
1074 return function invoke(method, arg) { |
|
1075 if (state === GenStateExecuting) { |
|
1076 throw new Error("Generator is already running"); |
|
1077 } |
|
1078 |
|
1079 if (state === GenStateCompleted) { |
|
1080 if (method === "throw") { |
|
1081 throw arg; |
|
1082 } |
|
1083 |
|
1084 // Be forgiving, per 25.3.3.3.3 of the spec: |
|
1085 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
|
1086 return doneResult(); |
|
1087 } |
|
1088 |
|
1089 context.method = method; |
|
1090 context.arg = arg; |
|
1091 |
|
1092 while (true) { |
|
1093 var delegate = context.delegate; |
|
1094 if (delegate) { |
|
1095 var delegateResult = maybeInvokeDelegate(delegate, context); |
|
1096 if (delegateResult) { |
|
1097 if (delegateResult === ContinueSentinel) continue; |
|
1098 return delegateResult; |
|
1099 } |
|
1100 } |
|
1101 |
|
1102 if (context.method === "next") { |
|
1103 // Setting context._sent for legacy support of Babel's |
|
1104 // function.sent implementation. |
|
1105 context.sent = context._sent = context.arg; |
|
1106 |
|
1107 } else if (context.method === "throw") { |
|
1108 if (state === GenStateSuspendedStart) { |
|
1109 state = GenStateCompleted; |
|
1110 throw context.arg; |
|
1111 } |
|
1112 |
|
1113 context.dispatchException(context.arg); |
|
1114 |
|
1115 } else if (context.method === "return") { |
|
1116 context.abrupt("return", context.arg); |
|
1117 } |
|
1118 |
|
1119 state = GenStateExecuting; |
|
1120 |
|
1121 var record = tryCatch(innerFn, self, context); |
|
1122 if (record.type === "normal") { |
|
1123 // If an exception is thrown from innerFn, we leave state === |
|
1124 // GenStateExecuting and loop back for another invocation. |
|
1125 state = context.done |
|
1126 ? GenStateCompleted |
|
1127 : GenStateSuspendedYield; |
|
1128 |
|
1129 if (record.arg === ContinueSentinel) { |
|
1130 continue; |
|
1131 } |
|
1132 |
|
1133 return { |
|
1134 value: record.arg, |
|
1135 done: context.done |
|
1136 }; |
|
1137 |
|
1138 } else if (record.type === "throw") { |
|
1139 state = GenStateCompleted; |
|
1140 // Dispatch the exception by looping back around to the |
|
1141 // context.dispatchException(context.arg) call above. |
|
1142 context.method = "throw"; |
|
1143 context.arg = record.arg; |
|
1144 } |
|
1145 } |
|
1146 }; |
|
1147 } |
|
1148 |
|
1149 // Call delegate.iterator[context.method](context.arg) and handle the |
|
1150 // result, either by returning a { value, done } result from the |
|
1151 // delegate iterator, or by modifying context.method and context.arg, |
|
1152 // setting context.delegate to null, and returning the ContinueSentinel. |
|
1153 function maybeInvokeDelegate(delegate, context) { |
|
1154 var method = delegate.iterator[context.method]; |
|
1155 if (method === undefined) { |
|
1156 // A .throw or .return when the delegate iterator has no .throw |
|
1157 // method always terminates the yield* loop. |
|
1158 context.delegate = null; |
|
1159 |
|
1160 if (context.method === "throw") { |
|
1161 if (delegate.iterator.return) { |
|
1162 // If the delegate iterator has a return method, give it a |
|
1163 // chance to clean up. |
|
1164 context.method = "return"; |
|
1165 context.arg = undefined; |
|
1166 maybeInvokeDelegate(delegate, context); |
|
1167 |
|
1168 if (context.method === "throw") { |
|
1169 // If maybeInvokeDelegate(context) changed context.method from |
|
1170 // "return" to "throw", let that override the TypeError below. |
|
1171 return ContinueSentinel; |
|
1172 } |
|
1173 } |
|
1174 |
|
1175 context.method = "throw"; |
|
1176 context.arg = new TypeError( |
|
1177 "The iterator does not provide a 'throw' method"); |
|
1178 } |
|
1179 |
|
1180 return ContinueSentinel; |
|
1181 } |
|
1182 |
|
1183 var record = tryCatch(method, delegate.iterator, context.arg); |
|
1184 |
|
1185 if (record.type === "throw") { |
|
1186 context.method = "throw"; |
|
1187 context.arg = record.arg; |
|
1188 context.delegate = null; |
|
1189 return ContinueSentinel; |
|
1190 } |
|
1191 |
|
1192 var info = record.arg; |
|
1193 |
|
1194 if (! info) { |
|
1195 context.method = "throw"; |
|
1196 context.arg = new TypeError("iterator result is not an object"); |
|
1197 context.delegate = null; |
|
1198 return ContinueSentinel; |
|
1199 } |
|
1200 |
|
1201 if (info.done) { |
|
1202 // Assign the result of the finished delegate to the temporary |
|
1203 // variable specified by delegate.resultName (see delegateYield). |
|
1204 context[delegate.resultName] = info.value; |
|
1205 |
|
1206 // Resume execution at the desired location (see delegateYield). |
|
1207 context.next = delegate.nextLoc; |
|
1208 |
|
1209 // If context.method was "throw" but the delegate handled the |
|
1210 // exception, let the outer generator proceed normally. If |
|
1211 // context.method was "next", forget context.arg since it has been |
|
1212 // "consumed" by the delegate iterator. If context.method was |
|
1213 // "return", allow the original .return call to continue in the |
|
1214 // outer generator. |
|
1215 if (context.method !== "return") { |
|
1216 context.method = "next"; |
|
1217 context.arg = undefined; |
|
1218 } |
|
1219 |
|
1220 } else { |
|
1221 // Re-yield the result returned by the delegate method. |
|
1222 return info; |
|
1223 } |
|
1224 |
|
1225 // The delegate iterator is finished, so forget it and continue with |
|
1226 // the outer generator. |
|
1227 context.delegate = null; |
|
1228 return ContinueSentinel; |
|
1229 } |
|
1230 |
|
1231 // Define Generator.prototype.{next,throw,return} in terms of the |
|
1232 // unified ._invoke helper method. |
|
1233 defineIteratorMethods(Gp); |
|
1234 |
|
1235 Gp[toStringTagSymbol] = "Generator"; |
|
1236 |
|
1237 // A Generator should always return itself as the iterator object when the |
|
1238 // @@iterator function is called on it. Some browsers' implementations of the |
|
1239 // iterator prototype chain incorrectly implement this, causing the Generator |
|
1240 // object to not be returned from this call. This ensures that doesn't happen. |
|
1241 // See https://github.com/facebook/regenerator/issues/274 for more details. |
|
1242 Gp[iteratorSymbol] = function() { |
|
1243 return this; |
|
1244 }; |
|
1245 |
|
1246 Gp.toString = function() { |
|
1247 return "[object Generator]"; |
|
1248 }; |
|
1249 |
|
1250 function pushTryEntry(locs) { |
|
1251 var entry = { tryLoc: locs[0] }; |
|
1252 |
|
1253 if (1 in locs) { |
|
1254 entry.catchLoc = locs[1]; |
|
1255 } |
|
1256 |
|
1257 if (2 in locs) { |
|
1258 entry.finallyLoc = locs[2]; |
|
1259 entry.afterLoc = locs[3]; |
|
1260 } |
|
1261 |
|
1262 this.tryEntries.push(entry); |
|
1263 } |
|
1264 |
|
1265 function resetTryEntry(entry) { |
|
1266 var record = entry.completion || {}; |
|
1267 record.type = "normal"; |
|
1268 delete record.arg; |
|
1269 entry.completion = record; |
|
1270 } |
|
1271 |
|
1272 function Context(tryLocsList) { |
|
1273 // The root entry object (effectively a try statement without a catch |
|
1274 // or a finally block) gives us a place to store values thrown from |
|
1275 // locations where there is no enclosing try statement. |
|
1276 this.tryEntries = [{ tryLoc: "root" }]; |
|
1277 tryLocsList.forEach(pushTryEntry, this); |
|
1278 this.reset(true); |
|
1279 } |
|
1280 |
|
1281 runtime.keys = function(object) { |
|
1282 var keys = []; |
|
1283 for (var key in object) { |
|
1284 keys.push(key); |
|
1285 } |
|
1286 keys.reverse(); |
|
1287 |
|
1288 // Rather than returning an object with a next method, we keep |
|
1289 // things simple and return the next function itself. |
|
1290 return function next() { |
|
1291 while (keys.length) { |
|
1292 var key = keys.pop(); |
|
1293 if (key in object) { |
|
1294 next.value = key; |
|
1295 next.done = false; |
|
1296 return next; |
|
1297 } |
|
1298 } |
|
1299 |
|
1300 // To avoid creating an additional object, we just hang the .value |
|
1301 // and .done properties off the next function object itself. This |
|
1302 // also ensures that the minifier will not anonymize the function. |
|
1303 next.done = true; |
|
1304 return next; |
|
1305 }; |
|
1306 }; |
|
1307 |
|
1308 function values(iterable) { |
|
1309 if (iterable) { |
|
1310 var iteratorMethod = iterable[iteratorSymbol]; |
|
1311 if (iteratorMethod) { |
|
1312 return iteratorMethod.call(iterable); |
|
1313 } |
|
1314 |
|
1315 if (typeof iterable.next === "function") { |
|
1316 return iterable; |
|
1317 } |
|
1318 |
|
1319 if (!isNaN(iterable.length)) { |
|
1320 var i = -1, next = function next() { |
|
1321 while (++i < iterable.length) { |
|
1322 if (hasOwn.call(iterable, i)) { |
|
1323 next.value = iterable[i]; |
|
1324 next.done = false; |
|
1325 return next; |
|
1326 } |
|
1327 } |
|
1328 |
|
1329 next.value = undefined; |
|
1330 next.done = true; |
|
1331 |
|
1332 return next; |
|
1333 }; |
|
1334 |
|
1335 return next.next = next; |
|
1336 } |
|
1337 } |
|
1338 |
|
1339 // Return an iterator with no values. |
|
1340 return { next: doneResult }; |
|
1341 } |
|
1342 runtime.values = values; |
|
1343 |
|
1344 function doneResult() { |
|
1345 return { value: undefined, done: true }; |
|
1346 } |
|
1347 |
|
1348 Context.prototype = { |
|
1349 constructor: Context, |
|
1350 |
|
1351 reset: function(skipTempReset) { |
|
1352 this.prev = 0; |
|
1353 this.next = 0; |
|
1354 // Resetting context._sent for legacy support of Babel's |
|
1355 // function.sent implementation. |
|
1356 this.sent = this._sent = undefined; |
|
1357 this.done = false; |
|
1358 this.delegate = null; |
|
1359 |
|
1360 this.method = "next"; |
|
1361 this.arg = undefined; |
|
1362 |
|
1363 this.tryEntries.forEach(resetTryEntry); |
|
1364 |
|
1365 if (!skipTempReset) { |
|
1366 for (var name in this) { |
|
1367 // Not sure about the optimal order of these conditions: |
|
1368 if (name.charAt(0) === "t" && |
|
1369 hasOwn.call(this, name) && |
|
1370 !isNaN(+name.slice(1))) { |
|
1371 this[name] = undefined; |
|
1372 } |
|
1373 } |
|
1374 } |
|
1375 }, |
|
1376 |
|
1377 stop: function() { |
|
1378 this.done = true; |
|
1379 |
|
1380 var rootEntry = this.tryEntries[0]; |
|
1381 var rootRecord = rootEntry.completion; |
|
1382 if (rootRecord.type === "throw") { |
|
1383 throw rootRecord.arg; |
|
1384 } |
|
1385 |
|
1386 return this.rval; |
|
1387 }, |
|
1388 |
|
1389 dispatchException: function(exception) { |
|
1390 if (this.done) { |
|
1391 throw exception; |
|
1392 } |
|
1393 |
|
1394 var context = this; |
|
1395 function handle(loc, caught) { |
|
1396 record.type = "throw"; |
|
1397 record.arg = exception; |
|
1398 context.next = loc; |
|
1399 |
|
1400 if (caught) { |
|
1401 // If the dispatched exception was caught by a catch block, |
|
1402 // then let that catch block handle the exception normally. |
|
1403 context.method = "next"; |
|
1404 context.arg = undefined; |
|
1405 } |
|
1406 |
|
1407 return !! caught; |
|
1408 } |
|
1409 |
|
1410 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
1411 var entry = this.tryEntries[i]; |
|
1412 var record = entry.completion; |
|
1413 |
|
1414 if (entry.tryLoc === "root") { |
|
1415 // Exception thrown outside of any try block that could handle |
|
1416 // it, so set the completion value of the entire function to |
|
1417 // throw the exception. |
|
1418 return handle("end"); |
|
1419 } |
|
1420 |
|
1421 if (entry.tryLoc <= this.prev) { |
|
1422 var hasCatch = hasOwn.call(entry, "catchLoc"); |
|
1423 var hasFinally = hasOwn.call(entry, "finallyLoc"); |
|
1424 |
|
1425 if (hasCatch && hasFinally) { |
|
1426 if (this.prev < entry.catchLoc) { |
|
1427 return handle(entry.catchLoc, true); |
|
1428 } else if (this.prev < entry.finallyLoc) { |
|
1429 return handle(entry.finallyLoc); |
|
1430 } |
|
1431 |
|
1432 } else if (hasCatch) { |
|
1433 if (this.prev < entry.catchLoc) { |
|
1434 return handle(entry.catchLoc, true); |
|
1435 } |
|
1436 |
|
1437 } else if (hasFinally) { |
|
1438 if (this.prev < entry.finallyLoc) { |
|
1439 return handle(entry.finallyLoc); |
|
1440 } |
|
1441 |
|
1442 } else { |
|
1443 throw new Error("try statement without catch or finally"); |
|
1444 } |
|
1445 } |
|
1446 } |
|
1447 }, |
|
1448 |
|
1449 abrupt: function(type, arg) { |
|
1450 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
1451 var entry = this.tryEntries[i]; |
|
1452 if (entry.tryLoc <= this.prev && |
|
1453 hasOwn.call(entry, "finallyLoc") && |
|
1454 this.prev < entry.finallyLoc) { |
|
1455 var finallyEntry = entry; |
|
1456 break; |
|
1457 } |
|
1458 } |
|
1459 |
|
1460 if (finallyEntry && |
|
1461 (type === "break" || |
|
1462 type === "continue") && |
|
1463 finallyEntry.tryLoc <= arg && |
|
1464 arg <= finallyEntry.finallyLoc) { |
|
1465 // Ignore the finally entry if control is not jumping to a |
|
1466 // location outside the try/catch block. |
|
1467 finallyEntry = null; |
|
1468 } |
|
1469 |
|
1470 var record = finallyEntry ? finallyEntry.completion : {}; |
|
1471 record.type = type; |
|
1472 record.arg = arg; |
|
1473 |
|
1474 if (finallyEntry) { |
|
1475 this.method = "next"; |
|
1476 this.next = finallyEntry.finallyLoc; |
|
1477 return ContinueSentinel; |
|
1478 } |
|
1479 |
|
1480 return this.complete(record); |
|
1481 }, |
|
1482 |
|
1483 complete: function(record, afterLoc) { |
|
1484 if (record.type === "throw") { |
|
1485 throw record.arg; |
|
1486 } |
|
1487 |
|
1488 if (record.type === "break" || |
|
1489 record.type === "continue") { |
|
1490 this.next = record.arg; |
|
1491 } else if (record.type === "return") { |
|
1492 this.rval = this.arg = record.arg; |
|
1493 this.method = "return"; |
|
1494 this.next = "end"; |
|
1495 } else if (record.type === "normal" && afterLoc) { |
|
1496 this.next = afterLoc; |
|
1497 } |
|
1498 |
|
1499 return ContinueSentinel; |
|
1500 }, |
|
1501 |
|
1502 finish: function(finallyLoc) { |
|
1503 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
1504 var entry = this.tryEntries[i]; |
|
1505 if (entry.finallyLoc === finallyLoc) { |
|
1506 this.complete(entry.completion, entry.afterLoc); |
|
1507 resetTryEntry(entry); |
|
1508 return ContinueSentinel; |
|
1509 } |
|
1510 } |
|
1511 }, |
|
1512 |
|
1513 "catch": function(tryLoc) { |
|
1514 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
1515 var entry = this.tryEntries[i]; |
|
1516 if (entry.tryLoc === tryLoc) { |
|
1517 var record = entry.completion; |
|
1518 if (record.type === "throw") { |
|
1519 var thrown = record.arg; |
|
1520 resetTryEntry(entry); |
|
1521 } |
|
1522 return thrown; |
|
1523 } |
|
1524 } |
|
1525 |
|
1526 // The context.catch method must only be called with a location |
|
1527 // argument that corresponds to a known catch block. |
|
1528 throw new Error("illegal catch attempt"); |
|
1529 }, |
|
1530 |
|
1531 delegateYield: function(iterable, resultName, nextLoc) { |
|
1532 this.delegate = { |
|
1533 iterator: values(iterable), |
|
1534 resultName: resultName, |
|
1535 nextLoc: nextLoc |
|
1536 }; |
|
1537 |
|
1538 if (this.method === "next") { |
|
1539 // Deliberately forget the last sent value so that we don't |
|
1540 // accidentally pass it on to the delegate. |
|
1541 this.arg = undefined; |
|
1542 } |
|
1543 |
|
1544 return ContinueSentinel; |
|
1545 } |
|
1546 }; |
|
1547 })( |
|
1548 // In sloppy mode, unbound `this` refers to the global object, fallback to |
|
1549 // Function constructor if we're in global strict mode. That is sadly a form |
|
1550 // of indirect eval which violates Content Security Policy. |
|
1551 (function() { |
|
1552 return this || (typeof self === "object" && self); |
|
1553 })() || Function("return this")() |
|
1554 ); |
|
1555 |
|
1556 |
|
1557 /***/ }), |
|
1558 |
|
1559 /***/ 7: |
|
1560 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1561 |
|
1562 "use strict"; |
|
1563 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; }); |
|
1564 /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); |
|
1565 |
|
1566 function _objectSpread(target) { |
|
1567 for (var i = 1; i < arguments.length; i++) { |
|
1568 var source = arguments[i] != null ? arguments[i] : {}; |
|
1569 var ownKeys = Object.keys(source); |
|
1570 |
|
1571 if (typeof Object.getOwnPropertySymbols === 'function') { |
|
1572 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { |
|
1573 return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
|
1574 })); |
|
1575 } |
|
1576 |
|
1577 ownKeys.forEach(function (key) { |
|
1578 Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]); |
|
1579 }); |
|
1580 } |
|
1581 |
|
1582 return target; |
|
1583 } |
|
1584 |
|
1585 /***/ }) |
981 /***/ }) |
1586 |
982 |
1587 /******/ })["default"]; |
983 /******/ })["default"]; |