@salesforce/lightning-out 2.2.11 → 2.3.0-rc.2

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 CHANGED
@@ -1,4 +1,4 @@
1
- /*! @salesforce/lightning-out v2.2.11 (2026-10-12) */
1
+ /*! @salesforce/lightning-out v2.3.0-rc.2 (2026-10-21) */
2
2
  /**
3
3
  * Numeric ranks for {@link LogLevel}; lower values are more severe.
4
4
  */
@@ -260,6 +260,10 @@ class LightningOutError {
260
260
  }
261
261
  }
262
262
 
263
+ function observeIFrame(phase, iframe, visible) {
264
+ return;
265
+ }
266
+
263
267
  /**
264
268
  * Utility functions for Lightning Out
265
269
  * @fileoverview Collection of utility functions used throughout the Lightning Out framework
@@ -557,7 +561,10 @@ class LightningOutIFrame {
557
561
  case messages.lo.loaded: {
558
562
  // Clear the timeout, cache its window and origin
559
563
  this.#timeoutID = clearTimeout(this.#timeoutID);
564
+ const firstAnchor = !this.iframeReady;
560
565
  this.#config(event.source, event.origin);
566
+ if (firstAnchor)
567
+ observeIFrame("origin-anchored", this.#element, this.#visible);
561
568
  // Extract lightningDomain from the postMessage if provided
562
569
  const lightningDomain = event.data.lightningDomain;
563
570
  // Notify the parentElement that the iframe has successfully loaded.
@@ -632,6 +639,7 @@ class LightningOutIFrame {
632
639
  // the iframe is appended to the DOM.
633
640
  iframe.addEventListener("load", this.#loaded);
634
641
  window.addEventListener("message", this.#messageListener);
642
+ observeIFrame("iframe-created", this.#element, this.#visible);
635
643
  }
636
644
  return this.#element;
637
645
  }
@@ -640,6 +648,7 @@ class LightningOutIFrame {
640
648
  this.#endpoint = new URL(endpoint);
641
649
  logger$3.debug(`#loadIframe: endpoint =`, getUrlData(this.#endpoint));
642
650
  this.#config(undefined, undefined);
651
+ observeIFrame("navigation-requested", iframe, this.#visible);
643
652
  if (this.#visible) {
644
653
  iframe.src = endpoint;
645
654
  }
@@ -655,6 +664,7 @@ class LightningOutIFrame {
655
664
  }
656
665
  }
657
666
  #loaded = () => {
667
+ observeIFrame("document-loaded", this.#element, this.#visible);
658
668
  // Browsers will call the onload event even when there is an error, so if the iframe
659
669
  // is not ready when the timeout expires, there was an error but we don't know
660
670
  // exactly what.
@@ -664,6 +674,7 @@ class LightningOutIFrame {
664
674
  }
665
675
  this.#timeoutID = setTimeout(() => {
666
676
  if (!this.iframeReady) {
677
+ observeIFrame("load-timeout", this.#element, this.#visible);
667
678
  const message = "Error: Unknown error, unable to load the iframe.";
668
679
  this.#parentError.dispatch(events.lo.iframe.error, message);
669
680
  this.#showErrorMessage(message);
@@ -676,6 +687,7 @@ class LightningOutIFrame {
676
687
  }
677
688
  if (this.#element) {
678
689
  this.#element.remove();
690
+ observeIFrame("iframe-destroyed", this.#element, this.#visible);
679
691
  }
680
692
  this.#shadowRoot = undefined;
681
693
  this.#element = undefined;
@@ -699,12 +711,14 @@ class LightningOutIFrame {
699
711
  this.#window.postMessage(message, this.#origin);
700
712
  }
701
713
  catch (err) {
714
+ observeIFrame("post-message-failed", this.#element, this.#visible);
702
715
  const message = `postMessage error: ${err}`;
703
716
  this.#parentError.dispatch(events.lo.iframe.error, message);
704
717
  throw this.#parentError.create(message);
705
718
  }
706
719
  }
707
720
  else {
721
+ observeIFrame("post-message-before-ready", this.#element, this.#visible);
708
722
  throw this.#parentError.create("Error attempting to postMessage on an iframe that is not ready.");
709
723
  }
710
724
  }
@@ -1528,7 +1542,7 @@ class LightningOutRouter {
1528
1542
  url.searchParams.set("parentElementId", parentElementId);
1529
1543
  url.searchParams.set("loAppOrigin", this.config.loAppOrigin);
1530
1544
  // This helps in general but also for cache busting
1531
- url.searchParams.set("loVersion", "2.2.11");
1545
+ url.searchParams.set("loVersion", "2.3.0-rc.2");
1532
1546
  if (this.config.appId) {
1533
1547
  url.searchParams.set("appId", this.config.appId);
1534
1548
  }
@@ -1,4 +1,4 @@
1
- /*! @salesforce/lightning-out v2.2.11 (2026-10-12) */
1
+ /*! @salesforce/lightning-out v2.3.0-rc.2 (2026-10-21) */
2
2
  var LO2 = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -263,6 +263,10 @@ var LO2 = (function (exports) {
263
263
  }
264
264
  }
265
265
 
