@ulearning/ai-generative-frame 0.0.0-stage → 1.0.0-next.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/LICENSE +21 -0
- package/README.md +233 -2
- package/dist/assistant-ui/entry.d.ts +34 -0
- package/dist/assistant-ui/entry.d.ts.map +1 -0
- package/dist/assistant-ui/entry.js +50 -0
- package/dist/assistant-ui/entry.js.map +1 -0
- package/dist/assistant-ui/extension.d.ts +18 -0
- package/dist/assistant-ui/extension.d.ts.map +1 -0
- package/dist/assistant-ui/extension.js +0 -0
- package/dist/assistant-ui/history.d.ts +15 -0
- package/dist/assistant-ui/history.d.ts.map +1 -0
- package/dist/assistant-ui/history.js +39 -0
- package/dist/assistant-ui/history.js.map +1 -0
- package/dist/assistant-ui/modelContext.d.ts +45 -0
- package/dist/assistant-ui/modelContext.d.ts.map +1 -0
- package/dist/assistant-ui/modelContext.js +88 -0
- package/dist/assistant-ui/modelContext.js.map +1 -0
- package/dist/assistant-ui/snapshotSaver.d.ts +11 -0
- package/dist/assistant-ui/snapshotSaver.d.ts.map +1 -0
- package/dist/assistant-ui/snapshotSaver.js +83 -0
- package/dist/assistant-ui/snapshotSaver.js.map +1 -0
- package/dist/assistant-ui/tool-calls.d.ts +21 -0
- package/dist/assistant-ui/tool-calls.d.ts.map +1 -0
- package/dist/assistant-ui/tool-calls.js +65 -0
- package/dist/assistant-ui/tool-calls.js.map +1 -0
- package/dist/assistant-ui/toolkit.d.ts +96 -0
- package/dist/assistant-ui/toolkit.d.ts.map +1 -0
- package/dist/assistant-ui/toolkit.js +456 -0
- package/dist/assistant-ui/toolkit.js.map +1 -0
- package/dist/assistant-ui/useSharedContext.d.ts +14 -0
- package/dist/assistant-ui/useSharedContext.d.ts.map +1 -0
- package/dist/assistant-ui/useSharedContext.js +27 -0
- package/dist/assistant-ui/useSharedContext.js.map +1 -0
- package/dist/assistant-ui.d.ts +3 -0
- package/dist/assistant-ui.d.ts.map +1 -0
- package/dist/assistant-ui.js +1 -0
- package/dist/bootstrap.d.ts +23 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +78 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/csp.d.ts +25 -0
- package/dist/csp.d.ts.map +1 -0
- package/dist/csp.js +78 -0
- package/dist/csp.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/json-schema.d.ts +70 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +163 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/preview.d.ts +30 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +60 -0
- package/dist/preview.js.map +1 -0
- package/dist/prompts/guidance.d.ts +41 -0
- package/dist/prompts/guidance.d.ts.map +1 -0
- package/dist/prompts/guidance.js +268 -0
- package/dist/prompts/guidance.js.map +1 -0
- package/dist/prompts.d.ts +2 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +1 -0
- package/dist/protocol.d.ts +114 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +49 -0
- package/dist/protocol.js.map +1 -0
- package/dist/repair/repair.d.ts +72 -0
- package/dist/repair/repair.d.ts.map +1 -0
- package/dist/repair/repair.js +103 -0
- package/dist/repair/repair.js.map +1 -0
- package/dist/repair.d.ts +2 -0
- package/dist/repair.d.ts.map +1 -0
- package/dist/repair.js +1 -0
- package/dist/rpc.d.ts +60 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +127 -0
- package/dist/rpc.js.map +1 -0
- package/dist/runtime/diagnostics.d.ts +17 -0
- package/dist/runtime/diagnostics.d.ts.map +1 -0
- package/dist/runtime/diagnostics.js +128 -0
- package/dist/runtime/diagnostics.js.map +1 -0
- package/dist/runtime/generated.d.ts +2 -0
- package/dist/runtime/generated.d.ts.map +1 -0
- package/dist/runtime/generated.js +5 -0
- package/dist/runtime/generated.js.map +1 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +264 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/morph.d.ts +51 -0
- package/dist/runtime/morph.d.ts.map +1 -0
- package/dist/runtime/morph.js +251 -0
- package/dist/runtime/morph.js.map +1 -0
- package/dist/runtime/screenshot.d.ts +23 -0
- package/dist/runtime/screenshot.d.ts.map +1 -0
- package/dist/runtime/screenshot.js +188 -0
- package/dist/runtime/screenshot.js.map +1 -0
- package/dist/runtime/size.d.ts +10 -0
- package/dist/runtime/size.d.ts.map +1 -0
- package/dist/runtime/size.js +21 -0
- package/dist/runtime/size.js.map +1 -0
- package/dist/runtime/storage.d.ts +4 -0
- package/dist/runtime/storage.d.ts.map +1 -0
- package/dist/runtime/storage.js +38 -0
- package/dist/runtime/storage.js.map +1 -0
- package/dist/spec/actions.d.ts +40 -0
- package/dist/spec/actions.d.ts.map +1 -0
- package/dist/spec/actions.js +53 -0
- package/dist/spec/actions.js.map +1 -0
- package/dist/spec/assistant-ui/thread.d.ts +66 -0
- package/dist/spec/assistant-ui/thread.d.ts.map +1 -0
- package/dist/spec/assistant-ui/thread.js +252 -0
- package/dist/spec/assistant-ui/thread.js.map +1 -0
- package/dist/spec/assistant-ui/toolkit.d.ts +33 -0
- package/dist/spec/assistant-ui/toolkit.d.ts.map +1 -0
- package/dist/spec/assistant-ui/toolkit.js +142 -0
- package/dist/spec/assistant-ui/toolkit.js.map +1 -0
- package/dist/spec/assistant-ui/web.d.ts +6 -0
- package/dist/spec/assistant-ui/web.d.ts.map +1 -0
- package/dist/spec/assistant-ui/web.js +48 -0
- package/dist/spec/assistant-ui/web.js.map +1 -0
- package/dist/spec/assistant-ui.d.ts +3 -0
- package/dist/spec/assistant-ui.d.ts.map +1 -0
- package/dist/spec/assistant-ui.js +1 -0
- package/dist/spec/calc.d.ts +8 -0
- package/dist/spec/calc.d.ts.map +1 -0
- package/dist/spec/calc.js +498 -0
- package/dist/spec/calc.js.map +1 -0
- package/dist/spec/catalog.d.ts +52 -0
- package/dist/spec/catalog.d.ts.map +1 -0
- package/dist/spec/catalog.js +104 -0
- package/dist/spec/catalog.js.map +1 -0
- package/dist/spec/expressions.d.ts +45 -0
- package/dist/spec/expressions.d.ts.map +1 -0
- package/dist/spec/expressions.js +199 -0
- package/dist/spec/expressions.js.map +1 -0
- package/dist/spec/patch.d.ts +20 -0
- package/dist/spec/patch.d.ts.map +1 -0
- package/dist/spec/patch.js +77 -0
- package/dist/spec/patch.js.map +1 -0
- package/dist/spec/pending.d.ts +15 -0
- package/dist/spec/pending.d.ts.map +1 -0
- package/dist/spec/pending.js +33 -0
- package/dist/spec/pending.js.map +1 -0
- package/dist/spec/pointer.d.ts +17 -0
- package/dist/spec/pointer.d.ts.map +1 -0
- package/dist/spec/pointer.js +88 -0
- package/dist/spec/pointer.js.map +1 -0
- package/dist/spec/prompt.d.ts +29 -0
- package/dist/spec/prompt.d.ts.map +1 -0
- package/dist/spec/prompt.js +145 -0
- package/dist/spec/prompt.js.map +1 -0
- package/dist/spec/render-spec.d.ts +50 -0
- package/dist/spec/render-spec.d.ts.map +1 -0
- package/dist/spec/render-spec.js +104 -0
- package/dist/spec/render-spec.js.map +1 -0
- package/dist/spec/resolve.d.ts +39 -0
- package/dist/spec/resolve.d.ts.map +1 -0
- package/dist/spec/resolve.js +51 -0
- package/dist/spec/resolve.js.map +1 -0
- package/dist/spec/resolved.d.ts +3 -0
- package/dist/spec/resolved.d.ts.map +1 -0
- package/dist/spec/resolved.js +36 -0
- package/dist/spec/resolved.js.map +1 -0
- package/dist/spec/state.d.ts +34 -0
- package/dist/spec/state.d.ts.map +1 -0
- package/dist/spec/state.js +111 -0
- package/dist/spec/state.js.map +1 -0
- package/dist/spec/stream.d.ts +50 -0
- package/dist/spec/stream.d.ts.map +1 -0
- package/dist/spec/stream.js +168 -0
- package/dist/spec/stream.js.map +1 -0
- package/dist/spec/tools.d.ts +3 -0
- package/dist/spec/tools.d.ts.map +1 -0
- package/dist/spec/tools.js +3 -0
- package/dist/spec/tree.d.ts +21 -0
- package/dist/spec/tree.d.ts.map +1 -0
- package/dist/spec/tree.js +27 -0
- package/dist/spec/tree.js.map +1 -0
- package/dist/spec/types.d.ts +66 -0
- package/dist/spec/types.d.ts.map +1 -0
- package/dist/spec/types.js +9 -0
- package/dist/spec/types.js.map +1 -0
- package/dist/spec/validate.d.ts +32 -0
- package/dist/spec/validate.d.ts.map +1 -0
- package/dist/spec/validate.js +264 -0
- package/dist/spec/validate.js.map +1 -0
- package/dist/spec/vue/SpecRenderer.d.ts +43 -0
- package/dist/spec/vue/SpecRenderer.d.ts.map +1 -0
- package/dist/spec/vue/SpecRenderer.js +357 -0
- package/dist/spec/vue/SpecRenderer.js.map +1 -0
- package/dist/spec/vue/useSpecStream.d.ts +19 -0
- package/dist/spec/vue/useSpecStream.d.ts.map +1 -0
- package/dist/spec/vue/useSpecStream.js +115 -0
- package/dist/spec/vue/useSpecStream.js.map +1 -0
- package/dist/spec/vue.d.ts +3 -0
- package/dist/spec/vue.d.ts.map +1 -0
- package/dist/spec/vue.js +3 -0
- package/dist/spec.d.ts +12 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +8 -0
- package/dist/theme.d.ts +38 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +370 -0
- package/dist/theme.js.map +1 -0
- package/dist/tools/define.d.ts +43 -0
- package/dist/tools/define.d.ts.map +1 -0
- package/dist/tools/define.js +31 -0
- package/dist/tools/define.js.map +1 -0
- package/dist/tools/edits.d.ts +19 -0
- package/dist/tools/edits.d.ts.map +1 -0
- package/dist/tools/edits.js +55 -0
- package/dist/tools/edits.js.map +1 -0
- package/dist/tools/registry.d.ts +19 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +33 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/tools.d.ts +88 -0
- package/dist/tools/tools.d.ts.map +1 -0
- package/dist/tools/tools.js +235 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +5 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/vue/Widget.d.ts +16 -0
- package/dist/vue/Widget.d.ts.map +1 -0
- package/dist/vue/Widget.js +58 -0
- package/dist/vue/Widget.js.map +1 -0
- package/dist/vue/sync.d.ts +19 -0
- package/dist/vue/sync.d.ts.map +1 -0
- package/dist/vue/sync.js +31 -0
- package/dist/vue/sync.js.map +1 -0
- package/dist/vue/themeStore.d.ts +23 -0
- package/dist/vue/themeStore.d.ts.map +1 -0
- package/dist/vue/themeStore.js +115 -0
- package/dist/vue/themeStore.js.map +1 -0
- package/dist/vue/useThemeTokens.d.ts +6 -0
- package/dist/vue/useThemeTokens.d.ts.map +1 -0
- package/dist/vue/useThemeTokens.js +49 -0
- package/dist/vue/useThemeTokens.js.map +1 -0
- package/dist/vue/useWidget.d.ts +10 -0
- package/dist/vue/useWidget.d.ts.map +1 -0
- package/dist/vue/useWidget.js +81 -0
- package/dist/vue/useWidget.js.map +1 -0
- package/dist/vue.d.ts +5 -0
- package/dist/vue.d.ts.map +1 -0
- package/dist/vue.js +4 -0
- package/dist/widget.d.ts +129 -0
- package/dist/widget.d.ts.map +1 -0
- package/dist/widget.js +655 -0
- package/dist/widget.js.map +1 -0
- package/package.json +125 -3
- package/src/assistant-ui/entry.ts +124 -0
- package/src/assistant-ui/extension.ts +19 -0
- package/src/assistant-ui/history.ts +63 -0
- package/src/assistant-ui/modelContext.ts +162 -0
- package/src/assistant-ui/snapshotSaver.ts +116 -0
- package/src/assistant-ui/tool-calls.ts +115 -0
- package/src/assistant-ui/toolkit.tsx +747 -0
- package/src/assistant-ui/useSharedContext.ts +40 -0
- package/src/assistant-ui.ts +14 -0
- package/src/bootstrap.ts +112 -0
- package/src/csp.ts +96 -0
- package/src/index.ts +44 -0
- package/src/json-schema.ts +353 -0
- package/src/preview.ts +120 -0
- package/src/prompts/guidance.ts +369 -0
- package/src/prompts.ts +8 -0
- package/src/protocol.ts +141 -0
- package/src/repair/repair.ts +202 -0
- package/src/repair.ts +11 -0
- package/src/rpc.ts +228 -0
- package/src/runtime/diagnostics.ts +165 -0
- package/src/runtime/generated.ts +2 -0
- package/src/runtime/index.ts +343 -0
- package/src/runtime/morph.ts +352 -0
- package/src/runtime/screenshot.ts +288 -0
- package/src/runtime/size.ts +17 -0
- package/src/runtime/storage.ts +49 -0
- package/src/spec/actions.ts +111 -0
- package/src/spec/assistant-ui/thread.ts +381 -0
- package/src/spec/assistant-ui/toolkit.tsx +295 -0
- package/src/spec/assistant-ui/web.tsx +63 -0
- package/src/spec/assistant-ui.ts +2 -0
- package/src/spec/calc.ts +598 -0
- package/src/spec/catalog.ts +196 -0
- package/src/spec/expressions.ts +301 -0
- package/src/spec/patch.ts +112 -0
- package/src/spec/pending.ts +36 -0
- package/src/spec/pointer.ts +170 -0
- package/src/spec/prompt.ts +243 -0
- package/src/spec/render-spec.ts +144 -0
- package/src/spec/resolve.ts +123 -0
- package/src/spec/resolved.ts +53 -0
- package/src/spec/state.ts +193 -0
- package/src/spec/stream.ts +230 -0
- package/src/spec/tools.ts +17 -0
- package/src/spec/tree.ts +37 -0
- package/src/spec/types.ts +51 -0
- package/src/spec/validate.ts +429 -0
- package/src/spec/vue/SpecRenderer.tsx +544 -0
- package/src/spec/vue/__tests__/harness.ts +50 -0
- package/src/spec/vue/useSpecStream.ts +162 -0
- package/src/spec/vue.ts +13 -0
- package/src/spec.ts +55 -0
- package/src/theme.ts +423 -0
- package/src/tools/define.ts +65 -0
- package/src/tools/edits.ts +73 -0
- package/src/tools/registry.ts +44 -0
- package/src/tools/tools.ts +361 -0
- package/src/tools.ts +32 -0
- package/src/version.ts +4 -0
- package/src/vue/Widget.tsx +74 -0
- package/src/vue/sync.ts +36 -0
- package/src/vue/themeStore.ts +157 -0
- package/src/vue/useThemeTokens.ts +71 -0
- package/src/vue/useWidget.ts +117 -0
- package/src/vue.ts +8 -0
- package/src/widget.ts +1080 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","names":[],"sources":["../../src/runtime/diagnostics.ts"],"sourcesContent":["import type { ConsoleEntry, ConsoleLevel, WidgetError } from \"../protocol\";\n\nconst MAX_CONSOLE = 200;\nconst MAX_ERRORS = 50;\nconst MAX_MESSAGE = 1000;\n\nconst LEVELS: readonly ConsoleLevel[] = [\n \"log\",\n \"info\",\n \"warn\",\n \"error\",\n \"debug\",\n];\n\nconst truncate = (text: string) =>\n text.length > MAX_MESSAGE ? `${text.slice(0, MAX_MESSAGE)}…` : text;\n\nexport const formatValue = (value: unknown): string => {\n if (typeof value === \"string\") return value;\n if (value instanceof Error)\n return value.stack ?? `${value.name}: ${value.message}`;\n if (typeof value === \"object\" && value !== null) {\n if (typeof Node !== \"undefined\" && value instanceof Node) {\n return `<${value.nodeName.toLowerCase()}>`;\n }\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n }\n return String(value);\n};\n\nexport type Diagnostics = {\n readonly errors: WidgetError[];\n readonly console: ConsoleEntry[];\n record(error: WidgetError): void;\n dispose(): void;\n};\n\nexport type DiagnosticsOptions = {\n onError?: (error: WidgetError) => void;\n onConsole?: (entry: ConsoleEntry) => void;\n};\n\n/** Captures errors, console output, failed resources, and CSP violations in a window. */\nexport function installDiagnostics(\n win: Window & typeof globalThis,\n options: DiagnosticsOptions = {},\n): Diagnostics {\n const errors: WidgetError[] = [];\n const consoleEntries: ConsoleEntry[] = [];\n\n const record = (error: WidgetError) => {\n const normalized: WidgetError = {\n ...error,\n message: truncate(error.message),\n };\n if (errors.length < MAX_ERRORS) errors.push(normalized);\n options.onError?.(normalized);\n };\n\n const onError = (event: ErrorEvent | Event) => {\n const target = event.target;\n if (target && target !== win && target instanceof win.Element) {\n const src =\n target.getAttribute(\"src\") ?? target.getAttribute(\"href\") ?? undefined;\n record({\n kind: \"resource\",\n message: `Failed to load <${target.localName}>${src ? ` ${src}` : \"\"}`,\n ...(src ? { source: src } : {}),\n });\n return;\n }\n const e = event as ErrorEvent;\n const stack = e.error instanceof Error ? e.error.stack : undefined;\n record({\n kind: \"error\",\n message: e.message || formatValue(e.error),\n ...(e.filename ? { source: e.filename } : {}),\n ...(e.lineno ? { line: e.lineno } : {}),\n ...(e.colno ? { column: e.colno } : {}),\n ...(stack ? { stack: truncate(stack) } : {}),\n });\n };\n\n const onRejection = (event: PromiseRejectionEvent) => {\n const reason: unknown = event.reason;\n const stack = reason instanceof Error ? reason.stack : undefined;\n record({\n kind: \"unhandledrejection\",\n message: reason instanceof Error ? reason.message : formatValue(reason),\n ...(stack ? { stack: truncate(stack) } : {}),\n });\n };\n\n const onViolation = (event: SecurityPolicyViolationEvent) => {\n record({\n kind: \"csp\",\n message: `Blocked by Content Security Policy (${event.effectiveDirective}): ${event.blockedURI || \"inline\"}`,\n ...(event.blockedURI ? { source: event.blockedURI } : {}),\n ...(event.lineNumber ? { line: event.lineNumber } : {}),\n });\n };\n\n win.addEventListener(\"error\", onError, true);\n win.addEventListener(\"unhandledrejection\", onRejection);\n win.document.addEventListener(\"securitypolicyviolation\", onViolation);\n\n const originals = new Map<ConsoleLevel, (...args: unknown[]) => void>();\n for (const level of LEVELS) {\n const original = win.console[level];\n originals.set(level, original);\n win.console[level] = (...args: unknown[]) => {\n const entry: ConsoleEntry = {\n level,\n message: truncate(args.map(formatValue).join(\" \")),\n };\n consoleEntries.push(entry);\n if (consoleEntries.length > MAX_CONSOLE) consoleEntries.shift();\n options.onConsole?.(entry);\n original.apply(win.console, args);\n };\n }\n\n return {\n errors,\n console: consoleEntries,\n record,\n dispose() {\n win.removeEventListener(\"error\", onError, true);\n win.removeEventListener(\"unhandledrejection\", onRejection);\n win.document.removeEventListener(\"securitypolicyviolation\", onViolation);\n for (const [level, original] of originals) win.console[level] = original;\n },\n };\n}\n\nconst VISUAL_SELECTOR =\n \"svg, canvas, img, video, picture, iframe, input, button, select, textarea, progress, meter\";\n\n/** True when the widget rendered nothing a person could see. */\nexport function isBlankRender(root: HTMLElement): boolean {\n const rect = root.getBoundingClientRect();\n if (rect.height < 2 || rect.width < 2) return true;\n if ((root.textContent ?? \"\").trim().length > 0) return false;\n for (const el of Array.from(root.querySelectorAll(VISUAL_SELECTOR))) {\n const r = el.getBoundingClientRect();\n if (r.width >= 2 && r.height >= 2) return false;\n }\n for (const el of Array.from(root.querySelectorAll(\"*\"))) {\n const style = root.ownerDocument.defaultView?.getComputedStyle(el);\n if (!style) continue;\n const painted =\n (style.backgroundColor !== \"rgba(0, 0, 0, 0)\" &&\n style.backgroundColor !== \"transparent\") ||\n style.backgroundImage !== \"none\" ||\n parseFloat(style.borderTopWidth) > 0;\n if (!painted) continue;\n const r = el.getBoundingClientRect();\n if (r.width >= 2 && r.height >= 2) return false;\n }\n return true;\n}\n"],"mappings":";AAEA,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,cAAc;AAEpB,MAAM,SAAkC;CACtC;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,YAAY,SAChB,KAAK,SAAS,cAAc,GAAG,KAAK,MAAM,GAAG,WAAW,EAAE,KAAK;AAEjE,MAAa,eAAe,UAA2B;CACrD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,iBAAiB,OACnB,OAAO,MAAM,SAAS,GAAG,MAAM,KAAK,IAAI,MAAM;CAChD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,IAAI,OAAO,SAAS,eAAe,iBAAiB,MAClD,OAAO,IAAI,MAAM,SAAS,YAAY,EAAE;EAE1C,IAAI;GACF,OAAO,KAAK,UAAU,KAAK;EAC7B,QAAQ;GACN,OAAO,OAAO,KAAK;EACrB;CACF;CACA,OAAO,OAAO,KAAK;AACrB;;AAeA,SAAgB,mBACd,KACA,UAA8B,CAAC,GAClB;CAC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iBAAiB,eAAe,CAAC,GAAG;EACnE,MAAM,IAAI,GAAG,sBAAsB;EACnC,IAAI,EAAE,SAAS,KAAK,EAAE,UAAU,GAAG,OAAO;CAC5C;CACA,KAAK,MAAM,MAAM,MAAM,KAAK,KAAK,iBAAiB,GAAG,CAAC,GAAG;EACvD,MAAM,QAAQ,KAAK,cAAc,aAAa,iBAAiB,EAAE;EACjE,IAAI,CAAC,OAAO;EAMZ,IAAI,EAJD,MAAM,oBAAoB,sBACzB,MAAM,oBAAoB,iBAC5B,MAAM,oBAAoB,UAC1B,WAAW,MAAM,cAAc,IAAI,IACvB;EACd,MAAM,IAAI,GAAG,sBAAsB;EACnC,IAAI,EAAE,SAAS,KAAK,EAAE,UAAU,GAAG,OAAO;CAC5C;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated.d.ts","mappings":"AACA,eAAO,MAAM,aAAa,EAAE,MAAm0kB","names":[],"ignoreList":[],"sources":["../../src/runtime/generated.ts"],"sourcesContent":[null]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// src/runtime/generated.ts
|
|
2
|
+
const runtimeSource = "(function(){let e={write:`genframe/write`,end:`genframe/end`,replace:`genframe/replace`,screenshot:`genframe/screenshot`,inspect:`genframe/inspect`,clearStorage:`genframe/clear-storage`,hostContextChanged:`ui/notifications/host-context-changed`,toolInputPartial:`ui/notifications/tool-input-partial`,toolInput:`ui/notifications/tool-input`,toolResult:`ui/notifications/tool-result`,ready:`genframe/ready`,initialize:`ui/initialize`,initialized:`ui/notifications/initialized`,sizeChanged:`ui/notifications/size-changed`,openLink:`ui/open-link`,message:`ui/message`,callTool:`tools/call`,requestDisplayMode:`ui/request-display-mode`,updateModelContext:`ui/update-model-context`,copyText:`genframe/copy-text`,widgetState:`genframe/widget-state`,log:`genframe/log`,error:`genframe/error`},t=/^<svg[\\s>/]/i;function n(e){let n=e.trimStart();if(n.startsWith(`<?xml`)){let e=n.indexOf(`>`);if(e===-1)return`html`;n=n.slice(e+1).trimStart()}for(;n.startsWith(`<!--`);){let e=n.indexOf(`-->`,4);if(e===-1)return`html`;n=n.slice(e+3).trimStart()}return t.test(n)?`svg`:`html`}let r={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603};var i=class extends Error{code;data;constructor(e,t,n){super(t),this.name=`RpcError`,this.code=e,this.data=n}};let a=e=>typeof e==`object`&&!!e;function o(e){return a(e)&&e.jsonrpc===`2.0`}let s=e=>e instanceof i?{code:e.code,message:e.message,...e.data===void 0?{}:{data:e.data}}:{code:r.internalError,message:e instanceof Error?e.message:String(e)};function c(e,t={}){let n=1,a=!1,c=/* @__PURE__ */ new Map,l=t=>{a||e.postMessage(t)},u=async(e,n)=>{try{if(!t.onRequest)throw new i(r.methodNotFound,`Unknown method: ${e.method}`);let a=await t.onRequest(e.method,e.params);n({jsonrpc:`2.0`,id:e.id,result:a??null})}catch(t){n({jsonrpc:`2.0`,id:e.id,error:s(t)})}},d=(e,n=l)=>{if(a||!o(e))return;let r=`id`in e&&(typeof e.id==`string`||typeof e.id==`number`);if(`method`in e&&typeof e.method==`string`){if(r)u(e,n);else try{t.onNotification?.(e.method,e.params)}catch{}return}if(!r)return;let s=e,d=c.get(s.id);d&&(c.delete(s.id),d.timer!==void 0&&clearTimeout(d.timer),s.error?d.reject(new i(s.error.code,s.error.message,s.error.data)):d.resolve(s.result))},f=e=>d(e.data);return e.addEventListener(`message`,f),e.start?.(),{request(e,t,r){if(a)return Promise.reject(/* @__PURE__ */ Error(`RPC peer is disposed`));let i=n++;return new Promise((n,a)=>{let o=r?.timeoutMs,s=o===void 0?void 0:setTimeout(()=>{c.delete(i),a(/* @__PURE__ */ Error(`${e} timed out after ${o}ms`))},o);c.set(i,{resolve:n,reject:a,timer:s}),l({jsonrpc:`2.0`,id:i,method:e,...t===void 0?{}:{params:t}})})},notify(e,t){l({jsonrpc:`2.0`,method:e,...t===void 0?{}:{params:t}})},receive:d,dispose(){if(!a){a=!0,e.removeEventListener(`message`,f);for(let e of c.values())e.timer!==void 0&&clearTimeout(e.timer),e.reject(/* @__PURE__ */ Error(`RPC peer is disposed`));c.clear()}}}}let l=`1.0.0-next.0`,u=1e3,d=[`log`,`info`,`warn`,`error`,`debug`],f=e=>e.length>u?`${e.slice(0,u)}…`:e,p=e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;if(typeof e==`object`&&e){if(typeof Node<`u`&&e instanceof Node)return`<${e.nodeName.toLowerCase()}>`;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)};function m(e,t={}){let n=[],r=[],i=e=>{let r={...e,message:f(e.message)};n.length<50&&n.push(r),t.onError?.(r)},a=t=>{let n=t.target;if(n&&n!==e&&n instanceof e.Element){let e=n.getAttribute(`src`)??n.getAttribute(`href`)??void 0;i({kind:`resource`,message:`Failed to load <${n.localName}>${e?` ${e}`:``}`,...e?{source:e}:{}});return}let r=t,a=r.error instanceof Error?r.error.stack:void 0;i({kind:`error`,message:r.message||p(r.error),...r.filename?{source:r.filename}:{},...r.lineno?{line:r.lineno}:{},...r.colno?{column:r.colno}:{},...a?{stack:f(a)}:{}})},o=e=>{let t=e.reason,n=t instanceof Error?t.stack:void 0;i({kind:`unhandledrejection`,message:t instanceof Error?t.message:p(t),...n?{stack:f(n)}:{}})},s=e=>{i({kind:`csp`,message:`Blocked by Content Security Policy (${e.effectiveDirective}): ${e.blockedURI||`inline`}`,...e.blockedURI?{source:e.blockedURI}:{},...e.lineNumber?{line:e.lineNumber}:{}})};e.addEventListener(`error`,a,!0),e.addEventListener(`unhandledrejection`,o),e.document.addEventListener(`securitypolicyviolation`,s);let c=/* @__PURE__ */ new Map;for(let n of d){let i=e.console[n];c.set(n,i),e.console[n]=(...a)=>{let o={level:n,message:f(a.map(p).join(` `))};r.push(o),r.length>200&&r.shift(),t.onConsole?.(o),i.apply(e.console,a)}}return{errors:n,console:r,record:i,dispose(){e.removeEventListener(`error`,a,!0),e.removeEventListener(`unhandledrejection`,o),e.document.removeEventListener(`securitypolicyviolation`,s);for(let[t,n]of c)e.console[t]=n}}}function h(e){let t=e.getBoundingClientRect();if(t.height<2||t.width<2)return!0;if((e.textContent??``).trim().length>0)return!1;for(let t of Array.from(e.querySelectorAll(`svg, canvas, img, video, picture, iframe, input, button, select, textarea, progress, meter`))){let e=t.getBoundingClientRect();if(e.width>=2&&e.height>=2)return!1}for(let t of Array.from(e.querySelectorAll(`*`))){let n=e.ownerDocument.defaultView?.getComputedStyle(t);if(!n||!(n.backgroundColor!==`rgba(0, 0, 0, 0)`&&n.backgroundColor!==`transparent`||n.backgroundImage!==`none`||parseFloat(n.borderTopWidth)>0))continue;let r=t.getBoundingClientRect();if(r.width>=2&&r.height>=2)return!1}return!0}let g=/* @__PURE__ */ new Set([`style`,`script`,`meta`,`link`,`title`,`base`]);function _(e){let t=e.toLowerCase().lastIndexOf(`<style`);if(t===-1)return e;let n=e.charAt(t+6);return n!==``&&!/[\\s>/]/.test(n)||e.toLowerCase().includes(`</style`,t)?e:e.slice(0,t)}function v(e,t){let n=e.createElement(`template`);n.innerHTML=t;let r=n.content,i=[];for(let t of Array.from(r.querySelectorAll(`script`)))t.replaceWith(e.createComment(`gf-script`)),i.push(t);return{fragment:r,scripts:i}}let y=(e,t)=>{if(e.nodeType!==t.nodeType)return!1;if(e.nodeType!==Node.ELEMENT_NODE)return!0;let n=e,r=t;return n.localName===r.localName&&n.namespaceURI===r.namespaceURI&&n.getAttribute(`id`)===r.getAttribute(`id`)},b=(e,t)=>{for(let n of Array.from(t.attributes))if(e.getAttributeNS(n.namespaceURI,n.localName)!==n.value)try{n.namespaceURI?e.setAttributeNS(n.namespaceURI,n.name,n.value):e.setAttribute(n.name,n.value)}catch{}for(let n of Array.from(e.attributes))t.hasAttributeNS(n.namespaceURI,n.localName)||e.removeAttributeNS(n.namespaceURI,n.localName)},x=(e,t,n)=>{if(e.nodeType!==Node.ELEMENT_NODE){e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue);return}let r=e,i=t;b(r,i),r instanceof HTMLTemplateElement&&i instanceof HTMLTemplateElement?r.innerHTML!==i.innerHTML&&r.content.replaceChildren(i.content):S(r,i,n)};function S(e,t,n){let r=Array.from(t.childNodes),i=e.firstChild;for(let t=0;t<r.length;t++){let a=r[t];if(!i){e.appendChild(a),n.onAdded(a);continue}if(y(i,a)){x(i,a,n),i=i.nextSibling;continue}let o=r[t+1];if(o&&y(i,o)){e.insertBefore(a,i),n.onAdded(a);continue}let s=i.nextSibling;s&&y(s,a)?(i.remove(),x(s,a,n),i=s.nextSibling):(e.replaceChild(a,i),n.onAdded(a),i=s)}for(;i;){let e=i.nextSibling;i.remove(),i=e}}let C=e=>{let t=!1,n=()=>{t||(t=!0,cancelAnimationFrame(r),clearTimeout(i),e())},r=requestAnimationFrame(n),i=setTimeout(n,50);return()=>{t=!0,cancelAnimationFrame(r),clearTimeout(i)}},w=(e=()=>{})=>(t,n)=>{let r=t.ownerDocument.createElementNS(n.namespaceURI??`http://www.w3.org/1999/xhtml`,`script`);for(let e of Array.from(n.attributes))try{r.setAttribute(e.name,e.value)}catch{}r.textContent=n.textContent;let i=r.getAttribute(`src`)??r.getAttribute(`href`);return i?new Promise(n=>{let a=setTimeout(()=>{e(`Script timed out: ${i}`,i),n()},15e3);r.addEventListener(`load`,()=>{clearTimeout(a),n()}),r.addEventListener(`error`,()=>{clearTimeout(a),e(`Script failed to load: ${i}`,i),n()}),t.replaceWith(r)}):(t.replaceWith(r),Promise.resolve())},T=e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;let t=e;g.has(t.localName)||typeof t.animate!=`function`||t.animate([{opacity:0},{opacity:1}],{duration:200,easing:`ease-out`})};function E(e){let{root:t}=e,r=t.ownerDocument,i=e.schedule??C,a=e.runScript??w(e.onScriptError),o=``,s=`html`,c=!1,l=!1,u,d,f=[],p={onAdded(t){e.animate?.()&&T(t)}},m=i=>{u?.(),u=void 0;let a=i?o:_(o);if(a===d)return;d=a,s=n(o),t.dataset.kind=s;let c=v(r,a);f=c.scripts,S(t,c.fragment,p),e.onRender?.(s)},h=async()=>{let e=r.createTreeWalker(t,NodeFilter.SHOW_COMMENT),n=[];for(let t=e.nextNode();t;t=e.nextNode())t.nodeValue===`gf-script`&&n.push(t);let i=f;for(let e=0;e<n.length&&e<i.length;e++)await a(n[e],i[e]);i.length>0&&!l&&(l=!0,r.dispatchEvent(new Event(`DOMContentLoaded`,{bubbles:!0})),r.defaultView?.dispatchEvent(new Event(`load`)))};return{get source(){return o},get kind(){return s},get ended(){return c},get scriptsRan(){return l},write(e){if(c)throw Error(`Cannot write after end; use replace`);e&&(o+=e,u??=i(()=>{u=void 0,m(!1)}))},async end(){c||(c=!0,m(!0),await h())},async replace(e){c=!0,o=e,m(!0),await h()},flush(){u&&m(c)}}}let D=`http://www.w3.org/1999/xhtml`,O=`http://www.w3.org/2000/svg`,k=4096,A=/* @__PURE__ */ new Set([`script`,`noscript`,`template`]),j=e=>{let t=/* @__PURE__ */ new Map,n,r,i,a=()=>{if(n)return;i=e.createElement(`div`),i.setAttribute(`aria-hidden`,`true`),i.style.cssText=`all:initial;position:absolute;left:-99999px;top:0;visibility:hidden;contain:strict;width:0;height:0;`;let t=i.attachShadow({mode:`closed`});n=e.createElement(`div`),r=e.createElementNS(O,`svg`),n.appendChild(r),t.appendChild(n),e.body.appendChild(i)};return{get(i){let o=`${i.namespaceURI}|${i.localName}`,s=t.get(o);if(s)return s;a();let c=e.createElementNS(i.namespaceURI??D,i.localName);(i.namespaceURI===O?r:n).appendChild(c);let l=e.defaultView.getComputedStyle(c);s=/* @__PURE__ */ new Map;for(let e=0;e<l.length;e++){let t=l.item(e);s.set(t,l.getPropertyValue(t))}return c.remove(),t.set(o,s),s},dispose(){i?.remove()}}},M=(e,t,n)=>{let r=document.createElement(`canvas`);return r.width=Math.max(1,t),r.height=Math.max(1,n),r.getContext(`2d`).drawImage(e,0,0,t,n),r.toDataURL(`image/png`)},N=(e,t,n)=>{if(e.nodeType===Node.TEXT_NODE)return e.cloneNode();if(e.nodeType!==Node.ELEMENT_NODE)return null;let r=e;if(A.has(r.localName))return null;let i=r.ownerDocument.defaultView,a=i.getComputedStyle(r),o;if(r instanceof i.HTMLCanvasElement){o=r.ownerDocument.createElement(`img`);try{o.setAttribute(`src`,r.toDataURL(`image/png`))}catch{}}else if(r instanceof i.HTMLImageElement&&r.complete&&r.naturalWidth>0&&!r.src.startsWith(`data:`)){o=r.cloneNode(!1);try{o.setAttribute(`src`,M(r,r.naturalWidth,r.naturalHeight))}catch{}}else o=r.cloneNode(!1);r instanceof i.HTMLInputElement?r.type===`checkbox`||r.type===`radio`?r.checked?o.setAttribute(`checked`,``):o.removeAttribute(`checked`):o.setAttribute(`value`,r.value):r instanceof i.HTMLTextAreaElement?o.textContent=r.value:r instanceof i.HTMLSelectElement&&o.setAttribute(`data-gf-value`,r.value);let s=t.get(r),c=[];for(let e=0;e<a.length;e++){let t=a.item(e);if(t.startsWith(`--`))continue;let r=a.getPropertyValue(t);(r!==s.get(t)||n&&r!==n.getPropertyValue(t))&&c.push(`${t}:${r}`)}if((a.animationName!==`none`||a.transitionProperty!==`none`)&&c.push(`animation:none`,`transition:none`),o.setAttribute(`style`,c.join(`;`)),!(r instanceof i.HTMLTextAreaElement))for(let e of Array.from(r.childNodes)){let n=N(e,t,a);n&&o.appendChild(n)}if(r instanceof i.HTMLSelectElement)for(let e of Array.from(o.querySelectorAll(`option`)))(e.getAttribute(`value`)===r.value||e.textContent===r.value)&&e.setAttribute(`selected`,``);return o},P=e=>{let t=[];for(let n of Array.from(e.styleSheets)){let e;try{e=n.cssRules}catch{continue}for(let n of Array.from(e))n.constructor.name===`CSSFontFaceRule`&&!/url\\((?!\\s*[\"']?data:)/i.test(n.cssText)&&t.push(n.cssText)}return t.join(`\n`)},F=e=>{let t=e.getBoundingClientRect(),n=Math.max(1,Math.ceil(t.width));return{layoutWidth:n,width:Math.max(n,Math.ceil(e.scrollWidth)),height:Math.max(1,Math.ceil(Math.max(t.height,e.scrollHeight)))}},I=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(/* @__PURE__ */ Error(`The serialized widget failed to rasterize`)),r.src=e});async function L(e,t={}){let n=e.ownerDocument,r=n.defaultView;await n.fonts?.ready;let{layoutWidth:i,width:a,height:o}=F(e),s=j(n),c;try{c=N(e,s,r.getComputedStyle(n.body))}finally{s.dispose()}let l=n.createElementNS(D,`div`);l.setAttribute(`style`,`width:${a}px;height:${o}px;overflow:hidden;`),c&&l.appendChild(c),c instanceof Element&&c.setAttribute(`style`,`${c.getAttribute(`style`)??``};width:${i}px;margin:0;`);let u=P(n),d=new XMLSerializer().serializeToString(l),f=`<svg xmlns=\"${O}\" width=\"${a}\" height=\"${o}\" viewBox=\"0 0 ${a} ${o}\"><foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">`+(u?`<style xmlns=\"${D}\">${u.replace(/</g,`\\\\3c `)}</style>`:``)+d+`</foreignObject></svg>`,p=await I(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`),m=t.scale??Math.min(r.devicePixelRatio||1,2),h=Math.max(.1,Math.min(m,k/a,k/o)),g=n.createElement(`canvas`);g.width=Math.round(a*h),g.height=Math.round(o*h);let _=g.getContext(`2d`);if(!_)throw Error(`Canvas 2D context is unavailable`);let v=t.background??r.getComputedStyle(n.documentElement).getPropertyValue(`--color-background`).trim();return v&&(_.fillStyle=v,_.fillRect(0,0,g.width,g.height)),_.scale(h,h),_.drawImage(p,0,0,a,o),{dataUrl:g.toDataURL(`image/png`),width:a,height:o}}function R(e){let t=e.getBoundingClientRect();return{width:Math.ceil(t.width),height:Math.ceil(t.height)}}function z(e){let t=R(e);return t.width>0?t:void 0}async function B(e){let t=[],n=async(e,n)=>{try{await n()!==!1&&t.push(e)}catch{}};return await n(`localStorage`,()=>e.localStorage.clear()),await n(`sessionStorage`,()=>e.sessionStorage.clear()),await n(`indexedDB`,async()=>{let t=e.indexedDB;if(typeof t?.databases!=`function`)return!1;let n=await t.databases();return await Promise.all(n.map(({name:e})=>e&&new Promise(n=>{let r=t.deleteDatabase(e);r.onsuccess=r.onerror=r.onblocked=()=>n()}))),!0}),await n(`cacheStorage`,async()=>{if(!e.caches)return!1;for(let t of await e.caches.keys())await e.caches.delete(t);return!0}),await n(`cookies`,()=>{for(let t of e.document.cookie.split(`;`)){let n=t.split(`=`)[0]?.trim();n&&(e.document.cookie=`${n}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`)}}),{cleared:t}}let V=/^--[\\w-]+$/;function H(t=window){let n=t.document,a=n.getElementById(`gf-config`),o=JSON.parse(a?.textContent??`{}`);a?.remove();let s=n.getElementById(`gf-root`)??n.body,u,d={},f=null,p=null,g=null,_={width:0,height:0},v=m(t,{onError:t=>u?.notify(e.error,t),onConsole:t=>{(t.level===`warn`||t.level===`error`)&&u?.notify(e.log,t)}}),y=t.matchMedia?.(`(prefers-reduced-motion: reduce)`),b=E({root:s,animate:()=>o.animate!==!1&&!y?.matches,onScriptError:(e,t)=>v.record({kind:`script`,message:e,...t?{source:t}:{}})}),x=()=>R(s),S,C=()=>{S=void 0;let t=z(s);if(!t)return;let r=d.containerDimensions?.maxHeight;n.documentElement.style.overflowY=typeof r==`number`&&t.height>r?`auto`:`hidden`,(t.width!==_.width||t.height!==_.height)&&(_=t,u?.notify(e.sizeChanged,t))},w=()=>{S??=t.requestAnimationFrame(C)};typeof t.ResizeObserver==`function`&&new t.ResizeObserver(w).observe(s);let T=e=>{let r=d.theme;d={...d,...e};let i=n.documentElement.style,a=!1;(e.theme===`light`||e.theme===`dark`)&&(i.colorScheme=e.theme,n.documentElement.dataset.theme=e.theme,a=e.theme!==r);let o=e.styles?.variables;if(o&&typeof o==`object`){for(let[e,t]of Object.entries(o))V.test(e)&&typeof t==`string`&&i.setProperty(e,t);a=!0}a&&t.dispatchEvent(new CustomEvent(`themechange`,{detail:{theme:d.theme,variables:d.styles?.variables}}))},D=()=>{if(!u)throw Error(`generative-frame is not connected to its host`);return u},O=t=>D().request(e.message,{role:`user`,content:[{type:`text`,text:String(t)}]}),k=t=>D().request(e.openLink,{url:String(t)}),A=(t,n)=>D().request(e.callTool,{name:t,...n===void 0?{}:{arguments:n}}),j=t=>D().request(e.requestDisplayMode,{mode:t}),M=t=>D().request(e.updateModelContext,t),N=async t=>{await D().request(e.copyText,{text:String(t)})},P={version:l,get theme(){return d.theme},get context(){return d},get toolInput(){return f},get toolOutput(){return p},get state(){return g},sendPrompt:O,openLink:k,callTool:A,requestDisplayMode:j,updateModelContext:M,copyText:N,setState:t=>{g=t,D().notify(e.widgetState,{state:t})},on(e,n){return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}},F=t;F.genframe=P,F.sendPrompt=O,F.openLink=k,t.navigator.clipboard?Object.defineProperty(t.navigator.clipboard,\"writeText\",{configurable:!0,value:N}):Object.defineProperty(t.navigator,\"clipboard\",{configurable:!0,value:{writeText:N}}),t.open=(e=>(e!==void 0&&k(String(e)).catch(()=>{}),null)),n.addEventListener(`click`,e=>{if(e.defaultPrevented||!(e.target instanceof t.Element))return;let n=e.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)??``;if(r.startsWith(`#`))return;let i;try{i=new URL(r,o.hostOrigin)}catch{return}(i.protocol===`http:`||i.protocol===`https:`)&&(e.preventDefault(),k(i.href).catch(()=>{}))},!0);let I=()=>({size:x(),blank:h(s),errorCount:v.errors.length}),H=()=>({kind:b.kind,ended:b.ended,size:x(),blank:b.ended?h(s):!1,errors:[...v.errors],console:[...v.console]}),U=async(n,a)=>{let o=a??{};switch(n){case e.end:return await b.end(),w(),I();case e.replace:if(typeof o.code!=`string`)throw new i(r.invalidParams,`replace requires a string 'code'`);return await b.replace(o.code),w(),I();case e.screenshot:return b.flush(),L(s,o);case e.inspect:return b.flush(),H();case e.clearStorage:return B(t);default:throw new i(r.methodNotFound,`Unknown method: ${n}`)}},W=(n,r)=>{let i=r??{};switch(n){case e.write:typeof i.chunk==`string`&&b.write(i.chunk);return;case e.hostContextChanged:T(i);return;case e.toolInputPartial:case e.toolInput:{let r=i.arguments;f=r&&typeof r==`object`?r:{},t.dispatchEvent(new CustomEvent(`toolinput`,{detail:{arguments:f,partial:n===e.toolInputPartial}}));return}case e.toolResult:p=i.structuredContent===void 0?i:i.structuredContent,t.dispatchEvent(new CustomEvent(`toolresult`,{detail:i}));return;default:return}},G=(t,n)=>{u=c(t,{onRequest:U,onNotification:W}),g=n.state??null,T(n.context??{}),u.notify(e.ready,{version:l}),w();for(let t of v.errors)u.notify(e.error,t)},K=0,q=()=>{K++,K>100&&t.clearInterval(Y),t.parent.postMessage({type:`genframe:ready`},o.hostOrigin)},J=e=>{if(e.source!==t.parent||e.origin!==o.hostOrigin)return;let n=e.data;n?.type===`genframe:init`&&e.ports[0]&&(t.removeEventListener(`message`,J),t.clearInterval(Y),G(e.ports[0],n))};t.addEventListener(`message`,J);let Y=t.setInterval(q,100);q()}H()})();";
|
|
3
|
+
export { runtimeSource };
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated.js","names":[],"sources":["../../src/runtime/generated.ts"],"sourcesContent":["// Generated by scripts/build-runtime.mjs from src/runtime. Do not edit by hand.\nexport const runtimeSource: string = \"(function(){let e={write:`genframe/write`,end:`genframe/end`,replace:`genframe/replace`,screenshot:`genframe/screenshot`,inspect:`genframe/inspect`,clearStorage:`genframe/clear-storage`,hostContextChanged:`ui/notifications/host-context-changed`,toolInputPartial:`ui/notifications/tool-input-partial`,toolInput:`ui/notifications/tool-input`,toolResult:`ui/notifications/tool-result`,ready:`genframe/ready`,initialize:`ui/initialize`,initialized:`ui/notifications/initialized`,sizeChanged:`ui/notifications/size-changed`,openLink:`ui/open-link`,message:`ui/message`,callTool:`tools/call`,requestDisplayMode:`ui/request-display-mode`,updateModelContext:`ui/update-model-context`,copyText:`genframe/copy-text`,widgetState:`genframe/widget-state`,log:`genframe/log`,error:`genframe/error`},t=/^<svg[\\\\s>/]/i;function n(e){let n=e.trimStart();if(n.startsWith(`<?xml`)){let e=n.indexOf(`>`);if(e===-1)return`html`;n=n.slice(e+1).trimStart()}for(;n.startsWith(`<!--`);){let e=n.indexOf(`-->`,4);if(e===-1)return`html`;n=n.slice(e+3).trimStart()}return t.test(n)?`svg`:`html`}let r={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603};var i=class extends Error{code;data;constructor(e,t,n){super(t),this.name=`RpcError`,this.code=e,this.data=n}};let a=e=>typeof e==`object`&&!!e;function o(e){return a(e)&&e.jsonrpc===`2.0`}let s=e=>e instanceof i?{code:e.code,message:e.message,...e.data===void 0?{}:{data:e.data}}:{code:r.internalError,message:e instanceof Error?e.message:String(e)};function c(e,t={}){let n=1,a=!1,c=/* @__PURE__ */ new Map,l=t=>{a||e.postMessage(t)},u=async(e,n)=>{try{if(!t.onRequest)throw new i(r.methodNotFound,`Unknown method: ${e.method}`);let a=await t.onRequest(e.method,e.params);n({jsonrpc:`2.0`,id:e.id,result:a??null})}catch(t){n({jsonrpc:`2.0`,id:e.id,error:s(t)})}},d=(e,n=l)=>{if(a||!o(e))return;let r=`id`in e&&(typeof e.id==`string`||typeof e.id==`number`);if(`method`in e&&typeof e.method==`string`){if(r)u(e,n);else try{t.onNotification?.(e.method,e.params)}catch{}return}if(!r)return;let s=e,d=c.get(s.id);d&&(c.delete(s.id),d.timer!==void 0&&clearTimeout(d.timer),s.error?d.reject(new i(s.error.code,s.error.message,s.error.data)):d.resolve(s.result))},f=e=>d(e.data);return e.addEventListener(`message`,f),e.start?.(),{request(e,t,r){if(a)return Promise.reject(/* @__PURE__ */ Error(`RPC peer is disposed`));let i=n++;return new Promise((n,a)=>{let o=r?.timeoutMs,s=o===void 0?void 0:setTimeout(()=>{c.delete(i),a(/* @__PURE__ */ Error(`${e} timed out after ${o}ms`))},o);c.set(i,{resolve:n,reject:a,timer:s}),l({jsonrpc:`2.0`,id:i,method:e,...t===void 0?{}:{params:t}})})},notify(e,t){l({jsonrpc:`2.0`,method:e,...t===void 0?{}:{params:t}})},receive:d,dispose(){if(!a){a=!0,e.removeEventListener(`message`,f);for(let e of c.values())e.timer!==void 0&&clearTimeout(e.timer),e.reject(/* @__PURE__ */ Error(`RPC peer is disposed`));c.clear()}}}}let l=`1.0.0-next.0`,u=1e3,d=[`log`,`info`,`warn`,`error`,`debug`],f=e=>e.length>u?`${e.slice(0,u)}…`:e,p=e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;if(typeof e==`object`&&e){if(typeof Node<`u`&&e instanceof Node)return`<${e.nodeName.toLowerCase()}>`;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)};function m(e,t={}){let n=[],r=[],i=e=>{let r={...e,message:f(e.message)};n.length<50&&n.push(r),t.onError?.(r)},a=t=>{let n=t.target;if(n&&n!==e&&n instanceof e.Element){let e=n.getAttribute(`src`)??n.getAttribute(`href`)??void 0;i({kind:`resource`,message:`Failed to load <${n.localName}>${e?` ${e}`:``}`,...e?{source:e}:{}});return}let r=t,a=r.error instanceof Error?r.error.stack:void 0;i({kind:`error`,message:r.message||p(r.error),...r.filename?{source:r.filename}:{},...r.lineno?{line:r.lineno}:{},...r.colno?{column:r.colno}:{},...a?{stack:f(a)}:{}})},o=e=>{let t=e.reason,n=t instanceof Error?t.stack:void 0;i({kind:`unhandledrejection`,message:t instanceof Error?t.message:p(t),...n?{stack:f(n)}:{}})},s=e=>{i({kind:`csp`,message:`Blocked by Content Security Policy (${e.effectiveDirective}): ${e.blockedURI||`inline`}`,...e.blockedURI?{source:e.blockedURI}:{},...e.lineNumber?{line:e.lineNumber}:{}})};e.addEventListener(`error`,a,!0),e.addEventListener(`unhandledrejection`,o),e.document.addEventListener(`securitypolicyviolation`,s);let c=/* @__PURE__ */ new Map;for(let n of d){let i=e.console[n];c.set(n,i),e.console[n]=(...a)=>{let o={level:n,message:f(a.map(p).join(` `))};r.push(o),r.length>200&&r.shift(),t.onConsole?.(o),i.apply(e.console,a)}}return{errors:n,console:r,record:i,dispose(){e.removeEventListener(`error`,a,!0),e.removeEventListener(`unhandledrejection`,o),e.document.removeEventListener(`securitypolicyviolation`,s);for(let[t,n]of c)e.console[t]=n}}}function h(e){let t=e.getBoundingClientRect();if(t.height<2||t.width<2)return!0;if((e.textContent??``).trim().length>0)return!1;for(let t of Array.from(e.querySelectorAll(`svg, canvas, img, video, picture, iframe, input, button, select, textarea, progress, meter`))){let e=t.getBoundingClientRect();if(e.width>=2&&e.height>=2)return!1}for(let t of Array.from(e.querySelectorAll(`*`))){let n=e.ownerDocument.defaultView?.getComputedStyle(t);if(!n||!(n.backgroundColor!==`rgba(0, 0, 0, 0)`&&n.backgroundColor!==`transparent`||n.backgroundImage!==`none`||parseFloat(n.borderTopWidth)>0))continue;let r=t.getBoundingClientRect();if(r.width>=2&&r.height>=2)return!1}return!0}let g=/* @__PURE__ */ new Set([`style`,`script`,`meta`,`link`,`title`,`base`]);function _(e){let t=e.toLowerCase().lastIndexOf(`<style`);if(t===-1)return e;let n=e.charAt(t+6);return n!==``&&!/[\\\\s>/]/.test(n)||e.toLowerCase().includes(`</style`,t)?e:e.slice(0,t)}function v(e,t){let n=e.createElement(`template`);n.innerHTML=t;let r=n.content,i=[];for(let t of Array.from(r.querySelectorAll(`script`)))t.replaceWith(e.createComment(`gf-script`)),i.push(t);return{fragment:r,scripts:i}}let y=(e,t)=>{if(e.nodeType!==t.nodeType)return!1;if(e.nodeType!==Node.ELEMENT_NODE)return!0;let n=e,r=t;return n.localName===r.localName&&n.namespaceURI===r.namespaceURI&&n.getAttribute(`id`)===r.getAttribute(`id`)},b=(e,t)=>{for(let n of Array.from(t.attributes))if(e.getAttributeNS(n.namespaceURI,n.localName)!==n.value)try{n.namespaceURI?e.setAttributeNS(n.namespaceURI,n.name,n.value):e.setAttribute(n.name,n.value)}catch{}for(let n of Array.from(e.attributes))t.hasAttributeNS(n.namespaceURI,n.localName)||e.removeAttributeNS(n.namespaceURI,n.localName)},x=(e,t,n)=>{if(e.nodeType!==Node.ELEMENT_NODE){e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue);return}let r=e,i=t;b(r,i),r instanceof HTMLTemplateElement&&i instanceof HTMLTemplateElement?r.innerHTML!==i.innerHTML&&r.content.replaceChildren(i.content):S(r,i,n)};function S(e,t,n){let r=Array.from(t.childNodes),i=e.firstChild;for(let t=0;t<r.length;t++){let a=r[t];if(!i){e.appendChild(a),n.onAdded(a);continue}if(y(i,a)){x(i,a,n),i=i.nextSibling;continue}let o=r[t+1];if(o&&y(i,o)){e.insertBefore(a,i),n.onAdded(a);continue}let s=i.nextSibling;s&&y(s,a)?(i.remove(),x(s,a,n),i=s.nextSibling):(e.replaceChild(a,i),n.onAdded(a),i=s)}for(;i;){let e=i.nextSibling;i.remove(),i=e}}let C=e=>{let t=!1,n=()=>{t||(t=!0,cancelAnimationFrame(r),clearTimeout(i),e())},r=requestAnimationFrame(n),i=setTimeout(n,50);return()=>{t=!0,cancelAnimationFrame(r),clearTimeout(i)}},w=(e=()=>{})=>(t,n)=>{let r=t.ownerDocument.createElementNS(n.namespaceURI??`http://www.w3.org/1999/xhtml`,`script`);for(let e of Array.from(n.attributes))try{r.setAttribute(e.name,e.value)}catch{}r.textContent=n.textContent;let i=r.getAttribute(`src`)??r.getAttribute(`href`);return i?new Promise(n=>{let a=setTimeout(()=>{e(`Script timed out: ${i}`,i),n()},15e3);r.addEventListener(`load`,()=>{clearTimeout(a),n()}),r.addEventListener(`error`,()=>{clearTimeout(a),e(`Script failed to load: ${i}`,i),n()}),t.replaceWith(r)}):(t.replaceWith(r),Promise.resolve())},T=e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;let t=e;g.has(t.localName)||typeof t.animate!=`function`||t.animate([{opacity:0},{opacity:1}],{duration:200,easing:`ease-out`})};function E(e){let{root:t}=e,r=t.ownerDocument,i=e.schedule??C,a=e.runScript??w(e.onScriptError),o=``,s=`html`,c=!1,l=!1,u,d,f=[],p={onAdded(t){e.animate?.()&&T(t)}},m=i=>{u?.(),u=void 0;let a=i?o:_(o);if(a===d)return;d=a,s=n(o),t.dataset.kind=s;let c=v(r,a);f=c.scripts,S(t,c.fragment,p),e.onRender?.(s)},h=async()=>{let e=r.createTreeWalker(t,NodeFilter.SHOW_COMMENT),n=[];for(let t=e.nextNode();t;t=e.nextNode())t.nodeValue===`gf-script`&&n.push(t);let i=f;for(let e=0;e<n.length&&e<i.length;e++)await a(n[e],i[e]);i.length>0&&!l&&(l=!0,r.dispatchEvent(new Event(`DOMContentLoaded`,{bubbles:!0})),r.defaultView?.dispatchEvent(new Event(`load`)))};return{get source(){return o},get kind(){return s},get ended(){return c},get scriptsRan(){return l},write(e){if(c)throw Error(`Cannot write after end; use replace`);e&&(o+=e,u??=i(()=>{u=void 0,m(!1)}))},async end(){c||(c=!0,m(!0),await h())},async replace(e){c=!0,o=e,m(!0),await h()},flush(){u&&m(c)}}}let D=`http://www.w3.org/1999/xhtml`,O=`http://www.w3.org/2000/svg`,k=4096,A=/* @__PURE__ */ new Set([`script`,`noscript`,`template`]),j=e=>{let t=/* @__PURE__ */ new Map,n,r,i,a=()=>{if(n)return;i=e.createElement(`div`),i.setAttribute(`aria-hidden`,`true`),i.style.cssText=`all:initial;position:absolute;left:-99999px;top:0;visibility:hidden;contain:strict;width:0;height:0;`;let t=i.attachShadow({mode:`closed`});n=e.createElement(`div`),r=e.createElementNS(O,`svg`),n.appendChild(r),t.appendChild(n),e.body.appendChild(i)};return{get(i){let o=`${i.namespaceURI}|${i.localName}`,s=t.get(o);if(s)return s;a();let c=e.createElementNS(i.namespaceURI??D,i.localName);(i.namespaceURI===O?r:n).appendChild(c);let l=e.defaultView.getComputedStyle(c);s=/* @__PURE__ */ new Map;for(let e=0;e<l.length;e++){let t=l.item(e);s.set(t,l.getPropertyValue(t))}return c.remove(),t.set(o,s),s},dispose(){i?.remove()}}},M=(e,t,n)=>{let r=document.createElement(`canvas`);return r.width=Math.max(1,t),r.height=Math.max(1,n),r.getContext(`2d`).drawImage(e,0,0,t,n),r.toDataURL(`image/png`)},N=(e,t,n)=>{if(e.nodeType===Node.TEXT_NODE)return e.cloneNode();if(e.nodeType!==Node.ELEMENT_NODE)return null;let r=e;if(A.has(r.localName))return null;let i=r.ownerDocument.defaultView,a=i.getComputedStyle(r),o;if(r instanceof i.HTMLCanvasElement){o=r.ownerDocument.createElement(`img`);try{o.setAttribute(`src`,r.toDataURL(`image/png`))}catch{}}else if(r instanceof i.HTMLImageElement&&r.complete&&r.naturalWidth>0&&!r.src.startsWith(`data:`)){o=r.cloneNode(!1);try{o.setAttribute(`src`,M(r,r.naturalWidth,r.naturalHeight))}catch{}}else o=r.cloneNode(!1);r instanceof i.HTMLInputElement?r.type===`checkbox`||r.type===`radio`?r.checked?o.setAttribute(`checked`,``):o.removeAttribute(`checked`):o.setAttribute(`value`,r.value):r instanceof i.HTMLTextAreaElement?o.textContent=r.value:r instanceof i.HTMLSelectElement&&o.setAttribute(`data-gf-value`,r.value);let s=t.get(r),c=[];for(let e=0;e<a.length;e++){let t=a.item(e);if(t.startsWith(`--`))continue;let r=a.getPropertyValue(t);(r!==s.get(t)||n&&r!==n.getPropertyValue(t))&&c.push(`${t}:${r}`)}if((a.animationName!==`none`||a.transitionProperty!==`none`)&&c.push(`animation:none`,`transition:none`),o.setAttribute(`style`,c.join(`;`)),!(r instanceof i.HTMLTextAreaElement))for(let e of Array.from(r.childNodes)){let n=N(e,t,a);n&&o.appendChild(n)}if(r instanceof i.HTMLSelectElement)for(let e of Array.from(o.querySelectorAll(`option`)))(e.getAttribute(`value`)===r.value||e.textContent===r.value)&&e.setAttribute(`selected`,``);return o},P=e=>{let t=[];for(let n of Array.from(e.styleSheets)){let e;try{e=n.cssRules}catch{continue}for(let n of Array.from(e))n.constructor.name===`CSSFontFaceRule`&&!/url\\\\((?!\\\\s*[\\\"']?data:)/i.test(n.cssText)&&t.push(n.cssText)}return t.join(`\\n`)},F=e=>{let t=e.getBoundingClientRect(),n=Math.max(1,Math.ceil(t.width));return{layoutWidth:n,width:Math.max(n,Math.ceil(e.scrollWidth)),height:Math.max(1,Math.ceil(Math.max(t.height,e.scrollHeight)))}},I=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(/* @__PURE__ */ Error(`The serialized widget failed to rasterize`)),r.src=e});async function L(e,t={}){let n=e.ownerDocument,r=n.defaultView;await n.fonts?.ready;let{layoutWidth:i,width:a,height:o}=F(e),s=j(n),c;try{c=N(e,s,r.getComputedStyle(n.body))}finally{s.dispose()}let l=n.createElementNS(D,`div`);l.setAttribute(`style`,`width:${a}px;height:${o}px;overflow:hidden;`),c&&l.appendChild(c),c instanceof Element&&c.setAttribute(`style`,`${c.getAttribute(`style`)??``};width:${i}px;margin:0;`);let u=P(n),d=new XMLSerializer().serializeToString(l),f=`<svg xmlns=\\\"${O}\\\" width=\\\"${a}\\\" height=\\\"${o}\\\" viewBox=\\\"0 0 ${a} ${o}\\\"><foreignObject x=\\\"0\\\" y=\\\"0\\\" width=\\\"100%\\\" height=\\\"100%\\\">`+(u?`<style xmlns=\\\"${D}\\\">${u.replace(/</g,`\\\\\\\\3c `)}</style>`:``)+d+`</foreignObject></svg>`,p=await I(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`),m=t.scale??Math.min(r.devicePixelRatio||1,2),h=Math.max(.1,Math.min(m,k/a,k/o)),g=n.createElement(`canvas`);g.width=Math.round(a*h),g.height=Math.round(o*h);let _=g.getContext(`2d`);if(!_)throw Error(`Canvas 2D context is unavailable`);let v=t.background??r.getComputedStyle(n.documentElement).getPropertyValue(`--color-background`).trim();return v&&(_.fillStyle=v,_.fillRect(0,0,g.width,g.height)),_.scale(h,h),_.drawImage(p,0,0,a,o),{dataUrl:g.toDataURL(`image/png`),width:a,height:o}}function R(e){let t=e.getBoundingClientRect();return{width:Math.ceil(t.width),height:Math.ceil(t.height)}}function z(e){let t=R(e);return t.width>0?t:void 0}async function B(e){let t=[],n=async(e,n)=>{try{await n()!==!1&&t.push(e)}catch{}};return await n(`localStorage`,()=>e.localStorage.clear()),await n(`sessionStorage`,()=>e.sessionStorage.clear()),await n(`indexedDB`,async()=>{let t=e.indexedDB;if(typeof t?.databases!=`function`)return!1;let n=await t.databases();return await Promise.all(n.map(({name:e})=>e&&new Promise(n=>{let r=t.deleteDatabase(e);r.onsuccess=r.onerror=r.onblocked=()=>n()}))),!0}),await n(`cacheStorage`,async()=>{if(!e.caches)return!1;for(let t of await e.caches.keys())await e.caches.delete(t);return!0}),await n(`cookies`,()=>{for(let t of e.document.cookie.split(`;`)){let n=t.split(`=`)[0]?.trim();n&&(e.document.cookie=`${n}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`)}}),{cleared:t}}let V=/^--[\\\\w-]+$/;function H(t=window){let n=t.document,a=n.getElementById(`gf-config`),o=JSON.parse(a?.textContent??`{}`);a?.remove();let s=n.getElementById(`gf-root`)??n.body,u,d={},f=null,p=null,g=null,_={width:0,height:0},v=m(t,{onError:t=>u?.notify(e.error,t),onConsole:t=>{(t.level===`warn`||t.level===`error`)&&u?.notify(e.log,t)}}),y=t.matchMedia?.(`(prefers-reduced-motion: reduce)`),b=E({root:s,animate:()=>o.animate!==!1&&!y?.matches,onScriptError:(e,t)=>v.record({kind:`script`,message:e,...t?{source:t}:{}})}),x=()=>R(s),S,C=()=>{S=void 0;let t=z(s);if(!t)return;let r=d.containerDimensions?.maxHeight;n.documentElement.style.overflowY=typeof r==`number`&&t.height>r?`auto`:`hidden`,(t.width!==_.width||t.height!==_.height)&&(_=t,u?.notify(e.sizeChanged,t))},w=()=>{S??=t.requestAnimationFrame(C)};typeof t.ResizeObserver==`function`&&new t.ResizeObserver(w).observe(s);let T=e=>{let r=d.theme;d={...d,...e};let i=n.documentElement.style,a=!1;(e.theme===`light`||e.theme===`dark`)&&(i.colorScheme=e.theme,n.documentElement.dataset.theme=e.theme,a=e.theme!==r);let o=e.styles?.variables;if(o&&typeof o==`object`){for(let[e,t]of Object.entries(o))V.test(e)&&typeof t==`string`&&i.setProperty(e,t);a=!0}a&&t.dispatchEvent(new CustomEvent(`themechange`,{detail:{theme:d.theme,variables:d.styles?.variables}}))},D=()=>{if(!u)throw Error(`generative-frame is not connected to its host`);return u},O=t=>D().request(e.message,{role:`user`,content:[{type:`text`,text:String(t)}]}),k=t=>D().request(e.openLink,{url:String(t)}),A=(t,n)=>D().request(e.callTool,{name:t,...n===void 0?{}:{arguments:n}}),j=t=>D().request(e.requestDisplayMode,{mode:t}),M=t=>D().request(e.updateModelContext,t),N=async t=>{await D().request(e.copyText,{text:String(t)})},P={version:l,get theme(){return d.theme},get context(){return d},get toolInput(){return f},get toolOutput(){return p},get state(){return g},sendPrompt:O,openLink:k,callTool:A,requestDisplayMode:j,updateModelContext:M,copyText:N,setState:t=>{g=t,D().notify(e.widgetState,{state:t})},on(e,n){return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}},F=t;F.genframe=P,F.sendPrompt=O,F.openLink=k,t.navigator.clipboard?Object.defineProperty(t.navigator.clipboard,\\\"writeText\\\",{configurable:!0,value:N}):Object.defineProperty(t.navigator,\\\"clipboard\\\",{configurable:!0,value:{writeText:N}}),t.open=(e=>(e!==void 0&&k(String(e)).catch(()=>{}),null)),n.addEventListener(`click`,e=>{if(e.defaultPrevented||!(e.target instanceof t.Element))return;let n=e.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)??``;if(r.startsWith(`#`))return;let i;try{i=new URL(r,o.hostOrigin)}catch{return}(i.protocol===`http:`||i.protocol===`https:`)&&(e.preventDefault(),k(i.href).catch(()=>{}))},!0);let I=()=>({size:x(),blank:h(s),errorCount:v.errors.length}),H=()=>({kind:b.kind,ended:b.ended,size:x(),blank:b.ended?h(s):!1,errors:[...v.errors],console:[...v.console]}),U=async(n,a)=>{let o=a??{};switch(n){case e.end:return await b.end(),w(),I();case e.replace:if(typeof o.code!=`string`)throw new i(r.invalidParams,`replace requires a string 'code'`);return await b.replace(o.code),w(),I();case e.screenshot:return b.flush(),L(s,o);case e.inspect:return b.flush(),H();case e.clearStorage:return B(t);default:throw new i(r.methodNotFound,`Unknown method: ${n}`)}},W=(n,r)=>{let i=r??{};switch(n){case e.write:typeof i.chunk==`string`&&b.write(i.chunk);return;case e.hostContextChanged:T(i);return;case e.toolInputPartial:case e.toolInput:{let r=i.arguments;f=r&&typeof r==`object`?r:{},t.dispatchEvent(new CustomEvent(`toolinput`,{detail:{arguments:f,partial:n===e.toolInputPartial}}));return}case e.toolResult:p=i.structuredContent===void 0?i:i.structuredContent,t.dispatchEvent(new CustomEvent(`toolresult`,{detail:i}));return;default:return}},G=(t,n)=>{u=c(t,{onRequest:U,onNotification:W}),g=n.state??null,T(n.context??{}),u.notify(e.ready,{version:l}),w();for(let t of v.errors)u.notify(e.error,t)},K=0,q=()=>{K++,K>100&&t.clearInterval(Y),t.parent.postMessage({type:`genframe:ready`},o.hostOrigin)},J=e=>{if(e.source!==t.parent||e.origin!==o.hostOrigin)return;let n=e.data;n?.type===`genframe:init`&&e.ports[0]&&(t.removeEventListener(`message`,J),t.clearInterval(Y),G(e.ports[0],n))};t.addEventListener(`message`,J);let Y=t.setInterval(q,100);q()}H()})();\";\n"],"mappings":";AACA,MAAa,gBAAwB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type RuntimeConfig = {
|
|
2
|
+
hostOrigin: string;
|
|
3
|
+
animate: boolean;
|
|
4
|
+
};
|
|
5
|
+
/** Boots the in-frame runtime: handshake, streaming renderer, bridge, and widget globals. */
|
|
6
|
+
export declare function startRuntime(win?: Window & typeof globalThis): void;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","mappings":"AAoBA,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,OAAO;CACjB;AAQD;AACA,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAM,GAAG,OAAO,UAAmB,GAAG,IAAI","names":[],"ignoreList":[],"sources":["../../src/runtime/index.ts"],"sourcesContent":[null]}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { METHODS, READY_MESSAGE } from "../protocol.js";
|
|
2
|
+
import { RPC_ERROR, RpcError, createRpcPeer } from "../rpc.js";
|
|
3
|
+
import { VERSION } from "../version.js";
|
|
4
|
+
import { installDiagnostics, isBlankRender } from "./diagnostics.js";
|
|
5
|
+
import { createStreamRenderer } from "./morph.js";
|
|
6
|
+
import { captureScreenshot } from "./screenshot.js";
|
|
7
|
+
import { measureRoot, reportableSize } from "./size.js";
|
|
8
|
+
import { clearFrameStorage } from "./storage.js";
|
|
9
|
+
// src/runtime/index.ts
|
|
10
|
+
const VARIABLE_NAME = /^--[\w-]+$/;
|
|
11
|
+
const READY_INTERVAL_MS = 100;
|
|
12
|
+
const READY_ATTEMPTS = 100;
|
|
13
|
+
/** Boots the in-frame runtime: handshake, streaming renderer, bridge, and widget globals. */
|
|
14
|
+
function startRuntime(win = window) {
|
|
15
|
+
const doc = win.document;
|
|
16
|
+
const configElement = doc.getElementById("gf-config");
|
|
17
|
+
const config = JSON.parse(configElement?.textContent ?? "{}");
|
|
18
|
+
configElement?.remove();
|
|
19
|
+
const root = doc.getElementById("gf-root") ?? doc.body;
|
|
20
|
+
let peer;
|
|
21
|
+
let context = {};
|
|
22
|
+
let toolInput = null;
|
|
23
|
+
let toolOutput = null;
|
|
24
|
+
let widgetState = null;
|
|
25
|
+
let lastSize = {
|
|
26
|
+
width: 0,
|
|
27
|
+
height: 0
|
|
28
|
+
};
|
|
29
|
+
const diagnostics = installDiagnostics(win, {
|
|
30
|
+
onError: (error) => peer?.notify(METHODS.error, error),
|
|
31
|
+
onConsole: (entry) => {
|
|
32
|
+
if (entry.level === "warn" || entry.level === "error") peer?.notify(METHODS.log, entry);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const reducedMotion = win.matchMedia?.("(prefers-reduced-motion: reduce)");
|
|
36
|
+
const renderer = createStreamRenderer({
|
|
37
|
+
root,
|
|
38
|
+
animate: () => config.animate !== false && !reducedMotion?.matches,
|
|
39
|
+
onScriptError: (message, src) => diagnostics.record({
|
|
40
|
+
kind: "script",
|
|
41
|
+
message,
|
|
42
|
+
...src ? { source: src } : {}
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
const measure = () => measureRoot(root);
|
|
46
|
+
let sizeFrame;
|
|
47
|
+
const reportSize = () => {
|
|
48
|
+
sizeFrame = void 0;
|
|
49
|
+
const size = reportableSize(root);
|
|
50
|
+
if (!size) return;
|
|
51
|
+
const maxHeight = context.containerDimensions?.maxHeight;
|
|
52
|
+
doc.documentElement.style.overflowY = typeof maxHeight === "number" && size.height > maxHeight ? "auto" : "hidden";
|
|
53
|
+
if (size.width === lastSize.width && size.height === lastSize.height) return;
|
|
54
|
+
lastSize = size;
|
|
55
|
+
peer?.notify(METHODS.sizeChanged, size);
|
|
56
|
+
};
|
|
57
|
+
const scheduleSize = () => {
|
|
58
|
+
sizeFrame ??= win.requestAnimationFrame(reportSize);
|
|
59
|
+
};
|
|
60
|
+
if (typeof win.ResizeObserver === "function") new win.ResizeObserver(scheduleSize).observe(root);
|
|
61
|
+
const applyContext = (next) => {
|
|
62
|
+
const previousTheme = context.theme;
|
|
63
|
+
context = {
|
|
64
|
+
...context,
|
|
65
|
+
...next
|
|
66
|
+
};
|
|
67
|
+
const style = doc.documentElement.style;
|
|
68
|
+
let themeChanged = false;
|
|
69
|
+
if (next.theme === "light" || next.theme === "dark") {
|
|
70
|
+
style.colorScheme = next.theme;
|
|
71
|
+
doc.documentElement.dataset["theme"] = next.theme;
|
|
72
|
+
themeChanged = next.theme !== previousTheme;
|
|
73
|
+
}
|
|
74
|
+
const variables = next.styles?.variables;
|
|
75
|
+
if (variables && typeof variables === "object") {
|
|
76
|
+
for (const [name, value] of Object.entries(variables)) if (VARIABLE_NAME.test(name) && typeof value === "string") style.setProperty(name, value);
|
|
77
|
+
themeChanged = true;
|
|
78
|
+
}
|
|
79
|
+
if (themeChanged) win.dispatchEvent(new CustomEvent("themechange", { detail: {
|
|
80
|
+
theme: context.theme,
|
|
81
|
+
variables: context.styles?.variables
|
|
82
|
+
} }));
|
|
83
|
+
};
|
|
84
|
+
const requirePeer = () => {
|
|
85
|
+
if (!peer) throw new Error("generative-frame is not connected to its host");
|
|
86
|
+
return peer;
|
|
87
|
+
};
|
|
88
|
+
const sendPrompt = (text) => requirePeer().request(METHODS.message, {
|
|
89
|
+
role: "user",
|
|
90
|
+
content: [{
|
|
91
|
+
type: "text",
|
|
92
|
+
text: String(text)
|
|
93
|
+
}]
|
|
94
|
+
});
|
|
95
|
+
const openLink = (url) => requirePeer().request(METHODS.openLink, { url: String(url) });
|
|
96
|
+
const callTool = (name, args) => requirePeer().request(METHODS.callTool, {
|
|
97
|
+
name,
|
|
98
|
+
...args !== void 0 ? { arguments: args } : {}
|
|
99
|
+
});
|
|
100
|
+
const requestDisplayMode = (mode) => requirePeer().request(METHODS.requestDisplayMode, { mode });
|
|
101
|
+
const updateModelContext = (params) => requirePeer().request(METHODS.updateModelContext, params);
|
|
102
|
+
const copyText = async (text) => {
|
|
103
|
+
await requirePeer().request(METHODS.copyText, { text: String(text) });
|
|
104
|
+
};
|
|
105
|
+
const setState = (state) => {
|
|
106
|
+
widgetState = state;
|
|
107
|
+
requirePeer().notify(METHODS.widgetState, { state });
|
|
108
|
+
};
|
|
109
|
+
const genframe = {
|
|
110
|
+
version: VERSION,
|
|
111
|
+
get theme() {
|
|
112
|
+
return context.theme;
|
|
113
|
+
},
|
|
114
|
+
get context() {
|
|
115
|
+
return context;
|
|
116
|
+
},
|
|
117
|
+
get toolInput() {
|
|
118
|
+
return toolInput;
|
|
119
|
+
},
|
|
120
|
+
get toolOutput() {
|
|
121
|
+
return toolOutput;
|
|
122
|
+
},
|
|
123
|
+
get state() {
|
|
124
|
+
return widgetState;
|
|
125
|
+
},
|
|
126
|
+
sendPrompt,
|
|
127
|
+
openLink,
|
|
128
|
+
callTool,
|
|
129
|
+
requestDisplayMode,
|
|
130
|
+
updateModelContext,
|
|
131
|
+
copyText,
|
|
132
|
+
setState,
|
|
133
|
+
on(type, listener) {
|
|
134
|
+
win.addEventListener(type, listener);
|
|
135
|
+
return () => win.removeEventListener(type, listener);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const globals = win;
|
|
139
|
+
globals["genframe"] = genframe;
|
|
140
|
+
globals["sendPrompt"] = sendPrompt;
|
|
141
|
+
globals["openLink"] = openLink;
|
|
142
|
+
if (win.navigator.clipboard) Object.defineProperty(win.navigator.clipboard, "writeText", {
|
|
143
|
+
configurable: true,
|
|
144
|
+
value: copyText
|
|
145
|
+
});
|
|
146
|
+
else Object.defineProperty(win.navigator, "clipboard", {
|
|
147
|
+
configurable: true,
|
|
148
|
+
value: { writeText: copyText }
|
|
149
|
+
});
|
|
150
|
+
win.open = ((url) => {
|
|
151
|
+
if (url !== void 0) openLink(String(url)).catch(() => {});
|
|
152
|
+
return null;
|
|
153
|
+
});
|
|
154
|
+
doc.addEventListener("click", (event) => {
|
|
155
|
+
if (event.defaultPrevented || !(event.target instanceof win.Element)) return;
|
|
156
|
+
const anchor = event.target.closest("a[href]");
|
|
157
|
+
if (!anchor) return;
|
|
158
|
+
const href = anchor.getAttribute("href") ?? "";
|
|
159
|
+
if (href.startsWith("#")) return;
|
|
160
|
+
let url;
|
|
161
|
+
try {
|
|
162
|
+
url = new URL(href, config.hostOrigin);
|
|
163
|
+
} catch {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return;
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
openLink(url.href).catch(() => {});
|
|
169
|
+
}, true);
|
|
170
|
+
const endResult = () => {
|
|
171
|
+
return {
|
|
172
|
+
size: measure(),
|
|
173
|
+
blank: isBlankRender(root),
|
|
174
|
+
errorCount: diagnostics.errors.length
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
const inspect = () => ({
|
|
178
|
+
kind: renderer.kind,
|
|
179
|
+
ended: renderer.ended,
|
|
180
|
+
size: measure(),
|
|
181
|
+
blank: renderer.ended ? isBlankRender(root) : false,
|
|
182
|
+
errors: [...diagnostics.errors],
|
|
183
|
+
console: [...diagnostics.console]
|
|
184
|
+
});
|
|
185
|
+
const onRequest = async (method, params) => {
|
|
186
|
+
const p = params ?? {};
|
|
187
|
+
switch (method) {
|
|
188
|
+
case METHODS.end:
|
|
189
|
+
await renderer.end();
|
|
190
|
+
scheduleSize();
|
|
191
|
+
return endResult();
|
|
192
|
+
case METHODS.replace:
|
|
193
|
+
if (typeof p["code"] !== "string") throw new RpcError(RPC_ERROR.invalidParams, "replace requires a string 'code'");
|
|
194
|
+
await renderer.replace(p["code"]);
|
|
195
|
+
scheduleSize();
|
|
196
|
+
return endResult();
|
|
197
|
+
case METHODS.screenshot:
|
|
198
|
+
renderer.flush();
|
|
199
|
+
return captureScreenshot(root, p);
|
|
200
|
+
case METHODS.inspect:
|
|
201
|
+
renderer.flush();
|
|
202
|
+
return inspect();
|
|
203
|
+
case METHODS.clearStorage: return clearFrameStorage(win);
|
|
204
|
+
default: throw new RpcError(RPC_ERROR.methodNotFound, `Unknown method: ${method}`);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
const onNotification = (method, params) => {
|
|
208
|
+
const p = params ?? {};
|
|
209
|
+
switch (method) {
|
|
210
|
+
case METHODS.write:
|
|
211
|
+
if (typeof p["chunk"] === "string") renderer.write(p["chunk"]);
|
|
212
|
+
return;
|
|
213
|
+
case METHODS.hostContextChanged:
|
|
214
|
+
applyContext(p);
|
|
215
|
+
return;
|
|
216
|
+
case METHODS.toolInputPartial:
|
|
217
|
+
case METHODS.toolInput: {
|
|
218
|
+
const args = p["arguments"];
|
|
219
|
+
toolInput = args && typeof args === "object" ? args : {};
|
|
220
|
+
win.dispatchEvent(new CustomEvent("toolinput", { detail: {
|
|
221
|
+
arguments: toolInput,
|
|
222
|
+
partial: method === METHODS.toolInputPartial
|
|
223
|
+
} }));
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
case METHODS.toolResult:
|
|
227
|
+
toolOutput = p["structuredContent"] !== void 0 ? p["structuredContent"] : p;
|
|
228
|
+
win.dispatchEvent(new CustomEvent("toolresult", { detail: p }));
|
|
229
|
+
return;
|
|
230
|
+
default: return;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const connect = (port, init) => {
|
|
234
|
+
peer = createRpcPeer(port, {
|
|
235
|
+
onRequest,
|
|
236
|
+
onNotification
|
|
237
|
+
});
|
|
238
|
+
widgetState = init.state ?? null;
|
|
239
|
+
applyContext(init.context ?? {});
|
|
240
|
+
peer.notify(METHODS.ready, { version: VERSION });
|
|
241
|
+
scheduleSize();
|
|
242
|
+
for (const error of diagnostics.errors) peer.notify(METHODS.error, error);
|
|
243
|
+
};
|
|
244
|
+
let attempts = 0;
|
|
245
|
+
const announce = () => {
|
|
246
|
+
attempts++;
|
|
247
|
+
if (attempts > READY_ATTEMPTS) win.clearInterval(readyTimer);
|
|
248
|
+
win.parent.postMessage({ type: READY_MESSAGE }, config.hostOrigin);
|
|
249
|
+
};
|
|
250
|
+
const onWindowMessage = (event) => {
|
|
251
|
+
if (event.source !== win.parent || event.origin !== config.hostOrigin) return;
|
|
252
|
+
const data = event.data;
|
|
253
|
+
if (data?.type !== "genframe:init" || !event.ports[0]) return;
|
|
254
|
+
win.removeEventListener("message", onWindowMessage);
|
|
255
|
+
win.clearInterval(readyTimer);
|
|
256
|
+
connect(event.ports[0], data);
|
|
257
|
+
};
|
|
258
|
+
win.addEventListener("message", onWindowMessage);
|
|
259
|
+
const readyTimer = win.setInterval(announce, READY_INTERVAL_MS);
|
|
260
|
+
announce();
|
|
261
|
+
}
|
|
262
|
+
export { startRuntime };
|
|
263
|
+
|
|
264
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/runtime/index.ts"],"sourcesContent":["import {\n INIT_MESSAGE,\n METHODS,\n READY_MESSAGE,\n type ColorScheme,\n type EndResult,\n type FrameInspection,\n type HostContext,\n type InitMessage,\n type ScreenshotOptions,\n type WidgetSize,\n} from \"../protocol\";\nimport { createRpcPeer, RPC_ERROR, RpcError, type RpcPeer } from \"../rpc\";\nimport { VERSION } from \"../version\";\nimport { installDiagnostics, isBlankRender } from \"./diagnostics\";\nimport { createStreamRenderer } from \"./morph\";\nimport { captureScreenshot } from \"./screenshot\";\nimport { measureRoot, reportableSize } from \"./size\";\nimport { clearFrameStorage } from \"./storage\";\n\nexport type RuntimeConfig = {\n hostOrigin: string;\n animate: boolean;\n};\n\nconst VARIABLE_NAME = /^--[\\w-]+$/;\nconst READY_INTERVAL_MS = 100;\nconst READY_ATTEMPTS = 100;\n\ntype Listener = (event: Event) => void;\n\n/** Boots the in-frame runtime: handshake, streaming renderer, bridge, and widget globals. */\nexport function startRuntime(win: Window & typeof globalThis = window): void {\n const doc = win.document;\n const configElement = doc.getElementById(\"gf-config\");\n const config = JSON.parse(\n configElement?.textContent ?? \"{}\",\n ) as RuntimeConfig;\n configElement?.remove();\n const root = doc.getElementById(\"gf-root\") ?? doc.body;\n\n let peer: RpcPeer | undefined;\n let context: HostContext = {};\n let toolInput: Record<string, unknown> | null = null;\n let toolOutput: unknown = null;\n let widgetState: unknown = null;\n let lastSize: WidgetSize = { width: 0, height: 0 };\n\n const diagnostics = installDiagnostics(win, {\n onError: (error) => peer?.notify(METHODS.error, error),\n onConsole: (entry) => {\n if (entry.level === \"warn\" || entry.level === \"error\") {\n peer?.notify(METHODS.log, entry);\n }\n },\n });\n\n const reducedMotion = win.matchMedia?.(\"(prefers-reduced-motion: reduce)\");\n const renderer = createStreamRenderer({\n root,\n animate: () => config.animate !== false && !reducedMotion?.matches,\n onScriptError: (message, src) =>\n diagnostics.record({\n kind: \"script\",\n message,\n ...(src ? { source: src } : {}),\n }),\n });\n\n const measure = (): WidgetSize => measureRoot(root);\n\n let sizeFrame: number | undefined;\n const reportSize = () => {\n sizeFrame = undefined;\n const size = reportableSize(root);\n if (!size) return;\n const maxHeight = context.containerDimensions?.maxHeight;\n // The host sizes the iframe to the content, so a scrollbar would only flash\n // while the two catch up and steal width; it is needed only past maxHeight.\n doc.documentElement.style.overflowY =\n typeof maxHeight === \"number\" && size.height > maxHeight\n ? \"auto\"\n : \"hidden\";\n if (size.width === lastSize.width && size.height === lastSize.height)\n return;\n lastSize = size;\n peer?.notify(METHODS.sizeChanged, size);\n };\n const scheduleSize = () => {\n sizeFrame ??= win.requestAnimationFrame(reportSize);\n };\n if (typeof win.ResizeObserver === \"function\") {\n new win.ResizeObserver(scheduleSize).observe(root);\n }\n\n const applyContext = (next: HostContext) => {\n const previousTheme = context.theme;\n context = { ...context, ...next };\n const style = doc.documentElement.style;\n let themeChanged = false;\n if (next.theme === \"light\" || next.theme === \"dark\") {\n style.colorScheme = next.theme;\n doc.documentElement.dataset[\"theme\"] = next.theme;\n themeChanged = next.theme !== previousTheme;\n }\n const variables = next.styles?.variables;\n if (variables && typeof variables === \"object\") {\n for (const [name, value] of Object.entries(variables)) {\n if (VARIABLE_NAME.test(name) && typeof value === \"string\") {\n style.setProperty(name, value);\n }\n }\n themeChanged = true;\n }\n if (themeChanged) {\n win.dispatchEvent(\n new CustomEvent(\"themechange\", {\n detail: {\n theme: context.theme,\n variables: context.styles?.variables,\n },\n }),\n );\n }\n };\n\n const requirePeer = () => {\n if (!peer) throw new Error(\"generative-frame is not connected to its host\");\n return peer;\n };\n\n const sendPrompt = (text: string) =>\n requirePeer().request(METHODS.message, {\n role: \"user\",\n content: [{ type: \"text\", text: String(text) }],\n });\n const openLink = (url: string) =>\n requirePeer().request(METHODS.openLink, { url: String(url) });\n const callTool = (name: string, args?: Record<string, unknown>) =>\n requirePeer().request(METHODS.callTool, {\n name,\n ...(args !== undefined ? { arguments: args } : {}),\n });\n const requestDisplayMode = (mode: string) =>\n requirePeer().request(METHODS.requestDisplayMode, { mode });\n const updateModelContext = (params: unknown) =>\n requirePeer().request(METHODS.updateModelContext, params);\n const copyText = async (text: string) => {\n await requirePeer().request(METHODS.copyText, { text: String(text) });\n };\n const setState = (state: unknown) => {\n widgetState = state;\n requirePeer().notify(METHODS.widgetState, { state });\n };\n\n const genframe = {\n version: VERSION,\n get theme(): ColorScheme | undefined {\n return context.theme;\n },\n get context(): HostContext {\n return context;\n },\n get toolInput() {\n return toolInput;\n },\n get toolOutput() {\n return toolOutput;\n },\n get state() {\n return widgetState;\n },\n sendPrompt,\n openLink,\n callTool,\n requestDisplayMode,\n updateModelContext,\n copyText,\n setState,\n on(type: \"themechange\" | \"toolinput\" | \"toolresult\", listener: Listener) {\n win.addEventListener(type, listener);\n return () => win.removeEventListener(type, listener);\n },\n };\n\n const globals = win as unknown as Record<string, unknown>;\n globals[\"genframe\"] = genframe;\n globals[\"sendPrompt\"] = sendPrompt;\n globals[\"openLink\"] = openLink;\n // The sandboxed frame cannot write the clipboard, so a widget's own writes are copied by the host too.\n if (win.navigator.clipboard)\n Object.defineProperty(win.navigator.clipboard, \"writeText\", {\n configurable: true,\n value: copyText,\n });\n else\n Object.defineProperty(win.navigator, \"clipboard\", {\n configurable: true,\n value: { writeText: copyText },\n });\n win.open = ((url?: string | URL) => {\n if (url !== undefined) void openLink(String(url)).catch(() => {});\n return null;\n }) as typeof win.open;\n\n doc.addEventListener(\n \"click\",\n (event) => {\n if (event.defaultPrevented || !(event.target instanceof win.Element)) {\n return;\n }\n const anchor = event.target.closest(\"a[href]\");\n if (!anchor) return;\n const href = anchor.getAttribute(\"href\") ?? \"\";\n if (href.startsWith(\"#\")) return;\n let url: URL;\n try {\n url = new URL(href, config.hostOrigin);\n } catch {\n return;\n }\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return;\n event.preventDefault();\n void openLink(url.href).catch(() => {});\n },\n true,\n );\n\n const endResult = (): EndResult => {\n const size = measure();\n return {\n size,\n blank: isBlankRender(root),\n errorCount: diagnostics.errors.length,\n };\n };\n\n const inspect = (): FrameInspection => ({\n kind: renderer.kind,\n ended: renderer.ended,\n size: measure(),\n blank: renderer.ended ? isBlankRender(root) : false,\n errors: [...diagnostics.errors],\n console: [...diagnostics.console],\n });\n\n const onRequest = async (method: string, params: unknown) => {\n const p = (params ?? {}) as Record<string, unknown>;\n switch (method) {\n case METHODS.end:\n await renderer.end();\n scheduleSize();\n return endResult();\n case METHODS.replace:\n if (typeof p[\"code\"] !== \"string\") {\n throw new RpcError(\n RPC_ERROR.invalidParams,\n \"replace requires a string 'code'\",\n );\n }\n await renderer.replace(p[\"code\"]);\n scheduleSize();\n return endResult();\n case METHODS.screenshot:\n renderer.flush();\n return captureScreenshot(root, p as ScreenshotOptions);\n case METHODS.inspect:\n renderer.flush();\n return inspect();\n case METHODS.clearStorage:\n return clearFrameStorage(win);\n default:\n throw new RpcError(\n RPC_ERROR.methodNotFound,\n `Unknown method: ${method}`,\n );\n }\n };\n\n const onNotification = (method: string, params: unknown) => {\n const p = (params ?? {}) as Record<string, unknown>;\n switch (method) {\n case METHODS.write:\n if (typeof p[\"chunk\"] === \"string\") renderer.write(p[\"chunk\"]);\n return;\n case METHODS.hostContextChanged:\n applyContext(p as HostContext);\n return;\n case METHODS.toolInputPartial:\n case METHODS.toolInput: {\n const args = p[\"arguments\"];\n toolInput =\n args && typeof args === \"object\"\n ? (args as Record<string, unknown>)\n : {};\n win.dispatchEvent(\n new CustomEvent(\"toolinput\", {\n detail: {\n arguments: toolInput,\n partial: method === METHODS.toolInputPartial,\n },\n }),\n );\n return;\n }\n case METHODS.toolResult:\n toolOutput =\n p[\"structuredContent\"] !== undefined ? p[\"structuredContent\"] : p;\n win.dispatchEvent(new CustomEvent(\"toolresult\", { detail: p }));\n return;\n default:\n return;\n }\n };\n\n const connect = (port: MessagePort, init: InitMessage) => {\n peer = createRpcPeer(port, { onRequest, onNotification });\n widgetState = init.state ?? null;\n applyContext(init.context ?? {});\n peer.notify(METHODS.ready, { version: VERSION });\n scheduleSize();\n for (const error of diagnostics.errors) peer.notify(METHODS.error, error);\n };\n\n let attempts = 0;\n const announce = () => {\n attempts++;\n if (attempts > READY_ATTEMPTS) win.clearInterval(readyTimer);\n win.parent.postMessage({ type: READY_MESSAGE }, config.hostOrigin);\n };\n const onWindowMessage = (event: MessageEvent) => {\n if (event.source !== win.parent || event.origin !== config.hostOrigin)\n return;\n const data = event.data as Partial<InitMessage> | null;\n if (data?.type !== INIT_MESSAGE || !event.ports[0]) return;\n win.removeEventListener(\"message\", onWindowMessage);\n win.clearInterval(readyTimer);\n connect(event.ports[0], data as InitMessage);\n };\n win.addEventListener(\"message\", onWindowMessage);\n const readyTimer = win.setInterval(announce, READY_INTERVAL_MS);\n announce();\n}\n"],"mappings":";;;;;;;;;AAyBA,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;;AAKvB,SAAgB,aAAa,MAAkC,QAAc;CAC3E,MAAM,MAAM,IAAI;CAChB,MAAM,gBAAgB,IAAI,eAAe,WAAW;CACpD,MAAM,SAAS,KAAK,MAClB,eAAe,eAAe,IAChC;CACA,eAAe,OAAO;CACtB,MAAM,OAAO,IAAI,eAAe,SAAS,KAAK,IAAI;CAElD,IAAI;CACJ,IAAI,UAAuB,CAAC;CAC5B,IAAI,YAA4C;CAChD,IAAI,aAAsB;CAC1B,IAAI,cAAuB;CAC3B,IAAI,WAAuB;EAAE,OAAO;EAAG,QAAQ;CAAE;CAEjD,MAAM,cAAc,mBAAmB,KAAK;EAC1C,UAAU,UAAU,MAAM,OAAO,QAAQ,OAAO,KAAK;EACrD,YAAY,UAAU;GACpB,IAAI,MAAM,UAAU,UAAU,MAAM,UAAU,SAC5C,MAAM,OAAO,QAAQ,KAAK,KAAK;EAEnC;CACF,CAAC;CAED,MAAM,gBAAgB,IAAI,aAAa,kCAAkC;C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xD,OAAO,cAAc,MAAM;GAAE;GAAW;EAAe,CAAC;EACxD,cAAc,KAAK,SAAS;EAC5B,aAAa,KAAK,WAAW,CAAC,CAAC;EAC/B,KAAK,OAAO,QAAQ,OAAO,EAAE,SAAS,QAAQ,CAAC;EAC/C,aAAa;EACb,KAAK,MAAM,SAAS,YAAY,QAAQ,KAAK,OAAO,QAAQ,OAAO,KAAK;CAC1E;CAEA,IAAI,WAAW;CACf,MAAM,iBAAiB;EACrB;EACA,IAAI,WAAW,gBAAgB,IAAI,cAAc,UAAU;EAC3D,IAAI,OAAO,YAAY,EAAE,MAAM,cAAc,GAAG,OAAO,UAAU;CACnE;CACA,MAAM,mBAAmB,UAAwB;EAC/C,IAAI,MAAM,WAAW,IAAI,UAAU,MAAM,WAAW,OAAO,YACzD;EACF,MAAM,OAAO,MAAM;EACnB,IAAI,MAAM,SAAA,mBAAyB,CAAC,MAAM,MAAM,IAAI;EACpD,IAAI,oBAAoB,WAAW,eAAe;EAClD,IAAI,cAAc,UAAU;EAC5B,QAAQ,MAAM,MAAM,IAAI,IAAmB;CAC7C;CACA,IAAI,iBAAiB,WAAW,eAAe;CAC/C,MAAM,aAAa,IAAI,YAAY,UAAU,iBAAiB;CAC9D,SAAS;AACX"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type WidgetKind } from "../protocol.js";
|
|
2
|
+
export declare const SCRIPT_PLACEHOLDER = "gf-script";
|
|
3
|
+
export type ParsedMarkup = {
|
|
4
|
+
fragment: DocumentFragment;
|
|
5
|
+
/** Scripts in document order; each one's position holds a placeholder comment. */
|
|
6
|
+
scripts: Element[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Drops a trailing `<style>` element that has not closed yet, so half-written
|
|
10
|
+
* CSS never applies and then snaps when the rule completes.
|
|
11
|
+
*/
|
|
12
|
+
export declare function stripUnclosedStyle(source: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Parses (possibly partial) markup into a detached fragment. The HTML parser
|
|
15
|
+
* closes open elements and drops a tag cut off mid-way, so any prefix of a
|
|
16
|
+
* document parses into a well-formed tree.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseMarkup(doc: Document, source: string): ParsedMarkup;
|
|
19
|
+
export type MorphContext = {
|
|
20
|
+
onAdded(node: Node): void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Makes `live`'s children match `next`'s, reusing live nodes matched by
|
|
24
|
+
* position and tag. Unmatched nodes move out of `next` into `live`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function morphChildren(live: ParentNode & Node, next: ParentNode & Node, ctx: MorphContext): void;
|
|
27
|
+
export type ScriptRunner = (placeholder: Comment, original: Element) => Promise<void>;
|
|
28
|
+
export type StreamRendererOptions = {
|
|
29
|
+
root: HTMLElement;
|
|
30
|
+
/** Whether newly inserted elements fade in. Checked per insertion. */
|
|
31
|
+
animate?: () => boolean;
|
|
32
|
+
/** Schedules a coalesced render; returns a cancel function. */
|
|
33
|
+
schedule?: (render: () => void) => () => void;
|
|
34
|
+
runScript?: ScriptRunner;
|
|
35
|
+
onScriptError?: (message: string, src: string | undefined) => void;
|
|
36
|
+
onRender?: (kind: WidgetKind) => void;
|
|
37
|
+
};
|
|
38
|
+
export type StreamRenderer = {
|
|
39
|
+
readonly source: string;
|
|
40
|
+
readonly kind: WidgetKind;
|
|
41
|
+
readonly ended: boolean;
|
|
42
|
+
readonly scriptsRan: boolean;
|
|
43
|
+
write(chunk: string): void;
|
|
44
|
+
/** Renders the complete source, then runs held scripts in document order. */
|
|
45
|
+
end(): Promise<void>;
|
|
46
|
+
replace(code: string): Promise<void>;
|
|
47
|
+
flush(): void;
|
|
48
|
+
};
|
|
49
|
+
export declare const createScriptRunner: (onError?: (message: string, src: string | undefined) => void) => ScriptRunner;
|
|
50
|
+
export declare function createStreamRenderer(options: StreamRendererOptions): StreamRenderer;
|
|
51
|
+
//# sourceMappingURL=morph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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