first commit
This commit is contained in:
248
wp-includes/js/dist/a11y.js
vendored
Normal file
248
wp-includes/js/dist/a11y.js
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* binding */ setup),
|
||||
speak: () => (/* binding */ speak)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","domReady"]
|
||||
const 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"]
|
||||
const 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__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/a11y.min.js
vendored
Normal file
2
wp-includes/js/dist/a11y.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(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:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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,{setup:()=>d,speak:()=>p});const n=window.wp.domReady;var o=e.n(n);const i=window.wp.i18n;function a(e="polite"){const t=document.createElement("div");t.id=`a11y-speak-${e}`,t.className="a11y-speak-region",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("aria-live",e),t.setAttribute("aria-relevant","additions text"),t.setAttribute("aria-atomic","true");const{body:n}=document;return n&&n.appendChild(t),t}let r="";function d(){const e=document.getElementById("a11y-speak-intro-text"),t=document.getElementById("a11y-speak-assertive"),n=document.getElementById("a11y-speak-polite");null===e&&function(){const e=document.createElement("p");e.id="a11y-speak-intro-text",e.className="a11y-speak-intro-text",e.textContent=(0,i.__)("Notifications"),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("hidden","hidden");const{body:t}=document;t&&t.appendChild(e)}(),null===t&&a("assertive"),null===n&&a("polite")}function p(e,t){!function(){const e=document.getElementsByClassName("a11y-speak-region"),t=document.getElementById("a11y-speak-intro-text");for(let t=0;t<e.length;t++)e[t].textContent="";t&&t.setAttribute("hidden","hidden")}(),e=function(e){return e=e.replace(/<[^<>]+>/g," "),r===e&&(e+=" "),r=e,e}(e);const n=document.getElementById("a11y-speak-intro-text"),o=document.getElementById("a11y-speak-assertive"),i=document.getElementById("a11y-speak-polite");o&&"assertive"===t?o.textContent=e:i&&(i.textContent=e),n&&n.removeAttribute("hidden")}o()(d),(window.wp=window.wp||{}).a11y=t})();
|
||||
716
wp-includes/js/dist/annotations.js
vendored
Normal file
716
wp-includes/js/dist/annotations.js
vendored
Normal file
@@ -0,0 +1,716 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* reexport */ store)
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/selectors.js
|
||||
var selectors_namespaceObject = {};
|
||||
__webpack_require__.r(selectors_namespaceObject);
|
||||
__webpack_require__.d(selectors_namespaceObject, {
|
||||
__experimentalGetAllAnnotationsForBlock: () => (__experimentalGetAllAnnotationsForBlock),
|
||||
__experimentalGetAnnotations: () => (__experimentalGetAnnotations),
|
||||
__experimentalGetAnnotationsForBlock: () => (__experimentalGetAnnotationsForBlock),
|
||||
__experimentalGetAnnotationsForRichText: () => (__experimentalGetAnnotationsForRichText)
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/actions.js
|
||||
var actions_namespaceObject = {};
|
||||
__webpack_require__.r(actions_namespaceObject);
|
||||
__webpack_require__.d(actions_namespaceObject, {
|
||||
__experimentalAddAnnotation: () => (__experimentalAddAnnotation),
|
||||
__experimentalRemoveAnnotation: () => (__experimentalRemoveAnnotation),
|
||||
__experimentalRemoveAnnotationsBySource: () => (__experimentalRemoveAnnotationsBySource),
|
||||
__experimentalUpdateAnnotationRange: () => (__experimentalUpdateAnnotationRange)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","richText"]
|
||||
const external_wp_richText_namespaceObject = window["wp"]["richText"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/constants.js
|
||||
/**
|
||||
* The identifier for the data store.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const STORE_NAME = 'core/annotations';
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/format/annotation.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const FORMAT_NAME = 'core/annotation';
|
||||
const ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-';
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Applies given annotations to the given record.
|
||||
*
|
||||
* @param {Object} record The record to apply annotations to.
|
||||
* @param {Array} annotations The annotation to apply.
|
||||
* @return {Object} A record with the annotations applied.
|
||||
*/
|
||||
function applyAnnotations(record, annotations = []) {
|
||||
annotations.forEach(annotation => {
|
||||
let {
|
||||
start,
|
||||
end
|
||||
} = annotation;
|
||||
if (start > record.text.length) {
|
||||
start = record.text.length;
|
||||
}
|
||||
if (end > record.text.length) {
|
||||
end = record.text.length;
|
||||
}
|
||||
const className = ANNOTATION_ATTRIBUTE_PREFIX + annotation.source;
|
||||
const id = ANNOTATION_ATTRIBUTE_PREFIX + annotation.id;
|
||||
record = (0,external_wp_richText_namespaceObject.applyFormat)(record, {
|
||||
type: FORMAT_NAME,
|
||||
attributes: {
|
||||
className,
|
||||
id
|
||||
}
|
||||
}, start, end);
|
||||
});
|
||||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes annotations from the given record.
|
||||
*
|
||||
* @param {Object} record Record to remove annotations from.
|
||||
* @return {Object} The cleaned record.
|
||||
*/
|
||||
function removeAnnotations(record) {
|
||||
return removeFormat(record, 'core/annotation', 0, record.text.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the positions of annotations inside an array of formats.
|
||||
*
|
||||
* @param {Array} formats Formats with annotations in there.
|
||||
* @return {Object} ID keyed positions of annotations.
|
||||
*/
|
||||
function retrieveAnnotationPositions(formats) {
|
||||
const positions = {};
|
||||
formats.forEach((characterFormats, i) => {
|
||||
characterFormats = characterFormats || [];
|
||||
characterFormats = characterFormats.filter(format => format.type === FORMAT_NAME);
|
||||
characterFormats.forEach(format => {
|
||||
let {
|
||||
id
|
||||
} = format.attributes;
|
||||
id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, '');
|
||||
if (!positions.hasOwnProperty(id)) {
|
||||
positions[id] = {
|
||||
start: i
|
||||
};
|
||||
}
|
||||
|
||||
// Annotations refer to positions between characters.
|
||||
// Formats refer to the character themselves.
|
||||
// So we need to adjust for that here.
|
||||
positions[id].end = i + 1;
|
||||
});
|
||||
});
|
||||
return positions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates annotations in the state based on positions retrieved from RichText.
|
||||
*
|
||||
* @param {Array} annotations The annotations that are currently applied.
|
||||
* @param {Array} positions The current positions of the given annotations.
|
||||
* @param {Object} actions
|
||||
* @param {Function} actions.removeAnnotation Function to remove an annotation from the state.
|
||||
* @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state.
|
||||
*/
|
||||
function updateAnnotationsWithPositions(annotations, positions, {
|
||||
removeAnnotation,
|
||||
updateAnnotationRange
|
||||
}) {
|
||||
annotations.forEach(currentAnnotation => {
|
||||
const position = positions[currentAnnotation.id];
|
||||
// If we cannot find an annotation, delete it.
|
||||
if (!position) {
|
||||
// Apparently the annotation has been removed, so remove it from the state:
|
||||
// Remove...
|
||||
removeAnnotation(currentAnnotation.id);
|
||||
return;
|
||||
}
|
||||
const {
|
||||
start,
|
||||
end
|
||||
} = currentAnnotation;
|
||||
if (start !== position.start || end !== position.end) {
|
||||
updateAnnotationRange(currentAnnotation.id, position.start, position.end);
|
||||
}
|
||||
});
|
||||
}
|
||||
const annotation = {
|
||||
name: FORMAT_NAME,
|
||||
title: (0,external_wp_i18n_namespaceObject.__)('Annotation'),
|
||||
tagName: 'mark',
|
||||
className: 'annotation-text',
|
||||
attributes: {
|
||||
className: 'class',
|
||||
id: 'id'
|
||||
},
|
||||
edit() {
|
||||
return null;
|
||||
},
|
||||
__experimentalGetPropsForEditableTreePreparation(select, {
|
||||
richTextIdentifier,
|
||||
blockClientId
|
||||
}) {
|
||||
return {
|
||||
annotations: select(STORE_NAME).__experimentalGetAnnotationsForRichText(blockClientId, richTextIdentifier)
|
||||
};
|
||||
},
|
||||
__experimentalCreatePrepareEditableTree({
|
||||
annotations
|
||||
}) {
|
||||
return (formats, text) => {
|
||||
if (annotations.length === 0) {
|
||||
return formats;
|
||||
}
|
||||
let record = {
|
||||
formats,
|
||||
text
|
||||
};
|
||||
record = applyAnnotations(record, annotations);
|
||||
return record.formats;
|
||||
};
|
||||
},
|
||||
__experimentalGetPropsForEditableTreeChangeHandler(dispatch) {
|
||||
return {
|
||||
removeAnnotation: dispatch(STORE_NAME).__experimentalRemoveAnnotation,
|
||||
updateAnnotationRange: dispatch(STORE_NAME).__experimentalUpdateAnnotationRange
|
||||
};
|
||||
},
|
||||
__experimentalCreateOnChangeEditableValue(props) {
|
||||
return formats => {
|
||||
const positions = retrieveAnnotationPositions(formats);
|
||||
const {
|
||||
removeAnnotation,
|
||||
updateAnnotationRange,
|
||||
annotations
|
||||
} = props;
|
||||
updateAnnotationsWithPositions(annotations, positions, {
|
||||
removeAnnotation,
|
||||
updateAnnotationRange
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/format/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
name: format_name,
|
||||
...settings
|
||||
} = annotation;
|
||||
(0,external_wp_richText_namespaceObject.registerFormatType)(format_name, settings);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","hooks"]
|
||||
const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/block/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds annotation className to the block-list-block component.
|
||||
*
|
||||
* @param {Object} OriginalComponent The original BlockListBlock component.
|
||||
* @return {Object} The enhanced component.
|
||||
*/
|
||||
const addAnnotationClassName = OriginalComponent => {
|
||||
return (0,external_wp_data_namespaceObject.withSelect)((select, {
|
||||
clientId,
|
||||
className
|
||||
}) => {
|
||||
const annotations = select(STORE_NAME).__experimentalGetAnnotationsForBlock(clientId);
|
||||
return {
|
||||
className: annotations.map(annotation => {
|
||||
return 'is-annotated-by-' + annotation.source;
|
||||
}).concat(className).filter(Boolean).join(' ')
|
||||
};
|
||||
})(OriginalComponent);
|
||||
};
|
||||
(0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/annotations', addAnnotationClassName);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/reducer.js
|
||||
/**
|
||||
* Filters an array based on the predicate, but keeps the reference the same if
|
||||
* the array hasn't changed.
|
||||
*
|
||||
* @param {Array} collection The collection to filter.
|
||||
* @param {Function} predicate Function that determines if the item should stay
|
||||
* in the array.
|
||||
* @return {Array} Filtered array.
|
||||
*/
|
||||
function filterWithReference(collection, predicate) {
|
||||
const filteredCollection = collection.filter(predicate);
|
||||
return collection.length === filteredCollection.length ? collection : filteredCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new object with the same keys, but with `callback()` called as
|
||||
* a transformer function on each of the values.
|
||||
*
|
||||
* @param {Object} obj The object to transform.
|
||||
* @param {Function} callback The function to transform each object value.
|
||||
* @return {Array} Transformed object.
|
||||
*/
|
||||
const mapValues = (obj, callback) => Object.entries(obj).reduce((acc, [key, value]) => ({
|
||||
...acc,
|
||||
[key]: callback(value)
|
||||
}), {});
|
||||
|
||||
/**
|
||||
* Verifies whether the given annotations is a valid annotation.
|
||||
*
|
||||
* @param {Object} annotation The annotation to verify.
|
||||
* @return {boolean} Whether the given annotation is valid.
|
||||
*/
|
||||
function isValidAnnotationRange(annotation) {
|
||||
return typeof annotation.start === 'number' && typeof annotation.end === 'number' && annotation.start <= annotation.end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reducer managing annotations.
|
||||
*
|
||||
* @param {Object} state The annotations currently shown in the editor.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Array} Updated state.
|
||||
*/
|
||||
function annotations(state = {}, action) {
|
||||
var _state$blockClientId;
|
||||
switch (action.type) {
|
||||
case 'ANNOTATION_ADD':
|
||||
const blockClientId = action.blockClientId;
|
||||
const newAnnotation = {
|
||||
id: action.id,
|
||||
blockClientId,
|
||||
richTextIdentifier: action.richTextIdentifier,
|
||||
source: action.source,
|
||||
selector: action.selector,
|
||||
range: action.range
|
||||
};
|
||||
if (newAnnotation.selector === 'range' && !isValidAnnotationRange(newAnnotation.range)) {
|
||||
return state;
|
||||
}
|
||||
const previousAnnotationsForBlock = (_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : [];
|
||||
return {
|
||||
...state,
|
||||
[blockClientId]: [...previousAnnotationsForBlock, newAnnotation]
|
||||
};
|
||||
case 'ANNOTATION_REMOVE':
|
||||
return mapValues(state, annotationsForBlock => {
|
||||
return filterWithReference(annotationsForBlock, annotation => {
|
||||
return annotation.id !== action.annotationId;
|
||||
});
|
||||
});
|
||||
case 'ANNOTATION_UPDATE_RANGE':
|
||||
return mapValues(state, annotationsForBlock => {
|
||||
let hasChangedRange = false;
|
||||
const newAnnotations = annotationsForBlock.map(annotation => {
|
||||
if (annotation.id === action.annotationId) {
|
||||
hasChangedRange = true;
|
||||
return {
|
||||
...annotation,
|
||||
range: {
|
||||
start: action.start,
|
||||
end: action.end
|
||||
}
|
||||
};
|
||||
}
|
||||
return annotation;
|
||||
});
|
||||
return hasChangedRange ? newAnnotations : annotationsForBlock;
|
||||
});
|
||||
case 'ANNOTATION_REMOVE_SOURCE':
|
||||
return mapValues(state, annotationsForBlock => {
|
||||
return filterWithReference(annotationsForBlock, annotation => {
|
||||
return annotation.source !== action.source;
|
||||
});
|
||||
});
|
||||
}
|
||||
return state;
|
||||
}
|
||||
/* harmony default export */ const reducer = (annotations);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/selectors.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Shared reference to an empty array for cases where it is important to avoid
|
||||
* returning a new array reference on every invocation, as in a connected or
|
||||
* other pure component which performs `shouldComponentUpdate` check on props.
|
||||
* This should be used as a last resort, since the normalized data should be
|
||||
* maintained by the reducer result in state.
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
const EMPTY_ARRAY = [];
|
||||
|
||||
/**
|
||||
* Returns the annotations for a specific client ID.
|
||||
*
|
||||
* @param {Object} state Editor state.
|
||||
* @param {string} clientId The ID of the block to get the annotations for.
|
||||
*
|
||||
* @return {Array} The annotations applicable to this block.
|
||||
*/
|
||||
const __experimentalGetAnnotationsForBlock = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId) => {
|
||||
var _state$blockClientId;
|
||||
return ((_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => {
|
||||
return annotation.selector === 'block';
|
||||
});
|
||||
}, (state, blockClientId) => {
|
||||
var _state$blockClientId2;
|
||||
return [(_state$blockClientId2 = state?.[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY];
|
||||
});
|
||||
function __experimentalGetAllAnnotationsForBlock(state, blockClientId) {
|
||||
var _state$blockClientId3;
|
||||
return (_state$blockClientId3 = state?.[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the annotations that apply to the given RichText instance.
|
||||
*
|
||||
* Both a blockClientId and a richTextIdentifier are required. This is because
|
||||
* a block might have multiple `RichText` components. This does mean that every
|
||||
* block needs to implement annotations itself.
|
||||
*
|
||||
* @param {Object} state Editor state.
|
||||
* @param {string} blockClientId The client ID for the block.
|
||||
* @param {string} richTextIdentifier Unique identifier that identifies the given RichText.
|
||||
* @return {Array} All the annotations relevant for the `RichText`.
|
||||
*/
|
||||
const __experimentalGetAnnotationsForRichText = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId, richTextIdentifier) => {
|
||||
var _state$blockClientId4;
|
||||
return ((_state$blockClientId4 = state?.[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => {
|
||||
return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier;
|
||||
}).map(annotation => {
|
||||
const {
|
||||
range,
|
||||
...other
|
||||
} = annotation;
|
||||
return {
|
||||
...range,
|
||||
...other
|
||||
};
|
||||
});
|
||||
}, (state, blockClientId) => {
|
||||
var _state$blockClientId5;
|
||||
return [(_state$blockClientId5 = state?.[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY];
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns all annotations in the editor state.
|
||||
*
|
||||
* @param {Object} state Editor state.
|
||||
* @return {Array} All annotations currently applied.
|
||||
*/
|
||||
function __experimentalGetAnnotations(state) {
|
||||
return Object.values(state).flat();
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/native.js
|
||||
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
||||
/* harmony default export */ const esm_browser_native = ({
|
||||
randomUUID
|
||||
});
|
||||
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
|
||||
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
||||
// require the crypto API and do not support built-in fallback to lower quality random number
|
||||
// generators (like Math.random()).
|
||||
let getRandomValues;
|
||||
const rnds8 = new Uint8Array(16);
|
||||
function rng() {
|
||||
// lazy load so that environments that need to polyfill have a chance to do so
|
||||
if (!getRandomValues) {
|
||||
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
||||
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
||||
|
||||
if (!getRandomValues) {
|
||||
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
||||
}
|
||||
}
|
||||
|
||||
return getRandomValues(rnds8);
|
||||
}
|
||||
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
|
||||
|
||||
/**
|
||||
* Convert array of 16 byte values to UUID string format of the form:
|
||||
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
||||
*/
|
||||
|
||||
const byteToHex = [];
|
||||
|
||||
for (let i = 0; i < 256; ++i) {
|
||||
byteToHex.push((i + 0x100).toString(16).slice(1));
|
||||
}
|
||||
|
||||
function unsafeStringify(arr, offset = 0) {
|
||||
// Note: Be careful editing this code! It's been tuned for performance
|
||||
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
||||
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
||||
}
|
||||
|
||||
function stringify(arr, offset = 0) {
|
||||
const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
|
||||
// of the following:
|
||||
// - One or more input array values don't map to a hex octet (leading to
|
||||
// "undefined" in the uuid)
|
||||
// - Invalid input values for the RFC `version` or `variant` fields
|
||||
|
||||
if (!validate(uuid)) {
|
||||
throw TypeError('Stringified UUID is invalid');
|
||||
}
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify)));
|
||||
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
|
||||
|
||||
|
||||
|
||||
|
||||
function v4(options, buf, offset) {
|
||||
if (esm_browser_native.randomUUID && !buf && !options) {
|
||||
return esm_browser_native.randomUUID();
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
||||
|
||||
rnds[6] = rnds[6] & 0x0f | 0x40;
|
||||
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
||||
|
||||
if (buf) {
|
||||
offset = offset || 0;
|
||||
|
||||
for (let i = 0; i < 16; ++i) {
|
||||
buf[offset + i] = rnds[i];
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
return unsafeStringify(rnds);
|
||||
}
|
||||
|
||||
/* harmony default export */ const esm_browser_v4 = (v4);
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/actions.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef WPAnnotationRange
|
||||
*
|
||||
* @property {number} start The offset where the annotation should start.
|
||||
* @property {number} end The offset where the annotation should end.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds an annotation to a block.
|
||||
*
|
||||
* The `block` attribute refers to a block ID that needs to be annotated.
|
||||
* `isBlockAnnotation` controls whether or not the annotation is a block
|
||||
* annotation. The `source` is the source of the annotation, this will be used
|
||||
* to identity groups of annotations.
|
||||
*
|
||||
* The `range` property is only relevant if the selector is 'range'.
|
||||
*
|
||||
* @param {Object} annotation The annotation to add.
|
||||
* @param {string} annotation.blockClientId The blockClientId to add the annotation to.
|
||||
* @param {string} annotation.richTextIdentifier Identifier for the RichText instance the annotation applies to.
|
||||
* @param {WPAnnotationRange} annotation.range The range at which to apply this annotation.
|
||||
* @param {string} [annotation.selector="range"] The way to apply this annotation.
|
||||
* @param {string} [annotation.source="default"] The source that added the annotation.
|
||||
* @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function __experimentalAddAnnotation({
|
||||
blockClientId,
|
||||
richTextIdentifier = null,
|
||||
range = null,
|
||||
selector = 'range',
|
||||
source = 'default',
|
||||
id = esm_browser_v4()
|
||||
}) {
|
||||
const action = {
|
||||
type: 'ANNOTATION_ADD',
|
||||
id,
|
||||
blockClientId,
|
||||
richTextIdentifier,
|
||||
source,
|
||||
selector
|
||||
};
|
||||
if (selector === 'range') {
|
||||
action.range = range;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an annotation with a specific ID.
|
||||
*
|
||||
* @param {string} annotationId The annotation to remove.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function __experimentalRemoveAnnotation(annotationId) {
|
||||
return {
|
||||
type: 'ANNOTATION_REMOVE',
|
||||
annotationId
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the range of an annotation.
|
||||
*
|
||||
* @param {string} annotationId ID of the annotation to update.
|
||||
* @param {number} start The start of the new range.
|
||||
* @param {number} end The end of the new range.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function __experimentalUpdateAnnotationRange(annotationId, start, end) {
|
||||
return {
|
||||
type: 'ANNOTATION_UPDATE_RANGE',
|
||||
annotationId,
|
||||
start,
|
||||
end
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all annotations of a specific source.
|
||||
*
|
||||
* @param {string} source The source to remove.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function __experimentalRemoveAnnotationsBySource(source) {
|
||||
return {
|
||||
type: 'ANNOTATION_REMOVE_SOURCE',
|
||||
source
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Module Constants
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Store definition for the annotations 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,
|
||||
selectors: selectors_namespaceObject,
|
||||
actions: actions_namespaceObject
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).annotations = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/annotations.min.js
vendored
Normal file
2
wp-includes/js/dist/annotations.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
768
wp-includes/js/dist/api-fetch.js
vendored
Normal file
768
wp-includes/js/dist/api-fetch.js
vendored
Normal file
@@ -0,0 +1,768 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
"default": () => (/* binding */ build_module)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
const 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 */ const 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 */ const 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 */ const root_url = (createRootURLMiddleware);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","url"]
|
||||
const 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 */ const 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 */ const 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 */ const 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 */ const 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 */ const 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.
|
||||
*
|
||||
* If the REST API request URL has contained the `wp_theme_preview` parameter as `''`,
|
||||
* then bypass this middleware.
|
||||
*
|
||||
* @param {Record<string, any>} themePath
|
||||
* @return {import('../types').APIFetchMiddleware} Preloading middleware.
|
||||
*/
|
||||
const createThemePreviewMiddleware = themePath => (options, next) => {
|
||||
if (typeof options.url === 'string') {
|
||||
const wpThemePreview = (0,external_wp_url_namespaceObject.getQueryArg)(options.url, 'wp_theme_preview');
|
||||
if (wpThemePreview === undefined) {
|
||||
options.url = (0,external_wp_url_namespaceObject.addQueryArgs)(options.url, {
|
||||
wp_theme_preview: themePath
|
||||
});
|
||||
} else if (wpThemePreview === '') {
|
||||
options.url = (0,external_wp_url_namespaceObject.removeQueryArgs)(options.url, 'wp_theme_preview');
|
||||
}
|
||||
}
|
||||
if (typeof options.path === 'string') {
|
||||
const wpThemePreview = (0,external_wp_url_namespaceObject.getQueryArg)(options.path, 'wp_theme_preview');
|
||||
if (wpThemePreview === undefined) {
|
||||
options.path = (0,external_wp_url_namespaceObject.addQueryArgs)(options.path, {
|
||||
wp_theme_preview: themePath
|
||||
});
|
||||
} else if (wpThemePreview === '') {
|
||||
options.path = (0,external_wp_url_namespaceObject.removeQueryArgs)(options.path, 'wp_theme_preview');
|
||||
}
|
||||
}
|
||||
return next(options);
|
||||
};
|
||||
/* harmony default export */ const 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 */ const build_module = (apiFetch);
|
||||
|
||||
(window.wp = window.wp || {}).apiFetch = __webpack_exports__["default"];
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/api-fetch.min.js
vendored
Normal file
2
wp-includes/js/dist/api-fetch.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
469
wp-includes/js/dist/autop.js
vendored
Normal file
469
wp-includes/js/dist/autop.js
vendored
Normal file
@@ -0,0 +1,469 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* binding */ autop),
|
||||
/* harmony export */ removep: () => (/* 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__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/autop.min.js
vendored
Normal file
2
wp-includes/js/dist/autop.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
159
wp-includes/js/dist/blob.js
vendored
Normal file
159
wp-includes/js/dist/blob.js
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* binding */ createBlobURL),
|
||||
/* harmony export */ downloadBlob: () => (/* binding */ downloadBlob),
|
||||
/* harmony export */ getBlobByURL: () => (/* binding */ getBlobByURL),
|
||||
/* harmony export */ getBlobTypeByURL: () => (/* binding */ getBlobTypeByURL),
|
||||
/* harmony export */ isBlobURL: () => (/* binding */ isBlobURL),
|
||||
/* harmony export */ revokeBlobURL: () => (/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads a file, e.g., a text or readable stream, in the browser.
|
||||
* Appropriate for downloading smaller file sizes, e.g., < 5 MB.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const fileContent = JSON.stringify(
|
||||
* {
|
||||
* "title": "My Post",
|
||||
* },
|
||||
* null,
|
||||
* 2
|
||||
* );
|
||||
* const filename = 'file.json';
|
||||
*
|
||||
* downloadBlob( filename, fileContent, 'application/json' );
|
||||
* ```
|
||||
*
|
||||
* @param {string} filename File name.
|
||||
* @param {BlobPart} content File content (BufferSource | Blob | string).
|
||||
* @param {string} contentType (Optional) File mime type. Default is `''`.
|
||||
*/
|
||||
function downloadBlob(filename, content, contentType = '') {
|
||||
if (!filename || !content) {
|
||||
return;
|
||||
}
|
||||
const file = new window.Blob([content], {
|
||||
type: contentType
|
||||
});
|
||||
const url = window.URL.createObjectURL(file);
|
||||
const anchorElement = document.createElement('a');
|
||||
anchorElement.href = url;
|
||||
anchorElement.download = filename;
|
||||
anchorElement.style.display = 'none';
|
||||
document.body.appendChild(anchorElement);
|
||||
anchorElement.click();
|
||||
document.body.removeChild(anchorElement);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
(window.wp = window.wp || {}).blob = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/blob.min.js
vendored
Normal file
2
wp-includes/js/dist/blob.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(o,t)=>{for(var n in t)e.o(t,n)&&!e.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:t[n]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r: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,{createBlobURL:()=>n,downloadBlob:()=>c,getBlobByURL:()=>r,getBlobTypeByURL:()=>d,isBlobURL:()=>l,revokeBlobURL:()=>i});const t={};function n(e){const o=window.URL.createObjectURL(e);return t[o]=e,o}function r(e){return t[e]}function d(e){return r(e)?.type.split("/")[0]}function i(e){t[e]&&window.URL.revokeObjectURL(e),delete t[e]}function l(e){return!(!e||!e.indexOf)&&0===e.indexOf("blob:")}function c(e,o,t=""){if(!e||!o)return;const n=new window.Blob([o],{type:t}),r=window.URL.createObjectURL(n),d=document.createElement("a");d.href=r,d.download=e,d.style.display="none",document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(r)}(window.wp=window.wp||{}).blob=o})();
|
||||
2258
wp-includes/js/dist/block-directory.js
vendored
Normal file
2258
wp-includes/js/dist/block-directory.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/dist/block-directory.min.js
vendored
Normal file
2
wp-includes/js/dist/block-directory.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
71492
wp-includes/js/dist/block-editor.js
vendored
Normal file
71492
wp-includes/js/dist/block-editor.js
vendored
Normal file
File diff suppressed because one or more lines are too long
21
wp-includes/js/dist/block-editor.min.js
vendored
Normal file
21
wp-includes/js/dist/block-editor.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
63870
wp-includes/js/dist/block-library.js
vendored
Normal file
63870
wp-includes/js/dist/block-library.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
wp-includes/js/dist/block-library.min.js
vendored
Normal file
4
wp-includes/js/dist/block-library.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
485
wp-includes/js/dist/block-serialization-default-parser.js
vendored
Normal file
485
wp-includes/js/dist/block-serialization-default-parser.js
vendored
Normal file
@@ -0,0 +1,485 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* 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__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/block-serialization-default-parser.min.js
vendored
Normal file
2
wp-includes/js/dist/block-serialization-default-parser.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var n={d:(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},e={};let t,r,o,s;n.r(e),n.d(e,{parse:()=>i});const l=/<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/g;function u(n,e,t,r,o){return{blockName:n,attrs:e,innerBlocks:t,innerHTML:r,innerContent:o}}function c(n){return u(null,{},[],n,[n])}const i=n=>{t=n,r=0,o=[],s=[],l.lastIndex=0;do{}while(f());return o};function f(){const n=s.length,e=function(){const n=l.exec(t);if(null===n)return["no-more-tokens","",null,0,0];const e=n.index,[r,o,s,u,c,,i]=n,f=r.length,p=!!o,a=!!i,b=(s||"core/")+u,k=!!c,h=k?function(n){try{return JSON.parse(n)}catch(n){return null}}(c):{};if(a)return["void-block",b,h,e,f];if(p)return["block-closer",b,null,e,f];return["block-opener",b,h,e,f]}(),[i,f,k,h,d]=e,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<s.length;)b();return!1;case"void-block":return 0===n?(null!==g&&o.push(c(t.substr(g,h-g))),o.push(u(f,k,[],"",[])),r=h+d,!0):(a(u(f,k,[],"",[]),h,d),r=h+d,!0);case"block-opener":return s.push(function(n,e,t,r,o){return{block:n,tokenStart:e,tokenLength:t,prevOffset:r||e+t,leadingHtmlStart:o}}(u(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 e=s.pop(),l=t.substr(e.prevOffset,h-e.prevOffset);return e.block.innerHTML+=l,e.block.innerContent.push(l),e.prevOffset=h+d,a(e.block,e.tokenStart,e.tokenLength,h+d),r=h+d,!0;default:return p(),!1}}function p(n){const e=n||t.length-r;0!==e&&o.push(c(t.substr(r,e)))}function a(n,e,r,o){const l=s[s.length-1];l.block.innerBlocks.push(n);const u=t.substr(l.prevOffset,e-l.prevOffset);u&&(l.block.innerHTML+=u,l.block.innerContent.push(u)),l.block.innerContent.push(null),l.prevOffset=o||e+r}function b(n){const{block:e,leadingHtmlStart:r,prevOffset:l,tokenStart:u}=s.pop(),i=n?t.substr(l,n-l):t.substr(l);i&&(e.innerHTML+=i,e.innerContent.push(i)),null!==r&&o.push(c(t.substr(r,u-r))),o.push(e)}(window.wp=window.wp||{}).blockSerializationDefaultParser=e})();
|
||||
15533
wp-includes/js/dist/blocks.js
vendored
Normal file
15533
wp-includes/js/dist/blocks.js
vendored
Normal file
File diff suppressed because one or more lines are too long
19
wp-includes/js/dist/blocks.min.js
vendored
Normal file
19
wp-includes/js/dist/blocks.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4059
wp-includes/js/dist/commands.js
vendored
Normal file
4059
wp-includes/js/dist/commands.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
wp-includes/js/dist/commands.min.js
vendored
Normal file
2
wp-includes/js/dist/commands.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
74126
wp-includes/js/dist/components.js
vendored
Normal file
74126
wp-includes/js/dist/components.js
vendored
Normal file
File diff suppressed because one or more lines are too long
41
wp-includes/js/dist/components.min.js
vendored
Normal file
41
wp-includes/js/dist/components.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5957
wp-includes/js/dist/compose.js
vendored
Normal file
5957
wp-includes/js/dist/compose.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9
wp-includes/js/dist/compose.min.js
vendored
Normal file
9
wp-includes/js/dist/compose.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
627
wp-includes/js/dist/core-commands.js
vendored
Normal file
627
wp-includes/js/dist/core-commands.js
vendored
Normal file
@@ -0,0 +1,627 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* reexport */ privateApis)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","commands"]
|
||||
const external_wp_commands_namespaceObject = window["wp"]["commands"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: external ["wp","primitives"]
|
||||
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// CONCATENATED MODULE: external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const library_plus = (plus);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/admin-navigation-commands.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function useAdminNavigationCommands() {
|
||||
(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';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: external ["wp","coreData"]
|
||||
const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const post = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const library_post = (post);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"
|
||||
})]
|
||||
});
|
||||
/* harmony default export */ const library_page = (page);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const layout = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const library_layout = (layout);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol-filled.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const symbolFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const symbol_filled = (symbolFilled);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/navigation.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const navigation = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
viewBox: "0 0 24 24",
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const library_navigation = (navigation);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/styles.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const styles = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
viewBox: "0 0 24 24",
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const library_styles = (styles);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const library_symbol = (symbol);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","router"]
|
||||
const external_wp_router_namespaceObject = window["wp"]["router"];
|
||||
;// CONCATENATED MODULE: external ["wp","url"]
|
||||
const external_wp_url_namespaceObject = window["wp"]["url"];
|
||||
;// CONCATENATED MODULE: external ["wp","compose"]
|
||||
const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/hooks.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
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"]
|
||||
const 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 acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/core-commands');
|
||||
|
||||
;// 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
|
||||
} = unlock(external_wp_router_namespaceObject.privateApis);
|
||||
const icons = {
|
||||
post: library_post,
|
||||
page: library_page,
|
||||
wp_template: library_layout,
|
||||
wp_template_part: symbol_filled
|
||||
};
|
||||
function useDebouncedValue(value) {
|
||||
const [debouncedValue, setDebouncedValue] = (0,external_wp_element_namespaceObject.useState)('');
|
||||
const debounced = (0,external_wp_compose_namespaceObject.useDebounce)(setDebouncedValue, 250);
|
||||
(0,external_wp_element_namespaceObject.useEffect)(() => {
|
||||
debounced(value);
|
||||
return () => debounced.cancel();
|
||||
}, [debounced, value]);
|
||||
return debouncedValue;
|
||||
}
|
||||
const getNavigationCommandLoaderPerPostType = postType => function useNavigationCommandLoader({
|
||||
search
|
||||
}) {
|
||||
const history = useHistory();
|
||||
const isBlockBasedTheme = useIsBlockBasedTheme();
|
||||
const delayedSearch = useDebouncedValue(search);
|
||||
const {
|
||||
records,
|
||||
isLoading
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
if (!delayedSearch) {
|
||||
return {
|
||||
isLoading: false
|
||||
};
|
||||
}
|
||||
const query = {
|
||||
search: delayedSearch,
|
||||
per_page: 10,
|
||||
orderby: 'relevance',
|
||||
status: ['publish', 'future', 'draft', 'pending', 'private']
|
||||
};
|
||||
return {
|
||||
records: select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, query),
|
||||
isLoading: !select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecords', ['postType', postType, query])
|
||||
};
|
||||
}, [delayedSearch]);
|
||||
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');
|
||||
return {
|
||||
...command,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
postType,
|
||||
postId: record.id,
|
||||
canvas: 'edit'
|
||||
};
|
||||
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 = useHistory();
|
||||
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 [];
|
||||
}
|
||||
const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
|
||||
const result = [];
|
||||
result.push(...orderedRecords.map(record => {
|
||||
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,
|
||||
canvas: 'edit'
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = targetUrl;
|
||||
}
|
||||
close();
|
||||
}
|
||||
};
|
||||
}));
|
||||
if (orderedRecords?.length > 0 && templateType === 'wp_template_part') {
|
||||
result.push({
|
||||
name: 'core/edit-site/open-template-parts',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Template parts'),
|
||||
icon: symbol_filled,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
postType: 'wp_template_part',
|
||||
categoryId: 'all-parts'
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = targetUrl;
|
||||
}
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}, [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 = useHistory();
|
||||
const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
|
||||
const canCreateTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
return select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates');
|
||||
}, []);
|
||||
const isBlockBasedTheme = useIsBlockBasedTheme();
|
||||
const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
const result = [];
|
||||
if (canCreateTemplate && isBlockBasedTheme) {
|
||||
result.push({
|
||||
name: 'core/edit-site/open-navigation',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
|
||||
icon: library_navigation,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
const args = {
|
||||
postType: 'wp_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 = {
|
||||
postType: '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 = {
|
||||
postType: 'wp_template'
|
||||
};
|
||||
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-patterns',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Patterns'),
|
||||
icon: library_symbol,
|
||||
callback: ({
|
||||
close
|
||||
}) => {
|
||||
if (canCreateTemplate) {
|
||||
const args = {
|
||||
postType: 'wp_block'
|
||||
};
|
||||
const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
|
||||
if (isSiteEditor) {
|
||||
history.push(args);
|
||||
} else {
|
||||
document.location = targetUrl;
|
||||
}
|
||||
close();
|
||||
} else {
|
||||
// If a user cannot access the site editor
|
||||
document.location.href = 'edit.php?post_type=wp_block';
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}, [history, isSiteEditor, canCreateTemplate, 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
wp-includes/js/dist/core-commands.min.js
vendored
Normal file
2
wp-includes/js/dist/core-commands.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7951
wp-includes/js/dist/core-data.js
vendored
Normal file
7951
wp-includes/js/dist/core-data.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/dist/core-data.min.js
vendored
Normal file
2
wp-includes/js/dist/core-data.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2745
wp-includes/js/dist/customize-widgets.js
vendored
Normal file
2745
wp-includes/js/dist/customize-widgets.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/dist/customize-widgets.min.js
vendored
Normal file
2
wp-includes/js/dist/customize-widgets.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
217
wp-includes/js/dist/data-controls.js
vendored
Normal file
217
wp-includes/js/dist/data-controls.js
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* binding */ __unstableAwaitPromise),
|
||||
apiFetch: () => (/* binding */ apiFetch),
|
||||
controls: () => (/* binding */ controls),
|
||||
dispatch: () => (/* binding */ dispatch),
|
||||
select: () => (/* binding */ build_module_select),
|
||||
syncSelect: () => (/* binding */ syncSelect)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","apiFetch"]
|
||||
const 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"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: external ["wp","deprecated"]
|
||||
const 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
wp-includes/js/dist/data-controls.min.js
vendored
Normal file
2
wp-includes/js/dist/data-controls.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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,{__unstableAwaitPromise:()=>p,apiFetch:()=>i,controls:()=>u,dispatch:()=>d,select:()=>a,syncSelect:()=>l});const o=window.wp.apiFetch;var r=e.n(o);const n=window.wp.data,s=window.wp.deprecated;var c=e.n(s);function i(e){return{type:"API_FETCH",request:e}}function a(e,t,...o){return c()("`select` control in `@wordpress/data-controls`",{since:"5.7",alternative:"built-in `resolveSelect` control in `@wordpress/data`"}),n.controls.resolveSelect(e,t,...o)}function l(e,t,...o){return c()("`syncSelect` control in `@wordpress/data-controls`",{since:"5.7",alternative:"built-in `select` control in `@wordpress/data`"}),n.controls.select(e,t,...o)}function d(e,t,...o){return c()("`dispatch` control in `@wordpress/data-controls`",{since:"5.7",alternative:"built-in `dispatch` control in `@wordpress/data`"}),n.controls.dispatch(e,t,...o)}const p=function(e){return{type:"AWAIT_PROMISE",promise:e}},u={AWAIT_PROMISE:({promise:e})=>e,API_FETCH:({request:e})=>r()(e)};(window.wp=window.wp||{}).dataControls=t})();
|
||||
4844
wp-includes/js/dist/data.js
vendored
Normal file
4844
wp-includes/js/dist/data.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9
wp-includes/js/dist/data.min.js
vendored
Normal file
9
wp-includes/js/dist/data.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1780
wp-includes/js/dist/date.js
vendored
Normal file
1780
wp-includes/js/dist/date.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12
wp-includes/js/dist/date.min.js
vendored
Normal file
12
wp-includes/js/dist/date.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
123
wp-includes/js/dist/deprecated.js
vendored
Normal file
123
wp-includes/js/dist/deprecated.js
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
"default": () => (/* binding */ deprecated)
|
||||
});
|
||||
|
||||
// UNUSED EXPORTS: logged
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","hooks"]
|
||||
const 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
wp-includes/js/dist/deprecated.min.js
vendored
Normal file
2
wp-includes/js/dist/deprecated.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(n,o)=>{for(var t in o)e.o(o,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:o[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},n={};e.d(n,{default:()=>i});const o=window.wp.hooks,t=Object.create(null);function i(e,n={}){const{since:i,version:r,alternative:d,plugin:a,link:c,hint:s}=n,l=`${e} is deprecated${i?` since version ${i}`:""}${r?` and will be removed${a?` from ${a}`:""} in version ${r}`:""}.${d?` Please use ${d} instead.`:""}${c?` See: ${c}`:""}${s?` Note: ${s}`:""}`;l in t||((0,o.doAction)("deprecated",e,n,l),console.warn(l),t[l]=!0)}(window.wp=window.wp||{}).deprecated=n.default})();
|
||||
696
wp-includes/js/dist/development/react-refresh-entry.js
vendored
Normal file
696
wp-includes/js/dist/development/react-refresh-entry.js
vendored
Normal file
File diff suppressed because one or more lines are too long
696
wp-includes/js/dist/development/react-refresh-entry.min.js
vendored
Normal file
696
wp-includes/js/dist/development/react-refresh-entry.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
68
wp-includes/js/dist/development/react-refresh-runtime.js
vendored
Normal file
68
wp-includes/js/dist/development/react-refresh-runtime.js
vendored
Normal file
File diff suppressed because one or more lines are too long
68
wp-includes/js/dist/development/react-refresh-runtime.min.js
vendored
Normal file
68
wp-includes/js/dist/development/react-refresh-runtime.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
76
wp-includes/js/dist/dom-ready.js
vendored
Normal file
76
wp-includes/js/dist/dom-ready.js
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (/* 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
wp-includes/js/dist/dom-ready.min.js
vendored
Normal file
2
wp-includes/js/dist/dom-ready.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,d)=>{for(var o in d)e.o(d,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:d[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function d(e){"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}e.d(t,{default:()=>d}),(window.wp=window.wp||{}).domReady=t.default})();
|
||||
2014
wp-includes/js/dist/dom.js
vendored
Normal file
2014
wp-includes/js/dist/dom.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/dist/dom.min.js
vendored
Normal file
2
wp-includes/js/dist/dom.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3410
wp-includes/js/dist/edit-post.js
vendored
Normal file
3410
wp-includes/js/dist/edit-post.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/dist/edit-post.min.js
vendored
Normal file
2
wp-includes/js/dist/edit-post.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
40692
wp-includes/js/dist/edit-site.js
vendored
Normal file
40692
wp-includes/js/dist/edit-site.js
vendored
Normal file
File diff suppressed because one or more lines are too long
11
wp-includes/js/dist/edit-site.min.js
vendored
Normal file
11
wp-includes/js/dist/edit-site.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4984
wp-includes/js/dist/edit-widgets.js
vendored
Normal file
4984
wp-includes/js/dist/edit-widgets.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/dist/edit-widgets.min.js
vendored
Normal file
2
wp-includes/js/dist/edit-widgets.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
28193
wp-includes/js/dist/editor.js
vendored
Normal file
28193
wp-includes/js/dist/editor.js
vendored
Normal file
File diff suppressed because one or more lines are too long
14
wp-includes/js/dist/editor.min.js
vendored
Normal file
14
wp-includes/js/dist/editor.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1896
wp-includes/js/dist/element.js
vendored
Normal file
1896
wp-includes/js/dist/element.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9
wp-includes/js/dist/element.min.js
vendored
Normal file
9
wp-includes/js/dist/element.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
193
wp-includes/js/dist/escape-html.js
vendored
Normal file
193
wp-includes/js/dist/escape-html.js
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* binding */ escapeAmpersand),
|
||||
escapeAttribute: () => (/* binding */ escapeAttribute),
|
||||
escapeEditableHTML: () => (/* binding */ escapeEditableHTML),
|
||||
escapeHTML: () => (/* binding */ escapeHTML),
|
||||
escapeLessThan: () => (/* binding */ escapeLessThan),
|
||||
escapeQuotationMark: () => (/* binding */ escapeQuotationMark),
|
||||
isValidAttributeName: () => (/* 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
wp-includes/js/dist/escape-html.min.js
vendored
Normal file
2
wp-includes/js/dist/escape-html.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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,{escapeAmpersand:()=>n,escapeAttribute:()=>u,escapeEditableHTML:()=>i,escapeHTML:()=>c,escapeLessThan:()=>o,escapeQuotationMark:()=>a,isValidAttributeName:()=>p});const r=/[\u007F-\u009F "'>/="\uFDD0-\uFDEF]/;function n(e){return e.replace(/&(?!([a-z0-9]+|#[0-9]+|#x[a-f0-9]+);)/gi,"&")}function a(e){return e.replace(/"/g,""")}function o(e){return e.replace(/</g,"<")}function u(e){return function(e){return e.replace(/>/g,">")}(a(n(e)))}function c(e){return o(n(e))}function i(e){return o(e.replace(/&/g,"&"))}function p(e){return!r.test(e)}(window.wp=window.wp||{}).escapeHtml=t})();
|
||||
1995
wp-includes/js/dist/format-library.js
vendored
Normal file
1995
wp-includes/js/dist/format-library.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/dist/format-library.min.js
vendored
Normal file
2
wp-includes/js/dist/format-library.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
594
wp-includes/js/dist/hooks.js
vendored
Normal file
594
wp-includes/js/dist/hooks.js
vendored
Normal file
@@ -0,0 +1,594 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* binding */ actions),
|
||||
addAction: () => (/* binding */ addAction),
|
||||
addFilter: () => (/* binding */ addFilter),
|
||||
applyFilters: () => (/* binding */ applyFilters),
|
||||
createHooks: () => (/* reexport */ build_module_createHooks),
|
||||
currentAction: () => (/* binding */ currentAction),
|
||||
currentFilter: () => (/* binding */ currentFilter),
|
||||
defaultHooks: () => (/* binding */ defaultHooks),
|
||||
didAction: () => (/* binding */ didAction),
|
||||
didFilter: () => (/* binding */ didFilter),
|
||||
doAction: () => (/* binding */ doAction),
|
||||
doingAction: () => (/* binding */ doingAction),
|
||||
doingFilter: () => (/* binding */ doingFilter),
|
||||
filters: () => (/* binding */ filters),
|
||||
hasAction: () => (/* binding */ hasAction),
|
||||
hasFilter: () => (/* binding */ hasFilter),
|
||||
removeAction: () => (/* binding */ removeAction),
|
||||
removeAllActions: () => (/* binding */ removeAllActions),
|
||||
removeAllFilters: () => (/* binding */ removeAllFilters),
|
||||
removeFilter: () => (/* 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 */ const 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 */ const 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 */ const 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 */ const 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 */ const 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 */ const 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 */ const 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 */ const 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 */ const 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 */ const 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__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/hooks.min.js
vendored
Normal file
2
wp-includes/js/dist/hooks.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r: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,{actions:()=>S,addAction:()=>m,addFilter:()=>p,applyFilters:()=>k,createHooks:()=>h,currentAction:()=>w,currentFilter:()=>I,defaultHooks:()=>f,didAction:()=>O,didFilter:()=>j,doAction:()=>b,doingAction:()=>x,doingFilter:()=>T,filters:()=>z,hasAction:()=>v,hasFilter:()=>y,removeAction:()=>A,removeAllActions:()=>F,removeAllFilters:()=>g,removeFilter:()=>_});const n=function(t){return"string"!=typeof t||""===t?(console.error("The namespace must be a non-empty string."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(t)||(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)};const r=function(t){return"string"!=typeof t||""===t?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(t)?(console.error("The hook name cannot begin with `__`."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(t)||(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)};const o=function(t,e){return function(o,i,s,c=10){const l=t[e];if(!r(o))return;if(!n(i))return;if("function"!=typeof s)return void console.error("The hook callback must be a function.");if("number"!=typeof c)return void console.error("If specified, the hook priority must be a number.");const u={callback:s,priority:c,namespace:i};if(l[o]){const t=l[o].handlers;let e;for(e=t.length;e>0&&!(c>=t[e-1].priority);e--);e===t.length?t[e]=u:t.splice(e,0,u),l.__current.forEach((t=>{t.name===o&&t.currentIndex>=e&&t.currentIndex++}))}else l[o]={handlers:[u],runs:0};"hookAdded"!==o&&t.doAction("hookAdded",o,i,s,c)}};const i=function(t,e,o=!1){return function(i,s){const c=t[e];if(!r(i))return;if(!o&&!n(s))return;if(!c[i])return 0;let l=0;if(o)l=c[i].handlers.length,c[i]={runs:c[i].runs,handlers:[]};else{const t=c[i].handlers;for(let e=t.length-1;e>=0;e--)t[e].namespace===s&&(t.splice(e,1),l++,c.__current.forEach((t=>{t.name===i&&t.currentIndex>=e&&t.currentIndex--})))}return"hookRemoved"!==i&&t.doAction("hookRemoved",i,s),l}};const s=function(t,e){return function(n,r){const o=t[e];return void 0!==r?n in o&&o[n].handlers.some((t=>t.namespace===r)):n in o}};const c=function(t,e,n=!1){return function(r,...o){const i=t[e];i[r]||(i[r]={handlers:[],runs:0}),i[r].runs++;const s=i[r].handlers;if(!s||!s.length)return n?o[0]:void 0;const c={name:r,currentIndex:0};for(i.__current.push(c);c.currentIndex<s.length;){const t=s[c.currentIndex].callback.apply(null,o);n&&(o[0]=t),c.currentIndex++}return i.__current.pop(),n?o[0]:void 0}};const l=function(t,e){return function(){var n;const r=t[e];return null!==(n=r.__current[r.__current.length-1]?.name)&&void 0!==n?n:null}};const u=function(t,e){return function(n){const r=t[e];return void 0===n?void 0!==r.__current[0]:!!r.__current[0]&&n===r.__current[0].name}};const a=function(t,e){return function(n){const o=t[e];if(r(n))return o[n]&&o[n].runs?o[n].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=s(this,"actions"),this.hasFilter=s(this,"filters"),this.removeAllActions=i(this,"actions",!0),this.removeAllFilters=i(this,"filters",!0),this.doAction=c(this,"actions"),this.applyFilters=c(this,"filters",!0),this.currentAction=l(this,"actions"),this.currentFilter=l(this,"filters"),this.doingAction=u(this,"actions"),this.doingFilter=u(this,"filters"),this.didAction=a(this,"actions"),this.didFilter=a(this,"filters")}}const h=function(){return new d},f=h(),{addAction:m,addFilter:p,removeAction:A,removeFilter:_,hasAction:v,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}=f;(window.wp=window.wp||{}).hooks=e})();
|
||||
99
wp-includes/js/dist/html-entities.js
vendored
Normal file
99
wp-includes/js/dist/html-entities.js
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* 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
|
||||
* import { decodeEntities } from '@wordpress/html-entities';
|
||||
*
|
||||
* 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
wp-includes/js/dist/html-entities.min.js
vendored
Normal file
2
wp-includes/js/dist/html-entities.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(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:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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:()=>o}),(window.wp=window.wp||{}).htmlEntities=t})();
|
||||
1610
wp-includes/js/dist/i18n.js
vendored
Normal file
1610
wp-includes/js/dist/i18n.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/dist/i18n.min.js
vendored
Normal file
2
wp-includes/js/dist/i18n.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
wp-includes/js/dist/interactivity-router.asset.php
vendored
Normal file
1
wp-includes/js/dist/interactivity-router.asset.php
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '93ff47d0e70d75545606');
|
||||
337
wp-includes/js/dist/interactivity-router.js
vendored
Normal file
337
wp-includes/js/dist/interactivity-router.js
vendored
Normal file
@@ -0,0 +1,337 @@
|
||||
import * as __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__ from "@wordpress/interactivity";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
o: () => (/* binding */ actions),
|
||||
w: () => (/* binding */ state)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external "@wordpress/interactivity"
|
||||
var x = (y) => {
|
||||
var x = {}; __webpack_require__.d(x, y); return x
|
||||
}
|
||||
var y = (x) => (() => (x))
|
||||
const interactivity_namespaceObject = x({ ["getConfig"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getConfig), ["privateApis"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.privateApis), ["store"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store) });
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/interactivity-router/build-module/index.js
|
||||
var _getConfig$navigation;
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
directivePrefix,
|
||||
getRegionRootFragment,
|
||||
initialVdom,
|
||||
toVdom,
|
||||
render,
|
||||
parseInitialData,
|
||||
populateInitialData,
|
||||
batch
|
||||
} = (0,interactivity_namespaceObject.privateApis)('I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.');
|
||||
// Check if the navigation mode is full page or region based.
|
||||
const navigationMode = (_getConfig$navigation = (0,interactivity_namespaceObject.getConfig)('core/router').navigationMode) !== null && _getConfig$navigation !== void 0 ? _getConfig$navigation : 'regionBased';
|
||||
|
||||
// The cache of visited and prefetched pages, stylesheets and scripts.
|
||||
const pages = new Map();
|
||||
const headElements = new Map();
|
||||
|
||||
// Helper to remove domain and hash from the URL. We are only interesting in
|
||||
// caching the path and the query.
|
||||
const getPagePath = url => {
|
||||
const u = new URL(url, window.location.href);
|
||||
return u.pathname + u.search;
|
||||
};
|
||||
|
||||
// Fetch a new page and convert it to a static virtual DOM.
|
||||
const fetchPage = async (url, {
|
||||
html
|
||||
}) => {
|
||||
try {
|
||||
if (!html) {
|
||||
const res = await window.fetch(url);
|
||||
if (res.status !== 200) {
|
||||
return false;
|
||||
}
|
||||
html = await res.text();
|
||||
}
|
||||
const dom = new window.DOMParser().parseFromString(html, 'text/html');
|
||||
return regionsToVdom(dom);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Return an object with VDOM trees of those HTML regions marked with a
|
||||
// `router-region` directive.
|
||||
const regionsToVdom = async (dom, {
|
||||
vdom
|
||||
} = {}) => {
|
||||
const regions = {
|
||||
body: undefined
|
||||
};
|
||||
let head;
|
||||
if (false) {}
|
||||
if (navigationMode === 'regionBased') {
|
||||
const attrName = `data-${directivePrefix}-router-region`;
|
||||
dom.querySelectorAll(`[${attrName}]`).forEach(region => {
|
||||
const id = region.getAttribute(attrName);
|
||||
regions[id] = vdom?.has(region) ? vdom.get(region) : toVdom(region);
|
||||
});
|
||||
}
|
||||
const title = dom.querySelector('title')?.innerText;
|
||||
const initialData = parseInitialData(dom);
|
||||
return {
|
||||
regions,
|
||||
head,
|
||||
title,
|
||||
initialData
|
||||
};
|
||||
};
|
||||
|
||||
// Render all interactive regions contained in the given page.
|
||||
const renderRegions = page => {
|
||||
batch(() => {
|
||||
if (false) {}
|
||||
if (navigationMode === 'regionBased') {
|
||||
populateInitialData(page.initialData);
|
||||
const attrName = `data-${directivePrefix}-router-region`;
|
||||
document.querySelectorAll(`[${attrName}]`).forEach(region => {
|
||||
const id = region.getAttribute(attrName);
|
||||
const fragment = getRegionRootFragment(region);
|
||||
render(page.regions[id], fragment);
|
||||
});
|
||||
}
|
||||
if (page.title) {
|
||||
document.title = page.title;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Load the given page forcing a full page reload.
|
||||
*
|
||||
* The function returns a promise that won't resolve, useful to prevent any
|
||||
* potential feedback indicating that the navigation has finished while the new
|
||||
* page is being loaded.
|
||||
*
|
||||
* @param href The page href.
|
||||
* @return Promise that never resolves.
|
||||
*/
|
||||
const forcePageReload = href => {
|
||||
window.location.assign(href);
|
||||
return new Promise(() => {});
|
||||
};
|
||||
|
||||
// Listen to the back and forward buttons and restore the page if it's in the
|
||||
// cache.
|
||||
window.addEventListener('popstate', async () => {
|
||||
const pagePath = getPagePath(window.location.href); // Remove hash.
|
||||
const page = pages.has(pagePath) && (await pages.get(pagePath));
|
||||
if (page) {
|
||||
renderRegions(page);
|
||||
// Update the URL in the state.
|
||||
state.url = window.location.href;
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize the router and cache the initial page using the initial vDOM.
|
||||
// Once this code is tested and more mature, the head should be updated for
|
||||
// region based navigation as well.
|
||||
if (false) {}
|
||||
pages.set(getPagePath(window.location.href), Promise.resolve(regionsToVdom(document, {
|
||||
vdom: initialVdom
|
||||
})));
|
||||
|
||||
// Check if the link is valid for client-side navigation.
|
||||
const isValidLink = ref => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === '_self') && ref.origin === window.location.origin && !ref.pathname.startsWith('/wp-admin') && !ref.pathname.startsWith('/wp-login.php') && !ref.getAttribute('href').startsWith('#') && !new URL(ref.href).searchParams.has('_wpnonce');
|
||||
|
||||
// Check if the event is valid for client-side navigation.
|
||||
const isValidEvent = event => event && event.button === 0 &&
|
||||
// Left clicks only.
|
||||
!event.metaKey &&
|
||||
// Open in new tab (Mac).
|
||||
!event.ctrlKey &&
|
||||
// Open in new tab (Windows).
|
||||
!event.altKey &&
|
||||
// Download.
|
||||
!event.shiftKey && !event.defaultPrevented;
|
||||
|
||||
// Variable to store the current navigation.
|
||||
let navigatingTo = '';
|
||||
const {
|
||||
state,
|
||||
actions
|
||||
} = (0,interactivity_namespaceObject.store)('core/router', {
|
||||
state: {
|
||||
url: window.location.href,
|
||||
navigation: {
|
||||
hasStarted: false,
|
||||
hasFinished: false,
|
||||
texts: {
|
||||
loading: '',
|
||||
loaded: ''
|
||||
},
|
||||
message: ''
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
/**
|
||||
* Navigates to the specified page.
|
||||
*
|
||||
* This function normalizes the passed href, fetchs the page HTML if
|
||||
* needed, and updates any interactive regions whose contents have
|
||||
* changed. It also creates a new entry in the browser session history.
|
||||
*
|
||||
* @param href The page href.
|
||||
* @param [options] Options object.
|
||||
* @param [options.force] If true, it forces re-fetching the URL.
|
||||
* @param [options.html] HTML string to be used instead of fetching the requested URL.
|
||||
* @param [options.replace] If true, it replaces the current entry in the browser session history.
|
||||
* @param [options.timeout] Time until the navigation is aborted, in milliseconds. Default is 10000.
|
||||
* @param [options.loadingAnimation] Whether an animation should be shown while navigating. Default to `true`.
|
||||
* @param [options.screenReaderAnnouncement] Whether a message for screen readers should be announced while navigating. Default to `true`.
|
||||
*
|
||||
* @return Promise that resolves once the navigation is completed or aborted.
|
||||
*/
|
||||
*navigate(href, options = {}) {
|
||||
const {
|
||||
clientNavigationDisabled
|
||||
} = (0,interactivity_namespaceObject.getConfig)();
|
||||
if (clientNavigationDisabled) {
|
||||
yield forcePageReload(href);
|
||||
}
|
||||
const pagePath = getPagePath(href);
|
||||
const {
|
||||
navigation
|
||||
} = state;
|
||||
const {
|
||||
loadingAnimation = true,
|
||||
screenReaderAnnouncement = true,
|
||||
timeout = 10000
|
||||
} = options;
|
||||
navigatingTo = href;
|
||||
actions.prefetch(pagePath, options);
|
||||
|
||||
// Create a promise that resolves when the specified timeout ends.
|
||||
// The timeout value is 10 seconds by default.
|
||||
const timeoutPromise = new Promise(resolve => setTimeout(resolve, timeout));
|
||||
|
||||
// Don't update the navigation status immediately, wait 400 ms.
|
||||
const loadingTimeout = setTimeout(() => {
|
||||
if (navigatingTo !== href) {
|
||||
return;
|
||||
}
|
||||
if (loadingAnimation) {
|
||||
navigation.hasStarted = true;
|
||||
navigation.hasFinished = false;
|
||||
}
|
||||
if (screenReaderAnnouncement) {
|
||||
navigation.message = navigation.texts.loading;
|
||||
}
|
||||
}, 400);
|
||||
const page = yield Promise.race([pages.get(pagePath), timeoutPromise]);
|
||||
|
||||
// Dismiss loading message if it hasn't been added yet.
|
||||
clearTimeout(loadingTimeout);
|
||||
|
||||
// Once the page is fetched, the destination URL could have changed
|
||||
// (e.g., by clicking another link in the meantime). If so, bail
|
||||
// out, and let the newer execution to update the HTML.
|
||||
if (navigatingTo !== href) {
|
||||
return;
|
||||
}
|
||||
if (page && !page.initialData?.config?.['core/router']?.clientNavigationDisabled) {
|
||||
yield renderRegions(page);
|
||||
window.history[options.replace ? 'replaceState' : 'pushState']({}, '', href);
|
||||
|
||||
// Update the URL in the state.
|
||||
state.url = href;
|
||||
|
||||
// Update the navigation status once the the new page rendering
|
||||
// has been completed.
|
||||
if (loadingAnimation) {
|
||||
navigation.hasStarted = false;
|
||||
navigation.hasFinished = true;
|
||||
}
|
||||
if (screenReaderAnnouncement) {
|
||||
// Announce that the page has been loaded. If the message is the
|
||||
// same, we use a no-break space similar to the @wordpress/a11y
|
||||
// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
|
||||
navigation.message = navigation.texts.loaded + (navigation.message === navigation.texts.loaded ? '\u00A0' : '');
|
||||
}
|
||||
|
||||
// Scroll to the anchor if exits in the link.
|
||||
const {
|
||||
hash
|
||||
} = new URL(href, window.location.href);
|
||||
if (hash) {
|
||||
document.querySelector(hash)?.scrollIntoView();
|
||||
}
|
||||
} else {
|
||||
yield forcePageReload(href);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Prefetchs the page with the passed URL.
|
||||
*
|
||||
* The function normalizes the URL and stores internally the fetch
|
||||
* promise, to avoid triggering a second fetch for an ongoing request.
|
||||
*
|
||||
* @param url The page URL.
|
||||
* @param [options] Options object.
|
||||
* @param [options.force] Force fetching the URL again.
|
||||
* @param [options.html] HTML string to be used instead of fetching the requested URL.
|
||||
*/
|
||||
prefetch(url, options = {}) {
|
||||
const {
|
||||
clientNavigationDisabled
|
||||
} = (0,interactivity_namespaceObject.getConfig)();
|
||||
if (clientNavigationDisabled) {
|
||||
return;
|
||||
}
|
||||
const pagePath = getPagePath(url);
|
||||
if (options.force || !pages.has(pagePath)) {
|
||||
pages.set(pagePath, fetchPage(pagePath, {
|
||||
html: options.html
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add click and prefetch to all links.
|
||||
if (false) {}
|
||||
|
||||
var __webpack_exports__actions = __webpack_exports__.o;
|
||||
var __webpack_exports__state = __webpack_exports__.w;
|
||||
export { __webpack_exports__actions as actions, __webpack_exports__state as state };
|
||||
1
wp-includes/js/dist/interactivity-router.min.asset.php
vendored
Normal file
1
wp-includes/js/dist/interactivity-router.min.asset.php
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => 'cb44832cae5c937ebbc3');
|
||||
2
wp-includes/js/dist/interactivity-router.min.js
vendored
Normal file
2
wp-includes/js/dist/interactivity-router.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
import*as e from"@wordpress/interactivity";var t={d:(e,o)=>{for(var i in o)t.o(o,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:o[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},o={};t.d(o,{o:()=>x,w:()=>b});const i=(e=>{var o={};return t.d(o,e),o})({getConfig:()=>e.getConfig,privateApis:()=>e.privateApis,store:()=>e.store});var a;const{directivePrefix:n,getRegionRootFragment:r,initialVdom:s,toVdom:c,render:l,parseInitialData:d,populateInitialData:g,batch:w}=(0,i.privateApis)("I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress."),h=null!==(a=(0,i.getConfig)("core/router").navigationMode)&&void 0!==a?a:"regionBased",u=new Map,m=(new Map,e=>{const t=new URL(e,window.location.href);return t.pathname+t.search}),f=async(e,{vdom:t}={})=>{const o={body:void 0};if("regionBased"===h){const i=`data-${n}-router-region`;e.querySelectorAll(`[${i}]`).forEach((e=>{const a=e.getAttribute(i);o[a]=t?.has(e)?t.get(e):c(e)}))}const i=e.querySelector("title")?.innerText,a=d(e);return{regions:o,head:undefined,title:i,initialData:a}},p=e=>{w((()=>{if("regionBased"===h){g(e.initialData);const t=`data-${n}-router-region`;document.querySelectorAll(`[${t}]`).forEach((o=>{const i=o.getAttribute(t),a=r(o);l(e.regions[i],a)}))}e.title&&(document.title=e.title)}))},v=e=>(window.location.assign(e),new Promise((()=>{})));window.addEventListener("popstate",(async()=>{const e=m(window.location.href),t=u.has(e)&&await u.get(e);t?(p(t),b.url=window.location.href):window.location.reload()})),u.set(m(window.location.href),Promise.resolve(f(document,{vdom:s})));let y="";const{state:b,actions:x}=(0,i.store)("core/router",{state:{url:window.location.href,navigation:{hasStarted:!1,hasFinished:!1,texts:{loading:"",loaded:""},message:""}},actions:{*navigate(e,t={}){const{clientNavigationDisabled:o}=(0,i.getConfig)();o&&(yield v(e));const a=m(e),{navigation:n}=b,{loadingAnimation:r=!0,screenReaderAnnouncement:s=!0,timeout:c=1e4}=t;y=e,x.prefetch(a,t);const l=new Promise((e=>setTimeout(e,c))),d=setTimeout((()=>{y===e&&(r&&(n.hasStarted=!0,n.hasFinished=!1),s&&(n.message=n.texts.loading))}),400),g=yield Promise.race([u.get(a),l]);if(clearTimeout(d),y===e)if(g&&!g.initialData?.config?.["core/router"]?.clientNavigationDisabled){yield p(g),window.history[t.replace?"replaceState":"pushState"]({},"",e),b.url=e,r&&(n.hasStarted=!1,n.hasFinished=!0),s&&(n.message=n.texts.loaded+(n.message===n.texts.loaded?" ":""));const{hash:o}=new URL(e,window.location.href);o&&document.querySelector(o)?.scrollIntoView()}else yield v(e)},prefetch(e,t={}){const{clientNavigationDisabled:o}=(0,i.getConfig)();if(o)return;const a=m(e);!t.force&&u.has(a)||u.set(a,(async(e,{html:t})=>{try{if(!t){const o=await window.fetch(e);if(200!==o.status)return!1;t=await o.text()}const o=(new window.DOMParser).parseFromString(t,"text/html");return f(o)}catch(e){return!1}})(a,{html:t.html}))}}});var A=o.o,P=o.w;export{A as actions,P as state};
|
||||
1866
wp-includes/js/dist/interactivity.js
vendored
Normal file
1866
wp-includes/js/dist/interactivity.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
wp-includes/js/dist/interactivity.min.js
vendored
Normal file
2
wp-includes/js/dist/interactivity.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
142
wp-includes/js/dist/is-shallow-equal.js
vendored
Normal file
142
wp-includes/js/dist/is-shallow-equal.js
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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": () => (/* binding */ isShallowEqual),
|
||||
isShallowEqualArrays: () => (/* reexport */ isShallowEqualArrays),
|
||||
isShallowEqualObjects: () => (/* 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__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/is-shallow-equal.min.js
vendored
Normal file
2
wp-includes/js/dist/is-shallow-equal.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var r={d:(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},e={};function t(r,e){if(r===e)return!0;const t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;let o=0;for(;o<t.length;){const n=t[o],i=r[n];if(void 0===i&&!e.hasOwnProperty(n)||i!==e[n])return!1;o++}return!0}function n(r,e){if(r===e)return!0;if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function o(r,e){if(r&&e){if(r.constructor===Object&&e.constructor===Object)return t(r,e);if(Array.isArray(r)&&Array.isArray(e))return n(r,e)}return r===e}r.r(e),r.d(e,{default:()=>o,isShallowEqualArrays:()=>n,isShallowEqualObjects:()=>t}),(window.wp=window.wp||{}).isShallowEqual=e})();
|
||||
796
wp-includes/js/dist/keyboard-shortcuts.js
vendored
Normal file
796
wp-includes/js/dist/keyboard-shortcuts.js
vendored
Normal file
@@ -0,0 +1,796 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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__, {
|
||||
ShortcutProvider: () => (/* reexport */ ShortcutProvider),
|
||||
__unstableUseShortcutEventMatch: () => (/* reexport */ useShortcutEventMatch),
|
||||
store: () => (/* reexport */ store),
|
||||
useShortcut: () => (/* reexport */ useShortcut)
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
|
||||
var actions_namespaceObject = {};
|
||||
__webpack_require__.r(actions_namespaceObject);
|
||||
__webpack_require__.d(actions_namespaceObject, {
|
||||
registerShortcut: () => (registerShortcut),
|
||||
unregisterShortcut: () => (unregisterShortcut)
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
|
||||
var selectors_namespaceObject = {};
|
||||
__webpack_require__.r(selectors_namespaceObject);
|
||||
__webpack_require__.d(selectors_namespaceObject, {
|
||||
getAllShortcutKeyCombinations: () => (getAllShortcutKeyCombinations),
|
||||
getAllShortcutRawKeyCombinations: () => (getAllShortcutRawKeyCombinations),
|
||||
getCategoryShortcuts: () => (getCategoryShortcuts),
|
||||
getShortcutAliases: () => (getShortcutAliases),
|
||||
getShortcutDescription: () => (getShortcutDescription),
|
||||
getShortcutKeyCombination: () => (getShortcutKeyCombination),
|
||||
getShortcutRepresentation: () => (getShortcutRepresentation)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/reducer.js
|
||||
/**
|
||||
* Reducer returning the registered shortcuts
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
function reducer(state = {}, action) {
|
||||
switch (action.type) {
|
||||
case 'REGISTER_SHORTCUT':
|
||||
return {
|
||||
...state,
|
||||
[action.name]: {
|
||||
category: action.category,
|
||||
keyCombination: action.keyCombination,
|
||||
aliases: action.aliases,
|
||||
description: action.description
|
||||
}
|
||||
};
|
||||
case 'UNREGISTER_SHORTCUT':
|
||||
const {
|
||||
[action.name]: actionName,
|
||||
...remainingState
|
||||
} = state;
|
||||
return remainingState;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
/* harmony default export */ const store_reducer = (reducer);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
|
||||
/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */
|
||||
|
||||
/**
|
||||
* Keyboard key combination.
|
||||
*
|
||||
* @typedef {Object} WPShortcutKeyCombination
|
||||
*
|
||||
* @property {string} character Character.
|
||||
* @property {WPKeycodeModifier|undefined} modifier Modifier.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration of a registered keyboard shortcut.
|
||||
*
|
||||
* @typedef {Object} WPShortcutConfig
|
||||
*
|
||||
* @property {string} name Shortcut name.
|
||||
* @property {string} category Shortcut category.
|
||||
* @property {string} description Shortcut description.
|
||||
* @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.
|
||||
* @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns an action object used to register a new keyboard shortcut.
|
||||
*
|
||||
* @param {WPShortcutConfig} config Shortcut config.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { useEffect } from 'react';
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect, useDispatch } from '@wordpress/data';
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
||||
*
|
||||
* useEffect( () => {
|
||||
* registerShortcut( {
|
||||
* name: 'custom/my-custom-shortcut',
|
||||
* category: 'my-category',
|
||||
* description: __( 'My custom shortcut' ),
|
||||
* keyCombination: {
|
||||
* modifier: 'primary',
|
||||
* character: 'j',
|
||||
* },
|
||||
* } );
|
||||
* }, [] );
|
||||
*
|
||||
* const shortcut = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutKeyCombination(
|
||||
* 'custom/my-custom-shortcut'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return shortcut ? (
|
||||
* <p>{ __( 'Shortcut is registered.' ) }</p>
|
||||
* ) : (
|
||||
* <p>{ __( 'Shortcut is not registered.' ) }</p>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
* @return {Object} action.
|
||||
*/
|
||||
function registerShortcut({
|
||||
name,
|
||||
category,
|
||||
description,
|
||||
keyCombination,
|
||||
aliases
|
||||
}) {
|
||||
return {
|
||||
type: 'REGISTER_SHORTCUT',
|
||||
name,
|
||||
category,
|
||||
keyCombination,
|
||||
aliases,
|
||||
description
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used to unregister a keyboard shortcut.
|
||||
*
|
||||
* @param {string} name Shortcut name.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { useEffect } from 'react';
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect, useDispatch } from '@wordpress/data';
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );
|
||||
*
|
||||
* useEffect( () => {
|
||||
* unregisterShortcut( 'core/editor/next-region' );
|
||||
* }, [] );
|
||||
*
|
||||
* const shortcut = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutKeyCombination(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return shortcut ? (
|
||||
* <p>{ __( 'Shortcut is not unregistered.' ) }</p>
|
||||
* ) : (
|
||||
* <p>{ __( 'Shortcut is unregistered.' ) }</p>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
* @return {Object} action.
|
||||
*/
|
||||
function unregisterShortcut(name) {
|
||||
return {
|
||||
type: 'UNREGISTER_SHORTCUT',
|
||||
name
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","keycodes"]
|
||||
const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */
|
||||
|
||||
/** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */
|
||||
|
||||
/**
|
||||
* Shared reference to an empty array for cases where it is important to avoid
|
||||
* returning a new array reference on every invocation.
|
||||
*
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
const EMPTY_ARRAY = [];
|
||||
|
||||
/**
|
||||
* Shortcut formatting methods.
|
||||
*
|
||||
* @property {WPKeycodeHandlerByModifier} display Display formatting.
|
||||
* @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.
|
||||
* @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.
|
||||
*/
|
||||
const FORMATTING_METHODS = {
|
||||
display: external_wp_keycodes_namespaceObject.displayShortcut,
|
||||
raw: external_wp_keycodes_namespaceObject.rawShortcut,
|
||||
ariaLabel: external_wp_keycodes_namespaceObject.shortcutAriaLabel
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a string representing the key combination.
|
||||
*
|
||||
* @param {?WPShortcutKeyCombination} shortcut Key combination.
|
||||
* @param {keyof FORMATTING_METHODS} representation Type of representation
|
||||
* (display, raw, ariaLabel).
|
||||
*
|
||||
* @return {string?} Shortcut representation.
|
||||
*/
|
||||
function getKeyCombinationRepresentation(shortcut, representation) {
|
||||
if (!shortcut) {
|
||||
return null;
|
||||
}
|
||||
return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](shortcut.character) : shortcut.character;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the main key combination for a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { createInterpolateElement } from '@wordpress/element';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
* const ExampleComponent = () => {
|
||||
* const {character, modifier} = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutKeyCombination(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* { createInterpolateElement(
|
||||
* sprintf(
|
||||
* 'Character: <code>%s</code> / Modifier: <code>%s</code>',
|
||||
* character,
|
||||
* modifier
|
||||
* ),
|
||||
* {
|
||||
* code: <code />,
|
||||
* }
|
||||
* ) }
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {WPShortcutKeyCombination?} Key combination.
|
||||
*/
|
||||
function getShortcutKeyCombination(state, name) {
|
||||
return state[name] ? state[name].keyCombination : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the main key combination for a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
* @param {keyof FORMATTING_METHODS} representation Type of representation
|
||||
* (display, raw, ariaLabel).
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const {display, raw, ariaLabel} = useSelect(
|
||||
* ( select ) =>{
|
||||
* return {
|
||||
* display: select( keyboardShortcutsStore ).getShortcutRepresentation('core/editor/next-region' ),
|
||||
* raw: select( keyboardShortcutsStore ).getShortcutRepresentation('core/editor/next-region','raw' ),
|
||||
* ariaLabel: select( keyboardShortcutsStore ).getShortcutRepresentation('core/editor/next-region', 'ariaLabel')
|
||||
* }
|
||||
* },
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* <ul>
|
||||
* <li>{ sprintf( 'display string: %s', display ) }</li>
|
||||
* <li>{ sprintf( 'raw string: %s', raw ) }</li>
|
||||
* <li>{ sprintf( 'ariaLabel string: %s', ariaLabel ) }</li>
|
||||
* </ul>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {string?} Shortcut representation.
|
||||
*/
|
||||
function getShortcutRepresentation(state, name, representation = 'display') {
|
||||
const shortcut = getShortcutKeyCombination(state, name);
|
||||
return getKeyCombinationRepresentation(shortcut, representation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shortcut description given its name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* const ExampleComponent = () => {
|
||||
* const shortcutDescription = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutDescription( 'core/editor/next-region' ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return shortcutDescription ? (
|
||||
* <div>{ shortcutDescription }</div>
|
||||
* ) : (
|
||||
* <div>{ __( 'No description.' ) }</div>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
* @return {string?} Shortcut description.
|
||||
*/
|
||||
function getShortcutDescription(state, name) {
|
||||
return state[name] ? state[name].description : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the aliases for a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { createInterpolateElement } from '@wordpress/element';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
* const ExampleComponent = () => {
|
||||
* const shortcutAliases = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutAliases(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* shortcutAliases.length > 0 && (
|
||||
* <ul>
|
||||
* { shortcutAliases.map( ( { character, modifier }, index ) => (
|
||||
* <li key={ index }>
|
||||
* { createInterpolateElement(
|
||||
* sprintf(
|
||||
* 'Character: <code>%s</code> / Modifier: <code>%s</code>',
|
||||
* character,
|
||||
* modifier
|
||||
* ),
|
||||
* {
|
||||
* code: <code />,
|
||||
* }
|
||||
* ) }
|
||||
* </li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* )
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {WPShortcutKeyCombination[]} Key combinations.
|
||||
*/
|
||||
function getShortcutAliases(state, name) {
|
||||
return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shortcuts that include aliases for a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { createInterpolateElement } from '@wordpress/element';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const allShortcutKeyCombinations = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getAllShortcutKeyCombinations(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* allShortcutKeyCombinations.length > 0 && (
|
||||
* <ul>
|
||||
* { allShortcutKeyCombinations.map(
|
||||
* ( { character, modifier }, index ) => (
|
||||
* <li key={ index }>
|
||||
* { createInterpolateElement(
|
||||
* sprintf(
|
||||
* 'Character: <code>%s</code> / Modifier: <code>%s</code>',
|
||||
* character,
|
||||
* modifier
|
||||
* ),
|
||||
* {
|
||||
* code: <code />,
|
||||
* }
|
||||
* ) }
|
||||
* </li>
|
||||
* )
|
||||
* ) }
|
||||
* </ul>
|
||||
* )
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {WPShortcutKeyCombination[]} Key combinations.
|
||||
*/
|
||||
const getAllShortcutKeyCombinations = (0,external_wp_data_namespaceObject.createSelector)((state, name) => {
|
||||
return [getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)].filter(Boolean);
|
||||
}, (state, name) => [state[name]]);
|
||||
|
||||
/**
|
||||
* Returns the raw representation of all the keyboard combinations of a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { createInterpolateElement } from '@wordpress/element';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const allShortcutRawKeyCombinations = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* allShortcutRawKeyCombinations.length > 0 && (
|
||||
* <ul>
|
||||
* { allShortcutRawKeyCombinations.map(
|
||||
* ( shortcutRawKeyCombination, index ) => (
|
||||
* <li key={ index }>
|
||||
* { createInterpolateElement(
|
||||
* sprintf(
|
||||
* ' <code>%s</code>',
|
||||
* shortcutRawKeyCombination
|
||||
* ),
|
||||
* {
|
||||
* code: <code />,
|
||||
* }
|
||||
* ) }
|
||||
* </li>
|
||||
* )
|
||||
* ) }
|
||||
* </ul>
|
||||
* )
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {string[]} Shortcuts.
|
||||
*/
|
||||
const getAllShortcutRawKeyCombinations = (0,external_wp_data_namespaceObject.createSelector)((state, name) => {
|
||||
return getAllShortcutKeyCombinations(state, name).map(combination => getKeyCombinationRepresentation(combination, 'raw'));
|
||||
}, (state, name) => [state[name]]);
|
||||
|
||||
/**
|
||||
* Returns the shortcut names list for a given category name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Category name.
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const categoryShortcuts = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getCategoryShortcuts(
|
||||
* 'block'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* categoryShortcuts.length > 0 && (
|
||||
* <ul>
|
||||
* { categoryShortcuts.map( ( categoryShortcut ) => (
|
||||
* <li key={ categoryShortcut }>{ categoryShortcut }</li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* )
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
* @return {string[]} Shortcut names.
|
||||
*/
|
||||
const getCategoryShortcuts = (0,external_wp_data_namespaceObject.createSelector)((state, categoryName) => {
|
||||
return Object.entries(state).filter(([, shortcut]) => shortcut.category === categoryName).map(([name]) => name);
|
||||
}, state => [state]);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const STORE_NAME = 'core/keyboard-shortcuts';
|
||||
|
||||
/**
|
||||
* Store definition for the keyboard shortcuts 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: store_reducer,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut-event-match.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Returns a function to check if a keyboard event matches a shortcut name.
|
||||
*
|
||||
* @return {Function} A function to check if a keyboard event matches a
|
||||
* predefined shortcut combination.
|
||||
*/
|
||||
function useShortcutEventMatch() {
|
||||
const {
|
||||
getAllShortcutKeyCombinations
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(store);
|
||||
|
||||
/**
|
||||
* A function to check if a keyboard event matches a predefined shortcut
|
||||
* combination.
|
||||
*
|
||||
* @param {string} name Shortcut name.
|
||||
* @param {KeyboardEvent} event Event to check.
|
||||
*
|
||||
* @return {boolean} True if the event matches any shortcuts, false if not.
|
||||
*/
|
||||
function isMatch(name, event) {
|
||||
return getAllShortcutKeyCombinations(name).some(({
|
||||
modifier,
|
||||
character
|
||||
}) => {
|
||||
return external_wp_keycodes_namespaceObject.isKeyboardEvent[modifier](event, character);
|
||||
});
|
||||
}
|
||||
return isMatch;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/context.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const globalShortcuts = new Set();
|
||||
const globalListener = event => {
|
||||
for (const keyboardShortcut of globalShortcuts) {
|
||||
keyboardShortcut(event);
|
||||
}
|
||||
};
|
||||
const context = (0,external_wp_element_namespaceObject.createContext)({
|
||||
add: shortcut => {
|
||||
if (globalShortcuts.size === 0) {
|
||||
document.addEventListener('keydown', globalListener);
|
||||
}
|
||||
globalShortcuts.add(shortcut);
|
||||
},
|
||||
delete: shortcut => {
|
||||
globalShortcuts.delete(shortcut);
|
||||
if (globalShortcuts.size === 0) {
|
||||
document.removeEventListener('keydown', globalListener);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Attach a keyboard shortcut handler.
|
||||
*
|
||||
* @param {string} name Shortcut name.
|
||||
* @param {Function} callback Shortcut callback.
|
||||
* @param {Object} options Shortcut options.
|
||||
* @param {boolean} options.isDisabled Whether to disable to shortut.
|
||||
*/
|
||||
function useShortcut(name, callback, {
|
||||
isDisabled = false
|
||||
} = {}) {
|
||||
const shortcuts = (0,external_wp_element_namespaceObject.useContext)(context);
|
||||
const isMatch = useShortcutEventMatch();
|
||||
const callbackRef = (0,external_wp_element_namespaceObject.useRef)();
|
||||
(0,external_wp_element_namespaceObject.useEffect)(() => {
|
||||
callbackRef.current = callback;
|
||||
}, [callback]);
|
||||
(0,external_wp_element_namespaceObject.useEffect)(() => {
|
||||
if (isDisabled) {
|
||||
return;
|
||||
}
|
||||
function _callback(event) {
|
||||
if (isMatch(name, event)) {
|
||||
callbackRef.current(event);
|
||||
}
|
||||
}
|
||||
shortcuts.add(_callback);
|
||||
return () => {
|
||||
shortcuts.delete(_callback);
|
||||
};
|
||||
}, [name, isDisabled, shortcuts]);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/components/shortcut-provider.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
const {
|
||||
Provider
|
||||
} = context;
|
||||
|
||||
/**
|
||||
* Handles callbacks added to context by `useShortcut`.
|
||||
* Adding a provider allows to register contextual shortcuts
|
||||
* that are only active when a certain part of the UI is focused.
|
||||
*
|
||||
* @param {Object} props Props to pass to `div`.
|
||||
*
|
||||
* @return {Element} Component.
|
||||
*/
|
||||
function ShortcutProvider(props) {
|
||||
const [keyboardShortcuts] = (0,external_wp_element_namespaceObject.useState)(() => new Set());
|
||||
function onKeyDown(event) {
|
||||
if (props.onKeyDown) {
|
||||
props.onKeyDown(event);
|
||||
}
|
||||
for (const keyboardShortcut of keyboardShortcuts) {
|
||||
keyboardShortcut(event);
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Provider, {
|
||||
value: keyboardShortcuts,
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
|
||||
...props,
|
||||
onKeyDown: onKeyDown
|
||||
})
|
||||
});
|
||||
/* eslint-enable jsx-a11y/no-static-element-interactions */
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/index.js
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).keyboardShortcuts = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/keyboard-shortcuts.min.js
vendored
Normal file
2
wp-includes/js/dist/keyboard-shortcuts.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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:()=>K,__unstableUseShortcutEventMatch:()=>R,store:()=>h,useShortcut:()=>T});var o={};e.r(o),e.d(o,{registerShortcut:()=>c,unregisterShortcut:()=>a});var n={};e.r(n),e.d(n,{getAllShortcutKeyCombinations:()=>m,getAllShortcutRawKeyCombinations:()=>p,getCategoryShortcuts:()=>b,getShortcutAliases:()=>w,getShortcutDescription:()=>f,getShortcutKeyCombination:()=>y,getShortcutRepresentation:()=>S});const r=window.wp.data;const i=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]:o,...n}=e;return n}return e};function c({name:e,category:t,description:o,keyCombination:n,aliases:r}){return{type:"REGISTER_SHORTCUT",name:e,category:t,keyCombination:n,aliases:r,description:o}}function a(e){return{type:"UNREGISTER_SHORTCUT",name:e}}const s=window.wp.keycodes,u=[],d={display:s.displayShortcut,raw:s.rawShortcut,ariaLabel:s.shortcutAriaLabel};function l(e,t){return e?e.modifier?d[t][e.modifier](e.character):e.character:null}function y(e,t){return e[t]?e[t].keyCombination:null}function S(e,t,o="display"){return l(y(e,t),o)}function f(e,t){return e[t]?e[t].description:null}function w(e,t){return e[t]&&e[t].aliases?e[t].aliases:u}const m=(0,r.createSelector)(((e,t)=>[y(e,t),...w(e,t)].filter(Boolean)),((e,t)=>[e[t]])),p=(0,r.createSelector)(((e,t)=>m(e,t).map((e=>l(e,"raw")))),((e,t)=>[e[t]])),b=(0,r.createSelector)(((e,t)=>Object.entries(e).filter((([,e])=>e.category===t)).map((([e])=>e))),(e=>[e])),h=(0,r.createReduxStore)("core/keyboard-shortcuts",{reducer:i,actions:o,selectors:n});(0,r.register)(h);const g=window.wp.element;function R(){const{getAllShortcutKeyCombinations:e}=(0,r.useSelect)(h);return function(t,o){return e(t).some((({modifier:e,character:t})=>s.isKeyboardEvent[e](o,t)))}}const C=new Set,v=e=>{for(const t of C)t(e)},E=(0,g.createContext)({add:e=>{0===C.size&&document.addEventListener("keydown",v),C.add(e)},delete:e=>{C.delete(e),0===C.size&&document.removeEventListener("keydown",v)}});function T(e,t,{isDisabled:o=!1}={}){const n=(0,g.useContext)(E),r=R(),i=(0,g.useRef)();(0,g.useEffect)((()=>{i.current=t}),[t]),(0,g.useEffect)((()=>{if(!o)return n.add(t),()=>{n.delete(t)};function t(t){r(e,t)&&i.current(t)}}),[e,o,n])}const k=window.ReactJSXRuntime,{Provider:O}=E;function K(e){const[t]=(0,g.useState)((()=>new Set));return(0,k.jsx)(O,{value:t,children:(0,k.jsx)("div",{...e,onKeyDown:function(o){e.onKeyDown&&e.onKeyDown(o);for(const e of t)e(o)}})})}(window.wp=window.wp||{}).keyboardShortcuts=t})();
|
||||
466
wp-includes/js/dist/keycodes.js
vendored
Normal file
466
wp-includes/js/dist/keycodes.js
vendored
Normal file
@@ -0,0 +1,466 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* binding */ ALT),
|
||||
BACKSPACE: () => (/* binding */ BACKSPACE),
|
||||
COMMAND: () => (/* binding */ COMMAND),
|
||||
CTRL: () => (/* binding */ CTRL),
|
||||
DELETE: () => (/* binding */ DELETE),
|
||||
DOWN: () => (/* binding */ DOWN),
|
||||
END: () => (/* binding */ END),
|
||||
ENTER: () => (/* binding */ ENTER),
|
||||
ESCAPE: () => (/* binding */ ESCAPE),
|
||||
F10: () => (/* binding */ F10),
|
||||
HOME: () => (/* binding */ HOME),
|
||||
LEFT: () => (/* binding */ LEFT),
|
||||
PAGEDOWN: () => (/* binding */ PAGEDOWN),
|
||||
PAGEUP: () => (/* binding */ PAGEUP),
|
||||
RIGHT: () => (/* binding */ RIGHT),
|
||||
SHIFT: () => (/* binding */ SHIFT),
|
||||
SPACE: () => (/* binding */ SPACE),
|
||||
TAB: () => (/* binding */ TAB),
|
||||
UP: () => (/* binding */ UP),
|
||||
ZERO: () => (/* binding */ ZERO),
|
||||
displayShortcut: () => (/* binding */ displayShortcut),
|
||||
displayShortcutList: () => (/* binding */ displayShortcutList),
|
||||
isAppleOS: () => (/* reexport */ isAppleOS),
|
||||
isKeyboardEvent: () => (/* binding */ isKeyboardEvent),
|
||||
modifiers: () => (/* binding */ modifiers),
|
||||
rawShortcut: () => (/* binding */ rawShortcut),
|
||||
shortcutAriaLabel: () => (/* binding */ shortcutAriaLabel)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
const 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().
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* Capitalise the first character of a string.
|
||||
* @param {string} string String to capitalise.
|
||||
* @return {string} Capitalised string.
|
||||
*/
|
||||
function capitaliseFirstCharacter(string) {
|
||||
return string.length < 2 ? string.toUpperCase() : string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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[]} */[]);
|
||||
return [...modifierKeys, capitaliseFirstCharacter(character)];
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* 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 capitaliseFirstCharacter((_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
wp-includes/js/dist/keycodes.min.js
vendored
Normal file
2
wp-includes/js/dist/keycodes.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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,{ALT:()=>S,BACKSPACE:()=>n,COMMAND:()=>A,CTRL:()=>E,DELETE:()=>m,DOWN:()=>C,END:()=>u,ENTER:()=>l,ESCAPE:()=>a,F10:()=>w,HOME:()=>f,LEFT:()=>p,PAGEDOWN:()=>d,PAGEUP:()=>s,RIGHT:()=>h,SHIFT:()=>O,SPACE:()=>c,TAB:()=>i,UP:()=>y,ZERO:()=>P,displayShortcut:()=>_,displayShortcutList:()=>L,isAppleOS:()=>o,isKeyboardEvent:()=>k,modifiers:()=>T,rawShortcut:()=>v,shortcutAriaLabel:()=>j});const r=window.wp.i18n;function o(e=null){if(!e){if("undefined"==typeof window)return!1;e=window}const{platform:t}=e.navigator;return-1!==t.indexOf("Mac")||["iPad","iPhone"].includes(t)}const n=8,i=9,l=13,a=27,c=32,s=33,d=34,u=35,f=36,p=37,y=38,h=39,C=40,m=46,w=121,S="alt",E="ctrl",A="meta",O="shift",P=48;function b(e){return e.length<2?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)}function g(e,t){return Object.fromEntries(Object.entries(e).map((([e,r])=>[e,t(r)])))}const T={primary:e=>e()?[A]:[E],primaryShift:e=>e()?[O,A]:[E,O],primaryAlt:e=>e()?[S,A]:[E,S],secondary:e=>e()?[O,S,A]:[E,O,S],access:e=>e()?[E,S]:[O,S],ctrl:()=>[E],alt:()=>[S],ctrlShift:()=>[E,O],shift:()=>[O],shiftAlt:()=>[O,S],undefined:()=>[]},v=g(T,(e=>(t,r=o)=>[...e(r),t.toLowerCase()].join("+"))),L=g(T,(e=>(t,r=o)=>{const n=r(),i={[S]:n?"⌥":"Alt",[E]:n?"⌃":"Ctrl",[A]:"⌘",[O]:n?"⇧":"Shift"};return[...e(r).reduce(((e,t)=>{var r;const o=null!==(r=i[t])&&void 0!==r?r:t;return n?[...e,o]:[...e,o,"+"]}),[]),b(t)]})),_=g(L,(e=>(t,r=o)=>e(t,r).join(""))),j=g(T,(e=>(t,n=o)=>{const i=n(),l={[O]:"Shift",[A]:i?"Command":"Control",[E]:"Control",[S]:i?"Option":"Alt",",":(0,r.__)("Comma"),".":(0,r.__)("Period"),"`":(0,r.__)("Backtick"),"~":(0,r.__)("Tilde")};return[...e(n),t].map((e=>{var t;return b(null!==(t=l[e])&&void 0!==t?t:e)})).join(i?" ":" + ")}));const k=g(T,(e=>(t,r,n=o)=>{const i=e(n),l=function(e){return[S,E,A,O].filter((t=>e[`${t}Key`]))}(t),a={Comma:",",Backslash:"\\",IntlRo:"\\",IntlYen:"\\"},c=i.filter((e=>!l.includes(e))),s=l.filter((e=>!i.includes(e)));if(c.length>0||s.length>0)return!1;let d=t.key.toLowerCase();return r?(t.altKey&&1===r.length&&(d=String.fromCharCode(t.keyCode).toLowerCase()),t.shiftKey&&1===r.length&&a[t.code]&&(d=a[t.code]),"del"===r&&(r="delete"),d===r.toLowerCase()):i.includes(d)}));(window.wp=window.wp||{}).keycodes=t})();
|
||||
823
wp-includes/js/dist/list-reusable-blocks.js
vendored
Normal file
823
wp-includes/js/dist/list-reusable-blocks.js
vendored
Normal file
@@ -0,0 +1,823 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
const 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 */ const 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"]
|
||||
const 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"]
|
||||
const external_wp_blob_namespaceObject = window["wp"]["blob"];
|
||||
;// 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';
|
||||
(0,external_wp_blob_namespaceObject.downloadBlob)(fileName, fileContent, 'application/json');
|
||||
}
|
||||
/* harmony default export */ const utils_export = (exportReusableBlock);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","compose"]
|
||||
const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// CONCATENATED MODULE: external ["wp","components"]
|
||||
const external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js
|
||||
/**
|
||||
* 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/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 */ const utils_import = (importReusableBlock);
|
||||
|
||||
;// CONCATENATED MODULE: external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// 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 /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("form", {
|
||||
className: "list-reusable-blocks-import-form",
|
||||
onSubmit: onSubmit,
|
||||
ref: formRef,
|
||||
children: [error && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
|
||||
status: "error",
|
||||
onRemove: () => onDismissError(),
|
||||
children: error
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("label", {
|
||||
htmlFor: inputId,
|
||||
className: "list-reusable-blocks-import-form__label",
|
||||
children: (0,external_wp_i18n_namespaceObject.__)('File')
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
|
||||
id: inputId,
|
||||
type: "file",
|
||||
onChange: onChangeFile
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
|
||||
type: "submit",
|
||||
isBusy: isLoading,
|
||||
__experimentalIsFocusable: true,
|
||||
disabled: !file || isLoading,
|
||||
variant: "secondary",
|
||||
className: "list-reusable-blocks-import-form__button",
|
||||
children: (0,external_wp_i18n_namespaceObject._x)('Import', 'button label')
|
||||
})]
|
||||
});
|
||||
}
|
||||
/* harmony default export */ const 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 /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
|
||||
popoverProps: {
|
||||
placement: 'bottom-start'
|
||||
},
|
||||
contentClassName: "list-reusable-blocks-import-dropdown__content",
|
||||
renderToggle: ({
|
||||
isOpen,
|
||||
onToggle
|
||||
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
|
||||
"aria-expanded": isOpen,
|
||||
onClick: onToggle,
|
||||
variant: "primary",
|
||||
children: (0,external_wp_i18n_namespaceObject.__)('Import from JSON')
|
||||
}),
|
||||
renderContent: ({
|
||||
onClose
|
||||
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(import_form, {
|
||||
onUpload: (0,external_wp_compose_namespaceObject.pipe)(onClose, onUpload)
|
||||
})
|
||||
});
|
||||
}
|
||||
/* harmony default export */ const 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( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(import_dropdown, {
|
||||
onUpload: showNotice
|
||||
}));
|
||||
});
|
||||
|
||||
(window.wp = window.wp || {}).listReusableBlocks = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/list-reusable-blocks.min.js
vendored
Normal file
2
wp-includes/js/dist/list-reusable-blocks.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(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:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t);const n=window.wp.element,o=window.wp.i18n;var r=function(){return r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},r.apply(this,arguments)};Object.create;Object.create;"function"==typeof SuppressedError&&SuppressedError;function s(e){return e.toLowerCase()}var a=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],i=/[^A-Z0-9]+/gi;function l(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}function c(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var n=t.splitRegexp,o=void 0===n?a:n,r=t.stripRegexp,c=void 0===r?i:r,p=t.transform,d=void 0===p?s:p,u=t.delimiter,w=void 0===u?" ":u,f=l(l(e,o,"$1\0$2"),c,"\0"),m=0,b=f.length;"\0"===f.charAt(m);)m++;for(;"\0"===f.charAt(b-1);)b--;return f.slice(m,b).split("\0").map(d).join(w)}(e,r({delimiter:"."},t))}const p=window.wp.apiFetch;var d=e.n(p);const u=window.wp.blob;const w=async function(e){const t=await d()({path:"/wp/v2/types/wp_block"}),n=await d()({path:`/wp/v2/${t.rest_base}/${e}?context=edit`}),o=n.title.raw,s=n.content.raw,a=n.wp_pattern_sync_status,i=JSON.stringify({__file:"wp_block",title:o,content:s,syncStatus:a},null,2),l=(void 0===p&&(p={}),c(o,r({delimiter:"-"},p))+".json");var p;(0,u.downloadBlob)(l,i,"application/json")},f=window.wp.compose,m=window.wp.components;const b=async function(e){const t=await function(e){const t=new window.FileReader;return new Promise((n=>{t.onload=()=>{n(t.result)},t.readAsText(e)}))}(e);let n;try{n=JSON.parse(t)}catch(e){throw new Error("Invalid JSON file")}if("wp_block"!==n.__file||!n.title||!n.content||"string"!=typeof n.title||"string"!=typeof n.content||n.syncStatus&&"string"!=typeof n.syncStatus)throw new Error("Invalid pattern JSON file");const o=await d()({path:"/wp/v2/types/wp_block"});return await d()({path:`/wp/v2/${o.rest_base}`,data:{title:n.title,content:n.content,status:"publish",meta:"unsynced"===n.syncStatus?{wp_pattern_sync_status:n.syncStatus}:void 0},method:"POST"})},_=window.ReactJSXRuntime;const v=(0,f.withInstanceId)((function({instanceId:e,onUpload:t}){const r="list-reusable-blocks-import-form-"+e,s=(0,n.useRef)(),[a,i]=(0,n.useState)(!1),[l,c]=(0,n.useState)(null),[p,d]=(0,n.useState)(null);return(0,_.jsxs)("form",{className:"list-reusable-blocks-import-form",onSubmit:e=>{e.preventDefault(),p&&(i({isLoading:!0}),b(p).then((e=>{s&&(i(!1),t(e))})).catch((e=>{if(!s)return;let t;switch(e.message){case"Invalid JSON file":t=(0,o.__)("Invalid JSON file");break;case"Invalid pattern JSON file":t=(0,o.__)("Invalid pattern JSON file");break;default:t=(0,o.__)("Unknown error")}i(!1),c(t)})))},ref:s,children:[l&&(0,_.jsx)(m.Notice,{status:"error",onRemove:()=>{c(null)},children:l}),(0,_.jsx)("label",{htmlFor:r,className:"list-reusable-blocks-import-form__label",children:(0,o.__)("File")}),(0,_.jsx)("input",{id:r,type:"file",onChange:e=>{d(e.target.files[0]),c(null)}}),(0,_.jsx)(m.Button,{type:"submit",isBusy:a,__experimentalIsFocusable:!0,disabled:!p||a,variant:"secondary",className:"list-reusable-blocks-import-form__button",children:(0,o._x)("Import","button label")})]})}));const y=function({onUpload:e}){return(0,_.jsx)(m.Dropdown,{popoverProps:{placement:"bottom-start"},contentClassName:"list-reusable-blocks-import-dropdown__content",renderToggle:({isOpen:e,onToggle:t})=>(0,_.jsx)(m.Button,{"aria-expanded":e,onClick:t,variant:"primary",children:(0,o.__)("Import from JSON")}),renderContent:({onClose:t})=>(0,_.jsx)(v,{onUpload:(0,f.pipe)(t,e)})})};document.body.addEventListener("click",(e=>{e.target.classList.contains("wp-list-reusable-blocks__export")&&(e.preventDefault(),w(e.target.dataset.id))})),document.addEventListener("DOMContentLoaded",(()=>{const e=document.querySelector(".page-title-action");if(!e)return;const t=document.createElement("div");t.className="list-reusable-blocks__container",e.parentNode.insertBefore(t,e),(0,n.createRoot)(t).render((0,_.jsx)(y,{onUpload:()=>{const e=document.createElement("div");e.className="notice notice-success is-dismissible",e.innerHTML=`<p>${(0,o.__)("Pattern imported successfully!")}</p>`;const t=document.querySelector(".wp-header-end");t&&t.parentNode.insertBefore(e,t)}}))})),(window.wp=window.wp||{}).listReusableBlocks=t})();
|
||||
711
wp-includes/js/dist/media-utils.js
vendored
Normal file
711
wp-includes/js/dist/media-utils.js
vendored
Normal file
@@ -0,0 +1,711 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* reexport */ media_upload),
|
||||
uploadMedia: () => (/* reexport */ uploadMedia)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
const 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() {
|
||||
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);
|
||||
}
|
||||
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 {
|
||||
value: featuredImageId,
|
||||
multiple,
|
||||
allowedTypes
|
||||
} = this.props;
|
||||
const featuredImageFrame = getFeaturedImageMediaFrame();
|
||||
const attachments = getAttachmentsCollection(featuredImageId);
|
||||
const selection = new wp.media.model.Selection(attachments.models, {
|
||||
props: attachments.props.toJSON()
|
||||
});
|
||||
this.frame = new featuredImageFrame({
|
||||
mimeType: allowedTypes,
|
||||
state: 'featured-image',
|
||||
multiple,
|
||||
selection,
|
||||
editing: featuredImageId
|
||||
});
|
||||
wp.media.frame = this.frame;
|
||||
// In order to select the current featured image when opening
|
||||
// the media library we have to set the appropriate settings.
|
||||
// Currently they are set in php for the post editor, but
|
||||
// not for site editor.
|
||||
wp.media.view.settings.post = {
|
||||
...wp.media.view.settings.post,
|
||||
featuredImageId: featuredImageId || -1
|
||||
};
|
||||
}
|
||||
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() {
|
||||
const {
|
||||
allowedTypes,
|
||||
gallery = false,
|
||||
unstableFeaturedImageFlow = false,
|
||||
modalClass,
|
||||
multiple = false,
|
||||
title = (0,external_wp_i18n_namespaceObject.__)('Select or Upload Media')
|
||||
} = this.props;
|
||||
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();
|
||||
this.frame.open();
|
||||
}
|
||||
render() {
|
||||
return this.props.render({
|
||||
open: this.openModal
|
||||
});
|
||||
}
|
||||
}
|
||||
/* harmony default export */ const media_upload = (MediaUpload);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/index.js
|
||||
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","apiFetch"]
|
||||
const 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"]
|
||||
const 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
wp-includes/js/dist/media-utils.min.js
vendored
Normal file
2
wp-includes/js/dist/media-utils.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
674
wp-includes/js/dist/notices.js
vendored
Normal file
674
wp-includes/js/dist/notices.js
vendored
Normal file
@@ -0,0 +1,674 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* 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: () => (createErrorNotice),
|
||||
createInfoNotice: () => (createInfoNotice),
|
||||
createNotice: () => (createNotice),
|
||||
createSuccessNotice: () => (createSuccessNotice),
|
||||
createWarningNotice: () => (createWarningNotice),
|
||||
removeAllNotices: () => (removeAllNotices),
|
||||
removeNotice: () => (removeNotice),
|
||||
removeNotices: () => (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: () => (getNotices)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
const 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 */ const 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 */ const 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 React Element 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 { removeAllNotices } = 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
wp-includes/js/dist/notices.min.js
vendored
Normal file
2
wp-includes/js/dist/notices.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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:()=>b});var n={};e.r(n),e.d(n,{createErrorNotice:()=>E,createInfoNotice:()=>f,createNotice:()=>l,createSuccessNotice:()=>d,createWarningNotice:()=>p,removeAllNotices:()=>O,removeNotice:()=>y,removeNotices:()=>N});var i={};e.r(i),e.d(i,{getNotices:()=>_});const r=window.wp.data,o=e=>t=>(n={},i)=>{const r=i[e];if(void 0===r)return n;const o=t(n[r],i);return o===n[r]?n:{...n,[r]:o}},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})),s="global",u="info";let a=0;function l(e=u,t,n={}){const{speak:i=!0,isDismissible:r=!0,context:o=s,id:c=`${o}${++a}`,actions:l=[],type:d="default",__unstableHTML:f,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:i?t:null,__unstableHTML:f,isDismissible:r,actions:l,type:d,icon:E,explicitDismiss:p,onDismiss:y}}}function d(e,t){return l("success",e,t)}function f(e,t){return l("info",e,t)}function E(e,t){return l("error",e,t)}function p(e,t){return l("warning",e,t)}function y(e,t=s){return{type:"REMOVE_NOTICE",id:e,context:t}}function O(e="default",t=s){return{type:"REMOVE_ALL_NOTICES",noticeType:e,context:t}}function N(e,t=s){return{type:"REMOVE_NOTICES",ids:e,context:t}}const T=[];function _(e,t=s){return e[t]||T}const b=(0,r.createReduxStore)("core/notices",{reducer:c,actions:n,selectors:i});(0,r.register)(b),(window.wp=window.wp||{}).notices=t})();
|
||||
456
wp-includes/js/dist/nux.js
vendored
Normal file
456
wp-includes/js/dist/nux.js
vendored
Normal file
@@ -0,0 +1,456 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* reexport */ dot_tip),
|
||||
store: () => (/* 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: () => (disableTips),
|
||||
dismissTip: () => (dismissTip),
|
||||
enableTips: () => (enableTips),
|
||||
triggerGuide: () => (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: () => (selectors_areTipsEnabled),
|
||||
getAssociatedGuide: () => (getAssociatedGuide),
|
||||
isTipVisible: () => (isTipVisible)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","deprecated"]
|
||||
const 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"]
|
||||
const 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 */ const 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/@wordpress/nux/build-module/store/selectors.js
|
||||
/**
|
||||
* WordPress 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 = (0,external_wp_data_namespaceObject.createSelector)((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","compose"]
|
||||
const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// CONCATENATED MODULE: external ["wp","components"]
|
||||
const external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","primitives"]
|
||||
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// CONCATENATED MODULE: external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const close_close = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const 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 /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(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,
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
|
||||
children: children
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
|
||||
variant: "link",
|
||||
onClick: onDismiss,
|
||||
children: hasNextTip ? (0,external_wp_i18n_namespaceObject.__)('See next tip') : (0,external_wp_i18n_namespaceObject.__)('Got it')
|
||||
})
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const 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__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/nux.min.js
vendored
Normal file
2
wp-includes/js/dist/nux.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={n:i=>{var n=i&&i.__esModule?()=>i.default:()=>i;return e.d(n,{a:n}),n},d:(i,n)=>{for(var t in n)e.o(n,t)&&!e.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:n[t]})},o:(e,i)=>Object.prototype.hasOwnProperty.call(e,i),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},i={};e.r(i),e.d(i,{DotTip:()=>P,store:()=>I});var n={};e.r(n),e.d(n,{disableTips:()=>a,dismissTip:()=>u,enableTips:()=>l,triggerGuide:()=>p});var t={};e.r(t),e.d(t,{areTipsEnabled:()=>T,getAssociatedGuide:()=>w,isTipVisible:()=>f});const s=window.wp.deprecated;var r=e.n(s);const o=window.wp.data;const c=(0,o.combineReducers)({areTipsEnabled:function(e=!0,i){switch(i.type){case"DISABLE_TIPS":return!1;case"ENABLE_TIPS":return!0}return e},dismissedTips:function(e={},i){switch(i.type){case"DISMISS_TIP":return{...e,[i.id]:!0};case"ENABLE_TIPS":return{}}return e}}),d=(0,o.combineReducers)({guides:function(e=[],i){return"TRIGGER_GUIDE"===i.type?[...e,i.tipIds]:e},preferences:c});function p(e){return{type:"TRIGGER_GUIDE",tipIds:e}}function u(e){return{type:"DISMISS_TIP",id:e}}function a(){return{type:"DISABLE_TIPS"}}function l(){return{type:"ENABLE_TIPS"}}const w=(0,o.createSelector)(((e,i)=>{for(const n of e.guides)if(n.includes(i)){const i=n.filter((i=>!Object.keys(e.preferences.dismissedTips).includes(i))),[t=null,s=null]=i;return{tipIds:n,currentTipId:t,nextTipId:s}}return null}),(e=>[e.guides,e.preferences.dismissedTips]));function f(e,i){if(!e.preferences.areTipsEnabled)return!1;if(e.preferences.dismissedTips?.hasOwnProperty(i))return!1;const n=w(e,i);return!n||n.currentTipId===i}function T(e){return e.preferences.areTipsEnabled}const b="core/nux",I=(0,o.createReduxStore)(b,{reducer:d,actions:n,selectors:t,persist:["preferences"]});(0,o.registerStore)(b,{reducer:d,actions:n,selectors:t,persist:["preferences"]});const m=window.wp.compose,S=window.wp.components,_=window.wp.i18n,g=window.wp.element,h=window.wp.primitives,x=window.ReactJSXRuntime,y=(0,x.jsx)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,x.jsx)(h.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 E(e){e.stopPropagation()}const P=(0,m.compose)((0,o.withSelect)(((e,{tipId:i})=>{const{isTipVisible:n,getAssociatedGuide:t}=e(I),s=t(i);return{isVisible:n(i),hasNextTip:!(!s||!s.nextTipId)}})),(0,o.withDispatch)(((e,{tipId:i})=>{const{dismissTip:n,disableTips:t}=e(I);return{onDismiss(){n(i)},onDisable(){t()}}})))((function({position:e="middle right",children:i,isVisible:n,hasNextTip:t,onDismiss:s,onDisable:r}){const o=(0,g.useRef)(null),c=(0,g.useCallback)((e=>{o.current&&(o.current.contains(e.relatedTarget)||r())}),[r,o]);return n?(0,x.jsxs)(S.Popover,{className:"nux-dot-tip",position:e,focusOnMount:!0,role:"dialog","aria-label":(0,_.__)("Editor tips"),onClick:E,onFocusOutside:c,children:[(0,x.jsx)("p",{children:i}),(0,x.jsx)("p",{children:(0,x.jsx)(S.Button,{variant:"link",onClick:s,children:t?(0,_.__)("See next tip"):(0,_.__)("Got it")})}),(0,x.jsx)(S.Button,{className:"nux-dot-tip__disable",icon:y,label:(0,_.__)("Disable tips"),onClick:r})]}):null}));r()("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=i})();
|
||||
1748
wp-includes/js/dist/patterns.js
vendored
Normal file
1748
wp-includes/js/dist/patterns.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/dist/patterns.min.js
vendored
Normal file
2
wp-includes/js/dist/patterns.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
656
wp-includes/js/dist/plugins.js
vendored
Normal file
656
wp-includes/js/dist/plugins.js
vendored
Normal file
@@ -0,0 +1,656 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* reexport */ plugin_area),
|
||||
getPlugin: () => (/* reexport */ getPlugin),
|
||||
getPlugins: () => (/* reexport */ getPlugins),
|
||||
registerPlugin: () => (/* reexport */ registerPlugin),
|
||||
unregisterPlugin: () => (/* reexport */ unregisterPlugin),
|
||||
usePluginContext: () => (/* reexport */ usePluginContext),
|
||||
withPluginContext: () => (/* reexport */ withPluginContext)
|
||||
});
|
||||
|
||||
;// 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","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","hooks"]
|
||||
const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
|
||||
;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
|
||||
const 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"]
|
||||
const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// CONCATENATED MODULE: external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// 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 {Component} Enhanced component with injected context as props.
|
||||
*/
|
||||
const withPluginContext = mapContextToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => {
|
||||
return props => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Context.Consumer, {
|
||||
children: context => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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"]
|
||||
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plugins.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const plugins = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const library_plugins = (plugins);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/api/index.js
|
||||
/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Defined behavior of a plugin type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 = React.createElement;
|
||||
* var Fragment = wp.element.Fragment;
|
||||
* var PluginSidebar = wp.editor.PluginSidebar;
|
||||
* var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
|
||||
* var registerPlugin = wp.plugins.registerPlugin;
|
||||
* var moreIcon = React.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/editor';
|
||||
* 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 = React.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 {Component} 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, store.getValue);
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
|
||||
style: {
|
||||
display: 'none'
|
||||
},
|
||||
children: plugins.map(({
|
||||
icon,
|
||||
name,
|
||||
render: Plugin
|
||||
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginContextProvider, {
|
||||
value: getPluginContext(icon, name),
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginErrorBoundary, {
|
||||
name: name,
|
||||
onError: onError,
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Plugin, {})
|
||||
})
|
||||
}, name))
|
||||
});
|
||||
}
|
||||
/* harmony default export */ const 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
wp-includes/js/dist/plugins.min.js
vendored
Normal file
2
wp-includes/js/dist/plugins.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={n:n=>{var r=n&&n.__esModule?()=>n.default:()=>n;return e.d(r,{a:r}),r},d:(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:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r: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:()=>P,getPlugin:()=>w,getPlugins:()=>x,registerPlugin:()=>h,unregisterPlugin:()=>f,usePluginContext:()=>c,withPluginContext:()=>p});const r=window.wp.element,t=window.wp.hooks,o=window.wp.isShallowEqual;var i=e.n(o);const l=window.wp.compose,s=window.ReactJSXRuntime,u=(0,r.createContext)({name:null,icon:null}),a=u.Provider;function c(){return(0,r.useContext)(u)}const p=e=>(0,l.createHigherOrderComponent)((n=>r=>(0,s.jsx)(u.Consumer,{children:t=>(0,s.jsx)(n,{...r,...e(t,r)})})),"withPluginContext");class g 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}}const d=window.wp.primitives,v=(0,s.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,s.jsx)(d.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"})}),m={};function h(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;m[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 m[e]={name:e,icon:v,...n},(0,t.doAction)("plugins.pluginRegistered",n,e),n}function f(e){if(!m[e])return void console.error('Plugin "'+e+'" is not registered.');const n=m[e];return delete m[e],(0,t.doAction)("plugins.pluginUnregistered",n,e),n}function w(e){return m[e]}function x(e){return Object.values(m).filter((n=>n.scope===e))}const y=function(e,n){var r,t,o=0;function i(){var i,l,s=r,u=arguments.length;e:for(;s;){if(s.args.length===arguments.length){for(l=0;l<u;l++)if(s.args[l]!==arguments[l]){s=s.next;continue e}return s!==r&&(s===t&&(t=s.prev),s.prev.next=s.next,s.next&&(s.next.prev=s.prev),s.next=r,s.prev=null,r.prev=s,r=s),s.val}s=s.next}for(i=new Array(u),l=0;l<u;l++)i[l]=arguments[l];return s={args:i,val:e.apply(null,i)},r?(r.prev=s,s.next=r):t=s,o===n.maxSize?(t=t.prev).next=null:o++,r=s,s.val}return n=n||{},i.clear=function(){r=null,t=null,o=0},i}(((e,n)=>({icon:e,name:n})));const P=function({scope:e,onError:n}){const o=(0,r.useMemo)((()=>{let n=[];return{subscribe:e=>((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=x(e);return i()(n,r)||(n=r),n}}}),[e]),l=(0,r.useSyncExternalStore)(o.subscribe,o.getValue,o.getValue);return(0,s.jsx)("div",{style:{display:"none"},children:l.map((({icon:e,name:r,render:t})=>(0,s.jsx)(a,{value:y(e,r),children:(0,s.jsx)(g,{name:r,onError:n,children:(0,s.jsx)(t,{})})},r)))})};(window.wp=window.wp||{}).plugins=n})();
|
||||
898
wp-includes/js/dist/preferences-persistence.js
vendored
Normal file
898
wp-includes/js/dist/preferences-persistence.js
vendored
Normal file
@@ -0,0 +1,898 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* binding */ __unstableCreatePersistenceLayer),
|
||||
create: () => (/* reexport */ create)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","apiFetch"]
|
||||
const 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'
|
||||
}, 'panels', convertEditPostPanels);
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/editor',
|
||||
to: 'core'
|
||||
}, 'isPublishSidebarEnabled');
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-post',
|
||||
to: 'core'
|
||||
}, '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/convert-editor-settings.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
function convertEditorSettings(data) {
|
||||
var _newData$coreEditPo, _newData$coreEditSi;
|
||||
let newData = data;
|
||||
const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', 'isPublishSidebarEnabled', 'isComplementaryAreaVisible', 'pinnedItems'];
|
||||
settingsToMoveToCore.forEach(setting => {
|
||||
if (data?.['core/edit-post']?.[setting] !== undefined) {
|
||||
newData = {
|
||||
...newData,
|
||||
core: {
|
||||
...newData?.core,
|
||||
[setting]: data['core/edit-post'][setting]
|
||||
}
|
||||
};
|
||||
delete newData['core/edit-post'][setting];
|
||||
}
|
||||
if (data?.['core/edit-site']?.[setting] !== undefined) {
|
||||
delete newData['core/edit-site'][setting];
|
||||
}
|
||||
});
|
||||
if (Object.keys((_newData$coreEditPo = newData?.['core/edit-post']) !== null && _newData$coreEditPo !== void 0 ? _newData$coreEditPo : {})?.length === 0) {
|
||||
delete newData['core/edit-post'];
|
||||
}
|
||||
if (Object.keys((_newData$coreEditSi = newData?.['core/edit-site']) !== null && _newData$coreEditSi !== void 0 ? _newData$coreEditSi : {})?.length === 0) {
|
||||
delete newData['core/edit-site'];
|
||||
}
|
||||
return newData;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
function convertPreferencesPackageData(data) {
|
||||
let newData = convertComplementaryAreas(data);
|
||||
newData = convertEditorSettings(newData);
|
||||
return newData;
|
||||
}
|
||||
|
||||
;// 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__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/preferences-persistence.min.js
vendored
Normal file
2
wp-includes/js/dist/preferences-persistence.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
775
wp-includes/js/dist/preferences.js
vendored
Normal file
775
wp-includes/js/dist/preferences.js
vendored
Normal file
@@ -0,0 +1,775 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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: () => (/* reexport */ PreferenceToggleMenuItem),
|
||||
privateApis: () => (/* reexport */ privateApis),
|
||||
store: () => (/* 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: () => (set),
|
||||
setDefaults: () => (setDefaults),
|
||||
setPersistenceLayer: () => (setPersistenceLayer),
|
||||
toggle: () => (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: () => (get)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: external ["wp","components"]
|
||||
const external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// CONCATENATED MODULE: external ["wp","i18n"]
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// CONCATENATED MODULE: external ["wp","primitives"]
|
||||
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// CONCATENATED MODULE: external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const check = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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 */ const library_check = (check);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","a11y"]
|
||||
const 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 */ const 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: external ["wp","deprecated"]
|
||||
const 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/preferences/build-module/store/selectors.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const withDeprecatedKeys = originalGet => (state, scope, name) => {
|
||||
const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', 'isPublishSidebarEnabled', 'isComplementaryAreaVisible', 'pinnedItems'];
|
||||
if (settingsToMoveToCore.includes(name) && ['core/edit-post', 'core/edit-site'].includes(scope)) {
|
||||
external_wp_deprecated_default()(`wp.data.select( 'core/preferences' ).get( '${scope}', '${name}' )`, {
|
||||
since: '6.5',
|
||||
alternative: `wp.data.select( 'core/preferences' ).get( 'core', '${name}' )`
|
||||
});
|
||||
return originalGet(state, 'core', name);
|
||||
}
|
||||
return originalGet(state, scope, name);
|
||||
};
|
||||
|
||||
/**
|
||||
* 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?
|
||||
*/
|
||||
const get = withDeprecatedKeys((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 preferences 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,
|
||||
handleToggling = true,
|
||||
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 /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
|
||||
icon: isActive && library_check,
|
||||
isSelected: isActive,
|
||||
onClick: () => {
|
||||
onToggle();
|
||||
if (handleToggling) {
|
||||
toggle(scope, name);
|
||||
}
|
||||
speakMessage();
|
||||
},
|
||||
role: "menuitemcheckbox",
|
||||
info: info,
|
||||
shortcut: shortcut,
|
||||
disabled: disabled,
|
||||
children: label
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/index.js
|
||||
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/preference-base-option/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function BaseOption({
|
||||
help,
|
||||
label,
|
||||
isChecked,
|
||||
onChange,
|
||||
children
|
||||
}) {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
|
||||
className: "preference-base-option",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, {
|
||||
__nextHasNoMarginBottom: true,
|
||||
help: help,
|
||||
label: label,
|
||||
checked: isChecked,
|
||||
onChange: onChange
|
||||
}), children]
|
||||
});
|
||||
}
|
||||
/* harmony default export */ const preference_base_option = (BaseOption);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/preference-toggle-control/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function PreferenceToggleControl(props) {
|
||||
const {
|
||||
scope,
|
||||
featureName,
|
||||
onToggle = () => {},
|
||||
...remainingProps
|
||||
} = props;
|
||||
const isChecked = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).get(scope, featureName), [scope, featureName]);
|
||||
const {
|
||||
toggle
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
const onChange = () => {
|
||||
onToggle();
|
||||
toggle(scope, featureName);
|
||||
};
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(preference_base_option, {
|
||||
onChange: onChange,
|
||||
isChecked: isChecked,
|
||||
...remainingProps
|
||||
});
|
||||
}
|
||||
/* harmony default export */ const preference_toggle_control = (PreferenceToggleControl);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/preferences-modal/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function PreferencesModal({
|
||||
closeModal,
|
||||
children
|
||||
}) {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
|
||||
className: "preferences-modal",
|
||||
title: (0,external_wp_i18n_namespaceObject.__)('Preferences'),
|
||||
onRequestClose: closeModal,
|
||||
children: children
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/preferences-modal-section/index.js
|
||||
|
||||
|
||||
const Section = ({
|
||||
description,
|
||||
title,
|
||||
children
|
||||
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
|
||||
className: "preferences-modal__section",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("legend", {
|
||||
className: "preferences-modal__section-legend",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
|
||||
className: "preferences-modal__section-title",
|
||||
children: title
|
||||
}), description && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
|
||||
className: "preferences-modal__section-description",
|
||||
children: description
|
||||
})]
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
|
||||
className: "preferences-modal__section-content",
|
||||
children: children
|
||||
})]
|
||||
});
|
||||
/* harmony default export */ const preferences_modal_section = (Section);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","compose"]
|
||||
const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
|
||||
|
||||
/**
|
||||
* Return an SVG icon.
|
||||
*
|
||||
* @param {IconProps} props icon is the SVG component to render
|
||||
* size is a number specifiying the icon size in pixels
|
||||
* Other props will be passed to wrapped SVG component
|
||||
* @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
|
||||
*
|
||||
* @return {JSX.Element} Icon component
|
||||
*/
|
||||
function Icon({
|
||||
icon,
|
||||
size = 24,
|
||||
...props
|
||||
}, ref) {
|
||||
return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
|
||||
width: size,
|
||||
height: size,
|
||||
...props,
|
||||
ref
|
||||
});
|
||||
}
|
||||
/* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const chevronLeft = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const chevron_left = (chevronLeft);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const chevronRight = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const chevron_right = (chevronRight);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","privateApis"]
|
||||
const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/lock-unlock.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
lock,
|
||||
unlock
|
||||
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/preferences');
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/preferences-modal-tabs/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const {
|
||||
Tabs
|
||||
} = unlock(external_wp_components_namespaceObject.privateApis);
|
||||
const PREFERENCES_MENU = 'preferences-menu';
|
||||
function PreferencesModalTabs({
|
||||
sections
|
||||
}) {
|
||||
const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
|
||||
|
||||
// This is also used to sync the two different rendered components
|
||||
// between small and large viewports.
|
||||
const [activeMenu, setActiveMenu] = (0,external_wp_element_namespaceObject.useState)(PREFERENCES_MENU);
|
||||
/**
|
||||
* Create helper objects from `sections` for easier data handling.
|
||||
* `tabs` is used for creating the `Tabs` and `sectionsContentMap`
|
||||
* is used for easier access to active tab's content.
|
||||
*/
|
||||
const {
|
||||
tabs,
|
||||
sectionsContentMap
|
||||
} = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
let mappedTabs = {
|
||||
tabs: [],
|
||||
sectionsContentMap: {}
|
||||
};
|
||||
if (sections.length) {
|
||||
mappedTabs = sections.reduce((accumulator, {
|
||||
name,
|
||||
tabLabel: title,
|
||||
content
|
||||
}) => {
|
||||
accumulator.tabs.push({
|
||||
name,
|
||||
title
|
||||
});
|
||||
accumulator.sectionsContentMap[name] = content;
|
||||
return accumulator;
|
||||
}, {
|
||||
tabs: [],
|
||||
sectionsContentMap: {}
|
||||
});
|
||||
}
|
||||
return mappedTabs;
|
||||
}, [sections]);
|
||||
let modalContent;
|
||||
// We render different components based on the viewport size.
|
||||
if (isLargeViewport) {
|
||||
modalContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
|
||||
className: "preferences__tabs",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs, {
|
||||
defaultTabId: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined,
|
||||
onSelect: setActiveMenu,
|
||||
orientation: "vertical",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabList, {
|
||||
className: "preferences__tabs-tablist",
|
||||
children: tabs.map(tab => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
|
||||
tabId: tab.name,
|
||||
className: "preferences__tabs-tab",
|
||||
children: tab.title
|
||||
}, tab.name))
|
||||
}), tabs.map(tab => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabPanel, {
|
||||
tabId: tab.name,
|
||||
className: "preferences__tabs-tabpanel",
|
||||
focusable: false,
|
||||
children: sectionsContentMap[tab.name] || null
|
||||
}, tab.name))]
|
||||
})
|
||||
});
|
||||
} else {
|
||||
modalContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, {
|
||||
initialPath: "/",
|
||||
className: "preferences__provider",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
|
||||
path: "/",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Card, {
|
||||
isBorderless: true,
|
||||
size: "small",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CardBody, {
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalItemGroup, {
|
||||
children: tabs.map(tab => {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNavigatorButton, {
|
||||
path: tab.name,
|
||||
as: external_wp_components_namespaceObject.__experimentalItem,
|
||||
isAction: true,
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
|
||||
justify: "space-between",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalTruncate, {
|
||||
children: tab.title
|
||||
})
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
|
||||
icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
|
||||
})
|
||||
})]
|
||||
})
|
||||
}, tab.name);
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}), sections.length && sections.map(section => {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
|
||||
path: section.name,
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Card, {
|
||||
isBorderless: true,
|
||||
size: "large",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.CardHeader, {
|
||||
isBorderless: false,
|
||||
justify: "left",
|
||||
size: "small",
|
||||
gap: "6",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, {
|
||||
icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Back')
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
|
||||
size: "16",
|
||||
children: section.tabLabel
|
||||
})]
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CardBody, {
|
||||
children: section.content
|
||||
})]
|
||||
})
|
||||
}, `${section.name}-menu`);
|
||||
})]
|
||||
});
|
||||
}
|
||||
return modalContent;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/private-apis.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const privateApis = {};
|
||||
lock(privateApis, {
|
||||
PreferenceBaseOption: preference_base_option,
|
||||
PreferenceToggleControl: preference_toggle_control,
|
||||
PreferencesModal: PreferencesModal,
|
||||
PreferencesModalSection: preferences_modal_section,
|
||||
PreferencesModalTabs: PreferencesModalTabs
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/index.js
|
||||
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).preferences = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/preferences.min.js
vendored
Normal file
2
wp-includes/js/dist/preferences.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
195
wp-includes/js/dist/primitives.js
vendored
Normal file
195
wp-includes/js/dist/primitives.js
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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__, {
|
||||
BlockQuotation: () => (/* reexport */ BlockQuotation),
|
||||
Circle: () => (/* reexport */ Circle),
|
||||
Defs: () => (/* reexport */ Defs),
|
||||
G: () => (/* reexport */ G),
|
||||
HorizontalRule: () => (/* reexport */ HorizontalRule),
|
||||
Line: () => (/* reexport */ Line),
|
||||
LinearGradient: () => (/* reexport */ LinearGradient),
|
||||
Path: () => (/* reexport */ Path),
|
||||
Polygon: () => (/* reexport */ Polygon),
|
||||
RadialGradient: () => (/* reexport */ RadialGradient),
|
||||
Rect: () => (/* reexport */ Rect),
|
||||
SVG: () => (/* reexport */ SVG),
|
||||
Stop: () => (/* reexport */ Stop),
|
||||
View: () => (/* reexport */ View)
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/clsx/dist/clsx.mjs
|
||||
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx);
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// 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: dist_clsx(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 /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("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__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/primitives.min.js
vendored
Normal file
2
wp-includes/js/dist/primitives.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=r(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}e.r(t),e.d(t,{BlockQuotation:()=>g,Circle:()=>i,Defs:()=>m,G:()=>l,HorizontalRule:()=>b,Line:()=>c,LinearGradient:()=>u,Path:()=>s,Polygon:()=>d,RadialGradient:()=>p,Rect:()=>f,SVG:()=>w,Stop:()=>y,View:()=>v});const n=function(){for(var e,t,n=0,o="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=r(e))&&(o&&(o+=" "),o+=t);return o},o=window.wp.element,a=window.ReactJSXRuntime,i=e=>(0,o.createElement)("circle",e),l=e=>(0,o.createElement)("g",e),c=e=>(0,o.createElement)("line",e),s=e=>(0,o.createElement)("path",e),d=e=>(0,o.createElement)("polygon",e),f=e=>(0,o.createElement)("rect",e),m=e=>(0,o.createElement)("defs",e),p=e=>(0,o.createElement)("radialGradient",e),u=e=>(0,o.createElement)("linearGradient",e),y=e=>(0,o.createElement)("stop",e),w=(0,o.forwardRef)((({className:e,isPressed:t,...r},o)=>{const i={...r,className:n(e,{"is-pressed":t})||void 0,"aria-hidden":!0,focusable:!1};return(0,a.jsx)("svg",{...i,ref:o})}));w.displayName="SVG";const b="hr",g="blockquote",v="div";(window.wp=window.wp||{}).primitives=t})();
|
||||
510
wp-includes/js/dist/priority-queue.js
vendored
Normal file
510
wp-includes/js/dist/priority-queue.js
vendored
Normal file
@@ -0,0 +1,510 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ 5033:
|
||||
/***/ ((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 */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (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 */
|
||||
/******/ (() => {
|
||||
/******/ __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 */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (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.
|
||||
(() => {
|
||||
"use strict";
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
createQueue: () => (/* binding */ createQueue)
|
||||
});
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/requestidlecallback/index.js
|
||||
var requestidlecallback = __webpack_require__(5033);
|
||||
;// 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 */ const 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__;
|
||||
/******/ })()
|
||||
;
|
||||
2
wp-includes/js/dist/priority-queue.min.js
vendored
Normal file
2
wp-includes/js/dist/priority-queue.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{var e={5033:(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,w=0,v={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&&v.timeRemaining()>u;r++)n=c.shift(),w++,n&&n(v);c.length?C():l=0}function I(e){return b++,c.push(e),C(),b}function O(e){var t=e-1-w;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=(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=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{createQueue:()=>t});n(5033);const e="undefined"==typeof window?e=>{setTimeout((()=>e(Date.now())),0)}:window.requestIdleCallback,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})();
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user