@lwrjs/core 0.5.11-alpha.2 → 0.6.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.
@@ -1,8 +1,13 @@
1
1
  import http from 'http';
2
2
  import https from 'https';
3
+ import { DiagnosticsError } from '@lwrjs/diagnostics';
3
4
  export default class NetworkDispatcher {
4
5
  constructor(port, internalRequestKey) {
5
6
  this.port = port || 3000;
7
+ const httpClient = this.port == 443 ? https : http;
8
+ this.pool = new httpClient.Agent({
9
+ maxSockets: 25,
10
+ });
6
11
  this.internalRequestKey = internalRequestKey || '';
7
12
  }
8
13
  dispatchUrl(url, method, lang) {
@@ -11,6 +16,7 @@ export default class NetworkDispatcher {
11
16
  host: 'localhost',
12
17
  port: this.port,
13
18
  path: url,
19
+ agent: this.pool,
14
20
  headers: {
15
21
  'Accept-Language': lang,
16
22
  // pass private key to get access to internal metadata
@@ -20,24 +26,42 @@ export default class NetworkDispatcher {
20
26
  return new Promise((resolve, reject) => {
21
27
  const httpClient = options.port == 443 ? https : http;
22
28
  const bodyChunks = [];
29
+ // console.log(`[INFO][NetworkDispatcher] Request: [${method}][${lang}] ${url}`);
23
30
  const req = httpClient.request(options, (res) => {
24
31
  res.on('data', (chunk) => {
25
32
  bodyChunks.push(chunk);
26
33
  });
27
34
  res.on('end', () => {
35
+ // console.log(`[END][NetworkDispatcher] Request: [${method}][${lang}] ${url}`);
28
36
  const body = Buffer.concat(bodyChunks).toString();
29
37
  try {
30
38
  const jsonResponse = JSON.parse(body);
31
39
  resolve(jsonResponse);
32
40
  }
33
41
  catch (e) {
34
- console.error(`[NetworkDispatcher] unexpected response body: '${body}'`, e);
42
+ console.error(`[ERROR][NetworkDispatcher] unexpected response body: [${method}][${lang}] ${url}: '${body}'`);
43
+ if (e instanceof DiagnosticsError) {
44
+ console.log('LWR Diagnostic Error: ');
45
+ console.log(e.diagnostics);
46
+ console.log(e.stack);
47
+ }
48
+ else {
49
+ console.error(e);
50
+ }
35
51
  resolve({});
36
52
  }
37
53
  });
38
54
  });
39
55
  req.on('error', (err) => {
40
- console.error('Error occurred fetching metadata: ' + err.message);
56
+ console.error(`[ERROR][NetworkDispatcher] Request: [${method}][${lang}] ${url}`);
57
+ if (err instanceof DiagnosticsError) {
58
+ console.log('LWR Diagnostic Error: ');
59
+ console.log(err.diagnostics);
60
+ console.log(err.stack);
61
+ }
62
+ else {
63
+ console.error(err);
64
+ }
41
65
  reject(err);
42
66
  });
43
67
  req.end();
@@ -3,4 +3,9 @@ import { Readable } from 'stream';
3
3
  import { FsContext } from '@lwrjs/types';
4
4
  export declare function writeStream(readStream: Readable, fullPath: string): Promise<void>;
5
5
  export declare function writeResponse(context: FsContext, fullPath: string): Promise<void>;
6
+ /**
7
+ * @param {*} o - Item to check if it's an object
8
+ * @returns {boolean}
9
+ */
10
+ export declare function isObject(o: unknown): boolean;
6
11
  //# sourceMappingURL=stream.d.ts.map
@@ -14,7 +14,19 @@ export async function writeResponse(context, fullPath) {
14
14
  }
15
15
  else if (context.fs?.body) {
16
16
  const body = context.fs?.body;
17
- fs.writeFileSync(fullPath, body, 'utf-8');
17
+ if (isObject(body)) {
18
+ fs.writeFileSync(fullPath, JSON.stringify(body), 'utf-8');
19
+ }
20
+ else {
21
+ fs.writeFileSync(fullPath, body, 'utf-8');
22
+ }
18
23
  }
19
24
  }
25
+ /**
26
+ * @param {*} o - Item to check if it's an object
27
+ * @returns {boolean}
28
+ */
29
+ export function isObject(o) {
30
+ return typeof o === 'object' && o !== null && !Array.isArray(o);
31
+ }
20
32
  //# sourceMappingURL=stream.js.map
@@ -15,13 +15,13 @@ interface ConfigMap {
15
15
  bootstrap: NormalizedLwrAppBootstrapConfig;
16
16
  locker: RequiredLwrLockerConfig;
17
17
  }
18
- export declare const ROOT_ATTRIBUTE_KEYS: ["amdLoader", "apiVersion", "assets", "assetProviders", "bundleConfig", "cacheDir", "contentDir", "environment", "errorRoutes", "esmLoader", "staticSiteGenerator", "globalData", "globalDataDir", "hooks", "ignoreLwrConfigFile", "lwrConfigFile", "layoutsDir", "locker", "lwc", "lwrVersion", "moduleProviders", "port", "resourceProviders", "rootDir", "routes", "serverMode", "serverType", "templateEngine", "viewProviders"];
18
+ export declare const ROOT_ATTRIBUTE_KEYS: ["amdLoader", "apiVersion", "assets", "assetProviders", "assetTransformers", "bundleConfig", "cacheDir", "contentDir", "environment", "errorRoutes", "esmLoader", "staticSiteGenerator", "globalData", "globalDataDir", "hooks", "ignoreLwrConfigFile", "lwrConfigFile", "layoutsDir", "locker", "lwc", "lwrVersion", "moduleProviders", "port", "resourceProviders", "rootDir", "routes", "serverMode", "serverType", "templateEngine", "viewProviders", "viewTransformers"];
19
19
  export declare const ASSET_DIR_ATTRIBUTE_KEYS: ["alias", "dir", "urlPath"];
20
20
  export declare const ASSET_FILE_ATTRIBUTE_KEYS: ["alias", "file", "urlPath"];
21
21
  export declare const LOCKER_ATTRIBUTE_KEYS: ["enabled", "trustedComponents", "clientOnly"];
22
22
  export declare const ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "contentTemplate", "id", "cache", "layoutTemplate", "method", "path", "rootComponent", "routeHandler", "properties"];
23
23
  export declare const ERROR_ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "contentTemplate", "id", "layoutTemplate", "rootComponent", "routeHandler", "status", "properties", "cache"];
24
- export declare const BOOTSTRAP_ATTRIBUTE_KEYS: ["autoBoot", "syntheticShadow", "workers", "services", "configAsSrc"];
24
+ export declare const BOOTSTRAP_ATTRIBUTE_KEYS: ["autoBoot", "syntheticShadow", "workers", "services", "configAsSrc", "experimentalSSR"];
25
25
  export declare class ValidationContext {
26
26
  diagnostics: Diagnostic[];
27
27
  sourceText: string;
@@ -11,6 +11,7 @@ export const ROOT_ATTRIBUTE_KEYS = createKeys('root', [
11
11
  'apiVersion',
12
12
  'assets',
13
13
  'assetProviders',
14
+ 'assetTransformers',
14
15
  'bundleConfig',
15
16
  'cacheDir',
16
17
  'contentDir',
@@ -36,6 +37,7 @@ export const ROOT_ATTRIBUTE_KEYS = createKeys('root', [
36
37
  'serverType',
37
38
  'templateEngine',
38
39
  'viewProviders',
40
+ 'viewTransformers',
39
41
  ]);
40
42
  export const ASSET_DIR_ATTRIBUTE_KEYS = createKeys('assetDir', ['alias', 'dir', 'urlPath']);
41
43
  export const ASSET_FILE_ATTRIBUTE_KEYS = createKeys('assetFile', ['alias', 'file', 'urlPath']);
@@ -69,6 +71,7 @@ export const BOOTSTRAP_ATTRIBUTE_KEYS = createKeys('bootstrap', [
69
71
  'workers',
70
72
  'services',
71
73
  'configAsSrc',
74
+ 'experimentalSSR',
72
75
  ]);
73
76
  const SPECIFIER_REGEX = /^@?[\w-]+(\/[\w-]+)*$/;
74
77
  function isNotEmptyString(node) {
@@ -21,6 +21,7 @@ function validateBootstrap(node, validationContext, propPrefix) {
21
21
  validationContext.assertValidKeys(node, 'bootstrap', BOOTSTRAP_ATTRIBUTE_KEYS);
22
22
  validationContext.assertArrayOfSpecifiers(findNode(node, ['services']), `${propPrefix}.services`);
23
23
  validationContext.assertIsBoolean(findNode(node, ['autoBoot']), `${propPrefix}.autoBoot`);
24
+ validationContext.assertIsBoolean(findNode(node, ['experimentalSSR']), `${propPrefix}.experimentalSSR`);
24
25
  validationContext.assertIsBoolean(findNode(node, ['configAsSrc']), `${propPrefix}.configAsSrc`);
25
26
  validationContext.assertIsBoolean(findNode(node, ['syntheticShadow']), `${propPrefix}.syntheticShadow`);
26
27
  // Each value in the worker map msut be a specifier
package/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.5.11-alpha.2",
8
- "homepage": "https://lwr.dev/",
7
+ "version": "0.6.0-alpha.11",
8
+ "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/salesforce/lwr.git",
@@ -33,27 +33,31 @@
33
33
  "package.cjs"
34
34
  ],
35
35
  "dependencies": {
36
- "@lwrjs/app-service": "0.5.11-alpha.2",
37
- "@lwrjs/asset-registry": "0.5.11-alpha.2",
38
- "@lwrjs/base-template-engine": "0.5.11-alpha.2",
39
- "@lwrjs/base-view-provider": "0.5.11-alpha.2",
40
- "@lwrjs/client-modules": "0.5.11-alpha.2",
41
- "@lwrjs/compiler": "0.5.11-alpha.2",
42
- "@lwrjs/diagnostics": "0.5.11-alpha.2",
43
- "@lwrjs/fs-asset-provider": "0.5.11-alpha.2",
44
- "@lwrjs/html-view-provider": "0.5.11-alpha.2",
45
- "@lwrjs/loader": "0.5.11-alpha.2",
46
- "@lwrjs/lwc-module-provider": "0.5.11-alpha.2",
47
- "@lwrjs/markdown-view-provider": "0.5.11-alpha.2",
48
- "@lwrjs/module-bundler": "0.5.11-alpha.2",
49
- "@lwrjs/module-registry": "0.5.11-alpha.2",
50
- "@lwrjs/npm-module-provider": "0.5.11-alpha.2",
51
- "@lwrjs/nunjucks-view-provider": "0.5.11-alpha.2",
52
- "@lwrjs/resource-registry": "0.5.11-alpha.2",
53
- "@lwrjs/router": "0.5.11-alpha.2",
54
- "@lwrjs/server": "0.5.11-alpha.2",
55
- "@lwrjs/shared-utils": "0.5.11-alpha.2",
56
- "@lwrjs/view-registry": "0.5.11-alpha.2",
36
+ "@lwrjs/app-service": "0.6.0-alpha.11",
37
+ "@lwrjs/asset-registry": "0.6.0-alpha.11",
38
+ "@lwrjs/asset-transformer": "0.6.0-alpha.11",
39
+ "@lwrjs/base-template-engine": "0.6.0-alpha.11",
40
+ "@lwrjs/base-view-provider": "0.6.0-alpha.11",
41
+ "@lwrjs/base-view-transformer": "0.6.0-alpha.11",
42
+ "@lwrjs/client-modules": "0.6.0-alpha.11",
43
+ "@lwrjs/compiler": "0.6.0-alpha.11",
44
+ "@lwrjs/diagnostics": "0.6.0-alpha.11",
45
+ "@lwrjs/fs-asset-provider": "0.6.0-alpha.11",
46
+ "@lwrjs/html-view-provider": "0.6.0-alpha.11",
47
+ "@lwrjs/loader": "0.6.0-alpha.11",
48
+ "@lwrjs/lwc-module-provider": "0.6.0-alpha.11",
49
+ "@lwrjs/lwc-ssr": "0.6.0-alpha.11",
50
+ "@lwrjs/markdown-view-provider": "0.6.0-alpha.11",
51
+ "@lwrjs/module-bundler": "0.6.0-alpha.11",
52
+ "@lwrjs/module-registry": "0.6.0-alpha.11",
53
+ "@lwrjs/npm-module-provider": "0.6.0-alpha.11",
54
+ "@lwrjs/nunjucks-view-provider": "0.6.0-alpha.11",
55
+ "@lwrjs/o11y": "0.6.0-alpha.11",
56
+ "@lwrjs/resource-registry": "0.6.0-alpha.11",
57
+ "@lwrjs/router": "0.6.0-alpha.11",
58
+ "@lwrjs/server": "0.6.0-alpha.11",
59
+ "@lwrjs/shared-utils": "0.6.0-alpha.11",
60
+ "@lwrjs/view-registry": "0.6.0-alpha.11",
57
61
  "dompurify": "^2.3.0",
58
62
  "fs-extra": "^10.0.0",
59
63
  "jsdom": "^16.7.0",
@@ -63,7 +67,7 @@
63
67
  "qs": "^6.9.4"
64
68
  },
65
69
  "devDependencies": {
66
- "@lwrjs/types": "0.5.11-alpha.2"
70
+ "@lwrjs/types": "0.6.0-alpha.11"
67
71
  },
68
72
  "peerDependencies": {
69
73
  "lwc": ">= 1.x <= 2.x"
@@ -71,5 +75,5 @@
71
75
  "engines": {
72
76
  "node": ">=14.15.4 <17"
73
77
  },
74
- "gitHead": "83785c79e6adbfb1ead85e0c23e9164a22cb5755"
78
+ "gitHead": "18ab72188c2d52e32cca47333951a9c76f996039"
75
79
  }