Merged in feature/from-pantheon (pull request #16)
code from pantheon * code from pantheon
This commit is contained in:
Vendored
+248
@@ -0,0 +1,248 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
setup: function() { return /* binding */ setup; },
|
||||
speak: function() { return /* binding */ speak; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","domReady"]
|
||||
var external_wp_domReady_namespaceObject = window["wp"]["domReady"];
|
||||
var external_wp_domReady_default = /*#__PURE__*/__webpack_require__.n(external_wp_domReady_namespaceObject);
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/add-intro-text.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Build the explanatory text to be placed before the aria live regions.
|
||||
*
|
||||
* This text is initially hidden from assistive technologies by using a `hidden`
|
||||
* HTML attribute which is then removed once a message fills the aria-live regions.
|
||||
*
|
||||
* @return {HTMLParagraphElement} The explanatory text HTML element.
|
||||
*/
|
||||
function addIntroText() {
|
||||
const introText = document.createElement('p');
|
||||
introText.id = 'a11y-speak-intro-text';
|
||||
introText.className = 'a11y-speak-intro-text';
|
||||
introText.textContent = (0,external_wp_i18n_namespaceObject.__)('Notifications');
|
||||
introText.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;');
|
||||
introText.setAttribute('hidden', 'hidden');
|
||||
const {
|
||||
body
|
||||
} = document;
|
||||
if (body) {
|
||||
body.appendChild(introText);
|
||||
}
|
||||
return introText;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/add-container.js
|
||||
/**
|
||||
* Build the live regions markup.
|
||||
*
|
||||
* @param {string} [ariaLive] Value for the 'aria-live' attribute; default: 'polite'.
|
||||
*
|
||||
* @return {HTMLDivElement} The ARIA live region HTML element.
|
||||
*/
|
||||
function addContainer(ariaLive = 'polite') {
|
||||
const container = document.createElement('div');
|
||||
container.id = `a11y-speak-${ariaLive}`;
|
||||
container.className = 'a11y-speak-region';
|
||||
container.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;');
|
||||
container.setAttribute('aria-live', ariaLive);
|
||||
container.setAttribute('aria-relevant', 'additions text');
|
||||
container.setAttribute('aria-atomic', 'true');
|
||||
const {
|
||||
body
|
||||
} = document;
|
||||
if (body) {
|
||||
body.appendChild(container);
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/clear.js
|
||||
/**
|
||||
* Clears the a11y-speak-region elements and hides the explanatory text.
|
||||
*/
|
||||
function clear() {
|
||||
const regions = document.getElementsByClassName('a11y-speak-region');
|
||||
const introText = document.getElementById('a11y-speak-intro-text');
|
||||
for (let i = 0; i < regions.length; i++) {
|
||||
regions[i].textContent = '';
|
||||
}
|
||||
|
||||
// Make sure the explanatory text is hidden from assistive technologies.
|
||||
if (introText) {
|
||||
introText.setAttribute('hidden', 'hidden');
|
||||
}
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/filter-message.js
|
||||
let previousMessage = '';
|
||||
|
||||
/**
|
||||
* Filter the message to be announced to the screenreader.
|
||||
*
|
||||
* @param {string} message The message to be announced.
|
||||
*
|
||||
* @return {string} The filtered message.
|
||||
*/
|
||||
function filterMessage(message) {
|
||||
/*
|
||||
* Strip HTML tags (if any) from the message string. Ideally, messages should
|
||||
* be simple strings, carefully crafted for specific use with A11ySpeak.
|
||||
* When re-using already existing strings this will ensure simple HTML to be
|
||||
* stripped out and replaced with a space. Browsers will collapse multiple
|
||||
* spaces natively.
|
||||
*/
|
||||
message = message.replace(/<[^<>]+>/g, ' ');
|
||||
|
||||
/*
|
||||
* Safari + VoiceOver don't announce repeated, identical strings. We use
|
||||
* a `no-break space` to force them to think identical strings are different.
|
||||
*/
|
||||
if (previousMessage === message) {
|
||||
message += '\u00A0';
|
||||
}
|
||||
previousMessage = message;
|
||||
return message;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/a11y/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create the live regions.
|
||||
*/
|
||||
function setup() {
|
||||
const introText = document.getElementById('a11y-speak-intro-text');
|
||||
const containerAssertive = document.getElementById('a11y-speak-assertive');
|
||||
const containerPolite = document.getElementById('a11y-speak-polite');
|
||||
if (introText === null) {
|
||||
addIntroText();
|
||||
}
|
||||
if (containerAssertive === null) {
|
||||
addContainer('assertive');
|
||||
}
|
||||
if (containerPolite === null) {
|
||||
addContainer('polite');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run setup on domReady.
|
||||
*/
|
||||
external_wp_domReady_default()(setup);
|
||||
|
||||
/**
|
||||
* Allows you to easily announce dynamic interface updates to screen readers using ARIA live regions.
|
||||
* This module is inspired by the `speak` function in `wp-a11y.js`.
|
||||
*
|
||||
* @param {string} message The message to be announced by assistive technologies.
|
||||
* @param {string} [ariaLive] The politeness level for aria-live; default: 'polite'.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { speak } from '@wordpress/a11y';
|
||||
*
|
||||
* // For polite messages that shouldn't interrupt what screen readers are currently announcing.
|
||||
* speak( 'The message you want to send to the ARIA live region' );
|
||||
*
|
||||
* // For assertive messages that should interrupt what screen readers are currently announcing.
|
||||
* speak( 'The message you want to send to the ARIA live region', 'assertive' );
|
||||
* ```
|
||||
*/
|
||||
function speak(message, ariaLive) {
|
||||
/*
|
||||
* Clear previous messages to allow repeated strings being read out and hide
|
||||
* the explanatory text from assistive technologies.
|
||||
*/
|
||||
clear();
|
||||
message = filterMessage(message);
|
||||
const introText = document.getElementById('a11y-speak-intro-text');
|
||||
const containerAssertive = document.getElementById('a11y-speak-assertive');
|
||||
const containerPolite = document.getElementById('a11y-speak-polite');
|
||||
if (containerAssertive && ariaLive === 'assertive') {
|
||||
containerAssertive.textContent = message;
|
||||
} else if (containerPolite) {
|
||||
containerPolite.textContent = message;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make the explanatory text available to assistive technologies by removing
|
||||
* the 'hidden' HTML attribute.
|
||||
*/
|
||||
if (introText) {
|
||||
introText.removeAttribute('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).a11y = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var t={n:function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},d:function(e,n){for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{setup:function(){return d},speak:function(){return p}});var n=window.wp.domReady,i=t.n(n),o=window.wp.i18n;function r(t="polite"){const e=document.createElement("div");e.id=`a11y-speak-${t}`,e.className="a11y-speak-region",e.setAttribute("style","position: absolute;margin: -1px;padding: 0;height: 1px;width: 1px;overflow: hidden;clip: rect(1px, 1px, 1px, 1px);-webkit-clip-path: inset(50%);clip-path: inset(50%);border: 0;word-wrap: normal !important;"),e.setAttribute("aria-live",t),e.setAttribute("aria-relevant","additions text"),e.setAttribute("aria-atomic","true");const{body:n}=document;return n&&n.appendChild(e),e}let a="";function d(){const t=document.getElementById("a11y-speak-intro-text"),e=document.getElementById("a11y-speak-assertive"),n=document.getElementById("a11y-speak-polite");null===t&&function(){const t=document.createElement("p");t.id="a11y-speak-intro-text",t.className="a11y-speak-intro-text",t.textContent=(0,o.__)("Notifications"),t.setAttribute("style","position: absolute;margin: -1px;padding: 0;height: 1px;width: 1px;overflow: hidden;clip: rect(1px, 1px, 1px, 1px);-webkit-clip-path: inset(50%);clip-path: inset(50%);border: 0;word-wrap: normal !important;"),t.setAttribute("hidden","hidden");const{body:e}=document;e&&e.appendChild(t)}(),null===e&&r("assertive"),null===n&&r("polite")}function p(t,e){!function(){const t=document.getElementsByClassName("a11y-speak-region"),e=document.getElementById("a11y-speak-intro-text");for(let e=0;e<t.length;e++)t[e].textContent="";e&&e.setAttribute("hidden","hidden")}(),t=function(t){return t=t.replace(/<[^<>]+>/g," "),a===t&&(t+=" "),a=t,t}(t);const n=document.getElementById("a11y-speak-intro-text"),i=document.getElementById("a11y-speak-assertive"),o=document.getElementById("a11y-speak-polite");i&&"assertive"===e?i.textContent=t:o&&(o.textContent=t),n&&n.removeAttribute("hidden")}i()(d),(window.wp=window.wp||{}).a11y=e}();
|
||||
+1014
File diff suppressed because it is too large
Load Diff
+2
File diff suppressed because one or more lines are too long
Vendored
+755
@@ -0,0 +1,755 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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); }
|
||||
/******/ }();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
"default": function() { return /* binding */ build_module; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/nonce.js
|
||||
/**
|
||||
* @param {string} nonce
|
||||
* @return {import('../types').APIFetchMiddleware & { nonce: string }} A middleware to enhance a request with a nonce.
|
||||
*/
|
||||
function createNonceMiddleware(nonce) {
|
||||
/**
|
||||
* @type {import('../types').APIFetchMiddleware & { nonce: string }}
|
||||
*/
|
||||
const middleware = (options, next) => {
|
||||
const {
|
||||
headers = {}
|
||||
} = options;
|
||||
|
||||
// If an 'X-WP-Nonce' header (or any case-insensitive variation
|
||||
// thereof) was specified, no need to add a nonce header.
|
||||
for (const headerName in headers) {
|
||||
if (headerName.toLowerCase() === 'x-wp-nonce' && headers[headerName] === middleware.nonce) {
|
||||
return next(options);
|
||||
}
|
||||
}
|
||||
return next({
|
||||
...options,
|
||||
headers: {
|
||||
...headers,
|
||||
'X-WP-Nonce': middleware.nonce
|
||||
}
|
||||
});
|
||||
};
|
||||
middleware.nonce = nonce;
|
||||
return middleware;
|
||||
}
|
||||
/* harmony default export */ var nonce = (createNonceMiddleware);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/namespace-endpoint.js
|
||||
/**
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const namespaceAndEndpointMiddleware = (options, next) => {
|
||||
let path = options.path;
|
||||
let namespaceTrimmed, endpointTrimmed;
|
||||
if (typeof options.namespace === 'string' && typeof options.endpoint === 'string') {
|
||||
namespaceTrimmed = options.namespace.replace(/^\/|\/$/g, '');
|
||||
endpointTrimmed = options.endpoint.replace(/^\//, '');
|
||||
if (endpointTrimmed) {
|
||||
path = namespaceTrimmed + '/' + endpointTrimmed;
|
||||
} else {
|
||||
path = namespaceTrimmed;
|
||||
}
|
||||
}
|
||||
delete options.namespace;
|
||||
delete options.endpoint;
|
||||
return next({
|
||||
...options,
|
||||
path
|
||||
});
|
||||
};
|
||||
/* harmony default export */ var namespace_endpoint = (namespaceAndEndpointMiddleware);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/root-url.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} rootURL
|
||||
* @return {import('../types').APIFetchMiddleware} Root URL middleware.
|
||||
*/
|
||||
const createRootURLMiddleware = rootURL => (options, next) => {
|
||||
return namespace_endpoint(options, optionsWithPath => {
|
||||
let url = optionsWithPath.url;
|
||||
let path = optionsWithPath.path;
|
||||
let apiRoot;
|
||||
if (typeof path === 'string') {
|
||||
apiRoot = rootURL;
|
||||
if (-1 !== rootURL.indexOf('?')) {
|
||||
path = path.replace('?', '&');
|
||||
}
|
||||
path = path.replace(/^\//, '');
|
||||
|
||||
// API root may already include query parameter prefix if site is
|
||||
// configured to use plain permalinks.
|
||||
if ('string' === typeof apiRoot && -1 !== apiRoot.indexOf('?')) {
|
||||
path = path.replace('?', '&');
|
||||
}
|
||||
url = apiRoot + path;
|
||||
}
|
||||
return next({
|
||||
...optionsWithPath,
|
||||
url
|
||||
});
|
||||
});
|
||||
};
|
||||
/* harmony default export */ var root_url = (createRootURLMiddleware);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","url"]
|
||||
var external_wp_url_namespaceObject = window["wp"]["url"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/preloading.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @param {Record<string, any>} preloadedData
|
||||
* @return {import('../types').APIFetchMiddleware} Preloading middleware.
|
||||
*/
|
||||
function createPreloadingMiddleware(preloadedData) {
|
||||
const cache = Object.fromEntries(Object.entries(preloadedData).map(([path, data]) => [(0,external_wp_url_namespaceObject.normalizePath)(path), data]));
|
||||
return (options, next) => {
|
||||
const {
|
||||
parse = true
|
||||
} = options;
|
||||
/** @type {string | void} */
|
||||
let rawPath = options.path;
|
||||
if (!rawPath && options.url) {
|
||||
const {
|
||||
rest_route: pathFromQuery,
|
||||
...queryArgs
|
||||
} = (0,external_wp_url_namespaceObject.getQueryArgs)(options.url);
|
||||
if (typeof pathFromQuery === 'string') {
|
||||
rawPath = (0,external_wp_url_namespaceObject.addQueryArgs)(pathFromQuery, queryArgs);
|
||||
}
|
||||
}
|
||||
if (typeof rawPath !== 'string') {
|
||||
return next(options);
|
||||
}
|
||||
const method = options.method || 'GET';
|
||||
const path = (0,external_wp_url_namespaceObject.normalizePath)(rawPath);
|
||||
if ('GET' === method && cache[path]) {
|
||||
const cacheData = cache[path];
|
||||
|
||||
// Unsetting the cache key ensures that the data is only used a single time.
|
||||
delete cache[path];
|
||||
return prepareResponse(cacheData, !!parse);
|
||||
} else if ('OPTIONS' === method && cache[method] && cache[method][path]) {
|
||||
const cacheData = cache[method][path];
|
||||
|
||||
// Unsetting the cache key ensures that the data is only used a single time.
|
||||
delete cache[method][path];
|
||||
return prepareResponse(cacheData, !!parse);
|
||||
}
|
||||
return next(options);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a helper function that sends a success response.
|
||||
*
|
||||
* @param {Record<string, any>} responseData
|
||||
* @param {boolean} parse
|
||||
* @return {Promise<any>} Promise with the response.
|
||||
*/
|
||||
function prepareResponse(responseData, parse) {
|
||||
return Promise.resolve(parse ? responseData.body : new window.Response(JSON.stringify(responseData.body), {
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: responseData.headers
|
||||
}));
|
||||
}
|
||||
/* harmony default export */ var preloading = (createPreloadingMiddleware);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/fetch-all-middleware.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Apply query arguments to both URL and Path, whichever is present.
|
||||
*
|
||||
* @param {import('../types').APIFetchOptions} props
|
||||
* @param {Record<string, string | number>} queryArgs
|
||||
* @return {import('../types').APIFetchOptions} The request with the modified query args
|
||||
*/
|
||||
const modifyQuery = ({
|
||||
path,
|
||||
url,
|
||||
...options
|
||||
}, queryArgs) => ({
|
||||
...options,
|
||||
url: url && (0,external_wp_url_namespaceObject.addQueryArgs)(url, queryArgs),
|
||||
path: path && (0,external_wp_url_namespaceObject.addQueryArgs)(path, queryArgs)
|
||||
});
|
||||
|
||||
/**
|
||||
* Duplicates parsing functionality from apiFetch.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @return {Promise<any>} Parsed response json.
|
||||
*/
|
||||
const parseResponse = response => response.json ? response.json() : Promise.reject(response);
|
||||
|
||||
/**
|
||||
* @param {string | null} linkHeader
|
||||
* @return {{ next?: string }} The parsed link header.
|
||||
*/
|
||||
const parseLinkHeader = linkHeader => {
|
||||
if (!linkHeader) {
|
||||
return {};
|
||||
}
|
||||
const match = linkHeader.match(/<([^>]+)>; rel="next"/);
|
||||
return match ? {
|
||||
next: match[1]
|
||||
} : {};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Response} response
|
||||
* @return {string | undefined} The next page URL.
|
||||
*/
|
||||
const getNextPageUrl = response => {
|
||||
const {
|
||||
next
|
||||
} = parseLinkHeader(response.headers.get('link'));
|
||||
return next;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import('../types').APIFetchOptions} options
|
||||
* @return {boolean} True if the request contains an unbounded query.
|
||||
*/
|
||||
const requestContainsUnboundedQuery = options => {
|
||||
const pathIsUnbounded = !!options.path && options.path.indexOf('per_page=-1') !== -1;
|
||||
const urlIsUnbounded = !!options.url && options.url.indexOf('per_page=-1') !== -1;
|
||||
return pathIsUnbounded || urlIsUnbounded;
|
||||
};
|
||||
|
||||
/**
|
||||
* The REST API enforces an upper limit on the per_page option. To handle large
|
||||
* collections, apiFetch consumers can pass `per_page=-1`; this middleware will
|
||||
* then recursively assemble a full response array from all available pages.
|
||||
*
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const fetchAllMiddleware = async (options, next) => {
|
||||
if (options.parse === false) {
|
||||
// If a consumer has opted out of parsing, do not apply middleware.
|
||||
return next(options);
|
||||
}
|
||||
if (!requestContainsUnboundedQuery(options)) {
|
||||
// If neither url nor path is requesting all items, do not apply middleware.
|
||||
return next(options);
|
||||
}
|
||||
|
||||
// Retrieve requested page of results.
|
||||
const response = await build_module({
|
||||
...modifyQuery(options, {
|
||||
per_page: 100
|
||||
}),
|
||||
// Ensure headers are returned for page 1.
|
||||
parse: false
|
||||
});
|
||||
const results = await parseResponse(response);
|
||||
if (!Array.isArray(results)) {
|
||||
// We have no reliable way of merging non-array results.
|
||||
return results;
|
||||
}
|
||||
let nextPage = getNextPageUrl(response);
|
||||
if (!nextPage) {
|
||||
// There are no further pages to request.
|
||||
return results;
|
||||
}
|
||||
|
||||
// Iteratively fetch all remaining pages until no "next" header is found.
|
||||
let mergedResults = /** @type {any[]} */[].concat(results);
|
||||
while (nextPage) {
|
||||
const nextResponse = await build_module({
|
||||
...options,
|
||||
// Ensure the URL for the next page is used instead of any provided path.
|
||||
path: undefined,
|
||||
url: nextPage,
|
||||
// Ensure we still get headers so we can identify the next page.
|
||||
parse: false
|
||||
});
|
||||
const nextResults = await parseResponse(nextResponse);
|
||||
mergedResults = mergedResults.concat(nextResults);
|
||||
nextPage = getNextPageUrl(nextResponse);
|
||||
}
|
||||
return mergedResults;
|
||||
};
|
||||
/* harmony default export */ var fetch_all_middleware = (fetchAllMiddleware);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/http-v1.js
|
||||
/**
|
||||
* Set of HTTP methods which are eligible to be overridden.
|
||||
*
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
const OVERRIDE_METHODS = new Set(['PATCH', 'PUT', 'DELETE']);
|
||||
|
||||
/**
|
||||
* Default request method.
|
||||
*
|
||||
* "A request has an associated method (a method). Unless stated otherwise it
|
||||
* is `GET`."
|
||||
*
|
||||
* @see https://fetch.spec.whatwg.org/#requests
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const DEFAULT_METHOD = 'GET';
|
||||
|
||||
/**
|
||||
* API Fetch middleware which overrides the request method for HTTP v1
|
||||
* compatibility leveraging the REST API X-HTTP-Method-Override header.
|
||||
*
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const httpV1Middleware = (options, next) => {
|
||||
const {
|
||||
method = DEFAULT_METHOD
|
||||
} = options;
|
||||
if (OVERRIDE_METHODS.has(method.toUpperCase())) {
|
||||
options = {
|
||||
...options,
|
||||
headers: {
|
||||
...options.headers,
|
||||
'X-HTTP-Method-Override': method,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
method: 'POST'
|
||||
};
|
||||
}
|
||||
return next(options);
|
||||
};
|
||||
/* harmony default export */ var http_v1 = (httpV1Middleware);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/user-locale.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const userLocaleMiddleware = (options, next) => {
|
||||
if (typeof options.url === 'string' && !(0,external_wp_url_namespaceObject.hasQueryArg)(options.url, '_locale')) {
|
||||
options.url = (0,external_wp_url_namespaceObject.addQueryArgs)(options.url, {
|
||||
_locale: 'user'
|
||||
});
|
||||
}
|
||||
if (typeof options.path === 'string' && !(0,external_wp_url_namespaceObject.hasQueryArg)(options.path, '_locale')) {
|
||||
options.path = (0,external_wp_url_namespaceObject.addQueryArgs)(options.path, {
|
||||
_locale: 'user'
|
||||
});
|
||||
}
|
||||
return next(options);
|
||||
};
|
||||
/* harmony default export */ var user_locale = (userLocaleMiddleware);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/utils/response.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Parses the apiFetch response.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @param {boolean} shouldParseResponse
|
||||
*
|
||||
* @return {Promise<any> | null | Response} Parsed response.
|
||||
*/
|
||||
const response_parseResponse = (response, shouldParseResponse = true) => {
|
||||
if (shouldParseResponse) {
|
||||
if (response.status === 204) {
|
||||
return null;
|
||||
}
|
||||
return response.json ? response.json() : Promise.reject(response);
|
||||
}
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calls the `json` function on the Response, throwing an error if the response
|
||||
* doesn't have a json function or if parsing the json itself fails.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @return {Promise<any>} Parsed response.
|
||||
*/
|
||||
const parseJsonAndNormalizeError = response => {
|
||||
const invalidJsonError = {
|
||||
code: 'invalid_json',
|
||||
message: (0,external_wp_i18n_namespaceObject.__)('The response is not a valid JSON response.')
|
||||
};
|
||||
if (!response || !response.json) {
|
||||
throw invalidJsonError;
|
||||
}
|
||||
return response.json().catch(() => {
|
||||
throw invalidJsonError;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the apiFetch response properly and normalize response errors.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @param {boolean} shouldParseResponse
|
||||
*
|
||||
* @return {Promise<any>} Parsed response.
|
||||
*/
|
||||
const parseResponseAndNormalizeError = (response, shouldParseResponse = true) => {
|
||||
return Promise.resolve(response_parseResponse(response, shouldParseResponse)).catch(res => parseAndThrowError(res, shouldParseResponse));
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses a response, throwing an error if parsing the response fails.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @param {boolean} shouldParseResponse
|
||||
* @return {Promise<any>} Parsed response.
|
||||
*/
|
||||
function parseAndThrowError(response, shouldParseResponse = true) {
|
||||
if (!shouldParseResponse) {
|
||||
throw response;
|
||||
}
|
||||
return parseJsonAndNormalizeError(response).then(error => {
|
||||
const unknownError = {
|
||||
code: 'unknown_error',
|
||||
message: (0,external_wp_i18n_namespaceObject.__)('An unknown error occurred.')
|
||||
};
|
||||
throw error || unknownError;
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/media-upload.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @param {import('../types').APIFetchOptions} options
|
||||
* @return {boolean} True if the request is for media upload.
|
||||
*/
|
||||
function isMediaUploadRequest(options) {
|
||||
const isCreateMethod = !!options.method && options.method === 'POST';
|
||||
const isMediaEndpoint = !!options.path && options.path.indexOf('/wp/v2/media') !== -1 || !!options.url && options.url.indexOf('/wp/v2/media') !== -1;
|
||||
return isMediaEndpoint && isCreateMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Middleware handling media upload failures and retries.
|
||||
*
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const mediaUploadMiddleware = (options, next) => {
|
||||
if (!isMediaUploadRequest(options)) {
|
||||
return next(options);
|
||||
}
|
||||
let retries = 0;
|
||||
const maxRetries = 5;
|
||||
|
||||
/**
|
||||
* @param {string} attachmentId
|
||||
* @return {Promise<any>} Processed post response.
|
||||
*/
|
||||
const postProcess = attachmentId => {
|
||||
retries++;
|
||||
return next({
|
||||
path: `/wp/v2/media/${attachmentId}/post-process`,
|
||||
method: 'POST',
|
||||
data: {
|
||||
action: 'create-image-subsizes'
|
||||
},
|
||||
parse: false
|
||||
}).catch(() => {
|
||||
if (retries < maxRetries) {
|
||||
return postProcess(attachmentId);
|
||||
}
|
||||
next({
|
||||
path: `/wp/v2/media/${attachmentId}?force=true`,
|
||||
method: 'DELETE'
|
||||
});
|
||||
return Promise.reject();
|
||||
});
|
||||
};
|
||||
return next({
|
||||
...options,
|
||||
parse: false
|
||||
}).catch(response => {
|
||||
const attachmentId = response.headers.get('x-wp-upload-attachment-id');
|
||||
if (response.status >= 500 && response.status < 600 && attachmentId) {
|
||||
return postProcess(attachmentId).catch(() => {
|
||||
if (options.parse !== false) {
|
||||
return Promise.reject({
|
||||
code: 'post_process',
|
||||
message: (0,external_wp_i18n_namespaceObject.__)('Media upload failed. If this is a photo or a large image, please scale it down and try again.')
|
||||
});
|
||||
}
|
||||
return Promise.reject(response);
|
||||
});
|
||||
}
|
||||
return parseAndThrowError(response, options.parse);
|
||||
}).then(response => parseResponseAndNormalizeError(response, options.parse));
|
||||
};
|
||||
/* harmony default export */ var media_upload = (mediaUploadMiddleware);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/middlewares/theme-preview.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This appends a `wp_theme_preview` parameter to the REST API request URL if
|
||||
* the admin URL contains a `theme` GET parameter.
|
||||
*
|
||||
* @param {Record<string, any>} themePath
|
||||
* @return {import('../types').APIFetchMiddleware} Preloading middleware.
|
||||
*/
|
||||
const createThemePreviewMiddleware = themePath => (options, next) => {
|
||||
if (typeof options.url === 'string' && !(0,external_wp_url_namespaceObject.hasQueryArg)(options.url, 'wp_theme_preview')) {
|
||||
options.url = (0,external_wp_url_namespaceObject.addQueryArgs)(options.url, {
|
||||
wp_theme_preview: themePath
|
||||
});
|
||||
}
|
||||
if (typeof options.path === 'string' && !(0,external_wp_url_namespaceObject.hasQueryArg)(options.path, 'wp_theme_preview')) {
|
||||
options.path = (0,external_wp_url_namespaceObject.addQueryArgs)(options.path, {
|
||||
wp_theme_preview: themePath
|
||||
});
|
||||
}
|
||||
return next(options);
|
||||
};
|
||||
/* harmony default export */ var theme_preview = (createThemePreviewMiddleware);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/api-fetch/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Default set of header values which should be sent with every request unless
|
||||
* explicitly provided through apiFetch options.
|
||||
*
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
const DEFAULT_HEADERS = {
|
||||
// The backend uses the Accept header as a condition for considering an
|
||||
// incoming request as a REST request.
|
||||
//
|
||||
// See: https://core.trac.wordpress.org/ticket/44534
|
||||
Accept: 'application/json, */*;q=0.1'
|
||||
};
|
||||
|
||||
/**
|
||||
* Default set of fetch option values which should be sent with every request
|
||||
* unless explicitly provided through apiFetch options.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const DEFAULT_OPTIONS = {
|
||||
credentials: 'include'
|
||||
};
|
||||
|
||||
/** @typedef {import('./types').APIFetchMiddleware} APIFetchMiddleware */
|
||||
/** @typedef {import('./types').APIFetchOptions} APIFetchOptions */
|
||||
|
||||
/**
|
||||
* @type {import('./types').APIFetchMiddleware[]}
|
||||
*/
|
||||
const middlewares = [user_locale, namespace_endpoint, http_v1, fetch_all_middleware];
|
||||
|
||||
/**
|
||||
* Register a middleware
|
||||
*
|
||||
* @param {import('./types').APIFetchMiddleware} middleware
|
||||
*/
|
||||
function registerMiddleware(middleware) {
|
||||
middlewares.unshift(middleware);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the status of a response, throwing the Response as an error if
|
||||
* it is outside the 200 range.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @return {Response} The response if the status is in the 200 range.
|
||||
*/
|
||||
const checkStatus = response => {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return response;
|
||||
}
|
||||
throw response;
|
||||
};
|
||||
|
||||
/** @typedef {(options: import('./types').APIFetchOptions) => Promise<any>} FetchHandler*/
|
||||
|
||||
/**
|
||||
* @type {FetchHandler}
|
||||
*/
|
||||
const defaultFetchHandler = nextOptions => {
|
||||
const {
|
||||
url,
|
||||
path,
|
||||
data,
|
||||
parse = true,
|
||||
...remainingOptions
|
||||
} = nextOptions;
|
||||
let {
|
||||
body,
|
||||
headers
|
||||
} = nextOptions;
|
||||
|
||||
// Merge explicitly-provided headers with default values.
|
||||
headers = {
|
||||
...DEFAULT_HEADERS,
|
||||
...headers
|
||||
};
|
||||
|
||||
// The `data` property is a shorthand for sending a JSON body.
|
||||
if (data) {
|
||||
body = JSON.stringify(data);
|
||||
headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
const responsePromise = window.fetch(
|
||||
// Fall back to explicitly passing `window.location` which is the behavior if `undefined` is passed.
|
||||
url || path || window.location.href, {
|
||||
...DEFAULT_OPTIONS,
|
||||
...remainingOptions,
|
||||
body,
|
||||
headers
|
||||
});
|
||||
return responsePromise.then(value => Promise.resolve(value).then(checkStatus).catch(response => parseAndThrowError(response, parse)).then(response => parseResponseAndNormalizeError(response, parse)), err => {
|
||||
// Re-throw AbortError for the users to handle it themselves.
|
||||
if (err && err.name === 'AbortError') {
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Otherwise, there is most likely no network connection.
|
||||
// Unfortunately the message might depend on the browser.
|
||||
throw {
|
||||
code: 'fetch_error',
|
||||
message: (0,external_wp_i18n_namespaceObject.__)('You are probably offline.')
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
/** @type {FetchHandler} */
|
||||
let fetchHandler = defaultFetchHandler;
|
||||
|
||||
/**
|
||||
* Defines a custom fetch handler for making the requests that will override
|
||||
* the default one using window.fetch
|
||||
*
|
||||
* @param {FetchHandler} newFetchHandler The new fetch handler
|
||||
*/
|
||||
function setFetchHandler(newFetchHandler) {
|
||||
fetchHandler = newFetchHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {import('./types').APIFetchOptions} options
|
||||
* @return {Promise<T>} A promise representing the request processed via the registered middlewares.
|
||||
*/
|
||||
function apiFetch(options) {
|
||||
// creates a nested function chain that calls all middlewares and finally the `fetchHandler`,
|
||||
// converting `middlewares = [ m1, m2, m3 ]` into:
|
||||
// ```
|
||||
// opts1 => m1( opts1, opts2 => m2( opts2, opts3 => m3( opts3, fetchHandler ) ) );
|
||||
// ```
|
||||
const enhancedHandler = middlewares.reduceRight(( /** @type {FetchHandler} */next, middleware) => {
|
||||
return workingOptions => middleware(workingOptions, next);
|
||||
}, fetchHandler);
|
||||
return enhancedHandler(options).catch(error => {
|
||||
if (error.code !== 'rest_cookie_invalid_nonce') {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
// If the nonce is invalid, refresh it and try again.
|
||||
return window
|
||||
// @ts-ignore
|
||||
.fetch(apiFetch.nonceEndpoint).then(checkStatus).then(data => data.text()).then(text => {
|
||||
// @ts-ignore
|
||||
apiFetch.nonceMiddleware.nonce = text;
|
||||
return apiFetch(options);
|
||||
});
|
||||
});
|
||||
}
|
||||
apiFetch.use = registerMiddleware;
|
||||
apiFetch.setFetchHandler = setFetchHandler;
|
||||
apiFetch.createNonceMiddleware = nonce;
|
||||
apiFetch.createPreloadingMiddleware = preloading;
|
||||
apiFetch.createRootURLMiddleware = root_url;
|
||||
apiFetch.fetchAllMiddleware = fetch_all_middleware;
|
||||
apiFetch.mediaUploadMiddleware = media_upload;
|
||||
apiFetch.createThemePreviewMiddleware = theme_preview;
|
||||
/* harmony default export */ var build_module = (apiFetch);
|
||||
|
||||
(window.wp = window.wp || {}).apiFetch = __webpack_exports__["default"];
|
||||
/******/ })()
|
||||
;
|
||||
+2
File diff suppressed because one or more lines are too long
Vendored
+470
@@ -0,0 +1,470 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ autop: function() { return /* binding */ autop; },
|
||||
/* harmony export */ removep: function() { return /* binding */ removep; }
|
||||
/* harmony export */ });
|
||||
/**
|
||||
* The regular expression for an HTML element.
|
||||
*
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const htmlSplitRegex = (() => {
|
||||
/* eslint-disable no-multi-spaces */
|
||||
const comments = '!' +
|
||||
// Start of comment, after the <.
|
||||
'(?:' +
|
||||
// Unroll the loop: Consume everything until --> is found.
|
||||
'-(?!->)' +
|
||||
// Dash not followed by end of comment.
|
||||
'[^\\-]*' +
|
||||
// Consume non-dashes.
|
||||
')*' +
|
||||
// Loop possessively.
|
||||
'(?:-->)?'; // End of comment. If not found, match all input.
|
||||
|
||||
const cdata = '!\\[CDATA\\[' +
|
||||
// Start of comment, after the <.
|
||||
'[^\\]]*' +
|
||||
// Consume non-].
|
||||
'(?:' +
|
||||
// Unroll the loop: Consume everything until ]]> is found.
|
||||
'](?!]>)' +
|
||||
// One ] not followed by end of comment.
|
||||
'[^\\]]*' +
|
||||
// Consume non-].
|
||||
')*?' +
|
||||
// Loop possessively.
|
||||
'(?:]]>)?'; // End of comment. If not found, match all input.
|
||||
|
||||
const escaped = '(?=' +
|
||||
// Is the element escaped?
|
||||
'!--' + '|' + '!\\[CDATA\\[' + ')' + '((?=!-)' +
|
||||
// If yes, which type?
|
||||
comments + '|' + cdata + ')';
|
||||
const regex = '(' +
|
||||
// Capture the entire match.
|
||||
'<' +
|
||||
// Find start of element.
|
||||
'(' +
|
||||
// Conditional expression follows.
|
||||
escaped +
|
||||
// Find end of escaped element.
|
||||
'|' +
|
||||
// ... else ...
|
||||
'[^>]*>?' +
|
||||
// Find end of normal element.
|
||||
')' + ')';
|
||||
return new RegExp(regex);
|
||||
/* eslint-enable no-multi-spaces */
|
||||
})();
|
||||
|
||||
/**
|
||||
* Separate HTML elements and comments from the text.
|
||||
*
|
||||
* @param {string} input The text which has to be formatted.
|
||||
*
|
||||
* @return {string[]} The formatted text.
|
||||
*/
|
||||
function htmlSplit(input) {
|
||||
const parts = [];
|
||||
let workingInput = input;
|
||||
let match;
|
||||
while (match = workingInput.match(htmlSplitRegex)) {
|
||||
// The `match` result, when invoked on a RegExp with the `g` flag (`/foo/g`) will not include `index`.
|
||||
// If the `g` flag is omitted, `index` is included.
|
||||
// `htmlSplitRegex` does not have the `g` flag so we can assert it will have an index number.
|
||||
// Assert `match.index` is a number.
|
||||
const index = /** @type {number} */match.index;
|
||||
parts.push(workingInput.slice(0, index));
|
||||
parts.push(match[0]);
|
||||
workingInput = workingInput.slice(index + match[0].length);
|
||||
}
|
||||
if (workingInput.length) {
|
||||
parts.push(workingInput);
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace characters or phrases within HTML elements only.
|
||||
*
|
||||
* @param {string} haystack The text which has to be formatted.
|
||||
* @param {Record<string,string>} replacePairs In the form {from: 'to', …}.
|
||||
*
|
||||
* @return {string} The formatted text.
|
||||
*/
|
||||
function replaceInHtmlTags(haystack, replacePairs) {
|
||||
// Find all elements.
|
||||
const textArr = htmlSplit(haystack);
|
||||
let changed = false;
|
||||
|
||||
// Extract all needles.
|
||||
const needles = Object.keys(replacePairs);
|
||||
|
||||
// Loop through delimiters (elements) only.
|
||||
for (let i = 1; i < textArr.length; i += 2) {
|
||||
for (let j = 0; j < needles.length; j++) {
|
||||
const needle = needles[j];
|
||||
if (-1 !== textArr[i].indexOf(needle)) {
|
||||
textArr[i] = textArr[i].replace(new RegExp(needle, 'g'), replacePairs[needle]);
|
||||
changed = true;
|
||||
// After one strtr() break out of the foreach loop and look at next element.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
haystack = textArr.join('');
|
||||
}
|
||||
return haystack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces double line-breaks with paragraph elements.
|
||||
*
|
||||
* A group of regex replaces used to identify text formatted with newlines and
|
||||
* replace double line-breaks with HTML paragraph tags. The remaining line-
|
||||
* breaks after conversion become `<br />` tags, unless br is set to 'false'.
|
||||
*
|
||||
* @param {string} text The text which has to be formatted.
|
||||
* @param {boolean} br Optional. If set, will convert all remaining line-
|
||||
* breaks after paragraphing. Default true.
|
||||
*
|
||||
* @example
|
||||
*```js
|
||||
* import { autop } from '@wordpress/autop';
|
||||
* autop( 'my text' ); // "<p>my text</p>"
|
||||
* ```
|
||||
*
|
||||
* @return {string} Text which has been converted into paragraph tags.
|
||||
*/
|
||||
function autop(text, br = true) {
|
||||
const preTags = [];
|
||||
if (text.trim() === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Just to make things a little easier, pad the end.
|
||||
text = text + '\n';
|
||||
|
||||
/*
|
||||
* Pre tags shouldn't be touched by autop.
|
||||
* Replace pre tags with placeholders and bring them back after autop.
|
||||
*/
|
||||
if (text.indexOf('<pre') !== -1) {
|
||||
const textParts = text.split('</pre>');
|
||||
const lastText = textParts.pop();
|
||||
text = '';
|
||||
for (let i = 0; i < textParts.length; i++) {
|
||||
const textPart = textParts[i];
|
||||
const start = textPart.indexOf('<pre');
|
||||
|
||||
// Malformed html?
|
||||
if (start === -1) {
|
||||
text += textPart;
|
||||
continue;
|
||||
}
|
||||
const name = '<pre wp-pre-tag-' + i + '></pre>';
|
||||
preTags.push([name, textPart.substr(start) + '</pre>']);
|
||||
text += textPart.substr(0, start) + name;
|
||||
}
|
||||
text += lastText;
|
||||
}
|
||||
// Change multiple <br>s into two line breaks, which will turn into paragraphs.
|
||||
text = text.replace(/<br\s*\/?>\s*<br\s*\/?>/g, '\n\n');
|
||||
const allBlocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
|
||||
|
||||
// Add a double line break above block-level opening tags.
|
||||
text = text.replace(new RegExp('(<' + allBlocks + '[\\s/>])', 'g'), '\n\n$1');
|
||||
|
||||
// Add a double line break below block-level closing tags.
|
||||
text = text.replace(new RegExp('(</' + allBlocks + '>)', 'g'), '$1\n\n');
|
||||
|
||||
// Standardize newline characters to "\n".
|
||||
text = text.replace(/\r\n|\r/g, '\n');
|
||||
|
||||
// Find newlines in all elements and add placeholders.
|
||||
text = replaceInHtmlTags(text, {
|
||||
'\n': ' <!-- wpnl --> '
|
||||
});
|
||||
|
||||
// Collapse line breaks before and after <option> elements so they don't get autop'd.
|
||||
if (text.indexOf('<option') !== -1) {
|
||||
text = text.replace(/\s*<option/g, '<option');
|
||||
text = text.replace(/<\/option>\s*/g, '</option>');
|
||||
}
|
||||
|
||||
/*
|
||||
* Collapse line breaks inside <object> elements, before <param> and <embed> elements
|
||||
* so they don't get autop'd.
|
||||
*/
|
||||
if (text.indexOf('</object>') !== -1) {
|
||||
text = text.replace(/(<object[^>]*>)\s*/g, '$1');
|
||||
text = text.replace(/\s*<\/object>/g, '</object>');
|
||||
text = text.replace(/\s*(<\/?(?:param|embed)[^>]*>)\s*/g, '$1');
|
||||
}
|
||||
|
||||
/*
|
||||
* Collapse line breaks inside <audio> and <video> elements,
|
||||
* before and after <source> and <track> elements.
|
||||
*/
|
||||
if (text.indexOf('<source') !== -1 || text.indexOf('<track') !== -1) {
|
||||
text = text.replace(/([<\[](?:audio|video)[^>\]]*[>\]])\s*/g, '$1');
|
||||
text = text.replace(/\s*([<\[]\/(?:audio|video)[>\]])/g, '$1');
|
||||
text = text.replace(/\s*(<(?:source|track)[^>]*>)\s*/g, '$1');
|
||||
}
|
||||
|
||||
// Collapse line breaks before and after <figcaption> elements.
|
||||
if (text.indexOf('<figcaption') !== -1) {
|
||||
text = text.replace(/\s*(<figcaption[^>]*>)/, '$1');
|
||||
text = text.replace(/<\/figcaption>\s*/, '</figcaption>');
|
||||
}
|
||||
|
||||
// Remove more than two contiguous line breaks.
|
||||
text = text.replace(/\n\n+/g, '\n\n');
|
||||
|
||||
// Split up the contents into an array of strings, separated by double line breaks.
|
||||
const texts = text.split(/\n\s*\n/).filter(Boolean);
|
||||
|
||||
// Reset text prior to rebuilding.
|
||||
text = '';
|
||||
|
||||
// Rebuild the content as a string, wrapping every bit with a <p>.
|
||||
texts.forEach(textPiece => {
|
||||
text += '<p>' + textPiece.replace(/^\n*|\n*$/g, '') + '</p>\n';
|
||||
});
|
||||
|
||||
// Under certain strange conditions it could create a P of entirely whitespace.
|
||||
text = text.replace(/<p>\s*<\/p>/g, '');
|
||||
|
||||
// Add a closing <p> inside <div>, <address>, or <form> tag if missing.
|
||||
text = text.replace(/<p>([^<]+)<\/(div|address|form)>/g, '<p>$1</p></$2>');
|
||||
|
||||
// If an opening or closing block element tag is wrapped in a <p>, unwrap it.
|
||||
text = text.replace(new RegExp('<p>\\s*(</?' + allBlocks + '[^>]*>)\\s*</p>', 'g'), '$1');
|
||||
|
||||
// In some cases <li> may get wrapped in <p>, fix them.
|
||||
text = text.replace(/<p>(<li.+?)<\/p>/g, '$1');
|
||||
|
||||
// If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>.
|
||||
text = text.replace(/<p><blockquote([^>]*)>/gi, '<blockquote$1><p>');
|
||||
text = text.replace(/<\/blockquote><\/p>/g, '</p></blockquote>');
|
||||
|
||||
// If an opening or closing block element tag is preceded by an opening <p> tag, remove it.
|
||||
text = text.replace(new RegExp('<p>\\s*(</?' + allBlocks + '[^>]*>)', 'g'), '$1');
|
||||
|
||||
// If an opening or closing block element tag is followed by a closing <p> tag, remove it.
|
||||
text = text.replace(new RegExp('(</?' + allBlocks + '[^>]*>)\\s*</p>', 'g'), '$1');
|
||||
|
||||
// Optionally insert line breaks.
|
||||
if (br) {
|
||||
// Replace newlines that shouldn't be touched with a placeholder.
|
||||
text = text.replace(/<(script|style).*?<\/\\1>/g, match => match[0].replace(/\n/g, '<WPPreserveNewline />'));
|
||||
|
||||
// Normalize <br>
|
||||
text = text.replace(/<br>|<br\/>/g, '<br />');
|
||||
|
||||
// Replace any new line characters that aren't preceded by a <br /> with a <br />.
|
||||
text = text.replace(/(<br \/>)?\s*\n/g, (a, b) => b ? a : '<br />\n');
|
||||
|
||||
// Replace newline placeholders with newlines.
|
||||
text = text.replace(/<WPPreserveNewline \/>/g, '\n');
|
||||
}
|
||||
|
||||
// If a <br /> tag is after an opening or closing block tag, remove it.
|
||||
text = text.replace(new RegExp('(</?' + allBlocks + '[^>]*>)\\s*<br />', 'g'), '$1');
|
||||
|
||||
// If a <br /> tag is before a subset of opening or closing block tags, remove it.
|
||||
text = text.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g, '$1');
|
||||
text = text.replace(/\n<\/p>$/g, '</p>');
|
||||
|
||||
// Replace placeholder <pre> tags with their original content.
|
||||
preTags.forEach(preTag => {
|
||||
const [name, original] = preTag;
|
||||
text = text.replace(name, original);
|
||||
});
|
||||
|
||||
// Restore newlines in all elements.
|
||||
if (-1 !== text.indexOf('<!-- wpnl -->')) {
|
||||
text = text.replace(/\s?<!-- wpnl -->\s?/g, '\n');
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces `<p>` tags with two line breaks. "Opposite" of autop().
|
||||
*
|
||||
* Replaces `<p>` tags with two line breaks except where the `<p>` has attributes.
|
||||
* Unifies whitespace. Indents `<li>`, `<dt>` and `<dd>` for better readability.
|
||||
*
|
||||
* @param {string} html The content from the editor.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { removep } from '@wordpress/autop';
|
||||
* removep( '<p>my text</p>' ); // "my text"
|
||||
* ```
|
||||
*
|
||||
* @return {string} The content with stripped paragraph tags.
|
||||
*/
|
||||
function removep(html) {
|
||||
const blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure';
|
||||
const blocklist1 = blocklist + '|div|p';
|
||||
const blocklist2 = blocklist + '|pre';
|
||||
/** @type {string[]} */
|
||||
const preserve = [];
|
||||
let preserveLinebreaks = false;
|
||||
let preserveBr = false;
|
||||
if (!html) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Protect script and style tags.
|
||||
if (html.indexOf('<script') !== -1 || html.indexOf('<style') !== -1) {
|
||||
html = html.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/g, match => {
|
||||
preserve.push(match);
|
||||
return '<wp-preserve>';
|
||||
});
|
||||
}
|
||||
|
||||
// Protect pre tags.
|
||||
if (html.indexOf('<pre') !== -1) {
|
||||
preserveLinebreaks = true;
|
||||
html = html.replace(/<pre[^>]*>[\s\S]+?<\/pre>/g, a => {
|
||||
a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>');
|
||||
a = a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>');
|
||||
return a.replace(/\r?\n/g, '<wp-line-break>');
|
||||
});
|
||||
}
|
||||
|
||||
// Remove line breaks but keep <br> tags inside image captions.
|
||||
if (html.indexOf('[caption') !== -1) {
|
||||
preserveBr = true;
|
||||
html = html.replace(/\[caption[\s\S]+?\[\/caption\]/g, a => {
|
||||
return a.replace(/<br([^>]*)>/g, '<wp-temp-br$1>').replace(/[\r\n\t]+/, '');
|
||||
});
|
||||
}
|
||||
|
||||
// Normalize white space characters before and after block tags.
|
||||
html = html.replace(new RegExp('\\s*</(' + blocklist1 + ')>\\s*', 'g'), '</$1>\n');
|
||||
html = html.replace(new RegExp('\\s*<((?:' + blocklist1 + ')(?: [^>]*)?)>', 'g'), '\n<$1>');
|
||||
|
||||
// Mark </p> if it has any attributes.
|
||||
html = html.replace(/(<p [^>]+>[\s\S]*?)<\/p>/g, '$1</p#>');
|
||||
|
||||
// Preserve the first <p> inside a <div>.
|
||||
html = html.replace(/<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n');
|
||||
|
||||
// Remove paragraph tags.
|
||||
html = html.replace(/\s*<p>/gi, '');
|
||||
html = html.replace(/\s*<\/p>\s*/gi, '\n\n');
|
||||
|
||||
// Normalize white space chars and remove multiple line breaks.
|
||||
html = html.replace(/\n[\s\u00a0]+\n/g, '\n\n');
|
||||
|
||||
// Replace <br> tags with line breaks.
|
||||
html = html.replace(/(\s*)<br ?\/?>\s*/gi, (_, space) => {
|
||||
if (space && space.indexOf('\n') !== -1) {
|
||||
return '\n\n';
|
||||
}
|
||||
return '\n';
|
||||
});
|
||||
|
||||
// Fix line breaks around <div>.
|
||||
html = html.replace(/\s*<div/g, '\n<div');
|
||||
html = html.replace(/<\/div>\s*/g, '</div>\n');
|
||||
|
||||
// Fix line breaks around caption shortcodes.
|
||||
html = html.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n');
|
||||
html = html.replace(/caption\]\n\n+\[caption/g, 'caption]\n\n[caption');
|
||||
|
||||
// Pad block elements tags with a line break.
|
||||
html = html.replace(new RegExp('\\s*<((?:' + blocklist2 + ')(?: [^>]*)?)\\s*>', 'g'), '\n<$1>');
|
||||
html = html.replace(new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g'), '</$1>\n');
|
||||
|
||||
// Indent <li>, <dt> and <dd> tags.
|
||||
html = html.replace(/<((li|dt|dd)[^>]*)>/g, ' \t<$1>');
|
||||
|
||||
// Fix line breaks around <select> and <option>.
|
||||
if (html.indexOf('<option') !== -1) {
|
||||
html = html.replace(/\s*<option/g, '\n<option');
|
||||
html = html.replace(/\s*<\/select>/g, '\n</select>');
|
||||
}
|
||||
|
||||
// Pad <hr> with two line breaks.
|
||||
if (html.indexOf('<hr') !== -1) {
|
||||
html = html.replace(/\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n');
|
||||
}
|
||||
|
||||
// Remove line breaks in <object> tags.
|
||||
if (html.indexOf('<object') !== -1) {
|
||||
html = html.replace(/<object[\s\S]+?<\/object>/g, a => {
|
||||
return a.replace(/[\r\n]+/g, '');
|
||||
});
|
||||
}
|
||||
|
||||
// Unmark special paragraph closing tags.
|
||||
html = html.replace(/<\/p#>/g, '</p>\n');
|
||||
|
||||
// Pad remaining <p> tags whit a line break.
|
||||
html = html.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g, '\n$1');
|
||||
|
||||
// Trim.
|
||||
html = html.replace(/^\s+/, '');
|
||||
html = html.replace(/[\s\u00a0]+$/, '');
|
||||
if (preserveLinebreaks) {
|
||||
html = html.replace(/<wp-line-break>/g, '\n');
|
||||
}
|
||||
if (preserveBr) {
|
||||
html = html.replace(/<wp-temp-br([^>]*)>/g, '<br$1>');
|
||||
}
|
||||
|
||||
// Restore preserved tags.
|
||||
if (preserve.length) {
|
||||
html = html.replace(/<wp-preserve>/g, () => {
|
||||
return (/** @type {string} */preserve.shift()
|
||||
);
|
||||
});
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).autop = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ createBlobURL: function() { return /* binding */ createBlobURL; },
|
||||
/* harmony export */ getBlobByURL: function() { return /* binding */ getBlobByURL; },
|
||||
/* harmony export */ getBlobTypeByURL: function() { return /* binding */ getBlobTypeByURL; },
|
||||
/* harmony export */ isBlobURL: function() { return /* binding */ isBlobURL; },
|
||||
/* harmony export */ revokeBlobURL: function() { return /* binding */ revokeBlobURL; }
|
||||
/* harmony export */ });
|
||||
/**
|
||||
* @type {Record<string, File|undefined>}
|
||||
*/
|
||||
const cache = {};
|
||||
|
||||
/**
|
||||
* Create a blob URL from a file.
|
||||
*
|
||||
* @param {File} file The file to create a blob URL for.
|
||||
*
|
||||
* @return {string} The blob URL.
|
||||
*/
|
||||
function createBlobURL(file) {
|
||||
const url = window.URL.createObjectURL(file);
|
||||
cache[url] = file;
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a file based on a blob URL. The file must have been created by
|
||||
* `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
|
||||
* `undefined`.
|
||||
*
|
||||
* @param {string} url The blob URL.
|
||||
*
|
||||
* @return {File|undefined} The file for the blob URL.
|
||||
*/
|
||||
function getBlobByURL(url) {
|
||||
return cache[url];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a blob type based on URL. The file must have been created by
|
||||
* `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
|
||||
* `undefined`.
|
||||
*
|
||||
* @param {string} url The blob URL.
|
||||
*
|
||||
* @return {string|undefined} The blob type.
|
||||
*/
|
||||
function getBlobTypeByURL(url) {
|
||||
return getBlobByURL(url)?.type.split('/')[0]; // 0: media type , 1: file extension eg ( type: 'image/jpeg' ).
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the resource and file cache from memory.
|
||||
*
|
||||
* @param {string} url The blob URL.
|
||||
*/
|
||||
function revokeBlobURL(url) {
|
||||
if (cache[url]) {
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
delete cache[url];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a url is a blob url.
|
||||
*
|
||||
* @param {string|undefined} url The URL.
|
||||
*
|
||||
* @return {boolean} Is the url a blob url?
|
||||
*/
|
||||
function isBlobURL(url) {
|
||||
if (!url || !url.indexOf) {
|
||||
return false;
|
||||
}
|
||||
return url.indexOf('blob:') === 0;
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).blob = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={d:function(n,t){for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{createBlobURL:function(){return o},getBlobByURL:function(){return r},getBlobTypeByURL:function(){return u},isBlobURL:function(){return c},revokeBlobURL:function(){return i}});const t={};function o(e){const n=window.URL.createObjectURL(e);return t[n]=e,n}function r(e){return t[e]}function u(e){return r(e)?.type.split("/")[0]}function i(e){t[e]&&window.URL.revokeObjectURL(e),delete t[e]}function c(e){return!(!e||!e.indexOf)&&0===e.indexOf("blob:")}(window.wp=window.wp||{}).blob=n}();
|
||||
+2152
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
+61593
File diff suppressed because one or more lines are too long
+41
File diff suppressed because one or more lines are too long
+58133
File diff suppressed because one or more lines are too long
+14
File diff suppressed because one or more lines are too long
@@ -0,0 +1,485 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ parse: function() { return /* binding */ parse; }
|
||||
/* harmony export */ });
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
let document;
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
let offset;
|
||||
/**
|
||||
* @type {ParsedBlock[]}
|
||||
*/
|
||||
let output;
|
||||
/**
|
||||
* @type {ParsedFrame[]}
|
||||
*/
|
||||
let stack;
|
||||
|
||||
/**
|
||||
* @typedef {Object|null} Attributes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ParsedBlock
|
||||
* @property {string|null} blockName Block name.
|
||||
* @property {Attributes} attrs Block attributes.
|
||||
* @property {ParsedBlock[]} innerBlocks Inner blocks.
|
||||
* @property {string} innerHTML Inner HTML.
|
||||
* @property {Array<string|null>} innerContent Inner content.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ParsedFrame
|
||||
* @property {ParsedBlock} block Block.
|
||||
* @property {number} tokenStart Token start.
|
||||
* @property {number} tokenLength Token length.
|
||||
* @property {number} prevOffset Previous offset.
|
||||
* @property {number|null} leadingHtmlStart Leading HTML start.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {'no-more-tokens'|'void-block'|'block-opener'|'block-closer'} TokenType
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {[TokenType, string, Attributes, number, number]} Token
|
||||
*/
|
||||
|
||||
/**
|
||||
* Matches block comment delimiters
|
||||
*
|
||||
* While most of this pattern is straightforward the attribute parsing
|
||||
* incorporates a tricks to make sure we don't choke on specific input
|
||||
*
|
||||
* - since JavaScript has no possessive quantifier or atomic grouping
|
||||
* we are emulating it with a trick
|
||||
*
|
||||
* we want a possessive quantifier or atomic group to prevent backtracking
|
||||
* on the `}`s should we fail to match the remainder of the pattern
|
||||
*
|
||||
* we can emulate this with a positive lookahead and back reference
|
||||
* (a++)*c === ((?=(a+))\1)*c
|
||||
*
|
||||
* let's examine an example:
|
||||
* - /(a+)*c/.test('aaaaaaaaaaaaad') fails after over 49,000 steps
|
||||
* - /(a++)*c/.test('aaaaaaaaaaaaad') fails after 85 steps
|
||||
* - /(?>a+)*c/.test('aaaaaaaaaaaaad') fails after 126 steps
|
||||
*
|
||||
* this is because the possessive `++` and the atomic group `(?>)`
|
||||
* tell the engine that all those `a`s belong together as a single group
|
||||
* and so it won't split it up when stepping backwards to try and match
|
||||
*
|
||||
* if we use /((?=(a+))\1)*c/ then we get the same behavior as the atomic group
|
||||
* or possessive and prevent the backtracking because the `a+` is matched but
|
||||
* not captured. thus, we find the long string of `a`s and remember it, then
|
||||
* reference it as a whole unit inside our pattern
|
||||
*
|
||||
* @see http://instanceof.me/post/52245507631/regex-emulate-atomic-grouping-with-lookahead
|
||||
* @see http://blog.stevenlevithan.com/archives/mimic-atomic-groups
|
||||
* @see https://javascript.info/regexp-infinite-backtracking-problem
|
||||
*
|
||||
* once browsers reliably support atomic grouping or possessive
|
||||
* quantifiers natively we should remove this trick and simplify
|
||||
*
|
||||
* @type {RegExp}
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 4.6.1 added optimization to prevent backtracking on attribute parsing
|
||||
*/
|
||||
const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/g;
|
||||
|
||||
/**
|
||||
* Constructs a block object.
|
||||
*
|
||||
* @param {string|null} blockName
|
||||
* @param {Attributes} attrs
|
||||
* @param {ParsedBlock[]} innerBlocks
|
||||
* @param {string} innerHTML
|
||||
* @param {string[]} innerContent
|
||||
* @return {ParsedBlock} The block object.
|
||||
*/
|
||||
function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
|
||||
return {
|
||||
blockName,
|
||||
attrs,
|
||||
innerBlocks,
|
||||
innerHTML,
|
||||
innerContent
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a freeform block object.
|
||||
*
|
||||
* @param {string} innerHTML
|
||||
* @return {ParsedBlock} The freeform block object.
|
||||
*/
|
||||
function Freeform(innerHTML) {
|
||||
return Block(null, {}, [], innerHTML, [innerHTML]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a frame object.
|
||||
*
|
||||
* @param {ParsedBlock} block
|
||||
* @param {number} tokenStart
|
||||
* @param {number} tokenLength
|
||||
* @param {number} prevOffset
|
||||
* @param {number|null} leadingHtmlStart
|
||||
* @return {ParsedFrame} The frame object.
|
||||
*/
|
||||
function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
||||
return {
|
||||
block,
|
||||
tokenStart,
|
||||
tokenLength,
|
||||
prevOffset: prevOffset || tokenStart + tokenLength,
|
||||
leadingHtmlStart
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Parser function, that converts input HTML into a block based structure.
|
||||
*
|
||||
* @param {string} doc The HTML document to parse.
|
||||
*
|
||||
* @example
|
||||
* Input post:
|
||||
* ```html
|
||||
* <!-- wp:columns {"columns":3} -->
|
||||
* <div class="wp-block-columns has-3-columns"><!-- wp:column -->
|
||||
* <div class="wp-block-column"><!-- wp:paragraph -->
|
||||
* <p>Left</p>
|
||||
* <!-- /wp:paragraph --></div>
|
||||
* <!-- /wp:column -->
|
||||
*
|
||||
* <!-- wp:column -->
|
||||
* <div class="wp-block-column"><!-- wp:paragraph -->
|
||||
* <p><strong>Middle</strong></p>
|
||||
* <!-- /wp:paragraph --></div>
|
||||
* <!-- /wp:column -->
|
||||
*
|
||||
* <!-- wp:column -->
|
||||
* <div class="wp-block-column"></div>
|
||||
* <!-- /wp:column --></div>
|
||||
* <!-- /wp:columns -->
|
||||
* ```
|
||||
*
|
||||
* Parsing code:
|
||||
* ```js
|
||||
* import { parse } from '@wordpress/block-serialization-default-parser';
|
||||
*
|
||||
* parse( post ) === [
|
||||
* {
|
||||
* blockName: "core/columns",
|
||||
* attrs: {
|
||||
* columns: 3
|
||||
* },
|
||||
* innerBlocks: [
|
||||
* {
|
||||
* blockName: "core/column",
|
||||
* attrs: null,
|
||||
* innerBlocks: [
|
||||
* {
|
||||
* blockName: "core/paragraph",
|
||||
* attrs: null,
|
||||
* innerBlocks: [],
|
||||
* innerHTML: "\n<p>Left</p>\n"
|
||||
* }
|
||||
* ],
|
||||
* innerHTML: '\n<div class="wp-block-column"></div>\n'
|
||||
* },
|
||||
* {
|
||||
* blockName: "core/column",
|
||||
* attrs: null,
|
||||
* innerBlocks: [
|
||||
* {
|
||||
* blockName: "core/paragraph",
|
||||
* attrs: null,
|
||||
* innerBlocks: [],
|
||||
* innerHTML: "\n<p><strong>Middle</strong></p>\n"
|
||||
* }
|
||||
* ],
|
||||
* innerHTML: '\n<div class="wp-block-column"></div>\n'
|
||||
* },
|
||||
* {
|
||||
* blockName: "core/column",
|
||||
* attrs: null,
|
||||
* innerBlocks: [],
|
||||
* innerHTML: '\n<div class="wp-block-column"></div>\n'
|
||||
* }
|
||||
* ],
|
||||
* innerHTML: '\n<div class="wp-block-columns has-3-columns">\n\n\n\n</div>\n'
|
||||
* }
|
||||
* ];
|
||||
* ```
|
||||
* @return {ParsedBlock[]} A block-based representation of the input HTML.
|
||||
*/
|
||||
const parse = doc => {
|
||||
document = doc;
|
||||
offset = 0;
|
||||
output = [];
|
||||
stack = [];
|
||||
tokenizer.lastIndex = 0;
|
||||
do {
|
||||
// twiddle our thumbs
|
||||
} while (proceed());
|
||||
return output;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the next token in the input document.
|
||||
*
|
||||
* @return {boolean} Returns true when there is more tokens to parse.
|
||||
*/
|
||||
function proceed() {
|
||||
const stackDepth = stack.length;
|
||||
const next = nextToken();
|
||||
const [tokenType, blockName, attrs, startOffset, tokenLength] = next;
|
||||
|
||||
// We may have some HTML soup before the next block.
|
||||
const leadingHtmlStart = startOffset > offset ? offset : null;
|
||||
switch (tokenType) {
|
||||
case 'no-more-tokens':
|
||||
// If not in a block then flush output.
|
||||
if (0 === stackDepth) {
|
||||
addFreeform();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise we have a problem
|
||||
// This is an error
|
||||
// we have options
|
||||
// - treat it all as freeform text
|
||||
// - assume an implicit closer (easiest when not nesting)
|
||||
|
||||
// For the easy case we'll assume an implicit closer.
|
||||
if (1 === stackDepth) {
|
||||
addBlockFromStack();
|
||||
return false;
|
||||
}
|
||||
|
||||
// For the nested case where it's more difficult we'll
|
||||
// have to assume that multiple closers are missing
|
||||
// and so we'll collapse the whole stack piecewise.
|
||||
while (0 < stack.length) {
|
||||
addBlockFromStack();
|
||||
}
|
||||
return false;
|
||||
case 'void-block':
|
||||
// easy case is if we stumbled upon a void block
|
||||
// in the top-level of the document.
|
||||
if (0 === stackDepth) {
|
||||
if (null !== leadingHtmlStart) {
|
||||
output.push(Freeform(document.substr(leadingHtmlStart, startOffset - leadingHtmlStart)));
|
||||
}
|
||||
output.push(Block(blockName, attrs, [], '', []));
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise we found an inner block.
|
||||
addInnerBlock(Block(blockName, attrs, [], '', []), startOffset, tokenLength);
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
case 'block-opener':
|
||||
// Track all newly-opened blocks on the stack.
|
||||
stack.push(Frame(Block(blockName, attrs, [], '', []), startOffset, tokenLength, startOffset + tokenLength, leadingHtmlStart));
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
case 'block-closer':
|
||||
// If we're missing an opener we're in trouble
|
||||
// This is an error.
|
||||
if (0 === stackDepth) {
|
||||
// We have options
|
||||
// - assume an implicit opener
|
||||
// - assume _this_ is the opener
|
||||
// - give up and close out the document.
|
||||
addFreeform();
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we're not nesting then this is easy - close the block.
|
||||
if (1 === stackDepth) {
|
||||
addBlockFromStack(startOffset);
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise we're nested and we have to close out the current
|
||||
// block and add it as a innerBlock to the parent.
|
||||
const stackTop = /** @type {ParsedFrame} */stack.pop();
|
||||
const html = document.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
|
||||
stackTop.block.innerHTML += html;
|
||||
stackTop.block.innerContent.push(html);
|
||||
stackTop.prevOffset = startOffset + tokenLength;
|
||||
addInnerBlock(stackTop.block, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
default:
|
||||
// This is an error.
|
||||
addFreeform();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse JSON if valid, otherwise return null
|
||||
*
|
||||
* Note that JSON coming from the block comment
|
||||
* delimiters is constrained to be an object
|
||||
* and cannot be things like `true` or `null`
|
||||
*
|
||||
* @param {string} input JSON input string to parse
|
||||
* @return {Object|null} parsed JSON if valid
|
||||
*/
|
||||
function parseJSON(input) {
|
||||
try {
|
||||
return JSON.parse(input);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the next token in the document.
|
||||
*
|
||||
* @return {Token} The next matched token.
|
||||
*/
|
||||
function nextToken() {
|
||||
// Aye the magic
|
||||
// we're using a single RegExp to tokenize the block comment delimiters
|
||||
// we're also using a trick here because the only difference between a
|
||||
// block opener and a block closer is the leading `/` before `wp:` (and
|
||||
// a closer has no attributes). we can trap them both and process the
|
||||
// match back in JavaScript to see which one it was.
|
||||
const matches = tokenizer.exec(document);
|
||||
|
||||
// We have no more tokens.
|
||||
if (null === matches) {
|
||||
return ['no-more-tokens', '', null, 0, 0];
|
||||
}
|
||||
const startedAt = matches.index;
|
||||
const [match, closerMatch, namespaceMatch, nameMatch, attrsMatch /* Internal/unused. */,, voidMatch] = matches;
|
||||
const length = match.length;
|
||||
const isCloser = !!closerMatch;
|
||||
const isVoid = !!voidMatch;
|
||||
const namespace = namespaceMatch || 'core/';
|
||||
const name = namespace + nameMatch;
|
||||
const hasAttrs = !!attrsMatch;
|
||||
const attrs = hasAttrs ? parseJSON(attrsMatch) : {};
|
||||
|
||||
// This state isn't allowed
|
||||
// This is an error.
|
||||
if (isCloser && (isVoid || hasAttrs)) {
|
||||
// We can ignore them since they don't hurt anything
|
||||
// we may warn against this at some point or reject it.
|
||||
}
|
||||
if (isVoid) {
|
||||
return ['void-block', name, attrs, startedAt, length];
|
||||
}
|
||||
if (isCloser) {
|
||||
return ['block-closer', name, null, startedAt, length];
|
||||
}
|
||||
return ['block-opener', name, attrs, startedAt, length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a freeform block to the output.
|
||||
*
|
||||
* @param {number} [rawLength]
|
||||
*/
|
||||
function addFreeform(rawLength) {
|
||||
const length = rawLength ? rawLength : document.length - offset;
|
||||
if (0 === length) {
|
||||
return;
|
||||
}
|
||||
output.push(Freeform(document.substr(offset, length)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds inner block to the parent block.
|
||||
*
|
||||
* @param {ParsedBlock} block
|
||||
* @param {number} tokenStart
|
||||
* @param {number} tokenLength
|
||||
* @param {number} [lastOffset]
|
||||
*/
|
||||
function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
|
||||
const parent = stack[stack.length - 1];
|
||||
parent.block.innerBlocks.push(block);
|
||||
const html = document.substr(parent.prevOffset, tokenStart - parent.prevOffset);
|
||||
if (html) {
|
||||
parent.block.innerHTML += html;
|
||||
parent.block.innerContent.push(html);
|
||||
}
|
||||
parent.block.innerContent.push(null);
|
||||
parent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds block from the stack to the output.
|
||||
*
|
||||
* @param {number} [endOffset]
|
||||
*/
|
||||
function addBlockFromStack(endOffset) {
|
||||
const {
|
||||
block,
|
||||
leadingHtmlStart,
|
||||
prevOffset,
|
||||
tokenStart
|
||||
} = /** @type {ParsedFrame} */stack.pop();
|
||||
const html = endOffset ? document.substr(prevOffset, endOffset - prevOffset) : document.substr(prevOffset);
|
||||
if (html) {
|
||||
block.innerHTML += html;
|
||||
block.innerContent.push(html);
|
||||
}
|
||||
if (null !== leadingHtmlStart) {
|
||||
output.push(Freeform(document.substr(leadingHtmlStart, tokenStart - leadingHtmlStart)));
|
||||
}
|
||||
output.push(block);
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).blockSerializationDefaultParser = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var n={d:function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r:function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},t={};let e,r,o,u;n.r(t),n.d(t,{parse:function(){return i}});const s=/<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/g;function l(n,t,e,r,o){return{blockName:n,attrs:t,innerBlocks:e,innerHTML:r,innerContent:o}}function c(n){return l(null,{},[],n,[n])}const i=n=>{e=n,r=0,o=[],u=[],s.lastIndex=0;do{}while(f());return o};function f(){const n=u.length,t=function(){const n=s.exec(e);if(null===n)return["no-more-tokens","",null,0,0];const t=n.index,[r,o,u,l,c,,i]=n,f=r.length,p=!!o,a=!!i,b=(u||"core/")+l,k=!!c,h=k?function(n){try{return JSON.parse(n)}catch(n){return null}}(c):{};if(a)return["void-block",b,h,t,f];if(p)return["block-closer",b,null,t,f];return["block-opener",b,h,t,f]}(),[i,f,k,h,d]=t,g=h>r?r:null;switch(i){case"no-more-tokens":if(0===n)return p(),!1;if(1===n)return b(),!1;for(;0<u.length;)b();return!1;case"void-block":return 0===n?(null!==g&&o.push(c(e.substr(g,h-g))),o.push(l(f,k,[],"",[])),r=h+d,!0):(a(l(f,k,[],"",[]),h,d),r=h+d,!0);case"block-opener":return u.push(function(n,t,e,r,o){return{block:n,tokenStart:t,tokenLength:e,prevOffset:r||t+e,leadingHtmlStart:o}}(l(f,k,[],"",[]),h,d,h+d,g)),r=h+d,!0;case"block-closer":if(0===n)return p(),!1;if(1===n)return b(h),r=h+d,!0;const t=u.pop(),s=e.substr(t.prevOffset,h-t.prevOffset);return t.block.innerHTML+=s,t.block.innerContent.push(s),t.prevOffset=h+d,a(t.block,t.tokenStart,t.tokenLength,h+d),r=h+d,!0;default:return p(),!1}}function p(n){const t=n||e.length-r;0!==t&&o.push(c(e.substr(r,t)))}function a(n,t,r,o){const s=u[u.length-1];s.block.innerBlocks.push(n);const l=e.substr(s.prevOffset,t-s.prevOffset);l&&(s.block.innerHTML+=l,s.block.innerContent.push(l)),s.block.innerContent.push(null),s.prevOffset=o||t+r}function b(n){const{block:t,leadingHtmlStart:r,prevOffset:s,tokenStart:l}=u.pop(),i=n?e.substr(s,n-s):e.substr(s);i&&(t.innerHTML+=i,t.innerContent.push(i)),null!==r&&o.push(c(e.substr(r,l-r))),o.push(t)}(window.wp=window.wp||{}).blockSerializationDefaultParser=t}();
|
||||
Vendored
+15686
File diff suppressed because one or more lines are too long
Vendored
+10
File diff suppressed because one or more lines are too long
Vendored
+4383
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
Vendored
+81491
File diff suppressed because one or more lines are too long
+55
File diff suppressed because one or more lines are too long
Vendored
+5819
File diff suppressed because it is too large
Load Diff
+9
File diff suppressed because one or more lines are too long
+601
@@ -0,0 +1,601 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
privateApis: function() { return /* reexport */ privateApis; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","commands"]
|
||||
var external_wp_commands_namespaceObject = window["wp"]["commands"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
var external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","primitives"]
|
||||
var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
|
||||
}));
|
||||
/* harmony default export */ var library_plus = (plus);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const symbol = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
|
||||
}));
|
||||
/* harmony default export */ var library_symbol = (symbol);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","url"]
|
||||
var external_wp_url_namespaceObject = window["wp"]["url"];
|
||||
;// CONCATENATED MODULE: external ["wp","router"]
|
||||
var external_wp_router_namespaceObject = window["wp"]["router"];
|
||||
;// CONCATENATED MODULE: external ["wp","coreData"]
|
||||
var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
var external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/hooks.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
function useIsTemplatesAccessible() {
|
||||
return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).canUser('read', 'templates'), []);
|
||||
}
|
||||
function useIsBlockBasedTheme() {
|
||||
return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, []);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","privateApis"]
|
||||
var external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/lock-unlock.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
lock,
|
||||
unlock
|
||||
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/core-commands');
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/admin-navigation-commands.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
const {
|
||||
useHistory
|
||||
} = unlock(external_wp_router_namespaceObject.privateApis);
|
||||
function useAdminNavigationCommands() {
|
||||
const history = useHistory();
|
||||
const isTemplatesAccessible = useIsTemplatesAccessible();
|
||||
const isBlockBasedTheme = useIsBlockBasedTheme();
|
||||
const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
|
||||
(0,external_wp_commands_namespaceObject.useCommand)({
|
||||
name: 'core/add-new-post',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Add new post'),
|
||||
icon: library_plus,
|
||||
callback: () => {
|
||||
document.location.href = 'post-new.php';
|
||||
}
|
||||
});
|
||||
(0,external_wp_commands_namespaceObject.useCommand)({
|
||||
name: 'core/add-new-page',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Add new page'),
|
||||
icon: library_plus,
|
||||
callback: () => {
|
||||
document.location.href = 'post-new.php?post_type=page';
|
||||
}
|
||||
});
|
||||
(0,external_wp_commands_namespaceObject.useCommand)({
|
||||
name: 'core/manage-reusable-blocks',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Patterns'),
|
||||
icon: library_symbol,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
if (isTemplatesAccessible && isBlockBasedTheme) {
|
||||
const args = {
|
||||
path: '/patterns'
|
||||
};
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
}
|
||||
close();
|
||||
} else {
|
||||
document.location.href = 'edit.php?post_type=wp_block';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const post = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z"
|
||||
}));
|
||||
/* harmony default export */ var library_post = (post);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const page = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z"
|
||||
}));
|
||||
/* harmony default export */ var library_page = (page);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
|
||||
}));
|
||||
/* harmony default export */ var library_layout = (layout);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol-filled.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const symbolFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
|
||||
}));
|
||||
/* harmony default export */ var symbol_filled = (symbolFilled);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/navigation.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const navigation = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
viewBox: "0 0 24 24",
|
||||
xmlns: "http://www.w3.org/2000/svg"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z"
|
||||
}));
|
||||
/* harmony default export */ var library_navigation = (navigation);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/styles.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const styles = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
viewBox: "0 0 24 24",
|
||||
xmlns: "http://www.w3.org/2000/svg"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z"
|
||||
}));
|
||||
/* harmony default export */ var library_styles = (styles);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/utils/order-entity-records-by-search.js
|
||||
function orderEntityRecordsBySearch(records = [], search = '') {
|
||||
if (!Array.isArray(records) || !records.length) {
|
||||
return [];
|
||||
}
|
||||
if (!search) {
|
||||
return records;
|
||||
}
|
||||
const priority = [];
|
||||
const nonPriority = [];
|
||||
for (let i = 0; i < records.length; i++) {
|
||||
const record = records[i];
|
||||
if (record?.title?.raw?.toLowerCase()?.includes(search?.toLowerCase())) {
|
||||
priority.push(record);
|
||||
} else {
|
||||
nonPriority.push(record);
|
||||
}
|
||||
}
|
||||
return priority.concat(nonPriority);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/site-editor-navigation-commands.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const {
|
||||
useHistory: site_editor_navigation_commands_useHistory,
|
||||
useLocation
|
||||
} = unlock(external_wp_router_namespaceObject.privateApis);
|
||||
const icons = {
|
||||
post: library_post,
|
||||
page: library_page,
|
||||
wp_template: library_layout,
|
||||
wp_template_part: symbol_filled
|
||||
};
|
||||
const getNavigationCommandLoaderPerPostType = postType => function useNavigationCommandLoader({
|
||||
search
|
||||
}) {
|
||||
const history = site_editor_navigation_commands_useHistory();
|
||||
const isBlockBasedTheme = useIsBlockBasedTheme();
|
||||
const {
|
||||
records,
|
||||
isLoading
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
const {
|
||||
getEntityRecords
|
||||
} = select(external_wp_coreData_namespaceObject.store);
|
||||
const query = {
|
||||
search: !!search ? search : undefined,
|
||||
per_page: 10,
|
||||
orderby: search ? 'relevance' : 'date',
|
||||
status: ['publish', 'future', 'draft', 'pending', 'private']
|
||||
};
|
||||
return {
|
||||
records: getEntityRecords('postType', postType, query),
|
||||
isLoading: !select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecords', ['postType', postType, query])
|
||||
};
|
||||
}, [search]);
|
||||
const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
return (records !== null && records !== void 0 ? records : []).map(record => {
|
||||
const command = {
|
||||
name: postType + '-' + record.id,
|
||||
searchLabel: record.title?.rendered + ' ' + record.id,
|
||||
label: record.title?.rendered ? record.title?.rendered : (0,external_wp_i18n_namespaceObject.__)('(no title)'),
|
||||
icon: icons[postType]
|
||||
};
|
||||
if (postType === 'post' || postType === 'page' && !isBlockBasedTheme) {
|
||||
return {
|
||||
...command,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
post: record.id,
|
||||
action: 'edit'
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', args);
|
||||
document.location = targetUrl;
|
||||
close();
|
||||
}
|
||||
};
|
||||
}
|
||||
const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
|
||||
const extraArgs = isSiteEditor ? {
|
||||
canvas: (0,external_wp_url_namespaceObject.getQueryArg)(window.location.href, 'canvas')
|
||||
} : {};
|
||||
return {
|
||||
...command,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
postType,
|
||||
postId: record.id,
|
||||
...extraArgs
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = targetUrl;
|
||||
}
|
||||
close();
|
||||
}
|
||||
};
|
||||
});
|
||||
}, [records, isBlockBasedTheme, history]);
|
||||
return {
|
||||
commands,
|
||||
isLoading
|
||||
};
|
||||
};
|
||||
const getNavigationCommandLoaderPerTemplate = templateType => function useNavigationCommandLoader({
|
||||
search
|
||||
}) {
|
||||
const history = site_editor_navigation_commands_useHistory();
|
||||
const location = useLocation();
|
||||
const isPatternsPage = location?.params?.path === '/patterns' || location?.params?.postType === 'wp_block';
|
||||
const didAccessPatternsPage = !!location?.params?.didAccessPatternsPage;
|
||||
const isBlockBasedTheme = useIsBlockBasedTheme();
|
||||
const {
|
||||
records,
|
||||
isLoading
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
const {
|
||||
getEntityRecords
|
||||
} = select(external_wp_coreData_namespaceObject.store);
|
||||
const query = {
|
||||
per_page: -1
|
||||
};
|
||||
return {
|
||||
records: getEntityRecords('postType', templateType, query),
|
||||
isLoading: !select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecords', ['postType', templateType, query])
|
||||
};
|
||||
}, []);
|
||||
|
||||
/*
|
||||
* wp_template and wp_template_part endpoints do not support per_page or orderby parameters.
|
||||
* We need to sort the results based on the search query to avoid removing relevant
|
||||
* records below using .slice().
|
||||
*/
|
||||
const orderedRecords = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
return orderEntityRecordsBySearch(records, search).slice(0, 10);
|
||||
}, [records, search]);
|
||||
const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
if (!isBlockBasedTheme && !templateType === 'wp_template_part') {
|
||||
return [];
|
||||
}
|
||||
return orderedRecords.map(record => {
|
||||
const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
|
||||
const extraArgs = isSiteEditor ? {
|
||||
canvas: (0,external_wp_url_namespaceObject.getQueryArg)(window.location.href, 'canvas')
|
||||
} : {};
|
||||
return {
|
||||
name: templateType + '-' + record.id,
|
||||
searchLabel: record.title?.rendered + ' ' + record.id,
|
||||
label: record.title?.rendered ? record.title?.rendered : (0,external_wp_i18n_namespaceObject.__)('(no title)'),
|
||||
icon: icons[templateType],
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
postType: templateType,
|
||||
postId: record.id,
|
||||
didAccessPatternsPage: !isBlockBasedTheme && (isPatternsPage || didAccessPatternsPage) ? 1 : undefined,
|
||||
...extraArgs
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = targetUrl;
|
||||
}
|
||||
close();
|
||||
}
|
||||
};
|
||||
});
|
||||
}, [isBlockBasedTheme, orderedRecords, history]);
|
||||
return {
|
||||
commands,
|
||||
isLoading
|
||||
};
|
||||
};
|
||||
const usePageNavigationCommandLoader = getNavigationCommandLoaderPerPostType('page');
|
||||
const usePostNavigationCommandLoader = getNavigationCommandLoaderPerPostType('post');
|
||||
const useTemplateNavigationCommandLoader = getNavigationCommandLoaderPerTemplate('wp_template');
|
||||
const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerTemplate('wp_template_part');
|
||||
function useSiteEditorBasicNavigationCommands() {
|
||||
const history = site_editor_navigation_commands_useHistory();
|
||||
const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
|
||||
const isTemplatesAccessible = useIsTemplatesAccessible();
|
||||
const isBlockBasedTheme = useIsBlockBasedTheme();
|
||||
const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
const result = [];
|
||||
if (!isTemplatesAccessible || !isBlockBasedTheme) {
|
||||
return result;
|
||||
}
|
||||
result.push({
|
||||
name: 'core/edit-site/open-navigation',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
|
||||
icon: library_navigation,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
path: '/navigation'
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = targetUrl;
|
||||
}
|
||||
close();
|
||||
}
|
||||
});
|
||||
result.push({
|
||||
name: 'core/edit-site/open-styles',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Styles'),
|
||||
icon: library_styles,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
path: '/wp_global_styles'
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = targetUrl;
|
||||
}
|
||||
close();
|
||||
}
|
||||
});
|
||||
result.push({
|
||||
name: 'core/edit-site/open-pages',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Pages'),
|
||||
icon: library_page,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
path: '/page'
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = targetUrl;
|
||||
}
|
||||
close();
|
||||
}
|
||||
});
|
||||
result.push({
|
||||
name: 'core/edit-site/open-templates',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
|
||||
icon: library_layout,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
path: '/wp_template'
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = targetUrl;
|
||||
}
|
||||
close();
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}, [history, isSiteEditor, isTemplatesAccessible, isBlockBasedTheme]);
|
||||
return {
|
||||
commands,
|
||||
isLoading: false
|
||||
};
|
||||
}
|
||||
function useSiteEditorNavigationCommands() {
|
||||
(0,external_wp_commands_namespaceObject.useCommandLoader)({
|
||||
name: 'core/edit-site/navigate-pages',
|
||||
hook: usePageNavigationCommandLoader
|
||||
});
|
||||
(0,external_wp_commands_namespaceObject.useCommandLoader)({
|
||||
name: 'core/edit-site/navigate-posts',
|
||||
hook: usePostNavigationCommandLoader
|
||||
});
|
||||
(0,external_wp_commands_namespaceObject.useCommandLoader)({
|
||||
name: 'core/edit-site/navigate-templates',
|
||||
hook: useTemplateNavigationCommandLoader
|
||||
});
|
||||
(0,external_wp_commands_namespaceObject.useCommandLoader)({
|
||||
name: 'core/edit-site/navigate-template-parts',
|
||||
hook: useTemplatePartNavigationCommandLoader
|
||||
});
|
||||
(0,external_wp_commands_namespaceObject.useCommandLoader)({
|
||||
name: 'core/edit-site/basic-navigation',
|
||||
hook: useSiteEditorBasicNavigationCommands,
|
||||
context: 'site-editor'
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/private-apis.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function useCommands() {
|
||||
useAdminNavigationCommands();
|
||||
useSiteEditorNavigationCommands();
|
||||
}
|
||||
const privateApis = {};
|
||||
lock(privateApis, {
|
||||
useCommands
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/index.js
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).coreCommands = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
File diff suppressed because one or more lines are too long
Vendored
+7553
File diff suppressed because it is too large
Load Diff
+2
File diff suppressed because one or more lines are too long
+3222
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
+217
@@ -0,0 +1,217 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
__unstableAwaitPromise: function() { return /* binding */ __unstableAwaitPromise; },
|
||||
apiFetch: function() { return /* binding */ apiFetch; },
|
||||
controls: function() { return /* binding */ controls; },
|
||||
dispatch: function() { return /* binding */ dispatch; },
|
||||
select: function() { return /* binding */ build_module_select; },
|
||||
syncSelect: function() { return /* binding */ syncSelect; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","apiFetch"]
|
||||
var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
|
||||
var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
var external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: external ["wp","deprecated"]
|
||||
var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
|
||||
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/data-controls/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Dispatches a control action for triggering an api fetch call.
|
||||
*
|
||||
* @param {Object} request Arguments for the fetch request.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { apiFetch } from '@wordpress/data-controls';
|
||||
*
|
||||
* // Action generator using apiFetch
|
||||
* export function* myAction() {
|
||||
* const path = '/v2/my-api/items';
|
||||
* const items = yield apiFetch( { path } );
|
||||
* // do something with the items.
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @return {Object} The control descriptor.
|
||||
*/
|
||||
function apiFetch(request) {
|
||||
return {
|
||||
type: 'API_FETCH',
|
||||
request
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Control for resolving a selector in a registered data store.
|
||||
* Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.
|
||||
*
|
||||
* @param storeNameOrDescriptor The store object or identifier.
|
||||
* @param selectorName The selector name.
|
||||
* @param args Arguments passed without change to the `@wordpress/data` control.
|
||||
*/
|
||||
function build_module_select(storeNameOrDescriptor, selectorName, ...args) {
|
||||
external_wp_deprecated_default()('`select` control in `@wordpress/data-controls`', {
|
||||
since: '5.7',
|
||||
alternative: 'built-in `resolveSelect` control in `@wordpress/data`'
|
||||
});
|
||||
return external_wp_data_namespaceObject.controls.resolveSelect(storeNameOrDescriptor, selectorName, ...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Control for calling a selector in a registered data store.
|
||||
* Alias for the `select` built-in control in the `@wordpress/data` package.
|
||||
*
|
||||
* @param storeNameOrDescriptor The store object or identifier.
|
||||
* @param selectorName The selector name.
|
||||
* @param args Arguments passed without change to the `@wordpress/data` control.
|
||||
*/
|
||||
function syncSelect(storeNameOrDescriptor, selectorName, ...args) {
|
||||
external_wp_deprecated_default()('`syncSelect` control in `@wordpress/data-controls`', {
|
||||
since: '5.7',
|
||||
alternative: 'built-in `select` control in `@wordpress/data`'
|
||||
});
|
||||
return external_wp_data_namespaceObject.controls.select(storeNameOrDescriptor, selectorName, ...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Control for dispatching an action in a registered data store.
|
||||
* Alias for the `dispatch` control in the `@wordpress/data` package.
|
||||
*
|
||||
* @param storeNameOrDescriptor The store object or identifier.
|
||||
* @param actionName The action name.
|
||||
* @param args Arguments passed without change to the `@wordpress/data` control.
|
||||
*/
|
||||
function dispatch(storeNameOrDescriptor, actionName, ...args) {
|
||||
external_wp_deprecated_default()('`dispatch` control in `@wordpress/data-controls`', {
|
||||
since: '5.7',
|
||||
alternative: 'built-in `dispatch` control in `@wordpress/data`'
|
||||
});
|
||||
return external_wp_data_namespaceObject.controls.dispatch(storeNameOrDescriptor, actionName, ...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches a control action for awaiting on a promise to be resolved.
|
||||
*
|
||||
* @param {Object} promise Promise to wait for.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __unstableAwaitPromise } from '@wordpress/data-controls';
|
||||
*
|
||||
* // Action generator using apiFetch
|
||||
* export function* myAction() {
|
||||
* const promise = getItemsAsync();
|
||||
* const items = yield __unstableAwaitPromise( promise );
|
||||
* // do something with the items.
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @return {Object} The control descriptor.
|
||||
*/
|
||||
const __unstableAwaitPromise = function (promise) {
|
||||
return {
|
||||
type: 'AWAIT_PROMISE',
|
||||
promise
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The default export is what you use to register the controls with your custom
|
||||
* store.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // WordPress dependencies
|
||||
* import { controls } from '@wordpress/data-controls';
|
||||
* import { registerStore } from '@wordpress/data';
|
||||
*
|
||||
* // Internal dependencies
|
||||
* import reducer from './reducer';
|
||||
* import * as selectors from './selectors';
|
||||
* import * as actions from './actions';
|
||||
* import * as resolvers from './resolvers';
|
||||
*
|
||||
* registerStore( 'my-custom-store', {
|
||||
* reducer,
|
||||
* controls,
|
||||
* actions,
|
||||
* selectors,
|
||||
* resolvers,
|
||||
* } );
|
||||
* ```
|
||||
* @return {Object} An object for registering the default controls with the
|
||||
* store.
|
||||
*/
|
||||
const controls = {
|
||||
AWAIT_PROMISE: ({
|
||||
promise
|
||||
}) => promise,
|
||||
API_FETCH({
|
||||
request
|
||||
}) {
|
||||
return external_wp_apiFetch_default()(request);
|
||||
}
|
||||
};
|
||||
|
||||
(window.wp = window.wp || {}).dataControls = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var t={n:function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,{a:e}),e},d:function(n,e){for(var r in e)t.o(e,r)&&!t.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:e[r]})},o:function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{__unstableAwaitPromise:function(){return d},apiFetch:function(){return u},controls:function(){return p},dispatch:function(){return l},select:function(){return s},syncSelect:function(){return a}});var e=window.wp.apiFetch,r=t.n(e),o=window.wp.data,i=window.wp.deprecated,c=t.n(i);function u(t){return{type:"API_FETCH",request:t}}function s(t,n,...e){return c()("`select` control in `@wordpress/data-controls`",{since:"5.7",alternative:"built-in `resolveSelect` control in `@wordpress/data`"}),o.controls.resolveSelect(t,n,...e)}function a(t,n,...e){return c()("`syncSelect` control in `@wordpress/data-controls`",{since:"5.7",alternative:"built-in `select` control in `@wordpress/data`"}),o.controls.select(t,n,...e)}function l(t,n,...e){return c()("`dispatch` control in `@wordpress/data-controls`",{since:"5.7",alternative:"built-in `dispatch` control in `@wordpress/data`"}),o.controls.dispatch(t,n,...e)}const d=function(t){return{type:"AWAIT_PROMISE",promise:t}},p={AWAIT_PROMISE:({promise:t})=>t,API_FETCH({request:t}){return r()(t)}};(window.wp=window.wp||{}).dataControls=n}();
|
||||
Vendored
+4791
File diff suppressed because it is too large
Load Diff
Vendored
+9
File diff suppressed because one or more lines are too long
Vendored
+1777
File diff suppressed because one or more lines are too long
Vendored
+12
File diff suppressed because one or more lines are too long
Vendored
+123
@@ -0,0 +1,123 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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); }
|
||||
/******/ }();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
"default": function() { return /* binding */ deprecated; }
|
||||
});
|
||||
|
||||
// UNUSED EXPORTS: logged
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","hooks"]
|
||||
var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/deprecated/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Object map tracking messages which have been logged, for use in ensuring a
|
||||
* message is only logged once.
|
||||
*
|
||||
* @type {Record<string, true | undefined>}
|
||||
*/
|
||||
const logged = Object.create(null);
|
||||
|
||||
/**
|
||||
* Logs a message to notify developers about a deprecated feature.
|
||||
*
|
||||
* @param {string} feature Name of the deprecated feature.
|
||||
* @param {Object} [options] Personalisation options
|
||||
* @param {string} [options.since] Version in which the feature was deprecated.
|
||||
* @param {string} [options.version] Version in which the feature will be removed.
|
||||
* @param {string} [options.alternative] Feature to use instead
|
||||
* @param {string} [options.plugin] Plugin name if it's a plugin feature
|
||||
* @param {string} [options.link] Link to documentation
|
||||
* @param {string} [options.hint] Additional message to help transition away from the deprecated feature.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import deprecated from '@wordpress/deprecated';
|
||||
*
|
||||
* deprecated( 'Eating meat', {
|
||||
* since: '2019.01.01'
|
||||
* version: '2020.01.01',
|
||||
* alternative: 'vegetables',
|
||||
* plugin: 'the earth',
|
||||
* hint: 'You may find it beneficial to transition gradually.',
|
||||
* } );
|
||||
*
|
||||
* // Logs: 'Eating meat is deprecated since version 2019.01.01 and will be removed from the earth in version 2020.01.01. Please use vegetables instead. Note: You may find it beneficial to transition gradually.'
|
||||
* ```
|
||||
*/
|
||||
function deprecated(feature, options = {}) {
|
||||
const {
|
||||
since,
|
||||
version,
|
||||
alternative,
|
||||
plugin,
|
||||
link,
|
||||
hint
|
||||
} = options;
|
||||
const pluginMessage = plugin ? ` from ${plugin}` : '';
|
||||
const sinceMessage = since ? ` since version ${since}` : '';
|
||||
const versionMessage = version ? ` and will be removed${pluginMessage} in version ${version}` : '';
|
||||
const useInsteadMessage = alternative ? ` Please use ${alternative} instead.` : '';
|
||||
const linkMessage = link ? ` See: ${link}` : '';
|
||||
const hintMessage = hint ? ` Note: ${hint}` : '';
|
||||
const message = `${feature} is deprecated${sinceMessage}${versionMessage}.${useInsteadMessage}${linkMessage}${hintMessage}`;
|
||||
|
||||
// Skip if already logged.
|
||||
if (message in logged) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires whenever a deprecated feature is encountered
|
||||
*
|
||||
* @param {string} feature Name of the deprecated feature.
|
||||
* @param {?Object} options Personalisation options
|
||||
* @param {string} options.since Version in which the feature was deprecated.
|
||||
* @param {?string} options.version Version in which the feature will be removed.
|
||||
* @param {?string} options.alternative Feature to use instead
|
||||
* @param {?string} options.plugin Plugin name if it's a plugin feature
|
||||
* @param {?string} options.link Link to documentation
|
||||
* @param {?string} options.hint Additional message to help transition away from the deprecated feature.
|
||||
* @param {?string} message Message sent to console.warn
|
||||
*/
|
||||
(0,external_wp_hooks_namespaceObject.doAction)('deprecated', feature, options, message);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(message);
|
||||
logged[message] = true;
|
||||
}
|
||||
|
||||
/** @typedef {import('utility-types').NonUndefined<Parameters<typeof deprecated>[1]>} DeprecatedOptions */
|
||||
|
||||
(window.wp = window.wp || {}).deprecated = __webpack_exports__["default"];
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={d:function(n,t){for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)}},n={};e.d(n,{default:function(){return i}});var t=window.wp.hooks;const o=Object.create(null);function i(e,n={}){const{since:i,version:r,alternative:c,plugin:a,link:d,hint:s}=n,l=`${e} is deprecated${i?` since version ${i}`:""}${r?` and will be removed${a?` from ${a}`:""} in version ${r}`:""}.${c?` Please use ${c} instead.`:""}${d?` See: ${d}`:""}${s?` Note: ${s}`:""}`;l in o||((0,t.doAction)("deprecated",e,n,l),console.warn(l),o[l]=!0)}(window.wp=window.wp||{}).deprecated=n.default}();
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
+76
@@ -0,0 +1,76 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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); }
|
||||
/******/ }();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": function() { return /* binding */ domReady; }
|
||||
/* harmony export */ });
|
||||
/**
|
||||
* @typedef {() => void} Callback
|
||||
*
|
||||
* TODO: Remove this typedef and inline `() => void` type.
|
||||
*
|
||||
* This typedef is used so that a descriptive type is provided in our
|
||||
* automatically generated documentation.
|
||||
*
|
||||
* An in-line type `() => void` would be preferable, but the generated
|
||||
* documentation is `null` in that case.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/issues/18045
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specify a function to execute when the DOM is fully loaded.
|
||||
*
|
||||
* @param {Callback} callback A function to execute after the DOM is ready.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import domReady from '@wordpress/dom-ready';
|
||||
*
|
||||
* domReady( function() {
|
||||
* //do something after DOM loads.
|
||||
* } );
|
||||
* ```
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function domReady(callback) {
|
||||
if (typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
if (document.readyState === 'complete' ||
|
||||
// DOMContentLoaded + Images/Styles/etc loaded, so we call directly.
|
||||
document.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.
|
||||
) {
|
||||
return void callback();
|
||||
}
|
||||
|
||||
// DOMContentLoaded has not fired yet, delay callback until then.
|
||||
document.addEventListener('DOMContentLoaded', callback);
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).domReady = __webpack_exports__["default"];
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t={};function n(e){"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}e.d(t,{default:function(){return n}}),(window.wp=window.wp||{}).domReady=t.default}();
|
||||
Vendored
+2014
File diff suppressed because it is too large
Load Diff
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
+9778
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
Vendored
+37508
File diff suppressed because one or more lines are too long
+19
File diff suppressed because one or more lines are too long
+4671
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
Vendored
+12854
File diff suppressed because it is too large
Load Diff
Vendored
+12
File diff suppressed because one or more lines are too long
Vendored
+1885
File diff suppressed because it is too large
Load Diff
+9
File diff suppressed because one or more lines are too long
+193
@@ -0,0 +1,193 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
escapeAmpersand: function() { return /* binding */ escapeAmpersand; },
|
||||
escapeAttribute: function() { return /* binding */ escapeAttribute; },
|
||||
escapeEditableHTML: function() { return /* binding */ escapeEditableHTML; },
|
||||
escapeHTML: function() { return /* binding */ escapeHTML; },
|
||||
escapeLessThan: function() { return /* binding */ escapeLessThan; },
|
||||
escapeQuotationMark: function() { return /* binding */ escapeQuotationMark; },
|
||||
isValidAttributeName: function() { return /* binding */ isValidAttributeName; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/escape-html/build-module/escape-greater.js
|
||||
/**
|
||||
* Returns a string with greater-than sign replaced.
|
||||
*
|
||||
* Note that if a resolution for Trac#45387 comes to fruition, it is no longer
|
||||
* necessary for `__unstableEscapeGreaterThan` to exist.
|
||||
*
|
||||
* See: https://core.trac.wordpress.org/ticket/45387
|
||||
*
|
||||
* @param {string} value Original string.
|
||||
*
|
||||
* @return {string} Escaped string.
|
||||
*/
|
||||
function __unstableEscapeGreaterThan(value) {
|
||||
return value.replace(/>/g, '>');
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/escape-html/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Regular expression matching invalid attribute names.
|
||||
*
|
||||
* "Attribute names must consist of one or more characters other than controls,
|
||||
* U+0020 SPACE, U+0022 ("), U+0027 ('), U+003E (>), U+002F (/), U+003D (=),
|
||||
* and noncharacters."
|
||||
*
|
||||
* @see https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
||||
*
|
||||
* @type {RegExp}
|
||||
*/
|
||||
const REGEXP_INVALID_ATTRIBUTE_NAME = /[\u007F-\u009F "'>/="\uFDD0-\uFDEF]/;
|
||||
|
||||
/**
|
||||
* Returns a string with ampersands escaped. Note that this is an imperfect
|
||||
* implementation, where only ampersands which do not appear as a pattern of
|
||||
* named, decimal, or hexadecimal character references are escaped. Invalid
|
||||
* named references (i.e. ambiguous ampersand) are still permitted.
|
||||
*
|
||||
* @see https://w3c.github.io/html/syntax.html#character-references
|
||||
* @see https://w3c.github.io/html/syntax.html#ambiguous-ampersand
|
||||
* @see https://w3c.github.io/html/syntax.html#named-character-references
|
||||
*
|
||||
* @param {string} value Original string.
|
||||
*
|
||||
* @return {string} Escaped string.
|
||||
*/
|
||||
function escapeAmpersand(value) {
|
||||
return value.replace(/&(?!([a-z0-9]+|#[0-9]+|#x[a-f0-9]+);)/gi, '&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string with quotation marks replaced.
|
||||
*
|
||||
* @param {string} value Original string.
|
||||
*
|
||||
* @return {string} Escaped string.
|
||||
*/
|
||||
function escapeQuotationMark(value) {
|
||||
return value.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string with less-than sign replaced.
|
||||
*
|
||||
* @param {string} value Original string.
|
||||
*
|
||||
* @return {string} Escaped string.
|
||||
*/
|
||||
function escapeLessThan(value) {
|
||||
return value.replace(/</g, '<');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an escaped attribute value.
|
||||
*
|
||||
* @see https://w3c.github.io/html/syntax.html#elements-attributes
|
||||
*
|
||||
* "[...] the text cannot contain an ambiguous ampersand [...] must not contain
|
||||
* any literal U+0022 QUOTATION MARK characters (")"
|
||||
*
|
||||
* Note we also escape the greater than symbol, as this is used by wptexturize to
|
||||
* split HTML strings. This is a WordPress specific fix
|
||||
*
|
||||
* Note that if a resolution for Trac#45387 comes to fruition, it is no longer
|
||||
* necessary for `__unstableEscapeGreaterThan` to be used.
|
||||
*
|
||||
* See: https://core.trac.wordpress.org/ticket/45387
|
||||
*
|
||||
* @param {string} value Attribute value.
|
||||
*
|
||||
* @return {string} Escaped attribute value.
|
||||
*/
|
||||
function escapeAttribute(value) {
|
||||
return __unstableEscapeGreaterThan(escapeQuotationMark(escapeAmpersand(value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an escaped HTML element value.
|
||||
*
|
||||
* @see https://w3c.github.io/html/syntax.html#writing-html-documents-elements
|
||||
*
|
||||
* "the text must not contain the character U+003C LESS-THAN SIGN (<) or an
|
||||
* ambiguous ampersand."
|
||||
*
|
||||
* @param {string} value Element value.
|
||||
*
|
||||
* @return {string} Escaped HTML element value.
|
||||
*/
|
||||
function escapeHTML(value) {
|
||||
return escapeLessThan(escapeAmpersand(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an escaped Editable HTML element value. This is different from
|
||||
* `escapeHTML`, because for editable HTML, ALL ampersands must be escaped in
|
||||
* order to render the content correctly on the page.
|
||||
*
|
||||
* @param {string} value Element value.
|
||||
*
|
||||
* @return {string} Escaped HTML element value.
|
||||
*/
|
||||
function escapeEditableHTML(value) {
|
||||
return escapeLessThan(value.replace(/&/g, '&'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given attribute name is valid, or false otherwise.
|
||||
*
|
||||
* @param {string} name Attribute name to test.
|
||||
*
|
||||
* @return {boolean} Whether attribute is valid.
|
||||
*/
|
||||
function isValidAttributeName(name) {
|
||||
return !REGEXP_INVALID_ATTRIBUTE_NAME.test(name);
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).escapeHtml = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={d:function(n,t){for(var r in t)e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{escapeAmpersand:function(){return r},escapeAttribute:function(){return c},escapeEditableHTML:function(){return a},escapeHTML:function(){return i},escapeLessThan:function(){return o},escapeQuotationMark:function(){return u},isValidAttributeName:function(){return f}});const t=/[\u007F-\u009F "'>/="\uFDD0-\uFDEF]/;function r(e){return e.replace(/&(?!([a-z0-9]+|#[0-9]+|#x[a-f0-9]+);)/gi,"&")}function u(e){return e.replace(/"/g,""")}function o(e){return e.replace(/</g,"<")}function c(e){return function(e){return e.replace(/>/g,">")}(u(r(e)))}function i(e){return o(r(e))}function a(e){return o(e.replace(/&/g,"&"))}function f(e){return!t.test(e)}(window.wp=window.wp||{}).escapeHtml=n}();
|
||||
+1851
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Vendored
+594
@@ -0,0 +1,594 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
actions: function() { return /* binding */ actions; },
|
||||
addAction: function() { return /* binding */ addAction; },
|
||||
addFilter: function() { return /* binding */ addFilter; },
|
||||
applyFilters: function() { return /* binding */ applyFilters; },
|
||||
createHooks: function() { return /* reexport */ build_module_createHooks; },
|
||||
currentAction: function() { return /* binding */ currentAction; },
|
||||
currentFilter: function() { return /* binding */ currentFilter; },
|
||||
defaultHooks: function() { return /* binding */ defaultHooks; },
|
||||
didAction: function() { return /* binding */ didAction; },
|
||||
didFilter: function() { return /* binding */ didFilter; },
|
||||
doAction: function() { return /* binding */ doAction; },
|
||||
doingAction: function() { return /* binding */ doingAction; },
|
||||
doingFilter: function() { return /* binding */ doingFilter; },
|
||||
filters: function() { return /* binding */ filters; },
|
||||
hasAction: function() { return /* binding */ hasAction; },
|
||||
hasFilter: function() { return /* binding */ hasFilter; },
|
||||
removeAction: function() { return /* binding */ removeAction; },
|
||||
removeAllActions: function() { return /* binding */ removeAllActions; },
|
||||
removeAllFilters: function() { return /* binding */ removeAllFilters; },
|
||||
removeFilter: function() { return /* binding */ removeFilter; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./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 */ var build_module_validateNamespace = (validateNamespace);
|
||||
|
||||
;// CONCATENATED MODULE: ./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 */ var build_module_validateHookName = (validateHookName);
|
||||
|
||||
;// CONCATENATED MODULE: ./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, priority = 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 */ var build_module_createAddHook = (createAddHook);
|
||||
|
||||
;// CONCATENATED MODULE: ./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, removeAll = 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 */ var build_module_createRemoveHook = (createRemoveHook);
|
||||
|
||||
;// CONCATENATED MODULE: ./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 */ var build_module_createHasHook = (createHasHook);
|
||||
|
||||
;// CONCATENATED MODULE: ./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[]) => undefined|unknown} Function that runs hook callbacks.
|
||||
*/
|
||||
function createRunHook(hooks, storeKey, returnFirstArg = false) {
|
||||
return function runHooks(hookName, ...args) {
|
||||
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) {}
|
||||
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];
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
/* harmony default export */ var build_module_createRunHook = (createRunHook);
|
||||
|
||||
;// CONCATENATED MODULE: ./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;
|
||||
const hooksStore = hooks[storeKey];
|
||||
return (_hooksStore$__current = hooksStore.__current[hooksStore.__current.length - 1]?.name) !== null && _hooksStore$__current !== void 0 ? _hooksStore$__current : null;
|
||||
};
|
||||
}
|
||||
/* harmony default export */ var build_module_createCurrentHook = (createCurrentHook);
|
||||
|
||||
;// CONCATENATED MODULE: ./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 */ var build_module_createDoingHook = (createDoingHook);
|
||||
|
||||
;// CONCATENATED MODULE: ./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 */ var build_module_createDidHook = (createDidHook);
|
||||
|
||||
;// CONCATENATED MODULE: ./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 */ var build_module_createHooks = (createHooks);
|
||||
|
||||
;// CONCATENATED MODULE: ./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;
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).hooks = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})},o:function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r:function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},t={};n.r(t),n.d(t,{actions:function(){return S},addAction:function(){return m},addFilter:function(){return p},applyFilters:function(){return k},createHooks:function(){return f},currentAction:function(){return w},currentFilter:function(){return I},defaultHooks:function(){return h},didAction:function(){return O},didFilter:function(){return j},doAction:function(){return b},doingAction:function(){return x},doingFilter:function(){return T},filters:function(){return z},hasAction:function(){return _},hasFilter:function(){return y},removeAction:function(){return A},removeAllActions:function(){return F},removeAllFilters:function(){return g},removeFilter:function(){return v}});var r=function(n){return"string"!=typeof n||""===n?(console.error("The namespace must be a non-empty string."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(n)||(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)};var e=function(n){return"string"!=typeof n||""===n?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(n)?(console.error("The hook name cannot begin with `__`."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(n)||(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)};var o=function(n,t){return function(o,i,c,s=10){const u=n[t];if(!e(o))return;if(!r(i))return;if("function"!=typeof c)return void console.error("The hook callback must be a function.");if("number"!=typeof s)return void console.error("If specified, the hook priority must be a number.");const l={callback:c,priority:s,namespace:i};if(u[o]){const n=u[o].handlers;let t;for(t=n.length;t>0&&!(s>=n[t-1].priority);t--);t===n.length?n[t]=l:n.splice(t,0,l),u.__current.forEach((n=>{n.name===o&&n.currentIndex>=t&&n.currentIndex++}))}else u[o]={handlers:[l],runs:0};"hookAdded"!==o&&n.doAction("hookAdded",o,i,c,s)}};var i=function(n,t,o=!1){return function(i,c){const s=n[t];if(!e(i))return;if(!o&&!r(c))return;if(!s[i])return 0;let u=0;if(o)u=s[i].handlers.length,s[i]={runs:s[i].runs,handlers:[]};else{const n=s[i].handlers;for(let t=n.length-1;t>=0;t--)n[t].namespace===c&&(n.splice(t,1),u++,s.__current.forEach((n=>{n.name===i&&n.currentIndex>=t&&n.currentIndex--})))}return"hookRemoved"!==i&&n.doAction("hookRemoved",i,c),u}};var c=function(n,t){return function(r,e){const o=n[t];return void 0!==e?r in o&&o[r].handlers.some((n=>n.namespace===e)):r in o}};var s=function(n,t,r=!1){return function(e,...o){const i=n[t];i[e]||(i[e]={handlers:[],runs:0}),i[e].runs++;const c=i[e].handlers;if(!c||!c.length)return r?o[0]:void 0;const s={name:e,currentIndex:0};for(i.__current.push(s);s.currentIndex<c.length;){const n=c[s.currentIndex].callback.apply(null,o);r&&(o[0]=n),s.currentIndex++}return i.__current.pop(),r?o[0]:void 0}};var u=function(n,t){return function(){var r;const e=n[t];return null!==(r=e.__current[e.__current.length-1]?.name)&&void 0!==r?r:null}};var l=function(n,t){return function(r){const e=n[t];return void 0===r?void 0!==e.__current[0]:!!e.__current[0]&&r===e.__current[0].name}};var a=function(n,t){return function(r){const o=n[t];if(e(r))return o[r]&&o[r].runs?o[r].runs:0}};class d{constructor(){this.actions=Object.create(null),this.actions.__current=[],this.filters=Object.create(null),this.filters.__current=[],this.addAction=o(this,"actions"),this.addFilter=o(this,"filters"),this.removeAction=i(this,"actions"),this.removeFilter=i(this,"filters"),this.hasAction=c(this,"actions"),this.hasFilter=c(this,"filters"),this.removeAllActions=i(this,"actions",!0),this.removeAllFilters=i(this,"filters",!0),this.doAction=s(this,"actions"),this.applyFilters=s(this,"filters",!0),this.currentAction=u(this,"actions"),this.currentFilter=u(this,"filters"),this.doingAction=l(this,"actions"),this.doingFilter=l(this,"filters"),this.didAction=a(this,"actions"),this.didFilter=a(this,"filters")}}var f=function(){return new d};const h=f(),{addAction:m,addFilter:p,removeAction:A,removeFilter:v,hasAction:_,hasFilter:y,removeAllActions:F,removeAllFilters:g,doAction:b,applyFilters:k,currentAction:w,currentFilter:I,doingAction:x,doingFilter:T,didAction:O,didFilter:j,actions:S,filters:z}=h;(window.wp=window.wp||{}).hooks=t}();
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ decodeEntities: function() { return /* binding */ decodeEntities; }
|
||||
/* harmony export */ });
|
||||
/** @type {HTMLTextAreaElement} */
|
||||
let _decodeTextArea;
|
||||
|
||||
/**
|
||||
* Decodes the HTML entities from a given string.
|
||||
*
|
||||
* @param {string} html String that contain HTML entities.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const result = decodeEntities( 'á' );
|
||||
* console.log( result ); // result will be "á"
|
||||
* ```
|
||||
*
|
||||
* @return {string} The decoded string.
|
||||
*/
|
||||
function decodeEntities(html) {
|
||||
// Not a string, or no entities to decode.
|
||||
if ('string' !== typeof html || -1 === html.indexOf('&')) {
|
||||
return html;
|
||||
}
|
||||
|
||||
// Create a textarea for decoding entities, that we can reuse.
|
||||
if (undefined === _decodeTextArea) {
|
||||
if (document.implementation && document.implementation.createHTMLDocument) {
|
||||
_decodeTextArea = document.implementation.createHTMLDocument('').createElement('textarea');
|
||||
} else {
|
||||
_decodeTextArea = document.createElement('textarea');
|
||||
}
|
||||
}
|
||||
_decodeTextArea.innerHTML = html;
|
||||
const decoded = _decodeTextArea.textContent;
|
||||
_decodeTextArea.innerHTML = '';
|
||||
|
||||
/**
|
||||
* Cast to string, HTMLTextAreaElement should always have `string` textContent.
|
||||
*
|
||||
* > The `textContent` property of the `Node` interface represents the text content of the
|
||||
* > node and its descendants.
|
||||
* >
|
||||
* > Value: A string or `null`
|
||||
* >
|
||||
* > * If the node is a `document` or a Doctype, `textContent` returns `null`.
|
||||
* > * If the node is a CDATA section, comment, processing instruction, or text node,
|
||||
* > textContent returns the text inside the node, i.e., the `Node.nodeValue`.
|
||||
* > * For other node types, `textContent returns the concatenation of the textContent of
|
||||
* > every child node, excluding comments and processing instructions. (This is an empty
|
||||
* > string if the node has no children.)
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
|
||||
*/
|
||||
return (/** @type {string} */decoded
|
||||
);
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).htmlEntities = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};let n;function o(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===n&&(n=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),n.innerHTML=e;const t=n.textContent;return n.innerHTML="",t}e.r(t),e.d(t,{decodeEntities:function(){return o}}),(window.wp=window.wp||{}).htmlEntities=t}();
|
||||
Vendored
+1609
File diff suppressed because it is too large
Load Diff
Vendored
+2
File diff suppressed because one or more lines are too long
+2605
File diff suppressed because it is too large
Load Diff
+2
File diff suppressed because one or more lines are too long
+142
@@ -0,0 +1,142 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
"default": function() { return /* binding */ isShallowEqual; },
|
||||
isShallowEqualArrays: function() { return /* reexport */ isShallowEqualArrays; },
|
||||
isShallowEqualObjects: function() { return /* reexport */ isShallowEqualObjects; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/is-shallow-equal/build-module/objects.js
|
||||
/**
|
||||
* Returns true if the two objects are shallow equal, or false otherwise.
|
||||
*
|
||||
* @param {import('.').ComparableObject} a First object to compare.
|
||||
* @param {import('.').ComparableObject} b Second object to compare.
|
||||
*
|
||||
* @return {boolean} Whether the two objects are shallow equal.
|
||||
*/
|
||||
function isShallowEqualObjects(a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
const aKeys = Object.keys(a);
|
||||
const bKeys = Object.keys(b);
|
||||
if (aKeys.length !== bKeys.length) {
|
||||
return false;
|
||||
}
|
||||
let i = 0;
|
||||
while (i < aKeys.length) {
|
||||
const key = aKeys[i];
|
||||
const aValue = a[key];
|
||||
if (
|
||||
// In iterating only the keys of the first object after verifying
|
||||
// equal lengths, account for the case that an explicit `undefined`
|
||||
// value in the first is implicitly undefined in the second.
|
||||
//
|
||||
// Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )
|
||||
aValue === undefined && !b.hasOwnProperty(key) || aValue !== b[key]) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/is-shallow-equal/build-module/arrays.js
|
||||
/**
|
||||
* Returns true if the two arrays are shallow equal, or false otherwise.
|
||||
*
|
||||
* @param {any[]} a First array to compare.
|
||||
* @param {any[]} b Second array to compare.
|
||||
*
|
||||
* @return {boolean} Whether the two arrays are shallow equal.
|
||||
*/
|
||||
function isShallowEqualArrays(a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0, len = a.length; i < len; i++) {
|
||||
if (a[i] !== b[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/is-shallow-equal/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Record<string, any>} ComparableObject
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns true if the two arrays or objects are shallow equal, or false
|
||||
* otherwise. Also handles primitive values, just in case.
|
||||
*
|
||||
* @param {unknown} a First object or array to compare.
|
||||
* @param {unknown} b Second object or array to compare.
|
||||
*
|
||||
* @return {boolean} Whether the two values are shallow equal.
|
||||
*/
|
||||
function isShallowEqual(a, b) {
|
||||
if (a && b) {
|
||||
if (a.constructor === Object && b.constructor === Object) {
|
||||
return isShallowEqualObjects(a, b);
|
||||
} else if (Array.isArray(a) && Array.isArray(b)) {
|
||||
return isShallowEqualArrays(a, b);
|
||||
}
|
||||
}
|
||||
return a === b;
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).isShallowEqual = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var r={d:function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},r:function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},t={};function e(r,t){if(r===t)return!0;const e=Object.keys(r),n=Object.keys(t);if(e.length!==n.length)return!1;let o=0;for(;o<e.length;){const n=e[o],u=r[n];if(void 0===u&&!t.hasOwnProperty(n)||u!==t[n])return!1;o++}return!0}function n(r,t){if(r===t)return!0;if(r.length!==t.length)return!1;for(let e=0,n=r.length;e<n;e++)if(r[e]!==t[e])return!1;return!0}function o(r,t){if(r&&t){if(r.constructor===Object&&t.constructor===Object)return e(r,t);if(Array.isArray(r)&&Array.isArray(t))return n(r,t)}return r===t}r.r(t),r.d(t,{default:function(){return o},isShallowEqualArrays:function(){return n},isShallowEqualObjects:function(){return e}}),(window.wp=window.wp||{}).isShallowEqual=t}();
|
||||
+1093
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ShortcutProvider:function(){return K},__unstableUseShortcutEventMatch:function(){return T},store:function(){return E},useShortcut:function(){return O}});var n={};e.r(n),e.d(n,{registerShortcut:function(){return i},unregisterShortcut:function(){return u}});var r={};e.r(r),e.d(r,{getAllShortcutKeyCombinations:function(){return m},getAllShortcutRawKeyCombinations:function(){return b},getCategoryShortcuts:function(){return C},getShortcutAliases:function(){return w},getShortcutDescription:function(){return g},getShortcutKeyCombination:function(){return v},getShortcutRepresentation:function(){return S}});var o=window.wp.data;var a=function(e={},t){switch(t.type){case"REGISTER_SHORTCUT":return{...e,[t.name]:{category:t.category,keyCombination:t.keyCombination,aliases:t.aliases,description:t.description}};case"UNREGISTER_SHORTCUT":const{[t.name]:n,...r}=e;return r}return e};function i({name:e,category:t,description:n,keyCombination:r,aliases:o}){return{type:"REGISTER_SHORTCUT",name:e,category:t,keyCombination:r,aliases:o,description:n}}function u(e){return{type:"UNREGISTER_SHORTCUT",name:e}}var c={};function s(e){return[e]}function l(e,t,n){var r;if(e.length!==t.length)return!1;for(r=n;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function d(e,t){var n,r=t||s;function o(){n=new WeakMap}function a(){var t,o,a,i,u,s=arguments.length;for(i=new Array(s),a=0;a<s;a++)i[a]=arguments[a];for(t=function(e){var t,r,o,a,i,u=n,s=!0;for(t=0;t<e.length;t++){if(!(i=r=e[t])||"object"!=typeof i){s=!1;break}u.has(r)?u=u.get(r):(o=new WeakMap,u.set(r,o),u=o)}return u.has(c)||((a=function(){var e={clear:function(){e.head=null}};return e}()).isUniqueByDependants=s,u.set(c,a)),u.get(c)}(u=r.apply(null,i)),t.isUniqueByDependants||(t.lastDependants&&!l(u,t.lastDependants,0)&&t.clear(),t.lastDependants=u),o=t.head;o;){if(l(o.args,i,1))return o!==t.head&&(o.prev.next=o.next,o.next&&(o.next.prev=o.prev),o.next=t.head,o.prev=null,t.head.prev=o,t.head=o),o.val;o=o.next}return o={val:e.apply(null,i)},i[0]=null,o.args=i,t.head&&(t.head.prev=o,o.next=t.head),t.head=o,o.val}return a.getDependants=r,a.clear=o,o(),a}var f=window.wp.keycodes;const p=[],y={display:f.displayShortcut,raw:f.rawShortcut,ariaLabel:f.shortcutAriaLabel};function h(e,t){return e?e.modifier?y[t][e.modifier](e.character):e.character:null}function v(e,t){return e[t]?e[t].keyCombination:null}function S(e,t,n="display"){return h(v(e,t),n)}function g(e,t){return e[t]?e[t].description:null}function w(e,t){return e[t]&&e[t].aliases?e[t].aliases:p}const m=d(((e,t)=>[v(e,t),...w(e,t)].filter(Boolean)),((e,t)=>[e[t]])),b=d(((e,t)=>m(e,t).map((e=>h(e,"raw")))),((e,t)=>[e[t]])),C=d(((e,t)=>Object.entries(e).filter((([,e])=>e.category===t)).map((([e])=>e))),(e=>[e])),E=(0,o.createReduxStore)("core/keyboard-shortcuts",{reducer:a,actions:n,selectors:r});(0,o.register)(E);var R=window.wp.element;function T(){const{getAllShortcutKeyCombinations:e}=(0,o.useSelect)(E);return function(t,n){return e(t).some((({modifier:e,character:t})=>f.isKeyboardEvent[e](n,t)))}}const k=new Set,D=e=>{for(const t of k)t(e)},x=(0,R.createContext)({add:e=>{0===k.size&&document.addEventListener("keydown",D),k.add(e)},delete:e=>{k.delete(e),0===k.size&&document.removeEventListener("keydown",D)}});function O(e,t,{isDisabled:n=!1}={}){const r=(0,R.useContext)(x),o=T(),a=(0,R.useRef)();(0,R.useEffect)((()=>{a.current=t}),[t]),(0,R.useEffect)((()=>{if(!n)return r.add(t),()=>{r.delete(t)};function t(t){o(e,t)&&a.current(t)}}),[e,n,r])}const{Provider:U}=x;function K(e){const[t]=(0,R.useState)((()=>new Set));return(0,R.createElement)(U,{value:t},(0,R.createElement)("div",{...e,onKeyDown:function(n){e.onKeyDown&&e.onKeyDown(n);for(const e of t)e(n)}}))}(window.wp=window.wp||{}).keyboardShortcuts=t}();
|
||||
Vendored
+948
@@ -0,0 +1,948 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
ALT: function() { return /* binding */ ALT; },
|
||||
BACKSPACE: function() { return /* binding */ BACKSPACE; },
|
||||
COMMAND: function() { return /* binding */ COMMAND; },
|
||||
CTRL: function() { return /* binding */ CTRL; },
|
||||
DELETE: function() { return /* binding */ DELETE; },
|
||||
DOWN: function() { return /* binding */ DOWN; },
|
||||
END: function() { return /* binding */ END; },
|
||||
ENTER: function() { return /* binding */ ENTER; },
|
||||
ESCAPE: function() { return /* binding */ ESCAPE; },
|
||||
F10: function() { return /* binding */ F10; },
|
||||
HOME: function() { return /* binding */ HOME; },
|
||||
LEFT: function() { return /* binding */ LEFT; },
|
||||
PAGEDOWN: function() { return /* binding */ PAGEDOWN; },
|
||||
PAGEUP: function() { return /* binding */ PAGEUP; },
|
||||
RIGHT: function() { return /* binding */ RIGHT; },
|
||||
SHIFT: function() { return /* binding */ SHIFT; },
|
||||
SPACE: function() { return /* binding */ SPACE; },
|
||||
TAB: function() { return /* binding */ TAB; },
|
||||
UP: function() { return /* binding */ UP; },
|
||||
ZERO: function() { return /* binding */ ZERO; },
|
||||
displayShortcut: function() { return /* binding */ displayShortcut; },
|
||||
displayShortcutList: function() { return /* binding */ displayShortcutList; },
|
||||
isAppleOS: function() { return /* reexport */ isAppleOS; },
|
||||
isKeyboardEvent: function() { return /* binding */ isKeyboardEvent; },
|
||||
modifiers: function() { return /* binding */ modifiers; },
|
||||
rawShortcut: function() { return /* binding */ rawShortcut; },
|
||||
shortcutAriaLabel: function() { return /* binding */ shortcutAriaLabel; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
|
||||
/******************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise, SuppressedError, Symbol */
|
||||
|
||||
var extendStatics = function(d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
|
||||
function __extends(d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
}
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
return __assign.apply(this, arguments);
|
||||
}
|
||||
|
||||
function __rest(s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
function __decorate(decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
}
|
||||
|
||||
function __param(paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
}
|
||||
|
||||
function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
|
||||
function __runInitializers(thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
|
||||
function __propKey(x) {
|
||||
return typeof x === "symbol" ? x : "".concat(x);
|
||||
};
|
||||
|
||||
function __setFunctionName(f, name, prefix) {
|
||||
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
||||
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
||||
};
|
||||
|
||||
function __metadata(metadataKey, metadataValue) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
||||
}
|
||||
|
||||
function __awaiter(thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
}
|
||||
|
||||
function __generator(thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
}
|
||||
|
||||
var __createBinding = Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
});
|
||||
|
||||
function __exportStar(m, o) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
|
||||
}
|
||||
|
||||
function __values(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
}
|
||||
|
||||
function __read(o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
function __spread() {
|
||||
for (var ar = [], i = 0; i < arguments.length; i++)
|
||||
ar = ar.concat(__read(arguments[i]));
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
function __spreadArrays() {
|
||||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
||||
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
||||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
||||
r[k] = a[j];
|
||||
return r;
|
||||
}
|
||||
|
||||
function __spreadArray(to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
}
|
||||
|
||||
function __await(v) {
|
||||
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
||||
}
|
||||
|
||||
function __asyncGenerator(thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
}
|
||||
|
||||
function __asyncDelegator(o) {
|
||||
var i, p;
|
||||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
||||
}
|
||||
|
||||
function __asyncValues(o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
}
|
||||
|
||||
function __makeTemplateObject(cooked, raw) {
|
||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
||||
return cooked;
|
||||
};
|
||||
|
||||
var __setModuleDefault = Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
};
|
||||
|
||||
function __importStar(mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
}
|
||||
|
||||
function __importDefault(mod) {
|
||||
return (mod && mod.__esModule) ? mod : { default: mod };
|
||||
}
|
||||
|
||||
function __classPrivateFieldGet(receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
}
|
||||
|
||||
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
||||
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||
}
|
||||
|
||||
function __classPrivateFieldIn(state, receiver) {
|
||||
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
|
||||
return typeof state === "function" ? receiver === state : state.has(receiver);
|
||||
}
|
||||
|
||||
function __addDisposableResource(env, value, async) {
|
||||
if (value !== null && value !== void 0) {
|
||||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
||||
var dispose;
|
||||
if (async) {
|
||||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
||||
dispose = value[Symbol.asyncDispose];
|
||||
}
|
||||
if (dispose === void 0) {
|
||||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
||||
dispose = value[Symbol.dispose];
|
||||
}
|
||||
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
||||
env.stack.push({ value: value, dispose: dispose, async: async });
|
||||
}
|
||||
else if (async) {
|
||||
env.stack.push({ async: true });
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
};
|
||||
|
||||
function __disposeResources(env) {
|
||||
function fail(e) {
|
||||
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
||||
env.hasError = true;
|
||||
}
|
||||
function next() {
|
||||
while (env.stack.length) {
|
||||
var rec = env.stack.pop();
|
||||
try {
|
||||
var result = rec.dispose && rec.dispose.call(rec.value);
|
||||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
||||
}
|
||||
catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
if (env.hasError) throw env.error;
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
/* harmony default export */ var tslib_es6 = ({
|
||||
__extends,
|
||||
__assign,
|
||||
__rest,
|
||||
__decorate,
|
||||
__param,
|
||||
__metadata,
|
||||
__awaiter,
|
||||
__generator,
|
||||
__createBinding,
|
||||
__exportStar,
|
||||
__values,
|
||||
__read,
|
||||
__spread,
|
||||
__spreadArrays,
|
||||
__spreadArray,
|
||||
__await,
|
||||
__asyncGenerator,
|
||||
__asyncDelegator,
|
||||
__asyncValues,
|
||||
__makeTemplateObject,
|
||||
__importStar,
|
||||
__importDefault,
|
||||
__classPrivateFieldGet,
|
||||
__classPrivateFieldSet,
|
||||
__classPrivateFieldIn,
|
||||
__addDisposableResource,
|
||||
__disposeResources,
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
|
||||
/**
|
||||
* Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
|
||||
*/
|
||||
var SUPPORTED_LOCALE = {
|
||||
tr: {
|
||||
regexp: /\u0130|\u0049|\u0049\u0307/g,
|
||||
map: {
|
||||
İ: "\u0069",
|
||||
I: "\u0131",
|
||||
İ: "\u0069",
|
||||
},
|
||||
},
|
||||
az: {
|
||||
regexp: /\u0130/g,
|
||||
map: {
|
||||
İ: "\u0069",
|
||||
I: "\u0131",
|
||||
İ: "\u0069",
|
||||
},
|
||||
},
|
||||
lt: {
|
||||
regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
|
||||
map: {
|
||||
I: "\u0069\u0307",
|
||||
J: "\u006A\u0307",
|
||||
Į: "\u012F\u0307",
|
||||
Ì: "\u0069\u0307\u0300",
|
||||
Í: "\u0069\u0307\u0301",
|
||||
Ĩ: "\u0069\u0307\u0303",
|
||||
},
|
||||
},
|
||||
};
|
||||
/**
|
||||
* Localized lower case.
|
||||
*/
|
||||
function localeLowerCase(str, locale) {
|
||||
var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
|
||||
if (lang)
|
||||
return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
|
||||
return lowerCase(str);
|
||||
}
|
||||
/**
|
||||
* Lower case as a function.
|
||||
*/
|
||||
function lowerCase(str) {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
|
||||
|
||||
// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
|
||||
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
||||
// Remove all non-word characters.
|
||||
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
||||
/**
|
||||
* Normalize the string into something other libraries can manipulate easier.
|
||||
*/
|
||||
function noCase(input, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
|
||||
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
|
||||
var start = 0;
|
||||
var end = result.length;
|
||||
// Trim the delimiter from around the output string.
|
||||
while (result.charAt(start) === "\0")
|
||||
start++;
|
||||
while (result.charAt(end - 1) === "\0")
|
||||
end--;
|
||||
// Transform each token independently.
|
||||
return result.slice(start, end).split("\0").map(transform).join(delimiter);
|
||||
}
|
||||
/**
|
||||
* Replace `re` in the input string with the replacement value.
|
||||
*/
|
||||
function replace(input, re, value) {
|
||||
if (re instanceof RegExp)
|
||||
return input.replace(re, value);
|
||||
return re.reduce(function (input, re) { return input.replace(re, value); }, input);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/upper-case-first/dist.es2015/index.js
|
||||
/**
|
||||
* Upper case the first character of an input string.
|
||||
*/
|
||||
function upperCaseFirst(input) {
|
||||
return input.charAt(0).toUpperCase() + input.substr(1);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/capital-case/dist.es2015/index.js
|
||||
|
||||
|
||||
|
||||
function capitalCaseTransform(input) {
|
||||
return upperCaseFirst(input.toLowerCase());
|
||||
}
|
||||
function capitalCase(input, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
return noCase(input, __assign({ delimiter: " ", transform: capitalCaseTransform }, options));
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keycodes/build-module/platform.js
|
||||
/**
|
||||
* Return true if platform is MacOS.
|
||||
*
|
||||
* @param {Window?} _window window object by default; used for DI testing.
|
||||
*
|
||||
* @return {boolean} True if MacOS; false otherwise.
|
||||
*/
|
||||
function isAppleOS(_window = null) {
|
||||
if (!_window) {
|
||||
if (typeof window === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
_window = window;
|
||||
}
|
||||
const {
|
||||
platform
|
||||
} = _window.navigator;
|
||||
return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keycodes/build-module/index.js
|
||||
/**
|
||||
* Note: The order of the modifier keys in many of the [foo]Shortcut()
|
||||
* functions in this file are intentional and should not be changed. They're
|
||||
* designed to fit with the standard menu keyboard shortcuts shown in the
|
||||
* user's platform.
|
||||
*
|
||||
* For example, on MacOS menu shortcuts will place Shift before Command, but
|
||||
* on Windows Control will usually come first. So don't provide your own
|
||||
* shortcut combos directly to keyboardShortcut().
|
||||
*/
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */
|
||||
|
||||
/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */
|
||||
|
||||
/**
|
||||
* An object of handler functions for each of the possible modifier
|
||||
* combinations. A handler will return a value for a given key.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler
|
||||
*/
|
||||
/** @typedef {(event: import('react').KeyboardEvent<HTMLElement> | KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */
|
||||
|
||||
/** @typedef {( isApple: () => boolean ) => WPModifierPart[]} WPModifier */
|
||||
|
||||
/**
|
||||
* Keycode for BACKSPACE key.
|
||||
*/
|
||||
const BACKSPACE = 8;
|
||||
|
||||
/**
|
||||
* Keycode for TAB key.
|
||||
*/
|
||||
const TAB = 9;
|
||||
|
||||
/**
|
||||
* Keycode for ENTER key.
|
||||
*/
|
||||
const ENTER = 13;
|
||||
|
||||
/**
|
||||
* Keycode for ESCAPE key.
|
||||
*/
|
||||
const ESCAPE = 27;
|
||||
|
||||
/**
|
||||
* Keycode for SPACE key.
|
||||
*/
|
||||
const SPACE = 32;
|
||||
|
||||
/**
|
||||
* Keycode for PAGEUP key.
|
||||
*/
|
||||
const PAGEUP = 33;
|
||||
|
||||
/**
|
||||
* Keycode for PAGEDOWN key.
|
||||
*/
|
||||
const PAGEDOWN = 34;
|
||||
|
||||
/**
|
||||
* Keycode for END key.
|
||||
*/
|
||||
const END = 35;
|
||||
|
||||
/**
|
||||
* Keycode for HOME key.
|
||||
*/
|
||||
const HOME = 36;
|
||||
|
||||
/**
|
||||
* Keycode for LEFT key.
|
||||
*/
|
||||
const LEFT = 37;
|
||||
|
||||
/**
|
||||
* Keycode for UP key.
|
||||
*/
|
||||
const UP = 38;
|
||||
|
||||
/**
|
||||
* Keycode for RIGHT key.
|
||||
*/
|
||||
const RIGHT = 39;
|
||||
|
||||
/**
|
||||
* Keycode for DOWN key.
|
||||
*/
|
||||
const DOWN = 40;
|
||||
|
||||
/**
|
||||
* Keycode for DELETE key.
|
||||
*/
|
||||
const DELETE = 46;
|
||||
|
||||
/**
|
||||
* Keycode for F10 key.
|
||||
*/
|
||||
const F10 = 121;
|
||||
|
||||
/**
|
||||
* Keycode for ALT key.
|
||||
*/
|
||||
const ALT = 'alt';
|
||||
|
||||
/**
|
||||
* Keycode for CTRL key.
|
||||
*/
|
||||
const CTRL = 'ctrl';
|
||||
|
||||
/**
|
||||
* Keycode for COMMAND/META key.
|
||||
*/
|
||||
const COMMAND = 'meta';
|
||||
|
||||
/**
|
||||
* Keycode for SHIFT key.
|
||||
*/
|
||||
const SHIFT = 'shift';
|
||||
|
||||
/**
|
||||
* Keycode for ZERO key.
|
||||
*/
|
||||
const ZERO = 48;
|
||||
|
||||
|
||||
/**
|
||||
* Map the values of an object with a specified callback and return the result object.
|
||||
*
|
||||
* @template {{ [s: string]: any; } | ArrayLike<any>} T
|
||||
*
|
||||
* @param {T} object Object to map values of.
|
||||
* @param {( value: any ) => any} mapFn Mapping function
|
||||
*
|
||||
* @return {any} Active modifier constants.
|
||||
*/
|
||||
function mapValues(object, mapFn) {
|
||||
return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, mapFn(value)]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Object that contains functions that return the available modifier
|
||||
* depending on platform.
|
||||
*
|
||||
* @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}
|
||||
*/
|
||||
const modifiers = {
|
||||
primary: _isApple => _isApple() ? [COMMAND] : [CTRL],
|
||||
primaryShift: _isApple => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
|
||||
primaryAlt: _isApple => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
|
||||
secondary: _isApple => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT],
|
||||
access: _isApple => _isApple() ? [CTRL, ALT] : [SHIFT, ALT],
|
||||
ctrl: () => [CTRL],
|
||||
alt: () => [ALT],
|
||||
ctrlShift: () => [CTRL, SHIFT],
|
||||
shift: () => [SHIFT],
|
||||
shiftAlt: () => [SHIFT, ALT],
|
||||
undefined: () => []
|
||||
};
|
||||
|
||||
/**
|
||||
* An object that contains functions to get raw shortcuts.
|
||||
*
|
||||
* These are intended for user with the KeyboardShortcuts.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming macOS:
|
||||
* rawShortcut.primary( 'm' )
|
||||
* // "meta+m""
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw
|
||||
* shortcuts.
|
||||
*/
|
||||
const rawShortcut = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
|
||||
return (/** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => {
|
||||
return [...modifier(_isApple), character.toLowerCase()].join('+');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Return an array of the parts of a keyboard shortcut chord for display.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming macOS:
|
||||
* displayShortcutList.primary( 'm' );
|
||||
* // [ "⌘", "M" ]
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to
|
||||
* shortcut sequences.
|
||||
*/
|
||||
const displayShortcutList = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
|
||||
return (/** @type {WPKeyHandler<string[]>} */(character, _isApple = isAppleOS) => {
|
||||
const isApple = _isApple();
|
||||
const replacementKeyMap = {
|
||||
[ALT]: isApple ? '⌥' : 'Alt',
|
||||
[CTRL]: isApple ? '⌃' : 'Ctrl',
|
||||
// Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.
|
||||
[COMMAND]: '⌘',
|
||||
[SHIFT]: isApple ? '⇧' : 'Shift'
|
||||
};
|
||||
const modifierKeys = modifier(_isApple).reduce((accumulator, key) => {
|
||||
var _replacementKeyMap$ke;
|
||||
const replacementKey = (_replacementKeyMap$ke = replacementKeyMap[key]) !== null && _replacementKeyMap$ke !== void 0 ? _replacementKeyMap$ke : key;
|
||||
// If on the Mac, adhere to platform convention and don't show plus between keys.
|
||||
if (isApple) {
|
||||
return [...accumulator, replacementKey];
|
||||
}
|
||||
return [...accumulator, replacementKey, '+'];
|
||||
}, /** @type {string[]} */[]);
|
||||
|
||||
// Symbols (~`,.) are removed by the default regular expression,
|
||||
// so override the rule to allow symbols used for shortcuts.
|
||||
// see: https://github.com/blakeembrey/change-case#options
|
||||
const capitalizedCharacter = capitalCase(character, {
|
||||
stripRegexp: /[^A-Z0-9~`,\.\\\-]/gi
|
||||
});
|
||||
return [...modifierKeys, capitalizedCharacter];
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* An object that contains functions to display shortcuts.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming macOS:
|
||||
* displayShortcut.primary( 'm' );
|
||||
* // "⌘M"
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
|
||||
* display shortcuts.
|
||||
*/
|
||||
const displayShortcut = mapValues(displayShortcutList, ( /** @type {WPKeyHandler<string[]>} */shortcutList) => {
|
||||
return (/** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => shortcutList(character, _isApple).join('')
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* An object that contains functions to return an aria label for a keyboard
|
||||
* shortcut.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming macOS:
|
||||
* shortcutAriaLabel.primary( '.' );
|
||||
* // "Command + Period"
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
|
||||
* shortcut ARIA labels.
|
||||
*/
|
||||
const shortcutAriaLabel = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
|
||||
return (/** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => {
|
||||
const isApple = _isApple();
|
||||
/** @type {Record<string,string>} */
|
||||
const replacementKeyMap = {
|
||||
[SHIFT]: 'Shift',
|
||||
[COMMAND]: isApple ? 'Command' : 'Control',
|
||||
[CTRL]: 'Control',
|
||||
[ALT]: isApple ? 'Option' : 'Alt',
|
||||
/* translators: comma as in the character ',' */
|
||||
',': (0,external_wp_i18n_namespaceObject.__)('Comma'),
|
||||
/* translators: period as in the character '.' */
|
||||
'.': (0,external_wp_i18n_namespaceObject.__)('Period'),
|
||||
/* translators: backtick as in the character '`' */
|
||||
'`': (0,external_wp_i18n_namespaceObject.__)('Backtick'),
|
||||
/* translators: tilde as in the character '~' */
|
||||
'~': (0,external_wp_i18n_namespaceObject.__)('Tilde')
|
||||
};
|
||||
return [...modifier(_isApple), character].map(key => {
|
||||
var _replacementKeyMap$ke2;
|
||||
return capitalCase((_replacementKeyMap$ke2 = replacementKeyMap[key]) !== null && _replacementKeyMap$ke2 !== void 0 ? _replacementKeyMap$ke2 : key);
|
||||
}).join(isApple ? ' ' : ' + ');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* From a given KeyboardEvent, returns an array of active modifier constants for
|
||||
* the event.
|
||||
*
|
||||
* @param {import('react').KeyboardEvent<HTMLElement> | KeyboardEvent} event Keyboard event.
|
||||
*
|
||||
* @return {Array<WPModifierPart>} Active modifier constants.
|
||||
*/
|
||||
function getEventModifiers(event) {
|
||||
return (/** @type {WPModifierPart[]} */[ALT, CTRL, COMMAND, SHIFT].filter(key => event[/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */
|
||||
`${key}Key`])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* An object that contains functions to check if a keyboard event matches a
|
||||
* predefined shortcut combination.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming an event for ⌘M key press:
|
||||
* isKeyboardEvent.primary( event, 'm' );
|
||||
* // true
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions
|
||||
* to match events.
|
||||
*/
|
||||
const isKeyboardEvent = mapValues(modifiers, ( /** @type {WPModifier} */getModifiers) => {
|
||||
return (/** @type {WPEventKeyHandler} */(event, character, _isApple = isAppleOS) => {
|
||||
const mods = getModifiers(_isApple);
|
||||
const eventMods = getEventModifiers(event);
|
||||
/** @type {Record<string,string>} */
|
||||
const replacementWithShiftKeyMap = {
|
||||
Comma: ',',
|
||||
Backslash: '\\',
|
||||
// Windows returns `\` for both IntlRo and IntlYen.
|
||||
IntlRo: '\\',
|
||||
IntlYen: '\\'
|
||||
};
|
||||
const modsDiff = mods.filter(mod => !eventMods.includes(mod));
|
||||
const eventModsDiff = eventMods.filter(mod => !mods.includes(mod));
|
||||
if (modsDiff.length > 0 || eventModsDiff.length > 0) {
|
||||
return false;
|
||||
}
|
||||
let key = event.key.toLowerCase();
|
||||
if (!character) {
|
||||
return mods.includes( /** @type {WPModifierPart} */key);
|
||||
}
|
||||
if (event.altKey && character.length === 1) {
|
||||
key = String.fromCharCode(event.keyCode).toLowerCase();
|
||||
}
|
||||
|
||||
// `event.key` returns the value of the key pressed, taking into the state of
|
||||
// modifier keys such as `Shift`. If the shift key is pressed, a different
|
||||
// value may be returned depending on the keyboard layout. It is necessary to
|
||||
// convert to the physical key value that don't take into account keyboard
|
||||
// layout or modifier key state.
|
||||
if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) {
|
||||
key = replacementWithShiftKeyMap[event.code];
|
||||
}
|
||||
|
||||
// For backwards compatibility.
|
||||
if (character === 'del') {
|
||||
character = 'delete';
|
||||
}
|
||||
return key === character.toLowerCase();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
(window.wp = window.wp || {}).keycodes = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var t={d:function(n,r){for(var e in r)t.o(r,e)&&!t.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:r[e]})},o:function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{ALT:function(){return P},BACKSPACE:function(){return s},COMMAND:function(){return L},CTRL:function(){return j},DELETE:function(){return S},DOWN:function(){return O},END:function(){return g},ENTER:function(){return p},ESCAPE:function(){return h},F10:function(){return b},HOME:function(){return v},LEFT:function(){return w},PAGEDOWN:function(){return A},PAGEUP:function(){return m},RIGHT:function(){return E},SHIFT:function(){return T},SPACE:function(){return y},TAB:function(){return d},UP:function(){return C},ZERO:function(){return _},displayShortcut:function(){return x},displayShortcutList:function(){return Z},isAppleOS:function(){return l},isKeyboardEvent:function(){return K},modifiers:function(){return k},rawShortcut:function(){return M},shortcutAriaLabel:function(){return D}});var r=function(){return r=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},r.apply(this,arguments)};Object.create;Object.create;"function"==typeof SuppressedError&&SuppressedError;function e(t){return t.toLowerCase()}var o=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],i=/[^A-Z0-9]+/gi;function u(t,n,r){return n instanceof RegExp?t.replace(n,r):n.reduce((function(t,n){return t.replace(n,r)}),t)}function c(t){return function(t){return t.charAt(0).toUpperCase()+t.substr(1)}(t.toLowerCase())}function f(t,n){return void 0===n&&(n={}),function(t,n){void 0===n&&(n={});for(var r=n.splitRegexp,c=void 0===r?o:r,f=n.stripRegexp,a=void 0===f?i:f,l=n.transform,s=void 0===l?e:l,d=n.delimiter,p=void 0===d?" ":d,h=u(u(t,c,"$1\0$2"),a,"\0"),y=0,m=h.length;"\0"===h.charAt(y);)y++;for(;"\0"===h.charAt(m-1);)m--;return h.slice(y,m).split("\0").map(s).join(p)}(t,r({delimiter:" ",transform:c},n))}var a=window.wp.i18n;function l(t=null){if(!t){if("undefined"==typeof window)return!1;t=window}const{platform:n}=t.navigator;return-1!==n.indexOf("Mac")||["iPad","iPhone"].includes(n)}const s=8,d=9,p=13,h=27,y=32,m=33,A=34,g=35,v=36,w=37,C=38,E=39,O=40,S=46,b=121,P="alt",j="ctrl",L="meta",T="shift",_=48;function R(t,n){return Object.fromEntries(Object.entries(t).map((([t,r])=>[t,n(r)])))}const k={primary:t=>t()?[L]:[j],primaryShift:t=>t()?[T,L]:[j,T],primaryAlt:t=>t()?[P,L]:[j,P],secondary:t=>t()?[T,P,L]:[j,T,P],access:t=>t()?[j,P]:[T,P],ctrl:()=>[j],alt:()=>[P],ctrlShift:()=>[j,T],shift:()=>[T],shiftAlt:()=>[T,P],undefined:()=>[]},M=R(k,(t=>(n,r=l)=>[...t(r),n.toLowerCase()].join("+"))),Z=R(k,(t=>(n,r=l)=>{const e=r(),o={[P]:e?"⌥":"Alt",[j]:e?"⌃":"Ctrl",[L]:"⌘",[T]:e?"⇧":"Shift"};return[...t(r).reduce(((t,n)=>{var r;const i=null!==(r=o[n])&&void 0!==r?r:n;return e?[...t,i]:[...t,i,"+"]}),[]),f(n,{stripRegexp:/[^A-Z0-9~`,\.\\\-]/gi})]})),x=R(Z,(t=>(n,r=l)=>t(n,r).join(""))),D=R(k,(t=>(n,r=l)=>{const e=r(),o={[T]:"Shift",[L]:e?"Command":"Control",[j]:"Control",[P]:e?"Option":"Alt",",":(0,a.__)("Comma"),".":(0,a.__)("Period"),"`":(0,a.__)("Backtick"),"~":(0,a.__)("Tilde")};return[...t(r),n].map((t=>{var n;return f(null!==(n=o[t])&&void 0!==n?n:t)})).join(e?" ":" + ")}));const K=R(k,(t=>(n,r,e=l)=>{const o=t(e),i=function(t){return[P,j,L,T].filter((n=>t[`${n}Key`]))}(n),u={Comma:",",Backslash:"\\",IntlRo:"\\",IntlYen:"\\"},c=o.filter((t=>!i.includes(t))),f=i.filter((t=>!o.includes(t)));if(c.length>0||f.length>0)return!1;let a=n.key.toLowerCase();return r?(n.altKey&&1===r.length&&(a=String.fromCharCode(n.keyCode).toLowerCase()),n.shiftKey&&1===r.length&&u[n.code]&&(a=u[n.code]),"del"===r&&(r="delete"),a===r.toLowerCase()):o.includes(a)}));(window.wp=window.wp||{}).keycodes=n}();
|
||||
+839
@@ -0,0 +1,839 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
var external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
|
||||
/******************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise, SuppressedError, Symbol */
|
||||
|
||||
var extendStatics = function(d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
|
||||
function __extends(d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
}
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
return __assign.apply(this, arguments);
|
||||
}
|
||||
|
||||
function __rest(s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
function __decorate(decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
}
|
||||
|
||||
function __param(paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
}
|
||||
|
||||
function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
|
||||
function __runInitializers(thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
|
||||
function __propKey(x) {
|
||||
return typeof x === "symbol" ? x : "".concat(x);
|
||||
};
|
||||
|
||||
function __setFunctionName(f, name, prefix) {
|
||||
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
||||
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
||||
};
|
||||
|
||||
function __metadata(metadataKey, metadataValue) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
||||
}
|
||||
|
||||
function __awaiter(thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
}
|
||||
|
||||
function __generator(thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
}
|
||||
|
||||
var __createBinding = Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
});
|
||||
|
||||
function __exportStar(m, o) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
|
||||
}
|
||||
|
||||
function __values(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
}
|
||||
|
||||
function __read(o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
function __spread() {
|
||||
for (var ar = [], i = 0; i < arguments.length; i++)
|
||||
ar = ar.concat(__read(arguments[i]));
|
||||
return ar;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
function __spreadArrays() {
|
||||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
||||
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
||||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
||||
r[k] = a[j];
|
||||
return r;
|
||||
}
|
||||
|
||||
function __spreadArray(to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
}
|
||||
|
||||
function __await(v) {
|
||||
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
||||
}
|
||||
|
||||
function __asyncGenerator(thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
}
|
||||
|
||||
function __asyncDelegator(o) {
|
||||
var i, p;
|
||||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
||||
}
|
||||
|
||||
function __asyncValues(o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
}
|
||||
|
||||
function __makeTemplateObject(cooked, raw) {
|
||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
||||
return cooked;
|
||||
};
|
||||
|
||||
var __setModuleDefault = Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
};
|
||||
|
||||
function __importStar(mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
}
|
||||
|
||||
function __importDefault(mod) {
|
||||
return (mod && mod.__esModule) ? mod : { default: mod };
|
||||
}
|
||||
|
||||
function __classPrivateFieldGet(receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
}
|
||||
|
||||
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
||||
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||
}
|
||||
|
||||
function __classPrivateFieldIn(state, receiver) {
|
||||
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
|
||||
return typeof state === "function" ? receiver === state : state.has(receiver);
|
||||
}
|
||||
|
||||
function __addDisposableResource(env, value, async) {
|
||||
if (value !== null && value !== void 0) {
|
||||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
||||
var dispose;
|
||||
if (async) {
|
||||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
||||
dispose = value[Symbol.asyncDispose];
|
||||
}
|
||||
if (dispose === void 0) {
|
||||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
||||
dispose = value[Symbol.dispose];
|
||||
}
|
||||
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
||||
env.stack.push({ value: value, dispose: dispose, async: async });
|
||||
}
|
||||
else if (async) {
|
||||
env.stack.push({ async: true });
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
};
|
||||
|
||||
function __disposeResources(env) {
|
||||
function fail(e) {
|
||||
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
||||
env.hasError = true;
|
||||
}
|
||||
function next() {
|
||||
while (env.stack.length) {
|
||||
var rec = env.stack.pop();
|
||||
try {
|
||||
var result = rec.dispose && rec.dispose.call(rec.value);
|
||||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
||||
}
|
||||
catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
if (env.hasError) throw env.error;
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
/* harmony default export */ var tslib_es6 = ({
|
||||
__extends,
|
||||
__assign,
|
||||
__rest,
|
||||
__decorate,
|
||||
__param,
|
||||
__metadata,
|
||||
__awaiter,
|
||||
__generator,
|
||||
__createBinding,
|
||||
__exportStar,
|
||||
__values,
|
||||
__read,
|
||||
__spread,
|
||||
__spreadArrays,
|
||||
__spreadArray,
|
||||
__await,
|
||||
__asyncGenerator,
|
||||
__asyncDelegator,
|
||||
__asyncValues,
|
||||
__makeTemplateObject,
|
||||
__importStar,
|
||||
__importDefault,
|
||||
__classPrivateFieldGet,
|
||||
__classPrivateFieldSet,
|
||||
__classPrivateFieldIn,
|
||||
__addDisposableResource,
|
||||
__disposeResources,
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
|
||||
/**
|
||||
* Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
|
||||
*/
|
||||
var SUPPORTED_LOCALE = {
|
||||
tr: {
|
||||
regexp: /\u0130|\u0049|\u0049\u0307/g,
|
||||
map: {
|
||||
İ: "\u0069",
|
||||
I: "\u0131",
|
||||
İ: "\u0069",
|
||||
},
|
||||
},
|
||||
az: {
|
||||
regexp: /\u0130/g,
|
||||
map: {
|
||||
İ: "\u0069",
|
||||
I: "\u0131",
|
||||
İ: "\u0069",
|
||||
},
|
||||
},
|
||||
lt: {
|
||||
regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
|
||||
map: {
|
||||
I: "\u0069\u0307",
|
||||
J: "\u006A\u0307",
|
||||
Į: "\u012F\u0307",
|
||||
Ì: "\u0069\u0307\u0300",
|
||||
Í: "\u0069\u0307\u0301",
|
||||
Ĩ: "\u0069\u0307\u0303",
|
||||
},
|
||||
},
|
||||
};
|
||||
/**
|
||||
* Localized lower case.
|
||||
*/
|
||||
function localeLowerCase(str, locale) {
|
||||
var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
|
||||
if (lang)
|
||||
return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
|
||||
return lowerCase(str);
|
||||
}
|
||||
/**
|
||||
* Lower case as a function.
|
||||
*/
|
||||
function lowerCase(str) {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
|
||||
|
||||
// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
|
||||
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
||||
// Remove all non-word characters.
|
||||
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
||||
/**
|
||||
* Normalize the string into something other libraries can manipulate easier.
|
||||
*/
|
||||
function noCase(input, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
|
||||
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
|
||||
var start = 0;
|
||||
var end = result.length;
|
||||
// Trim the delimiter from around the output string.
|
||||
while (result.charAt(start) === "\0")
|
||||
start++;
|
||||
while (result.charAt(end - 1) === "\0")
|
||||
end--;
|
||||
// Transform each token independently.
|
||||
return result.slice(start, end).split("\0").map(transform).join(delimiter);
|
||||
}
|
||||
/**
|
||||
* Replace `re` in the input string with the replacement value.
|
||||
*/
|
||||
function replace(input, re, value) {
|
||||
if (re instanceof RegExp)
|
||||
return input.replace(re, value);
|
||||
return re.reduce(function (input, re) { return input.replace(re, value); }, input);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js
|
||||
|
||||
|
||||
function dotCase(input, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
return noCase(input, __assign({ delimiter: "." }, options));
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js
|
||||
|
||||
|
||||
function paramCase(input, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
return dotCase(input, __assign({ delimiter: "-" }, options));
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","apiFetch"]
|
||||
var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
|
||||
var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js
|
||||
/**
|
||||
* Downloads a file.
|
||||
*
|
||||
* @param {string} fileName File Name.
|
||||
* @param {string} content File Content.
|
||||
* @param {string} contentType File mime type.
|
||||
*/
|
||||
function download(fileName, content, contentType) {
|
||||
const file = new window.Blob([content], {
|
||||
type: contentType
|
||||
});
|
||||
|
||||
// IE11 can't use the click to download technique
|
||||
// we use a specific IE11 technique instead.
|
||||
if (window.navigator.msSaveOrOpenBlob) {
|
||||
window.navigator.msSaveOrOpenBlob(file, fileName);
|
||||
} else {
|
||||
const a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(file);
|
||||
a.download = fileName;
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the textual content of the given file.
|
||||
*
|
||||
* @param {File} file File.
|
||||
* @return {Promise<string>} Content of the file.
|
||||
*/
|
||||
function readTextFile(file) {
|
||||
const reader = new window.FileReader();
|
||||
return new Promise(resolve => {
|
||||
reader.onload = () => {
|
||||
resolve(reader.result);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/export.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Export a reusable block as a JSON file.
|
||||
*
|
||||
* @param {number} id
|
||||
*/
|
||||
async function exportReusableBlock(id) {
|
||||
const postType = await external_wp_apiFetch_default()({
|
||||
path: `/wp/v2/types/wp_block`
|
||||
});
|
||||
const post = await external_wp_apiFetch_default()({
|
||||
path: `/wp/v2/${postType.rest_base}/${id}?context=edit`
|
||||
});
|
||||
const title = post.title.raw;
|
||||
const content = post.content.raw;
|
||||
const syncStatus = post.wp_pattern_sync_status;
|
||||
const fileContent = JSON.stringify({
|
||||
__file: 'wp_block',
|
||||
title,
|
||||
content,
|
||||
syncStatus
|
||||
}, null, 2);
|
||||
const fileName = paramCase(title) + '.json';
|
||||
download(fileName, fileContent, 'application/json');
|
||||
}
|
||||
/* harmony default export */ var utils_export = (exportReusableBlock);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","compose"]
|
||||
var external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// CONCATENATED MODULE: external ["wp","components"]
|
||||
var external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Import a reusable block from a JSON file.
|
||||
*
|
||||
* @param {File} file File.
|
||||
* @return {Promise} Promise returning the imported reusable block.
|
||||
*/
|
||||
async function importReusableBlock(file) {
|
||||
const fileContent = await readTextFile(file);
|
||||
let parsedContent;
|
||||
try {
|
||||
parsedContent = JSON.parse(fileContent);
|
||||
} catch (e) {
|
||||
throw new Error('Invalid JSON file');
|
||||
}
|
||||
if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== 'string' || typeof parsedContent.content !== 'string' || parsedContent.syncStatus && typeof parsedContent.syncStatus !== 'string') {
|
||||
throw new Error('Invalid pattern JSON file');
|
||||
}
|
||||
const postType = await external_wp_apiFetch_default()({
|
||||
path: `/wp/v2/types/wp_block`
|
||||
});
|
||||
const reusableBlock = await external_wp_apiFetch_default()({
|
||||
path: `/wp/v2/${postType.rest_base}`,
|
||||
data: {
|
||||
title: parsedContent.title,
|
||||
content: parsedContent.content,
|
||||
status: 'publish',
|
||||
meta: parsedContent.syncStatus === 'unsynced' ? {
|
||||
wp_pattern_sync_status: parsedContent.syncStatus
|
||||
} : undefined
|
||||
},
|
||||
method: 'POST'
|
||||
});
|
||||
return reusableBlock;
|
||||
}
|
||||
/* harmony default export */ var utils_import = (importReusableBlock);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-form/index.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
function ImportForm({
|
||||
instanceId,
|
||||
onUpload
|
||||
}) {
|
||||
const inputId = 'list-reusable-blocks-import-form-' + instanceId;
|
||||
const formRef = (0,external_wp_element_namespaceObject.useRef)();
|
||||
const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
|
||||
const [error, setError] = (0,external_wp_element_namespaceObject.useState)(null);
|
||||
const [file, setFile] = (0,external_wp_element_namespaceObject.useState)(null);
|
||||
const onChangeFile = event => {
|
||||
setFile(event.target.files[0]);
|
||||
setError(null);
|
||||
};
|
||||
const onSubmit = event => {
|
||||
event.preventDefault();
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
setIsLoading({
|
||||
isLoading: true
|
||||
});
|
||||
utils_import(file).then(reusableBlock => {
|
||||
if (!formRef) {
|
||||
return;
|
||||
}
|
||||
setIsLoading(false);
|
||||
onUpload(reusableBlock);
|
||||
}).catch(errors => {
|
||||
if (!formRef) {
|
||||
return;
|
||||
}
|
||||
let uiMessage;
|
||||
switch (errors.message) {
|
||||
case 'Invalid JSON file':
|
||||
uiMessage = (0,external_wp_i18n_namespaceObject.__)('Invalid JSON file');
|
||||
break;
|
||||
case 'Invalid pattern JSON file':
|
||||
uiMessage = (0,external_wp_i18n_namespaceObject.__)('Invalid pattern JSON file');
|
||||
break;
|
||||
default:
|
||||
uiMessage = (0,external_wp_i18n_namespaceObject.__)('Unknown error');
|
||||
}
|
||||
setIsLoading(false);
|
||||
setError(uiMessage);
|
||||
});
|
||||
};
|
||||
const onDismissError = () => {
|
||||
setError(null);
|
||||
};
|
||||
return (0,external_wp_element_namespaceObject.createElement)("form", {
|
||||
className: "list-reusable-blocks-import-form",
|
||||
onSubmit: onSubmit,
|
||||
ref: formRef
|
||||
}, error && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
|
||||
status: "error",
|
||||
onRemove: () => onDismissError()
|
||||
}, error), (0,external_wp_element_namespaceObject.createElement)("label", {
|
||||
htmlFor: inputId,
|
||||
className: "list-reusable-blocks-import-form__label"
|
||||
}, (0,external_wp_i18n_namespaceObject.__)('File')), (0,external_wp_element_namespaceObject.createElement)("input", {
|
||||
id: inputId,
|
||||
type: "file",
|
||||
onChange: onChangeFile
|
||||
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
|
||||
type: "submit",
|
||||
isBusy: isLoading,
|
||||
disabled: !file || isLoading,
|
||||
variant: "secondary",
|
||||
className: "list-reusable-blocks-import-form__button"
|
||||
}, (0,external_wp_i18n_namespaceObject._x)('Import', 'button label')));
|
||||
}
|
||||
/* harmony default export */ var import_form = ((0,external_wp_compose_namespaceObject.withInstanceId)(ImportForm));
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
function ImportDropdown({
|
||||
onUpload
|
||||
}) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
|
||||
popoverProps: {
|
||||
placement: 'bottom-start'
|
||||
},
|
||||
contentClassName: "list-reusable-blocks-import-dropdown__content",
|
||||
renderToggle: ({
|
||||
isOpen,
|
||||
onToggle
|
||||
}) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
|
||||
"aria-expanded": isOpen,
|
||||
onClick: onToggle,
|
||||
variant: "primary"
|
||||
}, (0,external_wp_i18n_namespaceObject.__)('Import from JSON')),
|
||||
renderContent: ({
|
||||
onClose
|
||||
}) => (0,external_wp_element_namespaceObject.createElement)(import_form, {
|
||||
onUpload: (0,external_wp_compose_namespaceObject.pipe)(onClose, onUpload)
|
||||
})
|
||||
});
|
||||
}
|
||||
/* harmony default export */ var import_dropdown = (ImportDropdown);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Setup Export Links.
|
||||
document.body.addEventListener('click', event => {
|
||||
if (!event.target.classList.contains('wp-list-reusable-blocks__export')) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
utils_export(event.target.dataset.id);
|
||||
});
|
||||
|
||||
// Setup Import Form.
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const button = document.querySelector('.page-title-action');
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
const showNotice = () => {
|
||||
const notice = document.createElement('div');
|
||||
notice.className = 'notice notice-success is-dismissible';
|
||||
notice.innerHTML = `<p>${(0,external_wp_i18n_namespaceObject.__)('Pattern imported successfully!')}</p>`;
|
||||
const headerEnd = document.querySelector('.wp-header-end');
|
||||
if (!headerEnd) {
|
||||
return;
|
||||
}
|
||||
headerEnd.parentNode.insertBefore(notice, headerEnd);
|
||||
};
|
||||
const container = document.createElement('div');
|
||||
container.className = 'list-reusable-blocks__container';
|
||||
button.parentNode.insertBefore(container, button);
|
||||
(0,external_wp_element_namespaceObject.createRoot)(container).render((0,external_wp_element_namespaceObject.createElement)(import_dropdown, {
|
||||
onUpload: showNotice
|
||||
}));
|
||||
});
|
||||
|
||||
(window.wp = window.wp || {}).listReusableBlocks = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
File diff suppressed because one or more lines are too long
+700
@@ -0,0 +1,700 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
MediaUpload: function() { return /* reexport */ media_upload; },
|
||||
uploadMedia: function() { return /* reexport */ uploadMedia; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
var external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/media-upload/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const DEFAULT_EMPTY_GALLERY = [];
|
||||
|
||||
/**
|
||||
* Prepares the Featured Image toolbars and frames.
|
||||
*
|
||||
* @return {window.wp.media.view.MediaFrame.Select} The default media workflow.
|
||||
*/
|
||||
const getFeaturedImageMediaFrame = () => {
|
||||
const {
|
||||
wp
|
||||
} = window;
|
||||
return wp.media.view.MediaFrame.Select.extend({
|
||||
/**
|
||||
* Enables the Set Featured Image Button.
|
||||
*
|
||||
* @param {Object} toolbar toolbar for featured image state
|
||||
* @return {void}
|
||||
*/
|
||||
featuredImageToolbar(toolbar) {
|
||||
this.createSelectToolbar(toolbar, {
|
||||
text: wp.media.view.l10n.setFeaturedImage,
|
||||
state: this.options.state
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Handle the edit state requirements of selected media item.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
editState() {
|
||||
const selection = this.state('featured-image').get('selection');
|
||||
const view = new wp.media.view.EditImage({
|
||||
model: selection.single(),
|
||||
controller: this
|
||||
}).render();
|
||||
|
||||
// Set the view to the EditImage frame using the selected image.
|
||||
this.content.set(view);
|
||||
|
||||
// After bringing in the frame, load the actual editor via an ajax call.
|
||||
view.loadEditor();
|
||||
},
|
||||
/**
|
||||
* Create the default states.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
createStates: function createStates() {
|
||||
this.on('toolbar:create:featured-image', this.featuredImageToolbar, this);
|
||||
this.on('content:render:edit-image', this.editState, this);
|
||||
this.states.add([new wp.media.controller.FeaturedImage(), new wp.media.controller.EditImage({
|
||||
model: this.options.editImage
|
||||
})]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Prepares the Gallery toolbars and frames.
|
||||
*
|
||||
* @return {window.wp.media.view.MediaFrame.Post} The default media workflow.
|
||||
*/
|
||||
const getGalleryDetailsMediaFrame = () => {
|
||||
const {
|
||||
wp
|
||||
} = window;
|
||||
/**
|
||||
* Custom gallery details frame.
|
||||
*
|
||||
* @see https://github.com/xwp/wp-core-media-widgets/blob/905edbccfc2a623b73a93dac803c5335519d7837/wp-admin/js/widgets/media-gallery-widget.js
|
||||
* @class GalleryDetailsMediaFrame
|
||||
* @class
|
||||
*/
|
||||
return wp.media.view.MediaFrame.Post.extend({
|
||||
/**
|
||||
* Set up gallery toolbar.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
galleryToolbar() {
|
||||
const editing = this.state().get('editing');
|
||||
this.toolbar.set(new wp.media.view.Toolbar({
|
||||
controller: this,
|
||||
items: {
|
||||
insert: {
|
||||
style: 'primary',
|
||||
text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery,
|
||||
priority: 80,
|
||||
requires: {
|
||||
library: true
|
||||
},
|
||||
/**
|
||||
* @fires wp.media.controller.State#update
|
||||
*/
|
||||
click() {
|
||||
const controller = this.controller,
|
||||
state = controller.state();
|
||||
controller.close();
|
||||
state.trigger('update', state.get('library'));
|
||||
|
||||
// Restore and reset the default state.
|
||||
controller.setState(controller.options.state);
|
||||
controller.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
},
|
||||
/**
|
||||
* Handle the edit state requirements of selected media item.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
editState() {
|
||||
const selection = this.state('gallery').get('selection');
|
||||
const view = new wp.media.view.EditImage({
|
||||
model: selection.single(),
|
||||
controller: this
|
||||
}).render();
|
||||
|
||||
// Set the view to the EditImage frame using the selected image.
|
||||
this.content.set(view);
|
||||
|
||||
// After bringing in the frame, load the actual editor via an ajax call.
|
||||
view.loadEditor();
|
||||
},
|
||||
/**
|
||||
* Create the default states.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
createStates: function createStates() {
|
||||
this.on('toolbar:create:main-gallery', this.galleryToolbar, this);
|
||||
this.on('content:render:edit-image', this.editState, this);
|
||||
this.states.add([new wp.media.controller.Library({
|
||||
id: 'gallery',
|
||||
title: wp.media.view.l10n.createGalleryTitle,
|
||||
priority: 40,
|
||||
toolbar: 'main-gallery',
|
||||
filterable: 'uploaded',
|
||||
multiple: 'add',
|
||||
editable: false,
|
||||
library: wp.media.query({
|
||||
type: 'image',
|
||||
...this.options.library
|
||||
})
|
||||
}), new wp.media.controller.EditImage({
|
||||
model: this.options.editImage
|
||||
}), new wp.media.controller.GalleryEdit({
|
||||
library: this.options.selection,
|
||||
editing: this.options.editing,
|
||||
menu: 'gallery',
|
||||
displaySettings: false,
|
||||
multiple: true
|
||||
}), new wp.media.controller.GalleryAdd()]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// The media library image object contains numerous attributes
|
||||
// we only need this set to display the image in the library.
|
||||
const slimImageObject = img => {
|
||||
const attrSet = ['sizes', 'mime', 'type', 'subtype', 'id', 'url', 'alt', 'link', 'caption'];
|
||||
return attrSet.reduce((result, key) => {
|
||||
if (img?.hasOwnProperty(key)) {
|
||||
result[key] = img[key];
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
};
|
||||
const getAttachmentsCollection = ids => {
|
||||
const {
|
||||
wp
|
||||
} = window;
|
||||
return wp.media.query({
|
||||
order: 'ASC',
|
||||
orderby: 'post__in',
|
||||
post__in: ids,
|
||||
posts_per_page: -1,
|
||||
query: true,
|
||||
type: 'image'
|
||||
});
|
||||
};
|
||||
class MediaUpload extends external_wp_element_namespaceObject.Component {
|
||||
constructor({
|
||||
allowedTypes,
|
||||
gallery = false,
|
||||
unstableFeaturedImageFlow = false,
|
||||
modalClass,
|
||||
multiple = false,
|
||||
title = (0,external_wp_i18n_namespaceObject.__)('Select or Upload Media')
|
||||
}) {
|
||||
super(...arguments);
|
||||
this.openModal = this.openModal.bind(this);
|
||||
this.onOpen = this.onOpen.bind(this);
|
||||
this.onSelect = this.onSelect.bind(this);
|
||||
this.onUpdate = this.onUpdate.bind(this);
|
||||
this.onClose = this.onClose.bind(this);
|
||||
const {
|
||||
wp
|
||||
} = window;
|
||||
if (gallery) {
|
||||
this.buildAndSetGalleryFrame();
|
||||
} else {
|
||||
const frameConfig = {
|
||||
title,
|
||||
multiple
|
||||
};
|
||||
if (!!allowedTypes) {
|
||||
frameConfig.library = {
|
||||
type: allowedTypes
|
||||
};
|
||||
}
|
||||
this.frame = wp.media(frameConfig);
|
||||
}
|
||||
if (modalClass) {
|
||||
this.frame.$el.addClass(modalClass);
|
||||
}
|
||||
if (unstableFeaturedImageFlow) {
|
||||
this.buildAndSetFeatureImageFrame();
|
||||
}
|
||||
this.initializeListeners();
|
||||
}
|
||||
initializeListeners() {
|
||||
// When an image is selected in the media frame...
|
||||
this.frame.on('select', this.onSelect);
|
||||
this.frame.on('update', this.onUpdate);
|
||||
this.frame.on('open', this.onOpen);
|
||||
this.frame.on('close', this.onClose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Gallery frame and initializes listeners.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
buildAndSetGalleryFrame() {
|
||||
const {
|
||||
addToGallery = false,
|
||||
allowedTypes,
|
||||
multiple = false,
|
||||
value = DEFAULT_EMPTY_GALLERY
|
||||
} = this.props;
|
||||
|
||||
// If the value did not changed there is no need to rebuild the frame,
|
||||
// we can continue to use the existing one.
|
||||
if (value === this.lastGalleryValue) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
wp
|
||||
} = window;
|
||||
this.lastGalleryValue = value;
|
||||
|
||||
// If a frame already existed remove it.
|
||||
if (this.frame) {
|
||||
this.frame.remove();
|
||||
}
|
||||
let currentState;
|
||||
if (addToGallery) {
|
||||
currentState = 'gallery-library';
|
||||
} else {
|
||||
currentState = value && value.length ? 'gallery-edit' : 'gallery';
|
||||
}
|
||||
if (!this.GalleryDetailsMediaFrame) {
|
||||
this.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame();
|
||||
}
|
||||
const attachments = getAttachmentsCollection(value);
|
||||
const selection = new wp.media.model.Selection(attachments.models, {
|
||||
props: attachments.props.toJSON(),
|
||||
multiple
|
||||
});
|
||||
this.frame = new this.GalleryDetailsMediaFrame({
|
||||
mimeType: allowedTypes,
|
||||
state: currentState,
|
||||
multiple,
|
||||
selection,
|
||||
editing: value && value.length ? true : false
|
||||
});
|
||||
wp.media.frame = this.frame;
|
||||
this.initializeListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Media Library requirements for the featured image flow.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
buildAndSetFeatureImageFrame() {
|
||||
const {
|
||||
wp
|
||||
} = window;
|
||||
const featuredImageFrame = getFeaturedImageMediaFrame();
|
||||
const attachments = getAttachmentsCollection(this.props.value);
|
||||
const selection = new wp.media.model.Selection(attachments.models, {
|
||||
props: attachments.props.toJSON()
|
||||
});
|
||||
this.frame = new featuredImageFrame({
|
||||
mimeType: this.props.allowedTypes,
|
||||
state: 'featured-image',
|
||||
multiple: this.props.multiple,
|
||||
selection,
|
||||
editing: this.props.value ? true : false
|
||||
});
|
||||
wp.media.frame = this.frame;
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this.frame.remove();
|
||||
}
|
||||
onUpdate(selections) {
|
||||
const {
|
||||
onSelect,
|
||||
multiple = false
|
||||
} = this.props;
|
||||
const state = this.frame.state();
|
||||
const selectedImages = selections || state.get('selection');
|
||||
if (!selectedImages || !selectedImages.models.length) {
|
||||
return;
|
||||
}
|
||||
if (multiple) {
|
||||
onSelect(selectedImages.models.map(model => slimImageObject(model.toJSON())));
|
||||
} else {
|
||||
onSelect(slimImageObject(selectedImages.models[0].toJSON()));
|
||||
}
|
||||
}
|
||||
onSelect() {
|
||||
const {
|
||||
onSelect,
|
||||
multiple = false
|
||||
} = this.props;
|
||||
// Get media attachment details from the frame state.
|
||||
const attachment = this.frame.state().get('selection').toJSON();
|
||||
onSelect(multiple ? attachment : attachment[0]);
|
||||
}
|
||||
onOpen() {
|
||||
const {
|
||||
wp
|
||||
} = window;
|
||||
const {
|
||||
value
|
||||
} = this.props;
|
||||
this.updateCollection();
|
||||
|
||||
//Handle active tab in media model on model open.
|
||||
if (this.props.mode) {
|
||||
this.frame.content.mode(this.props.mode);
|
||||
}
|
||||
|
||||
// Handle both this.props.value being either (number[]) multiple ids
|
||||
// (for galleries) or a (number) singular id (e.g. image block).
|
||||
const hasMedia = Array.isArray(value) ? !!value?.length : !!value;
|
||||
if (!hasMedia) {
|
||||
return;
|
||||
}
|
||||
const isGallery = this.props.gallery;
|
||||
const selection = this.frame.state().get('selection');
|
||||
const valueArray = Array.isArray(value) ? value : [value];
|
||||
if (!isGallery) {
|
||||
valueArray.forEach(id => {
|
||||
selection.add(wp.media.attachment(id));
|
||||
});
|
||||
}
|
||||
|
||||
// Load the images so they are available in the media modal.
|
||||
const attachments = getAttachmentsCollection(valueArray);
|
||||
|
||||
// Once attachments are loaded, set the current selection.
|
||||
attachments.more().done(function () {
|
||||
if (isGallery && attachments?.models?.length) {
|
||||
selection.add(attachments.models);
|
||||
}
|
||||
});
|
||||
}
|
||||
onClose() {
|
||||
const {
|
||||
onClose
|
||||
} = this.props;
|
||||
if (onClose) {
|
||||
onClose();
|
||||
}
|
||||
}
|
||||
updateCollection() {
|
||||
const frameContent = this.frame.content.get();
|
||||
if (frameContent && frameContent.collection) {
|
||||
const collection = frameContent.collection;
|
||||
|
||||
// Clean all attachments we have in memory.
|
||||
collection.toArray().forEach(model => model.trigger('destroy', model));
|
||||
|
||||
// Reset has more flag, if library had small amount of items all items may have been loaded before.
|
||||
collection.mirroring._hasMore = true;
|
||||
|
||||
// Request items.
|
||||
collection.more();
|
||||
}
|
||||
}
|
||||
openModal() {
|
||||
if (this.props.gallery) {
|
||||
this.buildAndSetGalleryFrame();
|
||||
}
|
||||
this.frame.open();
|
||||
}
|
||||
render() {
|
||||
return this.props.render({
|
||||
open: this.openModal
|
||||
});
|
||||
}
|
||||
}
|
||||
/* harmony default export */ var media_upload = (MediaUpload);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/index.js
|
||||
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","apiFetch"]
|
||||
var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
|
||||
var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
|
||||
;// CONCATENATED MODULE: external ["wp","blob"]
|
||||
var external_wp_blob_namespaceObject = window["wp"]["blob"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/utils/upload-media.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
/**
|
||||
* Browsers may use unexpected mime types, and they differ from browser to browser.
|
||||
* This function computes a flexible array of mime types from the mime type structured provided by the server.
|
||||
* Converts { jpg|jpeg|jpe: "image/jpeg" } into [ "image/jpeg", "image/jpg", "image/jpeg", "image/jpe" ]
|
||||
* The computation of this array instead of directly using the object,
|
||||
* solves the problem in chrome where mp3 files have audio/mp3 as mime type instead of audio/mpeg.
|
||||
* https://bugs.chromium.org/p/chromium/issues/detail?id=227004
|
||||
*
|
||||
* @param {?Object} wpMimeTypesObject Mime type object received from the server.
|
||||
* Extensions are keys separated by '|' and values are mime types associated with an extension.
|
||||
*
|
||||
* @return {?Array} An array of mime types or the parameter passed if it was "falsy".
|
||||
*/
|
||||
function getMimeTypesArray(wpMimeTypesObject) {
|
||||
if (!wpMimeTypesObject) {
|
||||
return wpMimeTypesObject;
|
||||
}
|
||||
return Object.entries(wpMimeTypesObject).map(([extensionsString, mime]) => {
|
||||
const [type] = mime.split('/');
|
||||
const extensions = extensionsString.split('|');
|
||||
return [mime, ...extensions.map(extension => `${type}/${extension}`)];
|
||||
}).flat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Media Upload is used by audio, image, gallery, video, and file blocks to
|
||||
* handle uploading a media file when a file upload button is activated.
|
||||
*
|
||||
* TODO: future enhancement to add an upload indicator.
|
||||
*
|
||||
* @param {Object} $0 Parameters object passed to the function.
|
||||
* @param {?Array} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.
|
||||
* @param {?Object} $0.additionalData Additional data to include in the request.
|
||||
* @param {Array} $0.filesList List of files.
|
||||
* @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.
|
||||
* @param {Function} $0.onError Function called when an error happens.
|
||||
* @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.
|
||||
* @param {?Object} $0.wpAllowedMimeTypes List of allowed mime types and file extensions.
|
||||
*/
|
||||
async function uploadMedia({
|
||||
allowedTypes,
|
||||
additionalData = {},
|
||||
filesList,
|
||||
maxUploadFileSize,
|
||||
onError = noop,
|
||||
onFileChange,
|
||||
wpAllowedMimeTypes = null
|
||||
}) {
|
||||
// Cast filesList to array.
|
||||
const files = [...filesList];
|
||||
const filesSet = [];
|
||||
const setAndUpdateFiles = (idx, value) => {
|
||||
(0,external_wp_blob_namespaceObject.revokeBlobURL)(filesSet[idx]?.url);
|
||||
filesSet[idx] = value;
|
||||
onFileChange(filesSet.filter(Boolean));
|
||||
};
|
||||
|
||||
// Allowed type specified by consumer.
|
||||
const isAllowedType = fileType => {
|
||||
if (!allowedTypes) {
|
||||
return true;
|
||||
}
|
||||
return allowedTypes.some(allowedType => {
|
||||
// If a complete mimetype is specified verify if it matches exactly the mime type of the file.
|
||||
if (allowedType.includes('/')) {
|
||||
return allowedType === fileType;
|
||||
}
|
||||
// Otherwise a general mime type is used and we should verify if the file mimetype starts with it.
|
||||
return fileType.startsWith(`${allowedType}/`);
|
||||
});
|
||||
};
|
||||
|
||||
// Allowed types for the current WP_User.
|
||||
const allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes);
|
||||
const isAllowedMimeTypeForUser = fileType => {
|
||||
return allowedMimeTypesForUser.includes(fileType);
|
||||
};
|
||||
const validFiles = [];
|
||||
for (const mediaFile of files) {
|
||||
// Verify if user is allowed to upload this mime type.
|
||||
// Defer to the server when type not detected.
|
||||
if (allowedMimeTypesForUser && mediaFile.type && !isAllowedMimeTypeForUser(mediaFile.type)) {
|
||||
onError({
|
||||
code: 'MIME_TYPE_NOT_ALLOWED_FOR_USER',
|
||||
message: (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: file name.
|
||||
(0,external_wp_i18n_namespaceObject.__)('%s: Sorry, you are not allowed to upload this file type.'), mediaFile.name),
|
||||
file: mediaFile
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if the block supports this mime type.
|
||||
// Defer to the server when type not detected.
|
||||
if (mediaFile.type && !isAllowedType(mediaFile.type)) {
|
||||
onError({
|
||||
code: 'MIME_TYPE_NOT_SUPPORTED',
|
||||
message: (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: file name.
|
||||
(0,external_wp_i18n_namespaceObject.__)('%s: Sorry, this file type is not supported here.'), mediaFile.name),
|
||||
file: mediaFile
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// Verify if file is greater than the maximum file upload size allowed for the site.
|
||||
if (maxUploadFileSize && mediaFile.size > maxUploadFileSize) {
|
||||
onError({
|
||||
code: 'SIZE_ABOVE_LIMIT',
|
||||
message: (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: file name.
|
||||
(0,external_wp_i18n_namespaceObject.__)('%s: This file exceeds the maximum upload size for this site.'), mediaFile.name),
|
||||
file: mediaFile
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't allow empty files to be uploaded.
|
||||
if (mediaFile.size <= 0) {
|
||||
onError({
|
||||
code: 'EMPTY_FILE',
|
||||
message: (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: file name.
|
||||
(0,external_wp_i18n_namespaceObject.__)('%s: This file is empty.'), mediaFile.name),
|
||||
file: mediaFile
|
||||
});
|
||||
continue;
|
||||
}
|
||||
validFiles.push(mediaFile);
|
||||
|
||||
// Set temporary URL to create placeholder media file, this is replaced
|
||||
// with final file from media gallery when upload is `done` below.
|
||||
filesSet.push({
|
||||
url: (0,external_wp_blob_namespaceObject.createBlobURL)(mediaFile)
|
||||
});
|
||||
onFileChange(filesSet);
|
||||
}
|
||||
for (let idx = 0; idx < validFiles.length; ++idx) {
|
||||
const mediaFile = validFiles[idx];
|
||||
try {
|
||||
var _savedMedia$caption$r;
|
||||
const savedMedia = await createMediaFromFile(mediaFile, additionalData);
|
||||
// eslint-disable-next-line camelcase
|
||||
const {
|
||||
alt_text,
|
||||
source_url,
|
||||
...savedMediaProps
|
||||
} = savedMedia;
|
||||
const mediaObject = {
|
||||
...savedMediaProps,
|
||||
alt: savedMedia.alt_text,
|
||||
caption: (_savedMedia$caption$r = savedMedia.caption?.raw) !== null && _savedMedia$caption$r !== void 0 ? _savedMedia$caption$r : '',
|
||||
title: savedMedia.title.raw,
|
||||
url: savedMedia.source_url
|
||||
};
|
||||
setAndUpdateFiles(idx, mediaObject);
|
||||
} catch (error) {
|
||||
// Reset to empty on failure.
|
||||
setAndUpdateFiles(idx, null);
|
||||
let message;
|
||||
if (error.message) {
|
||||
message = error.message;
|
||||
} else {
|
||||
message = (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: file name
|
||||
(0,external_wp_i18n_namespaceObject.__)('Error while uploading file %s to the media library.'), mediaFile.name);
|
||||
}
|
||||
onError({
|
||||
code: 'GENERAL',
|
||||
message,
|
||||
file: mediaFile
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {File} file Media File to Save.
|
||||
* @param {?Object} additionalData Additional data to include in the request.
|
||||
*
|
||||
* @return {Promise} Media Object Promise.
|
||||
*/
|
||||
function createMediaFromFile(file, additionalData) {
|
||||
// Create upload payload.
|
||||
const data = new window.FormData();
|
||||
data.append('file', file, file.name || file.type.replace('/', '.'));
|
||||
if (additionalData) {
|
||||
Object.entries(additionalData).forEach(([key, value]) => data.append(key, value));
|
||||
}
|
||||
return external_wp_apiFetch_default()({
|
||||
path: '/wp/v2/media',
|
||||
body: data,
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/utils/index.js
|
||||
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/index.js
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).mediaUtils = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
File diff suppressed because one or more lines are too long
Vendored
+674
@@ -0,0 +1,674 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
store: function() { return /* reexport */ store; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
|
||||
var actions_namespaceObject = {};
|
||||
__webpack_require__.r(actions_namespaceObject);
|
||||
__webpack_require__.d(actions_namespaceObject, {
|
||||
createErrorNotice: function() { return createErrorNotice; },
|
||||
createInfoNotice: function() { return createInfoNotice; },
|
||||
createNotice: function() { return createNotice; },
|
||||
createSuccessNotice: function() { return createSuccessNotice; },
|
||||
createWarningNotice: function() { return createWarningNotice; },
|
||||
removeAllNotices: function() { return removeAllNotices; },
|
||||
removeNotice: function() { return removeNotice; },
|
||||
removeNotices: function() { return removeNotices; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
|
||||
var selectors_namespaceObject = {};
|
||||
__webpack_require__.r(selectors_namespaceObject);
|
||||
__webpack_require__.d(selectors_namespaceObject, {
|
||||
getNotices: function() { return getNotices; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
var external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
|
||||
/**
|
||||
* Higher-order reducer creator which creates a combined reducer object, keyed
|
||||
* by a property on the action object.
|
||||
*
|
||||
* @param {string} actionProperty Action property by which to key object.
|
||||
*
|
||||
* @return {Function} Higher-order reducer.
|
||||
*/
|
||||
const onSubKey = actionProperty => reducer => (state = {}, action) => {
|
||||
// Retrieve subkey from action. Do not track if undefined; useful for cases
|
||||
// where reducer is scoped by action shape.
|
||||
const key = action[actionProperty];
|
||||
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.
|
||||
const nextKeyState = reducer(state[key], action);
|
||||
if (nextKeyState === state[key]) {
|
||||
return state;
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
[key]: nextKeyState
|
||||
};
|
||||
};
|
||||
/* harmony default export */ var on_sub_key = (onSubKey);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Reducer returning the next notices state. The notices state is an object
|
||||
* where each key is a context, its value an array of notice objects.
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
const notices = on_sub_key('context')((state = [], action) => {
|
||||
switch (action.type) {
|
||||
case 'CREATE_NOTICE':
|
||||
// Avoid duplicates on ID.
|
||||
return [...state.filter(({
|
||||
id
|
||||
}) => id !== action.notice.id), action.notice];
|
||||
case 'REMOVE_NOTICE':
|
||||
return state.filter(({
|
||||
id
|
||||
}) => id !== action.id);
|
||||
case 'REMOVE_NOTICES':
|
||||
return state.filter(({
|
||||
id
|
||||
}) => !action.ids.includes(id));
|
||||
case 'REMOVE_ALL_NOTICES':
|
||||
return state.filter(({
|
||||
type
|
||||
}) => type !== action.noticeType);
|
||||
}
|
||||
return state;
|
||||
});
|
||||
/* harmony default export */ var reducer = (notices);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
|
||||
/**
|
||||
* Default context to use for notice grouping when not otherwise specified. Its
|
||||
* specific value doesn't hold much meaning, but it must be reasonably unique
|
||||
* and, more importantly, referenced consistently in the store implementation.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const DEFAULT_CONTEXT = 'global';
|
||||
|
||||
/**
|
||||
* Default notice status.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const DEFAULT_STATUS = 'info';
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
|
||||
*
|
||||
* @property {string} label Message to use as action label.
|
||||
* @property {?string} url Optional URL of resource if action incurs
|
||||
* browser navigation.
|
||||
* @property {?Function} onClick Optional function to invoke when action is
|
||||
* triggered by user.
|
||||
*/
|
||||
|
||||
let uniqueId = 0;
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a notice is to be created.
|
||||
*
|
||||
* @param {string|undefined} status Notice status ("info" if undefined is passed).
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Notice options.
|
||||
* @param {string} [options.context='global'] Context under which to
|
||||
* group notice.
|
||||
* @param {string} [options.id] Identifier for notice.
|
||||
* Automatically assigned
|
||||
* if not specified.
|
||||
* @param {boolean} [options.isDismissible=true] Whether the notice can
|
||||
* be dismissed by user.
|
||||
* @param {string} [options.type='default'] Type of notice, one of
|
||||
* `default`, or `snackbar`.
|
||||
* @param {boolean} [options.speak=true] Whether the notice
|
||||
* content should be
|
||||
* announced to screen
|
||||
* readers.
|
||||
* @param {Array<WPNoticeAction>} [options.actions] User actions to be
|
||||
* presented with notice.
|
||||
* @param {string} [options.icon] An icon displayed with the notice.
|
||||
* Only used when type is set to `snackbar`.
|
||||
* @param {boolean} [options.explicitDismiss] Whether the notice includes
|
||||
* an explicit dismiss button and
|
||||
* can't be dismissed by clicking
|
||||
* the body of the notice. Only applies
|
||||
* when type is set to `snackbar`.
|
||||
* @param {Function} [options.onDismiss] Called when the notice is dismissed.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () => createNotice( 'success', __( 'Notice message' ) ) }
|
||||
* >
|
||||
* { __( 'Generate a success notice!' ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createNotice(status = DEFAULT_STATUS, content, options = {}) {
|
||||
const {
|
||||
speak = true,
|
||||
isDismissible = true,
|
||||
context = DEFAULT_CONTEXT,
|
||||
id = `${context}${++uniqueId}`,
|
||||
actions = [],
|
||||
type = 'default',
|
||||
__unstableHTML,
|
||||
icon = null,
|
||||
explicitDismiss = false,
|
||||
onDismiss
|
||||
} = options;
|
||||
|
||||
// The supported value shape of content is currently limited to plain text
|
||||
// strings. To avoid setting expectation that e.g. a WPElement could be
|
||||
// supported, cast to a string.
|
||||
content = String(content);
|
||||
return {
|
||||
type: 'CREATE_NOTICE',
|
||||
context,
|
||||
notice: {
|
||||
id,
|
||||
status,
|
||||
content,
|
||||
spokenMessage: speak ? content : null,
|
||||
__unstableHTML,
|
||||
isDismissible,
|
||||
actions,
|
||||
type,
|
||||
icon,
|
||||
explicitDismiss,
|
||||
onDismiss
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a success notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
*
|
||||
* @see createNotice
|
||||
*
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Optional notice options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createSuccessNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createSuccessNotice( __( 'Success!' ), {
|
||||
* type: 'snackbar',
|
||||
* icon: '🔥',
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Generate a snackbar success notice!' ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createSuccessNotice(content, options) {
|
||||
return createNotice('success', content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that an info notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
*
|
||||
* @see createNotice
|
||||
*
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Optional notice options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createInfoNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createInfoNotice( __( 'Something happened!' ), {
|
||||
* isDismissible: false,
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Generate a notice that cannot be dismissed.' ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createInfoNotice(content, options) {
|
||||
return createNotice('info', content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that an error notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
*
|
||||
* @see createNotice
|
||||
*
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Optional notice options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createErrorNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createErrorNotice( __( 'An error occurred!' ), {
|
||||
* type: 'snackbar',
|
||||
* explicitDismiss: true,
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __(
|
||||
* 'Generate an snackbar error notice with explicit dismiss button.'
|
||||
* ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createErrorNotice(content, options) {
|
||||
return createNotice('error', content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a warning notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
*
|
||||
* @see createNotice
|
||||
*
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Optional notice options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createWarningNotice( __( 'Warning!' ), {
|
||||
* onDismiss: () => {
|
||||
* createInfoNotice(
|
||||
* __( 'The warning has been dismissed!' )
|
||||
* );
|
||||
* },
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Generates a warning notice with onDismiss callback' ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createWarningNotice(content, options) {
|
||||
return createNotice('warning', content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a notice is to be removed.
|
||||
*
|
||||
* @param {string} id Notice unique identifier.
|
||||
* @param {string} [context='global'] Optional context (grouping) in which the notice is
|
||||
* intended to appear. Defaults to default context.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );
|
||||
* const { createWarningNotice, removeNotice } = useDispatch( noticesStore );
|
||||
*
|
||||
* return (
|
||||
* <>
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createWarningNotice( __( 'Warning!' ), {
|
||||
* isDismissible: false,
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Generate a notice' ) }
|
||||
* </Button>
|
||||
* { notices.length > 0 && (
|
||||
* <Button onClick={ () => removeNotice( notices[ 0 ].id ) }>
|
||||
* { __( 'Remove the notice' ) }
|
||||
* </Button>
|
||||
* ) }
|
||||
* </>
|
||||
* );
|
||||
*};
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function removeNotice(id, context = DEFAULT_CONTEXT) {
|
||||
return {
|
||||
type: 'REMOVE_NOTICE',
|
||||
id,
|
||||
context
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all notices from a given context. Defaults to the default context.
|
||||
*
|
||||
* @param {string} noticeType The context to remove all notices from.
|
||||
* @param {string} context The context to remove all notices from.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch, useSelect } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* export const ExampleComponent = () => {
|
||||
* const notices = useSelect( ( select ) =>
|
||||
* select( noticesStore ).getNotices()
|
||||
* );
|
||||
* const { removeNotices } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <>
|
||||
* <ul>
|
||||
* { notices.map( ( notice ) => (
|
||||
* <li key={ notice.id }>{ notice.content }</li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* removeAllNotices()
|
||||
* }
|
||||
* >
|
||||
* { __( 'Clear all notices', 'woo-gutenberg-products-block' ) }
|
||||
* </Button>
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* removeAllNotices( 'snackbar' )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) }
|
||||
* </Button>
|
||||
* </>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function removeAllNotices(noticeType = 'default', context = DEFAULT_CONTEXT) {
|
||||
return {
|
||||
type: 'REMOVE_ALL_NOTICES',
|
||||
noticeType,
|
||||
context
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that several notices are to be removed.
|
||||
*
|
||||
* @param {string[]} ids List of unique notice identifiers.
|
||||
* @param {string} [context='global'] Optional context (grouping) in which the notices are
|
||||
* intended to appear. Defaults to default context.
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch, useSelect } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const notices = useSelect( ( select ) =>
|
||||
* select( noticesStore ).getNotices()
|
||||
* );
|
||||
* const { removeNotices } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <>
|
||||
* <ul>
|
||||
* { notices.map( ( notice ) => (
|
||||
* <li key={ notice.id }>{ notice.content }</li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* removeNotices( notices.map( ( { id } ) => id ) )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Clear all notices' ) }
|
||||
* </Button>
|
||||
* </>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function removeNotices(ids, context = DEFAULT_CONTEXT) {
|
||||
return {
|
||||
type: 'REMOVE_NOTICES',
|
||||
ids,
|
||||
context
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
|
||||
|
||||
/**
|
||||
* The default empty set of notices to return when there are no notices
|
||||
* assigned for a given notices context. This can occur if the getNotices
|
||||
* selector is called without a notice ever having been created for the
|
||||
* context. A shared value is used to ensure referential equality between
|
||||
* sequential selector calls, since otherwise `[] !== []`.
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
const DEFAULT_NOTICES = [];
|
||||
|
||||
/**
|
||||
* @typedef {Object} WPNotice Notice object.
|
||||
*
|
||||
* @property {string} id Unique identifier of notice.
|
||||
* @property {string} status Status of notice, one of `success`,
|
||||
* `info`, `error`, or `warning`. Defaults
|
||||
* to `info`.
|
||||
* @property {string} content Notice message.
|
||||
* @property {string} spokenMessage Audibly announced message text used by
|
||||
* assistive technologies.
|
||||
* @property {string} __unstableHTML Notice message as raw HTML. Intended to
|
||||
* serve primarily for compatibility of
|
||||
* server-rendered notices, and SHOULD NOT
|
||||
* be used for notices. It is subject to
|
||||
* removal without notice.
|
||||
* @property {boolean} isDismissible Whether the notice can be dismissed by
|
||||
* user. Defaults to `true`.
|
||||
* @property {string} type Type of notice, one of `default`,
|
||||
* or `snackbar`. Defaults to `default`.
|
||||
* @property {boolean} speak Whether the notice content should be
|
||||
* announced to screen readers. Defaults to
|
||||
* `true`.
|
||||
* @property {WPNoticeAction[]} actions User actions to present with notice.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns all notices as an array, optionally for a given context. Defaults to
|
||||
* the global context.
|
||||
*
|
||||
* @param {Object} state Notices state.
|
||||
* @param {?string} context Optional grouping context.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );
|
||||
* return (
|
||||
* <ul>
|
||||
* { notices.map( ( notice ) => (
|
||||
* <li key={ notice.ID }>{ notice.content }</li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* )
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {WPNotice[]} Array of notices.
|
||||
*/
|
||||
function getNotices(state, context = DEFAULT_CONTEXT) {
|
||||
return state[context] || DEFAULT_NOTICES;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Store definition for the notices namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*/
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)('core/notices', {
|
||||
reducer: reducer,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).notices = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{store:function(){return b}});var n={};e.r(n),e.d(n,{createErrorNotice:function(){return E},createInfoNotice:function(){return d},createNotice:function(){return f},createSuccessNotice:function(){return l},createWarningNotice:function(){return p},removeAllNotices:function(){return O},removeNotice:function(){return y},removeNotices:function(){return N}});var r={};e.r(r),e.d(r,{getNotices:function(){return _}});var i=window.wp.data;var o=e=>t=>(n={},r)=>{const i=r[e];if(void 0===i)return n;const o=t(n[i],r);return o===n[i]?n:{...n,[i]:o}};var c=o("context")(((e=[],t)=>{switch(t.type){case"CREATE_NOTICE":return[...e.filter((({id:e})=>e!==t.notice.id)),t.notice];case"REMOVE_NOTICE":return e.filter((({id:e})=>e!==t.id));case"REMOVE_NOTICES":return e.filter((({id:e})=>!t.ids.includes(e)));case"REMOVE_ALL_NOTICES":return e.filter((({type:e})=>e!==t.noticeType))}return e}));const u="global",s="info";let a=0;function f(e=s,t,n={}){const{speak:r=!0,isDismissible:i=!0,context:o=u,id:c=`${o}${++a}`,actions:f=[],type:l="default",__unstableHTML:d,icon:E=null,explicitDismiss:p=!1,onDismiss:y}=n;return{type:"CREATE_NOTICE",context:o,notice:{id:c,status:e,content:t=String(t),spokenMessage:r?t:null,__unstableHTML:d,isDismissible:i,actions:f,type:l,icon:E,explicitDismiss:p,onDismiss:y}}}function l(e,t){return f("success",e,t)}function d(e,t){return f("info",e,t)}function E(e,t){return f("error",e,t)}function p(e,t){return f("warning",e,t)}function y(e,t=u){return{type:"REMOVE_NOTICE",id:e,context:t}}function O(e="default",t=u){return{type:"REMOVE_ALL_NOTICES",noticeType:e,context:t}}function N(e,t=u){return{type:"REMOVE_NOTICES",ids:e,context:t}}const T=[];function _(e,t=u){return e[t]||T}const b=(0,i.createReduxStore)("core/notices",{reducer:c,actions:n,selectors:r});(0,i.register)(b),(window.wp=window.wp||{}).notices=t}();
|
||||
Vendored
+744
@@ -0,0 +1,744 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
DotTip: function() { return /* reexport */ dot_tip; },
|
||||
store: function() { return /* reexport */ store; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/actions.js
|
||||
var actions_namespaceObject = {};
|
||||
__webpack_require__.r(actions_namespaceObject);
|
||||
__webpack_require__.d(actions_namespaceObject, {
|
||||
disableTips: function() { return disableTips; },
|
||||
dismissTip: function() { return dismissTip; },
|
||||
enableTips: function() { return enableTips; },
|
||||
triggerGuide: function() { return triggerGuide; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/selectors.js
|
||||
var selectors_namespaceObject = {};
|
||||
__webpack_require__.r(selectors_namespaceObject);
|
||||
__webpack_require__.d(selectors_namespaceObject, {
|
||||
areTipsEnabled: function() { return selectors_areTipsEnabled; },
|
||||
getAssociatedGuide: function() { return getAssociatedGuide; },
|
||||
isTipVisible: function() { return isTipVisible; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","deprecated"]
|
||||
var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
|
||||
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
var external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/reducer.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Reducer that tracks which tips are in a guide. Each guide is represented by
|
||||
* an array which contains the tip identifiers contained within that guide.
|
||||
*
|
||||
* @param {Array} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Array} Updated state.
|
||||
*/
|
||||
function guides(state = [], action) {
|
||||
switch (action.type) {
|
||||
case 'TRIGGER_GUIDE':
|
||||
return [...state, action.tipIds];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reducer that tracks whether or not tips are globally enabled.
|
||||
*
|
||||
* @param {boolean} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {boolean} Updated state.
|
||||
*/
|
||||
function areTipsEnabled(state = true, action) {
|
||||
switch (action.type) {
|
||||
case 'DISABLE_TIPS':
|
||||
return false;
|
||||
case 'ENABLE_TIPS':
|
||||
return true;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reducer that tracks which tips have been dismissed. If the state object
|
||||
* contains a tip identifier, then that tip is dismissed.
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
function dismissedTips(state = {}, action) {
|
||||
switch (action.type) {
|
||||
case 'DISMISS_TIP':
|
||||
return {
|
||||
...state,
|
||||
[action.id]: true
|
||||
};
|
||||
case 'ENABLE_TIPS':
|
||||
return {};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
const preferences = (0,external_wp_data_namespaceObject.combineReducers)({
|
||||
areTipsEnabled,
|
||||
dismissedTips
|
||||
});
|
||||
/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
|
||||
guides,
|
||||
preferences
|
||||
}));
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/actions.js
|
||||
/**
|
||||
* Returns an action object that, when dispatched, presents a guide that takes
|
||||
* the user through a series of tips step by step.
|
||||
*
|
||||
* @param {string[]} tipIds Which tips to show in the guide.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function triggerGuide(tipIds) {
|
||||
return {
|
||||
type: 'TRIGGER_GUIDE',
|
||||
tipIds
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object that, when dispatched, dismisses the given tip. A
|
||||
* dismissed tip will not show again.
|
||||
*
|
||||
* @param {string} id The tip to dismiss.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function dismissTip(id) {
|
||||
return {
|
||||
type: 'DISMISS_TIP',
|
||||
id
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object that, when dispatched, prevents all tips from
|
||||
* showing again.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function disableTips() {
|
||||
return {
|
||||
type: 'DISABLE_TIPS'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object that, when dispatched, makes all tips show again.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function enableTips() {
|
||||
return {
|
||||
type: 'ENABLE_TIPS'
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js
|
||||
|
||||
|
||||
/** @typedef {(...args: any[]) => *[]} GetDependants */
|
||||
|
||||
/** @typedef {() => void} Clear */
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* getDependants: GetDependants,
|
||||
* clear: Clear
|
||||
* }} EnhancedSelector
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal cache entry.
|
||||
*
|
||||
* @typedef CacheNode
|
||||
*
|
||||
* @property {?CacheNode|undefined} [prev] Previous node.
|
||||
* @property {?CacheNode|undefined} [next] Next node.
|
||||
* @property {*[]} args Function arguments for cache entry.
|
||||
* @property {*} val Function result.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Cache
|
||||
*
|
||||
* @property {Clear} clear Function to clear cache.
|
||||
* @property {boolean} [isUniqueByDependants] Whether dependants are valid in
|
||||
* considering cache uniqueness. A cache is unique if dependents are all arrays
|
||||
* or objects.
|
||||
* @property {CacheNode?} [head] Cache head.
|
||||
* @property {*[]} [lastDependants] Dependants from previous invocation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Arbitrary value used as key for referencing cache object in WeakMap tree.
|
||||
*
|
||||
* @type {{}}
|
||||
*/
|
||||
var LEAF_KEY = {};
|
||||
|
||||
/**
|
||||
* Returns the first argument as the sole entry in an array.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @param {T} value Value to return.
|
||||
*
|
||||
* @return {[T]} Value returned as entry in array.
|
||||
*/
|
||||
function arrayOf(value) {
|
||||
return [value];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the value passed is object-like, or false otherwise. A value
|
||||
* is object-like if it can support property assignment, e.g. object or array.
|
||||
*
|
||||
* @param {*} value Value to test.
|
||||
*
|
||||
* @return {boolean} Whether value is object-like.
|
||||
*/
|
||||
function isObjectLike(value) {
|
||||
return !!value && 'object' === typeof value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new cache object.
|
||||
*
|
||||
* @return {Cache} Cache object.
|
||||
*/
|
||||
function createCache() {
|
||||
/** @type {Cache} */
|
||||
var cache = {
|
||||
clear: function () {
|
||||
cache.head = null;
|
||||
},
|
||||
};
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if entries within the two arrays are strictly equal by
|
||||
* reference from a starting index.
|
||||
*
|
||||
* @param {*[]} a First array.
|
||||
* @param {*[]} b Second array.
|
||||
* @param {number} fromIndex Index from which to start comparison.
|
||||
*
|
||||
* @return {boolean} Whether arrays are shallowly equal.
|
||||
*/
|
||||
function isShallowEqual(a, b, fromIndex) {
|
||||
var i;
|
||||
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = fromIndex; i < a.length; i++) {
|
||||
if (a[i] !== b[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<*,*>} */
|
||||
var rootCache;
|
||||
|
||||
/** @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.
|
||||
*
|
||||
* @see isObjectLike
|
||||
*
|
||||
* @param {*[]} dependants Selector dependants.
|
||||
*
|
||||
* @return {Cache} Cache object.
|
||||
*/
|
||||
function getCache(dependants) {
|
||||
var caches = rootCache,
|
||||
isUniqueByDependants = true,
|
||||
i,
|
||||
dependant,
|
||||
map,
|
||||
cache;
|
||||
|
||||
for (i = 0; i < dependants.length; i++) {
|
||||
dependant = dependants[i];
|
||||
|
||||
// Can only compose WeakMap from object-like key.
|
||||
if (!isObjectLike(dependant)) {
|
||||
isUniqueByDependants = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Does current segment of cache already have a WeakMap?
|
||||
if (caches.has(dependant)) {
|
||||
// Traverse into nested WeakMap.
|
||||
caches = caches.get(dependant);
|
||||
} else {
|
||||
// Create, set, and traverse into a new one.
|
||||
map = new WeakMap();
|
||||
caches.set(dependant, map);
|
||||
caches = 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 = createCache();
|
||||
cache.isUniqueByDependants = isUniqueByDependants;
|
||||
caches.set(LEAF_KEY, cache);
|
||||
}
|
||||
|
||||
return caches.get(LEAF_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets root memoization cache.
|
||||
*/
|
||||
function clear() {
|
||||
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,
|
||||
cache,
|
||||
node,
|
||||
i,
|
||||
args,
|
||||
dependants;
|
||||
|
||||
// Create copy of arguments (avoid leaking deoptimization).
|
||||
args = new Array(len);
|
||||
for (i = 0; i < len; i++) {
|
||||
args[i] = arguments[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) {
|
||||
if (
|
||||
cache.lastDependants &&
|
||||
!isShallowEqual(dependants, cache.lastDependants, 0)
|
||||
) {
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
cache.lastDependants = dependants;
|
||||
}
|
||||
|
||||
node = cache.head;
|
||||
while (node) {
|
||||
// Check whether node arguments match arguments
|
||||
if (!isShallowEqual(node.args, args, 1)) {
|
||||
node = node.next;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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;
|
||||
if (node.next) {
|
||||
node.next.prev = node.prev;
|
||||
}
|
||||
|
||||
node.next = cache.head;
|
||||
node.prev = null;
|
||||
/** @type {CacheNode} */ (cache.head).prev = node;
|
||||
cache.head = node;
|
||||
}
|
||||
|
||||
// Return immediately
|
||||
return node.val;
|
||||
}
|
||||
|
||||
// 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.
|
||||
args[0] = null;
|
||||
node.args = 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 (cache.head) {
|
||||
cache.head.prev = node;
|
||||
node.next = cache.head;
|
||||
}
|
||||
|
||||
cache.head = node;
|
||||
|
||||
return node.val;
|
||||
}
|
||||
|
||||
callSelector.getDependants = normalizedGetDependants;
|
||||
callSelector.clear = clear;
|
||||
clear();
|
||||
|
||||
return /** @type {S & EnhancedSelector} */ (callSelector);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/selectors.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* An object containing information about a guide.
|
||||
*
|
||||
* @typedef {Object} NUXGuideInfo
|
||||
* @property {string[]} tipIds Which tips the guide contains.
|
||||
* @property {?string} currentTipId The guide's currently showing tip.
|
||||
* @property {?string} nextTipId The guide's next tip to show.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns an object describing the guide, if any, that the given tip is a part
|
||||
* of.
|
||||
*
|
||||
* @param {Object} state Global application state.
|
||||
* @param {string} tipId The tip to query.
|
||||
*
|
||||
* @return {?NUXGuideInfo} Information about the associated guide.
|
||||
*/
|
||||
const getAssociatedGuide = rememo((state, tipId) => {
|
||||
for (const tipIds of state.guides) {
|
||||
if (tipIds.includes(tipId)) {
|
||||
const nonDismissedTips = tipIds.filter(tId => !Object.keys(state.preferences.dismissedTips).includes(tId));
|
||||
const [currentTipId = null, nextTipId = null] = nonDismissedTips;
|
||||
return {
|
||||
tipIds,
|
||||
currentTipId,
|
||||
nextTipId
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}, state => [state.guides, state.preferences.dismissedTips]);
|
||||
|
||||
/**
|
||||
* Determines whether or not the given tip is showing. Tips are hidden if they
|
||||
* are disabled, have been dismissed, or are not the current tip in any
|
||||
* guide that they have been added to.
|
||||
*
|
||||
* @param {Object} state Global application state.
|
||||
* @param {string} tipId The tip to query.
|
||||
*
|
||||
* @return {boolean} Whether or not the given tip is showing.
|
||||
*/
|
||||
function isTipVisible(state, tipId) {
|
||||
if (!state.preferences.areTipsEnabled) {
|
||||
return false;
|
||||
}
|
||||
if (state.preferences.dismissedTips?.hasOwnProperty(tipId)) {
|
||||
return false;
|
||||
}
|
||||
const associatedGuide = getAssociatedGuide(state, tipId);
|
||||
if (associatedGuide && associatedGuide.currentTipId !== tipId) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not tips are globally enabled.
|
||||
*
|
||||
* @param {Object} state Global application state.
|
||||
*
|
||||
* @return {boolean} Whether tips are globally enabled.
|
||||
*/
|
||||
function selectors_areTipsEnabled(state) {
|
||||
return state.preferences.areTipsEnabled;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const STORE_NAME = 'core/nux';
|
||||
|
||||
/**
|
||||
* Store definition for the nux namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
||||
reducer: reducer,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject,
|
||||
persist: ['preferences']
|
||||
});
|
||||
|
||||
// Once we build a more generic persistence plugin that works across types of stores
|
||||
// we'd be able to replace this with a register call.
|
||||
(0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, {
|
||||
reducer: reducer,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject,
|
||||
persist: ['preferences']
|
||||
});
|
||||
|
||||
;// 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 ["wp","components"]
|
||||
var external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: external ["wp","primitives"]
|
||||
var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
|
||||
}));
|
||||
/* harmony default export */ var library_close = (close_close);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/components/dot-tip/index.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
function onClick(event) {
|
||||
// Tips are often nested within buttons. We stop propagation so that clicking
|
||||
// on a tip doesn't result in the button being clicked.
|
||||
event.stopPropagation();
|
||||
}
|
||||
function DotTip({
|
||||
position = 'middle right',
|
||||
children,
|
||||
isVisible,
|
||||
hasNextTip,
|
||||
onDismiss,
|
||||
onDisable
|
||||
}) {
|
||||
const anchorParent = (0,external_wp_element_namespaceObject.useRef)(null);
|
||||
const onFocusOutsideCallback = (0,external_wp_element_namespaceObject.useCallback)(event => {
|
||||
if (!anchorParent.current) {
|
||||
return;
|
||||
}
|
||||
if (anchorParent.current.contains(event.relatedTarget)) {
|
||||
return;
|
||||
}
|
||||
onDisable();
|
||||
}, [onDisable, anchorParent]);
|
||||
if (!isVisible) {
|
||||
return null;
|
||||
}
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
|
||||
className: "nux-dot-tip",
|
||||
position: position,
|
||||
focusOnMount: true,
|
||||
role: "dialog",
|
||||
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Editor tips'),
|
||||
onClick: onClick,
|
||||
onFocusOutside: onFocusOutsideCallback
|
||||
}, (0,external_wp_element_namespaceObject.createElement)("p", null, children), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
|
||||
variant: "link",
|
||||
onClick: onDismiss
|
||||
}, hasNextTip ? (0,external_wp_i18n_namespaceObject.__)('See next tip') : (0,external_wp_i18n_namespaceObject.__)('Got it'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
|
||||
className: "nux-dot-tip__disable",
|
||||
icon: library_close,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Disable tips'),
|
||||
onClick: onDisable
|
||||
}));
|
||||
}
|
||||
/* harmony default export */ var dot_tip = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, {
|
||||
tipId
|
||||
}) => {
|
||||
const {
|
||||
isTipVisible,
|
||||
getAssociatedGuide
|
||||
} = select(store);
|
||||
const associatedGuide = getAssociatedGuide(tipId);
|
||||
return {
|
||||
isVisible: isTipVisible(tipId),
|
||||
hasNextTip: !!(associatedGuide && associatedGuide.nextTipId)
|
||||
};
|
||||
}), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
|
||||
tipId
|
||||
}) => {
|
||||
const {
|
||||
dismissTip,
|
||||
disableTips
|
||||
} = dispatch(store);
|
||||
return {
|
||||
onDismiss() {
|
||||
dismissTip(tipId);
|
||||
},
|
||||
onDisable() {
|
||||
disableTips();
|
||||
}
|
||||
};
|
||||
}))(DotTip));
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
external_wp_deprecated_default()('wp.nux', {
|
||||
since: '5.4',
|
||||
hint: 'wp.components.Guide can be used to show a user guide.',
|
||||
version: '6.2'
|
||||
});
|
||||
|
||||
(window.wp = window.wp || {}).nux = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={n:function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,{a:t}),t},d:function(n,t){for(var r in t)e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{DotTip:function(){return P},store:function(){return g}});var t={};e.r(t),e.d(t,{disableTips:function(){return l},dismissTip:function(){return p},enableTips:function(){return d},triggerGuide:function(){return c}});var r={};e.r(r),e.d(r,{areTipsEnabled:function(){return h},getAssociatedGuide:function(){return v},isTipVisible:function(){return b}});var i=window.wp.deprecated,s=e.n(i),o=window.wp.data;const u=(0,o.combineReducers)({areTipsEnabled:function(e=!0,n){switch(n.type){case"DISABLE_TIPS":return!1;case"ENABLE_TIPS":return!0}return e},dismissedTips:function(e={},n){switch(n.type){case"DISMISS_TIP":return{...e,[n.id]:!0};case"ENABLE_TIPS":return{}}return e}});var a=(0,o.combineReducers)({guides:function(e=[],n){return"TRIGGER_GUIDE"===n.type?[...e,n.tipIds]:e},preferences:u});function c(e){return{type:"TRIGGER_GUIDE",tipIds:e}}function p(e){return{type:"DISMISS_TIP",id:e}}function l(){return{type:"DISABLE_TIPS"}}function d(){return{type:"ENABLE_TIPS"}}var f={};function w(e){return[e]}function T(e,n,t){var r;if(e.length!==n.length)return!1;for(r=t;r<e.length;r++)if(e[r]!==n[r])return!1;return!0}const v=function(e,n){var t,r=n||w;function i(){t=new WeakMap}function s(){var n,i,s,o,u,a=arguments.length;for(o=new Array(a),s=0;s<a;s++)o[s]=arguments[s];for(n=function(e){var n,r,i,s,o,u=t,a=!0;for(n=0;n<e.length;n++){if(!(o=r=e[n])||"object"!=typeof o){a=!1;break}u.has(r)?u=u.get(r):(i=new WeakMap,u.set(r,i),u=i)}return u.has(f)||((s=function(){var e={clear:function(){e.head=null}};return e}()).isUniqueByDependants=a,u.set(f,s)),u.get(f)}(u=r.apply(null,o)),n.isUniqueByDependants||(n.lastDependants&&!T(u,n.lastDependants,0)&&n.clear(),n.lastDependants=u),i=n.head;i;){if(T(i.args,o,1))return i!==n.head&&(i.prev.next=i.next,i.next&&(i.next.prev=i.prev),i.next=n.head,i.prev=null,n.head.prev=i,n.head=i),i.val;i=i.next}return i={val:e.apply(null,o)},o[0]=null,i.args=o,n.head&&(n.head.prev=i,i.next=n.head),n.head=i,i.val}return s.getDependants=r,s.clear=i,i(),s}(((e,n)=>{for(const t of e.guides)if(t.includes(n)){const n=t.filter((n=>!Object.keys(e.preferences.dismissedTips).includes(n))),[r=null,i=null]=n;return{tipIds:t,currentTipId:r,nextTipId:i}}return null}),(e=>[e.guides,e.preferences.dismissedTips]));function b(e,n){if(!e.preferences.areTipsEnabled)return!1;if(e.preferences.dismissedTips?.hasOwnProperty(n))return!1;const t=v(e,n);return!t||t.currentTipId===n}function h(e){return e.preferences.areTipsEnabled}const m="core/nux",g=(0,o.createReduxStore)(m,{reducer:a,actions:t,selectors:r,persist:["preferences"]});(0,o.registerStore)(m,{reducer:a,actions:t,selectors:r,persist:["preferences"]});var I=window.wp.element,y=window.wp.compose,E=window.wp.components,S=window.wp.i18n,_=window.wp.primitives;var x=(0,I.createElement)(_.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,I.createElement)(_.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"}));function D(e){e.stopPropagation()}var P=(0,y.compose)((0,o.withSelect)(((e,{tipId:n})=>{const{isTipVisible:t,getAssociatedGuide:r}=e(g),i=r(n);return{isVisible:t(n),hasNextTip:!(!i||!i.nextTipId)}})),(0,o.withDispatch)(((e,{tipId:n})=>{const{dismissTip:t,disableTips:r}=e(g);return{onDismiss(){t(n)},onDisable(){r()}}})))((function({position:e="middle right",children:n,isVisible:t,hasNextTip:r,onDismiss:i,onDisable:s}){const o=(0,I.useRef)(null),u=(0,I.useCallback)((e=>{o.current&&(o.current.contains(e.relatedTarget)||s())}),[s,o]);return t?(0,I.createElement)(E.Popover,{className:"nux-dot-tip",position:e,focusOnMount:!0,role:"dialog","aria-label":(0,S.__)("Editor tips"),onClick:D,onFocusOutside:u},(0,I.createElement)("p",null,n),(0,I.createElement)("p",null,(0,I.createElement)(E.Button,{variant:"link",onClick:i},r?(0,S.__)("See next tip"):(0,S.__)("Got it"))),(0,I.createElement)(E.Button,{className:"nux-dot-tip__disable",icon:x,label:(0,S.__)("Disable tips"),onClick:s})):null}));s()("wp.nux",{since:"5.4",hint:"wp.components.Guide can be used to show a user guide.",version:"6.2"}),(window.wp=window.wp||{}).nux=n}();
|
||||
Vendored
+762
@@ -0,0 +1,762 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
privateApis: function() { return /* reexport */ privateApis; },
|
||||
store: function() { return /* reexport */ store; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/patterns/build-module/store/actions.js
|
||||
var actions_namespaceObject = {};
|
||||
__webpack_require__.r(actions_namespaceObject);
|
||||
__webpack_require__.d(actions_namespaceObject, {
|
||||
convertSyncedPatternToStatic: function() { return convertSyncedPatternToStatic; },
|
||||
createPattern: function() { return createPattern; },
|
||||
createPatternFromFile: function() { return createPatternFromFile; },
|
||||
setEditingPattern: function() { return setEditingPattern; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/patterns/build-module/store/selectors.js
|
||||
var selectors_namespaceObject = {};
|
||||
__webpack_require__.r(selectors_namespaceObject);
|
||||
__webpack_require__.d(selectors_namespaceObject, {
|
||||
isEditingPattern: function() { return selectors_isEditingPattern; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
var external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/reducer.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
function isEditingPattern(state = {}, action) {
|
||||
if (action?.type === 'SET_EDITING_PATTERN') {
|
||||
return {
|
||||
...state,
|
||||
[action.clientId]: action.isEditing
|
||||
};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
|
||||
isEditingPattern
|
||||
}));
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","blocks"]
|
||||
var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
|
||||
;// CONCATENATED MODULE: external ["wp","coreData"]
|
||||
var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
|
||||
;// CONCATENATED MODULE: external ["wp","blockEditor"]
|
||||
var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/constants.js
|
||||
const PATTERN_TYPES = {
|
||||
theme: 'pattern',
|
||||
user: 'wp_block'
|
||||
};
|
||||
const PATTERN_DEFAULT_CATEGORY = 'all-patterns';
|
||||
const PATTERN_USER_CATEGORY = 'my-patterns';
|
||||
const PATTERN_CORE_SOURCES = ['core', 'pattern-directory/core', 'pattern-directory/featured', 'pattern-directory/theme'];
|
||||
const PATTERN_SYNC_TYPES = {
|
||||
full: 'fully',
|
||||
unsynced: 'unsynced'
|
||||
};
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/actions.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Returns a generator converting one or more static blocks into a pattern, or creating a new empty pattern.
|
||||
*
|
||||
* @param {string} title Pattern title.
|
||||
* @param {'full'|'unsynced'} syncType They way block is synced, 'full' or 'unsynced'.
|
||||
* @param {string|undefined} [content] Optional serialized content of blocks to convert to pattern.
|
||||
* @param {number[]|undefined} [categories] Ids of any selected categories.
|
||||
*/
|
||||
const createPattern = (title, syncType, content, categories) => async ({
|
||||
registry
|
||||
}) => {
|
||||
const meta = syncType === PATTERN_SYNC_TYPES.unsynced ? {
|
||||
wp_pattern_sync_status: syncType
|
||||
} : undefined;
|
||||
const reusableBlock = {
|
||||
title,
|
||||
content,
|
||||
status: 'publish',
|
||||
meta,
|
||||
wp_pattern_category: categories
|
||||
};
|
||||
const updatedRecord = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_block', reusableBlock);
|
||||
return updatedRecord;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a pattern from a JSON file.
|
||||
* @param {File} file The JSON file instance of the pattern.
|
||||
* @param {number[]|undefined} [categories] Ids of any selected categories.
|
||||
*/
|
||||
const createPatternFromFile = (file, categories) => async ({
|
||||
dispatch
|
||||
}) => {
|
||||
const fileContent = await file.text();
|
||||
/** @type {import('./types').PatternJSON} */
|
||||
let parsedContent;
|
||||
try {
|
||||
parsedContent = JSON.parse(fileContent);
|
||||
} catch (e) {
|
||||
throw new Error('Invalid JSON file');
|
||||
}
|
||||
if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== 'string' || typeof parsedContent.content !== 'string' || parsedContent.syncStatus && typeof parsedContent.syncStatus !== 'string') {
|
||||
throw new Error('Invalid pattern JSON file');
|
||||
}
|
||||
const pattern = await dispatch.createPattern(parsedContent.title, parsedContent.syncStatus, parsedContent.content, categories);
|
||||
return pattern;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a generator converting a synced pattern block into a static block.
|
||||
*
|
||||
* @param {string} clientId The client ID of the block to attach.
|
||||
*/
|
||||
const convertSyncedPatternToStatic = clientId => ({
|
||||
registry
|
||||
}) => {
|
||||
const oldBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId);
|
||||
const pattern = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref);
|
||||
const newBlocks = (0,external_wp_blocks_namespaceObject.parse)(typeof pattern.content === 'function' ? pattern.content(pattern) : pattern.content);
|
||||
registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(oldBlock.clientId, newBlocks);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an action descriptor for SET_EDITING_PATTERN action.
|
||||
*
|
||||
* @param {string} clientId The clientID of the pattern to target.
|
||||
* @param {boolean} isEditing Whether the block should be in editing state.
|
||||
* @return {Object} Action descriptor.
|
||||
*/
|
||||
function setEditingPattern(clientId, isEditing) {
|
||||
return {
|
||||
type: 'SET_EDITING_PATTERN',
|
||||
clientId,
|
||||
isEditing
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/constants.js
|
||||
/**
|
||||
* Module Constants
|
||||
*/
|
||||
const STORE_NAME = 'core/patterns';
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/selectors.js
|
||||
/**
|
||||
* Returns true if pattern is in the editing state.
|
||||
*
|
||||
* @param {Object} state Global application state.
|
||||
* @param {number} clientId the clientID of the block.
|
||||
* @return {boolean} Whether the pattern is in the editing state.
|
||||
*/
|
||||
function selectors_isEditingPattern(state, clientId) {
|
||||
return state.isEditingPattern[clientId];
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","privateApis"]
|
||||
var external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/lock-unlock.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
lock,
|
||||
unlock
|
||||
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/patterns');
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Post editor data store configuration.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const storeConfig = {
|
||||
reducer: reducer
|
||||
};
|
||||
|
||||
/**
|
||||
* Store definition for the editor namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
||||
...storeConfig
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
unlock(store).registerPrivateActions(actions_namespaceObject);
|
||||
unlock(store).registerPrivateSelectors(selectors_namespaceObject);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
var external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","components"]
|
||||
var external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: external ["wp","notices"]
|
||||
var external_wp_notices_namespaceObject = window["wp"]["notices"];
|
||||
;// CONCATENATED MODULE: external ["wp","compose"]
|
||||
var external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// CONCATENATED MODULE: external ["wp","htmlEntities"]
|
||||
var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/components/category-selector.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const unescapeString = arg => {
|
||||
return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(arg);
|
||||
};
|
||||
const CATEGORY_SLUG = 'wp_pattern_category';
|
||||
function CategorySelector({
|
||||
categoryTerms,
|
||||
onChange,
|
||||
categoryMap
|
||||
}) {
|
||||
const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
|
||||
const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500);
|
||||
const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
return Array.from(categoryMap.values()).map(category => unescapeString(category.label)).filter(category => {
|
||||
if (search !== '') {
|
||||
return category.toLowerCase().includes(search.toLowerCase());
|
||||
}
|
||||
return true;
|
||||
}).sort((a, b) => a.localeCompare(b));
|
||||
}, [search, categoryMap]);
|
||||
function handleChange(termNames) {
|
||||
const uniqueTerms = termNames.reduce((terms, newTerm) => {
|
||||
if (!terms.some(term => term.toLowerCase() === newTerm.toLowerCase())) {
|
||||
terms.push(newTerm);
|
||||
}
|
||||
return terms;
|
||||
}, []);
|
||||
onChange(uniqueTerms);
|
||||
}
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormTokenField, {
|
||||
className: "patterns-menu-items__convert-modal-categories",
|
||||
value: categoryTerms,
|
||||
suggestions: suggestions,
|
||||
onChange: handleChange,
|
||||
onInputChange: debouncedSearch,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Categories'),
|
||||
tokenizeOnBlur: true,
|
||||
__experimentalExpandOnFocus: true,
|
||||
__next40pxDefaultSize: true
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/components/create-pattern-modal.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function CreatePatternModal({
|
||||
onSuccess,
|
||||
onError,
|
||||
content,
|
||||
onClose,
|
||||
className = 'patterns-menu-items__convert-modal'
|
||||
}) {
|
||||
const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(PATTERN_SYNC_TYPES.full);
|
||||
const [categoryTerms, setCategoryTerms] = (0,external_wp_element_namespaceObject.useState)([]);
|
||||
const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
|
||||
const [isSaving, setIsSaving] = (0,external_wp_element_namespaceObject.useState)(false);
|
||||
const {
|
||||
createPattern
|
||||
} = unlock((0,external_wp_data_namespaceObject.useDispatch)(store));
|
||||
const {
|
||||
saveEntityRecord,
|
||||
invalidateResolution
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
|
||||
const {
|
||||
createErrorNotice
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
|
||||
const {
|
||||
corePatternCategories,
|
||||
userPatternCategories
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
const {
|
||||
getUserPatternCategories,
|
||||
getBlockPatternCategories
|
||||
} = select(external_wp_coreData_namespaceObject.store);
|
||||
return {
|
||||
corePatternCategories: getBlockPatternCategories(),
|
||||
userPatternCategories: getUserPatternCategories()
|
||||
};
|
||||
});
|
||||
const categoryMap = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
// Merge the user and core pattern categories and remove any duplicates.
|
||||
const uniqueCategories = new Map();
|
||||
[...userPatternCategories, ...corePatternCategories].forEach(category => {
|
||||
if (!uniqueCategories.has(category.label) &&
|
||||
// There are two core categories with `Post` label so explicitly remove the one with
|
||||
// the `query` slug to avoid any confusion.
|
||||
category.name !== 'query') {
|
||||
// We need to store the name separately as this is used as the slug in the
|
||||
// taxonomy and may vary from the label.
|
||||
uniqueCategories.set(category.label, {
|
||||
label: category.label,
|
||||
value: category.label,
|
||||
name: category.name
|
||||
});
|
||||
}
|
||||
});
|
||||
return uniqueCategories;
|
||||
}, [userPatternCategories, corePatternCategories]);
|
||||
async function onCreate(patternTitle, sync) {
|
||||
if (!title || isSaving) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
setIsSaving(true);
|
||||
const categories = await Promise.all(categoryTerms.map(termName => findOrCreateTerm(termName)));
|
||||
const newPattern = await createPattern(patternTitle, sync, typeof content === 'function' ? content() : content, categories);
|
||||
onSuccess({
|
||||
pattern: newPattern,
|
||||
categoryId: PATTERN_DEFAULT_CATEGORY
|
||||
});
|
||||
} catch (error) {
|
||||
createErrorNotice(error.message, {
|
||||
type: 'snackbar',
|
||||
id: 'convert-to-pattern-error'
|
||||
});
|
||||
onError();
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
setCategoryTerms([]);
|
||||
setTitle('');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} term
|
||||
* @return {Promise<number>} The pattern category id.
|
||||
*/
|
||||
async function findOrCreateTerm(term) {
|
||||
try {
|
||||
// We need to match any existing term to the correct slug to prevent duplicates, eg.
|
||||
// the core `Headers` category uses the singular `header` as the slug.
|
||||
const existingTerm = categoryMap.get(term);
|
||||
const termData = existingTerm ? {
|
||||
name: existingTerm.label,
|
||||
slug: existingTerm.name
|
||||
} : {
|
||||
name: term
|
||||
};
|
||||
const newTerm = await saveEntityRecord('taxonomy', CATEGORY_SLUG, termData, {
|
||||
throwOnError: true
|
||||
});
|
||||
invalidateResolution('getUserPatternCategories');
|
||||
return newTerm.id;
|
||||
} catch (error) {
|
||||
if (error.code !== 'term_exists') {
|
||||
throw error;
|
||||
}
|
||||
return error.data.term_id;
|
||||
}
|
||||
}
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
|
||||
title: (0,external_wp_i18n_namespaceObject.__)('Create pattern'),
|
||||
onRequestClose: () => {
|
||||
onClose();
|
||||
setTitle('');
|
||||
},
|
||||
overlayClassName: className
|
||||
}, (0,external_wp_element_namespaceObject.createElement)("form", {
|
||||
onSubmit: event => {
|
||||
event.preventDefault();
|
||||
onCreate(title, syncType);
|
||||
}
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
|
||||
spacing: "5"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
|
||||
__nextHasNoMarginBottom: true,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Name'),
|
||||
value: title,
|
||||
onChange: setTitle,
|
||||
placeholder: (0,external_wp_i18n_namespaceObject.__)('My pattern'),
|
||||
className: "patterns-create-modal__name-input"
|
||||
}), (0,external_wp_element_namespaceObject.createElement)(CategorySelector, {
|
||||
categoryTerms: categoryTerms,
|
||||
onChange: setCategoryTerms,
|
||||
categoryMap: categoryMap
|
||||
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Synced'),
|
||||
help: (0,external_wp_i18n_namespaceObject.__)('Editing the pattern will update it anywhere it is used.'),
|
||||
checked: syncType === PATTERN_SYNC_TYPES.full,
|
||||
onChange: () => {
|
||||
setSyncType(syncType === PATTERN_SYNC_TYPES.full ? PATTERN_SYNC_TYPES.unsynced : PATTERN_SYNC_TYPES.full);
|
||||
}
|
||||
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
|
||||
justify: "right"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
|
||||
variant: "tertiary",
|
||||
onClick: () => {
|
||||
onClose();
|
||||
setTitle('');
|
||||
}
|
||||
}, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
|
||||
variant: "primary",
|
||||
type: "submit",
|
||||
"aria-disabled": !title || isSaving,
|
||||
isBusy: isSaving
|
||||
}, (0,external_wp_i18n_namespaceObject.__)('Create'))))));
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","primitives"]
|
||||
var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const symbol = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
|
||||
}));
|
||||
/* harmony default export */ var library_symbol = (symbol);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/components/pattern-convert-button.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Menu control to convert block(s) to a pattern block.
|
||||
*
|
||||
* @param {Object} props Component props.
|
||||
* @param {string[]} props.clientIds Client ids of selected blocks.
|
||||
* @param {string} props.rootClientId ID of the currently selected top-level block.
|
||||
* @return {import('@wordpress/element').WPComponent} The menu control or null.
|
||||
*/
|
||||
function PatternConvertButton({
|
||||
clientIds,
|
||||
rootClientId
|
||||
}) {
|
||||
const {
|
||||
createSuccessNotice
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
|
||||
const {
|
||||
replaceBlocks
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
|
||||
// Ignore reason: false positive of the lint rule.
|
||||
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
||||
const {
|
||||
setEditingPattern
|
||||
} = unlock((0,external_wp_data_namespaceObject.useDispatch)(store));
|
||||
const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
|
||||
const canConvert = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
var _getBlocksByClientId;
|
||||
const {
|
||||
canUser
|
||||
} = select(external_wp_coreData_namespaceObject.store);
|
||||
const {
|
||||
getBlocksByClientId,
|
||||
canInsertBlockType,
|
||||
getBlockRootClientId
|
||||
} = select(external_wp_blockEditor_namespaceObject.store);
|
||||
const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : undefined);
|
||||
const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : [];
|
||||
const isReusable = blocks.length === 1 && blocks[0] && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]) && !!select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref);
|
||||
const _canConvert =
|
||||
// Hide when this is already a synced pattern.
|
||||
!isReusable &&
|
||||
// Hide when patterns are disabled.
|
||||
canInsertBlockType('core/block', rootId) && blocks.every(block =>
|
||||
// Guard against the case where a regular block has *just* been converted.
|
||||
!!block &&
|
||||
// Hide on invalid blocks.
|
||||
block.isValid &&
|
||||
// Hide when block doesn't support being made into a pattern.
|
||||
(0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) &&
|
||||
// Hide when current doesn't have permission to do that.
|
||||
!!canUser('create', 'blocks');
|
||||
return _canConvert;
|
||||
}, [clientIds, rootClientId]);
|
||||
const {
|
||||
getBlocksByClientId
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
|
||||
const getContent = (0,external_wp_element_namespaceObject.useCallback)(() => (0,external_wp_blocks_namespaceObject.serialize)(getBlocksByClientId(clientIds)), [getBlocksByClientId, clientIds]);
|
||||
if (!canConvert) {
|
||||
return null;
|
||||
}
|
||||
const handleSuccess = ({
|
||||
pattern
|
||||
}) => {
|
||||
if (pattern.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced) {
|
||||
const newBlock = (0,external_wp_blocks_namespaceObject.createBlock)('core/block', {
|
||||
ref: pattern.id
|
||||
});
|
||||
replaceBlocks(clientIds, newBlock);
|
||||
setEditingPattern(newBlock.clientId, true);
|
||||
}
|
||||
createSuccessNotice(pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ? (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: the name the user has given to the pattern.
|
||||
(0,external_wp_i18n_namespaceObject.__)('Unsynced pattern created: %s'), pattern.title.raw) : (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: the name the user has given to the pattern.
|
||||
(0,external_wp_i18n_namespaceObject.__)('Synced pattern created: %s'), pattern.title.raw), {
|
||||
type: 'snackbar',
|
||||
id: 'convert-to-pattern-success'
|
||||
});
|
||||
setIsModalOpen(false);
|
||||
};
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
|
||||
icon: library_symbol,
|
||||
onClick: () => setIsModalOpen(true),
|
||||
"aria-expanded": isModalOpen,
|
||||
"aria-haspopup": "dialog"
|
||||
}, (0,external_wp_i18n_namespaceObject.__)('Create pattern')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(CreatePatternModal, {
|
||||
content: getContent,
|
||||
onSuccess: pattern => {
|
||||
handleSuccess(pattern);
|
||||
},
|
||||
onError: () => {
|
||||
setIsModalOpen(false);
|
||||
},
|
||||
onClose: () => {
|
||||
setIsModalOpen(false);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","url"]
|
||||
var external_wp_url_namespaceObject = window["wp"]["url"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/components/patterns-manage-button.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
function PatternsManageButton({
|
||||
clientId
|
||||
}) {
|
||||
const {
|
||||
canRemove,
|
||||
isVisible,
|
||||
innerBlockCount,
|
||||
managePatternsUrl
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
const {
|
||||
getBlock,
|
||||
canRemoveBlock,
|
||||
getBlockCount,
|
||||
getSettings
|
||||
} = select(external_wp_blockEditor_namespaceObject.store);
|
||||
const {
|
||||
canUser
|
||||
} = select(external_wp_coreData_namespaceObject.store);
|
||||
const reusableBlock = getBlock(clientId);
|
||||
const isBlockTheme = getSettings().__unstableIsBlockBasedTheme;
|
||||
return {
|
||||
canRemove: canRemoveBlock(clientId),
|
||||
isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref),
|
||||
innerBlockCount: getBlockCount(clientId),
|
||||
// The site editor and templates both check whether the user
|
||||
// has edit_theme_options capabilities. We can leverage that here
|
||||
// and omit the manage patterns link if the user can't access it.
|
||||
managePatternsUrl: isBlockTheme && canUser('read', 'templates') ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', {
|
||||
path: '/patterns'
|
||||
}) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
|
||||
post_type: 'wp_block'
|
||||
})
|
||||
};
|
||||
}, [clientId]);
|
||||
|
||||
// Ignore reason: false positive of the lint rule.
|
||||
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
||||
const {
|
||||
convertSyncedPatternToStatic
|
||||
} = unlock((0,external_wp_data_namespaceObject.useDispatch)(store));
|
||||
if (!isVisible) {
|
||||
return null;
|
||||
}
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
|
||||
href: managePatternsUrl
|
||||
}, (0,external_wp_i18n_namespaceObject.__)('Manage patterns')), canRemove && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
|
||||
onClick: () => convertSyncedPatternToStatic(clientId)
|
||||
}, innerBlockCount > 1 ? (0,external_wp_i18n_namespaceObject.__)('Detach patterns') : (0,external_wp_i18n_namespaceObject.__)('Detach pattern')));
|
||||
}
|
||||
/* harmony default export */ var patterns_manage_button = (PatternsManageButton);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/components/index.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
function PatternsMenuItems({
|
||||
rootClientId
|
||||
}) {
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, ({
|
||||
selectedClientIds
|
||||
}) => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(PatternConvertButton, {
|
||||
clientIds: selectedClientIds,
|
||||
rootClientId: rootClientId
|
||||
}), selectedClientIds.length === 1 && (0,external_wp_element_namespaceObject.createElement)(patterns_manage_button, {
|
||||
clientId: selectedClientIds[0]
|
||||
})));
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/private-apis.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
const privateApis = {};
|
||||
lock(privateApis, {
|
||||
CreatePatternModal: CreatePatternModal,
|
||||
PatternsMenuItems: PatternsMenuItems,
|
||||
PATTERN_TYPES: PATTERN_TYPES,
|
||||
PATTERN_DEFAULT_CATEGORY: PATTERN_DEFAULT_CATEGORY,
|
||||
PATTERN_USER_CATEGORY: PATTERN_USER_CATEGORY,
|
||||
PATTERN_CORE_SOURCES: PATTERN_CORE_SOURCES,
|
||||
PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).patterns = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
File diff suppressed because one or more lines are too long
Vendored
+642
@@ -0,0 +1,642 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
PluginArea: function() { return /* reexport */ plugin_area; },
|
||||
getPlugin: function() { return /* reexport */ getPlugin; },
|
||||
getPlugins: function() { return /* reexport */ getPlugins; },
|
||||
registerPlugin: function() { return /* reexport */ registerPlugin; },
|
||||
unregisterPlugin: function() { return /* reexport */ unregisterPlugin; },
|
||||
usePluginContext: function() { return /* reexport */ usePluginContext; },
|
||||
withPluginContext: function() { return /* reexport */ withPluginContext; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
var external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
|
||||
/**
|
||||
* 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 {(...args: any[]) => any} F
|
||||
*
|
||||
* @param {F} fn Function to memoize.
|
||||
* @param {MemizeOptions} [options] Options object.
|
||||
*
|
||||
* @return {((...args: Parameters<F>) => ReturnType<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;
|
||||
};
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","hooks"]
|
||||
var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
|
||||
;// 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: external ["wp","compose"]
|
||||
var external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-context/index.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
const Context = (0,external_wp_element_namespaceObject.createContext)({
|
||||
name: null,
|
||||
icon: null
|
||||
});
|
||||
const PluginContextProvider = Context.Provider;
|
||||
|
||||
/**
|
||||
* A hook that returns the plugin context.
|
||||
*
|
||||
* @return {PluginContext} Plugin context
|
||||
*/
|
||||
function usePluginContext() {
|
||||
return (0,external_wp_element_namespaceObject.useContext)(Context);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Higher Order Component used to inject Plugin context to the
|
||||
* wrapped component.
|
||||
*
|
||||
* @param mapContextToProps Function called on every context change,
|
||||
* expected to return object of props to
|
||||
* merge with the component's own props.
|
||||
*
|
||||
* @return {WPComponent} Enhanced component with injected context as props.
|
||||
*/
|
||||
const withPluginContext = mapContextToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => {
|
||||
return props => (0,external_wp_element_namespaceObject.createElement)(Context.Consumer, null, context => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, {
|
||||
...props,
|
||||
...mapContextToProps(context, props)
|
||||
}));
|
||||
}, 'withPluginContext');
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-error-boundary/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
class PluginErrorBoundary extends external_wp_element_namespaceObject.Component {
|
||||
/**
|
||||
* @param {Object} props
|
||||
*/
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
hasError: false
|
||||
};
|
||||
}
|
||||
static getDerivedStateFromError() {
|
||||
return {
|
||||
hasError: true
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Error} error Error object passed by React.
|
||||
*/
|
||||
componentDidCatch(error) {
|
||||
const {
|
||||
name,
|
||||
onError
|
||||
} = this.props;
|
||||
if (onError) {
|
||||
onError(name, error);
|
||||
}
|
||||
}
|
||||
render() {
|
||||
if (!this.state.hasError) {
|
||||
return this.props.children;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","primitives"]
|
||||
var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plugins.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const plugins = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"
|
||||
}));
|
||||
/* harmony default export */ var library_plugins = (plugins);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/api/index.js
|
||||
/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Plugin definitions keyed by plugin name.
|
||||
*/
|
||||
const api_plugins = {};
|
||||
|
||||
/**
|
||||
* Registers a plugin to the editor.
|
||||
*
|
||||
* @param name A string identifying the plugin. Must be
|
||||
* unique across all registered plugins.
|
||||
* @param settings The settings for this plugin.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ES5 syntax
|
||||
* var el = wp.element.createElement;
|
||||
* var Fragment = wp.element.Fragment;
|
||||
* var PluginSidebar = wp.editPost.PluginSidebar;
|
||||
* var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
|
||||
* var registerPlugin = wp.plugins.registerPlugin;
|
||||
* var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
|
||||
*
|
||||
* function Component() {
|
||||
* return el(
|
||||
* Fragment,
|
||||
* {},
|
||||
* el(
|
||||
* PluginSidebarMoreMenuItem,
|
||||
* {
|
||||
* target: 'sidebar-name',
|
||||
* },
|
||||
* 'My Sidebar'
|
||||
* ),
|
||||
* el(
|
||||
* PluginSidebar,
|
||||
* {
|
||||
* name: 'sidebar-name',
|
||||
* title: 'My Sidebar',
|
||||
* },
|
||||
* 'Content of the sidebar'
|
||||
* )
|
||||
* );
|
||||
* }
|
||||
* registerPlugin( 'plugin-name', {
|
||||
* icon: moreIcon,
|
||||
* render: Component,
|
||||
* scope: 'my-page',
|
||||
* } );
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ESNext syntax
|
||||
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
|
||||
* import { registerPlugin } from '@wordpress/plugins';
|
||||
* import { more } from '@wordpress/icons';
|
||||
*
|
||||
* const Component = () => (
|
||||
* <>
|
||||
* <PluginSidebarMoreMenuItem
|
||||
* target="sidebar-name"
|
||||
* >
|
||||
* My Sidebar
|
||||
* </PluginSidebarMoreMenuItem>
|
||||
* <PluginSidebar
|
||||
* name="sidebar-name"
|
||||
* title="My Sidebar"
|
||||
* >
|
||||
* Content of the sidebar
|
||||
* </PluginSidebar>
|
||||
* </>
|
||||
* );
|
||||
*
|
||||
* registerPlugin( 'plugin-name', {
|
||||
* icon: more,
|
||||
* render: Component,
|
||||
* scope: 'my-page',
|
||||
* } );
|
||||
* ```
|
||||
*
|
||||
* @return The final plugin settings object.
|
||||
*/
|
||||
function registerPlugin(name, settings) {
|
||||
if (typeof settings !== 'object') {
|
||||
console.error('No settings object provided!');
|
||||
return null;
|
||||
}
|
||||
if (typeof name !== 'string') {
|
||||
console.error('Plugin name must be string.');
|
||||
return null;
|
||||
}
|
||||
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
||||
console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
|
||||
return null;
|
||||
}
|
||||
if (api_plugins[name]) {
|
||||
console.error(`Plugin "${name}" is already registered.`);
|
||||
}
|
||||
settings = (0,external_wp_hooks_namespaceObject.applyFilters)('plugins.registerPlugin', settings, name);
|
||||
const {
|
||||
render,
|
||||
scope
|
||||
} = settings;
|
||||
if (typeof render !== 'function') {
|
||||
console.error('The "render" property must be specified and must be a valid function.');
|
||||
return null;
|
||||
}
|
||||
if (scope) {
|
||||
if (typeof scope !== 'string') {
|
||||
console.error('Plugin scope must be string.');
|
||||
return null;
|
||||
}
|
||||
if (!/^[a-z][a-z0-9-]*$/.test(scope)) {
|
||||
console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
api_plugins[name] = {
|
||||
name,
|
||||
icon: library_plugins,
|
||||
...settings
|
||||
};
|
||||
(0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginRegistered', settings, name);
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a plugin by name.
|
||||
*
|
||||
* @param name Plugin name.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ES5 syntax
|
||||
* var unregisterPlugin = wp.plugins.unregisterPlugin;
|
||||
*
|
||||
* unregisterPlugin( 'plugin-name' );
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ESNext syntax
|
||||
* import { unregisterPlugin } from '@wordpress/plugins';
|
||||
*
|
||||
* unregisterPlugin( 'plugin-name' );
|
||||
* ```
|
||||
*
|
||||
* @return The previous plugin settings object, if it has been
|
||||
* successfully unregistered; otherwise `undefined`.
|
||||
*/
|
||||
function unregisterPlugin(name) {
|
||||
if (!api_plugins[name]) {
|
||||
console.error('Plugin "' + name + '" is not registered.');
|
||||
return;
|
||||
}
|
||||
const oldPlugin = api_plugins[name];
|
||||
delete api_plugins[name];
|
||||
(0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginUnregistered', oldPlugin, name);
|
||||
return oldPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a registered plugin settings.
|
||||
*
|
||||
* @param name Plugin name.
|
||||
*
|
||||
* @return Plugin setting.
|
||||
*/
|
||||
function getPlugin(name) {
|
||||
return api_plugins[name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all registered plugins without a scope or for a given scope.
|
||||
*
|
||||
* @param scope The scope to be used when rendering inside
|
||||
* a plugin area. No scope by default.
|
||||
*
|
||||
* @return The list of plugins without a scope or for a given scope.
|
||||
*/
|
||||
function getPlugins(scope) {
|
||||
return Object.values(api_plugins).filter(plugin => plugin.scope === scope);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-area/index.js
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const getPluginContext = memize((icon, name) => ({
|
||||
icon,
|
||||
name
|
||||
}));
|
||||
|
||||
/**
|
||||
* A component that renders all plugin fills in a hidden div.
|
||||
*
|
||||
* @param props
|
||||
* @param props.scope
|
||||
* @param props.onError
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ES5 syntax
|
||||
* var el = wp.element.createElement;
|
||||
* var PluginArea = wp.plugins.PluginArea;
|
||||
*
|
||||
* function Layout() {
|
||||
* return el(
|
||||
* 'div',
|
||||
* { scope: 'my-page' },
|
||||
* 'Content of the page',
|
||||
* PluginArea
|
||||
* );
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ESNext syntax
|
||||
* import { PluginArea } from '@wordpress/plugins';
|
||||
*
|
||||
* const Layout = () => (
|
||||
* <div>
|
||||
* Content of the page
|
||||
* <PluginArea scope="my-page" />
|
||||
* </div>
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @return {WPComponent} The component to be rendered.
|
||||
*/
|
||||
function PluginArea({
|
||||
scope,
|
||||
onError
|
||||
}) {
|
||||
const store = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
let lastValue = [];
|
||||
return {
|
||||
subscribe(listener) {
|
||||
(0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', listener);
|
||||
(0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', listener);
|
||||
return () => {
|
||||
(0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
|
||||
(0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
|
||||
};
|
||||
},
|
||||
getValue() {
|
||||
const nextValue = getPlugins(scope);
|
||||
if (!external_wp_isShallowEqual_default()(lastValue, nextValue)) {
|
||||
lastValue = nextValue;
|
||||
}
|
||||
return lastValue;
|
||||
}
|
||||
};
|
||||
}, [scope]);
|
||||
const plugins = (0,external_wp_element_namespaceObject.useSyncExternalStore)(store.subscribe, store.getValue);
|
||||
return (0,external_wp_element_namespaceObject.createElement)("div", {
|
||||
style: {
|
||||
display: 'none'
|
||||
}
|
||||
}, plugins.map(({
|
||||
icon,
|
||||
name,
|
||||
render: Plugin
|
||||
}) => (0,external_wp_element_namespaceObject.createElement)(PluginContextProvider, {
|
||||
key: name,
|
||||
value: getPluginContext(icon, name)
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(PluginErrorBoundary, {
|
||||
name: name,
|
||||
onError: onError
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(Plugin, null)))));
|
||||
}
|
||||
/* harmony default export */ var plugin_area = (PluginArea);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/index.js
|
||||
|
||||
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/index.js
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).plugins = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={n:function(n){var r=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(r,{a:r}),r},d:function(n,r){for(var t in r)e.o(r,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:r[t]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{PluginArea:function(){return x},getPlugin:function(){return w},getPlugins:function(){return h},registerPlugin:function(){return m},unregisterPlugin:function(){return v},usePluginContext:function(){return a},withPluginContext:function(){return c}});var r=window.wp.element;var t=window.wp.hooks,o=window.wp.isShallowEqual,i=e.n(o),u=window.wp.compose;const l=(0,r.createContext)({name:null,icon:null}),s=l.Provider;function a(){return(0,r.useContext)(l)}const c=e=>(0,u.createHigherOrderComponent)((n=>t=>(0,r.createElement)(l.Consumer,null,(o=>(0,r.createElement)(n,{...t,...e(o,t)})))),"withPluginContext");class p extends r.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){const{name:n,onError:r}=this.props;r&&r(n,e)}render(){return this.state.hasError?null:this.props.children}}var g=window.wp.primitives;var d=(0,r.createElement)(g.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(g.Path,{d:"M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"}));const f={};function m(e,n){if("object"!=typeof n)return console.error("No settings object provided!"),null;if("string"!=typeof e)return console.error("Plugin name must be string."),null;if(!/^[a-z][a-z0-9-]*$/.test(e))return console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".'),null;f[e]&&console.error(`Plugin "${e}" is already registered.`),n=(0,t.applyFilters)("plugins.registerPlugin",n,e);const{render:r,scope:o}=n;if("function"!=typeof r)return console.error('The "render" property must be specified and must be a valid function.'),null;if(o){if("string"!=typeof o)return console.error("Plugin scope must be string."),null;if(!/^[a-z][a-z0-9-]*$/.test(o))return console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".'),null}return f[e]={name:e,icon:d,...n},(0,t.doAction)("plugins.pluginRegistered",n,e),n}function v(e){if(!f[e])return void console.error('Plugin "'+e+'" is not registered.');const n=f[e];return delete f[e],(0,t.doAction)("plugins.pluginUnregistered",n,e),n}function w(e){return f[e]}function h(e){return Object.values(f).filter((n=>n.scope===e))}const y=function(e,n){var r,t,o=0;function i(){var i,u,l=r,s=arguments.length;e:for(;l;){if(l.args.length===arguments.length){for(u=0;u<s;u++)if(l.args[u]!==arguments[u]){l=l.next;continue e}return l!==r&&(l===t&&(t=l.prev),l.prev.next=l.next,l.next&&(l.next.prev=l.prev),l.next=r,l.prev=null,r.prev=l,r=l),l.val}l=l.next}for(i=new Array(s),u=0;u<s;u++)i[u]=arguments[u];return l={args:i,val:e.apply(null,i)},r?(r.prev=l,l.next=r):t=l,o===n.maxSize?(t=t.prev).next=null:o++,r=l,l.val}return n=n||{},i.clear=function(){r=null,t=null,o=0},i}(((e,n)=>({icon:e,name:n})));var x=function({scope:e,onError:n}){const o=(0,r.useMemo)((()=>{let n=[];return{subscribe(e){return(0,t.addAction)("plugins.pluginRegistered","core/plugins/plugin-area/plugins-registered",e),(0,t.addAction)("plugins.pluginUnregistered","core/plugins/plugin-area/plugins-unregistered",e),()=>{(0,t.removeAction)("plugins.pluginRegistered","core/plugins/plugin-area/plugins-registered"),(0,t.removeAction)("plugins.pluginUnregistered","core/plugins/plugin-area/plugins-unregistered")}},getValue(){const r=h(e);return i()(n,r)||(n=r),n}}}),[e]),u=(0,r.useSyncExternalStore)(o.subscribe,o.getValue);return(0,r.createElement)("div",{style:{display:"none"}},u.map((({icon:e,name:t,render:o})=>(0,r.createElement)(s,{key:t,value:y(e,t)},(0,r.createElement)(p,{name:t,onError:n},(0,r.createElement)(o,null))))))};(window.wp=window.wp||{}).plugins=n}();
|
||||
+862
@@ -0,0 +1,862 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
__unstableCreatePersistenceLayer: function() { return /* binding */ __unstableCreatePersistenceLayer; },
|
||||
create: function() { return /* reexport */ create; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","apiFetch"]
|
||||
var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
|
||||
var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/create/debounce-async.js
|
||||
/**
|
||||
* Performs a leading edge debounce of async functions.
|
||||
*
|
||||
* If three functions are throttled at the same time:
|
||||
* - The first happens immediately.
|
||||
* - The second is never called.
|
||||
* - The third happens `delayMS` milliseconds after the first has resolved.
|
||||
*
|
||||
* This is distinct from `{ debounce } from @wordpress/compose` in that it
|
||||
* waits for promise resolution.
|
||||
*
|
||||
* @param {Function} func A function that returns a promise.
|
||||
* @param {number} delayMS A delay in milliseconds.
|
||||
*
|
||||
* @return {Function} A function that debounce whatever function is passed
|
||||
* to it.
|
||||
*/
|
||||
function debounceAsync(func, delayMS) {
|
||||
let timeoutId;
|
||||
let activePromise;
|
||||
return async function debounced(...args) {
|
||||
// This is a leading edge debounce. If there's no promise or timeout
|
||||
// in progress, call the debounced function immediately.
|
||||
if (!activePromise && !timeoutId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Keep a reference to the promise.
|
||||
activePromise = func(...args).then((...thenArgs) => {
|
||||
resolve(...thenArgs);
|
||||
}).catch(error => {
|
||||
reject(error);
|
||||
}).finally(() => {
|
||||
// As soon this promise is complete, clear the way for the
|
||||
// next one to happen immediately.
|
||||
activePromise = null;
|
||||
});
|
||||
});
|
||||
}
|
||||
if (activePromise) {
|
||||
// Let any active promises finish before queuing the next request.
|
||||
await activePromise;
|
||||
}
|
||||
|
||||
// Clear any active timeouts, abandoning any requests that have
|
||||
// been queued but not been made.
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
|
||||
// Trigger any trailing edge calls to the function.
|
||||
return new Promise((resolve, reject) => {
|
||||
// Schedule the next request but with a delay.
|
||||
timeoutId = setTimeout(() => {
|
||||
activePromise = func(...args).then((...thenArgs) => {
|
||||
resolve(...thenArgs);
|
||||
}).catch(error => {
|
||||
reject(error);
|
||||
}).finally(() => {
|
||||
// As soon this promise is complete, clear the way for the
|
||||
// next one to happen immediately.
|
||||
activePromise = null;
|
||||
timeoutId = null;
|
||||
});
|
||||
}, delayMS);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/create/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
const EMPTY_OBJECT = {};
|
||||
const localStorage = window.localStorage;
|
||||
|
||||
/**
|
||||
* Creates a persistence layer that stores data in WordPress user meta via the
|
||||
* REST API.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {?Object} options.preloadedData Any persisted preferences data that should be preloaded.
|
||||
* When set, the persistence layer will avoid fetching data
|
||||
* from the REST API.
|
||||
* @param {?string} options.localStorageRestoreKey The key to use for restoring the localStorage backup, used
|
||||
* when the persistence layer calls `localStorage.getItem` or
|
||||
* `localStorage.setItem`.
|
||||
* @param {?number} options.requestDebounceMS Debounce requests to the API so that they only occur at
|
||||
* minimum every `requestDebounceMS` milliseconds, and don't
|
||||
* swamp the server. Defaults to 2500ms.
|
||||
*
|
||||
* @return {Object} A persistence layer for WordPress user meta.
|
||||
*/
|
||||
function create({
|
||||
preloadedData,
|
||||
localStorageRestoreKey = 'WP_PREFERENCES_RESTORE_DATA',
|
||||
requestDebounceMS = 2500
|
||||
} = {}) {
|
||||
let cache = preloadedData;
|
||||
const debouncedApiFetch = debounceAsync((external_wp_apiFetch_default()), requestDebounceMS);
|
||||
async function get() {
|
||||
if (cache) {
|
||||
return cache;
|
||||
}
|
||||
const user = await external_wp_apiFetch_default()({
|
||||
path: '/wp/v2/users/me?context=edit'
|
||||
});
|
||||
const serverData = user?.meta?.persisted_preferences;
|
||||
const localData = JSON.parse(localStorage.getItem(localStorageRestoreKey));
|
||||
|
||||
// Date parse returns NaN for invalid input. Coerce anything invalid
|
||||
// into a conveniently comparable zero.
|
||||
const serverTimestamp = Date.parse(serverData?._modified) || 0;
|
||||
const localTimestamp = Date.parse(localData?._modified) || 0;
|
||||
|
||||
// Prefer server data if it exists and is more recent.
|
||||
// Otherwise fallback to localStorage data.
|
||||
if (serverData && serverTimestamp >= localTimestamp) {
|
||||
cache = serverData;
|
||||
} else if (localData) {
|
||||
cache = localData;
|
||||
} else {
|
||||
cache = EMPTY_OBJECT;
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
function set(newData) {
|
||||
const dataWithTimestamp = {
|
||||
...newData,
|
||||
_modified: new Date().toISOString()
|
||||
};
|
||||
cache = dataWithTimestamp;
|
||||
|
||||
// Store data in local storage as a fallback. If for some reason the
|
||||
// api request does not complete or becomes unavailable, this data
|
||||
// can be used to restore preferences.
|
||||
localStorage.setItem(localStorageRestoreKey, JSON.stringify(dataWithTimestamp));
|
||||
|
||||
// The user meta endpoint seems susceptible to errors when consecutive
|
||||
// requests are made in quick succession. Ensure there's a gap between
|
||||
// any consecutive requests.
|
||||
//
|
||||
// Catch and do nothing with errors from the REST API.
|
||||
debouncedApiFetch({
|
||||
path: '/wp/v2/users/me',
|
||||
method: 'PUT',
|
||||
// `keepalive` will still send the request in the background,
|
||||
// even when a browser unload event might interrupt it.
|
||||
// This should hopefully make things more resilient.
|
||||
// This does have a size limit of 64kb, but the data is usually
|
||||
// much less.
|
||||
keepalive: true,
|
||||
data: {
|
||||
meta: {
|
||||
persisted_preferences: dataWithTimestamp
|
||||
}
|
||||
}
|
||||
}).catch(() => {});
|
||||
}
|
||||
return {
|
||||
get,
|
||||
set
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-feature-preferences.js
|
||||
/**
|
||||
* Move the 'features' object in local storage from the sourceStoreName to the
|
||||
* preferences store data structure.
|
||||
*
|
||||
* Previously, editors used a data structure like this for feature preferences:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/edit-post': {
|
||||
* preferences: {
|
||||
* features; {
|
||||
* topToolbar: true,
|
||||
* // ... other boolean 'feature' preferences
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* And for a while these feature preferences lived in the interface package:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/interface': {
|
||||
* preferences: {
|
||||
* features: {
|
||||
* 'core/edit-post': {
|
||||
* topToolbar: true
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* In the preferences store, 'features' aren't considered special, they're
|
||||
* merged to the root level of the scope along with other preferences:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/preferences': {
|
||||
* preferences: {
|
||||
* 'core/edit-post': {
|
||||
* topToolbar: true,
|
||||
* // ... any other preferences.
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* This function handles moving from either the source store or the interface
|
||||
* store to the preferences data structure.
|
||||
*
|
||||
* @param {Object} state The state before migration.
|
||||
* @param {string} sourceStoreName The name of the store that has persisted
|
||||
* preferences to migrate to the preferences
|
||||
* package.
|
||||
* @return {Object} The migrated state
|
||||
*/
|
||||
function moveFeaturePreferences(state, sourceStoreName) {
|
||||
const preferencesStoreName = 'core/preferences';
|
||||
const interfaceStoreName = 'core/interface';
|
||||
|
||||
// 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?.[interfaceStoreName]?.preferences?.features?.[sourceStoreName];
|
||||
const sourceFeatures = state?.[sourceStoreName]?.preferences?.features;
|
||||
const featuresToMigrate = interfaceFeatures ? interfaceFeatures : sourceFeatures;
|
||||
if (!featuresToMigrate) {
|
||||
return state;
|
||||
}
|
||||
const existingPreferences = state?.[preferencesStoreName]?.preferences;
|
||||
|
||||
// Avoid migrating features again if they've previously been migrated.
|
||||
if (existingPreferences?.[sourceStoreName]) {
|
||||
return state;
|
||||
}
|
||||
let updatedInterfaceState;
|
||||
if (interfaceFeatures) {
|
||||
const otherInterfaceState = state?.[interfaceStoreName];
|
||||
const otherInterfaceScopes = state?.[interfaceStoreName]?.preferences?.features;
|
||||
updatedInterfaceState = {
|
||||
[interfaceStoreName]: {
|
||||
...otherInterfaceState,
|
||||
preferences: {
|
||||
features: {
|
||||
...otherInterfaceScopes,
|
||||
[sourceStoreName]: undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
let updatedSourceState;
|
||||
if (sourceFeatures) {
|
||||
const otherSourceState = state?.[sourceStoreName];
|
||||
const sourcePreferences = state?.[sourceStoreName]?.preferences;
|
||||
updatedSourceState = {
|
||||
[sourceStoreName]: {
|
||||
...otherSourceState,
|
||||
preferences: {
|
||||
...sourcePreferences,
|
||||
features: undefined
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Set the feature values in the interface store, the features
|
||||
// object is keyed by 'scope', which matches the store name for
|
||||
// the source.
|
||||
return {
|
||||
...state,
|
||||
[preferencesStoreName]: {
|
||||
preferences: {
|
||||
...existingPreferences,
|
||||
[sourceStoreName]: featuresToMigrate
|
||||
}
|
||||
},
|
||||
...updatedInterfaceState,
|
||||
...updatedSourceState
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js
|
||||
/**
|
||||
* The interface package previously had a public API that could be used by
|
||||
* plugins to set persisted boolean 'feature' preferences.
|
||||
*
|
||||
* While usage was likely non-existent or very small, this function ensures
|
||||
* those are migrated to the preferences data structure. The interface
|
||||
* package's APIs have now been deprecated and use the preferences store.
|
||||
*
|
||||
* This will convert data that looks like this:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/interface': {
|
||||
* preferences: {
|
||||
* features: {
|
||||
* 'my-plugin': {
|
||||
* myPluginFeature: true
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* To this:
|
||||
* ```js
|
||||
* * {
|
||||
* 'core/preferences': {
|
||||
* preferences: {
|
||||
* 'my-plugin': {
|
||||
* myPluginFeature: true
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param {Object} state The local storage state
|
||||
*
|
||||
* @return {Object} The state with third party preferences moved to the
|
||||
* preferences data structure.
|
||||
*/
|
||||
function moveThirdPartyFeaturePreferencesToPreferences(state) {
|
||||
const interfaceStoreName = 'core/interface';
|
||||
const preferencesStoreName = 'core/preferences';
|
||||
const interfaceScopes = state?.[interfaceStoreName]?.preferences?.features;
|
||||
const interfaceScopeKeys = interfaceScopes ? Object.keys(interfaceScopes) : [];
|
||||
if (!interfaceScopeKeys?.length) {
|
||||
return state;
|
||||
}
|
||||
return interfaceScopeKeys.reduce(function (convertedState, scope) {
|
||||
if (scope.startsWith('core')) {
|
||||
return convertedState;
|
||||
}
|
||||
const featuresToMigrate = interfaceScopes?.[scope];
|
||||
if (!featuresToMigrate) {
|
||||
return convertedState;
|
||||
}
|
||||
const existingMigratedData = convertedState?.[preferencesStoreName]?.preferences?.[scope];
|
||||
if (existingMigratedData) {
|
||||
return convertedState;
|
||||
}
|
||||
const otherPreferencesScopes = convertedState?.[preferencesStoreName]?.preferences;
|
||||
const otherInterfaceState = convertedState?.[interfaceStoreName];
|
||||
const otherInterfaceScopes = convertedState?.[interfaceStoreName]?.preferences?.features;
|
||||
return {
|
||||
...convertedState,
|
||||
[preferencesStoreName]: {
|
||||
preferences: {
|
||||
...otherPreferencesScopes,
|
||||
[scope]: featuresToMigrate
|
||||
}
|
||||
},
|
||||
[interfaceStoreName]: {
|
||||
...otherInterfaceState,
|
||||
preferences: {
|
||||
features: {
|
||||
...otherInterfaceScopes,
|
||||
[scope]: undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}, state);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-individual-preference.js
|
||||
const identity = arg => arg;
|
||||
|
||||
/**
|
||||
* Migrates an individual item inside the `preferences` object for a package's store.
|
||||
*
|
||||
* Previously, some packages had individual 'preferences' of any data type, and many used
|
||||
* complex nested data structures. For example:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/edit-post': {
|
||||
* preferences: {
|
||||
* panels: {
|
||||
* publish: {
|
||||
* opened: true,
|
||||
* enabled: true,
|
||||
* }
|
||||
* },
|
||||
* // ...other preferences.
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
*
|
||||
* This function supports moving an individual preference like 'panels' above into the
|
||||
* preferences package data structure.
|
||||
*
|
||||
* It supports moving a preference to a particular scope in the preferences store and
|
||||
* optionally converting the data using a `convert` function.
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @param {Object} state The original state.
|
||||
* @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.to 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 moveIndividualPreferenceToPreferences(state, {
|
||||
from: sourceStoreName,
|
||||
to: scope
|
||||
}, key, convert = identity) {
|
||||
const preferencesStoreName = 'core/preferences';
|
||||
const sourcePreference = state?.[sourceStoreName]?.preferences?.[key];
|
||||
|
||||
// There's nothing to migrate, exit early.
|
||||
if (sourcePreference === undefined) {
|
||||
return state;
|
||||
}
|
||||
const targetPreference = state?.[preferencesStoreName]?.preferences?.[scope]?.[key];
|
||||
|
||||
// There's existing data at the target, so don't overwrite it, exit early.
|
||||
if (targetPreference) {
|
||||
return state;
|
||||
}
|
||||
const otherScopes = state?.[preferencesStoreName]?.preferences;
|
||||
const otherPreferences = state?.[preferencesStoreName]?.preferences?.[scope];
|
||||
const otherSourceState = state?.[sourceStoreName];
|
||||
const allSourcePreferences = state?.[sourceStoreName]?.preferences;
|
||||
|
||||
// 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
|
||||
});
|
||||
return {
|
||||
...state,
|
||||
[preferencesStoreName]: {
|
||||
preferences: {
|
||||
...otherScopes,
|
||||
[scope]: {
|
||||
...otherPreferences,
|
||||
...convertedPreferences
|
||||
}
|
||||
}
|
||||
},
|
||||
[sourceStoreName]: {
|
||||
...otherSourceState,
|
||||
preferences: {
|
||||
...allSourcePreferences,
|
||||
[key]: undefined
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.js
|
||||
/**
|
||||
* 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 converted 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} state The local storage state.
|
||||
*/
|
||||
function moveInterfaceEnableItems(state) {
|
||||
var _state$preferencesSto, _sourceEnableItems$si, _sourceEnableItems$mu;
|
||||
const interfaceStoreName = 'core/interface';
|
||||
const preferencesStoreName = 'core/preferences';
|
||||
const sourceEnableItems = state?.[interfaceStoreName]?.enableItems;
|
||||
|
||||
// There's nothing to migrate, exit early.
|
||||
if (!sourceEnableItems) {
|
||||
return state;
|
||||
}
|
||||
const allPreferences = (_state$preferencesSto = state?.[preferencesStoreName]?.preferences) !== null && _state$preferencesSto !== void 0 ? _state$preferencesSto : {};
|
||||
|
||||
// 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?.singleEnableItems?.complementaryArea) !== null && _sourceEnableItems$si !== void 0 ? _sourceEnableItems$si : {};
|
||||
const preferencesWithConvertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => {
|
||||
const data = sourceComplementaryAreas[scope];
|
||||
|
||||
// Don't overwrite any existing data in the preferences store.
|
||||
if (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?.multipleEnableItems?.pinnedItems) !== null && _sourceEnableItems$mu !== void 0 ? _sourceEnableItems$mu : {};
|
||||
const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => {
|
||||
const data = sourcePinnedItems[scope];
|
||||
// Don't overwrite any existing data in the preferences store.
|
||||
if (accumulator?.[scope]?.pinnedItems) {
|
||||
return accumulator;
|
||||
}
|
||||
return {
|
||||
...accumulator,
|
||||
[scope]: {
|
||||
...accumulator[scope],
|
||||
pinnedItems: data
|
||||
}
|
||||
};
|
||||
}, preferencesWithConvertedComplementaryAreas);
|
||||
const otherInterfaceItems = state[interfaceStoreName];
|
||||
return {
|
||||
...state,
|
||||
[preferencesStoreName]: {
|
||||
preferences: allConvertedData
|
||||
},
|
||||
[interfaceStoreName]: {
|
||||
...otherInterfaceItems,
|
||||
enableItems: undefined
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.js
|
||||
/**
|
||||
* Convert the post editor's panels state from:
|
||||
* ```
|
||||
* {
|
||||
* panels: {
|
||||
* tags: {
|
||||
* enabled: true,
|
||||
* opened: true,
|
||||
* },
|
||||
* permalinks: {
|
||||
* enabled: false,
|
||||
* opened: false,
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* to a new, more concise data structure:
|
||||
* {
|
||||
* 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?.panels) !== null && _preferences$panels !== void 0 ? _preferences$panels : {};
|
||||
return Object.keys(panels).reduce((convertedData, panelName) => {
|
||||
const panel = panels[panelName];
|
||||
if (panel?.enabled === false) {
|
||||
convertedData.inactivePanels.push(panelName);
|
||||
}
|
||||
if (panel?.opened === true) {
|
||||
convertedData.openPanels.push(panelName);
|
||||
}
|
||||
return convertedData;
|
||||
}, {
|
||||
inactivePanels: [],
|
||||
openPanels: []
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the legacy local storage data for a given user.
|
||||
*
|
||||
* @param {string | number} userId The user id.
|
||||
*
|
||||
* @return {Object | null} The local storage data.
|
||||
*/
|
||||
function getLegacyData(userId) {
|
||||
const key = `WP_DATA_USER_${userId}`;
|
||||
const unparsedData = window.localStorage.getItem(key);
|
||||
return JSON.parse(unparsedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts data from the old `@wordpress/data` package format.
|
||||
*
|
||||
* @param {Object | null | undefined} data The legacy data in its original format.
|
||||
*
|
||||
* @return {Object | undefined} The converted data or `undefined` if there was
|
||||
* nothing to convert.
|
||||
*/
|
||||
function convertLegacyData(data) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Move boolean feature preferences from each editor into the
|
||||
// preferences store data structure.
|
||||
data = moveFeaturePreferences(data, 'core/edit-widgets');
|
||||
data = moveFeaturePreferences(data, 'core/customize-widgets');
|
||||
data = moveFeaturePreferences(data, 'core/edit-post');
|
||||
data = moveFeaturePreferences(data, 'core/edit-site');
|
||||
|
||||
// Move third party boolean feature preferences from the interface package
|
||||
// to the preferences store data structure.
|
||||
data = moveThirdPartyFeaturePreferencesToPreferences(data);
|
||||
|
||||
// Move and convert the interface store's `enableItems` data into the
|
||||
// preferences data structure.
|
||||
data = moveInterfaceEnableItems(data);
|
||||
|
||||
// Move individual ad-hoc preferences from various packages into the
|
||||
// preferences store data structure.
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-post',
|
||||
to: 'core/edit-post'
|
||||
}, 'hiddenBlockTypes');
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-post',
|
||||
to: 'core/edit-post'
|
||||
}, 'editorMode');
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-post',
|
||||
to: 'core/edit-post'
|
||||
}, 'preferredStyleVariations');
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-post',
|
||||
to: 'core/edit-post'
|
||||
}, 'panels', convertEditPostPanels);
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/editor',
|
||||
to: 'core/edit-post'
|
||||
}, 'isPublishSidebarEnabled');
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-site',
|
||||
to: 'core/edit-site'
|
||||
}, 'editorMode');
|
||||
|
||||
// The new system is only concerned with persisting
|
||||
// 'core/preferences' preferences reducer, so only return that.
|
||||
return data?.['core/preferences']?.preferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the legacy local storage data for the given user and returns the
|
||||
* data converted to the new format.
|
||||
*
|
||||
* @param {string | number} userId The user id.
|
||||
*
|
||||
* @return {Object | undefined} The converted data or undefined if no local
|
||||
* storage data could be found.
|
||||
*/
|
||||
function convertLegacyLocalStorageData(userId) {
|
||||
const data = getLegacyData(userId);
|
||||
return convertLegacyData(data);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/convert-complementary-areas.js
|
||||
function convertComplementaryAreas(state) {
|
||||
return Object.keys(state).reduce((stateAccumulator, scope) => {
|
||||
const scopeData = state[scope];
|
||||
|
||||
// If a complementary area is truthy, convert it to the `isComplementaryAreaVisible` boolean.
|
||||
if (scopeData?.complementaryArea) {
|
||||
const updatedScopeData = {
|
||||
...scopeData
|
||||
};
|
||||
delete updatedScopeData.complementaryArea;
|
||||
updatedScopeData.isComplementaryAreaVisible = true;
|
||||
stateAccumulator[scope] = updatedScopeData;
|
||||
return stateAccumulator;
|
||||
}
|
||||
return stateAccumulator;
|
||||
}, state);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
function convertPreferencesPackageData(data) {
|
||||
return convertComplementaryAreas(data);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates the persistence layer with preloaded data.
|
||||
*
|
||||
* It prioritizes any data from the server, but falls back first to localStorage
|
||||
* restore data, and then to any legacy data.
|
||||
*
|
||||
* This function is used internally by WordPress in an inline script, so
|
||||
* prefixed with `__unstable`.
|
||||
*
|
||||
* @param {Object} serverData Preferences data preloaded from the server.
|
||||
* @param {string} userId The user id.
|
||||
*
|
||||
* @return {Object} The persistence layer initialized with the preloaded data.
|
||||
*/
|
||||
function __unstableCreatePersistenceLayer(serverData, userId) {
|
||||
const localStorageRestoreKey = `WP_PREFERENCES_USER_${userId}`;
|
||||
const localData = JSON.parse(window.localStorage.getItem(localStorageRestoreKey));
|
||||
|
||||
// Date parse returns NaN for invalid input. Coerce anything invalid
|
||||
// into a conveniently comparable zero.
|
||||
const serverModified = Date.parse(serverData && serverData._modified) || 0;
|
||||
const localModified = Date.parse(localData && localData._modified) || 0;
|
||||
let preloadedData;
|
||||
if (serverData && serverModified >= localModified) {
|
||||
preloadedData = convertPreferencesPackageData(serverData);
|
||||
} else if (localData) {
|
||||
preloadedData = convertPreferencesPackageData(localData);
|
||||
} else {
|
||||
// Check if there is data in the legacy format from the old persistence system.
|
||||
preloadedData = convertLegacyLocalStorageData(userId);
|
||||
}
|
||||
return create({
|
||||
preloadedData,
|
||||
localStorageRestoreKey
|
||||
});
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).preferencesPersistence = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={n:function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,{a:t}),t},d:function(r,t){for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{__unstableCreatePersistenceLayer:function(){return m},create:function(){return s}});var t=window.wp.apiFetch,n=e.n(t);const o={},c=window.localStorage;function s({preloadedData:e,localStorageRestoreKey:r="WP_PREFERENCES_RESTORE_DATA",requestDebounceMS:t=2500}={}){let s=e;const i=function(e,r){let t,n;return async function(...o){return n||t?(n&&await n,t&&(clearTimeout(t),t=null),new Promise(((c,s)=>{t=setTimeout((()=>{n=e(...o).then(((...e)=>{c(...e)})).catch((e=>{s(e)})).finally((()=>{n=null,t=null}))}),r)}))):new Promise(((r,t)=>{n=e(...o).then(((...e)=>{r(...e)})).catch((e=>{t(e)})).finally((()=>{n=null}))}))}}(n(),t);return{get:async function(){if(s)return s;const e=await n()({path:"/wp/v2/users/me?context=edit"}),t=e?.meta?.persisted_preferences,i=JSON.parse(c.getItem(r)),a=Date.parse(t?._modified)||0,f=Date.parse(i?._modified)||0;return s=t&&a>=f?t:i||o,s},set:function(e){const t={...e,_modified:(new Date).toISOString()};s=t,c.setItem(r,JSON.stringify(t)),i({path:"/wp/v2/users/me",method:"PUT",keepalive:!0,data:{meta:{persisted_preferences:t}}}).catch((()=>{}))}}}function i(e,r){const t="core/preferences",n="core/interface",o=e?.[n]?.preferences?.features?.[r],c=e?.[r]?.preferences?.features,s=o||c;if(!s)return e;const i=e?.[t]?.preferences;if(i?.[r])return e;let a,f;if(o){const t=e?.[n],o=e?.[n]?.preferences?.features;a={[n]:{...t,preferences:{features:{...o,[r]:void 0}}}}}if(c){const t=e?.[r],n=e?.[r]?.preferences;f={[r]:{...t,preferences:{...n,features:void 0}}}}return{...e,[t]:{preferences:{...i,[r]:s}},...a,...f}}const a=e=>e;function f(e,{from:r,to:t},n,o=a){const c="core/preferences",s=e?.[r]?.preferences?.[n];if(void 0===s)return e;const i=e?.[c]?.preferences?.[t]?.[n];if(i)return e;const f=e?.[c]?.preferences,u=e?.[c]?.preferences?.[t],p=e?.[r],d=e?.[r]?.preferences,l=o({[n]:s});return{...e,[c]:{preferences:{...f,[t]:{...u,...l}}},[r]:{...p,preferences:{...d,[n]:void 0}}}}function u(e){var r;const t=null!==(r=e?.panels)&&void 0!==r?r:{};return Object.keys(t).reduce(((e,r)=>{const n=t[r];return!1===n?.enabled&&e.inactivePanels.push(r),!0===n?.opened&&e.openPanels.push(r),e}),{inactivePanels:[],openPanels:[]})}function p(e){if(e)return e=i(e,"core/edit-widgets"),e=i(e,"core/customize-widgets"),e=i(e,"core/edit-post"),e=f(e=function(e){var r,t,n;const o="core/interface",c="core/preferences",s=e?.[o]?.enableItems;if(!s)return e;const i=null!==(r=e?.[c]?.preferences)&&void 0!==r?r:{},a=null!==(t=s?.singleEnableItems?.complementaryArea)&&void 0!==t?t:{},f=Object.keys(a).reduce(((e,r)=>{const t=a[r];return e?.[r]?.complementaryArea?e:{...e,[r]:{...e[r],complementaryArea:t}}}),i),u=null!==(n=s?.multipleEnableItems?.pinnedItems)&&void 0!==n?n:{},p=Object.keys(u).reduce(((e,r)=>{const t=u[r];return e?.[r]?.pinnedItems?e:{...e,[r]:{...e[r],pinnedItems:t}}}),f),d=e[o];return{...e,[c]:{preferences:p},[o]:{...d,enableItems:void 0}}}(e=function(e){const r="core/interface",t="core/preferences",n=e?.[r]?.preferences?.features,o=n?Object.keys(n):[];return o?.length?o.reduce((function(e,o){if(o.startsWith("core"))return e;const c=n?.[o];if(!c)return e;const s=e?.[t]?.preferences?.[o];if(s)return e;const i=e?.[t]?.preferences,a=e?.[r],f=e?.[r]?.preferences?.features;return{...e,[t]:{preferences:{...i,[o]:c}},[r]:{...a,preferences:{features:{...f,[o]:void 0}}}}}),e):e}(e=i(e,"core/edit-site"))),{from:"core/edit-post",to:"core/edit-post"},"hiddenBlockTypes"),e=f(e,{from:"core/edit-post",to:"core/edit-post"},"editorMode"),e=f(e,{from:"core/edit-post",to:"core/edit-post"},"preferredStyleVariations"),e=f(e,{from:"core/edit-post",to:"core/edit-post"},"panels",u),e=f(e,{from:"core/editor",to:"core/edit-post"},"isPublishSidebarEnabled"),e=f(e,{from:"core/edit-site",to:"core/edit-site"},"editorMode"),e?.["core/preferences"]?.preferences}function d(e){const r=function(e){const r=`WP_DATA_USER_${e}`,t=window.localStorage.getItem(r);return JSON.parse(t)}(e);return p(r)}function l(e){return r=e,Object.keys(r).reduce(((e,t)=>{const n=r[t];if(n?.complementaryArea){const r={...n};return delete r.complementaryArea,r.isComplementaryAreaVisible=!0,e[t]=r,e}return e}),r);var r}function m(e,r){const t=`WP_PREFERENCES_USER_${r}`,n=JSON.parse(window.localStorage.getItem(t)),o=Date.parse(e&&e._modified)||0,c=Date.parse(n&&n._modified)||0;let i;return i=e&&o>=c?l(e):n?l(n):d(r),s({preloadedData:i,localStorageRestoreKey:t})}(window.wp=window.wp||{}).preferencesPersistence=r}();
|
||||
+388
@@ -0,0 +1,388 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
PreferenceToggleMenuItem: function() { return /* reexport */ PreferenceToggleMenuItem; },
|
||||
store: function() { return /* reexport */ store; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/preferences/build-module/store/actions.js
|
||||
var actions_namespaceObject = {};
|
||||
__webpack_require__.r(actions_namespaceObject);
|
||||
__webpack_require__.d(actions_namespaceObject, {
|
||||
set: function() { return set; },
|
||||
setDefaults: function() { return setDefaults; },
|
||||
setPersistenceLayer: function() { return setPersistenceLayer; },
|
||||
toggle: function() { return toggle; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/preferences/build-module/store/selectors.js
|
||||
var selectors_namespaceObject = {};
|
||||
__webpack_require__.r(selectors_namespaceObject);
|
||||
__webpack_require__.d(selectors_namespaceObject, {
|
||||
get: function() { return get; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
var external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
var external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: external ["wp","components"]
|
||||
var external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: external ["wp","primitives"]
|
||||
var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24"
|
||||
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
|
||||
}));
|
||||
/* harmony default export */ var library_check = (check);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","a11y"]
|
||||
var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/reducer.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Reducer returning the defaults for user preferences.
|
||||
*
|
||||
* This is kept intentionally separate from the preferences
|
||||
* themselves so that defaults are not persisted.
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
function defaults(state = {}, action) {
|
||||
if (action.type === 'SET_PREFERENCE_DEFAULTS') {
|
||||
const {
|
||||
scope,
|
||||
defaults: values
|
||||
} = action;
|
||||
return {
|
||||
...state,
|
||||
[scope]: {
|
||||
...state[scope],
|
||||
...values
|
||||
}
|
||||
};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Higher order reducer that does the following:
|
||||
* - Merges any data from the persistence layer into the state when the
|
||||
* `SET_PERSISTENCE_LAYER` action is received.
|
||||
* - Passes any preferences changes to the persistence layer.
|
||||
*
|
||||
* @param {Function} reducer The preferences reducer.
|
||||
*
|
||||
* @return {Function} The enhanced reducer.
|
||||
*/
|
||||
function withPersistenceLayer(reducer) {
|
||||
let persistenceLayer;
|
||||
return (state, action) => {
|
||||
// Setup the persistence layer, and return the persisted data
|
||||
// as the state.
|
||||
if (action.type === 'SET_PERSISTENCE_LAYER') {
|
||||
const {
|
||||
persistenceLayer: persistence,
|
||||
persistedData
|
||||
} = action;
|
||||
persistenceLayer = persistence;
|
||||
return persistedData;
|
||||
}
|
||||
const nextState = reducer(state, action);
|
||||
if (action.type === 'SET_PREFERENCE_VALUE') {
|
||||
persistenceLayer?.set(nextState);
|
||||
}
|
||||
return nextState;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reducer returning the user preferences.
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
const preferences = withPersistenceLayer((state = {}, action) => {
|
||||
if (action.type === 'SET_PREFERENCE_VALUE') {
|
||||
const {
|
||||
scope,
|
||||
name,
|
||||
value
|
||||
} = action;
|
||||
return {
|
||||
...state,
|
||||
[scope]: {
|
||||
...state[scope],
|
||||
[name]: value
|
||||
}
|
||||
};
|
||||
}
|
||||
return state;
|
||||
});
|
||||
/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
|
||||
defaults,
|
||||
preferences
|
||||
}));
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/actions.js
|
||||
/**
|
||||
* Returns an action object used in signalling that a preference should be
|
||||
* toggled.
|
||||
*
|
||||
* @param {string} scope The preference scope (e.g. core/edit-post).
|
||||
* @param {string} name The preference name.
|
||||
*/
|
||||
function toggle(scope, name) {
|
||||
return function ({
|
||||
select,
|
||||
dispatch
|
||||
}) {
|
||||
const currentValue = select.get(scope, name);
|
||||
dispatch.set(scope, name, !currentValue);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a preference should be set
|
||||
* to a value
|
||||
*
|
||||
* @param {string} scope The preference scope (e.g. core/edit-post).
|
||||
* @param {string} name The preference name.
|
||||
* @param {*} value The value to set.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function set(scope, name, value) {
|
||||
return {
|
||||
type: 'SET_PREFERENCE_VALUE',
|
||||
scope,
|
||||
name,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that preference defaults should
|
||||
* be set.
|
||||
*
|
||||
* @param {string} scope The preference scope (e.g. core/edit-post).
|
||||
* @param {Object<string, *>} defaults A key/value map of preference names to values.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function setDefaults(scope, defaults) {
|
||||
return {
|
||||
type: 'SET_PREFERENCE_DEFAULTS',
|
||||
scope,
|
||||
defaults
|
||||
};
|
||||
}
|
||||
|
||||
/** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */
|
||||
/** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */
|
||||
/**
|
||||
* @typedef WPPreferencesPersistenceLayer
|
||||
*
|
||||
* @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer.
|
||||
* @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets the persistence layer.
|
||||
*
|
||||
* When a persistence layer is set, the preferences store will:
|
||||
* - call `get` immediately and update the store state to the value returned.
|
||||
* - call `set` with all preferences whenever a preference changes value.
|
||||
*
|
||||
* `setPersistenceLayer` should ideally be dispatched at the start of an
|
||||
* application's lifecycle, before any other actions have been dispatched to
|
||||
* the preferences store.
|
||||
*
|
||||
* @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
async function setPersistenceLayer(persistenceLayer) {
|
||||
const persistedData = await persistenceLayer.get();
|
||||
return {
|
||||
type: 'SET_PERSISTENCE_LAYER',
|
||||
persistenceLayer,
|
||||
persistedData
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/selectors.js
|
||||
/**
|
||||
* Returns a boolean indicating whether a prefer is active for a particular
|
||||
* scope.
|
||||
*
|
||||
* @param {Object} state The store state.
|
||||
* @param {string} scope The scope of the feature (e.g. core/edit-post).
|
||||
* @param {string} name The name of the feature.
|
||||
*
|
||||
* @return {*} Is the feature enabled?
|
||||
*/
|
||||
function get(state, scope, name) {
|
||||
const value = state.preferences[scope]?.[name];
|
||||
return value !== undefined ? value : state.defaults[scope]?.[name];
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/constants.js
|
||||
/**
|
||||
* The identifier for the data store.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const STORE_NAME = 'core/preferences';
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Store definition for the interface namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
||||
reducer: reducer,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/preference-toggle-menu-item/index.js
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
function PreferenceToggleMenuItem({
|
||||
scope,
|
||||
name,
|
||||
label,
|
||||
info,
|
||||
messageActivated,
|
||||
messageDeactivated,
|
||||
shortcut,
|
||||
onToggle = () => null,
|
||||
disabled = false
|
||||
}) {
|
||||
const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).get(scope, name), [scope, name]);
|
||||
const {
|
||||
toggle
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
const speakMessage = () => {
|
||||
if (isActive) {
|
||||
const message = messageDeactivated || (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: preference name, e.g. 'Fullscreen mode' */
|
||||
(0,external_wp_i18n_namespaceObject.__)('Preference deactivated - %s'), label);
|
||||
(0,external_wp_a11y_namespaceObject.speak)(message);
|
||||
} else {
|
||||
const message = messageActivated || (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: preference name, e.g. 'Fullscreen mode' */
|
||||
(0,external_wp_i18n_namespaceObject.__)('Preference activated - %s'), label);
|
||||
(0,external_wp_a11y_namespaceObject.speak)(message);
|
||||
}
|
||||
};
|
||||
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
|
||||
icon: isActive && library_check,
|
||||
isSelected: isActive,
|
||||
onClick: () => {
|
||||
onToggle();
|
||||
toggle(scope, name);
|
||||
speakMessage();
|
||||
},
|
||||
role: "menuitemcheckbox",
|
||||
info: info,
|
||||
shortcut: shortcut,
|
||||
disabled: disabled
|
||||
}, label);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/index.js
|
||||
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/index.js
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).preferences = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{PreferenceToggleMenuItem:function(){return y},store:function(){return m}});var n={};e.r(n),e.d(n,{set:function(){return l},setDefaults:function(){return w},setPersistenceLayer:function(){return g},toggle:function(){return d}});var r={};e.r(r),e.d(r,{get:function(){return S}});var o=window.wp.element,c=window.wp.data,s=window.wp.components,i=window.wp.i18n,u=window.wp.primitives;var a=(0,o.createElement)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(u.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),f=window.wp.a11y;const p=function(e){let t;return(n,r)=>{if("SET_PERSISTENCE_LAYER"===r.type){const{persistenceLayer:e,persistedData:n}=r;return t=e,n}const o=e(n,r);return"SET_PREFERENCE_VALUE"===r.type&&t?.set(o),o}}(((e={},t)=>{if("SET_PREFERENCE_VALUE"===t.type){const{scope:n,name:r,value:o}=t;return{...e,[n]:{...e[n],[r]:o}}}return e}));var E=(0,c.combineReducers)({defaults:function(e={},t){if("SET_PREFERENCE_DEFAULTS"===t.type){const{scope:n,defaults:r}=t;return{...e,[n]:{...e[n],...r}}}return e},preferences:p});function d(e,t){return function({select:n,dispatch:r}){const o=n.get(e,t);r.set(e,t,!o)}}function l(e,t,n){return{type:"SET_PREFERENCE_VALUE",scope:e,name:t,value:n}}function w(e,t){return{type:"SET_PREFERENCE_DEFAULTS",scope:e,defaults:t}}async function g(e){const t=await e.get();return{type:"SET_PERSISTENCE_LAYER",persistenceLayer:e,persistedData:t}}function S(e,t,n){const r=e.preferences[t]?.[n];return void 0!==r?r:e.defaults[t]?.[n]}const m=(0,c.createReduxStore)("core/preferences",{reducer:E,actions:n,selectors:r});function y({scope:e,name:t,label:n,info:r,messageActivated:u,messageDeactivated:p,shortcut:E,onToggle:d=(()=>null),disabled:l=!1}){const w=(0,c.useSelect)((n=>!!n(m).get(e,t)),[e,t]),{toggle:g}=(0,c.useDispatch)(m);return(0,o.createElement)(s.MenuItem,{icon:w&&a,isSelected:w,onClick:()=>{d(),g(e,t),(()=>{if(w){const e=p||(0,i.sprintf)((0,i.__)("Preference deactivated - %s"),n);(0,f.speak)(e)}else{const e=u||(0,i.sprintf)((0,i.__)("Preference activated - %s"),n);(0,f.speak)(e)}})()},role:"menuitemcheckbox",info:r,shortcut:E,disabled:l},n)}(0,c.register)(m),(window.wp=window.wp||{}).preferences=t}();
|
||||
Vendored
+299
@@ -0,0 +1,299 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ 4403:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
||||
Copyright (c) 2018 Jed Watson.
|
||||
Licensed under the MIT License (MIT), see
|
||||
http://jedwatson.github.io/classnames
|
||||
*/
|
||||
/* global define */
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var hasOwn = {}.hasOwnProperty;
|
||||
var nativeCodeString = '[native code]';
|
||||
|
||||
function classNames() {
|
||||
var classes = [];
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var arg = arguments[i];
|
||||
if (!arg) continue;
|
||||
|
||||
var argType = typeof arg;
|
||||
|
||||
if (argType === 'string' || argType === 'number') {
|
||||
classes.push(arg);
|
||||
} else if (Array.isArray(arg)) {
|
||||
if (arg.length) {
|
||||
var inner = classNames.apply(null, arg);
|
||||
if (inner) {
|
||||
classes.push(inner);
|
||||
}
|
||||
}
|
||||
} else if (argType === 'object') {
|
||||
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
||||
classes.push(arg.toString());
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var key in arg) {
|
||||
if (hasOwn.call(arg, key) && arg[key]) {
|
||||
classes.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return classes.join(' ');
|
||||
}
|
||||
|
||||
if ( true && module.exports) {
|
||||
classNames.default = classNames;
|
||||
module.exports = classNames;
|
||||
} else if (true) {
|
||||
// register as 'classnames', consistent with npm package name
|
||||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
|
||||
return classNames;
|
||||
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
|
||||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
||||
} else {}
|
||||
}());
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // The module cache
|
||||
/******/ var __webpack_module_cache__ = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/ // Check if module is in cache
|
||||
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||
/******/ if (cachedModule !== undefined) {
|
||||
/******/ return cachedModule.exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||
/******/ // no module.id needed
|
||||
/******/ // no module.loaded needed
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ !function() {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function() { return module['default']; } :
|
||||
/******/ function() { return module; };
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ }();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ !function() {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, definition) {
|
||||
/******/ for(var key in definition) {
|
||||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||
/******/ }
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/ }();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||
/******/ !function() {
|
||||
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
||||
/******/ }();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ !function() {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/ }();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
||||
!function() {
|
||||
"use strict";
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
BlockQuotation: function() { return /* reexport */ BlockQuotation; },
|
||||
Circle: function() { return /* reexport */ Circle; },
|
||||
Defs: function() { return /* reexport */ Defs; },
|
||||
G: function() { return /* reexport */ G; },
|
||||
HorizontalRule: function() { return /* reexport */ HorizontalRule; },
|
||||
Line: function() { return /* reexport */ Line; },
|
||||
LinearGradient: function() { return /* reexport */ LinearGradient; },
|
||||
Path: function() { return /* reexport */ Path; },
|
||||
Polygon: function() { return /* reexport */ Polygon; },
|
||||
RadialGradient: function() { return /* reexport */ RadialGradient; },
|
||||
Rect: function() { return /* reexport */ Rect; },
|
||||
SVG: function() { return /* reexport */ SVG; },
|
||||
Stop: function() { return /* reexport */ Stop; },
|
||||
View: function() { return /* reexport */ View; }
|
||||
});
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/classnames/index.js
|
||||
var classnames = __webpack_require__(4403);
|
||||
var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
var external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/primitives/build-module/svg/index.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {{isPressed?: boolean} & import('react').ComponentPropsWithoutRef<'svg'>} SVGProps */
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'circle'>} props
|
||||
*
|
||||
* @return {JSX.Element} Circle component
|
||||
*/
|
||||
const Circle = props => (0,external_wp_element_namespaceObject.createElement)('circle', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'g'>} props
|
||||
*
|
||||
* @return {JSX.Element} G component
|
||||
*/
|
||||
const G = props => (0,external_wp_element_namespaceObject.createElement)('g', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'line'>} props
|
||||
*
|
||||
* @return {JSX.Element} Path component
|
||||
*/
|
||||
const Line = props => (0,external_wp_element_namespaceObject.createElement)('line', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'path'>} props
|
||||
*
|
||||
* @return {JSX.Element} Path component
|
||||
*/
|
||||
const Path = props => (0,external_wp_element_namespaceObject.createElement)('path', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'polygon'>} props
|
||||
*
|
||||
* @return {JSX.Element} Polygon component
|
||||
*/
|
||||
const Polygon = props => (0,external_wp_element_namespaceObject.createElement)('polygon', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'rect'>} props
|
||||
*
|
||||
* @return {JSX.Element} Rect component
|
||||
*/
|
||||
const Rect = props => (0,external_wp_element_namespaceObject.createElement)('rect', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'defs'>} props
|
||||
*
|
||||
* @return {JSX.Element} Defs component
|
||||
*/
|
||||
const Defs = props => (0,external_wp_element_namespaceObject.createElement)('defs', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'radialGradient'>} props
|
||||
*
|
||||
* @return {JSX.Element} RadialGradient component
|
||||
*/
|
||||
const RadialGradient = props => (0,external_wp_element_namespaceObject.createElement)('radialGradient', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'linearGradient'>} props
|
||||
*
|
||||
* @return {JSX.Element} LinearGradient component
|
||||
*/
|
||||
const LinearGradient = props => (0,external_wp_element_namespaceObject.createElement)('linearGradient', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'stop'>} props
|
||||
*
|
||||
* @return {JSX.Element} Stop component
|
||||
*/
|
||||
const Stop = props => (0,external_wp_element_namespaceObject.createElement)('stop', props);
|
||||
const SVG = (0,external_wp_element_namespaceObject.forwardRef)(
|
||||
/**
|
||||
* @param {SVGProps} props isPressed indicates whether the SVG should appear as pressed.
|
||||
* Other props will be passed through to svg component.
|
||||
* @param {import('react').ForwardedRef<SVGSVGElement>} ref The forwarded ref to the SVG element.
|
||||
*
|
||||
* @return {JSX.Element} Stop component
|
||||
*/
|
||||
({
|
||||
className,
|
||||
isPressed,
|
||||
...props
|
||||
}, ref) => {
|
||||
const appliedProps = {
|
||||
...props,
|
||||
className: classnames_default()(className, {
|
||||
'is-pressed': isPressed
|
||||
}) || undefined,
|
||||
'aria-hidden': true,
|
||||
focusable: false
|
||||
};
|
||||
|
||||
// Disable reason: We need to have a way to render HTML tag for web.
|
||||
// eslint-disable-next-line react/forbid-elements
|
||||
return (0,external_wp_element_namespaceObject.createElement)("svg", {
|
||||
...appliedProps,
|
||||
ref: ref
|
||||
});
|
||||
});
|
||||
SVG.displayName = 'SVG';
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/primitives/build-module/horizontal-rule/index.js
|
||||
const HorizontalRule = 'hr';
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/primitives/build-module/block-quotation/index.js
|
||||
const BlockQuotation = 'blockquote';
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/primitives/build-module/view/index.js
|
||||
const View = 'div';
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/primitives/build-module/index.js
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}();
|
||||
(window.wp = window.wp || {}).primitives = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){var e={4403:function(e,t){var n;
|
||||
/*!
|
||||
Copyright (c) 2018 Jed Watson.
|
||||
Licensed under the MIT License (MIT), see
|
||||
http://jedwatson.github.io/classnames
|
||||
*/!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var i=typeof n;if("string"===i||"number"===i)e.push(n);else if(Array.isArray(n)){if(n.length){var u=o.apply(null,n);u&&e.push(u)}}else if("object"===i){if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]")){e.push(n.toString());continue}for(var a in n)r.call(n,a)&&n[a]&&e.push(a)}}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n)}()}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};!function(){"use strict";n.r(r),n.d(r,{BlockQuotation:function(){return g},Circle:function(){return i},Defs:function(){return s},G:function(){return u},HorizontalRule:function(){return y},Line:function(){return a},LinearGradient:function(){return d},Path:function(){return c},Polygon:function(){return l},RadialGradient:function(){return p},Rect:function(){return f},SVG:function(){return m},Stop:function(){return v},View:function(){return b}});var e=n(4403),t=n.n(e),o=window.wp.element;const i=e=>(0,o.createElement)("circle",e),u=e=>(0,o.createElement)("g",e),a=e=>(0,o.createElement)("line",e),c=e=>(0,o.createElement)("path",e),l=e=>(0,o.createElement)("polygon",e),f=e=>(0,o.createElement)("rect",e),s=e=>(0,o.createElement)("defs",e),p=e=>(0,o.createElement)("radialGradient",e),d=e=>(0,o.createElement)("linearGradient",e),v=e=>(0,o.createElement)("stop",e),m=(0,o.forwardRef)((({className:e,isPressed:n,...r},i)=>{const u={...r,className:t()(e,{"is-pressed":n})||void 0,"aria-hidden":!0,focusable:!1};return(0,o.createElement)("svg",{...u,ref:i})}));m.displayName="SVG";const y="hr",g="blockquote",b="div"}(),(window.wp=window.wp||{}).primitives=r}();
|
||||
+509
@@ -0,0 +1,509 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ 3159:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (factory) {
|
||||
if (true) {
|
||||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
||||
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
||||
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
|
||||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
||||
} else {}
|
||||
}(function(){
|
||||
'use strict';
|
||||
var scheduleStart, throttleDelay, lazytimer, lazyraf;
|
||||
var root = typeof window != 'undefined' ?
|
||||
window :
|
||||
typeof __webpack_require__.g != undefined ?
|
||||
__webpack_require__.g :
|
||||
this || {};
|
||||
var requestAnimationFrame = root.cancelRequestAnimationFrame && root.requestAnimationFrame || setTimeout;
|
||||
var cancelRequestAnimationFrame = root.cancelRequestAnimationFrame || clearTimeout;
|
||||
var tasks = [];
|
||||
var runAttempts = 0;
|
||||
var isRunning = false;
|
||||
var remainingTime = 7;
|
||||
var minThrottle = 35;
|
||||
var throttle = 125;
|
||||
var index = 0;
|
||||
var taskStart = 0;
|
||||
var tasklength = 0;
|
||||
var IdleDeadline = {
|
||||
get didTimeout(){
|
||||
return false;
|
||||
},
|
||||
timeRemaining: function(){
|
||||
var timeRemaining = remainingTime - (Date.now() - taskStart);
|
||||
return timeRemaining < 0 ? 0 : timeRemaining;
|
||||
},
|
||||
};
|
||||
var setInactive = debounce(function(){
|
||||
remainingTime = 22;
|
||||
throttle = 66;
|
||||
minThrottle = 0;
|
||||
});
|
||||
|
||||
function debounce(fn){
|
||||
var id, timestamp;
|
||||
var wait = 99;
|
||||
var check = function(){
|
||||
var last = (Date.now()) - timestamp;
|
||||
|
||||
if (last < wait) {
|
||||
id = setTimeout(check, wait - last);
|
||||
} else {
|
||||
id = null;
|
||||
fn();
|
||||
}
|
||||
};
|
||||
return function(){
|
||||
timestamp = Date.now();
|
||||
if(!id){
|
||||
id = setTimeout(check, wait);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function abortRunning(){
|
||||
if(isRunning){
|
||||
if(lazyraf){
|
||||
cancelRequestAnimationFrame(lazyraf);
|
||||
}
|
||||
if(lazytimer){
|
||||
clearTimeout(lazytimer);
|
||||
}
|
||||
isRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onInputorMutation(){
|
||||
if(throttle != 125){
|
||||
remainingTime = 7;
|
||||
throttle = 125;
|
||||
minThrottle = 35;
|
||||
|
||||
if(isRunning) {
|
||||
abortRunning();
|
||||
scheduleLazy();
|
||||
}
|
||||
}
|
||||
setInactive();
|
||||
}
|
||||
|
||||
function scheduleAfterRaf() {
|
||||
lazyraf = null;
|
||||
lazytimer = setTimeout(runTasks, 0);
|
||||
}
|
||||
|
||||
function scheduleRaf(){
|
||||
lazytimer = null;
|
||||
requestAnimationFrame(scheduleAfterRaf);
|
||||
}
|
||||
|
||||
function scheduleLazy(){
|
||||
|
||||
if(isRunning){return;}
|
||||
throttleDelay = throttle - (Date.now() - taskStart);
|
||||
|
||||
scheduleStart = Date.now();
|
||||
|
||||
isRunning = true;
|
||||
|
||||
if(minThrottle && throttleDelay < minThrottle){
|
||||
throttleDelay = minThrottle;
|
||||
}
|
||||
|
||||
if(throttleDelay > 9){
|
||||
lazytimer = setTimeout(scheduleRaf, throttleDelay);
|
||||
} else {
|
||||
throttleDelay = 0;
|
||||
scheduleRaf();
|
||||
}
|
||||
}
|
||||
|
||||
function runTasks(){
|
||||
var task, i, len;
|
||||
var timeThreshold = remainingTime > 9 ?
|
||||
9 :
|
||||
1
|
||||
;
|
||||
|
||||
taskStart = Date.now();
|
||||
isRunning = false;
|
||||
|
||||
lazytimer = null;
|
||||
|
||||
if(runAttempts > 2 || taskStart - throttleDelay - 50 < scheduleStart){
|
||||
for(i = 0, len = tasks.length; i < len && IdleDeadline.timeRemaining() > timeThreshold; i++){
|
||||
task = tasks.shift();
|
||||
tasklength++;
|
||||
if(task){
|
||||
task(IdleDeadline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tasks.length){
|
||||
scheduleLazy();
|
||||
} else {
|
||||
runAttempts = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function requestIdleCallbackShim(task){
|
||||
index++;
|
||||
tasks.push(task);
|
||||
scheduleLazy();
|
||||
return index;
|
||||
}
|
||||
|
||||
function cancelIdleCallbackShim(id){
|
||||
var index = id - 1 - tasklength;
|
||||
if(tasks[index]){
|
||||
tasks[index] = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(!root.requestIdleCallback || !root.cancelIdleCallback){
|
||||
root.requestIdleCallback = requestIdleCallbackShim;
|
||||
root.cancelIdleCallback = cancelIdleCallbackShim;
|
||||
|
||||
if(root.document && document.addEventListener){
|
||||
root.addEventListener('scroll', onInputorMutation, true);
|
||||
root.addEventListener('resize', onInputorMutation);
|
||||
|
||||
document.addEventListener('focus', onInputorMutation, true);
|
||||
document.addEventListener('mouseover', onInputorMutation, true);
|
||||
['click', 'keypress', 'touchstart', 'mousedown'].forEach(function(name){
|
||||
document.addEventListener(name, onInputorMutation, {capture: true, passive: true});
|
||||
});
|
||||
|
||||
if(root.MutationObserver){
|
||||
new MutationObserver( onInputorMutation ).observe( document.documentElement, {childList: true, subtree: true, attributes: true} );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try{
|
||||
root.requestIdleCallback(function(){}, {timeout: 0});
|
||||
} catch(e){
|
||||
(function(rIC){
|
||||
var timeRemainingProto, timeRemaining;
|
||||
root.requestIdleCallback = function(fn, timeout){
|
||||
if(timeout && typeof timeout.timeout == 'number'){
|
||||
return rIC(fn, timeout.timeout);
|
||||
}
|
||||
return rIC(fn);
|
||||
};
|
||||
if(root.IdleCallbackDeadline && (timeRemainingProto = IdleCallbackDeadline.prototype)){
|
||||
timeRemaining = Object.getOwnPropertyDescriptor(timeRemainingProto, 'timeRemaining');
|
||||
if(!timeRemaining || !timeRemaining.configurable || !timeRemaining.get){return;}
|
||||
Object.defineProperty(timeRemainingProto, 'timeRemaining', {
|
||||
value: function(){
|
||||
return timeRemaining.get.call(this);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
})(root.requestIdleCallback)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
request: requestIdleCallbackShim,
|
||||
cancel: cancelIdleCallbackShim,
|
||||
};
|
||||
}));
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // 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/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/global */
|
||||
/******/ !function() {
|
||||
/******/ __webpack_require__.g = (function() {
|
||||
/******/ if (typeof globalThis === 'object') return globalThis;
|
||||
/******/ try {
|
||||
/******/ return this || new Function('return this')();
|
||||
/******/ } catch (e) {
|
||||
/******/ if (typeof window === 'object') return window;
|
||||
/******/ }
|
||||
/******/ })();
|
||||
/******/ }();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||
/******/ !function() {
|
||||
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
||||
/******/ }();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ !function() {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/ }();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
||||
!function() {
|
||||
"use strict";
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
createQueue: function() { return /* binding */ createQueue; }
|
||||
});
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/requestidlecallback/index.js
|
||||
var requestidlecallback = __webpack_require__(3159);
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/priority-queue/build-module/request-idle-callback.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {( timeOrDeadline: IdleDeadline | number ) => void} Callback
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return {(callback: Callback) => void} RequestIdleCallback
|
||||
*/
|
||||
function createRequestIdleCallback() {
|
||||
if (typeof window === 'undefined') {
|
||||
return callback => {
|
||||
setTimeout(() => callback(Date.now()), 0);
|
||||
};
|
||||
}
|
||||
return window.requestIdleCallback;
|
||||
}
|
||||
/* harmony default export */ var request_idle_callback = (createRequestIdleCallback());
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/priority-queue/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Enqueued callback to invoke once idle time permits.
|
||||
*
|
||||
* @typedef {()=>void} WPPriorityQueueCallback
|
||||
*/
|
||||
|
||||
/**
|
||||
* An object used to associate callbacks in a particular context grouping.
|
||||
*
|
||||
* @typedef {{}} WPPriorityQueueContext
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function to add callback to priority queue.
|
||||
*
|
||||
* @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function to flush callbacks from priority queue.
|
||||
*
|
||||
* @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reset the queue.
|
||||
*
|
||||
* @typedef {()=>void} WPPriorityQueueReset
|
||||
*/
|
||||
|
||||
/**
|
||||
* Priority queue instance.
|
||||
*
|
||||
* @typedef {Object} WPPriorityQueue
|
||||
*
|
||||
* @property {WPPriorityQueueAdd} add Add callback to queue for context.
|
||||
* @property {WPPriorityQueueFlush} flush Flush queue for context.
|
||||
* @property {WPPriorityQueueFlush} cancel Clear queue for context.
|
||||
* @property {WPPriorityQueueReset} reset Reset queue.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a context-aware queue that only executes
|
||||
* the last task of a given context.
|
||||
*
|
||||
* @example
|
||||
*```js
|
||||
* import { createQueue } from '@wordpress/priority-queue';
|
||||
*
|
||||
* const queue = createQueue();
|
||||
*
|
||||
* // Context objects.
|
||||
* const ctx1 = {};
|
||||
* const ctx2 = {};
|
||||
*
|
||||
* // For a given context in the queue, only the last callback is executed.
|
||||
* queue.add( ctx1, () => console.log( 'This will be printed first' ) );
|
||||
* queue.add( ctx2, () => console.log( 'This won\'t be printed' ) );
|
||||
* queue.add( ctx2, () => console.log( 'This will be printed second' ) );
|
||||
*```
|
||||
*
|
||||
* @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.
|
||||
*/
|
||||
const createQueue = () => {
|
||||
/** @type {Map<WPPriorityQueueContext, WPPriorityQueueCallback>} */
|
||||
const waitingList = new Map();
|
||||
let isRunning = false;
|
||||
|
||||
/**
|
||||
* Callback to process as much queue as time permits.
|
||||
*
|
||||
* Map Iteration follows the original insertion order. This means that here
|
||||
* we can iterate the queue and know that the first contexts which were
|
||||
* added will be run first. On the other hand, if anyone adds a new callback
|
||||
* for an existing context it will supplant the previously-set callback for
|
||||
* that context because we reassigned that map key's value.
|
||||
*
|
||||
* In the case that a callback adds a new callback to its own context then
|
||||
* the callback it adds will appear at the end of the iteration and will be
|
||||
* run only after all other existing contexts have finished executing.
|
||||
*
|
||||
* @param {IdleDeadline|number} deadline Idle callback deadline object, or
|
||||
* animation frame timestamp.
|
||||
*/
|
||||
const runWaitingList = deadline => {
|
||||
for (const [nextElement, callback] of waitingList) {
|
||||
waitingList.delete(nextElement);
|
||||
callback();
|
||||
if ('number' === typeof deadline || deadline.timeRemaining() <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (waitingList.size === 0) {
|
||||
isRunning = false;
|
||||
return;
|
||||
}
|
||||
request_idle_callback(runWaitingList);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a callback to the queue for a given context.
|
||||
*
|
||||
* If errors with undefined callbacks are encountered double check that
|
||||
* all of your useSelect calls have the right dependencies set correctly
|
||||
* in their second parameter. Missing dependencies can cause unexpected
|
||||
* loops and race conditions in the queue.
|
||||
*
|
||||
* @type {WPPriorityQueueAdd}
|
||||
*
|
||||
* @param {WPPriorityQueueContext} element Context object.
|
||||
* @param {WPPriorityQueueCallback} item Callback function.
|
||||
*/
|
||||
const add = (element, item) => {
|
||||
waitingList.set(element, item);
|
||||
if (!isRunning) {
|
||||
isRunning = true;
|
||||
request_idle_callback(runWaitingList);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Flushes queue for a given context, returning true if the flush was
|
||||
* performed, or false if there is no queue for the given context.
|
||||
*
|
||||
* @type {WPPriorityQueueFlush}
|
||||
*
|
||||
* @param {WPPriorityQueueContext} element Context object.
|
||||
*
|
||||
* @return {boolean} Whether flush was performed.
|
||||
*/
|
||||
const flush = element => {
|
||||
const callback = waitingList.get(element);
|
||||
if (undefined === callback) {
|
||||
return false;
|
||||
}
|
||||
waitingList.delete(element);
|
||||
callback();
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears the queue for a given context, cancelling the callbacks without
|
||||
* executing them. Returns `true` if there were scheduled callbacks to cancel,
|
||||
* or `false` if there was is no queue for the given context.
|
||||
*
|
||||
* @type {WPPriorityQueueFlush}
|
||||
*
|
||||
* @param {WPPriorityQueueContext} element Context object.
|
||||
*
|
||||
* @return {boolean} Whether any callbacks got cancelled.
|
||||
*/
|
||||
const cancel = element => {
|
||||
return waitingList.delete(element);
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset the queue without running the pending callbacks.
|
||||
*
|
||||
* @type {WPPriorityQueueReset}
|
||||
*/
|
||||
const reset = () => {
|
||||
waitingList.clear();
|
||||
isRunning = false;
|
||||
};
|
||||
return {
|
||||
add,
|
||||
flush,
|
||||
cancel,
|
||||
reset
|
||||
};
|
||||
};
|
||||
|
||||
}();
|
||||
(window.wp = window.wp || {}).priorityQueue = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){var e={3159:function(e,t,n){var o,r,i;r=[],void 0===(i="function"==typeof(o=function(){"use strict";var e,t,o,r,i="undefined"!=typeof window?window:null!=typeof n.g?n.g:this||{},u=i.cancelRequestAnimationFrame&&i.requestAnimationFrame||setTimeout,a=i.cancelRequestAnimationFrame||clearTimeout,c=[],l=0,s=!1,d=7,f=35,m=125,b=0,p=0,v=0,w={get didTimeout(){return!1},timeRemaining:function(){var e=d-(Date.now()-p);return e<0?0:e}},y=g((function(){d=22,m=66,f=0}));function g(e){var t,n,o=99,r=function(){var i=Date.now()-n;i<o?t=setTimeout(r,o-i):(t=null,e())};return function(){n=Date.now(),t||(t=setTimeout(r,o))}}function h(){s&&(r&&a(r),o&&clearTimeout(o),s=!1)}function k(){125!=m&&(d=7,m=125,f=35,s&&(h(),C())),y()}function T(){r=null,o=setTimeout(D,0)}function q(){o=null,u(T)}function C(){s||(t=m-(Date.now()-p),e=Date.now(),s=!0,f&&t<f&&(t=f),t>9?o=setTimeout(q,t):(t=0,q()))}function D(){var n,r,i,u=d>9?9:1;if(p=Date.now(),s=!1,o=null,l>2||p-t-50<e)for(r=0,i=c.length;r<i&&w.timeRemaining()>u;r++)n=c.shift(),v++,n&&n(w);c.length?C():l=0}function I(e){return b++,c.push(e),C(),b}function O(e){var t=e-1-v;c[t]&&(c[t]=null)}if(i.requestIdleCallback&&i.cancelIdleCallback)try{i.requestIdleCallback((function(){}),{timeout:0})}catch(e){!function(e){var t,n;if(i.requestIdleCallback=function(t,n){return n&&"number"==typeof n.timeout?e(t,n.timeout):e(t)},i.IdleCallbackDeadline&&(t=IdleCallbackDeadline.prototype)){if(!(n=Object.getOwnPropertyDescriptor(t,"timeRemaining"))||!n.configurable||!n.get)return;Object.defineProperty(t,"timeRemaining",{value:function(){return n.get.call(this)},enumerable:!0,configurable:!0})}}(i.requestIdleCallback)}else i.requestIdleCallback=I,i.cancelIdleCallback=O,i.document&&document.addEventListener&&(i.addEventListener("scroll",k,!0),i.addEventListener("resize",k),document.addEventListener("focus",k,!0),document.addEventListener("mouseover",k,!0),["click","keypress","touchstart","mousedown"].forEach((function(e){document.addEventListener(e,k,{capture:!0,passive:!0})})),i.MutationObserver&&new MutationObserver(k).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}));return{request:I,cancel:O}})?o.apply(t,r):o)||(e.exports=i)}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.d=function(e,t){for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};!function(){"use strict";n.r(o),n.d(o,{createQueue:function(){return t}});n(3159);var e="undefined"==typeof window?e=>{setTimeout((()=>e(Date.now())),0)}:window.requestIdleCallback;const t=()=>{const t=new Map;let n=!1;const o=r=>{for(const[e,n]of t)if(t.delete(e),n(),"number"==typeof r||r.timeRemaining()<=0)break;0!==t.size?e(o):n=!1};return{add:(r,i)=>{t.set(r,i),n||(n=!0,e(o))},flush:e=>{const n=t.get(e);return void 0!==n&&(t.delete(e),n(),!0)},cancel:e=>t.delete(e),reset:()=>{t.clear(),n=!1}}}}(),(window.wp=window.wp||{}).priorityQueue=o}();
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* 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__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
__dangerousOptInToUnstableAPIsOnlyForCoreModules: function() { return /* reexport */ __dangerousOptInToUnstableAPIsOnlyForCoreModules; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/private-apis/build-module/implementation.js
|
||||
/**
|
||||
* wordpress/private-apis – the utilities to enable private cross-package
|
||||
* exports of private APIs.
|
||||
*
|
||||
* This "implementation.js" file is needed for the sake of the unit tests. It
|
||||
* exports more than the public API of the package to aid in testing.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The list of core modules allowed to opt-in to the private APIs.
|
||||
*/
|
||||
const CORE_MODULES_USING_PRIVATE_APIS = ['@wordpress/block-editor', '@wordpress/block-library', '@wordpress/blocks', '@wordpress/commands', '@wordpress/components', '@wordpress/core-commands', '@wordpress/core-data', '@wordpress/customize-widgets', '@wordpress/data', '@wordpress/edit-post', '@wordpress/edit-site', '@wordpress/edit-widgets', '@wordpress/editor', '@wordpress/patterns', '@wordpress/reusable-blocks', '@wordpress/router'];
|
||||
|
||||
/**
|
||||
* A list of core modules that already opted-in to
|
||||
* the privateApis package.
|
||||
*
|
||||
* @type {string[]}
|
||||
*/
|
||||
const registeredPrivateApis = [];
|
||||
|
||||
/*
|
||||
* Warning for theme and plugin developers.
|
||||
*
|
||||
* The use of private developer APIs is intended for use by WordPress Core
|
||||
* and the Gutenberg plugin exclusively.
|
||||
*
|
||||
* Dangerously opting in to using these APIs is NOT RECOMMENDED. Furthermore,
|
||||
* the WordPress Core philosophy to strive to maintain backward compatibility
|
||||
* for third-party developers DOES NOT APPLY to private APIs.
|
||||
*
|
||||
* THE CONSENT STRING FOR OPTING IN TO THESE APIS MAY CHANGE AT ANY TIME AND
|
||||
* WITHOUT NOTICE. THIS CHANGE WILL BREAK EXISTING THIRD-PARTY CODE. SUCH A
|
||||
* CHANGE MAY OCCUR IN EITHER A MAJOR OR MINOR RELEASE.
|
||||
*/
|
||||
const requiredConsent = 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.';
|
||||
|
||||
/** @type {boolean} */
|
||||
let allowReRegistration;
|
||||
// The safety measure is meant for WordPress core where IS_WORDPRESS_CORE
|
||||
// is set to true.
|
||||
// For the general use-case, the re-registration should be allowed by default
|
||||
// Let's default to true, then. Try/catch will fall back to "true" even if the
|
||||
// environment variable is not explicitly defined.
|
||||
try {
|
||||
allowReRegistration = true ? false : 0;
|
||||
} catch (error) {
|
||||
allowReRegistration = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by a @wordpress package wishing to opt-in to accessing or exposing
|
||||
* private private APIs.
|
||||
*
|
||||
* @param {string} consent The consent string.
|
||||
* @param {string} moduleName The name of the module that is opting in.
|
||||
* @return {{lock: typeof lock, unlock: typeof unlock}} An object containing the lock and unlock functions.
|
||||
*/
|
||||
const __dangerousOptInToUnstableAPIsOnlyForCoreModules = (consent, moduleName) => {
|
||||
if (!CORE_MODULES_USING_PRIVATE_APIS.includes(moduleName)) {
|
||||
throw new Error(`You tried to opt-in to unstable APIs as module "${moduleName}". ` + 'This feature is only for JavaScript modules shipped with WordPress core. ' + 'Please do not use it in plugins and themes as the unstable APIs will be removed ' + 'without a warning. If you ignore this error and depend on unstable features, ' + 'your product will inevitably break on one of the next WordPress releases.');
|
||||
}
|
||||
if (!allowReRegistration && registeredPrivateApis.includes(moduleName)) {
|
||||
// This check doesn't play well with Story Books / Hot Module Reloading
|
||||
// and isn't included in the Gutenberg plugin. It only matters in the
|
||||
// WordPress core release.
|
||||
throw new Error(`You tried to opt-in to unstable APIs as module "${moduleName}" which is already registered. ` + 'This feature is only for JavaScript modules shipped with WordPress core. ' + 'Please do not use it in plugins and themes as the unstable APIs will be removed ' + 'without a warning. If you ignore this error and depend on unstable features, ' + 'your product will inevitably break on one of the next WordPress releases.');
|
||||
}
|
||||
if (consent !== requiredConsent) {
|
||||
throw new Error(`You tried to opt-in to unstable APIs without confirming you know the consequences. ` + 'This feature is only for JavaScript modules shipped with WordPress core. ' + 'Please do not use it in plugins and themes as the unstable APIs will removed ' + 'without a warning. If you ignore this error and depend on unstable features, ' + 'your product will inevitably break on the next WordPress release.');
|
||||
}
|
||||
registeredPrivateApis.push(moduleName);
|
||||
return {
|
||||
lock,
|
||||
unlock
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Binds private data to an object.
|
||||
* It does not alter the passed object in any way, only
|
||||
* registers it in an internal map of private data.
|
||||
*
|
||||
* The private data can't be accessed by any other means
|
||||
* than the `unlock` function.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const object = {};
|
||||
* const privateData = { a: 1 };
|
||||
* lock( object, privateData );
|
||||
*
|
||||
* object
|
||||
* // {}
|
||||
*
|
||||
* unlock( object );
|
||||
* // { a: 1 }
|
||||
* ```
|
||||
*
|
||||
* @param {any} object The object to bind the private data to.
|
||||
* @param {any} privateData The private data to bind to the object.
|
||||
*/
|
||||
function lock(object, privateData) {
|
||||
if (!object) {
|
||||
throw new Error('Cannot lock an undefined object.');
|
||||
}
|
||||
if (!(__private in object)) {
|
||||
object[__private] = {};
|
||||
}
|
||||
lockedData.set(object[__private], privateData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlocks the private data bound to an object.
|
||||
*
|
||||
* It does not alter the passed object in any way, only
|
||||
* returns the private data paired with it using the `lock()`
|
||||
* function.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const object = {};
|
||||
* const privateData = { a: 1 };
|
||||
* lock( object, privateData );
|
||||
*
|
||||
* object
|
||||
* // {}
|
||||
*
|
||||
* unlock( object );
|
||||
* // { a: 1 }
|
||||
* ```
|
||||
*
|
||||
* @param {any} object The object to unlock the private data from.
|
||||
* @return {any} The private data bound to the object.
|
||||
*/
|
||||
function unlock(object) {
|
||||
if (!object) {
|
||||
throw new Error('Cannot unlock an undefined object.');
|
||||
}
|
||||
if (!(__private in object)) {
|
||||
throw new Error('Cannot unlock an object that was not locked before. ');
|
||||
}
|
||||
return lockedData.get(object[__private]);
|
||||
}
|
||||
const lockedData = new WeakMap();
|
||||
|
||||
/**
|
||||
* Used by lock() and unlock() to uniquely identify the private data
|
||||
* related to a containing object.
|
||||
*/
|
||||
const __private = Symbol('Private API ID');
|
||||
|
||||
// Unit tests utilities:
|
||||
|
||||
/**
|
||||
* Private function to allow the unit tests to allow
|
||||
* a mock module to access the private APIs.
|
||||
*
|
||||
* @param {string} name The name of the module.
|
||||
*/
|
||||
function allowCoreModule(name) {
|
||||
CORE_MODULES_USING_PRIVATE_APIS.push(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private function to allow the unit tests to set
|
||||
* a custom list of allowed modules.
|
||||
*/
|
||||
function resetAllowedCoreModules() {
|
||||
while (CORE_MODULES_USING_PRIVATE_APIS.length) {
|
||||
CORE_MODULES_USING_PRIVATE_APIS.pop();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Private function to allow the unit tests to reset
|
||||
* the list of registered private apis.
|
||||
*/
|
||||
function resetRegisteredPrivateApis() {
|
||||
while (registeredPrivateApis.length) {
|
||||
registeredPrivateApis.pop();
|
||||
}
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/private-apis/build-module/index.js
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).privateApis = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(){"use strict";var e={d:function(o,r){for(var t in r)e.o(r,t)&&!e.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:r[t]})},o:function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{__dangerousOptInToUnstableAPIsOnlyForCoreModules:function(){return s}});const r=["@wordpress/block-editor","@wordpress/block-library","@wordpress/blocks","@wordpress/commands","@wordpress/components","@wordpress/core-commands","@wordpress/core-data","@wordpress/customize-widgets","@wordpress/data","@wordpress/edit-post","@wordpress/edit-site","@wordpress/edit-widgets","@wordpress/editor","@wordpress/patterns","@wordpress/reusable-blocks","@wordpress/router"],t=[];let n;try{n=!1}catch(e){n=!0}const s=(e,o)=>{if(!r.includes(o))throw new Error(`You tried to opt-in to unstable APIs as module "${o}". This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will be removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on one of the next WordPress releases.`);if(!n&&t.includes(o))throw new Error(`You tried to opt-in to unstable APIs as module "${o}" which is already registered. This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will be removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on one of the next WordPress releases.`);if("I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress."!==e)throw new Error("You tried to opt-in to unstable APIs without confirming you know the consequences. This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on the next WordPress release.");return t.push(o),{lock:i,unlock:a}};function i(e,o){if(!e)throw new Error("Cannot lock an undefined object.");u in e||(e[u]={}),d.set(e[u],o)}function a(e){if(!e)throw new Error("Cannot unlock an undefined object.");if(!(u in e))throw new Error("Cannot unlock an object that was not locked before. ");return d.get(e[u])}const d=new WeakMap,u=Symbol("Private API ID");(window.wp=window.wp||{}).privateApis=o}();
|
||||
+885
@@ -0,0 +1,885 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ 9025:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.race = exports.join = exports.fork = exports.promise = undefined;
|
||||
|
||||
var _is = __webpack_require__(9681);
|
||||
|
||||
var _is2 = _interopRequireDefault(_is);
|
||||
|
||||
var _helpers = __webpack_require__(7783);
|
||||
|
||||
var _dispatcher = __webpack_require__(2451);
|
||||
|
||||
var _dispatcher2 = _interopRequireDefault(_dispatcher);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var promise = exports.promise = function promise(value, next, rungen, yieldNext, raiseNext) {
|
||||
if (!_is2.default.promise(value)) return false;
|
||||
value.then(next, raiseNext);
|
||||
return true;
|
||||
};
|
||||
|
||||
var forkedTasks = new Map();
|
||||
var fork = exports.fork = function fork(value, next, rungen) {
|
||||
if (!_is2.default.fork(value)) return false;
|
||||
var task = Symbol('fork');
|
||||
var dispatcher = (0, _dispatcher2.default)();
|
||||
forkedTasks.set(task, dispatcher);
|
||||
rungen(value.iterator.apply(null, value.args), function (result) {
|
||||
return dispatcher.dispatch(result);
|
||||
}, function (err) {
|
||||
return dispatcher.dispatch((0, _helpers.error)(err));
|
||||
});
|
||||
var unsubscribe = dispatcher.subscribe(function () {
|
||||
unsubscribe();
|
||||
forkedTasks.delete(task);
|
||||
});
|
||||
next(task);
|
||||
return true;
|
||||
};
|
||||
|
||||
var join = exports.join = function join(value, next, rungen, yieldNext, raiseNext) {
|
||||
if (!_is2.default.join(value)) return false;
|
||||
var dispatcher = forkedTasks.get(value.task);
|
||||
if (!dispatcher) {
|
||||
raiseNext('join error : task not found');
|
||||
} else {
|
||||
(function () {
|
||||
var unsubscribe = dispatcher.subscribe(function (result) {
|
||||
unsubscribe();
|
||||
next(result);
|
||||
});
|
||||
})();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
var race = exports.race = function race(value, next, rungen, yieldNext, raiseNext) {
|
||||
if (!_is2.default.race(value)) return false;
|
||||
var finished = false;
|
||||
var success = function success(result, k, v) {
|
||||
if (finished) return;
|
||||
finished = true;
|
||||
result[k] = v;
|
||||
next(result);
|
||||
};
|
||||
|
||||
var fail = function fail(err) {
|
||||
if (finished) return;
|
||||
raiseNext(err);
|
||||
};
|
||||
if (_is2.default.array(value.competitors)) {
|
||||
(function () {
|
||||
var result = value.competitors.map(function () {
|
||||
return false;
|
||||
});
|
||||
value.competitors.forEach(function (competitor, index) {
|
||||
rungen(competitor, function (output) {
|
||||
return success(result, index, output);
|
||||
}, fail);
|
||||
});
|
||||
})();
|
||||
} else {
|
||||
(function () {
|
||||
var result = Object.keys(value.competitors).reduce(function (p, c) {
|
||||
p[c] = false;
|
||||
return p;
|
||||
}, {});
|
||||
Object.keys(value.competitors).forEach(function (index) {
|
||||
rungen(value.competitors[index], function (output) {
|
||||
return success(result, index, output);
|
||||
}, fail);
|
||||
});
|
||||
})();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
var subscribe = function subscribe(value, next) {
|
||||
if (!_is2.default.subscribe(value)) return false;
|
||||
if (!_is2.default.channel(value.channel)) {
|
||||
throw new Error('the first argument of "subscribe" must be a valid channel');
|
||||
}
|
||||
var unsubscribe = value.channel.subscribe(function (ret) {
|
||||
unsubscribe && unsubscribe();
|
||||
next(ret);
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
exports["default"] = [promise, fork, join, race, subscribe];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7961:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.iterator = exports.array = exports.object = exports.error = exports.any = undefined;
|
||||
|
||||
var _is = __webpack_require__(9681);
|
||||
|
||||
var _is2 = _interopRequireDefault(_is);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var any = exports.any = function any(value, next, rungen, yieldNext) {
|
||||
yieldNext(value);
|
||||
return true;
|
||||
};
|
||||
|
||||
var error = exports.error = function error(value, next, rungen, yieldNext, raiseNext) {
|
||||
if (!_is2.default.error(value)) return false;
|
||||
raiseNext(value.error);
|
||||
return true;
|
||||
};
|
||||
|
||||
var object = exports.object = function object(value, next, rungen, yieldNext, raiseNext) {
|
||||
if (!_is2.default.all(value) || !_is2.default.obj(value.value)) return false;
|
||||
var result = {};
|
||||
var keys = Object.keys(value.value);
|
||||
var count = 0;
|
||||
var hasError = false;
|
||||
var gotResultSuccess = function gotResultSuccess(key, ret) {
|
||||
if (hasError) return;
|
||||
result[key] = ret;
|
||||
count++;
|
||||
if (count === keys.length) {
|
||||
yieldNext(result);
|
||||
}
|
||||
};
|
||||
|
||||
var gotResultError = function gotResultError(key, error) {
|
||||
if (hasError) return;
|
||||
hasError = true;
|
||||
raiseNext(error);
|
||||
};
|
||||
|
||||
keys.map(function (key) {
|
||||
rungen(value.value[key], function (ret) {
|
||||
return gotResultSuccess(key, ret);
|
||||
}, function (err) {
|
||||
return gotResultError(key, err);
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var array = exports.array = function array(value, next, rungen, yieldNext, raiseNext) {
|
||||
if (!_is2.default.all(value) || !_is2.default.array(value.value)) return false;
|
||||
var result = [];
|
||||
var count = 0;
|
||||
var hasError = false;
|
||||
var gotResultSuccess = function gotResultSuccess(key, ret) {
|
||||
if (hasError) return;
|
||||
result[key] = ret;
|
||||
count++;
|
||||
if (count === value.value.length) {
|
||||
yieldNext(result);
|
||||
}
|
||||
};
|
||||
|
||||
var gotResultError = function gotResultError(key, error) {
|
||||
if (hasError) return;
|
||||
hasError = true;
|
||||
raiseNext(error);
|
||||
};
|
||||
|
||||
value.value.map(function (v, key) {
|
||||
rungen(v, function (ret) {
|
||||
return gotResultSuccess(key, ret);
|
||||
}, function (err) {
|
||||
return gotResultError(key, err);
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var iterator = exports.iterator = function iterator(value, next, rungen, yieldNext, raiseNext) {
|
||||
if (!_is2.default.iterator(value)) return false;
|
||||
rungen(value, next, raiseNext);
|
||||
return true;
|
||||
};
|
||||
|
||||
exports["default"] = [error, iterator, array, object, any];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2165:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.cps = exports.call = undefined;
|
||||
|
||||
var _is = __webpack_require__(9681);
|
||||
|
||||
var _is2 = _interopRequireDefault(_is);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
|
||||
var call = exports.call = function call(value, next, rungen, yieldNext, raiseNext) {
|
||||
if (!_is2.default.call(value)) return false;
|
||||
try {
|
||||
next(value.func.apply(value.context, value.args));
|
||||
} catch (err) {
|
||||
raiseNext(err);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
var cps = exports.cps = function cps(value, next, rungen, yieldNext, raiseNext) {
|
||||
var _value$func;
|
||||
|
||||
if (!_is2.default.cps(value)) return false;
|
||||
(_value$func = value.func).call.apply(_value$func, [null].concat(_toConsumableArray(value.args), [function (err, result) {
|
||||
if (err) raiseNext(err);else next(result);
|
||||
}]));
|
||||
return true;
|
||||
};
|
||||
|
||||
exports["default"] = [call, cps];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 6288:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
|
||||
var _builtin = __webpack_require__(7961);
|
||||
|
||||
var _builtin2 = _interopRequireDefault(_builtin);
|
||||
|
||||
var _is = __webpack_require__(9681);
|
||||
|
||||
var _is2 = _interopRequireDefault(_is);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
|
||||
var create = function create() {
|
||||
var userControls = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
|
||||
|
||||
var controls = [].concat(_toConsumableArray(userControls), _toConsumableArray(_builtin2.default));
|
||||
|
||||
var runtime = function runtime(input) {
|
||||
var success = arguments.length <= 1 || arguments[1] === undefined ? function () {} : arguments[1];
|
||||
var error = arguments.length <= 2 || arguments[2] === undefined ? function () {} : arguments[2];
|
||||
|
||||
var iterate = function iterate(gen) {
|
||||
var yieldValue = function yieldValue(isError) {
|
||||
return function (ret) {
|
||||
try {
|
||||
var _ref = isError ? gen.throw(ret) : gen.next(ret);
|
||||
|
||||
var value = _ref.value;
|
||||
var done = _ref.done;
|
||||
|
||||
if (done) return success(value);
|
||||
next(value);
|
||||
} catch (e) {
|
||||
return error(e);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var next = function next(ret) {
|
||||
controls.some(function (control) {
|
||||
return control(ret, next, runtime, yieldValue(false), yieldValue(true));
|
||||
});
|
||||
};
|
||||
|
||||
yieldValue(false)();
|
||||
};
|
||||
|
||||
var iterator = _is2.default.iterator(input) ? input : regeneratorRuntime.mark(function _callee() {
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
_context.next = 2;
|
||||
return input;
|
||||
|
||||
case 2:
|
||||
return _context.abrupt('return', _context.sent);
|
||||
|
||||
case 3:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this);
|
||||
})();
|
||||
|
||||
iterate(iterator, success, error);
|
||||
};
|
||||
|
||||
return runtime;
|
||||
};
|
||||
|
||||
exports["default"] = create;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2290:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.wrapControls = exports.asyncControls = exports.create = undefined;
|
||||
|
||||
var _helpers = __webpack_require__(7783);
|
||||
|
||||
Object.keys(_helpers).forEach(function (key) {
|
||||
if (key === "default") return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _helpers[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _create = __webpack_require__(6288);
|
||||
|
||||
var _create2 = _interopRequireDefault(_create);
|
||||
|
||||
var _async = __webpack_require__(9025);
|
||||
|
||||
var _async2 = _interopRequireDefault(_async);
|
||||
|
||||
var _wrap = __webpack_require__(2165);
|
||||
|
||||
var _wrap2 = _interopRequireDefault(_wrap);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.create = _create2.default;
|
||||
exports.asyncControls = _async2.default;
|
||||
exports.wrapControls = _wrap2.default;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2451:
|
||||
/***/ (function(__unused_webpack_module, exports) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
var createDispatcher = function createDispatcher() {
|
||||
var listeners = [];
|
||||
|
||||
return {
|
||||
subscribe: function subscribe(listener) {
|
||||
listeners.push(listener);
|
||||
return function () {
|
||||
listeners = listeners.filter(function (l) {
|
||||
return l !== listener;
|
||||
});
|
||||
};
|
||||
},
|
||||
dispatch: function dispatch(action) {
|
||||
listeners.slice().forEach(function (listener) {
|
||||
return listener(action);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports["default"] = createDispatcher;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7783:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.createChannel = exports.subscribe = exports.cps = exports.apply = exports.call = exports.invoke = exports.delay = exports.race = exports.join = exports.fork = exports.error = exports.all = undefined;
|
||||
|
||||
var _keys = __webpack_require__(9851);
|
||||
|
||||
var _keys2 = _interopRequireDefault(_keys);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var all = exports.all = function all(value) {
|
||||
return {
|
||||
type: _keys2.default.all,
|
||||
value: value
|
||||
};
|
||||
};
|
||||
|
||||
var error = exports.error = function error(err) {
|
||||
return {
|
||||
type: _keys2.default.error,
|
||||
error: err
|
||||
};
|
||||
};
|
||||
|
||||
var fork = exports.fork = function fork(iterator) {
|
||||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
return {
|
||||
type: _keys2.default.fork,
|
||||
iterator: iterator,
|
||||
args: args
|
||||
};
|
||||
};
|
||||
|
||||
var join = exports.join = function join(task) {
|
||||
return {
|
||||
type: _keys2.default.join,
|
||||
task: task
|
||||
};
|
||||
};
|
||||
|
||||
var race = exports.race = function race(competitors) {
|
||||
return {
|
||||
type: _keys2.default.race,
|
||||
competitors: competitors
|
||||
};
|
||||
};
|
||||
|
||||
var delay = exports.delay = function delay(timeout) {
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(function () {
|
||||
return resolve(true);
|
||||
}, timeout);
|
||||
});
|
||||
};
|
||||
|
||||
var invoke = exports.invoke = function invoke(func) {
|
||||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
return {
|
||||
type: _keys2.default.call,
|
||||
func: func,
|
||||
context: null,
|
||||
args: args
|
||||
};
|
||||
};
|
||||
|
||||
var call = exports.call = function call(func, context) {
|
||||
for (var _len3 = arguments.length, args = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
||||
args[_key3 - 2] = arguments[_key3];
|
||||
}
|
||||
|
||||
return {
|
||||
type: _keys2.default.call,
|
||||
func: func,
|
||||
context: context,
|
||||
args: args
|
||||
};
|
||||
};
|
||||
|
||||
var apply = exports.apply = function apply(func, context, args) {
|
||||
return {
|
||||
type: _keys2.default.call,
|
||||
func: func,
|
||||
context: context,
|
||||
args: args
|
||||
};
|
||||
};
|
||||
|
||||
var cps = exports.cps = function cps(func) {
|
||||
for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
||||
args[_key4 - 1] = arguments[_key4];
|
||||
}
|
||||
|
||||
return {
|
||||
type: _keys2.default.cps,
|
||||
func: func,
|
||||
args: args
|
||||
};
|
||||
};
|
||||
|
||||
var subscribe = exports.subscribe = function subscribe(channel) {
|
||||
return {
|
||||
type: _keys2.default.subscribe,
|
||||
channel: channel
|
||||
};
|
||||
};
|
||||
|
||||
var createChannel = exports.createChannel = function createChannel(callback) {
|
||||
var listeners = [];
|
||||
var subscribe = function subscribe(l) {
|
||||
listeners.push(l);
|
||||
return function () {
|
||||
return listeners.splice(listeners.indexOf(l), 1);
|
||||
};
|
||||
};
|
||||
var next = function next(val) {
|
||||
return listeners.forEach(function (l) {
|
||||
return l(val);
|
||||
});
|
||||
};
|
||||
callback(next);
|
||||
|
||||
return {
|
||||
subscribe: subscribe
|
||||
};
|
||||
};
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9681:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
|
||||
|
||||
var _keys = __webpack_require__(9851);
|
||||
|
||||
var _keys2 = _interopRequireDefault(_keys);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var is = {
|
||||
obj: function obj(value) {
|
||||
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !!value;
|
||||
},
|
||||
all: function all(value) {
|
||||
return is.obj(value) && value.type === _keys2.default.all;
|
||||
},
|
||||
error: function error(value) {
|
||||
return is.obj(value) && value.type === _keys2.default.error;
|
||||
},
|
||||
array: Array.isArray,
|
||||
func: function func(value) {
|
||||
return typeof value === 'function';
|
||||
},
|
||||
promise: function promise(value) {
|
||||
return value && is.func(value.then);
|
||||
},
|
||||
iterator: function iterator(value) {
|
||||
return value && is.func(value.next) && is.func(value.throw);
|
||||
},
|
||||
fork: function fork(value) {
|
||||
return is.obj(value) && value.type === _keys2.default.fork;
|
||||
},
|
||||
join: function join(value) {
|
||||
return is.obj(value) && value.type === _keys2.default.join;
|
||||
},
|
||||
race: function race(value) {
|
||||
return is.obj(value) && value.type === _keys2.default.race;
|
||||
},
|
||||
call: function call(value) {
|
||||
return is.obj(value) && value.type === _keys2.default.call;
|
||||
},
|
||||
cps: function cps(value) {
|
||||
return is.obj(value) && value.type === _keys2.default.cps;
|
||||
},
|
||||
subscribe: function subscribe(value) {
|
||||
return is.obj(value) && value.type === _keys2.default.subscribe;
|
||||
},
|
||||
channel: function channel(value) {
|
||||
return is.obj(value) && is.func(value.subscribe);
|
||||
}
|
||||
};
|
||||
|
||||
exports["default"] = is;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9851:
|
||||
/***/ (function(__unused_webpack_module, exports) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
var keys = {
|
||||
all: Symbol('all'),
|
||||
error: Symbol('error'),
|
||||
fork: Symbol('fork'),
|
||||
join: Symbol('join'),
|
||||
race: Symbol('race'),
|
||||
call: Symbol('call'),
|
||||
cps: Symbol('cps'),
|
||||
subscribe: Symbol('subscribe')
|
||||
};
|
||||
|
||||
exports["default"] = keys;
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // 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/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); }
|
||||
/******/ }();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
||||
!function() {
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
"default": function() { return /* binding */ createMiddleware; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/redux-routine/build-module/is-generator.js
|
||||
/* eslint-disable jsdoc/valid-types */
|
||||
/**
|
||||
* Returns true if the given object is a generator, or false otherwise.
|
||||
*
|
||||
* @see https://www.ecma-international.org/ecma-262/6.0/#sec-generator-objects
|
||||
*
|
||||
* @param {any} object Object to test.
|
||||
*
|
||||
* @return {object is Generator} Whether object is a generator.
|
||||
*/
|
||||
function isGenerator(object) {
|
||||
/* eslint-enable jsdoc/valid-types */
|
||||
// Check that iterator (next) and iterable (Symbol.iterator) interfaces are satisfied.
|
||||
// These checks seem to be compatible with several generator helpers as well as the native implementation.
|
||||
return !!object && typeof object[Symbol.iterator] === 'function' && typeof object.next === 'function';
|
||||
}
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/rungen/dist/index.js
|
||||
var dist = __webpack_require__(2290);
|
||||
;// CONCATENATED MODULE: ./node_modules/is-promise/index.mjs
|
||||
function isPromise(obj) {
|
||||
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs
|
||||
/*!
|
||||
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
function isObject(o) {
|
||||
return Object.prototype.toString.call(o) === '[object Object]';
|
||||
}
|
||||
|
||||
function isPlainObject(o) {
|
||||
var ctor,prot;
|
||||
|
||||
if (isObject(o) === false) return false;
|
||||
|
||||
// If has modified constructor
|
||||
ctor = o.constructor;
|
||||
if (ctor === undefined) return true;
|
||||
|
||||
// If has modified prototype
|
||||
prot = ctor.prototype;
|
||||
if (isObject(prot) === false) return false;
|
||||
|
||||
// If constructor does not have an Object-specific method
|
||||
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Most likely a plain Object
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/redux-routine/build-module/is-action.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/* eslint-disable jsdoc/valid-types */
|
||||
/**
|
||||
* Returns true if the given object quacks like an action.
|
||||
*
|
||||
* @param {any} object Object to test
|
||||
*
|
||||
* @return {object is import('redux').AnyAction} Whether object is an action.
|
||||
*/
|
||||
function isAction(object) {
|
||||
return isPlainObject(object) && typeof object.type === 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given object quacks like an action and has a specific
|
||||
* action type
|
||||
*
|
||||
* @param {unknown} object Object to test
|
||||
* @param {string} expectedType The expected type for the action.
|
||||
*
|
||||
* @return {object is import('redux').AnyAction} Whether object is an action and is of specific type.
|
||||
*/
|
||||
function isActionOfType(object, expectedType) {
|
||||
/* eslint-enable jsdoc/valid-types */
|
||||
return isAction(object) && object.type === expectedType;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/redux-routine/build-module/runtime.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Create a co-routine runtime.
|
||||
*
|
||||
* @param controls Object of control handlers.
|
||||
* @param dispatch Unhandled action dispatch.
|
||||
*/
|
||||
function createRuntime(controls = {}, dispatch) {
|
||||
const rungenControls = Object.entries(controls).map(([actionType, control]) => (value, next, iterate, yieldNext, yieldError) => {
|
||||
if (!isActionOfType(value, actionType)) {
|
||||
return false;
|
||||
}
|
||||
const routine = control(value);
|
||||
if (isPromise(routine)) {
|
||||
// Async control routine awaits resolution.
|
||||
routine.then(yieldNext, yieldError);
|
||||
} else {
|
||||
yieldNext(routine);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
const unhandledActionControl = (value, next) => {
|
||||
if (!isAction(value)) {
|
||||
return false;
|
||||
}
|
||||
dispatch(value);
|
||||
next();
|
||||
return true;
|
||||
};
|
||||
rungenControls.push(unhandledActionControl);
|
||||
const rungenRuntime = (0,dist.create)(rungenControls);
|
||||
return action => new Promise((resolve, reject) => rungenRuntime(action, result => {
|
||||
if (isAction(result)) {
|
||||
dispatch(result);
|
||||
}
|
||||
resolve(result);
|
||||
}, reject));
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/redux-routine/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a Redux middleware, given an object of controls where each key is an
|
||||
* action type for which to act upon, the value a function which returns either
|
||||
* a promise which is to resolve when evaluation of the action should continue,
|
||||
* or a value. The value or resolved promise value is assigned on the return
|
||||
* value of the yield assignment. If the control handler returns undefined, the
|
||||
* execution is not continued.
|
||||
*
|
||||
* @param {Record<string, (value: import('redux').AnyAction) => Promise<boolean> | boolean>} controls Object of control handlers.
|
||||
*
|
||||
* @return {import('redux').Middleware} Co-routine runtime
|
||||
*/
|
||||
function createMiddleware(controls = {}) {
|
||||
return store => {
|
||||
const runtime = createRuntime(controls, store.dispatch);
|
||||
return next => action => {
|
||||
if (!isGenerator(action)) {
|
||||
return next(action);
|
||||
}
|
||||
return runtime(action);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
}();
|
||||
(window.wp = window.wp || {}).reduxRoutine = __webpack_exports__["default"];
|
||||
/******/ })()
|
||||
;
|
||||
+9
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user