@miragon/mcp-toolkit-ui 2.6.0 → 2.8.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/README.md +14 -5
- package/dist/app/adapt-data-widget.d.ts +1 -22
- package/dist/app/adapt-data-widget.d.ts.map +1 -1
- package/dist/app/adapt-data-widget.js +1 -35
- package/dist/app/adapt-data-widget.js.map +1 -1
- package/dist/app/builder/BuilderBanners.d.ts +7 -2
- package/dist/app/builder/BuilderBanners.d.ts.map +1 -1
- package/dist/app/builder/BuilderBanners.js +8 -3
- package/dist/app/builder/BuilderBanners.js.map +1 -1
- package/dist/app/builder/CanvasRow.d.ts +4 -2
- package/dist/app/builder/CanvasRow.d.ts.map +1 -1
- package/dist/app/builder/CanvasRow.js +29 -17
- package/dist/app/builder/CanvasRow.js.map +1 -1
- package/dist/app/builder/CatalogueSheet.d.ts.map +1 -1
- package/dist/app/builder/CatalogueSheet.js +14 -6
- package/dist/app/builder/CatalogueSheet.js.map +1 -1
- package/dist/app/builder/CellPropsSheet.d.ts +7 -3
- package/dist/app/builder/CellPropsSheet.d.ts.map +1 -1
- package/dist/app/builder/CellPropsSheet.js +10 -3
- package/dist/app/builder/CellPropsSheet.js.map +1 -1
- package/dist/app/builder/DiscardDialog.d.ts +18 -0
- package/dist/app/builder/DiscardDialog.d.ts.map +1 -0
- package/dist/app/builder/DiscardDialog.js +18 -0
- package/dist/app/builder/DiscardDialog.js.map +1 -0
- package/dist/app/builder/EmptyHint.d.ts +4 -0
- package/dist/app/builder/EmptyHint.d.ts.map +1 -1
- package/dist/app/builder/EmptyHint.js +6 -1
- package/dist/app/builder/EmptyHint.js.map +1 -1
- package/dist/app/builder/LayoutSurface.d.ts +33 -9
- package/dist/app/builder/LayoutSurface.d.ts.map +1 -1
- package/dist/app/builder/LayoutSurface.js +74 -23
- package/dist/app/builder/LayoutSurface.js.map +1 -1
- package/dist/app/builder/PipelineStrip.d.ts +5 -2
- package/dist/app/builder/PipelineStrip.d.ts.map +1 -1
- package/dist/app/builder/PipelineStrip.js +33 -15
- package/dist/app/builder/PipelineStrip.js.map +1 -1
- package/dist/app/builder/SaveDialog.d.ts +9 -1
- package/dist/app/builder/SaveDialog.d.ts.map +1 -1
- package/dist/app/builder/SaveDialog.js +9 -3
- package/dist/app/builder/SaveDialog.js.map +1 -1
- package/dist/app/builder/Toolbar.d.ts +14 -4
- package/dist/app/builder/Toolbar.d.ts.map +1 -1
- package/dist/app/builder/Toolbar.js +24 -7
- package/dist/app/builder/Toolbar.js.map +1 -1
- package/dist/app/builder/Workspace.d.ts +23 -3
- package/dist/app/builder/Workspace.d.ts.map +1 -1
- package/dist/app/builder/Workspace.js +58 -8
- package/dist/app/builder/Workspace.js.map +1 -1
- package/dist/app/builder/builder-model.d.ts +146 -3
- package/dist/app/builder/builder-model.d.ts.map +1 -1
- package/dist/app/builder/builder-model.js +196 -5
- package/dist/app/builder/builder-model.js.map +1 -1
- package/dist/app/builder/labels.d.ts +13 -62
- package/dist/app/builder/labels.d.ts.map +1 -1
- package/dist/app/builder/labels.js +9 -58
- package/dist/app/builder/labels.js.map +1 -1
- package/dist/app/builder/reveal.d.ts +10 -0
- package/dist/app/builder/reveal.d.ts.map +1 -0
- package/dist/app/builder/reveal.js +10 -0
- package/dist/app/builder/reveal.js.map +1 -0
- package/dist/app/builder/status-chip.d.ts.map +1 -1
- package/dist/app/builder/status-chip.js +3 -2
- package/dist/app/builder/status-chip.js.map +1 -1
- package/dist/app/builder/use-builder-catalogue.d.ts +5 -1
- package/dist/app/builder/use-builder-catalogue.d.ts.map +1 -1
- package/dist/app/builder/use-builder-catalogue.js +50 -17
- package/dist/app/builder/use-builder-catalogue.js.map +1 -1
- package/dist/app/builder/use-builder-session.d.ts +30 -0
- package/dist/app/builder/use-builder-session.d.ts.map +1 -0
- package/dist/app/builder/use-builder-session.js +58 -0
- package/dist/app/builder/use-builder-session.js.map +1 -0
- package/dist/app/builder/use-display-resolver.d.ts +17 -0
- package/dist/app/builder/use-display-resolver.d.ts.map +1 -0
- package/dist/app/builder/use-display-resolver.js +16 -0
- package/dist/app/builder/use-display-resolver.js.map +1 -0
- package/dist/app/builder/use-save-dashboard.d.ts +3 -1
- package/dist/app/builder/use-save-dashboard.d.ts.map +1 -1
- package/dist/app/builder/use-save-dashboard.js +3 -1
- package/dist/app/builder/use-save-dashboard.js.map +1 -1
- package/dist/app/index.d.ts +8 -3
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +8 -2
- package/dist/app/index.js.map +1 -1
- package/dist/app/layout-builder.d.ts +18 -25
- package/dist/app/layout-builder.d.ts.map +1 -1
- package/dist/app/layout-builder.js +84 -78
- package/dist/app/layout-builder.js.map +1 -1
- package/dist/app/mcp-app-view-chrome.d.ts +103 -20
- package/dist/app/mcp-app-view-chrome.d.ts.map +1 -1
- package/dist/app/mcp-app-view-chrome.js +125 -40
- package/dist/app/mcp-app-view-chrome.js.map +1 -1
- package/dist/app/mcp-app-view-states.d.ts +23 -0
- package/dist/app/mcp-app-view-states.d.ts.map +1 -0
- package/dist/app/mcp-app-view-states.js +55 -0
- package/dist/app/mcp-app-view-states.js.map +1 -0
- package/dist/app/mcp-app-view.d.ts +72 -5
- package/dist/app/mcp-app-view.d.ts.map +1 -1
- package/dist/app/mcp-app-view.js +241 -141
- package/dist/app/mcp-app-view.js.map +1 -1
- package/dist/app/mcp-toolkit-app.d.ts +8 -2
- package/dist/app/mcp-toolkit-app.d.ts.map +1 -1
- package/dist/app/mcp-toolkit-app.js +33 -4
- package/dist/app/mcp-toolkit-app.js.map +1 -1
- package/dist/app/mcp-use-host-bridge.d.ts +15 -6
- package/dist/app/mcp-use-host-bridge.d.ts.map +1 -1
- package/dist/app/mcp-use-host-bridge.js +51 -22
- package/dist/app/mcp-use-host-bridge.js.map +1 -1
- package/dist/app/model-context.d.ts +71 -0
- package/dist/app/model-context.d.ts.map +1 -0
- package/dist/app/model-context.js +101 -0
- package/dist/app/model-context.js.map +1 -0
- package/dist/app/use-build-mode-focus.d.ts +33 -0
- package/dist/app/use-build-mode-focus.d.ts.map +1 -0
- package/dist/app/use-build-mode-focus.js +59 -0
- package/dist/app/use-build-mode-focus.js.map +1 -0
- package/dist/app/use-view-actions.d.ts +31 -0
- package/dist/app/use-view-actions.d.ts.map +1 -0
- package/dist/app/use-view-actions.js +81 -0
- package/dist/app/use-view-actions.js.map +1 -0
- package/dist/app/use-view-lifecycle.d.ts +42 -0
- package/dist/app/use-view-lifecycle.d.ts.map +1 -0
- package/dist/app/use-view-lifecycle.js +81 -0
- package/dist/app/use-view-lifecycle.js.map +1 -0
- package/dist/app/view-lifecycle.d.ts +185 -0
- package/dist/app/view-lifecycle.d.ts.map +1 -0
- package/dist/app/view-lifecycle.js +207 -0
- package/dist/app/view-lifecycle.js.map +1 -0
- package/dist/app/widget-fixture.d.ts +10 -3
- package/dist/app/widget-fixture.d.ts.map +1 -1
- package/dist/app/widget-fixture.js +21 -8
- package/dist/app/widget-fixture.js.map +1 -1
- package/dist/app/widget-props-sheet.d.ts +6 -10
- package/dist/app/widget-props-sheet.d.ts.map +1 -1
- package/dist/app/widget-props-sheet.js +25 -20
- package/dist/app/widget-props-sheet.js.map +1 -1
- package/dist/app/widget-renderer.d.ts +41 -1
- package/dist/app/widget-renderer.d.ts.map +1 -1
- package/dist/app/widget-renderer.js +82 -31
- package/dist/app/widget-renderer.js.map +1 -1
- package/dist/components/DrillButton.d.ts +9 -6
- package/dist/components/DrillButton.d.ts.map +1 -1
- package/dist/components/DrillButton.js +9 -6
- package/dist/components/DrillButton.js.map +1 -1
- package/dist/components/EmptyState.d.ts +33 -0
- package/dist/components/EmptyState.d.ts.map +1 -0
- package/dist/components/EmptyState.js +19 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/ErrorState.d.ts +53 -0
- package/dist/components/ErrorState.d.ts.map +1 -0
- package/dist/components/ErrorState.js +77 -0
- package/dist/components/ErrorState.js.map +1 -0
- package/dist/components/FilterBar.d.ts +16 -5
- package/dist/components/FilterBar.d.ts.map +1 -1
- package/dist/components/FilterBar.js +13 -5
- package/dist/components/FilterBar.js.map +1 -1
- package/dist/components/GroupCard.d.ts.map +1 -1
- package/dist/components/GroupCard.js +2 -1
- package/dist/components/GroupCard.js.map +1 -1
- package/dist/components/KpiGrid.d.ts +70 -18
- package/dist/components/KpiGrid.d.ts.map +1 -1
- package/dist/components/KpiGrid.js +112 -23
- package/dist/components/KpiGrid.js.map +1 -1
- package/dist/components/ListFooter.d.ts +32 -4
- package/dist/components/ListFooter.d.ts.map +1 -1
- package/dist/components/ListFooter.js +35 -6
- package/dist/components/ListFooter.js.map +1 -1
- package/dist/components/PagedListFooter.d.ts +57 -0
- package/dist/components/PagedListFooter.d.ts.map +1 -0
- package/dist/components/PagedListFooter.js +27 -0
- package/dist/components/PagedListFooter.js.map +1 -0
- package/dist/components/Pills.d.ts +36 -12
- package/dist/components/Pills.d.ts.map +1 -1
- package/dist/components/Pills.js +29 -8
- package/dist/components/Pills.js.map +1 -1
- package/dist/components/SectionHeading.d.ts +3 -1
- package/dist/components/SectionHeading.d.ts.map +1 -1
- package/dist/components/SectionHeading.js +6 -2
- package/dist/components/SectionHeading.js.map +1 -1
- package/dist/components/Toast.d.ts +43 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/Toast.js +106 -0
- package/dist/components/Toast.js.map +1 -0
- package/dist/components/WidgetHeader.d.ts +34 -10
- package/dist/components/WidgetHeader.d.ts.map +1 -1
- package/dist/components/WidgetHeader.js +11 -6
- package/dist/components/WidgetHeader.js.map +1 -1
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/tool-result-recovery-model.d.ts +155 -0
- package/dist/hooks/tool-result-recovery-model.d.ts.map +1 -0
- package/dist/hooks/tool-result-recovery-model.js +273 -0
- package/dist/hooks/tool-result-recovery-model.js.map +1 -0
- package/dist/hooks/use-tool-query.d.ts +56 -14
- package/dist/hooks/use-tool-query.d.ts.map +1 -1
- package/dist/hooks/use-tool-query.js +102 -25
- package/dist/hooks/use-tool-query.js.map +1 -1
- package/dist/hooks/use-tool-result-recovery.d.ts +61 -44
- package/dist/hooks/use-tool-result-recovery.d.ts.map +1 -1
- package/dist/hooks/use-tool-result-recovery.js +62 -110
- package/dist/hooks/use-tool-result-recovery.js.map +1 -1
- package/dist/hooks/use-view-data.d.ts +55 -7
- package/dist/hooks/use-view-data.d.ts.map +1 -1
- package/dist/hooks/use-view-data.js +81 -11
- package/dist/hooks/use-view-data.js.map +1 -1
- package/dist/hooks/use-view-tool-query.d.ts +12 -7
- package/dist/hooks/use-view-tool-query.d.ts.map +1 -1
- package/dist/hooks/use-view-tool-query.js +15 -14
- package/dist/hooks/use-view-tool-query.js.map +1 -1
- package/dist/index.d.ts +27 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -7
- package/dist/index.js.map +1 -1
- package/dist/lib/focus-return.d.ts +61 -0
- package/dist/lib/focus-return.d.ts.map +1 -0
- package/dist/lib/focus-return.js +46 -0
- package/dist/lib/focus-return.js.map +1 -0
- package/dist/lib/focus-ring.d.ts +18 -0
- package/dist/lib/focus-ring.d.ts.map +1 -0
- package/dist/lib/focus-ring.js +18 -0
- package/dist/lib/focus-ring.js.map +1 -0
- package/dist/lib/icon-stroke.d.ts +12 -0
- package/dist/lib/icon-stroke.d.ts.map +1 -0
- package/dist/lib/icon-stroke.js +12 -0
- package/dist/lib/icon-stroke.js.map +1 -0
- package/dist/lib/parse-tool-result.d.ts +23 -1
- package/dist/lib/parse-tool-result.d.ts.map +1 -1
- package/dist/lib/parse-tool-result.js +38 -2
- package/dist/lib/parse-tool-result.js.map +1 -1
- package/dist/lib/toast-model.d.ts +86 -0
- package/dist/lib/toast-model.d.ts.map +1 -0
- package/dist/lib/toast-model.js +102 -0
- package/dist/lib/toast-model.js.map +1 -0
- package/dist/lib/tone-utils.d.ts +95 -9
- package/dist/lib/tone-utils.d.ts.map +1 -1
- package/dist/lib/tone-utils.js +100 -9
- package/dist/lib/tone-utils.js.map +1 -1
- package/dist/lib/tool-query.d.ts +107 -0
- package/dist/lib/tool-query.d.ts.map +1 -0
- package/dist/lib/tool-query.js +182 -0
- package/dist/lib/tool-query.js.map +1 -0
- package/dist/lib/tool-result-observer.d.ts +108 -0
- package/dist/lib/tool-result-observer.d.ts.map +1 -0
- package/dist/lib/tool-result-observer.js +158 -0
- package/dist/lib/tool-result-observer.js.map +1 -0
- package/dist/lib/typography.d.ts +37 -0
- package/dist/lib/typography.d.ts.map +1 -0
- package/dist/lib/typography.js +41 -0
- package/dist/lib/typography.js.map +1 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +11 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/locale/index.d.ts +3 -1
- package/dist/locale/index.d.ts.map +1 -1
- package/dist/locale/index.js +2 -1
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/locale-provider.d.ts +42 -1
- package/dist/locale/locale-provider.d.ts.map +1 -1
- package/dist/locale/locale-provider.js +44 -3
- package/dist/locale/locale-provider.js.map +1 -1
- package/dist/locale/message-types.d.ts +336 -0
- package/dist/locale/message-types.d.ts.map +1 -0
- package/dist/locale/message-types.js +7 -0
- package/dist/locale/message-types.js.map +1 -0
- package/dist/locale/messages-de.d.ts +9 -0
- package/dist/locale/messages-de.d.ts.map +1 -0
- package/dist/locale/messages-de.js +185 -0
- package/dist/locale/messages-de.js.map +1 -0
- package/dist/locale/messages-en.d.ts +8 -0
- package/dist/locale/messages-en.d.ts.map +1 -0
- package/dist/locale/messages-en.js +184 -0
- package/dist/locale/messages-en.js.map +1 -0
- package/dist/locale/toolkit-messages.d.ts +57 -0
- package/dist/locale/toolkit-messages.d.ts.map +1 -0
- package/dist/locale/toolkit-messages.js +103 -0
- package/dist/locale/toolkit-messages.js.map +1 -0
- package/dist/primitives/alert.d.ts +1 -1
- package/dist/primitives/alert.d.ts.map +1 -1
- package/dist/primitives/alert.js +6 -2
- package/dist/primitives/alert.js.map +1 -1
- package/dist/primitives/badge.d.ts +1 -1
- package/dist/primitives/badge.d.ts.map +1 -1
- package/dist/primitives/badge.js +19 -6
- package/dist/primitives/badge.js.map +1 -1
- package/dist/primitives/button.d.ts +1 -1
- package/dist/primitives/button.d.ts.map +1 -1
- package/dist/primitives/button.js +12 -8
- package/dist/primitives/button.js.map +1 -1
- package/dist/primitives/card.js +4 -4
- package/dist/primitives/card.js.map +1 -1
- package/dist/primitives/dialog.d.ts +7 -3
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +22 -8
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/input.d.ts.map +1 -1
- package/dist/primitives/input.js +4 -1
- package/dist/primitives/input.js.map +1 -1
- package/dist/primitives/scroll-area.js +1 -1
- package/dist/primitives/scroll-area.js.map +1 -1
- package/dist/primitives/select.d.ts.map +1 -1
- package/dist/primitives/select.js +6 -3
- package/dist/primitives/select.js.map +1 -1
- package/dist/primitives/sheet.d.ts +3 -1
- package/dist/primitives/sheet.d.ts.map +1 -1
- package/dist/primitives/sheet.js +17 -7
- package/dist/primitives/sheet.js.map +1 -1
- package/dist/primitives/skeleton.js +1 -1
- package/dist/primitives/skeleton.js.map +1 -1
- package/dist/primitives/switch.d.ts.map +1 -1
- package/dist/primitives/switch.js +2 -1
- package/dist/primitives/switch.js.map +1 -1
- package/dist/primitives/tabs.d.ts.map +1 -1
- package/dist/primitives/tabs.js +5 -3
- package/dist/primitives/tabs.js.map +1 -1
- package/dist/providers/query-provider.d.ts +32 -1
- package/dist/providers/query-provider.d.ts.map +1 -1
- package/dist/providers/query-provider.js +53 -4
- package/dist/providers/query-provider.js.map +1 -1
- package/dist/render-cases-primitives.js +1 -1
- package/dist/render-cases-primitives.js.map +1 -1
- package/dist/render-cases.d.ts.map +1 -1
- package/dist/render-cases.js +48 -6
- package/dist/render-cases.js.map +1 -1
- package/dist/render-effects.d.ts +42 -0
- package/dist/render-effects.d.ts.map +1 -0
- package/dist/render-effects.js +81 -0
- package/dist/render-effects.js.map +1 -0
- package/dist/render-scan.d.ts +25 -0
- package/dist/render-scan.d.ts.map +1 -0
- package/dist/render-scan.js +66 -0
- package/dist/render-scan.js.map +1 -0
- package/dist/theme/cd-tokens.d.ts +66 -0
- package/dist/theme/cd-tokens.d.ts.map +1 -0
- package/dist/theme/cd-tokens.js +64 -0
- package/dist/theme/cd-tokens.js.map +1 -0
- package/dist/theme/create-theme.d.ts +214 -39
- package/dist/theme/create-theme.d.ts.map +1 -1
- package/dist/theme/create-theme.js +204 -13
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/fonts.d.ts +38 -0
- package/dist/theme/fonts.d.ts.map +1 -0
- package/dist/theme/fonts.js +56 -0
- package/dist/theme/fonts.js.map +1 -0
- package/dist/theme/host-fonts.d.ts +39 -0
- package/dist/theme/host-fonts.d.ts.map +1 -0
- package/dist/theme/host-fonts.js +44 -0
- package/dist/theme/host-fonts.js.map +1 -0
- package/dist/theme/index.d.ts +8 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +5 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/portal-container.d.ts +16 -0
- package/dist/theme/portal-container.d.ts.map +1 -0
- package/dist/theme/portal-container.js +19 -0
- package/dist/theme/portal-container.js.map +1 -0
- package/dist/theme/presets.d.ts +24 -9
- package/dist/theme/presets.d.ts.map +1 -1
- package/dist/theme/presets.js +44 -11
- package/dist/theme/presets.js.map +1 -1
- package/dist/theme/theme-provider.d.ts +27 -9
- package/dist/theme/theme-provider.d.ts.map +1 -1
- package/dist/theme/theme-provider.js +42 -20
- package/dist/theme/theme-provider.js.map +1 -1
- package/package.json +11 -5
- package/src/app/adapt-data-widget.tsx +2 -42
- package/src/app/builder/BuilderBanners.tsx +26 -13
- package/src/app/builder/CanvasRow.tsx +79 -32
- package/src/app/builder/CatalogueSheet.tsx +58 -35
- package/src/app/builder/CellPropsSheet.tsx +17 -2
- package/src/app/builder/DiscardDialog.tsx +59 -0
- package/src/app/builder/EmptyHint.tsx +16 -11
- package/src/app/builder/LayoutSurface.tsx +207 -67
- package/src/app/builder/PipelineStrip.tsx +265 -156
- package/src/app/builder/SaveDialog.tsx +25 -14
- package/src/app/builder/Toolbar.tsx +154 -57
- package/src/app/builder/Workspace.tsx +226 -56
- package/src/app/builder/builder-feedback.test.tsx +75 -0
- package/src/app/builder/builder-model.test.ts +5 -0
- package/src/app/builder/builder-model.ts +346 -6
- package/src/app/builder/builder-model.ux.test.ts +456 -0
- package/src/app/builder/builder-ux.test.tsx +844 -0
- package/src/app/builder/labels.ts +15 -121
- package/src/app/builder/reveal.ts +10 -0
- package/src/app/builder/status-chip.tsx +8 -4
- package/src/app/builder/use-builder-catalogue.ts +62 -19
- package/src/app/builder/use-builder-session.ts +68 -0
- package/src/app/builder/use-display-resolver.ts +24 -0
- package/src/app/builder/use-save-dashboard.ts +5 -0
- package/src/app/index.ts +20 -3
- package/src/app/layout-builder.tsx +193 -186
- package/src/app/mcp-app-view-chrome.test.tsx +487 -14
- package/src/app/mcp-app-view-chrome.tsx +328 -100
- package/src/app/mcp-app-view-states.tsx +140 -0
- package/src/app/mcp-app-view.effects.test.tsx +292 -0
- package/src/app/mcp-app-view.test.tsx +478 -0
- package/src/app/mcp-app-view.tsx +447 -190
- package/src/app/mcp-toolkit-app.test.tsx +40 -0
- package/src/app/mcp-toolkit-app.tsx +39 -8
- package/src/app/mcp-use-host-bridge.test.tsx +180 -0
- package/src/app/mcp-use-host-bridge.tsx +67 -24
- package/src/app/model-context.test.tsx +116 -0
- package/src/app/model-context.tsx +125 -0
- package/src/app/use-build-mode-focus.ts +62 -0
- package/src/app/use-view-actions.ts +89 -0
- package/src/app/use-view-lifecycle.ts +122 -0
- package/src/app/view-lifecycle.test.ts +443 -0
- package/src/app/view-lifecycle.ts +334 -0
- package/src/app/widget-fixture.effects.test.tsx +51 -0
- package/src/app/widget-fixture.render.test.tsx +81 -0
- package/src/app/widget-fixture.tsx +34 -11
- package/src/app/widget-props-sheet.tsx +67 -39
- package/src/app/widget-renderer.render.test.tsx +131 -0
- package/src/app/widget-renderer.tsx +136 -38
- package/src/components/DrillButton.tsx +24 -10
- package/src/components/EmptyState.tsx +83 -0
- package/src/components/ErrorState.tsx +204 -0
- package/src/components/FilterBar.test.tsx +82 -0
- package/src/components/FilterBar.tsx +56 -27
- package/src/components/GroupCard.tsx +3 -2
- package/src/components/KpiGrid.test.tsx +279 -0
- package/src/components/KpiGrid.tsx +329 -91
- package/src/components/ListFooter.test.tsx +116 -0
- package/src/components/ListFooter.tsx +110 -12
- package/src/components/PagedListFooter.test.tsx +140 -0
- package/src/components/PagedListFooter.tsx +107 -0
- package/src/components/Pills.test.tsx +77 -0
- package/src/components/Pills.tsx +78 -16
- package/src/components/SectionHeading.tsx +9 -3
- package/src/components/Toast.tsx +206 -0
- package/src/components/WidgetHeader.test.tsx +78 -0
- package/src/components/WidgetHeader.tsx +63 -16
- package/src/components/feedback-states.test.tsx +314 -0
- package/src/components/tone-figures.test.tsx +58 -0
- package/src/fonts.css +19 -0
- package/src/globals.css +9 -165
- package/src/hooks/index.ts +6 -3
- package/src/hooks/tool-result-recovery-model.test.ts +744 -0
- package/src/hooks/tool-result-recovery-model.ts +418 -0
- package/src/hooks/use-tool-query.effects.test.tsx +205 -0
- package/src/hooks/use-tool-query.ts +156 -33
- package/src/hooks/use-tool-result-recovery.effects.test.tsx +141 -0
- package/src/hooks/use-tool-result-recovery.test.ts +28 -5
- package/src/hooks/use-tool-result-recovery.ts +101 -131
- package/src/hooks/use-view-data.test.tsx +169 -0
- package/src/hooks/use-view-data.ts +131 -10
- package/src/hooks/use-view-tool-query.ts +25 -19
- package/src/i18n-coverage.test.tsx +425 -0
- package/src/index.ts +102 -13
- package/src/lib/focus-return.test.ts +288 -0
- package/src/lib/focus-return.ts +96 -0
- package/src/lib/focus-ring.ts +20 -0
- package/src/lib/icon-stroke.test.ts +59 -0
- package/src/lib/icon-stroke.ts +13 -0
- package/src/lib/parse-tool-result.test.ts +46 -1
- package/src/lib/parse-tool-result.ts +40 -2
- package/src/lib/toast-model.test.ts +233 -0
- package/src/lib/toast-model.ts +165 -0
- package/src/lib/tone-utils.test.ts +125 -16
- package/src/lib/tone-utils.ts +144 -15
- package/src/lib/tool-query.test.ts +569 -0
- package/src/lib/tool-query.ts +253 -0
- package/src/lib/tool-result-observer.test.ts +296 -0
- package/src/lib/tool-result-observer.ts +211 -0
- package/src/lib/typography.test.ts +45 -0
- package/src/lib/typography.ts +47 -0
- package/src/lib/utils.ts +12 -1
- package/src/locale/index.ts +14 -1
- package/src/locale/locale-provider.test.tsx +87 -0
- package/src/locale/locale-provider.tsx +90 -3
- package/src/locale/message-types.ts +337 -0
- package/src/locale/messages-de.ts +198 -0
- package/src/locale/messages-en.ts +196 -0
- package/src/locale/toolkit-messages.test.ts +349 -0
- package/src/locale/toolkit-messages.ts +143 -0
- package/src/no-hardcoded-copy.test.ts +432 -0
- package/src/primitives/alert.tsx +7 -2
- package/src/primitives/badge.tsx +19 -7
- package/src/primitives/button.tsx +13 -8
- package/src/primitives/card.tsx +4 -4
- package/src/primitives/dialog.tsx +42 -8
- package/src/primitives/input.tsx +5 -3
- package/src/primitives/scroll-area.tsx +1 -1
- package/src/primitives/select.tsx +7 -4
- package/src/primitives/sheet.tsx +33 -6
- package/src/primitives/skeleton.tsx +1 -1
- package/src/primitives/switch.tsx +4 -2
- package/src/primitives/tabs.tsx +9 -6
- package/src/providers/query-provider.test.tsx +154 -0
- package/src/providers/query-provider.tsx +66 -5
- package/src/render-cases-primitives.tsx +1 -1
- package/src/render-cases.tsx +82 -6
- package/src/render-effects.tsx +96 -0
- package/src/render-scan.ts +75 -0
- package/src/theme/cd-tokens.generated.css +48 -0
- package/src/theme/cd-tokens.test.ts +109 -0
- package/src/theme/cd-tokens.ts +67 -0
- package/src/theme/create-theme.test.ts +253 -5
- package/src/theme/create-theme.ts +341 -41
- package/src/theme/fonts.test.ts +85 -0
- package/src/theme/fonts.ts +72 -0
- package/src/theme/host-fonts.test.ts +135 -0
- package/src/theme/host-fonts.ts +52 -0
- package/src/theme/index.ts +15 -1
- package/src/theme/portal-container.ts +20 -0
- package/src/theme/presets.ts +44 -11
- package/src/theme/theme-css.test.ts +619 -0
- package/src/theme/theme-provider.test.tsx +82 -0
- package/src/theme/theme-provider.tsx +60 -24
- package/src/theme.css +344 -0
- package/ui-catalog.json +783 -49
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useCallback, useEffect, useReducer, useRef, useState } from "react";
|
|
2
|
+
import { decodeViewResult, errorMessage, resolveViewLifecycle, RETRY_IDLE, retryFocusTarget, retryReducer, waitKey, withSlowHint, } from "./view-lifecycle.js";
|
|
3
|
+
/**
|
|
4
|
+
* Drives the {@link resolveViewLifecycle} state machine: owns the retry and
|
|
5
|
+
* the slow-hint timer, and returns the current phase plus `retry()`.
|
|
6
|
+
*/
|
|
7
|
+
export function useViewLifecycle(options) {
|
|
8
|
+
const { toolName, toolInput, callTool, isValid, onResult, slowHintAfterMs } = options;
|
|
9
|
+
const [retryState, dispatch] = useReducer(retryReducer, RETRY_IDLE);
|
|
10
|
+
// The wait that went slow; a newer wait (another attempt) starts fresh.
|
|
11
|
+
const [slowWait, setSlowWait] = useState(null);
|
|
12
|
+
const unslowed = resolveViewLifecycle({
|
|
13
|
+
hasViewData: options.hasViewData,
|
|
14
|
+
callStatus: options.callStatus,
|
|
15
|
+
cancelled: options.cancelled,
|
|
16
|
+
callErrorReason: errorMessage(options.callError),
|
|
17
|
+
recoveryFailed: options.recoveryFailed,
|
|
18
|
+
recoveryBlocked: options.recoveryBlocked,
|
|
19
|
+
toolWrites: options.toolWrites,
|
|
20
|
+
retryState,
|
|
21
|
+
slow: false,
|
|
22
|
+
canRetry: toolName !== undefined,
|
|
23
|
+
});
|
|
24
|
+
const currentWait = waitKey(unslowed, retryState);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (currentWait === null)
|
|
27
|
+
return;
|
|
28
|
+
const timer = setTimeout(() => setSlowWait(currentWait), slowHintAfterMs);
|
|
29
|
+
return () => clearTimeout(timer);
|
|
30
|
+
}, [currentWait, slowHintAfterMs]);
|
|
31
|
+
const lifecycle = withSlowHint(unslowed, slowWait, currentWait);
|
|
32
|
+
const retry = useCallback(() => {
|
|
33
|
+
if (toolName === undefined)
|
|
34
|
+
return;
|
|
35
|
+
dispatch({ type: "start" });
|
|
36
|
+
void callTool(toolName, toolInput ?? {}).then((result) => {
|
|
37
|
+
const outcome = decodeViewResult(result, isValid);
|
|
38
|
+
if (outcome.ok) {
|
|
39
|
+
onResult(outcome.data);
|
|
40
|
+
dispatch({ type: "succeeded" });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
dispatch({ type: "failed", reason: outcome.reason });
|
|
44
|
+
}
|
|
45
|
+
}, (err) => dispatch({ type: "failed", reason: errorMessage(err) }));
|
|
46
|
+
}, [callTool, isValid, onResult, toolInput, toolName]);
|
|
47
|
+
return { lifecycle, retry };
|
|
48
|
+
}
|
|
49
|
+
/** The retry button of the view's error state (the focus target after a failed retry). */
|
|
50
|
+
const RETRY_BUTTON = '[data-slot="error-state"] button';
|
|
51
|
+
/**
|
|
52
|
+
* Keeps keyboard focus in the view across a user retry: the pressed button
|
|
53
|
+
* unmounts when the view starts waiting, so focus moves to the frame (a
|
|
54
|
+
* `tabIndex={-1}` container), then to the new retry button when the retry
|
|
55
|
+
* failed, or stays on the frame once the view rendered (see
|
|
56
|
+
* {@link retryFocusTarget}). Focus the user moved elsewhere meanwhile is left
|
|
57
|
+
* alone. Returns the frame ref and `retry` wrapped to start the hand-off.
|
|
58
|
+
*/
|
|
59
|
+
export function useRetryFocus(phase, retry) {
|
|
60
|
+
const frameRef = useRef(null);
|
|
61
|
+
const owed = useRef(false);
|
|
62
|
+
const retryWithFocus = useCallback(() => {
|
|
63
|
+
owed.current = true;
|
|
64
|
+
retry();
|
|
65
|
+
}, [retry]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const frame = frameRef.current;
|
|
68
|
+
if (!owed.current || !frame)
|
|
69
|
+
return;
|
|
70
|
+
const { target, settled } = retryFocusTarget(phase);
|
|
71
|
+
if (settled)
|
|
72
|
+
owed.current = false;
|
|
73
|
+
const active = frame.ownerDocument.activeElement;
|
|
74
|
+
if (active && active !== frame.ownerDocument.body && !frame.contains(active))
|
|
75
|
+
return;
|
|
76
|
+
const button = target === "retry" ? frame.querySelector(RETRY_BUTTON) : null;
|
|
77
|
+
(button ?? frame).focus();
|
|
78
|
+
}, [phase]);
|
|
79
|
+
return { frameRef, retry: retryWithFocus };
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=use-view-lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-view-lifecycle.js","sourceRoot":"","sources":["../../src/app/use-view-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAA;AAC5F,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,YAAY,GAGb,MAAM,qBAAqB,CAAA;AAsB5B;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAI,OAAmC;IAIrE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,OAAO,CAAA;IACrF,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;IACnE,wEAAwE;IACxE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAA;IAE7D,MAAM,QAAQ,GAAG,oBAAoB,CAAC;QACp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AC,aAAa,CAAA;QAChD,IAAI,MAAM,IAAI,MAAM,KAAK,KAAK,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAM;QACpF,MAAM,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAc,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CACxF;QAAA,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE,CAAA;IAC5B,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IACX,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/** `useToolContext().status` of the rendering call. */
|
|
2
|
+
export type RenderCallStatus = "pending" | "ready" | "error";
|
|
3
|
+
/** The user-triggered retry of the rendering call. */
|
|
4
|
+
export type RetryState = {
|
|
5
|
+
status: "idle";
|
|
6
|
+
attempt: number;
|
|
7
|
+
} | {
|
|
8
|
+
status: "running";
|
|
9
|
+
attempt: number;
|
|
10
|
+
} | {
|
|
11
|
+
status: "failed";
|
|
12
|
+
attempt: number;
|
|
13
|
+
reason: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare const RETRY_IDLE: RetryState;
|
|
16
|
+
export type RetryAction = {
|
|
17
|
+
type: "start";
|
|
18
|
+
} | {
|
|
19
|
+
type: "failed";
|
|
20
|
+
reason: string | undefined;
|
|
21
|
+
} | {
|
|
22
|
+
type: "succeeded";
|
|
23
|
+
};
|
|
24
|
+
/** start → running (next attempt); failed → failed with reason; succeeded → idle. */
|
|
25
|
+
export declare function retryReducer(state: RetryState, action: RetryAction): RetryState;
|
|
26
|
+
export interface ViewLifecycleInput {
|
|
27
|
+
/** A renderable payload is in hand (host-delivered, recovered or retried). */
|
|
28
|
+
hasViewData: boolean;
|
|
29
|
+
/** Status of the original rendering call. */
|
|
30
|
+
callStatus: RenderCallStatus;
|
|
31
|
+
/** The host cancelled the original rendering call. */
|
|
32
|
+
cancelled: boolean;
|
|
33
|
+
/** Message of the original call's error, when it failed. */
|
|
34
|
+
callErrorReason: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The automatic stripped-result recovery ran and failed, or was needed but
|
|
37
|
+
* could not run because the host names no tool.
|
|
38
|
+
*/
|
|
39
|
+
recoveryFailed: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The host did not pass the result to the view, and the recovery policy
|
|
42
|
+
* forbids re-running the tool: it ran, but the view never got its result.
|
|
43
|
+
* Default `false`.
|
|
44
|
+
*/
|
|
45
|
+
recoveryBlocked?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The host reports the originating tool as writing (`readOnlyHint: false`
|
|
48
|
+
* or `destructiveHint: true`). A blocked state then offers no retry: one
|
|
49
|
+
* click would run the write a second time. Default `false`.
|
|
50
|
+
*/
|
|
51
|
+
toolWrites?: boolean;
|
|
52
|
+
/** The user-triggered retry. */
|
|
53
|
+
retryState: RetryState;
|
|
54
|
+
/** Loading has outlasted the slow-hint delay. */
|
|
55
|
+
slow: boolean;
|
|
56
|
+
/** The originating tool is known, so a retry can re-run it. */
|
|
57
|
+
canRetry: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* What an `error` phase stands for: `"failed"` (the call, the recovery or the
|
|
61
|
+
* retry failed) or `"blocked"` (the tool ran, but the host did not pass its
|
|
62
|
+
* result to the view, and the recovery policy keeps the view from re-running it).
|
|
63
|
+
*/
|
|
64
|
+
export type ViewErrorKind = "failed" | "blocked";
|
|
65
|
+
export type ViewLifecycle = {
|
|
66
|
+
phase: "result";
|
|
67
|
+
} | {
|
|
68
|
+
phase: "waiting";
|
|
69
|
+
slow: boolean;
|
|
70
|
+
} | {
|
|
71
|
+
phase: "cancelled";
|
|
72
|
+
} | {
|
|
73
|
+
phase: "error";
|
|
74
|
+
reason: string | undefined;
|
|
75
|
+
canRetry: boolean;
|
|
76
|
+
/** Absent for a failure; `"blocked"` for a result the view must not re-load. */
|
|
77
|
+
kind?: ViewErrorKind;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Resolve the single phase the view is in. Precedence: a payload always wins;
|
|
81
|
+
* a running retry is waiting; a failed retry is an error with ITS reason; a
|
|
82
|
+
* cancellation is terminal; a failed call is an error; a blocked recovery is
|
|
83
|
+
* a `blocked` error, retryable only for a tool not reported as writing; a
|
|
84
|
+
* failed recovery or a latched non-view result nothing can recover is an
|
|
85
|
+
* error; everything else is still waiting.
|
|
86
|
+
*/
|
|
87
|
+
export declare function resolveViewLifecycle(input: ViewLifecycleInput): ViewLifecycle;
|
|
88
|
+
/**
|
|
89
|
+
* The phase with its slow flag: a wait turns slow only while the wait that
|
|
90
|
+
* outlasted the delay (`slowWait`, a {@link waitKey}) is still the current one,
|
|
91
|
+
* so a new attempt starts without the hint.
|
|
92
|
+
*/
|
|
93
|
+
export declare function withSlowHint(lifecycle: ViewLifecycle, slowWait: string | null, currentWait: string | null): ViewLifecycle;
|
|
94
|
+
/**
|
|
95
|
+
* Where keyboard focus goes after the user pressed retry (the button unmounts
|
|
96
|
+
* as the view starts waiting): the view frame while waiting, the new retry
|
|
97
|
+
* button when the retry failed, the frame again once the view or a
|
|
98
|
+
* cancellation replaced the state. `settled` ends the hand-off.
|
|
99
|
+
*/
|
|
100
|
+
export declare function retryFocusTarget(phase: ViewLifecycle["phase"]): {
|
|
101
|
+
target: "frame" | "retry";
|
|
102
|
+
settled: boolean;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Identity of the current wait, so the slow-hint timer restarts for every new
|
|
106
|
+
* wait (the first load, then each retry attempt) and never for a finished one.
|
|
107
|
+
* `null` when the view is not waiting.
|
|
108
|
+
*/
|
|
109
|
+
export declare function waitKey(lifecycle: ViewLifecycle, retryState: RetryState): string | null;
|
|
110
|
+
/** Default delay before the waiting placeholder adds its slow hint. */
|
|
111
|
+
export declare const DEFAULT_SLOW_HINT_MS = 8000;
|
|
112
|
+
/**
|
|
113
|
+
* A decoded view call (a retry or a refresh), typed so a failure never turns
|
|
114
|
+
* into UI text: `isError` tells a tool error (with its raw `reason`, for the
|
|
115
|
+
* Details disclosure or the console) from a payload that is no view.
|
|
116
|
+
*/
|
|
117
|
+
export type ViewResultOutcome<T> = {
|
|
118
|
+
ok: true;
|
|
119
|
+
data: T;
|
|
120
|
+
} | {
|
|
121
|
+
ok: false;
|
|
122
|
+
isError: boolean;
|
|
123
|
+
reason: string | undefined;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Decode a view call's result: the payload when it is a complete view,
|
|
127
|
+
* otherwise a failure — a tool error with its `isError` text, or a payload
|
|
128
|
+
* the shell cannot render (no reason).
|
|
129
|
+
*/
|
|
130
|
+
export declare function decodeViewResult<T>(result: unknown, isValid: (value: unknown) => value is T): ViewResultOutcome<T>;
|
|
131
|
+
/** What {@link describeViewForModel} reports on. */
|
|
132
|
+
export interface ViewModelContextInput {
|
|
133
|
+
lifecycle: ViewLifecycle;
|
|
134
|
+
/** The originating tool, when the host names it. */
|
|
135
|
+
toolName: string | undefined;
|
|
136
|
+
/** The shown payload's failed data steps (result phase). */
|
|
137
|
+
stepErrors?: readonly {
|
|
138
|
+
stepId: string;
|
|
139
|
+
reason: string;
|
|
140
|
+
}[];
|
|
141
|
+
/** The step-error alert offers a retry (the view can refresh). */
|
|
142
|
+
stepsRetryable?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* When the view re-loaded the shown payload itself (epoch ms, see
|
|
145
|
+
* {@link reloadedAtOf}); `null` for a payload the host delivered.
|
|
146
|
+
*/
|
|
147
|
+
reloadedAt?: number | null;
|
|
148
|
+
/**
|
|
149
|
+
* How it re-loaded: it re-ran the tool because the host did not pass the
|
|
150
|
+
* result along (`"recovery"`, the default: its own recovery or the user's
|
|
151
|
+
* retry), the user refreshed the view (`"refresh"`), or the user applied an
|
|
152
|
+
* edit from the view builder, which ran the data steps again (`"builder"`).
|
|
153
|
+
*/
|
|
154
|
+
reloadedBy?: "recovery" | "refresh" | "builder";
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Where the shown payload came from: the host's tool result, the view's own
|
|
158
|
+
* re-execution when the host stripped it, the user's retry, a refresh, or the
|
|
159
|
+
* user's Apply in the view builder (its figures are the builder's own run of
|
|
160
|
+
* the data steps).
|
|
161
|
+
*/
|
|
162
|
+
export type ViewSource = "host" | "recovered" | "retry" | "refresh" | "builder";
|
|
163
|
+
/**
|
|
164
|
+
* When a payload counts as re-loaded by the view itself (N23): `at` when its
|
|
165
|
+
* figures can differ from the result the chat answered from, else `null`. A
|
|
166
|
+
* recovery, a refresh and a builder Apply always; a retry only after a call
|
|
167
|
+
* whose result reached the chat (a stripped or unusable one), never after a
|
|
168
|
+
* failed or cancelled call, of which the model never had figures. The host's
|
|
169
|
+
* own payload never.
|
|
170
|
+
*/
|
|
171
|
+
export declare function reloadedAtOf(source: ViewSource, at: number, callFailed: boolean): number | null;
|
|
172
|
+
/**
|
|
173
|
+
* The view's own line of model context (toolkit#176 K20): what failed and
|
|
174
|
+
* that the user sees an error instead of the view; a blocked recovery (the
|
|
175
|
+
* tool ran, its result never reached the view, and the model must not re-run
|
|
176
|
+
* it just to show the view); failed data steps; a payload the view re-loaded
|
|
177
|
+
* itself (a recovery, a retry, a refresh, a builder Apply), whose figures can
|
|
178
|
+
* differ from the tool result the model answered from (N23). `null` while
|
|
179
|
+
* there is nothing to report (waiting, or a plain host-delivered view).
|
|
180
|
+
* English: it is read by the model, never shown.
|
|
181
|
+
*/
|
|
182
|
+
export declare function describeViewForModel(input: ViewModelContextInput): string | null;
|
|
183
|
+
/** A displayable message for anything thrown. */
|
|
184
|
+
export declare function errorMessage(err: unknown): string | undefined;
|
|
185
|
+
//# sourceMappingURL=view-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-lifecycle.d.ts","source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|
|
3
|
+
*
|
|
4
|
+
* Before the view payload exists the shell is in exactly one phase:
|
|
5
|
+
*
|
|
6
|
+
* waiting ──result──▶ result
|
|
7
|
+
* │ ╲
|
|
8
|
+
* │ ╲──tool error / failed recovery / unrecoverable result──▶ error ──retry──▶ waiting
|
|
9
|
+
* │ ╲
|
|
10
|
+
* │ ╲──stripped result the policy must not re-load──▶ error (blocked)
|
|
11
|
+
* │
|
|
12
|
+
* └──host cancelled──▶ cancelled (terminal: the user stopped it)
|
|
13
|
+
*
|
|
14
|
+
* `waiting` carries a `slow` flag once loading outlasts the slow-hint delay.
|
|
15
|
+
* An `isError` result (or a failed call) is an `error`, never an endless
|
|
16
|
+
* skeleton, and a retry re-runs the originating tool once on the user's click.
|
|
17
|
+
* A latched result that is no view on a host that names no originating tool
|
|
18
|
+
* is an `error` too: nothing could recover it, so waiting would never end.
|
|
19
|
+
* A `blocked` error is no failure: the tool ran, the host kept its result
|
|
20
|
+
* from the view, and the recovery policy forbids re-running it. It offers to
|
|
21
|
+
* load the view only for a tool the host does not report as writing, so one
|
|
22
|
+
* click never runs a write a second time (CI §9).
|
|
23
|
+
* Pure functions only: the hook in `use-view-lifecycle.ts` feeds them.
|
|
24
|
+
*/
|
|
25
|
+
import { parseToolResult } from "../lib/parse-tool-result.js";
|
|
26
|
+
export const RETRY_IDLE = { status: "idle", attempt: 0 };
|
|
27
|
+
/** start → running (next attempt); failed → failed with reason; succeeded → idle. */
|
|
28
|
+
export function retryReducer(state, action) {
|
|
29
|
+
switch (action.type) {
|
|
30
|
+
case "start":
|
|
31
|
+
return { status: "running", attempt: state.attempt + 1 };
|
|
32
|
+
case "failed":
|
|
33
|
+
return { status: "failed", attempt: state.attempt, reason: action.reason };
|
|
34
|
+
case "succeeded":
|
|
35
|
+
return { status: "idle", attempt: state.attempt };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the single phase the view is in. Precedence: a payload always wins;
|
|
40
|
+
* a running retry is waiting; a failed retry is an error with ITS reason; a
|
|
41
|
+
* cancellation is terminal; a failed call is an error; a blocked recovery is
|
|
42
|
+
* a `blocked` error, retryable only for a tool not reported as writing; a
|
|
43
|
+
* failed recovery or a latched non-view result nothing can recover is an
|
|
44
|
+
* error; everything else is still waiting.
|
|
45
|
+
*/
|
|
46
|
+
export function resolveViewLifecycle(input) {
|
|
47
|
+
if (input.hasViewData)
|
|
48
|
+
return { phase: "result" };
|
|
49
|
+
const { retryState } = input;
|
|
50
|
+
if (retryState.status === "running")
|
|
51
|
+
return { phase: "waiting", slow: input.slow };
|
|
52
|
+
if (retryState.status === "failed") {
|
|
53
|
+
return { phase: "error", reason: retryState.reason, canRetry: input.canRetry };
|
|
54
|
+
}
|
|
55
|
+
if (input.cancelled)
|
|
56
|
+
return { phase: "cancelled" };
|
|
57
|
+
if (input.callStatus === "error") {
|
|
58
|
+
return { phase: "error", reason: input.callErrorReason, canRetry: input.canRetry };
|
|
59
|
+
}
|
|
60
|
+
if (input.recoveryBlocked) {
|
|
61
|
+
const canRetry = input.canRetry && !input.toolWrites;
|
|
62
|
+
return { phase: "error", reason: undefined, canRetry, kind: "blocked" };
|
|
63
|
+
}
|
|
64
|
+
if (input.recoveryFailed)
|
|
65
|
+
return { phase: "error", reason: undefined, canRetry: input.canRetry };
|
|
66
|
+
// A latched result without a renderable view: the recovery re-runs the
|
|
67
|
+
// originating tool, so it can only help when the host names that tool.
|
|
68
|
+
if (input.callStatus === "ready" && !input.canRetry) {
|
|
69
|
+
return { phase: "error", reason: undefined, canRetry: false };
|
|
70
|
+
}
|
|
71
|
+
return { phase: "waiting", slow: input.slow };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The phase with its slow flag: a wait turns slow only while the wait that
|
|
75
|
+
* outlasted the delay (`slowWait`, a {@link waitKey}) is still the current one,
|
|
76
|
+
* so a new attempt starts without the hint.
|
|
77
|
+
*/
|
|
78
|
+
export function withSlowHint(lifecycle, slowWait, currentWait) {
|
|
79
|
+
return lifecycle.phase === "waiting" && slowWait !== null && slowWait === currentWait
|
|
80
|
+
? { phase: "waiting", slow: true }
|
|
81
|
+
: lifecycle;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Where keyboard focus goes after the user pressed retry (the button unmounts
|
|
85
|
+
* as the view starts waiting): the view frame while waiting, the new retry
|
|
86
|
+
* button when the retry failed, the frame again once the view or a
|
|
87
|
+
* cancellation replaced the state. `settled` ends the hand-off.
|
|
88
|
+
*/
|
|
89
|
+
export function retryFocusTarget(phase) {
|
|
90
|
+
if (phase === "waiting")
|
|
91
|
+
return { target: "frame", settled: false };
|
|
92
|
+
if (phase === "error")
|
|
93
|
+
return { target: "retry", settled: true };
|
|
94
|
+
return { target: "frame", settled: true };
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Identity of the current wait, so the slow-hint timer restarts for every new
|
|
98
|
+
* wait (the first load, then each retry attempt) and never for a finished one.
|
|
99
|
+
* `null` when the view is not waiting.
|
|
100
|
+
*/
|
|
101
|
+
export function waitKey(lifecycle, retryState) {
|
|
102
|
+
return lifecycle.phase === "waiting" ? `${retryState.status}:${retryState.attempt}` : null;
|
|
103
|
+
}
|
|
104
|
+
/** Default delay before the waiting placeholder adds its slow hint. */
|
|
105
|
+
export const DEFAULT_SLOW_HINT_MS = 8000;
|
|
106
|
+
/**
|
|
107
|
+
* Decode a view call's result: the payload when it is a complete view,
|
|
108
|
+
* otherwise a failure — a tool error with its `isError` text, or a payload
|
|
109
|
+
* the shell cannot render (no reason).
|
|
110
|
+
*/
|
|
111
|
+
export function decodeViewResult(result, isValid) {
|
|
112
|
+
let decoded;
|
|
113
|
+
try {
|
|
114
|
+
decoded = parseToolResult(result);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
return { ok: false, isError: true, reason: errorMessage(err) };
|
|
118
|
+
}
|
|
119
|
+
return isValid(decoded)
|
|
120
|
+
? { ok: true, data: decoded }
|
|
121
|
+
: { ok: false, isError: false, reason: undefined };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* When a payload counts as re-loaded by the view itself (N23): `at` when its
|
|
125
|
+
* figures can differ from the result the chat answered from, else `null`. A
|
|
126
|
+
* recovery, a refresh and a builder Apply always; a retry only after a call
|
|
127
|
+
* whose result reached the chat (a stripped or unusable one), never after a
|
|
128
|
+
* failed or cancelled call, of which the model never had figures. The host's
|
|
129
|
+
* own payload never.
|
|
130
|
+
*/
|
|
131
|
+
export function reloadedAtOf(source, at, callFailed) {
|
|
132
|
+
if (source === "host")
|
|
133
|
+
return null;
|
|
134
|
+
if (source === "retry" && callFailed)
|
|
135
|
+
return null;
|
|
136
|
+
return at;
|
|
137
|
+
}
|
|
138
|
+
/** How the view says, to the model, that it loaded the shown figures itself. */
|
|
139
|
+
const RELOADED_BY = {
|
|
140
|
+
recovery: (at) => `re-ran the tool at ${at} because the host did not pass the original result to the view`,
|
|
141
|
+
refresh: (at) => `was refreshed by the user at ${at}`,
|
|
142
|
+
builder: (at) => `was edited by the user in the view builder, which loaded its data again at ${at}`,
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* The view's own line of model context (toolkit#176 K20): what failed and
|
|
146
|
+
* that the user sees an error instead of the view; a blocked recovery (the
|
|
147
|
+
* tool ran, its result never reached the view, and the model must not re-run
|
|
148
|
+
* it just to show the view); failed data steps; a payload the view re-loaded
|
|
149
|
+
* itself (a recovery, a retry, a refresh, a builder Apply), whose figures can
|
|
150
|
+
* differ from the tool result the model answered from (N23). `null` while
|
|
151
|
+
* there is nothing to report (waiting, or a plain host-delivered view).
|
|
152
|
+
* English: it is read by the model, never shown.
|
|
153
|
+
*/
|
|
154
|
+
export function describeViewForModel(input) {
|
|
155
|
+
const subject = input.toolName ? `The view of ${input.toolName}` : "The view";
|
|
156
|
+
const { lifecycle } = input;
|
|
157
|
+
if (lifecycle.phase === "error") {
|
|
158
|
+
if (lifecycle.kind === "blocked") {
|
|
159
|
+
return describeBlockedForModel(subject, input.toolName, lifecycle.canRetry);
|
|
160
|
+
}
|
|
161
|
+
const reason = lifecycle.reason ? ` (reason: ${lifecycle.reason})` : "";
|
|
162
|
+
const offer = lifecycle.canRetry ? "an error message with a retry button" : "an error message";
|
|
163
|
+
return `${subject} could not be shown${reason}. The user sees ${offer} instead of the view.`;
|
|
164
|
+
}
|
|
165
|
+
if (lifecycle.phase === "cancelled") {
|
|
166
|
+
return `${subject} was cancelled before it rendered. The user sees a note that the call was cancelled.`;
|
|
167
|
+
}
|
|
168
|
+
if (lifecycle.phase === "waiting")
|
|
169
|
+
return null;
|
|
170
|
+
const lines = [];
|
|
171
|
+
if (input.reloadedAt != null) {
|
|
172
|
+
const at = new Date(input.reloadedAt).toISOString();
|
|
173
|
+
const how = RELOADED_BY[input.reloadedBy ?? "recovery"](at);
|
|
174
|
+
lines.push(`${subject} ${how}; its figures are live as of then and can differ from the original result.`);
|
|
175
|
+
}
|
|
176
|
+
const failed = input.stepErrors ?? [];
|
|
177
|
+
if (failed.length > 0) {
|
|
178
|
+
const steps = failed.map((e) => `${e.stepId}: ${e.reason}`).join("; ");
|
|
179
|
+
const lead = lines.length > 0 ? "Some" : `${subject} is shown, but some`;
|
|
180
|
+
const offer = input.stepsRetryable ? "an alert with a retry button" : "an alert";
|
|
181
|
+
lines.push(`${lead} of its data could not be loaded (${steps}). The user sees ${offer}.`);
|
|
182
|
+
}
|
|
183
|
+
return lines.length > 0 ? lines.join(" ") : null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The model's line for a blocked recovery: the tool ran (nothing failed), the
|
|
187
|
+
* host kept its result from the view, the view did not re-run it, and the
|
|
188
|
+
* model must not re-run it just to show the view, a write least of all.
|
|
189
|
+
*/
|
|
190
|
+
function describeBlockedForModel(subject, toolName, canRetry) {
|
|
191
|
+
const tool = toolName ?? "the tool";
|
|
192
|
+
const offer = canRetry
|
|
193
|
+
? "a note with a button that loads the view"
|
|
194
|
+
: "a note to ask in the chat for the current state";
|
|
195
|
+
return (`${subject} is not shown: ${tool} ran, but the host did not pass its result to the view, ` +
|
|
196
|
+
`and the view did not re-run it. The user sees ${offer} instead of the view. ` +
|
|
197
|
+
`Do not re-run ${tool} just to show the view.`);
|
|
198
|
+
}
|
|
199
|
+
/** A displayable message for anything thrown. */
|
|
200
|
+
export function errorMessage(err) {
|
|
201
|
+
if (err instanceof Error)
|
|
202
|
+
return err.message || undefined;
|
|
203
|
+
if (typeof err === "string")
|
|
204
|
+
return err || undefined;
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=view-lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-lifecycle.js","sourceRoot":"","sources":["../../src/app/view-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAW7D,MAAM,CAAC,MAAM,UAAU,GAAe,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAA;AAKpE,qFAAqF;AACrF,MAAM,UAAU,YAAY,CAAC,KAAiB,EAAE,MAAmB;IACjE,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,GAAG,CAAC,EAAE,CAAA;QAC1D,KAAK,QAAQ;YACX,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAA;QAC5E,KAAK,WAAW;YACd,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA;IACrD,CAAC;AACH,CAAC;AAuDD;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAyB;IAC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C,IAAI,CAAC,CAAA;QACtE,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,qBAAqB,CAAA;QACxE,MAAM,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,UAAU,CAAA;QAChF,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,qCAAqC,KAAK,oBAAoB,KAAK,GAAG,CAAC,CAAA;IAC3F,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAClD,CAAC;AAED;;;;GAIG;AACH,SAAS,uBAAuB,CAC9B,OAAe,EACf,QAA4B,EAC5B,QAAiB;IAEjB,MAAM,IAAI,GAAG,QAAQ,IAAI,UAAU,CAAA;IACnC,MAAM,KAAK,GAAG,QAAQ;QACpB,CAAC,CAAC,0CAA0C;QAC5C,CAAC,CAAC,iDAAiD,CAAA;IACrD,OAAO,CACL,GAAG,OAAO,kBAAkB,IAAI,0DAA0D;QAC1F,iDAAiD,KAAK,wBAAwB;QAC9E,iBAAiB,IAAI,yBAAyB,CAC/C,CAAA;AACH,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,GAAG,CAAC,OAAO,IAAI,SAAS,CAAA;IACzD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,IAAI,SAAS,CAAA;IACpD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -130,9 +130,12 @@ export interface WidgetFixtureHostProps {
|
|
|
130
130
|
*/
|
|
131
131
|
tools?: Record<string, FixtureToolEntry>;
|
|
132
132
|
/**
|
|
133
|
-
* Host context overrides, merged over {@link DEFAULT_GLOBALS}.
|
|
134
|
-
*
|
|
135
|
-
*
|
|
133
|
+
* Host context overrides, merged over {@link DEFAULT_GLOBALS}. Two keys
|
|
134
|
+
* influence the simulated host: `theme` (`"light"` | `"dark"`, reported by
|
|
135
|
+
* `useHostBridge().theme`) and `locale` (a BCP 47 tag: the toolkit's own
|
|
136
|
+
* strings and number format follow it, exactly as under `McpAppView`; a
|
|
137
|
+
* `LocaleProvider` around or inside the widget still wins). The other keys
|
|
138
|
+
* are accepted for compatibility with existing playground setups.
|
|
136
139
|
*/
|
|
137
140
|
globals?: Record<string, unknown>;
|
|
138
141
|
/**
|
|
@@ -167,6 +170,10 @@ export declare function buildFixtureWidgetProps(data: Record<string, unknown>, d
|
|
|
167
170
|
* would (adapted widgets report through this bridge outside a real view).
|
|
168
171
|
* - **The toolkit `AppQueryProvider`** — so widgets that fetch via `useToolQuery`
|
|
169
172
|
* (e.g. generated `use*` hooks) resolve against the same registry.
|
|
173
|
+
* - **What `McpAppView` gives a widget** — the toolkit's strings in the host
|
|
174
|
+
* locale (`globals.locale`, as `McpAppView` does with the host's), the
|
|
175
|
+
* toast stack (`useToast()` shows real toasts) and the icon stroke of the
|
|
176
|
+
* view (2.5), so the preview matches what a host renders.
|
|
170
177
|
*
|
|
171
178
|
* ### Boundaries
|
|
172
179
|
* The harness simulates the **host-portable pattern** (`useHostBridge`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-fixture.d.ts","sourceRoot":"","sources":["../../src/app/widget-fixture.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"widget-fixture.d.ts","sourceRoot":"","sources":["../../src/app/widget-fixture.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAE9F,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,2BA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Aab;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EAAE,MAAM,EACd,IAAS,EACT,QAAQ,EACR,KAAK,EACL,OAAO,EACP,cAAc,EACd,YAAY,GACb,EAAE,sBAAsB,GAAG,SAAS,CA+DpC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import { LucideProvider } from "lucide-react";
|
|
4
|
+
import { ToastProvider } from "../components/Toast.js";
|
|
5
|
+
import { ICON_STROKE } from "../lib/icon-stroke.js";
|
|
6
|
+
import { ToolkitLocaleFallback } from "../locale/locale-provider.js";
|
|
3
7
|
import { AppQueryProvider } from "../providers/query-provider.js";
|
|
4
8
|
import { HostBridgeProvider, createStandaloneHostBridge } from "./host-bridge.js";
|
|
5
9
|
/**
|
|
@@ -81,10 +85,10 @@ export function useFixtureHost() {
|
|
|
81
85
|
return useContext(FixtureHostContext);
|
|
82
86
|
}
|
|
83
87
|
/**
|
|
84
|
-
* Default host-context values the harness reports.
|
|
85
|
-
* the mcp-use 2.x move (the other host globals were consumed by
|
|
86
|
-
* `window.openai` shim); the object keeps its shape so existing
|
|
87
|
-
* setups that spread overrides keep compiling.
|
|
88
|
+
* Default host-context values the harness reports. `theme` and `locale` are
|
|
89
|
+
* read since the mcp-use 2.x move (the other host globals were consumed by
|
|
90
|
+
* the 1.x `window.openai` shim); the object keeps its shape so existing
|
|
91
|
+
* playground setups that spread overrides keep compiling.
|
|
88
92
|
*/
|
|
89
93
|
const DEFAULT_GLOBALS = {
|
|
90
94
|
theme: "light",
|
|
@@ -133,6 +137,10 @@ export function buildFixtureWidgetProps(data, dataType) {
|
|
|
133
137
|
* would (adapted widgets report through this bridge outside a real view).
|
|
134
138
|
* - **The toolkit `AppQueryProvider`** — so widgets that fetch via `useToolQuery`
|
|
135
139
|
* (e.g. generated `use*` hooks) resolve against the same registry.
|
|
140
|
+
* - **What `McpAppView` gives a widget** — the toolkit's strings in the host
|
|
141
|
+
* locale (`globals.locale`, as `McpAppView` does with the host's), the
|
|
142
|
+
* toast stack (`useToast()` shows real toasts) and the icon stroke of the
|
|
143
|
+
* view (2.5), so the preview matches what a host renders.
|
|
136
144
|
*
|
|
137
145
|
* ### Boundaries
|
|
138
146
|
* The harness simulates the **host-portable pattern** (`useHostBridge`,
|
|
@@ -153,10 +161,13 @@ export function WidgetFixtureHost({ widget: Widget, data = {}, dataType, tools,
|
|
|
153
161
|
// The standalone host bridge is the harness's single simulation source: it
|
|
154
162
|
// logs every verb through the `HostActionLog` channel for the playground's
|
|
155
163
|
// activity log. Depends on the callback props directly — a fresh Provider
|
|
156
|
-
// value on callback change is fine for a dev harness.
|
|
157
|
-
//
|
|
158
|
-
// `window.openai` shim).
|
|
164
|
+
// value on callback change is fine for a dev harness. `globals.theme` and
|
|
165
|
+
// `globals.locale` influence the simulated host (the remaining globals fed
|
|
166
|
+
// the 1.x `window.openai` shim).
|
|
159
167
|
const bridgeTheme = (globals?.theme ?? DEFAULT_GLOBALS.theme) === "dark" ? "dark" : "light";
|
|
168
|
+
const hostLocale = typeof globals?.locale === "string" && globals.locale.trim() !== ""
|
|
169
|
+
? globals.locale
|
|
170
|
+
: DEFAULT_GLOBALS.locale;
|
|
160
171
|
const bridge = useMemo(() => createStandaloneHostBridge({
|
|
161
172
|
callTool: (name, args) => {
|
|
162
173
|
onHostAction?.({ type: "callTool", name, args });
|
|
@@ -172,6 +183,8 @@ export function WidgetFixtureHost({ widget: Widget, data = {}, dataType, tools,
|
|
|
172
183
|
// Spread `widgetProps` (keys/context) AND a `data` alias so both adapted
|
|
173
184
|
// widgets and raw `({ data })` widgets read their fixture from one mount.
|
|
174
185
|
const RenderWidget = Widget;
|
|
175
|
-
|
|
186
|
+
// The same scope `McpAppView` puts around a widget: the toolkit's strings
|
|
187
|
+
// in the host locale, the CI icon stroke and a toast stack.
|
|
188
|
+
return (_jsx(FixtureHostContext.Provider, { value: value, children: _jsx(HostBridgeProvider, { bridge: bridge, children: _jsx(AppQueryProvider, { callTool: callTool, children: _jsx(ToolkitLocaleFallback, { locale: hostLocale, children: _jsx(LucideProvider, { strokeWidth: ICON_STROKE, children: _jsx(ToastProvider, { children: _jsx(RenderWidget, { ...widgetProps, data: data }) }) }) }) }) }) }));
|
|
176
189
|
}
|
|
177
190
|
//# sourceMappingURL=widget-fixture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-fixture.js","sourceRoot":"","sources":["../../src/app/widget-fixture.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAsC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"widget-fixture.js","sourceRoot":"","sources":["../../src/app/widget-fixture.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAsC,MAAM,OAAO,CAAA;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAkCjF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,uBAAuB;IACjB,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAA;IAE9D,YAAY,OAA0C;QACpD,IAAI,OAAO,EAAE,CAAC;YACZ,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;gBAAE,IAAI,CAAC,QAAQ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