@lwrjs/config 0.10.0-alpha.4 → 0.10.0-alpha.6
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/validation/app-config-context.cjs +22 -0
- package/build/cjs/validation/app-config.cjs +3 -1
- package/build/es/utils/routes.d.ts +2 -2
- package/build/es/validation/app-config-context.d.ts +6 -5
- package/build/es/validation/app-config-context.js +22 -0
- package/build/es/validation/app-config.d.ts +1 -1
- package/build/es/validation/app-config.js +5 -1
- package/package.json +5 -5
|
@@ -377,6 +377,28 @@ var ValidationContext = class {
|
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
+
assertClientLockerSSR(routesNode, lockerNode) {
|
|
381
|
+
if (routesNode && lockerNode) {
|
|
382
|
+
const enabled = (0, import_jsonc_parser.findNodeAtLocation)(lockerNode, ["enabled"]);
|
|
383
|
+
const clientOnly = (0, import_jsonc_parser.findNodeAtLocation)(lockerNode, ["clientOnly"]);
|
|
384
|
+
const compileTimeLocker = enabled && enabled.value === true && (!clientOnly || clientOnly.value === false);
|
|
385
|
+
if (compileTimeLocker && routesNode.children) {
|
|
386
|
+
const hasSSR = routesNode.children.some((n) => {
|
|
387
|
+
const bootstrap = (0, import_jsonc_parser.findNodeAtLocation)(n, ["bootstrap"]);
|
|
388
|
+
if (bootstrap) {
|
|
389
|
+
const ssr = (0, import_jsonc_parser.findNodeAtLocation)(bootstrap, ["ssr"]);
|
|
390
|
+
return ssr?.value === true;
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
if (hasSSR) {
|
|
394
|
+
this.diagnostics.push({
|
|
395
|
+
description: import_diagnostics.descriptions.CONFIG_PARSER.COMPILE_LOCKER_SSR(),
|
|
396
|
+
location: this.getLocationFromNode(lockerNode)
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
380
402
|
assertRequiredKeys(node, property, requiredPropertyKeys) {
|
|
381
403
|
const missingProps = requiredPropertyKeys.filter((p) => (0, import_jsonc_parser.findNodeAtLocation)(node, [p]) === void 0);
|
|
382
404
|
if (missingProps.length > 0) {
|
|
@@ -152,11 +152,13 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
152
152
|
const routes = (0, import_jsonc_parser.findNodeAtLocation)(node, ["routes"]);
|
|
153
153
|
const errorRoutes = (0, import_jsonc_parser.findNodeAtLocation)(node, ["errorRoutes"]);
|
|
154
154
|
validationContext.assertUniqueIds([...routes?.children || [], ...errorRoutes?.children || []], "routes");
|
|
155
|
+
const lockerNode = (0, import_jsonc_parser.findNodeAtLocation)(node, ["locker"]);
|
|
155
156
|
validateRoutes(routes, validationContext, preMerge);
|
|
156
157
|
validateErrorRoutes(errorRoutes, validationContext);
|
|
157
158
|
validateRouteHandlers((0, import_jsonc_parser.findNodeAtLocation)(node, ["routeHandlers"]), validationContext);
|
|
158
159
|
validateAssets((0, import_jsonc_parser.findNodeAtLocation)(node, ["assets"]), validationContext, preMerge);
|
|
159
|
-
validateLocker(
|
|
160
|
+
validateLocker(lockerNode, validationContext);
|
|
161
|
+
validationContext.assertClientLockerSSR(routes, lockerNode);
|
|
160
162
|
validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["apiVersion"]), "apiVersion");
|
|
161
163
|
validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["lwrVersion"]), "lwrVersion");
|
|
162
164
|
validationContext.assertIsSpecifier((0, import_jsonc_parser.findNodeAtLocation)(node, ["amdLoader"]), "amdLoader");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LwrErrorRoute, LwrRoute, NormalizedLwrErrorRoute, NormalizedLwrRoute, ResourcePaths, RouteHandlersConfig } from '@lwrjs/types';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type ViewOrErrorRoute = LwrRoute | LwrErrorRoute;
|
|
3
|
+
type NormalizedRoute<T extends ViewOrErrorRoute> = T extends LwrRoute ? NormalizedLwrRoute : NormalizedLwrErrorRoute;
|
|
4
4
|
export declare function normalizeRoutes<T extends ViewOrErrorRoute>(routes: T[], routeHandlers: RouteHandlersConfig): NormalizedRoute<T>[];
|
|
5
5
|
export declare function normalizeRoutePaths<T extends ViewOrErrorRoute>(routes: T[] | undefined, resourcePaths: ResourcePaths): NormalizedRoute<T>[];
|
|
6
6
|
export declare function normalizeRouteHandlerPaths(routeHandlers: RouteHandlersConfig, resourcePaths: ResourcePaths): RouteHandlersConfig;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AssetDirConfig, AssetFileConfig, LwrErrorRoute, LwrRoute, NormalizedLwrGlobalConfig, NormalizedLwrAppBootstrapConfig, LwrLockerConfig, RouteHandlersConfig } from '@lwrjs/types';
|
|
2
2
|
import { Node } from 'jsonc-parser';
|
|
3
3
|
import { Diagnostic } from '@lwrjs/diagnostics';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
type RequiredAssetDirConfig = Required<AssetDirConfig>;
|
|
5
|
+
type RequiredAssetFileConfig = Required<AssetFileConfig>;
|
|
6
|
+
type RequiredLwrRoute = Required<LwrRoute>;
|
|
7
|
+
type RequiredLwrErrorRoute = Required<LwrErrorRoute>;
|
|
8
|
+
type RequiredLwrLockerConfig = Required<LwrLockerConfig>;
|
|
9
9
|
interface ConfigMap {
|
|
10
10
|
root: NormalizedLwrGlobalConfig;
|
|
11
11
|
assetDir: RequiredAssetDirConfig;
|
|
@@ -49,6 +49,7 @@ export declare class ValidationContext {
|
|
|
49
49
|
assertArrayOfSpecifiers(node: Node | undefined, property: string): void;
|
|
50
50
|
assertArrayOfServices(node: Node | undefined, property: string): void;
|
|
51
51
|
assertUniqueIds(nodes: Node[], property: string): void;
|
|
52
|
+
assertClientLockerSSR(routesNode: Node | undefined, lockerNode: Node | undefined): void;
|
|
52
53
|
assertRequiredKeys(node: Node, property: string, requiredPropertyKeys: string[]): void;
|
|
53
54
|
assertValidKeys<T extends keyof ConfigMap>(node: Node, property: T, validPropertyKeys: (keyof ConfigMap[T])[]): void;
|
|
54
55
|
}
|
|
@@ -359,6 +359,28 @@ export class ValidationContext {
|
|
|
359
359
|
});
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
|
+
assertClientLockerSSR(routesNode, lockerNode) {
|
|
363
|
+
if (routesNode && lockerNode) {
|
|
364
|
+
const enabled = findNodeAtLocation(lockerNode, ['enabled']);
|
|
365
|
+
const clientOnly = findNodeAtLocation(lockerNode, ['clientOnly']);
|
|
366
|
+
const compileTimeLocker = enabled && enabled.value === true && (!clientOnly || clientOnly.value === false);
|
|
367
|
+
if (compileTimeLocker && routesNode.children) {
|
|
368
|
+
const hasSSR = routesNode.children.some((n) => {
|
|
369
|
+
const bootstrap = findNodeAtLocation(n, ['bootstrap']);
|
|
370
|
+
if (bootstrap) {
|
|
371
|
+
const ssr = findNodeAtLocation(bootstrap, ['ssr']);
|
|
372
|
+
return ssr?.value === true;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
if (hasSSR) {
|
|
376
|
+
this.diagnostics.push({
|
|
377
|
+
description: descriptions.CONFIG_PARSER.COMPILE_LOCKER_SSR(),
|
|
378
|
+
location: this.getLocationFromNode(lockerNode),
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
362
384
|
assertRequiredKeys(node, property, requiredPropertyKeys) {
|
|
363
385
|
// All of the given properties must exist on the node
|
|
364
386
|
const missingProps = requiredPropertyKeys.filter((p) => findNodeAtLocation(node, [p]) === undefined);
|
|
@@ -4,7 +4,7 @@ export declare const SOURCE_BY_PHASE: {
|
|
|
4
4
|
pre: string;
|
|
5
5
|
post: string;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type ConfigPhase = 'file' | 'pre' | 'post';
|
|
8
8
|
export declare function validateLwrAppConfig(config: string | LwrGlobalConfig, phase: ConfigPhase): void | never;
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=app-config.d.ts.map
|
|
@@ -178,6 +178,8 @@ function validateLocker(node, validationContext) {
|
|
|
178
178
|
* - routes...
|
|
179
179
|
* - errorRoutes...
|
|
180
180
|
* - assets...
|
|
181
|
+
* - locker...
|
|
182
|
+
* - SSR is only used with clientOnly locker (or locker is disabled)
|
|
181
183
|
* - route and errorRoute ids must be unique
|
|
182
184
|
* - apiVersion: string
|
|
183
185
|
* - lwrVersion: string
|
|
@@ -206,11 +208,13 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
206
208
|
const routes = findNode(node, ['routes']);
|
|
207
209
|
const errorRoutes = findNode(node, ['errorRoutes']);
|
|
208
210
|
validationContext.assertUniqueIds([...(routes?.children || []), ...(errorRoutes?.children || [])], 'routes');
|
|
211
|
+
const lockerNode = findNode(node, ['locker']);
|
|
209
212
|
validateRoutes(routes, validationContext, preMerge);
|
|
210
213
|
validateErrorRoutes(errorRoutes, validationContext);
|
|
211
214
|
validateRouteHandlers(findNode(node, ['routeHandlers']), validationContext);
|
|
212
215
|
validateAssets(findNode(node, ['assets']), validationContext, preMerge);
|
|
213
|
-
validateLocker(
|
|
216
|
+
validateLocker(lockerNode, validationContext);
|
|
217
|
+
validationContext.assertClientLockerSSR(routes, lockerNode);
|
|
214
218
|
validationContext.assertNotEmptyString(findNode(node, ['apiVersion']), 'apiVersion');
|
|
215
219
|
validationContext.assertNotEmptyString(findNode(node, ['lwrVersion']), 'lwrVersion');
|
|
216
220
|
validationContext.assertIsSpecifier(findNode(node, ['amdLoader']), 'amdLoader');
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.10.0-alpha.
|
|
7
|
+
"version": "0.10.0-alpha.6",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"package.cjs"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@lwrjs/diagnostics": "0.10.0-alpha.
|
|
40
|
-
"@lwrjs/shared-utils": "0.10.0-alpha.
|
|
39
|
+
"@lwrjs/diagnostics": "0.10.0-alpha.6",
|
|
40
|
+
"@lwrjs/shared-utils": "0.10.0-alpha.6",
|
|
41
41
|
"fs-extra": "^11.1.0",
|
|
42
42
|
"jsonc-parser": "^3.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@lwrjs/types": "0.10.0-alpha.
|
|
45
|
+
"@lwrjs/types": "0.10.0-alpha.6"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"lwc": "2.x"
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=16.0.0 <20"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "9592d07bd5204eb85c9cb8b576e2a267a798ce00"
|
|
54
54
|
}
|