80 /******/ // __webpack_public_path__ |
80 /******/ // __webpack_public_path__ |
81 /******/ __webpack_require__.p = ""; |
81 /******/ __webpack_require__.p = ""; |
82 /******/ |
82 /******/ |
83 /******/ |
83 /******/ |
84 /******/ // Load entry module and return exports |
84 /******/ // Load entry module and return exports |
85 /******/ return __webpack_require__(__webpack_require__.s = 364); |
85 /******/ return __webpack_require__(__webpack_require__.s = 447); |
86 /******/ }) |
86 /******/ }) |
87 /************************************************************************/ |
87 /************************************************************************/ |
88 /******/ ({ |
88 /******/ ({ |
89 |
89 |
90 /***/ 132: |
90 /***/ 0: |
91 /***/ (function(module, exports) { |
91 /***/ (function(module, exports) { |
92 |
92 |
93 module.exports = function(originalModule) { |
93 (function() { module.exports = this["wp"]["element"]; }()); |
94 if (!originalModule.webpackPolyfill) { |
|
95 var module = Object.create(originalModule); |
|
96 // module.parent = undefined by default |
|
97 if (!module.children) module.children = []; |
|
98 Object.defineProperty(module, "loaded", { |
|
99 enumerable: true, |
|
100 get: function() { |
|
101 return module.l; |
|
102 } |
|
103 }); |
|
104 Object.defineProperty(module, "id", { |
|
105 enumerable: true, |
|
106 get: function() { |
|
107 return module.i; |
|
108 } |
|
109 }); |
|
110 Object.defineProperty(module, "exports", { |
|
111 enumerable: true |
|
112 }); |
|
113 module.webpackPolyfill = 1; |
|
114 } |
|
115 return module; |
|
116 }; |
|
117 |
|
118 |
94 |
119 /***/ }), |
95 /***/ }), |
120 |
96 |
121 /***/ 15: |
97 /***/ 1: |
|
98 /***/ (function(module, exports) { |
|
99 |
|
100 (function() { module.exports = this["wp"]["i18n"]; }()); |
|
101 |
|
102 /***/ }), |
|
103 |
|
104 /***/ 10: |
|
105 /***/ (function(module, exports) { |
|
106 |
|
107 (function() { module.exports = this["wp"]["blocks"]; }()); |
|
108 |
|
109 /***/ }), |
|
110 |
|
111 /***/ 126: |
|
112 /***/ (function(module, exports, __webpack_require__) { |
|
113 |
|
114 "use strict"; |
|
115 |
|
116 |
|
117 function _typeof(obj) { |
|
118 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { |
|
119 _typeof = function (obj) { |
|
120 return typeof obj; |
|
121 }; |
|
122 } else { |
|
123 _typeof = function (obj) { |
|
124 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
|
125 }; |
|
126 } |
|
127 |
|
128 return _typeof(obj); |
|
129 } |
|
130 |
|
131 function _classCallCheck(instance, Constructor) { |
|
132 if (!(instance instanceof Constructor)) { |
|
133 throw new TypeError("Cannot call a class as a function"); |
|
134 } |
|
135 } |
|
136 |
|
137 function _defineProperties(target, props) { |
|
138 for (var i = 0; i < props.length; i++) { |
|
139 var descriptor = props[i]; |
|
140 descriptor.enumerable = descriptor.enumerable || false; |
|
141 descriptor.configurable = true; |
|
142 if ("value" in descriptor) descriptor.writable = true; |
|
143 Object.defineProperty(target, descriptor.key, descriptor); |
|
144 } |
|
145 } |
|
146 |
|
147 function _createClass(Constructor, protoProps, staticProps) { |
|
148 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
149 if (staticProps) _defineProperties(Constructor, staticProps); |
|
150 return Constructor; |
|
151 } |
|
152 |
|
153 /** |
|
154 * Given an instance of EquivalentKeyMap, returns its internal value pair tuple |
|
155 * for a key, if one exists. The tuple members consist of the last reference |
|
156 * value for the key (used in efficient subsequent lookups) and the value |
|
157 * assigned for the key at the leaf node. |
|
158 * |
|
159 * @param {EquivalentKeyMap} instance EquivalentKeyMap instance. |
|
160 * @param {*} key The key for which to return value pair. |
|
161 * |
|
162 * @return {?Array} Value pair, if exists. |
|
163 */ |
|
164 function getValuePair(instance, key) { |
|
165 var _map = instance._map, |
|
166 _arrayTreeMap = instance._arrayTreeMap, |
|
167 _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the |
|
168 // value, which can be used to shortcut immediately to the value. |
|
169 |
|
170 if (_map.has(key)) { |
|
171 return _map.get(key); |
|
172 } // Sort keys to ensure stable retrieval from tree. |
|
173 |
|
174 |
|
175 var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value. |
|
176 |
|
177 var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap; |
|
178 |
|
179 for (var i = 0; i < properties.length; i++) { |
|
180 var property = properties[i]; |
|
181 map = map.get(property); |
|
182 |
|
183 if (map === undefined) { |
|
184 return; |
|
185 } |
|
186 |
|
187 var propertyValue = key[property]; |
|
188 map = map.get(propertyValue); |
|
189 |
|
190 if (map === undefined) { |
|
191 return; |
|
192 } |
|
193 } |
|
194 |
|
195 var valuePair = map.get('_ekm_value'); |
|
196 |
|
197 if (!valuePair) { |
|
198 return; |
|
199 } // If reached, it implies that an object-like key was set with another |
|
200 // reference, so delete the reference and replace with the current. |
|
201 |
|
202 |
|
203 _map.delete(valuePair[0]); |
|
204 |
|
205 valuePair[0] = key; |
|
206 map.set('_ekm_value', valuePair); |
|
207 |
|
208 _map.set(key, valuePair); |
|
209 |
|
210 return valuePair; |
|
211 } |
|
212 /** |
|
213 * Variant of a Map object which enables lookup by equivalent (deeply equal) |
|
214 * object and array keys. |
|
215 */ |
|
216 |
|
217 |
|
218 var EquivalentKeyMap = |
|
219 /*#__PURE__*/ |
|
220 function () { |
|
221 /** |
|
222 * Constructs a new instance of EquivalentKeyMap. |
|
223 * |
|
224 * @param {Iterable.<*>} iterable Initial pair of key, value for map. |
|
225 */ |
|
226 function EquivalentKeyMap(iterable) { |
|
227 _classCallCheck(this, EquivalentKeyMap); |
|
228 |
|
229 this.clear(); |
|
230 |
|
231 if (iterable instanceof EquivalentKeyMap) { |
|
232 // Map#forEach is only means of iterating with support for IE11. |
|
233 var iterablePairs = []; |
|
234 iterable.forEach(function (value, key) { |
|
235 iterablePairs.push([key, value]); |
|
236 }); |
|
237 iterable = iterablePairs; |
|
238 } |
|
239 |
|
240 if (iterable != null) { |
|
241 for (var i = 0; i < iterable.length; i++) { |
|
242 this.set(iterable[i][0], iterable[i][1]); |
|
243 } |
|
244 } |
|
245 } |
|
246 /** |
|
247 * Accessor property returning the number of elements. |
|
248 * |
|
249 * @return {number} Number of elements. |
|
250 */ |
|
251 |
|
252 |
|
253 _createClass(EquivalentKeyMap, [{ |
|
254 key: "set", |
|
255 |
|
256 /** |
|
257 * Add or update an element with a specified key and value. |
|
258 * |
|
259 * @param {*} key The key of the element to add. |
|
260 * @param {*} value The value of the element to add. |
|
261 * |
|
262 * @return {EquivalentKeyMap} Map instance. |
|
263 */ |
|
264 value: function set(key, value) { |
|
265 // Shortcut non-object-like to set on internal Map. |
|
266 if (key === null || _typeof(key) !== 'object') { |
|
267 this._map.set(key, value); |
|
268 |
|
269 return this; |
|
270 } // Sort keys to ensure stable assignment into tree. |
|
271 |
|
272 |
|
273 var properties = Object.keys(key).sort(); |
|
274 var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value. |
|
275 |
|
276 var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap; |
|
277 |
|
278 for (var i = 0; i < properties.length; i++) { |
|
279 var property = properties[i]; |
|
280 |
|
281 if (!map.has(property)) { |
|
282 map.set(property, new EquivalentKeyMap()); |
|
283 } |
|
284 |
|
285 map = map.get(property); |
|
286 var propertyValue = key[property]; |
|
287 |
|
288 if (!map.has(propertyValue)) { |
|
289 map.set(propertyValue, new EquivalentKeyMap()); |
|
290 } |
|
291 |
|
292 map = map.get(propertyValue); |
|
293 } // If an _ekm_value exists, there was already an equivalent key. Before |
|
294 // overriding, ensure that the old key reference is removed from map to |
|
295 // avoid memory leak of accumulating equivalent keys. This is, in a |
|
296 // sense, a poor man's WeakMap, while still enabling iterability. |
|
297 |
|
298 |
|
299 var previousValuePair = map.get('_ekm_value'); |
|
300 |
|
301 if (previousValuePair) { |
|
302 this._map.delete(previousValuePair[0]); |
|
303 } |
|
304 |
|
305 map.set('_ekm_value', valuePair); |
|
306 |
|
307 this._map.set(key, valuePair); |
|
308 |
|
309 return this; |
|
310 } |
|
311 /** |
|
312 * Returns a specified element. |
|
313 * |
|
314 * @param {*} key The key of the element to return. |
|
315 * |
|
316 * @return {?*} The element associated with the specified key or undefined |
|
317 * if the key can't be found. |
|
318 */ |
|
319 |
|
320 }, { |
|
321 key: "get", |
|
322 value: function get(key) { |
|
323 // Shortcut non-object-like to get from internal Map. |
|
324 if (key === null || _typeof(key) !== 'object') { |
|
325 return this._map.get(key); |
|
326 } |
|
327 |
|
328 var valuePair = getValuePair(this, key); |
|
329 |
|
330 if (valuePair) { |
|
331 return valuePair[1]; |
|
332 } |
|
333 } |
|
334 /** |
|
335 * Returns a boolean indicating whether an element with the specified key |
|
336 * exists or not. |
|
337 * |
|
338 * @param {*} key The key of the element to test for presence. |
|
339 * |
|
340 * @return {boolean} Whether an element with the specified key exists. |
|
341 */ |
|
342 |
|
343 }, { |
|
344 key: "has", |
|
345 value: function has(key) { |
|
346 if (key === null || _typeof(key) !== 'object') { |
|
347 return this._map.has(key); |
|
348 } // Test on the _presence_ of the pair, not its value, as even undefined |
|
349 // can be a valid member value for a key. |
|
350 |
|
351 |
|
352 return getValuePair(this, key) !== undefined; |
|
353 } |
|
354 /** |
|
355 * Removes the specified element. |
|
356 * |
|
357 * @param {*} key The key of the element to remove. |
|
358 * |
|
359 * @return {boolean} Returns true if an element existed and has been |
|
360 * removed, or false if the element does not exist. |
|
361 */ |
|
362 |
|
363 }, { |
|
364 key: "delete", |
|
365 value: function _delete(key) { |
|
366 if (!this.has(key)) { |
|
367 return false; |
|
368 } // This naive implementation will leave orphaned child trees. A better |
|
369 // implementation should traverse and remove orphans. |
|
370 |
|
371 |
|
372 this.set(key, undefined); |
|
373 return true; |
|
374 } |
|
375 /** |
|
376 * Executes a provided function once per each key/value pair, in insertion |
|
377 * order. |
|
378 * |
|
379 * @param {Function} callback Function to execute for each element. |
|
380 * @param {*} thisArg Value to use as `this` when executing |
|
381 * `callback`. |
|
382 */ |
|
383 |
|
384 }, { |
|
385 key: "forEach", |
|
386 value: function forEach(callback) { |
|
387 var _this = this; |
|
388 |
|
389 var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; |
|
390 |
|
391 this._map.forEach(function (value, key) { |
|
392 // Unwrap value from object-like value pair. |
|
393 if (key !== null && _typeof(key) === 'object') { |
|
394 value = value[1]; |
|
395 } |
|
396 |
|
397 callback.call(thisArg, value, key, _this); |
|
398 }); |
|
399 } |
|
400 /** |
|
401 * Removes all elements. |
|
402 */ |
|
403 |
|
404 }, { |
|
405 key: "clear", |
|
406 value: function clear() { |
|
407 this._map = new Map(); |
|
408 this._arrayTreeMap = new Map(); |
|
409 this._objectTreeMap = new Map(); |
|
410 } |
|
411 }, { |
|
412 key: "size", |
|
413 get: function get() { |
|
414 return this._map.size; |
|
415 } |
|
416 }]); |
|
417 |
|
418 return EquivalentKeyMap; |
|
419 }(); |
|
420 |
|
421 module.exports = EquivalentKeyMap; |
|
422 |
|
423 |
|
424 /***/ }), |
|
425 |
|
426 /***/ 14: |
122 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
427 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
123 |
428 |
124 "use strict"; |
429 "use strict"; |
125 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
430 |
126 function _defineProperty(obj, key, value) { |
431 // EXPORTS |
127 if (key in obj) { |
432 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; }); |
128 Object.defineProperty(obj, key, { |
|
129 value: value, |
|
130 enumerable: true, |
|
131 configurable: true, |
|
132 writable: true |
|
133 }); |
|
134 } else { |
|
135 obj[key] = value; |
|
136 } |
|
137 |
|
138 return obj; |
|
139 } |
|
140 |
|
141 /***/ }), |
|
142 |
|
143 /***/ 17: |
|
144 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
145 |
|
146 "use strict"; |
|
147 |
|
148 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
|
149 function _arrayWithoutHoles(arr) { |
|
150 if (Array.isArray(arr)) { |
|
151 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { |
|
152 arr2[i] = arr[i]; |
|
153 } |
|
154 |
|
155 return arr2; |
|
156 } |
|
157 } |
|
158 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
159 var iterableToArray = __webpack_require__(34); |
|
160 |
|
161 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
|
162 function _nonIterableSpread() { |
|
163 throw new TypeError("Invalid attempt to spread non-iterable instance"); |
|
164 } |
|
165 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
|
166 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; }); |
|
167 |
|
168 |
|
169 |
|
170 function _toConsumableArray(arr) { |
|
171 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
|
172 } |
|
173 |
|
174 /***/ }), |
|
175 |
|
176 /***/ 2: |
|
177 /***/ (function(module, exports) { |
|
178 |
|
179 (function() { module.exports = this["lodash"]; }()); |
|
180 |
|
181 /***/ }), |
|
182 |
|
183 /***/ 23: |
|
184 /***/ (function(module, exports, __webpack_require__) { |
|
185 |
|
186 module.exports = __webpack_require__(54); |
|
187 |
|
188 |
|
189 /***/ }), |
|
190 |
|
191 /***/ 25: |
|
192 /***/ (function(module, exports) { |
|
193 |
|
194 (function() { module.exports = this["wp"]["url"]; }()); |
|
195 |
|
196 /***/ }), |
|
197 |
|
198 /***/ 28: |
|
199 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
200 |
|
201 "use strict"; |
|
202 |
433 |
203 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js |
434 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js |
204 var arrayWithHoles = __webpack_require__(37); |
435 var arrayWithHoles = __webpack_require__(38); |
205 |
436 |
206 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js |
437 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js |
207 function _iterableToArrayLimit(arr, i) { |
438 function _iterableToArrayLimit(arr, i) { |
|
439 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; |
208 var _arr = []; |
440 var _arr = []; |
209 var _n = true; |
441 var _n = true; |
210 var _d = false; |
442 var _d = false; |
211 var _e = undefined; |
443 var _e = undefined; |
212 |
444 |
523 }); |
905 }); |
524 |
906 |
525 |
907 |
526 /***/ }), |
908 /***/ }), |
527 |
909 |
528 /***/ 33: |
910 /***/ 447: |
529 /***/ (function(module, exports) { |
|
530 |
|
531 (function() { module.exports = this["wp"]["apiFetch"]; }()); |
|
532 |
|
533 /***/ }), |
|
534 |
|
535 /***/ 34: |
|
536 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
911 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
537 |
912 |
538 "use strict"; |
913 "use strict"; |
539 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
914 // ESM COMPAT FLAG |
540 function _iterableToArray(iter) { |
|
541 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); |
|
542 } |
|
543 |
|
544 /***/ }), |
|
545 |
|
546 /***/ 364: |
|
547 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
548 |
|
549 "use strict"; |
|
550 __webpack_require__.r(__webpack_exports__); |
915 __webpack_require__.r(__webpack_exports__); |
|
916 |
|
917 // EXPORTS |
|
918 __webpack_require__.d(__webpack_exports__, "EntityProvider", function() { return /* reexport */ EntityProvider; }); |
|
919 __webpack_require__.d(__webpack_exports__, "useEntityId", function() { return /* reexport */ useEntityId; }); |
|
920 __webpack_require__.d(__webpack_exports__, "useEntityProp", function() { return /* reexport */ useEntityProp; }); |
|
921 __webpack_require__.d(__webpack_exports__, "useEntityBlockEditor", function() { return /* reexport */ useEntityBlockEditor; }); |
|
922 |
|
923 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/actions.js |
551 var build_module_actions_namespaceObject = {}; |
924 var build_module_actions_namespaceObject = {}; |
552 __webpack_require__.r(build_module_actions_namespaceObject); |
925 __webpack_require__.r(build_module_actions_namespaceObject); |
553 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUserQuery", function() { return receiveUserQuery; }); |
926 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUserQuery", function() { return receiveUserQuery; }); |
|
927 __webpack_require__.d(build_module_actions_namespaceObject, "receiveCurrentUser", function() { return receiveCurrentUser; }); |
554 __webpack_require__.d(build_module_actions_namespaceObject, "addEntities", function() { return addEntities; }); |
928 __webpack_require__.d(build_module_actions_namespaceObject, "addEntities", function() { return addEntities; }); |
555 __webpack_require__.d(build_module_actions_namespaceObject, "receiveEntityRecords", function() { return receiveEntityRecords; }); |
929 __webpack_require__.d(build_module_actions_namespaceObject, "receiveEntityRecords", function() { return receiveEntityRecords; }); |
|
930 __webpack_require__.d(build_module_actions_namespaceObject, "receiveCurrentTheme", function() { return receiveCurrentTheme; }); |
556 __webpack_require__.d(build_module_actions_namespaceObject, "receiveThemeSupports", function() { return receiveThemeSupports; }); |
931 __webpack_require__.d(build_module_actions_namespaceObject, "receiveThemeSupports", function() { return receiveThemeSupports; }); |
557 __webpack_require__.d(build_module_actions_namespaceObject, "receiveEmbedPreview", function() { return receiveEmbedPreview; }); |
932 __webpack_require__.d(build_module_actions_namespaceObject, "receiveEmbedPreview", function() { return receiveEmbedPreview; }); |
|
933 __webpack_require__.d(build_module_actions_namespaceObject, "editEntityRecord", function() { return actions_editEntityRecord; }); |
|
934 __webpack_require__.d(build_module_actions_namespaceObject, "undo", function() { return undo; }); |
|
935 __webpack_require__.d(build_module_actions_namespaceObject, "redo", function() { return redo; }); |
|
936 __webpack_require__.d(build_module_actions_namespaceObject, "__unstableCreateUndoLevel", function() { return __unstableCreateUndoLevel; }); |
558 __webpack_require__.d(build_module_actions_namespaceObject, "saveEntityRecord", function() { return saveEntityRecord; }); |
937 __webpack_require__.d(build_module_actions_namespaceObject, "saveEntityRecord", function() { return saveEntityRecord; }); |
|
938 __webpack_require__.d(build_module_actions_namespaceObject, "saveEditedEntityRecord", function() { return saveEditedEntityRecord; }); |
559 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUploadPermissions", function() { return receiveUploadPermissions; }); |
939 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUploadPermissions", function() { return receiveUploadPermissions; }); |
560 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUserPermission", function() { return receiveUserPermission; }); |
940 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUserPermission", function() { return receiveUserPermission; }); |
|
941 __webpack_require__.d(build_module_actions_namespaceObject, "receiveAutosaves", function() { return receiveAutosaves; }); |
|
942 |
|
943 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/selectors.js |
561 var build_module_selectors_namespaceObject = {}; |
944 var build_module_selectors_namespaceObject = {}; |
562 __webpack_require__.r(build_module_selectors_namespaceObject); |
945 __webpack_require__.r(build_module_selectors_namespaceObject); |
563 __webpack_require__.d(build_module_selectors_namespaceObject, "isRequestingEmbedPreview", function() { return isRequestingEmbedPreview; }); |
946 __webpack_require__.d(build_module_selectors_namespaceObject, "isRequestingEmbedPreview", function() { return isRequestingEmbedPreview; }); |
564 __webpack_require__.d(build_module_selectors_namespaceObject, "getAuthors", function() { return getAuthors; }); |
947 __webpack_require__.d(build_module_selectors_namespaceObject, "getAuthors", function() { return getAuthors; }); |
|
948 __webpack_require__.d(build_module_selectors_namespaceObject, "getCurrentUser", function() { return getCurrentUser; }); |
565 __webpack_require__.d(build_module_selectors_namespaceObject, "getUserQueryResults", function() { return getUserQueryResults; }); |
949 __webpack_require__.d(build_module_selectors_namespaceObject, "getUserQueryResults", function() { return getUserQueryResults; }); |
566 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntitiesByKind", function() { return getEntitiesByKind; }); |
950 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntitiesByKind", function() { return getEntitiesByKind; }); |
567 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntity", function() { return getEntity; }); |
951 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntity", function() { return selectors_getEntity; }); |
568 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecord", function() { return getEntityRecord; }); |
952 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecord", function() { return getEntityRecord; }); |
|
953 __webpack_require__.d(build_module_selectors_namespaceObject, "__experimentalGetEntityRecordNoResolver", function() { return __experimentalGetEntityRecordNoResolver; }); |
|
954 __webpack_require__.d(build_module_selectors_namespaceObject, "getRawEntityRecord", function() { return getRawEntityRecord; }); |
569 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecords", function() { return getEntityRecords; }); |
955 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecords", function() { return getEntityRecords; }); |
|
956 __webpack_require__.d(build_module_selectors_namespaceObject, "__experimentalGetDirtyEntityRecords", function() { return __experimentalGetDirtyEntityRecords; }); |
|
957 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecordEdits", function() { return getEntityRecordEdits; }); |
|
958 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecordNonTransientEdits", function() { return getEntityRecordNonTransientEdits; }); |
|
959 __webpack_require__.d(build_module_selectors_namespaceObject, "hasEditsForEntityRecord", function() { return hasEditsForEntityRecord; }); |
|
960 __webpack_require__.d(build_module_selectors_namespaceObject, "getEditedEntityRecord", function() { return getEditedEntityRecord; }); |
|
961 __webpack_require__.d(build_module_selectors_namespaceObject, "isAutosavingEntityRecord", function() { return isAutosavingEntityRecord; }); |
|
962 __webpack_require__.d(build_module_selectors_namespaceObject, "isSavingEntityRecord", function() { return isSavingEntityRecord; }); |
|
963 __webpack_require__.d(build_module_selectors_namespaceObject, "getLastEntitySaveError", function() { return getLastEntitySaveError; }); |
|
964 __webpack_require__.d(build_module_selectors_namespaceObject, "getUndoEdit", function() { return getUndoEdit; }); |
|
965 __webpack_require__.d(build_module_selectors_namespaceObject, "getRedoEdit", function() { return getRedoEdit; }); |
|
966 __webpack_require__.d(build_module_selectors_namespaceObject, "hasUndo", function() { return hasUndo; }); |
|
967 __webpack_require__.d(build_module_selectors_namespaceObject, "hasRedo", function() { return hasRedo; }); |
|
968 __webpack_require__.d(build_module_selectors_namespaceObject, "getCurrentTheme", function() { return getCurrentTheme; }); |
570 __webpack_require__.d(build_module_selectors_namespaceObject, "getThemeSupports", function() { return getThemeSupports; }); |
969 __webpack_require__.d(build_module_selectors_namespaceObject, "getThemeSupports", function() { return getThemeSupports; }); |
571 __webpack_require__.d(build_module_selectors_namespaceObject, "getEmbedPreview", function() { return getEmbedPreview; }); |
970 __webpack_require__.d(build_module_selectors_namespaceObject, "getEmbedPreview", function() { return getEmbedPreview; }); |
572 __webpack_require__.d(build_module_selectors_namespaceObject, "isPreviewEmbedFallback", function() { return isPreviewEmbedFallback; }); |
971 __webpack_require__.d(build_module_selectors_namespaceObject, "isPreviewEmbedFallback", function() { return isPreviewEmbedFallback; }); |
573 __webpack_require__.d(build_module_selectors_namespaceObject, "hasUploadPermissions", function() { return hasUploadPermissions; }); |
972 __webpack_require__.d(build_module_selectors_namespaceObject, "hasUploadPermissions", function() { return hasUploadPermissions; }); |
574 __webpack_require__.d(build_module_selectors_namespaceObject, "canUser", function() { return canUser; }); |
973 __webpack_require__.d(build_module_selectors_namespaceObject, "canUser", function() { return canUser; }); |
|
974 __webpack_require__.d(build_module_selectors_namespaceObject, "getAutosaves", function() { return getAutosaves; }); |
|
975 __webpack_require__.d(build_module_selectors_namespaceObject, "getAutosave", function() { return getAutosave; }); |
|
976 __webpack_require__.d(build_module_selectors_namespaceObject, "hasFetchedAutosaves", function() { return hasFetchedAutosaves; }); |
|
977 __webpack_require__.d(build_module_selectors_namespaceObject, "getReferenceByDistinctEdits", function() { return getReferenceByDistinctEdits; }); |
|
978 |
|
979 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/resolvers.js |
575 var resolvers_namespaceObject = {}; |
980 var resolvers_namespaceObject = {}; |
576 __webpack_require__.r(resolvers_namespaceObject); |
981 __webpack_require__.r(resolvers_namespaceObject); |
577 __webpack_require__.d(resolvers_namespaceObject, "getAuthors", function() { return resolvers_getAuthors; }); |
982 __webpack_require__.d(resolvers_namespaceObject, "getAuthors", function() { return resolvers_getAuthors; }); |
|
983 __webpack_require__.d(resolvers_namespaceObject, "getCurrentUser", function() { return resolvers_getCurrentUser; }); |
578 __webpack_require__.d(resolvers_namespaceObject, "getEntityRecord", function() { return resolvers_getEntityRecord; }); |
984 __webpack_require__.d(resolvers_namespaceObject, "getEntityRecord", function() { return resolvers_getEntityRecord; }); |
|
985 __webpack_require__.d(resolvers_namespaceObject, "getRawEntityRecord", function() { return resolvers_getRawEntityRecord; }); |
|
986 __webpack_require__.d(resolvers_namespaceObject, "getEditedEntityRecord", function() { return resolvers_getEditedEntityRecord; }); |
579 __webpack_require__.d(resolvers_namespaceObject, "getEntityRecords", function() { return resolvers_getEntityRecords; }); |
987 __webpack_require__.d(resolvers_namespaceObject, "getEntityRecords", function() { return resolvers_getEntityRecords; }); |
|
988 __webpack_require__.d(resolvers_namespaceObject, "getCurrentTheme", function() { return resolvers_getCurrentTheme; }); |
580 __webpack_require__.d(resolvers_namespaceObject, "getThemeSupports", function() { return resolvers_getThemeSupports; }); |
989 __webpack_require__.d(resolvers_namespaceObject, "getThemeSupports", function() { return resolvers_getThemeSupports; }); |
581 __webpack_require__.d(resolvers_namespaceObject, "getEmbedPreview", function() { return resolvers_getEmbedPreview; }); |
990 __webpack_require__.d(resolvers_namespaceObject, "getEmbedPreview", function() { return resolvers_getEmbedPreview; }); |
582 __webpack_require__.d(resolvers_namespaceObject, "hasUploadPermissions", function() { return resolvers_hasUploadPermissions; }); |
991 __webpack_require__.d(resolvers_namespaceObject, "hasUploadPermissions", function() { return resolvers_hasUploadPermissions; }); |
583 __webpack_require__.d(resolvers_namespaceObject, "canUser", function() { return resolvers_canUser; }); |
992 __webpack_require__.d(resolvers_namespaceObject, "canUser", function() { return resolvers_canUser; }); |
584 |
993 __webpack_require__.d(resolvers_namespaceObject, "getAutosaves", function() { return resolvers_getAutosaves; }); |
585 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js |
994 __webpack_require__.d(resolvers_namespaceObject, "getAutosave", function() { return resolvers_getAutosave; }); |
586 var objectSpread = __webpack_require__(7); |
995 |
|
996 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
|
997 var defineProperty = __webpack_require__(5); |
587 |
998 |
588 // EXTERNAL MODULE: external {"this":["wp","data"]} |
999 // EXTERNAL MODULE: external {"this":["wp","data"]} |
589 var external_this_wp_data_ = __webpack_require__(5); |
1000 var external_this_wp_data_ = __webpack_require__(4); |
590 |
1001 |
591 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules |
1002 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules |
592 var slicedToArray = __webpack_require__(28); |
1003 var slicedToArray = __webpack_require__(14); |
593 |
1004 |
594 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
1005 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
595 var toConsumableArray = __webpack_require__(17); |
1006 var toConsumableArray = __webpack_require__(18); |
596 |
1007 |
597 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
1008 // EXTERNAL MODULE: external {"this":"lodash"} |
598 var defineProperty = __webpack_require__(15); |
1009 var external_this_lodash_ = __webpack_require__(2); |
599 |
1010 |
600 // EXTERNAL MODULE: external "lodash" |
1011 // EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]} |
601 var external_lodash_ = __webpack_require__(2); |
1012 var external_this_wp_isShallowEqual_ = __webpack_require__(64); |
|
1013 var external_this_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_isShallowEqual_); |
602 |
1014 |
603 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js |
1015 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js |
604 /** |
1016 /** |
605 * A higher-order reducer creator which invokes the original reducer only if |
1017 * A higher-order reducer creator which invokes the original reducer only if |
606 * the dispatching action matches the given predicate, **OR** if state is |
1018 * the dispatching action matches the given predicate, **OR** if state is |
655 |
1130 |
656 if (nextKeyState === state[key]) { |
1131 if (nextKeyState === state[key]) { |
657 return state; |
1132 return state; |
658 } |
1133 } |
659 |
1134 |
660 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, key, nextKeyState)); |
1135 return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, key, nextKeyState)); |
661 }; |
1136 }; |
662 }; |
1137 }; |
663 }; |
1138 }; |
664 /* harmony default export */ var on_sub_key = (on_sub_key_onSubKey); |
1139 /* harmony default export */ var on_sub_key = (on_sub_key_onSubKey); |
665 |
1140 |
666 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/replace-action.js |
1141 // EXTERNAL MODULE: external {"this":"regeneratorRuntime"} |
667 /** |
1142 var external_this_regeneratorRuntime_ = __webpack_require__(24); |
668 * Higher-order reducer creator which substitutes the action object before |
1143 var external_this_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_this_regeneratorRuntime_); |
669 * passing to the original reducer. |
1144 |
670 * |
1145 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
671 * @param {Function} replacer Function mapping original action to replacement. |
1146 var external_this_wp_i18n_ = __webpack_require__(1); |
672 * |
1147 |
673 * @return {Function} Higher-order reducer. |
1148 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/actions.js |
674 */ |
1149 |
675 var replaceAction = function replaceAction(replacer) { |
1150 |
676 return function (reducer) { |
1151 function actions_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
677 return function (state, action) { |
1152 |
678 return reducer(state, replacer(action)); |
1153 function actions_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { actions_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { actions_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
1154 |
|
1155 /** |
|
1156 * External dependencies |
|
1157 */ |
|
1158 |
|
1159 /** |
|
1160 * Returns an action object used in signalling that items have been received. |
|
1161 * |
|
1162 * @param {Array} items Items received. |
|
1163 * |
|
1164 * @return {Object} Action object. |
|
1165 */ |
|
1166 |
|
1167 function receiveItems(items) { |
|
1168 return { |
|
1169 type: 'RECEIVE_ITEMS', |
|
1170 items: Object(external_this_lodash_["castArray"])(items) |
|
1171 }; |
|
1172 } |
|
1173 /** |
|
1174 * Returns an action object used in signalling that queried data has been |
|
1175 * received. |
|
1176 * |
|
1177 * @param {Array} items Queried items received. |
|
1178 * @param {?Object} query Optional query object. |
|
1179 * |
|
1180 * @return {Object} Action object. |
|
1181 */ |
|
1182 |
|
1183 function receiveQueriedItems(items) { |
|
1184 var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
1185 return actions_objectSpread({}, receiveItems(items), { |
|
1186 query: query |
|
1187 }); |
|
1188 } |
|
1189 |
|
1190 // EXTERNAL MODULE: external {"this":["wp","apiFetch"]} |
|
1191 var external_this_wp_apiFetch_ = __webpack_require__(45); |
|
1192 var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_); |
|
1193 |
|
1194 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/controls.js |
|
1195 |
|
1196 |
|
1197 /** |
|
1198 * WordPress dependencies |
|
1199 */ |
|
1200 |
|
1201 |
|
1202 /** |
|
1203 * Trigger an API Fetch request. |
|
1204 * |
|
1205 * @param {Object} request API Fetch Request Object. |
|
1206 * @return {Object} control descriptor. |
|
1207 */ |
|
1208 |
|
1209 function apiFetch(request) { |
|
1210 return { |
|
1211 type: 'API_FETCH', |
|
1212 request: request |
|
1213 }; |
|
1214 } |
|
1215 /** |
|
1216 * Calls a selector using the current state. |
|
1217 * |
|
1218 * @param {string} selectorName Selector name. |
|
1219 * @param {Array} args Selector arguments. |
|
1220 * |
|
1221 * @return {Object} control descriptor. |
|
1222 */ |
|
1223 |
|
1224 function controls_select(selectorName) { |
|
1225 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
1226 args[_key - 1] = arguments[_key]; |
|
1227 } |
|
1228 |
|
1229 return { |
|
1230 type: 'SELECT', |
|
1231 selectorName: selectorName, |
|
1232 args: args |
|
1233 }; |
|
1234 } |
|
1235 /** |
|
1236 * Dispatches a control action for triggering a registry select that has a |
|
1237 * resolver. |
|
1238 * |
|
1239 * @param {string} selectorName |
|
1240 * @param {Array} args Arguments for the select. |
|
1241 * |
|
1242 * @return {Object} control descriptor. |
|
1243 */ |
|
1244 |
|
1245 function resolveSelect(selectorName) { |
|
1246 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { |
|
1247 args[_key2 - 1] = arguments[_key2]; |
|
1248 } |
|
1249 |
|
1250 return { |
|
1251 type: 'RESOLVE_SELECT', |
|
1252 selectorName: selectorName, |
|
1253 args: args |
|
1254 }; |
|
1255 } |
|
1256 var controls = { |
|
1257 API_FETCH: function API_FETCH(_ref) { |
|
1258 var request = _ref.request; |
|
1259 return external_this_wp_apiFetch_default()(request); |
|
1260 }, |
|
1261 SELECT: Object(external_this_wp_data_["createRegistryControl"])(function (registry) { |
|
1262 return function (_ref2) { |
|
1263 var _registry$select; |
|
1264 |
|
1265 var selectorName = _ref2.selectorName, |
|
1266 args = _ref2.args; |
|
1267 return (_registry$select = registry.select('core'))[selectorName].apply(_registry$select, Object(toConsumableArray["a" /* default */])(args)); |
679 }; |
1268 }; |
|
1269 }), |
|
1270 RESOLVE_SELECT: Object(external_this_wp_data_["createRegistryControl"])(function (registry) { |
|
1271 return function (_ref3) { |
|
1272 var _registry$__experimen; |
|
1273 |
|
1274 var selectorName = _ref3.selectorName, |
|
1275 args = _ref3.args; |
|
1276 return (_registry$__experimen = registry.__experimentalResolveSelect('core'))[selectorName].apply(_registry$__experimen, Object(toConsumableArray["a" /* default */])(args)); |
|
1277 }; |
|
1278 }) |
|
1279 }; |
|
1280 /* harmony default export */ var build_module_controls = (controls); |
|
1281 |
|
1282 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/actions.js |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 var _marked = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(actions_editEntityRecord), |
|
1288 _marked2 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(undo), |
|
1289 _marked3 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(redo), |
|
1290 _marked4 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(saveEntityRecord), |
|
1291 _marked5 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(saveEditedEntityRecord); |
|
1292 |
|
1293 function build_module_actions_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
1294 |
|
1295 function build_module_actions_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { build_module_actions_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { build_module_actions_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
1296 |
|
1297 /** |
|
1298 * External dependencies |
|
1299 */ |
|
1300 |
|
1301 /** |
|
1302 * Internal dependencies |
|
1303 */ |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 /** |
|
1309 * Returns an action object used in signalling that authors have been received. |
|
1310 * |
|
1311 * @param {string} queryID Query ID. |
|
1312 * @param {Array|Object} users Users received. |
|
1313 * |
|
1314 * @return {Object} Action object. |
|
1315 */ |
|
1316 |
|
1317 function receiveUserQuery(queryID, users) { |
|
1318 return { |
|
1319 type: 'RECEIVE_USER_QUERY', |
|
1320 users: Object(external_this_lodash_["castArray"])(users), |
|
1321 queryID: queryID |
680 }; |
1322 }; |
|
1323 } |
|
1324 /** |
|
1325 * Returns an action used in signalling that the current user has been received. |
|
1326 * |
|
1327 * @param {Object} currentUser Current user object. |
|
1328 * |
|
1329 * @return {Object} Action object. |
|
1330 */ |
|
1331 |
|
1332 function receiveCurrentUser(currentUser) { |
|
1333 return { |
|
1334 type: 'RECEIVE_CURRENT_USER', |
|
1335 currentUser: currentUser |
|
1336 }; |
|
1337 } |
|
1338 /** |
|
1339 * Returns an action object used in adding new entities. |
|
1340 * |
|
1341 * @param {Array} entities Entities received. |
|
1342 * |
|
1343 * @return {Object} Action object. |
|
1344 */ |
|
1345 |
|
1346 function addEntities(entities) { |
|
1347 return { |
|
1348 type: 'ADD_ENTITIES', |
|
1349 entities: entities |
|
1350 }; |
|
1351 } |
|
1352 /** |
|
1353 * Returns an action object used in signalling that entity records have been received. |
|
1354 * |
|
1355 * @param {string} kind Kind of the received entity. |
|
1356 * @param {string} name Name of the received entity. |
|
1357 * @param {Array|Object} records Records received. |
|
1358 * @param {?Object} query Query Object. |
|
1359 * @param {?boolean} invalidateCache Should invalidate query caches |
|
1360 * |
|
1361 * @return {Object} Action object. |
|
1362 */ |
|
1363 |
|
1364 function receiveEntityRecords(kind, name, records, query) { |
|
1365 var invalidateCache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; |
|
1366 |
|
1367 // Auto drafts should not have titles, but some plugins rely on them so we can't filter this |
|
1368 // on the server. |
|
1369 if (kind === 'postType') { |
|
1370 records = Object(external_this_lodash_["castArray"])(records).map(function (record) { |
|
1371 return record.status === 'auto-draft' ? build_module_actions_objectSpread({}, record, { |
|
1372 title: '' |
|
1373 }) : record; |
|
1374 }); |
|
1375 } |
|
1376 |
|
1377 var action; |
|
1378 |
|
1379 if (query) { |
|
1380 action = receiveQueriedItems(records, query); |
|
1381 } else { |
|
1382 action = receiveItems(records); |
|
1383 } |
|
1384 |
|
1385 return build_module_actions_objectSpread({}, action, { |
|
1386 kind: kind, |
|
1387 name: name, |
|
1388 invalidateCache: invalidateCache |
|
1389 }); |
|
1390 } |
|
1391 /** |
|
1392 * Returns an action object used in signalling that the current theme has been received. |
|
1393 * |
|
1394 * @param {Object} currentTheme The current theme. |
|
1395 * |
|
1396 * @return {Object} Action object. |
|
1397 */ |
|
1398 |
|
1399 function receiveCurrentTheme(currentTheme) { |
|
1400 return { |
|
1401 type: 'RECEIVE_CURRENT_THEME', |
|
1402 currentTheme: currentTheme |
|
1403 }; |
|
1404 } |
|
1405 /** |
|
1406 * Returns an action object used in signalling that the index has been received. |
|
1407 * |
|
1408 * @param {Object} themeSupports Theme support for the current theme. |
|
1409 * |
|
1410 * @return {Object} Action object. |
|
1411 */ |
|
1412 |
|
1413 function receiveThemeSupports(themeSupports) { |
|
1414 return { |
|
1415 type: 'RECEIVE_THEME_SUPPORTS', |
|
1416 themeSupports: themeSupports |
|
1417 }; |
|
1418 } |
|
1419 /** |
|
1420 * Returns an action object used in signalling that the preview data for |
|
1421 * a given URl has been received. |
|
1422 * |
|
1423 * @param {string} url URL to preview the embed for. |
|
1424 * @param {*} preview Preview data. |
|
1425 * |
|
1426 * @return {Object} Action object. |
|
1427 */ |
|
1428 |
|
1429 function receiveEmbedPreview(url, preview) { |
|
1430 return { |
|
1431 type: 'RECEIVE_EMBED_PREVIEW', |
|
1432 url: url, |
|
1433 preview: preview |
|
1434 }; |
|
1435 } |
|
1436 /** |
|
1437 * Returns an action object that triggers an |
|
1438 * edit to an entity record. |
|
1439 * |
|
1440 * @param {string} kind Kind of the edited entity record. |
|
1441 * @param {string} name Name of the edited entity record. |
|
1442 * @param {number} recordId Record ID of the edited entity record. |
|
1443 * @param {Object} edits The edits. |
|
1444 * @param {Object} options Options for the edit. |
|
1445 * @param {boolean} options.undoIgnore Whether to ignore the edit in undo history or not. |
|
1446 * |
|
1447 * @return {Object} Action object. |
|
1448 */ |
|
1449 |
|
1450 function actions_editEntityRecord(kind, name, recordId, edits) { |
|
1451 var options, |
|
1452 entity, |
|
1453 _entity$transientEdit, |
|
1454 transientEdits, |
|
1455 _entity$mergedEdits, |
|
1456 mergedEdits, |
|
1457 record, |
|
1458 editedRecord, |
|
1459 edit, |
|
1460 _args = arguments; |
|
1461 |
|
1462 return external_this_regeneratorRuntime_default.a.wrap(function editEntityRecord$(_context) { |
|
1463 while (1) { |
|
1464 switch (_context.prev = _context.next) { |
|
1465 case 0: |
|
1466 options = _args.length > 4 && _args[4] !== undefined ? _args[4] : {}; |
|
1467 _context.next = 3; |
|
1468 return controls_select('getEntity', kind, name); |
|
1469 |
|
1470 case 3: |
|
1471 entity = _context.sent; |
|
1472 |
|
1473 if (entity) { |
|
1474 _context.next = 6; |
|
1475 break; |
|
1476 } |
|
1477 |
|
1478 throw new Error("The entity being edited (".concat(kind, ", ").concat(name, ") does not have a loaded config.")); |
|
1479 |
|
1480 case 6: |
|
1481 _entity$transientEdit = entity.transientEdits, transientEdits = _entity$transientEdit === void 0 ? {} : _entity$transientEdit, _entity$mergedEdits = entity.mergedEdits, mergedEdits = _entity$mergedEdits === void 0 ? {} : _entity$mergedEdits; |
|
1482 _context.next = 9; |
|
1483 return controls_select('getRawEntityRecord', kind, name, recordId); |
|
1484 |
|
1485 case 9: |
|
1486 record = _context.sent; |
|
1487 _context.next = 12; |
|
1488 return controls_select('getEditedEntityRecord', kind, name, recordId); |
|
1489 |
|
1490 case 12: |
|
1491 editedRecord = _context.sent; |
|
1492 edit = { |
|
1493 kind: kind, |
|
1494 name: name, |
|
1495 recordId: recordId, |
|
1496 // Clear edits when they are equal to their persisted counterparts |
|
1497 // so that the property is not considered dirty. |
|
1498 edits: Object.keys(edits).reduce(function (acc, key) { |
|
1499 var recordValue = record[key]; |
|
1500 var editedRecordValue = editedRecord[key]; |
|
1501 var value = mergedEdits[key] ? build_module_actions_objectSpread({}, editedRecordValue, {}, edits[key]) : edits[key]; |
|
1502 acc[key] = Object(external_this_lodash_["isEqual"])(recordValue, value) ? undefined : value; |
|
1503 return acc; |
|
1504 }, {}), |
|
1505 transientEdits: transientEdits |
|
1506 }; |
|
1507 return _context.abrupt("return", build_module_actions_objectSpread({ |
|
1508 type: 'EDIT_ENTITY_RECORD' |
|
1509 }, edit, { |
|
1510 meta: { |
|
1511 undo: !options.undoIgnore && build_module_actions_objectSpread({}, edit, { |
|
1512 // Send the current values for things like the first undo stack entry. |
|
1513 edits: Object.keys(edits).reduce(function (acc, key) { |
|
1514 acc[key] = editedRecord[key]; |
|
1515 return acc; |
|
1516 }, {}) |
|
1517 }) |
|
1518 } |
|
1519 })); |
|
1520 |
|
1521 case 15: |
|
1522 case "end": |
|
1523 return _context.stop(); |
|
1524 } |
|
1525 } |
|
1526 }, _marked); |
|
1527 } |
|
1528 /** |
|
1529 * Action triggered to undo the last edit to |
|
1530 * an entity record, if any. |
|
1531 */ |
|
1532 |
|
1533 function undo() { |
|
1534 var undoEdit; |
|
1535 return external_this_regeneratorRuntime_default.a.wrap(function undo$(_context2) { |
|
1536 while (1) { |
|
1537 switch (_context2.prev = _context2.next) { |
|
1538 case 0: |
|
1539 _context2.next = 2; |
|
1540 return controls_select('getUndoEdit'); |
|
1541 |
|
1542 case 2: |
|
1543 undoEdit = _context2.sent; |
|
1544 |
|
1545 if (undoEdit) { |
|
1546 _context2.next = 5; |
|
1547 break; |
|
1548 } |
|
1549 |
|
1550 return _context2.abrupt("return"); |
|
1551 |
|
1552 case 5: |
|
1553 _context2.next = 7; |
|
1554 return build_module_actions_objectSpread({ |
|
1555 type: 'EDIT_ENTITY_RECORD' |
|
1556 }, undoEdit, { |
|
1557 meta: { |
|
1558 isUndo: true |
|
1559 } |
|
1560 }); |
|
1561 |
|
1562 case 7: |
|
1563 case "end": |
|
1564 return _context2.stop(); |
|
1565 } |
|
1566 } |
|
1567 }, _marked2); |
|
1568 } |
|
1569 /** |
|
1570 * Action triggered to redo the last undoed |
|
1571 * edit to an entity record, if any. |
|
1572 */ |
|
1573 |
|
1574 function redo() { |
|
1575 var redoEdit; |
|
1576 return external_this_regeneratorRuntime_default.a.wrap(function redo$(_context3) { |
|
1577 while (1) { |
|
1578 switch (_context3.prev = _context3.next) { |
|
1579 case 0: |
|
1580 _context3.next = 2; |
|
1581 return controls_select('getRedoEdit'); |
|
1582 |
|
1583 case 2: |
|
1584 redoEdit = _context3.sent; |
|
1585 |
|
1586 if (redoEdit) { |
|
1587 _context3.next = 5; |
|
1588 break; |
|
1589 } |
|
1590 |
|
1591 return _context3.abrupt("return"); |
|
1592 |
|
1593 case 5: |
|
1594 _context3.next = 7; |
|
1595 return build_module_actions_objectSpread({ |
|
1596 type: 'EDIT_ENTITY_RECORD' |
|
1597 }, redoEdit, { |
|
1598 meta: { |
|
1599 isRedo: true |
|
1600 } |
|
1601 }); |
|
1602 |
|
1603 case 7: |
|
1604 case "end": |
|
1605 return _context3.stop(); |
|
1606 } |
|
1607 } |
|
1608 }, _marked3); |
|
1609 } |
|
1610 /** |
|
1611 * Forces the creation of a new undo level. |
|
1612 * |
|
1613 * @return {Object} Action object. |
|
1614 */ |
|
1615 |
|
1616 function __unstableCreateUndoLevel() { |
|
1617 return { |
|
1618 type: 'CREATE_UNDO_LEVEL' |
|
1619 }; |
|
1620 } |
|
1621 /** |
|
1622 * Action triggered to save an entity record. |
|
1623 * |
|
1624 * @param {string} kind Kind of the received entity. |
|
1625 * @param {string} name Name of the received entity. |
|
1626 * @param {Object} record Record to be saved. |
|
1627 * @param {Object} options Saving options. |
|
1628 * @param {boolean} [options.isAutosave=false] Whether this is an autosave. |
|
1629 */ |
|
1630 |
|
1631 function saveEntityRecord(kind, name, record) { |
|
1632 var _ref, |
|
1633 _ref$isAutosave, |
|
1634 isAutosave, |
|
1635 entities, |
|
1636 entity, |
|
1637 entityIdKey, |
|
1638 recordId, |
|
1639 _i, |
|
1640 _Object$entries, |
|
1641 _Object$entries$_i, |
|
1642 key, |
|
1643 value, |
|
1644 evaluatedValue, |
|
1645 updatedRecord, |
|
1646 error, |
|
1647 persistedEntity, |
|
1648 currentEdits, |
|
1649 path, |
|
1650 persistedRecord, |
|
1651 currentUser, |
|
1652 currentUserId, |
|
1653 autosavePost, |
|
1654 data, |
|
1655 newRecord, |
|
1656 _data, |
|
1657 _args4 = arguments; |
|
1658 |
|
1659 return external_this_regeneratorRuntime_default.a.wrap(function saveEntityRecord$(_context4) { |
|
1660 while (1) { |
|
1661 switch (_context4.prev = _context4.next) { |
|
1662 case 0: |
|
1663 _ref = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : { |
|
1664 isAutosave: false |
|
1665 }, _ref$isAutosave = _ref.isAutosave, isAutosave = _ref$isAutosave === void 0 ? false : _ref$isAutosave; |
|
1666 _context4.next = 3; |
|
1667 return getKindEntities(kind); |
|
1668 |
|
1669 case 3: |
|
1670 entities = _context4.sent; |
|
1671 entity = Object(external_this_lodash_["find"])(entities, { |
|
1672 kind: kind, |
|
1673 name: name |
|
1674 }); |
|
1675 |
|
1676 if (entity) { |
|
1677 _context4.next = 7; |
|
1678 break; |
|
1679 } |
|
1680 |
|
1681 return _context4.abrupt("return"); |
|
1682 |
|
1683 case 7: |
|
1684 entityIdKey = entity.key || DEFAULT_ENTITY_KEY; |
|
1685 recordId = record[entityIdKey]; // Evaluate optimized edits. |
|
1686 // (Function edits that should be evaluated on save to avoid expensive computations on every edit.) |
|
1687 |
|
1688 _i = 0, _Object$entries = Object.entries(record); |
|
1689 |
|
1690 case 10: |
|
1691 if (!(_i < _Object$entries.length)) { |
|
1692 _context4.next = 24; |
|
1693 break; |
|
1694 } |
|
1695 |
|
1696 _Object$entries$_i = Object(slicedToArray["a" /* default */])(_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1]; |
|
1697 |
|
1698 if (!(typeof value === 'function')) { |
|
1699 _context4.next = 21; |
|
1700 break; |
|
1701 } |
|
1702 |
|
1703 _context4.t0 = value; |
|
1704 _context4.next = 16; |
|
1705 return controls_select('getEditedEntityRecord', kind, name, recordId); |
|
1706 |
|
1707 case 16: |
|
1708 _context4.t1 = _context4.sent; |
|
1709 evaluatedValue = (0, _context4.t0)(_context4.t1); |
|
1710 _context4.next = 20; |
|
1711 return actions_editEntityRecord(kind, name, recordId, Object(defineProperty["a" /* default */])({}, key, evaluatedValue), { |
|
1712 undoIgnore: true |
|
1713 }); |
|
1714 |
|
1715 case 20: |
|
1716 record[key] = evaluatedValue; |
|
1717 |
|
1718 case 21: |
|
1719 _i++; |
|
1720 _context4.next = 10; |
|
1721 break; |
|
1722 |
|
1723 case 24: |
|
1724 _context4.next = 26; |
|
1725 return { |
|
1726 type: 'SAVE_ENTITY_RECORD_START', |
|
1727 kind: kind, |
|
1728 name: name, |
|
1729 recordId: recordId, |
|
1730 isAutosave: isAutosave |
|
1731 }; |
|
1732 |
|
1733 case 26: |
|
1734 _context4.prev = 26; |
|
1735 path = "".concat(entity.baseURL).concat(recordId ? '/' + recordId : ''); |
|
1736 _context4.next = 30; |
|
1737 return controls_select('getRawEntityRecord', kind, name, recordId); |
|
1738 |
|
1739 case 30: |
|
1740 persistedRecord = _context4.sent; |
|
1741 |
|
1742 if (!isAutosave) { |
|
1743 _context4.next = 55; |
|
1744 break; |
|
1745 } |
|
1746 |
|
1747 _context4.next = 34; |
|
1748 return controls_select('getCurrentUser'); |
|
1749 |
|
1750 case 34: |
|
1751 currentUser = _context4.sent; |
|
1752 currentUserId = currentUser ? currentUser.id : undefined; |
|
1753 _context4.next = 38; |
|
1754 return controls_select('getAutosave', persistedRecord.type, persistedRecord.id, currentUserId); |
|
1755 |
|
1756 case 38: |
|
1757 autosavePost = _context4.sent; |
|
1758 // Autosaves need all expected fields to be present. |
|
1759 // So we fallback to the previous autosave and then |
|
1760 // to the actual persisted entity if the edits don't |
|
1761 // have a value. |
|
1762 data = build_module_actions_objectSpread({}, persistedRecord, {}, autosavePost, {}, record); |
|
1763 data = Object.keys(data).reduce(function (acc, key) { |
|
1764 if (['title', 'excerpt', 'content'].includes(key)) { |
|
1765 // Edits should be the "raw" attribute values. |
|
1766 acc[key] = Object(external_this_lodash_["get"])(data[key], 'raw', data[key]); |
|
1767 } |
|
1768 |
|
1769 return acc; |
|
1770 }, { |
|
1771 status: data.status === 'auto-draft' ? 'draft' : data.status |
|
1772 }); |
|
1773 _context4.next = 43; |
|
1774 return apiFetch({ |
|
1775 path: "".concat(path, "/autosaves"), |
|
1776 method: 'POST', |
|
1777 data: data |
|
1778 }); |
|
1779 |
|
1780 case 43: |
|
1781 updatedRecord = _context4.sent; |
|
1782 |
|
1783 if (!(persistedRecord.id === updatedRecord.id)) { |
|
1784 _context4.next = 51; |
|
1785 break; |
|
1786 } |
|
1787 |
|
1788 newRecord = build_module_actions_objectSpread({}, persistedRecord, {}, data, {}, updatedRecord); |
|
1789 newRecord = Object.keys(newRecord).reduce(function (acc, key) { |
|
1790 // These properties are persisted in autosaves. |
|
1791 if (['title', 'excerpt', 'content'].includes(key)) { |
|
1792 // Edits should be the "raw" attribute values. |
|
1793 acc[key] = Object(external_this_lodash_["get"])(newRecord[key], 'raw', newRecord[key]); |
|
1794 } else if (key === 'status') { |
|
1795 // Status is only persisted in autosaves when going from |
|
1796 // "auto-draft" to "draft". |
|
1797 acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status; |
|
1798 } else { |
|
1799 // These properties are not persisted in autosaves. |
|
1800 acc[key] = Object(external_this_lodash_["get"])(persistedRecord[key], 'raw', persistedRecord[key]); |
|
1801 } |
|
1802 |
|
1803 return acc; |
|
1804 }, {}); |
|
1805 _context4.next = 49; |
|
1806 return receiveEntityRecords(kind, name, newRecord, undefined, true); |
|
1807 |
|
1808 case 49: |
|
1809 _context4.next = 53; |
|
1810 break; |
|
1811 |
|
1812 case 51: |
|
1813 _context4.next = 53; |
|
1814 return receiveAutosaves(persistedRecord.id, updatedRecord); |
|
1815 |
|
1816 case 53: |
|
1817 _context4.next = 70; |
|
1818 break; |
|
1819 |
|
1820 case 55: |
|
1821 // Auto drafts should be converted to drafts on explicit saves and we should not respect their default title, |
|
1822 // but some plugins break with this behavior so we can't filter it on the server. |
|
1823 _data = record; |
|
1824 |
|
1825 if (kind === 'postType' && persistedRecord && persistedRecord.status === 'auto-draft') { |
|
1826 if (!_data.status) { |
|
1827 _data = build_module_actions_objectSpread({}, _data, { |
|
1828 status: 'draft' |
|
1829 }); |
|
1830 } |
|
1831 |
|
1832 if (!_data.title || _data.title === 'Auto Draft') { |
|
1833 _data = build_module_actions_objectSpread({}, _data, { |
|
1834 title: '' |
|
1835 }); |
|
1836 } |
|
1837 } // Get the full local version of the record before the update, |
|
1838 // to merge it with the edits and then propagate it to subscribers |
|
1839 |
|
1840 |
|
1841 _context4.next = 59; |
|
1842 return controls_select('__experimentalGetEntityRecordNoResolver', kind, name, recordId); |
|
1843 |
|
1844 case 59: |
|
1845 persistedEntity = _context4.sent; |
|
1846 _context4.next = 62; |
|
1847 return controls_select('getEntityRecordEdits', kind, name, recordId); |
|
1848 |
|
1849 case 62: |
|
1850 currentEdits = _context4.sent; |
|
1851 _context4.next = 65; |
|
1852 return receiveEntityRecords(kind, name, build_module_actions_objectSpread({}, persistedEntity, {}, _data), undefined, true); |
|
1853 |
|
1854 case 65: |
|
1855 _context4.next = 67; |
|
1856 return apiFetch({ |
|
1857 path: path, |
|
1858 method: recordId ? 'PUT' : 'POST', |
|
1859 data: _data |
|
1860 }); |
|
1861 |
|
1862 case 67: |
|
1863 updatedRecord = _context4.sent; |
|
1864 _context4.next = 70; |
|
1865 return receiveEntityRecords(kind, name, updatedRecord, undefined, true); |
|
1866 |
|
1867 case 70: |
|
1868 _context4.next = 93; |
|
1869 break; |
|
1870 |
|
1871 case 72: |
|
1872 _context4.prev = 72; |
|
1873 _context4.t2 = _context4["catch"](26); |
|
1874 error = _context4.t2; // If we got to the point in the try block where we made an optimistic update, |
|
1875 // we need to roll it back here. |
|
1876 |
|
1877 if (!(persistedEntity && currentEdits)) { |
|
1878 _context4.next = 93; |
|
1879 break; |
|
1880 } |
|
1881 |
|
1882 _context4.next = 78; |
|
1883 return receiveEntityRecords(kind, name, persistedEntity, undefined, true); |
|
1884 |
|
1885 case 78: |
|
1886 _context4.t3 = actions_editEntityRecord; |
|
1887 _context4.t4 = kind; |
|
1888 _context4.t5 = name; |
|
1889 _context4.t6 = recordId; |
|
1890 _context4.t7 = build_module_actions_objectSpread; |
|
1891 _context4.t8 = {}; |
|
1892 _context4.t9 = currentEdits; |
|
1893 _context4.t10 = {}; |
|
1894 _context4.next = 88; |
|
1895 return controls_select('getEntityRecordEdits', kind, name, recordId); |
|
1896 |
|
1897 case 88: |
|
1898 _context4.t11 = _context4.sent; |
|
1899 _context4.t12 = (0, _context4.t7)(_context4.t8, _context4.t9, _context4.t10, _context4.t11); |
|
1900 _context4.t13 = { |
|
1901 undoIgnore: true |
|
1902 }; |
|
1903 _context4.next = 93; |
|
1904 return (0, _context4.t3)(_context4.t4, _context4.t5, _context4.t6, _context4.t12, _context4.t13); |
|
1905 |
|
1906 case 93: |
|
1907 _context4.next = 95; |
|
1908 return { |
|
1909 type: 'SAVE_ENTITY_RECORD_FINISH', |
|
1910 kind: kind, |
|
1911 name: name, |
|
1912 recordId: recordId, |
|
1913 error: error, |
|
1914 isAutosave: isAutosave |
|
1915 }; |
|
1916 |
|
1917 case 95: |
|
1918 return _context4.abrupt("return", updatedRecord); |
|
1919 |
|
1920 case 96: |
|
1921 case "end": |
|
1922 return _context4.stop(); |
|
1923 } |
|
1924 } |
|
1925 }, _marked4, null, [[26, 72]]); |
|
1926 } |
|
1927 /** |
|
1928 * Action triggered to save an entity record's edits. |
|
1929 * |
|
1930 * @param {string} kind Kind of the entity. |
|
1931 * @param {string} name Name of the entity. |
|
1932 * @param {Object} recordId ID of the record. |
|
1933 * @param {Object} options Saving options. |
|
1934 */ |
|
1935 |
|
1936 function saveEditedEntityRecord(kind, name, recordId, options) { |
|
1937 var edits, record; |
|
1938 return external_this_regeneratorRuntime_default.a.wrap(function saveEditedEntityRecord$(_context5) { |
|
1939 while (1) { |
|
1940 switch (_context5.prev = _context5.next) { |
|
1941 case 0: |
|
1942 _context5.next = 2; |
|
1943 return controls_select('hasEditsForEntityRecord', kind, name, recordId); |
|
1944 |
|
1945 case 2: |
|
1946 if (_context5.sent) { |
|
1947 _context5.next = 4; |
|
1948 break; |
|
1949 } |
|
1950 |
|
1951 return _context5.abrupt("return"); |
|
1952 |
|
1953 case 4: |
|
1954 _context5.next = 6; |
|
1955 return controls_select('getEntityRecordNonTransientEdits', kind, name, recordId); |
|
1956 |
|
1957 case 6: |
|
1958 edits = _context5.sent; |
|
1959 record = build_module_actions_objectSpread({ |
|
1960 id: recordId |
|
1961 }, edits); |
|
1962 return _context5.delegateYield(saveEntityRecord(kind, name, record, options), "t0", 9); |
|
1963 |
|
1964 case 9: |
|
1965 case "end": |
|
1966 return _context5.stop(); |
|
1967 } |
|
1968 } |
|
1969 }, _marked5); |
|
1970 } |
|
1971 /** |
|
1972 * Returns an action object used in signalling that Upload permissions have been received. |
|
1973 * |
|
1974 * @param {boolean} hasUploadPermissions Does the user have permission to upload files? |
|
1975 * |
|
1976 * @return {Object} Action object. |
|
1977 */ |
|
1978 |
|
1979 function receiveUploadPermissions(hasUploadPermissions) { |
|
1980 return { |
|
1981 type: 'RECEIVE_USER_PERMISSION', |
|
1982 key: 'create/media', |
|
1983 isAllowed: hasUploadPermissions |
|
1984 }; |
|
1985 } |
|
1986 /** |
|
1987 * Returns an action object used in signalling that the current user has |
|
1988 * permission to perform an action on a REST resource. |
|
1989 * |
|
1990 * @param {string} key A key that represents the action and REST resource. |
|
1991 * @param {boolean} isAllowed Whether or not the user can perform the action. |
|
1992 * |
|
1993 * @return {Object} Action object. |
|
1994 */ |
|
1995 |
|
1996 function receiveUserPermission(key, isAllowed) { |
|
1997 return { |
|
1998 type: 'RECEIVE_USER_PERMISSION', |
|
1999 key: key, |
|
2000 isAllowed: isAllowed |
|
2001 }; |
|
2002 } |
|
2003 /** |
|
2004 * Returns an action object used in signalling that the autosaves for a |
|
2005 * post have been received. |
|
2006 * |
|
2007 * @param {number} postId The id of the post that is parent to the autosave. |
|
2008 * @param {Array|Object} autosaves An array of autosaves or singular autosave object. |
|
2009 * |
|
2010 * @return {Object} Action object. |
|
2011 */ |
|
2012 |
|
2013 function receiveAutosaves(postId, autosaves) { |
|
2014 return { |
|
2015 type: 'RECEIVE_AUTOSAVES', |
|
2016 postId: postId, |
|
2017 autosaves: Object(external_this_lodash_["castArray"])(autosaves) |
|
2018 }; |
|
2019 } |
|
2020 |
|
2021 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entities.js |
|
2022 |
|
2023 |
|
2024 var entities_marked = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(loadPostTypeEntities), |
|
2025 entities_marked2 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(loadTaxonomyEntities), |
|
2026 entities_marked3 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(getKindEntities); |
|
2027 |
|
2028 /** |
|
2029 * External dependencies |
|
2030 */ |
|
2031 |
|
2032 /** |
|
2033 * WordPress dependencies |
|
2034 */ |
|
2035 |
|
2036 |
|
2037 /** |
|
2038 * Internal dependencies |
|
2039 */ |
|
2040 |
|
2041 |
|
2042 |
|
2043 var DEFAULT_ENTITY_KEY = 'id'; |
|
2044 var defaultEntities = [{ |
|
2045 label: Object(external_this_wp_i18n_["__"])('Site'), |
|
2046 name: 'site', |
|
2047 kind: 'root', |
|
2048 baseURL: '/wp/v2/settings', |
|
2049 getTitle: function getTitle(record) { |
|
2050 return Object(external_this_lodash_["get"])(record, ['title'], Object(external_this_wp_i18n_["__"])('Site Title')); |
|
2051 } |
|
2052 }, { |
|
2053 label: Object(external_this_wp_i18n_["__"])('Post Type'), |
|
2054 name: 'postType', |
|
2055 kind: 'root', |
|
2056 key: 'slug', |
|
2057 baseURL: '/wp/v2/types' |
|
2058 }, { |
|
2059 name: 'media', |
|
2060 kind: 'root', |
|
2061 baseURL: '/wp/v2/media', |
|
2062 plural: 'mediaItems', |
|
2063 label: Object(external_this_wp_i18n_["__"])('Media') |
|
2064 }, { |
|
2065 name: 'taxonomy', |
|
2066 kind: 'root', |
|
2067 key: 'slug', |
|
2068 baseURL: '/wp/v2/taxonomies', |
|
2069 plural: 'taxonomies', |
|
2070 label: Object(external_this_wp_i18n_["__"])('Taxonomy') |
|
2071 }, { |
|
2072 name: 'widgetArea', |
|
2073 kind: 'root', |
|
2074 baseURL: '/__experimental/widget-areas', |
|
2075 plural: 'widgetAreas', |
|
2076 transientEdits: { |
|
2077 blocks: true |
|
2078 }, |
|
2079 label: Object(external_this_wp_i18n_["__"])('Widget area') |
|
2080 }, { |
|
2081 label: Object(external_this_wp_i18n_["__"])('User'), |
|
2082 name: 'user', |
|
2083 kind: 'root', |
|
2084 baseURL: '/wp/v2/users', |
|
2085 plural: 'users' |
|
2086 }, { |
|
2087 name: 'comment', |
|
2088 kind: 'root', |
|
2089 baseURL: '/wp/v2/comments', |
|
2090 plural: 'comments', |
|
2091 label: Object(external_this_wp_i18n_["__"])('Comment') |
|
2092 }, { |
|
2093 name: 'menu', |
|
2094 kind: 'root', |
|
2095 baseURL: '/__experimental/menus', |
|
2096 plural: 'menus', |
|
2097 label: Object(external_this_wp_i18n_["__"])('Menu') |
|
2098 }, { |
|
2099 name: 'menuItem', |
|
2100 kind: 'root', |
|
2101 baseURL: '/__experimental/menu-items', |
|
2102 plural: 'menuItems', |
|
2103 label: Object(external_this_wp_i18n_["__"])('Menu Item') |
|
2104 }, { |
|
2105 name: 'menuLocation', |
|
2106 kind: 'root', |
|
2107 baseURL: '/__experimental/menu-locations', |
|
2108 plural: 'menuLocations', |
|
2109 label: Object(external_this_wp_i18n_["__"])('Menu Location'), |
|
2110 key: 'name' |
|
2111 }]; |
|
2112 var kinds = [{ |
|
2113 name: 'postType', |
|
2114 loadEntities: loadPostTypeEntities |
|
2115 }, { |
|
2116 name: 'taxonomy', |
|
2117 loadEntities: loadTaxonomyEntities |
|
2118 }]; |
|
2119 /** |
|
2120 * Returns the list of post type entities. |
|
2121 * |
|
2122 * @return {Promise} Entities promise |
|
2123 */ |
|
2124 |
|
2125 function loadPostTypeEntities() { |
|
2126 var postTypes; |
|
2127 return external_this_regeneratorRuntime_default.a.wrap(function loadPostTypeEntities$(_context) { |
|
2128 while (1) { |
|
2129 switch (_context.prev = _context.next) { |
|
2130 case 0: |
|
2131 _context.next = 2; |
|
2132 return apiFetch({ |
|
2133 path: '/wp/v2/types?context=edit' |
|
2134 }); |
|
2135 |
|
2136 case 2: |
|
2137 postTypes = _context.sent; |
|
2138 return _context.abrupt("return", Object(external_this_lodash_["map"])(postTypes, function (postType, name) { |
|
2139 return { |
|
2140 kind: 'postType', |
|
2141 baseURL: '/wp/v2/' + postType.rest_base, |
|
2142 name: name, |
|
2143 label: postType.labels.singular_name, |
|
2144 transientEdits: { |
|
2145 blocks: true, |
|
2146 selectionStart: true, |
|
2147 selectionEnd: true |
|
2148 }, |
|
2149 mergedEdits: { |
|
2150 meta: true |
|
2151 }, |
|
2152 getTitle: function getTitle(record) { |
|
2153 if (name === 'wp_template_part' || name === 'wp_template') { |
|
2154 return Object(external_this_lodash_["startCase"])(record.slug); |
|
2155 } |
|
2156 |
|
2157 return Object(external_this_lodash_["get"])(record, ['title', 'rendered'], record.id); |
|
2158 } |
|
2159 }; |
|
2160 })); |
|
2161 |
|
2162 case 4: |
|
2163 case "end": |
|
2164 return _context.stop(); |
|
2165 } |
|
2166 } |
|
2167 }, entities_marked); |
|
2168 } |
|
2169 /** |
|
2170 * Returns the list of the taxonomies entities. |
|
2171 * |
|
2172 * @return {Promise} Entities promise |
|
2173 */ |
|
2174 |
|
2175 |
|
2176 function loadTaxonomyEntities() { |
|
2177 var taxonomies; |
|
2178 return external_this_regeneratorRuntime_default.a.wrap(function loadTaxonomyEntities$(_context2) { |
|
2179 while (1) { |
|
2180 switch (_context2.prev = _context2.next) { |
|
2181 case 0: |
|
2182 _context2.next = 2; |
|
2183 return apiFetch({ |
|
2184 path: '/wp/v2/taxonomies?context=edit' |
|
2185 }); |
|
2186 |
|
2187 case 2: |
|
2188 taxonomies = _context2.sent; |
|
2189 return _context2.abrupt("return", Object(external_this_lodash_["map"])(taxonomies, function (taxonomy, name) { |
|
2190 return { |
|
2191 kind: 'taxonomy', |
|
2192 baseURL: '/wp/v2/' + taxonomy.rest_base, |
|
2193 name: name, |
|
2194 label: taxonomy.labels.singular_name |
|
2195 }; |
|
2196 })); |
|
2197 |
|
2198 case 4: |
|
2199 case "end": |
|
2200 return _context2.stop(); |
|
2201 } |
|
2202 } |
|
2203 }, entities_marked2); |
|
2204 } |
|
2205 /** |
|
2206 * Returns the entity's getter method name given its kind and name. |
|
2207 * |
|
2208 * @param {string} kind Entity kind. |
|
2209 * @param {string} name Entity name. |
|
2210 * @param {string} prefix Function prefix. |
|
2211 * @param {boolean} usePlural Whether to use the plural form or not. |
|
2212 * |
|
2213 * @return {string} Method name |
|
2214 */ |
|
2215 |
|
2216 |
|
2217 var entities_getMethodName = function getMethodName(kind, name) { |
|
2218 var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'get'; |
|
2219 var usePlural = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
|
2220 var entity = Object(external_this_lodash_["find"])(defaultEntities, { |
|
2221 kind: kind, |
|
2222 name: name |
|
2223 }); |
|
2224 var kindPrefix = kind === 'root' ? '' : Object(external_this_lodash_["upperFirst"])(Object(external_this_lodash_["camelCase"])(kind)); |
|
2225 var nameSuffix = Object(external_this_lodash_["upperFirst"])(Object(external_this_lodash_["camelCase"])(name)) + (usePlural ? 's' : ''); |
|
2226 var suffix = usePlural && entity.plural ? Object(external_this_lodash_["upperFirst"])(Object(external_this_lodash_["camelCase"])(entity.plural)) : nameSuffix; |
|
2227 return "".concat(prefix).concat(kindPrefix).concat(suffix); |
681 }; |
2228 }; |
682 |
2229 /** |
683 /* harmony default export */ var replace_action = (replaceAction); |
2230 * Loads the kind entities into the store. |
|
2231 * |
|
2232 * @param {string} kind Kind |
|
2233 * |
|
2234 * @return {Array} Entities |
|
2235 */ |
|
2236 |
|
2237 function getKindEntities(kind) { |
|
2238 var entities, kindConfig; |
|
2239 return external_this_regeneratorRuntime_default.a.wrap(function getKindEntities$(_context3) { |
|
2240 while (1) { |
|
2241 switch (_context3.prev = _context3.next) { |
|
2242 case 0: |
|
2243 _context3.next = 2; |
|
2244 return controls_select('getEntitiesByKind', kind); |
|
2245 |
|
2246 case 2: |
|
2247 entities = _context3.sent; |
|
2248 |
|
2249 if (!(entities && entities.length !== 0)) { |
|
2250 _context3.next = 5; |
|
2251 break; |
|
2252 } |
|
2253 |
|
2254 return _context3.abrupt("return", entities); |
|
2255 |
|
2256 case 5: |
|
2257 kindConfig = Object(external_this_lodash_["find"])(kinds, { |
|
2258 name: kind |
|
2259 }); |
|
2260 |
|
2261 if (kindConfig) { |
|
2262 _context3.next = 8; |
|
2263 break; |
|
2264 } |
|
2265 |
|
2266 return _context3.abrupt("return", []); |
|
2267 |
|
2268 case 8: |
|
2269 _context3.next = 10; |
|
2270 return kindConfig.loadEntities(); |
|
2271 |
|
2272 case 10: |
|
2273 entities = _context3.sent; |
|
2274 _context3.next = 13; |
|
2275 return addEntities(entities); |
|
2276 |
|
2277 case 13: |
|
2278 return _context3.abrupt("return", entities); |
|
2279 |
|
2280 case 14: |
|
2281 case "end": |
|
2282 return _context3.stop(); |
|
2283 } |
|
2284 } |
|
2285 }, entities_marked3); |
|
2286 } |
|
2287 |
|
2288 // EXTERNAL MODULE: external {"this":["wp","url"]} |
|
2289 var external_this_wp_url_ = __webpack_require__(31); |
684 |
2290 |
685 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js |
2291 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js |
686 /** |
2292 /** |
687 * External dependencies |
2293 * External dependencies |
688 */ |
2294 */ |
846 |
2398 |
847 return parts; |
2399 return parts; |
848 } |
2400 } |
849 /* harmony default export */ var get_query_parts = (with_weak_map_cache(getQueryParts)); |
2401 /* harmony default export */ var get_query_parts = (with_weak_map_cache(getQueryParts)); |
850 |
2402 |
851 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/selectors.js |
2403 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/reducer.js |
|
2404 |
|
2405 |
|
2406 function reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
2407 |
|
2408 function reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { reducer_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
2409 |
852 /** |
2410 /** |
853 * External dependencies |
2411 * External dependencies |
854 */ |
2412 */ |
855 |
2413 |
856 |
|
857 /** |
|
858 * Internal dependencies |
|
859 */ |
|
860 |
|
861 |
|
862 /** |
|
863 * Cache of state keys to EquivalentKeyMap where the inner map tracks queries |
|
864 * to their resulting items set. WeakMap allows garbage collection on expired |
|
865 * state references. |
|
866 * |
|
867 * @type {WeakMap<Object,EquivalentKeyMap>} |
|
868 */ |
|
869 |
|
870 var queriedItemsCacheByState = new WeakMap(); |
|
871 /** |
|
872 * Returns items for a given query, or null if the items are not known. |
|
873 * |
|
874 * @param {Object} state State object. |
|
875 * @param {?Object} query Optional query. |
|
876 * |
|
877 * @return {?Array} Query items. |
|
878 */ |
|
879 |
|
880 function getQueriedItemsUncached(state, query) { |
|
881 var _getQueryParts = get_query_parts(query), |
|
882 stableKey = _getQueryParts.stableKey, |
|
883 page = _getQueryParts.page, |
|
884 perPage = _getQueryParts.perPage; |
|
885 |
|
886 if (!state.queries[stableKey]) { |
|
887 return null; |
|
888 } |
|
889 |
|
890 var itemIds = state.queries[stableKey]; |
|
891 |
|
892 if (!itemIds) { |
|
893 return null; |
|
894 } |
|
895 |
|
896 var startOffset = perPage === -1 ? 0 : (page - 1) * perPage; |
|
897 var endOffset = perPage === -1 ? itemIds.length : Math.min(startOffset + perPage, itemIds.length); |
|
898 var items = []; |
|
899 |
|
900 for (var i = startOffset; i < endOffset; i++) { |
|
901 var itemId = itemIds[i]; |
|
902 items.push(state.items[itemId]); |
|
903 } |
|
904 |
|
905 return items; |
|
906 } |
|
907 /** |
|
908 * Returns items for a given query, or null if the items are not known. Caches |
|
909 * result both per state (by reference) and per query (by deep equality). |
|
910 * The caching approach is intended to be durable to query objects which are |
|
911 * deeply but not referentially equal, since otherwise: |
|
912 * |
|
913 * `getQueriedItems( state, {} ) !== getQueriedItems( state, {} )` |
|
914 * |
|
915 * @param {Object} state State object. |
|
916 * @param {?Object} query Optional query. |
|
917 * |
|
918 * @return {?Array} Query items. |
|
919 */ |
|
920 |
|
921 |
|
922 var getQueriedItems = Object(rememo["a" /* default */])(function (state) { |
|
923 var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
924 var queriedItemsCache = queriedItemsCacheByState.get(state); |
|
925 |
|
926 if (queriedItemsCache) { |
|
927 var queriedItems = queriedItemsCache.get(query); |
|
928 |
|
929 if (queriedItems !== undefined) { |
|
930 return queriedItems; |
|
931 } |
|
932 } else { |
|
933 queriedItemsCache = new equivalent_key_map_default.a(); |
|
934 queriedItemsCacheByState.set(state, queriedItemsCache); |
|
935 } |
|
936 |
|
937 var items = getQueriedItemsUncached(state, query); |
|
938 queriedItemsCache.set(query, items); |
|
939 return items; |
|
940 }); |
|
941 |
|
942 // EXTERNAL MODULE: ./node_modules/redux/es/redux.js |
|
943 var redux = __webpack_require__(71); |
|
944 |
|
945 // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js |
|
946 var regenerator = __webpack_require__(23); |
|
947 var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator); |
|
948 |
|
949 // EXTERNAL MODULE: external {"this":["wp","apiFetch"]} |
|
950 var external_this_wp_apiFetch_ = __webpack_require__(33); |
|
951 var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_); |
|
952 |
|
953 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/controls.js |
|
954 |
|
955 |
|
956 /** |
2414 /** |
957 * WordPress dependencies |
2415 * WordPress dependencies |
958 */ |
|
959 |
|
960 |
|
961 /** |
|
962 * Trigger an API Fetch request. |
|
963 * |
|
964 * @param {Object} request API Fetch Request Object. |
|
965 * @return {Object} control descriptor. |
|
966 */ |
|
967 |
|
968 function apiFetch(request) { |
|
969 return { |
|
970 type: 'API_FETCH', |
|
971 request: request |
|
972 }; |
|
973 } |
|
974 /** |
|
975 * Calls a selector using the current state. |
|
976 * @param {string} selectorName Selector name. |
|
977 * @param {Array} args Selector arguments. |
|
978 * |
|
979 * @return {Object} control descriptor. |
|
980 */ |
|
981 |
|
982 function controls_select(selectorName) { |
|
983 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
984 args[_key - 1] = arguments[_key]; |
|
985 } |
|
986 |
|
987 return { |
|
988 type: 'SELECT', |
|
989 selectorName: selectorName, |
|
990 args: args |
|
991 }; |
|
992 } |
|
993 var controls = { |
|
994 API_FETCH: function API_FETCH(_ref) { |
|
995 var request = _ref.request; |
|
996 return external_this_wp_apiFetch_default()(request); |
|
997 }, |
|
998 SELECT: Object(external_this_wp_data_["createRegistryControl"])(function (registry) { |
|
999 return function (_ref2) { |
|
1000 var _registry$select; |
|
1001 |
|
1002 var selectorName = _ref2.selectorName, |
|
1003 args = _ref2.args; |
|
1004 return (_registry$select = registry.select('core'))[selectorName].apply(_registry$select, Object(toConsumableArray["a" /* default */])(args)); |
|
1005 }; |
|
1006 }) |
|
1007 }; |
|
1008 /* harmony default export */ var build_module_controls = (controls); |
|
1009 |
|
1010 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/actions.js |
|
1011 |
|
1012 |
|
1013 |
|
1014 var _marked = |
|
1015 /*#__PURE__*/ |
|
1016 regenerator_default.a.mark(saveEntityRecord); |
|
1017 |
|
1018 /** |
|
1019 * External dependencies |
|
1020 */ |
|
1021 |
|
1022 /** |
|
1023 * Internal dependencies |
|
1024 */ |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 /** |
|
1030 * Returns an action object used in signalling that authors have been received. |
|
1031 * |
|
1032 * @param {string} queryID Query ID. |
|
1033 * @param {Array|Object} users Users received. |
|
1034 * |
|
1035 * @return {Object} Action object. |
|
1036 */ |
|
1037 |
|
1038 function receiveUserQuery(queryID, users) { |
|
1039 return { |
|
1040 type: 'RECEIVE_USER_QUERY', |
|
1041 users: Object(external_lodash_["castArray"])(users), |
|
1042 queryID: queryID |
|
1043 }; |
|
1044 } |
|
1045 /** |
|
1046 * Returns an action object used in adding new entities. |
|
1047 * |
|
1048 * @param {Array} entities Entities received. |
|
1049 * |
|
1050 * @return {Object} Action object. |
|
1051 */ |
|
1052 |
|
1053 function addEntities(entities) { |
|
1054 return { |
|
1055 type: 'ADD_ENTITIES', |
|
1056 entities: entities |
|
1057 }; |
|
1058 } |
|
1059 /** |
|
1060 * Returns an action object used in signalling that entity records have been received. |
|
1061 * |
|
1062 * @param {string} kind Kind of the received entity. |
|
1063 * @param {string} name Name of the received entity. |
|
1064 * @param {Array|Object} records Records received. |
|
1065 * @param {?Object} query Query Object. |
|
1066 * @param {?boolean} invalidateCache Should invalidate query caches |
|
1067 * |
|
1068 * @return {Object} Action object. |
|
1069 */ |
|
1070 |
|
1071 function receiveEntityRecords(kind, name, records, query) { |
|
1072 var invalidateCache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; |
|
1073 var action; |
|
1074 |
|
1075 if (query) { |
|
1076 action = receiveQueriedItems(records, query); |
|
1077 } else { |
|
1078 action = receiveItems(records); |
|
1079 } |
|
1080 |
|
1081 return Object(objectSpread["a" /* default */])({}, action, { |
|
1082 kind: kind, |
|
1083 name: name, |
|
1084 invalidateCache: invalidateCache |
|
1085 }); |
|
1086 } |
|
1087 /** |
|
1088 * Returns an action object used in signalling that the index has been received. |
|
1089 * |
|
1090 * @param {Object} themeSupports Theme support for the current theme. |
|
1091 * |
|
1092 * @return {Object} Action object. |
|
1093 */ |
|
1094 |
|
1095 function receiveThemeSupports(themeSupports) { |
|
1096 return { |
|
1097 type: 'RECEIVE_THEME_SUPPORTS', |
|
1098 themeSupports: themeSupports |
|
1099 }; |
|
1100 } |
|
1101 /** |
|
1102 * Returns an action object used in signalling that the preview data for |
|
1103 * a given URl has been received. |
|
1104 * |
|
1105 * @param {string} url URL to preview the embed for. |
|
1106 * @param {Mixed} preview Preview data. |
|
1107 * |
|
1108 * @return {Object} Action object. |
|
1109 */ |
|
1110 |
|
1111 function receiveEmbedPreview(url, preview) { |
|
1112 return { |
|
1113 type: 'RECEIVE_EMBED_PREVIEW', |
|
1114 url: url, |
|
1115 preview: preview |
|
1116 }; |
|
1117 } |
|
1118 /** |
|
1119 * Action triggered to save an entity record. |
|
1120 * |
|
1121 * @param {string} kind Kind of the received entity. |
|
1122 * @param {string} name Name of the received entity. |
|
1123 * @param {Object} record Record to be saved. |
|
1124 * |
|
1125 * @return {Object} Updated record. |
|
1126 */ |
|
1127 |
|
1128 function saveEntityRecord(kind, name, record) { |
|
1129 var entities, entity, key, recordId, updatedRecord; |
|
1130 return regenerator_default.a.wrap(function saveEntityRecord$(_context) { |
|
1131 while (1) { |
|
1132 switch (_context.prev = _context.next) { |
|
1133 case 0: |
|
1134 _context.next = 2; |
|
1135 return getKindEntities(kind); |
|
1136 |
|
1137 case 2: |
|
1138 entities = _context.sent; |
|
1139 entity = Object(external_lodash_["find"])(entities, { |
|
1140 kind: kind, |
|
1141 name: name |
|
1142 }); |
|
1143 |
|
1144 if (entity) { |
|
1145 _context.next = 6; |
|
1146 break; |
|
1147 } |
|
1148 |
|
1149 return _context.abrupt("return"); |
|
1150 |
|
1151 case 6: |
|
1152 key = entity.key || DEFAULT_ENTITY_KEY; |
|
1153 recordId = record[key]; |
|
1154 _context.next = 10; |
|
1155 return apiFetch({ |
|
1156 path: "".concat(entity.baseURL).concat(recordId ? '/' + recordId : ''), |
|
1157 method: recordId ? 'PUT' : 'POST', |
|
1158 data: record |
|
1159 }); |
|
1160 |
|
1161 case 10: |
|
1162 updatedRecord = _context.sent; |
|
1163 _context.next = 13; |
|
1164 return receiveEntityRecords(kind, name, updatedRecord, undefined, true); |
|
1165 |
|
1166 case 13: |
|
1167 return _context.abrupt("return", updatedRecord); |
|
1168 |
|
1169 case 14: |
|
1170 case "end": |
|
1171 return _context.stop(); |
|
1172 } |
|
1173 } |
|
1174 }, _marked, this); |
|
1175 } |
|
1176 /** |
|
1177 * Returns an action object used in signalling that Upload permissions have been received. |
|
1178 * |
|
1179 * @param {boolean} hasUploadPermissions Does the user have permission to upload files? |
|
1180 * |
|
1181 * @return {Object} Action object. |
|
1182 */ |
|
1183 |
|
1184 function receiveUploadPermissions(hasUploadPermissions) { |
|
1185 return { |
|
1186 type: 'RECEIVE_USER_PERMISSION', |
|
1187 key: 'create/media', |
|
1188 isAllowed: hasUploadPermissions |
|
1189 }; |
|
1190 } |
|
1191 /** |
|
1192 * Returns an action object used in signalling that the current user has |
|
1193 * permission to perform an action on a REST resource. |
|
1194 * |
|
1195 * @param {string} key A key that represents the action and REST resource. |
|
1196 * @param {boolean} isAllowed Whether or not the user can perform the action. |
|
1197 * |
|
1198 * @return {Object} Action object. |
|
1199 */ |
|
1200 |
|
1201 function receiveUserPermission(key, isAllowed) { |
|
1202 return { |
|
1203 type: 'RECEIVE_USER_PERMISSION', |
|
1204 key: key, |
|
1205 isAllowed: isAllowed |
|
1206 }; |
|
1207 } |
|
1208 |
|
1209 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entities.js |
|
1210 |
|
1211 |
|
1212 var entities_marked = |
|
1213 /*#__PURE__*/ |
|
1214 regenerator_default.a.mark(loadPostTypeEntities), |
|
1215 _marked2 = |
|
1216 /*#__PURE__*/ |
|
1217 regenerator_default.a.mark(loadTaxonomyEntities), |
|
1218 _marked3 = |
|
1219 /*#__PURE__*/ |
|
1220 regenerator_default.a.mark(getKindEntities); |
|
1221 |
|
1222 /** |
|
1223 * External dependencies |
|
1224 */ |
|
1225 |
|
1226 /** |
|
1227 * Internal dependencies |
|
1228 */ |
|
1229 |
|
1230 |
|
1231 |
|
1232 var DEFAULT_ENTITY_KEY = 'id'; |
|
1233 var defaultEntities = [{ |
|
1234 name: 'postType', |
|
1235 kind: 'root', |
|
1236 key: 'slug', |
|
1237 baseURL: '/wp/v2/types' |
|
1238 }, { |
|
1239 name: 'media', |
|
1240 kind: 'root', |
|
1241 baseURL: '/wp/v2/media', |
|
1242 plural: 'mediaItems' |
|
1243 }, { |
|
1244 name: 'taxonomy', |
|
1245 kind: 'root', |
|
1246 key: 'slug', |
|
1247 baseURL: '/wp/v2/taxonomies', |
|
1248 plural: 'taxonomies' |
|
1249 }]; |
|
1250 var kinds = [{ |
|
1251 name: 'postType', |
|
1252 loadEntities: loadPostTypeEntities |
|
1253 }, { |
|
1254 name: 'taxonomy', |
|
1255 loadEntities: loadTaxonomyEntities |
|
1256 }]; |
|
1257 /** |
|
1258 * Returns the list of post type entities. |
|
1259 * |
|
1260 * @return {Promise} Entities promise |
|
1261 */ |
|
1262 |
|
1263 function loadPostTypeEntities() { |
|
1264 var postTypes; |
|
1265 return regenerator_default.a.wrap(function loadPostTypeEntities$(_context) { |
|
1266 while (1) { |
|
1267 switch (_context.prev = _context.next) { |
|
1268 case 0: |
|
1269 _context.next = 2; |
|
1270 return apiFetch({ |
|
1271 path: '/wp/v2/types?context=edit' |
|
1272 }); |
|
1273 |
|
1274 case 2: |
|
1275 postTypes = _context.sent; |
|
1276 return _context.abrupt("return", Object(external_lodash_["map"])(postTypes, function (postType, name) { |
|
1277 return { |
|
1278 kind: 'postType', |
|
1279 baseURL: '/wp/v2/' + postType.rest_base, |
|
1280 name: name |
|
1281 }; |
|
1282 })); |
|
1283 |
|
1284 case 4: |
|
1285 case "end": |
|
1286 return _context.stop(); |
|
1287 } |
|
1288 } |
|
1289 }, entities_marked, this); |
|
1290 } |
|
1291 /** |
|
1292 * Returns the list of the taxonomies entities. |
|
1293 * |
|
1294 * @return {Promise} Entities promise |
|
1295 */ |
|
1296 |
|
1297 |
|
1298 function loadTaxonomyEntities() { |
|
1299 var taxonomies; |
|
1300 return regenerator_default.a.wrap(function loadTaxonomyEntities$(_context2) { |
|
1301 while (1) { |
|
1302 switch (_context2.prev = _context2.next) { |
|
1303 case 0: |
|
1304 _context2.next = 2; |
|
1305 return apiFetch({ |
|
1306 path: '/wp/v2/taxonomies?context=edit' |
|
1307 }); |
|
1308 |
|
1309 case 2: |
|
1310 taxonomies = _context2.sent; |
|
1311 return _context2.abrupt("return", Object(external_lodash_["map"])(taxonomies, function (taxonomy, name) { |
|
1312 return { |
|
1313 kind: 'taxonomy', |
|
1314 baseURL: '/wp/v2/' + taxonomy.rest_base, |
|
1315 name: name |
|
1316 }; |
|
1317 })); |
|
1318 |
|
1319 case 4: |
|
1320 case "end": |
|
1321 return _context2.stop(); |
|
1322 } |
|
1323 } |
|
1324 }, _marked2, this); |
|
1325 } |
|
1326 /** |
|
1327 * Returns the entity's getter method name given its kind and name. |
|
1328 * |
|
1329 * @param {string} kind Entity kind. |
|
1330 * @param {string} name Entity name. |
|
1331 * @param {string} prefix Function prefix. |
|
1332 * @param {boolean} usePlural Whether to use the plural form or not. |
|
1333 * |
|
1334 * @return {string} Method name |
|
1335 */ |
|
1336 |
|
1337 |
|
1338 var entities_getMethodName = function getMethodName(kind, name) { |
|
1339 var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'get'; |
|
1340 var usePlural = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
|
1341 var entity = Object(external_lodash_["find"])(defaultEntities, { |
|
1342 kind: kind, |
|
1343 name: name |
|
1344 }); |
|
1345 var kindPrefix = kind === 'root' ? '' : Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(kind)); |
|
1346 var nameSuffix = Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(name)) + (usePlural ? 's' : ''); |
|
1347 var suffix = usePlural && entity.plural ? Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(entity.plural)) : nameSuffix; |
|
1348 return "".concat(prefix).concat(kindPrefix).concat(suffix); |
|
1349 }; |
|
1350 /** |
|
1351 * Loads the kind entities into the store. |
|
1352 * |
|
1353 * @param {string} kind Kind |
|
1354 * |
|
1355 * @return {Array} Entities |
|
1356 */ |
|
1357 |
|
1358 function getKindEntities(kind) { |
|
1359 var entities, kindConfig; |
|
1360 return regenerator_default.a.wrap(function getKindEntities$(_context3) { |
|
1361 while (1) { |
|
1362 switch (_context3.prev = _context3.next) { |
|
1363 case 0: |
|
1364 _context3.next = 2; |
|
1365 return controls_select('getEntitiesByKind', kind); |
|
1366 |
|
1367 case 2: |
|
1368 entities = _context3.sent; |
|
1369 |
|
1370 if (!(entities && entities.length !== 0)) { |
|
1371 _context3.next = 5; |
|
1372 break; |
|
1373 } |
|
1374 |
|
1375 return _context3.abrupt("return", entities); |
|
1376 |
|
1377 case 5: |
|
1378 kindConfig = Object(external_lodash_["find"])(kinds, { |
|
1379 name: kind |
|
1380 }); |
|
1381 |
|
1382 if (kindConfig) { |
|
1383 _context3.next = 8; |
|
1384 break; |
|
1385 } |
|
1386 |
|
1387 return _context3.abrupt("return", []); |
|
1388 |
|
1389 case 8: |
|
1390 _context3.next = 10; |
|
1391 return kindConfig.loadEntities(); |
|
1392 |
|
1393 case 10: |
|
1394 entities = _context3.sent; |
|
1395 _context3.next = 13; |
|
1396 return addEntities(entities); |
|
1397 |
|
1398 case 13: |
|
1399 return _context3.abrupt("return", entities); |
|
1400 |
|
1401 case 14: |
|
1402 case "end": |
|
1403 return _context3.stop(); |
|
1404 } |
|
1405 } |
|
1406 }, _marked3, this); |
|
1407 } |
|
1408 |
|
1409 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/reducer.js |
|
1410 |
|
1411 |
|
1412 /** |
|
1413 * External dependencies |
|
1414 */ |
2416 */ |
1415 |
2417 |
1416 |
2418 |
1417 /** |
2419 /** |
1418 * Internal dependencies |
2420 * Internal dependencies |
1888 * |
3309 * |
1889 * @return {Object?} Record. |
3310 * @return {Object?} Record. |
1890 */ |
3311 */ |
1891 |
3312 |
1892 function getEntityRecord(state, kind, name, key) { |
3313 function getEntityRecord(state, kind, name, key) { |
1893 return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'items', key]); |
3314 return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'queriedData', 'items', key]); |
1894 } |
3315 } |
|
3316 /** |
|
3317 * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity from the API if the entity record isn't available in the local state. |
|
3318 * |
|
3319 * @param {Object} state State tree |
|
3320 * @param {string} kind Entity kind. |
|
3321 * @param {string} name Entity name. |
|
3322 * @param {number} key Record's key |
|
3323 * |
|
3324 * @return {Object?} Record. |
|
3325 */ |
|
3326 |
|
3327 function __experimentalGetEntityRecordNoResolver(state, kind, name, key) { |
|
3328 return getEntityRecord(state, kind, name, key); |
|
3329 } |
|
3330 /** |
|
3331 * Returns the entity's record object by key, |
|
3332 * with its attributes mapped to their raw values. |
|
3333 * |
|
3334 * @param {Object} state State tree. |
|
3335 * @param {string} kind Entity kind. |
|
3336 * @param {string} name Entity name. |
|
3337 * @param {number} key Record's key. |
|
3338 * |
|
3339 * @return {Object?} Object with the entity's raw attributes. |
|
3340 */ |
|
3341 |
|
3342 var getRawEntityRecord = Object(rememo["a" /* default */])(function (state, kind, name, key) { |
|
3343 var record = getEntityRecord(state, kind, name, key); |
|
3344 return record && Object.keys(record).reduce(function (accumulator, _key) { |
|
3345 // Because edits are the "raw" attribute values, |
|
3346 // we return those from record selectors to make rendering, |
|
3347 // comparisons, and joins with edits easier. |
|
3348 accumulator[_key] = Object(external_this_lodash_["get"])(record[_key], 'raw', record[_key]); |
|
3349 return accumulator; |
|
3350 }, {}); |
|
3351 }, function (state) { |
|
3352 return [state.entities.data]; |
|
3353 }); |
1895 /** |
3354 /** |
1896 * Returns the Entity's records. |
3355 * Returns the Entity's records. |
1897 * |
3356 * |
1898 * @param {Object} state State tree |
3357 * @param {Object} state State tree |
1899 * @param {string} kind Entity kind. |
3358 * @param {string} kind Entity kind. |
1900 * @param {string} name Entity name. |
3359 * @param {string} name Entity name. |
1901 * @param {?Object} query Optional terms query. |
3360 * @param {?Object} query Optional terms query. |
1902 * |
3361 * |
1903 * @return {Array} Records. |
3362 * @return {?Array} Records. |
1904 */ |
3363 */ |
1905 |
3364 |
1906 function getEntityRecords(state, kind, name, query) { |
3365 function getEntityRecords(state, kind, name, query) { |
1907 var queriedState = Object(external_lodash_["get"])(state.entities.data, [kind, name]); |
3366 var queriedState = Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'queriedData']); |
1908 |
3367 |
1909 if (!queriedState) { |
3368 if (!queriedState) { |
1910 return []; |
3369 return []; |
1911 } |
3370 } |
1912 |
3371 |
1913 return getQueriedItems(queriedState, query); |
3372 return getQueriedItems(queriedState, query); |
1914 } |
3373 } |
1915 /** |
3374 /** |
|
3375 * Returns the list of dirty entity records. |
|
3376 * |
|
3377 * @param {Object} state State tree. |
|
3378 * |
|
3379 * @return {[{ title: string, key: string, name: string, kind: string }]} The list of updated records |
|
3380 */ |
|
3381 |
|
3382 var __experimentalGetDirtyEntityRecords = Object(rememo["a" /* default */])(function (state) { |
|
3383 var data = state.entities.data; |
|
3384 var dirtyRecords = []; |
|
3385 Object.keys(data).forEach(function (kind) { |
|
3386 Object.keys(data[kind]).forEach(function (name) { |
|
3387 var primaryKeys = Object.keys(data[kind][name].edits).filter(function (primaryKey) { |
|
3388 return hasEditsForEntityRecord(state, kind, name, primaryKey); |
|
3389 }); |
|
3390 |
|
3391 if (primaryKeys.length) { |
|
3392 var entity = selectors_getEntity(state, kind, name); |
|
3393 primaryKeys.forEach(function (primaryKey) { |
|
3394 var entityRecord = getEntityRecord(state, kind, name, primaryKey); |
|
3395 dirtyRecords.push({ |
|
3396 // We avoid using primaryKey because it's transformed into a string |
|
3397 // when it's used as an object key. |
|
3398 key: entityRecord[entity.key || DEFAULT_ENTITY_KEY], |
|
3399 title: !entity.getTitle ? '' : entity.getTitle(entityRecord), |
|
3400 name: name, |
|
3401 kind: kind |
|
3402 }); |
|
3403 }); |
|
3404 } |
|
3405 }); |
|
3406 }); |
|
3407 return dirtyRecords; |
|
3408 }, function (state) { |
|
3409 return [state.entities.data]; |
|
3410 }); |
|
3411 /** |
|
3412 * Returns the specified entity record's edits. |
|
3413 * |
|
3414 * @param {Object} state State tree. |
|
3415 * @param {string} kind Entity kind. |
|
3416 * @param {string} name Entity name. |
|
3417 * @param {number} recordId Record ID. |
|
3418 * |
|
3419 * @return {Object?} The entity record's edits. |
|
3420 */ |
|
3421 |
|
3422 function getEntityRecordEdits(state, kind, name, recordId) { |
|
3423 return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'edits', recordId]); |
|
3424 } |
|
3425 /** |
|
3426 * Returns the specified entity record's non transient edits. |
|
3427 * |
|
3428 * Transient edits don't create an undo level, and |
|
3429 * are not considered for change detection. |
|
3430 * They are defined in the entity's config. |
|
3431 * |
|
3432 * @param {Object} state State tree. |
|
3433 * @param {string} kind Entity kind. |
|
3434 * @param {string} name Entity name. |
|
3435 * @param {number} recordId Record ID. |
|
3436 * |
|
3437 * @return {Object?} The entity record's non transient edits. |
|
3438 */ |
|
3439 |
|
3440 var getEntityRecordNonTransientEdits = Object(rememo["a" /* default */])(function (state, kind, name, recordId) { |
|
3441 var _ref = selectors_getEntity(state, kind, name) || {}, |
|
3442 transientEdits = _ref.transientEdits; |
|
3443 |
|
3444 var edits = getEntityRecordEdits(state, kind, name, recordId) || {}; |
|
3445 |
|
3446 if (!transientEdits) { |
|
3447 return edits; |
|
3448 } |
|
3449 |
|
3450 return Object.keys(edits).reduce(function (acc, key) { |
|
3451 if (!transientEdits[key]) { |
|
3452 acc[key] = edits[key]; |
|
3453 } |
|
3454 |
|
3455 return acc; |
|
3456 }, {}); |
|
3457 }, function (state) { |
|
3458 return [state.entities.config, state.entities.data]; |
|
3459 }); |
|
3460 /** |
|
3461 * Returns true if the specified entity record has edits, |
|
3462 * and false otherwise. |
|
3463 * |
|
3464 * @param {Object} state State tree. |
|
3465 * @param {string} kind Entity kind. |
|
3466 * @param {string} name Entity name. |
|
3467 * @param {number} recordId Record ID. |
|
3468 * |
|
3469 * @return {boolean} Whether the entity record has edits or not. |
|
3470 */ |
|
3471 |
|
3472 function hasEditsForEntityRecord(state, kind, name, recordId) { |
|
3473 return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(getEntityRecordNonTransientEdits(state, kind, name, recordId)).length > 0; |
|
3474 } |
|
3475 /** |
|
3476 * Returns the specified entity record, merged with its edits. |
|
3477 * |
|
3478 * @param {Object} state State tree. |
|
3479 * @param {string} kind Entity kind. |
|
3480 * @param {string} name Entity name. |
|
3481 * @param {number} recordId Record ID. |
|
3482 * |
|
3483 * @return {Object?} The entity record, merged with its edits. |
|
3484 */ |
|
3485 |
|
3486 var getEditedEntityRecord = Object(rememo["a" /* default */])(function (state, kind, name, recordId) { |
|
3487 return selectors_objectSpread({}, getRawEntityRecord(state, kind, name, recordId), {}, getEntityRecordEdits(state, kind, name, recordId)); |
|
3488 }, function (state) { |
|
3489 return [state.entities.data]; |
|
3490 }); |
|
3491 /** |
|
3492 * Returns true if the specified entity record is autosaving, and false otherwise. |
|
3493 * |
|
3494 * @param {Object} state State tree. |
|
3495 * @param {string} kind Entity kind. |
|
3496 * @param {string} name Entity name. |
|
3497 * @param {number} recordId Record ID. |
|
3498 * |
|
3499 * @return {boolean} Whether the entity record is autosaving or not. |
|
3500 */ |
|
3501 |
|
3502 function isAutosavingEntityRecord(state, kind, name, recordId) { |
|
3503 var _get = Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId], {}), |
|
3504 pending = _get.pending, |
|
3505 isAutosave = _get.isAutosave; |
|
3506 |
|
3507 return Boolean(pending && isAutosave); |
|
3508 } |
|
3509 /** |
|
3510 * Returns true if the specified entity record is saving, and false otherwise. |
|
3511 * |
|
3512 * @param {Object} state State tree. |
|
3513 * @param {string} kind Entity kind. |
|
3514 * @param {string} name Entity name. |
|
3515 * @param {number} recordId Record ID. |
|
3516 * |
|
3517 * @return {boolean} Whether the entity record is saving or not. |
|
3518 */ |
|
3519 |
|
3520 function isSavingEntityRecord(state, kind, name, recordId) { |
|
3521 return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId, 'pending'], false); |
|
3522 } |
|
3523 /** |
|
3524 * Returns the specified entity record's last save error. |
|
3525 * |
|
3526 * @param {Object} state State tree. |
|
3527 * @param {string} kind Entity kind. |
|
3528 * @param {string} name Entity name. |
|
3529 * @param {number} recordId Record ID. |
|
3530 * |
|
3531 * @return {Object?} The entity record's save error. |
|
3532 */ |
|
3533 |
|
3534 function getLastEntitySaveError(state, kind, name, recordId) { |
|
3535 return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId, 'error']); |
|
3536 } |
|
3537 /** |
|
3538 * Returns the current undo offset for the |
|
3539 * entity records edits history. The offset |
|
3540 * represents how many items from the end |
|
3541 * of the history stack we are at. 0 is the |
|
3542 * last edit, -1 is the second last, and so on. |
|
3543 * |
|
3544 * @param {Object} state State tree. |
|
3545 * |
|
3546 * @return {number} The current undo offset. |
|
3547 */ |
|
3548 |
|
3549 function getCurrentUndoOffset(state) { |
|
3550 return state.undo.offset; |
|
3551 } |
|
3552 /** |
|
3553 * Returns the previous edit from the current undo offset |
|
3554 * for the entity records edits history, if any. |
|
3555 * |
|
3556 * @param {Object} state State tree. |
|
3557 * |
|
3558 * @return {Object?} The edit. |
|
3559 */ |
|
3560 |
|
3561 |
|
3562 function getUndoEdit(state) { |
|
3563 return state.undo[state.undo.length - 2 + getCurrentUndoOffset(state)]; |
|
3564 } |
|
3565 /** |
|
3566 * Returns the next edit from the current undo offset |
|
3567 * for the entity records edits history, if any. |
|
3568 * |
|
3569 * @param {Object} state State tree. |
|
3570 * |
|
3571 * @return {Object?} The edit. |
|
3572 */ |
|
3573 |
|
3574 function getRedoEdit(state) { |
|
3575 return state.undo[state.undo.length + getCurrentUndoOffset(state)]; |
|
3576 } |
|
3577 /** |
|
3578 * Returns true if there is a previous edit from the current undo offset |
|
3579 * for the entity records edits history, and false otherwise. |
|
3580 * |
|
3581 * @param {Object} state State tree. |
|
3582 * |
|
3583 * @return {boolean} Whether there is a previous edit or not. |
|
3584 */ |
|
3585 |
|
3586 function hasUndo(state) { |
|
3587 return Boolean(getUndoEdit(state)); |
|
3588 } |
|
3589 /** |
|
3590 * Returns true if there is a next edit from the current undo offset |
|
3591 * for the entity records edits history, and false otherwise. |
|
3592 * |
|
3593 * @param {Object} state State tree. |
|
3594 * |
|
3595 * @return {boolean} Whether there is a next edit or not. |
|
3596 */ |
|
3597 |
|
3598 function hasRedo(state) { |
|
3599 return Boolean(getRedoEdit(state)); |
|
3600 } |
|
3601 /** |
|
3602 * Return the current theme. |
|
3603 * |
|
3604 * @param {Object} state Data state. |
|
3605 * |
|
3606 * @return {Object} The current theme. |
|
3607 */ |
|
3608 |
|
3609 function getCurrentTheme(state) { |
|
3610 return state.themes[state.currentTheme]; |
|
3611 } |
|
3612 /** |
1916 * Return theme supports data in the index. |
3613 * Return theme supports data in the index. |
1917 * |
3614 * |
1918 * @param {Object} state Data state. |
3615 * @param {Object} state Data state. |
1919 * |
3616 * |
1920 * @return {*} Index data. |
3617 * @return {*} Index data. |
2323 method: id ? 'GET' : 'OPTIONS', |
4230 method: id ? 'GET' : 'OPTIONS', |
2324 parse: false |
4231 parse: false |
2325 }); |
4232 }); |
2326 |
4233 |
2327 case 8: |
4234 case 8: |
2328 response = _context7.sent; |
4235 response = _context9.sent; |
2329 _context7.next = 14; |
4236 _context9.next = 14; |
2330 break; |
4237 break; |
2331 |
4238 |
2332 case 11: |
4239 case 11: |
2333 _context7.prev = 11; |
4240 _context9.prev = 11; |
2334 _context7.t0 = _context7["catch"](5); |
4241 _context9.t0 = _context9["catch"](5); |
2335 return _context7.abrupt("return"); |
4242 return _context9.abrupt("return"); |
2336 |
4243 |
2337 case 14: |
4244 case 14: |
2338 if (Object(external_lodash_["hasIn"])(response, ['headers', 'get'])) { |
4245 if (Object(external_this_lodash_["hasIn"])(response, ['headers', 'get'])) { |
2339 // If the request is fetched using the fetch api, the header can be |
4246 // If the request is fetched using the fetch api, the header can be |
2340 // retrieved using the 'get' method. |
4247 // retrieved using the 'get' method. |
2341 allowHeader = response.headers.get('allow'); |
4248 allowHeader = response.headers.get('allow'); |
2342 } else { |
4249 } else { |
2343 // If the request was preloaded server-side and is returned by the |
4250 // If the request was preloaded server-side and is returned by the |
2344 // preloading middleware, the header will be a simple property. |
4251 // preloading middleware, the header will be a simple property. |
2345 allowHeader = Object(external_lodash_["get"])(response, ['headers', 'Allow'], ''); |
4252 allowHeader = Object(external_this_lodash_["get"])(response, ['headers', 'Allow'], ''); |
2346 } |
4253 } |
2347 |
4254 |
2348 key = Object(external_lodash_["compact"])([action, resource, id]).join('/'); |
4255 key = Object(external_this_lodash_["compact"])([action, resource, id]).join('/'); |
2349 isAllowed = Object(external_lodash_["includes"])(allowHeader, method); |
4256 isAllowed = Object(external_this_lodash_["includes"])(allowHeader, method); |
2350 _context7.next = 19; |
4257 _context9.next = 19; |
2351 return receiveUserPermission(key, isAllowed); |
4258 return receiveUserPermission(key, isAllowed); |
2352 |
4259 |
2353 case 19: |
4260 case 19: |
2354 case "end": |
4261 case "end": |
2355 return _context7.stop(); |
4262 return _context9.stop(); |
2356 } |
4263 } |
2357 } |
4264 } |
2358 }, _marked7, this, [[5, 11]]); |
4265 }, _marked9, null, [[5, 11]]); |
|
4266 } |
|
4267 /** |
|
4268 * Request autosave data from the REST API. |
|
4269 * |
|
4270 * @param {string} postType The type of the parent post. |
|
4271 * @param {number} postId The id of the parent post. |
|
4272 */ |
|
4273 |
|
4274 function resolvers_getAutosaves(postType, postId) { |
|
4275 var _yield$resolveSelect, restBase, autosaves; |
|
4276 |
|
4277 return external_this_regeneratorRuntime_default.a.wrap(function getAutosaves$(_context10) { |
|
4278 while (1) { |
|
4279 switch (_context10.prev = _context10.next) { |
|
4280 case 0: |
|
4281 _context10.next = 2; |
|
4282 return resolveSelect('getPostType', postType); |
|
4283 |
|
4284 case 2: |
|
4285 _yield$resolveSelect = _context10.sent; |
|
4286 restBase = _yield$resolveSelect.rest_base; |
|
4287 _context10.next = 6; |
|
4288 return apiFetch({ |
|
4289 path: "/wp/v2/".concat(restBase, "/").concat(postId, "/autosaves?context=edit") |
|
4290 }); |
|
4291 |
|
4292 case 6: |
|
4293 autosaves = _context10.sent; |
|
4294 |
|
4295 if (!(autosaves && autosaves.length)) { |
|
4296 _context10.next = 10; |
|
4297 break; |
|
4298 } |
|
4299 |
|
4300 _context10.next = 10; |
|
4301 return receiveAutosaves(postId, autosaves); |
|
4302 |
|
4303 case 10: |
|
4304 case "end": |
|
4305 return _context10.stop(); |
|
4306 } |
|
4307 } |
|
4308 }, _marked10); |
|
4309 } |
|
4310 /** |
|
4311 * Request autosave data from the REST API. |
|
4312 * |
|
4313 * This resolver exists to ensure the underlying autosaves are fetched via |
|
4314 * `getAutosaves` when a call to the `getAutosave` selector is made. |
|
4315 * |
|
4316 * @param {string} postType The type of the parent post. |
|
4317 * @param {number} postId The id of the parent post. |
|
4318 */ |
|
4319 |
|
4320 function resolvers_getAutosave(postType, postId) { |
|
4321 return external_this_regeneratorRuntime_default.a.wrap(function getAutosave$(_context11) { |
|
4322 while (1) { |
|
4323 switch (_context11.prev = _context11.next) { |
|
4324 case 0: |
|
4325 _context11.next = 2; |
|
4326 return resolveSelect('getAutosaves', postType, postId); |
|
4327 |
|
4328 case 2: |
|
4329 case "end": |
|
4330 return _context11.stop(); |
|
4331 } |
|
4332 } |
|
4333 }, _marked11); |
|
4334 } |
|
4335 |
|
4336 // EXTERNAL MODULE: external {"this":["wp","element"]} |
|
4337 var external_this_wp_element_ = __webpack_require__(0); |
|
4338 |
|
4339 // EXTERNAL MODULE: external {"this":["wp","blocks"]} |
|
4340 var external_this_wp_blocks_ = __webpack_require__(10); |
|
4341 |
|
4342 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entity-provider.js |
|
4343 |
|
4344 |
|
4345 |
|
4346 |
|
4347 function entity_provider_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
4348 |
|
4349 function entity_provider_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { entity_provider_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { entity_provider_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
4350 |
|
4351 /** |
|
4352 * WordPress dependencies |
|
4353 */ |
|
4354 |
|
4355 |
|
4356 |
|
4357 /** |
|
4358 * Internal dependencies |
|
4359 */ |
|
4360 |
|
4361 |
|
4362 |
|
4363 var entity_provider_entities = entity_provider_objectSpread({}, defaultEntities.reduce(function (acc, entity) { |
|
4364 if (!acc[entity.kind]) { |
|
4365 acc[entity.kind] = {}; |
|
4366 } |
|
4367 |
|
4368 acc[entity.kind][entity.name] = { |
|
4369 context: Object(external_this_wp_element_["createContext"])() |
|
4370 }; |
|
4371 return acc; |
|
4372 }, {}), {}, kinds.reduce(function (acc, kind) { |
|
4373 acc[kind.name] = {}; |
|
4374 return acc; |
|
4375 }, {})); |
|
4376 |
|
4377 var entity_provider_getEntity = function getEntity(kind, type) { |
|
4378 if (!entity_provider_entities[kind]) { |
|
4379 throw new Error("Missing entity config for kind: ".concat(kind, ".")); |
|
4380 } |
|
4381 |
|
4382 if (!entity_provider_entities[kind][type]) { |
|
4383 entity_provider_entities[kind][type] = { |
|
4384 context: Object(external_this_wp_element_["createContext"])() |
|
4385 }; |
|
4386 } |
|
4387 |
|
4388 return entity_provider_entities[kind][type]; |
|
4389 }; |
|
4390 /** |
|
4391 * Context provider component for providing |
|
4392 * an entity for a specific entity type. |
|
4393 * |
|
4394 * @param {Object} props The component's props. |
|
4395 * @param {string} props.kind The entity kind. |
|
4396 * @param {string} props.type The entity type. |
|
4397 * @param {number} props.id The entity ID. |
|
4398 * @param {*} props.children The children to wrap. |
|
4399 * |
|
4400 * @return {Object} The provided children, wrapped with |
|
4401 * the entity's context provider. |
|
4402 */ |
|
4403 |
|
4404 |
|
4405 function EntityProvider(_ref) { |
|
4406 var kind = _ref.kind, |
|
4407 type = _ref.type, |
|
4408 id = _ref.id, |
|
4409 children = _ref.children; |
|
4410 var Provider = entity_provider_getEntity(kind, type).context.Provider; |
|
4411 return Object(external_this_wp_element_["createElement"])(Provider, { |
|
4412 value: id |
|
4413 }, children); |
|
4414 } |
|
4415 /** |
|
4416 * Hook that returns the ID for the nearest |
|
4417 * provided entity of the specified type. |
|
4418 * |
|
4419 * @param {string} kind The entity kind. |
|
4420 * @param {string} type The entity type. |
|
4421 */ |
|
4422 |
|
4423 function useEntityId(kind, type) { |
|
4424 return Object(external_this_wp_element_["useContext"])(entity_provider_getEntity(kind, type).context); |
|
4425 } |
|
4426 /** |
|
4427 * Hook that returns the value and a setter for the |
|
4428 * specified property of the nearest provided |
|
4429 * entity of the specified type. |
|
4430 * |
|
4431 * @param {string} kind The entity kind. |
|
4432 * @param {string} type The entity type. |
|
4433 * @param {string} prop The property name. |
|
4434 * @param {string} [_id] An entity ID to use instead of the context-provided one. |
|
4435 * |
|
4436 * @return {[*, Function]} A tuple where the first item is the |
|
4437 * property value and the second is the |
|
4438 * setter. |
|
4439 */ |
|
4440 |
|
4441 function useEntityProp(kind, type, prop, _id) { |
|
4442 var providerId = useEntityId(kind, type); |
|
4443 var id = _id !== null && _id !== void 0 ? _id : providerId; |
|
4444 |
|
4445 var _useSelect = Object(external_this_wp_data_["useSelect"])(function (select) { |
|
4446 var _select = select('core'), |
|
4447 getEntityRecord = _select.getEntityRecord, |
|
4448 getEditedEntityRecord = _select.getEditedEntityRecord; |
|
4449 |
|
4450 var entity = getEntityRecord(kind, type, id); // Trigger resolver. |
|
4451 |
|
4452 var editedEntity = getEditedEntityRecord(kind, type, id); |
|
4453 return entity && editedEntity ? { |
|
4454 value: editedEntity[prop], |
|
4455 fullValue: entity[prop] |
|
4456 } : {}; |
|
4457 }, [kind, type, id, prop]), |
|
4458 value = _useSelect.value, |
|
4459 fullValue = _useSelect.fullValue; |
|
4460 |
|
4461 var _useDispatch = Object(external_this_wp_data_["useDispatch"])('core'), |
|
4462 editEntityRecord = _useDispatch.editEntityRecord; |
|
4463 |
|
4464 var setValue = Object(external_this_wp_element_["useCallback"])(function (newValue) { |
|
4465 editEntityRecord(kind, type, id, Object(defineProperty["a" /* default */])({}, prop, newValue)); |
|
4466 }, [kind, type, id, prop]); |
|
4467 return [value, setValue, fullValue]; |
|
4468 } |
|
4469 /** |
|
4470 * Hook that returns block content getters and setters for |
|
4471 * the nearest provided entity of the specified type. |
|
4472 * |
|
4473 * The return value has the shape `[ blocks, onInput, onChange ]`. |
|
4474 * `onInput` is for block changes that don't create undo levels |
|
4475 * or dirty the post, non-persistent changes, and `onChange` is for |
|
4476 * peristent changes. They map directly to the props of a |
|
4477 * `BlockEditorProvider` and are intended to be used with it, |
|
4478 * or similar components or hooks. |
|
4479 * |
|
4480 * @param {string} kind The entity kind. |
|
4481 * @param {string} type The entity type. |
|
4482 * @param {Object} options |
|
4483 * @param {Object} [options.initialEdits] Initial edits object for the entity record. |
|
4484 * @param {string} [options.blocksProp='blocks'] The name of the entity prop that holds the blocks array. |
|
4485 * @param {string} [options.contentProp='content'] The name of the entity prop that holds the serialized blocks. |
|
4486 * @param {string} [options.id] An entity ID to use instead of the context-provided one. |
|
4487 * |
|
4488 * @return {[WPBlock[], Function, Function]} The block array and setters. |
|
4489 */ |
|
4490 |
|
4491 function useEntityBlockEditor(kind, type) { |
|
4492 var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, |
|
4493 initialEdits = _ref2.initialEdits, |
|
4494 _ref2$blocksProp = _ref2.blocksProp, |
|
4495 blocksProp = _ref2$blocksProp === void 0 ? 'blocks' : _ref2$blocksProp, |
|
4496 _ref2$contentProp = _ref2.contentProp, |
|
4497 contentProp = _ref2$contentProp === void 0 ? 'content' : _ref2$contentProp, |
|
4498 _id = _ref2.id; |
|
4499 |
|
4500 var providerId = useEntityId(kind, type); |
|
4501 var id = _id !== null && _id !== void 0 ? _id : providerId; |
|
4502 |
|
4503 var _useEntityProp = useEntityProp(kind, type, contentProp, id), |
|
4504 _useEntityProp2 = Object(slicedToArray["a" /* default */])(_useEntityProp, 2), |
|
4505 content = _useEntityProp2[0], |
|
4506 setContent = _useEntityProp2[1]; |
|
4507 |
|
4508 var _useDispatch2 = Object(external_this_wp_data_["useDispatch"])('core'), |
|
4509 editEntityRecord = _useDispatch2.editEntityRecord; |
|
4510 |
|
4511 Object(external_this_wp_element_["useEffect"])(function () { |
|
4512 if (initialEdits) { |
|
4513 editEntityRecord(kind, type, id, initialEdits, { |
|
4514 undoIgnore: true |
|
4515 }); |
|
4516 } |
|
4517 }, [id]); |
|
4518 var initialBlocks = Object(external_this_wp_element_["useMemo"])(function () { |
|
4519 // Guard against other instances that might have |
|
4520 // set content to a function already. |
|
4521 if (content && typeof content !== 'function') { |
|
4522 var parsedContent = Object(external_this_wp_blocks_["parse"])(content); |
|
4523 return parsedContent.length ? parsedContent : []; |
|
4524 } |
|
4525 |
|
4526 return []; |
|
4527 }, [content]); |
|
4528 |
|
4529 var _useEntityProp3 = useEntityProp(kind, type, blocksProp, id), |
|
4530 _useEntityProp4 = Object(slicedToArray["a" /* default */])(_useEntityProp3, 2), |
|
4531 _useEntityProp4$ = _useEntityProp4[0], |
|
4532 blocks = _useEntityProp4$ === void 0 ? initialBlocks : _useEntityProp4$, |
|
4533 onInput = _useEntityProp4[1]; |
|
4534 |
|
4535 var onChange = Object(external_this_wp_element_["useCallback"])(function (nextBlocks) { |
|
4536 onInput(nextBlocks); // Use a function edit to avoid serializing often. |
|
4537 |
|
4538 setContent(function (_ref3) { |
|
4539 var blocksToSerialize = _ref3.blocks; |
|
4540 return Object(external_this_wp_blocks_["serialize"])(blocksToSerialize); |
|
4541 }); |
|
4542 }, [onInput, setContent]); |
|
4543 return [blocks, onInput, onChange]; |
2359 } |
4544 } |
2360 |
4545 |
2361 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js |
4546 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js |
2362 |
4547 |
|
4548 |
|
4549 function build_module_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
4550 |
|
4551 function build_module_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { build_module_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { build_module_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
2363 |
4552 |
2364 /** |
4553 /** |
2365 * WordPress dependencies |
4554 * WordPress dependencies |
2366 */ |
4555 */ |
2367 |
4556 |
2439 return result; |
4628 return result; |
2440 }, {}); |
4629 }, {}); |
2441 Object(external_this_wp_data_["registerStore"])(REDUCER_KEY, { |
4630 Object(external_this_wp_data_["registerStore"])(REDUCER_KEY, { |
2442 reducer: build_module_reducer, |
4631 reducer: build_module_reducer, |
2443 controls: build_module_controls, |
4632 controls: build_module_controls, |
2444 actions: Object(objectSpread["a" /* default */])({}, build_module_actions_namespaceObject, entityActions), |
4633 actions: build_module_objectSpread({}, build_module_actions_namespaceObject, {}, entityActions), |
2445 selectors: Object(objectSpread["a" /* default */])({}, build_module_selectors_namespaceObject, entitySelectors), |
4634 selectors: build_module_objectSpread({}, build_module_selectors_namespaceObject, {}, entitySelectors), |
2446 resolvers: Object(objectSpread["a" /* default */])({}, resolvers_namespaceObject, entityResolvers) |
4635 resolvers: build_module_objectSpread({}, resolvers_namespaceObject, {}, entityResolvers) |
2447 }); |
4636 }); |
2448 |
4637 |
2449 |
4638 |
|
4639 |
|
4640 |
2450 /***/ }), |
4641 /***/ }), |
2451 |
4642 |
2452 /***/ 37: |
4643 /***/ 45: |
|
4644 /***/ (function(module, exports) { |
|
4645 |
|
4646 (function() { module.exports = this["wp"]["apiFetch"]; }()); |
|
4647 |
|
4648 /***/ }), |
|
4649 |
|
4650 /***/ 5: |
2453 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
4651 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
2454 |
4652 |
2455 "use strict"; |
4653 "use strict"; |
2456 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; }); |
4654 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
2457 function _arrayWithHoles(arr) { |
|
2458 if (Array.isArray(arr)) return arr; |
|
2459 } |
|
2460 |
|
2461 /***/ }), |
|
2462 |
|
2463 /***/ 38: |
|
2464 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
2465 |
|
2466 "use strict"; |
|
2467 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; }); |
|
2468 function _nonIterableRest() { |
|
2469 throw new TypeError("Invalid attempt to destructure non-iterable instance"); |
|
2470 } |
|
2471 |
|
2472 /***/ }), |
|
2473 |
|
2474 /***/ 49: |
|
2475 /***/ (function(module, exports) { |
|
2476 |
|
2477 (function() { module.exports = this["wp"]["deprecated"]; }()); |
|
2478 |
|
2479 /***/ }), |
|
2480 |
|
2481 /***/ 5: |
|
2482 /***/ (function(module, exports) { |
|
2483 |
|
2484 (function() { module.exports = this["wp"]["data"]; }()); |
|
2485 |
|
2486 /***/ }), |
|
2487 |
|
2488 /***/ 54: |
|
2489 /***/ (function(module, exports, __webpack_require__) { |
|
2490 |
|
2491 /** |
|
2492 * Copyright (c) 2014-present, Facebook, Inc. |
|
2493 * |
|
2494 * This source code is licensed under the MIT license found in the |
|
2495 * LICENSE file in the root directory of this source tree. |
|
2496 */ |
|
2497 |
|
2498 // This method of obtaining a reference to the global object needs to be |
|
2499 // kept identical to the way it is obtained in runtime.js |
|
2500 var g = (function() { |
|
2501 return this || (typeof self === "object" && self); |
|
2502 })() || Function("return this")(); |
|
2503 |
|
2504 // Use `getOwnPropertyNames` because not all browsers support calling |
|
2505 // `hasOwnProperty` on the global `self` object in a worker. See #183. |
|
2506 var hadRuntime = g.regeneratorRuntime && |
|
2507 Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; |
|
2508 |
|
2509 // Save the old regeneratorRuntime in case it needs to be restored later. |
|
2510 var oldRuntime = hadRuntime && g.regeneratorRuntime; |
|
2511 |
|
2512 // Force reevalutation of runtime.js. |
|
2513 g.regeneratorRuntime = undefined; |
|
2514 |
|
2515 module.exports = __webpack_require__(55); |
|
2516 |
|
2517 if (hadRuntime) { |
|
2518 // Restore the original runtime. |
|
2519 g.regeneratorRuntime = oldRuntime; |
|
2520 } else { |
|
2521 // Remove the global property added by runtime.js. |
|
2522 try { |
|
2523 delete g.regeneratorRuntime; |
|
2524 } catch(e) { |
|
2525 g.regeneratorRuntime = undefined; |
|
2526 } |
|
2527 } |
|
2528 |
|
2529 |
|
2530 /***/ }), |
|
2531 |
|
2532 /***/ 55: |
|
2533 /***/ (function(module, exports) { |
|
2534 |
|
2535 /** |
|
2536 * Copyright (c) 2014-present, Facebook, Inc. |
|
2537 * |
|
2538 * This source code is licensed under the MIT license found in the |
|
2539 * LICENSE file in the root directory of this source tree. |
|
2540 */ |
|
2541 |
|
2542 !(function(global) { |
|
2543 "use strict"; |
|
2544 |
|
2545 var Op = Object.prototype; |
|
2546 var hasOwn = Op.hasOwnProperty; |
|
2547 var undefined; // More compressible than void 0. |
|
2548 var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
|
2549 var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
|
2550 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
|
2551 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
|
2552 |
|
2553 var inModule = typeof module === "object"; |
|
2554 var runtime = global.regeneratorRuntime; |
|
2555 if (runtime) { |
|
2556 if (inModule) { |
|
2557 // If regeneratorRuntime is defined globally and we're in a module, |
|
2558 // make the exports object identical to regeneratorRuntime. |
|
2559 module.exports = runtime; |
|
2560 } |
|
2561 // Don't bother evaluating the rest of this file if the runtime was |
|
2562 // already defined globally. |
|
2563 return; |
|
2564 } |
|
2565 |
|
2566 // Define the runtime globally (as expected by generated code) as either |
|
2567 // module.exports (if we're in a module) or a new, empty object. |
|
2568 runtime = global.regeneratorRuntime = inModule ? module.exports : {}; |
|
2569 |
|
2570 function wrap(innerFn, outerFn, self, tryLocsList) { |
|
2571 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. |
|
2572 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
|
2573 var generator = Object.create(protoGenerator.prototype); |
|
2574 var context = new Context(tryLocsList || []); |
|
2575 |
|
2576 // The ._invoke method unifies the implementations of the .next, |
|
2577 // .throw, and .return methods. |
|
2578 generator._invoke = makeInvokeMethod(innerFn, self, context); |
|
2579 |
|
2580 return generator; |
|
2581 } |
|
2582 runtime.wrap = wrap; |
|
2583 |
|
2584 // Try/catch helper to minimize deoptimizations. Returns a completion |
|
2585 // record like context.tryEntries[i].completion. This interface could |
|
2586 // have been (and was previously) designed to take a closure to be |
|
2587 // invoked without arguments, but in all the cases we care about we |
|
2588 // already have an existing method we want to call, so there's no need |
|
2589 // to create a new function object. We can even get away with assuming |
|
2590 // the method takes exactly one argument, since that happens to be true |
|
2591 // in every case, so we don't have to touch the arguments object. The |
|
2592 // only additional allocation required is the completion record, which |
|
2593 // has a stable shape and so hopefully should be cheap to allocate. |
|
2594 function tryCatch(fn, obj, arg) { |
|
2595 try { |
|
2596 return { type: "normal", arg: fn.call(obj, arg) }; |
|
2597 } catch (err) { |
|
2598 return { type: "throw", arg: err }; |
|
2599 } |
|
2600 } |
|
2601 |
|
2602 var GenStateSuspendedStart = "suspendedStart"; |
|
2603 var GenStateSuspendedYield = "suspendedYield"; |
|
2604 var GenStateExecuting = "executing"; |
|
2605 var GenStateCompleted = "completed"; |
|
2606 |
|
2607 // Returning this object from the innerFn has the same effect as |
|
2608 // breaking out of the dispatch switch statement. |
|
2609 var ContinueSentinel = {}; |
|
2610 |
|
2611 // Dummy constructor functions that we use as the .constructor and |
|
2612 // .constructor.prototype properties for functions that return Generator |
|
2613 // objects. For full spec compliance, you may wish to configure your |
|
2614 // minifier not to mangle the names of these two functions. |
|
2615 function Generator() {} |
|
2616 function GeneratorFunction() {} |
|
2617 function GeneratorFunctionPrototype() {} |
|
2618 |
|
2619 // This is a polyfill for %IteratorPrototype% for environments that |
|
2620 // don't natively support it. |
|
2621 var IteratorPrototype = {}; |
|
2622 IteratorPrototype[iteratorSymbol] = function () { |
|
2623 return this; |
|
2624 }; |
|
2625 |
|
2626 var getProto = Object.getPrototypeOf; |
|
2627 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
|
2628 if (NativeIteratorPrototype && |
|
2629 NativeIteratorPrototype !== Op && |
|
2630 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { |
|
2631 // This environment has a native %IteratorPrototype%; use it instead |
|
2632 // of the polyfill. |
|
2633 IteratorPrototype = NativeIteratorPrototype; |
|
2634 } |
|
2635 |
|
2636 var Gp = GeneratorFunctionPrototype.prototype = |
|
2637 Generator.prototype = Object.create(IteratorPrototype); |
|
2638 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; |
|
2639 GeneratorFunctionPrototype.constructor = GeneratorFunction; |
|
2640 GeneratorFunctionPrototype[toStringTagSymbol] = |
|
2641 GeneratorFunction.displayName = "GeneratorFunction"; |
|
2642 |
|
2643 // Helper for defining the .next, .throw, and .return methods of the |
|
2644 // Iterator interface in terms of a single ._invoke method. |
|
2645 function defineIteratorMethods(prototype) { |
|
2646 ["next", "throw", "return"].forEach(function(method) { |
|
2647 prototype[method] = function(arg) { |
|
2648 return this._invoke(method, arg); |
|
2649 }; |
|
2650 }); |
|
2651 } |
|
2652 |
|
2653 runtime.isGeneratorFunction = function(genFun) { |
|
2654 var ctor = typeof genFun === "function" && genFun.constructor; |
|
2655 return ctor |
|
2656 ? ctor === GeneratorFunction || |
|
2657 // For the native GeneratorFunction constructor, the best we can |
|
2658 // do is to check its .name property. |
|
2659 (ctor.displayName || ctor.name) === "GeneratorFunction" |
|
2660 : false; |
|
2661 }; |
|
2662 |
|
2663 runtime.mark = function(genFun) { |
|
2664 if (Object.setPrototypeOf) { |
|
2665 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
|
2666 } else { |
|
2667 genFun.__proto__ = GeneratorFunctionPrototype; |
|
2668 if (!(toStringTagSymbol in genFun)) { |
|
2669 genFun[toStringTagSymbol] = "GeneratorFunction"; |
|
2670 } |
|
2671 } |
|
2672 genFun.prototype = Object.create(Gp); |
|
2673 return genFun; |
|
2674 }; |
|
2675 |
|
2676 // Within the body of any async function, `await x` is transformed to |
|
2677 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test |
|
2678 // `hasOwn.call(value, "__await")` to determine if the yielded value is |
|
2679 // meant to be awaited. |
|
2680 runtime.awrap = function(arg) { |
|
2681 return { __await: arg }; |
|
2682 }; |
|
2683 |
|
2684 function AsyncIterator(generator) { |
|
2685 function invoke(method, arg, resolve, reject) { |
|
2686 var record = tryCatch(generator[method], generator, arg); |
|
2687 if (record.type === "throw") { |
|
2688 reject(record.arg); |
|
2689 } else { |
|
2690 var result = record.arg; |
|
2691 var value = result.value; |
|
2692 if (value && |
|
2693 typeof value === "object" && |
|
2694 hasOwn.call(value, "__await")) { |
|
2695 return Promise.resolve(value.__await).then(function(value) { |
|
2696 invoke("next", value, resolve, reject); |
|
2697 }, function(err) { |
|
2698 invoke("throw", err, resolve, reject); |
|
2699 }); |
|
2700 } |
|
2701 |
|
2702 return Promise.resolve(value).then(function(unwrapped) { |
|
2703 // When a yielded Promise is resolved, its final value becomes |
|
2704 // the .value of the Promise<{value,done}> result for the |
|
2705 // current iteration. |
|
2706 result.value = unwrapped; |
|
2707 resolve(result); |
|
2708 }, function(error) { |
|
2709 // If a rejected Promise was yielded, throw the rejection back |
|
2710 // into the async generator function so it can be handled there. |
|
2711 return invoke("throw", error, resolve, reject); |
|
2712 }); |
|
2713 } |
|
2714 } |
|
2715 |
|
2716 var previousPromise; |
|
2717 |
|
2718 function enqueue(method, arg) { |
|
2719 function callInvokeWithMethodAndArg() { |
|
2720 return new Promise(function(resolve, reject) { |
|
2721 invoke(method, arg, resolve, reject); |
|
2722 }); |
|
2723 } |
|
2724 |
|
2725 return previousPromise = |
|
2726 // If enqueue has been called before, then we want to wait until |
|
2727 // all previous Promises have been resolved before calling invoke, |
|
2728 // so that results are always delivered in the correct order. If |
|
2729 // enqueue has not been called before, then it is important to |
|
2730 // call invoke immediately, without waiting on a callback to fire, |
|
2731 // so that the async generator function has the opportunity to do |
|
2732 // any necessary setup in a predictable way. This predictability |
|
2733 // is why the Promise constructor synchronously invokes its |
|
2734 // executor callback, and why async functions synchronously |
|
2735 // execute code before the first await. Since we implement simple |
|
2736 // async functions in terms of async generators, it is especially |
|
2737 // important to get this right, even though it requires care. |
|
2738 previousPromise ? previousPromise.then( |
|
2739 callInvokeWithMethodAndArg, |
|
2740 // Avoid propagating failures to Promises returned by later |
|
2741 // invocations of the iterator. |
|
2742 callInvokeWithMethodAndArg |
|
2743 ) : callInvokeWithMethodAndArg(); |
|
2744 } |
|
2745 |
|
2746 // Define the unified helper method that is used to implement .next, |
|
2747 // .throw, and .return (see defineIteratorMethods). |
|
2748 this._invoke = enqueue; |
|
2749 } |
|
2750 |
|
2751 defineIteratorMethods(AsyncIterator.prototype); |
|
2752 AsyncIterator.prototype[asyncIteratorSymbol] = function () { |
|
2753 return this; |
|
2754 }; |
|
2755 runtime.AsyncIterator = AsyncIterator; |
|
2756 |
|
2757 // Note that simple async functions are implemented on top of |
|
2758 // AsyncIterator objects; they just return a Promise for the value of |
|
2759 // the final result produced by the iterator. |
|
2760 runtime.async = function(innerFn, outerFn, self, tryLocsList) { |
|
2761 var iter = new AsyncIterator( |
|
2762 wrap(innerFn, outerFn, self, tryLocsList) |
|
2763 ); |
|
2764 |
|
2765 return runtime.isGeneratorFunction(outerFn) |
|
2766 ? iter // If outerFn is a generator, return the full iterator. |
|
2767 : iter.next().then(function(result) { |
|
2768 return result.done ? result.value : iter.next(); |
|
2769 }); |
|
2770 }; |
|
2771 |
|
2772 function makeInvokeMethod(innerFn, self, context) { |
|
2773 var state = GenStateSuspendedStart; |
|
2774 |
|
2775 return function invoke(method, arg) { |
|
2776 if (state === GenStateExecuting) { |
|
2777 throw new Error("Generator is already running"); |
|
2778 } |
|
2779 |
|
2780 if (state === GenStateCompleted) { |
|
2781 if (method === "throw") { |
|
2782 throw arg; |
|
2783 } |
|
2784 |
|
2785 // Be forgiving, per 25.3.3.3.3 of the spec: |
|
2786 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
|
2787 return doneResult(); |
|
2788 } |
|
2789 |
|
2790 context.method = method; |
|
2791 context.arg = arg; |
|
2792 |
|
2793 while (true) { |
|
2794 var delegate = context.delegate; |
|
2795 if (delegate) { |
|
2796 var delegateResult = maybeInvokeDelegate(delegate, context); |
|
2797 if (delegateResult) { |
|
2798 if (delegateResult === ContinueSentinel) continue; |
|
2799 return delegateResult; |
|
2800 } |
|
2801 } |
|
2802 |
|
2803 if (context.method === "next") { |
|
2804 // Setting context._sent for legacy support of Babel's |
|
2805 // function.sent implementation. |
|
2806 context.sent = context._sent = context.arg; |
|
2807 |
|
2808 } else if (context.method === "throw") { |
|
2809 if (state === GenStateSuspendedStart) { |
|
2810 state = GenStateCompleted; |
|
2811 throw context.arg; |
|
2812 } |
|
2813 |
|
2814 context.dispatchException(context.arg); |
|
2815 |
|
2816 } else if (context.method === "return") { |
|
2817 context.abrupt("return", context.arg); |
|
2818 } |
|
2819 |
|
2820 state = GenStateExecuting; |
|
2821 |
|
2822 var record = tryCatch(innerFn, self, context); |
|
2823 if (record.type === "normal") { |
|
2824 // If an exception is thrown from innerFn, we leave state === |
|
2825 // GenStateExecuting and loop back for another invocation. |
|
2826 state = context.done |
|
2827 ? GenStateCompleted |
|
2828 : GenStateSuspendedYield; |
|
2829 |
|
2830 if (record.arg === ContinueSentinel) { |
|
2831 continue; |
|
2832 } |
|
2833 |
|
2834 return { |
|
2835 value: record.arg, |
|
2836 done: context.done |
|
2837 }; |
|
2838 |
|
2839 } else if (record.type === "throw") { |
|
2840 state = GenStateCompleted; |
|
2841 // Dispatch the exception by looping back around to the |
|
2842 // context.dispatchException(context.arg) call above. |
|
2843 context.method = "throw"; |
|
2844 context.arg = record.arg; |
|
2845 } |
|
2846 } |
|
2847 }; |
|
2848 } |
|
2849 |
|
2850 // Call delegate.iterator[context.method](context.arg) and handle the |
|
2851 // result, either by returning a { value, done } result from the |
|
2852 // delegate iterator, or by modifying context.method and context.arg, |
|
2853 // setting context.delegate to null, and returning the ContinueSentinel. |
|
2854 function maybeInvokeDelegate(delegate, context) { |
|
2855 var method = delegate.iterator[context.method]; |
|
2856 if (method === undefined) { |
|
2857 // A .throw or .return when the delegate iterator has no .throw |
|
2858 // method always terminates the yield* loop. |
|
2859 context.delegate = null; |
|
2860 |
|
2861 if (context.method === "throw") { |
|
2862 if (delegate.iterator.return) { |
|
2863 // If the delegate iterator has a return method, give it a |
|
2864 // chance to clean up. |
|
2865 context.method = "return"; |
|
2866 context.arg = undefined; |
|
2867 maybeInvokeDelegate(delegate, context); |
|
2868 |
|
2869 if (context.method === "throw") { |
|
2870 // If maybeInvokeDelegate(context) changed context.method from |
|
2871 // "return" to "throw", let that override the TypeError below. |
|
2872 return ContinueSentinel; |
|
2873 } |
|
2874 } |
|
2875 |
|
2876 context.method = "throw"; |
|
2877 context.arg = new TypeError( |
|
2878 "The iterator does not provide a 'throw' method"); |
|
2879 } |
|
2880 |
|
2881 return ContinueSentinel; |
|
2882 } |
|
2883 |
|
2884 var record = tryCatch(method, delegate.iterator, context.arg); |
|
2885 |
|
2886 if (record.type === "throw") { |
|
2887 context.method = "throw"; |
|
2888 context.arg = record.arg; |
|
2889 context.delegate = null; |
|
2890 return ContinueSentinel; |
|
2891 } |
|
2892 |
|
2893 var info = record.arg; |
|
2894 |
|
2895 if (! info) { |
|
2896 context.method = "throw"; |
|
2897 context.arg = new TypeError("iterator result is not an object"); |
|
2898 context.delegate = null; |
|
2899 return ContinueSentinel; |
|
2900 } |
|
2901 |
|
2902 if (info.done) { |
|
2903 // Assign the result of the finished delegate to the temporary |
|
2904 // variable specified by delegate.resultName (see delegateYield). |
|
2905 context[delegate.resultName] = info.value; |
|
2906 |
|
2907 // Resume execution at the desired location (see delegateYield). |
|
2908 context.next = delegate.nextLoc; |
|
2909 |
|
2910 // If context.method was "throw" but the delegate handled the |
|
2911 // exception, let the outer generator proceed normally. If |
|
2912 // context.method was "next", forget context.arg since it has been |
|
2913 // "consumed" by the delegate iterator. If context.method was |
|
2914 // "return", allow the original .return call to continue in the |
|
2915 // outer generator. |
|
2916 if (context.method !== "return") { |
|
2917 context.method = "next"; |
|
2918 context.arg = undefined; |
|
2919 } |
|
2920 |
|
2921 } else { |
|
2922 // Re-yield the result returned by the delegate method. |
|
2923 return info; |
|
2924 } |
|
2925 |
|
2926 // The delegate iterator is finished, so forget it and continue with |
|
2927 // the outer generator. |
|
2928 context.delegate = null; |
|
2929 return ContinueSentinel; |
|
2930 } |
|
2931 |
|
2932 // Define Generator.prototype.{next,throw,return} in terms of the |
|
2933 // unified ._invoke helper method. |
|
2934 defineIteratorMethods(Gp); |
|
2935 |
|
2936 Gp[toStringTagSymbol] = "Generator"; |
|
2937 |
|
2938 // A Generator should always return itself as the iterator object when the |
|
2939 // @@iterator function is called on it. Some browsers' implementations of the |
|
2940 // iterator prototype chain incorrectly implement this, causing the Generator |
|
2941 // object to not be returned from this call. This ensures that doesn't happen. |
|
2942 // See https://github.com/facebook/regenerator/issues/274 for more details. |
|
2943 Gp[iteratorSymbol] = function() { |
|
2944 return this; |
|
2945 }; |
|
2946 |
|
2947 Gp.toString = function() { |
|
2948 return "[object Generator]"; |
|
2949 }; |
|
2950 |
|
2951 function pushTryEntry(locs) { |
|
2952 var entry = { tryLoc: locs[0] }; |
|
2953 |
|
2954 if (1 in locs) { |
|
2955 entry.catchLoc = locs[1]; |
|
2956 } |
|
2957 |
|
2958 if (2 in locs) { |
|
2959 entry.finallyLoc = locs[2]; |
|
2960 entry.afterLoc = locs[3]; |
|
2961 } |
|
2962 |
|
2963 this.tryEntries.push(entry); |
|
2964 } |
|
2965 |
|
2966 function resetTryEntry(entry) { |
|
2967 var record = entry.completion || {}; |
|
2968 record.type = "normal"; |
|
2969 delete record.arg; |
|
2970 entry.completion = record; |
|
2971 } |
|
2972 |
|
2973 function Context(tryLocsList) { |
|
2974 // The root entry object (effectively a try statement without a catch |
|
2975 // or a finally block) gives us a place to store values thrown from |
|
2976 // locations where there is no enclosing try statement. |
|
2977 this.tryEntries = [{ tryLoc: "root" }]; |
|
2978 tryLocsList.forEach(pushTryEntry, this); |
|
2979 this.reset(true); |
|
2980 } |
|
2981 |
|
2982 runtime.keys = function(object) { |
|
2983 var keys = []; |
|
2984 for (var key in object) { |
|
2985 keys.push(key); |
|
2986 } |
|
2987 keys.reverse(); |
|
2988 |
|
2989 // Rather than returning an object with a next method, we keep |
|
2990 // things simple and return the next function itself. |
|
2991 return function next() { |
|
2992 while (keys.length) { |
|
2993 var key = keys.pop(); |
|
2994 if (key in object) { |
|
2995 next.value = key; |
|
2996 next.done = false; |
|
2997 return next; |
|
2998 } |
|
2999 } |
|
3000 |
|
3001 // To avoid creating an additional object, we just hang the .value |
|
3002 // and .done properties off the next function object itself. This |
|
3003 // also ensures that the minifier will not anonymize the function. |
|
3004 next.done = true; |
|
3005 return next; |
|
3006 }; |
|
3007 }; |
|
3008 |
|
3009 function values(iterable) { |
|
3010 if (iterable) { |
|
3011 var iteratorMethod = iterable[iteratorSymbol]; |
|
3012 if (iteratorMethod) { |
|
3013 return iteratorMethod.call(iterable); |
|
3014 } |
|
3015 |
|
3016 if (typeof iterable.next === "function") { |
|
3017 return iterable; |
|
3018 } |
|
3019 |
|
3020 if (!isNaN(iterable.length)) { |
|
3021 var i = -1, next = function next() { |
|
3022 while (++i < iterable.length) { |
|
3023 if (hasOwn.call(iterable, i)) { |
|
3024 next.value = iterable[i]; |
|
3025 next.done = false; |
|
3026 return next; |
|
3027 } |
|
3028 } |
|
3029 |
|
3030 next.value = undefined; |
|
3031 next.done = true; |
|
3032 |
|
3033 return next; |
|
3034 }; |
|
3035 |
|
3036 return next.next = next; |
|
3037 } |
|
3038 } |
|
3039 |
|
3040 // Return an iterator with no values. |
|
3041 return { next: doneResult }; |
|
3042 } |
|
3043 runtime.values = values; |
|
3044 |
|
3045 function doneResult() { |
|
3046 return { value: undefined, done: true }; |
|
3047 } |
|
3048 |
|
3049 Context.prototype = { |
|
3050 constructor: Context, |
|
3051 |
|
3052 reset: function(skipTempReset) { |
|
3053 this.prev = 0; |
|
3054 this.next = 0; |
|
3055 // Resetting context._sent for legacy support of Babel's |
|
3056 // function.sent implementation. |
|
3057 this.sent = this._sent = undefined; |
|
3058 this.done = false; |
|
3059 this.delegate = null; |
|
3060 |
|
3061 this.method = "next"; |
|
3062 this.arg = undefined; |
|
3063 |
|
3064 this.tryEntries.forEach(resetTryEntry); |
|
3065 |
|
3066 if (!skipTempReset) { |
|
3067 for (var name in this) { |
|
3068 // Not sure about the optimal order of these conditions: |
|
3069 if (name.charAt(0) === "t" && |
|
3070 hasOwn.call(this, name) && |
|
3071 !isNaN(+name.slice(1))) { |
|
3072 this[name] = undefined; |
|
3073 } |
|
3074 } |
|
3075 } |
|
3076 }, |
|
3077 |
|
3078 stop: function() { |
|
3079 this.done = true; |
|
3080 |
|
3081 var rootEntry = this.tryEntries[0]; |
|
3082 var rootRecord = rootEntry.completion; |
|
3083 if (rootRecord.type === "throw") { |
|
3084 throw rootRecord.arg; |
|
3085 } |
|
3086 |
|
3087 return this.rval; |
|
3088 }, |
|
3089 |
|
3090 dispatchException: function(exception) { |
|
3091 if (this.done) { |
|
3092 throw exception; |
|
3093 } |
|
3094 |
|
3095 var context = this; |
|
3096 function handle(loc, caught) { |
|
3097 record.type = "throw"; |
|
3098 record.arg = exception; |
|
3099 context.next = loc; |
|
3100 |
|
3101 if (caught) { |
|
3102 // If the dispatched exception was caught by a catch block, |
|
3103 // then let that catch block handle the exception normally. |
|
3104 context.method = "next"; |
|
3105 context.arg = undefined; |
|
3106 } |
|
3107 |
|
3108 return !! caught; |
|
3109 } |
|
3110 |
|
3111 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
3112 var entry = this.tryEntries[i]; |
|
3113 var record = entry.completion; |
|
3114 |
|
3115 if (entry.tryLoc === "root") { |
|
3116 // Exception thrown outside of any try block that could handle |
|
3117 // it, so set the completion value of the entire function to |
|
3118 // throw the exception. |
|
3119 return handle("end"); |
|
3120 } |
|
3121 |
|
3122 if (entry.tryLoc <= this.prev) { |
|
3123 var hasCatch = hasOwn.call(entry, "catchLoc"); |
|
3124 var hasFinally = hasOwn.call(entry, "finallyLoc"); |
|
3125 |
|
3126 if (hasCatch && hasFinally) { |
|
3127 if (this.prev < entry.catchLoc) { |
|
3128 return handle(entry.catchLoc, true); |
|
3129 } else if (this.prev < entry.finallyLoc) { |
|
3130 return handle(entry.finallyLoc); |
|
3131 } |
|
3132 |
|
3133 } else if (hasCatch) { |
|
3134 if (this.prev < entry.catchLoc) { |
|
3135 return handle(entry.catchLoc, true); |
|
3136 } |
|
3137 |
|
3138 } else if (hasFinally) { |
|
3139 if (this.prev < entry.finallyLoc) { |
|
3140 return handle(entry.finallyLoc); |
|
3141 } |
|
3142 |
|
3143 } else { |
|
3144 throw new Error("try statement without catch or finally"); |
|
3145 } |
|
3146 } |
|
3147 } |
|
3148 }, |
|
3149 |
|
3150 abrupt: function(type, arg) { |
|
3151 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
3152 var entry = this.tryEntries[i]; |
|
3153 if (entry.tryLoc <= this.prev && |
|
3154 hasOwn.call(entry, "finallyLoc") && |
|
3155 this.prev < entry.finallyLoc) { |
|
3156 var finallyEntry = entry; |
|
3157 break; |
|
3158 } |
|
3159 } |
|
3160 |
|
3161 if (finallyEntry && |
|
3162 (type === "break" || |
|
3163 type === "continue") && |
|
3164 finallyEntry.tryLoc <= arg && |
|
3165 arg <= finallyEntry.finallyLoc) { |
|
3166 // Ignore the finally entry if control is not jumping to a |
|
3167 // location outside the try/catch block. |
|
3168 finallyEntry = null; |
|
3169 } |
|
3170 |
|
3171 var record = finallyEntry ? finallyEntry.completion : {}; |
|
3172 record.type = type; |
|
3173 record.arg = arg; |
|
3174 |
|
3175 if (finallyEntry) { |
|
3176 this.method = "next"; |
|
3177 this.next = finallyEntry.finallyLoc; |
|
3178 return ContinueSentinel; |
|
3179 } |
|
3180 |
|
3181 return this.complete(record); |
|
3182 }, |
|
3183 |
|
3184 complete: function(record, afterLoc) { |
|
3185 if (record.type === "throw") { |
|
3186 throw record.arg; |
|
3187 } |
|
3188 |
|
3189 if (record.type === "break" || |
|
3190 record.type === "continue") { |
|
3191 this.next = record.arg; |
|
3192 } else if (record.type === "return") { |
|
3193 this.rval = this.arg = record.arg; |
|
3194 this.method = "return"; |
|
3195 this.next = "end"; |
|
3196 } else if (record.type === "normal" && afterLoc) { |
|
3197 this.next = afterLoc; |
|
3198 } |
|
3199 |
|
3200 return ContinueSentinel; |
|
3201 }, |
|
3202 |
|
3203 finish: function(finallyLoc) { |
|
3204 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
3205 var entry = this.tryEntries[i]; |
|
3206 if (entry.finallyLoc === finallyLoc) { |
|
3207 this.complete(entry.completion, entry.afterLoc); |
|
3208 resetTryEntry(entry); |
|
3209 return ContinueSentinel; |
|
3210 } |
|
3211 } |
|
3212 }, |
|
3213 |
|
3214 "catch": function(tryLoc) { |
|
3215 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
3216 var entry = this.tryEntries[i]; |
|
3217 if (entry.tryLoc === tryLoc) { |
|
3218 var record = entry.completion; |
|
3219 if (record.type === "throw") { |
|
3220 var thrown = record.arg; |
|
3221 resetTryEntry(entry); |
|
3222 } |
|
3223 return thrown; |
|
3224 } |
|
3225 } |
|
3226 |
|
3227 // The context.catch method must only be called with a location |
|
3228 // argument that corresponds to a known catch block. |
|
3229 throw new Error("illegal catch attempt"); |
|
3230 }, |
|
3231 |
|
3232 delegateYield: function(iterable, resultName, nextLoc) { |
|
3233 this.delegate = { |
|
3234 iterator: values(iterable), |
|
3235 resultName: resultName, |
|
3236 nextLoc: nextLoc |
|
3237 }; |
|
3238 |
|
3239 if (this.method === "next") { |
|
3240 // Deliberately forget the last sent value so that we don't |
|
3241 // accidentally pass it on to the delegate. |
|
3242 this.arg = undefined; |
|
3243 } |
|
3244 |
|
3245 return ContinueSentinel; |
|
3246 } |
|
3247 }; |
|
3248 })( |
|
3249 // In sloppy mode, unbound `this` refers to the global object, fallback to |
|
3250 // Function constructor if we're in global strict mode. That is sadly a form |
|
3251 // of indirect eval which violates Content Security Policy. |
|
3252 (function() { |
|
3253 return this || (typeof self === "object" && self); |
|
3254 })() || Function("return this")() |
|
3255 ); |
|
3256 |
|
3257 |
|
3258 /***/ }), |
|
3259 |
|
3260 /***/ 59: |
|
3261 /***/ (function(module, exports) { |
|
3262 |
|
3263 var g; |
|
3264 |
|
3265 // This works in non-strict mode |
|
3266 g = (function() { |
|
3267 return this; |
|
3268 })(); |
|
3269 |
|
3270 try { |
|
3271 // This works if eval is allowed (see CSP) |
|
3272 g = g || new Function("return this")(); |
|
3273 } catch (e) { |
|
3274 // This works if the window reference is available |
|
3275 if (typeof window === "object") g = window; |
|
3276 } |
|
3277 |
|
3278 // g can still be undefined, but nothing to do about it... |
|
3279 // We return undefined, instead of nothing here, so it's |
|
3280 // easier to handle this case. if(!global) { ...} |
|
3281 |
|
3282 module.exports = g; |
|
3283 |
|
3284 |
|
3285 /***/ }), |
|
3286 |
|
3287 /***/ 7: |
|
3288 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3289 |
|
3290 "use strict"; |
|
3291 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; }); |
|
3292 /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); |
|
3293 |
|
3294 function _objectSpread(target) { |
|
3295 for (var i = 1; i < arguments.length; i++) { |
|
3296 var source = arguments[i] != null ? arguments[i] : {}; |
|
3297 var ownKeys = Object.keys(source); |
|
3298 |
|
3299 if (typeof Object.getOwnPropertySymbols === 'function') { |
|
3300 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { |
|
3301 return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
|
3302 })); |
|
3303 } |
|
3304 |
|
3305 ownKeys.forEach(function (key) { |
|
3306 Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]); |
|
3307 }); |
|
3308 } |
|
3309 |
|
3310 return target; |
|
3311 } |
|
3312 |
|
3313 /***/ }), |
|
3314 |
|
3315 /***/ 71: |
|
3316 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3317 |
|
3318 "use strict"; |
|
3319 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return createStore; }); |
|
3320 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return combineReducers; }); |
|
3321 /* unused harmony export bindActionCreators */ |
|
3322 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return applyMiddleware; }); |
|
3323 /* unused harmony export compose */ |
|
3324 /* unused harmony export __DO_NOT_USE__ActionTypes */ |
|
3325 /* harmony import */ var symbol_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77); |
|
3326 |
|
3327 |
|
3328 /** |
|
3329 * These are private action types reserved by Redux. |
|
3330 * For any unknown actions, you must return the current state. |
|
3331 * If the current state is undefined, you must return the initial state. |
|
3332 * Do not reference these action types directly in your code. |
|
3333 */ |
|
3334 var randomString = function randomString() { |
|
3335 return Math.random().toString(36).substring(7).split('').join('.'); |
|
3336 }; |
|
3337 |
|
3338 var ActionTypes = { |
|
3339 INIT: "@@redux/INIT" + randomString(), |
|
3340 REPLACE: "@@redux/REPLACE" + randomString(), |
|
3341 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() { |
|
3342 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString(); |
|
3343 } |
|
3344 }; |
|
3345 |
|
3346 /** |
|
3347 * @param {any} obj The object to inspect. |
|
3348 * @returns {boolean} True if the argument appears to be a plain object. |
|
3349 */ |
|
3350 function isPlainObject(obj) { |
|
3351 if (typeof obj !== 'object' || obj === null) return false; |
|
3352 var proto = obj; |
|
3353 |
|
3354 while (Object.getPrototypeOf(proto) !== null) { |
|
3355 proto = Object.getPrototypeOf(proto); |
|
3356 } |
|
3357 |
|
3358 return Object.getPrototypeOf(obj) === proto; |
|
3359 } |
|
3360 |
|
3361 /** |
|
3362 * Creates a Redux store that holds the state tree. |
|
3363 * The only way to change the data in the store is to call `dispatch()` on it. |
|
3364 * |
|
3365 * There should only be a single store in your app. To specify how different |
|
3366 * parts of the state tree respond to actions, you may combine several reducers |
|
3367 * into a single reducer function by using `combineReducers`. |
|
3368 * |
|
3369 * @param {Function} reducer A function that returns the next state tree, given |
|
3370 * the current state tree and the action to handle. |
|
3371 * |
|
3372 * @param {any} [preloadedState] The initial state. You may optionally specify it |
|
3373 * to hydrate the state from the server in universal apps, or to restore a |
|
3374 * previously serialized user session. |
|
3375 * If you use `combineReducers` to produce the root reducer function, this must be |
|
3376 * an object with the same shape as `combineReducers` keys. |
|
3377 * |
|
3378 * @param {Function} [enhancer] The store enhancer. You may optionally specify it |
|
3379 * to enhance the store with third-party capabilities such as middleware, |
|
3380 * time travel, persistence, etc. The only store enhancer that ships with Redux |
|
3381 * is `applyMiddleware()`. |
|
3382 * |
|
3383 * @returns {Store} A Redux store that lets you read the state, dispatch actions |
|
3384 * and subscribe to changes. |
|
3385 */ |
|
3386 |
|
3387 function createStore(reducer, preloadedState, enhancer) { |
|
3388 var _ref2; |
|
3389 |
|
3390 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') { |
|
3391 throw new Error('It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function'); |
|
3392 } |
|
3393 |
|
3394 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { |
|
3395 enhancer = preloadedState; |
|
3396 preloadedState = undefined; |
|
3397 } |
|
3398 |
|
3399 if (typeof enhancer !== 'undefined') { |
|
3400 if (typeof enhancer !== 'function') { |
|
3401 throw new Error('Expected the enhancer to be a function.'); |
|
3402 } |
|
3403 |
|
3404 return enhancer(createStore)(reducer, preloadedState); |
|
3405 } |
|
3406 |
|
3407 if (typeof reducer !== 'function') { |
|
3408 throw new Error('Expected the reducer to be a function.'); |
|
3409 } |
|
3410 |
|
3411 var currentReducer = reducer; |
|
3412 var currentState = preloadedState; |
|
3413 var currentListeners = []; |
|
3414 var nextListeners = currentListeners; |
|
3415 var isDispatching = false; |
|
3416 |
|
3417 function ensureCanMutateNextListeners() { |
|
3418 if (nextListeners === currentListeners) { |
|
3419 nextListeners = currentListeners.slice(); |
|
3420 } |
|
3421 } |
|
3422 /** |
|
3423 * Reads the state tree managed by the store. |
|
3424 * |
|
3425 * @returns {any} The current state tree of your application. |
|
3426 */ |
|
3427 |
|
3428 |
|
3429 function getState() { |
|
3430 if (isDispatching) { |
|
3431 throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.'); |
|
3432 } |
|
3433 |
|
3434 return currentState; |
|
3435 } |
|
3436 /** |
|
3437 * Adds a change listener. It will be called any time an action is dispatched, |
|
3438 * and some part of the state tree may potentially have changed. You may then |
|
3439 * call `getState()` to read the current state tree inside the callback. |
|
3440 * |
|
3441 * You may call `dispatch()` from a change listener, with the following |
|
3442 * caveats: |
|
3443 * |
|
3444 * 1. The subscriptions are snapshotted just before every `dispatch()` call. |
|
3445 * If you subscribe or unsubscribe while the listeners are being invoked, this |
|
3446 * will not have any effect on the `dispatch()` that is currently in progress. |
|
3447 * However, the next `dispatch()` call, whether nested or not, will use a more |
|
3448 * recent snapshot of the subscription list. |
|
3449 * |
|
3450 * 2. The listener should not expect to see all state changes, as the state |
|
3451 * might have been updated multiple times during a nested `dispatch()` before |
|
3452 * the listener is called. It is, however, guaranteed that all subscribers |
|
3453 * registered before the `dispatch()` started will be called with the latest |
|
3454 * state by the time it exits. |
|
3455 * |
|
3456 * @param {Function} listener A callback to be invoked on every dispatch. |
|
3457 * @returns {Function} A function to remove this change listener. |
|
3458 */ |
|
3459 |
|
3460 |
|
3461 function subscribe(listener) { |
|
3462 if (typeof listener !== 'function') { |
|
3463 throw new Error('Expected the listener to be a function.'); |
|
3464 } |
|
3465 |
|
3466 if (isDispatching) { |
|
3467 throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api-reference/store#subscribe(listener) for more details.'); |
|
3468 } |
|
3469 |
|
3470 var isSubscribed = true; |
|
3471 ensureCanMutateNextListeners(); |
|
3472 nextListeners.push(listener); |
|
3473 return function unsubscribe() { |
|
3474 if (!isSubscribed) { |
|
3475 return; |
|
3476 } |
|
3477 |
|
3478 if (isDispatching) { |
|
3479 throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api-reference/store#subscribe(listener) for more details.'); |
|
3480 } |
|
3481 |
|
3482 isSubscribed = false; |
|
3483 ensureCanMutateNextListeners(); |
|
3484 var index = nextListeners.indexOf(listener); |
|
3485 nextListeners.splice(index, 1); |
|
3486 }; |
|
3487 } |
|
3488 /** |
|
3489 * Dispatches an action. It is the only way to trigger a state change. |
|
3490 * |
|
3491 * The `reducer` function, used to create the store, will be called with the |
|
3492 * current state tree and the given `action`. Its return value will |
|
3493 * be considered the **next** state of the tree, and the change listeners |
|
3494 * will be notified. |
|
3495 * |
|
3496 * The base implementation only supports plain object actions. If you want to |
|
3497 * dispatch a Promise, an Observable, a thunk, or something else, you need to |
|
3498 * wrap your store creating function into the corresponding middleware. For |
|
3499 * example, see the documentation for the `redux-thunk` package. Even the |
|
3500 * middleware will eventually dispatch plain object actions using this method. |
|
3501 * |
|
3502 * @param {Object} action A plain object representing “what changed”. It is |
|
3503 * a good idea to keep actions serializable so you can record and replay user |
|
3504 * sessions, or use the time travelling `redux-devtools`. An action must have |
|
3505 * a `type` property which may not be `undefined`. It is a good idea to use |
|
3506 * string constants for action types. |
|
3507 * |
|
3508 * @returns {Object} For convenience, the same action object you dispatched. |
|
3509 * |
|
3510 * Note that, if you use a custom middleware, it may wrap `dispatch()` to |
|
3511 * return something else (for example, a Promise you can await). |
|
3512 */ |
|
3513 |
|
3514 |
|
3515 function dispatch(action) { |
|
3516 if (!isPlainObject(action)) { |
|
3517 throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.'); |
|
3518 } |
|
3519 |
|
3520 if (typeof action.type === 'undefined') { |
|
3521 throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?'); |
|
3522 } |
|
3523 |
|
3524 if (isDispatching) { |
|
3525 throw new Error('Reducers may not dispatch actions.'); |
|
3526 } |
|
3527 |
|
3528 try { |
|
3529 isDispatching = true; |
|
3530 currentState = currentReducer(currentState, action); |
|
3531 } finally { |
|
3532 isDispatching = false; |
|
3533 } |
|
3534 |
|
3535 var listeners = currentListeners = nextListeners; |
|
3536 |
|
3537 for (var i = 0; i < listeners.length; i++) { |
|
3538 var listener = listeners[i]; |
|
3539 listener(); |
|
3540 } |
|
3541 |
|
3542 return action; |
|
3543 } |
|
3544 /** |
|
3545 * Replaces the reducer currently used by the store to calculate the state. |
|
3546 * |
|
3547 * You might need this if your app implements code splitting and you want to |
|
3548 * load some of the reducers dynamically. You might also need this if you |
|
3549 * implement a hot reloading mechanism for Redux. |
|
3550 * |
|
3551 * @param {Function} nextReducer The reducer for the store to use instead. |
|
3552 * @returns {void} |
|
3553 */ |
|
3554 |
|
3555 |
|
3556 function replaceReducer(nextReducer) { |
|
3557 if (typeof nextReducer !== 'function') { |
|
3558 throw new Error('Expected the nextReducer to be a function.'); |
|
3559 } |
|
3560 |
|
3561 currentReducer = nextReducer; |
|
3562 dispatch({ |
|
3563 type: ActionTypes.REPLACE |
|
3564 }); |
|
3565 } |
|
3566 /** |
|
3567 * Interoperability point for observable/reactive libraries. |
|
3568 * @returns {observable} A minimal observable of state changes. |
|
3569 * For more information, see the observable proposal: |
|
3570 * https://github.com/tc39/proposal-observable |
|
3571 */ |
|
3572 |
|
3573 |
|
3574 function observable() { |
|
3575 var _ref; |
|
3576 |
|
3577 var outerSubscribe = subscribe; |
|
3578 return _ref = { |
|
3579 /** |
|
3580 * The minimal observable subscription method. |
|
3581 * @param {Object} observer Any object that can be used as an observer. |
|
3582 * The observer object should have a `next` method. |
|
3583 * @returns {subscription} An object with an `unsubscribe` method that can |
|
3584 * be used to unsubscribe the observable from the store, and prevent further |
|
3585 * emission of values from the observable. |
|
3586 */ |
|
3587 subscribe: function subscribe(observer) { |
|
3588 if (typeof observer !== 'object' || observer === null) { |
|
3589 throw new TypeError('Expected the observer to be an object.'); |
|
3590 } |
|
3591 |
|
3592 function observeState() { |
|
3593 if (observer.next) { |
|
3594 observer.next(getState()); |
|
3595 } |
|
3596 } |
|
3597 |
|
3598 observeState(); |
|
3599 var unsubscribe = outerSubscribe(observeState); |
|
3600 return { |
|
3601 unsubscribe: unsubscribe |
|
3602 }; |
|
3603 } |
|
3604 }, _ref[symbol_observable__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]] = function () { |
|
3605 return this; |
|
3606 }, _ref; |
|
3607 } // When a store is created, an "INIT" action is dispatched so that every |
|
3608 // reducer returns their initial state. This effectively populates |
|
3609 // the initial state tree. |
|
3610 |
|
3611 |
|
3612 dispatch({ |
|
3613 type: ActionTypes.INIT |
|
3614 }); |
|
3615 return _ref2 = { |
|
3616 dispatch: dispatch, |
|
3617 subscribe: subscribe, |
|
3618 getState: getState, |
|
3619 replaceReducer: replaceReducer |
|
3620 }, _ref2[symbol_observable__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]] = observable, _ref2; |
|
3621 } |
|
3622 |
|
3623 /** |
|
3624 * Prints a warning in the console if it exists. |
|
3625 * |
|
3626 * @param {String} message The warning message. |
|
3627 * @returns {void} |
|
3628 */ |
|
3629 function warning(message) { |
|
3630 /* eslint-disable no-console */ |
|
3631 if (typeof console !== 'undefined' && typeof console.error === 'function') { |
|
3632 console.error(message); |
|
3633 } |
|
3634 /* eslint-enable no-console */ |
|
3635 |
|
3636 |
|
3637 try { |
|
3638 // This error was thrown as a convenience so that if you enable |
|
3639 // "break on all exceptions" in your console, |
|
3640 // it would pause the execution at this line. |
|
3641 throw new Error(message); |
|
3642 } catch (e) {} // eslint-disable-line no-empty |
|
3643 |
|
3644 } |
|
3645 |
|
3646 function getUndefinedStateErrorMessage(key, action) { |
|
3647 var actionType = action && action.type; |
|
3648 var actionDescription = actionType && "action \"" + String(actionType) + "\"" || 'an action'; |
|
3649 return "Given " + actionDescription + ", reducer \"" + key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined."; |
|
3650 } |
|
3651 |
|
3652 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { |
|
3653 var reducerKeys = Object.keys(reducers); |
|
3654 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer'; |
|
3655 |
|
3656 if (reducerKeys.length === 0) { |
|
3657 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'; |
|
3658 } |
|
3659 |
|
3660 if (!isPlainObject(inputState)) { |
|
3661 return "The " + argumentName + " has unexpected type of \"" + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\""); |
|
3662 } |
|
3663 |
|
3664 var unexpectedKeys = Object.keys(inputState).filter(function (key) { |
|
3665 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]; |
|
3666 }); |
|
3667 unexpectedKeys.forEach(function (key) { |
|
3668 unexpectedKeyCache[key] = true; |
|
3669 }); |
|
3670 if (action && action.type === ActionTypes.REPLACE) return; |
|
3671 |
|
3672 if (unexpectedKeys.length > 0) { |
|
3673 return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored."); |
|
3674 } |
|
3675 } |
|
3676 |
|
3677 function assertReducerShape(reducers) { |
|
3678 Object.keys(reducers).forEach(function (key) { |
|
3679 var reducer = reducers[key]; |
|
3680 var initialState = reducer(undefined, { |
|
3681 type: ActionTypes.INIT |
|
3682 }); |
|
3683 |
|
3684 if (typeof initialState === 'undefined') { |
|
3685 throw new Error("Reducer \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined."); |
|
3686 } |
|
3687 |
|
3688 if (typeof reducer(undefined, { |
|
3689 type: ActionTypes.PROBE_UNKNOWN_ACTION() |
|
3690 }) === 'undefined') { |
|
3691 throw new Error("Reducer \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle " + ActionTypes.INIT + " or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null."); |
|
3692 } |
|
3693 }); |
|
3694 } |
|
3695 /** |
|
3696 * Turns an object whose values are different reducer functions, into a single |
|
3697 * reducer function. It will call every child reducer, and gather their results |
|
3698 * into a single state object, whose keys correspond to the keys of the passed |
|
3699 * reducer functions. |
|
3700 * |
|
3701 * @param {Object} reducers An object whose values correspond to different |
|
3702 * reducer functions that need to be combined into one. One handy way to obtain |
|
3703 * it is to use ES6 `import * as reducers` syntax. The reducers may never return |
|
3704 * undefined for any action. Instead, they should return their initial state |
|
3705 * if the state passed to them was undefined, and the current state for any |
|
3706 * unrecognized action. |
|
3707 * |
|
3708 * @returns {Function} A reducer function that invokes every reducer inside the |
|
3709 * passed object, and builds a state object with the same shape. |
|
3710 */ |
|
3711 |
|
3712 |
|
3713 function combineReducers(reducers) { |
|
3714 var reducerKeys = Object.keys(reducers); |
|
3715 var finalReducers = {}; |
|
3716 |
|
3717 for (var i = 0; i < reducerKeys.length; i++) { |
|
3718 var key = reducerKeys[i]; |
|
3719 |
|
3720 if (false) {} |
|
3721 |
|
3722 if (typeof reducers[key] === 'function') { |
|
3723 finalReducers[key] = reducers[key]; |
|
3724 } |
|
3725 } |
|
3726 |
|
3727 var finalReducerKeys = Object.keys(finalReducers); |
|
3728 var unexpectedKeyCache; |
|
3729 |
|
3730 if (false) {} |
|
3731 |
|
3732 var shapeAssertionError; |
|
3733 |
|
3734 try { |
|
3735 assertReducerShape(finalReducers); |
|
3736 } catch (e) { |
|
3737 shapeAssertionError = e; |
|
3738 } |
|
3739 |
|
3740 return function combination(state, action) { |
|
3741 if (state === void 0) { |
|
3742 state = {}; |
|
3743 } |
|
3744 |
|
3745 if (shapeAssertionError) { |
|
3746 throw shapeAssertionError; |
|
3747 } |
|
3748 |
|
3749 if (false) { var warningMessage; } |
|
3750 |
|
3751 var hasChanged = false; |
|
3752 var nextState = {}; |
|
3753 |
|
3754 for (var _i = 0; _i < finalReducerKeys.length; _i++) { |
|
3755 var _key = finalReducerKeys[_i]; |
|
3756 var reducer = finalReducers[_key]; |
|
3757 var previousStateForKey = state[_key]; |
|
3758 var nextStateForKey = reducer(previousStateForKey, action); |
|
3759 |
|
3760 if (typeof nextStateForKey === 'undefined') { |
|
3761 var errorMessage = getUndefinedStateErrorMessage(_key, action); |
|
3762 throw new Error(errorMessage); |
|
3763 } |
|
3764 |
|
3765 nextState[_key] = nextStateForKey; |
|
3766 hasChanged = hasChanged || nextStateForKey !== previousStateForKey; |
|
3767 } |
|
3768 |
|
3769 return hasChanged ? nextState : state; |
|
3770 }; |
|
3771 } |
|
3772 |
|
3773 function bindActionCreator(actionCreator, dispatch) { |
|
3774 return function () { |
|
3775 return dispatch(actionCreator.apply(this, arguments)); |
|
3776 }; |
|
3777 } |
|
3778 /** |
|
3779 * Turns an object whose values are action creators, into an object with the |
|
3780 * same keys, but with every function wrapped into a `dispatch` call so they |
|
3781 * may be invoked directly. This is just a convenience method, as you can call |
|
3782 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine. |
|
3783 * |
|
3784 * For convenience, you can also pass a single function as the first argument, |
|
3785 * and get a function in return. |
|
3786 * |
|
3787 * @param {Function|Object} actionCreators An object whose values are action |
|
3788 * creator functions. One handy way to obtain it is to use ES6 `import * as` |
|
3789 * syntax. You may also pass a single function. |
|
3790 * |
|
3791 * @param {Function} dispatch The `dispatch` function available on your Redux |
|
3792 * store. |
|
3793 * |
|
3794 * @returns {Function|Object} The object mimicking the original object, but with |
|
3795 * every action creator wrapped into the `dispatch` call. If you passed a |
|
3796 * function as `actionCreators`, the return value will also be a single |
|
3797 * function. |
|
3798 */ |
|
3799 |
|
3800 |
|
3801 function bindActionCreators(actionCreators, dispatch) { |
|
3802 if (typeof actionCreators === 'function') { |
|
3803 return bindActionCreator(actionCreators, dispatch); |
|
3804 } |
|
3805 |
|
3806 if (typeof actionCreators !== 'object' || actionCreators === null) { |
|
3807 throw new Error("bindActionCreators expected an object or a function, instead received " + (actionCreators === null ? 'null' : typeof actionCreators) + ". " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?"); |
|
3808 } |
|
3809 |
|
3810 var keys = Object.keys(actionCreators); |
|
3811 var boundActionCreators = {}; |
|
3812 |
|
3813 for (var i = 0; i < keys.length; i++) { |
|
3814 var key = keys[i]; |
|
3815 var actionCreator = actionCreators[key]; |
|
3816 |
|
3817 if (typeof actionCreator === 'function') { |
|
3818 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch); |
|
3819 } |
|
3820 } |
|
3821 |
|
3822 return boundActionCreators; |
|
3823 } |
|
3824 |
|
3825 function _defineProperty(obj, key, value) { |
4655 function _defineProperty(obj, key, value) { |
3826 if (key in obj) { |
4656 if (key in obj) { |
3827 Object.defineProperty(obj, key, { |
4657 Object.defineProperty(obj, key, { |
3828 value: value, |
4658 value: value, |
3829 enumerable: true, |
4659 enumerable: true, |
3835 } |
4665 } |
3836 |
4666 |
3837 return obj; |
4667 return obj; |
3838 } |
4668 } |
3839 |
4669 |
3840 function _objectSpread(target) { |
|
3841 for (var i = 1; i < arguments.length; i++) { |
|
3842 var source = arguments[i] != null ? arguments[i] : {}; |
|
3843 var ownKeys = Object.keys(source); |
|
3844 |
|
3845 if (typeof Object.getOwnPropertySymbols === 'function') { |
|
3846 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { |
|
3847 return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
|
3848 })); |
|
3849 } |
|
3850 |
|
3851 ownKeys.forEach(function (key) { |
|
3852 _defineProperty(target, key, source[key]); |
|
3853 }); |
|
3854 } |
|
3855 |
|
3856 return target; |
|
3857 } |
|
3858 |
|
3859 /** |
|
3860 * Composes single-argument functions from right to left. The rightmost |
|
3861 * function can take multiple arguments as it provides the signature for |
|
3862 * the resulting composite function. |
|
3863 * |
|
3864 * @param {...Function} funcs The functions to compose. |
|
3865 * @returns {Function} A function obtained by composing the argument functions |
|
3866 * from right to left. For example, compose(f, g, h) is identical to doing |
|
3867 * (...args) => f(g(h(...args))). |
|
3868 */ |
|
3869 function compose() { |
|
3870 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) { |
|
3871 funcs[_key] = arguments[_key]; |
|
3872 } |
|
3873 |
|
3874 if (funcs.length === 0) { |
|
3875 return function (arg) { |
|
3876 return arg; |
|
3877 }; |
|
3878 } |
|
3879 |
|
3880 if (funcs.length === 1) { |
|
3881 return funcs[0]; |
|
3882 } |
|
3883 |
|
3884 return funcs.reduce(function (a, b) { |
|
3885 return function () { |
|
3886 return a(b.apply(void 0, arguments)); |
|
3887 }; |
|
3888 }); |
|
3889 } |
|
3890 |
|
3891 /** |
|
3892 * Creates a store enhancer that applies middleware to the dispatch method |
|
3893 * of the Redux store. This is handy for a variety of tasks, such as expressing |
|
3894 * asynchronous actions in a concise manner, or logging every action payload. |
|
3895 * |
|
3896 * See `redux-thunk` package as an example of the Redux middleware. |
|
3897 * |
|
3898 * Because middleware is potentially asynchronous, this should be the first |
|
3899 * store enhancer in the composition chain. |
|
3900 * |
|
3901 * Note that each middleware will be given the `dispatch` and `getState` functions |
|
3902 * as named arguments. |
|
3903 * |
|
3904 * @param {...Function} middlewares The middleware chain to be applied. |
|
3905 * @returns {Function} A store enhancer applying the middleware. |
|
3906 */ |
|
3907 |
|
3908 function applyMiddleware() { |
|
3909 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) { |
|
3910 middlewares[_key] = arguments[_key]; |
|
3911 } |
|
3912 |
|
3913 return function (createStore) { |
|
3914 return function () { |
|
3915 var store = createStore.apply(void 0, arguments); |
|
3916 |
|
3917 var _dispatch = function dispatch() { |
|
3918 throw new Error("Dispatching while constructing your middleware is not allowed. " + "Other middleware would not be applied to this dispatch."); |
|
3919 }; |
|
3920 |
|
3921 var middlewareAPI = { |
|
3922 getState: store.getState, |
|
3923 dispatch: function dispatch() { |
|
3924 return _dispatch.apply(void 0, arguments); |
|
3925 } |
|
3926 }; |
|
3927 var chain = middlewares.map(function (middleware) { |
|
3928 return middleware(middlewareAPI); |
|
3929 }); |
|
3930 _dispatch = compose.apply(void 0, chain)(store.dispatch); |
|
3931 return _objectSpread({}, store, { |
|
3932 dispatch: _dispatch |
|
3933 }); |
|
3934 }; |
|
3935 }; |
|
3936 } |
|
3937 |
|
3938 /* |
|
3939 * This is a dummy function to check if the function name has been altered by minification. |
|
3940 * If the function has been minified and NODE_ENV !== 'production', warn the user. |
|
3941 */ |
|
3942 |
|
3943 function isCrushed() {} |
|
3944 |
|
3945 if (false) {} |
|
3946 |
|
3947 |
|
3948 |
|
3949 |
|
3950 /***/ }), |
4670 /***/ }), |
3951 |
4671 |
3952 /***/ 76: |
4672 /***/ 64: |
3953 /***/ (function(module, exports, __webpack_require__) { |
4673 /***/ (function(module, exports) { |
3954 |
4674 |
3955 "use strict"; |
4675 (function() { module.exports = this["wp"]["isShallowEqual"]; }()); |
3956 |
|
3957 |
|
3958 function _typeof(obj) { |
|
3959 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { |
|
3960 _typeof = function (obj) { |
|
3961 return typeof obj; |
|
3962 }; |
|
3963 } else { |
|
3964 _typeof = function (obj) { |
|
3965 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
|
3966 }; |
|
3967 } |
|
3968 |
|
3969 return _typeof(obj); |
|
3970 } |
|
3971 |
|
3972 function _classCallCheck(instance, Constructor) { |
|
3973 if (!(instance instanceof Constructor)) { |
|
3974 throw new TypeError("Cannot call a class as a function"); |
|
3975 } |
|
3976 } |
|
3977 |
|
3978 function _defineProperties(target, props) { |
|
3979 for (var i = 0; i < props.length; i++) { |
|
3980 var descriptor = props[i]; |
|
3981 descriptor.enumerable = descriptor.enumerable || false; |
|
3982 descriptor.configurable = true; |
|
3983 if ("value" in descriptor) descriptor.writable = true; |
|
3984 Object.defineProperty(target, descriptor.key, descriptor); |
|
3985 } |
|
3986 } |
|
3987 |
|
3988 function _createClass(Constructor, protoProps, staticProps) { |
|
3989 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
3990 if (staticProps) _defineProperties(Constructor, staticProps); |
|
3991 return Constructor; |
|
3992 } |
|
3993 |
|
3994 /** |
|
3995 * Given an instance of EquivalentKeyMap, returns its internal value pair tuple |
|
3996 * for a key, if one exists. The tuple members consist of the last reference |
|
3997 * value for the key (used in efficient subsequent lookups) and the value |
|
3998 * assigned for the key at the leaf node. |
|
3999 * |
|
4000 * @param {EquivalentKeyMap} instance EquivalentKeyMap instance. |
|
4001 * @param {*} key The key for which to return value pair. |
|
4002 * |
|
4003 * @return {?Array} Value pair, if exists. |
|
4004 */ |
|
4005 function getValuePair(instance, key) { |
|
4006 var _map = instance._map, |
|
4007 _arrayTreeMap = instance._arrayTreeMap, |
|
4008 _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the |
|
4009 // value, which can be used to shortcut immediately to the value. |
|
4010 |
|
4011 if (_map.has(key)) { |
|
4012 return _map.get(key); |
|
4013 } // Sort keys to ensure stable retrieval from tree. |
|
4014 |
|
4015 |
|
4016 var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value. |
|
4017 |
|
4018 var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap; |
|
4019 |
|
4020 for (var i = 0; i < properties.length; i++) { |
|
4021 var property = properties[i]; |
|
4022 map = map.get(property); |
|
4023 |
|
4024 if (map === undefined) { |
|
4025 return; |
|
4026 } |
|
4027 |
|
4028 var propertyValue = key[property]; |
|
4029 map = map.get(propertyValue); |
|
4030 |
|
4031 if (map === undefined) { |
|
4032 return; |
|
4033 } |
|
4034 } |
|
4035 |
|
4036 var valuePair = map.get('_ekm_value'); |
|
4037 |
|
4038 if (!valuePair) { |
|
4039 return; |
|
4040 } // If reached, it implies that an object-like key was set with another |
|
4041 // reference, so delete the reference and replace with the current. |
|
4042 |
|
4043 |
|
4044 _map.delete(valuePair[0]); |
|
4045 |
|
4046 valuePair[0] = key; |
|
4047 map.set('_ekm_value', valuePair); |
|
4048 |
|
4049 _map.set(key, valuePair); |
|
4050 |
|
4051 return valuePair; |
|
4052 } |
|
4053 /** |
|
4054 * Variant of a Map object which enables lookup by equivalent (deeply equal) |
|
4055 * object and array keys. |
|
4056 */ |
|
4057 |
|
4058 |
|
4059 var EquivalentKeyMap = |
|
4060 /*#__PURE__*/ |
|
4061 function () { |
|
4062 /** |
|
4063 * Constructs a new instance of EquivalentKeyMap. |
|
4064 * |
|
4065 * @param {Iterable.<*>} iterable Initial pair of key, value for map. |
|
4066 */ |
|
4067 function EquivalentKeyMap(iterable) { |
|
4068 _classCallCheck(this, EquivalentKeyMap); |
|
4069 |
|
4070 this.clear(); |
|
4071 |
|
4072 if (iterable instanceof EquivalentKeyMap) { |
|
4073 // Map#forEach is only means of iterating with support for IE11. |
|
4074 var iterablePairs = []; |
|
4075 iterable.forEach(function (value, key) { |
|
4076 iterablePairs.push([key, value]); |
|
4077 }); |
|
4078 iterable = iterablePairs; |
|
4079 } |
|
4080 |
|
4081 if (iterable != null) { |
|
4082 for (var i = 0; i < iterable.length; i++) { |
|
4083 this.set(iterable[i][0], iterable[i][1]); |
|
4084 } |
|
4085 } |
|
4086 } |
|
4087 /** |
|
4088 * Accessor property returning the number of elements. |
|
4089 * |
|
4090 * @return {number} Number of elements. |
|
4091 */ |
|
4092 |
|
4093 |
|
4094 _createClass(EquivalentKeyMap, [{ |
|
4095 key: "set", |
|
4096 |
|
4097 /** |
|
4098 * Add or update an element with a specified key and value. |
|
4099 * |
|
4100 * @param {*} key The key of the element to add. |
|
4101 * @param {*} value The value of the element to add. |
|
4102 * |
|
4103 * @return {EquivalentKeyMap} Map instance. |
|
4104 */ |
|
4105 value: function set(key, value) { |
|
4106 // Shortcut non-object-like to set on internal Map. |
|
4107 if (key === null || _typeof(key) !== 'object') { |
|
4108 this._map.set(key, value); |
|
4109 |
|
4110 return this; |
|
4111 } // Sort keys to ensure stable assignment into tree. |
|
4112 |
|
4113 |
|
4114 var properties = Object.keys(key).sort(); |
|
4115 var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value. |
|
4116 |
|
4117 var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap; |
|
4118 |
|
4119 for (var i = 0; i < properties.length; i++) { |
|
4120 var property = properties[i]; |
|
4121 |
|
4122 if (!map.has(property)) { |
|
4123 map.set(property, new EquivalentKeyMap()); |
|
4124 } |
|
4125 |
|
4126 map = map.get(property); |
|
4127 var propertyValue = key[property]; |
|
4128 |
|
4129 if (!map.has(propertyValue)) { |
|
4130 map.set(propertyValue, new EquivalentKeyMap()); |
|
4131 } |
|
4132 |
|
4133 map = map.get(propertyValue); |
|
4134 } // If an _ekm_value exists, there was already an equivalent key. Before |
|
4135 // overriding, ensure that the old key reference is removed from map to |
|
4136 // avoid memory leak of accumulating equivalent keys. This is, in a |
|
4137 // sense, a poor man's WeakMap, while still enabling iterability. |
|
4138 |
|
4139 |
|
4140 var previousValuePair = map.get('_ekm_value'); |
|
4141 |
|
4142 if (previousValuePair) { |
|
4143 this._map.delete(previousValuePair[0]); |
|
4144 } |
|
4145 |
|
4146 map.set('_ekm_value', valuePair); |
|
4147 |
|
4148 this._map.set(key, valuePair); |
|
4149 |
|
4150 return this; |
|
4151 } |
|
4152 /** |
|
4153 * Returns a specified element. |
|
4154 * |
|
4155 * @param {*} key The key of the element to return. |
|
4156 * |
|
4157 * @return {?*} The element associated with the specified key or undefined |
|
4158 * if the key can't be found. |
|
4159 */ |
|
4160 |
|
4161 }, { |
|
4162 key: "get", |
|
4163 value: function get(key) { |
|
4164 // Shortcut non-object-like to get from internal Map. |
|
4165 if (key === null || _typeof(key) !== 'object') { |
|
4166 return this._map.get(key); |
|
4167 } |
|
4168 |
|
4169 var valuePair = getValuePair(this, key); |
|
4170 |
|
4171 if (valuePair) { |
|
4172 return valuePair[1]; |
|
4173 } |
|
4174 } |
|
4175 /** |
|
4176 * Returns a boolean indicating whether an element with the specified key |
|
4177 * exists or not. |
|
4178 * |
|
4179 * @param {*} key The key of the element to test for presence. |
|
4180 * |
|
4181 * @return {boolean} Whether an element with the specified key exists. |
|
4182 */ |
|
4183 |
|
4184 }, { |
|
4185 key: "has", |
|
4186 value: function has(key) { |
|
4187 if (key === null || _typeof(key) !== 'object') { |
|
4188 return this._map.has(key); |
|
4189 } // Test on the _presence_ of the pair, not its value, as even undefined |
|
4190 // can be a valid member value for a key. |
|
4191 |
|
4192 |
|
4193 return getValuePair(this, key) !== undefined; |
|
4194 } |
|
4195 /** |
|
4196 * Removes the specified element. |
|
4197 * |
|
4198 * @param {*} key The key of the element to remove. |
|
4199 * |
|
4200 * @return {boolean} Returns true if an element existed and has been |
|
4201 * removed, or false if the element does not exist. |
|
4202 */ |
|
4203 |
|
4204 }, { |
|
4205 key: "delete", |
|
4206 value: function _delete(key) { |
|
4207 if (!this.has(key)) { |
|
4208 return false; |
|
4209 } // This naive implementation will leave orphaned child trees. A better |
|
4210 // implementation should traverse and remove orphans. |
|
4211 |
|
4212 |
|
4213 this.set(key, undefined); |
|
4214 return true; |
|
4215 } |
|
4216 /** |
|
4217 * Executes a provided function once per each key/value pair, in insertion |
|
4218 * order. |
|
4219 * |
|
4220 * @param {Function} callback Function to execute for each element. |
|
4221 * @param {*} thisArg Value to use as `this` when executing |
|
4222 * `callback`. |
|
4223 */ |
|
4224 |
|
4225 }, { |
|
4226 key: "forEach", |
|
4227 value: function forEach(callback) { |
|
4228 var _this = this; |
|
4229 |
|
4230 var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; |
|
4231 |
|
4232 this._map.forEach(function (value, key) { |
|
4233 // Unwrap value from object-like value pair. |
|
4234 if (key !== null && _typeof(key) === 'object') { |
|
4235 value = value[1]; |
|
4236 } |
|
4237 |
|
4238 callback.call(thisArg, value, key, _this); |
|
4239 }); |
|
4240 } |
|
4241 /** |
|
4242 * Removes all elements. |
|
4243 */ |
|
4244 |
|
4245 }, { |
|
4246 key: "clear", |
|
4247 value: function clear() { |
|
4248 this._map = new Map(); |
|
4249 this._arrayTreeMap = new Map(); |
|
4250 this._objectTreeMap = new Map(); |
|
4251 } |
|
4252 }, { |
|
4253 key: "size", |
|
4254 get: function get() { |
|
4255 return this._map.size; |
|
4256 } |
|
4257 }]); |
|
4258 |
|
4259 return EquivalentKeyMap; |
|
4260 }(); |
|
4261 |
|
4262 module.exports = EquivalentKeyMap; |
|
4263 |
|
4264 |
|
4265 /***/ }), |
|
4266 |
|
4267 /***/ 77: |
|
4268 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
4269 |
|
4270 "use strict"; |
|
4271 /* WEBPACK VAR INJECTION */(function(global, module) {/* harmony import */ var _ponyfill_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(99); |
|
4272 /* global window */ |
|
4273 |
|
4274 |
|
4275 var root; |
|
4276 |
|
4277 if (typeof self !== 'undefined') { |
|
4278 root = self; |
|
4279 } else if (typeof window !== 'undefined') { |
|
4280 root = window; |
|
4281 } else if (typeof global !== 'undefined') { |
|
4282 root = global; |
|
4283 } else if (true) { |
|
4284 root = module; |
|
4285 } else {} |
|
4286 |
|
4287 var result = Object(_ponyfill_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(root); |
|
4288 /* harmony default export */ __webpack_exports__["a"] = (result); |
|
4289 |
|
4290 /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(59), __webpack_require__(132)(module))) |
|
4291 |
|
4292 /***/ }), |
|
4293 |
|
4294 /***/ 99: |
|
4295 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
4296 |
|
4297 "use strict"; |
|
4298 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return symbolObservablePonyfill; }); |
|
4299 function symbolObservablePonyfill(root) { |
|
4300 var result; |
|
4301 var Symbol = root.Symbol; |
|
4302 |
|
4303 if (typeof Symbol === 'function') { |
|
4304 if (Symbol.observable) { |
|
4305 result = Symbol.observable; |
|
4306 } else { |
|
4307 result = Symbol('observable'); |
|
4308 Symbol.observable = result; |
|
4309 } |
|
4310 } else { |
|
4311 result = '@@observable'; |
|
4312 } |
|
4313 |
|
4314 return result; |
|
4315 }; |
|
4316 |
|
4317 |
4676 |
4318 /***/ }) |
4677 /***/ }) |
4319 |
4678 |
4320 /******/ }); |
4679 /******/ }); |