@lwc/ssr-runtime 8.4.0 → 8.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -7,110 +7,217 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9
9
  */
10
- const MULTI_SPACE = /\s+/g;
11
- class ClassList {
12
- constructor(el) {
13
- this.el = el;
14
- }
15
- add(...newClassNames) {
16
- const className = this.el.className;
17
- const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
18
- for (const newClassName of newClassNames) {
19
- set.add(newClassName);
20
- }
21
- this.el.className = Array.from(set).join(' ');
22
- }
23
- contains(className) {
24
- const currentClassNameStr = this.el.className;
25
- return currentClassNameStr.split(MULTI_SPACE).includes(className);
26
- }
27
- remove(...classNamesToRemove) {
28
- const className = this.el.className;
29
- const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
30
- for (const newClassName of classNamesToRemove) {
31
- set.delete(newClassName);
32
- }
33
- this.el.className = Array.from(set).join(' ');
34
- }
35
- replace(oldClassName, newClassName) {
36
- let classWasReplaced = false;
37
- const className = this.el.className;
38
- const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
39
- listOfClasses.forEach((value, idx) => {
40
- if (value === oldClassName) {
41
- classWasReplaced = true;
42
- listOfClasses[idx] = newClassName;
43
- }
44
- });
45
- this.el.className = listOfClasses.join(' ');
46
- return classWasReplaced;
47
- }
48
- toggle(classNameToToggle, force) {
49
- const classNameStr = this.el.className;
50
- const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
51
- if (!set.has(classNameToToggle) && force !== false) {
52
- set.add(classNameToToggle);
53
- }
54
- else if (set.has(classNameToToggle) && force !== true) {
55
- set.delete(classNameToToggle);
56
- }
57
- this.el.className = Array.from(set).join(' ');
58
- return set.has(classNameToToggle);
59
- }
60
- get value() {
61
- return this.el.className;
62
- }
63
- toString() {
64
- return this.el.className;
65
- }
66
- item(_index) {
67
- throw new Error('Method "item" not implemented.');
68
- }
69
- supports(_token) {
70
- throw new Error('Method "supports" not implemented.');
71
- }
72
- forEach(_callbackfn, _thisArg) {
73
- throw new Error('Method "forEach" not implemented.');
74
- }
75
- get length() {
76
- throw new Error('Property "length" not implemented.');
77
- }
10
+ // Stubs for all the un-implemented exports from @lwc/engine-server
11
+ function api(..._) {
12
+ throw new Error('@api cannot be used in SSR context.');
78
13
  }
79
-
80
- /******************************************************************************
81
- Copyright (c) Microsoft Corporation.
82
-
83
- Permission to use, copy, modify, and/or distribute this software for any
84
- purpose with or without fee is hereby granted.
85
-
86
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
87
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
88
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
89
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
90
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
91
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
92
- PERFORMANCE OF THIS SOFTWARE.
93
- ***************************************************************************** */
94
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
95
-
96
-
97
- function __classPrivateFieldGet(receiver, state, kind, f) {
98
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
99
- 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");
100
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
101
- }
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
-
110
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
111
- var e = new Error(message);
112
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
14
+ function createContextProvider(..._) {
15
+ throw new Error('createContextProvider cannot be used in SSR context.');
16
+ }
17
+ function createElement(..._) {
18
+ throw new Error('createElement cannot be used in SSR context.');
19
+ }
20
+ function freezeTemplate(..._) {
21
+ throw new Error('freezeTemplate cannot be used in SSR context.');
22
+ }
23
+ function getComponentDef(..._) {
24
+ throw new Error('getComponentDef cannot be used in SSR context.');
25
+ }
26
+ function isComponentConstructor(..._) {
27
+ throw new Error('isComponentConstructor cannot be used in SSR context.');
28
+ }
29
+ function parseFragment(..._) {
30
+ throw new Error('parseFragment cannot be used in SSR context.');
31
+ }
32
+ function parseSVGFragment(..._) {
33
+ throw new Error('parseSVGFragment cannot be used in SSR context.');
34
+ }
35
+ function readonly(..._) {
36
+ throw new Error('readonly cannot be used in SSR context.');
37
+ }
38
+ function registerComponent(..._) {
39
+ throw new Error('registerComponent cannot be used in SSR context.');
40
+ }
41
+ function registerDecorators(..._) {
42
+ throw new Error('registerDecorators cannot be used in SSR context.');
43
+ }
44
+ function registerTemplate(..._) {
45
+ throw new Error('registerTemplate cannot be used in SSR context.');
46
+ }
47
+ function sanitizeAttribute(..._) {
48
+ throw new Error('sanitizeAttribute cannot be used in SSR context.');
49
+ }
50
+ function setFeatureFlag(..._) {
51
+ throw new Error('setFeatureFlag cannot be used in SSR context.');
52
+ }
53
+ function setFeatureFlagForTest(..._) {
54
+ throw new Error('setFeatureFlagForTest cannot be used in SSR context.');
55
+ }
56
+ function swapComponent(..._) {
57
+ throw new Error('swapComponent cannot be used in SSR context.');
58
+ }
59
+ function swapStyle(..._) {
60
+ throw new Error('swapStyle cannot be used in SSR context.');
61
+ }
62
+ function swapTemplate(..._) {
63
+ throw new Error('swapTemplate cannot be used in SSR context.');
64
+ }
65
+ function track(..._) {
66
+ throw new Error('@track cannot be used in SSR context.');
67
+ }
68
+ function unwrap(..._) {
69
+ throw new Error('unwrap cannot be used in SSR context.');
70
+ }
71
+ function wire(..._) {
72
+ throw new Error('@wire cannot be used in SSR context.');
73
+ }
74
+ const renderer = {
75
+ isSyntheticShadowDefined: false,
76
+ insert(..._) {
77
+ throw new Error('renderer.insert cannot be used in SSR context.');
78
+ },
79
+ remove(..._) {
80
+ throw new Error('renderer.remove cannot be used in SSR context.');
81
+ },
82
+ cloneNode(..._) {
83
+ throw new Error('renderer.cloneNode cannot be used in SSR context.');
84
+ },
85
+ createFragment(..._) {
86
+ throw new Error('renderer.createFragment cannot be used in SSR context.');
87
+ },
88
+ createElement(..._) {
89
+ throw new Error('renderer.createElement cannot be used in SSR context.');
90
+ },
91
+ createText(..._) {
92
+ throw new Error('renderer.createText cannot be used in SSR context.');
93
+ },
94
+ createComment(..._) {
95
+ throw new Error('renderer.createComment cannot be used in SSR context.');
96
+ },
97
+ createCustomElement(..._) {
98
+ throw new Error('renderer.createCustomElement cannot be used in SSR context.');
99
+ },
100
+ nextSibling(..._) {
101
+ throw new Error('renderer.nextSibling cannot be used in SSR context.');
102
+ },
103
+ previousSibling(..._) {
104
+ throw new Error('renderer.previousSibling cannot be used in SSR context.');
105
+ },
106
+ attachShadow(..._) {
107
+ throw new Error('renderer.attachShadow cannot be used in SSR context.');
108
+ },
109
+ getProperty(..._) {
110
+ throw new Error('renderer.getProperty cannot be used in SSR context.');
111
+ },
112
+ setProperty(..._) {
113
+ throw new Error('renderer.setProperty cannot be used in SSR context.');
114
+ },
115
+ setText(..._) {
116
+ throw new Error('renderer.setText cannot be used in SSR context.');
117
+ },
118
+ getAttribute(..._) {
119
+ throw new Error('renderer.getAttribute cannot be used in SSR context.');
120
+ },
121
+ setAttribute(..._) {
122
+ throw new Error('renderer.setAttribute cannot be used in SSR context.');
123
+ },
124
+ removeAttribute(..._) {
125
+ throw new Error('renderer.removeAttribute cannot be used in SSR context.');
126
+ },
127
+ addEventListener(..._) {
128
+ throw new Error('renderer.addEventListener cannot be used in SSR context.');
129
+ },
130
+ removeEventListener(..._) {
131
+ throw new Error('renderer.removeEventListener cannot be used in SSR context.');
132
+ },
133
+ dispatchEvent(..._) {
134
+ throw new Error('renderer.dispatchEvent cannot be used in SSR context.');
135
+ },
136
+ getClassList(..._) {
137
+ throw new Error('renderer.getClassList cannot be used in SSR context.');
138
+ },
139
+ setCSSStyleProperty(..._) {
140
+ throw new Error('renderer.setCSSStyleProperty cannot be used in SSR context.');
141
+ },
142
+ getBoundingClientRect(..._) {
143
+ throw new Error('renderer.getBoundingClientRect cannot be used in SSR context.');
144
+ },
145
+ querySelector(..._) {
146
+ throw new Error('renderer.querySelector cannot be used in SSR context.');
147
+ },
148
+ querySelectorAll(..._) {
149
+ throw new Error('renderer.querySelectorAll cannot be used in SSR context.');
150
+ },
151
+ getElementsByTagName(..._) {
152
+ throw new Error('renderer.getElementsByTagName cannot be used in SSR context.');
153
+ },
154
+ getElementsByClassName(..._) {
155
+ throw new Error('renderer.getElementsByClassName cannot be used in SSR context.');
156
+ },
157
+ getChildren(..._) {
158
+ throw new Error('renderer.getChildren cannot be used in SSR context.');
159
+ },
160
+ getChildNodes(..._) {
161
+ throw new Error('renderer.getChildNodes cannot be used in SSR context.');
162
+ },
163
+ getFirstChild(..._) {
164
+ throw new Error('renderer.getFirstChild cannot be used in SSR context.');
165
+ },
166
+ getFirstElementChild(..._) {
167
+ throw new Error('renderer.getFirstElementChild cannot be used in SSR context.');
168
+ },
169
+ getLastChild(..._) {
170
+ throw new Error('renderer.getLastChild cannot be used in SSR context.');
171
+ },
172
+ getLastElementChild(..._) {
173
+ throw new Error('renderer.getLastElementChild cannot be used in SSR context.');
174
+ },
175
+ getTagName(..._) {
176
+ throw new Error('renderer.getTagName cannot be used in SSR context.');
177
+ },
178
+ getStyle(..._) {
179
+ throw new Error('renderer.getStyle cannot be used in SSR context.');
180
+ },
181
+ isConnected(..._) {
182
+ throw new Error('renderer.isConnected cannot be used in SSR context.');
183
+ },
184
+ insertStylesheet(..._) {
185
+ throw new Error('renderer.insertStylesheet cannot be used in SSR context.');
186
+ },
187
+ assertInstanceOfHTMLElement(..._) {
188
+ throw new Error('renderer.assertInstanceOfHTMLElement cannot be used in SSR context.');
189
+ },
190
+ ownerDocument(..._) {
191
+ throw new Error('renderer.ownerDocument cannot be used in SSR context.');
192
+ },
193
+ registerContextConsumer(..._) {
194
+ throw new Error('renderer.registerContextConsumer cannot be used in SSR context.');
195
+ },
196
+ attachInternals(..._) {
197
+ throw new Error('renderer.attachInternals cannot be used in SSR context.');
198
+ },
199
+ defineCustomElement(..._) {
200
+ throw new Error('renderer.defineCustomElement cannot be used in SSR context.');
201
+ },
202
+ getParentNode(..._) {
203
+ throw new Error('renderer.getParentNode cannot be used in SSR context.');
204
+ },
205
+ startTrackingMutations(..._) {
206
+ throw new Error('renderer.startTrackingMutations cannot be used in SSR context.');
207
+ },
208
+ stopTrackingMutations(..._) {
209
+ throw new Error('renderer.stopTrackingMutations cannot be used in SSR context.');
210
+ },
113
211
  };
212
+ /**
213
+ * The hot API is used to orchestrate hot swapping in client rendered components.
214
+ * It doesn't do anything on the server side, however, you may import it.
215
+ *
216
+ * The whole point of defining this and exporting it is so that you can import it in isomorphic code without
217
+ * an error being thrown by the import itself.
218
+ */
219
+ // A real stub, not a "not implemented" one! 😯
220
+ const hot = undefined;
114
221
 
115
222
  /**
116
223
  * Copyright (c) 2024 Salesforce, Inc.
@@ -126,6 +233,16 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
126
233
  * @param value
127
234
  * @param msg
128
235
  */
236
+ /**
237
+ *
238
+ * @param value
239
+ * @param msg
240
+ */
241
+ function isFalse$1(value, msg) {
242
+ if (value) {
243
+ throw new Error(`Assert Violation: ${msg}`);
244
+ }
245
+ }
129
246
 
130
247
  /*
131
248
  * Copyright (c) 2024, Salesforce, Inc.
@@ -146,6 +263,8 @@ defineProperty,
146
263
  entries,
147
264
  /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
148
265
  freeze,
266
+ /** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
267
+ fromEntries,
149
268
  /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
150
269
  getOwnPropertyDescriptor,
151
270
  /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
@@ -319,16 +438,162 @@ const ESCAPED_CHARS = {
319
438
  '>': '>',
320
439
  '&': '&',
321
440
  };
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 */
441
+ /**
442
+ *
443
+ * @param str
444
+ * @param attrMode
445
+ */
446
+ function htmlEscape(str, attrMode = false) {
447
+ const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
448
+ return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
449
+ }
450
+
451
+ /*
452
+ * Copyright (c) 2024, Salesforce, Inc.
453
+ * All rights reserved.
454
+ * SPDX-License-Identifier: MIT
455
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
456
+ */
457
+ let hooksAreSet = false;
458
+ /**
459
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
460
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
461
+ * lwc:inner-html directive.
462
+ * It is meant to be overridden via `setHooks`; it throws an error by default.
463
+ */
464
+ let sanitizeHtmlContent = () => {
465
+ // locker-service patches this function during runtime to sanitize HTML content.
466
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
467
+ };
468
+ function setHooks(hooks) {
469
+ isFalse$1(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
470
+ hooksAreSet = true;
471
+ sanitizeHtmlContent = hooks.sanitizeHtmlContent;
472
+ }
473
+ function flattenStylesheets(stylesheets) {
474
+ const list = [];
475
+ for (const stylesheet of stylesheets) {
476
+ if (!isArray(stylesheet)) {
477
+ list.push(stylesheet);
478
+ }
479
+ else {
480
+ list.push(...flattenStylesheets(stylesheet));
481
+ }
482
+ }
483
+ return list;
484
+ }
485
+ /** version: 8.6.0 */
486
+
487
+ /*
488
+ * Copyright (c) 2024, Salesforce, Inc.
489
+ * All rights reserved.
490
+ * SPDX-License-Identifier: MIT
491
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
492
+ */
493
+ const MULTI_SPACE = /\s+/g;
494
+ class ClassList {
495
+ constructor(el) {
496
+ this.el = el;
497
+ }
498
+ add(...newClassNames) {
499
+ const className = this.el.className;
500
+ const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
501
+ for (const newClassName of newClassNames) {
502
+ set.add(newClassName);
503
+ }
504
+ this.el.className = Array.from(set).join(' ');
505
+ }
506
+ contains(className) {
507
+ const currentClassNameStr = this.el.className;
508
+ return currentClassNameStr.split(MULTI_SPACE).includes(className);
509
+ }
510
+ remove(...classNamesToRemove) {
511
+ const className = this.el.className;
512
+ const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
513
+ for (const newClassName of classNamesToRemove) {
514
+ set.delete(newClassName);
515
+ }
516
+ this.el.className = Array.from(set).join(' ');
517
+ }
518
+ replace(oldClassName, newClassName) {
519
+ let classWasReplaced = false;
520
+ const className = this.el.className;
521
+ const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
522
+ listOfClasses.forEach((value, idx) => {
523
+ if (value === oldClassName) {
524
+ classWasReplaced = true;
525
+ listOfClasses[idx] = newClassName;
526
+ }
527
+ });
528
+ this.el.className = listOfClasses.join(' ');
529
+ return classWasReplaced;
530
+ }
531
+ toggle(classNameToToggle, force) {
532
+ const classNameStr = this.el.className;
533
+ const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
534
+ if (!set.has(classNameToToggle) && force !== false) {
535
+ set.add(classNameToToggle);
536
+ }
537
+ else if (set.has(classNameToToggle) && force !== true) {
538
+ set.delete(classNameToToggle);
539
+ }
540
+ this.el.className = Array.from(set).join(' ');
541
+ return set.has(classNameToToggle);
542
+ }
543
+ get value() {
544
+ return this.el.className;
545
+ }
546
+ toString() {
547
+ return this.el.className;
548
+ }
549
+ item(_index) {
550
+ throw new Error('Method "item" not implemented.');
551
+ }
552
+ supports(_token) {
553
+ throw new Error('Method "supports" not implemented.');
554
+ }
555
+ forEach(_callbackfn, _thisArg) {
556
+ throw new Error('Method "forEach" not implemented.');
557
+ }
558
+ get length() {
559
+ throw new Error('Property "length" not implemented.');
560
+ }
561
+ }
562
+
563
+ /******************************************************************************
564
+ Copyright (c) Microsoft Corporation.
565
+
566
+ Permission to use, copy, modify, and/or distribute this software for any
567
+ purpose with or without fee is hereby granted.
568
+
569
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
570
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
571
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
572
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
573
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
574
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
575
+ PERFORMANCE OF THIS SOFTWARE.
576
+ ***************************************************************************** */
577
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
578
+
579
+
580
+ function __classPrivateFieldGet(receiver, state, kind, f) {
581
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
582
+ 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");
583
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
584
+ }
585
+
586
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
587
+ if (kind === "m") throw new TypeError("Private method is not writable");
588
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
589
+ 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");
590
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
591
+ }
592
+
593
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
594
+ var e = new Error(message);
595
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
596
+ };
332
597
 
