@sitecore-jss/sitecore-jss-nextjs 21.7.0-canary.49 → 21.7.0-canary.50
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.
|
@@ -20,6 +20,7 @@ class Context {
|
|
|
20
20
|
* Promises for the SDKs
|
|
21
21
|
*/
|
|
22
22
|
this.sdkPromises = {};
|
|
23
|
+
this.sdkErrors = {};
|
|
23
24
|
/**
|
|
24
25
|
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
25
26
|
*
|
|
@@ -27,7 +28,14 @@ class Context {
|
|
|
27
28
|
* @returns initialized SDK
|
|
28
29
|
*/
|
|
29
30
|
this.getSDK = (name) => {
|
|
30
|
-
|
|
31
|
+
if (!this.sdkPromises[name]) {
|
|
32
|
+
return Promise.reject(`Unknown SDK '${String(name)}'`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return this.sdkPromises[name].then((result) => {
|
|
36
|
+
return ((this.sdkErrors[name] && Promise.reject(this.sdkErrors[name])) || Promise.resolve(result));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
31
39
|
};
|
|
32
40
|
this.sitecoreEdgeUrl = props.sitecoreEdgeUrl;
|
|
33
41
|
this.sitecoreEdgeContextId = props.sitecoreEdgeContextId;
|
|
@@ -57,7 +65,7 @@ class Context {
|
|
|
57
65
|
* @returns {void}
|
|
58
66
|
*/
|
|
59
67
|
initSDK(name) {
|
|
60
|
-
this.sdkPromises[name] = new Promise((resolve
|
|
68
|
+
this.sdkPromises[name] = new Promise((resolve) => {
|
|
61
69
|
this.props.sdks[name]
|
|
62
70
|
.init(this)
|
|
63
71
|
.then(() => {
|
|
@@ -65,8 +73,9 @@ class Context {
|
|
|
65
73
|
resolve(this.sdks[name]);
|
|
66
74
|
})
|
|
67
75
|
.catch((e) => {
|
|
68
|
-
// if init rejects, getSDK
|
|
69
|
-
|
|
76
|
+
// if init rejects, we mark SDK as failed - so getSDK call would reject with a reason
|
|
77
|
+
this.sdkErrors[name] = e;
|
|
78
|
+
resolve(undefined);
|
|
70
79
|
});
|
|
71
80
|
});
|
|
72
81
|
}
|
|
@@ -17,6 +17,7 @@ export class Context {
|
|
|
17
17
|
* Promises for the SDKs
|
|
18
18
|
*/
|
|
19
19
|
this.sdkPromises = {};
|
|
20
|
+
this.sdkErrors = {};
|
|
20
21
|
/**
|
|
21
22
|
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
22
23
|
*
|
|
@@ -24,7 +25,14 @@ export class Context {
|
|
|
24
25
|
* @returns initialized SDK
|
|
25
26
|
*/
|
|
26
27
|
this.getSDK = (name) => {
|
|
27
|
-
|
|
28
|
+
if (!this.sdkPromises[name]) {
|
|
29
|
+
return Promise.reject(`Unknown SDK '${String(name)}'`);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return this.sdkPromises[name].then((result) => {
|
|
33
|
+
return ((this.sdkErrors[name] && Promise.reject(this.sdkErrors[name])) || Promise.resolve(result));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
28
36
|
};
|
|
29
37
|
this.sitecoreEdgeUrl = props.sitecoreEdgeUrl;
|
|
30
38
|
this.sitecoreEdgeContextId = props.sitecoreEdgeContextId;
|
|
@@ -54,7 +62,7 @@ export class Context {
|
|
|
54
62
|
* @returns {void}
|
|
55
63
|
*/
|
|
56
64
|
initSDK(name) {
|
|
57
|
-
this.sdkPromises[name] = new Promise((resolve
|
|
65
|
+
this.sdkPromises[name] = new Promise((resolve) => {
|
|
58
66
|
this.props.sdks[name]
|
|
59
67
|
.init(this)
|
|
60
68
|
.then(() => {
|
|
@@ -62,8 +70,9 @@ export class Context {
|
|
|
62
70
|
resolve(this.sdks[name]);
|
|
63
71
|
})
|
|
64
72
|
.catch((e) => {
|
|
65
|
-
// if init rejects, getSDK
|
|
66
|
-
|
|
73
|
+
// if init rejects, we mark SDK as failed - so getSDK call would reject with a reason
|
|
74
|
+
this.sdkErrors[name] = e;
|
|
75
|
+
resolve(undefined);
|
|
67
76
|
});
|
|
68
77
|
});
|
|
69
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "21.7.0-canary.
|
|
3
|
+
"version": "21.7.0-canary.50",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"react-dom": "^18.2.0"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@sitecore-jss/sitecore-jss": "^21.7.0-canary.
|
|
76
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "^21.7.0-canary.
|
|
77
|
-
"@sitecore-jss/sitecore-jss-react": "^21.7.0-canary.
|
|
75
|
+
"@sitecore-jss/sitecore-jss": "^21.7.0-canary.50",
|
|
76
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^21.7.0-canary.50",
|
|
77
|
+
"@sitecore-jss/sitecore-jss-react": "^21.7.0-canary.50",
|
|
78
78
|
"@vercel/kv": "^0.2.1",
|
|
79
79
|
"node-html-parser": "^6.1.4",
|
|
80
80
|
"prop-types": "^15.8.1",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"description": "",
|
|
85
85
|
"types": "types/index.d.ts",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "2280864898b84d0472c54175075a1628e63a29b0",
|
|
87
87
|
"files": [
|
|
88
88
|
"dist",
|
|
89
89
|
"types",
|
|
@@ -93,6 +93,9 @@ export declare class Context<SDKModules extends SDKModulesType> {
|
|
|
93
93
|
protected sdkPromises: {
|
|
94
94
|
[module in keyof SDKModules]?: Promise<SDKModules[module]['sdk']>;
|
|
95
95
|
};
|
|
96
|
+
protected sdkErrors: {
|
|
97
|
+
[module in keyof SDKModules]?: string;
|
|
98
|
+
};
|
|
96
99
|
constructor(props: ContextConfig<SDKModules>);
|
|
97
100
|
init(props?: ContextInitProps): void;
|
|
98
101
|
/**
|