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


Generated : Tue Jul 7 08:20:13 2026 Cross-referenced by PHPXref