@seed-ship/mcp-ui-solid 2.2.7 → 2.2.9
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/UIResourceRenderer.cjs +80 -73
- package/dist/components/UIResourceRenderer.cjs.map +1 -1
- package/dist/components/UIResourceRenderer.d.ts.map +1 -1
- package/dist/components/UIResourceRenderer.js +80 -73
- package/dist/components/UIResourceRenderer.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChartRenderer.test.tsx +43 -0
- package/src/components/UIResourceRenderer.tsx +52 -51
- package/src/components/renderCellValue.test.ts +24 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -168,9 +168,55 @@ function ChartRenderer(props: {
|
|
|
168
168
|
setIsLoading(false)
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
// Reactive switch between native Chart.js and iframe fallback
|
|
172
|
+
// Must use <Show> — signals in component body are not reactive in SolidJS
|
|
173
|
+
return (
|
|
174
|
+
<Show
|
|
175
|
+
when={useNative()}
|
|
176
|
+
fallback={
|
|
177
|
+
<div class="relative w-full h-full min-h-[300px] bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden">
|
|
178
|
+
<Show when={isLoading()}>
|
|
179
|
+
<div class="absolute inset-0 flex items-center justify-center">
|
|
180
|
+
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600" />
|
|
181
|
+
</div>
|
|
182
|
+
</Show>
|
|
183
|
+
|
|
184
|
+
<Show when={error()}>
|
|
185
|
+
<div class="absolute inset-0 flex items-center justify-center p-4">
|
|
186
|
+
<div class="text-center">
|
|
187
|
+
<p class="text-red-600 dark:text-red-400 text-sm font-medium">Chart Error</p>
|
|
188
|
+
<p class="text-gray-600 dark:text-gray-400 text-xs mt-1">{error()}</p>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
</Show>
|
|
192
|
+
|
|
193
|
+
<Show when={iframeUrl() && !error()}>
|
|
194
|
+
<div class="w-full h-full p-4">
|
|
195
|
+
<Show when={params()?.title}>
|
|
196
|
+
<h3 class="text-sm font-semibold text-gray-900 dark:text-white mb-3">
|
|
197
|
+
{params()?.title}
|
|
198
|
+
</h3>
|
|
199
|
+
</Show>
|
|
200
|
+
<div class="w-full h-full" role="img" aria-label={params()?.title ? `Chart: ${params()?.title}` : 'Chart visualization'}>
|
|
201
|
+
<img
|
|
202
|
+
src={iframeUrl()}
|
|
203
|
+
alt={params()?.title ? `Chart: ${params()?.title}` : 'Chart visualization'}
|
|
204
|
+
class="w-full h-auto max-h-[300px] object-contain"
|
|
205
|
+
onError={() => {
|
|
206
|
+
setError('Failed to load chart')
|
|
207
|
+
props.onError?.({
|
|
208
|
+
type: 'render',
|
|
209
|
+
message: 'Chart rendering failed',
|
|
210
|
+
componentId: props.component.id,
|
|
211
|
+
})
|
|
212
|
+
}}
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
</Show>
|
|
217
|
+
</div>
|
|
218
|
+
}
|
|
219
|
+
>
|
|
174
220
|
<ChartJSRenderer
|
|
175
221
|
component={props.component}
|
|
176
222
|
onError={(err) => props.onError?.({
|
|
@@ -179,52 +225,7 @@ function ChartRenderer(props: {
|
|
|
179
225
|
componentId: props.component.id,
|
|
180
226
|
})}
|
|
181
227
|
/>
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Iframe fallback (Quickchart.io)
|
|
186
|
-
return (
|
|
187
|
-
<div class="relative w-full h-full min-h-[300px] bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden">
|
|
188
|
-
<Show when={isLoading()}>
|
|
189
|
-
<div class="absolute inset-0 flex items-center justify-center">
|
|
190
|
-
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600" />
|
|
191
|
-
</div>
|
|
192
|
-
</Show>
|
|
193
|
-
|
|
194
|
-
<Show when={error()}>
|
|
195
|
-
<div class="absolute inset-0 flex items-center justify-center p-4">
|
|
196
|
-
<div class="text-center">
|
|
197
|
-
<p class="text-red-600 dark:text-red-400 text-sm font-medium">Chart Error</p>
|
|
198
|
-
<p class="text-gray-600 dark:text-gray-400 text-xs mt-1">{error()}</p>
|
|
199
|
-
</div>
|
|
200
|
-
</div>
|
|
201
|
-
</Show>
|
|
202
|
-
|
|
203
|
-
<Show when={iframeUrl() && !error()}>
|
|
204
|
-
<div class="w-full h-full p-4">
|
|
205
|
-
<Show when={params()?.title}>
|
|
206
|
-
<h3 class="text-sm font-semibold text-gray-900 dark:text-white mb-3">
|
|
207
|
-
{params()?.title}
|
|
208
|
-
</h3>
|
|
209
|
-
</Show>
|
|
210
|
-
<div class="w-full h-full" role="img" aria-label={params()?.title ? `Chart: ${params()?.title}` : 'Chart visualization'}>
|
|
211
|
-
<img
|
|
212
|
-
src={iframeUrl()}
|
|
213
|
-
alt={params()?.title ? `Chart: ${params()?.title}` : 'Chart visualization'}
|
|
214
|
-
class="w-full h-auto max-h-[300px] object-contain"
|
|
215
|
-
onError={() => {
|
|
216
|
-
setError('Failed to load chart')
|
|
217
|
-
props.onError?.({
|
|
218
|
-
type: 'render',
|
|
219
|
-
message: 'Chart rendering failed',
|
|
220
|
-
componentId: props.component.id,
|
|
221
|
-
})
|
|
222
|
-
}}
|
|
223
|
-
/>
|
|
224
|
-
</div>
|
|
225
|
-
</div>
|
|
226
|
-
</Show>
|
|
227
|
-
</div>
|
|
228
|
+
</Show>
|
|
228
229
|
)
|
|
229
230
|
}
|
|
230
231
|
|
|
@@ -291,8 +292,8 @@ export function renderCellValue(value: any): string {
|
|
|
291
292
|
const hasHtml = /<[a-z][\s\S]*>/i.test(strValue)
|
|
292
293
|
if (hasHtml) {
|
|
293
294
|
return DOMPurify.sanitize(strValue, {
|
|
294
|
-
ALLOWED_TAGS: ['a', 'strong', 'em', 'b', 'i', 'code', 'span', 'br'],
|
|
295
|
-
ALLOWED_ATTR: ['href', 'target', 'rel', 'class', 'data-citation-page', 'data-citation-source', 'title'],
|
|
295
|
+
ALLOWED_TAGS: ['a', 'strong', 'em', 'b', 'i', 'code', 'span', 'br', 'button', 'svg', 'path'],
|
|
296
|
+
ALLOWED_ATTR: ['href', 'target', 'rel', 'class', 'data-citation-page', 'data-citation-source', 'data-citation-doc', 'data-citation-verified', 'title', 'fill', 'stroke', 'viewBox', 'stroke-linecap', 'stroke-linejoin', 'stroke-width', 'd'],
|
|
296
297
|
ADD_ATTR: ['target', 'rel'],
|
|
297
298
|
})
|
|
298
299
|
}
|
|
@@ -105,6 +105,30 @@ describe('renderCellValue', () => {
|
|
|
105
105
|
expect(result).toContain('<code>npm install</code>')
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
+
// Citation buttons with SVG (P1.2)
|
|
109
|
+
it('preserves citation <button> with data-citation-page', () => {
|
|
110
|
+
const result = renderCellValue('<button data-citation-page="5" class="citation-btn"><svg viewBox="0 0 24 24"><path d="M12 2L2 7v10l10 5 10-5V7z"/></svg></button>')
|
|
111
|
+
expect(result).toContain('<button')
|
|
112
|
+
expect(result).toContain('data-citation-page="5"')
|
|
113
|
+
expect(result).toContain('<svg')
|
|
114
|
+
expect(result).toContain('<path')
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('preserves citation button with data-citation-doc and data-citation-verified', () => {
|
|
118
|
+
const result = renderCellValue('<button data-citation-page="3" data-citation-doc="report.pdf" data-citation-verified="true">p.3</button>')
|
|
119
|
+
expect(result).toContain('data-citation-page="3"')
|
|
120
|
+
expect(result).toContain('data-citation-doc="report.pdf"')
|
|
121
|
+
expect(result).toContain('data-citation-verified="true"')
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('preserves mixed text with citation button', () => {
|
|
125
|
+
const result = renderCellValue('See source <button data-citation-page="7">[7]</button> for details')
|
|
126
|
+
expect(result).toContain('See source')
|
|
127
|
+
expect(result).toContain('<button')
|
|
128
|
+
expect(result).toContain('data-citation-page="7"')
|
|
129
|
+
expect(result).toContain('for details')
|
|
130
|
+
})
|
|
131
|
+
|
|
108
132
|
// Plain text XSS prevention
|
|
109
133
|
it('sanitizes plain text that looks like HTML injection', () => {
|
|
110
134
|
const result = renderCellValue('<img src=x onerror=alert(1)>')
|