wp/wp-includes/js/dist/deprecated.js
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     1 /******/ (function() { // webpackBootstrap
     1 /******/ (() => { // webpackBootstrap
     2 /******/ 	"use strict";
     2 /******/ 	"use strict";
     3 /******/ 	// The require scope
     3 /******/ 	// The require scope
     4 /******/ 	var __webpack_require__ = {};
     4 /******/ 	var __webpack_require__ = {};
     5 /******/ 	
     5 /******/ 	
     6 /************************************************************************/
     6 /************************************************************************/
     7 /******/ 	/* webpack/runtime/define property getters */
     7 /******/ 	/* webpack/runtime/define property getters */
     8 /******/ 	!function() {
     8 /******/ 	(() => {
     9 /******/ 		// define getter functions for harmony exports
     9 /******/ 		// define getter functions for harmony exports
    10 /******/ 		__webpack_require__.d = function(exports, definition) {
    10 /******/ 		__webpack_require__.d = (exports, definition) => {
    11 /******/ 			for(var key in definition) {
    11 /******/ 			for(var key in definition) {
    12 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
    12 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
    13 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
    13 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
    14 /******/ 				}
    14 /******/ 				}
    15 /******/ 			}
    15 /******/ 			}
    16 /******/ 		};
    16 /******/ 		};
    17 /******/ 	}();
    17 /******/ 	})();
    18 /******/ 	
    18 /******/ 	
    19 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
    19 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
    20 /******/ 	!function() {
    20 /******/ 	(() => {
    21 /******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
    21 /******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
    22 /******/ 	}();
    22 /******/ 	})();
    23 /******/ 	
    23 /******/ 	
    24 /************************************************************************/
    24 /************************************************************************/
    25 var __webpack_exports__ = {};
    25 var __webpack_exports__ = {};
    26 
    26 
    27 // EXPORTS
    27 // EXPORTS
    28 __webpack_require__.d(__webpack_exports__, {
    28 __webpack_require__.d(__webpack_exports__, {
    29   "default": function() { return /* binding */ deprecated; }
    29   "default": () => (/* binding */ deprecated)
    30 });
    30 });
    31 
    31 
    32 // UNUSED EXPORTS: logged
    32 // UNUSED EXPORTS: logged
    33 
    33 
    34 ;// CONCATENATED MODULE: external ["wp","hooks"]
    34 ;// CONCATENATED MODULE: external ["wp","hooks"]
    35 var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
    35 const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
    36 ;// CONCATENATED MODULE: ./node_modules/@wordpress/deprecated/build-module/index.js
    36 ;// CONCATENATED MODULE: ./node_modules/@wordpress/deprecated/build-module/index.js
    37 /**
    37 /**
    38  * WordPress dependencies
    38  * WordPress dependencies
    39  */
    39  */
       
    40 
    40 
    41 
    41 /**
    42 /**
    42  * Object map tracking messages which have been logged, for use in ensuring a
    43  * Object map tracking messages which have been logged, for use in ensuring a
    43  * message is only logged once.
    44  * message is only logged once.
    44  *
    45  *
    45  * @type {Record<string, true | undefined>}
    46  * @type {Record<string, true | undefined>}
    46  */
    47  */
       
    48 const logged = Object.create(null);
    47 
    49 
    48 const logged = Object.create(null);
       
    49 /**
    50 /**
    50  * Logs a message to notify developers about a deprecated feature.
    51  * Logs a message to notify developers about a deprecated feature.
    51  *
    52  *
    52  * @param {string} feature               Name of the deprecated feature.
    53  * @param {string} feature               Name of the deprecated feature.
    53  * @param {Object} [options]             Personalisation options
    54  * @param {Object} [options]             Personalisation options
    71  * } );
    72  * } );
    72  *
    73  *
    73  * // 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.'
    74  * // 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.'
    74  * ```
    75  * ```
    75  */
    76  */
    76 
    77 function deprecated(feature, options = {}) {
    77 function deprecated(feature) {
       
    78   let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
       
    79   const {
    78   const {
    80     since,
    79     since,
    81     version,
    80     version,
    82     alternative,
    81     alternative,
    83     plugin,
    82     plugin,
    88   const sinceMessage = since ? ` since version ${since}` : '';
    87   const sinceMessage = since ? ` since version ${since}` : '';
    89   const versionMessage = version ? ` and will be removed${pluginMessage} in version ${version}` : '';
    88   const versionMessage = version ? ` and will be removed${pluginMessage} in version ${version}` : '';
    90   const useInsteadMessage = alternative ? ` Please use ${alternative} instead.` : '';
    89   const useInsteadMessage = alternative ? ` Please use ${alternative} instead.` : '';
    91   const linkMessage = link ? ` See: ${link}` : '';
    90   const linkMessage = link ? ` See: ${link}` : '';
    92   const hintMessage = hint ? ` Note: ${hint}` : '';
    91   const hintMessage = hint ? ` Note: ${hint}` : '';
    93   const message = `${feature} is deprecated${sinceMessage}${versionMessage}.${useInsteadMessage}${linkMessage}${hintMessage}`; // Skip if already logged.
    92   const message = `${feature} is deprecated${sinceMessage}${versionMessage}.${useInsteadMessage}${linkMessage}${hintMessage}`;
    94 
    93 
       
    94   // Skip if already logged.
    95   if (message in logged) {
    95   if (message in logged) {
    96     return;
    96     return;
    97   }
    97   }
       
    98 
    98   /**
    99   /**
    99    * Fires whenever a deprecated feature is encountered
   100    * Fires whenever a deprecated feature is encountered
   100    *
   101    *
   101    * @param {string}  feature             Name of the deprecated feature.
   102    * @param {string}  feature             Name of the deprecated feature.
   102    * @param {?Object} options             Personalisation options
   103    * @param {?Object} options             Personalisation options
   106    * @param {?string} options.plugin      Plugin name if it's a plugin feature
   107    * @param {?string} options.plugin      Plugin name if it's a plugin feature
   107    * @param {?string} options.link        Link to documentation
   108    * @param {?string} options.link        Link to documentation
   108    * @param {?string} options.hint        Additional message to help transition away from the deprecated feature.
   109    * @param {?string} options.hint        Additional message to help transition away from the deprecated feature.
   109    * @param {?string} message             Message sent to console.warn
   110    * @param {?string} message             Message sent to console.warn
   110    */
   111    */
       
   112   (0,external_wp_hooks_namespaceObject.doAction)('deprecated', feature, options, message);
   111 
   113 
   112 
   114   // eslint-disable-next-line no-console
   113   (0,external_wp_hooks_namespaceObject.doAction)('deprecated', feature, options, message); // eslint-disable-next-line no-console
       
   114 
       
   115   console.warn(message);
   115   console.warn(message);
   116   logged[message] = true;
   116   logged[message] = true;
   117 }
   117 }
       
   118 
   118 /** @typedef {import('utility-types').NonUndefined<Parameters<typeof deprecated>[1]>} DeprecatedOptions */
   119 /** @typedef {import('utility-types').NonUndefined<Parameters<typeof deprecated>[1]>} DeprecatedOptions */
   119 
   120 
   120 (window.wp = window.wp || {}).deprecated = __webpack_exports__["default"];
   121 (window.wp = window.wp || {}).deprecated = __webpack_exports__["default"];
   121 /******/ })()
   122 /******/ })()
   122 ;
   123 ;