@lwrjs/core 0.12.0-alpha.4 → 0.12.0-alpha.6

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.
@@ -0,0 +1,74 @@
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/info/route-handler.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ default: () => siteInfoHandler
28
+ });
29
+ var import_config = __toModule(require("@lwrjs/config"));
30
+ var import_fs = __toModule(require("fs"));
31
+ var baseHtml = `<!DOCTYPE html>
32
+ <html lang="en">
33
+ <head>
34
+ <meta charset="utf-8" />
35
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
36
+ <title>Site Information</title>
37
+ </head>
38
+ <body>
39
+ <h1>Site Information</h1>
40
+ <h3>Environment</h3>
41
+ {{ versionInfo }}
42
+ <h3>Metadata</h3>
43
+ <pre>{{ metadata }}</pre>
44
+ </body>
45
+ </html>`;
46
+ async function siteInfoHandler(request, context) {
47
+ const versionInfo = {
48
+ "LWR Version": import_config.LWR_VERSION,
49
+ "LWC Version": import_config.LWC_VERSION,
50
+ "Node Version": import_config.NODE_VERSION,
51
+ "PWA Kit Runtime Version": import_config.PWA_KIT_RUNTIME_VERSION
52
+ };
53
+ let versionInfoString = "";
54
+ for (const key in versionInfo) {
55
+ if (versionInfo[key] !== "note-provided") {
56
+ versionInfoString += `<p>${key}: ${versionInfo[key]}</p>
57
+ `;
58
+ }
59
+ }
60
+ const providedMetadataPath = `${context.rootDir}/site/.metadata/runtime-info.json`;
61
+ let providedMetadata = {};
62
+ if (import_fs.default.existsSync(providedMetadataPath)) {
63
+ providedMetadata = JSON.parse(import_fs.default.readFileSync(providedMetadataPath, "utf-8"));
64
+ }
65
+ let infoHtml = baseHtml;
66
+ infoHtml = infoHtml.replace("{{ versionInfo }}", versionInfoString);
67
+ infoHtml = infoHtml.replace("{{ metadata }}", JSON.stringify(providedMetadata, null, 2));
68
+ return {
69
+ body: infoHtml,
70
+ cache: {
71
+ ttl: "200s"
72
+ }
73
+ };
74
+ }
@@ -55,7 +55,8 @@ function createAssetMiddleware(context) {
55
55
  const asset = await (0, import_instrumentation.getTracer)().trace({
56
56
  name: import_instrumentation.RequestHandlerSpan.GetAsset,
57
57
  attributes: {
58
- specifier: assetId.specifier
58
+ specifier: assetId.specifier,
59
+ url: req.originalUrl
59
60
  }
60
61
  }, () => {
61
62
  return assetRegistry.getAsset({...assetId, signature}, runtimeEnvironment, req.isSiteGeneration());
@@ -69,7 +69,8 @@ function createBundleMiddleware(context) {
69
69
  const bundleDefinition = await (0, import_instrumentation.getTracer)().trace({
70
70
  name: import_instrumentation.RequestHandlerSpan.GetBundle,
71
71
  attributes: {
72
- specifier: moduleId.specifier
72
+ specifier: moduleId.specifier,
73
+ url: req.originalUrl
73
74
  }
74
75
  }, () => {
75
76
  return moduleBundler.getModuleBundle(moduleId, {...runtimeEnvironment, bundle: true, sourceMapUrl}, runtimeParams);
@@ -47,7 +47,10 @@ function createMappingMiddleware(context) {
47
47
  const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
48
48
  const {moduleIds} = (0, import_identity.getMappingIdentity)(req);
49
49
  const importMetadata = await (0, import_instrumentation.getTracer)().trace({
50
- name: import_instrumentation.RequestHandlerSpan.GetMapping
50
+ name: import_instrumentation.RequestHandlerSpan.GetMapping,
51
+ attributes: {
52
+ url: req.originalUrl
53
+ }
51
54
  }, () => {
52
55
  return (0, import_shared_utils.getImportMetadataMappings)(moduleIds, runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler);
53
56
  });
@@ -62,7 +62,8 @@ function createModuleMiddleware(context) {
62
62
  const moduleDefinition = await (0, import_instrumentation.getTracer)().trace({
63
63
  name: import_instrumentation.RequestHandlerSpan.GetModule,
64
64
  attributes: {
65
- specifier: moduleId.specifier
65
+ specifier: moduleId.specifier,
66
+ url: req.originalUrl
66
67
  }
67
68
  }, () => {
68
69
  return moduleRegistry.getLinkedModule(moduleId, {...runtimeEnvironment, bundle: false}, runtimeParams);
@@ -70,7 +70,8 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
70
70
  viewResponse = await (0, import_instrumentation.getTracer)().trace({
71
71
  name: import_instrumentation.RequestHandlerSpan.GetView,
72
72
  attributes: {
73
- view: route.id
73
+ view: route.id,
74
+ url: req.originalUrl
74
75
  }
75
76
  }, () => {
76
77
  return resolve.call(viewHandler, viewRequest, route, runtimeEnvironment, runtimeParams);
@@ -0,0 +1,3 @@
1
+ import type { HandlerContext, ViewRequest, ViewResponse } from '@lwrjs/types';
2
+ export default function siteInfoHandler(request: ViewRequest, context: HandlerContext): Promise<ViewResponse>;
3
+ //# sourceMappingURL=route-handler.d.ts.map
@@ -0,0 +1,47 @@
1
+ import { LWC_VERSION, LWR_VERSION, PWA_KIT_RUNTIME_VERSION, NODE_VERSION } from '@lwrjs/config';
2
+ import fs from 'fs';
3
+ const baseHtml = `<!DOCTYPE html>
4
+ <html lang="en">
5
+ <head>
6
+ <meta charset="utf-8" />
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
8
+ <title>Site Information</title>
9
+ </head>
10
+ <body>
11
+ <h1>Site Information</h1>
12
+ <h3>Environment</h3>
13
+ {{ versionInfo }}
14
+ <h3>Metadata</h3>
15
+ <pre>{{ metadata }}</pre>
16
+ </body>
17
+ </html>`;
18
+ export default async function siteInfoHandler(request, context) {
19
+ const versionInfo = {
20
+ 'LWR Version': LWR_VERSION,
21
+ 'LWC Version': LWC_VERSION,
22
+ 'Node Version': NODE_VERSION,
23
+ 'PWA Kit Runtime Version': PWA_KIT_RUNTIME_VERSION,
24
+ };
25
+ let versionInfoString = '';
26
+ for (const key in versionInfo) {
27
+ if (versionInfo[key] !== 'note-provided') {
28
+ versionInfoString += `<p>${key}: ${versionInfo[key]}</p>\n`;
29
+ }
30
+ }
31
+ // Get any provided metadata from site/.metadata/runtime-info.json
32
+ const providedMetadataPath = `${context.rootDir}/site/.metadata/runtime-info.json`;
33
+ let providedMetadata = {};
34
+ if (fs.existsSync(providedMetadataPath)) {
35
+ providedMetadata = JSON.parse(fs.readFileSync(providedMetadataPath, 'utf-8'));
36
+ }
37
+ let infoHtml = baseHtml;
38
+ infoHtml = infoHtml.replace('{{ versionInfo }}', versionInfoString);
39
+ infoHtml = infoHtml.replace('{{ metadata }}', JSON.stringify(providedMetadata, null, 2));
40
+ return {
41
+ body: infoHtml,
42
+ cache: {
43
+ ttl: '200s',
44
+ },
45
+ };
46
+ }
47
+ //# sourceMappingURL=route-handler.js.map
@@ -26,6 +26,7 @@ function createAssetMiddleware(context) {
26
26
  name: RequestHandlerSpan.GetAsset,
27
27
  attributes: {
28
28
  specifier: assetId.specifier,
29
+ url: req.originalUrl,
29
30
  },
30
31
  }, () => {
31
32
  return assetRegistry.getAsset({ ...assetId, signature }, runtimeEnvironment, req.isSiteGeneration());
@@ -40,6 +40,7 @@ function createBundleMiddleware(context) {
40
40
  name: RequestHandlerSpan.GetBundle,
41
41
  attributes: {
42
42
  specifier: moduleId.specifier,
43
+ url: req.originalUrl,
43
44
  },
44
45
  }, () => {
45
46
  return moduleBundler.getModuleBundle(moduleId,
@@ -15,6 +15,9 @@ function createMappingMiddleware(context) {
15
15
  const { moduleIds } = getMappingIdentity(req);
16
16
  const importMetadata = await getTracer().trace({
17
17
  name: RequestHandlerSpan.GetMapping,
18
+ attributes: {
19
+ url: req.originalUrl,
20
+ },
18
21
  }, () => {
19
22
  return getImportMetadataMappings(moduleIds, runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler);
20
23
  });
@@ -38,6 +38,7 @@ function createModuleMiddleware(context) {
38
38
  name: RequestHandlerSpan.GetModule,
39
39
  attributes: {
40
40
  specifier: moduleId.specifier,
41
+ url: req.originalUrl,
41
42
  },
42
43
  }, () => {
43
44
  return moduleRegistry.getLinkedModule(moduleId,
@@ -45,6 +45,7 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
45
45
  name: RequestHandlerSpan.GetView,
46
46
  attributes: {
47
47
  view: route.id,
48
+ url: req.originalUrl,
48
49
  },
49
50
  }, () => {
50
51
  return resolve.call(viewHandler, viewRequest, route, runtimeEnvironment, runtimeParams);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.12.0-alpha.4",
7
+ "version": "0.12.0-alpha.6",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -27,7 +27,11 @@
27
27
  "import": "./build/es/middleware.js",
28
28
  "require": "./build/cjs/middleware.cjs"
29
29
  },
30
- "./package": "./package.cjs"
30
+ "./package": "./package.cjs",
31
+ "./info/route-handler": {
32
+ "import": "./build/es/info/route-handler.js",
33
+ "require": "./build/cjs/info/route-handler.cjs"
34
+ }
31
35
  },
32
36
  "files": [
33
37
  "build/**/*.js",
@@ -39,33 +43,34 @@
39
43
  "build": "tsc -b"
40
44
  },
41
45
  "dependencies": {
42
- "@lwrjs/app-service": "0.12.0-alpha.4",
43
- "@lwrjs/asset-registry": "0.12.0-alpha.4",
44
- "@lwrjs/asset-transformer": "0.12.0-alpha.4",
45
- "@lwrjs/base-view-provider": "0.12.0-alpha.4",
46
- "@lwrjs/base-view-transformer": "0.12.0-alpha.4",
47
- "@lwrjs/client-modules": "0.12.0-alpha.4",
48
- "@lwrjs/config": "0.12.0-alpha.4",
49
- "@lwrjs/diagnostics": "0.12.0-alpha.4",
50
- "@lwrjs/esbuild": "0.12.0-alpha.4",
51
- "@lwrjs/fs-asset-provider": "0.12.0-alpha.4",
52
- "@lwrjs/fs-watch": "0.12.0-alpha.4",
53
- "@lwrjs/html-view-provider": "0.12.0-alpha.4",
54
- "@lwrjs/instrumentation": "0.12.0-alpha.4",
55
- "@lwrjs/loader": "0.12.0-alpha.4",
56
- "@lwrjs/lwc-module-provider": "0.12.0-alpha.4",
57
- "@lwrjs/markdown-view-provider": "0.12.0-alpha.4",
58
- "@lwrjs/module-bundler": "0.12.0-alpha.4",
59
- "@lwrjs/module-registry": "0.12.0-alpha.4",
60
- "@lwrjs/npm-module-provider": "0.12.0-alpha.4",
61
- "@lwrjs/nunjucks-view-provider": "0.12.0-alpha.4",
62
- "@lwrjs/o11y": "0.12.0-alpha.4",
63
- "@lwrjs/resource-registry": "0.12.0-alpha.4",
64
- "@lwrjs/router": "0.12.0-alpha.4",
65
- "@lwrjs/server": "0.12.0-alpha.4",
66
- "@lwrjs/shared-utils": "0.12.0-alpha.4",
67
- "@lwrjs/static": "0.12.0-alpha.4",
68
- "@lwrjs/view-registry": "0.12.0-alpha.4",
46
+ "@lwrjs/app-service": "0.12.0-alpha.6",
47
+ "@lwrjs/asset-registry": "0.12.0-alpha.6",
48
+ "@lwrjs/asset-transformer": "0.12.0-alpha.6",
49
+ "@lwrjs/base-view-provider": "0.12.0-alpha.6",
50
+ "@lwrjs/base-view-transformer": "0.12.0-alpha.6",
51
+ "@lwrjs/client-modules": "0.12.0-alpha.6",
52
+ "@lwrjs/config": "0.12.0-alpha.6",
53
+ "@lwrjs/diagnostics": "0.12.0-alpha.6",
54
+ "@lwrjs/esbuild": "0.12.0-alpha.6",
55
+ "@lwrjs/fs-asset-provider": "0.12.0-alpha.6",
56
+ "@lwrjs/fs-watch": "0.12.0-alpha.6",
57
+ "@lwrjs/html-view-provider": "0.12.0-alpha.6",
58
+ "@lwrjs/instrumentation": "0.12.0-alpha.6",
59
+ "@lwrjs/loader": "0.12.0-alpha.6",
60
+ "@lwrjs/lwc-module-provider": "0.12.0-alpha.6",
61
+ "@lwrjs/lwc-ssr": "0.12.0-alpha.6",
62
+ "@lwrjs/markdown-view-provider": "0.12.0-alpha.6",
63
+ "@lwrjs/module-bundler": "0.12.0-alpha.6",
64
+ "@lwrjs/module-registry": "0.12.0-alpha.6",
65
+ "@lwrjs/npm-module-provider": "0.12.0-alpha.6",
66
+ "@lwrjs/nunjucks-view-provider": "0.12.0-alpha.6",
67
+ "@lwrjs/o11y": "0.12.0-alpha.6",
68
+ "@lwrjs/resource-registry": "0.12.0-alpha.6",
69
+ "@lwrjs/router": "0.12.0-alpha.6",
70
+ "@lwrjs/server": "0.12.0-alpha.6",
71
+ "@lwrjs/shared-utils": "0.12.0-alpha.6",
72
+ "@lwrjs/static": "0.12.0-alpha.6",
73
+ "@lwrjs/view-registry": "0.12.0-alpha.6",
69
74
  "chokidar": "^3.5.3",
70
75
  "esbuild": "^0.9.7",
71
76
  "fs-extra": "^11.1.1",
@@ -75,7 +80,7 @@
75
80
  "ws": "^8.8.1"
76
81
  },
77
82
  "devDependencies": {
78
- "@lwrjs/types": "0.12.0-alpha.4",
83
+ "@lwrjs/types": "0.12.0-alpha.6",
79
84
  "@types/ws": "^8.5.3"
80
85
  },
81
86
  "peerDependencies": {
@@ -87,5 +92,5 @@
87
92
  "volta": {
88
93
  "extends": "../../../package.json"
89
94
  },
90
- "gitHead": "7b68e0ffa5e4d61ae97a4b020f9690ee7b08d5da"
95
+ "gitHead": "d9428f6168feea04d3de54129a5861eb4590b26c"
91
96
  }