@lwc/ssr-runtime 8.4.0 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -11,110 +11,217 @@ 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
- }
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.');
82
17
  }
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;
18
+ function createContextProvider(..._) {
19
+ throw new Error('createContextProvider cannot be used in SSR context.');
20
+ }
21
+ function createElement(..._) {
22
+ throw new Error('createElement cannot be used in SSR context.');
23
+ }
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.');
82
+ },
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.');
190
+ },
191
+ assertInstanceOfHTMLElement(..._) {
192
+ throw new Error('renderer.assertInstanceOfHTMLElement cannot be used in SSR context.');
193
+ },
194
+ ownerDocument(..._) {
195
+ throw new Error('renderer.ownerDocument cannot be used in SSR context.');
196
+ },
197
+ registerContextConsumer(..._) {
198
+ throw new Error('renderer.registerContextConsumer cannot be used in SSR context.');
199
+ },
200
+ attachInternals(..._) {
201
+ throw new Error('renderer.attachInternals cannot be used in SSR context.');
202
+ },
203
+ defineCustomElement(..._) {
204
+ throw new Error('renderer.defineCustomElement cannot be used in SSR context.');
205
+ },
206
+ getParentNode(..._) {
207
+ throw new Error('renderer.getParentNode cannot be used in SSR context.');
208
+ },
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.');
214
+ },
117
215
  };
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;
118
225
 
119
226
  /**
120
227
  * Copyright (c) 2024 Salesforce, Inc.
@@ -130,6 +237,16 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
130
237
  * @param value
131
238
  * @param msg
132
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}`);
248
+ }
249
+ }
133
250
 
134
251
  /*
135
252
  * Copyright (c) 2024, Salesforce, Inc.
@@ -150,6 +267,8 @@ defineProperty,
150
267
  entries,
151
268
  /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
152
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,
153
272
  /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
154
273
  getOwnPropertyDescriptor,
155
274
  /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
@@ -323,16 +442,162 @@ const ESCAPED_CHARS = {
323
442
  '>': '>',
324
443
  '&': '&',
325
444
  };
326
- /**
327
- *
328
- * @param str
329
- * @param attrMode
330
- */
331
- function htmlEscape(str, attrMode = false) {
332
- const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
333
- return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
334
- }
335
- /** version: 8.4.0 */
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]);
453
+ }
454
+
455
+ /*
456
+ * Copyright (c) 2024, Salesforce, Inc.
457
+ * All rights reserved.
458
+ * SPDX-License-Identifier: MIT
459
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
460
+ */
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;
476
+ }
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;
488
+ }
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
+ };
336
601
 
