@lwrjs/core 0.8.0-alpha.11 → 0.8.0-alpha.12
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.
|
@@ -342,7 +342,7 @@ function apiMiddleware(app, context) {
|
|
|
342
342
|
const specifier = req.params[0] ? `/${req.params[0]}` : req.originalUrl;
|
|
343
343
|
const basePathSpecifier = `${basePath}${specifier}`;
|
|
344
344
|
try {
|
|
345
|
-
const assetObj = await context.assetRegistry.getAsset({specifier: basePathSpecifier, signature, type}, runtimeEnvironment);
|
|
345
|
+
const assetObj = await context.assetRegistry.getAsset({specifier: basePathSpecifier, signature, type}, runtimeEnvironment, req.isSiteGeneration());
|
|
346
346
|
if (immutable) {
|
|
347
347
|
}
|
|
348
348
|
if (assetObj.mime) {
|
|
@@ -117,7 +117,7 @@ var SiteGenerator = class {
|
|
|
117
117
|
if (resourceType === "route") {
|
|
118
118
|
await this.handleHtmlResource(url, context, siteConfig, dispatcher);
|
|
119
119
|
} else if (resourceType === "asset" || resourceType === "resource") {
|
|
120
|
-
await this.handleAssetOrResource(url, context, siteConfig);
|
|
120
|
+
await this.handleAssetOrResource(url, context, siteConfig, dispatcher);
|
|
121
121
|
} else if (resourceType == "mapping") {
|
|
122
122
|
await this.handleMappingResource(url, context, siteConfig, dispatcher);
|
|
123
123
|
} else if (resourceType === "js") {
|
|
@@ -274,9 +274,16 @@ var SiteGenerator = class {
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
async handleAssetOrResource(url, context, siteConfig) {
|
|
277
|
+
async handleAssetOrResource(url, context, siteConfig, dispatcher) {
|
|
278
|
+
const metadata = context.fs?.metadata;
|
|
278
279
|
const fullPath = this.getResourcePathFromUrl(siteConfig, url);
|
|
279
280
|
await (0, import_stream.writeResponse)(context, fullPath);
|
|
281
|
+
const assetReferences = metadata?.asset?.metadata?.assetReferences || [];
|
|
282
|
+
const dispatchRequests = [];
|
|
283
|
+
for (const ref of assetReferences) {
|
|
284
|
+
dispatchRequests.push(this.dispatchResourceRecursive(ref.override?.uri || ref.url, dispatcher, {resourceType: "asset", asset: metadata?.asset}, siteConfig));
|
|
285
|
+
}
|
|
286
|
+
return Promise.all(dispatchRequests);
|
|
280
287
|
}
|
|
281
288
|
getResourcePathFromUrl(siteConfig, url) {
|
|
282
289
|
const {outputDir} = siteConfig;
|
|
@@ -390,7 +390,7 @@ export default function apiMiddleware(app, context) {
|
|
|
390
390
|
const specifier = req.params[0] ? `/${req.params[0]}` : req.originalUrl;
|
|
391
391
|
const basePathSpecifier = `${basePath}${specifier}`;
|
|
392
392
|
try {
|
|
393
|
-
const assetObj = await context.assetRegistry.getAsset({ specifier: basePathSpecifier, signature, type: type }, runtimeEnvironment);
|
|
393
|
+
const assetObj = await context.assetRegistry.getAsset({ specifier: basePathSpecifier, signature, type: type }, runtimeEnvironment, req.isSiteGeneration());
|
|
394
394
|
if (immutable) {
|
|
395
395
|
// WIP: ?
|
|
396
396
|
}
|
|
@@ -129,7 +129,7 @@ export default class SiteGenerator {
|
|
|
129
129
|
// -- Process Assets (css, images, ...) && Resources (lwr-loader-shim ...)
|
|
130
130
|
}
|
|
131
131
|
else if (resourceType === 'asset' || resourceType === 'resource') {
|
|
132
|
-
await this.handleAssetOrResource(url, context, siteConfig);
|
|
132
|
+
await this.handleAssetOrResource(url, context, siteConfig, dispatcher);
|
|
133
133
|
// -- Import Metadata Mappings
|
|
134
134
|
}
|
|
135
135
|
else if (resourceType == 'mapping') {
|
|
@@ -394,9 +394,17 @@ export default class SiteGenerator {
|
|
|
394
394
|
* @param context - Response Context
|
|
395
395
|
* @param siteConfig - Global metadata about the site
|
|
396
396
|
*/
|
|
397
|
-
async handleAssetOrResource(url, context, siteConfig) {
|
|
397
|
+
async handleAssetOrResource(url, context, siteConfig, dispatcher) {
|
|
398
|
+
const metadata = context.fs?.metadata;
|
|
398
399
|
const fullPath = this.getResourcePathFromUrl(siteConfig, url);
|
|
399
400
|
await writeResponse(context, fullPath);
|
|
401
|
+
// Call and referenced assets...
|
|
402
|
+
const assetReferences = metadata?.asset?.metadata?.assetReferences || [];
|
|
403
|
+
const dispatchRequests = [];
|
|
404
|
+
for (const ref of assetReferences) {
|
|
405
|
+
dispatchRequests.push(this.dispatchResourceRecursive(ref.override?.uri || ref.url, dispatcher, { resourceType: 'asset', asset: metadata?.asset }, siteConfig));
|
|
406
|
+
}
|
|
407
|
+
return Promise.all(dispatchRequests);
|
|
400
408
|
}
|
|
401
409
|
getResourcePathFromUrl(siteConfig, url) {
|
|
402
410
|
const { outputDir } = siteConfig;
|
|
@@ -8,7 +8,7 @@ export interface RouteResourceOpts extends BaseResourceContextOpts {
|
|
|
8
8
|
}
|
|
9
9
|
export interface AssetResourceOpts extends BaseResourceContextOpts {
|
|
10
10
|
resourceType: 'asset';
|
|
11
|
-
asset
|
|
11
|
+
asset?: RenderedAssetReference;
|
|
12
12
|
}
|
|
13
13
|
export interface JsResourceOpts extends BaseResourceContextOpts {
|
|
14
14
|
resourceType: 'js';
|
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.12",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -32,32 +32,32 @@
|
|
|
32
32
|
"package.cjs"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@lwrjs/app-service": "0.8.0-alpha.
|
|
36
|
-
"@lwrjs/asset-registry": "0.8.0-alpha.
|
|
37
|
-
"@lwrjs/asset-transformer": "0.8.0-alpha.
|
|
38
|
-
"@lwrjs/base-template-engine": "0.8.0-alpha.
|
|
39
|
-
"@lwrjs/base-view-provider": "0.8.0-alpha.
|
|
40
|
-
"@lwrjs/base-view-transformer": "0.8.0-alpha.
|
|
41
|
-
"@lwrjs/client-modules": "0.8.0-alpha.
|
|
42
|
-
"@lwrjs/compiler": "0.8.0-alpha.
|
|
43
|
-
"@lwrjs/config": "0.8.0-alpha.
|
|
44
|
-
"@lwrjs/diagnostics": "0.8.0-alpha.
|
|
45
|
-
"@lwrjs/fs-asset-provider": "0.8.0-alpha.
|
|
46
|
-
"@lwrjs/html-view-provider": "0.8.0-alpha.
|
|
47
|
-
"@lwrjs/loader": "0.8.0-alpha.
|
|
48
|
-
"@lwrjs/lwc-module-provider": "0.8.0-alpha.
|
|
49
|
-
"@lwrjs/lwc-ssr": "0.8.0-alpha.
|
|
50
|
-
"@lwrjs/markdown-view-provider": "0.8.0-alpha.
|
|
51
|
-
"@lwrjs/module-bundler": "0.8.0-alpha.
|
|
52
|
-
"@lwrjs/module-registry": "0.8.0-alpha.
|
|
53
|
-
"@lwrjs/npm-module-provider": "0.8.0-alpha.
|
|
54
|
-
"@lwrjs/nunjucks-view-provider": "0.8.0-alpha.
|
|
55
|
-
"@lwrjs/o11y": "0.8.0-alpha.
|
|
56
|
-
"@lwrjs/resource-registry": "0.8.0-alpha.
|
|
57
|
-
"@lwrjs/router": "0.8.0-alpha.
|
|
58
|
-
"@lwrjs/server": "0.8.0-alpha.
|
|
59
|
-
"@lwrjs/shared-utils": "0.8.0-alpha.
|
|
60
|
-
"@lwrjs/view-registry": "0.8.0-alpha.
|
|
35
|
+
"@lwrjs/app-service": "0.8.0-alpha.12",
|
|
36
|
+
"@lwrjs/asset-registry": "0.8.0-alpha.12",
|
|
37
|
+
"@lwrjs/asset-transformer": "0.8.0-alpha.12",
|
|
38
|
+
"@lwrjs/base-template-engine": "0.8.0-alpha.12",
|
|
39
|
+
"@lwrjs/base-view-provider": "0.8.0-alpha.12",
|
|
40
|
+
"@lwrjs/base-view-transformer": "0.8.0-alpha.12",
|
|
41
|
+
"@lwrjs/client-modules": "0.8.0-alpha.12",
|
|
42
|
+
"@lwrjs/compiler": "0.8.0-alpha.12",
|
|
43
|
+
"@lwrjs/config": "0.8.0-alpha.12",
|
|
44
|
+
"@lwrjs/diagnostics": "0.8.0-alpha.12",
|
|
45
|
+
"@lwrjs/fs-asset-provider": "0.8.0-alpha.12",
|
|
46
|
+
"@lwrjs/html-view-provider": "0.8.0-alpha.12",
|
|
47
|
+
"@lwrjs/loader": "0.8.0-alpha.12",
|
|
48
|
+
"@lwrjs/lwc-module-provider": "0.8.0-alpha.12",
|
|
49
|
+
"@lwrjs/lwc-ssr": "0.8.0-alpha.12",
|
|
50
|
+
"@lwrjs/markdown-view-provider": "0.8.0-alpha.12",
|
|
51
|
+
"@lwrjs/module-bundler": "0.8.0-alpha.12",
|
|
52
|
+
"@lwrjs/module-registry": "0.8.0-alpha.12",
|
|
53
|
+
"@lwrjs/npm-module-provider": "0.8.0-alpha.12",
|
|
54
|
+
"@lwrjs/nunjucks-view-provider": "0.8.0-alpha.12",
|
|
55
|
+
"@lwrjs/o11y": "0.8.0-alpha.12",
|
|
56
|
+
"@lwrjs/resource-registry": "0.8.0-alpha.12",
|
|
57
|
+
"@lwrjs/router": "0.8.0-alpha.12",
|
|
58
|
+
"@lwrjs/server": "0.8.0-alpha.12",
|
|
59
|
+
"@lwrjs/shared-utils": "0.8.0-alpha.12",
|
|
60
|
+
"@lwrjs/view-registry": "0.8.0-alpha.12",
|
|
61
61
|
"fs-extra": "^10.1.0",
|
|
62
62
|
"ms": "^2.1.3",
|
|
63
63
|
"path-to-regexp": "^6.2.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"ws": "^8.8.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@lwrjs/types": "0.8.0-alpha.
|
|
68
|
+
"@lwrjs/types": "0.8.0-alpha.12",
|
|
69
69
|
"@types/ws": "^8.5.3"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=14.15.4 <19"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "eef0342738457f04590e760a0b501e4d78d93416"
|
|
78
78
|
}
|