@lwc/ssr-runtime 8.5.0 → 8.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs.js CHANGED
@@ -11,736 +11,445 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
  * SPDX-License-Identifier: MIT
12
12
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
13
13
  */
14
- const MULTI_SPACE = /\s+/g;
15
- class ClassList {
16
- constructor(el) {
17
- this.el = el;
18
- }
19
- add(...newClassNames) {
20
- const className = this.el.className;
21
- const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
22
- for (const newClassName of newClassNames) {
23
- set.add(newClassName);
24
- }
25
- this.el.className = Array.from(set).join(' ');
26
- }
27
- contains(className) {
28
- const currentClassNameStr = this.el.className;
29
- return currentClassNameStr.split(MULTI_SPACE).includes(className);
30
- }
31
- remove(...classNamesToRemove) {
32
- const className = this.el.className;
33
- const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
34
- for (const newClassName of classNamesToRemove) {
35
- set.delete(newClassName);
36
- }
37
- this.el.className = Array.from(set).join(' ');
38
- }
39
- replace(oldClassName, newClassName) {
40
- let classWasReplaced = false;
41
- const className = this.el.className;
42
- const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
43
- listOfClasses.forEach((value, idx) => {
44
- if (value === oldClassName) {
45
- classWasReplaced = true;
46
- listOfClasses[idx] = newClassName;
47
- }
48
- });
49
- this.el.className = listOfClasses.join(' ');
50
- return classWasReplaced;
51
- }
52
- toggle(classNameToToggle, force) {
53
- const classNameStr = this.el.className;
54
- const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
55
- if (!set.has(classNameToToggle) && force !== false) {
56
- set.add(classNameToToggle);
57
- }
58
- else if (set.has(classNameToToggle) && force !== true) {
59
- set.delete(classNameToToggle);
60
- }
61
- this.el.className = Array.from(set).join(' ');
62
- return set.has(classNameToToggle);
63
- }
64
- get value() {
65
- return this.el.className;
66
- }
67
- toString() {
68
- return this.el.className;
69
- }
70
- item(_index) {
71
- throw new Error('Method "item" not implemented.');
72
- }
73
- supports(_token) {
74
- throw new Error('Method "supports" not implemented.');
75
- }
76
- forEach(_callbackfn, _thisArg) {
77
- throw new Error('Method "forEach" not implemented.');
78
- }
79
- get length() {
80
- throw new Error('Property "length" not implemented.');
81
- }
82
- }
83
-
84
- /******************************************************************************
85
- Copyright (c) Microsoft Corporation.
86
-
87
- Permission to use, copy, modify, and/or distribute this software for any
88
- purpose with or without fee is hereby granted.
89
-
90
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
91
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
92
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
93
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
94
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
95
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
96
- PERFORMANCE OF THIS SOFTWARE.
97
- ***************************************************************************** */
98
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
99
-
100
-
101
- function __classPrivateFieldGet(receiver, state, kind, f) {
102
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
103
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
104
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
105
- }
106
-
107
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
108
- if (kind === "m") throw new TypeError("Private method is not writable");
109
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
110
- 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");
111
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
112
- }
113
-
114
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
115
- var e = new Error(message);
116
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
117
- };
118
-
119
- /**
120
- * Copyright (c) 2024 Salesforce, Inc.
121
- */
122
- /*
123
- * Copyright (c) 2018, salesforce.com, inc.
124
- * All rights reserved.
125
- * SPDX-License-Identifier: MIT
126
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
127
- */
128
- /**
129
- *
130
- * @param value
131
- * @param msg
132
- */
133
-
134
- /*
135
- * Copyright (c) 2024, Salesforce, Inc.
136
- * All rights reserved.
137
- * SPDX-License-Identifier: MIT
138
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
139
- */
140
- const {
141
- /** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */
142
- assign,
143
- /** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */
144
- create,
145
- /** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */
146
- defineProperties,
147
- /** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */
148
- defineProperty,
149
- /** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
150
- entries,
151
- /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
152
- freeze,
153
- /** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
154
- fromEntries,
155
- /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
156
- getOwnPropertyDescriptor,
157
- /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
158
- getOwnPropertyDescriptors,
159
- /** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
160
- getOwnPropertyNames,
161
- /** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
162
- getOwnPropertySymbols,
163
- /** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
164
- getPrototypeOf,
165
- /** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
166
- hasOwnProperty,
167
- /** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
168
- isFrozen,
169
- /** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
170
- keys,
171
- /** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
172
- seal,
173
- /** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
174
- setPrototypeOf, } = Object;
175
- const {
176
- /** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
177
- isArray,
178
- /** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
179
- from: ArrayFrom, } = Array;
180
- // For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
181
- // though it works fine for one, e.g. isArray), so comments for these are added to the export
182
- // statement, rather than this declaration.
183
- 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!
184
- } = Array.prototype;
185
- // No JSDocs here - see comment for Array.prototype
186
- const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
187
- /**
188
- * Determines whether the argument is `null`.
189
- * @param obj Value to test
190
- * @returns `true` if the value is `null`.
191
- */
192
- function isNull(obj) {
193
- return obj === null;
194
- }
195
- const OtS = {}.toString;
196
- /**
197
- * Converts the argument to a string, safely accounting for objects with "null" prototype.
198
- * Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
199
- * @param obj Value to convert to a string.
200
- * @returns String representation of the value.
201
- */
202
- function toString(obj) {
203
- if (obj?.toString) {
204
- // Arrays might hold objects with "null" prototype So using
205
- // Array.prototype.toString directly will cause an error Iterate through
206
- // all the items and handle individually.
207
- if (isArray(obj)) {
208
- // This behavior is slightly different from Array#toString:
209
- // 1. Array#toString calls `this.join`, rather than Array#join
210
- // Ex: arr = []; arr.join = () => 1; arr.toString() === 1; toString(arr) === ''
211
- // 2. Array#toString delegates to Object#toString if `this.join` is not a function
212
- // Ex: arr = []; arr.join = 'no'; arr.toString() === '[object Array]; toString(arr) = ''
213
- // 3. Array#toString converts null/undefined to ''
214
- // Ex: arr = [null, undefined]; arr.toString() === ','; toString(arr) === '[object Null],undefined'
215
- // 4. Array#toString converts recursive references to arrays to ''
216
- // Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
217
- // Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
218
- return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
219
- }
220
- return obj.toString();
221
- }
222
- else if (typeof obj === 'object') {
223
- // This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
224
- return OtS.call(obj);
225
- }
226
- else {
227
- return String(obj);
228
- }
229
- }
230
-
231
- /*
232
- * Copyright (c) 2018, salesforce.com, inc.
233
- * All rights reserved.
234
- * SPDX-License-Identifier: MIT
235
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
236
- */
237
- /**
238
- * According to the following list, there are 48 aria attributes of which two (ariaDropEffect and
239
- * ariaGrabbed) are deprecated:
240
- * https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes
241
- *
242
- * The above list of 46 aria attributes is consistent with the following resources:
243
- * https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
244
- * https://wicg.github.io/aom/spec/aria-reflection.html
245
- *
246
- * NOTE: If you update this list, please update test files that implicitly reference this list!
247
- * Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages.
248
- */
249
- const AriaPropertyNames = [
250
- 'ariaActiveDescendant',
251
- 'ariaAtomic',
252
- 'ariaAutoComplete',
253
- 'ariaBusy',
254
- 'ariaChecked',
255
- 'ariaColCount',
256
- 'ariaColIndex',
257
- 'ariaColIndexText',
258
- 'ariaColSpan',
259
- 'ariaControls',
260
- 'ariaCurrent',
261
- 'ariaDescribedBy',
262
- 'ariaDescription',
263
- 'ariaDetails',
264
- 'ariaDisabled',
265
- 'ariaErrorMessage',
266
- 'ariaExpanded',
267
- 'ariaFlowTo',
268
- 'ariaHasPopup',
269
- 'ariaHidden',
270
- 'ariaInvalid',
271
- 'ariaKeyShortcuts',
272
- 'ariaLabel',
273
- 'ariaLabelledBy',
274
- 'ariaLevel',
275
- 'ariaLive',
276
- 'ariaModal',
277
- 'ariaMultiLine',
278
- 'ariaMultiSelectable',
279
- 'ariaOrientation',
280
- 'ariaOwns',
281
- 'ariaPlaceholder',
282
- 'ariaPosInSet',
283
- 'ariaPressed',
284
- 'ariaReadOnly',
285
- 'ariaRelevant',
286
- 'ariaRequired',
287
- 'ariaRoleDescription',
288
- 'ariaRowCount',
289
- 'ariaRowIndex',
290
- 'ariaRowIndexText',
291
- 'ariaRowSpan',
292
- 'ariaSelected',
293
- 'ariaSetSize',
294
- 'ariaSort',
295
- 'ariaValueMax',
296
- 'ariaValueMin',
297
- 'ariaValueNow',
298
- 'ariaValueText',
299
- 'ariaBrailleLabel',
300
- 'ariaBrailleRoleDescription',
301
- 'role',
302
- ];
303
- const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (() => {
304
- const AriaAttrNameToPropNameMap = create(null);
305
- const AriaPropNameToAttrNameMap = create(null);
306
- // Synthetic creation of all AOM property descriptors for Custom Elements
307
- forEach.call(AriaPropertyNames, (propName) => {
308
- const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
309
- AriaAttrNameToPropNameMap[attrName] = propName;
310
- AriaPropNameToAttrNameMap[propName] = attrName;
311
- });
312
- return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
313
- })();
314
-
315
- /*
316
- * Copyright (c) 2020, salesforce.com, inc.
317
- * All rights reserved.
318
- * SPDX-License-Identifier: MIT
319
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
320
- */
321
- const ESCAPED_CHARS = {
322
- '"': '"',
323
- "'": ''',
324
- '<': '&lt;',
325
- '>': '&gt;',
326
- '&': '&amp;',
327
- };
328
- /**
329
- *
330
- * @param str
331
- * @param attrMode
332
- */
333
- function htmlEscape(str, attrMode = false) {
334
- const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
335
- return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
14
+ // Stubs for all the un-implemented exports from @lwc/engine-server
15
+ function api(..._) {
16
+ throw new Error('@api cannot be used in SSR context.');
336
17
  }
337
- function flattenStylesheets(stylesheets) {
338
- const list = [];
339
- for (const stylesheet of stylesheets) {
340
- if (!isArray(stylesheet)) {
341
- list.push(stylesheet);
342
- }
343
- else {
344
- list.push(...flattenStylesheets(stylesheet));
345
- }
346
- }
347
- return list;
18
+ function createContextProvider(..._) {
19
+ throw new Error('createContextProvider cannot be used in SSR context.');
348
20
  }
349
- /** version: 8.5.0 */
350
-
351
- /*
352
- * Copyright (c) 2024, Salesforce, Inc.
353
- * All rights reserved.
354
- * SPDX-License-Identifier: MIT
355
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
356
- */
357
- var _MutationTracker_enabledSet, _MutationTracker_mutationMap;
358
- class MutationTracker {
359
- constructor() {
360
- _MutationTracker_enabledSet.set(this, new WeakSet());
361
- _MutationTracker_mutationMap.set(this, new WeakMap());
362
- }
363
- add(instance, attrName) {
364
- if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
365
- let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
366
- if (!mutatedAttrs) {
367
- mutatedAttrs = new Set();
368
- __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
369
- }
370
- mutatedAttrs.add(attrName.toLowerCase());
371
- }
372
- }
373
- enable(instance) {
374
- __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
375
- }
376
- disable(instance) {
377
- __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
378
- }
379
- renderMutatedAttrs(instance) {
380
- const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
381
- if (mutatedAttrs) {
382
- return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
383
- }
384
- else {
385
- return '';
386
- }
387
- }
21
+ function createElement(..._) {
22
+ throw new Error('createElement cannot be used in SSR context.');
388
23
  }
389
- _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
390
- const mutationTracker = new MutationTracker();
391
-
392
- /*
393
- * Copyright (c) 2024, Salesforce, Inc.
394
- * All rights reserved.
395
- * SPDX-License-Identifier: MIT
396
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
397
- */
398
- /**
399
- * Map of global attribute or ARIA attribute to the corresponding property name.
400
- * Not all global attributes are included, just those from `HTMLElementTheGoodParts`.
401
- */
402
- const attrsToProps = assign(create(null), {
403
- accesskey: 'accessKey',
404
- dir: 'dir',
405
- draggable: 'draggable',
406
- hidden: 'hidden',
407
- id: 'id',
408
- lang: 'lang',
409
- spellcheck: 'spellcheck',
410
- tabindex: 'tabIndex',
411
- title: 'title',
412
- ...AriaAttrNameToPropNameMap,
413
- });
414
- /**
415
- * Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
416
- */
417
- const stringDescriptor = (attrName) => ({
418
- configurable: true,
419
- enumerable: true,
420
- get() {
421
- return this.getAttribute(attrName);
24
+ function freezeTemplate(..._) {
25
+ throw new Error('freezeTemplate cannot be used in SSR context.');
26
+ }
27
+ function getComponentDef(..._) {
28
+ throw new Error('getComponentDef cannot be used in SSR context.');
29
+ }
30
+ function isComponentConstructor(..._) {
31
+ throw new Error('isComponentConstructor cannot be used in SSR context.');
32
+ }
33
+ function parseFragment(..._) {
34
+ throw new Error('parseFragment cannot be used in SSR context.');
35
+ }
36
+ function parseSVGFragment(..._) {
37
+ throw new Error('parseSVGFragment cannot be used in SSR context.');
38
+ }
39
+ function readonly(..._) {
40
+ throw new Error('readonly cannot be used in SSR context.');
41
+ }
42
+ function registerComponent(..._) {
43
+ throw new Error('registerComponent cannot be used in SSR context.');
44
+ }
45
+ function registerDecorators(..._) {
46
+ throw new Error('registerDecorators cannot be used in SSR context.');
47
+ }
48
+ function registerTemplate(..._) {
49
+ throw new Error('registerTemplate cannot be used in SSR context.');
50
+ }
51
+ function sanitizeAttribute(..._) {
52
+ throw new Error('sanitizeAttribute cannot be used in SSR context.');
53
+ }
54
+ function setFeatureFlag(..._) {
55
+ throw new Error('setFeatureFlag cannot be used in SSR context.');
56
+ }
57
+ function setFeatureFlagForTest(..._) {
58
+ throw new Error('setFeatureFlagForTest cannot be used in SSR context.');
59
+ }
60
+ function swapComponent(..._) {
61
+ throw new Error('swapComponent cannot be used in SSR context.');
62
+ }
63
+ function swapStyle(..._) {
64
+ throw new Error('swapStyle cannot be used in SSR context.');
65
+ }
66
+ function swapTemplate(..._) {
67
+ throw new Error('swapTemplate cannot be used in SSR context.');
68
+ }
69
+ function track(..._) {
70
+ throw new Error('@track cannot be used in SSR context.');
71
+ }
72
+ function unwrap(..._) {
73
+ throw new Error('unwrap cannot be used in SSR context.');
74
+ }
75
+ function wire(..._) {
76
+ throw new Error('@wire cannot be used in SSR context.');
77
+ }
78
+ const renderer = {
79
+ isSyntheticShadowDefined: false,
80
+ insert(..._) {
81
+ throw new Error('renderer.insert cannot be used in SSR context.');
422
82
  },
423
- set(newValue) {
424
- const currentValue = this.getAttribute(attrName);
425
- const normalizedValue = String(newValue);
426
- if (normalizedValue !== currentValue) {
427
- this.setAttribute(attrName, normalizedValue);
428
- }
83
+ remove(..._) {
84
+ throw new Error('renderer.remove cannot be used in SSR context.');
85
+ },
86
+ cloneNode(..._) {
87
+ throw new Error('renderer.cloneNode cannot be used in SSR context.');
88
+ },
89
+ createFragment(..._) {
90
+ throw new Error('renderer.createFragment cannot be used in SSR context.');
91
+ },
92
+ createElement(..._) {
93
+ throw new Error('renderer.createElement cannot be used in SSR context.');
94
+ },
95
+ createText(..._) {
96
+ throw new Error('renderer.createText cannot be used in SSR context.');
97
+ },
98
+ createComment(..._) {
99
+ throw new Error('renderer.createComment cannot be used in SSR context.');
100
+ },
101
+ createCustomElement(..._) {
102
+ throw new Error('renderer.createCustomElement cannot be used in SSR context.');
103
+ },
104
+ nextSibling(..._) {
105
+ throw new Error('renderer.nextSibling cannot be used in SSR context.');
106
+ },
107
+ previousSibling(..._) {
108
+ throw new Error('renderer.previousSibling cannot be used in SSR context.');
109
+ },
110
+ attachShadow(..._) {
111
+ throw new Error('renderer.attachShadow cannot be used in SSR context.');
112
+ },
113
+ getProperty(..._) {
114
+ throw new Error('renderer.getProperty cannot be used in SSR context.');
115
+ },
116
+ setProperty(..._) {
117
+ throw new Error('renderer.setProperty cannot be used in SSR context.');
118
+ },
119
+ setText(..._) {
120
+ throw new Error('renderer.setText cannot be used in SSR context.');
121
+ },
122
+ getAttribute(..._) {
123
+ throw new Error('renderer.getAttribute cannot be used in SSR context.');
124
+ },
125
+ setAttribute(..._) {
126
+ throw new Error('renderer.setAttribute cannot be used in SSR context.');
127
+ },
128
+ removeAttribute(..._) {
129
+ throw new Error('renderer.removeAttribute cannot be used in SSR context.');
130
+ },
131
+ addEventListener(..._) {
132
+ throw new Error('renderer.addEventListener cannot be used in SSR context.');
133
+ },
134
+ removeEventListener(..._) {
135
+ throw new Error('renderer.removeEventListener cannot be used in SSR context.');
136
+ },
137
+ dispatchEvent(..._) {
138
+ throw new Error('renderer.dispatchEvent cannot be used in SSR context.');
139
+ },
140
+ getClassList(..._) {
141
+ throw new Error('renderer.getClassList cannot be used in SSR context.');
142
+ },
143
+ setCSSStyleProperty(..._) {
144
+ throw new Error('renderer.setCSSStyleProperty cannot be used in SSR context.');
145
+ },
146
+ getBoundingClientRect(..._) {
147
+ throw new Error('renderer.getBoundingClientRect cannot be used in SSR context.');
148
+ },
149
+ querySelector(..._) {
150
+ throw new Error('renderer.querySelector cannot be used in SSR context.');
151
+ },
152
+ querySelectorAll(..._) {
153
+ throw new Error('renderer.querySelectorAll cannot be used in SSR context.');
154
+ },
155
+ getElementsByTagName(..._) {
156
+ throw new Error('renderer.getElementsByTagName cannot be used in SSR context.');
157
+ },
158
+ getElementsByClassName(..._) {
159
+ throw new Error('renderer.getElementsByClassName cannot be used in SSR context.');
160
+ },
161
+ getChildren(..._) {
162
+ throw new Error('renderer.getChildren cannot be used in SSR context.');
163
+ },
164
+ getChildNodes(..._) {
165
+ throw new Error('renderer.getChildNodes cannot be used in SSR context.');
166
+ },
167
+ getFirstChild(..._) {
168
+ throw new Error('renderer.getFirstChild cannot be used in SSR context.');
169
+ },
170
+ getFirstElementChild(..._) {
171
+ throw new Error('renderer.getFirstElementChild cannot be used in SSR context.');
172
+ },
173
+ getLastChild(..._) {
174
+ throw new Error('renderer.getLastChild cannot be used in SSR context.');
175
+ },
176
+ getLastElementChild(..._) {
177
+ throw new Error('renderer.getLastElementChild cannot be used in SSR context.');
178
+ },
179
+ getTagName(..._) {
180
+ throw new Error('renderer.getTagName cannot be used in SSR context.');
181
+ },
182
+ getStyle(..._) {
183
+ throw new Error('renderer.getStyle cannot be used in SSR context.');
184
+ },
185
+ isConnected(..._) {
186
+ throw new Error('renderer.isConnected cannot be used in SSR context.');
187
+ },
188
+ insertStylesheet(..._) {
189
+ throw new Error('renderer.insertStylesheet cannot be used in SSR context.');
429
190
  },
430
- });
431
- /** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
432
- const explicitBooleanDescriptor = (attrName, defaultValue) => ({
433
- configurable: true,
434
- enumerable: true,
435
- get() {
436
- const value = this.getAttribute(attrName);
437
- return value === null ? defaultValue : value === String(defaultValue);
191
+ assertInstanceOfHTMLElement(..._) {
192
+ throw new Error('renderer.assertInstanceOfHTMLElement cannot be used in SSR context.');
438
193
  },
439
- set(newValue) {
440
- const currentValue = this.getAttribute(attrName);
441
- const normalizedValue = String(Boolean(newValue));
442
- if (normalizedValue !== currentValue) {
443
- this.setAttribute(attrName, normalizedValue);
444
- }
194
+ ownerDocument(..._) {
195
+ throw new Error('renderer.ownerDocument cannot be used in SSR context.');
445
196
  },
446
- });
447
- /**
448
- * Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
449
- */
450
- const booleanAttributeDescriptor = (attrName) => ({
451
- configurable: true,
452
- enumerable: true,
453
- get() {
454
- return this.hasAttribute(attrName);
197
+ registerContextConsumer(..._) {
198
+ throw new Error('renderer.registerContextConsumer cannot be used in SSR context.');
455
199
  },
456
- set(newValue) {
457
- const hasAttribute = this.hasAttribute(attrName);
458
- if (newValue) {
459
- if (!hasAttribute) {
460
- this.setAttribute(attrName, '');
461
- }
462
- }
463
- else {
464
- if (hasAttribute) {
465
- this.removeAttribute(attrName);
466
- }
467
- }
200
+ attachInternals(..._) {
201
+ throw new Error('renderer.attachInternals cannot be used in SSR context.');
468
202
  },
469
- });
470
- /**
471
- * Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
472
- */
473
- const ariaDescriptor = (attrName) => ({
474
- configurable: true,
475
- enumerable: true,
476
- get() {
477
- return this.getAttribute(attrName);
203
+ defineCustomElement(..._) {
204
+ throw new Error('renderer.defineCustomElement cannot be used in SSR context.');
478
205
  },
479
- set(newValue) {
480
- const currentValue = this.getAttribute(attrName);
481
- if (newValue !== currentValue) {
482
- // TODO [#3284]: According to the spec, IDL nullable type values
483
- // (null and undefined) should remove the attribute; however, we
484
- // only do so in the case of null for historical reasons.
485
- if (isNull(newValue)) {
486
- this.removeAttribute(attrName);
487
- }
488
- else {
489
- this.setAttribute(attrName, toString(newValue));
490
- }
491
- }
206
+ getParentNode(..._) {
207
+ throw new Error('renderer.getParentNode cannot be used in SSR context.');
492
208
  },
493
- });
494
- function reflectAttrToProp(instance, attrName, attrValue) {
495
- const reflectedPropName = attrsToProps[attrName];
496
- // If it is a reflected property and it was not overridden by the instance
497
- if (reflectedPropName && !hasOwnProperty.call(instance, reflectedPropName)) {
498
- const currentValue = instance[reflectedPropName];
499
- if (currentValue !== attrValue) {
500
- instance[reflectedPropName] = attrValue;
501
- }
502
- }
503
- }
504
- const descriptors = {
505
- accessKey: stringDescriptor('accesskey'),
506
- dir: stringDescriptor('dir'),
507
- draggable: explicitBooleanDescriptor('draggable', true),
508
- hidden: booleanAttributeDescriptor('hidden'),
509
- id: stringDescriptor('id'),
510
- lang: stringDescriptor('lang'),
511
- spellcheck: explicitBooleanDescriptor('spellcheck', false),
512
- tabIndex: {
513
- get() {
514
- const str = this.getAttribute('tabindex');
515
- const num = Number(str);
516
- return isFinite(num) ? Math.trunc(num) : -1;
517
- },
518
- set(newValue) {
519
- const currentValue = this.getAttribute('tabindex');
520
- const num = Number(newValue);
521
- const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
522
- if (normalizedValue !== currentValue) {
523
- this.setAttribute('tabindex', toString(newValue));
524
- }
525
- },
209
+ startTrackingMutations(..._) {
210
+ throw new Error('renderer.startTrackingMutations cannot be used in SSR context.');
211
+ },
212
+ stopTrackingMutations(..._) {
213
+ throw new Error('renderer.stopTrackingMutations cannot be used in SSR context.');
526
214
  },
527
- title: stringDescriptor('title'),
528
215
  };
529
- // Add descriptors for ARIA attributes
530
- for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
531
- descriptors[propName] = ariaDescriptor(attrName);
532
- }
216
+ /**
217
+ * The hot API is used to orchestrate hot swapping in client rendered components.
218
+ * It doesn't do anything on the server side, however, you may import it.
219
+ *
220
+ * The whole point of defining this and exporting it is so that you can import it in isomorphic code without
221
+ * an error being thrown by the import itself.
222
+ */
223
+ // A real stub, not a "not implemented" one! 😯
224
+ const hot = undefined;
533
225
 
226
+ /**
227
+ * Copyright (c) 2024 Salesforce, Inc.
228
+ */
534
229
  /*
535
- * Copyright (c) 2024, salesforce.com, inc.
230
+ * Copyright (c) 2018, salesforce.com, inc.
536
231
  * All rights reserved.
537
232
  * SPDX-License-Identifier: MIT
538
233
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
539
- */
540
- var _LightningElement_attrs, _LightningElement_classList;
541
- const SYMBOL__SET_INTERNALS = Symbol('set-internals');
542
- const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
543
- class LightningElement {
544
- constructor(propsAvailableAtConstruction) {
545
- this.isConnected = false;
546
- this.className = '';
547
- _LightningElement_attrs.set(this, void 0);
548
- _LightningElement_classList.set(this, null);
549
- assign(this, propsAvailableAtConstruction);
550
- }
551
- [(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
552
- __classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
553
- assign(this, props);
554
- defineProperty(this, 'className', {
555
- get() {
556
- return props.class ?? '';
557
- },
558
- set(newVal) {
559
- props.class = newVal;
560
- attrs.class = newVal;
561
- mutationTracker.add(this, 'class');
562
- },
563
- });
564
- }
565
- get classList() {
566
- if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
567
- return __classPrivateFieldGet(this, _LightningElement_classList, "f");
568
- }
569
- return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
570
- }
571
- setAttribute(attrName, attrValue) {
572
- const normalizedName = StringToLowerCase.call(toString(attrName));
573
- const normalizedValue = String(attrValue);
574
- __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
575
- reflectAttrToProp(this, normalizedName, normalizedValue);
576
- mutationTracker.add(this, normalizedName);
577
- }
578
- getAttribute(attrName) {
579
- const normalizedName = StringToLowerCase.call(toString(attrName));
580
- if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
581
- return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
582
- }
583
- return null;
584
- }
585
- hasAttribute(attrName) {
586
- const normalizedName = StringToLowerCase.call(toString(attrName));
587
- return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
588
- }
589
- removeAttribute(attrName) {
590
- const normalizedName = StringToLowerCase.call(toString(attrName));
591
- delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
592
- reflectAttrToProp(this, normalizedName, null);
593
- // Track mutations for removal of non-existing attributes
594
- mutationTracker.add(this, normalizedName);
595
- }
596
- addEventListener(_type, _listener, _options) {
597
- // noop
598
- }
599
- removeEventListener(_type, _listener, _options) {
600
- // noop
601
- }
602
- // ----------------------------------------------------------- //
603
- // Props/methods explicitly not available in this environment //
604
- // Getters are named "get*" for parity with @lwc/engine-server //
605
- // ----------------------------------------------------------- //
606
- get children() {
607
- throw new TypeError('"getChildren" is not supported in this environment');
608
- }
609
- get childNodes() {
610
- throw new TypeError('"getChildNodes" is not supported in this environment');
611
- }
612
- get firstChild() {
613
- throw new TypeError('"getFirstChild" is not supported in this environment');
614
- }
615
- get firstElementChild() {
616
- throw new TypeError('"getFirstElementChild" is not supported in this environment');
617
- }
618
- get hostElement() {
619
- // Intentionally different to match @lwc/engine-*core*
620
- throw new TypeError('this.hostElement is not supported in this environment');
621
- }
622
- get lastChild() {
623
- throw new TypeError('"getLastChild" is not supported in this environment');
624
- }
625
- get lastElementChild() {
626
- throw new TypeError('"getLastElementChild" is not supported in this environment');
627
- }
628
- get ownerDocument() {
629
- // Intentionally not "get*" to match @lwc/engine-server
630
- throw new TypeError('"ownerDocument" is not supported in this environment');
631
- }
632
- get style() {
633
- // Intentionally not "get*" to match @lwc/engine-server
634
- throw new TypeError('"style" is not supported in this environment');
635
- }
636
- attachInternals() {
637
- throw new TypeError('"attachInternals" is not supported in this environment');
638
- }
639
- dispatchEvent(_event) {
640
- throw new TypeError('"dispatchEvent" is not supported in this environment');
641
- }
642
- getBoundingClientRect() {
643
- throw new TypeError('"getBoundingClientRect" is not supported in this environment');
644
- }
645
- getElementsByClassName(_classNames) {
646
- throw new TypeError('"getElementsByClassName" is not supported in this environment');
647
- }
648
- getElementsByTagName(_qualifiedName) {
649
- throw new TypeError('"getElementsByTagName" is not supported in this environment');
650
- }
651
- querySelector(_selectors) {
652
- throw new TypeError('"querySelector" is not supported in this environment');
653
- }
654
- querySelectorAll(_selectors) {
655
- throw new TypeError('"querySelectorAll" is not supported in this environment');
656
- }
657
- getAttributeNS(_namespace, _localName) {
658
- throw new Error('Method "getAttributeNS" not implemented.');
659
- }
660
- hasAttributeNS(_namespace, _localName) {
661
- throw new Error('Method "hasAttributeNS" not implemented.');
662
- }
663
- removeAttributeNS(_namespace, _localName) {
664
- throw new Error('Method "removeAttributeNS" not implemented.');
665
- }
666
- setAttributeNS(_namespace, _qualifiedName, _value) {
667
- throw new Error('Method "setAttributeNS" not implemented.');
234
+ */
235
+ /**
236
+ *
237
+ * @param value
238
+ * @param msg
239
+ */
240
+ /**
241
+ *
242
+ * @param value
243
+ * @param msg
244
+ */
245
+ function isFalse$1(value, msg) {
246
+ if (value) {
247
+ throw new Error(`Assert Violation: ${msg}`);
668
248
  }
669
249
  }
670
- defineProperties(LightningElement.prototype, descriptors);
671
250
 
672
251
  /*
673
- * Copyright (c) 2024, salesforce.com, inc.
252
+ * Copyright (c) 2024, Salesforce, Inc.
674
253
  * All rights reserved.
675
254
  * SPDX-License-Identifier: MIT
676
255
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
677
256
  */
678
- const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&amp;').replaceAll('"', '&quot;');
679
- function* renderAttrs(instance, attrs) {
680
- if (!attrs) {
681
- return;
682
- }
683
- for (const attrName of Object.getOwnPropertyNames(attrs)) {
684
- const attrVal = attrs[attrName];
685
- if (typeof attrVal === 'string') {
686
- yield attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`;
687
- }
688
- else if (attrVal === null) {
689
- yield '';
690
- }
691
- }
692
- yield mutationTracker.renderMutatedAttrs(instance);
693
- }
694
- function renderAttrsNoYield(emit, instance, attrs) {
695
- if (!attrs) {
696
- return;
697
- }
698
- for (const attrName of Object.getOwnPropertyNames(attrs)) {
699
- const attrVal = attrs[attrName];
700
- if (typeof attrVal === 'string') {
701
- emit(attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`);
702
- }
703
- else if (attrVal === null) {
704
- emit('');
705
- }
706
- }
707
- emit(mutationTracker.renderMutatedAttrs(instance));
708
- }
709
- function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
710
- if (Cmp.renderMode !== 'light') {
711
- yield '<template shadowrootmode="open"></template>';
712
- }
713
- }
714
- function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
715
- if (Cmp.renderMode !== 'light') {
716
- emit('<template shadowrootmode="open"></template>');
717
- }
257
+ const {
258
+ /** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */
259
+ assign,
260
+ /** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */
261
+ create,
262
+ /** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */
263
+ defineProperties,
264
+ /** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */
265
+ defineProperty,
266
+ /** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
267
+ entries,
268
+ /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
269
+ freeze,
270
+ /** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
271
+ fromEntries,
272
+ /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
273
+ getOwnPropertyDescriptor,
274
+ /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
275
+ getOwnPropertyDescriptors,
276
+ /** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
277
+ getOwnPropertyNames,
278
+ /** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
279
+ getOwnPropertySymbols,
280
+ /** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
281
+ getPrototypeOf,
282
+ /** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
283
+ hasOwnProperty,
284
+ /** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
285
+ isFrozen,
286
+ /** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
287
+ keys,
288
+ /** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
289
+ seal,
290
+ /** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
291
+ setPrototypeOf, } = Object;
292
+ const {
293
+ /** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
294
+ isArray,
295
+ /** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
296
+ from: ArrayFrom, } = Array;
297
+ // For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
298
+ // though it works fine for one, e.g. isArray), so comments for these are added to the export
299
+ // statement, rather than this declaration.
300
+ 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!
301
+ } = Array.prototype;
302
+ // No JSDocs here - see comment for Array.prototype
303
+ const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
304
+ /**
305
+ * Determines whether the argument is `null`.
306
+ * @param obj Value to test
307
+ * @returns `true` if the value is `null`.
308
+ */
309
+ function isNull(obj) {
310
+ return obj === null;
718
311
  }
719
- async function serverSideRenderComponent(tagName, Component, props = {}, mode = 'asyncYield') {
720
- if (typeof tagName !== 'string') {
721
- throw new Error(`tagName must be a string, found: ${tagName}`);
722
- }
723
- // TODO [#4726]: remove `generateMarkup` export
724
- const generateMarkup = SYMBOL__GENERATE_MARKUP in Component ? Component[SYMBOL__GENERATE_MARKUP] : Component;
725
- let markup = '';
726
- const emit = (segment) => {
727
- markup += segment;
728
- };
729
- if (mode === 'asyncYield') {
730
- for await (const segment of generateMarkup(tagName, props, null, null)) {
731
- markup += segment;
312
+ const OtS = {}.toString;
313
+ /**
314
+ * Converts the argument to a string, safely accounting for objects with "null" prototype.
315
+ * Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
316
+ * @param obj Value to convert to a string.
317
+ * @returns String representation of the value.
318
+ */
319
+ function toString(obj) {
320
+ if (obj?.toString) {
321
+ // Arrays might hold objects with "null" prototype So using
322
+ // Array.prototype.toString directly will cause an error Iterate through
323
+ // all the items and handle individually.
324
+ if (isArray(obj)) {
325
+ // This behavior is slightly different from Array#toString:
326
+ // 1. Array#toString calls `this.join`, rather than Array#join
327
+ // Ex: arr = []; arr.join = () => 1; arr.toString() === 1; toString(arr) === ''
328
+ // 2. Array#toString delegates to Object#toString if `this.join` is not a function
329
+ // Ex: arr = []; arr.join = 'no'; arr.toString() === '[object Array]; toString(arr) = ''
330
+ // 3. Array#toString converts null/undefined to ''
331
+ // Ex: arr = [null, undefined]; arr.toString() === ','; toString(arr) === '[object Null],undefined'
332
+ // 4. Array#toString converts recursive references to arrays to ''
333
+ // Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
334
+ // Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
335
+ return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
732
336
  }
337
+ return obj.toString();
733
338
  }
734
- else if (mode === 'async') {
735
- await generateMarkup(emit, tagName, props, null, null);
736
- }
737
- else if (mode === 'sync') {
738
- generateMarkup(emit, tagName, props, null, null);
339
+ else if (typeof obj === 'object') {
340
+ // This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
341
+ return OtS.call(obj);
739
342
  }
740
343
  else {
741
- throw new Error(`Invalid mode: ${mode}`);
344
+ return String(obj);
742
345
  }
743
- return markup;
346
+ }
347
+
348
+ /*
349
+ * Copyright (c) 2018, salesforce.com, inc.
350
+ * All rights reserved.
351
+ * SPDX-License-Identifier: MIT
352
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
353
+ */
354
+ /**
355
+ * According to the following list, there are 48 aria attributes of which two (ariaDropEffect and
356
+ * ariaGrabbed) are deprecated:
357
+ * https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes
358
+ *
359
+ * The above list of 46 aria attributes is consistent with the following resources:
360
+ * https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
361
+ * https://wicg.github.io/aom/spec/aria-reflection.html
362
+ *
363
+ * NOTE: If you update this list, please update test files that implicitly reference this list!
364
+ * Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages.
365
+ */
366
+ const AriaPropertyNames = [
367
+ 'ariaActiveDescendant',
368
+ 'ariaAtomic',
369
+ 'ariaAutoComplete',
370
+ 'ariaBusy',
371
+ 'ariaChecked',
372
+ 'ariaColCount',
373
+ 'ariaColIndex',
374
+ 'ariaColIndexText',
375
+ 'ariaColSpan',
376
+ 'ariaControls',
377
+ 'ariaCurrent',
378
+ 'ariaDescribedBy',
379
+ 'ariaDescription',
380
+ 'ariaDetails',
381
+ 'ariaDisabled',
382
+ 'ariaErrorMessage',
383
+ 'ariaExpanded',
384
+ 'ariaFlowTo',
385
+ 'ariaHasPopup',
386
+ 'ariaHidden',
387
+ 'ariaInvalid',
388
+ 'ariaKeyShortcuts',
389
+ 'ariaLabel',
390
+ 'ariaLabelledBy',
391
+ 'ariaLevel',
392
+ 'ariaLive',
393
+ 'ariaModal',
394
+ 'ariaMultiLine',
395
+ 'ariaMultiSelectable',
396
+ 'ariaOrientation',
397
+ 'ariaOwns',
398
+ 'ariaPlaceholder',
399
+ 'ariaPosInSet',
400
+ 'ariaPressed',
401
+ 'ariaReadOnly',
402
+ 'ariaRelevant',
403
+ 'ariaRequired',
404
+ 'ariaRoleDescription',
405
+ 'ariaRowCount',
406
+ 'ariaRowIndex',
407
+ 'ariaRowIndexText',
408
+ 'ariaRowSpan',
409
+ 'ariaSelected',
410
+ 'ariaSetSize',
411
+ 'ariaSort',
412
+ 'ariaValueMax',
413
+ 'ariaValueMin',
414
+ 'ariaValueNow',
415
+ 'ariaValueText',
416
+ 'ariaBrailleLabel',
417
+ 'ariaBrailleRoleDescription',
418
+ 'role',
419
+ ];
420
+ const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (() => {
421
+ const AriaAttrNameToPropNameMap = create(null);
422
+ const AriaPropNameToAttrNameMap = create(null);
423
+ // Synthetic creation of all AOM property descriptors for Custom Elements
424
+ forEach.call(AriaPropertyNames, (propName) => {
425
+ const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
426
+ AriaAttrNameToPropNameMap[attrName] = propName;
427
+ AriaPropNameToAttrNameMap[propName] = attrName;
428
+ });
429
+ return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
430
+ })();
431
+
432
+ /*
433
+ * Copyright (c) 2020, salesforce.com, inc.
434
+ * All rights reserved.
435
+ * SPDX-License-Identifier: MIT
436
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
437
+ */
438
+ const ESCAPED_CHARS = {
439
+ '"': '&quot;',
440
+ "'": '&#x27;',
441
+ '<': '&lt;',
442
+ '>': '&gt;',
443
+ '&': '&amp;',
444
+ };
445
+ /**
446
+ *
447
+ * @param str
448
+ * @param attrMode
449
+ */
450
+ function htmlEscape(str, attrMode = false) {
451
+ const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
452
+ return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
744
453
  }
745
454
 
746
455
  /*
@@ -749,220 +458,467 @@ async function serverSideRenderComponent(tagName, Component, props = {}, mode =
749
458
  * SPDX-License-Identifier: MIT
750
459
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
751
460
  */
752
- // Stubs for all the un-implemented exports from @lwc/engine-server
753
- function api(..._) {
754
- throw new Error('@api cannot be used in SSR context.');
755
- }
756
- function createContextProvider(..._) {
757
- throw new Error('createContextProvider cannot be used in SSR context.');
758
- }
759
- function createElement(..._) {
760
- throw new Error('createElement cannot be used in SSR context.');
761
- }
762
- function freezeTemplate(..._) {
763
- throw new Error('freezeTemplate cannot be used in SSR context.');
764
- }
765
- function getComponentDef(..._) {
766
- throw new Error('getComponentDef cannot be used in SSR context.');
767
- }
768
- function isComponentConstructor(..._) {
769
- throw new Error('isComponentConstructor cannot be used in SSR context.');
770
- }
771
- function parseFragment(..._) {
772
- throw new Error('parseFragment cannot be used in SSR context.');
773
- }
774
- function parseSVGFragment(..._) {
775
- throw new Error('parseSVGFragment cannot be used in SSR context.');
776
- }
777
- function readonly(..._) {
778
- throw new Error('readonly cannot be used in SSR context.');
779
- }
780
- function registerComponent(..._) {
781
- throw new Error('registerComponent cannot be used in SSR context.');
782
- }
783
- function registerDecorators(..._) {
784
- throw new Error('registerDecorators cannot be used in SSR context.');
785
- }
786
- function registerTemplate(..._) {
787
- throw new Error('registerTemplate cannot be used in SSR context.');
788
- }
789
- function sanitizeAttribute(..._) {
790
- throw new Error('sanitizeAttribute cannot be used in SSR context.');
791
- }
792
- function setFeatureFlag(..._) {
793
- throw new Error('setFeatureFlag cannot be used in SSR context.');
794
- }
795
- function setFeatureFlagForTest(..._) {
796
- throw new Error('setFeatureFlagForTest cannot be used in SSR context.');
797
- }
798
- function setHooks(..._) {
799
- throw new Error('setHooks cannot be used in SSR context.');
800
- }
801
- function swapComponent(..._) {
802
- throw new Error('swapComponent cannot be used in SSR context.');
803
- }
804
- function swapStyle(..._) {
805
- throw new Error('swapStyle cannot be used in SSR context.');
806
- }
807
- function swapTemplate(..._) {
808
- throw new Error('swapTemplate cannot be used in SSR context.');
809
- }
810
- function track(..._) {
811
- throw new Error('@track cannot be used in SSR context.');
812
- }
813
- function unwrap(..._) {
814
- throw new Error('unwrap cannot be used in SSR context.');
461
+ let hooksAreSet = false;
462
+ /**
463
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
464
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
465
+ * lwc:inner-html directive.
466
+ * It is meant to be overridden via `setHooks`; it throws an error by default.
467
+ */
468
+ exports.sanitizeHtmlContent = () => {
469
+ // locker-service patches this function during runtime to sanitize HTML content.
470
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
471
+ };
472
+ function setHooks(hooks) {
473
+ isFalse$1(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
474
+ hooksAreSet = true;
475
+ exports.sanitizeHtmlContent = hooks.sanitizeHtmlContent;
815
476
  }
816
- function wire(..._) {
817
- throw new Error('@wire cannot be used in SSR context.');
477
+ function flattenStylesheets(stylesheets) {
478
+ const list = [];
479
+ for (const stylesheet of stylesheets) {
480
+ if (!isArray(stylesheet)) {
481
+ list.push(stylesheet);
482
+ }
483
+ else {
484
+ list.push(...flattenStylesheets(stylesheet));
485
+ }
486
+ }
487
+ return list;
818
488
  }
819
- const renderer = {
820
- isSyntheticShadowDefined: false,
821
- insert(..._) {
822
- throw new Error('renderer.insert cannot be used in SSR context.');
823
- },
824
- remove(..._) {
825
- throw new Error('renderer.remove cannot be used in SSR context.');
826
- },
827
- cloneNode(..._) {
828
- throw new Error('renderer.cloneNode cannot be used in SSR context.');
829
- },
830
- createFragment(..._) {
831
- throw new Error('renderer.createFragment cannot be used in SSR context.');
832
- },
833
- createElement(..._) {
834
- throw new Error('renderer.createElement cannot be used in SSR context.');
835
- },
836
- createText(..._) {
837
- throw new Error('renderer.createText cannot be used in SSR context.');
838
- },
839
- createComment(..._) {
840
- throw new Error('renderer.createComment cannot be used in SSR context.');
841
- },
842
- createCustomElement(..._) {
843
- throw new Error('renderer.createCustomElement cannot be used in SSR context.');
844
- },
845
- nextSibling(..._) {
846
- throw new Error('renderer.nextSibling cannot be used in SSR context.');
847
- },
848
- previousSibling(..._) {
849
- throw new Error('renderer.previousSibling cannot be used in SSR context.');
850
- },
851
- attachShadow(..._) {
852
- throw new Error('renderer.attachShadow cannot be used in SSR context.');
853
- },
854
- getProperty(..._) {
855
- throw new Error('renderer.getProperty cannot be used in SSR context.');
856
- },
857
- setProperty(..._) {
858
- throw new Error('renderer.setProperty cannot be used in SSR context.');
859
- },
860
- setText(..._) {
861
- throw new Error('renderer.setText cannot be used in SSR context.');
862
- },
863
- getAttribute(..._) {
864
- throw new Error('renderer.getAttribute cannot be used in SSR context.');
865
- },
866
- setAttribute(..._) {
867
- throw new Error('renderer.setAttribute cannot be used in SSR context.');
868
- },
869
- removeAttribute(..._) {
870
- throw new Error('renderer.removeAttribute cannot be used in SSR context.');
871
- },
872
- addEventListener(..._) {
873
- throw new Error('renderer.addEventListener cannot be used in SSR context.');
874
- },
875
- removeEventListener(..._) {
876
- throw new Error('renderer.removeEventListener cannot be used in SSR context.');
877
- },
878
- dispatchEvent(..._) {
879
- throw new Error('renderer.dispatchEvent cannot be used in SSR context.');
880
- },
881
- getClassList(..._) {
882
- throw new Error('renderer.getClassList cannot be used in SSR context.');
883
- },
884
- setCSSStyleProperty(..._) {
885
- throw new Error('renderer.setCSSStyleProperty cannot be used in SSR context.');
886
- },
887
- getBoundingClientRect(..._) {
888
- throw new Error('renderer.getBoundingClientRect cannot be used in SSR context.');
889
- },
890
- querySelector(..._) {
891
- throw new Error('renderer.querySelector cannot be used in SSR context.');
892
- },
893
- querySelectorAll(..._) {
894
- throw new Error('renderer.querySelectorAll cannot be used in SSR context.');
895
- },
896
- getElementsByTagName(..._) {
897
- throw new Error('renderer.getElementsByTagName cannot be used in SSR context.');
898
- },
899
- getElementsByClassName(..._) {
900
- throw new Error('renderer.getElementsByClassName cannot be used in SSR context.');
901
- },
902
- getChildren(..._) {
903
- throw new Error('renderer.getChildren cannot be used in SSR context.');
904
- },
905
- getChildNodes(..._) {
906
- throw new Error('renderer.getChildNodes cannot be used in SSR context.');
907
- },
908
- getFirstChild(..._) {
909
- throw new Error('renderer.getFirstChild cannot be used in SSR context.');
910
- },
911
- getFirstElementChild(..._) {
912
- throw new Error('renderer.getFirstElementChild cannot be used in SSR context.');
913
- },
914
- getLastChild(..._) {
915
- throw new Error('renderer.getLastChild cannot be used in SSR context.');
916
- },
917
- getLastElementChild(..._) {
918
- throw new Error('renderer.getLastElementChild cannot be used in SSR context.');
919
- },
920
- getTagName(..._) {
921
- throw new Error('renderer.getTagName cannot be used in SSR context.');
922
- },
923
- getStyle(..._) {
924
- throw new Error('renderer.getStyle cannot be used in SSR context.');
925
- },
926
- isConnected(..._) {
927
- throw new Error('renderer.isConnected cannot be used in SSR context.');
928
- },
929
- insertStylesheet(..._) {
930
- throw new Error('renderer.insertStylesheet cannot be used in SSR context.');
489
+ /** version: 8.6.0 */
490
+
491
+ /*
492
+ * Copyright (c) 2024, Salesforce, Inc.
493
+ * All rights reserved.
494
+ * SPDX-License-Identifier: MIT
495
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
496
+ */
497
+ const MULTI_SPACE = /\s+/g;
498
+ class ClassList {
499
+ constructor(el) {
500
+ this.el = el;
501
+ }
502
+ add(...newClassNames) {
503
+ const className = this.el.className;
504
+ const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
505
+ for (const newClassName of newClassNames) {
506
+ set.add(newClassName);
507
+ }
508
+ this.el.className = Array.from(set).join(' ');
509
+ }
510
+ contains(className) {
511
+ const currentClassNameStr = this.el.className;
512
+ return currentClassNameStr.split(MULTI_SPACE).includes(className);
513
+ }
514
+ remove(...classNamesToRemove) {
515
+ const className = this.el.className;
516
+ const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
517
+ for (const newClassName of classNamesToRemove) {
518
+ set.delete(newClassName);
519
+ }
520
+ this.el.className = Array.from(set).join(' ');
521
+ }
522
+ replace(oldClassName, newClassName) {
523
+ let classWasReplaced = false;
524
+ const className = this.el.className;
525
+ const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
526
+ listOfClasses.forEach((value, idx) => {
527
+ if (value === oldClassName) {
528
+ classWasReplaced = true;
529
+ listOfClasses[idx] = newClassName;
530
+ }
531
+ });
532
+ this.el.className = listOfClasses.join(' ');
533
+ return classWasReplaced;
534
+ }
535
+ toggle(classNameToToggle, force) {
536
+ const classNameStr = this.el.className;
537
+ const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
538
+ if (!set.has(classNameToToggle) && force !== false) {
539
+ set.add(classNameToToggle);
540
+ }
541
+ else if (set.has(classNameToToggle) && force !== true) {
542
+ set.delete(classNameToToggle);
543
+ }
544
+ this.el.className = Array.from(set).join(' ');
545
+ return set.has(classNameToToggle);
546
+ }
547
+ get value() {
548
+ return this.el.className;
549
+ }
550
+ toString() {
551
+ return this.el.className;
552
+ }
553
+ item(_index) {
554
+ throw new Error('Method "item" not implemented.');
555
+ }
556
+ supports(_token) {
557
+ throw new Error('Method "supports" not implemented.');
558
+ }
559
+ forEach(_callbackfn, _thisArg) {
560
+ throw new Error('Method "forEach" not implemented.');
561
+ }
562
+ get length() {
563
+ throw new Error('Property "length" not implemented.');
564
+ }
565
+ }
566
+
567
+ /******************************************************************************
568
+ Copyright (c) Microsoft Corporation.
569
+
570
+ Permission to use, copy, modify, and/or distribute this software for any
571
+ purpose with or without fee is hereby granted.
572
+
573
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
574
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
575
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
576
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
577
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
578
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
579
+ PERFORMANCE OF THIS SOFTWARE.
580
+ ***************************************************************************** */
581
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
582
+
583
+
584
+ function __classPrivateFieldGet(receiver, state, kind, f) {
585
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
586
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
587
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
588
+ }
589
+
590
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
591
+ if (kind === "m") throw new TypeError("Private method is not writable");
592
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
593
+ 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");
594
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
595
+ }
596
+
597
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
598
+ var e = new Error(message);
599
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
600
+ };
601
+
602
+ /*
603
+ * Copyright (c) 2024, Salesforce, Inc.
604
+ * All rights reserved.
605
+ * SPDX-License-Identifier: MIT
606
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
607
+ */
608
+ var _MutationTracker_enabledSet, _MutationTracker_mutationMap;
609
+ class MutationTracker {
610
+ constructor() {
611
+ _MutationTracker_enabledSet.set(this, new WeakSet());
612
+ _MutationTracker_mutationMap.set(this, new WeakMap());
613
+ }
614
+ add(instance, attrName) {
615
+ if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
616
+ let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
617
+ if (!mutatedAttrs) {
618
+ mutatedAttrs = new Set();
619
+ __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
620
+ }
621
+ mutatedAttrs.add(attrName.toLowerCase());
622
+ }
623
+ }
624
+ enable(instance) {
625
+ __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
626
+ }
627
+ disable(instance) {
628
+ __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
629
+ }
630
+ renderMutatedAttrs(instance) {
631
+ const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
632
+ if (mutatedAttrs) {
633
+ return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
634
+ }
635
+ else {
636
+ return '';
637
+ }
638
+ }
639
+ }
640
+ _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
641
+ const mutationTracker = new MutationTracker();
642
+
643
+ /*
644
+ * Copyright (c) 2024, Salesforce, Inc.
645
+ * All rights reserved.
646
+ * SPDX-License-Identifier: MIT
647
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
648
+ */
649
+ /**
650
+ * Map of global attribute or ARIA attribute to the corresponding property name.
651
+ * Not all global attributes are included, just those from `HTMLElementTheGoodParts`.
652
+ */
653
+ const attrsToProps = assign(create(null), {
654
+ accesskey: 'accessKey',
655
+ dir: 'dir',
656
+ draggable: 'draggable',
657
+ hidden: 'hidden',
658
+ id: 'id',
659
+ lang: 'lang',
660
+ spellcheck: 'spellcheck',
661
+ tabindex: 'tabIndex',
662
+ title: 'title',
663
+ ...AriaAttrNameToPropNameMap,
664
+ });
665
+ /**
666
+ * Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
667
+ */
668
+ const stringDescriptor = (attrName) => ({
669
+ configurable: true,
670
+ enumerable: true,
671
+ get() {
672
+ return this.getAttribute(attrName);
931
673
  },
932
- assertInstanceOfHTMLElement(..._) {
933
- throw new Error('renderer.assertInstanceOfHTMLElement cannot be used in SSR context.');
674
+ set(newValue) {
675
+ const currentValue = this.getAttribute(attrName);
676
+ const normalizedValue = String(newValue);
677
+ if (normalizedValue !== currentValue) {
678
+ this.setAttribute(attrName, normalizedValue);
679
+ }
934
680
  },
935
- ownerDocument(..._) {
936
- throw new Error('renderer.ownerDocument cannot be used in SSR context.');
681
+ });
682
+ /** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
683
+ const explicitBooleanDescriptor = (attrName, defaultValue) => ({
684
+ configurable: true,
685
+ enumerable: true,
686
+ get() {
687
+ const value = this.getAttribute(attrName);
688
+ return value === null ? defaultValue : value === String(defaultValue);
937
689
  },
938
- registerContextConsumer(..._) {
939
- throw new Error('renderer.registerContextConsumer cannot be used in SSR context.');
690
+ set(newValue) {
691
+ const currentValue = this.getAttribute(attrName);
692
+ const normalizedValue = String(Boolean(newValue));
693
+ if (normalizedValue !== currentValue) {
694
+ this.setAttribute(attrName, normalizedValue);
695
+ }
940
696
  },
941
- attachInternals(..._) {
942
- throw new Error('renderer.attachInternals cannot be used in SSR context.');
697
+ });
698
+ /**
699
+ * Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
700
+ */
701
+ const booleanAttributeDescriptor = (attrName) => ({
702
+ configurable: true,
703
+ enumerable: true,
704
+ get() {
705
+ return this.hasAttribute(attrName);
943
706
  },
944
- defineCustomElement(..._) {
945
- throw new Error('renderer.defineCustomElement cannot be used in SSR context.');
707
+ set(newValue) {
708
+ const hasAttribute = this.hasAttribute(attrName);
709
+ if (newValue) {
710
+ if (!hasAttribute) {
711
+ this.setAttribute(attrName, '');
712
+ }
713
+ }
714
+ else {
715
+ if (hasAttribute) {
716
+ this.removeAttribute(attrName);
717
+ }
718
+ }
946
719
  },
947
- getParentNode(..._) {
948
- throw new Error('renderer.getParentNode cannot be used in SSR context.');
720
+ });
721
+ /**
722
+ * Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
723
+ */
724
+ const ariaDescriptor = (attrName) => ({
725
+ configurable: true,
726
+ enumerable: true,
727
+ get() {
728
+ return this.getAttribute(attrName);
949
729
  },
950
- startTrackingMutations(..._) {
951
- throw new Error('renderer.startTrackingMutations cannot be used in SSR context.');
730
+ set(newValue) {
731
+ const currentValue = this.getAttribute(attrName);
732
+ if (newValue !== currentValue) {
733
+ // TODO [#3284]: According to the spec, IDL nullable type values
734
+ // (null and undefined) should remove the attribute; however, we
735
+ // only do so in the case of null for historical reasons.
736
+ if (isNull(newValue)) {
737
+ this.removeAttribute(attrName);
738
+ }
739
+ else {
740
+ this.setAttribute(attrName, toString(newValue));
741
+ }
742
+ }
952
743
  },
953
- stopTrackingMutations(..._) {
954
- throw new Error('renderer.stopTrackingMutations cannot be used in SSR context.');
744
+ });
745
+ function reflectAttrToProp(instance, attrName, attrValue) {
746
+ const reflectedPropName = attrsToProps[attrName];
747
+ // If it is a reflected property and it was not overridden by the instance
748
+ if (reflectedPropName && !hasOwnProperty.call(instance, reflectedPropName)) {
749
+ const currentValue = instance[reflectedPropName];
750
+ if (currentValue !== attrValue) {
751
+ instance[reflectedPropName] = attrValue;
752
+ }
753
+ }
754
+ }
755
+ const descriptors = {
756
+ accessKey: stringDescriptor('accesskey'),
757
+ dir: stringDescriptor('dir'),
758
+ draggable: explicitBooleanDescriptor('draggable', true),
759
+ hidden: booleanAttributeDescriptor('hidden'),
760
+ id: stringDescriptor('id'),
761
+ lang: stringDescriptor('lang'),
762
+ spellcheck: explicitBooleanDescriptor('spellcheck', false),
763
+ tabIndex: {
764
+ get() {
765
+ const str = this.getAttribute('tabindex');
766
+ const num = Number(str);
767
+ return isFinite(num) ? Math.trunc(num) : -1;
768
+ },
769
+ set(newValue) {
770
+ const currentValue = this.getAttribute('tabindex');
771
+ const num = Number(newValue);
772
+ const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
773
+ if (normalizedValue !== currentValue) {
774
+ this.setAttribute('tabindex', toString(newValue));
775
+ }
776
+ },
955
777
  },
778
+ title: stringDescriptor('title'),
956
779
  };
957
- /**
958
- * The hot API is used to orchestrate hot swapping in client rendered components.
959
- * It doesn't do anything on the server side, however, you may import it.
960
- *
961
- * The whole point of defining this and exporting it is so that you can import it in isomorphic code without
962
- * an error being thrown by the import itself.
780
+ // Add descriptors for ARIA attributes
781
+ for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
782
+ descriptors[propName] = ariaDescriptor(attrName);
783
+ }
784
+
785
+ /*
786
+ * Copyright (c) 2024, salesforce.com, inc.
787
+ * All rights reserved.
788
+ * SPDX-License-Identifier: MIT
789
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
963
790
  */
964
- // A real stub, not a "not implemented" one! 😯
965
- const hot = undefined;
791
+ var _LightningElement_attrs, _LightningElement_classList;
792
+ const SYMBOL__SET_INTERNALS = Symbol('set-internals');
793
+ const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
794
+ class LightningElement {
795
+ constructor(propsAvailableAtConstruction) {
796
+ this.isConnected = false;
797
+ this.className = '';
798
+ _LightningElement_attrs.set(this, void 0);
799
+ _LightningElement_classList.set(this, null);
800
+ assign(this, propsAvailableAtConstruction);
801
+ }
802
+ [(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
803
+ __classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
804
+ assign(this, props);
805
+ defineProperty(this, 'className', {
806
+ get() {
807
+ return props.class ?? '';
808
+ },
809
+ set(newVal) {
810
+ props.class = newVal;
811
+ attrs.class = newVal;
812
+ mutationTracker.add(this, 'class');
813
+ },
814
+ });
815
+ }
816
+ get classList() {
817
+ if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
818
+ return __classPrivateFieldGet(this, _LightningElement_classList, "f");
819
+ }
820
+ return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
821
+ }
822
+ setAttribute(attrName, attrValue) {
823
+ const normalizedName = StringToLowerCase.call(toString(attrName));
824
+ const normalizedValue = String(attrValue);
825
+ __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
826
+ reflectAttrToProp(this, normalizedName, normalizedValue);
827
+ mutationTracker.add(this, normalizedName);
828
+ }
829
+ getAttribute(attrName) {
830
+ const normalizedName = StringToLowerCase.call(toString(attrName));
831
+ if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
832
+ return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
833
+ }
834
+ return null;
835
+ }
836
+ hasAttribute(attrName) {
837
+ const normalizedName = StringToLowerCase.call(toString(attrName));
838
+ return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
839
+ }
840
+ removeAttribute(attrName) {
841
+ const normalizedName = StringToLowerCase.call(toString(attrName));
842
+ delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
843
+ reflectAttrToProp(this, normalizedName, null);
844
+ // Track mutations for removal of non-existing attributes
845
+ mutationTracker.add(this, normalizedName);
846
+ }
847
+ addEventListener(_type, _listener, _options) {
848
+ // noop
849
+ }
850
+ removeEventListener(_type, _listener, _options) {
851
+ // noop
852
+ }
853
+ // ----------------------------------------------------------- //
854
+ // Props/methods explicitly not available in this environment //
855
+ // Getters are named "get*" for parity with @lwc/engine-server //
856
+ // ----------------------------------------------------------- //
857
+ get children() {
858
+ throw new TypeError('"getChildren" is not supported in this environment');
859
+ }
860
+ get childNodes() {
861
+ throw new TypeError('"getChildNodes" is not supported in this environment');
862
+ }
863
+ get firstChild() {
864
+ throw new TypeError('"getFirstChild" is not supported in this environment');
865
+ }
866
+ get firstElementChild() {
867
+ throw new TypeError('"getFirstElementChild" is not supported in this environment');
868
+ }
869
+ get hostElement() {
870
+ // Intentionally different to match @lwc/engine-*core*
871
+ throw new TypeError('this.hostElement is not supported in this environment');
872
+ }
873
+ get lastChild() {
874
+ throw new TypeError('"getLastChild" is not supported in this environment');
875
+ }
876
+ get lastElementChild() {
877
+ throw new TypeError('"getLastElementChild" is not supported in this environment');
878
+ }
879
+ get ownerDocument() {
880
+ // Intentionally not "get*" to match @lwc/engine-server
881
+ throw new TypeError('"ownerDocument" is not supported in this environment');
882
+ }
883
+ get style() {
884
+ // Intentionally not "get*" to match @lwc/engine-server
885
+ throw new TypeError('"style" is not supported in this environment');
886
+ }
887
+ attachInternals() {
888
+ throw new TypeError('"attachInternals" is not supported in this environment');
889
+ }
890
+ dispatchEvent(_event) {
891
+ throw new TypeError('"dispatchEvent" is not supported in this environment');
892
+ }
893
+ getBoundingClientRect() {
894
+ throw new TypeError('"getBoundingClientRect" is not supported in this environment');
895
+ }
896
+ getElementsByClassName(_classNames) {
897
+ throw new TypeError('"getElementsByClassName" is not supported in this environment');
898
+ }
899
+ getElementsByTagName(_qualifiedName) {
900
+ throw new TypeError('"getElementsByTagName" is not supported in this environment');
901
+ }
902
+ querySelector(_selectors) {
903
+ throw new TypeError('"querySelector" is not supported in this environment');
904
+ }
905
+ querySelectorAll(_selectors) {
906
+ throw new TypeError('"querySelectorAll" is not supported in this environment');
907
+ }
908
+ getAttributeNS(_namespace, _localName) {
909
+ throw new Error('Method "getAttributeNS" not implemented.');
910
+ }
911
+ hasAttributeNS(_namespace, _localName) {
912
+ throw new Error('Method "hasAttributeNS" not implemented.');
913
+ }
914
+ removeAttributeNS(_namespace, _localName) {
915
+ throw new Error('Method "removeAttributeNS" not implemented.');
916
+ }
917
+ setAttributeNS(_namespace, _qualifiedName, _value) {
918
+ throw new Error('Method "setAttributeNS" not implemented.');
919
+ }
920
+ }
921
+ defineProperties(LightningElement.prototype, descriptors);
966
922
 
967
923
  /*
968
924
  * Copyright (c) 2024, salesforce.com, inc.
@@ -970,35 +926,72 @@ const hot = undefined;
970
926
  * SPDX-License-Identifier: MIT
971
927
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
972
928
  */
973
- /**
974
- * Converts an iterable into one that emits the object used by the [`iterator` directive](
975
- * https://lwc.dev/guide/html_templates#iterator).
976
- */
977
- function* toIteratorDirective(iterable) {
978
- if (iterable === undefined || iterable === null)
929
+ const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&amp;').replaceAll('"', '&quot;');
930
+ function* renderAttrs(instance, attrs) {
931
+ if (!attrs) {
979
932
  return;
980
- if (!iterable[Symbol.iterator]) {
981
- throw new Error(
982
- // Mimic error message from "[i]terable node" in engine-core's api.ts
983
- `Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
984
933
  }
985
- const iterator = iterable[Symbol.iterator]();
986
- let next = iterator.next();
987
- let index = 0;
988
- let { value, done: last = false } = next;
989
- while (last === false) {
990
- // using a look-back approach because we need to know if the element is the last
991
- next = iterator.next();
992
- last = next.done ?? false;
993
- yield {
994
- value,
995
- index,
996
- first: index === 0,
997
- last,
998
- };
999
- index += 1;
1000
- value = next.value;
934
+ for (const attrName of Object.getOwnPropertyNames(attrs)) {
935
+ const attrVal = attrs[attrName];
936
+ if (typeof attrVal === 'string') {
937
+ yield attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`;
938
+ }
939
+ else if (attrVal === null) {
940
+ yield '';
941
+ }
942
+ }
943
+ yield mutationTracker.renderMutatedAttrs(instance);
944
+ }
945
+ function renderAttrsNoYield(emit, instance, attrs) {
946
+ if (!attrs) {
947
+ return;
948
+ }
949
+ for (const attrName of Object.getOwnPropertyNames(attrs)) {
950
+ const attrVal = attrs[attrName];
951
+ if (typeof attrVal === 'string') {
952
+ emit(attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`);
953
+ }
954
+ else if (attrVal === null) {
955
+ emit('');
956
+ }
957
+ }
958
+ emit(mutationTracker.renderMutatedAttrs(instance));
959
+ }
960
+ function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
961
+ if (Cmp.renderMode !== 'light') {
962
+ yield '<template shadowrootmode="open"></template>';
963
+ }
964
+ }
965
+ function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
966
+ if (Cmp.renderMode !== 'light') {
967
+ emit('<template shadowrootmode="open"></template>');
968
+ }
969
+ }
970
+ async function serverSideRenderComponent(tagName, Component, props = {}, mode = 'asyncYield') {
971
+ if (typeof tagName !== 'string') {
972
+ throw new Error(`tagName must be a string, found: ${tagName}`);
973
+ }
974
+ // TODO [#4726]: remove `generateMarkup` export
975
+ const generateMarkup = SYMBOL__GENERATE_MARKUP in Component ? Component[SYMBOL__GENERATE_MARKUP] : Component;
976
+ let markup = '';
977
+ const emit = (segment) => {
978
+ markup += segment;
979
+ };
980
+ if (mode === 'asyncYield') {
981
+ for await (const segment of generateMarkup(tagName, props, null, null)) {
982
+ markup += segment;
983
+ }
984
+ }
985
+ else if (mode === 'async') {
986
+ await generateMarkup(emit, tagName, props, null, null);
987
+ }
988
+ else if (mode === 'sync') {
989
+ generateMarkup(emit, tagName, props, null, null);
990
+ }
991
+ else {
992
+ throw new Error(`Invalid mode: ${mode}`);
1001
993
  }
994
+ return markup;
1002
995
  }
1003
996
 
1004
997
  /*
@@ -1079,6 +1072,43 @@ function renderStylesheets(stylesheets, scopeToken, Component, hasScopedTemplate
1079
1072
  return result;
1080
1073
  }
1081
1074
 
1075
+ /*
1076
+ * Copyright (c) 2024, salesforce.com, inc.
1077
+ * All rights reserved.
1078
+ * SPDX-License-Identifier: MIT
1079
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1080
+ */
1081
+ /**
1082
+ * Converts an iterable into one that emits the object used by the [`iterator` directive](
1083
+ * https://lwc.dev/guide/html_templates#iterator).
1084
+ */
1085
+ function* toIteratorDirective(iterable) {
1086
+ if (iterable === undefined || iterable === null)
1087
+ return;
1088
+ if (!iterable[Symbol.iterator]) {
1089
+ throw new Error(
1090
+ // Mimic error message from "[i]terable node" in engine-core's api.ts
1091
+ `Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
1092
+ }
1093
+ const iterator = iterable[Symbol.iterator]();
1094
+ let next = iterator.next();
1095
+ let index = 0;
1096
+ let { value, done: last = false } = next;
1097
+ while (last === false) {
1098
+ // using a look-back approach because we need to know if the element is the last
1099
+ next = iterator.next();
1100
+ last = next.done ?? false;
1101
+ yield {
1102
+ value,
1103
+ index,
1104
+ first: index === 0,
1105
+ last,
1106
+ };
1107
+ index += 1;
1108
+ value = next.value;
1109
+ }
1110
+ }
1111
+
1082
1112
  exports.ClassList = ClassList;
1083
1113
  exports.LightningElement = LightningElement;
1084
1114
  exports.SYMBOL__GENERATE_MARKUP = SYMBOL__GENERATE_MARKUP;
@@ -1119,5 +1149,5 @@ exports.track = track;
1119
1149
  exports.unwrap = unwrap;
1120
1150
  exports.validateStyleTextContents = validateStyleTextContents;
1121
1151
  exports.wire = wire;
1122
- /** version: 8.5.0 */
1152
+ /** version: 8.6.0 */
1123
1153
  //# sourceMappingURL=index.cjs.js.map