@lwrjs/core 0.9.0-alpha.12 → 0.9.0-alpha.14
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/provider.cjs +6 -4
- package/build/cjs/context/server.cjs +5 -6
- package/build/cjs/index.cjs +35 -26
- package/build/cjs/middleware/bundle-middleware.cjs +2 -2
- package/build/cjs/middleware/module-middleware.cjs +1 -1
- package/build/cjs/middleware/redirects/unsigned-module-redirect.cjs +2 -2
- package/build/cjs/middleware/utils/metadata.cjs +3 -3
- package/build/cjs/middleware/view-middleware.cjs +12 -16
- package/build/cjs/tools/server-warmup.cjs +2 -9
- package/build/cjs/tools/static-generation.cjs +108 -27
- package/build/es/context/provider.js +3 -2
- package/build/es/context/server.js +5 -5
- package/build/es/index.d.ts +0 -1
- package/build/es/index.js +45 -27
- package/build/es/middleware/bundle-middleware.js +2 -2
- package/build/es/middleware/module-middleware.js +1 -1
- package/build/es/middleware/redirects/unsigned-module-redirect.d.ts +2 -2
- package/build/es/middleware/redirects/unsigned-module-redirect.js +2 -2
- package/build/es/middleware/utils/metadata.d.ts +2 -2
- package/build/es/middleware/utils/metadata.js +3 -7
- package/build/es/middleware/view-middleware.d.ts +2 -2
- package/build/es/middleware/view-middleware.js +12 -16
- package/build/es/tools/server-warmup.js +3 -10
- package/build/es/tools/static-generation.d.ts +8 -1
- package/build/es/tools/static-generation.js +126 -29
- package/build/es/tools/types.d.ts +2 -2
- package/package.json +29 -27
- package/build/cjs/context/configurations.cjs +0 -82
- package/build/cjs/context/global-data.cjs +0 -54
- package/build/cjs/context/services.cjs +0 -50
- package/build/cjs/tools/server-build.cjs +0 -182
- package/build/es/context/configurations.d.ts +0 -9
- package/build/es/context/configurations.js +0 -53
- package/build/es/context/global-data.d.ts +0 -3
- package/build/es/context/global-data.js +0 -29
- package/build/es/context/services.d.ts +0 -3
- package/build/es/context/services.js +0 -27
- package/build/es/tools/server-build.d.ts +0 -14
- package/build/es/tools/server-build.js +0 -182
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { performance } from 'perf_hooks';
|
|
2
|
-
import { getSpecifier, getFeatureFlags, hashContent, isSelfUrl, getModuleUriPrefix, getMappingUriPrefix, logger, WARN, INFO, } from '@lwrjs/shared-utils';
|
|
2
|
+
import { getSpecifier, getFeatureFlags, hashContent, isSelfUrl, getModuleUriPrefix, getMappingUriPrefix, logger, WARN, INFO, SiteMetadataImpl, isExternalUrl, } 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';
|
|
6
6
|
import { createDir, createResourceDir } from './utils/dir.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getRuntimeEnvironment } from '@lwrjs/config';
|
|
8
8
|
export default class SiteGenerator {
|
|
9
9
|
/**
|
|
10
10
|
* Build a static site in the configured directory
|
|
@@ -16,7 +16,7 @@ export default class SiteGenerator {
|
|
|
16
16
|
*/
|
|
17
17
|
async buildStaticApplication(config, dispatcher) {
|
|
18
18
|
const startTime = performance.now();
|
|
19
|
-
logger.info('[Static Generation
|
|
19
|
+
logger.info('[SSG] Static Site Generation');
|
|
20
20
|
// De-duplicate warming messages if log level is warn or info
|
|
21
21
|
if (!logger.currentLevel || logger.currentLevel == WARN || logger.currentLevel == INFO) {
|
|
22
22
|
logger.setOptions({ dedupe: new Set([WARN]) });
|
|
@@ -26,18 +26,16 @@ export default class SiteGenerator {
|
|
|
26
26
|
staticSiteGenerator.outputDir = '__generated_site__';
|
|
27
27
|
}
|
|
28
28
|
const outputDir = join(rootDir, staticSiteGenerator.outputDir);
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
if (!staticSiteGenerator.skipCleanOutputDir) {
|
|
30
|
+
logger.info(`[SSG] Clearing output directory: ${outputDir}`);
|
|
31
|
+
fs.rmSync(outputDir, { recursive: true, force: true });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
logger.info(`[SSG] Reusing existing output directory: ${outputDir}`);
|
|
35
|
+
}
|
|
31
36
|
const urlRewriteMap = new Map();
|
|
32
|
-
const {
|
|
33
|
-
const runtimeEnvironment =
|
|
34
|
-
...explodeMode(serverMode),
|
|
35
|
-
apiVersion,
|
|
36
|
-
basePath,
|
|
37
|
-
lwrVersion,
|
|
38
|
-
debug: false,
|
|
39
|
-
serverMode,
|
|
40
|
-
};
|
|
37
|
+
const { basePath } = config;
|
|
38
|
+
const runtimeEnvironment = getRuntimeEnvironment(config);
|
|
41
39
|
// For each locale, generate all the modules
|
|
42
40
|
await this.generateRoutes(runtimeEnvironment, staticSiteGenerator, routes, basePath, dispatcher, outputDir, urlRewriteMap);
|
|
43
41
|
// Write redirect files
|
|
@@ -46,7 +44,7 @@ export default class SiteGenerator {
|
|
|
46
44
|
this.copyAssets(assets, outputDir, basePath);
|
|
47
45
|
const endTime = performance.now();
|
|
48
46
|
const timeDiff = (endTime - startTime) / 1000;
|
|
49
|
-
logger.info(`[Static Generation
|
|
47
|
+
logger.info(`[SSG] Static Site Generation complete in ${Math.round(timeDiff)} seconds`);
|
|
50
48
|
}
|
|
51
49
|
/**
|
|
52
50
|
* Crawl all view routes for a site
|
|
@@ -77,9 +75,17 @@ export default class SiteGenerator {
|
|
|
77
75
|
const { _additionalModules } = staticSiteGenerator;
|
|
78
76
|
if (_additionalModules) {
|
|
79
77
|
for (const specifier of _additionalModules) {
|
|
78
|
+
logger.debug(`[SSG] Additional Module: ${locale} ${specifier}`);
|
|
79
|
+
const startTime = performance.now();
|
|
80
80
|
const siteConfig = this.createSiteConfig(outputDir, locale, urlRewriteMap, skipBaseDocumentGeneration, runtimeEnvironment);
|
|
81
81
|
// eslint-disable-next-line no-await-in-loop
|
|
82
82
|
await this.dispatchJSResourceRecursive(specifier, dispatcher, siteConfig, true);
|
|
83
|
+
// Capture any additional collected metadata
|
|
84
|
+
// eslint-disable-next-line no-await-in-loop
|
|
85
|
+
await this.captureAdditionalRouteMetadata(siteConfig);
|
|
86
|
+
const endTime = performance.now();
|
|
87
|
+
const timeDiff = endTime - startTime;
|
|
88
|
+
logger.info(`[SSG] Additional Module ${locale} ${specifier} in ${Math.round(timeDiff)} ms`);
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
91
|
}
|
|
@@ -90,9 +96,16 @@ export default class SiteGenerator {
|
|
|
90
96
|
// The lwc_ssr_placeholder will be replaced with a root component specifier at SSR time
|
|
91
97
|
const willSSR = routes.some((r) => r.bootstrap?.ssr);
|
|
92
98
|
if (willSSR) {
|
|
99
|
+
logger.debug(`[SSG] Fetch SSR Placeholder`);
|
|
100
|
+
const startTime = performance.now();
|
|
93
101
|
const siteConfig = this.createSiteConfig(outputDir, staticSiteGenerator.locales[0], // locale is unused in this bundle
|
|
94
102
|
urlRewriteMap, skipBaseDocumentGeneration, runtimeEnvironment);
|
|
95
103
|
await this.dispatchJSResourceRecursive('@lwrjs/lwc-ssr/lwc_ssr_placeholder', dispatcher, siteConfig, true);
|
|
104
|
+
// Capture any additional collected metadata
|
|
105
|
+
await this.captureAdditionalRouteMetadata(siteConfig);
|
|
106
|
+
const endTime = performance.now();
|
|
107
|
+
const timeDiff = endTime - startTime;
|
|
108
|
+
logger.info(`[SSG] SSR Placeholder in ${Math.round(timeDiff)} ms`);
|
|
96
109
|
}
|
|
97
110
|
}
|
|
98
111
|
/**
|
|
@@ -101,12 +114,15 @@ export default class SiteGenerator {
|
|
|
101
114
|
createGenerateURLFunction(dispatcher) {
|
|
102
115
|
const generateRoute = async (uri, siteConfig) => {
|
|
103
116
|
const locale = siteConfig.locale;
|
|
104
|
-
logger.
|
|
117
|
+
logger.debug(`[SSG] Start Generate: ${locale} ${uri}`);
|
|
118
|
+
const startTime = performance.now();
|
|
105
119
|
// Kick off site generation for the current route
|
|
106
120
|
await this.dispatchResourceRecursive(uri, dispatcher, { resourceType: 'route' }, siteConfig);
|
|
107
|
-
//
|
|
108
|
-
this.
|
|
109
|
-
|
|
121
|
+
// Capture any additional route metadata
|
|
122
|
+
await this.captureAdditionalRouteMetadata(siteConfig);
|
|
123
|
+
const endTime = performance.now();
|
|
124
|
+
const timeDiff = endTime - startTime;
|
|
125
|
+
logger.info(`[SSG] ${locale} ${uri} in ${Math.round(timeDiff)} ms`);
|
|
110
126
|
};
|
|
111
127
|
return generateRoute.bind(this);
|
|
112
128
|
}
|
|
@@ -122,10 +138,15 @@ export default class SiteGenerator {
|
|
|
122
138
|
const { visitedUrls } = siteConfig;
|
|
123
139
|
if (!visitedUrls.has(url)) {
|
|
124
140
|
visitedUrls.add(url); // Maintain a list of visited urls here to avoid potential infinite loops
|
|
141
|
+
// Skip remote urls (i.e. http://) the static view would call the remote url at runtime
|
|
142
|
+
if (isExternalUrl(url)) {
|
|
143
|
+
logger.warn('[SSG] Skipped generation of external url: ' + url);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
125
146
|
// Skip urls with path segment variables (i.e. '/custom/:bar')
|
|
126
147
|
// Users can specify specific urls via the '_additionalRoutePaths' config property
|
|
127
148
|
if (url.indexOf('/:') !== -1 || url.indexOf('*') !== -1) {
|
|
128
|
-
logger.warn('Skipped generation of url with variable path segment: ' + url);
|
|
149
|
+
logger.warn('[SSG] Skipped generation of url with variable path segment: ' + url);
|
|
129
150
|
return;
|
|
130
151
|
}
|
|
131
152
|
// Generate resource
|
|
@@ -212,6 +233,10 @@ export default class SiteGenerator {
|
|
|
212
233
|
: getSpecifier(importModule);
|
|
213
234
|
dispatchRequests.push(this.dispatchJSResourceRecursive(jsUri, dispatcher, siteConfig));
|
|
214
235
|
}
|
|
236
|
+
// If this is a bundle add it to the bundle metadata
|
|
237
|
+
if (moduleDefinition.bundleRecord) {
|
|
238
|
+
this.addBundleToSiteMetadata(moduleDefinition, url, siteConfig);
|
|
239
|
+
}
|
|
215
240
|
}
|
|
216
241
|
// Bundles with unresolved module uris
|
|
217
242
|
const uris = context.fs?.metadata?.resolvedUris || [];
|
|
@@ -221,6 +246,54 @@ export default class SiteGenerator {
|
|
|
221
246
|
// -- Dispatch dependencies
|
|
222
247
|
await Promise.all(dispatchRequests);
|
|
223
248
|
}
|
|
249
|
+
addBundleToSiteMetadata(bundleDefinition, url, siteConfig) {
|
|
250
|
+
if (siteConfig.siteMetadata) {
|
|
251
|
+
const specifier = bundleDefinition.specifier;
|
|
252
|
+
const imports = bundleDefinition.bundleRecord.imports?.map((moduleRef) => moduleRef.specifier) || [];
|
|
253
|
+
const bundleMetadata = {
|
|
254
|
+
version: bundleDefinition.version,
|
|
255
|
+
path: decodeURIComponent(url),
|
|
256
|
+
bundleRecord: {
|
|
257
|
+
includedModules: bundleDefinition.bundleRecord.includedModules || [],
|
|
258
|
+
imports,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
const siteBundles = siteConfig.siteMetadata.getSiteBundles().bundles;
|
|
262
|
+
siteBundles[specifier] = bundleMetadata;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
addResourceToSiteMetadata(resourceDefinition, url, siteConfig) {
|
|
266
|
+
if (siteConfig.siteMetadata) {
|
|
267
|
+
if (!resourceDefinition.specifier) {
|
|
268
|
+
logger.warn('[SSG] Could not save resource metadata. There was no specifier.', resourceDefinition);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
const specifier = resourceDefinition.specifier;
|
|
272
|
+
const resourceMetadata = {
|
|
273
|
+
path: decodeURIComponent(url),
|
|
274
|
+
mimeType: resourceDefinition.type,
|
|
275
|
+
};
|
|
276
|
+
const siteResources = siteConfig.siteMetadata.getSiteResources();
|
|
277
|
+
siteResources.resources[specifier] = resourceMetadata;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
addAssetToSiteMetadata(assetDefinition, url, siteConfig) {
|
|
282
|
+
if (siteConfig.siteMetadata) {
|
|
283
|
+
if (!assetDefinition.uri) {
|
|
284
|
+
logger.warn('[SSG] Could not save asset metadata. There was no uri.', assetDefinition);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
const specifier = assetDefinition.uri;
|
|
288
|
+
const resourceMetadata = {
|
|
289
|
+
path: decodeURIComponent(url),
|
|
290
|
+
mimeType: String(assetDefinition.mime),
|
|
291
|
+
};
|
|
292
|
+
const siteAssets = siteConfig.siteMetadata.getSiteAssets();
|
|
293
|
+
siteAssets.assets[specifier] = resourceMetadata;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
224
297
|
/**
|
|
225
298
|
* Handle processing a returned module URI mapping resource and follow all returned references
|
|
226
299
|
* @param url - URL of the request mapping resource
|
|
@@ -256,7 +329,7 @@ export default class SiteGenerator {
|
|
|
256
329
|
}
|
|
257
330
|
else {
|
|
258
331
|
const body = context.fs?.body;
|
|
259
|
-
logger.warn(`Failed to fetch ${url}: (${statusCode}) ${body}`);
|
|
332
|
+
logger.warn(`[SSG] Failed to fetch ${url}: (${statusCode}) ${body}`);
|
|
260
333
|
}
|
|
261
334
|
}
|
|
262
335
|
/**
|
|
@@ -359,7 +432,7 @@ export default class SiteGenerator {
|
|
|
359
432
|
}
|
|
360
433
|
}
|
|
361
434
|
else {
|
|
362
|
-
logger.warn('Skipped inline bootstrap resource: %j', resource);
|
|
435
|
+
logger.warn('[SSG] Skipped inline bootstrap resource: %j', resource);
|
|
363
436
|
}
|
|
364
437
|
}
|
|
365
438
|
}
|
|
@@ -371,7 +444,7 @@ export default class SiteGenerator {
|
|
|
371
444
|
dispatchRequests.push(this.dispatchResourceRecursive(resourceUri, dispatcher, { resourceType: 'resource' }, siteConfig));
|
|
372
445
|
}
|
|
373
446
|
else {
|
|
374
|
-
logger.warn('Skipped resource: %j', resource);
|
|
447
|
+
logger.warn('[SSG] Skipped resource: %j', resource);
|
|
375
448
|
}
|
|
376
449
|
}
|
|
377
450
|
// -- Dispatch dependencies
|
|
@@ -391,7 +464,7 @@ export default class SiteGenerator {
|
|
|
391
464
|
await this.dispatchResourceRecursive(mappingURL, dispatcher, { resourceType: 'mapping' }, siteConfig);
|
|
392
465
|
}
|
|
393
466
|
else {
|
|
394
|
-
logger.warn('Unable to fetch mapping for bare specifier or variable dynamic import: "' +
|
|
467
|
+
logger.warn('[SSG] Unable to fetch mapping for bare specifier or variable dynamic import: "' +
|
|
395
468
|
jsUri +
|
|
396
469
|
'"');
|
|
397
470
|
}
|
|
@@ -416,6 +489,14 @@ export default class SiteGenerator {
|
|
|
416
489
|
const metadata = context.fs?.metadata;
|
|
417
490
|
const fullPath = this.getResourcePathFromUrl(siteConfig, url);
|
|
418
491
|
await writeResponse(context, fullPath);
|
|
492
|
+
// Save Metadata
|
|
493
|
+
// If resource add to resource metadata
|
|
494
|
+
if (metadata?.resource) {
|
|
495
|
+
this.addResourceToSiteMetadata(metadata?.resource, url, siteConfig);
|
|
496
|
+
}
|
|
497
|
+
else if (metadata?.asset) {
|
|
498
|
+
this.addAssetToSiteMetadata(metadata?.asset, url, siteConfig);
|
|
499
|
+
}
|
|
419
500
|
// Call and referenced assets...
|
|
420
501
|
const assetReferences = metadata?.asset?.metadata?.assetReferences || [];
|
|
421
502
|
const dispatchRequests = [];
|
|
@@ -423,7 +504,7 @@ export default class SiteGenerator {
|
|
|
423
504
|
const refUrl = ref.override?.uri || ref.url;
|
|
424
505
|
dispatchRequests.push(this.dispatchResourceRecursive(refUrl, dispatcher, { resourceType: 'asset', asset: metadata?.asset }, siteConfig).catch((err) => {
|
|
425
506
|
// Warn the user that the we failed to fetch a referenced asset
|
|
426
|
-
logger.warn(`Failed to fetch asset reference => ${refUrl} from ${url}`, err);
|
|
507
|
+
logger.warn(`[SSG] Failed to fetch asset reference => ${refUrl} from ${url}`, err);
|
|
427
508
|
}));
|
|
428
509
|
}
|
|
429
510
|
return Promise.all(dispatchRequests);
|
|
@@ -481,11 +562,11 @@ export default class SiteGenerator {
|
|
|
481
562
|
fs.copySync(assetSrcDir, assetOutputDir);
|
|
482
563
|
}
|
|
483
564
|
else {
|
|
484
|
-
logger.warn('Could not find assets to copy at path: ' + assetSrcDir);
|
|
565
|
+
logger.warn('[SSG] Could not find assets to copy at path: ' + assetSrcDir);
|
|
485
566
|
}
|
|
486
567
|
}
|
|
487
568
|
catch (e) {
|
|
488
|
-
logger.error('Error occurred processing asset config: ' + JSON.stringify(asset), e);
|
|
569
|
+
logger.error('[SSG] Error occurred processing asset config: ' + JSON.stringify(asset), e);
|
|
489
570
|
}
|
|
490
571
|
}
|
|
491
572
|
}
|
|
@@ -511,12 +592,19 @@ export default class SiteGenerator {
|
|
|
511
592
|
skipBaseDocumentGeneration,
|
|
512
593
|
// Only include LEGACY_LOADER if true
|
|
513
594
|
...featureFlags,
|
|
595
|
+
siteMetadata: new SiteMetadataImpl({ rootDir: outputDir, runtimeEnvironment }),
|
|
514
596
|
};
|
|
515
597
|
}
|
|
516
598
|
filterFeatureFlags() {
|
|
517
599
|
const ffs = getFeatureFlags();
|
|
518
|
-
if (ffs.
|
|
519
|
-
|
|
600
|
+
if (ffs && Object.keys(ffs).length) {
|
|
601
|
+
const accumlator = {};
|
|
602
|
+
for (const [key, value] of Object.entries(ffs)) {
|
|
603
|
+
if (value) {
|
|
604
|
+
accumlator[key] = true;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return { featureFlags: accumlator };
|
|
520
608
|
}
|
|
521
609
|
else {
|
|
522
610
|
return undefined;
|
|
@@ -562,6 +650,15 @@ export default class SiteGenerator {
|
|
|
562
650
|
});
|
|
563
651
|
}
|
|
564
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* Capure additional metadata collected during the processing of a route or additional module
|
|
655
|
+
*/
|
|
656
|
+
async captureAdditionalRouteMetadata(siteConfig) {
|
|
657
|
+
// If there is a view config add any extra collected import metadata to the config
|
|
658
|
+
this.addAdditionalImportMetadataToViewConfig(siteConfig);
|
|
659
|
+
// Save site meta data
|
|
660
|
+
await siteConfig.siteMetadata?.persistSiteMetadata();
|
|
661
|
+
}
|
|
565
662
|
}
|
|
566
663
|
// Class used to track import metadata for a view
|
|
567
664
|
export class ViewImportMetadataImpl {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Endpoints, FeatureFlags, ImportMetadata } from '@lwrjs/types';
|
|
2
|
-
import { RenderedAssetReference } from '@lwrjs/types';
|
|
1
|
+
import type { Endpoints, FeatureFlags, ImportMetadata, RenderedAssetReference, SiteMetadata } from '@lwrjs/types';
|
|
3
2
|
export interface BaseResourceContextOpts {
|
|
4
3
|
resourceType: 'route' | 'asset' | 'js' | 'resource' | 'mapping';
|
|
5
4
|
}
|
|
@@ -44,5 +43,6 @@ export interface SiteConfig {
|
|
|
44
43
|
featureFlags?: FeatureFlags;
|
|
45
44
|
legacyDefaultMappingEndpoint?: string;
|
|
46
45
|
skipBaseDocumentGeneration?: boolean;
|
|
46
|
+
siteMetadata?: SiteMetadata;
|
|
47
47
|
}
|
|
48
48
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.9.0-alpha.
|
|
7
|
+
"version": "0.9.0-alpha.14",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -36,38 +36,40 @@
|
|
|
36
36
|
"package.cjs"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@lwrjs/
|
|
41
|
-
"@lwrjs/asset-
|
|
42
|
-
"@lwrjs/
|
|
43
|
-
"@lwrjs/base-view-
|
|
44
|
-
"@lwrjs/
|
|
45
|
-
"@lwrjs/
|
|
46
|
-
"@lwrjs/config": "0.9.0-alpha.
|
|
47
|
-
"@lwrjs/diagnostics": "0.9.0-alpha.
|
|
48
|
-
"@lwrjs/fs-asset-provider": "0.9.0-alpha.
|
|
49
|
-
"@lwrjs/html-view-provider": "0.9.0-alpha.
|
|
50
|
-
"@lwrjs/loader": "0.9.0-alpha.
|
|
51
|
-
"@lwrjs/lwc-module-provider": "0.9.0-alpha.
|
|
52
|
-
"@lwrjs/markdown-view-provider": "0.9.0-alpha.
|
|
53
|
-
"@lwrjs/module-bundler": "0.9.0-alpha.
|
|
54
|
-
"@lwrjs/module-registry": "0.9.0-alpha.
|
|
55
|
-
"@lwrjs/npm-module-provider": "0.9.0-alpha.
|
|
56
|
-
"@lwrjs/nunjucks-view-provider": "0.9.0-alpha.
|
|
57
|
-
"@lwrjs/o11y": "0.9.0-alpha.
|
|
58
|
-
"@lwrjs/resource-registry": "0.9.0-alpha.
|
|
59
|
-
"@lwrjs/router": "0.9.0-alpha.
|
|
60
|
-
"@lwrjs/server": "0.9.0-alpha.
|
|
61
|
-
"@lwrjs/shared-utils": "0.9.0-alpha.
|
|
62
|
-
"@lwrjs/view-registry": "0.9.0-alpha.
|
|
39
|
+
"@locker/compiler": "0.18.2",
|
|
40
|
+
"@lwrjs/app-service": "0.9.0-alpha.14",
|
|
41
|
+
"@lwrjs/asset-registry": "0.9.0-alpha.14",
|
|
42
|
+
"@lwrjs/asset-transformer": "0.9.0-alpha.14",
|
|
43
|
+
"@lwrjs/base-view-provider": "0.9.0-alpha.14",
|
|
44
|
+
"@lwrjs/base-view-transformer": "0.9.0-alpha.14",
|
|
45
|
+
"@lwrjs/client-modules": "0.9.0-alpha.14",
|
|
46
|
+
"@lwrjs/config": "0.9.0-alpha.14",
|
|
47
|
+
"@lwrjs/diagnostics": "0.9.0-alpha.14",
|
|
48
|
+
"@lwrjs/fs-asset-provider": "0.9.0-alpha.14",
|
|
49
|
+
"@lwrjs/html-view-provider": "0.9.0-alpha.14",
|
|
50
|
+
"@lwrjs/loader": "0.9.0-alpha.14",
|
|
51
|
+
"@lwrjs/lwc-module-provider": "0.9.0-alpha.14",
|
|
52
|
+
"@lwrjs/markdown-view-provider": "0.9.0-alpha.14",
|
|
53
|
+
"@lwrjs/module-bundler": "0.9.0-alpha.14",
|
|
54
|
+
"@lwrjs/module-registry": "0.9.0-alpha.14",
|
|
55
|
+
"@lwrjs/npm-module-provider": "0.9.0-alpha.14",
|
|
56
|
+
"@lwrjs/nunjucks-view-provider": "0.9.0-alpha.14",
|
|
57
|
+
"@lwrjs/o11y": "0.9.0-alpha.14",
|
|
58
|
+
"@lwrjs/resource-registry": "0.9.0-alpha.14",
|
|
59
|
+
"@lwrjs/router": "0.9.0-alpha.14",
|
|
60
|
+
"@lwrjs/server": "0.9.0-alpha.14",
|
|
61
|
+
"@lwrjs/shared-utils": "0.9.0-alpha.14",
|
|
62
|
+
"@lwrjs/view-registry": "0.9.0-alpha.14",
|
|
63
|
+
"chokidar": "^3.5.3",
|
|
63
64
|
"esbuild": "^0.9.7",
|
|
64
65
|
"fs-extra": "^10.1.0",
|
|
65
66
|
"path-to-regexp": "^6.2.0",
|
|
66
67
|
"qs": "^6.9.4",
|
|
68
|
+
"rollup": "~2.45.2",
|
|
67
69
|
"ws": "^8.8.1"
|
|
68
70
|
},
|
|
69
71
|
"devDependencies": {
|
|
70
|
-
"@lwrjs/types": "0.9.0-alpha.
|
|
72
|
+
"@lwrjs/types": "0.9.0-alpha.14",
|
|
71
73
|
"@types/ws": "^8.5.3"
|
|
72
74
|
},
|
|
73
75
|
"peerDependencies": {
|
|
@@ -76,5 +78,5 @@
|
|
|
76
78
|
"engines": {
|
|
77
79
|
"node": ">=14.15.4 <19"
|
|
78
80
|
},
|
|
79
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "64e0ba617151429da6e09f1a9686628f64183d25"
|
|
80
82
|
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
-
};
|
|
12
|
-
var __exportStar = (target, module2, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// packages/@lwrjs/core/src/context/configurations.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
|
-
__export(exports, {
|
|
27
|
-
resolveConfigurations: () => resolveConfigurations
|
|
28
|
-
});
|
|
29
|
-
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
30
|
-
var import_config = __toModule(require("@lwrjs/config"));
|
|
31
|
-
var import_global_data = __toModule(require("./global-data.cjs"));
|
|
32
|
-
var import_services = __toModule(require("./services.cjs"));
|
|
33
|
-
function normalizeRoutesBootstrap({routes, errorRoutes}) {
|
|
34
|
-
[...routes, ...errorRoutes].forEach((route) => {
|
|
35
|
-
if (!route.bootstrap) {
|
|
36
|
-
route.bootstrap = {...import_shared_utils.DEFAULT_LWR_BOOTSTRAP_CONFIG};
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async function runConfigurationsHook(hookPlugins, appConfig, globalData, runtimeEnvironment) {
|
|
41
|
-
for (const hookPlugin of hookPlugins) {
|
|
42
|
-
await hookPlugin.initConfigs(appConfig, globalData, runtimeEnvironment);
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
(0, import_config.validateLwrAppConfig)(JSON.stringify(appConfig), "post");
|
|
46
|
-
} catch (e) {
|
|
47
|
-
if (process.env.UNSAFE_IGNORE_CONFIG_VALIDATION === "true") {
|
|
48
|
-
import_shared_utils.logger.warn("ignoring config validation errors due to UNSAFE_IGNORE_CONFIG_VALIDATION flag...proceed with caution");
|
|
49
|
-
console.dir(e, {depth: null});
|
|
50
|
-
} else {
|
|
51
|
-
throw e;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
normalizeRoutesBootstrap(appConfig);
|
|
55
|
-
return {
|
|
56
|
-
appConfig,
|
|
57
|
-
globalData,
|
|
58
|
-
runtimeEnvironment
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
async function resolveConfigurations(config) {
|
|
62
|
-
const {
|
|
63
|
-
apiVersion,
|
|
64
|
-
basePath,
|
|
65
|
-
lwrVersion,
|
|
66
|
-
serverMode,
|
|
67
|
-
globalDataDir,
|
|
68
|
-
globalData: globalDataConfig
|
|
69
|
-
} = config;
|
|
70
|
-
const globalData = (0, import_global_data.getGlobalData)(globalDataDir, globalDataConfig);
|
|
71
|
-
const runtimeEnvironment = {
|
|
72
|
-
...(0, import_config.explodeMode)(serverMode),
|
|
73
|
-
apiVersion,
|
|
74
|
-
basePath,
|
|
75
|
-
lwrVersion,
|
|
76
|
-
debug: false,
|
|
77
|
-
serverMode,
|
|
78
|
-
featureFlags: (0, import_shared_utils.getFeatureFlags)()
|
|
79
|
-
};
|
|
80
|
-
const hookProviders = await (0, import_services.getServices)(config.hooks, void 0, config);
|
|
81
|
-
return runConfigurationsHook(hookProviders, config, globalData, runtimeEnvironment);
|
|
82
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
-
};
|
|
12
|
-
var __exportStar = (target, module2, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// packages/@lwrjs/core/src/context/global-data.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
|
-
__export(exports, {
|
|
27
|
-
getGlobalData: () => getGlobalData
|
|
28
|
-
});
|
|
29
|
-
var import_fs = __toModule(require("fs"));
|
|
30
|
-
var import_path = __toModule(require("path"));
|
|
31
|
-
function recursiveJsonCollector(resources, currentPath, collector) {
|
|
32
|
-
for (const resource of resources) {
|
|
33
|
-
const resourcePath = import_path.default.join(currentPath, resource);
|
|
34
|
-
if (resource.endsWith(".json")) {
|
|
35
|
-
const resourceName = import_path.default.basename(resource, ".json");
|
|
36
|
-
const jsonSource = JSON.parse(import_fs.default.readFileSync(resourcePath, "utf-8"));
|
|
37
|
-
collector[resourceName] = jsonSource;
|
|
38
|
-
} else if (import_fs.default.statSync(resourcePath).isDirectory()) {
|
|
39
|
-
const dirContentList = import_fs.default.readdirSync(resourcePath);
|
|
40
|
-
collector[resource] = recursiveJsonCollector(dirContentList, resourcePath, {});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return collector;
|
|
44
|
-
}
|
|
45
|
-
function getGlobalData(globalDataDir, defaultData = {}) {
|
|
46
|
-
if (!import_fs.default.existsSync(globalDataDir) || !import_fs.default.statSync(globalDataDir).isDirectory()) {
|
|
47
|
-
return defaultData;
|
|
48
|
-
}
|
|
49
|
-
const dirContentList = import_fs.default.readdirSync(globalDataDir);
|
|
50
|
-
return {
|
|
51
|
-
...recursiveJsonCollector(dirContentList, globalDataDir, {}),
|
|
52
|
-
...defaultData
|
|
53
|
-
};
|
|
54
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
-
};
|
|
12
|
-
var __exportStar = (target, module2, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// packages/@lwrjs/core/src/context/services.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
|
-
__export(exports, {
|
|
27
|
-
getServices: () => getServices
|
|
28
|
-
});
|
|
29
|
-
var import_path = __toModule(require("path"));
|
|
30
|
-
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
31
|
-
async function getServiceModule(path, {cacheDir, rootDir}) {
|
|
32
|
-
try {
|
|
33
|
-
if (path.endsWith(".ts")) {
|
|
34
|
-
const fullPath = (0, import_shared_utils.resolveFileExtension)(path);
|
|
35
|
-
path = await (0, import_shared_utils.transpileTs)(fullPath, {rootDir, cacheDir: import_path.default.join(cacheDir, "services")});
|
|
36
|
-
}
|
|
37
|
-
const moduleEntry = await Promise.resolve().then(() => __toModule(require(path)));
|
|
38
|
-
return moduleEntry.default || moduleEntry;
|
|
39
|
-
} catch (err) {
|
|
40
|
-
console.log(err);
|
|
41
|
-
throw new Error(`Unable to get Service: ${path}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function getServices(services, providerContext, lwrConfig) {
|
|
45
|
-
return Promise.all(services.map(async (serviceEntry) => {
|
|
46
|
-
const [serviceName, serviceConfig = {}] = Array.isArray(serviceEntry) ? serviceEntry : [serviceEntry];
|
|
47
|
-
const ServiceCtor = await getServiceModule(serviceName, lwrConfig);
|
|
48
|
-
return new ServiceCtor(serviceConfig, providerContext);
|
|
49
|
-
}));
|
|
50
|
-
}
|