@salesforce/lightning-out 2.3.0-rc.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +100 -26
- package/dist/index.iife.debug.js +100 -26
- package/dist/index.iife.prod.js +3 -3
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @salesforce/lightning-out v2.3.0
|
|
1
|
+
/*! @salesforce/lightning-out v2.3.0 (2026-10-30) */
|
|
2
2
|
/**
|
|
3
3
|
* Numeric ranks for {@link LogLevel}; lower values are more severe.
|
|
4
4
|
*/
|
|
@@ -1161,6 +1161,9 @@ const registry = new Registry();
|
|
|
1161
1161
|
* LightningOutComponent class for Lightning Out
|
|
1162
1162
|
*/
|
|
1163
1163
|
const logger$1 = new Logger("LightningOutComponent");
|
|
1164
|
+
// HTML accepts this diagnostic name, but older DOM setAttribute implementations reject it.
|
|
1165
|
+
const RUNTIME_MARKER_TEMPLATE = document.createElement("template");
|
|
1166
|
+
RUNTIME_MARKER_TEMPLATE.innerHTML = '<span --sfdc-runtime="isolated"></span>';
|
|
1164
1167
|
// These attributes are mirrored into the iframe
|
|
1165
1168
|
const MIRROR = new Set([
|
|
1166
1169
|
"autocapitalize",
|
|
@@ -1241,6 +1244,7 @@ class LightningOutComponent extends HTMLElement {
|
|
|
1241
1244
|
if (!this.componentReady) {
|
|
1242
1245
|
// We don't care about events.lo.iframe.ready, we care about messages.lo.ready
|
|
1243
1246
|
this.#loIFrame.load(this._getComponentURL().href);
|
|
1247
|
+
this.setAttributeNode(RUNTIME_MARKER_TEMPLATE.content.firstElementChild.attributes[0].cloneNode());
|
|
1244
1248
|
}
|
|
1245
1249
|
}
|
|
1246
1250
|
#messageListener = (event) => {
|
|
@@ -1335,6 +1339,10 @@ class LightningOutComponent extends HTMLElement {
|
|
|
1335
1339
|
#shouldObserveCallback = (attrOrPropName, isStandard) => {
|
|
1336
1340
|
const attrName = camelToKebab(attrOrPropName); // do this becaouse our config Sets are in kebab-case
|
|
1337
1341
|
logger$1.debug("#shouldObserveCallback:", { attrOrPropName, attrName, isStandard });
|
|
1342
|
+
// Host diagnostics are not properties of the embedded component.
|
|
1343
|
+
if (attrName === "--sfdc-runtime") {
|
|
1344
|
+
return false;
|
|
1345
|
+
}
|
|
1338
1346
|
if (isStandard) {
|
|
1339
1347
|
if (MIRROR.has(attrName) || ARIA_MIRROR.has(attrName)) {
|
|
1340
1348
|
return true;
|
|
@@ -1488,19 +1496,69 @@ class LightningOutComponent extends HTMLElement {
|
|
|
1488
1496
|
/**
|
|
1489
1497
|
* Router for handling Lightning Out component URLs
|
|
1490
1498
|
*/
|
|
1499
|
+
// Experience Cloud (CLWR) frontdoor URLs are minted under the site's Visualforce-sites auth path. This is an internal
|
|
1500
|
+
// Salesforce path, not a documented OAuth contract, so keep the heuristic here in one place. Group 1 is the path before
|
|
1501
|
+
// it, and #canonicalSitePrefix trims its slashes (trimming them in the regex backtracks badly on runs of slashes):
|
|
1502
|
+
// - "/site1vforcesite/secur/frontdoor.jsp" -> "/site1"
|
|
1503
|
+
// - "/site1/vforcesite/secur/frontdoor.jsp" -> "/site1"
|
|
1504
|
+
// - "/a/b/vforcesite/secur/frontdoor.jsp" -> "/a/b"
|
|
1505
|
+
// - "/vforcesite/secur/frontdoor.jsp" -> "" (a site published at the host root)
|
|
1506
|
+
// - "/secur/frontdoor.jsp" -> no match (My Domain)
|
|
1507
|
+
const CLWR_FRONTDOOR_PATH_REGEX = /^(.*?)vforcesite\/secur\//;
|
|
1491
1508
|
class LightningOutRouter {
|
|
1492
1509
|
config;
|
|
1493
1510
|
errorHandler;
|
|
1511
|
+
#sitePrefix;
|
|
1512
|
+
#sitePrefixWarning;
|
|
1494
1513
|
constructor(config, errorHandler) {
|
|
1495
1514
|
this.config = config;
|
|
1496
1515
|
this.errorHandler = errorHandler;
|
|
1497
1516
|
if (!this.config.origin) {
|
|
1498
1517
|
throw this.errorHandler(`Missing "frontdoor-url" or "org-url" attribute`);
|
|
1499
1518
|
}
|
|
1519
|
+
this.#sitePrefix = this.#resolveSitePrefix();
|
|
1520
|
+
}
|
|
1521
|
+
// Set when routing doesn't follow `site-prefix` as given. A login builds more than one router (its own, then one
|
|
1522
|
+
// after each iframe load), so the caller reports this once per login.
|
|
1523
|
+
get sitePrefixWarning() {
|
|
1524
|
+
return this.#sitePrefixWarning;
|
|
1525
|
+
}
|
|
1526
|
+
// `site-prefix` is what selects CLWR; `undefined` routes to LWR. A CLWR frontdoor URL also encodes the site prefix,
|
|
1527
|
+
// and it is the more accurate of the two (it's where the session was minted), so it wins when they disagree.
|
|
1528
|
+
#resolveSitePrefix() {
|
|
1529
|
+
const { sitePrefix, frontdoorUrl } = this.config;
|
|
1530
|
+
const frontdoorMatch = frontdoorUrl?.pathname.match(CLWR_FRONTDOOR_PATH_REGEX);
|
|
1531
|
+
if (!frontdoorMatch) {
|
|
1532
|
+
return sitePrefix === undefined ? undefined : this.#canonicalSitePrefix(sitePrefix);
|
|
1533
|
+
}
|
|
1534
|
+
const frontdoorSitePrefix = this.#canonicalSitePrefix(frontdoorMatch[1]);
|
|
1535
|
+
if (sitePrefix === undefined) {
|
|
1536
|
+
this.#sitePrefixWarning =
|
|
1537
|
+
`"frontdoor-url" is for an Experience Cloud site, but "site-prefix" isn't set, so components can't ` +
|
|
1538
|
+
`load from the site. Set site-prefix="${frontdoorSitePrefix}".`;
|
|
1539
|
+
return undefined;
|
|
1540
|
+
}
|
|
1541
|
+
if (this.#canonicalSitePrefix(sitePrefix) !== frontdoorSitePrefix) {
|
|
1542
|
+
this.#sitePrefixWarning =
|
|
1543
|
+
`"site-prefix" ("${sitePrefix}") doesn't match the site in "frontdoor-url", so Lightning Out uses ` +
|
|
1544
|
+
`that site. Set site-prefix="${frontdoorSitePrefix}".`;
|
|
1545
|
+
}
|
|
1546
|
+
return frontdoorSitePrefix;
|
|
1547
|
+
}
|
|
1548
|
+
// "" for a site at the host root, otherwise "/<prefix>", so prefixes compare equal however they're written and
|
|
1549
|
+
// `${sitePrefix}/lightning-out` has no empty path segment: "/" would otherwise give "//lightning-out", and "site1/"
|
|
1550
|
+
// "/site1//lightning-out". Surrounding whitespace is ignored, and backslashes, which URLs read as slashes, count as
|
|
1551
|
+
// separators: "/site1/" -> "/site1", "a\b" -> "/a/b", "/" -> "".
|
|
1552
|
+
#canonicalSitePrefix(sitePrefix) {
|
|
1553
|
+
const segments = sitePrefix
|
|
1554
|
+
.trim()
|
|
1555
|
+
.split(/[/\\]+/)
|
|
1556
|
+
.filter(Boolean);
|
|
1557
|
+
return segments.length ? `/${segments.join("/")}` : "";
|
|
1500
1558
|
}
|
|
1501
1559
|
getComponentURL(componentName, parentElementId) {
|
|
1502
1560
|
let appURL;
|
|
1503
|
-
if (this
|
|
1561
|
+
if (this.#sitePrefix === undefined) {
|
|
1504
1562
|
// Route to LWR
|
|
1505
1563
|
let lwrApp = componentName.includes("/")
|
|
1506
1564
|
? this.config.lwrAppComp
|
|
@@ -1515,15 +1573,18 @@ class LightningOutRouter {
|
|
|
1515
1573
|
appURL = new URL(`lwr/application/amd/0/${lang}ai/${lwrApp}`, this.config.origin);
|
|
1516
1574
|
}
|
|
1517
1575
|
else {
|
|
1518
|
-
// Route to CLWR. Note: sitePrefix may be blank and that's okay.
|
|
1519
|
-
|
|
1576
|
+
// Route to CLWR. Note: sitePrefix may be blank and that's okay. Set the pathname, rather than resolving
|
|
1577
|
+
// against the origin, so the host can't change whatever the prefix contains: URL parsing drops tabs and
|
|
1578
|
+
// newlines anywhere, so "/\t/host" would resolve to "//host".
|
|
1579
|
+
appURL = new URL(this.config.origin);
|
|
1580
|
+
appURL.pathname = `${this.#sitePrefix}/lightning-out`;
|
|
1520
1581
|
}
|
|
1521
1582
|
appURL.searchParams.set("componentName", componentName);
|
|
1522
1583
|
return this.#addCommonParams(appURL, parentElementId);
|
|
1523
1584
|
}
|
|
1524
1585
|
getAuthURL(parentElementId) {
|
|
1525
1586
|
let appURL;
|
|
1526
|
-
if (this
|
|
1587
|
+
if (this.#sitePrefix === undefined) {
|
|
1527
1588
|
// Route to LWR
|
|
1528
1589
|
const lwrApp = this.config.lwrAppAuth.replace("/", "%2F"); // ¯\_(ツ)_/¯
|
|
1529
1590
|
appURL = new URL(`lwr/application/amd/0/ai/${lwrApp}`, this.config.origin);
|
|
@@ -1542,7 +1603,7 @@ class LightningOutRouter {
|
|
|
1542
1603
|
url.searchParams.set("parentElementId", parentElementId);
|
|
1543
1604
|
url.searchParams.set("loAppOrigin", this.config.loAppOrigin);
|
|
1544
1605
|
// This helps in general but also for cache busting
|
|
1545
|
-
url.searchParams.set("loVersion", "2.3.0
|
|
1606
|
+
url.searchParams.set("loVersion", "2.3.0");
|
|
1546
1607
|
if (this.config.appId) {
|
|
1547
1608
|
url.searchParams.set("appId", this.config.appId);
|
|
1548
1609
|
}
|
|
@@ -1640,11 +1701,19 @@ class LightningOutApplication extends HTMLElement {
|
|
|
1640
1701
|
}));
|
|
1641
1702
|
}
|
|
1642
1703
|
#login(frontdoorUrl) {
|
|
1704
|
+
// Components that connect before the new session's iframe loads keep the current session's router, on the
|
|
1705
|
+
// origin its iframe reported (for example the Lightning domain), so cache it before the fields below change
|
|
1706
|
+
if (this.applicationReady) {
|
|
1707
|
+
this.getRouter();
|
|
1708
|
+
}
|
|
1709
|
+
let router;
|
|
1643
1710
|
try {
|
|
1644
1711
|
this.#frontdoorUrl = new URL(frontdoorUrl);
|
|
1645
1712
|
this.#lwrAppOrigin = this.#frontdoorUrl.origin;
|
|
1646
|
-
|
|
1647
|
-
|
|
1713
|
+
// Build this login's URLs, and check site-prefix, against the new frontdoor URL
|
|
1714
|
+
router = this.#createRouter();
|
|
1715
|
+
const startURL = router.getAuthURL(this._uuid);
|
|
1716
|
+
const authErrorPage = router.getPageURL(this.#lwrPageAuthError, this._uuid);
|
|
1648
1717
|
const errorRedirectUri = authErrorPage.pathname + authErrorPage.search;
|
|
1649
1718
|
// "High Assurance session required at login" (W-24017576)
|
|
1650
1719
|
startURL.searchParams.set("error-redirect-uri", errorRedirectUri);
|
|
@@ -1658,6 +1727,9 @@ class LightningOutApplication extends HTMLElement {
|
|
|
1658
1727
|
catch {
|
|
1659
1728
|
throw this.#loError.create(`Invalid frontdoor-url: ${frontdoorUrl}`);
|
|
1660
1729
|
}
|
|
1730
|
+
if (router.sitePrefixWarning) {
|
|
1731
|
+
logger.warn(router.sitePrefixWarning);
|
|
1732
|
+
}
|
|
1661
1733
|
this.#loIFrame.load(this.#frontdoorUrl.href);
|
|
1662
1734
|
}
|
|
1663
1735
|
#logout() {
|
|
@@ -1669,29 +1741,30 @@ class LightningOutApplication extends HTMLElement {
|
|
|
1669
1741
|
}
|
|
1670
1742
|
getRouter() {
|
|
1671
1743
|
if (this.#loRouter === undefined) {
|
|
1672
|
-
|
|
1673
|
-
origin: this.#lwrAppOrigin,
|
|
1674
|
-
lwrPageAuth: this.#lwrPageAuth,
|
|
1675
|
-
lwrAppAuth: this.#lwrAppAuth,
|
|
1676
|
-
lwrAppComp: this.#lwrAppComp,
|
|
1677
|
-
lwrAppAura: this.#lwrAppAura,
|
|
1678
|
-
sitePrefix: this.#sitePrefix,
|
|
1679
|
-
lang: this.#lang,
|
|
1680
|
-
appId: this.#appId,
|
|
1681
|
-
testMode: this.__testMode || "prod" === "test",
|
|
1682
|
-
loAppOrigin: window.location.origin,
|
|
1683
|
-
designSystem: this.#designSystem,
|
|
1684
|
-
globalStyle: this.#globalStyle,
|
|
1685
|
-
};
|
|
1686
|
-
this.#loRouter = new LightningOutRouter(config, (msg) => this.#loError.create(msg));
|
|
1744
|
+
this.#loRouter = this.#createRouter();
|
|
1687
1745
|
}
|
|
1688
1746
|
return this.#loRouter;
|
|
1689
1747
|
}
|
|
1690
1748
|
_getComponentURL(componentName, parentElementId) {
|
|
1691
1749
|
return this.getRouter().getComponentURL(componentName, parentElementId);
|
|
1692
1750
|
}
|
|
1693
|
-
#
|
|
1694
|
-
|
|
1751
|
+
#createRouter() {
|
|
1752
|
+
const config = {
|
|
1753
|
+
origin: this.#lwrAppOrigin,
|
|
1754
|
+
frontdoorUrl: this.#frontdoorUrl,
|
|
1755
|
+
lwrPageAuth: this.#lwrPageAuth,
|
|
1756
|
+
lwrAppAuth: this.#lwrAppAuth,
|
|
1757
|
+
lwrAppComp: this.#lwrAppComp,
|
|
1758
|
+
lwrAppAura: this.#lwrAppAura,
|
|
1759
|
+
sitePrefix: this.#sitePrefix,
|
|
1760
|
+
lang: this.#lang,
|
|
1761
|
+
appId: this.#appId,
|
|
1762
|
+
testMode: this.__testMode || "prod" === "test",
|
|
1763
|
+
loAppOrigin: window.location.origin,
|
|
1764
|
+
designSystem: this.#designSystem,
|
|
1765
|
+
globalStyle: this.#globalStyle,
|
|
1766
|
+
};
|
|
1767
|
+
return new LightningOutRouter(config, (msg) => this.#loError.create(msg));
|
|
1695
1768
|
}
|
|
1696
1769
|
#getPageURL(pagePathname) {
|
|
1697
1770
|
return this.getRouter().getPageURL(pagePathname, this._uuid);
|
|
@@ -1927,7 +2000,8 @@ class LightningOutApplication extends HTMLElement {
|
|
|
1927
2000
|
};
|
|
1928
2001
|
_propertyChanged_sitePrefix = (sitePrefix) => {
|
|
1929
2002
|
if (sitePrefix !== undefined) {
|
|
1930
|
-
|
|
2003
|
+
// A removed attribute is reported as null, which means unset
|
|
2004
|
+
this.#sitePrefix = sitePrefix ?? undefined;
|
|
1931
2005
|
}
|
|
1932
2006
|
};
|
|
1933
2007
|
_propertyChanged_appId = (appId) => {
|
package/dist/index.iife.debug.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @salesforce/lightning-out v2.3.0
|
|
1
|
+
/*! @salesforce/lightning-out v2.3.0 (2026-10-30) */
|
|
2
2
|
var LO2 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -1164,6 +1164,9 @@ var LO2 = (function (exports) {
|
|
|
1164
1164
|
* LightningOutComponent class for Lightning Out
|
|
1165
1165
|
*/
|
|
1166
1166
|
const logger$1 = new Logger("LightningOutComponent");
|
|
1167
|
+
// HTML accepts this diagnostic name, but older DOM setAttribute implementations reject it.
|
|
1168
|
+
const RUNTIME_MARKER_TEMPLATE = document.createElement("template");
|
|
1169
|
+
RUNTIME_MARKER_TEMPLATE.innerHTML = '<span --sfdc-runtime="isolated"></span>';
|
|
1167
1170
|
// These attributes are mirrored into the iframe
|
|
1168
1171
|
const MIRROR = new Set([
|
|
1169
1172
|
"autocapitalize",
|
|
@@ -1244,6 +1247,7 @@ var LO2 = (function (exports) {
|
|
|
1244
1247
|
if (!this.componentReady) {
|
|
1245
1248
|
// We don't care about events.lo.iframe.ready, we care about messages.lo.ready
|
|
1246
1249
|
this.#loIFrame.load(this._getComponentURL().href);
|
|
1250
|
+
this.setAttributeNode(RUNTIME_MARKER_TEMPLATE.content.firstElementChild.attributes[0].cloneNode());
|
|
1247
1251
|
}
|
|
1248
1252
|
}
|
|
1249
1253
|
#messageListener = (event) => {
|
|
@@ -1338,6 +1342,10 @@ var LO2 = (function (exports) {
|
|
|
1338
1342
|
#shouldObserveCallback = (attrOrPropName, isStandard) => {
|
|
1339
1343
|
const attrName = camelToKebab(attrOrPropName); // do this becaouse our config Sets are in kebab-case
|
|
1340
1344
|
logger$1.debug("#shouldObserveCallback:", { attrOrPropName, attrName, isStandard });
|
|
1345
|
+
// Host diagnostics are not properties of the embedded component.
|
|
1346
|
+
if (attrName === "--sfdc-runtime") {
|
|
1347
|
+
return false;
|
|
1348
|
+
}
|
|
1341
1349
|
if (isStandard) {
|
|
1342
1350
|
if (MIRROR.has(attrName) || ARIA_MIRROR.has(attrName)) {
|
|
1343
1351
|
return true;
|
|
@@ -1491,19 +1499,69 @@ var LO2 = (function (exports) {
|
|
|
1491
1499
|
/**
|
|
1492
1500
|
* Router for handling Lightning Out component URLs
|
|
1493
1501
|
*/
|
|
1502
|
+
// Experience Cloud (CLWR) frontdoor URLs are minted under the site's Visualforce-sites auth path. This is an internal
|
|
1503
|
+
// Salesforce path, not a documented OAuth contract, so keep the heuristic here in one place. Group 1 is the path before
|
|
1504
|
+
// it, and #canonicalSitePrefix trims its slashes (trimming them in the regex backtracks badly on runs of slashes):
|
|
1505
|
+
// - "/site1vforcesite/secur/frontdoor.jsp" -> "/site1"
|
|
1506
|
+
// - "/site1/vforcesite/secur/frontdoor.jsp" -> "/site1"
|
|
1507
|
+
// - "/a/b/vforcesite/secur/frontdoor.jsp" -> "/a/b"
|
|
1508
|
+
// - "/vforcesite/secur/frontdoor.jsp" -> "" (a site published at the host root)
|
|
1509
|
+
// - "/secur/frontdoor.jsp" -> no match (My Domain)
|
|
1510
|
+
const CLWR_FRONTDOOR_PATH_REGEX = /^(.*?)vforcesite\/secur\//;
|
|
1494
1511
|
class LightningOutRouter {
|
|
1495
1512
|
config;
|
|
1496
1513
|
errorHandler;
|
|
1514
|
+
#sitePrefix;
|
|
1515
|
+
#sitePrefixWarning;
|
|
1497
1516
|
constructor(config, errorHandler) {
|
|
1498
1517
|
this.config = config;
|
|
1499
1518
|
this.errorHandler = errorHandler;
|
|
1500
1519
|
if (!this.config.origin) {
|
|
1501
1520
|
throw this.errorHandler(`Missing "frontdoor-url" or "org-url" attribute`);
|
|
1502
1521
|
}
|
|
1522
|
+
this.#sitePrefix = this.#resolveSitePrefix();
|
|
1523
|
+
}
|
|
1524
|
+
// Set when routing doesn't follow `site-prefix` as given. A login builds more than one router (its own, then one
|
|
1525
|
+
// after each iframe load), so the caller reports this once per login.
|
|
1526
|
+
get sitePrefixWarning() {
|
|
1527
|
+
return this.#sitePrefixWarning;
|
|
1528
|
+
}
|
|
1529
|
+
// `site-prefix` is what selects CLWR; `undefined` routes to LWR. A CLWR frontdoor URL also encodes the site prefix,
|
|
1530
|
+
// and it is the more accurate of the two (it's where the session was minted), so it wins when they disagree.
|
|
1531
|
+
#resolveSitePrefix() {
|
|
1532
|
+
const { sitePrefix, frontdoorUrl } = this.config;
|
|
1533
|
+
const frontdoorMatch = frontdoorUrl?.pathname.match(CLWR_FRONTDOOR_PATH_REGEX);
|
|
1534
|
+
if (!frontdoorMatch) {
|
|
1535
|
+
return sitePrefix === undefined ? undefined : this.#canonicalSitePrefix(sitePrefix);
|
|
1536
|
+
}
|
|
1537
|
+
const frontdoorSitePrefix = this.#canonicalSitePrefix(frontdoorMatch[1]);
|
|
1538
|
+
if (sitePrefix === undefined) {
|
|
1539
|
+
this.#sitePrefixWarning =
|
|
1540
|
+
`"frontdoor-url" is for an Experience Cloud site, but "site-prefix" isn't set, so components can't ` +
|
|
1541
|
+
`load from the site. Set site-prefix="${frontdoorSitePrefix}".`;
|
|
1542
|
+
return undefined;
|
|
1543
|
+
}
|
|
1544
|
+
if (this.#canonicalSitePrefix(sitePrefix) !== frontdoorSitePrefix) {
|
|
1545
|
+
this.#sitePrefixWarning =
|
|
1546
|
+
`"site-prefix" ("${sitePrefix}") doesn't match the site in "frontdoor-url", so Lightning Out uses ` +
|
|
1547
|
+
`that site. Set site-prefix="${frontdoorSitePrefix}".`;
|
|
1548
|
+
}
|
|
1549
|
+
return frontdoorSitePrefix;
|
|
1550
|
+
}
|
|
1551
|
+
// "" for a site at the host root, otherwise "/<prefix>", so prefixes compare equal however they're written and
|
|
1552
|
+
// `${sitePrefix}/lightning-out` has no empty path segment: "/" would otherwise give "//lightning-out", and "site1/"
|
|
1553
|
+
// "/site1//lightning-out". Surrounding whitespace is ignored, and backslashes, which URLs read as slashes, count as
|
|
1554
|
+
// separators: "/site1/" -> "/site1", "a\b" -> "/a/b", "/" -> "".
|
|
1555
|
+
#canonicalSitePrefix(sitePrefix) {
|
|
1556
|
+
const segments = sitePrefix
|
|
1557
|
+
.trim()
|
|
1558
|
+
.split(/[/\\]+/)
|
|
1559
|
+
.filter(Boolean);
|
|
1560
|
+
return segments.length ? `/${segments.join("/")}` : "";
|
|
1503
1561
|
}
|
|
1504
1562
|
getComponentURL(componentName, parentElementId) {
|
|
1505
1563
|
let appURL;
|
|
1506
|
-
if (this
|
|
1564
|
+
if (this.#sitePrefix === undefined) {
|
|
1507
1565
|
// Route to LWR
|
|
1508
1566
|
let lwrApp = componentName.includes("/")
|
|
1509
1567
|
? this.config.lwrAppComp
|
|
@@ -1518,15 +1576,18 @@ var LO2 = (function (exports) {
|
|
|
1518
1576
|
appURL = new URL(`lwr/application/amd/0/${lang}ai/${lwrApp}`, this.config.origin);
|
|
1519
1577
|
}
|
|
1520
1578
|
else {
|
|
1521
|
-
// Route to CLWR. Note: sitePrefix may be blank and that's okay.
|
|
1522
|
-
|
|
1579
|
+
// Route to CLWR. Note: sitePrefix may be blank and that's okay. Set the pathname, rather than resolving
|
|
1580
|
+
// against the origin, so the host can't change whatever the prefix contains: URL parsing drops tabs and
|
|
1581
|
+
// newlines anywhere, so "/\t/host" would resolve to "//host".
|
|
1582
|
+
appURL = new URL(this.config.origin);
|
|
1583
|
+
appURL.pathname = `${this.#sitePrefix}/lightning-out`;
|
|
1523
1584
|
}
|
|
1524
1585
|
appURL.searchParams.set("componentName", componentName);
|
|
1525
1586
|
return this.#addCommonParams(appURL, parentElementId);
|
|
1526
1587
|
}
|
|
1527
1588
|
getAuthURL(parentElementId) {
|
|
1528
1589
|
let appURL;
|
|
1529
|
-
if (this
|
|
1590
|
+
if (this.#sitePrefix === undefined) {
|
|
1530
1591
|
// Route to LWR
|
|
1531
1592
|
const lwrApp = this.config.lwrAppAuth.replace("/", "%2F"); // ¯\_(ツ)_/¯
|
|
1532
1593
|
appURL = new URL(`lwr/application/amd/0/ai/${lwrApp}`, this.config.origin);
|
|
@@ -1545,7 +1606,7 @@ var LO2 = (function (exports) {
|
|
|
1545
1606
|
url.searchParams.set("parentElementId", parentElementId);
|
|
1546
1607
|
url.searchParams.set("loAppOrigin", this.config.loAppOrigin);
|
|
1547
1608
|
// This helps in general but also for cache busting
|
|
1548
|
-
url.searchParams.set("loVersion", "2.3.0
|
|
1609
|
+
url.searchParams.set("loVersion", "2.3.0");
|
|
1549
1610
|
if (this.config.appId) {
|
|
1550
1611
|
url.searchParams.set("appId", this.config.appId);
|
|
1551
1612
|
}
|
|
@@ -1643,11 +1704,19 @@ var LO2 = (function (exports) {
|
|
|
1643
1704
|
}));
|
|
1644
1705
|
}
|
|
1645
1706
|
#login(frontdoorUrl) {
|
|
1707
|
+
// Components that connect before the new session's iframe loads keep the current session's router, on the
|
|
1708
|
+
// origin its iframe reported (for example the Lightning domain), so cache it before the fields below change
|
|
1709
|
+
if (this.applicationReady) {
|
|
1710
|
+
this.getRouter();
|
|
1711
|
+
}
|
|
1712
|
+
let router;
|
|
1646
1713
|
try {
|
|
1647
1714
|
this.#frontdoorUrl = new URL(frontdoorUrl);
|
|
1648
1715
|
this.#lwrAppOrigin = this.#frontdoorUrl.origin;
|
|
1649
|
-
|
|
1650
|
-
|
|
1716
|
+
// Build this login's URLs, and check site-prefix, against the new frontdoor URL
|
|
1717
|
+
router = this.#createRouter();
|
|
1718
|
+
const startURL = router.getAuthURL(this._uuid);
|
|
1719
|
+
const authErrorPage = router.getPageURL(this.#lwrPageAuthError, this._uuid);
|
|
1651
1720
|
const errorRedirectUri = authErrorPage.pathname + authErrorPage.search;
|
|
1652
1721
|
// "High Assurance session required at login" (W-24017576)
|
|
1653
1722
|
startURL.searchParams.set("error-redirect-uri", errorRedirectUri);
|
|
@@ -1661,6 +1730,9 @@ var LO2 = (function (exports) {
|
|
|
1661
1730
|
catch {
|
|
1662
1731
|
throw this.#loError.create(`Invalid frontdoor-url: ${frontdoorUrl}`);
|
|
1663
1732
|
}
|
|
1733
|
+
if (router.sitePrefixWarning) {
|
|
1734
|
+
logger.warn(router.sitePrefixWarning);
|
|
1735
|
+
}
|
|
1664
1736
|
this.#loIFrame.load(this.#frontdoorUrl.href);
|
|
1665
1737
|
}
|
|
1666
1738
|
#logout() {
|
|
@@ -1672,29 +1744,30 @@ var LO2 = (function (exports) {
|
|
|
1672
1744
|
}
|
|
1673
1745
|
getRouter() {
|
|
1674
1746
|
if (this.#loRouter === undefined) {
|
|
1675
|
-
|
|
1676
|
-
origin: this.#lwrAppOrigin,
|
|
1677
|
-
lwrPageAuth: this.#lwrPageAuth,
|
|
1678
|
-
lwrAppAuth: this.#lwrAppAuth,
|
|
1679
|
-
lwrAppComp: this.#lwrAppComp,
|
|
1680
|
-
lwrAppAura: this.#lwrAppAura,
|
|
1681
|
-
sitePrefix: this.#sitePrefix,
|
|
1682
|
-
lang: this.#lang,
|
|
1683
|
-
appId: this.#appId,
|
|
1684
|
-
testMode: this.__testMode || "debug" === "test",
|
|
1685
|
-
loAppOrigin: window.location.origin,
|
|
1686
|
-
designSystem: this.#designSystem,
|
|
1687
|
-
globalStyle: this.#globalStyle,
|
|
1688
|
-
};
|
|
1689
|
-
this.#loRouter = new LightningOutRouter(config, (msg) => this.#loError.create(msg));
|
|
1747
|
+
this.#loRouter = this.#createRouter();
|
|
1690
1748
|
}
|
|
1691
1749
|
return this.#loRouter;
|
|
1692
1750
|
}
|
|
1693
1751
|
_getComponentURL(componentName, parentElementId) {
|
|
1694
1752
|
return this.getRouter().getComponentURL(componentName, parentElementId);
|
|
1695
1753
|
}
|
|
1696
|
-
#
|
|
1697
|
-
|
|
1754
|
+
#createRouter() {
|
|
1755
|
+
const config = {
|
|
1756
|
+
origin: this.#lwrAppOrigin,
|
|
1757
|
+
frontdoorUrl: this.#frontdoorUrl,
|
|
1758
|
+
lwrPageAuth: this.#lwrPageAuth,
|
|
1759
|
+
lwrAppAuth: this.#lwrAppAuth,
|
|
1760
|
+
lwrAppComp: this.#lwrAppComp,
|
|
1761
|
+
lwrAppAura: this.#lwrAppAura,
|
|
1762
|
+
sitePrefix: this.#sitePrefix,
|
|
1763
|
+
lang: this.#lang,
|
|
1764
|
+
appId: this.#appId,
|
|
1765
|
+
testMode: this.__testMode || "debug" === "test",
|
|
1766
|
+
loAppOrigin: window.location.origin,
|
|
1767
|
+
designSystem: this.#designSystem,
|
|
1768
|
+
globalStyle: this.#globalStyle,
|
|
1769
|
+
};
|
|
1770
|
+
return new LightningOutRouter(config, (msg) => this.#loError.create(msg));
|
|
1698
1771
|
}
|
|
1699
1772
|
#getPageURL(pagePathname) {
|
|
1700
1773
|
return this.getRouter().getPageURL(pagePathname, this._uuid);
|
|
@@ -1930,7 +2003,8 @@ var LO2 = (function (exports) {
|
|
|
1930
2003
|
};
|
|
1931
2004
|
_propertyChanged_sitePrefix = (sitePrefix) => {
|
|
1932
2005
|
if (sitePrefix !== undefined) {
|
|
1933
|
-
|
|
2006
|
+
// A removed attribute is reported as null, which means unset
|
|
2007
|
+
this.#sitePrefix = sitePrefix ?? undefined;
|
|
1934
2008
|
}
|
|
1935
2009
|
};
|
|
1936
2010
|
_propertyChanged_appId = (appId) => {
|
package/dist/index.iife.prod.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @salesforce/lightning-out v2.3.0
|
|
2
|
-
var LO2=function(e){"use strict";const t={error:0,warn:1,info:2,debug:3,trace:4};class i{static#e="LO2";static#t="error";#i;static set level(e){this.#t=e}static set prefix(e){this.#e=e}get brand(){return`${i.#e}:${this.#i}:`}constructor(e){this.#i="string"==typeof e?e:e.constructor?.name}error(...e){t.error<=t[i.#t]&&console.error(this.brand,...e)}warn(...e){t.warn<=t[i.#t]&&console.warn(this.brand,...e)}info(...e){t.info<=t[i.#t]&&console.info(this.brand,...e)}debug(...e){t.debug<=t[i.#t]&&console.debug(this.brand,...e)}trace(...e){t.trace<=t[i.#t]&&console.trace(this.brand,...e)}}function r(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(36)}const s={application:{ready:"lo.application.ready",error:"lo.application.error",logout:"lo.application.logout",auth:{redirect:"lo.application.auth.redirect"},session:{refresh:"lo.application.session.refresh"}},component:{ready:"lo.component.ready",error:"lo.component.error"},iframe:{load:"lo.iframe.load",error:"lo.iframe.error",logout:"lo.iframe.logout",auth:{redirect:"lo.iframe.auth.redirect"}}},o={addEventListener:"lo.addEventListener",authReload:"lo.auth.reload",dispatchEvent:"lo.dispatchEvent",error:"lo.error",getComponentData:"lo.getComponentData",loaded:"lo.loaded",logout:"lo.logout",ready:"lo.ready",redirect:"lo.redirect",removeEventListener:"lo.removeEventListener",resize:"lo.resize",sessionExpiry:"lo.sessionExpiry",sessionExpiryResponse:"lo.sessionExpiry.response",setComponentData:"lo.setComponentData",setComponentProps:"lo.setComponentProps"},n=new i("LightningOutError"),a="Session not ready",h="Session timeout",l="Session failed: iframe error",d="Malformed sessionExpiry response",c="Session terminated",p="Session APIs are not supported in org-url mode";class m{#r;#i;constructor(e){this.#i="string"==typeof e?e:e.constructor?.name,"function"==typeof e.dispatchEvent&&(this.#r=e)}#s(e){return`${this.#i}: ${e}`}create(e){const t="string"==typeof e?e:e.message;return new Error(this.#s(t))}dispatch(e,t){const i="string"==typeof t?t:t.message||t.detail?.message;if(this.#r){const r=t.detail||{message:this.#s(i),originalError:t},s=new CustomEvent(e,{detail:r});this.#r.dispatchEvent(s),n.error(`${this.#s("dispatched error")} -> ${e}: ${i}`)}else n.error(`${this.#s("unable to dispatch error on a non-EventTarget object")} -> ${e}: ${i}`)}}const u=new m("LightningOutUtils");function g(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function f(e,t=!1){if(/[A-Z]/.test(e))throw u.create(`elementNameToStandardName: "${e}" is not a valid custom element name - must be all lowercase.`);const i=e.indexOf("-");if(-1===i)throw u.create(`elementNameToStandardName: "${e}" is not a valid custom element name - missing hyphen character.`);return`${function(e){if(/[A-Z]/.test(e))throw u.create(`snakeToCamel: "${e}" is not valid snake_case - must be all lowercase.`);return e.replace(/_([a-z_])/g,(e,t)=>t.toUpperCase())}(e.slice(0,i))}${t?":":"/"}${function(e){if(/[A-Z]/.test(e))throw u.create(`kebabToCamel: "${e}" is not valid kebab-case - must be all lowercase.`);return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}(e.slice(i+1))}`}function v(e){return e.startsWith("$$")}function b(e,t){const i=Object.entries(t).map(t=>{let[i,r]=t;const s=i.split("dataMirror");2===s.length&&""===s[0]&&(i=s[1].charAt(0).toLowerCase()+s[1].slice(1));const o=`_propertyChanged_${i}`;if("function"==typeof e[o]){r=(0,e[o])(r)}return[i,r]});return Object.fromEntries(i)}const w=new i("LightningOutIFrame");class y{#o;#n;#a;#h="display:none";#l="border:0px; width:100%; height:100%; overflow:auto;";#d;#c;#p;#m;#u;#g;constructor(e){this.#o=e.parentElement,this.#n=e.parentElement instanceof
|
|
1
|
+
/*! @salesforce/lightning-out v2.3.0 (2026-10-30) */
|
|
2
|
+
var LO2=function(e){"use strict";const t={error:0,warn:1,info:2,debug:3,trace:4};class i{static#e="LO2";static#t="error";#i;static set level(e){this.#t=e}static set prefix(e){this.#e=e}get brand(){return`${i.#e}:${this.#i}:`}constructor(e){this.#i="string"==typeof e?e:e.constructor?.name}error(...e){t.error<=t[i.#t]&&console.error(this.brand,...e)}warn(...e){t.warn<=t[i.#t]&&console.warn(this.brand,...e)}info(...e){t.info<=t[i.#t]&&console.info(this.brand,...e)}debug(...e){t.debug<=t[i.#t]&&console.debug(this.brand,...e)}trace(...e){t.trace<=t[i.#t]&&console.trace(this.brand,...e)}}function r(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(36)}const s={application:{ready:"lo.application.ready",error:"lo.application.error",logout:"lo.application.logout",auth:{redirect:"lo.application.auth.redirect"},session:{refresh:"lo.application.session.refresh"}},component:{ready:"lo.component.ready",error:"lo.component.error"},iframe:{load:"lo.iframe.load",error:"lo.iframe.error",logout:"lo.iframe.logout",auth:{redirect:"lo.iframe.auth.redirect"}}},o={addEventListener:"lo.addEventListener",authReload:"lo.auth.reload",dispatchEvent:"lo.dispatchEvent",error:"lo.error",getComponentData:"lo.getComponentData",loaded:"lo.loaded",logout:"lo.logout",ready:"lo.ready",redirect:"lo.redirect",removeEventListener:"lo.removeEventListener",resize:"lo.resize",sessionExpiry:"lo.sessionExpiry",sessionExpiryResponse:"lo.sessionExpiry.response",setComponentData:"lo.setComponentData",setComponentProps:"lo.setComponentProps"},n=new i("LightningOutError"),a="Session not ready",h="Session timeout",l="Session failed: iframe error",d="Malformed sessionExpiry response",c="Session terminated",p="Session APIs are not supported in org-url mode";class m{#r;#i;constructor(e){this.#i="string"==typeof e?e:e.constructor?.name,"function"==typeof e.dispatchEvent&&(this.#r=e)}#s(e){return`${this.#i}: ${e}`}create(e){const t="string"==typeof e?e:e.message;return new Error(this.#s(t))}dispatch(e,t){const i="string"==typeof t?t:t.message||t.detail?.message;if(this.#r){const r=t.detail||{message:this.#s(i),originalError:t},s=new CustomEvent(e,{detail:r});this.#r.dispatchEvent(s),n.error(`${this.#s("dispatched error")} -> ${e}: ${i}`)}else n.error(`${this.#s("unable to dispatch error on a non-EventTarget object")} -> ${e}: ${i}`)}}const u=new m("LightningOutUtils");function g(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function f(e,t=!1){if(/[A-Z]/.test(e))throw u.create(`elementNameToStandardName: "${e}" is not a valid custom element name - must be all lowercase.`);const i=e.indexOf("-");if(-1===i)throw u.create(`elementNameToStandardName: "${e}" is not a valid custom element name - missing hyphen character.`);return`${function(e){if(/[A-Z]/.test(e))throw u.create(`snakeToCamel: "${e}" is not valid snake_case - must be all lowercase.`);return e.replace(/_([a-z_])/g,(e,t)=>t.toUpperCase())}(e.slice(0,i))}${t?":":"/"}${function(e){if(/[A-Z]/.test(e))throw u.create(`kebabToCamel: "${e}" is not valid kebab-case - must be all lowercase.`);return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}(e.slice(i+1))}`}function v(e){return e.startsWith("$$")}function b(e,t){const i=Object.entries(t).map(t=>{let[i,r]=t;const s=i.split("dataMirror");2===s.length&&""===s[0]&&(i=s[1].charAt(0).toLowerCase()+s[1].slice(1));const o=`_propertyChanged_${i}`;if("function"==typeof e[o]){r=(0,e[o])(r)}return[i,r]});return Object.fromEntries(i)}const w=new i("LightningOutIFrame");class y{#o;#n;#a;#h="display:none";#l="border:0px; width:100%; height:100%; overflow:auto;";#d;#c;#p;#m;#u;#g;constructor(e){this.#o=e.parentElement,this.#n=e.parentElement instanceof x,this.#a=new m(e.parentElement)}get iframeReady(){return!!this.#p&&!!this.#m}get iframeElement(){return this.#c}isTrustedMessage(e){return this.iframeReady&&e.source===this.#p&&e.origin===this.#m}#f(e,t){this.#p=e,this.#m=t}#v=e=>{if(e.data.id===this.#o._uuid){if(this.iframeReady){if(e.source!==this.#p||e.origin!==this.#m)return void w.debug("#messageListener: rejected message with mismatched source/origin",`expected origin: ${this.#m}`,`got origin: ${e.origin}`)}else{if(!(e.data.type===o.loaded||e.data.type===o.redirect||e.data.type===o.logout))return void w.debug("#messageListener: rejected pre-ready message that is not an allowed pre-ready type",`type: ${e.data.type}`);if(e.source!==this.#c?.contentWindow)return void w.debug("#messageListener: rejected pre-ready message from a foreign source",`origin: ${e.origin}`,`type: ${e.data.type}`)}switch(w.debug("#messageListener:",`parentElement._uuid: ${this.#o._uuid}`,`parentElement.localName: ${this.#o.localName}`,JSON.stringify(e.data)),e.data.type){case o.loaded:{this.#g=clearTimeout(this.#g);const t=!this.iframeReady;this.#f(e.source,e.origin),t&&(this.#c,this.#n);const i=e.data.lightningDomain;this.#o.dispatchEvent(new CustomEvent(s.iframe.load,{detail:{origin:e.origin,lightningDomain:i}}));break}case o.logout:this.#g=clearTimeout(this.#g),this.#o.dispatchEvent(new CustomEvent(s.iframe.logout));break;case o.redirect:this.#g=clearTimeout(this.#g),this.#o.dispatchEvent(new CustomEvent(s.iframe.auth.redirect,{detail:{redirectUrl:e.data.redirectUrl,redirectOrigin:e.origin}}));break;case o.resize:break;case o.sessionExpiryResponse:this.#o instanceof k&&this.#o._handleSessionExpiryResponse(e.data)}}};#b(e){this.#c&&this.#n&&(this.#c.style.height=`${e}px`,w.debug(`#handleResize: applied height ${e}px to iframe`))}#w(){if(!this.#c){const e=window.document.createElement("iframe");e.name="lightning_af",e.setAttribute("sandbox",["allow-downloads","allow-forms","allow-popups","allow-same-origin","allow-scripts","allow-top-navigation-by-user-activation"].join(" ")),e.style.cssText=this.#n?this.#l:this.#h,this.#c=e,this.#d=this.#o.attachShadow({mode:"closed"}),this.#d.appendChild(this.#c),e.addEventListener("load",this.#y),window.addEventListener("message",this.#v),this.#c,this.#n}return this.#c}load(e){const t=this.#w();this.#u=new URL(e),w.debug("#loadIframe: endpoint =",function(e){const t={},i=e=>{const t={};for(const[i,r]of e.entries())t[i]=r;return t};if(t.url=e.origin+e.pathname,t.urlParams=i(e.searchParams),"/secur/frontdoor.jsp"===e.pathname){const e=t.urlParams.otp?"startURL":"retURL",r=new URL(t.urlParams[e],"http://dummy.com");t.urlParams[e]={url:r.pathname,urlParams:i(r.searchParams)}}return t}(this.#u)),this.#f(void 0,void 0),this.#n,this.#n?t.src=e:localStorage.getItem("LightningOutIFrame:load:window.open")?window.open(e,`LO2 Hidden ${this.#o._uuid}`,"left=200,top=200,width=800,height=800"):t.src=e}#y=()=>{this.#c,this.#n;this.#g&&clearTimeout(this.#g),this.#g=setTimeout(()=>{if(!this.iframeReady){this.#c,this.#n;const e="Error: Unknown error, unable to load the iframe.";this.#a.dispatch(s.iframe.error,e),this.#E(e)}},6e4)};destroy(){this.#d&&(this.#d.innerHTML=""),this.#c&&(this.#c.remove(),this.#c,this.#n),this.#d=void 0,this.#c=void 0,this.#f(void 0,void 0)}#E(e){if(this.#n&&this.#u){const t=new URL("/lightning/lightning.out.message.html",this.#u.origin);t.search=new URLSearchParams({loAppOrigin:window.location.origin,parentElementId:this.#o._uuid,message:e}).toString(),this.load(t.href)}}postMessage(e){if(!this.#p||!this.#m)throw this.#c,this.#n,this.#a.create("Error attempting to postMessage on an iframe that is not ready.");w.debug("postMessage:",`parentElement: ${this.#o._uuid}`,JSON.stringify(e));try{this.#p.postMessage(e,this.#m)}catch(e){this.#c,this.#n;const t=`postMessage error: ${e}`;throw this.#a.dispatch(s.iframe.error,t),this.#a.create(t)}}}
|
|
3
3
|
/**
|
|
4
4
|
* @file property-observer.ts
|
|
5
5
|
* @author Caridy Patiño (2025)
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @description Provides the PropertyObserver class, a utility to observe property and attribute
|
|
8
8
|
* changes on any DOM element, with automatic getter/setter interception and batched notifications.
|
|
9
|
-
*/const E=new i("PropertyObserver");class _{_el;_cb;_cache;_shouldObserve;_interceptedProps;_originalDescriptors;_observer;_changesPending;_pendingChanges;_attributeExceptions=new Map([["for","htmlFor"],["class","className"],["formnovalidate","formNoValidate"],["readonly","readOnly"],["maxlength","maxLength"],["minlength","minLength"],["contenteditable","contentEditable"],["spellcheck","spellcheck"],["novalidate","noValidate"],["autofocus","autofocus"],["autocomplete","autocomplete"],["crossorigin","crossOrigin"]]);constructor(e,t,i){if(!(e instanceof Element))throw new TypeError("Target must be a DOM Element");if("function"!=typeof t)throw new TypeError("Callback must be a function");if(i&&"function"!=typeof i)throw new TypeError("shouldObserve callback must be a function");this._el=e,this._cb=t,this._cache=new Map,this._shouldObserve=i||((e,t)=>!1===t),this._interceptedProps=new Set,this._originalDescriptors=new Map,this._changesPending=!1,this._pendingChanges={},this._initialScan(),this._setupMutationObserver()}disconnect(){this._observer&&this._observer.disconnect();for(const[e,t]of this._originalDescriptors)Object.defineProperty(this._el,e,t);this._cache.clear(),this._interceptedProps.clear(),this._originalDescriptors.clear(),this._pendingChanges={},this._changesPending=!1}_initialScan(){const e={};for(const t of Array.from(this._el.attributes)){const i=t.name,r=this._isStandardAttribute(i);if(!this._shouldObserve(i,r))continue;const s=this._attributeNameToPropName(i),o=t.value;e[s]=o,this._cache.set(s,o),this._installPropertyInterceptor(s)}for(const t of Object.getOwnPropertyNames(this._el)){const i=this._isStandardProperty(t);if(this._cache.has(t)||!this._shouldObserve(t,i))continue;const r=this._el[t];e[t]=r,this._cache.set(t,r),this._installPropertyInterceptor(t)}if(Object.keys(e).length>0)try{this._cb(e)}catch(e){E.error("Error in initial PropertyObserver callback:",e)}}_setupMutationObserver(){this._observer=new MutationObserver(e=>{const t={};for(const i of e)if("attributes"===i.type&&i.attributeName){const e=i.attributeName,r=this._isStandardAttribute(e);if(!this._shouldObserve(e,r))continue;const s=this._attributeNameToPropName(e),o=this._el.getAttribute(e);o!==this._cache.get(s)&&(t[s]=o,this._cache.set(s,o),this._interceptedProps.has(s)||this._installPropertyInterceptor(s))}Object.keys(t).length>0&&this._batchChanges(t)}),this._observer.observe(this._el,{attributes:!0,attributeOldValue:!1})}_installPropertyInterceptor(e){if(this._interceptedProps.has(e))return;const t=Object.getOwnPropertyDescriptor(this._el,e)||{value:this._el[e],writable:!0,enumerable:!0,configurable:!0};this._originalDescriptors.set(e,t);const i={enumerable:t.enumerable,configurable:t.configurable,get:t.get||(()=>t.value),set:i=>{i!==this._cache.get(e)&&(t.set?t.set.call(this._el,i):t.value=i,this._cache.set(e,i),this._batchChanges({[e]:i}))}};Object.defineProperty(this._el,e,i),this._interceptedProps.add(e)}_batchChanges(e){Object.assign(this._pendingChanges,e),this._changesPending||(this._changesPending=!0,queueMicrotask(()=>{this._changesPending=!1;const e={...this._pendingChanges};this._pendingChanges={};try{this._cb(e)}catch(e){E.error("Error in PropertyObserver callback:",e)}}))}_attributeNameToPropName(e){return this._attributeExceptions.has(e)?this._attributeExceptions.get(e):e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}_isStandardAttribute(e){if(e.startsWith("data-")||e.startsWith("aria-")||e.startsWith("on"))return!0;const t=this._attributeNameToPropName(e);return this._isStandardProperty(t)}_isStandardProperty(e){return e in HTMLElement.prototype}}const C=new class{#_=new m("LightningOutRegistry");appToComps=new WeakMap;compToApp=new WeakMap;compNameToApp=new Map;registerApplication(e){this.appToComps.has(e)||this.appToComps.set(e,new Set)}registerComponentName(e,t){if(this.compNameToApp.has(e))throw this.#_.create(`"${e}" is already registered to another App.`);this.compNameToApp.set(e,t)}registerComponent(e,t){if(this.compToApp.has(e))throw this.#_.create("This Comp is already registered to another App.");let i=t;if(!i){const t=e.localName;if(i=this.compNameToApp.get(t),!i)throw this.#_.create(`Could not find a parent App for component "${e.localName}"`)}return this.appToComps.get(i).add(e),this.compToApp.set(e,i),i}unregisterComponent(e){const t=this.compToApp.get(e);if(!t)return!1;const i=this.appToComps.get(t);return i?.delete(e),this.compToApp.delete(e),!0}getComps(e){const t=this.appToComps.get(e);if(!t)throw this.#_.create("Unable to find set of LightningOutComponents");return t}},L=new i("LightningOutComponent"),R=new Set(["autocapitalize","autocorrect","dir","enterkeyhint","inputmode","lang","spellcheck","style","title","translate"]),P=new Set(["aria-disabled","aria-hidden","aria-label","aria-live","aria-modal","aria-pressed","aria-valuemax","aria-valuemin","aria-valuenow"]),S=new Set(["accesskey","autofocus","draggable","exportparts","hidden","inert","nonce","part","slot","tabindex"]),A=new Set(["aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"]);class $ extends HTMLElement{_uuid=r();componentReady=!1;_standardName=f(this.localName);#C;#_=new m(this);#L=new y({parentElement:this});#R;#P=!0;#S=[];#A=new WeakMap;#$=0;constructor(){super(),L.trace("constructor: called",`_uuid: ${this._uuid}`)}_getComponentURL(){const e=this.#C;if(!e)throw this.#_.create("Undefined parent App!");return e._getComponentURL(this._standardName,this._uuid)}_init(){this.componentReady||this.#L.load(this._getComponentURL().href)}#v=e=>{if(this.#L.isTrustedMessage(e)){if(e.data.id===this._uuid)switch(L.debug("#messageListener:",`this._uuid: ${this._uuid}`,`this._standardName: ${this._standardName}`,`event.data: ${JSON.stringify(e.data)}`),e.data.type){case o.ready:for(this.componentReady=!0;this.#S.length;){const e=this.#S.shift();e&&("add"===e.type?this.addEventListener(...e.args):"remove"===e.type?this.removeEventListener(...e.args):"dispatch"===e.type&&this.dispatchEvent(e.event))}super.dispatchEvent(new CustomEvent(s.component.ready));break;case o.getComponentData:this.#R=new _(this,this.#O,this.#U);break;case o.dispatchEvent:{const t=new CustomEvent(e.data.name,{detail:e.data.detail});super.dispatchEvent(t);break}case o.error:this.#_.dispatch(s.component.error,e.data.error);break;default:L.info("#messageListener:","Unknown message received:",{"event.data":e.data})}}else L.debug("#messageListener: rejected untrusted source/origin",`_uuid: ${this._uuid}`,`origin: ${e.origin}`)};_propertyChanged_style=e=>{const t=this.style,i=[];for(let e=0;e<t.length;e+=1){const r=t.item(e);r.startsWith("--")&&i.push(`${r}:${t.getPropertyValue(r)}`)}return i.join(";")};#O=e=>{const t=b(this,e);L.debug("#propObserverCallback:",{changes:e,propsToSend:t}),this.#P?(this.#P=!1,this.#L.postMessage({type:o.setComponentData,componentData:{id:this._uuid,name:this._standardName,props:t}})):this.#L.postMessage({type:o.setComponentProps,componentProps:t})};#U=(e,t)=>{const i=g(e);return L.debug("#shouldObserveCallback:",{attrOrPropName:e,attrName:i,isStandard:t}),t?!(!R.has(i)&&!P.has(i))||(S.has(i)||A.has(i)||i.startsWith("on")?(L.warn(`"${i}" will not be mirrored.`),!1):!!i.startsWith("data-mirror-")||(L.warn(`"${i}" will not be mirrored.`),!1)):!i.startsWith("_")&&!v(e)};addEventListener(e,t,i){if(e===s.component.ready&&this.componentReady){const e=new CustomEvent(s.component.ready);queueMicrotask(()=>{"function"==typeof t?t.call(this,e):t.handleEvent(e)})}if(e.startsWith("lo."))return void super.addEventListener(e,t,i);let r=this.#A.get(t);r||(r=`${e}_${this.#$++}`,this.#A.set(t,r)),this.componentReady?(super.addEventListener(...arguments),this.#L.postMessage({name:e,options:i,listenerKey:r,type:o.addEventListener})):(this.#S.push({type:"add",args:[e,t,i]}),L.debug("addEventListener:","#eventQueue pushed add args:",[e,t,i]))}dispatchEvent(e){if(e.type.startsWith("lo."))return L.debug(`dispatchEvent: dispatching event "${e.type}" to this Element only`),super.dispatchEvent(e);if(this.componentReady){L.debug(`dispatchEvent: dispatching event "${e.type}" to this Element and embedded Element inside the iframe`);const t=super.dispatchEvent(e);return this.#L.postMessage({name:e.type,detail:e.detail||{},type:o.dispatchEvent}),t}return L.debug(`dispatchEvent: component not ready, queueing event "${e.type}"`),this.#S.push({type:"dispatch",event:e}),!0}removeEventListener(e,t,i){if(e.startsWith("lo."))return void super.removeEventListener(...arguments);const r=this.#A.get(t);this.componentReady?(super.removeEventListener(...arguments),this.#L.postMessage({name:e,options:i,listenerKey:r,type:o.removeEventListener})):(this.#S.push({type:"remove",args:[e,t,i]}),L.debug("removeEventListener:","#eventQueue pushed remove args:",[e,t,i])),r&&this.#A.delete(t)}adoptedCallback(){throw this.remove(),this.#_.create("This component cannot be rerendered for security reasons.")}connectedCallback(){if(L.trace("connectedCallback: called",`_uuid: ${this._uuid}`),window.addEventListener("message",this.#v),this.hasChildNodes())throw this.#_.create("Should not have child nodes");this.style.display||="block",this.style.width||="100%",this.style.height||="100%",this.#C=C.registerComponent(this),this._standardName=this.#C._getComponentStandardName(this),this.#C.applicationReady&&this._init()}disconnectedCallback(){L.trace("disconnectedCallback: called",`_uuid: ${this._uuid}`),this.#L.destroy(),window.removeEventListener("message",this.#v),C.unregisterComponent(this),this.#R?.disconnect()}connectedMoveCallback(){}}class O{config;errorHandler;constructor(e,t){if(this.config=e,this.errorHandler=t,!this.config.origin)throw this.errorHandler('Missing "frontdoor-url" or "org-url" attribute')}getComponentURL(e,t){let i;if(void 0===this.config.sitePrefix){let t=e.includes("/")?this.config.lwrAppComp:e.includes(":")?this.config.lwrAppAura:void 0;if(void 0===t)throw this.errorHandler(`Invalid componentName: ${e}`);t=t.replace("/","%2F");const r=this.config.lang?`l/${this.config.lang}/`:"";i=new URL(`lwr/application/amd/0/${r}ai/${t}`,this.config.origin)}else i=new URL(`${this.config.sitePrefix}/lightning-out`,this.config.origin);return i.searchParams.set("componentName",e),this.#N(i,t)}getAuthURL(e){let t;if(void 0===this.config.sitePrefix){const e=this.config.lwrAppAuth.replace("/","%2F");t=new URL(`lwr/application/amd/0/ai/${e}`,this.config.origin)}else t=new URL(this.config.lwrPageAuth,this.config.origin);return this.#N(t,e)}getPageURL(e,t){const i=new URL(e,this.config.origin);return this.#N(i,t)}#N(e,t){return e.searchParams.set("parentElementId",t),e.searchParams.set("loAppOrigin",this.config.loAppOrigin),e.searchParams.set("loVersion","2.3.0-rc.3"),this.config.appId&&e.searchParams.set("appId",this.config.appId),this.config.testMode&&e.searchParams.set("testMode","true"),this.config.designSystem&&e.searchParams.set("designSystem",this.config.designSystem),this.config.globalStyle&&e.searchParams.set("globalStyle",this.config.globalStyle),e}}const U=new i("LightningOutApplication"),N=new Set(["slds1","slds2","none"]),I=new Set(["frontdoorUrl","orgUrl"]);class T extends HTMLElement{_uuid=r();applicationReady=!1;#_=new m(this);#L=new y({parentElement:this});#I;#R;#T="";#k="lightningout/auth";#x="lightningout/container";#M="lightningout/auraContainer";#j="lightning/lightning.out.auth.html";#D="lightning/lightning.out.logout.html";#F="lightning/lightning.out.auth.error.html";#W="/secur/logout.jsp";lwrApplication;orgUrl;#z;frontdoorUrl;#H;appId;#K;components;#Q=new Map;sitePrefix;#Z;designSystem;#V;globalStyle;#q;#J=document.documentElement.lang??"";#G=!1;#X=null;#B=null;constructor(){super(),U.trace("constructor: called",`_uuid: ${this._uuid}`),C.registerApplication(this)}addEventListener(e,t,i){if(e===s.application.ready&&this.applicationReady){const e=new CustomEvent(s.application.ready);queueMicrotask(()=>{"function"==typeof t?t.call(this,e):t.handleEvent(e)})}super.addEventListener(e,t,i)}#Y(e){try{this.#z=new URL(e)}catch{throw this.#_.create(`Invalid org-url: ${e}`)}this.dispatchEvent(new CustomEvent(s.iframe.load,{detail:this.#z.origin}))}#ee(e){try{this.#H=new URL(e),this.#T=this.#H.origin;const t=this.#te(),i=this.#ie(this.#F),r=i.pathname+i.search;t.searchParams.set("error-redirect-uri",r);const s=this.#H.searchParams.has("otp")?"startURL":"retURL";this.#H.searchParams.set(s,t.pathname+t.search),this.#H.searchParams.set("error-redirect-uri",r)}catch{throw this.#_.create(`Invalid frontdoor-url: ${e}`)}this.#L.load(this.#H.href)}#re(){const e=new URL(this.#W,this.#T),t=this.#ie(this.#D);e.searchParams.set("redirect-uri",t.pathname+t.search),this.#L.load(e.href)}getRouter(){if(void 0===this.#I){const e={origin:this.#T,lwrPageAuth:this.#j,lwrAppAuth:this.#k,lwrAppComp:this.#x,lwrAppAura:this.#M,sitePrefix:this.#Z,lang:this.#J,appId:this.#K,testMode:this.__testMode||!1,loAppOrigin:window.location.origin,designSystem:this.#V,globalStyle:this.#q};this.#I=new O(e,e=>this.#_.create(e))}return this.#I}_getComponentURL(e,t){return this.getRouter().getComponentURL(e,t)}#te(){return this.getRouter().getAuthURL(this._uuid)}#ie(e){return this.getRouter().getPageURL(e,this._uuid)}#se=e=>{this.applicationReady=!0;const t=e.detail;return this.#T="string"==typeof t?t:t.lightningDomain||t.origin,this.#I=void 0,this.#G?(U.trace("#iframeLoaded: frontdoor-url refresh path"),this.#G=!1,void this.dispatchEvent(new CustomEvent(s.application.session.refresh))):this.#B?(U.trace("#iframeLoaded: sessionRefresh() reload path"),clearTimeout(this.#B.timeoutId),this.#B.resolve(),void(this.#B=null)):(U.trace("#iframeLoaded: initial-auth path"),this.#oe(),void this.dispatchEvent(new CustomEvent(s.application.ready)))};sessionExpiry(){if(void 0!==this.#z)return Promise.reject(this.#_.create(p));if(!this.applicationReady)return Promise.reject(this.#_.create(a));if(this.#X)return this.#X.promise;let e,t;const i=new Promise((i,r)=>{e=i,t=r}),r=window.setTimeout(()=>{const e=this.#X;this.#X=null,e?.reject(this.#_.create(h))},3e4);return this.#X={promise:i,resolve:e,reject:t,timeoutId:r},this.#L.postMessage({type:o.sessionExpiry,id:this._uuid}),i}sessionRefresh(){if(void 0!==this.#z)return Promise.reject(this.#_.create(p));if(!this.applicationReady)return Promise.reject(this.#_.create(a));if(this.#B)return this.#B.promise;let e,t;const i=new Promise((i,r)=>{e=i,t=r}),r=window.setTimeout(()=>{const e=this.#B;this.#B=null,e?.reject(this.#_.create(h))},6e4);return this.#B={promise:i,resolve:e,reject:t,timeoutId:r},this.#L.postMessage({type:o.authReload,id:this._uuid}),i}_handleSessionExpiryResponse(e){const t=this.#X;t&&(clearTimeout(t.timeoutId),this.#X=null,void 0!==e.error?t.reject(this.#_.create(e.error)):void 0===e.ttl?t.reject(this.#_.create(d)):t.resolve(e.ttl))}#ne(e){const t=this.#B;t&&(clearTimeout(t.timeoutId),this.#B=null,t.reject(this.#_.create(e)))}#ae(e){const t=this.#X;t&&(clearTimeout(t.timeoutId),this.#X=null,t.reject(this.#_.create(e)))}#he(e){this.#ne(e),this.#ae(e)}#le=e=>{this.#G=!1;const t=e.detail?.message;this.#he(t??l),this.#_.dispatch(s.application.error,e)};#de=e=>{this.dispatchEvent(new CustomEvent(s.application.logout))};#ce=e=>{this.dispatchEvent(new CustomEvent(s.application.auth.redirect,{detail:e.detail}))};#oe(){C.getComps(this).forEach(e=>{e._init()})}#O=e=>{const t={},i={};Object.keys(e).forEach(r=>{I.has(r)?i[r]=e[r]:t[r]=e[r]}),b(this,t),b(this,i)};#U=(e,t)=>t?"lang"===e:!e.startsWith("_")&&!v(e);_propertyChanged_lwrApplication=e=>{if(void 0!==e){const t=e.split("/");if(2!==t.length||!t[0]||!t[1])throw this.#_.create(`"${e}" is not a valid lwr-application name, must be of the form 'namespace/name'`);this.#x=e}};_propertyChanged_lang=e=>{this.#J=e??""};_propertyChanged_orgUrl=e=>{if(void 0!==e){if(void 0!==this.#H)throw this.#_.create('Can\'t set "org-url" because "frontdoor-url" is already set');""===e?this.#re():this.#Y(e)}};_propertyChanged_frontdoorUrl=e=>{if(void 0===e)return;if(void 0!==this.#z)throw this.#_.create('Can\'t set "frontdoor-url" because "org-url" is already set');if(""===e)return this.#he(c),void this.#re();const t=null!==this.#B;this.#he(c),this.#G=this.applicationReady&&!t,this.#ee(e)};_propertyChanged_sitePrefix=e=>{void 0!==e&&(this.#Z=e)};_propertyChanged_appId=e=>{void 0!==e&&(this.#K=e)};_propertyChanged_globalStyle=e=>{if(void 0!==e){const t=e.split(";").map(e=>e.trim()).filter(e=>e.length>0),i=[];for(const e of t){const[t,...r]=e.split(":"),s=t.trim();if(!s.startsWith("--"))throw this.#_.create(`Invalid global-style: "${s}" is not a CSS custom property. Only CSS custom properties (starting with --) are allowed.`);const o=r.join(":").trim();o&&i.push(`${s}:${o}`)}this.#q=i.join(";")+";"}};_propertyChanged_components=e=>{void 0!==e&&e.split(",").forEach(e=>{const[t,i]=e.split(" as ").map(e=>e.trim()),r=function(e){return e.includes("/")||e.includes(":")}(t);if(r&&t.includes(":"))throw this.#_.create(`"${t}" is not supported in components. Use kebab "namespace-name" in components and the "aura" attribute on the component element instead.`);const s=r?t:f(t),o=i||(r?function(e){const t=e.includes("/")?"/":":",i=e.indexOf(t);if(-1===i)throw u.create(`standardNameToElementName: "${e}" is not a valid component name - missing namespace separator.`);if(/-/.test(e))throw u.create(`standardNameToElementName: "${e}" is not a valid component name - must not contain hyphens.`);if(/^[A-Z]/.test(e))throw u.create(`standardNameToElementName: "${e}" is not a valid component name - first character must not be uppercase.`);const r=e.slice(0,i),s=e.slice(i+1);return`${r.replace(/([A-Z_])/g,"_$1").toLowerCase()}-${g(s)}`}(s):t);if(o&&!this.#Q.has(o)){this.#Q.set(o,s);try{C.registerComponentName(o,this),customElements.define(o,class extends ${})}catch(e){throw this.#_.create(`"${o}" is already registered. ${e}`)}}})};_propertyChanged_designSystem=e=>{if(void 0!==e&&!N.has(e))throw this.#_.create(`Invalid design-system: ${e}`);this.#V=e};_getComponentStandardName(e){const t=e.localName,i=e.hasAttribute("aura"),r=this.#Q.get(t);if(!r)throw this.#_.create(`"${t}" is not registered.`);return i&&r.includes("/")?r.replace("/",":"):r}get _compNames(){}connectedCallback(){if(U.trace("connectedCallback: called",`_uuid: ${this._uuid}`),this.hasChildNodes())throw this.#_.create("Should not have child nodes");this.style.display||="none",this.addEventListener(s.iframe.load,this.#se),this.addEventListener(s.iframe.error,this.#le),this.addEventListener(s.iframe.logout,this.#de),this.addEventListener(s.iframe.auth.redirect,this.#ce),this.#R=new _(this,this.#O,this.#U)}disconnectedCallback(){U.trace("disconnectedCallback: called",`_uuid: ${this._uuid}`),this.#he(c),this.#re(),this.#L.destroy(),this.removeEventListener(s.iframe.load,this.#se),this.removeEventListener(s.iframe.error,this.#le),this.removeEventListener(s.iframe.logout,this.#de),this.removeEventListener(s.iframe.auth.redirect,this.#ce),this.#R?.disconnect()}connectedMoveCallback(){}}return i.level="debug",window.customElements.define("lightning-out-application",T),e.LightningOutApplication=T,e}({});
|
|
9
|
+
*/const E=new i("PropertyObserver");class _{_el;_cb;_cache;_shouldObserve;_interceptedProps;_originalDescriptors;_observer;_changesPending;_pendingChanges;_attributeExceptions=new Map([["for","htmlFor"],["class","className"],["formnovalidate","formNoValidate"],["readonly","readOnly"],["maxlength","maxLength"],["minlength","minLength"],["contenteditable","contentEditable"],["spellcheck","spellcheck"],["novalidate","noValidate"],["autofocus","autofocus"],["autocomplete","autocomplete"],["crossorigin","crossOrigin"]]);constructor(e,t,i){if(!(e instanceof Element))throw new TypeError("Target must be a DOM Element");if("function"!=typeof t)throw new TypeError("Callback must be a function");if(i&&"function"!=typeof i)throw new TypeError("shouldObserve callback must be a function");this._el=e,this._cb=t,this._cache=new Map,this._shouldObserve=i||((e,t)=>!1===t),this._interceptedProps=new Set,this._originalDescriptors=new Map,this._changesPending=!1,this._pendingChanges={},this._initialScan(),this._setupMutationObserver()}disconnect(){this._observer&&this._observer.disconnect();for(const[e,t]of this._originalDescriptors)Object.defineProperty(this._el,e,t);this._cache.clear(),this._interceptedProps.clear(),this._originalDescriptors.clear(),this._pendingChanges={},this._changesPending=!1}_initialScan(){const e={};for(const t of Array.from(this._el.attributes)){const i=t.name,r=this._isStandardAttribute(i);if(!this._shouldObserve(i,r))continue;const s=this._attributeNameToPropName(i),o=t.value;e[s]=o,this._cache.set(s,o),this._installPropertyInterceptor(s)}for(const t of Object.getOwnPropertyNames(this._el)){const i=this._isStandardProperty(t);if(this._cache.has(t)||!this._shouldObserve(t,i))continue;const r=this._el[t];e[t]=r,this._cache.set(t,r),this._installPropertyInterceptor(t)}if(Object.keys(e).length>0)try{this._cb(e)}catch(e){E.error("Error in initial PropertyObserver callback:",e)}}_setupMutationObserver(){this._observer=new MutationObserver(e=>{const t={};for(const i of e)if("attributes"===i.type&&i.attributeName){const e=i.attributeName,r=this._isStandardAttribute(e);if(!this._shouldObserve(e,r))continue;const s=this._attributeNameToPropName(e),o=this._el.getAttribute(e);o!==this._cache.get(s)&&(t[s]=o,this._cache.set(s,o),this._interceptedProps.has(s)||this._installPropertyInterceptor(s))}Object.keys(t).length>0&&this._batchChanges(t)}),this._observer.observe(this._el,{attributes:!0,attributeOldValue:!1})}_installPropertyInterceptor(e){if(this._interceptedProps.has(e))return;const t=Object.getOwnPropertyDescriptor(this._el,e)||{value:this._el[e],writable:!0,enumerable:!0,configurable:!0};this._originalDescriptors.set(e,t);const i={enumerable:t.enumerable,configurable:t.configurable,get:t.get||(()=>t.value),set:i=>{i!==this._cache.get(e)&&(t.set?t.set.call(this._el,i):t.value=i,this._cache.set(e,i),this._batchChanges({[e]:i}))}};Object.defineProperty(this._el,e,i),this._interceptedProps.add(e)}_batchChanges(e){Object.assign(this._pendingChanges,e),this._changesPending||(this._changesPending=!0,queueMicrotask(()=>{this._changesPending=!1;const e={...this._pendingChanges};this._pendingChanges={};try{this._cb(e)}catch(e){E.error("Error in PropertyObserver callback:",e)}}))}_attributeNameToPropName(e){return this._attributeExceptions.has(e)?this._attributeExceptions.get(e):e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}_isStandardAttribute(e){if(e.startsWith("data-")||e.startsWith("aria-")||e.startsWith("on"))return!0;const t=this._attributeNameToPropName(e);return this._isStandardProperty(t)}_isStandardProperty(e){return e in HTMLElement.prototype}}const C=new class{#_=new m("LightningOutRegistry");appToComps=new WeakMap;compToApp=new WeakMap;compNameToApp=new Map;registerApplication(e){this.appToComps.has(e)||this.appToComps.set(e,new Set)}registerComponentName(e,t){if(this.compNameToApp.has(e))throw this.#_.create(`"${e}" is already registered to another App.`);this.compNameToApp.set(e,t)}registerComponent(e,t){if(this.compToApp.has(e))throw this.#_.create("This Comp is already registered to another App.");let i=t;if(!i){const t=e.localName;if(i=this.compNameToApp.get(t),!i)throw this.#_.create(`Could not find a parent App for component "${e.localName}"`)}return this.appToComps.get(i).add(e),this.compToApp.set(e,i),i}unregisterComponent(e){const t=this.compToApp.get(e);if(!t)return!1;const i=this.appToComps.get(t);return i?.delete(e),this.compToApp.delete(e),!0}getComps(e){const t=this.appToComps.get(e);if(!t)throw this.#_.create("Unable to find set of LightningOutComponents");return t}},P=new i("LightningOutComponent"),L=document.createElement("template");L.innerHTML='<span --sfdc-runtime="isolated"></span>';const R=new Set(["autocapitalize","autocorrect","dir","enterkeyhint","inputmode","lang","spellcheck","style","title","translate"]),S=new Set(["aria-disabled","aria-hidden","aria-label","aria-live","aria-modal","aria-pressed","aria-valuemax","aria-valuemin","aria-valuenow"]),A=new Set(["accesskey","autofocus","draggable","exportparts","hidden","inert","nonce","part","slot","tabindex"]),$=new Set(["aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"]);class x extends HTMLElement{_uuid=r();componentReady=!1;_standardName=f(this.localName);#C;#_=new m(this);#P=new y({parentElement:this});#L;#R=!0;#S=[];#A=new WeakMap;#$=0;constructor(){super(),P.trace("constructor: called",`_uuid: ${this._uuid}`)}_getComponentURL(){const e=this.#C;if(!e)throw this.#_.create("Undefined parent App!");return e._getComponentURL(this._standardName,this._uuid)}_init(){this.componentReady||(this.#P.load(this._getComponentURL().href),this.setAttributeNode(L.content.firstElementChild.attributes[0].cloneNode()))}#v=e=>{if(this.#P.isTrustedMessage(e)){if(e.data.id===this._uuid)switch(P.debug("#messageListener:",`this._uuid: ${this._uuid}`,`this._standardName: ${this._standardName}`,`event.data: ${JSON.stringify(e.data)}`),e.data.type){case o.ready:for(this.componentReady=!0;this.#S.length;){const e=this.#S.shift();e&&("add"===e.type?this.addEventListener(...e.args):"remove"===e.type?this.removeEventListener(...e.args):"dispatch"===e.type&&this.dispatchEvent(e.event))}super.dispatchEvent(new CustomEvent(s.component.ready));break;case o.getComponentData:this.#L=new _(this,this.#x,this.#O);break;case o.dispatchEvent:{const t=new CustomEvent(e.data.name,{detail:e.data.detail});super.dispatchEvent(t);break}case o.error:this.#_.dispatch(s.component.error,e.data.error);break;default:P.info("#messageListener:","Unknown message received:",{"event.data":e.data})}}else P.debug("#messageListener: rejected untrusted source/origin",`_uuid: ${this._uuid}`,`origin: ${e.origin}`)};_propertyChanged_style=e=>{const t=this.style,i=[];for(let e=0;e<t.length;e+=1){const r=t.item(e);r.startsWith("--")&&i.push(`${r}:${t.getPropertyValue(r)}`)}return i.join(";")};#x=e=>{const t=b(this,e);P.debug("#propObserverCallback:",{changes:e,propsToSend:t}),this.#R?(this.#R=!1,this.#P.postMessage({type:o.setComponentData,componentData:{id:this._uuid,name:this._standardName,props:t}})):this.#P.postMessage({type:o.setComponentProps,componentProps:t})};#O=(e,t)=>{const i=g(e);return P.debug("#shouldObserveCallback:",{attrOrPropName:e,attrName:i,isStandard:t}),"--sfdc-runtime"!==i&&(t?!(!R.has(i)&&!S.has(i))||(A.has(i)||$.has(i)||i.startsWith("on")?(P.warn(`"${i}" will not be mirrored.`),!1):!!i.startsWith("data-mirror-")||(P.warn(`"${i}" will not be mirrored.`),!1)):!i.startsWith("_")&&!v(e))};addEventListener(e,t,i){if(e===s.component.ready&&this.componentReady){const e=new CustomEvent(s.component.ready);queueMicrotask(()=>{"function"==typeof t?t.call(this,e):t.handleEvent(e)})}if(e.startsWith("lo."))return void super.addEventListener(e,t,i);let r=this.#A.get(t);r||(r=`${e}_${this.#$++}`,this.#A.set(t,r)),this.componentReady?(super.addEventListener(...arguments),this.#P.postMessage({name:e,options:i,listenerKey:r,type:o.addEventListener})):(this.#S.push({type:"add",args:[e,t,i]}),P.debug("addEventListener:","#eventQueue pushed add args:",[e,t,i]))}dispatchEvent(e){if(e.type.startsWith("lo."))return P.debug(`dispatchEvent: dispatching event "${e.type}" to this Element only`),super.dispatchEvent(e);if(this.componentReady){P.debug(`dispatchEvent: dispatching event "${e.type}" to this Element and embedded Element inside the iframe`);const t=super.dispatchEvent(e);return this.#P.postMessage({name:e.type,detail:e.detail||{},type:o.dispatchEvent}),t}return P.debug(`dispatchEvent: component not ready, queueing event "${e.type}"`),this.#S.push({type:"dispatch",event:e}),!0}removeEventListener(e,t,i){if(e.startsWith("lo."))return void super.removeEventListener(...arguments);const r=this.#A.get(t);this.componentReady?(super.removeEventListener(...arguments),this.#P.postMessage({name:e,options:i,listenerKey:r,type:o.removeEventListener})):(this.#S.push({type:"remove",args:[e,t,i]}),P.debug("removeEventListener:","#eventQueue pushed remove args:",[e,t,i])),r&&this.#A.delete(t)}adoptedCallback(){throw this.remove(),this.#_.create("This component cannot be rerendered for security reasons.")}connectedCallback(){if(P.trace("connectedCallback: called",`_uuid: ${this._uuid}`),window.addEventListener("message",this.#v),this.hasChildNodes())throw this.#_.create("Should not have child nodes");this.style.display||="block",this.style.width||="100%",this.style.height||="100%",this.#C=C.registerComponent(this),this._standardName=this.#C._getComponentStandardName(this),this.#C.applicationReady&&this._init()}disconnectedCallback(){P.trace("disconnectedCallback: called",`_uuid: ${this._uuid}`),this.#P.destroy(),window.removeEventListener("message",this.#v),C.unregisterComponent(this),this.#L?.disconnect()}connectedMoveCallback(){}}const O=/^(.*?)vforcesite\/secur\//;class U{config;errorHandler;#U;#N;constructor(e,t){if(this.config=e,this.errorHandler=t,!this.config.origin)throw this.errorHandler('Missing "frontdoor-url" or "org-url" attribute');this.#U=this.#T()}get sitePrefixWarning(){return this.#N}#T(){const{sitePrefix:e,frontdoorUrl:t}=this.config,i=t?.pathname.match(O);if(!i)return void 0===e?void 0:this.#I(e);const r=this.#I(i[1]);if(void 0!==e)return this.#I(e)!==r&&(this.#N=`"site-prefix" ("${e}") doesn't match the site in "frontdoor-url", so Lightning Out uses that site. Set site-prefix="${r}".`),r;this.#N=`"frontdoor-url" is for an Experience Cloud site, but "site-prefix" isn't set, so components can't load from the site. Set site-prefix="${r}".`}#I(e){const t=e.trim().split(/[/\\]+/).filter(Boolean);return t.length?`/${t.join("/")}`:""}getComponentURL(e,t){let i;if(void 0===this.#U){let t=e.includes("/")?this.config.lwrAppComp:e.includes(":")?this.config.lwrAppAura:void 0;if(void 0===t)throw this.errorHandler(`Invalid componentName: ${e}`);t=t.replace("/","%2F");const r=this.config.lang?`l/${this.config.lang}/`:"";i=new URL(`lwr/application/amd/0/${r}ai/${t}`,this.config.origin)}else i=new URL(this.config.origin),i.pathname=`${this.#U}/lightning-out`;return i.searchParams.set("componentName",e),this.#k(i,t)}getAuthURL(e){let t;if(void 0===this.#U){const e=this.config.lwrAppAuth.replace("/","%2F");t=new URL(`lwr/application/amd/0/ai/${e}`,this.config.origin)}else t=new URL(this.config.lwrPageAuth,this.config.origin);return this.#k(t,e)}getPageURL(e,t){const i=new URL(e,this.config.origin);return this.#k(i,t)}#k(e,t){return e.searchParams.set("parentElementId",t),e.searchParams.set("loAppOrigin",this.config.loAppOrigin),e.searchParams.set("loVersion","2.3.0"),this.config.appId&&e.searchParams.set("appId",this.config.appId),this.config.testMode&&e.searchParams.set("testMode","true"),this.config.designSystem&&e.searchParams.set("designSystem",this.config.designSystem),this.config.globalStyle&&e.searchParams.set("globalStyle",this.config.globalStyle),e}}const N=new i("LightningOutApplication"),T=new Set(["slds1","slds2","none"]),I=new Set(["frontdoorUrl","orgUrl"]);class k extends HTMLElement{_uuid=r();applicationReady=!1;#_=new m(this);#P=new y({parentElement:this});#M;#L;#j="";#D="lightningout/auth";#W="lightningout/container";#F="lightningout/auraContainer";#H="lightning/lightning.out.auth.html";#z="lightning/lightning.out.logout.html";#K="lightning/lightning.out.auth.error.html";#Q="/secur/logout.jsp";lwrApplication;orgUrl;#Z;frontdoorUrl;#V;appId;#q;components;#J=new Map;sitePrefix;#U;designSystem;#B;globalStyle;#G;#X=document.documentElement.lang??"";#Y=!1;#ee=null;#te=null;constructor(){super(),N.trace("constructor: called",`_uuid: ${this._uuid}`),C.registerApplication(this)}addEventListener(e,t,i){if(e===s.application.ready&&this.applicationReady){const e=new CustomEvent(s.application.ready);queueMicrotask(()=>{"function"==typeof t?t.call(this,e):t.handleEvent(e)})}super.addEventListener(e,t,i)}#ie(e){try{this.#Z=new URL(e)}catch{throw this.#_.create(`Invalid org-url: ${e}`)}this.dispatchEvent(new CustomEvent(s.iframe.load,{detail:this.#Z.origin}))}#re(e){let t;this.applicationReady&&this.getRouter();try{this.#V=new URL(e),this.#j=this.#V.origin,t=this.#se();const i=t.getAuthURL(this._uuid),r=t.getPageURL(this.#K,this._uuid),s=r.pathname+r.search;i.searchParams.set("error-redirect-uri",s);const o=this.#V.searchParams.has("otp")?"startURL":"retURL";this.#V.searchParams.set(o,i.pathname+i.search),this.#V.searchParams.set("error-redirect-uri",s)}catch{throw this.#_.create(`Invalid frontdoor-url: ${e}`)}t.sitePrefixWarning&&N.warn(t.sitePrefixWarning),this.#P.load(this.#V.href)}#oe(){const e=new URL(this.#Q,this.#j),t=this.#ne(this.#z);e.searchParams.set("redirect-uri",t.pathname+t.search),this.#P.load(e.href)}getRouter(){return void 0===this.#M&&(this.#M=this.#se()),this.#M}_getComponentURL(e,t){return this.getRouter().getComponentURL(e,t)}#se(){const e={origin:this.#j,frontdoorUrl:this.#V,lwrPageAuth:this.#H,lwrAppAuth:this.#D,lwrAppComp:this.#W,lwrAppAura:this.#F,sitePrefix:this.#U,lang:this.#X,appId:this.#q,testMode:this.__testMode||!1,loAppOrigin:window.location.origin,designSystem:this.#B,globalStyle:this.#G};return new U(e,e=>this.#_.create(e))}#ne(e){return this.getRouter().getPageURL(e,this._uuid)}#ae=e=>{this.applicationReady=!0;const t=e.detail;return this.#j="string"==typeof t?t:t.lightningDomain||t.origin,this.#M=void 0,this.#Y?(N.trace("#iframeLoaded: frontdoor-url refresh path"),this.#Y=!1,void this.dispatchEvent(new CustomEvent(s.application.session.refresh))):this.#te?(N.trace("#iframeLoaded: sessionRefresh() reload path"),clearTimeout(this.#te.timeoutId),this.#te.resolve(),void(this.#te=null)):(N.trace("#iframeLoaded: initial-auth path"),this.#he(),void this.dispatchEvent(new CustomEvent(s.application.ready)))};sessionExpiry(){if(void 0!==this.#Z)return Promise.reject(this.#_.create(p));if(!this.applicationReady)return Promise.reject(this.#_.create(a));if(this.#ee)return this.#ee.promise;let e,t;const i=new Promise((i,r)=>{e=i,t=r}),r=window.setTimeout(()=>{const e=this.#ee;this.#ee=null,e?.reject(this.#_.create(h))},3e4);return this.#ee={promise:i,resolve:e,reject:t,timeoutId:r},this.#P.postMessage({type:o.sessionExpiry,id:this._uuid}),i}sessionRefresh(){if(void 0!==this.#Z)return Promise.reject(this.#_.create(p));if(!this.applicationReady)return Promise.reject(this.#_.create(a));if(this.#te)return this.#te.promise;let e,t;const i=new Promise((i,r)=>{e=i,t=r}),r=window.setTimeout(()=>{const e=this.#te;this.#te=null,e?.reject(this.#_.create(h))},6e4);return this.#te={promise:i,resolve:e,reject:t,timeoutId:r},this.#P.postMessage({type:o.authReload,id:this._uuid}),i}_handleSessionExpiryResponse(e){const t=this.#ee;t&&(clearTimeout(t.timeoutId),this.#ee=null,void 0!==e.error?t.reject(this.#_.create(e.error)):void 0===e.ttl?t.reject(this.#_.create(d)):t.resolve(e.ttl))}#le(e){const t=this.#te;t&&(clearTimeout(t.timeoutId),this.#te=null,t.reject(this.#_.create(e)))}#de(e){const t=this.#ee;t&&(clearTimeout(t.timeoutId),this.#ee=null,t.reject(this.#_.create(e)))}#ce(e){this.#le(e),this.#de(e)}#pe=e=>{this.#Y=!1;const t=e.detail?.message;this.#ce(t??l),this.#_.dispatch(s.application.error,e)};#me=e=>{this.dispatchEvent(new CustomEvent(s.application.logout))};#ue=e=>{this.dispatchEvent(new CustomEvent(s.application.auth.redirect,{detail:e.detail}))};#he(){C.getComps(this).forEach(e=>{e._init()})}#x=e=>{const t={},i={};Object.keys(e).forEach(r=>{I.has(r)?i[r]=e[r]:t[r]=e[r]}),b(this,t),b(this,i)};#O=(e,t)=>t?"lang"===e:!e.startsWith("_")&&!v(e);_propertyChanged_lwrApplication=e=>{if(void 0!==e){const t=e.split("/");if(2!==t.length||!t[0]||!t[1])throw this.#_.create(`"${e}" is not a valid lwr-application name, must be of the form 'namespace/name'`);this.#W=e}};_propertyChanged_lang=e=>{this.#X=e??""};_propertyChanged_orgUrl=e=>{if(void 0!==e){if(void 0!==this.#V)throw this.#_.create('Can\'t set "org-url" because "frontdoor-url" is already set');""===e?this.#oe():this.#ie(e)}};_propertyChanged_frontdoorUrl=e=>{if(void 0===e)return;if(void 0!==this.#Z)throw this.#_.create('Can\'t set "frontdoor-url" because "org-url" is already set');if(""===e)return this.#ce(c),void this.#oe();const t=null!==this.#te;this.#ce(c),this.#Y=this.applicationReady&&!t,this.#re(e)};_propertyChanged_sitePrefix=e=>{void 0!==e&&(this.#U=e??void 0)};_propertyChanged_appId=e=>{void 0!==e&&(this.#q=e)};_propertyChanged_globalStyle=e=>{if(void 0!==e){const t=e.split(";").map(e=>e.trim()).filter(e=>e.length>0),i=[];for(const e of t){const[t,...r]=e.split(":"),s=t.trim();if(!s.startsWith("--"))throw this.#_.create(`Invalid global-style: "${s}" is not a CSS custom property. Only CSS custom properties (starting with --) are allowed.`);const o=r.join(":").trim();o&&i.push(`${s}:${o}`)}this.#G=i.join(";")+";"}};_propertyChanged_components=e=>{void 0!==e&&e.split(",").forEach(e=>{const[t,i]=e.split(" as ").map(e=>e.trim()),r=function(e){return e.includes("/")||e.includes(":")}(t);if(r&&t.includes(":"))throw this.#_.create(`"${t}" is not supported in components. Use kebab "namespace-name" in components and the "aura" attribute on the component element instead.`);const s=r?t:f(t),o=i||(r?function(e){const t=e.includes("/")?"/":":",i=e.indexOf(t);if(-1===i)throw u.create(`standardNameToElementName: "${e}" is not a valid component name - missing namespace separator.`);if(/-/.test(e))throw u.create(`standardNameToElementName: "${e}" is not a valid component name - must not contain hyphens.`);if(/^[A-Z]/.test(e))throw u.create(`standardNameToElementName: "${e}" is not a valid component name - first character must not be uppercase.`);const r=e.slice(0,i),s=e.slice(i+1);return`${r.replace(/([A-Z_])/g,"_$1").toLowerCase()}-${g(s)}`}(s):t);if(o&&!this.#J.has(o)){this.#J.set(o,s);try{C.registerComponentName(o,this),customElements.define(o,class extends x{})}catch(e){throw this.#_.create(`"${o}" is already registered. ${e}`)}}})};_propertyChanged_designSystem=e=>{if(void 0!==e&&!T.has(e))throw this.#_.create(`Invalid design-system: ${e}`);this.#B=e};_getComponentStandardName(e){const t=e.localName,i=e.hasAttribute("aura"),r=this.#J.get(t);if(!r)throw this.#_.create(`"${t}" is not registered.`);return i&&r.includes("/")?r.replace("/",":"):r}get _compNames(){}connectedCallback(){if(N.trace("connectedCallback: called",`_uuid: ${this._uuid}`),this.hasChildNodes())throw this.#_.create("Should not have child nodes");this.style.display||="none",this.addEventListener(s.iframe.load,this.#ae),this.addEventListener(s.iframe.error,this.#pe),this.addEventListener(s.iframe.logout,this.#me),this.addEventListener(s.iframe.auth.redirect,this.#ue),this.#L=new _(this,this.#x,this.#O)}disconnectedCallback(){N.trace("disconnectedCallback: called",`_uuid: ${this._uuid}`),this.#ce(c),this.#oe(),this.#P.destroy(),this.removeEventListener(s.iframe.load,this.#ae),this.removeEventListener(s.iframe.error,this.#pe),this.removeEventListener(s.iframe.logout,this.#me),this.removeEventListener(s.iframe.auth.redirect,this.#ue),this.#L?.disconnect()}connectedMoveCallback(){}}return i.level="debug",window.customElements.define("lightning-out-application",k),e.LightningOutApplication=k,e}({});
|
|
10
10
|
//# sourceMappingURL=index.iife.prod.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lightning-out",
|
|
3
|
-
"version": "2.3.0
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Lightning Out 2.0 for Salesforce",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"core": "2.3.0
|
|
26
|
-
"utils": "2.3.0
|
|
25
|
+
"core": "2.3.0",
|
|
26
|
+
"utils": "2.3.0"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"dist/",
|