[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  "use strict";
   2  var wp;
   3  (wp ||= {}).privateApis = (() => {
   4    var __defProp = Object.defineProperty;
   5    var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
   6    var __getOwnPropNames = Object.getOwnPropertyNames;
   7    var __hasOwnProp = Object.prototype.hasOwnProperty;
   8    var __export = (target, all) => {
   9      for (var name in all)
  10        __defProp(target, name, { get: all[name], enumerable: true });
  11    };
  12    var __copyProps = (to, from, except, desc) => {
  13      if (from && typeof from === "object" || typeof from === "function") {
  14        for (let key of __getOwnPropNames(from))
  15          if (!__hasOwnProp.call(to, key) && key !== except)
  16            __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  17      }
  18      return to;
  19    };
  20    var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  21  
  22    // packages/private-apis/build-module/index.js
  23    var index_exports = {};
  24    __export(index_exports, {
  25      __dangerousOptInToUnstableAPIsOnlyForCoreModules: () => __dangerousOptInToUnstableAPIsOnlyForCoreModules
  26    });
  27  
  28    // packages/private-apis/build-module/implementation.js
  29    var CORE_MODULES_USING_PRIVATE_APIS = [
  30      "@wordpress/block-directory",
  31      "@wordpress/block-editor",
  32      "@wordpress/block-library",
  33      "@wordpress/blocks",
  34      "@wordpress/boot",
  35      "@wordpress/commands",
  36      "@wordpress/workflows",
  37      "@wordpress/components",
  38      "@wordpress/core-commands",
  39      "@wordpress/core-data",
  40      "@wordpress/customize-widgets",
  41      "@wordpress/data",
  42      "@wordpress/edit-post",
  43      "@wordpress/edit-site",
  44      "@wordpress/edit-widgets",
  45      "@wordpress/editor",
  46      "@wordpress/font-list-route",
  47      "@wordpress/format-library",
  48      "@wordpress/patterns",
  49      "@wordpress/preferences",
  50      "@wordpress/reusable-blocks",
  51      "@wordpress/route",
  52      "@wordpress/router",
  53      "@wordpress/routes",
  54      "@wordpress/sync",
  55      "@wordpress/theme",
  56      "@wordpress/dataviews",
  57      "@wordpress/fields",
  58      "@wordpress/lazy-editor",
  59      "@wordpress/media-utils",
  60      "@wordpress/upload-media",
  61      "@wordpress/global-styles-ui"
  62    ];
  63    var requiredConsent = "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.";
  64    var __dangerousOptInToUnstableAPIsOnlyForCoreModules = (consent, moduleName) => {
  65      if (!CORE_MODULES_USING_PRIVATE_APIS.includes(moduleName)) {
  66        throw new Error(
  67          `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.`
  68        );
  69      }
  70      if (consent !== requiredConsent) {
  71        throw new Error(
  72          `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.`
  73        );
  74      }
  75      return {
  76        lock,
  77        unlock
  78      };
  79    };
  80    function lock(object, privateData) {
  81      if (!object) {
  82        throw new Error("Cannot lock an undefined object.");
  83      }
  84      const _object = object;
  85      if (!(__private in _object)) {
  86        _object[__private] = {};
  87      }
  88      lockedData.set(_object[__private], privateData);
  89    }
  90    function unlock(object) {
  91      if (!object) {
  92        throw new Error("Cannot unlock an undefined object.");
  93      }
  94      const _object = object;
  95      if (!(__private in _object)) {
  96        throw new Error(
  97          "Cannot unlock an object that was not locked before. "
  98        );
  99      }
 100      return lockedData.get(_object[__private]);
 101    }
 102    var lockedData = /* @__PURE__ */ new WeakMap();
 103    var __private = Symbol("Private API ID");
 104    return __toCommonJS(index_exports);
 105  })();


Generated : Thu Apr 23 08:20:11 2026 Cross-referenced by PHPXref