@automattic/jetpack-shared-extension-utils 0.15.3 → 0.15.4

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,10 @@ 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
+ ## [0.15.4] - 2024-08-21
9
+ ### Changed
10
+ - Internal updates.
11
+
8
12
  ## [0.15.3] - 2024-08-15
9
13
  ### Changed
10
14
  - Updated package dependencies. [#38662]
@@ -428,6 +432,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
428
432
  ### Changed
429
433
  - Core: prepare utility for release
430
434
 
435
+ [0.15.4]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.15.3...0.15.4
431
436
  [0.15.3]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.15.2...0.15.3
432
437
  [0.15.2]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.15.1...0.15.2
433
438
  [0.15.1]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.15.0...0.15.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-shared-extension-utils",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
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": {
@@ -17,9 +17,9 @@
17
17
  "test": "jest"
18
18
  },
19
19
  "dependencies": {
20
- "@automattic/jetpack-analytics": "^0.1.29",
21
- "@automattic/jetpack-components": "^0.55.7",
22
- "@automattic/jetpack-connection": "^0.35.1",
20
+ "@automattic/jetpack-analytics": "^0.1.30",
21
+ "@automattic/jetpack-components": "^0.55.9",
22
+ "@automattic/jetpack-connection": "^0.35.3",
23
23
  "@wordpress/api-fetch": "7.5.0",
24
24
  "@wordpress/compose": "7.5.0",
25
25
  "@wordpress/data": "10.5.0",
@@ -6,7 +6,7 @@ import './style.scss';
6
6
  /**
7
7
  * The Jetpack logo used for block editor panels
8
8
  *
9
- * @returns {React.Component} Jetpack logo component
9
+ * @return {React.Component} Jetpack logo component
10
10
  */
11
11
  const JetpackEditorPanelLogo = () => (
12
12
  <JetpackLogo
@@ -10,7 +10,7 @@ import getIconColor from './get-icon-color';
10
10
  * dynamically set the icon color later on.
11
11
  *
12
12
  * @param {object} metadata - Block.json content
13
- * @returns {React.Component} Icon component
13
+ * @return {React.Component} Icon component
14
14
  */
15
15
  export function getBlockIconComponent( metadata ) {
16
16
  // Set default values
@@ -46,7 +46,7 @@ export function getBlockIconComponent( metadata ) {
46
46
  * of the icon.
47
47
  *
48
48
  * @param {object} metadata - Block.json content
49
- * @returns {object} Icon property for client registration
49
+ * @return {object} Icon property for client registration
50
50
  */
51
51
  export function getBlockIconProp( metadata ) {
52
52
  return {
@@ -10,7 +10,7 @@ import getIconColor from './get-icon-color';
10
10
  * dynamically set the icon color later on.
11
11
  *
12
12
  * @param {object} metadata - Block.json content
13
- * @returns {React.JSX.Element|string} Icon component
13
+ * @return {React.JSX.Element|string} Icon component
14
14
  */
15
15
  export function getBlockIconComponent( metadata ) {
16
16
  // If the SVG has been passed as a string, use SvgXml to correctly parse it.
@@ -27,7 +27,7 @@ export function getBlockIconComponent( metadata ) {
27
27
  * of the icon.
28
28
  *
29
29
  * @param {object} metadata - Block.json content
30
- * @returns {object} Icon property for client registration
30
+ * @return {object} Icon property for client registration
31
31
  */
32
32
  export function getBlockIconProp( metadata ) {
33
33
  return {
@@ -7,7 +7,7 @@ import { select } from '@wordpress/data';
7
7
  /**
8
8
  * Retrieves host app's namespace e.g. "WordPress" or "Jetpack".
9
9
  *
10
- * @returns {string} hostAppNamespace The host app's namespace.
10
+ * @return {string} hostAppNamespace The host app's namespace.
11
11
  */
12
12
  export default function getHostAppNamespace() {
13
13
  return select( blockEditorStore ).getSettings().hostAppNamespace;
@@ -10,7 +10,7 @@ const JETPACK_GREEN_40 = '#069e08';
10
10
  *
11
11
  * Green in the Jetpack context, otherwise black for Simple sites or Atomic sites.
12
12
  *
13
- * @returns {string} HEX color for block editor icons
13
+ * @return {string} HEX color for block editor icons
14
14
  */
15
15
  export default function getIconColor() {
16
16
  if ( isAtomicSite() || isSimpleSite() ) {
@@ -2,7 +2,7 @@ import getJetpackData from './get-jetpack-data';
2
2
  /**
3
3
  * Returns the jetpack block variation that is defined on the backend.
4
4
  *
5
- * @returns {?string} options are ['production', 'beta', 'experimental']
5
+ * @return {?string} options are ['production', 'beta', 'experimental']
6
6
  */
7
7
  export default function getJetpackBlocksVariation() {
8
8
  const data = getJetpackData();
@@ -3,7 +3,7 @@ export const JETPACK_DATA_PATH = 'Jetpack_Editor_Initial_State';
3
3
  /**
4
4
  * Retrieves Jetpack editor state
5
5
  *
6
- * @returns {object|null}Object The Jetpack Editor State.
6
+ * @return {object|null}Object The Jetpack Editor State.
7
7
  */
8
8
  export default function getJetpackData() {
9
9
  return 'object' === typeof window ? window?.[ JETPACK_DATA_PATH ] ?? null : null;
@@ -4,7 +4,7 @@ import getJetpackData from './get-jetpack-data';
4
4
  * Return whether a Jetpack Gutenberg extension is available or not.
5
5
  *
6
6
  * @param {string} name - The extension's name (without the `jetpack/` prefix)
7
- * @returns {object} Object indicating if the extension is available (property `available`) and the reason why it is
7
+ * @return {object} Object indicating if the extension is available (property `available`) and the reason why it is
8
8
  * unavailable (property `unavailable_reason`).
9
9
  */
10
10
  export default function getJetpackExtensionAvailability( name ) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Returns the site fragment (slug) in the environment we're running Gutenberg in.
3
3
  *
4
- * @returns {?string} Site fragment (slug)
4
+ * @return {?string} Site fragment (slug)
5
5
  */
6
6
  export default function getSiteFragment() {
7
7
  // Gutenberg in Jetpack adds a site fragment in the initial state
@@ -6,7 +6,7 @@ import { JETPACK_MODULES_STORE_ID } from '../../modules-state';
6
6
  * Manage a Jetpack module's status (get and set).
7
7
  *
8
8
  * @param {string} name - The module's name.
9
- * @returns {boolean} Whether the module is active.
9
+ * @return {boolean} Whether the module is active.
10
10
  */
11
11
  const useModuleStatus = name => {
12
12
  const { isModuleActive, isChangingStatus, isLoadingModules } = useSelect(
@@ -3,7 +3,7 @@ import getJetpackData from './get-jetpack-data';
3
3
  /**
4
4
  * Return whether the current user is connected to WP.com.
5
5
  *
6
- * @returns {boolean} Whether the current user is connected.
6
+ * @return {boolean} Whether the current user is connected.
7
7
  */
8
8
  export default function isCurrentUserConnected() {
9
9
  return getJetpackData()?.jetpack?.is_current_user_connected ?? false;
@@ -6,7 +6,7 @@ import getJetpackData from './get-jetpack-data';
6
6
  * @see https://github.com/Automattic/jetpack/pull/38500 introduced the is_my_jetpack_available flag
7
7
  * The value is the same that can be found on Initial_State.siteData.showMyJetpack (dashboard context)
8
8
  *
9
- * @returns {boolean} Object indicating if My Jetpack is available (so to navigate to interstitials and product pages)
9
+ * @return {boolean} Object indicating if My Jetpack is available (so to navigate to interstitials and product pages)
10
10
  */
11
11
  export default function isMyJetpackAvailable() {
12
12
  return getJetpackData()?.jetpack?.is_my_jetpack_available === true;
@@ -12,11 +12,11 @@ export const SET_MODULE_UPDATING = 'SET_MODULE_UPDATING';
12
12
  /**
13
13
  * Yield actions to update module status
14
14
  *
15
- * @param {object} settings - Jetpack module settings.
16
- * @param {string} settings.name - Jetpack module name.
15
+ * @param {object} settings - Jetpack module settings.
16
+ * @param {string} settings.name - Jetpack module name.
17
17
  * @param {boolean} settings.active - If the module is active or not.
18
- * @yields {object} - an action object.
19
- * @returns {object} - an action object.
18
+ * @yield {object} - an action object.
19
+ * @return {object} - an action object.
20
20
  */
21
21
  export function* updateJetpackModuleStatus( settings ) {
22
22
  try {
@@ -36,8 +36,8 @@ export function* updateJetpackModuleStatus( settings ) {
36
36
 
37
37
  /**
38
38
  * Yield actions to update module status
39
- * @yields {object} - an action object.
40
- * @returns {boolean} - if operation is successful or not.
39
+ * @yield {object} - an action object.
40
+ * @return {boolean} - if operation is successful or not.
41
41
  */
42
42
  export function* fetchModules() {
43
43
  // We don't fetch modules for Simple Site and aknowledge that all modules are active
@@ -62,7 +62,7 @@ export function* fetchModules() {
62
62
  * Set modules as loading action
63
63
  *
64
64
  * @param {boolean} isLoading - If the modules are loading or not.
65
- * @returns {object} - an action object.
65
+ * @return {object} - an action object.
66
66
  */
67
67
  function setIsLoading( isLoading ) {
68
68
  return setJetpackModules( { isLoading } );
@@ -71,9 +71,9 @@ function setIsLoading( isLoading ) {
71
71
  /**
72
72
  * Set modules as updating action
73
73
  *
74
- * @param {string} name - Name of the module.
74
+ * @param {string} name - Name of the module.
75
75
  * @param {boolean} isUpdating - If the modules are updating or not.
76
- * @returns {object} - an action object.
76
+ * @return {object} - an action object.
77
77
  */
78
78
  function setIsUpdating( name, isUpdating ) {
79
79
  return { type: SET_MODULE_UPDATING, name, isUpdating };
@@ -82,10 +82,10 @@ function setIsUpdating( name, isUpdating ) {
82
82
  /**
83
83
  * Set Jetpack module action
84
84
  *
85
- * @param {object} options - Jetpack settings.
86
- * @param {object} options.modules - Jetpack modules.
85
+ * @param {object} options - Jetpack settings.
86
+ * @param {object} options.modules - Jetpack modules.
87
87
  * @param {boolean} options.isLoading - If the modules are loading or not.
88
- * @returns {object} - an action object.
88
+ * @return {object} - an action object.
89
89
  */
90
90
  export function setJetpackModules( options ) {
91
91
  return { type: SET_JETPACK_MODULES, options };
@@ -6,7 +6,7 @@ export const UPDATE_JETPACK_MODULE_STATUS = 'UPDATE_JETPACK_MODULE_STATUS';
6
6
  /**
7
7
  * fetchJetpackModules action
8
8
  *
9
- * @returns {object} - an action object.
9
+ * @return {object} - an action object.
10
10
  */
11
11
  export const fetchJetpackModules = () => {
12
12
  return {
@@ -17,8 +17,8 @@ export const fetchJetpackModules = () => {
17
17
  /**
18
18
  * Updating single module status action
19
19
  *
20
- * @param settings - Jetpack module settings.
21
- * @param {string} settings.name - Jetpack module name.
20
+ * @param settings - Jetpack module settings.
21
+ * @param {string} settings.name - Jetpack module name.
22
22
  * @param {boolean} settings.active - If the module is active or not.
23
23
  */
24
24
 
@@ -4,8 +4,8 @@ import { fetchJetpackModules } from './controls';
4
4
  /**
5
5
  * Yield actions to get the Jetpack modules.
6
6
  *
7
- * @yields {object} - an action object.
8
- * @returns {object} - an action object.
7
+ * @yield {object} - an action object.
8
+ * @return {object} - an action object.
9
9
  */
10
10
  export function* getJetpackModules() {
11
11
  try {
package/src/plan-utils.js CHANGED
@@ -10,12 +10,12 @@ import { isAtomicSite, isSimpleSite } from './site-type-utils';
10
10
  * Return the checkout URL to upgrade the site plan,
11
11
  * depending on the plan, postId, and postType site values.
12
12
  *
13
- * @param {object} siteParams - Site params used to build the URL.
13
+ * @param {object} siteParams - Site params used to build the URL.
14
14
  * @param {string} siteParams.planSlug - Plan slug.
15
- * @param {object} siteParams.plan - An object with details about the plan.
16
- * @param {number} siteParams.postId - Post id.
15
+ * @param {object} siteParams.plan - An object with details about the plan.
16
+ * @param {number} siteParams.postId - Post id.
17
17
  * @param {string} siteParams.postType - Post type.
18
- * @returns {string} Upgrade URL.
18
+ * @return {string} Upgrade URL.
19
19
  */
20
20
  export function getUpgradeUrl( { planSlug, plan, postId, postType } ) {
21
21
  // WP.com plan objects have a dedicated `path_slug` field, Jetpack plan objects don't.
@@ -88,7 +88,7 @@ export function getUpgradeUrl( { planSlug, plan, postId, postType } ) {
88
88
  * the block requires a paid plan.
89
89
  *
90
90
  * @param {string} name - Block name.
91
- * @returns {boolean} True if the block is upgradable, false otherwise.
91
+ * @return {boolean} True if the block is upgradable, false otherwise.
92
92
  */
93
93
  export function isUpgradable( name ) {
94
94
  if ( ! name ) {
@@ -105,8 +105,8 @@ export function isUpgradable( name ) {
105
105
  * Checks whether the block requires a paid plan or not.
106
106
  *
107
107
  * @param {string} unavailableReason - The reason why block is unavailable
108
- * @param {object} details - The block details
109
- * @returns {string|boolean} Either false if the block doesn't require a paid plan, or the actual plan name it requires.
108
+ * @param {object} details - The block details
109
+ * @return {string|boolean} Either false if the block doesn't require a paid plan, or the actual plan name it requires.
110
110
  */
111
111
  export function requiresPaidPlan( unavailableReason, details ) {
112
112
  if ( unavailableReason === 'missing_plan' ) {
@@ -119,7 +119,7 @@ export function requiresPaidPlan( unavailableReason, details ) {
119
119
  * Returns the required plan slug for a passed block name.
120
120
  *
121
121
  * @param {string} name - Block name.
122
- * @returns {string|boolean} Plan name if the block is upgradable, false otherwise.
122
+ * @return {string|boolean} Plan name if the block is upgradable, false otherwise.
123
123
  */
124
124
  export function getRequiredPlan( name ) {
125
125
  if ( ! name ) {
@@ -158,7 +158,7 @@ const usableBlockWithFreePlan = [
158
158
  /**
159
159
  * Return whether upgrade nudges are enabled or not.
160
160
  *
161
- * @returns {boolean} True if the Upgrade Nudge is enable. Otherwise, False.
161
+ * @return {boolean} True if the Upgrade Nudge is enable. Otherwise, False.
162
162
  */
163
163
  export function isUpgradeNudgeEnabled() {
164
164
  return get( getJetpackData(), 'jetpack.enable_upgrade_nudge', false );
@@ -4,9 +4,9 @@ import getJetpackExtensionAvailability from './get-jetpack-extension-availabilit
4
4
  /**
5
5
  * Registers a Gutenberg block if the availability requirements are met.
6
6
  *
7
- * @param {string} name - The plugin's name
7
+ * @param {string} name - The plugin's name
8
8
  * @param {object} settings - The plugin's settings.
9
- * @returns {object|boolean} Either false if the plugin is not available, or the results of `registerPlugin`
9
+ * @return {object|boolean} Either false if the plugin is not available, or the results of `registerPlugin`
10
10
  */
11
11
  export default function registerJetpackPlugin( name, settings ) {
12
12
  const { available, unavailableReason } = getJetpackExtensionAvailability( name );
@@ -3,7 +3,7 @@ import getJetpackData from './get-jetpack-data';
3
3
  /**
4
4
  * Get the site type from environment
5
5
  *
6
- * @returns {(string|null)} Site type
6
+ * @return {(string|null)} Site type
7
7
  */
8
8
  function getSiteType() {
9
9
  return 'object' === typeof window && typeof window._currentSiteType === 'string'
@@ -14,7 +14,7 @@ function getSiteType() {
14
14
  /**
15
15
  * Check if environment is Simple site.
16
16
  *
17
- * @returns {boolean} True for Simple sites.
17
+ * @return {boolean} True for Simple sites.
18
18
  */
19
19
  export function isSimpleSite() {
20
20
  return getSiteType() === 'simple';
@@ -23,7 +23,7 @@ export function isSimpleSite() {
23
23
  /**
24
24
  * Check if environment is Atomic site.
25
25
  *
26
- * @returns {boolean} True for Atomic sites.
26
+ * @return {boolean} True for Atomic sites.
27
27
  */
28
28
  export function isAtomicSite() {
29
29
  return getSiteType() === 'atomic';
@@ -32,7 +32,7 @@ export function isAtomicSite() {
32
32
  /**
33
33
  * Return whether the current blog is set to private. (if blog_public option is -1)
34
34
  *
35
- * @returns {boolean} whether the current blog is set to private.
35
+ * @return {boolean} whether the current blog is set to private.
36
36
  */
37
37
  export function isPrivateSite() {
38
38
  const jetpackData = getJetpackData();
@@ -43,7 +43,7 @@ export function isPrivateSite() {
43
43
  * Return whether the current site is coming soon (i.e. not launched yet).
44
44
  * This is only available for WordPress.com sites so far.
45
45
  *
46
- * @returns {boolean} whether the current site is coming soon.
46
+ * @return {boolean} whether the current site is coming soon.
47
47
  */
48
48
  export function isComingSoon() {
49
49
  const jetpackData = getJetpackData();