File: /www/wwwroot/www.waciwang.com/wp-content/plugins/gutenberg/build/scripts/private-apis/index.js.map
{
"version": 3,
"sources": ["../../../packages/private-apis/src/implementation.ts"],
"sourcesContent": ["/**\n * wordpress/private-apis \u2013 the utilities to enable private cross-package\n * exports of private APIs.\n *\n * This \"implementation.ts\" file is needed for the sake of the unit tests. It\n * exports more than the public API of the package to aid in testing.\n */\n\n/**\n * The list of core modules allowed to opt-in to the private APIs.\n */\nconst CORE_MODULES_USING_PRIVATE_APIS = [\n\t'@wordpress/block-directory',\n\t'@wordpress/block-editor',\n\t'@wordpress/block-library',\n\t'@wordpress/blocks',\n\t'@wordpress/boot',\n\t'@wordpress/commands',\n\t'@wordpress/workflows',\n\t'@wordpress/components',\n\t'@wordpress/core-commands',\n\t'@wordpress/core-data',\n\t'@wordpress/customize-widgets',\n\t'@wordpress/data',\n\t'@wordpress/edit-post',\n\t'@wordpress/edit-site',\n\t'@wordpress/edit-widgets',\n\t'@wordpress/editor',\n\t'@wordpress/font-list-route',\n\t'@wordpress/format-library',\n\t'@wordpress/patterns',\n\t'@wordpress/preferences',\n\t'@wordpress/reusable-blocks',\n\t'@wordpress/route',\n\t'@wordpress/router',\n\t'@wordpress/routes',\n\t'@wordpress/sync',\n\t'@wordpress/theme',\n\t'@wordpress/dataviews',\n\t'@wordpress/fields',\n\t'@wordpress/lazy-editor',\n\t'@wordpress/media-utils',\n\t'@wordpress/upload-media',\n\t'@wordpress/global-styles-ui',\n];\n\n/*\n * Warning for theme and plugin developers.\n *\n * The use of private developer APIs is intended for use by WordPress Core\n * and the Gutenberg plugin exclusively.\n *\n * Dangerously opting in to using these APIs is NOT RECOMMENDED. Furthermore,\n * the WordPress Core philosophy to strive to maintain backward compatibility\n * for third-party developers DOES NOT APPLY to private APIs.\n *\n * THE CONSENT STRING FOR OPTING IN TO THESE APIS MAY CHANGE AT ANY TIME AND\n * WITHOUT NOTICE. THIS CHANGE WILL BREAK EXISTING THIRD-PARTY CODE. SUCH A\n * CHANGE MAY OCCUR IN EITHER A MAJOR OR MINOR RELEASE.\n */\nconst requiredConsent =\n\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.';\n\n/**\n * Called by a @wordpress package wishing to opt-in to accessing or exposing\n * private private APIs.\n *\n * @param consent The consent string.\n * @param moduleName The name of the module that is opting in.\n * @return An object containing the lock and unlock functions.\n */\nexport const __dangerousOptInToUnstableAPIsOnlyForCoreModules = (\n\tconsent: string,\n\tmoduleName: string\n) => {\n\tif ( ! CORE_MODULES_USING_PRIVATE_APIS.includes( moduleName ) ) {\n\t\tthrow new Error(\n\t\t\t`You tried to opt-in to unstable APIs as module \"${ moduleName }\". ` +\n\t\t\t\t'This feature is only for JavaScript modules shipped with WordPress core. ' +\n\t\t\t\t'Please do not use it in plugins and themes as the unstable APIs will be removed ' +\n\t\t\t\t'without a warning. If you ignore this error and depend on unstable features, ' +\n\t\t\t\t'your product will inevitably break on one of the next WordPress releases.'\n\t\t);\n\t}\n\tif ( consent !== requiredConsent ) {\n\t\tthrow new Error(\n\t\t\t`You tried to opt-in to unstable APIs without confirming you know the consequences. ` +\n\t\t\t\t'This feature is only for JavaScript modules shipped with WordPress core. ' +\n\t\t\t\t'Please do not use it in plugins and themes as the unstable APIs will removed ' +\n\t\t\t\t'without a warning. If you ignore this error and depend on unstable features, ' +\n\t\t\t\t'your product will inevitably break on the next WordPress release.'\n\t\t);\n\t}\n\n\treturn {\n\t\tlock,\n\t\tunlock,\n\t};\n};\n\n/**\n * Binds private data to an object.\n * It does not alter the passed object in any way, only\n * registers it in an internal map of private data.\n *\n * The private data can't be accessed by any other means\n * than the `unlock` function.\n *\n * @example\n * ```js\n * const object = {};\n * const privateData = { a: 1 };\n * lock( object, privateData );\n *\n * object\n * // {}\n *\n * unlock( object );\n * // { a: 1 }\n * ```\n *\n * @param object The object to bind the private data to.\n * @param privateData The private data to bind to the object.\n */\nfunction lock( object: unknown, privateData: unknown ) {\n\tif ( ! object ) {\n\t\tthrow new Error( 'Cannot lock an undefined object.' );\n\t}\n\tconst _object = object as Record< symbol, WeakKey >;\n\n\tif ( ! ( __private in _object ) ) {\n\t\t_object[ __private ] = {};\n\t}\n\tlockedData.set( _object[ __private ], privateData );\n}\n\n/**\n * Unlocks the private data bound to an object.\n *\n * It does not alter the passed object in any way, only\n * returns the private data paired with it using the `lock()`\n * function.\n *\n * @example\n * ```js\n * const object = {};\n * const privateData = { a: 1 };\n * lock( object, privateData );\n *\n * object\n * // {}\n *\n * unlock( object );\n * // { a: 1 }\n * ```\n *\n * @param object The object to unlock the private data from.\n * @return The private data bound to the object.\n */\nfunction unlock< T = any >( object: unknown ): T {\n\tif ( ! object ) {\n\t\tthrow new Error( 'Cannot unlock an undefined object.' );\n\t}\n\tconst _object = object as Record< symbol, WeakKey >;\n\n\tif ( ! ( __private in _object ) ) {\n\t\tthrow new Error(\n\t\t\t'Cannot unlock an object that was not locked before. '\n\t\t);\n\t}\n\n\treturn lockedData.get( _object[ __private ] );\n}\n\nconst lockedData = new WeakMap();\n\n/**\n * Used by lock() and unlock() to uniquely identify the private data\n * related to a containing object.\n */\nconst __private = Symbol( 'Private API ID' );\n\n// Unit tests utilities:\n\n/**\n * Private function to allow the unit tests to allow\n * a mock module to access the private APIs.\n *\n * @param name The name of the module.\n */\nexport function allowCoreModule( name: string ) {\n\tCORE_MODULES_USING_PRIVATE_APIS.push( name );\n}\n\n/**\n * Private function to allow the unit tests to set\n * a custom list of allowed modules.\n */\nexport function resetAllowedCoreModules() {\n\twhile ( CORE_MODULES_USING_PRIVATE_APIS.length ) {\n\t\tCORE_MODULES_USING_PRIVATE_APIS.pop();\n\t}\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,MAAM,kCAAkC;IACvC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;EACD;AAgBA,MAAM,kBACL;AAUM,MAAM,mDAAmD,CAC/D,SACA,eACI;AACJ,QAAK,CAAE,gCAAgC,SAAU,UAAW,GAAI;AAC/D,YAAM,IAAI;QACT,mDAAoD,UAAW;MAKhE;IACD;AACA,QAAK,YAAY,iBAAkB;AAClC,YAAM,IAAI;QACT;MAKD;IACD;AAEA,WAAO;MACN;MACA;IACD;EACD;AA0BA,WAAS,KAAM,QAAiB,aAAuB;AACtD,QAAK,CAAE,QAAS;AACf,YAAM,IAAI,MAAO,kCAAmC;IACrD;AACA,UAAM,UAAU;AAEhB,QAAK,EAAI,aAAa,UAAY;AACjC,cAAS,SAAU,IAAI,CAAC;IACzB;AACA,eAAW,IAAK,QAAS,SAAU,GAAG,WAAY;EACnD;AAyBA,WAAS,OAAmB,QAAqB;AAChD,QAAK,CAAE,QAAS;AACf,YAAM,IAAI,MAAO,oCAAqC;IACvD;AACA,UAAM,UAAU;AAEhB,QAAK,EAAI,aAAa,UAAY;AACjC,YAAM,IAAI;QACT;MACD;IACD;AAEA,WAAO,WAAW,IAAK,QAAS,SAAU,CAAE;EAC7C;AAEA,MAAM,aAAa,oBAAI,QAAQ;AAM/B,MAAM,YAAY,uBAAQ,gBAAiB;",
"names": []
}