80 /******/ // __webpack_public_path__ |
80 /******/ // __webpack_public_path__ |
81 /******/ __webpack_require__.p = ""; |
81 /******/ __webpack_require__.p = ""; |
82 /******/ |
82 /******/ |
83 /******/ |
83 /******/ |
84 /******/ // Load entry module and return exports |
84 /******/ // Load entry module and return exports |
85 /******/ return __webpack_require__(__webpack_require__.s = 418); |
85 /******/ return __webpack_require__(__webpack_require__.s = "+BeG"); |
86 /******/ }) |
86 /******/ }) |
87 /************************************************************************/ |
87 /************************************************************************/ |
88 /******/ ({ |
88 /******/ ({ |
89 |
89 |
90 /***/ 32: |
90 /***/ "+BeG": |
91 /***/ (function(module, exports) { |
|
92 |
|
93 (function() { module.exports = this["wp"]["hooks"]; }()); |
|
94 |
|
95 /***/ }), |
|
96 |
|
97 /***/ 418: |
|
98 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
91 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
99 |
92 |
100 "use strict"; |
93 "use strict"; |
101 __webpack_require__.r(__webpack_exports__); |
94 __webpack_require__.r(__webpack_exports__); |
102 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logged", function() { return logged; }); |
95 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logged", function() { return logged; }); |
103 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return deprecated; }); |
96 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return deprecated; }); |
104 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(32); |
97 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("g56x"); |
105 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__); |
98 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__); |
106 /** |
99 /** |
107 * WordPress dependencies |
100 * WordPress dependencies |
108 */ |
101 */ |
109 |
102 |
110 /** |
103 /** |
111 * Object map tracking messages which have been logged, for use in ensuring a |
104 * Object map tracking messages which have been logged, for use in ensuring a |
112 * message is only logged once. |
105 * message is only logged once. |
113 * |
106 * |
114 * @type {Object} |
107 * @type {Record<string, true | undefined>} |
115 */ |
108 */ |
116 |
109 |
117 var logged = Object.create(null); |
110 const logged = Object.create(null); |
118 /** |
111 /** |
119 * Logs a message to notify developers about a deprecated feature. |
112 * Logs a message to notify developers about a deprecated feature. |
120 * |
113 * |
121 * @param {string} feature Name of the deprecated feature. |
114 * @param {string} feature Name of the deprecated feature. |
122 * @param {?Object} options Personalisation options |
115 * @param {Object} [options] Personalisation options |
123 * @param {?string} options.version Version in which the feature will be removed. |
116 * @param {string} [options.since] Version in which the feature was deprecated. |
124 * @param {?string} options.alternative Feature to use instead |
117 * @param {string} [options.version] Version in which the feature will be removed. |
125 * @param {?string} options.plugin Plugin name if it's a plugin feature |
118 * @param {string} [options.alternative] Feature to use instead |
126 * @param {?string} options.link Link to documentation |
119 * @param {string} [options.plugin] Plugin name if it's a plugin feature |
127 * @param {?string} options.hint Additional message to help transition away from the deprecated feature. |
120 * @param {string} [options.link] Link to documentation |
|
121 * @param {string} [options.hint] Additional message to help transition away from the deprecated feature. |
128 * |
122 * |
129 * @example |
123 * @example |
130 * ```js |
124 * ```js |
131 * import deprecated from '@wordpress/deprecated'; |
125 * import deprecated from '@wordpress/deprecated'; |
132 * |
126 * |
133 * deprecated( 'Eating meat', { |
127 * deprecated( 'Eating meat', { |
134 * version: 'the future', |
128 * since: '2019.01.01' |
|
129 * version: '2020.01.01', |
135 * alternative: 'vegetables', |
130 * alternative: 'vegetables', |
136 * plugin: 'the earth', |
131 * plugin: 'the earth', |
137 * hint: 'You may find it beneficial to transition gradually.', |
132 * hint: 'You may find it beneficial to transition gradually.', |
138 * } ); |
133 * } ); |
139 * |
134 * |
140 * // Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.' |
135 * // 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.' |
141 * ``` |
136 * ``` |
142 */ |
137 */ |
143 |
138 |
144 function deprecated(feature) { |
139 function deprecated(feature, options = {}) { |
145 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
140 const { |
146 var version = options.version, |
141 since, |
147 alternative = options.alternative, |
142 version, |
148 plugin = options.plugin, |
143 alternative, |
149 link = options.link, |
144 plugin, |
150 hint = options.hint; |
145 link, |
151 var pluginMessage = plugin ? " from ".concat(plugin) : ''; |
146 hint |
152 var versionMessage = version ? " and will be removed".concat(pluginMessage, " in version ").concat(version) : ''; |
147 } = options; |
153 var useInsteadMessage = alternative ? " Please use ".concat(alternative, " instead.") : ''; |
148 const pluginMessage = plugin ? ` from ${plugin}` : ''; |
154 var linkMessage = link ? " See: ".concat(link) : ''; |
149 const sinceMessage = since ? ` since version ${since}` : ''; |
155 var hintMessage = hint ? " Note: ".concat(hint) : ''; |
150 const versionMessage = version ? ` and will be removed${pluginMessage} in version ${version}` : ''; |
156 var message = "".concat(feature, " is deprecated").concat(versionMessage, ".").concat(useInsteadMessage).concat(linkMessage).concat(hintMessage); // Skip if already logged. |
151 const useInsteadMessage = alternative ? ` Please use ${alternative} instead.` : ''; |
|
152 const linkMessage = link ? ` See: ${link}` : ''; |
|
153 const hintMessage = hint ? ` Note: ${hint}` : ''; |
|
154 const message = `${feature} is deprecated${sinceMessage}${versionMessage}.${useInsteadMessage}${linkMessage}${hintMessage}`; // Skip if already logged. |
157 |
155 |
158 if (message in logged) { |
156 if (message in logged) { |
159 return; |
157 return; |
160 } |
158 } |
161 /** |
159 /** |
162 * Fires whenever a deprecated feature is encountered |
160 * Fires whenever a deprecated feature is encountered |
163 * |
161 * |
164 * @param {string} feature Name of the deprecated feature. |
162 * @param {string} feature Name of the deprecated feature. |
165 * @param {?Object} options Personalisation options |
163 * @param {?Object} options Personalisation options |
|
164 * @param {string} options.since Version in which the feature was deprecated. |
166 * @param {?string} options.version Version in which the feature will be removed. |
165 * @param {?string} options.version Version in which the feature will be removed. |
167 * @param {?string} options.alternative Feature to use instead |
166 * @param {?string} options.alternative Feature to use instead |
168 * @param {?string} options.plugin Plugin name if it's a plugin feature |
167 * @param {?string} options.plugin Plugin name if it's a plugin feature |
169 * @param {?string} options.link Link to documentation |
168 * @param {?string} options.link Link to documentation |
170 * @param {?string} options.hint Additional message to help transition away from the deprecated feature. |
169 * @param {?string} options.hint Additional message to help transition away from the deprecated feature. |