You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
8.6 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ "use strict";
  3. /******/ // The require scope
  4. /******/ var __webpack_require__ = {};
  5. /******/
  6. /************************************************************************/
  7. /******/ /* webpack/runtime/define property getters */
  8. /******/ !function() {
  9. /******/ // define getter functions for harmony exports
  10. /******/ __webpack_require__.d = function(exports, definition) {
  11. /******/ for(var key in definition) {
  12. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  13. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  14. /******/ }
  15. /******/ }
  16. /******/ };
  17. /******/ }();
  18. /******/
  19. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  20. /******/ !function() {
  21. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  22. /******/ }();
  23. /******/
  24. /******/ /* webpack/runtime/make namespace object */
  25. /******/ !function() {
  26. /******/ // define __esModule on exports
  27. /******/ __webpack_require__.r = function(exports) {
  28. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  29. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  30. /******/ }
  31. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  32. /******/ };
  33. /******/ }();
  34. /******/
  35. /************************************************************************/
  36. var __webpack_exports__ = {};
  37. // ESM COMPAT FLAG
  38. __webpack_require__.r(__webpack_exports__);
  39. // EXPORTS
  40. __webpack_require__.d(__webpack_exports__, {
  41. __dangerousOptInToUnstableAPIsOnlyForCoreModules: function() { return /* reexport */ __dangerousOptInToUnstableAPIsOnlyForCoreModules; }
  42. });
  43. ;// CONCATENATED MODULE: ./node_modules/@wordpress/private-apis/build-module/implementation.js
  44. /**
  45. * wordpress/private-apis the utilities to enable private cross-package
  46. * exports of private APIs.
  47. *
  48. * This "implementation.js" file is needed for the sake of the unit tests. It
  49. * exports more than the public API of the package to aid in testing.
  50. */
  51. /**
  52. * The list of core modules allowed to opt-in to the private APIs.
  53. */
  54. const CORE_MODULES_USING_PRIVATE_APIS = ['@wordpress/block-editor', '@wordpress/block-library', '@wordpress/blocks', '@wordpress/commands', '@wordpress/components', '@wordpress/core-commands', '@wordpress/core-data', '@wordpress/customize-widgets', '@wordpress/data', '@wordpress/edit-post', '@wordpress/edit-site', '@wordpress/edit-widgets', '@wordpress/editor', '@wordpress/patterns', '@wordpress/reusable-blocks', '@wordpress/router'];
  55. /**
  56. * A list of core modules that already opted-in to
  57. * the privateApis package.
  58. *
  59. * @type {string[]}
  60. */
  61. const registeredPrivateApis = [];
  62. /*
  63. * Warning for theme and plugin developers.
  64. *
  65. * The use of private developer APIs is intended for use by WordPress Core
  66. * and the Gutenberg plugin exclusively.
  67. *
  68. * Dangerously opting in to using these APIs is NOT RECOMMENDED. Furthermore,
  69. * the WordPress Core philosophy to strive to maintain backward compatibility
  70. * for third-party developers DOES NOT APPLY to private APIs.
  71. *
  72. * THE CONSENT STRING FOR OPTING IN TO THESE APIS MAY CHANGE AT ANY TIME AND
  73. * WITHOUT NOTICE. THIS CHANGE WILL BREAK EXISTING THIRD-PARTY CODE. SUCH A
  74. * CHANGE MAY OCCUR IN EITHER A MAJOR OR MINOR RELEASE.
  75. */
  76. const requiredConsent = 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.';
  77. /** @type {boolean} */
  78. let allowReRegistration;
  79. // The safety measure is meant for WordPress core where IS_WORDPRESS_CORE
  80. // is set to true.
  81. // For the general use-case, the re-registration should be allowed by default
  82. // Let's default to true, then. Try/catch will fall back to "true" even if the
  83. // environment variable is not explicitly defined.
  84. try {
  85. allowReRegistration = true ? false : 0;
  86. } catch (error) {
  87. allowReRegistration = true;
  88. }
  89. /**
  90. * Called by a @wordpress package wishing to opt-in to accessing or exposing
  91. * private private APIs.
  92. *
  93. * @param {string} consent The consent string.
  94. * @param {string} moduleName The name of the module that is opting in.
  95. * @return {{lock: typeof lock, unlock: typeof unlock}} An object containing the lock and unlock functions.
  96. */
  97. const __dangerousOptInToUnstableAPIsOnlyForCoreModules = (consent, moduleName) => {
  98. if (!CORE_MODULES_USING_PRIVATE_APIS.includes(moduleName)) {
  99. throw new Error(`You tried to opt-in to unstable APIs as module "${moduleName}". ` + 'This feature is only for JavaScript modules shipped with WordPress core. ' + 'Please do not use it in plugins and themes as the unstable APIs will be removed ' + 'without a warning. If you ignore this error and depend on unstable features, ' + 'your product will inevitably break on one of the next WordPress releases.');
  100. }
  101. if (!allowReRegistration && registeredPrivateApis.includes(moduleName)) {
  102. // This check doesn't play well with Story Books / Hot Module Reloading
  103. // and isn't included in the Gutenberg plugin. It only matters in the
  104. // WordPress core release.
  105. throw new Error(`You tried to opt-in to unstable APIs as module "${moduleName}" which is already registered. ` + 'This feature is only for JavaScript modules shipped with WordPress core. ' + 'Please do not use it in plugins and themes as the unstable APIs will be removed ' + 'without a warning. If you ignore this error and depend on unstable features, ' + 'your product will inevitably break on one of the next WordPress releases.');
  106. }
  107. if (consent !== requiredConsent) {
  108. throw new Error(`You tried to opt-in to unstable APIs without confirming you know the consequences. ` + 'This feature is only for JavaScript modules shipped with WordPress core. ' + 'Please do not use it in plugins and themes as the unstable APIs will removed ' + 'without a warning. If you ignore this error and depend on unstable features, ' + 'your product will inevitably break on the next WordPress release.');
  109. }
  110. registeredPrivateApis.push(moduleName);
  111. return {
  112. lock,
  113. unlock
  114. };
  115. };
  116. /**
  117. * Binds private data to an object.
  118. * It does not alter the passed object in any way, only
  119. * registers it in an internal map of private data.
  120. *
  121. * The private data can't be accessed by any other means
  122. * than the `unlock` function.
  123. *
  124. * @example
  125. * ```js
  126. * const object = {};
  127. * const privateData = { a: 1 };
  128. * lock( object, privateData );
  129. *
  130. * object
  131. * // {}
  132. *
  133. * unlock( object );
  134. * // { a: 1 }
  135. * ```
  136. *
  137. * @param {any} object The object to bind the private data to.
  138. * @param {any} privateData The private data to bind to the object.
  139. */
  140. function lock(object, privateData) {
  141. if (!object) {
  142. throw new Error('Cannot lock an undefined object.');
  143. }
  144. if (!(__private in object)) {
  145. object[__private] = {};
  146. }
  147. lockedData.set(object[__private], privateData);
  148. }
  149. /**
  150. * Unlocks the private data bound to an object.
  151. *
  152. * It does not alter the passed object in any way, only
  153. * returns the private data paired with it using the `lock()`
  154. * function.
  155. *
  156. * @example
  157. * ```js
  158. * const object = {};
  159. * const privateData = { a: 1 };
  160. * lock( object, privateData );
  161. *
  162. * object
  163. * // {}
  164. *
  165. * unlock( object );
  166. * // { a: 1 }
  167. * ```
  168. *
  169. * @param {any} object The object to unlock the private data from.
  170. * @return {any} The private data bound to the object.
  171. */
  172. function unlock(object) {
  173. if (!object) {
  174. throw new Error('Cannot unlock an undefined object.');
  175. }
  176. if (!(__private in object)) {
  177. throw new Error('Cannot unlock an object that was not locked before. ');
  178. }
  179. return lockedData.get(object[__private]);
  180. }
  181. const lockedData = new WeakMap();
  182. /**
  183. * Used by lock() and unlock() to uniquely identify the private data
  184. * related to a containing object.
  185. */
  186. const __private = Symbol('Private API ID');
  187. // Unit tests utilities:
  188. /**
  189. * Private function to allow the unit tests to allow
  190. * a mock module to access the private APIs.
  191. *
  192. * @param {string} name The name of the module.
  193. */
  194. function allowCoreModule(name) {
  195. CORE_MODULES_USING_PRIVATE_APIS.push(name);
  196. }
  197. /**
  198. * Private function to allow the unit tests to set
  199. * a custom list of allowed modules.
  200. */
  201. function resetAllowedCoreModules() {
  202. while (CORE_MODULES_USING_PRIVATE_APIS.length) {
  203. CORE_MODULES_USING_PRIVATE_APIS.pop();
  204. }
  205. }
  206. /**
  207. * Private function to allow the unit tests to reset
  208. * the list of registered private apis.
  209. */
  210. function resetRegisteredPrivateApis() {
  211. while (registeredPrivateApis.length) {
  212. registeredPrivateApis.pop();
  213. }
  214. }
  215. ;// CONCATENATED MODULE: ./node_modules/@wordpress/private-apis/build-module/index.js
  216. (window.wp = window.wp || {}).privateApis = __webpack_exports__;
  217. /******/ })()
  218. ;