[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ var __webpack_modules__ = ({ 4 5 /***/ 66: 6 /***/ ((module) => { 7 8 9 10 var isMergeableObject = function isMergeableObject(value) { 11 return isNonNullObject(value) 12 && !isSpecial(value) 13 }; 14 15 function isNonNullObject(value) { 16 return !!value && typeof value === 'object' 17 } 18 19 function isSpecial(value) { 20 var stringValue = Object.prototype.toString.call(value); 21 22 return stringValue === '[object RegExp]' 23 || stringValue === '[object Date]' 24 || isReactElement(value) 25 } 26 27 // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 28 var canUseSymbol = typeof Symbol === 'function' && Symbol.for; 29 var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; 30 31 function isReactElement(value) { 32 return value.$$typeof === REACT_ELEMENT_TYPE 33 } 34 35 function emptyTarget(val) { 36 return Array.isArray(val) ? [] : {} 37 } 38 39 function cloneUnlessOtherwiseSpecified(value, options) { 40 return (options.clone !== false && options.isMergeableObject(value)) 41 ? deepmerge(emptyTarget(value), value, options) 42 : value 43 } 44 45 function defaultArrayMerge(target, source, options) { 46 return target.concat(source).map(function(element) { 47 return cloneUnlessOtherwiseSpecified(element, options) 48 }) 49 } 50 51 function getMergeFunction(key, options) { 52 if (!options.customMerge) { 53 return deepmerge 54 } 55 var customMerge = options.customMerge(key); 56 return typeof customMerge === 'function' ? customMerge : deepmerge 57 } 58 59 function getEnumerableOwnPropertySymbols(target) { 60 return Object.getOwnPropertySymbols 61 ? Object.getOwnPropertySymbols(target).filter(function(symbol) { 62 return Object.propertyIsEnumerable.call(target, symbol) 63 }) 64 : [] 65 } 66 67 function getKeys(target) { 68 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) 69 } 70 71 function propertyIsOnObject(object, property) { 72 try { 73 return property in object 74 } catch(_) { 75 return false 76 } 77 } 78 79 // Protects from prototype poisoning and unexpected merging up the prototype chain. 80 function propertyIsUnsafe(target, key) { 81 return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, 82 && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, 83 && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. 84 } 85 86 function mergeObject(target, source, options) { 87 var destination = {}; 88 if (options.isMergeableObject(target)) { 89 getKeys(target).forEach(function(key) { 90 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 91 }); 92 } 93 getKeys(source).forEach(function(key) { 94 if (propertyIsUnsafe(target, key)) { 95 return 96 } 97 98 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 99 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 100 } else { 101 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 102 } 103 }); 104 return destination 105 } 106 107 function deepmerge(target, source, options) { 108 options = options || {}; 109 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 110 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 111 // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() 112 // implementations can use it. The caller may not replace it. 113 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 114 115 var sourceIsArray = Array.isArray(source); 116 var targetIsArray = Array.isArray(target); 117 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 118 119 if (!sourceAndTargetTypesMatch) { 120 return cloneUnlessOtherwiseSpecified(source, options) 121 } else if (sourceIsArray) { 122 return options.arrayMerge(target, source, options) 123 } else { 124 return mergeObject(target, source, options) 125 } 126 } 127 128 deepmerge.all = function deepmergeAll(array, options) { 129 if (!Array.isArray(array)) { 130 throw new Error('first argument should be an array') 131 } 132 133 return array.reduce(function(prev, next) { 134 return deepmerge(prev, next, options) 135 }, {}) 136 }; 137 138 var deepmerge_1 = deepmerge; 139 140 module.exports = deepmerge_1; 141 142 143 /***/ }), 144 145 /***/ 3249: 146 /***/ ((module) => { 147 148 149 150 function _typeof(obj) { 151 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 152 _typeof = function (obj) { 153 return typeof obj; 154 }; 155 } else { 156 _typeof = function (obj) { 157 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 158 }; 159 } 160 161 return _typeof(obj); 162 } 163 164 function _classCallCheck(instance, Constructor) { 165 if (!(instance instanceof Constructor)) { 166 throw new TypeError("Cannot call a class as a function"); 167 } 168 } 169 170 function _defineProperties(target, props) { 171 for (var i = 0; i < props.length; i++) { 172 var descriptor = props[i]; 173 descriptor.enumerable = descriptor.enumerable || false; 174 descriptor.configurable = true; 175 if ("value" in descriptor) descriptor.writable = true; 176 Object.defineProperty(target, descriptor.key, descriptor); 177 } 178 } 179 180 function _createClass(Constructor, protoProps, staticProps) { 181 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 182 if (staticProps) _defineProperties(Constructor, staticProps); 183 return Constructor; 184 } 185 186 /** 187 * Given an instance of EquivalentKeyMap, returns its internal value pair tuple 188 * for a key, if one exists. The tuple members consist of the last reference 189 * value for the key (used in efficient subsequent lookups) and the value 190 * assigned for the key at the leaf node. 191 * 192 * @param {EquivalentKeyMap} instance EquivalentKeyMap instance. 193 * @param {*} key The key for which to return value pair. 194 * 195 * @return {?Array} Value pair, if exists. 196 */ 197 function getValuePair(instance, key) { 198 var _map = instance._map, 199 _arrayTreeMap = instance._arrayTreeMap, 200 _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the 201 // value, which can be used to shortcut immediately to the value. 202 203 if (_map.has(key)) { 204 return _map.get(key); 205 } // Sort keys to ensure stable retrieval from tree. 206 207 208 var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value. 209 210 var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap; 211 212 for (var i = 0; i < properties.length; i++) { 213 var property = properties[i]; 214 map = map.get(property); 215 216 if (map === undefined) { 217 return; 218 } 219 220 var propertyValue = key[property]; 221 map = map.get(propertyValue); 222 223 if (map === undefined) { 224 return; 225 } 226 } 227 228 var valuePair = map.get('_ekm_value'); 229 230 if (!valuePair) { 231 return; 232 } // If reached, it implies that an object-like key was set with another 233 // reference, so delete the reference and replace with the current. 234 235 236 _map.delete(valuePair[0]); 237 238 valuePair[0] = key; 239 map.set('_ekm_value', valuePair); 240 241 _map.set(key, valuePair); 242 243 return valuePair; 244 } 245 /** 246 * Variant of a Map object which enables lookup by equivalent (deeply equal) 247 * object and array keys. 248 */ 249 250 251 var EquivalentKeyMap = 252 /*#__PURE__*/ 253 function () { 254 /** 255 * Constructs a new instance of EquivalentKeyMap. 256 * 257 * @param {Iterable.<*>} iterable Initial pair of key, value for map. 258 */ 259 function EquivalentKeyMap(iterable) { 260 _classCallCheck(this, EquivalentKeyMap); 261 262 this.clear(); 263 264 if (iterable instanceof EquivalentKeyMap) { 265 // Map#forEach is only means of iterating with support for IE11. 266 var iterablePairs = []; 267 iterable.forEach(function (value, key) { 268 iterablePairs.push([key, value]); 269 }); 270 iterable = iterablePairs; 271 } 272 273 if (iterable != null) { 274 for (var i = 0; i < iterable.length; i++) { 275 this.set(iterable[i][0], iterable[i][1]); 276 } 277 } 278 } 279 /** 280 * Accessor property returning the number of elements. 281 * 282 * @return {number} Number of elements. 283 */ 284 285 286 _createClass(EquivalentKeyMap, [{ 287 key: "set", 288 289 /** 290 * Add or update an element with a specified key and value. 291 * 292 * @param {*} key The key of the element to add. 293 * @param {*} value The value of the element to add. 294 * 295 * @return {EquivalentKeyMap} Map instance. 296 */ 297 value: function set(key, value) { 298 // Shortcut non-object-like to set on internal Map. 299 if (key === null || _typeof(key) !== 'object') { 300 this._map.set(key, value); 301 302 return this; 303 } // Sort keys to ensure stable assignment into tree. 304 305 306 var properties = Object.keys(key).sort(); 307 var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value. 308 309 var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap; 310 311 for (var i = 0; i < properties.length; i++) { 312 var property = properties[i]; 313 314 if (!map.has(property)) { 315 map.set(property, new EquivalentKeyMap()); 316 } 317 318 map = map.get(property); 319 var propertyValue = key[property]; 320 321 if (!map.has(propertyValue)) { 322 map.set(propertyValue, new EquivalentKeyMap()); 323 } 324 325 map = map.get(propertyValue); 326 } // If an _ekm_value exists, there was already an equivalent key. Before 327 // overriding, ensure that the old key reference is removed from map to 328 // avoid memory leak of accumulating equivalent keys. This is, in a 329 // sense, a poor man's WeakMap, while still enabling iterability. 330 331 332 var previousValuePair = map.get('_ekm_value'); 333 334 if (previousValuePair) { 335 this._map.delete(previousValuePair[0]); 336 } 337 338 map.set('_ekm_value', valuePair); 339 340 this._map.set(key, valuePair); 341 342 return this; 343 } 344 /** 345 * Returns a specified element. 346 * 347 * @param {*} key The key of the element to return. 348 * 349 * @return {?*} The element associated with the specified key or undefined 350 * if the key can't be found. 351 */ 352 353 }, { 354 key: "get", 355 value: function get(key) { 356 // Shortcut non-object-like to get from internal Map. 357 if (key === null || _typeof(key) !== 'object') { 358 return this._map.get(key); 359 } 360 361 var valuePair = getValuePair(this, key); 362 363 if (valuePair) { 364 return valuePair[1]; 365 } 366 } 367 /** 368 * Returns a boolean indicating whether an element with the specified key 369 * exists or not. 370 * 371 * @param {*} key The key of the element to test for presence. 372 * 373 * @return {boolean} Whether an element with the specified key exists. 374 */ 375 376 }, { 377 key: "has", 378 value: function has(key) { 379 if (key === null || _typeof(key) !== 'object') { 380 return this._map.has(key); 381 } // Test on the _presence_ of the pair, not its value, as even undefined 382 // can be a valid member value for a key. 383 384 385 return getValuePair(this, key) !== undefined; 386 } 387 /** 388 * Removes the specified element. 389 * 390 * @param {*} key The key of the element to remove. 391 * 392 * @return {boolean} Returns true if an element existed and has been 393 * removed, or false if the element does not exist. 394 */ 395 396 }, { 397 key: "delete", 398 value: function _delete(key) { 399 if (!this.has(key)) { 400 return false; 401 } // This naive implementation will leave orphaned child trees. A better 402 // implementation should traverse and remove orphans. 403 404 405 this.set(key, undefined); 406 return true; 407 } 408 /** 409 * Executes a provided function once per each key/value pair, in insertion 410 * order. 411 * 412 * @param {Function} callback Function to execute for each element. 413 * @param {*} thisArg Value to use as `this` when executing 414 * `callback`. 415 */ 416 417 }, { 418 key: "forEach", 419 value: function forEach(callback) { 420 var _this = this; 421 422 var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; 423 424 this._map.forEach(function (value, key) { 425 // Unwrap value from object-like value pair. 426 if (key !== null && _typeof(key) === 'object') { 427 value = value[1]; 428 } 429 430 callback.call(thisArg, value, key, _this); 431 }); 432 } 433 /** 434 * Removes all elements. 435 */ 436 437 }, { 438 key: "clear", 439 value: function clear() { 440 this._map = new Map(); 441 this._arrayTreeMap = new Map(); 442 this._objectTreeMap = new Map(); 443 } 444 }, { 445 key: "size", 446 get: function get() { 447 return this._map.size; 448 } 449 }]); 450 451 return EquivalentKeyMap; 452 }(); 453 454 module.exports = EquivalentKeyMap; 455 456 457 /***/ }) 458 459 /******/ }); 460 /************************************************************************/ 461 /******/ // The module cache 462 /******/ var __webpack_module_cache__ = {}; 463 /******/ 464 /******/ // The require function 465 /******/ function __webpack_require__(moduleId) { 466 /******/ // Check if module is in cache 467 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 468 /******/ if (cachedModule !== undefined) { 469 /******/ return cachedModule.exports; 470 /******/ } 471 /******/ // Create a new module (and put it into the cache) 472 /******/ var module = __webpack_module_cache__[moduleId] = { 473 /******/ // no module.id needed 474 /******/ // no module.loaded needed 475 /******/ exports: {} 476 /******/ }; 477 /******/ 478 /******/ // Execute the module function 479 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 480 /******/ 481 /******/ // Return the exports of the module 482 /******/ return module.exports; 483 /******/ } 484 /******/ 485 /************************************************************************/ 486 /******/ /* webpack/runtime/compat get default export */ 487 /******/ (() => { 488 /******/ // getDefaultExport function for compatibility with non-harmony modules 489 /******/ __webpack_require__.n = (module) => { 490 /******/ var getter = module && module.__esModule ? 491 /******/ () => (module['default']) : 492 /******/ () => (module); 493 /******/ __webpack_require__.d(getter, { a: getter }); 494 /******/ return getter; 495 /******/ }; 496 /******/ })(); 497 /******/ 498 /******/ /* webpack/runtime/define property getters */ 499 /******/ (() => { 500 /******/ // define getter functions for harmony exports 501 /******/ __webpack_require__.d = (exports, definition) => { 502 /******/ for(var key in definition) { 503 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 504 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 505 /******/ } 506 /******/ } 507 /******/ }; 508 /******/ })(); 509 /******/ 510 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 511 /******/ (() => { 512 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 513 /******/ })(); 514 /******/ 515 /******/ /* webpack/runtime/make namespace object */ 516 /******/ (() => { 517 /******/ // define __esModule on exports 518 /******/ __webpack_require__.r = (exports) => { 519 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 520 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 521 /******/ } 522 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 523 /******/ }; 524 /******/ })(); 525 /******/ 526 /************************************************************************/ 527 var __webpack_exports__ = {}; 528 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 529 (() => { 530 // ESM COMPAT FLAG 531 __webpack_require__.r(__webpack_exports__); 532 533 // EXPORTS 534 __webpack_require__.d(__webpack_exports__, { 535 AsyncModeProvider: () => (/* reexport */ async_mode_provider_context), 536 RegistryConsumer: () => (/* reexport */ RegistryConsumer), 537 RegistryProvider: () => (/* reexport */ context), 538 combineReducers: () => (/* binding */ build_module_combineReducers), 539 controls: () => (/* reexport */ controls), 540 createReduxStore: () => (/* reexport */ createReduxStore), 541 createRegistry: () => (/* reexport */ createRegistry), 542 createRegistryControl: () => (/* reexport */ createRegistryControl), 543 createRegistrySelector: () => (/* reexport */ createRegistrySelector), 544 createSelector: () => (/* reexport */ rememo), 545 dispatch: () => (/* reexport */ dispatch_dispatch), 546 plugins: () => (/* reexport */ plugins_namespaceObject), 547 register: () => (/* binding */ register), 548 registerGenericStore: () => (/* binding */ registerGenericStore), 549 registerStore: () => (/* binding */ registerStore), 550 resolveSelect: () => (/* binding */ build_module_resolveSelect), 551 select: () => (/* reexport */ select_select), 552 subscribe: () => (/* binding */ subscribe), 553 suspendSelect: () => (/* binding */ suspendSelect), 554 use: () => (/* binding */ use), 555 useDispatch: () => (/* reexport */ use_dispatch), 556 useRegistry: () => (/* reexport */ useRegistry), 557 useSelect: () => (/* reexport */ useSelect), 558 useSuspenseSelect: () => (/* reexport */ useSuspenseSelect), 559 withDispatch: () => (/* reexport */ with_dispatch), 560 withRegistry: () => (/* reexport */ with_registry), 561 withSelect: () => (/* reexport */ with_select) 562 }); 563 564 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js 565 var selectors_namespaceObject = {}; 566 __webpack_require__.r(selectors_namespaceObject); 567 __webpack_require__.d(selectors_namespaceObject, { 568 countSelectorsByStatus: () => (countSelectorsByStatus), 569 getCachedResolvers: () => (getCachedResolvers), 570 getIsResolving: () => (getIsResolving), 571 getResolutionError: () => (getResolutionError), 572 getResolutionState: () => (getResolutionState), 573 hasFinishedResolution: () => (hasFinishedResolution), 574 hasResolutionFailed: () => (hasResolutionFailed), 575 hasResolvingSelectors: () => (hasResolvingSelectors), 576 hasStartedResolution: () => (hasStartedResolution), 577 isResolving: () => (isResolving) 578 }); 579 580 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js 581 var actions_namespaceObject = {}; 582 __webpack_require__.r(actions_namespaceObject); 583 __webpack_require__.d(actions_namespaceObject, { 584 failResolution: () => (failResolution), 585 failResolutions: () => (failResolutions), 586 finishResolution: () => (finishResolution), 587 finishResolutions: () => (finishResolutions), 588 invalidateResolution: () => (invalidateResolution), 589 invalidateResolutionForStore: () => (invalidateResolutionForStore), 590 invalidateResolutionForStoreSelector: () => (invalidateResolutionForStoreSelector), 591 startResolution: () => (startResolution), 592 startResolutions: () => (startResolutions) 593 }); 594 595 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js 596 var plugins_namespaceObject = {}; 597 __webpack_require__.r(plugins_namespaceObject); 598 __webpack_require__.d(plugins_namespaceObject, { 599 persistence: () => (persistence) 600 }); 601 602 ;// CONCATENATED MODULE: external ["wp","deprecated"] 603 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; 604 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); 605 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js 606 function _typeof(o) { 607 "@babel/helpers - typeof"; 608 609 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { 610 return typeof o; 611 } : function (o) { 612 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; 613 }, _typeof(o); 614 } 615 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPrimitive.js 616 617 function _toPrimitive(input, hint) { 618 if (_typeof(input) !== "object" || input === null) return input; 619 var prim = input[Symbol.toPrimitive]; 620 if (prim !== undefined) { 621 var res = prim.call(input, hint || "default"); 622 if (_typeof(res) !== "object") return res; 623 throw new TypeError("@@toPrimitive must return a primitive value."); 624 } 625 return (hint === "string" ? String : Number)(input); 626 } 627 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js 628 629 630 function _toPropertyKey(arg) { 631 var key = _toPrimitive(arg, "string"); 632 return _typeof(key) === "symbol" ? key : String(key); 633 } 634 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js 635 636 function _defineProperty(obj, key, value) { 637 key = _toPropertyKey(key); 638 if (key in obj) { 639 Object.defineProperty(obj, key, { 640 value: value, 641 enumerable: true, 642 configurable: true, 643 writable: true 644 }); 645 } else { 646 obj[key] = value; 647 } 648 return obj; 649 } 650 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js 651 652 function ownKeys(e, r) { 653 var t = Object.keys(e); 654 if (Object.getOwnPropertySymbols) { 655 var o = Object.getOwnPropertySymbols(e); 656 r && (o = o.filter(function (r) { 657 return Object.getOwnPropertyDescriptor(e, r).enumerable; 658 })), t.push.apply(t, o); 659 } 660 return t; 661 } 662 function _objectSpread2(e) { 663 for (var r = 1; r < arguments.length; r++) { 664 var t = null != arguments[r] ? arguments[r] : {}; 665 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { 666 _defineProperty(e, r, t[r]); 667 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { 668 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); 669 }); 670 } 671 return e; 672 } 673 ;// CONCATENATED MODULE: ./node_modules/redux/es/redux.js 674 675 676 /** 677 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js 678 * 679 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes 680 * during build. 681 * @param {number} code 682 */ 683 function formatProdErrorMessage(code) { 684 return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. '; 685 } 686 687 // Inlined version of the `symbol-observable` polyfill 688 var $$observable = (function () { 689 return typeof Symbol === 'function' && Symbol.observable || '@@observable'; 690 })(); 691 692 /** 693 * These are private action types reserved by Redux. 694 * For any unknown actions, you must return the current state. 695 * If the current state is undefined, you must return the initial state. 696 * Do not reference these action types directly in your code. 697 */ 698 var randomString = function randomString() { 699 return Math.random().toString(36).substring(7).split('').join('.'); 700 }; 701 702 var ActionTypes = { 703 INIT: "@@redux/INIT" + randomString(), 704 REPLACE: "@@redux/REPLACE" + randomString(), 705 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() { 706 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString(); 707 } 708 }; 709 710 /** 711 * @param {any} obj The object to inspect. 712 * @returns {boolean} True if the argument appears to be a plain object. 713 */ 714 function isPlainObject(obj) { 715 if (typeof obj !== 'object' || obj === null) return false; 716 var proto = obj; 717 718 while (Object.getPrototypeOf(proto) !== null) { 719 proto = Object.getPrototypeOf(proto); 720 } 721 722 return Object.getPrototypeOf(obj) === proto; 723 } 724 725 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of 726 function miniKindOf(val) { 727 if (val === void 0) return 'undefined'; 728 if (val === null) return 'null'; 729 var type = typeof val; 730 731 switch (type) { 732 case 'boolean': 733 case 'string': 734 case 'number': 735 case 'symbol': 736 case 'function': 737 { 738 return type; 739 } 740 } 741 742 if (Array.isArray(val)) return 'array'; 743 if (isDate(val)) return 'date'; 744 if (isError(val)) return 'error'; 745 var constructorName = ctorName(val); 746 747 switch (constructorName) { 748 case 'Symbol': 749 case 'Promise': 750 case 'WeakMap': 751 case 'WeakSet': 752 case 'Map': 753 case 'Set': 754 return constructorName; 755 } // other 756 757 758 return type.slice(8, -1).toLowerCase().replace(/\s/g, ''); 759 } 760 761 function ctorName(val) { 762 return typeof val.constructor === 'function' ? val.constructor.name : null; 763 } 764 765 function isError(val) { 766 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number'; 767 } 768 769 function isDate(val) { 770 if (val instanceof Date) return true; 771 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function'; 772 } 773 774 function kindOf(val) { 775 var typeOfVal = typeof val; 776 777 if (false) {} 778 779 return typeOfVal; 780 } 781 782 /** 783 * @deprecated 784 * 785 * **We recommend using the `configureStore` method 786 * of the `@reduxjs/toolkit` package**, which replaces `createStore`. 787 * 788 * Redux Toolkit is our recommended approach for writing Redux logic today, 789 * including store setup, reducers, data fetching, and more. 790 * 791 * **For more details, please read this Redux docs page:** 792 * **https://redux.js.org/introduction/why-rtk-is-redux-today** 793 * 794 * `configureStore` from Redux Toolkit is an improved version of `createStore` that 795 * simplifies setup and helps avoid common bugs. 796 * 797 * You should not be using the `redux` core package by itself today, except for learning purposes. 798 * The `createStore` method from the core `redux` package will not be removed, but we encourage 799 * all users to migrate to using Redux Toolkit for all Redux code. 800 * 801 * If you want to use `createStore` without this visual deprecation warning, use 802 * the `legacy_createStore` import instead: 803 * 804 * `import { legacy_createStore as createStore} from 'redux'` 805 * 806 */ 807 808 function createStore(reducer, preloadedState, enhancer) { 809 var _ref2; 810 811 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') { 812 throw new Error( true ? formatProdErrorMessage(0) : 0); 813 } 814 815 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { 816 enhancer = preloadedState; 817 preloadedState = undefined; 818 } 819 820 if (typeof enhancer !== 'undefined') { 821 if (typeof enhancer !== 'function') { 822 throw new Error( true ? formatProdErrorMessage(1) : 0); 823 } 824 825 return enhancer(createStore)(reducer, preloadedState); 826 } 827 828 if (typeof reducer !== 'function') { 829 throw new Error( true ? formatProdErrorMessage(2) : 0); 830 } 831 832 var currentReducer = reducer; 833 var currentState = preloadedState; 834 var currentListeners = []; 835 var nextListeners = currentListeners; 836 var isDispatching = false; 837 /** 838 * This makes a shallow copy of currentListeners so we can use 839 * nextListeners as a temporary list while dispatching. 840 * 841 * This prevents any bugs around consumers calling 842 * subscribe/unsubscribe in the middle of a dispatch. 843 */ 844 845 function ensureCanMutateNextListeners() { 846 if (nextListeners === currentListeners) { 847 nextListeners = currentListeners.slice(); 848 } 849 } 850 /** 851 * Reads the state tree managed by the store. 852 * 853 * @returns {any} The current state tree of your application. 854 */ 855 856 857 function getState() { 858 if (isDispatching) { 859 throw new Error( true ? formatProdErrorMessage(3) : 0); 860 } 861 862 return currentState; 863 } 864 /** 865 * Adds a change listener. It will be called any time an action is dispatched, 866 * and some part of the state tree may potentially have changed. You may then 867 * call `getState()` to read the current state tree inside the callback. 868 * 869 * You may call `dispatch()` from a change listener, with the following 870 * caveats: 871 * 872 * 1. The subscriptions are snapshotted just before every `dispatch()` call. 873 * If you subscribe or unsubscribe while the listeners are being invoked, this 874 * will not have any effect on the `dispatch()` that is currently in progress. 875 * However, the next `dispatch()` call, whether nested or not, will use a more 876 * recent snapshot of the subscription list. 877 * 878 * 2. The listener should not expect to see all state changes, as the state 879 * might have been updated multiple times during a nested `dispatch()` before 880 * the listener is called. It is, however, guaranteed that all subscribers 881 * registered before the `dispatch()` started will be called with the latest 882 * state by the time it exits. 883 * 884 * @param {Function} listener A callback to be invoked on every dispatch. 885 * @returns {Function} A function to remove this change listener. 886 */ 887 888 889 function subscribe(listener) { 890 if (typeof listener !== 'function') { 891 throw new Error( true ? formatProdErrorMessage(4) : 0); 892 } 893 894 if (isDispatching) { 895 throw new Error( true ? formatProdErrorMessage(5) : 0); 896 } 897 898 var isSubscribed = true; 899 ensureCanMutateNextListeners(); 900 nextListeners.push(listener); 901 return function unsubscribe() { 902 if (!isSubscribed) { 903 return; 904 } 905 906 if (isDispatching) { 907 throw new Error( true ? formatProdErrorMessage(6) : 0); 908 } 909 910 isSubscribed = false; 911 ensureCanMutateNextListeners(); 912 var index = nextListeners.indexOf(listener); 913 nextListeners.splice(index, 1); 914 currentListeners = null; 915 }; 916 } 917 /** 918 * Dispatches an action. It is the only way to trigger a state change. 919 * 920 * The `reducer` function, used to create the store, will be called with the 921 * current state tree and the given `action`. Its return value will 922 * be considered the **next** state of the tree, and the change listeners 923 * will be notified. 924 * 925 * The base implementation only supports plain object actions. If you want to 926 * dispatch a Promise, an Observable, a thunk, or something else, you need to 927 * wrap your store creating function into the corresponding middleware. For 928 * example, see the documentation for the `redux-thunk` package. Even the 929 * middleware will eventually dispatch plain object actions using this method. 930 * 931 * @param {Object} action A plain object representing “what changed”. It is 932 * a good idea to keep actions serializable so you can record and replay user 933 * sessions, or use the time travelling `redux-devtools`. An action must have 934 * a `type` property which may not be `undefined`. It is a good idea to use 935 * string constants for action types. 936 * 937 * @returns {Object} For convenience, the same action object you dispatched. 938 * 939 * Note that, if you use a custom middleware, it may wrap `dispatch()` to 940 * return something else (for example, a Promise you can await). 941 */ 942 943 944 function dispatch(action) { 945 if (!isPlainObject(action)) { 946 throw new Error( true ? formatProdErrorMessage(7) : 0); 947 } 948 949 if (typeof action.type === 'undefined') { 950 throw new Error( true ? formatProdErrorMessage(8) : 0); 951 } 952 953 if (isDispatching) { 954 throw new Error( true ? formatProdErrorMessage(9) : 0); 955 } 956 957 try { 958 isDispatching = true; 959 currentState = currentReducer(currentState, action); 960 } finally { 961 isDispatching = false; 962 } 963 964 var listeners = currentListeners = nextListeners; 965 966 for (var i = 0; i < listeners.length; i++) { 967 var listener = listeners[i]; 968 listener(); 969 } 970 971 return action; 972 } 973 /** 974 * Replaces the reducer currently used by the store to calculate the state. 975 * 976 * You might need this if your app implements code splitting and you want to 977 * load some of the reducers dynamically. You might also need this if you 978 * implement a hot reloading mechanism for Redux. 979 * 980 * @param {Function} nextReducer The reducer for the store to use instead. 981 * @returns {void} 982 */ 983 984 985 function replaceReducer(nextReducer) { 986 if (typeof nextReducer !== 'function') { 987 throw new Error( true ? formatProdErrorMessage(10) : 0); 988 } 989 990 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT. 991 // Any reducers that existed in both the new and old rootReducer 992 // will receive the previous state. This effectively populates 993 // the new state tree with any relevant data from the old one. 994 995 dispatch({ 996 type: ActionTypes.REPLACE 997 }); 998 } 999 /** 1000 * Interoperability point for observable/reactive libraries. 1001 * @returns {observable} A minimal observable of state changes. 1002 * For more information, see the observable proposal: 1003 * https://github.com/tc39/proposal-observable 1004 */ 1005 1006 1007 function observable() { 1008 var _ref; 1009 1010 var outerSubscribe = subscribe; 1011 return _ref = { 1012 /** 1013 * The minimal observable subscription method. 1014 * @param {Object} observer Any object that can be used as an observer. 1015 * The observer object should have a `next` method. 1016 * @returns {subscription} An object with an `unsubscribe` method that can 1017 * be used to unsubscribe the observable from the store, and prevent further 1018 * emission of values from the observable. 1019 */ 1020 subscribe: function subscribe(observer) { 1021 if (typeof observer !== 'object' || observer === null) { 1022 throw new Error( true ? formatProdErrorMessage(11) : 0); 1023 } 1024 1025 function observeState() { 1026 if (observer.next) { 1027 observer.next(getState()); 1028 } 1029 } 1030 1031 observeState(); 1032 var unsubscribe = outerSubscribe(observeState); 1033 return { 1034 unsubscribe: unsubscribe 1035 }; 1036 } 1037 }, _ref[$$observable] = function () { 1038 return this; 1039 }, _ref; 1040 } // When a store is created, an "INIT" action is dispatched so that every 1041 // reducer returns their initial state. This effectively populates 1042 // the initial state tree. 1043 1044 1045 dispatch({ 1046 type: ActionTypes.INIT 1047 }); 1048 return _ref2 = { 1049 dispatch: dispatch, 1050 subscribe: subscribe, 1051 getState: getState, 1052 replaceReducer: replaceReducer 1053 }, _ref2[$$observable] = observable, _ref2; 1054 } 1055 /** 1056 * Creates a Redux store that holds the state tree. 1057 * 1058 * **We recommend using `configureStore` from the 1059 * `@reduxjs/toolkit` package**, which replaces `createStore`: 1060 * **https://redux.js.org/introduction/why-rtk-is-redux-today** 1061 * 1062 * The only way to change the data in the store is to call `dispatch()` on it. 1063 * 1064 * There should only be a single store in your app. To specify how different 1065 * parts of the state tree respond to actions, you may combine several reducers 1066 * into a single reducer function by using `combineReducers`. 1067 * 1068 * @param {Function} reducer A function that returns the next state tree, given 1069 * the current state tree and the action to handle. 1070 * 1071 * @param {any} [preloadedState] The initial state. You may optionally specify it 1072 * to hydrate the state from the server in universal apps, or to restore a 1073 * previously serialized user session. 1074 * If you use `combineReducers` to produce the root reducer function, this must be 1075 * an object with the same shape as `combineReducers` keys. 1076 * 1077 * @param {Function} [enhancer] The store enhancer. You may optionally specify it 1078 * to enhance the store with third-party capabilities such as middleware, 1079 * time travel, persistence, etc. The only store enhancer that ships with Redux 1080 * is `applyMiddleware()`. 1081 * 1082 * @returns {Store} A Redux store that lets you read the state, dispatch actions 1083 * and subscribe to changes. 1084 */ 1085 1086 var legacy_createStore = (/* unused pure expression or super */ null && (createStore)); 1087 1088 /** 1089 * Prints a warning in the console if it exists. 1090 * 1091 * @param {String} message The warning message. 1092 * @returns {void} 1093 */ 1094 function warning(message) { 1095 /* eslint-disable no-console */ 1096 if (typeof console !== 'undefined' && typeof console.error === 'function') { 1097 console.error(message); 1098 } 1099 /* eslint-enable no-console */ 1100 1101 1102 try { 1103 // This error was thrown as a convenience so that if you enable 1104 // "break on all exceptions" in your console, 1105 // it would pause the execution at this line. 1106 throw new Error(message); 1107 } catch (e) {} // eslint-disable-line no-empty 1108 1109 } 1110 1111 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { 1112 var reducerKeys = Object.keys(reducers); 1113 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer'; 1114 1115 if (reducerKeys.length === 0) { 1116 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'; 1117 } 1118 1119 if (!isPlainObject(inputState)) { 1120 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\""); 1121 } 1122 1123 var unexpectedKeys = Object.keys(inputState).filter(function (key) { 1124 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]; 1125 }); 1126 unexpectedKeys.forEach(function (key) { 1127 unexpectedKeyCache[key] = true; 1128 }); 1129 if (action && action.type === ActionTypes.REPLACE) return; 1130 1131 if (unexpectedKeys.length > 0) { 1132 return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored."); 1133 } 1134 } 1135 1136 function assertReducerShape(reducers) { 1137 Object.keys(reducers).forEach(function (key) { 1138 var reducer = reducers[key]; 1139 var initialState = reducer(undefined, { 1140 type: ActionTypes.INIT 1141 }); 1142 1143 if (typeof initialState === 'undefined') { 1144 throw new Error( true ? formatProdErrorMessage(12) : 0); 1145 } 1146 1147 if (typeof reducer(undefined, { 1148 type: ActionTypes.PROBE_UNKNOWN_ACTION() 1149 }) === 'undefined') { 1150 throw new Error( true ? formatProdErrorMessage(13) : 0); 1151 } 1152 }); 1153 } 1154 /** 1155 * Turns an object whose values are different reducer functions, into a single 1156 * reducer function. It will call every child reducer, and gather their results 1157 * into a single state object, whose keys correspond to the keys of the passed 1158 * reducer functions. 1159 * 1160 * @param {Object} reducers An object whose values correspond to different 1161 * reducer functions that need to be combined into one. One handy way to obtain 1162 * it is to use ES6 `import * as reducers` syntax. The reducers may never return 1163 * undefined for any action. Instead, they should return their initial state 1164 * if the state passed to them was undefined, and the current state for any 1165 * unrecognized action. 1166 * 1167 * @returns {Function} A reducer function that invokes every reducer inside the 1168 * passed object, and builds a state object with the same shape. 1169 */ 1170 1171 1172 function combineReducers(reducers) { 1173 var reducerKeys = Object.keys(reducers); 1174 var finalReducers = {}; 1175 1176 for (var i = 0; i < reducerKeys.length; i++) { 1177 var key = reducerKeys[i]; 1178 1179 if (false) {} 1180 1181 if (typeof reducers[key] === 'function') { 1182 finalReducers[key] = reducers[key]; 1183 } 1184 } 1185 1186 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same 1187 // keys multiple times. 1188 1189 var unexpectedKeyCache; 1190 1191 if (false) {} 1192 1193 var shapeAssertionError; 1194 1195 try { 1196 assertReducerShape(finalReducers); 1197 } catch (e) { 1198 shapeAssertionError = e; 1199 } 1200 1201 return function combination(state, action) { 1202 if (state === void 0) { 1203 state = {}; 1204 } 1205 1206 if (shapeAssertionError) { 1207 throw shapeAssertionError; 1208 } 1209 1210 if (false) { var warningMessage; } 1211 1212 var hasChanged = false; 1213 var nextState = {}; 1214 1215 for (var _i = 0; _i < finalReducerKeys.length; _i++) { 1216 var _key = finalReducerKeys[_i]; 1217 var reducer = finalReducers[_key]; 1218 var previousStateForKey = state[_key]; 1219 var nextStateForKey = reducer(previousStateForKey, action); 1220 1221 if (typeof nextStateForKey === 'undefined') { 1222 var actionType = action && action.type; 1223 throw new Error( true ? formatProdErrorMessage(14) : 0); 1224 } 1225 1226 nextState[_key] = nextStateForKey; 1227 hasChanged = hasChanged || nextStateForKey !== previousStateForKey; 1228 } 1229 1230 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length; 1231 return hasChanged ? nextState : state; 1232 }; 1233 } 1234 1235 function bindActionCreator(actionCreator, dispatch) { 1236 return function () { 1237 return dispatch(actionCreator.apply(this, arguments)); 1238 }; 1239 } 1240 /** 1241 * Turns an object whose values are action creators, into an object with the 1242 * same keys, but with every function wrapped into a `dispatch` call so they 1243 * may be invoked directly. This is just a convenience method, as you can call 1244 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine. 1245 * 1246 * For convenience, you can also pass an action creator as the first argument, 1247 * and get a dispatch wrapped function in return. 1248 * 1249 * @param {Function|Object} actionCreators An object whose values are action 1250 * creator functions. One handy way to obtain it is to use ES6 `import * as` 1251 * syntax. You may also pass a single function. 1252 * 1253 * @param {Function} dispatch The `dispatch` function available on your Redux 1254 * store. 1255 * 1256 * @returns {Function|Object} The object mimicking the original object, but with 1257 * every action creator wrapped into the `dispatch` call. If you passed a 1258 * function as `actionCreators`, the return value will also be a single 1259 * function. 1260 */ 1261 1262 1263 function bindActionCreators(actionCreators, dispatch) { 1264 if (typeof actionCreators === 'function') { 1265 return bindActionCreator(actionCreators, dispatch); 1266 } 1267 1268 if (typeof actionCreators !== 'object' || actionCreators === null) { 1269 throw new Error( true ? formatProdErrorMessage(16) : 0); 1270 } 1271 1272 var boundActionCreators = {}; 1273 1274 for (var key in actionCreators) { 1275 var actionCreator = actionCreators[key]; 1276 1277 if (typeof actionCreator === 'function') { 1278 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch); 1279 } 1280 } 1281 1282 return boundActionCreators; 1283 } 1284 1285 /** 1286 * Composes single-argument functions from right to left. The rightmost 1287 * function can take multiple arguments as it provides the signature for 1288 * the resulting composite function. 1289 * 1290 * @param {...Function} funcs The functions to compose. 1291 * @returns {Function} A function obtained by composing the argument functions 1292 * from right to left. For example, compose(f, g, h) is identical to doing 1293 * (...args) => f(g(h(...args))). 1294 */ 1295 function compose() { 1296 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) { 1297 funcs[_key] = arguments[_key]; 1298 } 1299 1300 if (funcs.length === 0) { 1301 return function (arg) { 1302 return arg; 1303 }; 1304 } 1305 1306 if (funcs.length === 1) { 1307 return funcs[0]; 1308 } 1309 1310 return funcs.reduce(function (a, b) { 1311 return function () { 1312 return a(b.apply(void 0, arguments)); 1313 }; 1314 }); 1315 } 1316 1317 /** 1318 * Creates a store enhancer that applies middleware to the dispatch method 1319 * of the Redux store. This is handy for a variety of tasks, such as expressing 1320 * asynchronous actions in a concise manner, or logging every action payload. 1321 * 1322 * See `redux-thunk` package as an example of the Redux middleware. 1323 * 1324 * Because middleware is potentially asynchronous, this should be the first 1325 * store enhancer in the composition chain. 1326 * 1327 * Note that each middleware will be given the `dispatch` and `getState` functions 1328 * as named arguments. 1329 * 1330 * @param {...Function} middlewares The middleware chain to be applied. 1331 * @returns {Function} A store enhancer applying the middleware. 1332 */ 1333 1334 function applyMiddleware() { 1335 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) { 1336 middlewares[_key] = arguments[_key]; 1337 } 1338 1339 return function (createStore) { 1340 return function () { 1341 var store = createStore.apply(void 0, arguments); 1342 1343 var _dispatch = function dispatch() { 1344 throw new Error( true ? formatProdErrorMessage(15) : 0); 1345 }; 1346 1347 var middlewareAPI = { 1348 getState: store.getState, 1349 dispatch: function dispatch() { 1350 return _dispatch.apply(void 0, arguments); 1351 } 1352 }; 1353 var chain = middlewares.map(function (middleware) { 1354 return middleware(middlewareAPI); 1355 }); 1356 _dispatch = compose.apply(void 0, chain)(store.dispatch); 1357 return _objectSpread2(_objectSpread2({}, store), {}, { 1358 dispatch: _dispatch 1359 }); 1360 }; 1361 }; 1362 } 1363 1364 1365 1366 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js 1367 var equivalent_key_map = __webpack_require__(3249); 1368 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map); 1369 ;// CONCATENATED MODULE: external ["wp","reduxRoutine"] 1370 const external_wp_reduxRoutine_namespaceObject = window["wp"]["reduxRoutine"]; 1371 var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_namespaceObject); 1372 ;// CONCATENATED MODULE: external ["wp","compose"] 1373 const external_wp_compose_namespaceObject = window["wp"]["compose"]; 1374 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/combine-reducers.js 1375 function combine_reducers_combineReducers(reducers) { 1376 const keys = Object.keys(reducers); 1377 return function combinedReducer(state = {}, action) { 1378 const nextState = {}; 1379 let hasChanged = false; 1380 for (const key of keys) { 1381 const reducer = reducers[key]; 1382 const prevStateForKey = state[key]; 1383 const nextStateForKey = reducer(prevStateForKey, action); 1384 nextState[key] = nextStateForKey; 1385 hasChanged = hasChanged || nextStateForKey !== prevStateForKey; 1386 } 1387 return hasChanged ? nextState : state; 1388 }; 1389 } 1390 1391 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js 1392 /** 1393 * Creates a selector function that takes additional curried argument with the 1394 * registry `select` function. While a regular selector has signature 1395 * ```js 1396 * ( state, ...selectorArgs ) => ( result ) 1397 * ``` 1398 * that allows to select data from the store's `state`, a registry selector 1399 * has signature: 1400 * ```js 1401 * ( select ) => ( state, ...selectorArgs ) => ( result ) 1402 * ``` 1403 * that supports also selecting from other registered stores. 1404 * 1405 * @example 1406 * ```js 1407 * import { store as coreStore } from '@wordpress/core-data'; 1408 * import { store as editorStore } from '@wordpress/editor'; 1409 * 1410 * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => { 1411 * return select( editorStore ).getCurrentPostId(); 1412 * } ); 1413 * 1414 * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => { 1415 * // calling another registry selector just like any other function 1416 * const postType = getCurrentPostType( state ); 1417 * const postId = getCurrentPostId( state ); 1418 * return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId ); 1419 * } ); 1420 * ``` 1421 * 1422 * Note how the `getCurrentPostId` selector can be called just like any other function, 1423 * (it works even inside a regular non-registry selector) and we don't need to pass the 1424 * registry as argument. The registry binding happens automatically when registering the selector 1425 * with a store. 1426 * 1427 * @param {Function} registrySelector Function receiving a registry `select` 1428 * function and returning a state selector. 1429 * 1430 * @return {Function} Registry selector that can be registered with a store. 1431 */ 1432 function createRegistrySelector(registrySelector) { 1433 const selectorsByRegistry = new WeakMap(); 1434 // Create a selector function that is bound to the registry referenced by `selector.registry` 1435 // and that has the same API as a regular selector. Binding it in such a way makes it 1436 // possible to call the selector directly from another selector. 1437 const wrappedSelector = (...args) => { 1438 let selector = selectorsByRegistry.get(wrappedSelector.registry); 1439 // We want to make sure the cache persists even when new registry 1440 // instances are created. For example patterns create their own editors 1441 // with their own core/block-editor stores, so we should keep track of 1442 // the cache for each registry instance. 1443 if (!selector) { 1444 selector = registrySelector(wrappedSelector.registry.select); 1445 selectorsByRegistry.set(wrappedSelector.registry, selector); 1446 } 1447 return selector(...args); 1448 }; 1449 1450 /** 1451 * Flag indicating that the selector is a registry selector that needs the correct registry 1452 * reference to be assigned to `selector.registry` to make it work correctly. 1453 * be mapped as a registry selector. 1454 * 1455 * @type {boolean} 1456 */ 1457 wrappedSelector.isRegistrySelector = true; 1458 return wrappedSelector; 1459 } 1460 1461 /** 1462 * Creates a control function that takes additional curried argument with the `registry` object. 1463 * While a regular control has signature 1464 * ```js 1465 * ( action ) => ( iteratorOrPromise ) 1466 * ``` 1467 * where the control works with the `action` that it's bound to, a registry control has signature: 1468 * ```js 1469 * ( registry ) => ( action ) => ( iteratorOrPromise ) 1470 * ``` 1471 * A registry control is typically used to select data or dispatch an action to a registered 1472 * store. 1473 * 1474 * When registering a control created with `createRegistryControl` with a store, the store 1475 * knows which calling convention to use when executing the control. 1476 * 1477 * @param {Function} registryControl Function receiving a registry object and returning a control. 1478 * 1479 * @return {Function} Registry control that can be registered with a store. 1480 */ 1481 function createRegistryControl(registryControl) { 1482 registryControl.isRegistryControl = true; 1483 return registryControl; 1484 } 1485 1486 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js 1487 /** 1488 * Internal dependencies 1489 */ 1490 1491 1492 /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ 1493 1494 const SELECT = '@@data/SELECT'; 1495 const RESOLVE_SELECT = '@@data/RESOLVE_SELECT'; 1496 const DISPATCH = '@@data/DISPATCH'; 1497 function isObject(object) { 1498 return object !== null && typeof object === 'object'; 1499 } 1500 1501 /** 1502 * Dispatches a control action for triggering a synchronous registry select. 1503 * 1504 * Note: This control synchronously returns the current selector value, triggering the 1505 * resolution, but not waiting for it. 1506 * 1507 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store 1508 * @param {string} selectorName The name of the selector. 1509 * @param {Array} args Arguments for the selector. 1510 * 1511 * @example 1512 * ```js 1513 * import { controls } from '@wordpress/data'; 1514 * 1515 * // Action generator using `select`. 1516 * export function* myAction() { 1517 * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' ); 1518 * // Do stuff with the result from the `select`. 1519 * } 1520 * ``` 1521 * 1522 * @return {Object} The control descriptor. 1523 */ 1524 function controls_select(storeNameOrDescriptor, selectorName, ...args) { 1525 return { 1526 type: SELECT, 1527 storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, 1528 selectorName, 1529 args 1530 }; 1531 } 1532 1533 /** 1534 * Dispatches a control action for triggering and resolving a registry select. 1535 * 1536 * Note: when this control action is handled, it automatically considers 1537 * selectors that may have a resolver. In such case, it will return a `Promise` that resolves 1538 * after the selector finishes resolving, with the final result value. 1539 * 1540 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store 1541 * @param {string} selectorName The name of the selector 1542 * @param {Array} args Arguments for the selector. 1543 * 1544 * @example 1545 * ```js 1546 * import { controls } from '@wordpress/data'; 1547 * 1548 * // Action generator using resolveSelect 1549 * export function* myAction() { 1550 * const isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' ); 1551 * // do stuff with the result from the select. 1552 * } 1553 * ``` 1554 * 1555 * @return {Object} The control descriptor. 1556 */ 1557 function resolveSelect(storeNameOrDescriptor, selectorName, ...args) { 1558 return { 1559 type: RESOLVE_SELECT, 1560 storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, 1561 selectorName, 1562 args 1563 }; 1564 } 1565 1566 /** 1567 * Dispatches a control action for triggering a registry dispatch. 1568 * 1569 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store 1570 * @param {string} actionName The name of the action to dispatch 1571 * @param {Array} args Arguments for the dispatch action. 1572 * 1573 * @example 1574 * ```js 1575 * import { controls } from '@wordpress/data-controls'; 1576 * 1577 * // Action generator using dispatch 1578 * export function* myAction() { 1579 * yield controls.dispatch( 'core/editor', 'togglePublishSidebar' ); 1580 * // do some other things. 1581 * } 1582 * ``` 1583 * 1584 * @return {Object} The control descriptor. 1585 */ 1586 function dispatch(storeNameOrDescriptor, actionName, ...args) { 1587 return { 1588 type: DISPATCH, 1589 storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, 1590 actionName, 1591 args 1592 }; 1593 } 1594 const controls = { 1595 select: controls_select, 1596 resolveSelect, 1597 dispatch 1598 }; 1599 const builtinControls = { 1600 [SELECT]: createRegistryControl(registry => ({ 1601 storeKey, 1602 selectorName, 1603 args 1604 }) => registry.select(storeKey)[selectorName](...args)), 1605 [RESOLVE_SELECT]: createRegistryControl(registry => ({ 1606 storeKey, 1607 selectorName, 1608 args 1609 }) => { 1610 const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select'; 1611 return registry[method](storeKey)[selectorName](...args); 1612 }), 1613 [DISPATCH]: createRegistryControl(registry => ({ 1614 storeKey, 1615 actionName, 1616 args 1617 }) => registry.dispatch(storeKey)[actionName](...args)) 1618 }; 1619 1620 ;// CONCATENATED MODULE: external ["wp","privateApis"] 1621 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; 1622 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/lock-unlock.js 1623 /** 1624 * WordPress dependencies 1625 */ 1626 1627 const { 1628 lock, 1629 unlock 1630 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/data'); 1631 1632 ;// CONCATENATED MODULE: ./node_modules/is-promise/index.mjs 1633 function isPromise(obj) { 1634 return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; 1635 } 1636 1637 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js 1638 /** 1639 * External dependencies 1640 */ 1641 1642 1643 /** 1644 * Simplest possible promise redux middleware. 1645 * 1646 * @type {import('redux').Middleware} 1647 */ 1648 const promiseMiddleware = () => next => action => { 1649 if (isPromise(action)) { 1650 return action.then(resolvedAction => { 1651 if (resolvedAction) { 1652 return next(resolvedAction); 1653 } 1654 }); 1655 } 1656 return next(action); 1657 }; 1658 /* harmony default export */ const promise_middleware = (promiseMiddleware); 1659 1660 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js 1661 /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ 1662 1663 /** 1664 * Creates a middleware handling resolvers cache invalidation. 1665 * 1666 * @param {WPDataRegistry} registry Registry for which to create the middleware. 1667 * @param {string} storeName Name of the store for which to create the middleware. 1668 * 1669 * @return {Function} Middleware function. 1670 */ 1671 const createResolversCacheMiddleware = (registry, storeName) => () => next => action => { 1672 const resolvers = registry.select(storeName).getCachedResolvers(); 1673 const resolverEntries = Object.entries(resolvers); 1674 resolverEntries.forEach(([selectorName, resolversByArgs]) => { 1675 const resolver = registry.stores[storeName]?.resolvers?.[selectorName]; 1676 if (!resolver || !resolver.shouldInvalidate) { 1677 return; 1678 } 1679 resolversByArgs.forEach((value, args) => { 1680 // Works around a bug in `EquivalentKeyMap` where `map.delete` merely sets an entry value 1681 // to `undefined` and `map.forEach` then iterates also over these orphaned entries. 1682 if (value === undefined) { 1683 return; 1684 } 1685 1686 // resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector. 1687 // If the value is "finished" or "error" it means this resolver has finished its resolution which means we need 1688 // to invalidate it, if it's true it means it's inflight and the invalidation is not necessary. 1689 if (value.status !== 'finished' && value.status !== 'error') { 1690 return; 1691 } 1692 if (!resolver.shouldInvalidate(action, ...args)) { 1693 return; 1694 } 1695 1696 // Trigger cache invalidation 1697 registry.dispatch(storeName).invalidateResolution(selectorName, args); 1698 }); 1699 }); 1700 return next(action); 1701 }; 1702 /* harmony default export */ const resolvers_cache_middleware = (createResolversCacheMiddleware); 1703 1704 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js 1705 function createThunkMiddleware(args) { 1706 return () => next => action => { 1707 if (typeof action === 'function') { 1708 return action(args); 1709 } 1710 return next(action); 1711 }; 1712 } 1713 1714 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js 1715 /** 1716 * External dependencies 1717 */ 1718 1719 /** 1720 * Higher-order reducer creator which creates a combined reducer object, keyed 1721 * by a property on the action object. 1722 * 1723 * @param actionProperty Action property by which to key object. 1724 * @return Higher-order reducer. 1725 */ 1726 const onSubKey = actionProperty => reducer => (state = {}, action) => { 1727 // Retrieve subkey from action. Do not track if undefined; useful for cases 1728 // where reducer is scoped by action shape. 1729 const key = action[actionProperty]; 1730 if (key === undefined) { 1731 return state; 1732 } 1733 1734 // Avoid updating state if unchanged. Note that this also accounts for a 1735 // reducer which returns undefined on a key which is not yet tracked. 1736 const nextKeyState = reducer(state[key], action); 1737 if (nextKeyState === state[key]) { 1738 return state; 1739 } 1740 return { 1741 ...state, 1742 [key]: nextKeyState 1743 }; 1744 }; 1745 1746 /** 1747 * Normalize selector argument array by defaulting `undefined` value to an empty array 1748 * and removing trailing `undefined` values. 1749 * 1750 * @param args Selector argument array 1751 * @return Normalized state key array 1752 */ 1753 function selectorArgsToStateKey(args) { 1754 if (args === undefined || args === null) { 1755 return []; 1756 } 1757 const len = args.length; 1758 let idx = len; 1759 while (idx > 0 && args[idx - 1] === undefined) { 1760 idx--; 1761 } 1762 return idx === len ? args : args.slice(0, idx); 1763 } 1764 1765 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js 1766 /** 1767 * External dependencies 1768 */ 1769 1770 /** 1771 * Internal dependencies 1772 */ 1773 1774 /** 1775 * Reducer function returning next state for selector resolution of 1776 * subkeys, object form: 1777 * 1778 * selectorName -> EquivalentKeyMap<Array,boolean> 1779 */ 1780 const subKeysIsResolved = onSubKey('selectorName')((state = new (equivalent_key_map_default())(), action) => { 1781 switch (action.type) { 1782 case 'START_RESOLUTION': 1783 { 1784 const nextState = new (equivalent_key_map_default())(state); 1785 nextState.set(selectorArgsToStateKey(action.args), { 1786 status: 'resolving' 1787 }); 1788 return nextState; 1789 } 1790 case 'FINISH_RESOLUTION': 1791 { 1792 const nextState = new (equivalent_key_map_default())(state); 1793 nextState.set(selectorArgsToStateKey(action.args), { 1794 status: 'finished' 1795 }); 1796 return nextState; 1797 } 1798 case 'FAIL_RESOLUTION': 1799 { 1800 const nextState = new (equivalent_key_map_default())(state); 1801 nextState.set(selectorArgsToStateKey(action.args), { 1802 status: 'error', 1803 error: action.error 1804 }); 1805 return nextState; 1806 } 1807 case 'START_RESOLUTIONS': 1808 { 1809 const nextState = new (equivalent_key_map_default())(state); 1810 for (const resolutionArgs of action.args) { 1811 nextState.set(selectorArgsToStateKey(resolutionArgs), { 1812 status: 'resolving' 1813 }); 1814 } 1815 return nextState; 1816 } 1817 case 'FINISH_RESOLUTIONS': 1818 { 1819 const nextState = new (equivalent_key_map_default())(state); 1820 for (const resolutionArgs of action.args) { 1821 nextState.set(selectorArgsToStateKey(resolutionArgs), { 1822 status: 'finished' 1823 }); 1824 } 1825 return nextState; 1826 } 1827 case 'FAIL_RESOLUTIONS': 1828 { 1829 const nextState = new (equivalent_key_map_default())(state); 1830 action.args.forEach((resolutionArgs, idx) => { 1831 const resolutionState = { 1832 status: 'error', 1833 error: undefined 1834 }; 1835 const error = action.errors[idx]; 1836 if (error) { 1837 resolutionState.error = error; 1838 } 1839 nextState.set(selectorArgsToStateKey(resolutionArgs), resolutionState); 1840 }); 1841 return nextState; 1842 } 1843 case 'INVALIDATE_RESOLUTION': 1844 { 1845 const nextState = new (equivalent_key_map_default())(state); 1846 nextState.delete(selectorArgsToStateKey(action.args)); 1847 return nextState; 1848 } 1849 } 1850 return state; 1851 }); 1852 1853 /** 1854 * Reducer function returning next state for selector resolution, object form: 1855 * 1856 * selectorName -> EquivalentKeyMap<Array, boolean> 1857 * 1858 * @param state Current state. 1859 * @param action Dispatched action. 1860 * 1861 * @return Next state. 1862 */ 1863 const isResolved = (state = {}, action) => { 1864 switch (action.type) { 1865 case 'INVALIDATE_RESOLUTION_FOR_STORE': 1866 return {}; 1867 case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': 1868 { 1869 if (action.selectorName in state) { 1870 const { 1871 [action.selectorName]: removedSelector, 1872 ...restState 1873 } = state; 1874 return restState; 1875 } 1876 return state; 1877 } 1878 case 'START_RESOLUTION': 1879 case 'FINISH_RESOLUTION': 1880 case 'FAIL_RESOLUTION': 1881 case 'START_RESOLUTIONS': 1882 case 'FINISH_RESOLUTIONS': 1883 case 'FAIL_RESOLUTIONS': 1884 case 'INVALIDATE_RESOLUTION': 1885 return subKeysIsResolved(state, action); 1886 } 1887 return state; 1888 }; 1889 /* harmony default export */ const metadata_reducer = (isResolved); 1890 1891 ;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js 1892 1893 1894 /** @typedef {(...args: any[]) => *[]} GetDependants */ 1895 1896 /** @typedef {() => void} Clear */ 1897 1898 /** 1899 * @typedef {{ 1900 * getDependants: GetDependants, 1901 * clear: Clear 1902 * }} EnhancedSelector 1903 */ 1904 1905 /** 1906 * Internal cache entry. 1907 * 1908 * @typedef CacheNode 1909 * 1910 * @property {?CacheNode|undefined} [prev] Previous node. 1911 * @property {?CacheNode|undefined} [next] Next node. 1912 * @property {*[]} args Function arguments for cache entry. 1913 * @property {*} val Function result. 1914 */ 1915 1916 /** 1917 * @typedef Cache 1918 * 1919 * @property {Clear} clear Function to clear cache. 1920 * @property {boolean} [isUniqueByDependants] Whether dependants are valid in 1921 * considering cache uniqueness. A cache is unique if dependents are all arrays 1922 * or objects. 1923 * @property {CacheNode?} [head] Cache head. 1924 * @property {*[]} [lastDependants] Dependants from previous invocation. 1925 */ 1926 1927 /** 1928 * Arbitrary value used as key for referencing cache object in WeakMap tree. 1929 * 1930 * @type {{}} 1931 */ 1932 var LEAF_KEY = {}; 1933 1934 /** 1935 * Returns the first argument as the sole entry in an array. 1936 * 1937 * @template T 1938 * 1939 * @param {T} value Value to return. 1940 * 1941 * @return {[T]} Value returned as entry in array. 1942 */ 1943 function arrayOf(value) { 1944 return [value]; 1945 } 1946 1947 /** 1948 * Returns true if the value passed is object-like, or false otherwise. A value 1949 * is object-like if it can support property assignment, e.g. object or array. 1950 * 1951 * @param {*} value Value to test. 1952 * 1953 * @return {boolean} Whether value is object-like. 1954 */ 1955 function isObjectLike(value) { 1956 return !!value && 'object' === typeof value; 1957 } 1958 1959 /** 1960 * Creates and returns a new cache object. 1961 * 1962 * @return {Cache} Cache object. 1963 */ 1964 function createCache() { 1965 /** @type {Cache} */ 1966 var cache = { 1967 clear: function () { 1968 cache.head = null; 1969 }, 1970 }; 1971 1972 return cache; 1973 } 1974 1975 /** 1976 * Returns true if entries within the two arrays are strictly equal by 1977 * reference from a starting index. 1978 * 1979 * @param {*[]} a First array. 1980 * @param {*[]} b Second array. 1981 * @param {number} fromIndex Index from which to start comparison. 1982 * 1983 * @return {boolean} Whether arrays are shallowly equal. 1984 */ 1985 function isShallowEqual(a, b, fromIndex) { 1986 var i; 1987 1988 if (a.length !== b.length) { 1989 return false; 1990 } 1991 1992 for (i = fromIndex; i < a.length; i++) { 1993 if (a[i] !== b[i]) { 1994 return false; 1995 } 1996 } 1997 1998 return true; 1999 } 2000 2001 /** 2002 * Returns a memoized selector function. The getDependants function argument is 2003 * called before the memoized selector and is expected to return an immutable 2004 * reference or array of references on which the selector depends for computing 2005 * its own return value. The memoize cache is preserved only as long as those 2006 * dependant references remain the same. If getDependants returns a different 2007 * reference(s), the cache is cleared and the selector value regenerated. 2008 * 2009 * @template {(...args: *[]) => *} S 2010 * 2011 * @param {S} selector Selector function. 2012 * @param {GetDependants=} getDependants Dependant getter returning an array of 2013 * references used in cache bust consideration. 2014 */ 2015 /* harmony default export */ function rememo(selector, getDependants) { 2016 /** @type {WeakMap<*,*>} */ 2017 var rootCache; 2018 2019 /** @type {GetDependants} */ 2020 var normalizedGetDependants = getDependants ? getDependants : arrayOf; 2021 2022 /** 2023 * Returns the cache for a given dependants array. When possible, a WeakMap 2024 * will be used to create a unique cache for each set of dependants. This 2025 * is feasible due to the nature of WeakMap in allowing garbage collection 2026 * to occur on entries where the key object is no longer referenced. Since 2027 * WeakMap requires the key to be an object, this is only possible when the 2028 * dependant is object-like. The root cache is created as a hierarchy where 2029 * each top-level key is the first entry in a dependants set, the value a 2030 * WeakMap where each key is the next dependant, and so on. This continues 2031 * so long as the dependants are object-like. If no dependants are object- 2032 * like, then the cache is shared across all invocations. 2033 * 2034 * @see isObjectLike 2035 * 2036 * @param {*[]} dependants Selector dependants. 2037 * 2038 * @return {Cache} Cache object. 2039 */ 2040 function getCache(dependants) { 2041 var caches = rootCache, 2042 isUniqueByDependants = true, 2043 i, 2044 dependant, 2045 map, 2046 cache; 2047 2048 for (i = 0; i < dependants.length; i++) { 2049 dependant = dependants[i]; 2050 2051 // Can only compose WeakMap from object-like key. 2052 if (!isObjectLike(dependant)) { 2053 isUniqueByDependants = false; 2054 break; 2055 } 2056 2057 // Does current segment of cache already have a WeakMap? 2058 if (caches.has(dependant)) { 2059 // Traverse into nested WeakMap. 2060 caches = caches.get(dependant); 2061 } else { 2062 // Create, set, and traverse into a new one. 2063 map = new WeakMap(); 2064 caches.set(dependant, map); 2065 caches = map; 2066 } 2067 } 2068 2069 // We use an arbitrary (but consistent) object as key for the last item 2070 // in the WeakMap to serve as our running cache. 2071 if (!caches.has(LEAF_KEY)) { 2072 cache = createCache(); 2073 cache.isUniqueByDependants = isUniqueByDependants; 2074 caches.set(LEAF_KEY, cache); 2075 } 2076 2077 return caches.get(LEAF_KEY); 2078 } 2079 2080 /** 2081 * Resets root memoization cache. 2082 */ 2083 function clear() { 2084 rootCache = new WeakMap(); 2085 } 2086 2087 /* eslint-disable jsdoc/check-param-names */ 2088 /** 2089 * The augmented selector call, considering first whether dependants have 2090 * changed before passing it to underlying memoize function. 2091 * 2092 * @param {*} source Source object for derivation. 2093 * @param {...*} extraArgs Additional arguments to pass to selector. 2094 * 2095 * @return {*} Selector result. 2096 */ 2097 /* eslint-enable jsdoc/check-param-names */ 2098 function callSelector(/* source, ...extraArgs */) { 2099 var len = arguments.length, 2100 cache, 2101 node, 2102 i, 2103 args, 2104 dependants; 2105 2106 // Create copy of arguments (avoid leaking deoptimization). 2107 args = new Array(len); 2108 for (i = 0; i < len; i++) { 2109 args[i] = arguments[i]; 2110 } 2111 2112 dependants = normalizedGetDependants.apply(null, args); 2113 cache = getCache(dependants); 2114 2115 // If not guaranteed uniqueness by dependants (primitive type), shallow 2116 // compare against last dependants and, if references have changed, 2117 // destroy cache to recalculate result. 2118 if (!cache.isUniqueByDependants) { 2119 if ( 2120 cache.lastDependants && 2121 !isShallowEqual(dependants, cache.lastDependants, 0) 2122 ) { 2123 cache.clear(); 2124 } 2125 2126 cache.lastDependants = dependants; 2127 } 2128 2129 node = cache.head; 2130 while (node) { 2131 // Check whether node arguments match arguments 2132 if (!isShallowEqual(node.args, args, 1)) { 2133 node = node.next; 2134 continue; 2135 } 2136 2137 // At this point we can assume we've found a match 2138 2139 // Surface matched node to head if not already 2140 if (node !== cache.head) { 2141 // Adjust siblings to point to each other. 2142 /** @type {CacheNode} */ (node.prev).next = node.next; 2143 if (node.next) { 2144 node.next.prev = node.prev; 2145 } 2146 2147 node.next = cache.head; 2148 node.prev = null; 2149 /** @type {CacheNode} */ (cache.head).prev = node; 2150 cache.head = node; 2151 } 2152 2153 // Return immediately 2154 return node.val; 2155 } 2156 2157 // No cached value found. Continue to insertion phase: 2158 2159 node = /** @type {CacheNode} */ ({ 2160 // Generate the result from original function 2161 val: selector.apply(null, args), 2162 }); 2163 2164 // Avoid including the source object in the cache. 2165 args[0] = null; 2166 node.args = args; 2167 2168 // Don't need to check whether node is already head, since it would 2169 // have been returned above already if it was 2170 2171 // Shift existing head down list 2172 if (cache.head) { 2173 cache.head.prev = node; 2174 node.next = cache.head; 2175 } 2176 2177 cache.head = node; 2178 2179 return node.val; 2180 } 2181 2182 callSelector.getDependants = normalizedGetDependants; 2183 callSelector.clear = clear; 2184 clear(); 2185 2186 return /** @type {S & EnhancedSelector} */ (callSelector); 2187 } 2188 2189 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js 2190 /** 2191 * WordPress dependencies 2192 */ 2193 2194 2195 /** 2196 * Internal dependencies 2197 */ 2198 2199 2200 2201 /** @typedef {Record<string, import('./reducer').State>} State */ 2202 /** @typedef {import('./reducer').StateValue} StateValue */ 2203 /** @typedef {import('./reducer').Status} Status */ 2204 2205 /** 2206 * Returns the raw resolution state value for a given selector name, 2207 * and arguments set. May be undefined if the selector has never been resolved 2208 * or not resolved for the given set of arguments, otherwise true or false for 2209 * resolution started and completed respectively. 2210 * 2211 * @param {State} state Data state. 2212 * @param {string} selectorName Selector name. 2213 * @param {unknown[]?} args Arguments passed to selector. 2214 * 2215 * @return {StateValue|undefined} isResolving value. 2216 */ 2217 function getResolutionState(state, selectorName, args) { 2218 const map = state[selectorName]; 2219 if (!map) { 2220 return; 2221 } 2222 return map.get(selectorArgsToStateKey(args)); 2223 } 2224 2225 /** 2226 * Returns an `isResolving`-like value for a given selector name and arguments set. 2227 * Its value is either `undefined` if the selector has never been resolved or has been 2228 * invalidated, or a `true`/`false` boolean value if the resolution is in progress or 2229 * has finished, respectively. 2230 * 2231 * This is a legacy selector that was implemented when the "raw" internal data had 2232 * this `undefined | boolean` format. Nowadays the internal value is an object that 2233 * can be retrieved with `getResolutionState`. 2234 * 2235 * @deprecated 2236 * 2237 * @param {State} state Data state. 2238 * @param {string} selectorName Selector name. 2239 * @param {unknown[]?} args Arguments passed to selector. 2240 * 2241 * @return {boolean | undefined} isResolving value. 2242 */ 2243 function getIsResolving(state, selectorName, args) { 2244 external_wp_deprecated_default()('wp.data.select( store ).getIsResolving', { 2245 since: '6.6', 2246 version: '6.8', 2247 alternative: 'wp.data.select( store ).getResolutionState' 2248 }); 2249 const resolutionState = getResolutionState(state, selectorName, args); 2250 return resolutionState && resolutionState.status === 'resolving'; 2251 } 2252 2253 /** 2254 * Returns true if resolution has already been triggered for a given 2255 * selector name, and arguments set. 2256 * 2257 * @param {State} state Data state. 2258 * @param {string} selectorName Selector name. 2259 * @param {unknown[]?} args Arguments passed to selector. 2260 * 2261 * @return {boolean} Whether resolution has been triggered. 2262 */ 2263 function hasStartedResolution(state, selectorName, args) { 2264 return getResolutionState(state, selectorName, args) !== undefined; 2265 } 2266 2267 /** 2268 * Returns true if resolution has completed for a given selector 2269 * name, and arguments set. 2270 * 2271 * @param {State} state Data state. 2272 * @param {string} selectorName Selector name. 2273 * @param {unknown[]?} args Arguments passed to selector. 2274 * 2275 * @return {boolean} Whether resolution has completed. 2276 */ 2277 function hasFinishedResolution(state, selectorName, args) { 2278 const status = getResolutionState(state, selectorName, args)?.status; 2279 return status === 'finished' || status === 'error'; 2280 } 2281 2282 /** 2283 * Returns true if resolution has failed for a given selector 2284 * name, and arguments set. 2285 * 2286 * @param {State} state Data state. 2287 * @param {string} selectorName Selector name. 2288 * @param {unknown[]?} args Arguments passed to selector. 2289 * 2290 * @return {boolean} Has resolution failed 2291 */ 2292 function hasResolutionFailed(state, selectorName, args) { 2293 return getResolutionState(state, selectorName, args)?.status === 'error'; 2294 } 2295 2296 /** 2297 * Returns the resolution error for a given selector name, and arguments set. 2298 * Note it may be of an Error type, but may also be null, undefined, or anything else 2299 * that can be `throw`-n. 2300 * 2301 * @param {State} state Data state. 2302 * @param {string} selectorName Selector name. 2303 * @param {unknown[]?} args Arguments passed to selector. 2304 * 2305 * @return {Error|unknown} Last resolution error 2306 */ 2307 function getResolutionError(state, selectorName, args) { 2308 const resolutionState = getResolutionState(state, selectorName, args); 2309 return resolutionState?.status === 'error' ? resolutionState.error : null; 2310 } 2311 2312 /** 2313 * Returns true if resolution has been triggered but has not yet completed for 2314 * a given selector name, and arguments set. 2315 * 2316 * @param {State} state Data state. 2317 * @param {string} selectorName Selector name. 2318 * @param {unknown[]?} args Arguments passed to selector. 2319 * 2320 * @return {boolean} Whether resolution is in progress. 2321 */ 2322 function isResolving(state, selectorName, args) { 2323 return getResolutionState(state, selectorName, args)?.status === 'resolving'; 2324 } 2325 2326 /** 2327 * Returns the list of the cached resolvers. 2328 * 2329 * @param {State} state Data state. 2330 * 2331 * @return {State} Resolvers mapped by args and selectorName. 2332 */ 2333 function getCachedResolvers(state) { 2334 return state; 2335 } 2336 2337 /** 2338 * Whether the store has any currently resolving selectors. 2339 * 2340 * @param {State} state Data state. 2341 * 2342 * @return {boolean} True if one or more selectors are resolving, false otherwise. 2343 */ 2344 function hasResolvingSelectors(state) { 2345 return Object.values(state).some(selectorState => 2346 /** 2347 * This uses the internal `_map` property of `EquivalentKeyMap` for 2348 * optimization purposes, since the `EquivalentKeyMap` implementation 2349 * does not support a `.values()` implementation. 2350 * 2351 * @see https://github.com/aduth/equivalent-key-map 2352 */ 2353 Array.from(selectorState._map.values()).some(resolution => resolution[1]?.status === 'resolving')); 2354 } 2355 2356 /** 2357 * Retrieves the total number of selectors, grouped per status. 2358 * 2359 * @param {State} state Data state. 2360 * 2361 * @return {Object} Object, containing selector totals by status. 2362 */ 2363 const countSelectorsByStatus = rememo(state => { 2364 const selectorsByStatus = {}; 2365 Object.values(state).forEach(selectorState => 2366 /** 2367 * This uses the internal `_map` property of `EquivalentKeyMap` for 2368 * optimization purposes, since the `EquivalentKeyMap` implementation 2369 * does not support a `.values()` implementation. 2370 * 2371 * @see https://github.com/aduth/equivalent-key-map 2372 */ 2373 Array.from(selectorState._map.values()).forEach(resolution => { 2374 var _resolution$1$status; 2375 const currentStatus = (_resolution$1$status = resolution[1]?.status) !== null && _resolution$1$status !== void 0 ? _resolution$1$status : 'error'; 2376 if (!selectorsByStatus[currentStatus]) { 2377 selectorsByStatus[currentStatus] = 0; 2378 } 2379 selectorsByStatus[currentStatus]++; 2380 })); 2381 return selectorsByStatus; 2382 }, state => [state]); 2383 2384 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js 2385 /** 2386 * Returns an action object used in signalling that selector resolution has 2387 * started. 2388 * 2389 * @param {string} selectorName Name of selector for which resolver triggered. 2390 * @param {unknown[]} args Arguments to associate for uniqueness. 2391 * 2392 * @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object. 2393 */ 2394 function startResolution(selectorName, args) { 2395 return { 2396 type: 'START_RESOLUTION', 2397 selectorName, 2398 args 2399 }; 2400 } 2401 2402 /** 2403 * Returns an action object used in signalling that selector resolution has 2404 * completed. 2405 * 2406 * @param {string} selectorName Name of selector for which resolver triggered. 2407 * @param {unknown[]} args Arguments to associate for uniqueness. 2408 * 2409 * @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object. 2410 */ 2411 function finishResolution(selectorName, args) { 2412 return { 2413 type: 'FINISH_RESOLUTION', 2414 selectorName, 2415 args 2416 }; 2417 } 2418 2419 /** 2420 * Returns an action object used in signalling that selector resolution has 2421 * failed. 2422 * 2423 * @param {string} selectorName Name of selector for which resolver triggered. 2424 * @param {unknown[]} args Arguments to associate for uniqueness. 2425 * @param {Error|unknown} error The error that caused the failure. 2426 * 2427 * @return {{ type: 'FAIL_RESOLUTION', selectorName: string, args: unknown[], error: Error|unknown }} Action object. 2428 */ 2429 function failResolution(selectorName, args, error) { 2430 return { 2431 type: 'FAIL_RESOLUTION', 2432 selectorName, 2433 args, 2434 error 2435 }; 2436 } 2437 2438 /** 2439 * Returns an action object used in signalling that a batch of selector resolutions has 2440 * started. 2441 * 2442 * @param {string} selectorName Name of selector for which resolver triggered. 2443 * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item 2444 * is associated to a resolution. 2445 * 2446 * @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object. 2447 */ 2448 function startResolutions(selectorName, args) { 2449 return { 2450 type: 'START_RESOLUTIONS', 2451 selectorName, 2452 args 2453 }; 2454 } 2455 2456 /** 2457 * Returns an action object used in signalling that a batch of selector resolutions has 2458 * completed. 2459 * 2460 * @param {string} selectorName Name of selector for which resolver triggered. 2461 * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item 2462 * is associated to a resolution. 2463 * 2464 * @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object. 2465 */ 2466 function finishResolutions(selectorName, args) { 2467 return { 2468 type: 'FINISH_RESOLUTIONS', 2469 selectorName, 2470 args 2471 }; 2472 } 2473 2474 /** 2475 * Returns an action object used in signalling that a batch of selector resolutions has 2476 * completed and at least one of them has failed. 2477 * 2478 * @param {string} selectorName Name of selector for which resolver triggered. 2479 * @param {unknown[]} args Array of arguments to associate for uniqueness, each item 2480 * is associated to a resolution. 2481 * @param {(Error|unknown)[]} errors Array of errors to associate for uniqueness, each item 2482 * is associated to a resolution. 2483 * @return {{ type: 'FAIL_RESOLUTIONS', selectorName: string, args: unknown[], errors: Array<Error|unknown> }} Action object. 2484 */ 2485 function failResolutions(selectorName, args, errors) { 2486 return { 2487 type: 'FAIL_RESOLUTIONS', 2488 selectorName, 2489 args, 2490 errors 2491 }; 2492 } 2493 2494 /** 2495 * Returns an action object used in signalling that we should invalidate the resolution cache. 2496 * 2497 * @param {string} selectorName Name of selector for which resolver should be invalidated. 2498 * @param {unknown[]} args Arguments to associate for uniqueness. 2499 * 2500 * @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object. 2501 */ 2502 function invalidateResolution(selectorName, args) { 2503 return { 2504 type: 'INVALIDATE_RESOLUTION', 2505 selectorName, 2506 args 2507 }; 2508 } 2509 2510 /** 2511 * Returns an action object used in signalling that the resolution 2512 * should be invalidated. 2513 * 2514 * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object. 2515 */ 2516 function invalidateResolutionForStore() { 2517 return { 2518 type: 'INVALIDATE_RESOLUTION_FOR_STORE' 2519 }; 2520 } 2521 2522 /** 2523 * Returns an action object used in signalling that the resolution cache for a 2524 * given selectorName should be invalidated. 2525 * 2526 * @param {string} selectorName Name of selector for which all resolvers should 2527 * be invalidated. 2528 * 2529 * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object. 2530 */ 2531 function invalidateResolutionForStoreSelector(selectorName) { 2532 return { 2533 type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', 2534 selectorName 2535 }; 2536 } 2537 2538 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js 2539 /** 2540 * External dependencies 2541 */ 2542 2543 2544 2545 /** 2546 * WordPress dependencies 2547 */ 2548 2549 2550 2551 /** 2552 * Internal dependencies 2553 */ 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 /** @typedef {import('../types').DataRegistry} DataRegistry */ 2566 /** @typedef {import('../types').ListenerFunction} ListenerFunction */ 2567 /** 2568 * @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor 2569 * @template {import('../types').AnyConfig} C 2570 */ 2571 /** 2572 * @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig 2573 * @template State 2574 * @template {Record<string,import('../types').ActionCreator>} Actions 2575 * @template Selectors 2576 */ 2577 2578 const trimUndefinedValues = array => { 2579 const result = [...array]; 2580 for (let i = result.length - 1; i >= 0; i--) { 2581 if (result[i] === undefined) { 2582 result.splice(i, 1); 2583 } 2584 } 2585 return result; 2586 }; 2587 2588 /** 2589 * Creates a new object with the same keys, but with `callback()` called as 2590 * a transformer function on each of the values. 2591 * 2592 * @param {Object} obj The object to transform. 2593 * @param {Function} callback The function to transform each object value. 2594 * @return {Array} Transformed object. 2595 */ 2596 const mapValues = (obj, callback) => Object.fromEntries(Object.entries(obj !== null && obj !== void 0 ? obj : {}).map(([key, value]) => [key, callback(value, key)])); 2597 2598 // Convert non serializable types to plain objects 2599 const devToolsReplacer = (key, state) => { 2600 if (state instanceof Map) { 2601 return Object.fromEntries(state); 2602 } 2603 if (state instanceof window.HTMLElement) { 2604 return null; 2605 } 2606 return state; 2607 }; 2608 2609 /** 2610 * Create a cache to track whether resolvers started running or not. 2611 * 2612 * @return {Object} Resolvers Cache. 2613 */ 2614 function createResolversCache() { 2615 const cache = {}; 2616 return { 2617 isRunning(selectorName, args) { 2618 return cache[selectorName] && cache[selectorName].get(trimUndefinedValues(args)); 2619 }, 2620 clear(selectorName, args) { 2621 if (cache[selectorName]) { 2622 cache[selectorName].delete(trimUndefinedValues(args)); 2623 } 2624 }, 2625 markAsRunning(selectorName, args) { 2626 if (!cache[selectorName]) { 2627 cache[selectorName] = new (equivalent_key_map_default())(); 2628 } 2629 cache[selectorName].set(trimUndefinedValues(args), true); 2630 } 2631 }; 2632 } 2633 function createBindingCache(bind) { 2634 const cache = new WeakMap(); 2635 return { 2636 get(item, itemName) { 2637 let boundItem = cache.get(item); 2638 if (!boundItem) { 2639 boundItem = bind(item, itemName); 2640 cache.set(item, boundItem); 2641 } 2642 return boundItem; 2643 } 2644 }; 2645 } 2646 2647 /** 2648 * Creates a data store descriptor for the provided Redux store configuration containing 2649 * properties describing reducer, actions, selectors, controls and resolvers. 2650 * 2651 * @example 2652 * ```js 2653 * import { createReduxStore } from '@wordpress/data'; 2654 * 2655 * const store = createReduxStore( 'demo', { 2656 * reducer: ( state = 'OK' ) => state, 2657 * selectors: { 2658 * getValue: ( state ) => state, 2659 * }, 2660 * } ); 2661 * ``` 2662 * 2663 * @template State 2664 * @template {Record<string,import('../types').ActionCreator>} Actions 2665 * @template Selectors 2666 * @param {string} key Unique namespace identifier. 2667 * @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties 2668 * describing reducer, actions, selectors, 2669 * and resolvers. 2670 * 2671 * @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object. 2672 */ 2673 function createReduxStore(key, options) { 2674 const privateActions = {}; 2675 const privateSelectors = {}; 2676 const privateRegistrationFunctions = { 2677 privateActions, 2678 registerPrivateActions: actions => { 2679 Object.assign(privateActions, actions); 2680 }, 2681 privateSelectors, 2682 registerPrivateSelectors: selectors => { 2683 Object.assign(privateSelectors, selectors); 2684 } 2685 }; 2686 const storeDescriptor = { 2687 name: key, 2688 instantiate: registry => { 2689 /** 2690 * Stores listener functions registered with `subscribe()`. 2691 * 2692 * When functions register to listen to store changes with 2693 * `subscribe()` they get added here. Although Redux offers 2694 * its own `subscribe()` function directly, by wrapping the 2695 * subscription in this store instance it's possible to 2696 * optimize checking if the state has changed before calling 2697 * each listener. 2698 * 2699 * @type {Set<ListenerFunction>} 2700 */ 2701 const listeners = new Set(); 2702 const reducer = options.reducer; 2703 const thunkArgs = { 2704 registry, 2705 get dispatch() { 2706 return thunkActions; 2707 }, 2708 get select() { 2709 return thunkSelectors; 2710 }, 2711 get resolveSelect() { 2712 return getResolveSelectors(); 2713 } 2714 }; 2715 const store = instantiateReduxStore(key, options, registry, thunkArgs); 2716 // Expose the private registration functions on the store 2717 // so they can be copied to a sub registry in registry.js. 2718 lock(store, privateRegistrationFunctions); 2719 const resolversCache = createResolversCache(); 2720 function bindAction(action) { 2721 return (...args) => Promise.resolve(store.dispatch(action(...args))); 2722 } 2723 const actions = { 2724 ...mapValues(actions_namespaceObject, bindAction), 2725 ...mapValues(options.actions, bindAction) 2726 }; 2727 const boundPrivateActions = createBindingCache(bindAction); 2728 const allActions = new Proxy(() => {}, { 2729 get: (target, prop) => { 2730 const privateAction = privateActions[prop]; 2731 return privateAction ? boundPrivateActions.get(privateAction, prop) : actions[prop]; 2732 } 2733 }); 2734 const thunkActions = new Proxy(allActions, { 2735 apply: (target, thisArg, [action]) => store.dispatch(action) 2736 }); 2737 lock(actions, allActions); 2738 const resolvers = options.resolvers ? mapResolvers(options.resolvers) : {}; 2739 function bindSelector(selector, selectorName) { 2740 if (selector.isRegistrySelector) { 2741 selector.registry = registry; 2742 } 2743 const boundSelector = (...args) => { 2744 args = normalize(selector, args); 2745 const state = store.__unstableOriginalGetState(); 2746 // Before calling the selector, switch to the correct 2747 // registry. 2748 if (selector.isRegistrySelector) { 2749 selector.registry = registry; 2750 } 2751 return selector(state.root, ...args); 2752 }; 2753 2754 // Expose normalization method on the bound selector 2755 // in order that it can be called when fullfilling 2756 // the resolver. 2757 boundSelector.__unstableNormalizeArgs = selector.__unstableNormalizeArgs; 2758 const resolver = resolvers[selectorName]; 2759 if (!resolver) { 2760 boundSelector.hasResolver = false; 2761 return boundSelector; 2762 } 2763 return mapSelectorWithResolver(boundSelector, selectorName, resolver, store, resolversCache); 2764 } 2765 function bindMetadataSelector(metaDataSelector) { 2766 const boundSelector = (...args) => { 2767 const state = store.__unstableOriginalGetState(); 2768 const originalSelectorName = args && args[0]; 2769 const originalSelectorArgs = args && args[1]; 2770 const targetSelector = options?.selectors?.[originalSelectorName]; 2771 2772 // Normalize the arguments passed to the target selector. 2773 if (originalSelectorName && targetSelector) { 2774 args[1] = normalize(targetSelector, originalSelectorArgs); 2775 } 2776 return metaDataSelector(state.metadata, ...args); 2777 }; 2778 boundSelector.hasResolver = false; 2779 return boundSelector; 2780 } 2781 const selectors = { 2782 ...mapValues(selectors_namespaceObject, bindMetadataSelector), 2783 ...mapValues(options.selectors, bindSelector) 2784 }; 2785 const boundPrivateSelectors = createBindingCache(bindSelector); 2786 2787 // Pre-bind the private selectors that have been registered by the time of 2788 // instantiation, so that registry selectors are bound to the registry. 2789 for (const [selectorName, selector] of Object.entries(privateSelectors)) { 2790 boundPrivateSelectors.get(selector, selectorName); 2791 } 2792 const allSelectors = new Proxy(() => {}, { 2793 get: (target, prop) => { 2794 const privateSelector = privateSelectors[prop]; 2795 return privateSelector ? boundPrivateSelectors.get(privateSelector, prop) : selectors[prop]; 2796 } 2797 }); 2798 const thunkSelectors = new Proxy(allSelectors, { 2799 apply: (target, thisArg, [selector]) => selector(store.__unstableOriginalGetState()) 2800 }); 2801 lock(selectors, allSelectors); 2802 const resolveSelectors = mapResolveSelectors(selectors, store); 2803 const suspendSelectors = mapSuspendSelectors(selectors, store); 2804 const getSelectors = () => selectors; 2805 const getActions = () => actions; 2806 const getResolveSelectors = () => resolveSelectors; 2807 const getSuspendSelectors = () => suspendSelectors; 2808 2809 // We have some modules monkey-patching the store object 2810 // It's wrong to do so but until we refactor all of our effects to controls 2811 // We need to keep the same "store" instance here. 2812 store.__unstableOriginalGetState = store.getState; 2813 store.getState = () => store.__unstableOriginalGetState().root; 2814 2815 // Customize subscribe behavior to call listeners only on effective change, 2816 // not on every dispatch. 2817 const subscribe = store && (listener => { 2818 listeners.add(listener); 2819 return () => listeners.delete(listener); 2820 }); 2821 let lastState = store.__unstableOriginalGetState(); 2822 store.subscribe(() => { 2823 const state = store.__unstableOriginalGetState(); 2824 const hasChanged = state !== lastState; 2825 lastState = state; 2826 if (hasChanged) { 2827 for (const listener of listeners) { 2828 listener(); 2829 } 2830 } 2831 }); 2832 2833 // This can be simplified to just { subscribe, getSelectors, getActions } 2834 // Once we remove the use function. 2835 return { 2836 reducer, 2837 store, 2838 actions, 2839 selectors, 2840 resolvers, 2841 getSelectors, 2842 getResolveSelectors, 2843 getSuspendSelectors, 2844 getActions, 2845 subscribe 2846 }; 2847 } 2848 }; 2849 2850 // Expose the private registration functions on the store 2851 // descriptor. That's a natural choice since that's where the 2852 // public actions and selectors are stored . 2853 lock(storeDescriptor, privateRegistrationFunctions); 2854 return storeDescriptor; 2855 } 2856 2857 /** 2858 * Creates a redux store for a namespace. 2859 * 2860 * @param {string} key Unique namespace identifier. 2861 * @param {Object} options Registered store options, with properties 2862 * describing reducer, actions, selectors, 2863 * and resolvers. 2864 * @param {DataRegistry} registry Registry reference. 2865 * @param {Object} thunkArgs Argument object for the thunk middleware. 2866 * @return {Object} Newly created redux store. 2867 */ 2868 function instantiateReduxStore(key, options, registry, thunkArgs) { 2869 const controls = { 2870 ...options.controls, 2871 ...builtinControls 2872 }; 2873 const normalizedControls = mapValues(controls, control => control.isRegistryControl ? control(registry) : control); 2874 const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls), createThunkMiddleware(thunkArgs)]; 2875 const enhancers = [applyMiddleware(...middlewares)]; 2876 if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) { 2877 enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({ 2878 name: key, 2879 instanceId: key, 2880 serialize: { 2881 replacer: devToolsReplacer 2882 } 2883 })); 2884 } 2885 const { 2886 reducer, 2887 initialState 2888 } = options; 2889 const enhancedReducer = combine_reducers_combineReducers({ 2890 metadata: metadata_reducer, 2891 root: reducer 2892 }); 2893 return createStore(enhancedReducer, { 2894 root: initialState 2895 }, (0,external_wp_compose_namespaceObject.compose)(enhancers)); 2896 } 2897 2898 /** 2899 * Maps selectors to functions that return a resolution promise for them 2900 * 2901 * @param {Object} selectors Selectors to map. 2902 * @param {Object} store The redux store the selectors select from. 2903 * 2904 * @return {Object} Selectors mapped to their resolution functions. 2905 */ 2906 function mapResolveSelectors(selectors, store) { 2907 const { 2908 getIsResolving, 2909 hasStartedResolution, 2910 hasFinishedResolution, 2911 hasResolutionFailed, 2912 isResolving, 2913 getCachedResolvers, 2914 getResolutionState, 2915 getResolutionError, 2916 hasResolvingSelectors, 2917 countSelectorsByStatus, 2918 ...storeSelectors 2919 } = selectors; 2920 return mapValues(storeSelectors, (selector, selectorName) => { 2921 // If the selector doesn't have a resolver, just convert the return value 2922 // (including exceptions) to a Promise, no additional extra behavior is needed. 2923 if (!selector.hasResolver) { 2924 return async (...args) => selector.apply(null, args); 2925 } 2926 return (...args) => { 2927 return new Promise((resolve, reject) => { 2928 const hasFinished = () => selectors.hasFinishedResolution(selectorName, args); 2929 const finalize = result => { 2930 const hasFailed = selectors.hasResolutionFailed(selectorName, args); 2931 if (hasFailed) { 2932 const error = selectors.getResolutionError(selectorName, args); 2933 reject(error); 2934 } else { 2935 resolve(result); 2936 } 2937 }; 2938 const getResult = () => selector.apply(null, args); 2939 // Trigger the selector (to trigger the resolver) 2940 const result = getResult(); 2941 if (hasFinished()) { 2942 return finalize(result); 2943 } 2944 const unsubscribe = store.subscribe(() => { 2945 if (hasFinished()) { 2946 unsubscribe(); 2947 finalize(getResult()); 2948 } 2949 }); 2950 }); 2951 }; 2952 }); 2953 } 2954 2955 /** 2956 * Maps selectors to functions that throw a suspense promise if not yet resolved. 2957 * 2958 * @param {Object} selectors Selectors to map. 2959 * @param {Object} store The redux store the selectors select from. 2960 * 2961 * @return {Object} Selectors mapped to their suspense functions. 2962 */ 2963 function mapSuspendSelectors(selectors, store) { 2964 return mapValues(selectors, (selector, selectorName) => { 2965 // Selector without a resolver doesn't have any extra suspense behavior. 2966 if (!selector.hasResolver) { 2967 return selector; 2968 } 2969 return (...args) => { 2970 const result = selector.apply(null, args); 2971 if (selectors.hasFinishedResolution(selectorName, args)) { 2972 if (selectors.hasResolutionFailed(selectorName, args)) { 2973 throw selectors.getResolutionError(selectorName, args); 2974 } 2975 return result; 2976 } 2977 throw new Promise(resolve => { 2978 const unsubscribe = store.subscribe(() => { 2979 if (selectors.hasFinishedResolution(selectorName, args)) { 2980 resolve(); 2981 unsubscribe(); 2982 } 2983 }); 2984 }); 2985 }; 2986 }); 2987 } 2988 2989 /** 2990 * Convert resolvers to a normalized form, an object with `fulfill` method and 2991 * optional methods like `isFulfilled`. 2992 * 2993 * @param {Object} resolvers Resolver to convert 2994 */ 2995 function mapResolvers(resolvers) { 2996 return mapValues(resolvers, resolver => { 2997 if (resolver.fulfill) { 2998 return resolver; 2999 } 3000 return { 3001 ...resolver, 3002 // Copy the enumerable properties of the resolver function. 3003 fulfill: resolver // Add the fulfill method. 3004 }; 3005 }); 3006 } 3007 3008 /** 3009 * Returns a selector with a matched resolver. 3010 * Resolvers are side effects invoked once per argument set of a given selector call, 3011 * used in ensuring that the data needs for the selector are satisfied. 3012 * 3013 * @param {Object} selector The selector function to be bound. 3014 * @param {string} selectorName The selector name. 3015 * @param {Object} resolver Resolver to call. 3016 * @param {Object} store The redux store to which the resolvers should be mapped. 3017 * @param {Object} resolversCache Resolvers Cache. 3018 */ 3019 function mapSelectorWithResolver(selector, selectorName, resolver, store, resolversCache) { 3020 function fulfillSelector(args) { 3021 const state = store.getState(); 3022 if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) { 3023 return; 3024 } 3025 const { 3026 metadata 3027 } = store.__unstableOriginalGetState(); 3028 if (hasStartedResolution(metadata, selectorName, args)) { 3029 return; 3030 } 3031 resolversCache.markAsRunning(selectorName, args); 3032 setTimeout(async () => { 3033 resolversCache.clear(selectorName, args); 3034 store.dispatch(startResolution(selectorName, args)); 3035 try { 3036 const action = resolver.fulfill(...args); 3037 if (action) { 3038 await store.dispatch(action); 3039 } 3040 store.dispatch(finishResolution(selectorName, args)); 3041 } catch (error) { 3042 store.dispatch(failResolution(selectorName, args, error)); 3043 } 3044 }, 0); 3045 } 3046 const selectorResolver = (...args) => { 3047 args = normalize(selector, args); 3048 fulfillSelector(args); 3049 return selector(...args); 3050 }; 3051 selectorResolver.hasResolver = true; 3052 return selectorResolver; 3053 } 3054 3055 /** 3056 * Applies selector's normalization function to the given arguments 3057 * if it exists. 3058 * 3059 * @param {Object} selector The selector potentially with a normalization method property. 3060 * @param {Array} args selector arguments to normalize. 3061 * @return {Array} Potentially normalized arguments. 3062 */ 3063 function normalize(selector, args) { 3064 if (selector.__unstableNormalizeArgs && typeof selector.__unstableNormalizeArgs === 'function' && args?.length) { 3065 return selector.__unstableNormalizeArgs(args); 3066 } 3067 return args; 3068 } 3069 3070 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js 3071 const coreDataStore = { 3072 name: 'core/data', 3073 instantiate(registry) { 3074 const getCoreDataSelector = selectorName => (key, ...args) => { 3075 return registry.select(key)[selectorName](...args); 3076 }; 3077 const getCoreDataAction = actionName => (key, ...args) => { 3078 return registry.dispatch(key)[actionName](...args); 3079 }; 3080 return { 3081 getSelectors() { 3082 return Object.fromEntries(['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].map(selectorName => [selectorName, getCoreDataSelector(selectorName)])); 3083 }, 3084 getActions() { 3085 return Object.fromEntries(['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].map(actionName => [actionName, getCoreDataAction(actionName)])); 3086 }, 3087 subscribe() { 3088 // There's no reasons to trigger any listener when we subscribe to this store 3089 // because there's no state stored in this store that need to retrigger selectors 3090 // if a change happens, the corresponding store where the tracking stated live 3091 // would have already triggered a "subscribe" call. 3092 return () => () => {}; 3093 } 3094 }; 3095 } 3096 }; 3097 /* harmony default export */ const store = (coreDataStore); 3098 3099 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/utils/emitter.js 3100 /** 3101 * Create an event emitter. 3102 * 3103 * @return {import("../types").DataEmitter} Emitter. 3104 */ 3105 function createEmitter() { 3106 let isPaused = false; 3107 let isPending = false; 3108 const listeners = new Set(); 3109 const notifyListeners = () => 3110 // We use Array.from to clone the listeners Set 3111 // This ensures that we don't run a listener 3112 // that was added as a response to another listener. 3113 Array.from(listeners).forEach(listener => listener()); 3114 return { 3115 get isPaused() { 3116 return isPaused; 3117 }, 3118 subscribe(listener) { 3119 listeners.add(listener); 3120 return () => listeners.delete(listener); 3121 }, 3122 pause() { 3123 isPaused = true; 3124 }, 3125 resume() { 3126 isPaused = false; 3127 if (isPending) { 3128 isPending = false; 3129 notifyListeners(); 3130 } 3131 }, 3132 emit() { 3133 if (isPaused) { 3134 isPending = true; 3135 return; 3136 } 3137 notifyListeners(); 3138 } 3139 }; 3140 } 3141 3142 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js 3143 /** 3144 * WordPress dependencies 3145 */ 3146 3147 3148 /** 3149 * Internal dependencies 3150 */ 3151 3152 3153 3154 3155 3156 /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ 3157 3158 /** 3159 * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations. 3160 * 3161 * @property {Function} registerGenericStore Given a namespace key and settings 3162 * object, registers a new generic 3163 * store. 3164 * @property {Function} registerStore Given a namespace key and settings 3165 * object, registers a new namespace 3166 * store. 3167 * @property {Function} subscribe Given a function callback, invokes 3168 * the callback on any change to state 3169 * within any registered store. 3170 * @property {Function} select Given a namespace key, returns an 3171 * object of the store's registered 3172 * selectors. 3173 * @property {Function} dispatch Given a namespace key, returns an 3174 * object of the store's registered 3175 * action dispatchers. 3176 */ 3177 3178 /** 3179 * @typedef {Object} WPDataPlugin An object of registry function overrides. 3180 * 3181 * @property {Function} registerStore registers store. 3182 */ 3183 3184 function getStoreName(storeNameOrDescriptor) { 3185 return typeof storeNameOrDescriptor === 'string' ? storeNameOrDescriptor : storeNameOrDescriptor.name; 3186 } 3187 /** 3188 * Creates a new store registry, given an optional object of initial store 3189 * configurations. 3190 * 3191 * @param {Object} storeConfigs Initial store configurations. 3192 * @param {Object?} parent Parent registry. 3193 * 3194 * @return {WPDataRegistry} Data registry. 3195 */ 3196 function createRegistry(storeConfigs = {}, parent = null) { 3197 const stores = {}; 3198 const emitter = createEmitter(); 3199 let listeningStores = null; 3200 3201 /** 3202 * Global listener called for each store's update. 3203 */ 3204 function globalListener() { 3205 emitter.emit(); 3206 } 3207 3208 /** 3209 * Subscribe to changes to any data, either in all stores in registry, or 3210 * in one specific store. 3211 * 3212 * @param {Function} listener Listener function. 3213 * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name. 3214 * 3215 * @return {Function} Unsubscribe function. 3216 */ 3217 const subscribe = (listener, storeNameOrDescriptor) => { 3218 // subscribe to all stores 3219 if (!storeNameOrDescriptor) { 3220 return emitter.subscribe(listener); 3221 } 3222 3223 // subscribe to one store 3224 const storeName = getStoreName(storeNameOrDescriptor); 3225 const store = stores[storeName]; 3226 if (store) { 3227 return store.subscribe(listener); 3228 } 3229 3230 // Trying to access a store that hasn't been registered, 3231 // this is a pattern rarely used but seen in some places. 3232 // We fallback to global `subscribe` here for backward-compatibility for now. 3233 // See https://github.com/WordPress/gutenberg/pull/27466 for more info. 3234 if (!parent) { 3235 return emitter.subscribe(listener); 3236 } 3237 return parent.subscribe(listener, storeNameOrDescriptor); 3238 }; 3239 3240 /** 3241 * Calls a selector given the current state and extra arguments. 3242 * 3243 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store 3244 * or the store descriptor. 3245 * 3246 * @return {*} The selector's returned value. 3247 */ 3248 function select(storeNameOrDescriptor) { 3249 const storeName = getStoreName(storeNameOrDescriptor); 3250 listeningStores?.add(storeName); 3251 const store = stores[storeName]; 3252 if (store) { 3253 return store.getSelectors(); 3254 } 3255 return parent?.select(storeName); 3256 } 3257 function __unstableMarkListeningStores(callback, ref) { 3258 listeningStores = new Set(); 3259 try { 3260 return callback.call(this); 3261 } finally { 3262 ref.current = Array.from(listeningStores); 3263 listeningStores = null; 3264 } 3265 } 3266 3267 /** 3268 * Given a store descriptor, returns an object containing the store's selectors pre-bound to 3269 * state so that you only need to supply additional arguments, and modified so that they return 3270 * promises that resolve to their eventual values, after any resolvers have ran. 3271 * 3272 * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling 3273 * convention of passing the store name is 3274 * also supported. 3275 * 3276 * @return {Object} Each key of the object matches the name of a selector. 3277 */ 3278 function resolveSelect(storeNameOrDescriptor) { 3279 const storeName = getStoreName(storeNameOrDescriptor); 3280 listeningStores?.add(storeName); 3281 const store = stores[storeName]; 3282 if (store) { 3283 return store.getResolveSelectors(); 3284 } 3285 return parent && parent.resolveSelect(storeName); 3286 } 3287 3288 /** 3289 * Given a store descriptor, returns an object containing the store's selectors pre-bound to 3290 * state so that you only need to supply additional arguments, and modified so that they throw 3291 * promises in case the selector is not resolved yet. 3292 * 3293 * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling 3294 * convention of passing the store name is 3295 * also supported. 3296 * 3297 * @return {Object} Object containing the store's suspense-wrapped selectors. 3298 */ 3299 function suspendSelect(storeNameOrDescriptor) { 3300 const storeName = getStoreName(storeNameOrDescriptor); 3301 listeningStores?.add(storeName); 3302 const store = stores[storeName]; 3303 if (store) { 3304 return store.getSuspendSelectors(); 3305 } 3306 return parent && parent.suspendSelect(storeName); 3307 } 3308 3309 /** 3310 * Returns the available actions for a part of the state. 3311 * 3312 * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store 3313 * or the store descriptor. 3314 * 3315 * @return {*} The action's returned value. 3316 */ 3317 function dispatch(storeNameOrDescriptor) { 3318 const storeName = getStoreName(storeNameOrDescriptor); 3319 const store = stores[storeName]; 3320 if (store) { 3321 return store.getActions(); 3322 } 3323 return parent && parent.dispatch(storeName); 3324 } 3325 3326 // 3327 // Deprecated 3328 // TODO: Remove this after `use()` is removed. 3329 function withPlugins(attributes) { 3330 return Object.fromEntries(Object.entries(attributes).map(([key, attribute]) => { 3331 if (typeof attribute !== 'function') { 3332 return [key, attribute]; 3333 } 3334 return [key, function () { 3335 return registry[key].apply(null, arguments); 3336 }]; 3337 })); 3338 } 3339 3340 /** 3341 * Registers a store instance. 3342 * 3343 * @param {string} name Store registry name. 3344 * @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe). 3345 */ 3346 function registerStoreInstance(name, createStore) { 3347 if (stores[name]) { 3348 // eslint-disable-next-line no-console 3349 console.error('Store "' + name + '" is already registered.'); 3350 return stores[name]; 3351 } 3352 const store = createStore(); 3353 if (typeof store.getSelectors !== 'function') { 3354 throw new TypeError('store.getSelectors must be a function'); 3355 } 3356 if (typeof store.getActions !== 'function') { 3357 throw new TypeError('store.getActions must be a function'); 3358 } 3359 if (typeof store.subscribe !== 'function') { 3360 throw new TypeError('store.subscribe must be a function'); 3361 } 3362 // The emitter is used to keep track of active listeners when the registry 3363 // get paused, that way, when resumed we should be able to call all these 3364 // pending listeners. 3365 store.emitter = createEmitter(); 3366 const currentSubscribe = store.subscribe; 3367 store.subscribe = listener => { 3368 const unsubscribeFromEmitter = store.emitter.subscribe(listener); 3369 const unsubscribeFromStore = currentSubscribe(() => { 3370 if (store.emitter.isPaused) { 3371 store.emitter.emit(); 3372 return; 3373 } 3374 listener(); 3375 }); 3376 return () => { 3377 unsubscribeFromStore?.(); 3378 unsubscribeFromEmitter?.(); 3379 }; 3380 }; 3381 stores[name] = store; 3382 store.subscribe(globalListener); 3383 3384 // Copy private actions and selectors from the parent store. 3385 if (parent) { 3386 try { 3387 unlock(store.store).registerPrivateActions(unlock(parent).privateActionsOf(name)); 3388 unlock(store.store).registerPrivateSelectors(unlock(parent).privateSelectorsOf(name)); 3389 } catch (e) { 3390 // unlock() throws if store.store was not locked. 3391 // The error indicates there's nothing to do here so let's 3392 // ignore it. 3393 } 3394 } 3395 return store; 3396 } 3397 3398 /** 3399 * Registers a new store given a store descriptor. 3400 * 3401 * @param {StoreDescriptor} store Store descriptor. 3402 */ 3403 function register(store) { 3404 registerStoreInstance(store.name, () => store.instantiate(registry)); 3405 } 3406 function registerGenericStore(name, store) { 3407 external_wp_deprecated_default()('wp.data.registerGenericStore', { 3408 since: '5.9', 3409 alternative: 'wp.data.register( storeDescriptor )' 3410 }); 3411 registerStoreInstance(name, () => store); 3412 } 3413 3414 /** 3415 * Registers a standard `@wordpress/data` store. 3416 * 3417 * @param {string} storeName Unique namespace identifier. 3418 * @param {Object} options Store description (reducer, actions, selectors, resolvers). 3419 * 3420 * @return {Object} Registered store object. 3421 */ 3422 function registerStore(storeName, options) { 3423 if (!options.reducer) { 3424 throw new TypeError('Must specify store reducer'); 3425 } 3426 const store = registerStoreInstance(storeName, () => createReduxStore(storeName, options).instantiate(registry)); 3427 return store.store; 3428 } 3429 function batch(callback) { 3430 // If we're already batching, just call the callback. 3431 if (emitter.isPaused) { 3432 callback(); 3433 return; 3434 } 3435 emitter.pause(); 3436 Object.values(stores).forEach(store => store.emitter.pause()); 3437 try { 3438 callback(); 3439 } finally { 3440 emitter.resume(); 3441 Object.values(stores).forEach(store => store.emitter.resume()); 3442 } 3443 } 3444 let registry = { 3445 batch, 3446 stores, 3447 namespaces: stores, 3448 // TODO: Deprecate/remove this. 3449 subscribe, 3450 select, 3451 resolveSelect, 3452 suspendSelect, 3453 dispatch, 3454 use, 3455 register, 3456 registerGenericStore, 3457 registerStore, 3458 __unstableMarkListeningStores 3459 }; 3460 3461 // 3462 // TODO: 3463 // This function will be deprecated as soon as it is no longer internally referenced. 3464 function use(plugin, options) { 3465 if (!plugin) { 3466 return; 3467 } 3468 registry = { 3469 ...registry, 3470 ...plugin(registry, options) 3471 }; 3472 return registry; 3473 } 3474 registry.register(store); 3475 for (const [name, config] of Object.entries(storeConfigs)) { 3476 registry.register(createReduxStore(name, config)); 3477 } 3478 if (parent) { 3479 parent.subscribe(globalListener); 3480 } 3481 const registryWithPlugins = withPlugins(registry); 3482 lock(registryWithPlugins, { 3483 privateActionsOf: name => { 3484 try { 3485 return unlock(stores[name].store).privateActions; 3486 } catch (e) { 3487 // unlock() throws an error the store was not locked – this means 3488 // there no private actions are available 3489 return {}; 3490 } 3491 }, 3492 privateSelectorsOf: name => { 3493 try { 3494 return unlock(stores[name].store).privateSelectors; 3495 } catch (e) { 3496 return {}; 3497 } 3498 } 3499 }); 3500 return registryWithPlugins; 3501 } 3502 3503 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js 3504 /** 3505 * Internal dependencies 3506 */ 3507 3508 /* harmony default export */ const default_registry = (createRegistry()); 3509 3510 ;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs 3511 /*! 3512 * is-plain-object <https://github.com/jonschlinkert/is-plain-object> 3513 * 3514 * Copyright (c) 2014-2017, Jon Schlinkert. 3515 * Released under the MIT License. 3516 */ 3517 3518 function is_plain_object_isObject(o) { 3519 return Object.prototype.toString.call(o) === '[object Object]'; 3520 } 3521 3522 function is_plain_object_isPlainObject(o) { 3523 var ctor,prot; 3524 3525 if (is_plain_object_isObject(o) === false) return false; 3526 3527 // If has modified constructor 3528 ctor = o.constructor; 3529 if (ctor === undefined) return true; 3530 3531 // If has modified prototype 3532 prot = ctor.prototype; 3533 if (is_plain_object_isObject(prot) === false) return false; 3534 3535 // If constructor does not have an Object-specific method 3536 if (prot.hasOwnProperty('isPrototypeOf') === false) { 3537 return false; 3538 } 3539 3540 // Most likely a plain Object 3541 return true; 3542 } 3543 3544 3545 3546 // EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js 3547 var cjs = __webpack_require__(66); 3548 var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs); 3549 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js 3550 let objectStorage; 3551 const storage = { 3552 getItem(key) { 3553 if (!objectStorage || !objectStorage[key]) { 3554 return null; 3555 } 3556 return objectStorage[key]; 3557 }, 3558 setItem(key, value) { 3559 if (!objectStorage) { 3560 storage.clear(); 3561 } 3562 objectStorage[key] = String(value); 3563 }, 3564 clear() { 3565 objectStorage = Object.create(null); 3566 } 3567 }; 3568 /* harmony default export */ const object = (storage); 3569 3570 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js 3571 /** 3572 * Internal dependencies 3573 */ 3574 3575 let default_storage; 3576 try { 3577 // Private Browsing in Safari 10 and earlier will throw an error when 3578 // attempting to set into localStorage. The test here is intentional in 3579 // causing a thrown error as condition for using fallback object storage. 3580 default_storage = window.localStorage; 3581 default_storage.setItem('__wpDataTestLocalStorage', ''); 3582 default_storage.removeItem('__wpDataTestLocalStorage'); 3583 } catch (error) { 3584 default_storage = object; 3585 } 3586 /* harmony default export */ const storage_default = (default_storage); 3587 3588 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js 3589 /** 3590 * External dependencies 3591 */ 3592 3593 3594 3595 /** 3596 * Internal dependencies 3597 */ 3598 3599 3600 3601 /** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */ 3602 3603 /** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */ 3604 3605 /** 3606 * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options. 3607 * 3608 * @property {Storage} storage Persistent storage implementation. This must 3609 * at least implement `getItem` and `setItem` of 3610 * the Web Storage API. 3611 * @property {string} storageKey Key on which to set in persistent storage. 3612 */ 3613 3614 /** 3615 * Default plugin storage. 3616 * 3617 * @type {Storage} 3618 */ 3619 const DEFAULT_STORAGE = storage_default; 3620 3621 /** 3622 * Default plugin storage key. 3623 * 3624 * @type {string} 3625 */ 3626 const DEFAULT_STORAGE_KEY = 'WP_DATA'; 3627 3628 /** 3629 * Higher-order reducer which invokes the original reducer only if state is 3630 * inequal from that of the action's `nextState` property, otherwise returning 3631 * the original state reference. 3632 * 3633 * @param {Function} reducer Original reducer. 3634 * 3635 * @return {Function} Enhanced reducer. 3636 */ 3637 const withLazySameState = reducer => (state, action) => { 3638 if (action.nextState === state) { 3639 return state; 3640 } 3641 return reducer(state, action); 3642 }; 3643 3644 /** 3645 * Creates a persistence interface, exposing getter and setter methods (`get` 3646 * and `set` respectively). 3647 * 3648 * @param {WPDataPersistencePluginOptions} options Plugin options. 3649 * 3650 * @return {Object} Persistence interface. 3651 */ 3652 function createPersistenceInterface(options) { 3653 const { 3654 storage = DEFAULT_STORAGE, 3655 storageKey = DEFAULT_STORAGE_KEY 3656 } = options; 3657 let data; 3658 3659 /** 3660 * Returns the persisted data as an object, defaulting to an empty object. 3661 * 3662 * @return {Object} Persisted data. 3663 */ 3664 function getData() { 3665 if (data === undefined) { 3666 // If unset, getItem is expected to return null. Fall back to 3667 // empty object. 3668 const persisted = storage.getItem(storageKey); 3669 if (persisted === null) { 3670 data = {}; 3671 } else { 3672 try { 3673 data = JSON.parse(persisted); 3674 } catch (error) { 3675 // Similarly, should any error be thrown during parse of 3676 // the string (malformed JSON), fall back to empty object. 3677 data = {}; 3678 } 3679 } 3680 } 3681 return data; 3682 } 3683 3684 /** 3685 * Merges an updated reducer state into the persisted data. 3686 * 3687 * @param {string} key Key to update. 3688 * @param {*} value Updated value. 3689 */ 3690 function setData(key, value) { 3691 data = { 3692 ...data, 3693 [key]: value 3694 }; 3695 storage.setItem(storageKey, JSON.stringify(data)); 3696 } 3697 return { 3698 get: getData, 3699 set: setData 3700 }; 3701 } 3702 3703 /** 3704 * Data plugin to persist store state into a single storage key. 3705 * 3706 * @param {WPDataRegistry} registry Data registry. 3707 * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options. 3708 * 3709 * @return {WPDataPlugin} Data plugin. 3710 */ 3711 function persistencePlugin(registry, pluginOptions) { 3712 const persistence = createPersistenceInterface(pluginOptions); 3713 3714 /** 3715 * Creates an enhanced store dispatch function, triggering the state of the 3716 * given store name to be persisted when changed. 3717 * 3718 * @param {Function} getState Function which returns current state. 3719 * @param {string} storeName Store name. 3720 * @param {?Array<string>} keys Optional subset of keys to save. 3721 * 3722 * @return {Function} Enhanced dispatch function. 3723 */ 3724 function createPersistOnChange(getState, storeName, keys) { 3725 let getPersistedState; 3726 if (Array.isArray(keys)) { 3727 // Given keys, the persisted state should by produced as an object 3728 // of the subset of keys. This implementation uses combineReducers 3729 // to leverage its behavior of returning the same object when none 3730 // of the property values changes. This allows a strict reference 3731 // equality to bypass a persistence set on an unchanging state. 3732 const reducers = keys.reduce((accumulator, key) => Object.assign(accumulator, { 3733 [key]: (state, action) => action.nextState[key] 3734 }), {}); 3735 getPersistedState = withLazySameState(build_module_combineReducers(reducers)); 3736 } else { 3737 getPersistedState = (state, action) => action.nextState; 3738 } 3739 let lastState = getPersistedState(undefined, { 3740 nextState: getState() 3741 }); 3742 return () => { 3743 const state = getPersistedState(lastState, { 3744 nextState: getState() 3745 }); 3746 if (state !== lastState) { 3747 persistence.set(storeName, state); 3748 lastState = state; 3749 } 3750 }; 3751 } 3752 return { 3753 registerStore(storeName, options) { 3754 if (!options.persist) { 3755 return registry.registerStore(storeName, options); 3756 } 3757 3758 // Load from persistence to use as initial state. 3759 const persistedState = persistence.get()[storeName]; 3760 if (persistedState !== undefined) { 3761 let initialState = options.reducer(options.initialState, { 3762 type: '@@WP/PERSISTENCE_RESTORE' 3763 }); 3764 if (is_plain_object_isPlainObject(initialState) && is_plain_object_isPlainObject(persistedState)) { 3765 // If state is an object, ensure that: 3766 // - Other keys are left intact when persisting only a 3767 // subset of keys. 3768 // - New keys in what would otherwise be used as initial 3769 // state are deeply merged as base for persisted value. 3770 initialState = cjs_default()(initialState, persistedState, { 3771 isMergeableObject: is_plain_object_isPlainObject 3772 }); 3773 } else { 3774 // If there is a mismatch in object-likeness of default 3775 // initial or persisted state, defer to persisted value. 3776 initialState = persistedState; 3777 } 3778 options = { 3779 ...options, 3780 initialState 3781 }; 3782 } 3783 const store = registry.registerStore(storeName, options); 3784 store.subscribe(createPersistOnChange(store.getState, storeName, options.persist)); 3785 return store; 3786 } 3787 }; 3788 } 3789 persistencePlugin.__unstableMigrate = () => {}; 3790 /* harmony default export */ const persistence = (persistencePlugin); 3791 3792 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js 3793 3794 3795 ;// CONCATENATED MODULE: external ["wp","priorityQueue"] 3796 const external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"]; 3797 ;// CONCATENATED MODULE: external ["wp","element"] 3798 const external_wp_element_namespaceObject = window["wp"]["element"]; 3799 ;// CONCATENATED MODULE: external ["wp","isShallowEqual"] 3800 const external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; 3801 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); 3802 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js 3803 /** 3804 * WordPress dependencies 3805 */ 3806 3807 3808 /** 3809 * Internal dependencies 3810 */ 3811 3812 const Context = (0,external_wp_element_namespaceObject.createContext)(default_registry); 3813 const { 3814 Consumer, 3815 Provider 3816 } = Context; 3817 3818 /** 3819 * A custom react Context consumer exposing the provided `registry` to 3820 * children components. Used along with the RegistryProvider. 3821 * 3822 * You can read more about the react context api here: 3823 * https://react.dev/learn/passing-data-deeply-with-context#step-3-provide-the-context 3824 * 3825 * @example 3826 * ```js 3827 * import { 3828 * RegistryProvider, 3829 * RegistryConsumer, 3830 * createRegistry 3831 * } from '@wordpress/data'; 3832 * 3833 * const registry = createRegistry( {} ); 3834 * 3835 * const App = ( { props } ) => { 3836 * return <RegistryProvider value={ registry }> 3837 * <div>Hello There</div> 3838 * <RegistryConsumer> 3839 * { ( registry ) => ( 3840 * <ComponentUsingRegistry 3841 * { ...props } 3842 * registry={ registry } 3843 * ) } 3844 * </RegistryConsumer> 3845 * </RegistryProvider> 3846 * } 3847 * ``` 3848 */ 3849 const RegistryConsumer = Consumer; 3850 3851 /** 3852 * A custom Context provider for exposing the provided `registry` to children 3853 * components via a consumer. 3854 * 3855 * See <a name="#RegistryConsumer">RegistryConsumer</a> documentation for 3856 * example. 3857 */ 3858 /* harmony default export */ const context = (Provider); 3859 3860 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js 3861 /** 3862 * WordPress dependencies 3863 */ 3864 3865 3866 /** 3867 * Internal dependencies 3868 */ 3869 3870 3871 /** 3872 * A custom react hook exposing the registry context for use. 3873 * 3874 * This exposes the `registry` value provided via the 3875 * <a href="#RegistryProvider">Registry Provider</a> to a component implementing 3876 * this hook. 3877 * 3878 * It acts similarly to the `useContext` react hook. 3879 * 3880 * Note: Generally speaking, `useRegistry` is a low level hook that in most cases 3881 * won't be needed for implementation. Most interactions with the `@wordpress/data` 3882 * API can be performed via the `useSelect` hook, or the `withSelect` and 3883 * `withDispatch` higher order components. 3884 * 3885 * @example 3886 * ```js 3887 * import { 3888 * RegistryProvider, 3889 * createRegistry, 3890 * useRegistry, 3891 * } from '@wordpress/data'; 3892 * 3893 * const registry = createRegistry( {} ); 3894 * 3895 * const SomeChildUsingRegistry = ( props ) => { 3896 * const registry = useRegistry(); 3897 * // ...logic implementing the registry in other react hooks. 3898 * }; 3899 * 3900 * 3901 * const ParentProvidingRegistry = ( props ) => { 3902 * return <RegistryProvider value={ registry }> 3903 * <SomeChildUsingRegistry { ...props } /> 3904 * </RegistryProvider> 3905 * }; 3906 * ``` 3907 * 3908 * @return {Function} A custom react hook exposing the registry context value. 3909 */ 3910 function useRegistry() { 3911 return (0,external_wp_element_namespaceObject.useContext)(Context); 3912 } 3913 3914 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js 3915 /** 3916 * WordPress dependencies 3917 */ 3918 3919 const context_Context = (0,external_wp_element_namespaceObject.createContext)(false); 3920 const { 3921 Consumer: context_Consumer, 3922 Provider: context_Provider 3923 } = context_Context; 3924 const AsyncModeConsumer = (/* unused pure expression or super */ null && (context_Consumer)); 3925 3926 /** 3927 * Context Provider Component used to switch the data module component rerendering 3928 * between Sync and Async modes. 3929 * 3930 * @example 3931 * 3932 * ```js 3933 * import { useSelect, AsyncModeProvider } from '@wordpress/data'; 3934 * import { store as blockEditorStore } from '@wordpress/block-editor'; 3935 * 3936 * function BlockCount() { 3937 * const count = useSelect( ( select ) => { 3938 * return select( blockEditorStore ).getBlockCount() 3939 * }, [] ); 3940 * 3941 * return count; 3942 * } 3943 * 3944 * function App() { 3945 * return ( 3946 * <AsyncModeProvider value={ true }> 3947 * <BlockCount /> 3948 * </AsyncModeProvider> 3949 * ); 3950 * } 3951 * ``` 3952 * 3953 * In this example, the BlockCount component is rerendered asynchronously. 3954 * It means if a more critical task is being performed (like typing in an input), 3955 * the rerendering is delayed until the browser becomes IDLE. 3956 * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior. 3957 * 3958 * @param {boolean} props.value Enable Async Mode. 3959 * @return {Component} The component to be rendered. 3960 */ 3961 /* harmony default export */ const async_mode_provider_context = (context_Provider); 3962 3963 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js 3964 /** 3965 * WordPress dependencies 3966 */ 3967 3968 3969 /** 3970 * Internal dependencies 3971 */ 3972 3973 function useAsyncMode() { 3974 return (0,external_wp_element_namespaceObject.useContext)(context_Context); 3975 } 3976 3977 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js 3978 /** 3979 * WordPress dependencies 3980 */ 3981 3982 3983 3984 3985 /** 3986 * Internal dependencies 3987 */ 3988 3989 3990 const renderQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)(); 3991 3992 /** 3993 * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor 3994 * @template {import('../../types').AnyConfig} C 3995 */ 3996 /** 3997 * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig 3998 * @template State 3999 * @template {Record<string,import('../../types').ActionCreator>} Actions 4000 * @template Selectors 4001 */ 4002 /** @typedef {import('../../types').MapSelect} MapSelect */ 4003 /** 4004 * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn 4005 * @template {MapSelect|StoreDescriptor<any>} T 4006 */ 4007 4008 function Store(registry, suspense) { 4009 const select = suspense ? registry.suspendSelect : registry.select; 4010 const queueContext = {}; 4011 let lastMapSelect; 4012 let lastMapResult; 4013 let lastMapResultValid = false; 4014 let lastIsAsync; 4015 let subscriber; 4016 let didWarnUnstableReference; 4017 const storeStatesOnMount = new Map(); 4018 function getStoreState(name) { 4019 var _registry$stores$name; 4020 // If there's no store property (custom generic store), return an empty 4021 // object. When comparing the state, the empty objects will cause the 4022 // equality check to fail, setting `lastMapResultValid` to false. 4023 return (_registry$stores$name = registry.stores[name]?.store?.getState?.()) !== null && _registry$stores$name !== void 0 ? _registry$stores$name : {}; 4024 } 4025 const createSubscriber = stores => { 4026 // The set of stores the `subscribe` function is supposed to subscribe to. Here it is 4027 // initialized, and then the `updateStores` function can add new stores to it. 4028 const activeStores = [...stores]; 4029 4030 // The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could 4031 // be called multiple times to establish multiple subscriptions. That's why we need to 4032 // keep a set of active subscriptions; 4033 const activeSubscriptions = new Set(); 4034 function subscribe(listener) { 4035 // Maybe invalidate the value right after subscription was created. 4036 // React will call `getValue` after subscribing, to detect store 4037 // updates that happened in the interval between the `getValue` call 4038 // during render and creating the subscription, which is slightly 4039 // delayed. We need to ensure that this second `getValue` call will 4040 // compute a fresh value only if any of the store states have 4041 // changed in the meantime. 4042 if (lastMapResultValid) { 4043 for (const name of activeStores) { 4044 if (storeStatesOnMount.get(name) !== getStoreState(name)) { 4045 lastMapResultValid = false; 4046 } 4047 } 4048 } 4049 storeStatesOnMount.clear(); 4050 const onStoreChange = () => { 4051 // Invalidate the value on store update, so that a fresh value is computed. 4052 lastMapResultValid = false; 4053 listener(); 4054 }; 4055 const onChange = () => { 4056 if (lastIsAsync) { 4057 renderQueue.add(queueContext, onStoreChange); 4058 } else { 4059 onStoreChange(); 4060 } 4061 }; 4062 const unsubs = []; 4063 function subscribeStore(storeName) { 4064 unsubs.push(registry.subscribe(onChange, storeName)); 4065 } 4066 for (const storeName of activeStores) { 4067 subscribeStore(storeName); 4068 } 4069 activeSubscriptions.add(subscribeStore); 4070 return () => { 4071 activeSubscriptions.delete(subscribeStore); 4072 for (const unsub of unsubs.values()) { 4073 // The return value of the subscribe function could be undefined if the store is a custom generic store. 4074 unsub?.(); 4075 } 4076 // Cancel existing store updates that were already scheduled. 4077 renderQueue.cancel(queueContext); 4078 }; 4079 } 4080 4081 // Check if `newStores` contains some stores we're not subscribed to yet, and add them. 4082 function updateStores(newStores) { 4083 for (const newStore of newStores) { 4084 if (activeStores.includes(newStore)) { 4085 continue; 4086 } 4087 4088 // New `subscribe` calls will subscribe to `newStore`, too. 4089 activeStores.push(newStore); 4090 4091 // Add `newStore` to existing subscriptions. 4092 for (const subscription of activeSubscriptions) { 4093 subscription(newStore); 4094 } 4095 } 4096 } 4097 return { 4098 subscribe, 4099 updateStores 4100 }; 4101 }; 4102 return (mapSelect, isAsync) => { 4103 function updateValue() { 4104 // If the last value is valid, and the `mapSelect` callback hasn't changed, 4105 // then we can safely return the cached value. The value can change only on 4106 // store update, and in that case value will be invalidated by the listener. 4107 if (lastMapResultValid && mapSelect === lastMapSelect) { 4108 return lastMapResult; 4109 } 4110 const listeningStores = { 4111 current: null 4112 }; 4113 const mapResult = registry.__unstableMarkListeningStores(() => mapSelect(select, registry), listeningStores); 4114 if (false) {} 4115 if (!subscriber) { 4116 for (const name of listeningStores.current) { 4117 storeStatesOnMount.set(name, getStoreState(name)); 4118 } 4119 subscriber = createSubscriber(listeningStores.current); 4120 } else { 4121 subscriber.updateStores(listeningStores.current); 4122 } 4123 4124 // If the new value is shallow-equal to the old one, keep the old one so 4125 // that we don't trigger unwanted updates that do a `===` check. 4126 if (!external_wp_isShallowEqual_default()(lastMapResult, mapResult)) { 4127 lastMapResult = mapResult; 4128 } 4129 lastMapSelect = mapSelect; 4130 lastMapResultValid = true; 4131 } 4132 function getValue() { 4133 // Update the value in case it's been invalidated or `mapSelect` has changed. 4134 updateValue(); 4135 return lastMapResult; 4136 } 4137 4138 // When transitioning from async to sync mode, cancel existing store updates 4139 // that have been scheduled, and invalidate the value so that it's freshly 4140 // computed. It might have been changed by the update we just cancelled. 4141 if (lastIsAsync && !isAsync) { 4142 lastMapResultValid = false; 4143 renderQueue.cancel(queueContext); 4144 } 4145 updateValue(); 4146 lastIsAsync = isAsync; 4147 4148 // Return a pair of functions that can be passed to `useSyncExternalStore`. 4149 return { 4150 subscribe: subscriber.subscribe, 4151 getValue 4152 }; 4153 }; 4154 } 4155 function useStaticSelect(storeName) { 4156 return useRegistry().select(storeName); 4157 } 4158 function useMappingSelect(suspense, mapSelect, deps) { 4159 const registry = useRegistry(); 4160 const isAsync = useAsyncMode(); 4161 const store = (0,external_wp_element_namespaceObject.useMemo)(() => Store(registry, suspense), [registry, suspense]); 4162 4163 // These are "pass-through" dependencies from the parent hook, 4164 // and the parent should catch any hook rule violations. 4165 // eslint-disable-next-line react-hooks/exhaustive-deps 4166 const selector = (0,external_wp_element_namespaceObject.useCallback)(mapSelect, deps); 4167 const { 4168 subscribe, 4169 getValue 4170 } = store(selector, isAsync); 4171 const result = (0,external_wp_element_namespaceObject.useSyncExternalStore)(subscribe, getValue, getValue); 4172 (0,external_wp_element_namespaceObject.useDebugValue)(result); 4173 return result; 4174 } 4175 4176 /** 4177 * Custom react hook for retrieving props from registered selectors. 4178 * 4179 * In general, this custom React hook follows the 4180 * [rules of hooks](https://react.dev/reference/rules/rules-of-hooks). 4181 * 4182 * @template {MapSelect | StoreDescriptor<any>} T 4183 * @param {T} mapSelect Function called on every state change. The returned value is 4184 * exposed to the component implementing this hook. The function 4185 * receives the `registry.select` method on the first argument 4186 * and the `registry` on the second argument. 4187 * When a store key is passed, all selectors for the store will be 4188 * returned. This is only meant for usage of these selectors in event 4189 * callbacks, not for data needed to create the element tree. 4190 * @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is 4191 * invoked on every state change unless the dependencies change. 4192 * 4193 * @example 4194 * ```js 4195 * import { useSelect } from '@wordpress/data'; 4196 * import { store as myCustomStore } from 'my-custom-store'; 4197 * 4198 * function HammerPriceDisplay( { currency } ) { 4199 * const price = useSelect( ( select ) => { 4200 * return select( myCustomStore ).getPrice( 'hammer', currency ); 4201 * }, [ currency ] ); 4202 * return new Intl.NumberFormat( 'en-US', { 4203 * style: 'currency', 4204 * currency, 4205 * } ).format( price ); 4206 * } 4207 * 4208 * // Rendered in the application: 4209 * // <HammerPriceDisplay currency="USD" /> 4210 * ``` 4211 * 4212 * In the above example, when `HammerPriceDisplay` is rendered into an 4213 * application, the price will be retrieved from the store state using the 4214 * `mapSelect` callback on `useSelect`. If the currency prop changes then 4215 * any price in the state for that currency is retrieved. If the currency prop 4216 * doesn't change and other props are passed in that do change, the price will 4217 * not change because the dependency is just the currency. 4218 * 4219 * When data is only used in an event callback, the data should not be retrieved 4220 * on render, so it may be useful to get the selectors function instead. 4221 * 4222 * **Don't use `useSelect` this way when calling the selectors in the render 4223 * function because your component won't re-render on a data change.** 4224 * 4225 * ```js 4226 * import { useSelect } from '@wordpress/data'; 4227 * import { store as myCustomStore } from 'my-custom-store'; 4228 * 4229 * function Paste( { children } ) { 4230 * const { getSettings } = useSelect( myCustomStore ); 4231 * function onPaste() { 4232 * // Do something with the settings. 4233 * const settings = getSettings(); 4234 * } 4235 * return <div onPaste={ onPaste }>{ children }</div>; 4236 * } 4237 * ``` 4238 * @return {UseSelectReturn<T>} A custom react hook. 4239 */ 4240 function useSelect(mapSelect, deps) { 4241 // On initial call, on mount, determine the mode of this `useSelect` call 4242 // and then never allow it to change on subsequent updates. 4243 const staticSelectMode = typeof mapSelect !== 'function'; 4244 const staticSelectModeRef = (0,external_wp_element_namespaceObject.useRef)(staticSelectMode); 4245 if (staticSelectMode !== staticSelectModeRef.current) { 4246 const prevMode = staticSelectModeRef.current ? 'static' : 'mapping'; 4247 const nextMode = staticSelectMode ? 'static' : 'mapping'; 4248 throw new Error(`Switching useSelect from $prevMode} to $nextMode} is not allowed`); 4249 } 4250 4251 /* eslint-disable react-hooks/rules-of-hooks */ 4252 // `staticSelectMode` is not allowed to change during the hook instance's, 4253 // lifetime, so the rules of hooks are not really violated. 4254 return staticSelectMode ? useStaticSelect(mapSelect) : useMappingSelect(false, mapSelect, deps); 4255 /* eslint-enable react-hooks/rules-of-hooks */ 4256 } 4257 4258 /** 4259 * A variant of the `useSelect` hook that has the same API, but is a compatible 4260 * Suspense-enabled data source. 4261 * 4262 * @template {MapSelect} T 4263 * @param {T} mapSelect Function called on every state change. The 4264 * returned value is exposed to the component 4265 * using this hook. The function receives the 4266 * `registry.suspendSelect` method as the first 4267 * argument and the `registry` as the second one. 4268 * @param {Array} deps A dependency array used to memoize the `mapSelect` 4269 * so that the same `mapSelect` is invoked on every 4270 * state change unless the dependencies change. 4271 * 4272 * @throws {Promise} A suspense Promise that is thrown if any of the called 4273 * selectors is in an unresolved state. 4274 * 4275 * @return {ReturnType<T>} Data object returned by the `mapSelect` function. 4276 */ 4277 function useSuspenseSelect(mapSelect, deps) { 4278 return useMappingSelect(true, mapSelect, deps); 4279 } 4280 4281 ;// CONCATENATED MODULE: external "ReactJSXRuntime" 4282 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; 4283 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js 4284 /** 4285 * WordPress dependencies 4286 */ 4287 4288 4289 /** 4290 * Internal dependencies 4291 */ 4292 4293 4294 /** @typedef {import('react').ComponentType} ComponentType */ 4295 4296 /** 4297 * Higher-order component used to inject state-derived props using registered 4298 * selectors. 4299 * 4300 * @param {Function} mapSelectToProps Function called on every state change, 4301 * expected to return object of props to 4302 * merge with the component's own props. 4303 * 4304 * @example 4305 * ```js 4306 * import { withSelect } from '@wordpress/data'; 4307 * import { store as myCustomStore } from 'my-custom-store'; 4308 * 4309 * function PriceDisplay( { price, currency } ) { 4310 * return new Intl.NumberFormat( 'en-US', { 4311 * style: 'currency', 4312 * currency, 4313 * } ).format( price ); 4314 * } 4315 * 4316 * const HammerPriceDisplay = withSelect( ( select, ownProps ) => { 4317 * const { getPrice } = select( myCustomStore ); 4318 * const { currency } = ownProps; 4319 * 4320 * return { 4321 * price: getPrice( 'hammer', currency ), 4322 * }; 4323 * } )( PriceDisplay ); 4324 * 4325 * // Rendered in the application: 4326 * // 4327 * // <HammerPriceDisplay currency="USD" /> 4328 * ``` 4329 * In the above example, when `HammerPriceDisplay` is rendered into an 4330 * application, it will pass the price into the underlying `PriceDisplay` 4331 * component and update automatically if the price of a hammer ever changes in 4332 * the store. 4333 * 4334 * @return {ComponentType} Enhanced component with merged state data props. 4335 */ 4336 4337 const withSelect = mapSelectToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_compose_namespaceObject.pure)(ownProps => { 4338 const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry); 4339 const mergeProps = useSelect(mapSelect); 4340 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 4341 ...ownProps, 4342 ...mergeProps 4343 }); 4344 }), 'withSelect'); 4345 /* harmony default export */ const with_select = (withSelect); 4346 4347 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js 4348 /** 4349 * WordPress dependencies 4350 */ 4351 4352 4353 4354 /** 4355 * Internal dependencies 4356 */ 4357 4358 4359 /** 4360 * Custom react hook for returning aggregate dispatch actions using the provided 4361 * dispatchMap. 4362 * 4363 * Currently this is an internal api only and is implemented by `withDispatch` 4364 * 4365 * @param {Function} dispatchMap Receives the `registry.dispatch` function as 4366 * the first argument and the `registry` object 4367 * as the second argument. Should return an 4368 * object mapping props to functions. 4369 * @param {Array} deps An array of dependencies for the hook. 4370 * @return {Object} An object mapping props to functions created by the passed 4371 * in dispatchMap. 4372 */ 4373 const useDispatchWithMap = (dispatchMap, deps) => { 4374 const registry = useRegistry(); 4375 const currentDispatchMapRef = (0,external_wp_element_namespaceObject.useRef)(dispatchMap); 4376 (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => { 4377 currentDispatchMapRef.current = dispatchMap; 4378 }); 4379 return (0,external_wp_element_namespaceObject.useMemo)(() => { 4380 const currentDispatchProps = currentDispatchMapRef.current(registry.dispatch, registry); 4381 return Object.fromEntries(Object.entries(currentDispatchProps).map(([propName, dispatcher]) => { 4382 if (typeof dispatcher !== 'function') { 4383 // eslint-disable-next-line no-console 4384 console.warn(`Property $propName} returned from dispatchMap in useDispatchWithMap must be a function.`); 4385 } 4386 return [propName, (...args) => currentDispatchMapRef.current(registry.dispatch, registry)[propName](...args)]; 4387 })); 4388 }, [registry, ...deps]); 4389 }; 4390 /* harmony default export */ const use_dispatch_with_map = (useDispatchWithMap); 4391 4392 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js 4393 /** 4394 * WordPress dependencies 4395 */ 4396 4397 4398 /** 4399 * Internal dependencies 4400 */ 4401 4402 4403 /** @typedef {import('react').ComponentType} ComponentType */ 4404 4405 /** 4406 * Higher-order component used to add dispatch props using registered action 4407 * creators. 4408 * 4409 * @param {Function} mapDispatchToProps A function of returning an object of 4410 * prop names where value is a 4411 * dispatch-bound action creator, or a 4412 * function to be called with the 4413 * component's props and returning an 4414 * action creator. 4415 * 4416 * @example 4417 * ```jsx 4418 * function Button( { onClick, children } ) { 4419 * return <button type="button" onClick={ onClick }>{ children }</button>; 4420 * } 4421 * 4422 * import { withDispatch } from '@wordpress/data'; 4423 * import { store as myCustomStore } from 'my-custom-store'; 4424 * 4425 * const SaleButton = withDispatch( ( dispatch, ownProps ) => { 4426 * const { startSale } = dispatch( myCustomStore ); 4427 * const { discountPercent } = ownProps; 4428 * 4429 * return { 4430 * onClick() { 4431 * startSale( discountPercent ); 4432 * }, 4433 * }; 4434 * } )( Button ); 4435 * 4436 * // Rendered in the application: 4437 * // 4438 * // <SaleButton discountPercent="20">Start Sale!</SaleButton> 4439 * ``` 4440 * 4441 * @example 4442 * In the majority of cases, it will be sufficient to use only two first params 4443 * passed to `mapDispatchToProps` as illustrated in the previous example. 4444 * However, there might be some very advanced use cases where using the 4445 * `registry` object might be used as a tool to optimize the performance of 4446 * your component. Using `select` function from the registry might be useful 4447 * when you need to fetch some dynamic data from the store at the time when the 4448 * event is fired, but at the same time, you never use it to render your 4449 * component. In such scenario, you can avoid using the `withSelect` higher 4450 * order component to compute such prop, which might lead to unnecessary 4451 * re-renders of your component caused by its frequent value change. 4452 * Keep in mind, that `mapDispatchToProps` must return an object with functions 4453 * only. 4454 * 4455 * ```jsx 4456 * function Button( { onClick, children } ) { 4457 * return <button type="button" onClick={ onClick }>{ children }</button>; 4458 * } 4459 * 4460 * import { withDispatch } from '@wordpress/data'; 4461 * import { store as myCustomStore } from 'my-custom-store'; 4462 * 4463 * const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => { 4464 * // Stock number changes frequently. 4465 * const { getStockNumber } = select( myCustomStore ); 4466 * const { startSale } = dispatch( myCustomStore ); 4467 * return { 4468 * onClick() { 4469 * const discountPercent = getStockNumber() > 50 ? 10 : 20; 4470 * startSale( discountPercent ); 4471 * }, 4472 * }; 4473 * } )( Button ); 4474 * 4475 * // Rendered in the application: 4476 * // 4477 * // <SaleButton>Start Sale!</SaleButton> 4478 * ``` 4479 * 4480 * _Note:_ It is important that the `mapDispatchToProps` function always 4481 * returns an object with the same keys. For example, it should not contain 4482 * conditions under which a different value would be returned. 4483 * 4484 * @return {ComponentType} Enhanced component with merged dispatcher props. 4485 */ 4486 4487 const withDispatch = mapDispatchToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ownProps => { 4488 const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry); 4489 const dispatchProps = use_dispatch_with_map(mapDispatch, []); 4490 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 4491 ...ownProps, 4492 ...dispatchProps 4493 }); 4494 }, 'withDispatch'); 4495 /* harmony default export */ const with_dispatch = (withDispatch); 4496 4497 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js 4498 /** 4499 * WordPress dependencies 4500 */ 4501 4502 4503 /** 4504 * Internal dependencies 4505 */ 4506 4507 4508 /** 4509 * Higher-order component which renders the original component with the current 4510 * registry context passed as its `registry` prop. 4511 * 4512 * @param {Component} OriginalComponent Original component. 4513 * 4514 * @return {Component} Enhanced component. 4515 */ 4516 4517 const withRegistry = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => props => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RegistryConsumer, { 4518 children: registry => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OriginalComponent, { 4519 ...props, 4520 registry: registry 4521 }) 4522 }), 'withRegistry'); 4523 /* harmony default export */ const with_registry = (withRegistry); 4524 4525 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js 4526 /** 4527 * Internal dependencies 4528 */ 4529 4530 4531 /** 4532 * @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor 4533 * @template {import('../../types').AnyConfig} StoreConfig 4534 */ 4535 /** 4536 * @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn 4537 * @template StoreNameOrDescriptor 4538 */ 4539 4540 /** 4541 * A custom react hook returning the current registry dispatch actions creators. 4542 * 4543 * Note: The component using this hook must be within the context of a 4544 * RegistryProvider. 4545 * 4546 * @template {undefined | string | StoreDescriptor<any>} StoreNameOrDescriptor 4547 * @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the 4548 * store or its descriptor from which to 4549 * retrieve action creators. If not 4550 * provided, the registry.dispatch 4551 * function is returned instead. 4552 * 4553 * @example 4554 * This illustrates a pattern where you may need to retrieve dynamic data from 4555 * the server via the `useSelect` hook to use in combination with the dispatch 4556 * action. 4557 * 4558 * ```jsx 4559 * import { useCallback } from 'react'; 4560 * import { useDispatch, useSelect } from '@wordpress/data'; 4561 * import { store as myCustomStore } from 'my-custom-store'; 4562 * 4563 * function Button( { onClick, children } ) { 4564 * return <button type="button" onClick={ onClick }>{ children }</button> 4565 * } 4566 * 4567 * const SaleButton = ( { children } ) => { 4568 * const { stockNumber } = useSelect( 4569 * ( select ) => select( myCustomStore ).getStockNumber(), 4570 * [] 4571 * ); 4572 * const { startSale } = useDispatch( myCustomStore ); 4573 * const onClick = useCallback( () => { 4574 * const discountPercent = stockNumber > 50 ? 10: 20; 4575 * startSale( discountPercent ); 4576 * }, [ stockNumber ] ); 4577 * return <Button onClick={ onClick }>{ children }</Button> 4578 * } 4579 * 4580 * // Rendered somewhere in the application: 4581 * // 4582 * // <SaleButton>Start Sale!</SaleButton> 4583 * ``` 4584 * @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook. 4585 */ 4586 const useDispatch = storeNameOrDescriptor => { 4587 const { 4588 dispatch 4589 } = useRegistry(); 4590 return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor); 4591 }; 4592 /* harmony default export */ const use_dispatch = (useDispatch); 4593 4594 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/dispatch.js 4595 /** 4596 * Internal dependencies 4597 */ 4598 4599 4600 4601 /** 4602 * Given a store descriptor, returns an object of the store's action creators. 4603 * Calling an action creator will cause it to be dispatched, updating the state value accordingly. 4604 * 4605 * Note: Action creators returned by the dispatch will return a promise when 4606 * they are called. 4607 * 4608 * @param storeNameOrDescriptor The store descriptor. The legacy calling convention of passing 4609 * the store name is also supported. 4610 * 4611 * @example 4612 * ```js 4613 * import { dispatch } from '@wordpress/data'; 4614 * import { store as myCustomStore } from 'my-custom-store'; 4615 * 4616 * dispatch( myCustomStore ).setPrice( 'hammer', 9.75 ); 4617 * ``` 4618 * @return Object containing the action creators. 4619 */ 4620 function dispatch_dispatch(storeNameOrDescriptor) { 4621 return default_registry.dispatch(storeNameOrDescriptor); 4622 } 4623 4624 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/select.js 4625 /** 4626 * Internal dependencies 4627 */ 4628 4629 4630 4631 /** 4632 * Given a store descriptor, returns an object of the store's selectors. 4633 * The selector functions are been pre-bound to pass the current state automatically. 4634 * As a consumer, you need only pass arguments of the selector, if applicable. 4635 * 4636 * 4637 * @param storeNameOrDescriptor The store descriptor. The legacy calling convention 4638 * of passing the store name is also supported. 4639 * 4640 * @example 4641 * ```js 4642 * import { select } from '@wordpress/data'; 4643 * import { store as myCustomStore } from 'my-custom-store'; 4644 * 4645 * select( myCustomStore ).getPrice( 'hammer' ); 4646 * ``` 4647 * 4648 * @return Object containing the store's selectors. 4649 */ 4650 function select_select(storeNameOrDescriptor) { 4651 return default_registry.select(storeNameOrDescriptor); 4652 } 4653 4654 ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js 4655 /** 4656 * Internal dependencies 4657 */ 4658 4659 4660 4661 4662 /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 /** 4680 * Object of available plugins to use with a registry. 4681 * 4682 * @see [use](#use) 4683 * 4684 * @type {Object} 4685 */ 4686 4687 4688 /** 4689 * The combineReducers helper function turns an object whose values are different 4690 * reducing functions into a single reducing function you can pass to registerReducer. 4691 * 4692 * @type {import('./types').combineReducers} 4693 * @param {Object} reducers An object whose values correspond to different reducing 4694 * functions that need to be combined into one. 4695 * 4696 * @example 4697 * ```js 4698 * import { combineReducers, createReduxStore, register } from '@wordpress/data'; 4699 * 4700 * const prices = ( state = {}, action ) => { 4701 * return action.type === 'SET_PRICE' ? 4702 * { 4703 * ...state, 4704 * [ action.item ]: action.price, 4705 * } : 4706 * state; 4707 * }; 4708 * 4709 * const discountPercent = ( state = 0, action ) => { 4710 * return action.type === 'START_SALE' ? 4711 * action.discountPercent : 4712 * state; 4713 * }; 4714 * 4715 * const store = createReduxStore( 'my-shop', { 4716 * reducer: combineReducers( { 4717 * prices, 4718 * discountPercent, 4719 * } ), 4720 * } ); 4721 * register( store ); 4722 * ``` 4723 * 4724 * @return {Function} A reducer that invokes every reducer inside the reducers 4725 * object, and constructs a state object with the same shape. 4726 */ 4727 const build_module_combineReducers = combine_reducers_combineReducers; 4728 4729 /** 4730 * Given a store descriptor, returns an object containing the store's selectors pre-bound to state 4731 * so that you only need to supply additional arguments, and modified so that they return promises 4732 * that resolve to their eventual values, after any resolvers have ran. 4733 * 4734 * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling 4735 * convention of passing the store name is 4736 * also supported. 4737 * 4738 * @example 4739 * ```js 4740 * import { resolveSelect } from '@wordpress/data'; 4741 * import { store as myCustomStore } from 'my-custom-store'; 4742 * 4743 * resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log) 4744 * ``` 4745 * 4746 * @return {Object} Object containing the store's promise-wrapped selectors. 4747 */ 4748 const build_module_resolveSelect = default_registry.resolveSelect; 4749 4750 /** 4751 * Given a store descriptor, returns an object containing the store's selectors pre-bound to state 4752 * so that you only need to supply additional arguments, and modified so that they throw promises 4753 * in case the selector is not resolved yet. 4754 * 4755 * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling 4756 * convention of passing the store name is 4757 * also supported. 4758 * 4759 * @return {Object} Object containing the store's suspense-wrapped selectors. 4760 */ 4761 const suspendSelect = default_registry.suspendSelect; 4762 4763 /** 4764 * Given a listener function, the function will be called any time the state value 4765 * of one of the registered stores has changed. If you specify the optional 4766 * `storeNameOrDescriptor` parameter, the listener function will be called only 4767 * on updates on that one specific registered store. 4768 * 4769 * This function returns an `unsubscribe` function used to stop the subscription. 4770 * 4771 * @param {Function} listener Callback function. 4772 * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name. 4773 * 4774 * @example 4775 * ```js 4776 * import { subscribe } from '@wordpress/data'; 4777 * 4778 * const unsubscribe = subscribe( () => { 4779 * // You could use this opportunity to test whether the derived result of a 4780 * // selector has subsequently changed as the result of a state update. 4781 * } ); 4782 * 4783 * // Later, if necessary... 4784 * unsubscribe(); 4785 * ``` 4786 */ 4787 const subscribe = default_registry.subscribe; 4788 4789 /** 4790 * Registers a generic store instance. 4791 * 4792 * @deprecated Use `register( storeDescriptor )` instead. 4793 * 4794 * @param {string} name Store registry name. 4795 * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`). 4796 */ 4797 const registerGenericStore = default_registry.registerGenericStore; 4798 4799 /** 4800 * Registers a standard `@wordpress/data` store. 4801 * 4802 * @deprecated Use `register` instead. 4803 * 4804 * @param {string} storeName Unique namespace identifier for the store. 4805 * @param {Object} options Store description (reducer, actions, selectors, resolvers). 4806 * 4807 * @return {Object} Registered store object. 4808 */ 4809 const registerStore = default_registry.registerStore; 4810 4811 /** 4812 * Extends a registry to inherit functionality provided by a given plugin. A 4813 * plugin is an object with properties aligning to that of a registry, merged 4814 * to extend the default registry behavior. 4815 * 4816 * @param {Object} plugin Plugin object. 4817 */ 4818 const use = default_registry.use; 4819 4820 /** 4821 * Registers a standard `@wordpress/data` store descriptor. 4822 * 4823 * @example 4824 * ```js 4825 * import { createReduxStore, register } from '@wordpress/data'; 4826 * 4827 * const store = createReduxStore( 'demo', { 4828 * reducer: ( state = 'OK' ) => state, 4829 * selectors: { 4830 * getValue: ( state ) => state, 4831 * }, 4832 * } ); 4833 * register( store ); 4834 * ``` 4835 * 4836 * @param {StoreDescriptor} store Store descriptor. 4837 */ 4838 const register = default_registry.register; 4839 4840 })(); 4841 4842 (window.wp = window.wp || {}).data = __webpack_exports__; 4843 /******/ })() 4844 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |