@lwrjs/config 0.15.0-alpha.12 → 0.15.0-alpha.13

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.
@@ -185,5 +185,8 @@ var DEFAULT_LWR_BOOTSTRAP_CONFIG = {
185
185
  module: void 0,
186
186
  preloadModules: [],
187
187
  lwrVersion: import_package.lwrVersion,
188
- lwcVersion: import_package.lwcVersion
188
+ lwcVersion: import_package.lwcVersion,
189
+ preloadResources: {
190
+ patterns: []
191
+ }
189
192
  };
@@ -131,7 +131,8 @@ var BOOTSTRAP_ATTRIBUTE_KEYS = createKeys("bootstrap", [
131
131
  "module",
132
132
  "preloadModules",
133
133
  "lwrVersion",
134
- "lwcVersion"
134
+ "lwcVersion",
135
+ "preloadResources"
135
136
  ]);
136
137
  function isNotEmptyString(node) {
137
138
  return node.type === "string" && node.value.length > 0;
@@ -146,7 +147,7 @@ var ValidationContext = class {
146
147
  return (0, import_helpers.calculatePositionFromSource)(this.sourceText, node);
147
148
  }
148
149
  assertIsObject(node, property) {
149
- if (node.type !== "object") {
150
+ if (node?.type !== "object" && node) {
150
151
  this.diagnostics.push({
151
152
  description: import_diagnostics.descriptions.CONFIG_PARSER.INCORRECT_NODE_TYPE(property, "object", node.type),
152
153
  location: this.getLocationFromNode(node)
@@ -177,6 +178,22 @@ var ValidationContext = class {
177
178
  });
178
179
  }
179
180
  }
181
+ assertIsFilePattern(node, property) {
182
+ const fileExtRegex = /^\.[a-zA-Z0-9]+$/;
183
+ if (node) {
184
+ const children = node.children || [];
185
+ for (const [index, child] of children.entries()) {
186
+ const match = (0, import_jsonc_parser.findNodeAtLocation)(child, ["match"])?.value;
187
+ if (!fileExtRegex.test(match)) {
188
+ this.diagnostics.push({
189
+ description: import_diagnostics.descriptions.CONFIG_PARSER.INVALID_FILE_PATTERN(`${property}[${index}].match`, match),
190
+ location: this.getLocationFromNode(node)
191
+ });
192
+ break;
193
+ }
194
+ }
195
+ }
196
+ }
180
197
  assertIsPath(node, property) {
181
198
  if (node && (node.type !== "string" || node.value[0] !== "/")) {
182
199
  this.diagnostics.push({
@@ -57,6 +57,7 @@ function validateBootstrap(node, validationContext, propPrefix) {
57
57
  validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["lwrVersion"]), `${propPrefix}.lwrVersion`);
58
58
  validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["lwcVersion"]), `${propPrefix}.lwcVersion`);
59
59
  validationContext.assertSsrPreloadData(node, propPrefix);
60
+ validationContext.assertIsFilePattern((0, import_jsonc_parser.findNodeAtLocation)(node, ["preloadResources", "patterns"]), `${propPrefix}.preloadResources.patterns`);
60
61
  const workers = (0, import_jsonc_parser.findNodeAtLocation)(node, ["workers"]);
61
62
  if (workers && workers.children) {
62
63
  workers.children.forEach((w, index) => {
@@ -160,6 +160,9 @@ export const DEFAULT_LWR_BOOTSTRAP_CONFIG = {
160
160
  module: undefined,
161
161
  preloadModules: [],
162
162
  lwrVersion: LWR_VERSION,
163
- lwcVersion: LWC_VERSION
163
+ lwcVersion: LWC_VERSION,
164
+ preloadResources: {
165
+ patterns: []
166
+ },
164
167
  };
165
168
  //# sourceMappingURL=defaults.js.map
@@ -33,17 +33,18 @@ export declare const I18N_ATTRIBUTE_KEYS: ["defaultLocale", "locales", "uriPatte
33
33
  export declare const STATIC_SITE_GENERATOR_ATTRIBUTE_KEYS: ["outputDir", "skipBaseDocumentGeneration", "skipCleanOutputDir", "_additionalModules", "_additionalRoutePaths"];
34
34
  export declare const ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "subRoutes", "contentTemplate", "id", "cache", "layoutTemplate", "method", "path", "rootComponent", "routeHandler", "properties"];
35
35
  export declare const ERROR_ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "subRoutes", "contentTemplate", "id", "layoutTemplate", "rootComponent", "routeHandler", "status", "properties", "cache"];
36
- export declare const BOOTSTRAP_ATTRIBUTE_KEYS: ["autoBoot", "syntheticShadow", "workers", "services", "configAsSrc", "ssr", "preloadData", "proxyForSSR", "includeCookiesForSSR", "mixedMode", "module", "preloadModules", "lwrVersion", "lwcVersion"];
36
+ export declare const BOOTSTRAP_ATTRIBUTE_KEYS: ["autoBoot", "syntheticShadow", "workers", "services", "configAsSrc", "ssr", "preloadData", "proxyForSSR", "includeCookiesForSSR", "mixedMode", "module", "preloadModules", "lwrVersion", "lwcVersion", "preloadResources"];
37
37
  export declare const BASE_PATH_REGEX: RegExp;
38
38
  export declare class ValidationContext {
39
39
  diagnostics: Diagnostic[];
40
40
  sourceText: string;
41
41
  constructor(sourceText: string);
42
42
  private getLocationFromNode;
43
- assertIsObject<T extends keyof ConfigMap>(node: Node, property: T): void;
43
+ assertIsObject(node: Node | undefined, property: string): void;
44
44
  assertIsBoolean(node: Node | undefined, property: string): void;
45
45
  assertIsArray(node: Node | undefined, property: string): void;
46
46
  assertIsSpecifier(node: Node | undefined, property: string): void;
47
+ assertIsFilePattern(node: Node | undefined, property: string): void;
47
48
  assertIsPath(node: Node | undefined, property: string): void;
48
49
  assertIsPort(node: Node | undefined, property: string): void;
49
50
  assertIsServerType(node: Node | undefined, property: string): void;
@@ -95,7 +95,8 @@ export const BOOTSTRAP_ATTRIBUTE_KEYS = createKeys('bootstrap', [
95
95
  'module',
96
96
  'preloadModules',
97
97
  'lwrVersion',
98
- 'lwcVersion'
98
+ 'lwcVersion',
99
+ 'preloadResources'
99
100
  ]);
100
101
  function isNotEmptyString(node) {
101
102
  return node.type === 'string' && node.value.length > 0;
@@ -110,7 +111,7 @@ export class ValidationContext {
110
111
  return calculatePositionFromSource(this.sourceText, node);
111
112
  }
112
113
  assertIsObject(node, property) {
113
- if (node.type !== 'object') {
114
+ if (node?.type !== 'object' && node) {
114
115
  this.diagnostics.push({
115
116
  description: descriptions.CONFIG_PARSER.INCORRECT_NODE_TYPE(property, 'object', node.type),
116
117
  location: this.getLocationFromNode(node),
@@ -141,6 +142,22 @@ export class ValidationContext {
141
142
  });
142
143
  }
143
144
  }
145
+ assertIsFilePattern(node, property) {
146
+ const fileExtRegex = /^\.[a-zA-Z0-9]+$/;
147
+ if (node) {
148
+ const children = node.children || [];
149
+ for (const [index, child] of children.entries()) {
150
+ const match = findNodeAtLocation(child, ['match'])?.value;
151
+ if (!fileExtRegex.test(match)) {
152
+ this.diagnostics.push({
153
+ description: descriptions.CONFIG_PARSER.INVALID_FILE_PATTERN(`${property}[${index}].match`, match),
154
+ location: this.getLocationFromNode(node)
155
+ });
156
+ break;
157
+ }
158
+ }
159
+ }
160
+ }
144
161
  assertIsPath(node, property) {
145
162
  if (node && (node.type !== 'string' || node.value[0] !== '/')) {
146
163
  this.diagnostics.push({
@@ -22,6 +22,7 @@ export const SOURCE_BY_PHASE = {
22
22
  * - module: optional string specifier
23
23
  * - lwrVersion: optional string version
24
24
  * - lwcVersion: optional string version
25
+ * - preloadResources: optional object
25
26
  */
26
27
  function validateBootstrap(node, validationContext, propPrefix) {
27
28
  if (node) {
@@ -41,6 +42,7 @@ function validateBootstrap(node, validationContext, propPrefix) {
41
42
  validationContext.assertNotEmptyString(findNode(node, ['lwrVersion']), `${propPrefix}.lwrVersion`);
42
43
  validationContext.assertNotEmptyString(findNode(node, ['lwcVersion']), `${propPrefix}.lwcVersion`);
43
44
  validationContext.assertSsrPreloadData(node, propPrefix);
45
+ validationContext.assertIsFilePattern(findNode(node, ['preloadResources', 'patterns']), `${propPrefix}.preloadResources.patterns`);
44
46
  // Each value in the worker map msut be a specifier
45
47
  const workers = findNode(node, ['workers']);
46
48
  if (workers && workers.children) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.15.0-alpha.12",
7
+ "version": "0.15.0-alpha.13",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -42,14 +42,14 @@
42
42
  "test": "jest"
43
43
  },
44
44
  "dependencies": {
45
- "@lwrjs/diagnostics": "0.15.0-alpha.12",
46
- "@lwrjs/instrumentation": "0.15.0-alpha.12",
47
- "@lwrjs/shared-utils": "0.15.0-alpha.12",
45
+ "@lwrjs/diagnostics": "0.15.0-alpha.13",
46
+ "@lwrjs/instrumentation": "0.15.0-alpha.13",
47
+ "@lwrjs/shared-utils": "0.15.0-alpha.13",
48
48
  "fs-extra": "^11.2.0",
49
49
  "jsonc-parser": "^3.3.1"
50
50
  },
51
51
  "devDependencies": {
52
- "@lwrjs/types": "0.15.0-alpha.12",
52
+ "@lwrjs/types": "0.15.0-alpha.13",
53
53
  "jest": "^26.6.3",
54
54
  "memfs": "^4.9.3",
55
55
  "ts-jest": "^26.5.6"
@@ -71,5 +71,5 @@
71
71
  "volta": {
72
72
  "extends": "../../../package.json"
73
73
  },
74
- "gitHead": "24d0d4a163fcfbaa5e0a005aafd7cf77f314a2ab"
74
+ "gitHead": "687327a328b33a1abc3ac45e1406d72ebe7d37b4"
75
75
  }