@salesforce/lightning-out 2.2.3 → 2.2.4-rc.1
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 +176 -14
- package/dist/index.iife.debug.js +176 -14
- 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.2.
|
|
1
|
+
/*! @salesforce/lightning-out v2.2.4-rc.1 (2026-06-29) */
|
|
2
2
|
/**
|
|
3
3
|
* Numeric ranks for {@link LogLevel}; lower values are more severe.
|
|
4
4
|
*/
|
|
@@ -128,6 +128,9 @@ const events = {
|
|
|
128
128
|
auth: {
|
|
129
129
|
redirect: "lo.application.auth.redirect",
|
|
130
130
|
},
|
|
131
|
+
session: {
|
|
132
|
+
refresh: "lo.application.session.refresh",
|
|
133
|
+
},
|
|
131
134
|
},
|
|
132
135
|
/**
|
|
133
136
|
* Public events dispatched on individual component elements.
|
|
@@ -156,6 +159,7 @@ const events = {
|
|
|
156
159
|
const messages = {
|
|
157
160
|
lo: {
|
|
158
161
|
addEventListener: "lo.addEventListener",
|
|
162
|
+
authReload: "lo.auth.reload",
|
|
159
163
|
dispatchEvent: "lo.dispatchEvent",
|
|
160
164
|
error: "lo.error",
|
|
161
165
|
getComponentData: "lo.getComponentData",
|
|
@@ -164,6 +168,9 @@ const messages = {
|
|
|
164
168
|
ready: "lo.ready",
|
|
165
169
|
redirect: "lo.redirect",
|
|
166
170
|
removeEventListener: "lo.removeEventListener",
|
|
171
|
+
resize: "lo.resize",
|
|
172
|
+
sessionExpiry: "lo.sessionExpiry",
|
|
173
|
+
sessionExpiryResponse: "lo.sessionExpiry.response",
|
|
167
174
|
setComponentData: "lo.setComponentData",
|
|
168
175
|
setComponentProps: "lo.setComponentProps",
|
|
169
176
|
},
|
|
@@ -173,6 +180,16 @@ const messages = {
|
|
|
173
180
|
* Error class for Lightning Out
|
|
174
181
|
*/
|
|
175
182
|
const logger$4 = new Logger("LightningOutError");
|
|
183
|
+
const errorMessages = {
|
|
184
|
+
sessionNotReady: "Session not ready",
|
|
185
|
+
sessionRefreshSuperseded: "Session refresh superseded",
|
|
186
|
+
sessionRefreshTimeout: "Session refresh timeout",
|
|
187
|
+
sessionRefreshIframeError: "Session refresh failed: iframe error",
|
|
188
|
+
sessionExpiryTimeout: "Session expiry timeout",
|
|
189
|
+
sessionExpiryMalformedResponse: "Malformed sessionExpiry response",
|
|
190
|
+
sessionTerminated: "Session terminated",
|
|
191
|
+
notSupportedInOrgUrlMode: "Session APIs are not supported in org-url mode",
|
|
192
|
+
};
|
|
176
193
|
/**
|
|
177
194
|
* Branded error helper for Lightning Out. Wraps messages with the owning component's name and, when the owner is an
|
|
178
195
|
* `EventTarget`, dispatches them as `CustomEvent`s so consumers can react via `addEventListener`.
|
|
@@ -536,6 +553,15 @@ class LightningOutIFrame {
|
|
|
536
553
|
}));
|
|
537
554
|
break;
|
|
538
555
|
}
|
|
556
|
+
case messages.lo.resize: {
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
case messages.lo.sessionExpiryResponse: {
|
|
560
|
+
if (this.#parentElement instanceof LightningOutApplication) {
|
|
561
|
+
this.#parentElement._handleSessionExpiryResponse(event.data);
|
|
562
|
+
}
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
539
565
|
}
|
|
540
566
|
};
|
|
541
567
|
#handleResize(height) {
|
|
@@ -1462,7 +1488,7 @@ class LightningOutRouter {
|
|
|
1462
1488
|
url.searchParams.set("parentElementId", parentElementId);
|
|
1463
1489
|
url.searchParams.set("loAppOrigin", this.config.loAppOrigin);
|
|
1464
1490
|
// This helps in general but also for cache busting
|
|
1465
|
-
url.searchParams.set("loVersion", "2.2.
|
|
1491
|
+
url.searchParams.set("loVersion", "2.2.4-rc.1");
|
|
1466
1492
|
if (this.config.appId) {
|
|
1467
1493
|
url.searchParams.set("appId", this.config.appId);
|
|
1468
1494
|
}
|
|
@@ -1521,6 +1547,10 @@ class LightningOutApplication extends HTMLElement {
|
|
|
1521
1547
|
globalStyle;
|
|
1522
1548
|
#globalStyle;
|
|
1523
1549
|
#lang = document.documentElement.lang ?? "";
|
|
1550
|
+
// Session refresh state
|
|
1551
|
+
#isRefreshing = false;
|
|
1552
|
+
#promiseSessionExpiry = null;
|
|
1553
|
+
#promiseSessionRefresh = null;
|
|
1524
1554
|
constructor() {
|
|
1525
1555
|
super();
|
|
1526
1556
|
logger.trace("constructor: called", `_uuid: ${this._uuid}`);
|
|
@@ -1610,8 +1640,12 @@ class LightningOutApplication extends HTMLElement {
|
|
|
1610
1640
|
#getPageURL(pagePathname) {
|
|
1611
1641
|
return this.getRouter().getPageURL(pagePathname, this._uuid);
|
|
1612
1642
|
}
|
|
1643
|
+
// Three paths reach #iframeLoaded:
|
|
1644
|
+
// 1. frontdoor-url update (#isRefreshing=true): supersession in _propertyChanged_frontdoorUrl has already
|
|
1645
|
+
// cleared #promiseSessionRefresh, so only #isRefreshing needs to be checked.
|
|
1646
|
+
// 2. sessionRefresh()-initiated reload (#promiseSessionRefresh set): resolve and skip initial-auth bookkeeping.
|
|
1647
|
+
// 3. Initial auth (neither flag set): existing behavior.
|
|
1613
1648
|
#iframeLoaded = (event) => {
|
|
1614
|
-
// Set our internal flag
|
|
1615
1649
|
this.applicationReady = true;
|
|
1616
1650
|
const eventDetail = event.detail;
|
|
1617
1651
|
// Handle both old format (string) and new format (object with origin and lightningDomain)
|
|
@@ -1626,12 +1660,122 @@ class LightningOutApplication extends HTMLElement {
|
|
|
1626
1660
|
}
|
|
1627
1661
|
// Reset the router so it picks up the new origin in its config
|
|
1628
1662
|
this.#loRouter = undefined;
|
|
1663
|
+
if (this.#isRefreshing) {
|
|
1664
|
+
logger.trace("#iframeLoaded: frontdoor-url refresh path");
|
|
1665
|
+
this.#isRefreshing = false;
|
|
1666
|
+
this.dispatchEvent(new CustomEvent(events.lo.application.session.refresh));
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
if (this.#promiseSessionRefresh) {
|
|
1670
|
+
logger.trace("#iframeLoaded: sessionRefresh() reload path");
|
|
1671
|
+
clearTimeout(this.#promiseSessionRefresh.timeoutId);
|
|
1672
|
+
this.#promiseSessionRefresh.resolve();
|
|
1673
|
+
this.#promiseSessionRefresh = null;
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
logger.trace("#iframeLoaded: initial-auth path");
|
|
1629
1677
|
// Initiate registered components
|
|
1630
1678
|
this.#initComponents();
|
|
1631
|
-
// Notify the user that the application session is ready
|
|
1632
1679
|
this.dispatchEvent(new CustomEvent(events.lo.application.ready));
|
|
1633
1680
|
};
|
|
1681
|
+
sessionExpiry() {
|
|
1682
|
+
// org-url mode has no auth iframe to receive postMessages — fast-fail rather than hang.
|
|
1683
|
+
if (this.#orgUrl !== undefined) {
|
|
1684
|
+
return Promise.reject(this.#loError.create(errorMessages.notSupportedInOrgUrlMode));
|
|
1685
|
+
}
|
|
1686
|
+
if (!this.applicationReady) {
|
|
1687
|
+
return Promise.reject(this.#loError.create(errorMessages.sessionNotReady));
|
|
1688
|
+
}
|
|
1689
|
+
if (this.#promiseSessionExpiry) {
|
|
1690
|
+
// coalesce concurrent callers onto the same in-flight Promise
|
|
1691
|
+
return new Promise((resolve, reject) => {
|
|
1692
|
+
const slot = this.#promiseSessionExpiry;
|
|
1693
|
+
const prevResolve = slot.resolve;
|
|
1694
|
+
const prevReject = slot.reject;
|
|
1695
|
+
slot.resolve = (n) => {
|
|
1696
|
+
prevResolve(n);
|
|
1697
|
+
resolve(n);
|
|
1698
|
+
};
|
|
1699
|
+
slot.reject = (e) => {
|
|
1700
|
+
prevReject(e);
|
|
1701
|
+
reject(e);
|
|
1702
|
+
};
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
return new Promise((resolve, reject) => {
|
|
1706
|
+
const timeoutId = window.setTimeout(() => {
|
|
1707
|
+
// Read slot.reject (the chained wrapper) at fire time — the local `reject` only
|
|
1708
|
+
// resolves the first caller, while coalesced callers are reachable via slot.reject.
|
|
1709
|
+
const slot = this.#promiseSessionExpiry;
|
|
1710
|
+
this.#promiseSessionExpiry = null;
|
|
1711
|
+
slot?.reject(this.#loError.create(errorMessages.sessionExpiryTimeout));
|
|
1712
|
+
}, 30_000);
|
|
1713
|
+
this.#promiseSessionExpiry = { resolve, reject, timeoutId };
|
|
1714
|
+
this.#loIFrame.postMessage({ type: messages.lo.sessionExpiry, id: this._uuid });
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
sessionRefresh() {
|
|
1718
|
+
// org-url mode has no auth iframe to reload — fast-fail rather than hang.
|
|
1719
|
+
if (this.#orgUrl !== undefined) {
|
|
1720
|
+
return Promise.reject(this.#loError.create(errorMessages.notSupportedInOrgUrlMode));
|
|
1721
|
+
}
|
|
1722
|
+
if (!this.applicationReady) {
|
|
1723
|
+
return Promise.reject(this.#loError.create(errorMessages.sessionNotReady));
|
|
1724
|
+
}
|
|
1725
|
+
// Supersede in-flight refresh (caller initiated a new one) — reuse the in-progress reload.
|
|
1726
|
+
let shouldPostReload = true;
|
|
1727
|
+
if (this.#promiseSessionRefresh) {
|
|
1728
|
+
clearTimeout(this.#promiseSessionRefresh.timeoutId);
|
|
1729
|
+
this.#promiseSessionRefresh.reject(this.#loError.create(errorMessages.sessionRefreshSuperseded));
|
|
1730
|
+
this.#promiseSessionRefresh = null;
|
|
1731
|
+
shouldPostReload = false;
|
|
1732
|
+
}
|
|
1733
|
+
return new Promise((resolve, reject) => {
|
|
1734
|
+
const timeoutId = window.setTimeout(() => {
|
|
1735
|
+
this.#promiseSessionRefresh = null;
|
|
1736
|
+
reject(this.#loError.create(errorMessages.sessionRefreshTimeout));
|
|
1737
|
+
}, 60_000);
|
|
1738
|
+
this.#promiseSessionRefresh = { resolve, reject, timeoutId };
|
|
1739
|
+
if (shouldPostReload) {
|
|
1740
|
+
this.#loIFrame.postMessage({ type: messages.lo.authReload, id: this._uuid });
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* @internal
|
|
1746
|
+
*
|
|
1747
|
+
* Bridge: called from LightningOutIFrame.#messageListener on receipt of "lo.sessionExpiry.response".
|
|
1748
|
+
* Underscore-prefixed (not `#`-private) because JS private fields are lexically scoped to the declaring
|
|
1749
|
+
* class — a cross-class call from LightningOutIFrame.#messageListener cannot reach a `#`-private method.
|
|
1750
|
+
* Matches the existing `_getComponentURL` convention.
|
|
1751
|
+
*/
|
|
1752
|
+
_handleSessionExpiryResponse(msg) {
|
|
1753
|
+
const slot = this.#promiseSessionExpiry;
|
|
1754
|
+
if (!slot)
|
|
1755
|
+
return;
|
|
1756
|
+
clearTimeout(slot.timeoutId);
|
|
1757
|
+
this.#promiseSessionExpiry = null;
|
|
1758
|
+
if (msg.error !== undefined)
|
|
1759
|
+
slot.reject(this.#loError.create(msg.error));
|
|
1760
|
+
else if (msg.ttl === undefined)
|
|
1761
|
+
slot.reject(this.#loError.create(errorMessages.sessionExpiryMalformedResponse));
|
|
1762
|
+
else
|
|
1763
|
+
slot.resolve(msg.ttl);
|
|
1764
|
+
}
|
|
1765
|
+
#failPendingRefresh(detail) {
|
|
1766
|
+
const slot = this.#promiseSessionRefresh;
|
|
1767
|
+
if (!slot)
|
|
1768
|
+
return;
|
|
1769
|
+
clearTimeout(slot.timeoutId);
|
|
1770
|
+
this.#promiseSessionRefresh = null;
|
|
1771
|
+
slot.reject(this.#loError.create(detail));
|
|
1772
|
+
}
|
|
1634
1773
|
#iframeError = (event) => {
|
|
1774
|
+
// Reset #isRefreshing so a failed frontdoor-url refresh doesn't leave the flag stuck —
|
|
1775
|
+
// otherwise the NEXT successful #iframeLoaded would be misinterpreted as a refresh and
|
|
1776
|
+
// skip #initComponents() + lo.application.ready.
|
|
1777
|
+
this.#isRefreshing = false;
|
|
1778
|
+
this.#failPendingRefresh(event.detail?.message ?? errorMessages.sessionRefreshIframeError);
|
|
1635
1779
|
// Notify the user that the application session has failed
|
|
1636
1780
|
this.#loError.dispatch(events.lo.application.error, event);
|
|
1637
1781
|
};
|
|
@@ -1702,17 +1846,23 @@ class LightningOutApplication extends HTMLElement {
|
|
|
1702
1846
|
}
|
|
1703
1847
|
};
|
|
1704
1848
|
_propertyChanged_frontdoorUrl = (frontdoorUrl) => {
|
|
1705
|
-
if (frontdoorUrl
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
if (frontdoorUrl === "") {
|
|
1710
|
-
this.#logout();
|
|
1711
|
-
}
|
|
1712
|
-
else {
|
|
1713
|
-
this.#login(frontdoorUrl);
|
|
1714
|
-
}
|
|
1849
|
+
if (frontdoorUrl === undefined)
|
|
1850
|
+
return;
|
|
1851
|
+
if (this.#orgUrl !== undefined) {
|
|
1852
|
+
throw this.#loError.create(`Can't set "frontdoor-url" because "org-url" is already set`);
|
|
1715
1853
|
}
|
|
1854
|
+
if (frontdoorUrl === "") {
|
|
1855
|
+
this.#logout();
|
|
1856
|
+
return;
|
|
1857
|
+
}
|
|
1858
|
+
// Supersede any in-flight sessionRefresh()
|
|
1859
|
+
if (this.#promiseSessionRefresh) {
|
|
1860
|
+
clearTimeout(this.#promiseSessionRefresh.timeoutId);
|
|
1861
|
+
this.#promiseSessionRefresh.reject(this.#loError.create(errorMessages.sessionRefreshSuperseded));
|
|
1862
|
+
this.#promiseSessionRefresh = null;
|
|
1863
|
+
}
|
|
1864
|
+
this.#isRefreshing = this.applicationReady;
|
|
1865
|
+
this.#login(frontdoorUrl);
|
|
1716
1866
|
};
|
|
1717
1867
|
_propertyChanged_sitePrefix = (sitePrefix) => {
|
|
1718
1868
|
if (sitePrefix !== undefined) {
|
|
@@ -1831,6 +1981,18 @@ class LightningOutApplication extends HTMLElement {
|
|
|
1831
1981
|
}
|
|
1832
1982
|
disconnectedCallback() {
|
|
1833
1983
|
logger.trace("disconnectedCallback: called", `_uuid: ${this._uuid}`);
|
|
1984
|
+
// Reject pending session Promises before #logout() — the navigation it triggers would otherwise
|
|
1985
|
+
// resolve a pending refresh that should be terminated.
|
|
1986
|
+
if (this.#promiseSessionExpiry) {
|
|
1987
|
+
clearTimeout(this.#promiseSessionExpiry.timeoutId);
|
|
1988
|
+
this.#promiseSessionExpiry.reject(this.#loError.create(errorMessages.sessionTerminated));
|
|
1989
|
+
this.#promiseSessionExpiry = null;
|
|
1990
|
+
}
|
|
1991
|
+
if (this.#promiseSessionRefresh) {
|
|
1992
|
+
clearTimeout(this.#promiseSessionRefresh.timeoutId);
|
|
1993
|
+
this.#promiseSessionRefresh.reject(this.#loError.create(errorMessages.sessionTerminated));
|
|
1994
|
+
this.#promiseSessionRefresh = null;
|
|
1995
|
+
}
|
|
1834
1996
|
// Since disconnectedCallback is called after the DOM has been removed, calling logout and destroying the iframe
|
|
1835
1997
|
// here may be a moot point, but doing it for completeness.
|
|
1836
1998
|
this.#logout();
|
package/dist/index.iife.debug.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @salesforce/lightning-out v2.2.
|
|
1
|
+
/*! @salesforce/lightning-out v2.2.4-rc.1 (2026-06-29) */
|
|
2
2
|
var LO2 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -131,6 +131,9 @@ var LO2 = (function (exports) {
|
|
|
131
131
|
auth: {
|
|
132
132
|
redirect: "lo.application.auth.redirect",
|
|
133
133
|
},
|
|
134
|
+
session: {
|
|
135
|
+
refresh: "lo.application.session.refresh",
|
|
136
|
+
},
|
|
134
137
|
},
|
|
135
138
|
/**
|
|
136
139
|
* Public events dispatched on individual component elements.
|
|
@@ -159,6 +162,7 @@ var LO2 = (function (exports) {
|
|
|
159
162
|
const messages = {
|
|
160
163
|
lo: {
|
|
161
164
|
addEventListener: "lo.addEventListener",
|
|
165
|
+
authReload: "lo.auth.reload",
|
|
162
166
|
dispatchEvent: "lo.dispatchEvent",
|
|
163
167
|
error: "lo.error",
|
|
164
168
|
getComponentData: "lo.getComponentData",
|
|
@@ -167,6 +171,9 @@ var LO2 = (function (exports) {
|
|
|
167
171
|
ready: "lo.ready",
|
|
168
172
|
redirect: "lo.redirect",
|
|
169
173
|
removeEventListener: "lo.removeEventListener",
|
|
174
|
+
resize: "lo.resize",
|
|
175
|
+
sessionExpiry: "lo.sessionExpiry",
|
|
176
|
+
sessionExpiryResponse: "lo.sessionExpiry.response",
|
|
170
177
|
setComponentData: "lo.setComponentData",
|
|
171
178
|
setComponentProps: "lo.setComponentProps",
|
|
172
179
|
},
|
|
@@ -176,6 +183,16 @@ var LO2 = (function (exports) {
|
|
|
176
183
|
* Error class for Lightning Out
|
|
177
184
|
*/
|
|
178
185
|
const logger$4 = new Logger("LightningOutError");
|
|
186
|
+
const errorMessages = {
|
|
187
|
+
sessionNotReady: "Session not ready",
|
|
188
|
+
sessionRefreshSuperseded: "Session refresh superseded",
|
|
189
|
+
sessionRefreshTimeout: "Session refresh timeout",
|
|
190
|
+
sessionRefreshIframeError: "Session refresh failed: iframe error",
|
|
191
|
+
sessionExpiryTimeout: "Session expiry timeout",
|
|
192
|
+
sessionExpiryMalformedResponse: "Malformed sessionExpiry response",
|
|
193
|
+
sessionTerminated: "Session terminated",
|
|
194
|
+
notSupportedInOrgUrlMode: "Session APIs are not supported in org-url mode",
|
|
195
|
+
};
|
|
179
196
|
/**
|
|
180
197
|
* Branded error helper for Lightning Out. Wraps messages with the owning component's name and, when the owner is an
|
|
181
198
|
* `EventTarget`, dispatches them as `CustomEvent`s so consumers can react via `addEventListener`.
|
|
@@ -539,6 +556,15 @@ var LO2 = (function (exports) {
|
|
|
539
556
|
}));
|
|
540
557
|
break;
|
|
541
558
|
}
|
|
559
|
+
case messages.lo.resize: {
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
case messages.lo.sessionExpiryResponse: {
|
|
563
|
+
if (this.#parentElement instanceof LightningOutApplication) {
|
|
564
|
+
this.#parentElement._handleSessionExpiryResponse(event.data);
|
|
565
|
+
}
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
542
568
|
}
|
|
543
569
|
};
|
|
544
570
|
#handleResize(height) {
|
|
@@ -1465,7 +1491,7 @@ var LO2 = (function (exports) {
|
|
|
1465
1491
|
url.searchParams.set("parentElementId", parentElementId);
|
|
1466
1492
|
url.searchParams.set("loAppOrigin", this.config.loAppOrigin);
|
|
1467
1493
|
// This helps in general but also for cache busting
|
|
1468
|
-
url.searchParams.set("loVersion", "2.2.
|
|
1494
|
+
url.searchParams.set("loVersion", "2.2.4-rc.1");
|
|
1469
1495
|
if (this.config.appId) {
|
|
1470
1496
|
url.searchParams.set("appId", this.config.appId);
|
|
1471
1497
|
}
|
|
@@ -1524,6 +1550,10 @@ var LO2 = (function (exports) {
|
|
|
1524
1550
|
globalStyle;
|
|
1525
1551
|
#globalStyle;
|
|
1526
1552
|
#lang = document.documentElement.lang ?? "";
|
|
1553
|
+
// Session refresh state
|
|
1554
|
+
#isRefreshing = false;
|
|
1555
|
+
#promiseSessionExpiry = null;
|
|
1556
|
+
#promiseSessionRefresh = null;
|
|
1527
1557
|
constructor() {
|
|
1528
1558
|
super();
|
|
1529
1559
|
logger.trace("constructor: called", `_uuid: ${this._uuid}`);
|
|
@@ -1613,8 +1643,12 @@ var LO2 = (function (exports) {
|
|
|
1613
1643
|
#getPageURL(pagePathname) {
|
|
1614
1644
|
return this.getRouter().getPageURL(pagePathname, this._uuid);
|
|
1615
1645
|
}
|
|
1646
|
+
// Three paths reach #iframeLoaded:
|
|
1647
|
+
// 1. frontdoor-url update (#isRefreshing=true): supersession in _propertyChanged_frontdoorUrl has already
|
|
1648
|
+
// cleared #promiseSessionRefresh, so only #isRefreshing needs to be checked.
|
|
1649
|
+
// 2. sessionRefresh()-initiated reload (#promiseSessionRefresh set): resolve and skip initial-auth bookkeeping.
|
|
1650
|
+
// 3. Initial auth (neither flag set): existing behavior.
|
|
1616
1651
|
#iframeLoaded = (event) => {
|
|
1617
|
-
// Set our internal flag
|
|
1618
1652
|
this.applicationReady = true;
|
|
1619
1653
|
const eventDetail = event.detail;
|
|
1620
1654
|
// Handle both old format (string) and new format (object with origin and lightningDomain)
|
|
@@ -1629,12 +1663,122 @@ var LO2 = (function (exports) {
|
|
|
1629
1663
|
}
|
|
1630
1664
|
// Reset the router so it picks up the new origin in its config
|
|
1631
1665
|
this.#loRouter = undefined;
|
|
1666
|
+
if (this.#isRefreshing) {
|
|
1667
|
+
logger.trace("#iframeLoaded: frontdoor-url refresh path");
|
|
1668
|
+
this.#isRefreshing = false;
|
|
1669
|
+
this.dispatchEvent(new CustomEvent(events.lo.application.session.refresh));
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
if (this.#promiseSessionRefresh) {
|
|
1673
|
+
logger.trace("#iframeLoaded: sessionRefresh() reload path");
|
|
1674
|
+
clearTimeout(this.#promiseSessionRefresh.timeoutId);
|
|
1675
|
+
this.#promiseSessionRefresh.resolve();
|
|
1676
|
+
this.#promiseSessionRefresh = null;
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
logger.trace("#iframeLoaded: initial-auth path");
|
|
1632
1680
|
// Initiate registered components
|
|
1633
1681
|
this.#initComponents();
|
|
1634
|
-
// Notify the user that the application session is ready
|
|
1635
1682
|
this.dispatchEvent(new CustomEvent(events.lo.application.ready));
|
|
1636
1683
|
};
|
|
1684
|
+
sessionExpiry() {
|
|
1685
|
+
// org-url mode has no auth iframe to receive postMessages — fast-fail rather than hang.
|
|
1686
|
+
if (this.#orgUrl !== undefined) {
|
|
1687
|
+
return Promise.reject(this.#loError.create(errorMessages.notSupportedInOrgUrlMode));
|
|
1688
|
+
}
|
|
1689
|
+
if (!this.applicationReady) {
|
|
1690
|
+
return Promise.reject(this.#loError.create(errorMessages.sessionNotReady));
|
|
1691
|
+
}
|
|
1692
|
+
if (this.#promiseSessionExpiry) {
|
|
1693
|
+
// coalesce concurrent callers onto the same in-flight Promise
|
|
1694
|
+
return new Promise((resolve, reject) => {
|
|
1695
|
+
const slot = this.#promiseSessionExpiry;
|
|
1696
|
+
const prevResolve = slot.resolve;
|
|
1697
|
+
const prevReject = slot.reject;
|
|
1698
|
+
slot.resolve = (n) => {
|
|
1699
|
+
prevResolve(n);
|
|
1700
|
+
resolve(n);
|
|
1701
|
+
};
|
|
1702
|
+
slot.reject = (e) => {
|
|
1703
|
+
prevReject(e);
|
|
1704
|
+
reject(e);
|
|
1705
|
+
};
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
return new Promise((resolve, reject) => {
|
|
1709
|
+
const timeoutId = window.setTimeout(() => {
|
|
1710
|
+
// Read slot.reject (the chained wrapper) at fire time — the local `reject` only
|
|
1711
|
+
// resolves the first caller, while coalesced callers are reachable via slot.reject.
|
|
1712
|
+
const slot = this.#promiseSessionExpiry;
|
|
1713
|
+
this.#promiseSessionExpiry = null;
|
|
1714
|
+
slot?.reject(this.#loError.create(errorMessages.sessionExpiryTimeout));
|
|
1715
|
+
}, 30_000);
|
|
1716
|
+
this.#promiseSessionExpiry = { resolve, reject, timeoutId };
|
|
1717
|
+
this.#loIFrame.postMessage({ type: messages.lo.sessionExpiry, id: this._uuid });
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
sessionRefresh() {
|
|
1721
|
+
// org-url mode has no auth iframe to reload — fast-fail rather than hang.
|
|
1722
|
+
if (this.#orgUrl !== undefined) {
|
|
1723
|
+
return Promise.reject(this.#loError.create(errorMessages.notSupportedInOrgUrlMode));
|
|
1724
|
+
}
|
|
1725
|
+
if (!this.applicationReady) {
|
|
1726
|
+
return Promise.reject(this.#loError.create(errorMessages.sessionNotReady));
|
|
1727
|
+
}
|
|
1728
|
+
// Supersede in-flight refresh (caller initiated a new one) — reuse the in-progress reload.
|
|
1729
|
+
let shouldPostReload = true;
|
|
1730
|
+
if (this.#promiseSessionRefresh) {
|
|
1731
|
+
clearTimeout(this.#promiseSessionRefresh.timeoutId);
|
|
1732
|
+
this.#promiseSessionRefresh.reject(this.#loError.create(errorMessages.sessionRefreshSuperseded));
|
|
1733
|
+
this.#promiseSessionRefresh = null;
|
|
1734
|
+
shouldPostReload = false;
|
|
1735
|
+
}
|
|
1736
|
+
return new Promise((resolve, reject) => {
|
|
1737
|
+
const timeoutId = window.setTimeout(() => {
|
|
1738
|
+
this.#promiseSessionRefresh = null;
|
|
1739
|
+
reject(this.#loError.create(errorMessages.sessionRefreshTimeout));
|
|
1740
|
+
}, 60_000);
|
|
1741
|
+
this.#promiseSessionRefresh = { resolve, reject, timeoutId };
|
|
1742
|
+
if (shouldPostReload) {
|
|
1743
|
+
this.#loIFrame.postMessage({ type: messages.lo.authReload, id: this._uuid });
|
|
1744
|
+
}
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* @internal
|
|
1749
|
+
*
|
|
1750
|
+
* Bridge: called from LightningOutIFrame.#messageListener on receipt of "lo.sessionExpiry.response".
|
|
1751
|
+
* Underscore-prefixed (not `#`-private) because JS private fields are lexically scoped to the declaring
|
|
1752
|
+
* class — a cross-class call from LightningOutIFrame.#messageListener cannot reach a `#`-private method.
|
|
1753
|
+
* Matches the existing `_getComponentURL` convention.
|
|
1754
|
+
*/
|
|
1755
|
+
_handleSessionExpiryResponse(msg) {
|
|
1756
|
+
const slot = this.#promiseSessionExpiry;
|
|
1757
|
+
if (!slot)
|
|
1758
|
+
return;
|
|
1759
|
+
clearTimeout(slot.timeoutId);
|
|
1760
|
+
this.#promiseSessionExpiry = null;
|
|
1761
|
+
if (msg.error !== undefined)
|
|
1762
|
+
slot.reject(this.#loError.create(msg.error));
|
|
1763
|
+
else if (msg.ttl === undefined)
|
|
1764
|
+
slot.reject(this.#loError.create(errorMessages.sessionExpiryMalformedResponse));
|
|
1765
|
+
else
|
|
1766
|
+
slot.resolve(msg.ttl);
|
|
1767
|
+
}
|
|
1768
|
+
#failPendingRefresh(detail) {
|
|
1769
|
+
const slot = this.#promiseSessionRefresh;
|
|
1770
|
+
if (!slot)
|
|
1771
|
+
return;
|
|
1772
|
+
clearTimeout(slot.timeoutId);
|
|
1773
|
+
this.#promiseSessionRefresh = null;
|
|
1774
|
+
slot.reject(this.#loError.create(detail));
|
|
1775
|
+
}
|
|
1637
1776
|
#iframeError = (event) => {
|
|
1777
|
+
// Reset #isRefreshing so a failed frontdoor-url refresh doesn't leave the flag stuck —
|
|
1778
|
+
// otherwise the NEXT successful #iframeLoaded would be misinterpreted as a refresh and
|
|
1779
|
+
// skip #initComponents() + lo.application.ready.
|
|
1780
|
+
this.#isRefreshing = false;
|
|
1781
|
+
this.#failPendingRefresh(event.detail?.message ?? errorMessages.sessionRefreshIframeError);
|
|
1638
1782
|
// Notify the user that the application session has failed
|
|
1639
1783
|
this.#loError.dispatch(events.lo.application.error, event);
|
|
1640
1784
|
};
|
|
@@ -1705,17 +1849,23 @@ var LO2 = (function (exports) {
|
|
|
1705
1849
|
}
|
|
1706
1850
|
};
|
|
1707
1851
|
_propertyChanged_frontdoorUrl = (frontdoorUrl) => {
|
|
1708
|
-
if (frontdoorUrl
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
if (frontdoorUrl === "") {
|
|
1713
|
-
this.#logout();
|
|
1714
|
-
}
|
|
1715
|
-
else {
|
|
1716
|
-
this.#login(frontdoorUrl);
|
|
1717
|
-
}
|
|
1852
|
+
if (frontdoorUrl === undefined)
|
|
1853
|
+
return;
|
|
1854
|
+
if (this.#orgUrl !== undefined) {
|
|
1855
|
+
throw this.#loError.create(`Can't set "frontdoor-url" because "org-url" is already set`);
|
|
1718
1856
|
}
|
|
1857
|
+
if (frontdoorUrl === "") {
|
|
1858
|
+
this.#logout();
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
// Supersede any in-flight sessionRefresh()
|
|
1862
|
+
if (this.#promiseSessionRefresh) {
|
|
1863
|
+
clearTimeout(this.#promiseSessionRefresh.timeoutId);
|
|
1864
|
+
this.#promiseSessionRefresh.reject(this.#loError.create(errorMessages.sessionRefreshSuperseded));
|
|
1865
|
+
this.#promiseSessionRefresh = null;
|
|
1866
|
+
}
|
|
1867
|
+
this.#isRefreshing = this.applicationReady;
|
|
1868
|
+
this.#login(frontdoorUrl);
|
|
1719
1869
|
};
|
|
1720
1870
|
_propertyChanged_sitePrefix = (sitePrefix) => {
|
|
1721
1871
|
if (sitePrefix !== undefined) {
|
|
@@ -1834,6 +1984,18 @@ var LO2 = (function (exports) {
|
|
|
1834
1984
|
}
|
|
1835
1985
|
disconnectedCallback() {
|
|
1836
1986
|
logger.trace("disconnectedCallback: called", `_uuid: ${this._uuid}`);
|
|
1987
|
+
// Reject pending session Promises before #logout() — the navigation it triggers would otherwise
|
|
1988
|
+
// resolve a pending refresh that should be terminated.
|
|
1989
|
+
if (this.#promiseSessionExpiry) {
|
|
1990
|
+
clearTimeout(this.#promiseSessionExpiry.timeoutId);
|
|
1991
|
+
this.#promiseSessionExpiry.reject(this.#loError.create(errorMessages.sessionTerminated));
|
|
1992
|
+
this.#promiseSessionExpiry = null;
|
|
1993
|
+
}
|
|
1994
|
+
if (this.#promiseSessionRefresh) {
|
|
1995
|
+
clearTimeout(this.#promiseSessionRefresh.timeoutId);
|
|
1996
|
+
this.#promiseSessionRefresh.reject(this.#loError.create(errorMessages.sessionTerminated));
|
|
1997
|
+
this.#promiseSessionRefresh = null;
|
|
1998
|
+
}
|
|
1837
1999
|
// Since disconnectedCallback is called after the DOM has been removed, calling logout and destroying the iframe
|
|
1838
2000
|
// here may be a moot point, but doing it for completeness.
|
|
1839
2001
|
this.#logout();
|
package/dist/index.iife.prod.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @salesforce/lightning-out v2.2.
|
|
2
|
-
var LO2=function(e){"use strict";const t={error:0,warn:1,info:2,debug:3,trace:4};class r{static#e="LO2";static#t="error";#r;static set level(e){this.#t=e}static set prefix(e){this.#e=e}get brand(){return`${r.#e}:${this.#r}:`}constructor(e){this.#r="string"==typeof e?e:e.constructor?.name}error(...e){t.error<=t[r.#t]&&console.error(this.brand,...e)}warn(...e){t.warn<=t[r.#t]&&console.warn(this.brand,...e)}info(...e){t.info<=t[r.#t]&&console.info(this.brand,...e)}debug(...e){t.debug<=t[r.#t]&&console.debug(this.brand,...e)}trace(...e){t.trace<=t[r.#t]&&console.trace(this.brand,...e)}}function i(){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"}},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",dispatchEvent:"lo.dispatchEvent",error:"lo.error",getComponentData:"lo.getComponentData",loaded:"lo.loaded",logout:"lo.logout",ready:"lo.ready",redirect:"lo.redirect",removeEventListener:"lo.removeEventListener",setComponentData:"lo.setComponentData",setComponentProps:"lo.setComponentProps"},n=new r("LightningOutError");class
|
|
1
|
+
/*! @salesforce/lightning-out v2.2.4-rc.1 (2026-06-29) */
|
|
2
|
+
var LO2=function(e){"use strict";const t={error:0,warn:1,info:2,debug:3,trace:4};class r{static#e="LO2";static#t="error";#r;static set level(e){this.#t=e}static set prefix(e){this.#e=e}get brand(){return`${r.#e}:${this.#r}:`}constructor(e){this.#r="string"==typeof e?e:e.constructor?.name}error(...e){t.error<=t[r.#t]&&console.error(this.brand,...e)}warn(...e){t.warn<=t[r.#t]&&console.warn(this.brand,...e)}info(...e){t.info<=t[r.#t]&&console.info(this.brand,...e)}debug(...e){t.debug<=t[r.#t]&&console.debug(this.brand,...e)}trace(...e){t.trace<=t[r.#t]&&console.trace(this.brand,...e)}}function i(){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 r("LightningOutError"),a="Session not ready",h="Session refresh superseded",l="Session refresh timeout",c="Session refresh failed: iframe error",p="Session expiry timeout",d="Malformed sessionExpiry response",m="Session terminated",u="Session APIs are not supported in org-url mode";class g{#i;#r;constructor(e){this.#r="string"==typeof e?e:e.constructor?.name,"function"==typeof e.dispatchEvent&&(this.#i=e)}#s(e){return`${this.#r}: ${e}`}create(e){const t="string"==typeof e?e:e.message;return new Error(this.#s(t))}dispatch(e,t){const r="string"==typeof t?t:t.message||t.detail?.message;if(this.#i){const i=t.detail||{message:this.#s(r),originalError:t},s=new CustomEvent(e,{detail:i});this.#i.dispatchEvent(s),n.error(`${this.#s("dispatched error")} -> ${e}: ${r}`)}else n.error(`${this.#s("unable to dispatch error on a non-EventTarget object")} -> ${e}: ${r}`)}}const f=new g("LightningOutUtils");function v(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function b(e,t=!1){if(/[A-Z]/.test(e))throw f.create(`elementNameToStandardName: "${e}" is not a valid custom element name - must be all lowercase.`);const r=e.indexOf("-");if(-1===r)throw f.create(`elementNameToStandardName: "${e}" is not a valid custom element name - missing hyphen character.`);return`${function(e){if(/[A-Z]/.test(e))throw f.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,r))}${t?":":"/"}${function(e){if(/[A-Z]/.test(e))throw f.create(`kebabToCamel: "${e}" is not valid kebab-case - must be all lowercase.`);return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}(e.slice(r+1))}`}function w(e,t){const r=Object.entries(t).map(t=>{let[r,i]=t;const s=r.split("dataMirror");2===s.length&&""===s[0]&&(r=s[1].charAt(0).toLowerCase()+s[1].slice(1));const o=`_propertyChanged_${r}`;if("function"==typeof e[o]){i=(0,e[o])(i)}return[r,i]});return Object.fromEntries(r)}const E=new r("LightningOutIFrame");class y{#o;#n;#a;#h="display:none";#l="border:0px; width:100%; height:100%; overflow:auto;";#c;#p;#d;#m;#u;#g;constructor(e){this.#o=e.parentElement,this.#n=e.isVisible,this.#a=new g(e.parentElement)}get iframeReady(){return!!this.#d&&!!this.#m}get iframeElement(){return this.#p}#f(e,t){this.#d=e,this.#m=t}#v=e=>{if(e.data.id===this.#o._uuid)switch(E.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),this.#f(e.source,e.origin);const t=e.data.lightningDomain;this.#o.dispatchEvent(new CustomEvent(s.iframe.load,{detail:{origin:e.origin,lightningDomain:t}}));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.#p&&this.#n&&(this.#p.style.height=`${e}px`,E.debug(`#handleResize: applied height ${e}px to iframe`))}#w(){if(!this.#p){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.#p=e,this.#c=this.#o.attachShadow({mode:"closed"}),this.#c.appendChild(this.#p),e.addEventListener("load",this.#E),window.addEventListener("message",this.#v)}return this.#p}load(e){const t=this.#w();this.#u=new URL(e),E.debug("#loadIframe: endpoint =",function(e){const t={},r=e=>{const t={};for(const[r,i]of e.entries())t[r]=i;return t};if(t.url=e.origin+e.pathname,t.urlParams=r(e.searchParams),"/secur/frontdoor.jsp"===e.pathname){const e=t.urlParams.otp?"startURL":"retURL",i=new URL(t.urlParams[e],"http://dummy.com");t.urlParams[e]={url:i.pathname,urlParams:r(i.searchParams)}}return t}(this.#u)),this.#f(void 0,void 0),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}#E=()=>{this.#g&&clearTimeout(this.#g),this.#g=setTimeout(()=>{if(!this.iframeReady){const e="Error: Unknown error, unable to load the iframe.";this.#a.dispatch(s.iframe.error,e),this.#y(e)}},6e4)};destroy(){this.#c&&(this.#c.innerHTML=""),this.#p&&this.#p.remove(),this.#c=void 0,this.#p=void 0,this.#f(void 0,void 0)}#y(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.#d||!this.#m)throw this.#a.create("Error attempting to postMessage on an iframe that is not ready.");E.debug("postMessage:",`parentElement: ${this.#o._uuid}`,JSON.stringify(e));try{this.#d.postMessage(e,this.#m)}catch(e){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 u=new r("PropertyObserver");class g{_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,r){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(r&&"function"!=typeof r)throw new TypeError("shouldObserve callback must be a function");this._el=e,this._cb=t,this._cache=new Map,this._shouldObserve=r||((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 r=t.name,i=this._isStandardAttribute(r);if(!this._shouldObserve(r,i))continue;const s=this._attributeNameToPropName(r),o=t.value;e[s]=o,this._cache.set(s,o),this._installPropertyInterceptor(s)}for(const t of Object.getOwnPropertyNames(this._el)){const r=this._isStandardProperty(t);if(this._cache.has(t)||!this._shouldObserve(t,r))continue;const i=this._el[t];e[t]=i,this._cache.set(t,i),this._installPropertyInterceptor(t)}if(Object.keys(e).length>0)try{this._cb(e)}catch(e){u.error("Error in initial PropertyObserver callback:",e)}}_setupMutationObserver(){this._observer=new MutationObserver(e=>{const t={};for(const r of e)if("attributes"===r.type&&r.attributeName){const e=r.attributeName,i=this._isStandardAttribute(e);if(!this._shouldObserve(e,i))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 r={enumerable:t.enumerable,configurable:t.configurable,get:t.get||(()=>t.value),set:r=>{r!==this._cache.get(e)&&(t.set?t.set.call(this._el,r):t.value=r,this._cache.set(e,r),this._batchChanges({[e]:r}))}};Object.defineProperty(this._el,e,r),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){u.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 f=new class{#_=new a("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 r=t;if(!r){const t=e.localName;if(r=this.compNameToApp.get(t),!r)throw this.#_.create(`Could not find a parent App for component "${e.localName}"`)}return this.appToComps.get(r).add(e),this.compToApp.set(e,r),r}unregisterComponent(e){const t=this.compToApp.get(e);if(!t)return!1;const r=this.appToComps.get(t);return r?.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}},v=new r("LightningOutComponent"),b=new Set(["autocapitalize","autocorrect","dir","enterkeyhint","inputmode","lang","spellcheck","style","title","translate"]),w=new Set(["aria-disabled","aria-hidden","aria-label","aria-live","aria-modal","aria-pressed","aria-valuemax","aria-valuemin","aria-valuenow"]),y=new Set(["accesskey","autofocus","draggable","exportparts","hidden","inert","nonce","part","slot","tabindex"]),E=new Set(["aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"]);class _ extends HTMLElement{_uuid=i();componentReady=!1;_standardName=c(this.localName);#C;#_=new a(this);#L=new m({parentElement:this,isVisible:!0});#A;#P=!0;#O=[];#R=new WeakMap;#$=0;constructor(){super(),v.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(e.data.id===this._uuid)switch(v.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.#O.length;){const e=this.#O.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.#A=new g(this,this.#U,this.#S);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:v.info("#messageListener:","Unknown message received:",{"event.data":e.data})}};_propertyChanged_style=e=>{const t=this.style,r=[];for(let e=0;e<t.length;e+=1){const i=t.item(e);i.startsWith("--")&&r.push(`${i}:${t.getPropertyValue(i)}`)}return r.join(";")};#U=e=>{const t=d(this,e);v.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})};#S=(e,t)=>{const r=h(e);return v.debug("#shouldObserveCallback:",{attrOrPropName:e,attrName:r,isStandard:t}),t?!(!b.has(r)&&!w.has(r))||(y.has(r)||E.has(r)||r.startsWith("on")?(v.warn(`"${r}" will not be mirrored.`),!1):!!r.startsWith("data-mirror-")||(v.warn(`"${r}" will not be mirrored.`),!1)):!r.startsWith("_")};addEventListener(e,t,r){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,r);let i=this.#R.get(t);i||(i=`${e}_${this.#$++}`,this.#R.set(t,i)),this.componentReady?(super.addEventListener(...arguments),this.#L.postMessage({name:e,options:r,listenerKey:i,type:o.addEventListener})):(this.#O.push({type:"add",args:[e,t,r]}),v.debug("addEventListener:","#eventQueue pushed add args:",[e,t,r]))}dispatchEvent(e){if(e.type.startsWith("lo."))return v.debug(`dispatchEvent: dispatching event "${e.type}" to this Element only`),super.dispatchEvent(e);if(this.componentReady){v.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 v.debug(`dispatchEvent: component not ready, queueing event "${e.type}"`),this.#O.push({type:"dispatch",event:e}),!0}removeEventListener(e,t,r){if(e.startsWith("lo."))return void super.removeEventListener(...arguments);const i=this.#R.get(t);this.componentReady?(super.removeEventListener(...arguments),this.#L.postMessage({name:e,options:r,listenerKey:i,type:o.removeEventListener})):(this.#O.push({type:"remove",args:[e,t,r]}),v.debug("removeEventListener:","#eventQueue pushed remove args:",[e,t,r])),i&&this.#R.delete(t)}adoptedCallback(){throw this.remove(),this.#_.create("This component cannot be rerendered for security reasons.")}connectedCallback(){if(v.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=f.registerComponent(this),this._standardName=this.#C._getComponentStandardName(this),this.#C.applicationReady&&this._init()}disconnectedCallback(){v.trace("disconnectedCallback: called",`_uuid: ${this._uuid}`),this.#L.destroy(),window.removeEventListener("message",this.#v),f.unregisterComponent(this),this.#A?.disconnect()}connectedMoveCallback(){}}class C{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 r;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 i=this.config.lang?`l/${this.config.lang}/`:"";r=new URL(`lwr/application/amd/0/${i}ai/${t}`,this.config.origin)}else r=new URL(`${this.config.sitePrefix}/lightning-out`,this.config.origin);return r.searchParams.set("componentName",e),this.#N(r,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 r=new URL(e,this.config.origin);return this.#N(r,t)}#N(e,t){return e.searchParams.set("parentElementId",t),e.searchParams.set("loAppOrigin",this.config.loAppOrigin),e.searchParams.set("loVersion","2.2.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 L=new r("LightningOutApplication"),A=new Set(["slds1","slds2","none"]),P=new Set(["frontdoorUrl","orgUrl"]);class O extends HTMLElement{_uuid=i();applicationReady=!1;#_=new a(this);#L=new m({parentElement:this,isVisible:!1});#k;#A;#T="";#I="lightningout/auth";#M="lightningout/container";#x="lightningout/auraContainer";#D="lightning/lightning.out.auth.html";#F="lightning/lightning.out.logout.html";#j="lightning/lightning.out.auth.error.html";#W="/secur/logout.jsp";lwrApplication;orgUrl;#V;frontdoorUrl;#H;appId;#K;components;#Q=new Map;sitePrefix;#z;designSystem;#Z;globalStyle;#q;#J=document.documentElement.lang??"";constructor(){super(),L.trace("constructor: called",`_uuid: ${this._uuid}`),f.registerApplication(this)}addEventListener(e,t,r){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,r)}#G(e){try{this.#V=new URL(e)}catch{throw this.#_.create(`Invalid org-url: ${e}`)}this.dispatchEvent(new CustomEvent(s.iframe.load,{detail:this.#V.origin}))}#X(e){try{this.#H=new URL(e),this.#T=this.#H.origin;const t=this.#B(),r=this.#H.searchParams.has("otp")?"startURL":"retURL";this.#H.searchParams.set(r,t.pathname+t.search);const i=this.#Y(this.#j);this.#H.searchParams.set("error-redirect-uri",i.pathname+i.search)}catch{throw this.#_.create(`Invalid frontdoor-url: ${e}`)}this.#L.load(this.#H.href)}#ee(){const e=new URL(this.#W,this.#T),t=this.#Y(this.#F);e.searchParams.set("redirect-uri",t.pathname+t.search),this.#L.load(e.href)}getRouter(){if(void 0===this.#k){const e={origin:this.#T,lwrPageAuth:this.#D,lwrAppAuth:this.#I,lwrAppComp:this.#M,lwrAppAura:this.#x,sitePrefix:this.#z,lang:this.#J,appId:this.#K,testMode:this.__testMode||!1,loAppOrigin:window.location.origin,designSystem:this.#Z,globalStyle:this.#q};this.#k=new C(e,e=>this.#_.create(e))}return this.#k}_getComponentURL(e,t){return this.getRouter().getComponentURL(e,t)}#B(){return this.getRouter().getAuthURL(this._uuid)}#Y(e){return this.getRouter().getPageURL(e,this._uuid)}#te=e=>{this.applicationReady=!0;const t=e.detail;this.#T="string"==typeof t?t:t.lightningDomain||t.origin,this.#k=void 0,this.#re(),this.dispatchEvent(new CustomEvent(s.application.ready))};#ie=e=>{this.#_.dispatch(s.application.error,e)};#se=e=>{this.dispatchEvent(new CustomEvent(s.application.logout))};#oe=e=>{this.dispatchEvent(new CustomEvent(s.application.auth.redirect,{detail:e.detail}))};#re(){f.getComps(this).forEach(e=>{e._init()})}#U=e=>{const t={},r={};Object.keys(e).forEach(i=>{P.has(i)?r[i]=e[i]:t[i]=e[i]}),d(this,t),d(this,r)};#S=(e,t)=>t?"lang"===e:!e.startsWith("_");_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.#M=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.#ee():this.#G(e)}};_propertyChanged_frontdoorUrl=e=>{if(void 0!==e){if(void 0!==this.#V)throw this.#_.create('Can\'t set "frontdoor-url" because "org-url" is already set');""===e?this.#ee():this.#X(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),r=[];for(const e of t){const[t,...i]=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=i.join(":").trim();o&&r.push(`${s}:${o}`)}this.#q=r.join(";")+";"}};_propertyChanged_components=e=>{void 0!==e&&e.split(",").forEach(e=>{const[t,r]=e.split(" as ").map(e=>e.trim()),i=function(e){return e.includes("/")||e.includes(":")}(t);if(i&&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=i?t:c(t),o=r||(i?function(e){const t=e.includes("/")?"/":":",r=e.indexOf(t);if(-1===r)throw l.create(`standardNameToElementName: "${e}" is not a valid component name - missing namespace separator.`);if(/-/.test(e))throw l.create(`standardNameToElementName: "${e}" is not a valid component name - must not contain hyphens.`);if(/^[A-Z]/.test(e))throw l.create(`standardNameToElementName: "${e}" is not a valid component name - first character must not be uppercase.`);const i=e.slice(0,r),s=e.slice(r+1);return`${i.replace(/([A-Z_])/g,"_$1").toLowerCase()}-${h(s)}`}(s):t);if(o&&!this.#Q.has(o)){this.#Q.set(o,s);try{f.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&&!A.has(e))throw this.#_.create(`Invalid design-system: ${e}`);this.#Z=e};_getComponentStandardName(e){const t=e.localName,r=e.hasAttribute("aura"),i=this.#Q.get(t);if(!i)throw this.#_.create(`"${t}" is not registered.`);return r&&i.includes("/")?i.replace("/",":"):i}get _compNames(){}connectedCallback(){if(L.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.#te),this.addEventListener(s.iframe.error,this.#ie),this.addEventListener(s.iframe.logout,this.#se),this.addEventListener(s.iframe.auth.redirect,this.#oe),this.#A=new g(this,this.#U,this.#S)}disconnectedCallback(){L.trace("disconnectedCallback: called",`_uuid: ${this._uuid}`),this.#ee(),this.#L.destroy(),this.removeEventListener(s.iframe.load,this.#te),this.removeEventListener(s.iframe.error,this.#ie),this.removeEventListener(s.iframe.logout,this.#se),this.removeEventListener(s.iframe.auth.redirect,this.#oe),this.#A?.disconnect()}connectedMoveCallback(){}}return r.level="debug",window.customElements.define("lightning-out-application",O),e.LightningOutApplication=O,e}({});
|
|
9
|
+
*/const _=new r("PropertyObserver");class C{_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,r){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(r&&"function"!=typeof r)throw new TypeError("shouldObserve callback must be a function");this._el=e,this._cb=t,this._cache=new Map,this._shouldObserve=r||((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 r=t.name,i=this._isStandardAttribute(r);if(!this._shouldObserve(r,i))continue;const s=this._attributeNameToPropName(r),o=t.value;e[s]=o,this._cache.set(s,o),this._installPropertyInterceptor(s)}for(const t of Object.getOwnPropertyNames(this._el)){const r=this._isStandardProperty(t);if(this._cache.has(t)||!this._shouldObserve(t,r))continue;const i=this._el[t];e[t]=i,this._cache.set(t,i),this._installPropertyInterceptor(t)}if(Object.keys(e).length>0)try{this._cb(e)}catch(e){_.error("Error in initial PropertyObserver callback:",e)}}_setupMutationObserver(){this._observer=new MutationObserver(e=>{const t={};for(const r of e)if("attributes"===r.type&&r.attributeName){const e=r.attributeName,i=this._isStandardAttribute(e);if(!this._shouldObserve(e,i))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 r={enumerable:t.enumerable,configurable:t.configurable,get:t.get||(()=>t.value),set:r=>{r!==this._cache.get(e)&&(t.set?t.set.call(this._el,r):t.value=r,this._cache.set(e,r),this._batchChanges({[e]:r}))}};Object.defineProperty(this._el,e,r),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){_.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 R=new class{#_=new g("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 r=t;if(!r){const t=e.localName;if(r=this.compNameToApp.get(t),!r)throw this.#_.create(`Could not find a parent App for component "${e.localName}"`)}return this.appToComps.get(r).add(e),this.compToApp.set(e,r),r}unregisterComponent(e){const t=this.compToApp.get(e);if(!t)return!1;const r=this.appToComps.get(t);return r?.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}},S=new r("LightningOutComponent"),L=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"]),A=new Set(["accesskey","autofocus","draggable","exportparts","hidden","inert","nonce","part","slot","tabindex"]),O=new Set(["aria-activedescendant","aria-controls","aria-describedby","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns"]);class $ extends HTMLElement{_uuid=i();componentReady=!1;_standardName=b(this.localName);#C;#_=new g(this);#R=new y({parentElement:this,isVisible:!0});#S;#L=!0;#P=[];#A=new WeakMap;#O=0;constructor(){super(),S.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.#R.load(this._getComponentURL().href)}#v=e=>{if(e.data.id===this._uuid)switch(S.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.#P.length;){const e=this.#P.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.#S=new C(this,this.#$,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:S.info("#messageListener:","Unknown message received:",{"event.data":e.data})}};_propertyChanged_style=e=>{const t=this.style,r=[];for(let e=0;e<t.length;e+=1){const i=t.item(e);i.startsWith("--")&&r.push(`${i}:${t.getPropertyValue(i)}`)}return r.join(";")};#$=e=>{const t=w(this,e);S.debug("#propObserverCallback:",{changes:e,propsToSend:t}),this.#L?(this.#L=!1,this.#R.postMessage({type:o.setComponentData,componentData:{id:this._uuid,name:this._standardName,props:t}})):this.#R.postMessage({type:o.setComponentProps,componentProps:t})};#U=(e,t)=>{const r=v(e);return S.debug("#shouldObserveCallback:",{attrOrPropName:e,attrName:r,isStandard:t}),t?!(!L.has(r)&&!P.has(r))||(A.has(r)||O.has(r)||r.startsWith("on")?(S.warn(`"${r}" will not be mirrored.`),!1):!!r.startsWith("data-mirror-")||(S.warn(`"${r}" will not be mirrored.`),!1)):!r.startsWith("_")};addEventListener(e,t,r){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,r);let i=this.#A.get(t);i||(i=`${e}_${this.#O++}`,this.#A.set(t,i)),this.componentReady?(super.addEventListener(...arguments),this.#R.postMessage({name:e,options:r,listenerKey:i,type:o.addEventListener})):(this.#P.push({type:"add",args:[e,t,r]}),S.debug("addEventListener:","#eventQueue pushed add args:",[e,t,r]))}dispatchEvent(e){if(e.type.startsWith("lo."))return S.debug(`dispatchEvent: dispatching event "${e.type}" to this Element only`),super.dispatchEvent(e);if(this.componentReady){S.debug(`dispatchEvent: dispatching event "${e.type}" to this Element and embedded Element inside the iframe`);const t=super.dispatchEvent(e);return this.#R.postMessage({name:e.type,detail:e.detail||{},type:o.dispatchEvent}),t}return S.debug(`dispatchEvent: component not ready, queueing event "${e.type}"`),this.#P.push({type:"dispatch",event:e}),!0}removeEventListener(e,t,r){if(e.startsWith("lo."))return void super.removeEventListener(...arguments);const i=this.#A.get(t);this.componentReady?(super.removeEventListener(...arguments),this.#R.postMessage({name:e,options:r,listenerKey:i,type:o.removeEventListener})):(this.#P.push({type:"remove",args:[e,t,r]}),S.debug("removeEventListener:","#eventQueue pushed remove args:",[e,t,r])),i&&this.#A.delete(t)}adoptedCallback(){throw this.remove(),this.#_.create("This component cannot be rerendered for security reasons.")}connectedCallback(){if(S.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=R.registerComponent(this),this._standardName=this.#C._getComponentStandardName(this),this.#C.applicationReady&&this._init()}disconnectedCallback(){S.trace("disconnectedCallback: called",`_uuid: ${this._uuid}`),this.#R.destroy(),window.removeEventListener("message",this.#v),R.unregisterComponent(this),this.#S?.disconnect()}connectedMoveCallback(){}}class U{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 r;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 i=this.config.lang?`l/${this.config.lang}/`:"";r=new URL(`lwr/application/amd/0/${i}ai/${t}`,this.config.origin)}else r=new URL(`${this.config.sitePrefix}/lightning-out`,this.config.origin);return r.searchParams.set("componentName",e),this.#I(r,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.#I(t,e)}getPageURL(e,t){const r=new URL(e,this.config.origin);return this.#I(r,t)}#I(e,t){return e.searchParams.set("parentElementId",t),e.searchParams.set("loAppOrigin",this.config.loAppOrigin),e.searchParams.set("loVersion","2.2.4-rc.1"),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 I=new r("LightningOutApplication"),N=new Set(["slds1","slds2","none"]),T=new Set(["frontdoorUrl","orgUrl"]);class k extends HTMLElement{_uuid=i();applicationReady=!1;#_=new g(this);#R=new y({parentElement:this,isVisible:!1});#N;#S;#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;#V;frontdoorUrl;#z;appId;#H;components;#K=new Map;sitePrefix;#Q;designSystem;#Z;globalStyle;#q;#J=document.documentElement.lang??"";#G=!1;#X=null;#B=null;constructor(){super(),I.trace("constructor: called",`_uuid: ${this._uuid}`),R.registerApplication(this)}addEventListener(e,t,r){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,r)}#Y(e){try{this.#V=new URL(e)}catch{throw this.#_.create(`Invalid org-url: ${e}`)}this.dispatchEvent(new CustomEvent(s.iframe.load,{detail:this.#V.origin}))}#ee(e){try{this.#z=new URL(e),this.#T=this.#z.origin;const t=this.#te(),r=this.#z.searchParams.has("otp")?"startURL":"retURL";this.#z.searchParams.set(r,t.pathname+t.search);const i=this.#re(this.#F);this.#z.searchParams.set("error-redirect-uri",i.pathname+i.search)}catch{throw this.#_.create(`Invalid frontdoor-url: ${e}`)}this.#R.load(this.#z.href)}#ie(){const e=new URL(this.#W,this.#T),t=this.#re(this.#D);e.searchParams.set("redirect-uri",t.pathname+t.search),this.#R.load(e.href)}getRouter(){if(void 0===this.#N){const e={origin:this.#T,lwrPageAuth:this.#j,lwrAppAuth:this.#k,lwrAppComp:this.#x,lwrAppAura:this.#M,sitePrefix:this.#Q,lang:this.#J,appId:this.#H,testMode:this.__testMode||!1,loAppOrigin:window.location.origin,designSystem:this.#Z,globalStyle:this.#q};this.#N=new U(e,e=>this.#_.create(e))}return this.#N}_getComponentURL(e,t){return this.getRouter().getComponentURL(e,t)}#te(){return this.getRouter().getAuthURL(this._uuid)}#re(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.#N=void 0,this.#G?(I.trace("#iframeLoaded: frontdoor-url refresh path"),this.#G=!1,void this.dispatchEvent(new CustomEvent(s.application.session.refresh))):this.#B?(I.trace("#iframeLoaded: sessionRefresh() reload path"),clearTimeout(this.#B.timeoutId),this.#B.resolve(),void(this.#B=null)):(I.trace("#iframeLoaded: initial-auth path"),this.#oe(),void this.dispatchEvent(new CustomEvent(s.application.ready)))};sessionExpiry(){return void 0!==this.#V?Promise.reject(this.#_.create(u)):this.applicationReady?this.#X?new Promise((e,t)=>{const r=this.#X,i=r.resolve,s=r.reject;r.resolve=t=>{i(t),e(t)},r.reject=e=>{s(e),t(e)}}):new Promise((e,t)=>{const r=window.setTimeout(()=>{const e=this.#X;this.#X=null,e?.reject(this.#_.create(p))},3e4);this.#X={resolve:e,reject:t,timeoutId:r},this.#R.postMessage({type:o.sessionExpiry,id:this._uuid})}):Promise.reject(this.#_.create(a))}sessionRefresh(){if(void 0!==this.#V)return Promise.reject(this.#_.create(u));if(!this.applicationReady)return Promise.reject(this.#_.create(a));let e=!0;return this.#B&&(clearTimeout(this.#B.timeoutId),this.#B.reject(this.#_.create(h)),this.#B=null,e=!1),new Promise((t,r)=>{const i=window.setTimeout(()=>{this.#B=null,r(this.#_.create(l))},6e4);this.#B={resolve:t,reject:r,timeoutId:i},e&&this.#R.postMessage({type:o.authReload,id:this._uuid})})}_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=>{this.#G=!1,this.#ne(e.detail?.message??c),this.#_.dispatch(s.application.error,e)};#he=e=>{this.dispatchEvent(new CustomEvent(s.application.logout))};#le=e=>{this.dispatchEvent(new CustomEvent(s.application.auth.redirect,{detail:e.detail}))};#oe(){R.getComps(this).forEach(e=>{e._init()})}#$=e=>{const t={},r={};Object.keys(e).forEach(i=>{T.has(i)?r[i]=e[i]:t[i]=e[i]}),w(this,t),w(this,r)};#U=(e,t)=>t?"lang"===e:!e.startsWith("_");_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.#z)throw this.#_.create('Can\'t set "org-url" because "frontdoor-url" is already set');""===e?this.#ie():this.#Y(e)}};_propertyChanged_frontdoorUrl=e=>{if(void 0!==e){if(void 0!==this.#V)throw this.#_.create('Can\'t set "frontdoor-url" because "org-url" is already set');""!==e?(this.#B&&(clearTimeout(this.#B.timeoutId),this.#B.reject(this.#_.create(h)),this.#B=null),this.#G=this.applicationReady,this.#ee(e)):this.#ie()}};_propertyChanged_sitePrefix=e=>{void 0!==e&&(this.#Q=e)};_propertyChanged_appId=e=>{void 0!==e&&(this.#H=e)};_propertyChanged_globalStyle=e=>{if(void 0!==e){const t=e.split(";").map(e=>e.trim()).filter(e=>e.length>0),r=[];for(const e of t){const[t,...i]=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=i.join(":").trim();o&&r.push(`${s}:${o}`)}this.#q=r.join(";")+";"}};_propertyChanged_components=e=>{void 0!==e&&e.split(",").forEach(e=>{const[t,r]=e.split(" as ").map(e=>e.trim()),i=function(e){return e.includes("/")||e.includes(":")}(t);if(i&&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=i?t:b(t),o=r||(i?function(e){const t=e.includes("/")?"/":":",r=e.indexOf(t);if(-1===r)throw f.create(`standardNameToElementName: "${e}" is not a valid component name - missing namespace separator.`);if(/-/.test(e))throw f.create(`standardNameToElementName: "${e}" is not a valid component name - must not contain hyphens.`);if(/^[A-Z]/.test(e))throw f.create(`standardNameToElementName: "${e}" is not a valid component name - first character must not be uppercase.`);const i=e.slice(0,r),s=e.slice(r+1);return`${i.replace(/([A-Z_])/g,"_$1").toLowerCase()}-${v(s)}`}(s):t);if(o&&!this.#K.has(o)){this.#K.set(o,s);try{R.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.#Z=e};_getComponentStandardName(e){const t=e.localName,r=e.hasAttribute("aura"),i=this.#K.get(t);if(!i)throw this.#_.create(`"${t}" is not registered.`);return r&&i.includes("/")?i.replace("/",":"):i}get _compNames(){}connectedCallback(){if(I.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.#ae),this.addEventListener(s.iframe.logout,this.#he),this.addEventListener(s.iframe.auth.redirect,this.#le),this.#S=new C(this,this.#$,this.#U)}disconnectedCallback(){I.trace("disconnectedCallback: called",`_uuid: ${this._uuid}`),this.#X&&(clearTimeout(this.#X.timeoutId),this.#X.reject(this.#_.create(m)),this.#X=null),this.#B&&(clearTimeout(this.#B.timeoutId),this.#B.reject(this.#_.create(m)),this.#B=null),this.#ie(),this.#R.destroy(),this.removeEventListener(s.iframe.load,this.#se),this.removeEventListener(s.iframe.error,this.#ae),this.removeEventListener(s.iframe.logout,this.#he),this.removeEventListener(s.iframe.auth.redirect,this.#le),this.#S?.disconnect()}connectedMoveCallback(){}}return r.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.2.
|
|
3
|
+
"version": "2.2.4-rc.1",
|
|
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.2.
|
|
26
|
-
"utils": "2.2.
|
|
25
|
+
"core": "2.2.4-rc.1",
|
|
26
|
+
"utils": "2.2.4-rc.1"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"dist/",
|