@lwrjs/lwc-ssr 0.24.2 → 0.24.4

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