@lwrjs/core 0.6.4 → 0.7.0-alpha.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/build/cjs/env-config.cjs +2 -1
- package/build/cjs/index.cjs +2 -2
- package/build/cjs/middlewares/api-middleware.cjs +4 -0
- package/build/cjs/middlewares/ui-middleware.cjs +2 -0
- package/build/cjs/tools/static-generation.cjs +7 -7
- package/build/cjs/validation/app-config-context.cjs +20 -0
- package/build/cjs/validation/app-config.cjs +1 -0
- package/build/es/env-config.js +3 -4
- package/build/es/index.js +3 -3
- package/build/es/middlewares/api-middleware.js +9 -5
- package/build/es/middlewares/ui-middleware.js +4 -0
- package/build/es/tools/static-generation.d.ts +1 -1
- package/build/es/tools/static-generation.js +9 -9
- package/build/es/tools/types.d.ts +2 -2
- package/build/es/validation/app-config-context.d.ts +2 -0
- package/build/es/validation/app-config-context.js +21 -0
- package/build/es/validation/app-config.js +2 -0
- package/package.json +28 -28
package/build/cjs/env-config.cjs
CHANGED
|
@@ -55,6 +55,7 @@ var DEFAULT_DATA_DIR = "$rootDir/src/data";
|
|
|
55
55
|
var DEFAULT_MODULE_PROVIDERS = [
|
|
56
56
|
"@lwrjs/app-service/moduleProvider",
|
|
57
57
|
"@lwrjs/lwc-ssr/moduleProvider",
|
|
58
|
+
"@lwrjs/router/module-provider",
|
|
58
59
|
"@lwrjs/lwc-module-provider",
|
|
59
60
|
"@lwrjs/npm-module-provider"
|
|
60
61
|
];
|
|
@@ -299,7 +300,7 @@ function normalizeConfig(config) {
|
|
|
299
300
|
const assets = normalizeAssetsDir(mergedLwrGlobalConfig.assets, rootDir);
|
|
300
301
|
const contentDir = (0, import_shared_utils.normalizeDirectory)(mergedLwrGlobalConfig.contentDir, rootDir);
|
|
301
302
|
const layoutsDir = (0, import_shared_utils.normalizeDirectory)(mergedLwrGlobalConfig.layoutsDir, rootDir);
|
|
302
|
-
const amdLoader = (0, import_shared_utils.
|
|
303
|
+
const amdLoader = (0, import_shared_utils.getFeatureFlags)().LEGACY_LOADER ? DEFAULT_AMD_LOADER_LEGACY : DEFAULT_AMD_LOADER;
|
|
303
304
|
return {
|
|
304
305
|
...mergedLwrGlobalConfig,
|
|
305
306
|
assets,
|
package/build/cjs/index.cjs
CHANGED
|
@@ -75,7 +75,7 @@ async function initContext(app, server, rawLwrConfig) {
|
|
|
75
75
|
lwrVersion,
|
|
76
76
|
debug: false,
|
|
77
77
|
serverMode,
|
|
78
|
-
|
|
78
|
+
featureFlags: (0, import_shared_utils.getFeatureFlags)()
|
|
79
79
|
};
|
|
80
80
|
const hookProviders = await getServices(rawLwrConfig.hooks, void 0, rawLwrConfig);
|
|
81
81
|
const {lwrConfig, dataConfig, runtimeConfig} = await (0, import_hooks.runConfigurationsHook)(hookProviders, rawLwrConfig, rawDataConfig, rawRuntimeEnvConfig);
|
|
@@ -259,7 +259,7 @@ async function generateStaticSite(config) {
|
|
|
259
259
|
await new import_static_generation.default().buildStaticApplication(lwrApp.getConfig(), dispatcher);
|
|
260
260
|
}
|
|
261
261
|
function overrideConfigAsSrc(lwrApp) {
|
|
262
|
-
if ((0, import_shared_utils.
|
|
262
|
+
if (!(0, import_shared_utils.getFeatureFlags)().LEGACY_LOADER) {
|
|
263
263
|
const normalizedConfig = lwrApp.getConfig();
|
|
264
264
|
const routes = normalizedConfig.routes || [];
|
|
265
265
|
for (const route of routes) {
|
|
@@ -252,9 +252,13 @@ function apiMiddleware(app, context) {
|
|
|
252
252
|
}
|
|
253
253
|
});
|
|
254
254
|
app.get([
|
|
255
|
+
`/:apiVersion/mapping/:format/:compat/l/:locale/e/:environment/bi/:bundleSpecifier/mp/:specifiers`,
|
|
255
256
|
`/:apiVersion/mapping/:format/:compat/l/:locale/e/:environment/mp/:specifiers`,
|
|
257
|
+
`/:apiVersion/mapping/:format/:compat/l/:locale/bi/:bundleSpecifier/mp/:specifiers`,
|
|
258
|
+
`/:apiVersion/mapping/:format/:compat/e/:environment/bi/:bundleSpecifier/mp/:specifiers`,
|
|
256
259
|
`/:apiVersion/mapping/:format/:compat/l/:locale/mp/:specifiers`,
|
|
257
260
|
`/:apiVersion/mapping/:format/:compat/e/:environment/mp/:specifiers`,
|
|
261
|
+
`/:apiVersion/mapping/:format/:compat/bi/:bundleSpecifier/mp/:specifiers`,
|
|
258
262
|
`/:apiVersion/mapping/:format/:compat/mp/:specifiers`
|
|
259
263
|
], async (req, res) => {
|
|
260
264
|
const requestContext = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
@@ -42,6 +42,7 @@ function uiMiddleware(app, context) {
|
|
|
42
42
|
res.status(400).send({error: "Accept header and json query parameter are incompatible"});
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
+
req.params.bundleSpecifier = defaultRuntimeEnvironment.bundle ? "0" : void 0;
|
|
45
46
|
const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
46
47
|
const targetEnvironment = runtimeParams.environment;
|
|
47
48
|
if (!(0, import_utils.isSupportedEnvironment)(environmentConfig, targetEnvironment)) {
|
|
@@ -89,6 +90,7 @@ function uiMiddleware(app, context) {
|
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
async function sendConfigurationResponse(req, res, defaultStatus = 200) {
|
|
93
|
+
req.params.bundleSpecifier = defaultRuntimeEnvironment.bundle ? "0" : void 0;
|
|
92
94
|
const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
93
95
|
const {appId, encodedViewPath} = req.params;
|
|
94
96
|
const route = routes.find((route2) => route2.id === appId);
|
|
@@ -228,7 +228,7 @@ var SiteGenerator = class {
|
|
|
228
228
|
if (jsUri.startsWith("/")) {
|
|
229
229
|
await this.dispatchResourceRecursive(jsUri, dispatcher, {resourceType: "js"}, siteConfig);
|
|
230
230
|
} else {
|
|
231
|
-
const supportsFingerprints = siteConfig.
|
|
231
|
+
const supportsFingerprints = !siteConfig.featureFlags?.LEGACY_LOADER;
|
|
232
232
|
if (supportsFingerprints) {
|
|
233
233
|
const mappingEndpoint = siteConfig.endpoints?.uris?.mapping;
|
|
234
234
|
if (mappingEndpoint) {
|
|
@@ -285,25 +285,25 @@ var SiteGenerator = class {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
createSiteConfig(outputDir, locale, urlRewriteMap) {
|
|
288
|
-
const
|
|
288
|
+
const featureFlags = this.filterFeatureFlags();
|
|
289
289
|
return {
|
|
290
290
|
outputDir,
|
|
291
291
|
viewPaths: new Set(),
|
|
292
292
|
visitedUrls: new Set(),
|
|
293
293
|
locale,
|
|
294
294
|
urlRewriteMap,
|
|
295
|
-
...
|
|
295
|
+
...featureFlags
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
|
-
|
|
299
|
-
if ((0, import_shared_utils.
|
|
300
|
-
return {
|
|
298
|
+
filterFeatureFlags() {
|
|
299
|
+
if ((0, import_shared_utils.getFeatureFlags)().LEGACY_LOADER) {
|
|
300
|
+
return {featureFlags: {LEGACY_LOADER: true}};
|
|
301
301
|
} else {
|
|
302
302
|
return void 0;
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
addAdditionalImportMetadataToViewConfig(siteConfig) {
|
|
306
|
-
const supportsFingerprints = siteConfig.
|
|
306
|
+
const supportsFingerprints = !siteConfig.featureFlags?.LEGACY_LOADER;
|
|
307
307
|
const additionalImportMetadata = siteConfig?.importMetadata?.getAdditionalImportMetadata();
|
|
308
308
|
if (supportsFingerprints && siteConfig.viewConfigPath && additionalImportMetadata?.imports && Object.keys(additionalImportMetadata.imports).length > 0) {
|
|
309
309
|
const imports = additionalImportMetadata.imports ? JSON.stringify(additionalImportMetadata.imports) : "{}";
|
|
@@ -26,6 +26,7 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
ASSET_DIR_ATTRIBUTE_KEYS: () => ASSET_DIR_ATTRIBUTE_KEYS,
|
|
28
28
|
ASSET_FILE_ATTRIBUTE_KEYS: () => ASSET_FILE_ATTRIBUTE_KEYS,
|
|
29
|
+
BASE_PATH_REGEX: () => BASE_PATH_REGEX,
|
|
29
30
|
BOOTSTRAP_ATTRIBUTE_KEYS: () => BOOTSTRAP_ATTRIBUTE_KEYS,
|
|
30
31
|
ERROR_ROUTE_ATTRIBUTE_KEYS: () => ERROR_ROUTE_ATTRIBUTE_KEYS,
|
|
31
32
|
LOCKER_ATTRIBUTE_KEYS: () => LOCKER_ATTRIBUTE_KEYS,
|
|
@@ -111,6 +112,7 @@ var SPECIFIER_REGEX = /^@?[\w-]+(\/[\w-]+)*$/;
|
|
|
111
112
|
function isNotEmptyString(node) {
|
|
112
113
|
return node.type === "string" && node.value.length > 0;
|
|
113
114
|
}
|
|
115
|
+
var BASE_PATH_REGEX = /^(\/[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/g;
|
|
114
116
|
var ValidationContext = class {
|
|
115
117
|
constructor(sourceText) {
|
|
116
118
|
this.diagnostics = [];
|
|
@@ -224,6 +226,24 @@ var ValidationContext = class {
|
|
|
224
226
|
});
|
|
225
227
|
}
|
|
226
228
|
}
|
|
229
|
+
assertIsBasePath(node, property) {
|
|
230
|
+
if (!node) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (node.type !== "string") {
|
|
234
|
+
this.diagnostics.push({
|
|
235
|
+
description: import_diagnostics.descriptions.CONFIG_PARSER.INCORRECT_NODE_TYPE(property, "string", node.type),
|
|
236
|
+
location: this.getLocationFromNode(node)
|
|
237
|
+
});
|
|
238
|
+
} else if (node.value === "") {
|
|
239
|
+
return;
|
|
240
|
+
} else if (node.value.match(BASE_PATH_REGEX) === null) {
|
|
241
|
+
this.diagnostics.push({
|
|
242
|
+
description: import_diagnostics.descriptions.CONFIG_PARSER.INVALID_BASEPATH(property, node.value),
|
|
243
|
+
location: this.getLocationFromNode(node)
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
227
247
|
assertNotEmptyString(node, property) {
|
|
228
248
|
if (!node) {
|
|
229
249
|
return;
|
|
@@ -168,6 +168,7 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
168
168
|
validationContext.assertArrayOfServices((0, import_jsonc_parser.findNodeAtLocation)(node, ["assetProviders"]), "assetProviders");
|
|
169
169
|
validationContext.assertNotEmptyArray((0, import_jsonc_parser.findNodeAtLocation)(node, ["lwc", "modules"]), "lwc.modules");
|
|
170
170
|
validationContext.assertIsEnvironment((0, import_jsonc_parser.findNodeAtLocation)(node, ["environment"]), "environment");
|
|
171
|
+
validationContext.assertIsBasePath((0, import_jsonc_parser.findNodeAtLocation)(node, ["basePath"]), "basePath");
|
|
171
172
|
}
|
|
172
173
|
function validateLwrAppConfig(jsonSourceText, phase) {
|
|
173
174
|
const errors = [];
|
package/build/es/env-config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
|
-
import { ASSETS_CACHE_DIR, readFile, normalizeDirectory, normalizeResourcePath, DEFAULT_LWR_BOOTSTRAP_CONFIG, DEFAULT_LWR_LOCKER_CONFIG, DEFAULT_LOCKER_TRUSTED_CMP, normalizeInterchangeableModuleConfig,
|
|
4
|
+
import { ASSETS_CACHE_DIR, readFile, normalizeDirectory, normalizeResourcePath, DEFAULT_LWR_BOOTSTRAP_CONFIG, DEFAULT_LWR_LOCKER_CONFIG, DEFAULT_LOCKER_TRUSTED_CMP, normalizeInterchangeableModuleConfig, getFeatureFlags, } from '@lwrjs/shared-utils';
|
|
5
5
|
import { rootPath, version } from '@lwrjs/core/package';
|
|
6
6
|
import { validateLwrAppConfig } from './validation/app-config.js';
|
|
7
7
|
import { LwrConfigValidationError } from '@lwrjs/diagnostics';
|
|
@@ -28,6 +28,7 @@ const DEFAULT_DATA_DIR = '$rootDir/src/data';
|
|
|
28
28
|
const DEFAULT_MODULE_PROVIDERS = [
|
|
29
29
|
'@lwrjs/app-service/moduleProvider',
|
|
30
30
|
'@lwrjs/lwc-ssr/moduleProvider',
|
|
31
|
+
'@lwrjs/router/module-provider',
|
|
31
32
|
'@lwrjs/lwc-module-provider',
|
|
32
33
|
'@lwrjs/npm-module-provider',
|
|
33
34
|
];
|
|
@@ -311,9 +312,7 @@ export function normalizeConfig(config) {
|
|
|
311
312
|
const assets = normalizeAssetsDir(mergedLwrGlobalConfig.assets, rootDir);
|
|
312
313
|
const contentDir = normalizeDirectory(mergedLwrGlobalConfig.contentDir, rootDir);
|
|
313
314
|
const layoutsDir = normalizeDirectory(mergedLwrGlobalConfig.layoutsDir, rootDir);
|
|
314
|
-
const amdLoader =
|
|
315
|
-
? DEFAULT_AMD_LOADER
|
|
316
|
-
: DEFAULT_AMD_LOADER_LEGACY;
|
|
315
|
+
const amdLoader = getFeatureFlags().LEGACY_LOADER ? DEFAULT_AMD_LOADER_LEGACY : DEFAULT_AMD_LOADER;
|
|
317
316
|
return {
|
|
318
317
|
...mergedLwrGlobalConfig,
|
|
319
318
|
assets,
|
package/build/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deepFreeze,
|
|
1
|
+
import { deepFreeze, getFeatureFlags, DEFAULT_LWR_BOOTSTRAP_CONFIG } from '@lwrjs/shared-utils';
|
|
2
2
|
import { LwrCompiler } from '@lwrjs/compiler';
|
|
3
3
|
import { LwrModuleBundler } from '@lwrjs/module-bundler';
|
|
4
4
|
import { LwrModuleRegistry } from '@lwrjs/module-registry';
|
|
@@ -50,7 +50,7 @@ async function initContext(app, server, rawLwrConfig) {
|
|
|
50
50
|
lwrVersion,
|
|
51
51
|
debug: false,
|
|
52
52
|
serverMode,
|
|
53
|
-
|
|
53
|
+
featureFlags: getFeatureFlags(),
|
|
54
54
|
};
|
|
55
55
|
const hookProviders = await getServices(rawLwrConfig.hooks, undefined, rawLwrConfig);
|
|
56
56
|
const { lwrConfig, dataConfig, runtimeConfig } = await runConfigurationsHook(hookProviders, rawLwrConfig, rawDataConfig, rawRuntimeEnvConfig);
|
|
@@ -233,7 +233,7 @@ export async function generateStaticSite(config) {
|
|
|
233
233
|
* Create normalized config for static generation forcing the app config to come as src
|
|
234
234
|
*/
|
|
235
235
|
function overrideConfigAsSrc(lwrApp) {
|
|
236
|
-
if (
|
|
236
|
+
if (!getFeatureFlags().LEGACY_LOADER) {
|
|
237
237
|
const normalizedConfig = lwrApp.getConfig();
|
|
238
238
|
const routes = normalizedConfig.routes || [];
|
|
239
239
|
for (const route of routes) {
|
|
@@ -276,15 +276,19 @@ export default function apiMiddleware(app, context) {
|
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
278
|
// Mapping Services
|
|
279
|
-
// /{apiversion}/mapping/{format}/{compat}/l/{language}/mp/{specifiers}
|
|
279
|
+
// /{apiversion}/mapping/{format}/{compat}(/l/{language})?(/e/{environment})?(/bi/{bundleStrategyId})?/mp/{specifiers}
|
|
280
280
|
app.get([
|
|
281
|
-
// Full URL
|
|
281
|
+
// Full URL (3 optional segments)
|
|
282
|
+
`/:apiVersion/mapping/:format/:compat/l/:locale/e/:environment/bi/:bundleSpecifier/mp/:specifiers`,
|
|
283
|
+
// With 2 optional segments: l & e, l & bi, e & bi
|
|
282
284
|
`/:apiVersion/mapping/:format/:compat/l/:locale/e/:environment/mp/:specifiers`,
|
|
283
|
-
|
|
285
|
+
`/:apiVersion/mapping/:format/:compat/l/:locale/bi/:bundleSpecifier/mp/:specifiers`,
|
|
286
|
+
`/:apiVersion/mapping/:format/:compat/e/:environment/bi/:bundleSpecifier/mp/:specifiers`,
|
|
287
|
+
// With 1 optional segment
|
|
284
288
|
`/:apiVersion/mapping/:format/:compat/l/:locale/mp/:specifiers`,
|
|
285
|
-
// Without Locale
|
|
286
289
|
`/:apiVersion/mapping/:format/:compat/e/:environment/mp/:specifiers`,
|
|
287
|
-
|
|
290
|
+
`/:apiVersion/mapping/:format/:compat/bi/:bundleSpecifier/mp/:specifiers`,
|
|
291
|
+
// With 0 optional segments
|
|
288
292
|
`/:apiVersion/mapping/:format/:compat/mp/:specifiers`,
|
|
289
293
|
], async (req, res) => {
|
|
290
294
|
const requestContext = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
@@ -14,6 +14,8 @@ export default function uiMiddleware(app, context) {
|
|
|
14
14
|
res.status(400).send({ error: 'Accept header and json query parameter are incompatible' });
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
+
// UI URIs do not contain bundle IDs, so always use the environment default
|
|
18
|
+
req.params.bundleSpecifier = defaultRuntimeEnvironment.bundle ? '0' : undefined;
|
|
17
19
|
const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
18
20
|
const targetEnvironment = runtimeParams.environment;
|
|
19
21
|
if (!isSupportedEnvironment(environmentConfig, targetEnvironment)) {
|
|
@@ -67,6 +69,8 @@ export default function uiMiddleware(app, context) {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
async function sendConfigurationResponse(req, res, defaultStatus = 200) {
|
|
72
|
+
// UI URIs do not contain bundle IDs, so always use the environment default
|
|
73
|
+
req.params.bundleSpecifier = defaultRuntimeEnvironment.bundle ? '0' : undefined;
|
|
70
74
|
const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
71
75
|
const { appId, encodedViewPath } = req.params;
|
|
72
76
|
// Match the route id
|
|
@@ -91,7 +91,7 @@ export default class SiteGenerator {
|
|
|
91
91
|
* Create a new site config for the current view
|
|
92
92
|
*/
|
|
93
93
|
private createSiteConfig;
|
|
94
|
-
private
|
|
94
|
+
private filterFeatureFlags;
|
|
95
95
|
/**
|
|
96
96
|
* Add any additional import metadata collected during static site generation to the Client Bootstrap Config for this view.
|
|
97
97
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { performance } from 'perf_hooks';
|
|
2
|
-
import { getSpecifier,
|
|
2
|
+
import { getSpecifier, getFeatureFlags, hashContent } from '@lwrjs/shared-utils';
|
|
3
3
|
import { join, dirname, extname } from 'path';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
5
|
import { writeResponse } from './utils/stream.js';
|
|
@@ -325,7 +325,7 @@ export default class SiteGenerator {
|
|
|
325
325
|
await this.dispatchResourceRecursive(jsUri, dispatcher, { resourceType: 'js' }, siteConfig);
|
|
326
326
|
}
|
|
327
327
|
else {
|
|
328
|
-
const supportsFingerprints = siteConfig.
|
|
328
|
+
const supportsFingerprints = !siteConfig.featureFlags?.LEGACY_LOADER;
|
|
329
329
|
if (supportsFingerprints) {
|
|
330
330
|
// Download mapping
|
|
331
331
|
const mappingEndpoint = siteConfig.endpoints?.uris?.mapping;
|
|
@@ -417,20 +417,20 @@ export default class SiteGenerator {
|
|
|
417
417
|
* Create a new site config for the current view
|
|
418
418
|
*/
|
|
419
419
|
createSiteConfig(outputDir, locale, urlRewriteMap) {
|
|
420
|
-
const
|
|
420
|
+
const featureFlags = this.filterFeatureFlags();
|
|
421
421
|
return {
|
|
422
422
|
outputDir,
|
|
423
423
|
viewPaths: new Set(),
|
|
424
424
|
visitedUrls: new Set(),
|
|
425
425
|
locale,
|
|
426
426
|
urlRewriteMap,
|
|
427
|
-
// Only include
|
|
428
|
-
...
|
|
427
|
+
// Only include LEGACY_LOADER if true
|
|
428
|
+
...featureFlags,
|
|
429
429
|
};
|
|
430
430
|
}
|
|
431
|
-
|
|
432
|
-
if (
|
|
433
|
-
return {
|
|
431
|
+
filterFeatureFlags() {
|
|
432
|
+
if (getFeatureFlags().LEGACY_LOADER) {
|
|
433
|
+
return { featureFlags: { LEGACY_LOADER: true } };
|
|
434
434
|
}
|
|
435
435
|
else {
|
|
436
436
|
return undefined;
|
|
@@ -440,7 +440,7 @@ export default class SiteGenerator {
|
|
|
440
440
|
* Add any additional import metadata collected during static site generation to the Client Bootstrap Config for this view.
|
|
441
441
|
*/
|
|
442
442
|
addAdditionalImportMetadataToViewConfig(siteConfig) {
|
|
443
|
-
const supportsFingerprints = siteConfig.
|
|
443
|
+
const supportsFingerprints = !siteConfig.featureFlags?.LEGACY_LOADER;
|
|
444
444
|
const additionalImportMetadata = siteConfig?.importMetadata?.getAdditionalImportMetadata();
|
|
445
445
|
if (supportsFingerprints &&
|
|
446
446
|
siteConfig.viewConfigPath &&
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Endpoints,
|
|
1
|
+
import { Endpoints, FeatureFlags, ImportMetadata } from '@lwrjs/types';
|
|
2
2
|
import { RenderedAssetReference } from '@lwrjs/types';
|
|
3
3
|
export interface BaseResourceContextOpts {
|
|
4
4
|
resourceType: 'route' | 'asset' | 'js' | 'resource' | 'mapping';
|
|
@@ -41,6 +41,6 @@ export interface SiteConfig {
|
|
|
41
41
|
endpoints?: Endpoints;
|
|
42
42
|
importMetadata?: ViewImportMetadata;
|
|
43
43
|
viewConfigPath?: string;
|
|
44
|
-
|
|
44
|
+
featureFlags?: FeatureFlags;
|
|
45
45
|
}
|
|
46
46
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -22,6 +22,7 @@ export declare const LOCKER_ATTRIBUTE_KEYS: ["enabled", "trustedComponents", "cl
|
|
|
22
22
|
export declare const ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "contentTemplate", "id", "cache", "layoutTemplate", "method", "path", "rootComponent", "routeHandler", "properties"];
|
|
23
23
|
export declare const ERROR_ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "contentTemplate", "id", "layoutTemplate", "rootComponent", "routeHandler", "status", "properties", "cache"];
|
|
24
24
|
export declare const BOOTSTRAP_ATTRIBUTE_KEYS: ["autoBoot", "syntheticShadow", "workers", "services", "configAsSrc", "experimentalSSR"];
|
|
25
|
+
export declare const BASE_PATH_REGEX: RegExp;
|
|
25
26
|
export declare class ValidationContext {
|
|
26
27
|
diagnostics: Diagnostic[];
|
|
27
28
|
sourceText: string;
|
|
@@ -38,6 +39,7 @@ export declare class ValidationContext {
|
|
|
38
39
|
assertIsMethod(node: Node | undefined, property: string): void;
|
|
39
40
|
assertIsStatus(node: Node | undefined, property: string): void;
|
|
40
41
|
assertIsEnvironment(node: Node | undefined, property: string): void;
|
|
42
|
+
assertIsBasePath(node: Node | undefined, property: string): void;
|
|
41
43
|
assertNotEmptyString(node: Node | undefined, property: string): void;
|
|
42
44
|
assertNotEmptyArray(node: Node | undefined, property: string): void;
|
|
43
45
|
assertHasOneOrMore(node: Node, property: string, childProps: string[]): void;
|
|
@@ -78,6 +78,7 @@ const SPECIFIER_REGEX = /^@?[\w-]+(\/[\w-]+)*$/;
|
|
|
78
78
|
function isNotEmptyString(node) {
|
|
79
79
|
return node.type === 'string' && node.value.length > 0;
|
|
80
80
|
}
|
|
81
|
+
export const BASE_PATH_REGEX = /^(\/[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/g;
|
|
81
82
|
export class ValidationContext {
|
|
82
83
|
constructor(sourceText) {
|
|
83
84
|
this.diagnostics = [];
|
|
@@ -191,6 +192,26 @@ export class ValidationContext {
|
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
194
|
}
|
|
195
|
+
assertIsBasePath(node, property) {
|
|
196
|
+
if (!node) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (node.type !== 'string') {
|
|
200
|
+
this.diagnostics.push({
|
|
201
|
+
description: descriptions.CONFIG_PARSER.INCORRECT_NODE_TYPE(property, 'string', node.type),
|
|
202
|
+
location: this.getLocationFromNode(node),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
else if (node.value === '') {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
else if (node.value.match(BASE_PATH_REGEX) === null) {
|
|
209
|
+
this.diagnostics.push({
|
|
210
|
+
description: descriptions.CONFIG_PARSER.INVALID_BASEPATH(property, node.value),
|
|
211
|
+
location: this.getLocationFromNode(node),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
194
215
|
assertNotEmptyString(node, property) {
|
|
195
216
|
if (!node) {
|
|
196
217
|
return;
|
|
@@ -180,6 +180,7 @@ function validateLocker(node, validationContext) {
|
|
|
180
180
|
* - resourceProviders: array of services
|
|
181
181
|
* - assetProviders: array of services
|
|
182
182
|
* - lwc.modules: array
|
|
183
|
+
* - basePath: valid subdomain part
|
|
183
184
|
* Notes:
|
|
184
185
|
* - ignore `bundleConfig` because it is not yet RFCed
|
|
185
186
|
* - specifier strings are validated for type and shape only, NOT if they are resolvable
|
|
@@ -216,6 +217,7 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
216
217
|
validationContext.assertArrayOfServices(findNode(node, ['assetProviders']), 'assetProviders');
|
|
217
218
|
validationContext.assertNotEmptyArray(findNode(node, ['lwc', 'modules']), 'lwc.modules');
|
|
218
219
|
validationContext.assertIsEnvironment(findNode(node, ['environment']), 'environment');
|
|
220
|
+
validationContext.assertIsBasePath(findNode(node, ['basePath']), 'basePath');
|
|
219
221
|
}
|
|
220
222
|
export function validateLwrAppConfig(jsonSourceText, phase) {
|
|
221
223
|
const errors = [];
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.7.0-alpha.2",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -33,31 +33,31 @@
|
|
|
33
33
|
"package.cjs"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@lwrjs/app-service": "0.
|
|
37
|
-
"@lwrjs/asset-registry": "0.
|
|
38
|
-
"@lwrjs/asset-transformer": "0.
|
|
39
|
-
"@lwrjs/base-template-engine": "0.
|
|
40
|
-
"@lwrjs/base-view-provider": "0.
|
|
41
|
-
"@lwrjs/base-view-transformer": "0.
|
|
42
|
-
"@lwrjs/client-modules": "0.
|
|
43
|
-
"@lwrjs/compiler": "0.
|
|
44
|
-
"@lwrjs/diagnostics": "0.
|
|
45
|
-
"@lwrjs/fs-asset-provider": "0.
|
|
46
|
-
"@lwrjs/html-view-provider": "0.
|
|
47
|
-
"@lwrjs/loader": "0.
|
|
48
|
-
"@lwrjs/lwc-module-provider": "0.
|
|
49
|
-
"@lwrjs/lwc-ssr": "0.
|
|
50
|
-
"@lwrjs/markdown-view-provider": "0.
|
|
51
|
-
"@lwrjs/module-bundler": "0.
|
|
52
|
-
"@lwrjs/module-registry": "0.
|
|
53
|
-
"@lwrjs/npm-module-provider": "0.
|
|
54
|
-
"@lwrjs/nunjucks-view-provider": "0.
|
|
55
|
-
"@lwrjs/o11y": "0.
|
|
56
|
-
"@lwrjs/resource-registry": "0.
|
|
57
|
-
"@lwrjs/router": "0.
|
|
58
|
-
"@lwrjs/server": "0.
|
|
59
|
-
"@lwrjs/shared-utils": "0.
|
|
60
|
-
"@lwrjs/view-registry": "0.
|
|
36
|
+
"@lwrjs/app-service": "0.7.0-alpha.2",
|
|
37
|
+
"@lwrjs/asset-registry": "0.7.0-alpha.2",
|
|
38
|
+
"@lwrjs/asset-transformer": "0.7.0-alpha.2",
|
|
39
|
+
"@lwrjs/base-template-engine": "0.7.0-alpha.2",
|
|
40
|
+
"@lwrjs/base-view-provider": "0.7.0-alpha.2",
|
|
41
|
+
"@lwrjs/base-view-transformer": "0.7.0-alpha.2",
|
|
42
|
+
"@lwrjs/client-modules": "0.7.0-alpha.2",
|
|
43
|
+
"@lwrjs/compiler": "0.7.0-alpha.2",
|
|
44
|
+
"@lwrjs/diagnostics": "0.7.0-alpha.2",
|
|
45
|
+
"@lwrjs/fs-asset-provider": "0.7.0-alpha.2",
|
|
46
|
+
"@lwrjs/html-view-provider": "0.7.0-alpha.2",
|
|
47
|
+
"@lwrjs/loader": "0.7.0-alpha.2",
|
|
48
|
+
"@lwrjs/lwc-module-provider": "0.7.0-alpha.2",
|
|
49
|
+
"@lwrjs/lwc-ssr": "0.7.0-alpha.2",
|
|
50
|
+
"@lwrjs/markdown-view-provider": "0.7.0-alpha.2",
|
|
51
|
+
"@lwrjs/module-bundler": "0.7.0-alpha.2",
|
|
52
|
+
"@lwrjs/module-registry": "0.7.0-alpha.2",
|
|
53
|
+
"@lwrjs/npm-module-provider": "0.7.0-alpha.2",
|
|
54
|
+
"@lwrjs/nunjucks-view-provider": "0.7.0-alpha.2",
|
|
55
|
+
"@lwrjs/o11y": "0.7.0-alpha.2",
|
|
56
|
+
"@lwrjs/resource-registry": "0.7.0-alpha.2",
|
|
57
|
+
"@lwrjs/router": "0.7.0-alpha.2",
|
|
58
|
+
"@lwrjs/server": "0.7.0-alpha.2",
|
|
59
|
+
"@lwrjs/shared-utils": "0.7.0-alpha.2",
|
|
60
|
+
"@lwrjs/view-registry": "0.7.0-alpha.2",
|
|
61
61
|
"dompurify": "^2.3.0",
|
|
62
62
|
"fs-extra": "^10.0.0",
|
|
63
63
|
"jsdom": "^16.7.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"qs": "^6.9.4"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@lwrjs/types": "0.
|
|
70
|
+
"@lwrjs/types": "0.7.0-alpha.2"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"lwc": ">= 1.x <= 2.x"
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=14.15.4 <17"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "fc3a13d1c5440833eb2ec17fbf0e294554bafa08"
|
|
79
79
|
}
|