@webmcp-auto-ui/ui 2.5.26 → 2.5.28

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.
Files changed (88) hide show
  1. package/README.md +2 -2
  2. package/package.json +15 -3
  3. package/src/agent/AgentConsole.svelte +1 -21
  4. package/src/agent/DataServersPanel.svelte +164 -0
  5. package/src/agent/LLMSelector.svelte +26 -8
  6. package/src/agent/ModelCacheManager.svelte +359 -0
  7. package/src/agent/{GemmaLoader.svelte → ModelLoader.svelte} +1 -1
  8. package/src/agent/SettingsPanel.svelte +16 -2
  9. package/src/index.ts +45 -31
  10. package/src/widgets/WidgetRenderer.svelte +118 -115
  11. package/src/widgets/export-widget.ts +28 -1
  12. package/src/widgets/helpers/safe-image.ts +78 -0
  13. package/src/widgets/notebook/.gitkeep +0 -0
  14. package/src/widgets/notebook/chart-renderer.ts +63 -0
  15. package/src/widgets/notebook/compact.ts +823 -0
  16. package/src/widgets/notebook/document.ts +1065 -0
  17. package/src/widgets/notebook/editorial.ts +936 -0
  18. package/src/widgets/notebook/executors/.gitkeep +1 -0
  19. package/src/widgets/notebook/executors/index.ts +4 -0
  20. package/src/widgets/notebook/executors/js-worker.ts +269 -0
  21. package/src/widgets/notebook/executors/sql.ts +206 -0
  22. package/src/widgets/notebook/import-modals.ts +553 -0
  23. package/src/widgets/notebook/left-pane.ts +249 -0
  24. package/src/widgets/notebook/prose.ts +280 -0
  25. package/src/widgets/notebook/recipe-browser.ts +350 -0
  26. package/src/widgets/notebook/recipes/compact.md +124 -0
  27. package/src/widgets/notebook/recipes/document.md +139 -0
  28. package/src/widgets/notebook/recipes/editorial.md +120 -0
  29. package/src/widgets/notebook/recipes/workspace.md +119 -0
  30. package/src/widgets/notebook/resource-extractor.ts +162 -0
  31. package/src/widgets/notebook/share-handlers.ts +222 -0
  32. package/src/widgets/notebook/shared.ts +1592 -0
  33. package/src/widgets/notebook/workspace.ts +852 -0
  34. package/src/widgets/rich/cards.ts +181 -0
  35. package/src/widgets/rich/carousel.ts +319 -0
  36. package/src/widgets/rich/chart-rich.ts +386 -0
  37. package/src/widgets/rich/d3.ts +503 -0
  38. package/src/widgets/rich/data-table.ts +342 -0
  39. package/src/widgets/rich/gallery.ts +350 -0
  40. package/src/widgets/rich/grid-data.ts +173 -0
  41. package/src/widgets/rich/hemicycle.ts +313 -0
  42. package/src/widgets/rich/js-sandbox.ts +106 -0
  43. package/src/widgets/rich/json-viewer.ts +202 -0
  44. package/src/widgets/rich/log.ts +143 -0
  45. package/src/widgets/rich/map.ts +218 -0
  46. package/src/widgets/rich/profile.ts +256 -0
  47. package/src/widgets/rich/sankey.ts +262 -0
  48. package/src/widgets/rich/stat-card.ts +125 -0
  49. package/src/widgets/rich/timeline.ts +179 -0
  50. package/src/widgets/rich/trombinoscope.ts +246 -0
  51. package/src/widgets/simple/actions.ts +89 -0
  52. package/src/widgets/simple/alert.ts +100 -0
  53. package/src/widgets/simple/chart.ts +189 -0
  54. package/src/widgets/simple/code.ts +79 -0
  55. package/src/widgets/simple/kv.ts +68 -0
  56. package/src/widgets/simple/list.ts +89 -0
  57. package/src/widgets/simple/stat.ts +58 -0
  58. package/src/widgets/simple/tags.ts +125 -0
  59. package/src/widgets/simple/text.ts +198 -0
  60. package/src/wm/FloatingLayout.svelte +2 -0
  61. package/src/wm/LinkIndicators.svelte +8 -15
  62. package/src/widgets/SafeImage.svelte +0 -76
  63. package/src/widgets/rich/Cards.svelte +0 -39
  64. package/src/widgets/rich/Carousel.svelte +0 -88
  65. package/src/widgets/rich/Chart.svelte +0 -142
  66. package/src/widgets/rich/D3Widget.svelte +0 -373
  67. package/src/widgets/rich/DataTable.svelte +0 -62
  68. package/src/widgets/rich/Gallery.svelte +0 -94
  69. package/src/widgets/rich/GridData.svelte +0 -44
  70. package/src/widgets/rich/Hemicycle.svelte +0 -78
  71. package/src/widgets/rich/JsSandbox.svelte +0 -51
  72. package/src/widgets/rich/JsonViewer.svelte +0 -42
  73. package/src/widgets/rich/LogViewer.svelte +0 -24
  74. package/src/widgets/rich/MapView.svelte +0 -140
  75. package/src/widgets/rich/ProfileCard.svelte +0 -59
  76. package/src/widgets/rich/Sankey.svelte +0 -38
  77. package/src/widgets/rich/StatCard.svelte +0 -35
  78. package/src/widgets/rich/Timeline.svelte +0 -43
  79. package/src/widgets/rich/Trombinoscope.svelte +0 -48
  80. package/src/widgets/simple/ActionsBlock.svelte +0 -15
  81. package/src/widgets/simple/AlertBlock.svelte +0 -11
  82. package/src/widgets/simple/ChartBlock.svelte +0 -21
  83. package/src/widgets/simple/CodeBlock.svelte +0 -11
  84. package/src/widgets/simple/KVBlock.svelte +0 -16
  85. package/src/widgets/simple/ListBlock.svelte +0 -17
  86. package/src/widgets/simple/StatBlock.svelte +0 -14
  87. package/src/widgets/simple/TagsBlock.svelte +0 -15
  88. package/src/widgets/simple/TextBlock.svelte +0 -122
