@agimon-ai/po-native-components 0.0.0-alpha.21 → 0.0.0-alpha.211
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/LICENSE +21 -149
- package/README.md +9 -51
- package/dist/components/AgentAvatar.d.mts +19 -0
- package/dist/components/AgentAvatar.d.mts.map +1 -0
- package/dist/components/AgentAvatar.mjs +88 -0
- package/dist/components/AgentAvatar.mjs.map +1 -0
- package/dist/components/AnnotationSurface.d.mts +69 -0
- package/dist/components/AnnotationSurface.d.mts.map +1 -0
- package/dist/components/AnnotationSurface.mjs +431 -0
- package/dist/components/AnnotationSurface.mjs.map +1 -0
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.mjs +1 -1
- package/dist/components/Button.mjs +3 -3
- package/dist/components/Button.mjs.map +1 -1
- package/dist/components/CodeBlock.d.mts +3 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +42 -47
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/ComputerRow.d.mts +15 -0
- package/dist/components/ComputerRow.d.mts.map +1 -0
- package/dist/components/ComputerRow.mjs +107 -0
- package/dist/components/ComputerRow.mjs.map +1 -0
- package/dist/components/CopyButton.d.mts +13 -0
- package/dist/components/CopyButton.d.mts.map +1 -0
- package/dist/components/CopyButton.mjs +49 -0
- package/dist/components/CopyButton.mjs.map +1 -0
- package/dist/components/CountBadge.d.mts +15 -0
- package/dist/components/CountBadge.d.mts.map +1 -0
- package/dist/components/CountBadge.mjs +49 -0
- package/dist/components/CountBadge.mjs.map +1 -0
- package/dist/components/CtaCard.d.mts +19 -0
- package/dist/components/CtaCard.d.mts.map +1 -0
- package/dist/components/CtaCard.mjs +92 -0
- package/dist/components/CtaCard.mjs.map +1 -0
- package/dist/components/Dialog.d.mts +2 -2
- package/dist/components/Dialog.d.mts.map +1 -1
- package/dist/components/Dialog.mjs +16 -10
- package/dist/components/Dialog.mjs.map +1 -1
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +2 -2
- package/dist/components/DropdownMenu.d.mts +3 -1
- package/dist/components/DropdownMenu.d.mts.map +1 -1
- package/dist/components/DropdownMenu.mjs +21 -14
- package/dist/components/DropdownMenu.mjs.map +1 -1
- package/dist/components/EmptyState.d.mts +31 -3
- package/dist/components/EmptyState.d.mts.map +1 -1
- package/dist/components/EmptyState.mjs +303 -29
- package/dist/components/EmptyState.mjs.map +1 -1
- package/dist/components/FileList.d.mts +48 -0
- package/dist/components/FileList.d.mts.map +1 -0
- package/dist/components/FileList.mjs +737 -0
- package/dist/components/FileList.mjs.map +1 -0
- package/dist/components/FilePreview.d.mts +33 -0
- package/dist/components/FilePreview.d.mts.map +1 -0
- package/dist/components/FilePreview.mjs +102 -0
- package/dist/components/FilePreview.mjs.map +1 -0
- package/dist/components/FileViewer.d.mts +57 -0
- package/dist/components/FileViewer.d.mts.map +1 -0
- package/dist/components/FileViewer.mjs +345 -0
- package/dist/components/FileViewer.mjs.map +1 -0
- package/dist/components/HashlineLines.d.mts +13 -0
- package/dist/components/HashlineLines.d.mts.map +1 -0
- package/dist/components/HashlineLines.mjs +153 -0
- package/dist/components/HashlineLines.mjs.map +1 -0
- package/dist/components/HostFilter.d.mts +17 -0
- package/dist/components/HostFilter.d.mts.map +1 -0
- package/dist/components/HostFilter.mjs +68 -0
- package/dist/components/HostFilter.mjs.map +1 -0
- package/dist/components/HostTag.d.mts +7 -0
- package/dist/components/HostTag.d.mts.map +1 -0
- package/dist/components/HostTag.mjs +48 -0
- package/dist/components/HostTag.mjs.map +1 -0
- package/dist/components/InfoStrip.d.mts +9 -0
- package/dist/components/InfoStrip.d.mts.map +1 -0
- package/dist/components/InfoStrip.mjs +53 -0
- package/dist/components/InfoStrip.mjs.map +1 -0
- package/dist/components/Input.d.mts +3 -1
- package/dist/components/Input.d.mts.map +1 -1
- package/dist/components/Input.mjs +4 -3
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Label.mjs +1 -1
- package/dist/components/LinkText.d.mts +13 -0
- package/dist/components/LinkText.d.mts.map +1 -0
- package/dist/components/LinkText.mjs +32 -0
- package/dist/components/LinkText.mjs.map +1 -0
- package/dist/components/List.d.mts.map +1 -1
- package/dist/components/List.mjs +50 -11
- package/dist/components/List.mjs.map +1 -1
- package/dist/components/LiveDuration.d.mts +30 -0
- package/dist/components/LiveDuration.d.mts.map +1 -0
- package/dist/components/LiveDuration.mjs +67 -0
- package/dist/components/LiveDuration.mjs.map +1 -0
- package/dist/components/LoadingState.d.mts +17 -0
- package/dist/components/LoadingState.d.mts.map +1 -0
- package/dist/components/LoadingState.mjs +90 -0
- package/dist/components/LoadingState.mjs.map +1 -0
- package/dist/components/Markdown.d.mts +24 -2
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +356 -27
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts +10 -15
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +94 -68
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/NativeShellState.d.mts +30 -0
- package/dist/components/NativeShellState.d.mts.map +1 -0
- package/dist/components/NativeShellState.mjs +61 -0
- package/dist/components/NativeShellState.mjs.map +1 -0
- package/dist/components/RailItem.d.mts +13 -0
- package/dist/components/RailItem.d.mts.map +1 -0
- package/dist/components/RailItem.mjs +61 -0
- package/dist/components/RailItem.mjs.map +1 -0
- package/dist/components/ReferenceChip.d.mts +18 -0
- package/dist/components/ReferenceChip.d.mts.map +1 -0
- package/dist/components/ReferenceChip.mjs +38 -0
- package/dist/components/ReferenceChip.mjs.map +1 -0
- package/dist/components/SectionLabel.mjs +1 -1
- package/dist/components/SeekBar.d.mts +17 -0
- package/dist/components/SeekBar.d.mts.map +1 -0
- package/dist/components/SeekBar.mjs +97 -0
- package/dist/components/SeekBar.mjs.map +1 -0
- package/dist/components/Select.d.mts +39 -0
- package/dist/components/Select.d.mts.map +1 -0
- package/dist/components/Select.mjs +288 -0
- package/dist/components/Select.mjs.map +1 -0
- package/dist/components/Sheet.d.mts +17 -2
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +34 -11
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/SheetFrame.mjs +149 -28
- package/dist/components/SheetFrame.mjs.map +1 -1
- package/dist/components/SheetList.d.mts +14 -0
- package/dist/components/SheetList.d.mts.map +1 -0
- package/dist/components/SheetList.mjs +34 -0
- package/dist/components/SheetList.mjs.map +1 -0
- package/dist/components/ShowMore.d.mts +10 -0
- package/dist/components/ShowMore.d.mts.map +1 -0
- package/dist/components/ShowMore.mjs +44 -0
- package/dist/components/ShowMore.mjs.map +1 -0
- package/dist/components/Spinner.d.mts +1 -1
- package/dist/components/StatusBadge.d.mts +1 -1
- package/dist/components/Switch.d.mts +14 -0
- package/dist/components/Switch.d.mts.map +1 -0
- package/dist/components/Switch.mjs +37 -0
- package/dist/components/Switch.mjs.map +1 -0
- package/dist/components/SyntaxLine.d.mts +19 -0
- package/dist/components/SyntaxLine.d.mts.map +1 -0
- package/dist/components/SyntaxLine.mjs +134 -0
- package/dist/components/SyntaxLine.mjs.map +1 -0
- package/dist/components/Tabs.d.mts.map +1 -1
- package/dist/components/Tabs.mjs +8 -7
- package/dist/components/Tabs.mjs.map +1 -1
- package/dist/components/ToolPathLink.d.mts +10 -0
- package/dist/components/ToolPathLink.d.mts.map +1 -0
- package/dist/components/ToolPathLink.mjs +42 -0
- package/dist/components/ToolPathLink.mjs.map +1 -0
- package/dist/components/ToolResultImage.d.mts +21 -0
- package/dist/components/ToolResultImage.d.mts.map +1 -0
- package/dist/components/ToolResultImage.mjs +60 -0
- package/dist/components/ToolResultImage.mjs.map +1 -0
- package/dist/icons/IconColorContext.d.mts +2 -1
- package/dist/icons/IconColorContext.d.mts.map +1 -1
- package/dist/icons/IconColorContext.mjs.map +1 -1
- package/dist/icons/iconGlyphs.d.mts +132 -0
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +132 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +133 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +35 -2
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +31 -7
- package/dist/index.mjs +36 -12
- package/dist/lib/fileKindLabel.mjs +17 -0
- package/dist/lib/fileKindLabel.mjs.map +1 -0
- package/dist/lib/fonts.d.mts +3 -1
- package/dist/lib/fonts.d.mts.map +1 -1
- package/dist/lib/fonts.mjs +4 -2
- package/dist/lib/fonts.mjs.map +1 -1
- package/dist/lib/insideSheet.d.mts +10 -0
- package/dist/lib/insideSheet.d.mts.map +1 -0
- package/dist/lib/markdown.mjs +310 -23
- package/dist/lib/markdown.mjs.map +1 -1
- package/dist/lib/reading.mjs +60 -0
- package/dist/lib/reading.mjs.map +1 -0
- package/dist/lib/useControllable.mjs +14 -6
- package/dist/lib/useControllable.mjs.map +1 -1
- package/dist/lib/useReadingPage.mjs +33 -0
- package/dist/lib/useReadingPage.mjs.map +1 -0
- package/dist/po-runtime-identity.json +1 -0
- package/dist/shell.d.mts +6 -0
- package/dist/shell.mjs +7 -0
- package/locales/vi.json +112 -0
- package/locales/zh-CN.json +112 -0
- package/package.json +43 -30
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,52 @@
|
|
|
1
1
|
import { fontOf } from "./lib/fonts.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Dot } from "./components/Dot.mjs";
|
|
3
|
+
import { AgentAvatar, agentInitials, tintFor } from "./components/AgentAvatar.mjs";
|
|
4
4
|
import { impactLight, selectionTick } from "./lib/haptics.mjs";
|
|
5
|
+
import { AnnotationSurface } from "./components/AnnotationSurface.mjs";
|
|
6
|
+
import { Badge } from "./components/Badge.mjs";
|
|
5
7
|
import { Spinner } from "./components/Spinner.mjs";
|
|
6
8
|
import { Button } from "./components/Button.mjs";
|
|
7
|
-
import { ActivityIcon, AlertIcon, ArrowRightIcon, BranchIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, CloseIcon, CopyIcon, EditIcon, FileIcon, FolderIcon, ForkIcon, GearIcon, HomeIcon, ImageIcon, KebabIcon, LightbulbIcon, LockIcon, MessageIcon, PaletteIcon, PlayCircleIcon, PlusIcon, SearchIcon, SendIcon, SlidersIcon, SparklesIcon, TaskIcon, TrashIcon, UsersIcon, WorkflowIcon, WrenchIcon } from "./icons/icons.mjs";
|
|
9
|
+
import { ActivityIcon, AlertIcon, ArrowRightIcon, ArrowUpRightIcon, AudioLinesIcon, Back10Icon, BoxIcon, BranchIcon, CalendarIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, ChevronUpIcon, CloseIcon, CopyIcon, DownloadIcon, EditIcon, EraserIcon, FileIcon, FitIcon, FolderIcon, ForkIcon, Forward10Icon, GearIcon, GlobeIcon, HandIcon, HighlighterIcon, HomeIcon, IdCardIcon, ImageIcon, KebabIcon, LanguagesIcon, LightbulbIcon, LockIcon, MenuIcon, MessageIcon, MicIcon, MinusIcon, MonitorIcon, PaletteIcon, PauseIcon, PinIcon, PlayCircleIcon, PlayIcon, PlusIcon, RedoIcon, RefreshIcon, SearchIcon, SendIcon, ServerIcon, ShieldIcon, SlidersIcon, SmartphoneIcon, SparklesIcon, StepBackIcon, StepForwardIcon, StopIcon, TaskIcon, TerminalIcon, TrashIcon, UndoIcon, UserIcon, UsersIcon, WorkflowIcon, WrenchIcon } from "./icons/icons.mjs";
|
|
10
|
+
import { CopyButton } from "./components/CopyButton.mjs";
|
|
11
|
+
import { ShowMore } from "./components/ShowMore.mjs";
|
|
8
12
|
import { CodeBlock } from "./components/CodeBlock.mjs";
|
|
13
|
+
import { ToolResultImage, authorImageOpener } from "./components/ToolResultImage.mjs";
|
|
9
14
|
import { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./components/Dialog.mjs";
|
|
10
|
-
import {
|
|
15
|
+
import { List, ListRow } from "./components/List.mjs";
|
|
16
|
+
import { ComputerRow } from "./components/ComputerRow.mjs";
|
|
17
|
+
import { CountBadge } from "./components/CountBadge.mjs";
|
|
11
18
|
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "./components/DropdownMenu.mjs";
|
|
19
|
+
import { Panel, PanelBody, PanelHeader } from "./components/Panel.mjs";
|
|
20
|
+
import { CtaCard } from "./components/CtaCard.mjs";
|
|
12
21
|
import { EmptyState } from "./components/EmptyState.mjs";
|
|
22
|
+
import { LoadingState } from "./components/LoadingState.mjs";
|
|
23
|
+
import { SyntaxLine, useSyntaxLines } from "./components/SyntaxLine.mjs";
|
|
24
|
+
import { HashlineLines } from "./components/HashlineLines.mjs";
|
|
13
25
|
import { Input } from "./components/Input.mjs";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
26
|
+
import { SegmentedControl } from "./components/SegmentedControl.mjs";
|
|
27
|
+
import { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger } from "./components/Sheet.mjs";
|
|
28
|
+
import { SheetList } from "./components/SheetList.mjs";
|
|
29
|
+
import { FileList } from "./components/FileList.mjs";
|
|
16
30
|
import { Markdown } from "./components/Markdown.mjs";
|
|
31
|
+
import { FilePreview } from "./components/FilePreview.mjs";
|
|
32
|
+
import { FilePathStrip, FileViewer, FileViewerHeader } from "./components/FileViewer.mjs";
|
|
33
|
+
import { Label } from "./components/Label.mjs";
|
|
34
|
+
import { LinkText } from "./components/LinkText.mjs";
|
|
35
|
+
import { RailItem } from "./components/RailItem.mjs";
|
|
36
|
+
import { ReferenceChip } from "./components/ReferenceChip.mjs";
|
|
17
37
|
import { STATUS_EDGE, StatusBadge } from "./components/StatusBadge.mjs";
|
|
18
38
|
import { MessageItem, MessageItemBody, MessageItemGroup, MessageItemHeader, MessageItemStatus, STATUS_GLYPH, STATUS_LABEL, toolTone, useMessageItem } from "./components/MessageItem.mjs";
|
|
19
|
-
import { Panel, PanelBody, PanelHeader } from "./components/Panel.mjs";
|
|
20
|
-
import { PoNativeProvider } from "./components/PoNativeProvider.mjs";
|
|
21
39
|
import { SectionLabel } from "./components/SectionLabel.mjs";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
40
|
+
import { SeekBar } from "./components/SeekBar.mjs";
|
|
41
|
+
import { Select } from "./components/Select.mjs";
|
|
42
|
+
import { Switch } from "./components/Switch.mjs";
|
|
24
43
|
import { TabBadge, Tabs, TabsContent, TabsList, TabsTrigger } from "./components/Tabs.mjs";
|
|
25
44
|
import { Textarea } from "./components/Textarea.mjs";
|
|
26
|
-
import {
|
|
45
|
+
import { ToolPathLink } from "./components/ToolPathLink.mjs";
|
|
46
|
+
import { HostFilter } from "./components/HostFilter.mjs";
|
|
47
|
+
import { HostTag } from "./components/HostTag.mjs";
|
|
48
|
+
import { InfoStrip } from "./components/InfoStrip.mjs";
|
|
49
|
+
import { ageLabel, ansiSpans, boundedFileSource, buildReviewPrompt, collapseLines, fileAssetPath, fileKind, filePreviewMode, fileTree, filterFiles, hashlineBody, isFileLayout, modifiedLabel, newestFiles, readMediaBytes, resultTextLines, sizeLabel, sortFiles } from "@agimon-ai/po-web-components/text";
|
|
50
|
+
import { IconColorContext, LiveDuration, PoNativeProvider, sheetsYielded, yieldSheets } from "@agimon-ai/po-native-components/shell";
|
|
27
51
|
|
|
28
|
-
export { ActivityIcon, AlertIcon, ArrowRightIcon, Badge, BranchIcon, Button, CheckIcon, ChevronDownIcon, ChevronRightIcon, CloseIcon, CodeBlock, CopyIcon, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Dot, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, EditIcon, EmptyState, FileIcon, FolderIcon, ForkIcon, GearIcon, HomeIcon, IconColorContext, ImageIcon, Input, KebabIcon, Label, LightbulbIcon, List, ListRow, LockIcon, Markdown, MessageIcon, MessageItem, MessageItemBody, MessageItemGroup, MessageItemHeader, MessageItemStatus, PaletteIcon, Panel, PanelBody, PanelHeader, PlayCircleIcon, PlusIcon, PoNativeProvider, STATUS_EDGE, STATUS_GLYPH, STATUS_LABEL, SearchIcon, SectionLabel, SegmentedControl, SendIcon, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SlidersIcon, SparklesIcon, Spinner, StatusBadge, TabBadge, Tabs, TabsContent, TabsList, TabsTrigger, TaskIcon, Textarea, TrashIcon, UsersIcon, WorkflowIcon, WrenchIcon, ansiSpans, buildReviewPrompt, fontOf, impactLight, selectionTick, toolTone, useMessageItem };
|
|
52
|
+
export { ActivityIcon, AgentAvatar, AlertIcon, AnnotationSurface, ArrowRightIcon, ArrowUpRightIcon, AudioLinesIcon, Back10Icon, Badge, BoxIcon, BranchIcon, Button, CalendarIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, ChevronUpIcon, CloseIcon, CodeBlock, ComputerRow, CopyButton, CopyIcon, CountBadge, CtaCard, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Dot, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, EditIcon, EmptyState, EraserIcon, FileIcon, FileList, FilePathStrip, FilePreview, FileViewer, FileViewerHeader, FitIcon, FolderIcon, ForkIcon, Forward10Icon, GearIcon, GlobeIcon, HandIcon, HashlineLines, HighlighterIcon, HomeIcon, HostFilter, HostTag, IconColorContext, IdCardIcon, ImageIcon, InfoStrip, Input, KebabIcon, Label, LanguagesIcon, LightbulbIcon, LinkText, List, ListRow, LiveDuration, LoadingState, LockIcon, Markdown, MenuIcon, MessageIcon, MessageItem, MessageItemBody, MessageItemGroup, MessageItemHeader, MessageItemStatus, MicIcon, MinusIcon, MonitorIcon, PaletteIcon, Panel, PanelBody, PanelHeader, PauseIcon, PinIcon, PlayCircleIcon, PlayIcon, PlusIcon, PoNativeProvider, RailItem, RedoIcon, ReferenceChip, RefreshIcon, STATUS_EDGE, STATUS_GLYPH, STATUS_LABEL, SearchIcon, SectionLabel, SeekBar, SegmentedControl, Select, SendIcon, ServerIcon, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetList, SheetTitle, SheetTrigger, ShieldIcon, ShowMore, SlidersIcon, SmartphoneIcon, SparklesIcon, Spinner, StatusBadge, StepBackIcon, StepForwardIcon, StopIcon, Switch, SyntaxLine, TabBadge, Tabs, TabsContent, TabsList, TabsTrigger, TaskIcon, TerminalIcon, Textarea, ToolPathLink, ToolResultImage, TrashIcon, UndoIcon, UserIcon, UsersIcon, WorkflowIcon, WrenchIcon, ageLabel, agentInitials, ansiSpans, authorImageOpener, boundedFileSource, buildReviewPrompt, collapseLines, fileAssetPath, fileKind, filePreviewMode, fileTree, filterFiles, fontOf, hashlineBody, impactLight, isFileLayout, modifiedLabel, newestFiles, readMediaBytes, resultTextLines, selectionTick, sheetsYielded, sizeLabel, sortFiles, tintFor, toolTone, useMessageItem, useSyntaxLines, yieldSheets };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/lib/fileKindLabel.ts
|
|
2
|
+
/** A file kind as the reader's language names it; the kind itself stays the filter value. */
|
|
3
|
+
function fileKindLabel(kind, t) {
|
|
4
|
+
switch (kind) {
|
|
5
|
+
case "Markdown": return t("nativeComponents.fileKind.markdown", "Markdown");
|
|
6
|
+
case "Image": return t("nativeComponents.fileKind.image", "Image");
|
|
7
|
+
case "Code": return t("nativeComponents.fileKind.code", "Code");
|
|
8
|
+
case "Data": return t("nativeComponents.fileKind.data", "Data");
|
|
9
|
+
case "Document": return t("nativeComponents.fileKind.document", "Document");
|
|
10
|
+
case "Other": return t("nativeComponents.fileKind.other", "Other");
|
|
11
|
+
default: return kind;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { fileKindLabel };
|
|
17
|
+
//# sourceMappingURL=fileKindLabel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileKindLabel.mjs","names":[],"sources":["../../src/lib/fileKindLabel.ts"],"sourcesContent":["import type { FileKind } from '@agimon-ai/po-web-components/text';\n\ntype Translate = (key: string, fallback: string, vars?: Readonly<Record<string, string | number>>) => string;\n\n/** A file kind as the reader's language names it; the kind itself stays the filter value. */\nexport function fileKindLabel(kind: FileKind, t: Translate): string {\n switch (kind) {\n case 'Markdown':\n return t('nativeComponents.fileKind.markdown', 'Markdown');\n case 'Image':\n return t('nativeComponents.fileKind.image', 'Image');\n case 'Code':\n return t('nativeComponents.fileKind.code', 'Code');\n case 'Data':\n return t('nativeComponents.fileKind.data', 'Data');\n case 'Document':\n return t('nativeComponents.fileKind.document', 'Document');\n case 'Other':\n return t('nativeComponents.fileKind.other', 'Other');\n default:\n return kind;\n }\n}\n"],"mappings":";;AAKA,SAAgB,cAAc,MAAgB,GAAsB;CAClE,QAAQ,MAAR;EACE,KAAK,YACH,OAAO,EAAE,sCAAsC,UAAU;EAC3D,KAAK,SACH,OAAO,EAAE,mCAAmC,OAAO;EACrD,KAAK,QACH,OAAO,EAAE,kCAAkC,MAAM;EACnD,KAAK,QACH,OAAO,EAAE,kCAAkC,MAAM;EACnD,KAAK,YACH,OAAO,EAAE,sCAAsC,UAAU;EAC3D,KAAK,SACH,OAAO,EAAE,mCAAmC,OAAO;EACrD,SACE,OAAO;CACX;AACF"}
|
package/dist/lib/fonts.d.mts
CHANGED
|
@@ -3,7 +3,9 @@ import { NativeFontStack } from "@agimon-ai/po-web-components/nativeTheme";
|
|
|
3
3
|
/**
|
|
4
4
|
* The font family a native style names for a stack: the platform font on iOS
|
|
5
5
|
* and Android until the brand families are bundled, and the brand family with
|
|
6
|
-
* a CSS generic fallback on web, where story renders run.
|
|
6
|
+
* a CSS generic fallback on web, where story renders run. On web the variable
|
|
7
|
+
* face comes first, as in theme.css: fontsource registers it as "<family>
|
|
8
|
+
* Variable", so the plain name alone matches nothing and falls back.
|
|
7
9
|
*
|
|
8
10
|
* ponytail: load IBM Plex Sans and JetBrains Mono through expo-font and return
|
|
9
11
|
* `stack.family` everywhere once the native visual review starts.
|
package/dist/lib/fonts.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.d.mts","names":[],"sources":["../../src/lib/fonts.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fonts.d.mts","names":[],"sources":["../../src/lib/fonts.ts"],"mappings":";;;;;;;;;;;;wBAagB,OAAO,OAAO"}
|
package/dist/lib/fonts.mjs
CHANGED
|
@@ -4,7 +4,9 @@ import { Platform } from "react-native";
|
|
|
4
4
|
/**
|
|
5
5
|
* The font family a native style names for a stack: the platform font on iOS
|
|
6
6
|
* and Android until the brand families are bundled, and the brand family with
|
|
7
|
-
* a CSS generic fallback on web, where story renders run.
|
|
7
|
+
* a CSS generic fallback on web, where story renders run. On web the variable
|
|
8
|
+
* face comes first, as in theme.css: fontsource registers it as "<family>
|
|
9
|
+
* Variable", so the plain name alone matches nothing and falls back.
|
|
8
10
|
*
|
|
9
11
|
* ponytail: load IBM Plex Sans and JetBrains Mono through expo-font and return
|
|
10
12
|
* `stack.family` everywhere once the native visual review starts.
|
|
@@ -13,7 +15,7 @@ function fontOf(stack) {
|
|
|
13
15
|
return Platform.select({
|
|
14
16
|
ios: stack.ios,
|
|
15
17
|
android: stack.android,
|
|
16
|
-
default: `${stack.family}, ${stack.android}`
|
|
18
|
+
default: `${stack.family} Variable, ${stack.family}, ${stack.android}`
|
|
17
19
|
});
|
|
18
20
|
}
|
|
19
21
|
|
package/dist/lib/fonts.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.mjs","names":["NativeFontStack","Platform","fontOf","stack","select","ios","android","default","family"],"sources":["../../src/lib/fonts.ts"],"sourcesContent":["import type { NativeFontStack } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Platform } from 'react-native';\n\n/**\n * The font family a native style names for a stack: the platform font on iOS\n * and Android until the brand families are bundled, and the brand family with\n * a CSS generic fallback on web, where story renders run.\n *\n * ponytail: load IBM Plex Sans and JetBrains Mono through expo-font and return\n * `stack.family` everywhere once the native visual review starts.\n */\nexport function fontOf(stack: NativeFontStack): string {\n return Platform.select({\n ios: stack.ios,\n android: stack.android,\n default: `${stack.family}, ${stack.android}`,\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fonts.mjs","names":["NativeFontStack","Platform","fontOf","stack","select","ios","android","default","family"],"sources":["../../src/lib/fonts.ts"],"sourcesContent":["import type { NativeFontStack } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Platform } from 'react-native';\n\n/**\n * The font family a native style names for a stack: the platform font on iOS\n * and Android until the brand families are bundled, and the brand family with\n * a CSS generic fallback on web, where story renders run. On web the variable\n * face comes first, as in theme.css: fontsource registers it as \"<family>\n * Variable\", so the plain name alone matches nothing and falls back.\n *\n * ponytail: load IBM Plex Sans and JetBrains Mono through expo-font and return\n * `stack.family` everywhere once the native visual review starts.\n */\nexport function fontOf(stack: NativeFontStack): string {\n return Platform.select({\n ios: stack.ios,\n android: stack.android,\n default: `${stack.family} Variable, ${stack.family}, ${stack.android}`,\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgBE,OAAOC,OAAgC;CACrD,OAAOF,SAASG,OAAO;EACrBC,KAAKF,MAAME;EACXC,SAASH,MAAMG;EACfC,SAAS,GAAGJ,MAAMK,OAAM,aAAcL,MAAMK,OAAM,IAAKL,MAAMG;CAC/D,CAAC;AACH"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/lib/insideSheet.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether the caller renders inside a bottom sheet. A sheet's text field has
|
|
4
|
+
* to be the bottom sheet's own TextInput, or the keyboard covers it and the
|
|
5
|
+
* sheet never moves; Input reads this instead of asking callers to pick.
|
|
6
|
+
*/
|
|
7
|
+
export declare const InsideSheetContext: import("react").Context<boolean>;
|
|
8
|
+
export declare function useInsideSheet(): boolean;
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=insideSheet.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insideSheet.d.mts","names":[],"sources":["../../src/lib/insideSheet.ts"],"mappings":";;;;;;qBAOa,oCAAkB;wBAEf"}
|
package/dist/lib/markdown.mjs
CHANGED
|
@@ -5,13 +5,165 @@ const RULE = /^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/;
|
|
|
5
5
|
const BULLET_ITEM = /^ {0,3}[-*+][ \t]+(.*)$/;
|
|
6
6
|
const ORDERED_ITEM = /^ {0,3}(\d{1,9})[.)][ \t]+(.*)$/;
|
|
7
7
|
const INDENTED = /^[ \t]+\S/;
|
|
8
|
+
const QUOTE = /^ {0,3}> ?(.*)$/;
|
|
9
|
+
const TABLE_DIVIDER = /^ {0,3}\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
|
|
10
|
+
const HTML_COMMENT = /^ {0,3}<!--/;
|
|
11
|
+
/** CommonMark's block-level tag names, plus the picture and image markup READMEs open with. */
|
|
12
|
+
const HTML_BLOCK = /^ {0,3}<\/?(?:address|article|aside|blockquote|center|details|div|dl|figcaption|figure|footer|form|h[1-6]|header|hr|li|main|nav|ol|p|picture|section|summary|table|tbody|td|tfoot|th|thead|tr|ul)(?=[\s/>]|$)/i;
|
|
13
|
+
/** Any other tag standing alone on its line, such as `<img ...>` or `<br>`. */
|
|
14
|
+
const HTML_TAG_LINE = /^ {0,3}<\/?[A-Za-z][A-Za-z0-9-]*(?:\s[^<>]*)?\/?>[ \t]*$/;
|
|
15
|
+
const HARD_BREAK = /(?: {2,}|\\)$/;
|
|
8
16
|
const ESCAPABLE = /[!-/:-@[-`{-~]/;
|
|
9
17
|
const WORD_CHAR = /[\p{L}\p{N}]/u;
|
|
18
|
+
/** `@session:git` and the like, read where an `@` starts the text or follows whitespace. */
|
|
19
|
+
const REFERENCE_AT = /@([a-z][a-z0-9+.-]*:[^\s@]+)/iuy;
|
|
20
|
+
const TRAILING_PUNCTUATION = /[.,;:!?)\]]+$/u;
|
|
21
|
+
const BARE_URL = /https?:\/\/[^\s<>]+/iuy;
|
|
22
|
+
const URL_TRAILING = /[.,;:!?'"*_~]$/u;
|
|
23
|
+
/** The href a reference link carries; the renderer recognises it by this prefix. */
|
|
24
|
+
const REFERENCE_HREF_PREFIX = "po-reference:";
|
|
25
|
+
/** An http(s) address with a host and no credentials, normalised; anything else is undefined. */
|
|
26
|
+
function webHref(raw) {
|
|
27
|
+
if (!/^https?:\/\//iu.test(raw)) return void 0;
|
|
28
|
+
try {
|
|
29
|
+
const url = new URL(raw);
|
|
30
|
+
if (url.protocol !== "http:" && url.protocol !== "https:" || !url.host || url.username || url.password) return void 0;
|
|
31
|
+
return url.href;
|
|
32
|
+
} catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function count(text, char) {
|
|
37
|
+
return text.split(char).length - 1;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A bare http(s) URL starting at `start`, without the trailing punctuation that ends a sentence.
|
|
41
|
+
* A closing bracket stays only while it balances one inside the URL, so `wiki/A_(b)` keeps it.
|
|
42
|
+
*/
|
|
43
|
+
function readBareUrl(source, start) {
|
|
44
|
+
BARE_URL.lastIndex = start;
|
|
45
|
+
let text = BARE_URL.exec(source)?.[0];
|
|
46
|
+
if (text === void 0) return void 0;
|
|
47
|
+
for (;;) if (URL_TRAILING.test(text)) text = text.slice(0, -1);
|
|
48
|
+
else if (text.endsWith(")") && count(text, ")") > count(text, "(")) text = text.slice(0, -1);
|
|
49
|
+
else if (text.endsWith("]") && count(text, "]") > count(text, "[")) text = text.slice(0, -1);
|
|
50
|
+
else break;
|
|
51
|
+
const href = webHref(text);
|
|
52
|
+
return href === void 0 ? void 0 : {
|
|
53
|
+
text,
|
|
54
|
+
href,
|
|
55
|
+
end: start + text.length
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Where a bare URL may begin: the start, or after anything but a letter or digit. */
|
|
59
|
+
function urlStarts(source, index) {
|
|
60
|
+
const char = source[index];
|
|
61
|
+
return (char === "h" || char === "H") && (index === 0 || !WORD_CHAR.test(source[index - 1]));
|
|
62
|
+
}
|
|
63
|
+
/** The `@scheme:value` reference an `@` at `index` starts, without the punctuation a sentence hangs on it. */
|
|
64
|
+
function referenceAt(source, index) {
|
|
65
|
+
if (source[index] !== "@" || index > 0 && !/\s/u.test(source[index - 1])) return void 0;
|
|
66
|
+
REFERENCE_AT.lastIndex = index;
|
|
67
|
+
const reference = REFERENCE_AT.exec(source)?.[1]?.replace(TRAILING_PUNCTUATION, "");
|
|
68
|
+
return reference === void 0 || reference === "" || reference.endsWith(":") ? void 0 : reference;
|
|
69
|
+
}
|
|
70
|
+
/** The reference a code span is, when the span is exactly one reference as prose would read it. */
|
|
71
|
+
function exactReference(text) {
|
|
72
|
+
const reference = referenceAt(text, 0);
|
|
73
|
+
return reference !== void 0 && reference.length + 1 === text.length ? reference : void 0;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Plain text cut into runs, bare http(s) links and `@scheme:value` references (`scheme:value`, as
|
|
77
|
+
* Markdown hands them to its host), for text that is not Markdown.
|
|
78
|
+
*/
|
|
79
|
+
function splitWebLinks(text) {
|
|
80
|
+
if (text.length > MAX_PARSE_CHARACTERS) return [{ text }];
|
|
81
|
+
const parts = [];
|
|
82
|
+
let from = 0;
|
|
83
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
84
|
+
const reference = referenceAt(text, index);
|
|
85
|
+
if (reference !== void 0) {
|
|
86
|
+
if (index > from) parts.push({ text: text.slice(from, index) });
|
|
87
|
+
parts.push({
|
|
88
|
+
text: `@${reference}`,
|
|
89
|
+
reference
|
|
90
|
+
});
|
|
91
|
+
from = index + 1 + reference.length;
|
|
92
|
+
index = from - 1;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (!urlStarts(text, index)) continue;
|
|
96
|
+
const url = readBareUrl(text, index);
|
|
97
|
+
if (url === void 0) continue;
|
|
98
|
+
if (index > from) parts.push({ text: text.slice(from, index) });
|
|
99
|
+
parts.push({
|
|
100
|
+
text: url.text,
|
|
101
|
+
href: url.href
|
|
102
|
+
});
|
|
103
|
+
from = url.end;
|
|
104
|
+
index = url.end - 1;
|
|
105
|
+
}
|
|
106
|
+
if (from < text.length) parts.push({ text: text.slice(from) });
|
|
107
|
+
return parts;
|
|
108
|
+
}
|
|
109
|
+
const MAX_PARSE_CHARACTERS = 1e5;
|
|
110
|
+
const MAX_PARSE_WORK = 25e4;
|
|
111
|
+
const MAX_PARSE_DEPTH = 32;
|
|
112
|
+
const PARSE_LIMIT = /* @__PURE__ */ new Error("Markdown parsing limit reached.");
|
|
113
|
+
function spend(budget, work) {
|
|
114
|
+
budget.remaining -= work;
|
|
115
|
+
if (budget.remaining < 0) throw PARSE_LIMIT;
|
|
116
|
+
}
|
|
10
117
|
function isBlank(line) {
|
|
11
118
|
return line.trim() === "";
|
|
12
119
|
}
|
|
120
|
+
/** Joins a paragraph's lines: a space between them, or a line break after two spaces or a backslash. */
|
|
121
|
+
function joinLines(lines) {
|
|
122
|
+
return lines.map((line, index) => {
|
|
123
|
+
const current = index === 0 ? line : line.trimStart();
|
|
124
|
+
if (index === lines.length - 1) return current;
|
|
125
|
+
return `${current.replace(/(?: {2,}|\\|[ \t]+)$/u, "")}${HARD_BREAK.test(current) ? "\n" : " "}`;
|
|
126
|
+
}).join("");
|
|
127
|
+
}
|
|
128
|
+
/** A table row's cells: outer pipes dropped, split on unescaped pipes, `\|` read as a pipe. */
|
|
129
|
+
function tableCells(line) {
|
|
130
|
+
let row = line.trim();
|
|
131
|
+
if (row.startsWith("|")) row = row.slice(1);
|
|
132
|
+
if (row.endsWith("|") && !row.endsWith("\\|")) row = row.slice(0, -1);
|
|
133
|
+
const cells = [];
|
|
134
|
+
let cell = "";
|
|
135
|
+
for (let index = 0; index < row.length; index += 1) {
|
|
136
|
+
const char = row[index];
|
|
137
|
+
if (char === "\\" && row[index + 1] === "|") {
|
|
138
|
+
cell += "|";
|
|
139
|
+
index += 1;
|
|
140
|
+
} else if (char === "|") {
|
|
141
|
+
cells.push(cell.trim());
|
|
142
|
+
cell = "";
|
|
143
|
+
} else cell += char;
|
|
144
|
+
}
|
|
145
|
+
cells.push(cell.trim());
|
|
146
|
+
return cells;
|
|
147
|
+
}
|
|
13
148
|
/** Parses a Markdown document into blocks. */
|
|
14
149
|
function parseMarkdown(source) {
|
|
150
|
+
if (source.length <= MAX_PARSE_CHARACTERS) try {
|
|
151
|
+
return parseBlocks(source, { remaining: MAX_PARSE_WORK }, 0);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if (error !== PARSE_LIMIT) throw error;
|
|
154
|
+
}
|
|
155
|
+
return [{
|
|
156
|
+
type: "paragraph",
|
|
157
|
+
children: [{
|
|
158
|
+
type: "text",
|
|
159
|
+
text: source
|
|
160
|
+
}]
|
|
161
|
+
}];
|
|
162
|
+
}
|
|
163
|
+
function parseBlocks(source, budget, depth) {
|
|
164
|
+
if (depth > MAX_PARSE_DEPTH) throw PARSE_LIMIT;
|
|
165
|
+
spend(budget, source.length + 1);
|
|
166
|
+
const inline = (text) => parseInlineNodes(text, budget, depth + 1);
|
|
15
167
|
const lines = source.replace(/\r\n?/g, "\n").split("\n");
|
|
16
168
|
const blocks = [];
|
|
17
169
|
let paragraph = [];
|
|
@@ -19,7 +171,7 @@ function parseMarkdown(source) {
|
|
|
19
171
|
const flushParagraph = () => {
|
|
20
172
|
if (paragraph.length > 0) blocks.push({
|
|
21
173
|
type: "paragraph",
|
|
22
|
-
children:
|
|
174
|
+
children: inline(joinLines(paragraph))
|
|
23
175
|
});
|
|
24
176
|
paragraph = [];
|
|
25
177
|
};
|
|
@@ -28,7 +180,7 @@ function parseMarkdown(source) {
|
|
|
28
180
|
type: "list",
|
|
29
181
|
ordered: list.ordered,
|
|
30
182
|
start: list.start,
|
|
31
|
-
items: list.items.map(
|
|
183
|
+
items: list.items.map((item) => inline(joinLines(item)))
|
|
32
184
|
});
|
|
33
185
|
list = void 0;
|
|
34
186
|
};
|
|
@@ -61,6 +213,16 @@ function parseMarkdown(source) {
|
|
|
61
213
|
flush();
|
|
62
214
|
continue;
|
|
63
215
|
}
|
|
216
|
+
if (paragraph.length === 0 && HTML_COMMENT.test(line)) {
|
|
217
|
+
flush();
|
|
218
|
+
while (index < lines.length && !lines[index].includes("-->")) index += 1;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (paragraph.length === 0 && (HTML_BLOCK.test(line) || HTML_TAG_LINE.test(line))) {
|
|
222
|
+
flush();
|
|
223
|
+
while (index + 1 < lines.length && !isBlank(lines[index + 1])) index += 1;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
64
226
|
const heading = HEADING.exec(line);
|
|
65
227
|
if (heading !== null) {
|
|
66
228
|
flush();
|
|
@@ -68,7 +230,7 @@ function parseMarkdown(source) {
|
|
|
68
230
|
blocks.push({
|
|
69
231
|
type: "heading",
|
|
70
232
|
level,
|
|
71
|
-
children:
|
|
233
|
+
children: inline(heading[2] ?? "")
|
|
72
234
|
});
|
|
73
235
|
continue;
|
|
74
236
|
}
|
|
@@ -77,6 +239,41 @@ function parseMarkdown(source) {
|
|
|
77
239
|
blocks.push({ type: "rule" });
|
|
78
240
|
continue;
|
|
79
241
|
}
|
|
242
|
+
if (QUOTE.test(line)) {
|
|
243
|
+
flush();
|
|
244
|
+
const quoted = [];
|
|
245
|
+
while (index < lines.length && QUOTE.test(lines[index])) {
|
|
246
|
+
quoted.push(QUOTE.exec(lines[index])[1]);
|
|
247
|
+
index += 1;
|
|
248
|
+
}
|
|
249
|
+
index -= 1;
|
|
250
|
+
blocks.push({
|
|
251
|
+
type: "quote",
|
|
252
|
+
children: parseBlocks(quoted.join("\n"), budget, depth + 1)
|
|
253
|
+
});
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
const divider = lines[index + 1];
|
|
257
|
+
if (line.includes("|") && divider !== void 0 && divider.includes("|") && TABLE_DIVIDER.test(divider)) {
|
|
258
|
+
const header = tableCells(line);
|
|
259
|
+
if (header.length === tableCells(divider).length) {
|
|
260
|
+
flush();
|
|
261
|
+
index += 2;
|
|
262
|
+
const rows = [];
|
|
263
|
+
while (index < lines.length && !isBlank(lines[index]) && lines[index].includes("|")) {
|
|
264
|
+
const cells = tableCells(lines[index]);
|
|
265
|
+
rows.push(header.map((_, column) => inline(cells[column] ?? "")));
|
|
266
|
+
index += 1;
|
|
267
|
+
}
|
|
268
|
+
index -= 1;
|
|
269
|
+
blocks.push({
|
|
270
|
+
type: "table",
|
|
271
|
+
header: header.map((cell) => inline(cell)),
|
|
272
|
+
rows
|
|
273
|
+
});
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
80
277
|
const bullet = BULLET_ITEM.exec(line);
|
|
81
278
|
const ordered = bullet === null ? ORDERED_ITEM.exec(line) : null;
|
|
82
279
|
if (bullet !== null || ordered !== null) {
|
|
@@ -90,12 +287,11 @@ function parseMarkdown(source) {
|
|
|
90
287
|
items: []
|
|
91
288
|
};
|
|
92
289
|
}
|
|
93
|
-
list.items.push(isOrdered ? ordered[2] : bullet[1]);
|
|
290
|
+
list.items.push([isOrdered ? ordered[2] : bullet[1]]);
|
|
94
291
|
continue;
|
|
95
292
|
}
|
|
96
293
|
if (list !== void 0 && INDENTED.test(line)) {
|
|
97
|
-
|
|
98
|
-
list.items[last] = `${list.items[last]}\n${line.trim()}`;
|
|
294
|
+
list.items.at(-1).push(line.trim());
|
|
99
295
|
continue;
|
|
100
296
|
}
|
|
101
297
|
flushList();
|
|
@@ -104,8 +300,10 @@ function parseMarkdown(source) {
|
|
|
104
300
|
flush();
|
|
105
301
|
return blocks;
|
|
106
302
|
}
|
|
107
|
-
/**
|
|
108
|
-
function
|
|
303
|
+
/** `autolink` is off inside a link's label, so a URL there never nests a link in a link. */
|
|
304
|
+
function parseInlineNodes(source, budget, depth, autolink = true) {
|
|
305
|
+
if (depth > MAX_PARSE_DEPTH) throw PARSE_LIMIT;
|
|
306
|
+
spend(budget, source.length + 1);
|
|
109
307
|
const nodes = [];
|
|
110
308
|
let text = "";
|
|
111
309
|
const pushText = (value) => {
|
|
@@ -121,6 +319,7 @@ function parseInline(source) {
|
|
|
121
319
|
};
|
|
122
320
|
let index = 0;
|
|
123
321
|
while (index < source.length) {
|
|
322
|
+
spend(budget, 1);
|
|
124
323
|
const char = source[index];
|
|
125
324
|
if (char === "\\" && index + 1 < source.length && ESCAPABLE.test(source[index + 1])) {
|
|
126
325
|
pushText(source[index + 1]);
|
|
@@ -128,7 +327,7 @@ function parseInline(source) {
|
|
|
128
327
|
continue;
|
|
129
328
|
}
|
|
130
329
|
if (char === "`") {
|
|
131
|
-
const span = readCodeSpan(source, index);
|
|
330
|
+
const span = readCodeSpan(source, index, budget);
|
|
132
331
|
if (span !== void 0) {
|
|
133
332
|
pushNode({
|
|
134
333
|
type: "code",
|
|
@@ -142,24 +341,36 @@ function parseInline(source) {
|
|
|
142
341
|
index += run.length;
|
|
143
342
|
continue;
|
|
144
343
|
}
|
|
344
|
+
if (char === "!" && source[index + 1] === "[") {
|
|
345
|
+
const image = readLink(source, index + 1, budget);
|
|
346
|
+
if (image !== void 0) {
|
|
347
|
+
pushNode({
|
|
348
|
+
type: "image",
|
|
349
|
+
src: image.href,
|
|
350
|
+
alt: image.label
|
|
351
|
+
});
|
|
352
|
+
index = image.end;
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
145
356
|
if (char === "[") {
|
|
146
|
-
const link = readLink(source, index);
|
|
357
|
+
const link = readLink(source, index, budget);
|
|
147
358
|
if (link !== void 0) {
|
|
148
359
|
pushNode({
|
|
149
360
|
type: "link",
|
|
150
361
|
href: link.href,
|
|
151
|
-
children:
|
|
362
|
+
children: parseInlineNodes(link.label, budget, depth + 1, false)
|
|
152
363
|
});
|
|
153
364
|
index = link.end;
|
|
154
365
|
continue;
|
|
155
366
|
}
|
|
156
367
|
}
|
|
157
368
|
if ((char === "*" || char === "_") && source[index + 1] === char) {
|
|
158
|
-
const strong = readDelimited(source, index, char.repeat(2));
|
|
369
|
+
const strong = readDelimited(source, index, char.repeat(2), budget);
|
|
159
370
|
if (strong !== void 0) {
|
|
160
371
|
pushNode({
|
|
161
372
|
type: "strong",
|
|
162
|
-
children:
|
|
373
|
+
children: parseInlineNodes(strong.inner, budget, depth + 1, autolink)
|
|
163
374
|
});
|
|
164
375
|
index = strong.end;
|
|
165
376
|
continue;
|
|
@@ -169,16 +380,62 @@ function parseInline(source) {
|
|
|
169
380
|
continue;
|
|
170
381
|
}
|
|
171
382
|
if (char === "*" || char === "_") {
|
|
172
|
-
const em = readDelimited(source, index, char);
|
|
383
|
+
const em = readDelimited(source, index, char, budget);
|
|
173
384
|
if (em !== void 0) {
|
|
174
385
|
pushNode({
|
|
175
386
|
type: "em",
|
|
176
|
-
children:
|
|
387
|
+
children: parseInlineNodes(em.inner, budget, depth + 1, autolink)
|
|
177
388
|
});
|
|
178
389
|
index = em.end;
|
|
179
390
|
continue;
|
|
180
391
|
}
|
|
181
392
|
}
|
|
393
|
+
if (autolink && char === "<") {
|
|
394
|
+
const url = readBareUrl(source, index + 1);
|
|
395
|
+
if (url !== void 0 && source[url.end] === ">") {
|
|
396
|
+
spend(budget, url.text.length);
|
|
397
|
+
pushNode({
|
|
398
|
+
type: "link",
|
|
399
|
+
href: url.href,
|
|
400
|
+
children: [{
|
|
401
|
+
type: "text",
|
|
402
|
+
text: url.text
|
|
403
|
+
}]
|
|
404
|
+
});
|
|
405
|
+
index = url.end + 1;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (autolink && urlStarts(source, index)) {
|
|
410
|
+
const url = readBareUrl(source, index);
|
|
411
|
+
if (url !== void 0) {
|
|
412
|
+
spend(budget, url.text.length);
|
|
413
|
+
pushNode({
|
|
414
|
+
type: "link",
|
|
415
|
+
href: url.href,
|
|
416
|
+
children: [{
|
|
417
|
+
type: "text",
|
|
418
|
+
text: url.text
|
|
419
|
+
}]
|
|
420
|
+
});
|
|
421
|
+
index = url.end;
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const reference = referenceAt(source, index);
|
|
426
|
+
if (reference !== void 0) {
|
|
427
|
+
spend(budget, reference.length);
|
|
428
|
+
pushNode({
|
|
429
|
+
type: "link",
|
|
430
|
+
href: REFERENCE_HREF_PREFIX + encodeURIComponent(reference),
|
|
431
|
+
children: [{
|
|
432
|
+
type: "text",
|
|
433
|
+
text: `@${reference}`
|
|
434
|
+
}]
|
|
435
|
+
});
|
|
436
|
+
index += 1 + reference.length;
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
182
439
|
pushText(char);
|
|
183
440
|
index += 1;
|
|
184
441
|
}
|
|
@@ -189,11 +446,12 @@ function parseInline(source) {
|
|
|
189
446
|
return nodes;
|
|
190
447
|
}
|
|
191
448
|
/** A code span opened by the backtick run at `start`, closed by a run of the same length. */
|
|
192
|
-
function readCodeSpan(source, start) {
|
|
449
|
+
function readCodeSpan(source, start, budget) {
|
|
193
450
|
const run = /^`+/.exec(source.slice(start))[0];
|
|
194
451
|
let search = start + run.length;
|
|
195
452
|
while (search < source.length) {
|
|
196
453
|
const found = source.indexOf(run, search);
|
|
454
|
+
spend(budget, (found === -1 ? source.length : found + run.length) - search);
|
|
197
455
|
if (found === -1) return void 0;
|
|
198
456
|
const after = found + run.length;
|
|
199
457
|
if (source[after] === "`" || source[found - 1] === "`") {
|
|
@@ -210,10 +468,11 @@ function readCodeSpan(source, start) {
|
|
|
210
468
|
}
|
|
211
469
|
}
|
|
212
470
|
/** `[label](href)` starting at the bracket; brackets in the label may nest. */
|
|
213
|
-
function readLink(source, start) {
|
|
471
|
+
function readLink(source, start, budget) {
|
|
214
472
|
let depth = 0;
|
|
215
473
|
let close = -1;
|
|
216
474
|
for (let index = start; index < source.length; index += 1) {
|
|
475
|
+
spend(budget, 1);
|
|
217
476
|
const char = source[index];
|
|
218
477
|
if (char === "\\") {
|
|
219
478
|
index += 1;
|
|
@@ -229,12 +488,39 @@ function readLink(source, start) {
|
|
|
229
488
|
}
|
|
230
489
|
}
|
|
231
490
|
if (close === -1 || source[close + 1] !== "(") return void 0;
|
|
232
|
-
|
|
233
|
-
|
|
491
|
+
let index = close + 2;
|
|
492
|
+
const skipSpace = () => {
|
|
493
|
+
while (index < source.length && /\s/.test(source[index])) {
|
|
494
|
+
spend(budget, 1);
|
|
495
|
+
index += 1;
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
skipSpace();
|
|
499
|
+
if (source[index] === "<") index += 1;
|
|
500
|
+
const hrefStart = index;
|
|
501
|
+
while (index < source.length && !/[\s()<>]/.test(source[index])) {
|
|
502
|
+
spend(budget, 1);
|
|
503
|
+
index += 1;
|
|
504
|
+
}
|
|
505
|
+
const href = source.slice(hrefStart, index);
|
|
506
|
+
if (source[index] === ">") index += 1;
|
|
507
|
+
const beforeSpace = index;
|
|
508
|
+
skipSpace();
|
|
509
|
+
if (index > beforeSpace && source[index] === "\"") {
|
|
510
|
+
index += 1;
|
|
511
|
+
while (index < source.length && source[index] !== "\"") {
|
|
512
|
+
spend(budget, 1);
|
|
513
|
+
index += 1;
|
|
514
|
+
}
|
|
515
|
+
if (source[index] !== "\"") return void 0;
|
|
516
|
+
index += 1;
|
|
517
|
+
skipSpace();
|
|
518
|
+
}
|
|
519
|
+
if (source[index] !== ")") return void 0;
|
|
234
520
|
return {
|
|
235
521
|
label: source.slice(start + 1, close),
|
|
236
|
-
href
|
|
237
|
-
end:
|
|
522
|
+
href,
|
|
523
|
+
end: index + 1
|
|
238
524
|
};
|
|
239
525
|
}
|
|
240
526
|
/**
|
|
@@ -242,7 +528,7 @@ function readLink(source, start) {
|
|
|
242
528
|
* end with a space, and an underscore only counts at a word boundary, so
|
|
243
529
|
* `snake_case_name` stays text.
|
|
244
530
|
*/
|
|
245
|
-
function readDelimited(source, start, delimiter) {
|
|
531
|
+
function readDelimited(source, start, delimiter, budget) {
|
|
246
532
|
const underscore = delimiter[0] === "_";
|
|
247
533
|
if (underscore && start > 0 && WORD_CHAR.test(source[start - 1])) return void 0;
|
|
248
534
|
const open = start + delimiter.length;
|
|
@@ -250,6 +536,7 @@ function readDelimited(source, start, delimiter) {
|
|
|
250
536
|
let search = open;
|
|
251
537
|
while (search < source.length) {
|
|
252
538
|
const found = source.indexOf(delimiter, search);
|
|
539
|
+
spend(budget, (found === -1 ? source.length : found + delimiter.length) - search);
|
|
253
540
|
if (found === -1) return void 0;
|
|
254
541
|
const end = found + delimiter.length;
|
|
255
542
|
if (delimiter.length === 1 && source[end] === delimiter) {
|
|
@@ -267,5 +554,5 @@ function readDelimited(source, start, delimiter) {
|
|
|
267
554
|
}
|
|
268
555
|
|
|
269
556
|
//#endregion
|
|
270
|
-
export {
|
|
557
|
+
export { REFERENCE_HREF_PREFIX, exactReference, parseMarkdown, splitWebLinks, webHref };
|
|
271
558
|
//# sourceMappingURL=markdown.mjs.map
|