diff -r be944660c56a -r 3d72ae0968f4 wp/wp-includes/js/dist/data.js --- a/wp/wp-includes/js/dist/data.js Wed Sep 21 18:19:35 2022 +0200 +++ b/wp/wp-includes/js/dist/data.js Tue Sep 27 16:37:53 2022 +0200 @@ -1,153 +1,8 @@ -this["wp"] = this["wp"] || {}; this["wp"]["data"] = -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "pfJ3"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "8mpt": -/***/ (function(module, exports) { - -function combineReducers( reducers ) { - var keys = Object.keys( reducers ), - getNextState; - - getNextState = ( function() { - var fn, i, key; - - fn = 'return {'; - for ( i = 0; i < keys.length; i++ ) { - // Rely on Quoted escaping of JSON.stringify with guarantee that - // each member of Object.keys is a string. - // - // "If Type(value) is String, then return the result of calling the - // abstract operation Quote with argument value. [...] The abstract - // operation Quote(value) wraps a String value in double quotes and - // escapes characters within it." - // - // https://www.ecma-international.org/ecma-262/5.1/#sec-15.12.3 - key = JSON.stringify( keys[ i ] ); - - fn += key + ':r[' + key + '](s[' + key + '],a),'; - } - fn += '}'; - - return new Function( 'r,s,a', fn ); - } )(); - - return function combinedReducer( state, action ) { - var nextState, i, key; - - // Assumed changed if initial state. - if ( state === undefined ) { - return getNextState( reducers, {}, action ); - } - - nextState = getNextState( reducers, state, action ); - - // Determine whether state has changed. - i = keys.length; - while ( i-- ) { - key = keys[ i ]; - if ( state[ key ] !== nextState[ key ] ) { - // Return immediately if a changed value is encountered. - return nextState; - } - } - - return state; - }; -} - -module.exports = combineReducers; - - -/***/ }), - -/***/ "FtRg": -/***/ (function(module, exports, __webpack_require__) { +/******/ (function() { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ 2167: +/***/ (function(module) { "use strict"; @@ -461,194 +316,213 @@ /***/ }), -/***/ "GRId": -/***/ (function(module, exports) { - -(function() { module.exports = window["wp"]["element"]; }()); - -/***/ }), - -/***/ "JlUD": -/***/ (function(module, exports) { - -module.exports = isPromise; -module.exports.default = isPromise; - -function isPromise(obj) { - return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; +/***/ 9125: +/***/ (function(module) { + +function combineReducers( reducers ) { + var keys = Object.keys( reducers ), + getNextState; + + getNextState = ( function() { + var fn, i, key; + + fn = 'return {'; + for ( i = 0; i < keys.length; i++ ) { + // Rely on Quoted escaping of JSON.stringify with guarantee that + // each member of Object.keys is a string. + // + // "If Type(value) is String, then return the result of calling the + // abstract operation Quote with argument value. [...] The abstract + // operation Quote(value) wraps a String value in double quotes and + // escapes characters within it." + // + // https://www.ecma-international.org/ecma-262/5.1/#sec-15.12.3 + key = JSON.stringify( keys[ i ] ); + + fn += key + ':r[' + key + '](s[' + key + '],a),'; + } + fn += '}'; + + return new Function( 'r,s,a', fn ); + } )(); + + return function combinedReducer( state, action ) { + var nextState, i, key; + + // Assumed changed if initial state. + if ( state === undefined ) { + return getNextState( reducers, {}, action ); + } + + nextState = getNextState( reducers, state, action ); + + // Determine whether state has changed. + i = keys.length; + while ( i-- ) { + key = keys[ i ]; + if ( state[ key ] !== nextState[ key ] ) { + // Return immediately if a changed value is encountered. + return nextState; + } + } + + return state; + }; } - -/***/ }), - -/***/ "K9lf": -/***/ (function(module, exports) { - -(function() { module.exports = window["wp"]["compose"]; }()); - -/***/ }), - -/***/ "NMb1": -/***/ (function(module, exports) { - -(function() { module.exports = window["wp"]["deprecated"]; }()); - -/***/ }), - -/***/ "XI5e": -/***/ (function(module, exports) { - -(function() { module.exports = window["wp"]["priorityQueue"]; }()); - -/***/ }), - -/***/ "XIDh": -/***/ (function(module, exports) { - -(function() { module.exports = window["wp"]["reduxRoutine"]; }()); - -/***/ }), - -/***/ "YLtl": -/***/ (function(module, exports) { - -(function() { module.exports = window["lodash"]; }()); - -/***/ }), - -/***/ "cDcd": -/***/ (function(module, exports) { - -(function() { module.exports = window["React"]; }()); - -/***/ }), - -/***/ "mHlH": -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* unused harmony export useCallback */ -/* unused harmony export useCallbackOne */ -/* unused harmony export useMemo */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useMemoOne; }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("cDcd"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); - - -function areInputsEqual(newInputs, lastInputs) { - if (newInputs.length !== lastInputs.length) { - return false; - } - - for (var i = 0; i < newInputs.length; i++) { - if (newInputs[i] !== lastInputs[i]) { - return false; - } - } - - return true; -} - -function useMemoOne(getResult, inputs) { - var initial = Object(react__WEBPACK_IMPORTED_MODULE_0__["useState"])(function () { - return { - inputs: inputs, - result: getResult() - }; - })[0]; - var isFirstRun = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(true); - var committed = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(initial); - var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); - var cache = useCache ? committed.current : { - inputs: inputs, - result: getResult() - }; - Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () { - isFirstRun.current = false; - committed.current = cache; - }, [cache]); - return cache.result; -} -function useCallbackOne(callback, inputs) { - return useMemoOne(function () { - return callback; - }, inputs); -} -var useMemo = useMemoOne; -var useCallback = useCallbackOne; - - - - -/***/ }), - -/***/ "pfJ3": -/***/ (function(module, __webpack_exports__, __webpack_require__) { - +module.exports = combineReducers; + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ !function() { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be in strict mode. +!function() { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS -__webpack_require__.d(__webpack_exports__, "withSelect", function() { return /* reexport */ with_select; }); -__webpack_require__.d(__webpack_exports__, "withDispatch", function() { return /* reexport */ with_dispatch; }); -__webpack_require__.d(__webpack_exports__, "withRegistry", function() { return /* reexport */ with_registry; }); -__webpack_require__.d(__webpack_exports__, "RegistryProvider", function() { return /* reexport */ context; }); -__webpack_require__.d(__webpack_exports__, "RegistryConsumer", function() { return /* reexport */ RegistryConsumer; }); -__webpack_require__.d(__webpack_exports__, "useRegistry", function() { return /* reexport */ useRegistry; }); -__webpack_require__.d(__webpack_exports__, "useSelect", function() { return /* reexport */ useSelect; }); -__webpack_require__.d(__webpack_exports__, "useDispatch", function() { return /* reexport */ use_dispatch; }); -__webpack_require__.d(__webpack_exports__, "AsyncModeProvider", function() { return /* reexport */ async_mode_provider_context; }); -__webpack_require__.d(__webpack_exports__, "createRegistry", function() { return /* reexport */ createRegistry; }); -__webpack_require__.d(__webpack_exports__, "createRegistrySelector", function() { return /* reexport */ createRegistrySelector; }); -__webpack_require__.d(__webpack_exports__, "createRegistryControl", function() { return /* reexport */ createRegistryControl; }); -__webpack_require__.d(__webpack_exports__, "controls", function() { return /* reexport */ controls_controls; }); -__webpack_require__.d(__webpack_exports__, "createReduxStore", function() { return /* reexport */ createReduxStore; }); -__webpack_require__.d(__webpack_exports__, "plugins", function() { return /* reexport */ plugins_namespaceObject; }); -__webpack_require__.d(__webpack_exports__, "combineReducers", function() { return /* reexport */ turbo_combine_reducers_default.a; }); -__webpack_require__.d(__webpack_exports__, "select", function() { return /* binding */ build_module_select; }); -__webpack_require__.d(__webpack_exports__, "resolveSelect", function() { return /* binding */ build_module_resolveSelect; }); -__webpack_require__.d(__webpack_exports__, "dispatch", function() { return /* binding */ build_module_dispatch; }); -__webpack_require__.d(__webpack_exports__, "subscribe", function() { return /* binding */ build_module_subscribe; }); -__webpack_require__.d(__webpack_exports__, "registerGenericStore", function() { return /* binding */ build_module_registerGenericStore; }); -__webpack_require__.d(__webpack_exports__, "registerStore", function() { return /* binding */ registerStore; }); -__webpack_require__.d(__webpack_exports__, "use", function() { return /* binding */ build_module_use; }); -__webpack_require__.d(__webpack_exports__, "register", function() { return /* binding */ build_module_register; }); +__webpack_require__.d(__webpack_exports__, { + "AsyncModeProvider": function() { return /* reexport */ async_mode_provider_context; }, + "RegistryConsumer": function() { return /* reexport */ RegistryConsumer; }, + "RegistryProvider": function() { return /* reexport */ context; }, + "combineReducers": function() { return /* reexport */ (turbo_combine_reducers_default()); }, + "controls": function() { return /* reexport */ controls; }, + "createReduxStore": function() { return /* reexport */ createReduxStore; }, + "createRegistry": function() { return /* reexport */ createRegistry; }, + "createRegistryControl": function() { return /* reexport */ createRegistryControl; }, + "createRegistrySelector": function() { return /* reexport */ createRegistrySelector; }, + "dispatch": function() { return /* binding */ build_module_dispatch; }, + "plugins": function() { return /* reexport */ plugins_namespaceObject; }, + "register": function() { return /* binding */ register; }, + "registerGenericStore": function() { return /* binding */ registerGenericStore; }, + "registerStore": function() { return /* binding */ registerStore; }, + "resolveSelect": function() { return /* binding */ build_module_resolveSelect; }, + "select": function() { return /* binding */ build_module_select; }, + "subscribe": function() { return /* binding */ subscribe; }, + "use": function() { return /* binding */ use; }, + "useDispatch": function() { return /* reexport */ use_dispatch; }, + "useRegistry": function() { return /* reexport */ useRegistry; }, + "useSelect": function() { return /* reexport */ useSelect; }, + "withDispatch": function() { return /* reexport */ with_dispatch; }, + "withRegistry": function() { return /* reexport */ with_registry; }, + "withSelect": function() { return /* reexport */ with_select; } +}); // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js var selectors_namespaceObject = {}; __webpack_require__.r(selectors_namespaceObject); -__webpack_require__.d(selectors_namespaceObject, "getIsResolving", function() { return getIsResolving; }); -__webpack_require__.d(selectors_namespaceObject, "hasStartedResolution", function() { return hasStartedResolution; }); -__webpack_require__.d(selectors_namespaceObject, "hasFinishedResolution", function() { return hasFinishedResolution; }); -__webpack_require__.d(selectors_namespaceObject, "isResolving", function() { return isResolving; }); -__webpack_require__.d(selectors_namespaceObject, "getCachedResolvers", function() { return getCachedResolvers; }); +__webpack_require__.d(selectors_namespaceObject, { + "getCachedResolvers": function() { return getCachedResolvers; }, + "getIsResolving": function() { return getIsResolving; }, + "getResolutionError": function() { return getResolutionError; }, + "getResolutionState": function() { return getResolutionState; }, + "hasFinishedResolution": function() { return hasFinishedResolution; }, + "hasResolutionFailed": function() { return hasResolutionFailed; }, + "hasStartedResolution": function() { return hasStartedResolution; }, + "isResolving": function() { return isResolving; } +}); // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js var actions_namespaceObject = {}; __webpack_require__.r(actions_namespaceObject); -__webpack_require__.d(actions_namespaceObject, "startResolution", function() { return startResolution; }); -__webpack_require__.d(actions_namespaceObject, "finishResolution", function() { return finishResolution; }); -__webpack_require__.d(actions_namespaceObject, "startResolutions", function() { return startResolutions; }); -__webpack_require__.d(actions_namespaceObject, "finishResolutions", function() { return finishResolutions; }); -__webpack_require__.d(actions_namespaceObject, "invalidateResolution", function() { return invalidateResolution; }); -__webpack_require__.d(actions_namespaceObject, "invalidateResolutionForStore", function() { return invalidateResolutionForStore; }); -__webpack_require__.d(actions_namespaceObject, "invalidateResolutionForStoreSelector", function() { return invalidateResolutionForStoreSelector; }); +__webpack_require__.d(actions_namespaceObject, { + "failResolution": function() { return failResolution; }, + "failResolutions": function() { return failResolutions; }, + "finishResolution": function() { return finishResolution; }, + "finishResolutions": function() { return finishResolutions; }, + "invalidateResolution": function() { return invalidateResolution; }, + "invalidateResolutionForStore": function() { return invalidateResolutionForStore; }, + "invalidateResolutionForStoreSelector": function() { return invalidateResolutionForStoreSelector; }, + "startResolution": function() { return startResolution; }, + "startResolutions": function() { return startResolutions; } +}); // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js var plugins_namespaceObject = {}; __webpack_require__.r(plugins_namespaceObject); -__webpack_require__.d(plugins_namespaceObject, "controls", function() { return plugins_controls; }); -__webpack_require__.d(plugins_namespaceObject, "persistence", function() { return plugins_persistence; }); +__webpack_require__.d(plugins_namespaceObject, { + "persistence": function() { return persistence; } +}); // EXTERNAL MODULE: ./node_modules/turbo-combine-reducers/index.js -var turbo_combine_reducers = __webpack_require__("8mpt"); +var turbo_combine_reducers = __webpack_require__(9125); var turbo_combine_reducers_default = /*#__PURE__*/__webpack_require__.n(turbo_combine_reducers); - -// EXTERNAL MODULE: external "lodash" -var external_lodash_ = __webpack_require__("YLtl"); - -// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js +;// CONCATENATED MODULE: external "lodash" +var external_lodash_namespaceObject = window["lodash"]; +;// CONCATENATED MODULE: external ["wp","deprecated"] +var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; +var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -663,7 +537,7 @@ return obj; } -// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js function ownKeys(object, enumerableOnly) { @@ -671,14 +545,9 @@ if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); - - if (enumerableOnly) { - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - } - - keys.push.apply(keys, symbols); + enumerableOnly && (symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + })), keys.push.apply(keys, symbols); } return keys; @@ -686,24 +555,17 @@ function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } + var source = null != arguments[i] ? arguments[i] : {}; + i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { + _defineProperty(target, key, source[key]); + }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); } return target; } -// CONCATENATED MODULE: ./node_modules/redux/es/redux.js +;// CONCATENATED MODULE: ./node_modules/redux/es/redux.js /** @@ -813,36 +675,36 @@ } /** - * Creates a Redux store that holds the state tree. - * The only way to change the data in the store is to call `dispatch()` on it. - * - * There should only be a single store in your app. To specify how different - * parts of the state tree respond to actions, you may combine several reducers - * into a single reducer function by using `combineReducers`. - * - * @param {Function} reducer A function that returns the next state tree, given - * the current state tree and the action to handle. - * - * @param {any} [preloadedState] The initial state. You may optionally specify it - * to hydrate the state from the server in universal apps, or to restore a - * previously serialized user session. - * If you use `combineReducers` to produce the root reducer function, this must be - * an object with the same shape as `combineReducers` keys. - * - * @param {Function} [enhancer] The store enhancer. You may optionally specify it - * to enhance the store with third-party capabilities such as middleware, - * time travel, persistence, etc. The only store enhancer that ships with Redux - * is `applyMiddleware()`. - * - * @returns {Store} A Redux store that lets you read the state, dispatch actions - * and subscribe to changes. + * @deprecated + * + * **We recommend using the `configureStore` method + * of the `@reduxjs/toolkit` package**, which replaces `createStore`. + * + * Redux Toolkit is our recommended approach for writing Redux logic today, + * including store setup, reducers, data fetching, and more. + * + * **For more details, please read this Redux docs page:** + * **https://redux.js.org/introduction/why-rtk-is-redux-today** + * + * `configureStore` from Redux Toolkit is an improved version of `createStore` that + * simplifies setup and helps avoid common bugs. + * + * You should not be using the `redux` core package by itself today, except for learning purposes. + * The `createStore` method from the core `redux` package will not be removed, but we encourage + * all users to migrate to using Redux Toolkit for all Redux code. + * + * If you want to use `createStore` without this visual deprecation warning, use + * the `legacy_createStore` import instead: + * + * `import { legacy_createStore as createStore} from 'redux'` + * */ -function redux_createStore(reducer, preloadedState, enhancer) { +function createStore(reducer, preloadedState, enhancer) { var _ref2; if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') { - throw new Error( true ? formatProdErrorMessage(0) : undefined); + throw new Error( true ? formatProdErrorMessage(0) : 0); } if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { @@ -852,14 +714,14 @@ if (typeof enhancer !== 'undefined') { if (typeof enhancer !== 'function') { - throw new Error( true ? formatProdErrorMessage(1) : undefined); + throw new Error( true ? formatProdErrorMessage(1) : 0); } - return enhancer(redux_createStore)(reducer, preloadedState); + return enhancer(createStore)(reducer, preloadedState); } if (typeof reducer !== 'function') { - throw new Error( true ? formatProdErrorMessage(2) : undefined); + throw new Error( true ? formatProdErrorMessage(2) : 0); } var currentReducer = reducer; @@ -889,7 +751,7 @@ function getState() { if (isDispatching) { - throw new Error( true ? formatProdErrorMessage(3) : undefined); + throw new Error( true ? formatProdErrorMessage(3) : 0); } return currentState; @@ -921,11 +783,11 @@ function subscribe(listener) { if (typeof listener !== 'function') { - throw new Error( true ? formatProdErrorMessage(4) : undefined); + throw new Error( true ? formatProdErrorMessage(4) : 0); } if (isDispatching) { - throw new Error( true ? formatProdErrorMessage(5) : undefined); + throw new Error( true ? formatProdErrorMessage(5) : 0); } var isSubscribed = true; @@ -937,7 +799,7 @@ } if (isDispatching) { - throw new Error( true ? formatProdErrorMessage(6) : undefined); + throw new Error( true ? formatProdErrorMessage(6) : 0); } isSubscribed = false; @@ -976,15 +838,15 @@ function dispatch(action) { if (!isPlainObject(action)) { - throw new Error( true ? formatProdErrorMessage(7) : undefined); + throw new Error( true ? formatProdErrorMessage(7) : 0); } if (typeof action.type === 'undefined') { - throw new Error( true ? formatProdErrorMessage(8) : undefined); + throw new Error( true ? formatProdErrorMessage(8) : 0); } if (isDispatching) { - throw new Error( true ? formatProdErrorMessage(9) : undefined); + throw new Error( true ? formatProdErrorMessage(9) : 0); } try { @@ -1017,7 +879,7 @@ function replaceReducer(nextReducer) { if (typeof nextReducer !== 'function') { - throw new Error( true ? formatProdErrorMessage(10) : undefined); + throw new Error( true ? formatProdErrorMessage(10) : 0); } currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT. @@ -1052,7 +914,7 @@ */ subscribe: function subscribe(observer) { if (typeof observer !== 'object' || observer === null) { - throw new Error( true ? formatProdErrorMessage(11) : undefined); + throw new Error( true ? formatProdErrorMessage(11) : 0); } function observeState() { @@ -1085,6 +947,38 @@ replaceReducer: replaceReducer }, _ref2[$$observable] = observable, _ref2; } +/** + * Creates a Redux store that holds the state tree. + * + * **We recommend using `configureStore` from the + * `@reduxjs/toolkit` package**, which replaces `createStore`: + * **https://redux.js.org/introduction/why-rtk-is-redux-today** + * + * The only way to change the data in the store is to call `dispatch()` on it. + * + * There should only be a single store in your app. To specify how different + * parts of the state tree respond to actions, you may combine several reducers + * into a single reducer function by using `combineReducers`. + * + * @param {Function} reducer A function that returns the next state tree, given + * the current state tree and the action to handle. + * + * @param {any} [preloadedState] The initial state. You may optionally specify it + * to hydrate the state from the server in universal apps, or to restore a + * previously serialized user session. + * If you use `combineReducers` to produce the root reducer function, this must be + * an object with the same shape as `combineReducers` keys. + * + * @param {Function} [enhancer] The store enhancer. You may optionally specify it + * to enhance the store with third-party capabilities such as middleware, + * time travel, persistence, etc. The only store enhancer that ships with Redux + * is `applyMiddleware()`. + * + * @returns {Store} A Redux store that lets you read the state, dispatch actions + * and subscribe to changes. + */ + +var legacy_createStore = (/* unused pure expression or super */ null && (createStore)); /** * Prints a warning in the console if it exists. @@ -1142,13 +1036,13 @@ }); if (typeof initialState === 'undefined') { - throw new Error( true ? formatProdErrorMessage(12) : undefined); + throw new Error( true ? formatProdErrorMessage(12) : 0); } if (typeof reducer(undefined, { type: ActionTypes.PROBE_UNKNOWN_ACTION() }) === 'undefined') { - throw new Error( true ? formatProdErrorMessage(13) : undefined); + throw new Error( true ? formatProdErrorMessage(13) : 0); } }); } @@ -1221,7 +1115,7 @@ if (typeof nextStateForKey === 'undefined') { var actionType = action && action.type; - throw new Error( true ? formatProdErrorMessage(14) : undefined); + throw new Error( true ? formatProdErrorMessage(14) : 0); } nextState[_key] = nextStateForKey; @@ -1267,7 +1161,7 @@ } if (typeof actionCreators !== 'object' || actionCreators === null) { - throw new Error( true ? formatProdErrorMessage(16) : undefined); + throw new Error( true ? formatProdErrorMessage(16) : 0); } var boundActionCreators = {}; @@ -1342,7 +1236,7 @@ var store = createStore.apply(void 0, arguments); var _dispatch = function dispatch() { - throw new Error( true ? formatProdErrorMessage(15) : undefined); + throw new Error( true ? formatProdErrorMessage(15) : 0); }; var middlewareAPI = { @@ -1374,14 +1268,12 @@ // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js -var equivalent_key_map = __webpack_require__("FtRg"); +var equivalent_key_map = __webpack_require__(2167); var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map); - -// EXTERNAL MODULE: external ["wp","reduxRoutine"] -var external_wp_reduxRoutine_ = __webpack_require__("XIDh"); -var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_); - -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js +;// CONCATENATED MODULE: external ["wp","reduxRoutine"] +var external_wp_reduxRoutine_namespaceObject = window["wp"]["reduxRoutine"]; +var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_namespaceObject); +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js /** * Creates a selector function that takes additional curried argument with the * registry `select` function. While a regular selector has signature @@ -1415,15 +1307,17 @@ * with a store. * * @param {Function} registrySelector Function receiving a registry `select` - * function and returning a state selector. + * function and returning a state selector. * * @return {Function} Registry selector that can be registered with a store. */ function createRegistrySelector(registrySelector) { - // create a selector function that is bound to the registry referenced by `selector.registry` + // Create a selector function that is bound to the registry referenced by `selector.registry` // and that has the same API as a regular selector. Binding it in such a way makes it // possible to call the selector directly from another selector. - const selector = (...args) => registrySelector(selector.registry.select)(...args); + const selector = function () { + return registrySelector(selector.registry.select)(...arguments); + }; /** * Flag indicating that the selector is a registry selector that needs the correct registry * reference to be assigned to `selecto.registry` to make it work correctly. @@ -1462,11 +1356,18 @@ return registryControl; } -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js +/** + * External dependencies + */ + /** * Internal dependencies */ + +/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ + const SELECT = '@@data/SELECT'; const RESOLVE_SELECT = '@@data/RESOLVE_SELECT'; const DISPATCH = '@@data/DISPATCH'; @@ -1476,9 +1377,9 @@ * Note: This control synchronously returns the current selector value, triggering the * resolution, but not waiting for it. * - * @param {string} storeKey The key for the store the selector belongs to. - * @param {string} selectorName The name of the selector. - * @param {Array} args Arguments for the selector. + * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store + * @param {string} selectorName The name of the selector. + * @param {Array} args Arguments for the selector. * * @example * ```js @@ -1494,10 +1395,14 @@ * @return {Object} The control descriptor. */ -function controls_select(storeKey, selectorName, ...args) { +function controls_select(storeNameOrDescriptor, selectorName) { + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } + return { type: SELECT, - storeKey, + storeKey: (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, selectorName, args }; @@ -1509,9 +1414,9 @@ * selectors that may have a resolver. In such case, it will return a `Promise` that resolves * after the selector finishes resolving, with the final result value. * - * @param {string} storeKey The key for the store the selector belongs to - * @param {string} selectorName The name of the selector - * @param {Array} args Arguments for the selector. + * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store + * @param {string} selectorName The name of the selector + * @param {Array} args Arguments for the selector. * * @example * ```js @@ -1528,10 +1433,14 @@ */ -function controls_resolveSelect(storeKey, selectorName, ...args) { +function resolveSelect(storeNameOrDescriptor, selectorName) { + for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + args[_key2 - 2] = arguments[_key2]; + } + return { type: RESOLVE_SELECT, - storeKey, + storeKey: (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, selectorName, args }; @@ -1539,9 +1448,9 @@ /** * Dispatches a control action for triggering a registry dispatch. * - * @param {string} storeKey The key for the store the action belongs to - * @param {string} actionName The name of the action to dispatch - * @param {Array} args Arguments for the dispatch action. + * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store + * @param {string} actionName The name of the action to dispatch + * @param {Array} args Arguments for the dispatch action. * * @example * ```js @@ -1558,46 +1467,58 @@ */ -function controls_dispatch(storeKey, actionName, ...args) { +function dispatch(storeNameOrDescriptor, actionName) { + for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { + args[_key3 - 2] = arguments[_key3]; + } + return { type: DISPATCH, - storeKey, + storeKey: (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor, actionName, args }; } -const controls_controls = { +const controls = { select: controls_select, - resolveSelect: controls_resolveSelect, - dispatch: controls_dispatch + resolveSelect, + dispatch }; const builtinControls = { - [SELECT]: createRegistryControl(registry => ({ - storeKey, - selectorName, - args - }) => registry.select(storeKey)[selectorName](...args)), - [RESOLVE_SELECT]: createRegistryControl(registry => ({ - storeKey, - selectorName, - args - }) => { + [SELECT]: createRegistryControl(registry => _ref => { + let { + storeKey, + selectorName, + args + } = _ref; + return registry.select(storeKey)[selectorName](...args); + }), + [RESOLVE_SELECT]: createRegistryControl(registry => _ref2 => { + let { + storeKey, + selectorName, + args + } = _ref2; const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select'; return registry[method](storeKey)[selectorName](...args); }), - [DISPATCH]: createRegistryControl(registry => ({ - storeKey, - actionName, - args - }) => registry.dispatch(storeKey)[actionName](...args)) + [DISPATCH]: createRegistryControl(registry => _ref3 => { + let { + storeKey, + actionName, + args + } = _ref3; + return registry.dispatch(storeKey)[actionName](...args); + }) }; -// EXTERNAL MODULE: ./node_modules/is-promise/index.js -var is_promise = __webpack_require__("JlUD"); -var is_promise_default = /*#__PURE__*/__webpack_require__.n(is_promise); - -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js +;// CONCATENATED MODULE: ./node_modules/is-promise/index.mjs +function isPromise(obj) { + return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js /** * External dependencies */ @@ -1605,11 +1526,11 @@ /** * Simplest possible promise redux middleware. * - * @return {Function} middleware. + * @type {import('redux').Middleware} */ const promiseMiddleware = () => next => action => { - if (is_promise_default()(action)) { + if (isPromise(action)) { return action.then(resolvedAction => { if (resolvedAction) { return next(resolvedAction); @@ -1622,11 +1543,60 @@ /* harmony default export */ var promise_middleware = (promiseMiddleware); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js +const coreDataStore = { + name: 'core/data', + + instantiate(registry) { + const getCoreDataSelector = selectorName => function (key) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return registry.select(key)[selectorName](...args); + }; + + const getCoreDataAction = actionName => function (key) { + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + return registry.dispatch(key)[actionName](...args); + }; + + return { + getSelectors() { + return Object.fromEntries(['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].map(selectorName => [selectorName, getCoreDataSelector(selectorName)])); + }, + + getActions() { + return Object.fromEntries(['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].map(actionName => [actionName, getCoreDataAction(actionName)])); + }, + + subscribe() { + // There's no reasons to trigger any listener when we subscribe to this store + // because there's no state stored in this store that need to retrigger selectors + // if a change happens, the corresponding store where the tracking stated live + // would have already triggered a "subscribe" call. + return () => () => {}; + } + + }; + } + +}; +/* harmony default export */ var store = (coreDataStore); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js /** * External dependencies */ +/** + * Internal dependencies + */ + + /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ /** @@ -1641,9 +1611,10 @@ */ const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => { - const resolvers = registry.select('core/data').getCachedResolvers(reducerKey); - Object.entries(resolvers).forEach(([selectorName, resolversByArgs]) => { - const resolver = Object(external_lodash_["get"])(registry.stores, [reducerKey, 'resolvers', selectorName]); + const resolvers = registry.select(store).getCachedResolvers(reducerKey); + Object.entries(resolvers).forEach(_ref => { + let [selectorName, resolversByArgs] = _ref; + const resolver = (0,external_lodash_namespaceObject.get)(registry.stores, [reducerKey, 'resolvers', selectorName]); if (!resolver || !resolver.shouldInvalidate) { return; @@ -1651,14 +1622,14 @@ resolversByArgs.forEach((value, args) => { // resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector. - // If the value is false it means this resolver has finished its resolution which means we need to invalidate it, - // if it's true it means it's inflight and the invalidation is not necessary. - if (value !== false || !resolver.shouldInvalidate(action, ...args)) { + // If the value is "finished" or "error" it means this resolver has finished its resolution which means we need + // to invalidate it, if it's true it means it's inflight and the invalidation is not necessary. + if ((value === null || value === void 0 ? void 0 : value.status) !== 'finished' && (value === null || value === void 0 ? void 0 : value.status) !== 'error' || !resolver.shouldInvalidate(action, ...args)) { return; } // Trigger cache invalidation - registry.dispatch('core/data').invalidateResolution(reducerKey, selectorName, args); + registry.dispatch(store).invalidateResolution(reducerKey, selectorName, args); }); }); return next(action); @@ -1666,7 +1637,7 @@ /* harmony default export */ var resolvers_cache_middleware = (createResolversCacheMiddleware); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js function createThunkMiddleware(args) { return () => next => action => { if (typeof action === 'function') { @@ -1677,16 +1648,21 @@ }; } -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js +/** + * External dependencies + */ + /** * Higher-order reducer creator which creates a combined reducer object, keyed * by a property on the action object. * - * @param {string} actionProperty Action property by which to key object. - * - * @return {Function} Higher-order reducer. + * @param actionProperty Action property by which to key object. + * @return Higher-order reducer. */ -const onSubKey = actionProperty => reducer => (state = {}, action) => { +const onSubKey = actionProperty => reducer => function () { + let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + let action = arguments.length > 1 ? arguments[1] : undefined; // Retrieve subkey from action. Do not track if undefined; useful for cases // where reducer is scoped by action shape. const key = action[actionProperty]; @@ -1707,13 +1683,36 @@ [key]: nextKeyState }; }; - -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js +/** + * Normalize selector argument array by defaulting `undefined` value to an empty array + * and removing trailing `undefined` values. + * + * @param args Selector argument array + * @return Normalized state key array + */ + +function selectorArgsToStateKey(args) { + if (args === undefined || args === null) { + return []; + } + + const len = args.length; + let idx = len; + + while (idx > 0 && args[idx - 1] === undefined) { + idx--; + } + + return idx === len ? args : args.slice(0, idx); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js /** * External dependencies */ + /** * Internal dependencies */ @@ -1724,41 +1723,89 @@ * subkeys, object form: * * selectorName -> EquivalentKeyMap - * - * @param {Object} state Current state. - * @param {Object} action Dispatched action. - * - * @return {Object} Next state. */ - -const subKeysIsResolved = onSubKey('selectorName')((state = new equivalent_key_map_default.a(), action) => { +const subKeysIsResolved = onSubKey('selectorName')(function () { + let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new (equivalent_key_map_default())(); + let action = arguments.length > 1 ? arguments[1] : undefined; + switch (action.type) { case 'START_RESOLUTION': + { + const nextState = new (equivalent_key_map_default())(state); + nextState.set(selectorArgsToStateKey(action.args), { + status: 'resolving' + }); + return nextState; + } + case 'FINISH_RESOLUTION': { - const isStarting = action.type === 'START_RESOLUTION'; - const nextState = new equivalent_key_map_default.a(state); - nextState.set(action.args, isStarting); + const nextState = new (equivalent_key_map_default())(state); + nextState.set(selectorArgsToStateKey(action.args), { + status: 'finished' + }); + return nextState; + } + + case 'FAIL_RESOLUTION': + { + const nextState = new (equivalent_key_map_default())(state); + nextState.set(selectorArgsToStateKey(action.args), { + status: 'error', + error: action.error + }); return nextState; } case 'START_RESOLUTIONS': + { + const nextState = new (equivalent_key_map_default())(state); + + for (const resolutionArgs of action.args) { + nextState.set(selectorArgsToStateKey(resolutionArgs), { + status: 'resolving' + }); + } + + return nextState; + } + case 'FINISH_RESOLUTIONS': { - const isStarting = action.type === 'START_RESOLUTIONS'; - const nextState = new equivalent_key_map_default.a(state); + const nextState = new (equivalent_key_map_default())(state); for (const resolutionArgs of action.args) { - nextState.set(resolutionArgs, isStarting); + nextState.set(selectorArgsToStateKey(resolutionArgs), { + status: 'finished' + }); } return nextState; } + case 'FAIL_RESOLUTIONS': + { + const nextState = new (equivalent_key_map_default())(state); + action.args.forEach((resolutionArgs, idx) => { + const resolutionState = { + status: 'error', + error: undefined + }; + const error = action.errors[idx]; + + if (error) { + resolutionState.error = error; + } + + nextState.set(selectorArgsToStateKey(resolutionArgs), resolutionState); + }); + return nextState; + } + case 'INVALIDATE_RESOLUTION': { - const nextState = new equivalent_key_map_default.a(state); - nextState.delete(action.args); + const nextState = new (equivalent_key_map_default())(state); + nextState.delete(selectorArgsToStateKey(action.args)); return nextState; } } @@ -1770,24 +1817,29 @@ * * selectorName -> EquivalentKeyMap * - * @param {Object} state Current state. - * @param {Object} action Dispatched action. - * - * @return {Object} Next state. + * @param state Current state. + * @param action Dispatched action. + * + * @return Next state. */ -const isResolved = (state = {}, action) => { +const isResolved = function () { + let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + let action = arguments.length > 1 ? arguments[1] : undefined; + switch (action.type) { case 'INVALIDATE_RESOLUTION_FOR_STORE': return {}; case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR': - return Object(external_lodash_["has"])(state, [action.selectorName]) ? Object(external_lodash_["omit"])(state, [action.selectorName]) : state; + return (0,external_lodash_namespaceObject.has)(state, [action.selectorName]) ? (0,external_lodash_namespaceObject.omit)(state, [action.selectorName]) : state; case 'START_RESOLUTION': case 'FINISH_RESOLUTION': + case 'FAIL_RESOLUTION': case 'START_RESOLUTIONS': case 'FINISH_RESOLUTIONS': + case 'FAIL_RESOLUTIONS': case 'INVALIDATE_RESOLUTION': return subKeysIsResolved(state, action); } @@ -1797,96 +1849,161 @@ /* harmony default export */ var metadata_reducer = (isResolved); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js /** * External dependencies */ /** + * Internal dependencies + */ + + +/** @typedef {Record} State */ + +/** @typedef {import('./reducer').StateValue} StateValue */ + +/** @typedef {import('./reducer').Status} Status */ + +/** + * Returns the raw resolution state value for a given selector name, + * and arguments set. May be undefined if the selector has never been resolved + * or not resolved for the given set of arguments, otherwise true or false for + * resolution started and completed respectively. + * + * @param {State} state Data state. + * @param {string} selectorName Selector name. + * @param {unknown[]?} args Arguments passed to selector. + * + * @return {StateValue|undefined} isResolving value. + */ + +function getResolutionState(state, selectorName, args) { + const map = (0,external_lodash_namespaceObject.get)(state, [selectorName]); + + if (!map) { + return; + } + + return map.get(selectorArgsToStateKey(args)); +} +/** * Returns the raw `isResolving` value for a given selector name, * and arguments set. May be undefined if the selector has never been resolved * or not resolved for the given set of arguments, otherwise true or false for * resolution started and completed respectively. * - * @param {Object} state Data state. - * @param {string} selectorName Selector name. - * @param {Array} args Arguments passed to selector. - * - * @return {?boolean} isResolving value. + * @param {State} state Data state. + * @param {string} selectorName Selector name. + * @param {unknown[]?} args Arguments passed to selector. + * + * @return {boolean | undefined} isResolving value. */ function getIsResolving(state, selectorName, args) { - const map = Object(external_lodash_["get"])(state, [selectorName]); - - if (!map) { - return; - } - - return map.get(args); + const resolutionState = getResolutionState(state, selectorName, args); + return resolutionState && resolutionState.status === 'resolving'; } /** * Returns true if resolution has already been triggered for a given * selector name, and arguments set. * - * @param {Object} state Data state. - * @param {string} selectorName Selector name. - * @param {?Array} args Arguments passed to selector (default `[]`). + * @param {State} state Data state. + * @param {string} selectorName Selector name. + * @param {unknown[]?} args Arguments passed to selector. * * @return {boolean} Whether resolution has been triggered. */ -function hasStartedResolution(state, selectorName, args = []) { - return getIsResolving(state, selectorName, args) !== undefined; +function hasStartedResolution(state, selectorName, args) { + return getResolutionState(state, selectorName, args) !== undefined; } /** * Returns true if resolution has completed for a given selector * name, and arguments set. * - * @param {Object} state Data state. - * @param {string} selectorName Selector name. - * @param {?Array} args Arguments passed to selector. + * @param {State} state Data state. + * @param {string} selectorName Selector name. + * @param {unknown[]?} args Arguments passed to selector. * * @return {boolean} Whether resolution has completed. */ -function hasFinishedResolution(state, selectorName, args = []) { - return getIsResolving(state, selectorName, args) === false; +function hasFinishedResolution(state, selectorName, args) { + var _getResolutionState; + + const status = (_getResolutionState = getResolutionState(state, selectorName, args)) === null || _getResolutionState === void 0 ? void 0 : _getResolutionState.status; + return status === 'finished' || status === 'error'; +} +/** + * Returns true if resolution has failed for a given selector + * name, and arguments set. + * + * @param {State} state Data state. + * @param {string} selectorName Selector name. + * @param {unknown[]?} args Arguments passed to selector. + * + * @return {boolean} Has resolution failed + */ + +function hasResolutionFailed(state, selectorName, args) { + var _getResolutionState2; + + return ((_getResolutionState2 = getResolutionState(state, selectorName, args)) === null || _getResolutionState2 === void 0 ? void 0 : _getResolutionState2.status) === 'error'; +} +/** + * Returns the resolution error for a given selector name, and arguments set. + * Note it may be of an Error type, but may also be null, undefined, or anything else + * that can be `throw`-n. + * + * @param {State} state Data state. + * @param {string} selectorName Selector name. + * @param {unknown[]?} args Arguments passed to selector. + * + * @return {Error|unknown} Last resolution error + */ + +function getResolutionError(state, selectorName, args) { + const resolutionState = getResolutionState(state, selectorName, args); + return (resolutionState === null || resolutionState === void 0 ? void 0 : resolutionState.status) === 'error' ? resolutionState.error : null; } /** * Returns true if resolution has been triggered but has not yet completed for * a given selector name, and arguments set. * - * @param {Object} state Data state. - * @param {string} selectorName Selector name. - * @param {?Array} args Arguments passed to selector. + * @param {State} state Data state. + * @param {string} selectorName Selector name. + * @param {unknown[]?} args Arguments passed to selector. * * @return {boolean} Whether resolution is in progress. */ -function isResolving(state, selectorName, args = []) { - return getIsResolving(state, selectorName, args) === true; +function isResolving(state, selectorName, args) { + var _getResolutionState3; + + return ((_getResolutionState3 = getResolutionState(state, selectorName, args)) === null || _getResolutionState3 === void 0 ? void 0 : _getResolutionState3.status) === 'resolving'; } /** * Returns the list of the cached resolvers. * - * @param {Object} state Data state. - * - * @return {Object} Resolvers mapped by args and selectorName. + * @param {State} state Data state. + * + * @return {State} Resolvers mapped by args and selectorName. */ function getCachedResolvers(state) { return state; } -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js /** * Returns an action object used in signalling that selector resolution has * started. * - * @param {string} selectorName Name of selector for which resolver triggered. - * @param {...*} args Arguments to associate for uniqueness. - * - * @return {Object} Action object. + * @param {string} selectorName Name of selector for which resolver triggered. + * @param {unknown[]} args Arguments to associate for uniqueness. + * + * @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object. */ function startResolution(selectorName, args) { return { @@ -1899,10 +2016,10 @@ * Returns an action object used in signalling that selector resolution has * completed. * - * @param {string} selectorName Name of selector for which resolver triggered. - * @param {...*} args Arguments to associate for uniqueness. - * - * @return {Object} Action object. + * @param {string} selectorName Name of selector for which resolver triggered. + * @param {unknown[]} args Arguments to associate for uniqueness. + * + * @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object. */ function finishResolution(selectorName, args) { @@ -1913,14 +2030,33 @@ }; } /** + * Returns an action object used in signalling that selector resolution has + * failed. + * + * @param {string} selectorName Name of selector for which resolver triggered. + * @param {unknown[]} args Arguments to associate for uniqueness. + * @param {Error|unknown} error The error that caused the failure. + * + * @return {{ type: 'FAIL_RESOLUTION', selectorName: string, args: unknown[], error: Error|unknown }} Action object. + */ + +function failResolution(selectorName, args, error) { + return { + type: 'FAIL_RESOLUTION', + selectorName, + args, + error + }; +} +/** * Returns an action object used in signalling that a batch of selector resolutions has * started. * - * @param {string} selectorName Name of selector for which resolver triggered. - * @param {...*} args Array of arguments to associate for uniqueness, each item - * is associated to a resolution. - * - * @return {Object} Action object. + * @param {string} selectorName Name of selector for which resolver triggered. + * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item + * is associated to a resolution. + * + * @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object. */ function startResolutions(selectorName, args) { @@ -1934,11 +2070,11 @@ * Returns an action object used in signalling that a batch of selector resolutions has * completed. * - * @param {string} selectorName Name of selector for which resolver triggered. - * @param {...*} args Array of arguments to associate for uniqueness, each item - * is associated to a resolution. - * - * @return {Object} Action object. + * @param {string} selectorName Name of selector for which resolver triggered. + * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item + * is associated to a resolution. + * + * @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object. */ function finishResolutions(selectorName, args) { @@ -1949,12 +2085,32 @@ }; } /** + * Returns an action object used in signalling that a batch of selector resolutions has + * completed and at least one of them has failed. + * + * @param {string} selectorName Name of selector for which resolver triggered. + * @param {unknown[]} args Array of arguments to associate for uniqueness, each item + * is associated to a resolution. + * @param {(Error|unknown)[]} errors Array of errors to associate for uniqueness, each item + * is associated to a resolution. + * @return {{ type: 'FAIL_RESOLUTIONS', selectorName: string, args: unknown[], errors: Array }} Action object. + */ + +function failResolutions(selectorName, args, errors) { + return { + type: 'FAIL_RESOLUTIONS', + selectorName, + args, + errors + }; +} +/** * Returns an action object used in signalling that we should invalidate the resolution cache. * - * @param {string} selectorName Name of selector for which resolver should be invalidated. - * @param {Array} args Arguments to associate for uniqueness. - * - * @return {Object} Action object. + * @param {string} selectorName Name of selector for which resolver should be invalidated. + * @param {unknown[]} args Arguments to associate for uniqueness. + * + * @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object. */ function invalidateResolution(selectorName, args) { @@ -1968,7 +2124,7 @@ * Returns an action object used in signalling that the resolution * should be invalidated. * - * @return {Object} Action object. + * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object. */ function invalidateResolutionForStore() { @@ -1983,7 +2139,7 @@ * @param {string} selectorName Name of selector for which all resolvers should * be invalidated. * - * @return {Object} Action object. + * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object. */ function invalidateResolutionForStoreSelector(selectorName) { @@ -1993,7 +2149,7 @@ }; } -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js /** * External dependencies */ @@ -2017,43 +2173,55 @@ -/** @typedef {import('../types').WPDataRegistry} WPDataRegistry */ - -/** @typedef {import('../types').WPDataStore} WPDataStore */ - -/** @typedef {import('../types').WPDataReduxStoreConfig} WPDataReduxStoreConfig */ - +/** @typedef {import('../types').DataRegistry} DataRegistry */ + +/** @typedef {import('../types').StoreDescriptor} StoreDescriptor */ + +/** @typedef {import('../types').ReduxStoreConfig} ReduxStoreConfig */ + +const trimUndefinedValues = array => { + const result = [...array]; + + for (let i = result.length - 1; i >= 0; i--) { + if (result[i] === undefined) { + result.splice(i, 1); + } + } + + return result; +}; /** * Create a cache to track whether resolvers started running or not. * * @return {Object} Resolvers Cache. */ + function createResolversCache() { const cache = {}; return { isRunning(selectorName, args) { - return cache[selectorName] && cache[selectorName].get(args); + return cache[selectorName] && cache[selectorName].get(trimUndefinedValues(args)); }, clear(selectorName, args) { if (cache[selectorName]) { - cache[selectorName].delete(args); + cache[selectorName].delete(trimUndefinedValues(args)); } }, markAsRunning(selectorName, args) { if (!cache[selectorName]) { - cache[selectorName] = new equivalent_key_map_default.a(); + cache[selectorName] = new (equivalent_key_map_default())(); } - cache[selectorName].set(args, true); + cache[selectorName].set(trimUndefinedValues(args), true); } }; } /** - * Creates a data store definition for the provided Redux store options containing + * Creates a data store descriptor for the provided Redux store configuration containing * properties describing reducer, actions, selectors, controls and resolvers. * * @example @@ -2068,12 +2236,12 @@ * } ); * ``` * - * @param {string} key Unique namespace identifier. - * @param {WPDataReduxStoreConfig} options Registered store options, with properties - * describing reducer, actions, selectors, - * and resolvers. - * - * @return {WPDataStore} Store Object. + * @param {string} key Unique namespace identifier. + * @param {ReduxStoreConfig} options Registered store options, with properties + * describing reducer, actions, selectors, + * and resolvers. + * + * @return {StoreDescriptor} Store Object. */ @@ -2104,13 +2272,25 @@ const actions = mapActions({ ...actions_namespaceObject, ...options.actions }, store); - let selectors = mapSelectors({ ...Object(external_lodash_["mapValues"])(selectors_namespaceObject, selector => (state, ...args) => selector(state.metadata, ...args)), - ...Object(external_lodash_["mapValues"])(options.selectors, selector => { + let selectors = mapSelectors({ ...(0,external_lodash_namespaceObject.mapValues)(selectors_namespaceObject, selector => function (state) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return selector(state.metadata, ...args); + }), + ...(0,external_lodash_namespaceObject.mapValues)(options.selectors, selector => { if (selector.isRegistrySelector) { selector.registry = registry; } - return (state, ...args) => selector(state.root, ...args); + return function (state) { + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + return selector(state.root, ...args); + }; }) }, store); @@ -2171,12 +2351,12 @@ /** * Creates a redux store for a namespace. * - * @param {string} key Unique namespace identifier. - * @param {Object} options Registered store options, with properties - * describing reducer, actions, selectors, - * and resolvers. - * @param {WPDataRegistry} registry Registry reference. - * @param {Object} thunkArgs Argument object for the thunk middleware. + * @param {string} key Unique namespace identifier. + * @param {Object} options Registered store options, with properties + * describing reducer, actions, selectors, + * and resolvers. + * @param {DataRegistry} registry Registry reference. + * @param {Object} thunkArgs Argument object for the thunk middleware. * @return {Object} Newly created redux store. */ @@ -2184,13 +2364,8 @@ const controls = { ...options.controls, ...builtinControls }; - const normalizedControls = Object(external_lodash_["mapValues"])(controls, control => control.isRegistryControl ? control(registry) : control); - const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls)]; - - if (options.__experimentalUseThunks) { - middlewares.push(createThunkMiddleware(thunkArgs)); - } - + const normalizedControls = (0,external_lodash_namespaceObject.mapValues)(controls, control => control.isRegistryControl ? control(registry) : control); + const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls), createThunkMiddleware(thunkArgs)]; const enhancers = [applyMiddleware(...middlewares)]; if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) { @@ -2208,9 +2383,9 @@ metadata: metadata_reducer, root: reducer }); - return redux_createStore(enhancedReducer, { + return createStore(enhancedReducer, { root: initialState - }, Object(external_lodash_["flowRight"])(enhancers)); + }, (0,external_lodash_namespaceObject.flowRight)(enhancers)); } /** * Maps selectors to a store. @@ -2248,53 +2423,87 @@ return selector; }; - return Object(external_lodash_["mapValues"])(selectors, createStateSelector); + return (0,external_lodash_namespaceObject.mapValues)(selectors, createStateSelector); } /** * Maps actions to dispatch from a given store. * - * @param {Object} actions Actions to register. - * @param {Object} store The redux store to which the actions should be mapped. - * @return {Object} Actions mapped to the redux store provided. + * @param {Object} actions Actions to register. + * @param {Object} store The redux store to which the actions should be mapped. + * + * @return {Object} Actions mapped to the redux store provided. */ function mapActions(actions, store) { - const createBoundAction = action => (...args) => { - return Promise.resolve(store.dispatch(action(...args))); + const createBoundAction = action => function () { + return Promise.resolve(store.dispatch(action(...arguments))); }; - return Object(external_lodash_["mapValues"])(actions, createBoundAction); + return (0,external_lodash_namespaceObject.mapValues)(actions, createBoundAction); } /** * Maps selectors to functions that return a resolution promise for them * * @param {Object} selectors Selectors to map. * @param {Object} store The redux store the selectors select from. - * @return {Object} Selectors mapped to their resolution functions. + * + * @return {Object} Selectors mapped to their resolution functions. */ function mapResolveSelectors(selectors, store) { - return Object(external_lodash_["mapValues"])(Object(external_lodash_["omit"])(selectors, ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers']), (selector, selectorName) => (...args) => new Promise(resolve => { - const hasFinished = () => selectors.hasFinishedResolution(selectorName, args); - - const getResult = () => selector.apply(null, args); // trigger the selector (to trigger the resolver) - - - const result = getResult(); - - if (hasFinished()) { - return resolve(result); + const storeSelectors = (0,external_lodash_namespaceObject.omit)(selectors, ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'hasResolutionFailed', 'isResolving', 'getCachedResolvers', 'getResolutionState', 'getResolutionError']); + return (0,external_lodash_namespaceObject.mapValues)(storeSelectors, (selector, selectorName) => { + // If the selector doesn't have a resolver, just convert the return value + // (including exceptions) to a Promise, no additional extra behavior is needed. + if (!selector.hasResolver) { + return async function () { + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + return selector.apply(null, args); + }; } - const unsubscribe = store.subscribe(() => { - if (hasFinished()) { - unsubscribe(); - resolve(getResult()); + return function () { + for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; } - }); - })); + + return new Promise((resolve, reject) => { + const hasFinished = () => selectors.hasFinishedResolution(selectorName, args); + + const finalize = result => { + const hasFailed = selectors.hasResolutionFailed(selectorName, args); + + if (hasFailed) { + const error = selectors.getResolutionError(selectorName, args); + reject(error); + } else { + resolve(result); + } + }; + + const getResult = () => selector.apply(null, args); // Trigger the selector (to trigger the resolver) + + + const result = getResult(); + + if (hasFinished()) { + return finalize(result); + } + + const unsubscribe = store.subscribe(() => { + if (hasFinished()) { + unsubscribe(); + finalize(getResult()); + } + }); + }); + }; + }); } /** * Returns resolvers with matched selectors for a given namespace. @@ -2312,14 +2521,14 @@ // The `resolver` can be either a function that does the resolution, or, in more advanced // cases, an object with a `fullfill` method and other optional methods like `isFulfilled`. // Here we normalize the `resolver` function to an object with `fulfill` method. - const mappedResolvers = Object(external_lodash_["mapValues"])(resolvers, resolver => { + const mappedResolvers = (0,external_lodash_namespaceObject.mapValues)(resolvers, resolver => { if (resolver.fulfill) { return resolver; } return { ...resolver, - // copy the enumerable properties of the resolver function - fulfill: resolver // add the fulfill method + // Copy the enumerable properties of the resolver function. + fulfill: resolver // Add the fulfill method. }; }); @@ -2332,7 +2541,11 @@ return selector; } - const selectorResolver = (...args) => { + const selectorResolver = function () { + for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { + args[_key5] = arguments[_key5]; + } + async function fulfillSelector() { const state = store.getState(); @@ -2352,8 +2565,13 @@ setTimeout(async () => { resolversCache.clear(selectorName, args); store.dispatch(startResolution(selectorName, args)); - await fulfillResolver(store, mappedResolvers, selectorName, ...args); - store.dispatch(finishResolution(selectorName, args)); + + try { + await fulfillResolver(store, mappedResolvers, selectorName, ...args); + store.dispatch(finishResolution(selectorName, args)); + } catch (error) { + store.dispatch(failResolution(selectorName, args, error)); + } }); } @@ -2367,7 +2585,7 @@ return { resolvers: mappedResolvers, - selectors: Object(external_lodash_["mapValues"])(selectors, mapSelector) + selectors: (0,external_lodash_namespaceObject.mapValues)(selectors, mapSelector) }; } /** @@ -2376,17 +2594,21 @@ * @param {Object} store Store reference, for fulfilling via resolvers * @param {Object} resolvers Store Resolvers * @param {string} selectorName Selector name to fulfill. - * @param {Array} args Selector Arguments. + * @param {Array} args Selector Arguments. */ -async function fulfillResolver(store, resolvers, selectorName, ...args) { - const resolver = Object(external_lodash_["get"])(resolvers, [selectorName]); +async function fulfillResolver(store, resolvers, selectorName) { + const resolver = (0,external_lodash_namespaceObject.get)(resolvers, [selectorName]); if (!resolver) { return; } + for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) { + args[_key6 - 3] = arguments[_key6]; + } + const action = resolver.fulfill(...args); if (action) { @@ -2394,54 +2616,75 @@ } } -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js -function createCoreDataStore(registry) { - const getCoreDataSelector = selectorName => (key, ...args) => { - return registry.select(key)[selectorName](...args); - }; - - const getCoreDataAction = actionName => (key, ...args) => { - return registry.dispatch(key)[actionName](...args); - }; +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/utils/emitter.js +/** + * Create an event emitter. + * + * @return {import("../types").DataEmitter} Emitter. + */ +function createEmitter() { + let isPaused = false; + let isPending = false; + const listeners = new Set(); + + const notifyListeners = () => // We use Array.from to clone the listeners Set + // This ensures that we don't run a listener + // that was added as a response to another listener. + Array.from(listeners).forEach(listener => listener()); return { - getSelectors() { - return ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].reduce((memo, selectorName) => ({ ...memo, - [selectorName]: getCoreDataSelector(selectorName) - }), {}); + get isPaused() { + return isPaused; + }, + + subscribe(listener) { + listeners.add(listener); + return () => listeners.delete(listener); + }, + + pause() { + isPaused = true; }, - getActions() { - return ['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].reduce((memo, actionName) => ({ ...memo, - [actionName]: getCoreDataAction(actionName) - }), {}); + resume() { + isPaused = false; + + if (isPending) { + isPending = false; + notifyListeners(); + } }, - subscribe() { - // There's no reasons to trigger any listener when we subscribe to this store - // because there's no state stored in this store that need to retrigger selectors - // if a change happens, the corresponding store where the tracking stated live - // would have already triggered a "subscribe" call. - return () => {}; + emit() { + if (isPaused) { + isPending = true; + return; + } + + notifyListeners(); } }; } -/* harmony default export */ var build_module_store = (createCoreDataStore); - -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js /** * External dependencies */ /** + * WordPress dependencies + */ + + +/** * Internal dependencies */ -/** @typedef {import('./types').WPDataStore} WPDataStore */ + +/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ /** * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations. @@ -2479,49 +2722,44 @@ * @return {WPDataRegistry} Data registry. */ -function createRegistry(storeConfigs = {}, parent = null) { +function createRegistry() { + let storeConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; const stores = {}; - let listeners = []; - - const __experimentalListeningStores = new Set(); + const emitter = createEmitter(); + const listeningStores = new Set(); /** * Global listener called for each store's update. */ - function globalListener() { - listeners.forEach(listener => listener()); + emitter.emit(); } /** * Subscribe to changes to any data. * - * @param {Function} listener Listener function. + * @param {Function} listener Listener function. * - * @return {Function} Unsubscribe function. + * @return {Function} Unsubscribe function. */ const subscribe = listener => { - listeners.push(listener); - return () => { - listeners = Object(external_lodash_["without"])(listeners, listener); - }; + return emitter.subscribe(listener); }; /** * Calls a selector given the current state and extra arguments. * - * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store - * or the store definition. + * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store + * or the store descriptor. * * @return {*} The selector's returned value. */ - function select(storeNameOrDefinition) { - const storeName = Object(external_lodash_["isObject"])(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; - - __experimentalListeningStores.add(storeName); - + function select(storeNameOrDescriptor) { + const storeName = (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor; + listeningStores.add(storeName); const store = stores[storeName]; if (store) { @@ -2531,11 +2769,10 @@ return parent && parent.select(storeName); } - function __experimentalMarkListeningStores(callback, ref) { - __experimentalListeningStores.clear(); - + function __unstableMarkListeningStores(callback, ref) { + listeningStores.clear(); const result = callback.call(this); - ref.current = Array.from(__experimentalListeningStores); + ref.current = Array.from(listeningStores); return result; } /** @@ -2544,18 +2781,16 @@ * and modified so that they return promises that resolve to their eventual values, * after any resolvers have ran. * - * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store - * or the store definition. + * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store + * or the store descriptor. * * @return {Object} Each key of the object matches the name of a selector. */ - function resolveSelect(storeNameOrDefinition) { - const storeName = Object(external_lodash_["isObject"])(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; - - __experimentalListeningStores.add(storeName); - + function resolveSelect(storeNameOrDescriptor) { + const storeName = (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor; + listeningStores.add(storeName); const store = stores[storeName]; if (store) { @@ -2567,15 +2802,15 @@ /** * Returns the available actions for a part of the state. * - * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store - * or the store definition. + * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store + * or the store descriptor. * * @return {*} The action's returned value. */ - function dispatch(storeNameOrDefinition) { - const storeName = Object(external_lodash_["isObject"])(storeNameOrDefinition) ? storeNameOrDefinition.name : storeNameOrDefinition; + function dispatch(storeNameOrDescriptor) { + const storeName = (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor; const store = stores[storeName]; if (store) { @@ -2586,11 +2821,10 @@ } // // Deprecated // TODO: Remove this after `use()` is removed. - // function withPlugins(attributes) { - return Object(external_lodash_["mapValues"])(attributes, (attribute, key) => { + return (0,external_lodash_namespaceObject.mapValues)(attributes, (attribute, key) => { if (typeof attribute !== 'function') { return attribute; } @@ -2601,38 +2835,87 @@ }); } /** - * Registers a generic store. + * Registers a store instance. * - * @param {string} key Store registry key. - * @param {Object} config Configuration (getSelectors, getActions, subscribe). + * @param {string} name Store registry name. + * @param {Object} store Store instance object (getSelectors, getActions, subscribe). */ - function registerGenericStore(key, config) { - if (typeof config.getSelectors !== 'function') { - throw new TypeError('config.getSelectors must be a function'); + function registerStoreInstance(name, store) { + if (typeof store.getSelectors !== 'function') { + throw new TypeError('store.getSelectors must be a function'); + } + + if (typeof store.getActions !== 'function') { + throw new TypeError('store.getActions must be a function'); } - if (typeof config.getActions !== 'function') { - throw new TypeError('config.getActions must be a function'); - } - - if (typeof config.subscribe !== 'function') { - throw new TypeError('config.subscribe must be a function'); - } - - stores[key] = config; - config.subscribe(globalListener); + if (typeof store.subscribe !== 'function') { + throw new TypeError('store.subscribe must be a function'); + } // The emitter is used to keep track of active listeners when the registry + // get paused, that way, when resumed we should be able to call all these + // pending listeners. + + + store.emitter = createEmitter(); + const currentSubscribe = store.subscribe; + + store.subscribe = listener => { + const unsubscribeFromEmitter = store.emitter.subscribe(listener); + const unsubscribeFromStore = currentSubscribe(() => { + if (store.emitter.isPaused) { + store.emitter.emit(); + return; + } + + listener(); + }); + return () => { + unsubscribeFromStore === null || unsubscribeFromStore === void 0 ? void 0 : unsubscribeFromStore(); + unsubscribeFromEmitter === null || unsubscribeFromEmitter === void 0 ? void 0 : unsubscribeFromEmitter(); + }; + }; + + stores[name] = store; + store.subscribe(globalListener); } /** - * Registers a new store definition. + * Registers a new store given a store descriptor. * - * @param {WPDataStore} store Store definition. + * @param {StoreDescriptor} store Store descriptor. */ function register(store) { - registerGenericStore(store.name, store.instantiate(registry)); + registerStoreInstance(store.name, store.instantiate(registry)); + } + + function registerGenericStore(name, store) { + external_wp_deprecated_default()('wp.data.registerGenericStore', { + since: '5.9', + alternative: 'wp.data.register( storeDescriptor )' + }); + registerStoreInstance(name, store); + } + /** + * Registers a standard `@wordpress/data` store. + * + * @param {string} storeName Unique namespace identifier. + * @param {Object} options Store description (reducer, actions, selectors, resolvers). + * + * @return {Object} Registered store object. + */ + + + function registerStore(storeName, options) { + if (!options.reducer) { + throw new TypeError('Must specify store reducer'); + } + + const store = createReduxStore(storeName, options).instantiate(registry); + registerStoreInstance(storeName, store); + return store.store; } /** * Subscribe handler to a store. @@ -2643,7 +2926,7 @@ */ - function __experimentalSubscribeStore(storeName, handler) { + function __unstableSubscribeStore(storeName, handler) { if (storeName in stores) { return stores[storeName].subscribe(handler); } // Trying to access a store that hasn't been registered, @@ -2656,11 +2939,19 @@ return subscribe(handler); } - return parent.__experimentalSubscribeStore(storeName, handler); + return parent.__unstableSubscribeStore(storeName, handler); + } + + function batch(callback) { + emitter.pause(); + (0,external_lodash_namespaceObject.forEach)(stores, store => store.emitter.pause()); + callback(); + emitter.resume(); + (0,external_lodash_namespaceObject.forEach)(stores, store => store.emitter.resume()); } let registry = { - registerGenericStore, + batch, stores, namespaces: stores, // TODO: Deprecate/remove this. @@ -2670,41 +2961,30 @@ dispatch, use, register, - __experimentalMarkListeningStores, - __experimentalSubscribeStore - }; - /** - * Registers a standard `@wordpress/data` store. - * - * @param {string} storeName Unique namespace identifier. - * @param {Object} options Store description (reducer, actions, selectors, resolvers). - * - * @return {Object} Registered store object. - */ - - registry.registerStore = (storeName, options) => { - if (!options.reducer) { - throw new TypeError('Must specify store reducer'); - } - - const store = createReduxStore(storeName, options).instantiate(registry); - registerGenericStore(storeName, store); - return store.store; + registerGenericStore, + registerStore, + __unstableMarkListeningStores, + __unstableSubscribeStore }; // // TODO: // This function will be deprecated as soon as it is no longer internally referenced. - // - function use(plugin, options) { + if (!plugin) { + return; + } + registry = { ...registry, ...plugin(registry, options) }; return registry; } - registerGenericStore('core/data', build_module_store(registry)); - Object.entries(storeConfigs).forEach(([name, config]) => registry.registerStore(name, config)); + registry.register(store); + + for (const [name, config] of Object.entries(storeConfigs)) { + registry.register(createReduxStore(name, config)); + } if (parent) { parent.subscribe(globalListener); @@ -2713,31 +2993,14 @@ return withPlugins(registry); } -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js /** * Internal dependencies */ /* harmony default export */ var default_registry = (createRegistry()); -// EXTERNAL MODULE: external ["wp","deprecated"] -var external_wp_deprecated_ = __webpack_require__("NMb1"); -var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_); - -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/controls/index.js -/** - * WordPress dependencies - */ - -/* harmony default export */ var plugins_controls = (registry => { - external_wp_deprecated_default()('wp.data.plugins.controls', { - since: '5.4', - hint: 'The controls plugins is now baked-in.' - }); - return registry; -}); - -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js let objectStorage; const storage = { getItem(key) { @@ -2763,7 +3026,7 @@ }; /* harmony default export */ var object = (storage); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js /** * Internal dependencies */ @@ -2783,7 +3046,7 @@ /* harmony default export */ var storage_default = (default_storage); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js /** * External dependencies */ @@ -2969,13 +3232,13 @@ type: '@@WP/PERSISTENCE_RESTORE' }); - if (Object(external_lodash_["isPlainObject"])(initialState) && Object(external_lodash_["isPlainObject"])(persistedState)) { + if ((0,external_lodash_namespaceObject.isPlainObject)(initialState) && (0,external_lodash_namespaceObject.isPlainObject)(persistedState)) { // If state is an object, ensure that: // - Other keys are left intact when persisting only a // subset of keys. // - New keys in what would otherwise be used as initial // state are deeply merged as base for persisted value. - initialState = Object(external_lodash_["merge"])({}, initialState, persistedState); + initialState = (0,external_lodash_namespaceObject.merge)({}, initialState, persistedState); } else { // If there is a mismatch in object-likeness of default // initial or persisted state, defer to persisted value. @@ -2995,96 +3258,452 @@ }; } /** - * Deprecated: Remove this function and the code in WordPress Core that calls - * it once WordPress 5.4 is released. + * Move the 'features' object in local storage from the sourceStoreName to the + * preferences store. + * + * @param {Object} persistence The persistence interface. + * @param {string} sourceStoreName The name of the store that has persisted + * preferences to migrate to the preferences + * package. + */ + + +function migrateFeaturePreferencesToPreferencesStore(persistence, sourceStoreName) { + var _state$interfaceStore, _state$interfaceStore2, _state$interfaceStore3, _state$sourceStoreNam, _state$sourceStoreNam2; + + const preferencesStoreName = 'core/preferences'; + const interfaceStoreName = 'core/interface'; + const state = persistence.get(); // Features most recently (and briefly) lived in the interface package. + // If data exists there, prioritize using that for the migration. If not + // also check the original package as the user may have updated from an + // older block editor version. + + const interfaceFeatures = (_state$interfaceStore = state[interfaceStoreName]) === null || _state$interfaceStore === void 0 ? void 0 : (_state$interfaceStore2 = _state$interfaceStore.preferences) === null || _state$interfaceStore2 === void 0 ? void 0 : (_state$interfaceStore3 = _state$interfaceStore2.features) === null || _state$interfaceStore3 === void 0 ? void 0 : _state$interfaceStore3[sourceStoreName]; + const sourceFeatures = (_state$sourceStoreNam = state[sourceStoreName]) === null || _state$sourceStoreNam === void 0 ? void 0 : (_state$sourceStoreNam2 = _state$sourceStoreNam.preferences) === null || _state$sourceStoreNam2 === void 0 ? void 0 : _state$sourceStoreNam2.features; + const featuresToMigrate = interfaceFeatures ? interfaceFeatures : sourceFeatures; + + if (featuresToMigrate) { + var _state$preferencesSto; + + const existingPreferences = (_state$preferencesSto = state[preferencesStoreName]) === null || _state$preferencesSto === void 0 ? void 0 : _state$preferencesSto.preferences; // Avoid migrating features again if they've previously been migrated. + + if (!(existingPreferences !== null && existingPreferences !== void 0 && existingPreferences[sourceStoreName])) { + // Set the feature values in the interface store, the features + // object is keyed by 'scope', which matches the store name for + // the source. + persistence.set(preferencesStoreName, { + preferences: { ...existingPreferences, + [sourceStoreName]: featuresToMigrate + } + }); // Remove migrated feature preferences from `interface`. + + if (interfaceFeatures) { + var _state$interfaceStore4, _state$interfaceStore5; + + const otherInterfaceState = state[interfaceStoreName]; + const otherInterfaceScopes = (_state$interfaceStore4 = state[interfaceStoreName]) === null || _state$interfaceStore4 === void 0 ? void 0 : (_state$interfaceStore5 = _state$interfaceStore4.preferences) === null || _state$interfaceStore5 === void 0 ? void 0 : _state$interfaceStore5.features; + persistence.set(interfaceStoreName, { ...otherInterfaceState, + preferences: { + features: { ...otherInterfaceScopes, + [sourceStoreName]: undefined + } + } + }); + } // Remove migrated feature preferences from the source. + + + if (sourceFeatures) { + var _state$sourceStoreNam3; + + const otherSourceState = state[sourceStoreName]; + const sourcePreferences = (_state$sourceStoreNam3 = state[sourceStoreName]) === null || _state$sourceStoreNam3 === void 0 ? void 0 : _state$sourceStoreNam3.preferences; + persistence.set(sourceStoreName, { ...otherSourceState, + preferences: { ...sourcePreferences, + features: undefined + } + }); + } + } + } +} +/** + * Migrates an individual item inside the `preferences` object for a store. + * + * @param {Object} persistence The persistence interface. + * @param {Object} migrate An options object that contains details of the migration. + * @param {string} migrate.from The name of the store to migrate from. + * @param {string} migrate.scope The scope in the preferences store to migrate to. + * @param {string} key The key in the preferences object to migrate. + * @param {?Function} convert A function that converts preferences from one format to another. */ - -persistencePlugin.__unstableMigrate = pluginOptions => { - var _state$coreEditor, _state$coreEditor$pre; - - const persistence = createPersistenceInterface(pluginOptions); - const state = persistence.get(); // Migrate 'insertUsage' from 'core/editor' to 'core/block-editor' - - 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; - - if (editorInsertUsage) { - var _state$coreBlockEdi, _state$coreBlockEdi$p; - - 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; - persistence.set('core/block-editor', { +function migrateIndividualPreferenceToPreferencesStore(persistence, _ref, key) { + var _state$sourceStoreNam4, _state$sourceStoreNam5, _state$preferencesSto2, _state$preferencesSto3, _state$preferencesSto4, _state$preferencesSto5, _state$preferencesSto6, _state$preferencesSto7, _state$sourceStoreNam6; + + let { + from: sourceStoreName, + scope + } = _ref; + let convert = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : external_lodash_namespaceObject.identity; + const preferencesStoreName = 'core/preferences'; + const state = persistence.get(); + const sourcePreference = (_state$sourceStoreNam4 = state[sourceStoreName]) === null || _state$sourceStoreNam4 === void 0 ? void 0 : (_state$sourceStoreNam5 = _state$sourceStoreNam4.preferences) === null || _state$sourceStoreNam5 === void 0 ? void 0 : _state$sourceStoreNam5[key]; // There's nothing to migrate, exit early. + + if (sourcePreference === undefined) { + return; + } + + const targetPreference = (_state$preferencesSto2 = state[preferencesStoreName]) === null || _state$preferencesSto2 === void 0 ? void 0 : (_state$preferencesSto3 = _state$preferencesSto2.preferences) === null || _state$preferencesSto3 === void 0 ? void 0 : (_state$preferencesSto4 = _state$preferencesSto3[scope]) === null || _state$preferencesSto4 === void 0 ? void 0 : _state$preferencesSto4[key]; // There's existing data at the target, so don't overwrite it, exit early. + + if (targetPreference) { + return; + } + + const otherScopes = (_state$preferencesSto5 = state[preferencesStoreName]) === null || _state$preferencesSto5 === void 0 ? void 0 : _state$preferencesSto5.preferences; + const otherPreferences = (_state$preferencesSto6 = state[preferencesStoreName]) === null || _state$preferencesSto6 === void 0 ? void 0 : (_state$preferencesSto7 = _state$preferencesSto6.preferences) === null || _state$preferencesSto7 === void 0 ? void 0 : _state$preferencesSto7[scope]; // Pass an object with the key and value as this allows the convert + // function to convert to a data structure that has different keys. + + const convertedPreferences = convert({ + [key]: sourcePreference + }); + persistence.set(preferencesStoreName, { + preferences: { ...otherScopes, + [scope]: { ...otherPreferences, + ...convertedPreferences + } + } + }); // Remove migrated feature preferences from the source. + + const otherSourceState = state[sourceStoreName]; + const allSourcePreferences = (_state$sourceStoreNam6 = state[sourceStoreName]) === null || _state$sourceStoreNam6 === void 0 ? void 0 : _state$sourceStoreNam6.preferences; + persistence.set(sourceStoreName, { ...otherSourceState, + preferences: { ...allSourcePreferences, + [key]: undefined + } + }); +} +/** + * Convert from: + * ``` + * { + * panels: { + * tags: { + * enabled: true, + * opened: true, + * }, + * permalinks: { + * enabled: false, + * opened: false, + * }, + * }, + * } + * ``` + * + * to: + * { + * inactivePanels: [ + * 'permalinks', + * ], + * openPanels: [ + * 'tags', + * ], + * } + * + * @param {Object} preferences A preferences object. + * + * @return {Object} The converted data. + */ + +function convertEditPostPanels(preferences) { + var _preferences$panels; + + const panels = (_preferences$panels = preferences === null || preferences === void 0 ? void 0 : preferences.panels) !== null && _preferences$panels !== void 0 ? _preferences$panels : {}; + return Object.keys(panels).reduce((convertedData, panelName) => { + const panel = panels[panelName]; + + if ((panel === null || panel === void 0 ? void 0 : panel.enabled) === false) { + convertedData.inactivePanels.push(panelName); + } + + if ((panel === null || panel === void 0 ? void 0 : panel.opened) === true) { + convertedData.openPanels.push(panelName); + } + + return convertedData; + }, { + inactivePanels: [], + openPanels: [] + }); +} +function migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence) { + var _state$interfaceStore6, _state$interfaceStore7; + + const interfaceStoreName = 'core/interface'; + const preferencesStoreName = 'core/preferences'; + let state = persistence.get(); + const interfaceScopes = (_state$interfaceStore6 = state[interfaceStoreName]) === null || _state$interfaceStore6 === void 0 ? void 0 : (_state$interfaceStore7 = _state$interfaceStore6.preferences) === null || _state$interfaceStore7 === void 0 ? void 0 : _state$interfaceStore7.features; + + for (const scope in interfaceScopes) { + var _state$preferencesSto8, _state$interfaceStore8, _state$interfaceStore9; + + // Don't migrate any core 'scopes'. + if (scope.startsWith('core')) { + continue; + } // Skip this scope if there are no features to migrate. + + + const featuresToMigrate = interfaceScopes[scope]; + + if (!featuresToMigrate) { + continue; + } + + const existingPreferences = (_state$preferencesSto8 = state[preferencesStoreName]) === null || _state$preferencesSto8 === void 0 ? void 0 : _state$preferencesSto8.preferences; // Add the data to the preferences store structure. + + persistence.set(preferencesStoreName, { + preferences: { ...existingPreferences, + [scope]: featuresToMigrate + } + }); // Remove the data from the interface store structure. + // Call `persistence.get` again to make sure `state` is up-to-date with + // any changes from the previous iteration of this loop. + + state = persistence.get(); + const otherInterfaceState = state[interfaceStoreName]; + const otherInterfaceScopes = (_state$interfaceStore8 = state[interfaceStoreName]) === null || _state$interfaceStore8 === void 0 ? void 0 : (_state$interfaceStore9 = _state$interfaceStore8.preferences) === null || _state$interfaceStore9 === void 0 ? void 0 : _state$interfaceStore9.features; + persistence.set(interfaceStoreName, { ...otherInterfaceState, preferences: { - insertUsage: { ...editorInsertUsage, - ...blockEditorInsertUsage + features: { ...otherInterfaceScopes, + [scope]: undefined } } }); } - - let editPostState = state['core/edit-post']; // Default `fullscreenMode` to `false` if any persisted state had existed - // and the user hadn't made an explicit choice about fullscreen mode. This - // is needed since `fullscreenMode` previously did not have a default value - // and was implicitly false by its absence. It is now `true` by default, but - // this change is not intended to affect upgrades from earlier versions. - - const hadPersistedState = Object.keys(state).length > 0; - const hadFullscreenModePreference = Object(external_lodash_["has"])(state, ['core/edit-post', 'preferences', 'features', 'fullscreenMode']); - - if (hadPersistedState && !hadFullscreenModePreference) { - editPostState = Object(external_lodash_["merge"])({}, editPostState, { - preferences: { - features: { - fullscreenMode: false - } +} +/** + * Migrates interface 'enableItems' data to the preferences store. + * + * The interface package stores this data in this format: + * ```js + * { + * enableItems: { + * singleEnableItems: { + * complementaryArea: { + * 'core/edit-post': 'edit-post/document', + * 'core/edit-site': 'edit-site/global-styles', + * } + * }, + * multipleEnableItems: { + * pinnedItems: { + * 'core/edit-post': { + * 'plugin-1': true, + * }, + * 'core/edit-site': { + * 'plugin-2': true, + * }, + * }, + * } + * } + * } + * ``` + * and it should be migrated it to: + * ```js + * { + * 'core/edit-post': { + * complementaryArea: 'edit-post/document', + * pinnedItems: { + * 'plugin-1': true, + * }, + * }, + * 'core/edit-site': { + * complementaryArea: 'edit-site/global-styles', + * pinnedItems: { + * 'plugin-2': true, + * }, + * }, + * } + * ``` + * + * @param {Object} persistence The persistence interface. + */ + +function migrateInterfaceEnableItemsToPreferencesStore(persistence) { + var _state$interfaceStore10, _state$preferencesSto9, _state$preferencesSto10, _sourceEnableItems$si, _sourceEnableItems$si2, _sourceEnableItems$mu, _sourceEnableItems$mu2; + + const interfaceStoreName = 'core/interface'; + const preferencesStoreName = 'core/preferences'; + const state = persistence.get(); + const sourceEnableItems = (_state$interfaceStore10 = state[interfaceStoreName]) === null || _state$interfaceStore10 === void 0 ? void 0 : _state$interfaceStore10.enableItems; // There's nothing to migrate, exit early. + + if (!sourceEnableItems) { + return; + } + + const allPreferences = (_state$preferencesSto9 = (_state$preferencesSto10 = state[preferencesStoreName]) === null || _state$preferencesSto10 === void 0 ? void 0 : _state$preferencesSto10.preferences) !== null && _state$preferencesSto9 !== void 0 ? _state$preferencesSto9 : {}; // First convert complementaryAreas into the right format. + // Use the existing preferences as the accumulator so that the data is + // merged. + + const sourceComplementaryAreas = (_sourceEnableItems$si = sourceEnableItems === null || sourceEnableItems === void 0 ? void 0 : (_sourceEnableItems$si2 = sourceEnableItems.singleEnableItems) === null || _sourceEnableItems$si2 === void 0 ? void 0 : _sourceEnableItems$si2.complementaryArea) !== null && _sourceEnableItems$si !== void 0 ? _sourceEnableItems$si : {}; + const convertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => { + var _accumulator$scope; + + const data = sourceComplementaryAreas[scope]; // Don't overwrite any existing data in the preferences store. + + if ((_accumulator$scope = accumulator[scope]) !== null && _accumulator$scope !== void 0 && _accumulator$scope.complementaryArea) { + return accumulator; + } + + return { ...accumulator, + [scope]: { ...accumulator[scope], + complementaryArea: data } - }); - } // Migrate 'areTipsEnabled' from 'core/nux' to 'showWelcomeGuide' in 'core/edit-post' - - - const areTipsEnabled = Object(external_lodash_["get"])(state, ['core/nux', 'preferences', 'areTipsEnabled']); - const hasWelcomeGuide = Object(external_lodash_["has"])(state, ['core/edit-post', 'preferences', 'features', 'welcomeGuide']); - - if (areTipsEnabled !== undefined && !hasWelcomeGuide) { - editPostState = Object(external_lodash_["merge"])({}, editPostState, { - preferences: { - features: { - welcomeGuide: areTipsEnabled + }; + }, allPreferences); // Next feed the converted complementary areas back into a reducer that + // converts the pinned items, resulting in the fully migrated data. + + const sourcePinnedItems = (_sourceEnableItems$mu = sourceEnableItems === null || sourceEnableItems === void 0 ? void 0 : (_sourceEnableItems$mu2 = sourceEnableItems.multipleEnableItems) === null || _sourceEnableItems$mu2 === void 0 ? void 0 : _sourceEnableItems$mu2.pinnedItems) !== null && _sourceEnableItems$mu !== void 0 ? _sourceEnableItems$mu : {}; + const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => { + var _accumulator$scope2; + + const data = sourcePinnedItems[scope]; // Don't overwrite any existing data in the preferences store. + + if ((_accumulator$scope2 = accumulator[scope]) !== null && _accumulator$scope2 !== void 0 && _accumulator$scope2.pinnedItems) { + return accumulator; + } + + return { ...accumulator, + [scope]: { ...accumulator[scope], + pinnedItems: data + } + }; + }, convertedComplementaryAreas); + persistence.set(preferencesStoreName, { + preferences: allConvertedData + }); // Remove migrated preferences. + + const otherInterfaceItems = state[interfaceStoreName]; + persistence.set(interfaceStoreName, { ...otherInterfaceItems, + enableItems: undefined + }); +} + +persistencePlugin.__unstableMigrate = pluginOptions => { + const persistence = createPersistenceInterface(pluginOptions); // Boolean feature preferences. + + migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-widgets'); + migrateFeaturePreferencesToPreferencesStore(persistence, 'core/customize-widgets'); + migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-post'); + migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-site'); + migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence); // Other ad-hoc preferences. + + migrateIndividualPreferenceToPreferencesStore(persistence, { + from: 'core/edit-post', + scope: 'core/edit-post' + }, 'hiddenBlockTypes'); + migrateIndividualPreferenceToPreferencesStore(persistence, { + from: 'core/edit-post', + scope: 'core/edit-post' + }, 'editorMode'); + migrateIndividualPreferenceToPreferencesStore(persistence, { + from: 'core/edit-post', + scope: 'core/edit-post' + }, 'preferredStyleVariations'); + migrateIndividualPreferenceToPreferencesStore(persistence, { + from: 'core/edit-post', + scope: 'core/edit-post' + }, 'panels', convertEditPostPanels); + migrateIndividualPreferenceToPreferencesStore(persistence, { + from: 'core/editor', + scope: 'core/edit-post' + }, 'isPublishSidebarEnabled'); + migrateIndividualPreferenceToPreferencesStore(persistence, { + from: 'core/edit-site', + scope: 'core/edit-site' + }, 'editorMode'); + migrateInterfaceEnableItemsToPreferencesStore(persistence); +}; + +/* harmony default export */ var persistence = (persistencePlugin); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js + + +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js +function _extends() { + _extends = Object.assign ? Object.assign.bind() : function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; } } - }); + } + + return target; + }; + return _extends.apply(this, arguments); +} +;// CONCATENATED MODULE: external ["wp","element"] +var external_wp_element_namespaceObject = window["wp"]["element"]; +;// CONCATENATED MODULE: external ["wp","compose"] +var external_wp_compose_namespaceObject = window["wp"]["compose"]; +;// CONCATENATED MODULE: external "React" +var external_React_namespaceObject = window["React"]; +;// CONCATENATED MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js + + +function areInputsEqual(newInputs, lastInputs) { + if (newInputs.length !== lastInputs.length) { + return false; } - if (editPostState !== state['core/edit-post']) { - persistence.set('core/edit-post', editPostState); + for (var i = 0; i < newInputs.length; i++) { + if (newInputs[i] !== lastInputs[i]) { + return false; + } } -}; - -/* harmony default export */ var plugins_persistence = (persistencePlugin); - -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js - - - -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js -var esm_extends = __webpack_require__("wx14"); - -// EXTERNAL MODULE: external ["wp","element"] -var external_wp_element_ = __webpack_require__("GRId"); - -// EXTERNAL MODULE: external ["wp","compose"] -var external_wp_compose_ = __webpack_require__("K9lf"); - -// EXTERNAL MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js -var use_memo_one_esm = __webpack_require__("mHlH"); - -// EXTERNAL MODULE: external ["wp","priorityQueue"] -var external_wp_priorityQueue_ = __webpack_require__("XI5e"); - -// EXTERNAL MODULE: external ["wp","isShallowEqual"] -var external_wp_isShallowEqual_ = __webpack_require__("rl8x"); -var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_); - -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js + + return true; +} + +function useMemoOne(getResult, inputs) { + var initial = (0,external_React_namespaceObject.useState)(function () { + return { + inputs: inputs, + result: getResult() + }; + })[0]; + var isFirstRun = (0,external_React_namespaceObject.useRef)(true); + var committed = (0,external_React_namespaceObject.useRef)(initial); + var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); + var cache = useCache ? committed.current : { + inputs: inputs, + result: getResult() + }; + (0,external_React_namespaceObject.useEffect)(function () { + isFirstRun.current = false; + committed.current = cache; + }, [cache]); + return cache.result; +} +function useCallbackOne(callback, inputs) { + return useMemoOne(function () { + return callback; + }, inputs); +} +var useMemo = (/* unused pure expression or super */ null && (useMemoOne)); +var useCallback = (/* unused pure expression or super */ null && (useCallbackOne)); + + + +;// CONCATENATED MODULE: external ["wp","priorityQueue"] +var external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"]; +;// CONCATENATED MODULE: external ["wp","isShallowEqual"] +var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; +var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js /** * WordPress dependencies */ @@ -3094,7 +3713,7 @@ */ -const Context = Object(external_wp_element_["createContext"])(default_registry); +const Context = (0,external_wp_element_namespaceObject.createContext)(default_registry); const { Consumer, Provider @@ -3142,7 +3761,7 @@ /* harmony default export */ var context = (Provider); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js /** * WordPress dependencies */ @@ -3177,7 +3796,7 @@ * const registry = createRegistry( {} ); * * const SomeChildUsingRegistry = ( props ) => { - * const registry = useRegistry( registry ); + * const registry = useRegistry(); * // ...logic implementing the registry in other react hooks. * }; * @@ -3193,20 +3812,20 @@ */ function useRegistry() { - return Object(external_wp_element_["useContext"])(Context); + return (0,external_wp_element_namespaceObject.useContext)(Context); } -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js /** * WordPress dependencies */ -const context_Context = Object(external_wp_element_["createContext"])(false); +const context_Context = (0,external_wp_element_namespaceObject.createContext)(false); const { Consumer: context_Consumer, Provider: context_Provider } = context_Context; -const AsyncModeConsumer = context_Consumer; +const AsyncModeConsumer = (/* unused pure expression or super */ null && (context_Consumer)); /** * Context Provider Component used to switch the data module component rerendering * between Sync and Async modes. @@ -3238,13 +3857,13 @@ * the rerendering is delayed until the browser becomes IDLE. * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior. * - * @param {boolean} props.value Enable Async Mode. + * @param {boolean} props.value Enable Async Mode. * @return {WPComponent} The component to be rendered. */ /* harmony default export */ var async_mode_provider_context = (context_Provider); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js /** * WordPress dependencies */ @@ -3255,10 +3874,10 @@ function useAsyncMode() { - return Object(external_wp_element_["useContext"])(context_Context); + return (0,external_wp_element_namespaceObject.useContext)(context_Context); } -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js /** * External dependencies */ @@ -3277,8 +3896,11 @@ -const renderQueue = Object(external_wp_priorityQueue_["createQueue"])(); -/** @typedef {import('./types').WPDataStore} WPDataStore */ + +const noop = () => {}; + +const renderQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)(); +/** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */ /** * Custom react hook for retrieving props from registered selectors. @@ -3286,20 +3908,20 @@ * In general, this custom React hook follows the * [rules of hooks](https://reactjs.org/docs/hooks-rules.html). * - * @param {Function|WPDataStore|string} _mapSelect Function called on every state change. The - * returned value is exposed to the component - * implementing this hook. The function receives - * the `registry.select` method on the first - * argument and the `registry` on the second - * argument. - * When a store key is passed, all selectors for - * the store will be returned. This is only meant - * for usage of these selectors in event - * callbacks, not for data needed to create the - * element tree. - * @param {Array} deps If provided, this memoizes the mapSelect so the - * same `mapSelect` is invoked on every state - * change unless the dependencies change. + * @param {Function|StoreDescriptor|string} mapSelect Function called on every state change. The + * returned value is exposed to the component + * implementing this hook. The function receives + * the `registry.select` method on the first + * argument and the `registry` on the second + * argument. + * When a store key is passed, all selectors for + * the store will be returned. This is only meant + * for usage of these selectors in event + * callbacks, not for data needed to create the + * element tree. + * @param {Array} deps If provided, this memoizes the mapSelect so the + * same `mapSelect` is invoked on every state + * change unless the dependencies change. * * @example * ```js @@ -3348,66 +3970,77 @@ * @return {Function} A custom react hook. */ -function useSelect(_mapSelect, deps) { - const isWithoutMapping = typeof _mapSelect !== 'function'; - - if (isWithoutMapping) { +function useSelect(mapSelect, deps) { + const hasMappingFunction = 'function' === typeof mapSelect; // If we're recalling a store by its name or by + // its descriptor then we won't be caching the + // calls to `mapSelect` because we won't be calling it. + + if (!hasMappingFunction) { deps = []; - } - - const mapSelect = Object(external_wp_element_["useCallback"])(_mapSelect, deps); + } // Because of the "rule of hooks" we have to call `useCallback` + // on every invocation whether or not we have a real function + // for `mapSelect`. we'll create this intermediate variable to + // fulfill that need and then reference it with our "real" + // `_mapSelect` if we can. + + + const callbackMapper = (0,external_wp_element_namespaceObject.useCallback)(hasMappingFunction ? mapSelect : noop, deps); + + const _mapSelect = hasMappingFunction ? callbackMapper : null; + const registry = useRegistry(); const isAsync = useAsyncMode(); // React can sometimes clear the `useMemo` cache. // We use the cache-stable `useMemoOne` to avoid // losing queues. - const queueContext = Object(use_memo_one_esm["a" /* useMemoOne */])(() => ({ + const queueContext = useMemoOne(() => ({ queue: true }), [registry]); - const [, forceRender] = Object(external_wp_element_["useReducer"])(s => s + 1, 0); - const latestMapSelect = Object(external_wp_element_["useRef"])(); - const latestIsAsync = Object(external_wp_element_["useRef"])(isAsync); - const latestMapOutput = Object(external_wp_element_["useRef"])(); - const latestMapOutputError = Object(external_wp_element_["useRef"])(); - const isMountedAndNotUnsubscribing = Object(external_wp_element_["useRef"])(); // Keep track of the stores being selected in the mapSelect function, + const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(s => s + 1, 0); + const latestMapSelect = (0,external_wp_element_namespaceObject.useRef)(); + const latestIsAsync = (0,external_wp_element_namespaceObject.useRef)(isAsync); + const latestMapOutput = (0,external_wp_element_namespaceObject.useRef)(); + const latestMapOutputError = (0,external_wp_element_namespaceObject.useRef)(); + const isMountedAndNotUnsubscribing = (0,external_wp_element_namespaceObject.useRef)(); // Keep track of the stores being selected in the _mapSelect function, // and only subscribe to those stores later. - const listeningStores = Object(external_wp_element_["useRef"])([]); - const trapSelect = Object(external_wp_element_["useCallback"])(callback => registry.__experimentalMarkListeningStores(callback, listeningStores), [registry]); // Generate a "flag" for used in the effect dependency array. + const listeningStores = (0,external_wp_element_namespaceObject.useRef)([]); + const wrapSelect = (0,external_wp_element_namespaceObject.useCallback)(callback => registry.__unstableMarkListeningStores(() => callback(registry.select, registry), listeningStores), [registry]); // Generate a "flag" for used in the effect dependency array. // It's different than just using `mapSelect` since deps could be undefined, // in that case, we would still want to memoize it. - const depsChangedFlag = Object(external_wp_element_["useMemo"])(() => ({}), deps || []); + const depsChangedFlag = (0,external_wp_element_namespaceObject.useMemo)(() => ({}), deps || []); let mapOutput; - if (!isWithoutMapping) { - try { - if (latestMapSelect.current !== mapSelect || latestMapOutputError.current) { - mapOutput = trapSelect(() => mapSelect(registry.select, registry)); - } else { - mapOutput = latestMapOutput.current; + if (_mapSelect) { + mapOutput = latestMapOutput.current; + const hasReplacedMapSelect = latestMapSelect.current !== _mapSelect; + const lastMapSelectFailed = !!latestMapOutputError.current; + + if (hasReplacedMapSelect || lastMapSelectFailed) { + try { + mapOutput = wrapSelect(_mapSelect); + } catch (error) { + let errorMessage = `An error occurred while running 'mapSelect': ${error.message}`; + + if (latestMapOutputError.current) { + errorMessage += `\nThe error may be correlated with this previous error:\n`; + errorMessage += `${latestMapOutputError.current.stack}\n\n`; + errorMessage += 'Original stack trace:'; + } // eslint-disable-next-line no-console + + + console.error(errorMessage); } - } catch (error) { - let errorMessage = `An error occurred while running 'mapSelect': ${error.message}`; - - if (latestMapOutputError.current) { - errorMessage += `\nThe error may be correlated with this previous error:\n`; - errorMessage += `${latestMapOutputError.current.stack}\n\n`; - errorMessage += 'Original stack trace:'; - } // eslint-disable-next-line no-console - - - console.error(errorMessage); - mapOutput = latestMapOutput.current; } } - Object(external_wp_compose_["useIsomorphicLayoutEffect"])(() => { - if (isWithoutMapping) { + (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => { + if (!hasMappingFunction) { return; } - latestMapSelect.current = mapSelect; + latestMapSelect.current = _mapSelect; latestMapOutput.current = mapOutput; latestMapOutputError.current = undefined; isMountedAndNotUnsubscribing.current = true; // This has to run after the other ref updates @@ -3420,15 +4053,15 @@ renderQueue.flush(queueContext); } }); - Object(external_wp_compose_["useIsomorphicLayoutEffect"])(() => { - if (isWithoutMapping) { + (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => { + if (!hasMappingFunction) { return; } const onStoreChange = () => { if (isMountedAndNotUnsubscribing.current) { try { - const newMapOutput = trapSelect(() => latestMapSelect.current(registry.select, registry)); + const newMapOutput = wrapSelect(latestMapSelect.current); if (external_wp_isShallowEqual_default()(latestMapOutput.current, newMapOutput)) { return; @@ -3441,15 +4074,7 @@ forceRender(); } - }; // catch any possible state changes during mount before the subscription - // could be set. - - - if (latestIsAsync.current) { - renderQueue.add(queueContext, onStoreChange); - } else { - onStoreChange(); - } + }; const onChange = () => { if (latestIsAsync.current) { @@ -3457,20 +4082,25 @@ } else { onStoreChange(); } - }; - - const unsubscribers = listeningStores.current.map(storeName => registry.__experimentalSubscribeStore(storeName, onChange)); + }; // Catch any possible state changes during mount before the subscription + // could be set. + + + onChange(); + const unsubscribers = listeningStores.current.map(storeName => registry.__unstableSubscribeStore(storeName, onChange)); return () => { isMountedAndNotUnsubscribing.current = false; // The return value of the subscribe function could be undefined if the store is a custom generic store. unsubscribers.forEach(unsubscribe => unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe()); renderQueue.flush(queueContext); - }; - }, [registry, trapSelect, depsChangedFlag, isWithoutMapping]); - return isWithoutMapping ? registry.select(_mapSelect) : mapOutput; + }; // If you're tempted to eliminate the spread dependencies below don't do it! + // We're passing these in from the calling function and want to make sure we're + // examining every individual value inside the `deps` array. + }, [registry, wrapSelect, hasMappingFunction, depsChangedFlag]); + return hasMappingFunction ? mapOutput : registry.select(mapSelect); } -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js @@ -3488,8 +4118,8 @@ * selectors. * * @param {Function} mapSelectToProps Function called on every state change, - * expected to return object of props to - * merge with the component's own props. + * expected to return object of props to + * merge with the component's own props. * * @example * ```js @@ -3523,16 +4153,16 @@ * @return {WPComponent} Enhanced component with merged state data props. */ -const withSelect = mapSelectToProps => Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => Object(external_wp_compose_["pure"])(ownProps => { +const withSelect = mapSelectToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_compose_namespaceObject.pure)(ownProps => { const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry); const mergeProps = useSelect(mapSelect); - return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, ownProps, mergeProps)); + return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, ownProps, mergeProps)); }), 'withSelect'); /* harmony default export */ var with_select = (withSelect); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js /** * External dependencies */ @@ -3554,37 +4184,39 @@ * * Currently this is an internal api only and is implemented by `withDispatch` * - * @param {Function} dispatchMap Receives the `registry.dispatch` function as - * the first argument and the `registry` object - * as the second argument. Should return an - * object mapping props to functions. - * @param {Array} deps An array of dependencies for the hook. + * @param {Function} dispatchMap Receives the `registry.dispatch` function as + * the first argument and the `registry` object + * as the second argument. Should return an + * object mapping props to functions. + * @param {Array} deps An array of dependencies for the hook. * @return {Object} An object mapping props to functions created by the passed * in dispatchMap. */ const useDispatchWithMap = (dispatchMap, deps) => { const registry = useRegistry(); - const currentDispatchMap = Object(external_wp_element_["useRef"])(dispatchMap); - Object(external_wp_compose_["useIsomorphicLayoutEffect"])(() => { + const currentDispatchMap = (0,external_wp_element_namespaceObject.useRef)(dispatchMap); + (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => { currentDispatchMap.current = dispatchMap; }); - return Object(external_wp_element_["useMemo"])(() => { + return (0,external_wp_element_namespaceObject.useMemo)(() => { const currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry); - return Object(external_lodash_["mapValues"])(currentDispatchProps, (dispatcher, propName) => { + return (0,external_lodash_namespaceObject.mapValues)(currentDispatchProps, (dispatcher, propName) => { if (typeof dispatcher !== 'function') { // eslint-disable-next-line no-console console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`); } - return (...args) => currentDispatchMap.current(registry.dispatch, registry)[propName](...args); + return function () { + return currentDispatchMap.current(registry.dispatch, registry)[propName](...arguments); + }; }); }, [registry, ...deps]); }; /* harmony default export */ var use_dispatch_with_map = (useDispatchWithMap); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js @@ -3677,16 +4309,16 @@ * @return {WPComponent} Enhanced component with merged dispatcher props. */ -const withDispatch = mapDispatchToProps => Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => ownProps => { +const withDispatch = mapDispatchToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ownProps => { const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry); const dispatchProps = use_dispatch_with_map(mapDispatch, []); - return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, ownProps, dispatchProps)); + return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, ownProps, dispatchProps)); }, 'withDispatch'); /* harmony default export */ var with_dispatch = (withDispatch); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js @@ -3708,17 +4340,17 @@ * @return {WPComponent} Enhanced component. */ -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, { +const withRegistry = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => props => (0,external_wp_element_namespaceObject.createElement)(RegistryConsumer, null, registry => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, props, { registry: registry }))), 'withRegistry'); /* harmony default export */ var with_registry = (withRegistry); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js /** * Internal dependencies */ -/** @typedef {import('./types').WPDataStore} WPDataStore */ +/** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */ /** * A custom react hook returning the current registry dispatch actions creators. @@ -3726,11 +4358,11 @@ * Note: The component using this hook must be within the context of a * RegistryProvider. * - * @param {string|WPDataStore} [storeNameOrDefinition] Optionally provide the name of the - * store or its definition from which to - * retrieve action creators. If not - * provided, the registry.dispatch - * function is returned instead. + * @param {string|StoreDescriptor} [storeNameOrDescriptor] Optionally provide the name of the + * store or its descriptor from which to + * retrieve action creators. If not + * provided, the registry.dispatch + * function is returned instead. * * @example * This illustrates a pattern where you may need to retrieve dynamic data from @@ -3765,16 +4397,16 @@ * @return {Function} A custom react hook. */ -const useDispatch = storeNameOrDefinition => { +const useDispatch = storeNameOrDescriptor => { const { dispatch } = useRegistry(); - return storeNameOrDefinition === void 0 ? dispatch : dispatch(storeNameOrDefinition); + return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor); }; /* harmony default export */ var use_dispatch = (useDispatch); -// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js /** * External dependencies */ @@ -3785,7 +4417,7 @@ -/** @typedef {import('./types').WPDataStore} WPDataStore */ +/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */ @@ -3842,18 +4474,18 @@ * register( store ); * ``` * - * @return {Function} A reducer that invokes every reducer inside the reducers - * object, and constructs a state object with the same shape. + * @return {Function} A reducer that invokes every reducer inside the reducers + * object, and constructs a state object with the same shape. */ /** - * Given the name or definition of a registered store, returns an object of the store's selectors. + * Given the name or descriptor of a registered store, returns an object of the store's selectors. * The selector functions are been pre-bound to pass the current state automatically. * As a consumer, you need only pass arguments of the selector, if applicable. * - * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store - * or the store definition. + * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store + * or the store descriptor. * * @example * ```js @@ -3872,8 +4504,8 @@ * and modified so that they return promises that resolve to their eventual values, * after any resolvers have ran. * - * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store - * or the store definition. + * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store + * or the store descriptor. * * @example * ```js @@ -3893,8 +4525,8 @@ * Note: Action creators returned by the dispatch will return a promise when * they are called. * - * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store - * or the store definition. + * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store + * or the store descriptor. * * @example * ```js @@ -3927,17 +4559,17 @@ * ``` */ -const build_module_subscribe = default_registry.subscribe; +const subscribe = default_registry.subscribe; /** - * Registers a generic store. - * - * @deprecated Use `register` instead. - * - * @param {string} key Store registry key. - * @param {Object} config Configuration (getSelectors, getActions, subscribe). + * Registers a generic store instance. + * + * @deprecated Use `register( storeDescriptor )` instead. + * + * @param {string} name Store registry name. + * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`). */ -const build_module_registerGenericStore = default_registry.registerGenericStore; +const registerGenericStore = default_registry.registerGenericStore; /** * Registers a standard `@wordpress/data` store. * @@ -3958,9 +4590,9 @@ * @param {Object} plugin Plugin object. */ -const build_module_use = default_registry.use; +const use = default_registry.use; /** - * Registers a standard `@wordpress/data` store definition. + * Registers a standard `@wordpress/data` store descriptor. * * @example * ```js @@ -3975,44 +4607,12 @@ * register( store ); * ``` * - * @param {WPDataStore} store Store definition. + * @param {StoreDescriptor} store Store descriptor. */ -const build_module_register = default_registry.register; - - -/***/ }), - -/***/ "rl8x": -/***/ (function(module, exports) { - -(function() { module.exports = window["wp"]["isShallowEqual"]; }()); - -/***/ }), - -/***/ "wx14": -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); -function _extends() { - _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; - }; - - return _extends.apply(this, arguments); -} - -/***/ }) - -/******/ }); \ No newline at end of file +const register = default_registry.register; + +}(); +(window.wp = window.wp || {}).data = __webpack_exports__; +/******/ })() +; \ No newline at end of file