@automattic/jetpack-connection 0.34.2 → 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,10 @@
|
|
|
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
|
+
|
|
5
9
|
## [0.34.2] - 2024-08-09
|
|
6
10
|
### Added
|
|
7
11
|
- React 19 compatibility: Making sure useRef includes an argument. [#38765]
|
|
@@ -812,6 +816,7 @@
|
|
|
812
816
|
- `Main` and `ConnectUser` components added.
|
|
813
817
|
- `JetpackRestApiClient` API client added.
|
|
814
818
|
|
|
819
|
+
[0.35.0]: https://github.com/Automattic/jetpack-connection-js/compare/v0.34.2...v0.35.0
|
|
815
820
|
[0.34.2]: https://github.com/Automattic/jetpack-connection-js/compare/v0.34.1...v0.34.2
|
|
816
821
|
[0.34.1]: https://github.com/Automattic/jetpack-connection-js/compare/v0.34.0...v0.34.1
|
|
817
822
|
[0.34.0]: https://github.com/Automattic/jetpack-connection-js/compare/v0.33.19...v0.34.0
|
|
@@ -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
|
|
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
|
|
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
|
|
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 } =
|
|
7
|
-
|
|
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.
|
|
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": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@automattic/jetpack-api": "^0.17.9",
|
|
19
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",
|
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(
|