@lwc/ssr-runtime 8.2.0 → 8.4.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  /**
2
2
  * Copyright (c) 2024 Salesforce, Inc.
3
3
  */
4
- import { htmlPropertyToAttribute } from '@lwc/shared';
5
-
6
4
  /*
7
5
  * Copyright (c) 2024, Salesforce, Inc.
8
6
  * All rights reserved.
@@ -102,31 +100,266 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
102
100
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
103
101
  }
104
102
 
103
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
104
+ if (kind === "m") throw new TypeError("Private method is not writable");
105
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
106
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
107
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
108
+ }
109
+
105
110
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
106
111
  var e = new Error(message);
107
112
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
108
113
  };
109
114
 
115
+ /**
116
+ * Copyright (c) 2024 Salesforce, Inc.
117
+ */
118
+ /*
119
+ * Copyright (c) 2018, salesforce.com, inc.
120
+ * All rights reserved.
121
+ * SPDX-License-Identifier: MIT
122
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
123
+ */
124
+ /**
125
+ *
126
+ * @param value
127
+ * @param msg
128
+ */
129
+
130
+ /*
131
+ * Copyright (c) 2024, Salesforce, Inc.
132
+ * All rights reserved.
133
+ * SPDX-License-Identifier: MIT
134
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
135
+ */
136
+ const {
137
+ /** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */
138
+ assign,
139
+ /** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */
140
+ create,
141
+ /** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */
142
+ defineProperties,
143
+ /** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */
144
+ defineProperty,
145
+ /** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
146
+ entries,
147
+ /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
148
+ freeze,
149
+ /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
150
+ getOwnPropertyDescriptor,
151
+ /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
152
+ getOwnPropertyDescriptors,
153
+ /** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
154
+ getOwnPropertyNames,
155
+ /** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
156
+ getOwnPropertySymbols,
157
+ /** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
158
+ getPrototypeOf,
159
+ /** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
160
+ hasOwnProperty,
161
+ /** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
162
+ isFrozen,
163
+ /** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
164
+ keys,
165
+ /** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
166
+ seal,
167
+ /** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
168
+ setPrototypeOf, } = Object;
169
+ const {
170
+ /** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
171
+ isArray,
172
+ /** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
173
+ from: ArrayFrom, } = Array;
174
+ // For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
175
+ // though it works fine for one, e.g. isArray), so comments for these are added to the export
176
+ // statement, rather than this declaration.
177
+ const { concat: ArrayConcat, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly!
178
+ } = Array.prototype;
179
+ // No JSDocs here - see comment for Array.prototype
180
+ const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
181
+ /**
182
+ * Determines whether the argument is `null`.
183
+ * @param obj Value to test
184
+ * @returns `true` if the value is `null`.
185
+ */
186
+ function isNull(obj) {
187
+ return obj === null;
188
+ }
189
+ const OtS = {}.toString;
190
+ /**
191
+ * Converts the argument to a string, safely accounting for objects with "null" prototype.
192
+ * Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
193
+ * @param obj Value to convert to a string.
194
+ * @returns String representation of the value.
195
+ */
196
+ function toString(obj) {
197
+ if (obj?.toString) {
198
+ // Arrays might hold objects with "null" prototype So using
199
+ // Array.prototype.toString directly will cause an error Iterate through
200
+ // all the items and handle individually.
201
+ if (isArray(obj)) {
202
+ // This behavior is slightly different from Array#toString:
203
+ // 1. Array#toString calls `this.join`, rather than Array#join
204
+ // Ex: arr = []; arr.join = () => 1; arr.toString() === 1; toString(arr) === ''
205
+ // 2. Array#toString delegates to Object#toString if `this.join` is not a function
206
+ // Ex: arr = []; arr.join = 'no'; arr.toString() === '[object Array]; toString(arr) = ''
207
+ // 3. Array#toString converts null/undefined to ''
208
+ // Ex: arr = [null, undefined]; arr.toString() === ','; toString(arr) === '[object Null],undefined'
209
+ // 4. Array#toString converts recursive references to arrays to ''
210
+ // Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
211
+ // Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
212
+ return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
213
+ }
214
+ return obj.toString();
215
+ }
216
+ else if (typeof obj === 'object') {
217
+ // This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
218
+ return OtS.call(obj);
219
+ }
220
+ else {
221
+ return String(obj);
222
+ }
223
+ }
224
+
225
+ /*
226
+ * Copyright (c) 2018, salesforce.com, inc.
227
+ * All rights reserved.
228
+ * SPDX-License-Identifier: MIT
229
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
230
+ */
231
+ /**
232
+ * According to the following list, there are 48 aria attributes of which two (ariaDropEffect and
233
+ * ariaGrabbed) are deprecated:
234
+ * https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes
235
+ *
236
+ * The above list of 46 aria attributes is consistent with the following resources:
237
+ * https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
238
+ * https://wicg.github.io/aom/spec/aria-reflection.html
239
+ *
240
+ * NOTE: If you update this list, please update test files that implicitly reference this list!
241
+ * Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages.
242
+ */
243
+ const AriaPropertyNames = [
244
+ 'ariaActiveDescendant',
245
+ 'ariaAtomic',
246
+ 'ariaAutoComplete',
247
+ 'ariaBusy',
248
+ 'ariaChecked',
249
+ 'ariaColCount',
250
+ 'ariaColIndex',
251
+ 'ariaColIndexText',
252
+ 'ariaColSpan',
253
+ 'ariaControls',
254
+ 'ariaCurrent',
255
+ 'ariaDescribedBy',
256
+ 'ariaDescription',
257
+ 'ariaDetails',
258
+ 'ariaDisabled',
259
+ 'ariaErrorMessage',
260
+ 'ariaExpanded',
261
+ 'ariaFlowTo',
262
+ 'ariaHasPopup',
263
+ 'ariaHidden',
264
+ 'ariaInvalid',
265
+ 'ariaKeyShortcuts',
266
+ 'ariaLabel',
267
+ 'ariaLabelledBy',
268
+ 'ariaLevel',
269
+ 'ariaLive',
270
+ 'ariaModal',
271
+ 'ariaMultiLine',
272
+ 'ariaMultiSelectable',
273
+ 'ariaOrientation',
274
+ 'ariaOwns',
275
+ 'ariaPlaceholder',
276
+ 'ariaPosInSet',
277
+ 'ariaPressed',
278
+ 'ariaReadOnly',
279
+ 'ariaRelevant',
280
+ 'ariaRequired',
281
+ 'ariaRoleDescription',
282
+ 'ariaRowCount',
283
+ 'ariaRowIndex',
284
+ 'ariaRowIndexText',
285
+ 'ariaRowSpan',
286
+ 'ariaSelected',
287
+ 'ariaSetSize',
288
+ 'ariaSort',
289
+ 'ariaValueMax',
290
+ 'ariaValueMin',
291
+ 'ariaValueNow',
292
+ 'ariaValueText',
293
+ 'ariaBrailleLabel',
294
+ 'ariaBrailleRoleDescription',
295
+ 'role',
296
+ ];
297
+ const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (() => {
298
+ const AriaAttrNameToPropNameMap = create(null);
299
+ const AriaPropNameToAttrNameMap = create(null);
300
+ // Synthetic creation of all AOM property descriptors for Custom Elements
301
+ forEach.call(AriaPropertyNames, (propName) => {
302
+ const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
303
+ AriaAttrNameToPropNameMap[attrName] = propName;
304
+ AriaPropNameToAttrNameMap[propName] = attrName;
305
+ });
306
+ return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
307
+ })();
308
+
309
+ /*
310
+ * Copyright (c) 2020, salesforce.com, inc.
311
+ * All rights reserved.
312
+ * SPDX-License-Identifier: MIT
313
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
314
+ */
315
+ const ESCAPED_CHARS = {
316
+ '"': '"',
317
+ "'": ''',
318
+ '<': '&lt;',
319
+ '>': '&gt;',
320
+ '&': '&amp;',
321
+ };
322
+ /**
323
+ *
324
+ * @param str
325
+ * @param attrMode
326
+ */
327
+ function htmlEscape(str, attrMode = false) {
328
+ const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
329
+ return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
330
+ }
331
+ /** version: 8.4.0 */
332
+
110
333
  /*
111
334
  * Copyright (c) 2024, Salesforce, Inc.
112
335
  * All rights reserved.
113
336
  * SPDX-License-Identifier: MIT
114
337
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
115
338
  */
339
+ var _MutationTracker_enabledSet, _MutationTracker_mutationMap;
116
340
  class MutationTracker {
117
341
  constructor() {
118
- this.mutationMap = new WeakMap();
342
+ _MutationTracker_enabledSet.set(this, new WeakSet());
343
+ _MutationTracker_mutationMap.set(this, new WeakMap());
119
344
  }
120
345
  add(instance, attrName) {
121
- let mutatedAttrs = this.mutationMap.get(instance);
122
- if (!mutatedAttrs) {
123
- mutatedAttrs = new Set();
124
- this.mutationMap.set(instance, mutatedAttrs);
346
+ if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
347
+ let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
348
+ if (!mutatedAttrs) {
349
+ mutatedAttrs = new Set();
350
+ __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
351
+ }
352
+ mutatedAttrs.add(attrName.toLowerCase());
125
353
  }
126
- mutatedAttrs.add(attrName.toLowerCase());
354
+ }
355
+ enable(instance) {
356
+ __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
357
+ }
358
+ disable(instance) {
359
+ __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
127
360
  }
128
361
  renderMutatedAttrs(instance) {
129
- const mutatedAttrs = this.mutationMap.get(instance);
362
+ const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
130
363
  if (mutatedAttrs) {
131
364
  return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
132
365
  }
@@ -135,42 +368,73 @@ class MutationTracker {
135
368
  }
136
369
  }
137
370
  }
371
+ _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
138
372
  const mutationTracker = new MutationTracker();
139
373
 
374
+ /*
375
+ * Copyright (c) 2024, Salesforce, Inc.
376
+ * All rights reserved.
377
+ * SPDX-License-Identifier: MIT
378
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
379
+ */
380
+ // Eventually include globals that also reflect
381
+ const attrsToProps = AriaAttrNameToPropNameMap;
382
+ function reflectAttrToProp(instance, attrName, attrValue) {
383
+ const reflectedPropName = attrsToProps[attrName];
384
+ // If it is a reflected property and it was not overridden by the instance
385
+ if (reflectedPropName && !hasOwnProperty.call(instance, reflectedPropName)) {
386
+ const currentValue = instance[reflectedPropName];
387
+ if (currentValue !== attrValue) {
388
+ instance[reflectedPropName] = attrValue;
389
+ }
390
+ }
391
+ }
392
+ const descriptors = create(null);
393
+ for (const [attrName, propName] of entries(attrsToProps)) {
394
+ descriptors[propName] = {
395
+ get() {
396
+ return this.getAttribute(attrName);
397
+ },
398
+ set(newValue) {
399
+ const currentValue = this.getAttribute(attrName);
400
+ if (newValue !== currentValue) {
401
+ // TODO [#3284]: According to the spec, IDL nullable type values
402
+ // (null and undefined) should remove the attribute; however, we
403
+ // only do so in the case of null for historical reasons.
404
+ // See also https://github.com/w3c/aria/issues/1858
405
+ if (isNull(newValue)) {
406
+ this.removeAttribute(attrName);
407
+ }
408
+ else {
409
+ this.setAttribute(attrName, toString(newValue));
410
+ }
411
+ }
412
+ },
413
+ configurable: true,
414
+ enumerable: true,
415
+ };
416
+ }
417
+
140
418
  /*
141
419
  * Copyright (c) 2024, salesforce.com, inc.
142
420
  * All rights reserved.
143
421
  * SPDX-License-Identifier: MIT
144
422
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
145
423
  */
146
- var _LightningElement_instances, _LightningElement_setAttribute;
424
+ var _LightningElement_attrs, _LightningElement_classList;
425
+ const SYMBOL__SET_INTERNALS = Symbol('set-internals');
147
426
  class LightningElement {
148
427
  constructor(propsAvailableAtConstruction) {
149
- _LightningElement_instances.add(this);
150
428
  this.isConnected = false;
151
429
  this.className = '';
152
- this.__classList = null;
153
- Object.assign(this, propsAvailableAtConstruction);
154
- }
155
- // TODO [W-14977927]: protect internals from userland
156
- __internal__setState(props, reflectedProps, attrs) {
157
- Object.assign(this, props);
158
- this.__attrs = attrs;
159
- // Whenever a reflected prop changes, we'll update the original props object
160
- // that was passed in. That'll be referenced when the attrs are rendered later.
161
- for (const reflectedPropName of reflectedProps) {
162
- Object.defineProperty(this, reflectedPropName, {
163
- get() {
164
- return props[reflectedPropName] ?? null;
165
- },
166
- set(newValue) {
167
- props[reflectedPropName] = newValue;
168
- mutationTracker.add(this, htmlPropertyToAttribute(reflectedPropName));
169
- },
170
- enumerable: true,
171
- });
172
- }
173
- Object.defineProperty(this, 'className', {
430
+ _LightningElement_attrs.set(this, void 0);
431
+ _LightningElement_classList.set(this, null);
432
+ assign(this, propsAvailableAtConstruction);
433
+ }
434
+ [(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
435
+ __classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
436
+ assign(this, props);
437
+ defineProperty(this, 'className', {
174
438
  get() {
175
439
  return props.class ?? '';
176
440
  },
@@ -182,35 +446,35 @@ class LightningElement {
182
446
  });
183
447
  }
184
448
  get classList() {
185
- if (this.__classList) {
186
- return this.__classList;
449
+ if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
450
+ return __classPrivateFieldGet(this, _LightningElement_classList, "f");
187
451
  }
188
- return (this.__classList = new ClassList(this));
452
+ return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
189
453
  }
190
454
  setAttribute(attrName, attrValue) {
191
- __classPrivateFieldGet(this, _LightningElement_instances, "m", _LightningElement_setAttribute).call(this, attrName, String(attrValue));
455
+ const normalizedName = StringToLowerCase.call(toString(attrName));
456
+ const normalizedValue = String(attrValue);
457
+ __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
458
+ reflectAttrToProp(this, normalizedName, normalizedValue);
459
+ mutationTracker.add(this, normalizedName);
192
460
  }
193
461
  getAttribute(attrName) {
194
- if (this.hasAttribute(attrName)) {
195
- return this.__attrs[attrName];
462
+ const normalizedName = StringToLowerCase.call(toString(attrName));
463
+ if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
464
+ return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
196
465
  }
197
466
  return null;
198
467
  }
199
468
  hasAttribute(attrName) {
200
- return typeof attrName === 'string' && typeof this.__attrs[attrName] === 'string';
469
+ const normalizedName = StringToLowerCase.call(toString(attrName));
470
+ return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
201
471
  }
202
472
  removeAttribute(attrName) {
203
- if (this.hasAttribute(attrName)) {
204
- // Reflected attributes use accessor methods to update their
205
- // corresponding properties so we can't simply `delete`. Instead,
206
- // we use `null` when we want to remove.
207
- __classPrivateFieldGet(this, _LightningElement_instances, "m", _LightningElement_setAttribute).call(this, attrName, null);
208
- }
209
- else {
210
- // This interprets the removal of a non-existing attribute as an
211
- // attribute mutation. We may want to revisit this.
212
- mutationTracker.add(this, attrName);
213
- }
473
+ const normalizedName = StringToLowerCase.call(toString(attrName));
474
+ delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
475
+ reflectAttrToProp(this, normalizedName, null);
476
+ // Track mutations for removal of non-existing attributes
477
+ mutationTracker.add(this, normalizedName);
214
478
  }
215
479
  addEventListener(_type, _listener, _options) {
216
480
  // noop
@@ -286,10 +550,7 @@ class LightningElement {
286
550
  throw new Error('Method "setAttributeNS" not implemented.');
287
551
  }
288
552
  }
289
- _LightningElement_instances = new WeakSet(), _LightningElement_setAttribute = function _LightningElement_setAttribute(attrName, attrValue) {
290
- this.__attrs[attrName] = attrValue;
291
- mutationTracker.add(this, attrName);
292
- };
553
+ defineProperties(LightningElement.prototype, descriptors);
293
554
 
294
555
  /*
295
556
  * Copyright (c) 2024, salesforce.com, inc.
@@ -313,19 +574,274 @@ function* renderAttrs(instance, attrs) {
313
574
  }
314
575
  yield mutationTracker.renderMutatedAttrs(instance);
315
576
  }
577
+ function renderAttrsNoYield(emit, instance, attrs) {
578
+ if (!attrs) {
579
+ return;
580
+ }
581
+ for (const attrName of Object.getOwnPropertyNames(attrs)) {
582
+ const attrVal = attrs[attrName];
583
+ if (typeof attrVal === 'string') {
584
+ emit(attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`);
585
+ }
586
+ else if (attrVal === null) {
587
+ emit('');
588
+ }
589
+ }
590
+ emit(mutationTracker.renderMutatedAttrs(instance));
591
+ }
316
592
  function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
317
593
  if (Cmp.renderMode !== 'light') {
318
594
  yield '<template shadowrootmode="open"></template>';
319
595
  }
320
596
  }
321
- async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props) {
597
+ function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
598
+ if (Cmp.renderMode !== 'light') {
599
+ emit('<template shadowrootmode="open"></template>');
600
+ }
601
+ }
602
+ async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props, mode = 'asyncYield') {
322
603
  let markup = '';
323
- for await (const segment of compiledGenerateMarkup(tagName, props, null, null)) {
604
+ const emit = (segment) => {
324
605
  markup += segment;
606
+ };
607
+ if (mode === 'asyncYield') {
608
+ for await (const segment of compiledGenerateMarkup(tagName, props, null, null)) {
609
+ markup += segment;
610
+ }
611
+ }
612
+ else if (mode === 'async') {
613
+ await compiledGenerateMarkup(emit, tagName, props, null, null);
614
+ }
615
+ else if (mode === 'sync') {
616
+ compiledGenerateMarkup(emit, tagName, props, null, null);
617
+ }
618
+ else {
619
+ throw new Error(`Invalid mode: ${mode}`);
325
620
  }
326
621
  return markup;
327
622
  }
328
623
 
624
+ /*
625
+ * Copyright (c) 2024, Salesforce, Inc.
626
+ * All rights reserved.
627
+ * SPDX-License-Identifier: MIT
628
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
629
+ */
630
+ // Stubs for all the un-implemented exports from @lwc/engine-server
631
+ function api(..._) {
632
+ throw new Error('@api cannot be used in SSR context.');
633
+ }
634
+ function createContextProvider(..._) {
635
+ throw new Error('createContextProvider cannot be used in SSR context.');
636
+ }
637
+ function createElement(..._) {
638
+ throw new Error('createElement cannot be used in SSR context.');
639
+ }
640
+ function freezeTemplate(..._) {
641
+ throw new Error('freezeTemplate cannot be used in SSR context.');
642
+ }
643
+ function getComponentDef(..._) {
644
+ throw new Error('getComponentDef cannot be used in SSR context.');
645
+ }
646
+ function isComponentConstructor(..._) {
647
+ throw new Error('isComponentConstructor cannot be used in SSR context.');
648
+ }
649
+ function parseFragment(..._) {
650
+ throw new Error('parseFragment cannot be used in SSR context.');
651
+ }
652
+ function parseSVGFragment(..._) {
653
+ throw new Error('parseSVGFragment cannot be used in SSR context.');
654
+ }
655
+ function readonly(..._) {
656
+ throw new Error('readonly cannot be used in SSR context.');
657
+ }
658
+ function registerComponent(..._) {
659
+ throw new Error('registerComponent cannot be used in SSR context.');
660
+ }
661
+ function registerDecorators(..._) {
662
+ throw new Error('registerDecorators cannot be used in SSR context.');
663
+ }
664
+ function registerTemplate(..._) {
665
+ throw new Error('registerTemplate cannot be used in SSR context.');
666
+ }
667
+ function sanitizeAttribute(..._) {
668
+ throw new Error('sanitizeAttribute cannot be used in SSR context.');
669
+ }
670
+ function setFeatureFlag(..._) {
671
+ throw new Error('setFeatureFlag cannot be used in SSR context.');
672
+ }
673
+ function setFeatureFlagForTest(..._) {
674
+ throw new Error('setFeatureFlagForTest cannot be used in SSR context.');
675
+ }
676
+ function setHooks(..._) {
677
+ throw new Error('setHooks cannot be used in SSR context.');
678
+ }
679
+ function swapComponent(..._) {
680
+ throw new Error('swapComponent cannot be used in SSR context.');
681
+ }
682
+ function swapStyle(..._) {
683
+ throw new Error('swapStyle cannot be used in SSR context.');
684
+ }
685
+ function swapTemplate(..._) {
686
+ throw new Error('swapTemplate cannot be used in SSR context.');
687
+ }
688
+ function track(..._) {
689
+ throw new Error('@track cannot be used in SSR context.');
690
+ }
691
+ function unwrap(..._) {
692
+ throw new Error('unwrap cannot be used in SSR context.');
693
+ }
694
+ function wire(..._) {
695
+ throw new Error('@wire cannot be used in SSR context.');
696
+ }
697
+ const renderer = {
698
+ isSyntheticShadowDefined: false,
699
+ insert(..._) {
700
+ throw new Error('renderer.insert cannot be used in SSR context.');
701
+ },
702
+ remove(..._) {
703
+ throw new Error('renderer.remove cannot be used in SSR context.');
704
+ },
705
+ cloneNode(..._) {
706
+ throw new Error('renderer.cloneNode cannot be used in SSR context.');
707
+ },
708
+ createFragment(..._) {
709
+ throw new Error('renderer.createFragment cannot be used in SSR context.');
710
+ },
711
+ createElement(..._) {
712
+ throw new Error('renderer.createElement cannot be used in SSR context.');
713
+ },
714
+ createText(..._) {
715
+ throw new Error('renderer.createText cannot be used in SSR context.');
716
+ },
717
+ createComment(..._) {
718
+ throw new Error('renderer.createComment cannot be used in SSR context.');
719
+ },
720
+ createCustomElement(..._) {
721
+ throw new Error('renderer.createCustomElement cannot be used in SSR context.');
722
+ },
723
+ nextSibling(..._) {
724
+ throw new Error('renderer.nextSibling cannot be used in SSR context.');
725
+ },
726
+ previousSibling(..._) {
727
+ throw new Error('renderer.previousSibling cannot be used in SSR context.');
728
+ },
729
+ attachShadow(..._) {
730
+ throw new Error('renderer.attachShadow cannot be used in SSR context.');
731
+ },
732
+ getProperty(..._) {
733
+ throw new Error('renderer.getProperty cannot be used in SSR context.');
734
+ },
735
+ setProperty(..._) {
736
+ throw new Error('renderer.setProperty cannot be used in SSR context.');
737
+ },
738
+ setText(..._) {
739
+ throw new Error('renderer.setText cannot be used in SSR context.');
740
+ },
741
+ getAttribute(..._) {
742
+ throw new Error('renderer.getAttribute cannot be used in SSR context.');
743
+ },
744
+ setAttribute(..._) {
745
+ throw new Error('renderer.setAttribute cannot be used in SSR context.');
746
+ },
747
+ removeAttribute(..._) {
748
+ throw new Error('renderer.removeAttribute cannot be used in SSR context.');
749
+ },
750
+ addEventListener(..._) {
751
+ throw new Error('renderer.addEventListener cannot be used in SSR context.');
752
+ },
753
+ removeEventListener(..._) {
754
+ throw new Error('renderer.removeEventListener cannot be used in SSR context.');
755
+ },
756
+ dispatchEvent(..._) {
757
+ throw new Error('renderer.dispatchEvent cannot be used in SSR context.');
758
+ },
759
+ getClassList(..._) {
760
+ throw new Error('renderer.getClassList cannot be used in SSR context.');
761
+ },
762
+ setCSSStyleProperty(..._) {
763
+ throw new Error('renderer.setCSSStyleProperty cannot be used in SSR context.');
764
+ },
765
+ getBoundingClientRect(..._) {
766
+ throw new Error('renderer.getBoundingClientRect cannot be used in SSR context.');
767
+ },
768
+ querySelector(..._) {
769
+ throw new Error('renderer.querySelector cannot be used in SSR context.');
770
+ },
771
+ querySelectorAll(..._) {
772
+ throw new Error('renderer.querySelectorAll cannot be used in SSR context.');
773
+ },
774
+ getElementsByTagName(..._) {
775
+ throw new Error('renderer.getElementsByTagName cannot be used in SSR context.');
776
+ },
777
+ getElementsByClassName(..._) {
778
+ throw new Error('renderer.getElementsByClassName cannot be used in SSR context.');
779
+ },
780
+ getChildren(..._) {
781
+ throw new Error('renderer.getChildren cannot be used in SSR context.');
782
+ },
783
+ getChildNodes(..._) {
784
+ throw new Error('renderer.getChildNodes cannot be used in SSR context.');
785
+ },
786
+ getFirstChild(..._) {
787
+ throw new Error('renderer.getFirstChild cannot be used in SSR context.');
788
+ },
789
+ getFirstElementChild(..._) {
790
+ throw new Error('renderer.getFirstElementChild cannot be used in SSR context.');
791
+ },
792
+ getLastChild(..._) {
793
+ throw new Error('renderer.getLastChild cannot be used in SSR context.');
794
+ },
795
+ getLastElementChild(..._) {
796
+ throw new Error('renderer.getLastElementChild cannot be used in SSR context.');
797
+ },
798
+ getTagName(..._) {
799
+ throw new Error('renderer.getTagName cannot be used in SSR context.');
800
+ },
801
+ getStyle(..._) {
802
+ throw new Error('renderer.getStyle cannot be used in SSR context.');
803
+ },
804
+ isConnected(..._) {
805
+ throw new Error('renderer.isConnected cannot be used in SSR context.');
806
+ },
807
+ insertStylesheet(..._) {
808
+ throw new Error('renderer.insertStylesheet cannot be used in SSR context.');
809
+ },
810
+ assertInstanceOfHTMLElement(..._) {
811
+ throw new Error('renderer.assertInstanceOfHTMLElement cannot be used in SSR context.');
812
+ },
813
+ ownerDocument(..._) {
814
+ throw new Error('renderer.ownerDocument cannot be used in SSR context.');
815
+ },
816
+ registerContextConsumer(..._) {
817
+ throw new Error('renderer.registerContextConsumer cannot be used in SSR context.');
818
+ },
819
+ attachInternals(..._) {
820
+ throw new Error('renderer.attachInternals cannot be used in SSR context.');
821
+ },
822
+ defineCustomElement(..._) {
823
+ throw new Error('renderer.defineCustomElement cannot be used in SSR context.');
824
+ },
825
+ getParentNode(..._) {
826
+ throw new Error('renderer.getParentNode cannot be used in SSR context.');
827
+ },
828
+ startTrackingMutations(..._) {
829
+ throw new Error('renderer.startTrackingMutations cannot be used in SSR context.');
830
+ },
831
+ stopTrackingMutations(..._) {
832
+ throw new Error('renderer.stopTrackingMutations cannot be used in SSR context.');
833
+ },
834
+ };
835
+ /**
836
+ * The hot API is used to orchestrate hot swapping in client rendered components.
837
+ * It doesn't do anything on the server side, however, you may import it.
838
+ *
839
+ * The whole point of defining this and exporting it is so that you can import it in isomorphic code without
840
+ * an error being thrown by the import itself.
841
+ */
842
+ // A real stub, not a "not implemented" one! 😯
843
+ const hot = undefined;
844
+
329
845
  /*
330
846
  * Copyright (c) 2024, salesforce.com, inc.
331
847
  * All rights reserved.
@@ -411,6 +927,6 @@ function validateStyleTextContents(contents) {
411
927
  }
412
928
  }
413
929
 
414
- export { ClassList, LightningElement, MutationTracker, fallbackTmpl, renderAttrs, serverSideRenderComponent as renderComponent, serverSideRenderComponent, toIteratorDirective, validateStyleTextContents };
415
- /** version: 8.2.0 */
930
+ export { ClassList, LightningElement, SYMBOL__SET_INTERNALS, api, createContextProvider, createElement, fallbackTmpl, fallbackTmplNoYield, freezeTemplate, getComponentDef, hot, htmlEscape, isComponentConstructor, mutationTracker, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, renderAttrs, renderAttrsNoYield, serverSideRenderComponent as renderComponent, renderer, sanitizeAttribute, serverSideRenderComponent, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, toIteratorDirective, track, unwrap, validateStyleTextContents, wire };
931
+ /** version: 8.4.0 */
416
932
  //# sourceMappingURL=index.js.map