: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Returns a memoized selector function. The getDependants function argument is
* called before the memoized selector and is expected to return an immutable
* reference or array of references on which the selector depends for computing
* its own return value. The memoize cache is preserved only as long as those
* dependant references remain the same. If getDependants returns a different
* reference(s), the cache is cleared and the selector value regenerated.
* @template {(...args: *[]) => *} S
* @param {S} selector Selector function.
* @param {GetDependants=} getDependants Dependant getter returning an array of
* references used in cache bust consideration.
/* harmony default export */ function rememo(selector, getDependants) {
/** @type {WeakMap<*,*>} */
/** @type {GetDependants} */
var normalizedGetDependants = getDependants ? getDependants : arrayOf;
* Returns the cache for a given dependants array. When possible, a WeakMap
* will be used to create a unique cache for each set of dependants. This
* is feasible due to the nature of WeakMap in allowing garbage collection
* to occur on entries where the key object is no longer referenced. Since
* WeakMap requires the key to be an object, this is only possible when the
* dependant is object-like. The root cache is created as a hierarchy where
* each top-level key is the first entry in a dependants set, the value a
* WeakMap where each key is the next dependant, and so on. This continues
* so long as the dependants are object-like. If no dependants are object-
* like, then the cache is shared across all invocations.
* @param {*[]} dependants Selector dependants.
* @return {Cache} Cache object.
function getCache(dependants) {
isUniqueByDependants = true,
for (i = 0; i < dependants.length; i++) {
dependant = dependants[i];
// Can only compose WeakMap from object-like key.
if (!isObjectLike(dependant)) {
isUniqueByDependants = false;
// Does current segment of cache already have a WeakMap?
if (caches.has(dependant)) {
// Traverse into nested WeakMap.
caches = caches.get(dependant);
// Create, set, and traverse into a new one.
caches.set(dependant, map);
// We use an arbitrary (but consistent) object as key for the last item
// in the WeakMap to serve as our running cache.
if (!caches.has(LEAF_KEY)) {
cache.isUniqueByDependants = isUniqueByDependants;
caches.set(LEAF_KEY, cache);
return caches.get(LEAF_KEY);
* Resets root memoization cache.
rootCache = new WeakMap();
/* eslint-disable jsdoc/check-param-names */
* The augmented selector call, considering first whether dependants have
* changed before passing it to underlying memoize function.
* @param {*} source Source object for derivation.
* @param {...*} extraArgs Additional arguments to pass to selector.
* @return {*} Selector result.
/* eslint-enable jsdoc/check-param-names */
function callSelector(/* source, ...extraArgs */) {
var len = arguments.length,
// Create copy of arguments (avoid leaking deoptimization).
for (i = 0; i < len; i++) {
dependants = normalizedGetDependants.apply(null, args);
cache = getCache(dependants);
// If not guaranteed uniqueness by dependants (primitive type), shallow
// compare against last dependants and, if references have changed,
// destroy cache to recalculate result.
if (!cache.isUniqueByDependants) {
!isShallowEqual(dependants, cache.lastDependants, 0)
cache.lastDependants = dependants;
// Check whether node arguments match arguments
if (!isShallowEqual(node.args, args, 1)) {
// At this point we can assume we've found a match
// Surface matched node to head if not already
if (node !== cache.head) {
// Adjust siblings to point to each other.
/** @type {CacheNode} */ (node.prev).next = node.next;
node.next.prev = node.prev;
/** @type {CacheNode} */ (cache.head).prev = node;
// No cached value found. Continue to insertion phase:
node = /** @type {CacheNode} */ ({
// Generate the result from original function
val: selector.apply(null, args),
// Avoid including the source object in the cache.
// Don't need to check whether node is already head, since it would
// have been returned above already if it was
// Shift existing head down list
callSelector.getDependants = normalizedGetDependants;
callSelector.clear = clear;
return /** @type {S & EnhancedSelector} */ (callSelector);
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js
/** @typedef {Record<string, import('./reducer').State>} State */
/** @typedef {import('./reducer').StateValue} StateValue */
/** @typedef {import('./reducer').Status} Status */
* Returns the raw resolution state value for a given selector name,
* and arguments set. May be undefined if the selector has never been resolved
* or not resolved for the given set of arguments, otherwise true or false for
* resolution started and completed respectively.
* @param {State} state Data state.
* @param {string} selectorName Selector name.
* @param {unknown[]?} args Arguments passed to selector.
* @return {StateValue|undefined} isResolving value.
function getResolutionState(state, selectorName, args) {
const map = state[selectorName];
return map.get(selectorArgsToStateKey(args));
* Returns an `isResolving`-like value for a given selector name and arguments set.
* Its value is either `undefined` if the selector has never been resolved or has been
* invalidated, or a `true`/`false` boolean value if the resolution is in progress or
* has finished, respectively.
* This is a legacy selector that was implemented when the "raw" internal data had
* this `undefined | boolean` format. Nowadays the internal value is an object that
* can be retrieved with `getResolutionState`.
* @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) {
external_wp_deprecated_default()('wp.data.select( store ).getIsResolving', {
alternative: 'wp.data.select( store ).getResolutionState'
const resolutionState = getResolutionState(state, selectorName, args);
return resolutionState && resolutionState.status === 'resolving';
* Returns true if resolution has already been triggered for a given
* selector name, and arguments set.
* @param {State} state Data state.
* @param {string} selectorName Selector name.
* @param {unknown[]?} args Arguments passed to selector.
* @return {boolean} Whether resolution has been triggered.
function hasStartedResolution(state, selectorName, args) {
return getResolutionState(state, selectorName, args) !== undefined;
* Returns true if resolution has completed 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} Whether resolution has completed.
function hasFinishedResolution(state, selectorName, args) {
const status = getResolutionState(state, selectorName, args)?.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) {
return getResolutionState(state, selectorName, args)?.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
* @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?.status === 'error' ? resolutionState.error : null;
* Returns true if resolution has been triggered but has not yet completed for
* a given selector name, and arguments set.
* @param {State} state Data state.
* @param {string} selectorName Selector name.
* @param {unknown[]?} args Arguments passed to selector.
* @return {boolean} Whether resolution is in progress.
function isResolving(state, selectorName, args) {
return getResolutionState(state, selectorName, args)?.status === 'resolving';
* Returns the list of the cached resolvers.
* @param {State} state Data state.
* @return {State} Resolvers mapped by args and selectorName.
function getCachedResolvers(state) {
* Whether the store has any currently resolving selectors.
* @param {State} state Data state.
* @return {boolean} True if one or more selectors are resolving, false otherwise.
function hasResolvingSelectors(state) {
return Object.values(state).some(selectorState =>
* This uses the internal `_map` property of `EquivalentKeyMap` for
* optimization purposes, since the `EquivalentKeyMap` implementation
* does not support a `.values()` implementation.
* @see https://github.com/aduth/equivalent-key-map
Array.from(selectorState._map.values()).some(resolution => resolution[1]?.status === 'resolving'));
* Retrieves the total number of selectors, grouped per status.
* @param {State} state Data state.
* @return {Object} Object, containing selector totals by status.
const countSelectorsByStatus = rememo(state => {
const selectorsByStatus = {};
Object.values(state).forEach(selectorState =>
* This uses the internal `_map` property of `EquivalentKeyMap` for
* optimization purposes, since the `EquivalentKeyMap` implementation
* does not support a `.values()` implementation.
* @see https://github.com/aduth/equivalent-key-map
Array.from(selectorState._map.values()).forEach(resolution => {
var _resolution$1$status;
const currentStatus = (_resolution$1$status = resolution[1]?.status) !== null && _resolution$1$status !== void 0 ? _resolution$1$status : 'error';
if (!selectorsByStatus[currentStatus]) {
selectorsByStatus[currentStatus] = 0;
selectorsByStatus[currentStatus]++;
return selectorsByStatus;
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js
* Returns an action object used in signalling that selector resolution has
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[]} args Arguments to associate for uniqueness.
* @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
function startResolution(selectorName, args) {
type: 'START_RESOLUTION',
* Returns an action object used in signalling that selector resolution has
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[]} args Arguments to associate for uniqueness.
* @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
function finishResolution(selectorName, args) {
type: 'FINISH_RESOLUTION',
* Returns an action object used in signalling that selector resolution has
* @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) {
* Returns an action object used in signalling that a batch of selector resolutions has
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
* is associated to a resolution.
* @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
function startResolutions(selectorName, args) {
type: 'START_RESOLUTIONS',
* Returns an action object used in signalling that a batch of selector resolutions has
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
* is associated to a resolution.
* @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
function finishResolutions(selectorName, args) {
type: 'FINISH_RESOLUTIONS',
* 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) {
type: 'FAIL_RESOLUTIONS',
* Returns an action object used in signalling that we should invalidate the resolution cache.
* @param {string} selectorName Name of selector for which resolver should be invalidated.
* @param {unknown[]} args Arguments to associate for uniqueness.
* @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object.