@sitecore-content-sdk/nextjs 2.0.0-canary.19 → 2.0.0-canary.20
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/DesignLibrary/DesignLibraryClientEvents.js +2 -2
- package/dist/cjs/components/DesignLibrary/DesignLibraryServer.js +4 -0
- package/dist/cjs/server-actions/update-server-component-action.js +3 -1
- package/dist/esm/components/DesignLibrary/DesignLibraryClientEvents.js +2 -2
- package/dist/esm/components/DesignLibrary/DesignLibraryServer.js +4 -0
- package/dist/esm/server-actions/update-server-component-action.js +3 -1
- package/package.json +7 -7
- package/types/components/DesignLibrary/DesignLibraryClientEvents.d.ts.map +1 -1
- package/types/components/DesignLibrary/DesignLibraryServer.d.ts.map +1 -1
- package/types/server-actions/update-server-component-action.d.ts +6 -1
- package/types/server-actions/update-server-component-action.d.ts.map +1 -1
|
@@ -102,11 +102,11 @@ const DesignLibraryVariantGenerationEvents = ({ designLibraryStatus, component,
|
|
|
102
102
|
generatedComponentData,
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
-
const unsubPreview = addServerComponentPreviewHandler((eventArgs) => {
|
|
105
|
+
const unsubPreview = addServerComponentPreviewHandler(component, (rendering, eventArgs) => {
|
|
106
106
|
_previewComponentAction({
|
|
107
107
|
uid: component.uid,
|
|
108
108
|
args: eventArgs,
|
|
109
|
-
}, edgeUrl);
|
|
109
|
+
}, rendering, edgeUrl);
|
|
110
110
|
});
|
|
111
111
|
if (componentInitError) {
|
|
112
112
|
// an error occurred during initialization of the component on the server side
|
|
@@ -158,6 +158,10 @@ const DesignLibraryServerVariantGeneration = async ({ page, rendering, loadServe
|
|
|
158
158
|
if (previewData === null || previewData === void 0 ? void 0 : previewData.error) {
|
|
159
159
|
componentInitError = getComponentInitError(codegen.DesignLibraryPreviewError.GeneratedComponentFetch, previewData.error);
|
|
160
160
|
}
|
|
161
|
+
// apply the updates to the component rendering
|
|
162
|
+
if (previewData === null || previewData === void 0 ? void 0 : previewData.rendering) {
|
|
163
|
+
updateComponent(componentToUpdate, previewData.rendering.fields, previewData.rendering.params);
|
|
164
|
+
}
|
|
161
165
|
if (previewData === null || previewData === void 0 ? void 0 : previewData.generatedComponentData) {
|
|
162
166
|
generatedComponentData = previewData.generatedComponentData;
|
|
163
167
|
try {
|
|
@@ -25,14 +25,16 @@ async function updateComponentAction(updatedComponent) {
|
|
|
25
25
|
* The generated component data is retrieved from a secured cache endpoint via the provided event arguments.
|
|
26
26
|
* This enables rendering dynamic updates of server components inside Design Library
|
|
27
27
|
* @param {PreviewEventModel} previewEvent - The preview event model containing the UID and the preview event arguments with cache information to fetch the generated component data.
|
|
28
|
+
* @param {ComponentRendering} rendering - The component rendering data to use when rendering server side.
|
|
28
29
|
* @param {string} [edgeUrl] - Optional Edge URL to fetch the generated component data.
|
|
29
30
|
* @returns A Promise that resolves when the cache has been updated.
|
|
30
31
|
*/
|
|
31
|
-
async function previewComponentAction(previewEvent, edgeUrl) {
|
|
32
|
+
async function previewComponentAction(previewEvent, rendering, edgeUrl) {
|
|
32
33
|
content_1.debug.editing(`Updating server component cache for Preview Component: ${previewEvent.uid}`);
|
|
33
34
|
const updatedComponent = {
|
|
34
35
|
uid: previewEvent.uid,
|
|
35
36
|
generatedComponentData: undefined,
|
|
37
|
+
rendering,
|
|
36
38
|
error: undefined,
|
|
37
39
|
};
|
|
38
40
|
if (previewEvent.args) {
|
|
@@ -64,11 +64,11 @@ export const DesignLibraryVariantGenerationEvents = ({ designLibraryStatus, comp
|
|
|
64
64
|
generatedComponentData,
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
|
-
const unsubPreview = addServerComponentPreviewHandler((eventArgs) => {
|
|
67
|
+
const unsubPreview = addServerComponentPreviewHandler(component, (rendering, eventArgs) => {
|
|
68
68
|
_previewComponentAction({
|
|
69
69
|
uid: component.uid,
|
|
70
70
|
args: eventArgs,
|
|
71
|
-
}, edgeUrl);
|
|
71
|
+
}, rendering, edgeUrl);
|
|
72
72
|
});
|
|
73
73
|
if (componentInitError) {
|
|
74
74
|
// an error occurred during initialization of the component on the server side
|
|
@@ -117,6 +117,10 @@ export const DesignLibraryServerVariantGeneration = async ({ page, rendering, lo
|
|
|
117
117
|
if (previewData === null || previewData === void 0 ? void 0 : previewData.error) {
|
|
118
118
|
componentInitError = getComponentInitError(codegen.DesignLibraryPreviewError.GeneratedComponentFetch, previewData.error);
|
|
119
119
|
}
|
|
120
|
+
// apply the updates to the component rendering
|
|
121
|
+
if (previewData === null || previewData === void 0 ? void 0 : previewData.rendering) {
|
|
122
|
+
updateComponent(componentToUpdate, previewData.rendering.fields, previewData.rendering.params);
|
|
123
|
+
}
|
|
120
124
|
if (previewData === null || previewData === void 0 ? void 0 : previewData.generatedComponentData) {
|
|
121
125
|
generatedComponentData = previewData.generatedComponentData;
|
|
122
126
|
try {
|
|
@@ -21,14 +21,16 @@ export async function updateComponentAction(updatedComponent) {
|
|
|
21
21
|
* The generated component data is retrieved from a secured cache endpoint via the provided event arguments.
|
|
22
22
|
* This enables rendering dynamic updates of server components inside Design Library
|
|
23
23
|
* @param {PreviewEventModel} previewEvent - The preview event model containing the UID and the preview event arguments with cache information to fetch the generated component data.
|
|
24
|
+
* @param {ComponentRendering} rendering - The component rendering data to use when rendering server side.
|
|
24
25
|
* @param {string} [edgeUrl] - Optional Edge URL to fetch the generated component data.
|
|
25
26
|
* @returns A Promise that resolves when the cache has been updated.
|
|
26
27
|
*/
|
|
27
|
-
export async function previewComponentAction(previewEvent, edgeUrl) {
|
|
28
|
+
export async function previewComponentAction(previewEvent, rendering, edgeUrl) {
|
|
28
29
|
debug.editing(`Updating server component cache for Preview Component: ${previewEvent.uid}`);
|
|
29
30
|
const updatedComponent = {
|
|
30
31
|
uid: previewEvent.uid,
|
|
31
32
|
generatedComponentData: undefined,
|
|
33
|
+
rendering,
|
|
32
34
|
error: undefined,
|
|
33
35
|
};
|
|
34
36
|
if (previewEvent.args) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/nextjs",
|
|
3
|
-
"version": "2.0.0-canary.
|
|
3
|
+
"version": "2.0.0-canary.20",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"url": "https://github.com/sitecore/content-sdk/issues"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@sitecore-content-sdk/analytics-core": "2.0.0-canary.
|
|
36
|
-
"@sitecore-content-sdk/personalize": "2.0.0-canary.
|
|
35
|
+
"@sitecore-content-sdk/analytics-core": "2.0.0-canary.20",
|
|
36
|
+
"@sitecore-content-sdk/personalize": "2.0.0-canary.20",
|
|
37
37
|
"@stylistic/eslint-plugin": "^5.2.2",
|
|
38
38
|
"@testing-library/dom": "^10.4.0",
|
|
39
39
|
"@testing-library/react": "^16.3.0",
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@babel/parser": "^7.27.2",
|
|
94
|
-
"@sitecore-content-sdk/content": "2.0.0-canary.
|
|
95
|
-
"@sitecore-content-sdk/core": "2.0.0-canary.
|
|
96
|
-
"@sitecore-content-sdk/react": "2.0.0-canary.
|
|
94
|
+
"@sitecore-content-sdk/content": "2.0.0-canary.20",
|
|
95
|
+
"@sitecore-content-sdk/core": "2.0.0-canary.20",
|
|
96
|
+
"@sitecore-content-sdk/react": "2.0.0-canary.20",
|
|
97
97
|
"recast": "^0.23.11",
|
|
98
98
|
"regex-parser": "^2.3.1",
|
|
99
99
|
"sync-disk-cache": "^2.1.0"
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
},
|
|
178
178
|
"description": "",
|
|
179
179
|
"types": "types/index.d.ts",
|
|
180
|
-
"gitHead": "
|
|
180
|
+
"gitHead": "2c7a87d40152c06be18d218bed3519f99576df5d",
|
|
181
181
|
"files": [
|
|
182
182
|
"dist",
|
|
183
183
|
"types",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DesignLibraryClientEvents.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/DesignLibraryClientEvents.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAOzC,OAAO,EACL,+BAA+B,EAC/B,yCAAyC,EAC1C,MAAM,UAAU,CAAC;AAclB,eAAO,MAAM,kBAAkB,GAAI,OAAO,GAAG,SAU5C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GAAI,qCAGxC,+BAA+B,sBAgBjC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oCAAoC,GAAI,4FAMlD,yCAAyC,
|
|
1
|
+
{"version":3,"file":"DesignLibraryClientEvents.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/DesignLibraryClientEvents.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAOzC,OAAO,EACL,+BAA+B,EAC/B,yCAAyC,EAC1C,MAAM,UAAU,CAAC;AAclB,eAAO,MAAM,kBAAkB,GAAI,OAAO,GAAG,SAU5C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GAAI,qCAGxC,+BAA+B,sBAgBjC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oCAAoC,GAAI,4FAMlD,yCAAyC,sBA8D3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DesignLibraryServer.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/DesignLibraryServer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAwB1B,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,yCAAyC,EAE1C,MAAM,UAAU,CAAC;AAMlB,eAAO,MAAM,kBAAkB,GAAU,OAAO,GAAG,kBAUlD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAAU,yDAKvC,wBAAwB,sCAoB1B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oCAAoC,GAAU,yDAKxD,yCAAyC,+
|
|
1
|
+
{"version":3,"file":"DesignLibraryServer.d.ts","sourceRoot":"","sources":["../../../src/components/DesignLibrary/DesignLibraryServer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAwB1B,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,yCAAyC,EAE1C,MAAM,UAAU,CAAC;AAMlB,eAAO,MAAM,kBAAkB,GAAU,OAAO,GAAG,kBAUlD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAAU,yDAKvC,wBAAwB,sCAoB1B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oCAAoC,GAAU,yDAKxD,yCAAyC,+BA+I3C,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GAAU,oCAI9C,+BAA+B,+BAsCjC,CAAC"}
|
|
@@ -23,6 +23,10 @@ export type ComponentPreviewModel = {
|
|
|
23
23
|
* The data needed for generated component to be rendered on the server
|
|
24
24
|
*/
|
|
25
25
|
generatedComponentData?: GeneratedComponentData;
|
|
26
|
+
/**
|
|
27
|
+
* The updated component rendering data.
|
|
28
|
+
*/
|
|
29
|
+
rendering?: ComponentRendering | null;
|
|
26
30
|
/**
|
|
27
31
|
* Error message in case fetching generated component data from secured cache endpoint fails.
|
|
28
32
|
*/
|
|
@@ -51,8 +55,9 @@ export declare function updateComponentAction(updatedComponent: ComponentUpdateM
|
|
|
51
55
|
* The generated component data is retrieved from a secured cache endpoint via the provided event arguments.
|
|
52
56
|
* This enables rendering dynamic updates of server components inside Design Library
|
|
53
57
|
* @param {PreviewEventModel} previewEvent - The preview event model containing the UID and the preview event arguments with cache information to fetch the generated component data.
|
|
58
|
+
* @param {ComponentRendering} rendering - The component rendering data to use when rendering server side.
|
|
54
59
|
* @param {string} [edgeUrl] - Optional Edge URL to fetch the generated component data.
|
|
55
60
|
* @returns A Promise that resolves when the cache has been updated.
|
|
56
61
|
*/
|
|
57
|
-
export declare function previewComponentAction(previewEvent: PreviewEventModel, edgeUrl
|
|
62
|
+
export declare function previewComponentAction(previewEvent: PreviewEventModel, rendering: ComponentRendering | null, edgeUrl: string | undefined): Promise<void>;
|
|
58
63
|
//# sourceMappingURL=update-server-component-action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-server-component-action.d.ts","sourceRoot":"","sources":["../../src/server-actions/update-server-component-action.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EAEvB,MAAM,uCAAuC,CAAC;AAO/C,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B;;OAEG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,+BAA+B,CAAC;CACvC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,gBAAgB,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjG;AAED
|
|
1
|
+
{"version":3,"file":"update-server-component-action.d.ts","sourceRoot":"","sources":["../../src/server-actions/update-server-component-action.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EAEvB,MAAM,uCAAuC,CAAC;AAO/C,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B;;OAEG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD;;OAEG;IACH,SAAS,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,+BAA+B,CAAC;CACvC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,gBAAgB,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjG;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,kBAAkB,GAAG,IAAI,EACpC,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,OAAO,CAAC,IAAI,CAAC,CAgCf"}
|