@lwc/ssr-runtime 8.10.1 → 8.11.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs.js CHANGED
@@ -262,24 +262,44 @@ defineProperties,
262
262
  defineProperty,
263
263
  /** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
264
264
  entries,
265
+ /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
266
+ freeze,
267
+ /** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
268
+ fromEntries,
269
+ /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
270
+ getOwnPropertyDescriptor: getOwnPropertyDescriptor$1,
271
+ /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
272
+ getOwnPropertyDescriptors,
265
273
  /** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
266
274
  getOwnPropertyNames: getOwnPropertyNames$1,
275
+ /** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
276
+ getOwnPropertySymbols: getOwnPropertySymbols$1,
277
+ /** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
278
+ getPrototypeOf: getPrototypeOf$1,
267
279
  /** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
268
280
  hasOwnProperty: hasOwnProperty$1,
281
+ /** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
282
+ isFrozen,
269
283
  /** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
270
- keys} = Object;
284
+ keys,
285
+ /** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
286
+ seal,
287
+ /** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
288
+ setPrototypeOf, } = Object;
271
289
  const {
272
290
  /** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
273
- isArray: isArray$1} = Array;
291
+ isArray: isArray$1,
292
+ /** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
293
+ from: ArrayFrom, } = Array;
274
294
  // For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
275
295
  // though it works fine for one, e.g. isArray), so comments for these are added to the export
276
296
  // statement, rather than this declaration.
277
- const { join: ArrayJoin, map: ArrayMap, forEach, // Weird anomaly!
297
+ const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly!
278
298
  } = Array.prototype;
279
299
  /** Detached {@linkcode String.fromCharCode}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode MDN Reference}. */
280
300
  const { fromCharCode: StringFromCharCode } = String;
281
301
  // No JSDocs here - see comment for Array.prototype
282
- const { charCodeAt: StringCharCodeAt, replace: StringReplace, toLowerCase: StringToLowerCase} = String.prototype;
302
+ const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
283
303
  /**
284
304
  * Determines whether the argument is `undefined`.
285
305
  * @param obj Value to test
@@ -571,18 +591,6 @@ function setHooks(hooks) {
571
591
  hooksAreSet = true;
572
592
  exports.sanitizeHtmlContent = hooks.sanitizeHtmlContent;
573
593
  }
574
- function flattenStylesheets(stylesheets) {
575
- const list = [];
576
- for (const stylesheet of stylesheets) {
577
- if (!isArray$1(stylesheet)) {
578
- list.push(stylesheet);
579
- }
580
- else {
581
- list.push(...flattenStylesheets(stylesheet));
582
- }
583
- }
584
- return list;
585
- }
586
594
 
587
595
  /*
588
596
  * Copyright (c) 2024, Salesforce, Inc.
@@ -591,7 +599,7 @@ function flattenStylesheets(stylesheets) {
591
599
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
592
600
  */
593
601
  const DEFAULT_SSR_MODE = 'sync';
594
- /** version: 8.10.1 */
602
+ /** version: 8.11.0 */
595
603
 
596
604
  /*
597
605
  * Copyright (c) 2024, Salesforce, Inc.
@@ -1072,12 +1080,12 @@ function* renderAttrs(instance, attrs, hostScopeToken, scopeToken) {
1072
1080
  function renderAttrsNoYield(emit, instance, attrs, hostScopeToken, scopeToken) {
1073
1081
  emit(renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken));
1074
1082
  }
1075
- function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
1083
+ function* fallbackTmpl(_props, _attrs, _shadowSlottedContent, _lightSlottedContent, Cmp, _instance) {
1076
1084
  if (Cmp.renderMode !== 'light') {
1077
1085
  yield '<template shadowrootmode="open"></template>';
1078
1086
  }
1079
1087
  }
1080
- function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
1088
+ function fallbackTmplNoYield(emit, _props, _attrs, _shadowSlottedContent, _lightSlottedContent, Cmp, _instance) {
1081
1089
  if (Cmp.renderMode !== 'light') {
1082
1090
  emit('<template shadowrootmode="open"></template>');
1083
1091
  }
@@ -1086,22 +1094,21 @@ async function serverSideRenderComponent(tagName, Component, props = {}, mode =
1086
1094
  if (typeof tagName !== 'string') {
1087
1095
  throw new Error(`tagName must be a string, found: ${tagName}`);
1088
1096
  }
1089
- // TODO [#4726]: remove `generateMarkup` export
1090
- const generateMarkup = SYMBOL__GENERATE_MARKUP in Component ? Component[SYMBOL__GENERATE_MARKUP] : Component;
1097
+ const generateMarkup = Component[SYMBOL__GENERATE_MARKUP];
1091
1098
  let markup = '';
1092
1099
  const emit = (segment) => {
1093
1100
  markup += segment;
1094
1101
  };
1095
1102
  if (mode === 'asyncYield') {
1096
- for await (const segment of generateMarkup(tagName, props, null, null)) {
1103
+ for await (const segment of generateMarkup(tagName, props, null, null, null)) {
1097
1104
  markup += segment;
1098
1105
  }
1099
1106
  }
1100
1107
  else if (mode === 'async') {
1101
- await generateMarkup(emit, tagName, props, null, null);
1108
+ await generateMarkup(emit, tagName, props, null, null, null);
1102
1109
  }
1103
1110
  else if (mode === 'sync') {
1104
- generateMarkup(emit, tagName, props, null, null);
1111
+ generateMarkup(emit, tagName, props, null, null, null);
1105
1112
  }
1106
1113
  else {
1107
1114
  throw new Error(`Invalid mode: ${mode}`);
@@ -1163,27 +1170,41 @@ function validateStyleTextContents(contents) {
1163
1170
  * SPDX-License-Identifier: MIT
1164
1171
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1165
1172
  */
