@diegopluna/narvi 0.0.2 → 0.2.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 +116 -44
- package/dist/base.css +96 -0
- package/dist/color.d.ts +1 -1
- package/dist/color.js +1 -1
- package/dist/components/activity/ActivityContent.svelte +3 -15
- package/dist/components/activity/ActivityStep.svelte +12 -12
- package/dist/components/activity/ActivityThought.svelte +4 -4
- package/dist/components/activity/ActivityTrigger.svelte +5 -6
- 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 +17 -17
- package/dist/components/app-shell/AppShellHeader.svelte.d.ts +2 -2
- package/dist/components/app-shell/AppShellMain.svelte +4 -20
- package/dist/components/app-shell/AppShellPanel.svelte +21 -19
- 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 +50 -24
- package/dist/components/app-shell/AppShellRoot.svelte.d.ts +8 -6
- 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 +41 -65
- package/dist/components/app-shell/AppShellSidebar.svelte.d.ts +1 -5
- package/dist/components/app-shell/AppShellToggle.svelte +62 -23
- package/dist/components/app-shell/AppShellToggle.svelte.d.ts +2 -0
- 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 +99 -23
- package/dist/components/approval/Approval.svelte.d.ts +7 -0
- package/dist/components/avatar/AvatarFallback.svelte +1 -2
- package/dist/components/avatar/AvatarRoot.svelte +2 -2
- package/dist/components/badge/Badge.svelte +5 -5
- package/dist/components/button/Button.svelte +227 -51
- package/dist/components/button/Button.svelte.d.ts +38 -2
- package/dist/components/card/Card.svelte +19 -33
- package/dist/components/change-stats/ChangeStats.svelte +1 -2
- package/dist/components/changes-summary/ChangesSummary.svelte +14 -15
- package/dist/components/checkbox/Checkbox.svelte +31 -25
- package/dist/components/checkbox/Checkbox.svelte.d.ts +5 -0
- package/dist/components/code/Code.svelte +1 -2
- package/dist/components/collapsible/CollapsibleContent.svelte +38 -0
- package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +11 -0
- package/dist/components/collapsible/CollapsibleRoot.svelte +44 -0
- package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +11 -0
- package/dist/components/collapsible/CollapsibleTrigger.svelte +83 -0
- package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +13 -0
- package/dist/components/collapsible/context.d.ts +5 -0
- package/dist/components/collapsible/context.js +11 -0
- package/dist/components/collapsible/index.d.ts +7 -0
- package/dist/components/collapsible/index.js +4 -0
- package/dist/components/command/CommandItem.svelte +1 -1
- package/dist/components/command/styles.d.ts +3 -2
- package/dist/components/command/styles.js +15 -12
- package/dist/components/composer/ComposerAttachButton.svelte +1 -1
- package/dist/components/composer/ComposerAttachment.svelte +13 -18
- package/dist/components/composer/ComposerModelPicker.svelte +24 -28
- package/dist/components/composer/ComposerRoot.svelte +15 -13
- package/dist/components/composer/ComposerSubmit.svelte +12 -20
- package/dist/components/composer/ComposerTextarea.svelte +1 -1
- package/dist/components/composer/ComposerToggle.svelte +16 -18
- 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 +3 -2
- package/dist/components/conversation/ConversationEmpty.svelte +1 -1
- package/dist/components/conversation/ConversationScrollButton.svelte +9 -11
- package/dist/components/dialog/ConfirmDialog.svelte +1 -1
- package/dist/components/dialog/DialogContent.svelte +5 -1
- package/dist/components/dialog/styles.d.ts +2 -26
- package/dist/components/dialog/styles.js +12 -49
- package/dist/components/divider/Divider.svelte +3 -3
- package/dist/components/empty-state/EmptyState.svelte +4 -5
- package/dist/components/field/Field.svelte +4 -4
- package/dist/components/frame/Frame.svelte +6 -7
- package/dist/components/frame/Frame.svelte.d.ts +1 -1
- package/dist/components/grid/Grid.svelte +111 -0
- package/dist/components/grid/Grid.svelte.d.ts +27 -0
- package/dist/components/heading/Heading.svelte +2 -2
- package/dist/components/hover-card/HoverCardContent.svelte +50 -0
- package/dist/components/hover-card/HoverCardContent.svelte.d.ts +10 -0
- package/dist/components/hover-card/HoverCardRoot.svelte +22 -0
- package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +5 -0
- package/dist/components/hover-card/index.d.ts +7 -0
- package/dist/components/hover-card/index.js +7 -0
- package/dist/components/kbd/Kbd.svelte +12 -7
- package/dist/components/link/Link.svelte +9 -7
- package/dist/components/link/Link.svelte.d.ts +4 -1
- 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 +134 -0
- package/dist/components/markdown/MarkdownFile.svelte.d.ts +19 -0
- package/dist/components/markdown/MarkdownFootnotes.svelte +61 -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 +265 -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 +328 -0
- package/dist/components/markdown/styles.js +302 -0
- package/dist/components/menu/MenuRadioItem.svelte +3 -3
- package/dist/components/menu/index.d.ts +23 -0
- package/dist/components/menu/index.js +3 -1
- package/dist/components/message/MessageAction.svelte +24 -5
- package/dist/components/message/MessageAction.svelte.d.ts +9 -0
- package/dist/components/message/MessageActions.svelte +2 -3
- package/dist/components/message/MessageContent.svelte +2 -3
- package/dist/components/message/MessageCopy.svelte +66 -8
- package/dist/components/message/MessageCopy.svelte.d.ts +17 -1
- package/dist/components/message/MessageHeader.svelte +3 -3
- package/dist/components/message/MessagePending.svelte +1 -1
- package/dist/components/message/MessageRoot.svelte +3 -4
- package/dist/components/message/MessageTime.svelte +3 -4
- package/dist/components/notice/Notice.svelte +14 -10
- package/dist/components/plan/Plan.svelte +25 -21
- package/dist/components/progress/Progress.svelte +34 -38
- package/dist/components/questionnaire/Questionnaire.svelte +19 -22
- package/dist/components/queued-message/QueuedMessage.svelte +14 -7
- package/dist/components/rail/RailItem.svelte +43 -40
- package/dist/components/rail/RailItem.svelte.d.ts +3 -1
- package/dist/components/rail/RailRoot.svelte +18 -4
- package/dist/components/rail/RailRoot.svelte.d.ts +1 -1
- 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 +4 -8
- package/dist/components/reasoning/ReasoningTrigger.svelte +4 -5
- package/dist/components/resize-handle/ResizeHandle.svelte +4 -7
- package/dist/components/reveal/Reveal.svelte +89 -0
- package/dist/components/reveal/Reveal.svelte.d.ts +17 -0
- package/dist/components/reveal/revealed.d.ts +38 -0
- package/dist/components/reveal/revealed.js +79 -0
- package/dist/components/segmented/SegmentedControl.svelte +11 -16
- package/dist/components/select/Select.svelte +1 -1
- package/dist/components/separator/Separator.svelte +1 -1
- package/dist/components/settings-row/SettingsRow.svelte +5 -5
- package/dist/components/sheet/SheetContent.svelte +63 -0
- package/dist/components/sheet/SheetContent.svelte.d.ts +18 -0
- package/dist/components/sheet/index.d.ts +12 -0
- package/dist/components/sheet/index.js +12 -0
- package/dist/components/sheet/styles.d.ts +51 -0
- package/dist/components/sheet/styles.js +65 -0
- package/dist/components/shimmer/Shimmer.svelte +41 -26
- package/dist/components/sidebar/SidebarContent.svelte +1 -1
- package/dist/components/sidebar/SidebarFolder.svelte +142 -0
- package/dist/components/sidebar/SidebarFolder.svelte.d.ts +19 -0
- package/dist/components/sidebar/SidebarFooter.svelte +1 -1
- package/dist/components/sidebar/SidebarGroup.svelte +41 -35
- package/dist/components/sidebar/SidebarGroup.svelte.d.ts +3 -3
- package/dist/components/sidebar/SidebarHeader.svelte +12 -6
- package/dist/components/sidebar/SidebarHeader.svelte.d.ts +4 -1
- package/dist/components/sidebar/SidebarItem.svelte +34 -38
- package/dist/components/sidebar/SidebarRoot.svelte +62 -0
- package/dist/components/sidebar/SidebarRoot.svelte.d.ts +14 -0
- package/dist/components/sidebar/index.d.ts +5 -1
- package/dist/components/sidebar/index.js +3 -1
- package/dist/components/skeleton/Skeleton.svelte +26 -15
- package/dist/components/slider/Slider.svelte +200 -0
- package/dist/components/slider/Slider.svelte.d.ts +55 -0
- package/dist/components/spinner/Spinner.svelte +4 -11
- package/dist/components/stack/Stack.svelte +37 -44
- package/dist/components/stack/Stack.svelte.d.ts +12 -6
- package/dist/components/status-indicator/StatusIndicator.svelte +1 -1
- package/dist/components/suggestions/SuggestionsItem.svelte +11 -13
- package/dist/components/switch/Switch.svelte +16 -25
- package/dist/components/tab-strip/TabStrip.svelte +340 -0
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +31 -0
- package/dist/components/tabs/Tabs.svelte +15 -14
- package/dist/components/tabs/Tabs.svelte.d.ts +4 -0
- package/dist/components/text/Text.svelte +64 -14
- package/dist/components/text/Text.svelte.d.ts +13 -3
- package/dist/components/toast/Toaster.svelte +12 -10
- package/dist/components/toggle/Toggle.svelte +40 -0
- package/dist/components/toggle/Toggle.svelte.d.ts +15 -0
- package/dist/components/toggle-group/ToggleGroupItem.svelte +37 -0
- package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +12 -0
- package/dist/components/toggle-group/ToggleGroupRoot.svelte +95 -0
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +33 -0
- package/dist/components/toggle-group/context.d.ts +6 -0
- package/dist/components/toggle-group/context.js +11 -0
- package/dist/components/toggle-group/index.d.ts +5 -0
- package/dist/components/toggle-group/index.js +3 -0
- package/dist/components/tool/ToolContent.svelte +3 -8
- package/dist/components/tool/ToolSection.svelte +4 -5
- package/dist/components/tool/ToolTrigger.svelte +14 -15
- package/dist/components/tooltip/TooltipContent.svelte +9 -6
- package/dist/components/work-fold/WorkFold.svelte +17 -34
- package/dist/components/work-fold/WorkFold.svelte.d.ts +1 -1
- package/dist/index.d.ts +38 -10
- package/dist/index.js +38 -12
- package/dist/internal/Chevron.svelte +2 -3
- package/dist/internal/Code.svelte +3 -4
- package/dist/internal/Collapse.svelte +6 -5
- package/dist/internal/Collapse.svelte.d.ts +2 -1
- package/dist/internal/Glyph.svelte +16 -0
- package/dist/internal/Glyph.svelte.d.ts +6 -0
- package/dist/internal/Tile.svelte +17 -37
- package/dist/internal/control.d.ts +4 -4
- package/dist/internal/control.js +21 -18
- package/dist/internal/layer.d.ts +3 -5
- package/dist/internal/layer.js +14 -18
- package/dist/internal/layout.d.ts +13 -0
- package/dist/internal/layout.js +453 -0
- package/dist/internal/markers.stylex.d.ts +8 -0
- package/dist/internal/markers.stylex.js +4 -0
- package/dist/internal/plugin-order.d.ts +8 -0
- package/dist/internal/plugin-order.js +16 -0
- package/dist/internal/responsive.d.ts +45 -0
- package/dist/internal/responsive.js +42 -0
- 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 +31 -4
- package/dist/internal/sx.js +17 -0
- package/dist/internal/toggle.d.ts +73 -0
- package/dist/internal/toggle.js +83 -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 +177 -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 +23 -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 +178 -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/media.stylex.d.ts +52 -0
- package/dist/media.stylex.js +53 -0
- package/dist/preset.d.ts +40 -16
- package/dist/preset.js +169 -51
- package/dist/tokens.stylex.d.ts +70 -37
- package/dist/tokens.stylex.js +127 -62
- package/dist/typography.d.ts +48 -0
- package/dist/typography.js +55 -0
- package/dist/vite.d.ts +9 -1
- package/dist/vite.js +37 -4
- package/package.json +58 -6
- package/skills/building-ui/SKILL.md +242 -0
- package/skills/building-ui/references/components.md +207 -0
- package/skills/markdown/SKILL.md +452 -0
- package/skills/markdown/references/plugins.md +103 -0
- package/skills/setup/SKILL.md +191 -0
- package/skills/styling/SKILL.md +269 -0
- package/skills/theming/SKILL.md +184 -0
- package/dist/internal/loop.d.ts +0 -35
- package/dist/internal/loop.js +0 -72
package/dist/internal/shared.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as stylex from '@stylexjs/stylex';
|
|
2
|
-
import { colors } from '../tokens.stylex.js';
|
|
2
|
+
import { colors, font, play } from '../tokens.stylex.js';
|
|
3
|
+
import { media } from '../media.stylex.js';
|
|
4
|
+
const turn = stylex.keyframes({ to: { rotate: '1turn' } });
|
|
5
|
+
// Focus as the keyboard gives it, or as the catalog shows it without a keyboard
|
|
6
|
+
const FOCUS = ':is(:focus-visible, [data-preview~="focus"])';
|
|
3
7
|
/**
|
|
4
8
|
* Edges in Narvi are drawn with shadows, which forced-colours mode removes.
|
|
5
9
|
* A transparent outline costs nothing normally and becomes the edge there.
|
|
@@ -8,13 +12,25 @@ export const shared = stylex.create({
|
|
|
8
12
|
// For anything that can take focus: the same outline turns into the focus ring.
|
|
9
13
|
focusable: {
|
|
10
14
|
outlineStyle: 'solid',
|
|
11
|
-
outlineWidth: { default: '1px',
|
|
12
|
-
outlineColor: { default: 'transparent',
|
|
13
|
-
outlineOffset: { default: '-1px',
|
|
15
|
+
outlineWidth: { default: '1px', [FOCUS]: '2px' },
|
|
16
|
+
outlineColor: { default: 'transparent', [FOCUS]: colors.focusRing },
|
|
17
|
+
outlineOffset: { default: '-1px', [FOCUS]: '2px' },
|
|
14
18
|
// In an Electron title bar, a control must not drag the window: it would
|
|
15
19
|
// never receive the click. Ignored everywhere else.
|
|
16
20
|
WebkitAppRegion: 'no-drag'
|
|
17
21
|
},
|
|
22
|
+
// A spinner's turn. It animates `rotate` and nothing else, so the compositor turns it,
|
|
23
|
+
// smoothly and at the display's rate, with no style or paint on the main thread. Narvi's
|
|
24
|
+
// other loops are stepped; a stepped spinner reads as slow. Slower, not still, for people
|
|
25
|
+
// who have asked for less motion: it still has to read as progress. Attach `whileVisible`
|
|
26
|
+
// to what takes this, so it turns only while it can be seen.
|
|
27
|
+
spin: {
|
|
28
|
+
animationName: turn,
|
|
29
|
+
animationDuration: { default: '2.4s', [media.motion]: '600ms' },
|
|
30
|
+
animationTimingFunction: 'linear',
|
|
31
|
+
animationIterationCount: 'infinite',
|
|
32
|
+
animationPlayState: play.whileVisible
|
|
33
|
+
},
|
|
18
34
|
// The parts of a window's title bar that drag the window, in Electron
|
|
19
35
|
dragRegion: {
|
|
20
36
|
WebkitAppRegion: 'drag',
|
|
@@ -29,7 +45,7 @@ export const shared = stylex.create({
|
|
|
29
45
|
eyebrow: {
|
|
30
46
|
margin: 0,
|
|
31
47
|
color: colors.textSubtle,
|
|
32
|
-
fontSize:
|
|
48
|
+
fontSize: font.sizeCaption,
|
|
33
49
|
fontWeight: '500',
|
|
34
50
|
lineHeight: 1.2,
|
|
35
51
|
fontVariantNumeric: 'tabular-nums'
|
package/dist/internal/sx.d.ts
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import type { StyleXArray, StyleXClassNameFor, StyleXStyles } from '@stylexjs/stylex';
|
|
2
2
|
import type { ClassValue } from 'svelte/elements';
|
|
3
3
|
/**
|
|
4
|
-
* A style that only sets custom properties, such as `{ '--primary': colors.
|
|
4
|
+
* A style that only sets custom properties, such as `{ '--primary': colors.accent }`.
|
|
5
5
|
* `StyleXStyles` lists the CSS properties it knows, and TypeScript rejects an object
|
|
6
6
|
* that shares none of them, so a style of custom properties alone needs its own type.
|
|
7
7
|
*/
|
|
8
8
|
type CustomProperties = Readonly<{
|
|
9
9
|
[name: `--${string}`]: StyleXClassNameFor<string, unknown>;
|
|
10
10
|
}>;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A marker, from `stylex.defaultMarker()` or a `stylex.defineMarker()` of your own. On an
|
|
13
|
+
* element, it makes that element the ancestor that `stylex.when.ancestor(':hover', marker)`
|
|
14
|
+
* in a descendant's styles waits on: a hover group.
|
|
15
|
+
*/
|
|
16
|
+
export type Marker = Readonly<{
|
|
17
|
+
marker: StyleXClassNameFor<'marker', unknown>;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Styles a consumer can pass to a component's `sx` prop: compiled StyleX styles, styles of
|
|
21
|
+
* custom properties alone, and markers, nested in arrays as deep as you like. `false`, `null`
|
|
22
|
+
* and `undefined` are skipped, so `cond && styles.x` works.
|
|
23
|
+
*/
|
|
24
|
+
export type Sx = StyleXArray<StyleXStyles | CustomProperties | Marker>;
|
|
25
|
+
type StyleArg = Sx | Readonly<Record<string, unknown>> | ReadonlyArray<StyleArg>;
|
|
14
26
|
/**
|
|
15
27
|
* Resolves StyleX styles to element attributes and appends a consumer `class`.
|
|
16
28
|
* Later styles win, so pass the consumer's `sx` last.
|
|
@@ -19,4 +31,19 @@ export declare function attrs(styles: ReadonlyArray<StyleArg>, className?: Class
|
|
|
19
31
|
class?: ClassValue;
|
|
20
32
|
style?: string;
|
|
21
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Styles as attributes to spread onto an element or a component that takes `class` and
|
|
36
|
+
* `style` but no `sx`: `<Mark {...sx(styles.mark, active && styles.lit)} />`. Like `sx`,
|
|
37
|
+
* it takes markers, and later styles win.
|
|
38
|
+
*/
|
|
39
|
+
export declare function sx(...styles: ReadonlyArray<Sx>): {
|
|
40
|
+
class?: string;
|
|
41
|
+
style?: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Styles as one class string, for a prop that takes only a class, such as `iconClass`, or
|
|
45
|
+
* for joining with classes of your own. Empty when no style applies. Dynamic styles (those
|
|
46
|
+
* created from a function) also set inline `style`, which this drops; use `sx()` for those.
|
|
47
|
+
*/
|
|
48
|
+
export declare function classes(...styles: ReadonlyArray<Sx>): string;
|
|
22
49
|
export {};
|
package/dist/internal/sx.js
CHANGED
|
@@ -9,3 +9,20 @@ export function attrs(styles, className) {
|
|
|
9
9
|
return resolved;
|
|
10
10
|
return { ...resolved, class: [resolved.class, className] };
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Styles as attributes to spread onto an element or a component that takes `class` and
|
|
14
|
+
* `style` but no `sx`: `<Mark {...sx(styles.mark, active && styles.lit)} />`. Like `sx`,
|
|
15
|
+
* it takes markers, and later styles win.
|
|
16
|
+
*/
|
|
17
|
+
export function sx(...styles) {
|
|
18
|
+
const { class: className, style } = stylex.attrs(...styles);
|
|
19
|
+
return { ...(className ? { class: className } : {}), ...(style ? { style } : {}) };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Styles as one class string, for a prop that takes only a class, such as `iconClass`, or
|
|
23
|
+
* for joining with classes of your own. Empty when no style applies. Dynamic styles (those
|
|
24
|
+
* created from a function) also set inline `style`, which this drops; use `sx()` for those.
|
|
25
|
+
*/
|
|
26
|
+
export function classes(...styles) {
|
|
27
|
+
return stylex.attrs(...styles).class ?? '';
|
|
28
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The look of a button that stays pressed: Toggle, and the items of a
|
|
3
|
+
* ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
|
|
4
|
+
* the accent, the one colour that marks state, as Composer's toggles are.
|
|
5
|
+
*/
|
|
6
|
+
import * as stylex from '@stylexjs/stylex';
|
|
7
|
+
export declare const toggle: Readonly<{
|
|
8
|
+
readonly base: Readonly<{
|
|
9
|
+
readonly position: stylex.StyleXClassNameFor<"position", "relative">;
|
|
10
|
+
readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
|
|
11
|
+
readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
|
|
12
|
+
readonly justifyContent: stylex.StyleXClassNameFor<"justifyContent", "center">;
|
|
13
|
+
readonly flexShrink: stylex.StyleXClassNameFor<"flexShrink", 0>;
|
|
14
|
+
readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
|
|
15
|
+
readonly margin: stylex.StyleXClassNameFor<"margin", 0>;
|
|
16
|
+
readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 0>;
|
|
17
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string | null>;
|
|
18
|
+
readonly color: stylex.StyleXClassNameFor<"color", string | null>;
|
|
19
|
+
readonly fontFamily: stylex.StyleXClassNameFor<"fontFamily", string>;
|
|
20
|
+
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
|
|
21
|
+
readonly lineHeight: stylex.StyleXClassNameFor<"lineHeight", 1>;
|
|
22
|
+
readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
|
|
23
|
+
readonly cursor: stylex.StyleXClassNameFor<"cursor", "pointer" | "not-allowed">;
|
|
24
|
+
readonly opacity: stylex.StyleXClassNameFor<"opacity", 1 | 0.5>;
|
|
25
|
+
readonly userSelect: stylex.StyleXClassNameFor<"userSelect", "none">;
|
|
26
|
+
readonly appearance: stylex.StyleXClassNameFor<"appearance", "none">;
|
|
27
|
+
readonly WebkitTapHighlightColor: stylex.StyleXClassNameFor<"WebkitTapHighlightColor", "transparent">;
|
|
28
|
+
readonly WebkitAppRegion: stylex.StyleXClassNameFor<"WebkitAppRegion", "no-drag">;
|
|
29
|
+
readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "solid">;
|
|
30
|
+
readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", "1px" | "2px">;
|
|
31
|
+
readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", string>;
|
|
32
|
+
readonly outlineOffset: stylex.StyleXClassNameFor<"outlineOffset", "2px" | "-1px">;
|
|
33
|
+
readonly scale: stylex.StyleXClassNameFor<"scale", 0.96 | null>;
|
|
34
|
+
readonly transitionProperty: stylex.StyleXClassNameFor<"transitionProperty", "background-color, color, box-shadow" | "scale, background-color, color, box-shadow">;
|
|
35
|
+
readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
|
|
36
|
+
readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", "ease" | `${stylex.StyleXVar<string>}, ease, ease, ease`>;
|
|
37
|
+
}>;
|
|
38
|
+
readonly sm: Readonly<{
|
|
39
|
+
readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "1.75rem">;
|
|
40
|
+
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.625rem">;
|
|
41
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", "0.375rem">;
|
|
42
|
+
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
|
43
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
44
|
+
readonly '::after': stylex.StyleXClassNameFor<"::after", {
|
|
45
|
+
readonly content: "\"\"";
|
|
46
|
+
readonly position: "absolute";
|
|
47
|
+
readonly insetInline: 0;
|
|
48
|
+
readonly insetBlock: "-6px";
|
|
49
|
+
}>;
|
|
50
|
+
}>;
|
|
51
|
+
readonly md: Readonly<{
|
|
52
|
+
readonly minHeight: stylex.StyleXClassNameFor<"minHeight", "2rem">;
|
|
53
|
+
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.75rem">;
|
|
54
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", "0.4375rem">;
|
|
55
|
+
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
|
56
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
57
|
+
readonly '::after': stylex.StyleXClassNameFor<"::after", {
|
|
58
|
+
readonly content: "\"\"";
|
|
59
|
+
readonly position: "absolute";
|
|
60
|
+
readonly insetInline: 0;
|
|
61
|
+
readonly insetBlock: "-4px";
|
|
62
|
+
}>;
|
|
63
|
+
}>;
|
|
64
|
+
readonly iconSm: Readonly<{
|
|
65
|
+
readonly width: stylex.StyleXClassNameFor<"width", "1.75rem">;
|
|
66
|
+
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 0>;
|
|
67
|
+
}>;
|
|
68
|
+
readonly iconMd: Readonly<{
|
|
69
|
+
readonly width: stylex.StyleXClassNameFor<"width", "2rem">;
|
|
70
|
+
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 0>;
|
|
71
|
+
}>;
|
|
72
|
+
}>;
|
|
73
|
+
export type ToggleSize = 'sm' | 'md';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The look of a button that stays pressed: Toggle, and the items of a
|
|
3
|
+
* ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
|
|
4
|
+
* the accent, the one colour that marks state, as Composer's toggles are.
|
|
5
|
+
*/
|
|
6
|
+
import * as stylex from '@stylexjs/stylex';
|
|
7
|
+
import { colors, font, motion, radius } from '../tokens.stylex.js';
|
|
8
|
+
import { media } from '../media.stylex.js';
|
|
9
|
+
const ON = ':is([data-state="on"])';
|
|
10
|
+
const DISABLED = ':is([data-disabled])';
|
|
11
|
+
export const toggle = stylex.create({
|
|
12
|
+
base: {
|
|
13
|
+
position: 'relative',
|
|
14
|
+
display: 'inline-flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
flexShrink: 0,
|
|
18
|
+
boxSizing: 'border-box',
|
|
19
|
+
margin: 0,
|
|
20
|
+
borderWidth: 0,
|
|
21
|
+
backgroundColor: {
|
|
22
|
+
default: 'transparent',
|
|
23
|
+
':hover': { default: null, [media.hover]: colors.fillHover },
|
|
24
|
+
[ON]: {
|
|
25
|
+
default: colors.accentSoft,
|
|
26
|
+
':hover': { default: null, [media.hover]: colors.focusHalo }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
color: {
|
|
30
|
+
default: colors.textMuted,
|
|
31
|
+
':hover': { default: null, [media.hover]: colors.text },
|
|
32
|
+
[ON]: { default: colors.accent, ':hover': colors.accent, [media.forcedColors]: 'Highlight' }
|
|
33
|
+
},
|
|
34
|
+
fontFamily: font.body,
|
|
35
|
+
fontWeight: font.weightMedium,
|
|
36
|
+
lineHeight: 1,
|
|
37
|
+
whiteSpace: 'nowrap',
|
|
38
|
+
cursor: { default: 'pointer', [DISABLED]: 'not-allowed' },
|
|
39
|
+
opacity: { default: 1, [DISABLED]: 0.5 },
|
|
40
|
+
userSelect: 'none',
|
|
41
|
+
appearance: 'none',
|
|
42
|
+
WebkitTapHighlightColor: 'transparent',
|
|
43
|
+
WebkitAppRegion: 'no-drag',
|
|
44
|
+
// In forced colours a pressed toggle keeps a frame, as the lit wash is gone
|
|
45
|
+
outlineStyle: 'solid',
|
|
46
|
+
outlineWidth: { default: '1px', ':focus-visible': '2px' },
|
|
47
|
+
outlineColor: {
|
|
48
|
+
default: 'transparent',
|
|
49
|
+
[ON]: { default: 'transparent', [media.forcedColors]: 'Highlight' },
|
|
50
|
+
':focus-visible': colors.focusRing
|
|
51
|
+
},
|
|
52
|
+
outlineOffset: { default: '-1px', ':focus-visible': '2px' },
|
|
53
|
+
scale: { default: null, ':active': { default: null, [media.motion]: 0.96 } },
|
|
54
|
+
transitionProperty: {
|
|
55
|
+
default: 'background-color, color, box-shadow',
|
|
56
|
+
[media.motion]: 'scale, background-color, color, box-shadow'
|
|
57
|
+
},
|
|
58
|
+
transitionDuration: motion.base,
|
|
59
|
+
transitionTimingFunction: {
|
|
60
|
+
default: 'ease',
|
|
61
|
+
[media.motion]: `${motion.easeOut}, ease, ease, ease`
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
// The same heights as Button's, and the same 40px reach for a finger
|
|
65
|
+
sm: {
|
|
66
|
+
minHeight: '1.75rem',
|
|
67
|
+
paddingInline: '0.625rem',
|
|
68
|
+
gap: '0.375rem',
|
|
69
|
+
borderRadius: radius.item,
|
|
70
|
+
fontSize: font.sizeMeta,
|
|
71
|
+
'::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-6px' }
|
|
72
|
+
},
|
|
73
|
+
md: {
|
|
74
|
+
minHeight: '2rem',
|
|
75
|
+
paddingInline: '0.75rem',
|
|
76
|
+
gap: '0.4375rem',
|
|
77
|
+
borderRadius: radius.control,
|
|
78
|
+
fontSize: font.sizeBody,
|
|
79
|
+
'::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-4px' }
|
|
80
|
+
},
|
|
81
|
+
iconSm: { width: '1.75rem', paddingInline: 0 },
|
|
82
|
+
iconMd: { width: '2rem', paddingInline: 0 }
|
|
83
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lets an animation that never ends run only while it can be seen.
|
|
3
|
+
*
|
|
4
|
+
* Such an animation costs something for as long as it runs: a shimmer three
|
|
5
|
+
* screens up the conversation, or in a window behind another, is paid for and
|
|
6
|
+
* never looked at. So every one of Narvi's reads its play state from a custom
|
|
7
|
+
* property, and this sets that property: running while the element is in the
|
|
8
|
+
* viewport and the document is showing, paused otherwise.
|
|
9
|
+
*
|
|
10
|
+
* The animations themselves are stepped (`steps(30)` over two seconds, say), so
|
|
11
|
+
* the compositor draws a handful of frames a second, not one for every refresh
|
|
12
|
+
* of the display. A spinner is the exception: it has to turn smoothly, so it is
|
|
13
|
+
* a plain rotation, and only the pausing applies to it.
|
|
14
|
+
*
|
|
15
|
+
* Without this the animation runs: the property's fallback is `running`.
|
|
16
|
+
*
|
|
17
|
+
* ```svelte
|
|
18
|
+
* <span {@attach whileVisible} {...stylex.attrs(styles.pulse)}></span>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* pulse: {
|
|
23
|
+
* animationName: pulse,
|
|
24
|
+
* animationDuration: '2s',
|
|
25
|
+
* animationTimingFunction: 'steps(12)',
|
|
26
|
+
* animationIterationCount: 'infinite',
|
|
27
|
+
* animationPlayState: play.whileVisible // from tokens.stylex.js
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
import type { Attachment } from 'svelte/attachments';
|
|
32
|
+
export declare const whileVisible: Attachment<HTMLElement | SVGElement>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const watched = new Map();
|
|
2
|
+
let observer = null;
|
|
3
|
+
function apply(item) {
|
|
4
|
+
const running = item.inView && !document.hidden;
|
|
5
|
+
item.element.style.setProperty('--narvi-play', running ? 'running' : 'paused');
|
|
6
|
+
}
|
|
7
|
+
function applyAll() {
|
|
8
|
+
for (const item of watched.values())
|
|
9
|
+
apply(item);
|
|
10
|
+
}
|
|
11
|
+
export const whileVisible = (element) => {
|
|
12
|
+
// Nothing to watch with: leave the animation running, as it would without this
|
|
13
|
+
if (typeof IntersectionObserver === 'undefined')
|
|
14
|
+
return;
|
|
15
|
+
if (observer === null) {
|
|
16
|
+
observer = new IntersectionObserver((entries) => {
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
const item = watched.get(entry.target);
|
|
19
|
+
if (!item)
|
|
20
|
+
continue;
|
|
21
|
+
item.inView = entry.isIntersecting;
|
|
22
|
+
apply(item);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
document.addEventListener('visibilitychange', applyAll);
|
|
26
|
+
}
|
|
27
|
+
const item = { element, inView: false };
|
|
28
|
+
watched.set(element, item);
|
|
29
|
+
// Paused until the observer has looked, which it does before the next frame is drawn
|
|
30
|
+
apply(item);
|
|
31
|
+
observer.observe(element);
|
|
32
|
+
return () => {
|
|
33
|
+
if (watched.get(element) !== item)
|
|
34
|
+
return;
|
|
35
|
+
watched.delete(element);
|
|
36
|
+
observer?.unobserve(element);
|
|
37
|
+
element.style.removeProperty('--narvi-play');
|
|
38
|
+
if (watched.size === 0) {
|
|
39
|
+
observer?.disconnect();
|
|
40
|
+
observer = null;
|
|
41
|
+
document.removeEventListener('visibilitychange', applyAll);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Markdown document tree.
|
|
3
|
+
*
|
|
4
|
+
* Every block has an `id` that is stable for as long as the block exists: while a reply
|
|
5
|
+
* streams, a block that is already finished keeps both its id and its object, so a renderer
|
|
6
|
+
* keyed by id never touches it again. Inline nodes have no ids; they belong to their block.
|
|
7
|
+
*
|
|
8
|
+
* A block's `from` and `to` are offsets into the source text, `to` exclusive.
|
|
9
|
+
*/
|
|
10
|
+
export type Point = {
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
};
|
|
14
|
+
export type Document = Point & {
|
|
15
|
+
type: 'document';
|
|
16
|
+
id: number;
|
|
17
|
+
children: Block[];
|
|
18
|
+
/** Footnote definitions, in the order they are first referenced. */
|
|
19
|
+
footnotes: FootnoteDefinition[];
|
|
20
|
+
/**
|
|
21
|
+
* The YAML front matter a file starts with, between its `---` lines, as written. Read only
|
|
22
|
+
* with the `frontmatter` option, and then left out of `children`.
|
|
23
|
+
*/
|
|
24
|
+
frontmatter?: string;
|
|
25
|
+
};
|
|
26
|
+
export type Paragraph = Point & {
|
|
27
|
+
type: 'paragraph';
|
|
28
|
+
id: number;
|
|
29
|
+
children: Inline[];
|
|
30
|
+
};
|
|
31
|
+
export type Heading = Point & {
|
|
32
|
+
type: 'heading';
|
|
33
|
+
id: number;
|
|
34
|
+
depth: 1 | 2 | 3 | 4 | 5 | 6;
|
|
35
|
+
children: Inline[];
|
|
36
|
+
};
|
|
37
|
+
export type ThematicBreak = Point & {
|
|
38
|
+
type: 'thematicBreak';
|
|
39
|
+
id: number;
|
|
40
|
+
};
|
|
41
|
+
/** The kinds of GitHub alert: a block quote that opens with `[!NOTE]` and the like. */
|
|
42
|
+
export type AlertKind = 'note' | 'tip' | 'important' | 'warning' | 'caution';
|
|
43
|
+
export type Blockquote = Point & {
|
|
44
|
+
type: 'blockquote';
|
|
45
|
+
id: number;
|
|
46
|
+
/** Set when the quote is a GitHub alert; its `[!NOTE]` line is then left out of the children. */
|
|
47
|
+
alert?: AlertKind;
|
|
48
|
+
children: Block[];
|
|
49
|
+
};
|
|
50
|
+
export type List = Point & {
|
|
51
|
+
type: 'list';
|
|
52
|
+
id: number;
|
|
53
|
+
ordered: boolean;
|
|
54
|
+
/** The first number of an ordered list. */
|
|
55
|
+
start: number | null;
|
|
56
|
+
/** A tight list has no blank lines between its items; its paragraphs are not wrapped. */
|
|
57
|
+
tight: boolean;
|
|
58
|
+
children: ListItem[];
|
|
59
|
+
};
|
|
60
|
+
export type ListItem = Point & {
|
|
61
|
+
type: 'listItem';
|
|
62
|
+
id: number;
|
|
63
|
+
/** A GFM task item: `[ ]` is false, `[x]` is true. Null for an ordinary item. */
|
|
64
|
+
checked: boolean | null;
|
|
65
|
+
/** Where the `[` of a task item's `[ ]` is in the source, for ticking it there. Null otherwise. */
|
|
66
|
+
checkedAt: number | null;
|
|
67
|
+
children: Block[];
|
|
68
|
+
};
|
|
69
|
+
export type CodeBlock = Point & {
|
|
70
|
+
type: 'code';
|
|
71
|
+
id: number;
|
|
72
|
+
/** The first word of the info string, unescaped. */
|
|
73
|
+
lang: string | null;
|
|
74
|
+
/** The rest of the info string. */
|
|
75
|
+
meta: string | null;
|
|
76
|
+
value: string;
|
|
77
|
+
/** True for a fenced block that has not seen its closing fence yet. */
|
|
78
|
+
open: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type HtmlBlock = Point & {
|
|
81
|
+
type: 'html';
|
|
82
|
+
id: number;
|
|
83
|
+
value: string;
|
|
84
|
+
};
|
|
85
|
+
/** A formula set on lines of its own, between `$$` and `$$` or `\\[` and `\\]`. */
|
|
86
|
+
export type MathBlock = Point & {
|
|
87
|
+
type: 'math';
|
|
88
|
+
id: number;
|
|
89
|
+
/** The TeX source, without its delimiters. */
|
|
90
|
+
value: string;
|
|
91
|
+
/** True until its closing delimiter arrives. */
|
|
92
|
+
open: boolean;
|
|
93
|
+
};
|
|
94
|
+
export type Table = Point & {
|
|
95
|
+
type: 'table';
|
|
96
|
+
id: number;
|
|
97
|
+
align: Array<'left' | 'right' | 'center' | null>;
|
|
98
|
+
/** True while more rows may still arrive. */
|
|
99
|
+
open: boolean;
|
|
100
|
+
/** The first row is the header. */
|
|
101
|
+
children: TableRow[];
|
|
102
|
+
};
|
|
103
|
+
export type TableRow = Point & {
|
|
104
|
+
type: 'tableRow';
|
|
105
|
+
id: number;
|
|
106
|
+
children: TableCell[];
|
|
107
|
+
};
|
|
108
|
+
export type TableCell = Point & {
|
|
109
|
+
type: 'tableCell';
|
|
110
|
+
id: number;
|
|
111
|
+
/** The cell as written, trimmed, with `\\|` read as a pipe. */
|
|
112
|
+
source: string;
|
|
113
|
+
children: Inline[];
|
|
114
|
+
};
|
|
115
|
+
export type FootnoteDefinition = Point & {
|
|
116
|
+
type: 'footnoteDefinition';
|
|
117
|
+
id: number;
|
|
118
|
+
/** The label as written. */
|
|
119
|
+
label: string;
|
|
120
|
+
children: Block[];
|
|
121
|
+
};
|
|
122
|
+
export type Block = Paragraph | Heading | ThematicBreak | Blockquote | List | ListItem | CodeBlock | HtmlBlock | MathBlock | Table | FootnoteDefinition;
|
|
123
|
+
export type Text = {
|
|
124
|
+
type: 'text';
|
|
125
|
+
value: string;
|
|
126
|
+
};
|
|
127
|
+
export type Emphasis = {
|
|
128
|
+
type: 'emphasis';
|
|
129
|
+
children: Inline[];
|
|
130
|
+
};
|
|
131
|
+
export type Strong = {
|
|
132
|
+
type: 'strong';
|
|
133
|
+
children: Inline[];
|
|
134
|
+
};
|
|
135
|
+
export type Delete = {
|
|
136
|
+
type: 'delete';
|
|
137
|
+
children: Inline[];
|
|
138
|
+
};
|
|
139
|
+
export type InlineCode = {
|
|
140
|
+
type: 'inlineCode';
|
|
141
|
+
value: string;
|
|
142
|
+
};
|
|
143
|
+
export type Break = {
|
|
144
|
+
type: 'break';
|
|
145
|
+
};
|
|
146
|
+
export type SoftBreak = {
|
|
147
|
+
type: 'softBreak';
|
|
148
|
+
};
|
|
149
|
+
export type InlineHtml = {
|
|
150
|
+
type: 'inlineHtml';
|
|
151
|
+
value: string;
|
|
152
|
+
};
|
|
153
|
+
/** A formula in running text: `$x$` or `\\(x\\)`, and `$$x$$` or `\\[x\\]` with `display`. */
|
|
154
|
+
export type InlineMath = {
|
|
155
|
+
type: 'inlineMath';
|
|
156
|
+
value: string;
|
|
157
|
+
display: boolean;
|
|
158
|
+
};
|
|
159
|
+
export type Link = {
|
|
160
|
+
type: 'link';
|
|
161
|
+
url: string;
|
|
162
|
+
title: string | null;
|
|
163
|
+
children: Inline[];
|
|
164
|
+
/** How it was written: `[a](b)`, `[a][b]`, `<https://…>` or a bare `www.…`. */
|
|
165
|
+
kind: 'inline' | 'reference' | 'autolink' | 'literal';
|
|
166
|
+
/**
|
|
167
|
+
* A link whose address is still being written, in a tidied preview: `[the docs](https://na`.
|
|
168
|
+
* It has its words and no address yet. Drawn as a link that goes nowhere.
|
|
169
|
+
*/
|
|
170
|
+
pending?: boolean;
|
|
171
|
+
};
|
|
172
|
+
export type Image = {
|
|
173
|
+
type: 'image';
|
|
174
|
+
url: string;
|
|
175
|
+
title: string | null;
|
|
176
|
+
/** The alt text, as plain text. */
|
|
177
|
+
alt: string;
|
|
178
|
+
/** The size an HTML `<img>` asked for. A Markdown image has none. */
|
|
179
|
+
width?: string;
|
|
180
|
+
height?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Whether it is a video: an HTML `<video>`, or an image a transform marked as one, such
|
|
183
|
+
* as a link to an `.mp4`. It is drawn with controls, and nothing of it loads until it is played.
|
|
184
|
+
*/
|
|
185
|
+
video?: boolean;
|
|
186
|
+
children: Inline[];
|
|
187
|
+
};
|
|
188
|
+
/** A reference to a footnote. Its number comes from the document's `footnotes`, in order. */
|
|
189
|
+
export type FootnoteReference = {
|
|
190
|
+
type: 'footnoteReference';
|
|
191
|
+
label: string;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* A node a plugin's transform puts in: a file chip, a mention. The plugin's component for
|
|
195
|
+
* `name` draws it; without one, its children show.
|
|
196
|
+
*/
|
|
197
|
+
export type InlineCustom = {
|
|
198
|
+
type: 'custom';
|
|
199
|
+
name: string;
|
|
200
|
+
data: Readonly<Record<string, unknown>>;
|
|
201
|
+
children: Inline[];
|
|
202
|
+
};
|
|
203
|
+
export type Inline = Text | Emphasis | Strong | Delete | InlineCode | Break | SoftBreak | InlineHtml | InlineMath | Link | Image | FootnoteReference | InlineCustom;
|
|
204
|
+
export type Node = Document | Block | TableRow | TableCell | Inline;
|
|
205
|
+
/** A link reference definition: `[label]: url "title"`. */
|
|
206
|
+
export type Definition = {
|
|
207
|
+
url: string;
|
|
208
|
+
title: string | null;
|
|
209
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Markdown document tree.
|
|
3
|
+
*
|
|
4
|
+
* Every block has an `id` that is stable for as long as the block exists: while a reply
|
|
5
|
+
* streams, a block that is already finished keeps both its id and its object, so a renderer
|
|
6
|
+
* keyed by id never touches it again. Inline nodes have no ids; they belong to their block.
|
|
7
|
+
*
|
|
8
|
+
* A block's `from` and `to` are offsets into the source text, `to` exclusive.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|