337
602
  /*
338
603
  * Copyright (c) 2024, Salesforce, Inc.
@@ -367,263 +632,13 @@ class MutationTracker {
367
632
  if (mutatedAttrs) {
368
633
  return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
369
634
  }
370
- else {
371
- return '';
372
- }
373
- }
374
- }
375
- _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
376
- const mutationTracker = new MutationTracker();
377
-
378
- /*
379
- * Copyright (c) 2024, Salesforce, Inc.
380
- * All rights reserved.
381
- * SPDX-License-Identifier: MIT
382
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
383
- */
384
- // Eventually include globals that also reflect
385
- const attrsToProps = AriaAttrNameToPropNameMap;
386
- function reflectAttrToProp(instance, attrName, attrValue) {
387
- const reflectedPropName = attrsToProps[attrName];
388
- // If it is a reflected property and it was not overridden by the instance
389
- if (reflectedPropName && !hasOwnProperty.call(instance, reflectedPropName)) {
390
- const currentValue = instance[reflectedPropName];
391
- if (currentValue !== attrValue) {
392
- instance[reflectedPropName] = attrValue;
393
- }
394
- }
395
- }
396
- const descriptors = create(null);
397
- for (const [attrName, propName] of entries(attrsToProps)) {
398
- descriptors[propName] = {
399
- get() {
400
- return this.getAttribute(attrName);
401
- },
402
- set(newValue) {
403
- const currentValue = this.getAttribute(attrName);
404
- if (newValue !== currentValue) {
405
- // TODO [#3284]: According to the spec, IDL nullable type values
406
- // (null and undefined) should remove the attribute; however, we
407
- // only do so in the case of null for historical reasons.
408
- // See also https://github.com/w3c/aria/issues/1858
409
- if (isNull(newValue)) {
410
- this.removeAttribute(attrName);
411
- }
412
- else {
413
- this.setAttribute(attrName, toString(newValue));
414
- }
415
- }
416
- },
417
- configurable: true,
418
- enumerable: true,
419
- };
420
- }
421
-
422
- /*
423
- * Copyright (c) 2024, salesforce.com, inc.
424
- * All rights reserved.
425
- * SPDX-License-Identifier: MIT
426
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
427
- */
428
- var _LightningElement_attrs, _LightningElement_classList;
429
- const SYMBOL__SET_INTERNALS = Symbol('set-internals');
430
- class LightningElement {
431
- constructor(propsAvailableAtConstruction) {
432
- this.isConnected = false;
433
- this.className = '';
434
- _LightningElement_attrs.set(this, void 0);
435
- _LightningElement_classList.set(this, null);
436
- assign(this, propsAvailableAtConstruction);
437
- }
438
- [(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
439
- __classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
440
- assign(this, props);
441
- defineProperty(this, 'className', {
442
- get() {
443
- return props.class ?? '';
444
- },
445
- set(newVal) {
446
- props.class = newVal;
447
- attrs.class = newVal;
448
- mutationTracker.add(this, 'class');
449
- },
450
- });
451
- }
452
- get classList() {
453
- if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
454
- return __classPrivateFieldGet(this, _LightningElement_classList, "f");
455
- }
456
- return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
457
- }
458
- setAttribute(attrName, attrValue) {
459
- const normalizedName = StringToLowerCase.call(toString(attrName));
460
- const normalizedValue = String(attrValue);
461
- __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
462
- reflectAttrToProp(this, normalizedName, normalizedValue);
463
- mutationTracker.add(this, normalizedName);
464
- }
465
- getAttribute(attrName) {
466
- const normalizedName = StringToLowerCase.call(toString(attrName));
467
- if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
468
- return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
469
- }
470
- return null;
471
- }
472
- hasAttribute(attrName) {
473
- const normalizedName = StringToLowerCase.call(toString(attrName));
474
- return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
475
- }
476
- removeAttribute(attrName) {
477
- const normalizedName = StringToLowerCase.call(toString(attrName));
478
- delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
479
- reflectAttrToProp(this, normalizedName, null);
480
- // Track mutations for removal of non-existing attributes
481
- mutationTracker.add(this, normalizedName);
482
- }
483
- addEventListener(_type, _listener, _options) {
484
- // noop
485
- }
486
- removeEventListener(_type, _listener, _options) {
487
- // noop
488
- }
489
- // ----------------------------------------------------------- //
490
- // Props/methods explicitly not available in this environment //
491
- // Getters are named "get*" for parity with @lwc/engine-server //
492
- // ----------------------------------------------------------- //
493
- get children() {
494
- throw new TypeError('"getChildren" is not supported in this environment');
495
- }
496
- get childNodes() {
497
- throw new TypeError('"getChildNodes" is not supported in this environment');
498
- }
499
- get firstChild() {
500
- throw new TypeError('"getFirstChild" is not supported in this environment');
501
- }
502
- get firstElementChild() {
503
- throw new TypeError('"getFirstElementChild" is not supported in this environment');
504
- }
505
- get hostElement() {
506
- // Intentionally different to match @lwc/engine-*core*
507
- throw new TypeError('this.hostElement is not supported in this environment');
508
- }
509
- get lastChild() {
510
- throw new TypeError('"getLastChild" is not supported in this environment');
511
- }
512
- get lastElementChild() {
513
- throw new TypeError('"getLastElementChild" is not supported in this environment');
514
- }
515
- get ownerDocument() {
516
- // Intentionally not "get*" to match @lwc/engine-server
517
- throw new TypeError('"ownerDocument" is not supported in this environment');
518
- }
519
- get style() {
520
- // Intentionally not "get*" to match @lwc/engine-server
521
- throw new TypeError('"style" is not supported in this environment');
522
- }
523
- attachInternals() {
524
- throw new TypeError('"attachInternals" is not supported in this environment');
525
- }
526
- dispatchEvent(_event) {
527
- throw new TypeError('"dispatchEvent" is not supported in this environment');
528
- }
529
- getBoundingClientRect() {
530
- throw new TypeError('"getBoundingClientRect" is not supported in this environment');
531
- }
532
- getElementsByClassName(_classNames) {
533
- throw new TypeError('"getElementsByClassName" is not supported in this environment');
534
- }
535
- getElementsByTagName(_qualifiedName) {
536
- throw new TypeError('"getElementsByTagName" is not supported in this environment');
537
- }
538
- querySelector(_selectors) {
539
- throw new TypeError('"querySelector" is not supported in this environment');
540
- }
541
- querySelectorAll(_selectors) {
542
- throw new TypeError('"querySelectorAll" is not supported in this environment');
543
- }
544
- getAttributeNS(_namespace, _localName) {
545
- throw new Error('Method "getAttributeNS" not implemented.');
546
- }
547
- hasAttributeNS(_namespace, _localName) {
548
- throw new Error('Method "hasAttributeNS" not implemented.');
549
- }
550
- removeAttributeNS(_namespace, _localName) {
551
- throw new Error('Method "removeAttributeNS" not implemented.');
552
- }
553
- setAttributeNS(_namespace, _qualifiedName, _value) {
554
- throw new Error('Method "setAttributeNS" not implemented.');
555
- }
556
- }
557
- defineProperties(LightningElement.prototype, descriptors);
558
-
559
- /*
560
- * Copyright (c) 2024, salesforce.com, inc.
561
- * All rights reserved.
562
- * SPDX-License-Identifier: MIT
563
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
564
- */
565
- const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&amp;').replaceAll('"', '&quot;');
566
- function* renderAttrs(instance, attrs) {
567
- if (!attrs) {
568
- return;
569
- }
570
- for (const attrName of Object.getOwnPropertyNames(attrs)) {
571
- const attrVal = attrs[attrName];
572
- if (typeof attrVal === 'string') {
573
- yield attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`;
574
- }
575
- else if (attrVal === null) {
576
- yield '';
577
- }
578
- }
579
- yield mutationTracker.renderMutatedAttrs(instance);
580
- }
581
- function renderAttrsNoYield(emit, instance, attrs) {
582
- if (!attrs) {
583
- return;
584
- }
585
- for (const attrName of Object.getOwnPropertyNames(attrs)) {
586
- const attrVal = attrs[attrName];
587
- if (typeof attrVal === 'string') {
588
- emit(attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`);
589
- }
590
- else if (attrVal === null) {
591
- emit('');
592
- }
593
- }
594
- emit(mutationTracker.renderMutatedAttrs(instance));
595
- }
596
- function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
597
- if (Cmp.renderMode !== 'light') {
598
- yield '<template shadowrootmode="open"></template>';
599
- }
600
- }
601
- function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
602
- if (Cmp.renderMode !== 'light') {
603
- emit('<template shadowrootmode="open"></template>');
604
- }
605
- }
606
- async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props, mode = 'asyncYield') {
607
- let markup = '';
608
- const emit = (segment) => {
609
- markup += segment;
610
- };
611
- if (mode === 'asyncYield') {
612
- for await (const segment of compiledGenerateMarkup(tagName, props, null, null)) {
613
- markup += segment;
635
+ else {
636
+ return '';
614
637
  }
615
638
  }
616
- else if (mode === 'async') {
617
- await compiledGenerateMarkup(emit, tagName, props, null, null);
618
- }
619
- else if (mode === 'sync') {
620
- compiledGenerateMarkup(emit, tagName, props, null, null);
621
- }
622
- else {
623
- throw new Error(`Invalid mode: ${mode}`);
624
- }
625
- return markup;
626
639
  }
640
+ _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
641
+ const mutationTracker = new MutationTracker();
627
642
 
628
643
  /*
629
644
  * Copyright (c) 2024, Salesforce, Inc.
@@ -631,220 +646,279 @@ async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props,
631
646
  * SPDX-License-Identifier: MIT
632
647
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
633
648
  */
634
- // Stubs for all the un-implemented exports from @lwc/engine-server
635
- function api(..._) {
636
- throw new Error('@api cannot be used in SSR context.');
637
- }
638
- function createContextProvider(..._) {
639
- throw new Error('createContextProvider cannot be used in SSR context.');
640
- }
641
- function createElement(..._) {
642
- throw new Error('createElement cannot be used in SSR context.');
643
- }
644
- function freezeTemplate(..._) {
645
- throw new Error('freezeTemplate cannot be used in SSR context.');
646
- }
647
- function getComponentDef(..._) {
648
- throw new Error('getComponentDef cannot be used in SSR context.');
649
- }
650
- function isComponentConstructor(..._) {
651
- throw new Error('isComponentConstructor cannot be used in SSR context.');
652
- }
653
- function parseFragment(..._) {
654
- throw new Error('parseFragment cannot be used in SSR context.');
655
- }
656
- function parseSVGFragment(..._) {
657
- throw new Error('parseSVGFragment cannot be used in SSR context.');
658
- }
659
- function readonly(..._) {
660
- throw new Error('readonly cannot be used in SSR context.');
661
- }
662
- function registerComponent(..._) {
663
- throw new Error('registerComponent cannot be used in SSR context.');
664
- }
665
- function registerDecorators(..._) {
666
- throw new Error('registerDecorators cannot be used in SSR context.');
667
- }
668
- function registerTemplate(..._) {
669
- throw new Error('registerTemplate cannot be used in SSR context.');
670
- }
671
- function sanitizeAttribute(..._) {
672
- throw new Error('sanitizeAttribute cannot be used in SSR context.');
673
- }
674
- function setFeatureFlag(..._) {
675
- throw new Error('setFeatureFlag cannot be used in SSR context.');
676
- }
677
- function setFeatureFlagForTest(..._) {
678
- throw new Error('setFeatureFlagForTest cannot be used in SSR context.');
679
- }
680
- function setHooks(..._) {
681
- throw new Error('setHooks cannot be used in SSR context.');
682
- }
683
- function swapComponent(..._) {
684
- throw new Error('swapComponent cannot be used in SSR context.');
685
- }
686
- function swapStyle(..._) {
687
- throw new Error('swapStyle cannot be used in SSR context.');
688
- }
689
- function swapTemplate(..._) {
690
- throw new Error('swapTemplate cannot be used in SSR context.');
691
- }
692
- function track(..._) {
693
- throw new Error('@track cannot be used in SSR context.');
694
- }
695
- function unwrap(..._) {
696
- throw new Error('unwrap cannot be used in SSR context.');
697
- }
698
- function wire(..._) {
699
- throw new Error('@wire cannot be used in SSR context.');
700
- }
701
- const renderer = {
702
- isSyntheticShadowDefined: false,
703
- insert(..._) {
704
- throw new Error('renderer.insert cannot be used in SSR context.');
705
- },
706
- remove(..._) {
707
- throw new Error('renderer.remove cannot be used in SSR context.');
708
- },
709
- cloneNode(..._) {
710
- throw new Error('renderer.cloneNode cannot be used in SSR context.');
711
- },
712
- createFragment(..._) {
713
- throw new Error('renderer.createFragment cannot be used in SSR context.');
714
- },
715
- createElement(..._) {
716
- throw new Error('renderer.createElement cannot be used in SSR context.');
717
- },
718
- createText(..._) {
719
- throw new Error('renderer.createText cannot be used in SSR context.');
720
- },
721
- createComment(..._) {
722
- throw new Error('renderer.createComment cannot be used in SSR context.');
723
- },
724
- createCustomElement(..._) {
725
- throw new Error('renderer.createCustomElement cannot be used in SSR context.');
726
- },
727
- nextSibling(..._) {
728
- throw new Error('renderer.nextSibling cannot be used in SSR context.');
729
- },
730
- previousSibling(..._) {
731
- throw new Error('renderer.previousSibling cannot be used in SSR context.');
732
- },
733
- attachShadow(..._) {
734
- throw new Error('renderer.attachShadow cannot be used in SSR context.');
735
- },
736
- getProperty(..._) {
737
- throw new Error('renderer.getProperty cannot be used in SSR context.');
738
- },
739
- setProperty(..._) {
740
- throw new Error('renderer.setProperty cannot be used in SSR context.');
741
- },
742
- setText(..._) {
743
- throw new Error('renderer.setText cannot be used in SSR context.');
744
- },
745
- getAttribute(..._) {
746
- throw new Error('renderer.getAttribute cannot be used in SSR context.');
747
- },
748
- setAttribute(..._) {
749
- throw new Error('renderer.setAttribute cannot be used in SSR context.');
750
- },
751
- removeAttribute(..._) {
752
- throw new Error('renderer.removeAttribute cannot be used in SSR context.');
753
- },
754
- addEventListener(..._) {
755
- throw new Error('renderer.addEventListener cannot be used in SSR context.');
756
- },
757
- removeEventListener(..._) {
758
- throw new Error('renderer.removeEventListener cannot be used in SSR context.');
759
- },
760
- dispatchEvent(..._) {
761
- throw new Error('renderer.dispatchEvent cannot be used in SSR context.');
762
- },
763
- getClassList(..._) {
764
- throw new Error('renderer.getClassList cannot be used in SSR context.');
765
- },
766
- setCSSStyleProperty(..._) {
767
- throw new Error('renderer.setCSSStyleProperty cannot be used in SSR context.');
768
- },
769
- getBoundingClientRect(..._) {
770
- throw new Error('renderer.getBoundingClientRect cannot be used in SSR context.');
771
- },
772
- querySelector(..._) {
773
- throw new Error('renderer.querySelector cannot be used in SSR context.');
774
- },
775
- querySelectorAll(..._) {
776
- throw new Error('renderer.querySelectorAll cannot be used in SSR context.');
777
- },
778
- getElementsByTagName(..._) {
779
- throw new Error('renderer.getElementsByTagName cannot be used in SSR context.');
780
- },
781
- getElementsByClassName(..._) {
782
- throw new Error('renderer.getElementsByClassName cannot be used in SSR context.');
783
- },
784
- getChildren(..._) {
785
- throw new Error('renderer.getChildren cannot be used in SSR context.');
786
- },
787
- getChildNodes(..._) {
788
- throw new Error('renderer.getChildNodes cannot be used in SSR context.');
789
- },
790
- getFirstChild(..._) {
791
- throw new Error('renderer.getFirstChild cannot be used in SSR context.');
792
- },
793
- getFirstElementChild(..._) {
794
- throw new Error('renderer.getFirstElementChild cannot be used in SSR context.');
795
- },
796
- getLastChild(..._) {
797
- throw new Error('renderer.getLastChild cannot be used in SSR context.');
798
- },
799
- getLastElementChild(..._) {
800
- throw new Error('renderer.getLastElementChild cannot be used in SSR context.');
801
- },
802
- getTagName(..._) {
803
- throw new Error('renderer.getTagName cannot be used in SSR context.');
804
- },
805
- getStyle(..._) {
806
- throw new Error('renderer.getStyle cannot be used in SSR context.');
807
- },
808
- isConnected(..._) {
809
- throw new Error('renderer.isConnected cannot be used in SSR context.');
810
- },
811
- insertStylesheet(..._) {
812
- throw new Error('renderer.insertStylesheet cannot be used in SSR context.');
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);
813
673
  },
814
- assertInstanceOfHTMLElement(..._) {
815
- 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
+ }
816
680
  },
