@lwc/ssr-runtime 8.6.0 → 8.7.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/clone-and-deep-freeze.d.ts +1 -0
- package/dist/index.cjs.js +176 -28
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +175 -29
- package/dist/index.js.map +1 -1
- package/dist/reflection.d.ts +7 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -295,8 +295,18 @@ from: ArrayFrom, } = Array;
|
|
295
295
|
// statement, rather than this declaration.
|
296
296
|
const { concat: ArrayConcat, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly!
|
297
297
|
} = Array.prototype;
|
298
|
+
/** Detached {@linkcode String.fromCharCode}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode MDN Reference}. */
|
299
|
+
const { fromCharCode: StringFromCharCode } = String;
|
298
300
|
// No JSDocs here - see comment for Array.prototype
|
299
301
|
const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
|
302
|
+
/**
|
303
|
+
* Determines whether the argument is `undefined`.
|
304
|
+
* @param obj Value to test
|
305
|
+
* @returns `true` if the value is `undefined`.
|
306
|
+
*/
|
307
|
+
function isUndefined(obj) {
|
308
|
+
return obj === undefined;
|
309
|
+
}
|
300
310
|
/**
|
301
311
|
* Determines whether the argument is `null`.
|
302
312
|
* @param obj Value to test
|
@@ -305,6 +315,14 @@ const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringRepla
|
|
305
315
|
function isNull(obj) {
|
306
316
|
return obj === null;
|
307
317
|
}
|
318
|
+
/**
|
319
|
+
* Determines whether the argument is an object or null.
|
320
|
+
* @param obj Value to test
|
321
|
+
* @returns `true` if the value is an object or null.
|
322
|
+
*/
|
323
|
+
function isObject(obj) {
|
324
|
+
return typeof obj === 'object';
|
325
|
+
}
|
308
326
|
const OtS = {}.toString;
|
309
327
|
/**
|
310
328
|
* Converts the argument to a string, safely accounting for objects with "null" prototype.
|
@@ -419,11 +437,114 @@ const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (
|
|
419
437
|
// Synthetic creation of all AOM property descriptors for Custom Elements
|
420
438
|
forEach.call(AriaPropertyNames, (propName) => {
|
421
439
|
const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
|
440
|
+
// These type assertions are because the map types are a 1:1 mapping of ariaX to aria-x.
|
441
|
+
// TypeScript knows we have one of ariaX | ariaY and one of aria-x | aria-y, and tries to
|
442
|
+
// prevent us from doing ariaX: aria-y, but we that it's safe.
|
422
443
|
AriaAttrNameToPropNameMap[attrName] = propName;
|
423
444
|
AriaPropNameToAttrNameMap[propName] = attrName;
|
424
445
|
});
|
425
446
|
return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
|
426
447
|
})();
|
448
|
+
/**
|
449
|
+
*
|
450
|
+
* @param attrName
|
451
|
+
*/
|
452
|
+
function isAriaAttribute(attrName) {
|
453
|
+
return attrName in AriaAttrNameToPropNameMap;
|
454
|
+
}
|
455
|
+
// This list is based on https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
|
456
|
+
const GLOBAL_ATTRIBUTE = /*@__PURE__*/ new Set([
|
457
|
+
'accesskey',
|
458
|
+
'autocapitalize',
|
459
|
+
'autofocus',
|
460
|
+
'class',
|
461
|
+
'contenteditable',
|
462
|
+
'contextmenu',
|
463
|
+
'dir',
|
464
|
+
'draggable',
|
465
|
+
'enterkeyhint',
|
466
|
+
'exportparts',
|
467
|
+
'hidden',
|
468
|
+
'id',
|
469
|
+
'inputmode',
|
470
|
+
'is',
|
471
|
+
'itemid',
|
472
|
+
'itemprop',
|
473
|
+
'itemref',
|
474
|
+
'itemscope',
|
475
|
+
'itemtype',
|
476
|
+
'lang',
|
477
|
+
'nonce',
|
478
|
+
'part',
|
479
|
+
'slot',
|
480
|
+
'spellcheck',
|
481
|
+
'style',
|
482
|
+
'tabindex',
|
483
|
+
'title',
|
484
|
+
'translate',
|
485
|
+
]);
|
486
|
+
/**
|
487
|
+
*
|
488
|
+
* @param attrName
|
489
|
+
*/
|
490
|
+
function isGlobalHtmlAttribute(attrName) {
|
491
|
+
return GLOBAL_ATTRIBUTE.has(attrName);
|
492
|
+
}
|
493
|
+
// These are HTML standard prop/attribute IDL mappings, but are not predictable based on camel/kebab-case conversion
|
494
|
+
const SPECIAL_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map([
|
495
|
+
['accessKey', 'accesskey'],
|
496
|
+
['readOnly', 'readonly'],
|
497
|
+
['tabIndex', 'tabindex'],
|
498
|
+
['bgColor', 'bgcolor'],
|
499
|
+
['colSpan', 'colspan'],
|
500
|
+
['rowSpan', 'rowspan'],
|
501
|
+
['contentEditable', 'contenteditable'],
|
502
|
+
['crossOrigin', 'crossorigin'],
|
503
|
+
['dateTime', 'datetime'],
|
504
|
+
['formAction', 'formaction'],
|
505
|
+
['isMap', 'ismap'],
|
506
|
+
['maxLength', 'maxlength'],
|
507
|
+
['minLength', 'minlength'],
|
508
|
+
['noValidate', 'novalidate'],
|
509
|
+
['useMap', 'usemap'],
|
510
|
+
['htmlFor', 'for'],
|
511
|
+
]);
|
512
|
+
/**
|
513
|
+
* Map associating previously transformed HTML property into HTML attribute.
|
514
|
+
*/
|
515
|
+
const CACHED_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map();
|
516
|
+
/**
|
517
|
+
*
|
518
|
+
* @param propName
|
519
|
+
*/
|
520
|
+
function htmlPropertyToAttribute(propName) {
|
521
|
+
const ariaAttributeName = AriaPropNameToAttrNameMap[propName];
|
522
|
+
if (!isUndefined(ariaAttributeName)) {
|
523
|
+
return ariaAttributeName;
|
524
|
+
}
|
525
|
+
const specialAttributeName = SPECIAL_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
526
|
+
if (!isUndefined(specialAttributeName)) {
|
527
|
+
return specialAttributeName;
|
528
|
+
}
|
529
|
+
const cachedAttributeName = CACHED_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
530
|
+
if (!isUndefined(cachedAttributeName)) {
|
531
|
+
return cachedAttributeName;
|
532
|
+
}
|
533
|
+
let attributeName = '';
|
534
|
+
for (let i = 0, len = propName.length; i < len; i++) {
|
535
|
+
const code = StringCharCodeAt.call(propName, i);
|
536
|
+
if (code >= 65 && // "A"
|
537
|
+
code <= 90 // "Z"
|
538
|
+
) {
|
539
|
+
attributeName += '-' + StringFromCharCode(code + 32);
|
540
|
+
}
|
541
|
+
else {
|
542
|
+
attributeName += StringFromCharCode(code);
|
543
|
+
}
|
544
|
+
}
|
545
|
+
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
546
|
+
return attributeName;
|
547
|
+
}
|
427
548
|
|
428
549
|
/*
|
429
550
|
* Copyright (c) 2020, salesforce.com, inc.
|
@@ -482,7 +603,7 @@ function flattenStylesheets(stylesheets) {
|
|
482
603
|
}
|
483
604
|
return list;
|
484
605
|
}
|
485
|
-
/** version: 8.
|
606
|
+
/** version: 8.7.0 */
|
486
607
|
|
487
608
|
/*
|
488
609
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -643,21 +764,25 @@ const mutationTracker = new MutationTracker();
|
|
643
764
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
644
765
|
*/
|
645
766
|
/**
|
646
|
-
*
|
647
|
-
*
|
767
|
+
* Filters out the following types of properties that should not be set.
|
768
|
+
* - Properties that are not public.
|
769
|
+
* - Properties that are not global.
|
770
|
+
* - Properties that are global but are internally overridden.
|
648
771
|
*/
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
});
|
772
|
+
function filterProperties(props, publicFields, privateFields) {
|
773
|
+
const propsToAssign = create(null);
|
774
|
+
const publicFieldSet = new Set(publicFields);
|
775
|
+
const privateFieldSet = new Set(privateFields);
|
776
|
+
keys(props).forEach((propName) => {
|
777
|
+
const attrName = htmlPropertyToAttribute(propName);
|
778
|
+
if (publicFieldSet.has(propName) ||
|
779
|
+
((isGlobalHtmlAttribute(attrName) || isAriaAttribute(attrName)) &&
|
780
|
+
!privateFieldSet.has(propName))) {
|
781
|
+
propsToAssign[propName] = props[propName];
|
782
|
+
}
|
783
|
+
});
|
784
|
+
return propsToAssign;
|
785
|
+
}
|
661
786
|
/**
|
662
787
|
* Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
|
663
788
|
*/
|
@@ -738,16 +863,6 @@ const ariaDescriptor = (attrName) => ({
|
|
738
863
|
}
|
739
864
|
},
|
740
865
|
});
|
741
|
-
function reflectAttrToProp(instance, attrName, attrValue) {
|
742
|
-
const reflectedPropName = attrsToProps[attrName];
|
743
|
-
// If it is a reflected property and it was not overridden by the instance
|
744
|
-
if (reflectedPropName && !hasOwnProperty.call(instance, reflectedPropName)) {
|
745
|
-
const currentValue = instance[reflectedPropName];
|
746
|
-
if (currentValue !== attrValue) {
|
747
|
-
instance[reflectedPropName] = attrValue;
|
748
|
-
}
|
749
|
-
}
|
750
|
-
}
|
751
866
|
const descriptors = {
|
752
867
|
accessKey: stringDescriptor('accesskey'),
|
753
868
|
dir: stringDescriptor('dir'),
|
@@ -819,7 +934,6 @@ class LightningElement {
|
|
819
934
|
const normalizedName = StringToLowerCase.call(toString(attrName));
|
820
935
|
const normalizedValue = String(attrValue);
|
821
936
|
__classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
|
822
|
-
reflectAttrToProp(this, normalizedName, normalizedValue);
|
823
937
|
mutationTracker.add(this, normalizedName);
|
824
938
|
}
|
825
939
|
getAttribute(attrName) {
|
@@ -836,7 +950,6 @@ class LightningElement {
|
|
836
950
|
removeAttribute(attrName) {
|
837
951
|
const normalizedName = StringToLowerCase.call(toString(attrName));
|
838
952
|
delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
839
|
-
reflectAttrToProp(this, normalizedName, null);
|
840
953
|
// Track mutations for removal of non-existing attributes
|
841
954
|
mutationTracker.add(this, normalizedName);
|
842
955
|
}
|
@@ -1105,6 +1218,39 @@ function* toIteratorDirective(iterable) {
|
|
1105
1218
|
}
|
1106
1219
|
}
|
1107
1220
|
|
1108
|
-
|
1109
|
-
|
1221
|
+
/*
|
1222
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
1223
|
+
* All rights reserved.
|
1224
|
+
* SPDX-License-Identifier: MIT
|
1225
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1226
|
+
*/
|
1227
|
+
// Deep freeze and clone an object. Designed for cloning/freezing child props when passed from a parent to a child so
|
1228
|
+
// that they are immutable. This is one of the normal guarantees of both engine-dom and engine-server that we want to
|
1229
|
+
// emulate in ssr-runtime. The goal here is that a child cannot mutate the props of its parent and thus affect
|
1230
|
+
// the parent's rendering, which would lead to bidirectional reactivity and mischief.
|
1231
|
+
function cloneAndDeepFreeze(obj) {
|
1232
|
+
if (isArray(obj)) {
|
1233
|
+
const res = [];
|
1234
|
+
for (const item of obj) {
|
1235
|
+
ArrayPush.call(res, cloneAndDeepFreeze(item));
|
1236
|
+
}
|
1237
|
+
freeze(res);
|
1238
|
+
return res;
|
1239
|
+
}
|
1240
|
+
else if (isObject(obj) && !isNull(obj)) {
|
1241
|
+
const res = create(null);
|
1242
|
+
for (const [key, value] of entries(obj)) {
|
1243
|
+
res[key] = cloneAndDeepFreeze(value);
|
1244
|
+
}
|
1245
|
+
freeze(res);
|
1246
|
+
return res;
|
1247
|
+
}
|
1248
|
+
else {
|
1249
|
+
// primitive
|
1250
|
+
return obj;
|
1251
|
+
}
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
export { ClassList, LightningElement, SYMBOL__GENERATE_MARKUP, SYMBOL__SET_INTERNALS, api, cloneAndDeepFreeze, createContextProvider, createElement, fallbackTmpl, fallbackTmplNoYield, filterProperties, freezeTemplate, getComponentDef, hasScopedStaticStylesheets, hot, htmlEscape, isComponentConstructor, mutationTracker, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, renderAttrs, renderAttrsNoYield, serverSideRenderComponent as renderComponent, renderStylesheets, renderer, sanitizeAttribute, sanitizeHtmlContent, serverSideRenderComponent, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, toIteratorDirective, track, unwrap, validateStyleTextContents, wire };
|
1255
|
+
/** version: 8.7.0 */
|
1110
1256
|
//# sourceMappingURL=index.js.map
|