@sitecore-content-sdk/content 1.5.0-canary.9 → 2.0.0-canary.2
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/editing/codegen/index.js +2 -1
- package/dist/cjs/editing/codegen/preview.js +37 -8
- package/dist/cjs/editing/design-library.js +9 -2
- package/dist/cjs/editing/index.js +2 -1
- package/dist/cjs/tools/codegen/import-map.js +4 -4
- package/dist/esm/editing/codegen/index.js +1 -1
- package/dist/esm/editing/codegen/preview.js +33 -8
- package/dist/esm/editing/design-library.js +8 -1
- package/dist/esm/editing/index.js +1 -1
- package/dist/esm/tools/codegen/import-map.js +4 -4
- package/package.json +3 -3
- package/types/editing/codegen/index.d.ts +1 -1
- package/types/editing/codegen/index.d.ts.map +1 -1
- package/types/editing/codegen/preview.d.ts +68 -35
- package/types/editing/codegen/preview.d.ts.map +1 -1
- package/types/editing/design-library.d.ts +8 -1
- package/types/editing/design-library.d.ts.map +1 -1
- package/types/editing/index.d.ts +1 -1
- package/types/editing/index.d.ts.map +1 -1
- package/types/tools/codegen/import-map.d.ts +3 -4
- package/types/tools/codegen/import-map.d.ts.map +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DesignLibraryPreviewError = exports.sendErrorEvent = exports.createComponentInstance = exports.addStyleElement = exports.getImportMapInfo = exports.getDesignLibraryImportMapEvent = exports.getDesignLibraryComponentPropsEvent = exports.getDesignLibraryComponentPreviewErrorEvent = exports.addServerComponentPreviewHandler = exports.addComponentPreviewHandler = void 0;
|
|
3
|
+
exports.fetchGeneratedComponentFromCache = exports.DesignLibraryPreviewError = exports.sendErrorEvent = exports.createComponentInstance = exports.addStyleElement = exports.getImportMapInfo = exports.getDesignLibraryImportMapEvent = exports.getDesignLibraryComponentPropsEvent = exports.getDesignLibraryComponentPreviewErrorEvent = exports.addServerComponentPreviewHandler = exports.addComponentPreviewHandler = void 0;
|
|
4
4
|
var preview_1 = require("./preview");
|
|
5
5
|
Object.defineProperty(exports, "addComponentPreviewHandler", { enumerable: true, get: function () { return preview_1.addComponentPreviewHandler; } });
|
|
6
6
|
Object.defineProperty(exports, "addServerComponentPreviewHandler", { enumerable: true, get: function () { return preview_1.addServerComponentPreviewHandler; } });
|
|
@@ -12,3 +12,4 @@ Object.defineProperty(exports, "addStyleElement", { enumerable: true, get: funct
|
|
|
12
12
|
Object.defineProperty(exports, "createComponentInstance", { enumerable: true, get: function () { return preview_1.createComponentInstance; } });
|
|
13
13
|
Object.defineProperty(exports, "sendErrorEvent", { enumerable: true, get: function () { return preview_1.sendErrorEvent; } });
|
|
14
14
|
Object.defineProperty(exports, "DesignLibraryPreviewError", { enumerable: true, get: function () { return preview_1.DesignLibraryPreviewError; } });
|
|
15
|
+
Object.defineProperty(exports, "fetchGeneratedComponentFromCache", { enumerable: true, get: function () { return preview_1.fetchGeneratedComponentFromCache; } });
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.sendErrorEvent = exports.createComponentInstance = exports.addServerComponentPreviewHandler = exports.addComponentPreviewHandler = exports.DesignLibraryPreviewError = void 0;
|
|
4
7
|
exports.buildComponentDependencies = buildComponentDependencies;
|
|
@@ -8,7 +11,11 @@ exports.getDesignLibraryComponentPropsEvent = getDesignLibraryComponentPropsEven
|
|
|
8
11
|
exports.getDesignLibraryImportMapEvent = getDesignLibraryImportMapEvent;
|
|
9
12
|
exports.getImportMapInfo = getImportMapInfo;
|
|
10
13
|
exports.isImportEntryInfoArray = isImportEntryInfoArray;
|
|
14
|
+
exports.fetchGeneratedComponentFromCache = fetchGeneratedComponentFromCache;
|
|
15
|
+
const core_1 = require("@sitecore-content-sdk/core");
|
|
11
16
|
const design_library_1 = require("../design-library");
|
|
17
|
+
const debug_1 = __importDefault(require("../../debug"));
|
|
18
|
+
const { SITECORE_EDGE_PLATFORM_URL_DEFAULT } = core_1.constants;
|
|
12
19
|
/**
|
|
13
20
|
* Event to send import map to design library
|
|
14
21
|
*/
|
|
@@ -97,7 +104,7 @@ const addComponentPreviewHandler = (importMap, callback) => {
|
|
|
97
104
|
return;
|
|
98
105
|
}
|
|
99
106
|
console.debug('Component Library: message received', eventArgs);
|
|
100
|
-
const Component = (0, exports.createComponentInstance)(importMap, eventArgs);
|
|
107
|
+
const Component = (0, exports.createComponentInstance)(importMap, eventArgs.message);
|
|
101
108
|
addStyleElement(eventArgs.message.styles.content);
|
|
102
109
|
callback(null, Component);
|
|
103
110
|
}
|
|
@@ -115,7 +122,7 @@ const addComponentPreviewHandler = (importMap, callback) => {
|
|
|
115
122
|
exports.addComponentPreviewHandler = addComponentPreviewHandler;
|
|
116
123
|
/**
|
|
117
124
|
* Adds the browser-side event handler for 'component:generation:component-preview' message used in Design Library for server components
|
|
118
|
-
* The event should contain the component code, styles and imports
|
|
125
|
+
* The event should contain the cache id and token which will be used to fetch the component code, styles and imports from secured endpoint
|
|
119
126
|
* @param {Function} callback callback to be called after component is received
|
|
120
127
|
* @internal
|
|
121
128
|
*/
|
|
@@ -157,14 +164,13 @@ function addStyleElement(stylesContent) {
|
|
|
157
164
|
/**
|
|
158
165
|
* Dynamically creates a React component instance from provided importMap and from code, styles, and dependencies provided in the preview event.
|
|
159
166
|
* @param {ImportEntry[]} importMap - The import map containing module and export references that might be injected as dependencies in the provided code.
|
|
160
|
-
* @param {
|
|
167
|
+
* @param {GeneratedComponentData} generatedComponentData - The generated component data received from design library.
|
|
161
168
|
* @returns The dynamically created React component instance.
|
|
162
169
|
* @throws If any required modules or exports are missing from the import map, an error is thrown describing the missing dependencies.
|
|
163
170
|
* @internal
|
|
164
171
|
*/
|
|
165
|
-
const createComponentInstance = (importMap,
|
|
166
|
-
const
|
|
167
|
-
const dependencies = buildComponentDependencies(message.imports, importMap);
|
|
172
|
+
const createComponentInstance = (importMap, generatedComponentData) => {
|
|
173
|
+
const dependencies = buildComponentDependencies(generatedComponentData.imports, importMap);
|
|
168
174
|
if (dependencies.missing.modules.length > 0 || dependencies.missing.exports.length > 0) {
|
|
169
175
|
let errorMessage = '';
|
|
170
176
|
dependencies.missing.modules.forEach((mod) => {
|
|
@@ -179,9 +185,9 @@ const createComponentInstance = (importMap, previewEventArgs) => {
|
|
|
179
185
|
const importNames = dependencies.successful.map((entry) => entry.name);
|
|
180
186
|
const importInstances = dependencies.successful.map((entry) => entry.value);
|
|
181
187
|
const exports = { Component: null };
|
|
182
|
-
const componentFn = new Function('exports',
|
|
188
|
+
const componentFn = new Function('exports', generatedComponentData.styles.styleImport.name, ...importNames, generatedComponentData.code.content);
|
|
183
189
|
// Function will set exports.Component
|
|
184
|
-
componentFn(exports,
|
|
190
|
+
componentFn(exports, generatedComponentData.styles.styleImport.content, ...importInstances);
|
|
185
191
|
return exports.Component;
|
|
186
192
|
};
|
|
187
193
|
exports.createComponentInstance = createComponentInstance;
|
|
@@ -275,3 +281,26 @@ const sendErrorEvent = (uid, error, type) => {
|
|
|
275
281
|
}
|
|
276
282
|
};
|
|
277
283
|
exports.sendErrorEvent = sendErrorEvent;
|
|
284
|
+
/**
|
|
285
|
+
* Fetches generated component data from the authoring cache endpoint.
|
|
286
|
+
* This is used by the Design Studio Server to fetch the updated component data from the secured cache endpoint and render it in the Design Library Studio preview iframe.
|
|
287
|
+
* @param {string} id - The unique identifier of the component to fetch from cache.
|
|
288
|
+
* @param {string} token - The authorization token for authentication.
|
|
289
|
+
* @param {string} [edgeUrl] - The URL of the Sitecore Edge endpoint.
|
|
290
|
+
* @returns A Promise that resolves to the component rendering data, component generation data, or undefined if the fetch fails.
|
|
291
|
+
* @internal
|
|
292
|
+
*/
|
|
293
|
+
async function fetchGeneratedComponentFromCache(id, token, edgeUrl = SITECORE_EDGE_PLATFORM_URL_DEFAULT) {
|
|
294
|
+
const dataFetcher = new core_1.NativeDataFetcher({ debugger: debug_1.default.editing });
|
|
295
|
+
const componentDataResponse = await dataFetcher.fetch(`${edgeUrl}/authoring/api/v1/components/cache/${id}`, {
|
|
296
|
+
method: 'GET',
|
|
297
|
+
headers: {
|
|
298
|
+
Authorization: `Bearer ${token}`,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
if (componentDataResponse.status !== 200) {
|
|
302
|
+
throw new Error(`Failed to fetch generated component data from cache for id: ${id}. Response Status: ${componentDataResponse.status}, Response Status Text: ${componentDataResponse.statusText}`);
|
|
303
|
+
}
|
|
304
|
+
const generatedComponentData = JSON.parse(componentDataResponse.data.content);
|
|
305
|
+
return generatedComponentData;
|
|
306
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.postToDesignLibrary = exports.updateComponent = exports.updateComponentHandler = exports.validateEvent = exports.validateOrigin = exports.addComponentUpdateHandler = exports.DesignLibraryStatus = exports.COMPONENT_UPDATE_CACHE_KEY_PREFIX = void 0;
|
|
3
|
+
exports.postToDesignLibrary = exports.updateComponent = exports.updateComponentHandler = exports.validateEvent = exports.validateOrigin = exports.addComponentUpdateHandler = exports.DesignLibraryStatus = exports.COMPONENT_PREVIEW_CACHE_KEY_PREFIX = exports.COMPONENT_UPDATE_CACHE_KEY_PREFIX = void 0;
|
|
4
4
|
exports.getDesignLibraryStatusEvent = getDesignLibraryStatusEvent;
|
|
5
5
|
exports.getDesignLibraryScriptLink = getDesignLibraryScriptLink;
|
|
6
6
|
exports.isDesignLibraryMode = isDesignLibraryMode;
|
|
@@ -16,6 +16,11 @@ const DESIGN_LIBRARY_STATUS_EVENT_NAME = 'component:status';
|
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
18
|
exports.COMPONENT_UPDATE_CACHE_KEY_PREFIX = 'component-update-';
|
|
19
|
+
/**
|
|
20
|
+
* Prefix for component preview cache keys
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
exports.COMPONENT_PREVIEW_CACHE_KEY_PREFIX = 'component-preview-';
|
|
19
24
|
/**
|
|
20
25
|
* Enumeration of statuses for the design library.
|
|
21
26
|
* @internal
|
|
@@ -133,15 +138,17 @@ exports.updateComponent = updateComponent;
|
|
|
133
138
|
* Generates a DesignLibraryStatusEvent with the given status and uid.
|
|
134
139
|
* @param {DesignLibraryStatus} status - The status of rendering.
|
|
135
140
|
* @param {string} uid - The unique identifier for the event.
|
|
141
|
+
* @param {boolean} [isRenderingServerComponent] - Indicates if the component being rendered is a server component.
|
|
136
142
|
* @returns An object representing the DesignLibraryStatusEvent.
|
|
137
143
|
* @internal
|
|
138
144
|
*/
|
|
139
|
-
function getDesignLibraryStatusEvent(status, uid) {
|
|
145
|
+
function getDesignLibraryStatusEvent(status, uid, isRenderingServerComponent = false) {
|
|
140
146
|
return {
|
|
141
147
|
name: DESIGN_LIBRARY_STATUS_EVENT_NAME,
|
|
142
148
|
message: {
|
|
143
149
|
status,
|
|
144
150
|
uid,
|
|
151
|
+
isRenderingServerComponent,
|
|
145
152
|
},
|
|
146
153
|
};
|
|
147
154
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateComponent = exports.COMPONENT_UPDATE_CACHE_KEY_PREFIX = exports.postToDesignLibrary = exports.isDesignLibraryMode = exports.getDesignLibraryScriptLink = exports.getDesignLibraryStatusEvent = exports.DesignLibraryStatus = exports.addComponentUpdateHandler = exports.DesignLibraryMode = exports.MetadataKind = exports.LayoutKind = exports.DesignLibraryVariantGeneration = exports.ComponentLayoutService = exports.PREVIEW_KEY = exports.PAGES_EDITING_MARKER = exports.INVALID_SECRET_HTML_MESSAGE = exports.QUERY_PARAM_EDITING_SECRET = exports.EDITING_ALLOWED_ORIGINS = exports.getContentSdkPagesClientData = exports.resetEditorChromes = exports.isEditorActive = exports.PagesEditor = exports.DEFAULT_PLACEHOLDER_UID = exports.EditingService = void 0;
|
|
3
|
+
exports.updateComponent = exports.COMPONENT_PREVIEW_CACHE_KEY_PREFIX = exports.COMPONENT_UPDATE_CACHE_KEY_PREFIX = exports.postToDesignLibrary = exports.isDesignLibraryMode = exports.getDesignLibraryScriptLink = exports.getDesignLibraryStatusEvent = exports.DesignLibraryStatus = exports.addComponentUpdateHandler = exports.DesignLibraryMode = exports.MetadataKind = exports.LayoutKind = exports.DesignLibraryVariantGeneration = exports.ComponentLayoutService = exports.PREVIEW_KEY = exports.PAGES_EDITING_MARKER = exports.INVALID_SECRET_HTML_MESSAGE = exports.QUERY_PARAM_EDITING_SECRET = exports.EDITING_ALLOWED_ORIGINS = exports.getContentSdkPagesClientData = exports.resetEditorChromes = exports.isEditorActive = exports.PagesEditor = exports.DEFAULT_PLACEHOLDER_UID = exports.EditingService = void 0;
|
|
4
4
|
var editing_service_1 = require("./editing-service");
|
|
5
5
|
Object.defineProperty(exports, "EditingService", { enumerable: true, get: function () { return editing_service_1.EditingService; } });
|
|
6
6
|
var utils_1 = require("./utils");
|
|
@@ -30,4 +30,5 @@ Object.defineProperty(exports, "getDesignLibraryScriptLink", { enumerable: true,
|
|
|
30
30
|
Object.defineProperty(exports, "isDesignLibraryMode", { enumerable: true, get: function () { return design_library_1.isDesignLibraryMode; } });
|
|
31
31
|
Object.defineProperty(exports, "postToDesignLibrary", { enumerable: true, get: function () { return design_library_1.postToDesignLibrary; } });
|
|
32
32
|
Object.defineProperty(exports, "COMPONENT_UPDATE_CACHE_KEY_PREFIX", { enumerable: true, get: function () { return design_library_1.COMPONENT_UPDATE_CACHE_KEY_PREFIX; } });
|
|
33
|
+
Object.defineProperty(exports, "COMPONENT_PREVIEW_CACHE_KEY_PREFIX", { enumerable: true, get: function () { return design_library_1.COMPONENT_PREVIEW_CACHE_KEY_PREFIX; } });
|
|
33
34
|
Object.defineProperty(exports, "updateComponent", { enumerable: true, get: function () { return design_library_1.updateComponent; } });
|
|
@@ -283,7 +283,7 @@ const prepImportMaps = async (paths, separateMaps) => {
|
|
|
283
283
|
*/
|
|
284
284
|
const writeImportMap = (args) => {
|
|
285
285
|
return async ({ scConfig }) => {
|
|
286
|
-
const defaultTemplate = args.
|
|
286
|
+
const defaultTemplate = args.defaultTemplate || exports.defaultMapTemplate;
|
|
287
287
|
const clientTemplate = args.clientTemplate || exports.defaultMapTemplate;
|
|
288
288
|
if (!scConfig) {
|
|
289
289
|
throw new Error('Sitecore configuration is required to be provided');
|
|
@@ -319,7 +319,7 @@ const writeImportMap = (args) => {
|
|
|
319
319
|
};
|
|
320
320
|
exports.writeImportMap = writeImportMap;
|
|
321
321
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
322
|
-
function _defaultMapTemplate(indexedImportMap, framework = 'core') {
|
|
322
|
+
function _defaultMapTemplate(indexedImportMap, framework = 'core', defaultImportEntriesImport = 'defaultImportEntries') {
|
|
323
323
|
const importStatements = [];
|
|
324
324
|
const importMapArray = Array.from(indexedImportMap);
|
|
325
325
|
// get import map entries after
|
|
@@ -371,7 +371,7 @@ function _defaultMapTemplate(indexedImportMap, framework = 'core') {
|
|
|
371
371
|
// Below are built-in Content SDK imports neccessary for the import map
|
|
372
372
|
import {
|
|
373
373
|
combineImportEntries,
|
|
374
|
-
|
|
374
|
+
${defaultImportEntriesImport},
|
|
375
375
|
ImportEntry,
|
|
376
376
|
} from '@sitecore-content-sdk/${framework}/codegen';
|
|
377
377
|
// end of built-in imports
|
|
@@ -393,6 +393,6 @@ ${finalImportMap
|
|
|
393
393
|
.join(',\n')}
|
|
394
394
|
] as ImportEntry[];
|
|
395
395
|
|
|
396
|
-
export default combineImportEntries(
|
|
396
|
+
export default combineImportEntries(${defaultImportEntriesImport}, importMap);
|
|
397
397
|
`;
|
|
398
398
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { addComponentPreviewHandler, addServerComponentPreviewHandler, getDesignLibraryComponentPreviewErrorEvent, getDesignLibraryComponentPropsEvent, getDesignLibraryImportMapEvent, getImportMapInfo, addStyleElement, createComponentInstance, sendErrorEvent, DesignLibraryPreviewError, } from './preview';
|
|
1
|
+
export { addComponentPreviewHandler, addServerComponentPreviewHandler, getDesignLibraryComponentPreviewErrorEvent, getDesignLibraryComponentPropsEvent, getDesignLibraryImportMapEvent, getImportMapInfo, addStyleElement, createComponentInstance, sendErrorEvent, DesignLibraryPreviewError, fetchGeneratedComponentFromCache, } from './preview';
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { NativeDataFetcher, constants } from '@sitecore-content-sdk/core';
|
|
1
2
|
import { validateEvent } from '../design-library';
|
|
3
|
+
import debug from '../../debug';
|
|
4
|
+
const { SITECORE_EDGE_PLATFORM_URL_DEFAULT } = constants;
|
|
2
5
|
/**
|
|
3
6
|
* Event to send import map to design library
|
|
4
7
|
*/
|
|
@@ -87,7 +90,7 @@ export const addComponentPreviewHandler = (importMap, callback) => {
|
|
|
87
90
|
return;
|
|
88
91
|
}
|
|
89
92
|
console.debug('Component Library: message received', eventArgs);
|
|
90
|
-
const Component = createComponentInstance(importMap, eventArgs);
|
|
93
|
+
const Component = createComponentInstance(importMap, eventArgs.message);
|
|
91
94
|
addStyleElement(eventArgs.message.styles.content);
|
|
92
95
|
callback(null, Component);
|
|
93
96
|
}
|
|
@@ -104,7 +107,7 @@ export const addComponentPreviewHandler = (importMap, callback) => {
|
|
|
104
107
|
};
|
|
105
108
|
/**
|
|
106
109
|
* Adds the browser-side event handler for 'component:generation:component-preview' message used in Design Library for server components
|
|
107
|
-
* The event should contain the component code, styles and imports
|
|
110
|
+
* The event should contain the cache id and token which will be used to fetch the component code, styles and imports from secured endpoint
|
|
108
111
|
* @param {Function} callback callback to be called after component is received
|
|
109
112
|
* @internal
|
|
110
113
|
*/
|
|
@@ -145,14 +148,13 @@ export function addStyleElement(stylesContent) {
|
|
|
145
148
|
/**
|
|
146
149
|
* Dynamically creates a React component instance from provided importMap and from code, styles, and dependencies provided in the preview event.
|
|
147
150
|
* @param {ImportEntry[]} importMap - The import map containing module and export references that might be injected as dependencies in the provided code.
|
|
148
|
-
* @param {
|
|
151
|
+
* @param {GeneratedComponentData} generatedComponentData - The generated component data received from design library.
|
|
149
152
|
* @returns The dynamically created React component instance.
|
|
150
153
|
* @throws If any required modules or exports are missing from the import map, an error is thrown describing the missing dependencies.
|
|
151
154
|
* @internal
|
|
152
155
|
*/
|
|
153
|
-
export const createComponentInstance = (importMap,
|
|
154
|
-
const
|
|
155
|
-
const dependencies = buildComponentDependencies(message.imports, importMap);
|
|
156
|
+
export const createComponentInstance = (importMap, generatedComponentData) => {
|
|
157
|
+
const dependencies = buildComponentDependencies(generatedComponentData.imports, importMap);
|
|
156
158
|
if (dependencies.missing.modules.length > 0 || dependencies.missing.exports.length > 0) {
|
|
157
159
|
let errorMessage = '';
|
|
158
160
|
dependencies.missing.modules.forEach((mod) => {
|
|
@@ -167,9 +169,9 @@ export const createComponentInstance = (importMap, previewEventArgs) => {
|
|
|
167
169
|
const importNames = dependencies.successful.map((entry) => entry.name);
|
|
168
170
|
const importInstances = dependencies.successful.map((entry) => entry.value);
|
|
169
171
|
const exports = { Component: null };
|
|
170
|
-
const componentFn = new Function('exports',
|
|
172
|
+
const componentFn = new Function('exports', generatedComponentData.styles.styleImport.name, ...importNames, generatedComponentData.code.content);
|
|
171
173
|
// Function will set exports.Component
|
|
172
|
-
componentFn(exports,
|
|
174
|
+
componentFn(exports, generatedComponentData.styles.styleImport.content, ...importInstances);
|
|
173
175
|
return exports.Component;
|
|
174
176
|
};
|
|
175
177
|
/**
|
|
@@ -261,3 +263,26 @@ export const sendErrorEvent = (uid, error, type) => {
|
|
|
261
263
|
target.postMessage(errorEvent, '*');
|
|
262
264
|
}
|
|
263
265
|
};
|
|
266
|
+
/**
|
|
267
|
+
* Fetches generated component data from the authoring cache endpoint.
|
|
268
|
+
* This is used by the Design Studio Server to fetch the updated component data from the secured cache endpoint and render it in the Design Library Studio preview iframe.
|
|
269
|
+
* @param {string} id - The unique identifier of the component to fetch from cache.
|
|
270
|
+
* @param {string} token - The authorization token for authentication.
|
|
271
|
+
* @param {string} [edgeUrl] - The URL of the Sitecore Edge endpoint.
|
|
272
|
+
* @returns A Promise that resolves to the component rendering data, component generation data, or undefined if the fetch fails.
|
|
273
|
+
* @internal
|
|
274
|
+
*/
|
|
275
|
+
export async function fetchGeneratedComponentFromCache(id, token, edgeUrl = SITECORE_EDGE_PLATFORM_URL_DEFAULT) {
|
|
276
|
+
const dataFetcher = new NativeDataFetcher({ debugger: debug.editing });
|
|
277
|
+
const componentDataResponse = await dataFetcher.fetch(`${edgeUrl}/authoring/api/v1/components/cache/${id}`, {
|
|
278
|
+
method: 'GET',
|
|
279
|
+
headers: {
|
|
280
|
+
Authorization: `Bearer ${token}`,
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
if (componentDataResponse.status !== 200) {
|
|
284
|
+
throw new Error(`Failed to fetch generated component data from cache for id: ${id}. Response Status: ${componentDataResponse.status}, Response Status Text: ${componentDataResponse.statusText}`);
|
|
285
|
+
}
|
|
286
|
+
const generatedComponentData = JSON.parse(componentDataResponse.data.content);
|
|
287
|
+
return generatedComponentData;
|
|
288
|
+
}
|
|
@@ -10,6 +10,11 @@ const DESIGN_LIBRARY_STATUS_EVENT_NAME = 'component:status';
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export const COMPONENT_UPDATE_CACHE_KEY_PREFIX = 'component-update-';
|
|
13
|
+
/**
|
|
14
|
+
* Prefix for component preview cache keys
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export const COMPONENT_PREVIEW_CACHE_KEY_PREFIX = 'component-preview-';
|
|
13
18
|
/**
|
|
14
19
|
* Enumeration of statuses for the design library.
|
|
15
20
|
* @internal
|
|
@@ -122,15 +127,17 @@ export const updateComponent = (component, fields, params) => {
|
|
|
122
127
|
* Generates a DesignLibraryStatusEvent with the given status and uid.
|
|
123
128
|
* @param {DesignLibraryStatus} status - The status of rendering.
|
|
124
129
|
* @param {string} uid - The unique identifier for the event.
|
|
130
|
+
* @param {boolean} [isRenderingServerComponent] - Indicates if the component being rendered is a server component.
|
|
125
131
|
* @returns An object representing the DesignLibraryStatusEvent.
|
|
126
132
|
* @internal
|
|
127
133
|
*/
|
|
128
|
-
export function getDesignLibraryStatusEvent(status, uid) {
|
|
134
|
+
export function getDesignLibraryStatusEvent(status, uid, isRenderingServerComponent = false) {
|
|
129
135
|
return {
|
|
130
136
|
name: DESIGN_LIBRARY_STATUS_EVENT_NAME,
|
|
131
137
|
message: {
|
|
132
138
|
status,
|
|
133
139
|
uid,
|
|
140
|
+
isRenderingServerComponent,
|
|
134
141
|
},
|
|
135
142
|
};
|
|
136
143
|
}
|
|
@@ -3,4 +3,4 @@ export { DEFAULT_PLACEHOLDER_UID, PagesEditor, isEditorActive, resetEditorChrome
|
|
|
3
3
|
export { ComponentLayoutService, } from './component-layout-service';
|
|
4
4
|
export { DesignLibraryVariantGeneration, } from './models';
|
|
5
5
|
export { LayoutKind, MetadataKind, DesignLibraryMode, } from './models';
|
|
6
|
-
export { addComponentUpdateHandler, DesignLibraryStatus, getDesignLibraryStatusEvent, getDesignLibraryScriptLink, isDesignLibraryMode, postToDesignLibrary, COMPONENT_UPDATE_CACHE_KEY_PREFIX, updateComponent, } from './design-library';
|
|
6
|
+
export { addComponentUpdateHandler, DesignLibraryStatus, getDesignLibraryStatusEvent, getDesignLibraryScriptLink, isDesignLibraryMode, postToDesignLibrary, COMPONENT_UPDATE_CACHE_KEY_PREFIX, COMPONENT_PREVIEW_CACHE_KEY_PREFIX, updateComponent, } from './design-library';
|
|
@@ -241,7 +241,7 @@ const prepImportMaps = async (paths, separateMaps) => {
|
|
|
241
241
|
*/
|
|
242
242
|
export const writeImportMap = (args) => {
|
|
243
243
|
return async ({ scConfig }) => {
|
|
244
|
-
const defaultTemplate = args.
|
|
244
|
+
const defaultTemplate = args.defaultTemplate || defaultMapTemplate;
|
|
245
245
|
const clientTemplate = args.clientTemplate || defaultMapTemplate;
|
|
246
246
|
if (!scConfig) {
|
|
247
247
|
throw new Error('Sitecore configuration is required to be provided');
|
|
@@ -276,7 +276,7 @@ export const writeImportMap = (args) => {
|
|
|
276
276
|
};
|
|
277
277
|
};
|
|
278
278
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
279
|
-
function _defaultMapTemplate(indexedImportMap, framework = 'core') {
|
|
279
|
+
function _defaultMapTemplate(indexedImportMap, framework = 'core', defaultImportEntriesImport = 'defaultImportEntries') {
|
|
280
280
|
const importStatements = [];
|
|
281
281
|
const importMapArray = Array.from(indexedImportMap);
|
|
282
282
|
// get import map entries after
|
|
@@ -328,7 +328,7 @@ function _defaultMapTemplate(indexedImportMap, framework = 'core') {
|
|
|
328
328
|
// Below are built-in Content SDK imports neccessary for the import map
|
|
329
329
|
import {
|
|
330
330
|
combineImportEntries,
|
|
331
|
-
|
|
331
|
+
${defaultImportEntriesImport},
|
|
332
332
|
ImportEntry,
|
|
333
333
|
} from '@sitecore-content-sdk/${framework}/codegen';
|
|
334
334
|
// end of built-in imports
|
|
@@ -350,6 +350,6 @@ ${finalImportMap
|
|
|
350
350
|
.join(',\n')}
|
|
351
351
|
] as ImportEntry[];
|
|
352
352
|
|
|
353
|
-
export default combineImportEntries(
|
|
353
|
+
export default combineImportEntries(${defaultImportEntriesImport}, importMap);
|
|
354
354
|
`;
|
|
355
355
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/content",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-canary.2",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@sitecore-cloudsdk/events": "^0.5.1"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@sitecore-content-sdk/core": "
|
|
80
|
+
"@sitecore-content-sdk/core": "2.0.0-canary.2",
|
|
81
81
|
"chalk": "^4.1.2",
|
|
82
82
|
"debug": "^4.4.0",
|
|
83
83
|
"glob": "^11.0.2",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
},
|
|
87
87
|
"description": "",
|
|
88
88
|
"types": "types/index.d.ts",
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "fb5a8d3373cf15bbb9dcc2312b80825fe7d82ac8",
|
|
90
90
|
"files": [
|
|
91
91
|
"dist",
|
|
92
92
|
"types",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { addComponentPreviewHandler, addServerComponentPreviewHandler, getDesignLibraryComponentPreviewErrorEvent, getDesignLibraryComponentPropsEvent, getDesignLibraryImportMapEvent, getImportMapInfo, addStyleElement, createComponentInstance, sendErrorEvent, DesignLibraryPreviewError, ImportEntry, ImportEntryInfo, ComponentPreviewEventArgs, } from './preview';
|
|
1
|
+
export { addComponentPreviewHandler, addServerComponentPreviewHandler, getDesignLibraryComponentPreviewErrorEvent, getDesignLibraryComponentPropsEvent, getDesignLibraryImportMapEvent, getImportMapInfo, addStyleElement, createComponentInstance, sendErrorEvent, DesignLibraryPreviewError, ImportEntry, ImportEntryInfo, GeneratedComponentData, ComponentPreviewEventArgs, ServerComponentPreviewEventArgs, fetchGeneratedComponentFromCache, } from './preview';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editing/codegen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,0CAA0C,EAC1C,mCAAmC,EACnC,8BAA8B,EAC9B,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,cAAc,EACd,yBAAyB,EACzB,WAAW,EACX,eAAe,EACf,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editing/codegen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,0CAA0C,EAC1C,mCAAmC,EACnC,8BAA8B,EAC9B,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,cAAc,EACd,yBAAyB,EACzB,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,yBAAyB,EACzB,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,WAAW,CAAC"}
|
|
@@ -56,50 +56,73 @@ export type ComponentImport = {
|
|
|
56
56
|
alias: string;
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
|
-
* Represents
|
|
59
|
+
* Represents the data needed to render AI generated component.
|
|
60
60
|
* @internal
|
|
61
61
|
*/
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
export type GeneratedComponentData = {
|
|
63
|
+
/**
|
|
64
|
+
* The unique identifier for the component.
|
|
65
|
+
*/
|
|
66
|
+
uid: string;
|
|
67
|
+
/**
|
|
68
|
+
* The code of the component.
|
|
69
|
+
*/
|
|
70
|
+
code: {
|
|
71
|
+
type: 'function';
|
|
72
|
+
content: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* The styles of the component.
|
|
76
|
+
*/
|
|
77
|
+
styles: {
|
|
78
|
+
type: 'style-element';
|
|
69
79
|
/**
|
|
70
|
-
* The
|
|
80
|
+
* The styles content to be attached to the DOM.
|
|
71
81
|
*/
|
|
72
|
-
|
|
73
|
-
type: 'function';
|
|
74
|
-
content: string;
|
|
75
|
-
};
|
|
82
|
+
content: string;
|
|
76
83
|
/**
|
|
77
|
-
* The
|
|
84
|
+
* The CSS module import
|
|
78
85
|
*/
|
|
79
|
-
|
|
80
|
-
type: 'style-element';
|
|
86
|
+
styleImport: {
|
|
81
87
|
/**
|
|
82
|
-
* The
|
|
88
|
+
* The name of the style import.
|
|
83
89
|
*/
|
|
84
|
-
|
|
90
|
+
name: string;
|
|
85
91
|
/**
|
|
86
|
-
* The
|
|
92
|
+
* The value of the style import
|
|
87
93
|
*/
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The name of the style import.
|
|
91
|
-
*/
|
|
92
|
-
name: string;
|
|
93
|
-
/**
|
|
94
|
-
* The value of the style import
|
|
95
|
-
*/
|
|
96
|
-
content: unknown;
|
|
97
|
-
};
|
|
94
|
+
content: unknown;
|
|
98
95
|
};
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The imports of the component.
|
|
99
|
+
*/
|
|
100
|
+
imports: ComponentImport[];
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Represents a component preview event data sent from design library
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
export interface ComponentPreviewEventArgs extends DesignLibraryEvent {
|
|
107
|
+
name: typeof DESIGN_LIBRARY_COMPONENT_PREVIEW_EVENT_NAME;
|
|
108
|
+
message: GeneratedComponentData;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Represents a server component preview event data sent from design library in variant generation mode.
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
export interface ServerComponentPreviewEventArgs extends DesignLibraryEvent {
|
|
115
|
+
name: typeof DESIGN_LIBRARY_COMPONENT_PREVIEW_EVENT_NAME;
|
|
116
|
+
message: {
|
|
99
117
|
/**
|
|
100
|
-
* The
|
|
118
|
+
* The cache information for the component preview, used for server components in Design Library variant generation mode.
|
|
101
119
|
*/
|
|
102
|
-
|
|
120
|
+
cache: {
|
|
121
|
+
/** The unique identifier for the cache entry. */
|
|
122
|
+
id: string;
|
|
123
|
+
/** The jwt token for authentication when fetching the preview component from the cache. */
|
|
124
|
+
token: string;
|
|
125
|
+
};
|
|
103
126
|
};
|
|
104
127
|
}
|
|
105
128
|
/**
|
|
@@ -184,11 +207,11 @@ export declare function buildComponentDependencies(componentImports: ComponentIm
|
|
|
184
207
|
export declare const addComponentPreviewHandler: (importMap: ImportEntry[], callback: (error: unknown | null, Component: unknown) => void) => (() => void) | undefined;
|
|
185
208
|
/**
|
|
186
209
|
* Adds the browser-side event handler for 'component:generation:component-preview' message used in Design Library for server components
|
|
187
|
-
* The event should contain the component code, styles and imports
|
|
210
|
+
* The event should contain the cache id and token which will be used to fetch the component code, styles and imports from secured endpoint
|
|
188
211
|
* @param {Function} callback callback to be called after component is received
|
|
189
212
|
* @internal
|
|
190
213
|
*/
|
|
191
|
-
export declare const addServerComponentPreviewHandler: (callback: (eventArgs:
|
|
214
|
+
export declare const addServerComponentPreviewHandler: (callback: (eventArgs: ServerComponentPreviewEventArgs) => void) => () => void;
|
|
192
215
|
/**
|
|
193
216
|
* Adds <style> element in the document head with the provided CSS.
|
|
194
217
|
* If an existing style element with the id "content-sdk-style-preview" is found, it is removed
|
|
@@ -200,12 +223,12 @@ export declare function addStyleElement(stylesContent: string): void;
|
|
|
200
223
|
/**
|
|
201
224
|
* Dynamically creates a React component instance from provided importMap and from code, styles, and dependencies provided in the preview event.
|
|
202
225
|
* @param {ImportEntry[]} importMap - The import map containing module and export references that might be injected as dependencies in the provided code.
|
|
203
|
-
* @param {
|
|
226
|
+
* @param {GeneratedComponentData} generatedComponentData - The generated component data received from design library.
|
|
204
227
|
* @returns The dynamically created React component instance.
|
|
205
228
|
* @throws If any required modules or exports are missing from the import map, an error is thrown describing the missing dependencies.
|
|
206
229
|
* @internal
|
|
207
230
|
*/
|
|
208
|
-
export declare const createComponentInstance: (importMap: ImportEntry[],
|
|
231
|
+
export declare const createComponentInstance: (importMap: ImportEntry[], generatedComponentData: GeneratedComponentData) => unknown;
|
|
209
232
|
/**
|
|
210
233
|
* Generates a DesignLibraryComponentPreviewErrorEvent with the given uid and error.
|
|
211
234
|
* @param {string} uid - The unique identifier for the event.
|
|
@@ -252,5 +275,15 @@ export declare function isImportEntryInfoArray(data: unknown): data is ImportEnt
|
|
|
252
275
|
* @internal
|
|
253
276
|
*/
|
|
254
277
|
export declare const sendErrorEvent: (uid: string, error: unknown, type: DesignLibraryPreviewError) => void;
|
|
278
|
+
/**
|
|
279
|
+
* Fetches generated component data from the authoring cache endpoint.
|
|
280
|
+
* This is used by the Design Studio Server to fetch the updated component data from the secured cache endpoint and render it in the Design Library Studio preview iframe.
|
|
281
|
+
* @param {string} id - The unique identifier of the component to fetch from cache.
|
|
282
|
+
* @param {string} token - The authorization token for authentication.
|
|
283
|
+
* @param {string} [edgeUrl] - The URL of the Sitecore Edge endpoint.
|
|
284
|
+
* @returns A Promise that resolves to the component rendering data, component generation data, or undefined if the fetch fails.
|
|
285
|
+
* @internal
|
|
286
|
+
*/
|
|
287
|
+
export declare function fetchGeneratedComponentFromCache(id: string, token: string, edgeUrl?: string): Promise<GeneratedComponentData>;
|
|
255
288
|
export {};
|
|
256
289
|
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/editing/codegen/preview.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/editing/codegen/preview.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAiB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAKtE;;GAEG;AACH,QAAA,MAAM,oCAAoC,oCAAoC,CAAC;AAE/E;;GAEG;AACH,QAAA,MAAM,yCAAyC,yCAAyC,CAAC;AAEzF;;GAEG;AACH,QAAA,MAAM,2CAA2C,2CAA2C,CAAC;AAE7F;;GAEG;AACH,QAAA,MAAM,iDAAiD,iDACP,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;I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,CAAC,CAwBjC"}
|
|
@@ -9,6 +9,11 @@ declare const DESIGN_LIBRARY_STATUS_EVENT_NAME = "component:status";
|
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
11
|
export declare const COMPONENT_UPDATE_CACHE_KEY_PREFIX = "component-update-";
|
|
12
|
+
/**
|
|
13
|
+
* Prefix for component preview cache keys
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare const COMPONENT_PREVIEW_CACHE_KEY_PREFIX = "component-preview-";
|
|
12
17
|
/**
|
|
13
18
|
* Base interface for all Design Library events.
|
|
14
19
|
*/
|
|
@@ -31,6 +36,7 @@ export interface DesignLibraryStatusEvent extends DesignLibraryEvent {
|
|
|
31
36
|
message: {
|
|
32
37
|
status: 'ready' | 'rendered';
|
|
33
38
|
uid: string;
|
|
39
|
+
isRenderingServerComponent: boolean;
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
@@ -83,10 +89,11 @@ export declare const updateComponent: (component: ComponentRendering<ComponentFi
|
|
|
83
89
|
* Generates a DesignLibraryStatusEvent with the given status and uid.
|
|
84
90
|
* @param {DesignLibraryStatus} status - The status of rendering.
|
|
85
91
|
* @param {string} uid - The unique identifier for the event.
|
|
92
|
+
* @param {boolean} [isRenderingServerComponent] - Indicates if the component being rendered is a server component.
|
|
86
93
|
* @returns An object representing the DesignLibraryStatusEvent.
|
|
87
94
|
* @internal
|
|
88
95
|
*/
|
|
89
|
-
export declare function getDesignLibraryStatusEvent(status: DesignLibraryStatus, uid: string): DesignLibraryStatusEvent;
|
|
96
|
+
export declare function getDesignLibraryStatusEvent(status: DesignLibraryStatus, uid: string, isRenderingServerComponent?: boolean): DesignLibraryStatusEvent;
|
|
90
97
|
/**
|
|
91
98
|
* Generates the URL for the design library script link.
|
|
92
99
|
* Caller should pass the resolved Edge URL from config.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-library.d.ts","sourceRoot":"","sources":["../../src/editing/design-library.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,KAAK,EACL,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,QAAA,MAAM,gCAAgC,qBAAqB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,iCAAiC,sBAAsB,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,IAAI,EAAE,OAAO,gCAAgC,CAAC;IAC9C,OAAO,EAAE;QACP,MAAM,EAAE,OAAO,GAAG,UAAU,CAAC;QAC7B,GAAG,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"design-library.d.ts","sourceRoot":"","sources":["../../src/editing/design-library.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,KAAK,EACL,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,QAAA,MAAM,gCAAgC,qBAAqB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,iCAAiC,sBAAsB,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,kCAAkC,uBAAuB,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB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X,0BAA0B,UAAQ,GACjC,wBAAwB,CAS1B;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,GAAE,MAAqD,GACrE,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,iBAAiB,CAE5E;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,kBAAkB,SAW1D,CAAC"}
|
package/types/editing/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { DEFAULT_PLACEHOLDER_UID, PagesEditor, isEditorActive, resetEditorChrome
|
|
|
3
3
|
export { ComponentLayoutService, ComponentLayoutRequestParams, ComponentLayoutServiceConfig, } from './component-layout-service';
|
|
4
4
|
export { EditingRenderQueryParams, RenderComponentQueryParams, DesignLibraryVariantGeneration, } from './models';
|
|
5
5
|
export { LayoutKind, MetadataKind, EditingPreviewData, DesignLibraryRenderPreviewData, DesignLibraryMode, } from './models';
|
|
6
|
-
export { addComponentUpdateHandler, DesignLibraryStatus, DesignLibraryStatusEvent, getDesignLibraryStatusEvent, getDesignLibraryScriptLink, isDesignLibraryMode, postToDesignLibrary, COMPONENT_UPDATE_CACHE_KEY_PREFIX, updateComponent, } from './design-library';
|
|
6
|
+
export { addComponentUpdateHandler, DesignLibraryStatus, DesignLibraryStatusEvent, getDesignLibraryStatusEvent, getDesignLibraryScriptLink, isDesignLibraryMode, postToDesignLibrary, COMPONENT_UPDATE_CACHE_KEY_PREFIX, COMPONENT_PREVIEW_CACHE_KEY_PREFIX, updateComponent, } from './design-library';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EACL,uBAAuB,EACvB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,GACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,8BAA8B,EAC9B,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,iCAAiC,EACjC,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EACL,uBAAuB,EACvB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,GACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,8BAA8B,EAC9B,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,iCAAiC,EACjC,kCAAkC,EAClC,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
|
|
@@ -43,13 +43,12 @@ export type WriteImportMapArgsInternal = WriteImportMapArgs & {
|
|
|
43
43
|
*/
|
|
44
44
|
separateServerClientMaps?: boolean;
|
|
45
45
|
/**
|
|
46
|
-
* Function to return custom template for
|
|
47
|
-
* Will be used as default template if separateServerClientMaps is false.
|
|
46
|
+
* Function to return custom template for import map file.
|
|
48
47
|
* @param {Map<string, ModuleExports>} indexedImportMap import map to be processed into final import-map.ts or import-map.server.ts file
|
|
49
48
|
* @returns {string} contents for resulting import map file
|
|
50
49
|
* @internal
|
|
51
50
|
*/
|
|
52
|
-
|
|
51
|
+
defaultTemplate?: (indexedImportMap: Map<string, ModuleExports>) => string;
|
|
53
52
|
/**
|
|
54
53
|
* Function to return custom template for client import map file when separateServerClientMaps is true.
|
|
55
54
|
* @param {Map<string, ModuleExports>} indexedImportMap import map to be processed into final import-map.client.ts file
|
|
@@ -94,6 +93,6 @@ declare function _getImportMap(paths: string[]): Map<string, ModuleExports>;
|
|
|
94
93
|
export declare const writeImportMap: (args: WriteImportMapArgsInternal) => ({ scConfig }: {
|
|
95
94
|
scConfig: SitecoreConfig;
|
|
96
95
|
}) => Promise<void>;
|
|
97
|
-
declare function _defaultMapTemplate(indexedImportMap: Map<string, ModuleExports>, framework?: string): string;
|
|
96
|
+
declare function _defaultMapTemplate(indexedImportMap: Map<string, ModuleExports>, framework?: string, defaultImportEntriesImport?: string): string;
|
|
98
97
|
export {};
|
|
99
98
|
//# sourceMappingURL=import-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-map.d.ts","sourceRoot":"","sources":["../../../src/tools/codegen/import-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;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