[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  (function() {
   2  "use strict";
   3  var wp;
   4  (wp ||= {}).privateApis = (() => {
   5    var __defProp = Object.defineProperty;
   6    var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
   7    var __getOwnPropNames = Object.getOwnPropertyNames;
   8    var __hasOwnProp = Object.prototype.hasOwnProperty;
   9    var __export = (target, all) => {
  10      for (var name in all)
  11        __defProp(target, name, { get: all[name], enumerable: true });
  12    };
  13    var __copyProps = (to, from, except, desc) => {
  14      if (from && typeof from === "object" || typeof from === "function") {
  15        for (let key of __getOwnPropNames(from))
  16          if (!__hasOwnProp.call(to, key) && key !== except)
  17            __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  18      }
  19      return to;
  20    };
  21    var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  22  
  23    // packages/private-apis/build-module/index.mjs
  24    var index_exports = {};
  25    __export(index_exports, {
  26      __dangerousOptInToUnstableAPIsOnlyForCoreModules: () => __dangerousOptInToUnstableAPIsOnlyForCoreModules
  27    });
  28  
  29    // packages/private-apis/build-module/implementation.mjs
  30    var CORE_MODULES_USING_PRIVATE_APIS = [
  31      "@wordpress/admin-ui",
  32      "@wordpress/api-fetch",
  33      "@wordpress/block-directory",
  34      "@wordpress/block-editor",
  35      "@wordpress/block-library",
  36      "@wordpress/blocks",
  37      "@wordpress/boot",
  38      "@wordpress/commands",
  39      "@wordpress/compose",
  40      "@wordpress/connectors",
  41      "@wordpress/workflows",
  42      "@wordpress/components",
  43      "@wordpress/core-actions",
  44      "@wordpress/core-commands",
  45      "@wordpress/core-data",
  46      "@wordpress/core-fields",
  47      "@wordpress/customize-widgets",
  48      "@wordpress/data",
  49      "@wordpress/edit-post",
  50      "@wordpress/edit-site",
  51      "@wordpress/edit-widgets",
  52      "@wordpress/editor",
  53      "@wordpress/font-list-route",
  54      "@wordpress/format-library",
  55      "@wordpress/notices",
  56      "@wordpress/patterns",
  57      "@wordpress/preferences",
  58      "@wordpress/rich-text",
  59      "@wordpress/route",
  60      "@wordpress/router",
  61      "@wordpress/routes",
  62      "@wordpress/storybook",
  63      "@wordpress/theme",
  64      // Do not remove: older `@wordpress/dataviews` versions published to npm
  65      // call the opt-in at module load, so a plugin bundling one of those
  66      // copies throws at load time if this entry is missing.
  67      "@wordpress/dataviews",
  68      // Do not remove: older `@wordpress/sync` versions published to npm call
  69      // the opt-in at module load, so a plugin bundling one of those copies
  70      // throws at load time if this entry is missing.
  71      "@wordpress/sync",
  72      "@wordpress/fields",
  73      "@wordpress/lazy-editor",
  74      "@wordpress/media-editor",
  75      "@wordpress/media-utils",
  76      "@wordpress/upload-media",
  77      "@wordpress/global-styles-engine",
  78      "@wordpress/global-styles-ui",
  79      "@wordpress/ui",
  80      "@wordpress/views",
  81      "@wordpress/widget-dashboard"
  82    ];
  83    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.";
  84    var __dangerousOptInToUnstableAPIsOnlyForCoreModules = (consent, moduleName) => {
  85      if (!CORE_MODULES_USING_PRIVATE_APIS.includes(moduleName)) {
  86        throw new Error(
  87          `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.`
  88        );
  89      }
  90      if (consent !== requiredConsent) {
  91        throw new Error(
  92          `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.`
  93        );
  94      }
  95      return {
  96        lock,
  97        unlock
  98      };
  99    };
 100    function lock(object, privateData) {
 101      if (!object) {
 102        throw new Error("Cannot lock an undefined object.");
 103      }
 104      const _object = object;
 105      if (!(__private in _object)) {
 106        _object[__private] = {};
 107      }
 108      lockedData.set(_object[__private], privateData);
 109    }
 110    function unlock(object) {
 111      if (!object) {
 112        throw new Error("Cannot unlock an undefined object.");
 113      }
 114      const _object = object;
 115      if (!(__private in _object)) {
 116        throw new Error(
 117          "Cannot unlock an object that was not locked before. "
 118        );
 119      }
 120      return lockedData.get(_object[__private]);
 121    }
 122    var lockedData = /* @__PURE__ */ new WeakMap();
 123    var __private = /* @__PURE__ */ Symbol("Private API ID");
 124    return __toCommonJS(index_exports);
 125  })();
 126  (window.wp ||= {}).privateApis = wp.privateApis;
 127  })();


Generated : Wed Oct 28 08:20:35 2026 Cross-referenced by PHPXref