@seed-ship/mcp-ui-solid 1.0.3 → 1.0.4
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/components/GenerativeUIErrorBoundary.cjs +104 -0
- package/dist/components/GenerativeUIErrorBoundary.cjs.map +1 -0
- package/dist/components/GenerativeUIErrorBoundary.js +104 -0
- package/dist/components/GenerativeUIErrorBoundary.js.map +1 -0
- package/dist/components/StreamingUIRenderer.cjs +271 -0
- package/dist/components/StreamingUIRenderer.cjs.map +1 -0
- package/dist/components/StreamingUIRenderer.js +271 -0
- package/dist/components/StreamingUIRenderer.js.map +1 -0
- package/dist/components/UIResourceRenderer.cjs +347 -0
- package/dist/components/UIResourceRenderer.cjs.map +1 -0
- package/dist/components/UIResourceRenderer.js +347 -0
- package/dist/components/UIResourceRenderer.js.map +1 -0
- package/dist/components.cjs +8 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +6 -4
- package/dist/components.js.map +1 -1
- package/dist/hooks/useStreamingUI.cjs +230 -0
- package/dist/hooks/useStreamingUI.cjs.map +1 -0
- package/dist/hooks/useStreamingUI.js +230 -0
- package/dist/hooks/useStreamingUI.js.map +1 -0
- package/dist/hooks.cjs +4 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +2 -2
- package/dist/index.cjs +16 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -293
- package/dist/index.js.map +1 -1
- package/dist/services/component-registry.cjs +295 -0
- package/dist/services/component-registry.cjs.map +1 -0
- package/dist/services/component-registry.js +295 -0
- package/dist/services/component-registry.js.map +1 -0
- package/dist/services/validation.cjs +253 -0
- package/dist/services/validation.cjs.map +1 -0
- package/dist/services/validation.js +253 -0
- package/dist/services/validation.js.map +1 -0
- package/dist/utils/logger.cjs +31 -0
- package/dist/utils/logger.cjs.map +1 -0
- package/dist/utils/logger.js +31 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +1 -1
- package/dist/StreamingUIRenderer-DQ1WoVV6.cjs +0 -5
- package/dist/StreamingUIRenderer-DQ1WoVV6.cjs.map +0 -1
- package/dist/StreamingUIRenderer-oyg_cKKl.js +0 -757
- package/dist/StreamingUIRenderer-oyg_cKKl.js.map +0 -1
- package/dist/useStreamingUI-BL0nh13E.js +0 -187
- package/dist/useStreamingUI-BL0nh13E.js.map +0 -1
- package/dist/useStreamingUI-CXmvpRhz.cjs +0 -3
- package/dist/useStreamingUI-CXmvpRhz.cjs.map +0 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const web = require("solid-js/web");
|
|
4
|
+
const solidJs = require("solid-js");
|
|
5
|
+
const logger$1 = require("../utils/logger.cjs");
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ web.template(`<p class="text-xs text-yellow-600 dark:text-yellow-400 mt-2 font-mono">`), _tmpl$2 = /* @__PURE__ */ web.template(`<button class="mt-3 text-xs font-medium text-yellow-800 dark:text-yellow-200 hover:text-yellow-900 dark:hover:text-yellow-100 underline">Retry Rendering`), _tmpl$3 = /* @__PURE__ */ web.template(`<div class="w-full h-full bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4"><div class="flex items-start gap-3"><div class=flex-shrink-0><svg class="w-5 h-5 text-yellow-600 dark:text-yellow-400"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg></div><div class="flex-1 min-w-0"><p class="text-sm font-medium text-yellow-900 dark:text-yellow-100">Component Failed to Render</p><p class="text-xs text-yellow-700 dark:text-yellow-300 mt-1">Type: <!> | ID: <!>...`);
|
|
7
|
+
const logger = logger$1.createLogger("generative-ui");
|
|
8
|
+
function DefaultErrorFallback(props) {
|
|
9
|
+
return (() => {
|
|
10
|
+
var _el$ = _tmpl$3(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$6.firstChild, _el$0 = _el$7.nextSibling, _el$8 = _el$0.nextSibling, _el$1 = _el$8.nextSibling;
|
|
11
|
+
_el$1.nextSibling;
|
|
12
|
+
web.insert(_el$6, () => props.componentType, _el$0);
|
|
13
|
+
web.insert(_el$6, () => props.componentId.slice(0, 8), _el$1);
|
|
14
|
+
web.insert(_el$4, web.createComponent(solidJs.Show, {
|
|
15
|
+
get when() {
|
|
16
|
+
return false;
|
|
17
|
+
},
|
|
18
|
+
get children() {
|
|
19
|
+
var _el$10 = _tmpl$();
|
|
20
|
+
web.insert(_el$10, () => props.error.message);
|
|
21
|
+
return _el$10;
|
|
22
|
+
}
|
|
23
|
+
}), null);
|
|
24
|
+
web.insert(_el$4, web.createComponent(solidJs.Show, {
|
|
25
|
+
get when() {
|
|
26
|
+
return props.allowRetry;
|
|
27
|
+
},
|
|
28
|
+
get children() {
|
|
29
|
+
var _el$11 = _tmpl$2();
|
|
30
|
+
web.addEventListener(_el$11, "click", props.onRetry, true);
|
|
31
|
+
return _el$11;
|
|
32
|
+
}
|
|
33
|
+
}), null);
|
|
34
|
+
return _el$;
|
|
35
|
+
})();
|
|
36
|
+
}
|
|
37
|
+
const GenerativeUIErrorBoundary = (props) => {
|
|
38
|
+
const [retryKey, setRetryKey] = solidJs.createSignal(0);
|
|
39
|
+
const [renderStartTime] = solidJs.createSignal(performance.now());
|
|
40
|
+
const handleError = (error) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const renderEndTime = performance.now();
|
|
43
|
+
const renderDuration = renderEndTime - renderStartTime();
|
|
44
|
+
const errorContext = {
|
|
45
|
+
componentId: props.componentId,
|
|
46
|
+
componentType: props.componentType,
|
|
47
|
+
errorMessage: error.message,
|
|
48
|
+
errorStack: error.stack,
|
|
49
|
+
renderDuration,
|
|
50
|
+
retryCount: retryKey(),
|
|
51
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
52
|
+
userAgent: navigator.userAgent,
|
|
53
|
+
viewport: {
|
|
54
|
+
width: window.innerWidth,
|
|
55
|
+
height: window.innerHeight
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
logger.error(`Component render failed: ${props.componentType}`, errorContext);
|
|
59
|
+
(_a = props.onError) == null ? void 0 : _a.call(props, {
|
|
60
|
+
type: "render",
|
|
61
|
+
message: error.message,
|
|
62
|
+
componentId: props.componentId,
|
|
63
|
+
details: errorContext
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const handleRetry = () => {
|
|
67
|
+
const newRetryCount = retryKey() + 1;
|
|
68
|
+
logger.info(`Retrying component render: ${props.componentType}`, {
|
|
69
|
+
componentId: props.componentId,
|
|
70
|
+
retryCount: newRetryCount
|
|
71
|
+
});
|
|
72
|
+
setRetryKey(newRetryCount);
|
|
73
|
+
};
|
|
74
|
+
return web.createComponent(solidJs.ErrorBoundary, {
|
|
75
|
+
fallback: (error) => {
|
|
76
|
+
handleError(error);
|
|
77
|
+
if (props.fallback) {
|
|
78
|
+
return props.fallback(error, props.allowRetry ? handleRetry : void 0);
|
|
79
|
+
}
|
|
80
|
+
return web.createComponent(DefaultErrorFallback, {
|
|
81
|
+
error,
|
|
82
|
+
get componentId() {
|
|
83
|
+
return props.componentId;
|
|
84
|
+
},
|
|
85
|
+
get componentType() {
|
|
86
|
+
return props.componentType;
|
|
87
|
+
},
|
|
88
|
+
get allowRetry() {
|
|
89
|
+
return props.allowRetry;
|
|
90
|
+
},
|
|
91
|
+
onRetry: handleRetry
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
get children() {
|
|
95
|
+
return (() => {
|
|
96
|
+
retryKey();
|
|
97
|
+
return web.memo(() => props.children);
|
|
98
|
+
})();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
web.delegateEvents(["click"]);
|
|
103
|
+
exports.GenerativeUIErrorBoundary = GenerativeUIErrorBoundary;
|
|
104
|
+
//# sourceMappingURL=GenerativeUIErrorBoundary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerativeUIErrorBoundary.cjs","sources":["../../src/components/GenerativeUIErrorBoundary.tsx"],"sourcesContent":["/**\n * Generative UI Error Boundary with Telemetry\n * Phase 0: Error isolation + structured logging\n *\n * Features:\n * - Component-level error isolation\n * - Structured logging with context\n * - Performance timing\n * - Retry mechanism\n * - User-friendly fallback UI\n */\n\nimport { Component, ErrorBoundary, createSignal, Show } from 'solid-js'\nimport { createLogger } from '../utils/logger'\nimport type { RendererError } from '../types'\n\nconst logger = createLogger('generative-ui')\n\n/**\n * Props for GenerativeUIErrorBoundary\n */\nexport interface GenerativeUIErrorBoundaryProps {\n /**\n * Component identifier for telemetry\n */\n componentId: string\n\n /**\n * Component type for context\n */\n componentType: string\n\n /**\n * Error callback\n */\n onError?: (error: RendererError) => void\n\n /**\n * Allow retry on error\n */\n allowRetry?: boolean\n\n /**\n * Child components to wrap\n */\n children: any\n\n /**\n * Custom fallback UI (optional)\n */\n fallback?: (error: Error, retry?: () => void) => any\n}\n\n/**\n * Default fallback UI for errors\n */\nfunction DefaultErrorFallback(props: {\n error: Error\n componentId: string\n componentType: string\n allowRetry?: boolean\n onRetry?: () => void\n}) {\n return (\n <div class=\"w-full h-full bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4\">\n <div class=\"flex items-start gap-3\">\n <div class=\"flex-shrink-0\">\n <svg\n class=\"w-5 h-5 text-yellow-600 dark:text-yellow-400\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <div class=\"flex-1 min-w-0\">\n <p class=\"text-sm font-medium text-yellow-900 dark:text-yellow-100\">\n Component Failed to Render\n </p>\n <p class=\"text-xs text-yellow-700 dark:text-yellow-300 mt-1\">\n Type: {props.componentType} | ID: {props.componentId.slice(0, 8)}...\n </p>\n <Show when={import.meta.env.DEV}>\n <p class=\"text-xs text-yellow-600 dark:text-yellow-400 mt-2 font-mono\">\n {props.error.message}\n </p>\n </Show>\n <Show when={props.allowRetry}>\n <button\n onClick={props.onRetry}\n class=\"mt-3 text-xs font-medium text-yellow-800 dark:text-yellow-200 hover:text-yellow-900 dark:hover:text-yellow-100 underline\"\n >\n Retry Rendering\n </button>\n </Show>\n </div>\n </div>\n </div>\n )\n}\n\n/**\n * Generative UI Error Boundary Component\n */\nexport const GenerativeUIErrorBoundary: Component<GenerativeUIErrorBoundaryProps> = (props) => {\n const [retryKey, setRetryKey] = createSignal(0)\n const [renderStartTime] = createSignal(performance.now())\n\n // Handle error with telemetry\n const handleError = (error: Error) => {\n const renderEndTime = performance.now()\n const renderDuration = renderEndTime - renderStartTime()\n\n // Structure error context\n const errorContext = {\n componentId: props.componentId,\n componentType: props.componentType,\n errorMessage: error.message,\n errorStack: error.stack,\n renderDuration,\n retryCount: retryKey(),\n timestamp: new Date().toISOString(),\n userAgent: navigator.userAgent,\n viewport: {\n width: window.innerWidth,\n height: window.innerHeight,\n },\n }\n\n // Log to structured logger\n logger.error(`Component render failed: ${props.componentType}`, errorContext)\n\n // Call error callback\n props.onError?.({\n type: 'render',\n message: error.message,\n componentId: props.componentId,\n details: errorContext,\n })\n\n // In production, send to monitoring service\n if (import.meta.env.PROD) {\n // Future: Send to Sentry or other APM\n // Sentry.captureException(error, { contexts: { component: errorContext } })\n }\n }\n\n // Retry mechanism\n const handleRetry = () => {\n const newRetryCount = retryKey() + 1\n logger.info(`Retrying component render: ${props.componentType}`, {\n componentId: props.componentId,\n retryCount: newRetryCount,\n })\n setRetryKey(newRetryCount)\n }\n\n return (\n <ErrorBoundary\n fallback={(error) => {\n handleError(error)\n\n // Use custom fallback if provided\n if (props.fallback) {\n return props.fallback(error, props.allowRetry ? handleRetry : undefined)\n }\n\n // Default fallback\n return (\n <DefaultErrorFallback\n error={error}\n componentId={props.componentId}\n componentType={props.componentType}\n allowRetry={props.allowRetry}\n onRetry={handleRetry}\n />\n )\n }}\n >\n {/* Key prop for forcing remount on retry */}\n {(() => {\n const _ = retryKey() // Access signal to track changes\n return <>{props.children}</>\n })()}\n </ErrorBoundary>\n )\n}\n\n/**\n * Performance monitoring wrapper\n * Logs render times for performance analysis\n */\nexport function withPerformanceMonitoring<P extends { componentId: string; componentType: string }>(\n WrappedComponent: Component<P>\n) {\n return (props: P) => {\n const renderStart = performance.now()\n\n // Log render start\n logger.debug(`Component render start: ${props.componentType}`, {\n componentId: props.componentId,\n timestamp: new Date().toISOString(),\n })\n\n // Measure on mount completion\n if (typeof window !== 'undefined') {\n requestAnimationFrame(() => {\n const renderEnd = performance.now()\n const duration = renderEnd - renderStart\n\n logger.info(`Component rendered: ${props.componentType}`, {\n componentId: props.componentId,\n renderDuration: duration,\n timestamp: new Date().toISOString(),\n })\n\n // Warn if render is slow (>50ms target)\n if (duration > 50) {\n logger.warn(`Slow component render: ${props.componentType}`, {\n componentId: props.componentId,\n renderDuration: duration,\n threshold: 50,\n })\n }\n })\n }\n\n return <WrappedComponent {...props} />\n }\n}\n\n/**\n * Hook to track component lifecycle events\n */\nexport function useComponentTelemetry(componentId: string, componentType: string) {\n const mountTime = performance.now()\n\n // Log mount\n logger.debug(`Component mounted: ${componentType}`, {\n componentId,\n timestamp: new Date().toISOString(),\n })\n\n // Return cleanup function for unmount\n return () => {\n const lifetime = performance.now() - mountTime\n logger.debug(`Component unmounted: ${componentType}`, {\n componentId,\n lifetime,\n timestamp: new Date().toISOString(),\n })\n }\n}\n"],"names":["logger","createLogger","DefaultErrorFallback","props","_el$","_tmpl$3","_el$2","firstChild","_el$3","_el$4","nextSibling","_el$5","_el$6","_el$7","_el$0","_el$8","_el$1","_$insert","componentType","componentId","slice","_$createComponent","Show","when","import","children","_el$10","_tmpl$","error","message","allowRetry","_el$11","_tmpl$2","_$addEventListener","onRetry","GenerativeUIErrorBoundary","retryKey","setRetryKey","createSignal","renderStartTime","performance","now","handleError","renderEndTime","renderDuration","errorContext","errorMessage","errorStack","stack","retryCount","timestamp","Date","toISOString","userAgent","navigator","viewport","width","window","innerWidth","height","innerHeight","onError","type","details","handleRetry","newRetryCount","info","ErrorBoundary","fallback","undefined","_$memo","_$delegateEvents"],"mappings":";;;;;;AAgBA,MAAMA,SAASC,SAAAA,aAAa,eAAe;AAwC3C,SAASC,qBAAqBC,OAM3B;AACD,UAAA,MAAA;AAAA,QAAAC,OAAAC,WAAAC,QAAAF,KAAAG,YAAAC,QAAAF,MAAAC,YAAAE,QAAAD,MAAAE,aAAAC,QAAAF,MAAAF,YAAAK,QAAAD,MAAAD,aAAAG,QAAAD,MAAAL,YAAAO,QAAAD,MAAAH,aAAAK,QAAAD,MAAAJ,aAAAM,QAAAD,MAAAL;AAAAM,UAAAN;AAAAO,QAAAA,OAAAL,OAAA,MAuBiBT,MAAMe,eAAaJ,KAAA;AAAAG,eAAAL,OAAA,MAAST,MAAMgB,YAAYC,MAAM,GAAG,CAAC,GAACJ,KAAA;AAAAC,eAAAR,OAAAY,IAAAA,gBAEjEC,cAAI;AAAA,MAAA,IAACC,OAAI;AAAA,eAAEC;AAAAA,MAAmB;AAAA,MAAA,IAAAC,WAAA;AAAA,YAAAC,SAAAC,OAAAA;AAAAV,YAAAA,OAAAS,QAAA,MAE1BvB,MAAMyB,MAAMC,OAAO;AAAA,eAAAH;AAAAA,MAAA;AAAA,IAAA,CAAA,GAAA,IAAA;AAAAT,eAAAR,OAAAY,IAAAA,gBAGvBC,c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aAAa,IAAI;AAAA,MAC/DC,aAAahB,MAAMgB;AAAAA,MACnB8B,YAAYgB;AAAAA,IAAAA,CACb;AACD5B,gBAAY4B,aAAa;AAAA,EAC3B;AAEA,SAAA5C,IAAAA,gBACG8C,QAAAA,eAAa;AAAA,IACZC,UAAWxC,CAAAA,UAAU;AACnBc,kBAAYd,KAAK;AAGjB,UAAIzB,MAAMiE,UAAU;AAClB,eAAOjE,MAAMiE,SAASxC,OAAOzB,MAAM2B,aAAakC,cAAcK,MAAS;AAAA,MACzE;AAGA,aAAAhD,IAAAA,gBACGnB,sBAAoB;AAAA,QACnB0B;AAAAA,QAAY,IACZT,cAAW;AAAA,iBAAEhB,MAAMgB;AAAAA,QAAW;AAAA,QAAA,IAC9BD,gBAAa;AAAA,iBAAEf,MAAMe;AAAAA,QAAa;AAAA,QAAA,IAClCY,aAAU;AAAA,iBAAE3B,MAAM2B;AAAAA,QAAU;AAAA,QAC5BI,SAAS8B;AAAAA,MAAAA,CAAW;AAAA,IAG1B;AAAA,IAAC,IAAAvC,WAAA;AAAA,cAGC,MAAM;AACIW,iBAAAA;AACV,eAAAkC,IAAAA,KAAA,MAAUnE,MAAMsB,QAAQ;AAAA,MAC1B,GAAA;AAAA,IAAI;AAAA,EAAA,CAAA;AAGV;AAkEC8C,IAAAA,eAAA,CAAA,OAAA,CAAA;;"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { delegateEvents, createComponent, memo, template, insert, addEventListener } from "solid-js/web";
|
|
2
|
+
import { createSignal, ErrorBoundary, Show } from "solid-js";
|
|
3
|
+
import { createLogger } from "../utils/logger.js";
|
|
4
|
+
var _tmpl$ = /* @__PURE__ */ template(`<p class="text-xs text-yellow-600 dark:text-yellow-400 mt-2 font-mono">`), _tmpl$2 = /* @__PURE__ */ template(`<button class="mt-3 text-xs font-medium text-yellow-800 dark:text-yellow-200 hover:text-yellow-900 dark:hover:text-yellow-100 underline">Retry Rendering`), _tmpl$3 = /* @__PURE__ */ template(`<div class="w-full h-full bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4"><div class="flex items-start gap-3"><div class=flex-shrink-0><svg class="w-5 h-5 text-yellow-600 dark:text-yellow-400"fill=none stroke=currentColor viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg></div><div class="flex-1 min-w-0"><p class="text-sm font-medium text-yellow-900 dark:text-yellow-100">Component Failed to Render</p><p class="text-xs text-yellow-700 dark:text-yellow-300 mt-1">Type: <!> | ID: <!>...`);
|
|
5
|
+
const logger = createLogger("generative-ui");
|
|
6
|
+
function DefaultErrorFallback(props) {
|
|
7
|
+
return (() => {
|
|
8
|
+
var _el$ = _tmpl$3(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$6.firstChild, _el$0 = _el$7.nextSibling, _el$8 = _el$0.nextSibling, _el$1 = _el$8.nextSibling;
|
|
9
|
+
_el$1.nextSibling;
|
|
10
|
+
insert(_el$6, () => props.componentType, _el$0);
|
|
11
|
+
insert(_el$6, () => props.componentId.slice(0, 8), _el$1);
|
|
12
|
+
insert(_el$4, createComponent(Show, {
|
|
13
|
+
get when() {
|
|
14
|
+
return false;
|
|
15
|
+
},
|
|
16
|
+
get children() {
|
|
17
|
+
var _el$10 = _tmpl$();
|
|
18
|
+
insert(_el$10, () => props.error.message);
|
|
19
|
+
return _el$10;
|
|
20
|
+
}
|
|
21
|
+
}), null);
|
|
22
|
+
insert(_el$4, createComponent(Show, {
|
|
23
|
+
get when() {
|
|
24
|
+
return props.allowRetry;
|
|
25
|
+
},
|
|
26
|
+
get children() {
|
|
27
|
+
var _el$11 = _tmpl$2();
|
|
28
|
+
addEventListener(_el$11, "click", props.onRetry, true);
|
|
29
|
+
return _el$11;
|
|
30
|
+
}
|
|
31
|
+
}), null);
|
|
32
|
+
return _el$;
|
|
33
|
+
})();
|
|
34
|
+
}
|
|
35
|
+
const GenerativeUIErrorBoundary = (props) => {
|
|
36
|
+
const [retryKey, setRetryKey] = createSignal(0);
|
|
37
|
+
const [renderStartTime] = createSignal(performance.now());
|
|
38
|
+
const handleError = (error) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const renderEndTime = performance.now();
|
|
41
|
+
const renderDuration = renderEndTime - renderStartTime();
|
|
42
|
+
const errorContext = {
|
|
43
|
+
componentId: props.componentId,
|
|
44
|
+
componentType: props.componentType,
|
|
45
|
+
errorMessage: error.message,
|
|
46
|
+
errorStack: error.stack,
|
|
47
|
+
renderDuration,
|
|
48
|
+
retryCount: retryKey(),
|
|
49
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
50
|
+
userAgent: navigator.userAgent,
|
|
51
|
+
viewport: {
|
|
52
|
+
width: window.innerWidth,
|
|
53
|
+
height: window.innerHeight
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
logger.error(`Component render failed: ${props.componentType}`, errorContext);
|
|
57
|
+
(_a = props.onError) == null ? void 0 : _a.call(props, {
|
|
58
|
+
type: "render",
|
|
59
|
+
message: error.message,
|
|
60
|
+
componentId: props.componentId,
|
|
61
|
+
details: errorContext
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const handleRetry = () => {
|
|
65
|
+
const newRetryCount = retryKey() + 1;
|
|
66
|
+
logger.info(`Retrying component render: ${props.componentType}`, {
|
|
67
|
+
componentId: props.componentId,
|
|
68
|
+
retryCount: newRetryCount
|
|
69
|
+
});
|
|
70
|
+
setRetryKey(newRetryCount);
|
|
71
|
+
};
|
|
72
|
+
return createComponent(ErrorBoundary, {
|
|
73
|
+
fallback: (error) => {
|
|
74
|
+
handleError(error);
|
|
75
|
+
if (props.fallback) {
|
|
76
|
+
return props.fallback(error, props.allowRetry ? handleRetry : void 0);
|
|
77
|
+
}
|
|
78
|
+
return createComponent(DefaultErrorFallback, {
|
|
79
|
+
error,
|
|
80
|
+
get componentId() {
|
|
81
|
+
return props.componentId;
|
|
82
|
+
},
|
|
83
|
+
get componentType() {
|
|
84
|
+
return props.componentType;
|
|
85
|
+
},
|
|
86
|
+
get allowRetry() {
|
|
87
|
+
return props.allowRetry;
|
|
88
|
+
},
|
|
89
|
+
onRetry: handleRetry
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
get children() {
|
|
93
|
+
return (() => {
|
|
94
|
+
retryKey();
|
|
95
|
+
return memo(() => props.children);
|
|
96
|
+
})();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
delegateEvents(["click"]);
|
|
101
|
+
export {
|
|
102
|
+
GenerativeUIErrorBoundary
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=GenerativeUIErrorBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerativeUIErrorBoundary.js","sources":["../../src/components/GenerativeUIErrorBoundary.tsx"],"sourcesContent":["/**\n * Generative UI Error Boundary with Telemetry\n * Phase 0: Error isolation + structured logging\n *\n * Features:\n * - Component-level error isolation\n * - Structured logging with context\n * - Performance timing\n * - Retry mechanism\n * - User-friendly fallback UI\n */\n\nimport { Component, ErrorBoundary, createSignal, Show } from 'solid-js'\nimport { createLogger } from '../utils/logger'\nimport type { RendererError } from '../types'\n\nconst logger = createLogger('generative-ui')\n\n/**\n * Props for GenerativeUIErrorBoundary\n */\nexport interface GenerativeUIErrorBoundaryProps {\n /**\n * Component identifier for telemetry\n */\n componentId: string\n\n /**\n * Component type for context\n */\n componentType: string\n\n /**\n * Error callback\n */\n onError?: (error: RendererError) => void\n\n /**\n * Allow retry on error\n */\n allowRetry?: boolean\n\n /**\n * Child components to wrap\n */\n children: any\n\n /**\n * Custom fallback UI (optional)\n */\n fallback?: (error: Error, retry?: () => void) => any\n}\n\n/**\n * Default fallback UI for errors\n */\nfunction DefaultErrorFallback(props: {\n error: Error\n componentId: string\n componentType: string\n allowRetry?: boolean\n onRetry?: () => void\n}) {\n return (\n <div class=\"w-full h-full bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4\">\n <div class=\"flex items-start gap-3\">\n <div class=\"flex-shrink-0\">\n <svg\n class=\"w-5 h-5 text-yellow-600 dark:text-yellow-400\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <div class=\"flex-1 min-w-0\">\n <p class=\"text-sm font-medium text-yellow-900 dark:text-yellow-100\">\n Component Failed to Render\n </p>\n <p class=\"text-xs text-yellow-700 dark:text-yellow-300 mt-1\">\n Type: {props.componentType} | ID: {props.componentId.slice(0, 8)}...\n </p>\n <Show when={import.meta.env.DEV}>\n <p class=\"text-xs text-yellow-600 dark:text-yellow-400 mt-2 font-mono\">\n {props.error.message}\n </p>\n </Show>\n <Show when={props.allowRetry}>\n <button\n onClick={props.onRetry}\n class=\"mt-3 text-xs font-medium text-yellow-800 dark:text-yellow-200 hover:text-yellow-900 dark:hover:text-yellow-100 underline\"\n >\n Retry Rendering\n </button>\n </Show>\n </div>\n </div>\n </div>\n )\n}\n\n/**\n * Generative UI Error Boundary Component\n */\nexport const GenerativeUIErrorBoundary: Component<GenerativeUIErrorBoundaryProps> = (props) => {\n const [retryKey, setRetryKey] = createSignal(0)\n const [renderStartTime] = createSignal(performance.now())\n\n // Handle error with telemetry\n const handleError = (error: Error) => {\n const renderEndTime = performance.now()\n const renderDuration = renderEndTime - renderStartTime()\n\n // Structure error context\n const errorContext = {\n componentId: props.componentId,\n componentType: props.componentType,\n errorMessage: error.message,\n errorStack: error.stack,\n renderDuration,\n retryCount: retryKey(),\n timestamp: new Date().toISOString(),\n userAgent: navigator.userAgent,\n viewport: {\n width: window.innerWidth,\n height: window.innerHeight,\n },\n }\n\n // Log to structured logger\n logger.error(`Component render failed: ${props.componentType}`, errorContext)\n\n // Call error callback\n props.onError?.({\n type: 'render',\n message: error.message,\n componentId: props.componentId,\n details: errorContext,\n })\n\n // In production, send to monitoring service\n if (import.meta.env.PROD) {\n // Future: Send to Sentry or other APM\n // Sentry.captureException(error, { contexts: { component: errorContext } })\n }\n }\n\n // Retry mechanism\n const handleRetry = () => {\n const newRetryCount = retryKey() + 1\n logger.info(`Retrying component render: ${props.componentType}`, {\n componentId: props.componentId,\n retryCount: newRetryCount,\n })\n setRetryKey(newRetryCount)\n }\n\n return (\n <ErrorBoundary\n fallback={(error) => {\n handleError(error)\n\n // Use custom fallback if provided\n if (props.fallback) {\n return props.fallback(error, props.allowRetry ? handleRetry : undefined)\n }\n\n // Default fallback\n return (\n <DefaultErrorFallback\n error={error}\n componentId={props.componentId}\n componentType={props.componentType}\n allowRetry={props.allowRetry}\n onRetry={handleRetry}\n />\n )\n }}\n >\n {/* Key prop for forcing remount on retry */}\n {(() => {\n const _ = retryKey() // Access signal to track changes\n return <>{props.children}</>\n })()}\n </ErrorBoundary>\n )\n}\n\n/**\n * Performance monitoring wrapper\n * Logs render times for performance analysis\n */\nexport function withPerformanceMonitoring<P extends { componentId: string; componentType: string }>(\n WrappedComponent: Component<P>\n) {\n return (props: P) => {\n const renderStart = performance.now()\n\n // Log render start\n logger.debug(`Component render start: ${props.componentType}`, {\n componentId: props.componentId,\n timestamp: new Date().toISOString(),\n })\n\n // Measure on mount completion\n if (typeof window !== 'undefined') {\n requestAnimationFrame(() => {\n const renderEnd = performance.now()\n const duration = renderEnd - renderStart\n\n logger.info(`Component rendered: ${props.componentType}`, {\n componentId: props.componentId,\n renderDuration: duration,\n timestamp: new Date().toISOString(),\n })\n\n // Warn if render is slow (>50ms target)\n if (duration > 50) {\n logger.warn(`Slow component render: ${props.componentType}`, {\n componentId: props.componentId,\n renderDuration: duration,\n threshold: 50,\n })\n }\n })\n }\n\n return <WrappedComponent {...props} />\n }\n}\n\n/**\n * Hook to track component lifecycle events\n */\nexport function useComponentTelemetry(componentId: string, componentType: string) {\n const mountTime = performance.now()\n\n // Log mount\n logger.debug(`Component mounted: ${componentType}`, {\n componentId,\n timestamp: new Date().toISOString(),\n })\n\n // Return cleanup function for unmount\n return () => {\n const lifetime = performance.now() - mountTime\n logger.debug(`Component unmounted: ${componentType}`, {\n componentId,\n lifetime,\n timestamp: new Date().toISOString(),\n })\n }\n}\n"],"names":["logger","createLogger","DefaultErrorFallback","props","_el$","_tmpl$3","_el$2","firstChild","_el$3","_el$4","nextSibling","_el$5","_el$6","_el$7","_el$0","_el$8","_el$1","_$insert","componentType","componentId","slice","_$createComponent","Show","when","import","children","_el$10","_tmpl$","error","message","allowRetry","_el$11","_tmpl$2","_$addEventListener","onRetry","GenerativeUIErrorBoundary","retryKey","setRetryKey","createSignal","renderStartTime","performance","now","handleError","renderEndTime","renderDuration","errorContext","errorMessage","errorStack","stack","retryCount","timestamp","Date","toISOString","userAgent","navigator","viewport","width","window","innerWidth","height","innerHeight","onError","type","details","handleRetry","newRetryCount","info","ErrorBoundary","fallback","undefined","_$memo","_$delegateEvents"],"mappings":";;;;AAgBA,MAAMA,SAASC,aAAa,eAAe;AAwC3C,SAASC,qBAAqBC,OAM3B;AACD,UAAA,MAAA;AAAA,QAAAC,OAAAC,WAAAC,QAAAF,KAAAG,YAAAC,QAAAF,MAAAC,YAAAE,QAAAD,MAAAE,aAAAC,QAAAF,MAAAF,YAAAK,QAAAD,MAAAD,aAAAG,QAAAD,MAAAL,YAAAO,QAAAD,MAAAH,aAAAK,QAAAD,MAAAJ,aAAAM,QAAAD,MAAAL;AAAAM,UAAAN;AAAAO,WAAA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Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const web = require("solid-js/web");
|
|
4
|
+
const solidJs = require("solid-js");
|
|
5
|
+
const useStreamingUI = require("../hooks/useStreamingUI.cjs");
|
|
6
|
+
const validation = require("../services/validation.cjs");
|
|
7
|
+
const GenerativeUIErrorBoundary = require("./GenerativeUIErrorBoundary.cjs");
|
|
8
|
+
var _tmpl$ = /* @__PURE__ */ web.template(`<div class="w-full bg-error-subtle border border-border-error rounded-lg p-4"><p class="text-sm font-medium text-error-primary">Validation Error</p><p class="text-xs text-text-secondary mt-1">`), _tmpl$2 = /* @__PURE__ */ web.template(`<h3 class="text-sm font-semibold text-text-primary">`), _tmpl$3 = /* @__PURE__ */ web.template(`<span class="text-sm text-text-secondary">`), _tmpl$4 = /* @__PURE__ */ web.template(`<div class=mt-2><p class="text-2xl font-semibold text-text-primary">`), _tmpl$5 = /* @__PURE__ */ web.template(`<div class="w-full bg-surface-secondary border border-border-subtle rounded-lg p-4"><div class="flex items-center gap-2 mb-2"><span class="text-xs font-medium text-text-tertiary uppercase"></span></div><div class="mt-3 text-xs text-text-tertiary">Component ID: <!>...`), _tmpl$6 = /* @__PURE__ */ web.template(`<span class="text-sm text-text-secondary"> / `), _tmpl$7 = /* @__PURE__ */ web.template(`<div class=mt-2><div class="h-1 w-full overflow-hidden rounded-full bg-surface-tertiary"><div class="animate-progress-indeterminate h-full w-1/3 bg-brand-primary">`), _tmpl$8 = /* @__PURE__ */ web.template(`<div class="mb-4 rounded-lg border border-border-subtle bg-surface-secondary p-4"><div class="mb-2 flex items-center justify-between"><span class="text-sm font-medium text-text-primary"></span></div><div class="h-2 w-full overflow-hidden rounded-full bg-surface-tertiary"><div class="h-full bg-brand-primary transition-all duration-300 ease-out">`), _tmpl$9 = /* @__PURE__ */ web.template(`<button type=button class="mt-3 rounded-md bg-error-primary px-3 py-1.5 text-sm font-medium text-white hover:bg-error-hover">Retry`), _tmpl$0 = /* @__PURE__ */ web.template(`<div class="mb-4 rounded-lg border border-border-error bg-error-subtle p-4"><div class="mb-2 flex items-center gap-2"><svg class="h-5 w-5 text-error-primary"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg><span class="font-medium text-error-primary"></span></div><p class="text-sm text-text-secondary">`), _tmpl$1 = /* @__PURE__ */ web.template(`<div><div class="font-medium text-text-primary">Cost</div><div>$`), _tmpl$10 = /* @__PURE__ */ web.template(`<div><div class="font-medium text-text-primary">Cached</div><div class=text-success-primary>Yes`), _tmpl$11 = /* @__PURE__ */ web.template(`<div class="mt-6 rounded-lg border border-border-subtle bg-surface-secondary p-4 text-sm text-text-secondary"><div class="grid grid-cols-2 gap-4 md:grid-cols-4"><div><div class="font-medium text-text-primary">Provider</div><div></div></div><div><div class="font-medium text-text-primary">Model</div><div></div></div><div><div class="font-medium text-text-primary">Execution Time</div><div>ms</div></div><div><div class="font-medium text-text-primary">TTFB</div><div>ms`), _tmpl$12 = /* @__PURE__ */ web.template(`<div><div class="grid grid-cols-12 gap-4">`), _tmpl$13 = /* @__PURE__ */ web.template(`<div>`), _tmpl$14 = /* @__PURE__ */ web.template(`<div class="col-span-12 md:col-span-6 lg:col-span-4"><div class="animate-pulse rounded-lg border border-border-subtle bg-surface-secondary p-4"><div class="mb-4 h-6 w-1/2 rounded bg-surface-tertiary"></div><div class=space-y-3><div class="h-4 rounded bg-surface-tertiary"></div><div class="h-4 w-5/6 rounded bg-surface-tertiary"></div><div class="h-4 w-4/6 rounded bg-surface-tertiary"></div></div><div class="mt-4 h-32 rounded bg-surface-tertiary">`);
|
|
9
|
+
function StreamingComponentRenderer(props) {
|
|
10
|
+
var _a;
|
|
11
|
+
const validation$1 = validation.validateComponent(props.component);
|
|
12
|
+
if (!validation$1.valid) {
|
|
13
|
+
(_a = props.onError) == null ? void 0 : _a.call(props, {
|
|
14
|
+
type: "validation",
|
|
15
|
+
message: "Component validation failed",
|
|
16
|
+
componentId: props.component.id,
|
|
17
|
+
details: validation$1.errors
|
|
18
|
+
});
|
|
19
|
+
return (() => {
|
|
20
|
+
var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
|
|
21
|
+
web.insert(_el$3, () => {
|
|
22
|
+
var _a2, _b;
|
|
23
|
+
return ((_b = (_a2 = validation$1.errors) == null ? void 0 : _a2[0]) == null ? void 0 : _b.message) || "Unknown validation error";
|
|
24
|
+
});
|
|
25
|
+
return _el$;
|
|
26
|
+
})();
|
|
27
|
+
}
|
|
28
|
+
const params = props.component.params;
|
|
29
|
+
return web.createComponent(GenerativeUIErrorBoundary.GenerativeUIErrorBoundary, {
|
|
30
|
+
get componentId() {
|
|
31
|
+
return props.component.id;
|
|
32
|
+
},
|
|
33
|
+
get componentType() {
|
|
34
|
+
return props.component.type;
|
|
35
|
+
},
|
|
36
|
+
get onError() {
|
|
37
|
+
return props.onError;
|
|
38
|
+
},
|
|
39
|
+
allowRetry: false,
|
|
40
|
+
get children() {
|
|
41
|
+
var _el$4 = _tmpl$5(), _el$5 = _el$4.firstChild, _el$6 = _el$5.firstChild, _el$1 = _el$5.nextSibling, _el$10 = _el$1.firstChild, _el$12 = _el$10.nextSibling;
|
|
42
|
+
_el$12.nextSibling;
|
|
43
|
+
web.insert(_el$6, () => props.component.type);
|
|
44
|
+
web.insert(_el$4, web.createComponent(solidJs.Show, {
|
|
45
|
+
get when() {
|
|
46
|
+
return params == null ? void 0 : params.title;
|
|
47
|
+
},
|
|
48
|
+
get children() {
|
|
49
|
+
var _el$7 = _tmpl$2();
|
|
50
|
+
web.insert(_el$7, () => params.title);
|
|
51
|
+
return _el$7;
|
|
52
|
+
}
|
|
53
|
+
}), _el$1);
|
|
54
|
+
web.insert(_el$4, web.createComponent(solidJs.Show, {
|
|
55
|
+
get when() {
|
|
56
|
+
return web.memo(() => props.component.type === "metric")() && (params == null ? void 0 : params.value);
|
|
57
|
+
},
|
|
58
|
+
get children() {
|
|
59
|
+
var _el$8 = _tmpl$4(), _el$9 = _el$8.firstChild;
|
|
60
|
+
web.insert(_el$9, () => params.value);
|
|
61
|
+
web.insert(_el$8, web.createComponent(solidJs.Show, {
|
|
62
|
+
get when() {
|
|
63
|
+
return params.unit;
|
|
64
|
+
},
|
|
65
|
+
get children() {
|
|
66
|
+
var _el$0 = _tmpl$3();
|
|
67
|
+
web.insert(_el$0, () => params.unit);
|
|
68
|
+
return _el$0;
|
|
69
|
+
}
|
|
70
|
+
}), null);
|
|
71
|
+
return _el$8;
|
|
72
|
+
}
|
|
73
|
+
}), _el$1);
|
|
74
|
+
web.insert(_el$1, () => props.component.id.slice(0, 8), _el$12);
|
|
75
|
+
return _el$4;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function StreamingUIRenderer(props) {
|
|
80
|
+
const {
|
|
81
|
+
components,
|
|
82
|
+
isLoading,
|
|
83
|
+
isStreaming,
|
|
84
|
+
error,
|
|
85
|
+
progress,
|
|
86
|
+
metadata,
|
|
87
|
+
startStreaming
|
|
88
|
+
} = useStreamingUI.useStreamingUI({
|
|
89
|
+
query: props.query,
|
|
90
|
+
spaceIds: props.spaceIds,
|
|
91
|
+
sessionId: props.sessionId,
|
|
92
|
+
options: props.options,
|
|
93
|
+
onComplete: props.onComplete,
|
|
94
|
+
onError: props.onError,
|
|
95
|
+
onComponentReceived: props.onComponentReceived
|
|
96
|
+
});
|
|
97
|
+
const [animatingComponents, setAnimatingComponents] = solidJs.createSignal(/* @__PURE__ */ new Set());
|
|
98
|
+
const handleComponentRender = (componentId) => {
|
|
99
|
+
setAnimatingComponents((prev) => /* @__PURE__ */ new Set([...prev, componentId]));
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
setAnimatingComponents((prev) => {
|
|
102
|
+
const next = new Set(prev);
|
|
103
|
+
next.delete(componentId);
|
|
104
|
+
return next;
|
|
105
|
+
});
|
|
106
|
+
}, 500);
|
|
107
|
+
};
|
|
108
|
+
return (() => {
|
|
109
|
+
var _el$13 = _tmpl$12(), _el$28 = _el$13.firstChild;
|
|
110
|
+
web.insert(_el$13, web.createComponent(solidJs.Show, {
|
|
111
|
+
get when() {
|
|
112
|
+
return web.memo(() => props.showProgress !== false)() && (isLoading() || isStreaming());
|
|
113
|
+
},
|
|
114
|
+
get children() {
|
|
115
|
+
var _el$14 = _tmpl$8(), _el$15 = _el$14.firstChild, _el$16 = _el$15.firstChild, _el$19 = _el$15.nextSibling, _el$20 = _el$19.firstChild;
|
|
116
|
+
web.insert(_el$16, () => progress().message);
|
|
117
|
+
web.insert(_el$15, web.createComponent(solidJs.Show, {
|
|
118
|
+
get when() {
|
|
119
|
+
return progress().totalCount !== null;
|
|
120
|
+
},
|
|
121
|
+
get children() {
|
|
122
|
+
var _el$17 = _tmpl$6(), _el$18 = _el$17.firstChild;
|
|
123
|
+
web.insert(_el$17, () => progress().receivedCount, _el$18);
|
|
124
|
+
web.insert(_el$17, () => progress().totalCount, null);
|
|
125
|
+
return _el$17;
|
|
126
|
+
}
|
|
127
|
+
}), null);
|
|
128
|
+
web.insert(_el$14, web.createComponent(solidJs.Show, {
|
|
129
|
+
get when() {
|
|
130
|
+
return web.memo(() => progress().totalCount === null)() && isStreaming();
|
|
131
|
+
},
|
|
132
|
+
get children() {
|
|
133
|
+
return _tmpl$7();
|
|
134
|
+
}
|
|
135
|
+
}), null);
|
|
136
|
+
web.effect((_$p) => web.setStyleProperty(_el$20, "width", progress().totalCount !== null ? `${progress().receivedCount / progress().totalCount * 100}%` : "0%"));
|
|
137
|
+
return _el$14;
|
|
138
|
+
}
|
|
139
|
+
}), _el$28);
|
|
140
|
+
web.insert(_el$13, web.createComponent(solidJs.Show, {
|
|
141
|
+
get when() {
|
|
142
|
+
return error();
|
|
143
|
+
},
|
|
144
|
+
get children() {
|
|
145
|
+
var _el$22 = _tmpl$0(), _el$23 = _el$22.firstChild, _el$24 = _el$23.firstChild, _el$25 = _el$24.nextSibling, _el$26 = _el$23.nextSibling;
|
|
146
|
+
web.insert(_el$25, () => {
|
|
147
|
+
var _a;
|
|
148
|
+
return (_a = error()) == null ? void 0 : _a.error;
|
|
149
|
+
});
|
|
150
|
+
web.insert(_el$26, () => {
|
|
151
|
+
var _a;
|
|
152
|
+
return (_a = error()) == null ? void 0 : _a.message;
|
|
153
|
+
});
|
|
154
|
+
web.insert(_el$22, web.createComponent(solidJs.Show, {
|
|
155
|
+
get when() {
|
|
156
|
+
var _a;
|
|
157
|
+
return (_a = error()) == null ? void 0 : _a.recoverable;
|
|
158
|
+
},
|
|
159
|
+
get children() {
|
|
160
|
+
var _el$27 = _tmpl$9();
|
|
161
|
+
_el$27.$$click = () => startStreaming();
|
|
162
|
+
return _el$27;
|
|
163
|
+
}
|
|
164
|
+
}), null);
|
|
165
|
+
return _el$22;
|
|
166
|
+
}
|
|
167
|
+
}), _el$28);
|
|
168
|
+
web.insert(_el$28, web.createComponent(solidJs.For, {
|
|
169
|
+
get each() {
|
|
170
|
+
return components();
|
|
171
|
+
},
|
|
172
|
+
children: (component) => (() => {
|
|
173
|
+
var _el$50 = _tmpl$13();
|
|
174
|
+
web.use(() => handleComponentRender(component.id), _el$50);
|
|
175
|
+
web.insert(_el$50, web.createComponent(StreamingComponentRenderer, {
|
|
176
|
+
component,
|
|
177
|
+
get onError() {
|
|
178
|
+
return props.onRenderError;
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
web.effect((_p$) => {
|
|
182
|
+
var _v$ = `
|
|
183
|
+
col-span-${component.position.colSpan}
|
|
184
|
+
${animatingComponents().has(component.id) ? "animate-fade-in-up" : ""}
|
|
185
|
+
`, _v$2 = component.position.colStart, _v$3 = component.position.colStart + component.position.colSpan;
|
|
186
|
+
_v$ !== _p$.e && web.className(_el$50, _p$.e = _v$);
|
|
187
|
+
_v$2 !== _p$.t && web.setStyleProperty(_el$50, "grid-column-start", _p$.t = _v$2);
|
|
188
|
+
_v$3 !== _p$.a && web.setStyleProperty(_el$50, "grid-column-end", _p$.a = _v$3);
|
|
189
|
+
return _p$;
|
|
190
|
+
}, {
|
|
191
|
+
e: void 0,
|
|
192
|
+
t: void 0,
|
|
193
|
+
a: void 0
|
|
194
|
+
});
|
|
195
|
+
return _el$50;
|
|
196
|
+
})()
|
|
197
|
+
}), null);
|
|
198
|
+
web.insert(_el$28, web.createComponent(solidJs.Show, {
|
|
199
|
+
get when() {
|
|
200
|
+
return web.memo(() => !!isStreaming())() && progress().totalCount !== null;
|
|
201
|
+
},
|
|
202
|
+
get children() {
|
|
203
|
+
return web.createComponent(solidJs.For, {
|
|
204
|
+
get each() {
|
|
205
|
+
return Array.from({
|
|
206
|
+
length: progress().totalCount - progress().receivedCount
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
children: () => web.createComponent(SkeletonComponent, {})
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}), null);
|
|
213
|
+
web.insert(_el$13, web.createComponent(solidJs.Show, {
|
|
214
|
+
get when() {
|
|
215
|
+
return web.memo(() => props.showMetadata !== false)() && metadata();
|
|
216
|
+
},
|
|
217
|
+
get children() {
|
|
218
|
+
var _el$29 = _tmpl$11(), _el$30 = _el$29.firstChild, _el$31 = _el$30.firstChild, _el$32 = _el$31.firstChild, _el$33 = _el$32.nextSibling, _el$34 = _el$31.nextSibling, _el$35 = _el$34.firstChild, _el$36 = _el$35.nextSibling, _el$37 = _el$34.nextSibling, _el$38 = _el$37.firstChild, _el$39 = _el$38.nextSibling, _el$40 = _el$39.firstChild, _el$45 = _el$37.nextSibling, _el$46 = _el$45.firstChild, _el$47 = _el$46.nextSibling, _el$48 = _el$47.firstChild;
|
|
219
|
+
web.insert(_el$33, () => {
|
|
220
|
+
var _a;
|
|
221
|
+
return (_a = metadata()) == null ? void 0 : _a.provider;
|
|
222
|
+
});
|
|
223
|
+
web.insert(_el$36, () => {
|
|
224
|
+
var _a;
|
|
225
|
+
return (_a = metadata()) == null ? void 0 : _a.model;
|
|
226
|
+
});
|
|
227
|
+
web.insert(_el$39, () => {
|
|
228
|
+
var _a;
|
|
229
|
+
return (_a = metadata()) == null ? void 0 : _a.executionTimeMs;
|
|
230
|
+
}, _el$40);
|
|
231
|
+
web.insert(_el$30, web.createComponent(solidJs.Show, {
|
|
232
|
+
get when() {
|
|
233
|
+
var _a;
|
|
234
|
+
return ((_a = metadata()) == null ? void 0 : _a.costUSD) !== void 0;
|
|
235
|
+
},
|
|
236
|
+
get children() {
|
|
237
|
+
var _el$41 = _tmpl$1(), _el$42 = _el$41.firstChild, _el$43 = _el$42.nextSibling;
|
|
238
|
+
_el$43.firstChild;
|
|
239
|
+
web.insert(_el$43, () => {
|
|
240
|
+
var _a, _b;
|
|
241
|
+
return (_b = (_a = metadata()) == null ? void 0 : _a.costUSD) == null ? void 0 : _b.toFixed(4);
|
|
242
|
+
}, null);
|
|
243
|
+
return _el$41;
|
|
244
|
+
}
|
|
245
|
+
}), _el$45);
|
|
246
|
+
web.insert(_el$47, () => {
|
|
247
|
+
var _a;
|
|
248
|
+
return (_a = metadata()) == null ? void 0 : _a.firstTokenMs;
|
|
249
|
+
}, _el$48);
|
|
250
|
+
web.insert(_el$30, web.createComponent(solidJs.Show, {
|
|
251
|
+
get when() {
|
|
252
|
+
var _a;
|
|
253
|
+
return (_a = metadata()) == null ? void 0 : _a.cached;
|
|
254
|
+
},
|
|
255
|
+
get children() {
|
|
256
|
+
return _tmpl$10();
|
|
257
|
+
}
|
|
258
|
+
}), null);
|
|
259
|
+
return _el$29;
|
|
260
|
+
}
|
|
261
|
+
}), null);
|
|
262
|
+
web.effect(() => web.className(_el$13, `streaming-ui-renderer ${props.class || ""}`));
|
|
263
|
+
return _el$13;
|
|
264
|
+
})();
|
|
265
|
+
}
|
|
266
|
+
function SkeletonComponent() {
|
|
267
|
+
return _tmpl$14();
|
|
268
|
+
}
|
|
269
|
+
web.delegateEvents(["click"]);
|
|
270
|
+
exports.StreamingUIRenderer = StreamingUIRenderer;
|
|
271
|
+
//# sourceMappingURL=StreamingUIRenderer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingUIRenderer.cjs","sources":["../../src/components/StreamingUIRenderer.tsx"],"sourcesContent":["/**\n * StreamingUIRenderer Component - Phase 2\n *\n * Renders streaming dashboard components with skeleton states and progress indicators.\n * Uses the useStreamingUI hook for SSE connection and state management.\n *\n * Features:\n * - Skeleton loading states while components stream\n * - Progress bar and status messages\n * - Smooth component animations on arrival\n * - Error handling with retry capability\n * - Responsive 12-column grid layout\n *\n * Usage:\n * ```tsx\n * <StreamingUIRenderer\n * query=\"Show me revenue trends\"\n * spaceIds={['uuid1', 'uuid2']}\n * onComplete={(metadata) => console.log('Done!', metadata)}\n * />\n * ```\n */\n\nimport { Show, For, createSignal } from 'solid-js'\nimport { useStreamingUI, type UseStreamingUIOptions } from '../hooks/useStreamingUI'\nimport type { UIComponent, RendererError } from '../types'\nimport { validateComponent } from '../services/validation'\nimport { GenerativeUIErrorBoundary } from './GenerativeUIErrorBoundary'\n\nexport interface StreamingUIRendererProps extends UseStreamingUIOptions {\n class?: string\n showProgress?: boolean\n showMetadata?: boolean\n onRenderError?: (error: RendererError) => void\n}\n\n/**\n * Component Renderer - Inline lightweight version\n * (Full implementation in UIResourceRenderer)\n */\nfunction StreamingComponentRenderer(props: {\n component: UIComponent\n onError?: (error: RendererError) => void\n}) {\n // Validate component before rendering\n const validation = validateComponent(props.component)\n if (!validation.valid) {\n props.onError?.({\n type: 'validation',\n message: 'Component validation failed',\n componentId: props.component.id,\n details: validation.errors,\n })\n\n return (\n <div class=\"w-full bg-error-subtle border border-border-error rounded-lg p-4\">\n <p class=\"text-sm font-medium text-error-primary\">Validation Error</p>\n <p class=\"text-xs text-text-secondary mt-1\">\n {validation.errors?.[0]?.message || 'Unknown validation error'}\n </p>\n </div>\n )\n }\n\n // Simplified renderer - just show component type and title\n // Full rendering logic in UIResourceRenderer\n const params = props.component.params as any\n\n return (\n <GenerativeUIErrorBoundary\n componentId={props.component.id}\n componentType={props.component.type}\n onError={props.onError}\n allowRetry={false}\n >\n <div class=\"w-full bg-surface-secondary border border-border-subtle rounded-lg p-4\">\n <div class=\"flex items-center gap-2 mb-2\">\n <span class=\"text-xs font-medium text-text-tertiary uppercase\">\n {props.component.type}\n </span>\n </div>\n <Show when={params?.title}>\n <h3 class=\"text-sm font-semibold text-text-primary\">{params.title}</h3>\n </Show>\n <Show when={props.component.type === 'metric' && params?.value}>\n <div class=\"mt-2\">\n <p class=\"text-2xl font-semibold text-text-primary\">{params.value}</p>\n <Show when={params.unit}>\n <span class=\"text-sm text-text-secondary\">{params.unit}</span>\n </Show>\n </div>\n </Show>\n <div class=\"mt-3 text-xs text-text-tertiary\">\n Component ID: {props.component.id.slice(0, 8)}...\n </div>\n </div>\n </GenerativeUIErrorBoundary>\n )\n}\n\nexport function StreamingUIRenderer(props: StreamingUIRendererProps) {\n const { components, isLoading, isStreaming, error, progress, metadata, startStreaming } =\n useStreamingUI({\n query: props.query,\n spaceIds: props.spaceIds,\n sessionId: props.sessionId,\n options: props.options,\n onComplete: props.onComplete,\n onError: props.onError,\n onComponentReceived: props.onComponentReceived,\n })\n\n const [animatingComponents, setAnimatingComponents] = createSignal<Set<string>>(new Set())\n\n // Track new components for animation\n const handleComponentRender = (componentId: string) => {\n setAnimatingComponents((prev) => new Set([...prev, componentId]))\n\n // Remove from animating set after animation completes\n setTimeout(() => {\n setAnimatingComponents((prev) => {\n const next = new Set(prev)\n next.delete(componentId)\n return next\n })\n }, 500)\n }\n\n return (\n <div class={`streaming-ui-renderer ${props.class || ''}`}>\n {/* Progress Bar */}\n <Show when={props.showProgress !== false && (isLoading() || isStreaming())}>\n <div class=\"mb-4 rounded-lg border border-border-subtle bg-surface-secondary p-4\">\n {/* Status Message */}\n <div class=\"mb-2 flex items-center justify-between\">\n <span class=\"text-sm font-medium text-text-primary\">{progress().message}</span>\n <Show when={progress().totalCount !== null}>\n <span class=\"text-sm text-text-secondary\">\n {progress().receivedCount} / {progress().totalCount}\n </span>\n </Show>\n </div>\n\n {/* Progress Bar */}\n <div class=\"h-2 w-full overflow-hidden rounded-full bg-surface-tertiary\">\n <div\n class=\"h-full bg-brand-primary transition-all duration-300 ease-out\"\n style={{\n width:\n progress().totalCount !== null\n ? `${(progress().receivedCount / progress().totalCount!) * 100}%`\n : '0%',\n }}\n />\n </div>\n\n {/* Indeterminate Progress (when totalCount unknown) */}\n <Show when={progress().totalCount === null && isStreaming()}>\n <div class=\"mt-2\">\n <div class=\"h-1 w-full overflow-hidden rounded-full bg-surface-tertiary\">\n <div class=\"animate-progress-indeterminate h-full w-1/3 bg-brand-primary\" />\n </div>\n </div>\n </Show>\n </div>\n </Show>\n\n {/* Error State */}\n <Show when={error()}>\n <div class=\"mb-4 rounded-lg border border-border-error bg-error-subtle p-4\">\n <div class=\"mb-2 flex items-center gap-2\">\n <svg\n class=\"h-5 w-5 text-error-primary\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\"\n />\n </svg>\n <span class=\"font-medium text-error-primary\">{error()?.error}</span>\n </div>\n <p class=\"text-sm text-text-secondary\">{error()?.message}</p>\n\n {/* Retry Button (if recoverable) */}\n <Show when={error()?.recoverable}>\n <button\n type=\"button\"\n class=\"mt-3 rounded-md bg-error-primary px-3 py-1.5 text-sm font-medium text-white hover:bg-error-hover\"\n onClick={() => startStreaming()}\n >\n Retry\n </button>\n </Show>\n </div>\n </Show>\n\n {/* Components Grid */}\n <div class=\"grid grid-cols-12 gap-4\">\n {/* Render received components */}\n <For each={components()}>\n {(component) => (\n <div\n ref={() => handleComponentRender(component.id)}\n class={`\n col-span-${component.position.colSpan}\n ${animatingComponents().has(component.id) ? 'animate-fade-in-up' : ''}\n `}\n style={{\n 'grid-column-start': component.position.colStart,\n 'grid-column-end': component.position.colStart + component.position.colSpan,\n }}\n >\n <StreamingComponentRenderer component={component} onError={props.onRenderError} />\n </div>\n )}\n </For>\n\n {/* Skeleton placeholders (if streaming and expecting more) */}\n <Show when={isStreaming() && progress().totalCount !== null}>\n <For\n each={Array.from({\n length: progress().totalCount! - progress().receivedCount,\n })}\n >\n {() => <SkeletonComponent />}\n </For>\n </Show>\n </div>\n\n {/* Metadata Display */}\n <Show when={props.showMetadata !== false && metadata()}>\n <div class=\"mt-6 rounded-lg border border-border-subtle bg-surface-secondary p-4 text-sm text-text-secondary\">\n <div class=\"grid grid-cols-2 gap-4 md:grid-cols-4\">\n <div>\n <div class=\"font-medium text-text-primary\">Provider</div>\n <div>{metadata()?.provider}</div>\n </div>\n <div>\n <div class=\"font-medium text-text-primary\">Model</div>\n <div>{metadata()?.model}</div>\n </div>\n <div>\n <div class=\"font-medium text-text-primary\">Execution Time</div>\n <div>{metadata()?.executionTimeMs}ms</div>\n </div>\n <Show when={metadata()?.costUSD !== undefined}>\n <div>\n <div class=\"font-medium text-text-primary\">Cost</div>\n <div>${metadata()?.costUSD?.toFixed(4)}</div>\n </div>\n </Show>\n <div>\n <div class=\"font-medium text-text-primary\">TTFB</div>\n <div>{metadata()?.firstTokenMs}ms</div>\n </div>\n <Show when={metadata()?.cached}>\n <div>\n <div class=\"font-medium text-text-primary\">Cached</div>\n <div class=\"text-success-primary\">Yes</div>\n </div>\n </Show>\n </div>\n </div>\n </Show>\n </div>\n )\n}\n\n/**\n * Skeleton Component - Placeholder while components load\n */\nfunction SkeletonComponent() {\n return (\n <div class=\"col-span-12 md:col-span-6 lg:col-span-4\">\n <div class=\"animate-pulse rounded-lg border border-border-subtle bg-surface-secondary p-4\">\n {/* Header skeleton */}\n <div class=\"mb-4 h-6 w-1/2 rounded bg-surface-tertiary\" />\n\n {/* Content skeleton */}\n <div class=\"space-y-3\">\n <div class=\"h-4 rounded bg-surface-tertiary\" />\n <div class=\"h-4 w-5/6 rounded bg-surface-tertiary\" />\n <div class=\"h-4 w-4/6 rounded bg-surface-tertiary\" />\n </div>\n\n {/* Chart/visual skeleton */}\n <div class=\"mt-4 h-32 rounded bg-surface-tertiary\" />\n </div>\n </div>\n )\n}\n\n// CSS Animations (add to global styles or Tailwind config)\n/*\n@keyframes fade-in-up {\n from {\n opacity: 0;\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes progress-indeterminate {\n 0% {\n transform: translateX(-100%);\n }\n 100% {\n transform: translateX(400%);\n }\n}\n\n.animate-fade-in-up {\n animation: fade-in-up 0.5s ease-out;\n}\n\n.animate-progress-indeterminate {\n animation: progress-indeterminate 1.5s infinite ease-in-out;\n}\n*/\n"],"names":["StreamingComponentRenderer","props","validation","validateComponent","component","valid","onError","type","message","componentId","id","details","errors","_el$","_tmpl$","_el$2","firstChild","_el$3","nextSibling","_$insert","params","_$createComponent","GenerativeUIErrorBoundary","componentType","allowRetry","children","_el$4","_tmpl$5","_el$5","_el$6","_el$1","_el$10","_el$12","Show","when","title","_el$7","_tmpl$2","_$memo","value","_el$8","_tmpl$4","_el$9","unit","_el$0","_tmpl$3","slice","StreamingUIRenderer","components","isLoading","isStreaming","error","progress","metadata","startStreaming","useStreamingUI","query","spaceIds","sessionId","options","onComplete","onComponentReceived","animatingComponents","setAnimatingComponents","createSignal","Set","handleComponentRender","prev","setTimeout","next","delete","_el$13","_tmpl$12","_el$28","showProgress","_el$14","_tmpl$8","_el$15","_el$16","_el$19","_el$20","totalCount","_el$17","_tmpl$6","_el$18","receivedCount","_tmpl$7","_$effect","_$p","_$setStyleProperty","_el$22","_tmpl$0","_el$23","_el$24","_el$25","_el$26","recoverable","_el$27","_tmpl$9","$$click","For","each","_el$50","_tmpl$13","_$use","onRenderError","_p$","_v$","position","colSpan","has","_v$2","colStart","_v$3","e","_$className","t","a","undefined","Array","from","length","SkeletonComponent","showMetadata","_el$29","_tmpl$11","_el$30","_el$31","_el$32","_el$33","_el$34","_el$35","_el$36","_el$37","_el$38","_el$39","_el$40","_el$45","_el$46","_el$47","_el$48","provider","model","executionTimeMs","costUSD","_el$41","_tmpl$1","_el$42","_el$43","toFixed","firstTokenMs","cached","_tmpl$10","class","_tmpl$14","_$delegateEvents"],"mappings":";;;;;;;;AAwCA,SAASA,2BAA2BC,OAGjC;;AAED,QAAMC,eAAaC,WAAAA,kBAAkBF,MAAMG,SAAS;AACpD,MAAI,CAACF,aAAWG,OAAO;AACrBJ,gBAAMK,YAANL,+BAAgB;AAAA,MACdM,MAAM;AAAA,MACNC,SAAS;AAAA,MACTC,aAAaR,MAAMG,UAAUM;AAAAA,MAC7BC,SAAST,aAAWU;AAAAA,IAAAA;AAGtB,YAAA,MAAA;AAAA,UAAAC,OAAAC,OAAAA,GAAAC,QAAAF,KAAAG,YAAAC,QAAAF,MAAAG;AAAAC,UAAAA,OAAAF,OAAA;;AAIOf,uBAAAA,MAAAA,aAAWU,WAAXV,gBAAAA,IAAoB,OAApBA,mBAAwBM,YAAW;AAAA,OAA0B;AAAA,aAAAK;AAAAA,IAAA,GAAA;AAAA,EAItE;AAIA,QAAMO,SAASnB,MAAMG,UAAUgB;AAE/B,SAAAC,IAAAA,gBACGC,0BAAAA,2BAAyB;AAAA,IAAA,IACxBb,cAAW;AAAA,aAAER,MAAMG,UAAUM;AAAAA,IAAE;AAAA,IAAA,IAC/Ba,gBAAa;AAAA,aAAEtB,MAAMG,UAAUG;AAAAA,IAAI;AAAA,IAAA,IACnCD,UAAO;AAAA,aAAEL,MAAMK;AAAAA,IAAO;AAAA,IACtBkB,YAAY;AAAA,IAAK,IAAAC,WAAA;AAAA,UAAAC,QAAAC,QAAAA,GAAAC,QAAAF,MAAAV,YAAAa,QAAAD,MAAAZ,YAAAc,QAAAF,MAAAV,aAAAa,SAAAD,MAAAd,YAAAgB,SAAAD,OAAAb;AAAAc,aAAAd;AAAAC,UAAAA,OAAAU,OAAA,MAKV5B,MAAMG,UAAUG,IAAI;AAAAY,iBA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