2022-04-11 08:04:30 -04:00
/******/ ( function ( ) { // webpackBootstrap
/******/ var _ _webpack _modules _ _ = ( {
2020-03-23 19:40:19 -04:00
2022-04-11 08:04:30 -04:00
/***/ 2167 :
/***/ ( function ( module ) {
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
"use strict" ;
2018-12-14 06:02:53 -05:00
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function _typeof ( obj ) {
if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) {
_typeof = function ( obj ) {
return typeof obj ;
} ;
} else {
_typeof = function ( obj ) {
return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ;
} ;
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
return _typeof ( obj ) ;
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function _classCallCheck ( instance , Constructor ) {
if ( ! ( instance instanceof Constructor ) ) {
throw new TypeError ( "Cannot call a class as a function" ) ;
}
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function _defineProperties ( target , props ) {
for ( var i = 0 ; i < props . length ; i ++ ) {
var descriptor = props [ i ] ;
descriptor . enumerable = descriptor . enumerable || false ;
descriptor . configurable = true ;
if ( "value" in descriptor ) descriptor . writable = true ;
Object . defineProperty ( target , descriptor . key , descriptor ) ;
}
}
2019-03-07 04:09:59 -05:00
2021-05-20 08:20:04 -04:00
function _createClass ( Constructor , protoProps , staticProps ) {
if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ;
if ( staticProps ) _defineProperties ( Constructor , staticProps ) ;
return Constructor ;
}
2019-03-07 04:09:59 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Given an instance of EquivalentKeyMap , returns its internal value pair tuple
* for a key , if one exists . The tuple members consist of the last reference
* value for the key ( used in efficient subsequent lookups ) and the value
* assigned for the key at the leaf node .
*
* @ param { EquivalentKeyMap } instance EquivalentKeyMap instance .
* @ param { * } key The key for which to return value pair .
*
* @ return { ? Array } Value pair , if exists .
* /
function getValuePair ( instance , key ) {
var _map = instance . _map ,
_arrayTreeMap = instance . _arrayTreeMap ,
_objectTreeMap = instance . _objectTreeMap ; // Map keeps a reference to the last object-like key used to set the
// value, which can be used to shortcut immediately to the value.
2019-10-15 11:37:08 -04:00
2021-05-20 08:20:04 -04:00
if ( _map . has ( key ) ) {
return _map . get ( key ) ;
} // Sort keys to ensure stable retrieval from tree.
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
var properties = Object . keys ( key ) . sort ( ) ; // Tree by type to avoid conflicts on numeric object keys, empty value.
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
var map = Array . isArray ( key ) ? _arrayTreeMap : _objectTreeMap ;
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
for ( var i = 0 ; i < properties . length ; i ++ ) {
var property = properties [ i ] ;
map = map . get ( property ) ;
2019-10-15 11:37:08 -04:00
2021-05-20 08:20:04 -04:00
if ( map === undefined ) {
return ;
}
2019-10-15 11:37:08 -04:00
2021-05-20 08:20:04 -04:00
var propertyValue = key [ property ] ;
map = map . get ( propertyValue ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
if ( map === undefined ) {
return ;
}
}
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
var valuePair = map . get ( '_ekm_value' ) ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
if ( ! valuePair ) {
return ;
} // If reached, it implies that an object-like key was set with another
// reference, so delete the reference and replace with the current.
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
_map . delete ( valuePair [ 0 ] ) ;
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
valuePair [ 0 ] = key ;
map . set ( '_ekm_value' , valuePair ) ;
_map . set ( key , valuePair ) ;
return valuePair ;
2021-02-02 00:17:13 -05:00
}
2021-05-20 08:20:04 -04:00
/ * *
* Variant of a Map object which enables lookup by equivalent ( deeply equal )
* object and array keys .
* /
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
var EquivalentKeyMap =
/*#__PURE__*/
function ( ) {
/ * *
* Constructs a new instance of EquivalentKeyMap .
*
* @ param { Iterable . < * > } iterable Initial pair of key , value for map .
* /
function EquivalentKeyMap ( iterable ) {
_classCallCheck ( this , EquivalentKeyMap ) ;
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
this . clear ( ) ;
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
if ( iterable instanceof EquivalentKeyMap ) {
// Map#forEach is only means of iterating with support for IE11.
var iterablePairs = [ ] ;
iterable . forEach ( function ( value , key ) {
iterablePairs . push ( [ key , value ] ) ;
2021-05-19 11:09:27 -04:00
} ) ;
2021-05-20 08:20:04 -04:00
iterable = iterablePairs ;
2021-05-19 11:09:27 -04:00
}
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
if ( iterable != null ) {
for ( var i = 0 ; i < iterable . length ; i ++ ) {
this . set ( iterable [ i ] [ 0 ] , iterable [ i ] [ 1 ] ) ;
}
2021-02-02 00:17:13 -05:00
}
}
2021-05-20 08:20:04 -04:00
/ * *
* Accessor property returning the number of elements .
*
* @ return { number } Number of elements .
* /
2021-02-02 00:17:13 -05:00
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
_createClass ( EquivalentKeyMap , [ {
key : "set" ,
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Add or update an element with a specified key and value .
*
* @ param { * } key The key of the element to add .
* @ param { * } value The value of the element to add .
*
* @ return { EquivalentKeyMap } Map instance .
* /
value : function set ( key , value ) {
// Shortcut non-object-like to set on internal Map.
if ( key === null || _typeof ( key ) !== 'object' ) {
this . _map . set ( key , value ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
return this ;
} // Sort keys to ensure stable assignment into tree.
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
var properties = Object . keys ( key ) . sort ( ) ;
var valuePair = [ key , value ] ; // Tree by type to avoid conflicts on numeric object keys, empty value.
2018-12-14 06:02:53 -05:00
2021-05-20 08:20:04 -04:00
var map = Array . isArray ( key ) ? this . _arrayTreeMap : this . _objectTreeMap ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
for ( var i = 0 ; i < properties . length ; i ++ ) {
var property = properties [ i ] ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
if ( ! map . has ( property ) ) {
map . set ( property , new EquivalentKeyMap ( ) ) ;
}
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
map = map . get ( property ) ;
var propertyValue = key [ property ] ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
if ( ! map . has ( propertyValue ) ) {
map . set ( propertyValue , new EquivalentKeyMap ( ) ) ;
}
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
map = map . get ( propertyValue ) ;
} // If an _ekm_value exists, there was already an equivalent key. Before
// overriding, ensure that the old key reference is removed from map to
// avoid memory leak of accumulating equivalent keys. This is, in a
// sense, a poor man's WeakMap, while still enabling iterability.
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
var previousValuePair = map . get ( '_ekm_value' ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( previousValuePair ) {
this . _map . delete ( previousValuePair [ 0 ] ) ;
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
map . set ( '_ekm_value' , valuePair ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
this . _map . set ( key , valuePair ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
return this ;
}
/ * *
* Returns a specified element .
*
* @ param { * } key The key of the element to return .
*
* @ return { ? * } The element associated with the specified key or undefined
* if the key can ' t be found .
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
} , {
key : "get" ,
value : function get ( key ) {
// Shortcut non-object-like to get from internal Map.
if ( key === null || _typeof ( key ) !== 'object' ) {
return this . _map . get ( key ) ;
}
2020-06-29 07:50:29 -04:00
2021-05-20 08:20:04 -04:00
var valuePair = getValuePair ( this , key ) ;
2020-06-29 07:50:29 -04:00
2021-05-20 08:20:04 -04:00
if ( valuePair ) {
return valuePair [ 1 ] ;
}
2021-05-19 11:09:27 -04:00
}
2021-05-20 08:20:04 -04:00
/ * *
* Returns a boolean indicating whether an element with the specified key
* exists or not .
*
* @ param { * } key The key of the element to test for presence .
*
* @ return { boolean } Whether an element with the specified key exists .
* /
} , {
key : "has" ,
value : function has ( key ) {
if ( key === null || _typeof ( key ) !== 'object' ) {
return this . _map . has ( key ) ;
} // Test on the _presence_ of the pair, not its value, as even undefined
// can be a valid member value for a key.
2020-06-29 07:50:29 -04:00
2021-05-20 08:20:04 -04:00
return getValuePair ( this , key ) !== undefined ;
2021-05-19 11:09:27 -04:00
}
2021-05-20 08:20:04 -04:00
/ * *
* Removes the specified element .
*
* @ param { * } key The key of the element to remove .
*
* @ return { boolean } Returns true if an element existed and has been
* removed , or false if the element does not exist .
* /
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
} , {
key : "delete" ,
value : function _delete ( key ) {
if ( ! this . has ( key ) ) {
return false ;
} // This naive implementation will leave orphaned child trees. A better
// implementation should traverse and remove orphans.
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
this . set ( key , undefined ) ;
return true ;
2021-05-19 11:09:27 -04:00
}
2021-05-20 08:20:04 -04:00
/ * *
* Executes a provided function once per each key / value pair , in insertion
* order .
*
* @ param { Function } callback Function to execute for each element .
* @ param { * } thisArg Value to use as ` this ` when executing
* ` callback ` .
* /
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
} , {
key : "forEach" ,
value : function forEach ( callback ) {
var _this = this ;
2019-03-21 08:48:00 -04:00
2021-05-20 08:20:04 -04:00
var thisArg = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : this ;
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
this . _map . forEach ( function ( value , key ) {
// Unwrap value from object-like value pair.
if ( key !== null && _typeof ( key ) === 'object' ) {
value = value [ 1 ] ;
}
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
callback . call ( thisArg , value , key , _this ) ;
} ) ;
2021-05-19 11:09:27 -04:00
}
2021-05-20 08:20:04 -04:00
/ * *
* Removes all elements .
* /
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
} , {
key : "clear" ,
value : function clear ( ) {
this . _map = new Map ( ) ;
this . _arrayTreeMap = new Map ( ) ;
this . _objectTreeMap = new Map ( ) ;
2021-05-19 11:09:27 -04:00
}
2021-05-20 08:20:04 -04:00
} , {
key : "size" ,
get : function get ( ) {
return this . _map . size ;
2021-05-19 11:09:27 -04:00
}
2021-05-20 08:20:04 -04:00
} ] ) ;
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
return EquivalentKeyMap ;
} ( ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
module . exports = EquivalentKeyMap ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2018-12-13 23:41:57 -05:00
2022-04-11 08:04:30 -04:00
/***/ 9125 :
/***/ ( function ( module ) {
2018-12-13 23:41:57 -05:00
2022-04-11 08:04:30 -04:00
function combineReducers ( reducers ) {
var keys = Object . keys ( reducers ) ,
getNextState ;
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
getNextState = ( function ( ) {
var fn , i , key ;
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
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 ] ) ;
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
fn += key + ':r[' + key + '](s[' + key + '],a),' ;
}
fn += '}' ;
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
return new Function ( 'r,s,a' , fn ) ;
} ) ( ) ;
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
return function combinedReducer ( state , action ) {
var nextState , i , key ;
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
// Assumed changed if initial state.
if ( state === undefined ) {
return getNextState ( reducers , { } , action ) ;
}
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
nextState = getNextState ( reducers , state , action ) ;
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
// 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 ;
}
}
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
return state ;
} ;
2021-05-20 08:20:04 -04:00
}
2018-12-16 23:52:00 -05:00
2022-04-11 08:04:30 -04:00
module . exports = combineReducers ;
2018-12-16 23:52:00 -05:00
2018-12-13 23:41:57 -05:00
2022-04-11 08:04:30 -04:00
/***/ } )
2021-05-07 07:48:27 -04:00
2022-04-11 08:04:30 -04:00
/******/ } ) ;
/************************************************************************/
/******/ // 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 ( ) {
2021-05-20 08:20:04 -04:00
"use strict" ;
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
// EXPORTS
2022-04-11 08:04:30 -04:00
_ _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 ; }
} ) ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js
var selectors _namespaceObject = { } ;
_ _webpack _require _ _ . r ( selectors _namespaceObject ) ;
2022-04-11 08:04:30 -04:00
_ _webpack _require _ _ . d ( selectors _namespaceObject , {
"getCachedResolvers" : function ( ) { return getCachedResolvers ; } ,
"getIsResolving" : function ( ) { return getIsResolving ; } ,
2022-04-12 11:12:47 -04:00
"getResolutionError" : function ( ) { return getResolutionError ; } ,
"getResolutionState" : function ( ) { return getResolutionState ; } ,
2022-04-11 08:04:30 -04:00
"hasFinishedResolution" : function ( ) { return hasFinishedResolution ; } ,
2022-04-12 11:12:47 -04:00
"hasResolutionFailed" : function ( ) { return hasResolutionFailed ; } ,
2022-04-11 08:04:30 -04:00
"hasStartedResolution" : function ( ) { return hasStartedResolution ; } ,
"isResolving" : function ( ) { return isResolving ; }
} ) ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js
var actions _namespaceObject = { } ;
_ _webpack _require _ _ . r ( actions _namespaceObject ) ;
2022-04-11 08:04:30 -04:00
_ _webpack _require _ _ . d ( actions _namespaceObject , {
2022-04-12 11:12:47 -04:00
"failResolution" : function ( ) { return failResolution ; } ,
"failResolutions" : function ( ) { return failResolutions ; } ,
2022-04-11 08:04:30 -04:00
"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 ; }
} ) ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js
var plugins _namespaceObject = { } ;
_ _webpack _require _ _ . r ( plugins _namespaceObject ) ;
2022-04-11 08:04:30 -04:00
_ _webpack _require _ _ . d ( plugins _namespaceObject , {
"persistence" : function ( ) { return persistence ; }
} ) ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: ./node_modules/turbo-combine-reducers/index.js
2022-04-11 08:04:30 -04:00
var turbo _combine _reducers = _ _webpack _require _ _ ( 9125 ) ;
2021-05-20 08:20:04 -04:00
var turbo _combine _reducers _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( turbo _combine _reducers ) ;
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: external "lodash"
var external _lodash _namespaceObject = window [ "lodash" ] ;
2022-04-12 11:12:47 -04:00
; // 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 ) ;
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
2021-05-20 08:20:04 -04:00
function _defineProperty ( obj , key , value ) {
if ( key in obj ) {
Object . defineProperty ( obj , key , {
value : value ,
enumerable : true ,
configurable : true ,
writable : true
} ) ;
} else {
obj [ key ] = value ;
2021-05-07 07:48:27 -04:00
}
2021-05-20 08:20:04 -04:00
return obj ;
2021-05-07 07:48:27 -04:00
}
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
function ownKeys ( object , enumerableOnly ) {
var keys = Object . keys ( object ) ;
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
if ( Object . getOwnPropertySymbols ) {
var symbols = Object . getOwnPropertySymbols ( object ) ;
2021-12-21 02:02:34 -05:00
enumerableOnly && ( symbols = symbols . filter ( function ( sym ) {
return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ;
} ) ) , keys . push . apply ( keys , symbols ) ;
2021-05-19 11:09:27 -04:00
}
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
return keys ;
2021-05-07 07:48:27 -04:00
}
2021-05-20 08:20:04 -04:00
function _objectSpread2 ( target ) {
for ( var i = 1 ; i < arguments . length ; i ++ ) {
2021-12-21 02:02:34 -05:00
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 ) ) ;
} ) ;
2019-09-19 11:19:18 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
return target ;
}
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/redux/es/redux.js
2018-12-13 23:41:57 -05:00
2019-03-21 08:48:00 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Adapted from React : https : //github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
*
* Do not require this module directly ! Use normal throw error calls . These messages will be replaced with error codes
* during build .
* @ param { number } code
* /
function formatProdErrorMessage ( code ) {
return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ' ;
2019-03-21 08:48:00 -04:00
}
2021-05-20 08:20:04 -04:00
// Inlined version of the `symbol-observable` polyfill
var $$observable = ( function ( ) {
return typeof Symbol === 'function' && Symbol . observable || '@@observable' ;
} ) ( ) ;
/ * *
* These are private action types reserved by Redux .
* For any unknown actions , you must return the current state .
* If the current state is undefined , you must return the initial state .
* Do not reference these action types directly in your code .
2021-02-02 00:17:13 -05:00
* /
2021-05-20 08:20:04 -04:00
var randomString = function randomString ( ) {
return Math . random ( ) . toString ( 36 ) . substring ( 7 ) . split ( '' ) . join ( '.' ) ;
} ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
var ActionTypes = {
INIT : "@@redux/INIT" + randomString ( ) ,
REPLACE : "@@redux/REPLACE" + randomString ( ) ,
PROBE _UNKNOWN _ACTION : function PROBE _UNKNOWN _ACTION ( ) {
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString ( ) ;
}
} ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* @ param { any } obj The object to inspect .
* @ returns { boolean } True if the argument appears to be a plain object .
* /
function isPlainObject ( obj ) {
if ( typeof obj !== 'object' || obj === null ) return false ;
var proto = obj ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
while ( Object . getPrototypeOf ( proto ) !== null ) {
proto = Object . getPrototypeOf ( proto ) ;
}
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
return Object . getPrototypeOf ( obj ) === proto ;
}
2019-03-21 08:48:00 -04:00
Editor: Update block editor packages for WordPress 5.8.1.
The following packages were updated:
- @wordpress/a11y to `3.1.2`
- @wordpress/annotations to `2.1.6`
- @wordpress/api-fetch to `5.1.2`
- @wordpress/autop to `3.1.2`
- @wordpress/babel-preset-default to `6.2.1`
- @wordpress/blob to `3.1.2`
- @wordpress/block-directory to `2.1.21`
- @wordpress/block-editor to `6.1.14`
- @wordpress/block-library to `3.2.19`
- @wordpress/block-serialization-default-parser to `4.1.2`
- @wordpress/blocks to `9.1.8`
- @wordpress/components to `14.1.11`
- @wordpress/compose to `4.1.6`
- @wordpress/core-data to `3.1.12`
- @wordpress/customize-widgets to `1.0.20`
- @wordpress/data-controls to `2.1.6`
- @wordpress/data to `5.1.6`
- @wordpress/date to `4.1.2`
- @wordpress/deprecated to `3.1.2`
- @wordpress/dom-ready to `3.1.2`
- @wordpress/dom to `3.1.5`
- @wordpress/e2e-test-utils to `5.3.1`
- @wordpress/edit-post to `4.1.21`
- @wordpress/edit-widgets to `2.1.21`
- @wordpress/editor to `10.1.17`
- @wordpress/element to `3.1.2`
- @wordpress/escape-html to `2.1.2`
- @wordpress/format-library to `2.1.14`
- @wordpress/html-entities to `3.1.2`
- @wordpress/i18n to `4.1.2`
- @wordpress/icons to `4.0.3`
- @wordpress/interface to `3.1.12`
- @wordpress/keyboard-shortcuts to `2.1.7`
- @wordpress/keycodes to `3.1.2`
- @wordpress/list-reusable-blocks to `2.1.11`
- @wordpress/media-utils to `2.1.2`
- @wordpress/notices to `3.1.6`
- @wordpress/nux to `4.1.11`
- @wordpress/plugins to `3.1.6`
- @wordpress/primitives to `2.1.2`
- @wordpress/priority-queue to `2.1.2`
- @wordpress/react-i18n to `2.1.2`
- @wordpress/redux-routine to `4.1.2`
- @wordpress/reusable-blocks to `2.1.17`
- @wordpress/rich-text to `4.1.6`
- @wordpress/scripts to `16.1.5`
- @wordpress/server-side-render to `2.1.12`
- @wordpress/shortcode to `3.1.2`
- @wordpress/url to `3.1.2`
- @wordpress/viewport to `3.1.6`
- @wordpress/warning to `2.1.2`
- @wordpress/widgets to `1.1.19`
- @wordpress/wordcount to `3.1.2`
Props oandregal, juanmaguitar, gziolo, jblz, talldanwp, ribaricplusplus, peterwisoncc, youknowriad, paaljoachim, kreppar, ellatrix, aristath, walbo, ajlende, kevin940726, mamaduka, ntsekouras, toro_unit, mkaz, joen, noisysocks, zieladam, andraganescu, antonvlasenko, terraling, dariak, vladytimy, circlecube, desrosj.
Fixes #54052, #52818.
Built from https://develop.svn.wordpress.org/trunk@51719
git-svn-id: http://core.svn.wordpress.org/trunk@51325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-01 15:08:24 -04:00
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
function miniKindOf ( val ) {
if ( val === void 0 ) return 'undefined' ;
if ( val === null ) return 'null' ;
var type = typeof val ;
switch ( type ) {
case 'boolean' :
case 'string' :
case 'number' :
case 'symbol' :
case 'function' :
{
return type ;
}
}
if ( Array . isArray ( val ) ) return 'array' ;
if ( isDate ( val ) ) return 'date' ;
if ( isError ( val ) ) return 'error' ;
var constructorName = ctorName ( val ) ;
switch ( constructorName ) {
case 'Symbol' :
case 'Promise' :
case 'WeakMap' :
case 'WeakSet' :
case 'Map' :
case 'Set' :
return constructorName ;
} // other
return type . slice ( 8 , - 1 ) . toLowerCase ( ) . replace ( /\s/g , '' ) ;
}
function ctorName ( val ) {
return typeof val . constructor === 'function' ? val . constructor . name : null ;
}
function isError ( val ) {
return val instanceof Error || typeof val . message === 'string' && val . constructor && typeof val . constructor . stackTraceLimit === 'number' ;
}
function isDate ( val ) {
if ( val instanceof Date ) return true ;
return typeof val . toDateString === 'function' && typeof val . getDate === 'function' && typeof val . setDate === 'function' ;
}
2021-05-20 08:20:04 -04:00
function kindOf ( val ) {
var typeOfVal = typeof val ;
2019-03-21 08:48:00 -04:00
2021-05-20 08:20:04 -04:00
if ( false ) { }
return typeOfVal ;
}
2019-03-21 08:48:00 -04:00
2018-12-13 23:41:57 -05:00
/ * *
2022-04-19 11:11:17 -04:00
* @ deprecated
2021-02-02 00:17:13 -05:00
*
2022-04-19 11:11:17 -04:00
* * * We recommend using the ` configureStore ` method
* of the ` @reduxjs/toolkit ` package * * , which replaces ` createStore ` .
2021-02-02 00:17:13 -05:00
*
2022-04-19 11:11:17 -04:00
* Redux Toolkit is our recommended approach for writing Redux logic today ,
* including store setup , reducers , data fetching , and more .
2021-02-02 00:17:13 -05:00
*
2022-04-19 11:11:17 -04:00
* * * For more details , please read this Redux docs page : * *
* * * https : //redux.js.org/introduction/why-rtk-is-redux-today**
2021-02-02 00:17:13 -05:00
*
2022-04-19 11:11:17 -04:00
* ` 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' `
2021-02-02 00:17:13 -05:00
*
2018-12-13 23:41:57 -05:00
* /
2021-05-20 08:20:04 -04:00
2022-04-11 08:04:30 -04:00
function createStore ( reducer , preloadedState , enhancer ) {
2021-05-20 08:20:04 -04:00
var _ref2 ;
if ( typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments [ 3 ] === 'function' ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 0 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
if ( typeof preloadedState === 'function' && typeof enhancer === 'undefined' ) {
enhancer = preloadedState ;
preloadedState = undefined ;
}
if ( typeof enhancer !== 'undefined' ) {
if ( typeof enhancer !== 'function' ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 1 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
2022-04-11 08:04:30 -04:00
return enhancer ( createStore ) ( reducer , preloadedState ) ;
2021-05-20 08:20:04 -04:00
}
if ( typeof reducer !== 'function' ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 2 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
var currentReducer = reducer ;
var currentState = preloadedState ;
var currentListeners = [ ] ;
var nextListeners = currentListeners ;
var isDispatching = false ;
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* This makes a shallow copy of currentListeners so we can use
* nextListeners as a temporary list while dispatching .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* This prevents any bugs around consumers calling
* subscribe / unsubscribe in the middle of a dispatch .
2021-02-02 00:17:13 -05:00
* /
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function ensureCanMutateNextListeners ( ) {
if ( nextListeners === currentListeners ) {
nextListeners = currentListeners . slice ( ) ;
}
}
/ * *
* Reads the state tree managed by the store .
*
* @ returns { any } The current state tree of your application .
* /
2019-09-19 11:19:18 -04:00
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function getState ( ) {
if ( isDispatching ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 3 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
return currentState ;
}
/ * *
* Adds a change listener . It will be called any time an action is dispatched ,
* and some part of the state tree may potentially have changed . You may then
* call ` getState() ` to read the current state tree inside the callback .
*
* You may call ` dispatch() ` from a change listener , with the following
* caveats :
*
* 1. The subscriptions are snapshotted just before every ` dispatch() ` call .
* If you subscribe or unsubscribe while the listeners are being invoked , this
* will not have any effect on the ` dispatch() ` that is currently in progress .
* However , the next ` dispatch() ` call , whether nested or not , will use a more
* recent snapshot of the subscription list .
*
* 2. The listener should not expect to see all state changes , as the state
* might have been updated multiple times during a nested ` dispatch() ` before
* the listener is called . It is , however , guaranteed that all subscribers
* registered before the ` dispatch() ` started will be called with the latest
* state by the time it exits .
*
* @ param { Function } listener A callback to be invoked on every dispatch .
* @ returns { Function } A function to remove this change listener .
* /
2020-10-20 09:36:16 -04:00
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
function subscribe ( listener ) {
if ( typeof listener !== 'function' ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 4 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( isDispatching ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 5 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
var isSubscribed = true ;
ensureCanMutateNextListeners ( ) ;
nextListeners . push ( listener ) ;
return function unsubscribe ( ) {
if ( ! isSubscribed ) {
return ;
}
2018-12-16 23:52:00 -05:00
2021-05-20 08:20:04 -04:00
if ( isDispatching ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 6 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
2018-12-16 23:52:00 -05:00
2021-05-20 08:20:04 -04:00
isSubscribed = false ;
ensureCanMutateNextListeners ( ) ;
var index = nextListeners . indexOf ( listener ) ;
nextListeners . splice ( index , 1 ) ;
currentListeners = null ;
} ;
}
/ * *
* Dispatches an action . It is the only way to trigger a state change .
*
* The ` reducer ` function , used to create the store , will be called with the
* current state tree and the given ` action ` . Its return value will
* be considered the * * next * * state of the tree , and the change listeners
* will be notified .
*
* The base implementation only supports plain object actions . If you want to
* dispatch a Promise , an Observable , a thunk , or something else , you need to
* wrap your store creating function into the corresponding middleware . For
* example , see the documentation for the ` redux-thunk ` package . Even the
* middleware will eventually dispatch plain object actions using this method .
*
* @ param { Object } action A plain object representing “ what changed ” . It is
* a good idea to keep actions serializable so you can record and replay user
* sessions , or use the time travelling ` redux-devtools ` . An action must have
* a ` type ` property which may not be ` undefined ` . It is a good idea to use
* string constants for action types .
*
* @ returns { Object } For convenience , the same action object you dispatched .
*
* Note that , if you use a custom middleware , it may wrap ` dispatch() ` to
* return something else ( for example , a Promise you can await ) .
* /
2019-09-19 11:19:18 -04:00
2018-12-16 23:52:00 -05:00
2021-05-20 08:20:04 -04:00
function dispatch ( action ) {
if ( ! isPlainObject ( action ) ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 7 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
2018-12-16 23:52:00 -05:00
2021-05-20 08:20:04 -04:00
if ( typeof action . type === 'undefined' ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 8 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
if ( isDispatching ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 9 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
try {
isDispatching = true ;
currentState = currentReducer ( currentState , action ) ;
} finally {
isDispatching = false ;
}
var listeners = currentListeners = nextListeners ;
for ( var i = 0 ; i < listeners . length ; i ++ ) {
var listener = listeners [ i ] ;
listener ( ) ;
}
return action ;
}
/ * *
* Replaces the reducer currently used by the store to calculate the state .
*
* You might need this if your app implements code splitting and you want to
* load some of the reducers dynamically . You might also need this if you
* implement a hot reloading mechanism for Redux .
*
* @ param { Function } nextReducer The reducer for the store to use instead .
* @ returns { void }
* /
function replaceReducer ( nextReducer ) {
if ( typeof nextReducer !== 'function' ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 10 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
currentReducer = nextReducer ; // This action has a similiar effect to ActionTypes.INIT.
// Any reducers that existed in both the new and old rootReducer
// will receive the previous state. This effectively populates
// the new state tree with any relevant data from the old one.
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
dispatch ( {
type : ActionTypes . REPLACE
2021-05-19 11:09:27 -04:00
} ) ;
}
2021-05-20 08:20:04 -04:00
/ * *
* Interoperability point for observable / reactive libraries .
* @ returns { observable } A minimal observable of state changes .
* For more information , see the observable proposal :
* https : //github.com/tc39/proposal-observable
* /
2019-09-19 11:19:18 -04:00
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
function observable ( ) {
var _ref ;
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
var outerSubscribe = subscribe ;
return _ref = {
/ * *
* The minimal observable subscription method .
* @ param { Object } observer Any object that can be used as an observer .
* The observer object should have a ` next ` method .
* @ returns { subscription } An object with an ` unsubscribe ` method that can
* be used to unsubscribe the observable from the store , and prevent further
* emission of values from the observable .
* /
subscribe : function subscribe ( observer ) {
if ( typeof observer !== 'object' || observer === null ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 11 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
function observeState ( ) {
if ( observer . next ) {
observer . next ( getState ( ) ) ;
}
}
observeState ( ) ;
var unsubscribe = outerSubscribe ( observeState ) ;
return {
unsubscribe : unsubscribe
} ;
}
} , _ref [ $$observable ] = function ( ) {
return this ;
} , _ref ;
} // When a store is created, an "INIT" action is dispatched so that every
// reducer returns their initial state. This effectively populates
// the initial state tree.
dispatch ( {
type : ActionTypes . INIT
} ) ;
return _ref2 = {
dispatch : dispatch ,
subscribe : subscribe ,
getState : getState ,
replaceReducer : replaceReducer
} , _ref2 [ $$observable ] = observable , _ref2 ;
}
2022-04-19 11:11:17 -04:00
/ * *
* 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 ) ) ;
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Prints a warning in the console if it exists .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { String } message The warning message .
* @ returns { void }
2018-12-14 06:02:53 -05:00
* /
2021-05-20 08:20:04 -04:00
function warning ( message ) {
/* eslint-disable no-console */
if ( typeof console !== 'undefined' && typeof console . error === 'function' ) {
console . error ( message ) ;
}
/* eslint-enable no-console */
2018-12-14 06:02:53 -05:00
2021-05-20 08:20:04 -04:00
try {
// This error was thrown as a convenience so that if you enable
// "break on all exceptions" in your console,
// it would pause the execution at this line.
throw new Error ( message ) ;
} catch ( e ) { } // eslint-disable-line no-empty
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
}
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
function getUnexpectedStateShapeWarningMessage ( inputState , reducers , action , unexpectedKeyCache ) {
var reducerKeys = Object . keys ( reducers ) ;
var argumentName = action && action . type === ActionTypes . INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer' ;
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
if ( reducerKeys . length === 0 ) {
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.' ;
}
if ( ! isPlainObject ( inputState ) ) {
return "The " + argumentName + " has unexpected type of \"" + kindOf ( inputState ) + "\". Expected argument to be an object with the following " + ( "keys: \"" + reducerKeys . join ( '", "' ) + "\"" ) ;
}
var unexpectedKeys = Object . keys ( inputState ) . filter ( function ( key ) {
return ! reducers . hasOwnProperty ( key ) && ! unexpectedKeyCache [ key ] ;
2021-05-19 11:09:27 -04:00
} ) ;
2021-05-20 08:20:04 -04:00
unexpectedKeys . forEach ( function ( key ) {
unexpectedKeyCache [ key ] = true ;
} ) ;
if ( action && action . type === ActionTypes . REPLACE ) return ;
2018-12-14 06:02:53 -05:00
2021-05-20 08:20:04 -04:00
if ( unexpectedKeys . length > 0 ) {
return "Unexpected " + ( unexpectedKeys . length > 1 ? 'keys' : 'key' ) + " " + ( "\"" + unexpectedKeys . join ( '", "' ) + "\" found in " + argumentName + ". " ) + "Expected to find one of the known reducer keys instead: " + ( "\"" + reducerKeys . join ( '", "' ) + "\". Unexpected keys will be ignored." ) ;
}
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function assertReducerShape ( reducers ) {
Object . keys ( reducers ) . forEach ( function ( key ) {
var reducer = reducers [ key ] ;
var initialState = reducer ( undefined , {
type : ActionTypes . INIT
} ) ;
if ( typeof initialState === 'undefined' ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 12 ) : 0 ) ;
2021-05-19 11:09:27 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( typeof reducer ( undefined , {
type : ActionTypes . PROBE _UNKNOWN _ACTION ( )
} ) === 'undefined' ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 13 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
}
} ) ;
2021-02-02 00:17:13 -05:00
}
/ * *
2021-05-20 08:20:04 -04:00
* Turns an object whose values are different reducer functions , into a single
* reducer function . It will call every child reducer , and gather their results
* into a single state object , whose keys correspond to the keys of the passed
* reducer functions .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { Object } reducers An object whose values correspond to different
* reducer functions that need to be combined into one . One handy way to obtain
* it is to use ES6 ` import * as reducers ` syntax . The reducers may never return
* undefined for any action . Instead , they should return their initial state
* if the state passed to them was undefined , and the current state for any
* unrecognized action .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ returns { Function } A reducer function that invokes every reducer inside the
* passed object , and builds a state object with the same shape .
2021-02-02 00:17:13 -05:00
* /
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function combineReducers ( reducers ) {
var reducerKeys = Object . keys ( reducers ) ;
var finalReducers = { } ;
for ( var i = 0 ; i < reducerKeys . length ; i ++ ) {
var key = reducerKeys [ i ] ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( false ) { }
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( typeof reducers [ key ] === 'function' ) {
finalReducers [ key ] = reducers [ key ] ;
}
2021-05-19 11:09:27 -04:00
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
var finalReducerKeys = Object . keys ( finalReducers ) ; // This is used to make sure we don't warn about the same
// keys multiple times.
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
var unexpectedKeyCache ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( false ) { }
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
var shapeAssertionError ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
try {
assertReducerShape ( finalReducers ) ;
} catch ( e ) {
shapeAssertionError = e ;
}
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
return function combination ( state , action ) {
if ( state === void 0 ) {
state = { } ;
}
2020-10-13 09:10:30 -04:00
2021-05-20 08:20:04 -04:00
if ( shapeAssertionError ) {
throw shapeAssertionError ;
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( false ) { var warningMessage ; }
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
var hasChanged = false ;
var nextState = { } ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
for ( var _i = 0 ; _i < finalReducerKeys . length ; _i ++ ) {
var _key = finalReducerKeys [ _i ] ;
var reducer = finalReducers [ _key ] ;
var previousStateForKey = state [ _key ] ;
var nextStateForKey = reducer ( previousStateForKey , action ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( typeof nextStateForKey === 'undefined' ) {
var actionType = action && action . type ;
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 14 ) : 0 ) ;
2021-02-02 00:17:13 -05:00
}
2021-05-20 08:20:04 -04:00
nextState [ _key ] = nextStateForKey ;
hasChanged = hasChanged || nextStateForKey !== previousStateForKey ;
}
hasChanged = hasChanged || finalReducerKeys . length !== Object . keys ( state ) . length ;
return hasChanged ? nextState : state ;
} ;
}
function bindActionCreator ( actionCreator , dispatch ) {
return function ( ) {
return dispatch ( actionCreator . apply ( this , arguments ) ) ;
} ;
}
2018-12-13 23:41:57 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Turns an object whose values are action creators , into an object with the
* same keys , but with every function wrapped into a ` dispatch ` call so they
* may be invoked directly . This is just a convenience method , as you can call
* ` store.dispatch(MyActionCreators.doSomething()) ` yourself just fine .
2019-09-19 11:19:18 -04:00
*
2021-05-20 08:20:04 -04:00
* For convenience , you can also pass an action creator as the first argument ,
* and get a dispatch wrapped function in return .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { Function | Object } actionCreators An object whose values are action
* creator functions . One handy way to obtain it is to use ES6 ` import * as `
* syntax . You may also pass a single function .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { Function } dispatch The ` dispatch ` function available on your Redux
* store .
*
* @ returns { Function | Object } The object mimicking the original object , but with
* every action creator wrapped into the ` dispatch ` call . If you passed a
* function as ` actionCreators ` , the return value will also be a single
* function .
2018-12-13 23:41:57 -05:00
* /
2021-05-20 08:20:04 -04:00
function bindActionCreators ( actionCreators , dispatch ) {
if ( typeof actionCreators === 'function' ) {
return bindActionCreator ( actionCreators , dispatch ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( typeof actionCreators !== 'object' || actionCreators === null ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 16 ) : 0 ) ;
2021-02-02 00:17:13 -05:00
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
var boundActionCreators = { } ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
for ( var key in actionCreators ) {
var actionCreator = actionCreators [ key ] ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( typeof actionCreator === 'function' ) {
boundActionCreators [ key ] = bindActionCreator ( actionCreator , dispatch ) ;
}
}
return boundActionCreators ;
}
2019-09-19 11:19:18 -04:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Composes single - argument functions from right to left . The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { ... Function } funcs The functions to compose .
* @ returns { Function } A function obtained by composing the argument functions
* from right to left . For example , compose ( f , g , h ) is identical to doing
* ( ... args ) => f ( g ( h ( ... args ) ) ) .
2021-02-02 00:17:13 -05:00
* /
2021-05-20 08:20:04 -04:00
function compose ( ) {
for ( var _len = arguments . length , funcs = new Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
funcs [ _key ] = arguments [ _key ] ;
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( funcs . length === 0 ) {
return function ( arg ) {
return arg ;
} ;
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( funcs . length === 1 ) {
return funcs [ 0 ] ;
2021-02-02 00:17:13 -05:00
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
return funcs . reduce ( function ( a , b ) {
return function ( ) {
return a ( b . apply ( void 0 , arguments ) ) ;
} ;
} ) ;
2019-09-19 11:19:18 -04:00
}
2021-05-20 08:20:04 -04:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Creates a store enhancer that applies middleware to the dispatch method
* of the Redux store . This is handy for a variety of tasks , such as expressing
* asynchronous actions in a concise manner , or logging every action payload .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* See ` redux-thunk ` package as an example of the Redux middleware .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* Because middleware is potentially asynchronous , this should be the first
* store enhancer in the composition chain .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* Note that each middleware will be given the ` dispatch ` and ` getState ` functions
* as named arguments .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { ... Function } middlewares The middleware chain to be applied .
* @ returns { Function } A store enhancer applying the middleware .
2021-02-02 00:17:13 -05:00
* /
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
function applyMiddleware ( ) {
for ( var _len = arguments . length , middlewares = new Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
middlewares [ _key ] = arguments [ _key ] ;
}
return function ( createStore ) {
return function ( ) {
var store = createStore . apply ( void 0 , arguments ) ;
var _dispatch = function dispatch ( ) {
2022-04-11 08:04:30 -04:00
throw new Error ( true ? formatProdErrorMessage ( 15 ) : 0 ) ;
2021-05-20 08:20:04 -04:00
} ;
var middlewareAPI = {
getState : store . getState ,
dispatch : function dispatch ( ) {
return _dispatch . apply ( void 0 , arguments ) ;
}
} ;
var chain = middlewares . map ( function ( middleware ) {
return middleware ( middlewareAPI ) ;
} ) ;
_dispatch = compose . apply ( void 0 , chain ) ( store . dispatch ) ;
return _objectSpread2 ( _objectSpread2 ( { } , store ) , { } , {
dispatch : _dispatch
} ) ;
} ;
} ;
2021-02-02 00:17:13 -05:00
}
2021-05-20 08:20:04 -04:00
/ *
* This is a dummy function to check if the function name has been altered by minification .
* If the function has been minified and NODE _ENV !== 'production' , warn the user .
* /
function isCrushed ( ) { }
if ( false ) { }
// EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
2022-04-11 08:04:30 -04:00
var equivalent _key _map = _ _webpack _require _ _ ( 2167 ) ;
2021-05-20 08:20:04 -04:00
var equivalent _key _map _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( equivalent _key _map ) ;
2022-04-11 08:04:30 -04:00
; // 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
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Creates a selector function that takes additional curried argument with the
* registry ` select ` function . While a regular selector has signature
* ` ` ` js
* ( state , ... selectorArgs ) => ( result )
* ` ` `
* that allows to select data from the store ' s ` state ` , a registry selector
* has signature :
* ` ` ` js
* ( select ) => ( state , ... selectorArgs ) => ( result )
* ` ` `
* that supports also selecting from other registered stores .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ example
* ` ` ` js
* const getCurrentPostId = createRegistrySelector ( ( select ) => ( state ) => {
* return select ( 'core/editor' ) . getCurrentPostId ( ) ;
* } ) ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* const getPostEdits = createRegistrySelector ( ( select ) => ( state ) => {
* // calling another registry selector just like any other function
* const postType = getCurrentPostType ( state ) ;
* const postId = getCurrentPostId ( state ) ;
* return select ( 'core' ) . getEntityRecordEdits ( 'postType' , postType , postId ) ;
* } ) ;
* ` ` `
*
* Note how the ` getCurrentPostId ` selector can be called just like any other function ,
* ( it works even inside a regular non - registry selector ) and we don ' t need to pass the
* registry as argument . The registry binding happens automatically when registering the selector
* with a store .
*
* @ param { Function } registrySelector Function receiving a registry ` select `
2021-11-08 09:29:21 -05:00
* function and returning a state selector .
2021-05-20 08:20:04 -04:00
*
* @ return { Function } Registry selector that can be registered with a store .
2021-02-02 00:17:13 -05:00
* /
2021-05-20 08:20:04 -04:00
function createRegistrySelector ( registrySelector ) {
2022-04-12 11:12:47 -04:00
// Create a selector function that is bound to the registry referenced by `selector.registry`
2021-05-20 08:20:04 -04:00
// 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.
2021-11-15 07:50:17 -05:00
const selector = function ( ) {
return registrySelector ( selector . registry . select ) ( ... arguments ) ;
} ;
2021-05-20 08:20:04 -04:00
/ * *
* 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 .
* be mapped as a registry selector .
*
* @ type { boolean }
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
selector . isRegistrySelector = true ;
return selector ;
2021-02-02 00:17:13 -05:00
}
/ * *
2021-05-20 08:20:04 -04:00
* Creates a control function that takes additional curried argument with the ` registry ` object .
* While a regular control has signature
* ` ` ` js
* ( action ) => ( iteratorOrPromise )
* ` ` `
* where the control works with the ` action ` that it ' s bound to , a registry control has signature :
* ` ` ` js
* ( registry ) => ( action ) => ( iteratorOrPromise )
* ` ` `
* A registry control is typically used to select data or dispatch an action to a registered
* store .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* When registering a control created with ` createRegistryControl ` with a store , the store
* knows which calling convention to use when executing the control .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { Function } registryControl Function receiving a registry object and returning a control .
*
* @ return { Function } Registry control that can be registered with a store .
2021-02-02 00:17:13 -05:00
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function createRegistryControl ( registryControl ) {
registryControl . isRegistryControl = true ;
return registryControl ;
2021-02-02 00:17:13 -05:00
}
2019-09-19 11:19:18 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js
2021-11-08 09:29:21 -05:00
/ * *
* External dependencies
* /
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Internal dependencies
2021-02-02 00:17:13 -05:00
* /
2021-05-20 08:20:04 -04:00
2021-11-08 09:29:21 -05:00
2022-04-12 11:12:47 -04:00
/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
2021-11-08 09:29:21 -05:00
2021-05-20 08:20:04 -04:00
const SELECT = '@@data/SELECT' ;
const RESOLVE _SELECT = '@@data/RESOLVE_SELECT' ;
const DISPATCH = '@@data/DISPATCH' ;
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Dispatches a control action for triggering a synchronous registry select .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* Note : This control synchronously returns the current selector value , triggering the
* resolution , but not waiting for it .
2021-02-02 00:17:13 -05:00
*
2022-04-12 11:12:47 -04:00
* @ 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 .
2021-05-19 11:09:27 -04:00
*
2021-05-20 08:20:04 -04:00
* @ example
* ` ` ` js
* import { controls } from '@wordpress/data' ;
2021-05-19 11:09:27 -04:00
*
2021-05-20 08:20:04 -04:00
* // Action generator using `select`.
* export function * myAction ( ) {
* const isEditorSideBarOpened = yield controls . select ( 'core/edit-post' , 'isEditorSideBarOpened' ) ;
* // Do stuff with the result from the `select`.
* }
* ` ` `
*
* @ return { Object } The control descriptor .
2021-05-19 11:09:27 -04:00
* /
2022-04-12 11:12:47 -04:00
function controls _select ( storeNameOrDescriptor , selectorName ) {
2021-11-15 07:50:17 -05:00
for ( var _len = arguments . length , args = new Array ( _len > 2 ? _len - 2 : 0 ) , _key = 2 ; _key < _len ; _key ++ ) {
args [ _key - 2 ] = arguments [ _key ] ;
}
2021-05-19 11:09:27 -04:00
return {
2021-05-20 08:20:04 -04:00
type : SELECT ,
2022-04-12 11:12:47 -04:00
storeKey : ( 0 , external _lodash _namespaceObject . isObject ) ( storeNameOrDescriptor ) ? storeNameOrDescriptor . name : storeNameOrDescriptor ,
2021-05-19 11:09:27 -04:00
selectorName ,
args
} ;
}
/ * *
2021-05-20 08:20:04 -04:00
* Dispatches a control action for triggering and resolving a registry select .
2021-05-19 11:09:27 -04:00
*
2021-05-20 08:20:04 -04:00
* Note : when this control action is handled , it automatically considers
* 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 .
2021-05-19 11:09:27 -04:00
*
2022-04-12 11:12:47 -04:00
* @ 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 .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ example
* ` ` ` js
* import { controls } from '@wordpress/data' ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* // Action generator using resolveSelect
* export function * myAction ( ) {
* const isSidebarOpened = yield controls . resolveSelect ( 'core/edit-post' , 'isEditorSideBarOpened' ) ;
* // do stuff with the result from the select.
* }
* ` ` `
*
* @ return { Object } The control descriptor .
2021-02-02 00:17:13 -05:00
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
2022-04-12 11:12:47 -04:00
function resolveSelect ( storeNameOrDescriptor , selectorName ) {
2021-11-15 07:50:17 -05:00
for ( var _len2 = arguments . length , args = new Array ( _len2 > 2 ? _len2 - 2 : 0 ) , _key2 = 2 ; _key2 < _len2 ; _key2 ++ ) {
args [ _key2 - 2 ] = arguments [ _key2 ] ;
}
2021-02-02 00:17:13 -05:00
return {
2021-05-20 08:20:04 -04:00
type : RESOLVE _SELECT ,
2022-04-12 11:12:47 -04:00
storeKey : ( 0 , external _lodash _namespaceObject . isObject ) ( storeNameOrDescriptor ) ? storeNameOrDescriptor . name : storeNameOrDescriptor ,
2021-05-19 11:09:27 -04:00
selectorName ,
args
2021-02-02 00:17:13 -05:00
} ;
}
/ * *
2021-05-20 08:20:04 -04:00
* Dispatches a control action for triggering a registry dispatch .
2021-02-02 00:17:13 -05:00
*
2022-04-12 11:12:47 -04:00
* @ 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 .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ example
* ` ` ` js
* import { controls } from '@wordpress/data-controls' ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* // Action generator using dispatch
* export function * myAction ( ) {
* yield controls . dispatch ( 'core/edit-post' , 'togglePublishSidebar' ) ;
* // do some other things.
* }
* ` ` `
*
* @ return { Object } The control descriptor .
2021-02-02 00:17:13 -05:00
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
2022-04-12 11:12:47 -04:00
function dispatch ( storeNameOrDescriptor , actionName ) {
2021-11-15 07:50:17 -05:00
for ( var _len3 = arguments . length , args = new Array ( _len3 > 2 ? _len3 - 2 : 0 ) , _key3 = 2 ; _key3 < _len3 ; _key3 ++ ) {
args [ _key3 - 2 ] = arguments [ _key3 ] ;
}
2019-09-19 11:19:18 -04:00
return {
2021-05-20 08:20:04 -04:00
type : DISPATCH ,
2022-04-12 11:12:47 -04:00
storeKey : ( 0 , external _lodash _namespaceObject . isObject ) ( storeNameOrDescriptor ) ? storeNameOrDescriptor . name : storeNameOrDescriptor ,
2021-05-20 08:20:04 -04:00
actionName ,
args
2019-09-19 11:19:18 -04:00
} ;
}
2022-04-11 08:04:30 -04:00
const controls = {
2021-05-20 08:20:04 -04:00
select : controls _select ,
2022-04-11 08:04:30 -04:00
resolveSelect ,
dispatch
2021-05-20 08:20:04 -04:00
} ;
const builtinControls = {
2021-11-15 07:50:17 -05:00
[ 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 ;
2021-05-20 08:20:04 -04:00
const method = registry . select ( storeKey ) [ selectorName ] . hasResolver ? 'resolveSelect' : 'select' ;
return registry [ method ] ( storeKey ) [ selectorName ] ( ... args ) ;
} ) ,
2021-11-15 07:50:17 -05:00
[ DISPATCH ] : createRegistryControl ( registry => _ref3 => {
let {
storeKey ,
actionName ,
args
} = _ref3 ;
return registry . dispatch ( storeKey ) [ actionName ] ( ... args ) ;
} )
2021-05-20 08:20:04 -04:00
} ;
2018-12-13 23:41:57 -05:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/is-promise/index.mjs
function isPromise ( obj ) {
return ! ! obj && ( typeof obj === 'object' || typeof obj === 'function' ) && typeof obj . then === 'function' ;
}
2018-12-13 23:41:57 -05:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js
2018-12-13 23:41:57 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* External dependencies
2018-12-13 23:41:57 -05:00
* /
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Simplest possible promise redux middleware .
2021-02-02 00:17:13 -05:00
*
2021-11-08 09:29:21 -05:00
* @ type { import ( 'redux' ) . Middleware }
2021-02-02 00:17:13 -05:00
* /
2021-05-20 08:20:04 -04:00
const promiseMiddleware = ( ) => next => action => {
2022-04-11 08:04:30 -04:00
if ( isPromise ( action ) ) {
2021-05-20 08:20:04 -04:00
return action . then ( resolvedAction => {
if ( resolvedAction ) {
return next ( resolvedAction ) ;
}
} ) ;
}
return next ( action ) ;
} ;
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var promise _middleware = ( promiseMiddleware ) ;
2021-05-19 11:09:27 -04:00
2022-04-12 11:12:47 -04:00
; // 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 ) ;
2021-11-08 09:29:21 -05:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js
2021-05-20 08:20:04 -04:00
/ * *
* External dependencies
* /
2021-02-02 00:17:13 -05:00
2021-11-08 09:29:21 -05:00
/ * *
* Internal dependencies
* /
2021-05-20 08:20:04 -04:00
/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */
2021-05-19 11:09:27 -04:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Creates a middleware handling resolvers cache invalidation .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { WPDataRegistry } registry The registry reference for which to create
* the middleware .
* @ param { string } reducerKey The namespace for which to create the
* middleware .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ return { Function } Middleware function .
2021-02-02 00:17:13 -05:00
* /
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
const createResolversCacheMiddleware = ( registry , reducerKey ) => ( ) => next => action => {
2022-04-12 11:12:47 -04:00
const resolvers = registry . select ( store ) . getCachedResolvers ( reducerKey ) ;
2021-11-15 07:50:17 -05:00
Object . entries ( resolvers ) . forEach ( _ref => {
let [ selectorName , resolversByArgs ] = _ref ;
2022-04-11 08:04:30 -04:00
const resolver = ( 0 , external _lodash _namespaceObject . get ) ( registry . stores , [ reducerKey , 'resolvers' , selectorName ] ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
if ( ! resolver || ! resolver . shouldInvalidate ) {
return ;
}
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
resolversByArgs . forEach ( ( value , args ) => {
// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.
2022-04-12 11:12:47 -04:00
// 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 ) ) {
2021-05-20 08:20:04 -04:00
return ;
} // Trigger cache invalidation
2020-01-08 06:57:23 -05:00
2022-04-12 11:12:47 -04:00
registry . dispatch ( store ) . invalidateResolution ( reducerKey , selectorName , args ) ;
2021-05-20 08:20:04 -04:00
} ) ;
} ) ;
return next ( action ) ;
} ;
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var resolvers _cache _middleware = ( createResolversCacheMiddleware ) ;
2021-04-15 11:19:43 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js
2021-05-20 08:20:04 -04:00
function createThunkMiddleware ( args ) {
return ( ) => next => action => {
if ( typeof action === 'function' ) {
return action ( args ) ;
}
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
return next ( action ) ;
} ;
}
2021-02-02 00:17:13 -05:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js
2022-04-12 11:12:47 -04:00
/ * *
* External dependencies
* /
2021-05-20 08:20:04 -04:00
/ * *
* Higher - order reducer creator which creates a combined reducer object , keyed
* by a property on the action object .
*
2022-04-12 11:12:47 -04:00
* @ param actionProperty Action property by which to key object .
* @ return Higher - order reducer .
2021-05-20 08:20:04 -04:00
* /
2021-11-15 07:50:17 -05:00
const onSubKey = actionProperty => reducer => function ( ) {
2022-04-12 11:12:47 -04:00
let state = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
2021-11-15 07:50:17 -05:00
let action = arguments . length > 1 ? arguments [ 1 ] : undefined ;
2021-05-20 08:20:04 -04:00
// Retrieve subkey from action. Do not track if undefined; useful for cases
// where reducer is scoped by action shape.
const key = action [ actionProperty ] ;
2018-12-14 06:02:53 -05:00
2021-05-20 08:20:04 -04:00
if ( key === undefined ) {
return state ;
} // Avoid updating state if unchanged. Note that this also accounts for a
// reducer which returns undefined on a key which is not yet tracked.
2019-03-07 04:09:59 -05:00
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
const nextKeyState = reducer ( state [ key ] , action ) ;
2019-03-07 04:09:59 -05:00
2021-05-20 08:20:04 -04:00
if ( nextKeyState === state [ key ] ) {
return state ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
return { ... state ,
[ key ] : nextKeyState
} ;
} ;
2022-04-12 11:12:47 -04:00
/ * *
* 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 ) ;
}
2019-09-19 11:19:18 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js
2021-05-20 08:20:04 -04:00
/ * *
* External dependencies
* /
2018-12-13 23:41:57 -05:00
2021-11-08 09:29:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2018-12-13 23:41:57 -05:00
2019-03-07 04:09:59 -05:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Reducer function returning next state for selector resolution of
* subkeys , object form :
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* selectorName - > EquivalentKeyMap < Array , boolean >
2021-02-02 00:17:13 -05:00
* /
2021-11-15 07:50:17 -05:00
const subKeysIsResolved = onSubKey ( 'selectorName' ) ( function ( ) {
2022-04-11 08:04:30 -04:00
let state = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : new ( equivalent _key _map _default ( ) ) ( ) ;
2021-11-15 07:50:17 -05:00
let action = arguments . length > 1 ? arguments [ 1 ] : undefined ;
2021-05-20 08:20:04 -04:00
switch ( action . type ) {
case 'START_RESOLUTION' :
2022-04-12 11:12:47 -04:00
{
const nextState = new ( equivalent _key _map _default ( ) ) ( state ) ;
nextState . set ( selectorArgsToStateKey ( action . args ) , {
status : 'resolving'
} ) ;
return nextState ;
}
2021-05-20 08:20:04 -04:00
case 'FINISH_RESOLUTION' :
{
2022-04-11 08:04:30 -04:00
const nextState = new ( equivalent _key _map _default ( ) ) ( state ) ;
2022-04-12 11:12:47 -04:00
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
} ) ;
2021-05-20 08:20:04 -04:00
return nextState ;
}
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
case 'START_RESOLUTIONS' :
2022-04-12 11:12:47 -04:00
{
const nextState = new ( equivalent _key _map _default ( ) ) ( state ) ;
for ( const resolutionArgs of action . args ) {
nextState . set ( selectorArgsToStateKey ( resolutionArgs ) , {
status : 'resolving'
} ) ;
}
return nextState ;
}
2021-05-20 08:20:04 -04:00
case 'FINISH_RESOLUTIONS' :
{
2022-04-11 08:04:30 -04:00
const nextState = new ( equivalent _key _map _default ( ) ) ( state ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
for ( const resolutionArgs of action . args ) {
2022-04-12 11:12:47 -04:00
nextState . set ( selectorArgsToStateKey ( resolutionArgs ) , {
status : 'finished'
} ) ;
2021-05-20 08:20:04 -04:00
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
return nextState ;
}
2022-04-12 11:12:47 -04:00
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 ;
}
2021-05-20 08:20:04 -04:00
case 'INVALIDATE_RESOLUTION' :
{
2022-04-11 08:04:30 -04:00
const nextState = new ( equivalent _key _map _default ( ) ) ( state ) ;
2022-04-12 11:12:47 -04:00
nextState . delete ( selectorArgsToStateKey ( action . args ) ) ;
2021-05-20 08:20:04 -04:00
return nextState ;
}
2021-01-27 21:04:13 -05:00
}
2021-05-20 08:20:04 -04:00
return state ;
} ) ;
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Reducer function returning next state for selector resolution , object form :
*
* selectorName - > EquivalentKeyMap < Array , boolean >
*
2021-11-08 09:29:21 -05:00
* @ param state Current state .
* @ param action Dispatched action .
2021-02-02 00:17:13 -05:00
*
2021-11-08 09:29:21 -05:00
* @ return Next state .
2021-02-02 00:17:13 -05:00
* /
2021-01-27 21:04:13 -05:00
2021-11-15 07:50:17 -05:00
const isResolved = function ( ) {
let state = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
let action = arguments . length > 1 ? arguments [ 1 ] : undefined ;
2021-05-20 08:20:04 -04:00
switch ( action . type ) {
case 'INVALIDATE_RESOLUTION_FOR_STORE' :
return { } ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR' :
2022-04-11 08:04:30 -04:00
return ( 0 , external _lodash _namespaceObject . has ) ( state , [ action . selectorName ] ) ? ( 0 , external _lodash _namespaceObject . omit ) ( state , [ action . selectorName ] ) : state ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
case 'START_RESOLUTION' :
case 'FINISH_RESOLUTION' :
2022-04-12 11:12:47 -04:00
case 'FAIL_RESOLUTION' :
2021-05-20 08:20:04 -04:00
case 'START_RESOLUTIONS' :
case 'FINISH_RESOLUTIONS' :
2022-04-12 11:12:47 -04:00
case 'FAIL_RESOLUTIONS' :
2021-05-20 08:20:04 -04:00
case 'INVALIDATE_RESOLUTION' :
return subKeysIsResolved ( state , action ) ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
return state ;
} ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var metadata _reducer = ( isResolved ) ;
2018-12-13 23:41:57 -05:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* External dependencies
* /
2022-04-12 11:12:47 -04:00
/ * *
* Internal dependencies
* /
2021-11-08 09:29:21 -05:00
/** @typedef {Record<string, import('./reducer').State>} State */
2022-04-12 11:12:47 -04:00
/** @typedef {import('./reducer').StateValue} StateValue */
/** @typedef {import('./reducer').Status} Status */
2021-05-20 08:20:04 -04:00
/ * *
2022-04-12 11:12:47 -04:00
* Returns the raw resolution state value for a given selector name ,
2021-05-20 08:20:04 -04:00
* 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 .
2021-02-02 00:17:13 -05:00
*
2022-04-12 11:12:47 -04:00
* @ param { State } state Data state .
* @ param { string } selectorName Selector name .
* @ param { unknown [ ] ? } args Arguments passed to selector .
2021-05-20 08:20:04 -04:00
*
2022-04-12 11:12:47 -04:00
* @ return { StateValue | undefined } isResolving value .
2021-02-02 00:17:13 -05:00
* /
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
function getResolutionState ( state , selectorName , args ) {
2022-04-11 08:04:30 -04:00
const map = ( 0 , external _lodash _namespaceObject . get ) ( state , [ selectorName ] ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( ! map ) {
2022-04-12 11:12:47 -04:00
return ;
2021-05-20 08:20:04 -04:00
}
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
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 { 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 resolutionState = getResolutionState ( state , selectorName , args ) ;
return resolutionState && resolutionState . status === 'resolving' ;
2021-02-02 00:17:13 -05:00
}
/ * *
2021-05-20 08:20:04 -04:00
* Returns true if resolution has already been triggered for a given
* selector name , and arguments set .
2021-02-02 00:17:13 -05:00
*
2022-04-12 11:12:47 -04:00
* @ param { State } state Data state .
* @ param { string } selectorName Selector name .
* @ param { unknown [ ] ? } args Arguments passed to selector .
2021-05-20 08:20:04 -04:00
*
* @ return { boolean } Whether resolution has been triggered .
2021-02-02 00:17:13 -05:00
* /
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
function hasStartedResolution ( state , selectorName , args ) {
return getResolutionState ( state , selectorName , args ) !== undefined ;
2021-02-02 00:17:13 -05:00
}
2018-12-17 22:14:52 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Returns true if resolution has completed for a given selector
* name , and arguments set .
2021-02-02 00:17:13 -05:00
*
2022-04-12 11:12:47 -04:00
* @ param { State } state Data state .
* @ param { string } selectorName Selector name .
* @ param { unknown [ ] ? } args Arguments passed to selector .
2021-05-20 08:20:04 -04:00
*
* @ return { boolean } Whether resolution has completed .
2018-12-17 22:14:52 -05:00
* /
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
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 ;
2021-05-20 08:20:04 -04:00
}
/ * *
* Returns true if resolution has been triggered but has not yet completed for
* a given selector name , and arguments set .
*
2022-04-12 11:12:47 -04:00
* @ param { State } state Data state .
* @ param { string } selectorName Selector name .
* @ param { unknown [ ] ? } args Arguments passed to selector .
2021-05-20 08:20:04 -04:00
*
* @ return { boolean } Whether resolution is in progress .
* /
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
function isResolving ( state , selectorName , args ) {
var _getResolutionState3 ;
return ( ( _getResolutionState3 = getResolutionState ( state , selectorName , args ) ) === null || _getResolutionState3 === void 0 ? void 0 : _getResolutionState3 . status ) === 'resolving' ;
2021-05-20 08:20:04 -04:00
}
/ * *
* Returns the list of the cached resolvers .
*
2021-11-08 09:29:21 -05:00
* @ param { State } state Data state .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ return { State } Resolvers mapped by args and selectorName .
2021-05-20 08:20:04 -04:00
* /
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
function getCachedResolvers ( state ) {
return state ;
}
2018-12-13 23:41:57 -05:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js
2021-05-20 08:20:04 -04:00
/ * *
* Returns an action object used in signalling that selector resolution has
* started .
*
2021-11-08 09:29:21 -05:00
* @ param { string } selectorName Name of selector for which resolver triggered .
* @ param { unknown [ ] } args Arguments to associate for uniqueness .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ return { { type : 'START_RESOLUTION' , selectorName : string , args : unknown [ ] } } Action object .
2021-05-20 08:20:04 -04:00
* /
function startResolution ( selectorName , args ) {
return {
type : 'START_RESOLUTION' ,
selectorName ,
args
} ;
}
/ * *
* Returns an action object used in signalling that selector resolution has
* completed .
*
2021-11-08 09:29:21 -05:00
* @ param { string } selectorName Name of selector for which resolver triggered .
* @ param { unknown [ ] } args Arguments to associate for uniqueness .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ return { { type : 'FINISH_RESOLUTION' , selectorName : string , args : unknown [ ] } } Action object .
2021-05-20 08:20:04 -04:00
* /
2019-03-07 04:09:59 -05:00
2021-05-20 08:20:04 -04:00
function finishResolution ( selectorName , args ) {
return {
type : 'FINISH_RESOLUTION' ,
selectorName ,
args
} ;
}
2022-04-12 11:12:47 -04:00
/ * *
* 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
} ;
}
2021-05-20 08:20:04 -04:00
/ * *
* Returns an action object used in signalling that a batch of selector resolutions has
* started .
*
2022-04-12 11:12:47 -04:00
* @ 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 .
2021-05-20 08:20:04 -04:00
*
2022-04-12 11:12:47 -04:00
* @ return { { type : 'START_RESOLUTIONS' , selectorName : string , args : unknown [ ] [ ] } } Action object .
2021-05-20 08:20:04 -04:00
* /
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
function startResolutions ( selectorName , args ) {
return {
type : 'START_RESOLUTIONS' ,
selectorName ,
args
2021-02-02 00:17:13 -05:00
} ;
2021-05-20 08:20:04 -04:00
}
/ * *
* Returns an action object used in signalling that a batch of selector resolutions has
* completed .
*
2022-04-12 11:12:47 -04:00
* @ 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 .
2021-05-20 08:20:04 -04:00
*
2022-04-12 11:12:47 -04:00
* @ return { { type : 'FINISH_RESOLUTIONS' , selectorName : string , args : unknown [ ] [ ] } } Action object .
2021-05-20 08:20:04 -04:00
* /
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
function finishResolutions ( selectorName , args ) {
2021-02-02 00:17:13 -05:00
return {
2021-05-20 08:20:04 -04:00
type : 'FINISH_RESOLUTIONS' ,
selectorName ,
args
2021-02-02 00:17:13 -05:00
} ;
}
2022-04-12 11:12:47 -04:00
/ * *
* 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 < Error | unknown > } } Action object .
* /
function failResolutions ( selectorName , args , errors ) {
return {
type : 'FAIL_RESOLUTIONS' ,
selectorName ,
args ,
errors
} ;
}
2018-12-17 22:14:52 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Returns an action object used in signalling that we should invalidate the resolution cache .
2018-12-17 22:14:52 -05:00
*
2021-11-08 09:29:21 -05:00
* @ param { string } selectorName Name of selector for which resolver should be invalidated .
* @ param { unknown [ ] } args Arguments to associate for uniqueness .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ return { { type : 'INVALIDATE_RESOLUTION' , selectorName : string , args : any [ ] } } Action object .
2018-12-17 22:14:52 -05:00
* /
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function invalidateResolution ( selectorName , args ) {
return {
type : 'INVALIDATE_RESOLUTION' ,
selectorName ,
args
2021-02-02 00:17:13 -05:00
} ;
2021-05-20 08:20:04 -04:00
}
/ * *
* Returns an action object used in signalling that the resolution
* should be invalidated .
*
2021-11-08 09:29:21 -05:00
* @ return { { type : 'INVALIDATE_RESOLUTION_FOR_STORE' } } Action object .
2021-05-20 08:20:04 -04:00
* /
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function invalidateResolutionForStore ( ) {
return {
type : 'INVALIDATE_RESOLUTION_FOR_STORE'
2021-02-02 00:17:13 -05:00
} ;
2021-05-20 08:20:04 -04:00
}
/ * *
* Returns an action object used in signalling that the resolution cache for a
* given selectorName should be invalidated .
*
* @ param { string } selectorName Name of selector for which all resolvers should
* be invalidated .
*
2021-11-08 09:29:21 -05:00
* @ return { { type : 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR' , selectorName : string } } Action object .
2021-05-20 08:20:04 -04:00
* /
2019-03-07 04:09:59 -05:00
2021-05-20 08:20:04 -04:00
function invalidateResolutionForStoreSelector ( selectorName ) {
2019-09-19 11:19:18 -04:00
return {
2021-05-20 08:20:04 -04:00
type : 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR' ,
selectorName
} ;
}
2021-05-19 11:09:27 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js
2021-05-20 08:20:04 -04:00
/ * *
* External dependencies
* /
2021-05-19 11:09:27 -04:00
2018-12-13 23:41:57 -05:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* WordPress dependencies
2021-02-02 00:17:13 -05:00
* /
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
2021-02-02 00:17:13 -05:00
/ * *
* Internal dependencies
* /
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
2022-04-12 11:12:47 -04:00
/** @typedef {import('../types').DataRegistry} DataRegistry */
2021-05-20 08:20:04 -04:00
2022-04-12 11:12:47 -04:00
/** @typedef {import('../types').StoreDescriptor} StoreDescriptor */
2021-05-20 08:20:04 -04:00
2022-04-12 11:12:47 -04:00
/** @typedef {import('../types').ReduxStoreConfig} ReduxStoreConfig */
2018-12-13 23:41:57 -05:00
2021-11-08 09:29:21 -05:00
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 ;
} ;
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Create a cache to track whether resolvers started running or not .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ return { Object } Resolvers Cache .
2021-02-02 00:17:13 -05:00
* /
2018-12-13 23:41:57 -05:00
2021-11-08 09:29:21 -05:00
2021-05-20 08:20:04 -04:00
function createResolversCache ( ) {
const cache = { } ;
return {
isRunning ( selectorName , args ) {
2021-11-08 09:29:21 -05:00
return cache [ selectorName ] && cache [ selectorName ] . get ( trimUndefinedValues ( args ) ) ;
2021-05-20 08:20:04 -04:00
} ,
clear ( selectorName , args ) {
if ( cache [ selectorName ] ) {
2021-11-08 09:29:21 -05:00
cache [ selectorName ] . delete ( trimUndefinedValues ( args ) ) ;
2021-05-20 08:20:04 -04:00
}
} ,
markAsRunning ( selectorName , args ) {
if ( ! cache [ selectorName ] ) {
2022-04-11 08:04:30 -04:00
cache [ selectorName ] = new ( equivalent _key _map _default ( ) ) ( ) ;
2021-05-20 08:20:04 -04:00
}
2021-11-08 09:29:21 -05:00
cache [ selectorName ] . set ( trimUndefinedValues ( args ) , true ) ;
2021-05-20 08:20:04 -04:00
}
} ;
}
2021-02-02 00:17:13 -05:00
/ * *
2022-04-12 11:12:47 -04:00
* Creates a data store descriptor for the provided Redux store configuration containing
2021-05-20 08:20:04 -04:00
* properties describing reducer , actions , selectors , controls and resolvers .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ example
* ` ` ` js
* import { createReduxStore } from '@wordpress/data' ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* const store = createReduxStore ( 'demo' , {
* reducer : ( state = 'OK' ) => state ,
* selectors : {
* getValue : ( state ) => state ,
* } ,
* } ) ;
* ` ` `
*
2022-04-12 11:12:47 -04:00
* @ param { string } key Unique namespace identifier .
* @ param { ReduxStoreConfig } options Registered store options , with properties
* describing reducer , actions , selectors ,
* and resolvers .
2021-05-20 08:20:04 -04:00
*
2022-04-12 11:12:47 -04:00
* @ return { StoreDescriptor } Store Object .
2021-02-02 00:17:13 -05:00
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function createReduxStore ( key , options ) {
return {
name : key ,
instantiate : registry => {
const reducer = options . reducer ;
const thunkArgs = {
registry ,
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
get dispatch ( ) {
return Object . assign ( action => store . dispatch ( action ) , getActions ( ) ) ;
} ,
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
get select ( ) {
return Object . assign ( selector => selector ( store . _ _unstableOriginalGetState ( ) ) , getSelectors ( ) ) ;
} ,
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
get resolveSelect ( ) {
return getResolveSelectors ( ) ;
}
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
} ;
const store = instantiateReduxStore ( key , options , registry , thunkArgs ) ;
const resolversCache = createResolversCache ( ) ;
let resolvers ;
const actions = mapActions ( { ... actions _namespaceObject ,
... options . actions
} , store ) ;
2022-04-11 08:04:30 -04:00
let selectors = mapSelectors ( { ... ( 0 , external _lodash _namespaceObject . mapValues ) ( selectors _namespaceObject , selector => function ( state ) {
2021-11-15 07:50:17 -05:00
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 ) ;
} ) ,
2022-04-11 08:04:30 -04:00
... ( 0 , external _lodash _namespaceObject . mapValues ) ( options . selectors , selector => {
2021-05-20 08:20:04 -04:00
if ( selector . isRegistrySelector ) {
selector . registry = registry ;
}
2021-11-15 07:50:17 -05:00
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 ) ;
} ;
2021-05-20 08:20:04 -04:00
} )
} , store ) ;
if ( options . resolvers ) {
const result = mapResolvers ( options . resolvers , selectors , store , resolversCache ) ;
resolvers = result . resolvers ;
selectors = result . selectors ;
}
const resolveSelectors = mapResolveSelectors ( selectors , store ) ;
const getSelectors = ( ) => selectors ;
const getActions = ( ) => actions ;
const getResolveSelectors = ( ) => resolveSelectors ; // We have some modules monkey-patching the store object
// It's wrong to do so but until we refactor all of our effects to controls
// We need to keep the same "store" instance here.
2020-03-23 19:40:19 -04:00
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
store . _ _unstableOriginalGetState = store . getState ;
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
store . getState = ( ) => store . _ _unstableOriginalGetState ( ) . root ; // Customize subscribe behavior to call listeners only on effective change,
// not on every dispatch.
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
const subscribe = store && ( listener => {
let lastState = store . _ _unstableOriginalGetState ( ) ;
return store . subscribe ( ( ) => {
const state = store . _ _unstableOriginalGetState ( ) ;
const hasChanged = state !== lastState ;
lastState = state ;
if ( hasChanged ) {
listener ( ) ;
}
} ) ;
} ) ; // This can be simplified to just { subscribe, getSelectors, getActions }
// Once we remove the use function.
return {
reducer ,
store ,
actions ,
selectors ,
resolvers ,
getSelectors ,
getResolveSelectors ,
getActions ,
subscribe
} ;
2021-02-02 00:17:13 -05:00
}
2021-05-20 08:20:04 -04:00
} ;
}
/ * *
* Creates a redux store for a namespace .
*
2022-04-12 11:12:47 -04:00
* @ 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 .
2021-05-20 08:20:04 -04:00
* @ return { Object } Newly created redux store .
* /
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
function instantiateReduxStore ( key , options , registry , thunkArgs ) {
const controls = { ... options . controls ,
... builtinControls
} ;
2022-04-11 08:04:30 -04:00
const normalizedControls = ( 0 , external _lodash _namespaceObject . mapValues ) ( controls , control => control . isRegistryControl ? control ( registry ) : control ) ;
2022-04-12 11:12:47 -04:00
const middlewares = [ resolvers _cache _middleware ( registry , key ) , promise _middleware , external _wp _reduxRoutine _default ( ) ( normalizedControls ) , createThunkMiddleware ( thunkArgs ) ] ;
2021-05-20 08:20:04 -04:00
const enhancers = [ applyMiddleware ( ... middlewares ) ] ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( typeof window !== 'undefined' && window . _ _REDUX _DEVTOOLS _EXTENSION _ _ ) {
enhancers . push ( window . _ _REDUX _DEVTOOLS _EXTENSION _ _ ( {
name : key ,
instanceId : key
} ) ) ;
2021-02-02 00:17:13 -05:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
const {
reducer ,
initialState
} = options ;
const enhancedReducer = turbo _combine _reducers _default ( ) ( {
metadata : metadata _reducer ,
root : reducer
} ) ;
2022-04-11 08:04:30 -04:00
return createStore ( enhancedReducer , {
2021-05-20 08:20:04 -04:00
root : initialState
2022-04-11 08:04:30 -04:00
} , ( 0 , external _lodash _namespaceObject . flowRight ) ( enhancers ) ) ;
2021-05-20 08:20:04 -04:00
}
/ * *
* Maps selectors to a store .
*
* @ param { Object } selectors Selectors to register . Keys will be used as the
* public facing API . Selectors will get passed the
* state as first argument .
* @ param { Object } store The store to which the selectors should be mapped .
* @ return { Object } Selectors mapped to the provided store .
* /
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function mapSelectors ( selectors , store ) {
const createStateSelector = registrySelector => {
const selector = function runSelector ( ) {
// This function is an optimized implementation of:
//
// selector( store.getState(), ...arguments )
//
// Where the above would incur an `Array#concat` in its application,
// the logic here instead efficiently constructs an arguments array via
// direct assignment.
const argsLength = arguments . length ;
const args = new Array ( argsLength + 1 ) ;
args [ 0 ] = store . _ _unstableOriginalGetState ( ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
for ( let i = 0 ; i < argsLength ; i ++ ) {
args [ i + 1 ] = arguments [ i ] ;
}
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
return registrySelector ( ... args ) ;
} ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
selector . hasResolver = false ;
return selector ;
} ;
2018-12-13 23:41:57 -05:00
2022-04-11 08:04:30 -04:00
return ( 0 , external _lodash _namespaceObject . mapValues ) ( selectors , createStateSelector ) ;
2021-05-20 08:20:04 -04:00
}
/ * *
* Maps actions to dispatch from a given store .
*
2021-11-08 09:29:21 -05:00
* @ 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 .
2021-05-20 08:20:04 -04:00
* /
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function mapActions ( actions , store ) {
2021-11-15 07:50:17 -05:00
const createBoundAction = action => function ( ) {
return Promise . resolve ( store . dispatch ( action ( ... arguments ) ) ) ;
2021-05-20 08:20:04 -04:00
} ;
2018-12-13 23:41:57 -05:00
2022-04-11 08:04:30 -04:00
return ( 0 , external _lodash _namespaceObject . mapValues ) ( actions , createBoundAction ) ;
2021-05-20 08:20:04 -04:00
}
/ * *
* 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 .
2021-11-08 09:29:21 -05:00
*
* @ return { Object } Selectors mapped to their resolution functions .
2021-05-20 08:20:04 -04:00
* /
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function mapResolveSelectors ( selectors , store ) {
2022-04-12 11:12:47 -04:00
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 ) ;
} ;
2021-11-15 07:50:17 -05:00
}
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
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 ) ;
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
if ( hasFailed ) {
const error = selectors . getResolutionError ( selectorName , args ) ;
reject ( error ) ;
} else {
resolve ( result ) ;
}
} ;
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
const getResult = ( ) => selector . apply ( null , args ) ; // Trigger the selector (to trigger the resolver)
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
const result = getResult ( ) ;
2021-11-15 07:50:17 -05:00
if ( hasFinished ( ) ) {
2022-04-12 11:12:47 -04:00
return finalize ( result ) ;
2021-11-15 07:50:17 -05:00
}
2022-04-12 11:12:47 -04:00
const unsubscribe = store . subscribe ( ( ) => {
if ( hasFinished ( ) ) {
unsubscribe ( ) ;
finalize ( getResult ( ) ) ;
}
} ) ;
2021-11-15 07:50:17 -05:00
} ) ;
2022-04-12 11:12:47 -04:00
} ;
2021-11-15 07:50:17 -05:00
} ) ;
2021-05-20 08:20:04 -04:00
}
/ * *
* Returns resolvers with matched selectors for a given namespace .
* Resolvers are side effects invoked once per argument set of a given selector call ,
* used in ensuring that the data needs for the selector are satisfied .
*
* @ param { Object } resolvers Resolvers to register .
* @ param { Object } selectors The current selectors to be modified .
* @ param { Object } store The redux store to which the resolvers should be mapped .
* @ param { Object } resolversCache Resolvers Cache .
* /
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function mapResolvers ( resolvers , selectors , store , resolversCache ) {
// 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.
2022-04-11 08:04:30 -04:00
const mappedResolvers = ( 0 , external _lodash _namespaceObject . mapValues ) ( resolvers , resolver => {
2021-05-20 08:20:04 -04:00
if ( resolver . fulfill ) {
return resolver ;
}
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
return { ... resolver ,
2022-04-12 11:12:47 -04:00
// Copy the enumerable properties of the resolver function.
fulfill : resolver // Add the fulfill method.
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
} ;
} ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
const mapSelector = ( selector , selectorName ) => {
const resolver = resolvers [ selectorName ] ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( ! resolver ) {
selector . hasResolver = false ;
return selector ;
2021-02-02 00:17:13 -05:00
}
2019-09-19 11:19:18 -04:00
2021-11-15 07:50:17 -05:00
const selectorResolver = function ( ) {
2022-04-12 11:12:47 -04:00
for ( var _len5 = arguments . length , args = new Array ( _len5 ) , _key5 = 0 ; _key5 < _len5 ; _key5 ++ ) {
args [ _key5 ] = arguments [ _key5 ] ;
2021-11-15 07:50:17 -05:00
}
2021-05-20 08:20:04 -04:00
async function fulfillSelector ( ) {
const state = store . getState ( ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( resolversCache . isRunning ( selectorName , args ) || typeof resolver . isFulfilled === 'function' && resolver . isFulfilled ( state , ... args ) ) {
return ;
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
const {
metadata
} = store . _ _unstableOriginalGetState ( ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( hasStartedResolution ( metadata , selectorName , args ) ) {
return ;
}
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
resolversCache . markAsRunning ( selectorName , args ) ;
setTimeout ( async ( ) => {
resolversCache . clear ( selectorName , args ) ;
store . dispatch ( startResolution ( selectorName , args ) ) ;
2022-04-12 11:12:47 -04:00
try {
await fulfillResolver ( store , mappedResolvers , selectorName , ... args ) ;
store . dispatch ( finishResolution ( selectorName , args ) ) ;
} catch ( error ) {
store . dispatch ( failResolution ( selectorName , args , error ) ) ;
}
2021-05-20 08:20:04 -04:00
} ) ;
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
fulfillSelector ( ... args ) ;
return selector ( ... args ) ;
2021-05-19 11:09:27 -04:00
} ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
selectorResolver . hasResolver = true ;
return selectorResolver ;
} ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
return {
resolvers : mappedResolvers ,
2022-04-11 08:04:30 -04:00
selectors : ( 0 , external _lodash _namespaceObject . mapValues ) ( selectors , mapSelector )
2021-05-20 08:20:04 -04:00
} ;
2021-02-02 00:17:13 -05:00
}
2019-09-19 11:19:18 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Calls a resolver given arguments
*
* @ param { Object } store Store reference , for fulfilling via resolvers
* @ param { Object } resolvers Store Resolvers
* @ param { string } selectorName Selector name to fulfill .
2021-11-08 09:29:21 -05:00
* @ param { Array } args Selector Arguments .
2019-09-19 11:19:18 -04:00
* /
2021-11-15 07:50:17 -05:00
async function fulfillResolver ( store , resolvers , selectorName ) {
2022-04-11 08:04:30 -04:00
const resolver = ( 0 , external _lodash _namespaceObject . get ) ( resolvers , [ selectorName ] ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( ! resolver ) {
return ;
}
2019-09-19 11:19:18 -04:00
2022-04-12 11:12:47 -04:00
for ( var _len6 = arguments . length , args = new Array ( _len6 > 3 ? _len6 - 3 : 0 ) , _key6 = 3 ; _key6 < _len6 ; _key6 ++ ) {
args [ _key6 - 3 ] = arguments [ _key6 ] ;
2021-11-15 07:50:17 -05:00
}
2021-05-20 08:20:04 -04:00
const action = resolver . fulfill ( ... args ) ;
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
if ( action ) {
await store . dispatch ( action ) ;
}
}
2019-09-19 11:19:18 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/utils/emitter.js
2021-11-08 09:29:21 -05:00
/ * *
* Create an event emitter .
*
2022-04-12 11:12:47 -04:00
* @ return { import ( "../types" ) . DataEmitter } Emitter .
2021-11-08 09:29:21 -05:00
* /
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 {
get isPaused ( ) {
return isPaused ;
} ,
subscribe ( listener ) {
listeners . add ( listener ) ;
return ( ) => listeners . delete ( listener ) ;
} ,
pause ( ) {
isPaused = true ;
} ,
resume ( ) {
isPaused = false ;
if ( isPending ) {
isPending = false ;
notifyListeners ( ) ;
}
} ,
emit ( ) {
if ( isPaused ) {
isPending = true ;
return ;
}
notifyListeners ( ) ;
}
} ;
}
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js
2019-09-19 11:19:18 -04:00
/ * *
2021-02-02 00:17:13 -05:00
* External dependencies
2019-09-19 11:19:18 -04:00
* /
/ * *
2022-04-12 11:12:47 -04:00
* WordPress dependencies
2019-09-19 11:19:18 -04:00
* /
2022-04-12 11:12:47 -04:00
/ * *
* Internal dependencies
* /
2021-02-02 00:17:13 -05:00
2021-11-08 09:29:21 -05:00
2022-04-12 11:12:47 -04:00
/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* @ typedef { Object } WPDataRegistry An isolated orchestrator of store registrations .
2019-09-19 11:19:18 -04:00
*
2021-05-20 08:20:04 -04:00
* @ property { Function } registerGenericStore Given a namespace key and settings
* object , registers a new generic
* store .
* @ property { Function } registerStore Given a namespace key and settings
* object , registers a new namespace
* store .
* @ property { Function } subscribe Given a function callback , invokes
* the callback on any change to state
* within any registered store .
* @ property { Function } select Given a namespace key , returns an
* object of the store ' s registered
* selectors .
* @ property { Function } dispatch Given a namespace key , returns an
* object of the store ' s registered
* action dispatchers .
2021-02-02 00:17:13 -05:00
* /
/ * *
2021-05-20 08:20:04 -04:00
* @ typedef { Object } WPDataPlugin An object of registry function overrides .
2019-09-19 11:19:18 -04:00
*
2021-05-20 08:20:04 -04:00
* @ property { Function } registerStore registers store .
2021-02-02 00:17:13 -05:00
* /
/ * *
2021-05-20 08:20:04 -04:00
* Creates a new store registry , given an optional object of initial store
* configurations .
2019-09-19 11:19:18 -04:00
*
2021-05-20 08:20:04 -04:00
* @ param { Object } storeConfigs Initial store configurations .
* @ param { Object ? } parent Parent registry .
2019-09-19 11:19:18 -04:00
*
2021-05-20 08:20:04 -04:00
* @ return { WPDataRegistry } Data registry .
2019-09-19 11:19:18 -04:00
* /
2021-11-15 07:50:17 -05:00
function createRegistry ( ) {
let storeConfigs = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
let parent = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : null ;
2021-05-20 08:20:04 -04:00
const stores = { } ;
2021-11-08 09:29:21 -05:00
const emitter = createEmitter ( ) ;
2022-04-12 11:12:47 -04:00
const listeningStores = new Set ( ) ;
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Global listener called for each store ' s update .
2021-02-02 00:17:13 -05:00
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function globalListener ( ) {
2021-11-08 09:29:21 -05:00
emitter . emit ( ) ;
2021-02-02 00:17:13 -05:00
}
/ * *
2021-05-20 08:20:04 -04:00
* Subscribe to changes to any data .
2021-02-02 00:17:13 -05:00
*
2021-11-08 09:29:21 -05:00
* @ param { Function } listener Listener function .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ return { Function } Unsubscribe function .
2021-02-02 00:17:13 -05:00
* /
2021-05-20 08:20:04 -04:00
const subscribe = listener => {
2021-11-08 09:29:21 -05:00
return emitter . subscribe ( listener ) ;
2021-02-02 00:17:13 -05:00
} ;
/ * *
2021-05-20 08:20:04 -04:00
* Calls a selector given the current state and extra arguments .
2021-02-02 00:17:13 -05:00
*
2022-04-12 11:12:47 -04:00
* @ param { string | StoreDescriptor } storeNameOrDescriptor Unique namespace identifier for the store
* or the store descriptor .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ return { * } The selector ' s returned value .
2021-02-02 00:17:13 -05:00
* /
2019-09-19 11:19:18 -04:00
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
function select ( storeNameOrDescriptor ) {
const storeName = ( 0 , external _lodash _namespaceObject . isObject ) ( storeNameOrDescriptor ) ? storeNameOrDescriptor . name : storeNameOrDescriptor ;
listeningStores . add ( storeName ) ;
2021-05-20 08:20:04 -04:00
const store = stores [ storeName ] ;
if ( store ) {
return store . getSelectors ( ) ;
}
return parent && parent . select ( storeName ) ;
2021-02-02 00:17:13 -05:00
}
2022-04-12 11:12:47 -04:00
function _ _unstableMarkListeningStores ( callback , ref ) {
listeningStores . clear ( ) ;
2021-05-20 08:20:04 -04:00
const result = callback . call ( this ) ;
2022-04-12 11:12:47 -04:00
ref . current = Array . from ( listeningStores ) ;
2021-05-20 08:20:04 -04:00
return result ;
}
/ * *
* Given the name of a registered store , returns an object containing the store ' s
* selectors pre - bound to state so that you only need to supply additional arguments ,
* and modified so that they return promises that resolve to their eventual values ,
* after any resolvers have ran .
*
2022-04-12 11:12:47 -04:00
* @ param { string | StoreDescriptor } storeNameOrDescriptor Unique namespace identifier for the store
* or the store descriptor .
2021-05-20 08:20:04 -04:00
*
* @ return { Object } Each key of the object matches the name of a selector .
* /
2021-02-02 00:17:13 -05:00
2022-04-12 11:12:47 -04:00
function resolveSelect ( storeNameOrDescriptor ) {
const storeName = ( 0 , external _lodash _namespaceObject . isObject ) ( storeNameOrDescriptor ) ? storeNameOrDescriptor . name : storeNameOrDescriptor ;
listeningStores . add ( storeName ) ;
2021-05-20 08:20:04 -04:00
const store = stores [ storeName ] ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( store ) {
return store . getResolveSelectors ( ) ;
2021-02-02 00:17:13 -05:00
}
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
return parent && parent . resolveSelect ( storeName ) ;
}
/ * *
* Returns the available actions for a part of the state .
*
2022-04-12 11:12:47 -04:00
* @ param { string | StoreDescriptor } storeNameOrDescriptor Unique namespace identifier for the store
* or the store descriptor .
2021-05-20 08:20:04 -04:00
*
* @ return { * } The action ' s returned value .
* /
2019-09-19 11:19:18 -04:00
2022-04-12 11:12:47 -04:00
function dispatch ( storeNameOrDescriptor ) {
const storeName = ( 0 , external _lodash _namespaceObject . isObject ) ( storeNameOrDescriptor ) ? storeNameOrDescriptor . name : storeNameOrDescriptor ;
2021-05-20 08:20:04 -04:00
const store = stores [ storeName ] ;
2021-02-07 22:37:09 -05:00
2021-05-20 08:20:04 -04:00
if ( store ) {
return store . getActions ( ) ;
}
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
return parent && parent . dispatch ( storeName ) ;
} //
// Deprecated
// TODO: Remove this after `use()` is removed.
2021-02-07 22:37:09 -05:00
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
function withPlugins ( attributes ) {
2022-04-11 08:04:30 -04:00
return ( 0 , external _lodash _namespaceObject . mapValues ) ( attributes , ( attribute , key ) => {
2021-05-20 08:20:04 -04:00
if ( typeof attribute !== 'function' ) {
return attribute ;
2021-02-02 00:17:13 -05:00
}
2021-05-20 08:20:04 -04:00
return function ( ) {
return registry [ key ] . apply ( null , arguments ) ;
} ;
2019-09-19 11:19:18 -04:00
} ) ;
2021-02-02 00:17:13 -05:00
}
2021-05-20 08:20:04 -04:00
/ * *
2022-04-12 11:12:47 -04:00
* Registers a store instance .
2021-05-20 08:20:04 -04:00
*
2022-04-12 11:12:47 -04:00
* @ param { string } name Store registry name .
* @ param { Object } store Store instance object ( getSelectors , getActions , subscribe ) .
2021-05-20 08:20:04 -04:00
* /
2019-09-19 11:19:18 -04:00
2022-04-12 11:12:47 -04:00
function registerStoreInstance ( name , store ) {
if ( typeof store . getSelectors !== 'function' ) {
throw new TypeError ( 'store.getSelectors must be a function' ) ;
2021-05-20 08:20:04 -04:00
}
2019-09-19 11:19:18 -04:00
2022-04-12 11:12:47 -04:00
if ( typeof store . getActions !== 'function' ) {
throw new TypeError ( 'store.getActions must be a function' ) ;
2021-05-20 08:20:04 -04:00
}
2019-09-19 11:19:18 -04:00
2022-04-12 11:12:47 -04:00
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
2021-11-08 09:29:21 -05:00
// get paused, that way, when resumed we should be able to call all these
// pending listeners.
2022-04-12 11:12:47 -04:00
store . emitter = createEmitter ( ) ;
const currentSubscribe = store . subscribe ;
2021-11-08 09:29:21 -05:00
2022-04-12 11:12:47 -04:00
store . subscribe = listener => {
const unsubscribeFromEmitter = store . emitter . subscribe ( listener ) ;
const unsubscribeFromStore = currentSubscribe ( ( ) => {
if ( store . emitter . isPaused ) {
store . emitter . emit ( ) ;
2021-11-08 09:29:21 -05:00
return ;
}
listener ( ) ;
} ) ;
return ( ) => {
2022-04-12 11:12:47 -04:00
unsubscribeFromStore === null || unsubscribeFromStore === void 0 ? void 0 : unsubscribeFromStore ( ) ;
unsubscribeFromEmitter === null || unsubscribeFromEmitter === void 0 ? void 0 : unsubscribeFromEmitter ( ) ;
2021-11-08 09:29:21 -05:00
} ;
} ;
2021-05-20 08:20:04 -04:00
2022-04-12 11:12:47 -04:00
stores [ name ] = store ;
store . subscribe ( globalListener ) ;
2021-02-02 00:17:13 -05:00
}
2021-05-20 08:20:04 -04:00
/ * *
2022-04-12 11:12:47 -04:00
* Registers a new store given a store descriptor .
2021-05-20 08:20:04 -04:00
*
2022-04-12 11:12:47 -04:00
* @ param { StoreDescriptor } store Store descriptor .
2021-05-20 08:20:04 -04:00
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function register ( store ) {
2022-04-12 11:12:47 -04:00
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 ;
2021-02-02 00:17:13 -05:00
}
2021-05-20 08:20:04 -04:00
/ * *
* Subscribe handler to a store .
*
* @ param { string [ ] } storeName The store name .
* @ param { Function } handler The function subscribed to the store .
* @ return { Function } A function to unsubscribe the handler .
* /
2019-09-19 11:19:18 -04:00
2018-12-13 23:41:57 -05:00
2022-04-12 11:12:47 -04:00
function _ _unstableSubscribeStore ( storeName , handler ) {
2021-05-20 08:20:04 -04:00
if ( storeName in stores ) {
return stores [ storeName ] . subscribe ( handler ) ;
} // Trying to access a store that hasn't been registered,
// this is a pattern rarely used but seen in some places.
// We fallback to regular `subscribe` here for backward-compatibility for now.
// See https://github.com/WordPress/gutenberg/pull/27466 for more info.
2019-09-19 11:19:18 -04:00
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( ! parent ) {
return subscribe ( handler ) ;
}
2018-12-17 22:14:52 -05:00
2022-04-12 11:12:47 -04:00
return parent . _ _unstableSubscribeStore ( storeName , handler ) ;
2021-05-20 08:20:04 -04:00
}
2019-03-21 08:48:00 -04:00
2021-11-08 09:29:21 -05:00
function batch ( callback ) {
emitter . pause ( ) ;
2022-04-11 08:04:30 -04:00
( 0 , external _lodash _namespaceObject . forEach ) ( stores , store => store . emitter . pause ( ) ) ;
2021-11-08 09:29:21 -05:00
callback ( ) ;
emitter . resume ( ) ;
2022-04-11 08:04:30 -04:00
( 0 , external _lodash _namespaceObject . forEach ) ( stores , store => store . emitter . resume ( ) ) ;
2021-11-08 09:29:21 -05:00
}
2021-05-20 08:20:04 -04:00
let registry = {
2021-11-08 09:29:21 -05:00
batch ,
2021-05-20 08:20:04 -04:00
stores ,
namespaces : stores ,
// TODO: Deprecate/remove this.
subscribe ,
select ,
resolveSelect ,
dispatch ,
use ,
register ,
2022-04-12 11:12:47 -04:00
registerGenericStore ,
registerStore ,
_ _unstableMarkListeningStores ,
_ _unstableSubscribeStore
2021-05-20 08:20:04 -04:00
} ; //
// TODO:
// This function will be deprecated as soon as it is no longer internally referenced.
2019-03-21 08:48:00 -04:00
2021-05-20 08:20:04 -04:00
function use ( plugin , options ) {
2022-04-12 11:12:47 -04:00
if ( ! plugin ) {
return ;
}
2021-05-20 08:20:04 -04:00
registry = { ... registry ,
... plugin ( registry , options )
} ;
return registry ;
}
2019-03-21 08:48:00 -04:00
2022-04-12 11:12:47 -04:00
registry . register ( store ) ;
for ( const [ name , config ] of Object . entries ( storeConfigs ) ) {
registry . register ( createReduxStore ( name , config ) ) ;
}
2019-03-21 08:48:00 -04:00
2021-05-20 08:20:04 -04:00
if ( parent ) {
parent . subscribe ( globalListener ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
return withPlugins ( registry ) ;
}
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js
2020-06-26 09:33:47 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Internal dependencies
2020-06-26 09:33:47 -04:00
* /
2021-05-20 08:20:04 -04:00
/* harmony default export */ var default _registry = ( createRegistry ( ) ) ;
2019-09-19 11:19:18 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js
2021-05-20 08:20:04 -04:00
let objectStorage ;
const storage = {
getItem ( key ) {
if ( ! objectStorage || ! objectStorage [ key ] ) {
return null ;
}
2019-03-21 08:48:00 -04:00
2021-05-20 08:20:04 -04:00
return objectStorage [ key ] ;
} ,
2019-03-21 08:48:00 -04:00
2021-05-20 08:20:04 -04:00
setItem ( key , value ) {
if ( ! objectStorage ) {
storage . clear ( ) ;
}
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
objectStorage [ key ] = String ( value ) ;
} ,
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
clear ( ) {
objectStorage = Object . create ( null ) ;
}
} ;
/* harmony default export */ var object = ( storage ) ;
2019-03-21 08:48:00 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js
2019-09-19 11:19:18 -04:00
/ * *
2021-02-02 00:17:13 -05:00
* Internal dependencies
2019-09-19 11:19:18 -04:00
* /
2019-03-21 08:48:00 -04:00
2021-05-20 08:20:04 -04:00
let default _storage ;
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
try {
// Private Browsing in Safari 10 and earlier will throw an error when
// attempting to set into localStorage. The test here is intentional in
// causing a thrown error as condition for using fallback object storage.
default _storage = window . localStorage ;
default _storage . setItem ( '__wpDataTestLocalStorage' , '' ) ;
default _storage . removeItem ( '__wpDataTestLocalStorage' ) ;
} catch ( error ) {
default _storage = object ;
2021-02-02 00:17:13 -05:00
}
2021-05-20 08:20:04 -04:00
/* harmony default export */ var storage _default = ( default _storage ) ;
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js
2019-09-19 11:19:18 -04:00
/ * *
2021-02-02 00:17:13 -05:00
* External dependencies
2019-09-19 11:19:18 -04:00
* /
/ * *
2021-05-20 08:20:04 -04:00
* Internal dependencies
2019-09-19 11:19:18 -04:00
* /
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
/** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
/** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */
2021-02-02 00:17:13 -05:00
2019-09-19 11:19:18 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* @ typedef { Object } WPDataPersistencePluginOptions Persistence plugin options .
*
* @ property { Storage } storage Persistent storage implementation . This must
* at least implement ` getItem ` and ` setItem ` of
* the Web Storage API .
* @ property { string } storageKey Key on which to set in persistent storage .
*
2019-09-19 11:19:18 -04:00
* /
2021-01-27 21:04:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Default plugin storage .
2021-01-27 21:04:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ type { Storage }
* /
const DEFAULT _STORAGE = storage _default ;
/ * *
* Default plugin storage key .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ type { string }
* /
const DEFAULT _STORAGE _KEY = 'WP_DATA' ;
/ * *
* Higher - order reducer which invokes the original reducer only if state is
* inequal from that of the action ' s ` nextState ` property , otherwise returning
* the original state reference .
2021-01-27 21:04:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { Function } reducer Original reducer .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ return { Function } Enhanced reducer .
* /
const withLazySameState = reducer => ( state , action ) => {
if ( action . nextState === state ) {
return state ;
}
return reducer ( state , action ) ;
} ;
/ * *
* Creates a persistence interface , exposing getter and setter methods ( ` get `
* and ` set ` respectively ) .
2021-05-07 07:48:27 -04:00
*
2021-05-20 08:20:04 -04:00
* @ param { WPDataPersistencePluginOptions } options Plugin options .
2021-05-07 07:48:27 -04:00
*
2021-05-20 08:20:04 -04:00
* @ return { Object } Persistence interface .
* /
function createPersistenceInterface ( options ) {
const {
storage = DEFAULT _STORAGE ,
storageKey = DEFAULT _STORAGE _KEY
} = options ;
let data ;
/ * *
* Returns the persisted data as an object , defaulting to an empty object .
*
* @ return { Object } Persisted data .
* /
function getData ( ) {
if ( data === undefined ) {
// If unset, getItem is expected to return null. Fall back to
// empty object.
const persisted = storage . getItem ( storageKey ) ;
if ( persisted === null ) {
data = { } ;
} else {
try {
data = JSON . parse ( persisted ) ;
} catch ( error ) {
// Similarly, should any error be thrown during parse of
// the string (malformed JSON), fall back to empty object.
data = { } ;
}
}
}
return data ;
}
/ * *
* Merges an updated reducer state into the persisted data .
*
* @ param { string } key Key to update .
* @ param { * } value Updated value .
* /
function setData ( key , value ) {
data = { ... data ,
[ key ] : value
} ;
storage . setItem ( storageKey , JSON . stringify ( data ) ) ;
}
return {
get : getData ,
set : setData
} ;
}
/ * *
* Data plugin to persist store state into a single storage key .
2021-05-07 07:48:27 -04:00
*
2021-05-20 08:20:04 -04:00
* @ param { WPDataRegistry } registry Data registry .
* @ param { ? WPDataPersistencePluginOptions } pluginOptions Plugin options .
2021-05-07 07:48:27 -04:00
*
2021-05-20 08:20:04 -04:00
* @ return { WPDataPlugin } Data plugin .
2021-01-27 21:04:13 -05:00
* /
2021-05-20 08:20:04 -04:00
function persistencePlugin ( registry , pluginOptions ) {
const persistence = createPersistenceInterface ( pluginOptions ) ;
/ * *
* Creates an enhanced store dispatch function , triggering the state of the
* given store name to be persisted when changed .
*
* @ param { Function } getState Function which returns current state .
* @ param { string } storeName Store name .
* @ param { ? Array < string > } keys Optional subset of keys to save .
*
* @ return { Function } Enhanced dispatch function .
* /
function createPersistOnChange ( getState , storeName , keys ) {
let getPersistedState ;
if ( Array . isArray ( keys ) ) {
// Given keys, the persisted state should by produced as an object
// of the subset of keys. This implementation uses combineReducers
// to leverage its behavior of returning the same object when none
// of the property values changes. This allows a strict reference
// equality to bypass a persistence set on an unchanging state.
const reducers = keys . reduce ( ( accumulator , key ) => Object . assign ( accumulator , {
[ key ] : ( state , action ) => action . nextState [ key ]
} ) , { } ) ;
getPersistedState = withLazySameState ( turbo _combine _reducers _default ( ) ( reducers ) ) ;
} else {
getPersistedState = ( state , action ) => action . nextState ;
}
let lastState = getPersistedState ( undefined , {
nextState : getState ( )
} ) ;
return ( ) => {
const state = getPersistedState ( lastState , {
nextState : getState ( )
} ) ;
if ( state !== lastState ) {
persistence . set ( storeName , state ) ;
lastState = state ;
}
} ;
}
return {
registerStore ( storeName , options ) {
if ( ! options . persist ) {
return registry . registerStore ( storeName , options ) ;
} // Load from persistence to use as initial state.
const persistedState = persistence . get ( ) [ storeName ] ;
if ( persistedState !== undefined ) {
let initialState = options . reducer ( options . initialState , {
type : '@@WP/PERSISTENCE_RESTORE'
} ) ;
2022-04-11 08:04:30 -04:00
if ( ( 0 , external _lodash _namespaceObject . isPlainObject ) ( initialState ) && ( 0 , external _lodash _namespaceObject . isPlainObject ) ( persistedState ) ) {
2021-05-20 08:20:04 -04:00
// 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.
2022-04-11 08:04:30 -04:00
initialState = ( 0 , external _lodash _namespaceObject . merge ) ( { } , initialState , persistedState ) ;
2021-05-20 08:20:04 -04:00
} else {
// If there is a mismatch in object-likeness of default
// initial or persisted state, defer to persisted value.
initialState = persistedState ;
}
options = { ... options ,
initialState
} ;
}
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
const store = registry . registerStore ( storeName , options ) ;
store . subscribe ( createPersistOnChange ( store . getState , storeName , options . persist ) ) ;
return store ;
}
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
} ;
}
/ * *
2021-11-08 09:29:21 -05:00
* Move the 'features' object in local storage from the sourceStoreName to the
2022-04-12 11:12:47 -04:00
* preferences store .
2021-11-08 09:29:21 -05:00
*
* @ param { Object } persistence The persistence interface .
* @ param { string } sourceStoreName The name of the store that has persisted
2022-04-12 11:12:47 -04:00
* preferences to migrate to the preferences
2021-11-08 09:29:21 -05:00
* package .
2021-05-20 08:20:04 -04:00
* /
2021-01-27 21:04:13 -05:00
2021-02-02 00:17:13 -05:00
2022-04-12 11:12:47 -04:00
function migrateFeaturePreferencesToPreferencesStore ( persistence , sourceStoreName ) {
var _state$interfaceStore , _state$interfaceStore2 , _state$interfaceStore3 , _state$sourceStoreNam , _state$sourceStoreNam2 ;
2021-02-02 00:17:13 -05:00
2022-04-12 11:12:47 -04:00
const preferencesStoreName = 'core/preferences' ;
2021-11-08 09:29:21 -05:00
const interfaceStoreName = 'core/interface' ;
2022-04-12 11:12:47 -04:00
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 ;
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
if ( featuresToMigrate ) {
var _state$preferencesSto ;
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
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.
2021-05-20 08:20:04 -04:00
2022-04-12 11:12:47 -04:00
if ( ! ( existingPreferences !== null && existingPreferences !== void 0 && existingPreferences [ sourceStoreName ] ) ) {
2021-11-08 09:29:21 -05:00
// Set the feature values in the interface store, the features
// object is keyed by 'scope', which matches the store name for
// the source.
2022-04-12 11:12:47 -04:00
persistence . set ( preferencesStoreName , {
preferences : { ... existingPreferences ,
[ sourceStoreName ] : featuresToMigrate
2021-05-20 08:20:04 -04:00
}
2022-04-12 11:12:47 -04:00
} ) ; // Remove migrated feature preferences from `interface`.
2021-05-07 07:48:27 -04:00
2022-04-12 11:12:47 -04:00
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 .
* /
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 ) ;
2021-11-08 09:29:21 -05:00
}
2022-04-12 11:12:47 -04:00
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 : {
features : { ... otherInterfaceScopes ,
[ scope ] : undefined
}
}
} ) ;
2021-05-20 08:20:04 -04:00
}
2021-11-08 09:29:21 -05:00
}
/ * *
2022-04-12 11:12:47 -04:00
* 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 .
2021-11-08 09:29:21 -05:00
* /
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
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
}
} ;
} , 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
} ) ;
}
2021-11-08 09:29:21 -05:00
persistencePlugin . _ _unstableMigrate = pluginOptions => {
2022-04-12 11:12:47 -04:00
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 ) ;
2021-05-20 08:20:04 -04:00
} ;
2021-02-02 00:17:13 -05:00
2022-04-11 08:04:30 -04:00
/* 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 || 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 ] ;
}
}
}
2021-02-02 00:17:13 -05:00
2022-04-11 08:04:30 -04:00
return target ;
} ;
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
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
2021-02-02 00:17:13 -05:00
2019-03-21 08:48:00 -04:00
2022-04-11 08:04:30 -04:00
function areInputsEqual ( newInputs , lastInputs ) {
if ( newInputs . length !== lastInputs . length ) {
return false ;
}
2021-05-20 08:20:04 -04:00
2022-04-11 08:04:30 -04:00
for ( var i = 0 ; i < newInputs . length ; i ++ ) {
if ( newInputs [ i ] !== lastInputs [ i ] ) {
return false ;
}
}
2021-05-20 08:20:04 -04:00
2022-04-11 08:04:30 -04:00
return true ;
}
2021-05-20 08:20:04 -04:00
2022-04-11 08:04:30 -04:00
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 ) ) ;
2020-06-26 09:33:47 -04:00
2020-10-13 09:10:30 -04:00
2022-04-11 08:04:30 -04:00
; // 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
2021-02-02 00:17:13 -05:00
/ * *
* WordPress dependencies
* /
2020-10-13 09:10:30 -04:00
2021-02-02 00:17:13 -05:00
/ * *
* Internal dependencies
* /
2022-04-11 08:04:30 -04:00
const Context = ( 0 , external _wp _element _namespaceObject . createContext ) ( default _registry ) ;
2021-05-20 08:20:04 -04:00
const {
Consumer ,
Provider
} = Context ;
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* A custom react Context consumer exposing the provided ` registry ` to
* children components . Used along with the RegistryProvider .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* You can read more about the react context api here :
* https : //reactjs.org/docs/context.html#contextprovider
2021-02-02 00:17:13 -05:00
*
* @ example
* ` ` ` js
2021-05-20 08:20:04 -04:00
* import {
* RegistryProvider ,
* RegistryConsumer ,
* createRegistry
* } from '@wordpress/data' ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* const registry = createRegistry ( { } ) ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* const App = ( { props } ) => {
* return < RegistryProvider value = { registry } >
* < div > Hello There < / d i v >
* < RegistryConsumer >
* { ( registry ) => (
* < ComponentUsingRegistry
* { ... props }
* registry = { registry }
* ) }
* < / R e g i s t r y C o n s u m e r >
* < / R e g i s t r y P r o v i d e r >
* }
* ` ` `
2020-03-10 10:53:18 -04:00
* /
2021-05-20 08:20:04 -04:00
const RegistryConsumer = Consumer ;
2020-03-10 10:53:18 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* A custom Context provider for exposing the provided ` registry ` to children
* components via a consumer .
2020-03-10 10:53:18 -04:00
*
2021-05-20 08:20:04 -04:00
* See < a name = "#RegistryConsumer" > RegistryConsumer < / a > d o c u m e n t a t i o n f o r
* example .
2020-03-10 10:53:18 -04:00
* /
2019-10-15 11:37:08 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var context = ( Provider ) ;
2020-01-08 06:57:23 -05:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js
2021-02-02 00:17:13 -05:00
/ * *
* WordPress dependencies
* /
2020-01-08 06:57:23 -05:00
2021-02-02 00:17:13 -05:00
/ * *
* Internal dependencies
* /
2020-01-08 06:57:23 -05:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* A custom react hook exposing the registry context for use .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* This exposes the ` registry ` value provided via the
* < a href = "#RegistryProvider" > Registry Provider < / a > t o a c o m p o n e n t i m p l e m e n t i n g
* this hook .
*
* It acts similarly to the ` useContext ` react hook .
*
* Note : Generally speaking , ` useRegistry ` is a low level hook that in most cases
* won ' t be needed for implementation . Most interactions with the ` @wordpress/data `
* API can be performed via the ` useSelect ` hook , or the ` withSelect ` and
* ` withDispatch ` higher order components .
2021-02-02 00:17:13 -05:00
*
* @ example
2021-05-20 08:20:04 -04:00
* ` ` ` js
* import {
* RegistryProvider ,
* createRegistry ,
* useRegistry ,
* } from '@wordpress/data' ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* const registry = createRegistry ( { } ) ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* const SomeChildUsingRegistry = ( props ) => {
2021-11-08 09:29:21 -05:00
* const registry = useRegistry ( ) ;
2021-05-20 08:20:04 -04:00
* // ...logic implementing the registry in other react hooks.
* } ;
2021-02-02 00:17:13 -05:00
*
*
2021-05-20 08:20:04 -04:00
* const ParentProvidingRegistry = ( props ) => {
* return < RegistryProvider value = { registry } >
* < SomeChildUsingRegistry { ... props } / >
* < / R e g i s t r y P r o v i d e r >
* } ;
2021-02-02 00:17:13 -05:00
* ` ` `
*
2021-05-20 08:20:04 -04:00
* @ return { Function } A custom react hook exposing the registry context value .
* /
function useRegistry ( ) {
2022-04-11 08:04:30 -04:00
return ( 0 , external _wp _element _namespaceObject . useContext ) ( Context ) ;
2021-05-20 08:20:04 -04:00
}
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2022-04-11 08:04:30 -04:00
const context _Context = ( 0 , external _wp _element _namespaceObject . createContext ) ( false ) ;
2021-05-20 08:20:04 -04:00
const {
Consumer : context _Consumer ,
Provider : context _Provider
} = context _Context ;
2022-04-11 08:04:30 -04:00
const AsyncModeConsumer = ( /* unused pure expression or super */ null && ( context _Consumer ) ) ;
2021-05-20 08:20:04 -04:00
/ * *
* Context Provider Component used to switch the data module component rerendering
* between Sync and Async modes .
*
2021-02-02 00:17:13 -05:00
* @ example
*
2021-05-20 08:20:04 -04:00
* ` ` ` js
* import { useSelect , AsyncModeProvider } from '@wordpress/data' ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* function BlockCount ( ) {
* const count = useSelect ( ( select ) => {
* return select ( 'core/block-editor' ) . getBlockCount ( )
* } , [ ] ) ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* return count ;
* }
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* function App ( ) {
* return (
* < AsyncModeProvider value = { true } >
* < BlockCount / >
* < / A s y n c M o d e P r o v i d e r >
* ) ;
* }
2021-02-02 00:17:13 -05:00
* ` ` `
*
2021-05-20 08:20:04 -04:00
* In this example , the BlockCount component is rerendered asynchronously .
* It means if a more critical task is being performed ( like typing in an input ) ,
* the rerendering is delayed until the browser becomes IDLE .
* It is possible to nest multiple levels of AsyncModeProvider to fine - tune the rendering behavior .
2021-02-02 00:17:13 -05:00
*
2021-11-08 09:29:21 -05:00
* @ param { boolean } props . value Enable Async Mode .
2021-05-20 08:20:04 -04:00
* @ return { WPComponent } The component to be rendered .
2021-02-02 00:17:13 -05:00
* /
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var async _mode _provider _context = ( context _Provider ) ;
2019-03-21 08:48:00 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js
2021-02-02 00:17:13 -05:00
/ * *
* WordPress dependencies
* /
2020-03-23 19:40:19 -04:00
2021-02-02 00:17:13 -05:00
/ * *
* Internal dependencies
* /
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
function useAsyncMode ( ) {
2022-04-11 08:04:30 -04:00
return ( 0 , external _wp _element _namespaceObject . useContext ) ( context _Context ) ;
2021-05-20 08:20:04 -04:00
}
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* External dependencies
2021-02-02 00:17:13 -05:00
* /
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-02-02 00:17:13 -05:00
/ * *
* Internal dependencies
* /
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
2022-04-12 11:12:47 -04:00
const noop = ( ) => { } ;
2022-04-11 08:04:30 -04:00
const renderQueue = ( 0 , external _wp _priorityQueue _namespaceObject . createQueue ) ( ) ;
2022-04-12 11:12:47 -04:00
/** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */
2021-01-27 21:04:13 -05:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Custom react hook for retrieving props from registered selectors .
*
* In general , this custom React hook follows the
* [ rules of hooks ] ( https : //reactjs.org/docs/hooks-rules.html).
*
2022-04-12 11:12:47 -04:00
* @ 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 .
2021-05-20 08:20:04 -04:00
*
* @ example
* ` ` ` js
* import { useSelect } from '@wordpress/data' ;
*
* function HammerPriceDisplay ( { currency } ) {
* const price = useSelect ( ( select ) => {
* return select ( 'my-shop' ) . getPrice ( 'hammer' , currency )
* } , [ currency ] ) ;
* return new Intl . NumberFormat ( 'en-US' , {
* style : 'currency' ,
* currency ,
* } ) . format ( price ) ;
* }
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* // Rendered in the application:
* // <HammerPriceDisplay currency="USD" />
* ` ` `
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* In the above example , when ` HammerPriceDisplay ` is rendered into an
* application , the price will be retrieved from the store state using the
* ` mapSelect ` callback on ` useSelect ` . If the currency prop changes then
* any price in the state for that currency is retrieved . If the currency prop
* doesn ' t change and other props are passed in that do change , the price will
* not change because the dependency is just the currency .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* When data is only used in an event callback , the data should not be retrieved
* on render , so it may be useful to get the selectors function instead .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* * * Don ' t use ` useSelect ` this way when calling the selectors in the render
* function because your component won ' t re - render on a data change . * *
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* ` ` ` js
* import { useSelect } from '@wordpress/data' ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* function Paste ( { children } ) {
* const { getSettings } = useSelect ( 'my-shop' ) ;
* function onPaste ( ) {
* // Do something with the settings.
* const settings = getSettings ( ) ;
* }
* return < div onPaste = { onPaste } > { children } < / d i v > ;
2021-02-02 00:17:13 -05:00
* }
* ` ` `
2021-05-20 08:20:04 -04:00
*
2021-02-02 00:17:13 -05:00
* @ return { Function } A custom react hook .
* /
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
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.
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
if ( ! hasMappingFunction ) {
2021-05-20 08:20:04 -04:00
deps = [ ] ;
2022-04-12 11:12:47 -04:00
} // 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 ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
const registry = useRegistry ( ) ;
const isAsync = useAsyncMode ( ) ; // React can sometimes clear the `useMemo` cache.
// We use the cache-stable `useMemoOne` to avoid
// losing queues.
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
const queueContext = useMemoOne ( ( ) => ( {
2021-05-20 08:20:04 -04:00
queue : true
} ) , [ registry ] ) ;
2022-04-11 08:04:30 -04:00
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 ) ( ) ;
2022-04-12 11:12:47 -04:00
const isMountedAndNotUnsubscribing = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ; // Keep track of the stores being selected in the _mapSelect function,
2021-05-20 08:20:04 -04:00
// and only subscribe to those stores later.
2022-04-11 08:04:30 -04:00
const listeningStores = ( 0 , external _wp _element _namespaceObject . useRef ) ( [ ] ) ;
2022-04-12 11:12:47 -04:00
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.
2021-05-20 08:20:04 -04:00
// It's different than just using `mapSelect` since deps could be undefined,
// in that case, we would still want to memoize it.
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
const depsChangedFlag = ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => ( { } ) , deps || [ ] ) ;
2021-05-20 08:20:04 -04:00
let mapOutput ;
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
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 } ` ;
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
if ( latestMapOutputError . current ) {
errorMessage += ` \n The 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
2021-06-15 04:52:30 -04:00
2022-04-12 11:12:47 -04:00
console . error ( errorMessage ) ;
}
2021-05-20 08:20:04 -04:00
}
}
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
( 0 , external _wp _compose _namespaceObject . useIsomorphicLayoutEffect ) ( ( ) => {
2022-04-12 11:12:47 -04:00
if ( ! hasMappingFunction ) {
2021-05-20 08:20:04 -04:00
return ;
}
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
latestMapSelect . current = _mapSelect ;
2021-05-20 08:20:04 -04:00
latestMapOutput . current = mapOutput ;
latestMapOutputError . current = undefined ;
isMountedAndNotUnsubscribing . current = true ; // This has to run after the other ref updates
// to avoid using stale values in the flushed
// callbacks or potentially overwriting a
// changed `latestMapOutput.current`.
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
if ( latestIsAsync . current !== isAsync ) {
latestIsAsync . current = isAsync ;
renderQueue . flush ( queueContext ) ;
}
} ) ;
2022-04-11 08:04:30 -04:00
( 0 , external _wp _compose _namespaceObject . useIsomorphicLayoutEffect ) ( ( ) => {
2022-04-12 11:12:47 -04:00
if ( ! hasMappingFunction ) {
2021-05-20 08:20:04 -04:00
return ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
const onStoreChange = ( ) => {
if ( isMountedAndNotUnsubscribing . current ) {
try {
2022-04-12 11:12:47 -04:00
const newMapOutput = wrapSelect ( latestMapSelect . current ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
if ( external _wp _isShallowEqual _default ( ) ( latestMapOutput . current , newMapOutput ) ) {
return ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
latestMapOutput . current = newMapOutput ;
} catch ( error ) {
latestMapOutputError . current = error ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
forceRender ( ) ;
}
2022-04-12 11:12:47 -04:00
} ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
const onChange = ( ) => {
if ( latestIsAsync . current ) {
renderQueue . add ( queueContext , onStoreChange ) ;
} else {
onStoreChange ( ) ;
}
2022-04-12 11:12:47 -04:00
} ; // Catch any possible state changes during mount before the subscription
// could be set.
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
onChange ( ) ;
const unsubscribers = listeningStores . current . map ( storeName => registry . _ _unstableSubscribeStore ( storeName , onChange ) ) ;
2021-05-20 08:20:04 -04:00
return ( ) => {
isMountedAndNotUnsubscribing . current = false ; // The return value of the subscribe function could be undefined if the store is a custom generic store.
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
unsubscribers . forEach ( unsubscribe => unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe ( ) ) ;
renderQueue . flush ( queueContext ) ;
2022-04-12 11:12:47 -04:00
} ; // 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 ) ;
2021-05-20 08:20:04 -04:00
}
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js
2021-01-27 21:04:13 -05:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* WordPress dependencies
2021-02-02 00:17:13 -05:00
* /
2021-01-27 21:04:13 -05:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Internal dependencies
2021-02-02 00:17:13 -05:00
* /
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Higher - order component used to inject state - derived props using registered
* selectors .
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { Function } mapSelectToProps Function called on every state change ,
2021-11-08 09:29:21 -05:00
* expected to return object of props to
* merge with the component ' s own props .
2021-02-02 00:17:13 -05:00
*
* @ example
* ` ` ` js
2021-05-20 08:20:04 -04:00
* import { withSelect } from '@wordpress/data' ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* function PriceDisplay ( { price , currency } ) {
* return new Intl . NumberFormat ( 'en-US' , {
* style : 'currency' ,
* currency ,
* } ) . format ( price ) ;
* }
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* const HammerPriceDisplay = withSelect ( ( select , ownProps ) => {
* const { getPrice } = select ( 'my-shop' ) ;
* const { currency } = ownProps ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* return {
* price : getPrice ( 'hammer' , currency ) ,
* } ;
* } ) ( PriceDisplay ) ;
2021-02-02 00:17:13 -05:00
*
2021-05-20 08:20:04 -04:00
* // Rendered in the application:
* //
* // <HammerPriceDisplay currency="USD" />
2021-02-02 00:17:13 -05:00
* ` ` `
2021-05-20 08:20:04 -04:00
* In the above example , when ` HammerPriceDisplay ` is rendered into an
* application , it will pass the price into the underlying ` PriceDisplay `
* component and update automatically if the price of a hammer ever changes in
* the store .
*
* @ return { WPComponent } Enhanced component with merged state data props .
2021-02-02 00:17:13 -05:00
* /
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
const withSelect = mapSelectToProps => ( 0 , external _wp _compose _namespaceObject . createHigherOrderComponent ) ( WrappedComponent => ( 0 , external _wp _compose _namespaceObject . pure ) ( ownProps => {
2021-05-20 08:20:04 -04:00
const mapSelect = ( select , registry ) => mapSelectToProps ( select , ownProps , registry ) ;
const mergeProps = useSelect ( mapSelect ) ;
2022-04-11 08:04:30 -04:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( WrappedComponent , _extends ( { } , ownProps , mergeProps ) ) ;
2021-05-20 08:20:04 -04:00
} ) , 'withSelect' ) ;
/* harmony default export */ var with _select = ( withSelect ) ;
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* External dependencies
2021-02-02 00:17:13 -05:00
* /
2021-01-27 21:04:13 -05:00
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* WordPress dependencies
2021-02-02 00:17:13 -05:00
* /
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
2021-05-19 11:09:27 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Internal dependencies
2021-05-19 11:09:27 -04:00
* /
2021-05-20 08:20:04 -04:00
2021-05-19 11:09:27 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Custom react hook for returning aggregate dispatch actions using the provided
* dispatchMap .
2021-05-19 11:09:27 -04:00
*
2021-05-20 08:20:04 -04:00
* Currently this is an internal api only and is implemented by ` withDispatch `
2021-05-19 11:09:27 -04:00
*
2021-11-08 09:29:21 -05:00
* @ 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 .
2021-05-20 08:20:04 -04:00
* @ return { Object } An object mapping props to functions created by the passed
* in dispatchMap .
2021-05-19 11:09:27 -04:00
* /
2021-05-20 08:20:04 -04:00
const useDispatchWithMap = ( dispatchMap , deps ) => {
const registry = useRegistry ( ) ;
2022-04-11 08:04:30 -04:00
const currentDispatchMap = ( 0 , external _wp _element _namespaceObject . useRef ) ( dispatchMap ) ;
( 0 , external _wp _compose _namespaceObject . useIsomorphicLayoutEffect ) ( ( ) => {
2021-05-20 08:20:04 -04:00
currentDispatchMap . current = dispatchMap ;
} ) ;
2022-04-11 08:04:30 -04:00
return ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => {
2021-05-20 08:20:04 -04:00
const currentDispatchProps = currentDispatchMap . current ( registry . dispatch , registry ) ;
2022-04-11 08:04:30 -04:00
return ( 0 , external _lodash _namespaceObject . mapValues ) ( currentDispatchProps , ( dispatcher , propName ) => {
2021-05-20 08:20:04 -04:00
if ( typeof dispatcher !== 'function' ) {
// eslint-disable-next-line no-console
console . warn ( ` Property ${ propName } returned from dispatchMap in useDispatchWithMap must be a function. ` ) ;
2021-05-19 11:09:27 -04:00
}
2021-11-15 07:50:17 -05:00
return function ( ) {
return currentDispatchMap . current ( registry . dispatch , registry ) [ propName ] ( ... arguments ) ;
} ;
2021-05-20 08:20:04 -04:00
} ) ;
} , [ registry , ... deps ] ) ;
} ;
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var use _dispatch _with _map = ( useDispatchWithMap ) ;
2021-05-19 11:09:27 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2021-05-19 11:09:27 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Higher - order component used to add dispatch props using registered action
* creators .
*
* @ param { Function } mapDispatchToProps A function of returning an object of
* prop names where value is a
* dispatch - bound action creator , or a
* function to be called with the
* component ' s props and returning an
* action creator .
*
* @ example
* ` ` ` jsx
* function Button ( { onClick , children } ) {
* return < button type = "button" onClick = { onClick } > { children } < / b u t t o n > ;
* }
*
* import { withDispatch } from '@wordpress/data' ;
*
* const SaleButton = withDispatch ( ( dispatch , ownProps ) => {
* const { startSale } = dispatch ( 'my-shop' ) ;
* const { discountPercent } = ownProps ;
*
* return {
* onClick ( ) {
* startSale ( discountPercent ) ;
* } ,
* } ;
* } ) ( Button ) ;
*
* // Rendered in the application:
* //
* // <SaleButton discountPercent="20">Start Sale!</SaleButton>
* ` ` `
*
* @ example
* In the majority of cases , it will be sufficient to use only two first params
* passed to ` mapDispatchToProps ` as illustrated in the previous example .
* However , there might be some very advanced use cases where using the
* ` registry ` object might be used as a tool to optimize the performance of
* your component . Using ` select ` function from the registry might be useful
* when you need to fetch some dynamic data from the store at the time when the
* event is fired , but at the same time , you never use it to render your
* component . In such scenario , you can avoid using the ` withSelect ` higher
* order component to compute such prop , which might lead to unnecessary
* re - renders of your component caused by its frequent value change .
* Keep in mind , that ` mapDispatchToProps ` must return an object with functions
* only .
2021-05-19 11:09:27 -04:00
*
2021-05-20 08:20:04 -04:00
* ` ` ` jsx
* function Button ( { onClick , children } ) {
* return < button type = "button" onClick = { onClick } > { children } < / b u t t o n > ;
* }
2021-05-19 11:09:27 -04:00
*
2021-05-20 08:20:04 -04:00
* import { withDispatch } from '@wordpress/data' ;
*
* const SaleButton = withDispatch ( ( dispatch , ownProps , { select } ) => {
* // Stock number changes frequently.
* const { getStockNumber } = select ( 'my-shop' ) ;
* const { startSale } = dispatch ( 'my-shop' ) ;
* return {
* onClick ( ) {
* const discountPercent = getStockNumber ( ) > 50 ? 10 : 20 ;
* startSale ( discountPercent ) ;
* } ,
* } ;
* } ) ( Button ) ;
*
* // Rendered in the application:
* //
* // <SaleButton>Start Sale!</SaleButton>
* ` ` `
*
* _Note : _ It is important that the ` mapDispatchToProps ` function always
* returns an object with the same keys . For example , it should not contain
* conditions under which a different value would be returned .
*
* @ return { WPComponent } Enhanced component with merged dispatcher props .
2021-05-19 11:09:27 -04:00
* /
2022-04-11 08:04:30 -04:00
const withDispatch = mapDispatchToProps => ( 0 , external _wp _compose _namespaceObject . createHigherOrderComponent ) ( WrappedComponent => ownProps => {
2021-05-20 08:20:04 -04:00
const mapDispatch = ( dispatch , registry ) => mapDispatchToProps ( dispatch , ownProps , registry ) ;
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
const dispatchProps = use _dispatch _with _map ( mapDispatch , [ ] ) ;
2022-04-11 08:04:30 -04:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( WrappedComponent , _extends ( { } , ownProps , dispatchProps ) ) ;
2021-05-20 08:20:04 -04:00
} , 'withDispatch' ) ;
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var with _dispatch = ( withDispatch ) ;
2021-05-19 11:09:27 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Higher - order component which renders the original component with the current
* registry context passed as its ` registry ` prop .
*
* @ param { WPComponent } OriginalComponent Original component .
*
* @ return { WPComponent } Enhanced component .
* /
2021-05-19 11:09:27 -04:00
2022-04-11 08:04:30 -04:00
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 , {
2021-05-20 08:20:04 -04:00
registry : registry
} ) ) ) , 'withRegistry' ) ;
/* harmony default export */ var with _registry = ( withRegistry ) ;
2021-05-19 11:09:27 -04:00
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2021-05-19 11:09:27 -04:00
2022-04-12 11:12:47 -04:00
/** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* A custom react hook returning the current registry dispatch actions creators .
*
* Note : The component using this hook must be within the context of a
* RegistryProvider .
*
2022-04-12 11:12:47 -04:00
* @ 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 .
2021-05-20 08:20:04 -04:00
*
* @ example
* This illustrates a pattern where you may need to retrieve dynamic data from
* the server via the ` useSelect ` hook to use in combination with the dispatch
* action .
*
* ` ` ` jsx
* import { useDispatch , useSelect } from '@wordpress/data' ;
* import { useCallback } from '@wordpress/element' ;
*
* function Button ( { onClick , children } ) {
* return < button type = "button" onClick = { onClick } > { children } < / b u t t o n >
* }
*
* const SaleButton = ( { children } ) => {
* const { stockNumber } = useSelect (
* ( select ) => select ( 'my-shop' ) . getStockNumber ( ) ,
* [ ]
* ) ;
* const { startSale } = useDispatch ( 'my-shop' ) ;
* const onClick = useCallback ( ( ) => {
* const discountPercent = stockNumber > 50 ? 10 : 20 ;
* startSale ( discountPercent ) ;
* } , [ stockNumber ] ) ;
* return < Button onClick = { onClick } > { children } < / B u t t o n >
* }
*
* // Rendered somewhere in the application:
* //
* // <SaleButton>Start Sale!</SaleButton>
* ` ` `
* @ return { Function } A custom react hook .
* /
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
const useDispatch = storeNameOrDescriptor => {
2021-05-20 08:20:04 -04:00
const {
dispatch
} = useRegistry ( ) ;
2022-04-12 11:12:47 -04:00
return storeNameOrDescriptor === void 0 ? dispatch : dispatch ( storeNameOrDescriptor ) ;
2021-05-20 08:20:04 -04:00
} ;
/* harmony default export */ var use _dispatch = ( useDispatch ) ;
2022-04-11 08:04:30 -04:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js
2021-02-02 00:17:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* External dependencies
2021-02-02 00:17:13 -05:00
* /
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2021-01-27 21:04:13 -05:00
2022-04-12 11:12:47 -04:00
/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
2021-01-27 21:04:13 -05:00
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Object of available plugins to use with a registry .
*
* @ see [ use ] ( # use )
*
* @ type { Object }
* /
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* The combineReducers helper function turns an object whose values are different
* reducing functions into a single reducing function you can pass to registerReducer .
*
* @ param { Object } reducers An object whose values correspond to different reducing
* functions that need to be combined into one .
*
* @ example
* ` ` ` js
* import { combineReducers , createReduxStore , register } from '@wordpress/data' ;
*
* const prices = ( state = { } , action ) => {
* return action . type === 'SET_PRICE' ?
* {
* ... state ,
* [ action . item ] : action . price ,
* } :
* state ;
* } ;
*
* const discountPercent = ( state = 0 , action ) => {
* return action . type === 'START_SALE' ?
* action . discountPercent :
* state ;
* } ;
*
* const store = createReduxStore ( 'my-shop' , {
* reducer : combineReducers ( {
* prices ,
* discountPercent ,
* } ) ,
* } ) ;
* register ( store ) ;
* ` ` `
*
2021-11-08 09:29:21 -05:00
* @ return { Function } A reducer that invokes every reducer inside the reducers
* object , and constructs a state object with the same shape .
2021-05-20 08:20:04 -04:00
* /
2021-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
2022-04-12 11:12:47 -04:00
* Given the name or descriptor of a registered store , returns an object of the store ' s selectors .
2021-05-20 08:20:04 -04:00
* 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 .
*
2022-04-12 11:12:47 -04:00
* @ param { string | StoreDescriptor } storeNameOrDescriptor Unique namespace identifier for the store
* or the store descriptor .
2021-05-20 08:20:04 -04:00
*
* @ example
* ` ` ` js
* import { select } from '@wordpress/data' ;
*
* select ( 'my-shop' ) . getPrice ( 'hammer' ) ;
* ` ` `
*
* @ return { Object } Object containing the store ' s selectors .
* /
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
const build _module _select = default _registry . select ;
/ * *
* Given the name of a registered store , returns an object containing the store ' s
* selectors pre - bound to state so that you only need to supply additional arguments ,
* and modified so that they return promises that resolve to their eventual values ,
* after any resolvers have ran .
*
2022-04-12 11:12:47 -04:00
* @ param { string | StoreDescriptor } storeNameOrDescriptor Unique namespace identifier for the store
* or the store descriptor .
2021-05-20 08:20:04 -04:00
*
* @ example
* ` ` ` js
* import { resolveSelect } from '@wordpress/data' ;
*
* resolveSelect ( 'my-shop' ) . getPrice ( 'hammer' ) . then ( console . log )
* ` ` `
*
* @ return { Object } Object containing the store ' s promise - wrapped selectors .
* /
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
const build _module _resolveSelect = default _registry . resolveSelect ;
/ * *
* Given the name of a registered store , returns an object of the store ' s action creators .
* Calling an action creator will cause it to be dispatched , updating the state value accordingly .
*
* Note : Action creators returned by the dispatch will return a promise when
* they are called .
*
2022-04-12 11:12:47 -04:00
* @ param { string | StoreDescriptor } storeNameOrDescriptor Unique namespace identifier for the store
* or the store descriptor .
2021-05-20 08:20:04 -04:00
*
* @ example
* ` ` ` js
* import { dispatch } from '@wordpress/data' ;
*
* dispatch ( 'my-shop' ) . setPrice ( 'hammer' , 9.75 ) ;
* ` ` `
* @ return { Object } Object containing the action creators .
* /
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
const build _module _dispatch = default _registry . dispatch ;
/ * *
* Given a listener function , the function will be called any time the state value
* of one of the registered stores has changed . This function returns a ` unsubscribe `
* function used to stop the subscription .
*
* @ param { Function } listener Callback function .
*
* @ example
* ` ` ` js
* import { subscribe } from '@wordpress/data' ;
*
* const unsubscribe = subscribe ( ( ) => {
* // You could use this opportunity to test whether the derived result of a
* // selector has subsequently changed as the result of a state update.
* } ) ;
*
* // Later, if necessary...
* unsubscribe ( ) ;
* ` ` `
* /
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
const subscribe = default _registry . subscribe ;
2021-05-20 08:20:04 -04:00
/ * *
2022-04-12 11:12:47 -04:00
* Registers a generic store instance .
2021-05-20 08:20:04 -04:00
*
2022-04-12 11:12:47 -04:00
* @ deprecated Use ` register( storeDescriptor ) ` instead .
2021-05-20 08:20:04 -04:00
*
2022-04-12 11:12:47 -04:00
* @ param { string } name Store registry name .
* @ param { Object } store Store instance ( ` { getSelectors, getActions, subscribe } ` ) .
2021-05-20 08:20:04 -04:00
* /
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
const registerGenericStore = default _registry . registerGenericStore ;
2021-05-20 08:20:04 -04:00
/ * *
* Registers a standard ` @wordpress/data ` store .
*
* @ deprecated Use ` register ` instead .
*
* @ param { string } storeName Unique namespace identifier for the store .
* @ param { Object } options Store description ( reducer , actions , selectors , resolvers ) .
*
* @ return { Object } Registered store object .
* /
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
const registerStore = default _registry . registerStore ;
/ * *
* Extends a registry to inherit functionality provided by a given plugin . A
* plugin is an object with properties aligning to that of a registry , merged
* to extend the default registry behavior .
*
* @ param { Object } plugin Plugin object .
* /
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
const use = default _registry . use ;
2021-05-20 08:20:04 -04:00
/ * *
2022-04-12 11:12:47 -04:00
* Registers a standard ` @wordpress/data ` store descriptor .
2021-05-20 08:20:04 -04:00
*
* @ example
* ` ` ` js
* import { createReduxStore , register } from '@wordpress/data' ;
*
* const store = createReduxStore ( 'demo' , {
* reducer : ( state = 'OK' ) => state ,
* selectors : {
* getValue : ( state ) => state ,
* } ,
* } ) ;
* register ( store ) ;
* ` ` `
*
2022-04-12 11:12:47 -04:00
* @ param { StoreDescriptor } store Store descriptor .
2021-05-20 08:20:04 -04:00
* /
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
const register = default _registry . register ;
2021-01-27 21:04:13 -05:00
2022-04-11 08:04:30 -04:00
} ( ) ;
( window . wp = window . wp || { } ) . data = _ _webpack _exports _ _ ;
/******/ } ) ( )
;