@modelcontextprotocol/server-shadertoy 1.2.2 → 1.3.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/mcp-app.html CHANGED
@@ -64,7 +64,7 @@ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Rec
64
64
  for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);p({method:u("ui/open-link"),params:p({url:d().describe("URL to open in the host's browser")})});var bl=p({isError:M().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),wl=p({isError:M().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),yl=p({isError:M().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();p({method:u("ui/notifications/sandbox-proxy-ready"),params:p({})});var Bt=p({connectDomains:T(d()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
65
65
 
66
66
  - Maps to CSP \`connect-src\` directive
67
- - Empty or omitted → no network connections (secure default)`),resourceDomains:T(d()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:T(d()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:T(d()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Jt=p({camera:p({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:p({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:p({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:p({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});p({method:u("ui/notifications/size-changed"),params:p({width:z().optional().describe("New width in pixels."),height:z().optional().describe("New height in pixels.")})});var Sl=p({method:u("ui/notifications/tool-input"),params:p({arguments:x(d(),O().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),kl=p({method:u("ui/notifications/tool-input-partial"),params:p({arguments:x(d(),O().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),Tl=p({method:u("ui/notifications/tool-cancelled"),params:p({reason:d().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),zl=p({fonts:d().optional()}),Rl=p({variables:vl.optional().describe("CSS variables for theming the app."),css:zl.optional().describe("CSS blocks that apps can inject.")}),El=p({method:u("ui/resource-teardown"),params:p({})});x(d(),O());var yn=p({text:p({}).optional().describe("Host supports text content blocks."),image:p({}).optional().describe("Host supports image content blocks."),audio:p({}).optional().describe("Host supports audio content blocks."),resource:p({}).optional().describe("Host supports resource content blocks."),resourceLink:p({}).optional().describe("Host supports resource link content blocks."),structuredContent:p({}).optional().describe("Host supports structured content.")}),Il=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),openLinks:p({}).optional().describe("Host supports opening external URLs."),downloadFile:p({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:p({listChanged:M().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:p({listChanged:M().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:p({}).optional().describe("Host accepts log messages."),sandbox:p({permissions:Jt.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Bt.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:yn.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:yn.optional().describe("Host supports receiving content messages (ui/message) from the view.")}),Pl=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),tools:p({listChanged:M().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:T(Oe).optional().describe("Display modes the app supports.")});p({method:u("ui/notifications/initialized"),params:p({}).optional()});p({csp:Bt.optional().describe("Content Security Policy configuration for UI resources."),permissions:Jt.optional().describe("Sandbox permissions requested by the UI resource."),domain:d().optional().describe(`Dedicated origin for view sandbox.
67
+ - Empty or omitted → no network connections (secure default)`),resourceDomains:T(d()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:T(d()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:T(d()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Jt=p({camera:p({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:p({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:p({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:p({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});p({method:u("ui/notifications/size-changed"),params:p({width:z().optional().describe("New width in pixels."),height:z().optional().describe("New height in pixels.")})});var Sl=p({method:u("ui/notifications/tool-input"),params:p({arguments:x(d(),O().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),kl=p({method:u("ui/notifications/tool-input-partial"),params:p({arguments:x(d(),O().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),Tl=p({method:u("ui/notifications/tool-cancelled"),params:p({reason:d().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),zl=p({fonts:d().optional()}),Rl=p({variables:vl.optional().describe("CSS variables for theming the app."),css:zl.optional().describe("CSS blocks that apps can inject.")}),El=p({method:u("ui/resource-teardown"),params:p({})});x(d(),O());var yn=p({text:p({}).optional().describe("Host supports text content blocks."),image:p({}).optional().describe("Host supports image content blocks."),audio:p({}).optional().describe("Host supports audio content blocks."),resource:p({}).optional().describe("Host supports resource content blocks."),resourceLink:p({}).optional().describe("Host supports resource link content blocks."),structuredContent:p({}).optional().describe("Host supports structured content.")});p({method:u("ui/notifications/request-teardown"),params:p({}).optional()});var Il=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),openLinks:p({}).optional().describe("Host supports opening external URLs."),downloadFile:p({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:p({listChanged:M().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:p({listChanged:M().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:p({}).optional().describe("Host accepts log messages."),sandbox:p({permissions:Jt.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Bt.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:yn.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:yn.optional().describe("Host supports receiving content messages (ui/message) from the view.")}),Pl=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),tools:p({listChanged:M().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:T(Oe).optional().describe("Display modes the app supports.")});p({method:u("ui/notifications/initialized"),params:p({}).optional()});p({csp:Bt.optional().describe("Content Security Policy configuration for UI resources."),permissions:Jt.optional().describe("Sandbox permissions requested by the UI resource."),domain:d().optional().describe(`Dedicated origin for view sandbox.
68
68
 
69
69
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
70
70
 
@@ -81,7 +81,7 @@ Boolean requesting whether a visible border and background is provided by the ho
81
81
  - omitted: host decides border`)});p({method:u("ui/request-display-mode"),params:p({mode:Oe.describe("The display mode being requested.")})});var $l=p({mode:Oe.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),Cl=R([u("model"),u("app")]).describe("Tool visibility scope - who can access the tool.");p({resourceUri:d().optional(),visibility:T(Cl).optional().describe(`Who can access this tool. Default: ["model", "app"]
82
82
  - "model": Tool visible to and callable by the agent
83
83
  - "app": Tool callable by the app from this server only`)});p({mimeTypes:T(d()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});p({method:u("ui/download-file"),params:p({contents:T(R([wo,yo])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});p({method:u("ui/message"),params:p({role:u("user").describe('Message role, currently only "user" is supported.'),content:T(je).describe("Message content blocks (text, image, etc.).")})});p({method:u("ui/notifications/sandbox-resource-ready"),params:p({html:d().describe("HTML content to load into the inner iframe."),sandbox:d().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Bt.optional().describe("CSP configuration from resource metadata."),permissions:Jt.optional().describe("Sandbox permissions from resource metadata.")})});var xl=p({method:u("ui/notifications/tool-result"),params:lt.describe("Standard MCP tool execution result.")}),zo=p({toolInfo:p({id:Ae.optional().describe("JSON-RPC id of the tools/call request."),tool:Ht.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:gl.optional().describe("Current color theme preference."),styles:Rl.optional().describe("Style configuration for theming the app."),displayMode:Oe.optional().describe("How the UI is currently displayed."),availableDisplayModes:T(Oe).optional().describe("Display modes the host supports."),containerDimensions:R([p({height:z().describe("Fixed container height in pixels.")}),p({maxHeight:R([z(),mt()]).optional().describe("Maximum container height in pixels.")})]).and(R([p({width:z().describe("Fixed container width in pixels.")}),p({maxWidth:R([z(),mt()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
84
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:d().optional().describe("User's language and region preference in BCP 47 format."),timeZone:d().optional().describe("User's timezone in IANA format."),userAgent:d().optional().describe("Host application identifier."),platform:R([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p({touch:M().optional().describe("Whether the device supports touch input."),hover:M().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p({top:z().describe("Top safe area inset in pixels."),right:z().describe("Right safe area inset in pixels."),bottom:z().describe("Bottom safe area inset in pixels."),left:z().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),Zl=p({method:u("ui/notifications/host-context-changed"),params:zo.describe("Partial context update containing only changed fields.")});p({method:u("ui/update-model-context"),params:p({content:T(je).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:x(d(),O().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});p({method:u("ui/initialize"),params:p({appInfo:ct.describe("App identification (name and version)."),appCapabilities:Pl.describe("Features and capabilities this app provides."),protocolVersion:d().describe("Protocol version this app supports.")})});var Ol=p({protocolVersion:d().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:ct.describe("Host application identification and version."),hostCapabilities:Il.describe("Features and capabilities provided by the host."),hostContext:zo.describe("Rich context about the host environment.")}).passthrough();function Nl(e){let t=document.documentElement;t.setAttribute("data-theme",e),t.style.colorScheme=e}function Al(e,t=document.documentElement){for(let[n,o]of Object.entries(e))o!==void 0&&t.style.setProperty(n,o)}class Ml extends hl{constructor(n,o={},r={autoResize:!0}){super(r);Q(this,"_appInfo");Q(this,"_capabilities");Q(this,"options");Q(this,"_hostCapabilities");Q(this,"_hostInfo");Q(this,"_hostContext");Q(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=o,this.options=r,this.setRequestHandler(ut,s=>(console.log("Received ping:",s.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(n){this.setNotificationHandler(Sl,o=>n(o.params))}set ontoolinputpartial(n){this.setNotificationHandler(kl,o=>n(o.params))}set ontoolresult(n){this.setNotificationHandler(xl,o=>n(o.params))}set ontoolcancelled(n){this.setNotificationHandler(Tl,o=>n(o.params))}set onhostcontextchanged(n){this.setNotificationHandler(Zl,o=>{this._hostContext={...this._hostContext,...o.params},n(o.params)})}set onteardown(n){this.setRequestHandler(El,(o,r)=>n(o.params,r))}set oncalltool(n){this.setRequestHandler(ko,(o,r)=>n(o.params,r))}set onlisttools(n){this.setRequestHandler(So,(o,r)=>n(o.params,r))}assertCapabilityForMethod(n){}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,o){if(typeof n=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${n}"). Did you mean: callServerTool({ name: "${n}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:n},lt,o)}async readServerResource(n,o){return await this.request({method:"resources/read",params:n},bo,o)}async listServerResources(n,o){return await this.request({method:"resources/list",params:n},vo,o)}sendMessage(n,o){return this.request({method:"ui/message",params:n},yl,o)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,o){return this.request({method:"ui/update-model-context",params:n},Pt,o)}openLink(n,o){return this.request({method:"ui/open-link",params:n},bl,o)}downloadFile(n,o){return this.request({method:"ui/download-file",params:n},wl,o)}requestDisplayMode(n,o){return this.request({method:"ui/request-display-mode",params:n},$l,o)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,o=0,r=0,s=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let a=document.documentElement,c=a.style.width,l=a.style.height;a.style.width="fit-content",a.style.height="max-content";let f=a.getBoundingClientRect();a.style.width=c,a.style.height=l;let h=window.innerWidth-a.clientWidth,g=Math.ceil(f.width+h),v=Math.ceil(f.height);(g!==o||v!==r)&&(o=g,r=v,this.sendSizeChanged({width:g,height:v}))}))};s();let i=new ResizeObserver(s);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(n=new ml(window.parent,window.parent),o){var r;if(this.transport)throw Error("App is already connected. Call close() before connecting again.");await super.connect(n);try{let s=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:pl}},Ol,o);if(s===void 0)throw Error(`Server sent invalid initialize result: ${s}`);this._hostCapabilities=s.hostCapabilities,this._hostInfo=s.hostInfo,this._hostContext=s.hostContext,await this.notification({method:"ui/notifications/initialized"}),(r=this.options)!=null&&r.autoResize&&this.setupSizeChangedNotifications()}catch(s){throw this.close(),s}}}function Dl(e){var t=`#version 300 es
84
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:d().optional().describe("User's language and region preference in BCP 47 format."),timeZone:d().optional().describe("User's timezone in IANA format."),userAgent:d().optional().describe("Host application identifier."),platform:R([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p({touch:M().optional().describe("Whether the device supports touch input."),hover:M().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p({top:z().describe("Top safe area inset in pixels."),right:z().describe("Right safe area inset in pixels."),bottom:z().describe("Bottom safe area inset in pixels."),left:z().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),Zl=p({method:u("ui/notifications/host-context-changed"),params:zo.describe("Partial context update containing only changed fields.")});p({method:u("ui/update-model-context"),params:p({content:T(je).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:x(d(),O().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});p({method:u("ui/initialize"),params:p({appInfo:ct.describe("App identification (name and version)."),appCapabilities:Pl.describe("Features and capabilities this app provides."),protocolVersion:d().describe("Protocol version this app supports.")})});var Ol=p({protocolVersion:d().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:ct.describe("Host application identification and version."),hostCapabilities:Il.describe("Features and capabilities provided by the host."),hostContext:zo.describe("Rich context about the host environment.")}).passthrough();function Nl(e){let t=document.documentElement;t.setAttribute("data-theme",e),t.style.colorScheme=e}function Al(e,t=document.documentElement){for(let[n,o]of Object.entries(e))o!==void 0&&t.style.setProperty(n,o)}class Ml extends hl{constructor(n,o={},r={autoResize:!0}){super(r);Q(this,"_appInfo");Q(this,"_capabilities");Q(this,"options");Q(this,"_hostCapabilities");Q(this,"_hostInfo");Q(this,"_hostContext");Q(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=o,this.options=r,this.setRequestHandler(ut,s=>(console.log("Received ping:",s.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(n){this.setNotificationHandler(Sl,o=>n(o.params))}set ontoolinputpartial(n){this.setNotificationHandler(kl,o=>n(o.params))}set ontoolresult(n){this.setNotificationHandler(xl,o=>n(o.params))}set ontoolcancelled(n){this.setNotificationHandler(Tl,o=>n(o.params))}set onhostcontextchanged(n){this.setNotificationHandler(Zl,o=>{this._hostContext={...this._hostContext,...o.params},n(o.params)})}set onteardown(n){this.setRequestHandler(El,(o,r)=>n(o.params,r))}set oncalltool(n){this.setRequestHandler(ko,(o,r)=>n(o.params,r))}set onlisttools(n){this.setRequestHandler(So,(o,r)=>n(o.params,r))}assertCapabilityForMethod(n){}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,o){if(typeof n=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${n}"). Did you mean: callServerTool({ name: "${n}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:n},lt,o)}async readServerResource(n,o){return await this.request({method:"resources/read",params:n},bo,o)}async listServerResources(n,o){return await this.request({method:"resources/list",params:n},vo,o)}sendMessage(n,o){return this.request({method:"ui/message",params:n},yl,o)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,o){return this.request({method:"ui/update-model-context",params:n},Pt,o)}openLink(n,o){return this.request({method:"ui/open-link",params:n},bl,o)}downloadFile(n,o){return this.request({method:"ui/download-file",params:n},wl,o)}requestTeardown(n={}){return this.notification({method:"ui/notifications/request-teardown",params:n})}requestDisplayMode(n,o){return this.request({method:"ui/request-display-mode",params:n},$l,o)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,o=0,r=0,s=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let a=document.documentElement,c=a.style.width,l=a.style.height;a.style.width="fit-content",a.style.height="max-content";let f=a.getBoundingClientRect();a.style.width=c,a.style.height=l;let h=window.innerWidth-a.clientWidth,g=Math.ceil(f.width+h),v=Math.ceil(f.height);(g!==o||v!==r)&&(o=g,r=v,this.sendSizeChanged({width:g,height:v}))}))};s();let i=new ResizeObserver(s);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(n=new ml(window.parent,window.parent),o){var r;if(this.transport)throw Error("App is already connected. Call close() before connecting again.");await super.connect(n);try{let s=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:pl}},Ol,o);if(s===void 0)throw Error(`Server sent invalid initialize result: ${s}`);this._hostCapabilities=s.hostCapabilities,this._hostInfo=s.hostInfo,this._hostContext=s.hostContext,await this.notification({method:"ui/notifications/initialized"}),(r=this.options)!=null&&r.autoResize&&this.setupSizeChangedNotifications()}catch(s){throw this.close(),s}}}function Dl(e){var t=`#version 300 es
85
85
  #ifdef GL_ES
86
86
  precision highp float;
87
87
  precision highp int;
@@ -121,7 +121,7 @@ container holding the app. Specify either width or maxWidth, and either height o
121
121
  gl_Position = vec4(vertexInPosition, 0.0, 1.0);
122
122
  }
123
123
  `,o=new Float32Array([-1,-1,1,-1,-1,1,1,1,-1,1,1,-1]);var r={alpha:!1,depth:!1,stencil:!1,premultipliedAlpha:!1,antialias:!0,preserveDrawingBuffer:!1,powerPreference:"high-performance"},s=document.getElementById(e).getContext("webgl2",r),i=!1,a=0,c=0,l,f=0,h={x:0,y:0,clickX:0,clickY:0},g=!1,v="",y={},S={},$={},W={},N={},re={},H={},k={},J={},Z,ae=()=>{s.getExtension("OES_texture_float_linear"),s.getExtension("OES_texture_half_float_linear"),s.getExtension("EXT_color_buffer_float"),s.getExtension("WEBGL_debug_shaders"),["A","B","C","D","Image"].forEach(b=>{y[b]="",S[b]={},H[b]=null,k[b]={},b!="Image"&&($[b]=te(),W[b]=te(),N[b]=Fe($[b]),re[b]=Fe(W[b]),J[b]=!1)}),Z=s.createBuffer(),s.bindBuffer(s.ARRAY_BUFFER,Z),s.bufferData(s.ARRAY_BUFFER,o,s.STATIC_DRAW),s.viewport(0,0,s.canvas.width,s.canvas.height);var _=document.getElementById(e);window.addEventListener("resize",function(){s.canvas.width=_.width,s.canvas.height=_.height,s.viewport(0,0,s.canvas.width,s.canvas.height)}),_.addEventListener("mousemove",b=>{g&&(h.x=b.offsetX,h.y=_.height-b.offsetY)}),_.addEventListener("mousedown",b=>{g=!0;var j=b.offsetX,A=_.height-b.offsetY;h.x=j,h.y=A,h.clickX=j,h.clickY=A}),_.addEventListener("mouseup",()=>{g=!1,h.clickX=-Math.abs(h.clickX),h.clickY=-Math.abs(h.clickY)}),_.addEventListener("contextmenu",b=>{b.preventDefault()}),_.addEventListener("touchstart",b=>{if(b.preventDefault(),b.touches.length>0){var j=b.touches[0],A=_.getBoundingClientRect(),P=j.clientX-A.left,He=_.height-(j.clientY-A.top);g=!0,h.x=P,h.y=He,h.clickX=P,h.clickY=He}},{passive:!1}),_.addEventListener("touchmove",b=>{if(b.preventDefault(),g&&b.touches.length>0){var j=b.touches[0],A=_.getBoundingClientRect();h.x=j.clientX-A.left,h.y=_.height-(j.clientY-A.top)}},{passive:!1}),_.addEventListener("touchend",b=>{b.preventDefault(),g=!1,h.clickX=-Math.abs(h.clickX),h.clickY=-Math.abs(h.clickY)},{passive:!1}),_.addEventListener("touchcancel",()=>{g=!1,h.clickX=-Math.abs(h.clickX),h.clickY=-Math.abs(h.clickY)})},te=()=>{var _=s.createTexture();return s.bindTexture(s.TEXTURE_2D,_),s.texImage2D(s.TEXTURE_2D,0,s.RGBA32F,s.canvas.width,s.canvas.height,0,s.RGBA,s.FLOAT,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),_},Fe=_=>{var b=s.createFramebuffer();return s.bindFramebuffer(s.FRAMEBUFFER,b),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,_,0),s.bindTexture(s.TEXTURE_2D,null),s.bindFramebuffer(s.FRAMEBUFFER,null),b},Wt=_=>{var b=s.createShader(s.VERTEX_SHADER);if(s.shaderSource(b,n),s.compileShader(b),!s.getShaderParameter(b,s.COMPILE_STATUS))return console.error("Vertex Shader compilation failed: "+s.getShaderInfoLog(b)),s.deleteShader(b),null;var j=t+v+y[_],A=s.createShader(s.FRAGMENT_SHADER);if(s.shaderSource(A,j),s.compileShader(A),!s.getShaderParameter(A,s.COMPILE_STATUS))return console.error("Fragment Shader compilation failed: "+s.getShaderInfoLog(A)),console.error(j),s.deleteShader(A),null;var P=s.createProgram();return s.attachShader(P,b),s.attachShader(P,A),s.linkProgram(P),s.getProgramParameter(P,s.LINK_STATUS)?(k[_].iResolution=s.getUniformLocation(P,"iResolution"),k[_].iTime=s.getUniformLocation(P,"iTime"),k[_].iTimeDelta=s.getUniformLocation(P,"iTimeDelta"),k[_].iFrameRate=s.getUniformLocation(P,"iFrameRate"),k[_].iFrame=s.getUniformLocation(P,"iFrame"),k[_].iChannelTime=s.getUniformLocation(P,"iChannelTime[0]"),k[_].iChannelResolution=s.getUniformLocation(P,"iChannelResolution[0]"),k[_].iChannel0=s.getUniformLocation(P,"iChannel0"),k[_].iChannel1=s.getUniformLocation(P,"iChannel1"),k[_].iChannel2=s.getUniformLocation(P,"iChannel2"),k[_].iChannel3=s.getUniformLocation(P,"iChannel3"),k[_].iMouse=s.getUniformLocation(P,"iMouse"),k[_].iDate=s.getUniformLocation(P,"iDate"),k[_].iSampleRate=s.getUniformLocation(P,"iSampleRate"),k[_].vertexInPosition=s.getAttribLocation(P,"vertexInPosition"),P):(console.error("Program initialization failed: "+s.getProgramInfoLog(P)),null)},Xt=(_,b)=>{let j=[];for(let A=0;A<_;A++)j=[...j,...b];return j},Pe=(_,b)=>{if(_){_.source&&(y[b]=_.source,H[b]=Wt(b),H[b]==null&&console.error("Failed to compile "+b));for(let A=0;A<4;A++){var j=_[`iChannel${A}`];(j=="A"||j=="B"||j=="C"||j=="D")&&(S[b][A]=j)}}else y[b]="",H[b]=null},Gt=()=>{var _=i?Date.now():c,b=new Date(_);a==0&&(a=_),l&&l();var j=(_-c)*.001,A=(_-a)*.001,P=[b.getFullYear(),b.getMonth(),b.getDate(),b.getTime()*.001],He=new Float32Array(Xt(4,[A])),$o=new Float32Array(Xt(4,[s.canvas.width,s.canvas.height,0]));["A","B","C","D","Image"].forEach(D=>{if(H[D]){if(D==="Image")s.bindFramebuffer(s.FRAMEBUFFER,null);else{var Co=J[D]?re[D]:N[D];s.bindFramebuffer(s.FRAMEBUFFER,Co)}for(let Je=0;Je<4;Je++){var Be=S[D][Je];if(Be){var xo=J[Be]?$[Be]:W[Be];s.activeTexture(s[`TEXTURE${Je}`]),s.bindTexture(s.TEXTURE_2D,xo)}}s.useProgram(H[D]),s.uniform3f(k[D].iResolution,s.canvas.width,s.canvas.height,1),s.uniform1f(k[D].iTime,A),s.uniform1f(k[D].iTimeDelta,j),s.uniform1f(k[D].iFrameRate,60),s.uniform1i(k[D].iFrame,f),s.uniform1fv(k[D].iChannelTime,He),s.uniform3fv(k[D].iChannelResolution,$o),s.uniform1i(k[D].iChannel0,0),s.uniform1i(k[D].iChannel1,1),s.uniform1i(k[D].iChannel2,2),s.uniform1i(k[D].iChannel3,3),s.uniform4f(k[D].iMouse,h.x,h.y,h.clickX,h.clickY),s.uniform4f(k[D].iDate,P[0],P[1],P[2],P[3]),s.uniform1f(k[D].iSampleRate,44100),s.viewport(0,0,s.canvas.width,s.canvas.height),s.bindBuffer(s.ARRAY_BUFFER,Z),s.vertexAttribPointer(k[D].vertexInPosition,2,s.FLOAT,!1,0,0),s.enableVertexAttribArray(k[D].vertexInPosition),s.drawArrays(s.TRIANGLES,0,6),J[D]=!J[D]}}),c=_,f++},Kt=()=>{i&&(Gt(),requestAnimationFrame(Kt))};this.setCommon=_=>{_===void 0&&(_=""),_===null&&(_=""),v=_,["A","B","C","D","Image"].forEach(b=>{H[b]&&(H[b]=Wt(b))})},this.setBufferA=_=>{Pe(_,"A")},this.setBufferB=_=>{Pe(_,"B")},this.setBufferC=_=>{Pe(_,"C")},this.setBufferD=_=>{Pe(_,"D")},this.setImage=_=>{Pe(_,"Image")},this.setOnDraw=_=>{l=_},this.addTexture=(_,b)=>{$[b]=_,W[b]=_,J[b]=!1},this.time=()=>(c-a)*.001,this.isPlaying=()=>i,this.reset=()=>{var _=new Date;a=_,c=_,f=0,Gt()},this.pause=()=>{i=!1},this.play=()=>{if(!i){i=!0;var _=Date.now(),b=c-a;a=_-b,c=_,Kt()}},ae()}function ql(e){return typeof e=="object"&&e!==null&&typeof e.fragmentShader=="string"}const ve={info:console.log.bind(console,"[APP]"),warn:console.warn.bind(console,"[APP]"),error:console.error.bind(console,"[APP]")},Vt=document.querySelector(".main"),nt=document.getElementById("canvas"),Ce=document.getElementById("code-preview"),Ro=document.getElementById("fullscreen-btn");let ke="inline";function Eo(){nt.width=window.innerWidth,nt.height=window.innerHeight}Eo();window.addEventListener("resize",Eo);function Io(e){var t;if(e.theme&&Nl(e.theme),(t=e.styles)!=null&&t.variables&&Al(e.styles.variables),e.availableDisplayModes!==void 0){const n=e.availableDisplayModes.includes("fullscreen");Ro.classList.toggle("available",n)}e.displayMode&&(ke=e.displayMode,Vt.classList.toggle("fullscreen",ke==="fullscreen"))}document.addEventListener("keydown",e=>{e.key==="Escape"&&ke==="fullscreen"&&Po()});async function Po(){const e=ke==="fullscreen"?"inline":"fullscreen";try{ke=(await pe.requestDisplayMode({mode:e})).mode,Vt.classList.toggle("fullscreen",ke==="fullscreen")}catch(t){ve.error("Failed to change display mode:",t)}}Ro.addEventListener("click",Po);let X=null;const pe=new Ml({name:"ShaderToy Renderer",version:"1.0.0"});pe.onteardown=async()=>(ve.info("App is being torn down"),X&&X.pause(),{});pe.ontoolinputpartial=e=>{var n;Ce.classList.add("visible"),nt.classList.add("hidden");const t=(n=e.arguments)==null?void 0:n.fragmentShader;Ce.textContent=typeof t=="string"?t:"",Ce.scrollTop=Ce.scrollHeight};pe.ontoolinput=e=>{if(ve.info("Received shader input"),Ce.classList.remove("visible"),nt.classList.remove("hidden"),!ql(e.arguments)){ve.error("Invalid tool input");return}const{fragmentShader:t,common:n,bufferA:o,bufferB:r,bufferC:s,bufferD:i}=e.arguments;X||(X=new Dl("canvas")),X.setCommon(n||""),o&&X.setBufferA({source:o,iChannel0:"A"}),r&&X.setBufferB({source:r,iChannel1:"B"}),s&&X.setBufferC({source:s,iChannel2:"C"}),i&&X.setBufferD({source:i,iChannel3:"D"}),X.setImage({source:t,iChannel0:o?"A":void 0,iChannel1:r?"B":void 0,iChannel2:s?"C":void 0,iChannel3:i?"D":void 0}),X.play(),ve.info("Setup complete")};pe.onerror=ve.error;pe.onhostcontextchanged=Io;const Ll=new IntersectionObserver(e=>{e.forEach(t=>{t.isIntersecting?X==null||X.play():X==null||X.pause()})});Ll.observe(Vt);pe.connect().then(()=>{ve.info("Connected to host");const e=pe.getHostContext();e&&Io(e)});</script>
124
- <style rel="stylesheet" crossorigin>*{box-sizing:border-box}html,body{font-family:system-ui,-apple-system,sans-serif;font-size:1rem}code{font-size:1em}html,body{margin:0;width:100%;height:100%;min-height:400px;overflow:hidden}.main{position:relative;width:100%;height:100%;min-height:400px;border-radius:var(--border-radius-lg);overflow:hidden}.main.fullscreen{border-radius:0}#canvas{width:100%;height:100%;display:block}#canvas.hidden{display:none}#code-preview{display:none;width:100%;height:100%;margin:0;padding:16px;box-sizing:border-box;overflow:auto;background:linear-gradient(135deg,var(--color-background-secondary) 0%,var(--color-background-tertiary) 100%);color:var(--color-text-ghost);font-family:var(--font-mono);font-size:var(--font-text-xs-size);line-height:var(--font-text-xs-line-height);white-space:pre-wrap}#code-preview.visible{display:block}.fullscreen-btn{position:absolute;bottom:16px;right:16px;width:40px;height:40px;border:none;border-radius:8px;background:#0009;color:#fff;cursor:pointer;display:none;align-items:center;justify-content:center;transition:background .2s,opacity .2s;opacity:0;z-index:100}.fullscreen-btn:hover{background:#000c;opacity:1}.fullscreen-btn svg{width:20px;height:20px}.fullscreen-btn .collapse-icon{display:none}.fullscreen-btn.available{display:flex}.main:hover .fullscreen-btn.available{opacity:.7}.main.fullscreen .fullscreen-btn .expand-icon{display:none}.main.fullscreen .fullscreen-btn .collapse-icon{display:block}</style>
124
+ <style rel="stylesheet" crossorigin>*{box-sizing:border-box}html,body{font-family:system-ui,-apple-system,sans-serif;font-size:1rem}code{font-size:1em}html,body{margin:0;width:100%;height:100%;min-height:400px;overflow:hidden}.main{position:relative;width:100%;height:100%;min-height:400px;border-radius:var(--border-radius-lg);overflow:hidden}.main.fullscreen{border-radius:0}#canvas{width:100%;height:100%;display:block;touch-action:none}#canvas.hidden{display:none}#code-preview{display:none;width:100%;height:100%;margin:0;padding:16px;box-sizing:border-box;overflow:auto;background:linear-gradient(135deg,var(--color-background-secondary) 0%,var(--color-background-tertiary) 100%);color:var(--color-text-ghost);font-family:var(--font-mono);font-size:var(--font-text-xs-size);line-height:var(--font-text-xs-line-height);white-space:pre-wrap}#code-preview.visible{display:block}.fullscreen-btn{position:absolute;bottom:16px;right:16px;width:40px;height:40px;border:none;border-radius:8px;background:#0009;color:#fff;cursor:pointer;display:none;align-items:center;justify-content:center;transition:background .2s,opacity .2s;opacity:0;z-index:100}.fullscreen-btn:hover{background:#000c;opacity:1}.fullscreen-btn svg{width:20px;height:20px}.fullscreen-btn .collapse-icon{display:none}.fullscreen-btn.available{display:flex}.main:hover .fullscreen-btn.available{opacity:.7}.main.fullscreen .fullscreen-btn .expand-icon{display:none}.main.fullscreen .fullscreen-btn .collapse-icon{display:block}</style>
125
125
  </head>
126
126
  <body>
127
127
  <main class="main">
package/dist/server.js CHANGED
@@ -147,22 +147,22 @@ var require_code = __commonJS((exports) => {
147
147
  i2++;
148
148
  }
149
149
  }
150
- function mergeExprItems(a2, b2) {
151
- if (b2 === '""')
150
+ function mergeExprItems(a2, b) {
151
+ if (b === '""')
152
152
  return a2;
153
153
  if (a2 === '""')
154
- return b2;
154
+ return b;
155
155
  if (typeof a2 == "string") {
156
- if (b2 instanceof Name || a2[a2.length - 1] !== '"')
156
+ if (b instanceof Name || a2[a2.length - 1] !== '"')
157
157
  return;
158
- if (typeof b2 != "string")
159
- return `${a2.slice(0, -1)}${b2}"`;
160
- if (b2[0] === '"')
161
- return a2.slice(0, -1) + b2.slice(1);
158
+ if (typeof b != "string")
159
+ return `${a2.slice(0, -1)}${b}"`;
160
+ if (b[0] === '"')
161
+ return a2.slice(0, -1) + b.slice(1);
162
162
  return;
163
163
  }
164
- if (typeof b2 == "string" && b2[0] === '"' && !(a2 instanceof Name))
165
- return `"${a2}${b2.slice(1)}`;
164
+ if (typeof b == "string" && b[0] === '"' && !(a2 instanceof Name))
165
+ return `"${a2}${b.slice(1)}`;
166
166
  return;
167
167
  }
168
168
  function strConcat(c1, c2) {
@@ -1997,43 +1997,43 @@ var require_subschema = __commonJS((exports) => {
1997
1997
 
1998
1998
  // ../../node_modules/fast-deep-equal/index.js
1999
1999
  var require_fast_deep_equal = __commonJS((exports, module) => {
2000
- module.exports = function equal(a2, b2) {
2001
- if (a2 === b2)
2000
+ module.exports = function equal(a2, b) {
2001
+ if (a2 === b)
2002
2002
  return true;
2003
- if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
2004
- if (a2.constructor !== b2.constructor)
2003
+ if (a2 && b && typeof a2 == "object" && typeof b == "object") {
2004
+ if (a2.constructor !== b.constructor)
2005
2005
  return false;
2006
2006
  var length, i2, keys;
2007
2007
  if (Array.isArray(a2)) {
2008
2008
  length = a2.length;
2009
- if (length != b2.length)
2009
+ if (length != b.length)
2010
2010
  return false;
2011
2011
  for (i2 = length;i2-- !== 0; )
2012
- if (!equal(a2[i2], b2[i2]))
2012
+ if (!equal(a2[i2], b[i2]))
2013
2013
  return false;
2014
2014
  return true;
2015
2015
  }
2016
2016
  if (a2.constructor === RegExp)
2017
- return a2.source === b2.source && a2.flags === b2.flags;
2017
+ return a2.source === b.source && a2.flags === b.flags;
2018
2018
  if (a2.valueOf !== Object.prototype.valueOf)
2019
- return a2.valueOf() === b2.valueOf();
2019
+ return a2.valueOf() === b.valueOf();
2020
2020
  if (a2.toString !== Object.prototype.toString)
2021
- return a2.toString() === b2.toString();
2021
+ return a2.toString() === b.toString();
2022
2022
  keys = Object.keys(a2);
2023
2023
  length = keys.length;
2024
- if (length !== Object.keys(b2).length)
2024
+ if (length !== Object.keys(b).length)
2025
2025
  return false;
2026
2026
  for (i2 = length;i2-- !== 0; )
2027
- if (!Object.prototype.hasOwnProperty.call(b2, keys[i2]))
2027
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i2]))
2028
2028
  return false;
2029
2029
  for (i2 = length;i2-- !== 0; ) {
2030
2030
  var key = keys[i2];
2031
- if (!equal(a2[key], b2[key]))
2031
+ if (!equal(a2[key], b[key]))
2032
2032
  return false;
2033
2033
  }
2034
2034
  return true;
2035
2035
  }
2036
- return a2 !== a2 && b2 !== b2;
2036
+ return a2 !== a2 && b !== b;
2037
2037
  };
2038
2038
  });
2039
2039
 
@@ -27025,8 +27025,8 @@ class j {
27025
27025
  sessionId;
27026
27026
  setProtocolVersion;
27027
27027
  }
27028
- var b = exports_external.union([exports_external.literal("light"), exports_external.literal("dark")]).describe("Color theme preference for the host environment.");
27029
- var L = exports_external.union([exports_external.literal("inline"), exports_external.literal("fullscreen"), exports_external.literal("pip")]).describe("Display mode for UI presentation.");
27028
+ var g = exports_external.union([exports_external.literal("light"), exports_external.literal("dark")]).describe("Color theme preference for the host environment.");
27029
+ var G = exports_external.union([exports_external.literal("inline"), exports_external.literal("fullscreen"), exports_external.literal("pip")]).describe("Display mode for UI presentation.");
27030
27030
  var i = exports_external.union([exports_external.literal("--color-background-primary"), exports_external.literal("--color-background-secondary"), exports_external.literal("--color-background-tertiary"), exports_external.literal("--color-background-inverse"), exports_external.literal("--color-background-ghost"), exports_external.literal("--color-background-info"), exports_external.literal("--color-background-danger"), exports_external.literal("--color-background-success"), exports_external.literal("--color-background-warning"), exports_external.literal("--color-background-disabled"), exports_external.literal("--color-text-primary"), exports_external.literal("--color-text-secondary"), exports_external.literal("--color-text-tertiary"), exports_external.literal("--color-text-inverse"), exports_external.literal("--color-text-ghost"), exports_external.literal("--color-text-info"), exports_external.literal("--color-text-danger"), exports_external.literal("--color-text-success"), exports_external.literal("--color-text-warning"), exports_external.literal("--color-text-disabled"), exports_external.literal("--color-border-primary"), exports_external.literal("--color-border-secondary"), exports_external.literal("--color-border-tertiary"), exports_external.literal("--color-border-inverse"), exports_external.literal("--color-border-ghost"), exports_external.literal("--color-border-info"), exports_external.literal("--color-border-danger"), exports_external.literal("--color-border-success"), exports_external.literal("--color-border-warning"), exports_external.literal("--color-border-disabled"), exports_external.literal("--color-ring-primary"), exports_external.literal("--color-ring-secondary"), exports_external.literal("--color-ring-inverse"), exports_external.literal("--color-ring-info"), exports_external.literal("--color-ring-danger"), exports_external.literal("--color-ring-success"), exports_external.literal("--color-ring-warning"), exports_external.literal("--font-sans"), exports_external.literal("--font-mono"), exports_external.literal("--font-weight-normal"), exports_external.literal("--font-weight-medium"), exports_external.literal("--font-weight-semibold"), exports_external.literal("--font-weight-bold"), exports_external.literal("--font-text-xs-size"), exports_external.literal("--font-text-sm-size"), exports_external.literal("--font-text-md-size"), exports_external.literal("--font-text-lg-size"), exports_external.literal("--font-heading-xs-size"), exports_external.literal("--font-heading-sm-size"), exports_external.literal("--font-heading-md-size"), exports_external.literal("--font-heading-lg-size"), exports_external.literal("--font-heading-xl-size"), exports_external.literal("--font-heading-2xl-size"), exports_external.literal("--font-heading-3xl-size"), exports_external.literal("--font-text-xs-line-height"), exports_external.literal("--font-text-sm-line-height"), exports_external.literal("--font-text-md-line-height"), exports_external.literal("--font-text-lg-line-height"), exports_external.literal("--font-heading-xs-line-height"), exports_external.literal("--font-heading-sm-line-height"), exports_external.literal("--font-heading-md-line-height"), exports_external.literal("--font-heading-lg-line-height"), exports_external.literal("--font-heading-xl-line-height"), exports_external.literal("--font-heading-2xl-line-height"), exports_external.literal("--font-heading-3xl-line-height"), exports_external.literal("--border-radius-xs"), exports_external.literal("--border-radius-sm"), exports_external.literal("--border-radius-md"), exports_external.literal("--border-radius-lg"), exports_external.literal("--border-radius-xl"), exports_external.literal("--border-radius-full"), exports_external.literal("--border-width-regular"), exports_external.literal("--shadow-hairline"), exports_external.literal("--shadow-sm"), exports_external.literal("--shadow-md"), exports_external.literal("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming.");
27031
27031
  var o = exports_external.record(i.describe(`Style variables for theming MCP apps.
27032
27032
 
@@ -27061,15 +27061,16 @@ var t = exports_external.object({ method: exports_external.literal("ui/notificat
27061
27061
  var A = exports_external.object({ method: exports_external.literal("ui/notifications/tool-input"), params: exports_external.object({ arguments: exports_external.record(exports_external.string(), exports_external.unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.") }) });
27062
27062
  var P = exports_external.object({ method: exports_external.literal("ui/notifications/tool-input-partial"), params: exports_external.object({ arguments: exports_external.record(exports_external.string(), exports_external.unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).") }) });
27063
27063
  var H = exports_external.object({ method: exports_external.literal("ui/notifications/tool-cancelled"), params: exports_external.object({ reason: exports_external.string().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").') }) });
27064
- var g = exports_external.object({ fonts: exports_external.string().optional() });
27065
- var C = exports_external.object({ variables: o.optional().describe("CSS variables for theming the app."), css: g.optional().describe("CSS blocks that apps can inject.") });
27064
+ var S = exports_external.object({ fonts: exports_external.string().optional() });
27065
+ var y = exports_external.object({ variables: o.optional().describe("CSS variables for theming the app."), css: S.optional().describe("CSS blocks that apps can inject.") });
27066
27066
  var _ = exports_external.object({ method: exports_external.literal("ui/resource-teardown"), params: exports_external.object({}) });
27067
27067
  var e = exports_external.record(exports_external.string(), exports_external.unknown());
27068
27068
  var q = exports_external.object({ text: exports_external.object({}).optional().describe("Host supports text content blocks."), image: exports_external.object({}).optional().describe("Host supports image content blocks."), audio: exports_external.object({}).optional().describe("Host supports audio content blocks."), resource: exports_external.object({}).optional().describe("Host supports resource content blocks."), resourceLink: exports_external.object({}).optional().describe("Host supports resource link content blocks."), structuredContent: exports_external.object({}).optional().describe("Host supports structured content.") });
27069
- var y = exports_external.object({ experimental: exports_external.object({}).optional().describe("Experimental features (structure TBD)."), openLinks: exports_external.object({}).optional().describe("Host supports opening external URLs."), downloadFile: exports_external.object({}).optional().describe("Host supports file downloads via ui/download-file."), serverTools: exports_external.object({ listChanged: exports_external.boolean().optional().describe("Host supports tools/list_changed notifications.") }).optional().describe("Host can proxy tool calls to the MCP server."), serverResources: exports_external.object({ listChanged: exports_external.boolean().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."), logging: exports_external.object({}).optional().describe("Host accepts log messages."), sandbox: exports_external.object({ permissions: K.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."), csp: B.optional().describe("CSP domains approved by the host.") }).optional().describe("Sandbox configuration applied by the host."), updateModelContext: q.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."), message: q.optional().describe("Host supports receiving content messages (ui/message) from the view.") });
27070
- var u = exports_external.object({ experimental: exports_external.object({}).optional().describe("Experimental features (structure TBD)."), tools: exports_external.object({ listChanged: exports_external.boolean().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."), availableDisplayModes: exports_external.array(L).optional().describe("Display modes the app supports.") });
27071
- var QQ = exports_external.object({ method: exports_external.literal("ui/notifications/initialized"), params: exports_external.object({}).optional() });
27072
- var ZQ = exports_external.object({ csp: B.optional().describe("Content Security Policy configuration for UI resources."), permissions: K.optional().describe("Sandbox permissions requested by the UI resource."), domain: exports_external.string().optional().describe(`Dedicated origin for view sandbox.
27069
+ var QQ = exports_external.object({ method: exports_external.literal("ui/notifications/request-teardown"), params: exports_external.object({}).optional() });
27070
+ var C = exports_external.object({ experimental: exports_external.object({}).optional().describe("Experimental features (structure TBD)."), openLinks: exports_external.object({}).optional().describe("Host supports opening external URLs."), downloadFile: exports_external.object({}).optional().describe("Host supports file downloads via ui/download-file."), serverTools: exports_external.object({ listChanged: exports_external.boolean().optional().describe("Host supports tools/list_changed notifications.") }).optional().describe("Host can proxy tool calls to the MCP server."), serverResources: exports_external.object({ listChanged: exports_external.boolean().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."), logging: exports_external.object({}).optional().describe("Host accepts log messages."), sandbox: exports_external.object({ permissions: K.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."), csp: B.optional().describe("CSP domains approved by the host.") }).optional().describe("Sandbox configuration applied by the host."), updateModelContext: q.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."), message: q.optional().describe("Host supports receiving content messages (ui/message) from the view.") });
27071
+ var f = exports_external.object({ experimental: exports_external.object({}).optional().describe("Experimental features (structure TBD)."), tools: exports_external.object({ listChanged: exports_external.boolean().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."), availableDisplayModes: exports_external.array(G).optional().describe("Display modes the app supports.") });
27072
+ var ZQ = exports_external.object({ method: exports_external.literal("ui/notifications/initialized"), params: exports_external.object({}).optional() });
27073
+ var $Q = exports_external.object({ csp: B.optional().describe("Content Security Policy configuration for UI resources."), permissions: K.optional().describe("Sandbox permissions requested by the UI resource."), domain: exports_external.string().optional().describe(`Dedicated origin for view sandbox.
27073
27074
 
27074
27075
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
27075
27076
 
@@ -27084,27 +27085,27 @@ Boolean requesting whether a visible border and background is provided by the ho
27084
27085
  - \`true\`: request visible border + background
27085
27086
  - \`false\`: request no visible border + background
27086
27087
  - omitted: host decides border`) });
27087
- var $Q = exports_external.object({ method: exports_external.literal("ui/request-display-mode"), params: exports_external.object({ mode: L.describe("The display mode being requested.") }) });
27088
- var T = exports_external.object({ mode: L.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough();
27089
- var f = exports_external.union([exports_external.literal("model"), exports_external.literal("app")]).describe("Tool visibility scope - who can access the tool.");
27090
- var JQ = exports_external.object({ resourceUri: exports_external.string().optional(), visibility: exports_external.array(f).optional().describe(`Who can access this tool. Default: ["model", "app"]
27088
+ var JQ = exports_external.object({ method: exports_external.literal("ui/request-display-mode"), params: exports_external.object({ mode: G.describe("The display mode being requested.") }) });
27089
+ var T = exports_external.object({ mode: G.describe("The display mode that was actually set. May differ from requested if not supported.") }).passthrough();
27090
+ var u = exports_external.union([exports_external.literal("model"), exports_external.literal("app")]).describe("Tool visibility scope - who can access the tool.");
27091
+ var XQ = exports_external.object({ resourceUri: exports_external.string().optional(), visibility: exports_external.array(u).optional().describe(`Who can access this tool. Default: ["model", "app"]
27091
27092
  - "model": Tool visible to and callable by the agent
27092
27093
  - "app": Tool callable by the app from this server only`) });
27093
- var kQ = exports_external.object({ mimeTypes: exports_external.array(exports_external.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.') });
27094
- var XQ = exports_external.object({ method: exports_external.literal("ui/download-file"), params: exports_external.object({ contents: exports_external.array(exports_external.union([EmbeddedResourceSchema, ResourceLinkSchema])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.") }) });
27095
- var VQ = exports_external.object({ method: exports_external.literal("ui/message"), params: exports_external.object({ role: exports_external.literal("user").describe('Message role, currently only "user" is supported.'), content: exports_external.array(ContentBlockSchema).describe("Message content blocks (text, image, etc.).") }) });
27096
- var DQ = exports_external.object({ method: exports_external.literal("ui/notifications/sandbox-resource-ready"), params: exports_external.object({ html: exports_external.string().describe("HTML content to load into the inner iframe."), sandbox: exports_external.string().optional().describe("Optional override for the inner iframe's sandbox attribute."), csp: B.optional().describe("CSP configuration from resource metadata."), permissions: K.optional().describe("Sandbox permissions from resource metadata.") }) });
27097
- var U = exports_external.object({ method: exports_external.literal("ui/notifications/tool-result"), params: CallToolResultSchema.describe("Standard MCP tool execution result.") });
27098
- var k = exports_external.object({ toolInfo: exports_external.object({ id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."), tool: ToolSchema.describe("Tool definition including name, inputSchema, etc.") }).optional().describe("Metadata of the tool call that instantiated this App."), theme: b.optional().describe("Current color theme preference."), styles: C.optional().describe("Style configuration for theming the app."), displayMode: L.optional().describe("How the UI is currently displayed."), availableDisplayModes: exports_external.array(L).optional().describe("Display modes the host supports."), containerDimensions: exports_external.union([exports_external.object({ height: exports_external.number().describe("Fixed container height in pixels.") }), exports_external.object({ maxHeight: exports_external.union([exports_external.number(), exports_external.undefined()]).optional().describe("Maximum container height in pixels.") })]).and(exports_external.union([exports_external.object({ width: exports_external.number().describe("Fixed container width in pixels.") }), exports_external.object({ maxWidth: exports_external.union([exports_external.number(), exports_external.undefined()]).optional().describe("Maximum container width in pixels.") })])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
27094
+ var RQ = exports_external.object({ mimeTypes: exports_external.array(exports_external.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.') });
27095
+ var VQ = exports_external.object({ method: exports_external.literal("ui/download-file"), params: exports_external.object({ contents: exports_external.array(exports_external.union([EmbeddedResourceSchema, ResourceLinkSchema])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.") }) });
27096
+ var DQ = exports_external.object({ method: exports_external.literal("ui/message"), params: exports_external.object({ role: exports_external.literal("user").describe('Message role, currently only "user" is supported.'), content: exports_external.array(ContentBlockSchema).describe("Message content blocks (text, image, etc.).") }) });
27097
+ var GQ = exports_external.object({ method: exports_external.literal("ui/notifications/sandbox-resource-ready"), params: exports_external.object({ html: exports_external.string().describe("HTML content to load into the inner iframe."), sandbox: exports_external.string().optional().describe("Optional override for the inner iframe's sandbox attribute."), csp: B.optional().describe("CSP configuration from resource metadata."), permissions: K.optional().describe("Sandbox permissions from resource metadata.") }) });
27098
+ var E = exports_external.object({ method: exports_external.literal("ui/notifications/tool-result"), params: CallToolResultSchema.describe("Standard MCP tool execution result.") });
27099
+ var k = exports_external.object({ toolInfo: exports_external.object({ id: RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."), tool: ToolSchema.describe("Tool definition including name, inputSchema, etc.") }).optional().describe("Metadata of the tool call that instantiated this App."), theme: g.optional().describe("Current color theme preference."), styles: y.optional().describe("Style configuration for theming the app."), displayMode: G.optional().describe("How the UI is currently displayed."), availableDisplayModes: exports_external.array(G).optional().describe("Display modes the host supports."), containerDimensions: exports_external.union([exports_external.object({ height: exports_external.number().describe("Fixed container height in pixels.") }), exports_external.object({ maxHeight: exports_external.union([exports_external.number(), exports_external.undefined()]).optional().describe("Maximum container height in pixels.") })]).and(exports_external.union([exports_external.object({ width: exports_external.number().describe("Fixed container width in pixels.") }), exports_external.object({ maxWidth: exports_external.union([exports_external.number(), exports_external.undefined()]).optional().describe("Maximum container width in pixels.") })])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
27099
27100
  container holding the app. Specify either width or maxWidth, and either height or maxHeight.`), locale: exports_external.string().optional().describe("User's language and region preference in BCP 47 format."), timeZone: exports_external.string().optional().describe("User's timezone in IANA format."), userAgent: exports_external.string().optional().describe("Host application identifier."), platform: exports_external.union([exports_external.literal("web"), exports_external.literal("desktop"), exports_external.literal("mobile")]).optional().describe("Platform type for responsive design decisions."), deviceCapabilities: exports_external.object({ touch: exports_external.boolean().optional().describe("Whether the device supports touch input."), hover: exports_external.boolean().optional().describe("Whether the device supports hover interactions.") }).optional().describe("Device input capabilities."), safeAreaInsets: exports_external.object({ top: exports_external.number().describe("Top safe area inset in pixels."), right: exports_external.number().describe("Right safe area inset in pixels."), bottom: exports_external.number().describe("Bottom safe area inset in pixels."), left: exports_external.number().describe("Left safe area inset in pixels.") }).optional().describe("Mobile safe area boundaries in pixels.") }).passthrough();
27100
- var E = exports_external.object({ method: exports_external.literal("ui/notifications/host-context-changed"), params: k.describe("Partial context update containing only changed fields.") });
27101
+ var R = exports_external.object({ method: exports_external.literal("ui/notifications/host-context-changed"), params: k.describe("Partial context update containing only changed fields.") });
27101
27102
  var LQ = exports_external.object({ method: exports_external.literal("ui/update-model-context"), params: exports_external.object({ content: exports_external.array(ContentBlockSchema).optional().describe("Context content blocks (text, image, etc.)."), structuredContent: exports_external.record(exports_external.string(), exports_external.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.") }) });
27102
- var GQ = exports_external.object({ method: exports_external.literal("ui/initialize"), params: exports_external.object({ appInfo: ImplementationSchema.describe("App identification (name and version)."), appCapabilities: u.describe("Features and capabilities this app provides."), protocolVersion: exports_external.string().describe("Protocol version this app supports.") }) });
27103
- var R = exports_external.object({ protocolVersion: exports_external.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'), hostInfo: ImplementationSchema.describe("Host application identification and version."), hostCapabilities: y.describe("Features and capabilities provided by the host."), hostContext: k.describe("Rich context about the host environment.") }).passthrough();
27103
+ var WQ = exports_external.object({ method: exports_external.literal("ui/initialize"), params: exports_external.object({ appInfo: ImplementationSchema.describe("App identification (name and version)."), appCapabilities: f.describe("Features and capabilities this app provides."), protocolVersion: exports_external.string().describe("Protocol version this app supports.") }) });
27104
+ var U = exports_external.object({ protocolVersion: exports_external.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'), hostInfo: ImplementationSchema.describe("Host application identification and version."), hostCapabilities: C.describe("Features and capabilities provided by the host."), hostContext: k.describe("Rich context about the host environment.") }).passthrough();
27104
27105
  var v = "ui/resourceUri";
27105
27106
  var d = "text/html;profile=mcp-app";
27106
27107
 
27107
- class qQ extends Protocol {
27108
+ class OQ extends Protocol {
27108
27109
  _appInfo;
27109
27110
  _capabilities;
27110
27111
  options;
@@ -27136,13 +27137,13 @@ class qQ extends Protocol {
27136
27137
  this.setNotificationHandler(P, ($) => Z($.params));
27137
27138
  }
27138
27139
  set ontoolresult(Z) {
27139
- this.setNotificationHandler(U, ($) => Z($.params));
27140
+ this.setNotificationHandler(E, ($) => Z($.params));
27140
27141
  }
27141
27142
  set ontoolcancelled(Z) {
27142
27143
  this.setNotificationHandler(H, ($) => Z($.params));
27143
27144
  }
27144
27145
  set onhostcontextchanged(Z) {
27145
- this.setNotificationHandler(E, ($) => {
27146
+ this.setNotificationHandler(R, ($) => {
27146
27147
  this._hostContext = { ...this._hostContext, ...$.params }, Z($.params);
27147
27148
  });
27148
27149
  }
@@ -27204,6 +27205,9 @@ class qQ extends Protocol {
27204
27205
  downloadFile(Z, $) {
27205
27206
  return this.request({ method: "ui/download-file", params: Z }, I, $);
27206
27207
  }
27208
+ requestTeardown(Z = {}) {
27209
+ return this.notification({ method: "ui/notifications/request-teardown", params: Z });
27210
+ }
27207
27211
  requestDisplayMode(Z, $) {
27208
27212
  return this.request({ method: "ui/request-display-mode", params: Z }, T, $);
27209
27213
  }
@@ -27216,11 +27220,11 @@ class qQ extends Protocol {
27216
27220
  return;
27217
27221
  Z = true, requestAnimationFrame(() => {
27218
27222
  Z = false;
27219
- let V = document.documentElement, G = V.style.width, W = V.style.height;
27223
+ let V = document.documentElement, L = V.style.width, W = V.style.height;
27220
27224
  V.style.width = "fit-content", V.style.height = "max-content";
27221
- let M = V.getBoundingClientRect();
27222
- V.style.width = G, V.style.height = W;
27223
- let h = window.innerWidth - V.clientWidth, N = Math.ceil(M.width + h), Y = Math.ceil(M.height);
27225
+ let x = V.getBoundingClientRect();
27226
+ V.style.width = L, V.style.height = W;
27227
+ let h = window.innerWidth - V.clientWidth, N = Math.ceil(x.width + h), Y = Math.ceil(x.height);
27224
27228
  if (N !== $ || Y !== J)
27225
27229
  $ = N, J = Y, this.sendSizeChanged({ width: N, height: Y });
27226
27230
  });
@@ -27234,7 +27238,7 @@ class qQ extends Protocol {
27234
27238
  throw Error("App is already connected. Call close() before connecting again.");
27235
27239
  await super.connect(Z);
27236
27240
  try {
27237
- let J = await this.request({ method: "ui/initialize", params: { appCapabilities: this._capabilities, appInfo: this._appInfo, protocolVersion: F } }, R, $);
27241
+ let J = await this.request({ method: "ui/initialize", params: { appCapabilities: this._capabilities, appInfo: this._appInfo, protocolVersion: F } }, U, $);
27238
27242
  if (J === undefined)
27239
27243
  throw Error(`Server sent invalid initialize result: ${J}`);
27240
27244
  if (this._hostCapabilities = J.hostCapabilities, this._hostInfo = J.hostInfo, this._hostContext = J.hostContext, await this.notification({ method: "ui/notifications/initialized" }), this.options?.autoResize)
@@ -27244,15 +27248,15 @@ class qQ extends Protocol {
27244
27248
  }
27245
27249
  }
27246
27250
  }
27247
- function uZ(Z, $, J, X) {
27248
- let D = J._meta, V = D.ui, G = D[v], W = D;
27249
- if (V?.resourceUri && !G)
27251
+ function hZ(Z, $, J, X) {
27252
+ let D = J._meta, V = D.ui, L = D[v], W = D;
27253
+ if (V?.resourceUri && !L)
27250
27254
  W = { ...D, [v]: V.resourceUri };
27251
- else if (G && !V?.resourceUri)
27252
- W = { ...D, ui: { ...V, resourceUri: G } };
27255
+ else if (L && !V?.resourceUri)
27256
+ W = { ...D, ui: { ...V, resourceUri: L } };
27253
27257
  return Z.registerTool($, { ...J, _meta: W }, X);
27254
27258
  }
27255
- function fZ(Z, $, J, X, D) {
27259
+ function mZ(Z, $, J, X, D) {
27256
27260
  return Z.registerResource($, J, { mimeType: d, ...X }, D);
27257
27261
  }
27258
27262
 
@@ -28554,7 +28558,7 @@ function createServer() {
28554
28558
  version: "1.0.0"
28555
28559
  });
28556
28560
  const resourceUri = "ui://shadertoy/mcp-app.html";
28557
- uZ(server, "render-shadertoy", {
28561
+ hZ(server, "render-shadertoy", {
28558
28562
  title: "ShaderToy Renderer",
28559
28563
  description: TOOL_DESCRIPTION,
28560
28564
  inputSchema: exports_external.object({
@@ -28571,7 +28575,7 @@ function createServer() {
28571
28575
  content: [{ type: "text", text: "Shader rendered successfully" }]
28572
28576
  };
28573
28577
  });
28574
- fZ(server, resourceUri, resourceUri, { mimeType: d }, async () => {
28578
+ mZ(server, resourceUri, resourceUri, { mimeType: d }, async () => {
28575
28579
  const html = await fs.readFile(path.join(DIST_DIR, "mcp-app.html"), "utf-8");
28576
28580
  return {
28577
28581
  contents: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelcontextprotocol/server-shadertoy",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "MCP App Server example for rendering ShaderToy-compatible GLSL shaders",
6
6
  "repository": {