data.js (127061B)
1 this["wp"] = this["wp"] || {}; this["wp"]["data"] = 2 /******/ (function(modules) { // webpackBootstrap 3 /******/ // The module cache 4 /******/ var installedModules = {}; 5 /******/ 6 /******/ // The require function 7 /******/ function __webpack_require__(moduleId) { 8 /******/ 9 /******/ // Check if module is in cache 10 /******/ if(installedModules[moduleId]) { 11 /******/ return installedModules[moduleId].exports; 12 /******/ } 13 /******/ // Create a new module (and put it into the cache) 14 /******/ var module = installedModules[moduleId] = { 15 /******/ i: moduleId, 16 /******/ l: false, 17 /******/ exports: {} 18 /******/ }; 19 /******/ 20 /******/ // Execute the module function 21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 22 /******/ 23 /******/ // Flag the module as loaded 24 /******/ module.l = true; 25 /******/ 26 /******/ // Return the exports of the module 27 /******/ return module.exports; 28 /******/ } 29 /******/ 30 /******/ 31 /******/ // expose the modules object (__webpack_modules__) 32 /******/ __webpack_require__.m = modules; 33 /******/ 34 /******/ // expose the module cache 35 /******/ __webpack_require__.c = installedModules; 36 /******/ 37 /******/ // define getter function for harmony exports 38 /******/ __webpack_require__.d = function(exports, name, getter) { 39 /******/ if(!__webpack_require__.o(exports, name)) { 40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 41 /******/ } 42 /******/ }; 43 /******/ 44 /******/ // define __esModule on exports 45 /******/ __webpack_require__.r = function(exports) { 46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 48 /******/ } 49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 50 /******/ }; 51 /******/ 52 /******/ // create a fake namespace object 53 /******/ // mode & 1: value is a module id, require it 54 /******/ // mode & 2: merge all properties of value into the ns 55 /******/ // mode & 4: return value when already ns object 56 /******/ // mode & 8|1: behave like require 57 /******/ __webpack_require__.t = function(value, mode) { 58 /******/ if(mode & 1) value = __webpack_require__(value); 59 /******/ if(mode & 8) return value; 60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 61 /******/ var ns = Object.create(null); 62 /******/ __webpack_require__.r(ns); 63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 65 /******/ return ns; 66 /******/ }; 67 /******/ 68 /******/ // getDefaultExport function for compatibility with non-harmony modules 69 /******/ __webpack_require__.n = function(module) { 70 /******/ var getter = module && module.__esModule ? 71 /******/ function getDefault() { return module['default']; } : 72 /******/ function getModuleExports() { return module; }; 73 /******/ __webpack_require__.d(getter, 'a', getter); 74 /******/ return getter; 75 /******/ }; 76 /******/ 77 /******/ // Object.prototype.hasOwnProperty.call 78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 79 /******/ 80 /******/ // __webpack_public_path__ 81 /******/ __webpack_require__.p = ""; 82 /******/ 83 /******/ 84 /******/ // Load entry module and return exports 85 /******/ return __webpack_require__(__webpack_require__.s = "pfJ3"); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ "8mpt": 91 /***/ (function(module, exports) { 92 93 function combineReducers( reducers ) { 94 var keys = Object.keys( reducers ), 95 getNextState; 96 97 getNextState = ( function() { 98 var fn, i, key; 99 100 fn = 'return {'; 101 for ( i = 0; i < keys.length; i++ ) { 102 // Rely on Quoted escaping of JSON.stringify with guarantee that 103 // each member of Object.keys is a string. 104 // 105 // "If Type(value) is String, then return the result of calling the 106 // abstract operation Quote with argument value. [...] The abstract 107 // operation Quote(value) wraps a String value in double quotes and 108 // escapes characters within it." 109 // 110 // https://www.ecma-international.org/ecma-262/5.1/#sec-15.12.3 111 key = JSON.stringify( keys[ i ] ); 112 113 fn += key + ':r[' + key + '](s[' + key + '],a),'; 114 } 115 fn += '}'; 116 117 return new Function( 'r,s,a', fn ); 118 } )(); 119 120 return function combinedReducer( state, action ) { 121 var nextState, i, key; 122 123 // Assumed changed if initial state. 124 if ( state === undefined ) { 125 return getNextState( reducers, {}, action ); 126 } 127 128 nextState = getNextState( reducers, state, action ); 129 130 // Determine whether state has changed. 131 i = keys.length; 132 while ( i-- ) { 133 key = keys[ i ]; 134 if ( state[ key ] !== nextState[ key ] ) { 135 // Return immediately if a changed value is encountered. 136 return nextState; 137 } 138 } 139 140 return state; 141 }; 142 } 143 144 module.exports = combineReducers; 145 146 147 /***/ }), 148 149 /***/ "FtRg": 150 /***/ (function(module, exports, __webpack_require__) { 151 152 "use strict"; 153 154 155 function _typeof(obj) { 156 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 157 _typeof = function (obj) { 158 return typeof obj; 159 }; 160 } else { 161 _typeof = function (obj) { 162 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 163 }; 164 } 165 166 return _typeof(obj); 167 } 168 169 function _classCallCheck(instance, Constructor) { 170 if (!(instance instanceof Constructor)) { 171 throw new TypeError("Cannot call a class as a function"); 172 } 173 } 174 175 function _defineProperties(target, props) { 176 for (var i = 0; i < props.length; i++) { 177 var descriptor = props[i]; 178 descriptor.enumerable = descriptor.enumerable || false; 179 descriptor.configurable = true; 180 if ("value" in descriptor) descriptor.writable = true; 181 Object.defineProperty(target, descriptor.key, descriptor); 182 } 183 } 184 185 function _createClass(Constructor, protoProps, staticProps) { 186 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 187 if (staticProps) _defineProperties(Constructor, staticProps); 188 return Constructor; 189 } 190 191 /** 192 * Given an instance of EquivalentKeyMap, returns its internal value pair tuple 193 * for a key, if one exists. The tuple members consist of the last reference 194 * value for the key (used in efficient subsequent lookups) and the value 195 * assigned for the key at the leaf node. 196 * 197 * @param {EquivalentKeyMap} instance EquivalentKeyMap instance. 198 * @param {*} key The key for which to return value pair. 199 * 200 * @return {?Array} Value pair, if exists. 201 */ 202 function getValuePair(instance, key) { 203 var _map = instance._map, 204 _arrayTreeMap = instance._arrayTreeMap, 205 _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the 206 // value, which can be used to shortcut immediately to the value. 207 208 if (_map.has(key)) { 209 return _map.get(key); 210 } // Sort keys to ensure stable retrieval from tree. 211 212 213 var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value. 214 215 var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap; 216 217 for (var i = 0; i < properties.length; i++) { 218 var property = properties[i]; 219 map = map.get(property); 220 221 if (map === undefined) { 222 return; 223 } 224 225 var propertyValue = key[property]; 226 map = map.get(propertyValue); 227 228 if (map === undefined) { 229 return; 230 } 231 } 232 233 var valuePair = map.get('_ekm_value'); 234 235 if (!valuePair) { 236 return; 237 } // If reached, it implies that an object-like key was set with another 238 // reference, so delete the reference and replace with the current. 239 240 241 _map.delete(valuePair[0]); 242 243 valuePair[0] = key; 244 map.set('_ekm_value', valuePair); 245 246 _map.set(key, valuePair); 247 248 return valuePair; 249 } 250 /** 251 * Variant of a Map object which enables lookup by equivalent (deeply equal) 252 * object and array keys. 253 */ 254 255 256 var EquivalentKeyMap = 257 /*#__PURE__*/ 258 function () { 259 /** 260 * Constructs a new instance of EquivalentKeyMap. 261 * 262 * @param {Iterable.<*>} iterable Initial pair of key, value for map. 263 */ 264 function EquivalentKeyMap(iterable) { 265 _classCallCheck(this, EquivalentKeyMap); 266 267 this.clear(); 268 269 if (iterable instanceof EquivalentKeyMap) { 270 // Map#forEach is only means of iterating with support for IE11. 271 var iterablePairs = []; 272 iterable.forEach(function (value, key) { 273 iterablePairs.push([key, value]); 274 }); 275 iterable = iterablePairs; 276 } 277 278 if (iterable != null) { 279 for (var i = 0; i < iterable.length; i++) { 280 this.set(iterable[i][0], iterable[i][1]); 281 } 282 } 283 } 284 /** 285 * Accessor property returning the number of elements. 286 * 287 * @return {number} Number of elements. 288 */ 289 290 291 _createClass(EquivalentKeyMap, [{ 292 key: "set", 293 294 /** 295 * Add or update an element with a specified key and value. 296 * 297 * @param {*} key The key of the element to add. 298 * @param {*} value The value of the element to add. 299 * 300 * @return {EquivalentKeyMap} Map instance. 301 */ 302 value: function set(key, value) { 303 // Shortcut non-object-like to set on internal Map. 304 if (key === null || _typeof(key) !== 'object') { 305 this._map.set(key, value); 306 307 return this; 308 } // Sort keys to ensure stable assignment into tree. 309 310 311 var properties = Object.keys(key).sort(); 312 var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value. 313 314 var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap; 315 316 for (var i = 0; i < properties.length; i++) { 317 var property = properties[i]; 318 319 if (!map.has(property)) { 320 map.set(property, new EquivalentKeyMap()); 321 } 322 323 map = map.get(property); 324 var propertyValue = key[property]; 325 326 if (!map.has(propertyValue)) { 327 map.set(propertyValue, new EquivalentKeyMap()); 328 } 329 330 map = map.get(propertyValue); 331 } // If an _ekm_value exists, there was already an equivalent key. Before 332 // overriding, ensure that the old key reference is removed from map to 333 // avoid memory leak of accumulating equivalent keys. This is, in a 334 // sense, a poor man's WeakMap, while still enabling iterability. 335 336 337 var previousValuePair = map.get('_ekm_value'); 338 339 if (previousValuePair) { 340 this._map.delete(previousValuePair[0]); 341 } 342 343 map.set('_ekm_value', valuePair); 344 345 this._map.set(key, valuePair); 346 347 return this; 348 } 349 /** 350 * Returns a specified element. 351 * 352 * @param {*} key The key of the element to return. 353 * 354 * @return {?*} The element associated with the specified key or undefined 355 * if the key can't be found. 356 */ 357 358 }, { 359 key: "get", 360 value: function get(key) { 361 // Shortcut non-object-like to get from internal Map. 362 if (key === null || _typeof(key) !== 'object') { 363 return this._map.get(key); 364 } 365 366 var valuePair = getValuePair(this, key); 367 368 if (valuePair) { 369 return valuePair[1]; 370 } 371 } 372 /** 373 * Returns a boolean indicating whether an element with the specified key 374 * exists or not. 375 * 376 * @param {*} key The key of the element to test for presence. 377 * 378 * @return {boolean} Whether an element with the specified key exists. 379 */ 380 381 }, { 382 key: "has", 383 value: function has(key) { 384 if (key === null || _typeof(key) !== 'object') { 385 return this._map.has(key); 386 } // Test on the _presence_ of the pair, not its value, as even undefined 387 // can be a valid member value for a key. 388 389 390 return getValuePair(this, key) !== undefined; 391 } 392 /** 393 * Removes the specified element. 394 * 395 * @param {*} key The key of the element to remove. 396 * 397 * @return {boolean} Returns true if an element existed and has been 398 * removed, or false if the element does not exist. 399 */ 400 401 }, { 402 key: "delete", 403 value: function _delete(key) { 404 if (!this.has(key)) { 405 return false; 406 } // This naive implementation will leave orphaned child trees. A better 407 // implementation should traverse and remove orphans. 408 409 410 this.set(key, undefined); 411 return true; 412 } 413 /** 414 * Executes a provided function once per each key/value pair, in insertion 415 * order. 416 * 417 * @param {Function} callback Function to execute for each element. 418 * @param {*} thisArg Value to use as `this` when executing 419 * `callback`. 420 */ 421 422 }, { 423 key: "forEach", 424 value: function forEach(callback) { 425 var _this = this; 426 427 var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; 428 429 this._map.forEach(function (value, key) { 430 // Unwrap value from object-like value pair. 431 if (key !== null && _typeof(key) === 'object') { 432 value = value[1]; 433 } 434 435 callback.call(thisArg, value, key, _this); 436 }); 437 } 438 /** 439 * Removes all elements. 440 */ 441 442 }, { 443 key: "clear", 444 value: function clear() { 445 this._map = new Map(); 446 this._arrayTreeMap = new Map(); 447 this._objectTreeMap = new Map(); 448 } 449 }, { 450 key: "size", 451 get: function get() { 452 return this._map.size; 453 } 454 }]); 455 456 return EquivalentKeyMap; 457 }(); 458 459 module.exports = EquivalentKeyMap; 460 461 462 /***/ }), 463 464 /***/ "GRId": 465 /***/ (function(module, exports) { 466 467 (function() { module.exports = window["wp"]["element"]; }()); 468 469 /***/ }), 470 471 /***/ "JlUD": 472 /***/ (function(module, exports) { 473 474 module.exports = isPromise; 475 module.exports.default = isPromise; 476 477 function isPromise(obj) { 478 return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; 479 } 480 481 482 /***/ }), 483 484 /***/ "K9lf": 485 /***/ (function(module, exports) { 486 487 (function() { module.exports = window["wp"]["compose"]; }()); 488 489 /***/ }), 490 491 /***/ "NMb1": 492 /***/ (function(module, exports) { 493 494 (function() { module.exports = window["wp"]["deprecated"]; }()); 495 496 /***/ }), 497 498 /***/ "XI5e": 499 /***/ (function(module, exports) { 500 501 (function() { module.exports = window["wp"]["priorityQueue"]; }()); 502 503 /***/ }), 504 505 /***/ "XIDh": 506 /***/ (function(module, exports) { 507 508 (function() { module.exports = window["wp"]["reduxRoutine"]; }()); 509 510 /***/ }), 511 512 /***/ "YLtl": 513 /***/ (function(module, exports) { 514 515 (function() { module.exports = window["lodash"]; }()); 516 517 /***/ }), 518 519 /***/ "cDcd": 520 /***/ (function(module, exports) { 521 522 (function() { module.exports = window["React"]; }()); 523 524 /***/ }), 525 526 /***/ "mHlH": 527 /***/ (function(module, __webpack_exports__, __webpack_require__) { 528 529 "use strict"; 530 /* unused harmony export useCallback */ 531 /* unused harmony export useCallbackOne */ 532 /* unused harmony export useMemo */ 533 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useMemoOne; }); 534 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("cDcd"); 535 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 536 537 538 function areInputsEqual(newInputs, lastInputs) { 539 if (newInputs.length !== lastInputs.length) { 540 return false; 541 } 542 543 for (var i = 0; i < newInputs.length; i++) { 544 if (newInputs[i] !== lastInputs[i]) { 545 return false; 546 } 547 } 548 549 return true; 550 } 551 552 function useMemoOne(getResult, inputs) { 553 var initial = Object(react__WEBPACK_IMPORTED_MODULE_0__["useState"])(function () { 554 return { 555 inputs: inputs, 556 result: getResult() 557 }; 558 })[0]; 559 var isFirstRun = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(true); 560 var committed = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(initial); 561 var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); 562 var cache = useCache ? committed.current : { 563 inputs: inputs, 564 result: getResult() 565 }; 566 Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () { 567 isFirstRun.current = false; 568 committed.current = cache; 569 }, [cache]); 570 return cache.result; 571 } 572 function useCallbackOne(callback, inputs) { 573 return useMemoOne(function () { 574 return callback; 575 }, inputs); 576 } 577 var useMemo = useMemoOne; 578 var useCallback = useCallbackOne; 579 580 581 582 583 /***/ }), 584 585 /***/ "pfJ3": 586 /***/ (function(module, __webpack_exports__, __webpack_require__) { 587 588 "use strict"; 589 // ESM COMPAT FLAG 590 __webpack_require__.r(__webpack_exports__); 591 592 // EXPORTS 593 __webpack_require__.d(__webpack_exports__, "withSelect", function() { return /* reexport */ with_select; }); 594 __webpack_require__.d(__webpack_exports__, "withDispatch", function() { return /* reexport */ with_dispatch; }); 595 __webpack_require__.d(__webpack_exports__, "withRegistry", function() { return /* reexport */ with_registry; }); 596 __webpack_require__.d(__webpack_exports__, "RegistryProvider", function() { return /* reexport */ context; }); 597 __webpack_require__.d(__webpack_exports__, "RegistryConsumer", function() { return /* reexport */ RegistryConsumer; }); 598 __webpack_require__.d(__webpack_exports__, "useRegistry", function() { return /* reexport */ useRegistry; }); 599 __webpack_require__.d(__webpack_exports__, "useSelect", function() { return /* reexport */ useSelect; }); 600 __webpack_require__.d(__webpack_exports__, "useDispatch", function() { return /* reexport */ use_dispatch; }); 601 __webpack_require__.d(__webpack_exports__, "AsyncModeProvider", function() { return /* reexport */ async_mode_provider_context; }); 602 __webpack_require__.d(__webpack_exports__, "createRegistry", function() { return /* reexport */ createRegistry; }); 603 __webpack_require__.d(__webpack_exports__, "createRegistrySelector", function() { return /* reexport */ createRegistrySelector; }); 604 __webpack_require__.d(__webpack_exports__, "createRegistryControl", function() { return /* reexport */ createRegistryControl; }); 605 __webpack_require__.d(__webpack_exports__, "controls", function() { return /* reexport */ controls_controls; }); 606 __webpack_require__.d(__webpack_exports__, "createReduxStore", function() { return /* reexport */ createReduxStore; }); 607 __webpack_require__.d(__webpack_exports__, "plugins", function() { return /* reexport */ plugins_namespaceObject; }); 608 __webpack_require__.d(__webpack_exports__, "combineReducers", function() { return /* reexport */ turbo_combine_reducers_default.a; }); 609 __webpack_require__.d(__webpack_exports__, "select", function() { return /* binding */ build_module_select; }); 610 __webpack_require__.d(__webpack_exports__, "resolveSelect", function() { return /* binding */ build_module_resolveSelect; }); 611 __webpack_require__.d(__webpack_exports__, "dispatch", function() { return /* binding */ build_module_dispatch; }); 612 __webpack_require__.d(__webpack_exports__, "subscribe", function() { return /* binding */ build_module_subscribe; }); 613 __webpack_require__.d(__webpack_exports__, "registerGenericStore", function() { return /* binding */ build_module_registerGenericStore; }); 614 __webpack_require__.d(__webpack_exports__, "registerStore", function() { return /* binding */ registerStore; }); 615 __webpack_require__.d(__webpack_exports__, "use", function() { return /* binding */ build_module_use; }); 616 __webpack_require__.d(__webpack_exports__, "register", function() { return /* binding */ build_module_register; }); 617 618 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js 619 var selectors_namespaceObject = {}; 620 __webpack_require__.r(selectors_namespaceObject); 621 __webpack_require__.d(selectors_namespaceObject, "getIsResolving", function() { return getIsResolving; }); 622 __webpack_require__.d(selectors_namespaceObject, "hasStartedResolution", function() { return hasStartedResolution; }); 623 __webpack_require__.d(selectors_namespaceObject, "hasFinishedResolution", function() { return hasFinishedResolution; }); 624 __webpack_require__.d(selectors_namespaceObject, "isResolving", function() { return isResolving; }); 625 __webpack_require__.d(selectors_namespaceObject, "getCachedResolvers", function() { return getCachedResolvers; }); 626 627 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js 628 var actions_namespaceObject = {}; 629 __webpack_require__.r(actions_namespaceObject); 630 __webpack_require__.d(actions_namespaceObject, "startResolution", function() { return startResolution; }); 631 __webpack_require__.d(actions_namespaceObject, "finishResolution", function() { return finishResolution; }); 632 __webpack_require__.d(actions_namespaceObject, "startResolutions", function() { return startResolutions; }); 633 __webpack_require__.d(actions_namespaceObject, "finishResolutions", function() { return finishResolutions; }); 634 __webpack_require__.d(actions_namespaceObject, "invalidateResolution", function() { return invalidateResolution; }); 635 __webpack_require__.d(actions_namespaceObject, "invalidateResolutionForStore", function() { return invalidateResolutionForStore; }); 636 __webpack_require__.d(actions_namespaceObject, "invalidateResolutionForStoreSelector", function() { return invalidateResolutionForStoreSelector; }); 637 638 // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js 639 var plugins_namespaceObject = {}; 640 __webpack_require__.r(plugins_namespaceObject); 641 __webpack_require__.d(plugins_namespaceObject, "controls", function() { return plugins_controls; }); 642 __webpack_require__.d(plugins_namespaceObject, "persistence", function() { return plugins_persistence; }); 643 644 // EXTERNAL MODULE: ./node_modules/turbo-combine-reducers/index.js 645 var turbo_combine_reducers = __webpack_require__("8mpt"); 646 var turbo_combine_reducers_default = /*#__PURE__*/__webpack_require__.n(turbo_combine_reducers); 647 648 // EXTERNAL MODULE: external "lodash" 649 var external_lodash_ = __webpack_require__("YLtl"); 650 651 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js 652 function _defineProperty(obj, key, value) { 653 if (key in obj) { 654 Object.defineProperty(obj, key, { 655 value: value, 656 enumerable: true, 657 configurable: true, 658 writable: true 659 }); 660 } else { 661 obj[key] = value; 662 } 663 664 return obj; 665 } 666 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js 667 668 669 function ownKeys(object, enumerableOnly) { 670 var keys = Object.keys(object); 671 672 if (Object.getOwnPropertySymbols) { 673 var symbols = Object.getOwnPropertySymbols(object); 674 675 if (enumerableOnly) { 676 symbols = symbols.filter(function (sym) { 677 return Object.getOwnPropertyDescriptor(object, sym).enumerable; 678 }); 679 } 680 681 keys.push.apply(keys, symbols); 682 } 683 684 return keys; 685 } 686 687 function _objectSpread2(target) { 688 for (var i = 1; i < arguments.length; i++) { 689 var source = arguments[i] != null ? arguments[i] : {}; 690 691 if (i % 2) { 692 ownKeys(Object(source), true).forEach(function (key) { 693 _defineProperty(target, key, source[key]); 694 }); 695 } else if (Object.getOwnPropertyDescriptors) { 696 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); 697 } else { 698 ownKeys(Object(source)).forEach(function (key) { 699 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); 700 }); 701 } 702 } 703 704 return target; 705 } 706 // CONCATENATED MODULE: ./node_modules/redux/es/redux.js 707 708 709 /** 710 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js 711 * 712 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes 713 * during build. 714 * @param {number} code 715 */ 716 function formatProdErrorMessage(code) { 717 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. '; 718 } 719 720 // Inlined version of the `symbol-observable` polyfill 721 var $$observable = (function () { 722 return typeof Symbol === 'function' && Symbol.observable || '@@observable'; 723 })(); 724 725 /** 726 * These are private action types reserved by Redux. 727 * For any unknown actions, you must return the current state. 728 * If the current state is undefined, you must return the initial state. 729 * Do not reference these action types directly in your code. 730 */ 731 var randomString = function randomString() { 732 return Math.random().toString(36).substring(7).split('').join('.'); 733 }; 734 735 var ActionTypes = { 736 INIT: "@@redux/INIT" + randomString(), 737 REPLACE: "@@redux/REPLACE" + randomString(), 738 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() { 739 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString(); 740 } 741 }; 742 743 /** 744 * @param {any} obj The object to inspect. 745 * @returns {boolean} True if the argument appears to be a plain object. 746 */ 747 function isPlainObject(obj) { 748 if (typeof obj !== 'object' || obj === null) return false; 749 var proto = obj; 750 751 while (Object.getPrototypeOf(proto) !== null) { 752 proto = Object.getPrototypeOf(proto); 753 } 754 755 return Object.getPrototypeOf(obj) === proto; 756 } 757 758 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of 759 function miniKindOf(val) { 760 if (val === void 0) return 'undefined'; 761 if (val === null) return 'null'; 762 var type = typeof val; 763 764 switch (type) { 765 case 'boolean': 766 case 'string': 767 case 'number': 768 case 'symbol': 769 case 'function': 770 { 771 return type; 772 } 773 } 774 775 if (Array.isArray(val)) return 'array'; 776 if (isDate(val)) return 'date'; 777 if (isError(val)) return 'error'; 778 var constructorName = ctorName(val); 779 780 switch (constructorName) { 781 case 'Symbol': 782 case 'Promise': 783 case 'WeakMap': 784 case 'WeakSet': 785 case 'Map': 786 case 'Set': 787 return constructorName; 788 } // other 789 790 791 return type.slice(8, -1).toLowerCase().replace(/\s/g, ''); 792 } 793 794 function ctorName(val) { 795 return typeof val.constructor === 'function' ? val.constructor.name : null; 796 } 797 798 function isError(val) { 799 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number'; 800 } 801 802 function isDate(val) { 803 if (val instanceof Date) return true; 804 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function'; 805 } 806 807 function kindOf(val) { 808 var typeOfVal = typeof val; 809 810 if (false) {} 811 812 return typeOfVal; 813 } 814 815 /** 816 * Creates a Redux store that holds the state tree. 817 * The only way to change the data in the store is to call `dispatch()` on it. 818 * 819 * There should only be a single store in your app. To specify how different 820 * parts of the state tree respond to actions, you may combine several reducers 821 * into a single reducer function by using `combineReducers`. 822 * 823 * @param {Function} reducer A function that returns the next state tree, given 824 * the current state tree and the action to handle. 825 * 826 * @param {any} [preloadedState] The initial state. You may optionally specify it 827 * to hydrate the state from the server in universal apps, or to restore a 828 * previously serialized user session. 829 * If you use `combineReducers` to produce the root reducer function, this must be 830 * an object with the same shape as `combineReducers` keys. 831 * 832 * @param {Function} [enhancer] The store enhancer. You may optionally specify it 833 * to enhance the store with third-party capabilities such as middleware, 834 * time travel, persistence, etc. The only store enhancer that ships with Redux 835 * is `applyMiddleware()`. 836 * 837 * @returns {Store} A Redux store that lets you read the state, dispatch actions 838 * and subscribe to changes. 839 */ 840 841 function redux_createStore(reducer, preloadedState, enhancer) { 842 var _ref2; 843 844 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') { 845 throw new Error( true ? formatProdErrorMessage(0) : undefined); 846 } 847 848 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { 849 enhancer = preloadedState; 850 preloadedState = undefined; 851 } 852 853 if (typeof enhancer !== 'undefined') { 854 if (typeof enhancer !== 'function') { 855 throw new Error( true ? formatProdErrorMessage(1) : undefined); 856 } 857 858 return enhancer(redux_createStore)(reducer, preloadedState); 859 } 860 861 if (typeof reducer !== 'function') { 862 throw new Error( true ? formatProdErrorMessage(2) : undefined); 863 } 864 865 var currentReducer = reducer; 866 var currentState = preloadedState; 867 var currentListeners = []; 868 var nextListeners = currentListeners; 869 var isDispatching = false; 870 /** 871 * This makes a shallow copy of currentListeners so we can use 872 * nextListeners as a temporary list while dispatching. 873 * 874 * This prevents any bugs around consumers calling 875 * subscribe/unsubscribe in the middle of a dispatch. 876 */ 877 878 function ensureCanMutateNextListeners() { 879 if (nextListeners === currentListeners) { 880 nextListeners = currentListeners.slice(); 881 } 882 } 883 /** 884 * Reads the state tree managed by the store. 885 * 886 * @returns {any} The current state tree of your application. 887 */ 888 889 890 function getState() { 891 if (isDispatching) { 892 throw new Error( true ? formatProdErrorMessage(3) : undefined); 893 } 894 895 return currentState; 896 } 897 /** 898 * Adds a change listener. It will be called any time an action is dispatched, 899 * and some part of the state tree may potentially have changed. You may then 900 * call `getState()` to read the current state tree inside the callback. 901 * 902 * You may call `dispatch()` from a change listener, with the following 903 * caveats: 904 * 905 * 1. The subscriptions are snapshotted just before every `dispatch()` call. 906 * If you subscribe or unsubscribe while the listeners are being invoked, this 907 * will not have any effect on the `dispatch()` that is currently in progress. 908 * However, the next `dispatch()` call, whether nested or not, will use a more 909 * recent snapshot of the subscription list. 910 * 911 * 2. The listener should not expect to see all state changes, as the state 912 * might have been updated multiple times during a nested `dispatch()` before 913 * the listener is called. It is, however, guaranteed that all subscribers 914 * registered before the `dispatch()` started will be called with the latest 915 * state by the time it exits. 916 * 917 * @param {Function} listener A callback to be invoked on every dispatch. 918 * @returns {Function} A function to remove this change listener. 919 */ 920 921 922 function subscribe(listener) { 923 if (typeof listener !== 'function') { 924 throw new Error( true ? formatProdErrorMessage(4) : undefined); 925 } 926 927 if (isDispatching) { 928 throw new Error( true ? formatProdErrorMessage(5) : undefined); 929 } 930 931 var isSubscribed = true; 932 ensureCanMutateNextListeners(); 933 nextListeners.push(listener); 934 return function unsubscribe() { 935 if (!isSubscribed) { 936 return; 937 } 938 939 if (isDispatching) { 940 throw new Error( true ? formatProdErrorMessage(6) : undefined); 941 } 942 943 isSubscribed = false; 944 ensureCanMutateNextListeners(); 945 var index = nextListeners.indexOf(listener); 946 nextListeners.splice(index, 1); 947 currentListeners = null; 948 }; 949 } 950 /** 951 * Dispatches an action. It is the only way to trigger a state change. 952 * 953 * The `reducer` function, used to create the store, will be called with the 954 * current state tree and the given `action`. Its return value will 955 * be considered the **next** state of the tree, and the change listeners 956 * will be notified. 957 * 958 * The base implementation only supports plain object actions. If you want to 959 * dispatch a Promise, an Observable, a thunk, or something else, you need to 960 * wrap your store creating function into the corresponding middleware. For 961 * example, see the documentation for the `redux-thunk` package. Even the 962 * middleware will eventually dispatch plain object actions using this method. 963 * 964 * @param {Object} action A plain object representing “what changed”. It is 965 * a good idea to keep actions serializable so you can record and replay user 966 * sessions, or use the time travelling `redux-devtools`. An action must have 967 * a `type` property which may not be `undefined`. It is a good idea to use 968 * string constants for action types. 969 * 970 * @returns {Object} For convenience, the same action object you dispatched. 971 * 972 * Note that, if you use a custom middleware, it may wrap `dispatch()` to 973 * return something else (for example, a Promise you can await). 974 */ 975 976 977 function dispatch(action) { 978 if (!isPlainObject(action)) { 979 throw new Error( true ? formatProdErrorMessage(7) : undefined); 980 } 981 982 if (typeof action.type === 'undefined') { 983 throw new Error( true ? formatProdErrorMessage(8) : undefined); 984 } 985 986 if (isDispatching) { 987 throw new Error( true ? formatProdErrorMessage(9) : undefined); 988 } 989 990 try { 991 isDispatching = true; 992 currentState = currentReducer(currentState, action); 993 } finally { 994 isDispatching = false; 995 } 996 997 var listeners = currentListeners = nextListeners; 998 999 for (var i = 0; i < listeners.length; i++) { 1000 var listener = listeners[i]; 1001 listener(); 1002 } 1003 1004 return action; 1005 } 1006 /** 1007 * Replaces the reducer currently used by the store to calculate the state. 1008 * 1009 * You might need this if your app implements code splitting and you want to 1010 * load some of the reducers dynamically. You might also need this if you 1011 * implement a hot reloading mechanism for Redux. 1012 * 1013 * @param {Function} nextReducer The reducer for the store to use instead. 1014 * @returns {void} 1015 */ 1016 1017 1018 function replaceReducer(nextReducer) { 1019 if (typeof nextReducer !== 'function') { 1020 throw new Error( true ? formatProdErrorMessage(10) : undefined); 1021 } 1022 1023 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT. 1024 // Any reducers that existed in both the new and old rootReducer 1025 // will receive the previous state. This effectively populates 1026 // the new state tree with any relevant data from the old one. 1027 1028 dispatch({ 1029 type: ActionTypes.REPLACE 1030 }); 1031 } 1032 /** 1033 * Interoperability point for observable/reactive libraries. 1034 * @returns {observable} A minimal observable of state changes. 1035 * For more information, see the observable proposal: 1036 * https://github.com/tc39/proposal-observable 1037 */ 1038 1039 1040 function observable() { 1041 var _ref; 1042 1043 var outerSubscribe = subscribe; 1044 return _ref = { 1045 /** 1046 * The minimal observable subscription method. 1047 * @param {Object} observer Any object that can be used as an observer. 1048 * The observer object should have a `next` method. 1049 * @returns {subscription} An object with an `unsubscribe` method that can 1050 * be used to unsubscribe the observable from the store, and prevent further 1051 * emission of values from the observable. 1052 */ 1053 subscribe: function subscribe(observer) { 1054 if (typeof observer !== 'object' || observer === null) { 1055 throw new Error( true ? formatProdErrorMessage(11) : undefined); 1056 } 1057 1058 function observeState() { 1059 if (observer.next) { 1060 observer.next(getState()); 1061 } 1062 } 1063 1064 observeState(); 1065 var unsubscribe = outerSubscribe(observeState); 1066 return { 1067 unsubscribe: unsubscribe 1068 }; 1069 } 1070 }, _ref[$$observable] = function () { 1071 return this; 1072 }, _ref; 1073 } // When a store is created, an "INIT" action is dispatched so that every 1074 // reducer returns their initial state. This effectively populates 1075 // the initial state tree. 1076 1077 1078 dispatch({ 1079 type: ActionTypes.INIT 1080 }); 1081 return _ref2 = { 1082 dispatch: dispatch, 1083 subscribe: subscribe, 1084 getState: getState, 1085 replaceReducer: replaceReducer 1086 }, _ref2[$$observable] = observable, _ref2; 1087 } 1088 1089 /** 1090 * Prints a warning in the console if it exists. 1091 * 1092 * @param {String} message The warning message. 1093 * @returns {void} 1094 */ 1095 function warning(message) { 1096 /* eslint-disable no-console */ 1097 if (typeof console !== 'undefined' && typeof console.error === 'function') { 1098 console.error(message); 1099 } 1100 /* eslint-enable no-console */ 1101 1102 1103 try { 1104 // This error was thrown as a convenience so that if you enable 1105 // "break on all exceptions" in your console, 1106 // it would pause the execution at this line. 1107 throw new Error(message); 1108 } catch (e) {} // eslint-disable-line no-empty 1109 1110 } 1111 1112 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { 1113 var reducerKeys = Object.keys(reducers); 1114 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer'; 1115 1116 if (reducerKeys.length === 0) { 1117 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'; 1118 } 1119 1120 if (!isPlainObject(inputState)) { 1121 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\""); 1122 } 1123 1124 var unexpectedKeys = Object.keys(inputState).filter(function (key) { 1125 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]; 1126 }); 1127 unexpectedKeys.forEach(function (key) { 1128 unexpectedKeyCache[key] = true; 1129 }); 1130 if (action && action.type === ActionTypes.REPLACE) return; 1131 1132 if (unexpectedKeys.length > 0) { 1133 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."); 1134 } 1135 } 1136 1137 function assertReducerShape(reducers) { 1138 Object.keys(reducers).forEach(function (key) { 1139 var reducer = reducers[key]; 1140 var initialState = reducer(undefined, { 1141 type: ActionTypes.INIT 1142 }); 1143 1144 if (typeof initialState === 'undefined') { 1145 throw new Error( true ? formatProdErrorMessage(12) : undefined); 1146 } 1147 1148 if (typeof reducer(undefined, { 1149 type: ActionTypes.PROBE_UNKNOWN_ACTION() 1150 }) === 'undefined') { 1151 throw new Error( true ? formatProdErrorMessage(13) : undefined); 1152 } 1153 }); 1154 } 1155 /** 1156 * Turns an object whose values are different reducer functions, into a single 1157 * reducer function. It will call every child reducer, and gather their results 1158 * into a single state object, whose keys correspond to the keys of the passed 1159 * reducer functions. 1160 * 1161 * @param {Object} reducers An object whose values correspond to different 1162 * reducer functions that need to be combined into one. One handy way to obtain 1163 * it is to use ES6 `import * as reducers` syntax. The reducers may never return 1164 * undefined for any action. Instead, they should return their initial state 1165 * if the state passed to them was undefined, and the current state for any 1166 * unrecognized action. 1167 * 1168 * @returns {Function} A reducer function that invokes every reducer inside the 1169 * passed object, and builds a state object with the same shape. 1170 */ 1171 1172 1173 function combineReducers(reducers) { 1174 var reducerKeys = Object.keys(reducers); 1175 var finalReducers = {}; 1176 1177 for (var i = 0; i < reducerKeys.length; i++) { 1178 var key = reducerKeys[i]; 1179 1180 if (false) {} 1181 1182 if (typeof reducers[key] === 'function') { 1183 finalReducers[key] = reducers[key]; 1184 } 1185 } 1186 1187 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same 1188 // keys multiple times. 1189 1190 var unexpectedKeyCache; 1191 1192 if (false) {} 1193 1194 var shapeAssertionError; 1195 1196 try { 1197 assertReducerShape(finalReducers); 1198 } catch (e) { 1199 shapeAssertionError = e; 1200 } 1201 1202 return function combination(state, action) { 1203 if (state === void 0) { 1204 state = {}; 1205 } 1206 1207 if (shapeAssertionError) { 1208 throw shapeAssertionError; 1209 } 1210 1211 if (false) { var warningMessage; } 1212 1213 var hasChanged = false; 1214 var nextState = {}; 1215 1216 for (var _i = 0; _i < finalReducerKeys.length; _i++) { 1217 var _key = finalReducerKeys[_i]; 1218 var reducer = finalReducers[_key]; 1219 var previousStateForKey = state[_key]; 1220 var nextStateForKey = reducer(previousStateForKey, action); 1221 1222 if (typeof nextStateForKey === 'undefined') { 1223 var actionType = action && action.type; 1224 throw new Error( true ? formatProdErrorMessage(14) : undefined); 1225 } 1226 1227 nextState[_key] = nextStateForKey; 1228 hasChanged = hasChanged || nextStateForKey !== previousStateForKey; 1229 } 1230 1231 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length; 1232 return hasChanged ? nextState : state; 1233 }; 1234 } 1235 1236 function bindActionCreator(actionCreator, dispatch) { 1237 return function () { 1238 return dispatch(actionCreator.apply(this, arguments)); 1239 }; 1240 } 1241 /** 1242 * Turns an object whose values are action creators, into an object with the 1243 * same keys, but with every function wrapped into a `dispatch` call so they 1244 * may be invoked directly. This is just a convenience method, as you can call 1245 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine. 1246 * 1247 * For convenience, you can also pass an action creator as the first argument, 1248 * and get a dispatch wrapped function in return. 1249 * 1250 * @param {Function|Object} actionCreators An object whose values are action 1251 * creator functions. One handy way to obtain it is to use ES6 `import * as` 1252 * syntax. You may also pass a single function. 1253 * 1254 * @param {Function} dispatch The `dispatch` function available on your Redux 1255 * store. 1256 * 1257 * @returns {Function|Object} The object mimicking the original object, but with 1258 * every action creator wrapped into the `dispatch` call. If you passed a 1259 * function as `actionCreators`, the return value will also be a single 1260 * function. 1261 */ 1262 1263 1264 function bindActionCreators(actionCreators, dispatch) { 1265 if (typeof actionCreators === 'function') { 1266 return bindActionCreator(actionCreators, dispatch); 1267 } 1268 1269 if (typeof actionCreators !== 'object' || actionCreators === null) { 1270 throw new Error( true ? formatProdErrorMessage(16) : undefined); 1271 } 1272 1273 var boundActionCreators = {}; 1274 1275 for (var key in actionCreators) { 1276 var actionCreator = actionCreators[key]; 1277 1278 if (typeof actionCreator === 'function') { 1279 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch); 1280 } 1281 } 1282 1283 return boundActionCreators; 1284 } 1285 1286 /** 1287 * Composes single-argument functions from right to left. The rightmost 1288 * function can take multiple arguments as it provides the signature for 1289 * the resulting composite function. 1290 * 1291 * @param {...Function} funcs The functions to compose. 1292 * @returns {Function} A function obtained by composing the argument functions 1293 * from right to left. For example, compose(f, g, h) is identical to doing 1294 * (...args) => f(g(h(...args))). 1295 */ 1296 function compose() { 1297 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) { 1298 funcs[_key] = arguments[_key]; 1299 } 1300 1301 if (funcs.length === 0) { 1302 return function (arg) { 1303 return arg; 1304 }; 1305 } 1306 1307 if (funcs.length === 1) { 1308 return funcs[0]; 1309 } 1310 1311 return funcs.reduce(function (a, b) { 1312 return function () { 1313 return a(b.apply(void 0, arguments)); 1314 }; 1315 }); 1316 } 1317 1318 /** 1319 * Creates a store enhancer that applies middleware to the dispatch method 1320 * of the Redux store. This is handy for a variety of tasks, such as expressing 1321 * asynchronous actions in a concise manner, or logging every action payload. 1322 * 1323 * See `redux-thunk` package as an example of the Redux middleware. 1324 * 1325 * Because middleware is potentially asynchronous, this should be the first 1326 * store enhancer in the composition chain. 1327 * 1328 * Note that each middleware will be given the `dispatch` and `getState` functions 1329 * as named arguments. 1330 * 1331 * @param {...Function} middlewares The middleware chain to be applied. 1332 * @returns {Function} A store enhancer applying the middleware. 1333 */ 1334 1335 function applyMiddleware() { 1336 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) { 1337 middlewares[_key] = arguments[_key]; 1338 } 1339 1340 return function (createStore) { 1341 return function () { 1342 var store = createStore.apply(void 0, arguments); 1343 1344 var _dispatch = function dispatch() { 1345 throw new Error( true ? formatProdErrorMessage(15) : undefined); 1346 }; 1347 1348 var middlewareAPI = { 1349 getState: store.getState, 1350 dispatch: function dispatch() { 1351 return _dispatch.apply(void 0, arguments); 1352 } 1353 }; 1354 var chain = middlewares.map(function (middleware) { 1355 return middleware(middlewareAPI); 1356 }); 1357 _dispatch = compose.apply(void 0, chain)(store.dispatch); 1358 return _objectSpread2(_objectSpread2({}, store), {}, { 1359 dispatch: _dispatch 1360 }); 1361 }; 1362 }; 1363 } 1364 1365 /* 1366 * This is a dummy function to check if the function name has been altered by minification. 1367 * If the function has been minified and NODE_ENV !== 'production', warn the user. 1368 */ 1369 1370 function isCrushed() {} 1371 1372 if (false) {} 1373 1374 1375 1376 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js 1377 var equivalent_key_map = __webpack_require__("FtRg"); 1378 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map); 1379 1380 // EXTERNAL MODULE: external ["wp","reduxRoutine"] 1381 var external_wp_reduxRoutine_ = __webpack_require__("XIDh"); 1382 var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_); 1383 1384 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js 1385 /** 1386 * Creates a selector function that takes additional curried argument with the 1387 * registry `select` function. While a regular selector has signature 1388 * ```js 1389 * ( state, ...selectorArgs ) => ( result ) 1390 * ``` 1391 * that allows to select data from the store's `state`, a registry selector 1392 * has signature: 1393 * ```js 1394 * ( select ) => ( state, ...selectorArgs ) => ( result ) 1395 * ``` 1396 * that supports also selecting from other registered stores. 1397 * 1398 * @example 1399 * ```js 1400 * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => { 1401 * return select( 'core/editor' ).getCurrentPostId(); 1402 * } ); 1403 * 1404 * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => { 1405 * // calling another registry selector just like any other function 1406 * const postType = getCurrentPostType( state ); 1407 * const postId = getCurrentPostId( state ); 1408 * return select( 'core' ).getEntityRecordEdits( 'postType', postType, postId ); 1409 * } ); 1410 * ``` 1411 * 1412 * Note how the `getCurrentPostId` selector can be called just like any other function, 1413 * (it works even inside a regular non-registry selector) and we don't need to pass the 1414 * registry as argument. The registry binding happens automatically when registering the selector 1415 * with a store. 1416 * 1417 * @param {Function} registrySelector Function receiving a registry `select` 1418 * function and returning a state selector. 1419 * 1420 * @return {Function} Registry selector that can be registered with a store. 1421 */ 1422 function createRegistrySelector(registrySelector) { 1423 // create a selector function that is bound to the registry referenced by `selector.registry` 1424 // and that has the same API as a regular selector. Binding it in such a way makes it 1425 // possible to call the selector directly from another selector. 1426 const selector = (...args) => registrySelector(selector.registry.select)(...args); 1427 /** 1428 * Flag indicating that the selector is a registry selector that needs the correct registry 1429 * reference to be assigned to `selecto.registry` to make it work correctly. 1430 * be mapped as a registry selector. 1431 * 1432 * @type {boolean} 1433 */ 1434 1435 1436 selector.isRegistrySelector = true; 1437 return selector; 1438 } 1439 /** 1440 * Creates a control function that takes additional curried argument with the `registry` object. 1441 * While a regular control has signature 1442 * ```js 1443 * ( action ) => ( iteratorOrPromise ) 1444 * ``` 1445 * where the control works with the `action` that it's bound to, a registry control has signature: 1446 * ```js 1447 * ( registry ) => ( action ) => ( iteratorOrPromise ) 1448 * ``` 1449 * A registry control is typically used to select data or dispatch an action to a registered 1450 * store. 1451 * 1452 * When registering a control created with `createRegistryControl` with a store, the store 1453 * knows which calling convention to use when executing the control. 1454 * 1455 * @param {Function} registryControl Function receiving a registry object and returning a control. 1456 * 1457 * @return {Function} Registry control that can be registered with a store. 1458 */ 1459 1460 function createRegistryControl(registryControl) { 1461 registryControl.isRegistryControl = true; 1462 return registryControl; 1463 } 1464 1465 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js 1466 /** 1467 * Internal dependencies 1468 */ 1469 1470 const SELECT = '@@data/SELECT'; 1471 const RESOLVE_SELECT = '@@data/RESOLVE_SELECT'; 1472 const DISPATCH = '@@data/DISPATCH'; 1473 /** 1474 * Dispatches a control action for triggering a synchronous registry select. 1475 * 1476 * Note: This control synchronously returns the current selector value, triggering the 1477 * resolution, but not waiting for it. 1478 * 1479 * @param {string} storeKey The key for the store the selector belongs to. 1480 * @param {string} selectorName The name of the selector. 1481 * @param {Array} args Arguments for the selector. 1482 * 1483 * @example 1484 * ```js 1485 * import { controls } from '@wordpress/data'; 1486 * 1487 * // Action generator using `select`. 1488 * export function* myAction() { 1489 * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' ); 1490 * // Do stuff with the result from the `select`. 1491 * } 1492 * ``` 1493 * 1494 * @return {Object} The control descriptor. 1495 */ 1496 1497 function controls_select(storeKey, selectorName, ...args) { 1498 return { 1499 type: SELECT, 1500 storeKey, 1501 selectorName, 1502 args 1503 }; 1504 } 1505 /** 1506 * Dispatches a control action for triggering and resolving a registry select. 1507 * 1508 * Note: when this control action is handled, it automatically considers 1509 * selectors that may have a resolver. In such case, it will return a `Promise` that resolves 1510 * after the selector finishes resolving, with the final result value. 1511 * 1512 * @param {string} storeKey The key for the store the selector belongs to 1513 * @param {string} selectorName The name of the selector 1514 * @param {Array} args Arguments for the selector. 1515 * 1516 * @example 1517 * ```js 1518 * import { controls } from '@wordpress/data'; 1519 * 1520 * // Action generator using resolveSelect 1521 * export function* myAction() { 1522 * const isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' ); 1523 * // do stuff with the result from the select. 1524 * } 1525 * ``` 1526 * 1527 * @return {Object} The control descriptor. 1528 */ 1529 1530 1531 function controls_resolveSelect(storeKey, selectorName, ...args) { 1532 return { 1533 type: RESOLVE_SELECT, 1534 storeKey, 1535 selectorName, 1536 args 1537 }; 1538 } 1539 /** 1540 * Dispatches a control action for triggering a registry dispatch. 1541 * 1542 * @param {string} storeKey The key for the store the action belongs to 1543 * @param {string} actionName The name of the action to dispatch 1544 * @param {Array} args Arguments for the dispatch action. 1545 * 1546 * @example 1547 * ```js 1548 * import { controls } from '@wordpress/data-controls'; 1549 * 1550 * // Action generator using dispatch 1551 * export function* myAction() { 1552 * yield controls.dispatch( 'core/edit-post', 'togglePublishSidebar' ); 1553 * // do some other things. 1554 * } 1555 * ``` 1556 * 1557 * @return {Object} The control descriptor. 1558 */ 1559 1560 1561 function controls_dispatch(storeKey, actionName, ...args) { 1562 return { 1563 type: DISPATCH, 1564 storeKey, 1565 actionName, 1566 args 1567 }; 1568 } 1569 1570 const controls_controls = { 1571 select: controls_select, 1572 resolveSelect: controls_resolveSelect, 1573 dispatch: controls_dispatch 1574 }; 1575 const builtinControls = { 1576 [SELECT]: createRegistryControl(registry => ({ 1577 storeKey, 1578 selectorName, 1579 args 1580 }) => registry.select(storeKey)[selectorName](...args)), 1581 [RESOLVE_SELECT]: createRegistryControl(registry => ({ 1582 storeKey, 1583 selectorName, 1584 args 1585 }) => { 1586 const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select'; 1587 return registry[method](storeKey)[selectorName](...args); 1588 }), 1589 [DISPATCH]: createRegistryControl(registry => ({ 1590 storeKey, 1591 actionName, 1592 args 1593 }) => registry.dispatch(storeKey)[actionName](...args)) 1594 }; 1595 1596 // EXTERNAL MODULE: ./node_modules/is-promise/index.js 1597 var is_promise = __webpack_require__("JlUD"); 1598 var is_promise_default = /*#__PURE__*/__webpack_require__.n(is_promise); 1599 1600 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js 1601 /** 1602 * External dependencies 1603 */ 1604 1605 /** 1606 * Simplest possible promise redux middleware. 1607 * 1608 * @return {Function} middleware. 1609 */ 1610 1611 const promiseMiddleware = () => next => action => { 1612 if (is_promise_default()(action)) { 1613 return action.then(resolvedAction => { 1614 if (resolvedAction) { 1615 return next(resolvedAction); 1616 } 1617 }); 1618 } 1619 1620 return next(action); 1621 }; 1622 1623 /* harmony default export */ var promise_middleware = (promiseMiddleware); 1624 1625 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js 1626 /** 1627 * External dependencies 1628 */ 1629 1630 /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ 1631 1632 /** 1633 * Creates a middleware handling resolvers cache invalidation. 1634 * 1635 * @param {WPDataRegistry} registry The registry reference for which to create 1636 * the middleware. 1637 * @param {string} reducerKey The namespace for which to create the 1638 * middleware. 1639 * 1640 * @return {Function} Middleware function. 1641 */ 1642 1643 const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => { 1644 const resolvers = registry.select('core/data').getCachedResolvers(reducerKey); 1645 Object.entries(resolvers).forEach(([selectorName, resolversByArgs]) => { 1646 const resolver = Object(external_lodash_["get"])(registry.stores, [reducerKey, 'resolvers', selectorName]); 1647 1648 if (!resolver || !resolver.shouldInvalidate) { 1649 return; 1650 } 1651 1652 resolversByArgs.forEach((value, args) => { 1653 // resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector. 1654 // If the value is false it means this resolver has finished its resolution which means we need to invalidate it, 1655 // if it's true it means it's inflight and the invalidation is not necessary. 1656 if (value !== false || !resolver.shouldInvalidate(action, ...args)) { 1657 return; 1658 } // Trigger cache invalidation 1659 1660 1661 registry.dispatch('core/data').invalidateResolution(reducerKey, selectorName, args); 1662 }); 1663 }); 1664 return next(action); 1665 }; 1666 1667 /* harmony default export */ var resolvers_cache_middleware = (createResolversCacheMiddleware); 1668 1669 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js 1670 function createThunkMiddleware(args) { 1671 return () => next => action => { 1672 if (typeof action === 'function') { 1673 return action(args); 1674 } 1675 1676 return next(action); 1677 }; 1678 } 1679 1680 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js 1681 /** 1682 * Higher-order reducer creator which creates a combined reducer object, keyed 1683 * by a property on the action object. 1684 * 1685 * @param {string} actionProperty Action property by which to key object. 1686 * 1687 * @return {Function} Higher-order reducer. 1688 */ 1689 const onSubKey = actionProperty => reducer => (state = {}, action) => { 1690 // Retrieve subkey from action. Do not track if undefined; useful for cases 1691 // where reducer is scoped by action shape. 1692 const key = action[actionProperty]; 1693 1694 if (key === undefined) { 1695 return state; 1696 } // Avoid updating state if unchanged. Note that this also accounts for a 1697 // reducer which returns undefined on a key which is not yet tracked. 1698 1699 1700 const nextKeyState = reducer(state[key], action); 1701 1702 if (nextKeyState === state[key]) { 1703 return state; 1704 } 1705 1706 return { ...state, 1707 [key]: nextKeyState 1708 }; 1709 }; 1710 1711 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js 1712 /** 1713 * External dependencies 1714 */ 1715 1716 1717 /** 1718 * Internal dependencies 1719 */ 1720 1721 1722 /** 1723 * Reducer function returning next state for selector resolution of 1724 * subkeys, object form: 1725 * 1726 * selectorName -> EquivalentKeyMap<Array,boolean> 1727 * 1728 * @param {Object} state Current state. 1729 * @param {Object} action Dispatched action. 1730 * 1731 * @return {Object} Next state. 1732 */ 1733 1734 const subKeysIsResolved = onSubKey('selectorName')((state = new equivalent_key_map_default.a(), action) => { 1735 switch (action.type) { 1736 case 'START_RESOLUTION': 1737 case 'FINISH_RESOLUTION': 1738 { 1739 const isStarting = action.type === 'START_RESOLUTION'; 1740 const nextState = new equivalent_key_map_default.a(state); 1741 nextState.set(action.args, isStarting); 1742 return nextState; 1743 } 1744 1745 case 'START_RESOLUTIONS': 1746 case 'FINISH_RESOLUTIONS': 1747 { 1748 const isStarting = action.type === 'START_RESOLUTIONS'; 1749 const nextState = new equivalent_key_map_default.a(state); 1750 1751 for (const resolutionArgs of action.args) { 1752 nextState.set(resolutionArgs, isStarting); 1753 } 1754 1755 return nextState; 1756 } 1757 1758 case 'INVALIDATE_RESOLUTION': 1759 { 1760 const nextState = new equivalent_key_map_default.a(state); 1761 nextState.delete(action.args); 1762 return nextState; 1763 } 1764 } 1765 1766 return state; 1767 }); 1768 /** 1769 * Reducer function returning next state for selector resolution, object form: 1770 * 1771 * selectorName -> EquivalentKeyMap<Array, boolean> 1772 * 1773 * @param {Object} state Current state. 1774 * @param {Object} action Dispatched action. 1775 * 1776 * @return {Object} Next state. 1777 */ 1778 1779 const isResolved = (state = {}, action) => { 1780 switch (action.type) { 1781 case 'INVALIDATE_RESOLUTION_FOR_STORE': 1782 return {}; 1783 1784 case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': 1785 return Object(external_lodash_["has"])(state, [action.selectorName]) ? Object(external_lodash_["omit"])(state, [action.selectorName]) : state; 1786 1787 case 'START_RESOLUTION': 1788 case 'FINISH_RESOLUTION': 1789 case 'START_RESOLUTIONS': 1790 case 'FINISH_RESOLUTIONS': 1791 case 'INVALIDATE_RESOLUTION': 1792 return subKeysIsResolved(state, action); 1793 } 1794 1795 return state; 1796 }; 1797 1798 /* harmony default export */ var metadata_reducer = (isResolved); 1799 1800 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js 1801 /** 1802 * External dependencies 1803 */ 1804 1805 /** 1806 * Returns the raw `isResolving` value for a given selector name, 1807 * and arguments set. May be undefined if the selector has never been resolved 1808 * or not resolved for the given set of arguments, otherwise true or false for 1809 * resolution started and completed respectively. 1810 * 1811 * @param {Object} state Data state. 1812 * @param {string} selectorName Selector name. 1813 * @param {Array} args Arguments passed to selector. 1814 * 1815 * @return {?boolean} isResolving value. 1816 */ 1817 1818 function getIsResolving(state, selectorName, args) { 1819 const map = Object(external_lodash_["get"])(state, [selectorName]); 1820 1821 if (!map) { 1822 return; 1823 } 1824 1825 return map.get(args); 1826 } 1827 /** 1828 * Returns true if resolution has already been triggered for a given 1829 * selector name, and arguments set. 1830 * 1831 * @param {Object} state Data state. 1832 * @param {string} selectorName Selector name. 1833 * @param {?Array} args Arguments passed to selector (default `[]`). 1834 * 1835 * @return {boolean} Whether resolution has been triggered. 1836 */ 1837 1838 function hasStartedResolution(state, selectorName, args = []) { 1839 return getIsResolving(state, selectorName, args) !== undefined; 1840 } 1841 /** 1842 * Returns true if resolution has completed for a given selector 1843 * name, and arguments set. 1844 * 1845 * @param {Object} state Data state. 1846 * @param {string} selectorName Selector name. 1847 * @param {?Array} args Arguments passed to selector. 1848 * 1849 * @return {boolean} Whether resolution has completed. 1850 */ 1851 1852 function hasFinishedResolution(state, selectorName, args = []) { 1853 return getIsResolving(state, selectorName, args) === false; 1854 } 1855 /** 1856 * Returns true if resolution has been triggered but has not yet completed for 1857 * a given selector name, and arguments set. 1858 * 1859 * @param {Object} state Data state. 1860 * @param {string} selectorName Selector name. 1861 * @param {?Array} args Arguments passed to selector. 1862 * 1863 * @return {boolean} Whether resolution is in progress. 1864 */ 1865 1866 function isResolving(state, selectorName, args = []) { 1867 return getIsResolving(state, selectorName, args) === true; 1868 } 1869 /** 1870 * Returns the list of the cached resolvers. 1871 * 1872 * @param {Object} state Data state. 1873 * 1874 * @return {Object} Resolvers mapped by args and selectorName. 1875 */ 1876 1877 function getCachedResolvers(state) { 1878 return state; 1879 } 1880 1881 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js 1882 /** 1883 * Returns an action object used in signalling that selector resolution has 1884 * started. 1885 * 1886 * @param {string} selectorName Name of selector for which resolver triggered. 1887 * @param {...*} args Arguments to associate for uniqueness. 1888 * 1889 * @return {Object} Action object. 1890 */ 1891 function startResolution(selectorName, args) { 1892 return { 1893 type: 'START_RESOLUTION', 1894 selectorName, 1895 args 1896 }; 1897 } 1898 /** 1899 * Returns an action object used in signalling that selector resolution has 1900 * completed. 1901 * 1902 * @param {string} selectorName Name of selector for which resolver triggered. 1903 * @param {...*} args Arguments to associate for uniqueness. 1904 * 1905 * @return {Object} Action object. 1906 */ 1907 1908 function finishResolution(selectorName, args) { 1909 return { 1910 type: 'FINISH_RESOLUTION', 1911 selectorName, 1912 args 1913 }; 1914 } 1915 /** 1916 * Returns an action object used in signalling that a batch of selector resolutions has 1917 * started. 1918 * 1919 * @param {string} selectorName Name of selector for which resolver triggered. 1920 * @param {...*} args Array of arguments to associate for uniqueness, each item 1921 * is associated to a resolution. 1922 * 1923 * @return {Object} Action object. 1924 */ 1925 1926 function startResolutions(selectorName, args) { 1927 return { 1928 type: 'START_RESOLUTIONS', 1929 selectorName, 1930 args 1931 }; 1932 } 1933 /** 1934 * Returns an action object used in signalling that a batch of selector resolutions has 1935 * completed. 1936 * 1937 * @param {string} selectorName Name of selector for which resolver triggered. 1938 * @param {...*} args Array of arguments to associate for uniqueness, each item 1939 * is associated to a resolution. 1940 * 1941 * @return {Object} Action object. 1942 */ 1943 1944 function finishResolutions(selectorName, args) { 1945 return { 1946 type: 'FINISH_RESOLUTIONS', 1947 selectorName, 1948 args 1949 }; 1950 } 1951 /** 1952 * Returns an action object used in signalling that we should invalidate the resolution cache. 1953 * 1954 * @param {string} selectorName Name of selector for which resolver should be invalidated. 1955 * @param {Array} args Arguments to associate for uniqueness. 1956 * 1957 * @return {Object} Action object. 1958 */ 1959 1960 function invalidateResolution(selectorName, args) { 1961 return { 1962 type: 'INVALIDATE_RESOLUTION', 1963 selectorName, 1964 args 1965 }; 1966 } 1967 /** 1968 * Returns an action object used in signalling that the resolution 1969 * should be invalidated. 1970 * 1971 * @return {Object} Action object. 1972 */ 1973 1974 function invalidateResolutionForStore() { 1975 return { 1976 type: 'INVALIDATE_RESOLUTION_FOR_STORE' 1977 }; 1978 } 1979 /** 1980 * Returns an action object used in signalling that the resolution cache for a 1981 * given selectorName should be invalidated. 1982 * 1983 * @param {string} selectorName Name of selector for which all resolvers should 1984 * be invalidated. 1985 * 1986 * @return {Object} Action object. 1987 */ 1988 1989 function invalidateResolutionForStoreSelector(selectorName) { 1990 return { 1991 type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', 1992 selectorName 1993 }; 1994 } 1995 1996 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js 1997 /** 1998 * External dependencies 1999 */ 2000 2001 2002 2003 2004 /** 2005 * WordPress dependencies 2006 */ 2007 2008 2009 /** 2010 * Internal dependencies 2011 */ 2012 2013 2014 2015 2016 2017 2018 2019 2020 /** @typedef {import('../types').WPDataRegistry} WPDataRegistry */ 2021 2022 /** @typedef {import('../types').WPDataStore} WPDataStore */ 2023 2024 /** @typedef {import('../types').WPDataReduxStoreConfig} WPDataReduxStoreConfig */ 2025 2026 /** 2027 * Create a cache to track whether resolvers started running or not. 2028 * 2029 * @return {Object} Resolvers Cache. 2030 */ 2031 2032 function createResolversCache() { 2033 const cache = {}; 2034 return { 2035 isRunning(selectorName, args) { 2036 return cache[selectorName] && cache[selectorName].get(args); 2037 }, 2038 2039 clear(selectorName, args) { 2040 if (cache[selectorName]) { 2041 cache[selectorName].delete(args); 2042 } 2043 }, 2044 2045 markAsRunning(selectorName, args) { 2046 if (!cache[selectorName]) { 2047 cache[selectorName] = new equivalent_key_map_default.a(); 2048 } 2049 2050 cache[selectorName].set(args, true); 2051 } 2052 2053 }; 2054 } 2055 /** 2056 * Creates a data store definition for the provided Redux store options containing 2057 * properties describing reducer, actions, selectors, controls and resolvers. 2058 * 2059 * @example 2060 * ```js 2061 * import { createReduxStore } from '@wordpress/data'; 2062 * 2063 * const store = createReduxStore( 'demo', { 2064 * reducer: ( state = 'OK' ) => state, 2065 * selectors: { 2066 * getValue: ( state ) => state, 2067 * }, 2068 * } ); 2069 * ``` 2070 * 2071 * @param {string} key Unique namespace identifier. 2072 * @param {WPDataReduxStoreConfig} options Registered store options, with properties 2073 * describing reducer, actions, selectors, 2074 * and resolvers. 2075 * 2076 * @return {WPDataStore} Store Object. 2077 */ 2078 2079 2080 function createReduxStore(key, options) { 2081 return { 2082 name: key, 2083 instantiate: registry => { 2084 const reducer = options.reducer; 2085 const thunkArgs = { 2086 registry, 2087 2088 get dispatch() { 2089 return Object.assign(action => store.dispatch(action), getActions()); 2090 }, 2091 2092 get select() { 2093 return Object.assign(selector => selector(store.__unstableOriginalGetState()), getSelectors()); 2094 }, 2095 2096 get resolveSelect() { 2097 return getResolveSelectors(); 2098 } 2099 2100 }; 2101 const store = instantiateReduxStore(key, options, registry, thunkArgs); 2102 const resolversCache = createResolversCache(); 2103 let resolvers; 2104 const actions = mapActions({ ...actions_namespaceObject, 2105 ...options.actions 2106 }, store); 2107 let selectors = mapSelectors({ ...Object(external_lodash_["mapValues"])(selectors_namespaceObject, selector => (state, ...args) => selector(state.metadata, ...args)), 2108 ...Object(external_lodash_["mapValues"])(options.selectors, selector => { 2109 if (selector.isRegistrySelector) { 2110 selector.registry = registry; 2111 } 2112 2113 return (state, ...args) => selector(state.root, ...args); 2114 }) 2115 }, store); 2116 2117 if (options.resolvers) { 2118 const result = mapResolvers(options.resolvers, selectors, store, resolversCache); 2119 resolvers = result.resolvers; 2120 selectors = result.selectors; 2121 } 2122 2123 const resolveSelectors = mapResolveSelectors(selectors, store); 2124 2125 const getSelectors = () => selectors; 2126 2127 const getActions = () => actions; 2128 2129 const getResolveSelectors = () => resolveSelectors; // We have some modules monkey-patching the store object 2130 // It's wrong to do so but until we refactor all of our effects to controls 2131 // We need to keep the same "store" instance here. 2132 2133 2134 store.__unstableOriginalGetState = store.getState; 2135 2136 store.getState = () => store.__unstableOriginalGetState().root; // Customize subscribe behavior to call listeners only on effective change, 2137 // not on every dispatch. 2138 2139 2140 const subscribe = store && (listener => { 2141 let lastState = store.__unstableOriginalGetState(); 2142 2143 return store.subscribe(() => { 2144 const state = store.__unstableOriginalGetState(); 2145 2146 const hasChanged = state !== lastState; 2147 lastState = state; 2148 2149 if (hasChanged) { 2150 listener(); 2151 } 2152 }); 2153 }); // This can be simplified to just { subscribe, getSelectors, getActions } 2154 // Once we remove the use function. 2155 2156 2157 return { 2158 reducer, 2159 store, 2160 actions, 2161 selectors, 2162 resolvers, 2163 getSelectors, 2164 getResolveSelectors, 2165 getActions, 2166 subscribe 2167 }; 2168 } 2169 }; 2170 } 2171 /** 2172 * Creates a redux store for a namespace. 2173 * 2174 * @param {string} key Unique namespace identifier. 2175 * @param {Object} options Registered store options, with properties 2176 * describing reducer, actions, selectors, 2177 * and resolvers. 2178 * @param {WPDataRegistry} registry Registry reference. 2179 * @param {Object} thunkArgs Argument object for the thunk middleware. 2180 * @return {Object} Newly created redux store. 2181 */ 2182 2183 function instantiateReduxStore(key, options, registry, thunkArgs) { 2184 const controls = { ...options.controls, 2185 ...builtinControls 2186 }; 2187 const normalizedControls = Object(external_lodash_["mapValues"])(controls, control => control.isRegistryControl ? control(registry) : control); 2188 const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls)]; 2189 2190 if (options.__experimentalUseThunks) { 2191 middlewares.push(createThunkMiddleware(thunkArgs)); 2192 } 2193 2194 const enhancers = [applyMiddleware(...middlewares)]; 2195 2196 if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) { 2197 enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({ 2198 name: key, 2199 instanceId: key 2200 })); 2201 } 2202 2203 const { 2204 reducer, 2205 initialState 2206 } = options; 2207 const enhancedReducer = turbo_combine_reducers_default()({ 2208 metadata: metadata_reducer, 2209 root: reducer 2210 }); 2211 return redux_createStore(enhancedReducer, { 2212 root: initialState 2213 }, Object(external_lodash_["flowRight"])(enhancers)); 2214 } 2215 /** 2216 * Maps selectors to a store. 2217 * 2218 * @param {Object} selectors Selectors to register. Keys will be used as the 2219 * public facing API. Selectors will get passed the 2220 * state as first argument. 2221 * @param {Object} store The store to which the selectors should be mapped. 2222 * @return {Object} Selectors mapped to the provided store. 2223 */ 2224 2225 2226 function mapSelectors(selectors, store) { 2227 const createStateSelector = registrySelector => { 2228 const selector = function runSelector() { 2229 // This function is an optimized implementation of: 2230 // 2231 // selector( store.getState(), ...arguments ) 2232 // 2233 // Where the above would incur an `Array#concat` in its application, 2234 // the logic here instead efficiently constructs an arguments array via 2235 // direct assignment. 2236 const argsLength = arguments.length; 2237 const args = new Array(argsLength + 1); 2238 args[0] = store.__unstableOriginalGetState(); 2239 2240 for (let i = 0; i < argsLength; i++) { 2241 args[i + 1] = arguments[i]; 2242 } 2243 2244 return registrySelector(...args); 2245 }; 2246 2247 selector.hasResolver = false; 2248 return selector; 2249 }; 2250 2251 return Object(external_lodash_["mapValues"])(selectors, createStateSelector); 2252 } 2253 /** 2254 * Maps actions to dispatch from a given store. 2255 * 2256 * @param {Object} actions Actions to register. 2257 * @param {Object} store The redux store to which the actions should be mapped. 2258 * @return {Object} Actions mapped to the redux store provided. 2259 */ 2260 2261 2262 function mapActions(actions, store) { 2263 const createBoundAction = action => (...args) => { 2264 return Promise.resolve(store.dispatch(action(...args))); 2265 }; 2266 2267 return Object(external_lodash_["mapValues"])(actions, createBoundAction); 2268 } 2269 /** 2270 * Maps selectors to functions that return a resolution promise for them 2271 * 2272 * @param {Object} selectors Selectors to map. 2273 * @param {Object} store The redux store the selectors select from. 2274 * @return {Object} Selectors mapped to their resolution functions. 2275 */ 2276 2277 2278 function mapResolveSelectors(selectors, store) { 2279 return Object(external_lodash_["mapValues"])(Object(external_lodash_["omit"])(selectors, ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers']), (selector, selectorName) => (...args) => new Promise(resolve => { 2280 const hasFinished = () => selectors.hasFinishedResolution(selectorName, args); 2281 2282 const getResult = () => selector.apply(null, args); // trigger the selector (to trigger the resolver) 2283 2284 2285 const result = getResult(); 2286 2287 if (hasFinished()) { 2288 return resolve(result); 2289 } 2290 2291 const unsubscribe = store.subscribe(() => { 2292 if (hasFinished()) { 2293 unsubscribe(); 2294 resolve(getResult()); 2295 } 2296 }); 2297 })); 2298 } 2299 /** 2300 * Returns resolvers with matched selectors for a given namespace. 2301 * Resolvers are side effects invoked once per argument set of a given selector call, 2302 * used in ensuring that the data needs for the selector are satisfied. 2303 * 2304 * @param {Object} resolvers Resolvers to register. 2305 * @param {Object} selectors The current selectors to be modified. 2306 * @param {Object} store The redux store to which the resolvers should be mapped. 2307 * @param {Object} resolversCache Resolvers Cache. 2308 */ 2309 2310 2311 function mapResolvers(resolvers, selectors, store, resolversCache) { 2312 // The `resolver` can be either a function that does the resolution, or, in more advanced 2313 // cases, an object with a `fullfill` method and other optional methods like `isFulfilled`. 2314 // Here we normalize the `resolver` function to an object with `fulfill` method. 2315 const mappedResolvers = Object(external_lodash_["mapValues"])(resolvers, resolver => { 2316 if (resolver.fulfill) { 2317 return resolver; 2318 } 2319 2320 return { ...resolver, 2321 // copy the enumerable properties of the resolver function 2322 fulfill: resolver // add the fulfill method 2323 2324 }; 2325 }); 2326 2327 const mapSelector = (selector, selectorName) => { 2328 const resolver = resolvers[selectorName]; 2329 2330 if (!resolver) { 2331 selector.hasResolver = false; 2332 return selector; 2333 } 2334 2335 const selectorResolver = (...args) => { 2336 async function fulfillSelector() { 2337 const state = store.getState(); 2338 2339 if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) { 2340 return; 2341 } 2342 2343 const { 2344 metadata 2345 } = store.__unstableOriginalGetState(); 2346 2347 if (hasStartedResolution(metadata, selectorName, args)) { 2348 return; 2349 } 2350 2351 resolversCache.markAsRunning(selectorName, args); 2352 setTimeout(async () => { 2353 resolversCache.clear(selectorName, args); 2354 store.dispatch(startResolution(selectorName, args)); 2355 await fulfillResolver(store, mappedResolvers, selectorName, ...args); 2356 store.dispatch(finishResolution(selectorName, args)); 2357 }); 2358 } 2359 2360 fulfillSelector(...args); 2361 return selector(...args); 2362 }; 2363 2364 selectorResolver.hasResolver = true; 2365 return selectorResolver; 2366 }; 2367 2368 return { 2369 resolvers: mappedResolvers, 2370 selectors: Object(external_lodash_["mapValues"])(selectors, mapSelector) 2371 }; 2372 } 2373 /** 2374 * Calls a resolver given arguments 2375 * 2376 * @param {Object} store Store reference, for fulfilling via resolvers 2377 * @param {Object} resolvers Store Resolvers 2378 * @param {string} selectorName Selector name to fulfill. 2379 * @param {Array} args Selector Arguments. 2380 */ 2381 2382 2383 async function fulfillResolver(store, resolvers, selectorName, ...args) { 2384 const resolver = Object(external_lodash_["get"])(resolvers, [selectorName]); 2385 2386 if (!resolver) { 2387 return; 2388 } 2389 2390 const action = resolver.fulfill(...args); 2391 2392 if (action) { 2393 await store.dispatch(action); 2394 } 2395 } 2396 2397 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js 2398 function createCoreDataStore(registry) { 2399 const getCoreDataSelector = selectorName => (key, ...args) => { 2400 return registry.select(key)[selectorName](...args); 2401 }; 2402 2403 const getCoreDataAction = actionName => (key, ...args) => { 2404 return registry.dispatch(key)[actionName](...args); 2405 }; 2406 2407 return { 2408 getSelectors() { 2409 return ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].reduce((memo, selectorName) => ({ ...memo, 2410 [selectorName]: getCoreDataSelector(selectorName) 2411 }), {}); 2412 }, 2413 2414 getActions() { 2415 return ['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].reduce((memo, actionName) => ({ ...memo, 2416 [actionName]: getCoreDataAction(actionName) 2417 }), {}); 2418 }, 2419 2420 subscribe() { 2421 // There's no reasons to trigger any listener when we subscribe to this store 2422 // because there's no state stored in this store that need to retrigger selectors 2423 // if a change happens, the corresponding store where the tracking stated live 2424 // would have already triggered a "subscribe" call. 2425 return () => {}; 2426 } 2427 2428 }; 2429 } 2430 2431 /* harmony default export */ var build_module_store = (createCoreDataStore); 2432 2433 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js 2434 /** 2435 * External dependencies 2436 */ 2437 2438 /** 2439 * Internal dependencies 2440 */ 2441 2442 2443 2444 /** @typedef {import('./types').WPDataStore} WPDataStore */ 2445 2446 /** 2447 * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations. 2448 * 2449 * @property {Function} registerGenericStore Given a namespace key and settings 2450 * object, registers a new generic 2451 * store. 2452 * @property {Function} registerStore Given a namespace key and settings 2453 * object, registers a new namespace 2454 * store. 2455 * @property {Function} subscribe Given a function callback, invokes 2456 * the callback on any change to state 2457 * within any registered store. 2458 * @property {Function} select Given a namespace key, returns an 2459 * object of the store's registered 2460 * selectors. 2461 * @property {Function} dispatch Given a namespace key, returns an 2462 * object of the store's registered 2463 * action dispatchers. 2464 */ 2465 2466 /** 2467 * @typedef {Object} WPDataPlugin An object of registry function overrides. 2468 * 2469 * @property {Function} registerStore registers store. 2470 */ 2471 2472 /** 2473 * Creates a new store registry, given an optional object of initial store 2474 * configurations. 2475 * 2476 * @param {Object} storeConfigs Initial store configurations. 2477 * @param {Object?} parent Parent registry. 2478 * 2479 * @return {WPDataRegistry} Data registry. 2480 */ 2481 2482 function createRegistry(storeConfigs = {}, parent = null) { 2483 const stores = {}; 2484 let listeners = []; 2485 2486 const __experimentalListeningStores = new Set(); 2487 /** 2488 * Global listener called for each store's update. 2489 */ 2490 2491 2492 function globalListener() { 2493 listeners.forEach(listener => listener()); 2494 } 2495 /** 2496 * Subscribe to changes to any data. 2497 * 2498 * @param {Function} listener Listener function. 2499 * 2500 * @return {Function} Unsubscribe function. 2501 */ 2502 2503 2504 const subscribe = listener => { 2505 listeners.push(listener); 2506 return () => { 2507 listeners = Object(external_lodash_["without"])(listeners, listener); 2508 }; 2509 }; 2510 /** 2511 * Calls a selector given the current state and extra arguments. 2512 * 2513 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store 2514 * or the store definition. 2515 * 2516 * @return {*} The selector's returned value. 2517 */ 2518 2519 2520 function select(storeNameOrDefinition) { 2521 const storeName = Object(external_lodash_["isObject"])(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; 2522 2523 __experimentalListeningStores.add(storeName); 2524 2525 const store = stores[storeName]; 2526 2527 if (store) { 2528 return store.getSelectors(); 2529 } 2530 2531 return parent && parent.select(storeName); 2532 } 2533 2534 function __experimentalMarkListeningStores(callback, ref) { 2535 __experimentalListeningStores.clear(); 2536 2537 const result = callback.call(this); 2538 ref.current = Array.from(__experimentalListeningStores); 2539 return result; 2540 } 2541 /** 2542 * Given the name of a registered store, returns an object containing the store's 2543 * selectors pre-bound to state so that you only need to supply additional arguments, 2544 * and modified so that they return promises that resolve to their eventual values, 2545 * after any resolvers have ran. 2546 * 2547 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store 2548 * or the store definition. 2549 * 2550 * @return {Object} Each key of the object matches the name of a selector. 2551 */ 2552 2553 2554 function resolveSelect(storeNameOrDefinition) { 2555 const storeName = Object(external_lodash_["isObject"])(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; 2556 2557 __experimentalListeningStores.add(storeName); 2558 2559 const store = stores[storeName]; 2560 2561 if (store) { 2562 return store.getResolveSelectors(); 2563 } 2564 2565 return parent && parent.resolveSelect(storeName); 2566 } 2567 /** 2568 * Returns the available actions for a part of the state. 2569 * 2570 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store 2571 * or the store definition. 2572 * 2573 * @return {*} The action's returned value. 2574 */ 2575 2576 2577 function dispatch(storeNameOrDefinition) { 2578 const storeName = Object(external_lodash_["isObject"])(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; 2579 const store = stores[storeName]; 2580 2581 if (store) { 2582 return store.getActions(); 2583 } 2584 2585 return parent && parent.dispatch(storeName); 2586 } // 2587 // Deprecated 2588 // TODO: Remove this after `use()` is removed. 2589 // 2590 2591 2592 function withPlugins(attributes) { 2593 return Object(external_lodash_["mapValues"])(attributes, (attribute, key) => { 2594 if (typeof attribute !== 'function') { 2595 return attribute; 2596 } 2597 2598 return function () { 2599 return registry[key].apply(null, arguments); 2600 }; 2601 }); 2602 } 2603 /** 2604 * Registers a generic store. 2605 * 2606 * @param {string} key Store registry key. 2607 * @param {Object} config Configuration (getSelectors, getActions, subscribe). 2608 */ 2609 2610 2611 function registerGenericStore(key, config) { 2612 if (typeof config.getSelectors !== 'function') { 2613 throw new TypeError('config.getSelectors must be a function'); 2614 } 2615 2616 if (typeof config.getActions !== 'function') { 2617 throw new TypeError('config.getActions must be a function'); 2618 } 2619 2620 if (typeof config.subscribe !== 'function') { 2621 throw new TypeError('config.subscribe must be a function'); 2622 } 2623 2624 stores[key] = config; 2625 config.subscribe(globalListener); 2626 } 2627 /** 2628 * Registers a new store definition. 2629 * 2630 * @param {WPDataStore} store Store definition. 2631 */ 2632 2633 2634 function register(store) { 2635 registerGenericStore(store.name, store.instantiate(registry)); 2636 } 2637 /** 2638 * Subscribe handler to a store. 2639 * 2640 * @param {string[]} storeName The store name. 2641 * @param {Function} handler The function subscribed to the store. 2642 * @return {Function} A function to unsubscribe the handler. 2643 */ 2644 2645 2646 function __experimentalSubscribeStore(storeName, handler) { 2647 if (storeName in stores) { 2648 return stores[storeName].subscribe(handler); 2649 } // Trying to access a store that hasn't been registered, 2650 // this is a pattern rarely used but seen in some places. 2651 // We fallback to regular `subscribe` here for backward-compatibility for now. 2652 // See https://github.com/WordPress/gutenberg/pull/27466 for more info. 2653 2654 2655 if (!parent) { 2656 return subscribe(handler); 2657 } 2658 2659 return parent.__experimentalSubscribeStore(storeName, handler); 2660 } 2661 2662 let registry = { 2663 registerGenericStore, 2664 stores, 2665 namespaces: stores, 2666 // TODO: Deprecate/remove this. 2667 subscribe, 2668 select, 2669 resolveSelect, 2670 dispatch, 2671 use, 2672 register, 2673 __experimentalMarkListeningStores, 2674 __experimentalSubscribeStore 2675 }; 2676 /** 2677 * Registers a standard `@wordpress/data` store. 2678 * 2679 * @param {string} storeName Unique namespace identifier. 2680 * @param {Object} options Store description (reducer, actions, selectors, resolvers). 2681 * 2682 * @return {Object} Registered store object. 2683 */ 2684 2685 registry.registerStore = (storeName, options) => { 2686 if (!options.reducer) { 2687 throw new TypeError('Must specify store reducer'); 2688 } 2689 2690 const store = createReduxStore(storeName, options).instantiate(registry); 2691 registerGenericStore(storeName, store); 2692 return store.store; 2693 }; // 2694 // TODO: 2695 // This function will be deprecated as soon as it is no longer internally referenced. 2696 // 2697 2698 2699 function use(plugin, options) { 2700 registry = { ...registry, 2701 ...plugin(registry, options) 2702 }; 2703 return registry; 2704 } 2705 2706 registerGenericStore('core/data', build_module_store(registry)); 2707 Object.entries(storeConfigs).forEach(([name, config]) => registry.registerStore(name, config)); 2708 2709 if (parent) { 2710 parent.subscribe(globalListener); 2711 } 2712 2713 return withPlugins(registry); 2714 } 2715 2716 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js 2717 /** 2718 * Internal dependencies 2719 */ 2720 2721 /* harmony default export */ var default_registry = (createRegistry()); 2722 2723 // EXTERNAL MODULE: external ["wp","deprecated"] 2724 var external_wp_deprecated_ = __webpack_require__("NMb1"); 2725 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_); 2726 2727 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/controls/index.js 2728 /** 2729 * WordPress dependencies 2730 */ 2731 2732 /* harmony default export */ var plugins_controls = (registry => { 2733 external_wp_deprecated_default()('wp.data.plugins.controls', { 2734 since: '5.4', 2735 hint: 'The controls plugins is now baked-in.' 2736 }); 2737 return registry; 2738 }); 2739 2740 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js 2741 let objectStorage; 2742 const storage = { 2743 getItem(key) { 2744 if (!objectStorage || !objectStorage[key]) { 2745 return null; 2746 } 2747 2748 return objectStorage[key]; 2749 }, 2750 2751 setItem(key, value) { 2752 if (!objectStorage) { 2753 storage.clear(); 2754 } 2755 2756 objectStorage[key] = String(value); 2757 }, 2758 2759 clear() { 2760 objectStorage = Object.create(null); 2761 } 2762 2763 }; 2764 /* harmony default export */ var object = (storage); 2765 2766 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js 2767 /** 2768 * Internal dependencies 2769 */ 2770 2771 let default_storage; 2772 2773 try { 2774 // Private Browsing in Safari 10 and earlier will throw an error when 2775 // attempting to set into localStorage. The test here is intentional in 2776 // causing a thrown error as condition for using fallback object storage. 2777 default_storage = window.localStorage; 2778 default_storage.setItem('__wpDataTestLocalStorage', ''); 2779 default_storage.removeItem('__wpDataTestLocalStorage'); 2780 } catch (error) { 2781 default_storage = object; 2782 } 2783 2784 /* harmony default export */ var storage_default = (default_storage); 2785 2786 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js 2787 /** 2788 * External dependencies 2789 */ 2790 2791 /** 2792 * Internal dependencies 2793 */ 2794 2795 2796 2797 /** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */ 2798 2799 /** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */ 2800 2801 /** 2802 * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options. 2803 * 2804 * @property {Storage} storage Persistent storage implementation. This must 2805 * at least implement `getItem` and `setItem` of 2806 * the Web Storage API. 2807 * @property {string} storageKey Key on which to set in persistent storage. 2808 * 2809 */ 2810 2811 /** 2812 * Default plugin storage. 2813 * 2814 * @type {Storage} 2815 */ 2816 2817 const DEFAULT_STORAGE = storage_default; 2818 /** 2819 * Default plugin storage key. 2820 * 2821 * @type {string} 2822 */ 2823 2824 const DEFAULT_STORAGE_KEY = 'WP_DATA'; 2825 /** 2826 * Higher-order reducer which invokes the original reducer only if state is 2827 * inequal from that of the action's `nextState` property, otherwise returning 2828 * the original state reference. 2829 * 2830 * @param {Function} reducer Original reducer. 2831 * 2832 * @return {Function} Enhanced reducer. 2833 */ 2834 2835 const withLazySameState = reducer => (state, action) => { 2836 if (action.nextState === state) { 2837 return state; 2838 } 2839 2840 return reducer(state, action); 2841 }; 2842 /** 2843 * Creates a persistence interface, exposing getter and setter methods (`get` 2844 * and `set` respectively). 2845 * 2846 * @param {WPDataPersistencePluginOptions} options Plugin options. 2847 * 2848 * @return {Object} Persistence interface. 2849 */ 2850 2851 function createPersistenceInterface(options) { 2852 const { 2853 storage = DEFAULT_STORAGE, 2854 storageKey = DEFAULT_STORAGE_KEY 2855 } = options; 2856 let data; 2857 /** 2858 * Returns the persisted data as an object, defaulting to an empty object. 2859 * 2860 * @return {Object} Persisted data. 2861 */ 2862 2863 function getData() { 2864 if (data === undefined) { 2865 // If unset, getItem is expected to return null. Fall back to 2866 // empty object. 2867 const persisted = storage.getItem(storageKey); 2868 2869 if (persisted === null) { 2870 data = {}; 2871 } else { 2872 try { 2873 data = JSON.parse(persisted); 2874 } catch (error) { 2875 // Similarly, should any error be thrown during parse of 2876 // the string (malformed JSON), fall back to empty object. 2877 data = {}; 2878 } 2879 } 2880 } 2881 2882 return data; 2883 } 2884 /** 2885 * Merges an updated reducer state into the persisted data. 2886 * 2887 * @param {string} key Key to update. 2888 * @param {*} value Updated value. 2889 */ 2890 2891 2892 function setData(key, value) { 2893 data = { ...data, 2894 [key]: value 2895 }; 2896 storage.setItem(storageKey, JSON.stringify(data)); 2897 } 2898 2899 return { 2900 get: getData, 2901 set: setData 2902 }; 2903 } 2904 /** 2905 * Data plugin to persist store state into a single storage key. 2906 * 2907 * @param {WPDataRegistry} registry Data registry. 2908 * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options. 2909 * 2910 * @return {WPDataPlugin} Data plugin. 2911 */ 2912 2913 function persistencePlugin(registry, pluginOptions) { 2914 const persistence = createPersistenceInterface(pluginOptions); 2915 /** 2916 * Creates an enhanced store dispatch function, triggering the state of the 2917 * given store name to be persisted when changed. 2918 * 2919 * @param {Function} getState Function which returns current state. 2920 * @param {string} storeName Store name. 2921 * @param {?Array<string>} keys Optional subset of keys to save. 2922 * 2923 * @return {Function} Enhanced dispatch function. 2924 */ 2925 2926 function createPersistOnChange(getState, storeName, keys) { 2927 let getPersistedState; 2928 2929 if (Array.isArray(keys)) { 2930 // Given keys, the persisted state should by produced as an object 2931 // of the subset of keys. This implementation uses combineReducers 2932 // to leverage its behavior of returning the same object when none 2933 // of the property values changes. This allows a strict reference 2934 // equality to bypass a persistence set on an unchanging state. 2935 const reducers = keys.reduce((accumulator, key) => Object.assign(accumulator, { 2936 [key]: (state, action) => action.nextState[key] 2937 }), {}); 2938 getPersistedState = withLazySameState(turbo_combine_reducers_default()(reducers)); 2939 } else { 2940 getPersistedState = (state, action) => action.nextState; 2941 } 2942 2943 let lastState = getPersistedState(undefined, { 2944 nextState: getState() 2945 }); 2946 return () => { 2947 const state = getPersistedState(lastState, { 2948 nextState: getState() 2949 }); 2950 2951 if (state !== lastState) { 2952 persistence.set(storeName, state); 2953 lastState = state; 2954 } 2955 }; 2956 } 2957 2958 return { 2959 registerStore(storeName, options) { 2960 if (!options.persist) { 2961 return registry.registerStore(storeName, options); 2962 } // Load from persistence to use as initial state. 2963 2964 2965 const persistedState = persistence.get()[storeName]; 2966 2967 if (persistedState !== undefined) { 2968 let initialState = options.reducer(options.initialState, { 2969 type: '@@WP/PERSISTENCE_RESTORE' 2970 }); 2971 2972 if (Object(external_lodash_["isPlainObject"])(initialState) && Object(external_lodash_["isPlainObject"])(persistedState)) { 2973 // If state is an object, ensure that: 2974 // - Other keys are left intact when persisting only a 2975 // subset of keys. 2976 // - New keys in what would otherwise be used as initial 2977 // state are deeply merged as base for persisted value. 2978 initialState = Object(external_lodash_["merge"])({}, initialState, persistedState); 2979 } else { 2980 // If there is a mismatch in object-likeness of default 2981 // initial or persisted state, defer to persisted value. 2982 initialState = persistedState; 2983 } 2984 2985 options = { ...options, 2986 initialState 2987 }; 2988 } 2989 2990 const store = registry.registerStore(storeName, options); 2991 store.subscribe(createPersistOnChange(store.getState, storeName, options.persist)); 2992 return store; 2993 } 2994 2995 }; 2996 } 2997 /** 2998 * Deprecated: Remove this function and the code in WordPress Core that calls 2999 * it once WordPress 5.4 is released. 3000 */ 3001 3002 3003 persistencePlugin.__unstableMigrate = pluginOptions => { 3004 var _state$coreEditor, _state$coreEditor$pre; 3005 3006 const persistence = createPersistenceInterface(pluginOptions); 3007 const state = persistence.get(); // Migrate 'insertUsage' from 'core/editor' to 'core/block-editor' 3008 3009 const editorInsertUsage = (_state$coreEditor = state['core/editor']) === null || _state$coreEditor === void 0 ? void 0 : (_state$coreEditor$pre = _state$coreEditor.preferences) === null || _state$coreEditor$pre === void 0 ? void 0 : _state$coreEditor$pre.insertUsage; 3010 3011 if (editorInsertUsage) { 3012 var _state$coreBlockEdi, _state$coreBlockEdi$p; 3013 3014 const blockEditorInsertUsage = (_state$coreBlockEdi = state['core/block-editor']) === null || _state$coreBlockEdi === void 0 ? void 0 : (_state$coreBlockEdi$p = _state$coreBlockEdi.preferences) === null || _state$coreBlockEdi$p === void 0 ? void 0 : _state$coreBlockEdi$p.insertUsage; 3015 persistence.set('core/block-editor', { 3016 preferences: { 3017 insertUsage: { ...editorInsertUsage, 3018 ...blockEditorInsertUsage 3019 } 3020 } 3021 }); 3022 } 3023 3024 let editPostState = state['core/edit-post']; // Default `fullscreenMode` to `false` if any persisted state had existed 3025 // and the user hadn't made an explicit choice about fullscreen mode. This 3026 // is needed since `fullscreenMode` previously did not have a default value 3027 // and was implicitly false by its absence. It is now `true` by default, but 3028 // this change is not intended to affect upgrades from earlier versions. 3029 3030 const hadPersistedState = Object.keys(state).length > 0; 3031 const hadFullscreenModePreference = Object(external_lodash_["has"])(state, ['core/edit-post', 'preferences', 'features', 'fullscreenMode']); 3032 3033 if (hadPersistedState && !hadFullscreenModePreference) { 3034 editPostState = Object(external_lodash_["merge"])({}, editPostState, { 3035 preferences: { 3036 features: { 3037 fullscreenMode: false 3038 } 3039 } 3040 }); 3041 } // Migrate 'areTipsEnabled' from 'core/nux' to 'showWelcomeGuide' in 'core/edit-post' 3042 3043 3044 const areTipsEnabled = Object(external_lodash_["get"])(state, ['core/nux', 'preferences', 'areTipsEnabled']); 3045 const hasWelcomeGuide = Object(external_lodash_["has"])(state, ['core/edit-post', 'preferences', 'features', 'welcomeGuide']); 3046 3047 if (areTipsEnabled !== undefined && !hasWelcomeGuide) { 3048 editPostState = Object(external_lodash_["merge"])({}, editPostState, { 3049 preferences: { 3050 features: { 3051 welcomeGuide: areTipsEnabled 3052 } 3053 } 3054 }); 3055 } 3056 3057 if (editPostState !== state['core/edit-post']) { 3058 persistence.set('core/edit-post', editPostState); 3059 } 3060 }; 3061 3062 /* harmony default export */ var plugins_persistence = (persistencePlugin); 3063 3064 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js 3065 3066 3067 3068 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js 3069 var esm_extends = __webpack_require__("wx14"); 3070 3071 // EXTERNAL MODULE: external ["wp","element"] 3072 var external_wp_element_ = __webpack_require__("GRId"); 3073 3074 // EXTERNAL MODULE: external ["wp","compose"] 3075 var external_wp_compose_ = __webpack_require__("K9lf"); 3076 3077 // EXTERNAL MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js 3078 var use_memo_one_esm = __webpack_require__("mHlH"); 3079 3080 // EXTERNAL MODULE: external ["wp","priorityQueue"] 3081 var external_wp_priorityQueue_ = __webpack_require__("XI5e"); 3082 3083 // EXTERNAL MODULE: external ["wp","isShallowEqual"] 3084 var external_wp_isShallowEqual_ = __webpack_require__("rl8x"); 3085 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_); 3086 3087 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js 3088 /** 3089 * WordPress dependencies 3090 */ 3091 3092 /** 3093 * Internal dependencies 3094 */ 3095 3096 3097 const Context = Object(external_wp_element_["createContext"])(default_registry); 3098 const { 3099 Consumer, 3100 Provider 3101 } = Context; 3102 /** 3103 * A custom react Context consumer exposing the provided `registry` to 3104 * children components. Used along with the RegistryProvider. 3105 * 3106 * You can read more about the react context api here: 3107 * https://reactjs.org/docs/context.html#contextprovider 3108 * 3109 * @example 3110 * ```js 3111 * import { 3112 * RegistryProvider, 3113 * RegistryConsumer, 3114 * createRegistry 3115 * } from '@wordpress/data'; 3116 * 3117 * const registry = createRegistry( {} ); 3118 * 3119 * const App = ( { props } ) => { 3120 * return <RegistryProvider value={ registry }> 3121 * <div>Hello There</div> 3122 * <RegistryConsumer> 3123 * { ( registry ) => ( 3124 * <ComponentUsingRegistry 3125 * { ...props } 3126 * registry={ registry } 3127 * ) } 3128 * </RegistryConsumer> 3129 * </RegistryProvider> 3130 * } 3131 * ``` 3132 */ 3133 3134 const RegistryConsumer = Consumer; 3135 /** 3136 * A custom Context provider for exposing the provided `registry` to children 3137 * components via a consumer. 3138 * 3139 * See <a name="#RegistryConsumer">RegistryConsumer</a> documentation for 3140 * example. 3141 */ 3142 3143 /* harmony default export */ var context = (Provider); 3144 3145 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js 3146 /** 3147 * WordPress dependencies 3148 */ 3149 3150 /** 3151 * Internal dependencies 3152 */ 3153 3154 3155 /** 3156 * A custom react hook exposing the registry context for use. 3157 * 3158 * This exposes the `registry` value provided via the 3159 * <a href="#RegistryProvider">Registry Provider</a> to a component implementing 3160 * this hook. 3161 * 3162 * It acts similarly to the `useContext` react hook. 3163 * 3164 * Note: Generally speaking, `useRegistry` is a low level hook that in most cases 3165 * won't be needed for implementation. Most interactions with the `@wordpress/data` 3166 * API can be performed via the `useSelect` hook, or the `withSelect` and 3167 * `withDispatch` higher order components. 3168 * 3169 * @example 3170 * ```js 3171 * import { 3172 * RegistryProvider, 3173 * createRegistry, 3174 * useRegistry, 3175 * } from '@wordpress/data'; 3176 * 3177 * const registry = createRegistry( {} ); 3178 * 3179 * const SomeChildUsingRegistry = ( props ) => { 3180 * const registry = useRegistry( registry ); 3181 * // ...logic implementing the registry in other react hooks. 3182 * }; 3183 * 3184 * 3185 * const ParentProvidingRegistry = ( props ) => { 3186 * return <RegistryProvider value={ registry }> 3187 * <SomeChildUsingRegistry { ...props } /> 3188 * </RegistryProvider> 3189 * }; 3190 * ``` 3191 * 3192 * @return {Function} A custom react hook exposing the registry context value. 3193 */ 3194 3195 function useRegistry() { 3196 return Object(external_wp_element_["useContext"])(Context); 3197 } 3198 3199 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js 3200 /** 3201 * WordPress dependencies 3202 */ 3203 3204 const context_Context = Object(external_wp_element_["createContext"])(false); 3205 const { 3206 Consumer: context_Consumer, 3207 Provider: context_Provider 3208 } = context_Context; 3209 const AsyncModeConsumer = context_Consumer; 3210 /** 3211 * Context Provider Component used to switch the data module component rerendering 3212 * between Sync and Async modes. 3213 * 3214 * @example 3215 * 3216 * ```js 3217 * import { useSelect, AsyncModeProvider } from '@wordpress/data'; 3218 * 3219 * function BlockCount() { 3220 * const count = useSelect( ( select ) => { 3221 * return select( 'core/block-editor' ).getBlockCount() 3222 * }, [] ); 3223 * 3224 * return count; 3225 * } 3226 * 3227 * function App() { 3228 * return ( 3229 * <AsyncModeProvider value={ true }> 3230 * <BlockCount /> 3231 * </AsyncModeProvider> 3232 * ); 3233 * } 3234 * ``` 3235 * 3236 * In this example, the BlockCount component is rerendered asynchronously. 3237 * It means if a more critical task is being performed (like typing in an input), 3238 * the rerendering is delayed until the browser becomes IDLE. 3239 * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior. 3240 * 3241 * @param {boolean} props.value Enable Async Mode. 3242 * @return {WPComponent} The component to be rendered. 3243 */ 3244 3245 /* harmony default export */ var async_mode_provider_context = (context_Provider); 3246 3247 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js 3248 /** 3249 * WordPress dependencies 3250 */ 3251 3252 /** 3253 * Internal dependencies 3254 */ 3255 3256 3257 function useAsyncMode() { 3258 return Object(external_wp_element_["useContext"])(context_Context); 3259 } 3260 3261 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js 3262 /** 3263 * External dependencies 3264 */ 3265 3266 /** 3267 * WordPress dependencies 3268 */ 3269 3270 3271 3272 3273 3274 /** 3275 * Internal dependencies 3276 */ 3277 3278 3279 3280 const renderQueue = Object(external_wp_priorityQueue_["createQueue"])(); 3281 /** @typedef {import('./types').WPDataStore} WPDataStore */ 3282 3283 /** 3284 * Custom react hook for retrieving props from registered selectors. 3285 * 3286 * In general, this custom React hook follows the 3287 * [rules of hooks](https://reactjs.org/docs/hooks-rules.html). 3288 * 3289 * @param {Function|WPDataStore|string} _mapSelect Function called on every state change. The 3290 * returned value is exposed to the component 3291 * implementing this hook. The function receives 3292 * the `registry.select` method on the first 3293 * argument and the `registry` on the second 3294 * argument. 3295 * When a store key is passed, all selectors for 3296 * the store will be returned. This is only meant 3297 * for usage of these selectors in event 3298 * callbacks, not for data needed to create the 3299 * element tree. 3300 * @param {Array} deps If provided, this memoizes the mapSelect so the 3301 * same `mapSelect` is invoked on every state 3302 * change unless the dependencies change. 3303 * 3304 * @example 3305 * ```js 3306 * import { useSelect } from '@wordpress/data'; 3307 * 3308 * function HammerPriceDisplay( { currency } ) { 3309 * const price = useSelect( ( select ) => { 3310 * return select( 'my-shop' ).getPrice( 'hammer', currency ) 3311 * }, [ currency ] ); 3312 * return new Intl.NumberFormat( 'en-US', { 3313 * style: 'currency', 3314 * currency, 3315 * } ).format( price ); 3316 * } 3317 * 3318 * // Rendered in the application: 3319 * // <HammerPriceDisplay currency="USD" /> 3320 * ``` 3321 * 3322 * In the above example, when `HammerPriceDisplay` is rendered into an 3323 * application, the price will be retrieved from the store state using the 3324 * `mapSelect` callback on `useSelect`. If the currency prop changes then 3325 * any price in the state for that currency is retrieved. If the currency prop 3326 * doesn't change and other props are passed in that do change, the price will 3327 * not change because the dependency is just the currency. 3328 * 3329 * When data is only used in an event callback, the data should not be retrieved 3330 * on render, so it may be useful to get the selectors function instead. 3331 * 3332 * **Don't use `useSelect` this way when calling the selectors in the render 3333 * function because your component won't re-render on a data change.** 3334 * 3335 * ```js 3336 * import { useSelect } from '@wordpress/data'; 3337 * 3338 * function Paste( { children } ) { 3339 * const { getSettings } = useSelect( 'my-shop' ); 3340 * function onPaste() { 3341 * // Do something with the settings. 3342 * const settings = getSettings(); 3343 * } 3344 * return <div onPaste={ onPaste }>{ children }</div>; 3345 * } 3346 * ``` 3347 * 3348 * @return {Function} A custom react hook. 3349 */ 3350 3351 function useSelect(_mapSelect, deps) { 3352 const isWithoutMapping = typeof _mapSelect !== 'function'; 3353 3354 if (isWithoutMapping) { 3355 deps = []; 3356 } 3357 3358 const mapSelect = Object(external_wp_element_["useCallback"])(_mapSelect, deps); 3359 const registry = useRegistry(); 3360 const isAsync = useAsyncMode(); // React can sometimes clear the `useMemo` cache. 3361 // We use the cache-stable `useMemoOne` to avoid 3362 // losing queues. 3363 3364 const queueContext = Object(use_memo_one_esm["a" /* useMemoOne */])(() => ({ 3365 queue: true 3366 }), [registry]); 3367 const [, forceRender] = Object(external_wp_element_["useReducer"])(s => s + 1, 0); 3368 const latestMapSelect = Object(external_wp_element_["useRef"])(); 3369 const latestIsAsync = Object(external_wp_element_["useRef"])(isAsync); 3370 const latestMapOutput = Object(external_wp_element_["useRef"])(); 3371 const latestMapOutputError = Object(external_wp_element_["useRef"])(); 3372 const isMountedAndNotUnsubscribing = Object(external_wp_element_["useRef"])(); // Keep track of the stores being selected in the mapSelect function, 3373 // and only subscribe to those stores later. 3374 3375 const listeningStores = Object(external_wp_element_["useRef"])([]); 3376 const trapSelect = Object(external_wp_element_["useCallback"])(callback => registry.__experimentalMarkListeningStores(callback, listeningStores), [registry]); // Generate a "flag" for used in the effect dependency array. 3377 // It's different than just using `mapSelect` since deps could be undefined, 3378 // in that case, we would still want to memoize it. 3379 3380 const depsChangedFlag = Object(external_wp_element_["useMemo"])(() => ({}), deps || []); 3381 let mapOutput; 3382 3383 if (!isWithoutMapping) { 3384 try { 3385 if (latestMapSelect.current !== mapSelect || latestMapOutputError.current) { 3386 mapOutput = trapSelect(() => mapSelect(registry.select, registry)); 3387 } else { 3388 mapOutput = latestMapOutput.current; 3389 } 3390 } catch (error) { 3391 let errorMessage = `An error occurred while running 'mapSelect': ${error.message}`; 3392 3393 if (latestMapOutputError.current) { 3394 errorMessage += `\nThe error may be correlated with this previous error:\n`; 3395 errorMessage += `${latestMapOutputError.current.stack}\n\n`; 3396 errorMessage += 'Original stack trace:'; 3397 } // eslint-disable-next-line no-console 3398 3399 3400 console.error(errorMessage); 3401 mapOutput = latestMapOutput.current; 3402 } 3403 } 3404 3405 Object(external_wp_compose_["useIsomorphicLayoutEffect"])(() => { 3406 if (isWithoutMapping) { 3407 return; 3408 } 3409 3410 latestMapSelect.current = mapSelect; 3411 latestMapOutput.current = mapOutput; 3412 latestMapOutputError.current = undefined; 3413 isMountedAndNotUnsubscribing.current = true; // This has to run after the other ref updates 3414 // to avoid using stale values in the flushed 3415 // callbacks or potentially overwriting a 3416 // changed `latestMapOutput.current`. 3417 3418 if (latestIsAsync.current !== isAsync) { 3419 latestIsAsync.current = isAsync; 3420 renderQueue.flush(queueContext); 3421 } 3422 }); 3423 Object(external_wp_compose_["useIsomorphicLayoutEffect"])(() => { 3424 if (isWithoutMapping) { 3425 return; 3426 } 3427 3428 const onStoreChange = () => { 3429 if (isMountedAndNotUnsubscribing.current) { 3430 try { 3431 const newMapOutput = trapSelect(() => latestMapSelect.current(registry.select, registry)); 3432 3433 if (external_wp_isShallowEqual_default()(latestMapOutput.current, newMapOutput)) { 3434 return; 3435 } 3436 3437 latestMapOutput.current = newMapOutput; 3438 } catch (error) { 3439 latestMapOutputError.current = error; 3440 } 3441 3442 forceRender(); 3443 } 3444 }; // catch any possible state changes during mount before the subscription 3445 // could be set. 3446 3447 3448 if (latestIsAsync.current) { 3449 renderQueue.add(queueContext, onStoreChange); 3450 } else { 3451 onStoreChange(); 3452 } 3453 3454 const onChange = () => { 3455 if (latestIsAsync.current) { 3456 renderQueue.add(queueContext, onStoreChange); 3457 } else { 3458 onStoreChange(); 3459 } 3460 }; 3461 3462 const unsubscribers = listeningStores.current.map(storeName => registry.__experimentalSubscribeStore(storeName, onChange)); 3463 return () => { 3464 isMountedAndNotUnsubscribing.current = false; // The return value of the subscribe function could be undefined if the store is a custom generic store. 3465 3466 unsubscribers.forEach(unsubscribe => unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe()); 3467 renderQueue.flush(queueContext); 3468 }; 3469 }, [registry, trapSelect, depsChangedFlag, isWithoutMapping]); 3470 return isWithoutMapping ? registry.select(_mapSelect) : mapOutput; 3471 } 3472 3473 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js 3474 3475 3476 3477 /** 3478 * WordPress dependencies 3479 */ 3480 3481 /** 3482 * Internal dependencies 3483 */ 3484 3485 3486 /** 3487 * Higher-order component used to inject state-derived props using registered 3488 * selectors. 3489 * 3490 * @param {Function} mapSelectToProps Function called on every state change, 3491 * expected to return object of props to 3492 * merge with the component's own props. 3493 * 3494 * @example 3495 * ```js 3496 * import { withSelect } from '@wordpress/data'; 3497 * 3498 * function PriceDisplay( { price, currency } ) { 3499 * return new Intl.NumberFormat( 'en-US', { 3500 * style: 'currency', 3501 * currency, 3502 * } ).format( price ); 3503 * } 3504 * 3505 * const HammerPriceDisplay = withSelect( ( select, ownProps ) => { 3506 * const { getPrice } = select( 'my-shop' ); 3507 * const { currency } = ownProps; 3508 * 3509 * return { 3510 * price: getPrice( 'hammer', currency ), 3511 * }; 3512 * } )( PriceDisplay ); 3513 * 3514 * // Rendered in the application: 3515 * // 3516 * // <HammerPriceDisplay currency="USD" /> 3517 * ``` 3518 * In the above example, when `HammerPriceDisplay` is rendered into an 3519 * application, it will pass the price into the underlying `PriceDisplay` 3520 * component and update automatically if the price of a hammer ever changes in 3521 * the store. 3522 * 3523 * @return {WPComponent} Enhanced component with merged state data props. 3524 */ 3525 3526 const withSelect = mapSelectToProps => Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => Object(external_wp_compose_["pure"])(ownProps => { 3527 const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry); 3528 3529 const mergeProps = useSelect(mapSelect); 3530 return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, ownProps, mergeProps)); 3531 }), 'withSelect'); 3532 3533 /* harmony default export */ var with_select = (withSelect); 3534 3535 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js 3536 /** 3537 * External dependencies 3538 */ 3539 3540 /** 3541 * WordPress dependencies 3542 */ 3543 3544 3545 3546 /** 3547 * Internal dependencies 3548 */ 3549 3550 3551 /** 3552 * Custom react hook for returning aggregate dispatch actions using the provided 3553 * dispatchMap. 3554 * 3555 * Currently this is an internal api only and is implemented by `withDispatch` 3556 * 3557 * @param {Function} dispatchMap Receives the `registry.dispatch` function as 3558 * the first argument and the `registry` object 3559 * as the second argument. Should return an 3560 * object mapping props to functions. 3561 * @param {Array} deps An array of dependencies for the hook. 3562 * @return {Object} An object mapping props to functions created by the passed 3563 * in dispatchMap. 3564 */ 3565 3566 const useDispatchWithMap = (dispatchMap, deps) => { 3567 const registry = useRegistry(); 3568 const currentDispatchMap = Object(external_wp_element_["useRef"])(dispatchMap); 3569 Object(external_wp_compose_["useIsomorphicLayoutEffect"])(() => { 3570 currentDispatchMap.current = dispatchMap; 3571 }); 3572 return Object(external_wp_element_["useMemo"])(() => { 3573 const currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry); 3574 return Object(external_lodash_["mapValues"])(currentDispatchProps, (dispatcher, propName) => { 3575 if (typeof dispatcher !== 'function') { 3576 // eslint-disable-next-line no-console 3577 console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`); 3578 } 3579 3580 return (...args) => currentDispatchMap.current(registry.dispatch, registry)[propName](...args); 3581 }); 3582 }, [registry, ...deps]); 3583 }; 3584 3585 /* harmony default export */ var use_dispatch_with_map = (useDispatchWithMap); 3586 3587 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js 3588 3589 3590 3591 /** 3592 * WordPress dependencies 3593 */ 3594 3595 /** 3596 * Internal dependencies 3597 */ 3598 3599 3600 /** 3601 * Higher-order component used to add dispatch props using registered action 3602 * creators. 3603 * 3604 * @param {Function} mapDispatchToProps A function of returning an object of 3605 * prop names where value is a 3606 * dispatch-bound action creator, or a 3607 * function to be called with the 3608 * component's props and returning an 3609 * action creator. 3610 * 3611 * @example 3612 * ```jsx 3613 * function Button( { onClick, children } ) { 3614 * return <button type="button" onClick={ onClick }>{ children }</button>; 3615 * } 3616 * 3617 * import { withDispatch } from '@wordpress/data'; 3618 * 3619 * const SaleButton = withDispatch( ( dispatch, ownProps ) => { 3620 * const { startSale } = dispatch( 'my-shop' ); 3621 * const { discountPercent } = ownProps; 3622 * 3623 * return { 3624 * onClick() { 3625 * startSale( discountPercent ); 3626 * }, 3627 * }; 3628 * } )( Button ); 3629 * 3630 * // Rendered in the application: 3631 * // 3632 * // <SaleButton discountPercent="20">Start Sale!</SaleButton> 3633 * ``` 3634 * 3635 * @example 3636 * In the majority of cases, it will be sufficient to use only two first params 3637 * passed to `mapDispatchToProps` as illustrated in the previous example. 3638 * However, there might be some very advanced use cases where using the 3639 * `registry` object might be used as a tool to optimize the performance of 3640 * your component. Using `select` function from the registry might be useful 3641 * when you need to fetch some dynamic data from the store at the time when the 3642 * event is fired, but at the same time, you never use it to render your 3643 * component. In such scenario, you can avoid using the `withSelect` higher 3644 * order component to compute such prop, which might lead to unnecessary 3645 * re-renders of your component caused by its frequent value change. 3646 * Keep in mind, that `mapDispatchToProps` must return an object with functions 3647 * only. 3648 * 3649 * ```jsx 3650 * function Button( { onClick, children } ) { 3651 * return <button type="button" onClick={ onClick }>{ children }</button>; 3652 * } 3653 * 3654 * import { withDispatch } from '@wordpress/data'; 3655 * 3656 * const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => { 3657 * // Stock number changes frequently. 3658 * const { getStockNumber } = select( 'my-shop' ); 3659 * const { startSale } = dispatch( 'my-shop' ); 3660 * return { 3661 * onClick() { 3662 * const discountPercent = getStockNumber() > 50 ? 10 : 20; 3663 * startSale( discountPercent ); 3664 * }, 3665 * }; 3666 * } )( Button ); 3667 * 3668 * // Rendered in the application: 3669 * // 3670 * // <SaleButton>Start Sale!</SaleButton> 3671 * ``` 3672 * 3673 * _Note:_ It is important that the `mapDispatchToProps` function always 3674 * returns an object with the same keys. For example, it should not contain 3675 * conditions under which a different value would be returned. 3676 * 3677 * @return {WPComponent} Enhanced component with merged dispatcher props. 3678 */ 3679 3680 const withDispatch = mapDispatchToProps => Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => ownProps => { 3681 const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry); 3682 3683 const dispatchProps = use_dispatch_with_map(mapDispatch, []); 3684 return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, ownProps, dispatchProps)); 3685 }, 'withDispatch'); 3686 3687 /* harmony default export */ var with_dispatch = (withDispatch); 3688 3689 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js 3690 3691 3692 3693 /** 3694 * WordPress dependencies 3695 */ 3696 3697 /** 3698 * Internal dependencies 3699 */ 3700 3701 3702 /** 3703 * Higher-order component which renders the original component with the current 3704 * registry context passed as its `registry` prop. 3705 * 3706 * @param {WPComponent} OriginalComponent Original component. 3707 * 3708 * @return {WPComponent} Enhanced component. 3709 */ 3710 3711 const withRegistry = Object(external_wp_compose_["createHigherOrderComponent"])(OriginalComponent => props => Object(external_wp_element_["createElement"])(RegistryConsumer, null, registry => Object(external_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, { 3712 registry: registry 3713 }))), 'withRegistry'); 3714 /* harmony default export */ var with_registry = (withRegistry); 3715 3716 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js 3717 /** 3718 * Internal dependencies 3719 */ 3720 3721 /** @typedef {import('./types').WPDataStore} WPDataStore */ 3722 3723 /** 3724 * A custom react hook returning the current registry dispatch actions creators. 3725 * 3726 * Note: The component using this hook must be within the context of a 3727 * RegistryProvider. 3728 * 3729 * @param {string|WPDataStore} [storeNameOrDefinition] Optionally provide the name of the 3730 * store or its definition from which to 3731 * retrieve action creators. If not 3732 * provided, the registry.dispatch 3733 * function is returned instead. 3734 * 3735 * @example 3736 * This illustrates a pattern where you may need to retrieve dynamic data from 3737 * the server via the `useSelect` hook to use in combination with the dispatch 3738 * action. 3739 * 3740 * ```jsx 3741 * import { useDispatch, useSelect } from '@wordpress/data'; 3742 * import { useCallback } from '@wordpress/element'; 3743 * 3744 * function Button( { onClick, children } ) { 3745 * return <button type="button" onClick={ onClick }>{ children }</button> 3746 * } 3747 * 3748 * const SaleButton = ( { children } ) => { 3749 * const { stockNumber } = useSelect( 3750 * ( select ) => select( 'my-shop' ).getStockNumber(), 3751 * [] 3752 * ); 3753 * const { startSale } = useDispatch( 'my-shop' ); 3754 * const onClick = useCallback( () => { 3755 * const discountPercent = stockNumber > 50 ? 10: 20; 3756 * startSale( discountPercent ); 3757 * }, [ stockNumber ] ); 3758 * return <Button onClick={ onClick }>{ children }</Button> 3759 * } 3760 * 3761 * // Rendered somewhere in the application: 3762 * // 3763 * // <SaleButton>Start Sale!</SaleButton> 3764 * ``` 3765 * @return {Function} A custom react hook. 3766 */ 3767 3768 const useDispatch = storeNameOrDefinition => { 3769 const { 3770 dispatch 3771 } = useRegistry(); 3772 return storeNameOrDefinition === void 0 ? dispatch : dispatch(storeNameOrDefinition); 3773 }; 3774 3775 /* harmony default export */ var use_dispatch = (useDispatch); 3776 3777 // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js 3778 /** 3779 * External dependencies 3780 */ 3781 3782 /** 3783 * Internal dependencies 3784 */ 3785 3786 3787 3788 /** @typedef {import('./types').WPDataStore} WPDataStore */ 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 /** 3802 * Object of available plugins to use with a registry. 3803 * 3804 * @see [use](#use) 3805 * 3806 * @type {Object} 3807 */ 3808 3809 3810 /** 3811 * The combineReducers helper function turns an object whose values are different 3812 * reducing functions into a single reducing function you can pass to registerReducer. 3813 * 3814 * @param {Object} reducers An object whose values correspond to different reducing 3815 * functions that need to be combined into one. 3816 * 3817 * @example 3818 * ```js 3819 * import { combineReducers, createReduxStore, register } from '@wordpress/data'; 3820 * 3821 * const prices = ( state = {}, action ) => { 3822 * return action.type === 'SET_PRICE' ? 3823 * { 3824 * ...state, 3825 * [ action.item ]: action.price, 3826 * } : 3827 * state; 3828 * }; 3829 * 3830 * const discountPercent = ( state = 0, action ) => { 3831 * return action.type === 'START_SALE' ? 3832 * action.discountPercent : 3833 * state; 3834 * }; 3835 * 3836 * const store = createReduxStore( 'my-shop', { 3837 * reducer: combineReducers( { 3838 * prices, 3839 * discountPercent, 3840 * } ), 3841 * } ); 3842 * register( store ); 3843 * ``` 3844 * 3845 * @return {Function} A reducer that invokes every reducer inside the reducers 3846 * object, and constructs a state object with the same shape. 3847 */ 3848 3849 3850 /** 3851 * Given the name or definition of a registered store, returns an object of the store's selectors. 3852 * The selector functions are been pre-bound to pass the current state automatically. 3853 * As a consumer, you need only pass arguments of the selector, if applicable. 3854 * 3855 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store 3856 * or the store definition. 3857 * 3858 * @example 3859 * ```js 3860 * import { select } from '@wordpress/data'; 3861 * 3862 * select( 'my-shop' ).getPrice( 'hammer' ); 3863 * ``` 3864 * 3865 * @return {Object} Object containing the store's selectors. 3866 */ 3867 3868 const build_module_select = default_registry.select; 3869 /** 3870 * Given the name of a registered store, returns an object containing the store's 3871 * selectors pre-bound to state so that you only need to supply additional arguments, 3872 * and modified so that they return promises that resolve to their eventual values, 3873 * after any resolvers have ran. 3874 * 3875 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store 3876 * or the store definition. 3877 * 3878 * @example 3879 * ```js 3880 * import { resolveSelect } from '@wordpress/data'; 3881 * 3882 * resolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log) 3883 * ``` 3884 * 3885 * @return {Object} Object containing the store's promise-wrapped selectors. 3886 */ 3887 3888 const build_module_resolveSelect = default_registry.resolveSelect; 3889 /** 3890 * Given the name of a registered store, returns an object of the store's action creators. 3891 * Calling an action creator will cause it to be dispatched, updating the state value accordingly. 3892 * 3893 * Note: Action creators returned by the dispatch will return a promise when 3894 * they are called. 3895 * 3896 * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store 3897 * or the store definition. 3898 * 3899 * @example 3900 * ```js 3901 * import { dispatch } from '@wordpress/data'; 3902 * 3903 * dispatch( 'my-shop' ).setPrice( 'hammer', 9.75 ); 3904 * ``` 3905 * @return {Object} Object containing the action creators. 3906 */ 3907 3908 const build_module_dispatch = default_registry.dispatch; 3909 /** 3910 * Given a listener function, the function will be called any time the state value 3911 * of one of the registered stores has changed. This function returns a `unsubscribe` 3912 * function used to stop the subscription. 3913 * 3914 * @param {Function} listener Callback function. 3915 * 3916 * @example 3917 * ```js 3918 * import { subscribe } from '@wordpress/data'; 3919 * 3920 * const unsubscribe = subscribe( () => { 3921 * // You could use this opportunity to test whether the derived result of a 3922 * // selector has subsequently changed as the result of a state update. 3923 * } ); 3924 * 3925 * // Later, if necessary... 3926 * unsubscribe(); 3927 * ``` 3928 */ 3929 3930 const build_module_subscribe = default_registry.subscribe; 3931 /** 3932 * Registers a generic store. 3933 * 3934 * @deprecated Use `register` instead. 3935 * 3936 * @param {string} key Store registry key. 3937 * @param {Object} config Configuration (getSelectors, getActions, subscribe). 3938 */ 3939 3940 const build_module_registerGenericStore = default_registry.registerGenericStore; 3941 /** 3942 * Registers a standard `@wordpress/data` store. 3943 * 3944 * @deprecated Use `register` instead. 3945 * 3946 * @param {string} storeName Unique namespace identifier for the store. 3947 * @param {Object} options Store description (reducer, actions, selectors, resolvers). 3948 * 3949 * @return {Object} Registered store object. 3950 */ 3951 3952 const registerStore = default_registry.registerStore; 3953 /** 3954 * Extends a registry to inherit functionality provided by a given plugin. A 3955 * plugin is an object with properties aligning to that of a registry, merged 3956 * to extend the default registry behavior. 3957 * 3958 * @param {Object} plugin Plugin object. 3959 */ 3960 3961 const build_module_use = default_registry.use; 3962 /** 3963 * Registers a standard `@wordpress/data` store definition. 3964 * 3965 * @example 3966 * ```js 3967 * import { createReduxStore, register } from '@wordpress/data'; 3968 * 3969 * const store = createReduxStore( 'demo', { 3970 * reducer: ( state = 'OK' ) => state, 3971 * selectors: { 3972 * getValue: ( state ) => state, 3973 * }, 3974 * } ); 3975 * register( store ); 3976 * ``` 3977 * 3978 * @param {WPDataStore} store Store definition. 3979 */ 3980 3981 const build_module_register = default_registry.register; 3982 3983 3984 /***/ }), 3985 3986 /***/ "rl8x": 3987 /***/ (function(module, exports) { 3988 3989 (function() { module.exports = window["wp"]["isShallowEqual"]; }()); 3990 3991 /***/ }), 3992 3993 /***/ "wx14": 3994 /***/ (function(module, __webpack_exports__, __webpack_require__) { 3995 3996 "use strict"; 3997 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); 3998 function _extends() { 3999 _extends = Object.assign || function (target) { 4000 for (var i = 1; i < arguments.length; i++) { 4001 var source = arguments[i]; 4002 4003 for (var key in source) { 4004 if (Object.prototype.hasOwnProperty.call(source, key)) { 4005 target[key] = source[key]; 4006 } 4007 } 4008 } 4009 4010 return target; 4011 }; 4012 4013 return _extends.apply(this, arguments); 4014 } 4015 4016 /***/ }) 4017 4018 /******/ });