@@ -0,0 +1,63 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Chart renderer — Vega-Lite via lazy dynamic import of vega-embed.
3
+ //
4
+ // Design notes:
5
+ // - vega-embed is imported dynamically so it does not bloat the initial
6
+ // bundle. The first chart render pays a one-time cost; subsequent charts
7
+ // share the cached module.
8
+ // - On failure (missing dep, invalid spec, CSP denies eval, etc.) we fall
9
+ // back to a readable <pre>JSON</pre> preview of the spec so the user
10
+ // still sees *something* rather than an empty panel.
11
+ // - vega-embed is declared as an optional peer dependency in package.json;
12
+ // apps that want interactive charts install it, others degrade gracefully.
13
+ // ---------------------------------------------------------------------------
14
+
15
+ export interface ChartRenderer {
16
+ mount(container: HTMLElement, spec: unknown): void | Promise<void>;
17
+ destroy(): void;
18
+ }
19
+
20
+ let cachedEmbed: Promise<any> | null = null;
21
+
22
+ function loadEmbed(): Promise<any> {
23
+ if (!cachedEmbed) {
24
+ // @ts-ignore — vega-embed is an optional peer dep; resolved at runtime
25
+ cachedEmbed = import('vega-embed').then((m: any) => m?.default ?? m);
26
+ }
27
+ return cachedEmbed;
28
+ }
29
+
30
+ function escapeHtml(s: string): string {
31
+ return String(s ?? '').replace(/[&<>"']/g, (c) =>
32
+ ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]!));
33
+ }
34
+
35
+ function renderFallback(container: HTMLElement, spec: unknown, reason?: string): void {
36
+ let preview: string;
37
+ try { preview = JSON.stringify(spec, null, 2); } catch { preview = String(spec); }
38
+ const note = reason ? `<div class="nb-chart-fallback-note">${escapeHtml(reason)}</div>` : '';
39
+ container.innerHTML = `${note}<pre class="nb-chart-fallback">${escapeHtml(preview)}</pre>`;
40
+ }
41
+
42
+ /**
43
+ * Render a Vega / Vega-Lite spec into the given container. Resolves once the
44
+ * chart is mounted (or falls back to a JSON preview on error). Never throws.
45
+ */
46
+ export async function renderChart(container: HTMLElement, spec: unknown): Promise<void> {
47
+ if (!container) return;
48
+ if (!spec || typeof spec !== 'object') {
49
+ renderFallback(container, spec, 'Invalid chart spec');
50
+ return;
51
+ }
52
+ try {
53
+ const embed = await loadEmbed();
54
+ if (typeof embed !== 'function') {
55
+ renderFallback(container, spec, 'vega-embed unavailable');
56
+ return;
57
+ }
58
+ container.innerHTML = '';
59
+ await embed(container, spec as any, { actions: false, renderer: 'canvas' });
60
+ } catch (err: any) {
61
+ renderFallback(container, spec, `chart render failed: ${String(err?.message ?? err)}`);
62
+ }
63
+ }