kollapsminoriteten/wp-includes/js/dist/deprecated.js

123 lines
4.6 KiB
JavaScript
Raw Normal View History

2024-04-17 11:32:24 +02:00
/******/ (() => { // webpackBootstrap
2022-06-16 14:03:35 +02:00
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
2024-04-17 11:32:24 +02:00
/******/ (() => {
2022-06-16 14:03:35 +02:00
/******/ // define getter functions for harmony exports
2024-04-17 11:32:24 +02:00
/******/ __webpack_require__.d = (exports, definition) => {
2022-06-16 14:03:35 +02:00
/******/ 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] });
/******/ }
/******/ }
2019-11-02 10:38:58 +01:00
/******/ };
2024-04-17 11:32:24 +02:00
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
2024-04-17 11:32:24 +02:00
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
2019-11-02 10:38:58 +01:00
/************************************************************************/
2022-06-16 14:03:35 +02:00
var __webpack_exports__ = {};
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
2024-04-17 11:32:24 +02:00
"default": () => (/* binding */ deprecated)
2022-06-16 14:03:35 +02:00
});
2019-11-02 10:38:58 +01:00
2022-06-16 14:03:35 +02:00
// UNUSED EXPORTS: logged
2019-11-02 10:38:58 +01:00
2025-04-25 12:30:07 +02:00
;// external ["wp","hooks"]
2024-04-17 11:32:24 +02:00
const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/deprecated/build-module/index.js
2019-11-02 10:38:58 +01:00
/**
* WordPress dependencies
*/
2023-12-07 09:44:11 +01:00
2019-11-02 10:38:58 +01:00
/**
* Object map tracking messages which have been logged, for use in ensuring a
* message is only logged once.
*
2021-07-23 11:58:50 +02:00
* @type {Record<string, true | undefined>}
2019-11-02 10:38:58 +01:00
*/
2021-07-23 11:58:50 +02:00
const logged = Object.create(null);
2023-12-07 09:44:11 +01:00
2019-11-02 10:38:58 +01:00
/**
* Logs a message to notify developers about a deprecated feature.
*
2021-04-27 08:32:47 +02:00
* @param {string} feature Name of the deprecated feature.
* @param {Object} [options] Personalisation options
2021-07-23 11:58:50 +02:00
* @param {string} [options.since] Version in which the feature was deprecated.
2021-04-27 08:32:47 +02:00
* @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.
2019-11-02 10:38:58 +01:00
*
* @example
* ```js
* import deprecated from '@wordpress/deprecated';
*
* deprecated( 'Eating meat', {
2021-07-23 11:58:50 +02:00
* since: '2019.01.01'
* version: '2020.01.01',
2019-11-02 10:38:58 +01:00
* alternative: 'vegetables',
* plugin: 'the earth',
* hint: 'You may find it beneficial to transition gradually.',
* } );
*
2021-07-23 11:58:50 +02:00
* // 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.'
2019-11-02 10:38:58 +01:00
* ```
*/
2023-09-26 10:33:34 +02:00
function deprecated(feature, options = {}) {
2021-07-23 11:58:50 +02:00
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}` : '';
2023-12-07 09:44:11 +01:00
const message = `${feature} is deprecated${sinceMessage}${versionMessage}.${useInsteadMessage}${linkMessage}${hintMessage}`;
2019-11-02 10:38:58 +01:00
2023-12-07 09:44:11 +01:00
// Skip if already logged.
2019-11-02 10:38:58 +01:00
if (message in logged) {
return;
}
2023-12-07 09:44:11 +01:00
2019-11-02 10:38:58 +01:00
/**
* Fires whenever a deprecated feature is encountered
*
* @param {string} feature Name of the deprecated feature.
* @param {?Object} options Personalisation options
2021-07-23 11:58:50 +02:00
* @param {string} options.since Version in which the feature was deprecated.
2019-11-02 10:38:58 +01:00
* @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
*/
2023-12-07 09:44:11 +01:00
(0,external_wp_hooks_namespaceObject.doAction)('deprecated', feature, options, message);
2019-11-02 10:38:58 +01:00
2023-12-07 09:44:11 +01:00
// eslint-disable-next-line no-console
2019-11-02 10:38:58 +01:00
console.warn(message);
logged[message] = true;
}
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
/** @typedef {import('utility-types').NonUndefined<Parameters<typeof deprecated>[1]>} DeprecatedOptions */
2019-11-02 10:38:58 +01:00
2022-06-16 14:03:35 +02:00
(window.wp = window.wp || {}).deprecated = __webpack_exports__["default"];
/******/ })()
;