[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
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 85 /******/ return __webpack_require__(__webpack_require__.s = 470); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ 0: 91 /***/ (function(module, exports) { 92 93 (function() { module.exports = this["wp"]["element"]; }()); 94 95 /***/ }), 96 97 /***/ 1: 98 /***/ (function(module, exports) { 99 100 (function() { module.exports = this["wp"]["i18n"]; }()); 101 102 /***/ }), 103 104 /***/ 107: 105 /***/ (function(module, exports, __webpack_require__) { 106 107 "use strict"; 108 109 110 function _typeof(obj) { 111 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 112 _typeof = function (obj) { 113 return typeof obj; 114 }; 115 } else { 116 _typeof = function (obj) { 117 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 118 }; 119 } 120 121 return _typeof(obj); 122 } 123 124 function _classCallCheck(instance, Constructor) { 125 if (!(instance instanceof Constructor)) { 126 throw new TypeError("Cannot call a class as a function"); 127 } 128 } 129 130 function _defineProperties(target, props) { 131 for (var i = 0; i < props.length; i++) { 132 var descriptor = props[i]; 133 descriptor.enumerable = descriptor.enumerable || false; 134 descriptor.configurable = true; 135 if ("value" in descriptor) descriptor.writable = true; 136 Object.defineProperty(target, descriptor.key, descriptor); 137 } 138 } 139 140 function _createClass(Constructor, protoProps, staticProps) { 141 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 142 if (staticProps) _defineProperties(Constructor, staticProps); 143 return Constructor; 144 } 145 146 /** 147 * Given an instance of EquivalentKeyMap, returns its internal value pair tuple 148 * for a key, if one exists. The tuple members consist of the last reference 149 * value for the key (used in efficient subsequent lookups) and the value 150 * assigned for the key at the leaf node. 151 * 152 * @param {EquivalentKeyMap} instance EquivalentKeyMap instance. 153 * @param {*} key The key for which to return value pair. 154 * 155 * @return {?Array} Value pair, if exists. 156 */ 157 function getValuePair(instance, key) { 158 var _map = instance._map, 159 _arrayTreeMap = instance._arrayTreeMap, 160 _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the 161 // value, which can be used to shortcut immediately to the value. 162 163 if (_map.has(key)) { 164 return _map.get(key); 165 } // Sort keys to ensure stable retrieval from tree. 166 167 168 var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value. 169 170 var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap; 171 172 for (var i = 0; i < properties.length; i++) { 173 var property = properties[i]; 174 map = map.get(property); 175 176 if (map === undefined) { 177 return; 178 } 179 180 var propertyValue = key[property]; 181 map = map.get(propertyValue); 182 183 if (map === undefined) { 184 return; 185 } 186 } 187 188 var valuePair = map.get('_ekm_value'); 189 190 if (!valuePair) { 191 return; 192 } // If reached, it implies that an object-like key was set with another 193 // reference, so delete the reference and replace with the current. 194 195 196 _map.delete(valuePair[0]); 197 198 valuePair[0] = key; 199 map.set('_ekm_value', valuePair); 200 201 _map.set(key, valuePair); 202 203 return valuePair; 204 } 205 /** 206 * Variant of a Map object which enables lookup by equivalent (deeply equal) 207 * object and array keys. 208 */ 209 210 211 var EquivalentKeyMap = 212 /*#__PURE__*/ 213 function () { 214 /** 215 * Constructs a new instance of EquivalentKeyMap. 216 * 217 * @param {Iterable.<*>} iterable Initial pair of key, value for map. 218 */ 219 function EquivalentKeyMap(iterable) { 220 _classCallCheck(this, EquivalentKeyMap); 221 222 this.clear(); 223 224 if (iterable instanceof EquivalentKeyMap) { 225 // Map#forEach is only means of iterating with support for IE11. 226 var iterablePairs = []; 227 iterable.forEach(function (value, key) { 228 iterablePairs.push([key, value]); 229 }); 230 iterable = iterablePairs; 231 } 232 233 if (iterable != null) { 234 for (var i = 0; i < iterable.length; i++) { 235 this.set(iterable[i][0], iterable[i][1]); 236 } 237 } 238 } 239 /** 240 * Accessor property returning the number of elements. 241 * 242 * @return {number} Number of elements. 243 */ 244 245 246 _createClass(EquivalentKeyMap, [{ 247 key: "set", 248 249 /** 250 * Add or update an element with a specified key and value. 251 * 252 * @param {*} key The key of the element to add. 253 * @param {*} value The value of the element to add. 254 * 255 * @return {EquivalentKeyMap} Map instance. 256 */ 257 value: function set(key, value) { 258 // Shortcut non-object-like to set on internal Map. 259 if (key === null || _typeof(key) !== 'object') { 260 this._map.set(key, value); 261 262 return this; 263 } // Sort keys to ensure stable assignment into tree. 264 265 266 var properties = Object.keys(key).sort(); 267 var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value. 268 269 var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap; 270 271 for (var i = 0; i < properties.length; i++) { 272 var property = properties[i]; 273 274 if (!map.has(property)) { 275 map.set(property, new EquivalentKeyMap()); 276 } 277 278 map = map.get(property); 279 var propertyValue = key[property]; 280 281 if (!map.has(propertyValue)) { 282 map.set(propertyValue, new EquivalentKeyMap()); 283 } 284 285 map = map.get(propertyValue); 286 } // If an _ekm_value exists, there was already an equivalent key. Before 287 // overriding, ensure that the old key reference is removed from map to 288 // avoid memory leak of accumulating equivalent keys. This is, in a 289 // sense, a poor man's WeakMap, while still enabling iterability. 290 291 292 var previousValuePair = map.get('_ekm_value'); 293 294 if (previousValuePair) { 295 this._map.delete(previousValuePair[0]); 296 } 297 298 map.set('_ekm_value', valuePair); 299 300 this._map.set(key, valuePair); 301 302 return this; 303 } 304 /** 305 * Returns a specified element. 306 * 307 * @param {*} key The key of the element to return. 308 * 309 * @return {?*} The element associated with the specified key or undefined 310 * if the key can't be found. 311 */ 312 313 }, { 314 key: "get", 315 value: function get(key) { 316 // Shortcut non-object-like to get from internal Map. 317 if (key === null || _typeof(key) !== 'object') { 318 return this._map.get(key); 319 } 320 321 var valuePair = getValuePair(this, key); 322 323 if (valuePair) { 324 return valuePair[1]; 325 } 326 } 327 /** 328 * Returns a boolean indicating whether an element with the specified key 329 * exists or not. 330 * 331 * @param {*} key The key of the element to test for presence. 332 * 333 * @return {boolean} Whether an element with the specified key exists. 334 */ 335 336 }, { 337 key: "has", 338 value: function has(key) { 339 if (key === null || _typeof(key) !== 'object') { 340 return this._map.has(key); 341 } // Test on the _presence_ of the pair, not its value, as even undefined 342 // can be a valid member value for a key. 343 344 345 return getValuePair(this, key) !== undefined; 346 } 347 /** 348 * Removes the specified element. 349 * 350 * @param {*} key The key of the element to remove. 351 * 352 * @return {boolean} Returns true if an element existed and has been 353 * removed, or false if the element does not exist. 354 */ 355 356 }, { 357 key: "delete", 358 value: function _delete(key) { 359 if (!this.has(key)) { 360 return false; 361 } // This naive implementation will leave orphaned child trees. A better 362 // implementation should traverse and remove orphans. 363 364 365 this.set(key, undefined); 366 return true; 367 } 368 /** 369 * Executes a provided function once per each key/value pair, in insertion 370 * order. 371 * 372 * @param {Function} callback Function to execute for each element. 373 * @param {*} thisArg Value to use as `this` when executing 374 * `callback`. 375 */ 376 377 }, { 378 key: "forEach", 379 value: function forEach(callback) { 380 var _this = this; 381 382 var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; 383 384 this._map.forEach(function (value, key) { 385 // Unwrap value from object-like value pair. 386 if (key !== null && _typeof(key) === 'object') { 387 value = value[1]; 388 } 389 390 callback.call(thisArg, value, key, _this); 391 }); 392 } 393 /** 394 * Removes all elements. 395 */ 396 397 }, { 398 key: "clear", 399 value: function clear() { 400 this._map = new Map(); 401 this._arrayTreeMap = new Map(); 402 this._objectTreeMap = new Map(); 403 } 404 }, { 405 key: "size", 406 get: function get() { 407 return this._map.size; 408 } 409 }]); 410 411 return EquivalentKeyMap; 412 }(); 413 414 module.exports = EquivalentKeyMap; 415 416 417 /***/ }), 418 419 /***/ 11: 420 /***/ (function(module, exports) { 421 422 (function() { module.exports = this["wp"]["blocks"]; }()); 423 424 /***/ }), 425 426 /***/ 12: 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__(31); 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 /***/ 17: 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__(27); 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__(37); 499 500 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js 501 var unsupportedIterableToArray = __webpack_require__(31); 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 /***/ 20: 526 /***/ (function(module, exports) { 527 528 (function() { module.exports = this["regeneratorRuntime"]; }()); 529 530 /***/ }), 531 532 /***/ 27: 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 /***/ 30: 550 /***/ (function(module, exports) { 551 552 (function() { module.exports = this["wp"]["url"]; }()); 553 554 /***/ }), 555 556 /***/ 31: 557 /***/ (function(module, __webpack_exports__, __webpack_require__) { 558 559 "use strict"; 560 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; }); 561 /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(27); 562 563 function _unsupportedIterableToArray(o, minLen) { 564 if (!o) return; 565 if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); 566 var n = Object.prototype.toString.call(o).slice(8, -1); 567 if (n === "Object" && o.constructor) n = o.constructor.name; 568 if (n === "Map" || n === "Set") return Array.from(o); 569 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); 570 } 571 572 /***/ }), 573 574 /***/ 32: 575 /***/ (function(module, exports) { 576 577 (function() { module.exports = this["wp"]["dataControls"]; }()); 578 579 /***/ }), 580 581 /***/ 36: 582 /***/ (function(module, exports) { 583 584 (function() { module.exports = this["wp"]["deprecated"]; }()); 585 586 /***/ }), 587 588 /***/ 37: 589 /***/ (function(module, __webpack_exports__, __webpack_require__) { 590 591 "use strict"; 592 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); 593 function _iterableToArray(iter) { 594 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); 595 } 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 /***/ 470: 911 /***/ (function(module, __webpack_exports__, __webpack_require__) { 912 913 "use strict"; 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, "deleteEntityRecord", function() { return deleteEntityRecord; }); 934 __webpack_require__.d(build_module_actions_namespaceObject, "editEntityRecord", function() { return actions_editEntityRecord; }); 935 __webpack_require__.d(build_module_actions_namespaceObject, "undo", function() { return undo; }); 936 __webpack_require__.d(build_module_actions_namespaceObject, "redo", function() { return redo; }); 937 __webpack_require__.d(build_module_actions_namespaceObject, "__unstableCreateUndoLevel", function() { return __unstableCreateUndoLevel; }); 938 __webpack_require__.d(build_module_actions_namespaceObject, "saveEntityRecord", function() { return saveEntityRecord; }); 939 __webpack_require__.d(build_module_actions_namespaceObject, "saveEditedEntityRecord", function() { return saveEditedEntityRecord; }); 940 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUploadPermissions", function() { return receiveUploadPermissions; }); 941 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUserPermission", function() { return receiveUserPermission; }); 942 __webpack_require__.d(build_module_actions_namespaceObject, "receiveAutosaves", function() { return receiveAutosaves; }); 943 944 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/selectors.js 945 var build_module_selectors_namespaceObject = {}; 946 __webpack_require__.r(build_module_selectors_namespaceObject); 947 __webpack_require__.d(build_module_selectors_namespaceObject, "isRequestingEmbedPreview", function() { return isRequestingEmbedPreview; }); 948 __webpack_require__.d(build_module_selectors_namespaceObject, "getAuthors", function() { return getAuthors; }); 949 __webpack_require__.d(build_module_selectors_namespaceObject, "__unstableGetAuthor", function() { return __unstableGetAuthor; }); 950 __webpack_require__.d(build_module_selectors_namespaceObject, "getCurrentUser", function() { return getCurrentUser; }); 951 __webpack_require__.d(build_module_selectors_namespaceObject, "getUserQueryResults", function() { return getUserQueryResults; }); 952 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntitiesByKind", function() { return getEntitiesByKind; }); 953 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntity", function() { return selectors_getEntity; }); 954 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecord", function() { return getEntityRecord; }); 955 __webpack_require__.d(build_module_selectors_namespaceObject, "__experimentalGetEntityRecordNoResolver", function() { return __experimentalGetEntityRecordNoResolver; }); 956 __webpack_require__.d(build_module_selectors_namespaceObject, "getRawEntityRecord", function() { return getRawEntityRecord; }); 957 __webpack_require__.d(build_module_selectors_namespaceObject, "hasEntityRecords", function() { return hasEntityRecords; }); 958 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecords", function() { return getEntityRecords; }); 959 __webpack_require__.d(build_module_selectors_namespaceObject, "__experimentalGetDirtyEntityRecords", function() { return __experimentalGetDirtyEntityRecords; }); 960 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecordEdits", function() { return getEntityRecordEdits; }); 961 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecordNonTransientEdits", function() { return getEntityRecordNonTransientEdits; }); 962 __webpack_require__.d(build_module_selectors_namespaceObject, "hasEditsForEntityRecord", function() { return hasEditsForEntityRecord; }); 963 __webpack_require__.d(build_module_selectors_namespaceObject, "getEditedEntityRecord", function() { return getEditedEntityRecord; }); 964 __webpack_require__.d(build_module_selectors_namespaceObject, "isAutosavingEntityRecord", function() { return isAutosavingEntityRecord; }); 965 __webpack_require__.d(build_module_selectors_namespaceObject, "isSavingEntityRecord", function() { return isSavingEntityRecord; }); 966 __webpack_require__.d(build_module_selectors_namespaceObject, "isDeletingEntityRecord", function() { return isDeletingEntityRecord; }); 967 __webpack_require__.d(build_module_selectors_namespaceObject, "getLastEntitySaveError", function() { return getLastEntitySaveError; }); 968 __webpack_require__.d(build_module_selectors_namespaceObject, "getLastEntityDeleteError", function() { return getLastEntityDeleteError; }); 969 __webpack_require__.d(build_module_selectors_namespaceObject, "getUndoEdit", function() { return getUndoEdit; }); 970 __webpack_require__.d(build_module_selectors_namespaceObject, "getRedoEdit", function() { return getRedoEdit; }); 971 __webpack_require__.d(build_module_selectors_namespaceObject, "hasUndo", function() { return hasUndo; }); 972 __webpack_require__.d(build_module_selectors_namespaceObject, "hasRedo", function() { return hasRedo; }); 973 __webpack_require__.d(build_module_selectors_namespaceObject, "getCurrentTheme", function() { return getCurrentTheme; }); 974 __webpack_require__.d(build_module_selectors_namespaceObject, "getThemeSupports", function() { return getThemeSupports; }); 975 __webpack_require__.d(build_module_selectors_namespaceObject, "getEmbedPreview", function() { return getEmbedPreview; }); 976 __webpack_require__.d(build_module_selectors_namespaceObject, "isPreviewEmbedFallback", function() { return isPreviewEmbedFallback; }); 977 __webpack_require__.d(build_module_selectors_namespaceObject, "hasUploadPermissions", function() { return hasUploadPermissions; }); 978 __webpack_require__.d(build_module_selectors_namespaceObject, "canUser", function() { return canUser; }); 979 __webpack_require__.d(build_module_selectors_namespaceObject, "getAutosaves", function() { return getAutosaves; }); 980 __webpack_require__.d(build_module_selectors_namespaceObject, "getAutosave", function() { return getAutosave; }); 981 __webpack_require__.d(build_module_selectors_namespaceObject, "hasFetchedAutosaves", function() { return hasFetchedAutosaves; }); 982 __webpack_require__.d(build_module_selectors_namespaceObject, "getReferenceByDistinctEdits", function() { return getReferenceByDistinctEdits; }); 983 984 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/resolvers.js 985 var resolvers_namespaceObject = {}; 986 __webpack_require__.r(resolvers_namespaceObject); 987 __webpack_require__.d(resolvers_namespaceObject, "getAuthors", function() { return resolvers_getAuthors; }); 988 __webpack_require__.d(resolvers_namespaceObject, "__unstableGetAuthor", function() { return resolvers_unstableGetAuthor; }); 989 __webpack_require__.d(resolvers_namespaceObject, "getCurrentUser", function() { return resolvers_getCurrentUser; }); 990 __webpack_require__.d(resolvers_namespaceObject, "getEntityRecord", function() { return resolvers_getEntityRecord; }); 991 __webpack_require__.d(resolvers_namespaceObject, "getRawEntityRecord", function() { return resolvers_getRawEntityRecord; }); 992 __webpack_require__.d(resolvers_namespaceObject, "getEditedEntityRecord", function() { return resolvers_getEditedEntityRecord; }); 993 __webpack_require__.d(resolvers_namespaceObject, "getEntityRecords", function() { return resolvers_getEntityRecords; }); 994 __webpack_require__.d(resolvers_namespaceObject, "getCurrentTheme", function() { return resolvers_getCurrentTheme; }); 995 __webpack_require__.d(resolvers_namespaceObject, "getThemeSupports", function() { return resolvers_getThemeSupports; }); 996 __webpack_require__.d(resolvers_namespaceObject, "getEmbedPreview", function() { return resolvers_getEmbedPreview; }); 997 __webpack_require__.d(resolvers_namespaceObject, "hasUploadPermissions", function() { return resolvers_hasUploadPermissions; }); 998 __webpack_require__.d(resolvers_namespaceObject, "canUser", function() { return resolvers_canUser; }); 999 __webpack_require__.d(resolvers_namespaceObject, "getAutosaves", function() { return resolvers_getAutosaves; }); 1000 __webpack_require__.d(resolvers_namespaceObject, "getAutosave", function() { return resolvers_getAutosave; }); 1001 1002 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js 1003 var defineProperty = __webpack_require__(5); 1004 1005 // EXTERNAL MODULE: external {"this":["wp","data"]} 1006 var external_this_wp_data_ = __webpack_require__(4); 1007 1008 // EXTERNAL MODULE: external {"this":["wp","dataControls"]} 1009 var external_this_wp_dataControls_ = __webpack_require__(32); 1010 1011 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules 1012 var slicedToArray = __webpack_require__(12); 1013 1014 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules 1015 var toConsumableArray = __webpack_require__(17); 1016 1017 // EXTERNAL MODULE: external {"this":"lodash"} 1018 var external_this_lodash_ = __webpack_require__(2); 1019 1020 // EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]} 1021 var external_this_wp_isShallowEqual_ = __webpack_require__(64); 1022 var external_this_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_isShallowEqual_); 1023 1024 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js 1025 /** 1026 * A higher-order reducer creator which invokes the original reducer only if 1027 * the dispatching action matches the given predicate, **OR** if state is 1028 * initializing (undefined). 1029 * 1030 * @param {Function} isMatch Function predicate for allowing reducer call. 1031 * 1032 * @return {Function} Higher-order reducer. 1033 */ 1034 var ifMatchingAction = function ifMatchingAction(isMatch) { 1035 return function (reducer) { 1036 return function (state, action) { 1037 if (state === undefined || isMatch(action)) { 1038 return reducer(state, action); 1039 } 1040 1041 return state; 1042 }; 1043 }; 1044 }; 1045 1046 /* harmony default export */ var if_matching_action = (ifMatchingAction); 1047 1048 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/replace-action.js 1049 /** 1050 * Higher-order reducer creator which substitutes the action object before 1051 * passing to the original reducer. 1052 * 1053 * @param {Function} replacer Function mapping original action to replacement. 1054 * 1055 * @return {Function} Higher-order reducer. 1056 */ 1057 var replaceAction = function replaceAction(replacer) { 1058 return function (reducer) { 1059 return function (state, action) { 1060 return reducer(state, replacer(action)); 1061 }; 1062 }; 1063 }; 1064 1065 /* harmony default export */ var replace_action = (replaceAction); 1066 1067 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/conservative-map-item.js 1068 /** 1069 * External dependencies 1070 */ 1071 1072 /** 1073 * Given the current and next item entity, returns the minimally "modified" 1074 * result of the next item, preferring value references from the original item 1075 * if equal. If all values match, the original item is returned. 1076 * 1077 * @param {Object} item Original item. 1078 * @param {Object} nextItem Next item. 1079 * 1080 * @return {Object} Minimally modified merged item. 1081 */ 1082 1083 function conservativeMapItem(item, nextItem) { 1084 // Return next item in its entirety if there is no original item. 1085 if (!item) { 1086 return nextItem; 1087 } 1088 1089 var hasChanges = false; 1090 var result = {}; 1091 1092 for (var key in nextItem) { 1093 if (Object(external_this_lodash_["isEqual"])(item[key], nextItem[key])) { 1094 result[key] = item[key]; 1095 } else { 1096 hasChanges = true; 1097 result[key] = nextItem[key]; 1098 } 1099 } 1100 1101 if (!hasChanges) { 1102 return item; 1103 } // Only at this point, backfill properties from the original item which 1104 // weren't explicitly set into the result above. This is an optimization 1105 // to allow `hasChanges` to return early. 1106 1107 1108 for (var _key in item) { 1109 if (!result.hasOwnProperty(_key)) { 1110 result[_key] = item[_key]; 1111 } 1112 } 1113 1114 return result; 1115 } 1116 1117 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/on-sub-key.js 1118 1119 1120 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; } 1121 1122 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; } 1123 1124 /** 1125 * Higher-order reducer creator which creates a combined reducer object, keyed 1126 * by a property on the action object. 1127 * 1128 * @param {string} actionProperty Action property by which to key object. 1129 * 1130 * @return {Function} Higher-order reducer. 1131 */ 1132 var on_sub_key_onSubKey = function onSubKey(actionProperty) { 1133 return function (reducer) { 1134 return function () { 1135 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 1136 var action = arguments.length > 1 ? arguments[1] : undefined; 1137 // Retrieve subkey from action. Do not track if undefined; useful for cases 1138 // where reducer is scoped by action shape. 1139 var key = action[actionProperty]; 1140 1141 if (key === undefined) { 1142 return state; 1143 } // Avoid updating state if unchanged. Note that this also accounts for a 1144 // reducer which returns undefined on a key which is not yet tracked. 1145 1146 1147 var nextKeyState = reducer(state[key], action); 1148 1149 if (nextKeyState === state[key]) { 1150 return state; 1151 } 1152 1153 return _objectSpread(_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, key, nextKeyState)); 1154 }; 1155 }; 1156 }; 1157 /* harmony default export */ var on_sub_key = (on_sub_key_onSubKey); 1158 1159 // EXTERNAL MODULE: external {"this":"regeneratorRuntime"} 1160 var external_this_regeneratorRuntime_ = __webpack_require__(20); 1161 var external_this_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_this_regeneratorRuntime_); 1162 1163 // EXTERNAL MODULE: external {"this":["wp","i18n"]} 1164 var external_this_wp_i18n_ = __webpack_require__(1); 1165 1166 // EXTERNAL MODULE: external {"this":["wp","url"]} 1167 var external_this_wp_url_ = __webpack_require__(30); 1168 1169 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/actions.js 1170 1171 1172 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; } 1173 1174 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; } 1175 1176 /** 1177 * External dependencies 1178 */ 1179 1180 /** 1181 * Returns an action object used in signalling that items have been received. 1182 * 1183 * @param {Array} items Items received. 1184 * 1185 * @return {Object} Action object. 1186 */ 1187 1188 function receiveItems(items) { 1189 return { 1190 type: 'RECEIVE_ITEMS', 1191 items: Object(external_this_lodash_["castArray"])(items) 1192 }; 1193 } 1194 /** 1195 * Returns an action object used in signalling that entity records have been 1196 * deleted and they need to be removed from entities state. 1197 * 1198 * @param {string} kind Kind of the removed entities. 1199 * @param {string} name Name of the removed entities. 1200 * @param {Array|number} records Record IDs of the removed entities. 1201 * @param {boolean} invalidateCache Controls whether we want to invalidate the cache. 1202 * @return {Object} Action object. 1203 */ 1204 1205 function removeItems(kind, name, records) { 1206 var invalidateCache = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 1207 return { 1208 type: 'REMOVE_ITEMS', 1209 itemIds: Object(external_this_lodash_["castArray"])(records), 1210 kind: kind, 1211 name: name, 1212 invalidateCache: invalidateCache 1213 }; 1214 } 1215 /** 1216 * Returns an action object used in signalling that queried data has been 1217 * received. 1218 * 1219 * @param {Array} items Queried items received. 1220 * @param {?Object} query Optional query object. 1221 * 1222 * @return {Object} Action object. 1223 */ 1224 1225 function receiveQueriedItems(items) { 1226 var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 1227 return actions_objectSpread(actions_objectSpread({}, receiveItems(items)), {}, { 1228 query: query 1229 }); 1230 } 1231 1232 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/actions.js 1233 1234 1235 1236 1237 var _marked = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(deleteEntityRecord), 1238 _marked2 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(actions_editEntityRecord), 1239 _marked3 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(undo), 1240 _marked4 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(redo), 1241 _marked5 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(saveEntityRecord), 1242 _marked6 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(saveEditedEntityRecord); 1243 1244 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; } 1245 1246 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; } 1247 1248 /** 1249 * External dependencies 1250 */ 1251 1252 /** 1253 * WordPress dependencies 1254 */ 1255 1256 1257 1258 /** 1259 * Internal dependencies 1260 */ 1261 1262 1263 1264 /** 1265 * Returns an action object used in signalling that authors have been received. 1266 * 1267 * @param {string} queryID Query ID. 1268 * @param {Array|Object} users Users received. 1269 * 1270 * @return {Object} Action object. 1271 */ 1272 1273 function receiveUserQuery(queryID, users) { 1274 return { 1275 type: 'RECEIVE_USER_QUERY', 1276 users: Object(external_this_lodash_["castArray"])(users), 1277 queryID: queryID 1278 }; 1279 } 1280 /** 1281 * Returns an action used in signalling that the current user has been received. 1282 * 1283 * @param {Object} currentUser Current user object. 1284 * 1285 * @return {Object} Action object. 1286 */ 1287 1288 function receiveCurrentUser(currentUser) { 1289 return { 1290 type: 'RECEIVE_CURRENT_USER', 1291 currentUser: currentUser 1292 }; 1293 } 1294 /** 1295 * Returns an action object used in adding new entities. 1296 * 1297 * @param {Array} entities Entities received. 1298 * 1299 * @return {Object} Action object. 1300 */ 1301 1302 function addEntities(entities) { 1303 return { 1304 type: 'ADD_ENTITIES', 1305 entities: entities 1306 }; 1307 } 1308 /** 1309 * Returns an action object used in signalling that entity records have been received. 1310 * 1311 * @param {string} kind Kind of the received entity. 1312 * @param {string} name Name of the received entity. 1313 * @param {Array|Object} records Records received. 1314 * @param {?Object} query Query Object. 1315 * @param {?boolean} invalidateCache Should invalidate query caches 1316 * 1317 * @return {Object} Action object. 1318 */ 1319 1320 function receiveEntityRecords(kind, name, records, query) { 1321 var invalidateCache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; 1322 1323 // Auto drafts should not have titles, but some plugins rely on them so we can't filter this 1324 // on the server. 1325 if (kind === 'postType') { 1326 records = Object(external_this_lodash_["castArray"])(records).map(function (record) { 1327 return record.status === 'auto-draft' ? build_module_actions_objectSpread(build_module_actions_objectSpread({}, record), {}, { 1328 title: '' 1329 }) : record; 1330 }); 1331 } 1332 1333 var action; 1334 1335 if (query) { 1336 action = receiveQueriedItems(records, query); 1337 } else { 1338 action = receiveItems(records); 1339 } 1340 1341 return build_module_actions_objectSpread(build_module_actions_objectSpread({}, action), {}, { 1342 kind: kind, 1343 name: name, 1344 invalidateCache: invalidateCache 1345 }); 1346 } 1347 /** 1348 * Returns an action object used in signalling that the current theme has been received. 1349 * 1350 * @param {Object} currentTheme The current theme. 1351 * 1352 * @return {Object} Action object. 1353 */ 1354 1355 function receiveCurrentTheme(currentTheme) { 1356 return { 1357 type: 'RECEIVE_CURRENT_THEME', 1358 currentTheme: currentTheme 1359 }; 1360 } 1361 /** 1362 * Returns an action object used in signalling that the index has been received. 1363 * 1364 * @param {Object} themeSupports Theme support for the current theme. 1365 * 1366 * @return {Object} Action object. 1367 */ 1368 1369 function receiveThemeSupports(themeSupports) { 1370 return { 1371 type: 'RECEIVE_THEME_SUPPORTS', 1372 themeSupports: themeSupports 1373 }; 1374 } 1375 /** 1376 * Returns an action object used in signalling that the preview data for 1377 * a given URl has been received. 1378 * 1379 * @param {string} url URL to preview the embed for. 1380 * @param {*} preview Preview data. 1381 * 1382 * @return {Object} Action object. 1383 */ 1384 1385 function receiveEmbedPreview(url, preview) { 1386 return { 1387 type: 'RECEIVE_EMBED_PREVIEW', 1388 url: url, 1389 preview: preview 1390 }; 1391 } 1392 /** 1393 * Action triggered to delete an entity record. 1394 * 1395 * @param {string} kind Kind of the deleted entity. 1396 * @param {string} name Name of the deleted entity. 1397 * @param {string} recordId Record ID of the deleted entity. 1398 * @param {?Object} query Special query parameters for the DELETE API call. 1399 */ 1400 1401 function deleteEntityRecord(kind, name, recordId, query) { 1402 var entities, entity, error, deletedRecord, path; 1403 return external_this_regeneratorRuntime_default.a.wrap(function deleteEntityRecord$(_context) { 1404 while (1) { 1405 switch (_context.prev = _context.next) { 1406 case 0: 1407 _context.next = 2; 1408 return getKindEntities(kind); 1409 1410 case 2: 1411 entities = _context.sent; 1412 entity = Object(external_this_lodash_["find"])(entities, { 1413 kind: kind, 1414 name: name 1415 }); 1416 deletedRecord = false; 1417 1418 if (entity) { 1419 _context.next = 7; 1420 break; 1421 } 1422 1423 return _context.abrupt("return"); 1424 1425 case 7: 1426 _context.next = 9; 1427 return { 1428 type: 'DELETE_ENTITY_RECORD_START', 1429 kind: kind, 1430 name: name, 1431 recordId: recordId 1432 }; 1433 1434 case 9: 1435 _context.prev = 9; 1436 path = "".concat(entity.baseURL, "/").concat(recordId); 1437 1438 if (query) { 1439 path = Object(external_this_wp_url_["addQueryArgs"])(path, query); 1440 } 1441 1442 _context.next = 14; 1443 return Object(external_this_wp_dataControls_["apiFetch"])({ 1444 path: path, 1445 method: 'DELETE' 1446 }); 1447 1448 case 14: 1449 deletedRecord = _context.sent; 1450 _context.next = 17; 1451 return removeItems(kind, name, recordId, true); 1452 1453 case 17: 1454 _context.next = 22; 1455 break; 1456 1457 case 19: 1458 _context.prev = 19; 1459 _context.t0 = _context["catch"](9); 1460 error = _context.t0; 1461 1462 case 22: 1463 _context.next = 24; 1464 return { 1465 type: 'DELETE_ENTITY_RECORD_FINISH', 1466 kind: kind, 1467 name: name, 1468 recordId: recordId, 1469 error: error 1470 }; 1471 1472 case 24: 1473 return _context.abrupt("return", deletedRecord); 1474 1475 case 25: 1476 case "end": 1477 return _context.stop(); 1478 } 1479 } 1480 }, _marked, null, [[9, 19]]); 1481 } 1482 /** 1483 * Returns an action object that triggers an 1484 * edit to an entity record. 1485 * 1486 * @param {string} kind Kind of the edited entity record. 1487 * @param {string} name Name of the edited entity record. 1488 * @param {number} recordId Record ID of the edited entity record. 1489 * @param {Object} edits The edits. 1490 * @param {Object} options Options for the edit. 1491 * @param {boolean} options.undoIgnore Whether to ignore the edit in undo history or not. 1492 * 1493 * @return {Object} Action object. 1494 */ 1495 1496 function actions_editEntityRecord(kind, name, recordId, edits) { 1497 var options, 1498 entity, 1499 _entity$transientEdit, 1500 transientEdits, 1501 _entity$mergedEdits, 1502 mergedEdits, 1503 record, 1504 editedRecord, 1505 edit, 1506 _args2 = arguments; 1507 1508 return external_this_regeneratorRuntime_default.a.wrap(function editEntityRecord$(_context2) { 1509 while (1) { 1510 switch (_context2.prev = _context2.next) { 1511 case 0: 1512 options = _args2.length > 4 && _args2[4] !== undefined ? _args2[4] : {}; 1513 _context2.next = 3; 1514 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getEntity', kind, name); 1515 1516 case 3: 1517 entity = _context2.sent; 1518 1519 if (entity) { 1520 _context2.next = 6; 1521 break; 1522 } 1523 1524 throw new Error("The entity being edited (".concat(kind, ", ").concat(name, ") does not have a loaded config.")); 1525 1526 case 6: 1527 _entity$transientEdit = entity.transientEdits, transientEdits = _entity$transientEdit === void 0 ? {} : _entity$transientEdit, _entity$mergedEdits = entity.mergedEdits, mergedEdits = _entity$mergedEdits === void 0 ? {} : _entity$mergedEdits; 1528 _context2.next = 9; 1529 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getRawEntityRecord', kind, name, recordId); 1530 1531 case 9: 1532 record = _context2.sent; 1533 _context2.next = 12; 1534 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getEditedEntityRecord', kind, name, recordId); 1535 1536 case 12: 1537 editedRecord = _context2.sent; 1538 edit = { 1539 kind: kind, 1540 name: name, 1541 recordId: recordId, 1542 // Clear edits when they are equal to their persisted counterparts 1543 // so that the property is not considered dirty. 1544 edits: Object.keys(edits).reduce(function (acc, key) { 1545 var recordValue = record[key]; 1546 var editedRecordValue = editedRecord[key]; 1547 var value = mergedEdits[key] ? build_module_actions_objectSpread(build_module_actions_objectSpread({}, editedRecordValue), edits[key]) : edits[key]; 1548 acc[key] = Object(external_this_lodash_["isEqual"])(recordValue, value) ? undefined : value; 1549 return acc; 1550 }, {}), 1551 transientEdits: transientEdits 1552 }; 1553 return _context2.abrupt("return", build_module_actions_objectSpread(build_module_actions_objectSpread({ 1554 type: 'EDIT_ENTITY_RECORD' 1555 }, edit), {}, { 1556 meta: { 1557 undo: !options.undoIgnore && build_module_actions_objectSpread(build_module_actions_objectSpread({}, edit), {}, { 1558 // Send the current values for things like the first undo stack entry. 1559 edits: Object.keys(edits).reduce(function (acc, key) { 1560 acc[key] = editedRecord[key]; 1561 return acc; 1562 }, {}) 1563 }) 1564 } 1565 })); 1566 1567 case 15: 1568 case "end": 1569 return _context2.stop(); 1570 } 1571 } 1572 }, _marked2); 1573 } 1574 /** 1575 * Action triggered to undo the last edit to 1576 * an entity record, if any. 1577 */ 1578 1579 function undo() { 1580 var undoEdit; 1581 return external_this_regeneratorRuntime_default.a.wrap(function undo$(_context3) { 1582 while (1) { 1583 switch (_context3.prev = _context3.next) { 1584 case 0: 1585 _context3.next = 2; 1586 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getUndoEdit'); 1587 1588 case 2: 1589 undoEdit = _context3.sent; 1590 1591 if (undoEdit) { 1592 _context3.next = 5; 1593 break; 1594 } 1595 1596 return _context3.abrupt("return"); 1597 1598 case 5: 1599 _context3.next = 7; 1600 return build_module_actions_objectSpread(build_module_actions_objectSpread({ 1601 type: 'EDIT_ENTITY_RECORD' 1602 }, undoEdit), {}, { 1603 meta: { 1604 isUndo: true 1605 } 1606 }); 1607 1608 case 7: 1609 case "end": 1610 return _context3.stop(); 1611 } 1612 } 1613 }, _marked3); 1614 } 1615 /** 1616 * Action triggered to redo the last undoed 1617 * edit to an entity record, if any. 1618 */ 1619 1620 function redo() { 1621 var redoEdit; 1622 return external_this_regeneratorRuntime_default.a.wrap(function redo$(_context4) { 1623 while (1) { 1624 switch (_context4.prev = _context4.next) { 1625 case 0: 1626 _context4.next = 2; 1627 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getRedoEdit'); 1628 1629 case 2: 1630 redoEdit = _context4.sent; 1631 1632 if (redoEdit) { 1633 _context4.next = 5; 1634 break; 1635 } 1636 1637 return _context4.abrupt("return"); 1638 1639 case 5: 1640 _context4.next = 7; 1641 return build_module_actions_objectSpread(build_module_actions_objectSpread({ 1642 type: 'EDIT_ENTITY_RECORD' 1643 }, redoEdit), {}, { 1644 meta: { 1645 isRedo: true 1646 } 1647 }); 1648 1649 case 7: 1650 case "end": 1651 return _context4.stop(); 1652 } 1653 } 1654 }, _marked4); 1655 } 1656 /** 1657 * Forces the creation of a new undo level. 1658 * 1659 * @return {Object} Action object. 1660 */ 1661 1662 function __unstableCreateUndoLevel() { 1663 return { 1664 type: 'CREATE_UNDO_LEVEL' 1665 }; 1666 } 1667 /** 1668 * Action triggered to save an entity record. 1669 * 1670 * @param {string} kind Kind of the received entity. 1671 * @param {string} name Name of the received entity. 1672 * @param {Object} record Record to be saved. 1673 * @param {Object} options Saving options. 1674 * @param {boolean} [options.isAutosave=false] Whether this is an autosave. 1675 */ 1676 1677 function saveEntityRecord(kind, name, record) { 1678 var _ref, 1679 _ref$isAutosave, 1680 isAutosave, 1681 entities, 1682 entity, 1683 entityIdKey, 1684 recordId, 1685 _i, 1686 _Object$entries, 1687 _Object$entries$_i, 1688 key, 1689 value, 1690 evaluatedValue, 1691 updatedRecord, 1692 error, 1693 persistedEntity, 1694 currentEdits, 1695 path, 1696 persistedRecord, 1697 currentUser, 1698 currentUserId, 1699 autosavePost, 1700 data, 1701 newRecord, 1702 _data, 1703 _args5 = arguments; 1704 1705 return external_this_regeneratorRuntime_default.a.wrap(function saveEntityRecord$(_context5) { 1706 while (1) { 1707 switch (_context5.prev = _context5.next) { 1708 case 0: 1709 _ref = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : { 1710 isAutosave: false 1711 }, _ref$isAutosave = _ref.isAutosave, isAutosave = _ref$isAutosave === void 0 ? false : _ref$isAutosave; 1712 _context5.next = 3; 1713 return getKindEntities(kind); 1714 1715 case 3: 1716 entities = _context5.sent; 1717 entity = Object(external_this_lodash_["find"])(entities, { 1718 kind: kind, 1719 name: name 1720 }); 1721 1722 if (entity) { 1723 _context5.next = 7; 1724 break; 1725 } 1726 1727 return _context5.abrupt("return"); 1728 1729 case 7: 1730 entityIdKey = entity.key || DEFAULT_ENTITY_KEY; 1731 recordId = record[entityIdKey]; // Evaluate optimized edits. 1732 // (Function edits that should be evaluated on save to avoid expensive computations on every edit.) 1733 1734 _i = 0, _Object$entries = Object.entries(record); 1735 1736 case 10: 1737 if (!(_i < _Object$entries.length)) { 1738 _context5.next = 24; 1739 break; 1740 } 1741 1742 _Object$entries$_i = Object(slicedToArray["a" /* default */])(_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1]; 1743 1744 if (!(typeof value === 'function')) { 1745 _context5.next = 21; 1746 break; 1747 } 1748 1749 _context5.t0 = value; 1750 _context5.next = 16; 1751 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getEditedEntityRecord', kind, name, recordId); 1752 1753 case 16: 1754 _context5.t1 = _context5.sent; 1755 evaluatedValue = (0, _context5.t0)(_context5.t1); 1756 _context5.next = 20; 1757 return actions_editEntityRecord(kind, name, recordId, Object(defineProperty["a" /* default */])({}, key, evaluatedValue), { 1758 undoIgnore: true 1759 }); 1760 1761 case 20: 1762 record[key] = evaluatedValue; 1763 1764 case 21: 1765 _i++; 1766 _context5.next = 10; 1767 break; 1768 1769 case 24: 1770 _context5.next = 26; 1771 return { 1772 type: 'SAVE_ENTITY_RECORD_START', 1773 kind: kind, 1774 name: name, 1775 recordId: recordId, 1776 isAutosave: isAutosave 1777 }; 1778 1779 case 26: 1780 _context5.prev = 26; 1781 path = "".concat(entity.baseURL).concat(recordId ? '/' + recordId : ''); 1782 _context5.next = 30; 1783 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getRawEntityRecord', kind, name, recordId); 1784 1785 case 30: 1786 persistedRecord = _context5.sent; 1787 1788 if (!isAutosave) { 1789 _context5.next = 55; 1790 break; 1791 } 1792 1793 _context5.next = 34; 1794 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getCurrentUser'); 1795 1796 case 34: 1797 currentUser = _context5.sent; 1798 currentUserId = currentUser ? currentUser.id : undefined; 1799 _context5.next = 38; 1800 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getAutosave', persistedRecord.type, persistedRecord.id, currentUserId); 1801 1802 case 38: 1803 autosavePost = _context5.sent; 1804 // Autosaves need all expected fields to be present. 1805 // So we fallback to the previous autosave and then 1806 // to the actual persisted entity if the edits don't 1807 // have a value. 1808 data = build_module_actions_objectSpread(build_module_actions_objectSpread(build_module_actions_objectSpread({}, persistedRecord), autosavePost), record); 1809 data = Object.keys(data).reduce(function (acc, key) { 1810 if (['title', 'excerpt', 'content'].includes(key)) { 1811 // Edits should be the "raw" attribute values. 1812 acc[key] = Object(external_this_lodash_["get"])(data[key], 'raw', data[key]); 1813 } 1814 1815 return acc; 1816 }, { 1817 status: data.status === 'auto-draft' ? 'draft' : data.status 1818 }); 1819 _context5.next = 43; 1820 return Object(external_this_wp_dataControls_["apiFetch"])({ 1821 path: "".concat(path, "/autosaves"), 1822 method: 'POST', 1823 data: data 1824 }); 1825 1826 case 43: 1827 updatedRecord = _context5.sent; 1828 1829 if (!(persistedRecord.id === updatedRecord.id)) { 1830 _context5.next = 51; 1831 break; 1832 } 1833 1834 newRecord = build_module_actions_objectSpread(build_module_actions_objectSpread(build_module_actions_objectSpread({}, persistedRecord), data), updatedRecord); 1835 newRecord = Object.keys(newRecord).reduce(function (acc, key) { 1836 // These properties are persisted in autosaves. 1837 if (['title', 'excerpt', 'content'].includes(key)) { 1838 // Edits should be the "raw" attribute values. 1839 acc[key] = Object(external_this_lodash_["get"])(newRecord[key], 'raw', newRecord[key]); 1840 } else if (key === 'status') { 1841 // Status is only persisted in autosaves when going from 1842 // "auto-draft" to "draft". 1843 acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status; 1844 } else { 1845 // These properties are not persisted in autosaves. 1846 acc[key] = Object(external_this_lodash_["get"])(persistedRecord[key], 'raw', persistedRecord[key]); 1847 } 1848 1849 return acc; 1850 }, {}); 1851 _context5.next = 49; 1852 return receiveEntityRecords(kind, name, newRecord, undefined, true); 1853 1854 case 49: 1855 _context5.next = 53; 1856 break; 1857 1858 case 51: 1859 _context5.next = 53; 1860 return receiveAutosaves(persistedRecord.id, updatedRecord); 1861 1862 case 53: 1863 _context5.next = 70; 1864 break; 1865 1866 case 55: 1867 // Auto drafts should be converted to drafts on explicit saves and we should not respect their default title, 1868 // but some plugins break with this behavior so we can't filter it on the server. 1869 _data = record; 1870 1871 if (kind === 'postType' && persistedRecord && persistedRecord.status === 'auto-draft') { 1872 if (!_data.status) { 1873 _data = build_module_actions_objectSpread(build_module_actions_objectSpread({}, _data), {}, { 1874 status: 'draft' 1875 }); 1876 } 1877 1878 if (!_data.title || _data.title === 'Auto Draft') { 1879 _data = build_module_actions_objectSpread(build_module_actions_objectSpread({}, _data), {}, { 1880 title: '' 1881 }); 1882 } 1883 } // Get the full local version of the record before the update, 1884 // to merge it with the edits and then propagate it to subscribers 1885 1886 1887 _context5.next = 59; 1888 return Object(external_this_wp_dataControls_["syncSelect"])('core', '__experimentalGetEntityRecordNoResolver', kind, name, recordId); 1889 1890 case 59: 1891 persistedEntity = _context5.sent; 1892 _context5.next = 62; 1893 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getEntityRecordEdits', kind, name, recordId); 1894 1895 case 62: 1896 currentEdits = _context5.sent; 1897 _context5.next = 65; 1898 return receiveEntityRecords(kind, name, build_module_actions_objectSpread(build_module_actions_objectSpread({}, persistedEntity), _data), undefined, true); 1899 1900 case 65: 1901 _context5.next = 67; 1902 return Object(external_this_wp_dataControls_["apiFetch"])({ 1903 path: path, 1904 method: recordId ? 'PUT' : 'POST', 1905 data: _data 1906 }); 1907 1908 case 67: 1909 updatedRecord = _context5.sent; 1910 _context5.next = 70; 1911 return receiveEntityRecords(kind, name, updatedRecord, undefined, true); 1912 1913 case 70: 1914 _context5.next = 91; 1915 break; 1916 1917 case 72: 1918 _context5.prev = 72; 1919 _context5.t2 = _context5["catch"](26); 1920 error = _context5.t2; // If we got to the point in the try block where we made an optimistic update, 1921 // we need to roll it back here. 1922 1923 if (!(persistedEntity && currentEdits)) { 1924 _context5.next = 91; 1925 break; 1926 } 1927 1928 _context5.next = 78; 1929 return receiveEntityRecords(kind, name, persistedEntity, undefined, true); 1930 1931 case 78: 1932 _context5.t3 = actions_editEntityRecord; 1933 _context5.t4 = kind; 1934 _context5.t5 = name; 1935 _context5.t6 = recordId; 1936 _context5.t7 = build_module_actions_objectSpread; 1937 _context5.t8 = build_module_actions_objectSpread({}, currentEdits); 1938 _context5.next = 86; 1939 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getEntityRecordEdits', kind, name, recordId); 1940 1941 case 86: 1942 _context5.t9 = _context5.sent; 1943 _context5.t10 = (0, _context5.t7)(_context5.t8, _context5.t9); 1944 _context5.t11 = { 1945 undoIgnore: true 1946 }; 1947 _context5.next = 91; 1948 return (0, _context5.t3)(_context5.t4, _context5.t5, _context5.t6, _context5.t10, _context5.t11); 1949 1950 case 91: 1951 _context5.next = 93; 1952 return { 1953 type: 'SAVE_ENTITY_RECORD_FINISH', 1954 kind: kind, 1955 name: name, 1956 recordId: recordId, 1957 error: error, 1958 isAutosave: isAutosave 1959 }; 1960 1961 case 93: 1962 return _context5.abrupt("return", updatedRecord); 1963 1964 case 94: 1965 case "end": 1966 return _context5.stop(); 1967 } 1968 } 1969 }, _marked5, null, [[26, 72]]); 1970 } 1971 /** 1972 * Action triggered to save an entity record's edits. 1973 * 1974 * @param {string} kind Kind of the entity. 1975 * @param {string} name Name of the entity. 1976 * @param {Object} recordId ID of the record. 1977 * @param {Object} options Saving options. 1978 */ 1979 1980 function saveEditedEntityRecord(kind, name, recordId, options) { 1981 var edits, record; 1982 return external_this_regeneratorRuntime_default.a.wrap(function saveEditedEntityRecord$(_context6) { 1983 while (1) { 1984 switch (_context6.prev = _context6.next) { 1985 case 0: 1986 _context6.next = 2; 1987 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'hasEditsForEntityRecord', kind, name, recordId); 1988 1989 case 2: 1990 if (_context6.sent) { 1991 _context6.next = 4; 1992 break; 1993 } 1994 1995 return _context6.abrupt("return"); 1996 1997 case 4: 1998 _context6.next = 6; 1999 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getEntityRecordNonTransientEdits', kind, name, recordId); 2000 2001 case 6: 2002 edits = _context6.sent; 2003 record = build_module_actions_objectSpread({ 2004 id: recordId 2005 }, edits); 2006 return _context6.delegateYield(saveEntityRecord(kind, name, record, options), "t0", 9); 2007 2008 case 9: 2009 case "end": 2010 return _context6.stop(); 2011 } 2012 } 2013 }, _marked6); 2014 } 2015 /** 2016 * Returns an action object used in signalling that Upload permissions have been received. 2017 * 2018 * @param {boolean} hasUploadPermissions Does the user have permission to upload files? 2019 * 2020 * @return {Object} Action object. 2021 */ 2022 2023 function receiveUploadPermissions(hasUploadPermissions) { 2024 return { 2025 type: 'RECEIVE_USER_PERMISSION', 2026 key: 'create/media', 2027 isAllowed: hasUploadPermissions 2028 }; 2029 } 2030 /** 2031 * Returns an action object used in signalling that the current user has 2032 * permission to perform an action on a REST resource. 2033 * 2034 * @param {string} key A key that represents the action and REST resource. 2035 * @param {boolean} isAllowed Whether or not the user can perform the action. 2036 * 2037 * @return {Object} Action object. 2038 */ 2039 2040 function receiveUserPermission(key, isAllowed) { 2041 return { 2042 type: 'RECEIVE_USER_PERMISSION', 2043 key: key, 2044 isAllowed: isAllowed 2045 }; 2046 } 2047 /** 2048 * Returns an action object used in signalling that the autosaves for a 2049 * post have been received. 2050 * 2051 * @param {number} postId The id of the post that is parent to the autosave. 2052 * @param {Array|Object} autosaves An array of autosaves or singular autosave object. 2053 * 2054 * @return {Object} Action object. 2055 */ 2056 2057 function receiveAutosaves(postId, autosaves) { 2058 return { 2059 type: 'RECEIVE_AUTOSAVES', 2060 postId: postId, 2061 autosaves: Object(external_this_lodash_["castArray"])(autosaves) 2062 }; 2063 } 2064 2065 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entities.js 2066 2067 2068 var entities_marked = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(loadPostTypeEntities), 2069 entities_marked2 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(loadTaxonomyEntities), 2070 entities_marked3 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(getKindEntities); 2071 2072 /** 2073 * External dependencies 2074 */ 2075 2076 /** 2077 * WordPress dependencies 2078 */ 2079 2080 2081 2082 /** 2083 * Internal dependencies 2084 */ 2085 2086 2087 var DEFAULT_ENTITY_KEY = 'id'; 2088 var defaultEntities = [{ 2089 label: Object(external_this_wp_i18n_["__"])('Base'), 2090 name: '__unstableBase', 2091 kind: 'root', 2092 baseURL: '' 2093 }, { 2094 label: Object(external_this_wp_i18n_["__"])('Site'), 2095 name: 'site', 2096 kind: 'root', 2097 baseURL: '/wp/v2/settings', 2098 getTitle: function getTitle(record) { 2099 return Object(external_this_lodash_["get"])(record, ['title'], Object(external_this_wp_i18n_["__"])('Site Title')); 2100 } 2101 }, { 2102 label: Object(external_this_wp_i18n_["__"])('Post Type'), 2103 name: 'postType', 2104 kind: 'root', 2105 key: 'slug', 2106 baseURL: '/wp/v2/types' 2107 }, { 2108 name: 'media', 2109 kind: 'root', 2110 baseURL: '/wp/v2/media', 2111 plural: 'mediaItems', 2112 label: Object(external_this_wp_i18n_["__"])('Media') 2113 }, { 2114 name: 'taxonomy', 2115 kind: 'root', 2116 key: 'slug', 2117 baseURL: '/wp/v2/taxonomies', 2118 plural: 'taxonomies', 2119 label: Object(external_this_wp_i18n_["__"])('Taxonomy') 2120 }, { 2121 name: 'sidebar', 2122 kind: 'root', 2123 baseURL: '/wp/v2/sidebars', 2124 plural: 'sidebars', 2125 transientEdits: { 2126 blocks: true 2127 }, 2128 label: Object(external_this_wp_i18n_["__"])('Widget areas') 2129 }, { 2130 name: 'widget', 2131 kind: 'root', 2132 baseURL: '/wp/v2/widgets', 2133 plural: 'widgets', 2134 transientEdits: { 2135 blocks: true 2136 }, 2137 label: Object(external_this_wp_i18n_["__"])('Widgets') 2138 }, { 2139 label: Object(external_this_wp_i18n_["__"])('User'), 2140 name: 'user', 2141 kind: 'root', 2142 baseURL: '/wp/v2/users', 2143 plural: 'users' 2144 }, { 2145 name: 'comment', 2146 kind: 'root', 2147 baseURL: '/wp/v2/comments', 2148 plural: 'comments', 2149 label: Object(external_this_wp_i18n_["__"])('Comment') 2150 }, { 2151 name: 'menu', 2152 kind: 'root', 2153 baseURL: '/__experimental/menus', 2154 plural: 'menus', 2155 label: Object(external_this_wp_i18n_["__"])('Menu') 2156 }, { 2157 name: 'menuItem', 2158 kind: 'root', 2159 baseURL: '/__experimental/menu-items', 2160 plural: 'menuItems', 2161 label: Object(external_this_wp_i18n_["__"])('Menu Item') 2162 }, { 2163 name: 'menuLocation', 2164 kind: 'root', 2165 baseURL: '/__experimental/menu-locations', 2166 plural: 'menuLocations', 2167 label: Object(external_this_wp_i18n_["__"])('Menu Location'), 2168 key: 'name' 2169 }]; 2170 var kinds = [{ 2171 name: 'postType', 2172 loadEntities: loadPostTypeEntities 2173 }, { 2174 name: 'taxonomy', 2175 loadEntities: loadTaxonomyEntities 2176 }]; 2177 /** 2178 * Returns the list of post type entities. 2179 * 2180 * @return {Promise} Entities promise 2181 */ 2182 2183 function loadPostTypeEntities() { 2184 var postTypes; 2185 return external_this_regeneratorRuntime_default.a.wrap(function loadPostTypeEntities$(_context) { 2186 while (1) { 2187 switch (_context.prev = _context.next) { 2188 case 0: 2189 _context.next = 2; 2190 return Object(external_this_wp_dataControls_["apiFetch"])({ 2191 path: '/wp/v2/types?context=edit' 2192 }); 2193 2194 case 2: 2195 postTypes = _context.sent; 2196 return _context.abrupt("return", Object(external_this_lodash_["map"])(postTypes, function (postType, name) { 2197 return { 2198 kind: 'postType', 2199 baseURL: '/wp/v2/' + postType.rest_base, 2200 name: name, 2201 label: postType.labels.singular_name, 2202 transientEdits: { 2203 blocks: true, 2204 selectionStart: true, 2205 selectionEnd: true 2206 }, 2207 mergedEdits: { 2208 meta: true 2209 }, 2210 getTitle: function getTitle(record) { 2211 if (name === 'wp_template_part' || name === 'wp_template') { 2212 return Object(external_this_lodash_["startCase"])(record.slug); 2213 } 2214 2215 return Object(external_this_lodash_["get"])(record, ['title', 'rendered'], record.id); 2216 } 2217 }; 2218 })); 2219 2220 case 4: 2221 case "end": 2222 return _context.stop(); 2223 } 2224 } 2225 }, entities_marked); 2226 } 2227 /** 2228 * Returns the list of the taxonomies entities. 2229 * 2230 * @return {Promise} Entities promise 2231 */ 2232 2233 2234 function loadTaxonomyEntities() { 2235 var taxonomies; 2236 return external_this_regeneratorRuntime_default.a.wrap(function loadTaxonomyEntities$(_context2) { 2237 while (1) { 2238 switch (_context2.prev = _context2.next) { 2239 case 0: 2240 _context2.next = 2; 2241 return Object(external_this_wp_dataControls_["apiFetch"])({ 2242 path: '/wp/v2/taxonomies?context=edit' 2243 }); 2244 2245 case 2: 2246 taxonomies = _context2.sent; 2247 return _context2.abrupt("return", Object(external_this_lodash_["map"])(taxonomies, function (taxonomy, name) { 2248 return { 2249 kind: 'taxonomy', 2250 baseURL: '/wp/v2/' + taxonomy.rest_base, 2251 name: name, 2252 label: taxonomy.labels.singular_name 2253 }; 2254 })); 2255 2256 case 4: 2257 case "end": 2258 return _context2.stop(); 2259 } 2260 } 2261 }, entities_marked2); 2262 } 2263 /** 2264 * Returns the entity's getter method name given its kind and name. 2265 * 2266 * @param {string} kind Entity kind. 2267 * @param {string} name Entity name. 2268 * @param {string} prefix Function prefix. 2269 * @param {boolean} usePlural Whether to use the plural form or not. 2270 * 2271 * @return {string} Method name 2272 */ 2273 2274 2275 var entities_getMethodName = function getMethodName(kind, name) { 2276 var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'get'; 2277 var usePlural = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 2278 var entity = Object(external_this_lodash_["find"])(defaultEntities, { 2279 kind: kind, 2280 name: name 2281 }); 2282 var kindPrefix = kind === 'root' ? '' : Object(external_this_lodash_["upperFirst"])(Object(external_this_lodash_["camelCase"])(kind)); 2283 var nameSuffix = Object(external_this_lodash_["upperFirst"])(Object(external_this_lodash_["camelCase"])(name)) + (usePlural ? 's' : ''); 2284 var suffix = usePlural && entity.plural ? Object(external_this_lodash_["upperFirst"])(Object(external_this_lodash_["camelCase"])(entity.plural)) : nameSuffix; 2285 return "".concat(prefix).concat(kindPrefix).concat(suffix); 2286 }; 2287 /** 2288 * Loads the kind entities into the store. 2289 * 2290 * @param {string} kind Kind 2291 * 2292 * @return {Array} Entities 2293 */ 2294 2295 function getKindEntities(kind) { 2296 var entities, kindConfig; 2297 return external_this_regeneratorRuntime_default.a.wrap(function getKindEntities$(_context3) { 2298 while (1) { 2299 switch (_context3.prev = _context3.next) { 2300 case 0: 2301 _context3.next = 2; 2302 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'getEntitiesByKind', kind); 2303 2304 case 2: 2305 entities = _context3.sent; 2306 2307 if (!(entities && entities.length !== 0)) { 2308 _context3.next = 5; 2309 break; 2310 } 2311 2312 return _context3.abrupt("return", entities); 2313 2314 case 5: 2315 kindConfig = Object(external_this_lodash_["find"])(kinds, { 2316 name: kind 2317 }); 2318 2319 if (kindConfig) { 2320 _context3.next = 8; 2321 break; 2322 } 2323 2324 return _context3.abrupt("return", []); 2325 2326 case 8: 2327 _context3.next = 10; 2328 return kindConfig.loadEntities(); 2329 2330 case 10: 2331 entities = _context3.sent; 2332 _context3.next = 13; 2333 return addEntities(entities); 2334 2335 case 13: 2336 return _context3.abrupt("return", entities); 2337 2338 case 14: 2339 case "end": 2340 return _context3.stop(); 2341 } 2342 } 2343 }, entities_marked3); 2344 } 2345 2346 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/get-normalized-comma-separable.js 2347 /** 2348 * Given a value which can be specified as one or the other of a comma-separated 2349 * string or an array, returns a value normalized to an array of strings, or 2350 * null if the value cannot be interpreted as either. 2351 * 2352 * @param {string|string[]|*} value 2353 * 2354 * @return {?(string[])} Normalized field value. 2355 */ 2356 function getNormalizedCommaSeparable(value) { 2357 if (typeof value === 'string') { 2358 return value.split(','); 2359 } else if (Array.isArray(value)) { 2360 return value; 2361 } 2362 2363 return null; 2364 } 2365 2366 /* harmony default export */ var get_normalized_comma_separable = (getNormalizedCommaSeparable); 2367 2368 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js 2369 /** 2370 * External dependencies 2371 */ 2372 2373 /** 2374 * Given a function, returns an enhanced function which caches the result and 2375 * tracks in WeakMap. The result is only cached if the original function is 2376 * passed a valid object-like argument (requirement for WeakMap key). 2377 * 2378 * @param {Function} fn Original function. 2379 * 2380 * @return {Function} Enhanced caching function. 2381 */ 2382 2383 function withWeakMapCache(fn) { 2384 var cache = new WeakMap(); 2385 return function (key) { 2386 var value; 2387 2388 if (cache.has(key)) { 2389 value = cache.get(key); 2390 } else { 2391 value = fn(key); // Can reach here if key is not valid for WeakMap, since `has` 2392 // will return false for invalid key. Since `set` will throw, 2393 // ensure that key is valid before setting into cache. 2394 2395 if (Object(external_this_lodash_["isObjectLike"])(key)) { 2396 cache.set(key, value); 2397 } 2398 } 2399 2400 return value; 2401 }; 2402 } 2403 2404 /* harmony default export */ var with_weak_map_cache = (withWeakMapCache); 2405 2406 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/get-query-parts.js 2407 2408 2409 /** 2410 * WordPress dependencies 2411 */ 2412 2413 /** 2414 * Internal dependencies 2415 */ 2416 2417 2418 /** 2419 * An object of properties describing a specific query. 2420 * 2421 * @typedef {Object} WPQueriedDataQueryParts 2422 * 2423 * @property {number} page The query page (1-based index, default 1). 2424 * @property {number} perPage Items per page for query (default 10). 2425 * @property {string} stableKey An encoded stable string of all non- 2426 * pagination, non-fields query parameters. 2427 * @property {?(string[])} fields Target subset of fields to derive from 2428 * item objects. 2429 * @property {?(number[])} include Specific item IDs to include. 2430 */ 2431 2432 /** 2433 * Given a query object, returns an object of parts, including pagination 2434 * details (`page` and `perPage`, or default values). All other properties are 2435 * encoded into a stable (idempotent) `stableKey` value. 2436 * 2437 * @param {Object} query Optional query object. 2438 * 2439 * @return {WPQueriedDataQueryParts} Query parts. 2440 */ 2441 2442 function getQueryParts(query) { 2443 /** 2444 * @type {WPQueriedDataQueryParts} 2445 */ 2446 var parts = { 2447 stableKey: '', 2448 page: 1, 2449 perPage: 10, 2450 fields: null, 2451 include: null 2452 }; // Ensure stable key by sorting keys. Also more efficient for iterating. 2453 2454 var keys = Object.keys(query).sort(); 2455 2456 for (var i = 0; i < keys.length; i++) { 2457 var key = keys[i]; 2458 var value = query[key]; 2459 2460 switch (key) { 2461 case 'page': 2462 parts[key] = Number(value); 2463 break; 2464 2465 case 'per_page': 2466 parts.perPage = Number(value); 2467 break; 2468 2469 case 'include': 2470 parts.include = get_normalized_comma_separable(value).map(Number); 2471 break; 2472 2473 default: 2474 // While in theory, we could exclude "_fields" from the stableKey 2475 // because two request with different fields have the same results 2476 // We're not able to ensure that because the server can decide to omit 2477 // fields from the response even if we explicitely asked for it. 2478 // Example: Asking for titles in posts without title support. 2479 if (key === '_fields') { 2480 parts.fields = get_normalized_comma_separable(value); 2481 } // While it could be any deterministic string, for simplicity's 2482 // sake mimic querystring encoding for stable key. 2483 // 2484 // TODO: For consistency with PHP implementation, addQueryArgs 2485 // should accept a key value pair, which may optimize its 2486 // implementation for our use here, vs. iterating an object 2487 // with only a single key. 2488 2489 2490 parts.stableKey += (parts.stableKey ? '&' : '') + Object(external_this_wp_url_["addQueryArgs"])('', Object(defineProperty["a" /* default */])({}, key, value)).slice(1); 2491 } 2492 } 2493 2494 return parts; 2495 } 2496 /* harmony default export */ var get_query_parts = (with_weak_map_cache(getQueryParts)); 2497 2498 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/reducer.js 2499 2500 2501 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; } 2502 2503 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; } 2504 2505 /** 2506 * External dependencies 2507 */ 2508 2509 /** 2510 * WordPress dependencies 2511 */ 2512 2513 2514 /** 2515 * Internal dependencies 2516 */ 2517 2518 2519 2520 2521 /** 2522 * Returns a merged array of item IDs, given details of the received paginated 2523 * items. The array is sparse-like with `undefined` entries where holes exist. 2524 * 2525 * @param {?Array<number>} itemIds Original item IDs (default empty array). 2526 * @param {number[]} nextItemIds Item IDs to merge. 2527 * @param {number} page Page of items merged. 2528 * @param {number} perPage Number of items per page. 2529 * 2530 * @return {number[]} Merged array of item IDs. 2531 */ 2532 2533 function getMergedItemIds(itemIds, nextItemIds, page, perPage) { 2534 var receivedAllIds = page === 1 && perPage === -1; 2535 2536 if (receivedAllIds) { 2537 return nextItemIds; 2538 } 2539 2540 var nextItemIdsStartIndex = (page - 1) * perPage; // If later page has already been received, default to the larger known 2541 // size of the existing array, else calculate as extending the existing. 2542 2543 var size = Math.max(itemIds.length, nextItemIdsStartIndex + nextItemIds.length); // Preallocate array since size is known. 2544 2545 var mergedItemIds = new Array(size); 2546 2547 for (var i = 0; i < size; i++) { 2548 // Preserve existing item ID except for subset of range of next items. 2549 var isInNextItemsRange = i >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + nextItemIds.length; 2550 mergedItemIds[i] = isInNextItemsRange ? nextItemIds[i - nextItemIdsStartIndex] : itemIds[i]; 2551 } 2552 2553 return mergedItemIds; 2554 } 2555 /** 2556 * Reducer tracking items state, keyed by ID. Items are assumed to be normal, 2557 * where identifiers are common across all queries. 2558 * 2559 * @param {Object} state Current state. 2560 * @param {Object} action Dispatched action. 2561 * 2562 * @return {Object} Next state. 2563 */ 2564 2565 function reducer_items() { 2566 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2567 var action = arguments.length > 1 ? arguments[1] : undefined; 2568 2569 switch (action.type) { 2570 case 'RECEIVE_ITEMS': 2571 var key = action.key || DEFAULT_ENTITY_KEY; 2572 return reducer_objectSpread(reducer_objectSpread({}, state), action.items.reduce(function (accumulator, value) { 2573 var itemId = value[key]; 2574 accumulator[itemId] = conservativeMapItem(state[itemId], value); 2575 return accumulator; 2576 }, {})); 2577 2578 case 'REMOVE_ITEMS': 2579 var newState = Object(external_this_lodash_["omit"])(state, action.itemIds); 2580 return newState; 2581 } 2582 2583 return state; 2584 } 2585 /** 2586 * Reducer tracking item completeness, keyed by ID. A complete item is one for 2587 * which all fields are known. This is used in supporting `_fields` queries, 2588 * where not all properties associated with an entity are necessarily returned. 2589 * In such cases, completeness is used as an indication of whether it would be 2590 * safe to use queried data for a non-`_fields`-limited request. 2591 * 2592 * @param {Object<string,boolean>} state Current state. 2593 * @param {Object} action Dispatched action. 2594 * 2595 * @return {Object<string,boolean>} Next state. 2596 */ 2597 2598 2599 function itemIsComplete() { 2600 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2601 var action = arguments.length > 1 ? arguments[1] : undefined; 2602 var type = action.type, 2603 query = action.query, 2604 _action$key = action.key, 2605 key = _action$key === void 0 ? DEFAULT_ENTITY_KEY : _action$key; 2606 2607 if (type !== 'RECEIVE_ITEMS') { 2608 return state; 2609 } // An item is considered complete if it is received without an associated 2610 // fields query. Ideally, this would be implemented in such a way where the 2611 // complete aggregate of all fields would satisfy completeness. Since the 2612 // fields are not consistent across all entity types, this would require 2613 // introspection on the REST schema for each entity to know which fields 2614 // compose a complete item for that entity. 2615 2616 2617 var isCompleteQuery = !query || !Array.isArray(get_query_parts(query).fields); 2618 return reducer_objectSpread(reducer_objectSpread({}, state), action.items.reduce(function (result, item) { 2619 var itemId = item[key]; // Defer to completeness if already assigned. Technically the 2620 // data may be outdated if receiving items for a field subset. 2621 2622 result[itemId] = state[itemId] || isCompleteQuery; 2623 return result; 2624 }, {})); 2625 } 2626 /** 2627 * Reducer tracking queries state, keyed by stable query key. Each reducer 2628 * query object includes `itemIds` and `requestingPageByPerPage`. 2629 * 2630 * @param {Object} state Current state. 2631 * @param {Object} action Dispatched action. 2632 * 2633 * @return {Object} Next state. 2634 */ 2635 2636 var receiveQueries = Object(external_this_lodash_["flowRight"])([// Limit to matching action type so we don't attempt to replace action on 2637 // an unhandled action. 2638 if_matching_action(function (action) { 2639 return 'query' in action; 2640 }), // Inject query parts into action for use both in `onSubKey` and reducer. 2641 replace_action(function (action) { 2642 // `ifMatchingAction` still passes on initialization, where state is 2643 // undefined and a query is not assigned. Avoid attempting to parse 2644 // parts. `onSubKey` will omit by lack of `stableKey`. 2645 if (action.query) { 2646 return reducer_objectSpread(reducer_objectSpread({}, action), get_query_parts(action.query)); 2647 } 2648 2649 return action; 2650 }), // Queries shape is shared, but keyed by query `stableKey` part. Original 2651 // reducer tracks only a single query object. 2652 on_sub_key('stableKey')])(function () { 2653 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 2654 var action = arguments.length > 1 ? arguments[1] : undefined; 2655 var type = action.type, 2656 page = action.page, 2657 perPage = action.perPage, 2658 _action$key2 = action.key, 2659 key = _action$key2 === void 0 ? DEFAULT_ENTITY_KEY : _action$key2; 2660 2661 if (type !== 'RECEIVE_ITEMS') { 2662 return state; 2663 } 2664 2665 return getMergedItemIds(state || [], Object(external_this_lodash_["map"])(action.items, key), page, perPage); 2666 }); 2667 /** 2668 * Reducer tracking queries state. 2669 * 2670 * @param {Object} state Current state. 2671 * @param {Object} action Dispatched action. 2672 * 2673 * @return {Object} Next state. 2674 */ 2675 2676 var reducer_queries = function queries() { 2677 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2678 var action = arguments.length > 1 ? arguments[1] : undefined; 2679 2680 switch (action.type) { 2681 case 'RECEIVE_ITEMS': 2682 return receiveQueries(state, action); 2683 2684 case 'REMOVE_ITEMS': 2685 var newState = reducer_objectSpread({}, state); 2686 2687 var removedItems = action.itemIds.reduce(function (result, itemId) { 2688 result[itemId] = true; 2689 return result; 2690 }, {}); 2691 Object(external_this_lodash_["forEach"])(newState, function (queryItems, key) { 2692 newState[key] = Object(external_this_lodash_["filter"])(queryItems, function (queryId) { 2693 return !removedItems[queryId]; 2694 }); 2695 }); 2696 return newState; 2697 2698 default: 2699 return state; 2700 } 2701 }; 2702 2703 /* harmony default export */ var queried_data_reducer = (Object(external_this_wp_data_["combineReducers"])({ 2704 items: reducer_items, 2705 itemIsComplete: itemIsComplete, 2706 queries: reducer_queries 2707 })); 2708 2709 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/reducer.js 2710 2711 2712 2713 2714 function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; 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 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; } } }; } 2715 2716 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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 2717 2718 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; } 2719 2720 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; } 2721 2722 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; } 2723 2724 /** 2725 * External dependencies 2726 */ 2727 2728 /** 2729 * WordPress dependencies 2730 */ 2731 2732 2733 2734 /** 2735 * Internal dependencies 2736 */ 2737 2738 2739 2740 2741 /** 2742 * Reducer managing terms state. Keyed by taxonomy slug, the value is either 2743 * undefined (if no request has been made for given taxonomy), null (if a 2744 * request is in-flight for given taxonomy), or the array of terms for the 2745 * taxonomy. 2746 * 2747 * @param {Object} state Current state. 2748 * @param {Object} action Dispatched action. 2749 * 2750 * @return {Object} Updated state. 2751 */ 2752 2753 function terms() { 2754 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2755 var action = arguments.length > 1 ? arguments[1] : undefined; 2756 2757 switch (action.type) { 2758 case 'RECEIVE_TERMS': 2759 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.taxonomy, action.terms)); 2760 } 2761 2762 return state; 2763 } 2764 /** 2765 * Reducer managing authors state. Keyed by id. 2766 * 2767 * @param {Object} state Current state. 2768 * @param {Object} action Dispatched action. 2769 * 2770 * @return {Object} Updated state. 2771 */ 2772 2773 function reducer_users() { 2774 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { 2775 byId: {}, 2776 queries: {} 2777 }; 2778 var action = arguments.length > 1 ? arguments[1] : undefined; 2779 2780 switch (action.type) { 2781 case 'RECEIVE_USER_QUERY': 2782 return { 2783 byId: build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state.byId), Object(external_this_lodash_["keyBy"])(action.users, 'id')), 2784 queries: build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state.queries), {}, Object(defineProperty["a" /* default */])({}, action.queryID, Object(external_this_lodash_["map"])(action.users, function (user) { 2785 return user.id; 2786 }))) 2787 }; 2788 } 2789 2790 return state; 2791 } 2792 /** 2793 * Reducer managing current user state. 2794 * 2795 * @param {Object} state Current state. 2796 * @param {Object} action Dispatched action. 2797 * 2798 * @return {Object} Updated state. 2799 */ 2800 2801 function reducer_currentUser() { 2802 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2803 var action = arguments.length > 1 ? arguments[1] : undefined; 2804 2805 switch (action.type) { 2806 case 'RECEIVE_CURRENT_USER': 2807 return action.currentUser; 2808 } 2809 2810 return state; 2811 } 2812 /** 2813 * Reducer managing taxonomies. 2814 * 2815 * @param {Object} state Current state. 2816 * @param {Object} action Dispatched action. 2817 * 2818 * @return {Object} Updated state. 2819 */ 2820 2821 function reducer_taxonomies() { 2822 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 2823 var action = arguments.length > 1 ? arguments[1] : undefined; 2824 2825 switch (action.type) { 2826 case 'RECEIVE_TAXONOMIES': 2827 return action.taxonomies; 2828 } 2829 2830 return state; 2831 } 2832 /** 2833 * Reducer managing the current theme. 2834 * 2835 * @param {string} state Current state. 2836 * @param {Object} action Dispatched action. 2837 * 2838 * @return {string} Updated state. 2839 */ 2840 2841 function currentTheme() { 2842 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; 2843 var action = arguments.length > 1 ? arguments[1] : undefined; 2844 2845 switch (action.type) { 2846 case 'RECEIVE_CURRENT_THEME': 2847 return action.currentTheme.stylesheet; 2848 } 2849 2850 return state; 2851 } 2852 /** 2853 * Reducer managing installed themes. 2854 * 2855 * @param {Object} state Current state. 2856 * @param {Object} action Dispatched action. 2857 * 2858 * @return {Object} Updated state. 2859 */ 2860 2861 function themes() { 2862 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2863 var action = arguments.length > 1 ? arguments[1] : undefined; 2864 2865 switch (action.type) { 2866 case 'RECEIVE_CURRENT_THEME': 2867 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.currentTheme.stylesheet, action.currentTheme)); 2868 } 2869 2870 return state; 2871 } 2872 /** 2873 * Reducer managing theme supports data. 2874 * 2875 * @param {Object} state Current state. 2876 * @param {Object} action Dispatched action. 2877 * 2878 * @return {Object} Updated state. 2879 */ 2880 2881 function themeSupports() { 2882 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2883 var action = arguments.length > 1 ? arguments[1] : undefined; 2884 2885 switch (action.type) { 2886 case 'RECEIVE_THEME_SUPPORTS': 2887 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state), action.themeSupports); 2888 } 2889 2890 return state; 2891 } 2892 /** 2893 * Higher Order Reducer for a given entity config. It supports: 2894 * 2895 * - Fetching 2896 * - Editing 2897 * - Saving 2898 * 2899 * @param {Object} entityConfig Entity config. 2900 * 2901 * @return {Function} Reducer. 2902 */ 2903 2904 function reducer_entity(entityConfig) { 2905 return Object(external_this_lodash_["flowRight"])([// Limit to matching action type so we don't attempt to replace action on 2906 // an unhandled action. 2907 if_matching_action(function (action) { 2908 return action.name && action.kind && action.name === entityConfig.name && action.kind === entityConfig.kind; 2909 }), // Inject the entity config into the action. 2910 replace_action(function (action) { 2911 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, action), {}, { 2912 key: entityConfig.key || DEFAULT_ENTITY_KEY 2913 }); 2914 })])(Object(external_this_wp_data_["combineReducers"])({ 2915 queriedData: queried_data_reducer, 2916 edits: function edits() { 2917 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2918 var action = arguments.length > 1 ? arguments[1] : undefined; 2919 2920 switch (action.type) { 2921 case 'RECEIVE_ITEMS': 2922 var nextState = build_module_reducer_objectSpread({}, state); 2923 2924 var _iterator = _createForOfIteratorHelper(action.items), 2925 _step; 2926 2927 try { 2928 var _loop = function _loop() { 2929 var record = _step.value; 2930 var recordId = record[action.key]; 2931 var edits = nextState[recordId]; 2932 2933 if (!edits) { 2934 return "continue"; 2935 } 2936 2937 var nextEdits = Object.keys(edits).reduce(function (acc, key) { 2938 // If the edited value is still different to the persisted value, 2939 // keep the edited value in edits. 2940 if ( // Edits are the "raw" attribute values, but records may have 2941 // objects with more properties, so we use `get` here for the 2942 // comparison. 2943 !Object(external_this_lodash_["isEqual"])(edits[key], Object(external_this_lodash_["get"])(record[key], 'raw', record[key]))) { 2944 acc[key] = edits[key]; 2945 } 2946 2947 return acc; 2948 }, {}); 2949 2950 if (Object.keys(nextEdits).length) { 2951 nextState[recordId] = nextEdits; 2952 } else { 2953 delete nextState[recordId]; 2954 } 2955 }; 2956 2957 for (_iterator.s(); !(_step = _iterator.n()).done;) { 2958 var _ret = _loop(); 2959 2960 if (_ret === "continue") continue; 2961 } 2962 } catch (err) { 2963 _iterator.e(err); 2964 } finally { 2965 _iterator.f(); 2966 } 2967 2968 return nextState; 2969 2970 case 'EDIT_ENTITY_RECORD': 2971 var nextEdits = build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state[action.recordId]), action.edits); 2972 2973 Object.keys(nextEdits).forEach(function (key) { 2974 // Delete cleared edits so that the properties 2975 // are not considered dirty. 2976 if (nextEdits[key] === undefined) { 2977 delete nextEdits[key]; 2978 } 2979 }); 2980 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.recordId, nextEdits)); 2981 } 2982 2983 return state; 2984 }, 2985 saving: function saving() { 2986 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2987 var action = arguments.length > 1 ? arguments[1] : undefined; 2988 2989 switch (action.type) { 2990 case 'SAVE_ENTITY_RECORD_START': 2991 case 'SAVE_ENTITY_RECORD_FINISH': 2992 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.recordId, { 2993 pending: action.type === 'SAVE_ENTITY_RECORD_START', 2994 error: action.error, 2995 isAutosave: action.isAutosave 2996 })); 2997 } 2998 2999 return state; 3000 }, 3001 deleting: function deleting() { 3002 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3003 var action = arguments.length > 1 ? arguments[1] : undefined; 3004 3005 switch (action.type) { 3006 case 'DELETE_ENTITY_RECORD_START': 3007 case 'DELETE_ENTITY_RECORD_FINISH': 3008 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.recordId, { 3009 pending: action.type === 'DELETE_ENTITY_RECORD_START', 3010 error: action.error 3011 })); 3012 } 3013 3014 return state; 3015 } 3016 })); 3017 } 3018 /** 3019 * Reducer keeping track of the registered entities. 3020 * 3021 * @param {Object} state Current state. 3022 * @param {Object} action Dispatched action. 3023 * 3024 * @return {Object} Updated state. 3025 */ 3026 3027 3028 function entitiesConfig() { 3029 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultEntities; 3030 var action = arguments.length > 1 ? arguments[1] : undefined; 3031 3032 switch (action.type) { 3033 case 'ADD_ENTITIES': 3034 return [].concat(Object(toConsumableArray["a" /* default */])(state), Object(toConsumableArray["a" /* default */])(action.entities)); 3035 } 3036 3037 return state; 3038 } 3039 /** 3040 * Reducer keeping track of the registered entities config and data. 3041 * 3042 * @param {Object} state Current state. 3043 * @param {Object} action Dispatched action. 3044 * 3045 * @return {Object} Updated state. 3046 */ 3047 3048 var reducer_entities = function entities() { 3049 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3050 var action = arguments.length > 1 ? arguments[1] : undefined; 3051 var newConfig = entitiesConfig(state.config, action); // Generates a dynamic reducer for the entities 3052 3053 var entitiesDataReducer = state.reducer; 3054 3055 if (!entitiesDataReducer || newConfig !== state.config) { 3056 var entitiesByKind = Object(external_this_lodash_["groupBy"])(newConfig, 'kind'); 3057 entitiesDataReducer = Object(external_this_wp_data_["combineReducers"])(Object.entries(entitiesByKind).reduce(function (memo, _ref) { 3058 var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 2), 3059 kind = _ref2[0], 3060 subEntities = _ref2[1]; 3061 3062 var kindReducer = Object(external_this_wp_data_["combineReducers"])(subEntities.reduce(function (kindMemo, entityConfig) { 3063 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, kindMemo), {}, Object(defineProperty["a" /* default */])({}, entityConfig.name, reducer_entity(entityConfig))); 3064 }, {})); 3065 memo[kind] = kindReducer; 3066 return memo; 3067 }, {})); 3068 } 3069 3070 var newData = entitiesDataReducer(state.data, action); 3071 3072 if (newData === state.data && newConfig === state.config && entitiesDataReducer === state.reducer) { 3073 return state; 3074 } 3075 3076 return { 3077 reducer: entitiesDataReducer, 3078 data: newData, 3079 config: newConfig 3080 }; 3081 }; 3082 /** 3083 * Reducer keeping track of entity edit undo history. 3084 * 3085 * @param {Object} state Current state. 3086 * @param {Object} action Dispatched action. 3087 * 3088 * @return {Object} Updated state. 3089 */ 3090 3091 var UNDO_INITIAL_STATE = []; 3092 UNDO_INITIAL_STATE.offset = 0; 3093 var lastEditAction; 3094 function reducer_undo() { 3095 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UNDO_INITIAL_STATE; 3096 var action = arguments.length > 1 ? arguments[1] : undefined; 3097 3098 switch (action.type) { 3099 case 'EDIT_ENTITY_RECORD': 3100 case 'CREATE_UNDO_LEVEL': 3101 var isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL'; 3102 var isUndoOrRedo = !isCreateUndoLevel && (action.meta.isUndo || action.meta.isRedo); 3103 3104 if (isCreateUndoLevel) { 3105 action = lastEditAction; 3106 } else if (!isUndoOrRedo) { 3107 // Don't lose the last edit cache if the new one only has transient edits. 3108 // Transient edits don't create new levels so updating the cache would make 3109 // us skip an edit later when creating levels explicitly. 3110 if (Object.keys(action.edits).some(function (key) { 3111 return !action.transientEdits[key]; 3112 })) { 3113 lastEditAction = action; 3114 } else { 3115 lastEditAction = build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, action), {}, { 3116 edits: build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, lastEditAction && lastEditAction.edits), action.edits) 3117 }); 3118 } 3119 } 3120 3121 var nextState; 3122 3123 if (isUndoOrRedo) { 3124 nextState = Object(toConsumableArray["a" /* default */])(state); 3125 nextState.offset = state.offset + (action.meta.isUndo ? -1 : 1); 3126 3127 if (state.flattenedUndo) { 3128 // The first undo in a sequence of undos might happen while we have 3129 // flattened undos in state. If this is the case, we want execution 3130 // to continue as if we were creating an explicit undo level. This 3131 // will result in an extra undo level being appended with the flattened 3132 // undo values. 3133 isCreateUndoLevel = true; 3134 action = lastEditAction; 3135 } else { 3136 return nextState; 3137 } 3138 } 3139 3140 if (!action.meta.undo) { 3141 return state; 3142 } // Transient edits don't create an undo level, but are 3143 // reachable in the next meaningful edit to which they 3144 // are merged. They are defined in the entity's config. 3145 3146 3147 if (!isCreateUndoLevel && !Object.keys(action.edits).some(function (key) { 3148 return !action.transientEdits[key]; 3149 })) { 3150 nextState = Object(toConsumableArray["a" /* default */])(state); 3151 nextState.flattenedUndo = build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state.flattenedUndo), action.edits); 3152 nextState.offset = state.offset; 3153 return nextState; 3154 } // Clear potential redos, because this only supports linear history. 3155 3156 3157 nextState = nextState || state.slice(0, state.offset || undefined); 3158 nextState.offset = nextState.offset || 0; 3159 nextState.pop(); 3160 3161 if (!isCreateUndoLevel) { 3162 nextState.push({ 3163 kind: action.meta.undo.kind, 3164 name: action.meta.undo.name, 3165 recordId: action.meta.undo.recordId, 3166 edits: build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state.flattenedUndo), action.meta.undo.edits) 3167 }); 3168 } // When an edit is a function it's an optimization to avoid running some expensive operation. 3169 // We can't rely on the function references being the same so we opt out of comparing them here. 3170 3171 3172 var comparisonUndoEdits = Object.values(action.meta.undo.edits).filter(function (edit) { 3173 return typeof edit !== 'function'; 3174 }); 3175 var comparisonEdits = Object.values(action.edits).filter(function (edit) { 3176 return typeof edit !== 'function'; 3177 }); 3178 3179 if (!external_this_wp_isShallowEqual_default()(comparisonUndoEdits, comparisonEdits)) { 3180 nextState.push({ 3181 kind: action.kind, 3182 name: action.name, 3183 recordId: action.recordId, 3184 edits: isCreateUndoLevel ? build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state.flattenedUndo), action.edits) : action.edits 3185 }); 3186 } 3187 3188 return nextState; 3189 } 3190 3191 return state; 3192 } 3193 /** 3194 * Reducer managing embed preview data. 3195 * 3196 * @param {Object} state Current state. 3197 * @param {Object} action Dispatched action. 3198 * 3199 * @return {Object} Updated state. 3200 */ 3201 3202 function embedPreviews() { 3203 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3204 var action = arguments.length > 1 ? arguments[1] : undefined; 3205 3206 switch (action.type) { 3207 case 'RECEIVE_EMBED_PREVIEW': 3208 var url = action.url, 3209 preview = action.preview; 3210 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, url, preview)); 3211 } 3212 3213 return state; 3214 } 3215 /** 3216 * State which tracks whether the user can perform an action on a REST 3217 * resource. 3218 * 3219 * @param {Object} state Current state. 3220 * @param {Object} action Dispatched action. 3221 * 3222 * @return {Object} Updated state. 3223 */ 3224 3225 function userPermissions() { 3226 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3227 var action = arguments.length > 1 ? arguments[1] : undefined; 3228 3229 switch (action.type) { 3230 case 'RECEIVE_USER_PERMISSION': 3231 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.key, action.isAllowed)); 3232 } 3233 3234 return state; 3235 } 3236 /** 3237 * Reducer returning autosaves keyed by their parent's post id. 3238 * 3239 * @param {Object} state Current state. 3240 * @param {Object} action Dispatched action. 3241 * 3242 * @return {Object} Updated state. 3243 */ 3244 3245 function reducer_autosaves() { 3246 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3247 var action = arguments.length > 1 ? arguments[1] : undefined; 3248 3249 switch (action.type) { 3250 case 'RECEIVE_AUTOSAVES': 3251 var postId = action.postId, 3252 autosavesData = action.autosaves; 3253 return build_module_reducer_objectSpread(build_module_reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, postId, autosavesData)); 3254 } 3255 3256 return state; 3257 } 3258 /* harmony default export */ var build_module_reducer = (Object(external_this_wp_data_["combineReducers"])({ 3259 terms: terms, 3260 users: reducer_users, 3261 currentTheme: currentTheme, 3262 currentUser: reducer_currentUser, 3263 taxonomies: reducer_taxonomies, 3264 themes: themes, 3265 themeSupports: themeSupports, 3266 entities: reducer_entities, 3267 undo: reducer_undo, 3268 embedPreviews: embedPreviews, 3269 userPermissions: userPermissions, 3270 autosaves: reducer_autosaves 3271 })); 3272 3273 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js 3274 var rememo = __webpack_require__(42); 3275 3276 // EXTERNAL MODULE: external {"this":["wp","deprecated"]} 3277 var external_this_wp_deprecated_ = __webpack_require__(36); 3278 var external_this_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_deprecated_); 3279 3280 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/name.js 3281 /** 3282 * The reducer key used by core data in store registration. 3283 * This is defined in a separate file to avoid cycle-dependency 3284 * 3285 * @type {string} 3286 */ 3287 var REDUCER_KEY = 'core'; 3288 3289 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js 3290 var equivalent_key_map = __webpack_require__(107); 3291 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map); 3292 3293 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/selectors.js 3294 /** 3295 * External dependencies 3296 */ 3297 3298 3299 3300 /** 3301 * Internal dependencies 3302 */ 3303 3304 3305 /** 3306 * Cache of state keys to EquivalentKeyMap where the inner map tracks queries 3307 * to their resulting items set. WeakMap allows garbage collection on expired 3308 * state references. 3309 * 3310 * @type {WeakMap<Object,EquivalentKeyMap>} 3311 */ 3312 3313 var queriedItemsCacheByState = new WeakMap(); 3314 /** 3315 * Returns items for a given query, or null if the items are not known. 3316 * 3317 * @param {Object} state State object. 3318 * @param {?Object} query Optional query. 3319 * 3320 * @return {?Array} Query items. 3321 */ 3322 3323 function getQueriedItemsUncached(state, query) { 3324 var _getQueryParts = get_query_parts(query), 3325 stableKey = _getQueryParts.stableKey, 3326 page = _getQueryParts.page, 3327 perPage = _getQueryParts.perPage, 3328 include = _getQueryParts.include, 3329 fields = _getQueryParts.fields; 3330 3331 var itemIds; 3332 3333 if (Array.isArray(include) && !stableKey) { 3334 // If the parsed query yields a set of IDs, but otherwise no filtering, 3335 // it's safe to consider targeted item IDs as the include set. This 3336 // doesn't guarantee that those objects have been queried, which is 3337 // accounted for below in the loop `null` return. 3338 itemIds = include; // TODO: Avoid storing the empty stable string in reducer, since it 3339 // can be computed dynamically here always. 3340 } else if (state.queries[stableKey]) { 3341 itemIds = state.queries[stableKey]; 3342 } 3343 3344 if (!itemIds) { 3345 return null; 3346 } 3347 3348 var startOffset = perPage === -1 ? 0 : (page - 1) * perPage; 3349 var endOffset = perPage === -1 ? itemIds.length : Math.min(startOffset + perPage, itemIds.length); 3350 var items = []; 3351 3352 for (var i = startOffset; i < endOffset; i++) { 3353 var itemId = itemIds[i]; 3354 3355 if (Array.isArray(include) && !include.includes(itemId)) { 3356 continue; 3357 } 3358 3359 if (!state.items.hasOwnProperty(itemId)) { 3360 return null; 3361 } 3362 3363 var item = state.items[itemId]; 3364 var filteredItem = void 0; 3365 3366 if (Array.isArray(fields)) { 3367 filteredItem = {}; 3368 3369 for (var f = 0; f < fields.length; f++) { 3370 var field = fields[f].split('.'); 3371 var value = Object(external_this_lodash_["get"])(item, field); 3372 Object(external_this_lodash_["set"])(filteredItem, field, value); 3373 } 3374 } else { 3375 // If expecting a complete item, validate that completeness, or 3376 // otherwise abort. 3377 if (!state.itemIsComplete[itemId]) { 3378 return null; 3379 } 3380 3381 filteredItem = item; 3382 } 3383 3384 items.push(filteredItem); 3385 } 3386 3387 return items; 3388 } 3389 /** 3390 * Returns items for a given query, or null if the items are not known. Caches 3391 * result both per state (by reference) and per query (by deep equality). 3392 * The caching approach is intended to be durable to query objects which are 3393 * deeply but not referentially equal, since otherwise: 3394 * 3395 * `getQueriedItems( state, {} ) !== getQueriedItems( state, {} )` 3396 * 3397 * @param {Object} state State object. 3398 * @param {?Object} query Optional query. 3399 * 3400 * @return {?Array} Query items. 3401 */ 3402 3403 3404 var getQueriedItems = Object(rememo["a" /* default */])(function (state) { 3405 var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 3406 var queriedItemsCache = queriedItemsCacheByState.get(state); 3407 3408 if (queriedItemsCache) { 3409 var queriedItems = queriedItemsCache.get(query); 3410 3411 if (queriedItems !== undefined) { 3412 return queriedItems; 3413 } 3414 } else { 3415 queriedItemsCache = new equivalent_key_map_default.a(); 3416 queriedItemsCacheByState.set(state, queriedItemsCache); 3417 } 3418 3419 var items = getQueriedItemsUncached(state, query); 3420 queriedItemsCache.set(query, items); 3421 return items; 3422 }); 3423 3424 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/selectors.js 3425 3426 3427 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; } 3428 3429 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; } 3430 3431 /** 3432 * External dependencies 3433 */ 3434 3435 3436 /** 3437 * WordPress dependencies 3438 */ 3439 3440 3441 3442 3443 /** 3444 * Internal dependencies 3445 */ 3446 3447 3448 3449 3450 3451 /** 3452 * Returns true if a request is in progress for embed preview data, or false 3453 * otherwise. 3454 * 3455 * @param {Object} state Data state. 3456 * @param {string} url URL the preview would be for. 3457 * 3458 * @return {boolean} Whether a request is in progress for an embed preview. 3459 */ 3460 3461 var isRequestingEmbedPreview = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { 3462 return function (state, url) { 3463 return select('core/data').isResolving(REDUCER_KEY, 'getEmbedPreview', [url]); 3464 }; 3465 }); 3466 /** 3467 * Returns all available authors. 3468 * 3469 * @param {Object} state Data state. 3470 * @param {Object|undefined} query Optional object of query parameters to 3471 * include with request. 3472 * @return {Array} Authors list. 3473 */ 3474 3475 function getAuthors(state, query) { 3476 var path = Object(external_this_wp_url_["addQueryArgs"])('/wp/v2/users/?who=authors&per_page=100', query); 3477 return getUserQueryResults(state, path); 3478 } 3479 /** 3480 * Returns all available authors. 3481 * 3482 * @param {Object} state Data state. 3483 * @param {number} id The author id. 3484 * 3485 * @return {Array} Authors list. 3486 */ 3487 3488 function __unstableGetAuthor(state, id) { 3489 return Object(external_this_lodash_["get"])(state, ['users', 'byId', id], null); 3490 } 3491 /** 3492 * Returns the current user. 3493 * 3494 * @param {Object} state Data state. 3495 * 3496 * @return {Object} Current user object. 3497 */ 3498 3499 function getCurrentUser(state) { 3500 return state.currentUser; 3501 } 3502 /** 3503 * Returns all the users returned by a query ID. 3504 * 3505 * @param {Object} state Data state. 3506 * @param {string} queryID Query ID. 3507 * 3508 * @return {Array} Users list. 3509 */ 3510 3511 var getUserQueryResults = Object(rememo["a" /* default */])(function (state, queryID) { 3512 var queryResults = state.users.queries[queryID]; 3513 return Object(external_this_lodash_["map"])(queryResults, function (id) { 3514 return state.users.byId[id]; 3515 }); 3516 }, function (state, queryID) { 3517 return [state.users.queries[queryID], state.users.byId]; 3518 }); 3519 /** 3520 * Returns whether the entities for the give kind are loaded. 3521 * 3522 * @param {Object} state Data state. 3523 * @param {string} kind Entity kind. 3524 * 3525 * @return {boolean} Whether the entities are loaded 3526 */ 3527 3528 function getEntitiesByKind(state, kind) { 3529 return Object(external_this_lodash_["filter"])(state.entities.config, { 3530 kind: kind 3531 }); 3532 } 3533 /** 3534 * Returns the entity object given its kind and name. 3535 * 3536 * @param {Object} state Data state. 3537 * @param {string} kind Entity kind. 3538 * @param {string} name Entity name. 3539 * 3540 * @return {Object} Entity 3541 */ 3542 3543 function selectors_getEntity(state, kind, name) { 3544 return Object(external_this_lodash_["find"])(state.entities.config, { 3545 kind: kind, 3546 name: name 3547 }); 3548 } 3549 /** 3550 * Returns the Entity's record object by key. Returns `null` if the value is not 3551 * yet received, undefined if the value entity is known to not exist, or the 3552 * entity object if it exists and is received. 3553 * 3554 * @param {Object} state State tree 3555 * @param {string} kind Entity kind. 3556 * @param {string} name Entity name. 3557 * @param {number} key Record's key 3558 * @param {?Object} query Optional query. 3559 * 3560 * @return {Object?} Record. 3561 */ 3562 3563 function getEntityRecord(state, kind, name, key, query) { 3564 var queriedState = Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'queriedData']); 3565 3566 if (!queriedState) { 3567 return undefined; 3568 } 3569 3570 if (query === undefined) { 3571 // If expecting a complete item, validate that completeness. 3572 if (!queriedState.itemIsComplete[key]) { 3573 return undefined; 3574 } 3575 3576 return queriedState.items[key]; 3577 } 3578 3579 var item = queriedState.items[key]; 3580 3581 if (item && query._fields) { 3582 var filteredItem = {}; 3583 var fields = get_normalized_comma_separable(query._fields); 3584 3585 for (var f = 0; f < fields.length; f++) { 3586 var field = fields[f].split('.'); 3587 var value = Object(external_this_lodash_["get"])(item, field); 3588 Object(external_this_lodash_["set"])(filteredItem, field, value); 3589 } 3590 3591 return filteredItem; 3592 } 3593 3594 return item; 3595 } 3596 /** 3597 * 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. 3598 * 3599 * @param {Object} state State tree 3600 * @param {string} kind Entity kind. 3601 * @param {string} name Entity name. 3602 * @param {number} key Record's key 3603 * 3604 * @return {Object|null} Record. 3605 */ 3606 3607 function __experimentalGetEntityRecordNoResolver(state, kind, name, key) { 3608 return getEntityRecord(state, kind, name, key); 3609 } 3610 /** 3611 * Returns the entity's record object by key, 3612 * with its attributes mapped to their raw values. 3613 * 3614 * @param {Object} state State tree. 3615 * @param {string} kind Entity kind. 3616 * @param {string} name Entity name. 3617 * @param {number} key Record's key. 3618 * 3619 * @return {Object?} Object with the entity's raw attributes. 3620 */ 3621 3622 var getRawEntityRecord = Object(rememo["a" /* default */])(function (state, kind, name, key) { 3623 var record = getEntityRecord(state, kind, name, key); 3624 return record && Object.keys(record).reduce(function (accumulator, _key) { 3625 // Because edits are the "raw" attribute values, 3626 // we return those from record selectors to make rendering, 3627 // comparisons, and joins with edits easier. 3628 accumulator[_key] = Object(external_this_lodash_["get"])(record[_key], 'raw', record[_key]); 3629 return accumulator; 3630 }, {}); 3631 }, function (state) { 3632 return [state.entities.data]; 3633 }); 3634 /** 3635 * Returns true if records have been received for the given set of parameters, 3636 * or false otherwise. 3637 * 3638 * @param {Object} state State tree 3639 * @param {string} kind Entity kind. 3640 * @param {string} name Entity name. 3641 * @param {?Object} query Optional terms query. 3642 * 3643 * @return {boolean} Whether entity records have been received. 3644 */ 3645 3646 function hasEntityRecords(state, kind, name, query) { 3647 return Array.isArray(getEntityRecords(state, kind, name, query)); 3648 } 3649 /** 3650 * Returns the Entity's records. 3651 * 3652 * @param {Object} state State tree 3653 * @param {string} kind Entity kind. 3654 * @param {string} name Entity name. 3655 * @param {?Object} query Optional terms query. 3656 * 3657 * @return {?Array} Records. 3658 */ 3659 3660 function getEntityRecords(state, kind, name, query) { 3661 // Queried data state is prepopulated for all known entities. If this is not 3662 // assigned for the given parameters, then it is known to not exist. Thus, a 3663 // return value of an empty array is used instead of `null` (where `null` is 3664 // otherwise used to represent an unknown state). 3665 var queriedState = Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'queriedData']); 3666 3667 if (!queriedState) { 3668 return []; 3669 } 3670 3671 return getQueriedItems(queriedState, query); 3672 } 3673 /** 3674 * Returns the list of dirty entity records. 3675 * 3676 * @param {Object} state State tree. 3677 * 3678 * @return {[{ title: string, key: string, name: string, kind: string }]} The list of updated records 3679 */ 3680 3681 var __experimentalGetDirtyEntityRecords = Object(rememo["a" /* default */])(function (state) { 3682 var data = state.entities.data; 3683 var dirtyRecords = []; 3684 Object.keys(data).forEach(function (kind) { 3685 Object.keys(data[kind]).forEach(function (name) { 3686 var primaryKeys = Object.keys(data[kind][name].edits).filter(function (primaryKey) { 3687 return hasEditsForEntityRecord(state, kind, name, primaryKey); 3688 }); 3689 3690 if (primaryKeys.length) { 3691 var entity = selectors_getEntity(state, kind, name); 3692 primaryKeys.forEach(function (primaryKey) { 3693 var entityRecord = getEditedEntityRecord(state, kind, name, primaryKey); 3694 dirtyRecords.push({ 3695 // We avoid using primaryKey because it's transformed into a string 3696 // when it's used as an object key. 3697 key: entityRecord[entity.key || DEFAULT_ENTITY_KEY], 3698 title: !entity.getTitle ? '' : entity.getTitle(entityRecord), 3699 name: name, 3700 kind: kind 3701 }); 3702 }); 3703 } 3704 }); 3705 }); 3706 return dirtyRecords; 3707 }, function (state) { 3708 return [state.entities.data]; 3709 }); 3710 /** 3711 * Returns the specified entity record's edits. 3712 * 3713 * @param {Object} state State tree. 3714 * @param {string} kind Entity kind. 3715 * @param {string} name Entity name. 3716 * @param {number} recordId Record ID. 3717 * 3718 * @return {Object?} The entity record's edits. 3719 */ 3720 3721 function getEntityRecordEdits(state, kind, name, recordId) { 3722 return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'edits', recordId]); 3723 } 3724 /** 3725 * Returns the specified entity record's non transient edits. 3726 * 3727 * Transient edits don't create an undo level, and 3728 * are not considered for change detection. 3729 * They are defined in the entity's config. 3730 * 3731 * @param {Object} state State tree. 3732 * @param {string} kind Entity kind. 3733 * @param {string} name Entity name. 3734 * @param {number} recordId Record ID. 3735 * 3736 * @return {Object?} The entity record's non transient edits. 3737 */ 3738 3739 var getEntityRecordNonTransientEdits = Object(rememo["a" /* default */])(function (state, kind, name, recordId) { 3740 var _ref = selectors_getEntity(state, kind, name) || {}, 3741 transientEdits = _ref.transientEdits; 3742 3743 var edits = getEntityRecordEdits(state, kind, name, recordId) || {}; 3744 3745 if (!transientEdits) { 3746 return edits; 3747 } 3748 3749 return Object.keys(edits).reduce(function (acc, key) { 3750 if (!transientEdits[key]) { 3751 acc[key] = edits[key]; 3752 } 3753 3754 return acc; 3755 }, {}); 3756 }, function (state) { 3757 return [state.entities.config, state.entities.data]; 3758 }); 3759 /** 3760 * Returns true if the specified entity record has edits, 3761 * and false otherwise. 3762 * 3763 * @param {Object} state State tree. 3764 * @param {string} kind Entity kind. 3765 * @param {string} name Entity name. 3766 * @param {number} recordId Record ID. 3767 * 3768 * @return {boolean} Whether the entity record has edits or not. 3769 */ 3770 3771 function hasEditsForEntityRecord(state, kind, name, recordId) { 3772 return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(getEntityRecordNonTransientEdits(state, kind, name, recordId)).length > 0; 3773 } 3774 /** 3775 * Returns the specified entity record, merged with its edits. 3776 * 3777 * @param {Object} state State tree. 3778 * @param {string} kind Entity kind. 3779 * @param {string} name Entity name. 3780 * @param {number} recordId Record ID. 3781 * 3782 * @return {Object?} The entity record, merged with its edits. 3783 */ 3784 3785 var getEditedEntityRecord = Object(rememo["a" /* default */])(function (state, kind, name, recordId) { 3786 return selectors_objectSpread(selectors_objectSpread({}, getRawEntityRecord(state, kind, name, recordId)), getEntityRecordEdits(state, kind, name, recordId)); 3787 }, function (state) { 3788 return [state.entities.data]; 3789 }); 3790 /** 3791 * Returns true if the specified entity record is autosaving, and false otherwise. 3792 * 3793 * @param {Object} state State tree. 3794 * @param {string} kind Entity kind. 3795 * @param {string} name Entity name. 3796 * @param {number} recordId Record ID. 3797 * 3798 * @return {boolean} Whether the entity record is autosaving or not. 3799 */ 3800 3801 function isAutosavingEntityRecord(state, kind, name, recordId) { 3802 var _get = Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId], {}), 3803 pending = _get.pending, 3804 isAutosave = _get.isAutosave; 3805 3806 return Boolean(pending && isAutosave); 3807 } 3808 /** 3809 * Returns true if the specified entity record is saving, and false otherwise. 3810 * 3811 * @param {Object} state State tree. 3812 * @param {string} kind Entity kind. 3813 * @param {string} name Entity name. 3814 * @param {number} recordId Record ID. 3815 * 3816 * @return {boolean} Whether the entity record is saving or not. 3817 */ 3818 3819 function isSavingEntityRecord(state, kind, name, recordId) { 3820 return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId, 'pending'], false); 3821 } 3822 /** 3823 * Returns true if the specified entity record is deleting, and false otherwise. 3824 * 3825 * @param {Object} state State tree. 3826 * @param {string} kind Entity kind. 3827 * @param {string} name Entity name. 3828 * @param {number} recordId Record ID. 3829 * 3830 * @return {boolean} Whether the entity record is deleting or not. 3831 */ 3832 3833 function isDeletingEntityRecord(state, kind, name, recordId) { 3834 return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'deleting', recordId, 'pending'], false); 3835 } 3836 /** 3837 * Returns the specified entity record's last save error. 3838 * 3839 * @param {Object} state State tree. 3840 * @param {string} kind Entity kind. 3841 * @param {string} name Entity name. 3842 * @param {number} recordId Record ID. 3843 * 3844 * @return {Object?} The entity record's save error. 3845 */ 3846 3847 function getLastEntitySaveError(state, kind, name, recordId) { 3848 return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId, 'error']); 3849 } 3850 /** 3851 * Returns the specified entity record's last delete error. 3852 * 3853 * @param {Object} state State tree. 3854 * @param {string} kind Entity kind. 3855 * @param {string} name Entity name. 3856 * @param {number} recordId Record ID. 3857 * 3858 * @return {Object?} The entity record's save error. 3859 */ 3860 3861 function getLastEntityDeleteError(state, kind, name, recordId) { 3862 return Object(external_this_lodash_["get"])(state.entities.data, [kind, name, 'deleting', recordId, 'error']); 3863 } 3864 /** 3865 * Returns the current undo offset for the 3866 * entity records edits history. The offset 3867 * represents how many items from the end 3868 * of the history stack we are at. 0 is the 3869 * last edit, -1 is the second last, and so on. 3870 * 3871 * @param {Object} state State tree. 3872 * 3873 * @return {number} The current undo offset. 3874 */ 3875 3876 function getCurrentUndoOffset(state) { 3877 return state.undo.offset; 3878 } 3879 /** 3880 * Returns the previous edit from the current undo offset 3881 * for the entity records edits history, if any. 3882 * 3883 * @param {Object} state State tree. 3884 * 3885 * @return {Object?} The edit. 3886 */ 3887 3888 3889 function getUndoEdit(state) { 3890 return state.undo[state.undo.length - 2 + getCurrentUndoOffset(state)]; 3891 } 3892 /** 3893 * Returns the next edit from the current undo offset 3894 * for the entity records edits history, if any. 3895 * 3896 * @param {Object} state State tree. 3897 * 3898 * @return {Object?} The edit. 3899 */ 3900 3901 function getRedoEdit(state) { 3902 return state.undo[state.undo.length + getCurrentUndoOffset(state)]; 3903 } 3904 /** 3905 * Returns true if there is a previous edit from the current undo offset 3906 * for the entity records edits history, and false otherwise. 3907 * 3908 * @param {Object} state State tree. 3909 * 3910 * @return {boolean} Whether there is a previous edit or not. 3911 */ 3912 3913 function hasUndo(state) { 3914 return Boolean(getUndoEdit(state)); 3915 } 3916 /** 3917 * Returns true if there is a next edit from the current undo offset 3918 * for the entity records edits history, and false otherwise. 3919 * 3920 * @param {Object} state State tree. 3921 * 3922 * @return {boolean} Whether there is a next edit or not. 3923 */ 3924 3925 function hasRedo(state) { 3926 return Boolean(getRedoEdit(state)); 3927 } 3928 /** 3929 * Return the current theme. 3930 * 3931 * @param {Object} state Data state. 3932 * 3933 * @return {Object} The current theme. 3934 */ 3935 3936 function getCurrentTheme(state) { 3937 return state.themes[state.currentTheme]; 3938 } 3939 /** 3940 * Return theme supports data in the index. 3941 * 3942 * @param {Object} state Data state. 3943 * 3944 * @return {*} Index data. 3945 */ 3946 3947 function getThemeSupports(state) { 3948 return state.themeSupports; 3949 } 3950 /** 3951 * Returns the embed preview for the given URL. 3952 * 3953 * @param {Object} state Data state. 3954 * @param {string} url Embedded URL. 3955 * 3956 * @return {*} Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API. 3957 */ 3958 3959 function getEmbedPreview(state, url) { 3960 return state.embedPreviews[url]; 3961 } 3962 /** 3963 * Determines if the returned preview is an oEmbed link fallback. 3964 * 3965 * WordPress can be configured to return a simple link to a URL if it is not embeddable. 3966 * We need to be able to determine if a URL is embeddable or not, based on what we 3967 * get back from the oEmbed preview API. 3968 * 3969 * @param {Object} state Data state. 3970 * @param {string} url Embedded URL. 3971 * 3972 * @return {boolean} Is the preview for the URL an oEmbed link fallback. 3973 */ 3974 3975 function isPreviewEmbedFallback(state, url) { 3976 var preview = state.embedPreviews[url]; 3977 var oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>'; 3978 3979 if (!preview) { 3980 return false; 3981 } 3982 3983 return preview.html === oEmbedLinkCheck; 3984 } 3985 /** 3986 * Returns whether the current user can upload media. 3987 * 3988 * Calling this may trigger an OPTIONS request to the REST API via the 3989 * `canUser()` resolver. 3990 * 3991 * https://developer.wordpress.org/rest-api/reference/ 3992 * 3993 * @deprecated since 5.0. Callers should use the more generic `canUser()` selector instead of 3994 * `hasUploadPermissions()`, e.g. `canUser( 'create', 'media' )`. 3995 * 3996 * @param {Object} state Data state. 3997 * 3998 * @return {boolean} Whether or not the user can upload media. Defaults to `true` if the OPTIONS 3999 * request is being made. 4000 */ 4001 4002 function hasUploadPermissions(state) { 4003 external_this_wp_deprecated_default()("select( 'core' ).hasUploadPermissions()", { 4004 alternative: "select( 'core' ).canUser( 'create', 'media' )" 4005 }); 4006 return Object(external_this_lodash_["defaultTo"])(canUser(state, 'create', 'media'), true); 4007 } 4008 /** 4009 * Returns whether the current user can perform the given action on the given 4010 * REST resource. 4011 * 4012 * Calling this may trigger an OPTIONS request to the REST API via the 4013 * `canUser()` resolver. 4014 * 4015 * https://developer.wordpress.org/rest-api/reference/ 4016 * 4017 * @param {Object} state Data state. 4018 * @param {string} action Action to check. One of: 'create', 'read', 'update', 'delete'. 4019 * @param {string} resource REST resource to check, e.g. 'media' or 'posts'. 4020 * @param {string=} id Optional ID of the rest resource to check. 4021 * 4022 * @return {boolean|undefined} Whether or not the user can perform the action, 4023 * or `undefined` if the OPTIONS request is still being made. 4024 */ 4025 4026 function canUser(state, action, resource, id) { 4027 var key = Object(external_this_lodash_["compact"])([action, resource, id]).join('/'); 4028 return Object(external_this_lodash_["get"])(state, ['userPermissions', key]); 4029 } 4030 /** 4031 * Returns the latest autosaves for the post. 4032 * 4033 * May return multiple autosaves since the backend stores one autosave per 4034 * author for each post. 4035 * 4036 * @param {Object} state State tree. 4037 * @param {string} postType The type of the parent post. 4038 * @param {number} postId The id of the parent post. 4039 * 4040 * @return {?Array} An array of autosaves for the post, or undefined if there is none. 4041 */ 4042 4043 function getAutosaves(state, postType, postId) { 4044 return state.autosaves[postId]; 4045 } 4046 /** 4047 * Returns the autosave for the post and author. 4048 * 4049 * @param {Object} state State tree. 4050 * @param {string} postType The type of the parent post. 4051 * @param {number} postId The id of the parent post. 4052 * @param {number} authorId The id of the author. 4053 * 4054 * @return {?Object} The autosave for the post and author. 4055 */ 4056 4057 function getAutosave(state, postType, postId, authorId) { 4058 if (authorId === undefined) { 4059 return; 4060 } 4061 4062 var autosaves = state.autosaves[postId]; 4063 return Object(external_this_lodash_["find"])(autosaves, { 4064 author: authorId 4065 }); 4066 } 4067 /** 4068 * Returns true if the REST request for autosaves has completed. 4069 * 4070 * @param {Object} state State tree. 4071 * @param {string} postType The type of the parent post. 4072 * @param {number} postId The id of the parent post. 4073 * 4074 * @return {boolean} True if the REST request was completed. False otherwise. 4075 */ 4076 4077 var hasFetchedAutosaves = Object(external_this_wp_data_["createRegistrySelector"])(function (select) { 4078 return function (state, postType, postId) { 4079 return select(REDUCER_KEY).hasFinishedResolution('getAutosaves', [postType, postId]); 4080 }; 4081 }); 4082 /** 4083 * Returns a new reference when edited values have changed. This is useful in 4084 * inferring where an edit has been made between states by comparison of the 4085 * return values using strict equality. 4086 * 4087 * @example 4088 * 4089 * ``` 4090 * const hasEditOccurred = ( 4091 * getReferenceByDistinctEdits( beforeState ) !== 4092 * getReferenceByDistinctEdits( afterState ) 4093 * ); 4094 * ``` 4095 * 4096 * @param {Object} state Editor state. 4097 * 4098 * @return {*} A value whose reference will change only when an edit occurs. 4099 */ 4100 4101 var getReferenceByDistinctEdits = Object(rememo["a" /* default */])(function () { 4102 return []; 4103 }, function (state) { 4104 return [state.undo.length, state.undo.offset, state.undo.flattenedUndo]; 4105 }); 4106 4107 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-not-resolved.js 4108 4109 4110 /** 4111 * WordPress dependencies 4112 */ 4113 4114 /** 4115 * Higher-order function which invokes the given resolver only if it has not 4116 * already been resolved with the arguments passed to the enhanced function. 4117 * 4118 * This only considers resolution state, and notably does not support resolver 4119 * custom `isFulfilled` behavior. 4120 * 4121 * @param {Function} resolver Original resolver. 4122 * @param {string} selectorName Selector name associated with resolver. 4123 * 4124 * @return {Function} Enhanced resolver. 4125 */ 4126 4127 var if_not_resolved_ifNotResolved = function ifNotResolved(resolver, selectorName) { 4128 return ( 4129 /*#__PURE__*/ 4130 4131 /** 4132 * @param {...any} args Original resolver arguments. 4133 */ 4134 external_this_regeneratorRuntime_default.a.mark(function resolveIfNotResolved() { 4135 var _len, 4136 args, 4137 _key, 4138 hasStartedResolution, 4139 _args = arguments; 4140 4141 return external_this_regeneratorRuntime_default.a.wrap(function resolveIfNotResolved$(_context) { 4142 while (1) { 4143 switch (_context.prev = _context.next) { 4144 case 0: 4145 for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 4146 args[_key] = _args[_key]; 4147 } 4148 4149 _context.next = 3; 4150 return Object(external_this_wp_dataControls_["select"])('core', 'hasStartedResolution', selectorName, args); 4151 4152 case 3: 4153 hasStartedResolution = _context.sent; 4154 4155 if (hasStartedResolution) { 4156 _context.next = 6; 4157 break; 4158 } 4159 4160 return _context.delegateYield(resolver.apply(void 0, args), "t0", 6); 4161 4162 case 6: 4163 case "end": 4164 return _context.stop(); 4165 } 4166 } 4167 }, resolveIfNotResolved); 4168 }) 4169 ); 4170 }; 4171 4172 /* harmony default export */ var if_not_resolved = (if_not_resolved_ifNotResolved); 4173 4174 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/resolvers.js 4175 4176 4177 4178 4179 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; } 4180 4181 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; } 4182 4183 var resolvers_marked = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getAuthors), 4184 resolvers_marked2 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_unstableGetAuthor), 4185 resolvers_marked3 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getCurrentUser), 4186 resolvers_marked4 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getEntityRecord), 4187 resolvers_marked5 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getEntityRecords), 4188 resolvers_marked6 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getCurrentTheme), 4189 _marked7 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getThemeSupports), 4190 _marked8 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getEmbedPreview), 4191 _marked9 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_hasUploadPermissions), 4192 _marked10 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_canUser), 4193 _marked11 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getAutosaves), 4194 _marked12 = /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(resolvers_getAutosave); 4195 4196 /** 4197 * External dependencies 4198 */ 4199 4200 /** 4201 * WordPress dependencies 4202 */ 4203 4204 4205 4206 4207 /** 4208 * Internal dependencies 4209 */ 4210 4211 4212 4213 4214 /** 4215 * Requests authors from the REST API. 4216 * 4217 * @param {Object|undefined} query Optional object of query parameters to 4218 * include with request. 4219 */ 4220 4221 function resolvers_getAuthors(query) { 4222 var path, users; 4223 return external_this_regeneratorRuntime_default.a.wrap(function getAuthors$(_context) { 4224 while (1) { 4225 switch (_context.prev = _context.next) { 4226 case 0: 4227 path = Object(external_this_wp_url_["addQueryArgs"])('/wp/v2/users/?who=authors&per_page=100', query); 4228 _context.next = 3; 4229 return Object(external_this_wp_dataControls_["apiFetch"])({ 4230 path: path 4231 }); 4232 4233 case 3: 4234 users = _context.sent; 4235 _context.next = 6; 4236 return receiveUserQuery(path, users); 4237 4238 case 6: 4239 case "end": 4240 return _context.stop(); 4241 } 4242 } 4243 }, resolvers_marked); 4244 } 4245 /** 4246 * Temporary approach to resolving editor access to author queries. 4247 * 4248 * @param {number} id The author id. 4249 */ 4250 4251 function resolvers_unstableGetAuthor(id) { 4252 var path, users; 4253 return external_this_regeneratorRuntime_default.a.wrap(function __unstableGetAuthor$(_context2) { 4254 while (1) { 4255 switch (_context2.prev = _context2.next) { 4256 case 0: 4257 path = "/wp/v2/users?who=authors&include=".concat(id); 4258 _context2.next = 3; 4259 return Object(external_this_wp_dataControls_["apiFetch"])({ 4260 path: path 4261 }); 4262 4263 case 3: 4264 users = _context2.sent; 4265 _context2.next = 6; 4266 return receiveUserQuery('author', users); 4267 4268 case 6: 4269 case "end": 4270 return _context2.stop(); 4271 } 4272 } 4273 }, resolvers_marked2); 4274 } 4275 /** 4276 * Requests the current user from the REST API. 4277 */ 4278 4279 function resolvers_getCurrentUser() { 4280 var currentUser; 4281 return external_this_regeneratorRuntime_default.a.wrap(function getCurrentUser$(_context3) { 4282 while (1) { 4283 switch (_context3.prev = _context3.next) { 4284 case 0: 4285 _context3.next = 2; 4286 return Object(external_this_wp_dataControls_["apiFetch"])({ 4287 path: '/wp/v2/users/me' 4288 }); 4289 4290 case 2: 4291 currentUser = _context3.sent; 4292 _context3.next = 5; 4293 return receiveCurrentUser(currentUser); 4294 4295 case 5: 4296 case "end": 4297 return _context3.stop(); 4298 } 4299 } 4300 }, resolvers_marked3); 4301 } 4302 /** 4303 * Requests an entity's record from the REST API. 4304 * 4305 * @param {string} kind Entity kind. 4306 * @param {string} name Entity name. 4307 * @param {number|string} key Record's key 4308 * @param {Object|undefined} query Optional object of query parameters to 4309 * include with request. 4310 */ 4311 4312 function resolvers_getEntityRecord(kind, name) { 4313 var key, 4314 query, 4315 entities, 4316 entity, 4317 path, 4318 hasRecords, 4319 record, 4320 _args4 = arguments; 4321 return external_this_regeneratorRuntime_default.a.wrap(function getEntityRecord$(_context4) { 4322 while (1) { 4323 switch (_context4.prev = _context4.next) { 4324 case 0: 4325 key = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : ''; 4326 query = _args4.length > 3 ? _args4[3] : undefined; 4327 _context4.next = 4; 4328 return getKindEntities(kind); 4329 4330 case 4: 4331 entities = _context4.sent; 4332 entity = Object(external_this_lodash_["find"])(entities, { 4333 kind: kind, 4334 name: name 4335 }); 4336 4337 if (entity) { 4338 _context4.next = 8; 4339 break; 4340 } 4341 4342 return _context4.abrupt("return"); 4343 4344 case 8: 4345 if (query !== undefined && query._fields) { 4346 // If requesting specific fields, items and query assocation to said 4347 // records are stored by ID reference. Thus, fields must always include 4348 // the ID. 4349 query = resolvers_objectSpread(resolvers_objectSpread({}, query), {}, { 4350 _fields: Object(external_this_lodash_["uniq"])([].concat(Object(toConsumableArray["a" /* default */])(get_normalized_comma_separable(query._fields) || []), [entity.key || DEFAULT_ENTITY_KEY])).join() 4351 }); 4352 } // Disable reason: While true that an early return could leave `path` 4353 // unused, it's important that path is derived using the query prior to 4354 // additional query modifications in the condition below, since those 4355 // modifications are relevant to how the data is tracked in state, and not 4356 // for how the request is made to the REST API. 4357 // eslint-disable-next-line @wordpress/no-unused-vars-before-return 4358 4359 4360 path = Object(external_this_wp_url_["addQueryArgs"])(entity.baseURL + '/' + key, resolvers_objectSpread(resolvers_objectSpread({}, query), {}, { 4361 context: 'edit' 4362 })); 4363 4364 if (!(query !== undefined)) { 4365 _context4.next = 17; 4366 break; 4367 } 4368 4369 query = resolvers_objectSpread(resolvers_objectSpread({}, query), {}, { 4370 include: [key] 4371 }); // The resolution cache won't consider query as reusable based on the 4372 // fields, so it's tested here, prior to initiating the REST request, 4373 // and without causing `getEntityRecords` resolution to occur. 4374 4375 _context4.next = 14; 4376 return Object(external_this_wp_dataControls_["syncSelect"])('core', 'hasEntityRecords', kind, name, query); 4377 4378 case 14: 4379 hasRecords = _context4.sent; 4380 4381 if (!hasRecords) { 4382 _context4.next = 17; 4383 break; 4384 } 4385 4386 return _context4.abrupt("return"); 4387 4388 case 17: 4389 _context4.next = 19; 4390 return Object(external_this_wp_dataControls_["apiFetch"])({ 4391 path: path 4392 }); 4393 4394 case 19: 4395 record = _context4.sent; 4396 _context4.next = 22; 4397 return receiveEntityRecords(kind, name, record, query); 4398 4399 case 22: 4400 case "end": 4401 return _context4.stop(); 4402 } 4403 } 4404 }, resolvers_marked4); 4405 } 4406 /** 4407 * Requests an entity's record from the REST API. 4408 */ 4409 4410 var resolvers_getRawEntityRecord = if_not_resolved(resolvers_getEntityRecord, 'getEntityRecord'); 4411 /** 4412 * Requests an entity's record from the REST API. 4413 */ 4414 4415 var resolvers_getEditedEntityRecord = if_not_resolved(resolvers_getRawEntityRecord, 'getRawEntityRecord'); 4416 /** 4417 * Requests the entity's records from the REST API. 4418 * 4419 * @param {string} kind Entity kind. 4420 * @param {string} name Entity name. 4421 * @param {Object?} query Query Object. 4422 */ 4423 4424 function resolvers_getEntityRecords(kind, name) { 4425 var query, 4426 entities, 4427 entity, 4428 path, 4429 records, 4430 _args5 = arguments; 4431 return external_this_regeneratorRuntime_default.a.wrap(function getEntityRecords$(_context5) { 4432 while (1) { 4433 switch (_context5.prev = _context5.next) { 4434 case 0: 4435 query = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {}; 4436 _context5.next = 3; 4437 return getKindEntities(kind); 4438 4439 case 3: 4440 entities = _context5.sent; 4441 entity = Object(external_this_lodash_["find"])(entities, { 4442 kind: kind, 4443 name: name 4444 }); 4445 4446 if (entity) { 4447 _context5.next = 7; 4448 break; 4449 } 4450 4451 return _context5.abrupt("return"); 4452 4453 case 7: 4454 if (query._fields) { 4455 // If requesting specific fields, items and query assocation to said 4456 // records are stored by ID reference. Thus, fields must always include 4457 // the ID. 4458 query = resolvers_objectSpread(resolvers_objectSpread({}, query), {}, { 4459 _fields: Object(external_this_lodash_["uniq"])([].concat(Object(toConsumableArray["a" /* default */])(get_normalized_comma_separable(query._fields) || []), [entity.key || DEFAULT_ENTITY_KEY])).join() 4460 }); 4461 } 4462 4463 path = Object(external_this_wp_url_["addQueryArgs"])(entity.baseURL, resolvers_objectSpread(resolvers_objectSpread({}, query), {}, { 4464 context: 'edit' 4465 })); 4466 _context5.t0 = Object; 4467 _context5.next = 12; 4468 return Object(external_this_wp_dataControls_["apiFetch"])({ 4469 path: path 4470 }); 4471 4472 case 12: 4473 _context5.t1 = _context5.sent; 4474 records = _context5.t0.values.call(_context5.t0, _context5.t1); 4475 4476 // If we request fields but the result doesn't contain the fields, 4477 // explicitely set these fields as "undefined" 4478 // that way we consider the query "fullfilled". 4479 if (query._fields) { 4480 records = records.map(function (record) { 4481 query._fields.split(',').forEach(function (field) { 4482 if (!record.hasOwnProperty(field)) { 4483 record[field] = undefined; 4484 } 4485 }); 4486 4487 return record; 4488 }); 4489 } 4490 4491 _context5.next = 17; 4492 return receiveEntityRecords(kind, name, records, query); 4493 4494 case 17: 4495 case "end": 4496 return _context5.stop(); 4497 } 4498 } 4499 }, resolvers_marked5); 4500 } 4501 4502 resolvers_getEntityRecords.shouldInvalidate = function (action, kind, name) { 4503 return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && kind === action.kind && name === action.name; 4504 }; 4505 /** 4506 * Requests the current theme. 4507 */ 4508 4509 4510 function resolvers_getCurrentTheme() { 4511 var activeThemes; 4512 return external_this_regeneratorRuntime_default.a.wrap(function getCurrentTheme$(_context6) { 4513 while (1) { 4514 switch (_context6.prev = _context6.next) { 4515 case 0: 4516 _context6.next = 2; 4517 return Object(external_this_wp_dataControls_["apiFetch"])({ 4518 path: '/wp/v2/themes?status=active' 4519 }); 4520 4521 case 2: 4522 activeThemes = _context6.sent; 4523 _context6.next = 5; 4524 return receiveCurrentTheme(activeThemes[0]); 4525 4526 case 5: 4527 case "end": 4528 return _context6.stop(); 4529 } 4530 } 4531 }, resolvers_marked6); 4532 } 4533 /** 4534 * Requests theme supports data from the index. 4535 */ 4536 4537 function resolvers_getThemeSupports() { 4538 var activeThemes; 4539 return external_this_regeneratorRuntime_default.a.wrap(function getThemeSupports$(_context7) { 4540 while (1) { 4541 switch (_context7.prev = _context7.next) { 4542 case 0: 4543 _context7.next = 2; 4544 return Object(external_this_wp_dataControls_["apiFetch"])({ 4545 path: '/wp/v2/themes?status=active' 4546 }); 4547 4548 case 2: 4549 activeThemes = _context7.sent; 4550 _context7.next = 5; 4551 return receiveThemeSupports(activeThemes[0].theme_supports); 4552 4553 case 5: 4554 case "end": 4555 return _context7.stop(); 4556 } 4557 } 4558 }, _marked7); 4559 } 4560 /** 4561 * Requests a preview from the from the Embed API. 4562 * 4563 * @param {string} url URL to get the preview for. 4564 */ 4565 4566 function resolvers_getEmbedPreview(url) { 4567 var embedProxyResponse; 4568 return external_this_regeneratorRuntime_default.a.wrap(function getEmbedPreview$(_context8) { 4569 while (1) { 4570 switch (_context8.prev = _context8.next) { 4571 case 0: 4572 _context8.prev = 0; 4573 _context8.next = 3; 4574 return Object(external_this_wp_dataControls_["apiFetch"])({ 4575 path: Object(external_this_wp_url_["addQueryArgs"])('/oembed/1.0/proxy', { 4576 url: url 4577 }) 4578 }); 4579 4580 case 3: 4581 embedProxyResponse = _context8.sent; 4582 _context8.next = 6; 4583 return receiveEmbedPreview(url, embedProxyResponse); 4584 4585 case 6: 4586 _context8.next = 12; 4587 break; 4588 4589 case 8: 4590 _context8.prev = 8; 4591 _context8.t0 = _context8["catch"](0); 4592 _context8.next = 12; 4593 return receiveEmbedPreview(url, false); 4594 4595 case 12: 4596 case "end": 4597 return _context8.stop(); 4598 } 4599 } 4600 }, _marked8, null, [[0, 8]]); 4601 } 4602 /** 4603 * Requests Upload Permissions from the REST API. 4604 * 4605 * @deprecated since 5.0. Callers should use the more generic `canUser()` selector instead of 4606 * `hasUploadPermissions()`, e.g. `canUser( 'create', 'media' )`. 4607 */ 4608 4609 function resolvers_hasUploadPermissions() { 4610 return external_this_regeneratorRuntime_default.a.wrap(function hasUploadPermissions$(_context9) { 4611 while (1) { 4612 switch (_context9.prev = _context9.next) { 4613 case 0: 4614 external_this_wp_deprecated_default()("select( 'core' ).hasUploadPermissions()", { 4615 alternative: "select( 'core' ).canUser( 'create', 'media' )" 4616 }); 4617 return _context9.delegateYield(resolvers_canUser('create', 'media'), "t0", 2); 4618 4619 case 2: 4620 case "end": 4621 return _context9.stop(); 4622 } 4623 } 4624 }, _marked9); 4625 } 4626 /** 4627 * Checks whether the current user can perform the given action on the given 4628 * REST resource. 4629 * 4630 * @param {string} action Action to check. One of: 'create', 'read', 'update', 4631 * 'delete'. 4632 * @param {string} resource REST resource to check, e.g. 'media' or 'posts'. 4633 * @param {?string} id ID of the rest resource to check. 4634 */ 4635 4636 function resolvers_canUser(action, resource, id) { 4637 var methods, method, path, response, allowHeader, key, isAllowed; 4638 return external_this_regeneratorRuntime_default.a.wrap(function canUser$(_context10) { 4639 while (1) { 4640 switch (_context10.prev = _context10.next) { 4641 case 0: 4642 methods = { 4643 create: 'POST', 4644 read: 'GET', 4645 update: 'PUT', 4646 delete: 'DELETE' 4647 }; 4648 method = methods[action]; 4649 4650 if (method) { 4651 _context10.next = 4; 4652 break; 4653 } 4654 4655 throw new Error("'".concat(action, "' is not a valid action.")); 4656 4657 case 4: 4658 path = id ? "/wp/v2/".concat(resource, "/").concat(id) : "/wp/v2/".concat(resource); 4659 _context10.prev = 5; 4660 _context10.next = 8; 4661 return Object(external_this_wp_dataControls_["apiFetch"])({ 4662 path: path, 4663 // Ideally this would always be an OPTIONS request, but unfortunately there's 4664 // a bug in the REST API which causes the Allow header to not be sent on 4665 // OPTIONS requests to /posts/:id routes. 4666 // https://core.trac.wordpress.org/ticket/45753 4667 method: id ? 'GET' : 'OPTIONS', 4668 parse: false 4669 }); 4670 4671 case 8: 4672 response = _context10.sent; 4673 _context10.next = 14; 4674 break; 4675 4676 case 11: 4677 _context10.prev = 11; 4678 _context10.t0 = _context10["catch"](5); 4679 return _context10.abrupt("return"); 4680 4681 case 14: 4682 if (Object(external_this_lodash_["hasIn"])(response, ['headers', 'get'])) { 4683 // If the request is fetched using the fetch api, the header can be 4684 // retrieved using the 'get' method. 4685 allowHeader = response.headers.get('allow'); 4686 } else { 4687 // If the request was preloaded server-side and is returned by the 4688 // preloading middleware, the header will be a simple property. 4689 allowHeader = Object(external_this_lodash_["get"])(response, ['headers', 'Allow'], ''); 4690 } 4691 4692 key = Object(external_this_lodash_["compact"])([action, resource, id]).join('/'); 4693 isAllowed = Object(external_this_lodash_["includes"])(allowHeader, method); 4694 _context10.next = 19; 4695 return receiveUserPermission(key, isAllowed); 4696 4697 case 19: 4698 case "end": 4699 return _context10.stop(); 4700 } 4701 } 4702 }, _marked10, null, [[5, 11]]); 4703 } 4704 /** 4705 * Request autosave data from the REST API. 4706 * 4707 * @param {string} postType The type of the parent post. 4708 * @param {number} postId The id of the parent post. 4709 */ 4710 4711 function resolvers_getAutosaves(postType, postId) { 4712 var _yield$select, restBase, autosaves; 4713 4714 return external_this_regeneratorRuntime_default.a.wrap(function getAutosaves$(_context11) { 4715 while (1) { 4716 switch (_context11.prev = _context11.next) { 4717 case 0: 4718 _context11.next = 2; 4719 return Object(external_this_wp_dataControls_["select"])('core', 'getPostType', postType); 4720 4721 case 2: 4722 _yield$select = _context11.sent; 4723 restBase = _yield$select.rest_base; 4724 _context11.next = 6; 4725 return Object(external_this_wp_dataControls_["apiFetch"])({ 4726 path: "/wp/v2/".concat(restBase, "/").concat(postId, "/autosaves?context=edit") 4727 }); 4728 4729 case 6: 4730 autosaves = _context11.sent; 4731 4732 if (!(autosaves && autosaves.length)) { 4733 _context11.next = 10; 4734 break; 4735 } 4736 4737 _context11.next = 10; 4738 return receiveAutosaves(postId, autosaves); 4739 4740 case 10: 4741 case "end": 4742 return _context11.stop(); 4743 } 4744 } 4745 }, _marked11); 4746 } 4747 /** 4748 * Request autosave data from the REST API. 4749 * 4750 * This resolver exists to ensure the underlying autosaves are fetched via 4751 * `getAutosaves` when a call to the `getAutosave` selector is made. 4752 * 4753 * @param {string} postType The type of the parent post. 4754 * @param {number} postId The id of the parent post. 4755 */ 4756 4757 function resolvers_getAutosave(postType, postId) { 4758 return external_this_regeneratorRuntime_default.a.wrap(function getAutosave$(_context12) { 4759 while (1) { 4760 switch (_context12.prev = _context12.next) { 4761 case 0: 4762 _context12.next = 2; 4763 return Object(external_this_wp_dataControls_["select"])('core', 'getAutosaves', postType, postId); 4764 4765 case 2: 4766 case "end": 4767 return _context12.stop(); 4768 } 4769 } 4770 }, _marked12); 4771 } 4772 4773 // EXTERNAL MODULE: external {"this":["wp","element"]} 4774 var external_this_wp_element_ = __webpack_require__(0); 4775 4776 // EXTERNAL MODULE: external {"this":["wp","blocks"]} 4777 var external_this_wp_blocks_ = __webpack_require__(11); 4778 4779 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entity-provider.js 4780 4781 4782 4783 4784 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; } 4785 4786 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; } 4787 4788 /** 4789 * WordPress dependencies 4790 */ 4791 4792 4793 4794 /** 4795 * Internal dependencies 4796 */ 4797 4798 4799 4800 var entity_provider_entities = entity_provider_objectSpread(entity_provider_objectSpread({}, defaultEntities.reduce(function (acc, entity) { 4801 if (!acc[entity.kind]) { 4802 acc[entity.kind] = {}; 4803 } 4804 4805 acc[entity.kind][entity.name] = { 4806 context: Object(external_this_wp_element_["createContext"])() 4807 }; 4808 return acc; 4809 }, {})), kinds.reduce(function (acc, kind) { 4810 acc[kind.name] = {}; 4811 return acc; 4812 }, {})); 4813 4814 var entity_provider_getEntity = function getEntity(kind, type) { 4815 if (!entity_provider_entities[kind]) { 4816 throw new Error("Missing entity config for kind: ".concat(kind, ".")); 4817 } 4818 4819 if (!entity_provider_entities[kind][type]) { 4820 entity_provider_entities[kind][type] = { 4821 context: Object(external_this_wp_element_["createContext"])() 4822 }; 4823 } 4824 4825 return entity_provider_entities[kind][type]; 4826 }; 4827 /** 4828 * Context provider component for providing 4829 * an entity for a specific entity type. 4830 * 4831 * @param {Object} props The component's props. 4832 * @param {string} props.kind The entity kind. 4833 * @param {string} props.type The entity type. 4834 * @param {number} props.id The entity ID. 4835 * @param {*} props.children The children to wrap. 4836 * 4837 * @return {Object} The provided children, wrapped with 4838 * the entity's context provider. 4839 */ 4840 4841 4842 function EntityProvider(_ref) { 4843 var kind = _ref.kind, 4844 type = _ref.type, 4845 id = _ref.id, 4846 children = _ref.children; 4847 var Provider = entity_provider_getEntity(kind, type).context.Provider; 4848 return Object(external_this_wp_element_["createElement"])(Provider, { 4849 value: id 4850 }, children); 4851 } 4852 /** 4853 * Hook that returns the ID for the nearest 4854 * provided entity of the specified type. 4855 * 4856 * @param {string} kind The entity kind. 4857 * @param {string} type The entity type. 4858 */ 4859 4860 function useEntityId(kind, type) { 4861 return Object(external_this_wp_element_["useContext"])(entity_provider_getEntity(kind, type).context); 4862 } 4863 /** 4864 * Hook that returns the value and a setter for the 4865 * specified property of the nearest provided 4866 * entity of the specified type. 4867 * 4868 * @param {string} kind The entity kind. 4869 * @param {string} type The entity type. 4870 * @param {string} prop The property name. 4871 * @param {string} [_id] An entity ID to use instead of the context-provided one. 4872 * 4873 * @return {[*, Function]} A tuple where the first item is the 4874 * property value and the second is the 4875 * setter. 4876 */ 4877 4878 function useEntityProp(kind, type, prop, _id) { 4879 var providerId = useEntityId(kind, type); 4880 var id = _id !== null && _id !== void 0 ? _id : providerId; 4881 4882 var _useSelect = Object(external_this_wp_data_["useSelect"])(function (select) { 4883 var _select = select('core'), 4884 getEntityRecord = _select.getEntityRecord, 4885 getEditedEntityRecord = _select.getEditedEntityRecord; 4886 4887 var entity = getEntityRecord(kind, type, id); // Trigger resolver. 4888 4889 var editedEntity = getEditedEntityRecord(kind, type, id); 4890 return entity && editedEntity ? { 4891 value: editedEntity[prop], 4892 fullValue: entity[prop] 4893 } : {}; 4894 }, [kind, type, id, prop]), 4895 value = _useSelect.value, 4896 fullValue = _useSelect.fullValue; 4897 4898 var _useDispatch = Object(external_this_wp_data_["useDispatch"])('core'), 4899 editEntityRecord = _useDispatch.editEntityRecord; 4900 4901 var setValue = Object(external_this_wp_element_["useCallback"])(function (newValue) { 4902 editEntityRecord(kind, type, id, Object(defineProperty["a" /* default */])({}, prop, newValue)); 4903 }, [kind, type, id, prop]); 4904 return [value, setValue, fullValue]; 4905 } 4906 /** 4907 * Hook that returns block content getters and setters for 4908 * the nearest provided entity of the specified type. 4909 * 4910 * The return value has the shape `[ blocks, onInput, onChange ]`. 4911 * `onInput` is for block changes that don't create undo levels 4912 * or dirty the post, non-persistent changes, and `onChange` is for 4913 * peristent changes. They map directly to the props of a 4914 * `BlockEditorProvider` and are intended to be used with it, 4915 * or similar components or hooks. 4916 * 4917 * @param {string} kind The entity kind. 4918 * @param {string} type The entity type. 4919 * @param {Object} options 4920 * @param {Object} [options.initialEdits] Initial edits object for the entity record. 4921 * @param {string} [options.blocksProp='blocks'] The name of the entity prop that holds the blocks array. 4922 * @param {string} [options.contentProp='content'] The name of the entity prop that holds the serialized blocks. 4923 * @param {string} [options.id] An entity ID to use instead of the context-provided one. 4924 * 4925 * @return {[WPBlock[], Function, Function]} The block array and setters. 4926 */ 4927 4928 function useEntityBlockEditor(kind, type) { 4929 var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, 4930 initialEdits = _ref2.initialEdits, 4931 _ref2$blocksProp = _ref2.blocksProp, 4932 blocksProp = _ref2$blocksProp === void 0 ? 'blocks' : _ref2$blocksProp, 4933 _ref2$contentProp = _ref2.contentProp, 4934 contentProp = _ref2$contentProp === void 0 ? 'content' : _ref2$contentProp, 4935 _id = _ref2.id; 4936 4937 var providerId = useEntityId(kind, type); 4938 var id = _id !== null && _id !== void 0 ? _id : providerId; 4939 4940 var _useEntityProp = useEntityProp(kind, type, contentProp, id), 4941 _useEntityProp2 = Object(slicedToArray["a" /* default */])(_useEntityProp, 2), 4942 content = _useEntityProp2[0], 4943 setContent = _useEntityProp2[1]; 4944 4945 var _useDispatch2 = Object(external_this_wp_data_["useDispatch"])('core'), 4946 editEntityRecord = _useDispatch2.editEntityRecord; 4947 4948 Object(external_this_wp_element_["useEffect"])(function () { 4949 if (initialEdits) { 4950 editEntityRecord(kind, type, id, initialEdits, { 4951 undoIgnore: true 4952 }); 4953 } 4954 }, [id]); 4955 var initialBlocks = Object(external_this_wp_element_["useMemo"])(function () { 4956 // Guard against other instances that might have 4957 // set content to a function already. 4958 if (content && typeof content !== 'function') { 4959 var parsedContent = Object(external_this_wp_blocks_["parse"])(content); 4960 return parsedContent.length ? parsedContent : []; 4961 } 4962 4963 return []; 4964 }, [content]); 4965 4966 var _useEntityProp3 = useEntityProp(kind, type, blocksProp, id), 4967 _useEntityProp4 = Object(slicedToArray["a" /* default */])(_useEntityProp3, 2), 4968 _useEntityProp4$ = _useEntityProp4[0], 4969 blocks = _useEntityProp4$ === void 0 ? initialBlocks : _useEntityProp4$, 4970 onInput = _useEntityProp4[1]; 4971 4972 var onChange = Object(external_this_wp_element_["useCallback"])(function (nextBlocks) { 4973 onInput(nextBlocks); // Use a function edit to avoid serializing often. 4974 4975 setContent(function (_ref3) { 4976 var blocksToSerialize = _ref3.blocks; 4977 return Object(external_this_wp_blocks_["serialize"])(blocksToSerialize); 4978 }); 4979 }, [onInput, setContent]); 4980 return [blocks, onInput, onChange]; 4981 } 4982 4983 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js 4984 4985 4986 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; } 4987 4988 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; } 4989 4990 /** 4991 * WordPress dependencies 4992 */ 4993 4994 4995 /** 4996 * Internal dependencies 4997 */ 4998 4999 5000 5001 5002 5003 5004 // The entity selectors/resolvers and actions are shortcuts to their generic equivalents 5005 // (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecordss) 5006 // Instead of getEntityRecord, the consumer could use more user-frieldly named selector: getPostType, getTaxonomy... 5007 // The "kind" and the "name" of the entity are combined to generate these shortcuts. 5008 5009 var entitySelectors = defaultEntities.reduce(function (result, entity) { 5010 var kind = entity.kind, 5011 name = entity.name; 5012 5013 result[entities_getMethodName(kind, name)] = function (state, key) { 5014 return getEntityRecord(state, kind, name, key); 5015 }; 5016 5017 result[entities_getMethodName(kind, name, 'get', true)] = function (state) { 5018 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 5019 args[_key - 1] = arguments[_key]; 5020 } 5021 5022 return getEntityRecords.apply(build_module_selectors_namespaceObject, [state, kind, name].concat(args)); 5023 }; 5024 5025 return result; 5026 }, {}); 5027 var entityResolvers = defaultEntities.reduce(function (result, entity) { 5028 var kind = entity.kind, 5029 name = entity.name; 5030 5031 result[entities_getMethodName(kind, name)] = function (key) { 5032 return resolvers_getEntityRecord(kind, name, key); 5033 }; 5034 5035 var pluralMethodName = entities_getMethodName(kind, name, 'get', true); 5036 5037 result[pluralMethodName] = function () { 5038 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 5039 args[_key2] = arguments[_key2]; 5040 } 5041 5042 return resolvers_getEntityRecords.apply(resolvers_namespaceObject, [kind, name].concat(args)); 5043 }; 5044 5045 result[pluralMethodName].shouldInvalidate = function (action) { 5046 var _resolvers$getEntityR; 5047 5048 for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { 5049 args[_key3 - 1] = arguments[_key3]; 5050 } 5051 5052 return (_resolvers$getEntityR = resolvers_getEntityRecords).shouldInvalidate.apply(_resolvers$getEntityR, [action, kind, name].concat(args)); 5053 }; 5054 5055 return result; 5056 }, {}); 5057 var entityActions = defaultEntities.reduce(function (result, entity) { 5058 var kind = entity.kind, 5059 name = entity.name; 5060 5061 result[entities_getMethodName(kind, name, 'save')] = function (key) { 5062 return saveEntityRecord(kind, name, key); 5063 }; 5064 5065 result[entities_getMethodName(kind, name, 'delete')] = function (key, query) { 5066 return deleteEntityRecord(kind, name, key, query); 5067 }; 5068 5069 return result; 5070 }, {}); 5071 Object(external_this_wp_data_["registerStore"])(REDUCER_KEY, { 5072 reducer: build_module_reducer, 5073 controls: external_this_wp_dataControls_["controls"], 5074 actions: build_module_objectSpread(build_module_objectSpread({}, build_module_actions_namespaceObject), entityActions), 5075 selectors: build_module_objectSpread(build_module_objectSpread({}, build_module_selectors_namespaceObject), entitySelectors), 5076 resolvers: build_module_objectSpread(build_module_objectSpread({}, resolvers_namespaceObject), entityResolvers) 5077 }); 5078 5079 5080 5081 5082 /***/ }), 5083 5084 /***/ 5: 5085 /***/ (function(module, __webpack_exports__, __webpack_require__) { 5086 5087 "use strict"; 5088 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); 5089 function _defineProperty(obj, key, value) { 5090 if (key in obj) { 5091 Object.defineProperty(obj, key, { 5092 value: value, 5093 enumerable: true, 5094 configurable: true, 5095 writable: true 5096 }); 5097 } else { 5098 obj[key] = value; 5099 } 5100 5101 return obj; 5102 } 5103 5104 /***/ }), 5105 5106 /***/ 64: 5107 /***/ (function(module, exports) { 5108 5109 (function() { module.exports = this["wp"]["isShallowEqual"]; }()); 5110 5111 /***/ }) 5112 5113 /******/ });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 21 01:00:10 2021 | Cross-referenced by PHPXref 0.7.1 |