@lwc/ssr-runtime 9.0.2 → 9.0.4-alpha.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 +2195 -0
- package/dist/index.js +6 -5
- package/package.json +6 -5
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Salesforce, Inc.
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
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
|
+
/* v8 ignore start */
|
|
15
|
+
// Stubs for all the un-implemented exports from @lwc/engine-server
|
|
16
|
+
function api(..._) {
|
|
17
|
+
throw new Error('@api cannot be used in SSR context.');
|
|
18
|
+
}
|
|
19
|
+
function createElement(..._) {
|
|
20
|
+
throw new Error('createElement cannot be used in SSR context.');
|
|
21
|
+
}
|
|
22
|
+
function freezeTemplate(..._) {
|
|
23
|
+
throw new Error('freezeTemplate cannot be used in SSR context.');
|
|
24
|
+
}
|
|
25
|
+
function getComponentDef(..._) {
|
|
26
|
+
throw new Error('getComponentDef cannot be used in SSR context.');
|
|
27
|
+
}
|
|
28
|
+
function isComponentConstructor(..._) {
|
|
29
|
+
throw new Error('isComponentConstructor cannot be used in SSR context.');
|
|
30
|
+
}
|
|
31
|
+
function parseFragment(..._) {
|
|
32
|
+
throw new Error('parseFragment cannot be used in SSR context.');
|
|
33
|
+
}
|
|
34
|
+
function parseSVGFragment(..._) {
|
|
35
|
+
throw new Error('parseSVGFragment cannot be used in SSR context.');
|
|
36
|
+
}
|
|
37
|
+
function registerComponent(..._) {
|
|
38
|
+
throw new Error('registerComponent cannot be used in SSR context.');
|
|
39
|
+
}
|
|
40
|
+
function registerDecorators(..._) {
|
|
41
|
+
throw new Error('registerDecorators cannot be used in SSR context.');
|
|
42
|
+
}
|
|
43
|
+
function registerTemplate(..._) {
|
|
44
|
+
throw new Error('registerTemplate cannot be used in SSR context.');
|
|
45
|
+
}
|
|
46
|
+
function sanitizeAttribute(..._) {
|
|
47
|
+
throw new Error('sanitizeAttribute cannot be used in SSR context.');
|
|
48
|
+
}
|
|
49
|
+
function swapComponent(..._) {
|
|
50
|
+
throw new Error('swapComponent cannot be used in SSR context.');
|
|
51
|
+
}
|
|
52
|
+
function swapStyle(..._) {
|
|
53
|
+
throw new Error('swapStyle cannot be used in SSR context.');
|
|
54
|
+
}
|
|
55
|
+
function swapTemplate(..._) {
|
|
56
|
+
throw new Error('swapTemplate cannot be used in SSR context.');
|
|
57
|
+
}
|
|
58
|
+
function track(..._) {
|
|
59
|
+
throw new Error('@track cannot be used in SSR context.');
|
|
60
|
+
}
|
|
61
|
+
function unwrap$1(..._) {
|
|
62
|
+
throw new Error('unwrap cannot be used in SSR context.');
|
|
63
|
+
}
|
|
64
|
+
function wire(..._) {
|
|
65
|
+
throw new Error('@wire cannot be used in SSR context.');
|
|
66
|
+
}
|
|
67
|
+
const renderer = {
|
|
68
|
+
isSyntheticShadowDefined: false,
|
|
69
|
+
insert(..._) {
|
|
70
|
+
throw new Error('renderer.insert cannot be used in SSR context.');
|
|
71
|
+
},
|
|
72
|
+
remove(..._) {
|
|
73
|
+
throw new Error('renderer.remove cannot be used in SSR context.');
|
|
74
|
+
},
|
|
75
|
+
cloneNode(..._) {
|
|
76
|
+
throw new Error('renderer.cloneNode cannot be used in SSR context.');
|
|
77
|
+
},
|
|
78
|
+
createFragment(..._) {
|
|
79
|
+
throw new Error('renderer.createFragment cannot be used in SSR context.');
|
|
80
|
+
},
|
|
81
|
+
createElement(..._) {
|
|
82
|
+
throw new Error('renderer.createElement cannot be used in SSR context.');
|
|
83
|
+
},
|
|
84
|
+
createText(..._) {
|
|
85
|
+
throw new Error('renderer.createText cannot be used in SSR context.');
|
|
86
|
+
},
|
|
87
|
+
createComment(..._) {
|
|
88
|
+
throw new Error('renderer.createComment cannot be used in SSR context.');
|
|
89
|
+
},
|
|
90
|
+
createCustomElement(..._) {
|
|
91
|
+
throw new Error('renderer.createCustomElement cannot be used in SSR context.');
|
|
92
|
+
},
|
|
93
|
+
nextSibling(..._) {
|
|
94
|
+
throw new Error('renderer.nextSibling cannot be used in SSR context.');
|
|
95
|
+
},
|
|
96
|
+
previousSibling(..._) {
|
|
97
|
+
throw new Error('renderer.previousSibling cannot be used in SSR context.');
|
|
98
|
+
},
|
|
99
|
+
attachShadow(..._) {
|
|
100
|
+
throw new Error('renderer.attachShadow cannot be used in SSR context.');
|
|
101
|
+
},
|
|
102
|
+
getProperty(..._) {
|
|
103
|
+
throw new Error('renderer.getProperty cannot be used in SSR context.');
|
|
104
|
+
},
|
|
105
|
+
setProperty(..._) {
|
|
106
|
+
throw new Error('renderer.setProperty cannot be used in SSR context.');
|
|
107
|
+
},
|
|
108
|
+
setText(..._) {
|
|
109
|
+
throw new Error('renderer.setText cannot be used in SSR context.');
|
|
110
|
+
},
|
|
111
|
+
getAttribute(..._) {
|
|
112
|
+
throw new Error('renderer.getAttribute cannot be used in SSR context.');
|
|
113
|
+
},
|
|
114
|
+
setAttribute(..._) {
|
|
115
|
+
throw new Error('renderer.setAttribute cannot be used in SSR context.');
|
|
116
|
+
},
|
|
117
|
+
removeAttribute(..._) {
|
|
118
|
+
throw new Error('renderer.removeAttribute cannot be used in SSR context.');
|
|
119
|
+
},
|
|
120
|
+
addEventListener(..._) {
|
|
121
|
+
throw new Error('renderer.addEventListener cannot be used in SSR context.');
|
|
122
|
+
},
|
|
123
|
+
removeEventListener(..._) {
|
|
124
|
+
throw new Error('renderer.removeEventListener cannot be used in SSR context.');
|
|
125
|
+
},
|
|
126
|
+
dispatchEvent(..._) {
|
|
127
|
+
throw new Error('renderer.dispatchEvent cannot be used in SSR context.');
|
|
128
|
+
},
|
|
129
|
+
getClassList(..._) {
|
|
130
|
+
throw new Error('renderer.getClassList cannot be used in SSR context.');
|
|
131
|
+
},
|
|
132
|
+
setCSSStyleProperty(..._) {
|
|
133
|
+
throw new Error('renderer.setCSSStyleProperty cannot be used in SSR context.');
|
|
134
|
+
},
|
|
135
|
+
getBoundingClientRect(..._) {
|
|
136
|
+
throw new Error('renderer.getBoundingClientRect cannot be used in SSR context.');
|
|
137
|
+
},
|
|
138
|
+
querySelector(..._) {
|
|
139
|
+
throw new Error('renderer.querySelector cannot be used in SSR context.');
|
|
140
|
+
},
|
|
141
|
+
querySelectorAll(..._) {
|
|
142
|
+
throw new Error('renderer.querySelectorAll cannot be used in SSR context.');
|
|
143
|
+
},
|
|
144
|
+
getElementsByTagName(..._) {
|
|
145
|
+
throw new Error('renderer.getElementsByTagName cannot be used in SSR context.');
|
|
146
|
+
},
|
|
147
|
+
getElementsByClassName(..._) {
|
|
148
|
+
throw new Error('renderer.getElementsByClassName cannot be used in SSR context.');
|
|
149
|
+
},
|
|
150
|
+
getChildren(..._) {
|
|
151
|
+
throw new Error('renderer.getChildren cannot be used in SSR context.');
|
|
152
|
+
},
|
|
153
|
+
getChildNodes(..._) {
|
|
154
|
+
throw new Error('renderer.getChildNodes cannot be used in SSR context.');
|
|
155
|
+
},
|
|
156
|
+
getFirstChild(..._) {
|
|
157
|
+
throw new Error('renderer.getFirstChild cannot be used in SSR context.');
|
|
158
|
+
},
|
|
159
|
+
getFirstElementChild(..._) {
|
|
160
|
+
throw new Error('renderer.getFirstElementChild cannot be used in SSR context.');
|
|
161
|
+
},
|
|
162
|
+
getLastChild(..._) {
|
|
163
|
+
throw new Error('renderer.getLastChild cannot be used in SSR context.');
|
|
164
|
+
},
|
|
165
|
+
getLastElementChild(..._) {
|
|
166
|
+
throw new Error('renderer.getLastElementChild cannot be used in SSR context.');
|
|
167
|
+
},
|
|
168
|
+
getTagName(..._) {
|
|
169
|
+
throw new Error('renderer.getTagName cannot be used in SSR context.');
|
|
170
|
+
},
|
|
171
|
+
getStyle(..._) {
|
|
172
|
+
throw new Error('renderer.getStyle cannot be used in SSR context.');
|
|
173
|
+
},
|
|
174
|
+
isConnected(..._) {
|
|
175
|
+
throw new Error('renderer.isConnected cannot be used in SSR context.');
|
|
176
|
+
},
|
|
177
|
+
insertStylesheet(..._) {
|
|
178
|
+
throw new Error('renderer.insertStylesheet cannot be used in SSR context.');
|
|
179
|
+
},
|
|
180
|
+
assertInstanceOfHTMLElement(..._) {
|
|
181
|
+
throw new Error('renderer.assertInstanceOfHTMLElement cannot be used in SSR context.');
|
|
182
|
+
},
|
|
183
|
+
ownerDocument(..._) {
|
|
184
|
+
throw new Error('renderer.ownerDocument cannot be used in SSR context.');
|
|
185
|
+
},
|
|
186
|
+
registerContextConsumer(..._) {
|
|
187
|
+
throw new Error('renderer.registerContextConsumer cannot be used in SSR context.');
|
|
188
|
+
},
|
|
189
|
+
attachInternals(..._) {
|
|
190
|
+
throw new Error('renderer.attachInternals cannot be used in SSR context.');
|
|
191
|
+
},
|
|
192
|
+
defineCustomElement(..._) {
|
|
193
|
+
throw new Error('renderer.defineCustomElement cannot be used in SSR context.');
|
|
194
|
+
},
|
|
195
|
+
getParentNode(..._) {
|
|
196
|
+
throw new Error('renderer.getParentNode cannot be used in SSR context.');
|
|
197
|
+
},
|
|
198
|
+
startTrackingMutations(..._) {
|
|
199
|
+
throw new Error('renderer.startTrackingMutations cannot be used in SSR context.');
|
|
200
|
+
},
|
|
201
|
+
stopTrackingMutations(..._) {
|
|
202
|
+
throw new Error('renderer.stopTrackingMutations cannot be used in SSR context.');
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* The hot API is used to orchestrate hot swapping in client rendered components.
|
|
207
|
+
* It doesn't do anything on the server side, however, you may import it.
|
|
208
|
+
*
|
|
209
|
+
* The whole point of defining this and exporting it is so that you can import it in isomorphic code without
|
|
210
|
+
* an error being thrown by the import itself.
|
|
211
|
+
*/
|
|
212
|
+
// A real stub, not a "not implemented" one! 😯
|
|
213
|
+
const hot = undefined;
|
|
214
|
+
/* v8 ignore stop */
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Copyright (c) 2026 Salesforce, Inc.
|
|
218
|
+
*/
|
|
219
|
+
/*
|
|
220
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
221
|
+
* All rights reserved.
|
|
222
|
+
* SPDX-License-Identifier: MIT
|
|
223
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
224
|
+
*/
|
|
225
|
+
/**
|
|
226
|
+
*
|
|
227
|
+
* @param value
|
|
228
|
+
* @param msg
|
|
229
|
+
*/
|
|
230
|
+
/**
|
|
231
|
+
*
|
|
232
|
+
* @param value
|
|
233
|
+
* @param msg
|
|
234
|
+
*/
|
|
235
|
+
function isFalse$1(value, msg) {
|
|
236
|
+
if (value) {
|
|
237
|
+
throw new Error(`Assert Violation: ${msg}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/*
|
|
242
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
243
|
+
* All rights reserved.
|
|
244
|
+
* SPDX-License-Identifier: MIT
|
|
245
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
246
|
+
*/
|
|
247
|
+
const {
|
|
248
|
+
/** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */
|
|
249
|
+
assign,
|
|
250
|
+
/** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */
|
|
251
|
+
create,
|
|
252
|
+
/** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */
|
|
253
|
+
defineProperties,
|
|
254
|
+
/** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */
|
|
255
|
+
defineProperty,
|
|
256
|
+
/** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
|
|
257
|
+
entries,
|
|
258
|
+
/** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
|
|
259
|
+
getOwnPropertyNames: getOwnPropertyNames$1,
|
|
260
|
+
/** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
|
|
261
|
+
hasOwnProperty: hasOwnProperty$1,
|
|
262
|
+
/** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
|
|
263
|
+
keys} = Object;
|
|
264
|
+
const {
|
|
265
|
+
/** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
|
|
266
|
+
isArray: isArray$1} = Array;
|
|
267
|
+
// For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
|
|
268
|
+
// though it works fine for one, e.g. isArray), so comments for these are added to the export
|
|
269
|
+
// statement, rather than this declaration.
|
|
270
|
+
const { filter: ArrayFilter, join: ArrayJoin, map: ArrayMap, forEach, // Weird anomaly!
|
|
271
|
+
} = Array.prototype;
|
|
272
|
+
/** Detached {@linkcode String.fromCharCode}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode MDN Reference}. */
|
|
273
|
+
const { fromCharCode: StringFromCharCode } = String;
|
|
274
|
+
// No JSDocs here - see comment for Array.prototype
|
|
275
|
+
const { charCodeAt: StringCharCodeAt, replace: StringReplace, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
|
|
276
|
+
/**
|
|
277
|
+
* Determines whether the argument is `undefined`.
|
|
278
|
+
* @param obj Value to test
|
|
279
|
+
* @returns `true` if the value is `undefined`.
|
|
280
|
+
*/
|
|
281
|
+
function isUndefined$1(obj) {
|
|
282
|
+
return obj === undefined;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Determines whether the argument is `null`.
|
|
286
|
+
* @param obj Value to test
|
|
287
|
+
* @returns `true` if the value is `null`.
|
|
288
|
+
*/
|
|
289
|
+
function isNull(obj) {
|
|
290
|
+
return obj === null;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Determines whether the argument is a boolean.
|
|
294
|
+
* @param obj Value to test
|
|
295
|
+
* @returns `true` if the value is a boolean.
|
|
296
|
+
*/
|
|
297
|
+
function isBoolean(obj) {
|
|
298
|
+
return typeof obj === 'boolean';
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Determines whether the argument is an object or null.
|
|
302
|
+
* @param obj Value to test
|
|
303
|
+
* @returns `true` if the value is an object or null.
|
|
304
|
+
*/
|
|
305
|
+
function isObject(obj) {
|
|
306
|
+
return typeof obj === 'object';
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Determines whether the argument is a string.
|
|
310
|
+
* @param obj Value to test
|
|
311
|
+
* @returns `true` if the value is a string.
|
|
312
|
+
*/
|
|
313
|
+
function isString(obj) {
|
|
314
|
+
return typeof obj === 'string';
|
|
315
|
+
}
|
|
316
|
+
const OtS = {}.toString;
|
|
317
|
+
/**
|
|
318
|
+
* Converts the argument to a string, safely accounting for objects with "null" prototype.
|
|
319
|
+
* Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
|
|
320
|
+
* @param obj Value to convert to a string.
|
|
321
|
+
* @returns String representation of the value.
|
|
322
|
+
*/
|
|
323
|
+
function toString(obj) {
|
|
324
|
+
if (obj?.toString) {
|
|
325
|
+
// Arrays might hold objects with "null" prototype So using
|
|
326
|
+
// Array.prototype.toString directly will cause an error Iterate through
|
|
327
|
+
// all the items and handle individually.
|
|
328
|
+
if (isArray$1(obj)) {
|
|
329
|
+
// This behavior is slightly different from Array#toString:
|
|
330
|
+
// 1. Array#toString calls `this.join`, rather than Array#join
|
|
331
|
+
// Ex: arr = []; arr.join = () => 1; arr.toString() === 1; toString(arr) === ''
|
|
332
|
+
// 2. Array#toString delegates to Object#toString if `this.join` is not a function
|
|
333
|
+
// Ex: arr = []; arr.join = 'no'; arr.toString() === '[object Array]; toString(arr) = ''
|
|
334
|
+
// 3. Array#toString converts null/undefined to ''
|
|
335
|
+
// Ex: arr = [null, undefined]; arr.toString() === ','; toString(arr) === '[object Null],undefined'
|
|
336
|
+
// 4. Array#toString converts recursive references to arrays to ''
|
|
337
|
+
// Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
|
|
338
|
+
// Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
|
|
339
|
+
return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
|
|
340
|
+
}
|
|
341
|
+
return obj.toString();
|
|
342
|
+
}
|
|
343
|
+
else if (typeof obj === 'object') {
|
|
344
|
+
// This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
|
|
345
|
+
return OtS.call(obj);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
return String(obj);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/*
|
|
353
|
+
* Copyright (c) 2018, salesforce.com, 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
|
+
/**
|
|
359
|
+
* According to the following list, there are 48 aria attributes of which two (ariaDropEffect and
|
|
360
|
+
* ariaGrabbed) are deprecated:
|
|
361
|
+
* https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes
|
|
362
|
+
*
|
|
363
|
+
* The above list of 46 aria attributes is consistent with the following resources:
|
|
364
|
+
* https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
|
|
365
|
+
* https://wicg.github.io/aom/spec/aria-reflection.html
|
|
366
|
+
*
|
|
367
|
+
* NOTE: If you update this list, please update test files that implicitly reference this list!
|
|
368
|
+
* Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages.
|
|
369
|
+
*/
|
|
370
|
+
const AriaPropertyNames = [
|
|
371
|
+
'ariaActiveDescendant',
|
|
372
|
+
'ariaAtomic',
|
|
373
|
+
'ariaAutoComplete',
|
|
374
|
+
'ariaBusy',
|
|
375
|
+
'ariaChecked',
|
|
376
|
+
'ariaColCount',
|
|
377
|
+
'ariaColIndex',
|
|
378
|
+
'ariaColIndexText',
|
|
379
|
+
'ariaColSpan',
|
|
380
|
+
'ariaControls',
|
|
381
|
+
'ariaCurrent',
|
|
382
|
+
'ariaDescribedBy',
|
|
383
|
+
'ariaDescription',
|
|
384
|
+
'ariaDetails',
|
|
385
|
+
'ariaDisabled',
|
|
386
|
+
'ariaErrorMessage',
|
|
387
|
+
'ariaExpanded',
|
|
388
|
+
'ariaFlowTo',
|
|
389
|
+
'ariaHasPopup',
|
|
390
|
+
'ariaHidden',
|
|
391
|
+
'ariaInvalid',
|
|
392
|
+
'ariaKeyShortcuts',
|
|
393
|
+
'ariaLabel',
|
|
394
|
+
'ariaLabelledBy',
|
|
395
|
+
'ariaLevel',
|
|
396
|
+
'ariaLive',
|
|
397
|
+
'ariaModal',
|
|
398
|
+
'ariaMultiLine',
|
|
399
|
+
'ariaMultiSelectable',
|
|
400
|
+
'ariaOrientation',
|
|
401
|
+
'ariaOwns',
|
|
402
|
+
'ariaPlaceholder',
|
|
403
|
+
'ariaPosInSet',
|
|
404
|
+
'ariaPressed',
|
|
405
|
+
'ariaReadOnly',
|
|
406
|
+
'ariaRelevant',
|
|
407
|
+
'ariaRequired',
|
|
408
|
+
'ariaRoleDescription',
|
|
409
|
+
'ariaRowCount',
|
|
410
|
+
'ariaRowIndex',
|
|
411
|
+
'ariaRowIndexText',
|
|
412
|
+
'ariaRowSpan',
|
|
413
|
+
'ariaSelected',
|
|
414
|
+
'ariaSetSize',
|
|
415
|
+
'ariaSort',
|
|
416
|
+
'ariaValueMax',
|
|
417
|
+
'ariaValueMin',
|
|
418
|
+
'ariaValueNow',
|
|
419
|
+
'ariaValueText',
|
|
420
|
+
'ariaBrailleLabel',
|
|
421
|
+
'ariaBrailleRoleDescription',
|
|
422
|
+
'role',
|
|
423
|
+
];
|
|
424
|
+
const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (() => {
|
|
425
|
+
const AriaAttrNameToPropNameMap = create(null);
|
|
426
|
+
const AriaPropNameToAttrNameMap = create(null);
|
|
427
|
+
// Synthetic creation of all AOM property descriptors for Custom Elements
|
|
428
|
+
forEach.call(AriaPropertyNames, (propName) => {
|
|
429
|
+
const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
|
|
430
|
+
// These type assertions are because the map types are a 1:1 mapping of ariaX to aria-x.
|
|
431
|
+
// TypeScript knows we have one of ariaX | ariaY and one of aria-x | aria-y, and tries to
|
|
432
|
+
// prevent us from doing ariaX: aria-y, but we that it's safe.
|
|
433
|
+
AriaAttrNameToPropNameMap[attrName] = propName;
|
|
434
|
+
AriaPropNameToAttrNameMap[propName] = attrName;
|
|
435
|
+
});
|
|
436
|
+
return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
|
|
437
|
+
})();
|
|
438
|
+
/**
|
|
439
|
+
*
|
|
440
|
+
* @param attrName
|
|
441
|
+
*/
|
|
442
|
+
function isAriaAttribute(attrName) {
|
|
443
|
+
return attrName in AriaAttrNameToPropNameMap;
|
|
444
|
+
}
|
|
445
|
+
let trustedContext;
|
|
446
|
+
let contextKeys;
|
|
447
|
+
function setContextKeys(config) {
|
|
448
|
+
isFalse$1(contextKeys, '`setContextKeys` cannot be called more than once');
|
|
449
|
+
contextKeys = config;
|
|
450
|
+
}
|
|
451
|
+
function getContextKeys() {
|
|
452
|
+
return contextKeys;
|
|
453
|
+
}
|
|
454
|
+
function setTrustedContextSet(context) {
|
|
455
|
+
isFalse$1(trustedContext, 'Trusted Context Set is already set!');
|
|
456
|
+
trustedContext = context;
|
|
457
|
+
}
|
|
458
|
+
function addTrustedContext(contextParticipant) {
|
|
459
|
+
// This should be a no-op when the trustedSignals set isn't set by runtime
|
|
460
|
+
trustedContext?.add(contextParticipant);
|
|
461
|
+
}
|
|
462
|
+
function isTrustedContext(target) {
|
|
463
|
+
if (!trustedContext) {
|
|
464
|
+
// The runtime didn't set a trustedContext set
|
|
465
|
+
// this check should only be performed for runtimes that care about filtering context participants to track
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
return trustedContext.has(target);
|
|
469
|
+
}
|
|
470
|
+
// These are HTML standard prop/attribute IDL mappings, but are not predictable based on camel/kebab-case conversion
|
|
471
|
+
const SPECIAL_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map([
|
|
472
|
+
['accessKey', 'accesskey'],
|
|
473
|
+
['readOnly', 'readonly'],
|
|
474
|
+
['tabIndex', 'tabindex'],
|
|
475
|
+
['bgColor', 'bgcolor'],
|
|
476
|
+
['colSpan', 'colspan'],
|
|
477
|
+
['rowSpan', 'rowspan'],
|
|
478
|
+
['contentEditable', 'contenteditable'],
|
|
479
|
+
['crossOrigin', 'crossorigin'],
|
|
480
|
+
['dateTime', 'datetime'],
|
|
481
|
+
['formAction', 'formaction'],
|
|
482
|
+
['isMap', 'ismap'],
|
|
483
|
+
['maxLength', 'maxlength'],
|
|
484
|
+
['minLength', 'minlength'],
|
|
485
|
+
['noValidate', 'novalidate'],
|
|
486
|
+
['useMap', 'usemap'],
|
|
487
|
+
['htmlFor', 'for'],
|
|
488
|
+
]);
|
|
489
|
+
// Global properties that this framework currently reflects. For CSR, the native
|
|
490
|
+
// descriptors for these properties are added from HTMLElement.prototype to
|
|
491
|
+
// LightningElement.prototype. For SSR, in order to match CSR behavior, this
|
|
492
|
+
// list is used to determine which attributes to reflect.
|
|
493
|
+
const REFLECTIVE_GLOBAL_PROPERTY_SET = /*@__PURE__@*/ new Set([
|
|
494
|
+
'accessKey',
|
|
495
|
+
'dir',
|
|
496
|
+
'draggable',
|
|
497
|
+
'hidden',
|
|
498
|
+
'id',
|
|
499
|
+
'lang',
|
|
500
|
+
'spellcheck',
|
|
501
|
+
'tabIndex',
|
|
502
|
+
'title',
|
|
503
|
+
]);
|
|
504
|
+
/**
|
|
505
|
+
* Map associating previously transformed HTML property into HTML attribute.
|
|
506
|
+
*/
|
|
507
|
+
const CACHED_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map();
|
|
508
|
+
/**
|
|
509
|
+
*
|
|
510
|
+
* @param propName
|
|
511
|
+
*/
|
|
512
|
+
function htmlPropertyToAttribute(propName) {
|
|
513
|
+
const ariaAttributeName = AriaPropNameToAttrNameMap[propName];
|
|
514
|
+
if (!isUndefined$1(ariaAttributeName)) {
|
|
515
|
+
return ariaAttributeName;
|
|
516
|
+
}
|
|
517
|
+
const specialAttributeName = SPECIAL_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
|
518
|
+
if (!isUndefined$1(specialAttributeName)) {
|
|
519
|
+
return specialAttributeName;
|
|
520
|
+
}
|
|
521
|
+
const cachedAttributeName = CACHED_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
|
522
|
+
if (!isUndefined$1(cachedAttributeName)) {
|
|
523
|
+
return cachedAttributeName;
|
|
524
|
+
}
|
|
525
|
+
let attributeName = '';
|
|
526
|
+
for (let i = 0, len = propName.length; i < len; i++) {
|
|
527
|
+
const code = StringCharCodeAt.call(propName, i);
|
|
528
|
+
if (code >= 65 && // "A"
|
|
529
|
+
code <= 90 // "Z"
|
|
530
|
+
) {
|
|
531
|
+
attributeName += '-' + StringFromCharCode(code + 32);
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
attributeName += StringFromCharCode(code);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
538
|
+
return attributeName;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/*
|
|
542
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
543
|
+
* All rights reserved.
|
|
544
|
+
* SPDX-License-Identifier: MIT
|
|
545
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
546
|
+
*/
|
|
547
|
+
const ESCAPED_CHARS = {
|
|
548
|
+
'"': '"',
|
|
549
|
+
"'": ''',
|
|
550
|
+
'<': '<',
|
|
551
|
+
'>': '>',
|
|
552
|
+
'&': '&',
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
*
|
|
556
|
+
* @param str
|
|
557
|
+
* @param attrMode
|
|
558
|
+
*/
|
|
559
|
+
function htmlEscape(str, attrMode = false) {
|
|
560
|
+
const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
|
|
561
|
+
return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/*
|
|
565
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
566
|
+
* All rights reserved.
|
|
567
|
+
* SPDX-License-Identifier: MIT
|
|
568
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
569
|
+
*/
|
|
570
|
+
/**
|
|
571
|
+
* [ncls] - Normalize class name attribute.
|
|
572
|
+
*
|
|
573
|
+
* Transforms the provided class property value from an object/string into a string the diffing algo
|
|
574
|
+
* can operate on.
|
|
575
|
+
*
|
|
576
|
+
* This implementation is borrowed from Vue:
|
|
577
|
+
* https://github.com/vuejs/core/blob/e790e1bdd7df7be39e14780529db86e4da47a3db/packages/shared/src/normalizeProp.ts#L63-L82
|
|
578
|
+
*/
|
|
579
|
+
function normalizeClass(value) {
|
|
580
|
+
if (isUndefined$1(value) || isNull(value)) {
|
|
581
|
+
// Returning undefined here improves initial render cost, because the old vnode's class will be considered
|
|
582
|
+
// undefined in the `patchClassAttribute` routine, so `oldClass === newClass` will be true so we return early
|
|
583
|
+
return undefined;
|
|
584
|
+
}
|
|
585
|
+
let res = '';
|
|
586
|
+
if (isString(value)) {
|
|
587
|
+
res = value;
|
|
588
|
+
}
|
|
589
|
+
else if (isArray$1(value)) {
|
|
590
|
+
for (let i = 0; i < value.length; i++) {
|
|
591
|
+
const normalized = normalizeClass(value[i]);
|
|
592
|
+
if (normalized) {
|
|
593
|
+
res += normalized + ' ';
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
else if (isObject(value) && !isNull(value)) {
|
|
598
|
+
// Iterate own enumerable keys of the object
|
|
599
|
+
const _keys = keys(value);
|
|
600
|
+
for (let i = 0; i < _keys.length; i += 1) {
|
|
601
|
+
const key = _keys[i];
|
|
602
|
+
if (value[key]) {
|
|
603
|
+
res += key + ' ';
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return StringTrim.call(res);
|
|
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
|
+
let hooksAreSet = false;
|
|
617
|
+
let sanitizeHtmlContentImpl = () => {
|
|
618
|
+
// locker-service patches this function during runtime to sanitize HTML content.
|
|
619
|
+
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
623
|
+
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
|
624
|
+
* lwc:inner-html directive.
|
|
625
|
+
* It is meant to be overridden via `setHooks`; it throws an error by default.
|
|
626
|
+
*/
|
|
627
|
+
const sanitizeHtmlContent = (value) => {
|
|
628
|
+
return sanitizeHtmlContentImpl(value);
|
|
629
|
+
};
|
|
630
|
+
function setHooks(hooks) {
|
|
631
|
+
isFalse$1(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
|
|
632
|
+
hooksAreSet = true;
|
|
633
|
+
sanitizeHtmlContentImpl = hooks.sanitizeHtmlContent;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/*
|
|
637
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
638
|
+
* All rights reserved.
|
|
639
|
+
* SPDX-License-Identifier: MIT
|
|
640
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
641
|
+
*/
|
|
642
|
+
let trustedSignals;
|
|
643
|
+
function setTrustedSignalSet(signals) {
|
|
644
|
+
isFalse$1(trustedSignals, 'Trusted Signal Set is already set!');
|
|
645
|
+
trustedSignals = signals;
|
|
646
|
+
// Only used in LWC's integration tests. Contained within the set function as there are multiple imports of
|
|
647
|
+
// this module. Placing it here ensures we reference the import where the trustedSignals set is maintained
|
|
648
|
+
if (process.env.NODE_ENV === 'test-lwc-integration') {
|
|
649
|
+
// Used to reset the global state between test runs
|
|
650
|
+
globalThis.__lwcResetTrustedSignals = () => (trustedSignals = undefined);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function isTrustedSignal(target) {
|
|
654
|
+
if (!trustedSignals) {
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
return trustedSignals.has(target);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/*
|
|
661
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
662
|
+
* All rights reserved.
|
|
663
|
+
* SPDX-License-Identifier: MIT
|
|
664
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
665
|
+
*/
|
|
666
|
+
const DEFAULT_SSR_MODE = 'sync';
|
|
667
|
+
|
|
668
|
+
/*
|
|
669
|
+
* Copyright (c) 2025, salesforce.com, inc.
|
|
670
|
+
* All rights reserved.
|
|
671
|
+
* SPDX-License-Identifier: MIT
|
|
672
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
673
|
+
*/
|
|
674
|
+
/**
|
|
675
|
+
* Global HTML "tabindex" attribute is specially massaged into a stringified number
|
|
676
|
+
* This follows the historical behavior in api.ts:
|
|
677
|
+
* https://github.com/salesforce/lwc/blob/f34a347/packages/%40lwc/engine-core/src/framework/api.ts#L193-L211
|
|
678
|
+
*/
|
|
679
|
+
function normalizeTabIndex(value) {
|
|
680
|
+
const shouldNormalize = value > 0 && typeof value !== 'boolean';
|
|
681
|
+
return shouldNormalize ? 0 : value;
|
|
682
|
+
}
|
|
683
|
+
/** version: 9.0.4-alpha.0 */
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Copyright (c) 2026 Salesforce, Inc.
|
|
687
|
+
*/
|
|
688
|
+
/**
|
|
689
|
+
* Copyright (c) 2026 Salesforce, Inc.
|
|
690
|
+
*/
|
|
691
|
+
/*
|
|
692
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
693
|
+
* All rights reserved.
|
|
694
|
+
* SPDX-License-Identifier: MIT
|
|
695
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
696
|
+
*/
|
|
697
|
+
/**
|
|
698
|
+
*
|
|
699
|
+
* @param value
|
|
700
|
+
* @param msg
|
|
701
|
+
*/
|
|
702
|
+
/**
|
|
703
|
+
*
|
|
704
|
+
* @param value
|
|
705
|
+
* @param msg
|
|
706
|
+
*/
|
|
707
|
+
/** version: 9.0.4-alpha.0 */
|
|
708
|
+
|
|
709
|
+
/*
|
|
710
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
711
|
+
* All rights reserved.
|
|
712
|
+
* SPDX-License-Identifier: MIT
|
|
713
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
714
|
+
*/
|
|
715
|
+
class SignalBaseClass {
|
|
716
|
+
constructor() {
|
|
717
|
+
this.subscribers = new Set();
|
|
718
|
+
}
|
|
719
|
+
subscribe(onUpdate) {
|
|
720
|
+
this.subscribers.add(onUpdate);
|
|
721
|
+
return () => {
|
|
722
|
+
this.subscribers.delete(onUpdate);
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
notify() {
|
|
726
|
+
for (const subscriber of this.subscribers) {
|
|
727
|
+
subscriber();
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
/** version: 9.0.4-alpha.0 */
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Copyright (c) 2026 Salesforce, Inc.
|
|
735
|
+
*/
|
|
736
|
+
|
|
737
|
+
/*
|
|
738
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
739
|
+
* All rights reserved.
|
|
740
|
+
* SPDX-License-Identifier: MIT
|
|
741
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
742
|
+
*/
|
|
743
|
+
// When deprecating a feature flag, ensure that it is also no longer set in the application. For
|
|
744
|
+
// example, in core, the flag should be removed from LwcPermAndPrefUtilImpl.java
|
|
745
|
+
/** List of all feature flags available, with the default value `null`. */
|
|
746
|
+
const features = {
|
|
747
|
+
PLACEHOLDER_TEST_FLAG: null,
|
|
748
|
+
DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
|
|
749
|
+
ENABLE_WIRE_SYNC_EMIT: null,
|
|
750
|
+
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
751
|
+
ENABLE_FROZEN_TEMPLATE: null,
|
|
752
|
+
ENABLE_LEGACY_SCOPE_TOKENS: null,
|
|
753
|
+
ENABLE_FORCE_SHADOW_MIGRATE_MODE: null,
|
|
754
|
+
ENABLE_EXPERIMENTAL_SIGNALS: null,
|
|
755
|
+
ENABLE_LEGACY_SIGNAL_CONTEXT_VALIDATION: null,
|
|
756
|
+
DISABLE_SYNTHETIC_SHADOW: null,
|
|
757
|
+
DISABLE_SCOPE_TOKEN_VALIDATION: null,
|
|
758
|
+
LEGACY_LOCKER_ENABLED: null,
|
|
759
|
+
DISABLE_LEGACY_VALIDATION: null,
|
|
760
|
+
DISABLE_DETACHED_REHYDRATION: null,
|
|
761
|
+
ENABLE_LEGACY_CONTEXT_CONNECTION: null,
|
|
762
|
+
};
|
|
763
|
+
if (!globalThis.lwcRuntimeFlags) {
|
|
764
|
+
Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
765
|
+
}
|
|
766
|
+
/** Feature flags that have been set. */
|
|
767
|
+
const flags = globalThis.lwcRuntimeFlags;
|
|
768
|
+
/**
|
|
769
|
+
* Set the value at runtime of a given feature flag. This method only be invoked once per feature
|
|
770
|
+
* flag. It is meant to be used during the app initialization.
|
|
771
|
+
* @param name Name of the feature flag to set
|
|
772
|
+
* @param value Whether the feature flag should be enabled
|
|
773
|
+
* @throws Will throw if a non-boolean value is provided when running in production.
|
|
774
|
+
* @example setFeatureFlag("DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE", true)
|
|
775
|
+
*/
|
|
776
|
+
function setFeatureFlag(name, value) {
|
|
777
|
+
if (!isBoolean(value)) {
|
|
778
|
+
const message = `Failed to set the value "${value}" for the runtime feature flag "${name}". Runtime feature flags can only be set to a boolean value.`;
|
|
779
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
780
|
+
throw new TypeError(message);
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
// eslint-disable-next-line no-console
|
|
784
|
+
console.error(message);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (isUndefined$1(features[name])) {
|
|
789
|
+
// eslint-disable-next-line no-console
|
|
790
|
+
console.info(`Attempt to set a value on an unknown feature flag "${name}" resulted in a NOOP.`);
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
// This may seem redundant, but `process.env.NODE_ENV === 'test-lwc-integration'` is replaced by integration tests
|
|
794
|
+
if (process.env.NODE_ENV === 'test-lwc-integration' || process.env.NODE_ENV !== 'production') {
|
|
795
|
+
// Allow the same flag to be set more than once outside of production to enable testing
|
|
796
|
+
flags[name] = value;
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
// Disallow the same flag to be set more than once in production
|
|
800
|
+
const runtimeValue = flags[name];
|
|
801
|
+
if (!isUndefined$1(runtimeValue)) {
|
|
802
|
+
// eslint-disable-next-line no-console
|
|
803
|
+
console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
defineProperty(flags, name, { value });
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Set the value at runtime of a given feature flag. This method should only be used for testing
|
|
811
|
+
* purposes. It is a no-op when invoked in production mode.
|
|
812
|
+
* @param name Name of the feature flag to enable or disable
|
|
813
|
+
* @param value Whether the feature flag should be enabled
|
|
814
|
+
* @example setFeatureFlag("DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE", true)
|
|
815
|
+
*/
|
|
816
|
+
function setFeatureFlagForTest(name, value) {
|
|
817
|
+
// This may seem redundant, but `process.env.NODE_ENV === 'test-lwc-integration'` is replaced by Karma tests
|
|
818
|
+
if (process.env.NODE_ENV === 'test-lwc-integration' || process.env.NODE_ENV !== 'production') {
|
|
819
|
+
setFeatureFlag(name, value);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
/** version: 9.0.4-alpha.0 */
|
|
823
|
+
|
|
824
|
+
/*
|
|
825
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
826
|
+
* All rights reserved.
|
|
827
|
+
* SPDX-License-Identifier: MIT
|
|
828
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
829
|
+
*/
|
|
830
|
+
const MULTI_SPACE = /\s+/g;
|
|
831
|
+
function parseClassName(className) {
|
|
832
|
+
return (className ?? '')
|
|
833
|
+
.split(MULTI_SPACE)
|
|
834
|
+
.map((item) => item.trim())
|
|
835
|
+
.filter(Boolean);
|
|
836
|
+
}
|
|
837
|
+
class ClassList {
|
|
838
|
+
constructor(el) {
|
|
839
|
+
this.el = el;
|
|
840
|
+
}
|
|
841
|
+
add(...newClassNames) {
|
|
842
|
+
const set = new Set(parseClassName(this.el.className));
|
|
843
|
+
for (const newClassName of newClassNames) {
|
|
844
|
+
set.add(newClassName);
|
|
845
|
+
}
|
|
846
|
+
this.el.className = Array.from(set).join(' ');
|
|
847
|
+
}
|
|
848
|
+
contains(className) {
|
|
849
|
+
return parseClassName(this.el.className).includes(className);
|
|
850
|
+
}
|
|
851
|
+
remove(...classNamesToRemove) {
|
|
852
|
+
const set = new Set(parseClassName(this.el.className));
|
|
853
|
+
for (const newClassName of classNamesToRemove) {
|
|
854
|
+
set.delete(newClassName);
|
|
855
|
+
}
|
|
856
|
+
this.el.className = Array.from(set).join(' ');
|
|
857
|
+
}
|
|
858
|
+
replace(oldClassName, newClassName) {
|
|
859
|
+
let classWasReplaced = false;
|
|
860
|
+
const listOfClasses = parseClassName(this.el.className);
|
|
861
|
+
listOfClasses.forEach((value, idx) => {
|
|
862
|
+
if (value === oldClassName) {
|
|
863
|
+
classWasReplaced = true;
|
|
864
|
+
listOfClasses[idx] = newClassName;
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
this.el.className = listOfClasses.join(' ');
|
|
868
|
+
return classWasReplaced;
|
|
869
|
+
}
|
|
870
|
+
toggle(classNameToToggle, force) {
|
|
871
|
+
const set = new Set(parseClassName(this.el.className));
|
|
872
|
+
if (!set.has(classNameToToggle) && force !== false) {
|
|
873
|
+
set.add(classNameToToggle);
|
|
874
|
+
}
|
|
875
|
+
else if (set.has(classNameToToggle) && force !== true) {
|
|
876
|
+
set.delete(classNameToToggle);
|
|
877
|
+
}
|
|
878
|
+
this.el.className = Array.from(set).join(' ');
|
|
879
|
+
return set.has(classNameToToggle);
|
|
880
|
+
}
|
|
881
|
+
get value() {
|
|
882
|
+
return this.el.className;
|
|
883
|
+
}
|
|
884
|
+
toString() {
|
|
885
|
+
return this.el.className;
|
|
886
|
+
}
|
|
887
|
+
get length() {
|
|
888
|
+
return parseClassName(this.el.className).length;
|
|
889
|
+
}
|
|
890
|
+
item(index) {
|
|
891
|
+
return parseClassName(this.el.className ?? '')[index] ?? null;
|
|
892
|
+
}
|
|
893
|
+
forEach(callbackFn, thisArg) {
|
|
894
|
+
parseClassName(this.el.className).forEach((value, index) => callbackFn.call(thisArg, value, index, this));
|
|
895
|
+
}
|
|
896
|
+
// This method is present on DOMTokenList but throws an error in the browser when used
|
|
897
|
+
// in connection with Element#classList.
|
|
898
|
+
supports(_token) {
|
|
899
|
+
throw new TypeError('DOMTokenList has no supported tokens.');
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/******************************************************************************
|
|
904
|
+
Copyright (c) Microsoft Corporation.
|
|
905
|
+
|
|
906
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
907
|
+
purpose with or without fee is hereby granted.
|
|
908
|
+
|
|
909
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
910
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
911
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
912
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
913
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
914
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
915
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
916
|
+
***************************************************************************** */
|
|
917
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
921
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
922
|
+
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");
|
|
923
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
927
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
928
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
929
|
+
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");
|
|
930
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
934
|
+
var e = new Error(message);
|
|
935
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
/*
|
|
939
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
940
|
+
* All rights reserved.
|
|
941
|
+
* SPDX-License-Identifier: MIT
|
|
942
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
943
|
+
*/
|
|
944
|
+
var _MutationTracker_enabledSet, _MutationTracker_mutationMap;
|
|
945
|
+
class MutationTracker {
|
|
946
|
+
constructor() {
|
|
947
|
+
_MutationTracker_enabledSet.set(this, new WeakSet());
|
|
948
|
+
_MutationTracker_mutationMap.set(this, new WeakMap());
|
|
949
|
+
}
|
|
950
|
+
add(instance, attrName) {
|
|
951
|
+
if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
|
|
952
|
+
let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
|
953
|
+
if (!mutatedAttrs) {
|
|
954
|
+
mutatedAttrs = new Set();
|
|
955
|
+
__classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
|
|
956
|
+
}
|
|
957
|
+
mutatedAttrs.add(attrName.toLowerCase());
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
enable(instance) {
|
|
961
|
+
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
|
|
962
|
+
}
|
|
963
|
+
disable(instance) {
|
|
964
|
+
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
|
|
965
|
+
}
|
|
966
|
+
renderMutatedAttrs(instance) {
|
|
967
|
+
const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
|
968
|
+
if (mutatedAttrs) {
|
|
969
|
+
return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
return '';
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
_MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
|
|
977
|
+
const mutationTracker = new MutationTracker();
|
|
978
|
+
|
|
979
|
+
/*
|
|
980
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
981
|
+
* All rights reserved.
|
|
982
|
+
* SPDX-License-Identifier: MIT
|
|
983
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
984
|
+
*/
|
|
985
|
+
/**
|
|
986
|
+
* Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
|
|
987
|
+
*/
|
|
988
|
+
const stringDescriptor = (attrName) => ({
|
|
989
|
+
configurable: true,
|
|
990
|
+
enumerable: true,
|
|
991
|
+
get() {
|
|
992
|
+
return this.getAttribute(attrName);
|
|
993
|
+
},
|
|
994
|
+
set(newValue) {
|
|
995
|
+
const currentValue = this.getAttribute(attrName);
|
|
996
|
+
const normalizedValue = String(newValue);
|
|
997
|
+
if (normalizedValue !== currentValue) {
|
|
998
|
+
this.setAttribute(attrName, normalizedValue);
|
|
999
|
+
}
|
|
1000
|
+
},
|
|
1001
|
+
});
|
|
1002
|
+
/** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
|
|
1003
|
+
const explicitBooleanDescriptor = (attrName, defaultValue) => ({
|
|
1004
|
+
configurable: true,
|
|
1005
|
+
enumerable: true,
|
|
1006
|
+
get() {
|
|
1007
|
+
const value = this.getAttribute(attrName);
|
|
1008
|
+
if (value === null)
|
|
1009
|
+
return defaultValue;
|
|
1010
|
+
// spellcheck=false => false, everything else => true
|
|
1011
|
+
// draggable=true => true, everything else => false
|
|
1012
|
+
return value.toLowerCase() === String(defaultValue) ? defaultValue : !defaultValue;
|
|
1013
|
+
},
|
|
1014
|
+
set(newValue) {
|
|
1015
|
+
const currentValue = this.getAttribute(attrName);
|
|
1016
|
+
const normalizedValue = String(Boolean(newValue));
|
|
1017
|
+
if (normalizedValue !== currentValue) {
|
|
1018
|
+
this.setAttribute(attrName, normalizedValue);
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
});
|
|
1022
|
+
/**
|
|
1023
|
+
* Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
|
|
1024
|
+
*/
|
|
1025
|
+
const booleanAttributeDescriptor = (attrName) => ({
|
|
1026
|
+
configurable: true,
|
|
1027
|
+
enumerable: true,
|
|
1028
|
+
get() {
|
|
1029
|
+
return this.hasAttribute(attrName);
|
|
1030
|
+
},
|
|
1031
|
+
set(newValue) {
|
|
1032
|
+
const hasAttribute = this.hasAttribute(attrName);
|
|
1033
|
+
if (newValue) {
|
|
1034
|
+
if (!hasAttribute) {
|
|
1035
|
+
this.setAttribute(attrName, '');
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
if (hasAttribute) {
|
|
1040
|
+
this.removeAttribute(attrName);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
},
|
|
1044
|
+
});
|
|
1045
|
+
/**
|
|
1046
|
+
* Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
|
|
1047
|
+
*/
|
|
1048
|
+
const ariaDescriptor = (attrName) => ({
|
|
1049
|
+
configurable: true,
|
|
1050
|
+
enumerable: true,
|
|
1051
|
+
get() {
|
|
1052
|
+
return this.getAttribute(attrName);
|
|
1053
|
+
},
|
|
1054
|
+
set(newValue) {
|
|
1055
|
+
const currentValue = this.getAttribute(attrName);
|
|
1056
|
+
if (newValue !== currentValue) {
|
|
1057
|
+
// TODO [#3284]: According to the spec, IDL nullable type values
|
|
1058
|
+
// (null and undefined) should remove the attribute; however, we
|
|
1059
|
+
// only do so in the case of null for historical reasons.
|
|
1060
|
+
if (isNull(newValue)) {
|
|
1061
|
+
this.removeAttribute(attrName);
|
|
1062
|
+
}
|
|
1063
|
+
else {
|
|
1064
|
+
this.setAttribute(attrName, toString(newValue));
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
},
|
|
1068
|
+
});
|
|
1069
|
+
const tabIndexDescriptor = () => ({
|
|
1070
|
+
configurable: true,
|
|
1071
|
+
enumerable: true,
|
|
1072
|
+
get() {
|
|
1073
|
+
const str = this.getAttribute('tabindex');
|
|
1074
|
+
const num = Number(str);
|
|
1075
|
+
return isFinite(num) ? Math.trunc(num) : -1;
|
|
1076
|
+
},
|
|
1077
|
+
set(newValue) {
|
|
1078
|
+
const currentValue = this.getAttribute('tabindex');
|
|
1079
|
+
const num = Number(newValue);
|
|
1080
|
+
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
|
1081
|
+
if (normalizedValue !== currentValue) {
|
|
1082
|
+
this.setAttribute('tabindex', toString(newValue));
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
});
|
|
1086
|
+
const descriptors = {
|
|
1087
|
+
accessKey: stringDescriptor('accesskey'),
|
|
1088
|
+
dir: stringDescriptor('dir'),
|
|
1089
|
+
draggable: explicitBooleanDescriptor('draggable', true),
|
|
1090
|
+
hidden: booleanAttributeDescriptor('hidden'),
|
|
1091
|
+
id: stringDescriptor('id'),
|
|
1092
|
+
lang: stringDescriptor('lang'),
|
|
1093
|
+
spellcheck: explicitBooleanDescriptor('spellcheck', false),
|
|
1094
|
+
tabIndex: tabIndexDescriptor(),
|
|
1095
|
+
title: stringDescriptor('title'),
|
|
1096
|
+
};
|
|
1097
|
+
// Add descriptors for ARIA attributes
|
|
1098
|
+
for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
|
|
1099
|
+
descriptors[propName] = ariaDescriptor(attrName);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Copyright (C) 2017 salesforce.com, inc.
|
|
1104
|
+
*/
|
|
1105
|
+
const { isArray } = Array;
|
|
1106
|
+
const { prototype: ObjectDotPrototype, getPrototypeOf, create: ObjectCreate, defineProperty: ObjectDefineProperty, isExtensible, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, preventExtensions, hasOwnProperty, } = Object;
|
|
1107
|
+
const { push: ArrayPush, concat: ArrayConcat } = Array.prototype;
|
|
1108
|
+
function isUndefined(obj) {
|
|
1109
|
+
return obj === undefined;
|
|
1110
|
+
}
|
|
1111
|
+
function isFunction(obj) {
|
|
1112
|
+
return typeof obj === 'function';
|
|
1113
|
+
}
|
|
1114
|
+
const proxyToValueMap = new WeakMap();
|
|
1115
|
+
function registerProxy(proxy, value) {
|
|
1116
|
+
proxyToValueMap.set(proxy, value);
|
|
1117
|
+
}
|
|
1118
|
+
const unwrap = (replicaOrAny) => proxyToValueMap.get(replicaOrAny) || replicaOrAny;
|
|
1119
|
+
|
|
1120
|
+
class BaseProxyHandler {
|
|
1121
|
+
constructor(membrane, value) {
|
|
1122
|
+
this.originalTarget = value;
|
|
1123
|
+
this.membrane = membrane;
|
|
1124
|
+
}
|
|
1125
|
+
// Shared utility methods
|
|
1126
|
+
wrapDescriptor(descriptor) {
|
|
1127
|
+
if (hasOwnProperty.call(descriptor, 'value')) {
|
|
1128
|
+
descriptor.value = this.wrapValue(descriptor.value);
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
const { set: originalSet, get: originalGet } = descriptor;
|
|
1132
|
+
if (!isUndefined(originalGet)) {
|
|
1133
|
+
descriptor.get = this.wrapGetter(originalGet);
|
|
1134
|
+
}
|
|
1135
|
+
if (!isUndefined(originalSet)) {
|
|
1136
|
+
descriptor.set = this.wrapSetter(originalSet);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
return descriptor;
|
|
1140
|
+
}
|
|
1141
|
+
copyDescriptorIntoShadowTarget(shadowTarget, key) {
|
|
1142
|
+
const { originalTarget } = this;
|
|
1143
|
+
// Note: a property might get defined multiple times in the shadowTarget
|
|
1144
|
+
// but it will always be compatible with the previous descriptor
|
|
1145
|
+
// to preserve the object invariants, which makes these lines safe.
|
|
1146
|
+
const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
|
|
1147
|
+
// TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
|
|
1148
|
+
/* istanbul ignore else */
|
|
1149
|
+
if (!isUndefined(originalDescriptor)) {
|
|
1150
|
+
const wrappedDesc = this.wrapDescriptor(originalDescriptor);
|
|
1151
|
+
ObjectDefineProperty(shadowTarget, key, wrappedDesc);
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
lockShadowTarget(shadowTarget) {
|
|
1155
|
+
const { originalTarget } = this;
|
|
1156
|
+
const targetKeys = ArrayConcat.call(getOwnPropertyNames(originalTarget), getOwnPropertySymbols(originalTarget));
|
|
1157
|
+
targetKeys.forEach((key) => {
|
|
1158
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
|
1159
|
+
});
|
|
1160
|
+
const { membrane: { tagPropertyKey }, } = this;
|
|
1161
|
+
if (!isUndefined(tagPropertyKey) && !hasOwnProperty.call(shadowTarget, tagPropertyKey)) {
|
|
1162
|
+
ObjectDefineProperty(shadowTarget, tagPropertyKey, ObjectCreate(null));
|
|
1163
|
+
}
|
|
1164
|
+
preventExtensions(shadowTarget);
|
|
1165
|
+
}
|
|
1166
|
+
// Shared Traps
|
|
1167
|
+
// TODO: apply() is never called
|
|
1168
|
+
/* istanbul ignore next */
|
|
1169
|
+
apply(shadowTarget, thisArg, argArray) {
|
|
1170
|
+
/* No op */
|
|
1171
|
+
}
|
|
1172
|
+
// TODO: construct() is never called
|
|
1173
|
+
/* istanbul ignore next */
|
|
1174
|
+
construct(shadowTarget, argArray, newTarget) {
|
|
1175
|
+
/* No op */
|
|
1176
|
+
}
|
|
1177
|
+
get(shadowTarget, key) {
|
|
1178
|
+
const { originalTarget, membrane: { valueObserved }, } = this;
|
|
1179
|
+
const value = originalTarget[key];
|
|
1180
|
+
valueObserved(originalTarget, key);
|
|
1181
|
+
return this.wrapValue(value);
|
|
1182
|
+
}
|
|
1183
|
+
has(shadowTarget, key) {
|
|
1184
|
+
const { originalTarget, membrane: { tagPropertyKey, valueObserved }, } = this;
|
|
1185
|
+
valueObserved(originalTarget, key);
|
|
1186
|
+
// since key is never going to be undefined, and tagPropertyKey might be undefined
|
|
1187
|
+
// we can simply compare them as the second part of the condition.
|
|
1188
|
+
return key in originalTarget || key === tagPropertyKey;
|
|
1189
|
+
}
|
|
1190
|
+
ownKeys(shadowTarget) {
|
|
1191
|
+
const { originalTarget, membrane: { tagPropertyKey }, } = this;
|
|
1192
|
+
// if the membrane tag key exists and it is not in the original target, we add it to the keys.
|
|
1193
|
+
const keys = isUndefined(tagPropertyKey) || hasOwnProperty.call(originalTarget, tagPropertyKey)
|
|
1194
|
+
? []
|
|
1195
|
+
: [tagPropertyKey];
|
|
1196
|
+
// small perf optimization using push instead of concat to avoid creating an extra array
|
|
1197
|
+
ArrayPush.apply(keys, getOwnPropertyNames(originalTarget));
|
|
1198
|
+
ArrayPush.apply(keys, getOwnPropertySymbols(originalTarget));
|
|
1199
|
+
return keys;
|
|
1200
|
+
}
|
|
1201
|
+
isExtensible(shadowTarget) {
|
|
1202
|
+
const { originalTarget } = this;
|
|
1203
|
+
// optimization to avoid attempting to lock down the shadowTarget multiple times
|
|
1204
|
+
if (!isExtensible(shadowTarget)) {
|
|
1205
|
+
return false; // was already locked down
|
|
1206
|
+
}
|
|
1207
|
+
if (!isExtensible(originalTarget)) {
|
|
1208
|
+
this.lockShadowTarget(shadowTarget);
|
|
1209
|
+
return false;
|
|
1210
|
+
}
|
|
1211
|
+
return true;
|
|
1212
|
+
}
|
|
1213
|
+
getPrototypeOf(shadowTarget) {
|
|
1214
|
+
const { originalTarget } = this;
|
|
1215
|
+
return getPrototypeOf(originalTarget);
|
|
1216
|
+
}
|
|
1217
|
+
getOwnPropertyDescriptor(shadowTarget, key) {
|
|
1218
|
+
const { originalTarget, membrane: { valueObserved, tagPropertyKey }, } = this;
|
|
1219
|
+
// keys looked up via getOwnPropertyDescriptor need to be reactive
|
|
1220
|
+
valueObserved(originalTarget, key);
|
|
1221
|
+
let desc = getOwnPropertyDescriptor(originalTarget, key);
|
|
1222
|
+
if (isUndefined(desc)) {
|
|
1223
|
+
if (key !== tagPropertyKey) {
|
|
1224
|
+
return undefined;
|
|
1225
|
+
}
|
|
1226
|
+
// if the key is the membrane tag key, and is not in the original target,
|
|
1227
|
+
// we produce a synthetic descriptor and install it on the shadow target
|
|
1228
|
+
desc = { value: undefined, writable: false, configurable: false, enumerable: false };
|
|
1229
|
+
ObjectDefineProperty(shadowTarget, tagPropertyKey, desc);
|
|
1230
|
+
return desc;
|
|
1231
|
+
}
|
|
1232
|
+
if (desc.configurable === false) {
|
|
1233
|
+
// updating the descriptor to non-configurable on the shadow
|
|
1234
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
|
1235
|
+
}
|
|
1236
|
+
// Note: by accessing the descriptor, the key is marked as observed
|
|
1237
|
+
// but access to the value, setter or getter (if available) cannot observe
|
|
1238
|
+
// mutations, just like regular methods, in which case we just do nothing.
|
|
1239
|
+
return this.wrapDescriptor(desc);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
const getterMap$1 = new WeakMap();
|
|
1244
|
+
const setterMap$1 = new WeakMap();
|
|
1245
|
+
const reverseGetterMap = new WeakMap();
|
|
1246
|
+
const reverseSetterMap = new WeakMap();
|
|
1247
|
+
class ReactiveProxyHandler extends BaseProxyHandler {
|
|
1248
|
+
wrapValue(value) {
|
|
1249
|
+
return this.membrane.getProxy(value);
|
|
1250
|
+
}
|
|
1251
|
+
wrapGetter(originalGet) {
|
|
1252
|
+
const wrappedGetter = getterMap$1.get(originalGet);
|
|
1253
|
+
if (!isUndefined(wrappedGetter)) {
|
|
1254
|
+
return wrappedGetter;
|
|
1255
|
+
}
|
|
1256
|
+
const handler = this;
|
|
1257
|
+
const get = function () {
|
|
1258
|
+
// invoking the original getter with the original target
|
|
1259
|
+
return handler.wrapValue(originalGet.call(unwrap(this)));
|
|
1260
|
+
};
|
|
1261
|
+
getterMap$1.set(originalGet, get);
|
|
1262
|
+
reverseGetterMap.set(get, originalGet);
|
|
1263
|
+
return get;
|
|
1264
|
+
}
|
|
1265
|
+
wrapSetter(originalSet) {
|
|
1266
|
+
const wrappedSetter = setterMap$1.get(originalSet);
|
|
1267
|
+
if (!isUndefined(wrappedSetter)) {
|
|
1268
|
+
return wrappedSetter;
|
|
1269
|
+
}
|
|
1270
|
+
const set = function (v) {
|
|
1271
|
+
// invoking the original setter with the original target
|
|
1272
|
+
originalSet.call(unwrap(this), unwrap(v));
|
|
1273
|
+
};
|
|
1274
|
+
setterMap$1.set(originalSet, set);
|
|
1275
|
+
reverseSetterMap.set(set, originalSet);
|
|
1276
|
+
return set;
|
|
1277
|
+
}
|
|
1278
|
+
unwrapDescriptor(descriptor) {
|
|
1279
|
+
if (hasOwnProperty.call(descriptor, 'value')) {
|
|
1280
|
+
// dealing with a data descriptor
|
|
1281
|
+
descriptor.value = unwrap(descriptor.value);
|
|
1282
|
+
}
|
|
1283
|
+
else {
|
|
1284
|
+
const { set, get } = descriptor;
|
|
1285
|
+
if (!isUndefined(get)) {
|
|
1286
|
+
descriptor.get = this.unwrapGetter(get);
|
|
1287
|
+
}
|
|
1288
|
+
if (!isUndefined(set)) {
|
|
1289
|
+
descriptor.set = this.unwrapSetter(set);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
return descriptor;
|
|
1293
|
+
}
|
|
1294
|
+
unwrapGetter(redGet) {
|
|
1295
|
+
const reverseGetter = reverseGetterMap.get(redGet);
|
|
1296
|
+
if (!isUndefined(reverseGetter)) {
|
|
1297
|
+
return reverseGetter;
|
|
1298
|
+
}
|
|
1299
|
+
const handler = this;
|
|
1300
|
+
const get = function () {
|
|
1301
|
+
// invoking the red getter with the proxy of this
|
|
1302
|
+
return unwrap(redGet.call(handler.wrapValue(this)));
|
|
1303
|
+
};
|
|
1304
|
+
getterMap$1.set(get, redGet);
|
|
1305
|
+
reverseGetterMap.set(redGet, get);
|
|
1306
|
+
return get;
|
|
1307
|
+
}
|
|
1308
|
+
unwrapSetter(redSet) {
|
|
1309
|
+
const reverseSetter = reverseSetterMap.get(redSet);
|
|
1310
|
+
if (!isUndefined(reverseSetter)) {
|
|
1311
|
+
return reverseSetter;
|
|
1312
|
+
}
|
|
1313
|
+
const handler = this;
|
|
1314
|
+
const set = function (v) {
|
|
1315
|
+
// invoking the red setter with the proxy of this
|
|
1316
|
+
redSet.call(handler.wrapValue(this), handler.wrapValue(v));
|
|
1317
|
+
};
|
|
1318
|
+
setterMap$1.set(set, redSet);
|
|
1319
|
+
reverseSetterMap.set(redSet, set);
|
|
1320
|
+
return set;
|
|
1321
|
+
}
|
|
1322
|
+
set(shadowTarget, key, value) {
|
|
1323
|
+
const { originalTarget, membrane: { valueMutated }, } = this;
|
|
1324
|
+
const oldValue = originalTarget[key];
|
|
1325
|
+
if (oldValue !== value) {
|
|
1326
|
+
originalTarget[key] = value;
|
|
1327
|
+
valueMutated(originalTarget, key);
|
|
1328
|
+
}
|
|
1329
|
+
else if (key === 'length' && isArray(originalTarget)) {
|
|
1330
|
+
// fix for issue #236: push will add the new index, and by the time length
|
|
1331
|
+
// is updated, the internal length is already equal to the new length value
|
|
1332
|
+
// therefore, the oldValue is equal to the value. This is the forking logic
|
|
1333
|
+
// to support this use case.
|
|
1334
|
+
valueMutated(originalTarget, key);
|
|
1335
|
+
}
|
|
1336
|
+
return true;
|
|
1337
|
+
}
|
|
1338
|
+
deleteProperty(shadowTarget, key) {
|
|
1339
|
+
const { originalTarget, membrane: { valueMutated }, } = this;
|
|
1340
|
+
delete originalTarget[key];
|
|
1341
|
+
valueMutated(originalTarget, key);
|
|
1342
|
+
return true;
|
|
1343
|
+
}
|
|
1344
|
+
setPrototypeOf(shadowTarget, prototype) {
|
|
1345
|
+
}
|
|
1346
|
+
preventExtensions(shadowTarget) {
|
|
1347
|
+
if (isExtensible(shadowTarget)) {
|
|
1348
|
+
const { originalTarget } = this;
|
|
1349
|
+
preventExtensions(originalTarget);
|
|
1350
|
+
// if the originalTarget is a proxy itself, it might reject
|
|
1351
|
+
// the preventExtension call, in which case we should not attempt to lock down
|
|
1352
|
+
// the shadow target.
|
|
1353
|
+
// TODO: It should not actually be possible to reach this `if` statement.
|
|
1354
|
+
// If a proxy rejects extensions, then calling preventExtensions will throw an error:
|
|
1355
|
+
// https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
|
|
1356
|
+
/* istanbul ignore if */
|
|
1357
|
+
if (isExtensible(originalTarget)) {
|
|
1358
|
+
return false;
|
|
1359
|
+
}
|
|
1360
|
+
this.lockShadowTarget(shadowTarget);
|
|
1361
|
+
}
|
|
1362
|
+
return true;
|
|
1363
|
+
}
|
|
1364
|
+
defineProperty(shadowTarget, key, descriptor) {
|
|
1365
|
+
const { originalTarget, membrane: { valueMutated, tagPropertyKey }, } = this;
|
|
1366
|
+
if (key === tagPropertyKey && !hasOwnProperty.call(originalTarget, key)) {
|
|
1367
|
+
// To avoid leaking the membrane tag property into the original target, we must
|
|
1368
|
+
// be sure that the original target doesn't have yet.
|
|
1369
|
+
// NOTE: we do not return false here because Object.freeze and equivalent operations
|
|
1370
|
+
// will attempt to set the descriptor to the same value, and expect no to throw. This
|
|
1371
|
+
// is an small compromise for the sake of not having to diff the descriptors.
|
|
1372
|
+
return true;
|
|
1373
|
+
}
|
|
1374
|
+
ObjectDefineProperty(originalTarget, key, this.unwrapDescriptor(descriptor));
|
|
1375
|
+
// intentionally testing if false since it could be undefined as well
|
|
1376
|
+
if (descriptor.configurable === false) {
|
|
1377
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
|
1378
|
+
}
|
|
1379
|
+
valueMutated(originalTarget, key);
|
|
1380
|
+
return true;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
const getterMap = new WeakMap();
|
|
1385
|
+
const setterMap = new WeakMap();
|
|
1386
|
+
class ReadOnlyHandler extends BaseProxyHandler {
|
|
1387
|
+
wrapValue(value) {
|
|
1388
|
+
return this.membrane.getReadOnlyProxy(value);
|
|
1389
|
+
}
|
|
1390
|
+
wrapGetter(originalGet) {
|
|
1391
|
+
const wrappedGetter = getterMap.get(originalGet);
|
|
1392
|
+
if (!isUndefined(wrappedGetter)) {
|
|
1393
|
+
return wrappedGetter;
|
|
1394
|
+
}
|
|
1395
|
+
const handler = this;
|
|
1396
|
+
const get = function () {
|
|
1397
|
+
// invoking the original getter with the original target
|
|
1398
|
+
return handler.wrapValue(originalGet.call(unwrap(this)));
|
|
1399
|
+
};
|
|
1400
|
+
getterMap.set(originalGet, get);
|
|
1401
|
+
return get;
|
|
1402
|
+
}
|
|
1403
|
+
wrapSetter(originalSet) {
|
|
1404
|
+
const wrappedSetter = setterMap.get(originalSet);
|
|
1405
|
+
if (!isUndefined(wrappedSetter)) {
|
|
1406
|
+
return wrappedSetter;
|
|
1407
|
+
}
|
|
1408
|
+
const set = function (v) {
|
|
1409
|
+
};
|
|
1410
|
+
setterMap.set(originalSet, set);
|
|
1411
|
+
return set;
|
|
1412
|
+
}
|
|
1413
|
+
set(shadowTarget, key, value) {
|
|
1414
|
+
/* istanbul ignore next */
|
|
1415
|
+
return false;
|
|
1416
|
+
}
|
|
1417
|
+
deleteProperty(shadowTarget, key) {
|
|
1418
|
+
/* istanbul ignore next */
|
|
1419
|
+
return false;
|
|
1420
|
+
}
|
|
1421
|
+
setPrototypeOf(shadowTarget, prototype) {
|
|
1422
|
+
}
|
|
1423
|
+
preventExtensions(shadowTarget) {
|
|
1424
|
+
/* istanbul ignore next */
|
|
1425
|
+
return false;
|
|
1426
|
+
}
|
|
1427
|
+
defineProperty(shadowTarget, key, descriptor) {
|
|
1428
|
+
/* istanbul ignore next */
|
|
1429
|
+
return false;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
function defaultValueIsObservable(value) {
|
|
1434
|
+
// intentionally checking for null
|
|
1435
|
+
if (value === null) {
|
|
1436
|
+
return false;
|
|
1437
|
+
}
|
|
1438
|
+
// treat all non-object types, including undefined, as non-observable values
|
|
1439
|
+
if (typeof value !== 'object') {
|
|
1440
|
+
return false;
|
|
1441
|
+
}
|
|
1442
|
+
if (isArray(value)) {
|
|
1443
|
+
return true;
|
|
1444
|
+
}
|
|
1445
|
+
const proto = getPrototypeOf(value);
|
|
1446
|
+
return proto === ObjectDotPrototype || proto === null || getPrototypeOf(proto) === null;
|
|
1447
|
+
}
|
|
1448
|
+
const defaultValueObserved = (obj, key) => {
|
|
1449
|
+
/* do nothing */
|
|
1450
|
+
};
|
|
1451
|
+
const defaultValueMutated = (obj, key) => {
|
|
1452
|
+
/* do nothing */
|
|
1453
|
+
};
|
|
1454
|
+
function createShadowTarget(value) {
|
|
1455
|
+
return isArray(value) ? [] : {};
|
|
1456
|
+
}
|
|
1457
|
+
class ObservableMembrane {
|
|
1458
|
+
constructor(options = {}) {
|
|
1459
|
+
this.readOnlyObjectGraph = new WeakMap();
|
|
1460
|
+
this.reactiveObjectGraph = new WeakMap();
|
|
1461
|
+
const { valueMutated, valueObserved, valueIsObservable, tagPropertyKey } = options;
|
|
1462
|
+
this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
|
|
1463
|
+
this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
|
|
1464
|
+
this.valueIsObservable = isFunction(valueIsObservable)
|
|
1465
|
+
? valueIsObservable
|
|
1466
|
+
: defaultValueIsObservable;
|
|
1467
|
+
this.tagPropertyKey = tagPropertyKey;
|
|
1468
|
+
}
|
|
1469
|
+
getProxy(value) {
|
|
1470
|
+
const unwrappedValue = unwrap(value);
|
|
1471
|
+
if (this.valueIsObservable(unwrappedValue)) {
|
|
1472
|
+
// When trying to extract the writable version of a readonly we return the readonly.
|
|
1473
|
+
if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
|
|
1474
|
+
return value;
|
|
1475
|
+
}
|
|
1476
|
+
return this.getReactiveHandler(unwrappedValue);
|
|
1477
|
+
}
|
|
1478
|
+
return unwrappedValue;
|
|
1479
|
+
}
|
|
1480
|
+
getReadOnlyProxy(value) {
|
|
1481
|
+
value = unwrap(value);
|
|
1482
|
+
if (this.valueIsObservable(value)) {
|
|
1483
|
+
return this.getReadOnlyHandler(value);
|
|
1484
|
+
}
|
|
1485
|
+
return value;
|
|
1486
|
+
}
|
|
1487
|
+
unwrapProxy(p) {
|
|
1488
|
+
return unwrap(p);
|
|
1489
|
+
}
|
|
1490
|
+
getReactiveHandler(value) {
|
|
1491
|
+
let proxy = this.reactiveObjectGraph.get(value);
|
|
1492
|
+
if (isUndefined(proxy)) {
|
|
1493
|
+
// caching the proxy after the first time it is accessed
|
|
1494
|
+
const handler = new ReactiveProxyHandler(this, value);
|
|
1495
|
+
proxy = new Proxy(createShadowTarget(value), handler);
|
|
1496
|
+
registerProxy(proxy, value);
|
|
1497
|
+
this.reactiveObjectGraph.set(value, proxy);
|
|
1498
|
+
}
|
|
1499
|
+
return proxy;
|
|
1500
|
+
}
|
|
1501
|
+
getReadOnlyHandler(value) {
|
|
1502
|
+
let proxy = this.readOnlyObjectGraph.get(value);
|
|
1503
|
+
if (isUndefined(proxy)) {
|
|
1504
|
+
// caching the proxy after the first time it is accessed
|
|
1505
|
+
const handler = new ReadOnlyHandler(this, value);
|
|
1506
|
+
proxy = new Proxy(createShadowTarget(value), handler);
|
|
1507
|
+
registerProxy(proxy, value);
|
|
1508
|
+
this.readOnlyObjectGraph.set(value, proxy);
|
|
1509
|
+
}
|
|
1510
|
+
return proxy;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
/** version: 2.0.0 */
|
|
1514
|
+
|
|
1515
|
+
/*
|
|
1516
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
1517
|
+
* All rights reserved.
|
|
1518
|
+
* SPDX-License-Identifier: MIT
|
|
1519
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1520
|
+
*/
|
|
1521
|
+
const reactiveMembrane = new ObservableMembrane();
|
|
1522
|
+
// Modeled after `getReadOnlyProxy` in `membrane.ts` in `engine-core`
|
|
1523
|
+
// Return a proxy over the given object so that access is immutable
|
|
1524
|
+
// https://github.com/salesforce/lwc/blob/e9db491/packages/%40lwc/engine-core/src/framework/membrane.ts#L29-L33
|
|
1525
|
+
function getReadOnlyProxy(value) {
|
|
1526
|
+
return reactiveMembrane.getReadOnlyProxy(value);
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* DEPRECATED: This function allows you to create a reactive readonly
|
|
1530
|
+
* membrane around any object value.
|
|
1531
|
+
* WARNING: This function does *NOT* make the object read-only.
|
|
1532
|
+
* @param value any object
|
|
1533
|
+
* @returns the provided value
|
|
1534
|
+
* @deprecated
|
|
1535
|
+
*/
|
|
1536
|
+
function readonly(value) {
|
|
1537
|
+
return value;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
/*
|
|
1541
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
1542
|
+
* All rights reserved.
|
|
1543
|
+
* SPDX-License-Identifier: MIT
|
|
1544
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1545
|
+
*/
|
|
1546
|
+
const contextfulRelationships = new WeakMap();
|
|
1547
|
+
function establishContextfulRelationship(parentLe, childLe) {
|
|
1548
|
+
contextfulRelationships.set(childLe, parentLe);
|
|
1549
|
+
}
|
|
1550
|
+
function getContextfulStack(le) {
|
|
1551
|
+
const contextfulParent = contextfulRelationships.get(le);
|
|
1552
|
+
if (!contextfulParent) {
|
|
1553
|
+
return [];
|
|
1554
|
+
}
|
|
1555
|
+
return [contextfulParent, ...getContextfulStack(contextfulParent)];
|
|
1556
|
+
}
|
|
1557
|
+
const contextProviders = new WeakMap();
|
|
1558
|
+
function registerContextProvider(adapter, attachedLe, consumerCallback) {
|
|
1559
|
+
let elementMap = contextProviders.get(adapter);
|
|
1560
|
+
if (!elementMap) {
|
|
1561
|
+
elementMap = new WeakMap();
|
|
1562
|
+
contextProviders.set(adapter, elementMap);
|
|
1563
|
+
}
|
|
1564
|
+
elementMap.set(attachedLe, consumerCallback);
|
|
1565
|
+
}
|
|
1566
|
+
function connectContext$1(adapter, contextConsumer, onNewValue) {
|
|
1567
|
+
const elementMap = contextProviders.get(adapter);
|
|
1568
|
+
if (!elementMap) {
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
const contextfulStack = getContextfulStack(contextConsumer);
|
|
1572
|
+
for (const ancestor of contextfulStack) {
|
|
1573
|
+
const onConsumerConnected = elementMap.get(ancestor);
|
|
1574
|
+
if (onConsumerConnected) {
|
|
1575
|
+
onConsumerConnected({
|
|
1576
|
+
provide(newContextValue) {
|
|
1577
|
+
onNewValue(newContextValue);
|
|
1578
|
+
},
|
|
1579
|
+
});
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
function createContextProvider(adapter) {
|
|
1585
|
+
return (le, options) => {
|
|
1586
|
+
if (!(le instanceof LightningElement)) {
|
|
1587
|
+
throw new Error('Unable to register context provider on provided `elm`.');
|
|
1588
|
+
}
|
|
1589
|
+
if (!le.isConnected || !options?.consumerConnectedCallback) {
|
|
1590
|
+
return;
|
|
1591
|
+
}
|
|
1592
|
+
const { consumerConnectedCallback } = options;
|
|
1593
|
+
registerContextProvider(adapter, le, (consumer) => consumerConnectedCallback(consumer));
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
/*
|
|
1598
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
1599
|
+
* All rights reserved.
|
|
1600
|
+
* SPDX-License-Identifier: MIT
|
|
1601
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1602
|
+
*/
|
|
1603
|
+
class ContextBinding {
|
|
1604
|
+
constructor(component) {
|
|
1605
|
+
this.component = component;
|
|
1606
|
+
}
|
|
1607
|
+
provideContext(contextVariety, providedContextSignal) {
|
|
1608
|
+
const contextVarieties = this.component[SYMBOL__CONTEXT_VARIETIES];
|
|
1609
|
+
if (contextVarieties.has(contextVariety)) {
|
|
1610
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1611
|
+
throw new Error('Multiple contexts of the same variety were provided.');
|
|
1612
|
+
}
|
|
1613
|
+
return;
|
|
1614
|
+
}
|
|
1615
|
+
contextVarieties.set(contextVariety, providedContextSignal);
|
|
1616
|
+
}
|
|
1617
|
+
consumeContext(contextVariety, contextProvidedCallback) {
|
|
1618
|
+
const contextfulStack = getContextfulStack(this.component);
|
|
1619
|
+
for (const ancestor of contextfulStack) {
|
|
1620
|
+
// If the ancestor has the specified context variety, consume it and stop searching
|
|
1621
|
+
const ancestorContextVarieties = ancestor[SYMBOL__CONTEXT_VARIETIES];
|
|
1622
|
+
if (ancestorContextVarieties.has(contextVariety)) {
|
|
1623
|
+
contextProvidedCallback(ancestorContextVarieties.get(contextVariety));
|
|
1624
|
+
break;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
function connectContext(le) {
|
|
1630
|
+
const contextKeys = getContextKeys();
|
|
1631
|
+
if (isUndefined$1(contextKeys)) {
|
|
1632
|
+
return;
|
|
1633
|
+
}
|
|
1634
|
+
const { connectContext } = contextKeys;
|
|
1635
|
+
const enumerableKeys = keys(le);
|
|
1636
|
+
const contextfulKeys = ArrayFilter.call(enumerableKeys, (enumerableKey) => isTrustedContext(le[enumerableKey]));
|
|
1637
|
+
if (contextfulKeys.length === 0) {
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
try {
|
|
1641
|
+
for (let i = 0; i < contextfulKeys.length; i++) {
|
|
1642
|
+
le[contextfulKeys[i]][connectContext](new ContextBinding(le));
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
catch (err) {
|
|
1646
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1647
|
+
// eslint-disable-next-line preserve-caught-error
|
|
1648
|
+
throw new Error(`Attempted to connect to trusted context but received the following error: ${err.message}`);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
/*
|
|
1654
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
1655
|
+
* All rights reserved.
|
|
1656
|
+
* SPDX-License-Identifier: MIT
|
|
1657
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1658
|
+
*/
|
|
1659
|
+
var _LightningElement_props, _LightningElement_attrs, _LightningElement_classList, _a;
|
|
1660
|
+
const SYMBOL__SET_INTERNALS = Symbol('set-internals');
|
|
1661
|
+
const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
|
|
1662
|
+
const SYMBOL__DEFAULT_TEMPLATE = Symbol('default-template');
|
|
1663
|
+
const SYMBOL__CONTEXT_VARIETIES = Symbol('context-varieties');
|
|
1664
|
+
class LightningElement {
|
|
1665
|
+
constructor(propsAvailableAtConstruction) {
|
|
1666
|
+
this.isConnected = false;
|
|
1667
|
+
_LightningElement_props.set(this, void 0);
|
|
1668
|
+
_LightningElement_attrs.set(this, void 0);
|
|
1669
|
+
_LightningElement_classList.set(this, null);
|
|
1670
|
+
this[_a] = new Map();
|
|
1671
|
+
assign(this, propsAvailableAtConstruction);
|
|
1672
|
+
}
|
|
1673
|
+
[(_LightningElement_props = new WeakMap(), _LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), _a = SYMBOL__CONTEXT_VARIETIES, SYMBOL__SET_INTERNALS)](props, attrs, publicProperties) {
|
|
1674
|
+
__classPrivateFieldSet(this, _LightningElement_props, props, "f");
|
|
1675
|
+
__classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
|
|
1676
|
+
if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS) {
|
|
1677
|
+
// Setup context before connected callback is executed
|
|
1678
|
+
connectContext(this);
|
|
1679
|
+
}
|
|
1680
|
+
// Class should be set explicitly to avoid it being overridden by connectedCallback classList mutation.
|
|
1681
|
+
if (attrs.class) {
|
|
1682
|
+
this.className = attrs.class;
|
|
1683
|
+
}
|
|
1684
|
+
// Avoid setting the following types of properties that should not be set:
|
|
1685
|
+
// - Properties that are not public.
|
|
1686
|
+
// - Properties that are not global.
|
|
1687
|
+
for (const propName of keys(props)) {
|
|
1688
|
+
const attrName = htmlPropertyToAttribute(propName);
|
|
1689
|
+
if (publicProperties.has(propName) ||
|
|
1690
|
+
REFLECTIVE_GLOBAL_PROPERTY_SET.has(propName) ||
|
|
1691
|
+
isAriaAttribute(attrName)) {
|
|
1692
|
+
// For props passed from parents to children, they are intended to be read-only
|
|
1693
|
+
// to avoid a child mutating its parent's state
|
|
1694
|
+
this[propName] = getReadOnlyProxy(props[propName]);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
get className() {
|
|
1699
|
+
return __classPrivateFieldGet(this, _LightningElement_props, "f").class ?? '';
|
|
1700
|
+
}
|
|
1701
|
+
set className(newVal) {
|
|
1702
|
+
__classPrivateFieldGet(this, _LightningElement_props, "f").class = newVal;
|
|
1703
|
+
__classPrivateFieldGet(this, _LightningElement_attrs, "f").class = newVal;
|
|
1704
|
+
mutationTracker.add(this, 'class');
|
|
1705
|
+
}
|
|
1706
|
+
get classList() {
|
|
1707
|
+
if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
|
|
1708
|
+
return __classPrivateFieldGet(this, _LightningElement_classList, "f");
|
|
1709
|
+
}
|
|
1710
|
+
return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
|
|
1711
|
+
}
|
|
1712
|
+
setAttribute(attrName, attrValue) {
|
|
1713
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
|
1714
|
+
const normalizedValue = String(attrValue);
|
|
1715
|
+
__classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
|
|
1716
|
+
mutationTracker.add(this, normalizedName);
|
|
1717
|
+
}
|
|
1718
|
+
getAttribute(attrName) {
|
|
1719
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
|
1720
|
+
if (hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
|
|
1721
|
+
return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
|
1722
|
+
}
|
|
1723
|
+
return null;
|
|
1724
|
+
}
|
|
1725
|
+
hasAttribute(attrName) {
|
|
1726
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
|
1727
|
+
return hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
|
|
1728
|
+
}
|
|
1729
|
+
removeAttribute(attrName) {
|
|
1730
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
|
1731
|
+
delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
|
1732
|
+
// Track mutations for removal of non-existing attributes
|
|
1733
|
+
mutationTracker.add(this, normalizedName);
|
|
1734
|
+
}
|
|
1735
|
+
addEventListener(_type, _listener, _options) {
|
|
1736
|
+
// noop
|
|
1737
|
+
}
|
|
1738
|
+
removeEventListener(_type, _listener, _options) {
|
|
1739
|
+
// noop
|
|
1740
|
+
}
|
|
1741
|
+
get template() {
|
|
1742
|
+
return {
|
|
1743
|
+
synthetic: false,
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
// ----------------------------------------------------------- //
|
|
1747
|
+
// Props/methods explicitly not available in this environment //
|
|
1748
|
+
// Getters are named "get*" for parity with @lwc/engine-server //
|
|
1749
|
+
// ----------------------------------------------------------- //
|
|
1750
|
+
get children() {
|
|
1751
|
+
throw new TypeError('"getChildren" is not supported in this environment');
|
|
1752
|
+
}
|
|
1753
|
+
get childNodes() {
|
|
1754
|
+
throw new TypeError('"getChildNodes" is not supported in this environment');
|
|
1755
|
+
}
|
|
1756
|
+
get firstChild() {
|
|
1757
|
+
throw new TypeError('"getFirstChild" is not supported in this environment');
|
|
1758
|
+
}
|
|
1759
|
+
get firstElementChild() {
|
|
1760
|
+
throw new TypeError('"getFirstElementChild" is not supported in this environment');
|
|
1761
|
+
}
|
|
1762
|
+
get hostElement() {
|
|
1763
|
+
// Intentionally different to match @lwc/engine-*core*
|
|
1764
|
+
throw new TypeError('this.hostElement is not supported in this environment');
|
|
1765
|
+
}
|
|
1766
|
+
get lastChild() {
|
|
1767
|
+
throw new TypeError('"getLastChild" is not supported in this environment');
|
|
1768
|
+
}
|
|
1769
|
+
get lastElementChild() {
|
|
1770
|
+
throw new TypeError('"getLastElementChild" is not supported in this environment');
|
|
1771
|
+
}
|
|
1772
|
+
get ownerDocument() {
|
|
1773
|
+
// Intentionally not "get*" to match @lwc/engine-server
|
|
1774
|
+
throw new TypeError('"ownerDocument" is not supported in this environment');
|
|
1775
|
+
}
|
|
1776
|
+
get style() {
|
|
1777
|
+
// Intentionally not "get*" to match @lwc/engine-server
|
|
1778
|
+
throw new TypeError('"style" is not supported in this environment');
|
|
1779
|
+
}
|
|
1780
|
+
attachInternals() {
|
|
1781
|
+
throw new TypeError('"attachInternals" is not supported in this environment');
|
|
1782
|
+
}
|
|
1783
|
+
dispatchEvent(_event) {
|
|
1784
|
+
throw new TypeError('"dispatchEvent" is not supported in this environment');
|
|
1785
|
+
}
|
|
1786
|
+
getBoundingClientRect() {
|
|
1787
|
+
throw new TypeError('"getBoundingClientRect" is not supported in this environment');
|
|
1788
|
+
}
|
|
1789
|
+
getElementsByClassName(_classNames) {
|
|
1790
|
+
throw new TypeError('"getElementsByClassName" is not supported in this environment');
|
|
1791
|
+
}
|
|
1792
|
+
getElementsByTagName(_qualifiedName) {
|
|
1793
|
+
throw new TypeError('"getElementsByTagName" is not supported in this environment');
|
|
1794
|
+
}
|
|
1795
|
+
querySelector(_selectors) {
|
|
1796
|
+
throw new TypeError('"querySelector" is not supported in this environment');
|
|
1797
|
+
}
|
|
1798
|
+
querySelectorAll(_selectors) {
|
|
1799
|
+
throw new TypeError('"querySelectorAll" is not supported in this environment');
|
|
1800
|
+
}
|
|
1801
|
+
getAttributeNS(_namespace, _localName) {
|
|
1802
|
+
throw new Error('Method "getAttributeNS" not implemented.');
|
|
1803
|
+
}
|
|
1804
|
+
hasAttributeNS(_namespace, _localName) {
|
|
1805
|
+
throw new Error('Method "hasAttributeNS" not implemented.');
|
|
1806
|
+
}
|
|
1807
|
+
removeAttributeNS(_namespace, _localName) {
|
|
1808
|
+
throw new Error('Method "removeAttributeNS" not implemented.');
|
|
1809
|
+
}
|
|
1810
|
+
setAttributeNS(_namespace, _qualifiedName, _value) {
|
|
1811
|
+
throw new Error('Method "setAttributeNS" not implemented.');
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
defineProperties(LightningElement.prototype, descriptors);
|
|
1815
|
+
|
|
1816
|
+
/*
|
|
1817
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
1818
|
+
* All rights reserved.
|
|
1819
|
+
* SPDX-License-Identifier: MIT
|
|
1820
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1821
|
+
*/
|
|
1822
|
+
function renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken) {
|
|
1823
|
+
// The scopeToken is e.g. `lwc-xyz123` which is the token our parent gives us.
|
|
1824
|
+
// The hostScopeToken is e.g. `lwc-abc456-host` which is the token for our own component.
|
|
1825
|
+
// It's possible to have both, one, the other, or neither.
|
|
1826
|
+
const combinedScopeToken = scopeToken && hostScopeToken
|
|
1827
|
+
? `${scopeToken} ${hostScopeToken}`
|
|
1828
|
+
: scopeToken || hostScopeToken || '';
|
|
1829
|
+
let result = '';
|
|
1830
|
+
let hasClassAttribute = false;
|
|
1831
|
+
for (const attrName of getOwnPropertyNames$1(attrs)) {
|
|
1832
|
+
let attrValue = attrs[attrName];
|
|
1833
|
+
// Backwards compatibility with historical patchStyleAttribute() behavior:
|
|
1834
|
+
// https://github.com/salesforce/lwc/blob/59e2c6c/packages/%40lwc/engine-core/src/framework/modules/computed-style-attr.ts#L40
|
|
1835
|
+
if (attrName === 'style' && (!isString(attrValue) || attrValue === '')) {
|
|
1836
|
+
// If the style attribute is invalid, we don't render it.
|
|
1837
|
+
continue;
|
|
1838
|
+
}
|
|
1839
|
+
if (isNull(attrValue) || isUndefined$1(attrValue)) {
|
|
1840
|
+
attrValue = '';
|
|
1841
|
+
}
|
|
1842
|
+
else if (!isString(attrValue)) {
|
|
1843
|
+
attrValue = String(attrValue);
|
|
1844
|
+
}
|
|
1845
|
+
if (attrName === 'class') {
|
|
1846
|
+
if (attrValue === '') {
|
|
1847
|
+
// If the class attribute is empty, we don't render it.
|
|
1848
|
+
continue;
|
|
1849
|
+
}
|
|
1850
|
+
if (combinedScopeToken) {
|
|
1851
|
+
attrValue += ' ' + combinedScopeToken;
|
|
1852
|
+
hasClassAttribute = true;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
result +=
|
|
1856
|
+
attrValue === '' ? ` ${attrName}` : ` ${attrName}="${htmlEscape(attrValue, true)}"`;
|
|
1857
|
+
}
|
|
1858
|
+
// If we didn't render any `class` attribute, render one for the scope token(s)
|
|
1859
|
+
if (!hasClassAttribute && combinedScopeToken) {
|
|
1860
|
+
result += ` class="${combinedScopeToken}"`;
|
|
1861
|
+
}
|
|
1862
|
+
// For the host scope token only, we encode a special attribute for hydration
|
|
1863
|
+
if (hostScopeToken) {
|
|
1864
|
+
result += ` data-lwc-host-scope-token="${hostScopeToken}"`;
|
|
1865
|
+
}
|
|
1866
|
+
result += mutationTracker.renderMutatedAttrs(instance);
|
|
1867
|
+
return result;
|
|
1868
|
+
}
|
|
1869
|
+
function* renderAttrs(instance, attrs, hostScopeToken, scopeToken) {
|
|
1870
|
+
yield renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken);
|
|
1871
|
+
}
|
|
1872
|
+
function renderAttrsNoYield(instance, attrs, hostScopeToken, scopeToken) {
|
|
1873
|
+
return renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken);
|
|
1874
|
+
}
|
|
1875
|
+
async function* fallbackTmpl(shadowSlottedContent, _lightSlottedContent, _scopedSlottedContent, Cmp, instance, _renderContext) {
|
|
1876
|
+
if (Cmp.renderMode !== 'light') {
|
|
1877
|
+
yield `<template shadowrootmode="open"></template>`;
|
|
1878
|
+
if (shadowSlottedContent) {
|
|
1879
|
+
yield* shadowSlottedContent(instance);
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
function fallbackTmplNoYield(shadowSlottedContent, _lightSlottedContent, _scopedSlottedContent, Cmp, instance, _renderContext) {
|
|
1884
|
+
let markup = '';
|
|
1885
|
+
if (Cmp.renderMode !== 'light') {
|
|
1886
|
+
markup += '<template shadowrootmode="open"></template>';
|
|
1887
|
+
if (shadowSlottedContent) {
|
|
1888
|
+
markup += shadowSlottedContent(instance);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
return markup;
|
|
1892
|
+
}
|
|
1893
|
+
function addSlottedContent(name, fn, contentMap) {
|
|
1894
|
+
const contentList = contentMap[name];
|
|
1895
|
+
if (contentList) {
|
|
1896
|
+
contentList.push(fn);
|
|
1897
|
+
}
|
|
1898
|
+
else {
|
|
1899
|
+
contentMap[name] = [fn];
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
class RenderContext {
|
|
1903
|
+
constructor(styleDedupe) {
|
|
1904
|
+
this.stylesheetToId = new WeakMap();
|
|
1905
|
+
this.nextId = 0;
|
|
1906
|
+
if (styleDedupe || styleDedupe === '') {
|
|
1907
|
+
this.styleDedupePrefix = typeof styleDedupe === 'string' ? styleDedupe : '';
|
|
1908
|
+
this.styleDedupeIsEnabled = true;
|
|
1909
|
+
}
|
|
1910
|
+
else {
|
|
1911
|
+
this.styleDedupePrefix = '';
|
|
1912
|
+
this.styleDedupeIsEnabled = false;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
getNextId() {
|
|
1916
|
+
return this.nextId++;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* Create a string representing an LWC component for server-side rendering.
|
|
1921
|
+
* @param tagName The HTML tag name of the component
|
|
1922
|
+
* @param Component The `LightningElement` component constructor
|
|
1923
|
+
* @param props HTML attributes to provide for the root component
|
|
1924
|
+
* @param styleDedupe Provide a string key or `true` to enable style deduping via the `<lwc-style>`
|
|
1925
|
+
* helper. The key is used to avoid collisions of global IDs.
|
|
1926
|
+
* @param mode SSR render mode. Can be 'sync', 'async' or 'asyncYield'. Must match the render mode
|
|
1927
|
+
* used to compile your component.
|
|
1928
|
+
* @returns String representation of the component
|
|
1929
|
+
*/
|
|
1930
|
+
async function serverSideRenderComponent(tagName, Component, props = {}, styleDedupe = false, mode = DEFAULT_SSR_MODE) {
|
|
1931
|
+
if (typeof tagName !== 'string') {
|
|
1932
|
+
throw new Error(`tagName must be a string, found: ${tagName}`);
|
|
1933
|
+
}
|
|
1934
|
+
const generateMarkup = Component[SYMBOL__GENERATE_MARKUP];
|
|
1935
|
+
const renderContext = new RenderContext(styleDedupe);
|
|
1936
|
+
if (!generateMarkup) {
|
|
1937
|
+
// If a non-component is accidentally provided, render an empty template
|
|
1938
|
+
let markup = `<${tagName}>`;
|
|
1939
|
+
fallbackTmplNoYield(null, null, null, Component,
|
|
1940
|
+
// Using a false type assertion for the `instance` param is safe because it's only used
|
|
1941
|
+
// if there's slotted content, which we are not providing
|
|
1942
|
+
null);
|
|
1943
|
+
markup += `</${tagName}>`;
|
|
1944
|
+
return markup;
|
|
1945
|
+
}
|
|
1946
|
+
if (mode === 'asyncYield') {
|
|
1947
|
+
let markup = '';
|
|
1948
|
+
for await (const segment of generateMarkup(tagName, props, null, null, null, null, renderContext, null, null, null)) {
|
|
1949
|
+
markup += segment;
|
|
1950
|
+
}
|
|
1951
|
+
return markup;
|
|
1952
|
+
}
|
|
1953
|
+
else if (mode === 'async') {
|
|
1954
|
+
return await generateMarkup(tagName, props, null, null, null, null, renderContext, null, null, null);
|
|
1955
|
+
}
|
|
1956
|
+
else if (mode === 'sync') {
|
|
1957
|
+
return generateMarkup(tagName, props, null, null, null, null, renderContext, null, null, null);
|
|
1958
|
+
}
|
|
1959
|
+
else {
|
|
1960
|
+
throw new Error(`Invalid mode: ${mode}`);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
/*
|
|
1965
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
1966
|
+
* All rights reserved.
|
|
1967
|
+
* SPDX-License-Identifier: MIT
|
|
1968
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1969
|
+
*/
|
|
1970
|
+
/**
|
|
1971
|
+
* Given an object, render it for use as a text content node. Not that this applies to individual text nodes,
|
|
1972
|
+
* not the concatenated result of multiple adjacent text nodes.
|
|
1973
|
+
* @param value
|
|
1974
|
+
*/
|
|
1975
|
+
function normalizeTextContent(value) {
|
|
1976
|
+
// Using non strict equality to align with original implementation (ex. undefined == null)
|
|
1977
|
+
// See: https://github.com/salesforce/lwc/blob/348130f/packages/%40lwc/engine-core/src/framework/api.ts#L548
|
|
1978
|
+
return value == null ? '' : String(value);
|
|
1979
|
+
}
|
|
1980
|
+
/**
|
|
1981
|
+
* Given a string, render it for use as text content in HTML. Notably this escapes HTML and renders as
|
|
1982
|
+
* a ZWJ is empty. Intended to be used on the result of concatenating multiple adjacent text nodes together.
|
|
1983
|
+
* @param value
|
|
1984
|
+
*/
|
|
1985
|
+
function renderTextContent(value) {
|
|
1986
|
+
// We are at the end of a series of text nodes - flush to a concatenated string
|
|
1987
|
+
// We only render the ZWJ if there were actually any dynamic text nodes rendered
|
|
1988
|
+
// The ZWJ is just so hydration can compare the SSR'd dynamic text content against
|
|
1989
|
+
// the CSR'd text content.
|
|
1990
|
+
return value === '' ? '\u200D' : htmlEscape(value);
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
/*
|
|
1994
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
1995
|
+
* All rights reserved.
|
|
1996
|
+
* SPDX-License-Identifier: MIT
|
|
1997
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1998
|
+
*/
|
|
1999
|
+
/**
|
|
2000
|
+
* Per the HTML spec on restrictions for "raw text elements" like `<style>`:
|
|
2001
|
+
*
|
|
2002
|
+
* > The text in raw text and escapable raw text elements must not contain any occurrences of the string
|
|
2003
|
+
* > "</" (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of
|
|
2004
|
+
* > the element followed by one of:
|
|
2005
|
+
* > - U+0009 CHARACTER TABULATION (tab)
|
|
2006
|
+
* > - U+000A LINE FEED (LF)
|
|
2007
|
+
* > - U+000C FORM FEED (FF)
|
|
2008
|
+
* > - U+000D CARRIAGE RETURN (CR)
|
|
2009
|
+
* > - U+0020 SPACE
|
|
2010
|
+
* > - U+003E GREATER-THAN SIGN (>), or
|
|
2011
|
+
* > - U+002F SOLIDUS (/)
|
|
2012
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
|
|
2013
|
+
*/
|
|
2014
|
+
const INVALID_STYLE_CONTENT = /<\/style[\t\n\f\r >/]/i;
|
|
2015
|
+
/**
|
|
2016
|
+
* The text content inside `<style>` is a special case. It is _only_ rendered by the LWC engine itself; `<style>` tags
|
|
2017
|
+
* are disallowed inside of HTML templates.
|
|
2018
|
+
*
|
|
2019
|
+
* The `<style>` tag is unusual in how it's defined in HTML. Like `<script>`, it is considered a "raw text element,"
|
|
2020
|
+
* which means that it is parsed as raw text, but certain character sequences are disallowed, namely to avoid XSS
|
|
2021
|
+
* attacks like `</style><script>alert("pwned")</script>`.
|
|
2022
|
+
*
|
|
2023
|
+
* This also means that we cannot use "normal" HTML escaping inside `<style>` tags, e.g. we cannot use `<`,
|
|
2024
|
+
* `>`, etc., because these are treated as-is by the HTML parser.
|
|
2025
|
+
*
|
|
2026
|
+
*
|
|
2027
|
+
* @param contents CSS source to validate
|
|
2028
|
+
* @throws Throws if the contents provided are not valid.
|
|
2029
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
|
|
2030
|
+
* @see https://github.com/salesforce/lwc/issues/3439
|
|
2031
|
+
* @example
|
|
2032
|
+
* validateStyleTextContents('div { color: red }') // Ok
|
|
2033
|
+
* validateStyleTextContents('</style><script>alert("pwned")</script>') // Throws
|
|
2034
|
+
*/
|
|
2035
|
+
function validateStyleTextContents(contents) {
|
|
2036
|
+
if (INVALID_STYLE_CONTENT.test(contents)) {
|
|
2037
|
+
throw new Error('CSS contains unsafe characters and cannot be serialized inside a style element');
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
/*
|
|
2042
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
2043
|
+
* All rights reserved.
|
|
2044
|
+
* SPDX-License-Identifier: MIT
|
|
2045
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2046
|
+
*/
|
|
2047
|
+
// Traverse in the same order as `flattenStylesheets` but without creating unnecessary additional arrays
|
|
2048
|
+
function traverseStylesheets(stylesheets, callback) {
|
|
2049
|
+
if (isArray$1(stylesheets)) {
|
|
2050
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
2051
|
+
traverseStylesheets(stylesheets[i], callback);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
else if (stylesheets) {
|
|
2055
|
+
callback(stylesheets);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
function hasScopedStaticStylesheets(Component) {
|
|
2059
|
+
let scoped = false;
|
|
2060
|
+
traverseStylesheets(Component.stylesheets, (stylesheet) => {
|
|
2061
|
+
scoped ||= !!stylesheet.$scoped$;
|
|
2062
|
+
});
|
|
2063
|
+
return scoped;
|
|
2064
|
+
}
|
|
2065
|
+
function renderStylesheets(renderContext, defaultStylesheets, defaultScopedStylesheets, staticStylesheets, scopeToken, Component, hasScopedTemplateStyles) {
|
|
2066
|
+
const hasAnyScopedStyles = hasScopedTemplateStyles || hasScopedStaticStylesheets(Component);
|
|
2067
|
+
const { renderMode } = Component;
|
|
2068
|
+
let result = '';
|
|
2069
|
+
const renderStylesheet = (stylesheet) => {
|
|
2070
|
+
const { $scoped$: scoped } = stylesheet;
|
|
2071
|
+
const token = scoped ? scopeToken : undefined;
|
|
2072
|
+
const useActualHostSelector = !scoped || renderMode !== 'light';
|
|
2073
|
+
const useNativeDirPseudoclass = true;
|
|
2074
|
+
const { styleDedupeIsEnabled, stylesheetToId, styleDedupePrefix } = renderContext;
|
|
2075
|
+
if (!styleDedupeIsEnabled) {
|
|
2076
|
+
const styleContents = stylesheet(token, useActualHostSelector, useNativeDirPseudoclass);
|
|
2077
|
+
validateStyleTextContents(styleContents);
|
|
2078
|
+
// TODO [#2869]: `<style>`s should not have scope token classes
|
|
2079
|
+
result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} type="text/css">${styleContents}</style>`;
|
|
2080
|
+
}
|
|
2081
|
+
else if (stylesheetToId.has(stylesheet)) {
|
|
2082
|
+
const styleId = stylesheetToId.get(stylesheet);
|
|
2083
|
+
// TODO [#2869]: `<lwc-style>`s should not have scope token classes, but required for hydration to function correctly (W-19087941).
|
|
2084
|
+
result += `<lwc-style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} style-id="lwc-style-${styleDedupePrefix}-${styleId}"></lwc-style>`;
|
|
2085
|
+
}
|
|
2086
|
+
else {
|
|
2087
|
+
const styleId = renderContext.getNextId();
|
|
2088
|
+
stylesheetToId.set(stylesheet, styleId.toString());
|
|
2089
|
+
const styleContents = stylesheet(token, useActualHostSelector, useNativeDirPseudoclass);
|
|
2090
|
+
validateStyleTextContents(styleContents);
|
|
2091
|
+
// TODO [#2869]: `<style>`s should not have scope token classes
|
|
2092
|
+
result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} id="lwc-style-${styleDedupePrefix}-${styleId}" type="text/css">${styleContents}</style>`;
|
|
2093
|
+
result += `<lwc-style style-id="lwc-style-${styleDedupePrefix}-${styleId}"></lwc-style>`;
|
|
2094
|
+
}
|
|
2095
|
+
};
|
|
2096
|
+
traverseStylesheets(defaultStylesheets, renderStylesheet);
|
|
2097
|
+
traverseStylesheets(defaultScopedStylesheets, renderStylesheet);
|
|
2098
|
+
traverseStylesheets(staticStylesheets, renderStylesheet);
|
|
2099
|
+
return result;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
/*
|
|
2103
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
2104
|
+
* All rights reserved.
|
|
2105
|
+
* SPDX-License-Identifier: MIT
|
|
2106
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2107
|
+
*/
|
|
2108
|
+
/**
|
|
2109
|
+
* Converts an iterable into one that emits the object used by the [`iterator` directive](
|
|
2110
|
+
* https://lwc.dev/guide/html_templates#iterator).
|
|
2111
|
+
*/
|
|
2112
|
+
function* toIteratorDirective(iterable) {
|
|
2113
|
+
if (iterable === undefined || iterable === null)
|
|
2114
|
+
return;
|
|
2115
|
+
if (!iterable[Symbol.iterator]) {
|
|
2116
|
+
throw new Error(
|
|
2117
|
+
// Mimic error message from "[i]terable node" in engine-core's api.ts
|
|
2118
|
+
`Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
|
|
2119
|
+
}
|
|
2120
|
+
const iterator = iterable[Symbol.iterator]();
|
|
2121
|
+
let next = iterator.next();
|
|
2122
|
+
let index = 0;
|
|
2123
|
+
let { value, done: last = false } = next;
|
|
2124
|
+
while (last === false) {
|
|
2125
|
+
// using a look-back approach because we need to know if the element is the last
|
|
2126
|
+
next = iterator.next();
|
|
2127
|
+
last = next.done ?? false;
|
|
2128
|
+
yield {
|
|
2129
|
+
value,
|
|
2130
|
+
index,
|
|
2131
|
+
first: index === 0,
|
|
2132
|
+
last,
|
|
2133
|
+
};
|
|
2134
|
+
index += 1;
|
|
2135
|
+
value = next.value;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
exports.ClassList = ClassList;
|
|
2140
|
+
exports.LightningElement = LightningElement;
|
|
2141
|
+
exports.SYMBOL__DEFAULT_TEMPLATE = SYMBOL__DEFAULT_TEMPLATE;
|
|
2142
|
+
exports.SYMBOL__GENERATE_MARKUP = SYMBOL__GENERATE_MARKUP;
|
|
2143
|
+
exports.SYMBOL__SET_INTERNALS = SYMBOL__SET_INTERNALS;
|
|
2144
|
+
exports.SignalBaseClass = SignalBaseClass;
|
|
2145
|
+
exports.__dangerous_do_not_use_addTrustedContext = addTrustedContext;
|
|
2146
|
+
exports.addSlottedContent = addSlottedContent;
|
|
2147
|
+
exports.api = api;
|
|
2148
|
+
exports.connectContext = connectContext$1;
|
|
2149
|
+
exports.createContextProvider = createContextProvider;
|
|
2150
|
+
exports.createElement = createElement;
|
|
2151
|
+
exports.establishContextfulRelationship = establishContextfulRelationship;
|
|
2152
|
+
exports.fallbackTmpl = fallbackTmpl;
|
|
2153
|
+
exports.fallbackTmplNoYield = fallbackTmplNoYield;
|
|
2154
|
+
exports.freezeTemplate = freezeTemplate;
|
|
2155
|
+
exports.getComponentDef = getComponentDef;
|
|
2156
|
+
exports.hasScopedStaticStylesheets = hasScopedStaticStylesheets;
|
|
2157
|
+
exports.hot = hot;
|
|
2158
|
+
exports.htmlEscape = htmlEscape;
|
|
2159
|
+
exports.isComponentConstructor = isComponentConstructor;
|
|
2160
|
+
exports.isTrustedSignal = isTrustedSignal;
|
|
2161
|
+
exports.mutationTracker = mutationTracker;
|
|
2162
|
+
exports.normalizeClass = normalizeClass;
|
|
2163
|
+
exports.normalizeTabIndex = normalizeTabIndex;
|
|
2164
|
+
exports.normalizeTextContent = normalizeTextContent;
|
|
2165
|
+
exports.parseFragment = parseFragment;
|
|
2166
|
+
exports.parseSVGFragment = parseSVGFragment;
|
|
2167
|
+
exports.readonly = readonly;
|
|
2168
|
+
exports.registerComponent = registerComponent;
|
|
2169
|
+
exports.registerDecorators = registerDecorators;
|
|
2170
|
+
exports.registerTemplate = registerTemplate;
|
|
2171
|
+
exports.renderAttrs = renderAttrs;
|
|
2172
|
+
exports.renderAttrsNoYield = renderAttrsNoYield;
|
|
2173
|
+
exports.renderComponent = serverSideRenderComponent;
|
|
2174
|
+
exports.renderStylesheets = renderStylesheets;
|
|
2175
|
+
exports.renderTextContent = renderTextContent;
|
|
2176
|
+
exports.renderer = renderer;
|
|
2177
|
+
exports.sanitizeAttribute = sanitizeAttribute;
|
|
2178
|
+
exports.sanitizeHtmlContent = sanitizeHtmlContent;
|
|
2179
|
+
exports.serverSideRenderComponent = serverSideRenderComponent;
|
|
2180
|
+
exports.setContextKeys = setContextKeys;
|
|
2181
|
+
exports.setFeatureFlag = setFeatureFlag;
|
|
2182
|
+
exports.setFeatureFlagForTest = setFeatureFlagForTest;
|
|
2183
|
+
exports.setHooks = setHooks;
|
|
2184
|
+
exports.setTrustedContextSet = setTrustedContextSet;
|
|
2185
|
+
exports.setTrustedSignalSet = setTrustedSignalSet;
|
|
2186
|
+
exports.swapComponent = swapComponent;
|
|
2187
|
+
exports.swapStyle = swapStyle;
|
|
2188
|
+
exports.swapTemplate = swapTemplate;
|
|
2189
|
+
exports.toIteratorDirective = toIteratorDirective;
|
|
2190
|
+
exports.track = track;
|
|
2191
|
+
exports.unwrap = unwrap$1;
|
|
2192
|
+
exports.validateStyleTextContents = validateStyleTextContents;
|
|
2193
|
+
exports.wire = wire;
|
|
2194
|
+
/** version: 9.0.4-alpha.0 */
|
|
2195
|
+
//# sourceMappingURL=index.cjs.map
|