@sitecore-jss/sitecore-jss-nextjs 22.2.0-canary.8 → 22.2.0-canary.81
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/dist/cjs/components/Link.js +8 -2
- package/dist/cjs/components/NextImage.js +6 -1
- package/dist/cjs/editing/constants.js +1 -6
- package/dist/cjs/editing/editing-config-middleware.js +3 -3
- package/dist/cjs/editing/editing-data-middleware.js +3 -3
- package/dist/cjs/editing/editing-data-service.js +2 -2
- package/dist/cjs/editing/editing-render-middleware.js +5 -5
- package/dist/cjs/editing/feaas-render-middleware.js +3 -3
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/middleware/index.js +3 -1
- package/dist/cjs/middleware/personalize-middleware.js +7 -4
- package/dist/cjs/middleware/redirects-middleware.js +157 -42
- package/dist/esm/components/Link.js +8 -2
- package/dist/esm/components/NextImage.js +8 -3
- package/dist/esm/editing/constants.js +0 -5
- package/dist/esm/editing/editing-config-middleware.js +1 -1
- package/dist/esm/editing/editing-data-middleware.js +1 -1
- package/dist/esm/editing/editing-data-service.js +1 -1
- package/dist/esm/editing/editing-render-middleware.js +2 -2
- package/dist/esm/editing/feaas-render-middleware.js +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/middleware/index.js +1 -0
- package/dist/esm/middleware/personalize-middleware.js +6 -3
- package/dist/esm/middleware/redirects-middleware.js +157 -42
- package/package.json +11 -10
- package/types/editing/constants.d.ts +0 -5
- package/types/editing/editing-render-middleware.d.ts +3 -15
- package/types/index.d.ts +1 -2
- package/types/middleware/index.d.ts +1 -0
- package/types/middleware/redirects-middleware.d.ts +29 -1
- package/context.d.ts +0 -1
- package/context.js +0 -1
- package/dist/cjs/context/context.js +0 -83
- package/dist/cjs/context/index.js +0 -5
- package/dist/esm/context/context.js +0 -79
- package/dist/esm/context/index.js +0 -1
- package/types/context/context.d.ts +0 -116
- package/types/context/index.d.ts +0 -1
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { LayoutServicePageState } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
-
/**
|
|
3
|
-
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
4
|
-
*/
|
|
5
|
-
export class Context {
|
|
6
|
-
constructor(props) {
|
|
7
|
-
this.props = props;
|
|
8
|
-
/**
|
|
9
|
-
* Indicates whether the Context and SDK(s) have been initialized
|
|
10
|
-
*/
|
|
11
|
-
this.isInitialized = false;
|
|
12
|
-
/**
|
|
13
|
-
* Software Development Kits (SDKs) to be initialized
|
|
14
|
-
*/
|
|
15
|
-
this.sdks = {};
|
|
16
|
-
/**
|
|
17
|
-
* Promises for the SDKs
|
|
18
|
-
*/
|
|
19
|
-
this.sdkPromises = {};
|
|
20
|
-
this.sdkErrors = {};
|
|
21
|
-
/**
|
|
22
|
-
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
23
|
-
*
|
|
24
|
-
* @param {string} name SDK name
|
|
25
|
-
* @returns initialized SDK
|
|
26
|
-
*/
|
|
27
|
-
this.getSDK = (name) => {
|
|
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
|
-
}
|
|
36
|
-
};
|
|
37
|
-
this.sitecoreEdgeUrl = props.sitecoreEdgeUrl;
|
|
38
|
-
this.sitecoreEdgeContextId = props.sitecoreEdgeContextId;
|
|
39
|
-
this.siteName = props.siteName;
|
|
40
|
-
this.pageState = LayoutServicePageState.Normal;
|
|
41
|
-
}
|
|
42
|
-
init(props = {}) {
|
|
43
|
-
// Context and SDKs are initialized only once
|
|
44
|
-
if (this.isInitialized)
|
|
45
|
-
return;
|
|
46
|
-
this.isInitialized = true;
|
|
47
|
-
if (props.siteName) {
|
|
48
|
-
this.siteName = props.siteName;
|
|
49
|
-
}
|
|
50
|
-
if (props.pageState) {
|
|
51
|
-
this.pageState = props.pageState;
|
|
52
|
-
}
|
|
53
|
-
// iterate over the SDKs and initialize them
|
|
54
|
-
for (const sdkName of Object.keys(this.props.sdks)) {
|
|
55
|
-
this.initSDK(sdkName);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Initializes the Software Development Kit (SDK)
|
|
60
|
-
*
|
|
61
|
-
* @param {T} name SDK name
|
|
62
|
-
* @returns {void}
|
|
63
|
-
*/
|
|
64
|
-
initSDK(name) {
|
|
65
|
-
this.sdkPromises[name] = new Promise((resolve) => {
|
|
66
|
-
this.props.sdks[name]
|
|
67
|
-
.init(this)
|
|
68
|
-
.then(() => {
|
|
69
|
-
this.sdks[name] = this.props.sdks[name].sdk;
|
|
70
|
-
resolve(this.sdks[name]);
|
|
71
|
-
})
|
|
72
|
-
.catch((e) => {
|
|
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);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Context } from './context';
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { LayoutServicePageState } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
-
/**
|
|
3
|
-
* Software Development Kit (SDK) instance
|
|
4
|
-
*/
|
|
5
|
-
export type SDK<SDKType = unknown> = {
|
|
6
|
-
/**
|
|
7
|
-
* The Software Development Kit (SDK) library instance
|
|
8
|
-
*/
|
|
9
|
-
sdk: SDKType;
|
|
10
|
-
/**
|
|
11
|
-
* Initializes the Software Development Kit (SDK)
|
|
12
|
-
*/
|
|
13
|
-
init: (props: InitSDKProps) => Promise<void>;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Software Development Kits (SDKs) to be initialized
|
|
17
|
-
*/
|
|
18
|
-
type SDKModulesType = Record<string, SDK>;
|
|
19
|
-
/**
|
|
20
|
-
* Properties that are passed to the Context.
|
|
21
|
-
*/
|
|
22
|
-
export interface ContextInitProps {
|
|
23
|
-
/**
|
|
24
|
-
* Your Sitecore site name
|
|
25
|
-
*/
|
|
26
|
-
siteName?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Sitecore page state (normal, preview, edit)
|
|
29
|
-
*/
|
|
30
|
-
pageState?: LayoutServicePageState;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Configuration that is passed to the Context.
|
|
34
|
-
*/
|
|
35
|
-
export interface ContextConfig<SDKModules extends SDKModulesType> {
|
|
36
|
-
/**
|
|
37
|
-
* Your Sitecore Edge URL
|
|
38
|
-
*/
|
|
39
|
-
sitecoreEdgeUrl: string;
|
|
40
|
-
/**
|
|
41
|
-
* Your Sitecore Edge Context ID
|
|
42
|
-
*/
|
|
43
|
-
sitecoreEdgeContextId: string;
|
|
44
|
-
/**
|
|
45
|
-
* Your Sitecore site name
|
|
46
|
-
*/
|
|
47
|
-
siteName: string;
|
|
48
|
-
/**
|
|
49
|
-
* Software Development Kits (SDKs) to be initialized
|
|
50
|
-
*/
|
|
51
|
-
sdks: {
|
|
52
|
-
[module in keyof SDKModules]: SDKModules[module];
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Properties that are passed to the Software Development Kit (SDK) initialization function.
|
|
57
|
-
*/
|
|
58
|
-
type InitSDKProps = Omit<ContextConfig<SDKModulesType>, 'sdks'>;
|
|
59
|
-
/**
|
|
60
|
-
* Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
|
|
61
|
-
*/
|
|
62
|
-
export declare class Context<SDKModules extends SDKModulesType> {
|
|
63
|
-
protected props: ContextConfig<SDKModules>;
|
|
64
|
-
/**
|
|
65
|
-
* Indicates whether the Context and SDK(s) have been initialized
|
|
66
|
-
*/
|
|
67
|
-
isInitialized: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* The Sitecore Edge URL
|
|
70
|
-
*/
|
|
71
|
-
readonly sitecoreEdgeUrl: string;
|
|
72
|
-
/**
|
|
73
|
-
* The Sitecore Edge Context ID
|
|
74
|
-
*/
|
|
75
|
-
readonly sitecoreEdgeContextId: string;
|
|
76
|
-
/**
|
|
77
|
-
* The Sitecore site name
|
|
78
|
-
*/
|
|
79
|
-
siteName: string;
|
|
80
|
-
/**
|
|
81
|
-
* Sitecore page state (normal, preview, edit)
|
|
82
|
-
*/
|
|
83
|
-
pageState: LayoutServicePageState;
|
|
84
|
-
/**
|
|
85
|
-
* Software Development Kits (SDKs) to be initialized
|
|
86
|
-
*/
|
|
87
|
-
readonly sdks: {
|
|
88
|
-
[module in keyof SDKModules]?: SDKModules[module]['sdk'];
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Promises for the SDKs
|
|
92
|
-
*/
|
|
93
|
-
protected sdkPromises: {
|
|
94
|
-
[module in keyof SDKModules]?: Promise<SDKModules[module]['sdk']>;
|
|
95
|
-
};
|
|
96
|
-
protected sdkErrors: {
|
|
97
|
-
[module in keyof SDKModules]?: string;
|
|
98
|
-
};
|
|
99
|
-
constructor(props: ContextConfig<SDKModules>);
|
|
100
|
-
init(props?: ContextInitProps): void;
|
|
101
|
-
/**
|
|
102
|
-
* Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
|
|
103
|
-
*
|
|
104
|
-
* @param {string} name SDK name
|
|
105
|
-
* @returns initialized SDK
|
|
106
|
-
*/
|
|
107
|
-
getSDK: <T extends keyof SDKModules>(name: T) => Promise<SDKModules[T]["sdk"]>;
|
|
108
|
-
/**
|
|
109
|
-
* Initializes the Software Development Kit (SDK)
|
|
110
|
-
*
|
|
111
|
-
* @param {T} name SDK name
|
|
112
|
-
* @returns {void}
|
|
113
|
-
*/
|
|
114
|
-
protected initSDK<T extends keyof SDKModules>(name: T): void;
|
|
115
|
-
}
|
|
116
|
-
export {};
|
package/types/context/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Context, ContextConfig, SDK } from './context';
|