@lwrjs/core 0.12.0-alpha.1 → 0.12.0-alpha.11

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.
@@ -26,7 +26,9 @@ __markAsModule(exports);
26
26
  __export(exports, {
27
27
  createProviderContext: () => createProviderContext
28
28
  });
29
+ var import_fs = __toModule(require("fs"));
29
30
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
31
+ var import_site_metadata = __toModule(require("@lwrjs/static/site-metadata"));
30
32
  function createProviderContext(serverContext) {
31
33
  const {
32
34
  assets,
@@ -43,7 +45,8 @@ function createProviderContext(serverContext) {
43
45
  esmLoader,
44
46
  environment,
45
47
  basePath,
46
- bundleConfig
48
+ bundleConfig,
49
+ staticSiteGenerator
47
50
  } = serverContext.appConfig;
48
51
  const {onModuleDefinitionChange, onModuleSourceChange} = serverContext.appObserver;
49
52
  const {
@@ -52,6 +55,7 @@ function createProviderContext(serverContext) {
52
55
  notifyViewSourceChanged,
53
56
  notifyAssetSourceChanged
54
57
  } = serverContext.appEmitter;
58
+ const siteMetadata = staticSiteGenerator.outputDir && import_fs.default.existsSync(staticSiteGenerator.outputDir) ? new import_site_metadata.SiteMetadataImpl({rootDir: staticSiteGenerator.outputDir}) : void 0;
55
59
  return {
56
60
  appObserver: (0, import_shared_utils.deepFreeze)({onModuleDefinitionChange, onModuleSourceChange}),
57
61
  appEmitter: {
@@ -83,6 +87,7 @@ function createProviderContext(serverContext) {
83
87
  bundleConfig
84
88
  }),
85
89
  runtimeEnvironment: (0, import_shared_utils.deepFreeze)(serverContext.runtimeEnvironment),
86
- watcherFactory: serverContext.watcherFactory
90
+ watcherFactory: serverContext.watcherFactory,
91
+ siteMetadata
87
92
  };
88
93
  }
@@ -70,10 +70,15 @@ async function initContext(appConfig, runtimeEnvironment, globalData) {
70
70
  const skipValidation = true;
71
71
  await (0, import_config.executeConfigHooks)(hooks, appConfig, runtimeEnvironment, globalData, skipValidation);
72
72
  (0, import_config.executeInstrumentationHooks)(hooks);
73
- (0, import_config.executeStartHooks)(hooks, appConfig, runtimeEnvironment);
74
73
  }
75
74
  const services = await (0, import_modules.loadServices)(appConfig);
76
75
  const serverContext = (0, import_instrumentation.getTracer)().trace({name: import_instrumentation.CoreSpan.CreateServerContext}, () => (0, import_server2.createServerContext)(appConfig, runtimeEnvironment, globalData));
76
+ const routeHandlers = await (0, import_modules.loadRouteHandlers)(appConfig);
77
+ serverContext.routeHandlers = routeHandlers;
78
+ if (hooks.length) {
79
+ await (0, import_config.executeContextHooks)(hooks, serverContext);
80
+ (0, import_config.executeStartHooks)(hooks, appConfig, runtimeEnvironment);
81
+ }
77
82
  const providerContext = (0, import_provider.createProviderContext)(serverContext);
78
83
  const {moduleRegistry, assetRegistry, resourceRegistry, viewRegistry, moduleBundler} = serverContext;
79
84
  const moduleProviders = createServices(services.moduleProviders, providerContext);
@@ -94,8 +99,6 @@ async function initContext(appConfig, runtimeEnvironment, globalData) {
94
99
  viewRegistry.addViewProviders(viewProviders);
95
100
  viewRegistry.addViewTransformers(viewTransformers);
96
101
  await serverContext.viewRegistry.initializeViewProviders();
97
- const routeHandlers = await (0, import_modules.loadRouteHandlers)(appConfig);
98
- serverContext.routeHandlers = routeHandlers;
99
102
  return serverContext;
100
103
  }
101
104
  var LwrApp = class {
@@ -0,0 +1,149 @@
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
+ <style>
38
+ body {
39
+ font-family: Arial, sans-serif;
40
+ margin: 0;
41
+ padding: 20px;
42
+ background-color: #f9f9f9;
43
+ color: #333;
44
+ display: flex;
45
+ }
46
+
47
+ .container {
48
+ max-width: 800px;
49
+ width: 100%;
50
+ }
51
+
52
+ h1, h2 {
53
+ color: #555;
54
+ margin-bottom: 16px;
55
+ }
56
+
57
+ ul {
58
+ list-style-type: none;
59
+ padding: 0;
60
+ }
61
+
62
+ li {
63
+ background-color: #fff;
64
+ border: 1px solid #ddd;
65
+ margin-bottom: 10px;
66
+ padding: 10px;
67
+ border-radius: 4px;
68
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
69
+ display: flex;
70
+ }
71
+
72
+ .key {
73
+ margin-right: 10px;
74
+ color: #777;
75
+ font-weight: normal;
76
+ min-width: 200px;
77
+ }
78
+
79
+ .val {
80
+ font-weight: bold;
81
+ color: steelblue;
82
+ font-size: 1.1em;
83
+ flex-grow: 1;
84
+ text-align: left;
85
+ }
86
+
87
+ .data-container {
88
+ padding: 20px;
89
+ border: 1px solid #333;
90
+ border-radius: 5px;
91
+ white-space: pre;
92
+ font-family: monospace;
93
+ text-align: justify;
94
+ };
95
+ </style>
96
+ </head>
97
+ <body>
98
+ <div class="container">
99
+ <h1>Site Information</h1>
100
+ <h2>Environment</h2>
101
+ {{ versionInfo }}
102
+ <h2>Metadata</h2>
103
+ {{ metadata }}
104
+ </div>
105
+ </body>
106
+ </html>
107
+ `;
108
+ async function siteInfoHandler(_request, context) {
109
+ const versionInfo = {
110
+ "LWR Version": import_config.LWR_VERSION,
111
+ "LWC Version": import_config.LWC_VERSION,
112
+ "Node Version": import_config.NODE_VERSION,
113
+ "PWA Kit Runtime Version": import_config.PWA_KIT_RUNTIME_VERSION
114
+ };
115
+ let versionInfoString = "<ul>";
116
+ for (const key in versionInfo) {
117
+ if (versionInfo[key] !== "note-provided") {
118
+ versionInfoString += `<li><span class="key">${key}:</span><span class="val">${versionInfo[key]}</span></li>
119
+ `;
120
+ }
121
+ }
122
+ versionInfoString += "</ul>";
123
+ const providedMetadataPath = `${context.rootDir}/site/.metadata/runtime-info.json`;
124
+ let providedMetadata = {};
125
+ if (import_fs.default.existsSync(providedMetadataPath)) {
126
+ providedMetadata = JSON.parse(import_fs.default.readFileSync(providedMetadataPath, "utf-8"));
127
+ }
128
+ let providedInfoString = "<ul>";
129
+ for (const key in providedMetadata) {
130
+ if (providedMetadata[key] !== "note-provided") {
131
+ const value = typeof providedMetadata[key] === "object" ? `<div class="data-container val">${JSON.stringify(providedMetadata[key], null, 2)}</div>` : `<span class="val">${providedMetadata[key]}</span>`;
132
+ providedInfoString += `<li><span class="key">${key}:</span>${value}</li>
133
+ `;
134
+ }
135
+ }
136
+ providedInfoString += "</ul>";
137
+ let infoHtml = baseHtml;
138
+ infoHtml = infoHtml.replace("{{ versionInfo }}", versionInfoString);
139
+ infoHtml = infoHtml.replace("{{ metadata }}", providedInfoString);
140
+ return {
141
+ body: infoHtml,
142
+ headers: {
143
+ "content-type": `text/html; charset=utf-8`
144
+ },
145
+ cache: {
146
+ ttl: "200s"
147
+ }
148
+ };
149
+ }
@@ -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());
@@ -53,6 +53,11 @@ function createBundleMiddleware(context) {
53
53
  res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_JSON().message);
54
54
  return;
55
55
  }
56
+ if (!req.validateApiVersion(appConfig)) {
57
+ res.status(400);
58
+ res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion).message);
59
+ return;
60
+ }
56
61
  const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
57
62
  const importer = req.query.importer ? await (0, import_request.getRequestImporter)(req, moduleRegistry, runtimeParams) : void 0;
58
63
  const {moduleId, signature} = (0, import_identity.getModuleIdentity)(req, importer);
@@ -64,7 +69,8 @@ function createBundleMiddleware(context) {
64
69
  const bundleDefinition = await (0, import_instrumentation.getTracer)().trace({
65
70
  name: import_instrumentation.RequestHandlerSpan.GetBundle,
66
71
  attributes: {
67
- specifier: moduleId.specifier
72
+ specifier: moduleId.specifier,
73
+ url: req.originalUrl
68
74
  }
69
75
  }, () => {
70
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
  });
@@ -47,6 +47,11 @@ function createModuleMiddleware(context) {
47
47
  res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_JSON().message);
48
48
  return;
49
49
  }
50
+ if (!req.validateApiVersion(appConfig)) {
51
+ res.status(400);
52
+ res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion).message);
53
+ return;
54
+ }
50
55
  const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
51
56
  const importer = req.query.importer ? await (0, import_request.getRequestImporter)(req, moduleRegistry, runtimeParams) : void 0;
52
57
  const {moduleId, signature} = (0, import_identity.getModuleIdentity)(req, importer);
@@ -57,7 +62,8 @@ function createModuleMiddleware(context) {
57
62
  const moduleDefinition = await (0, import_instrumentation.getTracer)().trace({
58
63
  name: import_instrumentation.RequestHandlerSpan.GetModule,
59
64
  attributes: {
60
- specifier: moduleId.specifier
65
+ specifier: moduleId.specifier,
66
+ url: req.originalUrl
61
67
  }
62
68
  }, () => {
63
69
  return moduleRegistry.getLinkedModule(moduleId, {...runtimeEnvironment, bundle: false}, runtimeParams);
@@ -75,7 +75,7 @@ function getResourceIdentity(req) {
75
75
  }
76
76
  function getAssetIdentity(req) {
77
77
  const {signature, immutable, assetType: type} = req.params;
78
- const specifier = type ? "/" + req.params[0] : req.originalUrl.split("?")[0];
78
+ const specifier = type ? process.platform === "win32" ? req.params[0] : "/" + req.params[0] : req.originalUrl.split("?")[0];
79
79
  if (validateSpecifier(specifier) === false) {
80
80
  throw (0, import_diagnostics.createSingleDiagnosticError)({
81
81
  description: import_diagnostics.descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier)
@@ -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);
@@ -1,9 +1,14 @@
1
+ import fs from 'fs';
1
2
  import { deepFreeze } from '@lwrjs/shared-utils';
3
+ import { SiteMetadataImpl } from '@lwrjs/static/site-metadata';
2
4
  export function createProviderContext(serverContext) {
3
5
  // This is a subset of config to user-land code
4
- const { assets, cacheDir, i18n, lwc: { modules = [] }, routes, errorRoutes, rootDir, contentDir, layoutsDir, locker, amdLoader, esmLoader, environment, basePath, bundleConfig, } = serverContext.appConfig;
6
+ const { assets, cacheDir, i18n, lwc: { modules = [] }, routes, errorRoutes, rootDir, contentDir, layoutsDir, locker, amdLoader, esmLoader, environment, basePath, bundleConfig, staticSiteGenerator, } = serverContext.appConfig;
5
7
  const { onModuleDefinitionChange, onModuleSourceChange } = serverContext.appObserver;
6
8
  const { notifyModuleDefinitionChanged, notifyModuleSourceChanged, notifyViewSourceChanged, notifyAssetSourceChanged, } = serverContext.appEmitter;
9
+ const siteMetadata = staticSiteGenerator.outputDir && fs.existsSync(staticSiteGenerator.outputDir)
10
+ ? new SiteMetadataImpl({ rootDir: staticSiteGenerator.outputDir })
11
+ : undefined;
7
12
  return {
8
13
  appObserver: deepFreeze({ onModuleDefinitionChange, onModuleSourceChange }),
9
14
  appEmitter: {
@@ -36,6 +41,7 @@ export function createProviderContext(serverContext) {
36
41
  }),
37
42
  runtimeEnvironment: deepFreeze(serverContext.runtimeEnvironment),
38
43
  watcherFactory: serverContext.watcherFactory,
44
+ siteMetadata,
39
45
  };
40
46
  }
41
47
  //# sourceMappingURL=provider.js.map
package/build/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getFeatureFlags, DEFAULT_LWR_BOOTSTRAP_CONFIG } from '@lwrjs/shared-utils';
2
2
  import { createInternalServer } from '@lwrjs/server';
3
3
  import { LwrServerError, createSingleDiagnosticError, descriptions, logger } from '@lwrjs/diagnostics';
4
- import { loadConfig, executeConfigHooks, executeStartHooks, executeInstrumentationHooks, } from '@lwrjs/config';
4
+ import { loadConfig, executeConfigHooks, executeStartHooks, executeInstrumentationHooks, executeContextHooks, } from '@lwrjs/config';
5
5
  import { loadHooks, loadServices, loadRouteHandlers } from '@lwrjs/config/modules';
6
6
  import SiteGenerator from './tools/static-generation.js';
7
7
  import { warmupServer } from './tools/server-warmup.js';
@@ -47,12 +47,18 @@ async function initContext(appConfig, runtimeEnvironment, globalData) {
47
47
  const skipValidation = true; // skip for config hook, since `executeStartHooks` hook will validate
48
48
  await executeConfigHooks(hooks, appConfig, runtimeEnvironment, globalData, skipValidation);
49
49
  executeInstrumentationHooks(hooks);
50
- executeStartHooks(hooks, appConfig, runtimeEnvironment);
51
50
  }
52
51
  // load all configurable modules
53
52
  const services = await loadServices(appConfig);
54
53
  // create all framework components(ie. registries)
55
54
  const serverContext = getTracer().trace({ name: CoreSpan.CreateServerContext }, () => createServerContext(appConfig, runtimeEnvironment, globalData));
55
+ // set routes on server context
56
+ const routeHandlers = await loadRouteHandlers(appConfig);
57
+ serverContext.routeHandlers = routeHandlers;
58
+ if (hooks.length) {
59
+ await executeContextHooks(hooks, serverContext);
60
+ executeStartHooks(hooks, appConfig, runtimeEnvironment);
61
+ }
56
62
  // create public subset of configurations
57
63
  const providerContext = createProviderContext(serverContext);
58
64
  const { moduleRegistry, assetRegistry, resourceRegistry, viewRegistry, moduleBundler } = serverContext;
@@ -82,9 +88,6 @@ async function initContext(appConfig, runtimeEnvironment, globalData) {
82
88
  viewRegistry.addViewTransformers(viewTransformers);
83
89
  // invoke async initialization
84
90
  await serverContext.viewRegistry.initializeViewProviders();
85
- // set routes on server context
86
- const routeHandlers = await loadRouteHandlers(appConfig);
87
- serverContext.routeHandlers = routeHandlers;
88
91
  return serverContext;
89
92
  }
90
93
  export class LwrApp {
@@ -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,123 @@
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
+ <style>
10
+ body {
11
+ font-family: Arial, sans-serif;
12
+ margin: 0;
13
+ padding: 20px;
14
+ background-color: #f9f9f9;
15
+ color: #333;
16
+ display: flex;
17
+ }
18
+
19
+ .container {
20
+ max-width: 800px;
21
+ width: 100%;
22
+ }
23
+
24
+ h1, h2 {
25
+ color: #555;
26
+ margin-bottom: 16px;
27
+ }
28
+
29
+ ul {
30
+ list-style-type: none;
31
+ padding: 0;
32
+ }
33
+
34
+ li {
35
+ background-color: #fff;
36
+ border: 1px solid #ddd;
37
+ margin-bottom: 10px;
38
+ padding: 10px;
39
+ border-radius: 4px;
40
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
41
+ display: flex;
42
+ }
43
+
44
+ .key {
45
+ margin-right: 10px;
46
+ color: #777;
47
+ font-weight: normal;
48
+ min-width: 200px;
49
+ }
50
+
51
+ .val {
52
+ font-weight: bold;
53
+ color: steelblue;
54
+ font-size: 1.1em;
55
+ flex-grow: 1;
56
+ text-align: left;
57
+ }
58
+
59
+ .data-container {
60
+ padding: 20px;
61
+ border: 1px solid #333;
62
+ border-radius: 5px;
63
+ white-space: pre;
64
+ font-family: monospace;
65
+ text-align: justify;
66
+ };
67
+ </style>
68
+ </head>
69
+ <body>
70
+ <div class="container">
71
+ <h1>Site Information</h1>
72
+ <h2>Environment</h2>
73
+ {{ versionInfo }}
74
+ <h2>Metadata</h2>
75
+ {{ metadata }}
76
+ </div>
77
+ </body>
78
+ </html>
79
+ `;
80
+ export default async function siteInfoHandler(_request, context) {
81
+ const versionInfo = {
82
+ 'LWR Version': LWR_VERSION,
83
+ 'LWC Version': LWC_VERSION,
84
+ 'Node Version': NODE_VERSION,
85
+ 'PWA Kit Runtime Version': PWA_KIT_RUNTIME_VERSION,
86
+ };
87
+ let versionInfoString = '<ul>';
88
+ for (const key in versionInfo) {
89
+ if (versionInfo[key] !== 'note-provided') {
90
+ versionInfoString += `<li><span class="key">${key}:</span><span class="val">${versionInfo[key]}</span></li>\n`;
91
+ }
92
+ }
93
+ versionInfoString += '</ul>';
94
+ // Get any provided metadata from site/.metadata/runtime-info.json
95
+ const providedMetadataPath = `${context.rootDir}/site/.metadata/runtime-info.json`;
96
+ let providedMetadata = {};
97
+ if (fs.existsSync(providedMetadataPath)) {
98
+ providedMetadata = JSON.parse(fs.readFileSync(providedMetadataPath, 'utf-8'));
99
+ }
100
+ let providedInfoString = '<ul>';
101
+ for (const key in providedMetadata) {
102
+ if (providedMetadata[key] !== 'note-provided') {
103
+ const value = typeof providedMetadata[key] === 'object'
104
+ ? `<div class="data-container val">${JSON.stringify(providedMetadata[key], null, 2)}</div>`
105
+ : `<span class="val">${providedMetadata[key]}</span>`;
106
+ providedInfoString += `<li><span class="key">${key}:</span>${value}</li>\n`;
107
+ }
108
+ }
109
+ providedInfoString += '</ul>';
110
+ let infoHtml = baseHtml;
111
+ infoHtml = infoHtml.replace('{{ versionInfo }}', versionInfoString);
112
+ infoHtml = infoHtml.replace('{{ metadata }}', providedInfoString);
113
+ return {
114
+ body: infoHtml,
115
+ headers: {
116
+ 'content-type': `text/html; charset=utf-8`,
117
+ },
118
+ cache: {
119
+ ttl: '200s',
120
+ },
121
+ };
122
+ }
123
+ //# 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());
@@ -20,6 +20,12 @@ function createBundleMiddleware(context) {
20
20
  res.send(descriptions.UNRESOLVABLE.INVALID_JSON().message);
21
21
  return;
22
22
  }
23
+ if (!req.validateApiVersion(appConfig)) {
24
+ res.status(400);
25
+ res.send(descriptions.UNRESOLVABLE.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion)
26
+ .message);
27
+ return;
28
+ }
23
29
  const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(defaultRuntimeEnvironment);
24
30
  const importer = req.query.importer
25
31
  ? await getRequestImporter(req, moduleRegistry, runtimeParams)
@@ -34,6 +40,7 @@ function createBundleMiddleware(context) {
34
40
  name: RequestHandlerSpan.GetBundle,
35
41
  attributes: {
36
42
  specifier: moduleId.specifier,
43
+ url: req.originalUrl,
37
44
  },
38
45
  }, () => {
39
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
  });
@@ -19,6 +19,12 @@ function createModuleMiddleware(context) {
19
19
  res.send(descriptions.UNRESOLVABLE.INVALID_JSON().message);
20
20
  return;
21
21
  }
22
+ if (!req.validateApiVersion(appConfig)) {
23
+ res.status(400);
24
+ res.send(descriptions.UNRESOLVABLE.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion)
25
+ .message);
26
+ return;
27
+ }
22
28
  const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(defaultRuntimeEnvironment);
