@lwrjs/core 0.8.0-alpha.1 → 0.8.0-alpha.11

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.
@@ -27,7 +27,7 @@ __export(exports, {
27
27
  runConfigurationsHook: () => runConfigurationsHook
28
28
  });
29
29
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
30
- var import_app_config = __toModule(require("../validation/app-config.cjs"));
30
+ var import_config = __toModule(require("@lwrjs/config"));
31
31
  function normalizeRoutesBootstrap({routes, errorRoutes}) {
32
32
  [...routes, ...errorRoutes].forEach((route) => {
33
33
  if (!route.bootstrap) {
@@ -40,7 +40,7 @@ async function runConfigurationsHook(hookPlugins, lwrConfig, dataConfig, runtime
40
40
  await hookPlugin.initConfigs(lwrConfig, dataConfig, runtimeConfig);
41
41
  }
42
42
  try {
43
- (0, import_app_config.validateLwrAppConfig)(JSON.stringify(lwrConfig), "post");
43
+ (0, import_config.validateLwrAppConfig)(JSON.stringify(lwrConfig), "post");
44
44
  } catch (e) {
45
45
  if (process.env.UNSAFE_IGNORE_CONFIG_VALIDATION === "true") {
46
46
  console.warn("ignoring config validation errors due to UNSAFE_IGNORE_CONFIG_VALIDATION flag...proceed with caution");
@@ -36,8 +36,8 @@ var import_resource_registry = __toModule(require("@lwrjs/resource-registry"));
36
36
  var import_asset_registry = __toModule(require("@lwrjs/asset-registry"));
37
37
  var import_view_registry = __toModule(require("@lwrjs/view-registry"));
38
38
  var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
39
- var import_env_config = __toModule(require("./env-config.cjs"));
40
- var import_lwr_app_observer = __toModule(require("./lwr-app-observer.cjs"));
39
+ var import_config = __toModule(require("@lwrjs/config"));
40
+ var import_shared_utils2 = __toModule(require("@lwrjs/shared-utils"));
41
41
  var import_locale_middleware = __toModule(require("./middlewares/locale-middleware.cjs"));
42
42
  var import_api_middleware = __toModule(require("./middlewares/api-middleware.cjs"));
43
43
  var import_ui_middleware = __toModule(require("./middlewares/ui-middleware.cjs"));
@@ -69,7 +69,7 @@ async function initContext(app, server, rawLwrConfig) {
69
69
  const {apiVersion, basePath, lwrVersion, serverMode, globalDataDir, globalData} = rawLwrConfig;
70
70
  const rawDataConfig = (0, import_global_data.getGlobalData)(globalDataDir, globalData);
71
71
  const rawRuntimeEnvConfig = {
72
- ...(0, import_env_config.explodeMode)(serverMode),
72
+ ...(0, import_config.explodeMode)(serverMode),
73
73
  apiVersion,
74
74
  basePath,
75
75
  lwrVersion,
@@ -80,7 +80,7 @@ async function initContext(app, server, rawLwrConfig) {
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);
82
82
  const assetTransformers = await getServices(rawLwrConfig.assetTransformers, void 0, rawLwrConfig);
83
- const appObserver = new import_lwr_app_observer.LwrApplicationObserver();
83
+ const appObserver = new import_shared_utils2.LwrApplicationObserver();
84
84
  const appEmitter = appObserver.createLwrEmitter();
85
85
  const compiler = new import_compiler.LwrCompiler();
86
86
  const assetRegistry = new import_asset_registry.LwrAssetRegistry({
@@ -95,7 +95,7 @@ async function initContext(app, server, rawLwrConfig) {
95
95
  appEmitter,
96
96
  runtimeEnvironment: runtimeConfig
97
97
  }, lwrConfig);
98
- const moduleBundler = new import_module_bundler.LwrModuleBundler({moduleRegistry, appObserver}, lwrConfig);
98
+ const moduleBundler = new import_module_bundler.LwrModuleBundler({compiler, moduleRegistry, appObserver}, lwrConfig);
99
99
  const resourceRegistry = new import_resource_registry.LwrResourceRegistry();
100
100
  const viewRegistry = new import_view_registry.LwrViewRegistry({
101
101
  moduleRegistry,
@@ -186,13 +186,13 @@ async function initContext(app, server, rawLwrConfig) {
186
186
  var LwrApp = class {
187
187
  constructor(config) {
188
188
  this.initialized = false;
189
- this.config = (0, import_env_config.normalizeConfig)(config);
189
+ this.config = (0, import_config.normalizeConfig)(config);
190
190
  const {basePath} = this.config;
191
191
  this.app = (0, import_server.createInternalServer)(this.config.serverType, {basePath});
192
192
  this.server = this.app.createHttpServer();
193
193
  }
194
194
  setConfig(config) {
195
- this.config = (0, import_env_config.normalizeConfig)(config);
195
+ this.config = (0, import_config.normalizeConfig)(config);
196
196
  }
197
197
  getConfig() {
198
198
  return this.config;
@@ -42,7 +42,7 @@ var Hmr = class {
42
42
  }
43
43
  setupHotModuleReload() {
44
44
  const {server} = this;
45
- const wss = new import_ws.default.Server({server});
45
+ const wss = new import_ws.WebSocketServer({server});
46
46
  const connectedClients = new Map();
47
47
  this.connectedClients = connectedClients;
48
48
  wss.on("connection", function connection(ws, req) {
@@ -29,14 +29,14 @@ __export(exports, {
29
29
  var import_static_generation = __toModule(require("./static-generation.cjs"));
30
30
  var import_dir = __toModule(require("./utils/dir.cjs"));
31
31
  var import_network_dispatcher = __toModule(require("./utils/network-dispatcher.cjs"));
32
- var import_env_config = __toModule(require("../env-config.cjs"));
32
+ var import_config = __toModule(require("@lwrjs/config"));
33
33
  async function warmupServer(config, internalRequestKey) {
34
34
  console.log("[Server Warmup] starting");
35
35
  const {routes, staticSiteGenerator, port, apiVersion, basePath, lwrVersion, serverMode} = config;
36
36
  staticSiteGenerator.outputDir = import_dir.skipDirCreation;
37
37
  const urlRewriteMap = new Map();
38
38
  const runtimeEnvironment = {
39
- ...(0, import_env_config.explodeMode)(serverMode),
39
+ ...(0, import_config.explodeMode)(serverMode),
40
40
  apiVersion,
41
41
  basePath,
42
42
  lwrVersion,
@@ -33,7 +33,7 @@ var import_path = __toModule(require("path"));
33
33
  var import_fs_extra = __toModule(require("fs-extra"));
34
34
  var import_stream = __toModule(require("./utils/stream.cjs"));
35
35
  var import_dir = __toModule(require("./utils/dir.cjs"));
36
- var import_env_config = __toModule(require("../env-config.cjs"));
36
+ var import_config = __toModule(require("@lwrjs/config"));
37
37
  var SiteGenerator = class {
38
38
  async buildStaticApplication(config, dispatcher) {
39
39
  const startTime = import_perf_hooks.performance.now();
@@ -48,7 +48,7 @@ var SiteGenerator = class {
48
48
  const urlRewriteMap = new Map();
49
49
  const {apiVersion, basePath, lwrVersion, serverMode} = config;
50
50
  const runtimeEnvironment = {
51
- ...(0, import_env_config.explodeMode)(serverMode),
51
+ ...(0, import_config.explodeMode)(serverMode),
52
52
  apiVersion,
53
53
  basePath,
54
54
  lwrVersion,
@@ -101,8 +101,8 @@ var SiteGenerator = class {
101
101
  const {visitedUrls} = siteConfig;
102
102
  if (!visitedUrls.has(url)) {
103
103
  visitedUrls.add(url);
104
- if (url.indexOf("/:") !== -1) {
105
- console.error("Skipped url with variable path segment: " + url);
104
+ if (url.indexOf("/:") !== -1 || url.indexOf("*") !== -1) {
105
+ console.error("Skipped generation of url with variable path segment: " + url);
106
106
  return;
107
107
  }
108
108
  let context;
@@ -183,7 +183,7 @@ var SiteGenerator = class {
183
183
  const {outputDir} = siteConfig;
184
184
  let fileName = "index.html";
185
185
  let directoryPath = url;
186
- if (url.endsWith(".html")) {
186
+ if (url.endsWith(".html") || url.endsWith(".xml")) {
187
187
  const lastPathIndex = url.lastIndexOf("/") + 1;
188
188
  fileName = url.substring(lastPathIndex, url.length);
189
189
  directoryPath = url.substring(0, lastPathIndex);
@@ -404,6 +404,8 @@ var ViewImportMetadataImpl = class {
404
404
  }
405
405
  mergeImportMetadata(targetImportMetdadata, newImportMetadata) {
406
406
  Object.assign(targetImportMetdadata.imports, newImportMetadata.imports);
407
- Object.assign(targetImportMetdadata.index, newImportMetadata.index);
407
+ if (targetImportMetdadata.index) {
408
+ Object.assign(targetImportMetdadata.index, newImportMetadata.index || {});
409
+ }
408
410
  }
409
411
  };
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_LWR_BOOTSTRAP_CONFIG } from '@lwrjs/shared-utils';
2
- import { validateLwrAppConfig } from '../validation/app-config.js';
2
+ import { validateLwrAppConfig } from '@lwrjs/config';
3
3
  // Add missing bootstrap objects to routes
4
4
  function normalizeRoutesBootstrap({ routes, errorRoutes }) {
5
5
  [...routes, ...errorRoutes].forEach((route) => {
package/build/es/index.js CHANGED
@@ -6,8 +6,8 @@ import { LwrResourceRegistry } from '@lwrjs/resource-registry';
6
6
  import { LwrAssetRegistry } from '@lwrjs/asset-registry';
7
7
  import { LwrViewRegistry } from '@lwrjs/view-registry';
8
8
  import { LwrServerError, createSingleDiagnosticError, descriptions } from '@lwrjs/diagnostics';
9
- import { normalizeConfig, explodeMode } from './env-config.js';
10
- import { LwrApplicationObserver } from './lwr-app-observer.js';
9
+ import { normalizeConfig, explodeMode } from '@lwrjs/config';
10
+ import { LwrApplicationObserver } from '@lwrjs/shared-utils';
11
11
  import localeMiddleware from './middlewares/locale-middleware.js';
12
12
  import apiMiddleware from './middlewares/api-middleware.js';
13
13
  import uiMiddleware from './middlewares/ui-middleware.js';
@@ -70,7 +70,7 @@ async function initContext(app, server, rawLwrConfig) {
70
70
  appEmitter,
71
71
  runtimeEnvironment: runtimeConfig,
72
72
  }, lwrConfig);
73
- const moduleBundler = new LwrModuleBundler({ moduleRegistry, appObserver }, lwrConfig);
73
+ const moduleBundler = new LwrModuleBundler({ compiler, moduleRegistry, appObserver }, lwrConfig);
74
74
  const resourceRegistry = new LwrResourceRegistry();
75
75
  const viewRegistry = new LwrViewRegistry({
76
76
  moduleRegistry,
@@ -1,4 +1,4 @@
1
- import WebSocket from 'ws';
1
+ import { WebSocketServer } from 'ws';
2
2
  import { getCacheKeyFromJson } from '@lwrjs/shared-utils';
3
3
  import { getRequestProperties } from './utils.js';
4
4
  let hmr;
@@ -14,7 +14,7 @@ class Hmr {
14
14
  }
15
15
  setupHotModuleReload() {
16
16
  const { server } = this;
17
- const wss = new WebSocket.Server({ server });
17
+ const wss = new WebSocketServer({ server });
18
18
  const connectedClients = new Map();
19
19
  this.connectedClients = connectedClients;
20
20
  wss.on('connection', function connection(ws, req) {
@@ -1,7 +1,7 @@
1
1
  import SiteGenerator from './static-generation.js';
2
2
  import { skipDirCreation } from './utils/dir.js';
3
3
  import NetworkDispatcher from './utils/network-dispatcher.js';
4
- import { explodeMode } from '../env-config.js';
4
+ import { explodeMode } from '@lwrjs/config';
5
5
  export async function warmupServer(config, internalRequestKey) {
6
6
  console.log('[Server Warmup] starting');
7
7
  const { routes, staticSiteGenerator, port, apiVersion, basePath, lwrVersion, serverMode } = config;
@@ -4,7 +4,7 @@ import { join, dirname, extname } from 'path';
4
4
  import fs from 'fs-extra';
5
5
  import { writeResponse } from './utils/stream.js';
6
6
  import { createDir, createResourceDir } from './utils/dir.js';
7
- import { explodeMode } from '../env-config.js';
7
+ import { explodeMode } from '@lwrjs/config';
8
8
  export default class SiteGenerator {
9
9
  /**
10
10
  * Build a static site in the configured directory
@@ -108,8 +108,8 @@ export default class SiteGenerator {
108
108
  visitedUrls.add(url); // Maintain a list of visited urls here to avoid potential infinite loops
109
109
  // Skip urls with path segment variables (i.e. '/custom/:bar')
110
110
  // Users can specify specific urls via the '_additionalRoutePaths' config property
111
- if (url.indexOf('/:') !== -1) {
112
- console.error('Skipped url with variable path segment: ' + url);
111
+ if (url.indexOf('/:') !== -1 || url.indexOf('*') !== -1) {
112
+ console.error('Skipped generation of url with variable path segment: ' + url);
113
113
  return;
114
114
  }
115
115
  // Generate resource
@@ -255,9 +255,9 @@ export default class SiteGenerator {
255
255
  const { outputDir } = siteConfig;
256
256
  let fileName = 'index.html';
257
257
  let directoryPath = url;
258
- // If we have a route path that ends with a .html file extension,
258
+ // If we have a route path that ends with a html or xml file extension,
259
259
  // use that last path segment for the file name
260
- if (url.endsWith('.html')) {
260
+ if (url.endsWith('.html') || url.endsWith('.xml')) {
261
261
  const lastPathIndex = url.lastIndexOf('/') + 1;
262
262
  fileName = url.substring(lastPathIndex, url.length);
263
263
  directoryPath = url.substring(0, lastPathIndex);
@@ -576,7 +576,9 @@ export class ViewImportMetadataImpl {
576
576
  */
577
577
  mergeImportMetadata(targetImportMetdadata, newImportMetadata) {
578
578
  Object.assign(targetImportMetdadata.imports, newImportMetadata.imports);
579
- Object.assign(targetImportMetdadata.index, newImportMetadata.index);
579
+ if (targetImportMetdadata.index) {
580
+ Object.assign(targetImportMetdadata.index, newImportMetadata.index || {});
581
+ }
580
582
  }
581
583
  }
582
584
  //# sourceMappingURL=static-generation.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.8.0-alpha.1",
7
+ "version": "0.8.0-alpha.11",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -29,49 +29,50 @@
29
29
  "build/**/*.js",
30
30
  "build/**/*.cjs",
31
31
  "build/**/*.d.ts",
32
- "runtime-configs",
33
32
  "package.cjs"
34
33
  ],
35
34
  "dependencies": {
36
- "@lwrjs/app-service": "0.8.0-alpha.1",
37
- "@lwrjs/asset-registry": "0.8.0-alpha.1",
38
- "@lwrjs/asset-transformer": "0.8.0-alpha.1",
39
- "@lwrjs/base-template-engine": "0.8.0-alpha.1",
40
- "@lwrjs/base-view-provider": "0.8.0-alpha.1",
41
- "@lwrjs/base-view-transformer": "0.8.0-alpha.1",
42
- "@lwrjs/client-modules": "0.8.0-alpha.1",
43
- "@lwrjs/compiler": "0.8.0-alpha.1",
44
- "@lwrjs/diagnostics": "0.8.0-alpha.1",
45
- "@lwrjs/fs-asset-provider": "0.8.0-alpha.1",
46
- "@lwrjs/html-view-provider": "0.8.0-alpha.1",
47
- "@lwrjs/loader": "0.8.0-alpha.1",
48
- "@lwrjs/lwc-module-provider": "0.8.0-alpha.1",
49
- "@lwrjs/lwc-ssr": "0.8.0-alpha.1",
50
- "@lwrjs/markdown-view-provider": "0.8.0-alpha.1",
51
- "@lwrjs/module-bundler": "0.8.0-alpha.1",
52
- "@lwrjs/module-registry": "0.8.0-alpha.1",
53
- "@lwrjs/npm-module-provider": "0.8.0-alpha.1",
54
- "@lwrjs/nunjucks-view-provider": "0.8.0-alpha.1",
55
- "@lwrjs/o11y": "0.8.0-alpha.1",
56
- "@lwrjs/resource-registry": "0.8.0-alpha.1",
57
- "@lwrjs/router": "0.8.0-alpha.1",
58
- "@lwrjs/server": "0.8.0-alpha.1",
59
- "@lwrjs/shared-utils": "0.8.0-alpha.1",
60
- "@lwrjs/view-registry": "0.8.0-alpha.1",
35
+ "@lwrjs/app-service": "0.8.0-alpha.11",
36
+ "@lwrjs/asset-registry": "0.8.0-alpha.11",
37
+ "@lwrjs/asset-transformer": "0.8.0-alpha.11",
38
+ "@lwrjs/base-template-engine": "0.8.0-alpha.11",
39
+ "@lwrjs/base-view-provider": "0.8.0-alpha.11",
40
+ "@lwrjs/base-view-transformer": "0.8.0-alpha.11",
41
+ "@lwrjs/client-modules": "0.8.0-alpha.11",
42
+ "@lwrjs/compiler": "0.8.0-alpha.11",
43
+ "@lwrjs/config": "0.8.0-alpha.11",
44
+ "@lwrjs/diagnostics": "0.8.0-alpha.11",
45
+ "@lwrjs/fs-asset-provider": "0.8.0-alpha.11",
46
+ "@lwrjs/html-view-provider": "0.8.0-alpha.11",
47
+ "@lwrjs/loader": "0.8.0-alpha.11",
48
+ "@lwrjs/lwc-module-provider": "0.8.0-alpha.11",
49
+ "@lwrjs/lwc-ssr": "0.8.0-alpha.11",
50
+ "@lwrjs/markdown-view-provider": "0.8.0-alpha.11",
51
+ "@lwrjs/module-bundler": "0.8.0-alpha.11",
52
+ "@lwrjs/module-registry": "0.8.0-alpha.11",
53
+ "@lwrjs/npm-module-provider": "0.8.0-alpha.11",
54
+ "@lwrjs/nunjucks-view-provider": "0.8.0-alpha.11",
55
+ "@lwrjs/o11y": "0.8.0-alpha.11",
56
+ "@lwrjs/resource-registry": "0.8.0-alpha.11",
57
+ "@lwrjs/router": "0.8.0-alpha.11",
58
+ "@lwrjs/server": "0.8.0-alpha.11",
59
+ "@lwrjs/shared-utils": "0.8.0-alpha.11",
60
+ "@lwrjs/view-registry": "0.8.0-alpha.11",
61
61
  "fs-extra": "^10.1.0",
62
- "jsonc-parser": "^3.0.0",
63
62
  "ms": "^2.1.3",
64
63
  "path-to-regexp": "^6.2.0",
65
- "qs": "^6.9.4"
64
+ "qs": "^6.9.4",
65
+ "ws": "^8.8.1"
66
66
  },
67
67
  "devDependencies": {
68
- "@lwrjs/types": "0.8.0-alpha.1"
68
+ "@lwrjs/types": "0.8.0-alpha.11",
69
+ "@types/ws": "^8.5.3"
69
70
  },
70
71
  "peerDependencies": {
71
- "lwc": ">= 1.x <= 2.x"
72
+ "lwc": "2.x"
72
73
  },
73
74
  "engines": {
74
75
  "node": ">=14.15.4 <19"
75
76
  },
76
- "gitHead": "2718cc5abe11d0d6fd5375cf9205167b6f69e244"
77
+ "gitHead": "e8a2c6811e4a52227219f2d94648e0eae9800fbc"
77
78
  }