333
598
  /*
334
599
  * Copyright (c) 2024, Salesforce, Inc.
@@ -363,263 +628,13 @@ class MutationTracker {
363
628
  if (mutatedAttrs) {
364
629
  return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
365
630
  }
366
- else {
367
- return '';
368
- }
369
- }
370
- }
371
- _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
372
- const mutationTracker = new MutationTracker();
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
-
418
- /*
419
- * Copyright (c) 2024, salesforce.com, inc.
420
- * All rights reserved.
421
- * SPDX-License-Identifier: MIT
422
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
423
- */
424
- var _LightningElement_attrs, _LightningElement_classList;
425
- const SYMBOL__SET_INTERNALS = Symbol('set-internals');
426
- class LightningElement {
427
- constructor(propsAvailableAtConstruction) {
428
- this.isConnected = false;
429
- 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', {
438
- get() {
439
- return props.class ?? '';
440
- },
441
- set(newVal) {
442
- props.class = newVal;
443
- attrs.class = newVal;
444
- mutationTracker.add(this, 'class');
445
- },
446
- });
447
- }
448
- get classList() {
449
- if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
450
- return __classPrivateFieldGet(this, _LightningElement_classList, "f");
451
- }
452
- return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
453
- }
454
- setAttribute(attrName, 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);
460
- }
461
- getAttribute(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];
465
- }
466
- return null;
467
- }
468
- hasAttribute(attrName) {
469
- const normalizedName = StringToLowerCase.call(toString(attrName));
470
- return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
471
- }
472
- removeAttribute(attrName) {
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);
478
- }
479
- addEventListener(_type, _listener, _options) {
480
- // noop
481
- }
482
- removeEventListener(_type, _listener, _options) {
483
- // noop
484
- }
485
- // ----------------------------------------------------------- //
486
- // Props/methods explicitly not available in this environment //
487
- // Getters are named "get*" for parity with @lwc/engine-server //
488
- // ----------------------------------------------------------- //
489
- get children() {
490
- throw new TypeError('"getChildren" is not supported in this environment');
491
- }
492
- get childNodes() {
493
- throw new TypeError('"getChildNodes" is not supported in this environment');
494
- }
495
- get firstChild() {
496
- throw new TypeError('"getFirstChild" is not supported in this environment');
497
- }
498
- get firstElementChild() {
499
- throw new TypeError('"getFirstElementChild" is not supported in this environment');
500
- }
501
- get hostElement() {
502
- // Intentionally different to match @lwc/engine-*core*
503
- throw new TypeError('this.hostElement is not supported in this environment');
504
- }
505
- get lastChild() {
506
- throw new TypeError('"getLastChild" is not supported in this environment');
507
- }
508
- get lastElementChild() {
509
- throw new TypeError('"getLastElementChild" is not supported in this environment');
510
- }
511
- get ownerDocument() {
512
- // Intentionally not "get*" to match @lwc/engine-server
513
- throw new TypeError('"ownerDocument" is not supported in this environment');
514
- }
515
- get style() {
516
- // Intentionally not "get*" to match @lwc/engine-server
517
- throw new TypeError('"style" is not supported in this environment');
518
- }
519
- attachInternals() {
520
- throw new TypeError('"attachInternals" is not supported in this environment');
521
- }
522
- dispatchEvent(_event) {
523
- throw new TypeError('"dispatchEvent" is not supported in this environment');
524
- }
525
- getBoundingClientRect() {
526
- throw new TypeError('"getBoundingClientRect" is not supported in this environment');
527
- }
528
- getElementsByClassName(_classNames) {
529
- throw new TypeError('"getElementsByClassName" is not supported in this environment');
530
- }
531
- getElementsByTagName(_qualifiedName) {
532
- throw new TypeError('"getElementsByTagName" is not supported in this environment');
533
- }
534
- querySelector(_selectors) {
535
- throw new TypeError('"querySelector" is not supported in this environment');
536
- }
537
- querySelectorAll(_selectors) {
538
- throw new TypeError('"querySelectorAll" is not supported in this environment');
539
- }
540
- getAttributeNS(_namespace, _localName) {
541
- throw new Error('Method "getAttributeNS" not implemented.');
542
- }
543
- hasAttributeNS(_namespace, _localName) {
544
- throw new Error('Method "hasAttributeNS" not implemented.');
545
- }
546
- removeAttributeNS(_namespace, _localName) {
547
- throw new Error('Method "removeAttributeNS" not implemented.');
548
- }
549
- setAttributeNS(_namespace, _qualifiedName, _value) {
550
- throw new Error('Method "setAttributeNS" not implemented.');
551
- }
552
- }
553
- defineProperties(LightningElement.prototype, descriptors);
554
-
555
- /*
556
- * Copyright (c) 2024, salesforce.com, inc.
557
- * All rights reserved.
558
- * SPDX-License-Identifier: MIT
559
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
560
- */
561
- const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&amp;').replaceAll('"', '&quot;');
562
- function* renderAttrs(instance, attrs) {
563
- if (!attrs) {
564
- return;
565
- }
566
- for (const attrName of Object.getOwnPropertyNames(attrs)) {
567
- const attrVal = attrs[attrName];
568
- if (typeof attrVal === 'string') {
569
- yield attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`;
570
- }
571
- else if (attrVal === null) {
572
- yield '';
573
- }
574
- }
575
- yield mutationTracker.renderMutatedAttrs(instance);
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
- }
592
- function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
593
- if (Cmp.renderMode !== 'light') {
594
- yield '<template shadowrootmode="open"></template>';
595
- }
596
- }
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') {
603
- let markup = '';
604
- const emit = (segment) => {
605
- markup += segment;
606
- };
607
- if (mode === 'asyncYield') {
608
- for await (const segment of compiledGenerateMarkup(tagName, props, null, null)) {
609
- markup += segment;
631
+ else {
632
+ return '';
610
633
  }
611
634
  }
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}`);
620
- }
621
- return markup;
622
635
  }
