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