@sitecore-content-sdk/react 1.5.0-canary.10 → 1.5.0-canary.12

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.
Files changed (107) hide show
  1. package/dist/cjs/components/ClientEditingChromesUpdate.js +1 -1
  2. package/dist/cjs/components/Date.js +1 -1
  3. package/dist/cjs/components/DesignLibrary/DesignLibrary.js +6 -8
  4. package/dist/cjs/components/DesignLibrary/DesignLibraryApp.js +1 -1
  5. package/dist/cjs/components/DesignLibrary/DesignLibraryClientEvents.js +27 -30
  6. package/dist/cjs/components/DesignLibrary/DesignLibraryErrorBoundary.js +1 -1
  7. package/dist/cjs/components/DesignLibrary/DesignLibraryServer.js +22 -39
  8. package/dist/cjs/components/EditingScripts.js +3 -2
  9. package/dist/cjs/components/FieldMetadata.js +1 -1
  10. package/dist/cjs/components/File.js +1 -1
  11. package/dist/cjs/components/Form.js +2 -2
  12. package/dist/cjs/components/Image.js +2 -2
  13. package/dist/cjs/components/Link.js +1 -1
  14. package/dist/cjs/components/Placeholder/Placeholder.js +10 -1
  15. package/dist/cjs/components/Placeholder/PlaceholderMetadata.js +2 -2
  16. package/dist/cjs/components/Placeholder/placeholder-utils.js +3 -4
  17. package/dist/cjs/components/RichText.js +1 -1
  18. package/dist/cjs/components/SitecoreProvider.js +9 -1
  19. package/dist/cjs/components/Text.js +1 -1
  20. package/dist/cjs/enhancers/withEmptyFieldEditingComponent.js +1 -1
  21. package/dist/cjs/enhancers/withLoadImportMap.js +1 -10
  22. package/dist/cjs/index.js +8 -9
  23. package/dist/cjs/search/index.js +1 -3
  24. package/dist/cjs/server-actions/update-server-component-action.js +9 -42
  25. package/dist/cjs/utils.js +1 -1
  26. package/dist/esm/components/ClientEditingChromesUpdate.js +1 -1
  27. package/dist/esm/components/Date.js +1 -1
  28. package/dist/esm/components/DesignLibrary/DesignLibrary.js +7 -8
  29. package/dist/esm/components/DesignLibrary/DesignLibraryApp.js +1 -1
  30. package/dist/esm/components/DesignLibrary/DesignLibraryClientEvents.js +28 -31
  31. package/dist/esm/components/DesignLibrary/DesignLibraryErrorBoundary.js +1 -1
  32. package/dist/esm/components/DesignLibrary/DesignLibraryServer.js +22 -39
  33. package/dist/esm/components/EditingScripts.js +2 -1
  34. package/dist/esm/components/FieldMetadata.js +1 -1
  35. package/dist/esm/components/File.js +1 -1
  36. package/dist/esm/components/Form.js +1 -1
  37. package/dist/esm/components/Image.js +2 -2
  38. package/dist/esm/components/Link.js +1 -1
  39. package/dist/esm/components/Placeholder/Placeholder.js +10 -1
  40. package/dist/esm/components/Placeholder/PlaceholderMetadata.js +2 -2
  41. package/dist/esm/components/Placeholder/placeholder-utils.js +3 -4
  42. package/dist/esm/components/RichText.js +1 -1
  43. package/dist/esm/components/SitecoreProvider.js +9 -1
  44. package/dist/esm/components/Text.js +1 -1
  45. package/dist/esm/enhancers/withEmptyFieldEditingComponent.js +1 -1
  46. package/dist/esm/enhancers/withLoadImportMap.js +1 -9
  47. package/dist/esm/index.js +7 -7
  48. package/dist/esm/search/index.js +0 -1
  49. package/dist/esm/server-actions/update-server-component-action.js +8 -40
  50. package/dist/esm/utils.js +1 -1
  51. package/package.json +6 -7
  52. package/types/components/Date.d.ts +1 -1
  53. package/types/components/Date.d.ts.map +1 -1
  54. package/types/components/DesignLibrary/DesignLibrary.d.ts +5 -1
  55. package/types/components/DesignLibrary/DesignLibrary.d.ts.map +1 -1
  56. package/types/components/DesignLibrary/DesignLibraryClientEvents.d.ts +1 -1
  57. package/types/components/DesignLibrary/DesignLibraryClientEvents.d.ts.map +1 -1
  58. package/types/components/DesignLibrary/DesignLibraryServer.d.ts.map +1 -1
  59. package/types/components/DesignLibrary/models.d.ts +16 -11
  60. package/types/components/DesignLibrary/models.d.ts.map +1 -1
  61. package/types/components/EditingScripts.d.ts.map +1 -1
  62. package/types/components/ErrorBoundary.d.ts +3 -3
  63. package/types/components/ErrorBoundary.d.ts.map +1 -1
  64. package/types/components/FEaaS/models.d.ts +2 -2
  65. package/types/components/FEaaS/models.d.ts.map +1 -1
  66. package/types/components/Form.d.ts +1 -1
  67. package/types/components/Form.d.ts.map +1 -1
  68. package/types/components/Image.d.ts +1 -1
  69. package/types/components/Image.d.ts.map +1 -1
  70. package/types/components/Link.d.ts +1 -1
  71. package/types/components/Link.d.ts.map +1 -1
  72. package/types/components/Placeholder/ClientComponentWrapper.d.ts +1 -1
  73. package/types/components/Placeholder/ClientComponentWrapper.d.ts.map +1 -1
  74. package/types/components/Placeholder/Placeholder.d.ts +9 -2
  75. package/types/components/Placeholder/Placeholder.d.ts.map +1 -1
  76. package/types/components/Placeholder/PlaceholderMetadata.d.ts +1 -1
  77. package/types/components/Placeholder/PlaceholderMetadata.d.ts.map +1 -1
  78. package/types/components/Placeholder/models.d.ts +3 -3
  79. package/types/components/Placeholder/models.d.ts.map +1 -1
  80. package/types/components/Placeholder/placeholder-utils.d.ts +2 -3
  81. package/types/components/Placeholder/placeholder-utils.d.ts.map +1 -1
  82. package/types/components/RichText.d.ts +1 -1
  83. package/types/components/RichText.d.ts.map +1 -1
  84. package/types/components/SitecoreProvider.d.ts +4 -3
  85. package/types/components/SitecoreProvider.d.ts.map +1 -1
  86. package/types/components/Text.d.ts +1 -1
  87. package/types/components/Text.d.ts.map +1 -1
  88. package/types/enhancers/withAppPlaceholder.d.ts +2 -2
  89. package/types/enhancers/withAppPlaceholder.d.ts.map +1 -1
  90. package/types/enhancers/withDatasourceCheck.d.ts +1 -1
  91. package/types/enhancers/withDatasourceCheck.d.ts.map +1 -1
  92. package/types/enhancers/withEmptyFieldEditingComponent.d.ts +1 -1
  93. package/types/enhancers/withEmptyFieldEditingComponent.d.ts.map +1 -1
  94. package/types/enhancers/withLoadImportMap.d.ts +0 -6
  95. package/types/enhancers/withLoadImportMap.d.ts.map +1 -1
  96. package/types/enhancers/withPlaceholder.d.ts +2 -2
  97. package/types/enhancers/withPlaceholder.d.ts.map +1 -1
  98. package/types/enhancers/withSitecore.d.ts +2 -2
  99. package/types/enhancers/withSitecore.d.ts.map +1 -1
  100. package/types/index.d.ts +8 -8
  101. package/types/index.d.ts.map +1 -1
  102. package/types/search/index.d.ts +0 -1
  103. package/types/search/index.d.ts.map +1 -1
  104. package/types/server-actions/update-server-component-action.d.ts +7 -40
  105. package/types/server-actions/update-server-component-action.d.ts.map +1 -1
  106. package/types/utils.d.ts +1 -1
  107. package/types/utils.d.ts.map +1 -1
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.ClientEditingChromesUpdate = void 0;
38
- const editing_1 = require("@sitecore-content-sdk/content/editing");
38
+ const editing_1 = require("@sitecore-content-sdk/core/editing");
39
39
  const react_1 = __importStar(require("react"));
