@lwc/ssr-runtime 8.1.3 → 8.3.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/class-list.d.ts +32 -0
- package/dist/index.cjs.js +471 -75
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -77
- package/dist/index.js +443 -76
- package/dist/index.js.map +1 -1
- package/dist/lightning-element.d.ts +58 -0
- package/dist/mutation-tracker.d.ts +10 -0
- package/dist/render.d.ts +6 -0
- package/dist/stubs.d.ts +78 -0
- package/dist/to-iterator-directive.d.ts +10 -0
- package/dist/types.d.ts +1 -0
- package/package.json +4 -2
@@ -0,0 +1,32 @@
|
|
1
|
+
import { LightningElement } from './lightning-element';
|
2
|
+
interface DOMTokenList {
|
3
|
+
readonly length: number;
|
4
|
+
value: string;
|
5
|
+
toString(): string;
|
6
|
+
add(...tokens: string[]): void;
|
7
|
+
contains(token: string): boolean;
|
8
|
+
item(index: number): string | null;
|
9
|
+
remove(...tokens: string[]): void;
|
10
|
+
replace(token: string, newToken: string): boolean;
|
11
|
+
supports(token: string): boolean;
|
12
|
+
toggle(token: string, force?: boolean): boolean;
|
13
|
+
forEach(callbackfn: (value: string, key: number, parent: DOMTokenList) => void, thisArg?: any): void;
|
14
|
+
[index: number]: string;
|
15
|
+
}
|
16
|
+
export declare class ClassList implements DOMTokenList {
|
17
|
+
el: LightningElement;
|
18
|
+
constructor(el: LightningElement);
|
19
|
+
add(...newClassNames: string[]): void;
|
20
|
+
contains(className: string): boolean;
|
21
|
+
remove(...classNamesToRemove: string[]): void;
|
22
|
+
replace(oldClassName: string, newClassName: string): boolean;
|
23
|
+
toggle(classNameToToggle: string, force?: boolean): boolean;
|
24
|
+
get value(): string;
|
25
|
+
toString(): string;
|
26
|
+
[index: number]: never;
|
27
|
+
item(_index: number): string | null;
|
28
|
+
supports(_token: string): boolean;
|
29
|
+
forEach(_callbackfn: (value: string, key: number, parent: DOMTokenList) => void, _thisArg?: any): void;
|
30
|
+
get length(): number;
|
31
|
+
}
|
32
|
+
export {};
|
package/dist/index.cjs.js
CHANGED
@@ -5,67 +5,14 @@
|
|
5
5
|
|
6
6
|
Object.defineProperty(exports, '__esModule', { value: true });
|
7
7
|
|
8
|
-
|
9
|
-
* Copyright (c) 2024, Salesforce, Inc.
|
10
|
-
* All rights reserved.
|
11
|
-
* SPDX-License-Identifier: MIT
|
12
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
13
|
-
*/
|
14
|
-
/**
|
15
|
-
* Per the HTML spec on restrictions for "raw text elements" like `<style>`:
|
16
|
-
*
|
17
|
-
* > The text in raw text and escapable raw text elements must not contain any occurrences of the string
|
18
|
-
* > "</" (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of
|
19
|
-
* > the element followed by one of:
|
20
|
-
* > - U+0009 CHARACTER TABULATION (tab)
|
21
|
-
* > - U+000A LINE FEED (LF)
|
22
|
-
* > - U+000C FORM FEED (FF)
|
23
|
-
* > - U+000D CARRIAGE RETURN (CR)
|
24
|
-
* > - U+0020 SPACE
|
25
|
-
* > - U+003E GREATER-THAN SIGN (>), or
|
26
|
-
* > - U+002F SOLIDUS (/)
|
27
|
-
* @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
|
28
|
-
*/
|
29
|
-
const INVALID_STYLE_CONTENT = /<\/style[\t\n\f\r >/]/i;
|
30
|
-
/**
|
31
|
-
* The text content inside `<style>` is a special case. It is _only_ rendered by the LWC engine itself; `<style>` tags
|
32
|
-
* are disallowed inside of HTML templates.
|
33
|
-
*
|
34
|
-
* The `<style>` tag is unusual in how it's defined in HTML. Like `<script>`, it is considered a "raw text element,"
|
35
|
-
* which means that it is parsed as raw text, but certain character sequences are disallowed, namely to avoid XSS
|
36
|
-
* attacks like `</style><script>alert("pwned")</script>`.
|
37
|
-
*
|
38
|
-
* This also means that we cannot use "normal" HTML escaping inside `<style>` tags, e.g. we cannot use `<`,
|
39
|
-
* `>`, etc., because these are treated as-is by the HTML parser.
|
40
|
-
*
|
41
|
-
*
|
42
|
-
* @param contents CSS source to validate
|
43
|
-
* @throws Throws if the contents provided are not valid.
|
44
|
-
* @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
|
45
|
-
* @see https://github.com/salesforce/lwc/issues/3439
|
46
|
-
* @example
|
47
|
-
* validateStyleTextContents('div { color: red }') // Ok
|
48
|
-
* validateStyleTextContents('</style><script>alert("pwned")</script>') // Throws
|
49
|
-
*/
|
50
|
-
function validateStyleTextContents(contents) {
|
51
|
-
if (INVALID_STYLE_CONTENT.test(contents)) {
|
52
|
-
throw new Error('CSS contains unsafe characters and cannot be serialized inside a style element');
|
53
|
-
}
|
54
|
-
}
|
8
|
+
var shared = require('@lwc/shared');
|
55
9
|
|
56
10
|
/*
|
57
|
-
* Copyright (c) 2024,
|
11
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
58
12
|
* All rights reserved.
|
59
13
|
* SPDX-License-Identifier: MIT
|
60
14
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
61
15
|
*/
|
62
|
-
// At runtime, we don't have access to the DOM, so we don't want TypeScript to allow accessing DOM
|
63
|
-
// globals. However, we're mimicking DOM functionality here, so we *do* want access to DOM types.
|
64
|
-
// To access the real DOM types when writing new code, uncomment the line below and comment out the
|
65
|
-
// stub types. Switch them back when you're done to validate that you're not accidentally using
|
66
|
-
// DOM globals. IMPORTANT: The comment below is a "triple slash directive", it must start with ///
|
67
|
-
// and be located before import statements.
|
68
|
-
// /// <reference lib="dom" />
|
69
16
|
const MULTI_SPACE = /\s+/g;
|
70
17
|
class ClassList {
|
71
18
|
constructor(el) {
|
@@ -135,17 +82,103 @@ class ClassList {
|
|
135
82
|
throw new Error('Property "length" not implemented.');
|
136
83
|
}
|
137
84
|
}
|
85
|
+
|
86
|
+
/******************************************************************************
|
87
|
+
Copyright (c) Microsoft Corporation.
|
88
|
+
|
89
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
90
|
+
purpose with or without fee is hereby granted.
|
91
|
+
|
92
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
93
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
94
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
95
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
96
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
97
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
98
|
+
PERFORMANCE OF THIS SOFTWARE.
|
99
|
+
***************************************************************************** */
|
100
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
101
|
+
|
102
|
+
|
103
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
104
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
105
|
+
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");
|
106
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
107
|
+
}
|
108
|
+
|
109
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
110
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
111
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
112
|
+
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");
|
113
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
114
|
+
}
|
115
|
+
|
116
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
117
|
+
var e = new Error(message);
|
118
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
119
|
+
};
|
120
|
+
|
121
|
+
/*
|
122
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
123
|
+
* All rights reserved.
|
124
|
+
* SPDX-License-Identifier: MIT
|
125
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
126
|
+
*/
|
127
|
+
var _MutationTracker_enabledSet, _MutationTracker_mutationMap;
|
128
|
+
class MutationTracker {
|
129
|
+
constructor() {
|
130
|
+
_MutationTracker_enabledSet.set(this, new WeakSet());
|
131
|
+
_MutationTracker_mutationMap.set(this, new WeakMap());
|
132
|
+
}
|
133
|
+
add(instance, attrName) {
|
134
|
+
if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
|
135
|
+
let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
136
|
+
if (!mutatedAttrs) {
|
137
|
+
mutatedAttrs = new Set();
|
138
|
+
__classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
|
139
|
+
}
|
140
|
+
mutatedAttrs.add(attrName.toLowerCase());
|
141
|
+
}
|
142
|
+
}
|
143
|
+
enable(instance) {
|
144
|
+
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
|
145
|
+
}
|
146
|
+
disable(instance) {
|
147
|
+
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
|
148
|
+
}
|
149
|
+
renderMutatedAttrs(instance) {
|
150
|
+
const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
151
|
+
if (mutatedAttrs) {
|
152
|
+
return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
|
153
|
+
}
|
154
|
+
else {
|
155
|
+
return '';
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
_MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
|
160
|
+
const mutationTracker = new MutationTracker();
|
161
|
+
|
162
|
+
/*
|
163
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
164
|
+
* All rights reserved.
|
165
|
+
* SPDX-License-Identifier: MIT
|
166
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
167
|
+
*/
|
168
|
+
var _LightningElement_instances, _LightningElement_attrs, _LightningElement_classList, _LightningElement_setAttribute;
|
169
|
+
const SYMBOL__SET_INTERNALS = Symbol('set-internals');
|
138
170
|
class LightningElement {
|
139
171
|
constructor(propsAvailableAtConstruction) {
|
172
|
+
_LightningElement_instances.add(this);
|
140
173
|
this.isConnected = false;
|
141
174
|
this.className = '';
|
142
|
-
this
|
175
|
+
_LightningElement_attrs.set(this, void 0);
|
176
|
+
_LightningElement_classList.set(this, null);
|
143
177
|
Object.assign(this, propsAvailableAtConstruction);
|
144
178
|
}
|
145
|
-
|
146
|
-
__internal__setState(props, reflectedProps, attrs) {
|
179
|
+
[(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), _LightningElement_instances = new WeakSet(), SYMBOL__SET_INTERNALS)](props, reflectedProps, attrs) {
|
147
180
|
Object.assign(this, props);
|
148
|
-
this
|
181
|
+
__classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
|
149
182
|
// Whenever a reflected prop changes, we'll update the original props object
|
150
183
|
// that was passed in. That'll be referenced when the attrs are rendered later.
|
151
184
|
for (const reflectedPropName of reflectedProps) {
|
@@ -155,6 +188,7 @@ class LightningElement {
|
|
155
188
|
},
|
156
189
|
set(newValue) {
|
157
190
|
props[reflectedPropName] = newValue;
|
191
|
+
mutationTracker.add(this, shared.htmlPropertyToAttribute(reflectedPropName));
|
158
192
|
},
|
159
193
|
enumerable: true,
|
160
194
|
});
|
@@ -166,26 +200,40 @@ class LightningElement {
|
|
166
200
|
set(newVal) {
|
167
201
|
props.class = newVal;
|
168
202
|
attrs.class = newVal;
|
203
|
+
mutationTracker.add(this, 'class');
|
169
204
|
},
|
170
205
|
});
|
171
206
|
}
|
172
207
|
get classList() {
|
173
|
-
if (this
|
174
|
-
return this
|
208
|
+
if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
|
209
|
+
return __classPrivateFieldGet(this, _LightningElement_classList, "f");
|
175
210
|
}
|
176
|
-
return (this
|
211
|
+
return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
|
177
212
|
}
|
178
|
-
|
179
|
-
|
213
|
+
setAttribute(attrName, attrValue) {
|
214
|
+
__classPrivateFieldGet(this, _LightningElement_instances, "m", _LightningElement_setAttribute).call(this, attrName, String(attrValue));
|
180
215
|
}
|
181
|
-
|
182
|
-
this.
|
216
|
+
getAttribute(attrName) {
|
217
|
+
if (this.hasAttribute(attrName)) {
|
218
|
+
return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[attrName];
|
219
|
+
}
|
220
|
+
return null;
|
183
221
|
}
|
184
222
|
hasAttribute(attrName) {
|
185
|
-
return
|
223
|
+
return typeof attrName === 'string' && typeof __classPrivateFieldGet(this, _LightningElement_attrs, "f")[attrName] === 'string';
|
186
224
|
}
|
187
225
|
removeAttribute(attrName) {
|
188
|
-
this.
|
226
|
+
if (this.hasAttribute(attrName)) {
|
227
|
+
// Reflected attributes use accessor methods to update their
|
228
|
+
// corresponding properties so we can't simply `delete`. Instead,
|
229
|
+
// we use `null` when we want to remove.
|
230
|
+
__classPrivateFieldGet(this, _LightningElement_instances, "m", _LightningElement_setAttribute).call(this, attrName, null);
|
231
|
+
}
|
232
|
+
else {
|
233
|
+
// This interprets the removal of a non-existing attribute as an
|
234
|
+
// attribute mutation. We may want to revisit this.
|
235
|
+
mutationTracker.add(this, attrName);
|
236
|
+
}
|
189
237
|
}
|
190
238
|
addEventListener(_type, _listener, _options) {
|
191
239
|
// noop
|
@@ -261,19 +309,32 @@ class LightningElement {
|
|
261
309
|
throw new Error('Method "setAttributeNS" not implemented.');
|
262
310
|
}
|
263
311
|
}
|
312
|
+
_LightningElement_setAttribute = function _LightningElement_setAttribute(attrName, attrValue) {
|
313
|
+
__classPrivateFieldGet(this, _LightningElement_attrs, "f")[attrName] = attrValue;
|
314
|
+
mutationTracker.add(this, attrName);
|
315
|
+
};
|
316
|
+
|
317
|
+
/*
|
318
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
319
|
+
* All rights reserved.
|
320
|
+
* SPDX-License-Identifier: MIT
|
321
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
322
|
+
*/
|
264
323
|
const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&').replaceAll('"', '"');
|
265
|
-
function* renderAttrs(attrs) {
|
324
|
+
function* renderAttrs(instance, attrs) {
|
266
325
|
if (!attrs) {
|
267
326
|
return;
|
268
327
|
}
|
269
|
-
for (const
|
270
|
-
|
271
|
-
|
328
|
+
for (const attrName of Object.getOwnPropertyNames(attrs)) {
|
329
|
+
const attrVal = attrs[attrName];
|
330
|
+
if (typeof attrVal === 'string') {
|
331
|
+
yield attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`;
|
272
332
|
}
|
273
|
-
else if (
|
274
|
-
|
333
|
+
else if (attrVal === null) {
|
334
|
+
yield '';
|
275
335
|
}
|
276
336
|
}
|
337
|
+
yield mutationTracker.renderMutatedAttrs(instance);
|
277
338
|
}
|
278
339
|
function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
|
279
340
|
if (Cmp.renderMode !== 'light') {
|
@@ -288,10 +349,345 @@ async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props)
|
|
288
349
|
return markup;
|
289
350
|
}
|
290
351
|
|
352
|
+
/*
|
353
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
354
|
+
* All rights reserved.
|
355
|
+
* SPDX-License-Identifier: MIT
|
356
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
357
|
+
*/
|
358
|
+
// Stubs for all the un-implemented exports from @lwc/engine-server
|
359
|
+
function api(..._) {
|
360
|
+
throw new Error('@api cannot be used in SSR context.');
|
361
|
+
}
|
362
|
+
function createContextProvider(..._) {
|
363
|
+
throw new Error('createContextProvider cannot be used in SSR context.');
|
364
|
+
}
|
365
|
+
function createElement(..._) {
|
366
|
+
throw new Error('createElement cannot be used in SSR context.');
|
367
|
+
}
|
368
|
+
function freezeTemplate(..._) {
|
369
|
+
throw new Error('freezeTemplate cannot be used in SSR context.');
|
370
|
+
}
|
371
|
+
function getComponentDef(..._) {
|
372
|
+
throw new Error('getComponentDef cannot be used in SSR context.');
|
373
|
+
}
|
374
|
+
function isComponentConstructor(..._) {
|
375
|
+
throw new Error('isComponentConstructor cannot be used in SSR context.');
|
376
|
+
}
|
377
|
+
function parseFragment(..._) {
|
378
|
+
throw new Error('parseFragment cannot be used in SSR context.');
|
379
|
+
}
|
380
|
+
function parseSVGFragment(..._) {
|
381
|
+
throw new Error('parseSVGFragment cannot be used in SSR context.');
|
382
|
+
}
|
383
|
+
function readonly(..._) {
|
384
|
+
throw new Error('readonly cannot be used in SSR context.');
|
385
|
+
}
|
386
|
+
function registerComponent(..._) {
|
387
|
+
throw new Error('registerComponent cannot be used in SSR context.');
|
388
|
+
}
|
389
|
+
function registerDecorators(..._) {
|
390
|
+
throw new Error('registerDecorators cannot be used in SSR context.');
|
391
|
+
}
|
392
|
+
function registerTemplate(..._) {
|
393
|
+
throw new Error('registerTemplate cannot be used in SSR context.');
|
394
|
+
}
|
395
|
+
function sanitizeAttribute(..._) {
|
396
|
+
throw new Error('sanitizeAttribute cannot be used in SSR context.');
|
397
|
+
}
|
398
|
+
function setFeatureFlag(..._) {
|
399
|
+
throw new Error('setFeatureFlag cannot be used in SSR context.');
|
400
|
+
}
|
401
|
+
function setFeatureFlagForTest(..._) {
|
402
|
+
throw new Error('setFeatureFlagForTest cannot be used in SSR context.');
|
403
|
+
}
|
404
|
+
function setHooks(..._) {
|
405
|
+
throw new Error('setHooks cannot be used in SSR context.');
|
406
|
+
}
|
407
|
+
function swapComponent(..._) {
|
408
|
+
throw new Error('swapComponent cannot be used in SSR context.');
|
409
|
+
}
|
410
|
+
function swapStyle(..._) {
|
411
|
+
throw new Error('swapStyle cannot be used in SSR context.');
|
412
|
+
}
|
413
|
+
function swapTemplate(..._) {
|
414
|
+
throw new Error('swapTemplate cannot be used in SSR context.');
|
415
|
+
}
|
416
|
+
function track(..._) {
|
417
|
+
throw new Error('@track cannot be used in SSR context.');
|
418
|
+
}
|
419
|
+
function unwrap(..._) {
|
420
|
+
throw new Error('unwrap cannot be used in SSR context.');
|
421
|
+
}
|
422
|
+
function wire(..._) {
|
423
|
+
throw new Error('@wire cannot be used in SSR context.');
|
424
|
+
}
|
425
|
+
const renderer = {
|
426
|
+
isSyntheticShadowDefined: false,
|
427
|
+
insert(..._) {
|
428
|
+
throw new Error('renderer.insert cannot be used in SSR context.');
|
429
|
+
},
|
430
|
+
remove(..._) {
|
431
|
+
throw new Error('renderer.remove cannot be used in SSR context.');
|
432
|
+
},
|
433
|
+
cloneNode(..._) {
|
434
|
+
throw new Error('renderer.cloneNode cannot be used in SSR context.');
|
435
|
+
},
|
436
|
+
createFragment(..._) {
|
437
|
+
throw new Error('renderer.createFragment cannot be used in SSR context.');
|
438
|
+
},
|
439
|
+
createElement(..._) {
|
440
|
+
throw new Error('renderer.createElement cannot be used in SSR context.');
|
441
|
+
},
|
442
|
+
createText(..._) {
|
443
|
+
throw new Error('renderer.createText cannot be used in SSR context.');
|
444
|
+
},
|
445
|
+
createComment(..._) {
|
446
|
+
throw new Error('renderer.createComment cannot be used in SSR context.');
|
447
|
+
},
|
448
|
+
createCustomElement(..._) {
|
449
|
+
throw new Error('renderer.createCustomElement cannot be used in SSR context.');
|
450
|
+
},
|
451
|
+
nextSibling(..._) {
|
452
|
+
throw new Error('renderer.nextSibling cannot be used in SSR context.');
|
453
|
+
},
|
454
|
+
previousSibling(..._) {
|
455
|
+
throw new Error('renderer.previousSibling cannot be used in SSR context.');
|
456
|
+
},
|
457
|
+
attachShadow(..._) {
|
458
|
+
throw new Error('renderer.attachShadow cannot be used in SSR context.');
|
459
|
+
},
|
460
|
+
getProperty(..._) {
|
461
|
+
throw new Error('renderer.getProperty cannot be used in SSR context.');
|
462
|
+
},
|
463
|
+
setProperty(..._) {
|
464
|
+
throw new Error('renderer.setProperty cannot be used in SSR context.');
|
465
|
+
},
|
466
|
+
setText(..._) {
|
467
|
+
throw new Error('renderer.setText cannot be used in SSR context.');
|
468
|
+
},
|
469
|
+
getAttribute(..._) {
|
470
|
+
throw new Error('renderer.getAttribute cannot be used in SSR context.');
|
471
|
+
},
|
472
|
+
setAttribute(..._) {
|
473
|
+
throw new Error('renderer.setAttribute cannot be used in SSR context.');
|
474
|
+
},
|
475
|
+
removeAttribute(..._) {
|
476
|
+
throw new Error('renderer.removeAttribute cannot be used in SSR context.');
|
477
|
+
},
|
478
|
+
addEventListener(..._) {
|
479
|
+
throw new Error('renderer.addEventListener cannot be used in SSR context.');
|
480
|
+
},
|
481
|
+
removeEventListener(..._) {
|
482
|
+
throw new Error('renderer.removeEventListener cannot be used in SSR context.');
|
483
|
+
},
|
484
|
+
dispatchEvent(..._) {
|
485
|
+
throw new Error('renderer.dispatchEvent cannot be used in SSR context.');
|
486
|
+
},
|
487
|
+
getClassList(..._) {
|
488
|
+
throw new Error('renderer.getClassList cannot be used in SSR context.');
|
489
|
+
},
|
490
|
+
setCSSStyleProperty(..._) {
|
491
|
+
throw new Error('renderer.setCSSStyleProperty cannot be used in SSR context.');
|
492
|
+
},
|
493
|
+
getBoundingClientRect(..._) {
|
494
|
+
throw new Error('renderer.getBoundingClientRect cannot be used in SSR context.');
|
495
|
+
},
|
496
|
+
querySelector(..._) {
|
497
|
+
throw new Error('renderer.querySelector cannot be used in SSR context.');
|
498
|
+
},
|
499
|
+
querySelectorAll(..._) {
|
500
|
+
throw new Error('renderer.querySelectorAll cannot be used in SSR context.');
|
501
|
+
},
|
502
|
+
getElementsByTagName(..._) {
|
503
|
+
throw new Error('renderer.getElementsByTagName cannot be used in SSR context.');
|
504
|
+
},
|
505
|
+
getElementsByClassName(..._) {
|
506
|
+
throw new Error('renderer.getElementsByClassName cannot be used in SSR context.');
|
507
|
+
},
|
508
|
+
getChildren(..._) {
|
509
|
+
throw new Error('renderer.getChildren cannot be used in SSR context.');
|
510
|
+
},
|
511
|
+
getChildNodes(..._) {
|
512
|
+
throw new Error('renderer.getChildNodes cannot be used in SSR context.');
|
513
|
+
},
|
514
|
+
getFirstChild(..._) {
|
515
|
+
throw new Error('renderer.getFirstChild cannot be used in SSR context.');
|
516
|
+
},
|
517
|
+
getFirstElementChild(..._) {
|
518
|
+
throw new Error('renderer.getFirstElementChild cannot be used in SSR context.');
|
519
|
+
},
|
520
|
+
getLastChild(..._) {
|
521
|
+
throw new Error('renderer.getLastChild cannot be used in SSR context.');
|
522
|
+
},
|
523
|
+
getLastElementChild(..._) {
|
524
|
+
throw new Error('renderer.getLastElementChild cannot be used in SSR context.');
|
525
|
+
},
|
526
|
+
getTagName(..._) {
|
527
|
+
throw new Error('renderer.getTagName cannot be used in SSR context.');
|
528
|
+
},
|
529
|
+
getStyle(..._) {
|
530
|
+
throw new Error('renderer.getStyle cannot be used in SSR context.');
|
531
|
+
},
|
532
|
+
isConnected(..._) {
|
533
|
+
throw new Error('renderer.isConnected cannot be used in SSR context.');
|
534
|
+
},
|
535
|
+
insertStylesheet(..._) {
|
536
|
+
throw new Error('renderer.insertStylesheet cannot be used in SSR context.');
|
537
|
+
},
|
538
|
+
assertInstanceOfHTMLElement(..._) {
|
539
|
+
throw new Error('renderer.assertInstanceOfHTMLElement cannot be used in SSR context.');
|
540
|
+
},
|
541
|
+
ownerDocument(..._) {
|
542
|
+
throw new Error('renderer.ownerDocument cannot be used in SSR context.');
|
543
|
+
},
|
544
|
+
registerContextConsumer(..._) {
|
545
|
+
throw new Error('renderer.registerContextConsumer cannot be used in SSR context.');
|
546
|
+
},
|
547
|
+
attachInternals(..._) {
|
548
|
+
throw new Error('renderer.attachInternals cannot be used in SSR context.');
|
549
|
+
},
|
550
|
+
defineCustomElement(..._) {
|
551
|
+
throw new Error('renderer.defineCustomElement cannot be used in SSR context.');
|
552
|
+
},
|
553
|
+
getParentNode(..._) {
|
554
|
+
throw new Error('renderer.getParentNode cannot be used in SSR context.');
|
555
|
+
},
|
556
|
+
startTrackingMutations(..._) {
|
557
|
+
throw new Error('renderer.startTrackingMutations cannot be used in SSR context.');
|
558
|
+
},
|
559
|
+
stopTrackingMutations(..._) {
|
560
|
+
throw new Error('renderer.stopTrackingMutations cannot be used in SSR context.');
|
561
|
+
},
|
562
|
+
};
|
563
|
+
/**
|
564
|
+
* The hot API is used to orchestrate hot swapping in client rendered components.
|
565
|
+
* It doesn't do anything on the server side, however, you may import it.
|
566
|
+
*
|
567
|
+
* The whole point of defining this and exporting it is so that you can import it in isomorphic code without
|
568
|
+
* an error being thrown by the import itself.
|
569
|
+
*/
|
570
|
+
// A real stub, not a "not implemented" one! 😯
|
571
|
+
const hot = undefined;
|
572
|
+
|
573
|
+
/*
|
574
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
575
|
+
* All rights reserved.
|
576
|
+
* SPDX-License-Identifier: MIT
|
577
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
578
|
+
*/
|
579
|
+
/**
|
580
|
+
* Converts an iterable into one that emits the object used by the [`iterator` directive](
|
581
|
+
* https://lwc.dev/guide/html_templates#iterator).
|
582
|
+
*/
|
583
|
+
function* toIteratorDirective(iterable) {
|
584
|
+
if (iterable === undefined || iterable === null)
|
585
|
+
return;
|
586
|
+
if (!iterable[Symbol.iterator]) {
|
587
|
+
throw new Error(
|
588
|
+
// Mimic error message from "[i]terable node" in engine-core's api.ts
|
589
|
+
`Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
|
590
|
+
}
|
591
|
+
const iterator = iterable[Symbol.iterator]();
|
592
|
+
let next = iterator.next();
|
593
|
+
let index = 0;
|
594
|
+
let { value, done: last = false } = next;
|
595
|
+
while (last === false) {
|
596
|
+
// using a look-back approach because we need to know if the element is the last
|
597
|
+
next = iterator.next();
|
598
|
+
last = next.done ?? false;
|
599
|
+
yield {
|
600
|
+
value,
|
601
|
+
index,
|
602
|
+
first: index === 0,
|
603
|
+
last,
|
604
|
+
};
|
605
|
+
index += 1;
|
606
|
+
value = next.value;
|
607
|
+
}
|
608
|
+
}
|
609
|
+
|
610
|
+
/*
|
611
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
612
|
+
* All rights reserved.
|
613
|
+
* SPDX-License-Identifier: MIT
|
614
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
615
|
+
*/
|
616
|
+
/**
|
617
|
+
* Per the HTML spec on restrictions for "raw text elements" like `<style>`:
|
618
|
+
*
|
619
|
+
* > The text in raw text and escapable raw text elements must not contain any occurrences of the string
|
620
|
+
* > "</" (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of
|
621
|
+
* > the element followed by one of:
|
622
|
+
* > - U+0009 CHARACTER TABULATION (tab)
|
623
|
+
* > - U+000A LINE FEED (LF)
|
624
|
+
* > - U+000C FORM FEED (FF)
|
625
|
+
* > - U+000D CARRIAGE RETURN (CR)
|
626
|
+
* > - U+0020 SPACE
|
627
|
+
* > - U+003E GREATER-THAN SIGN (>), or
|
628
|
+
* > - U+002F SOLIDUS (/)
|
629
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
|
630
|
+
*/
|
631
|
+
const INVALID_STYLE_CONTENT = /<\/style[\t\n\f\r >/]/i;
|
632
|
+
/**
|
633
|
+
* The text content inside `<style>` is a special case. It is _only_ rendered by the LWC engine itself; `<style>` tags
|
634
|
+
* are disallowed inside of HTML templates.
|
635
|
+
*
|
636
|
+
* The `<style>` tag is unusual in how it's defined in HTML. Like `<script>`, it is considered a "raw text element,"
|
637
|
+
* which means that it is parsed as raw text, but certain character sequences are disallowed, namely to avoid XSS
|
638
|
+
* attacks like `</style><script>alert("pwned")</script>`.
|
639
|
+
*
|
640
|
+
* This also means that we cannot use "normal" HTML escaping inside `<style>` tags, e.g. we cannot use `<`,
|
641
|
+
* `>`, etc., because these are treated as-is by the HTML parser.
|
642
|
+
*
|
643
|
+
*
|
644
|
+
* @param contents CSS source to validate
|
645
|
+
* @throws Throws if the contents provided are not valid.
|
646
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
|
647
|
+
* @see https://github.com/salesforce/lwc/issues/3439
|
648
|
+
* @example
|
649
|
+
* validateStyleTextContents('div { color: red }') // Ok
|
650
|
+
* validateStyleTextContents('</style><script>alert("pwned")</script>') // Throws
|
651
|
+
*/
|
652
|
+
function validateStyleTextContents(contents) {
|
653
|
+
if (INVALID_STYLE_CONTENT.test(contents)) {
|
654
|
+
throw new Error('CSS contains unsafe characters and cannot be serialized inside a style element');
|
655
|
+
}
|
656
|
+
}
|
657
|
+
|
658
|
+
exports.ClassList = ClassList;
|
291
659
|
exports.LightningElement = LightningElement;
|
660
|
+
exports.SYMBOL__SET_INTERNALS = SYMBOL__SET_INTERNALS;
|
661
|
+
exports.api = api;
|
662
|
+
exports.createContextProvider = createContextProvider;
|
663
|
+
exports.createElement = createElement;
|
292
664
|
exports.fallbackTmpl = fallbackTmpl;
|
665
|
+
exports.freezeTemplate = freezeTemplate;
|
666
|
+
exports.getComponentDef = getComponentDef;
|
667
|
+
exports.hot = hot;
|
668
|
+
exports.isComponentConstructor = isComponentConstructor;
|
669
|
+
exports.mutationTracker = mutationTracker;
|
670
|
+
exports.parseFragment = parseFragment;
|
671
|
+
exports.parseSVGFragment = parseSVGFragment;
|
672
|
+
exports.readonly = readonly;
|
673
|
+
exports.registerComponent = registerComponent;
|
674
|
+
exports.registerDecorators = registerDecorators;
|
675
|
+
exports.registerTemplate = registerTemplate;
|
293
676
|
exports.renderAttrs = renderAttrs;
|
677
|
+
exports.renderComponent = serverSideRenderComponent;
|
678
|
+
exports.renderer = renderer;
|
679
|
+
exports.sanitizeAttribute = sanitizeAttribute;
|
294
680
|
exports.serverSideRenderComponent = serverSideRenderComponent;
|
681
|
+
exports.setFeatureFlag = setFeatureFlag;
|
682
|
+
exports.setFeatureFlagForTest = setFeatureFlagForTest;
|
683
|
+
exports.setHooks = setHooks;
|
684
|
+
exports.swapComponent = swapComponent;
|
685
|
+
exports.swapStyle = swapStyle;
|
686
|
+
exports.swapTemplate = swapTemplate;
|
687
|
+
exports.toIteratorDirective = toIteratorDirective;
|
688
|
+
exports.track = track;
|
689
|
+
exports.unwrap = unwrap;
|
295
690
|
exports.validateStyleTextContents = validateStyleTextContents;
|
296
|
-
|
691
|
+
exports.wire = wire;
|
692
|
+
/** version: 8.3.0 */
|
297
693
|
//# sourceMappingURL=index.cjs.js.map
|