|
1 this["wp"] = this["wp"] || {}; this["wp"]["listReusableBlocks"] = |
|
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 = 373); |
|
86 /******/ }) |
|
87 /************************************************************************/ |
|
88 /******/ ({ |
|
89 |
|
90 /***/ 0: |
|
91 /***/ (function(module, exports) { |
|
92 |
|
93 (function() { module.exports = this["wp"]["element"]; }()); |
|
94 |
|
95 /***/ }), |
|
96 |
|
97 /***/ 1: |
|
98 /***/ (function(module, exports) { |
|
99 |
|
100 (function() { module.exports = this["wp"]["i18n"]; }()); |
|
101 |
|
102 /***/ }), |
|
103 |
|
104 /***/ 10: |
|
105 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
106 |
|
107 "use strict"; |
|
108 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; }); |
|
109 function _classCallCheck(instance, Constructor) { |
|
110 if (!(instance instanceof Constructor)) { |
|
111 throw new TypeError("Cannot call a class as a function"); |
|
112 } |
|
113 } |
|
114 |
|
115 /***/ }), |
|
116 |
|
117 /***/ 11: |
|
118 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
119 |
|
120 "use strict"; |
|
121 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; }); |
|
122 /* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(32); |
|
123 /* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3); |
|
124 |
|
125 |
|
126 function _possibleConstructorReturn(self, call) { |
|
127 if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) { |
|
128 return call; |
|
129 } |
|
130 |
|
131 return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self); |
|
132 } |
|
133 |
|
134 /***/ }), |
|
135 |
|
136 /***/ 12: |
|
137 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
138 |
|
139 "use strict"; |
|
140 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; }); |
|
141 function _getPrototypeOf(o) { |
|
142 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { |
|
143 return o.__proto__ || Object.getPrototypeOf(o); |
|
144 }; |
|
145 return _getPrototypeOf(o); |
|
146 } |
|
147 |
|
148 /***/ }), |
|
149 |
|
150 /***/ 13: |
|
151 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
152 |
|
153 "use strict"; |
|
154 |
|
155 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js |
|
156 function _setPrototypeOf(o, p) { |
|
157 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { |
|
158 o.__proto__ = p; |
|
159 return o; |
|
160 }; |
|
161 |
|
162 return _setPrototypeOf(o, p); |
|
163 } |
|
164 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js |
|
165 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; }); |
|
166 |
|
167 function _inherits(subClass, superClass) { |
|
168 if (typeof superClass !== "function" && superClass !== null) { |
|
169 throw new TypeError("Super expression must either be null or a function"); |
|
170 } |
|
171 |
|
172 subClass.prototype = Object.create(superClass && superClass.prototype, { |
|
173 constructor: { |
|
174 value: subClass, |
|
175 writable: true, |
|
176 configurable: true |
|
177 } |
|
178 }); |
|
179 if (superClass) _setPrototypeOf(subClass, superClass); |
|
180 } |
|
181 |
|
182 /***/ }), |
|
183 |
|
184 /***/ 2: |
|
185 /***/ (function(module, exports) { |
|
186 |
|
187 (function() { module.exports = this["lodash"]; }()); |
|
188 |
|
189 /***/ }), |
|
190 |
|
191 /***/ 23: |
|
192 /***/ (function(module, exports, __webpack_require__) { |
|
193 |
|
194 module.exports = __webpack_require__(54); |
|
195 |
|
196 |
|
197 /***/ }), |
|
198 |
|
199 /***/ 3: |
|
200 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
201 |
|
202 "use strict"; |
|
203 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; }); |
|
204 function _assertThisInitialized(self) { |
|
205 if (self === void 0) { |
|
206 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
|
207 } |
|
208 |
|
209 return self; |
|
210 } |
|
211 |
|
212 /***/ }), |
|
213 |
|
214 /***/ 32: |
|
215 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
216 |
|
217 "use strict"; |
|
218 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); |
|
219 function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } |
|
220 |
|
221 function _typeof(obj) { |
|
222 if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { |
|
223 _typeof = function _typeof(obj) { |
|
224 return _typeof2(obj); |
|
225 }; |
|
226 } else { |
|
227 _typeof = function _typeof(obj) { |
|
228 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); |
|
229 }; |
|
230 } |
|
231 |
|
232 return _typeof(obj); |
|
233 } |
|
234 |
|
235 /***/ }), |
|
236 |
|
237 /***/ 33: |
|
238 /***/ (function(module, exports) { |
|
239 |
|
240 (function() { module.exports = this["wp"]["apiFetch"]; }()); |
|
241 |
|
242 /***/ }), |
|
243 |
|
244 /***/ 373: |
|
245 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
246 |
|
247 "use strict"; |
|
248 __webpack_require__.r(__webpack_exports__); |
|
249 |
|
250 // EXTERNAL MODULE: external {"this":["wp","element"]} |
|
251 var external_this_wp_element_ = __webpack_require__(0); |
|
252 |
|
253 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
|
254 var external_this_wp_i18n_ = __webpack_require__(1); |
|
255 |
|
256 // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js |
|
257 var regenerator = __webpack_require__(23); |
|
258 var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator); |
|
259 |
|
260 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js |
|
261 var asyncToGenerator = __webpack_require__(44); |
|
262 |
|
263 // EXTERNAL MODULE: external "lodash" |
|
264 var external_lodash_ = __webpack_require__(2); |
|
265 |
|
266 // EXTERNAL MODULE: external {"this":["wp","apiFetch"]} |
|
267 var external_this_wp_apiFetch_ = __webpack_require__(33); |
|
268 var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_); |
|
269 |
|
270 // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js |
|
271 /** |
|
272 * Downloads a file. |
|
273 * |
|
274 * @param {string} fileName File Name. |
|
275 * @param {string} content File Content. |
|
276 * @param {string} contentType File mime type. |
|
277 */ |
|
278 function download(fileName, content, contentType) { |
|
279 var file = new window.Blob([content], { |
|
280 type: contentType |
|
281 }); // IE11 can't use the click to download technique |
|
282 // we use a specific IE11 technique instead. |
|
283 |
|
284 if (window.navigator.msSaveOrOpenBlob) { |
|
285 window.navigator.msSaveOrOpenBlob(file, fileName); |
|
286 } else { |
|
287 var a = document.createElement('a'); |
|
288 a.href = URL.createObjectURL(file); |
|
289 a.download = fileName; |
|
290 a.style.display = 'none'; |
|
291 document.body.appendChild(a); |
|
292 a.click(); |
|
293 document.body.removeChild(a); |
|
294 } |
|
295 } |
|
296 /** |
|
297 * Reads the textual content of the given file. |
|
298 * |
|
299 * @param {File} file File. |
|
300 * @return {Promise<string>} Content of the file. |
|
301 */ |
|
302 |
|
303 function readTextFile(file) { |
|
304 var reader = new window.FileReader(); |
|
305 return new Promise(function (resolve) { |
|
306 reader.onload = function () { |
|
307 resolve(reader.result); |
|
308 }; |
|
309 |
|
310 reader.readAsText(file); |
|
311 }); |
|
312 } |
|
313 |
|
314 // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/export.js |
|
315 |
|
316 |
|
317 |
|
318 /** |
|
319 * External dependencies |
|
320 */ |
|
321 |
|
322 /** |
|
323 * WordPress dependencies |
|
324 */ |
|
325 |
|
326 |
|
327 /** |
|
328 * Internal dependencies |
|
329 */ |
|
330 |
|
331 |
|
332 /** |
|
333 * Export a reusable block as a JSON file. |
|
334 * |
|
335 * @param {number} id |
|
336 */ |
|
337 |
|
338 function exportReusableBlock(_x) { |
|
339 return _exportReusableBlock.apply(this, arguments); |
|
340 } |
|
341 |
|
342 function _exportReusableBlock() { |
|
343 _exportReusableBlock = Object(asyncToGenerator["a" /* default */])( |
|
344 /*#__PURE__*/ |
|
345 regenerator_default.a.mark(function _callee(id) { |
|
346 var postType, post, title, content, fileContent, fileName; |
|
347 return regenerator_default.a.wrap(function _callee$(_context) { |
|
348 while (1) { |
|
349 switch (_context.prev = _context.next) { |
|
350 case 0: |
|
351 _context.next = 2; |
|
352 return external_this_wp_apiFetch_default()({ |
|
353 path: "/wp/v2/types/wp_block" |
|
354 }); |
|
355 |
|
356 case 2: |
|
357 postType = _context.sent; |
|
358 _context.next = 5; |
|
359 return external_this_wp_apiFetch_default()({ |
|
360 path: "/wp/v2/".concat(postType.rest_base, "/").concat(id, "?context=edit") |
|
361 }); |
|
362 |
|
363 case 5: |
|
364 post = _context.sent; |
|
365 title = post.title.raw; |
|
366 content = post.content.raw; |
|
367 fileContent = JSON.stringify({ |
|
368 __file: 'wp_block', |
|
369 title: title, |
|
370 content: content |
|
371 }, null, 2); |
|
372 fileName = Object(external_lodash_["kebabCase"])(title) + '.json'; |
|
373 download(fileName, fileContent, 'application/json'); |
|
374 |
|
375 case 11: |
|
376 case "end": |
|
377 return _context.stop(); |
|
378 } |
|
379 } |
|
380 }, _callee, this); |
|
381 })); |
|
382 return _exportReusableBlock.apply(this, arguments); |
|
383 } |
|
384 |
|
385 /* harmony default export */ var utils_export = (exportReusableBlock); |
|
386 |
|
387 // EXTERNAL MODULE: external {"this":["wp","components"]} |
|
388 var external_this_wp_components_ = __webpack_require__(4); |
|
389 |
|
390 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js |
|
391 var classCallCheck = __webpack_require__(10); |
|
392 |
|
393 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js |
|
394 var createClass = __webpack_require__(9); |
|
395 |
|
396 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js |
|
397 var possibleConstructorReturn = __webpack_require__(11); |
|
398 |
|
399 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js |
|
400 var getPrototypeOf = __webpack_require__(12); |
|
401 |
|
402 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules |
|
403 var inherits = __webpack_require__(13); |
|
404 |
|
405 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js |
|
406 var assertThisInitialized = __webpack_require__(3); |
|
407 |
|
408 // EXTERNAL MODULE: external {"this":["wp","compose"]} |
|
409 var external_this_wp_compose_ = __webpack_require__(6); |
|
410 |
|
411 // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js |
|
412 |
|
413 |
|
414 |
|
415 /** |
|
416 * External dependencies |
|
417 */ |
|
418 |
|
419 /** |
|
420 * WordPress dependencies |
|
421 */ |
|
422 |
|
423 |
|
424 /** |
|
425 * Internal dependencies |
|
426 */ |
|
427 |
|
428 |
|
429 /** |
|
430 * Import a reusable block from a JSON file. |
|
431 * |
|
432 * @param {File} file File. |
|
433 * @return {Promise} Promise returning the imported reusable block. |
|
434 */ |
|
435 |
|
436 function importReusableBlock(_x) { |
|
437 return _importReusableBlock.apply(this, arguments); |
|
438 } |
|
439 |
|
440 function _importReusableBlock() { |
|
441 _importReusableBlock = Object(asyncToGenerator["a" /* default */])( |
|
442 /*#__PURE__*/ |
|
443 regenerator_default.a.mark(function _callee(file) { |
|
444 var fileContent, parsedContent, postType, reusableBlock; |
|
445 return regenerator_default.a.wrap(function _callee$(_context) { |
|
446 while (1) { |
|
447 switch (_context.prev = _context.next) { |
|
448 case 0: |
|
449 _context.next = 2; |
|
450 return readTextFile(file); |
|
451 |
|
452 case 2: |
|
453 fileContent = _context.sent; |
|
454 _context.prev = 3; |
|
455 parsedContent = JSON.parse(fileContent); |
|
456 _context.next = 10; |
|
457 break; |
|
458 |
|
459 case 7: |
|
460 _context.prev = 7; |
|
461 _context.t0 = _context["catch"](3); |
|
462 throw new Error('Invalid JSON file'); |
|
463 |
|
464 case 10: |
|
465 if (!(parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || !Object(external_lodash_["isString"])(parsedContent.title) || !Object(external_lodash_["isString"])(parsedContent.content))) { |
|
466 _context.next = 12; |
|
467 break; |
|
468 } |
|
469 |
|
470 throw new Error('Invalid Reusable Block JSON file'); |
|
471 |
|
472 case 12: |
|
473 _context.next = 14; |
|
474 return external_this_wp_apiFetch_default()({ |
|
475 path: "/wp/v2/types/wp_block" |
|
476 }); |
|
477 |
|
478 case 14: |
|
479 postType = _context.sent; |
|
480 _context.next = 17; |
|
481 return external_this_wp_apiFetch_default()({ |
|
482 path: "/wp/v2/".concat(postType.rest_base), |
|
483 data: { |
|
484 title: parsedContent.title, |
|
485 content: parsedContent.content, |
|
486 status: 'publish' |
|
487 }, |
|
488 method: 'POST' |
|
489 }); |
|
490 |
|
491 case 17: |
|
492 reusableBlock = _context.sent; |
|
493 return _context.abrupt("return", reusableBlock); |
|
494 |
|
495 case 19: |
|
496 case "end": |
|
497 return _context.stop(); |
|
498 } |
|
499 } |
|
500 }, _callee, this, [[3, 7]]); |
|
501 })); |
|
502 return _importReusableBlock.apply(this, arguments); |
|
503 } |
|
504 |
|
505 /* harmony default export */ var utils_import = (importReusableBlock); |
|
506 |
|
507 // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-form/index.js |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 /** |
|
517 * WordPress dependencies |
|
518 */ |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 /** |
|
524 * Internal dependencies |
|
525 */ |
|
526 |
|
527 |
|
528 |
|
529 var import_form_ImportForm = |
|
530 /*#__PURE__*/ |
|
531 function (_Component) { |
|
532 Object(inherits["a" /* default */])(ImportForm, _Component); |
|
533 |
|
534 function ImportForm() { |
|
535 var _this; |
|
536 |
|
537 Object(classCallCheck["a" /* default */])(this, ImportForm); |
|
538 |
|
539 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(ImportForm).apply(this, arguments)); |
|
540 _this.state = { |
|
541 isLoading: false, |
|
542 error: null, |
|
543 file: null |
|
544 }; |
|
545 _this.isStillMounted = true; |
|
546 _this.onChangeFile = _this.onChangeFile.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
547 _this.onSubmit = _this.onSubmit.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
548 return _this; |
|
549 } |
|
550 |
|
551 Object(createClass["a" /* default */])(ImportForm, [{ |
|
552 key: "componentWillUnmount", |
|
553 value: function componentWillUnmount() { |
|
554 this.isStillMounted = false; |
|
555 } |
|
556 }, { |
|
557 key: "onChangeFile", |
|
558 value: function onChangeFile(event) { |
|
559 this.setState({ |
|
560 file: event.target.files[0] |
|
561 }); |
|
562 } |
|
563 }, { |
|
564 key: "onSubmit", |
|
565 value: function onSubmit(event) { |
|
566 var _this2 = this; |
|
567 |
|
568 event.preventDefault(); |
|
569 var file = this.state.file; |
|
570 var onUpload = this.props.onUpload; |
|
571 |
|
572 if (!file) { |
|
573 return; |
|
574 } |
|
575 |
|
576 this.setState({ |
|
577 isLoading: true |
|
578 }); |
|
579 utils_import(file).then(function (reusableBlock) { |
|
580 if (!_this2.isStillMounted) { |
|
581 return; |
|
582 } |
|
583 |
|
584 _this2.setState({ |
|
585 isLoading: false |
|
586 }); |
|
587 |
|
588 onUpload(reusableBlock); |
|
589 }).catch(function (error) { |
|
590 if (!_this2.isStillMounted) { |
|
591 return; |
|
592 } |
|
593 |
|
594 var uiMessage; |
|
595 |
|
596 switch (error.message) { |
|
597 case 'Invalid JSON file': |
|
598 uiMessage = Object(external_this_wp_i18n_["__"])('Invalid JSON file'); |
|
599 break; |
|
600 |
|
601 case 'Invalid Reusable Block JSON file': |
|
602 uiMessage = Object(external_this_wp_i18n_["__"])('Invalid Reusable Block JSON file'); |
|
603 break; |
|
604 |
|
605 default: |
|
606 uiMessage = Object(external_this_wp_i18n_["__"])('Unknown error'); |
|
607 } |
|
608 |
|
609 _this2.setState({ |
|
610 isLoading: false, |
|
611 error: uiMessage |
|
612 }); |
|
613 }); |
|
614 } |
|
615 }, { |
|
616 key: "render", |
|
617 value: function render() { |
|
618 var instanceId = this.props.instanceId; |
|
619 var _this$state = this.state, |
|
620 file = _this$state.file, |
|
621 isLoading = _this$state.isLoading, |
|
622 error = _this$state.error; |
|
623 var inputId = 'list-reusable-blocks-import-form-' + instanceId; |
|
624 return Object(external_this_wp_element_["createElement"])("form", { |
|
625 className: "list-reusable-blocks-import-form", |
|
626 onSubmit: this.onSubmit |
|
627 }, error && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Notice"], { |
|
628 status: "error" |
|
629 }, error), Object(external_this_wp_element_["createElement"])("label", { |
|
630 htmlFor: inputId, |
|
631 className: "list-reusable-blocks-import-form__label" |
|
632 }, Object(external_this_wp_i18n_["__"])('File')), Object(external_this_wp_element_["createElement"])("input", { |
|
633 id: inputId, |
|
634 type: "file", |
|
635 onChange: this.onChangeFile |
|
636 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
637 type: "submit", |
|
638 isBusy: isLoading, |
|
639 disabled: !file || isLoading, |
|
640 isDefault: true, |
|
641 className: "list-reusable-blocks-import-form__button" |
|
642 }, Object(external_this_wp_i18n_["_x"])('Import', 'button label'))); |
|
643 } |
|
644 }]); |
|
645 |
|
646 return ImportForm; |
|
647 }(external_this_wp_element_["Component"]); |
|
648 |
|
649 /* harmony default export */ var import_form = (Object(external_this_wp_compose_["withInstanceId"])(import_form_ImportForm)); |
|
650 |
|
651 // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js |
|
652 |
|
653 |
|
654 /** |
|
655 * External dependencies |
|
656 */ |
|
657 |
|
658 /** |
|
659 * WordPress dependencies |
|
660 */ |
|
661 |
|
662 |
|
663 |
|
664 /** |
|
665 * Internal dependencies |
|
666 */ |
|
667 |
|
668 |
|
669 |
|
670 function ImportDropdown(_ref) { |
|
671 var onUpload = _ref.onUpload; |
|
672 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dropdown"], { |
|
673 position: "bottom right", |
|
674 contentClassName: "list-reusable-blocks-import-dropdown__content", |
|
675 renderToggle: function renderToggle(_ref2) { |
|
676 var isOpen = _ref2.isOpen, |
|
677 onToggle = _ref2.onToggle; |
|
678 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
679 type: "button", |
|
680 "aria-expanded": isOpen, |
|
681 onClick: onToggle, |
|
682 isPrimary: true |
|
683 }, Object(external_this_wp_i18n_["__"])('Import from JSON')); |
|
684 }, |
|
685 renderContent: function renderContent(_ref3) { |
|
686 var onClose = _ref3.onClose; |
|
687 return Object(external_this_wp_element_["createElement"])(import_form, { |
|
688 onUpload: Object(external_lodash_["flow"])(onClose, onUpload) |
|
689 }); |
|
690 } |
|
691 }); |
|
692 } |
|
693 |
|
694 /* harmony default export */ var import_dropdown = (ImportDropdown); |
|
695 |
|
696 // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js |
|
697 |
|
698 |
|
699 /** |
|
700 * WordPress dependencies |
|
701 */ |
|
702 |
|
703 |
|
704 /** |
|
705 * Internal dependencies |
|
706 */ |
|
707 |
|
708 |
|
709 // Setup Export Links |
|
710 |
|
711 document.body.addEventListener('click', function (event) { |
|
712 if (!event.target.classList.contains('wp-list-reusable-blocks__export')) { |
|
713 return; |
|
714 } |
|
715 |
|
716 event.preventDefault(); |
|
717 utils_export(event.target.dataset.id); |
|
718 }); // Setup Import Form |
|
719 |
|
720 document.addEventListener('DOMContentLoaded', function () { |
|
721 var button = document.querySelector('.page-title-action'); |
|
722 |
|
723 if (!button) { |
|
724 return; |
|
725 } |
|
726 |
|
727 var showNotice = function showNotice() { |
|
728 var notice = document.createElement('div'); |
|
729 notice.className = 'notice notice-success is-dismissible'; |
|
730 notice.innerHTML = "<p>".concat(Object(external_this_wp_i18n_["__"])('Reusable block imported successfully!'), "</p>"); |
|
731 var headerEnd = document.querySelector('.wp-header-end'); |
|
732 |
|
733 if (!headerEnd) { |
|
734 return; |
|
735 } |
|
736 |
|
737 headerEnd.parentNode.insertBefore(notice, headerEnd); |
|
738 }; |
|
739 |
|
740 var container = document.createElement('div'); |
|
741 container.className = 'list-reusable-blocks__container'; |
|
742 button.parentNode.insertBefore(container, button); |
|
743 Object(external_this_wp_element_["render"])(Object(external_this_wp_element_["createElement"])(import_dropdown, { |
|
744 onUpload: showNotice |
|
745 }), container); |
|
746 }); |
|
747 |
|
748 |
|
749 /***/ }), |
|
750 |
|
751 /***/ 4: |
|
752 /***/ (function(module, exports) { |
|
753 |
|
754 (function() { module.exports = this["wp"]["components"]; }()); |
|
755 |
|
756 /***/ }), |
|
757 |
|
758 /***/ 44: |
|
759 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
760 |
|
761 "use strict"; |
|
762 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; }); |
|
763 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
|
764 try { |
|
765 var info = gen[key](arg); |
|
766 var value = info.value; |
|
767 } catch (error) { |
|
768 reject(error); |
|
769 return; |
|
770 } |
|
771 |
|
772 if (info.done) { |
|
773 resolve(value); |
|
774 } else { |
|
775 Promise.resolve(value).then(_next, _throw); |
|
776 } |
|
777 } |
|
778 |
|
779 function _asyncToGenerator(fn) { |
|
780 return function () { |
|
781 var self = this, |
|
782 args = arguments; |
|
783 return new Promise(function (resolve, reject) { |
|
784 var gen = fn.apply(self, args); |
|
785 |
|
786 function _next(value) { |
|
787 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); |
|
788 } |
|
789 |
|
790 function _throw(err) { |
|
791 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); |
|
792 } |
|
793 |
|
794 _next(undefined); |
|
795 }); |
|
796 }; |
|
797 } |
|
798 |
|
799 /***/ }), |
|
800 |
|
801 /***/ 54: |
|
802 /***/ (function(module, exports, __webpack_require__) { |
|
803 |
|
804 /** |
|
805 * Copyright (c) 2014-present, Facebook, Inc. |
|
806 * |
|
807 * This source code is licensed under the MIT license found in the |
|
808 * LICENSE file in the root directory of this source tree. |
|
809 */ |
|
810 |
|
811 // This method of obtaining a reference to the global object needs to be |
|
812 // kept identical to the way it is obtained in runtime.js |
|
813 var g = (function() { |
|
814 return this || (typeof self === "object" && self); |
|
815 })() || Function("return this")(); |
|
816 |
|
817 // Use `getOwnPropertyNames` because not all browsers support calling |
|
818 // `hasOwnProperty` on the global `self` object in a worker. See #183. |
|
819 var hadRuntime = g.regeneratorRuntime && |
|
820 Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; |
|
821 |
|
822 // Save the old regeneratorRuntime in case it needs to be restored later. |
|
823 var oldRuntime = hadRuntime && g.regeneratorRuntime; |
|
824 |
|
825 // Force reevalutation of runtime.js. |
|
826 g.regeneratorRuntime = undefined; |
|
827 |
|
828 module.exports = __webpack_require__(55); |
|
829 |
|
830 if (hadRuntime) { |
|
831 // Restore the original runtime. |
|
832 g.regeneratorRuntime = oldRuntime; |
|
833 } else { |
|
834 // Remove the global property added by runtime.js. |
|
835 try { |
|
836 delete g.regeneratorRuntime; |
|
837 } catch(e) { |
|
838 g.regeneratorRuntime = undefined; |
|
839 } |
|
840 } |
|
841 |
|
842 |
|
843 /***/ }), |
|
844 |
|
845 /***/ 55: |
|
846 /***/ (function(module, exports) { |
|
847 |
|
848 /** |
|
849 * Copyright (c) 2014-present, Facebook, Inc. |
|
850 * |
|
851 * This source code is licensed under the MIT license found in the |
|
852 * LICENSE file in the root directory of this source tree. |
|
853 */ |
|
854 |
|
855 !(function(global) { |
|
856 "use strict"; |
|
857 |
|
858 var Op = Object.prototype; |
|
859 var hasOwn = Op.hasOwnProperty; |
|
860 var undefined; // More compressible than void 0. |
|
861 var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
|
862 var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
|
863 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
|
864 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
|
865 |
|
866 var inModule = typeof module === "object"; |
|
867 var runtime = global.regeneratorRuntime; |
|
868 if (runtime) { |
|
869 if (inModule) { |
|
870 // If regeneratorRuntime is defined globally and we're in a module, |
|
871 // make the exports object identical to regeneratorRuntime. |
|
872 module.exports = runtime; |
|
873 } |
|
874 // Don't bother evaluating the rest of this file if the runtime was |
|
875 // already defined globally. |
|
876 return; |
|
877 } |
|
878 |
|
879 // Define the runtime globally (as expected by generated code) as either |
|
880 // module.exports (if we're in a module) or a new, empty object. |
|
881 runtime = global.regeneratorRuntime = inModule ? module.exports : {}; |
|
882 |
|
883 function wrap(innerFn, outerFn, self, tryLocsList) { |
|
884 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. |
|
885 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
|
886 var generator = Object.create(protoGenerator.prototype); |
|
887 var context = new Context(tryLocsList || []); |
|
888 |
|
889 // The ._invoke method unifies the implementations of the .next, |
|
890 // .throw, and .return methods. |
|
891 generator._invoke = makeInvokeMethod(innerFn, self, context); |
|
892 |
|
893 return generator; |
|
894 } |
|
895 runtime.wrap = wrap; |
|
896 |
|
897 // Try/catch helper to minimize deoptimizations. Returns a completion |
|
898 // record like context.tryEntries[i].completion. This interface could |
|
899 // have been (and was previously) designed to take a closure to be |
|
900 // invoked without arguments, but in all the cases we care about we |
|
901 // already have an existing method we want to call, so there's no need |
|
902 // to create a new function object. We can even get away with assuming |
|
903 // the method takes exactly one argument, since that happens to be true |
|
904 // in every case, so we don't have to touch the arguments object. The |
|
905 // only additional allocation required is the completion record, which |
|
906 // has a stable shape and so hopefully should be cheap to allocate. |
|
907 function tryCatch(fn, obj, arg) { |
|
908 try { |
|
909 return { type: "normal", arg: fn.call(obj, arg) }; |
|
910 } catch (err) { |
|
911 return { type: "throw", arg: err }; |
|
912 } |
|
913 } |
|
914 |
|
915 var GenStateSuspendedStart = "suspendedStart"; |
|
916 var GenStateSuspendedYield = "suspendedYield"; |
|
917 var GenStateExecuting = "executing"; |
|
918 var GenStateCompleted = "completed"; |
|
919 |
|
920 // Returning this object from the innerFn has the same effect as |
|
921 // breaking out of the dispatch switch statement. |
|
922 var ContinueSentinel = {}; |
|
923 |
|
924 // Dummy constructor functions that we use as the .constructor and |
|
925 // .constructor.prototype properties for functions that return Generator |
|
926 // objects. For full spec compliance, you may wish to configure your |
|
927 // minifier not to mangle the names of these two functions. |
|
928 function Generator() {} |
|
929 function GeneratorFunction() {} |
|
930 function GeneratorFunctionPrototype() {} |
|
931 |
|
932 // This is a polyfill for %IteratorPrototype% for environments that |
|
933 // don't natively support it. |
|
934 var IteratorPrototype = {}; |
|
935 IteratorPrototype[iteratorSymbol] = function () { |
|
936 return this; |
|
937 }; |
|
938 |
|
939 var getProto = Object.getPrototypeOf; |
|
940 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
|
941 if (NativeIteratorPrototype && |
|
942 NativeIteratorPrototype !== Op && |
|
943 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { |
|
944 // This environment has a native %IteratorPrototype%; use it instead |
|
945 // of the polyfill. |
|
946 IteratorPrototype = NativeIteratorPrototype; |
|
947 } |
|
948 |
|
949 var Gp = GeneratorFunctionPrototype.prototype = |
|
950 Generator.prototype = Object.create(IteratorPrototype); |
|
951 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; |
|
952 GeneratorFunctionPrototype.constructor = GeneratorFunction; |
|
953 GeneratorFunctionPrototype[toStringTagSymbol] = |
|
954 GeneratorFunction.displayName = "GeneratorFunction"; |
|
955 |
|
956 // Helper for defining the .next, .throw, and .return methods of the |
|
957 // Iterator interface in terms of a single ._invoke method. |
|
958 function defineIteratorMethods(prototype) { |
|
959 ["next", "throw", "return"].forEach(function(method) { |
|
960 prototype[method] = function(arg) { |
|
961 return this._invoke(method, arg); |
|
962 }; |
|
963 }); |
|
964 } |
|
965 |
|
966 runtime.isGeneratorFunction = function(genFun) { |
|
967 var ctor = typeof genFun === "function" && genFun.constructor; |
|
968 return ctor |
|
969 ? ctor === GeneratorFunction || |
|
970 // For the native GeneratorFunction constructor, the best we can |
|
971 // do is to check its .name property. |
|
972 (ctor.displayName || ctor.name) === "GeneratorFunction" |
|
973 : false; |
|
974 }; |
|
975 |
|
976 runtime.mark = function(genFun) { |
|
977 if (Object.setPrototypeOf) { |
|
978 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
|
979 } else { |
|
980 genFun.__proto__ = GeneratorFunctionPrototype; |
|
981 if (!(toStringTagSymbol in genFun)) { |
|
982 genFun[toStringTagSymbol] = "GeneratorFunction"; |
|
983 } |
|
984 } |
|
985 genFun.prototype = Object.create(Gp); |
|
986 return genFun; |
|
987 }; |
|
988 |
|
989 // Within the body of any async function, `await x` is transformed to |
|
990 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test |
|
991 // `hasOwn.call(value, "__await")` to determine if the yielded value is |
|
992 // meant to be awaited. |
|
993 runtime.awrap = function(arg) { |
|
994 return { __await: arg }; |
|
995 }; |
|
996 |
|
997 function AsyncIterator(generator) { |
|
998 function invoke(method, arg, resolve, reject) { |
|
999 var record = tryCatch(generator[method], generator, arg); |
|
1000 if (record.type === "throw") { |
|
1001 reject(record.arg); |
|
1002 } else { |
|
1003 var result = record.arg; |
|
1004 var value = result.value; |
|
1005 if (value && |
|
1006 typeof value === "object" && |
|
1007 hasOwn.call(value, "__await")) { |
|
1008 return Promise.resolve(value.__await).then(function(value) { |
|
1009 invoke("next", value, resolve, reject); |
|
1010 }, function(err) { |
|
1011 invoke("throw", err, resolve, reject); |
|
1012 }); |
|
1013 } |
|
1014 |
|
1015 return Promise.resolve(value).then(function(unwrapped) { |
|
1016 // When a yielded Promise is resolved, its final value becomes |
|
1017 // the .value of the Promise<{value,done}> result for the |
|
1018 // current iteration. |
|
1019 result.value = unwrapped; |
|
1020 resolve(result); |
|
1021 }, function(error) { |
|
1022 // If a rejected Promise was yielded, throw the rejection back |
|
1023 // into the async generator function so it can be handled there. |
|
1024 return invoke("throw", error, resolve, reject); |
|
1025 }); |
|
1026 } |
|
1027 } |
|
1028 |
|
1029 var previousPromise; |
|
1030 |
|
1031 function enqueue(method, arg) { |
|
1032 function callInvokeWithMethodAndArg() { |
|
1033 return new Promise(function(resolve, reject) { |
|
1034 invoke(method, arg, resolve, reject); |
|
1035 }); |
|
1036 } |
|
1037 |
|
1038 return previousPromise = |
|
1039 // If enqueue has been called before, then we want to wait until |
|
1040 // all previous Promises have been resolved before calling invoke, |
|
1041 // so that results are always delivered in the correct order. If |
|
1042 // enqueue has not been called before, then it is important to |
|
1043 // call invoke immediately, without waiting on a callback to fire, |
|
1044 // so that the async generator function has the opportunity to do |
|
1045 // any necessary setup in a predictable way. This predictability |
|
1046 // is why the Promise constructor synchronously invokes its |
|
1047 // executor callback, and why async functions synchronously |
|
1048 // execute code before the first await. Since we implement simple |
|
1049 // async functions in terms of async generators, it is especially |
|
1050 // important to get this right, even though it requires care. |
|
1051 previousPromise ? previousPromise.then( |
|
1052 callInvokeWithMethodAndArg, |
|
1053 // Avoid propagating failures to Promises returned by later |
|
1054 // invocations of the iterator. |
|
1055 callInvokeWithMethodAndArg |
|
1056 ) : callInvokeWithMethodAndArg(); |
|
1057 } |
|
1058 |
|
1059 // Define the unified helper method that is used to implement .next, |
|
1060 // .throw, and .return (see defineIteratorMethods). |
|
1061 this._invoke = enqueue; |
|
1062 } |
|
1063 |
|
1064 defineIteratorMethods(AsyncIterator.prototype); |
|
1065 AsyncIterator.prototype[asyncIteratorSymbol] = function () { |
|
1066 return this; |
|
1067 }; |
|
1068 runtime.AsyncIterator = AsyncIterator; |
|
1069 |
|
1070 // Note that simple async functions are implemented on top of |
|
1071 // AsyncIterator objects; they just return a Promise for the value of |
|
1072 // the final result produced by the iterator. |
|
1073 runtime.async = function(innerFn, outerFn, self, tryLocsList) { |
|
1074 var iter = new AsyncIterator( |
|
1075 wrap(innerFn, outerFn, self, tryLocsList) |
|
1076 ); |
|
1077 |
|
1078 return runtime.isGeneratorFunction(outerFn) |
|
1079 ? iter // If outerFn is a generator, return the full iterator. |
|
1080 : iter.next().then(function(result) { |
|
1081 return result.done ? result.value : iter.next(); |
|
1082 }); |
|
1083 }; |
|
1084 |
|
1085 function makeInvokeMethod(innerFn, self, context) { |
|
1086 var state = GenStateSuspendedStart; |
|
1087 |
|
1088 return function invoke(method, arg) { |
|
1089 if (state === GenStateExecuting) { |
|
1090 throw new Error("Generator is already running"); |
|
1091 } |
|
1092 |
|
1093 if (state === GenStateCompleted) { |
|
1094 if (method === "throw") { |
|
1095 throw arg; |
|
1096 } |
|
1097 |
|
1098 // Be forgiving, per 25.3.3.3.3 of the spec: |
|
1099 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
|
1100 return doneResult(); |
|
1101 } |
|
1102 |
|
1103 context.method = method; |
|
1104 context.arg = arg; |
|
1105 |
|
1106 while (true) { |
|
1107 var delegate = context.delegate; |
|
1108 if (delegate) { |
|
1109 var delegateResult = maybeInvokeDelegate(delegate, context); |
|
1110 if (delegateResult) { |
|
1111 if (delegateResult === ContinueSentinel) continue; |
|
1112 return delegateResult; |
|
1113 } |
|
1114 } |
|
1115 |
|
1116 if (context.method === "next") { |
|
1117 // Setting context._sent for legacy support of Babel's |
|
1118 // function.sent implementation. |
|
1119 context.sent = context._sent = context.arg; |
|
1120 |
|
1121 } else if (context.method === "throw") { |
|
1122 if (state === GenStateSuspendedStart) { |
|
1123 state = GenStateCompleted; |
|
1124 throw context.arg; |
|
1125 } |
|
1126 |
|
1127 context.dispatchException(context.arg); |
|
1128 |
|
1129 } else if (context.method === "return") { |
|
1130 context.abrupt("return", context.arg); |
|
1131 } |
|
1132 |
|
1133 state = GenStateExecuting; |
|
1134 |
|
1135 var record = tryCatch(innerFn, self, context); |
|
1136 if (record.type === "normal") { |
|
1137 // If an exception is thrown from innerFn, we leave state === |
|
1138 // GenStateExecuting and loop back for another invocation. |
|
1139 state = context.done |
|
1140 ? GenStateCompleted |
|
1141 : GenStateSuspendedYield; |
|
1142 |
|
1143 if (record.arg === ContinueSentinel) { |
|
1144 continue; |
|
1145 } |
|
1146 |
|
1147 return { |
|
1148 value: record.arg, |
|
1149 done: context.done |
|
1150 }; |
|
1151 |
|
1152 } else if (record.type === "throw") { |
|
1153 state = GenStateCompleted; |
|
1154 // Dispatch the exception by looping back around to the |
|
1155 // context.dispatchException(context.arg) call above. |
|
1156 context.method = "throw"; |
|
1157 context.arg = record.arg; |
|
1158 } |
|
1159 } |
|
1160 }; |
|
1161 } |
|
1162 |
|
1163 // Call delegate.iterator[context.method](context.arg) and handle the |
|
1164 // result, either by returning a { value, done } result from the |
|
1165 // delegate iterator, or by modifying context.method and context.arg, |
|
1166 // setting context.delegate to null, and returning the ContinueSentinel. |
|
1167 function maybeInvokeDelegate(delegate, context) { |
|
1168 var method = delegate.iterator[context.method]; |
|
1169 if (method === undefined) { |
|
1170 // A .throw or .return when the delegate iterator has no .throw |
|
1171 // method always terminates the yield* loop. |
|
1172 context.delegate = null; |
|
1173 |
|
1174 if (context.method === "throw") { |
|
1175 if (delegate.iterator.return) { |
|
1176 // If the delegate iterator has a return method, give it a |
|
1177 // chance to clean up. |
|
1178 context.method = "return"; |
|
1179 context.arg = undefined; |
|
1180 maybeInvokeDelegate(delegate, context); |
|
1181 |
|
1182 if (context.method === "throw") { |
|
1183 // If maybeInvokeDelegate(context) changed context.method from |
|
1184 // "return" to "throw", let that override the TypeError below. |
|
1185 return ContinueSentinel; |
|
1186 } |
|
1187 } |
|
1188 |
|
1189 context.method = "throw"; |
|
1190 context.arg = new TypeError( |
|
1191 "The iterator does not provide a 'throw' method"); |
|
1192 } |
|
1193 |
|
1194 return ContinueSentinel; |
|
1195 } |
|
1196 |
|
1197 var record = tryCatch(method, delegate.iterator, context.arg); |
|
1198 |
|
1199 if (record.type === "throw") { |
|
1200 context.method = "throw"; |
|
1201 context.arg = record.arg; |
|
1202 context.delegate = null; |
|
1203 return ContinueSentinel; |
|
1204 } |
|
1205 |
|
1206 var info = record.arg; |
|
1207 |
|
1208 if (! info) { |
|
1209 context.method = "throw"; |
|
1210 context.arg = new TypeError("iterator result is not an object"); |
|
1211 context.delegate = null; |
|
1212 return ContinueSentinel; |
|
1213 } |
|
1214 |
|
1215 if (info.done) { |
|
1216 // Assign the result of the finished delegate to the temporary |
|
1217 // variable specified by delegate.resultName (see delegateYield). |
|
1218 context[delegate.resultName] = info.value; |
|
1219 |
|
1220 // Resume execution at the desired location (see delegateYield). |
|
1221 context.next = delegate.nextLoc; |
|
1222 |
|
1223 // If context.method was "throw" but the delegate handled the |
|
1224 // exception, let the outer generator proceed normally. If |
|
1225 // context.method was "next", forget context.arg since it has been |
|
1226 // "consumed" by the delegate iterator. If context.method was |
|
1227 // "return", allow the original .return call to continue in the |
|
1228 // outer generator. |
|
1229 if (context.method !== "return") { |
|
1230 context.method = "next"; |
|
1231 context.arg = undefined; |
|
1232 } |
|
1233 |
|
1234 } else { |
|
1235 // Re-yield the result returned by the delegate method. |
|
1236 return info; |
|
1237 } |
|
1238 |
|
1239 // The delegate iterator is finished, so forget it and continue with |
|
1240 // the outer generator. |
|
1241 context.delegate = null; |
|
1242 return ContinueSentinel; |
|
1243 } |
|
1244 |
|
1245 // Define Generator.prototype.{next,throw,return} in terms of the |
|
1246 // unified ._invoke helper method. |
|
1247 defineIteratorMethods(Gp); |
|
1248 |
|
1249 Gp[toStringTagSymbol] = "Generator"; |
|
1250 |
|
1251 // A Generator should always return itself as the iterator object when the |
|
1252 // @@iterator function is called on it. Some browsers' implementations of the |
|
1253 // iterator prototype chain incorrectly implement this, causing the Generator |
|
1254 // object to not be returned from this call. This ensures that doesn't happen. |
|
1255 // See https://github.com/facebook/regenerator/issues/274 for more details. |
|
1256 Gp[iteratorSymbol] = function() { |
|
1257 return this; |
|
1258 }; |
|
1259 |
|
1260 Gp.toString = function() { |
|
1261 return "[object Generator]"; |
|
1262 }; |
|
1263 |
|
1264 function pushTryEntry(locs) { |
|
1265 var entry = { tryLoc: locs[0] }; |
|
1266 |
|
1267 if (1 in locs) { |
|
1268 entry.catchLoc = locs[1]; |
|
1269 } |
|
1270 |
|
1271 if (2 in locs) { |
|
1272 entry.finallyLoc = locs[2]; |
|
1273 entry.afterLoc = locs[3]; |
|
1274 } |
|
1275 |
|
1276 this.tryEntries.push(entry); |
|
1277 } |
|
1278 |
|
1279 function resetTryEntry(entry) { |
|
1280 var record = entry.completion || {}; |
|
1281 record.type = "normal"; |
|
1282 delete record.arg; |
|
1283 entry.completion = record; |
|
1284 } |
|
1285 |
|
1286 function Context(tryLocsList) { |
|
1287 // The root entry object (effectively a try statement without a catch |
|
1288 // or a finally block) gives us a place to store values thrown from |
|
1289 // locations where there is no enclosing try statement. |
|
1290 this.tryEntries = [{ tryLoc: "root" }]; |
|
1291 tryLocsList.forEach(pushTryEntry, this); |
|
1292 this.reset(true); |
|
1293 } |
|
1294 |
|
1295 runtime.keys = function(object) { |
|
1296 var keys = []; |
|
1297 for (var key in object) { |
|
1298 keys.push(key); |
|
1299 } |
|
1300 keys.reverse(); |
|
1301 |
|
1302 // Rather than returning an object with a next method, we keep |
|
1303 // things simple and return the next function itself. |
|
1304 return function next() { |
|
1305 while (keys.length) { |
|
1306 var key = keys.pop(); |
|
1307 if (key in object) { |
|
1308 next.value = key; |
|
1309 next.done = false; |
|
1310 return next; |
|
1311 } |
|
1312 } |
|
1313 |
|
1314 // To avoid creating an additional object, we just hang the .value |
|
1315 // and .done properties off the next function object itself. This |
|
1316 // also ensures that the minifier will not anonymize the function. |
|
1317 next.done = true; |
|
1318 return next; |
|
1319 }; |
|
1320 }; |
|
1321 |
|
1322 function values(iterable) { |
|
1323 if (iterable) { |
|
1324 var iteratorMethod = iterable[iteratorSymbol]; |
|
1325 if (iteratorMethod) { |
|
1326 return iteratorMethod.call(iterable); |
|
1327 } |
|
1328 |
|
1329 if (typeof iterable.next === "function") { |
|
1330 return iterable; |
|
1331 } |
|
1332 |
|
1333 if (!isNaN(iterable.length)) { |
|
1334 var i = -1, next = function next() { |
|
1335 while (++i < iterable.length) { |
|
1336 if (hasOwn.call(iterable, i)) { |
|
1337 next.value = iterable[i]; |
|
1338 next.done = false; |
|
1339 return next; |
|
1340 } |
|
1341 } |
|
1342 |
|
1343 next.value = undefined; |
|
1344 next.done = true; |
|
1345 |
|
1346 return next; |
|
1347 }; |
|
1348 |
|
1349 return next.next = next; |
|
1350 } |
|
1351 } |
|
1352 |
|
1353 // Return an iterator with no values. |
|
1354 return { next: doneResult }; |
|
1355 } |
|
1356 runtime.values = values; |
|
1357 |
|
1358 function doneResult() { |
|
1359 return { value: undefined, done: true }; |
|
1360 } |
|
1361 |
|
1362 Context.prototype = { |
|
1363 constructor: Context, |
|
1364 |
|
1365 reset: function(skipTempReset) { |
|
1366 this.prev = 0; |
|
1367 this.next = 0; |
|
1368 // Resetting context._sent for legacy support of Babel's |
|
1369 // function.sent implementation. |
|
1370 this.sent = this._sent = undefined; |
|
1371 this.done = false; |
|
1372 this.delegate = null; |
|
1373 |
|
1374 this.method = "next"; |
|
1375 this.arg = undefined; |
|
1376 |
|
1377 this.tryEntries.forEach(resetTryEntry); |
|
1378 |
|
1379 if (!skipTempReset) { |
|
1380 for (var name in this) { |
|
1381 // Not sure about the optimal order of these conditions: |
|
1382 if (name.charAt(0) === "t" && |
|
1383 hasOwn.call(this, name) && |
|
1384 !isNaN(+name.slice(1))) { |
|
1385 this[name] = undefined; |
|
1386 } |
|
1387 } |
|
1388 } |
|
1389 }, |
|
1390 |
|
1391 stop: function() { |
|
1392 this.done = true; |
|
1393 |
|
1394 var rootEntry = this.tryEntries[0]; |
|
1395 var rootRecord = rootEntry.completion; |
|
1396 if (rootRecord.type === "throw") { |
|
1397 throw rootRecord.arg; |
|
1398 } |
|
1399 |
|
1400 return this.rval; |
|
1401 }, |
|
1402 |
|
1403 dispatchException: function(exception) { |
|
1404 if (this.done) { |
|
1405 throw exception; |
|
1406 } |
|
1407 |
|
1408 var context = this; |
|
1409 function handle(loc, caught) { |
|
1410 record.type = "throw"; |
|
1411 record.arg = exception; |
|
1412 context.next = loc; |
|
1413 |
|
1414 if (caught) { |
|
1415 // If the dispatched exception was caught by a catch block, |
|
1416 // then let that catch block handle the exception normally. |
|
1417 context.method = "next"; |
|
1418 context.arg = undefined; |
|
1419 } |
|
1420 |
|
1421 return !! caught; |
|
1422 } |
|
1423 |
|
1424 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
1425 var entry = this.tryEntries[i]; |
|
1426 var record = entry.completion; |
|
1427 |
|
1428 if (entry.tryLoc === "root") { |
|
1429 // Exception thrown outside of any try block that could handle |
|
1430 // it, so set the completion value of the entire function to |
|
1431 // throw the exception. |
|
1432 return handle("end"); |
|
1433 } |
|
1434 |
|
1435 if (entry.tryLoc <= this.prev) { |
|
1436 var hasCatch = hasOwn.call(entry, "catchLoc"); |
|
1437 var hasFinally = hasOwn.call(entry, "finallyLoc"); |
|
1438 |
|
1439 if (hasCatch && hasFinally) { |
|
1440 if (this.prev < entry.catchLoc) { |
|
1441 return handle(entry.catchLoc, true); |
|
1442 } else if (this.prev < entry.finallyLoc) { |
|
1443 return handle(entry.finallyLoc); |
|
1444 } |
|
1445 |
|
1446 } else if (hasCatch) { |
|
1447 if (this.prev < entry.catchLoc) { |
|
1448 return handle(entry.catchLoc, true); |
|
1449 } |
|
1450 |
|
1451 } else if (hasFinally) { |
|
1452 if (this.prev < entry.finallyLoc) { |
|
1453 return handle(entry.finallyLoc); |
|
1454 } |
|
1455 |
|
1456 } else { |
|
1457 throw new Error("try statement without catch or finally"); |
|
1458 } |
|
1459 } |
|
1460 } |
|
1461 }, |
|
1462 |
|
1463 abrupt: function(type, arg) { |
|
1464 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
1465 var entry = this.tryEntries[i]; |
|
1466 if (entry.tryLoc <= this.prev && |
|
1467 hasOwn.call(entry, "finallyLoc") && |
|
1468 this.prev < entry.finallyLoc) { |
|
1469 var finallyEntry = entry; |
|
1470 break; |
|
1471 } |
|
1472 } |
|
1473 |
|
1474 if (finallyEntry && |
|
1475 (type === "break" || |
|
1476 type === "continue") && |
|
1477 finallyEntry.tryLoc <= arg && |
|
1478 arg <= finallyEntry.finallyLoc) { |
|
1479 // Ignore the finally entry if control is not jumping to a |
|
1480 // location outside the try/catch block. |
|
1481 finallyEntry = null; |
|
1482 } |
|
1483 |
|
1484 var record = finallyEntry ? finallyEntry.completion : {}; |
|
1485 record.type = type; |
|
1486 record.arg = arg; |
|
1487 |
|
1488 if (finallyEntry) { |
|
1489 this.method = "next"; |
|
1490 this.next = finallyEntry.finallyLoc; |
|
1491 return ContinueSentinel; |
|
1492 } |
|
1493 |
|
1494 return this.complete(record); |
|
1495 }, |
|
1496 |
|
1497 complete: function(record, afterLoc) { |
|
1498 if (record.type === "throw") { |
|
1499 throw record.arg; |
|
1500 } |
|
1501 |
|
1502 if (record.type === "break" || |
|
1503 record.type === "continue") { |
|
1504 this.next = record.arg; |
|
1505 } else if (record.type === "return") { |
|
1506 this.rval = this.arg = record.arg; |
|
1507 this.method = "return"; |
|
1508 this.next = "end"; |
|
1509 } else if (record.type === "normal" && afterLoc) { |
|
1510 this.next = afterLoc; |
|
1511 } |
|
1512 |
|
1513 return ContinueSentinel; |
|
1514 }, |
|
1515 |
|
1516 finish: function(finallyLoc) { |
|
1517 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
1518 var entry = this.tryEntries[i]; |
|
1519 if (entry.finallyLoc === finallyLoc) { |
|
1520 this.complete(entry.completion, entry.afterLoc); |
|
1521 resetTryEntry(entry); |
|
1522 return ContinueSentinel; |
|
1523 } |
|
1524 } |
|
1525 }, |
|
1526 |
|
1527 "catch": function(tryLoc) { |
|
1528 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
1529 var entry = this.tryEntries[i]; |
|
1530 if (entry.tryLoc === tryLoc) { |
|
1531 var record = entry.completion; |
|
1532 if (record.type === "throw") { |
|
1533 var thrown = record.arg; |
|
1534 resetTryEntry(entry); |
|
1535 } |
|
1536 return thrown; |
|
1537 } |
|
1538 } |
|
1539 |
|
1540 // The context.catch method must only be called with a location |
|
1541 // argument that corresponds to a known catch block. |
|
1542 throw new Error("illegal catch attempt"); |
|
1543 }, |
|
1544 |
|
1545 delegateYield: function(iterable, resultName, nextLoc) { |
|
1546 this.delegate = { |
|
1547 iterator: values(iterable), |
|
1548 resultName: resultName, |
|
1549 nextLoc: nextLoc |
|
1550 }; |
|
1551 |
|
1552 if (this.method === "next") { |
|
1553 // Deliberately forget the last sent value so that we don't |
|
1554 // accidentally pass it on to the delegate. |
|
1555 this.arg = undefined; |
|
1556 } |
|
1557 |
|
1558 return ContinueSentinel; |
|
1559 } |
|
1560 }; |
|
1561 })( |
|
1562 // In sloppy mode, unbound `this` refers to the global object, fallback to |
|
1563 // Function constructor if we're in global strict mode. That is sadly a form |
|
1564 // of indirect eval which violates Content Security Policy. |
|
1565 (function() { |
|
1566 return this || (typeof self === "object" && self); |
|
1567 })() || Function("return this")() |
|
1568 ); |
|
1569 |
|
1570 |
|
1571 /***/ }), |
|
1572 |
|
1573 /***/ 6: |
|
1574 /***/ (function(module, exports) { |
|
1575 |
|
1576 (function() { module.exports = this["wp"]["compose"]; }()); |
|
1577 |
|
1578 /***/ }), |
|
1579 |
|
1580 /***/ 9: |
|
1581 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1582 |
|
1583 "use strict"; |
|
1584 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; }); |
|
1585 function _defineProperties(target, props) { |
|
1586 for (var i = 0; i < props.length; i++) { |
|
1587 var descriptor = props[i]; |
|
1588 descriptor.enumerable = descriptor.enumerable || false; |
|
1589 descriptor.configurable = true; |
|
1590 if ("value" in descriptor) descriptor.writable = true; |
|
1591 Object.defineProperty(target, descriptor.key, descriptor); |
|
1592 } |
|
1593 } |
|
1594 |
|
1595 function _createClass(Constructor, protoProps, staticProps) { |
|
1596 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
1597 if (staticProps) _defineProperties(Constructor, staticProps); |
|
1598 return Constructor; |
|
1599 } |
|
1600 |
|
1601 /***/ }) |
|
1602 |
|
1603 /******/ }); |