@wordpress/private-apis 1.46.0 → 1.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/implementation.cjs +2 -0
- package/build/implementation.cjs.map +2 -2
- package/build-module/implementation.mjs +2 -0
- package/build-module/implementation.mjs.map +2 -2
- package/build-types/implementation.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/implementation.ts +2 -0
package/CHANGELOG.md
CHANGED
package/build/implementation.cjs
CHANGED
|
@@ -27,12 +27,14 @@ __export(implementation_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(implementation_exports);
|
|
28
28
|
var CORE_MODULES_USING_PRIVATE_APIS = [
|
|
29
29
|
"@wordpress/admin-ui",
|
|
30
|
+
"@wordpress/api-fetch",
|
|
30
31
|
"@wordpress/block-directory",
|
|
31
32
|
"@wordpress/block-editor",
|
|
32
33
|
"@wordpress/block-library",
|
|
33
34
|
"@wordpress/blocks",
|
|
34
35
|
"@wordpress/boot",
|
|
35
36
|
"@wordpress/commands",
|
|
37
|
+
"@wordpress/compose",
|
|
36
38
|
"@wordpress/connectors",
|
|
37
39
|
"@wordpress/workflows",
|
|
38
40
|
"@wordpress/components",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/implementation.ts"],
|
|
4
|
-
"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/admin-ui',\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/connectors',\n\t'@wordpress/workflows',\n\t'@wordpress/components',\n\t'@wordpress/content-types',\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/rich-text',\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-editor',\n\t'@wordpress/media-utils',\n\t'@wordpress/upload-media',\n\t'@wordpress/global-styles-ui',\n\t'@wordpress/ui',\n\t'@wordpress/views',\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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,IAAM,kCAAkC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAgBA,IAAM,kBACL;AAUM,IAAM,mDAAmD,CAC/D,SACA,eACI;AACJ,MAAK,CAAE,gCAAgC,SAAU,UAAW,GAAI;AAC/D,UAAM,IAAI;AAAA,MACT,mDAAoD,UAAW;AAAA,IAKhE;AAAA,EACD;AACA,MAAK,YAAY,iBAAkB;AAClC,UAAM,IAAI;AAAA,MACT;AAAA,IAKD;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AA0BA,SAAS,KAAM,QAAiB,aAAuB;AACtD,MAAK,CAAE,QAAS;AACf,UAAM,IAAI,MAAO,kCAAmC;AAAA,EACrD;AACA,QAAM,UAAU;AAEhB,MAAK,EAAI,aAAa,UAAY;AACjC,YAAS,SAAU,IAAI,CAAC;AAAA,EACzB;AACA,aAAW,IAAK,QAAS,SAAU,GAAG,WAAY;AACnD;AAyBA,SAAS,OAAmB,QAAqB;AAChD,MAAK,CAAE,QAAS;AACf,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AACA,QAAM,UAAU;AAEhB,MAAK,EAAI,aAAa,UAAY;AACjC,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,WAAW,IAAK,QAAS,SAAU,CAAE;AAC7C;AAEA,IAAM,aAAa,oBAAI,QAAQ;AAM/B,IAAM,YAAY,uBAAQ,gBAAiB;AAUpC,SAAS,gBAAiB,MAAe;AAC/C,kCAAgC,KAAM,IAAK;AAC5C;AAMO,SAAS,0BAA0B;AACzC,SAAQ,gCAAgC,QAAS;AAChD,oCAAgC,IAAI;AAAA,EACrC;AACD;",
|
|
4
|
+
"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/admin-ui',\n\t'@wordpress/api-fetch',\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/compose',\n\t'@wordpress/connectors',\n\t'@wordpress/workflows',\n\t'@wordpress/components',\n\t'@wordpress/content-types',\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/rich-text',\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-editor',\n\t'@wordpress/media-utils',\n\t'@wordpress/upload-media',\n\t'@wordpress/global-styles-ui',\n\t'@wordpress/ui',\n\t'@wordpress/views',\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,IAAM,kCAAkC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAgBA,IAAM,kBACL;AAUM,IAAM,mDAAmD,CAC/D,SACA,eACI;AACJ,MAAK,CAAE,gCAAgC,SAAU,UAAW,GAAI;AAC/D,UAAM,IAAI;AAAA,MACT,mDAAoD,UAAW;AAAA,IAKhE;AAAA,EACD;AACA,MAAK,YAAY,iBAAkB;AAClC,UAAM,IAAI;AAAA,MACT;AAAA,IAKD;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AA0BA,SAAS,KAAM,QAAiB,aAAuB;AACtD,MAAK,CAAE,QAAS;AACf,UAAM,IAAI,MAAO,kCAAmC;AAAA,EACrD;AACA,QAAM,UAAU;AAEhB,MAAK,EAAI,aAAa,UAAY;AACjC,YAAS,SAAU,IAAI,CAAC;AAAA,EACzB;AACA,aAAW,IAAK,QAAS,SAAU,GAAG,WAAY;AACnD;AAyBA,SAAS,OAAmB,QAAqB;AAChD,MAAK,CAAE,QAAS;AACf,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AACA,QAAM,UAAU;AAEhB,MAAK,EAAI,aAAa,UAAY;AACjC,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,WAAW,IAAK,QAAS,SAAU,CAAE;AAC7C;AAEA,IAAM,aAAa,oBAAI,QAAQ;AAM/B,IAAM,YAAY,uBAAQ,gBAAiB;AAUpC,SAAS,gBAAiB,MAAe;AAC/C,kCAAgC,KAAM,IAAK;AAC5C;AAMO,SAAS,0BAA0B;AACzC,SAAQ,gCAAgC,QAAS;AAChD,oCAAgC,IAAI;AAAA,EACrC;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// packages/private-apis/src/implementation.ts
|
|
2
2
|
var CORE_MODULES_USING_PRIVATE_APIS = [
|
|
3
3
|
"@wordpress/admin-ui",
|
|
4
|
+
"@wordpress/api-fetch",
|
|
4
5
|
"@wordpress/block-directory",
|
|
5
6
|
"@wordpress/block-editor",
|
|
6
7
|
"@wordpress/block-library",
|
|
7
8
|
"@wordpress/blocks",
|
|
8
9
|
"@wordpress/boot",
|
|
9
10
|
"@wordpress/commands",
|
|
11
|
+
"@wordpress/compose",
|
|
10
12
|
"@wordpress/connectors",
|
|
11
13
|
"@wordpress/workflows",
|
|
12
14
|
"@wordpress/components",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/implementation.ts"],
|
|
4
|
-
"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/admin-ui',\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/connectors',\n\t'@wordpress/workflows',\n\t'@wordpress/components',\n\t'@wordpress/content-types',\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/rich-text',\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-editor',\n\t'@wordpress/media-utils',\n\t'@wordpress/upload-media',\n\t'@wordpress/global-styles-ui',\n\t'@wordpress/ui',\n\t'@wordpress/views',\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"],
|
|
5
|
-
"mappings": ";AAWA,IAAM,kCAAkC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAgBA,IAAM,kBACL;AAUM,IAAM,mDAAmD,CAC/D,SACA,eACI;AACJ,MAAK,CAAE,gCAAgC,SAAU,UAAW,GAAI;AAC/D,UAAM,IAAI;AAAA,MACT,mDAAoD,UAAW;AAAA,IAKhE;AAAA,EACD;AACA,MAAK,YAAY,iBAAkB;AAClC,UAAM,IAAI;AAAA,MACT;AAAA,IAKD;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AA0BA,SAAS,KAAM,QAAiB,aAAuB;AACtD,MAAK,CAAE,QAAS;AACf,UAAM,IAAI,MAAO,kCAAmC;AAAA,EACrD;AACA,QAAM,UAAU;AAEhB,MAAK,EAAI,aAAa,UAAY;AACjC,YAAS,SAAU,IAAI,CAAC;AAAA,EACzB;AACA,aAAW,IAAK,QAAS,SAAU,GAAG,WAAY;AACnD;AAyBA,SAAS,OAAmB,QAAqB;AAChD,MAAK,CAAE,QAAS;AACf,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AACA,QAAM,UAAU;AAEhB,MAAK,EAAI,aAAa,UAAY;AACjC,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,WAAW,IAAK,QAAS,SAAU,CAAE;AAC7C;AAEA,IAAM,aAAa,oBAAI,QAAQ;AAM/B,IAAM,YAAY,uBAAQ,gBAAiB;AAUpC,SAAS,gBAAiB,MAAe;AAC/C,kCAAgC,KAAM,IAAK;AAC5C;AAMO,SAAS,0BAA0B;AACzC,SAAQ,gCAAgC,QAAS;AAChD,oCAAgC,IAAI;AAAA,EACrC;AACD;",
|
|
4
|
+
"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/admin-ui',\n\t'@wordpress/api-fetch',\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/compose',\n\t'@wordpress/connectors',\n\t'@wordpress/workflows',\n\t'@wordpress/components',\n\t'@wordpress/content-types',\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/rich-text',\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-editor',\n\t'@wordpress/media-utils',\n\t'@wordpress/upload-media',\n\t'@wordpress/global-styles-ui',\n\t'@wordpress/ui',\n\t'@wordpress/views',\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"],
|
|
5
|
+
"mappings": ";AAWA,IAAM,kCAAkC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAgBA,IAAM,kBACL;AAUM,IAAM,mDAAmD,CAC/D,SACA,eACI;AACJ,MAAK,CAAE,gCAAgC,SAAU,UAAW,GAAI;AAC/D,UAAM,IAAI;AAAA,MACT,mDAAoD,UAAW;AAAA,IAKhE;AAAA,EACD;AACA,MAAK,YAAY,iBAAkB;AAClC,UAAM,IAAI;AAAA,MACT;AAAA,IAKD;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AA0BA,SAAS,KAAM,QAAiB,aAAuB;AACtD,MAAK,CAAE,QAAS;AACf,UAAM,IAAI,MAAO,kCAAmC;AAAA,EACrD;AACA,QAAM,UAAU;AAEhB,MAAK,EAAI,aAAa,UAAY;AACjC,YAAS,SAAU,IAAI,CAAC;AAAA,EACzB;AACA,aAAW,IAAK,QAAS,SAAU,GAAG,WAAY;AACnD;AAyBA,SAAS,OAAmB,QAAqB;AAChD,MAAK,CAAE,QAAS;AACf,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AACA,QAAM,UAAU;AAEhB,MAAK,EAAI,aAAa,UAAY;AACjC,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,WAAW,IAAK,QAAS,SAAU,CAAE;AAC7C;AAEA,IAAM,aAAa,oBAAI,QAAQ;AAM/B,IAAM,YAAY,uBAAQ,gBAAiB;AAUpC,SAAS,gBAAiB,MAAe;AAC/C,kCAAgC,KAAM,IAAK;AAC5C;AAMO,SAAS,0BAA0B;AACzC,SAAQ,gCAAgC,QAAS;AAChD,oCAAgC,IAAI;AAAA,EACrC;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../src/implementation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../src/implementation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkEH;;;;;;;GAOG;AACH,eAAO,MAAM,gDAAgD,YACnD,MAAM,cACH,MAAM;;;CAyBlB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,IAAI,CAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,QAUnD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,MAAM,CAAE,CAAC,GAAG,GAAG,EAAI,MAAM,EAAE,OAAO,GAAI,CAAC,CAa/C;AAYD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAE,IAAI,EAAE,MAAM,QAE5C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,SAItC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/private-apis",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"description": "Internal experimental APIs for WordPress core.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "d653c5fd6161571a0c2ebde28553d6e25624eacc"
|
|
51
51
|
}
|
package/src/implementation.ts
CHANGED
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
*/
|
|
12
12
|
const CORE_MODULES_USING_PRIVATE_APIS = [
|
|
13
13
|
'@wordpress/admin-ui',
|
|
14
|
+
'@wordpress/api-fetch',
|
|
14
15
|
'@wordpress/block-directory',
|
|
15
16
|
'@wordpress/block-editor',
|
|
16
17
|
'@wordpress/block-library',
|
|
17
18
|
'@wordpress/blocks',
|
|
18
19
|
'@wordpress/boot',
|
|
19
20
|
'@wordpress/commands',
|
|
21
|
+
'@wordpress/compose',
|
|
20
22
|
'@wordpress/connectors',
|
|
21
23
|
'@wordpress/workflows',
|
|
22
24
|
'@wordpress/components',
|