636
+ _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
637
+ const mutationTracker = new MutationTracker();
623
638
 
624
639
  /*
625
640
  * Copyright (c) 2024, Salesforce, Inc.
@@ -627,220 +642,279 @@ async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props,
627
642
  * SPDX-License-Identifier: MIT
628
643
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
629
644
  */
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.');
645
+ /**
646
+ * Map of global attribute or ARIA attribute to the corresponding property name.
647
+ * Not all global attributes are included, just those from `HTMLElementTheGoodParts`.
648
+ */
649
+ const attrsToProps = assign(create(null), {
650
+ accesskey: 'accessKey',
651
+ dir: 'dir',
652
+ draggable: 'draggable',
653
+ hidden: 'hidden',
654
+ id: 'id',
655
+ lang: 'lang',
656
+ spellcheck: 'spellcheck',
657
+ tabindex: 'tabIndex',
658
+ title: 'title',
659
+ ...AriaAttrNameToPropNameMap,
660
+ });
661
+ /**
662
+ * Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
663
+ */
664
+ const stringDescriptor = (attrName) => ({
665
+ configurable: true,
666
+ enumerable: true,
667
+ get() {
668
+ return this.getAttribute(attrName);
809
669
  },
810
- assertInstanceOfHTMLElement(..._) {
811
- throw new Error('renderer.assertInstanceOfHTMLElement cannot be used in SSR context.');
670
+ set(newValue) {
671
+ const currentValue = this.getAttribute(attrName);
672
+ const normalizedValue = String(newValue);
673
+ if (normalizedValue !== currentValue) {
674
+ this.setAttribute(attrName, normalizedValue);
675
+ }
812
676
  },
813
- ownerDocument(..._) {
814
- throw new Error('renderer.ownerDocument cannot be used in SSR context.');
677
+ });
678
+ /** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
679
+ const explicitBooleanDescriptor = (attrName, defaultValue) => ({
680
+ configurable: true,
681
+ enumerable: true,
682
+ get() {
683
+ const value = this.getAttribute(attrName);
684
+ return value === null ? defaultValue : value === String(defaultValue);
815
685
  },
816
- registerContextConsumer(..._) {
817
- throw new Error('renderer.registerContextConsumer cannot be used in SSR context.');
686
+ set(newValue) {
687
+ const currentValue = this.getAttribute(attrName);
688
+ const normalizedValue = String(Boolean(newValue));
689
+ if (normalizedValue !== currentValue) {
690
+ this.setAttribute(attrName, normalizedValue);
691
+ }
818
692
  },
819
- attachInternals(..._) {
820
- throw new Error('renderer.attachInternals cannot be used in SSR context.');
693
+ });
694
+ /**
695
+ * Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
696
+ */
697
+ const booleanAttributeDescriptor = (attrName) => ({
698
+ configurable: true,
699
+ enumerable: true,
700
+ get() {
701
+ return this.hasAttribute(attrName);
821
702
  },
822
- defineCustomElement(..._) {
823
- throw new Error('renderer.defineCustomElement cannot be used in SSR context.');
703
+ set(newValue) {
704
+ const hasAttribute = this.hasAttribute(attrName);
705
+ if (newValue) {
706
+ if (!hasAttribute) {
707
+ this.setAttribute(attrName, '');
708
+ }
709
+ }
710
+ else {
711
+ if (hasAttribute) {
712
+ this.removeAttribute(attrName);
713
+ }
714
+ }
824
715
  },
825
- getParentNode(..._) {
826
- throw new Error('renderer.getParentNode cannot be used in SSR context.');
716
+ });
717
+ /**
718
+ * Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
719
+ */
720
+ const ariaDescriptor = (attrName) => ({
721
+ configurable: true,
722
+ enumerable: true,
723
+ get() {
724
+ return this.getAttribute(attrName);
827
725
  },
828
- startTrackingMutations(..._) {
829
- throw new Error('renderer.startTrackingMutations cannot be used in SSR context.');
726
+ set(newValue) {
727
+ const currentValue = this.getAttribute(attrName);
728
+ if (newValue !== currentValue) {
729
+ // TODO [#3284]: According to the spec, IDL nullable type values
730
+ // (null and undefined) should remove the attribute; however, we
731
+ // only do so in the case of null for historical reasons.
732
+ if (isNull(newValue)) {
733
+ this.removeAttribute(attrName);
734
+ }
735
+ else {
736
+ this.setAttribute(attrName, toString(newValue));
737
+ }
738
+ }
830
739
  },
831
- stopTrackingMutations(..._) {
832
- throw new Error('renderer.stopTrackingMutations cannot be used in SSR context.');
740
+ });
741
+ function reflectAttrToProp(instance, attrName, attrValue) {
742
+ const reflectedPropName = attrsToProps[attrName];
743
+ // If it is a reflected property and it was not overridden by the instance
744
+ if (reflectedPropName && !hasOwnProperty.call(instance, reflectedPropName)) {
745
+ const currentValue = instance[reflectedPropName];
746
+ if (currentValue !== attrValue) {
747
+ instance[reflectedPropName] = attrValue;
748
+ }
749
+ }
750
+ }
751
+ const descriptors = {
752
+ accessKey: stringDescriptor('accesskey'),
753
+ dir: stringDescriptor('dir'),
754
+ draggable: explicitBooleanDescriptor('draggable', true),
755
+ hidden: booleanAttributeDescriptor('hidden'),
756
+ id: stringDescriptor('id'),
757
+ lang: stringDescriptor('lang'),
758
+ spellcheck: explicitBooleanDescriptor('spellcheck', false),
759
+ tabIndex: {
760
+ get() {
761
+ const str = this.getAttribute('tabindex');
762
+ const num = Number(str);
763
+ return isFinite(num) ? Math.trunc(num) : -1;
764
+ },
765
+ set(newValue) {
766
+ const currentValue = this.getAttribute('tabindex');
767
+ const num = Number(newValue);
768
+ const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
769
+ if (normalizedValue !== currentValue) {
770
+ this.setAttribute('tabindex', toString(newValue));
771
+ }
772
+ },
833
773
  },
774
+ title: stringDescriptor('title'),
834
775
  };
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.
776
+ // Add descriptors for ARIA attributes
777
+ for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
778
+ descriptors[propName] = ariaDescriptor(attrName);
779
+ }
780
+
781
+ /*
782
+ * Copyright (c) 2024, salesforce.com, inc.
783
+ * All rights reserved.
784
+ * SPDX-License-Identifier: MIT
785
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
841
786
  */
842
- // A real stub, not a "not implemented" one! 😯
843
- const hot = undefined;
787
+ var _LightningElement_attrs, _LightningElement_classList;
788
+ const SYMBOL__SET_INTERNALS = Symbol('set-internals');
789
+ const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
790
+ class LightningElement {
791
+ constructor(propsAvailableAtConstruction) {
792
+ this.isConnected = false;
793
+ this.className = '';
794
+ _LightningElement_attrs.set(this, void 0);
795
+ _LightningElement_classList.set(this, null);
796
+ assign(this, propsAvailableAtConstruction);
797
+ }
798
+ [(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
799
+ __classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
800
+ assign(this, props);
801
+ defineProperty(this, 'className', {
802
+ get() {
803
+ return props.class ?? '';
804
+ },
805
+ set(newVal) {
806
+ props.class = newVal;
807
+ attrs.class = newVal;
808
+ mutationTracker.add(this, 'class');
809
+ },
810
+ });
811
+ }
812
+ get classList() {
813
+ if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
814
+ return __classPrivateFieldGet(this, _LightningElement_classList, "f");
815
+ }
816
+ return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
817
+ }
818
+ setAttribute(attrName, attrValue) {
819
+ const normalizedName = StringToLowerCase.call(toString(attrName));
820
+ const normalizedValue = String(attrValue);
821
+ __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
822
+ reflectAttrToProp(this, normalizedName, normalizedValue);
823
+ mutationTracker.add(this, normalizedName);
824
+ }
825
+ getAttribute(attrName) {
826
+ const normalizedName = StringToLowerCase.call(toString(attrName));
827
+ if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
828
+ return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
829
+ }
830
+ return null;
831
+ }
832
+ hasAttribute(attrName) {
833
+ const normalizedName = StringToLowerCase.call(toString(attrName));
834
+ return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
835
+ }
836
+ removeAttribute(attrName) {
837
+ const normalizedName = StringToLowerCase.call(toString(attrName));
838
+ delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
839
+ reflectAttrToProp(this, normalizedName, null);
840
+ // Track mutations for removal of non-existing attributes
841
+ mutationTracker.add(this, normalizedName);
842
+ }
843
+ addEventListener(_type, _listener, _options) {
844
+ // noop
845
+ }
846
+ removeEventListener(_type, _listener, _options) {
847
+ // noop
848
+ }
849
+ // ----------------------------------------------------------- //
850
+ // Props/methods explicitly not available in this environment //
851
+ // Getters are named "get*" for parity with @lwc/engine-server //
852
+ // ----------------------------------------------------------- //
853
+ get children() {
854
+ throw new TypeError('"getChildren" is not supported in this environment');
855
+ }
856
+ get childNodes() {
857
+ throw new TypeError('"getChildNodes" is not supported in this environment');
858
+ }
859
+ get firstChild() {
860
+ throw new TypeError('"getFirstChild" is not supported in this environment');
861
+ }
862
+ get firstElementChild() {
863
+ throw new TypeError('"getFirstElementChild" is not supported in this environment');
864
+ }
865
+ get hostElement() {
866
+ // Intentionally different to match @lwc/engine-*core*
867
+ throw new TypeError('this.hostElement is not supported in this environment');
868
+ }
869
+ get lastChild() {
870
+ throw new TypeError('"getLastChild" is not supported in this environment');
871
+ }
872
+ get lastElementChild() {
873
+ throw new TypeError('"getLastElementChild" is not supported in this environment');
874
+ }
875
+ get ownerDocument() {
876
+ // Intentionally not "get*" to match @lwc/engine-server
877
+ throw new TypeError('"ownerDocument" is not supported in this environment');
878
+ }
879
+ get style() {
880
+ // Intentionally not "get*" to match @lwc/engine-server
881
+ throw new TypeError('"style" is not supported in this environment');
882
+ }
883
+ attachInternals() {
884
+ throw new TypeError('"attachInternals" is not supported in this environment');
885
+ }
886
+ dispatchEvent(_event) {
887
+ throw new TypeError('"dispatchEvent" is not supported in this environment');
888
+ }
889
+ getBoundingClientRect() {
890
+ throw new TypeError('"getBoundingClientRect" is not supported in this environment');
891
+ }
892
+ getElementsByClassName(_classNames) {
893
+ throw new TypeError('"getElementsByClassName" is not supported in this environment');
894
+ }
895
+ getElementsByTagName(_qualifiedName) {
896
+ throw new TypeError('"getElementsByTagName" is not supported in this environment');
897
+ }
898
+ querySelector(_selectors) {
899
+ throw new TypeError('"querySelector" is not supported in this environment');
900
+ }
901
+ querySelectorAll(_selectors) {
902
+ throw new TypeError('"querySelectorAll" is not supported in this environment');
903
+ }
904
+ getAttributeNS(_namespace, _localName) {
905
+ throw new Error('Method "getAttributeNS" not implemented.');
906
+ }
907
+ hasAttributeNS(_namespace, _localName) {
908
+ throw new Error('Method "hasAttributeNS" not implemented.');
909
+ }
910
+ removeAttributeNS(_namespace, _localName) {
911
+ throw new Error('Method "removeAttributeNS" not implemented.');
912
+ }
913
+ setAttributeNS(_namespace, _qualifiedName, _value) {
914
+ throw new Error('Method "setAttributeNS" not implemented.');
915
+ }
916
+ }
917
+ defineProperties(LightningElement.prototype, descriptors);
844
918
 
845
919
  /*
846
920
  * Copyright (c) 2024, salesforce.com, inc.
@@ -848,35 +922,72 @@ const hot = undefined;
848
922
  * SPDX-License-Identifier: MIT
849
923
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
850
924
  */
851
- /**
852
- * Converts an iterable into one that emits the object used by the [`iterator` directive](
853
- * https://lwc.dev/guide/html_templates#iterator).
854
- */
855
- function* toIteratorDirective(iterable) {
856
- if (iterable === undefined || iterable === null)
925
+ const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&amp;').replaceAll('"', '&quot;');
926
+ function* renderAttrs(instance, attrs) {
927
+ if (!attrs) {
857
928
  return;
858
- if (!iterable[Symbol.iterator]) {
859
- throw new Error(
860
- // Mimic error message from "[i]terable node" in engine-core's api.ts
861
- `Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
862
929
  }
863
- const iterator = iterable[Symbol.iterator]();
864
- let next = iterator.next();
865
- let index = 0;
866
- let { value, done: last = false } = next;
867
- while (last === false) {
868
- // using a look-back approach because we need to know if the element is the last
869
- next = iterator.next();
870
- last = next.done ?? false;
871
- yield {
872
- value,
873
- index,
874
- first: index === 0,
875
- last,
876
- };
877
- index += 1;
878
- value = next.value;
930
+ for (const attrName of Object.getOwnPropertyNames(attrs)) {
931
+ const attrVal = attrs[attrName];
932
+ if (typeof attrVal === 'string') {
933
+ yield attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`;
934
+ }
935
+ else if (attrVal === null) {
936
+ yield '';
937
+ }
938
+ }
939
+ yield mutationTracker.renderMutatedAttrs(instance);
940
+ }
941
+ function renderAttrsNoYield(emit, instance, attrs) {
942
+ if (!attrs) {
943
+ return;
944
+ }
945
+ for (const attrName of Object.getOwnPropertyNames(attrs)) {
946
+ const attrVal = attrs[attrName];
947
+ if (typeof attrVal === 'string') {
948
+ emit(attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`);
949
+ }
950
+ else if (attrVal === null) {
951
+ emit('');
952
+ }
953
+ }
954
+ emit(mutationTracker.renderMutatedAttrs(instance));
955
+ }
956
+ function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
957
+ if (Cmp.renderMode !== 'light') {
958
+ yield '<template shadowrootmode="open"></template>';
959
+ }
960
+ }
961
+ function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
962
+ if (Cmp.renderMode !== 'light') {
963
+ emit('<template shadowrootmode="open"></template>');
964
+ }
965
+ }
966
+ async function serverSideRenderComponent(tagName, Component, props = {}, mode = 'asyncYield') {
967
+ if (typeof tagName !== 'string') {
968
+ throw new Error(`tagName must be a string, found: ${tagName}`);
879
969
  }
970
+ // TODO [#4726]: remove `generateMarkup` export
971
+ const generateMarkup = SYMBOL__GENERATE_MARKUP in Component ? Component[SYMBOL__GENERATE_MARKUP] : Component;
972
+ let markup = '';
973
+ const emit = (segment) => {
974
+ markup += segment;
975
+ };
976
+ if (mode === 'asyncYield') {
977
+ for await (const segment of generateMarkup(tagName, props, null, null)) {
978
+ markup += segment;
979
+ }
980
+ }
981
+ else if (mode === 'async') {
982
+ await generateMarkup(emit, tagName, props, null, null);
983
+ }
984
+ else if (mode === 'sync') {
985
+ generateMarkup(emit, tagName, props, null, null);
986
+ }
987
+ else {
988
+ throw new Error(`Invalid mode: ${mode}`);
989
+ }
990
+ return markup;
880
991
  }
881
992
 
882
993
  /*
@@ -927,6 +1038,73 @@ function validateStyleTextContents(contents) {
927
1038
  }
928
1039
  }
929
1040
 
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 */
1041
+ /*
1042
+ * Copyright (c) 2024, Salesforce, Inc.
1043
+ * All rights reserved.
1044
+ * SPDX-License-Identifier: MIT
1045
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1046
+ */
1047
+ function hasScopedStaticStylesheets(Component) {
1048
+ const { stylesheets } = Component;
1049
+ if (stylesheets) {
1050
+ return flattenStylesheets(stylesheets).some((stylesheet) => stylesheet.$scoped$);
1051
+ }
1052
+ return false;
1053
+ }
1054
+ function renderStylesheets(stylesheets, scopeToken, Component, hasScopedTemplateStyles) {
1055
+ const hasAnyScopedStyles = hasScopedTemplateStyles || hasScopedStaticStylesheets(Component);
1056
+ let result = '';
1057
+ const truthyStylesheets = stylesheets.filter(Boolean);
1058
+ for (const stylesheet of flattenStylesheets(truthyStylesheets)) {
1059
+ // TODO [#2869]: `<style>`s should not have scope token classes
1060
+ result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} type="text/css">`;
1061
+ const token = stylesheet.$scoped$ ? scopeToken : undefined;
1062
+ const useActualHostSelector = !stylesheet.$scoped$ || Component.renderMode !== 'light';
1063
+ const useNativeDirPseudoclass = true;
1064
+ const styleContents = stylesheet(token, useActualHostSelector, useNativeDirPseudoclass);
1065
+ validateStyleTextContents(styleContents);
1066
+ result += styleContents + '</style>';
1067
+ }
1068
+ return result;
1069
+ }
1070
+
1071
+ /*
1072
+ * Copyright (c) 2024, salesforce.com, inc.
1073
+ * All rights reserved.
1074
+ * SPDX-License-Identifier: MIT
1075
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1076
+ */
1077
+ /**
1078
+ * Converts an iterable into one that emits the object used by the [`iterator` directive](
1079
+ * https://lwc.dev/guide/html_templates#iterator).
1080
+ */
1081
+ function* toIteratorDirective(iterable) {
1082
+ if (iterable === undefined || iterable === null)
1083
+ return;
1084
+ if (!iterable[Symbol.iterator]) {
1085
+ throw new Error(
1086
+ // Mimic error message from "[i]terable node" in engine-core's api.ts
1087
+ `Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
1088
+ }
1089
+ const iterator = iterable[Symbol.iterator]();
1090
+ let next = iterator.next();
1091
+ let index = 0;
1092
+ let { value, done: last = false } = next;
1093
+ while (last === false) {
1094
+ // using a look-back approach because we need to know if the element is the last
1095
+ next = iterator.next();
1096
+ last = next.done ?? false;
1097
+ yield {
1098
+ value,
1099
+ index,
1100
+ first: index === 0,
1101
+ last,
1102
+ };
1103
+ index += 1;
1104
+ value = next.value;
1105
+ }
1106
+ }
1107
+
1108
+ export { ClassList, LightningElement, SYMBOL__GENERATE_MARKUP, SYMBOL__SET_INTERNALS, api, createContextProvider, createElement, fallbackTmpl, fallbackTmplNoYield, freezeTemplate, getComponentDef, hasScopedStaticStylesheets, hot, htmlEscape, isComponentConstructor, mutationTracker, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, renderAttrs, renderAttrsNoYield, serverSideRenderComponent as renderComponent, renderStylesheets, renderer, sanitizeAttribute, sanitizeHtmlContent, serverSideRenderComponent, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, toIteratorDirective, track, unwrap, validateStyleTextContents, wire };
1109
+ /** version: 8.6.0 */
932
1110
  //# sourceMappingURL=index.js.map