9
|
1 |
this["wp"] = this["wp"] || {}; this["wp"]["coreData"] =
|
|
2 |
/******/ (function(modules) { // webpackBootstrap
|
|
3 |
/******/ // The module cache
|
|
4 |
/******/ var installedModules = {};
|
|
5 |
/******/
|
|
6 |
/******/ // The require function
|
|
7 |
/******/ function __webpack_require__(moduleId) {
|
|
8 |
/******/
|
|
9 |
/******/ // Check if module is in cache
|
|
10 |
/******/ if(installedModules[moduleId]) {
|
|
11 |
/******/ return installedModules[moduleId].exports;
|
|
12 |
/******/ }
|
|
13 |
/******/ // Create a new module (and put it into the cache)
|
|
14 |
/******/ var module = installedModules[moduleId] = {
|
|
15 |
/******/ i: moduleId,
|
|
16 |
/******/ l: false,
|
|
17 |
/******/ exports: {}
|
|
18 |
/******/ };
|
|
19 |
/******/
|
|
20 |
/******/ // Execute the module function
|
|
21 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22 |
/******/
|
|
23 |
/******/ // Flag the module as loaded
|
|
24 |
/******/ module.l = true;
|
|
25 |
/******/
|
|
26 |
/******/ // Return the exports of the module
|
|
27 |
/******/ return module.exports;
|
|
28 |
/******/ }
|
|
29 |
/******/
|
|
30 |
/******/
|
|
31 |
/******/ // expose the modules object (__webpack_modules__)
|
|
32 |
/******/ __webpack_require__.m = modules;
|
|
33 |
/******/
|
|
34 |
/******/ // expose the module cache
|
|
35 |
/******/ __webpack_require__.c = installedModules;
|
|
36 |
/******/
|
|
37 |
/******/ // define getter function for harmony exports
|
|
38 |
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39 |
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40 |
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41 |
/******/ }
|
|
42 |
/******/ };
|
|
43 |
/******/
|
|
44 |
/******/ // define __esModule on exports
|
|
45 |
/******/ __webpack_require__.r = function(exports) {
|
|
46 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48 |
/******/ }
|
|
49 |
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50 |
/******/ };
|
|
51 |
/******/
|
|
52 |
/******/ // create a fake namespace object
|
|
53 |
/******/ // mode & 1: value is a module id, require it
|
|
54 |
/******/ // mode & 2: merge all properties of value into the ns
|
|
55 |
/******/ // mode & 4: return value when already ns object
|
|
56 |
/******/ // mode & 8|1: behave like require
|
|
57 |
/******/ __webpack_require__.t = function(value, mode) {
|
|
58 |
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59 |
/******/ if(mode & 8) return value;
|
|
60 |
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61 |
/******/ var ns = Object.create(null);
|
|
62 |
/******/ __webpack_require__.r(ns);
|
|
63 |
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
64 |
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
65 |
/******/ return ns;
|
|
66 |
/******/ };
|
|
67 |
/******/
|
|
68 |
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69 |
/******/ __webpack_require__.n = function(module) {
|
|
70 |
/******/ var getter = module && module.__esModule ?
|
|
71 |
/******/ function getDefault() { return module['default']; } :
|
|
72 |
/******/ function getModuleExports() { return module; };
|
|
73 |
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74 |
/******/ return getter;
|
|
75 |
/******/ };
|
|
76 |
/******/
|
|
77 |
/******/ // Object.prototype.hasOwnProperty.call
|
|
78 |
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79 |
/******/
|
|
80 |
/******/ // __webpack_public_path__
|
|
81 |
/******/ __webpack_require__.p = "";
|
|
82 |
/******/
|
|
83 |
/******/
|
|
84 |
/******/ // Load entry module and return exports
|
16
|
85 |
/******/ return __webpack_require__(__webpack_require__.s = 447);
|
9
|
86 |
/******/ })
|
|
87 |
/************************************************************************/
|
|
88 |
/******/ ({
|
|
89 |
|
16
|
90 |
/***/ 0:
|
9
|
91 |
/***/ (function(module, exports) {
|
|
92 |
|
16
|
93 |
(function() { module.exports = this["wp"]["element"]; }());
|
9
|
94 |
|
|
95 |
/***/ }),
|
|
96 |
|
16
|
97 |
/***/ 1:
|
|
98 |
/***/ (function(module, exports) {
|
|
99 |
|
|
100 |
(function() { module.exports = this["wp"]["i18n"]; }());
|
9
|
101 |
|
|
102 |
/***/ }),
|
|
103 |
|
16
|
104 |
/***/ 10:
|
9
|
105 |
/***/ (function(module, exports) {
|
|
106 |
|
16
|
107 |
(function() { module.exports = this["wp"]["blocks"]; }());
|
9
|
108 |
|
|
109 |
/***/ }),
|
|
110 |
|
16
|
111 |
/***/ 126:
|
9
|
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 |
|
16
|
426 |
/***/ 14:
|
|
427 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
428 |
|
|
429 |
"use strict";
|
|
430 |
|
|
431 |
// EXPORTS
|
|
432 |
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; });
|
|
433 |
|
|
434 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
435 |
var arrayWithHoles = __webpack_require__(38);
|
|
436 |
|
|
437 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
438 |
function _iterableToArrayLimit(arr, i) {
|
|
439 |
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
440 |
var _arr = [];
|
|
441 |
var _n = true;
|
|
442 |
var _d = false;
|
|
443 |
var _e = undefined;
|
|
444 |
|
|
445 |
try {
|
|
446 |
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
447 |
_arr.push(_s.value);
|
|
448 |
|
|
449 |
if (i && _arr.length === i) break;
|
|
450 |
}
|
|
451 |
} catch (err) {
|
|
452 |
_d = true;
|
|
453 |
_e = err;
|
|
454 |
} finally {
|
|
455 |
try {
|
|
456 |
if (!_n && _i["return"] != null) _i["return"]();
|
|
457 |
} finally {
|
|
458 |
if (_d) throw _e;
|
|
459 |
}
|
|
460 |
}
|
|
461 |
|
|
462 |
return _arr;
|
|
463 |
}
|
|
464 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
465 |
var unsupportedIterableToArray = __webpack_require__(29);
|
|
466 |
|
|
467 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
|
|
468 |
var nonIterableRest = __webpack_require__(39);
|
|
469 |
|
|
470 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
|
|
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
function _slicedToArray(arr, i) {
|
|
476 |
return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])();
|
|
477 |
}
|
|
478 |
|
|
479 |
/***/ }),
|
|
480 |
|
|
481 |
/***/ 18:
|
|
482 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
483 |
|
|
484 |
"use strict";
|
|
485 |
|
|
486 |
// EXPORTS
|
|
487 |
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; });
|
|
488 |
|
|
489 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
|
|
490 |
var arrayLikeToArray = __webpack_require__(26);
|
|
491 |
|
|
492 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
|
|
493 |
|
|
494 |
function _arrayWithoutHoles(arr) {
|
|
495 |
if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr);
|
|
496 |
}
|
|
497 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
|
|
498 |
var iterableToArray = __webpack_require__(35);
|
|
499 |
|
|
500 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
501 |
var unsupportedIterableToArray = __webpack_require__(29);
|
|
502 |
|
|
503 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
|
|
504 |
function _nonIterableSpread() {
|
|
505 |
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
506 |
}
|
|
507 |
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
function _toConsumableArray(arr) {
|
|
513 |
return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread();
|
|
514 |
}
|
|
515 |
|
|
516 |
/***/ }),
|
|
517 |
|
|
518 |
/***/ 2:
|
|
519 |
/***/ (function(module, exports) {
|
|
520 |
|
|
521 |
(function() { module.exports = this["lodash"]; }());
|
|
522 |
|
|
523 |
/***/ }),
|
|
524 |
|
|
525 |
/***/ 24:
|
|
526 |
/***/ (function(module, exports) {
|
|
527 |
|
|
528 |
(function() { module.exports = this["regeneratorRuntime"]; }());
|
|
529 |
|
|
530 |
/***/ }),
|
|
531 |
|
|
532 |
/***/ 26:
|
|
533 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
534 |
|
|
535 |
"use strict";
|
|
536 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
|
|
537 |
function _arrayLikeToArray(arr, len) {
|
|
538 |
if (len == null || len > arr.length) len = arr.length;
|
|
539 |
|
|
540 |
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
541 |
arr2[i] = arr[i];
|
|
542 |
}
|
|
543 |
|
|
544 |
return arr2;
|
|
545 |
}
|
|
546 |
|
|
547 |
/***/ }),
|
|
548 |
|
|
549 |
/***/ 29:
|
|
550 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
551 |
|
|
552 |
"use strict";
|
|
553 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
|
|
554 |
/* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26);
|
|
555 |
|
|
556 |
function _unsupportedIterableToArray(o, minLen) {
|
|
557 |
if (!o) return;
|
|
558 |
if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
|
|
559 |
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
560 |
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
561 |
if (n === "Map" || n === "Set") return Array.from(o);
|
|
562 |
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
|
|
563 |
}
|
|
564 |
|
|
565 |
/***/ }),
|
|
566 |
|
|
567 |
/***/ 31:
|
|
568 |
/***/ (function(module, exports) {
|
|
569 |
|
|
570 |
(function() { module.exports = this["wp"]["url"]; }());
|
|
571 |
|
|
572 |
/***/ }),
|
|
573 |
|
|
574 |
/***/ 35:
|
|
575 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
576 |
|
|
577 |
"use strict";
|
|
578 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
|
|
579 |
function _iterableToArray(iter) {
|
|
580 |
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
581 |
}
|
|
582 |
|
|
583 |
/***/ }),
|
|
584 |
|
|
585 |
/***/ 36:
|
|
586 |
/***/ (function(module, exports) {
|
|
587 |
|
|
588 |
(function() { module.exports = this["wp"]["dataControls"]; }());
|
|
589 |
|
|
590 |
/***/ }),
|
|
591 |
|
|
592 |
/***/ 37:
|
|
593 |
/***/ (function(module, exports) {
|
|
594 |
|
|
595 |
(function() { module.exports = this["wp"]["deprecated"]; }());
|
|
596 |
|
|
597 |
/***/ }),
|
|
598 |
|
|
599 |
/***/ 38:
|
|
600 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
601 |
|
|
602 |
"use strict";
|
|
603 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
|
|
604 |
function _arrayWithHoles(arr) {
|
|
605 |
if (Array.isArray(arr)) return arr;
|
|
606 |
}
|
|
607 |
|
|
608 |
/***/ }),
|
|
609 |
|
|
610 |
/***/ 39:
|
|
611 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
612 |
|
|
613 |
"use strict";
|
|
614 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
|
|
615 |
function _nonIterableRest() {
|
|
616 |
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
617 |
}
|
|
618 |
|
|
619 |
/***/ }),
|
|
620 |
|
|
621 |
/***/ 4:
|
|
622 |
/***/ (function(module, exports) {
|
|
623 |
|
|
624 |
(function() { module.exports = this["wp"]["data"]; }());
|
|
625 |
|
|
626 |
/***/ }),
|
|
627 |
|
|
628 |
/***/ 42:
|
|
629 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
630 |
|
|
631 |
"use strict";
|
|
632 |
|
|
633 |
|
|
634 |
var LEAF_KEY, hasWeakMap;
|
|
635 |
|
|
636 |
/**
|
|
637 |
* Arbitrary value used as key for referencing cache object in WeakMap tree.
|
|
638 |
*
|
|
639 |
* @type {Object}
|
|
640 |
*/
|
|
641 |
LEAF_KEY = {};
|
|
642 |
|
|
643 |
/**
|
|
644 |
* Whether environment supports WeakMap.
|
|
645 |
*
|
|
646 |
* @type {boolean}
|
|
647 |
*/
|
|
648 |
hasWeakMap = typeof WeakMap !== 'undefined';
|
|
649 |
|
|
650 |
/**
|
|
651 |
* Returns the first argument as the sole entry in an array.
|
|
652 |
*
|
|
653 |
* @param {*} value Value to return.
|
|
654 |
*
|
|
655 |
* @return {Array} Value returned as entry in array.
|
|
656 |
*/
|
|
657 |
function arrayOf( value ) {
|
|
658 |
return [ value ];
|
|
659 |
}
|
|
660 |
|
|
661 |
/**
|
|
662 |
* Returns true if the value passed is object-like, or false otherwise. A value
|
|
663 |
* is object-like if it can support property assignment, e.g. object or array.
|
|
664 |
*
|
|
665 |
* @param {*} value Value to test.
|
|
666 |
*
|
|
667 |
* @return {boolean} Whether value is object-like.
|
|
668 |
*/
|
|
669 |
function isObjectLike( value ) {
|
|
670 |
return !! value && 'object' === typeof value;
|
|
671 |
}
|
|
672 |
|
|
673 |
/**
|
|
674 |
* Creates and returns a new cache object.
|
|
675 |
*
|
|
676 |
* @return {Object} Cache object.
|
|
677 |
*/
|
|
678 |
function createCache() {
|
|
679 |
var cache = {
|
|
680 |
clear: function() {
|
|
681 |
cache.head = null;
|
|
682 |
},
|
|
683 |
};
|
|
684 |
|
|
685 |
return cache;
|
|
686 |
}
|
|
687 |
|
|
688 |
/**
|
|
689 |
* Returns true if entries within the two arrays are strictly equal by
|
|
690 |
* reference from a starting index.
|
|
691 |
*
|
|
692 |
* @param {Array} a First array.
|
|
693 |
* @param {Array} b Second array.
|
|
694 |
* @param {number} fromIndex Index from which to start comparison.
|
|
695 |
*
|
|
696 |
* @return {boolean} Whether arrays are shallowly equal.
|
|
697 |
*/
|
|
698 |
function isShallowEqual( a, b, fromIndex ) {
|
|
699 |
var i;
|
|
700 |
|
|
701 |
if ( a.length !== b.length ) {
|
|
702 |
return false;
|
|
703 |
}
|
|
704 |
|
|
705 |
for ( i = fromIndex; i < a.length; i++ ) {
|
|
706 |
if ( a[ i ] !== b[ i ] ) {
|
|
707 |
return false;
|
|
708 |
}
|
|
709 |
}
|
|
710 |
|
|
711 |
return true;
|
|
712 |
}
|
|
713 |
|
|
714 |
/**
|
|
715 |
* Returns a memoized selector function. The getDependants function argument is
|
|
716 |
* called before the memoized selector and is expected to return an immutable
|
|
717 |
* reference or array of references on which the selector depends for computing
|
|
718 |
* its own return value. The memoize cache is preserved only as long as those
|
|
719 |
* dependant references remain the same. If getDependants returns a different
|
|
720 |
* reference(s), the cache is cleared and the selector value regenerated.
|
|
721 |
*
|
|
722 |
* @param {Function} selector Selector function.
|
|
723 |
* @param {Function} getDependants Dependant getter returning an immutable
|
|
724 |
* reference or array of reference used in
|
|
725 |
* cache bust consideration.
|
|
726 |
*
|
|
727 |
* @return {Function} Memoized selector.
|
|
728 |
*/
|
|
729 |
/* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) {
|
|
730 |
var rootCache, getCache;
|
|
731 |
|
|
732 |
// Use object source as dependant if getter not provided
|
|
733 |
if ( ! getDependants ) {
|
|
734 |
getDependants = arrayOf;
|
|
735 |
}
|
|
736 |
|
|
737 |
/**
|
|
738 |
* Returns the root cache. If WeakMap is supported, this is assigned to the
|
|
739 |
* root WeakMap cache set, otherwise it is a shared instance of the default
|
|
740 |
* cache object.
|
|
741 |
*
|
|
742 |
* @return {(WeakMap|Object)} Root cache object.
|
|
743 |
*/
|
|
744 |
function getRootCache() {
|
|
745 |
return rootCache;
|
|
746 |
}
|
|
747 |
|
|
748 |
/**
|
|
749 |
* Returns the cache for a given dependants array. When possible, a WeakMap
|
|
750 |
* will be used to create a unique cache for each set of dependants. This
|
|
751 |
* is feasible due to the nature of WeakMap in allowing garbage collection
|
|
752 |
* to occur on entries where the key object is no longer referenced. Since
|
|
753 |
* WeakMap requires the key to be an object, this is only possible when the
|
|
754 |
* dependant is object-like. The root cache is created as a hierarchy where
|
|
755 |
* each top-level key is the first entry in a dependants set, the value a
|
|
756 |
* WeakMap where each key is the next dependant, and so on. This continues
|
|
757 |
* so long as the dependants are object-like. If no dependants are object-
|
|
758 |
* like, then the cache is shared across all invocations.
|
|
759 |
*
|
|
760 |
* @see isObjectLike
|
|
761 |
*
|
|
762 |
* @param {Array} dependants Selector dependants.
|
|
763 |
*
|
|
764 |
* @return {Object} Cache object.
|
|
765 |
*/
|
|
766 |
function getWeakMapCache( dependants ) {
|
|
767 |
var caches = rootCache,
|
|
768 |
isUniqueByDependants = true,
|
|
769 |
i, dependant, map, cache;
|
|
770 |
|
|
771 |
for ( i = 0; i < dependants.length; i++ ) {
|
|
772 |
dependant = dependants[ i ];
|
|
773 |
|
|
774 |
// Can only compose WeakMap from object-like key.
|
|
775 |
if ( ! isObjectLike( dependant ) ) {
|
|
776 |
isUniqueByDependants = false;
|
|
777 |
break;
|
|
778 |
}
|
|
779 |
|
|
780 |
// Does current segment of cache already have a WeakMap?
|
|
781 |
if ( caches.has( dependant ) ) {
|
|
782 |
// Traverse into nested WeakMap.
|
|
783 |
caches = caches.get( dependant );
|
|
784 |
} else {
|
|
785 |
// Create, set, and traverse into a new one.
|
|
786 |
map = new WeakMap();
|
|
787 |
caches.set( dependant, map );
|
|
788 |
caches = map;
|
|
789 |
}
|
|
790 |
}
|
|
791 |
|
|
792 |
// We use an arbitrary (but consistent) object as key for the last item
|
|
793 |
// in the WeakMap to serve as our running cache.
|
|
794 |
if ( ! caches.has( LEAF_KEY ) ) {
|
|
795 |
cache = createCache();
|
|
796 |
cache.isUniqueByDependants = isUniqueByDependants;
|
|
797 |
caches.set( LEAF_KEY, cache );
|
|
798 |
}
|
|
799 |
|
|
800 |
return caches.get( LEAF_KEY );
|
|
801 |
}
|
|
802 |
|
|
803 |
// Assign cache handler by availability of WeakMap
|
|
804 |
getCache = hasWeakMap ? getWeakMapCache : getRootCache;
|
|
805 |
|
|
806 |
/**
|
|
807 |
* Resets root memoization cache.
|
|
808 |
*/
|
|
809 |
function clear() {
|
|
810 |
rootCache = hasWeakMap ? new WeakMap() : createCache();
|
|
811 |
}
|
|
812 |
|
|
813 |
// eslint-disable-next-line jsdoc/check-param-names
|
|
814 |
/**
|
|
815 |
* The augmented selector call, considering first whether dependants have
|
|
816 |
* changed before passing it to underlying memoize function.
|
|
817 |
*
|
|
818 |
* @param {Object} source Source object for derivation.
|
|
819 |
* @param {...*} extraArgs Additional arguments to pass to selector.
|
|
820 |
*
|
|
821 |
* @return {*} Selector result.
|
|
822 |
*/
|
|
823 |
function callSelector( /* source, ...extraArgs */ ) {
|
|
824 |
var len = arguments.length,
|
|
825 |
cache, node, i, args, dependants;
|
|
826 |
|
|
827 |
// Create copy of arguments (avoid leaking deoptimization).
|
|
828 |
args = new Array( len );
|
|
829 |
for ( i = 0; i < len; i++ ) {
|
|
830 |
args[ i ] = arguments[ i ];
|
|
831 |
}
|
|
832 |
|
|
833 |
dependants = getDependants.apply( null, args );
|
|
834 |
cache = getCache( dependants );
|
|
835 |
|
|
836 |
// If not guaranteed uniqueness by dependants (primitive type or lack
|
|
837 |
// of WeakMap support), shallow compare against last dependants and, if
|
|
838 |
// references have changed, destroy cache to recalculate result.
|
|
839 |
if ( ! cache.isUniqueByDependants ) {
|
|
840 |
if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
|
|
841 |
cache.clear();
|
|
842 |
}
|
|
843 |
|
|
844 |
cache.lastDependants = dependants;
|
|
845 |
}
|
|
846 |
|
|
847 |
node = cache.head;
|
|
848 |
while ( node ) {
|
|
849 |
// Check whether node arguments match arguments
|
|
850 |
if ( ! isShallowEqual( node.args, args, 1 ) ) {
|
|
851 |
node = node.next;
|
|
852 |
continue;
|
|
853 |
}
|
|
854 |
|
|
855 |
// At this point we can assume we've found a match
|
|
856 |
|
|
857 |
// Surface matched node to head if not already
|
|
858 |
if ( node !== cache.head ) {
|
|
859 |
// Adjust siblings to point to each other.
|
|
860 |
node.prev.next = node.next;
|
|
861 |
if ( node.next ) {
|
|
862 |
node.next.prev = node.prev;
|
|
863 |
}
|
|
864 |
|
|
865 |
node.next = cache.head;
|
|
866 |
node.prev = null;
|
|
867 |
cache.head.prev = node;
|
|
868 |
cache.head = node;
|
|
869 |
}
|
|
870 |
|
|
871 |
// Return immediately
|
|
872 |
return node.val;
|
|
873 |
}
|
|
874 |
|
|
875 |
// No cached value found. Continue to insertion phase:
|
|
876 |
|
|
877 |
node = {
|
|
878 |
// Generate the result from original function
|
|
879 |
val: selector.apply( null, args ),
|
|
880 |
};
|
|
881 |
|
|
882 |
// Avoid including the source object in the cache.
|
|
883 |
args[ 0 ] = null;
|
|
884 |
node.args = args;
|
|
885 |
|
|
886 |
// Don't need to check whether node is already head, since it would
|
|
887 |
// have been returned above already if it was
|
|
888 |
|
|
889 |
// Shift existing head down list
|
|
890 |
if ( cache.head ) {
|
|
891 |
cache.head.prev = node;
|
|
892 |
node.next = cache.head;
|
|
893 |
}
|
|
894 |
|
|
895 |
cache.head = node;
|
|
896 |
|
|
897 |
return node.val;
|
|
898 |
}
|
|
899 |
|
|
900 |
callSelector.getDependants = getDependants;
|
|
901 |
callSelector.clear = clear;
|
|
902 |
clear();
|
|
903 |
|
|
904 |
return callSelector;
|
|
905 |
});
|
|
906 |
|
|
907 |
|
|
908 |
/***/ }),
|
|
909 |
|
|
910 |
/***/ 447:
|
9
|
911 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
912 |
|
|
913 |
"use strict";
|
16
|
914 |
// ESM COMPAT FLAG
|
|
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
|
|
924 |
var build_module_actions_namespaceObject = {};
|
|
925 |
__webpack_require__.r(build_module_actions_namespaceObject);
|
|
926 |
__webpack_require__.d(build_module_actions_namespaceObject, "receiveUserQuery", function() { return receiveUserQuery; });
|
|
927 |
__webpack_require__.d(build_module_actions_namespaceObject, "receiveCurrentUser", function() { return receiveCurrentUser; });
|
|
928 |
__webpack_require__.d(build_module_actions_namespaceObject, "addEntities", function() { return addEntities; });
|
|
929 |
__webpack_require__.d(build_module_actions_namespaceObject, "receiveEntityRecords", function() { return receiveEntityRecords; });
|
|
930 |
__webpack_require__.d(build_module_actions_namespaceObject, "receiveCurrentTheme", function() { return receiveCurrentTheme; });
|
|
931 |
__webpack_require__.d(build_module_actions_namespaceObject, "receiveThemeSupports", function() { return receiveThemeSupports; });
|
|
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; });
|
|
937 |
__webpack_require__.d(build_module_actions_namespaceObject, "saveEntityRecord", function() { return saveEntityRecord; });
|
|
938 |
__webpack_require__.d(build_module_actions_namespaceObject, "saveEditedEntityRecord", function() { return saveEditedEntityRecord; });
|
|
939 |
__webpack_require__.d(build_module_actions_namespaceObject, "receiveUploadPermissions", function() { return receiveUploadPermissions; });
|
|
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
|
|
944 |
var build_module_selectors_namespaceObject = {};
|
|
945 |
__webpack_require__.r(build_module_selectors_namespaceObject);
|
|
946 |
__webpack_require__.d(build_module_selectors_namespaceObject, "isRequestingEmbedPreview", function() { return isRequestingEmbedPreview; });
|
|
947 |
__webpack_require__.d(build_module_selectors_namespaceObject, "getAuthors", function() { return getAuthors; });
|
|
948 |
__webpack_require__.d(build_module_selectors_namespaceObject, "getCurrentUser", function() { return getCurrentUser; });
|
|
949 |
__webpack_require__.d(build_module_selectors_namespaceObject, "getUserQueryResults", function() { return getUserQueryResults; });
|
|
950 |
__webpack_require__.d(build_module_selectors_namespaceObject, "getEntitiesByKind", function() { return getEntitiesByKind; });
|
|
951 |
__webpack_require__.d(build_module_selectors_namespaceObject, "getEntity", function() { return selectors_getEntity; });
|
|
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; });
|
|
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; });
|
|
969 |
__webpack_require__.d(build_module_selectors_namespaceObject, "getThemeSupports", function() { return getThemeSupports; });
|
|
970 |
__webpack_require__.d(build_module_selectors_namespaceObject, "getEmbedPreview", function() { return getEmbedPreview; });
|
|
971 |
__webpack_require__.d(build_module_selectors_namespaceObject, "isPreviewEmbedFallback", function() { return isPreviewEmbedFallback; });
|
|
972 |
__webpack_require__.d(build_module_selectors_namespaceObject, "hasUploadPermissions", function() { return hasUploadPermissions; });
|
|
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
|
|
980 |
var resolvers_namespaceObject = {};
|
|
981 |
__webpack_require__.r(resolvers_namespaceObject);
|
|
982 |
__webpack_require__.d(resolvers_namespaceObject, "getAuthors", function() { return resolvers_getAuthors; });
|
|
983 |
__webpack_require__.d(resolvers_namespaceObject, "getCurrentUser", function() { return resolvers_getCurrentUser; });
|
|
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; });
|
|
987 |
__webpack_require__.d(resolvers_namespaceObject, "getEntityRecords", function() { return resolvers_getEntityRecords; });
|
|
988 |
__webpack_require__.d(resolvers_namespaceObject, "getCurrentTheme", function() { return resolvers_getCurrentTheme; });
|
|
989 |
__webpack_require__.d(resolvers_namespaceObject, "getThemeSupports", function() { return resolvers_getThemeSupports; });
|
|
990 |
__webpack_require__.d(resolvers_namespaceObject, "getEmbedPreview", function() { return resolvers_getEmbedPreview; });
|
|
991 |
__webpack_require__.d(resolvers_namespaceObject, "hasUploadPermissions", function() { return resolvers_hasUploadPermissions; });
|
|
992 |
__webpack_require__.d(resolvers_namespaceObject, "canUser", function() { return resolvers_canUser; });
|
|
993 |
__webpack_require__.d(resolvers_namespaceObject, "getAutosaves", function() { return resolvers_getAutosaves; });
|
|
994 |
__webpack_require__.d(resolvers_namespaceObject, "getAutosave", function() { return resolvers_getAutosave; });
|
|
995 |
|
|
996 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
997 |
var defineProperty = __webpack_require__(5);
|
|
998 |
|
|
999 |
// EXTERNAL MODULE: external {"this":["wp","data"]}
|
|
1000 |
var external_this_wp_data_ = __webpack_require__(4);
|
|
1001 |
|
|
1002 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
|
|
1003 |
var slicedToArray = __webpack_require__(14);
|
|
1004 |
|
|
1005 |
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
|
|
1006 |
var toConsumableArray = __webpack_require__(18);
|
|
1007 |
|
|
1008 |
// EXTERNAL MODULE: external {"this":"lodash"}
|
|
1009 |
var external_this_lodash_ = __webpack_require__(2);
|
|
1010 |
|
|
1011 |
// EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]}
|
|
1012 |
var external_this_wp_isShallowEqual_ = __webpack_require__(64);
|
|
1013 |
var external_this_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_isShallowEqual_);
|
|
1014 |
|
|
1015 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js
|
|
1016 |
/**
|
|
1017 |
* A higher-order reducer creator which invokes the original reducer only if
|
|
1018 |
* the dispatching action matches the given predicate, **OR** if state is
|
|
1019 |
* initializing (undefined).
|
|
1020 |
*
|
|
1021 |
* @param {Function} isMatch Function predicate for allowing reducer call.
|
|
1022 |
*
|
|
1023 |
* @return {Function} Higher-order reducer.
|
|
1024 |
*/
|
|
1025 |
var ifMatchingAction = function ifMatchingAction(isMatch) {
|
|
1026 |
return function (reducer) {
|
|
1027 |
return function (state, action) {
|
|
1028 |
if (state === undefined || isMatch(action)) {
|
|
1029 |
return reducer(state, action);
|
|
1030 |
}
|
|
1031 |
|
|
1032 |
return state;
|
|
1033 |
};
|
|
1034 |
};
|
|
1035 |
};
|
|
1036 |
|
|
1037 |
/* harmony default export */ var if_matching_action = (ifMatchingAction);
|
|
1038 |
|
|
1039 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/replace-action.js
|
|
1040 |
/**
|
|
1041 |
* Higher-order reducer creator which substitutes the action object before
|
|
1042 |
* passing to the original reducer.
|
|
1043 |
*
|
|
1044 |
* @param {Function} replacer Function mapping original action to replacement.
|
|
1045 |
*
|
|
1046 |
* @return {Function} Higher-order reducer.
|
|
1047 |
*/
|
|
1048 |
var replaceAction = function replaceAction(replacer) {
|
|
1049 |
return function (reducer) {
|
|
1050 |
return function (state, action) {
|
|
1051 |
return reducer(state, replacer(action));
|
|
1052 |
};
|
|
1053 |
};
|
|
1054 |
};
|
|
1055 |
|
|
1056 |
/* harmony default export */ var replace_action = (replaceAction);
|
|
1057 |
|
|
1058 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/conservative-map-item.js
|
|
1059 |
/**
|
|
1060 |
* External dependencies
|
|
1061 |
*/
|
|
1062 |
|
|
1063 |
/**
|
|
1064 |
* Given the current and next item entity, returns the minimally "modified"
|
|
1065 |
* result of the next item, preferring value references from the original item
|
|
1066 |
* if equal. If all values match, the original item is returned.
|
|
1067 |
*
|
|
1068 |
* @param {Object} item Original item.
|
|
1069 |
* @param {Object} nextItem Next item.
|
|
1070 |
*
|
|
1071 |
* @return {Object} Minimally modified merged item.
|
|
1072 |
*/
|
|
1073 |
|
|
1074 |
function conservativeMapItem(item, nextItem) {
|
|
1075 |
// Return next item in its entirety if there is no original item.
|
|
1076 |
if (!item) {
|
|
1077 |
return nextItem;
|
|
1078 |
}
|
|
1079 |
|
|
1080 |
var hasChanges = false;
|
|
1081 |
var result = {};
|
|
1082 |
|
|
1083 |
for (var key in nextItem) {
|
|
1084 |
if (Object(external_this_lodash_["isEqual"])(item[key], nextItem[key])) {
|
|
1085 |
result[key] = item[key];
|
|
1086 |
} else {
|
|
1087 |
hasChanges = true;
|
|
1088 |
result[key] = nextItem[key];
|
|
1089 |
}
|
|
1090 |
}
|
|
1091 |
|
|
1092 |
if (!hasChanges) {
|
|
1093 |
return item;
|
|
1094 |
}
|
|
1095 |
|
|
1096 |
return result;
|
|
1097 |
}
|
|
1098 |
|
|
1099 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/on-sub-key.js
|
|
1100 |
|
|
1101 |
|
|
1102 |
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
1103 |
|
|
1104 |
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1105 |
|
|
1106 |
/**
|
|
1107 |
* Higher-order reducer creator which creates a combined reducer object, keyed
|
|
1108 |
* by a property on the action object.
|
|
1109 |
*
|
|
1110 |
* @param {string} actionProperty Action property by which to key object.
|
|
1111 |
*
|
|
1112 |
* @return {Function} Higher-order reducer.
|
|
1113 |
*/
|
|
1114 |
var on_sub_key_onSubKey = function onSubKey(actionProperty) {
|
|
1115 |
return function (reducer) {
|
|
1116 |
return function () {
|
|
1117 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1118 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
1119 |
// Retrieve subkey from action. Do not track if undefined; useful for cases
|
|
1120 |
// where reducer is scoped by action shape.
|
|
1121 |
var key = action[actionProperty];
|
|
1122 |
|
|
1123 |
if (key === undefined) {
|
|
1124 |
return state;
|
|
1125 |
} // Avoid updating state if unchanged. Note that this also accounts for a
|
|
1126 |
// reducer which returns undefined on a key which is not yet tracked.
|
|
1127 |
|
|
1128 |
|
|
1129 |
var nextKeyState = reducer(state[key], action);
|
|
1130 |
|
|
1131 |
if (nextKeyState === state[key]) {
|
|
1132 |
return state;
|
|
1133 |
}
|
|
1134 |
|
|
1135 |
return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, key, nextKeyState));
|
|
1136 |
};
|
|
1137 |
};
|
|
1138 |
};
|
|
1139 |
/* harmony default export */ var on_sub_key = (on_sub_key_onSubKey);
|
|
1140 |
|
|
1141 |
// EXTERNAL MODULE: external {"this":"regeneratorRuntime"}
|
|
1142 |
var external_this_regeneratorRuntime_ = __webpack_require__(24);
|
|
1143 |
var external_this_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_this_regeneratorRuntime_);
|
|
1144 |
|
|
1145 |
// EXTERNAL MODULE: external {"this":["wp","i18n"]}
|
|
1146 |
var external_this_wp_i18n_ = __webpack_require__(1);
|
|
1147 |
|
|
1148 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/actions.js
|
|
1149 |
|
|
1150 |
|
|
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; }
|
|
1152 |
|
|
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));
|
|
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
|
|
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);
|
|
2228 |
};
|
|
2229 |
/**
|
|
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);
|
|
2290 |
|
|
2291 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js
|
|
2292 |
/**
|
|
2293 |
* External dependencies
|
|
2294 |
*/
|
|
2295 |
|
|
2296 |
/**
|
|
2297 |
* Given a function, returns an enhanced function which caches the result and
|
|
2298 |
* tracks in WeakMap. The result is only cached if the original function is
|
|
2299 |
* passed a valid object-like argument (requirement for WeakMap key).
|
|
2300 |
*
|
|
2301 |
* @param {Function} fn Original function.
|
|
2302 |
*
|
|
2303 |
* @return {Function} Enhanced caching function.
|
|
2304 |
*/
|
|
2305 |
|
|
2306 |
function withWeakMapCache(fn) {
|
|
2307 |
var cache = new WeakMap();
|
|
2308 |
return function (key) {
|
|
2309 |
var value;
|
|
2310 |
|
|
2311 |
if (cache.has(key)) {
|
|
2312 |
value = cache.get(key);
|
|
2313 |
} else {
|
|
2314 |
value = fn(key); // Can reach here if key is not valid for WeakMap, since `has`
|
|
2315 |
// will return false for invalid key. Since `set` will throw,
|
|
2316 |
// ensure that key is valid before setting into cache.
|
|
2317 |
|
|
2318 |
if (Object(external_this_lodash_["isObjectLike"])(key)) {
|
|
2319 |
cache.set(key, value);
|
|
2320 |
}
|
|
2321 |
}
|
|
2322 |
|
|
2323 |
return value;
|
|
2324 |
};
|
|
2325 |
}
|
|
2326 |
|
|
2327 |
/* harmony default export */ var with_weak_map_cache = (withWeakMapCache);
|
|
2328 |
|
|
2329 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/get-query-parts.js
|
|
2330 |
|
|
2331 |
|
|
2332 |
/**
|
|
2333 |
* WordPress dependencies
|
|
2334 |
*/
|
|
2335 |
|
|
2336 |
/**
|
|
2337 |
* Internal dependencies
|
|
2338 |
*/
|
|
2339 |
|
|
2340 |
|
|
2341 |
/**
|
|
2342 |
* An object of properties describing a specific query.
|
|
2343 |
*
|
|
2344 |
* @typedef {Object} WPQueriedDataQueryParts
|
|
2345 |
*
|
|
2346 |
* @property {number} page The query page (1-based index, default 1).
|
|
2347 |
* @property {number} perPage Items per page for query (default 10).
|
|
2348 |
* @property {string} stableKey An encoded stable string of all non-pagination
|
|
2349 |
* query parameters.
|
|
2350 |
*/
|
|
2351 |
|
|
2352 |
/**
|
|
2353 |
* Given a query object, returns an object of parts, including pagination
|
|
2354 |
* details (`page` and `perPage`, or default values). All other properties are
|
|
2355 |
* encoded into a stable (idempotent) `stableKey` value.
|
|
2356 |
*
|
|
2357 |
* @param {Object} query Optional query object.
|
|
2358 |
*
|
|
2359 |
* @return {WPQueriedDataQueryParts} Query parts.
|
|
2360 |
*/
|
|
2361 |
|
|
2362 |
function getQueryParts(query) {
|
|
2363 |
/**
|
|
2364 |
* @type {WPQueriedDataQueryParts}
|
|
2365 |
*/
|
|
2366 |
var parts = {
|
|
2367 |
stableKey: '',
|
|
2368 |
page: 1,
|
|
2369 |
perPage: 10
|
|
2370 |
}; // Ensure stable key by sorting keys. Also more efficient for iterating.
|
|
2371 |
|
|
2372 |
var keys = Object.keys(query).sort();
|
|
2373 |
|
|
2374 |
for (var i = 0; i < keys.length; i++) {
|
|
2375 |
var key = keys[i];
|
|
2376 |
var value = query[key];
|
|
2377 |
|
|
2378 |
switch (key) {
|
|
2379 |
case 'page':
|
|
2380 |
parts[key] = Number(value);
|
|
2381 |
break;
|
|
2382 |
|
|
2383 |
case 'per_page':
|
|
2384 |
parts.perPage = Number(value);
|
|
2385 |
break;
|
|
2386 |
|
|
2387 |
default:
|
|
2388 |
// While it could be any deterministic string, for simplicity's
|
|
2389 |
// sake mimic querystring encoding for stable key.
|
|
2390 |
//
|
|
2391 |
// TODO: For consistency with PHP implementation, addQueryArgs
|
|
2392 |
// should accept a key value pair, which may optimize its
|
|
2393 |
// implementation for our use here, vs. iterating an object
|
|
2394 |
// with only a single key.
|
|
2395 |
parts.stableKey += (parts.stableKey ? '&' : '') + Object(external_this_wp_url_["addQueryArgs"])('', Object(defineProperty["a" /* default */])({}, key, value)).slice(1);
|
|
2396 |
}
|
|
2397 |
}
|
|
2398 |
|
|
2399 |
return parts;
|
|
2400 |
}
|
|
2401 |
/* harmony default export */ var get_query_parts = (with_weak_map_cache(getQueryParts));
|
|
2402 |
|
|
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 |
|
|
2410 |
/**
|
|
2411 |
* External dependencies
|
|
2412 |
*/
|
|
2413 |
|
|
2414 |
/**
|
|
2415 |
* WordPress dependencies
|
|
2416 |
*/
|
|
2417 |
|
|
2418 |
|
|
2419 |
/**
|
|
2420 |
* Internal dependencies
|
|
2421 |
*/
|
|
2422 |
|
|
2423 |
|
|
2424 |
|
|
2425 |
|
|
2426 |
/**
|
|
2427 |
* Returns a merged array of item IDs, given details of the received paginated
|
|
2428 |
* items. The array is sparse-like with `undefined` entries where holes exist.
|
|
2429 |
*
|
|
2430 |
* @param {?Array<number>} itemIds Original item IDs (default empty array).
|
|
2431 |
* @param {number[]} nextItemIds Item IDs to merge.
|
|
2432 |
* @param {number} page Page of items merged.
|
|
2433 |
* @param {number} perPage Number of items per page.
|
|
2434 |
*
|
|
2435 |
* @return {number[]} Merged array of item IDs.
|
|
2436 |
*/
|
|
2437 |
|
|
2438 |
function getMergedItemIds(itemIds, nextItemIds, page, perPage) {
|
|
2439 |
var receivedAllIds = page === 1 && perPage === -1;
|
|
2440 |
|
|
2441 |
if (receivedAllIds) {
|
|
2442 |
return nextItemIds;
|
|
2443 |
}
|
|
2444 |
|
|
2445 |
var nextItemIdsStartIndex = (page - 1) * perPage; // If later page has already been received, default to the larger known
|
|
2446 |
// size of the existing array, else calculate as extending the existing.
|
|
2447 |
|
|
2448 |
var size = Math.max(itemIds.length, nextItemIdsStartIndex + nextItemIds.length); // Preallocate array since size is known.
|
|
2449 |
|
|
2450 |
var mergedItemIds = new Array(size);
|
|
2451 |
|
|
2452 |
for (var i = 0; i < size; i++) {
|
|
2453 |
// Preserve existing item ID except for subset of range of next items.
|
|
2454 |
var isInNextItemsRange = i >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + nextItemIds.length;
|
|
2455 |
mergedItemIds[i] = isInNextItemsRange ? nextItemIds[i - nextItemIdsStartIndex] : itemIds[i];
|
|
2456 |
}
|
|
2457 |
|
|
2458 |
return mergedItemIds;
|
|
2459 |
}
|
|
2460 |
/**
|
|
2461 |
* Reducer tracking items state, keyed by ID. Items are assumed to be normal,
|
|
2462 |
* where identifiers are common across all queries.
|
|
2463 |
*
|
|
2464 |
* @param {Object} state Current state.
|
|
2465 |
* @param {Object} action Dispatched action.
|
|
2466 |
*
|
|
2467 |
* @return {Object} Next state.
|
|
2468 |
*/
|
|
2469 |
|
|
2470 |
function reducer_items() {
|
|
2471 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2472 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2473 |
|
|
2474 |
switch (action.type) {
|
|
2475 |
case 'RECEIVE_ITEMS':
|
|
2476 |
var key = action.key || DEFAULT_ENTITY_KEY;
|
|
2477 |
return reducer_objectSpread({}, state, {}, action.items.reduce(function (accumulator, value) {
|
|
2478 |
var itemId = value[key];
|
|
2479 |
accumulator[itemId] = conservativeMapItem(state[itemId], value);
|
|
2480 |
return accumulator;
|
|
2481 |
}, {}));
|
|
2482 |
}
|
|
2483 |
|
|
2484 |
return state;
|
|
2485 |
}
|
|
2486 |
/**
|
|
2487 |
* Reducer tracking queries state, keyed by stable query key. Each reducer
|
|
2488 |
* query object includes `itemIds` and `requestingPageByPerPage`.
|
|
2489 |
*
|
|
2490 |
* @param {Object} state Current state.
|
|
2491 |
* @param {Object} action Dispatched action.
|
|
2492 |
*
|
|
2493 |
* @return {Object} Next state.
|
|
2494 |
*/
|
|
2495 |
|
|
2496 |
|
|
2497 |
var queries = Object(external_this_lodash_["flowRight"])([// Limit to matching action type so we don't attempt to replace action on
|
|
2498 |
// an unhandled action.
|
|
2499 |
if_matching_action(function (action) {
|
|
2500 |
return 'query' in action;
|
|
2501 |
}), // Inject query parts into action for use both in `onSubKey` and reducer.
|
|
2502 |
replace_action(function (action) {
|
|
2503 |
// `ifMatchingAction` still passes on initialization, where state is
|
|
2504 |
// undefined and a query is not assigned. Avoid attempting to parse
|
|
2505 |
// parts. `onSubKey` will omit by lack of `stableKey`.
|
|
2506 |
if (action.query) {
|
|
2507 |
return reducer_objectSpread({}, action, {}, get_query_parts(action.query));
|
|
2508 |
}
|
|
2509 |
|
|
2510 |
return action;
|
|
2511 |
}), // Queries shape is shared, but keyed by query `stableKey` part. Original
|
|
2512 |
// reducer tracks only a single query object.
|
|
2513 |
on_sub_key('stableKey')])(function () {
|
|
2514 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
2515 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2516 |
var type = action.type,
|
|
2517 |
page = action.page,
|
|
2518 |
perPage = action.perPage,
|
|
2519 |
_action$key = action.key,
|
|
2520 |
key = _action$key === void 0 ? DEFAULT_ENTITY_KEY : _action$key;
|
|
2521 |
|
|
2522 |
if (type !== 'RECEIVE_ITEMS') {
|
|
2523 |
return state;
|
|
2524 |
}
|
|
2525 |
|
|
2526 |
return getMergedItemIds(state || [], Object(external_this_lodash_["map"])(action.items, key), page, perPage);
|
|
2527 |
});
|
|
2528 |
/* harmony default export */ var queried_data_reducer = (Object(external_this_wp_data_["combineReducers"])({
|
|
2529 |
items: reducer_items,
|
|
2530 |
queries: queries
|
|
2531 |
}));
|
|
2532 |
|
|
2533 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/reducer.js
|
|
2534 |
|
|
2535 |
|
|
2536 |
|
|
2537 |
|
|
2538 |
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2539 |
|
|
2540 |
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
2541 |
|
|
2542 |
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
2543 |
|
|
2544 |
function build_module_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; }
|
|
2545 |
|
|
2546 |
function build_module_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { build_module_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 { build_module_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2547 |
|
|
2548 |
/**
|
|
2549 |
* External dependencies
|
|
2550 |
*/
|
|
2551 |
|
|
2552 |
/**
|
|
2553 |
* WordPress dependencies
|
|
2554 |
*/
|
|
2555 |
|
|
2556 |
|
|
2557 |
|
|
2558 |
/**
|
|
2559 |
* Internal dependencies
|
|
2560 |
*/
|
|
2561 |
|
|
2562 |
|
|
2563 |
|
|
2564 |
|
|
2565 |
/**
|
|
2566 |
* Reducer managing terms state. Keyed by taxonomy slug, the value is either
|
|
2567 |
* undefined (if no request has been made for given taxonomy), null (if a
|
|
2568 |
* request is in-flight for given taxonomy), or the array of terms for the
|
|
2569 |
* taxonomy.
|
|
2570 |
*
|
|
2571 |
* @param {Object} state Current state.
|
|
2572 |
* @param {Object} action Dispatched action.
|
|
2573 |
*
|
|
2574 |
* @return {Object} Updated state.
|
|
2575 |
*/
|
|
2576 |
|
|
2577 |
function terms() {
|
|
2578 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2579 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2580 |
|
|
2581 |
switch (action.type) {
|
|
2582 |
case 'RECEIVE_TERMS':
|
|
2583 |
return build_module_reducer_objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.taxonomy, action.terms));
|
|
2584 |
}
|
|
2585 |
|
|
2586 |
return state;
|
|
2587 |
}
|
|
2588 |
/**
|
|
2589 |
* Reducer managing authors state. Keyed by id.
|
|
2590 |
*
|
|
2591 |
* @param {Object} state Current state.
|
|
2592 |
* @param {Object} action Dispatched action.
|
|
2593 |
*
|
|
2594 |
* @return {Object} Updated state.
|
|
2595 |
*/
|
|
2596 |
|
|
2597 |
function reducer_users() {
|
|
2598 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
2599 |
byId: {},
|
|
2600 |
queries: {}
|
|
2601 |
};
|
|
2602 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2603 |
|
|
2604 |
switch (action.type) {
|
|
2605 |
case 'RECEIVE_USER_QUERY':
|
|
2606 |
return {
|
|
2607 |
byId: build_module_reducer_objectSpread({}, state.byId, {}, Object(external_this_lodash_["keyBy"])(action.users, 'id')),
|
|
2608 |
queries: build_module_reducer_objectSpread({}, state.queries, Object(defineProperty["a" /* default */])({}, action.queryID, Object(external_this_lodash_["map"])(action.users, function (user) {
|
|
2609 |
return user.id;
|
|
2610 |
})))
|
|
2611 |
};
|
|
2612 |
}
|
|
2613 |
|
|
2614 |
return state;
|
|
2615 |
}
|
|
2616 |
/**
|
|
2617 |
* Reducer managing current user state.
|
|
2618 |
*
|
|
2619 |
* @param {Object} state Current state.
|
|
2620 |
* @param {Object} action Dispatched action.
|
|
2621 |
*
|
|
2622 |
* @return {Object} Updated state.
|
|
2623 |
*/
|
|
2624 |
|
|
2625 |
function reducer_currentUser() {
|
|
2626 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2627 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2628 |
|
|
2629 |
switch (action.type) {
|
|
2630 |
case 'RECEIVE_CURRENT_USER':
|
|
2631 |
return action.currentUser;
|
|
2632 |
}
|
|
2633 |
|
|
2634 |
return state;
|
|
2635 |
}
|
|
2636 |
/**
|
|
2637 |
* Reducer managing taxonomies.
|
|
2638 |
*
|
|
2639 |
* @param {Object} state Current state.
|
|
2640 |
* @param {Object} action Dispatched action.
|
|
2641 |
*
|
|
2642 |
* @return {Object} Updated state.
|
|
2643 |
*/
|
|
2644 |
|
|
2645 |
function reducer_taxonomies() {
|
|
2646 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2647 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2648 |
|
|
2649 |
switch (action.type) {
|
|
2650 |
case 'RECEIVE_TAXONOMIES':
|
|
2651 |
return action.taxonomies;
|
|
2652 |
}
|
|
2653 |
|
|
2654 |
return state;
|
|
2655 |
}
|
|
2656 |
/**
|
|
2657 |
* Reducer managing the current theme.
|
|
2658 |
*
|
|
2659 |
* @param {string} state Current state.
|
|
2660 |
* @param {Object} action Dispatched action.
|
|
2661 |
*
|
|
2662 |
* @return {string} Updated state.
|
|
2663 |
*/
|
|
2664 |
|
|
2665 |
function currentTheme() {
|
|
2666 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
|
|
2667 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2668 |
|
|
2669 |
switch (action.type) {
|
|
2670 |
case 'RECEIVE_CURRENT_THEME':
|
|
2671 |
return action.currentTheme.stylesheet;
|
|
2672 |
}
|
|
2673 |
|
|
2674 |
return state;
|
|
2675 |
}
|
|
2676 |
/**
|
|
2677 |
* Reducer managing installed themes.
|
|
2678 |
*
|
|
2679 |
* @param {Object} state Current state.
|
|
2680 |
* @param {Object} action Dispatched action.
|
|
2681 |
*
|
|
2682 |
* @return {Object} Updated state.
|
|
2683 |
*/
|
|
2684 |
|
|
2685 |
function themes() {
|
|
2686 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2687 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2688 |
|
|
2689 |
switch (action.type) {
|
|
2690 |
case 'RECEIVE_CURRENT_THEME':
|
|
2691 |
return build_module_reducer_objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.currentTheme.stylesheet, action.currentTheme));
|
|
2692 |
}
|
|
2693 |
|
|
2694 |
return state;
|
|
2695 |
}
|
|
2696 |
/**
|
|
2697 |
* Reducer managing theme supports data.
|
|
2698 |
*
|
|
2699 |
* @param {Object} state Current state.
|
|
2700 |
* @param {Object} action Dispatched action.
|
|
2701 |
*
|
|
2702 |
* @return {Object} Updated state.
|
|
2703 |
*/
|
|
2704 |
|
|
2705 |
function themeSupports() {
|
|
2706 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2707 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2708 |
|
|
2709 |
switch (action.type) {
|
|
2710 |
case 'RECEIVE_THEME_SUPPORTS':
|
|
2711 |
return build_module_reducer_objectSpread({}, state, {}, action.themeSupports);
|
|
2712 |
}
|
|
2713 |
|
|
2714 |
return state;
|
|
2715 |
}
|
|
2716 |
/**
|
|
2717 |
* Higher Order Reducer for a given entity config. It supports:
|
|
2718 |
*
|
|
2719 |
* - Fetching
|
|
2720 |
* - Editing
|
|
2721 |
* - Saving
|
|
2722 |
*
|
|
2723 |
* @param {Object} entityConfig Entity config.
|
|
2724 |
*
|
|
2725 |
* @return {Function} Reducer.
|
|
2726 |
*/
|
|
2727 |
|
|
2728 |
function reducer_entity(entityConfig) {
|
|
2729 |
return Object(external_this_lodash_["flowRight"])([// Limit to matching action type so we don't attempt to replace action on
|
|
2730 |
// an unhandled action.
|
|
2731 |
if_matching_action(function (action) {
|
|
2732 |
return action.name && action.kind && action.name === entityConfig.name && action.kind === entityConfig.kind;
|
|
2733 |
}), // Inject the entity config into the action.
|
|
2734 |
replace_action(function (action) {
|
|
2735 |
return build_module_reducer_objectSpread({}, action, {
|
|
2736 |
key: entityConfig.key || DEFAULT_ENTITY_KEY
|
|
2737 |
});
|
|
2738 |
})])(Object(external_this_wp_data_["combineReducers"])({
|
|
2739 |
queriedData: queried_data_reducer,
|
|
2740 |
edits: function edits() {
|
|
2741 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2742 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2743 |
|
|
2744 |
switch (action.type) {
|
|
2745 |
case 'RECEIVE_ITEMS':
|
|
2746 |
var nextState = build_module_reducer_objectSpread({}, state);
|
|
2747 |
|
|
2748 |
var _iterator = _createForOfIteratorHelper(action.items),
|
|
2749 |
_step;
|
|
2750 |
|
|
2751 |
try {
|
|
2752 |
var _loop = function _loop() {
|
|
2753 |
var record = _step.value;
|
|
2754 |
var recordId = record[action.key];
|
|
2755 |
var edits = nextState[recordId];
|
|
2756 |
|
|
2757 |
if (!edits) {
|
|
2758 |
return "continue";
|
|
2759 |
}
|
|
2760 |
|
|
2761 |
var nextEdits = Object.keys(edits).reduce(function (acc, key) {
|
|
2762 |
// If the edited value is still different to the persisted value,
|
|
2763 |
// keep the edited value in edits.
|
|
2764 |
if ( // Edits are the "raw" attribute values, but records may have
|
|
2765 |
// objects with more properties, so we use `get` here for the
|
|
2766 |
// comparison.
|
|
2767 |
!Object(external_this_lodash_["isEqual"])(edits[key], Object(external_this_lodash_["get"])(record[key], 'raw', record[key]))) {
|
|
2768 |
acc[key] = edits[key];
|
|
2769 |
}
|
|
2770 |
|
|
2771 |
return acc;
|
|
2772 |
}, {});
|
|
2773 |
|
|
2774 |
if (Object.keys(nextEdits).length) {
|
|
2775 |
nextState[recordId] = nextEdits;
|
|
2776 |
} else {
|
|
2777 |
delete nextState[recordId];
|
|
2778 |
}
|
|
2779 |
};
|
|
2780 |
|
|
2781 |
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2782 |
var _ret = _loop();
|
|
2783 |
|
|
2784 |
if (_ret === "continue") continue;
|
|
2785 |
}
|
|
2786 |
} catch (err) {
|
|
2787 |
_iterator.e(err);
|
|
2788 |
} finally {
|
|
2789 |
_iterator.f();
|
|
2790 |
}
|
|
2791 |
|
|
2792 |
return nextState;
|
|
2793 |
|
|
2794 |
case 'EDIT_ENTITY_RECORD':
|
|
2795 |
var nextEdits = build_module_reducer_objectSpread({}, state[action.recordId], {}, action.edits);
|
|
2796 |
|
|
2797 |
Object.keys(nextEdits).forEach(function (key) {
|
|
2798 |
// Delete cleared edits so that the properties
|
|
2799 |
// are not considered dirty.
|
|
2800 |
if (nextEdits[key] === undefined) {
|
|
2801 |
delete nextEdits[key];
|
|
2802 |
}
|
|
2803 |
});
|
|
2804 |
return build_module_reducer_objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.recordId, nextEdits));
|
|
2805 |
}
|
|
2806 |
|
|
2807 |
return state;
|
|
2808 |
},
|
|
2809 |
saving: function saving() {
|
|
2810 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2811 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2812 |
|
|
2813 |
switch (action.type) {
|
|
2814 |
case 'SAVE_ENTITY_RECORD_START':
|
|
2815 |
case 'SAVE_ENTITY_RECORD_FINISH':
|
|
2816 |
return build_module_reducer_objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.recordId, {
|
|
2817 |
pending: action.type === 'SAVE_ENTITY_RECORD_START',
|
|
2818 |
error: action.error,
|
|
2819 |
isAutosave: action.isAutosave
|
|
2820 |
}));
|
|
2821 |
}
|
|
2822 |
|
|
2823 |
return state;
|
|
2824 |
}
|
|
2825 |
}));
|
|
2826 |
}
|
|
2827 |
/**
|
|
2828 |
* Reducer keeping track of the registered entities.
|
|
2829 |
*
|
|
2830 |
* @param {Object} state Current state.
|
|
2831 |
* @param {Object} action Dispatched action.
|
|
2832 |
*
|
|
2833 |
* @return {Object} Updated state.
|
|
2834 |
*/
|
|
2835 |
|
|
2836 |
|
|
2837 |
function entitiesConfig() {
|
|
2838 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultEntities;
|
|
2839 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2840 |
|
|
2841 |
switch (action.type) {
|
|
2842 |
case 'ADD_ENTITIES':
|
|
2843 |
return [].concat(Object(toConsumableArray["a" /* default */])(state), Object(toConsumableArray["a" /* default */])(action.entities));
|
|
2844 |
}
|
|
2845 |
|
|
2846 |
return state;
|
|
2847 |
}
|
|
2848 |
/**
|
|
2849 |
* Reducer keeping track of the registered entities config and data.
|
|
2850 |
*
|
|
2851 |
* @param {Object} state Current state.
|
|
2852 |
* @param {Object} action Dispatched action.
|
|
2853 |
*
|
|
2854 |
* @return {Object} Updated state.
|
|
2855 |
*/
|
|
2856 |
|
|
2857 |
var reducer_entities = function entities() {
|
|
2858 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2859 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2860 |
var newConfig = entitiesConfig(state.config, action); // Generates a dynamic reducer for the entities
|
|
2861 |
|
|
2862 |
var entitiesDataReducer = state.reducer;
|
|
2863 |
|
|
2864 |
if (!entitiesDataReducer || newConfig !== state.config) {
|
|
2865 |
var entitiesByKind = Object(external_this_lodash_["groupBy"])(newConfig, 'kind');
|
|
2866 |
entitiesDataReducer = Object(external_this_wp_data_["combineReducers"])(Object.entries(entitiesByKind).reduce(function (memo, _ref) {
|
|
2867 |
var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 2),
|
|
2868 |
kind = _ref2[0],
|
|
2869 |
subEntities = _ref2[1];
|
|
2870 |
|
|
2871 |
var kindReducer = Object(external_this_wp_data_["combineReducers"])(subEntities.reduce(function (kindMemo, entityConfig) {
|
|
2872 |
return build_module_reducer_objectSpread({}, kindMemo, Object(defineProperty["a" /* default */])({}, entityConfig.name, reducer_entity(entityConfig)));
|
|
2873 |
}, {}));
|
|
2874 |
memo[kind] = kindReducer;
|
|
2875 |
return memo;
|
|
2876 |
}, {}));
|
|
2877 |
}
|
|
2878 |
|
|
2879 |
var newData = entitiesDataReducer(state.data, action);
|
|
2880 |
|
|
2881 |
if (newData === state.data && newConfig === state.config && entitiesDataReducer === state.reducer) {
|
|
2882 |
return state;
|
|
2883 |
}
|
|
2884 |
|
|
2885 |
return {
|
|
2886 |
reducer: entitiesDataReducer,
|
|
2887 |
data: newData,
|
|
2888 |
config: newConfig
|
|
2889 |
};
|
|
2890 |
};
|
|
2891 |
/**
|
|
2892 |
* Reducer keeping track of entity edit undo history.
|
|
2893 |
*
|
|
2894 |
* @param {Object} state Current state.
|
|
2895 |
* @param {Object} action Dispatched action.
|
|
2896 |
*
|
|
2897 |
* @return {Object} Updated state.
|
|
2898 |
*/
|
|
2899 |
|
|
2900 |
var UNDO_INITIAL_STATE = [];
|
|
2901 |
UNDO_INITIAL_STATE.offset = 0;
|
|
2902 |
var lastEditAction;
|
|
2903 |
function reducer_undo() {
|
|
2904 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UNDO_INITIAL_STATE;
|
|
2905 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
2906 |
|
|
2907 |
switch (action.type) {
|
|
2908 |
case 'EDIT_ENTITY_RECORD':
|
|
2909 |
case 'CREATE_UNDO_LEVEL':
|
|
2910 |
var isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL';
|
|
2911 |
var isUndoOrRedo = !isCreateUndoLevel && (action.meta.isUndo || action.meta.isRedo);
|
|
2912 |
|
|
2913 |
if (isCreateUndoLevel) {
|
|
2914 |
action = lastEditAction;
|
|
2915 |
} else if (!isUndoOrRedo) {
|
|
2916 |
// Don't lose the last edit cache if the new one only has transient edits.
|
|
2917 |
// Transient edits don't create new levels so updating the cache would make
|
|
2918 |
// us skip an edit later when creating levels explicitly.
|
|
2919 |
if (Object.keys(action.edits).some(function (key) {
|
|
2920 |
return !action.transientEdits[key];
|
|
2921 |
})) {
|
|
2922 |
lastEditAction = action;
|
|
2923 |
} else {
|
|
2924 |
lastEditAction = build_module_reducer_objectSpread({}, action, {
|
|
2925 |
edits: build_module_reducer_objectSpread({}, lastEditAction && lastEditAction.edits, {}, action.edits)
|
|
2926 |
});
|
|
2927 |
}
|
|
2928 |
}
|
|
2929 |
|
|
2930 |
var nextState;
|
|
2931 |
|
|
2932 |
if (isUndoOrRedo) {
|
|
2933 |
nextState = Object(toConsumableArray["a" /* default */])(state);
|
|
2934 |
nextState.offset = state.offset + (action.meta.isUndo ? -1 : 1);
|
|
2935 |
|
|
2936 |
if (state.flattenedUndo) {
|
|
2937 |
// The first undo in a sequence of undos might happen while we have
|
|
2938 |
// flattened undos in state. If this is the case, we want execution
|
|
2939 |
// to continue as if we were creating an explicit undo level. This
|
|
2940 |
// will result in an extra undo level being appended with the flattened
|
|
2941 |
// undo values.
|
|
2942 |
isCreateUndoLevel = true;
|
|
2943 |
action = lastEditAction;
|
|
2944 |
} else {
|
|
2945 |
return nextState;
|
|
2946 |
}
|
|
2947 |
}
|
|
2948 |
|
|
2949 |
if (!action.meta.undo) {
|
|
2950 |
return state;
|
|
2951 |
} // Transient edits don't create an undo level, but are
|
|
2952 |
// reachable in the next meaningful edit to which they
|
|
2953 |
// are merged. They are defined in the entity's config.
|
|
2954 |
|
|
2955 |
|
|
2956 |
if (!isCreateUndoLevel && !Object.keys(action.edits).some(function (key) {
|
|
2957 |
return !action.transientEdits[key];
|
|
2958 |
})) {
|
|
2959 |
nextState = Object(toConsumableArray["a" /* default */])(state);
|
|
2960 |
nextState.flattenedUndo = build_module_reducer_objectSpread({}, state.flattenedUndo, {}, action.edits);
|
|
2961 |
nextState.offset = state.offset;
|
|
2962 |
return nextState;
|
|
2963 |
} // Clear potential redos, because this only supports linear history.
|
|
2964 |
|
|
2965 |
|
|
2966 |
nextState = nextState || state.slice(0, state.offset || undefined);
|
|
2967 |
nextState.offset = nextState.offset || 0;
|
|
2968 |
nextState.pop();
|
|
2969 |
|
|
2970 |
if (!isCreateUndoLevel) {
|
|
2971 |
nextState.push({
|
|
2972 |
kind: action.meta.undo.kind,
|
|
2973 |
name: action.meta.undo.name,
|
|
2974 |
recordId: action.meta.undo.recordId,
|
|
2975 |
edits: build_module_reducer_objectSpread({}, state.flattenedUndo, {}, action.meta.undo.edits)
|
|
2976 |
});
|
|
2977 |
} // When an edit is a function it's an optimization to avoid running some expensive operation.
|
|
2978 |
// We can't rely on the function references being the same so we opt out of comparing them here.
|
|
2979 |
|
|
2980 |
|
|
2981 |
var comparisonUndoEdits = Object.values(action.meta.undo.edits).filter(function (edit) {
|
|
2982 |
return typeof edit !== 'function';
|
|
2983 |
});
|
|
2984 |
var comparisonEdits = Object.values(action.edits).filter(function (edit) {
|
|
2985 |
return typeof edit !== 'function';
|
|
2986 |
});
|
|
2987 |
|
|
2988 |
if (!external_this_wp_isShallowEqual_default()(comparisonUndoEdits, comparisonEdits)) {
|
|
2989 |
nextState.push({
|
|
2990 |
kind: action.kind,
|
|
2991 |
name: action.name,
|
|
2992 |
recordId: action.recordId,
|
|
2993 |
edits: isCreateUndoLevel ? build_module_reducer_objectSpread({}, state.flattenedUndo, {}, action.edits) : action.edits
|
|
2994 |
});
|
|
2995 |
}
|
|
2996 |
|
|
2997 |
return nextState;
|
|
2998 |
}
|
|
2999 |
|
|
3000 |
return state;
|
|
3001 |
}
|
|
3002 |
/**
|
|
3003 |
* Reducer managing embed preview data.
|
|
3004 |
*
|
|
3005 |
* @param {Object} state Current state.
|
|
3006 |
* @param {Object} action Dispatched action.
|
|
3007 |
*
|
|
3008 |
* @return {Object} Updated state.
|
|
3009 |
*/
|
|
3010 |
|
|
3011 |
function embedPreviews() {
|
|
3012 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3013 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
3014 |
|
|
3015 |
switch (action.type) {
|
|
3016 |
case 'RECEIVE_EMBED_PREVIEW':
|
|
3017 |
var url = action.url,
|
|
3018 |
preview = action.preview;
|
|
3019 |
return build_module_reducer_objectSpread({}, state, Object(defineProperty["a" /* default */])({}, url, preview));
|
|
3020 |
}
|
|
3021 |
|
|
3022 |
return state;
|
|
3023 |
}
|
|
3024 |
/**
|
|
3025 |
* State which tracks whether the user can perform an action on a REST
|
|
3026 |
* resource.
|
|
3027 |
*
|
|
3028 |
* @param {Object} state Current state.
|
|
3029 |
* @param {Object} action Dispatched action.
|
|
3030 |
*
|
|
3031 |
* @return {Object} Updated state.
|
|
3032 |
*/
|
|
3033 |
|
|
3034 |
function userPermissions() {
|
|
3035 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3036 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
3037 |
|
|
3038 |
switch (action.type) {
|
|
3039 |
case 'RECEIVE_USER_PERMISSION':
|
|
3040 |
return build_module_reducer_objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.key, action.isAllowed));
|
|
3041 |
}
|
|
3042 |
|
|
3043 |
return state;
|
|
3044 |
}
|
|
3045 |
/**
|
|
3046 |
* Reducer returning autosaves keyed by their parent's post id.
|
|
3047 |
*
|
|
3048 |
* @param {Object} state Current state.
|
|
3049 |
* @param {Object} action Dispatched action.
|
|
3050 |
*
|
|
3051 |
* @return {Object} Updated state.
|
|
3052 |
*/
|
|
3053 |
|
|
3054 |
function reducer_autosaves() {
|
|
3055 |
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3056 |
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
3057 |
|
|
3058 |
switch (action.type) {
|
|
3059 |
case 'RECEIVE_AUTOSAVES':
|
|
3060 |
var postId = action.postId,
|
|
3061 |
autosavesData = action.autosaves;
|
|
3062 |
return build_module_reducer_objectSpread({}, state, Object(defineProperty["a" /* default */])({}, postId, autosavesData));
|
|
3063 |
}
|
|
3064 |
|
|
3065 |
return state;
|
|
3066 |
}
|
|
3067 |
/* harmony default export */ var build_module_reducer = (Object(external_this_wp_data_["combineReducers"])({
|
|
3068 |
terms: terms,
|
|
3069 |
users: reducer_users,
|
|
3070 |
currentTheme: currentTheme,
|
|
3071 |
currentUser: reducer_currentUser,
|
|
3072 |
taxonomies: reducer_taxonomies,
|
|
3073 |
themes: themes,
|
|
3074 |
themeSupports: themeSupports,
|
|
3075 |
entities: reducer_entities,
|
|
3076 |
undo: reducer_undo,
|
|
3077 |
embedPreviews: embedPreviews,
|
|
3078 |
userPermissions: userPermissions,
|
|
3079 |
autosaves: reducer_autosaves
|
|
3080 |
}));
|
|
3081 |
|
|
3082 |
// EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js
|
|
3083 |
var rememo = __webpack_require__(42);
|
|
3084 |
|
|
3085 |
// EXTERNAL MODULE: external {"this":["wp","deprecated"]}
|
|
3086 |
var external_this_wp_deprecated_ = __webpack_require__(37);
|
|
3087 |
var external_this_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_deprecated_);
|
|
3088 |
|
|
3089 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/name.js
|
|
3090 |
/**
|
|
3091 |
* The reducer key used by core data in store registration.
|
|
3092 |
* This is defined in a separate file to avoid cycle-dependency
|
|
3093 |
*
|
|
3094 |
* @type {string}
|
|
3095 |
*/
|
|
3096 |
var REDUCER_KEY = 'core';
|
|
3097 |
|
|
3098 |
// EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
|
|
3099 |
var equivalent_key_map = __webpack_require__(126);
|
|
3100 |
var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
|
|
3101 |
|
|
3102 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/selectors.js
|
|
3103 |
/**
|
|
3104 |
* External dependencies
|
|
3105 |
*/
|
|
3106 |
|
|
3107 |
|
|
3108 |
/**
|
|
3109 |
* Internal dependencies
|
|
3110 |
*/
|
|
3111 |
|
|
3112 |
|
|
3113 |
/**
|
|
3114 |
* Cache of state keys to EquivalentKeyMap where the inner map tracks queries
|
|
3115 |
* to their resulting items set. WeakMap allows garbage collection on expired
|
|
3116 |
* state references.
|
|
3117 |
*
|
|
3118 |
* @type {WeakMap<Object,EquivalentKeyMap>}
|
|
3119 |
*/
|
|
3120 |
|
|
3121 |
var queriedItemsCacheByState = new WeakMap();
|
|
3122 |
/**
|
|
3123 |
* Returns items for a given query, or null if the items are not known.
|
|
3124 |
*
|
|
3125 |
* @param {Object} state State object.
|
|
3126 |
* @param {?Object} query Optional query.
|
|
3127 |
*
|
|
3128 |
* @return {?Array} Query items.
|
|
3129 |
*/
|
|
3130 |
|
|
3131 |
function getQueriedItemsUncached(state, query) {
|
|
3132 |
var _getQueryParts = get_query_parts(query),
|
|
3133 |
stableKey = _getQueryParts.stableKey,
|
|
3134 |
page = _getQueryParts.page,
|
|
3135 |
perPage = _getQueryParts.perPage;
|
|
3136 |
|
|
3137 |
if (!state.queries[stableKey]) {
|
|
3138 |
return null;
|
|
3139 |
}
|
|
3140 |
|
|
3141 |
var itemIds = state.queries[stableKey];
|
|
3142 |
|
|
3143 |
if (!itemIds) {
|
|
3144 |
return null;
|
|
3145 |
}
|
|
3146 |
|
|
3147 |
var startOffset = perPage === -1 ? 0 : (page - 1) * perPage;
|
|
3148 |
var endOffset = perPage === -1 ? itemIds.length : Math.min(startOffset + perPage, itemIds.length);
|
|
3149 |
var items = [];
|
|
3150 |
|
|
3151 |
for (var i = startOffset; i < endOffset; i++) {
|
|
3152 |
var itemId = itemIds[i];
|
|
3153 |
items.push(state.items[itemId]);
|
|
3154 |
}
|
|
3155 |
|
|
3156 |
return items;
|
|
3157 |
}
|
|
3158 |
/**
|
|
3159 |
* Returns items for a given query, or null if the items are not known. Caches
|
|
3160 |
* result both per state (by reference) and per query (by deep equality).
|
|
3161 |
* The caching approach is intended to be durable to query objects which are
|
|
3162 |
* deeply but not referentially equal, since otherwise:
|
|
3163 |
*
|
|
3164 |
* `getQueriedItems( state, {} ) !== getQueriedItems( state, {} )`
|
|
3165 |
*
|
|
3166 |
* @param {Object} state State object.
|
|
3167 |
* @param {?Object} query Optional query.
|
|
3168 |
*
|
|
3169 |
* @return {?Array} Query items.
|
|
3170 |
*/
|
|
3171 |
|
|
3172 |
|
|
3173 |
var getQueriedItems = Object(rememo["a" /* default */])(function (state) {
|
|
3174 |
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3175 |
var queriedItemsCache = queriedItemsCacheByState.get(state);
|
|
3176 |
|
|
3177 |
if (queriedItemsCache) {
|
|
3178 |
var queriedItems = queriedItemsCache.get(query);
|
|
3179 |
|
|
3180 |
if (queriedItems !== undefined) {
|
|
3181 |
return queriedItems;
|
|
3182 |
}
|
|
3183 |
} else {
|
|
3184 |
queriedItemsCache = new equivalent_key_map_default.a();
|
|
3185 |
queriedItemsCacheByState.set(state, queriedItemsCache);
|
|
3186 |
}
|
|
3187 |
|
|
3188 |
var items = getQueriedItemsUncached(state, query);
|
|
3189 |
queriedItemsCache.set(query, items);
|
|
3190 |
return items;
|
|
3191 |
});
|
|
3192 |
|
|
3193 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/selectors.js
|
|
3194 |
|
|
3195 |
|
|
3196 |
function selectors_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; }
|
|
3197 |
|
|
3198 |
function selectors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { selectors_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 { selectors_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3199 |
|
|
3200 |
/**
|
|
3201 |
* External dependencies
|
|
3202 |
*/
|
|
3203 |
|
|
3204 |
|
|
3205 |
/**
|
|
3206 |
* WordPress dependencies
|
|
3207 |
*/
|
|
3208 |
|
|
3209 |
|
|
3210 |
|
|
3211 |
/**
|
|
3212 |
* Internal dependencies
|
|
3213 |
*/
|
|
3214 |
|
|
3215 |
|
|
3216 |
|
|
3217 |
|
|
3218 |
/**
|
|
3219 |
* Returns true if a request is in progress for embed preview data, or false
|
|
3220 |
* otherwise.
|
|
3221 |
*
|
|
3222 |
* @param {Object} state Data state.
|
|
3223 |
* @param {string} url URL the preview would be for.
|
|
3224 |
*
|
|
3225 |
* @return {boolean} Whether a request is in progress for an embed preview.
|
|
3226 |
*/
|
|
3227 |
|
|
3228 |
var isRequestingEmbedPreview = Object(external_this_wp_data_["createRegistrySelector"])(function (select) {
|
|
3229 |
return function (state, url) {
|
|
3230 |
return select('core/data').isResolving(REDUCER_KEY, 'getEmbedPreview', [url]);
|
|
3231 |
};
|
|
3232 |
});
|
|
3233 |
/**
|
|
3234 |
* Returns all available authors.
|
|
3235 |
*
|
|
3236 |
* @param {Object} state Data state.
|
|
3237 |
*
|
|
3238 |
* @return {Array} Authors list.
|
|
3239 |
*/
|
|
3240 |
|
|
3241 |
function getAuthors(state) {
|
|
3242 |
return getUserQueryResults(state, 'authors');
|
|
3243 |
}
|
|
3244 |
/**
|
|
3245 |
* Returns the current user.
|
|
3246 |
*
|
|
3247 |
* @param {Object} state Data state.
|
|
3248 |
*
|
|
3249 |
* @return {Object} Current user object.
|
|
3250 |
*/
|
|
3251 |
|
|
3252 |
function getCurrentUser(state) {
|
|
3253 |
return state.currentUser;
|
|
3254 |
}
|
|
3255 |
/**
|
|
3256 |
* Returns all the users returned by a query ID.
|
|
3257 |
*
|
|
3258 |
* @param {Object} state Data state.
|
|
3259 |
* @param {string} queryID Query ID.
|
|
3260 |
*
|
|
3261 |
* @return {Array} Users list.
|
|
3262 |
*/
|
|
3263 |
|
|
3264 |
var getUserQueryResults = Object(rememo["a" /* default */])(function (state, queryID) {
|
|
3265 |
var queryResults = state.users.queries[queryID];
|
|
3266 |
return Object(external_this_lodash_["map"])(queryResults, function (id) {
|
|
3267 |
return state.users.byId[id];
|
|
3268 |
});
|
|
3269 |
}, function (state, queryID) {
|
|
3270 |
return [state.users.queries[queryID], state.users.byId];
|
|
3271 |
});
|
|
3272 |
/**
|
|
3273 |
* Returns whether the entities for the give kind are loaded.
|
|
3274 |
*
|
|
3275 |
* @param {Object} state Data state.
|
|
3276 |
* @param {string} kind Entity kind.
|
|
3277 |
*
|
|
3278 |
* @return {boolean} Whether the entities are loaded
|
|
3279 |
*/
|
|
3280 |
|
|
3281 |
function getEntitiesByKind(state, kind) {
|
|
3282 |
return Object(external_this_lodash_["filter"])(state.entities.config, {
|
|
3283 |
kind: kind
|
|
3284 |
});
|
|
3285 |
}
|
|
3286 |
/**
|
|
3287 |
* Returns the entity object given its kind and name.
|
|
3288 |
*
|
|
3289 |
* @param {Object} state Data state.
|
|
3290 |
* @param {string} kind Entity kind.
|
|
3291 |
* @param {string} name Entity name.
|
|
3292 |
*
|
|
3293 |
* @return {Object} Entity
|
|
3294 |
*/
|
|
3295 |
|
|
3296 |
function selectors_getEntity(state, kind, name) {
|
|
3297 |
return Object(external_this_lodash_["find"])(state.entities.config, {
|
|
3298 |
kind: kind,
|
|
3299 |
name: name
|
|
3300 |
});
|
|
3301 |
}
|
|
3302 |
/**
|
|
3303 |
* Returns the Entity's record object by key.
|
|
3304 |
*
|
|
3305 |
* @param {Object} state State tree
|
|
3306 |
* @param {string} kind Entity kind.
|
|
3307 |
* @param {string} name Entity name.
|
|
3308 |
* @param {number} key Record's key
|
|
3309 |
*
|
|
3310 |
* @return {Object?} Record.
|
|
3311 |
*/
|
|
3312 |
|
|
3313 |
function getEntityRecord(state, kind, name, key) {
|
|
3314 |
return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'queriedData', 'items', key]);
|
|
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 |
});
|
|
3354 |
/**
|
|
3355 |
* Returns the Entity's records.
|
|
3356 |
*
|
|
3357 |
* @param {Object} state State tree
|
|
3358 |
* @param {string} kind Entity kind.
|
|
3359 |
* @param {string} name Entity name.
|
|
3360 |
* @param {?Object} query Optional terms query.
|
|
3361 |
*
|
|
3362 |
* @return {?Array} Records.
|
|
3363 |
*/
|
|
3364 |
|
|
3365 |
function getEntityRecords(state, kind, name, query) {
|
|
3366 |
var queriedState = Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'queriedData']);
|
|
3367 |
|
|
3368 |
if (!queriedState) {
|
|
3369 |
return [];
|
|
3370 |
}
|
|
3371 |
|
|
3372 |
return getQueriedItems(queriedState, query);
|
|
3373 |
}
|
|
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 |
/**
|
|
3613 |
* Return theme supports data in the index.
|
|
3614 |
*
|
|
3615 |
* @param {Object} state Data state.
|
|
3616 |
*
|
|
3617 |
* @return {*} Index data.
|
|
3618 |
*/
|
|
3619 |
|
|
3620 |
function getThemeSupports(state) {
|
|
3621 |
return state.themeSupports;
|
|
3622 |
}
|
|
3623 |
/**
|
|
3624 |
* Returns the embed preview for the given URL.
|
|
3625 |
*
|
|
3626 |
* @param {Object} state Data state.
|
|
3627 |
* @param {string} url Embedded URL.
|
|
3628 |
*
|
|
3629 |
* @return {*} Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
|
|
3630 |
*/
|
|
3631 |
|
|
3632 |
function getEmbedPreview(state, url) {
|
|
3633 |
return state.embedPreviews[url];
|
|
3634 |
}
|
|
3635 |
/**
|
|
3636 |
* Determines if the returned preview is an oEmbed link fallback.
|
|
3637 |
*
|
|
3638 |
* WordPress can be configured to return a simple link to a URL if it is not embeddable.
|
|
3639 |
* We need to be able to determine if a URL is embeddable or not, based on what we
|
|
3640 |
* get back from the oEmbed preview API.
|
|
3641 |
*
|
|
3642 |
* @param {Object} state Data state.
|
|
3643 |
* @param {string} url Embedded URL.
|
|
3644 |
*
|
|
3645 |
* @return {boolean} Is the preview for the URL an oEmbed link fallback.
|
|
3646 |
*/
|
|
3647 |
|
|
3648 |
function isPreviewEmbedFallback(state, url) {
|
|
3649 |
var preview = state.embedPreviews[url];
|
|
3650 |
var oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>';
|
|
3651 |
|
|
3652 |
if (!preview) {
|
|
3653 |
return false;
|
|
3654 |
}
|
|
3655 |
|
|
3656 |
return preview.html === oEmbedLinkCheck;
|
|
3657 |
}
|
|
3658 |
/**
|
|
3659 |
* Returns whether the current user can upload media.
|
|
3660 |
*
|
|
3661 |
* Calling this may trigger an OPTIONS request to the REST API via the
|
|
3662 |
* `canUser()` resolver.
|
|
3663 |
*
|
|
3664 |
* https://developer.wordpress.org/rest-api/reference/
|
|
3665 |
*
|
|
3666 |
* @deprecated since 5.0. Callers should use the more generic `canUser()` selector instead of
|
|
3667 |
* `hasUploadPermissions()`, e.g. `canUser( 'create', 'media' )`.
|
|
3668 |
*
|
|
3669 |
* @param {Object} state Data state.
|
|
3670 |
*
|
|
3671 |
* @return {boolean} Whether or not the user can upload media. Defaults to `true` if the OPTIONS
|
|
3672 |
* request is being made.
|
|
3673 |
*/
|
|
3674 |
|
|
3675 |
function hasUploadPermissions(state) {
|
|
3676 |
external_this_wp_deprecated_default()("select( 'core' ).hasUploadPermissions()", {
|
|
3677 |
alternative: "select( 'core' ).canUser( 'create', 'media' )"
|
|
3678 |
});
|
|
3679 |
return Object(external_this_lodash_["defaultTo"])(canUser(state, 'create', 'media'), true);
|
|
3680 |
}
|
|
3681 |
/**
|
|
3682 |
* Returns whether the current user can perform the given action on the given
|
|
3683 |
* REST resource.
|
|
3684 |
*
|
|
3685 |
* Calling this may trigger an OPTIONS request to the REST API via the
|
|
3686 |
* `canUser()` resolver.
|
|
3687 |
*
|
|
3688 |
* https://developer.wordpress.org/rest-api/reference/
|
|
3689 |
*
|
|
3690 |
* @param {Object} state Data state.
|
|
3691 |
* @param {string} action Action to check. One of: 'create', 'read', 'update', 'delete'.
|
|
3692 |
* @param {string} resource REST resource to check, e.g. 'media' or 'posts'.
|
|
3693 |
* @param {string=} id Optional ID of the rest resource to check.
|
|
3694 |
*
|
|
3695 |
* @return {boolean|undefined} Whether or not the user can perform the action,
|
|
3696 |
* or `undefined` if the OPTIONS request is still being made.
|
|
3697 |
*/
|
|
3698 |
|
|
3699 |
function canUser(state, action, resource, id) {
|
|
3700 |
var key = Object(external_this_lodash_["compact"])([action, resource, id]).join('/');
|
|
3701 |
return Object(external_this_lodash_["get"])(state, ['userPermissions', key]);
|
|
3702 |
}
|
|
3703 |
/**
|
|
3704 |
* Returns the latest autosaves for the post.
|
|
3705 |
*
|
|
3706 |
* May return multiple autosaves since the backend stores one autosave per
|
|
3707 |
* author for each post.
|
|
3708 |
*
|
|
3709 |
* @param {Object} state State tree.
|
|
3710 |
* @param {string} postType The type of the parent post.
|
|
3711 |
* @param {number} postId The id of the parent post.
|
|
3712 |
*
|
|
3713 |
* @return {?Array} An array of autosaves for the post, or undefined if there is none.
|
|
3714 |
*/
|
|
3715 |
|
|
3716 |
function getAutosaves(state, postType, postId) {
|
|
3717 |
return state.autosaves[postId];
|
|
3718 |
}
|
|
3719 |
/**
|
|
3720 |
* Returns the autosave for the post and author.
|
|
3721 |
*
|
|
3722 |
* @param {Object} state State tree.
|
|
3723 |
* @param {string} postType The type of the parent post.
|
|
3724 |
* @param {number} postId The id of the parent post.
|
|
3725 |
* @param {number} authorId The id of the author.
|
|
3726 |
*
|
|
3727 |
* @return {?Object} The autosave for the post and author.
|
|
3728 |
*/
|
|
3729 |
|
|
3730 |
function getAutosave(state, postType, postId, authorId) {
|
|
3731 |
if (authorId === undefined) {
|
|
3732 |
return;
|
|
3733 |
}
|
|
3734 |
|
|
3735 |
var autosaves = state.autosaves[postId];
|
|
3736 |
return Object(external_this_lodash_["find"])(autosaves, {
|
|
3737 |
author: authorId
|
|
3738 |
});
|
|
3739 |
}
|
|
3740 |
/**
|
|
3741 |
* Returns true if the REST request for autosaves has completed.
|
|
3742 |
*
|
|
3743 |
* @param {Object} state State tree.
|
|
3744 |
* @param {string} postType The type of the parent post.
|
|
3745 |
* @param {number} postId The id of the parent post.
|
|
3746 |
*
|
|
3747 |
* @return {boolean} True if the REST request was completed. False otherwise.
|
|
3748 |
*/
|
|
3749 |
|
|
3750 |
var hasFetchedAutosaves = Object(external_this_wp_data_["createRegistrySelector"])(function (select) {
|
|
3751 |
return function (state, postType, postId) {
|
|
3752 |
return select(REDUCER_KEY).hasFinishedResolution('getAutosaves', [postType, postId]);
|
|
3753 |
};
|
|
3754 |
});
|
|
3755 |
/**
|
|
3756 |
* Returns a new reference when edited values have changed. This is useful in
|
|
3757 |
* inferring where an edit has been made between states by comparison of the
|
|
3758 |
* return values using strict equality.
|
|
3759 |
*
|
|
3760 |
* @example
|
|
3761 |
*
|
|
3762 |
* ```
|
|
3763 |
* const hasEditOccurred = (
|
|
3764 |
* getReferenceByDistinctEdits( beforeState ) !==
|
|
3765 |
* getReferenceByDistinctEdits( afterState )
|
|
3766 |
* );
|
|
3767 |
* ```
|
|
3768 |
*
|
|
3769 |
* @param {Object} state Editor state.
|
|
3770 |
*
|
|
3771 |
* @return {*} A value whose reference will change only when an edit occurs.
|
|
3772 |
*/
|
|
3773 |
|
|
3774 |
var getReferenceByDistinctEdits = Object(rememo["a" /* default */])(function () {
|
|
3775 |
return [];
|
|
3776 |
}, function (state) {
|
|
3777 |
return [state.undo.length, state.undo.offset];
|
|
3778 |
});
|
|
3779 |
|
|
3780 |
// EXTERNAL MODULE: external {"this":["wp","dataControls"]}
|
|
3781 |
var external_this_wp_dataControls_ = __webpack_require__(36);
|
|
3782 |
|
|
3783 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-not-resolved.js
|
|
3784 |
|
|
3785 |
|
|
3786 |
/**
|
|
3787 |
* WordPress dependencies
|
|
3788 |
*/
|
|
3789 |
|
|
3790 |
/**
|
|
3791 |
* Higher-order function which invokes the given resolver only if it has not
|
|
3792 |
* already been resolved with the arguments passed to the enhanced function.
|
|
3793 |
*
|
|
3794 |
* This only considers resolution state, and notably does not support resolver
|
|
3795 |
* custom `isFulfilled` behavior.
|
|
3796 |
*
|
|
3797 |
* @param {Function} resolver Original resolver.
|
|
3798 |
* @param {string} selectorName Selector name associated with resolver.
|
|
3799 |
*
|
|
3800 |
* @return {Function} Enhanced resolver.
|
|
3801 |
*/
|
|
3802 |
|
|
3803 |
var if_not_resolved_ifNotResolved = function ifNotResolved(resolver, selectorName) {
|
|
3804 |
return (
|
|
3805 |
/*#__PURE__*/
|
|
3806 |
|
|
3807 |
/**
|
|
3808 |
* @param {...any} args Original resolver arguments.
|
|
3809 |
*/
|
|
3810 |
external_this_regeneratorRuntime_default.a.mark(function resolveIfNotResolved() {
|
|
3811 |
var _len,
|
|
3812 |
args,
|
|
3813 |
_key,
|
|
3814 |
hasStartedResolution,
|
|
3815 |
_args = arguments;
|
|
3816 |
|
|
3817 |
return external_this_regeneratorRuntime_default.a.wrap(function resolveIfNotResolved$(_context) {
|
|
3818 |
while (1) {
|
|
3819 |
switch (_context.prev = _context.next) {
|
|
3820 |
case 0:
|
|
3821 |
for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3822 |
args[_key] = _args[_key];
|
|
3823 |
}
|
|
3824 |
|
|
3825 |
_context.next = 3;
|
|
3826 |
return Object(external_this_wp_dataControls_["select"])('core', 'hasStartedResolution', selectorName, args);
|
|
3827 |
|
|
3828 |
case 3:
|
|
3829 |
hasStartedResolution = _context.sent;
|
|
3830 |
|
|
3831 |
if (hasStartedResolution) {
|
|
3832 |
_context.next = 6;
|
|
3833 |
break;
|
|
3834 |
}
|
|
3835 |
|
|
3836 |
return _context.delegateYield(resolver.apply(void 0, args), "t0", 6);
|
|
3837 |
|
|
3838 |
case 6:
|
|
3839 |
case "end":
|
|
3840 |
return _context.stop();
|
|
3841 |
}
|
|
3842 |
}
|
|
3843 |
}, resolveIfNotResolved);
|
|
3844 |
})
|
|
3845 |
);
|
|
3846 |
};
|
|
3847 |
|
|
3848 |
/* harmony default export */ var if_not_resolved = (if_not_resolved_ifNotResolved);
|
|
3849 |
|
|
3850 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/resolvers.js
|
|
3851 |
|
|
3852 |
|
|
3853 |
|
|
3854 |
function resolvers_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; }
|
|
3855 |
|
|
3856 |
function resolvers_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { resolvers_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 { resolvers_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3857 |
|
|
3858 |
var resolvers_marked = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getAuthors),
|
|
3859 |
resolvers_marked2 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getCurrentUser),
|
|
3860 |
resolvers_marked3 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getEntityRecord),
|
|
3861 |
resolvers_marked4 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getEntityRecords),
|
|
3862 |
resolvers_marked5 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getCurrentTheme),
|
|
3863 |
_marked6 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getThemeSupports),
|
|
3864 |
_marked7 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getEmbedPreview),
|
|
3865 |
_marked8 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_hasUploadPermissions),
|
|
3866 |
_marked9 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_canUser),
|
|
3867 |
_marked10 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getAutosaves),
|
|
3868 |
_marked11 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getAutosave);
|
|
3869 |
|
|
3870 |
/**
|
|
3871 |
* External dependencies
|
|
3872 |
*/
|
|
3873 |
|
|
3874 |
/**
|
|
3875 |
* WordPress dependencies
|
|
3876 |
*/
|
|
3877 |
|
|
3878 |
|
|
3879 |
|
|
3880 |
/**
|
|
3881 |
* Internal dependencies
|
|
3882 |
*/
|
|
3883 |
|
|
3884 |
|
|
3885 |
|
|
3886 |
|
|
3887 |
|
|
3888 |
/**
|
|
3889 |
* Requests authors from the REST API.
|
|
3890 |
*/
|
|
3891 |
|
|
3892 |
function resolvers_getAuthors() {
|
|
3893 |
var users;
|
|
3894 |
return external_this_regeneratorRuntime_default.a.wrap(function getAuthors$(_context) {
|
|
3895 |
while (1) {
|
|
3896 |
switch (_context.prev = _context.next) {
|
|
3897 |
case 0:
|
|
3898 |
_context.next = 2;
|
|
3899 |
return apiFetch({
|
|
3900 |
path: '/wp/v2/users/?who=authors&per_page=-1'
|
|
3901 |
});
|
|
3902 |
|
|
3903 |
case 2:
|
|
3904 |
users = _context.sent;
|
|
3905 |
_context.next = 5;
|
|
3906 |
return receiveUserQuery('authors', users);
|
|
3907 |
|
|
3908 |
case 5:
|
|
3909 |
case "end":
|
|
3910 |
return _context.stop();
|
|
3911 |
}
|
|
3912 |
}
|
|
3913 |
}, resolvers_marked);
|
|
3914 |
}
|
|
3915 |
/**
|
|
3916 |
* Requests the current user from the REST API.
|
|
3917 |
*/
|
|
3918 |
|
|
3919 |
function resolvers_getCurrentUser() {
|
|
3920 |
var currentUser;
|
|
3921 |
return external_this_regeneratorRuntime_default.a.wrap(function getCurrentUser$(_context2) {
|
|
3922 |
while (1) {
|
|
3923 |
switch (_context2.prev = _context2.next) {
|
|
3924 |
case 0:
|
|
3925 |
_context2.next = 2;
|
|
3926 |
return apiFetch({
|
|
3927 |
path: '/wp/v2/users/me'
|
|
3928 |
});
|
|
3929 |
|
|
3930 |
case 2:
|
|
3931 |
currentUser = _context2.sent;
|
|
3932 |
_context2.next = 5;
|
|
3933 |
return receiveCurrentUser(currentUser);
|
|
3934 |
|
|
3935 |
case 5:
|
|
3936 |
case "end":
|
|
3937 |
return _context2.stop();
|
|
3938 |
}
|
|
3939 |
}
|
|
3940 |
}, resolvers_marked2);
|
|
3941 |
}
|
|
3942 |
/**
|
|
3943 |
* Requests an entity's record from the REST API.
|
|
3944 |
*
|
|
3945 |
* @param {string} kind Entity kind.
|
|
3946 |
* @param {string} name Entity name.
|
|
3947 |
* @param {number} key Record's key
|
|
3948 |
*/
|
|
3949 |
|
|
3950 |
function resolvers_getEntityRecord(kind, name) {
|
|
3951 |
var key,
|
|
3952 |
entities,
|
|
3953 |
entity,
|
|
3954 |
record,
|
|
3955 |
_args3 = arguments;
|
|
3956 |
return external_this_regeneratorRuntime_default.a.wrap(function getEntityRecord$(_context3) {
|
|
3957 |
while (1) {
|
|
3958 |
switch (_context3.prev = _context3.next) {
|
|
3959 |
case 0:
|
|
3960 |
key = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : '';
|
|
3961 |
_context3.next = 3;
|
|
3962 |
return getKindEntities(kind);
|
|
3963 |
|
|
3964 |
case 3:
|
|
3965 |
entities = _context3.sent;
|
|
3966 |
entity = Object(external_this_lodash_["find"])(entities, {
|
|
3967 |
kind: kind,
|
|
3968 |
name: name
|
|
3969 |
});
|
|
3970 |
|
|
3971 |
if (entity) {
|
|
3972 |
_context3.next = 7;
|
|
3973 |
break;
|
|
3974 |
}
|
|
3975 |
|
|
3976 |
return _context3.abrupt("return");
|
|
3977 |
|
|
3978 |
case 7:
|
|
3979 |
_context3.next = 9;
|
|
3980 |
return apiFetch({
|
|
3981 |
path: "".concat(entity.baseURL, "/").concat(key, "?context=edit")
|
|
3982 |
});
|
|
3983 |
|
|
3984 |
case 9:
|
|
3985 |
record = _context3.sent;
|
|
3986 |
_context3.next = 12;
|
|
3987 |
return receiveEntityRecords(kind, name, record);
|
|
3988 |
|
|
3989 |
case 12:
|
|
3990 |
case "end":
|
|
3991 |
return _context3.stop();
|
|
3992 |
}
|
|
3993 |
}
|
|
3994 |
}, resolvers_marked3);
|
|
3995 |
}
|
|
3996 |
/**
|
|
3997 |
* Requests an entity's record from the REST API.
|
|
3998 |
*/
|
|
3999 |
|
|
4000 |
var resolvers_getRawEntityRecord = if_not_resolved(resolvers_getEntityRecord, 'getEntityRecord');
|
|
4001 |
/**
|
|
4002 |
* Requests an entity's record from the REST API.
|
|
4003 |
*/
|
|
4004 |
|
|
4005 |
var resolvers_getEditedEntityRecord = if_not_resolved(resolvers_getRawEntityRecord, 'getRawEntityRecord');
|
|
4006 |
/**
|
|
4007 |
* Requests the entity's records from the REST API.
|
|
4008 |
*
|
|
4009 |
* @param {string} kind Entity kind.
|
|
4010 |
* @param {string} name Entity name.
|
|
4011 |
* @param {Object?} query Query Object.
|
|
4012 |
*/
|
|
4013 |
|
|
4014 |
function resolvers_getEntityRecords(kind, name) {
|
|
4015 |
var query,
|
|
4016 |
entities,
|
|
4017 |
entity,
|
|
4018 |
path,
|
|
4019 |
records,
|
|
4020 |
_args4 = arguments;
|
|
4021 |
return external_this_regeneratorRuntime_default.a.wrap(function getEntityRecords$(_context4) {
|
|
4022 |
while (1) {
|
|
4023 |
switch (_context4.prev = _context4.next) {
|
|
4024 |
case 0:
|
|
4025 |
query = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
|
|
4026 |
_context4.next = 3;
|
|
4027 |
return getKindEntities(kind);
|
|
4028 |
|
|
4029 |
case 3:
|
|
4030 |
entities = _context4.sent;
|
|
4031 |
entity = Object(external_this_lodash_["find"])(entities, {
|
|
4032 |
kind: kind,
|
|
4033 |
name: name
|
|
4034 |
});
|
|
4035 |
|
|
4036 |
if (entity) {
|
|
4037 |
_context4.next = 7;
|
|
4038 |
break;
|
|
4039 |
}
|
|
4040 |
|
|
4041 |
return _context4.abrupt("return");
|
|
4042 |
|
|
4043 |
case 7:
|
|
4044 |
path = Object(external_this_wp_url_["addQueryArgs"])(entity.baseURL, resolvers_objectSpread({}, query, {
|
|
4045 |
context: 'edit'
|
|
4046 |
}));
|
|
4047 |
_context4.next = 10;
|
|
4048 |
return apiFetch({
|
|
4049 |
path: path
|
|
4050 |
});
|
|
4051 |
|
|
4052 |
case 10:
|
|
4053 |
records = _context4.sent;
|
|
4054 |
_context4.next = 13;
|
|
4055 |
return receiveEntityRecords(kind, name, Object.values(records), query);
|
|
4056 |
|
|
4057 |
case 13:
|
|
4058 |
case "end":
|
|
4059 |
return _context4.stop();
|
|
4060 |
}
|
|
4061 |
}
|
|
4062 |
}, resolvers_marked4);
|
|
4063 |
}
|
|
4064 |
|
|
4065 |
resolvers_getEntityRecords.shouldInvalidate = function (action, kind, name) {
|
|
4066 |
return action.type === 'RECEIVE_ITEMS' && action.invalidateCache && kind === action.kind && name === action.name;
|
|
4067 |
};
|
|
4068 |
/**
|
|
4069 |
* Requests the current theme.
|
|
4070 |
*/
|
|
4071 |
|
|
4072 |
|
|
4073 |
function resolvers_getCurrentTheme() {
|
|
4074 |
var activeThemes;
|
|
4075 |
return external_this_regeneratorRuntime_default.a.wrap(function getCurrentTheme$(_context5) {
|
|
4076 |
while (1) {
|
|
4077 |
switch (_context5.prev = _context5.next) {
|
|
4078 |
case 0:
|
|
4079 |
_context5.next = 2;
|
|
4080 |
return apiFetch({
|
|
4081 |
path: '/wp/v2/themes?status=active'
|
|
4082 |
});
|
|
4083 |
|
|
4084 |
case 2:
|
|
4085 |
activeThemes = _context5.sent;
|
|
4086 |
_context5.next = 5;
|
|
4087 |
return receiveCurrentTheme(activeThemes[0]);
|
|
4088 |
|
|
4089 |
case 5:
|
|
4090 |
case "end":
|
|
4091 |
return _context5.stop();
|
|
4092 |
}
|
|
4093 |
}
|
|
4094 |
}, resolvers_marked5);
|
|
4095 |
}
|
|
4096 |
/**
|
|
4097 |
* Requests theme supports data from the index.
|
|
4098 |
*/
|
|
4099 |
|
|
4100 |
function resolvers_getThemeSupports() {
|
|
4101 |
var activeThemes;
|
|
4102 |
return external_this_regeneratorRuntime_default.a.wrap(function getThemeSupports$(_context6) {
|
|
4103 |
while (1) {
|
|
4104 |
switch (_context6.prev = _context6.next) {
|
|
4105 |
case 0:
|
|
4106 |
_context6.next = 2;
|
|
4107 |
return apiFetch({
|
|
4108 |
path: '/wp/v2/themes?status=active'
|
|
4109 |
});
|
|
4110 |
|
|
4111 |
case 2:
|
|
4112 |
activeThemes = _context6.sent;
|
|
4113 |
_context6.next = 5;
|
|
4114 |
return receiveThemeSupports(activeThemes[0].theme_supports);
|
|
4115 |
|
|
4116 |
case 5:
|
|
4117 |
case "end":
|
|
4118 |
return _context6.stop();
|
|
4119 |
}
|
|
4120 |
}
|
|
4121 |
}, _marked6);
|
|
4122 |
}
|
|
4123 |
/**
|
|
4124 |
* Requests a preview from the from the Embed API.
|
|
4125 |
*
|
|
4126 |
* @param {string} url URL to get the preview for.
|
|
4127 |
*/
|
|
4128 |
|
|
4129 |
function resolvers_getEmbedPreview(url) {
|
|
4130 |
var embedProxyResponse;
|
|
4131 |
return external_this_regeneratorRuntime_default.a.wrap(function getEmbedPreview$(_context7) {
|
|
4132 |
while (1) {
|
|
4133 |
switch (_context7.prev = _context7.next) {
|
|
4134 |
case 0:
|
|
4135 |
_context7.prev = 0;
|
|
4136 |
_context7.next = 3;
|
|
4137 |
return apiFetch({
|
|
4138 |
path: Object(external_this_wp_url_["addQueryArgs"])('/oembed/1.0/proxy', {
|
|
4139 |
url: url
|
|
4140 |
})
|
|
4141 |
});
|
|
4142 |
|
|
4143 |
case 3:
|
|
4144 |
embedProxyResponse = _context7.sent;
|
|
4145 |
_context7.next = 6;
|
|
4146 |
return receiveEmbedPreview(url, embedProxyResponse);
|
|
4147 |
|
|
4148 |
case 6:
|
|
4149 |
_context7.next = 12;
|
|
4150 |
break;
|
|
4151 |
|
|
4152 |
case 8:
|
|
4153 |
_context7.prev = 8;
|
|
4154 |
_context7.t0 = _context7["catch"](0);
|
|
4155 |
_context7.next = 12;
|
|
4156 |
return receiveEmbedPreview(url, false);
|
|
4157 |
|
|
4158 |
case 12:
|
|
4159 |
case "end":
|
|
4160 |
return _context7.stop();
|
|
4161 |
}
|
|
4162 |
}
|
|
4163 |
}, _marked7, null, [[0, 8]]);
|
|
4164 |
}
|
|
4165 |
/**
|
|
4166 |
* Requests Upload Permissions from the REST API.
|
|
4167 |
*
|
|
4168 |
* @deprecated since 5.0. Callers should use the more generic `canUser()` selector instead of
|
|
4169 |
* `hasUploadPermissions()`, e.g. `canUser( 'create', 'media' )`.
|
|
4170 |
*/
|
|
4171 |
|
|
4172 |
function resolvers_hasUploadPermissions() {
|
|
4173 |
return external_this_regeneratorRuntime_default.a.wrap(function hasUploadPermissions$(_context8) {
|
|
4174 |
while (1) {
|
|
4175 |
switch (_context8.prev = _context8.next) {
|
|
4176 |
case 0:
|
|
4177 |
external_this_wp_deprecated_default()("select( 'core' ).hasUploadPermissions()", {
|
|
4178 |
alternative: "select( 'core' ).canUser( 'create', 'media' )"
|
|
4179 |
});
|
|
4180 |
return _context8.delegateYield(resolvers_canUser('create', 'media'), "t0", 2);
|
|
4181 |
|
|
4182 |
case 2:
|
|
4183 |
case "end":
|
|
4184 |
return _context8.stop();
|
|
4185 |
}
|
|
4186 |
}
|
|
4187 |
}, _marked8);
|
|
4188 |
}
|
|
4189 |
/**
|
|
4190 |
* Checks whether the current user can perform the given action on the given
|
|
4191 |
* REST resource.
|
|
4192 |
*
|
|
4193 |
* @param {string} action Action to check. One of: 'create', 'read', 'update',
|
|
4194 |
* 'delete'.
|
|
4195 |
* @param {string} resource REST resource to check, e.g. 'media' or 'posts'.
|
|
4196 |
* @param {?string} id ID of the rest resource to check.
|
|
4197 |
*/
|
|
4198 |
|
|
4199 |
function resolvers_canUser(action, resource, id) {
|
|
4200 |
var methods, method, path, response, allowHeader, key, isAllowed;
|
|
4201 |
return external_this_regeneratorRuntime_default.a.wrap(function canUser$(_context9) {
|
|
4202 |
while (1) {
|
|
4203 |
switch (_context9.prev = _context9.next) {
|
|
4204 |
case 0:
|
|
4205 |
methods = {
|
|
4206 |
create: 'POST',
|
|
4207 |
read: 'GET',
|
|
4208 |
update: 'PUT',
|
|
4209 |
delete: 'DELETE'
|
|
4210 |
};
|
|
4211 |
method = methods[action];
|
|
4212 |
|
|
4213 |
if (method) {
|
|
4214 |
_context9.next = 4;
|
|
4215 |
break;
|
|
4216 |
}
|
|
4217 |
|
|
4218 |
throw new Error("'".concat(action, "' is not a valid action."));
|
|
4219 |
|
|
4220 |
case 4:
|
|
4221 |
path = id ? "/wp/v2/".concat(resource, "/").concat(id) : "/wp/v2/".concat(resource);
|
|
4222 |
_context9.prev = 5;
|
|
4223 |
_context9.next = 8;
|
|
4224 |
return apiFetch({
|
|
4225 |
path: path,
|
|
4226 |
// Ideally this would always be an OPTIONS request, but unfortunately there's
|
|
4227 |
// a bug in the REST API which causes the Allow header to not be sent on
|
|
4228 |
// OPTIONS requests to /posts/:id routes.
|
|
4229 |
// https://core.trac.wordpress.org/ticket/45753
|
|
4230 |
method: id ? 'GET' : 'OPTIONS',
|
|
4231 |
parse: false
|
|
4232 |
});
|
|
4233 |
|
|
4234 |
case 8:
|
|
4235 |
response = _context9.sent;
|
|
4236 |
_context9.next = 14;
|
|
4237 |
break;
|
|
4238 |
|
|
4239 |
case 11:
|
|
4240 |
_context9.prev = 11;
|
|
4241 |
_context9.t0 = _context9["catch"](5);
|
|
4242 |
return _context9.abrupt("return");
|
|
4243 |
|
|
4244 |
case 14:
|
|
4245 |
if (Object(external_this_lodash_["hasIn"])(response, ['headers', 'get'])) {
|
|
4246 |
// If the request is fetched using the fetch api, the header can be
|
|
4247 |
// retrieved using the 'get' method.
|
|
4248 |
allowHeader = response.headers.get('allow');
|
|
4249 |
} else {
|
|
4250 |
// If the request was preloaded server-side and is returned by the
|
|
4251 |
// preloading middleware, the header will be a simple property.
|
|
4252 |
allowHeader = Object(external_this_lodash_["get"])(response, ['headers', 'Allow'], '');
|
|
4253 |
}
|
|
4254 |
|
|
4255 |
key = Object(external_this_lodash_["compact"])([action, resource, id]).join('/');
|
|
4256 |
isAllowed = Object(external_this_lodash_["includes"])(allowHeader, method);
|
|
4257 |
_context9.next = 19;
|
|
4258 |
return receiveUserPermission(key, isAllowed);
|
|
4259 |
|
|
4260 |
case 19:
|
|
4261 |
case "end":
|
|
4262 |
return _context9.stop();
|
|
4263 |
}
|
|
4264 |
}
|
|
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];
|
|
4544 |
}
|
|
4545 |
|
|
4546 |
// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js
|
|
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; }
|
|
4552 |
|
|
4553 |
/**
|
|
4554 |
* WordPress dependencies
|
|
4555 |
*/
|
|
4556 |
|
|
4557 |
/**
|
|
4558 |
* Internal dependencies
|
|
4559 |
*/
|
|
4560 |
|
|
4561 |
|
|
4562 |
|
|
4563 |
|
|
4564 |
|
|
4565 |
|
|
4566 |
|
|
4567 |
// The entity selectors/resolvers and actions are shortcuts to their generic equivalents
|
|
4568 |
// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecordss)
|
|
4569 |
// Instead of getEntityRecord, the consumer could use more user-frieldly named selector: getPostType, getTaxonomy...
|
|
4570 |
// The "kind" and the "name" of the entity are combined to generate these shortcuts.
|
|
4571 |
|
|
4572 |
var entitySelectors = defaultEntities.reduce(function (result, entity) {
|
|
4573 |
var kind = entity.kind,
|
|
4574 |
name = entity.name;
|
|
4575 |
|
|
4576 |
result[entities_getMethodName(kind, name)] = function (state, key) {
|
|
4577 |
return getEntityRecord(state, kind, name, key);
|
|
4578 |
};
|
|
4579 |
|
|
4580 |
result[entities_getMethodName(kind, name, 'get', true)] = function (state) {
|
|
4581 |
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
4582 |
args[_key - 1] = arguments[_key];
|
|
4583 |
}
|
|
4584 |
|
|
4585 |
return getEntityRecords.apply(build_module_selectors_namespaceObject, [state, kind, name].concat(args));
|
|
4586 |
};
|
|
4587 |
|
|
4588 |
return result;
|
|
4589 |
}, {});
|
|
4590 |
var entityResolvers = defaultEntities.reduce(function (result, entity) {
|
|
4591 |
var kind = entity.kind,
|
|
4592 |
name = entity.name;
|
|
4593 |
|
|
4594 |
result[entities_getMethodName(kind, name)] = function (key) {
|
|
4595 |
return resolvers_getEntityRecord(kind, name, key);
|
|
4596 |
};
|
|
4597 |
|
|
4598 |
var pluralMethodName = entities_getMethodName(kind, name, 'get', true);
|
|
4599 |
|
|
4600 |
result[pluralMethodName] = function () {
|
|
4601 |
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
4602 |
args[_key2] = arguments[_key2];
|
|
4603 |
}
|
|
4604 |
|
|
4605 |
return resolvers_getEntityRecords.apply(resolvers_namespaceObject, [kind, name].concat(args));
|
|
4606 |
};
|
|
4607 |
|
|
4608 |
result[pluralMethodName].shouldInvalidate = function (action) {
|
|
4609 |
var _resolvers$getEntityR;
|
|
4610 |
|
|
4611 |
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
4612 |
args[_key3 - 1] = arguments[_key3];
|
|
4613 |
}
|
|
4614 |
|
|
4615 |
return (_resolvers$getEntityR = resolvers_getEntityRecords).shouldInvalidate.apply(_resolvers$getEntityR, [action, kind, name].concat(args));
|
|
4616 |
};
|
|
4617 |
|
|
4618 |
return result;
|
|
4619 |
}, {});
|
|
4620 |
var entityActions = defaultEntities.reduce(function (result, entity) {
|
|
4621 |
var kind = entity.kind,
|
|
4622 |
name = entity.name;
|
|
4623 |
|
|
4624 |
result[entities_getMethodName(kind, name, 'save')] = function (key) {
|
|
4625 |
return saveEntityRecord(kind, name, key);
|
|
4626 |
};
|
|
4627 |
|
|
4628 |
return result;
|
|
4629 |
}, {});
|
|
4630 |
Object(external_this_wp_data_["registerStore"])(REDUCER_KEY, {
|
|
4631 |
reducer: build_module_reducer,
|
|
4632 |
controls: build_module_controls,
|
|
4633 |
actions: build_module_objectSpread({}, build_module_actions_namespaceObject, {}, entityActions),
|
|
4634 |
selectors: build_module_objectSpread({}, build_module_selectors_namespaceObject, {}, entitySelectors),
|
|
4635 |
resolvers: build_module_objectSpread({}, resolvers_namespaceObject, {}, entityResolvers)
|
|
4636 |
});
|
|
4637 |
|
|
4638 |
|
|
4639 |
|
9
|
4640 |
|
|
4641 |
/***/ }),
|
|
4642 |
|
16
|
4643 |
/***/ 45:
|
|
4644 |
/***/ (function(module, exports) {
|
|
4645 |
|
|
4646 |
(function() { module.exports = this["wp"]["apiFetch"]; }());
|
|
4647 |
|
|
4648 |
/***/ }),
|
|
4649 |
|
|
4650 |
/***/ 5:
|
9
|
4651 |
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
4652 |
|
|
4653 |
"use strict";
|
16
|
4654 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
|
|
4655 |
function _defineProperty(obj, key, value) {
|
|
4656 |
if (key in obj) {
|
|
4657 |
Object.defineProperty(obj, key, {
|
|
4658 |
value: value,
|
|
4659 |
enumerable: true,
|
|
4660 |
configurable: true,
|
|
4661 |
writable: true
|
|
4662 |
});
|
|
4663 |
} else {
|
|
4664 |
obj[key] = value;
|
|
4665 |
}
|
|
4666 |
|
|
4667 |
return obj;
|
|
4668 |
}
|
|
4669 |
|
|
4670 |
/***/ }),
|
|
4671 |
|
|
4672 |
/***/ 64:
|
|
4673 |
/***/ (function(module, exports) {
|
|
4674 |
|
|
4675 |
(function() { module.exports = this["wp"]["isShallowEqual"]; }());
|
9
|
4676 |
|
|
4677 |
/***/ })
|
|
4678 |
|
|
4679 |
/******/ }); |