817
- ownerDocument(..._) {
818
- 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);
819
689
  },
820
- registerContextConsumer(..._) {
821
- 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
+ }
822
696
  },
823
- attachInternals(..._) {
824
- 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);
825
706
  },
826
- defineCustomElement(..._) {
827
- 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
+ }
828
719
  },
829
- getParentNode(..._) {
830
- 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);
831
729
  },
832
- startTrackingMutations(..._) {
833
- 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
+ }
834
743
  },
835
- stopTrackingMutations(..._) {
836
- 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
+ },
837
777
  },
778
+ title: stringDescriptor('title'),
838
779
  };
839
- /**
840
- * The hot API is used to orchestrate hot swapping in client rendered components.
841
- * It doesn't do anything on the server side, however, you may import it.
842
- *
843
- * The whole point of defining this and exporting it is so that you can import it in isomorphic code without
844
- * 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
845
790
  */
846
- // A real stub, not a "not implemented" one! 😯
847
- 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);
848
922
 
849
923
  /*
850
924
  * Copyright (c) 2024, salesforce.com, inc.
@@ -852,35 +926,72 @@ const hot = undefined;
852
926
  * SPDX-License-Identifier: MIT
853
927
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
854
928
  */
855
- /**
856
- * Converts an iterable into one that emits the object used by the [`iterator` directive](
857
- * https://lwc.dev/guide/html_templates#iterator).
858
- */
859
- function* toIteratorDirective(iterable) {
860
- if (iterable === undefined || iterable === null)
929
+ const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&amp;').replaceAll('"', '&quot;');
930
+ function* renderAttrs(instance, attrs) {
931
+ if (!attrs) {
861
932
  return;
862
- if (!iterable[Symbol.iterator]) {
863
- throw new Error(
864
- // Mimic error message from "[i]terable node" in engine-core's api.ts
865
- `Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
866
933
  }
867
- const iterator = iterable[Symbol.iterator]();
868
- let next = iterator.next();
869
- let index = 0;
870
- let { value, done: last = false } = next;
871
- while (last === false) {
872
- // using a look-back approach because we need to know if the element is the last
873
- next = iterator.next();
874
- last = next.done ?? false;
875
- yield {
876
- value,
877
- index,
878
- first: index === 0,
879
- last,
880
- };
881
- index += 1;
882
- 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}`);
883
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}`);
993
+ }
994
+ return markup;
884
995
  }
885
996
 
886
997
  /*
@@ -931,8 +1042,76 @@ function validateStyleTextContents(contents) {
931
1042
  }
932
1043
  }
933
1044
 
1045
+ /*
1046
+ * Copyright (c) 2024, Salesforce, Inc.
1047
+ * All rights reserved.
1048
+ * SPDX-License-Identifier: MIT
1049
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1050
+ */
1051
+ function hasScopedStaticStylesheets(Component) {
1052
+ const { stylesheets } = Component;
1053
+ if (stylesheets) {
1054
+ return flattenStylesheets(stylesheets).some((stylesheet) => stylesheet.$scoped$);
1055
+ }
1056
+ return false;
1057
+ }
1058
+ function renderStylesheets(stylesheets, scopeToken, Component, hasScopedTemplateStyles) {
1059
+ const hasAnyScopedStyles = hasScopedTemplateStyles || hasScopedStaticStylesheets(Component);
1060
+ let result = '';
1061
+ const truthyStylesheets = stylesheets.filter(Boolean);
1062
+ for (const stylesheet of flattenStylesheets(truthyStylesheets)) {
1063
+ // TODO [#2869]: `<style>`s should not have scope token classes
1064
+ result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} type="text/css">`;
1065
+ const token = stylesheet.$scoped$ ? scopeToken : undefined;
1066
+ const useActualHostSelector = !stylesheet.$scoped$ || Component.renderMode !== 'light';
1067
+ const useNativeDirPseudoclass = true;
1068
+ const styleContents = stylesheet(token, useActualHostSelector, useNativeDirPseudoclass);
1069
+ validateStyleTextContents(styleContents);
1070
+ result += styleContents + '</style>';
1071
+ }
1072
+ return result;
1073
+ }
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
+
934
1112
  exports.ClassList = ClassList;
935
1113
  exports.LightningElement = LightningElement;
1114
+ exports.SYMBOL__GENERATE_MARKUP = SYMBOL__GENERATE_MARKUP;
936
1115
  exports.SYMBOL__SET_INTERNALS = SYMBOL__SET_INTERNALS;
937
1116
  exports.api = api;
938
1117
  exports.createContextProvider = createContextProvider;
@@ -941,6 +1120,7 @@ exports.fallbackTmpl = fallbackTmpl;
941
1120
  exports.fallbackTmplNoYield = fallbackTmplNoYield;
942
1121
  exports.freezeTemplate = freezeTemplate;
943
1122
  exports.getComponentDef = getComponentDef;
1123
+ exports.hasScopedStaticStylesheets = hasScopedStaticStylesheets;
944
1124
  exports.hot = hot;
945
1125
  exports.htmlEscape = htmlEscape;
946
1126
  exports.isComponentConstructor = isComponentConstructor;
@@ -954,6 +1134,7 @@ exports.registerTemplate = registerTemplate;
954
1134
  exports.renderAttrs = renderAttrs;
955
1135
  exports.renderAttrsNoYield = renderAttrsNoYield;
956
1136
  exports.renderComponent = serverSideRenderComponent;
1137
+ exports.renderStylesheets = renderStylesheets;
957
1138
  exports.renderer = renderer;
958
1139
  exports.sanitizeAttribute = sanitizeAttribute;
959
1140
  exports.serverSideRenderComponent = serverSideRenderComponent;
@@ -968,5 +1149,5 @@ exports.track = track;
968
1149
  exports.unwrap = unwrap;
969
1150
  exports.validateStyleTextContents = validateStyleTextContents;
970
1151
  exports.wire = wire;
971
- /** version: 8.4.0 */
1152
+ /** version: 8.6.0 */
972
1153
  //# sourceMappingURL=index.cjs.js.map