@sitecore-content-sdk/content 2.2.0 → 2.2.1-canary.20260707122356
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/layout/rewrite-edge-host.js +1 -10
- package/dist/cjs/tools/codegen/import-map.js +21 -1
- package/dist/esm/layout/rewrite-edge-host.js +1 -10
- package/dist/esm/tools/codegen/import-map.js +21 -1
- package/package.json +4 -4
- package/types/layout/rewrite-edge-host.d.ts.map +1 -1
- package/types/tools/codegen/import-map.d.ts.map +1 -1
|
@@ -29,16 +29,7 @@ function isCustomEdgeUrl(url) {
|
|
|
29
29
|
* Matches both http:// and https:// protocols.
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|
|
32
|
-
const EDGE_HOST_PATTERN = new RegExp(`https?://${escapeRegExp(DEFAULT_EDGE_HOSTNAME)}`, 'gi');
|
|
33
|
-
/**
|
|
34
|
-
* Escapes a string so it can be safely embedded in a RegExp as a literal.
|
|
35
|
-
* @param {string} input - The string to escape
|
|
36
|
-
* @returns {string} The escaped string safe for RegExp construction
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
function escapeRegExp(input) {
|
|
40
|
-
return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
41
|
-
}
|
|
32
|
+
const EDGE_HOST_PATTERN = new RegExp(`https?://${(0, tools_1.escapeRegExp)(DEFAULT_EDGE_HOSTNAME)}`, 'gi');
|
|
42
33
|
/**
|
|
43
34
|
* Rewrites Experience Edge hostnames in a response object to use the custom hostname.
|
|
44
35
|
* This function performs a deep traversal of the object and replaces any string values
|
|
@@ -45,6 +45,7 @@ const templating_1 = require("./../templating");
|
|
|
45
45
|
const crypto_1 = __importDefault(require("crypto"));
|
|
46
46
|
const utils_1 = require("./utils");
|
|
47
47
|
const core_2 = require("@sitecore-content-sdk/core");
|
|
48
|
+
const node_tools_1 = require("@sitecore-content-sdk/core/node-tools");
|
|
48
49
|
const { ERROR_MESSAGES } = core_2.constants;
|
|
49
50
|
let _getComponentList = templating_1.getComponentList;
|
|
50
51
|
const aliasImport = /^([a-zA-Z0-9]+) as .+$/;
|
|
@@ -270,6 +271,24 @@ const prepImportMaps = async (paths, separateMaps) => {
|
|
|
270
271
|
{ map: (0, exports.getImportMap)(clientPaths), path: importMapFileClient, isClient: true },
|
|
271
272
|
];
|
|
272
273
|
};
|
|
274
|
+
const writeEmptyImportMaps = (args, defaultTemplate, clientTemplate) => {
|
|
275
|
+
const sitecoreDir = path_1.default.join(process.cwd(), '.sitecore');
|
|
276
|
+
const emptyMap = new Map();
|
|
277
|
+
const emptyImportMaps = args.separateServerClientMaps
|
|
278
|
+
? [
|
|
279
|
+
{ map: emptyMap, path: path_1.default.join(sitecoreDir, 'import-map.server.ts') },
|
|
280
|
+
{ map: emptyMap, path: path_1.default.join(sitecoreDir, 'import-map.client.ts'), isClient: true },
|
|
281
|
+
]
|
|
282
|
+
: [{ map: emptyMap, path: path_1.default.join(sitecoreDir, 'import-map.ts') }];
|
|
283
|
+
// Ensure .sitecore directory exists
|
|
284
|
+
(0, node_tools_1.ensurePathExists)(emptyImportMaps[0].path);
|
|
285
|
+
for (const importMap of emptyImportMaps) {
|
|
286
|
+
const importMapContent = importMap.isClient
|
|
287
|
+
? clientTemplate(importMap.map)
|
|
288
|
+
: defaultTemplate(importMap.map);
|
|
289
|
+
fs_1.default.writeFileSync(importMap.path, importMapContent, { encoding: 'utf8' });
|
|
290
|
+
}
|
|
291
|
+
};
|
|
273
292
|
/**
|
|
274
293
|
* Entry point function for generating import-map. Parses provided paths and outputs the modules and imports from those files into .sitecore/import-map.ts
|
|
275
294
|
* @param {WriteImportMapArgsInternal} args include/exclude paths settings to be processed for import-map, and the Sitecore configuration.
|
|
@@ -283,7 +302,8 @@ const writeImportMap = (args) => {
|
|
|
283
302
|
throw new Error(ERROR_MESSAGES.MV_008);
|
|
284
303
|
}
|
|
285
304
|
if (scConfig.disableCodeGeneration) {
|
|
286
|
-
core_1.debug.common('
|
|
305
|
+
core_1.debug.common('Code generation is disabled. Writing empty import maps for bundler resolution.');
|
|
306
|
+
writeEmptyImportMaps(args, defaultTemplate, clientTemplate);
|
|
287
307
|
return;
|
|
288
308
|
}
|
|
289
309
|
const paths = _getComponentList(args.paths, args.exclude).map((entry) => entry.filePath);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { constants } from '@sitecore-content-sdk/core';
|
|
2
|
-
import { normalizeUrl } from '@sitecore-content-sdk/core/tools';
|
|
2
|
+
import { normalizeUrl, escapeRegExp } from '@sitecore-content-sdk/core/tools';
|
|
3
3
|
/** Default Edge hostname derived from the default Edge URL (edge.sitecorecloud.io). @internal */
|
|
4
4
|
const DEFAULT_EDGE_HOSTNAME = new URL(constants.SITECORE_EXPERIENCE_EDGE_URL_DEFAULT).hostname;
|
|
5
5
|
/**
|
|
@@ -24,15 +24,6 @@ function isCustomEdgeUrl(url) {
|
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
26
26
|
const EDGE_HOST_PATTERN = new RegExp(`https?://${escapeRegExp(DEFAULT_EDGE_HOSTNAME)}`, 'gi');
|
|
27
|
-
/**
|
|
28
|
-
* Escapes a string so it can be safely embedded in a RegExp as a literal.
|
|
29
|
-
* @param {string} input - The string to escape
|
|
30
|
-
* @returns {string} The escaped string safe for RegExp construction
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
function escapeRegExp(input) {
|
|
34
|
-
return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
35
|
-
}
|
|
36
27
|
/**
|
|
37
28
|
* Rewrites Experience Edge hostnames in a response object to use the custom hostname.
|
|
38
29
|
* This function performs a deep traversal of the object and replaces any string values
|
|
@@ -6,6 +6,7 @@ import { getComponentList } from './../templating';
|
|
|
6
6
|
import crypto from 'crypto';
|
|
7
7
|
import { isNodeModuleImportOrAlias, getRelativeImportPath } from './utils';
|
|
8
8
|
import { constants } from '@sitecore-content-sdk/core';
|
|
9
|
+
import { ensurePathExists } from '@sitecore-content-sdk/core/node-tools';
|
|
9
10
|
const { ERROR_MESSAGES } = constants;
|
|
10
11
|
let _getComponentList = getComponentList;
|
|
11
12
|
const aliasImport = /^([a-zA-Z0-9]+) as .+$/;
|
|
@@ -228,6 +229,24 @@ const prepImportMaps = async (paths, separateMaps) => {
|
|
|
228
229
|
{ map: getImportMap(clientPaths), path: importMapFileClient, isClient: true },
|
|
229
230
|
];
|
|
230
231
|
};
|
|
232
|
+
const writeEmptyImportMaps = (args, defaultTemplate, clientTemplate) => {
|
|
233
|
+
const sitecoreDir = path.join(process.cwd(), '.sitecore');
|
|
234
|
+
const emptyMap = new Map();
|
|
235
|
+
const emptyImportMaps = args.separateServerClientMaps
|
|
236
|
+
? [
|
|
237
|
+
{ map: emptyMap, path: path.join(sitecoreDir, 'import-map.server.ts') },
|
|
238
|
+
{ map: emptyMap, path: path.join(sitecoreDir, 'import-map.client.ts'), isClient: true },
|
|
239
|
+
]
|
|
240
|
+
: [{ map: emptyMap, path: path.join(sitecoreDir, 'import-map.ts') }];
|
|
241
|
+
// Ensure .sitecore directory exists
|
|
242
|
+
ensurePathExists(emptyImportMaps[0].path);
|
|
243
|
+
for (const importMap of emptyImportMaps) {
|
|
244
|
+
const importMapContent = importMap.isClient
|
|
245
|
+
? clientTemplate(importMap.map)
|
|
246
|
+
: defaultTemplate(importMap.map);
|
|
247
|
+
fs.writeFileSync(importMap.path, importMapContent, { encoding: 'utf8' });
|
|
248
|
+
}
|
|
249
|
+
};
|
|
231
250
|
/**
|
|
232
251
|
* Entry point function for generating import-map. Parses provided paths and outputs the modules and imports from those files into .sitecore/import-map.ts
|
|
233
252
|
* @param {WriteImportMapArgsInternal} args include/exclude paths settings to be processed for import-map, and the Sitecore configuration.
|
|
@@ -241,7 +260,8 @@ export const writeImportMap = (args) => {
|
|
|
241
260
|
throw new Error(ERROR_MESSAGES.MV_008);
|
|
242
261
|
}
|
|
243
262
|
if (scConfig.disableCodeGeneration) {
|
|
244
|
-
debug.common('
|
|
263
|
+
debug.common('Code generation is disabled. Writing empty import maps for bundler resolution.');
|
|
264
|
+
writeEmptyImportMaps(args, defaultTemplate, clientTemplate);
|
|
245
265
|
return;
|
|
246
266
|
}
|
|
247
267
|
const paths = _getComponentList(args.paths, args.exclude).map((entry) => entry.filePath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/content",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1-canary.20260707122356",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"url": "https://github.com/sitecore/content-sdk/issues"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@sitecore-content-sdk/events": "
|
|
39
|
+
"@sitecore-content-sdk/events": "2.1.1-canary.20260707122356",
|
|
40
40
|
"@stylistic/eslint-plugin": "^5.2.2",
|
|
41
41
|
"@types/chai": "^5.2.2",
|
|
42
42
|
"@types/chai-spies": "^1.0.6",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"typescript": "~5.8.3"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@sitecore-content-sdk/events": "
|
|
76
|
+
"@sitecore-content-sdk/events": "2.1.1-canary.20260707122356"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@sitecore-content-sdk/core": "
|
|
79
|
+
"@sitecore-content-sdk/core": "2.1.2-canary.20260707122356",
|
|
80
80
|
"chalk": "^4.1.2",
|
|
81
81
|
"debug": "^4.4.0",
|
|
82
82
|
"glob": "^13.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewrite-edge-host.d.ts","sourceRoot":"","sources":["../../src/layout/rewrite-edge-host.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rewrite-edge-host.d.ts","sourceRoot":"","sources":["../../src/layout/rewrite-edge-host.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAM5E;AAuDD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAMxF;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,CAAC,CAqBrF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE5D"}
|
|
@@ -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;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
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;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAWhD,eAAO,MAAM,SAAS,GAAI,2BAEvB;IACD,oBAAoB,CAAC,EAAE,OAAO,gBAAgB,CAAC;CAChD,SAEA,CAAC;AAEF;;;;GAIG;AACH,eAAO,IAAI,YAAY,sBAAgB,CAAC;AAExC;;;;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