@lwrjs/core 0.8.0-alpha.12 → 0.8.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.
|
@@ -31,6 +31,7 @@ var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
|
31
31
|
var import_view_registry = __toModule(require("@lwrjs/view-registry"));
|
|
32
32
|
var import_utils = __toModule(require("./utils.cjs"));
|
|
33
33
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
34
|
+
var import_router = __toModule(require("@lwrjs/router"));
|
|
34
35
|
function uiMiddleware(app, context) {
|
|
35
36
|
const {viewRegistry, moduleRegistry, runtimeEnvironment: defaultRuntimeEnvironment} = context;
|
|
36
37
|
const {environment: environmentConfig, routes, errorRoutes} = context.appConfig;
|
|
@@ -145,16 +146,25 @@ function uiMiddleware(app, context) {
|
|
|
145
146
|
await sendViewResponse(req, res, route);
|
|
146
147
|
});
|
|
147
148
|
} else {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
const serverPath = route.path;
|
|
150
|
+
const paths = [serverPath];
|
|
151
|
+
const subRoutes = route.subRoutes ? (0, import_router.getClientRoutes)(route.subRoutes) : void 0;
|
|
152
|
+
if (subRoutes) {
|
|
153
|
+
const prefix = serverPath === "/" ? "" : serverPath;
|
|
154
|
+
subRoutes.routes.forEach((r) => paths.push(`${prefix}${r.uri}`));
|
|
155
|
+
}
|
|
156
|
+
paths.forEach((path) => {
|
|
157
|
+
app.get(path, async (req, res) => {
|
|
158
|
+
await sendViewResponse(req, res, route);
|
|
159
|
+
});
|
|
160
|
+
app.get([
|
|
161
|
+
`/:apiVersion/application/:format/l/:locale/ai/:appId${path}`,
|
|
162
|
+
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId${path}`,
|
|
163
|
+
`/:apiVersion/application/:format/ai/:appId${path}`,
|
|
164
|
+
`/:apiVersion/application/:format/e/:environment/ai/:appId${path}`
|
|
165
|
+
], async (req, res) => {
|
|
166
|
+
await sendViewResponse(req, res, route);
|
|
167
|
+
});
|
|
158
168
|
});
|
|
159
169
|
}
|
|
160
170
|
});
|
|
@@ -212,7 +212,7 @@ var SiteGenerator = class {
|
|
|
212
212
|
const assets = viewDefinition.viewRecord.assetReferences || [];
|
|
213
213
|
for (const asset of assets) {
|
|
214
214
|
const assetUrl = asset.override?.uri || asset.url;
|
|
215
|
-
if (assetUrl && !
|
|
215
|
+
if (assetUrl && !(0, import_shared_utils.isSelfUrl)(assetUrl)) {
|
|
216
216
|
dispatchRequests.push(this.dispatchResourceRecursive(assetUrl, dispatcher, {resourceType: "asset", asset}, siteConfig));
|
|
217
217
|
}
|
|
218
218
|
}
|
|
@@ -281,7 +281,10 @@ var SiteGenerator = class {
|
|
|
281
281
|
const assetReferences = metadata?.asset?.metadata?.assetReferences || [];
|
|
282
282
|
const dispatchRequests = [];
|
|
283
283
|
for (const ref of assetReferences) {
|
|
284
|
-
|
|
284
|
+
const refUrl = ref.override?.uri || ref.url;
|
|
285
|
+
dispatchRequests.push(this.dispatchResourceRecursive(refUrl, dispatcher, {resourceType: "asset", asset: metadata?.asset}, siteConfig).catch((err) => {
|
|
286
|
+
import_shared_utils.logger.warn(`Failed to fetch asset refrence => ${refUrl} from ${url}`, err);
|
|
287
|
+
}));
|
|
285
288
|
}
|
|
286
289
|
return Promise.all(dispatchRequests);
|
|
287
290
|
}
|
|
@@ -317,7 +320,7 @@ var SiteGenerator = class {
|
|
|
317
320
|
if (assetSrcDir && import_fs_extra.default.existsSync(assetSrcDir)) {
|
|
318
321
|
import_fs_extra.default.copySync(assetSrcDir, assetOutputDir);
|
|
319
322
|
} else {
|
|
320
|
-
|
|
323
|
+
console.warn("[WARN] Could not find assets to copy at path: " + assetSrcDir);
|
|
321
324
|
}
|
|
322
325
|
} catch (e) {
|
|
323
326
|
console.error("Error occurred processing asset config: " + JSON.stringify(asset));
|
|
@@ -3,6 +3,7 @@ import { DiagnosticsError } from '@lwrjs/diagnostics';
|
|
|
3
3
|
import { LwrViewHandler } from '@lwrjs/view-registry';
|
|
4
4
|
import { isSupportedEnvironment } from './utils.js';
|
|
5
5
|
import { decodeViewPath, getClientBootstrapConfigurationRoutes, extractRequestParams, } from '@lwrjs/shared-utils';
|
|
6
|
+
import { getClientRoutes } from '@lwrjs/router';
|
|
6
7
|
export default function uiMiddleware(app, context) {
|
|
7
8
|
const { viewRegistry, moduleRegistry, runtimeEnvironment: defaultRuntimeEnvironment } = context;
|
|
8
9
|
const { environment: environmentConfig, routes, errorRoutes } = context.appConfig;
|
|
@@ -135,18 +136,30 @@ export default function uiMiddleware(app, context) {
|
|
|
135
136
|
});
|
|
136
137
|
}
|
|
137
138
|
else {
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
// Get the client-side routes
|
|
140
|
+
const serverPath = route.path;
|
|
141
|
+
const paths = [serverPath];
|
|
142
|
+
const subRoutes = route.subRoutes ? getClientRoutes(route.subRoutes) : undefined;
|
|
143
|
+
if (subRoutes) {
|
|
144
|
+
// Concatenate each client uri to the server route.path, creating the full list of composite paths
|
|
145
|
+
const prefix = serverPath === '/' ? '' : serverPath;
|
|
146
|
+
subRoutes.routes.forEach((r) => paths.push(`${prefix}${r.uri}`));
|
|
147
|
+
}
|
|
148
|
+
// Register the server route.path and each composite client path, to enable full page refreshes of client pages
|
|
149
|
+
paths.forEach((path) => {
|
|
150
|
+
// vanity urls
|
|
151
|
+
app.get(path, async (req, res) => {
|
|
152
|
+
await sendViewResponse(req, res, route);
|
|
153
|
+
});
|
|
154
|
+
// canonical URL
|
|
155
|
+
app.get([
|
|
156
|
+
`/:apiVersion/application/:format/l/:locale/ai/:appId${path}`,
|
|
157
|
+
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId${path}`,
|
|
158
|
+
`/:apiVersion/application/:format/ai/:appId${path}`,
|
|
159
|
+
`/:apiVersion/application/:format/e/:environment/ai/:appId${path}`,
|
|
160
|
+
], async (req, res) => {
|
|
161
|
+
await sendViewResponse(req, res, route);
|
|
162
|
+
});
|
|
150
163
|
});
|
|
151
164
|
}
|
|
152
165
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { performance } from 'perf_hooks';
|
|
2
|
-
import { getSpecifier, getFeatureFlags, hashContent, getModuleUriPrefix, getMappingUriPrefix, } from '@lwrjs/shared-utils';
|
|
2
|
+
import { getSpecifier, getFeatureFlags, hashContent, isSelfUrl, getModuleUriPrefix, getMappingUriPrefix, logger, } 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';
|
|
@@ -306,8 +306,8 @@ export default class SiteGenerator {
|
|
|
306
306
|
const assets = viewDefinition.viewRecord.assetReferences || [];
|
|
307
307
|
for (const asset of assets) {
|
|
308
308
|
const assetUrl = asset.override?.uri || asset.url;
|
|
309
|
-
// skip
|
|
310
|
-
if (assetUrl && !assetUrl
|
|
309
|
+
// skip self referential asset urls / data urls (i.e. <img src="" /> <img src="data:image/png;base64, iVBORw0..." />)
|
|
310
|
+
if (assetUrl && !isSelfUrl(assetUrl)) {
|
|
311
311
|
dispatchRequests.push(this.dispatchResourceRecursive(assetUrl, dispatcher, { resourceType: 'asset', asset }, siteConfig));
|
|
312
312
|
}
|
|
313
313
|
}
|
|
@@ -402,7 +402,11 @@ export default class SiteGenerator {
|
|
|
402
402
|
const assetReferences = metadata?.asset?.metadata?.assetReferences || [];
|
|
403
403
|
const dispatchRequests = [];
|
|
404
404
|
for (const ref of assetReferences) {
|
|
405
|
-
|
|
405
|
+
const refUrl = ref.override?.uri || ref.url;
|
|
406
|
+
dispatchRequests.push(this.dispatchResourceRecursive(refUrl, dispatcher, { resourceType: 'asset', asset: metadata?.asset }, siteConfig).catch((err) => {
|
|
407
|
+
// Warn the user that the we failed to fetch a referenced asset
|
|
408
|
+
logger.warn(`Failed to fetch asset refrence => ${refUrl} from ${url}`, err);
|
|
409
|
+
}));
|
|
406
410
|
}
|
|
407
411
|
return Promise.all(dispatchRequests);
|
|
408
412
|
}
|
|
@@ -459,7 +463,7 @@ export default class SiteGenerator {
|
|
|
459
463
|
fs.copySync(assetSrcDir, assetOutputDir);
|
|
460
464
|
}
|
|
461
465
|
else {
|
|
462
|
-
|
|
466
|
+
console.warn('[WARN] Could not find assets to copy at path: ' + assetSrcDir);
|
|
463
467
|
}
|
|
464
468
|
}
|
|
465
469
|
catch (e) {
|
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.14",
|
|
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.14",
|
|
36
|
+
"@lwrjs/asset-registry": "0.8.0-alpha.14",
|
|
37
|
+
"@lwrjs/asset-transformer": "0.8.0-alpha.14",
|
|
38
|
+
"@lwrjs/base-template-engine": "0.8.0-alpha.14",
|
|
39
|
+
"@lwrjs/base-view-provider": "0.8.0-alpha.14",
|
|
40
|
+
"@lwrjs/base-view-transformer": "0.8.0-alpha.14",
|
|
41
|
+
"@lwrjs/client-modules": "0.8.0-alpha.14",
|
|
42
|
+
"@lwrjs/compiler": "0.8.0-alpha.14",
|
|
43
|
+
"@lwrjs/config": "0.8.0-alpha.14",
|
|
44
|
+
"@lwrjs/diagnostics": "0.8.0-alpha.14",
|
|
45
|
+
"@lwrjs/fs-asset-provider": "0.8.0-alpha.14",
|
|
46
|
+
"@lwrjs/html-view-provider": "0.8.0-alpha.14",
|
|
47
|
+
"@lwrjs/loader": "0.8.0-alpha.14",
|
|
48
|
+
"@lwrjs/lwc-module-provider": "0.8.0-alpha.14",
|
|
49
|
+
"@lwrjs/lwc-ssr": "0.8.0-alpha.14",
|
|
50
|
+
"@lwrjs/markdown-view-provider": "0.8.0-alpha.14",
|
|
51
|
+
"@lwrjs/module-bundler": "0.8.0-alpha.14",
|
|
52
|
+
"@lwrjs/module-registry": "0.8.0-alpha.14",
|
|
53
|
+
"@lwrjs/npm-module-provider": "0.8.0-alpha.14",
|
|
54
|
+
"@lwrjs/nunjucks-view-provider": "0.8.0-alpha.14",
|
|
55
|
+
"@lwrjs/o11y": "0.8.0-alpha.14",
|
|
56
|
+
"@lwrjs/resource-registry": "0.8.0-alpha.14",
|
|
57
|
+
"@lwrjs/router": "0.8.0-alpha.14",
|
|
58
|
+
"@lwrjs/server": "0.8.0-alpha.14",
|
|
59
|
+
"@lwrjs/shared-utils": "0.8.0-alpha.14",
|
|
60
|
+
"@lwrjs/view-registry": "0.8.0-alpha.14",
|
|
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.14",
|
|
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": "6d332d4e1364efe9b6ad0b022143cc2e7d04e2e0"
|
|
78
78
|
}
|