@lwrjs/core 0.15.0-alpha.2 → 0.15.0-alpha.21
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/__mocks__/undici.cjs +25 -0
- package/build/cjs/index.cjs +2 -2
- package/build/cjs/middleware/bundle-middleware.cjs +1 -1
- package/build/cjs/middleware/request-processor-middleware.cjs +12 -2
- package/build/cjs/middleware/view-middleware.cjs +45 -2
- package/build/cjs/tools/static-generation.cjs +4 -4
- package/build/es/index.js +2 -2
- package/build/es/middleware/bundle-middleware.js +3 -1
- package/build/es/middleware/request-processor-middleware.js +14 -4
- package/build/es/middleware/view-middleware.d.ts +1 -0
- package/build/es/middleware/view-middleware.js +49 -2
- package/build/es/tools/static-generation.js +4 -4
- package/package.json +34 -34
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// packages/@lwrjs/core/src/__mocks__/undici.ts
|
|
9
|
+
__markAsModule(exports);
|
|
10
|
+
__export(exports, {
|
|
11
|
+
Pool: () => Pool
|
|
12
|
+
});
|
|
13
|
+
var Pool = class {
|
|
14
|
+
async request() {
|
|
15
|
+
return Promise.resolve({
|
|
16
|
+
statusCode: 200,
|
|
17
|
+
body: {
|
|
18
|
+
text: () => Promise.resolve('{"one":1}'),
|
|
19
|
+
json: () => Promise.resolve({one: 1})
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
close() {
|
|
24
|
+
}
|
|
25
|
+
};
|
package/build/cjs/index.cjs
CHANGED
|
@@ -109,9 +109,9 @@ var LwrApp = class {
|
|
|
109
109
|
this.config = appConfig;
|
|
110
110
|
this.runtimeEnvironment = runtimeEnvironment;
|
|
111
111
|
this.globalData = globalData;
|
|
112
|
-
const {basePath, serverType} = this.config;
|
|
112
|
+
const {basePath, serverType, caseSensitiveRoutes} = this.config;
|
|
113
113
|
this.serverType = serverType;
|
|
114
|
-
this.app = (0, import_server.createInternalServer)(serverType, {basePath});
|
|
114
|
+
this.app = (0, import_server.createInternalServer)(serverType, {basePath, caseSensitiveRoutes});
|
|
115
115
|
this.server = this.app.createHttpServer();
|
|
116
116
|
this.use = this.app.use.bind(this.app);
|
|
117
117
|
this.all = this.app.all.bind(this.app);
|
|
@@ -84,7 +84,7 @@ function createBundleMiddleware(context) {
|
|
|
84
84
|
if (signature !== import_shared_utils.LATEST_SIGNATURE) {
|
|
85
85
|
res.setHeader("Cache-control", "public, max-age=31536000, immutable");
|
|
86
86
|
}
|
|
87
|
-
res.status(200).type("application/javascript").send(bundleDefinition.
|
|
87
|
+
res.status(200).type("application/javascript").send(await bundleDefinition.getCode());
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
function createSourceMapMiddleware(context) {
|
|
@@ -45,7 +45,7 @@ function requestProcessorMiddleware(app, context) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
requestClass = req.headers[MRT_REQUEST_CLASS_KEY];
|
|
48
|
-
requestDepth = (0, import_shared_utils.
|
|
48
|
+
requestDepth = (0, import_shared_utils.parseRequestDepth)(req.headers, req.query);
|
|
49
49
|
const forwarded = req.headers["forwarded"];
|
|
50
50
|
const host = req.headers["host"];
|
|
51
51
|
const forwardedProto = req.headers["x-forwarded-proto"];
|
|
@@ -57,7 +57,7 @@ function requestProcessorMiddleware(app, context) {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
if (requestDepth && requestDepth >
|
|
60
|
+
if (requestDepth && requestDepth > 1) {
|
|
61
61
|
import_diagnostics.logger.error({
|
|
62
62
|
label: "request-processor-middleware",
|
|
63
63
|
message: `Lambda SSR request cycle detected: ${req.originalUrl}`
|
|
@@ -72,6 +72,16 @@ function requestProcessorMiddleware(app, context) {
|
|
|
72
72
|
});
|
|
73
73
|
const pathValue = parsedRequestClass?.basePath || basePath || "";
|
|
74
74
|
req.basePath = pathValue === "" || pathValue.indexOf("/") === 0 ? pathValue : `/${pathValue}`;
|
|
75
|
+
const expressRequest = req.req;
|
|
76
|
+
if (expressRequest?.url?.startsWith(parsedRequestClass?.basePath)) {
|
|
77
|
+
expressRequest.url = expressRequest.url.split(parsedRequestClass?.basePath)[1] || "/";
|
|
78
|
+
expressRequest.originalUrl = expressRequest.url.split(parsedRequestClass?.basePath)[1] || "/";
|
|
79
|
+
} else {
|
|
80
|
+
import_diagnostics.logger.warn({
|
|
81
|
+
label: `request-processor-middleware`,
|
|
82
|
+
message: `The URL requested for doesn't start with the Base path`
|
|
83
|
+
});
|
|
84
|
+
}
|
|
75
85
|
} else {
|
|
76
86
|
import_diagnostics.logger.debug({
|
|
77
87
|
label: `request-processor-middleware`,
|
|
@@ -24,6 +24,7 @@ var __toModule = (module2) => {
|
|
|
24
24
|
// packages/@lwrjs/core/src/middleware/view-middleware.ts
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
+
convertMetricsToArrayOfStrings: () => convertMetricsToArrayOfStrings,
|
|
27
28
|
viewMiddleware: () => viewMiddleware
|
|
28
29
|
});
|
|
29
30
|
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
@@ -32,6 +33,7 @@ var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
|
32
33
|
var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
|
|
33
34
|
var import_error_handling = __toModule(require("./utils/error-handling.cjs"));
|
|
34
35
|
var import_view_registry = __toModule(require("@lwrjs/view-registry"));
|
|
36
|
+
var import_aws_exporter = __toModule(require("@lwrjs/instrumentation/aws-exporter"));
|
|
35
37
|
function createViewMiddleware(route, errorRoutes, context, viewHandler) {
|
|
36
38
|
const errorRoute = errorRoutes.find((route2) => route2.status === 500);
|
|
37
39
|
const appConfig = context.appConfig;
|
|
@@ -61,12 +63,15 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
|
|
|
61
63
|
...defaultRuntimeParams,
|
|
62
64
|
url: viewRequest.url,
|
|
63
65
|
params: viewRequest.params,
|
|
64
|
-
query: viewRequest.query
|
|
66
|
+
query: viewRequest.query,
|
|
67
|
+
cookie: req.headers?.cookie,
|
|
68
|
+
coreProxy: req.getCoreProxy(appConfig.coreProxy ?? void 0, route.bootstrap?.proxyForSSR)
|
|
65
69
|
};
|
|
66
70
|
const resolve = req.isJsonRequest() ? viewHandler.getViewJson : viewHandler.getViewContent;
|
|
67
71
|
let viewResponse;
|
|
68
72
|
let resolvedRoute;
|
|
69
73
|
let traceId;
|
|
74
|
+
let reqSpan;
|
|
70
75
|
try {
|
|
71
76
|
viewResponse = await (0, import_instrumentation.getTracer)().trace({
|
|
72
77
|
name: import_instrumentation.RequestHandlerSpan.GetView,
|
|
@@ -79,6 +84,7 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
|
|
|
79
84
|
}
|
|
80
85
|
}, (span) => {
|
|
81
86
|
traceId = span.traceId;
|
|
87
|
+
reqSpan = span.reqSpan;
|
|
82
88
|
return resolve.call(viewHandler, viewRequest, route, runtimeEnvironment, runtimeParams);
|
|
83
89
|
});
|
|
84
90
|
resolvedRoute = route;
|
|
@@ -113,8 +119,26 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
|
|
|
113
119
|
}
|
|
114
120
|
if (traceId?.length) {
|
|
115
121
|
res.setHeader("x-trace-id", traceId);
|
|
122
|
+
if (reqSpan?.status?.code === 0) {
|
|
123
|
+
res.set({
|
|
124
|
+
"X-Custom-Lwr-Metric": convertMetricsToArrayOfStrings((0, import_aws_exporter.convertToReadableSpan)(reqSpan))
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
let status = resolvedRoute.status || viewResponse.status || 200;
|
|
129
|
+
const redirect = viewResponse.metadata?.viewDefinition?.redirect;
|
|
130
|
+
if (viewResponse.status === 301 || viewResponse.status === 302) {
|
|
131
|
+
status = viewResponse.status;
|
|
132
|
+
} else if (redirect) {
|
|
133
|
+
if ((0, import_shared_utils.isURL)(redirect.location) || redirect.location.startsWith("/")) {
|
|
134
|
+
status = redirect.status || 302;
|
|
135
|
+
res.set({
|
|
136
|
+
Location: addRedirectQueryParam(redirect.location, (0, import_shared_utils.parseRequestDepth)(req.headers, req.query))
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
import_diagnostics.logger.warn(`[view-middleware] Redirect failed because the URL is invalid: "${redirect.location}"`);
|
|
140
|
+
}
|
|
116
141
|
}
|
|
117
|
-
const status = resolvedRoute.status || viewResponse.status || 200;
|
|
118
142
|
res.status(status);
|
|
119
143
|
res.send(viewResponse.body);
|
|
120
144
|
};
|
|
@@ -219,3 +243,22 @@ function addDefaultLocaleRedirects(defaultLocale, defaultLocalePaths, app) {
|
|
|
219
243
|
return res.sendStatus(301);
|
|
220
244
|
});
|
|
221
245
|
}
|
|
246
|
+
function addRedirectQueryParam(redirectUrl, depth) {
|
|
247
|
+
const fakeOrigin = "http://parse.com";
|
|
248
|
+
const url = (0, import_shared_utils.isURL)(redirectUrl) ? new URL(redirectUrl) : new URL(`${fakeOrigin}${redirectUrl}`);
|
|
249
|
+
url.searchParams.set(import_shared_utils.REQUEST_DEPTH_KEY, String(depth + 1));
|
|
250
|
+
return url.toString().replace(fakeOrigin, "");
|
|
251
|
+
}
|
|
252
|
+
function convertMetricsToArrayOfStrings(span) {
|
|
253
|
+
const requiredMetrics = ["traceId", "name", "attributes", "duration"];
|
|
254
|
+
return requiredMetrics.reduce((metricString, prop) => {
|
|
255
|
+
if (metricString && !metricString.endsWith("; ")) {
|
|
256
|
+
metricString += "; ";
|
|
257
|
+
}
|
|
258
|
+
if (span[prop]) {
|
|
259
|
+
const propValue = typeof span[prop] === "object" ? JSON.stringify(span[prop]) : span[prop];
|
|
260
|
+
metricString += `${prop}: ${propValue}`;
|
|
261
|
+
}
|
|
262
|
+
return metricString;
|
|
263
|
+
}, "");
|
|
264
|
+
}
|
|
@@ -232,12 +232,12 @@ var SiteGenerator = class {
|
|
|
232
232
|
addBundleToSiteMetadata(bundleDefinition, url, siteConfig) {
|
|
233
233
|
if (siteConfig.siteMetadata) {
|
|
234
234
|
const locale = siteConfig.locale;
|
|
235
|
-
const specifier = (0, import_site_metadata.getSiteBundleId)(bundleDefinition, locale, siteConfig.i18n);
|
|
236
|
-
const imports = bundleDefinition.bundleRecord.imports?.map((moduleRef) => (0, import_site_metadata.getSiteBundleId)(moduleRef, locale, siteConfig.i18n)) || [];
|
|
237
|
-
const dynamicImports = bundleDefinition.bundleRecord.dynamicImports?.map((moduleRef) => (0, import_site_metadata.getSiteBundleId)(moduleRef, locale, siteConfig.i18n));
|
|
235
|
+
const specifier = (0, import_site_metadata.getSiteBundleId)(bundleDefinition, locale, false, siteConfig.i18n);
|
|
236
|
+
const imports = bundleDefinition.bundleRecord.imports?.map((moduleRef) => (0, import_site_metadata.getSiteBundleId)(moduleRef, locale, false, siteConfig.i18n)) || [];
|
|
237
|
+
const dynamicImports = bundleDefinition.bundleRecord.dynamicImports?.map((moduleRef) => (0, import_site_metadata.getSiteBundleId)(moduleRef, locale, false, siteConfig.i18n));
|
|
238
238
|
const includedModules = bundleDefinition.bundleRecord.includedModules?.map((moduleRef) => {
|
|
239
239
|
const moduleId = (0, import_shared_utils.explodeSpecifier)(moduleRef);
|
|
240
|
-
return (0, import_site_metadata.getSiteBundleId)(moduleId, locale, siteConfig.i18n);
|
|
240
|
+
return (0, import_site_metadata.getSiteBundleId)(moduleId, locale, false, siteConfig.i18n);
|
|
241
241
|
}) || [];
|
|
242
242
|
const version = bundleDefinition.version === import_shared_utils.VERSION_NOT_PROVIDED ? void 0 : bundleDefinition.version;
|
|
243
243
|
const bundleMetadata = {
|
package/build/es/index.js
CHANGED
|
@@ -98,9 +98,9 @@ export class LwrApp {
|
|
|
98
98
|
this.config = appConfig;
|
|
99
99
|
this.runtimeEnvironment = runtimeEnvironment;
|
|
100
100
|
this.globalData = globalData;
|
|
101
|
-
const { basePath, serverType } = this.config;
|
|
101
|
+
const { basePath, serverType, caseSensitiveRoutes } = this.config;
|
|
102
102
|
this.serverType = serverType;
|
|
103
|
-
this.app = createInternalServer(serverType, { basePath });
|
|
103
|
+
this.app = createInternalServer(serverType, { basePath, caseSensitiveRoutes });
|
|
104
104
|
this.server = this.app.createHttpServer();
|
|
105
105
|
this.use = this.app.use.bind(this.app);
|
|
106
106
|
this.all = this.app.all.bind(this.app);
|
|
@@ -56,7 +56,9 @@ function createBundleMiddleware(context) {
|
|
|
56
56
|
if (signature !== LATEST_SIGNATURE) {
|
|
57
57
|
res.setHeader('Cache-control', 'public, max-age=31536000, immutable');
|
|
58
58
|
}
|
|
59
|
-
res.status(200)
|
|
59
|
+
res.status(200)
|
|
60
|
+
.type('application/javascript')
|
|
61
|
+
.send(await bundleDefinition.getCode());
|
|
60
62
|
};
|
|
61
63
|
}
|
|
62
64
|
function createSourceMapMiddleware(context) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
import { logger } from '@lwrjs/diagnostics';
|
|
10
|
-
import { REQUEST_DEPTH_HEADER, isLambdaEnv,
|
|
10
|
+
import { REQUEST_DEPTH_HEADER, isLambdaEnv, parseRequestDepth } from '@lwrjs/shared-utils';
|
|
11
11
|
const MRT_REQUEST_CLASS = 'X-Mobify-Request-Class';
|
|
12
12
|
const MRT_REQUEST_CLASS_KEY = MRT_REQUEST_CLASS.toLowerCase();
|
|
13
13
|
export function requestProcessorMiddleware(app, context) {
|
|
@@ -27,7 +27,7 @@ export function requestProcessorMiddleware(app, context) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
requestClass = req.headers[MRT_REQUEST_CLASS_KEY];
|
|
30
|
-
requestDepth =
|
|
30
|
+
requestDepth = parseRequestDepth(req.headers, req.query);
|
|
31
31
|
const forwarded = req.headers['forwarded'];
|
|
32
32
|
const host = req.headers['host'];
|
|
33
33
|
const forwardedProto = req.headers['x-forwarded-proto'];
|
|
@@ -40,8 +40,7 @@ export function requestProcessorMiddleware(app, context) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
if (requestDepth && requestDepth > 0) {
|
|
43
|
+
if (requestDepth && requestDepth > 1) {
|
|
45
44
|
logger.error({
|
|
46
45
|
label: 'request-processor-middleware',
|
|
47
46
|
message: `Lambda SSR request cycle detected: ${req.originalUrl}`,
|
|
@@ -58,6 +57,17 @@ export function requestProcessorMiddleware(app, context) {
|
|
|
58
57
|
const pathValue = parsedRequestClass?.basePath || basePath || '';
|
|
59
58
|
// If base path is '' or starts with / leave it alone
|
|
60
59
|
req.basePath = pathValue === '' || pathValue.indexOf('/') === 0 ? pathValue : `/${pathValue}`;
|
|
60
|
+
const expressRequest = req.req;
|
|
61
|
+
if (expressRequest?.url?.startsWith(parsedRequestClass?.basePath)) {
|
|
62
|
+
expressRequest.url = expressRequest.url.split(parsedRequestClass?.basePath)[1] || '/';
|
|
63
|
+
expressRequest.originalUrl = expressRequest.url.split(parsedRequestClass?.basePath)[1] || '/';
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
logger.warn({
|
|
67
|
+
label: `request-processor-middleware`,
|
|
68
|
+
message: `The URL requested for doesn't start with the Base path`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
61
71
|
}
|
|
62
72
|
else {
|
|
63
73
|
logger.debug({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { InternalAppServer, ServerContext, ServerTypes } from '@lwrjs/types';
|
|
2
2
|
export declare function viewMiddleware<T extends ServerTypes>(app: InternalAppServer<T>, context: ServerContext): void;
|
|
3
|
+
export declare function convertMetricsToArrayOfStrings(span: Record<string, any>): string;
|
|
3
4
|
//# sourceMappingURL=view-middleware.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { descriptions, logger } from '@lwrjs/diagnostics';
|
|
2
2
|
import { getClientRoutes } from '@lwrjs/router';
|
|
3
|
-
import { decodeViewPath, extractRequestParams, getClientBootstrapConfigurationRoutes, shortestTtl, } from '@lwrjs/shared-utils';
|
|
3
|
+
import { decodeViewPath, extractRequestParams, getClientBootstrapConfigurationRoutes, isURL, parseRequestDepth, REQUEST_DEPTH_KEY, shortestTtl, } from '@lwrjs/shared-utils';
|
|
4
4
|
import { RequestHandlerSpan, getTracer } from '@lwrjs/instrumentation';
|
|
5
5
|
import { handleErrors } from './utils/error-handling.js';
|
|
6
6
|
import { LwrViewHandler } from '@lwrjs/view-registry';
|
|
7
|
+
import { convertToReadableSpan } from '@lwrjs/instrumentation/aws-exporter';
|
|
7
8
|
function createViewMiddleware(route, errorRoutes, context, viewHandler) {
|
|
8
9
|
const errorRoute = errorRoutes.find((route) => route.status === 500);
|
|
9
10
|
const appConfig = context.appConfig;
|
|
@@ -36,11 +37,14 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
|
|
|
36
37
|
url: viewRequest.url,
|
|
37
38
|
params: viewRequest.params,
|
|
38
39
|
query: viewRequest.query,
|
|
40
|
+
cookie: req.headers?.cookie,
|
|
41
|
+
coreProxy: req.getCoreProxy(appConfig.coreProxy ?? undefined, route.bootstrap?.proxyForSSR),
|
|
39
42
|
};
|
|
40
43
|
const resolve = req.isJsonRequest() ? viewHandler.getViewJson : viewHandler.getViewContent;
|
|
41
44
|
let viewResponse;
|
|
42
45
|
let resolvedRoute;
|
|
43
46
|
let traceId;
|
|
47
|
+
let reqSpan;
|
|
44
48
|
try {
|
|
45
49
|
viewResponse = await getTracer().trace({
|
|
46
50
|
name: RequestHandlerSpan.GetView,
|
|
@@ -53,6 +57,7 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
|
|
|
53
57
|
},
|
|
54
58
|
}, (span) => {
|
|
55
59
|
traceId = span.traceId;
|
|
60
|
+
reqSpan = span.reqSpan;
|
|
56
61
|
return resolve.call(viewHandler, viewRequest, route, runtimeEnvironment, runtimeParams);
|
|
57
62
|
});
|
|
58
63
|
resolvedRoute = route;
|
|
@@ -92,8 +97,29 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
|
|
|
92
97
|
}
|
|
93
98
|
if (traceId?.length) {
|
|
94
99
|
res.setHeader('x-trace-id', traceId);
|
|
100
|
+
if (reqSpan?.status?.code === 0) {
|
|
101
|
+
res.set({
|
|
102
|
+
'X-Custom-Lwr-Metric': convertMetricsToArrayOfStrings(convertToReadableSpan(reqSpan)),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
let status = resolvedRoute.status || viewResponse.status || 200;
|
|
107
|
+
const redirect = viewResponse.metadata?.viewDefinition?.redirect;
|
|
108
|
+
if (viewResponse.status === 301 || viewResponse.status === 302) {
|
|
109
|
+
// route handle redirect status takes precedence
|
|
110
|
+
status = viewResponse.status;
|
|
111
|
+
}
|
|
112
|
+
else if (redirect) {
|
|
113
|
+
if (isURL(redirect.location) || redirect.location.startsWith('/')) {
|
|
114
|
+
status = redirect.status || 302;
|
|
115
|
+
res.set({
|
|
116
|
+
Location: addRedirectQueryParam(redirect.location, parseRequestDepth(req.headers, req.query)),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
logger.warn(`[view-middleware] Redirect failed because the URL is invalid: "${redirect.location}"`);
|
|
121
|
+
}
|
|
95
122
|
}
|
|
96
|
-
const status = resolvedRoute.status || viewResponse.status || 200;
|
|
97
123
|
res.status(status);
|
|
98
124
|
res.send(viewResponse.body);
|
|
99
125
|
};
|
|
@@ -222,4 +248,25 @@ function addDefaultLocaleRedirects(defaultLocale, defaultLocalePaths, app) {
|
|
|
222
248
|
return res.sendStatus(301);
|
|
223
249
|
});
|
|
224
250
|
}
|
|
251
|
+
function addRedirectQueryParam(redirectUrl, depth) {
|
|
252
|
+
// add a request depth query param to the URL
|
|
253
|
+
// the depth header cannot be used since headers cannot be added to a redirect
|
|
254
|
+
const fakeOrigin = 'http://parse.com';
|
|
255
|
+
const url = isURL(redirectUrl) ? new URL(redirectUrl) : new URL(`${fakeOrigin}${redirectUrl}`);
|
|
256
|
+
url.searchParams.set(REQUEST_DEPTH_KEY, String(depth + 1));
|
|
257
|
+
return url.toString().replace(fakeOrigin, '');
|
|
258
|
+
}
|
|
259
|
+
export function convertMetricsToArrayOfStrings(span) {
|
|
260
|
+
const requiredMetrics = ['traceId', 'name', 'attributes', 'duration'];
|
|
261
|
+
return requiredMetrics.reduce((metricString, prop) => {
|
|
262
|
+
if (metricString && !metricString.endsWith('; ')) {
|
|
263
|
+
metricString += '; ';
|
|
264
|
+
}
|
|
265
|
+
if (span[prop]) {
|
|
266
|
+
const propValue = typeof span[prop] === 'object' ? JSON.stringify(span[prop]) : span[prop];
|
|
267
|
+
metricString += `${prop}: ${propValue}`;
|
|
268
|
+
}
|
|
269
|
+
return metricString;
|
|
270
|
+
}, '');
|
|
271
|
+
}
|
|
225
272
|
//# sourceMappingURL=view-middleware.js.map
|
|
@@ -299,12 +299,12 @@ export default class SiteGenerator {
|
|
|
299
299
|
addBundleToSiteMetadata(bundleDefinition, url, siteConfig) {
|
|
300
300
|
if (siteConfig.siteMetadata) {
|
|
301
301
|
const locale = siteConfig.locale;
|
|
302
|
-
const specifier = getSiteBundleId(bundleDefinition, locale, siteConfig.i18n);
|
|
303
|
-
const imports = bundleDefinition.bundleRecord.imports?.map((moduleRef) => getSiteBundleId(moduleRef, locale, siteConfig.i18n)) || [];
|
|
304
|
-
const dynamicImports = bundleDefinition.bundleRecord.dynamicImports?.map((moduleRef) => getSiteBundleId(moduleRef, locale, siteConfig.i18n));
|
|
302
|
+
const specifier = getSiteBundleId(bundleDefinition, locale, false, siteConfig.i18n);
|
|
303
|
+
const imports = bundleDefinition.bundleRecord.imports?.map((moduleRef) => getSiteBundleId(moduleRef, locale, false, siteConfig.i18n)) || [];
|
|
304
|
+
const dynamicImports = bundleDefinition.bundleRecord.dynamicImports?.map((moduleRef) => getSiteBundleId(moduleRef, locale, false, siteConfig.i18n));
|
|
305
305
|
const includedModules = bundleDefinition.bundleRecord.includedModules?.map((moduleRef) => {
|
|
306
306
|
const moduleId = explodeSpecifier(moduleRef);
|
|
307
|
-
return getSiteBundleId(moduleId, locale, siteConfig.i18n);
|
|
307
|
+
return getSiteBundleId(moduleId, locale, false, siteConfig.i18n);
|
|
308
308
|
}) || [];
|
|
309
309
|
const version = bundleDefinition.version === VERSION_NOT_PROVIDED ? undefined : bundleDefinition.version;
|
|
310
310
|
const bundleMetadata = {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.15.0-alpha.
|
|
7
|
+
"version": "0.15.0-alpha.21",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -43,45 +43,45 @@
|
|
|
43
43
|
"build": "tsc -b"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@lwrjs/app-service": "0.15.0-alpha.
|
|
47
|
-
"@lwrjs/asset-registry": "0.15.0-alpha.
|
|
48
|
-
"@lwrjs/asset-transformer": "0.15.0-alpha.
|
|
49
|
-
"@lwrjs/base-view-provider": "0.15.0-alpha.
|
|
50
|
-
"@lwrjs/base-view-transformer": "0.15.0-alpha.
|
|
51
|
-
"@lwrjs/client-modules": "0.15.0-alpha.
|
|
52
|
-
"@lwrjs/config": "0.15.0-alpha.
|
|
53
|
-
"@lwrjs/diagnostics": "0.15.0-alpha.
|
|
54
|
-
"@lwrjs/esbuild": "0.15.0-alpha.
|
|
55
|
-
"@lwrjs/fs-asset-provider": "0.15.0-alpha.
|
|
56
|
-
"@lwrjs/fs-watch": "0.15.0-alpha.
|
|
57
|
-
"@lwrjs/html-view-provider": "0.15.0-alpha.
|
|
58
|
-
"@lwrjs/instrumentation": "0.15.0-alpha.
|
|
59
|
-
"@lwrjs/loader": "0.15.0-alpha.
|
|
60
|
-
"@lwrjs/lwc-module-provider": "0.15.0-alpha.
|
|
61
|
-
"@lwrjs/lwc-ssr": "0.15.0-alpha.
|
|
62
|
-
"@lwrjs/markdown-view-provider": "0.15.0-alpha.
|
|
63
|
-
"@lwrjs/module-bundler": "0.15.0-alpha.
|
|
64
|
-
"@lwrjs/module-registry": "0.15.0-alpha.
|
|
65
|
-
"@lwrjs/npm-module-provider": "0.15.0-alpha.
|
|
66
|
-
"@lwrjs/nunjucks-view-provider": "0.15.0-alpha.
|
|
67
|
-
"@lwrjs/o11y": "0.15.0-alpha.
|
|
68
|
-
"@lwrjs/resource-registry": "0.15.0-alpha.
|
|
69
|
-
"@lwrjs/router": "0.15.0-alpha.
|
|
70
|
-
"@lwrjs/server": "0.15.0-alpha.
|
|
71
|
-
"@lwrjs/shared-utils": "0.15.0-alpha.
|
|
72
|
-
"@lwrjs/static": "0.15.0-alpha.
|
|
73
|
-
"@lwrjs/view-registry": "0.15.0-alpha.
|
|
46
|
+
"@lwrjs/app-service": "0.15.0-alpha.21",
|
|
47
|
+
"@lwrjs/asset-registry": "0.15.0-alpha.21",
|
|
48
|
+
"@lwrjs/asset-transformer": "0.15.0-alpha.21",
|
|
49
|
+
"@lwrjs/base-view-provider": "0.15.0-alpha.21",
|
|
50
|
+
"@lwrjs/base-view-transformer": "0.15.0-alpha.21",
|
|
51
|
+
"@lwrjs/client-modules": "0.15.0-alpha.21",
|
|
52
|
+
"@lwrjs/config": "0.15.0-alpha.21",
|
|
53
|
+
"@lwrjs/diagnostics": "0.15.0-alpha.21",
|
|
54
|
+
"@lwrjs/esbuild": "0.15.0-alpha.21",
|
|
55
|
+
"@lwrjs/fs-asset-provider": "0.15.0-alpha.21",
|
|
56
|
+
"@lwrjs/fs-watch": "0.15.0-alpha.21",
|
|
57
|
+
"@lwrjs/html-view-provider": "0.15.0-alpha.21",
|
|
58
|
+
"@lwrjs/instrumentation": "0.15.0-alpha.21",
|
|
59
|
+
"@lwrjs/loader": "0.15.0-alpha.21",
|
|
60
|
+
"@lwrjs/lwc-module-provider": "0.15.0-alpha.21",
|
|
61
|
+
"@lwrjs/lwc-ssr": "0.15.0-alpha.21",
|
|
62
|
+
"@lwrjs/markdown-view-provider": "0.15.0-alpha.21",
|
|
63
|
+
"@lwrjs/module-bundler": "0.15.0-alpha.21",
|
|
64
|
+
"@lwrjs/module-registry": "0.15.0-alpha.21",
|
|
65
|
+
"@lwrjs/npm-module-provider": "0.15.0-alpha.21",
|
|
66
|
+
"@lwrjs/nunjucks-view-provider": "0.15.0-alpha.21",
|
|
67
|
+
"@lwrjs/o11y": "0.15.0-alpha.21",
|
|
68
|
+
"@lwrjs/resource-registry": "0.15.0-alpha.21",
|
|
69
|
+
"@lwrjs/router": "0.15.0-alpha.21",
|
|
70
|
+
"@lwrjs/server": "0.15.0-alpha.21",
|
|
71
|
+
"@lwrjs/shared-utils": "0.15.0-alpha.21",
|
|
72
|
+
"@lwrjs/static": "0.15.0-alpha.21",
|
|
73
|
+
"@lwrjs/view-registry": "0.15.0-alpha.21",
|
|
74
74
|
"chokidar": "^3.6.0",
|
|
75
75
|
"esbuild": "^0.9.7",
|
|
76
76
|
"fs-extra": "^11.2.0",
|
|
77
77
|
"path-to-regexp": "^6.2.2",
|
|
78
|
-
"qs": "^6.
|
|
79
|
-
"rollup": "^2.
|
|
78
|
+
"qs": "^6.13.0",
|
|
79
|
+
"rollup": "^2.79.2",
|
|
80
80
|
"ws": "^8.18.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@lwrjs/types": "0.15.0-alpha.
|
|
84
|
-
"@types/ws": "^8.5.
|
|
83
|
+
"@lwrjs/types": "0.15.0-alpha.21",
|
|
84
|
+
"@types/ws": "^8.5.12",
|
|
85
85
|
"memfs": "^4.9.3"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"volta": {
|
|
94
94
|
"extends": "../../../package.json"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "4c09ff654569ab490fc77f196d3230b31404940e"
|
|
97
97
|
}
|