1487 lines
47 KiB
JavaScript
1487 lines
47 KiB
JavaScript
(self["webpackChunk_woocommerce_storybook"] = self["webpackChunk_woocommerce_storybook"] || []).push([[4781],{
|
|
|
|
/***/ "../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/index.js":
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
U2: () => (/* binding */ addFilter),
|
|
W5: () => (/* binding */ applyFilters),
|
|
se: () => (/* binding */ defaultHooks),
|
|
Eo: () => (/* binding */ doAction)
|
|
});
|
|
|
|
// UNUSED EXPORTS: actions, addAction, createHooks, currentAction, currentFilter, didAction, didFilter, doingAction, doingFilter, filters, hasAction, hasFilter, removeAction, removeAllActions, removeAllFilters, removeFilter
|
|
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/validateNamespace.js
|
|
/**
|
|
* Validate a namespace string.
|
|
*
|
|
* @param {string} namespace The namespace to validate - should take the form
|
|
* `vendor/plugin/function`.
|
|
*
|
|
* @return {boolean} Whether the namespace is valid.
|
|
*/
|
|
function validateNamespace(namespace) {
|
|
if ('string' !== typeof namespace || '' === namespace) {
|
|
// eslint-disable-next-line no-console
|
|
console.error('The namespace must be a non-empty string.');
|
|
return false;
|
|
}
|
|
|
|
if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
|
|
// eslint-disable-next-line no-console
|
|
console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/* harmony default export */ const build_module_validateNamespace = (validateNamespace);
|
|
//# sourceMappingURL=validateNamespace.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/validateHookName.js
|
|
/**
|
|
* Validate a hookName string.
|
|
*
|
|
* @param {string} hookName The hook name to validate. Should be a non empty string containing
|
|
* only numbers, letters, dashes, periods and underscores. Also,
|
|
* the hook name cannot begin with `__`.
|
|
*
|
|
* @return {boolean} Whether the hook name is valid.
|
|
*/
|
|
function validateHookName(hookName) {
|
|
if ('string' !== typeof hookName || '' === hookName) {
|
|
// eslint-disable-next-line no-console
|
|
console.error('The hook name must be a non-empty string.');
|
|
return false;
|
|
}
|
|
|
|
if (/^__/.test(hookName)) {
|
|
// eslint-disable-next-line no-console
|
|
console.error('The hook name cannot begin with `__`.');
|
|
return false;
|
|
}
|
|
|
|
if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
|
|
// eslint-disable-next-line no-console
|
|
console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/* harmony default export */ const build_module_validateHookName = (validateHookName);
|
|
//# sourceMappingURL=validateHookName.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/createAddHook.js
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
|
|
/**
|
|
* @callback AddHook
|
|
*
|
|
* Adds the hook to the appropriate hooks container.
|
|
*
|
|
* @param {string} hookName Name of hook to add
|
|
* @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.
|
|
* @param {import('.').Callback} callback Function to call when the hook is run
|
|
* @param {number} [priority=10] Priority of this hook
|
|
*/
|
|
|
|
/**
|
|
* Returns a function which, when invoked, will add a hook.
|
|
*
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
* @param {import('.').StoreKey} storeKey
|
|
*
|
|
* @return {AddHook} Function that adds a new hook.
|
|
*/
|
|
|
|
function createAddHook(hooks, storeKey) {
|
|
return function addHook(hookName, namespace, callback) {
|
|
let priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
|
|
const hooksStore = hooks[storeKey];
|
|
|
|
if (!build_module_validateHookName(hookName)) {
|
|
return;
|
|
}
|
|
|
|
if (!build_module_validateNamespace(namespace)) {
|
|
return;
|
|
}
|
|
|
|
if ('function' !== typeof callback) {
|
|
// eslint-disable-next-line no-console
|
|
console.error('The hook callback must be a function.');
|
|
return;
|
|
} // Validate numeric priority
|
|
|
|
|
|
if ('number' !== typeof priority) {
|
|
// eslint-disable-next-line no-console
|
|
console.error('If specified, the hook priority must be a number.');
|
|
return;
|
|
}
|
|
|
|
const handler = {
|
|
callback,
|
|
priority,
|
|
namespace
|
|
};
|
|
|
|
if (hooksStore[hookName]) {
|
|
// Find the correct insert index of the new hook.
|
|
const handlers = hooksStore[hookName].handlers;
|
|
/** @type {number} */
|
|
|
|
let i;
|
|
|
|
for (i = handlers.length; i > 0; i--) {
|
|
if (priority >= handlers[i - 1].priority) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (i === handlers.length) {
|
|
// If append, operate via direct assignment.
|
|
handlers[i] = handler;
|
|
} else {
|
|
// Otherwise, insert before index via splice.
|
|
handlers.splice(i, 0, handler);
|
|
} // We may also be currently executing this hook. If the callback
|
|
// we're adding would come after the current callback, there's no
|
|
// problem; otherwise we need to increase the execution index of
|
|
// any other runs by 1 to account for the added element.
|
|
|
|
|
|
hooksStore.__current.forEach(hookInfo => {
|
|
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
|
hookInfo.currentIndex++;
|
|
}
|
|
});
|
|
} else {
|
|
// This is the first hook of its type.
|
|
hooksStore[hookName] = {
|
|
handlers: [handler],
|
|
runs: 0
|
|
};
|
|
}
|
|
|
|
if (hookName !== 'hookAdded') {
|
|
hooks.doAction('hookAdded', hookName, namespace, callback, priority);
|
|
}
|
|
};
|
|
}
|
|
|
|
/* harmony default export */ const build_module_createAddHook = (createAddHook);
|
|
//# sourceMappingURL=createAddHook.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/createRemoveHook.js
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
|
|
/**
|
|
* @callback RemoveHook
|
|
* Removes the specified callback (or all callbacks) from the hook with a given hookName
|
|
* and namespace.
|
|
*
|
|
* @param {string} hookName The name of the hook to modify.
|
|
* @param {string} namespace The unique namespace identifying the callback in the
|
|
* form `vendor/plugin/function`.
|
|
*
|
|
* @return {number | undefined} The number of callbacks removed.
|
|
*/
|
|
|
|
/**
|
|
* Returns a function which, when invoked, will remove a specified hook or all
|
|
* hooks by the given name.
|
|
*
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
* @param {import('.').StoreKey} storeKey
|
|
* @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName,
|
|
* without regard to namespace. Used to create
|
|
* `removeAll*` functions.
|
|
*
|
|
* @return {RemoveHook} Function that removes hooks.
|
|
*/
|
|
|
|
function createRemoveHook(hooks, storeKey) {
|
|
let removeAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
return function removeHook(hookName, namespace) {
|
|
const hooksStore = hooks[storeKey];
|
|
|
|
if (!build_module_validateHookName(hookName)) {
|
|
return;
|
|
}
|
|
|
|
if (!removeAll && !build_module_validateNamespace(namespace)) {
|
|
return;
|
|
} // Bail if no hooks exist by this name.
|
|
|
|
|
|
if (!hooksStore[hookName]) {
|
|
return 0;
|
|
}
|
|
|
|
let handlersRemoved = 0;
|
|
|
|
if (removeAll) {
|
|
handlersRemoved = hooksStore[hookName].handlers.length;
|
|
hooksStore[hookName] = {
|
|
runs: hooksStore[hookName].runs,
|
|
handlers: []
|
|
};
|
|
} else {
|
|
// Try to find the specified callback to remove.
|
|
const handlers = hooksStore[hookName].handlers;
|
|
|
|
for (let i = handlers.length - 1; i >= 0; i--) {
|
|
if (handlers[i].namespace === namespace) {
|
|
handlers.splice(i, 1);
|
|
handlersRemoved++; // This callback may also be part of a hook that is
|
|
// currently executing. If the callback we're removing
|
|
// comes after the current callback, there's no problem;
|
|
// otherwise we need to decrease the execution index of any
|
|
// other runs by 1 to account for the removed element.
|
|
|
|
hooksStore.__current.forEach(hookInfo => {
|
|
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
|
hookInfo.currentIndex--;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
if (hookName !== 'hookRemoved') {
|
|
hooks.doAction('hookRemoved', hookName, namespace);
|
|
}
|
|
|
|
return handlersRemoved;
|
|
};
|
|
}
|
|
|
|
/* harmony default export */ const build_module_createRemoveHook = (createRemoveHook);
|
|
//# sourceMappingURL=createRemoveHook.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/createHasHook.js
|
|
/**
|
|
* @callback HasHook
|
|
*
|
|
* Returns whether any handlers are attached for the given hookName and optional namespace.
|
|
*
|
|
* @param {string} hookName The name of the hook to check for.
|
|
* @param {string} [namespace] Optional. The unique namespace identifying the callback
|
|
* in the form `vendor/plugin/function`.
|
|
*
|
|
* @return {boolean} Whether there are handlers that are attached to the given hook.
|
|
*/
|
|
|
|
/**
|
|
* Returns a function which, when invoked, will return whether any handlers are
|
|
* attached to a particular hook.
|
|
*
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
* @param {import('.').StoreKey} storeKey
|
|
*
|
|
* @return {HasHook} Function that returns whether any handlers are
|
|
* attached to a particular hook and optional namespace.
|
|
*/
|
|
function createHasHook(hooks, storeKey) {
|
|
return function hasHook(hookName, namespace) {
|
|
const hooksStore = hooks[storeKey]; // Use the namespace if provided.
|
|
|
|
if ('undefined' !== typeof namespace) {
|
|
return hookName in hooksStore && hooksStore[hookName].handlers.some(hook => hook.namespace === namespace);
|
|
}
|
|
|
|
return hookName in hooksStore;
|
|
};
|
|
}
|
|
|
|
/* harmony default export */ const build_module_createHasHook = (createHasHook);
|
|
//# sourceMappingURL=createHasHook.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/createRunHook.js
|
|
/**
|
|
* Returns a function which, when invoked, will execute all callbacks
|
|
* registered to a hook of the specified type, optionally returning the final
|
|
* value of the call chain.
|
|
*
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
* @param {import('.').StoreKey} storeKey
|
|
* @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to
|
|
* return its first argument.
|
|
*
|
|
* @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks.
|
|
*/
|
|
function createRunHook(hooks, storeKey) {
|
|
let returnFirstArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
return function runHooks(hookName) {
|
|
const hooksStore = hooks[storeKey];
|
|
|
|
if (!hooksStore[hookName]) {
|
|
hooksStore[hookName] = {
|
|
handlers: [],
|
|
runs: 0
|
|
};
|
|
}
|
|
|
|
hooksStore[hookName].runs++;
|
|
const handlers = hooksStore[hookName].handlers; // The following code is stripped from production builds.
|
|
|
|
if (false) {}
|
|
|
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
args[_key - 1] = arguments[_key];
|
|
}
|
|
|
|
if (!handlers || !handlers.length) {
|
|
return returnFirstArg ? args[0] : undefined;
|
|
}
|
|
|
|
const hookInfo = {
|
|
name: hookName,
|
|
currentIndex: 0
|
|
};
|
|
|
|
hooksStore.__current.push(hookInfo);
|
|
|
|
while (hookInfo.currentIndex < handlers.length) {
|
|
const handler = handlers[hookInfo.currentIndex];
|
|
const result = handler.callback.apply(null, args);
|
|
|
|
if (returnFirstArg) {
|
|
args[0] = result;
|
|
}
|
|
|
|
hookInfo.currentIndex++;
|
|
}
|
|
|
|
hooksStore.__current.pop();
|
|
|
|
if (returnFirstArg) {
|
|
return args[0];
|
|
}
|
|
};
|
|
}
|
|
|
|
/* harmony default export */ const build_module_createRunHook = (createRunHook);
|
|
//# sourceMappingURL=createRunHook.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/createCurrentHook.js
|
|
/**
|
|
* Returns a function which, when invoked, will return the name of the
|
|
* currently running hook, or `null` if no hook of the given type is currently
|
|
* running.
|
|
*
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
* @param {import('.').StoreKey} storeKey
|
|
*
|
|
* @return {() => string | null} Function that returns the current hook name or null.
|
|
*/
|
|
function createCurrentHook(hooks, storeKey) {
|
|
return function currentHook() {
|
|
var _hooksStore$__current, _hooksStore$__current2;
|
|
|
|
const hooksStore = hooks[storeKey];
|
|
return (_hooksStore$__current = (_hooksStore$__current2 = hooksStore.__current[hooksStore.__current.length - 1]) === null || _hooksStore$__current2 === void 0 ? void 0 : _hooksStore$__current2.name) !== null && _hooksStore$__current !== void 0 ? _hooksStore$__current : null;
|
|
};
|
|
}
|
|
|
|
/* harmony default export */ const build_module_createCurrentHook = (createCurrentHook);
|
|
//# sourceMappingURL=createCurrentHook.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/createDoingHook.js
|
|
/**
|
|
* @callback DoingHook
|
|
* Returns whether a hook is currently being executed.
|
|
*
|
|
* @param {string} [hookName] The name of the hook to check for. If
|
|
* omitted, will check for any hook being executed.
|
|
*
|
|
* @return {boolean} Whether the hook is being executed.
|
|
*/
|
|
|
|
/**
|
|
* Returns a function which, when invoked, will return whether a hook is
|
|
* currently being executed.
|
|
*
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
* @param {import('.').StoreKey} storeKey
|
|
*
|
|
* @return {DoingHook} Function that returns whether a hook is currently
|
|
* being executed.
|
|
*/
|
|
function createDoingHook(hooks, storeKey) {
|
|
return function doingHook(hookName) {
|
|
const hooksStore = hooks[storeKey]; // If the hookName was not passed, check for any current hook.
|
|
|
|
if ('undefined' === typeof hookName) {
|
|
return 'undefined' !== typeof hooksStore.__current[0];
|
|
} // Return the __current hook.
|
|
|
|
|
|
return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false;
|
|
};
|
|
}
|
|
|
|
/* harmony default export */ const build_module_createDoingHook = (createDoingHook);
|
|
//# sourceMappingURL=createDoingHook.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/createDidHook.js
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
/**
|
|
* @callback DidHook
|
|
*
|
|
* Returns the number of times an action has been fired.
|
|
*
|
|
* @param {string} hookName The hook name to check.
|
|
*
|
|
* @return {number | undefined} The number of times the hook has run.
|
|
*/
|
|
|
|
/**
|
|
* Returns a function which, when invoked, will return the number of times a
|
|
* hook has been called.
|
|
*
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
* @param {import('.').StoreKey} storeKey
|
|
*
|
|
* @return {DidHook} Function that returns a hook's call count.
|
|
*/
|
|
|
|
function createDidHook(hooks, storeKey) {
|
|
return function didHook(hookName) {
|
|
const hooksStore = hooks[storeKey];
|
|
|
|
if (!build_module_validateHookName(hookName)) {
|
|
return;
|
|
}
|
|
|
|
return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
|
|
};
|
|
}
|
|
|
|
/* harmony default export */ const build_module_createDidHook = (createDidHook);
|
|
//# sourceMappingURL=createDidHook.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/createHooks.js
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Internal class for constructing hooks. Use `createHooks()` function
|
|
*
|
|
* Note, it is necessary to expose this class to make its type public.
|
|
*
|
|
* @private
|
|
*/
|
|
|
|
class _Hooks {
|
|
constructor() {
|
|
/** @type {import('.').Store} actions */
|
|
this.actions = Object.create(null);
|
|
this.actions.__current = [];
|
|
/** @type {import('.').Store} filters */
|
|
|
|
this.filters = Object.create(null);
|
|
this.filters.__current = [];
|
|
this.addAction = build_module_createAddHook(this, 'actions');
|
|
this.addFilter = build_module_createAddHook(this, 'filters');
|
|
this.removeAction = build_module_createRemoveHook(this, 'actions');
|
|
this.removeFilter = build_module_createRemoveHook(this, 'filters');
|
|
this.hasAction = build_module_createHasHook(this, 'actions');
|
|
this.hasFilter = build_module_createHasHook(this, 'filters');
|
|
this.removeAllActions = build_module_createRemoveHook(this, 'actions', true);
|
|
this.removeAllFilters = build_module_createRemoveHook(this, 'filters', true);
|
|
this.doAction = build_module_createRunHook(this, 'actions');
|
|
this.applyFilters = build_module_createRunHook(this, 'filters', true);
|
|
this.currentAction = build_module_createCurrentHook(this, 'actions');
|
|
this.currentFilter = build_module_createCurrentHook(this, 'filters');
|
|
this.doingAction = build_module_createDoingHook(this, 'actions');
|
|
this.doingFilter = build_module_createDoingHook(this, 'filters');
|
|
this.didAction = build_module_createDidHook(this, 'actions');
|
|
this.didFilter = build_module_createDidHook(this, 'filters');
|
|
}
|
|
|
|
}
|
|
/** @typedef {_Hooks} Hooks */
|
|
|
|
/**
|
|
* Returns an instance of the hooks object.
|
|
*
|
|
* @return {Hooks} A Hooks instance.
|
|
*/
|
|
|
|
function createHooks() {
|
|
return new _Hooks();
|
|
}
|
|
|
|
/* harmony default export */ const build_module_createHooks = (createHooks);
|
|
//# sourceMappingURL=createHooks.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/index.js
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
/** @typedef {(...args: any[])=>any} Callback */
|
|
|
|
/**
|
|
* @typedef Handler
|
|
* @property {Callback} callback The callback
|
|
* @property {string} namespace The namespace
|
|
* @property {number} priority The namespace
|
|
*/
|
|
|
|
/**
|
|
* @typedef Hook
|
|
* @property {Handler[]} handlers Array of handlers
|
|
* @property {number} runs Run counter
|
|
*/
|
|
|
|
/**
|
|
* @typedef Current
|
|
* @property {string} name Hook name
|
|
* @property {number} currentIndex The index
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Record<string, Hook> & {__current: Current[]}} Store
|
|
*/
|
|
|
|
/**
|
|
* @typedef {'actions' | 'filters'} StoreKey
|
|
*/
|
|
|
|
/**
|
|
* @typedef {import('./createHooks').Hooks} Hooks
|
|
*/
|
|
|
|
const defaultHooks = build_module_createHooks();
|
|
const {
|
|
addAction,
|
|
addFilter,
|
|
removeAction,
|
|
removeFilter,
|
|
hasAction,
|
|
hasFilter,
|
|
removeAllActions,
|
|
removeAllFilters,
|
|
doAction,
|
|
applyFilters,
|
|
currentAction,
|
|
currentFilter,
|
|
doingAction,
|
|
doingFilter,
|
|
didAction,
|
|
didFilter,
|
|
actions,
|
|
filters
|
|
} = defaultHooks;
|
|
|
|
//# sourceMappingURL=index.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ "../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/index.js":
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
__: () => (/* reexport */ __),
|
|
_n: () => (/* reexport */ _n),
|
|
_x: () => (/* reexport */ _x),
|
|
V8: () => (/* reexport */ isRTL),
|
|
nv: () => (/* reexport */ sprintf_sprintf)
|
|
});
|
|
|
|
// UNUSED EXPORTS: _nx, createI18n, defaultI18n, getLocaleData, hasTranslation, resetLocaleData, setLocaleData, subscribe
|
|
|
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/memize@1.1.0/node_modules/memize/index.js
|
|
var memize = __webpack_require__("../../node_modules/.pnpm/memize@1.1.0/node_modules/memize/index.js");
|
|
var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
|
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/sprintf-js@1.1.3/node_modules/sprintf-js/src/sprintf.js
|
|
var sprintf = __webpack_require__("../../node_modules/.pnpm/sprintf-js@1.1.3/node_modules/sprintf-js/src/sprintf.js");
|
|
var sprintf_default = /*#__PURE__*/__webpack_require__.n(sprintf);
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/sprintf.js
|
|
/**
|
|
* External dependencies
|
|
*/
|
|
|
|
|
|
/**
|
|
* Log to console, once per message; or more precisely, per referentially equal
|
|
* argument set. Because Jed throws errors, we log these to the console instead
|
|
* to avoid crashing the application.
|
|
*
|
|
* @param {...*} args Arguments to pass to `console.error`
|
|
*/
|
|
|
|
const logErrorOnce = memize_default()(console.error); // eslint-disable-line no-console
|
|
|
|
/**
|
|
* Returns a formatted string. If an error occurs in applying the format, the
|
|
* original format string is returned.
|
|
*
|
|
* @param {string} format The format of the string to generate.
|
|
* @param {...*} args Arguments to apply to the format.
|
|
*
|
|
* @see https://www.npmjs.com/package/sprintf-js
|
|
*
|
|
* @return {string} The formatted string.
|
|
*/
|
|
|
|
function sprintf_sprintf(format) {
|
|
try {
|
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
args[_key - 1] = arguments[_key];
|
|
}
|
|
|
|
return sprintf_default().sprintf(format, ...args);
|
|
} catch (error) {
|
|
if (error instanceof Error) {
|
|
logErrorOnce('sprintf error: \n\n' + error.toString());
|
|
}
|
|
|
|
return format;
|
|
}
|
|
}
|
|
//# sourceMappingURL=sprintf.js.map
|
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/tannin@1.2.0/node_modules/tannin/index.js + 4 modules
|
|
var node_modules_tannin = __webpack_require__("../../node_modules/.pnpm/tannin@1.2.0/node_modules/tannin/index.js");
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/create-i18n.js
|
|
/**
|
|
* External dependencies
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Record<string,any>} LocaleData
|
|
*/
|
|
|
|
/**
|
|
* Default locale data to use for Tannin domain when not otherwise provided.
|
|
* Assumes an English plural forms expression.
|
|
*
|
|
* @type {LocaleData}
|
|
*/
|
|
|
|
const DEFAULT_LOCALE_DATA = {
|
|
'': {
|
|
/** @param {number} n */
|
|
plural_forms(n) {
|
|
return n === 1 ? 0 : 1;
|
|
}
|
|
|
|
}
|
|
};
|
|
/*
|
|
* Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`,
|
|
* `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`.
|
|
*/
|
|
|
|
const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
|
|
/**
|
|
* @typedef {(domain?: string) => LocaleData} GetLocaleData
|
|
*
|
|
* Returns locale data by domain in a
|
|
* Jed-formatted JSON object shape.
|
|
*
|
|
* @see http://messageformat.github.io/Jed/
|
|
*/
|
|
|
|
/**
|
|
* @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData
|
|
*
|
|
* Merges locale data into the Tannin instance by domain. Note that this
|
|
* function will overwrite the domain configuration. Accepts data in a
|
|
* Jed-formatted JSON object shape.
|
|
*
|
|
* @see http://messageformat.github.io/Jed/
|
|
*/
|
|
|
|
/**
|
|
* @typedef {(data?: LocaleData, domain?: string) => void} AddLocaleData
|
|
*
|
|
* Merges locale data into the Tannin instance by domain. Note that this
|
|
* function will also merge the domain configuration. Accepts data in a
|
|
* Jed-formatted JSON object shape.
|
|
*
|
|
* @see http://messageformat.github.io/Jed/
|
|
*/
|
|
|
|
/**
|
|
* @typedef {(data?: LocaleData, domain?: string) => void} ResetLocaleData
|
|
*
|
|
* Resets all current Tannin instance locale data and sets the specified
|
|
* locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
|
|
*
|
|
* @see http://messageformat.github.io/Jed/
|
|
*/
|
|
|
|
/** @typedef {() => void} SubscribeCallback */
|
|
|
|
/** @typedef {() => void} UnsubscribeCallback */
|
|
|
|
/**
|
|
* @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe
|
|
*
|
|
* Subscribes to changes of locale data
|
|
*/
|
|
|
|
/**
|
|
* @typedef {(domain?: string) => string} GetFilterDomain
|
|
* Retrieve the domain to use when calling domain-specific filters.
|
|
*/
|
|
|
|
/**
|
|
* @typedef {(text: string, domain?: string) => string} __
|
|
*
|
|
* Retrieve the translation of text.
|
|
*
|
|
* @see https://developer.wordpress.org/reference/functions/__/
|
|
*/
|
|
|
|
/**
|
|
* @typedef {(text: string, context: string, domain?: string) => string} _x
|
|
*
|
|
* Retrieve translated string with gettext context.
|
|
*
|
|
* @see https://developer.wordpress.org/reference/functions/_x/
|
|
*/
|
|
|
|
/**
|
|
* @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n
|
|
*
|
|
* Translates and retrieves the singular or plural form based on the supplied
|
|
* number.
|
|
*
|
|
* @see https://developer.wordpress.org/reference/functions/_n/
|
|
*/
|
|
|
|
/**
|
|
* @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx
|
|
*
|
|
* Translates and retrieves the singular or plural form based on the supplied
|
|
* number, with gettext context.
|
|
*
|
|
* @see https://developer.wordpress.org/reference/functions/_nx/
|
|
*/
|
|
|
|
/**
|
|
* @typedef {() => boolean} IsRtl
|
|
*
|
|
* Check if current locale is RTL.
|
|
*
|
|
* **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
|
|
* For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
|
|
* language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
|
|
* including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
|
|
*/
|
|
|
|
/**
|
|
* @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation
|
|
*
|
|
* Check if there is a translation for a given string in singular form.
|
|
*/
|
|
|
|
/** @typedef {import('@wordpress/hooks').Hooks} Hooks */
|
|
|
|
/**
|
|
* An i18n instance
|
|
*
|
|
* @typedef I18n
|
|
* @property {GetLocaleData} getLocaleData Returns locale data by domain in a Jed-formatted JSON object shape.
|
|
* @property {SetLocaleData} setLocaleData Merges locale data into the Tannin instance by domain. Note that this
|
|
* function will overwrite the domain configuration. Accepts data in a
|
|
* Jed-formatted JSON object shape.
|
|
* @property {AddLocaleData} addLocaleData Merges locale data into the Tannin instance by domain. Note that this
|
|
* function will also merge the domain configuration. Accepts data in a
|
|
* Jed-formatted JSON object shape.
|
|
* @property {ResetLocaleData} resetLocaleData Resets all current Tannin instance locale data and sets the specified
|
|
* locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
|
|
* @property {Subscribe} subscribe Subscribes to changes of Tannin locale data.
|
|
* @property {__} __ Retrieve the translation of text.
|
|
* @property {_x} _x Retrieve translated string with gettext context.
|
|
* @property {_n} _n Translates and retrieves the singular or plural form based on the supplied
|
|
* number.
|
|
* @property {_nx} _nx Translates and retrieves the singular or plural form based on the supplied
|
|
* number, with gettext context.
|
|
* @property {IsRtl} isRTL Check if current locale is RTL.
|
|
* @property {HasTranslation} hasTranslation Check if there is a translation for a given string.
|
|
*/
|
|
|
|
/**
|
|
* Create an i18n instance
|
|
*
|
|
* @param {LocaleData} [initialData] Locale data configuration.
|
|
* @param {string} [initialDomain] Domain for which configuration applies.
|
|
* @param {Hooks} [hooks] Hooks implementation.
|
|
*
|
|
* @return {I18n} I18n instance.
|
|
*/
|
|
|
|
const createI18n = (initialData, initialDomain, hooks) => {
|
|
/**
|
|
* The underlying instance of Tannin to which exported functions interface.
|
|
*
|
|
* @type {Tannin}
|
|
*/
|
|
const tannin = new node_modules_tannin/* default */.A({});
|
|
const listeners = new Set();
|
|
|
|
const notifyListeners = () => {
|
|
listeners.forEach(listener => listener());
|
|
};
|
|
/**
|
|
* Subscribe to changes of locale data.
|
|
*
|
|
* @param {SubscribeCallback} callback Subscription callback.
|
|
* @return {UnsubscribeCallback} Unsubscribe callback.
|
|
*/
|
|
|
|
|
|
const subscribe = callback => {
|
|
listeners.add(callback);
|
|
return () => listeners.delete(callback);
|
|
};
|
|
/** @type {GetLocaleData} */
|
|
|
|
|
|
const getLocaleData = function () {
|
|
let domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
|
return tannin.data[domain];
|
|
};
|
|
/**
|
|
* @param {LocaleData} [data]
|
|
* @param {string} [domain]
|
|
*/
|
|
|
|
|
|
const doSetLocaleData = function (data) {
|
|
var _tannin$data$domain;
|
|
|
|
let domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
|
|
tannin.data[domain] = { ...tannin.data[domain],
|
|
...data
|
|
}; // Populate default domain configuration (supported locale date which omits
|
|
// a plural forms expression).
|
|
|
|
tannin.data[domain][''] = { ...DEFAULT_LOCALE_DATA[''],
|
|
...((_tannin$data$domain = tannin.data[domain]) === null || _tannin$data$domain === void 0 ? void 0 : _tannin$data$domain[''])
|
|
}; // Clean up cached plural forms functions cache as it might be updated.
|
|
|
|
delete tannin.pluralForms[domain];
|
|
};
|
|
/** @type {SetLocaleData} */
|
|
|
|
|
|
const setLocaleData = (data, domain) => {
|
|
doSetLocaleData(data, domain);
|
|
notifyListeners();
|
|
};
|
|
/** @type {AddLocaleData} */
|
|
|
|
|
|
const addLocaleData = function (data) {
|
|
var _tannin$data$domain2;
|
|
|
|
let domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
|
|
tannin.data[domain] = { ...tannin.data[domain],
|
|
...data,
|
|
// Populate default domain configuration (supported locale date which omits
|
|
// a plural forms expression).
|
|
'': { ...DEFAULT_LOCALE_DATA[''],
|
|
...((_tannin$data$domain2 = tannin.data[domain]) === null || _tannin$data$domain2 === void 0 ? void 0 : _tannin$data$domain2['']),
|
|
...(data === null || data === void 0 ? void 0 : data[''])
|
|
}
|
|
}; // Clean up cached plural forms functions cache as it might be updated.
|
|
|
|
delete tannin.pluralForms[domain];
|
|
notifyListeners();
|
|
};
|
|
/** @type {ResetLocaleData} */
|
|
|
|
|
|
const resetLocaleData = (data, domain) => {
|
|
// Reset all current Tannin locale data.
|
|
tannin.data = {}; // Reset cached plural forms functions cache.
|
|
|
|
tannin.pluralForms = {};
|
|
setLocaleData(data, domain);
|
|
};
|
|
/**
|
|
* Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not
|
|
* otherwise previously assigned.
|
|
*
|
|
* @param {string|undefined} domain Domain to retrieve the translated text.
|
|
* @param {string|undefined} context Context information for the translators.
|
|
* @param {string} single Text to translate if non-plural. Used as
|
|
* fallback return value on a caught error.
|
|
* @param {string} [plural] The text to be used if the number is
|
|
* plural.
|
|
* @param {number} [number] The number to compare against to use
|
|
* either the singular or plural form.
|
|
*
|
|
* @return {string} The translated string.
|
|
*/
|
|
|
|
|
|
const dcnpgettext = function () {
|
|
let domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
|
let context = arguments.length > 1 ? arguments[1] : undefined;
|
|
let single = arguments.length > 2 ? arguments[2] : undefined;
|
|
let plural = arguments.length > 3 ? arguments[3] : undefined;
|
|
let number = arguments.length > 4 ? arguments[4] : undefined;
|
|
|
|
if (!tannin.data[domain]) {
|
|
// Use `doSetLocaleData` to set silently, without notifying listeners.
|
|
doSetLocaleData(undefined, domain);
|
|
}
|
|
|
|
return tannin.dcnpgettext(domain, context, single, plural, number);
|
|
};
|
|
/** @type {GetFilterDomain} */
|
|
|
|
|
|
const getFilterDomain = function () {
|
|
let domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
|
return domain;
|
|
};
|
|
/** @type {__} */
|
|
|
|
|
|
const __ = (text, domain) => {
|
|
let translation = dcnpgettext(domain, undefined, text);
|
|
|
|
if (!hooks) {
|
|
return translation;
|
|
}
|
|
/**
|
|
* Filters text with its translation.
|
|
*
|
|
* @param {string} translation Translated text.
|
|
* @param {string} text Text to translate.
|
|
* @param {string} domain Text domain. Unique identifier for retrieving translated strings.
|
|
*/
|
|
|
|
|
|
translation =
|
|
/** @type {string} */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.gettext', translation, text, domain);
|
|
return (
|
|
/** @type {string} */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.gettext_' + getFilterDomain(domain), translation, text, domain)
|
|
);
|
|
};
|
|
/** @type {_x} */
|
|
|
|
|
|
const _x = (text, context, domain) => {
|
|
let translation = dcnpgettext(domain, context, text);
|
|
|
|
if (!hooks) {
|
|
return translation;
|
|
}
|
|
/**
|
|
* Filters text with its translation based on context information.
|
|
*
|
|
* @param {string} translation Translated text.
|
|
* @param {string} text Text to translate.
|
|
* @param {string} context Context information for the translators.
|
|
* @param {string} domain Text domain. Unique identifier for retrieving translated strings.
|
|
*/
|
|
|
|
|
|
translation =
|
|
/** @type {string} */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.gettext_with_context', translation, text, context, domain);
|
|
return (
|
|
/** @type {string} */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.gettext_with_context_' + getFilterDomain(domain), translation, text, context, domain)
|
|
);
|
|
};
|
|
/** @type {_n} */
|
|
|
|
|
|
const _n = (single, plural, number, domain) => {
|
|
let translation = dcnpgettext(domain, undefined, single, plural, number);
|
|
|
|
if (!hooks) {
|
|
return translation;
|
|
}
|
|
/**
|
|
* Filters the singular or plural form of a string.
|
|
*
|
|
* @param {string} translation Translated text.
|
|
* @param {string} single The text to be used if the number is singular.
|
|
* @param {string} plural The text to be used if the number is plural.
|
|
* @param {string} number The number to compare against to use either the singular or plural form.
|
|
* @param {string} domain Text domain. Unique identifier for retrieving translated strings.
|
|
*/
|
|
|
|
|
|
translation =
|
|
/** @type {string} */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.ngettext', translation, single, plural, number, domain);
|
|
return (
|
|
/** @type {string} */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.ngettext_' + getFilterDomain(domain), translation, single, plural, number, domain)
|
|
);
|
|
};
|
|
/** @type {_nx} */
|
|
|
|
|
|
const _nx = (single, plural, number, context, domain) => {
|
|
let translation = dcnpgettext(domain, context, single, plural, number);
|
|
|
|
if (!hooks) {
|
|
return translation;
|
|
}
|
|
/**
|
|
* Filters the singular or plural form of a string with gettext context.
|
|
*
|
|
* @param {string} translation Translated text.
|
|
* @param {string} single The text to be used if the number is singular.
|
|
* @param {string} plural The text to be used if the number is plural.
|
|
* @param {string} number The number to compare against to use either the singular or plural form.
|
|
* @param {string} context Context information for the translators.
|
|
* @param {string} domain Text domain. Unique identifier for retrieving translated strings.
|
|
*/
|
|
|
|
|
|
translation =
|
|
/** @type {string} */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.ngettext_with_context', translation, single, plural, number, context, domain);
|
|
return (
|
|
/** @type {string} */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.ngettext_with_context_' + getFilterDomain(domain), translation, single, plural, number, context, domain)
|
|
);
|
|
};
|
|
/** @type {IsRtl} */
|
|
|
|
|
|
const isRTL = () => {
|
|
return 'rtl' === _x('ltr', 'text direction');
|
|
};
|
|
/** @type {HasTranslation} */
|
|
|
|
|
|
const hasTranslation = (single, context, domain) => {
|
|
var _tannin$data, _tannin$data2;
|
|
|
|
const key = context ? context + '\u0004' + single : single;
|
|
let result = !!((_tannin$data = tannin.data) !== null && _tannin$data !== void 0 && (_tannin$data2 = _tannin$data[domain !== null && domain !== void 0 ? domain : 'default']) !== null && _tannin$data2 !== void 0 && _tannin$data2[key]);
|
|
|
|
if (hooks) {
|
|
/**
|
|
* Filters the presence of a translation in the locale data.
|
|
*
|
|
* @param {boolean} hasTranslation Whether the translation is present or not..
|
|
* @param {string} single The singular form of the translated text (used as key in locale data)
|
|
* @param {string} context Context information for the translators.
|
|
* @param {string} domain Text domain. Unique identifier for retrieving translated strings.
|
|
*/
|
|
result =
|
|
/** @type { boolean } */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.has_translation', result, single, context, domain);
|
|
result =
|
|
/** @type { boolean } */
|
|
|
|
/** @type {*} */
|
|
hooks.applyFilters('i18n.has_translation_' + getFilterDomain(domain), result, single, context, domain);
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
if (initialData) {
|
|
setLocaleData(initialData, initialDomain);
|
|
}
|
|
|
|
if (hooks) {
|
|
/**
|
|
* @param {string} hookName
|
|
*/
|
|
const onHookAddedOrRemoved = hookName => {
|
|
if (I18N_HOOK_REGEXP.test(hookName)) {
|
|
notifyListeners();
|
|
}
|
|
};
|
|
|
|
hooks.addAction('hookAdded', 'core/i18n', onHookAddedOrRemoved);
|
|
hooks.addAction('hookRemoved', 'core/i18n', onHookAddedOrRemoved);
|
|
}
|
|
|
|
return {
|
|
getLocaleData,
|
|
setLocaleData,
|
|
addLocaleData,
|
|
resetLocaleData,
|
|
subscribe,
|
|
__,
|
|
_x,
|
|
_n,
|
|
_nx,
|
|
isRTL,
|
|
hasTranslation
|
|
};
|
|
};
|
|
//# sourceMappingURL=create-i18n.js.map
|
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/index.js + 10 modules
|
|
var build_module = __webpack_require__("../../node_modules/.pnpm/@wordpress+hooks@3.6.1/node_modules/@wordpress/hooks/build-module/index.js");
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/default-i18n.js
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
|
|
|
|
const i18n = createI18n(undefined, undefined, build_module/* defaultHooks */.se);
|
|
/**
|
|
* Default, singleton instance of `I18n`.
|
|
*/
|
|
|
|
/* harmony default export */ const default_i18n = ((/* unused pure expression or super */ null && (i18n)));
|
|
/*
|
|
* Comments in this file are duplicated from ./i18n due to
|
|
* https://github.com/WordPress/gutenberg/pull/20318#issuecomment-590837722
|
|
*/
|
|
|
|
/**
|
|
* @typedef {import('./create-i18n').LocaleData} LocaleData
|
|
* @typedef {import('./create-i18n').SubscribeCallback} SubscribeCallback
|
|
* @typedef {import('./create-i18n').UnsubscribeCallback} UnsubscribeCallback
|
|
*/
|
|
|
|
/**
|
|
* Returns locale data by domain in a Jed-formatted JSON object shape.
|
|
*
|
|
* @see http://messageformat.github.io/Jed/
|
|
*
|
|
* @param {string} [domain] Domain for which to get the data.
|
|
* @return {LocaleData} Locale data.
|
|
*/
|
|
|
|
const getLocaleData = i18n.getLocaleData.bind(i18n);
|
|
/**
|
|
* Merges locale data into the Tannin instance by domain. Accepts data in a
|
|
* Jed-formatted JSON object shape.
|
|
*
|
|
* @see http://messageformat.github.io/Jed/
|
|
*
|
|
* @param {LocaleData} [data] Locale data configuration.
|
|
* @param {string} [domain] Domain for which configuration applies.
|
|
*/
|
|
|
|
const setLocaleData = i18n.setLocaleData.bind(i18n);
|
|
/**
|
|
* Resets all current Tannin instance locale data and sets the specified
|
|
* locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
|
|
*
|
|
* @see http://messageformat.github.io/Jed/
|
|
*
|
|
* @param {LocaleData} [data] Locale data configuration.
|
|
* @param {string} [domain] Domain for which configuration applies.
|
|
*/
|
|
|
|
const resetLocaleData = i18n.resetLocaleData.bind(i18n);
|
|
/**
|
|
* Subscribes to changes of locale data
|
|
*
|
|
* @param {SubscribeCallback} callback Subscription callback
|
|
* @return {UnsubscribeCallback} Unsubscribe callback
|
|
*/
|
|
|
|
const subscribe = i18n.subscribe.bind(i18n);
|
|
/**
|
|
* Retrieve the translation of text.
|
|
*
|
|
* @see https://developer.wordpress.org/reference/functions/__/
|
|
*
|
|
* @param {string} text Text to translate.
|
|
* @param {string} [domain] Domain to retrieve the translated text.
|
|
*
|
|
* @return {string} Translated text.
|
|
*/
|
|
|
|
const __ = i18n.__.bind(i18n);
|
|
/**
|
|
* Retrieve translated string with gettext context.
|
|
*
|
|
* @see https://developer.wordpress.org/reference/functions/_x/
|
|
*
|
|
* @param {string} text Text to translate.
|
|
* @param {string} context Context information for the translators.
|
|
* @param {string} [domain] Domain to retrieve the translated text.
|
|
*
|
|
* @return {string} Translated context string without pipe.
|
|
*/
|
|
|
|
const _x = i18n._x.bind(i18n);
|
|
/**
|
|
* Translates and retrieves the singular or plural form based on the supplied
|
|
* number.
|
|
*
|
|
* @see https://developer.wordpress.org/reference/functions/_n/
|
|
*
|
|
* @param {string} single The text to be used if the number is singular.
|
|
* @param {string} plural The text to be used if the number is plural.
|
|
* @param {number} number The number to compare against to use either the
|
|
* singular or plural form.
|
|
* @param {string} [domain] Domain to retrieve the translated text.
|
|
*
|
|
* @return {string} The translated singular or plural form.
|
|
*/
|
|
|
|
const _n = i18n._n.bind(i18n);
|
|
/**
|
|
* Translates and retrieves the singular or plural form based on the supplied
|
|
* number, with gettext context.
|
|
*
|
|
* @see https://developer.wordpress.org/reference/functions/_nx/
|
|
*
|
|
* @param {string} single The text to be used if the number is singular.
|
|
* @param {string} plural The text to be used if the number is plural.
|
|
* @param {number} number The number to compare against to use either the
|
|
* singular or plural form.
|
|
* @param {string} context Context information for the translators.
|
|
* @param {string} [domain] Domain to retrieve the translated text.
|
|
*
|
|
* @return {string} The translated singular or plural form.
|
|
*/
|
|
|
|
const _nx = i18n._nx.bind(i18n);
|
|
/**
|
|
* Check if current locale is RTL.
|
|
*
|
|
* **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
|
|
* For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
|
|
* language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
|
|
* including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
|
|
*
|
|
* @return {boolean} Whether locale is RTL.
|
|
*/
|
|
|
|
const isRTL = i18n.isRTL.bind(i18n);
|
|
/**
|
|
* Check if there is a translation for a given string (in singular form).
|
|
*
|
|
* @param {string} single Singular form of the string to look up.
|
|
* @param {string} [context] Context information for the translators.
|
|
* @param {string} [domain] Domain to retrieve the translated text.
|
|
* @return {boolean} Whether the translation exists or not.
|
|
*/
|
|
|
|
const hasTranslation = i18n.hasTranslation.bind(i18n);
|
|
//# sourceMappingURL=default-i18n.js.map
|
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/index.js
|
|
|
|
|
|
|
|
//# sourceMappingURL=index.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ "../../node_modules/.pnpm/memize@1.1.0/node_modules/memize/index.js":
|
|
/***/ ((module) => {
|
|
|
|
/**
|
|
* Memize options object.
|
|
*
|
|
* @typedef MemizeOptions
|
|
*
|
|
* @property {number} [maxSize] Maximum size of the cache.
|
|
*/
|
|
|
|
/**
|
|
* Internal cache entry.
|
|
*
|
|
* @typedef MemizeCacheNode
|
|
*
|
|
* @property {?MemizeCacheNode|undefined} [prev] Previous node.
|
|
* @property {?MemizeCacheNode|undefined} [next] Next node.
|
|
* @property {Array<*>} args Function arguments for cache
|
|
* entry.
|
|
* @property {*} val Function result.
|
|
*/
|
|
|
|
/**
|
|
* Properties of the enhanced function for controlling cache.
|
|
*
|
|
* @typedef MemizeMemoizedFunction
|
|
*
|
|
* @property {()=>void} clear Clear the cache.
|
|
*/
|
|
|
|
/**
|
|
* Accepts a function to be memoized, and returns a new memoized function, with
|
|
* optional options.
|
|
*
|
|
* @template {Function} F
|
|
*
|
|
* @param {F} fn Function to memoize.
|
|
* @param {MemizeOptions} [options] Options object.
|
|
*
|
|
* @return {F & MemizeMemoizedFunction} Memoized function.
|
|
*/
|
|
function memize( fn, options ) {
|
|
var size = 0;
|
|
|
|
/** @type {?MemizeCacheNode|undefined} */
|
|
var head;
|
|
|
|
/** @type {?MemizeCacheNode|undefined} */
|
|
var tail;
|
|
|
|
options = options || {};
|
|
|
|
function memoized( /* ...args */ ) {
|
|
var node = head,
|
|
len = arguments.length,
|
|
args, i;
|
|
|
|
searchCache: while ( node ) {
|
|
// Perform a shallow equality test to confirm that whether the node
|
|
// under test is a candidate for the arguments passed. Two arrays
|
|
// are shallowly equal if their length matches and each entry is
|
|
// strictly equal between the two sets. Avoid abstracting to a
|
|
// function which could incur an arguments leaking deoptimization.
|
|
|
|
// Check whether node arguments match arguments length
|
|
if ( node.args.length !== arguments.length ) {
|
|
node = node.next;
|
|
continue;
|
|
}
|
|
|
|
// Check whether node arguments match arguments values
|
|
for ( i = 0; i < len; i++ ) {
|
|
if ( node.args[ i ] !== arguments[ i ] ) {
|
|
node = node.next;
|
|
continue searchCache;
|
|
}
|
|
}
|
|
|
|
// At this point we can assume we've found a match
|
|
|
|
// Surface matched node to head if not already
|
|
if ( node !== head ) {
|
|
// As tail, shift to previous. Must only shift if not also
|
|
// head, since if both head and tail, there is no previous.
|
|
if ( node === tail ) {
|
|
tail = node.prev;
|
|
}
|
|
|
|
// Adjust siblings to point to each other. If node was tail,
|
|
// this also handles new tail's empty `next` assignment.
|
|
/** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
|
|
if ( node.next ) {
|
|
node.next.prev = node.prev;
|
|
}
|
|
|
|
node.next = head;
|
|
node.prev = null;
|
|
/** @type {MemizeCacheNode} */ ( head ).prev = node;
|
|
head = node;
|
|
}
|
|
|
|
// Return immediately
|
|
return node.val;
|
|
}
|
|
|
|
// No cached value found. Continue to insertion phase:
|
|
|
|
// Create a copy of arguments (avoid leaking deoptimization)
|
|
args = new Array( len );
|
|
for ( i = 0; i < len; i++ ) {
|
|
args[ i ] = arguments[ i ];
|
|
}
|
|
|
|
node = {
|
|
args: args,
|
|
|
|
// Generate the result from original function
|
|
val: fn.apply( null, args ),
|
|
};
|
|
|
|
// 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
|
|
if ( head ) {
|
|
head.prev = node;
|
|
node.next = head;
|
|
} else {
|
|
// If no head, follows that there's no tail (at initial or reset)
|
|
tail = node;
|
|
}
|
|
|
|
// Trim tail if we're reached max size and are pending cache insertion
|
|
if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
|
|
tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
|
|
/** @type {MemizeCacheNode} */ ( tail ).next = null;
|
|
} else {
|
|
size++;
|
|
}
|
|
|
|
head = node;
|
|
|
|
return node.val;
|
|
}
|
|
|
|
memoized.clear = function() {
|
|
head = null;
|
|
tail = null;
|
|
size = 0;
|
|
};
|
|
|
|
if ( false ) {}
|
|
|
|
// Ignore reason: There's not a clear solution to create an intersection of
|
|
// the function with additional properties, where the goal is to retain the
|
|
// function signature of the incoming argument and add control properties
|
|
// on the return value.
|
|
|
|
// @ts-ignore
|
|
return memoized;
|
|
}
|
|
|
|
module.exports = memize;
|
|
|
|
|
|
/***/ })
|
|
|
|
}]); |