@elliemae/ssf-guest 2.23.4 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/callchain-grandchild.html +60 -0
- package/dist/cjs/e2e-guest.html +323 -0
- package/dist/cjs/guest.js +25 -9
- package/dist/esm/callchain-grandchild.html +60 -0
- package/dist/esm/e2e-guest.html +323 -0
- package/dist/esm/guest.js +25 -9
- package/dist/public/callchain-grandchild.html +1 -0
- package/dist/public/callchain-grandchild.js +4 -0
- package/dist/public/callchain-grandchild.js.br +0 -0
- package/dist/public/callchain-grandchild.js.gz +0 -0
- package/dist/public/callchain-grandchild.js.map +1 -0
- package/dist/public/creditService.html +1 -1
- package/dist/public/e2e-guest.html +1 -0
- package/dist/public/e2e-guest.js +3 -0
- package/dist/public/e2e-guest.js.br +0 -0
- package/dist/public/e2e-guest.js.gz +0 -0
- package/dist/public/e2e-guest.js.map +1 -0
- package/dist/public/index.html +1 -1
- package/dist/public/js/emuiSsfGuest.bb7f9a5114e5717cda3d.js +3 -0
- package/dist/public/js/emuiSsfGuest.bb7f9a5114e5717cda3d.js.br +0 -0
- package/dist/public/js/emuiSsfGuest.bb7f9a5114e5717cda3d.js.gz +0 -0
- package/dist/public/js/emuiSsfGuest.bb7f9a5114e5717cda3d.js.map +1 -0
- package/dist/public/loanValidation.html +1 -1
- package/dist/public/pricingService.html +1 -1
- package/dist/public/titleService.html +1 -1
- package/dist/public/v2-guest.html +1 -1
- package/dist/types/lib/tests/utils.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/callchain-grandchild.html +1 -0
- package/dist/umd/callchain-grandchild.js +4 -0
- package/dist/umd/callchain-grandchild.js.br +0 -0
- package/dist/umd/callchain-grandchild.js.gz +0 -0
- package/dist/umd/callchain-grandchild.js.map +1 -0
- package/dist/umd/e2e-guest.html +1 -0
- package/dist/umd/e2e-guest.js +3 -0
- package/dist/umd/e2e-guest.js.br +0 -0
- package/dist/umd/e2e-guest.js.gz +0 -0
- package/dist/umd/e2e-guest.js.map +1 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.br +0 -0
- package/dist/umd/index.js.gz +0 -0
- package/dist/umd/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/public/js/emuiSsfGuest.dc017a38b78ac30a1aa3.js +0 -3
- package/dist/public/js/emuiSsfGuest.dc017a38b78ac30a1aa3.js.br +0 -0
- package/dist/public/js/emuiSsfGuest.dc017a38b78ac30a1aa3.js.gz +0 -0
- package/dist/public/js/emuiSsfGuest.dc017a38b78ac30a1aa3.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Grandchild Guest (C)</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="index.js"></script></head><body class="bg-green-50 p-2"><h3 class="text-sm font-semibold text-green-800 mb-2">Grandchild Guest (C)</h3><div class="flex flex-wrap gap-2 mb-2"><button data-testid="btn-get-caller-info" id="btnGetCallerInfo" disabled="disabled" class="rounded bg-green-600 px-3 py-1 text-xs text-white hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed">Call getCallerInfo()</button> <button data-testid="btn-ping" id="btnPing" disabled="disabled" class="rounded bg-green-600 px-3 py-1 text-xs text-white hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed">Call ping("hello from C")</button> <button data-testid="btn-get-loan" id="btnGetLoan" disabled="disabled" class="rounded bg-green-600 px-3 py-1 text-xs text-white hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed">Call getLoanDetails()</button></div><div data-testid="grandchild-status" id="status" class="text-xs bg-green-100 rounded p-2 mb-2 min-h-[20px]">Connecting...</div><div data-testid="grandchild-result" id="result" class="text-xs bg-white rounded p-2 min-h-[40px]"><pre id="resultPre" class="whitespace-pre-wrap">No results yet</pre></div><script src="./callchain-grandchild.js" type="module"></script></body></html>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const statusEl=document.getElementById("status"),resultEl=document.getElementById("resultPre"),log=e=>{const t=new Date().toLocaleTimeString();statusEl.innerHTML+=`<div>[${t}] ${e}</div>`},showResult=(e,t)=>{resultEl.textContent=`${e}:
|
|
2
|
+
${JSON.stringify(t,null,2)}`};window.addEventListener("DOMContentLoaded",async()=>{try{const e=new ice.guest.SSFGuest({logger:{index:"grandchild-c",team:"ui platform",appName:"grandchild-c"},keepAlive:!1});await e.connect(),log("Connected to Intermediate Host (B)");const t=await e.getObject("TestService");log("Got TestService proxy \u2014 buttons enabled");const l=n=>{document.getElementById(n).disabled=!1};l("btnGetCallerInfo"),l("btnPing"),l("btnGetLoan"),document.getElementById("btnGetCallerInfo").addEventListener("click",async()=>{log("Calling getCallerInfo()...");const n=await t.getCallerInfo();log("getCallerInfo() returned"),showResult("getCallerInfo()",n)}),document.getElementById("btnPing").addEventListener("click",async()=>{log('Calling ping("hello from C")...');const n=await t.ping("hello from C");log("ping() returned"),showResult('ping("hello from C")',n)}),document.getElementById("btnGetLoan").addEventListener("click",async()=>{log("Calling getLoanDetails()...");const n=await t.getLoanDetails();log("getLoanDetails() returned"),showResult("getLoanDetails()",n)})}catch(e){log(`ERROR: ${e.message}`)}});
|
|
3
|
+
|
|
4
|
+
//# sourceMappingURL=callchain-grandchild.js.map
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["webpack://ice.guest/callchain-grandchild.js"],"sourcesContent":["const statusEl = document.getElementById('status');\nconst resultEl = document.getElementById('resultPre');\n\nconst log = (msg) => {\n const ts = new Date().toLocaleTimeString();\n statusEl.innerHTML += `<div>[${ts}] ${msg}</div>`;\n};\n\nconst showResult = (label, data) => {\n resultEl.textContent = `${label}:\\n${JSON.stringify(data, null, 2)}`;\n};\n\nwindow.addEventListener('DOMContentLoaded', async () => {\n try {\n const guest = new ice.guest.SSFGuest({\n logger: {\n index: 'grandchild-c',\n team: 'ui platform',\n appName: 'grandchild-c',\n },\n keepAlive: false,\n });\n await guest.connect();\n log('Connected to Intermediate Host (B)');\n\n const testService = await guest.getObject('TestService');\n log('Got TestService proxy — buttons enabled');\n\n const enable = (id) => {\n document.getElementById(id).disabled = false;\n };\n enable('btnGetCallerInfo');\n enable('btnPing');\n enable('btnGetLoan');\n\n document\n .getElementById('btnGetCallerInfo')\n .addEventListener('click', async () => {\n log('Calling getCallerInfo()...');\n const result = await testService.getCallerInfo();\n log('getCallerInfo() returned');\n showResult('getCallerInfo()', result);\n });\n\n document.getElementById('btnPing').addEventListener('click', async () => {\n log('Calling ping(\"hello from C\")...');\n const result = await testService.ping('hello from C');\n log('ping() returned');\n showResult('ping(\"hello from C\")', result);\n });\n\n document\n .getElementById('btnGetLoan')\n .addEventListener('click', async () => {\n log('Calling getLoanDetails()...');\n const result = await testService.getLoanDetails();\n log('getLoanDetails() returned');\n showResult('getLoanDetails()', result);\n });\n } catch (err) {\n log(`ERROR: ${err.message}`);\n }\n});\n"],"mappings":"AAAA,MAAM,SAAW,SAAS,eAAe,QAAQ,EAC3C,SAAW,SAAS,eAAe,WAAW,EAE9C,IAAOA,GAAQ,CACnB,MAAMC,EAAK,IAAI,KAAK,EAAE,mBAAmB,EACzC,SAAS,WAAa,SAASA,CAAE,KAAKD,CAAG,QAC3C,EAEM,WAAa,CAACE,EAAOC,IAAS,CAClC,SAAS,YAAc,GAAGD,CAAK;AAAA,EAAM,KAAK,UAAUC,EAAM,KAAM,CAAC,CAAC,EACpE,EAEA,OAAO,iBAAiB,mBAAoB,SAAY,CACtD,GAAI,CACF,MAAMC,EAAQ,IAAI,IAAI,MAAM,SAAS,CACnC,OAAQ,CACN,MAAO,eACP,KAAM,cACN,QAAS,cACX,EACA,UAAW,EACb,CAAC,EACD,MAAMA,EAAM,QAAQ,EACpB,IAAI,oCAAoC,EAExC,MAAMC,EAAc,MAAMD,EAAM,UAAU,aAAa,EACvD,IAAI,8CAAyC,EAE7C,MAAME,EAAUC,GAAO,CACrB,SAAS,eAAeA,CAAE,EAAE,SAAW,EACzC,EACAD,EAAO,kBAAkB,EACzBA,EAAO,SAAS,EAChBA,EAAO,YAAY,EAEnB,SACG,eAAe,kBAAkB,EACjC,iBAAiB,QAAS,SAAY,CACrC,IAAI,4BAA4B,EAChC,MAAME,EAAS,MAAMH,EAAY,cAAc,EAC/C,IAAI,0BAA0B,EAC9B,WAAW,kBAAmBG,CAAM,CACtC,CAAC,EAEH,SAAS,eAAe,SAAS,EAAE,iBAAiB,QAAS,SAAY,CACvE,IAAI,iCAAiC,EACrC,MAAMA,EAAS,MAAMH,EAAY,KAAK,cAAc,EACpD,IAAI,iBAAiB,EACrB,WAAW,uBAAwBG,CAAM,CAC3C,CAAC,EAED,SACG,eAAe,YAAY,EAC3B,iBAAiB,QAAS,SAAY,CACrC,IAAI,6BAA6B,EACjC,MAAMA,EAAS,MAAMH,EAAY,eAAe,EAChD,IAAI,2BAA2B,EAC/B,WAAW,mBAAoBG,CAAM,CACvC,CAAC,CACL,OAASC,EAAK,CACZ,IAAI,UAAUA,EAAI,OAAO,EAAE,CAC7B,CACF,CAAC","names":["msg","ts","label","data","guest","testService","enable","id","result","err"],"sourceRoot":"","file":"callchain-grandchild.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>SSF E2E Guest</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="index.js"></script></head><body class="bg-emerald-50 p-2 text-xs"><div class="flex items-center justify-between mb-1"><h3 class="font-semibold text-emerald-800">E2E Guest</h3><span data-testid="guest-connection-status" id="connStatus" class="px-2 py-0.5 rounded text-white bg-gray-400">disconnected</span></div><div data-testid="guest-info" id="guestInfo" class="bg-emerald-100 rounded p-1 mb-1 text-xs text-emerald-700">Params: <span id="searchParams">—</span></div><details class="bg-emerald-100 rounded p-1 mb-1 text-[10px] text-emerald-700"><summary class="font-semibold cursor-pointer">Quick Guide (click to expand)</summary><ul class="mt-1 list-disc list-inside space-y-0.5"><li><strong>Objects tab:</strong> Use <code>getObject()</code> to fetch a scripting object, then <code>Invoke</code> to call a method. Result + errors appear below.</li><li><strong>Events tab:</strong> Subscribe to events (with or without criteria). When the host dispatches, received events appear below. Use the Feedback dropdown to control what the callback returns.</li><li><strong>Lifecycle tab:</strong> Change log level or disconnect/reconnect. Status badge at top right should reflect the state.</li><li><strong>Verify:</strong> Connection badge = <span class="text-green-700 font-bold">connected</span>. After getObject: methods are listed. After invoke: result appears. After subscribe+dispatch: events appear.</li></ul></details><div class="flex gap-1 mb-2 border-b border-emerald-300"><button data-testid="tab-objects" class="tab-btn px-2 py-1 rounded-t font-medium bg-emerald-200 text-emerald-800" data-tab="objects">Objects</button> <button data-testid="tab-events" class="tab-btn px-2 py-1 rounded-t text-emerald-600" data-tab="events">Events</button> <button data-testid="tab-lifecycle" class="tab-btn px-2 py-1 rounded-t text-emerald-600" data-tab="lifecycle">Lifecycle</button></div><div id="panel-objects" class="tab-panel"><div class="space-y-1"><button data-testid="btn-list-objects" id="btnListObjects" class="rounded bg-emerald-600 px-2 py-1 text-white hover:bg-emerald-700">listObjects()</button><div data-testid="objects-list" id="objectsList" class="bg-white rounded p-1 min-h-[20px]">—</div><div class="flex gap-1 items-center"><input data-testid="input-object-id" id="inputObjectId" value="Loan" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1" placeholder="Object ID"/> <button data-testid="btn-get-object" id="btnGetObject" class="rounded bg-emerald-600 px-2 py-1 text-white hover:bg-emerald-700">getObject()</button></div><div data-testid="current-object" id="currentObject" class="bg-white rounded p-1 min-h-[20px]">—</div><div class="flex gap-1 items-center"><input data-testid="input-method" id="inputMethod" value="getLoanDetails" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1" placeholder="Method name"/> <input data-testid="input-args" id="inputArgs" class="rounded border-emerald-300 px-2 py-0.5 text-xs w-24" placeholder="Args (JSON)"/> <button data-testid="btn-invoke" id="btnInvoke" class="rounded bg-emerald-600 px-2 py-1 text-white hover:bg-emerald-700">Invoke</button></div><div class="flex gap-1"><button data-testid="btn-invoke-error" id="btnInvokeError" class="rounded bg-red-500 px-2 py-1 text-white hover:bg-red-600">TC-SO-08: Call throwError()</button> <button data-testid="btn-invoke-async" id="btnInvokeAsync" class="rounded bg-blue-500 px-2 py-1 text-white hover:bg-blue-600">TC-SO-07: Call asyncMethod(200)</button></div><div data-testid="invoke-result" id="invokeResult" class="bg-white rounded p-1 min-h-[30px] whitespace-pre-wrap">—</div></div></div><div id="panel-events" class="tab-panel hidden"><div class="space-y-1"><div class="flex gap-1 items-center"><input data-testid="input-event-id" id="inputEventId" value="Loan.onPreSave" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1" placeholder="Event ID"/> <button data-testid="btn-subscribe" id="btnSubscribe" class="rounded bg-purple-600 px-2 py-1 text-white hover:bg-purple-700">Subscribe</button></div><div class="flex gap-1 items-center"><input data-testid="input-criteria" id="inputCriteria" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1" placeholder='Criteria JSON e.g. {"amount":{"gt":100000}}'/> <button data-testid="btn-subscribe-criteria" id="btnSubscribeCriteria" class="rounded bg-purple-600 px-2 py-1 text-white hover:bg-purple-700">Subscribe+Criteria</button></div><div class="flex gap-1 items-center"><select data-testid="select-unsub-token" id="selectUnsubToken" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1"><option value="">— select token —</option></select> <button data-testid="btn-unsubscribe" id="btnUnsubscribe" class="rounded bg-yellow-600 px-2 py-1 text-white hover:bg-yellow-700">Unsubscribe</button></div><h4 class="font-medium text-emerald-700 mt-1">Active Subscriptions</h4><div data-testid="subscriptions-list" id="subscriptionsList" class="bg-white rounded p-1 min-h-[20px]">—</div><h4 class="font-medium text-emerald-700 mt-1">Received Events</h4><div data-testid="events-received" id="eventsReceived" class="bg-white rounded p-1 min-h-[40px] max-h-[120px] overflow-y-auto">—</div><h4 class="font-medium text-emerald-700 mt-1">Feedback Return Value</h4><div class="flex gap-1 items-center"><select data-testid="select-feedback" id="selectFeedback" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1"><option value="true">return true (approve)</option><option value="false">return false (reject)</option><option value="object">return {status: "ok"}</option></select></div></div></div><div id="panel-lifecycle" class="tab-panel hidden"><div class="space-y-1"><button data-testid="btn-set-loglevel-0" id="btnLogLevel0" class="rounded bg-gray-600 px-2 py-1 text-white hover:bg-gray-700">setLogLevel(0) — Silent</button> <button data-testid="btn-set-loglevel-10" id="btnLogLevel10" class="rounded bg-gray-600 px-2 py-1 text-white hover:bg-gray-700">setLogLevel(10) — Debug</button> <button data-testid="btn-disconnect" id="btnDisconnect" class="rounded bg-red-600 px-2 py-1 text-white hover:bg-red-700">close() — Disconnect</button><p class="text-[10px] text-gray-400">Expected: status badge → "disconnected", further calls fail</p><button data-testid="btn-reconnect" id="btnReconnect" class="rounded bg-emerald-600 px-2 py-1 text-white hover:bg-emerald-700">connect() — Reconnect</button><p class="text-[10px] text-gray-400">Expected: status badge → "connected", calls work again</p></div></div><div class="mt-2"><h4 class="font-medium text-emerald-700">Guest Log</h4><div data-testid="guest-log" id="guestLog" class="bg-white rounded p-1 text-xs min-h-[40px] max-h-[100px] overflow-y-auto font-mono"></div></div><script src="./e2e-guest.js" type="module"></script></body></html>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{getGuest as I}from"./util.js";let o=null,s=null;const a=new Map;let d=0;const l=document.getElementById("guestLog"),n=(e,t="info")=>{const c=new Date().toLocaleTimeString(),r=t==="error"?"text-red-600":t==="success"?"text-green-600":"text-gray-600";l.innerHTML+=`<div class="${r}">[${c}] ${e}</div>`,l.scrollTop=l.scrollHeight},u=e=>{const t=document.getElementById("connStatus");t.textContent=e?"connected":"disconnected",t.className=`px-2 py-0.5 rounded text-white ${e?"bg-green-500":"bg-gray-400"}`};document.querySelectorAll(".tab-btn").forEach(e=>{e.addEventListener("click",()=>{document.querySelectorAll(".tab-btn").forEach(t=>t.classList.replace("bg-emerald-200","bg-transparent")),e.classList.replace("bg-transparent","bg-emerald-200"),document.querySelectorAll(".tab-panel").forEach(t=>t.classList.add("hidden")),document.getElementById(`panel-${e.dataset.tab}`).classList.remove("hidden")})});const f=new URLSearchParams(window.location.search),g=Object.fromEntries(f.entries());document.getElementById("searchParams").textContent=Object.keys(g).length?JSON.stringify(g):"(none)";const b=async()=>{try{o=I("e2e-guest"),await o.connect(),u(!0),n("Connected to host","success")}catch(e){u(!1),n(`Connect failed: ${e.message}`,"error")}},y=()=>{const e=document.getElementById("selectFeedback").value;return e==="true"?!0:e==="false"?!1:{status:"ok"}},m=()=>{const e=document.getElementById("subscriptionsList");if(!a.size){e.textContent="(none)";return}e.innerHTML=Array.from(a.entries()).map(([c,r])=>`<div>${r.eventId} \u2192 ${c.slice(0,8)}... ${r.criteria?`[criteria: ${JSON.stringify(r.criteria)}]`:""}</div>`).join("");const t=document.getElementById("selectUnsubToken");t.innerHTML='<option value="">\u2014 select token \u2014</option>',a.forEach((c,r)=>{const i=document.createElement("option");i.value=`${c.eventId}|${r}`,i.textContent=`${c.eventId} (${r.slice(0,8)}...)`,t.appendChild(i)})},E=(e,t)=>{d++;const c=document.getElementById("eventsReceived");d===1&&(c.innerHTML="");const r=new Date().toLocaleTimeString();c.innerHTML+=`<div class="border-b border-gray-100 py-0.5">[${r}] #${d} <strong>${e}</strong>: ${JSON.stringify(t)}</div>`,c.scrollTop=c.scrollHeight};window.addEventListener("DOMContentLoaded",async()=>{await b(),document.getElementById("btnListObjects").addEventListener("click",async()=>{try{const e=await o.listObjects();document.getElementById("objectsList").textContent=e.join(", ")||"(empty)",n(`listObjects(): [${e.join(", ")}]`,"success")}catch(e){n(`listObjects failed: ${e.message}`,"error")}}),document.getElementById("btnGetObject").addEventListener("click",async()=>{const e=document.getElementById("inputObjectId").value.trim();if(e)try{s=await o.getObject(e);const t=Object.keys(s).filter(c=>typeof s[c]=="function"||s[c]&&s[c].id);document.getElementById("currentObject").textContent=`"${e}" \u2014 keys: ${t.join(", ")}`,n(`getObject("${e}") success \u2014 ${t.length} members`,"success")}catch(t){document.getElementById("currentObject").textContent=`Error: ${t.message}`,n(`getObject("${e}") failed: ${t.message}`,"error")}}),document.getElementById("btnInvoke").addEventListener("click",async()=>{if(!s){n("No object loaded \u2014 call getObject first","error");return}const e=document.getElementById("inputMethod").value.trim(),t=document.getElementById("inputArgs").value.trim();let c=[];if(t)try{const r=JSON.parse(t);c=Array.isArray(r)?r:[r]}catch{c=[t]}try{const r=s[e];if(typeof r!="function"){n(`"${e}" is not a function on the proxy`,"error");return}n(`Invoking ${e}(${c.map(v=>JSON.stringify(v)).join(", ")})...`);const i=await r(...c);document.getElementById("invokeResult").textContent=JSON.stringify(i,null,2),n(`${e}() returned`,"success")}catch(r){document.getElementById("invokeResult").textContent=`Error: ${r.message||r}`,n(`${e}() threw: ${r.message||r}`,"error")}}),document.getElementById("btnInvokeError").addEventListener("click",async()=>{if(!s){n('No object \u2014 call getObject("Loan") first',"error");return}try{n("Invoking throwError()..."),await s.throwError(),n("throwError() did not throw (unexpected)","warn")}catch(e){document.getElementById("invokeResult").textContent=`Caught error: ${e.message||e}`,n(`throwError() caught: ${e.message||e}`,"success")}}),document.getElementById("btnInvokeAsync").addEventListener("click",async()=>{if(!s){n('No object \u2014 call getObject("Loan") first',"error");return}try{n("Invoking asyncMethod(200)...");const e=await s.asyncMethod(200);document.getElementById("invokeResult").textContent=JSON.stringify(e,null,2),n("asyncMethod(200) resolved","success")}catch(e){document.getElementById("invokeResult").textContent=`Error: ${e.message||e}`,n(`asyncMethod failed: ${e.message}`,"error")}}),document.getElementById("btnSubscribe").addEventListener("click",()=>{const e=document.getElementById("inputEventId").value.trim();if(e)try{const t=o.subscribe({eventId:e,callback:({eventParams:c,eventOptions:r})=>(E(e,c),y())});a.set(t,{eventId:e}),m(),n(`Subscribed to "${e}" \u2192 ${t.slice(0,8)}...`,"success")}catch(t){n(`Subscribe failed: ${t.message}`,"error")}}),document.getElementById("btnSubscribeCriteria").addEventListener("click",()=>{const e=document.getElementById("inputEventId").value.trim(),t=document.getElementById("inputCriteria").value.trim();if(!e)return;let c;try{c=t?JSON.parse(t):void 0}catch{n("Invalid criteria JSON","error");return}try{const r=o.subscribe({eventId:e,criteria:c,callback:({eventParams:i})=>(E(`${e} [criteria]`,i),y())});a.set(r,{eventId:e,criteria:c}),m(),n(`Subscribed to "${e}" with criteria \u2192 ${r.slice(0,8)}...`,"success")}catch(r){n(`Subscribe+criteria failed: ${r.message}`,"error")}}),document.getElementById("btnUnsubscribe").addEventListener("click",()=>{const e=document.getElementById("selectUnsubToken").value;if(!e){n("Select a subscription to unsubscribe","warn");return}const[t,c]=e.split("|");try{o.unsubscribe({eventId:t,token:c}),a.delete(c),m(),n(`Unsubscribed from "${t}"`,"success")}catch(r){n(`Unsubscribe failed: ${r.message}`,"error")}}),document.getElementById("btnLogLevel0").addEventListener("click",()=>{o.setLogLevel(0),n("setLogLevel(0)","success")}),document.getElementById("btnLogLevel10").addEventListener("click",()=>{o.setLogLevel(10),n("setLogLevel(10)","success")}),document.getElementById("btnDisconnect").addEventListener("click",async()=>{n("Calling close()..."),await o.close(),u(!1),n("Disconnected","success")}),document.getElementById("btnReconnect").addEventListener("click",async()=>{n("Reconnecting..."),await b()})});
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=e2e-guest.js.map
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["webpack://ice.guest/e2e-guest.js"],"sourcesContent":["import { getGuest } from './util.js';\n\nlet guest = null;\nlet currentProxy = null;\nconst subscriptions = new Map();\nlet eventCounter = 0;\n\n// --- Logging ---\nconst logEl = document.getElementById('guestLog');\nconst log = (msg, type = 'info') => {\n const ts = new Date().toLocaleTimeString();\n const color =\n type === 'error'\n ? 'text-red-600'\n : type === 'success'\n ? 'text-green-600'\n : 'text-gray-600';\n logEl.innerHTML += `<div class=\"${color}\">[${ts}] ${msg}</div>`;\n logEl.scrollTop = logEl.scrollHeight;\n};\n\nconst setStatus = (connected) => {\n const el = document.getElementById('connStatus');\n el.textContent = connected ? 'connected' : 'disconnected';\n el.className = `px-2 py-0.5 rounded text-white ${\n connected ? 'bg-green-500' : 'bg-gray-400'\n }`;\n};\n\n// --- Tab switching ---\ndocument.querySelectorAll('.tab-btn').forEach((btn) => {\n btn.addEventListener('click', () => {\n document\n .querySelectorAll('.tab-btn')\n .forEach((b) => b.classList.replace('bg-emerald-200', 'bg-transparent'));\n btn.classList.replace('bg-transparent', 'bg-emerald-200');\n document\n .querySelectorAll('.tab-panel')\n .forEach((p) => p.classList.add('hidden'));\n document\n .getElementById(`panel-${btn.dataset.tab}`)\n .classList.remove('hidden');\n });\n});\n\n// --- Display search params ---\nconst params = new URLSearchParams(window.location.search);\nconst paramsObj = Object.fromEntries(params.entries());\ndocument.getElementById('searchParams').textContent = Object.keys(paramsObj)\n .length\n ? JSON.stringify(paramsObj)\n : '(none)';\n\n// --- Connect ---\nconst doConnect = async () => {\n try {\n guest = getGuest('e2e-guest');\n await guest.connect();\n setStatus(true);\n log('Connected to host', 'success');\n } catch (err) {\n setStatus(false);\n log(`Connect failed: ${err.message}`, 'error');\n }\n};\n\n// --- Feedback value helper ---\nconst getFeedbackValue = () => {\n const v = document.getElementById('selectFeedback').value;\n if (v === 'true') return true;\n if (v === 'false') return false;\n return { status: 'ok' };\n};\n\n// --- Refresh subscriptions UI ---\nconst refreshSubscriptions = () => {\n const el = document.getElementById('subscriptionsList');\n if (!subscriptions.size) {\n el.textContent = '(none)';\n return;\n }\n el.innerHTML = Array.from(subscriptions.entries())\n .map(\n ([token, info]) =>\n `<div>${info.eventId} → ${token.slice(0, 8)}... ${\n info.criteria ? `[criteria: ${JSON.stringify(info.criteria)}]` : ''\n }</div>`,\n )\n .join('');\n\n const select = document.getElementById('selectUnsubToken');\n select.innerHTML = '<option value=\"\">— select token —</option>';\n subscriptions.forEach((info, token) => {\n const opt = document.createElement('option');\n opt.value = `${info.eventId}|${token}`;\n opt.textContent = `${info.eventId} (${token.slice(0, 8)}...)`;\n select.appendChild(opt);\n });\n};\n\n// --- Append event to received list ---\nconst appendEvent = (eventId, data) => {\n eventCounter++;\n const el = document.getElementById('eventsReceived');\n if (eventCounter === 1) el.innerHTML = '';\n const ts = new Date().toLocaleTimeString();\n el.innerHTML += `<div class=\"border-b border-gray-100 py-0.5\">[${ts}] #${eventCounter} <strong>${eventId}</strong>: ${JSON.stringify(\n data,\n )}</div>`;\n el.scrollTop = el.scrollHeight;\n};\n\n// --- Init ---\nwindow.addEventListener('DOMContentLoaded', async () => {\n await doConnect();\n\n // --- Objects Tab ---\n\n document\n .getElementById('btnListObjects')\n .addEventListener('click', async () => {\n try {\n const objects = await guest.listObjects();\n document.getElementById('objectsList').textContent =\n objects.join(', ') || '(empty)';\n log(`listObjects(): [${objects.join(', ')}]`, 'success');\n } catch (err) {\n log(`listObjects failed: ${err.message}`, 'error');\n }\n });\n\n document\n .getElementById('btnGetObject')\n .addEventListener('click', async () => {\n const objectId = document.getElementById('inputObjectId').value.trim();\n if (!objectId) return;\n try {\n currentProxy = await guest.getObject(objectId);\n const methods = Object.keys(currentProxy).filter(\n (k) =>\n typeof currentProxy[k] === 'function' ||\n (currentProxy[k] && currentProxy[k].id),\n );\n document.getElementById(\n 'currentObject',\n ).textContent = `\"${objectId}\" — keys: ${methods.join(', ')}`;\n log(\n `getObject(\"${objectId}\") success — ${methods.length} members`,\n 'success',\n );\n } catch (err) {\n document.getElementById(\n 'currentObject',\n ).textContent = `Error: ${err.message}`;\n log(`getObject(\"${objectId}\") failed: ${err.message}`, 'error');\n }\n });\n\n document.getElementById('btnInvoke').addEventListener('click', async () => {\n if (!currentProxy) {\n log('No object loaded — call getObject first', 'error');\n return;\n }\n const method = document.getElementById('inputMethod').value.trim();\n const argsRaw = document.getElementById('inputArgs').value.trim();\n let args = [];\n if (argsRaw) {\n try {\n const parsed = JSON.parse(argsRaw);\n args = Array.isArray(parsed) ? parsed : [parsed];\n } catch {\n args = [argsRaw];\n }\n }\n try {\n const fn = currentProxy[method];\n if (typeof fn !== 'function') {\n log(`\"${method}\" is not a function on the proxy`, 'error');\n return;\n }\n log(\n `Invoking ${method}(${args\n .map((a) => JSON.stringify(a))\n .join(', ')})...`,\n );\n const result = await fn(...args);\n document.getElementById('invokeResult').textContent = JSON.stringify(\n result,\n null,\n 2,\n );\n log(`${method}() returned`, 'success');\n } catch (err) {\n document.getElementById('invokeResult').textContent = `Error: ${\n err.message || err\n }`;\n log(`${method}() threw: ${err.message || err}`, 'error');\n }\n });\n\n document\n .getElementById('btnInvokeError')\n .addEventListener('click', async () => {\n if (!currentProxy) {\n log('No object — call getObject(\"Loan\") first', 'error');\n return;\n }\n try {\n log('Invoking throwError()...');\n await currentProxy.throwError();\n log('throwError() did not throw (unexpected)', 'warn');\n } catch (err) {\n document.getElementById('invokeResult').textContent = `Caught error: ${\n err.message || err\n }`;\n log(`throwError() caught: ${err.message || err}`, 'success');\n }\n });\n\n document\n .getElementById('btnInvokeAsync')\n .addEventListener('click', async () => {\n if (!currentProxy) {\n log('No object — call getObject(\"Loan\") first', 'error');\n return;\n }\n try {\n log('Invoking asyncMethod(200)...');\n const result = await currentProxy.asyncMethod(200);\n document.getElementById('invokeResult').textContent = JSON.stringify(\n result,\n null,\n 2,\n );\n log('asyncMethod(200) resolved', 'success');\n } catch (err) {\n document.getElementById('invokeResult').textContent = `Error: ${\n err.message || err\n }`;\n log(`asyncMethod failed: ${err.message}`, 'error');\n }\n });\n\n // --- Events Tab ---\n\n document.getElementById('btnSubscribe').addEventListener('click', () => {\n const eventId = document.getElementById('inputEventId').value.trim();\n if (!eventId) return;\n try {\n const token = guest.subscribe({\n eventId,\n callback: ({ eventParams, eventOptions }) => {\n appendEvent(eventId, eventParams);\n return getFeedbackValue();\n },\n });\n subscriptions.set(token, { eventId });\n refreshSubscriptions();\n log(`Subscribed to \"${eventId}\" → ${token.slice(0, 8)}...`, 'success');\n } catch (err) {\n log(`Subscribe failed: ${err.message}`, 'error');\n }\n });\n\n document\n .getElementById('btnSubscribeCriteria')\n .addEventListener('click', () => {\n const eventId = document.getElementById('inputEventId').value.trim();\n const criteriaRaw = document.getElementById('inputCriteria').value.trim();\n if (!eventId) return;\n let criteria;\n try {\n criteria = criteriaRaw ? JSON.parse(criteriaRaw) : undefined;\n } catch {\n log('Invalid criteria JSON', 'error');\n return;\n }\n try {\n const token = guest.subscribe({\n eventId,\n criteria,\n callback: ({ eventParams }) => {\n appendEvent(`${eventId} [criteria]`, eventParams);\n return getFeedbackValue();\n },\n });\n subscriptions.set(token, { eventId, criteria });\n refreshSubscriptions();\n log(\n `Subscribed to \"${eventId}\" with criteria → ${token.slice(0, 8)}...`,\n 'success',\n );\n } catch (err) {\n log(`Subscribe+criteria failed: ${err.message}`, 'error');\n }\n });\n\n document.getElementById('btnUnsubscribe').addEventListener('click', () => {\n const val = document.getElementById('selectUnsubToken').value;\n if (!val) {\n log('Select a subscription to unsubscribe', 'warn');\n return;\n }\n const [eventId, token] = val.split('|');\n try {\n guest.unsubscribe({ eventId, token });\n subscriptions.delete(token);\n refreshSubscriptions();\n log(`Unsubscribed from \"${eventId}\"`, 'success');\n } catch (err) {\n log(`Unsubscribe failed: ${err.message}`, 'error');\n }\n });\n\n // --- Lifecycle Tab ---\n\n document.getElementById('btnLogLevel0').addEventListener('click', () => {\n guest.setLogLevel(0);\n log('setLogLevel(0)', 'success');\n });\n\n document.getElementById('btnLogLevel10').addEventListener('click', () => {\n guest.setLogLevel(10);\n log('setLogLevel(10)', 'success');\n });\n\n document\n .getElementById('btnDisconnect')\n .addEventListener('click', async () => {\n log('Calling close()...');\n await guest.close();\n setStatus(false);\n log('Disconnected', 'success');\n });\n\n document\n .getElementById('btnReconnect')\n .addEventListener('click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AC","names":["getGuest","guest","currentProxy","subscriptions","eventCounter","logEl","log","msg","type","ts","color","setStatus","connected","el","btn","b","p","params","paramsObj","doConnect","err","getFeedbackValue","v","refreshSubscriptions","token","info","select","opt","appendEvent","eventId","data","objects","objectId","methods","k","method","argsRaw","args","parsed","fn","a","result","eventParams","eventOptions","criteriaRaw","criteria","val"],"sourceRoot":"","file":"e2e-guest.js"}
|
package/dist/umd/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(q,R){typeof exports=="object"&&typeof module=="object"?module.exports=R(require("emuiDiagnostics")):typeof define=="function"&&define.amd?define(["emuiDiagnostics"],R):typeof exports=="object"?exports.ice=R(require("emuiDiagnostics")):(q.ice=q.ice||{},q.ice.guest=R(q.emuiDiagnostics))})(globalThis,Q=>(()=>{var q={572(a,l,c){var g=c(736),h=g.Symbol;a.exports=h},561(a,l,c){var g=c(572),h=c(504),y=c(567),u="[object Null]",p="[object Undefined]",T=g?g.toStringTag:void 0;function w(E){return E==null?E===void 0?p:u:T&&T in Object(E)?h(E):y(E)}a.exports=w},605(a,l,c){var g=c(327),h=/^\s+/;function y(u){return u&&u.slice(0,g(u)+1).replace(h,"")}a.exports=y},433(a){var l=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;a.exports=l},504(a,l,c){var g=c(572),h=Object.prototype,y=h.hasOwnProperty,u=h.toString,p=g?g.toStringTag:void 0;function T(w){var E=y.call(w,p),f=w[p];try{w[p]=void 0;var m=!0}catch{}var x=u.call(w);return m&&(E?w[p]=f:delete w[p]),x}a.exports=T},567(a){var l=Object.prototype,c=l.toString;function g(h){return c.call(h)}a.exports=g},736(a,l,c){var g=c(433),h=typeof self=="object"&&self&&self.Object===Object&&self,y=g||h||Function("return this")();a.exports=y},327(a){var l=/\s/;function c(g){for(var h=g.length;h--&&l.test(g.charAt(h)););return h}a.exports=c},702(a,l,c){var g=c(230),h=c(381),y=c(569),u="Expected a function",p=Math.max,T=Math.min;function w(E,f,m){var x,k,U,G,S,L,A=0,j=!1,W=!1,B=!0;if(typeof E!="function")throw new TypeError(u);f=y(f)||0,g(m)&&(j=!!m.leading,W="maxWait"in m,U=W?p(y(m.maxWait)||0,f):U,B="trailing"in m?!!m.trailing:B);function F(b){var $=x,C=k;return x=k=void 0,A=b,G=E.apply(C,$),G}function X(b){return A=b,S=setTimeout(_,f),j?F(b):G}function Z(b){var $=b-L,C=b-A,K=f-$;return W?T(K,U-C):K}function V(b){var $=b-L,C=b-A;return L===void 0||$>=f||$<0||W&&C>=U}function _(){var b=h();if(V(b))return H(b);S=setTimeout(_,Z(b))}function H(b){return S=void 0,B&&x?F(b):(x=k=void 0,G)}function z(){S!==void 0&&clearTimeout(S),A=0,x=L=k=S=void 0}function N(){return S===void 0?G:H(h())}function D(){var b=h(),$=V(b);if(x=arguments,k=this,L=b,$){if(S===void 0)return X(L);if(W)return clearTimeout(S),S=setTimeout(_,f),F(L)}return S===void 0&&(S=setTimeout(_,f)),G}return D.cancel=z,D.flush=N,D}a.exports=w},230(a){function l(c){var g=typeof c;return c!=null&&(g=="object"||g=="function")}a.exports=l},470(a){function l(c){return c!=null&&typeof c=="object"}a.exports=l},89(a,l,c){var g=c(561),h=c(470),y="[object Symbol]";function u(p){return typeof p=="symbol"||h(p)&&g(p)==y}a.exports=u},381(a,l,c){var g=c(736),h=function(){return g.Date.now()};a.exports=h},345(a,l,c){var g=c(702),h=c(230),y="Expected a function";function u(p,T,w){var E=!0,f=!0;if(typeof p!="function")throw new TypeError(y);return h(w)&&(E="leading"in w?!!w.leading:E,f="trailing"in w?!!w.trailing:f),g(p,T,{leading:E,maxWait:T,trailing:f})}a.exports=u},569(a,l,c){var g=c(605),h=c(230),y=c(89),u=NaN,p=/^[-+]0x[0-9a-f]+$/i,T=/^0b[01]+$/i,w=/^0o[0-7]+$/i,E=parseInt;function f(m){if(typeof m=="number")return m;if(y(m))return u;if(h(m)){var x=typeof m.valueOf=="function"?m.valueOf():m;m=h(x)?x+"":x}if(typeof m!="string")return m===0?m:+m;m=g(m);var k=T.test(m);return k||w.test(m)?E(m.slice(2),k?2:8):p.test(m)?u:+m}a.exports=f},388(a){"use strict";a.exports=Q}},R={};function I(a){var l=R[a];if(l!==void 0)return l.exports;var c=R[a]={exports:{}};return q[a](c,c.exports,I),c.exports}I.n=a=>{var l=a&&a.__esModule?()=>a.default:()=>a;return I.d(l,{a:l}),l},I.d=(a,l)=>{for(var c in l)I.o(l,c)&&!I.o(a,c)&&Object.defineProperty(a,c,{enumerable:!0,get:l[c]})},I.o=(a,l)=>Object.prototype.hasOwnProperty.call(a,l),I.r=a=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})};var Y={};return(()=>{"use strict";I.r(Y),I.d(Y,{SSFGuest:()=>le});const l={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let c;const g=new Uint8Array(16);function h(){if(!c&&(c=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!c))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return c(g)}var y;const u=[];for(let n=0;n<256;++n)u.push((n+256).toString(16).slice(1));function p(n,e=0){return u[n[e+0]]+u[n[e+1]]+u[n[e+2]]+u[n[e+3]]+"-"+u[n[e+4]]+u[n[e+5]]+"-"+u[n[e+6]]+u[n[e+7]]+"-"+u[n[e+8]]+u[n[e+9]]+"-"+u[n[e+10]]+u[n[e+11]]+u[n[e+12]]+u[n[e+13]]+u[n[e+14]]+u[n[e+15]]}function T(n,e=0){const t=p(n,e);if(!y(t))throw TypeError("Stringified UUID is invalid");return t}const w=null;function E(n,e,t){if(l.randomUUID&&!e&&!n)return l.randomUUID();n=n||{};const s=n.random||(n.rng||h)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(let i=0;i<16;++i)e[t+i]=s[i];return e}return p(s)}const f=E;var m=I(345),x=I.n(m);const k="elli:remoting",U="elli:remoting:response",G="elli:remoting:exception",S=({messageType:n,messageBody:e,requestId:t,onewayMsg:s=!1})=>({requestId:t??(s?null:f()),source:k,type:n,body:e}),L=n=>{const{targetWin:e,targetOrigin:t,messageType:s,messageBody:i}=n,r=S({messageType:s,messageBody:i});e.postMessage(r,t)};class A{#i;#e;#t=new Map;#a=new Map;#n=null;#s=null;#c=new Map;constructor(e,t){if(!e)throw new Error("logger is required");if(!t)throw new Error("correlationId is required");this.#i=t,this.#e=e}#p=()=>{this.#n=null;const e=Date.now(),t=[];let s=null;if(this.#a.forEach((i,r)=>{const{requestId:o,cancelTime:d}=i;d&&d<=e?(this.#e.debug(`Detected response timeout for requestId: ${o}...`),t.push(r),i.resolve(void 0)):d&&(s=s===null?d:Math.min(s,d))}),t.forEach(i=>{this.#a.delete(i)}),s!==null){const i=Math.max(s-Date.now(),0);this.#g(i)}};#g=e=>{this.#n===null&&(this.#n=window.setTimeout(this.#p,e))};#f=()=>{this.#n!==null&&(window.clearTimeout(this.#n),this.#n=null)};#r=e=>{const t=this.#a.get(e);return this.#e.debug(`serving requestId: ${e}`),this.#a.delete(e),t};#o=e=>{const{requestId:t}=e;this.#e.debug(`Response received for invocation requestId: ${t}`);const s=this.#r(t);return s?(s.resolve(e.body),!0):(this.#e.debug(`Received response to stale/invalid request with requestId: ${t}`),!1)};#h=e=>{this.#e.debug(`Exception received for invocation (requestId = ${e.requestId})`);const t=this.#r(e.requestId);return t?(t.reject(new Error(e.body)),!0):(this.#e.warn(`Received exception for stale/invalid request (requestId = ${e.requestId})`),!1)};#v=({sourceWin:e,sourceOrigin:t,message:s})=>{this.#e.debug(`Received message of type "${s.type}"`);const i=this.#t.get(s.type);return i?(i.forEach(r=>{this.#e.debug(`Invoking message handler ${r.name}`),r({sourceWin:e,sourceOrigin:t,requestId:s.requestId,type:s.type,body:s.body})}),!0):!1};#l=e=>{if(this.#c.size===0||!e.source)return!1;const t=this.#c.get(e.source);return!t||e?.data?.source!==k?!1:(this.#e.debug(`Remoting: Received message of type "${e.data.type}"`),e.data.type===U?this.#o(e.data):e.data.type===G?this.#h(e.data):this.#v({sourceWin:e.source,sourceOrigin:t,message:e.data}),!0)};addSender=e=>{const{origin:t,window:s}=e;if(!t)throw new Error("origin is required");if(!s)throw new Error("window is required");this.#c.set(s,t)};initialize=e=>{this.#s&&this.#s.removeEventListener("message",this.#l),e.addEventListener("message",this.#l),this.#s=e,this.#e.debug(`initialized remoting id: ${this.#i}`)};close=()=>{this.#s&&(this.#s.removeEventListener("message",this.#l),this.#s=null),this.#f(),this.#e.debug(`closed remoting id: ${this.#i}`)};invoke=e=>{const{targetWin:t,targetOrigin:s,messageType:i,messageBody:r,responseTimeoutMs:o}=e;return new Promise((d,O)=>{const v=S({messageType:i,messageBody:r});this.#a.set(v.requestId,{requestId:v.requestId,resolve:d,reject:O,cancelTime:o?Date.now()+o:null}),t.postMessage(v,s);const{requestId:P}=v;this.#e.debug(`Posted invocation message of type ${i} requestId: ${P||""}`),o&&(this.#e.debug(`scheduling timeout check for requestId: ${P||""} in ${o} ms`),this.#g(o))})};listen=e=>{const{messageType:t,callback:s}=e,i=this.#t.get(t)||[];i.push(s),this.#t.set(t,i)};unlisten=e=>{const{messageType:t,callback:s}=e,i=this.#t.get(t);if(!i)return;const r=i.indexOf(s);r!==-1&&i.splice(r,1)};send=e=>{const{targetWin:t,targetOrigin:s,messageType:i,messageBody:r}=e,o=S({messageType:i,messageBody:r,onewayMsg:!0});t.postMessage(o,s),this.#e.debug(`Posted one-way message of type "${i}"`)};removeSender=e=>{const{window:t}=e;t&&this.#c.delete(t)};respond=e=>{const{targetWin:t,targetOrigin:s,requestId:i,response:r}=e,o=S({messageType:U,messageBody:r,requestId:i});t.postMessage(o,s),this.#e.debug(`Response sent to caller for invocation requestId: ${i}`)};raiseException=e=>{const{targetWin:t,targetOrigin:s,requestId:i,ex:r}=e,o=r instanceof Error?r.message:r,d=S({messageType:G,messageBody:o,requestId:i});t.postMessage(d,s),this.#e.debug(`Exception sent to caller for invocation. requestId: ${i}`)}}var j=(n=>(n.GuestClose="guest:close",n.GuestEventSubscribe="guest:eventSubscribe",n.GuestEventUnsubscribe="guest:eventUnsubscribe",n.GuestFocus="guest:focus",n.GuestReady="guest:ready",n.GuestReadyComplete="guest:readyComplete",n.GuestResize="guest:resize",n.HandShake="handshake",n.HandShakeAck="handshake:ack",n.HostClose="host:close",n.HostConfig="host:config",n.ListObjects="list:objects",n.ObjectEvent="object:event",n.ObjectGet="object:get",n.ObjectInvoke="object:invoke",n))(j||{});class W{__TYPE__="Proxy";id;objectType;constructor(e,t){this.id=e,this.objectType=t}}const B=n=>n?.constructor?.name==="Proxy"||n?.constructor?.name==="ScriptingObjectProxy"||n?.__TYPE__==="Proxy";class F{name;objectId;id;constructor(e){const{name:t,objectId:s}=e;if(!t)throw new Error("Event name is required");if(!s)throw new Error("Scripting object id is required");this.objectId=s,this.name=t,this.id=`${this.objectId}.${this.name}`.toLowerCase()}}class X{static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="ProxyEvent"}#i;objectId;name;id;getType(){return"ProxyEvent"}constructor(e){const{name:t,objectId:s,eventSrc:i}=e;if(!t)throw new Error("Event name is required");if(!s)throw new Error("Scripting object id is required");if(!i)throw new Error("Event source is required");this.objectId=s,this.name=t,this.#i=i,this.id=`${this.objectId}.${this.name}`.toLowerCase()}subscribe=e=>this.#i.subscribe({eventId:this.id,callback:e});unsubscribe=e=>{this.#i.unsubscribe({eventId:this.id,token:e})}}const Z=n=>n instanceof F,V=(n,e)=>`${n.toLowerCase()}.${e.toLowerCase()}`;var _=I(388);const H=()=>{const{parent:n}=window;try{return n?.location?.href}catch{return null}},z=n=>{if(!n||n==="about:blank")return"*";try{const{origin:e}=new URL(n);return e==="null"||!e?"*":e}catch{try{const{origin:e}=new URL(n,document.baseURI);return e==="null"||!e?"*":e}catch{return"*"}}},N=()=>window.self!==window.parent,D=(n,e)=>{const t=e||document.body,s=document.defaultView?.getComputedStyle?.(t,null),i=s?s[n]:"0";return parseInt(i,10)},b=/^https?:\/\/([a-z0-9-]+\.)*(?:elliemae\.io|ellielabs\.com|ellieservices\.com|encompassloconnect\.com|ice\.com|localhost:[0-9]+)$/i,$="elli:remoting",C=3e4,K=()=>new Promise((n,e)=>{if(N())n({origin:z(document.referrer||H()),window:window.parent});else{const t=window;let s;const i=r=>{if(b.test(r.origin)){const{source:o,type:d}=r.data||{};if(o===$&&d===j.HandShake){const{origin:O}=r,v=r.source;clearTimeout(s),L({targetWin:v,targetOrigin:O,messageType:j.HandShakeAck,messageBody:{}}),t.removeEventListener("message",i),n({origin:O,window:v})}}};s=setTimeout(()=>{t.removeEventListener("message",i),e(new Error(`Host handshake timed out after ${C}ms`))},C),t.addEventListener("message",i)}});let M=!1;const re=n=>{M=n},J=(n=null)=>{let e=n;const t=()=>{if(!e&&(e=window.ice?.guest?.SSFGuest?new window.ice.guest.SSFGuest:null,!e))throw new Error("Guest definition not found");return e};window.elli=window.elli??{},window.elli.script={guest:{create:(s,i)=>t().addScript(s,i)},connect:s=>t().connect(s),getObject:s=>t().getObject(s),setLogLevel:s=>t().setLogLevel(s),subscribe:(s,i,r,o)=>t().subscribe({eventId:`${s}.${i}`,callback:d=>r(d?.obj,d?.eventParams,d?.eventOptions),criteria:o?.criteria}),unsubscribe:(s,i,r)=>t().unsubscribe({eventId:`${s}.${i}`,token:r})}};try{J()}catch{}var oe=(n=>(n.OBJECT="object",n.VALUE="value",n))(oe||{});const ee=12e4,ce={eventFeedback:!0},te=()=>{const{document:n}=window,e=n.body,t=n.documentElement,i={height:e.offsetHeight+D("marginTop")+D("marginBottom"),width:Math.max(e.scrollWidth,t.scrollWidth)};L({targetWin:window.parent,targetOrigin:z(n.referrer||H()),messageType:j.GuestResize,messageBody:i}),window.removeEventListener("load",te)};N()&&window.addEventListener("load",te);const se={"cdn.ice.com":"https://api.elliemae.com/diagnostics/v2/logging","cdn.np.ice.com":"https://stg.api.elliemae.com/diagnostics/v2/logging","cdn.uat.ice.com":"https://concept.api.elliemae.com/diagnostics/v2/logging","cdn.pt1.ice.com":"https://pel1.api.ellielabs.com/diagnostics/v2/logging","cdn.qa1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging","cdn.dev1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging","cdn.mortgagetech.ice.com":"https://api.elliemae.com/diagnostics/v2/logging","cdn.mortgagetech.s1.ice.com":"https://stg.api.elliemae.com/diagnostics/v2/logging","cdn.mortgagetech.uat1.ice.com":"https://concept.api.elliemae.com/diagnostics/v2/logging","cdn.mortgagetech.pl1.ice.com":"https://pel1.api.ellielabs.com/diagnostics/v2/logging","cdn.mortgagetech.q1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging","cdn.mortgagetech.d1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging",localhost:"https://int.api.ellielabs.com/diagnostics/v2/logging"},ie=["click","scroll","keypress","touchstart"],ae=()=>{const n=document.currentScript?.src||"file:///opt/jenkins/workspace/UIPlatform_pui-microfe_master/245/libs/ssf-guest/lib/guest.ts",e=n?new URL(n).hostname:"localhost";return se[e]||se["cdn.mortgagetech.q1.ice.com"]};class le{#i;#e;#t;#a=!1;#n=null;#s=!1;#c=new Map;#p=null;#g=null;#f=null;#r=null;#o=null;#h=null;#v=new Map;#l(){if(!this.#o||!this.#r)throw new Error("Guest is not connected to a host. Call connect() first.");return{hostWindow:this.#o,hostOrigin:this.#r}}#E=!1;#u=null;#m=null;#b=null;#S=!0;#j=ee;#O;#w=null;constructor(e){const{console:t=!1,url:s=window.__ICE__?.diagnosticsUrl||ae(),index:i="ssf-guest-v2",team:r="ICE",appName:o="SSF Guest V2 Application"}=e?.logger??{};this.#O=e?.logger,this.#E=e?.usesDevConnectAPI??!1,this.#S=e?.keepAlive??!0,this.#j=e?.keepAliveInterval??ee;const d=t?(0,_.Console)():(0,_.http)(s);this.#e=e?.appLogger??(0,_.logger)({transport:d,index:i,team:r,appName:o}),(0,_.webvitals)(this.#e),(0,_.logUnhandledErrors)(this.#e),this.#i=f(),this.#t=new A(this.#e,this.#i),J(this),this.#e.audit({message:"Guest created",guestUrl:window.location.href,correlationId:this.#i})}#d=()=>({guestId:this.#p,guestTitle:this.#g,guestUrl:this.#f});#y=e=>{if(!e||!e.objectId)throw this.#e.error("Deserialization of scripting object failed. Object does not have an Object ID."),new Error("Cannot deserialize object JSON into proxy.");const t=new W(e.objectId,e.objectType);return e.functions&&e.functions.forEach(s=>{Object.defineProperty(t,s,{value:async(...i)=>this.#x({objectId:t.id,functionName:s,functionParams:[...i]}),enumerable:!0})}),e.events&&e.events.forEach(s=>{Object.defineProperty(t,s,{value:new X({objectId:t.id,name:s,eventSrc:this}),enumerable:!0})}),this.#e.debug(`Created guest proxy for scripting object (id = "${t.id}")`),t};#x=async({objectId:e,functionName:t,functionParams:s})=>{this.#e.debug(`Invoking scripting object method ${e}.${t}()...`);const i=[];if(s)for(let v=0;v<s.length;v+=1){const P=s[v];P instanceof Promise&&i.push(P.then(ne=>{s[v]=ne}))}await Promise.all(i);const{hostWindow:r,hostOrigin:o}=this.#l(),d=await this.#t.invoke({targetWin:r,targetOrigin:o,messageType:j.ObjectInvoke,messageBody:{objectId:e,functionName:t,functionParams:s}}),O=this.#T(d);return this.#e.audit({message:"Guest proxy invoked Scripting Object method",scriptingObject:e,scriptingMethod:t,...this.#d()}),O};#I(e,t){return Object.entries(t).every(([s,i])=>{const r=e[s];if("eq"in i)return r===i.eq;if("in"in i)return Array.isArray(i.in)&&i.in.includes(r);if("includes"in i)return Array.isArray(r)&&r.includes(i.includes);if("gt"in i){const o=typeof r=="number"?r:Number(r);return!Number.isNaN(o)&&o>i.gt}if("lt"in i){const o=typeof r=="number"?r:Number(r);return!Number.isNaN(o)&&o<i.lt}if("regex"in i)try{let o=this.#v.get(i.regex);return o||(o=new RegExp(i.regex),this.#v.set(i.regex,o)),typeof r=="string"&&o.test(r)}catch{return!1}return!1})}#T=e=>e?.type==="object"&&"object"in e?this.#y(e.object):e?.type==="value"?e.value:e;#k=({body:e})=>{e?.logLevel&&(this.#e.setLogLevel(e.logLevel),this.#e.debug(`Log level changed by host to ${e.logLevel}`)),this.#p=e?.guestId??null,this.#g=e?.guestTitle??null,this.#f=e?.guestUrl??null,this.#e.audit({message:"Received configuration from Host",...this.#d()})};#L=()=>{window.focus()};#_=async()=>{await this.close(),window.close()};#$=()=>{N()||(this.#h=setInterval(()=>{this.#o?.closed&&this.close().then(()=>{window.close()}).catch(()=>{})},1e3))};#P=async({sourceWin:e,sourceOrigin:t,requestId:s,body:i})=>{const r=this.#y(i.object);if(r){const o=V(r.id,i.eventName);this.#e.debug(`Received event "${o}" from host`);let d;i.eventHandler?d=[{callback:window[i.eventHandler],token:f()}]:d=this.#c.get(o)||[];const O=[];if(d.forEach(v=>{if(v?.callback){if(v.criteria&&!(i.eventParams?this.#I(i.eventParams,v.criteria):!1)){this.#e.debug(`Event ${o} did not match criteria for subscriber ${v.callback.name}`);return}this.#e.debug(`Invoking event subscriber ${v.callback.name} for event ${o}`);const P=v.callback({obj:r,eventName:i.eventName,eventParams:i.eventParams,eventOptions:i.eventOptions});P instanceof Promise?O.push(P):typeof P<"u"&&O.push(Promise.resolve(P))}}),s){const v=await Promise.all(O);this.#t.respond({targetWin:e,targetOrigin:t,requestId:s,response:v}),this.#e.audit({message:"Guest proxy processed event from host and responded",scriptingEventId:o,scriptingObject:r.id,...this.#d()})}else this.#e.audit({message:"Guest proxy processed event from host",scriptingEventId:o,scriptingObject:r.id,...this.#d()})}};#G=async()=>{if(!(!this.#u||!this.#m||!this.#b))try{await fetch(`${this.#b}/oauth2/v1/token/introspection?${new URLSearchParams({token:this.#u,client_id:this.#m}).toString()}`,{headers:{"content-type":"application/x-www-form-urlencoded;charset=UTF-8"},method:"POST"})}catch(e){this.#e.warn(`Failed to extend token lifetime: ${e.message}`)}};#C=async()=>{if(this.#u&&this.#m&&this.#b)try{await fetch(`${this.#b}/oauth2/v1/token/revocation?${new URLSearchParams({token:this.#u,client_id:this.#m}).toString()}`,{method:"POST"})}catch(e){this.#e.error(`Error revoking token. ${e.message}`)}finally{this.#u=null,this.#m=null}};#R=async()=>{if(this.#S)try{const e=await this.getObject("application");e?(this.#w=x()(async()=>{try{await e.keepSessionAlive(),await this.#G()}catch(t){this.#e.error(`Error keeping session alive. ${t.message}`)}},this.#j,{leading:!1}),ie.forEach(t=>{document.addEventListener(t,this.#w)})):this.#e.warn("Application object not available to send keep alive")}catch(e){this.#e.error(`Error getting application object. ${e.message}`)}};addScript=async(e,t)=>{if(!this.#a&&e){await this.connect();const s=document.createElement("script");s.setAttribute("src",e),s.setAttribute("type","module"),await new Promise((i,r)=>{let o,d;const O=()=>{s.removeEventListener("load",o),s.removeEventListener("error",d)};o=()=>{O(),this.#a=!0,re(!0),i()},d=()=>{O(),r(new Error(`Failed to load script: ${e}`))},s.addEventListener("load",o),s.addEventListener("error",d),this.#n=t.appendChild(s)})}};close=async()=>{this.#s&&(this.#o&&this.#r&&(this.#t.send({targetWin:this.#o,targetOrigin:this.#r,messageType:j.GuestClose,messageBody:{}}),this.#t.removeSender({origin:this.#r,window:this.#o})),this.#t.close(),this.#h&&(clearInterval(this.#h),this.#h=null),this.#w&&ie.forEach(e=>{document.removeEventListener(e,this.#w)}),await this.#C(),window.removeEventListener("beforeunload",this.close),this.#s=!1,this.#e.audit({message:"Guest disconnected from host",...this.#d()}),this.#p=null,this.#f=null,this.#g=null)};connect=async e=>{if(!this.#s){let t=window,s={...ce};if(e){const{window:r,...o}=e;r&&(t=r),s={...s,...o}}const i=await K();this.#r=i.origin,this.#o=i.window,this.#t.initialize(t),this.#t.addSender({origin:this.#r,window:this.#o}),this.#t.listen({messageType:j.ObjectEvent,callback:this.#P.bind(this)}),this.#t.listen({messageType:j.HostConfig,callback:this.#k.bind(this)}),this.#t.listen({messageType:j.GuestFocus,callback:this.#L.bind(this)}),this.#t.listen({messageType:j.HostClose,callback:this.#_.bind(this)}),this.#t.send({targetWin:this.#o,targetOrigin:this.#r,messageType:j.GuestReady,messageBody:s}),this.#s=!0,this.#$(),this.#E&&await this.getAuthToken(),await this.#R(),window.addEventListener("beforeunload",this.close),this.#e.audit({message:"Guest connected to host",guestUrl:window.location.href})}};getAuthToken=async()=>{if(!this.#u&&this.#s)try{const e=await this.getObject("auth");if(e){const t=await e.getAccessToken();this.#u=t?.access_token,this.#b=t?.host_name,this.#m=t?.client_id}else this.#e.warn("Auth object not available to get access token from host")}catch(e){this.#e.error(`Error getting access token from auth object. ${e.message}`)}return this.#u};getObject=async e=>{if(this.#e.debug(`Retrieving scripting object "${e}" from host...`),!this.#s)throw new Error("Not connected to host");const{hostWindow:t,hostOrigin:s}=this.#l(),i=await this.#t.invoke({targetWin:t,targetOrigin:s,messageType:j.ObjectGet,messageBody:{objectId:e}}),r=this.#y(i.object);return this.#e.audit({message:"Received scripting object from host",scriptingObject:e,...this.#d()}),r};listObjects=async()=>{if(this.#e.debug("Retrieving names of scripting objects exposed by host..."),!this.#s)throw new Error("Not connected to host");const{hostWindow:e,hostOrigin:t}=this.#l(),s=await this.#t.invoke({targetWin:e,targetOrigin:t,messageType:j.ListObjects,messageBody:{}});return this.#e.audit({message:"Received names of all scripting objects exposed by host",objects:s,...this.#d()}),s};removeScript=()=>{if(this.#a&&this.#n){const{parentNode:e}=this.#n;e?.removeChild?.(this.#n)}};setLogLevel=e=>{this.#e.setLogLevel(e),this.#e.debug(`Log level changed by guest to ${e}`)};subscribe=e=>{const{eventId:t,criteria:s,callback:i}=e;this.#e.debug(`Registering subscription for event ${t}`);const r=this.#c.get(t.toLowerCase())||[],o=f();r.push({callback:i,token:o,criteria:s}),this.#c.set(t.toLowerCase(),r);const{hostWindow:d,hostOrigin:O}=this.#l();return this.#t.send({targetWin:d,targetOrigin:O,messageType:j.GuestEventSubscribe,messageBody:{eventId:t,criteria:s,token:o}}),this.#e.debug(`Subscribed to event ${t} with token ${o}`),o};unsubscribe=e=>{const{eventId:t,token:s}=e,i=this.#c.get(t.toLowerCase());if(i){const r=i.length,o=i.filter(d=>d.token!==s);if(o.length<r){this.#c.set(t.toLowerCase(),o);const{hostWindow:d,hostOrigin:O}=this.#l();this.#t.send({targetWin:d,targetOrigin:O,messageType:j.GuestEventUnsubscribe,messageBody:{eventId:t,token:s}}),this.#e.debug(`Unsubscribed from event ${t}`)}}}}})(),Y})());
|
|
1
|
+
(function(q,R){typeof exports=="object"&&typeof module=="object"?module.exports=R(require("emuiDiagnostics")):typeof define=="function"&&define.amd?define(["emuiDiagnostics"],R):typeof exports=="object"?exports.ice=R(require("emuiDiagnostics")):(q.ice=q.ice||{},q.ice.guest=R(q.emuiDiagnostics))})(globalThis,Z=>(()=>{var q={572(a,l,c){var g=c(736),h=g.Symbol;a.exports=h},561(a,l,c){var g=c(572),h=c(504),w=c(567),u="[object Null]",p="[object Undefined]",I=g?g.toStringTag:void 0;function v(y){return y==null?y===void 0?p:u:I&&I in Object(y)?h(y):w(y)}a.exports=v},605(a,l,c){var g=c(327),h=/^\s+/;function w(u){return u&&u.slice(0,g(u)+1).replace(h,"")}a.exports=w},433(a){var l=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;a.exports=l},504(a,l,c){var g=c(572),h=Object.prototype,w=h.hasOwnProperty,u=h.toString,p=g?g.toStringTag:void 0;function I(v){var y=w.call(v,p),f=v[p];try{v[p]=void 0;var m=!0}catch{}var x=u.call(v);return m&&(y?v[p]=f:delete v[p]),x}a.exports=I},567(a){var l=Object.prototype,c=l.toString;function g(h){return c.call(h)}a.exports=g},736(a,l,c){var g=c(433),h=typeof self=="object"&&self&&self.Object===Object&&self,w=g||h||Function("return this")();a.exports=w},327(a){var l=/\s/;function c(g){for(var h=g.length;h--&&l.test(g.charAt(h)););return h}a.exports=c},702(a,l,c){var g=c(230),h=c(381),w=c(569),u="Expected a function",p=Math.max,I=Math.min;function v(y,f,m){var x,k,U,C,E,_,A=0,S=!1,W=!1,N=!0;if(typeof y!="function")throw new TypeError(u);f=w(f)||0,g(m)&&(S=!!m.leading,W="maxWait"in m,U=W?p(w(m.maxWait)||0,f):U,N="trailing"in m?!!m.trailing:N);function F(b){var P=x,G=k;return x=k=void 0,A=b,C=y.apply(G,P),C}function X(b){return A=b,E=setTimeout($,f),S?F(b):C}function J(b){var P=b-_,G=b-A,K=f-P;return W?I(K,U-G):K}function V(b){var P=b-_,G=b-A;return _===void 0||P>=f||P<0||W&&G>=U}function $(){var b=h();if(V(b))return H(b);E=setTimeout($,J(b))}function H(b){return E=void 0,N&&x?F(b):(x=k=void 0,C)}function z(){E!==void 0&&clearTimeout(E),A=0,x=_=k=E=void 0}function B(){return E===void 0?C:H(h())}function D(){var b=h(),P=V(b);if(x=arguments,k=this,_=b,P){if(E===void 0)return X(_);if(W)return clearTimeout(E),E=setTimeout($,f),F(_)}return E===void 0&&(E=setTimeout($,f)),C}return D.cancel=z,D.flush=B,D}a.exports=v},230(a){function l(c){var g=typeof c;return c!=null&&(g=="object"||g=="function")}a.exports=l},470(a){function l(c){return c!=null&&typeof c=="object"}a.exports=l},89(a,l,c){var g=c(561),h=c(470),w="[object Symbol]";function u(p){return typeof p=="symbol"||h(p)&&g(p)==w}a.exports=u},381(a,l,c){var g=c(736),h=function(){return g.Date.now()};a.exports=h},345(a,l,c){var g=c(702),h=c(230),w="Expected a function";function u(p,I,v){var y=!0,f=!0;if(typeof p!="function")throw new TypeError(w);return h(v)&&(y="leading"in v?!!v.leading:y,f="trailing"in v?!!v.trailing:f),g(p,I,{leading:y,maxWait:I,trailing:f})}a.exports=u},569(a,l,c){var g=c(605),h=c(230),w=c(89),u=NaN,p=/^[-+]0x[0-9a-f]+$/i,I=/^0b[01]+$/i,v=/^0o[0-7]+$/i,y=parseInt;function f(m){if(typeof m=="number")return m;if(w(m))return u;if(h(m)){var x=typeof m.valueOf=="function"?m.valueOf():m;m=h(x)?x+"":x}if(typeof m!="string")return m===0?m:+m;m=g(m);var k=I.test(m);return k||v.test(m)?y(m.slice(2),k?2:8):p.test(m)?u:+m}a.exports=f},388(a){"use strict";a.exports=Z}},R={};function T(a){var l=R[a];if(l!==void 0)return l.exports;var c=R[a]={exports:{}};return q[a](c,c.exports,T),c.exports}T.n=a=>{var l=a&&a.__esModule?()=>a.default:()=>a;return T.d(l,{a:l}),l},T.d=(a,l)=>{for(var c in l)T.o(l,c)&&!T.o(a,c)&&Object.defineProperty(a,c,{enumerable:!0,get:l[c]})},T.o=(a,l)=>Object.prototype.hasOwnProperty.call(a,l),T.r=a=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})};var Y={};return(()=>{"use strict";T.r(Y),T.d(Y,{SSFGuest:()=>ue});const l={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let c;const g=new Uint8Array(16);function h(){if(!c&&(c=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!c))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return c(g)}var w;const u=[];for(let n=0;n<256;++n)u.push((n+256).toString(16).slice(1));function p(n,e=0){return u[n[e+0]]+u[n[e+1]]+u[n[e+2]]+u[n[e+3]]+"-"+u[n[e+4]]+u[n[e+5]]+"-"+u[n[e+6]]+u[n[e+7]]+"-"+u[n[e+8]]+u[n[e+9]]+"-"+u[n[e+10]]+u[n[e+11]]+u[n[e+12]]+u[n[e+13]]+u[n[e+14]]+u[n[e+15]]}function I(n,e=0){const t=p(n,e);if(!w(t))throw TypeError("Stringified UUID is invalid");return t}const v=null;function y(n,e,t){if(l.randomUUID&&!e&&!n)return l.randomUUID();n=n||{};const s=n.random||(n.rng||h)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(let i=0;i<16;++i)e[t+i]=s[i];return e}return p(s)}const f=y;var m=T(345),x=T.n(m);const k="elli:remoting",U="elli:remoting:response",C="elli:remoting:exception",E=({messageType:n,messageBody:e,requestId:t,onewayMsg:s=!1})=>({requestId:t??(s?null:f()),source:k,type:n,body:e}),_=n=>{const{targetWin:e,targetOrigin:t,messageType:s,messageBody:i}=n,r=E({messageType:s,messageBody:i});e.postMessage(r,t)};class A{#i;#e;#t=new Map;#a=new Map;#n=null;#s=null;#c=new Map;constructor(e,t){if(!e)throw new Error("logger is required");if(!t)throw new Error("correlationId is required");this.#i=t,this.#e=e}#p=()=>{this.#n=null;const e=Date.now(),t=[];let s=null;if(this.#a.forEach((i,r)=>{const{requestId:o,cancelTime:d}=i;d&&d<=e?(this.#e.debug(`Detected response timeout for requestId: ${o}...`),t.push(r),i.resolve(void 0)):d&&(s=s===null?d:Math.min(s,d))}),t.forEach(i=>{this.#a.delete(i)}),s!==null){const i=Math.max(s-Date.now(),0);this.#g(i)}};#g=e=>{this.#n===null&&(this.#n=window.setTimeout(this.#p,e))};#f=()=>{this.#n!==null&&(window.clearTimeout(this.#n),this.#n=null)};#r=e=>{const t=this.#a.get(e);return this.#e.debug(`serving requestId: ${e}`),this.#a.delete(e),t};#o=e=>{const{requestId:t}=e;this.#e.debug(`Response received for invocation requestId: ${t}`);const s=this.#r(t);return s?(s.resolve(e.body),!0):(this.#e.debug(`Received response to stale/invalid request with requestId: ${t}`),!1)};#h=e=>{this.#e.debug(`Exception received for invocation (requestId = ${e.requestId})`);const t=this.#r(e.requestId);return t?(t.reject(new Error(e.body)),!0):(this.#e.warn(`Received exception for stale/invalid request (requestId = ${e.requestId})`),!1)};#v=({sourceWin:e,sourceOrigin:t,message:s})=>{this.#e.debug(`Received message of type "${s.type}"`);const i=this.#t.get(s.type);return i?(i.forEach(r=>{this.#e.debug(`Invoking message handler ${r.name}`),r({sourceWin:e,sourceOrigin:t,requestId:s.requestId,type:s.type,body:s.body})}),!0):!1};#l=e=>{if(this.#c.size===0||!e.source)return!1;const t=this.#c.get(e.source);return!t||e?.data?.source!==k?!1:(this.#e.debug(`Remoting: Received message of type "${e.data.type}"`),e.data.type===U?this.#o(e.data):e.data.type===C?this.#h(e.data):this.#v({sourceWin:e.source,sourceOrigin:t,message:e.data}),!0)};addSender=e=>{const{origin:t,window:s}=e;if(!t)throw new Error("origin is required");if(!s)throw new Error("window is required");this.#c.set(s,t)};initialize=e=>{this.#s&&this.#s.removeEventListener("message",this.#l),e.addEventListener("message",this.#l),this.#s=e,this.#e.debug(`initialized remoting id: ${this.#i}`)};close=()=>{this.#s&&(this.#s.removeEventListener("message",this.#l),this.#s=null),this.#f(),this.#e.debug(`closed remoting id: ${this.#i}`)};invoke=e=>{const{targetWin:t,targetOrigin:s,messageType:i,messageBody:r,responseTimeoutMs:o}=e;return new Promise((d,O)=>{const j=E({messageType:i,messageBody:r});this.#a.set(j.requestId,{requestId:j.requestId,resolve:d,reject:O,cancelTime:o?Date.now()+o:null}),t.postMessage(j,s);const{requestId:L}=j;this.#e.debug(`Posted invocation message of type ${i} requestId: ${L||""}`),o&&(this.#e.debug(`scheduling timeout check for requestId: ${L||""} in ${o} ms`),this.#g(o))})};listen=e=>{const{messageType:t,callback:s}=e,i=this.#t.get(t)||[];i.push(s),this.#t.set(t,i)};unlisten=e=>{const{messageType:t,callback:s}=e,i=this.#t.get(t);if(!i)return;const r=i.indexOf(s);r!==-1&&i.splice(r,1)};send=e=>{const{targetWin:t,targetOrigin:s,messageType:i,messageBody:r}=e,o=E({messageType:i,messageBody:r,onewayMsg:!0});t.postMessage(o,s),this.#e.debug(`Posted one-way message of type "${i}"`)};removeSender=e=>{const{window:t}=e;t&&this.#c.delete(t)};respond=e=>{const{targetWin:t,targetOrigin:s,requestId:i,response:r}=e,o=E({messageType:U,messageBody:r,requestId:i});t.postMessage(o,s),this.#e.debug(`Response sent to caller for invocation requestId: ${i}`)};raiseException=e=>{const{targetWin:t,targetOrigin:s,requestId:i,ex:r}=e,o=r instanceof Error?r.message:r,d=E({messageType:C,messageBody:o,requestId:i});t.postMessage(d,s),this.#e.debug(`Exception sent to caller for invocation. requestId: ${i}`)}}var S=(n=>(n.GuestClose="guest:close",n.GuestEventSubscribe="guest:eventSubscribe",n.GuestEventUnsubscribe="guest:eventUnsubscribe",n.GuestFocus="guest:focus",n.GuestReady="guest:ready",n.GuestReadyComplete="guest:readyComplete",n.GuestResize="guest:resize",n.HandShake="handshake",n.HandShakeAck="handshake:ack",n.HostClose="host:close",n.HostConfig="host:config",n.ListObjects="list:objects",n.ObjectEvent="object:event",n.ObjectGet="object:get",n.ObjectInvoke="object:invoke",n))(S||{});class W{__TYPE__="Proxy";id;objectType;constructor(e,t){this.id=e,this.objectType=t}}const N=n=>n?.constructor?.name==="Proxy"||n?.constructor?.name==="ScriptingObjectProxy"||n?.__TYPE__==="Proxy";class F{name;objectId;id;constructor(e){const{name:t,objectId:s}=e;if(!t)throw new Error("Event name is required");if(!s)throw new Error("Scripting object id is required");this.objectId=s,this.name=t,this.id=`${this.objectId}.${this.name}`.toLowerCase()}}class X{static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="ProxyEvent"}#i;objectId;name;id;getType(){return"ProxyEvent"}constructor(e){const{name:t,objectId:s,eventSrc:i}=e;if(!t)throw new Error("Event name is required");if(!s)throw new Error("Scripting object id is required");if(!i)throw new Error("Event source is required");this.objectId=s,this.name=t,this.#i=i,this.id=`${this.objectId}.${this.name}`.toLowerCase()}subscribe=e=>this.#i.subscribe({eventId:this.id,callback:e});unsubscribe=e=>{this.#i.unsubscribe({eventId:this.id,token:e})}}const J=n=>n instanceof F,V=(n,e)=>`${n.toLowerCase()}.${e.toLowerCase()}`;var $=T(388);const H=()=>{const{parent:n}=window;try{return n?.location?.href}catch{return null}},z=n=>{if(!n||n==="about:blank")return"*";try{const{origin:e}=new URL(n);return e==="null"||!e?"*":e}catch{try{const{origin:e}=new URL(n,document.baseURI);return e==="null"||!e?"*":e}catch{return"*"}}},B=()=>window.self!==window.parent,D=(n,e)=>{const t=e||document.body,s=document.defaultView?.getComputedStyle?.(t,null),i=s?s[n]:"0";return parseInt(i,10)},b=/^https?:\/\/([a-z0-9-]+\.)*(?:elliemae\.io|ellielabs\.com|ellieservices\.com|encompassloconnect\.com|ice\.com|localhost:[0-9]+)$/i,P="elli:remoting",G=3e4,K=()=>new Promise((n,e)=>{if(B())n({origin:z(document.referrer||H()),window:window.parent});else{const t=window;let s;const i=r=>{if(b.test(r.origin)){const{source:o,type:d}=r.data||{};if(o===P&&d===S.HandShake){const{origin:O}=r,j=r.source;clearTimeout(s),_({targetWin:j,targetOrigin:O,messageType:S.HandShakeAck,messageBody:{}}),t.removeEventListener("message",i),n({origin:O,window:j})}}};s=setTimeout(()=>{t.removeEventListener("message",i),e(new Error(`Host handshake timed out after ${G}ms`))},G),t.addEventListener("message",i)}});let M=!1;const re=n=>{M=n},ee=(n=null)=>{let e=n;const t=()=>{if(!e&&(e=window.ice?.guest?.SSFGuest?new window.ice.guest.SSFGuest:null,!e))throw new Error("Guest definition not found");return e};window.elli=window.elli??{},window.elli.script={guest:{create:(s,i)=>t().addScript(s,i)},connect:s=>t().connect(s),getObject:s=>t().getObject(s),setLogLevel:s=>t().setLogLevel(s),subscribe:(s,i,r,o)=>t().subscribe({eventId:`${s}.${i}`,callback:d=>r(d?.obj,d?.eventParams,d?.eventOptions),criteria:o?.criteria}),unsubscribe:(s,i,r)=>t().unsubscribe({eventId:`${s}.${i}`,token:r})}};try{ee()}catch{}var oe=(n=>(n.OBJECT="object",n.VALUE="value",n))(oe||{});const te=12e4,ce=2e3,ae={eventFeedback:!0},se=()=>{const{document:n}=window,e=n.body,t=n.documentElement,i={height:e.offsetHeight+D("marginTop")+D("marginBottom"),width:Math.max(e.scrollWidth,t.scrollWidth)};_({targetWin:window.parent,targetOrigin:z(n.referrer||H()),messageType:S.GuestResize,messageBody:i}),window.removeEventListener("load",se)};B()&&window.addEventListener("load",se);const ie={"cdn.ice.com":"https://api.elliemae.com/diagnostics/v2/logging","cdn.np.ice.com":"https://stg.api.elliemae.com/diagnostics/v2/logging","cdn.uat.ice.com":"https://concept.api.elliemae.com/diagnostics/v2/logging","cdn.pt1.ice.com":"https://pel1.api.ellielabs.com/diagnostics/v2/logging","cdn.qa1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging","cdn.dev1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging","cdn.mortgagetech.ice.com":"https://api.elliemae.com/diagnostics/v2/logging","cdn.mortgagetech.s1.ice.com":"https://stg.api.elliemae.com/diagnostics/v2/logging","cdn.mortgagetech.uat1.ice.com":"https://concept.api.elliemae.com/diagnostics/v2/logging","cdn.mortgagetech.pl1.ice.com":"https://pel1.api.ellielabs.com/diagnostics/v2/logging","cdn.mortgagetech.q1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging","cdn.mortgagetech.d1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging",localhost:"https://int.api.ellielabs.com/diagnostics/v2/logging"},ne=["click","scroll","keypress","touchstart"],le=()=>{const n=document.currentScript?.src||"file:///opt/jenkins/workspace/UIPlatform_pui-microfe_master/253/libs/ssf-guest/lib/guest.ts",e=n?new URL(n).hostname:"localhost";return ie[e]||ie["cdn.mortgagetech.q1.ice.com"]};class ue{#i;#e;#t;#a=!1;#n=null;#s=!1;#c=new Map;#p=null;#g=null;#f=null;#r=null;#o=null;#h=null;#v=new Map;#l(){if(!this.#o||!this.#r)throw new Error("Guest is not connected to a host. Call connect() first.");return{hostWindow:this.#o,hostOrigin:this.#r}}#E=!1;#u=null;#m=null;#b=null;#S=!0;#j=te;#O;#w=null;constructor(e){const{console:t=!1,url:s=window.__ICE__?.diagnosticsUrl||le(),index:i="ssf-guest-v2",team:r="ICE",appName:o="SSF Guest V2 Application"}=e?.logger??{};this.#O=e?.logger,this.#E=e?.usesDevConnectAPI??!1,this.#S=e?.keepAlive??!0,this.#j=e?.keepAliveInterval??te;const d=t?(0,$.Console)():(0,$.http)(s);this.#e=e?.appLogger??(0,$.logger)({transport:d,index:i,team:r,appName:o}),(0,$.webvitals)(this.#e),(0,$.logUnhandledErrors)(this.#e),this.#i=f(),this.#t=new A(this.#e,this.#i),ee(this),this.#e.audit({message:"Guest created",guestUrl:window.location.href,correlationId:this.#i})}#d=()=>({guestId:this.#p,guestTitle:this.#g,guestUrl:this.#f});#y=e=>{if(!e||!e.objectId)throw this.#e.error("Deserialization of scripting object failed. Object does not have an Object ID."),new Error("Cannot deserialize object JSON into proxy.");const t=new W(e.objectId,e.objectType);return e.functions&&e.functions.forEach(s=>{Object.defineProperty(t,s,{value:async(...i)=>{const o=t[s]?.callContext?.callChain;return this.#x({objectId:t.id,functionName:s,functionParams:[...i],callerChain:o})},enumerable:!0})}),e.events&&e.events.forEach(s=>{Object.defineProperty(t,s,{value:new X({objectId:t.id,name:s,eventSrc:this}),enumerable:!0})}),this.#e.debug(`Created guest proxy for scripting object (id = "${t.id}")`),t};#x=async({objectId:e,functionName:t,functionParams:s,callerChain:i})=>{this.#e.debug(`Invoking scripting object method ${e}.${t}()...`);const r=[];if(s)for(let L=0;L<s.length;L+=1){const Q=s[L];Q instanceof Promise&&r.push(Q.then(de=>{s[L]=de}))}await Promise.all(r);const{hostWindow:o,hostOrigin:d}=this.#l(),O=await this.#t.invoke({targetWin:o,targetOrigin:d,messageType:S.ObjectInvoke,messageBody:{objectId:e,functionName:t,functionParams:s,...i?.length?{callerChain:i}:{}}}),j=this.#I(O);return this.#e.audit({message:"Guest proxy invoked Scripting Object method",scriptingObject:e,scriptingMethod:t,...this.#d()}),j};#T(e,t){return Object.entries(t).every(([s,i])=>{const r=e[s];if("eq"in i)return r===i.eq;if("in"in i)return Array.isArray(i.in)&&i.in.includes(r);if("includes"in i)return Array.isArray(r)&&r.includes(i.includes);if("gt"in i){const o=typeof r=="number"?r:Number(r);return!Number.isNaN(o)&&o>i.gt}if("lt"in i){const o=typeof r=="number"?r:Number(r);return!Number.isNaN(o)&&o<i.lt}if("regex"in i)try{let o=this.#v.get(i.regex);return o||(o=new RegExp(i.regex),this.#v.set(i.regex,o)),typeof r=="string"&&o.test(r)}catch{return!1}return!1})}#I=e=>e?.type==="object"&&"object"in e?this.#y(e.object):e?.type==="value"?e.value:e;#k=({body:e})=>{e?.logLevel&&(this.#e.setLogLevel(e.logLevel),this.#e.debug(`Log level changed by host to ${e.logLevel}`)),this.#p=e?.guestId??null,this.#g=e?.guestTitle??null,this.#f=e?.guestUrl??null,this.#e.audit({message:"Received configuration from Host",...this.#d()})};#L=()=>{window.focus()};#_=async()=>{await this.close(),window.close()};#$=()=>{B()||(this.#h=setInterval(()=>{this.#o?.closed&&this.close().then(()=>{window.close()}).catch(()=>{})},1e3))};#P=async({sourceWin:e,sourceOrigin:t,requestId:s,body:i})=>{const r=this.#y(i.object);if(r){const o=V(r.id,i.eventName);this.#e.debug(`Received event "${o}" from host`);let d;i.eventHandler?d=[{callback:window[i.eventHandler],token:f()}]:d=this.#c.get(o)||[];const O=[];if(d.forEach(j=>{if(j?.callback){if(j.criteria&&!(i.eventParams?this.#T(i.eventParams,j.criteria):!1)){this.#e.debug(`Event ${o} did not match criteria for subscriber ${j.callback.name}`);return}this.#e.debug(`Invoking event subscriber ${j.callback.name} for event ${o}`);const L=j.callback({obj:r,eventName:i.eventName,eventParams:i.eventParams,eventOptions:i.eventOptions});L instanceof Promise?O.push(L):typeof L<"u"&&O.push(Promise.resolve(L))}}),s){const j=await Promise.all(O);this.#t.respond({targetWin:e,targetOrigin:t,requestId:s,response:j}),this.#e.audit({message:"Guest proxy processed event from host and responded",scriptingEventId:o,scriptingObject:r.id,...this.#d()})}else this.#e.audit({message:"Guest proxy processed event from host",scriptingEventId:o,scriptingObject:r.id,...this.#d()})}};#C=async()=>{if(!(!this.#u||!this.#m||!this.#b))try{await fetch(`${this.#b}/oauth2/v1/token/introspection?${new URLSearchParams({token:this.#u,client_id:this.#m}).toString()}`,{headers:{"content-type":"application/x-www-form-urlencoded;charset=UTF-8"},method:"POST"})}catch(e){this.#e.warn(`Failed to extend token lifetime: ${e.message}`)}};#G=async()=>{if(this.#u&&this.#m&&this.#b)try{await fetch(`${this.#b}/oauth2/v1/token/revocation?${new URLSearchParams({token:this.#u,client_id:this.#m}).toString()}`,{method:"POST"})}catch(e){this.#e.error(`Error revoking token. ${e.message}`)}finally{this.#u=null,this.#m=null}};#R=async()=>{if(this.#S)try{const e=await Promise.race([this.getObject("application"),new Promise(t=>{setTimeout(()=>t(null),ce)})]);e?(this.#w=x()(async()=>{try{await e.keepSessionAlive(),await this.#C()}catch(t){this.#e.error(`Error keeping session alive. ${t.message}`)}},this.#j,{leading:!1}),ne.forEach(t=>{document.addEventListener(t,this.#w)})):this.#e.warn("Application object not available to send keep alive")}catch(e){this.#e.error(`Error getting application object. ${e.message}`)}};addScript=async(e,t)=>{if(!this.#a&&e){await this.connect();const s=document.createElement("script");s.setAttribute("src",e),s.setAttribute("type","module"),await new Promise((i,r)=>{let o,d;const O=()=>{s.removeEventListener("load",o),s.removeEventListener("error",d)};o=()=>{O(),this.#a=!0,re(!0),i()},d=()=>{O(),r(new Error(`Failed to load script: ${e}`))},s.addEventListener("load",o),s.addEventListener("error",d),this.#n=t.appendChild(s)})}};close=async()=>{this.#s&&(this.#o&&this.#r&&(this.#t.send({targetWin:this.#o,targetOrigin:this.#r,messageType:S.GuestClose,messageBody:{}}),this.#t.removeSender({origin:this.#r,window:this.#o})),this.#t.close(),this.#h&&(clearInterval(this.#h),this.#h=null),this.#w&&ne.forEach(e=>{document.removeEventListener(e,this.#w)}),await this.#G(),window.removeEventListener("beforeunload",this.close),this.#s=!1,this.#e.audit({message:"Guest disconnected from host",...this.#d()}),this.#p=null,this.#f=null,this.#g=null)};connect=async e=>{if(!this.#s){let t=window,s={...ae};if(e){const{window:r,...o}=e;r&&(t=r),s={...s,...o}}const i=await K();this.#r=i.origin,this.#o=i.window,this.#t.initialize(t),this.#t.addSender({origin:this.#r,window:this.#o}),this.#t.listen({messageType:S.ObjectEvent,callback:this.#P.bind(this)}),this.#t.listen({messageType:S.HostConfig,callback:this.#k.bind(this)}),this.#t.listen({messageType:S.GuestFocus,callback:this.#L.bind(this)}),this.#t.listen({messageType:S.HostClose,callback:this.#_.bind(this)}),this.#t.send({targetWin:this.#o,targetOrigin:this.#r,messageType:S.GuestReady,messageBody:s}),this.#s=!0,this.#$(),this.#E&&await this.getAuthToken(),await this.#R(),window.addEventListener("beforeunload",this.close),this.#e.audit({message:"Guest connected to host",guestUrl:window.location.href})}};getAuthToken=async()=>{if(!this.#u&&this.#s)try{const e=await this.getObject("auth");if(e){const t=await e.getAccessToken();this.#u=t?.access_token,this.#b=t?.host_name,this.#m=t?.client_id}else this.#e.warn("Auth object not available to get access token from host")}catch(e){this.#e.error(`Error getting access token from auth object. ${e.message}`)}return this.#u};getObject=async e=>{if(this.#e.debug(`Retrieving scripting object "${e}" from host...`),!this.#s)throw new Error("Not connected to host");const{hostWindow:t,hostOrigin:s}=this.#l(),i=await this.#t.invoke({targetWin:t,targetOrigin:s,messageType:S.ObjectGet,messageBody:{objectId:e}}),r=this.#y(i.object);return this.#e.audit({message:"Received scripting object from host",scriptingObject:e,...this.#d()}),r};listObjects=async()=>{if(this.#e.debug("Retrieving names of scripting objects exposed by host..."),!this.#s)throw new Error("Not connected to host");const{hostWindow:e,hostOrigin:t}=this.#l(),s=await this.#t.invoke({targetWin:e,targetOrigin:t,messageType:S.ListObjects,messageBody:{}});return this.#e.audit({message:"Received names of all scripting objects exposed by host",objects:s,...this.#d()}),s};removeScript=()=>{if(this.#a&&this.#n){const{parentNode:e}=this.#n;e?.removeChild?.(this.#n)}};setLogLevel=e=>{this.#e.setLogLevel(e),this.#e.debug(`Log level changed by guest to ${e}`)};subscribe=e=>{const{eventId:t,criteria:s,callback:i}=e;this.#e.debug(`Registering subscription for event ${t}`);const r=this.#c.get(t.toLowerCase())||[],o=f();r.push({callback:i,token:o,criteria:s}),this.#c.set(t.toLowerCase(),r);const{hostWindow:d,hostOrigin:O}=this.#l();return this.#t.send({targetWin:d,targetOrigin:O,messageType:S.GuestEventSubscribe,messageBody:{eventId:t,criteria:s,token:o}}),this.#e.debug(`Subscribed to event ${t} with token ${o}`),o};unsubscribe=e=>{const{eventId:t,token:s}=e,i=this.#c.get(t.toLowerCase());if(i){const r=i.length,o=i.filter(d=>d.token!==s);if(o.length<r){this.#c.set(t.toLowerCase(),o);const{hostWindow:d,hostOrigin:O}=this.#l();this.#t.send({targetWin:d,targetOrigin:O,messageType:S.GuestEventUnsubscribe,messageBody:{eventId:t,token:s}}),this.#e.debug(`Unsubscribed from event ${t}`)}}}}})(),Y})());
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/umd/index.js.br
CHANGED
|
Binary file
|
package/dist/umd/index.js.gz
CHANGED
|
Binary file
|