@lwc/ssr-runtime 8.4.0 → 8.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs.js +178 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +176 -28
- package/dist/index.js.map +1 -1
- package/dist/lightning-element.d.ts +12 -9
- package/dist/reflection.d.ts +1 -1
- package/dist/render.d.ts +5 -2
- package/dist/styles.d.ts +4 -0
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
@@ -150,6 +150,8 @@ defineProperty,
|
|
150
150
|
entries,
|
151
151
|
/** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
|
152
152
|
freeze,
|
153
|
+
/** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
|
154
|
+
fromEntries,
|
153
155
|
/** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
|
154
156
|
getOwnPropertyDescriptor,
|
155
157
|
/** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
|
@@ -332,7 +334,19 @@ function htmlEscape(str, attrMode = false) {
|
|
332
334
|
const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
|
333
335
|
return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
|
334
336
|
}
|
335
|
-
|
337
|
+
function flattenStylesheets(stylesheets) {
|
338
|
+
const list = [];
|
339
|
+
for (const stylesheet of stylesheets) {
|
340
|
+
if (!isArray(stylesheet)) {
|
341
|
+
list.push(stylesheet);
|
342
|
+
}
|
343
|
+
else {
|
344
|
+
list.push(...flattenStylesheets(stylesheet));
|
345
|
+
}
|
346
|
+
}
|
347
|
+
return list;
|
348
|
+
}
|
349
|
+
/** version: 8.5.0 */
|
336
350
|
|
337
351
|
/*
|
338
352
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -381,8 +395,102 @@ const mutationTracker = new MutationTracker();
|
|
381
395
|
* SPDX-License-Identifier: MIT
|
382
396
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
383
397
|
*/
|
384
|
-
|
385
|
-
|
398
|
+
/**
|
399
|
+
* Map of global attribute or ARIA attribute to the corresponding property name.
|
400
|
+
* Not all global attributes are included, just those from `HTMLElementTheGoodParts`.
|
401
|
+
*/
|
402
|
+
const attrsToProps = assign(create(null), {
|
403
|
+
accesskey: 'accessKey',
|
404
|
+
dir: 'dir',
|
405
|
+
draggable: 'draggable',
|
406
|
+
hidden: 'hidden',
|
407
|
+
id: 'id',
|
408
|
+
lang: 'lang',
|
409
|
+
spellcheck: 'spellcheck',
|
410
|
+
tabindex: 'tabIndex',
|
411
|
+
title: 'title',
|
412
|
+
...AriaAttrNameToPropNameMap,
|
413
|
+
});
|
414
|
+
/**
|
415
|
+
* Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
|
416
|
+
*/
|
417
|
+
const stringDescriptor = (attrName) => ({
|
418
|
+
configurable: true,
|
419
|
+
enumerable: true,
|
420
|
+
get() {
|
421
|
+
return this.getAttribute(attrName);
|
422
|
+
},
|
423
|
+
set(newValue) {
|
424
|
+
const currentValue = this.getAttribute(attrName);
|
425
|
+
const normalizedValue = String(newValue);
|
426
|
+
if (normalizedValue !== currentValue) {
|
427
|
+
this.setAttribute(attrName, normalizedValue);
|
428
|
+
}
|
429
|
+
},
|
430
|
+
});
|
431
|
+
/** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
|
432
|
+
const explicitBooleanDescriptor = (attrName, defaultValue) => ({
|
433
|
+
configurable: true,
|
434
|
+
enumerable: true,
|
435
|
+
get() {
|
436
|
+
const value = this.getAttribute(attrName);
|
437
|
+
return value === null ? defaultValue : value === String(defaultValue);
|
438
|
+
},
|
439
|
+
set(newValue) {
|
440
|
+
const currentValue = this.getAttribute(attrName);
|
441
|
+
const normalizedValue = String(Boolean(newValue));
|
442
|
+
if (normalizedValue !== currentValue) {
|
443
|
+
this.setAttribute(attrName, normalizedValue);
|
444
|
+
}
|
445
|
+
},
|
446
|
+
});
|
447
|
+
/**
|
448
|
+
* Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
|
449
|
+
*/
|
450
|
+
const booleanAttributeDescriptor = (attrName) => ({
|
451
|
+
configurable: true,
|
452
|
+
enumerable: true,
|
453
|
+
get() {
|
454
|
+
return this.hasAttribute(attrName);
|
455
|
+
},
|
456
|
+
set(newValue) {
|
457
|
+
const hasAttribute = this.hasAttribute(attrName);
|
458
|
+
if (newValue) {
|
459
|
+
if (!hasAttribute) {
|
460
|
+
this.setAttribute(attrName, '');
|
461
|
+
}
|
462
|
+
}
|
463
|
+
else {
|
464
|
+
if (hasAttribute) {
|
465
|
+
this.removeAttribute(attrName);
|
466
|
+
}
|
467
|
+
}
|
468
|
+
},
|
469
|
+
});
|
470
|
+
/**
|
471
|
+
* Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
|
472
|
+
*/
|
473
|
+
const ariaDescriptor = (attrName) => ({
|
474
|
+
configurable: true,
|
475
|
+
enumerable: true,
|
476
|
+
get() {
|
477
|
+
return this.getAttribute(attrName);
|
478
|
+
},
|
479
|
+
set(newValue) {
|
480
|
+
const currentValue = this.getAttribute(attrName);
|
481
|
+
if (newValue !== currentValue) {
|
482
|
+
// TODO [#3284]: According to the spec, IDL nullable type values
|
483
|
+
// (null and undefined) should remove the attribute; however, we
|
484
|
+
// only do so in the case of null for historical reasons.
|
485
|
+
if (isNull(newValue)) {
|
486
|
+
this.removeAttribute(attrName);
|
487
|
+
}
|
488
|
+
else {
|
489
|
+
this.setAttribute(attrName, toString(newValue));
|
490
|
+
}
|
491
|
+
}
|
492
|
+
},
|
493
|
+
});
|
386
494
|
function reflectAttrToProp(instance, attrName, attrValue) {
|
387
495
|
const reflectedPropName = attrsToProps[attrName];
|
388
496
|
// If it is a reflected property and it was not overridden by the instance
|
@@ -393,30 +501,34 @@ function reflectAttrToProp(instance, attrName, attrValue) {
|
|
393
501
|
}
|
394
502
|
}
|
395
503
|
}
|
396
|
-
const descriptors =
|
397
|
-
|
398
|
-
|
504
|
+
const descriptors = {
|
505
|
+
accessKey: stringDescriptor('accesskey'),
|
506
|
+
dir: stringDescriptor('dir'),
|
507
|
+
draggable: explicitBooleanDescriptor('draggable', true),
|
508
|
+
hidden: booleanAttributeDescriptor('hidden'),
|
509
|
+
id: stringDescriptor('id'),
|
510
|
+
lang: stringDescriptor('lang'),
|
511
|
+
spellcheck: explicitBooleanDescriptor('spellcheck', false),
|
512
|
+
tabIndex: {
|
399
513
|
get() {
|
400
|
-
|
514
|
+
const str = this.getAttribute('tabindex');
|
515
|
+
const num = Number(str);
|
516
|
+
return isFinite(num) ? Math.trunc(num) : -1;
|
401
517
|
},
|
402
518
|
set(newValue) {
|
403
|
-
const currentValue = this.getAttribute(
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
// See also https://github.com/w3c/aria/issues/1858
|
409
|
-
if (isNull(newValue)) {
|
410
|
-
this.removeAttribute(attrName);
|
411
|
-
}
|
412
|
-
else {
|
413
|
-
this.setAttribute(attrName, toString(newValue));
|
414
|
-
}
|
519
|
+
const currentValue = this.getAttribute('tabindex');
|
520
|
+
const num = Number(newValue);
|
521
|
+
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
522
|
+
if (normalizedValue !== currentValue) {
|
523
|
+
this.setAttribute('tabindex', toString(newValue));
|
415
524
|
}
|
416
525
|
},
|
417
|
-
|
418
|
-
|
419
|
-
|
526
|
+
},
|
527
|
+
title: stringDescriptor('title'),
|
528
|
+
};
|
529
|
+
// Add descriptors for ARIA attributes
|
530
|
+
for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
|
531
|
+
descriptors[propName] = ariaDescriptor(attrName);
|
420
532
|
}
|
421
533
|
|
422
534
|
/*
|
@@ -427,6 +539,7 @@ for (const [attrName, propName] of entries(attrsToProps)) {
|
|
427
539
|
*/
|
428
540
|
var _LightningElement_attrs, _LightningElement_classList;
|
429
541
|
const SYMBOL__SET_INTERNALS = Symbol('set-internals');
|
542
|
+
const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
|
430
543
|
class LightningElement {
|
431
544
|
constructor(propsAvailableAtConstruction) {
|
432
545
|
this.isConnected = false;
|
@@ -603,21 +716,26 @@ function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
|
|
603
716
|
emit('<template shadowrootmode="open"></template>');
|
604
717
|
}
|
605
718
|
}
|
606
|
-
async function serverSideRenderComponent(tagName,
|
719
|
+
async function serverSideRenderComponent(tagName, Component, props = {}, mode = 'asyncYield') {
|
720
|
+
if (typeof tagName !== 'string') {
|
721
|
+
throw new Error(`tagName must be a string, found: ${tagName}`);
|
722
|
+
}
|
723
|
+
// TODO [#4726]: remove `generateMarkup` export
|
724
|
+
const generateMarkup = SYMBOL__GENERATE_MARKUP in Component ? Component[SYMBOL__GENERATE_MARKUP] : Component;
|
607
725
|
let markup = '';
|
608
726
|
const emit = (segment) => {
|
609
727
|
markup += segment;
|
610
728
|
};
|
611
729
|
if (mode === 'asyncYield') {
|
612
|
-
for await (const segment of
|
730
|
+
for await (const segment of generateMarkup(tagName, props, null, null)) {
|
613
731
|
markup += segment;
|
614
732
|
}
|
615
733
|
}
|
616
734
|
else if (mode === 'async') {
|
617
|
-
await
|
735
|
+
await generateMarkup(emit, tagName, props, null, null);
|
618
736
|
}
|
619
737
|
else if (mode === 'sync') {
|
620
|
-
|
738
|
+
generateMarkup(emit, tagName, props, null, null);
|
621
739
|
}
|
622
740
|
else {
|
623
741
|
throw new Error(`Invalid mode: ${mode}`);
|
@@ -931,8 +1049,39 @@ function validateStyleTextContents(contents) {
|
|
931
1049
|
}
|
932
1050
|
}
|
933
1051
|
|
1052
|
+
/*
|
1053
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
1054
|
+
* All rights reserved.
|
1055
|
+
* SPDX-License-Identifier: MIT
|
1056
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1057
|
+
*/
|
1058
|
+
function hasScopedStaticStylesheets(Component) {
|
1059
|
+
const { stylesheets } = Component;
|
1060
|
+
if (stylesheets) {
|
1061
|
+
return flattenStylesheets(stylesheets).some((stylesheet) => stylesheet.$scoped$);
|
1062
|
+
}
|
1063
|
+
return false;
|
1064
|
+
}
|
1065
|
+
function renderStylesheets(stylesheets, scopeToken, Component, hasScopedTemplateStyles) {
|
1066
|
+
const hasAnyScopedStyles = hasScopedTemplateStyles || hasScopedStaticStylesheets(Component);
|
1067
|
+
let result = '';
|
1068
|
+
const truthyStylesheets = stylesheets.filter(Boolean);
|
1069
|
+
for (const stylesheet of flattenStylesheets(truthyStylesheets)) {
|
1070
|
+
// TODO [#2869]: `<style>`s should not have scope token classes
|
1071
|
+
result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} type="text/css">`;
|
1072
|
+
const token = stylesheet.$scoped$ ? scopeToken : undefined;
|
1073
|
+
const useActualHostSelector = !stylesheet.$scoped$ || Component.renderMode !== 'light';
|
1074
|
+
const useNativeDirPseudoclass = true;
|
1075
|
+
const styleContents = stylesheet(token, useActualHostSelector, useNativeDirPseudoclass);
|
1076
|
+
validateStyleTextContents(styleContents);
|
1077
|
+
result += styleContents + '</style>';
|
1078
|
+
}
|
1079
|
+
return result;
|
1080
|
+
}
|
1081
|
+
|
934
1082
|
exports.ClassList = ClassList;
|
935
1083
|
exports.LightningElement = LightningElement;
|
1084
|
+
exports.SYMBOL__GENERATE_MARKUP = SYMBOL__GENERATE_MARKUP;
|
936
1085
|
exports.SYMBOL__SET_INTERNALS = SYMBOL__SET_INTERNALS;
|
937
1086
|
exports.api = api;
|
938
1087
|
exports.createContextProvider = createContextProvider;
|
@@ -941,6 +1090,7 @@ exports.fallbackTmpl = fallbackTmpl;
|
|
941
1090
|
exports.fallbackTmplNoYield = fallbackTmplNoYield;
|
942
1091
|
exports.freezeTemplate = freezeTemplate;
|
943
1092
|
exports.getComponentDef = getComponentDef;
|
1093
|
+
exports.hasScopedStaticStylesheets = hasScopedStaticStylesheets;
|
944
1094
|
exports.hot = hot;
|
945
1095
|
exports.htmlEscape = htmlEscape;
|
946
1096
|
exports.isComponentConstructor = isComponentConstructor;
|
@@ -954,6 +1104,7 @@ exports.registerTemplate = registerTemplate;
|
|
954
1104
|
exports.renderAttrs = renderAttrs;
|
955
1105
|
exports.renderAttrsNoYield = renderAttrsNoYield;
|
956
1106
|
exports.renderComponent = serverSideRenderComponent;
|
1107
|
+
exports.renderStylesheets = renderStylesheets;
|
957
1108
|
exports.renderer = renderer;
|
958
1109
|
exports.sanitizeAttribute = sanitizeAttribute;
|
959
1110
|
exports.serverSideRenderComponent = serverSideRenderComponent;
|
@@ -968,5 +1119,5 @@ exports.track = track;
|
|
968
1119
|
exports.unwrap = unwrap;
|
969
1120
|
exports.validateStyleTextContents = validateStyleTextContents;
|
970
1121
|
exports.wire = wire;
|
971
|
-
/** version: 8.
|
1122
|
+
/** version: 8.5.0 */
|
972
1123
|
//# sourceMappingURL=index.cjs.js.map
|