: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Copy the enumerable properties of the resolver function.
fulfill: resolver // Add the fulfill method.
* Returns a selector with a matched resolver.
* 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} selector The selector function to be bound.
* @param {string} selectorName The selector name.
* @param {Object} resolver Resolver to call.
* @param {Object} store The redux store to which the resolvers should be mapped.
* @param {Object} resolversCache Resolvers Cache.
function mapSelectorWithResolver(selector, selectorName, resolver, store, resolversCache) {
function fulfillSelector(args) {
const state = store.getState();
if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) {
} = store.__unstableOriginalGetState();
if (hasStartedResolution(metadata, selectorName, args)) {
resolversCache.markAsRunning(selectorName, args);
resolversCache.clear(selectorName, args);
store.dispatch(startResolution(selectorName, args));
const action = resolver.fulfill(...args);
await store.dispatch(action);
store.dispatch(finishResolution(selectorName, args));
store.dispatch(failResolution(selectorName, args, error));
const selectorResolver = (...args) => {
args = normalize(selector, args);
return selector(...args);
selectorResolver.hasResolver = true;
* Applies selector's normalization function to the given arguments
* @param {Object} selector The selector potentially with a normalization method property.
* @param {Array} args selector arguments to normalize.
* @return {Array} Potentially normalized arguments.
function normalize(selector, args) {
if (selector.__unstableNormalizeArgs && typeof selector.__unstableNormalizeArgs === 'function' && args?.length) {
return selector.__unstableNormalizeArgs(args);
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js
const getCoreDataSelector = selectorName => (key, ...args) => {
return registry.select(key)[selectorName](...args);
const getCoreDataAction = actionName => (key, ...args) => {
return registry.dispatch(key)[actionName](...args);
return Object.fromEntries(['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].map(selectorName => [selectorName, getCoreDataSelector(selectorName)]));
return Object.fromEntries(['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].map(actionName => [actionName, getCoreDataAction(actionName)]));
// 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.
/* harmony default export */ const store = (coreDataStore);
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/utils/emitter.js
* Create an event emitter.
* @return {import("../types").DataEmitter} Emitter.
function createEmitter() {
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 () => listeners.delete(listener);
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js
/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
* @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.
* @property {Function} registerGenericStore Given a namespace key and settings
* object, registers a new generic
* @property {Function} registerStore Given a namespace key and settings
* object, registers a new namespace
* @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
* @property {Function} dispatch Given a namespace key, returns an
* object of the store's registered
* @typedef {Object} WPDataPlugin An object of registry function overrides.
* @property {Function} registerStore registers store.
function getStoreName(storeNameOrDescriptor) {
return typeof storeNameOrDescriptor === 'string' ? storeNameOrDescriptor : storeNameOrDescriptor.name;
* Creates a new store registry, given an optional object of initial store
* @param {Object} storeConfigs Initial store configurations.
* @param {Object?} parent Parent registry.
* @return {WPDataRegistry} Data registry.
function createRegistry(storeConfigs = {}, parent = null) {
const emitter = createEmitter();
let listeningStores = null;
* Global listener called for each store's update.
function globalListener() {
* Subscribe to changes to any data, either in all stores in registry, or
* @param {Function} listener Listener function.
* @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.
* @return {Function} Unsubscribe function.
const subscribe = (listener, storeNameOrDescriptor) => {
// subscribe to all stores
if (!storeNameOrDescriptor) {
return emitter.subscribe(listener);
// subscribe to one store
const storeName = getStoreName(storeNameOrDescriptor);
const store = stores[storeName];
return store.subscribe(listener);
// Trying to access a store that hasn't been registered,
// this is a pattern rarely used but seen in some places.
// We fallback to global `subscribe` here for backward-compatibility for now.
// See https://github.com/WordPress/gutenberg/pull/27466 for more info.
return emitter.subscribe(listener);
return parent.subscribe(listener, storeNameOrDescriptor);
* Calls a selector given the current state and extra arguments.
* @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
* or the store descriptor.
* @return {*} The selector's returned value.
function select(storeNameOrDescriptor) {
const storeName = getStoreName(storeNameOrDescriptor);
listeningStores?.add(storeName);
const store = stores[storeName];
return store.getSelectors();
return parent?.select(storeName);
function __unstableMarkListeningStores(callback, ref) {
listeningStores = new Set();
return callback.call(this);
ref.current = Array.from(listeningStores);
* Given a store descriptor, 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.
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
* convention of passing the store name is
* @return {Object} Each key of the object matches the name of a selector.
function resolveSelect(storeNameOrDescriptor) {
const storeName = getStoreName(storeNameOrDescriptor);
listeningStores?.add(storeName);
const store = stores[storeName];
return store.getResolveSelectors();
return parent && parent.resolveSelect(storeName);
* Given a store descriptor, 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 throw
* promises in case the selector is not resolved yet.
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
* convention of passing the store name is
* @return {Object} Object containing the store's suspense-wrapped selectors.
function suspendSelect(storeNameOrDescriptor) {
const storeName = getStoreName(storeNameOrDescriptor);
listeningStores?.add(storeName);
const store = stores[storeName];
return store.getSuspendSelectors();
return parent && parent.suspendSelect(storeName);
* Returns the available actions for a part of the state.
* @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
* or the store descriptor.
* @return {*} The action's returned value.
function dispatch(storeNameOrDescriptor) {
const storeName = getStoreName(storeNameOrDescriptor);
const store = stores[storeName];
return store.getActions();
return parent && parent.dispatch(storeName);
// TODO: Remove this after `use()` is removed.
function withPlugins(attributes) {
return Object.fromEntries(Object.entries(attributes).map(([key, attribute]) => {
if (typeof attribute !== 'function') {
return [key, function () {
return registry[key].apply(null, arguments);
* Registers a store instance.
* @param {string} name Store registry name.
* @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe).
function registerStoreInstance(name, createStore) {
// eslint-disable-next-line no-console
console.error('Store "' + name + '" is already registered.');
const store = createStore();
if (typeof store.getSelectors !== 'function') {
throw new TypeError('store.getSelectors must be a function');
if (typeof store.getActions !== 'function') {
throw new TypeError('store.getActions must be a function');
if (typeof store.subscribe !== 'function') {
throw new TypeError('store.subscribe must be a function');
// The emitter is used to keep track of active listeners when the registry
// get paused, that way, when resumed we should be able to call all these
store.emitter = createEmitter();
const currentSubscribe = store.subscribe;
store.subscribe = listener => {
const unsubscribeFromEmitter = store.emitter.subscribe(listener);
const unsubscribeFromStore = currentSubscribe(() => {
if (store.emitter.isPaused) {
unsubscribeFromStore?.();
unsubscribeFromEmitter?.();
store.subscribe(globalListener);
// Copy private actions and selectors from the parent store.
unlock(store.store).registerPrivateActions(unlock(parent).privateActionsOf(name));
unlock(store.store).registerPrivateSelectors(unlock(parent).privateSelectorsOf(name));
// unlock() throws if store.store was not locked.
// The error indicates there's nothing to do here so let's
* Registers a new store given a store descriptor.
* @param {StoreDescriptor} store Store descriptor.
function register(store) {
registerStoreInstance(store.name, () => store.instantiate(registry));
function registerGenericStore(name, store) {
external_wp_deprecated_default()('wp.data.registerGenericStore', {
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) {
throw new TypeError('Must specify store reducer');
const store = registerStoreInstance(storeName, () => createReduxStore(storeName, options).instantiate(registry));
function batch(callback) {
// If we're already batching, just call the callback.
Object.values(stores).forEach(store => store.emitter.pause());
Object.values(stores).forEach(store => store.emitter.resume());
// TODO: Deprecate/remove this.
__unstableMarkListeningStores
// This function will be deprecated as soon as it is no longer internally referenced.
function use(plugin, options) {
...plugin(registry, options)
registry.register(store);
for (const [name, config] of Object.entries(storeConfigs)) {
registry.register(createReduxStore(name, config));
parent.subscribe(globalListener);
const registryWithPlugins = withPlugins(registry);
lock(registryWithPlugins, {
privateActionsOf: name => {
return unlock(stores[name].store).privateActions;
// unlock() throws an error the store was not locked – this means
// there no private actions are available
privateSelectorsOf: name => {
return unlock(stores[name].store).privateSelectors;
return registryWithPlugins;