[ 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.mjs
  23    var index_exports = {};
  24    __export(index_exports, {
  25      __dangerousOptInToUnstableAPIsOnlyForCoreModules: () => __dangerousOptInToUnstableAPIsOnlyForCoreModules
  26    });
  27  
  28    // packages/private-apis/build-module/implementation.mjs
  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/connectors",
  37      "@wordpress/workflows",
  38      "@wordpress/components",
  39      "@wordpress/core-commands",
  40      "@wordpress/core-data",
  41      "@wordpress/customize-widgets",
  42      "@wordpress/data",
  43      "@wordpress/edit-post",
  44      "@wordpress/edit-site",
  45      "@wordpress/edit-widgets",
  46      "@wordpress/editor",
  47      "@wordpress/font-list-route",
  48      "@wordpress/format-library",
  49      "@wordpress/patterns",
  50      "@wordpress/preferences",
  51      "@wordpress/reusable-blocks",
  52      "@wordpress/rich-text",
  53      "@wordpress/route",
  54      "@wordpress/router",
  55      "@wordpress/routes",
  56      "@wordpress/sync",
  57      "@wordpress/theme",
  58      "@wordpress/dataviews",
  59      "@wordpress/fields",
  60      "@wordpress/lazy-editor",
  61      "@wordpress/media-utils",
  62      "@wordpress/upload-media",
  63      "@wordpress/global-styles-ui",
  64      "@wordpress/ui"
  65    ];
  66    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.";
  67    var __dangerousOptInToUnstableAPIsOnlyForCoreModules = (consent, moduleName) => {
  68      if (!CORE_MODULES_USING_PRIVATE_APIS.includes(moduleName)) {
  69        throw new Error(
  70          `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.`
  71        );
  72      }
  73      if (consent !== requiredConsent) {
  74        throw new Error(
  75          `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.`
  76        );
  77      }
  78      return {
  79        lock,
  80        unlock
  81      };
  82    };
  83    function lock(object, privateData) {
  84      if (!object) {
  85        throw new Error("Cannot lock an undefined object.");
  86      }
  87      const _object = object;
  88      if (!(__private in _object)) {
  89        _object[__private] = {};
  90      }
  91      lockedData.set(_object[__private], privateData);
  92    }
  93    function unlock(object) {
  94      if (!object) {
  95        throw new Error("Cannot unlock an undefined object.");
  96      }
  97      const _object = object;
  98      if (!(__private in _object)) {
  99        throw new Error(
 100          "Cannot unlock an object that was not locked before. "
 101        );
 102      }
 103      return lockedData.get(_object[__private]);
 104    }
 105    var lockedData = /* @__PURE__ */ new WeakMap();
 106    var __private = /* @__PURE__ */ Symbol("Private API ID");
 107    return __toCommonJS(index_exports);
 108  })();


Generated : Tue Jun 23 08:20:11 2026 Cross-referenced by PHPXref