@automattic/jetpack-shared-extension-utils 1.1.3 → 1.2.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 CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.2.0] - 2025-06-23
9
+ ### Added
10
+ - Add `hasFeatureFlag` JS function that can be added via the `jetpack_block_editor_feature_flags` filter. [#43918]
11
+
12
+ ### Changed
13
+ - Scripts: Change imports for hosting checks. [#43972]
14
+
8
15
  ## [1.1.3] - 2025-06-23
9
16
  ### Changed
10
17
  - Update package dependencies. [#44020]
@@ -673,6 +680,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
673
680
  ### Changed
674
681
  - Core: prepare utility for release
675
682
 
683
+ [1.2.0]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.1.3...1.2.0
676
684
  [1.1.3]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.1.2...1.1.3
677
685
  [1.1.2]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.1.1...1.1.2
678
686
  [1.1.1]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.1.0...1.1.1
package/index.js CHANGED
@@ -25,6 +25,7 @@ export { getBlockIconComponent, getBlockIconProp } from './src/get-block-icon-fr
25
25
  export { default as getJetpackBlocksVariation } from './src/get-jetpack-blocks-variation';
26
26
  export * from './src/modules-state';
27
27
  export { default as isMyJetpackAvailable } from './src/is-my-jetpack-available';
28
+ export { default as hasFeatureFlag } from './src/has-feature-flag';
28
29
  export * from './src/libs';
29
30
  export { default as useUpgradeFlow } from './src/hooks/use-upgrade-flow';
30
31
  export * from './src/block-editor-actions';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-shared-extension-utils",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Utility functions used by the block editor extensions",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/shared-extension-utils/#readme",
6
6
  "bugs": {
@@ -1,5 +1,5 @@
1
1
  import colorStudio from '@automattic/color-studio';
2
- import { isAtomicSite, isSimpleSite } from './site-type-utils';
2
+ import { isWpcomPlatformSite } from '@automattic/jetpack-script-data';
3
3
 
4
4
  /**
5
5
  * Constants
@@ -15,7 +15,7 @@ const COLOR_JETPACK = PALETTE[ 'Jetpack Green 40' ];
15
15
  * @return {string} HEX color for block editor icons
16
16
  */
17
17
  export function getIconColor() {
18
- if ( isAtomicSite() || isSimpleSite() ) {
18
+ if ( isWpcomPlatformSite() ) {
19
19
  // Return null to match core block styling
20
20
  return null;
21
21
  }
@@ -1,4 +1,4 @@
1
- import { isAtomicSite, isSimpleSite } from './site-type-utils';
1
+ import { isWpcomPlatformSite } from '@automattic/jetpack-script-data';
2
2
 
3
3
  /**
4
4
  * Constants
@@ -13,7 +13,7 @@ const JETPACK_GREEN_40 = '#069e08';
13
13
  * @return {string} HEX color for block editor icons
14
14
  */
15
15
  export default function getIconColor() {
16
- if ( isAtomicSite() || isSimpleSite() ) {
16
+ if ( isWpcomPlatformSite() ) {
17
17
  // Return null to match core block styling
18
18
  return null;
19
19
  }
@@ -0,0 +1,21 @@
1
+ import getJetpackData from './get-jetpack-data';
2
+
3
+ /**
4
+ * Return the value of the Jetpack feature flag.
5
+ *
6
+ * To add a new feature flag, you need use the `jetpack_block_editor_feature_flags` filter.
7
+ *
8
+ * @param {string} flag - The feature flag to check.
9
+ *
10
+ * @return {boolean} Whether the current user is connected.
11
+ */
12
+ export default function hasFeatureFlag( flag ) {
13
+ const jetpackData = getJetpackData();
14
+ if ( ! jetpackData ) {
15
+ return false;
16
+ }
17
+ if ( ! jetpackData?.feature_flags ) {
18
+ return false;
19
+ }
20
+ return Boolean( jetpackData.feature_flags?.[ flag ] );
21
+ }
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
+ import { isWoASite, isSimpleSite } from '@automattic/jetpack-script-data';
4
5
  import debugFactory from 'debug';
5
- import { isAtomicSite, isSimpleSite } from '../../site-type-utils';
6
6
 
7
7
  const initialState = window?.JP_CONNECTION_INITIAL_STATE;
8
8
  const debug = debugFactory( 'shared-extension-utils:connection' );
@@ -26,7 +26,7 @@ export function isUserConnected(): boolean {
26
26
  return true;
27
27
  }
28
28
 
29
- if ( isAtomicSite() ) {
29
+ if ( isWoASite() ) {
30
30
  debugOnce( 'Atomic site connected ✅' );
31
31
  return true;
32
32
  }
@@ -1,5 +1,5 @@
1
+ import { isSimpleSite } from '@automattic/jetpack-script-data';
1
2
  import { select } from '@wordpress/data';
2
- import { isSimpleSite } from '../site-type-utils';
3
3
  import {
4
4
  fetchJetpackModules,
5
5
  updateJetpackModuleStatus as updateJetpackModuleStatusControl,
@@ -1,4 +1,4 @@
1
- import { isSimpleSite } from '../site-type-utils';
1
+ import { isSimpleSite } from '@automattic/jetpack-script-data';
2
2
 
3
3
  const jetpackModulesSelectors = {
4
4
  getJetpackModules: state => state.data,
package/src/plan-utils.js CHANGED
@@ -1,10 +1,10 @@
1
+ import { isWoASite, isSimpleSite } from '@automattic/jetpack-script-data';
1
2
  import { __ } from '@wordpress/i18n';
2
3
  import { addQueryArgs } from '@wordpress/url';
3
4
  import { compact, get, startsWith, map, filter, head } from 'lodash';
4
5
  import getJetpackData from './get-jetpack-data';
5
6
  import getJetpackExtensionAvailability from './get-jetpack-extension-availability';
6
7
  import getSiteFragment from './get-site-fragment';
7
- import { isAtomicSite, isSimpleSite } from './site-type-utils';
8
8
 
9
9
  /**
10
10
  * Return the checkout URL to upgrade the site plan,
@@ -68,7 +68,7 @@ export function getUpgradeUrl( { planSlug, plan, postId, postType } ) {
68
68
  )();
69
69
 
70
70
  // Redirect to calypso plans page for WoC sites.
71
- if ( isAtomicSite() ) {
71
+ if ( isWoASite() ) {
72
72
  return addQueryArgs( `https://wordpress.com/plans/${ getSiteFragment() }`, {
73
73
  redirect_to,
74
74
  customerType: 'business',