266
+ function observeIFrame(phase, iframe, visible) {
267
+ return;
268
+ }
269
+
266
270
  /**
267
271
  * Utility functions for Lightning Out
268
272
  * @fileoverview Collection of utility functions used throughout the Lightning Out framework
@@ -560,7 +564,10 @@ var LO2 = (function (exports) {
560
564
  case messages.lo.loaded: {
561
565
  // Clear the timeout, cache its window and origin
562
566
  this.#timeoutID = clearTimeout(this.#timeoutID);
567
+ const firstAnchor = !this.iframeReady;
563
568
  this.#config(event.source, event.origin);
569
+ if (firstAnchor)
570
+ observeIFrame("origin-anchored", this.#element, this.#visible);
564
571
  // Extract lightningDomain from the postMessage if provided
565
572
  const lightningDomain = event.data.lightningDomain;
566
573
  // Notify the parentElement that the iframe has successfully loaded.
@@ -635,6 +642,7 @@ var LO2 = (function (exports) {
635
642
  // the iframe is appended to the DOM.
636
643
  iframe.addEventListener("load", this.#loaded);
637
644
  window.addEventListener("message", this.#messageListener);
645
+ observeIFrame("iframe-created", this.#element, this.#visible);
638
646
  }
639
647
  return this.#element;
640
648
  }
@@ -643,6 +651,7 @@ var LO2 = (function (exports) {
643
651
  this.#endpoint = new URL(endpoint);
644
652
  logger$3.debug(`#loadIframe: endpoint =`, getUrlData(this.#endpoint));
645
653
  this.#config(undefined, undefined);
654
+ observeIFrame("navigation-requested", iframe, this.#visible);
646
655
  if (this.#visible) {
647
656
  iframe.src = endpoint;
648
657
  }
@@ -658,6 +667,7 @@ var LO2 = (function (exports) {
658
667
  }
659
668
  }
660
669
  #loaded = () => {
670
+ observeIFrame("document-loaded", this.#element, this.#visible);
661
671
  // Browsers will call the onload event even when there is an error, so if the iframe
662
672
  // is not ready when the timeout expires, there was an error but we don't know
663
673
  // exactly what.
@@ -667,6 +677,7 @@ var LO2 = (function (exports) {
667
677
  }
668
678
  this.#timeoutID = setTimeout(() => {
669
679
  if (!this.iframeReady) {
680
+ observeIFrame("load-timeout", this.#element, this.#visible);
670
681
  const message = "Error: Unknown error, unable to load the iframe.";
671
682
  this.#parentError.dispatch(events.lo.iframe.error, message);
672
683
  this.#showErrorMessage(message);
@@ -679,6 +690,7 @@ var LO2 = (function (exports) {
679
690
  }
680
691
  if (this.#element) {
681
692
  this.#element.remove();
693
+ observeIFrame("iframe-destroyed", this.#element, this.#visible);
682
694
  }
683
695
  this.#shadowRoot = undefined;
684
696
  this.#element = undefined;
@@ -702,12 +714,14 @@ var LO2 = (function (exports) {
702
714
  this.#window.postMessage(message, this.#origin);
703
715
  }
704
716
  catch (err) {
717
+ observeIFrame("post-message-failed", this.#element, this.#visible);
705
718
  const message = `postMessage error: ${err}`;
706
719
  this.#parentError.dispatch(events.lo.iframe.error, message);
707
720
  throw this.#parentError.create(message);
708
721
  }
709
722
  }
710
723
  else {
724
+ observeIFrame("post-message-before-ready", this.#element, this.#visible);
711
725
  throw this.#parentError.create("Error attempting to postMessage on an iframe that is not ready.");
712
726
  }
713
727
  }
@@ -1531,7 +1545,7 @@ var LO2 = (function (exports) {
1531
1545
  url.searchParams.set("parentElementId", parentElementId);
1532
1546
  url.searchParams.set("loAppOrigin", this.config.loAppOrigin);
1533
1547
  // This helps in general but also for cache busting
1534
- url.searchParams.set("loVersion", "2.2.11");
1548
+ url.searchParams.set("loVersion", "2.3.0-rc.2");
1535
1549
  if (this.config.appId) {
1536
1550
  url.searchParams.set("appId", this.config.appId);
1537
1551
  }
@@ -1,10 +1,10 @@
1
- /*! @salesforce/lightning-out v2.2.11 (2026-10-12) */
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 w(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 y=new i("LightningOutIFrame");class b{#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 $,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 y.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 y.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 y.debug("#messageListener: rejected pre-ready message from a foreign source",`origin: ${e.origin}`,`type: ${e.data.type}`)}switch(y.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 T&&this.#o._handleSessionExpiryResponse(e.data)}}};#w(e){this.#c&&this.#n&&(this.#c.style.height=`${e}px`,y.debug(`#handleResize: applied height ${e}px to iframe`))}#y(){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.#b),window.addEventListener("message",this.#v)}return this.#c}load(e){const t=this.#y();this.#u=new URL(e),y.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?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}#b=()=>{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.#E(e)}},6e4)};destroy(){this.#d&&(this.#d.innerHTML=""),this.#c&&this.#c.remove(),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.#a.create("Error attempting to postMessage on an iframe that is not ready.");y.debug("postMessage:",`parentElement: ${this.#o._uuid}`,JSON.stringify(e));try{this.#p.postMessage(e,this.#m)}catch(e){const t=`postMessage error: ${e}`;throw this.#a.dispatch(s.iframe.error,t),this.#a.create(t)}}}
1
+ /*! @salesforce/lightning-out v2.3.0-rc.2 (2026-10-21) */
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 $,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 T&&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 b({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=w(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.2.11"),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 b({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]}),w(this,t),w(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}},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.2"),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}({});
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.11",
3
+ "version": "2.3.0-rc.2",
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.11",
26
- "utils": "2.2.11"
25
+ "core": "2.3.0-rc.2",
26
+ "utils": "2.3.0-rc.2"
27
27
  },
28
28
  "files": [
29
29
  "dist/",