@lwrjs/core 0.8.0-alpha.0 → 0.8.0-alpha.10
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/context/hooks.cjs +2 -2
- package/build/cjs/index.cjs +5 -5
- package/build/cjs/tools/server-warmup.cjs +2 -2
- package/build/cjs/tools/static-generation.cjs +18 -9
- package/build/es/context/hooks.js +1 -1
- package/build/es/index.js +2 -2
- package/build/es/tools/server-warmup.js +1 -1
- package/build/es/tools/static-generation.js +23 -11
- package/package.json +29 -30
- package/build/cjs/env-config.cjs +0 -339
- package/build/cjs/validation/app-config-context.cjs +0 -406
- package/build/cjs/validation/app-config.cjs +0 -192
- package/build/cjs/validation/helpers.cjs +0 -34
- package/build/es/env-config.d.ts +0 -14
- package/build/es/env-config.js +0 -352
- package/build/es/validation/app-config-context.d.ts +0 -55
- package/build/es/validation/app-config-context.js +0 -391
- package/build/es/validation/app-config.d.ts +0 -10
- package/build/es/validation/app-config.js +0 -245
- package/build/es/validation/helpers.d.ts +0 -8
- package/build/es/validation/helpers.js +0 -23
- package/runtime-configs/compat.json +0 -13
- package/runtime-configs/dev.json +0 -13
- package/runtime-configs/prod-compat.json +0 -13
- package/runtime-configs/prod.json +0 -13
|
@@ -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
|
|
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,
|
|
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");
|
package/build/cjs/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ 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
|
|
39
|
+
var import_config = __toModule(require("@lwrjs/config"));
|
|
40
40
|
var import_lwr_app_observer = __toModule(require("./lwr-app-observer.cjs"));
|
|
41
41
|
var import_locale_middleware = __toModule(require("./middlewares/locale-middleware.cjs"));
|
|
42
42
|
var import_api_middleware = __toModule(require("./middlewares/api-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,
|
|
72
|
+
...(0, import_config.explodeMode)(serverMode),
|
|
73
73
|
apiVersion,
|
|
74
74
|
basePath,
|
|
75
75
|
lwrVersion,
|
|
@@ -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,
|
|
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,
|
|
195
|
+
this.config = (0, import_config.normalizeConfig)(config);
|
|
196
196
|
}
|
|
197
197
|
getConfig() {
|
|
198
198
|
return this.config;
|
|
@@ -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
|
|
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,
|
|
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
|
|
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,
|
|
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;
|
|
@@ -181,10 +181,17 @@ var SiteGenerator = class {
|
|
|
181
181
|
}
|
|
182
182
|
async handleHtmlResource(url, context, siteConfig, dispatcher) {
|
|
183
183
|
const {outputDir} = siteConfig;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
let fileName = "index.html";
|
|
185
|
+
let directoryPath = url;
|
|
186
|
+
if (url.endsWith(".html") || url.endsWith(".xml")) {
|
|
187
|
+
const lastPathIndex = url.lastIndexOf("/") + 1;
|
|
188
|
+
fileName = url.substring(lastPathIndex, url.length);
|
|
189
|
+
directoryPath = url.substring(0, lastPathIndex);
|
|
190
|
+
}
|
|
191
|
+
const dir = (0, import_dir.createResourceDir)(directoryPath, outputDir);
|
|
192
|
+
const localeDir = (0, import_dir.createResourceDir)(directoryPath, (0, import_path.join)(outputDir, siteConfig.locale));
|
|
193
|
+
const filePath = (0, import_path.join)(dir, fileName);
|
|
194
|
+
const fileLocalePath = (0, import_path.join)(localeDir, fileName);
|
|
188
195
|
if (siteConfig.locale.toLowerCase().startsWith("en")) {
|
|
189
196
|
siteConfig.viewPaths.add(filePath);
|
|
190
197
|
await (0, import_stream.writeResponse)(context, filePath);
|
|
@@ -397,6 +404,8 @@ var ViewImportMetadataImpl = class {
|
|
|
397
404
|
}
|
|
398
405
|
mergeImportMetadata(targetImportMetdadata, newImportMetadata) {
|
|
399
406
|
Object.assign(targetImportMetdadata.imports, newImportMetadata.imports);
|
|
400
|
-
|
|
407
|
+
if (targetImportMetdadata.index) {
|
|
408
|
+
Object.assign(targetImportMetdadata.index, newImportMetadata.index || {});
|
|
409
|
+
}
|
|
401
410
|
}
|
|
402
411
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_LWR_BOOTSTRAP_CONFIG } from '@lwrjs/shared-utils';
|
|
2
|
-
import { validateLwrAppConfig } from '
|
|
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,7 +6,7 @@ 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 '
|
|
9
|
+
import { normalizeConfig, explodeMode } from '@lwrjs/config';
|
|
10
10
|
import { LwrApplicationObserver } from './lwr-app-observer.js';
|
|
11
11
|
import localeMiddleware from './middlewares/locale-middleware.js';
|
|
12
12
|
import apiMiddleware from './middlewares/api-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,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 '
|
|
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 '
|
|
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
|
|
@@ -253,14 +253,24 @@ export default class SiteGenerator {
|
|
|
253
253
|
*/
|
|
254
254
|
async handleHtmlResource(url, context, siteConfig, dispatcher) {
|
|
255
255
|
const { outputDir } = siteConfig;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
//
|
|
259
|
-
//
|
|
260
|
-
|
|
256
|
+
let fileName = 'index.html';
|
|
257
|
+
let directoryPath = url;
|
|
258
|
+
// If we have a route path that ends with a html or xml file extension,
|
|
259
|
+
// use that last path segment for the file name
|
|
260
|
+
if (url.endsWith('.html') || url.endsWith('.xml')) {
|
|
261
|
+
const lastPathIndex = url.lastIndexOf('/') + 1;
|
|
262
|
+
fileName = url.substring(lastPathIndex, url.length);
|
|
263
|
+
directoryPath = url.substring(0, lastPathIndex);
|
|
264
|
+
}
|
|
265
|
+
const dir = createResourceDir(directoryPath, outputDir);
|
|
266
|
+
const localeDir = createResourceDir(directoryPath, join(outputDir, siteConfig.locale));
|
|
267
|
+
// TODO: Should we handle routes with non-html extensions differently?
|
|
268
|
+
// Example Route: "path": "/mixed_templates.md" (not sure why you would do this)
|
|
261
269
|
// "contentTemplate": "$contentDir/composed_markdown.md"
|
|
262
|
-
|
|
263
|
-
|
|
270
|
+
// Today this will get written to /mixed_templates.md/index.html
|
|
271
|
+
// Which we workaround by setting "renderSingle": true in serve.json
|
|
272
|
+
const filePath = join(dir, fileName);
|
|
273
|
+
const fileLocalePath = join(localeDir, fileName);
|
|
264
274
|
// Default Path (only write once)
|
|
265
275
|
// The default locale is english
|
|
266
276
|
if (siteConfig.locale.toLowerCase().startsWith('en')) {
|
|
@@ -566,7 +576,9 @@ export class ViewImportMetadataImpl {
|
|
|
566
576
|
*/
|
|
567
577
|
mergeImportMetadata(targetImportMetdadata, newImportMetadata) {
|
|
568
578
|
Object.assign(targetImportMetdadata.imports, newImportMetadata.imports);
|
|
569
|
-
|
|
579
|
+
if (targetImportMetdadata.index) {
|
|
580
|
+
Object.assign(targetImportMetdadata.index, newImportMetadata.index || {});
|
|
581
|
+
}
|
|
570
582
|
}
|
|
571
583
|
}
|
|
572
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.
|
|
7
|
+
"version": "0.8.0-alpha.10",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -29,43 +29,42 @@
|
|
|
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.
|
|
37
|
-
"@lwrjs/asset-registry": "0.8.0-alpha.
|
|
38
|
-
"@lwrjs/asset-transformer": "0.8.0-alpha.
|
|
39
|
-
"@lwrjs/base-template-engine": "0.8.0-alpha.
|
|
40
|
-
"@lwrjs/base-view-provider": "0.8.0-alpha.
|
|
41
|
-
"@lwrjs/base-view-transformer": "0.8.0-alpha.
|
|
42
|
-
"@lwrjs/client-modules": "0.8.0-alpha.
|
|
43
|
-
"@lwrjs/compiler": "0.8.0-alpha.
|
|
44
|
-
"@lwrjs/
|
|
45
|
-
"@lwrjs/
|
|
46
|
-
"@lwrjs/
|
|
47
|
-
"@lwrjs/
|
|
48
|
-
"@lwrjs/
|
|
49
|
-
"@lwrjs/lwc-
|
|
50
|
-
"@lwrjs/
|
|
51
|
-
"@lwrjs/
|
|
52
|
-
"@lwrjs/module-
|
|
53
|
-
"@lwrjs/
|
|
54
|
-
"@lwrjs/
|
|
55
|
-
"@lwrjs/
|
|
56
|
-
"@lwrjs/
|
|
57
|
-
"@lwrjs/
|
|
58
|
-
"@lwrjs/
|
|
59
|
-
"@lwrjs/
|
|
60
|
-
"@lwrjs/
|
|
35
|
+
"@lwrjs/app-service": "0.8.0-alpha.10",
|
|
36
|
+
"@lwrjs/asset-registry": "0.8.0-alpha.10",
|
|
37
|
+
"@lwrjs/asset-transformer": "0.8.0-alpha.10",
|
|
38
|
+
"@lwrjs/base-template-engine": "0.8.0-alpha.10",
|
|
39
|
+
"@lwrjs/base-view-provider": "0.8.0-alpha.10",
|
|
40
|
+
"@lwrjs/base-view-transformer": "0.8.0-alpha.10",
|
|
41
|
+
"@lwrjs/client-modules": "0.8.0-alpha.10",
|
|
42
|
+
"@lwrjs/compiler": "0.8.0-alpha.10",
|
|
43
|
+
"@lwrjs/config": "0.8.0-alpha.10",
|
|
44
|
+
"@lwrjs/diagnostics": "0.8.0-alpha.10",
|
|
45
|
+
"@lwrjs/fs-asset-provider": "0.8.0-alpha.10",
|
|
46
|
+
"@lwrjs/html-view-provider": "0.8.0-alpha.10",
|
|
47
|
+
"@lwrjs/loader": "0.8.0-alpha.10",
|
|
48
|
+
"@lwrjs/lwc-module-provider": "0.8.0-alpha.10",
|
|
49
|
+
"@lwrjs/lwc-ssr": "0.8.0-alpha.10",
|
|
50
|
+
"@lwrjs/markdown-view-provider": "0.8.0-alpha.10",
|
|
51
|
+
"@lwrjs/module-bundler": "0.8.0-alpha.10",
|
|
52
|
+
"@lwrjs/module-registry": "0.8.0-alpha.10",
|
|
53
|
+
"@lwrjs/npm-module-provider": "0.8.0-alpha.10",
|
|
54
|
+
"@lwrjs/nunjucks-view-provider": "0.8.0-alpha.10",
|
|
55
|
+
"@lwrjs/o11y": "0.8.0-alpha.10",
|
|
56
|
+
"@lwrjs/resource-registry": "0.8.0-alpha.10",
|
|
57
|
+
"@lwrjs/router": "0.8.0-alpha.10",
|
|
58
|
+
"@lwrjs/server": "0.8.0-alpha.10",
|
|
59
|
+
"@lwrjs/shared-utils": "0.8.0-alpha.10",
|
|
60
|
+
"@lwrjs/view-registry": "0.8.0-alpha.10",
|
|
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
64
|
"qs": "^6.9.4"
|
|
66
65
|
},
|
|
67
66
|
"devDependencies": {
|
|
68
|
-
"@lwrjs/types": "0.8.0-alpha.
|
|
67
|
+
"@lwrjs/types": "0.8.0-alpha.10"
|
|
69
68
|
},
|
|
70
69
|
"peerDependencies": {
|
|
71
70
|
"lwc": ">= 1.x <= 2.x"
|
|
@@ -73,5 +72,5 @@
|
|
|
73
72
|
"engines": {
|
|
74
73
|
"node": ">=14.15.4 <19"
|
|
75
74
|
},
|
|
76
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "55922351f484d77784d86ef7b03ebe788fa3e12c"
|
|
77
76
|
}
|