9
|
1 |
this["wp"] = this["wp"] || {}; this["wp"]["apiFetch"] = |
|
2 |
/******/ (function(modules) { // webpackBootstrap |
|
3 |
/******/ // The module cache |
|
4 |
/******/ var installedModules = {}; |
|
5 |
/******/ |
|
6 |
/******/ // The require function |
|
7 |
/******/ function __webpack_require__(moduleId) { |
|
8 |
/******/ |
|
9 |
/******/ // Check if module is in cache |
|
10 |
/******/ if(installedModules[moduleId]) { |
|
11 |
/******/ return installedModules[moduleId].exports; |
|
12 |
/******/ } |
|
13 |
/******/ // Create a new module (and put it into the cache) |
|
14 |
/******/ var module = installedModules[moduleId] = { |
|
15 |
/******/ i: moduleId, |
|
16 |
/******/ l: false, |
|
17 |
/******/ exports: {} |
|
18 |
/******/ }; |
|
19 |
/******/ |
|
20 |
/******/ // Execute the module function |
|
21 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
22 |
/******/ |
|
23 |
/******/ // Flag the module as loaded |
|
24 |
/******/ module.l = true; |
|
25 |
/******/ |
|
26 |
/******/ // Return the exports of the module |
|
27 |
/******/ return module.exports; |
|
28 |
/******/ } |
|
29 |
/******/ |
|
30 |
/******/ |
|
31 |
/******/ // expose the modules object (__webpack_modules__) |
|
32 |
/******/ __webpack_require__.m = modules; |
|
33 |
/******/ |
|
34 |
/******/ // expose the module cache |
|
35 |
/******/ __webpack_require__.c = installedModules; |
|
36 |
/******/ |
|
37 |
/******/ // define getter function for harmony exports |
|
38 |
/******/ __webpack_require__.d = function(exports, name, getter) { |
|
39 |
/******/ if(!__webpack_require__.o(exports, name)) { |
|
40 |
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
41 |
/******/ } |
|
42 |
/******/ }; |
|
43 |
/******/ |
|
44 |
/******/ // define __esModule on exports |
|
45 |
/******/ __webpack_require__.r = function(exports) { |
|
46 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
47 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
48 |
/******/ } |
|
49 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 |
/******/ }; |
|
51 |
/******/ |
|
52 |
/******/ // create a fake namespace object |
|
53 |
/******/ // mode & 1: value is a module id, require it |
|
54 |
/******/ // mode & 2: merge all properties of value into the ns |
|
55 |
/******/ // mode & 4: return value when already ns object |
|
56 |
/******/ // mode & 8|1: behave like require |
|
57 |
/******/ __webpack_require__.t = function(value, mode) { |
|
58 |
/******/ if(mode & 1) value = __webpack_require__(value); |
|
59 |
/******/ if(mode & 8) return value; |
|
60 |
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 |
/******/ var ns = Object.create(null); |
|
62 |
/******/ __webpack_require__.r(ns); |
|
63 |
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 |
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 |
/******/ return ns; |
|
66 |
/******/ }; |
|
67 |
/******/ |
|
68 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 |
/******/ __webpack_require__.n = function(module) { |
|
70 |
/******/ var getter = module && module.__esModule ? |
|
71 |
/******/ function getDefault() { return module['default']; } : |
|
72 |
/******/ function getModuleExports() { return module; }; |
|
73 |
/******/ __webpack_require__.d(getter, 'a', getter); |
|
74 |
/******/ return getter; |
|
75 |
/******/ }; |
|
76 |
/******/ |
|
77 |
/******/ // Object.prototype.hasOwnProperty.call |
|
78 |
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 |
/******/ |
|
80 |
/******/ // __webpack_public_path__ |
|
81 |
/******/ __webpack_require__.p = ""; |
|
82 |
/******/ |
|
83 |
/******/ |
|
84 |
/******/ // Load entry module and return exports |
|
85 |
/******/ return __webpack_require__(__webpack_require__.s = 369); |
|
86 |
/******/ }) |
|
87 |
/************************************************************************/ |
|
88 |
/******/ ({ |
|
89 |
|
|
90 |
/***/ 1: |
|
91 |
/***/ (function(module, exports) { |
|
92 |
|
|
93 |
(function() { module.exports = this["wp"]["i18n"]; }()); |
|
94 |
|
|
95 |
/***/ }), |
|
96 |
|
|
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 _defineProperty; }); |
|
102 |
function _defineProperty(obj, key, value) { |
|
103 |
if (key in obj) { |
|
104 |
Object.defineProperty(obj, key, { |
|
105 |
value: value, |
|
106 |
enumerable: true, |
|
107 |
configurable: true, |
|
108 |
writable: true |
|
109 |
}); |
|
110 |
} else { |
|
111 |
obj[key] = value; |
|
112 |
} |
|
113 |
|
|
114 |
return obj; |
|
115 |
} |
|
116 |
|
|
117 |
/***/ }), |
|
118 |
|
|
119 |
/***/ 21: |
|
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__) { |
|
746 |
|
|
747 |
"use strict"; |
|
748 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; }); |
|
749 |
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
|
750 |
try { |
|
751 |
var info = gen[key](arg); |
|
752 |
var value = info.value; |
|
753 |
} catch (error) { |
|
754 |
reject(error); |
|
755 |
return; |
|
756 |
} |
|
757 |
|
|
758 |
if (info.done) { |
|
759 |
resolve(value); |
|
760 |
} else { |
|
761 |
Promise.resolve(value).then(_next, _throw); |
|
762 |
} |
|
763 |
} |
|
764 |
|
|
765 |
function _asyncToGenerator(fn) { |
|
766 |
return function () { |
|
767 |
var self = this, |
|
768 |
args = arguments; |
|
769 |
return new Promise(function (resolve, reject) { |
|
770 |
var gen = fn.apply(self, args); |
|
771 |
|
|
772 |
function _next(value) { |
|
773 |
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); |
|
774 |
} |
|
775 |
|
|
776 |
function _throw(err) { |
|
777 |
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); |
|
778 |
} |
|
779 |
|
|
780 |
_next(undefined); |
|
781 |
}); |
|
782 |
}; |
|
783 |
} |
|
784 |
|
|
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 |
/***/ }) |
|
1586 |
|
|
1587 |
/******/ })["default"]; |