@maxhealth.tech/prefab 0.2.14 → 0.2.15
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/app.d.ts +1 -1
- package/dist/app.js +1 -1
- package/dist/renderer/bridge.d.ts.map +1 -1
- package/dist/renderer/bridge.js +15 -7
- package/dist/renderer/bridge.js.map +1 -1
- package/dist/renderer.auto.min.js +1 -1
- package/dist/renderer.min.js +1 -1
- package/package.json +1 -1
package/dist/app.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { ComponentJSON } from './core/component.js';
|
|
|
9
9
|
import type { Action, ActionJSON } from './actions/types.js';
|
|
10
10
|
import type { PipeFn } from './rx/pipes.js';
|
|
11
11
|
/** Package version — injected by build script, updated at release time. */
|
|
12
|
-
export declare const VERSION = "0.2.
|
|
12
|
+
export declare const VERSION = "0.2.15";
|
|
13
13
|
export interface Theme {
|
|
14
14
|
light?: Record<string, string>;
|
|
15
15
|
dark?: Record<string, string>;
|
package/dist/app.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {} from './core/component.js';
|
|
8
8
|
import { drainAutoState } from './rx/state-collector.js';
|
|
9
9
|
/** Package version — injected by build script, updated at release time. */
|
|
10
|
-
export const VERSION = '0.2.
|
|
10
|
+
export const VERSION = '0.2.15';
|
|
11
11
|
export class PrefabApp {
|
|
12
12
|
title;
|
|
13
13
|
view;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/renderer/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAIhD,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACtD,IAAI,EAAE,CAAC,CAAA;IACP,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE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AwB;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,IAAI;IAI5E,+BAA+B;IAC/B,UAAU,IAAI,IAAI;IAclB,mDAAmD;IACnD,IAAI,cAAc,IAAI,QAAQ,GAAG,SAAS,CAEzC;IAID,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,qBAAqB;IAsB7B,OAAO,CAAC,UAAU;IASlB,wCAAwC;IACxC,OAAO,CAAC,aAAa;IA2DrB,gEAAgE;IAChE,OAAO,CAAC,WAAW;IAoFnB,uEAAuE;IACvE,OAAO,CAAC,sBAAsB;IAc9B,qEAAqE;IACrE,OAAO,CAAC,cAAc;IActB,+EAA+E;IAC/E,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,QAAQ;CAMjB;AAOD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CAU5E;AAID,wBAAgB,QAAQ,IAAI,OAAO,CAOlC"}
|
package/dist/renderer/bridge.js
CHANGED
|
@@ -97,10 +97,19 @@ export class Bridge {
|
|
|
97
97
|
* Whichever protocol responds first wins.
|
|
98
98
|
*/
|
|
99
99
|
async initialize(appCapabilities) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
try {
|
|
101
|
+
return await Promise.any([
|
|
102
|
+
this.initPrefab(appCapabilities),
|
|
103
|
+
this.initJsonRpc(appCapabilities),
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
// All protocols failed — provide a clear diagnostic instead of raw AggregateError
|
|
108
|
+
const reasons = err instanceof AggregateError
|
|
109
|
+
? err.errors.map((e) => e.message).join('; ')
|
|
110
|
+
: String(err);
|
|
111
|
+
throw new Error(`Bridge init failed — no host responded. Tried: ${reasons}`, { cause: err });
|
|
112
|
+
}
|
|
104
113
|
}
|
|
105
114
|
/** Create an McpTransport that routes through the active protocol. */
|
|
106
115
|
createTransport() {
|
|
@@ -333,15 +342,14 @@ export class Bridge {
|
|
|
333
342
|
reject(err);
|
|
334
343
|
},
|
|
335
344
|
});
|
|
336
|
-
// Send ui/initialize request
|
|
345
|
+
// Send ui/initialize request (matches MCP Apps spec 2026-01-26 / ext-apps SDK schema)
|
|
337
346
|
this.postJsonRpc({
|
|
338
347
|
jsonrpc: '2.0',
|
|
339
348
|
id,
|
|
340
349
|
method: 'ui/initialize',
|
|
341
350
|
params: {
|
|
342
351
|
protocolVersion: '2026-01-26',
|
|
343
|
-
|
|
344
|
-
clientInfo: { name: 'prefab', version: '0.2' },
|
|
352
|
+
appInfo: { name: 'prefab', version: '0.2' },
|
|
345
353
|
appCapabilities: {
|
|
346
354
|
...(appCapabilities.displayModes && {
|
|
347
355
|
availableDisplayModes: appCapabilities.displayModes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/renderer/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA6DH,mDAAmD;AACnD,SAAS,iBAAiB,CAAC,GAAY;IACrC,OAAO,CACL,GAAG,KAAK,IAAI;QACZ,OAAO,GAAG,KAAK,QAAQ;QACtB,GAA+B,CAAC,OAAO,KAAK,KAAK,CACnD,CAAA;AACH,CAAC;AAED,gFAAgF;AAEhF,MAAM,OAAO,MAAM;IACT,UAAU,CAAQ;IAClB,SAAS,GAAG,IAAI,GAAG,EAA2D,CAAA;IAC9E,QAAQ,GAAyB,QAAQ,CAAA;IACzC,OAAO,CAA0B;IAEzC,iBAAiB;IACT,OAAO,GAAG,IAAI,GAAG,EAAyE,CAAA;IAC1F,aAAa,GAAG,CAAC,CAAA;IAEzB,iBAAiB;IACT,UAAU,GAAG,IAAI,GAAG,EAAkF,CAAA;IACtG,YAAY,GAAG,CAAC,CAAA;IAChB,UAA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;IACnD,MAAM,GAAG,GAAG,MAA4C,CAAA;IACxD,IAAI,OAAO,GAAG,CAAC,gBAAgB,KAAK,UAAU,EAAE,CAAC;QAC/C,IAAI,CAAC;YACH,MAAM,GAAG,GAAI,GAAG,CAAC,gBAAkC,EAAE,CAAA;YACrD,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,aAAa,IAAI,GAAG,EAAE,CAAC;gBACpE,OAAO,GAA8C,CAAA;YACvD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -11,4 +11,4 @@ ${U}
|
|
|
11
11
|
:root:not([data-theme="light"]) {
|
|
12
12
|
${U}
|
|
13
13
|
}
|
|
14
|
-
}`}}function h1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(a8(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function a8($,J){let Z=$.toLowerCase().split("+").map((Q)=>Q.trim()),q=Z[Z.length-1],U=new Set(Z.slice(0,-1));if(U.has("ctrl")!==(J.ctrlKey||J.metaKey))return!1;if(U.has("shift")!==J.shiftKey)return!1;if(U.has("alt")!==J.altKey)return!1;return J.key.toLowerCase()===q}var y1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',b1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',m1={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function o8($,J){try{let q=localStorage.getItem(J);if(q==="light"||q==="dark")return q}catch{}let Z=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(Z==="light"||Z==="dark")return Z;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function g0($,J){if(typeof document>"u")return()=>{};let Z=J?.position??"top-right",q=J?.storageKey??"prefab-theme",U=J?.syncDocument??!0,Q=getComputedStyle($).position;if(Q==="static"||Q==="")$.style.position="relative";let Y=document.createElement("button");Y.className="pf-theme-toggle",Y.setAttribute("aria-label","Toggle theme"),Y.setAttribute("title","Toggle light/dark"),Object.assign(Y.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let W=m1[Z]??m1["top-right"];for(let B of W.split(";")){let[z,D]=B.split(":").map((G)=>G.trim());if(z&&D)Y.style.setProperty(z,D)}Y.addEventListener("mouseenter",()=>{Y.style.opacity="1"}),Y.addEventListener("mouseleave",()=>{Y.style.opacity="0.7"});function H(B){if($.setAttribute("data-theme",B),U)document.documentElement.setAttribute("data-theme",B);Y.innerHTML=B==="dark"?b1:y1;try{localStorage.setItem(q,B)}catch{}}let N=o8($,q);H(N),Y.addEventListener("click",()=>{let B=$.getAttribute("data-theme")??"dark";H(B==="dark"?"light":"dark")}),$.appendChild(Y);let X;if(U)X=new MutationObserver((B)=>{for(let z of B)if(z.type==="attributes"&&z.attributeName==="data-theme"){let D=document.documentElement.getAttribute("data-theme");if((D==="light"||D==="dark")&&D!==$.getAttribute("data-theme")){$.setAttribute("data-theme",D),Y.innerHTML=D==="dark"?b1:y1;try{localStorage.setItem(q,D)}catch{}}}}),X.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{X?.disconnect(),Y.remove()}}function j0($){let J=$?.baseUrl??(typeof window<"u"?window.location.origin:""),Z={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(U,Q){let Y=await q(`${J}/mcp/tools/call`,{method:"POST",headers:Z,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:U,arguments:Q}})});if(!Y.ok)throw Error(`MCP tool call failed: ${Y.status} ${Y.statusText}`);let W=await Y.json();if(W.error)throw Error(W.error.message??"MCP tool call returned error");let H=W.result?.content??W.content??[];for(let N of H)if(N.type==="text"&&N.text!==void 0){try{let X=JSON.parse(N.text);if(typeof X==="object"&&X!==null&&"$prefab"in X)return X;return X}catch{}return N.text}return W.result??W},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function T0(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function t8($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class Q0{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=e8();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if(t8(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let Y=this.pending.get(U.id);if(Y){if(this.pending.delete(U.id),U.payload?.error!=null)Y.reject(Error(U.payload.error));else Y.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let Y of Q)Y(U.payload??{})};window.addEventListener("message",J),this.cleanup=()=>window.removeEventListener("message",J)}async initialize($){return Promise.any([this.initPrefab($),this.initJsonRpc($)])}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,J){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:J});else this.sendPrefab("prefab:open-link",{url:$,target:J})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,J){if(!this.listeners.has($))this.listeners.set($,new Set);let Z=this.listeners.get($);if(Z)Z.add(J)}off($,J){this.listeners.get($)?.delete(J)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((J,Z)=>{let q=!1,U=(Q)=>{if(q)return;q=!0,this.off("prefab:init-response",U),this.protocol="prefab",J(Q)};this.on("prefab:init-response",U),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",U),Z(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,J)=>{let Z=`tc-${++this.callIdCounter}`;return new Promise((q,U)=>{this.pending.set(Z,{resolve:q,reject:U}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:J},Z),setTimeout(()=>{if(this.pending.has(Z))this.pending.delete(Z),U(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,J,Z){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,U={type:$,payload:J,id:Z};q.postMessage(U,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let J=$.method,Z=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(J){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:Z.arguments??Z});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:Z.arguments??Z});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:Z});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",Z);break;case"ui/notifications/host-context-changed":{let q={};if(typeof Z.theme==="string")q.colorScheme=Z.theme;if(typeof Z.styles==="object"&&Z.styles!==null){let U=Z.styles;if(U.variables)q.variables=U.variables}this.dispatch("prefab:theme-update",q);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",Z);break}}initJsonRpc($){return new Promise((J,Z)=>{let q=++this.rpcIdCounter,U=!1;this.rpcPending.set(q,{resolve:(Q)=>{if(U)return;U=!0,this.protocol="jsonrpc";let Y=Q??{},W=Y.hostInfo??{},H=Y.hostContext??{},N=Y.hostCapabilities??{},X;if(typeof H.theme==="string"||typeof H.styles==="object"){if(X={},typeof H.theme==="string")X.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let B=H.styles;if(B.variables)X.variables=B.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:N.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:X,toolInput:void 0,meta:H})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",capabilities:{},clientInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!U)U=!0,this.rpcPending.delete(q),Z(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,J)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:J})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,J){let Z=++this.rpcIdCounter;return new Promise((q,U)=>{this.rpcPending.set(Z,{resolve:q,reject:U}),this.postJsonRpc({jsonrpc:"2.0",id:Z,method:$,params:J}),setTimeout(()=>{if(this.rpcPending.has(Z))this.rpcPending.delete(Z),U(Error(`JSON-RPC '${$}' timed out`))},30000)})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,J){let Z=this.listeners.get($);if(Z)for(let q of Z)q(J)}}function u0($,J){if(J.variables)for(let[Z,q]of Object.entries(J.variables))$.style.setProperty(Z.startsWith("--")?Z:`--${Z}`,q);if(J.colorScheme&&J.colorScheme!=="auto")$.setAttribute("data-theme",J.colorScheme)}function P0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function e8(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let J=$.acquireVsCodeApi();if(J!==null&&typeof J==="object"&&"postMessage"in J)return J}catch{return}return}var g={mount($,J,Z){L0();let q=[];if(J.pipes)for(let[D,G]of Object.entries(J.pipes))J2(D,G,q);let U=new J0(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=j0(Z.transport);else Q=T0();let Y=Z?.onToast??Z2,W={store:U,scope:{},transport:Q,rerender:()=>z(),onToast:Y,defs:J.defs};v1($,J.theme);let H=[];if(J.stylesheets)for(let D of J.stylesheets){let G=document.createElement("style");G.textContent=D,G.dataset.prefab="injected",document.head.appendChild(G),H.push(G)}let N;if(J.keyBindings)N=h1(J.keyBindings,async(D)=>{await k(D,{store:U,transport:Q,scope:{},rerender:()=>z(),onToast:Y})});let X,B=Z?.themeToggle??!0;if(B!==!1)X=g0($,typeof B==="object"?B:void 0);function z(){let D=$.querySelector(".pf-theme-toggle");$.innerHTML="";let G=w(J.view,W);if($.appendChild(G),D)$.appendChild(D)}return z(),{rerender:()=>z(),update(D){U.merge(D.update.state),z()},store:U,destroy(){X?.(),N?.(),r0();for(let D of H)D.remove();for(let D of q)I0(D);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},$2=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function J2($,J,Z){if($2.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+J+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}O0($,q),Z.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function Z2($){if(typeof document>"u")return;let J=q2(),Z=document.createElement("div");Z.className="pf-toast",Z.setAttribute("data-variant",$.variant??"default"),Z.style.padding="12px 16px",Z.style.borderRadius="8px",Z.style.backgroundColor="var(--card, #fff)",Z.style.border="1px solid var(--border, #e5e7eb)",Z.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let q=document.createElement("div");if(q.textContent=$.message,q.style.fontWeight="500",Z.appendChild(q),$.description){let Q=document.createElement("div");Q.textContent=$.description,Q.style.fontSize="14px",Q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Q)}J.appendChild(Z);let U=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},U)}function q2(){let J=document.getElementById("prefab-toast-container");if(!J)J=document.createElement("div"),J.id="prefab-toast-container",J.style.position="fixed",J.style.bottom="16px",J.style.right="16px",J.style.zIndex="9999",J.style.maxWidth="400px",document.body.appendChild(J);return J}if(typeof window<"u"){let $=window;$.PrefabRenderer=g,$.prefab={app:V0,mount:g.mount.bind(g),isPrefabData:g.isPrefabData.bind(g),isPrefabUpdate:g.isPrefabUpdate.bind(g),Bridge:Q0,isIframe:P0,registerPipe:O0,unregisterPipe:I0,listPipes:c0,registerComponent:M,createThemeToggle:g0};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)g.mount(Z,J)}}async function V0($){L0();let J=$?.mode??"auto",Z=J==="bridge"||J==="auto"&&P0(),q,U,Q={capabilities:{}};if(Z)U=new Q0($?.hostOrigin),U.connect(),Q=await U.initialize($?.capabilities??{toolInput:!0}),q=U.createTransport();else if($?.transport)q=j0($.transport);else q=T0();if(Q.theme&&typeof document<"u")u0(document.documentElement,Q.theme);let Y,W,H,N,X=Q.toolInput,B;if(U)U.on("prefab:tool-input",(G)=>{let F=G.args??G;if(Y)Y(F);else X=F}),U.on("prefab:tool-result",(G)=>{let F=G.result??G;if(W)W(F);else B=F}),U.on("prefab:tool-cancelled",()=>{H?.()}),U.on("prefab:tool-input-partial",(G)=>{N?.(G.args??G)}),U.on("prefab:theme-update",(G)=>{if(typeof document<"u")u0(document.documentElement,G)});function z(G,...F){let L=g1(G),V=new J0,A={store:V,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){L.innerHTML="";for(let E of F)L.appendChild(w(E,A))}return R(),{rerender:R,store:V,destroy:()=>{L.innerHTML=""}}}return{callTool:(G,F={})=>q.callTool(G,F),sendMessage:(G)=>q.sendMessage(G),onToolInput:(G)=>{if(Y=G,X){let F=X;X=void 0,queueMicrotask(()=>G(F))}},onToolResult:(G)=>{if(W=G,B!==void 0){let F=B;B=void 0,queueMicrotask(()=>G(F))}},onToolCancelled:(G)=>{H=G},onToolInputPartial:(G)=>{N=G},render:z,mount:(G,F,L)=>{let V=g1(G);return g.mount(V,F,{transport:q,...L})},requestMode:(G)=>U?.requestMode(G),openLink:(G,F)=>{if(U)U.openLink(G,F);else if(typeof window<"u")window.open(G,F??"_blank")},updateContext:(G)=>{if(U)U.updateContext(G)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}function g1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let J=document.querySelector($);if(!J)throw Error(`Element not found: ${$}`);return J}return $}var u1="#root";function x0($){return g.isPrefabData($)}function x1($){return g.isPrefabUpdate($)}function p1($){if(x0($))return $;if($!==null&&typeof $==="object"){let J=$;if(x0(J.structuredContent))return J.structuredContent;if(Array.isArray(J.content))for(let Z of J.content){let q=Z;if(q.type==="text"&&typeof q.text==="string")try{let U=JSON.parse(q.text);if(x0(U))return U}catch{}}}return null}async function c1(){let $=document.querySelector(u1);if(!$){console.error(`[prefab:auto] Mount target "${u1}" not found`);return}let J=$,Z=await V0(),q;function U(Q){if(q)q.destroy();q=Z.mount(J,Q)}Z.onToolResult((Q)=>{let Y=p1(Q);if(Y)U(Y);else if(x1(Q)&&q)q.update(Q)}),Z.onToolInput((Q)=>{let Y=p1(Q);if(Y)U(Y);else if(x1(Q)&&q)q.update(Q)})}function U2(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{c1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{c1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})})}U2();})();
|
|
14
|
+
}`}}function h1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(a8(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function a8($,J){let Z=$.toLowerCase().split("+").map((Q)=>Q.trim()),q=Z[Z.length-1],U=new Set(Z.slice(0,-1));if(U.has("ctrl")!==(J.ctrlKey||J.metaKey))return!1;if(U.has("shift")!==J.shiftKey)return!1;if(U.has("alt")!==J.altKey)return!1;return J.key.toLowerCase()===q}var y1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',b1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',m1={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function o8($,J){try{let q=localStorage.getItem(J);if(q==="light"||q==="dark")return q}catch{}let Z=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(Z==="light"||Z==="dark")return Z;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function g0($,J){if(typeof document>"u")return()=>{};let Z=J?.position??"top-right",q=J?.storageKey??"prefab-theme",U=J?.syncDocument??!0,Q=getComputedStyle($).position;if(Q==="static"||Q==="")$.style.position="relative";let Y=document.createElement("button");Y.className="pf-theme-toggle",Y.setAttribute("aria-label","Toggle theme"),Y.setAttribute("title","Toggle light/dark"),Object.assign(Y.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let W=m1[Z]??m1["top-right"];for(let B of W.split(";")){let[z,D]=B.split(":").map((G)=>G.trim());if(z&&D)Y.style.setProperty(z,D)}Y.addEventListener("mouseenter",()=>{Y.style.opacity="1"}),Y.addEventListener("mouseleave",()=>{Y.style.opacity="0.7"});function H(B){if($.setAttribute("data-theme",B),U)document.documentElement.setAttribute("data-theme",B);Y.innerHTML=B==="dark"?b1:y1;try{localStorage.setItem(q,B)}catch{}}let N=o8($,q);H(N),Y.addEventListener("click",()=>{let B=$.getAttribute("data-theme")??"dark";H(B==="dark"?"light":"dark")}),$.appendChild(Y);let X;if(U)X=new MutationObserver((B)=>{for(let z of B)if(z.type==="attributes"&&z.attributeName==="data-theme"){let D=document.documentElement.getAttribute("data-theme");if((D==="light"||D==="dark")&&D!==$.getAttribute("data-theme")){$.setAttribute("data-theme",D),Y.innerHTML=D==="dark"?b1:y1;try{localStorage.setItem(q,D)}catch{}}}}),X.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{X?.disconnect(),Y.remove()}}function j0($){let J=$?.baseUrl??(typeof window<"u"?window.location.origin:""),Z={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(U,Q){let Y=await q(`${J}/mcp/tools/call`,{method:"POST",headers:Z,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:U,arguments:Q}})});if(!Y.ok)throw Error(`MCP tool call failed: ${Y.status} ${Y.statusText}`);let W=await Y.json();if(W.error)throw Error(W.error.message??"MCP tool call returned error");let H=W.result?.content??W.content??[];for(let N of H)if(N.type==="text"&&N.text!==void 0){try{let X=JSON.parse(N.text);if(typeof X==="object"&&X!==null&&"$prefab"in X)return X;return X}catch{}return N.text}return W.result??W},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function T0(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function t8($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class Q0{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=e8();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if(t8(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let Y=this.pending.get(U.id);if(Y){if(this.pending.delete(U.id),U.payload?.error!=null)Y.reject(Error(U.payload.error));else Y.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let Y of Q)Y(U.payload??{})};window.addEventListener("message",J),this.cleanup=()=>window.removeEventListener("message",J)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(J){let Z=J instanceof AggregateError?J.errors.map((q)=>q.message).join("; "):String(J);throw Error(`Bridge init failed — no host responded. Tried: ${Z}`,{cause:J})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,J){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:J});else this.sendPrefab("prefab:open-link",{url:$,target:J})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,J){if(!this.listeners.has($))this.listeners.set($,new Set);let Z=this.listeners.get($);if(Z)Z.add(J)}off($,J){this.listeners.get($)?.delete(J)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((J,Z)=>{let q=!1,U=(Q)=>{if(q)return;q=!0,this.off("prefab:init-response",U),this.protocol="prefab",J(Q)};this.on("prefab:init-response",U),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",U),Z(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,J)=>{let Z=`tc-${++this.callIdCounter}`;return new Promise((q,U)=>{this.pending.set(Z,{resolve:q,reject:U}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:J},Z),setTimeout(()=>{if(this.pending.has(Z))this.pending.delete(Z),U(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,J,Z){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,U={type:$,payload:J,id:Z};q.postMessage(U,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let J=$.method,Z=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(J){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:Z.arguments??Z});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:Z.arguments??Z});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:Z});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",Z);break;case"ui/notifications/host-context-changed":{let q={};if(typeof Z.theme==="string")q.colorScheme=Z.theme;if(typeof Z.styles==="object"&&Z.styles!==null){let U=Z.styles;if(U.variables)q.variables=U.variables}this.dispatch("prefab:theme-update",q);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",Z);break}}initJsonRpc($){return new Promise((J,Z)=>{let q=++this.rpcIdCounter,U=!1;this.rpcPending.set(q,{resolve:(Q)=>{if(U)return;U=!0,this.protocol="jsonrpc";let Y=Q??{},W=Y.hostInfo??{},H=Y.hostContext??{},N=Y.hostCapabilities??{},X;if(typeof H.theme==="string"||typeof H.styles==="object"){if(X={},typeof H.theme==="string")X.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let B=H.styles;if(B.variables)X.variables=B.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:N.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:X,toolInput:void 0,meta:H})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!U)U=!0,this.rpcPending.delete(q),Z(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,J)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:J})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,J){let Z=++this.rpcIdCounter;return new Promise((q,U)=>{this.rpcPending.set(Z,{resolve:q,reject:U}),this.postJsonRpc({jsonrpc:"2.0",id:Z,method:$,params:J}),setTimeout(()=>{if(this.rpcPending.has(Z))this.rpcPending.delete(Z),U(Error(`JSON-RPC '${$}' timed out`))},30000)})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,J){let Z=this.listeners.get($);if(Z)for(let q of Z)q(J)}}function u0($,J){if(J.variables)for(let[Z,q]of Object.entries(J.variables))$.style.setProperty(Z.startsWith("--")?Z:`--${Z}`,q);if(J.colorScheme&&J.colorScheme!=="auto")$.setAttribute("data-theme",J.colorScheme)}function P0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function e8(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let J=$.acquireVsCodeApi();if(J!==null&&typeof J==="object"&&"postMessage"in J)return J}catch{return}return}var g={mount($,J,Z){L0();let q=[];if(J.pipes)for(let[D,G]of Object.entries(J.pipes))J2(D,G,q);let U=new J0(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=j0(Z.transport);else Q=T0();let Y=Z?.onToast??Z2,W={store:U,scope:{},transport:Q,rerender:()=>z(),onToast:Y,defs:J.defs};v1($,J.theme);let H=[];if(J.stylesheets)for(let D of J.stylesheets){let G=document.createElement("style");G.textContent=D,G.dataset.prefab="injected",document.head.appendChild(G),H.push(G)}let N;if(J.keyBindings)N=h1(J.keyBindings,async(D)=>{await k(D,{store:U,transport:Q,scope:{},rerender:()=>z(),onToast:Y})});let X,B=Z?.themeToggle??!0;if(B!==!1)X=g0($,typeof B==="object"?B:void 0);function z(){let D=$.querySelector(".pf-theme-toggle");$.innerHTML="";let G=w(J.view,W);if($.appendChild(G),D)$.appendChild(D)}return z(),{rerender:()=>z(),update(D){U.merge(D.update.state),z()},store:U,destroy(){X?.(),N?.(),r0();for(let D of H)D.remove();for(let D of q)I0(D);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},$2=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function J2($,J,Z){if($2.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+J+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}O0($,q),Z.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function Z2($){if(typeof document>"u")return;let J=q2(),Z=document.createElement("div");Z.className="pf-toast",Z.setAttribute("data-variant",$.variant??"default"),Z.style.padding="12px 16px",Z.style.borderRadius="8px",Z.style.backgroundColor="var(--card, #fff)",Z.style.border="1px solid var(--border, #e5e7eb)",Z.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let q=document.createElement("div");if(q.textContent=$.message,q.style.fontWeight="500",Z.appendChild(q),$.description){let Q=document.createElement("div");Q.textContent=$.description,Q.style.fontSize="14px",Q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Q)}J.appendChild(Z);let U=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},U)}function q2(){let J=document.getElementById("prefab-toast-container");if(!J)J=document.createElement("div"),J.id="prefab-toast-container",J.style.position="fixed",J.style.bottom="16px",J.style.right="16px",J.style.zIndex="9999",J.style.maxWidth="400px",document.body.appendChild(J);return J}if(typeof window<"u"){let $=window;$.PrefabRenderer=g,$.prefab={app:V0,mount:g.mount.bind(g),isPrefabData:g.isPrefabData.bind(g),isPrefabUpdate:g.isPrefabUpdate.bind(g),Bridge:Q0,isIframe:P0,registerPipe:O0,unregisterPipe:I0,listPipes:c0,registerComponent:M,createThemeToggle:g0};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)g.mount(Z,J)}}async function V0($){L0();let J=$?.mode??"auto",Z=J==="bridge"||J==="auto"&&P0(),q,U,Q={capabilities:{}};if(Z)U=new Q0($?.hostOrigin),U.connect(),Q=await U.initialize($?.capabilities??{toolInput:!0}),q=U.createTransport();else if($?.transport)q=j0($.transport);else q=T0();if(Q.theme&&typeof document<"u")u0(document.documentElement,Q.theme);let Y,W,H,N,X=Q.toolInput,B;if(U)U.on("prefab:tool-input",(G)=>{let F=G.args??G;if(Y)Y(F);else X=F}),U.on("prefab:tool-result",(G)=>{let F=G.result??G;if(W)W(F);else B=F}),U.on("prefab:tool-cancelled",()=>{H?.()}),U.on("prefab:tool-input-partial",(G)=>{N?.(G.args??G)}),U.on("prefab:theme-update",(G)=>{if(typeof document<"u")u0(document.documentElement,G)});function z(G,...F){let L=g1(G),V=new J0,A={store:V,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){L.innerHTML="";for(let E of F)L.appendChild(w(E,A))}return R(),{rerender:R,store:V,destroy:()=>{L.innerHTML=""}}}return{callTool:(G,F={})=>q.callTool(G,F),sendMessage:(G)=>q.sendMessage(G),onToolInput:(G)=>{if(Y=G,X){let F=X;X=void 0,queueMicrotask(()=>G(F))}},onToolResult:(G)=>{if(W=G,B!==void 0){let F=B;B=void 0,queueMicrotask(()=>G(F))}},onToolCancelled:(G)=>{H=G},onToolInputPartial:(G)=>{N=G},render:z,mount:(G,F,L)=>{let V=g1(G);return g.mount(V,F,{transport:q,...L})},requestMode:(G)=>U?.requestMode(G),openLink:(G,F)=>{if(U)U.openLink(G,F);else if(typeof window<"u")window.open(G,F??"_blank")},updateContext:(G)=>{if(U)U.updateContext(G)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}function g1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let J=document.querySelector($);if(!J)throw Error(`Element not found: ${$}`);return J}return $}var u1="#root";function x0($){return g.isPrefabData($)}function x1($){return g.isPrefabUpdate($)}function p1($){if(x0($))return $;if($!==null&&typeof $==="object"){let J=$;if(x0(J.structuredContent))return J.structuredContent;if(Array.isArray(J.content))for(let Z of J.content){let q=Z;if(q.type==="text"&&typeof q.text==="string")try{let U=JSON.parse(q.text);if(x0(U))return U}catch{}}}return null}async function c1(){let $=document.querySelector(u1);if(!$){console.error(`[prefab:auto] Mount target "${u1}" not found`);return}let J=$,Z=await V0(),q;function U(Q){if(q)q.destroy();q=Z.mount(J,Q)}Z.onToolResult((Q)=>{let Y=p1(Q);if(Y)U(Y);else if(x1(Q)&&q)q.update(Q)}),Z.onToolInput((Q)=>{let Y=p1(Q);if(Y)U(Y);else if(x1(Q)&&q)q.update(Q)})}function U2(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{c1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{c1().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})})}U2();})();
|
package/dist/renderer.min.js
CHANGED
|
@@ -11,4 +11,4 @@ ${U}
|
|
|
11
11
|
:root:not([data-theme="light"]) {
|
|
12
12
|
${U}
|
|
13
13
|
}
|
|
14
|
-
}`}}function g1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(J2(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function J2($,J){let Z=$.toLowerCase().split("+").map((Q)=>Q.trim()),q=Z[Z.length-1],U=new Set(Z.slice(0,-1));if(U.has("ctrl")!==(J.ctrlKey||J.metaKey))return!1;if(U.has("shift")!==J.shiftKey)return!1;if(U.has("alt")!==J.altKey)return!1;return J.key.toLowerCase()===q}var b1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',m1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',v1={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function Z2($,J){try{let q=localStorage.getItem(J);if(q==="light"||q==="dark")return q}catch{}let Z=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(Z==="light"||Z==="dark")return Z;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function M0($,J){if(typeof document>"u")return()=>{};let Z=J?.position??"top-right",q=J?.storageKey??"prefab-theme",U=J?.syncDocument??!0,Q=getComputedStyle($).position;if(Q==="static"||Q==="")$.style.position="relative";let W=document.createElement("button");W.className="pf-theme-toggle",W.setAttribute("aria-label","Toggle theme"),W.setAttribute("title","Toggle light/dark"),Object.assign(W.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let Y=v1[Z]??v1["top-right"];for(let _ of Y.split(";")){let[z,D]=_.split(":").map((G)=>G.trim());if(z&&D)W.style.setProperty(z,D)}W.addEventListener("mouseenter",()=>{W.style.opacity="1"}),W.addEventListener("mouseleave",()=>{W.style.opacity="0.7"});function H(_){if($.setAttribute("data-theme",_),U)document.documentElement.setAttribute("data-theme",_);W.innerHTML=_==="dark"?m1:b1;try{localStorage.setItem(q,_)}catch{}}let N=Z2($,q);H(N),W.addEventListener("click",()=>{let _=$.getAttribute("data-theme")??"dark";H(_==="dark"?"light":"dark")}),$.appendChild(W);let X;if(U)X=new MutationObserver((_)=>{for(let z of _)if(z.type==="attributes"&&z.attributeName==="data-theme"){let D=document.documentElement.getAttribute("data-theme");if((D==="light"||D==="dark")&&D!==$.getAttribute("data-theme")){$.setAttribute("data-theme",D),W.innerHTML=D==="dark"?m1:b1;try{localStorage.setItem(q,D)}catch{}}}}),X.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{X?.disconnect(),W.remove()}}function R0($){let J=$?.baseUrl??(typeof window<"u"?window.location.origin:""),Z={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(U,Q){let W=await q(`${J}/mcp/tools/call`,{method:"POST",headers:Z,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:U,arguments:Q}})});if(!W.ok)throw Error(`MCP tool call failed: ${W.status} ${W.statusText}`);let Y=await W.json();if(Y.error)throw Error(Y.error.message??"MCP tool call returned error");let H=Y.result?.content??Y.content??[];for(let N of H)if(N.type==="text"&&N.text!==void 0){try{let X=JSON.parse(N.text);if(typeof X==="object"&&X!==null&&"$prefab"in X)return X;return X}catch{}return N.text}return Y.result??Y},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function A0(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function q2($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class t{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=U2();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if(q2(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let W=this.pending.get(U.id);if(W){if(this.pending.delete(U.id),U.payload?.error!=null)W.reject(Error(U.payload.error));else W.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let W of Q)W(U.payload??{})};window.addEventListener("message",J),this.cleanup=()=>window.removeEventListener("message",J)}async initialize($){return Promise.any([this.initPrefab($),this.initJsonRpc($)])}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,J){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:J});else this.sendPrefab("prefab:open-link",{url:$,target:J})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,J){if(!this.listeners.has($))this.listeners.set($,new Set);let Z=this.listeners.get($);if(Z)Z.add(J)}off($,J){this.listeners.get($)?.delete(J)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((J,Z)=>{let q=!1,U=(Q)=>{if(q)return;q=!0,this.off("prefab:init-response",U),this.protocol="prefab",J(Q)};this.on("prefab:init-response",U),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",U),Z(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,J)=>{let Z=`tc-${++this.callIdCounter}`;return new Promise((q,U)=>{this.pending.set(Z,{resolve:q,reject:U}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:J},Z),setTimeout(()=>{if(this.pending.has(Z))this.pending.delete(Z),U(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,J,Z){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,U={type:$,payload:J,id:Z};q.postMessage(U,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let J=$.method,Z=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(J){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:Z.arguments??Z});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:Z.arguments??Z});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:Z});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",Z);break;case"ui/notifications/host-context-changed":{let q={};if(typeof Z.theme==="string")q.colorScheme=Z.theme;if(typeof Z.styles==="object"&&Z.styles!==null){let U=Z.styles;if(U.variables)q.variables=U.variables}this.dispatch("prefab:theme-update",q);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",Z);break}}initJsonRpc($){return new Promise((J,Z)=>{let q=++this.rpcIdCounter,U=!1;this.rpcPending.set(q,{resolve:(Q)=>{if(U)return;U=!0,this.protocol="jsonrpc";let W=Q??{},Y=W.hostInfo??{},H=W.hostContext??{},N=W.hostCapabilities??{},X;if(typeof H.theme==="string"||typeof H.styles==="object"){if(X={},typeof H.theme==="string")X.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let _=H.styles;if(_.variables)X.variables=_.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:Y.name,hostVersion:Y.version,capabilities:{toast:!0,navigation:N.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:X,toolInput:void 0,meta:H})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",capabilities:{},clientInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!U)U=!0,this.rpcPending.delete(q),Z(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,J)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:J})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,J){let Z=++this.rpcIdCounter;return new Promise((q,U)=>{this.rpcPending.set(Z,{resolve:q,reject:U}),this.postJsonRpc({jsonrpc:"2.0",id:Z,method:$,params:J}),setTimeout(()=>{if(this.rpcPending.has(Z))this.rpcPending.delete(Z),U(Error(`JSON-RPC '${$}' timed out`))},30000)})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,J){let Z=this.listeners.get($);if(Z)for(let q of Z)q(J)}}function _0($,J){if(J.variables)for(let[Z,q]of Object.entries(J.variables))$.style.setProperty(Z.startsWith("--")?Z:`--${Z}`,q);if(J.colorScheme&&J.colorScheme!=="auto")$.setAttribute("data-theme",J.colorScheme)}function Z0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function U2(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let J=$.acquireVsCodeApi();if(J!==null&&typeof J==="object"&&"postMessage"in J)return J}catch{return}return}async function k0($){I0();let J=$?.mode??"auto",Z=J==="bridge"||J==="auto"&&Z0(),q,U,Q={capabilities:{}};if(Z)U=new t($?.hostOrigin),U.connect(),Q=await U.initialize($?.capabilities??{toolInput:!0}),q=U.createTransport();else if($?.transport)q=R0($.transport);else q=A0();if(Q.theme&&typeof document<"u")_0(document.documentElement,Q.theme);let W,Y,H,N,X=Q.toolInput,_;if(U)U.on("prefab:tool-input",(G)=>{let E=G.args??G;if(W)W(E);else X=E}),U.on("prefab:tool-result",(G)=>{let E=G.result??G;if(Y)Y(E);else _=E}),U.on("prefab:tool-cancelled",()=>{H?.()}),U.on("prefab:tool-input-partial",(G)=>{N?.(G.args??G)}),U.on("prefab:theme-update",(G)=>{if(typeof document<"u")_0(document.documentElement,G)});function z(G,...E){let j=u1(G),O=new q0,A={store:O,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){j.innerHTML="";for(let F of E)j.appendChild(S(F,A))}return R(),{rerender:R,store:O,destroy:()=>{j.innerHTML=""}}}return{callTool:(G,E={})=>q.callTool(G,E),sendMessage:(G)=>q.sendMessage(G),onToolInput:(G)=>{if(W=G,X){let E=X;X=void 0,queueMicrotask(()=>G(E))}},onToolResult:(G)=>{if(Y=G,_!==void 0){let E=_;_=void 0,queueMicrotask(()=>G(E))}},onToolCancelled:(G)=>{H=G},onToolInputPartial:(G)=>{N=G},render:z,mount:(G,E,j)=>{let O=u1(G);return p.mount(O,E,{transport:q,...j})},requestMode:(G)=>U?.requestMode(G),openLink:(G,E)=>{if(U)U.openLink(G,E);else if(typeof window<"u")window.open(G,E??"_blank")},updateContext:(G)=>{if(U)U.updateContext(G)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}function u1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let J=document.querySelector($);if(!J)throw Error(`Element not found: ${$}`);return J}return $}var p={mount($,J,Z){I0();let q=[];if(J.pipes)for(let[D,G]of Object.entries(J.pipes))W2(D,G,q);let U=new q0(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=R0(Z.transport);else Q=A0();let W=Z?.onToast??Y2,Y={store:U,scope:{},transport:Q,rerender:()=>z(),onToast:W,defs:J.defs};h1($,J.theme);let H=[];if(J.stylesheets)for(let D of J.stylesheets){let G=document.createElement("style");G.textContent=D,G.dataset.prefab="injected",document.head.appendChild(G),H.push(G)}let N;if(J.keyBindings)N=g1(J.keyBindings,async(D)=>{await k(D,{store:U,transport:Q,scope:{},rerender:()=>z(),onToast:W})});let X,_=Z?.themeToggle??!0;if(_!==!1)X=M0($,typeof _==="object"?_:void 0);function z(){let D=$.querySelector(".pf-theme-toggle");$.innerHTML="";let G=S(J.view,Y);if($.appendChild(G),D)$.appendChild(D)}return z(),{rerender:()=>z(),update(D){U.merge(D.update.state),z()},store:U,destroy(){X?.(),N?.(),n0();for(let D of H)D.remove();for(let D of q)Q0(D);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},Q2=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function W2($,J,Z){if(Q2.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+J+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}U0($,q),Z.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function Y2($){if(typeof document>"u")return;let J=H2(),Z=document.createElement("div");Z.className="pf-toast",Z.setAttribute("data-variant",$.variant??"default"),Z.style.padding="12px 16px",Z.style.borderRadius="8px",Z.style.backgroundColor="var(--card, #fff)",Z.style.border="1px solid var(--border, #e5e7eb)",Z.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let q=document.createElement("div");if(q.textContent=$.message,q.style.fontWeight="500",Z.appendChild(q),$.description){let Q=document.createElement("div");Q.textContent=$.description,Q.style.fontSize="14px",Q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Q)}J.appendChild(Z);let U=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},U)}function H2(){let J=document.getElementById("prefab-toast-container");if(!J)J=document.createElement("div"),J.id="prefab-toast-container",J.style.position="fixed",J.style.bottom="16px",J.style.right="16px",J.style.zIndex="9999",J.style.maxWidth="400px",document.body.appendChild(J);return J}if(typeof window<"u"){let $=window;$.PrefabRenderer=p,$.prefab={app:k0,mount:p.mount.bind(p),isPrefabData:p.isPrefabData.bind(p),isPrefabUpdate:p.isPrefabUpdate.bind(p),Bridge:t,isIframe:Z0,registerPipe:U0,unregisterPipe:Q0,listPipes:N0,registerComponent:M,createThemeToggle:M0};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)p.mount(Z,J)}}})();
|
|
14
|
+
}`}}function g1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(J2(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function J2($,J){let Z=$.toLowerCase().split("+").map((Q)=>Q.trim()),q=Z[Z.length-1],U=new Set(Z.slice(0,-1));if(U.has("ctrl")!==(J.ctrlKey||J.metaKey))return!1;if(U.has("shift")!==J.shiftKey)return!1;if(U.has("alt")!==J.altKey)return!1;return J.key.toLowerCase()===q}var b1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',m1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',v1={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function Z2($,J){try{let q=localStorage.getItem(J);if(q==="light"||q==="dark")return q}catch{}let Z=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(Z==="light"||Z==="dark")return Z;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function M0($,J){if(typeof document>"u")return()=>{};let Z=J?.position??"top-right",q=J?.storageKey??"prefab-theme",U=J?.syncDocument??!0,Q=getComputedStyle($).position;if(Q==="static"||Q==="")$.style.position="relative";let W=document.createElement("button");W.className="pf-theme-toggle",W.setAttribute("aria-label","Toggle theme"),W.setAttribute("title","Toggle light/dark"),Object.assign(W.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let Y=v1[Z]??v1["top-right"];for(let _ of Y.split(";")){let[z,D]=_.split(":").map((G)=>G.trim());if(z&&D)W.style.setProperty(z,D)}W.addEventListener("mouseenter",()=>{W.style.opacity="1"}),W.addEventListener("mouseleave",()=>{W.style.opacity="0.7"});function H(_){if($.setAttribute("data-theme",_),U)document.documentElement.setAttribute("data-theme",_);W.innerHTML=_==="dark"?m1:b1;try{localStorage.setItem(q,_)}catch{}}let N=Z2($,q);H(N),W.addEventListener("click",()=>{let _=$.getAttribute("data-theme")??"dark";H(_==="dark"?"light":"dark")}),$.appendChild(W);let X;if(U)X=new MutationObserver((_)=>{for(let z of _)if(z.type==="attributes"&&z.attributeName==="data-theme"){let D=document.documentElement.getAttribute("data-theme");if((D==="light"||D==="dark")&&D!==$.getAttribute("data-theme")){$.setAttribute("data-theme",D),W.innerHTML=D==="dark"?m1:b1;try{localStorage.setItem(q,D)}catch{}}}}),X.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{X?.disconnect(),W.remove()}}function R0($){let J=$?.baseUrl??(typeof window<"u"?window.location.origin:""),Z={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(U,Q){let W=await q(`${J}/mcp/tools/call`,{method:"POST",headers:Z,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:U,arguments:Q}})});if(!W.ok)throw Error(`MCP tool call failed: ${W.status} ${W.statusText}`);let Y=await W.json();if(Y.error)throw Error(Y.error.message??"MCP tool call returned error");let H=Y.result?.content??Y.content??[];for(let N of H)if(N.type==="text"&&N.text!==void 0){try{let X=JSON.parse(N.text);if(typeof X==="object"&&X!==null&&"$prefab"in X)return X;return X}catch{}return N.text}return Y.result??Y},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function A0(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function q2($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class t{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=U2();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if(q2(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let W=this.pending.get(U.id);if(W){if(this.pending.delete(U.id),U.payload?.error!=null)W.reject(Error(U.payload.error));else W.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let W of Q)W(U.payload??{})};window.addEventListener("message",J),this.cleanup=()=>window.removeEventListener("message",J)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(J){let Z=J instanceof AggregateError?J.errors.map((q)=>q.message).join("; "):String(J);throw Error(`Bridge init failed — no host responded. Tried: ${Z}`,{cause:J})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,J){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:J});else this.sendPrefab("prefab:open-link",{url:$,target:J})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,J){if(!this.listeners.has($))this.listeners.set($,new Set);let Z=this.listeners.get($);if(Z)Z.add(J)}off($,J){this.listeners.get($)?.delete(J)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((J,Z)=>{let q=!1,U=(Q)=>{if(q)return;q=!0,this.off("prefab:init-response",U),this.protocol="prefab",J(Q)};this.on("prefab:init-response",U),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",U),Z(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,J)=>{let Z=`tc-${++this.callIdCounter}`;return new Promise((q,U)=>{this.pending.set(Z,{resolve:q,reject:U}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:J},Z),setTimeout(()=>{if(this.pending.has(Z))this.pending.delete(Z),U(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,J,Z){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,U={type:$,payload:J,id:Z};q.postMessage(U,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let J=$.method,Z=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(J){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:Z.arguments??Z});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:Z.arguments??Z});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:Z});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",Z);break;case"ui/notifications/host-context-changed":{let q={};if(typeof Z.theme==="string")q.colorScheme=Z.theme;if(typeof Z.styles==="object"&&Z.styles!==null){let U=Z.styles;if(U.variables)q.variables=U.variables}this.dispatch("prefab:theme-update",q);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",Z);break}}initJsonRpc($){return new Promise((J,Z)=>{let q=++this.rpcIdCounter,U=!1;this.rpcPending.set(q,{resolve:(Q)=>{if(U)return;U=!0,this.protocol="jsonrpc";let W=Q??{},Y=W.hostInfo??{},H=W.hostContext??{},N=W.hostCapabilities??{},X;if(typeof H.theme==="string"||typeof H.styles==="object"){if(X={},typeof H.theme==="string")X.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let _=H.styles;if(_.variables)X.variables=_.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:Y.name,hostVersion:Y.version,capabilities:{toast:!0,navigation:N.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:X,toolInput:void 0,meta:H})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!U)U=!0,this.rpcPending.delete(q),Z(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,J)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:J})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,J){let Z=++this.rpcIdCounter;return new Promise((q,U)=>{this.rpcPending.set(Z,{resolve:q,reject:U}),this.postJsonRpc({jsonrpc:"2.0",id:Z,method:$,params:J}),setTimeout(()=>{if(this.rpcPending.has(Z))this.rpcPending.delete(Z),U(Error(`JSON-RPC '${$}' timed out`))},30000)})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,J){let Z=this.listeners.get($);if(Z)for(let q of Z)q(J)}}function _0($,J){if(J.variables)for(let[Z,q]of Object.entries(J.variables))$.style.setProperty(Z.startsWith("--")?Z:`--${Z}`,q);if(J.colorScheme&&J.colorScheme!=="auto")$.setAttribute("data-theme",J.colorScheme)}function Z0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function U2(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let J=$.acquireVsCodeApi();if(J!==null&&typeof J==="object"&&"postMessage"in J)return J}catch{return}return}async function k0($){I0();let J=$?.mode??"auto",Z=J==="bridge"||J==="auto"&&Z0(),q,U,Q={capabilities:{}};if(Z)U=new t($?.hostOrigin),U.connect(),Q=await U.initialize($?.capabilities??{toolInput:!0}),q=U.createTransport();else if($?.transport)q=R0($.transport);else q=A0();if(Q.theme&&typeof document<"u")_0(document.documentElement,Q.theme);let W,Y,H,N,X=Q.toolInput,_;if(U)U.on("prefab:tool-input",(G)=>{let E=G.args??G;if(W)W(E);else X=E}),U.on("prefab:tool-result",(G)=>{let E=G.result??G;if(Y)Y(E);else _=E}),U.on("prefab:tool-cancelled",()=>{H?.()}),U.on("prefab:tool-input-partial",(G)=>{N?.(G.args??G)}),U.on("prefab:theme-update",(G)=>{if(typeof document<"u")_0(document.documentElement,G)});function z(G,...E){let j=u1(G),O=new q0,A={store:O,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){j.innerHTML="";for(let F of E)j.appendChild(S(F,A))}return R(),{rerender:R,store:O,destroy:()=>{j.innerHTML=""}}}return{callTool:(G,E={})=>q.callTool(G,E),sendMessage:(G)=>q.sendMessage(G),onToolInput:(G)=>{if(W=G,X){let E=X;X=void 0,queueMicrotask(()=>G(E))}},onToolResult:(G)=>{if(Y=G,_!==void 0){let E=_;_=void 0,queueMicrotask(()=>G(E))}},onToolCancelled:(G)=>{H=G},onToolInputPartial:(G)=>{N=G},render:z,mount:(G,E,j)=>{let O=u1(G);return p.mount(O,E,{transport:q,...j})},requestMode:(G)=>U?.requestMode(G),openLink:(G,E)=>{if(U)U.openLink(G,E);else if(typeof window<"u")window.open(G,E??"_blank")},updateContext:(G)=>{if(U)U.updateContext(G)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}function u1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let J=document.querySelector($);if(!J)throw Error(`Element not found: ${$}`);return J}return $}var p={mount($,J,Z){I0();let q=[];if(J.pipes)for(let[D,G]of Object.entries(J.pipes))W2(D,G,q);let U=new q0(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=R0(Z.transport);else Q=A0();let W=Z?.onToast??Y2,Y={store:U,scope:{},transport:Q,rerender:()=>z(),onToast:W,defs:J.defs};h1($,J.theme);let H=[];if(J.stylesheets)for(let D of J.stylesheets){let G=document.createElement("style");G.textContent=D,G.dataset.prefab="injected",document.head.appendChild(G),H.push(G)}let N;if(J.keyBindings)N=g1(J.keyBindings,async(D)=>{await k(D,{store:U,transport:Q,scope:{},rerender:()=>z(),onToast:W})});let X,_=Z?.themeToggle??!0;if(_!==!1)X=M0($,typeof _==="object"?_:void 0);function z(){let D=$.querySelector(".pf-theme-toggle");$.innerHTML="";let G=S(J.view,Y);if($.appendChild(G),D)$.appendChild(D)}return z(),{rerender:()=>z(),update(D){U.merge(D.update.state),z()},store:U,destroy(){X?.(),N?.(),n0();for(let D of H)D.remove();for(let D of q)Q0(D);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},Q2=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function W2($,J,Z){if(Q2.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+J+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}U0($,q),Z.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function Y2($){if(typeof document>"u")return;let J=H2(),Z=document.createElement("div");Z.className="pf-toast",Z.setAttribute("data-variant",$.variant??"default"),Z.style.padding="12px 16px",Z.style.borderRadius="8px",Z.style.backgroundColor="var(--card, #fff)",Z.style.border="1px solid var(--border, #e5e7eb)",Z.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let q=document.createElement("div");if(q.textContent=$.message,q.style.fontWeight="500",Z.appendChild(q),$.description){let Q=document.createElement("div");Q.textContent=$.description,Q.style.fontSize="14px",Q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Q)}J.appendChild(Z);let U=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},U)}function H2(){let J=document.getElementById("prefab-toast-container");if(!J)J=document.createElement("div"),J.id="prefab-toast-container",J.style.position="fixed",J.style.bottom="16px",J.style.right="16px",J.style.zIndex="9999",J.style.maxWidth="400px",document.body.appendChild(J);return J}if(typeof window<"u"){let $=window;$.PrefabRenderer=p,$.prefab={app:k0,mount:p.mount.bind(p),isPrefabData:p.isPrefabData.bind(p),isPrefabUpdate:p.isPrefabUpdate.bind(p),Bridge:t,isIframe:Z0,registerPipe:U0,unregisterPipe:Q0,listPipes:N0,registerComponent:M,createThemeToggle:M0};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)p.mount(Z,J)}}})();
|
package/package.json
CHANGED