@automattic/jetpack-connection 0.34.1 → 0.35.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
@@ -2,6 +2,17 @@
2
2
 
3
3
  ### This is a list detailing changes for the Jetpack RNA Connection Component releases.
4
4
 
5
+ ## [0.35.0] - 2024-08-13
6
+ ### Added
7
+ - Updated the connection initial state to fallback on the new consolidated Jetpack script data [#38825]
8
+
9
+ ## [0.34.2] - 2024-08-09
10
+ ### Added
11
+ - React 19 compatibility: Making sure useRef includes an argument. [#38765]
12
+
13
+ ### Removed
14
+ - Tests: Removed react-test-renderer. [#38755]
15
+
5
16
  ## [0.34.1] - 2024-07-22
6
17
  ### Added
7
18
  - Display the proper error message for suspended sites on site registration. [#38359]
@@ -805,6 +816,8 @@
805
816
  - `Main` and `ConnectUser` components added.
806
817
  - `JetpackRestApiClient` API client added.
807
818
 
819
+ [0.35.0]: https://github.com/Automattic/jetpack-connection-js/compare/v0.34.2...v0.35.0
820
+ [0.34.2]: https://github.com/Automattic/jetpack-connection-js/compare/v0.34.1...v0.34.2
808
821
  [0.34.1]: https://github.com/Automattic/jetpack-connection-js/compare/v0.34.0...v0.34.1
809
822
  [0.34.0]: https://github.com/Automattic/jetpack-connection-js/compare/v0.33.19...v0.34.0
810
823
  [0.33.19]: https://github.com/Automattic/jetpack-connection-js/compare/v0.33.18...v0.33.19
@@ -34,8 +34,8 @@ const InPlaceConnection = props => {
34
34
  } = props;
35
35
  let { height = '300' } = props;
36
36
 
37
- const iframeWrapRef = useRef();
38
- const iframeRef = useRef();
37
+ const iframeWrapRef = useRef( undefined );
38
+ const iframeRef = useRef( undefined );
39
39
 
40
40
  /**
41
41
  * Handles messages received from inside the iframe.
@@ -1,9 +1,10 @@
1
1
  import restApi from '@automattic/jetpack-api';
2
+ import { getScriptData } from '@automattic/jetpack-script-data';
2
3
  import { useSelect, useDispatch } from '@wordpress/data';
3
4
  import { useEffect } from 'react';
4
5
  import { STORE_ID } from '../../state/store';
5
6
 
6
- const initialState = window?.JP_CONNECTION_INITIAL_STATE ? window.JP_CONNECTION_INITIAL_STATE : {};
7
+ const initialState = window?.JP_CONNECTION_INITIAL_STATE || getScriptData()?.connection || {};
7
8
 
8
9
  export default ( {
9
10
  registrationNonce = initialState.registrationNonce,
@@ -1,11 +1,15 @@
1
+ import { getScriptData } from '@automattic/jetpack-script-data';
2
+
1
3
  /**
2
4
  * Get the Calypso origin based on the development environment.
3
5
  *
4
6
  * @returns {string} The Calypso url origin.
5
7
  */
6
8
  export default function getCalypsoOrigin() {
7
- const calypsoEnv =
8
- typeof window !== 'undefined' && window?.JP_CONNECTION_INITIAL_STATE?.calypsoEnv;
9
+ const calypsoEnv = (
10
+ ( typeof window !== 'undefined' && window?.JP_CONNECTION_INITIAL_STATE ) ||
11
+ getScriptData()?.connection
12
+ )?.calypsoEnv;
9
13
 
10
14
  switch ( calypsoEnv ) {
11
15
  case 'development':
@@ -1,5 +1,6 @@
1
1
  import restApi from '@automattic/jetpack-api';
2
2
  import { getCalypsoOrigin } from '@automattic/jetpack-connection';
3
+ import { getScriptData } from '@automattic/jetpack-script-data';
3
4
  import { useDispatch, useSelect } from '@wordpress/data';
4
5
  import debugFactory from 'debug';
5
6
  import { useEffect, useState, useMemo } from 'react';
@@ -13,7 +14,7 @@ const {
13
14
  apiRoot,
14
15
  apiNonce,
15
16
  siteSuffix: defaultSiteSuffix,
16
- } = window?.JP_CONNECTION_INITIAL_STATE ? window.JP_CONNECTION_INITIAL_STATE : {};
17
+ } = window?.JP_CONNECTION_INITIAL_STATE || getScriptData()?.connection || {};
17
18
  const defaultAdminUrl =
18
19
  typeof window !== 'undefined' ? window?.myJetpackInitialState?.adminUrl : null;
19
20
 
@@ -1,11 +1,11 @@
1
1
  import restApi from '@automattic/jetpack-api';
2
+ import { getScriptData } from '@automattic/jetpack-script-data';
2
3
  import { useDispatch } from '@wordpress/data';
3
4
  import { useEffect, useState } from 'react';
4
5
  import { STORE_ID } from '../../state/store';
5
6
 
6
- const { apiRoot, apiNonce } = window?.JP_CONNECTION_INITIAL_STATE
7
- ? window.JP_CONNECTION_INITIAL_STATE
8
- : {};
7
+ const { apiRoot, apiNonce } =
8
+ window?.JP_CONNECTION_INITIAL_STATE || getScriptData()?.connection || {};
9
9
 
10
10
  /**
11
11
  * Restore connection hook.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-connection",
3
- "version": "0.34.1",
3
+ "version": "0.35.0",
4
4
  "description": "Jetpack Connection Component",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/connection/#readme",
6
6
  "bugs": {
@@ -16,8 +16,9 @@
16
16
  "dependencies": {
17
17
  "@automattic/jetpack-analytics": "^0.1.29",
18
18
  "@automattic/jetpack-api": "^0.17.9",
19
- "@automattic/jetpack-components": "^0.55.0",
19
+ "@automattic/jetpack-components": "^0.55.6",
20
20
  "@automattic/jetpack-config": "^0.1.24",
21
+ "@automattic/jetpack-script-data": "^0.1.1",
21
22
  "@wordpress/base-styles": "5.2.0",
22
23
  "@wordpress/browserslist-config": "6.2.0",
23
24
  "@wordpress/components": "28.2.0",
@@ -41,8 +42,7 @@
41
42
  "jest": "29.7.0",
42
43
  "jest-environment-jsdom": "29.7.0",
43
44
  "react": "18.3.1",
44
- "react-dom": "18.3.1",
45
- "react-test-renderer": "18.3.1"
45
+ "react-dom": "18.3.1"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "react": "^18.0.0",
package/state/store.jsx CHANGED
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable no-console */
2
2
 
3
+ import { getScriptData } from '@automattic/jetpack-script-data';
3
4
  import actions from './actions';
4
5
  import controls from './controls';
5
6
  import reducer from './reducers';
@@ -8,7 +9,7 @@ import selectors from './selectors';
8
9
  import storeHolder from './store-holder';
9
10
  import STORE_ID from './store-id';
10
11
 
11
- const initialState = window.JP_CONNECTION_INITIAL_STATE;
12
+ const initialState = window.JP_CONNECTION_INITIAL_STATE || getScriptData()?.connection;
12
13
 
13
14
  if ( ! initialState ) {
14
15
  console.error(