23
29
  const importer = req.query.importer
24
30
  ? await getRequestImporter(req, moduleRegistry, runtimeParams)
@@ -32,6 +38,7 @@ function createModuleMiddleware(context) {
32
38
  name: RequestHandlerSpan.GetModule,
33
39
  attributes: {
34
40
  specifier: moduleId.specifier,
41
+ url: req.originalUrl,
35
42
  },
36
43
  }, () => {
37
44
  return moduleRegistry.getLinkedModule(moduleId,
@@ -44,7 +44,11 @@ export function getResourceIdentity(req) {
44
44
  }
45
45
  export function getAssetIdentity(req) {
46
46
  const { signature, immutable, assetType: type } = req.params;
47
- const specifier = type ? '/' + req.params[0] : req.originalUrl.split('?')[0];
47
+ const specifier = type
48
+ ? process.platform === 'win32'
49
+ ? req.params[0]
50
+ : '/' + req.params[0]
51
+ : req.originalUrl.split('?')[0];
48
52
  if (validateSpecifier(specifier) === false) {
49
53
  throw createSingleDiagnosticError({
50
54
  description: descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier),
@@ -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.1",
7
+ "version": "0.12.0-alpha.11",
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.1",
43
- "@lwrjs/asset-registry": "0.12.0-alpha.1",
44
- "@lwrjs/asset-transformer": "0.12.0-alpha.1",
45
- "@lwrjs/base-view-provider": "0.12.0-alpha.1",
46
- "@lwrjs/base-view-transformer": "0.12.0-alpha.1",
47
- "@lwrjs/client-modules": "0.12.0-alpha.1",
48
- "@lwrjs/config": "0.12.0-alpha.1",
49
- "@lwrjs/diagnostics": "0.12.0-alpha.1",
50
- "@lwrjs/esbuild": "0.12.0-alpha.1",
51
- "@lwrjs/fs-asset-provider": "0.12.0-alpha.1",
52
- "@lwrjs/fs-watch": "0.12.0-alpha.1",
53
- "@lwrjs/html-view-provider": "0.12.0-alpha.1",
54
- "@lwrjs/instrumentation": "0.12.0-alpha.1",
55
- "@lwrjs/loader": "0.12.0-alpha.1",
56
- "@lwrjs/lwc-module-provider": "0.12.0-alpha.1",
57
- "@lwrjs/markdown-view-provider": "0.12.0-alpha.1",
58
- "@lwrjs/module-bundler": "0.12.0-alpha.1",
59
- "@lwrjs/module-registry": "0.12.0-alpha.1",
60
- "@lwrjs/npm-module-provider": "0.12.0-alpha.1",
61
- "@lwrjs/nunjucks-view-provider": "0.12.0-alpha.1",
62
- "@lwrjs/o11y": "0.12.0-alpha.1",
63
- "@lwrjs/resource-registry": "0.12.0-alpha.1",
64
- "@lwrjs/router": "0.12.0-alpha.1",
65
- "@lwrjs/server": "0.12.0-alpha.1",
66
- "@lwrjs/shared-utils": "0.12.0-alpha.1",
67
- "@lwrjs/static": "0.12.0-alpha.1",
68
- "@lwrjs/view-registry": "0.12.0-alpha.1",
46
+ "@lwrjs/app-service": "0.12.0-alpha.11",
47
+ "@lwrjs/asset-registry": "0.12.0-alpha.11",
48
+ "@lwrjs/asset-transformer": "0.12.0-alpha.11",
49
+ "@lwrjs/base-view-provider": "0.12.0-alpha.11",
50
+ "@lwrjs/base-view-transformer": "0.12.0-alpha.11",
51
+ "@lwrjs/client-modules": "0.12.0-alpha.11",
52
+ "@lwrjs/config": "0.12.0-alpha.11",
53
+ "@lwrjs/diagnostics": "0.12.0-alpha.11",
54
+ "@lwrjs/esbuild": "0.12.0-alpha.11",
55
+ "@lwrjs/fs-asset-provider": "0.12.0-alpha.11",
56
+ "@lwrjs/fs-watch": "0.12.0-alpha.11",
57
+ "@lwrjs/html-view-provider": "0.12.0-alpha.11",
58
+ "@lwrjs/instrumentation": "0.12.0-alpha.11",
59
+ "@lwrjs/loader": "0.12.0-alpha.11",
60
+ "@lwrjs/lwc-module-provider": "0.12.0-alpha.11",
61
+ "@lwrjs/lwc-ssr": "0.12.0-alpha.11",
62
+ "@lwrjs/markdown-view-provider": "0.12.0-alpha.11",
63
+ "@lwrjs/module-bundler": "0.12.0-alpha.11",
64
+ "@lwrjs/module-registry": "0.12.0-alpha.11",
65
+ "@lwrjs/npm-module-provider": "0.12.0-alpha.11",
66
+ "@lwrjs/nunjucks-view-provider": "0.12.0-alpha.11",
67
+ "@lwrjs/o11y": "0.12.0-alpha.11",
68
+ "@lwrjs/resource-registry": "0.12.0-alpha.11",
69
+ "@lwrjs/router": "0.12.0-alpha.11",
70
+ "@lwrjs/server": "0.12.0-alpha.11",
71
+ "@lwrjs/shared-utils": "0.12.0-alpha.11",
72
+ "@lwrjs/static": "0.12.0-alpha.11",
73
+ "@lwrjs/view-registry": "0.12.0-alpha.11",
69
74
  "chokidar": "^3.5.3",
70
75
  "esbuild": "^0.9.7",
71
76
  "fs-extra": "^11.1.1",
@@ -75,17 +80,17 @@
75
80
  "ws": "^8.8.1"
76
81
  },
77
82
  "devDependencies": {
78
- "@lwrjs/types": "0.12.0-alpha.1",
83
+ "@lwrjs/types": "0.12.0-alpha.11",
79
84
  "@types/ws": "^8.5.3"
80
85
  },
81
86
  "peerDependencies": {
82
87
  "lwc": ">= 2.x"
83
88
  },
84
89
  "engines": {
85
- "node": ">=16.0.0"
90
+ "node": ">=18.0.0"
86
91
  },
87
92
  "volta": {
88
93
  "extends": "../../../package.json"
89
94
  },
90
- "gitHead": "138cc3716e923d0367e8279aaf2d6be21e74f440"
95
+ "gitHead": "781951a5ef92ce735cbffce7c7a2a32c60bd3c16"
91
96
  }