@runtypelabs/persona 4.33.0 → 4.34.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/activity-ui.d.cts +3 -15
- package/dist/activity-ui.d.ts +3 -15
- package/dist/animations/glyph-cycle.d.cts +1 -3
- package/dist/animations/glyph-cycle.d.ts +1 -3
- package/dist/animations/wipe.d.cts +1 -3
- package/dist/animations/wipe.d.ts +1 -3
- package/dist/approval-ui.cjs +2 -2
- package/dist/approval-ui.d.cts +3 -15
- package/dist/approval-ui.d.ts +3 -15
- package/dist/approval-ui.js +1 -1
- package/dist/artifacts-ui.cjs +1 -1
- package/dist/artifacts-ui.d.cts +3 -21
- package/dist/artifacts-ui.d.ts +3 -21
- package/dist/background-runtime.d.cts +2 -3
- package/dist/background-runtime.d.ts +2 -3
- package/dist/{chunk-gu34lr-P.js → chunk-Brdx4NCz.js} +1 -1
- package/dist/{chunk-dLJWKfOb.js → chunk-C-rux8Q9.js} +1 -1
- package/dist/{chunk-Ds_twaZn.js → chunk-C4v-HNhS.js} +1 -1
- package/dist/{chunk-Bkma5hIU.js → chunk-CE4seJxF.js} +1 -1
- package/dist/{chunk-D6U0E82p.js → chunk-CV8EPIhT.js} +1 -1
- package/dist/{chunk-ql5N2I_t.js → chunk-CWzHNuVK.js} +1 -1
- package/dist/{chunk-DbGLjU2P.js → chunk-CYpt7PsO.js} +1 -1
- package/dist/{chunk-DOZmcve8.js → chunk-Csr59G5V.js} +1 -1
- package/dist/{chunk-DW7Vg_l2.js → chunk-CxNPSY-b.js} +1 -1
- package/dist/chunk-Dqa_GOcj.js +1 -0
- package/dist/chunk-DsWv3EGF.js +1 -0
- package/dist/{chunk-C7-m0EmI.js → chunk-NUNdcnAZ.js} +1 -1
- package/dist/{chunk-CXQJG7pb.js → chunk-YMkMvAsa.js} +2 -2
- package/dist/{chunk-C-EHtpbB.js → chunk-h5aOI_Pa.js} +1 -1
- package/dist/chunk-kizhspe5.js +1 -0
- package/dist/client-dispatch.js +1 -1
- package/dist/client-history.js +1 -1
- package/dist/client-stream.js +1 -1
- package/dist/{code-generators-DqauYyfX.d.cts → code-generators-DPAqTcAz.d.cts} +0 -2
- package/dist/{code-generators-DqauYyfX.d.ts → code-generators-DPAqTcAz.d.ts} +0 -2
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.d.cts +1 -1
- package/dist/codegen.d.ts +1 -1
- package/dist/codegen.js +1 -1
- package/dist/composer-actions-runtime.cjs +1 -1
- package/dist/composer-actions-runtime.d.cts +4 -20
- package/dist/composer-actions-runtime.d.ts +4 -20
- package/dist/composer-actions-runtime.js +1 -1
- package/dist/{composer-input-DnqGCXZz.d.ts → composer-input-i_FiUp6J.d.cts} +1 -7
- package/dist/{composer-input-DnqGCXZz.d.cts → composer-input-i_FiUp6J.d.ts} +1 -7
- package/dist/{composer-store-6Iwy6WLI.d.ts → composer-store-DhGNgG7Z.d.cts} +1 -3
- package/dist/{composer-store-6Iwy6WLI.d.cts → composer-store-DhGNgG7Z.d.ts} +1 -3
- package/dist/config-diagnostics.d.cts +0 -2
- package/dist/config-diagnostics.d.ts +0 -2
- package/dist/{context-mention-manager-B-rHF98n.d.ts → context-mention-manager-DL-xwGfL.d.cts} +2 -6
- package/dist/{context-mention-manager-B-rHF98n.d.cts → context-mention-manager-DL-xwGfL.d.ts} +2 -6
- package/dist/context-mentions-inline.cjs +1 -1
- package/dist/context-mentions-inline.d.cts +2 -4
- package/dist/context-mentions-inline.d.ts +2 -4
- package/dist/context-mentions-inline.js +1 -1
- package/dist/context-mentions.cjs +1 -1
- package/dist/context-mentions.d.cts +3 -9
- package/dist/context-mentions.d.ts +3 -9
- package/dist/{defaults-BuOjqUAG.d.ts → defaults-Bga2Xrsp.d.cts} +1 -5
- package/dist/{defaults-BuOjqUAG.d.cts → defaults-Bga2Xrsp.d.ts} +1 -5
- package/dist/dictation-runtime.cjs +1 -1
- package/dist/dictation-runtime.d.cts +4 -13
- package/dist/dictation-runtime.d.ts +4 -13
- package/dist/dictation-runtime.js +1 -1
- package/dist/{dom-context-DHTabIn7.d.cts → dom-context-Bw-_9Evh.d.cts} +0 -2
- package/dist/{dom-context-DHTabIn7.d.ts → dom-context-Bw-_9Evh.d.ts} +0 -2
- package/dist/event-stream-view.cjs +1 -1
- package/dist/event-stream-view.d.cts +3 -16
- package/dist/event-stream-view.d.ts +3 -16
- package/dist/{fallback-speech-engine-SqEfkGda.d.ts → fallback-speech-engine-kLdyPcmk.d.cts} +1 -3
- package/dist/{fallback-speech-engine-SqEfkGda.d.cts → fallback-speech-engine-kLdyPcmk.d.ts} +1 -3
- package/dist/{feature-preferences-DqAmje-2.d.ts → feature-preferences-CmwZGKrf.d.cts} +1 -5
- package/dist/{feature-preferences-DqAmje-2.d.cts → feature-preferences-CmwZGKrf.d.ts} +1 -5
- package/dist/forms-ui.d.cts +2 -4
- package/dist/forms-ui.d.ts +2 -4
- package/dist/{history-confirm-dialog-B3L7QNcO.d.cts → history-confirm-dialog-i46-lPN_.d.cts} +2 -14
- package/dist/{history-confirm-dialog-B3L7QNcO.d.ts → history-confirm-dialog-i46-lPN_.d.ts} +2 -14
- package/dist/history-shell.cjs +1 -1
- package/dist/history-shell.d.cts +8 -27
- package/dist/history-shell.d.ts +8 -27
- package/dist/history-shell.js +1 -1
- package/dist/history-view.d.cts +1 -1
- package/dist/history-view.d.ts +1 -1
- package/dist/icons-extra.cjs +1 -1
- package/dist/icons-extra.d.cts +0 -2
- package/dist/icons-extra.d.ts +0 -2
- package/dist/index.cjs +45 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +49 -49
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/launcher.global.js +2 -2
- package/dist/launcher.global.js.map +1 -1
- package/dist/{loading-label-runtime-loader-JecjOfJS.d.ts → loading-label-runtime-loader-Ccr3ETd3.d.cts} +1 -3
- package/dist/{loading-label-runtime-loader-JecjOfJS.d.cts → loading-label-runtime-loader-Ccr3ETd3.d.ts} +1 -3
- package/dist/loading-label-runtime.cjs +1 -1
- package/dist/loading-label-runtime.d.cts +1 -1
- package/dist/loading-label-runtime.d.ts +1 -1
- package/dist/loading-label-runtime.js +1 -1
- package/dist/markdown-parsers.js +1 -1
- package/dist/{message-bubble-CBYtpDsT.d.ts → message-bubble-C6AVaH7f.d.cts} +20 -3
- package/dist/{message-bubble-CBYtpDsT.d.cts → message-bubble-C6AVaH7f.d.ts} +20 -3
- package/dist/{plugin-kit-C1mRjLgW.d.cts → plugin-kit-BVggqE3C.d.cts} +0 -2
- package/dist/{plugin-kit-C1mRjLgW.d.ts → plugin-kit-BVggqE3C.d.ts} +0 -2
- package/dist/plugin-kit.d.cts +1 -1
- package/dist/plugin-kit.d.ts +1 -1
- package/dist/preferences-runtime.cjs +1 -1
- package/dist/preferences-runtime.d.cts +1 -1
- package/dist/preferences-runtime.d.ts +1 -1
- package/dist/preferences-runtime.js +1 -1
- package/dist/{preview-_UJwwt2L.d.cts → preview-BMdRffo4.d.cts} +2 -6
- package/dist/{preview-_UJwwt2L.d.ts → preview-BMdRffo4.d.ts} +2 -6
- package/dist/{registry-B5ZV3K-h.d.ts → registry-B16l8s1b.d.cts} +1 -8
- package/dist/{registry-B5ZV3K-h.d.cts → registry-B16l8s1b.d.ts} +1 -8
- package/dist/{session-Bys8_XuB.d.cts → session-CtZHe7fc.d.cts} +8 -92
- package/dist/{session-Bys8_XuB.d.ts → session-CtZHe7fc.d.ts} +8 -92
- package/dist/session-reconnect.d.cts +2 -4
- package/dist/session-reconnect.d.ts +2 -4
- package/dist/smart-dom-reader.d.cts +2 -8
- package/dist/smart-dom-reader.d.ts +2 -8
- package/dist/testing.d.cts +0 -2
- package/dist/testing.d.ts +0 -2
- package/dist/theme-editor-preview.cjs +42 -42
- package/dist/theme-editor-preview.d.cts +1 -1
- package/dist/theme-editor-preview.d.ts +1 -1
- package/dist/theme-editor-preview.js +25 -25
- package/dist/theme-editor.cjs +25 -5
- package/dist/theme-editor.d.cts +2 -22
- package/dist/theme-editor.d.ts +2 -22
- package/dist/theme-editor.js +1 -1
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +2 -4
- package/dist/theme-reference.d.ts +2 -4
- package/dist/theme-reference.js +1 -1
- package/dist/{tool-loading-animation-d5qAQcwv.d.ts → tool-loading-animation-D2cyFvmM.d.cts} +1 -7
- package/dist/{tool-loading-animation-d5qAQcwv.d.cts → tool-loading-animation-D2cyFvmM.d.ts} +1 -7
- package/dist/{tooltip-BkW-8MnD.d.cts → tooltip-DbXkAuJL.d.cts} +0 -2
- package/dist/{tooltip-BkW-8MnD.d.ts → tooltip-DbXkAuJL.d.ts} +0 -2
- package/dist/{turn-activity-ui-q6fHVnx-.d.cts → turn-activity-ui-Do1Nd-Ow.d.cts} +2 -12
- package/dist/{turn-activity-ui-q6fHVnx-.d.ts → turn-activity-ui-Do1Nd-Ow.d.ts} +2 -12
- package/dist/turn-activity-ui.d.cts +1 -1
- package/dist/turn-activity-ui.d.ts +1 -1
- package/dist/{types-B_mj21jg.d.cts → types-BC7MRxO5.d.cts} +76 -29
- package/dist/{types-B_mj21jg.d.ts → types-BC7MRxO5.d.ts} +76 -29
- package/dist/ui-extras.js +3 -3
- package/dist/voice-client-tools.d.cts +1 -3
- package/dist/voice-client-tools.d.ts +1 -3
- package/dist/voice-runtime.cjs +1 -1
- package/dist/voice-runtime.d.cts +2 -12
- package/dist/voice-runtime.d.ts +2 -12
- package/dist/voice-runtime.js +2 -2
- package/dist/voice-worklet-player.d.cts +2 -6
- package/dist/voice-worklet-player.d.ts +2 -6
- package/dist/{webmcp-runtime-entry-ClEO3qdI.d.ts → webmcp-runtime-entry-B8g46vS0.d.cts} +1 -5
- package/dist/{webmcp-runtime-entry-ClEO3qdI.d.cts → webmcp-runtime-entry-B8g46vS0.d.ts} +1 -5
- package/dist/webmcp-runtime.d.cts +1 -1
- package/dist/webmcp-runtime.d.ts +1 -1
- package/dist/widget.css +1 -1
- package/package.json +4 -4
- package/src/components/event-stream-view.test.ts +5 -0
- package/src/components/message-bubble.ts +26 -6
- package/src/components/scroll-to-bottom.test.ts +135 -0
- package/src/components/scroll-to-bottom.ts +50 -13
- package/src/components/user-message-collapse.ts +117 -0
- package/src/defaults.ts +6 -0
- package/src/styles/widget.css +56 -0
- package/src/theme-reference.ts +2 -2
- package/src/types/theme.ts +29 -0
- package/src/types.ts +49 -5
- package/src/ui.scroll-additive.test.ts +219 -117
- package/src/ui.scroll.test.ts +176 -13
- package/src/ui.ts +230 -107
- package/src/ui.turn-activity.test.ts +7 -7
- package/src/ui.user-message-collapse.test.ts +540 -0
- package/src/utils/auto-follow.test.ts +0 -38
- package/src/utils/auto-follow.ts +0 -35
- package/src/utils/theme.test.ts +23 -0
- package/src/utils/tokens.ts +16 -0
- package/dist/chunk-CVMIncEY.js +0 -1
- package/dist/chunk-DVgzoVCB.js +0 -1
- package/dist/chunk-d54BJdKd.js +0 -1
package/dist/install.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){let e=(e,t=!1,r)=>{let n,o,a=e?.style.position??"",i=e?.getAttribute("aria-busy"),l=!1,s=setTimeout(()=>{if(e?.isConnected){if("static"===getComputedStyle(e).position&&(e.style.position="relative",l=!0),e.setAttribute("aria-busy","true"),n=e.ownerDocument.createElement("span"),n.setAttribute("data-persona-loading",""),n.setAttribute("role","status"),n.setAttribute("aria-label","Loading assistant"),n.style.cssText="position:absolute;inset:0;display:grid;place-items:center;pointer-events:none",e.append(n),r)try{return void(o=r({container:n,target:e,kind:t?"launcher":"embedded"}))}catch(e){console.warn("Loading hook failed:",e),n.replaceChildren()}n.setAttribute("data-persona-loading","default"),n.style.cssText="position:absolute;pointer-events:none;box-sizing:border-box;width:14px;height:14px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;"+(t?"bottom:8px;right:8px":"top:50%;left:50%;margin:-7px;color:var(--persona-text,currentColor)"),e.append(n)}},300);return()=>{if(clearTimeout(s),!n||!e)return;let t=n;n=void 0;try{o?.()}catch(e){console.warn("Loading hook failed:",e)}t.remove(),null==i?e.removeAttribute("aria-busy"):e.setAttribute("aria-busy",i),l&&"relative"===e.style.position&&(e.style.position=a)}};!function(){"use strict";if(window.__siteAgentInstallerLoaded)return;window.__siteAgentInstallerLoaded=!0;let t=(()=>{let e=document.currentScript;if(!e)return{};let t={},r=e.getAttribute("data-config");if(r)try{let e=r.replace(/[\r\n]+\s*/g,""),n=JSON.parse(e);if(n.config){let{__proto__:e,constructor:r,prototype:o,...a}=n;Object.assign(t,a)}else t.config=n}catch(e){console.error("Invalid data-config JSON:",e)}for(let[r,n]of[["clientToken","runtype-token"],["flowId","flow-id"],["agentId","agent-id"],["apiUrl","api-url"],["previewQueryParam","preview-param"]]){let o=e.getAttribute(`data-${n}`);o&&(t[r]=o)}return t})(),r=document.currentScript?.src||"",n={...window.siteAgentConfig||{},...t},o=(e,t)=>{try{e?.(t)}catch(e){console.error("Lifecycle callback failed:",e)}},a=(e,t)=>{try{window.dispatchEvent(new CustomEvent(e,{detail:t}))}catch{}},i=(e,t)=>{console.error("Widget install failed:",t),o(n.onError,{phase:e,error:t}),a("persona:error",{phase:e,error:t})},l=e=>{let t=e.launcher??{};return!1!==t.enabled&&"floating"===(t.mountMode??"floating")};if(o(n.onScriptLoad,{version:n.version||"latest"}),a("persona:script-load",{version:n.version||"latest"}),!(()=>{if(!n.previewQueryParam)return!0;let e=new URLSearchParams(window.location.search).get(n.previewQueryParam);return null!==e&&""!==e&&"false"!==e.toLowerCase()&&"0"!==e})())return;let s=n.version||"latest",d=n.cdn||"jsdelivr",c=!1!==n.autoInit,u=()=>{if(!r)return null;try{let e=new URL(r.replace(/^https:\/\/cdn\.runtype\.com\/persona\/latest\//,"https://cdn.runtype.com/persona/4.
|
|
1
|
+
!function(){let e=(e,t=!1,r)=>{let n,o,a=e?.style.position??"",i=e?.getAttribute("aria-busy"),l=!1,s=setTimeout(()=>{if(e?.isConnected){if("static"===getComputedStyle(e).position&&(e.style.position="relative",l=!0),e.setAttribute("aria-busy","true"),n=e.ownerDocument.createElement("span"),n.setAttribute("data-persona-loading",""),n.setAttribute("role","status"),n.setAttribute("aria-label","Loading assistant"),n.style.cssText="position:absolute;inset:0;display:grid;place-items:center;pointer-events:none",e.append(n),r)try{return void(o=r({container:n,target:e,kind:t?"launcher":"embedded"}))}catch(e){console.warn("Loading hook failed:",e),n.replaceChildren()}n.setAttribute("data-persona-loading","default"),n.style.cssText="position:absolute;pointer-events:none;box-sizing:border-box;width:14px;height:14px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;"+(t?"bottom:8px;right:8px":"top:50%;left:50%;margin:-7px;color:var(--persona-text,currentColor)"),e.append(n)}},300);return()=>{if(clearTimeout(s),!n||!e)return;let t=n;n=void 0;try{o?.()}catch(e){console.warn("Loading hook failed:",e)}t.remove(),null==i?e.removeAttribute("aria-busy"):e.setAttribute("aria-busy",i),l&&"relative"===e.style.position&&(e.style.position=a)}};!function(){"use strict";if(window.__siteAgentInstallerLoaded)return;window.__siteAgentInstallerLoaded=!0;let t=(()=>{let e=document.currentScript;if(!e)return{};let t={},r=e.getAttribute("data-config");if(r)try{let e=r.replace(/[\r\n]+\s*/g,""),n=JSON.parse(e);if(n.config){let{__proto__:e,constructor:r,prototype:o,...a}=n;Object.assign(t,a)}else t.config=n}catch(e){console.error("Invalid data-config JSON:",e)}for(let[r,n]of[["clientToken","runtype-token"],["flowId","flow-id"],["agentId","agent-id"],["apiUrl","api-url"],["previewQueryParam","preview-param"]]){let o=e.getAttribute(`data-${n}`);o&&(t[r]=o)}return t})(),r=document.currentScript?.src||"",n={...window.siteAgentConfig||{},...t},o=(e,t)=>{try{e?.(t)}catch(e){console.error("Lifecycle callback failed:",e)}},a=(e,t)=>{try{window.dispatchEvent(new CustomEvent(e,{detail:t}))}catch{}},i=(e,t)=>{console.error("Widget install failed:",t),o(n.onError,{phase:e,error:t}),a("persona:error",{phase:e,error:t})},l=e=>{let t=e.launcher??{};return!1!==t.enabled&&"floating"===(t.mountMode??"floating")};if(o(n.onScriptLoad,{version:n.version||"latest"}),a("persona:script-load",{version:n.version||"latest"}),!(()=>{if(!n.previewQueryParam)return!0;let e=new URLSearchParams(window.location.search).get(n.previewQueryParam);return null!==e&&""!==e&&"false"!==e.toLowerCase()&&"0"!==e})())return;let s=n.version||"latest",d=n.cdn||"jsdelivr",c=!1!==n.autoInit,u=()=>{if(!r)return null;try{let e=new URL(r.replace(/^https:\/\/cdn\.runtype\.com\/persona\/latest\//,"https://cdn.runtype.com/persona/4.34.0/"),document.baseURI);return"http:"!==e.protocol&&"https:"!==e.protocol?null:e.origin+e.pathname.slice(0,e.pathname.lastIndexOf("/"))}catch{return null}},p=e=>({cssUrl:`${e}/widget.css`,jsUrl:`${e}/index.global.js`,launcherUrl:`${e}/launcher.global.js`}),{cssUrl:g,jsUrl:f,launcherUrl:w}=(()=>{if(n.cssUrl&&n.jsUrl){let e=n.jsUrl.replace(/index\.global\.js($|\?)/,"launcher.global.js$1");return{cssUrl:n.cssUrl,jsUrl:n.jsUrl,launcherUrl:e===n.jsUrl?null:e}}if(!n.cdn){let e=u();if(e){if(!n.version)return p(e);let t=new URL(e).origin;if("https://cdn.runtype.com"===t)return p(`${t}/persona/${n.version}`)}}let e="@runtypelabs/persona";return p(`${"unpkg"===d?"https://unpkg.com":"https://cdn.jsdelivr.net"}${"unpkg"===d?`/${e}@${s}/dist`:`/npm/${e}@${s}/dist`}`)})();if(!n.cssUrl||!n.jsUrl){let e=u();try{e&&new URL(e).origin!==new URL(f,document.baseURI).origin&&console.warn(`${f}: strict CSP may silently block cross-origin assets; pin the installer URL.`)}catch{}}let h=()=>!!window.AgentWidget,m=(e,t,r=!1)=>new Promise((n,o)=>{if(t||!e)return void n();let a=document.createElement(r?"link":"script");Object.assign(a,r?{rel:"stylesheet",href:e}:{src:e,async:!0}),r&&a.setAttribute("data-persona","true"),a.onload=()=>n(),a.onerror=()=>o(Error(`Failed to load ${e}`)),document.head.appendChild(a)}),y=()=>m(g,!!document.head.querySelector('link[data-persona],link[href*="widget.css"]'),!0),b=()=>m(f,h()),v=()=>{let e=n.target||"body",t={...n.config};for(let e of["apiUrl","clientToken","flowId","agentId","future","brand"])n[e]&&!t[e]&&(t[e]=n[e]);return{target:e,widgetConfig:t}},U=async(e=!1)=>{if(!window.AgentWidget?.initAgentWidget)throw Error("Widget unavailable");let t,{target:r,widgetConfig:i}=v();if(0!==Object.keys(i).length){!i.postprocessMessage&&window.AgentWidget.markdownPostprocessor&&(i.postprocessMessage=({text:e})=>window.AgentWidget.markdownPostprocessor(e));try{return t=window.AgentWidget.initAgentWidget({target:r,config:i,useShadowDom:n.useShadowDom??!1,windowKey:n.windowKey}),await(t?.ready),e&&t?.open?.(),!e&&l(i)&&(o(n.onLauncherShown,{deferred:!1}),a("persona:launcher-shown",{deferred:!1})),o(n.onChatReady,t),a("persona:chat-ready",t),t}catch(e){throw t?.destroy?.(),e}}},A=(t,r)=>{let l,s="idle",d=window.AgentWidgetLauncher.mount({target:t,config:r,onOpen:()=>{if("idle"!==s)return;s="loading";let t="bundle",r=e(l?.element??null,!0,n.renderLoading);b().then(async()=>{t="init",await U(!0),r(),l?.destroy(),s="done"}).catch(e=>{r(),s="idle",i(t,e)})}});l=d,o(n.onLauncherShown,{deferred:!0,element:d.element}),a("persona:launcher-shown",{deferred:!0,element:d.element}),(()=>{let e=()=>{let e=h()?[]:[f];for(let t of["markdown-parsers.js","client-stream.js"]){let r=f.replace(/index\.global\.js($|\?)/,`${t}$1`);r!==f&&e.push(r)}for(let t of e){let e=document.createElement("link");Object.assign(e,{rel:"prefetch",as:"script",href:t}),document.head.appendChild(e)}};typeof requestIdleCallback<"u"?requestIdleCallback(e,{timeout:4e3}):setTimeout(e,1200)})()};(e=>{let t=()=>{typeof requestIdleCallback<"u"?requestIdleCallback(()=>{requestAnimationFrame(()=>{requestAnimationFrame(e)})},{timeout:3e3}):setTimeout(e,300)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()})(async()=>{let t=()=>{};try{let r=c&&(n.config||n.apiUrl||n.clientToken);if(r){let{target:e,widgetConfig:r}=v();if((e=>!(!w||!l(e)||!0===(e.launcher??{}).autoExpand||"function"==typeof e.onStateLoaded||(e=>{let t=e.persistState;if(!t)return!1;let r="object"==typeof t?t:null;if(r&&!1===r.persist?.openState)return!1;let n=r&&r.keyPrefix||"persona-",o=r&&r.storage||"session";try{return"true"===("local"===o?window.localStorage:window.sessionStorage).getItem(`${n}widget-open`)}catch{return!1}})(e)))(r))try{if(await Promise.all([y(),m(w,!!window.AgentWidgetLauncher)]),window.AgentWidgetLauncher?.mount)return void A(e,r)}catch(t){console.warn("Launcher failed; loading widget.",t)}}if(r){let{target:r,widgetConfig:o}=v();!1===o.launcher?.enabled&&(t=e("string"==typeof r?document.querySelector(r):r,!1,n.renderLoading))}try{await y()}catch(t){return i("css",t)}try{await b()}catch(t){return i("bundle",t)}r&&await U(!1)}catch(t){i("init",t)}finally{t()}})}()}();
|
|
2
2
|
//# sourceMappingURL=install.global.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["delayInstallLoading","e","t","n","indicator","cleanup","position","target","style","busy","getAttribute","positioned","timer","setTimeout","isConnected","getComputedStyle","s","setAttribute","r","ownerDocument","createElement","cssText","append","render","i","container","kind","launcher","error","console","warn","replaceChildren","clearTimeout","element","remove","removeAttribute","window","__siteAgentInstallerLoaded","scriptConfig","script","document","currentScript","configJson","normalizedJson","replace","parsedConfig","JSON","parse","config","__proto__","_a","constructor","_b","prototype","_c","safeConfig","Object","assign","key","attribute","value","installerSrc","src","siteAgentConfig","safeCall","fn","arg","dispatchLifecycle","dispatchEvent","CustomEvent","name","detail","fail","onError","phase","hasFloatingLauncher","widgetConfig","enabled","mountMode","onScriptLoad","version","previewQueryParam","URLSearchParams","location","search","get","toLowerCase","cdn","autoInit","getInstallerBase","url","URL","baseURI","protocol","origin","pathname","slice","lastIndexOf","assetUrls","cssUrl","base","jsUrl","launcherUrl","m","h","g","derivedLauncherUrl","selfBase","selfOrigin","packageName","isJsLoaded","AgentWidget","loadAsset","Promise","loaded","resolve","node","css","rel","href","async","a","onload","onerror","reject","Error","head","appendChild","loadCSS","querySelector","loadJS","buildWidgetInit","initWidget","initAgentWidget","handle","keys","length","postprocessMessage","markdownPostprocessor","text","useShadowDom","windowKey","ready","openAfter","open","onLauncherShown","deferred","onChatReady","destroy","mountDeferredLauncher","launcherHandle","mounted","AgentWidgetLauncher","mount","onOpen","errorPhase","stopLoading","renderLoading","then","catch","c","prefetchFullBundle","addPrefetch","urls","chunk","push","link","as","requestIdleCallback","timeout","afterDom","requestAnimationFrame","callback","readyState","addEventListener","once","waitForHydration","shouldAutoInit","apiUrl","clientToken","autoExpand","onStateLoaded","persistState","asObject","persist","openState","keyPrefix","storageType","storage","localStorage","sessionStorage","getItem","hasPersistedOpenState","shouldDeferPanel","all"],"sources":["../src/utils/install-loading.ts","../src/install.ts","../src/utils/cdn-release.ts"],"sourcesContent":["import type { InstallLoadingRenderer } from \"../types/install-loading\";\n\n/** Installer feedback must work before widget.css or the main bundle arrives.\n * It occupies no layout space and never replaces the launcher's content. */\nexport const delayInstallLoading = (target: HTMLElement | null, launcher = false, render?: InstallLoadingRenderer) => {\n let indicator: HTMLElement | undefined;\n let cleanup: void | (() => void);\n const position = target?.style.position ?? \"\";\n const busy = target?.getAttribute(\"aria-busy\");\n let positioned = false;\n const timer = setTimeout(() => {\n if (!target?.isConnected) return;\n if (getComputedStyle(target).position === \"static\") {\n target.style.position = \"relative\";\n positioned = true;\n }\n target.setAttribute(\"aria-busy\", \"true\");\n indicator = target.ownerDocument.createElement(\"span\");\n indicator.setAttribute(\"data-persona-loading\", \"\");\n indicator.setAttribute(\"role\", \"status\");\n indicator.setAttribute(\"aria-label\", \"Loading assistant\");\n indicator.style.cssText = \"position:absolute;inset:0;display:grid;place-items:center;pointer-events:none\";\n target.append(indicator);\n if (render) {\n try {\n cleanup = render({ container: indicator, target, kind: launcher ? \"launcher\" : \"embedded\" });\n return;\n } catch (error) {\n console.warn(\"Loading hook failed:\", error);\n indicator.replaceChildren();\n }\n }\n indicator.setAttribute(\"data-persona-loading\", \"default\");\n // Inline geometry keeps the same ring visible even while CSS is loading.\n // The stylesheet only adds motion (and respects reduced-motion settings).\n indicator.style.cssText = `position:absolute;pointer-events:none;box-sizing:border-box;width:14px;height:14px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;${launcher ? \"bottom:8px;right:8px\" : \"top:50%;left:50%;margin:-7px;color:var(--persona-text,currentColor)\"}`;\n target.append(indicator);\n }, 300);\n return () => {\n clearTimeout(timer);\n if (!indicator || !target) return;\n const element = indicator;\n indicator = undefined;\n try { cleanup?.(); } catch (error) { console.warn(\"Loading hook failed:\", error); }\n element.remove();\n if (busy == null) target.removeAttribute(\"aria-busy\");\n else target.setAttribute(\"aria-busy\", busy);\n if (positioned && target.style.position === \"relative\") target.style.position = position;\n };\n};\n","/**\n * Standalone installer script for easy script tag installation\n * This script automatically loads CSS and JS, then initializes the widget\n * if configuration is provided via window.siteAgentConfig\n */\n\nimport { pinCdnRelease } from \"./utils/cdn-release\";\n\nimport type { BrandConfig } from \"./types/theme\";\nimport { delayInstallLoading } from \"./utils/install-loading\";\nimport type { InstallLoadingRenderer } from \"./types/install-loading\";\n\ninterface SiteAgentInstallConfig {\n // Setting `cdn` explicitly opts into npm-CDN asset URLs (jsDelivr/unpkg),\n // and `version` pins the asset version. When neither is set, assets load\n // from the directory the installer script itself was served from. On the\n // first-party CDN (cdn.runtype.com) a `version` stays first-party\n // (…/persona/<version>/); elsewhere it opts into npm-CDN URLs. Prefer\n // pinning via the installer script URL itself — see getCdnBase().\n version?: string;\n cdn?: \"unpkg\" | \"jsdelivr\";\n cssUrl?: string;\n jsUrl?: string;\n target?: string | HTMLElement;\n config?: any;\n /** Opt in to the staged v5 defaults when using top-level installer options. */\n future?: { v5Defaults?: boolean };\n brand?: BrandConfig;\n autoInit?: boolean;\n // Client token mode options (can also be set via data attributes)\n clientToken?: string;\n flowId?: string;\n agentId?: string;\n apiUrl?: string;\n // Optional query param key that gates widget installation in preview mode\n previewQueryParam?: string;\n // Shadow DOM option (defaults to false for better CSS compatibility)\n useShadowDom?: boolean;\n // Expose the widget handle on window[windowKey] for programmatic access\n windowKey?: string;\n /** Replace the delayed loading ring. Persona owns timing and cleanup. */\n renderLoading?: InstallLoadingRenderer;\n /**\n * Fired as soon as the installer script executes, before it loads or gates\n * anything. For diagnostics / load-timing baselines (\"did my embed run\").\n */\n onScriptLoad?: (info: { version: string }) => void;\n /**\n * Fired when the floating launcher is painted on the page: at page-load time.\n * Deferred installs: the critical launcher mounts. Eager floating installs:\n * the full widget's launcher mounts. Use this for \"widget appeared\" analytics.\n * Does NOT fire for inline / docked / composer-bar installs (no floating\n * launcher): use `onChatReady` there.\n */\n onLauncherShown?: (info: { deferred: boolean; element?: HTMLElement }) => void;\n /**\n * Fired when the full widget is initialized and its controller API is\n * callable. Deferred installs: after the user first opens the panel. Eager\n * installs: on page load.\n */\n onChatReady?: (handle: any) => void;\n /**\n * Fired when a load step fails (stylesheet, full bundle, or init), so you can\n * detect ad-blocked / timed-out installs instead of failing silently.\n */\n onError?: (info: { phase: \"css\" | \"bundle\" | \"init\"; error: unknown }) => void;\n}\n\ndeclare global {\n interface Window {\n siteAgentConfig?: SiteAgentInstallConfig;\n AgentWidget?: any;\n AgentWidgetLauncher?: any;\n }\n}\n\n(function() {\n \"use strict\";\n\n // Prevent double installation\n if ((window as any).__siteAgentInstallerLoaded) {\n return;\n }\n (window as any).__siteAgentInstallerLoaded = true;\n\n /**\n * Read configuration from data attributes on the current script tag.\n * Supports: data-config (JSON), data-runtype-token, data-flow-id, data-agent-id, data-api-url\n */\n const getConfigFromScript = (): Partial<SiteAgentInstallConfig> => {\n // Try to get the current script element\n const script = document.currentScript as HTMLScriptElement | null;\n if (!script) return {};\n\n const scriptConfig: Partial<SiteAgentInstallConfig> = {};\n\n // Full config from data-config attribute (JSON string)\n const configJson = script.getAttribute('data-config');\n if (configJson) {\n try {\n // HTML attributes preserve literal newlines/tabs which are invalid\n // control characters inside JSON string literals: strip them.\n const normalizedJson = configJson.replace(/[\\r\\n]+\\s*/g, '');\n const parsedConfig = JSON.parse(normalizedJson);\n // If it has nested 'config' property, use it; otherwise treat as widget config\n if (parsedConfig.config) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { __proto__: _a, constructor: _b, prototype: _c, ...safeConfig } = parsedConfig;\n Object.assign(scriptConfig, safeConfig);\n } else {\n // Treat the entire object as widget config\n scriptConfig.config = parsedConfig;\n }\n } catch (e) {\n console.error(\"Invalid data-config JSON:\", e);\n }\n }\n\n for (const [key, attribute] of [\n [\"clientToken\", \"runtype-token\"], [\"flowId\", \"flow-id\"],\n [\"agentId\", \"agent-id\"], [\"apiUrl\", \"api-url\"],\n [\"previewQueryParam\", \"preview-param\"],\n ] as const) {\n const value = script.getAttribute(`data-${attribute}`);\n if (value) scriptConfig[key] = value;\n }\n\n return scriptConfig;\n };\n\n // Get config from script attributes (must be called synchronously during script execution)\n const scriptConfig = getConfigFromScript();\n\n // The installer's own URL, captured now because document.currentScript is\n // null once synchronous execution ends (and always inside modules).\n const installerSrc = (document.currentScript as HTMLScriptElement | null)?.src || \"\";\n\n // Merge script attributes with window config (script attributes take precedence)\n const windowConfig: SiteAgentInstallConfig = window.siteAgentConfig || {};\n const config: SiteAgentInstallConfig = { ...windowConfig, ...scriptConfig };\n\n // --- Lifecycle helpers -----------------------------------------------------\n // A throwing user callback must never break the installer.\n const safeCall = <T>(fn: ((arg: T) => void) | undefined, arg: T): void => {\n try {\n fn?.(arg);\n } catch (e) {\n console.error(\"Lifecycle callback failed:\", e);\n }\n };\n const dispatchLifecycle = (name: string, detail: unknown): void => {\n try {\n window.dispatchEvent(new CustomEvent(name, { detail }));\n } catch {\n /* CustomEvent unsupported: ignore */\n }\n };\n const fail = (phase: \"css\" | \"bundle\" | \"init\", error: unknown): void => {\n console.error(\"Widget install failed:\", error);\n safeCall(config.onError, { phase, error });\n dispatchLifecycle(\"persona:error\", { phase, error });\n };\n // True when the config renders a standard floating launcher button: the only\n // case that paints a clickable launcher at load. Shared by the deferral gate\n // and the eager-path `onLauncherShown` so the event name stays honest.\n const hasFloatingLauncher = (widgetConfig: any): boolean => {\n const launcher = widgetConfig.launcher ?? {};\n if (launcher.enabled === false) return false; // inline embed\n return (launcher.mountMode ?? \"floating\") === \"floating\"; // not docked / composer-bar\n };\n\n // Earliest signal: the installer has executed. Fire before any loading or\n // preview-gating so it's a reliable \"did my embed run\" beacon for diagnostics.\n safeCall(config.onScriptLoad, { version: config.version || \"latest\" });\n dispatchLifecycle(\"persona:script-load\", { version: config.version || \"latest\" });\n\n const isPreviewModeEnabled = (): boolean => {\n if (!config.previewQueryParam) {\n return true;\n }\n\n const params = new URLSearchParams(window.location.search);\n const value = params.get(config.previewQueryParam);\n return value !== null && value !== \"\" && value.toLowerCase() !== \"false\" && value !== \"0\";\n };\n\n if (!isPreviewModeEnabled()) {\n return;\n }\n \n const version = config.version || \"latest\";\n const cdn = config.cdn || \"jsdelivr\";\n const autoInit = config.autoInit !== false; // Default to true\n\n // Directory the installer itself was served from. Every published layout\n // (npm CDN dist/, first-party CDN, self-hosted copies) keeps the sibling\n // assets next to install.global.js, so this base is valid wherever the\n // installer loaded from — and always satisfies the same CSP/origin rules\n // that let the installer through. Non-http(s) sources (inline, blob:) and\n // module contexts (no currentScript) yield null.\n const getInstallerBase = (): string | null => {\n if (!installerSrc) return null;\n try {\n const url = new URL(pinCdnRelease(installerSrc), document.baseURI);\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return null;\n return url.origin + url.pathname.slice(0, url.pathname.lastIndexOf(\"/\"));\n } catch {\n return null;\n }\n };\n\n // Determine CDN base URL. Precedence:\n // 1. explicit cssUrl + jsUrl\n // 2. explicit `cdn` / `version` → npm CDN construction\n // 3. the installer's own directory (default)\n // 4. npm CDN construction (currentScript unavailable)\n const assetUrls = (base: string) => ({\n cssUrl: `${base}/widget.css`,\n jsUrl: `${base}/index.global.js`,\n launcherUrl: `${base}/launcher.global.js`,\n });\n const getCdnBase = () => {\n // For a custom URL override, derive the sibling launcher URL when the\n // override mirrors the dist layout (…/index.global.js → …/launcher.global.js)\n // so self-hosted deployments still get the optimization. A non-standard\n // jsUrl yields null → eager-load fallback.\n if (config.cssUrl && config.jsUrl) {\n const derivedLauncherUrl = config.jsUrl.replace(/index\\.global\\.js($|\\?)/, \"launcher.global.js$1\");\n return {\n cssUrl: config.cssUrl,\n jsUrl: config.jsUrl,\n launcherUrl: (derivedLauncherUrl !== config.jsUrl ? derivedLauncherUrl : null) as string | null,\n };\n }\n\n // Default: load assets from wherever the installer was served, so a page\n // whose CSP allows only its own CDN (e.g. cdn.runtype.com) never has\n // sibling requests fan out to a third-party host. An explicit `cdn`\n // keeps the documented npm-CDN behavior.\n if (!config.cdn) {\n const selfBase = getInstallerBase();\n if (selfBase) {\n if (!config.version) {\n return assetUrls(selfBase);\n }\n // A `version` on the first-party CDN stays first-party: the bucket\n // mirrors every release at /persona/<version>/, and rerouting to a\n // npm CDN would be blocked by the CSP that allowed the installer.\n const selfOrigin = new URL(selfBase).origin;\n if (selfOrigin === \"https://cdn.runtype.com\") {\n return assetUrls(`${selfOrigin}/persona/${config.version}`);\n }\n }\n }\n\n const packageName = \"@runtypelabs/persona\";\n // jsDelivr namespaces npm packages under /npm/; unpkg serves them at the root.\n const basePath = cdn === \"unpkg\"\n ? `/${packageName}@${version}/dist`\n : `/npm/${packageName}@${version}/dist`;\n const host = cdn === \"unpkg\" ? \"https://unpkg.com\" : \"https://cdn.jsdelivr.net\";\n\n return assetUrls(`${host}${basePath}`);\n };\n\n const { cssUrl, jsUrl, launcherUrl } = getCdnBase();\n\n // Surface silent CSP breakage: when `cdn`/`version` reroutes assets to a\n // different origin than the one that served the installer, a strict CSP\n // (e.g. Runtype-hosted apps) blocks them with no visible error. Explicit\n // cssUrl/jsUrl overrides are a deliberate choice, so they don't warn.\n if (!(config.cssUrl && config.jsUrl)) {\n const selfBase = getInstallerBase();\n try {\n if (selfBase && new URL(selfBase).origin !== new URL(jsUrl, document.baseURI).origin) {\n console.warn(\n `${jsUrl}: strict CSP may silently block cross-origin assets; pin the installer URL.`,\n );\n }\n } catch {\n // URL parsing is best-effort; never let diagnostics break installation.\n }\n }\n\n // Check if CSS is already loaded\n const isCssLoaded = () => {\n return !!document.head.querySelector('link[data-persona],link[href*=\"widget.css\"]');\n };\n\n // Check if JS is already loaded\n const isJsLoaded = () => {\n return !!(window as any).AgentWidget;\n };\n\n /**\n * Wait for framework hydration to complete (Next.js, Nuxt, etc.)\n * This prevents the framework from removing dynamically added CSS during reconciliation.\n * Uses requestIdleCallback + double requestAnimationFrame for reliable detection.\n */\n const waitForHydration = (callback: () => void): void => {\n const afterDom = () => {\n // Strategy 1: Use requestIdleCallback if available (best for detecting idle after hydration)\n if (typeof requestIdleCallback !== 'undefined') {\n requestIdleCallback(() => {\n // Double requestAnimationFrame ensures at least one full paint cycle completed\n requestAnimationFrame(() => {\n requestAnimationFrame(callback);\n });\n }, { timeout: 3000 }); // Max wait 3 seconds, then proceed anyway\n } else {\n // Strategy 2: Fallback for Safari (no requestIdleCallback)\n // 300ms is typically enough for hydration on most pages\n setTimeout(callback, 300);\n }\n };\n\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', afterDom, { once: true });\n } else {\n // DOM already ready, but still wait for potential hydration\n afterDom();\n }\n };\n\n // Stylesheet and script requests share lifecycle and failure handling.\n const loadAsset = (url: string | null, loaded: boolean, css = false): Promise<void> => {\n return new Promise((resolve, reject) => {\n if (loaded || !url) { resolve(); return; }\n const node = document.createElement(css ? \"link\" : \"script\");\n Object.assign(node, css ? { rel: \"stylesheet\", href: url } : { src: url, async: true });\n if (css) node.setAttribute(\"data-persona\", \"true\");\n node.onload = () => resolve();\n node.onerror = () => reject(new Error(`Failed to load ${url}`));\n document.head.appendChild(node);\n });\n };\n const loadCSS = () => loadAsset(cssUrl, isCssLoaded(), true);\n const loadJS = () => loadAsset(jsUrl, isJsLoaded());\n const loadLauncher = () => loadAsset(launcherUrl, !!window.AgentWidgetLauncher);\n\n // Warm the full bundle in the background (download-only, not executed) so the\n // first open is quick. Runs at idle so it never competes with the launcher.\n const prefetchFullBundle = (): void => {\n const addPrefetch = () => {\n const urls = isJsLoaded() ? [] : [jsUrl];\n for (const chunk of [\"markdown-parsers.js\", \"client-stream.js\"]) {\n const url = jsUrl.replace(/index\\.global\\.js($|\\?)/, `${chunk}$1`);\n if (url !== jsUrl) urls.push(url);\n }\n for (const href of urls) {\n const link = document.createElement(\"link\");\n Object.assign(link, { rel: \"prefetch\", as: \"script\", href });\n document.head.appendChild(link);\n }\n };\n if (typeof requestIdleCallback !== \"undefined\") {\n requestIdleCallback(addPrefetch, { timeout: 4000 });\n } else {\n setTimeout(addPrefetch, 1200);\n }\n };\n\n // Merge top-level installer options into the widget config. Shared by the\n // eager init path and the deferred-launcher path.\n const buildWidgetInit = (): { target: string | HTMLElement; widgetConfig: any } => {\n const target = config.target || \"body\";\n const widgetConfig: any = { ...config.config };\n\n for (const key of [\"apiUrl\", \"clientToken\", \"flowId\", \"agentId\", \"future\", \"brand\"] as const) {\n if (config[key] && !widgetConfig[key]) widgetConfig[key] = config[key];\n }\n\n return { target, widgetConfig };\n };\n\n // Initialize the full widget. When `openAfter` is true (the deferred-launcher\n // handoff), open the panel immediately via the public controller API so the\n // user's click on the critical launcher carries through.\n const initWidget = async (openAfter = false): Promise<any> => {\n if (!window.AgentWidget?.initAgentWidget) throw new Error(\"Widget unavailable\");\n\n const { target, widgetConfig } = buildWidgetInit();\n\n // Only initialize if we have either apiUrl OR clientToken (or other config)\n if (Object.keys(widgetConfig).length === 0) {\n return;\n }\n\n // Auto-apply markdown postprocessor if not explicitly set and available\n if (!widgetConfig.postprocessMessage && window.AgentWidget.markdownPostprocessor) {\n widgetConfig.postprocessMessage = ({ text }: { text: string }) =>\n window.AgentWidget.markdownPostprocessor(text);\n }\n\n let handle: any;\n try {\n handle = window.AgentWidget.initAgentWidget({\n target,\n config: widgetConfig,\n // Explicitly disable shadow DOM for better CSS compatibility with host page\n useShadowDom: config.useShadowDom ?? false,\n windowKey: config.windowKey\n });\n\n await handle?.ready;\n\n // Handoff from the critical launcher: the user already clicked, so open\n // the panel via the existing public controller method.\n if (openAfter) handle?.open?.();\n\n // Eager floating installs paint their launcher at load time too: emit the\n // same page-load \"appeared\" signal as the deferred path. The deferred\n // handoff (openAfter) already fired it at launcher mount, and non-floating\n // modes have no launcher, so guard on both.\n if (!openAfter && hasFloatingLauncher(widgetConfig)) {\n safeCall(config.onLauncherShown, { deferred: false });\n dispatchLifecycle(\"persona:launcher-shown\", { deferred: false });\n }\n\n // The full widget is initialized and its controller API is callable.\n safeCall(config.onChatReady, handle);\n dispatchLifecycle(\"persona:chat-ready\", handle);\n return handle;\n } catch (error) {\n handle?.destroy?.();\n throw error;\n }\n };\n\n // A persisted \"open\" state reopens the panel on reload with no click\n // (ui.ts:7513). The installer can't see that from config, so it reads the very\n // same storage key the widget writes. Mirrors normalizePersistStateConfig\n // (ui.ts:213): openState persistence defaults on, storage to sessionStorage,\n // key prefix to \"persona-\".\n const hasPersistedOpenState = (widgetConfig: any): boolean => {\n const persistState = widgetConfig.persistState;\n if (!persistState) return false; // persistence off → nothing to restore\n const asObject = typeof persistState === \"object\" ? persistState : null;\n if (asObject && asObject.persist?.openState === false) return false; // open-state persistence opted out\n const keyPrefix = (asObject && asObject.keyPrefix) || \"persona-\";\n const storageType = (asObject && asObject.storage) || \"session\";\n try {\n const storage = storageType === \"local\" ? window.localStorage : window.sessionStorage;\n return storage.getItem(`${keyPrefix}widget-open`) === \"true\";\n } catch {\n return false; // storage blocked (private mode) → the widget can't restore either\n }\n };\n\n // The deferred-launcher optimization only applies to the common floating case\n // that paints a collapsed launcher and waits for a click. Anything that starts\n // open or renders differently eager-loads the full bundle exactly as before: // including the two open triggers config alone can't express: a host\n // onStateLoaded hook that may request open, and a restored \"was open\" state.\n const shouldDeferPanel = (widgetConfig: any): boolean => {\n if (!launcherUrl) return false; // custom bundle URL override: can't derive launcher URL\n if (!hasFloatingLauncher(widgetConfig)) return false; // inline / docked / composer-bar\n const launcher = widgetConfig.launcher ?? {};\n if (launcher.autoExpand === true) return false; // starts open\n if (typeof widgetConfig.onStateLoaded === \"function\") return false; // hook may request open\n if (hasPersistedOpenState(widgetConfig)) return false; // restored \"was open\"\n return true;\n };\n\n // Render the real launcher from the tiny critical bundle; load + mount the\n // full widget on first click, then remove the critical launcher.\n const mountDeferredLauncher = (target: string | HTMLElement, widgetConfig: any): void => {\n let phase: \"idle\" | \"loading\" | \"done\" = \"idle\";\n let launcherHandle: { destroy: () => void; element: HTMLButtonElement } | undefined;\n\n const onOpen = () => {\n if (phase !== \"idle\") return; // already loading or handed off\n phase = \"loading\";\n let errorPhase: \"bundle\" | \"init\" = \"bundle\";\n const stopLoading = delayInstallLoading(launcherHandle?.element ?? null, true, config.renderLoading);\n loadJS()\n .then(async () => {\n errorPhase = \"init\";\n await initWidget(true); // keep the critical launcher until the panel is complete\n stopLoading();\n launcherHandle?.destroy(); // remove the critical launcher (same component → invisible)\n phase = \"done\";\n })\n .catch((error) => {\n stopLoading();\n phase = \"idle\"; // allow the click to be retried\n fail(errorPhase, error);\n });\n };\n\n const mounted = window.AgentWidgetLauncher.mount({ target, config: widgetConfig, onOpen });\n launcherHandle = mounted;\n\n // The real launcher is now painted at page-load time: emit the page-load\n // \"appeared\" signal (distinct from `onChatReady`, which waits for first open).\n safeCall(config.onLauncherShown, { deferred: true, element: mounted.element });\n dispatchLifecycle(\"persona:launcher-shown\", { deferred: true, element: mounted.element });\n\n // Warm the full bundle so the first open is quick.\n prefetchFullBundle();\n };\n\n // Main installation flow (called after hydration completes)\n const install = async () => {\n let stopLoading = () => {};\n try {\n // Auto-init if we have config OR apiUrl OR clientToken\n const shouldAutoInit = autoInit && (\n config.config ||\n config.apiUrl ||\n config.clientToken\n );\n\n // Fast path: render the real launcher from the ~13 KB critical bundle and\n // defer the full widget until first open. Only for the common floating\n // case; everything else falls through to the eager path below.\n if (shouldAutoInit) {\n const { target, widgetConfig } = buildWidgetInit();\n if (shouldDeferPanel(widgetConfig)) {\n try {\n // CSS + launcher in parallel so the launcher paints correctly styled.\n await Promise.all([loadCSS(), loadLauncher()]);\n if (window.AgentWidgetLauncher?.mount) {\n mountDeferredLauncher(target, widgetConfig);\n return;\n }\n } catch (error) {\n console.warn(\"Launcher failed; loading widget.\", error);\n }\n // Fall through to the eager path on any failure.\n }\n }\n\n // Only an actual visible embedded surface needs initial feedback. A\n // collapsed floating launcher must not put a spinner over the host page.\n if (shouldAutoInit) {\n const { target, widgetConfig } = buildWidgetInit();\n if (widgetConfig.launcher?.enabled === false) {\n stopLoading = delayInstallLoading(typeof target === \"string\" ? document.querySelector(target) : target, false, config.renderLoading);\n }\n }\n // Eager path: retain feedback through all renderer/style preparation.\n try {\n await loadCSS();\n } catch (error) {\n return fail(\"css\", error);\n }\n try {\n await loadJS();\n } catch (error) {\n return fail(\"bundle\", error);\n }\n if (shouldAutoInit) {\n await initWidget(false);\n }\n } catch (error) {\n // Safety net for anything unexpected before the eager loads above.\n fail(\"init\", error);\n } finally {\n stopLoading();\n }\n };\n\n // Start installation after hydration completes\n // This prevents Next.js/Nuxt/etc. from removing dynamically added CSS\n waitForHydration(install);\n})();\n","import { version } from \"../../package.json\";\n\n/**\n * A cached /latest/ entry must keep using its own release, even after another\n * release replaces latest. Only rewrite our published CDN layout; custom hosts\n * and explicitly versioned URLs retain their existing sibling resolution.\n * The bundler embeds this package version in each script-tag entry.\n */\nexport function pinCdnRelease(src: string): string {\n return src.replace(\n /^https:\\/\\/cdn\\.runtype\\.com\\/persona\\/latest\\//,\n `https://cdn.runtype.com/persona/${version}/`,\n );\n}\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BvJ,OAAOyJ,aAAezJ,OAAO0J,gBACxDC,QAAQ,GAAGL,eAC5B,OACE,OAAO,CACT,GAaIM,CAAsBpH,IA0DlBqH,CAAiBrH,GACnB,IAGE,SADMqC,QAAQiF,IAAI,CAAClE,IAtLFhB,EAAUV,IAAelE,OAAOoH,uBAuL7CpH,OAAOoH,qBAAqBC,MAE9B,YADAJ,EAAsB9I,EAAQqE,EAGlC,OAAShD,GACPC,QAAQC,KAAK,mCAAoCF,EACnD,CAGJ,CAIA,GAAIqJ,EAAgB,CAClB,IAAQ1K,OAAAJ,EAAQyE,aAAA1D,GAAiBiH,KACM,IAAnCvD,EAAajD,UAAUkD,UACzB5E,EAAcD,EAAsC,iBAAXO,EAAsBiC,SAASyF,cAAc1H,GAAUA,GAAQ,EAAOyC,EAAO6G,eAE1H,CAEA,UACQ7B,GACR,OAASpG,GACP,OAAO4C,EAAK,MAAO5C,EACrB,CACA,UACQsG,GACR,OAAStG,GACP,OAAO4C,EAAK,SAAU5C,EACxB,CACIqJ,SACI7C,GAAW,EAErB,OAASxG,GAEP4C,EAAK,OAAQ5C,EACf,SACEgI,GACF,GAMJ,CDpgBA,ECogBG,C","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["delayInstallLoading","e","t","n","indicator","cleanup","position","target","style","busy","getAttribute","positioned","timer","setTimeout","isConnected","getComputedStyle","s","setAttribute","r","ownerDocument","createElement","cssText","append","render","i","container","kind","launcher","error","console","warn","replaceChildren","clearTimeout","element","remove","removeAttribute","window","__siteAgentInstallerLoaded","scriptConfig","script","document","currentScript","configJson","normalizedJson","replace","parsedConfig","JSON","parse","config","__proto__","_a","constructor","_b","prototype","_c","safeConfig","Object","assign","key","attribute","value","installerSrc","src","siteAgentConfig","safeCall","fn","arg","dispatchLifecycle","dispatchEvent","CustomEvent","name","detail","fail","onError","phase","hasFloatingLauncher","widgetConfig","enabled","mountMode","onScriptLoad","version","previewQueryParam","URLSearchParams","location","search","get","toLowerCase","cdn","autoInit","getInstallerBase","url","URL","baseURI","protocol","origin","pathname","slice","lastIndexOf","assetUrls","cssUrl","base","jsUrl","launcherUrl","m","h","g","derivedLauncherUrl","selfBase","selfOrigin","packageName","isJsLoaded","AgentWidget","loadAsset","Promise","loaded","resolve","node","css","rel","href","async","a","onload","onerror","reject","Error","head","appendChild","loadCSS","querySelector","loadJS","buildWidgetInit","initWidget","initAgentWidget","handle","keys","length","postprocessMessage","markdownPostprocessor","text","useShadowDom","windowKey","ready","openAfter","open","onLauncherShown","deferred","onChatReady","destroy","mountDeferredLauncher","launcherHandle","mounted","AgentWidgetLauncher","mount","onOpen","errorPhase","stopLoading","renderLoading","then","catch","c","prefetchFullBundle","addPrefetch","urls","chunk","push","link","as","requestIdleCallback","timeout","afterDom","requestAnimationFrame","callback","readyState","addEventListener","once","waitForHydration","shouldAutoInit","apiUrl","clientToken","autoExpand","onStateLoaded","persistState","asObject","persist","openState","keyPrefix","storageType","storage","localStorage","sessionStorage","getItem","hasPersistedOpenState","shouldDeferPanel","all"],"sources":["../src/utils/install-loading.ts","../src/install.ts","../src/utils/cdn-release.ts"],"sourcesContent":["import type { InstallLoadingRenderer } from \"../types/install-loading\";\n\n/** Installer feedback must work before widget.css or the main bundle arrives.\n * It occupies no layout space and never replaces the launcher's content. */\nexport const delayInstallLoading = (target: HTMLElement | null, launcher = false, render?: InstallLoadingRenderer) => {\n let indicator: HTMLElement | undefined;\n let cleanup: void | (() => void);\n const position = target?.style.position ?? \"\";\n const busy = target?.getAttribute(\"aria-busy\");\n let positioned = false;\n const timer = setTimeout(() => {\n if (!target?.isConnected) return;\n if (getComputedStyle(target).position === \"static\") {\n target.style.position = \"relative\";\n positioned = true;\n }\n target.setAttribute(\"aria-busy\", \"true\");\n indicator = target.ownerDocument.createElement(\"span\");\n indicator.setAttribute(\"data-persona-loading\", \"\");\n indicator.setAttribute(\"role\", \"status\");\n indicator.setAttribute(\"aria-label\", \"Loading assistant\");\n indicator.style.cssText = \"position:absolute;inset:0;display:grid;place-items:center;pointer-events:none\";\n target.append(indicator);\n if (render) {\n try {\n cleanup = render({ container: indicator, target, kind: launcher ? \"launcher\" : \"embedded\" });\n return;\n } catch (error) {\n console.warn(\"Loading hook failed:\", error);\n indicator.replaceChildren();\n }\n }\n indicator.setAttribute(\"data-persona-loading\", \"default\");\n // Inline geometry keeps the same ring visible even while CSS is loading.\n // The stylesheet only adds motion (and respects reduced-motion settings).\n indicator.style.cssText = `position:absolute;pointer-events:none;box-sizing:border-box;width:14px;height:14px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;${launcher ? \"bottom:8px;right:8px\" : \"top:50%;left:50%;margin:-7px;color:var(--persona-text,currentColor)\"}`;\n target.append(indicator);\n }, 300);\n return () => {\n clearTimeout(timer);\n if (!indicator || !target) return;\n const element = indicator;\n indicator = undefined;\n try { cleanup?.(); } catch (error) { console.warn(\"Loading hook failed:\", error); }\n element.remove();\n if (busy == null) target.removeAttribute(\"aria-busy\");\n else target.setAttribute(\"aria-busy\", busy);\n if (positioned && target.style.position === \"relative\") target.style.position = position;\n };\n};\n","/**\n * Standalone installer script for easy script tag installation\n * This script automatically loads CSS and JS, then initializes the widget\n * if configuration is provided via window.siteAgentConfig\n */\n\nimport { pinCdnRelease } from \"./utils/cdn-release\";\n\nimport type { BrandConfig } from \"./types/theme\";\nimport { delayInstallLoading } from \"./utils/install-loading\";\nimport type { InstallLoadingRenderer } from \"./types/install-loading\";\n\ninterface SiteAgentInstallConfig {\n // Setting `cdn` explicitly opts into npm-CDN asset URLs (jsDelivr/unpkg),\n // and `version` pins the asset version. When neither is set, assets load\n // from the directory the installer script itself was served from. On the\n // first-party CDN (cdn.runtype.com) a `version` stays first-party\n // (…/persona/<version>/); elsewhere it opts into npm-CDN URLs. Prefer\n // pinning via the installer script URL itself — see getCdnBase().\n version?: string;\n cdn?: \"unpkg\" | \"jsdelivr\";\n cssUrl?: string;\n jsUrl?: string;\n target?: string | HTMLElement;\n config?: any;\n /** Opt in to the staged v5 defaults when using top-level installer options. */\n future?: { v5Defaults?: boolean };\n brand?: BrandConfig;\n autoInit?: boolean;\n // Client token mode options (can also be set via data attributes)\n clientToken?: string;\n flowId?: string;\n agentId?: string;\n apiUrl?: string;\n // Optional query param key that gates widget installation in preview mode\n previewQueryParam?: string;\n // Shadow DOM option (defaults to false for better CSS compatibility)\n useShadowDom?: boolean;\n // Expose the widget handle on window[windowKey] for programmatic access\n windowKey?: string;\n /** Replace the delayed loading ring. Persona owns timing and cleanup. */\n renderLoading?: InstallLoadingRenderer;\n /**\n * Fired as soon as the installer script executes, before it loads or gates\n * anything. For diagnostics / load-timing baselines (\"did my embed run\").\n */\n onScriptLoad?: (info: { version: string }) => void;\n /**\n * Fired when the floating launcher is painted on the page: at page-load time.\n * Deferred installs: the critical launcher mounts. Eager floating installs:\n * the full widget's launcher mounts. Use this for \"widget appeared\" analytics.\n * Does NOT fire for inline / docked / composer-bar installs (no floating\n * launcher): use `onChatReady` there.\n */\n onLauncherShown?: (info: { deferred: boolean; element?: HTMLElement }) => void;\n /**\n * Fired when the full widget is initialized and its controller API is\n * callable. Deferred installs: after the user first opens the panel. Eager\n * installs: on page load.\n */\n onChatReady?: (handle: any) => void;\n /**\n * Fired when a load step fails (stylesheet, full bundle, or init), so you can\n * detect ad-blocked / timed-out installs instead of failing silently.\n */\n onError?: (info: { phase: \"css\" | \"bundle\" | \"init\"; error: unknown }) => void;\n}\n\ndeclare global {\n interface Window {\n siteAgentConfig?: SiteAgentInstallConfig;\n AgentWidget?: any;\n AgentWidgetLauncher?: any;\n }\n}\n\n(function() {\n \"use strict\";\n\n // Prevent double installation\n if ((window as any).__siteAgentInstallerLoaded) {\n return;\n }\n (window as any).__siteAgentInstallerLoaded = true;\n\n /**\n * Read configuration from data attributes on the current script tag.\n * Supports: data-config (JSON), data-runtype-token, data-flow-id, data-agent-id, data-api-url\n */\n const getConfigFromScript = (): Partial<SiteAgentInstallConfig> => {\n // Try to get the current script element\n const script = document.currentScript as HTMLScriptElement | null;\n if (!script) return {};\n\n const scriptConfig: Partial<SiteAgentInstallConfig> = {};\n\n // Full config from data-config attribute (JSON string)\n const configJson = script.getAttribute('data-config');\n if (configJson) {\n try {\n // HTML attributes preserve literal newlines/tabs which are invalid\n // control characters inside JSON string literals: strip them.\n const normalizedJson = configJson.replace(/[\\r\\n]+\\s*/g, '');\n const parsedConfig = JSON.parse(normalizedJson);\n // If it has nested 'config' property, use it; otherwise treat as widget config\n if (parsedConfig.config) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { __proto__: _a, constructor: _b, prototype: _c, ...safeConfig } = parsedConfig;\n Object.assign(scriptConfig, safeConfig);\n } else {\n // Treat the entire object as widget config\n scriptConfig.config = parsedConfig;\n }\n } catch (e) {\n console.error(\"Invalid data-config JSON:\", e);\n }\n }\n\n for (const [key, attribute] of [\n [\"clientToken\", \"runtype-token\"], [\"flowId\", \"flow-id\"],\n [\"agentId\", \"agent-id\"], [\"apiUrl\", \"api-url\"],\n [\"previewQueryParam\", \"preview-param\"],\n ] as const) {\n const value = script.getAttribute(`data-${attribute}`);\n if (value) scriptConfig[key] = value;\n }\n\n return scriptConfig;\n };\n\n // Get config from script attributes (must be called synchronously during script execution)\n const scriptConfig = getConfigFromScript();\n\n // The installer's own URL, captured now because document.currentScript is\n // null once synchronous execution ends (and always inside modules).\n const installerSrc = (document.currentScript as HTMLScriptElement | null)?.src || \"\";\n\n // Merge script attributes with window config (script attributes take precedence)\n const windowConfig: SiteAgentInstallConfig = window.siteAgentConfig || {};\n const config: SiteAgentInstallConfig = { ...windowConfig, ...scriptConfig };\n\n // --- Lifecycle helpers -----------------------------------------------------\n // A throwing user callback must never break the installer.\n const safeCall = <T>(fn: ((arg: T) => void) | undefined, arg: T): void => {\n try {\n fn?.(arg);\n } catch (e) {\n console.error(\"Lifecycle callback failed:\", e);\n }\n };\n const dispatchLifecycle = (name: string, detail: unknown): void => {\n try {\n window.dispatchEvent(new CustomEvent(name, { detail }));\n } catch {\n /* CustomEvent unsupported: ignore */\n }\n };\n const fail = (phase: \"css\" | \"bundle\" | \"init\", error: unknown): void => {\n console.error(\"Widget install failed:\", error);\n safeCall(config.onError, { phase, error });\n dispatchLifecycle(\"persona:error\", { phase, error });\n };\n // True when the config renders a standard floating launcher button: the only\n // case that paints a clickable launcher at load. Shared by the deferral gate\n // and the eager-path `onLauncherShown` so the event name stays honest.\n const hasFloatingLauncher = (widgetConfig: any): boolean => {\n const launcher = widgetConfig.launcher ?? {};\n if (launcher.enabled === false) return false; // inline embed\n return (launcher.mountMode ?? \"floating\") === \"floating\"; // not docked / composer-bar\n };\n\n // Earliest signal: the installer has executed. Fire before any loading or\n // preview-gating so it's a reliable \"did my embed run\" beacon for diagnostics.\n safeCall(config.onScriptLoad, { version: config.version || \"latest\" });\n dispatchLifecycle(\"persona:script-load\", { version: config.version || \"latest\" });\n\n const isPreviewModeEnabled = (): boolean => {\n if (!config.previewQueryParam) {\n return true;\n }\n\n const params = new URLSearchParams(window.location.search);\n const value = params.get(config.previewQueryParam);\n return value !== null && value !== \"\" && value.toLowerCase() !== \"false\" && value !== \"0\";\n };\n\n if (!isPreviewModeEnabled()) {\n return;\n }\n \n const version = config.version || \"latest\";\n const cdn = config.cdn || \"jsdelivr\";\n const autoInit = config.autoInit !== false; // Default to true\n\n // Directory the installer itself was served from. Every published layout\n // (npm CDN dist/, first-party CDN, self-hosted copies) keeps the sibling\n // assets next to install.global.js, so this base is valid wherever the\n // installer loaded from — and always satisfies the same CSP/origin rules\n // that let the installer through. Non-http(s) sources (inline, blob:) and\n // module contexts (no currentScript) yield null.\n const getInstallerBase = (): string | null => {\n if (!installerSrc) return null;\n try {\n const url = new URL(pinCdnRelease(installerSrc), document.baseURI);\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return null;\n return url.origin + url.pathname.slice(0, url.pathname.lastIndexOf(\"/\"));\n } catch {\n return null;\n }\n };\n\n // Determine CDN base URL. Precedence:\n // 1. explicit cssUrl + jsUrl\n // 2. explicit `cdn` / `version` → npm CDN construction\n // 3. the installer's own directory (default)\n // 4. npm CDN construction (currentScript unavailable)\n const assetUrls = (base: string) => ({\n cssUrl: `${base}/widget.css`,\n jsUrl: `${base}/index.global.js`,\n launcherUrl: `${base}/launcher.global.js`,\n });\n const getCdnBase = () => {\n // For a custom URL override, derive the sibling launcher URL when the\n // override mirrors the dist layout (…/index.global.js → …/launcher.global.js)\n // so self-hosted deployments still get the optimization. A non-standard\n // jsUrl yields null → eager-load fallback.\n if (config.cssUrl && config.jsUrl) {\n const derivedLauncherUrl = config.jsUrl.replace(/index\\.global\\.js($|\\?)/, \"launcher.global.js$1\");\n return {\n cssUrl: config.cssUrl,\n jsUrl: config.jsUrl,\n launcherUrl: (derivedLauncherUrl !== config.jsUrl ? derivedLauncherUrl : null) as string | null,\n };\n }\n\n // Default: load assets from wherever the installer was served, so a page\n // whose CSP allows only its own CDN (e.g. cdn.runtype.com) never has\n // sibling requests fan out to a third-party host. An explicit `cdn`\n // keeps the documented npm-CDN behavior.\n if (!config.cdn) {\n const selfBase = getInstallerBase();\n if (selfBase) {\n if (!config.version) {\n return assetUrls(selfBase);\n }\n // A `version` on the first-party CDN stays first-party: the bucket\n // mirrors every release at /persona/<version>/, and rerouting to a\n // npm CDN would be blocked by the CSP that allowed the installer.\n const selfOrigin = new URL(selfBase).origin;\n if (selfOrigin === \"https://cdn.runtype.com\") {\n return assetUrls(`${selfOrigin}/persona/${config.version}`);\n }\n }\n }\n\n const packageName = \"@runtypelabs/persona\";\n // jsDelivr namespaces npm packages under /npm/; unpkg serves them at the root.\n const basePath = cdn === \"unpkg\"\n ? `/${packageName}@${version}/dist`\n : `/npm/${packageName}@${version}/dist`;\n const host = cdn === \"unpkg\" ? \"https://unpkg.com\" : \"https://cdn.jsdelivr.net\";\n\n return assetUrls(`${host}${basePath}`);\n };\n\n const { cssUrl, jsUrl, launcherUrl } = getCdnBase();\n\n // Surface silent CSP breakage: when `cdn`/`version` reroutes assets to a\n // different origin than the one that served the installer, a strict CSP\n // (e.g. Runtype-hosted apps) blocks them with no visible error. Explicit\n // cssUrl/jsUrl overrides are a deliberate choice, so they don't warn.\n if (!(config.cssUrl && config.jsUrl)) {\n const selfBase = getInstallerBase();\n try {\n if (selfBase && new URL(selfBase).origin !== new URL(jsUrl, document.baseURI).origin) {\n console.warn(\n `${jsUrl}: strict CSP may silently block cross-origin assets; pin the installer URL.`,\n );\n }\n } catch {\n // URL parsing is best-effort; never let diagnostics break installation.\n }\n }\n\n // Check if CSS is already loaded\n const isCssLoaded = () => {\n return !!document.head.querySelector('link[data-persona],link[href*=\"widget.css\"]');\n };\n\n // Check if JS is already loaded\n const isJsLoaded = () => {\n return !!(window as any).AgentWidget;\n };\n\n /**\n * Wait for framework hydration to complete (Next.js, Nuxt, etc.)\n * This prevents the framework from removing dynamically added CSS during reconciliation.\n * Uses requestIdleCallback + double requestAnimationFrame for reliable detection.\n */\n const waitForHydration = (callback: () => void): void => {\n const afterDom = () => {\n // Strategy 1: Use requestIdleCallback if available (best for detecting idle after hydration)\n if (typeof requestIdleCallback !== 'undefined') {\n requestIdleCallback(() => {\n // Double requestAnimationFrame ensures at least one full paint cycle completed\n requestAnimationFrame(() => {\n requestAnimationFrame(callback);\n });\n }, { timeout: 3000 }); // Max wait 3 seconds, then proceed anyway\n } else {\n // Strategy 2: Fallback for Safari (no requestIdleCallback)\n // 300ms is typically enough for hydration on most pages\n setTimeout(callback, 300);\n }\n };\n\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', afterDom, { once: true });\n } else {\n // DOM already ready, but still wait for potential hydration\n afterDom();\n }\n };\n\n // Stylesheet and script requests share lifecycle and failure handling.\n const loadAsset = (url: string | null, loaded: boolean, css = false): Promise<void> => {\n return new Promise((resolve, reject) => {\n if (loaded || !url) { resolve(); return; }\n const node = document.createElement(css ? \"link\" : \"script\");\n Object.assign(node, css ? { rel: \"stylesheet\", href: url } : { src: url, async: true });\n if (css) node.setAttribute(\"data-persona\", \"true\");\n node.onload = () => resolve();\n node.onerror = () => reject(new Error(`Failed to load ${url}`));\n document.head.appendChild(node);\n });\n };\n const loadCSS = () => loadAsset(cssUrl, isCssLoaded(), true);\n const loadJS = () => loadAsset(jsUrl, isJsLoaded());\n const loadLauncher = () => loadAsset(launcherUrl, !!window.AgentWidgetLauncher);\n\n // Warm the full bundle in the background (download-only, not executed) so the\n // first open is quick. Runs at idle so it never competes with the launcher.\n const prefetchFullBundle = (): void => {\n const addPrefetch = () => {\n const urls = isJsLoaded() ? [] : [jsUrl];\n for (const chunk of [\"markdown-parsers.js\", \"client-stream.js\"]) {\n const url = jsUrl.replace(/index\\.global\\.js($|\\?)/, `${chunk}$1`);\n if (url !== jsUrl) urls.push(url);\n }\n for (const href of urls) {\n const link = document.createElement(\"link\");\n Object.assign(link, { rel: \"prefetch\", as: \"script\", href });\n document.head.appendChild(link);\n }\n };\n if (typeof requestIdleCallback !== \"undefined\") {\n requestIdleCallback(addPrefetch, { timeout: 4000 });\n } else {\n setTimeout(addPrefetch, 1200);\n }\n };\n\n // Merge top-level installer options into the widget config. Shared by the\n // eager init path and the deferred-launcher path.\n const buildWidgetInit = (): { target: string | HTMLElement; widgetConfig: any } => {\n const target = config.target || \"body\";\n const widgetConfig: any = { ...config.config };\n\n for (const key of [\"apiUrl\", \"clientToken\", \"flowId\", \"agentId\", \"future\", \"brand\"] as const) {\n if (config[key] && !widgetConfig[key]) widgetConfig[key] = config[key];\n }\n\n return { target, widgetConfig };\n };\n\n // Initialize the full widget. When `openAfter` is true (the deferred-launcher\n // handoff), open the panel immediately via the public controller API so the\n // user's click on the critical launcher carries through.\n const initWidget = async (openAfter = false): Promise<any> => {\n if (!window.AgentWidget?.initAgentWidget) throw new Error(\"Widget unavailable\");\n\n const { target, widgetConfig } = buildWidgetInit();\n\n // Only initialize if we have either apiUrl OR clientToken (or other config)\n if (Object.keys(widgetConfig).length === 0) {\n return;\n }\n\n // Auto-apply markdown postprocessor if not explicitly set and available\n if (!widgetConfig.postprocessMessage && window.AgentWidget.markdownPostprocessor) {\n widgetConfig.postprocessMessage = ({ text }: { text: string }) =>\n window.AgentWidget.markdownPostprocessor(text);\n }\n\n let handle: any;\n try {\n handle = window.AgentWidget.initAgentWidget({\n target,\n config: widgetConfig,\n // Explicitly disable shadow DOM for better CSS compatibility with host page\n useShadowDom: config.useShadowDom ?? false,\n windowKey: config.windowKey\n });\n\n await handle?.ready;\n\n // Handoff from the critical launcher: the user already clicked, so open\n // the panel via the existing public controller method.\n if (openAfter) handle?.open?.();\n\n // Eager floating installs paint their launcher at load time too: emit the\n // same page-load \"appeared\" signal as the deferred path. The deferred\n // handoff (openAfter) already fired it at launcher mount, and non-floating\n // modes have no launcher, so guard on both.\n if (!openAfter && hasFloatingLauncher(widgetConfig)) {\n safeCall(config.onLauncherShown, { deferred: false });\n dispatchLifecycle(\"persona:launcher-shown\", { deferred: false });\n }\n\n // The full widget is initialized and its controller API is callable.\n safeCall(config.onChatReady, handle);\n dispatchLifecycle(\"persona:chat-ready\", handle);\n return handle;\n } catch (error) {\n handle?.destroy?.();\n throw error;\n }\n };\n\n // A persisted \"open\" state reopens the panel on reload with no click\n // (ui.ts:7513). The installer can't see that from config, so it reads the very\n // same storage key the widget writes. Mirrors normalizePersistStateConfig\n // (ui.ts:213): openState persistence defaults on, storage to sessionStorage,\n // key prefix to \"persona-\".\n const hasPersistedOpenState = (widgetConfig: any): boolean => {\n const persistState = widgetConfig.persistState;\n if (!persistState) return false; // persistence off → nothing to restore\n const asObject = typeof persistState === \"object\" ? persistState : null;\n if (asObject && asObject.persist?.openState === false) return false; // open-state persistence opted out\n const keyPrefix = (asObject && asObject.keyPrefix) || \"persona-\";\n const storageType = (asObject && asObject.storage) || \"session\";\n try {\n const storage = storageType === \"local\" ? window.localStorage : window.sessionStorage;\n return storage.getItem(`${keyPrefix}widget-open`) === \"true\";\n } catch {\n return false; // storage blocked (private mode) → the widget can't restore either\n }\n };\n\n // The deferred-launcher optimization only applies to the common floating case\n // that paints a collapsed launcher and waits for a click. Anything that starts\n // open or renders differently eager-loads the full bundle exactly as before: // including the two open triggers config alone can't express: a host\n // onStateLoaded hook that may request open, and a restored \"was open\" state.\n const shouldDeferPanel = (widgetConfig: any): boolean => {\n if (!launcherUrl) return false; // custom bundle URL override: can't derive launcher URL\n if (!hasFloatingLauncher(widgetConfig)) return false; // inline / docked / composer-bar\n const launcher = widgetConfig.launcher ?? {};\n if (launcher.autoExpand === true) return false; // starts open\n if (typeof widgetConfig.onStateLoaded === \"function\") return false; // hook may request open\n if (hasPersistedOpenState(widgetConfig)) return false; // restored \"was open\"\n return true;\n };\n\n // Render the real launcher from the tiny critical bundle; load + mount the\n // full widget on first click, then remove the critical launcher.\n const mountDeferredLauncher = (target: string | HTMLElement, widgetConfig: any): void => {\n let phase: \"idle\" | \"loading\" | \"done\" = \"idle\";\n let launcherHandle: { destroy: () => void; element: HTMLButtonElement } | undefined;\n\n const onOpen = () => {\n if (phase !== \"idle\") return; // already loading or handed off\n phase = \"loading\";\n let errorPhase: \"bundle\" | \"init\" = \"bundle\";\n const stopLoading = delayInstallLoading(launcherHandle?.element ?? null, true, config.renderLoading);\n loadJS()\n .then(async () => {\n errorPhase = \"init\";\n await initWidget(true); // keep the critical launcher until the panel is complete\n stopLoading();\n launcherHandle?.destroy(); // remove the critical launcher (same component → invisible)\n phase = \"done\";\n })\n .catch((error) => {\n stopLoading();\n phase = \"idle\"; // allow the click to be retried\n fail(errorPhase, error);\n });\n };\n\n const mounted = window.AgentWidgetLauncher.mount({ target, config: widgetConfig, onOpen });\n launcherHandle = mounted;\n\n // The real launcher is now painted at page-load time: emit the page-load\n // \"appeared\" signal (distinct from `onChatReady`, which waits for first open).\n safeCall(config.onLauncherShown, { deferred: true, element: mounted.element });\n dispatchLifecycle(\"persona:launcher-shown\", { deferred: true, element: mounted.element });\n\n // Warm the full bundle so the first open is quick.\n prefetchFullBundle();\n };\n\n // Main installation flow (called after hydration completes)\n const install = async () => {\n let stopLoading = () => {};\n try {\n // Auto-init if we have config OR apiUrl OR clientToken\n const shouldAutoInit = autoInit && (\n config.config ||\n config.apiUrl ||\n config.clientToken\n );\n\n // Fast path: render the real launcher from the ~13 KB critical bundle and\n // defer the full widget until first open. Only for the common floating\n // case; everything else falls through to the eager path below.\n if (shouldAutoInit) {\n const { target, widgetConfig } = buildWidgetInit();\n if (shouldDeferPanel(widgetConfig)) {\n try {\n // CSS + launcher in parallel so the launcher paints correctly styled.\n await Promise.all([loadCSS(), loadLauncher()]);\n if (window.AgentWidgetLauncher?.mount) {\n mountDeferredLauncher(target, widgetConfig);\n return;\n }\n } catch (error) {\n console.warn(\"Launcher failed; loading widget.\", error);\n }\n // Fall through to the eager path on any failure.\n }\n }\n\n // Only an actual visible embedded surface needs initial feedback. A\n // collapsed floating launcher must not put a spinner over the host page.\n if (shouldAutoInit) {\n const { target, widgetConfig } = buildWidgetInit();\n if (widgetConfig.launcher?.enabled === false) {\n stopLoading = delayInstallLoading(typeof target === \"string\" ? document.querySelector(target) : target, false, config.renderLoading);\n }\n }\n // Eager path: retain feedback through all renderer/style preparation.\n try {\n await loadCSS();\n } catch (error) {\n return fail(\"css\", error);\n }\n try {\n await loadJS();\n } catch (error) {\n return fail(\"bundle\", error);\n }\n if (shouldAutoInit) {\n await initWidget(false);\n }\n } catch (error) {\n // Safety net for anything unexpected before the eager loads above.\n fail(\"init\", error);\n } finally {\n stopLoading();\n }\n };\n\n // Start installation after hydration completes\n // This prevents Next.js/Nuxt/etc. from removing dynamically added CSS\n waitForHydration(install);\n})();\n","import { version } from \"../../package.json\";\n\n/**\n * A cached /latest/ entry must keep using its own release, even after another\n * release replaces latest. Only rewrite our published CDN layout; custom hosts\n * and explicitly versioned URLs retain their existing sibling resolution.\n * The bundler embeds this package version in each script-tag entry.\n */\nexport function pinCdnRelease(src: string): string {\n return src.replace(\n /^https:\\/\\/cdn\\.runtype\\.com\\/persona\\/latest\\//,\n `https://cdn.runtype.com/persona/${version}/`,\n );\n}\n"],"mappings":"YAIA,IAAaA,GAAuBC,EAA4BC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