40
40
  /**
41
41
  * Updates editing chromes in app router / RSC context.
@@ -19,7 +19,7 @@ const react_1 = __importDefault(require("react"));
19
19
  const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
20
20
  const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
21
21
  const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
22
- const layout_1 = require("@sitecore-content-sdk/content/layout");
22
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
23
23
  /**
24
24
  * The DateField component.
25
25
  * @public
@@ -38,10 +38,10 @@ exports.DesignLibrary = exports.__mockDependencies = void 0;
38
38
  /* eslint-disable jsdoc/require-param */
39
39
  /* eslint-disable prefer-const */
40
40
  const react_1 = __importStar(require("react"));
41
- const layout_1 = require("@sitecore-content-sdk/content/layout");
42
- const editing_1 = require("@sitecore-content-sdk/content/editing");
43
- const codegen = __importStar(require("@sitecore-content-sdk/content/codegen"));
44
- const editing = __importStar(require("@sitecore-content-sdk/content/editing"));
41
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
42
+ const editing_1 = require("@sitecore-content-sdk/core/editing");
43
+ const codegen = __importStar(require("@sitecore-content-sdk/core/codegen"));
44
+ const editing = __importStar(require("@sitecore-content-sdk/core/editing"));
45
45
  const withSitecore_1 = require("../../enhancers/withSitecore");
46
46
  const Placeholder_1 = require("../Placeholder");
47
47
  const DesignLibraryErrorBoundary_1 = require("./DesignLibraryErrorBoundary");
@@ -71,10 +71,9 @@ exports.__mockDependencies = __mockDependencies;
71
71
  * @returns {JSX.Element} The preview surface, or `null` when not in Design Library mode.
72
72
  * @public
73
73
  */
