[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> private-apis.js (source)

   1  /******/ (() => { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/define property getters */
   8  /******/     (() => {
   9  /******/         // define getter functions for harmony exports
  10  /******/         __webpack_require__.d = (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  /******/     (() => {
  21  /******/         __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  22  /******/     })();
  23  /******/     
  24  /******/     /* webpack/runtime/make namespace object */
  25  /******/     (() => {
  26  /******/         // define __esModule on exports
  27  /******/         __webpack_require__.r = (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  
  40  // EXPORTS
  41  __webpack_require__.d(__webpack_exports__, {
  42    __dangerousOptInToUnstableAPIsOnlyForCoreModules: () => (/* reexport */ __dangerousOptInToUnstableAPIsOnlyForCoreModules)
  43  });
  44  
  45  ;// ./node_modules/@wordpress/private-apis/build-module/implementation.js
  46  const CORE_MODULES_USING_PRIVATE_APIS = [
  47    "@wordpress/block-directory",
  48    "@wordpress/block-editor",
  49    "@wordpress/block-library",
  50    "@wordpress/blocks",
  51    "@wordpress/commands",
  52    "@wordpress/components",
  53    "@wordpress/core-commands",
  54    "@wordpress/core-data",
  55    "@wordpress/customize-widgets",
  56    "@wordpress/data",
  57    "@wordpress/edit-post",
  58    "@wordpress/edit-site",
  59    "@wordpress/edit-widgets",
  60    "@wordpress/editor",
  61    "@wordpress/format-library",
  62    "@wordpress/patterns",
  63    "@wordpress/preferences",
  64    "@wordpress/reusable-blocks",
  65    "@wordpress/router",
  66    "@wordpress/sync",
  67    "@wordpress/dataviews",
  68    "@wordpress/fields",
  69    "@wordpress/media-utils",
  70    "@wordpress/upload-media"
  71  ];
  72  const registeredPrivateApis = [];
  73  const requiredConsent = "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.";
  74  const allowReRegistration =  true ? false : 0;
  75  const __dangerousOptInToUnstableAPIsOnlyForCoreModules = (consent, moduleName) => {
  76    if (!CORE_MODULES_USING_PRIVATE_APIS.includes(moduleName)) {
  77      throw new Error(
  78        `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.`
  79      );
  80    }
  81    if (!allowReRegistration && registeredPrivateApis.includes(moduleName)) {
  82      throw new Error(
  83        `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.`
  84      );
  85    }
  86    if (consent !== requiredConsent) {
  87      throw new Error(
  88        `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.`
  89      );
  90    }
  91    registeredPrivateApis.push(moduleName);
  92    return {
  93      lock,
  94      unlock
  95    };
  96  };
  97  function lock(object, privateData) {
  98    if (!object) {
  99      throw new Error("Cannot lock an undefined object.");
 100    }
 101    const _object = object;
 102    if (!(__private in _object)) {
 103      _object[__private] = {};
 104    }
 105    lockedData.set(_object[__private], privateData);
 106  }
 107  function unlock(object) {
 108    if (!object) {
 109      throw new Error("Cannot unlock an undefined object.");
 110    }
 111    const _object = object;
 112    if (!(__private in _object)) {
 113      throw new Error(
 114        "Cannot unlock an object that was not locked before. "
 115      );
 116    }
 117    return lockedData.get(_object[__private]);
 118  }
 119  const lockedData = /* @__PURE__ */ new WeakMap();
 120  const __private = Symbol("Private API ID");
 121  function allowCoreModule(name) {
 122    CORE_MODULES_USING_PRIVATE_APIS.push(name);
 123  }
 124  function resetAllowedCoreModules() {
 125    while (CORE_MODULES_USING_PRIVATE_APIS.length) {
 126      CORE_MODULES_USING_PRIVATE_APIS.pop();
 127    }
 128  }
 129  function resetRegisteredPrivateApis() {
 130    while (registeredPrivateApis.length) {
 131      registeredPrivateApis.pop();
 132    }
 133  }
 134  
 135  
 136  ;// ./node_modules/@wordpress/private-apis/build-module/index.js
 137  
 138  
 139  
 140  (window.wp = window.wp || {}).privateApis = __webpack_exports__;
 141  /******/ })()
 142  ;


Generated : Mon Oct 27 08:20:06 2025 Cross-referenced by PHPXref