@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,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Math for Narvi's Markdown, typeset with KaTeX.
|
|
3
|
+
*
|
|
4
|
+
* import { math } from '@diegopluna/narvi/markdown/math';
|
|
5
|
+
* <Markdown value={text} plugins={[math()]} />
|
|
6
|
+
*
|
|
7
|
+
* It turns on formula syntax (`$x$`, `$$x$$`, `\(x\)`, `\[x\]`), which changes what a dollar
|
|
8
|
+
* sign means, under rules that leave prices and shell variables as text. KaTeX itself loads
|
|
9
|
+
* the first time a formula is shown.
|
|
10
|
+
*/
|
|
11
|
+
import MarkdownMath from '../components/markdown/MarkdownMath.svelte';
|
|
12
|
+
import { withProps } from './plugin.js';
|
|
13
|
+
export function math() {
|
|
14
|
+
const component = withProps(MarkdownMath);
|
|
15
|
+
return {
|
|
16
|
+
name: 'math',
|
|
17
|
+
syntax: { math: true },
|
|
18
|
+
components: { math: component, inlineMath: component },
|
|
19
|
+
// A fenced block in the language `math` is a formula too
|
|
20
|
+
languages: { math: component }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsing a whole document, or one that arrives a piece at a time.
|
|
3
|
+
*/
|
|
4
|
+
import type { Document } from './ast.js';
|
|
5
|
+
import { type BlockOptions } from './blocks.js';
|
|
6
|
+
export type ParseOptions = BlockOptions & {
|
|
7
|
+
/**
|
|
8
|
+
* Reads YAML front matter: a file that starts with a line of `---`, then `key: value`
|
|
9
|
+
* lines, then a line of `---` or `...`. It is kept as `frontmatter` on the document and
|
|
10
|
+
* left out of what is drawn. Off by default: a reply that starts with `---` starts with a
|
|
11
|
+
* rule. Turn it on for files.
|
|
12
|
+
*/
|
|
13
|
+
frontmatter?: boolean | undefined;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A document that grows as text arrives. Each complete line is read once; `snapshot()` shows
|
|
17
|
+
* the document as it stands, with the unfinished last line and every open block previewed on
|
|
18
|
+
* a copy, so nothing already read is read again.
|
|
19
|
+
*
|
|
20
|
+
* Blocks that are finished keep their `id` and their object from one snapshot to the next.
|
|
21
|
+
* So does every part of the unfinished end that says what it said before (`share.ts`): of a
|
|
22
|
+
* paragraph that grew by a word, the text at its end is new, and the emphasis, code and links
|
|
23
|
+
* before it are the objects they were.
|
|
24
|
+
*/
|
|
25
|
+
export declare class MarkdownStream {
|
|
26
|
+
private parser;
|
|
27
|
+
private text;
|
|
28
|
+
/** Where the line that is not finished yet starts. */
|
|
29
|
+
private pending;
|
|
30
|
+
private finished;
|
|
31
|
+
/** The last snapshot, which the next one shares what it can with. */
|
|
32
|
+
private last;
|
|
33
|
+
private options;
|
|
34
|
+
/**
|
|
35
|
+
* Front matter in the making. `start` is before the first line; `maybe` after an opening
|
|
36
|
+
* `---`; `open` once the next line reads as YAML; `closed` at its end; `none` when the
|
|
37
|
+
* file has none. Until it closes its lines are held here, in case it never does: then
|
|
38
|
+
* they are a rule and text after all.
|
|
39
|
+
*/
|
|
40
|
+
private front;
|
|
41
|
+
private held;
|
|
42
|
+
private frontmatter;
|
|
43
|
+
constructor(options?: ParseOptions);
|
|
44
|
+
/** The text read so far. */
|
|
45
|
+
get value(): string;
|
|
46
|
+
/** Adds text to the end. */
|
|
47
|
+
append(chunk: string): this;
|
|
48
|
+
/**
|
|
49
|
+
* Sets the whole text. When it continues the text so far, only the new part is read;
|
|
50
|
+
* otherwise the document is read again from the start.
|
|
51
|
+
*/
|
|
52
|
+
set(text: string): this;
|
|
53
|
+
private readLines;
|
|
54
|
+
/** Takes one whole line: into front matter while one is open, to the parser otherwise. */
|
|
55
|
+
private readLine;
|
|
56
|
+
/** Hands the lines held for front matter to a parser, as the Markdown they turned out to be. */
|
|
57
|
+
private releaseHeld;
|
|
58
|
+
private withFrontmatter;
|
|
59
|
+
/**
|
|
60
|
+
* The document as it stands, with the unfinished end previewed. Changes nothing.
|
|
61
|
+
*
|
|
62
|
+
* With `tidy`, the end reads as it most likely will once written: emphasis that has started
|
|
63
|
+
* is closed, a link waiting for its destination shows as text, and what is still ambiguous
|
|
64
|
+
* is held back, such as a bare marker on the last line or a table's header row before its
|
|
65
|
+
* delimiter row. Only the unfinished end is tidied, never text that is complete.
|
|
66
|
+
*
|
|
67
|
+
* With `final`, the text is read as all there is, as `finish()` reads it, but the stream
|
|
68
|
+
* stays open: nothing is marked as still being written, and a formula that never closed
|
|
69
|
+
* is the text it was written as.
|
|
70
|
+
*/
|
|
71
|
+
snapshot({ tidy, final }?: {
|
|
72
|
+
tidy?: boolean | undefined;
|
|
73
|
+
final?: boolean | undefined;
|
|
74
|
+
}): Document;
|
|
75
|
+
/** A snapshot with all that the one before it said too kept as the same objects. */
|
|
76
|
+
private shared;
|
|
77
|
+
/** Ends the document: every open block closes for good. */
|
|
78
|
+
finish(): Document;
|
|
79
|
+
}
|
|
80
|
+
/** Parses a whole document. */
|
|
81
|
+
export declare function parse(text: string, options?: ParseOptions): Document;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { BlockParser } from './blocks.js';
|
|
2
|
+
import { shareDocument } from './share.js';
|
|
3
|
+
const reFrontOpen = /^---[ \t]*$/;
|
|
4
|
+
const reFrontClose = /^(?:---|\.\.\.)[ \t]*$/;
|
|
5
|
+
// What the line after the opening `---` is when front matter follows: a key, a comment, or
|
|
6
|
+
// the end of an empty one. Text under a rule is none of these.
|
|
7
|
+
const reFrontFirst = /^(?:[A-Za-z_][\w.-]*[ \t]*:|#|(?:---|\.\.\.)[ \t]*$)/;
|
|
8
|
+
const reLineEnding = /\r\n|\n|\r/g;
|
|
9
|
+
// A line that so far holds only what blocks start with: markers and the spaces between
|
|
10
|
+
// them (`- *`, `> -`, `* **`), a list's number with its `.` or `)` (a number alone is a
|
|
11
|
+
// number), and a task's box in the making (`- [x`). Any of them may turn into something else with the next
|
|
12
|
+
// character, so none is drawn yet.
|
|
13
|
+
const reMarkerOnly = /^(?=.*[^ \t])[-*+=#>|_~` \t]*(?:\d{1,9}[.)][-*+=#>|_~` \t]*)?(?:\[[ xX]?\]?[ \t]*)?$/;
|
|
14
|
+
/**
|
|
15
|
+
* A document that grows as text arrives. Each complete line is read once; `snapshot()` shows
|
|
16
|
+
* the document as it stands, with the unfinished last line and every open block previewed on
|
|
17
|
+
* a copy, so nothing already read is read again.
|
|
18
|
+
*
|
|
19
|
+
* Blocks that are finished keep their `id` and their object from one snapshot to the next.
|
|
20
|
+
* So does every part of the unfinished end that says what it said before (`share.ts`): of a
|
|
21
|
+
* paragraph that grew by a word, the text at its end is new, and the emphasis, code and links
|
|
22
|
+
* before it are the objects they were.
|
|
23
|
+
*/
|
|
24
|
+
export class MarkdownStream {
|
|
25
|
+
parser;
|
|
26
|
+
text = '';
|
|
27
|
+
/** Where the line that is not finished yet starts. */
|
|
28
|
+
pending = 0;
|
|
29
|
+
finished = null;
|
|
30
|
+
/** The last snapshot, which the next one shares what it can with. */
|
|
31
|
+
last = null;
|
|
32
|
+
options;
|
|
33
|
+
/**
|
|
34
|
+
* Front matter in the making. `start` is before the first line; `maybe` after an opening
|
|
35
|
+
* `---`; `open` once the next line reads as YAML; `closed` at its end; `none` when the
|
|
36
|
+
* file has none. Until it closes its lines are held here, in case it never does: then
|
|
37
|
+
* they are a rule and text after all.
|
|
38
|
+
*/
|
|
39
|
+
front = 'none';
|
|
40
|
+
held = [];
|
|
41
|
+
frontmatter = null;
|
|
42
|
+
constructor(options = {}) {
|
|
43
|
+
this.options = options;
|
|
44
|
+
this.parser = new BlockParser(options);
|
|
45
|
+
this.front = options.frontmatter ? 'start' : 'none';
|
|
46
|
+
}
|
|
47
|
+
/** The text read so far. */
|
|
48
|
+
get value() {
|
|
49
|
+
return this.text;
|
|
50
|
+
}
|
|
51
|
+
/** Adds text to the end. */
|
|
52
|
+
append(chunk) {
|
|
53
|
+
if (chunk.length === 0)
|
|
54
|
+
return this;
|
|
55
|
+
if (this.finished)
|
|
56
|
+
throw new Error('This stream is finished');
|
|
57
|
+
this.text += chunk;
|
|
58
|
+
this.readLines();
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Sets the whole text. When it continues the text so far, only the new part is read;
|
|
63
|
+
* otherwise the document is read again from the start.
|
|
64
|
+
*/
|
|
65
|
+
set(text) {
|
|
66
|
+
// Compared as slices, which the engine does a block at a time: `startsWith` reads every
|
|
67
|
+
// character, and this runs on every update of a reply that streams
|
|
68
|
+
if (!this.finished &&
|
|
69
|
+
text.length >= this.text.length &&
|
|
70
|
+
text.slice(0, this.text.length) === this.text)
|
|
71
|
+
return this.append(text.slice(this.text.length));
|
|
72
|
+
this.parser = new BlockParser(this.options);
|
|
73
|
+
this.text = '';
|
|
74
|
+
this.pending = 0;
|
|
75
|
+
this.finished = null;
|
|
76
|
+
// Read from the start again: every block is new, and none is measured against the old
|
|
77
|
+
this.last = null;
|
|
78
|
+
this.front = this.options.frontmatter ? 'start' : 'none';
|
|
79
|
+
this.held = [];
|
|
80
|
+
this.frontmatter = null;
|
|
81
|
+
return this.append(text);
|
|
82
|
+
}
|
|
83
|
+
readLines() {
|
|
84
|
+
const text = this.text;
|
|
85
|
+
reLineEnding.lastIndex = this.pending;
|
|
86
|
+
let m;
|
|
87
|
+
while ((m = reLineEnding.exec(text))) {
|
|
88
|
+
// A `\r` at the very end may be the first half of `\r\n`
|
|
89
|
+
if (m[0] === '\r' && m.index === text.length - 1)
|
|
90
|
+
break;
|
|
91
|
+
this.readLine(text.slice(this.pending, m.index), this.pending);
|
|
92
|
+
this.pending = m.index + m[0].length;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Takes one whole line: into front matter while one is open, to the parser otherwise. */
|
|
96
|
+
readLine(line, start) {
|
|
97
|
+
if (this.front === 'none' || this.front === 'closed') {
|
|
98
|
+
this.parser.incorporateLine(line, start);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (this.front === 'start') {
|
|
102
|
+
if (reFrontOpen.test(line)) {
|
|
103
|
+
this.front = 'maybe';
|
|
104
|
+
this.held.push([line, start]);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.front = 'none';
|
|
108
|
+
this.parser.incorporateLine(line, start);
|
|
109
|
+
}
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (this.front === 'maybe') {
|
|
113
|
+
if (!reFrontFirst.test(line)) {
|
|
114
|
+
// A rule with text under it, not front matter
|
|
115
|
+
this.held.push([line, start]);
|
|
116
|
+
this.releaseHeld(this.parser);
|
|
117
|
+
this.front = 'none';
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.front = 'open';
|
|
121
|
+
}
|
|
122
|
+
if (reFrontClose.test(line)) {
|
|
123
|
+
this.frontmatter = this.held
|
|
124
|
+
.slice(1)
|
|
125
|
+
.map(([text]) => text)
|
|
126
|
+
.join('\n');
|
|
127
|
+
this.held = [];
|
|
128
|
+
this.front = 'closed';
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.held.push([line, start]);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** Hands the lines held for front matter to a parser, as the Markdown they turned out to be. */
|
|
135
|
+
releaseHeld(parser) {
|
|
136
|
+
for (const [line, start] of this.held)
|
|
137
|
+
parser.incorporateLine(line, start);
|
|
138
|
+
if (parser === this.parser)
|
|
139
|
+
this.held = [];
|
|
140
|
+
}
|
|
141
|
+
withFrontmatter(document) {
|
|
142
|
+
return this.frontmatter === null ? document : { ...document, frontmatter: this.frontmatter };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The document as it stands, with the unfinished end previewed. Changes nothing.
|
|
146
|
+
*
|
|
147
|
+
* With `tidy`, the end reads as it most likely will once written: emphasis that has started
|
|
148
|
+
* is closed, a link waiting for its destination shows as text, and what is still ambiguous
|
|
149
|
+
* is held back, such as a bare marker on the last line or a table's header row before its
|
|
150
|
+
* delimiter row. Only the unfinished end is tidied, never text that is complete.
|
|
151
|
+
*
|
|
152
|
+
* With `final`, the text is read as all there is, as `finish()` reads it, but the stream
|
|
153
|
+
* stays open: nothing is marked as still being written, and a formula that never closed
|
|
154
|
+
* is the text it was written as.
|
|
155
|
+
*/
|
|
156
|
+
snapshot({ tidy = false, final = false } = {}) {
|
|
157
|
+
if (this.finished)
|
|
158
|
+
return this.finished;
|
|
159
|
+
const preview = this.parser.fork();
|
|
160
|
+
// Front matter that has not closed: nothing of it is drawn while more may come. Read
|
|
161
|
+
// as final, it never closed, and is a rule and the text under it.
|
|
162
|
+
const waiting = this.front === 'maybe' || this.front === 'open';
|
|
163
|
+
if (waiting && !final)
|
|
164
|
+
return this.shared(preview.toDocument(this.parser, tidy));
|
|
165
|
+
if (waiting)
|
|
166
|
+
this.releaseHeld(preview);
|
|
167
|
+
let rest = this.text.slice(this.pending).replace(/\r$/, '');
|
|
168
|
+
// A line that so far is only a marker could still become a list, a heading or a rule
|
|
169
|
+
if (tidy && reMarkerOnly.test(rest))
|
|
170
|
+
rest = '';
|
|
171
|
+
if (rest.length > 0)
|
|
172
|
+
preview.incorporateLine(rest, this.pending);
|
|
173
|
+
if (!final)
|
|
174
|
+
preview.markTail();
|
|
175
|
+
preview.closeAll();
|
|
176
|
+
return this.shared(this.withFrontmatter(preview.toDocument(this.parser, tidy)));
|
|
177
|
+
}
|
|
178
|
+
/** A snapshot with all that the one before it said too kept as the same objects. */
|
|
179
|
+
shared(document) {
|
|
180
|
+
return (this.last = shareDocument(this.last, document));
|
|
181
|
+
}
|
|
182
|
+
/** Ends the document: every open block closes for good. */
|
|
183
|
+
finish() {
|
|
184
|
+
if (this.finished)
|
|
185
|
+
return this.finished;
|
|
186
|
+
if (this.front === 'maybe' || this.front === 'open') {
|
|
187
|
+
this.releaseHeld(this.parser);
|
|
188
|
+
this.front = 'none';
|
|
189
|
+
}
|
|
190
|
+
const rest = this.text.slice(this.pending).replace(/\r$/, '');
|
|
191
|
+
if (rest.length > 0 || this.text.endsWith('\r')) {
|
|
192
|
+
if (rest.length > 0)
|
|
193
|
+
this.parser.incorporateLine(rest, this.pending);
|
|
194
|
+
this.pending = this.text.length;
|
|
195
|
+
}
|
|
196
|
+
this.parser.closeAll();
|
|
197
|
+
this.finished = this.withFrontmatter(this.parser.toDocument());
|
|
198
|
+
return this.finished;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/** Parses a whole document. */
|
|
202
|
+
export function parse(text, options = {}) {
|
|
203
|
+
return new MarkdownStream(options).append(text).finish();
|
|
204
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a plugin can add to Narvi's Markdown, and the default policy for links and images.
|
|
3
|
+
*/
|
|
4
|
+
import type { Complete } from '../internal/complete.js';
|
|
5
|
+
import type { Component } from 'svelte';
|
|
6
|
+
import type { Block, Document, Image, Inline, Link } from './ast.js';
|
|
7
|
+
/**
|
|
8
|
+
* A piece of highlighted code. `kind` names what it is (`keyword`, `string`, `comment`…) and
|
|
9
|
+
* takes Narvi's colour for that kind; `color` is a CSS colour of the highlighter's own, from
|
|
10
|
+
* an editor theme, and wins over the kind.
|
|
11
|
+
*/
|
|
12
|
+
export type HighlightToken = {
|
|
13
|
+
text: string;
|
|
14
|
+
kind?: string | undefined;
|
|
15
|
+
color?: string | undefined;
|
|
16
|
+
italic?: boolean | undefined;
|
|
17
|
+
bold?: boolean | undefined;
|
|
18
|
+
};
|
|
19
|
+
/** Turns code into lines of tokens, or returns null to show it plain. */
|
|
20
|
+
export type Highlighter = (code: string, lang: string | null) => HighlightToken[][] | null;
|
|
21
|
+
/**
|
|
22
|
+
* Highlights code that arrives in pieces, keeping its place between them, so a block that
|
|
23
|
+
* streams is never tokenized again from the top.
|
|
24
|
+
*/
|
|
25
|
+
export type HighlightStream = {
|
|
26
|
+
/** Takes more code, and returns the lines it completed. */
|
|
27
|
+
push(chunk: string): HighlightToken[][];
|
|
28
|
+
/** Ends the code, and returns the lines that were left. */
|
|
29
|
+
end(): HighlightToken[][];
|
|
30
|
+
/** Frees what the stream holds. */
|
|
31
|
+
dispose(): void;
|
|
32
|
+
};
|
|
33
|
+
/** The props a component that replaces a node type receives. */
|
|
34
|
+
export type NodeProps<N> = {
|
|
35
|
+
node: N;
|
|
36
|
+
/** Renders the node's children as Narvi would. */
|
|
37
|
+
children?: import('svelte').Snippet | undefined;
|
|
38
|
+
};
|
|
39
|
+
/** A component for a node, with extra props it is given beside `node` and `children`. */
|
|
40
|
+
export type PluginComponent = {
|
|
41
|
+
component: Component<NodeProps<never>>;
|
|
42
|
+
props: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* A plugin's component, typed for the node it draws, with the extra props it takes:
|
|
46
|
+
* `components: { file: withProps(FileChip, { open }) }`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function withProps<Props extends Record<string, unknown>>(component: Component<Props>, props?: Omit<Props, 'node' | 'children'>): PluginComponent;
|
|
49
|
+
export type LinkPolicy = {
|
|
50
|
+
/**
|
|
51
|
+
* The address to link to, or null to show the link's text without a link. The default
|
|
52
|
+
* allows `http:`, `https:`, `mailto:`, `tel:`, and addresses without a scheme. On a page
|
|
53
|
+
* that is not on the web (a desktop app on `file:` or a scheme of its own), an address
|
|
54
|
+
* without a scheme is a file on the machine, and is allowed only when the app gives `open`.
|
|
55
|
+
*
|
|
56
|
+
* `url` is the address as a browser will read it (see `readUrl`). It may still be
|
|
57
|
+
* `//host/…`, which starts with `/` and leaves the site: test `readUrl(url).kind`, not the
|
|
58
|
+
* start of the string. A `javascript:` address is refused whatever this returns.
|
|
59
|
+
*/
|
|
60
|
+
href?: ((url: string, node: Link) => string | null) | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* The address to load an image from, or null to show its alt text instead. The default
|
|
63
|
+
* allows `http:`, `https:`, and addresses without a scheme. A remote image is requested as
|
|
64
|
+
* soon as it is shown, so text written by a model can send data out through its address:
|
|
65
|
+
* an app that renders such text should decide here which hosts it loads.
|
|
66
|
+
*/
|
|
67
|
+
image?: ((url: string, node: Image) => string | null) | undefined;
|
|
68
|
+
/** Whether a link opens in a new tab. The default: links to another origin do. */
|
|
69
|
+
external?: ((href: string) => boolean) | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Called when a link is clicked, before the browser follows it. Call
|
|
72
|
+
* `event.preventDefault()` to open it yourself: in a side panel, an in-app browser, or
|
|
73
|
+
* the app's own router. Modifier keys are on the event.
|
|
74
|
+
*/
|
|
75
|
+
open?: ((href: string, event: MouseEvent) => void) | undefined;
|
|
76
|
+
};
|
|
77
|
+
/** A policy with every decision filled in; `open` stays optional. */
|
|
78
|
+
export type ResolvedLinkPolicy = Complete<Omit<LinkPolicy, 'open'>> & Pick<LinkPolicy, 'open'>;
|
|
79
|
+
export type MarkdownPlugin = {
|
|
80
|
+
name: string;
|
|
81
|
+
/** Syntax to read beyond CommonMark and GFM. */
|
|
82
|
+
syntax?: {
|
|
83
|
+
/** Formulas: `$x$`, `$$x$$`, `\\(x\\)` and `\\[x\\]`, as `inlineMath` and `math` nodes. */
|
|
84
|
+
math?: boolean | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Rewrites a block after it is parsed: for example, turning `@thread:12` in its text into
|
|
88
|
+
* a link. It is called for the blocks that hold text or code (paragraphs, headings, tables,
|
|
89
|
+
* code blocks, wherever they are nested), and never for the lists and quotes around them.
|
|
90
|
+
* A finished block is transformed once; return the same block to change nothing.
|
|
91
|
+
*/
|
|
92
|
+
transform?: ((block: Block, document: Document) => Block) | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Components that replace Narvi's for node types, and that draw the `custom` nodes a
|
|
95
|
+
* transform adds, by their `name`. Use `withProps` to hand one extra props.
|
|
96
|
+
*/
|
|
97
|
+
components?: Record<string, Component<NodeProps<never>> | PluginComponent> | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Components that draw a fenced code block in a language, by its name in lower case:
|
|
100
|
+
* `{ mermaid: Diagram }`. One takes over once the fence has closed; while the block is
|
|
101
|
+
* still being written it shows as code.
|
|
102
|
+
*/
|
|
103
|
+
languages?: Record<string, Component<NodeProps<never>> | PluginComponent> | undefined;
|
|
104
|
+
/** Colours code blocks. */
|
|
105
|
+
highlight?: Highlighter | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Colours a code block while it streams. Returns null for a language it does not know.
|
|
108
|
+
* Without it, a streaming block is highlighted once its fence closes.
|
|
109
|
+
*/
|
|
110
|
+
highlightStream?: ((lang: string | null) => HighlightStream | null) | undefined;
|
|
111
|
+
/** Decides links and images. Later plugins override earlier ones, one function at a time. */
|
|
112
|
+
links?: LinkPolicy | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* For `static`: how to write the nodes this plugin draws as markup, by the same names as
|
|
115
|
+
* `components`. A finished block that holds one of these nodes can then be written as
|
|
116
|
+
* markup too; without it, the block is built from parts as ever. It is used only while
|
|
117
|
+
* this plugin's own component is the one that draws the node.
|
|
118
|
+
*/
|
|
119
|
+
static?: Record<string, StaticPart<never>> | undefined;
|
|
120
|
+
};
|
|
121
|
+
/** What a `static` writer is given to work with. */
|
|
122
|
+
export type StaticTools = {
|
|
123
|
+
/** Escapes text for markup, and for an attribute value in double quotes. */
|
|
124
|
+
escape: (text: string) => string;
|
|
125
|
+
/** The node's own children, as markup. Throws nothing: a child that needs a part ends the attempt. */
|
|
126
|
+
children: () => string;
|
|
127
|
+
/** The attribute that marks an element as this part's, so that its clicks reach `click`. */
|
|
128
|
+
part: string;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* A node as markup, for `static`. The plugin is trusted code: everything it writes is put
|
|
132
|
+
* on the page as it is, so every piece of text and every attribute value from the node must
|
|
133
|
+
* go through `tools.escape`.
|
|
134
|
+
*/
|
|
135
|
+
export type StaticPart<N> = {
|
|
136
|
+
/** The node as markup, or null to have the plugin's component draw it. */
|
|
137
|
+
html: (node: N, tools: StaticTools) => string | null;
|
|
138
|
+
/** Called for a click, or a middle click, on an element that carries `tools.part`. */
|
|
139
|
+
click?: ((element: HTMLElement, event: MouseEvent) => void) | undefined;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* An address as a browser will read it. A browser drops tabs and line endings from anywhere
|
|
143
|
+
* in an address, and control characters and spaces from its ends, before it looks for the
|
|
144
|
+
* scheme: `java\tscript:` is `javascript:`. So does this, and every check is made on the
|
|
145
|
+
* result, which is also what gets rendered.
|
|
146
|
+
*
|
|
147
|
+
* `kind` says where the address goes: `relative` stays on the page's own site; `network` is
|
|
148
|
+
* `//host/…`, which borrows the page's scheme; `scheme` has one of its own; and `unsafe` is
|
|
149
|
+
* an address with backslashes at its start, which a browser reads as `//host` and which on
|
|
150
|
+
* a `file:` page is a network share.
|
|
151
|
+
*/
|
|
152
|
+
export declare function readUrl(url: string): {
|
|
153
|
+
url: string;
|
|
154
|
+
scheme: string | null;
|
|
155
|
+
kind: 'relative' | 'network' | 'scheme' | 'unsafe';
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* The default decision for a link. `followRelative` says whether an address on the page's
|
|
159
|
+
* own site may be followed when the page is not on the web. There, in a desktop app on a
|
|
160
|
+
* `file:` page or a scheme of its own, `/Users/me/report.html` is a file on the machine, and
|
|
161
|
+
* following it puts that file in the app's window. So such a link is refused unless the app
|
|
162
|
+
* opens links itself. A link to a place in the same page (`#name`) is always allowed, and a
|
|
163
|
+
* link with no address is never one.
|
|
164
|
+
*/
|
|
165
|
+
export declare function defaultHref(url: string, followRelative: boolean): string | null;
|
|
166
|
+
export declare const defaultLinkPolicy: ResolvedLinkPolicy;
|
|
167
|
+
/**
|
|
168
|
+
* Calls `fn` on every inline node of a block, outermost first, and puts back what it returns.
|
|
169
|
+
* Return null to leave a node as it is; its children are then visited too. `inLink` says
|
|
170
|
+
* whether the node sits inside a link, which cannot hold another.
|
|
171
|
+
*/
|
|
172
|
+
export declare function mapInlines(block: Block, fn: (node: Inline, context: {
|
|
173
|
+
inLink: boolean;
|
|
174
|
+
}) => Inline[] | null): Block;
|
|
175
|
+
/**
|
|
176
|
+
* Calls `fn` on every text node of a block, and puts back what it returns. Code is not text,
|
|
177
|
+
* and text inside a link is left alone, so what `fn` returns may hold links.
|
|
178
|
+
*/
|
|
179
|
+
export declare function mapText(block: Block, fn: (value: string) => Inline[] | null): Block;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plugin's component, typed for the node it draws, with the extra props it takes:
|
|
3
|
+
* `components: { file: withProps(FileChip, { open }) }`.
|
|
4
|
+
*/
|
|
5
|
+
export function withProps(component, props = {}) {
|
|
6
|
+
return { component: component, props };
|
|
7
|
+
}
|
|
8
|
+
const reScheme = /^([a-z][a-z0-9+.-]*):/i;
|
|
9
|
+
// Tabs and line endings: the characters a browser strips from inside an address
|
|
10
|
+
const reStripped = /[\t\n\r]/g;
|
|
11
|
+
// eslint-disable-next-line no-control-regex
|
|
12
|
+
const reEdges = /^[\x00-\x20]+|[\x00-\x20]+$/g;
|
|
13
|
+
/**
|
|
14
|
+
* An address as a browser will read it. A browser drops tabs and line endings from anywhere
|
|
15
|
+
* in an address, and control characters and spaces from its ends, before it looks for the
|
|
16
|
+
* scheme: `java\tscript:` is `javascript:`. So does this, and every check is made on the
|
|
17
|
+
* result, which is also what gets rendered.
|
|
18
|
+
*
|
|
19
|
+
* `kind` says where the address goes: `relative` stays on the page's own site; `network` is
|
|
20
|
+
* `//host/…`, which borrows the page's scheme; `scheme` has one of its own; and `unsafe` is
|
|
21
|
+
* an address with backslashes at its start, which a browser reads as `//host` and which on
|
|
22
|
+
* a `file:` page is a network share.
|
|
23
|
+
*/
|
|
24
|
+
export function readUrl(url) {
|
|
25
|
+
const cleaned = url.replace(reStripped, '').replace(reEdges, '');
|
|
26
|
+
const scheme = cleaned.match(reScheme)?.[1]?.toLowerCase() ?? null;
|
|
27
|
+
if (scheme)
|
|
28
|
+
return { url: cleaned, scheme, kind: 'scheme' };
|
|
29
|
+
if (/^[\\/]{2}/.test(cleaned)) {
|
|
30
|
+
return { url: cleaned, scheme: null, kind: cleaned.startsWith('//') ? 'network' : 'unsafe' };
|
|
31
|
+
}
|
|
32
|
+
return { url: cleaned, scheme: null, kind: 'relative' };
|
|
33
|
+
}
|
|
34
|
+
/** Whether the page itself is on the web, where `//host/…` means another web host. */
|
|
35
|
+
function onTheWeb() {
|
|
36
|
+
return typeof location === 'undefined' || /^https?:$/.test(location.protocol);
|
|
37
|
+
}
|
|
38
|
+
/** An address with one of the schemes given, or none, as it may be rendered; null otherwise. */
|
|
39
|
+
function allow(url, schemes) {
|
|
40
|
+
const read = readUrl(url);
|
|
41
|
+
if (read.kind === 'unsafe')
|
|
42
|
+
return null;
|
|
43
|
+
// On a `file:` or app page, `//host/…` is not the web: it is a share, or the app's own scheme
|
|
44
|
+
if (read.kind === 'network')
|
|
45
|
+
return onTheWeb() ? read.url : null;
|
|
46
|
+
if (read.kind === 'scheme')
|
|
47
|
+
return schemes.includes(read.scheme) ? read.url : null;
|
|
48
|
+
return read.url;
|
|
49
|
+
}
|
|
50
|
+
const LINK_SCHEMES = ['http', 'https', 'mailto', 'tel'];
|
|
51
|
+
/**
|
|
52
|
+
* The default decision for a link. `followRelative` says whether an address on the page's
|
|
53
|
+
* own site may be followed when the page is not on the web. There, in a desktop app on a
|
|
54
|
+
* `file:` page or a scheme of its own, `/Users/me/report.html` is a file on the machine, and
|
|
55
|
+
* following it puts that file in the app's window. So such a link is refused unless the app
|
|
56
|
+
* opens links itself. A link to a place in the same page (`#name`) is always allowed, and a
|
|
57
|
+
* link with no address is never one.
|
|
58
|
+
*/
|
|
59
|
+
export function defaultHref(url, followRelative) {
|
|
60
|
+
const href = allow(url, LINK_SCHEMES);
|
|
61
|
+
if (href === null || href === '')
|
|
62
|
+
return null;
|
|
63
|
+
if (followRelative || href.startsWith('#') || onTheWeb())
|
|
64
|
+
return href;
|
|
65
|
+
return readUrl(href).kind === 'relative' ? null : href;
|
|
66
|
+
}
|
|
67
|
+
export const defaultLinkPolicy = {
|
|
68
|
+
href: (url) => defaultHref(url, false),
|
|
69
|
+
image: (url) => allow(url, ['http', 'https']),
|
|
70
|
+
external(href) {
|
|
71
|
+
const read = readUrl(href);
|
|
72
|
+
if (read.kind === 'relative')
|
|
73
|
+
return false;
|
|
74
|
+
if (read.kind === 'scheme' && read.scheme !== 'http' && read.scheme !== 'https')
|
|
75
|
+
return false;
|
|
76
|
+
if (typeof location === 'undefined')
|
|
77
|
+
return true;
|
|
78
|
+
try {
|
|
79
|
+
return new URL(read.url, location.href).origin !== location.origin;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Calls `fn` on every inline node of a block, outermost first, and puts back what it returns.
|
|
88
|
+
* Return null to leave a node as it is; its children are then visited too. `inLink` says
|
|
89
|
+
* whether the node sits inside a link, which cannot hold another.
|
|
90
|
+
*/
|
|
91
|
+
export function mapInlines(block, fn) {
|
|
92
|
+
const mapInlines = (inlines, inLink = false) => {
|
|
93
|
+
let changed = false;
|
|
94
|
+
const out = [];
|
|
95
|
+
for (const node of inlines) {
|
|
96
|
+
const replaced = fn(node, { inLink });
|
|
97
|
+
if (replaced) {
|
|
98
|
+
changed = true;
|
|
99
|
+
out.push(...replaced);
|
|
100
|
+
}
|
|
101
|
+
else if ('children' in node && node.type !== 'image') {
|
|
102
|
+
const children = mapInlines(node.children, inLink || node.type === 'link');
|
|
103
|
+
if (children !== node.children) {
|
|
104
|
+
changed = true;
|
|
105
|
+
out.push({ ...node, children });
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
out.push(node);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
out.push(node);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return changed ? out : inlines;
|
|
116
|
+
};
|
|
117
|
+
const mapBlock = (b) => {
|
|
118
|
+
switch (b.type) {
|
|
119
|
+
case 'paragraph':
|
|
120
|
+
case 'heading': {
|
|
121
|
+
const children = mapInlines(b.children);
|
|
122
|
+
return children === b.children ? b : { ...b, children };
|
|
123
|
+
}
|
|
124
|
+
case 'blockquote':
|
|
125
|
+
case 'listItem':
|
|
126
|
+
case 'footnoteDefinition': {
|
|
127
|
+
const children = b.children.map(mapBlock);
|
|
128
|
+
return children.every((c, i) => c === b.children[i]) ? b : { ...b, children };
|
|
129
|
+
}
|
|
130
|
+
case 'list': {
|
|
131
|
+
const children = b.children.map(mapBlock);
|
|
132
|
+
return children.every((c, i) => c === b.children[i]) ? b : { ...b, children };
|
|
133
|
+
}
|
|
134
|
+
case 'table': {
|
|
135
|
+
let changed = false;
|
|
136
|
+
const rows = b.children.map((row) => {
|
|
137
|
+
const cells = row.children.map((cell) => {
|
|
138
|
+
const children = mapInlines(cell.children);
|
|
139
|
+
if (children === cell.children)
|
|
140
|
+
return cell;
|
|
141
|
+
changed = true;
|
|
142
|
+
return { ...cell, children };
|
|
143
|
+
});
|
|
144
|
+
return cells.every((c, i) => c === row.children[i]) ? row : { ...row, children: cells };
|
|
145
|
+
});
|
|
146
|
+
return changed ? { ...b, children: rows } : b;
|
|
147
|
+
}
|
|
148
|
+
default:
|
|
149
|
+
return b;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
return mapBlock(block);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Calls `fn` on every text node of a block, and puts back what it returns. Code is not text,
|
|
156
|
+
* and text inside a link is left alone, so what `fn` returns may hold links.
|
|
157
|
+
*/
|
|
158
|
+
export function mapText(block, fn) {
|
|
159
|
+
return mapInlines(block, (node, { inLink }) => node.type === 'text' && !inLink ? fn(node.value) : null);
|
|
160
|
+
}
|