74
- const DesignLibrary = () => {
74
+ exports.DesignLibrary = (0, withLoadImportMap_1.withLoadImportMap)(({ loadImportMap }) => {
75
75
  var _a, _b;
76
76
  const { page } = (0, withSitecore_1.useSitecore)();
77
- const loadImportMap = (0, withLoadImportMap_1.useLoadImportMap)();
78
77
  const route = page.layout.sitecore.route;
79
78
  const rendering = (_a = route === null || route === void 0 ? void 0 : route.placeholders[layout_1.EDITING_COMPONENT_PLACEHOLDER]) === null || _a === void 0 ? void 0 : _a[0];
80
79
  const uid = rendering === null || rendering === void 0 ? void 0 : rendering.uid;
@@ -159,5 +158,4 @@ const DesignLibrary = () => {
159
158
  return (react_1.default.createElement("main", null, isGeneratedComponentActive ? (react_1.default.createElement(DesignLibraryErrorBoundary_1.DesignLibraryErrorBoundary, { uid: uid, renderKey: renderKey },
160
159
  react_1.default.createElement(Placeholder_1.PlaceholderMetadata, { rendering: rendering },
161
160
  react_1.default.createElement(Component, { fields: propsState.fields, params: propsState.params, key: renderKey })))) : (react_1.default.createElement("div", { id: layout_1.EDITING_COMPONENT_ID }, route && (react_1.default.createElement(Placeholder_1.Placeholder, { name: layout_1.EDITING_COMPONENT_PLACEHOLDER, rendering: route, key: renderKey }))))));
162
- };
163
- exports.DesignLibrary = DesignLibrary;
161
+ });
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DesignLibraryApp = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
- const layout_1 = require("@sitecore-content-sdk/content/layout");
8
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
9
9
  const DesignLibraryServer_1 = require("./DesignLibraryServer");
10
10
  const DesignLibrary_1 = require("./DesignLibrary");
11
11
  /**
@@ -36,19 +36,16 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.DesignLibraryVariantGenerationEvents = exports.DesignLibraryPreviewEvents = exports.__mockDependencies = void 0;
38
38
  const react_1 = __importStar(require("react"));
39
- const dlHelpers = __importStar(require("@sitecore-content-sdk/content/editing"));
40
- const codegen = __importStar(require("@sitecore-content-sdk/content/codegen"));
39
+ const dlHelpers = __importStar(require("@sitecore-content-sdk/core/editing"));
40
+ const codegen = __importStar(require("@sitecore-content-sdk/core/codegen"));
41
41
  const update_server_component_action_1 = require("../../server-actions/update-server-component-action");
42
- const withSitecore_1 = require("../../enhancers/withSitecore");
43
42
  let { getDesignLibraryComponentPropsEvent, addServerComponentPreviewHandler, getDesignLibraryImportMapEvent, addStyleElement, sendErrorEvent, } = codegen;
44
43
  let { getDesignLibraryStatusEvent, addComponentUpdateHandler, postToDesignLibrary } = dlHelpers;
45
- let _updateComponentAction = update_server_component_action_1.updateComponentAction;
46
- let _previewComponentAction = update_server_component_action_1.previewComponentAction;
44
+ let _updateServerComponentAction = update_server_component_action_1.updateServerComponentAction;
47
45
  const __mockDependencies = (mocks) => {
48
46
  postToDesignLibrary = mocks.postToDesignLibrary;
49
47
  addComponentUpdateHandler = mocks.addComponentUpdateHandler;
50
- _updateComponentAction = mocks.updateComponentAction;
51
- _previewComponentAction = mocks.previewComponentAction;
48
+ _updateServerComponentAction = mocks.updateServerComponentAction;
52
49
  addServerComponentPreviewHandler = mocks.addServerComponentPreviewHandler;
53
50
  getDesignLibraryImportMapEvent = mocks.getDesignLibraryImportMapEvent;
54
51
  getDesignLibraryComponentPropsEvent = mocks.getDesignLibraryComponentPropsEvent;
@@ -67,12 +64,17 @@ const DesignLibraryPreviewEvents = ({ designLibraryStatus, component, }) => {
67
64
  (0, react_1.useEffect)(() => {
68
65
  if (!(component === null || component === void 0 ? void 0 : component.uid))
69
66
  return;
70
- postToDesignLibrary(getDesignLibraryStatusEvent(designLibraryStatus, component.uid, true));
71
- const unsubUpdate = addComponentUpdateHandler(component, (rendering) => {
72
- _updateComponentAction({ uid: rendering.uid, rendering });
67
+ postToDesignLibrary(getDesignLibraryStatusEvent(designLibraryStatus, component.uid));
68
+ const unsubUpdate = addComponentUpdateHandler(component, (updated) => {
69
+ _updateServerComponentAction({ uid: updated.uid, updatedComponent: updated });
70
+ });
71
+ // eslint-disable-next-line no-unused-vars
72
+ const unsubPreview = addServerComponentPreviewHandler((_eventArgs) => {
73
+ console.error('Component Library variant generation for server components is temporarily disabled.');
73
74
  });
74
75
  return () => {
75
76
  unsubUpdate && unsubUpdate();
77
+ unsubPreview && unsubPreview();
76
78
  };
77
79
  }, [component, designLibraryStatus]);
78
80
  return react_1.default.createElement(react_1.default.Fragment, null);
@@ -86,46 +88,41 @@ exports.DesignLibraryPreviewEvents = DesignLibraryPreviewEvents;
86
88
  * @param {DesignLibraryVariantGenerationEventsProps} props The props. {@link DesignLibraryVariantGenerationEventsProps}
87
89
  * @returns {JSX.Element} empty JSX element.
88
90
  */
89
- const DesignLibraryVariantGenerationEvents = ({ designLibraryStatus, component, importMap, componentInitError, generatedComponentData, }) => {
90
- const { api } = (0, withSitecore_1.useSitecore)();
91
+ const DesignLibraryVariantGenerationEvents = ({ designLibraryStatus, component, importMap, importMapError, previewComponentData, }) => {
91
92
  (0, react_1.useEffect)(() => {
92
- var _a;
93
+ var _a, _b;
93
94
  if (!(component === null || component === void 0 ? void 0 : component.uid))
94
95
  return;
95
- postToDesignLibrary(getDesignLibraryStatusEvent(designLibraryStatus, component.uid, true));
96
- const unsubUpdate = addComponentUpdateHandler(component, (rendering) => {
97
- _updateComponentAction({
98
- uid: rendering.uid,
99
- rendering,
100
- generatedComponentData,
96
+ postToDesignLibrary(getDesignLibraryStatusEvent(designLibraryStatus, component.uid));
97
+ const unsubUpdate = addComponentUpdateHandler(component, (updated) => {
98
+ _updateServerComponentAction({
99
+ uid: updated.uid,
100
+ updatedComponent: updated,
101
+ previewComponent: previewComponentData,
101
102
  });
102
103
  });
103
104
  const unsubPreview = addServerComponentPreviewHandler((eventArgs) => {
104
- var _a;
105
- _previewComponentAction({
106
- uid: component.uid,
107
- args: eventArgs,
108
- }, (_a = api === null || api === void 0 ? void 0 : api.edge) === null || _a === void 0 ? void 0 : _a.edgeUrl);
105
+ _updateServerComponentAction({ uid: component.uid, previewComponent: eventArgs });
109
106
  });
110
- if (componentInitError) {
111
- // an error occurred during initialization of the component on the server side
112
- sendErrorEvent(component.uid, componentInitError, codegen.DesignLibraryPreviewError.RenderInit);
107
+ if (importMapError) {
108
+ // an import map error occurred on the server side in DesignLibraryServer, post error event to Design Studio
109
+ sendErrorEvent(component.uid, importMapError, codegen.DesignLibraryPreviewError.RenderInit);
113
110
  }
114
111
  else {
115
112
  const importMapEvent = getDesignLibraryImportMapEvent(component.uid, importMap);
116
113
  postToDesignLibrary(importMapEvent);
117
114
  const propsEvent = getDesignLibraryComponentPropsEvent(component.uid, component.fields, component.params);
118
115
  postToDesignLibrary(propsEvent);
119
- if ((_a = generatedComponentData === null || generatedComponentData === void 0 ? void 0 : generatedComponentData.styles) === null || _a === void 0 ? void 0 : _a.content) {
116
+ if ((_b = (_a = previewComponentData === null || previewComponentData === void 0 ? void 0 : previewComponentData.message) === null || _a === void 0 ? void 0 : _a.styles) === null || _b === void 0 ? void 0 : _b.content) {
120
117
  // the generated component has custom styles, so add the css in style element and add it to document head
121
- addStyleElement(generatedComponentData.styles.content);
118
+ addStyleElement(previewComponentData.message.styles.content);
122
119
  }
123
120
  }
124
121
  return () => {
125
122
  unsubUpdate && unsubUpdate();
126
123
  unsubPreview && unsubPreview();
127
124
  };
128
- }, [component, designLibraryStatus, importMap, componentInitError, generatedComponentData]);
125
+ }, [component, designLibraryStatus, importMap, importMapError, previewComponentData]);
129
126
  return react_1.default.createElement(react_1.default.Fragment, null);
130
127
  };
131
128
  exports.DesignLibraryVariantGenerationEvents = DesignLibraryVariantGenerationEvents;
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.DesignLibraryErrorBoundary = void 0;
38
38
  const react_1 = __importStar(require("react"));
39
- const codegen_1 = require("@sitecore-content-sdk/content/codegen");
39
+ const codegen_1 = require("@sitecore-content-sdk/core/codegen");
40
40
  class DesignLibraryErrorBoundary extends react_1.default.Component {
41
41
  constructor() {
42
42
  super(...arguments);
@@ -39,11 +39,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.DesignLibraryServerPreview = exports.DesignLibraryServerVariantGeneration = exports.DesignLibraryServer = exports.__mockDependencies = void 0;
41
41
  const react_1 = __importDefault(require("react"));
42
- const layout_1 = require("@sitecore-content-sdk/content/layout");
42
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
43
43
  const DesignLibraryClientEvents_1 = require("./DesignLibraryClientEvents");
44
- const globalCache = __importStar(require("@sitecore-content-sdk/core/tools"));
45
- const editing_1 = require("@sitecore-content-sdk/content/editing");
46
- const codegen = __importStar(require("@sitecore-content-sdk/content/codegen"));
44
+ const globalCache = __importStar(require("@sitecore-content-sdk/core/utils"));
45
+ const editing_1 = require("@sitecore-content-sdk/core/editing");
46
+ const codegen = __importStar(require("@sitecore-content-sdk/core/codegen"));
47
47
  const Placeholder_1 = require("../Placeholder");
48
48
  const DesignLibraryErrorBoundary_1 = require("./DesignLibraryErrorBoundary");
49
49
  const ErrorBoundary_1 = require("../ErrorBoundary");
@@ -79,7 +79,9 @@ const DesignLibraryServer = async ({ page, componentMap, rendering, loadServerIm
79
79
  return null;
80
80
  }
81
81
  const isVariantGeneration = (_a = page.mode.designLibrary) === null || _a === void 0 ? void 0 : _a.isVariantGeneration;
82
- if (isVariantGeneration) {
82
+ // Temporarily disable server side variant generation due to potential security vulerability
83
+ // eslint-disable-next-line no-constant-condition
84
+ if (isVariantGeneration && false) {
83
85
  return (react_1.default.createElement(exports.DesignLibraryServerVariantGeneration, { page: page, rendering: rendering, loadServerImportMap: loadServerImportMap, componentMap: componentMap }));
84
86
  }
85
87
  return (react_1.default.createElement(exports.DesignLibraryServerPreview, { page: page, rendering: rendering, componentMap: componentMap }));
@@ -101,12 +103,12 @@ const DesignLibraryServerVariantGeneration = async ({ page, rendering, loadServe
101
103
  let importMap;
102
104
  let importMapInfo;
103
105
  let Component;
104
- let componentInitError;
105
- let generatedComponentData;
106
+ let importMapError;
107
+ let previewComponentData;
106
108
  // load importmap and importmap payload to pass to FE
107
109
  // if not provided, or errors during load set error to pass to FE
108
110
  if (!loadServerImportMap) {
109
- componentInitError = 'No loadImportMap provided';
111
+ importMapError = 'No loadImportMap provided';
110
112
  }
111
113
  else {
112
114
  try {
@@ -115,7 +117,7 @@ const DesignLibraryServerVariantGeneration = async ({ page, rendering, loadServe
115
117
  importMapInfo = getImportMapInfo(importMap);
116
118
  }
117
119
  catch (e) {
118
- componentInitError = `Error loading import map: ${e}`;
120
+ importMapError = `Error loading import map: ${e}`;
119
121
  }
120
122
  }
121
123
  let componentToUpdate = (_b = (_a = rendering === null || rendering === void 0 ? void 0 : rendering.placeholders) === null || _a === void 0 ? void 0 : _a[layout_1.EDITING_COMPONENT_PLACEHOLDER]) === null || _b === void 0 ? void 0 : _b[0];
@@ -125,43 +127,24 @@ const DesignLibraryServerVariantGeneration = async ({ page, rendering, loadServe
125
127
  return react_1.default.createElement(ErrorBoundary_1.ErrorComponent, { message: "Rendering UID is missing in the rendering data" });
126
128
  const uid = componentToUpdate.uid;
127
129
  const componentUpdateKey = `${editing_1.COMPONENT_UPDATE_CACHE_KEY_PREFIX}${uid}`;
128
- const componentPreviewKey = `${editing_1.COMPONENT_PREVIEW_CACHE_KEY_PREFIX}${uid}`;
129
130
  // check if we have an update for this component in the global cache
130
131
  if (hasCache(componentUpdateKey)) {
131
- // we have fields/params update, get it and clean the cache
132
+ // we have an update, get it and clean the cache
132
133
  designLibraryStatus = editing_1.DesignLibraryStatus.RENDERED;
133
134
  const updateData = getCacheAndClean(componentUpdateKey);
134
135
  // apply the updates to the component rendering
135
- if (updateData === null || updateData === void 0 ? void 0 : updateData.rendering) {
136
- updateComponent(componentToUpdate, updateData.rendering.fields, updateData.rendering.params);
137
- }
138
- // generate the component instance if we are dealing with an AI-generated component
139
- if ((updateData === null || updateData === void 0 ? void 0 : updateData.generatedComponentData) && !componentInitError && importMap) {
140
- generatedComponentData = updateData.generatedComponentData;
141
- try {
142
- // use provided code and import map to create the component instance
143
- Component = createComponentInstance(importMap, updateData.generatedComponentData);
144
- }
145
- catch (error) {
146
- // error during component initialization - send error to client
147
- componentInitError = error.toString();
148
- }
136
+ if (updateData === null || updateData === void 0 ? void 0 : updateData.updatedComponent) {
137
+ updateComponent(componentToUpdate, updateData.updatedComponent.fields, updateData.updatedComponent.params);
149
138
  }
150
- }
151
- else if (hasCache(componentPreviewKey) && !componentInitError && importMap) {
152
- // we have a preview update, get it and clean the cache
153
- designLibraryStatus = editing_1.DesignLibraryStatus.RENDERED;
154
- const previewData = getCacheAndClean(componentPreviewKey);
155
- componentInitError = previewData === null || previewData === void 0 ? void 0 : previewData.error;
156
- if (previewData === null || previewData === void 0 ? void 0 : previewData.generatedComponentData) {
157
- generatedComponentData = previewData.generatedComponentData;
139
+ if ((updateData === null || updateData === void 0 ? void 0 : updateData.previewComponent) && !importMapError && importMap) {
140
+ previewComponentData = updateData.previewComponent;
158
141
  try {
159
142
  // use provided code and import map to create the component instance
160
- Component = createComponentInstance(importMap, previewData.generatedComponentData);
143
+ Component = createComponentInstance(importMap, updateData.previewComponent);
161
144
  }
162
145
  catch (error) {
163
146
  // error during component initialization - send error to client
164
- componentInitError = error.toString();
147
+ importMapError = error.toString();
165
148
  }
166
149
  }
167
150
  }
@@ -171,7 +154,7 @@ const DesignLibraryServerVariantGeneration = async ({ page, rendering, loadServe
171
154
  react_1.default.createElement(Component, { fields: componentToUpdate.fields, params: componentToUpdate.params, key: Date.now() })))) : (react_1.default.createElement(Placeholder_1.AppPlaceholder, { name: layout_1.EDITING_COMPONENT_PLACEHOLDER, page: page, rendering: rendering, componentMap: componentMap, key: Date.now() })),
172
155
  react_1.default.createElement(DesignLibraryClientEvents_1.DesignLibraryVariantGenerationEvents, { designLibraryStatus: designLibraryStatus, importMap: importMapInfo,
173
156
  // pass a new object since we have mutated the original which leads to old reference passed to the client
174
- component: Object.assign({}, componentToUpdate), componentInitError: componentInitError, generatedComponentData: generatedComponentData })));
157
+ component: Object.assign({}, componentToUpdate), importMapError: importMapError, previewComponentData: previewComponentData })));
175
158
  };
176
159
  exports.DesignLibraryServerVariantGeneration = DesignLibraryServerVariantGeneration;
177
160
  /**
@@ -199,12 +182,12 @@ const DesignLibraryServerPreview = async ({ page, rendering, componentMap, }) =>
199
182
  designLibraryStatus = editing_1.DesignLibraryStatus.RENDERED;
200
183
  const updateData = getCacheAndClean(componentUpdateKey);
201
184
  // apply the updates to the component rendering
202
- if (updateData === null || updateData === void 0 ? void 0 : updateData.rendering) {
203
- updateComponent(componentToUpdate, updateData.rendering.fields, updateData.rendering.params);
185
+ if (updateData === null || updateData === void 0 ? void 0 : updateData.updatedComponent) {
186
+ updateComponent(componentToUpdate, updateData.updatedComponent.fields, updateData.updatedComponent.params);
204
187
  }
205
188
  }
206
189
  return (react_1.default.createElement(react_1.default.Fragment, null,
207
- react_1.default.createElement(Placeholder_1.AppPlaceholder, { name: layout_1.EDITING_COMPONENT_PLACEHOLDER, page: page, rendering: rendering, componentMap: componentMap, key: Date.now() }),
190
+ react_1.default.createElement(Placeholder_1.AppPlaceholder, { name: layout_1.EDITING_COMPONENT_PLACEHOLDER, page: page, rendering: rendering, componentMap: componentMap }),
208
191
  react_1.default.createElement(DesignLibraryClientEvents_1.DesignLibraryPreviewEvents, { designLibraryStatus: designLibraryStatus,
209
192
  // pass a new object since we have mutated the original which leads to old reference passed to the client
210
193
  component: Object.assign({}, componentToUpdate) })));
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.EditingScripts = void 0;
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const withSitecore_1 = require("../enhancers/withSitecore");
10
- const editing_1 = require("@sitecore-content-sdk/content/editing");
10
+ const editing_1 = require("@sitecore-content-sdk/core/editing");
11
+ const editing_2 = require("@sitecore-content-sdk/core/editing");
11
12
  /**
12
13
  * Renders client scripts and data for editing/preview mode for Pages.
13
14
  * Renders script required for the Design Library (when mode.isDesignLibrary is true).
@@ -31,7 +32,7 @@ const EditingScripts = () => {
31
32
  const month = String(now.getUTCMonth() + 1).padStart(2, '0');
32
33
  const year = String(now.getUTCFullYear());
33
34
  const cacheTimestamp = `${hour}-${day}-${month}-${year}`;
34
- const scriptUrl = `${(0, editing_1.getDesignLibraryScriptLink)((_a = api === null || api === void 0 ? void 0 : api.edge) === null || _a === void 0 ? void 0 : _a.edgeUrl)}?cb=${cacheTimestamp}`;
35
+ const scriptUrl = `${(0, editing_2.getDesignLibraryScriptLink)((_a = api === null || api === void 0 ? void 0 : api.edge) === null || _a === void 0 ? void 0 : _a.edgeUrl)}?cb=${cacheTimestamp}`;
35
36
  return (react_1.default.createElement(react_1.default.Fragment, null,
36
37
  react_1.default.createElement("script", { src: scriptUrl, suppressHydrationWarning: true })));
37
38
  }
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.FieldMetadata = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
- const editing_1 = require("@sitecore-content-sdk/content/editing");
8
+ const editing_1 = require("@sitecore-content-sdk/core/editing");
9
9
  /**
10
10
  * The component which renders field metadata markup
11
11
  * @param {FieldMetadataProps} props the props of the component
@@ -15,7 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.File = void 0;
18
- const layout_1 = require("@sitecore-content-sdk/content/layout");
18
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
19
19
  const react_1 = __importDefault(require("react"));
20
20
  /**
21
21
  * The File component.
@@ -36,10 +36,10 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.Form = exports.mockFormModule = void 0;
38
38
  const react_1 = __importStar(require("react"));
39
- const content_1 = require("@sitecore-content-sdk/content");
39
+ const core_1 = require("@sitecore-content-sdk/core");
40
40
  const withSitecore_1 = require("../enhancers/withSitecore");
41
41
  const ErrorBoundary_1 = require("./ErrorBoundary");
42
- let { executeScriptElements, loadForm, subscribeToFormSubmitEvent } = content_1.form;
42
+ let { executeScriptElements, loadForm, subscribeToFormSubmitEvent } = core_1.form;
43
43
  /**
44
44
  * Mock function to replace the form module functions for `testing` purposes.
45
45
  * @param {any} formModule - The form module to mock
@@ -16,13 +16,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Image = void 0;
18
18
  /* eslint-disable no-unused-vars */
19
- const media_1 = require("@sitecore-content-sdk/content/media");
19
+ const media_1 = require("@sitecore-content-sdk/core/media");
20
20
  const react_1 = __importDefault(require("react"));
21
21
  const utils_1 = require("../utils");
22
22
  const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
23
23
  const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
24
24
  const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
25
- const layout_1 = require("@sitecore-content-sdk/content/layout");
25
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
26
26
  const getImageAttrs = (_a, imageParams, mediaUrlPrefix) => {
27
27
  var { src, srcSet } = _a, otherAttrs = __rest(_a, ["src", "srcSet"]);
28
28
  if (!src) {
@@ -47,7 +47,7 @@ var __rest = (this && this.__rest) || function (s, e) {
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.Link = void 0;
49
49
  const react_1 = __importStar(require("react"));
50
- const layout_1 = require("@sitecore-content-sdk/content/layout");
50
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
51
51
  const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
52
52
  const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
53
53
  const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
@@ -40,7 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.Placeholder = exports.PlaceholderComponent = void 0;
41
41
  const react_1 = __importDefault(require("react"));
42
42
  const withComponentMap_1 = require("../../enhancers/withComponentMap");
43
- const editing_1 = require("@sitecore-content-sdk/content/editing");
43
+ const editing_1 = require("@sitecore-content-sdk/core/editing");
44
44
  const withSitecore_1 = require("../../enhancers/withSitecore");
45
45
  const placeholder_utils_1 = require("./placeholder-utils");
46
46
  const PlaceholderMetadata_1 = require("./PlaceholderMetadata");
@@ -59,6 +59,15 @@ class PlaceholderComponent extends react_1.default.Component {
59
59
  componentDidCatch(error) {
60
60
  this.setState({ error });
61
61
  }
62
+ /**
63
+ * Renders the placeholder when it is empty. The required CSS styles are applied to the placeholder in edit mode.
64
+ * @param {React.ReactNode | React.ReactElement[]} node react node
65
+ * @returns react node
66
+ * @deprecated use renderEmptyPlaceholder from react/nextjs import instead
67
+ */
68
+ renderEmptyPlaceholder(node) {
69
+ return (0, placeholder_utils_1.renderEmptyPlaceholder)(node);
70
+ }
62
71
  render() {
63
72
  const childProps = Object.assign({}, this.props);
64
73
  delete childProps.componentMap;
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PlaceholderMetadata = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
- const layout_1 = require("@sitecore-content-sdk/content/layout");
9
- const editing_1 = require("@sitecore-content-sdk/content/editing");
8
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
9
+ const editing_1 = require("@sitecore-content-sdk/core/editing");
10
10
  /**
11
11
  * A React component to generate metadata blocks for a placeholder or rendering.
12
12
  * It utilizes dynamic attributes based on whether the component acts as a placeholder
@@ -19,8 +19,8 @@ exports.getAppComponentProps = getAppComponentProps;
19
19
  const react_1 = __importDefault(require("react"));
20
20
  const MissingComponent_1 = require("../MissingComponent");
21
21
  const sharedTypes_1 = require("../sharedTypes");
22
- const layout_1 = require("@sitecore-content-sdk/content/layout");
23
- const content_1 = require("@sitecore-content-sdk/content");
22
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
23
+ const core_1 = require("@sitecore-content-sdk/core");
24
24
  const HiddenRendering_1 = require("../HiddenRendering");
25
25
  const FEaaS_1 = require("../FEaaS");
26
26
  /**
@@ -85,7 +85,6 @@ exports.getSXAParams = getSXAParams;
85
85
  * Renders the placeholder when it is empty. The required CSS styles are applied to the placeholder in edit mode.
86
86
  * @param {React.ReactNode | React.ReactElement[]} node react node
87
87
  * @returns react node
88
- * @public
89
88
  */
90
89
  const renderEmptyPlaceholder = (node) => {
91
90
  return react_1.default.createElement("div", { className: "sc-jss-empty-placeholder" }, node);
@@ -137,7 +136,7 @@ const getComponentForRendering = (renderingDefinition, placeholderName, componen
137
136
  const logUnknownComponentError = (variant) => {
138
137
  console.error(`Placeholder ${placeholderName} contains unknown component ${renderingDefinition.componentName}${variant ? ` (${variant})` : ''}. Ensure that a React component exists for it, and that it is registered in your component-map file.`);
139
138
  };
140
- if (renderingDefinition.componentName === content_1.HIDDEN_RENDERING_NAME) {
139
+ if (renderingDefinition.componentName === core_1.constants.HIDDEN_RENDERING_NAME) {
141
140
  return {
142
141
  component: hiddenRenderingComponent !== null && hiddenRenderingComponent !== void 0 ? hiddenRenderingComponent : HiddenRendering_1.HiddenRendering,
143
142
  isEmpty: true,
@@ -47,10 +47,10 @@ var __rest = (this && this.__rest) || function (s, e) {
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.RichText = void 0;
49
49
  const react_1 = __importStar(require("react"));
50
- const layout_1 = require("@sitecore-content-sdk/content/layout");
51
50
  const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
52
51
  const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
53
52
  const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
53
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
54
54
  /**
55
55
  * The RichText component.
56
56
  * @param {RichTextProps} props component props
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SitecoreProvider = exports.ImportMapReactContext = exports.ComponentMapReactContext = exports.SitecoreProviderReactContext = void 0;
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const react_2 = __importDefault(require("fast-deep-equal/es6/react"));
10
+ const core_1 = require("@sitecore-content-sdk/core");
10
11
  /**
11
12
  * The context for the SitecoreProvider component.
12
13
  * @public
@@ -20,6 +21,7 @@ exports.ImportMapReactContext = react_1.default.createContext(undefined);
20
21
  */
21
22
  class SitecoreProvider extends react_1.default.Component {
22
23
  constructor(props) {
24
+ var _a, _b, _c, _d, _e, _f;
23
25
  super(props);
24
26
  /**
25
27
  * Update page state.
@@ -30,10 +32,16 @@ class SitecoreProvider extends react_1.default.Component {
30
32
  page: value,
31
33
  });
32
34
  };
35
+ // If any Edge ID is present but no edgeUrl, apply the default
36
+ let api = props.api;
37
+ if ((((_b = (_a = props.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId) || ((_d = (_c = props.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.clientContextId)) &&
38
+ !((_f = (_e = props.api) === null || _e === void 0 ? void 0 : _e.edge) === null || _f === void 0 ? void 0 : _f.edgeUrl)) {
39
+ api = Object.assign(Object.assign({}, props.api), { edge: Object.assign(Object.assign({}, props.api.edge), { edgeUrl: core_1.constants.SITECORE_EDGE_URL_DEFAULT }) });
40
+ }
33
41
  this.state = {
34
42
  page: props.page,
35
43
  setPage: this.setPage,
36
- api: props.api,
44
+ api,
37
45
  };
38
46
  }
39
47
  componentDidUpdate(prevProps) {
@@ -17,10 +17,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.Text = void 0;
19
19
  const react_1 = __importDefault(require("react"));
20
- const layout_1 = require("@sitecore-content-sdk/content/layout");
21
20
  const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
22
21
  const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
23
22
  const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
23
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
24
24
  /**
25
25
  * The Text component.
26
26
  * @public
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.withEmptyFieldEditingComponent = withEmptyFieldEditingComponent;
37
37
  const react_1 = __importStar(require("react"));
38
- const layout_1 = require("@sitecore-content-sdk/content/layout");
38
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
39
39
  /**
40
40
  * Returns the passed field component or default component in case field value is empty and edit mode is 'metadata'
41
41
  * @param {ComponentType<FieldComponentProps>} FieldComponent the field component
@@ -33,18 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.useLoadImportMap = useLoadImportMap;
37
36
  exports.withLoadImportMap = withLoadImportMap;
38
37
  const react_1 = __importStar(require("react"));
39
38
  const SitecoreProvider_1 = require("../components/SitecoreProvider");
40
- /**
41
- * Hook that retrieves the loadImportMap function from context.
42
- * @returns {() => Promise<ImportMapImport> | undefined} The loadImportMap function from context, or undefined if not available.
43
- * @public
44
- */
45
- function useLoadImportMap() {
46
- return (0, react_1.useContext)(SitecoreProvider_1.ImportMapReactContext);
47
- }
48
39
  /**
49
40
  * Higher-order component that injects the loadImportMap function from context into component props.
50
41
  * If the component already receives loadImportMap via props, the prop value takes precedence.
@@ -53,7 +44,7 @@ function useLoadImportMap() {
53
44
  */
54
45
  function withLoadImportMap(Component) {
55
46
  const WithLoadImportMap = (props) => {
56
- const loadImportMapContext = useLoadImportMap();
47
+ const loadImportMapContext = (0, react_1.useContext)(SitecoreProvider_1.ImportMapReactContext);
57
48
  const loadClientImportMap = props.loadImportMap || loadImportMapContext;
58
49
  return react_1.default.createElement(Component, Object.assign({}, props, { loadImportMap: loadClientImportMap }));
59
50
  };