@diegopluna/narvi 0.1.0 → 0.3.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 +102 -41
- package/dist/base.css +2 -2
- package/dist/color.d.ts +2 -2
- package/dist/color.js +1 -1
- package/dist/components/activity/ActivityContent.svelte +5 -17
- package/dist/components/activity/ActivityContent.svelte.d.ts +2 -2
- package/dist/components/activity/ActivityRoot.svelte +5 -5
- package/dist/components/activity/ActivityRoot.svelte.d.ts +5 -5
- package/dist/components/activity/ActivityStep.svelte +21 -21
- package/dist/components/activity/ActivityStep.svelte.d.ts +9 -9
- package/dist/components/activity/ActivityThought.svelte +7 -7
- package/dist/components/activity/ActivityThought.svelte.d.ts +3 -3
- package/dist/components/activity/ActivityTrigger.svelte +8 -8
- package/dist/components/activity/ActivityTrigger.svelte.d.ts +5 -5
- package/dist/components/announcer/Announcer.svelte +5 -18
- package/dist/components/announcer/Announcer.svelte.d.ts +3 -3
- package/dist/components/app-shell/AppShellBar.svelte +89 -0
- package/dist/components/app-shell/AppShellBar.svelte.d.ts +20 -0
- package/dist/components/app-shell/AppShellHeader.svelte +20 -19
- package/dist/components/app-shell/AppShellHeader.svelte.d.ts +5 -5
- package/dist/components/app-shell/AppShellMain.svelte +6 -22
- package/dist/components/app-shell/AppShellMain.svelte.d.ts +2 -2
- package/dist/components/app-shell/AppShellPanel.svelte +27 -25
- package/dist/components/app-shell/AppShellPanel.svelte.d.ts +6 -6
- package/dist/components/app-shell/AppShellPanes.svelte +58 -0
- package/dist/components/app-shell/AppShellPanes.svelte.d.ts +11 -0
- package/dist/components/app-shell/AppShellRail.svelte +85 -0
- package/dist/components/app-shell/AppShellRail.svelte.d.ts +11 -0
- package/dist/components/app-shell/AppShellRoot.svelte +58 -32
- package/dist/components/app-shell/AppShellRoot.svelte.d.ts +16 -14
- package/dist/components/app-shell/AppShellSheet.svelte +95 -0
- package/dist/components/app-shell/AppShellSheet.svelte.d.ts +17 -0
- package/dist/components/app-shell/AppShellSidebar.svelte +40 -64
- package/dist/components/app-shell/AppShellSidebar.svelte.d.ts +4 -8
- package/dist/components/app-shell/AppShellToggle.svelte +66 -26
- package/dist/components/app-shell/AppShellToggle.svelte.d.ts +5 -3
- package/dist/components/app-shell/context.d.ts +6 -0
- package/dist/components/app-shell/index.d.ts +9 -1
- package/dist/components/app-shell/index.js +5 -1
- package/dist/components/approval/Approval.svelte +101 -29
- package/dist/components/approval/Approval.svelte.d.ts +17 -10
- package/dist/components/avatar/AvatarFallback.svelte +4 -4
- package/dist/components/avatar/AvatarFallback.svelte.d.ts +2 -2
- package/dist/components/avatar/AvatarImage.svelte +3 -3
- package/dist/components/avatar/AvatarImage.svelte.d.ts +3 -3
- package/dist/components/avatar/AvatarRoot.svelte +7 -7
- package/dist/components/avatar/AvatarRoot.svelte.d.ts +5 -5
- package/dist/components/badge/Badge.svelte +26 -11
- package/dist/components/badge/Badge.svelte.d.ts +8 -5
- package/dist/components/button/Button.svelte +263 -53
- package/dist/components/button/Button.svelte.d.ts +53 -11
- package/dist/components/card/Card.svelte +21 -32
- package/dist/components/card/Card.svelte.d.ts +6 -6
- package/dist/components/change-stats/ChangeStats.svelte +5 -6
- package/dist/components/change-stats/ChangeStats.svelte.d.ts +4 -4
- package/dist/components/changes-summary/ChangesSummary.svelte +20 -21
- package/dist/components/changes-summary/ChangesSummary.svelte.d.ts +6 -6
- package/dist/components/checkbox/Checkbox.svelte +37 -23
- package/dist/components/checkbox/Checkbox.svelte.d.ts +14 -7
- package/dist/components/choice-cards/ChoiceCards.svelte +145 -0
- package/dist/components/choice-cards/ChoiceCards.svelte.d.ts +29 -0
- package/dist/components/code/Code.svelte +3 -4
- package/dist/components/code/Code.svelte.d.ts +2 -2
- package/dist/components/collapsible/CollapsibleContent.svelte +8 -8
- package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +10 -5
- package/dist/components/collapsible/CollapsibleRoot.svelte +8 -5
- package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +10 -5
- package/dist/components/collapsible/CollapsibleTrigger.svelte +19 -10
- package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +20 -7
- package/dist/components/command/CommandDialog.svelte +3 -3
- package/dist/components/command/CommandDialog.svelte.d.ts +3 -3
- package/dist/components/command/CommandEmpty.svelte +8 -5
- package/dist/components/command/CommandEmpty.svelte.d.ts +10 -5
- package/dist/components/command/CommandFooter.svelte +2 -2
- package/dist/components/command/CommandFooter.svelte.d.ts +2 -2
- package/dist/components/command/CommandGroup.svelte +9 -6
- package/dist/components/command/CommandGroup.svelte.d.ts +12 -6
- package/dist/components/command/CommandInput.svelte +4 -1
- package/dist/components/command/CommandInput.svelte.d.ts +7 -4
- package/dist/components/command/CommandItem.svelte +15 -12
- package/dist/components/command/CommandItem.svelte.d.ts +18 -8
- package/dist/components/command/CommandList.svelte +7 -4
- package/dist/components/command/CommandList.svelte.d.ts +9 -5
- package/dist/components/command/CommandRoot.svelte +8 -5
- package/dist/components/command/CommandRoot.svelte.d.ts +10 -5
- package/dist/components/command/index.d.ts +3 -2
- package/dist/components/command/index.js +3 -2
- package/dist/components/command/styles.d.ts +3 -2
- package/dist/components/command/styles.js +13 -10
- package/dist/components/composer/ComposerAttachButton.svelte +5 -5
- package/dist/components/composer/ComposerAttachButton.svelte.d.ts +4 -4
- package/dist/components/composer/ComposerAttachment.svelte +11 -14
- package/dist/components/composer/ComposerAttachment.svelte.d.ts +2 -2
- package/dist/components/composer/ComposerAttachments.svelte +3 -3
- package/dist/components/composer/ComposerAttachments.svelte.d.ts +3 -3
- package/dist/components/composer/ComposerModelPicker.svelte +27 -29
- package/dist/components/composer/ComposerModelPicker.svelte.d.ts +9 -9
- package/dist/components/composer/ComposerRoot.svelte +26 -32
- package/dist/components/composer/ComposerRoot.svelte.d.ts +15 -15
- package/dist/components/composer/ComposerSubmit.svelte +14 -20
- package/dist/components/composer/ComposerSubmit.svelte.d.ts +4 -4
- package/dist/components/composer/ComposerTextarea.svelte +4 -4
- package/dist/components/composer/ComposerTextarea.svelte.d.ts +3 -3
- package/dist/components/composer/ComposerToggle.svelte +13 -15
- package/dist/components/composer/ComposerToggle.svelte.d.ts +4 -4
- package/dist/components/composer/ComposerToolbar.svelte +2 -2
- package/dist/components/composer/ComposerToolbar.svelte.d.ts +2 -2
- package/dist/components/composer/ComposerTray.svelte +78 -0
- package/dist/components/composer/ComposerTray.svelte.d.ts +15 -0
- package/dist/components/composer/index.d.ts +3 -1
- package/dist/components/composer/index.js +3 -2
- package/dist/components/conversation/ConversationContent.svelte +7 -6
- package/dist/components/conversation/ConversationContent.svelte.d.ts +4 -4
- package/dist/components/conversation/ConversationEmpty.svelte +6 -6
- package/dist/components/conversation/ConversationEmpty.svelte.d.ts +5 -5
- package/dist/components/conversation/ConversationRoot.svelte +4 -4
- package/dist/components/conversation/ConversationRoot.svelte.d.ts +4 -4
- package/dist/components/conversation/ConversationScrollButton.svelte +7 -7
- package/dist/components/conversation/ConversationScrollButton.svelte.d.ts +4 -4
- package/dist/components/dialog/ConfirmDialog.svelte +47 -16
- package/dist/components/dialog/ConfirmDialog.svelte.d.ts +14 -9
- package/dist/components/dialog/DialogBody.svelte +12 -4
- package/dist/components/dialog/DialogBody.svelte.d.ts +5 -3
- package/dist/components/dialog/DialogContent.svelte +16 -11
- package/dist/components/dialog/DialogContent.svelte.d.ts +21 -9
- package/dist/components/dialog/DialogDescription.svelte +7 -4
- package/dist/components/dialog/DialogDescription.svelte.d.ts +9 -5
- package/dist/components/dialog/DialogFooter.svelte +2 -2
- package/dist/components/dialog/DialogFooter.svelte.d.ts +2 -2
- package/dist/components/dialog/DialogHeader.svelte +2 -2
- package/dist/components/dialog/DialogHeader.svelte.d.ts +2 -2
- package/dist/components/dialog/DialogTitle.svelte +7 -4
- package/dist/components/dialog/DialogTitle.svelte.d.ts +9 -5
- package/dist/components/dialog/index.d.ts +5 -4
- package/dist/components/dialog/index.js +4 -3
- package/dist/components/dialog/styles.d.ts +8 -3
- package/dist/components/dialog/styles.js +11 -7
- package/dist/components/divider/Divider.svelte +6 -6
- package/dist/components/divider/Divider.svelte.d.ts +3 -3
- package/dist/components/empty-state/EmptyState.svelte +14 -10
- package/dist/components/empty-state/EmptyState.svelte.d.ts +5 -4
- package/dist/components/field/Field.svelte +92 -31
- package/dist/components/field/Field.svelte.d.ts +24 -11
- package/dist/components/field/context.d.ts +6 -3
- package/dist/components/frame/Frame.svelte +12 -13
- package/dist/components/frame/Frame.svelte.d.ts +7 -7
- package/dist/components/grid/Grid.svelte +17 -6
- package/dist/components/grid/Grid.svelte.d.ts +6 -6
- package/dist/components/heading/Heading.svelte +31 -8
- package/dist/components/heading/Heading.svelte.d.ts +6 -4
- package/dist/components/hover-card/HoverCardContent.svelte +7 -4
- package/dist/components/hover-card/HoverCardContent.svelte.d.ts +9 -5
- package/dist/components/hover-card/HoverCardRoot.svelte +2 -1
- package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +3 -2
- package/dist/components/hover-card/index.d.ts +2 -1
- package/dist/components/hover-card/index.js +2 -1
- package/dist/components/input/Input.svelte +63 -17
- package/dist/components/input/Input.svelte.d.ts +12 -5
- package/dist/components/kbd/Kbd.svelte +14 -9
- package/dist/components/kbd/Kbd.svelte.d.ts +2 -2
- package/dist/components/link/Link.svelte +12 -8
- package/dist/components/link/Link.svelte.d.ts +9 -6
- package/dist/components/list/ListItem.svelte +41 -0
- package/dist/components/list/ListItem.svelte.d.ts +10 -0
- package/dist/components/list/ListRoot.svelte +69 -0
- package/dist/components/list/ListRoot.svelte.d.ts +28 -0
- package/dist/components/list/context.d.ts +5 -0
- package/dist/components/list/context.js +8 -0
- package/dist/components/list/index.d.ts +5 -0
- package/dist/components/list/index.js +3 -0
- package/dist/components/markdown/Markdown.svelte +714 -0
- package/dist/components/markdown/Markdown.svelte.d.ts +80 -0
- package/dist/components/markdown/MarkdownBlock.svelte +231 -0
- package/dist/components/markdown/MarkdownBlock.svelte.d.ts +11 -0
- package/dist/components/markdown/MarkdownBlocks.svelte +115 -0
- package/dist/components/markdown/MarkdownBlocks.svelte.d.ts +15 -0
- package/dist/components/markdown/MarkdownCode.svelte +583 -0
- package/dist/components/markdown/MarkdownCode.svelte.d.ts +23 -0
- package/dist/components/markdown/MarkdownDiagram.svelte +310 -0
- package/dist/components/markdown/MarkdownDiagram.svelte.d.ts +6 -0
- package/dist/components/markdown/MarkdownFile.svelte +136 -0
- package/dist/components/markdown/MarkdownFile.svelte.d.ts +19 -0
- package/dist/components/markdown/MarkdownFootnotes.svelte +62 -0
- package/dist/components/markdown/MarkdownFootnotes.svelte.d.ts +8 -0
- package/dist/components/markdown/MarkdownFresh.svelte +69 -0
- package/dist/components/markdown/MarkdownFresh.svelte.d.ts +6 -0
- package/dist/components/markdown/MarkdownHtml.svelte +72 -0
- package/dist/components/markdown/MarkdownHtml.svelte.d.ts +7 -0
- package/dist/components/markdown/MarkdownImage.svelte +150 -0
- package/dist/components/markdown/MarkdownImage.svelte.d.ts +8 -0
- package/dist/components/markdown/MarkdownInlines.svelte +225 -0
- package/dist/components/markdown/MarkdownInlines.svelte.d.ts +7 -0
- package/dist/components/markdown/MarkdownLink.svelte +120 -0
- package/dist/components/markdown/MarkdownLink.svelte.d.ts +25 -0
- package/dist/components/markdown/MarkdownMath.svelte +138 -0
- package/dist/components/markdown/MarkdownMath.svelte.d.ts +7 -0
- package/dist/components/markdown/MarkdownTable.svelte +258 -0
- package/dist/components/markdown/MarkdownTable.svelte.d.ts +17 -0
- package/dist/components/markdown/caret.d.ts +14 -0
- package/dist/components/markdown/caret.js +67 -0
- package/dist/components/markdown/context.d.ts +93 -0
- package/dist/components/markdown/context.js +128 -0
- package/dist/components/markdown/copy.d.ts +13 -0
- package/dist/components/markdown/copy.js +74 -0
- package/dist/components/markdown/hidden.d.ts +12 -0
- package/dist/components/markdown/hidden.js +31 -0
- package/dist/components/markdown/kept.d.ts +32 -0
- package/dist/components/markdown/kept.js +71 -0
- package/dist/components/markdown/labels.d.ts +46 -0
- package/dist/components/markdown/labels.js +35 -0
- package/dist/components/markdown/save.d.ts +11 -0
- package/dist/components/markdown/save.js +58 -0
- package/dist/components/markdown/scrollable.d.ts +24 -0
- package/dist/components/markdown/scrollable.js +152 -0
- package/dist/components/markdown/static.d.ts +37 -0
- package/dist/components/markdown/static.js +233 -0
- package/dist/components/markdown/styles.d.ts +320 -0
- package/dist/components/markdown/styles.js +294 -0
- package/dist/components/menu/ContextMenuContent.svelte +8 -5
- package/dist/components/menu/ContextMenuContent.svelte.d.ts +10 -5
- package/dist/components/menu/ContextMenuTrigger.svelte +8 -5
- package/dist/components/menu/ContextMenuTrigger.svelte.d.ts +10 -5
- package/dist/components/menu/MenuCheckboxItem.svelte +8 -5
- package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +11 -6
- package/dist/components/menu/MenuContent.svelte +7 -4
- package/dist/components/menu/MenuContent.svelte.d.ts +9 -5
- package/dist/components/menu/MenuItem.svelte +14 -11
- package/dist/components/menu/MenuItem.svelte.d.ts +18 -8
- package/dist/components/menu/MenuLabel.svelte +7 -4
- package/dist/components/menu/MenuLabel.svelte.d.ts +9 -5
- package/dist/components/menu/MenuRadioItem.svelte +26 -11
- package/dist/components/menu/MenuRadioItem.svelte.d.ts +20 -6
- package/dist/components/menu/MenuSeparator.svelte +6 -3
- package/dist/components/menu/MenuSeparator.svelte.d.ts +7 -4
- package/dist/components/menu/MenuSubContent.svelte +7 -4
- package/dist/components/menu/MenuSubContent.svelte.d.ts +9 -5
- package/dist/components/menu/MenuSubTrigger.svelte +9 -6
- package/dist/components/menu/MenuSubTrigger.svelte.d.ts +11 -6
- package/dist/components/menu/context-menu.d.ts +3 -1
- package/dist/components/menu/context-menu.js +2 -1
- package/dist/components/menu/index.d.ts +24 -0
- package/dist/components/menu/index.js +9 -6
- package/dist/components/message/MessageAction.svelte +26 -6
- package/dist/components/message/MessageAction.svelte.d.ts +13 -4
- package/dist/components/message/MessageActions.svelte +4 -4
- package/dist/components/message/MessageActions.svelte.d.ts +4 -4
- package/dist/components/message/MessageContent.svelte +5 -6
- package/dist/components/message/MessageContent.svelte.d.ts +3 -3
- package/dist/components/message/MessageCopy.svelte +74 -18
- package/dist/components/message/MessageCopy.svelte.d.ts +22 -6
- package/dist/components/message/MessageHeader.svelte +6 -6
- package/dist/components/message/MessageHeader.svelte.d.ts +3 -3
- package/dist/components/message/MessagePending.svelte +3 -3
- package/dist/components/message/MessagePending.svelte.d.ts +2 -2
- package/dist/components/message/MessageRoot.svelte +5 -5
- package/dist/components/message/MessageRoot.svelte.d.ts +5 -5
- package/dist/components/message/MessageTime.svelte +4 -4
- package/dist/components/message/MessageTime.svelte.d.ts +3 -3
- package/dist/components/notice/Notice.svelte +59 -19
- package/dist/components/notice/Notice.svelte.d.ts +13 -8
- package/dist/components/plan/Plan.svelte +28 -30
- package/dist/components/plan/Plan.svelte.d.ts +5 -5
- package/dist/components/popover/PopoverContent.svelte +7 -4
- package/dist/components/popover/PopoverContent.svelte.d.ts +9 -5
- package/dist/components/popover/index.d.ts +4 -3
- package/dist/components/popover/index.js +4 -3
- package/dist/components/progress/Progress.svelte +34 -36
- package/dist/components/progress/Progress.svelte.d.ts +3 -3
- package/dist/components/questionnaire/Questionnaire.svelte +36 -33
- package/dist/components/questionnaire/Questionnaire.svelte.d.ts +11 -11
- package/dist/components/queued-message/QueuedMessage.svelte +24 -17
- package/dist/components/queued-message/QueuedMessage.svelte.d.ts +10 -10
- package/dist/components/rail/RailItem.svelte +49 -53
- package/dist/components/rail/RailItem.svelte.d.ts +11 -9
- package/dist/components/rail/RailRoot.svelte +20 -6
- package/dist/components/rail/RailRoot.svelte.d.ts +3 -3
- package/dist/components/rail/RailSeparator.svelte +17 -0
- package/dist/components/rail/RailSeparator.svelte.d.ts +18 -0
- package/dist/components/rail/index.d.ts +2 -1
- package/dist/components/rail/index.js +2 -1
- package/dist/components/reasoning/ReasoningContent.svelte +6 -10
- package/dist/components/reasoning/ReasoningContent.svelte.d.ts +2 -2
- package/dist/components/reasoning/ReasoningRoot.svelte +6 -6
- package/dist/components/reasoning/ReasoningRoot.svelte.d.ts +6 -6
- package/dist/components/reasoning/ReasoningTrigger.svelte +5 -5
- package/dist/components/reasoning/ReasoningTrigger.svelte.d.ts +3 -3
- package/dist/components/resize-handle/ResizeHandle.svelte +12 -13
- package/dist/components/resize-handle/ResizeHandle.svelte.d.ts +10 -10
- package/dist/components/reveal/Reveal.svelte +16 -10
- package/dist/components/reveal/Reveal.svelte.d.ts +4 -4
- package/dist/components/reveal/revealed.js +13 -9
- package/dist/components/rolling-text/RollingText.svelte +3 -3
- package/dist/components/rolling-text/RollingText.svelte.d.ts +3 -3
- package/dist/components/search-button/SearchButton.svelte +92 -0
- package/dist/components/search-button/SearchButton.svelte.d.ts +13 -0
- package/dist/components/segmented/SegmentedControl.svelte +78 -32
- package/dist/components/segmented/SegmentedControl.svelte.d.ts +14 -5
- package/dist/components/select/Select.svelte +40 -15
- package/dist/components/select/Select.svelte.d.ts +21 -13
- package/dist/components/separator/Separator.svelte +4 -4
- package/dist/components/separator/Separator.svelte.d.ts +3 -3
- package/dist/components/settings-group/SettingsGroup.svelte +118 -0
- package/dist/components/settings-group/SettingsGroup.svelte.d.ts +19 -0
- package/dist/components/settings-group/context.d.ts +7 -0
- package/dist/components/settings-group/context.js +9 -0
- package/dist/components/settings-row/SettingsRow.svelte +185 -57
- package/dist/components/settings-row/SettingsRow.svelte.d.ts +39 -14
- package/dist/components/sheet/SheetContent.svelte +31 -11
- package/dist/components/sheet/SheetContent.svelte.d.ts +33 -9
- package/dist/components/sheet/index.d.ts +5 -4
- package/dist/components/sheet/index.js +4 -3
- package/dist/components/sheet/styles.d.ts +6 -0
- package/dist/components/sheet/styles.js +2 -0
- package/dist/components/shimmer/Shimmer.svelte +37 -24
- package/dist/components/shimmer/Shimmer.svelte.d.ts +3 -3
- package/dist/components/sidebar/SidebarContent.svelte +4 -4
- package/dist/components/sidebar/SidebarContent.svelte.d.ts +3 -3
- package/dist/components/sidebar/SidebarFolder.svelte +147 -0
- package/dist/components/sidebar/SidebarFolder.svelte.d.ts +19 -0
- package/dist/components/sidebar/SidebarFooter.svelte +3 -3
- package/dist/components/sidebar/SidebarFooter.svelte.d.ts +2 -2
- package/dist/components/sidebar/SidebarGroup.svelte +41 -37
- package/dist/components/sidebar/SidebarGroup.svelte.d.ts +8 -8
- package/dist/components/sidebar/SidebarHeader.svelte +15 -9
- package/dist/components/sidebar/SidebarHeader.svelte.d.ts +7 -4
- package/dist/components/sidebar/SidebarItem.svelte +64 -45
- package/dist/components/sidebar/SidebarItem.svelte.d.ts +15 -10
- package/dist/components/sidebar/SidebarRoot.svelte +62 -0
- package/dist/components/sidebar/SidebarRoot.svelte.d.ts +14 -0
- package/dist/components/sidebar/SidebarSwitcher.svelte +28 -0
- package/dist/components/sidebar/SidebarSwitcher.svelte.d.ts +11 -0
- package/dist/components/sidebar/depth.d.ts +8 -0
- package/dist/components/sidebar/depth.js +14 -0
- package/dist/components/sidebar/index.d.ts +7 -1
- package/dist/components/sidebar/index.js +4 -1
- package/dist/components/skeleton/Skeleton.svelte +31 -20
- package/dist/components/skeleton/Skeleton.svelte.d.ts +5 -5
- package/dist/components/slider/Slider.svelte +24 -23
- package/dist/components/slider/Slider.svelte.d.ts +13 -13
- package/dist/components/spinner/Spinner.svelte +8 -14
- package/dist/components/spinner/Spinner.svelte.d.ts +3 -3
- package/dist/components/stack/Stack.svelte +19 -8
- package/dist/components/stack/Stack.svelte.d.ts +8 -8
- package/dist/components/status-indicator/StatusIndicator.svelte +6 -5
- package/dist/components/status-indicator/StatusIndicator.svelte.d.ts +4 -4
- package/dist/components/suggestions/SuggestionsItem.svelte +8 -8
- package/dist/components/suggestions/SuggestionsItem.svelte.d.ts +3 -3
- package/dist/components/suggestions/SuggestionsRoot.svelte +5 -5
- package/dist/components/suggestions/SuggestionsRoot.svelte.d.ts +5 -5
- package/dist/components/switch/Switch.svelte +27 -21
- package/dist/components/switch/Switch.svelte.d.ts +8 -6
- package/dist/components/tab-strip/TabStrip.svelte +421 -0
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +31 -0
- package/dist/components/tabs/Tabs.svelte +83 -33
- package/dist/components/tabs/Tabs.svelte.d.ts +15 -5
- package/dist/components/text/Text.svelte +63 -31
- package/dist/components/text/Text.svelte.d.ts +18 -12
- package/dist/components/textarea/Textarea.svelte +5 -5
- package/dist/components/textarea/Textarea.svelte.d.ts +5 -5
- package/dist/components/theme/Theme.svelte +4 -4
- package/dist/components/theme/Theme.svelte.d.ts +4 -4
- package/dist/components/toast/Toaster.svelte +39 -32
- package/dist/components/toast/Toaster.svelte.d.ts +2 -2
- package/dist/components/toast/toasts.svelte.d.ts +52 -15
- package/dist/components/toast/toasts.svelte.js +45 -20
- package/dist/components/toggle/Toggle.svelte +11 -8
- package/dist/components/toggle/Toggle.svelte.d.ts +15 -7
- package/dist/components/toggle-group/ToggleGroupItem.svelte +9 -6
- package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +12 -6
- package/dist/components/toggle-group/ToggleGroupRoot.svelte +17 -14
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +13 -12
- package/dist/components/tool/ToolContent.svelte +5 -10
- package/dist/components/tool/ToolContent.svelte.d.ts +2 -2
- package/dist/components/tool/ToolInput.svelte +3 -3
- package/dist/components/tool/ToolInput.svelte.d.ts +3 -3
- package/dist/components/tool/ToolOutput.svelte +4 -4
- package/dist/components/tool/ToolOutput.svelte.d.ts +4 -4
- package/dist/components/tool/ToolRoot.svelte +7 -7
- package/dist/components/tool/ToolRoot.svelte.d.ts +7 -7
- package/dist/components/tool/ToolSection.svelte +8 -9
- package/dist/components/tool/ToolSection.svelte.d.ts +4 -4
- package/dist/components/tool/ToolTrigger.svelte +14 -13
- package/dist/components/tool/ToolTrigger.svelte.d.ts +4 -4
- package/dist/components/tooltip/TooltipContent.svelte +12 -9
- package/dist/components/tooltip/TooltipContent.svelte.d.ts +12 -6
- package/dist/components/tooltip/TooltipRoot.svelte +7 -4
- package/dist/components/tooltip/TooltipRoot.svelte.d.ts +8 -4
- package/dist/components/tooltip/TooltipTrigger.svelte +2 -1
- package/dist/components/tooltip/TooltipTrigger.svelte.d.ts +3 -2
- package/dist/components/tooltip/index.d.ts +2 -1
- package/dist/components/tooltip/index.js +2 -1
- package/dist/components/work-fold/WorkFold.svelte +9 -13
- package/dist/components/work-fold/WorkFold.svelte.d.ts +4 -4
- package/dist/index.d.ts +30 -12
- package/dist/index.js +24 -10
- package/dist/internal/Chevron.svelte +1 -1
- package/dist/internal/Chevron.svelte.d.ts +1 -1
- package/dist/internal/Code.svelte +9 -5
- package/dist/internal/Code.svelte.d.ts +3 -3
- package/dist/internal/Collapse.svelte +4 -4
- package/dist/internal/Collapse.svelte.d.ts +4 -4
- package/dist/internal/Glyph.svelte +19 -1
- package/dist/internal/Glyph.svelte.d.ts +9 -2
- package/dist/internal/Tile.svelte +22 -42
- package/dist/internal/Tile.svelte.d.ts +5 -5
- package/dist/internal/complete.d.ts +8 -0
- package/dist/internal/complete.js +1 -0
- package/dist/internal/control.d.ts +4 -4
- package/dist/internal/control.js +20 -17
- package/dist/internal/icon.d.ts +9 -0
- package/dist/internal/icon.js +1 -0
- package/dist/internal/icons.css +14 -0
- package/dist/internal/json.d.ts +1 -1
- package/dist/internal/layer.d.ts +6 -6
- package/dist/internal/layer.js +17 -14
- package/dist/internal/layout.d.ts +1 -1
- package/dist/internal/layout.js +6 -0
- package/dist/internal/loose.d.ts +22 -0
- package/dist/internal/loose.js +4 -0
- package/dist/internal/markers.stylex.d.ts +12 -0
- package/dist/internal/markers.stylex.js +6 -0
- package/dist/internal/plugin-order.d.ts +8 -0
- package/dist/internal/plugin-order.js +16 -0
- package/dist/internal/responsive.d.ts +1 -1
- package/dist/internal/roving.d.ts +1 -1
- package/dist/internal/roving.js +5 -2
- package/dist/internal/shared.d.ts +8 -1
- package/dist/internal/shared.js +21 -5
- package/dist/internal/sx.d.ts +5 -5
- package/dist/internal/toggle.d.ts +1 -2
- package/dist/internal/toggle.js +8 -12
- package/dist/internal/tooltip-trigger.d.ts +9 -0
- package/dist/internal/tooltip-trigger.js +19 -0
- package/dist/internal/visible.d.ts +32 -0
- package/dist/internal/visible.js +44 -0
- package/dist/markdown/ast.d.ts +209 -0
- package/dist/markdown/ast.js +10 -0
- package/dist/markdown/blocks.d.ts +178 -0
- package/dist/markdown/blocks.js +1489 -0
- package/dist/markdown/code-info.d.ts +10 -0
- package/dist/markdown/code-info.js +16 -0
- package/dist/markdown/common.d.ts +25 -0
- package/dist/markdown/common.js +107 -0
- package/dist/markdown/diagrams.d.ts +2 -0
- package/dist/markdown/diagrams.js +18 -0
- package/dist/markdown/file-paths.d.ts +29 -0
- package/dist/markdown/file-paths.js +80 -0
- package/dist/markdown/files.d.ts +16 -0
- package/dist/markdown/files.js +133 -0
- package/dist/markdown/highlight.d.ts +30 -0
- package/dist/markdown/highlight.js +127 -0
- package/dist/markdown/html.d.ts +14 -0
- package/dist/markdown/html.js +289 -0
- package/dist/markdown/images.d.ts +15 -0
- package/dist/markdown/images.js +45 -0
- package/dist/markdown/index.d.ts +12 -0
- package/dist/markdown/index.js +5 -0
- package/dist/markdown/inlines.d.ts +48 -0
- package/dist/markdown/inlines.js +1714 -0
- package/dist/markdown/math.d.ts +2 -0
- package/dist/markdown/math.js +22 -0
- package/dist/markdown/parse.d.ts +81 -0
- package/dist/markdown/parse.js +204 -0
- package/dist/markdown/plugin.d.ts +179 -0
- package/dist/markdown/plugin.js +160 -0
- package/dist/markdown/sanitize.d.ts +78 -0
- package/dist/markdown/sanitize.js +522 -0
- package/dist/markdown/share.d.ts +12 -0
- package/dist/markdown/share.js +59 -0
- package/dist/markdown/table.d.ts +13 -0
- package/dist/markdown/table.js +60 -0
- package/dist/markers.stylex.d.ts +13 -0
- package/dist/markers.stylex.js +11 -0
- package/dist/preset.d.ts +44 -20
- package/dist/preset.js +169 -51
- package/dist/tokens.stylex.d.ts +57 -37
- package/dist/tokens.stylex.js +113 -62
- package/dist/typography.d.ts +55 -0
- package/dist/typography.js +63 -0
- package/dist/visually-hidden.d.ts +18 -0
- package/dist/visually-hidden.js +21 -0
- package/dist/vite.d.ts +9 -3
- package/dist/vite.js +27 -2
- package/package.json +57 -6
- package/skills/building-ui/SKILL.md +385 -0
- package/skills/building-ui/references/components.md +211 -0
- package/skills/markdown/SKILL.md +452 -0
- package/skills/markdown/references/plugins.md +103 -0
- package/skills/setup/SKILL.md +199 -0
- package/skills/styling/SKILL.md +318 -0
- package/skills/theming/SKILL.md +277 -0
- package/dist/internal/loop.d.ts +0 -35
- package/dist/internal/loop.js +0 -72
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a fence's info string says beyond the language: the file the code is from.
|
|
3
|
+
*/
|
|
4
|
+
import type { CodeBlock } from './ast.js';
|
|
5
|
+
/**
|
|
6
|
+
* The title a code block gives itself: `title="src/app.ts"`, `file=…`, `filename=…`, or a
|
|
7
|
+
* first word that reads as a file name, as in ```` ```ts src/app.ts ```` and
|
|
8
|
+
* ```` ```ts:src/app.ts ````. Null when it gives none.
|
|
9
|
+
*/
|
|
10
|
+
export declare function codeTitle(node: CodeBlock): string | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const reNamed = /(?:^|\s)(?:title|file|filename|path)=(?:"([^"]*)"|'([^']*)'|(\S+))/;
|
|
2
|
+
const reFileName = /^[^\s=]*\.[A-Za-z][A-Za-z0-9]{0,9}(?::\d+(?:-\d+)?)?$/;
|
|
3
|
+
/**
|
|
4
|
+
* The title a code block gives itself: `title="src/app.ts"`, `file=…`, `filename=…`, or a
|
|
5
|
+
* first word that reads as a file name, as in ```` ```ts src/app.ts ```` and
|
|
6
|
+
* ```` ```ts:src/app.ts ````. Null when it gives none.
|
|
7
|
+
*/
|
|
8
|
+
export function codeTitle(node) {
|
|
9
|
+
if (!node.meta)
|
|
10
|
+
return null;
|
|
11
|
+
const named = reNamed.exec(node.meta);
|
|
12
|
+
if (named)
|
|
13
|
+
return named[1] ?? named[2] ?? named[3] ?? null;
|
|
14
|
+
const first = node.meta.split(/\s+/)[0];
|
|
15
|
+
return reFileName.test(first) ? first : null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const ESCAPABLE = "[!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]";
|
|
2
|
+
export declare const ENTITY = "&(?:#x[a-f0-9]{1,6}|#[0-9]{1,7}|[a-z][a-z0-9]{1,31});";
|
|
3
|
+
/** Decodes one entity, `&` or `#` or `#`. Returns the text unchanged if it is not one. */
|
|
4
|
+
export declare function decodeEntity(entity: string): string;
|
|
5
|
+
/** Replaces backslash escapes and entities with the characters they stand for. */
|
|
6
|
+
export declare function unescapeString(s: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* The form two reference labels are compared in: brackets dropped, whitespace collapsed,
|
|
9
|
+
* and Unicode case folded (lowercasing after uppercasing folds `ẞ` and `ß` together).
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeReference(label: string): string;
|
|
12
|
+
/** Percent-encodes what a URL may not hold, keeping escapes that are already there. */
|
|
13
|
+
export declare function normalizeUri(uri: string): string;
|
|
14
|
+
/** Unicode whitespace, as the spec defines it for emphasis. */
|
|
15
|
+
export declare const reUnicodeWhitespace: RegExp;
|
|
16
|
+
/** Unicode punctuation and symbols (general categories P and S), as the spec defines them. */
|
|
17
|
+
export declare const rePunctuation: RegExp;
|
|
18
|
+
/** Spaces, tabs and line endings. */
|
|
19
|
+
export declare const reSpaceOrTab: RegExp;
|
|
20
|
+
export declare const reNonSpace: RegExp;
|
|
21
|
+
/** Replaces NUL, which the spec turns into U+FFFD. */
|
|
22
|
+
export declare function replaceNul(s: string): string;
|
|
23
|
+
export declare const OPENTAG: string;
|
|
24
|
+
export declare const CLOSETAG: string;
|
|
25
|
+
export declare const reHtmlTag: RegExp;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers the block and inline parsers share: escapes, entities, reference labels and URLs.
|
|
3
|
+
*/
|
|
4
|
+
import { decodeNamedCharacterReference } from 'decode-named-character-reference';
|
|
5
|
+
export const ESCAPABLE = '[!"#$%&\'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]';
|
|
6
|
+
export const ENTITY = '&(?:#x[a-f0-9]{1,6}|#[0-9]{1,7}|[a-z][a-z0-9]{1,31});';
|
|
7
|
+
const reBackslashOrAmp = /[\\&]/;
|
|
8
|
+
const reEntityOrEscapedChar = new RegExp('\\\\' + ESCAPABLE + '|' + ENTITY, 'gi');
|
|
9
|
+
/** Decodes one entity, `&` or `#` or `#`. Returns the text unchanged if it is not one. */
|
|
10
|
+
export function decodeEntity(entity) {
|
|
11
|
+
if (entity.charCodeAt(1) === 35 /* # */) {
|
|
12
|
+
const hex = entity.charCodeAt(2) === 120 || entity.charCodeAt(2) === 88; /* x X */
|
|
13
|
+
const code = parseInt(entity.slice(hex ? 3 : 2, -1), hex ? 16 : 10);
|
|
14
|
+
// NUL, surrogates and anything past the last code point are replaced
|
|
15
|
+
if (code === 0 || code > 0x10ffff || (code >= 0xd800 && code <= 0xdfff))
|
|
16
|
+
return '�';
|
|
17
|
+
return String.fromCodePoint(code);
|
|
18
|
+
}
|
|
19
|
+
const decoded = decodeNamedCharacterReference(entity.slice(1, -1));
|
|
20
|
+
return decoded === false ? entity : decoded;
|
|
21
|
+
}
|
|
22
|
+
/** Replaces backslash escapes and entities with the characters they stand for. */
|
|
23
|
+
export function unescapeString(s) {
|
|
24
|
+
if (!reBackslashOrAmp.test(s))
|
|
25
|
+
return s;
|
|
26
|
+
return s.replace(reEntityOrEscapedChar, (m) => m.charCodeAt(0) === 92 ? m[1] : decodeEntity(m));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The form two reference labels are compared in: brackets dropped, whitespace collapsed,
|
|
30
|
+
* and Unicode case folded (lowercasing after uppercasing folds `ẞ` and `ß` together).
|
|
31
|
+
*/
|
|
32
|
+
export function normalizeReference(label) {
|
|
33
|
+
return label
|
|
34
|
+
.slice(1, -1)
|
|
35
|
+
.trim()
|
|
36
|
+
.replace(/[ \t\r\n]+/g, ' ')
|
|
37
|
+
.toLowerCase()
|
|
38
|
+
.toUpperCase();
|
|
39
|
+
}
|
|
40
|
+
const reSafeUrl = /[A-Za-z0-9;/?:@&=+$,\-_.!~*'()#]/;
|
|
41
|
+
const reHex = /^[0-9a-fA-F]{2}$/;
|
|
42
|
+
/** Percent-encodes what a URL may not hold, keeping escapes that are already there. */
|
|
43
|
+
export function normalizeUri(uri) {
|
|
44
|
+
let out = '';
|
|
45
|
+
for (let i = 0; i < uri.length; i++) {
|
|
46
|
+
const ch = uri[i];
|
|
47
|
+
if (reSafeUrl.test(ch)) {
|
|
48
|
+
out += ch;
|
|
49
|
+
}
|
|
50
|
+
else if (ch === '%' && reHex.test(uri.slice(i + 1, i + 3))) {
|
|
51
|
+
out += uri.slice(i, i + 3);
|
|
52
|
+
i += 2;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const code = uri.codePointAt(i);
|
|
56
|
+
const char = String.fromCodePoint(code);
|
|
57
|
+
if (code >= 0xd800 && code <= 0xdfff) {
|
|
58
|
+
out += '%EF%BF%BD';
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
out += encodeURIComponent(char);
|
|
62
|
+
}
|
|
63
|
+
i += char.length - 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/** Unicode whitespace, as the spec defines it for emphasis. */
|
|
69
|
+
export const reUnicodeWhitespace = /^\s/u;
|
|
70
|
+
/** Unicode punctuation and symbols (general categories P and S), as the spec defines them. */
|
|
71
|
+
export const rePunctuation = /^[\p{P}\p{S}]/u;
|
|
72
|
+
/** Spaces, tabs and line endings. */
|
|
73
|
+
export const reSpaceOrTab = /[ \t]/;
|
|
74
|
+
export const reNonSpace = /[^ \t\f\v\r\n]/;
|
|
75
|
+
/** Replaces NUL, which the spec turns into U+FFFD. */
|
|
76
|
+
export function replaceNul(s) {
|
|
77
|
+
return s.includes('\0') ? s.replace(/\0/g, '�') : s;
|
|
78
|
+
}
|
|
79
|
+
// Raw HTML, as the inline parser and the HTML blocks recognise it
|
|
80
|
+
const TAGNAME = '[A-Za-z][A-Za-z0-9-]*';
|
|
81
|
+
const ATTRIBUTENAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
|
|
82
|
+
const UNQUOTEDVALUE = '[^"\'=<>`\\x00-\\x20]+';
|
|
83
|
+
const SINGLEQUOTEDVALUE = "'[^']*'";
|
|
84
|
+
const DOUBLEQUOTEDVALUE = '"[^"]*"';
|
|
85
|
+
const ATTRIBUTEVALUE = '(?:' + UNQUOTEDVALUE + '|' + SINGLEQUOTEDVALUE + '|' + DOUBLEQUOTEDVALUE + ')';
|
|
86
|
+
const ATTRIBUTEVALUESPEC = '(?:\\s*=\\s*' + ATTRIBUTEVALUE + ')';
|
|
87
|
+
const ATTRIBUTE = '(?:\\s+' + ATTRIBUTENAME + ATTRIBUTEVALUESPEC + '?)';
|
|
88
|
+
export const OPENTAG = '<' + TAGNAME + ATTRIBUTE + '*\\s*/?>';
|
|
89
|
+
export const CLOSETAG = '</' + TAGNAME + '\\s*[>]';
|
|
90
|
+
const HTMLCOMMENT = '<!-->|<!--->|<!--[\\s\\S]*?-->';
|
|
91
|
+
const PROCESSINGINSTRUCTION = '[<][?][\\s\\S]*?[?][>]';
|
|
92
|
+
const DECLARATION = '<![A-Za-z][^>]*>';
|
|
93
|
+
const CDATA = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>';
|
|
94
|
+
const HTMLTAG = '(?:' +
|
|
95
|
+
OPENTAG +
|
|
96
|
+
'|' +
|
|
97
|
+
CLOSETAG +
|
|
98
|
+
'|' +
|
|
99
|
+
HTMLCOMMENT +
|
|
100
|
+
'|' +
|
|
101
|
+
PROCESSINGINSTRUCTION +
|
|
102
|
+
'|' +
|
|
103
|
+
DECLARATION +
|
|
104
|
+
'|' +
|
|
105
|
+
CDATA +
|
|
106
|
+
')';
|
|
107
|
+
export const reHtmlTag = new RegExp('^' + HTMLTAG);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagrams for Narvi's Markdown: a fenced code block in the language `mermaid` is drawn as a
|
|
3
|
+
* diagram, by Pele, which reads Mermaid's syntax and draws SVG in Narvi's colours.
|
|
4
|
+
*
|
|
5
|
+
* import { diagrams } from '@diegopluna/narvi/markdown/diagrams';
|
|
6
|
+
* <Markdown value={text} plugins={[diagrams()]} />
|
|
7
|
+
*
|
|
8
|
+
* Pele loads the first time a diagram is shown, and each kind of diagram on first use. A
|
|
9
|
+
* diagram is drawn once its fence has closed; until then it shows as code.
|
|
10
|
+
*/
|
|
11
|
+
import MarkdownDiagram from '../components/markdown/MarkdownDiagram.svelte';
|
|
12
|
+
import { withProps } from './plugin.js';
|
|
13
|
+
export function diagrams() {
|
|
14
|
+
return {
|
|
15
|
+
name: 'diagrams',
|
|
16
|
+
languages: { mermaid: withProps(MarkdownDiagram) }
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading file paths out of text: `src/app.ts`, `src/app.ts:42:7`, `src/app.ts#L42-L50`.
|
|
3
|
+
*/
|
|
4
|
+
/** A file, and where in it. */
|
|
5
|
+
export type FileReference = {
|
|
6
|
+
path: string;
|
|
7
|
+
line?: number | undefined;
|
|
8
|
+
column?: number | undefined;
|
|
9
|
+
endLine?: number | undefined;
|
|
10
|
+
};
|
|
11
|
+
/** Splits `src/app.ts:42:7` or `src/app.ts#L42-L50` into the path and the place in it. */
|
|
12
|
+
export declare function splitPosition(text: string): FileReference;
|
|
13
|
+
export declare const reExtension: RegExp;
|
|
14
|
+
/**
|
|
15
|
+
* Whether text reads as a path, for when no `resolve` can say. It errs towards no: "and/or",
|
|
16
|
+
* "1/2", "v1.2.3" and "github.com/owner/repo" are not paths.
|
|
17
|
+
*/
|
|
18
|
+
export declare function looksLikePath(path: string, hasPosition?: boolean): boolean;
|
|
19
|
+
export declare function basename(path: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* What a chip shows for a path: the file's name, or the whole path when it leaves the
|
|
22
|
+
* project (`../../.ssh/id_rsa`, `~/.ssh/id_rsa`), so a name alone cannot pass for a file
|
|
23
|
+
* of the project.
|
|
24
|
+
*/
|
|
25
|
+
export declare function displayName(path: string): string;
|
|
26
|
+
/** Whether some words name this path: its name, or the end of the path from a folder on. */
|
|
27
|
+
export declare function namesPath(words: string, path: string): boolean;
|
|
28
|
+
/** The place in a file, as it is written after a path: `:42`, `:42:7`, `:42-50`. */
|
|
29
|
+
export declare function formatPosition(file: FileReference): string;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading file paths out of text: `src/app.ts`, `src/app.ts:42:7`, `src/app.ts#L42-L50`.
|
|
3
|
+
*/
|
|
4
|
+
// A line or column has at most seven digits: more is not a place in any file
|
|
5
|
+
const rePosition = /(?::(\d{1,7})(?::(\d{1,7}))?(?:-(\d{1,7}))?|#L(\d{1,7})(?:C(\d{1,7}))?(?:-L?(\d{1,7}))?)$/;
|
|
6
|
+
/** Splits `src/app.ts:42:7` or `src/app.ts#L42-L50` into the path and the place in it. */
|
|
7
|
+
export function splitPosition(text) {
|
|
8
|
+
const m = rePosition.exec(text);
|
|
9
|
+
if (!m)
|
|
10
|
+
return { path: text };
|
|
11
|
+
const number = (value) => (value ? Number(value) : undefined);
|
|
12
|
+
const file = { path: text.slice(0, m.index) };
|
|
13
|
+
const line = number(m[1] ?? m[4]);
|
|
14
|
+
const column = number(m[2] ?? m[5]);
|
|
15
|
+
const endLine = number(m[3] ?? m[6]);
|
|
16
|
+
if (line !== undefined)
|
|
17
|
+
file.line = line;
|
|
18
|
+
if (column !== undefined)
|
|
19
|
+
file.column = column;
|
|
20
|
+
if (endLine !== undefined)
|
|
21
|
+
file.endLine = endLine;
|
|
22
|
+
return file;
|
|
23
|
+
}
|
|
24
|
+
export const reExtension = /\.[A-Za-z][A-Za-z0-9]{0,9}$/;
|
|
25
|
+
const reHost = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:com|org|net|dev|io|ai|app|co|sh|run|edu|gov)$/i;
|
|
26
|
+
/**
|
|
27
|
+
* Whether text reads as a path, for when no `resolve` can say. It errs towards no: "and/or",
|
|
28
|
+
* "1/2", "v1.2.3" and "github.com/owner/repo" are not paths.
|
|
29
|
+
*/
|
|
30
|
+
export function looksLikePath(path, hasPosition = false) {
|
|
31
|
+
if (path.length === 0 || path.length > 260)
|
|
32
|
+
return false;
|
|
33
|
+
// A network share is not a file of the project
|
|
34
|
+
if (/^[\\/]{2}/.test(path))
|
|
35
|
+
return false;
|
|
36
|
+
if (/[\s<>"|?*`]/.test(path) || path.includes('://') || path.includes('...'))
|
|
37
|
+
return false;
|
|
38
|
+
const segments = path.split(/[\\/]/);
|
|
39
|
+
const base = segments[segments.length - 1];
|
|
40
|
+
const hasExtension = reExtension.test(base) && base.length > (base.match(reExtension)?.[0].length ?? 0);
|
|
41
|
+
if (segments.length === 1) {
|
|
42
|
+
// A bare name is a file only with a place in it: `app.ts:42`
|
|
43
|
+
return hasPosition && hasExtension;
|
|
44
|
+
}
|
|
45
|
+
if (reHost.test(segments[0]))
|
|
46
|
+
return false;
|
|
47
|
+
if (segments.every((segment) => /^\d*$/.test(segment)))
|
|
48
|
+
return false;
|
|
49
|
+
const rooted = /^(?:\.{1,2}|~|[A-Za-z]:)?$/.test(segments[0]);
|
|
50
|
+
// `./.env` and `/etc/hosts` name files without an extension; `src/lib` alone could be anything
|
|
51
|
+
return hasExtension || rooted || segments.length > 2;
|
|
52
|
+
}
|
|
53
|
+
export function basename(path) {
|
|
54
|
+
const trimmed = path.replace(/[\\/]+$/, '');
|
|
55
|
+
const base = trimmed.slice(Math.max(trimmed.lastIndexOf('/'), trimmed.lastIndexOf('\\')) + 1);
|
|
56
|
+
return path === trimmed ? base : base + '/';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What a chip shows for a path: the file's name, or the whole path when it leaves the
|
|
60
|
+
* project (`../../.ssh/id_rsa`, `~/.ssh/id_rsa`), so a name alone cannot pass for a file
|
|
61
|
+
* of the project.
|
|
62
|
+
*/
|
|
63
|
+
export function displayName(path) {
|
|
64
|
+
return /^~|(?:^|[\\/])\.\.(?:[\\/]|$)/.test(path) ? path : basename(path);
|
|
65
|
+
}
|
|
66
|
+
/** Whether some words name this path: its name, or the end of the path from a folder on. */
|
|
67
|
+
export function namesPath(words, path) {
|
|
68
|
+
const plain = (value) => value.replace(/\\/g, '/').replace(/^(?:\.\/)+/, '');
|
|
69
|
+
const named = plain(words);
|
|
70
|
+
const real = plain(path);
|
|
71
|
+
return named !== '' && (real === named || real.endsWith('/' + named));
|
|
72
|
+
}
|
|
73
|
+
/** The place in a file, as it is written after a path: `:42`, `:42:7`, `:42-50`. */
|
|
74
|
+
export function formatPosition(file) {
|
|
75
|
+
if (file.line === undefined)
|
|
76
|
+
return '';
|
|
77
|
+
if (file.endLine !== undefined)
|
|
78
|
+
return `:${file.line}-${file.endLine}`;
|
|
79
|
+
return file.column !== undefined ? `:${file.line}:${file.column}` : `:${file.line}`;
|
|
80
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { formatPosition, looksLikePath, splitPosition, type FileReference } from './file-paths.js';
|
|
2
|
+
import { type MarkdownPlugin } from './plugin.js';
|
|
3
|
+
export { formatPosition, looksLikePath, splitPosition, type FileReference };
|
|
4
|
+
export type FilesOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Says whether a path names a file the app knows, and returns it as the app wants it (made
|
|
7
|
+
* absolute, say), or null when it does not. With it, any inline code without spaces is
|
|
8
|
+
* asked, so a bare `package.json` can be found; without it, only text that looks like a
|
|
9
|
+
* path becomes a chip.
|
|
10
|
+
*/
|
|
11
|
+
resolve?: ((path: string) => string | null | undefined) | undefined;
|
|
12
|
+
/** Opens a file when its chip is activated. Without it, chips only show. */
|
|
13
|
+
open?: ((file: FileReference, event: MouseEvent) => void) | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** The first-party file plugin. */
|
|
16
|
+
export declare function files(options?: FilesOptions): MarkdownPlugin;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File references for Narvi's Markdown: inline code and links that name a file become chips
|
|
3
|
+
* the app can open, the way coding agents' replies are read.
|
|
4
|
+
*
|
|
5
|
+
* import { files } from '@diegopluna/narvi/markdown/files';
|
|
6
|
+
* const plugins = [files({ resolve: (path) => tree.find(path), open: (file) => editor.open(file) })];
|
|
7
|
+
*
|
|
8
|
+
* `src/app.ts`, `src/app.ts:42`, `src/app.ts:42:7`, `src/app.ts:42-50` and `src/app.ts#L42-L50`
|
|
9
|
+
* are all read, as is `[the config](src/config.ts#L10)`.
|
|
10
|
+
*/
|
|
11
|
+
import MarkdownFile, { chipFile, fileHtml } from '../components/markdown/MarkdownFile.svelte';
|
|
12
|
+
import { displayName, formatPosition, looksLikePath, namesPath, reExtension, splitPosition } from './file-paths.js';
|
|
13
|
+
import { mapInlines, withProps } from './plugin.js';
|
|
14
|
+
import { inlineText } from './table.js';
|
|
15
|
+
export { formatPosition, looksLikePath, splitPosition };
|
|
16
|
+
function decode(url) {
|
|
17
|
+
try {
|
|
18
|
+
return decodeURIComponent(url);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return url;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** The first-party file plugin. */
|
|
25
|
+
export function files(options = {}) {
|
|
26
|
+
const { resolve, open } = options;
|
|
27
|
+
/**
|
|
28
|
+
* The file some text names, or null. `certain` is for a `file:` address, which names a
|
|
29
|
+
* file whatever it looks like, spaces and all.
|
|
30
|
+
*
|
|
31
|
+
* Some paths are never files to open, whoever asks: a network share (`\\\\host\\share`,
|
|
32
|
+
* `//host/share`), which on Windows is fetched from another machine; a path with control
|
|
33
|
+
* or invisible characters in it (zero-width, direction marks), which can make a chip, its
|
|
34
|
+
* tooltip or a copy of it read as something else; and one that starts with `-`, which a
|
|
35
|
+
* command the app hands it to would read as an option.
|
|
36
|
+
*/
|
|
37
|
+
const fileOf = (text, fromLink, certain = false) => {
|
|
38
|
+
if (text.length === 0 || text.length > 300 || (!certain && /\s/.test(text)))
|
|
39
|
+
return null;
|
|
40
|
+
if (/[\p{Cc}\p{Cf}]/u.test(text) || /^[\\/]{2}/.test(text) || text.startsWith('-'))
|
|
41
|
+
return null;
|
|
42
|
+
const file = splitPosition(text);
|
|
43
|
+
if (file.path === '')
|
|
44
|
+
return null;
|
|
45
|
+
if (resolve) {
|
|
46
|
+
const path = resolve(file.path);
|
|
47
|
+
return path ? { ...file, path } : null;
|
|
48
|
+
}
|
|
49
|
+
if (certain)
|
|
50
|
+
return file;
|
|
51
|
+
const position = file.line !== undefined;
|
|
52
|
+
if (!looksLikePath(file.path, position))
|
|
53
|
+
return null;
|
|
54
|
+
// A link to `docs/intro` could be a page; one to `docs/intro.md` names a file
|
|
55
|
+
if (fromLink && !reExtension.test(file.path))
|
|
56
|
+
return null;
|
|
57
|
+
return file;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The label of a chip made from a link. A link's words can say anything, so they are kept
|
|
61
|
+
* only when they cannot be taken for another file: prose of several words with no file's
|
|
62
|
+
* name among them, or words that name this very file. Otherwise the chip shows the real
|
|
63
|
+
* name: `[package.json](file:///home/me/.ssh/id_rsa)` shows `id_rsa`, and so does
|
|
64
|
+
* `[src/safe/id_rsa](~/.ssh/id_rsa)`.
|
|
65
|
+
*/
|
|
66
|
+
const linkLabel = (children, file) => {
|
|
67
|
+
// Invisible characters could make one name read as another
|
|
68
|
+
const words = inlineText(children)
|
|
69
|
+
.replace(/[\p{Cc}\p{Cf}]/gu, '')
|
|
70
|
+
.trim();
|
|
71
|
+
const tokens = words.split(/\s+/).map((token) => token.replace(/[.,;:!?)\]]+$/, ''));
|
|
72
|
+
const readsAsFile = (token) => /[\\/]/.test(token) || reExtension.test(splitPosition(token).path);
|
|
73
|
+
const honest = tokens.length === 1
|
|
74
|
+
? namesPath(splitPosition(tokens[0]).path, file.path)
|
|
75
|
+
: tokens.every((token) => !readsAsFile(token) || namesPath(splitPosition(token).path, file.path));
|
|
76
|
+
if (honest)
|
|
77
|
+
return children;
|
|
78
|
+
return [{ type: 'text', value: displayName(file.path) + formatPosition(file) }];
|
|
79
|
+
};
|
|
80
|
+
const chip = (file, source, children, link = false) => ({
|
|
81
|
+
type: 'custom',
|
|
82
|
+
name: 'file',
|
|
83
|
+
// `link` marks a chip whose label is the words of a link, not a path
|
|
84
|
+
data: link ? { ...file, source, link } : { ...file, source },
|
|
85
|
+
children
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
name: 'files',
|
|
89
|
+
transform: (block) => mapInlines(block, (node, { inLink }) => {
|
|
90
|
+
if (node.type === 'inlineCode' && !inLink) {
|
|
91
|
+
const file = fileOf(node.value, false);
|
|
92
|
+
if (!file)
|
|
93
|
+
return null;
|
|
94
|
+
// The chip shows the file's name; the whole path is its title
|
|
95
|
+
const label = displayName(file.path) + formatPosition(file);
|
|
96
|
+
return [chip(file, node.value, [{ type: 'text', value: label }])];
|
|
97
|
+
}
|
|
98
|
+
if (node.type === 'link' && (node.kind === 'inline' || node.kind === 'reference')) {
|
|
99
|
+
const url = decode(node.url);
|
|
100
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toLowerCase();
|
|
101
|
+
// A drive letter is not a scheme
|
|
102
|
+
const windows = /^[A-Za-z]:[\\/]/.test(url);
|
|
103
|
+
if (scheme && scheme !== 'file' && !windows)
|
|
104
|
+
return null;
|
|
105
|
+
if (!scheme && !resolve && /^(?:[/#?]|$)/.test(url))
|
|
106
|
+
return null;
|
|
107
|
+
let path = url;
|
|
108
|
+
if (scheme === 'file') {
|
|
109
|
+
// `file://host/…` is a file on another machine: not one to open from here
|
|
110
|
+
const address = /^file:\/\/([^/]*)(\/.*)?$/i.exec(url);
|
|
111
|
+
if (!address || (address[1] !== '' && address[1].toLowerCase() !== 'localhost'))
|
|
112
|
+
return null;
|
|
113
|
+
path = address[2] ?? '';
|
|
114
|
+
}
|
|
115
|
+
const file = fileOf(path, true, scheme === 'file');
|
|
116
|
+
return file ? [chip(file, path, linkLabel(node.children, file), true)] : null;
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}),
|
|
120
|
+
components: { file: withProps(MarkdownFile, { open }) },
|
|
121
|
+
// A finished reply's chips are written as markup, and their clicks come back here
|
|
122
|
+
static: {
|
|
123
|
+
file: {
|
|
124
|
+
html: (node, tools) => fileHtml(node, open !== undefined, tools),
|
|
125
|
+
click(chip, event) {
|
|
126
|
+
const file = chipFile(chip);
|
|
127
|
+
if (file && open)
|
|
128
|
+
open(file, event);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntax highlighting for Narvi's Markdown, with Pierre's Highlights: a WebAssembly
|
|
3
|
+
* highlighter with 152 languages that can tokenize code as it streams.
|
|
4
|
+
*
|
|
5
|
+
* import { highlight } from '@diegopluna/narvi/markdown/highlight';
|
|
6
|
+
* <Markdown value={text} plugins={[highlight()]} />
|
|
7
|
+
*
|
|
8
|
+
* Importing this module loads the highlighter (about 150 KB gzipped), so import it where
|
|
9
|
+
* Markdown with code is shown, or with a dynamic `import()` to keep it out of the first load.
|
|
10
|
+
*/
|
|
11
|
+
import { type Theme } from '@pierre/highlights';
|
|
12
|
+
import type { MarkdownPlugin } from './plugin.js';
|
|
13
|
+
export type HighlightOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* Zed-compatible editor themes, one for light and one for dark, such as those in
|
|
16
|
+
* `@pierre/highlights/themes`. Their colours follow the page's `color-scheme`. Without
|
|
17
|
+
* them, code takes Narvi's own syntax colours, which follow the Narvi theme.
|
|
18
|
+
*/
|
|
19
|
+
themes?: {
|
|
20
|
+
light: Theme;
|
|
21
|
+
dark: Theme;
|
|
22
|
+
} | undefined;
|
|
23
|
+
/** Lines at or above this length are shown plain. Default 2000. */
|
|
24
|
+
maxLineLength?: number | undefined;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The first-party highlighter plugin. A code block in a language Highlights does not know is
|
|
28
|
+
* shown plain.
|
|
29
|
+
*/
|
|
30
|
+
export declare function highlight(options?: HighlightOptions): MarkdownPlugin;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntax highlighting for Narvi's Markdown, with Pierre's Highlights: a WebAssembly
|
|
3
|
+
* highlighter with 152 languages that can tokenize code as it streams.
|
|
4
|
+
*
|
|
5
|
+
* import { highlight } from '@diegopluna/narvi/markdown/highlight';
|
|
6
|
+
* <Markdown value={text} plugins={[highlight()]} />
|
|
7
|
+
*
|
|
8
|
+
* Importing this module loads the highlighter (about 150 KB gzipped), so import it where
|
|
9
|
+
* Markdown with code is shown, or with a dynamic `import()` to keep it out of the first load.
|
|
10
|
+
*/
|
|
11
|
+
import { StreamTokenizer, codeToTokens, isSupportedLanguage } from '@pierre/highlights';
|
|
12
|
+
/** A theme of CSS variables: each token's colour names its type, which Narvi then colours. */
|
|
13
|
+
const kindsTheme = { name: 'narvi', appearance: 'dark', style: {}, cssVariables: true };
|
|
14
|
+
const PREFIX = '--narvi-hl-';
|
|
15
|
+
const reKind = new RegExp(`^var\\(${PREFIX}([a-z0-9_-]+)\\)$`);
|
|
16
|
+
/** Highlights's token types, by their first word, as the kinds Narvi colours. */
|
|
17
|
+
const KINDS = {
|
|
18
|
+
attribute: 'attribute',
|
|
19
|
+
boolean: 'constant',
|
|
20
|
+
comment: 'comment',
|
|
21
|
+
constant: 'constant',
|
|
22
|
+
constructor: 'function',
|
|
23
|
+
diff: null,
|
|
24
|
+
embedded: null,
|
|
25
|
+
emphasis: null,
|
|
26
|
+
enum: 'type',
|
|
27
|
+
function: 'function',
|
|
28
|
+
hint: 'comment',
|
|
29
|
+
keyword: 'keyword',
|
|
30
|
+
label: 'keyword',
|
|
31
|
+
link_text: 'string',
|
|
32
|
+
link_uri: 'string',
|
|
33
|
+
namespace: 'type',
|
|
34
|
+
number: 'number',
|
|
35
|
+
operator: 'operator',
|
|
36
|
+
preproc: 'keyword',
|
|
37
|
+
property: 'property',
|
|
38
|
+
punctuation: 'punctuation',
|
|
39
|
+
selector: 'tag',
|
|
40
|
+
string: 'string',
|
|
41
|
+
tag: 'tag',
|
|
42
|
+
title: 'function',
|
|
43
|
+
type: 'type',
|
|
44
|
+
variant: 'type'
|
|
45
|
+
};
|
|
46
|
+
function kindOf(color) {
|
|
47
|
+
const name = color?.match(reKind)?.[1];
|
|
48
|
+
if (!name)
|
|
49
|
+
return undefined;
|
|
50
|
+
if (name === 'diff-plus')
|
|
51
|
+
return 'inserted';
|
|
52
|
+
if (name === 'diff-minus')
|
|
53
|
+
return 'deleted';
|
|
54
|
+
return KINDS[name.split('-')[0]] ?? undefined;
|
|
55
|
+
}
|
|
56
|
+
/** Names models and people write on a fence that Highlights knows by another. */
|
|
57
|
+
const ALIASES = {
|
|
58
|
+
node: 'js',
|
|
59
|
+
console: 'bash',
|
|
60
|
+
terminal: 'bash',
|
|
61
|
+
postgres: 'sql',
|
|
62
|
+
postgresql: 'sql',
|
|
63
|
+
mysql: 'sql',
|
|
64
|
+
sqlite: 'sql',
|
|
65
|
+
python3: 'python',
|
|
66
|
+
gitignore: 'ini',
|
|
67
|
+
dockerignore: 'ini',
|
|
68
|
+
luau: 'lua'
|
|
69
|
+
};
|
|
70
|
+
function resolveLang(lang) {
|
|
71
|
+
if (!lang)
|
|
72
|
+
return null;
|
|
73
|
+
const lower = lang.toLowerCase();
|
|
74
|
+
const name = ALIASES[lower] ?? lower;
|
|
75
|
+
return isSupportedLanguage(name) && name !== 'plain' && name !== 'text' ? name : null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The first-party highlighter plugin. A code block in a language Highlights does not know is
|
|
79
|
+
* shown plain.
|
|
80
|
+
*/
|
|
81
|
+
export function highlight(options = {}) {
|
|
82
|
+
const { themes, maxLineLength = 2000 } = options;
|
|
83
|
+
const base = themes
|
|
84
|
+
? { themes, defaultColor: 'light-dark()' }
|
|
85
|
+
: { theme: kindsTheme, cssVariablePrefix: PREFIX };
|
|
86
|
+
const convert = (lines) => lines.map((line) => line.map((token) => {
|
|
87
|
+
const out = { text: token.content };
|
|
88
|
+
if (themes) {
|
|
89
|
+
const color = token.htmlStyle?.color ?? token.color;
|
|
90
|
+
if (color)
|
|
91
|
+
out.color = color;
|
|
92
|
+
if (token.fontStyle) {
|
|
93
|
+
if (token.fontStyle & 1)
|
|
94
|
+
out.italic = true;
|
|
95
|
+
if (token.fontStyle & 2)
|
|
96
|
+
out.bold = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const kind = kindOf(token.color);
|
|
101
|
+
if (kind)
|
|
102
|
+
out.kind = kind;
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}));
|
|
106
|
+
const optionsFor = (lang) => ({ ...base, lang, tokenizeMaxLineLength: maxLineLength });
|
|
107
|
+
return {
|
|
108
|
+
name: 'highlight',
|
|
109
|
+
highlight(code, lang) {
|
|
110
|
+
const name = resolveLang(lang);
|
|
111
|
+
if (!name)
|
|
112
|
+
return null;
|
|
113
|
+
return convert(codeToTokens(code, optionsFor(name)).tokens);
|
|
114
|
+
},
|
|
115
|
+
highlightStream(lang) {
|
|
116
|
+
const name = resolveLang(lang);
|
|
117
|
+
if (!name)
|
|
118
|
+
return null;
|
|
119
|
+
const tokenizer = new StreamTokenizer(optionsFor(name));
|
|
120
|
+
return {
|
|
121
|
+
push: (chunk) => convert(tokenizer.pushCode(chunk)),
|
|
122
|
+
end: () => convert(tokenizer.end()),
|
|
123
|
+
dispose: () => tokenizer.dispose()
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Document } from './ast.js';
|
|
2
|
+
export type HtmlOptions = {
|
|
3
|
+
/** Writes raw HTML as text instead of passing it through. Default `true` (pass through). */
|
|
4
|
+
rawHtml?: boolean | undefined;
|
|
5
|
+
/** Escapes the tags GFM's tag filter disallows, such as `<script>`. Default `true`. */
|
|
6
|
+
tagFilter?: boolean | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Puts links and images through the default policy: a link whose address it refuses is
|
|
9
|
+
* written as its text, and an image as its alt text. Default `false`.
|
|
10
|
+
*/
|
|
11
|
+
safeLinks?: boolean | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare function escapeHtml(s: string): string;
|
|
14
|
+
export declare function toHtml(doc: Document, options?: HtmlOptions): string;
|