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