@adia-ai/web-components 0.0.1
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 +195 -0
- package/a2ui/dockables/action.js +152 -0
- package/a2ui/dockables/base.js +30 -0
- package/a2ui/dockables/controller.js +97 -0
- package/a2ui/dockables/data-source.js +103 -0
- package/a2ui/dockables/index.js +6 -0
- package/a2ui/dockables/lifecycle.js +84 -0
- package/a2ui/dockables/provider.js +59 -0
- package/a2ui/index.js +19 -0
- package/a2ui/manifest-runtime.js +226 -0
- package/a2ui/registry.js +200 -0
- package/a2ui/renderer.js +361 -0
- package/a2ui/root.js +152 -0
- package/a2ui/stream.js +243 -0
- package/a2ui/surface-manifest.js +294 -0
- package/a2ui/surface.js +222 -0
- package/a2ui/wire-factory.js +134 -0
- package/a2ui/wiring-engine.js +209 -0
- package/a2ui/wiring-registry.js +342 -0
- package/components/accordion/accordion.a2ui.json +129 -0
- package/components/accordion/accordion.css +133 -0
- package/components/accordion/accordion.js +125 -0
- package/components/accordion/accordion.yaml +527 -0
- package/components/action-list/action-list.a2ui.json +64 -0
- package/components/action-list/action-list.css +115 -0
- package/components/action-list/action-list.js +149 -0
- package/components/action-list/action-list.yaml +56 -0
- package/components/agent-artifact/agent-artifact.a2ui.json +99 -0
- package/components/agent-artifact/agent-artifact.css +94 -0
- package/components/agent-artifact/agent-artifact.js +169 -0
- package/components/agent-artifact/agent-artifact.yaml +71 -0
- package/components/agent-feedback-bar/agent-feedback-bar.a2ui.json +91 -0
- package/components/agent-feedback-bar/agent-feedback-bar.css +33 -0
- package/components/agent-feedback-bar/agent-feedback-bar.js +152 -0
- package/components/agent-feedback-bar/agent-feedback-bar.yaml +65 -0
- package/components/agent-questions/agent-questions.a2ui.json +89 -0
- package/components/agent-questions/agent-questions.css +146 -0
- package/components/agent-questions/agent-questions.js +189 -0
- package/components/agent-questions/agent-questions.yaml +63 -0
- package/components/agent-reasoning/agent-reasoning.a2ui.json +100 -0
- package/components/agent-reasoning/agent-reasoning.css +273 -0
- package/components/agent-reasoning/agent-reasoning.js +469 -0
- package/components/agent-reasoning/agent-reasoning.yaml +70 -0
- package/components/agent-suggestions/agent-suggestions.a2ui.json +87 -0
- package/components/agent-suggestions/agent-suggestions.css +18 -0
- package/components/agent-suggestions/agent-suggestions.js +87 -0
- package/components/agent-suggestions/agent-suggestions.yaml +59 -0
- package/components/agent-trace/agent-trace.a2ui.json +78 -0
- package/components/agent-trace/agent-trace.css +275 -0
- package/components/agent-trace/agent-trace.js +216 -0
- package/components/agent-trace/agent-trace.yaml +53 -0
- package/components/alert/alert.a2ui.json +211 -0
- package/components/alert/alert.css +88 -0
- package/components/alert/alert.js +96 -0
- package/components/alert/alert.yaml +205 -0
- package/components/avatar/avatar.a2ui.json +215 -0
- package/components/avatar/avatar.css +159 -0
- package/components/avatar/avatar.js +157 -0
- package/components/avatar/avatar.yaml +559 -0
- package/components/badge/badge.a2ui.json +169 -0
- package/components/badge/badge.css +78 -0
- package/components/badge/badge.js +53 -0
- package/components/badge/badge.yaml +612 -0
- package/components/block/block.a2ui.json +135 -0
- package/components/block/block.css +29 -0
- package/components/block/block.js +23 -0
- package/components/block/block.yaml +115 -0
- package/components/breadcrumb/breadcrumb.a2ui.json +86 -0
- package/components/breadcrumb/breadcrumb.css +78 -0
- package/components/breadcrumb/breadcrumb.js +44 -0
- package/components/breadcrumb/breadcrumb.yaml +84 -0
- package/components/button/button.a2ui.json +172 -0
- package/components/button/button.css +168 -0
- package/components/button/button.js +60 -0
- package/components/button/button.yaml +120 -0
- package/components/calendar-picker/calendar-picker.a2ui.json +139 -0
- package/components/calendar-picker/calendar-picker.css +321 -0
- package/components/calendar-picker/calendar-picker.js +324 -0
- package/components/calendar-picker/calendar-picker.yaml +243 -0
- package/components/canvas/canvas.a2ui.json +75 -0
- package/components/canvas/canvas.css +52 -0
- package/components/canvas/canvas.js +179 -0
- package/components/canvas/canvas.yaml +62 -0
- package/components/card/card.a2ui.json +276 -0
- package/components/card/card.css +362 -0
- package/components/card/card.js +58 -0
- package/components/card/card.yaml +527 -0
- package/components/chart/chart.a2ui.json +298 -0
- package/components/chart/chart.css +512 -0
- package/components/chart/chart.js +1075 -0
- package/components/chart/chart.yaml +540 -0
- package/components/chat/chat-input.css +141 -0
- package/components/chat/chat-input.js +242 -0
- package/components/chat/chat.a2ui.json +181 -0
- package/components/chat/chat.css +193 -0
- package/components/chat/chat.js +155 -0
- package/components/chat/chat.yaml +230 -0
- package/components/check/check.a2ui.json +134 -0
- package/components/check/check.css +126 -0
- package/components/check/check.js +58 -0
- package/components/check/check.yaml +109 -0
- package/components/code/code.a2ui.json +153 -0
- package/components/code/code.css +133 -0
- package/components/code/code.js +114 -0
- package/components/code/code.yaml +163 -0
- package/components/col/col.a2ui.json +104 -0
- package/components/col/col.css +36 -0
- package/components/col/col.js +19 -0
- package/components/col/col.yaml +364 -0
- package/components/color-picker/color-picker.a2ui.json +100 -0
- package/components/color-picker/color-picker.css +182 -0
- package/components/color-picker/color-picker.js +537 -0
- package/components/color-picker/color-picker.yaml +105 -0
- package/components/command/command.a2ui.json +221 -0
- package/components/command/command.css +251 -0
- package/components/command/command.js +284 -0
- package/components/command/command.yaml +186 -0
- package/components/description-list/description-list.a2ui.json +89 -0
- package/components/description-list/description-list.css +70 -0
- package/components/description-list/description-list.js +75 -0
- package/components/description-list/description-list.yaml +59 -0
- package/components/divider/divider.a2ui.json +126 -0
- package/components/divider/divider.css +102 -0
- package/components/divider/divider.js +47 -0
- package/components/divider/divider.yaml +366 -0
- package/components/drawer/drawer.a2ui.json +199 -0
- package/components/drawer/drawer.css +342 -0
- package/components/drawer/drawer.js +263 -0
- package/components/drawer/drawer.yaml +366 -0
- package/components/embed/embed.a2ui.json +150 -0
- package/components/embed/embed.css +28 -0
- package/components/embed/embed.js +63 -0
- package/components/embed/embed.yaml +224 -0
- package/components/empty-state/empty-state.a2ui.json +133 -0
- package/components/empty-state/empty-state.css +58 -0
- package/components/empty-state/empty-state.js +87 -0
- package/components/empty-state/empty-state.yaml +314 -0
- package/components/footer/footer.a2ui.json +79 -0
- package/components/footer/footer.yaml +239 -0
- package/components/grid/grid.a2ui.json +171 -0
- package/components/grid/grid.css +37 -0
- package/components/grid/grid.js +21 -0
- package/components/grid/grid.yaml +577 -0
- package/components/header/header.a2ui.json +76 -0
- package/components/header/header.yaml +336 -0
- package/components/heatmap/heatmap.a2ui.json +150 -0
- package/components/heatmap/heatmap.css +146 -0
- package/components/heatmap/heatmap.js +246 -0
- package/components/heatmap/heatmap.yaml +131 -0
- package/components/icon/icon.a2ui.json +79 -0
- package/components/icon/icon.css +20 -0
- package/components/icon/icon.js +26 -0
- package/components/icon/icon.yaml +233 -0
- package/components/image/image.a2ui.json +261 -0
- package/components/image/image.css +76 -0
- package/components/image/image.js +102 -0
- package/components/image/image.yaml +477 -0
- package/components/index.js +85 -0
- package/components/input/input.a2ui.json +284 -0
- package/components/input/input.css +162 -0
- package/components/input/input.js +148 -0
- package/components/input/input.yaml +496 -0
- package/components/inspector/inspector.a2ui.json +67 -0
- package/components/inspector/inspector.css +31 -0
- package/components/inspector/inspector.js +133 -0
- package/components/inspector/inspector.yaml +58 -0
- package/components/kbd/kbd.a2ui.json +96 -0
- package/components/kbd/kbd.css +62 -0
- package/components/kbd/kbd.js +24 -0
- package/components/kbd/kbd.yaml +213 -0
- package/components/list/list.a2ui.json +145 -0
- package/components/list/list.css +103 -0
- package/components/list/list.js +236 -0
- package/components/list/list.yaml +122 -0
- package/components/menu/menu.a2ui.json +146 -0
- package/components/menu/menu.css +146 -0
- package/components/menu/menu.js +296 -0
- package/components/menu/menu.yaml +123 -0
- package/components/modal/modal.a2ui.json +136 -0
- package/components/modal/modal.css +153 -0
- package/components/modal/modal.js +181 -0
- package/components/modal/modal.yaml +114 -0
- package/components/noodles/noodles.a2ui.json +145 -0
- package/components/noodles/noodles.css +118 -0
- package/components/noodles/noodles.js +470 -0
- package/components/noodles/noodles.yaml +123 -0
- package/components/otp-input/otp-input.a2ui.json +104 -0
- package/components/otp-input/otp-input.css +78 -0
- package/components/otp-input/otp-input.js +170 -0
- package/components/otp-input/otp-input.yaml +218 -0
- package/components/pagination/pagination.a2ui.json +122 -0
- package/components/pagination/pagination.css +162 -0
- package/components/pagination/pagination.js +185 -0
- package/components/pagination/pagination.yaml +165 -0
- package/components/pane/pane.a2ui.json +94 -0
- package/components/pane/pane.css +166 -0
- package/components/pane/pane.js +140 -0
- package/components/pane/pane.yaml +197 -0
- package/components/pipeline-status/pipeline-status.a2ui.json +90 -0
- package/components/pipeline-status/pipeline-status.css +162 -0
- package/components/pipeline-status/pipeline-status.js +176 -0
- package/components/pipeline-status/pipeline-status.yaml +99 -0
- package/components/popover/popover.a2ui.json +181 -0
- package/components/popover/popover.css +57 -0
- package/components/popover/popover.js +170 -0
- package/components/popover/popover.yaml +257 -0
- package/components/progress/progress.a2ui.json +199 -0
- package/components/progress/progress.css +88 -0
- package/components/progress/progress.js +64 -0
- package/components/progress/progress.yaml +342 -0
- package/components/progress-row/progress-row.a2ui.json +100 -0
- package/components/progress-row/progress-row.css +57 -0
- package/components/progress-row/progress-row.js +92 -0
- package/components/progress-row/progress-row.yaml +87 -0
- package/components/radio/radio.a2ui.json +232 -0
- package/components/radio/radio.css +102 -0
- package/components/radio/radio.js +73 -0
- package/components/radio/radio.yaml +248 -0
- package/components/range/range.a2ui.json +151 -0
- package/components/range/range.css +148 -0
- package/components/range/range.js +177 -0
- package/components/range/range.yaml +188 -0
- package/components/rating/rating.a2ui.json +105 -0
- package/components/rating/rating.css +92 -0
- package/components/rating/rating.js +138 -0
- package/components/rating/rating.yaml +74 -0
- package/components/richtext/richtext.a2ui.json +82 -0
- package/components/richtext/richtext.css +225 -0
- package/components/richtext/richtext.js +74 -0
- package/components/richtext/richtext.yaml +89 -0
- package/components/row/row.a2ui.json +102 -0
- package/components/row/row.css +51 -0
- package/components/row/row.js +39 -0
- package/components/row/row.yaml +358 -0
- package/components/search/search.a2ui.json +186 -0
- package/components/search/search.css +28 -0
- package/components/search/search.js +124 -0
- package/components/search/search.yaml +154 -0
- package/components/section/section.a2ui.json +78 -0
- package/components/section/section.yaml +338 -0
- package/components/segment/segment.a2ui.json +100 -0
- package/components/segment/segment.css +81 -0
- package/components/segment/segment.js +32 -0
- package/components/segment/segment.yaml +216 -0
- package/components/segmented/segmented.a2ui.json +106 -0
- package/components/segmented/segmented.css +67 -0
- package/components/segmented/segmented.js +149 -0
- package/components/segmented/segmented.yaml +91 -0
- package/components/select/select.a2ui.json +203 -0
- package/components/select/select.css +277 -0
- package/components/select/select.js +388 -0
- package/components/select/select.yaml +375 -0
- package/components/skeleton/skeleton.a2ui.json +120 -0
- package/components/skeleton/skeleton.css +47 -0
- package/components/skeleton/skeleton.js +43 -0
- package/components/skeleton/skeleton.yaml +153 -0
- package/components/slider/slider.a2ui.json +162 -0
- package/components/slider/slider.css +137 -0
- package/components/slider/slider.js +162 -0
- package/components/slider/slider.yaml +299 -0
- package/components/stack/stack.a2ui.json +62 -0
- package/components/stack/stack.css +28 -0
- package/components/stack/stack.js +18 -0
- package/components/stack/stack.yaml +54 -0
- package/components/stat/stat.a2ui.json +246 -0
- package/components/stat/stat.css +101 -0
- package/components/stat/stat.js +91 -0
- package/components/stat/stat.yaml +206 -0
- package/components/stepper/stepper.a2ui.json +77 -0
- package/components/stepper/stepper.css +243 -0
- package/components/stepper/stepper.js +118 -0
- package/components/stepper/stepper.yaml +73 -0
- package/components/stream/stream.a2ui.json +98 -0
- package/components/stream/stream.css +37 -0
- package/components/stream/stream.js +99 -0
- package/components/stream/stream.yaml +87 -0
- package/components/swiper/swiper.a2ui.json +140 -0
- package/components/swiper/swiper.css +267 -0
- package/components/swiper/swiper.js +285 -0
- package/components/swiper/swiper.yaml +268 -0
- package/components/switch/switch.a2ui.json +134 -0
- package/components/switch/switch.css +104 -0
- package/components/switch/switch.js +53 -0
- package/components/switch/switch.yaml +322 -0
- package/components/table/cell-types.js +296 -0
- package/components/table/table.a2ui.json +458 -0
- package/components/table/table.css +531 -0
- package/components/table/table.js +1392 -0
- package/components/table/table.yaml +528 -0
- package/components/tabs/tab.js +34 -0
- package/components/tabs/tabs.a2ui.json +174 -0
- package/components/tabs/tabs.css +162 -0
- package/components/tabs/tabs.js +226 -0
- package/components/tabs/tabs.yaml +255 -0
- package/components/tag/tag.a2ui.json +148 -0
- package/components/tag/tag.css +118 -0
- package/components/tag/tag.js +88 -0
- package/components/tag/tag.yaml +125 -0
- package/components/text/text.a2ui.json +99 -0
- package/components/text/text.css +65 -0
- package/components/text/text.js +35 -0
- package/components/text/text.yaml +360 -0
- package/components/textarea/textarea.a2ui.json +91 -0
- package/components/textarea/textarea.css +93 -0
- package/components/textarea/textarea.js +114 -0
- package/components/textarea/textarea.yaml +79 -0
- package/components/timeline/timeline.a2ui.json +82 -0
- package/components/timeline/timeline.css +389 -0
- package/components/timeline/timeline.js +171 -0
- package/components/timeline/timeline.yaml +185 -0
- package/components/toast/toast.a2ui.json +199 -0
- package/components/toast/toast.css +211 -0
- package/components/toast/toast.js +146 -0
- package/components/toast/toast.yaml +184 -0
- package/components/toggle-group/toggle-group.a2ui.json +126 -0
- package/components/toggle-group/toggle-group.css +102 -0
- package/components/toggle-group/toggle-group.js +147 -0
- package/components/toggle-group/toggle-group.yaml +98 -0
- package/components/toolbar/toolbar.a2ui.json +131 -0
- package/components/toolbar/toolbar.css +132 -0
- package/components/toolbar/toolbar.js +366 -0
- package/components/toolbar/toolbar.yaml +238 -0
- package/components/tooltip/tooltip.a2ui.json +148 -0
- package/components/tooltip/tooltip.css +39 -0
- package/components/tooltip/tooltip.js +96 -0
- package/components/tooltip/tooltip.yaml +201 -0
- package/components/tree/tree.a2ui.json +119 -0
- package/components/tree/tree.css +133 -0
- package/components/tree/tree.js +253 -0
- package/components/tree/tree.yaml +92 -0
- package/components/upload/upload.a2ui.json +185 -0
- package/components/upload/upload.css +115 -0
- package/components/upload/upload.js +189 -0
- package/components/upload/upload.yaml +302 -0
- package/core/anchor.js +187 -0
- package/core/controller.js +182 -0
- package/core/element.js +257 -0
- package/core/form.js +217 -0
- package/core/icons.js +180 -0
- package/core/markdown.js +95 -0
- package/core/polyfills.js +23 -0
- package/core/provider.js +262 -0
- package/core/signals.js +113 -0
- package/core/template.js +226 -0
- package/core/transport.js +77 -0
- package/package.json +38 -0
- package/patterns/adia-chat/adia-chat.a2ui.json +149 -0
- package/patterns/adia-chat/adia-chat.css +10 -0
- package/patterns/adia-chat/adia-chat.js +297 -0
- package/patterns/adia-chat/adia-chat.yaml +118 -0
- package/patterns/adia-chat/css/adia-chat.empty.css +12 -0
- package/patterns/adia-chat/css/adia-chat.layout.css +60 -0
- package/patterns/adia-chat/css/adia-chat.markdown.css +74 -0
- package/patterns/adia-chat/css/adia-chat.messages.css +87 -0
- package/patterns/adia-chat/css/adia-chat.streaming.css +30 -0
- package/patterns/adia-chat/css/adia-chat.tokens.css +95 -0
- package/patterns/adia-chat/index.html +93 -0
- package/patterns/adia-editor/adia-editor.a2ui.json +58 -0
- package/patterns/adia-editor/adia-editor.css +6 -0
- package/patterns/adia-editor/adia-editor.js +56 -0
- package/patterns/adia-editor/adia-editor.yaml +36 -0
- package/patterns/adia-editor/css/adia-editor.layout.css +86 -0
- package/patterns/adia-editor/css/adia-editor.tokens.css +28 -0
- package/patterns/adia-editor/index.html +179 -0
- package/patterns/app-nav/app-nav.a2ui.json +89 -0
- package/patterns/app-nav/app-nav.css +92 -0
- package/patterns/app-nav/app-nav.js +99 -0
- package/patterns/app-nav/app-nav.yaml +54 -0
- package/patterns/app-nav-group/app-nav-group.a2ui.json +82 -0
- package/patterns/app-nav-group/app-nav-group.css +261 -0
- package/patterns/app-nav-group/app-nav-group.js +116 -0
- package/patterns/app-nav-group/app-nav-group.yaml +59 -0
- package/patterns/app-nav-item/app-nav-item.a2ui.json +83 -0
- package/patterns/app-nav-item/app-nav-item.css +156 -0
- package/patterns/app-nav-item/app-nav-item.js +42 -0
- package/patterns/app-nav-item/app-nav-item.yaml +62 -0
- package/patterns/app-shell/app-shell.a2ui.json +114 -0
- package/patterns/app-shell/app-shell.css +14 -0
- package/patterns/app-shell/app-shell.js +251 -0
- package/patterns/app-shell/app-shell.yaml +66 -0
- package/patterns/app-shell/css/app-shell.collapsed.css +86 -0
- package/patterns/app-shell/css/app-shell.helpers.css +42 -0
- package/patterns/app-shell/css/app-shell.main.css +58 -0
- package/patterns/app-shell/css/app-shell.shell.css +44 -0
- package/patterns/app-shell/css/app-shell.sidebar.css +116 -0
- package/patterns/app-shell/css/app-shell.templates.css +214 -0
- package/patterns/app-shell/css/app-shell.tokens.css +116 -0
- package/patterns/app-shell/index.html +112 -0
- package/patterns/gen-ui/gen-ui.a2ui.json +72 -0
- package/patterns/gen-ui/gen-ui.css +83 -0
- package/patterns/gen-ui/gen-ui.js +136 -0
- package/patterns/gen-ui/gen-ui.yaml +43 -0
- package/patterns/index.js +10 -0
- package/patterns/section-nav/section-nav.a2ui.json +91 -0
- package/patterns/section-nav/section-nav.css +59 -0
- package/patterns/section-nav/section-nav.js +42 -0
- package/patterns/section-nav/section-nav.yaml +58 -0
- package/patterns/section-nav-group/section-nav-group.a2ui.json +95 -0
- package/patterns/section-nav-group/section-nav-group.css +74 -0
- package/patterns/section-nav-group/section-nav-group.js +84 -0
- package/patterns/section-nav-group/section-nav-group.yaml +66 -0
- package/patterns/section-nav-item/section-nav-item.a2ui.json +97 -0
- package/patterns/section-nav-item/section-nav-item.css +96 -0
- package/patterns/section-nav-item/section-nav-item.js +66 -0
- package/patterns/section-nav-item/section-nav-item.yaml +70 -0
- package/styles/colors/index.css +6 -0
- package/styles/colors/parameters.css +52 -0
- package/styles/colors/primitives-accent.css +89 -0
- package/styles/colors/primitives-brand.css +89 -0
- package/styles/colors/primitives-danger.css +89 -0
- package/styles/colors/primitives-info.css +89 -0
- package/styles/colors/primitives-neutral.css +91 -0
- package/styles/colors/primitives-shared.css +57 -0
- package/styles/colors/primitives-success.css +89 -0
- package/styles/colors/primitives-warning.css +89 -0
- package/styles/colors/primitives.css +17 -0
- package/styles/colors/scrims.css +182 -0
- package/styles/colors/semantics.css +595 -0
- package/styles/colors/surfaces.css +43 -0
- package/styles/fonts.css +99 -0
- package/styles/layouts/admin.css +7 -0
- package/styles/prose.css +186 -0
- package/styles/styles.css +193 -0
- package/styles/themes.css +155 -0
- package/styles/tokens.css +304 -0
- package/styles/typography.css +853 -0
- package/traits/active-state.js +24 -0
- package/traits/anchor-positioning.js +66 -0
- package/traits/attention-pulse.js +30 -0
- package/traits/confetti-burst.js +65 -0
- package/traits/confetti.js +57 -0
- package/traits/count-up.js +42 -0
- package/traits/define.js +76 -0
- package/traits/dirty-state.js +38 -0
- package/traits/drag-ghost.js +38 -0
- package/traits/draggable.js +73 -0
- package/traits/fade-presence.js +52 -0
- package/traits/focus-trap.js +63 -0
- package/traits/focusable.js +38 -0
- package/traits/glow-focus.js +33 -0
- package/traits/gradient-shift.js +32 -0
- package/traits/haptic-feedback.js +28 -0
- package/traits/hotkey.js +62 -0
- package/traits/hoverable.js +26 -0
- package/traits/index.js +55 -0
- package/traits/inertia-drag.js +133 -0
- package/traits/intersection-observer.js +33 -0
- package/traits/keyboard-nav.js +36 -0
- package/traits/magnetic-hover.js +37 -0
- package/traits/noise-texture.js +30 -0
- package/traits/parallax.js +42 -0
- package/traits/portal.js +27 -0
- package/traits/pressable.js +75 -0
- package/traits/resizable.js +100 -0
- package/traits/resize-observer.js +31 -0
- package/traits/ripple.js +53 -0
- package/traits/roving-tabindex.js +67 -0
- package/traits/scale-press.js +43 -0
- package/traits/scroll-lock.js +27 -0
- package/traits/shimmer-loading.js +44 -0
- package/traits/snap-to-grid.js +28 -0
- package/traits/sound-feedback.js +30 -0
- package/traits/spring-animate.js +56 -0
- package/traits/tilt-hover.js +37 -0
- package/traits/tossable.js +178 -0
- package/traits/typeahead.js +63 -0
- package/traits/typewriter.js +35 -0
- package/traits/validation.js +118 -0
package/a2ui/stream.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI Stream Adapters — connect to various transports and yield A2UI messages.
|
|
3
|
+
*
|
|
4
|
+
* Each adapter returns an AsyncIterable<A2UIMessage>.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* const stream = sseStream('/api/agent');
|
|
8
|
+
* for await (const message of stream) { renderer.process(message); }
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SSE (Server-Sent Events) stream adapter.
|
|
13
|
+
*/
|
|
14
|
+
export function sseStream(url, options = {}) {
|
|
15
|
+
let finalUrl = url;
|
|
16
|
+
if (options.catalog) {
|
|
17
|
+
const types = options.catalog instanceof Map ? [...options.catalog.keys()] : Object.keys(options.catalog);
|
|
18
|
+
const sep = url.includes('?') ? '&' : '?';
|
|
19
|
+
finalUrl = `${url}${sep}a2ui_catalog=${encodeURIComponent(types.join(','))}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
[Symbol.asyncIterator]() {
|
|
24
|
+
const eventSource = new EventSource(finalUrl);
|
|
25
|
+
const queue = [];
|
|
26
|
+
let resolve = null;
|
|
27
|
+
let done = false;
|
|
28
|
+
|
|
29
|
+
eventSource.onmessage = (e) => {
|
|
30
|
+
try {
|
|
31
|
+
const message = JSON.parse(e.data);
|
|
32
|
+
if (resolve) { const r = resolve; resolve = null; r({ value: message, done: false }); }
|
|
33
|
+
else queue.push(message);
|
|
34
|
+
} catch { console.warn('A2UI SSE: invalid JSON', e.data); }
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
eventSource.onerror = () => {
|
|
38
|
+
done = true;
|
|
39
|
+
eventSource.close();
|
|
40
|
+
if (resolve) { const r = resolve; resolve = null; r({ value: undefined, done: true }); }
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
if (options.signal) {
|
|
44
|
+
options.signal.addEventListener('abort', () => {
|
|
45
|
+
done = true;
|
|
46
|
+
eventSource.close();
|
|
47
|
+
if (resolve) { const r = resolve; resolve = null; r({ value: undefined, done: true }); }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
next() {
|
|
53
|
+
if (queue.length > 0) return Promise.resolve({ value: queue.shift(), done: false });
|
|
54
|
+
if (done) return Promise.resolve({ value: undefined, done: true });
|
|
55
|
+
return new Promise(r => { resolve = r; });
|
|
56
|
+
},
|
|
57
|
+
return() {
|
|
58
|
+
done = true;
|
|
59
|
+
eventSource.close();
|
|
60
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* WebSocket stream adapter.
|
|
69
|
+
*/
|
|
70
|
+
export function wsStream(url, options = {}) {
|
|
71
|
+
return {
|
|
72
|
+
[Symbol.asyncIterator]() {
|
|
73
|
+
const ws = new WebSocket(url);
|
|
74
|
+
const queue = [];
|
|
75
|
+
let resolve = null;
|
|
76
|
+
let done = false;
|
|
77
|
+
|
|
78
|
+
ws.onopen = () => {
|
|
79
|
+
if (options.catalog) {
|
|
80
|
+
const types = options.catalog instanceof Map ? [...options.catalog.keys()] : Object.keys(options.catalog);
|
|
81
|
+
ws.send(JSON.stringify({ type: 'a2ui:catalog', supportedTypes: types }));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
ws.onmessage = (e) => {
|
|
86
|
+
try {
|
|
87
|
+
const message = JSON.parse(e.data);
|
|
88
|
+
if (resolve) { const r = resolve; resolve = null; r({ value: message, done: false }); }
|
|
89
|
+
else queue.push(message);
|
|
90
|
+
} catch { console.warn('A2UI WS: invalid JSON', e.data); }
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
ws.onclose = () => {
|
|
94
|
+
done = true;
|
|
95
|
+
if (resolve) { const r = resolve; resolve = null; r({ value: undefined, done: true }); }
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
ws.onerror = () => { done = true; ws.close(); };
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
next() {
|
|
102
|
+
if (queue.length > 0) return Promise.resolve({ value: queue.shift(), done: false });
|
|
103
|
+
if (done) return Promise.resolve({ value: undefined, done: true });
|
|
104
|
+
return new Promise(r => { resolve = r; });
|
|
105
|
+
},
|
|
106
|
+
return() { done = true; ws.close(); return Promise.resolve({ value: undefined, done: true }); },
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Array/mock stream adapter — for testing.
|
|
114
|
+
*/
|
|
115
|
+
export function mockStream(messages, delay = 0) {
|
|
116
|
+
return {
|
|
117
|
+
async *[Symbol.asyncIterator]() {
|
|
118
|
+
for (const msg of messages) {
|
|
119
|
+
if (delay > 0) await new Promise(r => setTimeout(r, delay));
|
|
120
|
+
yield msg;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* MCP stream adapter — connects to MCP server, yields A2UI messages.
|
|
128
|
+
*/
|
|
129
|
+
export function mcpStream(url, options = {}) {
|
|
130
|
+
return {
|
|
131
|
+
async *[Symbol.asyncIterator]() {
|
|
132
|
+
const { signal, catalog, onAction } = options;
|
|
133
|
+
|
|
134
|
+
const ws = new WebSocket(url);
|
|
135
|
+
await new Promise((resolve, reject) => {
|
|
136
|
+
ws.onopen = resolve;
|
|
137
|
+
ws.onerror = reject;
|
|
138
|
+
if (signal) signal.addEventListener('abort', () => {
|
|
139
|
+
ws.close();
|
|
140
|
+
reject(new DOMException('Aborted', 'AbortError'));
|
|
141
|
+
}, { once: true });
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (catalog) {
|
|
145
|
+
const types = catalog instanceof Map ? [...catalog.keys()] : Object.keys(catalog);
|
|
146
|
+
ws.send(JSON.stringify({
|
|
147
|
+
jsonrpc: '2.0',
|
|
148
|
+
method: 'a2ui/catalog',
|
|
149
|
+
params: { supportedTypes: types },
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const queue = [];
|
|
154
|
+
let resolve = null;
|
|
155
|
+
let done = false;
|
|
156
|
+
|
|
157
|
+
ws.onmessage = (e) => {
|
|
158
|
+
try {
|
|
159
|
+
const rpc = JSON.parse(e.data);
|
|
160
|
+
|
|
161
|
+
if (rpc.result?.content) {
|
|
162
|
+
for (const block of rpc.result.content) {
|
|
163
|
+
if (block.type === 'resource' && block.resource?.mimeType === 'application/json+a2ui') {
|
|
164
|
+
const messages = JSON.parse(block.resource.text);
|
|
165
|
+
for (const msg of (Array.isArray(messages) ? messages : [messages])) {
|
|
166
|
+
if (resolve) { const r = resolve; resolve = null; r({ value: msg, done: false }); }
|
|
167
|
+
else queue.push(msg);
|
|
168
|
+
}
|
|
169
|
+
} else if (block.type === 'text') {
|
|
170
|
+
try {
|
|
171
|
+
const msg = JSON.parse(block.text);
|
|
172
|
+
if (msg.type && (msg.type.startsWith('create') || msg.type.startsWith('update') || msg.type.startsWith('delete'))) {
|
|
173
|
+
if (resolve) { const r = resolve; resolve = null; r({ value: msg, done: false }); }
|
|
174
|
+
else queue.push(msg);
|
|
175
|
+
}
|
|
176
|
+
} catch { /* not A2UI */ }
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (rpc.method === 'a2ui/action' && onAction) {
|
|
182
|
+
onAction(rpc.params?.name, rpc.params?.arguments).then(result => {
|
|
183
|
+
ws.send(JSON.stringify({ jsonrpc: '2.0', id: rpc.id, result }));
|
|
184
|
+
}).catch(err => {
|
|
185
|
+
ws.send(JSON.stringify({ jsonrpc: '2.0', id: rpc.id, error: { code: -1, message: err.message } }));
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
} catch { console.warn('A2UI MCP: invalid message', e.data); }
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
ws.onclose = () => { done = true; if (resolve) { const r = resolve; resolve = null; r({ value: undefined, done: true }); } };
|
|
192
|
+
ws.onerror = () => { done = true; ws.close(); };
|
|
193
|
+
if (signal) signal.addEventListener('abort', () => { done = true; ws.close(); if (resolve) { const r = resolve; resolve = null; r({ value: undefined, done: true }); } });
|
|
194
|
+
|
|
195
|
+
while (!done || queue.length > 0) {
|
|
196
|
+
if (queue.length > 0) { yield queue.shift(); }
|
|
197
|
+
else if (done) { break; }
|
|
198
|
+
else {
|
|
199
|
+
const v = await new Promise(r => { resolve = r; });
|
|
200
|
+
if (v.done) break;
|
|
201
|
+
yield v.value;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* JSONL (newline-delimited JSON) stream adapter via fetch.
|
|
210
|
+
*/
|
|
211
|
+
export function jsonlStream(url, options = {}) {
|
|
212
|
+
return {
|
|
213
|
+
async *[Symbol.asyncIterator]() {
|
|
214
|
+
const headers = {};
|
|
215
|
+
if (options.catalog) {
|
|
216
|
+
const types = options.catalog instanceof Map ? [...options.catalog.keys()] : Object.keys(options.catalog);
|
|
217
|
+
headers['X-A2UI-Catalog'] = types.join(',');
|
|
218
|
+
}
|
|
219
|
+
const response = await fetch(url, { signal: options.signal, headers });
|
|
220
|
+
const reader = response.body.getReader();
|
|
221
|
+
const decoder = new TextDecoder();
|
|
222
|
+
let buffer = '';
|
|
223
|
+
|
|
224
|
+
while (true) {
|
|
225
|
+
const { done, value } = await reader.read();
|
|
226
|
+
if (done) break;
|
|
227
|
+
buffer += decoder.decode(value, { stream: true });
|
|
228
|
+
const lines = buffer.split('\n');
|
|
229
|
+
buffer = lines.pop();
|
|
230
|
+
for (const line of lines) {
|
|
231
|
+
const trimmed = line.trim();
|
|
232
|
+
if (!trimmed) continue;
|
|
233
|
+
try { yield JSON.parse(trimmed); }
|
|
234
|
+
catch { console.warn('A2UI JSONL: invalid JSON', trimmed); }
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (buffer.trim()) {
|
|
238
|
+
try { yield JSON.parse(buffer.trim()); }
|
|
239
|
+
catch { /* ignore */ }
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface Manifest — Multi-surface relationship document (A008).
|
|
3
|
+
*
|
|
4
|
+
* Manages a graph of surfaces and their associations:
|
|
5
|
+
* routes-to, feeds, shares-context, depends-on, triggers, contains, slots-into
|
|
6
|
+
*
|
|
7
|
+
* The manifest is the design-time document that describes application topology.
|
|
8
|
+
* The runtime reads it to set up navigation, pre-fetch data, and manage
|
|
9
|
+
* cross-surface context.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} SurfaceDescriptor
|
|
14
|
+
* @property {string} name — Human-readable name
|
|
15
|
+
* @property {string} [route] — URL pattern with :param placeholders
|
|
16
|
+
* @property {boolean} [entryPoint] — Can user navigate here directly?
|
|
17
|
+
* @property {string[]} [requiredParams] — Params needed to render
|
|
18
|
+
* @property {Record<string, object>} [produces] — Data this surface outputs
|
|
19
|
+
* @property {Record<string, { keys: string[] }>} [consumes] — Named contexts consumed
|
|
20
|
+
* @property {string} [status] — generated | manual | template | placeholder
|
|
21
|
+
* @property {string} [generatedBy] — Execution ID from gen-ui pipeline
|
|
22
|
+
* @property {string[]} [tags] — Freeform tags
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {object} Association
|
|
27
|
+
* @property {string} type — routes-to | feeds | shares-context | depends-on | triggers | contains | slots-into
|
|
28
|
+
* @property {string} from — Source surface ID
|
|
29
|
+
* @property {string} to — Target surface ID
|
|
30
|
+
* @property {string} [trigger] — What activates this association
|
|
31
|
+
* @property {Record<string, object>} [params] — Data passed from source to target
|
|
32
|
+
* @property {object} [mapping] — Data flow mapping (for feeds)
|
|
33
|
+
* @property {string} [context] — Shared context name (for shares-context)
|
|
34
|
+
* @property {string} [condition] — Dependency condition (for depends-on)
|
|
35
|
+
* @property {string} [fallback] — Fallback action (for depends-on)
|
|
36
|
+
* @property {string} [effect] — Side effect (for triggers)
|
|
37
|
+
* @property {string} [slot] — Composition slot (for contains/slots-into)
|
|
38
|
+
* @property {number} [position] — Order within slot
|
|
39
|
+
* @property {object} [meta] — Freeform metadata
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
export class SurfaceManifest {
|
|
43
|
+
#id;
|
|
44
|
+
#name;
|
|
45
|
+
#version;
|
|
46
|
+
/** @type {Map<string, SurfaceDescriptor>} */
|
|
47
|
+
#surfaces = new Map();
|
|
48
|
+
/** @type {Association[]} */
|
|
49
|
+
#associations = [];
|
|
50
|
+
/** @type {Map<string, object>} */
|
|
51
|
+
#sharedContexts = new Map();
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {object} opts
|
|
55
|
+
* @param {string} opts.id — Manifest ID
|
|
56
|
+
* @param {string} opts.name — Human-readable name
|
|
57
|
+
* @param {string} [opts.version]
|
|
58
|
+
*/
|
|
59
|
+
constructor({ id, name, version = '1.0.0' }) {
|
|
60
|
+
this.#id = id;
|
|
61
|
+
this.#name = name;
|
|
62
|
+
this.#version = version;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ── Surface CRUD ──
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Add or update a surface descriptor.
|
|
69
|
+
* @param {string} surfaceId
|
|
70
|
+
* @param {SurfaceDescriptor} descriptor
|
|
71
|
+
*/
|
|
72
|
+
addSurface(surfaceId, descriptor) {
|
|
73
|
+
this.#surfaces.set(surfaceId, { ...descriptor });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Remove a surface and all its associations.
|
|
78
|
+
* @param {string} surfaceId
|
|
79
|
+
*/
|
|
80
|
+
removeSurface(surfaceId) {
|
|
81
|
+
this.#surfaces.delete(surfaceId);
|
|
82
|
+
this.#associations = this.#associations.filter(
|
|
83
|
+
a => a.from !== surfaceId && a.to !== surfaceId
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get a surface descriptor.
|
|
89
|
+
* @param {string} surfaceId
|
|
90
|
+
* @returns {SurfaceDescriptor | null}
|
|
91
|
+
*/
|
|
92
|
+
getSurface(surfaceId) {
|
|
93
|
+
return this.#surfaces.get(surfaceId) ?? null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** @returns {string[]} */
|
|
97
|
+
get surfaceIds() {
|
|
98
|
+
return [...this.#surfaces.keys()];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ── Associations ──
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Add an association between surfaces.
|
|
105
|
+
* @param {Association} association
|
|
106
|
+
*/
|
|
107
|
+
addAssociation(association) {
|
|
108
|
+
// Validate surfaces exist
|
|
109
|
+
if (!this.#surfaces.has(association.from)) {
|
|
110
|
+
console.warn(`Manifest: surface "${association.from}" not found`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (!this.#surfaces.has(association.to)) {
|
|
114
|
+
console.warn(`Manifest: surface "${association.to}" not found`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Deduplicate: same type + from + to replaces existing
|
|
119
|
+
this.#associations = this.#associations.filter(
|
|
120
|
+
a => !(a.type === association.type && a.from === association.from && a.to === association.to)
|
|
121
|
+
);
|
|
122
|
+
this.#associations.push({ ...association });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get associations for a surface (outgoing).
|
|
127
|
+
* @param {string} surfaceId
|
|
128
|
+
* @param {string} [type] — Filter by association type
|
|
129
|
+
* @returns {Association[]}
|
|
130
|
+
*/
|
|
131
|
+
getAssociationsFrom(surfaceId, type) {
|
|
132
|
+
return this.#associations.filter(
|
|
133
|
+
a => a.from === surfaceId && (!type || a.type === type)
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get associations targeting a surface (incoming).
|
|
139
|
+
* @param {string} surfaceId
|
|
140
|
+
* @param {string} [type]
|
|
141
|
+
* @returns {Association[]}
|
|
142
|
+
*/
|
|
143
|
+
getAssociationsTo(surfaceId, type) {
|
|
144
|
+
return this.#associations.filter(
|
|
145
|
+
a => a.to === surfaceId && (!type || a.type === type)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Get all surfaces sharing a context with the given surface.
|
|
151
|
+
* @param {string} surfaceId
|
|
152
|
+
* @returns {{ surfaceId: string, context: string }[]}
|
|
153
|
+
*/
|
|
154
|
+
getSharedContextPeers(surfaceId) {
|
|
155
|
+
const peers = [];
|
|
156
|
+
for (const a of this.#associations) {
|
|
157
|
+
if (a.type !== 'shares-context') continue;
|
|
158
|
+
if (a.from === surfaceId) peers.push({ surfaceId: a.to, context: a.context });
|
|
159
|
+
if (a.to === surfaceId) peers.push({ surfaceId: a.from, context: a.context });
|
|
160
|
+
}
|
|
161
|
+
return peers;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ── Shared Contexts ──
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Define a shared context.
|
|
168
|
+
* @param {string} name
|
|
169
|
+
* @param {object} config — { shape, source, params }
|
|
170
|
+
*/
|
|
171
|
+
defineSharedContext(name, config) {
|
|
172
|
+
this.#sharedContexts.set(name, { ...config });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Get a shared context definition.
|
|
177
|
+
* @param {string} name
|
|
178
|
+
* @returns {object | null}
|
|
179
|
+
*/
|
|
180
|
+
getSharedContext(name) {
|
|
181
|
+
return this.#sharedContexts.get(name) ?? null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ── Validation ──
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Validate the manifest for common issues.
|
|
188
|
+
* @returns {{ valid: boolean, issues: { severity: string, message: string }[] }}
|
|
189
|
+
*/
|
|
190
|
+
validate() {
|
|
191
|
+
const issues = [];
|
|
192
|
+
|
|
193
|
+
// Check for orphan surfaces (no associations)
|
|
194
|
+
for (const id of this.#surfaces.keys()) {
|
|
195
|
+
const hasAssoc = this.#associations.some(a => a.from === id || a.to === id);
|
|
196
|
+
if (!hasAssoc && this.#surfaces.size > 1) {
|
|
197
|
+
issues.push({ severity: 'warning', message: `Surface "${id}" has no associations` });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Check for missing entry points
|
|
202
|
+
const entryPoints = [...this.#surfaces.entries()].filter(([, d]) => d.entryPoint);
|
|
203
|
+
if (entryPoints.length === 0 && this.#surfaces.size > 0) {
|
|
204
|
+
issues.push({ severity: 'warning', message: 'No surface marked as entryPoint' });
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Check depends-on has fallback
|
|
208
|
+
for (const a of this.#associations) {
|
|
209
|
+
if (a.type === 'depends-on' && !a.fallback) {
|
|
210
|
+
issues.push({ severity: 'warning', message: `depends-on from "${a.from}" to "${a.to}" has no fallback` });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Check shares-context references defined contexts
|
|
215
|
+
for (const a of this.#associations) {
|
|
216
|
+
if (a.type === 'shares-context' && a.context && !this.#sharedContexts.has(a.context)) {
|
|
217
|
+
issues.push({ severity: 'error', message: `Shared context "${a.context}" referenced but not defined` });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Check feeds associations have trigger
|
|
222
|
+
for (const a of this.#associations) {
|
|
223
|
+
if (a.type === 'feeds' && !a.trigger) {
|
|
224
|
+
issues.push({ severity: 'warning', message: `feeds from "${a.from}" to "${a.to}" has no trigger` });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Check routes-to targets have routes
|
|
229
|
+
for (const a of this.#associations) {
|
|
230
|
+
if (a.type === 'routes-to') {
|
|
231
|
+
const target = this.#surfaces.get(a.to);
|
|
232
|
+
if (target && !target.route) {
|
|
233
|
+
issues.push({ severity: 'error', message: `routes-to target "${a.to}" has no route defined` });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
valid: !issues.some(i => i.severity === 'error'),
|
|
240
|
+
issues,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ── Serialization ──
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Export as a JSON-serializable object.
|
|
248
|
+
* @returns {object}
|
|
249
|
+
*/
|
|
250
|
+
toJSON() {
|
|
251
|
+
return {
|
|
252
|
+
$schema: 'https://a2ui.dev/schema/relationships/v1',
|
|
253
|
+
id: this.#id,
|
|
254
|
+
name: this.#name,
|
|
255
|
+
version: this.#version,
|
|
256
|
+
surfaces: Object.fromEntries(this.#surfaces),
|
|
257
|
+
associations: [...this.#associations],
|
|
258
|
+
sharedContexts: Object.fromEntries(this.#sharedContexts),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Import from a JSON object.
|
|
264
|
+
* @param {object} json
|
|
265
|
+
* @returns {SurfaceManifest}
|
|
266
|
+
*/
|
|
267
|
+
static fromJSON(json) {
|
|
268
|
+
const manifest = new SurfaceManifest({
|
|
269
|
+
id: json.id,
|
|
270
|
+
name: json.name,
|
|
271
|
+
version: json.version,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
if (json.surfaces) {
|
|
275
|
+
for (const [id, desc] of Object.entries(json.surfaces)) {
|
|
276
|
+
manifest.addSurface(id, desc);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (json.sharedContexts) {
|
|
281
|
+
for (const [name, config] of Object.entries(json.sharedContexts)) {
|
|
282
|
+
manifest.defineSharedContext(name, config);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (json.associations) {
|
|
287
|
+
for (const assoc of json.associations) {
|
|
288
|
+
manifest.addAssociation(assoc);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return manifest;
|
|
293
|
+
}
|
|
294
|
+
}
|