@lwrjs/lwc-ssr 0.24.2 → 0.24.3

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,37 +1,34 @@
1
- var __create = Object.create;
1
+ "use strict";
2
2
  var __defProp = Object.defineProperty;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
10
- __defProp(target, name, {get: all[name], enumerable: true});
8
+ __defProp(target, name, { get: all[name], enumerable: true });
11
9
  };
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});
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
15
  }
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);
16
+ return to;
22
17
  };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
 
24
20
  // packages/@lwrjs/lwc-ssr/src/viewTransformer/index.ts
25
- __markAsModule(exports);
26
- __export(exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
27
23
  default: () => lwcSsrViewTransformer
28
24
  });
29
- var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
30
- var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
31
- var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
32
- var import_utils = __toModule(require("../utils.cjs"));
33
- var import_renderer = __toModule(require("../renderer.cjs"));
34
- function lwcSsrViewTransformer(options, {config, moduleBundler, resourceRegistry}) {
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_diagnostics = require("@lwrjs/diagnostics");
27
+ var import_instrumentation = require("@lwrjs/instrumentation");
28
+ var import_shared_utils = require("@lwrjs/shared-utils");
29
+ var import_utils = require("../utils.cjs");
30
+ var import_renderer = require("../renderer.cjs");
31
+ function lwcSsrViewTransformer(options, { config, moduleBundler, resourceRegistry }) {
35
32
  const routes = [...config.routes, ...config.errorRoutes];
36
33
  return {
37
34
  name: "ssr-lwc-transformer",
@@ -39,7 +36,7 @@ function lwcSsrViewTransformer(options, {config, moduleBundler, resourceRegistry
39
36
  if (!viewContext.view.bootstrap?.ssr) {
40
37
  return {};
41
38
  }
42
- import_diagnostics.logger.debug({label: "lwcSsrViewTransformer", message: "link"});
39
+ import_diagnostics.logger.debug({ label: "lwcSsrViewTransformer", message: "link" });
43
40
  import_diagnostics.logger.verbose({
44
41
  label: "lwcSsrViewTransformer",
45
42
  message: "link input",
@@ -48,8 +45,8 @@ function lwcSsrViewTransformer(options, {config, moduleBundler, resourceRegistry
48
45
  if (!metadata.serverData) {
49
46
  metadata.serverData = {};
50
47
  }
51
- const allBundles = new Set([...metadata.serverBundles ?? []]);
52
- const {customElements, serverData} = metadata;
48
+ const allBundles = /* @__PURE__ */ new Set([...metadata.serverBundles ?? []]);
49
+ const { customElements, serverData } = metadata;
53
50
  const ssrModules = getComponentsToSSR(customElements, stringBuilder);
54
51
  const rootSpecifiers = Object.values(ssrModules).map((m) => m.specifier);
55
52
  if (!rootSpecifiers.length) {
@@ -57,69 +54,90 @@ function lwcSsrViewTransformer(options, {config, moduleBundler, resourceRegistry
57
54
  }
58
55
  const islands = rootSpecifiers.join(",");
59
56
  let pageTtl;
60
- await (0, import_instrumentation.getTracer)().trace({name: import_instrumentation.ViewSpan.RenderIsland, attributes: {specifiers: islands}}, async () => {
61
- try {
62
- const route = routes.find((r) => r.id === viewContext.view.id);
63
- if (!route) {
64
- throw new Error(`Unable to resolve configuration for view: ${viewContext.view.id}`);
65
- }
66
- const {
67
- results,
68
- warnings,
69
- bundles: islandBundles
70
- } = await (0, import_renderer.getRenderer)(config, moduleBundler, resourceRegistry).render(ssrModules, route, viewContext.runtimeEnvironment, viewContext.runtimeParams, metadata.serverData, false);
71
- for (const root in results) {
72
- const {html, props, cache} = results[root] || {};
73
- const {tagName, startOffset, endOffset, hydrate} = ssrModules[root];
74
- pageTtl = (0, import_shared_utils.shortestTtl)(cache?.ttl, pageTtl);
75
- if (html) {
76
- let propsAttr = "";
77
- if (hydrate) {
78
- const propsId = (0, import_utils.getPropsId)();
79
- const hydrateAttr = props && props[import_shared_utils.HYDRATE_DIRECTIVE] ? ` ${import_shared_utils.HYDRATE_DIRECTIVE}="${props[import_shared_utils.HYDRATE_DIRECTIVE]}"` : "";
80
- propsAttr = ` ${import_utils.SSR_PROPS_ATTR}="${propsId}"${hydrateAttr}`;
81
- serverData[propsId] = props;
57
+ await (0, import_instrumentation.getTracer)().trace(
58
+ { name: import_instrumentation.ViewSpan.RenderIsland, attributes: { specifiers: islands } },
59
+ async () => {
60
+ try {
61
+ const route = routes.find((r) => r.id === viewContext.view.id);
62
+ if (!route) {
63
+ throw new Error(
64
+ `Unable to resolve configuration for view: ${viewContext.view.id}`
65
+ );
66
+ }
67
+ const {
68
+ results,
69
+ warnings,
70
+ bundles: islandBundles
71
+ } = await (0, import_renderer.getRenderer)(config, moduleBundler, resourceRegistry).render(
72
+ ssrModules,
73
+ route,
74
+ viewContext.runtimeEnvironment,
75
+ viewContext.runtimeParams,
76
+ metadata.serverData,
77
+ false
78
+ // isFirstOf2PassSSR
79
+ );
80
+ for (const root in results) {
81
+ const { html, props, cache } = results[root] || {};
82
+ const { tagName, startOffset, endOffset, hydrate } = ssrModules[root];
83
+ pageTtl = (0, import_shared_utils.shortestTtl)(cache?.ttl, pageTtl);
84
+ if (html) {
85
+ let propsAttr = "";
86
+ if (hydrate) {
87
+ const propsId = (0, import_utils.getPropsId)();
88
+ const hydrateAttr = props && props[import_shared_utils.HYDRATE_DIRECTIVE] ? ` ${import_shared_utils.HYDRATE_DIRECTIVE}="${props[import_shared_utils.HYDRATE_DIRECTIVE]}"` : "";
89
+ propsAttr = ` ${import_utils.SSR_PROPS_ATTR}="${propsId}"${hydrateAttr}`;
90
+ serverData[propsId] = props;
91
+ }
92
+ const [, remain] = html.split(`<${tagName}`);
93
+ stringBuilder.overwrite(
94
+ startOffset,
95
+ endOffset,
96
+ [`<${tagName}`, propsAttr, remain].join("")
97
+ );
82
98
  }
83
- const [, remain] = html.split(`<${tagName}`);
84
- stringBuilder.overwrite(startOffset, endOffset, [`<${tagName}`, propsAttr, remain].join(""));
85
99
  }
100
+ (0, import_utils.mergeWarnings)(metadata, warnings);
101
+ metadata.serverBundles = islandBundles ? /* @__PURE__ */ new Set([...allBundles, ...islandBundles]) : allBundles;
102
+ results && (0, import_shared_utils.addHeadMarkup)(
103
+ Object.values(results).map((r) => r.markup),
104
+ stringBuilder
105
+ );
106
+ } catch (e) {
107
+ if (e instanceof import_diagnostics.LwrError) throw e;
108
+ throw new import_diagnostics.LwrApplicationError(
109
+ import_diagnostics.descriptions.APPLICATION.SSR_ERROR(islands, (0, import_diagnostics.stringifyError)(e))
110
+ );
86
111
  }
87
- (0, import_utils.mergeWarnings)(metadata, warnings);
88
- metadata.serverBundles = islandBundles ? new Set([...allBundles, ...islandBundles]) : allBundles;
89
- results && (0, import_shared_utils.addHeadMarkup)(Object.values(results).map((r) => r.markup), stringBuilder);
90
- } catch (e) {
91
- if (e instanceof import_diagnostics.LwrError)
92
- throw e;
93
- throw new import_diagnostics.LwrApplicationError(import_diagnostics.descriptions.APPLICATION.SSR_ERROR(islands, (0, import_diagnostics.stringifyError)(e)));
94
112
  }
95
- });
113
+ );
96
114
  import_diagnostics.logger.verbose({
97
115
  label: "lwcSsrViewTransformer",
98
116
  message: "response",
99
117
  additionalInfo: stringBuilder
100
118
  });
101
- return {cache: {ttl: pageTtl}};
119
+ return { cache: { ttl: pageTtl } };
102
120
  }
103
121
  };
104
122
  }
105
123
  function getComponentsToSSR(customElements, stringBuilder) {
106
124
  const cmpInfo = {};
107
- for (const {tagName, location, props: rawProps = {}} of customElements.values()) {
125
+ for (const { tagName, location, props: rawProps = {} } of customElements.values()) {
108
126
  const isCsr = (0, import_shared_utils.isCsrIsland)(rawProps);
109
127
  if (isCsr && location) {
110
- const {startOffset, endOffset} = location;
128
+ const { startOffset, endOffset } = location;
111
129
  stringBuilder.overwrite(startOffset, endOffset, `<${tagName}></${tagName}>`);
112
130
  }
113
131
  if (!isCsr && !rawProps?.["lwc:external"] && location) {
114
- const {startOffset, endOffset} = location;
132
+ const { startOffset, endOffset } = location;
115
133
  const specifier = (0, import_shared_utils.kebabCaseToModuleSpecifier)(tagName);
116
134
  const isHydrateOnVisible = (0, import_shared_utils.isHydrateVisible)(rawProps);
117
135
  const hydrate = (0, import_shared_utils.isHydrateOnLoad)(rawProps) || isHydrateOnVisible;
118
- const props = {...rawProps};
136
+ const props = { ...rawProps };
119
137
  if (!isHydrateOnVisible) {
120
138
  delete props[import_shared_utils.HYDRATE_DIRECTIVE];
121
139
  }
122
- cmpInfo[specifier] = {startOffset, endOffset, props, tagName, specifier, hydrate};
140
+ cmpInfo[specifier] = { startOffset, endOffset, props, tagName, specifier, hydrate };
123
141
  }
124
142
  }
125
143
  return cmpInfo;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.24.2",
7
+ "version": "0.24.3",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -48,11 +48,11 @@
48
48
  "package.cjs"
49
49
  ],
50
50
  "dependencies": {
51
- "@lwrjs/config": "0.24.2",
52
- "@lwrjs/diagnostics": "0.24.2",
53
- "@lwrjs/instrumentation": "0.24.2",
54
- "@lwrjs/loader": "0.24.2",
55
- "@lwrjs/shared-utils": "0.24.2",
51
+ "@lwrjs/config": "0.24.3",
52
+ "@lwrjs/diagnostics": "0.24.3",
53
+ "@lwrjs/instrumentation": "0.24.3",
54
+ "@lwrjs/loader": "0.24.3",
55
+ "@lwrjs/shared-utils": "0.24.3",
56
56
  "@rollup/plugin-node-resolve": "^15.2.3",
57
57
  "@rollup/plugin-terser": "^0.4.4",
58
58
  "fs-extra": "^11.2.0",
@@ -61,7 +61,7 @@
61
61
  "undici": "^7.28.0"
62
62
  },
63
63
  "devDependencies": {
64
- "@lwrjs/types": "0.24.2",
64
+ "@lwrjs/types": "0.24.3",
65
65
  "jest": "29.7.0",
66
66
  "memfs": "^4.13.0",
67
67
  "ts-jest": "^29.2.6"
@@ -75,5 +75,5 @@
75
75
  "volta": {
76
76
  "extends": "../../../package.json"
77
77
  },
78
- "gitHead": "7492ce779f3b7e91617c4644a1aa567eff01db58"
78
+ "gitHead": "ed415a8f04d5558cac756fbc2a0e454a373e31c1"
79
79
  }