1166
- function hasScopedStaticStylesheets(Component) {
1167
- const { stylesheets } = Component;
1168
- if (stylesheets) {
1169
- return flattenStylesheets(stylesheets).some((stylesheet) => stylesheet.$scoped$);
1173
+ // Traverse in the same order as `flattenStylesheets` but without creating unnecessary additional arrays
1174
+ function traverseStylesheets(stylesheets, callback) {
1175
+ if (isArray$1(stylesheets)) {
1176
+ for (let i = 0; i < stylesheets.length; i++) {
1177
+ traverseStylesheets(stylesheets[i], callback);
1178
+ }
1179
+ }
1180
+ else if (stylesheets) {
1181
+ callback(stylesheets);
1170
1182
  }
1171
- return false;
1172
1183
  }
1173
- function renderStylesheets(stylesheets, scopeToken, Component, hasScopedTemplateStyles) {
1184
+ function hasScopedStaticStylesheets(Component) {
1185
+ let scoped = false;
1186
+ traverseStylesheets(Component.stylesheets, (stylesheet) => {
1187
+ scoped ||= !!stylesheet.$scoped$;
1188
+ });
1189
+ return scoped;
1190
+ }
1191
+ function renderStylesheets(defaultStylesheets, defaultScopedStylesheets, staticStylesheets, scopeToken, Component, hasScopedTemplateStyles) {
1174
1192
  const hasAnyScopedStyles = hasScopedTemplateStyles || hasScopedStaticStylesheets(Component);
1193
+ const { renderMode } = Component;
1175
1194
  let result = '';
1176
- const truthyStylesheets = stylesheets.filter(Boolean);
1177
- for (const stylesheet of flattenStylesheets(truthyStylesheets)) {
1178
- // TODO [#2869]: `<style>`s should not have scope token classes
1179
- result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} type="text/css">`;
1180
- const token = stylesheet.$scoped$ ? scopeToken : undefined;
1181
- const useActualHostSelector = !stylesheet.$scoped$ || Component.renderMode !== 'light';
1195
+ const renderStylesheet = (stylesheet) => {
1196
+ const { $scoped$: scoped } = stylesheet;
1197
+ const token = scoped ? scopeToken : undefined;
1198
+ const useActualHostSelector = !scoped || renderMode !== 'light';
1182
1199
  const useNativeDirPseudoclass = true;
1183
1200
  const styleContents = stylesheet(token, useActualHostSelector, useNativeDirPseudoclass);
1184
1201
  validateStyleTextContents(styleContents);
1185
- result += styleContents + '</style>';
1186
- }
1202
+ // TODO [#2869]: `<style>`s should not have scope token classes
1203
+ result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} type="text/css">${styleContents}</style>`;
1204
+ };
1205
+ traverseStylesheets(defaultStylesheets, renderStylesheet);
1206
+ traverseStylesheets(defaultScopedStylesheets, renderStylesheet);
1207
+ traverseStylesheets(staticStylesheets, renderStylesheet);
1187
1208
  return result;
1188
1209
  }
1189
1210
 
@@ -1885,5 +1906,5 @@ exports.track = track;
1885
1906
  exports.unwrap = unwrap$1;
1886
1907
  exports.validateStyleTextContents = validateStyleTextContents;
1887
1908
  exports.wire = wire;
1888
- /** version: 8.10.1 */
1909
+ /** version: 8.11.0 */
1889
1910
  //# sourceMappingURL=index.cjs.js.map