diff -r 48c4eec2b7e6 -r 8c2e4d02f4ef wp/wp-includes/js/dist/private-apis.js --- a/wp/wp-includes/js/dist/private-apis.js Fri Sep 05 18:40:08 2025 +0200 +++ b/wp/wp-includes/js/dist/private-apis.js Fri Sep 05 18:52:52 2025 +0200 @@ -42,25 +42,23 @@ __dangerousOptInToUnstableAPIsOnlyForCoreModules: () => (/* reexport */ __dangerousOptInToUnstableAPIsOnlyForCoreModules) }); -;// CONCATENATED MODULE: ./node_modules/@wordpress/private-apis/build-module/implementation.js +;// ./node_modules/@wordpress/private-apis/build-module/implementation.js /** * wordpress/private-apis – the utilities to enable private cross-package * exports of private APIs. * - * This "implementation.js" file is needed for the sake of the unit tests. It + * This "implementation.ts" file is needed for the sake of the unit tests. It * exports more than the public API of the package to aid in testing. */ /** * The list of core modules allowed to opt-in to the private APIs. */ -const CORE_MODULES_USING_PRIVATE_APIS = ['@wordpress/block-directory', '@wordpress/block-editor', '@wordpress/block-library', '@wordpress/blocks', '@wordpress/commands', '@wordpress/components', '@wordpress/core-commands', '@wordpress/core-data', '@wordpress/customize-widgets', '@wordpress/data', '@wordpress/edit-post', '@wordpress/edit-site', '@wordpress/edit-widgets', '@wordpress/editor', '@wordpress/format-library', '@wordpress/interface', '@wordpress/patterns', '@wordpress/preferences', '@wordpress/reusable-blocks', '@wordpress/router', '@wordpress/dataviews']; +const CORE_MODULES_USING_PRIVATE_APIS = ['@wordpress/block-directory', '@wordpress/block-editor', '@wordpress/block-library', '@wordpress/blocks', '@wordpress/commands', '@wordpress/components', '@wordpress/core-commands', '@wordpress/core-data', '@wordpress/customize-widgets', '@wordpress/data', '@wordpress/edit-post', '@wordpress/edit-site', '@wordpress/edit-widgets', '@wordpress/editor', '@wordpress/format-library', '@wordpress/patterns', '@wordpress/preferences', '@wordpress/reusable-blocks', '@wordpress/router', '@wordpress/dataviews', '@wordpress/fields', '@wordpress/media-utils', '@wordpress/upload-media']; /** * A list of core modules that already opted-in to * the privateApis package. - * - * @type {string[]} */ const registeredPrivateApis = []; @@ -80,26 +78,16 @@ */ 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.'; -/** @type {boolean} */ -let allowReRegistration; -// The safety measure is meant for WordPress core where IS_WORDPRESS_CORE -// is set to true. -// For the general use-case, the re-registration should be allowed by default -// Let's default to true, then. Try/catch will fall back to "true" even if the -// environment variable is not explicitly defined. -try { - allowReRegistration = true ? false : 0; -} catch (error) { - allowReRegistration = true; -} +// The safety measure is meant for WordPress core where IS_WORDPRESS_CORE is set to true. +const allowReRegistration = true ? false : 0; /** * Called by a @wordpress package wishing to opt-in to accessing or exposing * private private APIs. * - * @param {string} consent The consent string. - * @param {string} moduleName The name of the module that is opting in. - * @return {{lock: typeof lock, unlock: typeof unlock}} An object containing the lock and unlock functions. + * @param consent The consent string. + * @param moduleName The name of the module that is opting in. + * @return An object containing the lock and unlock functions. */ const __dangerousOptInToUnstableAPIsOnlyForCoreModules = (consent, moduleName) => { if (!CORE_MODULES_USING_PRIVATE_APIS.includes(moduleName)) { @@ -142,17 +130,18 @@ * // { a: 1 } * ``` * - * @param {any} object The object to bind the private data to. - * @param {any} privateData The private data to bind to the object. + * @param object The object to bind the private data to. + * @param privateData The private data to bind to the object. */ function lock(object, privateData) { if (!object) { throw new Error('Cannot lock an undefined object.'); } - if (!(__private in object)) { - object[__private] = {}; + const _object = object; + if (!(__private in _object)) { + _object[__private] = {}; } - lockedData.set(object[__private], privateData); + lockedData.set(_object[__private], privateData); } /** @@ -175,17 +164,18 @@ * // { a: 1 } * ``` * - * @param {any} object The object to unlock the private data from. - * @return {any} The private data bound to the object. + * @param object The object to unlock the private data from. + * @return The private data bound to the object. */ function unlock(object) { if (!object) { throw new Error('Cannot unlock an undefined object.'); } - if (!(__private in object)) { + const _object = object; + if (!(__private in _object)) { throw new Error('Cannot unlock an object that was not locked before. '); } - return lockedData.get(object[__private]); + return lockedData.get(_object[__private]); } const lockedData = new WeakMap(); @@ -201,7 +191,7 @@ * Private function to allow the unit tests to allow * a mock module to access the private APIs. * - * @param {string} name The name of the module. + * @param name The name of the module. */ function allowCoreModule(name) { CORE_MODULES_USING_PRIVATE_APIS.push(name); @@ -226,7 +216,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/private-apis/build-module/index.js +;// ./node_modules/@wordpress/private-apis/build-module/index.js (window.wp = window.wp || {}).privateApis = __webpack_exports__;