zidane-ui 9.2.3 → 9.4.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/dist/adapters/live.d.ts +8 -0
- package/dist/adapters/live.js +19 -8
- package/dist/adapters/server-composer-host.js +22 -9
- package/dist/adapters/server-git-host.js +5 -2
- package/dist/adapters/server-host.js +158 -27
- package/dist/adapters/server-machines-host.js +7 -0
- package/dist/adapters/server-media.d.ts +9 -1
- package/dist/adapters/server-media.js +14 -1
- package/dist/adapters/server-session-host.js +49 -0
- package/dist/adapters/server-settings-sections.js +4 -1
- package/dist/adapters/sse-host.js +3 -0
- package/dist/adapters/sse-protocol.d.ts +10 -0
- package/dist/appearance/ZoomIndicator.js +5 -8
- package/dist/chat/HostTranscript.d.ts +0 -12
- package/dist/chat/HostTranscript.js +20 -1
- package/dist/chat/SessionStreamsProvider.d.ts +9 -1
- package/dist/chat/SessionStreamsProvider.js +11 -2
- package/dist/chat/Transcript.d.ts +21 -11
- package/dist/chat/Transcript.js +346 -161
- package/dist/chat/composer/ModelOptionsPicker.js +6 -2
- package/dist/chat/composer/ModelPicker.d.ts +1 -1
- package/dist/chat/composer/PlacePicker.d.ts +3 -1
- package/dist/chat/composer/PlacePicker.js +5 -1
- package/dist/chat/composer/use-draft-target.js +15 -3
- package/dist/chat/headless/block-runs.js +26 -1
- package/dist/chat/headless/chip-views.js +1 -1
- package/dist/chat/headless/draft-target.d.ts +28 -1
- package/dist/chat/headless/draft-target.js +22 -1
- package/dist/chat/headless/host.d.ts +43 -7
- package/dist/chat/headless/hosts.d.ts +4 -0
- package/dist/chat/headless/index.d.ts +27 -26
- package/dist/chat/headless/index.js +15 -14
- package/dist/chat/headless/labels.d.ts +17 -0
- package/dist/chat/headless/labels.js +17 -0
- package/dist/chat/headless/markdown-chunks.d.ts +2 -1
- package/dist/chat/headless/markdown-chunks.js +12 -20
- package/dist/chat/headless/markdown-scan.d.ts +64 -0
- package/dist/chat/headless/markdown-scan.js +119 -0
- package/dist/chat/headless/markdown-stream.d.ts +64 -0
- package/dist/chat/headless/markdown-stream.js +143 -0
- package/dist/chat/headless/output-pager.d.ts +68 -0
- package/dist/chat/headless/output-pager.js +113 -0
- package/dist/chat/headless/prompt-origin.d.ts +2 -0
- package/dist/chat/headless/prompt-origin.js +6 -2
- package/dist/chat/headless/session-list.d.ts +10 -0
- package/dist/chat/headless/sidebar/activity.d.ts +14 -0
- package/dist/chat/headless/sidebar/activity.js +32 -0
- package/dist/chat/headless/sidebar/directory.d.ts +19 -2
- package/dist/chat/headless/sidebar/directory.js +19 -51
- package/dist/chat/headless/sidebar/environment.d.ts +15 -4
- package/dist/chat/headless/sidebar/environment.js +27 -9
- package/dist/chat/headless/sidebar/index.d.ts +2 -2
- package/dist/chat/headless/sidebar/index.js +2 -2
- package/dist/chat/headless/sidebar/labels.d.ts +19 -2
- package/dist/chat/headless/sidebar/labels.js +8 -1
- package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
- package/dist/chat/headless/sidebar/prewarm.js +114 -0
- package/dist/chat/headless/streams/actions.d.ts +4 -2
- package/dist/chat/headless/streams/actions.js +2 -1
- package/dist/chat/headless/streams/event-bytes.d.ts +17 -0
- package/dist/chat/headless/streams/event-bytes.js +46 -0
- package/dist/chat/headless/streams/live-events.d.ts +25 -1
- package/dist/chat/headless/streams/live-events.js +53 -2
- package/dist/chat/headless/streams/selectors.d.ts +3 -0
- package/dist/chat/headless/streams/selectors.js +8 -1
- package/dist/chat/headless/streams/session-streams.d.ts +15 -3
- package/dist/chat/headless/streams/session-streams.js +31 -3
- package/dist/chat/headless/streams/store.d.ts +45 -6
- package/dist/chat/headless/streams/store.js +85 -31
- package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
- package/dist/chat/headless/streams/transcript-map.js +85 -0
- package/dist/chat/headless/streams/transcript.d.ts +4 -2
- package/dist/chat/headless/streams/transcript.js +19 -7
- package/dist/chat/headless/streams/types.d.ts +2 -1
- package/dist/chat/headless/transcript/batch.js +5 -1
- package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
- package/dist/chat/headless/transcript/blob-media.js +23 -0
- package/dist/chat/headless/transcript/collapse.d.ts +10 -0
- package/dist/chat/headless/transcript/collapse.js +35 -6
- package/dist/chat/headless/transcript/derive.d.ts +98 -0
- package/dist/chat/headless/transcript/derive.js +89 -0
- package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
- package/dist/chat/headless/transcript/exchange-media.js +8 -5
- package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
- package/dist/chat/headless/transcript/fold-attachments.js +3 -2
- package/dist/chat/headless/transcript/fold.d.ts +2 -1
- package/dist/chat/headless/transcript/fold.js +16 -6
- package/dist/chat/headless/transcript/incremental.d.ts +53 -0
- package/dist/chat/headless/transcript/incremental.js +181 -0
- package/dist/chat/headless/transcript/index.d.ts +2 -2
- package/dist/chat/headless/transcript/index.js +2 -2
- package/dist/chat/headless/transcript/nesting.js +2 -1
- package/dist/chat/headless/transcript/rail.d.ts +50 -1
- package/dist/chat/headless/transcript/rail.js +165 -23
- package/dist/chat/headless/transcript/rows.d.ts +5 -1
- package/dist/chat/headless/transcript/run-failures.js +2 -1
- package/dist/chat/headless/transcript/seams.d.ts +78 -0
- package/dist/chat/headless/transcript/seams.js +116 -0
- package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
- package/dist/chat/headless/transcript/tool-media.js +27 -9
- package/dist/chat/index.d.ts +9 -8
- package/dist/chat/index.js +18 -17
- package/dist/chat/sidebar/ProjectIcon.js +1 -1
- package/dist/chat/sidebar/RowChips.js +2 -2
- package/dist/chat/sidebar/SessionSidebar.d.ts +6 -0
- package/dist/chat/sidebar/SessionSidebar.js +23 -16
- package/dist/chat/sidebar/SidebarFilterMenu.js +0 -1
- package/dist/chat/sidebar/SidebarFold.js +17 -16
- package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
- package/dist/chat/sidebar/SidebarFooter.js +6 -6
- package/dist/chat/sidebar/SidebarSessionRow.d.ts +7 -1
- package/dist/chat/sidebar/SidebarSessionRow.js +11 -8
- package/dist/chat/sidebar/session-menu.d.ts +4 -0
- package/dist/chat/sidebar/session-menu.js +14 -2
- package/dist/chat/sidebar/sidebar-live.js +28 -4
- package/dist/chat/sidebar/useInboxRows.js +6 -6
- package/dist/chat/sidebar/useInboxTriage.js +50 -47
- package/dist/chat/sidebar/useSessionSearch.js +19 -18
- package/dist/chat/testing/contract.d.ts +5 -3
- package/dist/chat/testing/contract.js +66 -1
- package/dist/chat/transcript/DiffLines.d.ts +6 -1
- package/dist/chat/transcript/DiffLines.js +35 -20
- package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
- package/dist/chat/transcript/EditDiffBlock.js +89 -30
- package/dist/chat/transcript/FileChip.js +28 -0
- package/dist/chat/transcript/LazyRow.d.ts +40 -40
- package/dist/chat/transcript/LazyRow.js +100 -149
- package/dist/chat/transcript/MermaidDiagram.js +2 -1
- package/dist/chat/transcript/PromptEcho.js +3 -11
- package/dist/chat/transcript/SessionChip.d.ts +11 -0
- package/dist/chat/transcript/SessionChip.js +34 -0
- package/dist/chat/transcript/SubagentBlock.js +3 -2
- package/dist/chat/transcript/TranscriptRail.d.ts +25 -2
- package/dist/chat/transcript/TranscriptRail.js +175 -17
- package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
- package/dist/chat/transcript/TranscriptRow.js +4 -3
- package/dist/chat/transcript/actions.d.ts +37 -1
- package/dist/chat/transcript/actions.js +27 -1
- package/dist/chat/transcript/chip-details.d.ts +11 -0
- package/dist/chat/transcript/chip-details.js +17 -1
- package/dist/chat/transcript/clipped-output.d.ts +58 -0
- package/dist/chat/transcript/clipped-output.js +131 -0
- package/dist/chat/transcript/fold-attachments.js +10 -5
- package/dist/chat/transcript/fold-worker.js +5 -3
- package/dist/chat/transcript/fold.js +13 -4
- package/dist/chat/transcript/index.d.ts +11 -10
- package/dist/chat/transcript/index.js +10 -9
- package/dist/chat/transcript/markdown-cache.d.ts +17 -2
- package/dist/chat/transcript/markdown-cache.js +48 -4
- package/dist/chat/transcript/markdown.js +110 -55
- package/dist/chat/transcript/media-gallery.d.ts +3 -2
- package/dist/chat/transcript/media-gallery.js +19 -19
- package/dist/chat/transcript/messages.js +5 -4
- package/dist/chat/transcript/notices.js +2 -1
- package/dist/chat/transcript/prompt.d.ts +1 -1
- package/dist/chat/transcript/prompt.js +6 -4
- package/dist/chat/transcript/prose.js +2 -1
- package/dist/chat/transcript/root-items.d.ts +96 -0
- package/dist/chat/transcript/root-items.js +180 -0
- package/dist/chat/transcript/row-mount.d.ts +184 -0
- package/dist/chat/transcript/row-mount.js +532 -0
- package/dist/chat/transcript/row-parking.d.ts +152 -0
- package/dist/chat/transcript/row-parking.js +171 -0
- package/dist/chat/transcript/row-ui-state.d.ts +37 -0
- package/dist/chat/transcript/row-ui-state.js +53 -0
- package/dist/chat/transcript/run-rows.js +3 -2
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/chat/transcript/tasks.js +3 -2
- package/dist/chat/transcript/tool-media.d.ts +4 -2
- package/dist/chat/transcript/tool-media.js +15 -7
- package/dist/chat/transcript/tool-parts.d.ts +27 -4
- package/dist/chat/transcript/tool-parts.js +31 -6
- package/dist/chat/transcript/tool-payload.js +26 -11
- package/dist/chat/transcript/tool-row.d.ts +2 -1
- package/dist/chat/transcript/tool-row.js +38 -19
- package/dist/chat/transcript/use-transcript-rows.d.ts +25 -8
- package/dist/chat/transcript/use-transcript-rows.js +28 -46
- package/dist/chat/transcript/useHistoryBackfill.d.ts +42 -0
- package/dist/chat/transcript/useHistoryBackfill.js +170 -0
- package/dist/chat/transcript/useStickToBottom.js +2 -3
- package/dist/chat/transcript/useTranscriptFind.js +2 -4
- package/dist/chat/transcript/useTranscriptScroll.d.ts +7 -4
- package/dist/chat/transcript/useTranscriptScroll.js +12 -1
- package/dist/chat/transcript/useTranscriptSearch.d.ts +2 -2
- package/dist/chat/transcript/useTranscriptSearch.js +35 -19
- package/dist/chat/transcript/useTranscriptSelectionCopy.d.ts +5 -5
- package/dist/chat/transcript/useTranscriptSelectionCopy.js +28 -7
- package/dist/chat/transcript/view-scope.d.ts +26 -6
- package/dist/chat/transcript/view-scope.js +106 -20
- package/dist/code/editor/FileTree.d.ts +2 -0
- package/dist/code/editor/FileTree.js +1 -1
- package/dist/code/editor/FileView.js +16 -25
- package/dist/code/editor/find/useFind.js +17 -17
- package/dist/code/editor/useCodeDocument.js +22 -19
- package/dist/code/editor/useDetachCleanup.js +4 -3
- package/dist/code/use-highlighted-html.js +12 -13
- package/dist/components/IconButton.d.ts +3 -1
- package/dist/components/IconButton.js +7 -2
- package/dist/components/IconButtonTip.d.ts +3 -1
- package/dist/components/IconButtonTip.js +2 -1
- package/dist/components/RowActionsMenu.js +7 -14
- package/dist/components/Tooltip.d.ts +4 -1
- package/dist/components/Tooltip.js +8 -6
- package/dist/components/assign-ref.d.ts +8 -0
- package/dist/components/assign-ref.js +12 -0
- package/dist/components/floating/FloatingSurface.js +2 -2
- package/dist/components/floating/HoverCard.js +32 -14
- package/dist/components/floating/Popover.js +4 -7
- package/dist/components/floating/useAnchoredPosition.d.ts +5 -3
- package/dist/components/floating/useAnchoredPosition.js +7 -7
- package/dist/components/object-key.d.ts +7 -0
- package/dist/components/object-key.js +18 -0
- package/dist/components/palette/PaletteList.js +2 -7
- package/dist/components/tooltip-arming.d.ts +3 -0
- package/dist/components/tooltip-arming.js +8 -1
- package/dist/core.css +3 -3
- package/dist/dist/{index-E1Z0aPmi.d.ts → index-BheVJOLc.d.ts} +3 -1
- package/dist/dist/index.d.ts +2 -2
- package/dist/files/FilesTab.js +0 -1
- package/dist/files/TreeColumn.d.ts +2 -4
- package/dist/files/TreeColumn.js +0 -5
- package/dist/files/headless/host.d.ts +3 -7
- package/dist/files/headless/labels.d.ts +0 -1
- package/dist/files/headless/labels.js +0 -1
- package/dist/files/headless/workspace-diff.js +1 -1
- package/dist/files/useCodeReview.js +1 -3
- package/dist/files/useFilesDiagnostics.d.ts +1 -1
- package/dist/files/useFilesDiagnostics.js +4 -11
- package/dist/files/useOpenFiles.js +9 -12
- package/dist/files/useWorkspace.d.ts +5 -7
- package/dist/files/useWorkspace.js +4 -15
- package/dist/git/GitBar.js +5 -3
- package/dist/git/MoveSessionDialog.d.ts +18 -8
- package/dist/git/MoveSessionDialog.js +32 -53
- package/dist/git/MoveToDialog.d.ts +61 -0
- package/dist/git/MoveToDialog.js +240 -0
- package/dist/git/SandboxManager.js +9 -4
- package/dist/git/SyncChip.js +11 -4
- package/dist/git/TeleportSessionDialog.d.ts +69 -0
- package/dist/git/TeleportSessionDialog.js +440 -0
- package/dist/git/headless/host.d.ts +14 -0
- package/dist/git/headless/index.d.ts +2 -1
- package/dist/git/headless/index.js +2 -1
- package/dist/git/headless/labels.d.ts +44 -1
- package/dist/git/headless/labels.js +50 -0
- package/dist/git/headless/sandboxes.d.ts +1 -1
- package/dist/git/headless/sandboxes.js +4 -3
- package/dist/git/headless/teleport.d.ts +76 -0
- package/dist/git/headless/teleport.js +19 -0
- package/dist/git/index.d.ts +4 -2
- package/dist/git/index.js +4 -2
- package/dist/git/useEnvironmentChoices.d.ts +5 -2
- package/dist/git/useEnvironmentChoices.js +12 -4
- package/dist/hooks/useLatest.d.ts +8 -0
- package/dist/hooks/useLatest.js +17 -0
- package/dist/hooks/useMinuteTick.d.ts +6 -2
- package/dist/hooks/useMinuteTick.js +12 -6
- package/dist/hooks/useNearViewport.js +11 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/keybindings/KeybindingsProvider.js +3 -4
- package/dist/keybindings/headless/catalog.d.ts +1 -1
- package/dist/keybindings/headless/catalog.js +18 -0
- package/dist/machines/AddServerForm.js +55 -3
- package/dist/machines/Banners.d.ts +2 -2
- package/dist/machines/Banners.js +3 -3
- package/dist/machines/DaemonMenu.js +1 -3
- package/dist/machines/HostsSection.js +5 -1
- package/dist/machines/OrganizationPanel.d.ts +25 -0
- package/dist/machines/OrganizationPanel.js +266 -0
- package/dist/machines/PersonalLayerPanel.d.ts +32 -0
- package/dist/machines/PersonalLayerPanel.js +360 -0
- package/dist/machines/headless/fixture-host.d.ts +10 -0
- package/dist/machines/headless/fixture-host.js +44 -0
- package/dist/machines/headless/host.d.ts +21 -1
- package/dist/machines/headless/index.d.ts +3 -1
- package/dist/machines/headless/index.js +3 -1
- package/dist/machines/headless/labels.d.ts +55 -0
- package/dist/machines/headless/labels.js +58 -1
- package/dist/machines/headless/layer.d.ts +64 -0
- package/dist/machines/headless/layer.js +56 -0
- package/dist/machines/headless/organization.d.ts +38 -0
- package/dist/machines/headless/organization.js +44 -0
- package/dist/machines/index.d.ts +3 -1
- package/dist/machines/index.js +3 -1
- package/dist/machines/testing/contract.d.ts +25 -1
- package/dist/machines/testing/contract.js +97 -1
- package/dist/motion/grow.js +12 -13
- package/dist/motion/swap.js +2 -5
- package/dist/motion/use-flip-list.d.ts +14 -0
- package/dist/motion/use-flip-list.js +17 -12
- package/dist/palette/headless/app-sources.js +37 -0
- package/dist/palette/headless/labels.js +3 -0
- package/dist/server/sse-handler.js +25 -2
- package/dist/session/DiffFileTree.js +1 -4
- package/dist/session/OpenSessionsDialog.d.ts +46 -0
- package/dist/session/OpenSessionsDialog.js +170 -0
- package/dist/session/PlanTracker.js +1 -2
- package/dist/session/ProjectHome.js +10 -9
- package/dist/session/RemindersPanel.js +10 -12
- package/dist/session/SecretsPanel.js +2 -1
- package/dist/session/SessionHeader.js +1 -0
- package/dist/session/SessionPeopleStack.d.ts +23 -0
- package/dist/session/SessionPeopleStack.js +65 -0
- package/dist/session/SessionPlaceMenu.js +5 -4
- package/dist/session/ShareSessionDialog.d.ts +32 -0
- package/dist/session/ShareSessionDialog.js +342 -0
- package/dist/session/TypingLine.d.ts +22 -0
- package/dist/session/TypingLine.js +31 -0
- package/dist/session/headless/host.d.ts +40 -1
- package/dist/session/headless/index.d.ts +4 -2
- package/dist/session/headless/index.js +3 -1
- package/dist/session/headless/labels.d.ts +49 -0
- package/dist/session/headless/labels.js +56 -0
- package/dist/session/headless/people.d.ts +29 -0
- package/dist/session/headless/people.js +53 -0
- package/dist/session/headless/place.d.ts +5 -0
- package/dist/session/headless/place.js +5 -1
- package/dist/session/headless/typing.d.ts +37 -0
- package/dist/session/headless/typing.js +60 -0
- package/dist/session/index.d.ts +5 -1
- package/dist/session/index.js +5 -1
- package/dist/settings/headless/fixture-performance.js +4 -2
- package/dist/settings/headless/performance.d.ts +4 -0
- package/dist/settings/headless/search.d.ts +1 -1
- package/dist/settings/headless/sections-host.d.ts +7 -2
- package/dist/settings/section.d.ts +15 -3
- package/dist/settings/section.js +15 -3
- package/dist/settings/sections/environments/EnvironmentsSection.js +30 -6
- package/dist/settings/sections/keybindings/labels.d.ts +3 -0
- package/dist/settings/sections/keybindings/labels.js +3 -0
- package/dist/settings/sections/keybindings/rows.js +12 -0
- package/dist/settings/sections/logs/LogsSection.js +5 -8
- package/dist/settings/sections/performance/PerformanceSection.js +8 -1
- package/dist/settings/sections/performance/labels.d.ts +2 -0
- package/dist/settings/sections/performance/labels.js +2 -0
- package/dist/styles.css +65 -9
- package/dist/terminal/HostTerminalSurface.js +28 -30
- package/dist/terminal/TerminalPanel.js +4 -12
- package/dist/terminal/TerminalProvider.d.ts +10 -2
- package/dist/terminal/TerminalProvider.js +10 -2
- package/dist/terminal/headless/labels.d.ts +0 -1
- package/dist/terminal/headless/labels.js +1 -2
- package/dist/terminal/headless/store.js +5 -1
- package/dist/views/headless/answers.d.ts +8 -2
- package/dist/views/headless/answers.js +58 -1
- package/dist/views/headless/placement.d.ts +78 -0
- package/dist/views/headless/placement.js +154 -44
- package/dist/workspace/LayoutBudget.js +1 -7
- package/package.json +2 -2
- package/src/styles/chat.css +3 -1
- package/src/styles/palette.css +3 -3
- package/src/styles/transcript.css +50 -5
- /package/dist/dist/{index-De9AbmxS.d.ts → index-ttmMvjgM.d.ts} +0 -0
|
@@ -10,20 +10,22 @@ import { SessionStreamStore } from "./streams/store.js";
|
|
|
10
10
|
import { DEFAULT_MODEL_PICKER_PREFS, MODEL_PICKER_STORAGE_KEY, createModelPickerPrefs, parseModelPickerPrefs } from "./composer/model-picker-prefs.js";
|
|
11
11
|
import { EMPTY_RUN_METER, createRunMeter } from "./composer/run-meter.js";
|
|
12
12
|
import { beginChipWork, chipWorkBusy, resetChipWorkForTests, whenChipsSettle } from "./chip-settle.js";
|
|
13
|
-
import { applyInboxPatch, isSettled, isSnoozed, nextWakeAt } from "./sidebar/inbox-state.js";
|
|
14
13
|
import { commandName, commandView, commitView, sessionForToken, sessionView, skillGroupView, skillName, skillView } from "./chip-views.js";
|
|
14
|
+
import { applyInboxPatch, isSettled, isSnoozed, nextWakeAt } from "./sidebar/inbox-state.js";
|
|
15
15
|
import { caretEffectivelyAtStart, composeSubmitText, decodeHistoryEntry, encodeHistoryDraft, exitsModeOnKey, modeForTypedChar, unsentDraft } from "./composer-modes.js";
|
|
16
|
+
import { createSessionStreams } from "./streams/session-streams.js";
|
|
17
|
+
import { createDraftScopeStore, draftScopeOf } from "./draft-scope.js";
|
|
16
18
|
import { DEFAULT_COMPOSER_CHROME_LABELS } from "./composer/labels-chrome.js";
|
|
17
19
|
import { DEFAULT_COMPOSER_LABELS } from "./composer/labels.js";
|
|
18
|
-
import {
|
|
19
|
-
import { draftFolderPath, draftLocalFolder, recentHostFolders, recentLocalFolders } from "./draft-target.js";
|
|
20
|
+
import { draftFolderPath, draftLocalFolder, recentHostFolders, recentLocalFolders, unavailablePlaceIssue } from "./draft-target.js";
|
|
20
21
|
import { chipForPath, classifyInlineCode, positionSuffix, resolveChipPath } from "./file-chip.js";
|
|
21
22
|
import { hostReachable, hostStatusLabel } from "./hosts.js";
|
|
22
23
|
import { DEFAULT_CHAT_LABELS, secretExpiryWords } from "./labels.js";
|
|
23
24
|
import { CHUNK_THRESHOLD, openFenceOf, splitMarkdown, withoutPartialEmphasis, withoutPartialFence } from "./markdown-chunks.js";
|
|
24
25
|
import { approvalNotificationDetail, notificationContent, questionNotificationDetail, shouldNotify } from "./notifications.js";
|
|
25
|
-
import { createPathResolver } from "./path-resolver.js";
|
|
26
26
|
import { findCommand } from "./composer/commands.js";
|
|
27
|
+
import { TOOL_OUTPUT_PAGE_SIZE, createToolOutputPager, sliceToolOutput, toolOutputPagerDone } from "./output-pager.js";
|
|
28
|
+
import { createPathResolver } from "./path-resolver.js";
|
|
27
29
|
import { promptOriginWire } from "./prompt-origin.js";
|
|
28
30
|
import { REFERENCES_STORAGE_KEY, createReferenceStore } from "./reference-store.js";
|
|
29
31
|
import { authFailureDetails, createAuthFixes, isAuthFixed, planAuthCard } from "./transcript/auth-failure.js";
|
|
@@ -33,27 +35,23 @@ import { foldActionItems, toolAction } from "./transcript/fold-actions.js";
|
|
|
33
35
|
import { dockRunReceipts, dotVariantFor, findLastStreamingRow, foldExchanges, foldWorkerRows } from "./transcript/fold.js";
|
|
34
36
|
import { nestToolCalls, nestedCallVisible } from "./transcript/nesting.js";
|
|
35
37
|
import { computeSelectStops, rowTurnIds, stopForRow } from "./transcript/select-stops.js";
|
|
36
|
-
import { EMPTY_RAIL, computeRailModel, createTranscriptRailStore, dataRowSelector, plainPreview, sameRail } from "./transcript/rail.js";
|
|
38
|
+
import { EMPTY_RAIL, computeRailModel, computeRailModelParts, createTranscriptRailStore, dataRowSelector, plainPreview, railWithOutline, sameRail } from "./transcript/rail.js";
|
|
37
39
|
import { failureTooltip, markRunFailures } from "./transcript/run-failures.js";
|
|
38
40
|
import { secretTimeLeft, secretTimeLeftIso } from "./secrets.js";
|
|
39
|
-
import { createModelKnobs, modelKnobsOf } from "./composer/model-knobs.js";
|
|
40
|
-
import { createModelNames, modelNamesOf, namerFor } from "./composer/model-names.js";
|
|
41
|
-
import { NO_PROVIDER_ERROR, newSessionRequest, promptAttachments, promptRefs, sendPrompt, shellCommandOf, wireOriginal } from "./send-flow.js";
|
|
42
41
|
import { createRunEstimates, pickRunEstimate } from "./sidebar/estimates.js";
|
|
43
42
|
import { createSessionStreamActions } from "./streams/actions.js";
|
|
44
43
|
import { selectEditEvents, stableSelection } from "./streams/selectors.js";
|
|
45
|
-
import { createSessionStreams } from "./streams/session-streams.js";
|
|
46
44
|
import { composeLiveCost, formatSessionCostLabel } from "./composer/live-cost.js";
|
|
45
|
+
import { createModelKnobs, modelKnobsOf } from "./composer/model-knobs.js";
|
|
46
|
+
import { createModelNames, modelNamesOf, namerFor } from "./composer/model-names.js";
|
|
47
47
|
import { commitModelPick, lastModelChainOf, rememberableChain, rememberedPick, settledResource } from "./composer/remember-model-pick.js";
|
|
48
48
|
import { MAX_EXTENSION_COMPOSER_BADGES, conversationBadges, resolveBadgePanel } from "./composer/conversation-badges.js";
|
|
49
|
-
import {
|
|
49
|
+
import { NO_PROVIDER_ERROR, newSessionRequest, promptAttachments, promptRefs, sendPrompt, shellCommandOf, wireOriginal } from "./send-flow.js";
|
|
50
50
|
import { defaultModelPatch, effortPickerTarget, rememberedDefaultModel } from "./composer/new-session-defaults.js";
|
|
51
|
+
import { PROJECT_GROUP_CAP, RELATIVE_TIME_DATE_AFTER_DAYS, buildSessionRows, compareSessions, dateBucket, filterSessions, formatElapsedShort, relativeTime } from "./session-list.js";
|
|
51
52
|
import { wireAttachmentsToChat } from "./composer/draft-sync.js";
|
|
52
53
|
import { createSiteIcons, siteOrigin } from "./site-icons.js";
|
|
53
|
-
import { COMMON_EMOJI, MAIN_SESSION_ICON_KEY, PROJECT_ICONS_KEY, firstGrapheme, isProjectIcon, parseProjectIcons } from "./sidebar/project-icons.js";
|
|
54
54
|
import { DEFAULT_SIDEBAR_LABELS } from "./sidebar/labels.js";
|
|
55
|
-
import { deleteSessionPrompt, environmentKindLabel, environmentSummaryText, runsInRemoteSandbox } from "./sidebar/environment.js";
|
|
56
|
-
import { pinSession, pinnedSessions } from "./sidebar/pinned-sessions.js";
|
|
57
55
|
import { activityLabel, createSessionActivity, reduceActivity } from "./sidebar/activity.js";
|
|
58
56
|
import { createSessionBadges } from "./sidebar/badges.js";
|
|
59
57
|
import { createCompactionProgress, reduceCompaction } from "./sidebar/compaction.js";
|
|
@@ -64,12 +62,15 @@ import { CHATS_BUCKET, buildHostSidebarRows, buildQuerySidebarRows, buildSidebar
|
|
|
64
62
|
import { DEFAULT_SIDEBAR_VIEW, DEFAULT_SIDEBAR_VIEW_DEFAULTS, DEFAULT_SWITCHER_PREFS, SIDEBAR_SPACE_KEY, SIDEBAR_SWITCHER_KEY, SIDEBAR_VIEW_KEY, SIDEBAR_VIEW_VERSION, createSidebarViews, defaultSidebarLayout, parseSidebarView, parseSidebarViewPicks, parseSwitcherPrefs, readSidebarViews, resolveSidebarView, sidebarLayoutOf, sidebarViewDefaults } from "./sidebar/view.js";
|
|
65
63
|
import { availableProjectsOf, createSessionDirectory, filterDirectorySessions, projectKeyOf, sessionRefsOf } from "./sidebar/directory.js";
|
|
66
64
|
import { deriveDotState } from "./sidebar/dot-state.js";
|
|
65
|
+
import { deleteSessionPrompt, environmentKindLabel, environmentLabel, environmentSummaryText, runsInRemoteSandbox } from "./sidebar/environment.js";
|
|
67
66
|
import { SESSION_HISTORY_LIMIT, createSessionHistory, parseSessionHistory } from "./sidebar/history.js";
|
|
68
67
|
import { INBOX_EARLIER_AFTER_MS, INBOX_PAGE, INBOX_PAGE_MORE, INBOX_RUN_HOLD_MS, INBOX_SHELVES, INBOX_SHELVES_FOLDED, INBOX_SHELVES_KEY, buildInboxRows, compareInboxSection, inboxDockStart, inboxEarlierAfterMs, inboxFolderOf, inboxSectionOf, inboxSessionOrder, nextInboxChangeAt } from "./sidebar/inbox.js";
|
|
69
68
|
import { PINNED_PROJECTS_KEY, parsePinnedProjects, withPinnedProject } from "./sidebar/pinned-projects.js";
|
|
69
|
+
import { pinSession, pinnedSessions } from "./sidebar/pinned-sessions.js";
|
|
70
|
+
import { COMMON_EMOJI, MAIN_SESSION_ICON_KEY, PROJECT_ICONS_KEY, firstGrapheme, isProjectIcon, parseProjectIcons } from "./sidebar/project-icons.js";
|
|
70
71
|
import { SMOOTH_TICK_MS, drainBucket, safeSurrogateSlice, tickBucket } from "./smooth-stream.js";
|
|
71
72
|
import { constant, useReadable, writable } from "./store.js";
|
|
72
73
|
import { createComposerLists } from "./composer/composer-sources.js";
|
|
73
74
|
import { UNDECIDED_NEW_CHAT_DRAFT_KEY, createDraftBook, createWebStorageDraftStorage, draftBookOf, newChatDraftKey } from "./composer/draft-book.js";
|
|
74
75
|
import { promptDraftOf } from "./turn-prompt.js";
|
|
75
|
-
export { AGENT_GROUPING, CHATS_BUCKET, CHUNK_THRESHOLD, COMMON_EMOJI, DEFAULT_CHAT_LABELS, DEFAULT_COMPOSER_CHROME_LABELS, DEFAULT_COMPOSER_LABELS, DEFAULT_MODEL_PICKER_PREFS, DEFAULT_SIDEBAR_LABELS, DEFAULT_SIDEBAR_VIEW, DEFAULT_SIDEBAR_VIEW_DEFAULTS, DEFAULT_SWITCHER_PREFS, EMPTY_RAIL, EMPTY_RUN_METER, INBOX_EARLIER_AFTER_MS, INBOX_PAGE, INBOX_PAGE_MORE, INBOX_RUN_HOLD_MS, INBOX_SHELVES, INBOX_SHELVES_FOLDED, INBOX_SHELVES_KEY, LIVE_BLOCK_RUN_LINES, MAIN_SESSION_ICON_KEY, MAX_EXTENSION_COMPOSER_BADGES, MAX_ROW_CHIPS, MODEL_PICKER_STORAGE_KEY, NO_PROVIDER_ERROR, NO_SIDEBAR_CONTRIBUTIONS, PINNED_PROJECTS_KEY, PROJECT_GROUP_CAP, PROJECT_ICONS_KEY, REFERENCES_STORAGE_KEY, RELATIVE_TIME_DATE_AFTER_DAYS, SESSION_HISTORY_LIMIT, SIDEBAR_SPACE_KEY, SIDEBAR_SWITCHER_KEY, SIDEBAR_VIEW_KEY, SIDEBAR_VIEW_VERSION, SMOOTH_TICK_MS, SessionStreamStore, UNDECIDED_NEW_CHAT_DRAFT_KEY, VIEW_CHOICE, activityLabel, applyInboxPatch, approvalNotificationDetail, authFailureDetails, availableProjectsOf, batchTaskRuns, batchThinkingRuns, batchToolRuns, beginChipWork, buildHostSidebarRows, buildInboxRows, buildQuerySidebarRows, buildSessionRows, buildSidebarRows, caretEffectivelyAtStart, chipForPath, chipWorkBusy, claimChildSessions, classifyInlineCode, clearedViewFilters, clusterByOwner, collapseEvents, commandName, commandRef, commandView, commitModelPick, commitView, compareInboxSection, compareSessions, composeLiveCost, composeSubmitText, computeRailModel, computeSelectStops, constant, conversationBadges, createAuthFixes, createChatBlockRuns, createCompactionProgress, createComposerLists, createDecorator, createDraftBook, createDraftScopeStore, createModelKnobs, createModelNames, createModelPickerPrefs, createNotificationStore, createPathResolver, createReferenceStore, createRunEstimates, createRunMeter, createSessionActivity, createSessionBadges, createSessionDirectory, createSessionHistory, createSessionStreamActions, createSessionStreams, createSidebarViews, createSiteIcons, createTranscriptRailStore, createWebStorageDraftStorage, dataRowSelector, dateBucket, decodeHistoryEntry, defaultFrameScheduler, defaultModelPatch, defaultSidebarLayout, deleteSessionPrompt, deriveDotState, dockRunReceipts, dotVariantFor, draftBookOf, draftFolderPath, draftLocalFolder, draftScopeOf, drainBucket, effortPickerTarget, encodeHistoryDraft, environmentKindLabel, environmentSummaryText, exchangesMedia, exitsModeOnKey, extensionSpaceOf, failureTooltip, filterDirectorySessions, filterQueryOf, filterSessions, filtersForSpace, findCommand, findLastStreamingRow, firstGrapheme, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, formatElapsedShort, formatSessionCostLabel, groupsByFolder, hostReachable, hostStatusLabel, inboxDockStart, inboxEarlierAfterMs, inboxFolderOf, inboxSectionOf, inboxSessionOrder, inheritRowIdentity, isAuthFixed, isProjectIcon, isProjectMember, isSettled, isSnoozed, itemRows, itemsForSpace, lastModelChainOf, markRunFailures, mediaRefsOf, mediumKey, mergeLiveTail, mergePromptPreviews, mergeSidebarSpaces, missingPreviewData, modeForTypedChar, modelKnobsOf, modelNamesOf, namerFor, nestSidebarRows, nestToolCalls, nestedCallVisible, newChatDraftKey, newSessionRequest, nextInboxChangeAt, nextSavedViewName, nextWakeAt, notificationContent, openFenceOf, pairToolEvents, parseBashExitMeta, parseModelPickerPrefs, parsePinnedProjects, parseProjectIcons, parseSessionHistory, parseSidebarView, parseSidebarViewPicks, parseSwitcherPrefs, partitionMainSession, pickRunEstimate, pinSession, pinnedSessions, plainPreview, planAuthCard, positionSuffix, projectKeyOf, projectPathOf, promptAttachments, promptDraftOf, promptOriginWire, promptRefs, questionNotificationDetail, readSidebarViews, recentHostFolders, recentLocalFolders, reduceActivity, reduceCompaction, refusedSpawn, relativeTime, rememberableChain, rememberedDefaultModel, rememberedPick, repoGroups, resetChipWorkForTests, resolveBadgePanel, resolveChipPath, resolveGrouping, resolveSidebarView, resolveSort, rowTurnIds, runsInRemoteSandbox, safeSurrogateSlice, sameRail, secretExpiryWords, secretTimeLeft, secretTimeLeftIso, selectEditEvents, sendPrompt, sessionForToken, sessionRefsOf, sessionView, settledResource, shellCommandOf, shortUrl, shouldNotify, sidebarContributionsOf, sidebarLayoutOf, sidebarViewDefaults, siteOrigin, skillGroupView, skillName, skillView, spaceMembership, splitMarkdown, stableSelection, stopForRow, switcherSpaces, tickBucket, toolAction, toolFailed, unsentDraft, urlRefs, useReadable, viewFilterOf, viewFiltersOn, whenChipsSettle, wireAttachmentsToChat, wireOriginal, withPinnedProject, withoutPartialEmphasis, withoutPartialFence, writable };
|
|
76
|
+
export { AGENT_GROUPING, CHATS_BUCKET, CHUNK_THRESHOLD, COMMON_EMOJI, DEFAULT_CHAT_LABELS, DEFAULT_COMPOSER_CHROME_LABELS, DEFAULT_COMPOSER_LABELS, DEFAULT_MODEL_PICKER_PREFS, DEFAULT_SIDEBAR_LABELS, DEFAULT_SIDEBAR_VIEW, DEFAULT_SIDEBAR_VIEW_DEFAULTS, DEFAULT_SWITCHER_PREFS, EMPTY_RAIL, EMPTY_RUN_METER, INBOX_EARLIER_AFTER_MS, INBOX_PAGE, INBOX_PAGE_MORE, INBOX_RUN_HOLD_MS, INBOX_SHELVES, INBOX_SHELVES_FOLDED, INBOX_SHELVES_KEY, LIVE_BLOCK_RUN_LINES, MAIN_SESSION_ICON_KEY, MAX_EXTENSION_COMPOSER_BADGES, MAX_ROW_CHIPS, MODEL_PICKER_STORAGE_KEY, NO_PROVIDER_ERROR, NO_SIDEBAR_CONTRIBUTIONS, PINNED_PROJECTS_KEY, PROJECT_GROUP_CAP, PROJECT_ICONS_KEY, REFERENCES_STORAGE_KEY, RELATIVE_TIME_DATE_AFTER_DAYS, SESSION_HISTORY_LIMIT, SIDEBAR_SPACE_KEY, SIDEBAR_SWITCHER_KEY, SIDEBAR_VIEW_KEY, SIDEBAR_VIEW_VERSION, SMOOTH_TICK_MS, SessionStreamStore, TOOL_OUTPUT_PAGE_SIZE, UNDECIDED_NEW_CHAT_DRAFT_KEY, VIEW_CHOICE, activityLabel, applyInboxPatch, approvalNotificationDetail, authFailureDetails, availableProjectsOf, batchTaskRuns, batchThinkingRuns, batchToolRuns, beginChipWork, buildHostSidebarRows, buildInboxRows, buildQuerySidebarRows, buildSessionRows, buildSidebarRows, caretEffectivelyAtStart, chipForPath, chipWorkBusy, claimChildSessions, classifyInlineCode, clearedViewFilters, clusterByOwner, collapseEvents, commandName, commandRef, commandView, commitModelPick, commitView, compareInboxSection, compareSessions, composeLiveCost, composeSubmitText, computeRailModel, computeRailModelParts, computeSelectStops, constant, conversationBadges, createAuthFixes, createChatBlockRuns, createCompactionProgress, createComposerLists, createDecorator, createDraftBook, createDraftScopeStore, createModelKnobs, createModelNames, createModelPickerPrefs, createNotificationStore, createPathResolver, createReferenceStore, createRunEstimates, createRunMeter, createSessionActivity, createSessionBadges, createSessionDirectory, createSessionHistory, createSessionStreamActions, createSessionStreams, createSidebarViews, createSiteIcons, createToolOutputPager, createTranscriptRailStore, createWebStorageDraftStorage, dataRowSelector, dateBucket, decodeHistoryEntry, defaultFrameScheduler, defaultModelPatch, defaultSidebarLayout, deleteSessionPrompt, deriveDotState, dockRunReceipts, dotVariantFor, draftBookOf, draftFolderPath, draftLocalFolder, draftScopeOf, drainBucket, effortPickerTarget, encodeHistoryDraft, environmentKindLabel, environmentLabel, environmentSummaryText, exchangesMedia, exitsModeOnKey, extensionSpaceOf, failureTooltip, filterDirectorySessions, filterQueryOf, filterSessions, filtersForSpace, findCommand, findLastStreamingRow, firstGrapheme, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, formatElapsedShort, formatSessionCostLabel, groupsByFolder, hostReachable, hostStatusLabel, inboxDockStart, inboxEarlierAfterMs, inboxFolderOf, inboxSectionOf, inboxSessionOrder, inheritRowIdentity, isAuthFixed, isProjectIcon, isProjectMember, isSettled, isSnoozed, itemRows, itemsForSpace, lastModelChainOf, markRunFailures, mediaRefsOf, mediumKey, mergeLiveTail, mergePromptPreviews, mergeSidebarSpaces, missingPreviewData, modeForTypedChar, modelKnobsOf, modelNamesOf, namerFor, nestSidebarRows, nestToolCalls, nestedCallVisible, newChatDraftKey, newSessionRequest, nextInboxChangeAt, nextSavedViewName, nextWakeAt, notificationContent, openFenceOf, pairToolEvents, parseBashExitMeta, parseModelPickerPrefs, parsePinnedProjects, parseProjectIcons, parseSessionHistory, parseSidebarView, parseSidebarViewPicks, parseSwitcherPrefs, partitionMainSession, pickRunEstimate, pinSession, pinnedSessions, plainPreview, planAuthCard, positionSuffix, projectKeyOf, projectPathOf, promptAttachments, promptDraftOf, promptOriginWire, promptRefs, questionNotificationDetail, railWithOutline, readSidebarViews, recentHostFolders, recentLocalFolders, reduceActivity, reduceCompaction, refusedSpawn, relativeTime, rememberableChain, rememberedDefaultModel, rememberedPick, repoGroups, resetChipWorkForTests, resolveBadgePanel, resolveChipPath, resolveGrouping, resolveSidebarView, resolveSort, rowTurnIds, runsInRemoteSandbox, safeSurrogateSlice, sameRail, secretExpiryWords, secretTimeLeft, secretTimeLeftIso, selectEditEvents, sendPrompt, sessionForToken, sessionRefsOf, sessionView, settledResource, shellCommandOf, shortUrl, shouldNotify, sidebarContributionsOf, sidebarLayoutOf, sidebarViewDefaults, siteOrigin, skillGroupView, skillName, skillView, sliceToolOutput, spaceMembership, splitMarkdown, stableSelection, stopForRow, switcherSpaces, tickBucket, toolAction, toolFailed, toolOutputPagerDone, unavailablePlaceIssue, unsentDraft, urlRefs, useReadable, viewFilterOf, viewFiltersOn, whenChipsSettle, wireAttachmentsToChat, wireOriginal, withPinnedProject, withoutPartialEmphasis, withoutPartialFence, writable };
|
|
@@ -135,6 +135,23 @@ export declare const DEFAULT_CHAT_LABELS: {
|
|
|
135
135
|
modelVerdictTitle: (approved: boolean, model: string, confidence: string | null) => string;
|
|
136
136
|
loadFullOutput: string;
|
|
137
137
|
loadingFullOutput: string;
|
|
138
|
+
/** A paged result (`ChatHost.toolOutputRange`): read its next page. */
|
|
139
|
+
loadMoreOutput: string;
|
|
140
|
+
/** A paged result: read every page still missing. */
|
|
141
|
+
loadAllOutput: string;
|
|
142
|
+
loadingOutput: string;
|
|
143
|
+
/** How much of a paged result shows: the sizes loaded and in all. */
|
|
144
|
+
outputLoaded: (loaded: string, total: string) => string;
|
|
145
|
+
/** A page of a result failed to load (the raw error as the detail). */
|
|
146
|
+
outputLoadFailed: string;
|
|
147
|
+
/** Under an input the host clipped for the wire (`clipped.input`). */
|
|
148
|
+
loadFullInput: string;
|
|
149
|
+
loadingFullInput: string;
|
|
150
|
+
/** Under a diff the host cut to its first hunks (`EditPayload.clipped`). */
|
|
151
|
+
loadFullDiff: string;
|
|
152
|
+
loadingFullDiff: string;
|
|
153
|
+
/** What a diff the host cut leaves out: the hunks it dropped (0: one hunk cut short) and the size of the whole diff's text. */
|
|
154
|
+
diffNotShown: (hunks: number, size: string) => string;
|
|
138
155
|
showOutput: string;
|
|
139
156
|
inputCaption: string;
|
|
140
157
|
outputCaption: string;
|
|
@@ -173,6 +173,23 @@ const DEFAULT_CHAT_LABELS = {
|
|
|
173
173
|
modelVerdictTitle: (approved, model, confidence) => `${approved ? "Approved" : "Blocked"} by the decision model ${model}${confidence ? ` (confidence ${confidence})` : ""}`,
|
|
174
174
|
loadFullOutput: "Load full output",
|
|
175
175
|
loadingFullOutput: "Loading full output…",
|
|
176
|
+
/** A paged result (`ChatHost.toolOutputRange`): read its next page. */
|
|
177
|
+
loadMoreOutput: "Load more",
|
|
178
|
+
/** A paged result: read every page still missing. */
|
|
179
|
+
loadAllOutput: "Load all",
|
|
180
|
+
loadingOutput: "Loading…",
|
|
181
|
+
/** How much of a paged result shows: the sizes loaded and in all. */
|
|
182
|
+
outputLoaded: (loaded, total) => `${loaded} of ${total} loaded`,
|
|
183
|
+
/** A page of a result failed to load (the raw error as the detail). */
|
|
184
|
+
outputLoadFailed: "Couldn't load the output",
|
|
185
|
+
/** Under an input the host clipped for the wire (`clipped.input`). */
|
|
186
|
+
loadFullInput: "Load full input",
|
|
187
|
+
loadingFullInput: "Loading full input…",
|
|
188
|
+
/** Under a diff the host cut to its first hunks (`EditPayload.clipped`). */
|
|
189
|
+
loadFullDiff: "Load full diff",
|
|
190
|
+
loadingFullDiff: "Loading full diff…",
|
|
191
|
+
/** What a diff the host cut leaves out: the hunks it dropped (0: one hunk cut short) and the size of the whole diff's text. */
|
|
192
|
+
diffNotShown: (hunks, size) => hunks > 0 ? `${hunks} more ${hunks === 1 ? "hunk" : "hunks"} not shown, ${size} in all` : `Part of the diff not shown, ${size} in all`,
|
|
176
193
|
showOutput: "Show output",
|
|
177
194
|
inputCaption: "Input",
|
|
178
195
|
outputCaption: "Output",
|
|
@@ -43,7 +43,8 @@ export interface OpenFence {
|
|
|
43
43
|
*/
|
|
44
44
|
export declare function openFenceOf(chunk: string): OpenFence | null;
|
|
45
45
|
/**
|
|
46
|
-
* Splits markdown into chunks that parse on their own, so a long or streaming reply can re-render only its last chunk. Text shorter than the threshold comes back as one chunk.
|
|
46
|
+
* Splits markdown into chunks that parse on their own, so a long or streaming reply can re-render only its last chunk. Text shorter than the threshold, or holding a definition, comes back as one chunk.
|
|
47
|
+
* While a reply streams it re-renders on every delta, so it splits at every block boundary: everything above the open block stays a memoised chunk (`MarkdownStream` keeps that split as the text grows).
|
|
47
48
|
*
|
|
48
49
|
* @param text - The markdown to split.
|
|
49
50
|
* @param opts - Split options. `streaming: true` uses finer chunks for a reply that is still growing.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockScanner, STREAMING_THRESHOLD, fenceLanguage, opensChunk } from "./markdown-scan.js";
|
|
1
2
|
import { isFenceClose, parseFenceOpen } from "zidane/chat/pure";
|
|
2
3
|
// src/chat/headless/markdown-chunks.ts
|
|
3
4
|
/** Below this, one parse is cheap enough: no chunking at all. */
|
|
@@ -9,13 +10,6 @@ function stepFence(fence, line) {
|
|
|
9
10
|
if (fence) return isFenceClose(line, fence.char, fence.length) ? null : fence;
|
|
10
11
|
return parseFenceOpen(line);
|
|
11
12
|
}
|
|
12
|
-
/**
|
|
13
|
-
* While a reply streams it is re-rendered on every delta (many per second),
|
|
14
|
-
* so it splits much finer: everything above the growing paragraph stays a
|
|
15
|
-
* memoised chunk and only the tail is parsed again.
|
|
16
|
-
*/
|
|
17
|
-
const STREAMING_THRESHOLD = 1200;
|
|
18
|
-
const STREAMING_TARGET = 600;
|
|
19
13
|
/** A last line of one or two backticks or tildes: a fence still arriving. */
|
|
20
14
|
const PARTIAL_FENCE = /\n {0,3}(?:`{1,2}|~{1,2})$/;
|
|
21
15
|
/**
|
|
@@ -69,8 +63,7 @@ function openFenceOf(chunk) {
|
|
|
69
63
|
fence = next;
|
|
70
64
|
}
|
|
71
65
|
if (fence === null || fence.indent !== 0) return null;
|
|
72
|
-
const
|
|
73
|
-
const language = /^(\w+)/.exec(info.trim().split(/\s/)[0] ?? "")?.[1] ?? "plaintext";
|
|
66
|
+
const language = fenceLanguage(lines[at].slice(fence.length));
|
|
74
67
|
return {
|
|
75
68
|
before: lines.slice(0, at).join("\n"),
|
|
76
69
|
language,
|
|
@@ -78,31 +71,30 @@ function openFenceOf(chunk) {
|
|
|
78
71
|
};
|
|
79
72
|
}
|
|
80
73
|
/**
|
|
81
|
-
* Splits markdown into chunks that parse on their own, so a long or streaming reply can re-render only its last chunk. Text shorter than the threshold comes back as one chunk.
|
|
74
|
+
* Splits markdown into chunks that parse on their own, so a long or streaming reply can re-render only its last chunk. Text shorter than the threshold, or holding a definition, comes back as one chunk.
|
|
75
|
+
* While a reply streams it re-renders on every delta, so it splits at every block boundary: everything above the open block stays a memoised chunk (`MarkdownStream` keeps that split as the text grows).
|
|
82
76
|
*
|
|
83
77
|
* @param text - The markdown to split.
|
|
84
78
|
* @param opts - Split options. `streaming: true` uses finer chunks for a reply that is still growing.
|
|
85
79
|
*/
|
|
86
80
|
function splitMarkdown(text, opts = {}) {
|
|
87
81
|
const threshold = opts.streaming ? STREAMING_THRESHOLD : CHUNK_THRESHOLD;
|
|
88
|
-
const target = opts.streaming ?
|
|
82
|
+
const target = opts.streaming ? 0 : CHUNK_TARGET;
|
|
89
83
|
if (text.length < threshold) return [text];
|
|
90
84
|
const lines = text.split("\n");
|
|
85
|
+
const scanner = new BlockScanner(target);
|
|
91
86
|
const chunks = [];
|
|
92
87
|
let start = 0;
|
|
93
|
-
let size = 0;
|
|
94
|
-
let fence = null;
|
|
95
88
|
for (let i = 0; i < lines.length; i++) {
|
|
96
89
|
const line = lines[i];
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
chunks.push(lines.slice(start, i + 1).join("\n"));
|
|
102
|
-
start = i + 1;
|
|
103
|
-
size = 0;
|
|
90
|
+
if (scanner.pending && opensChunk(line, true)) {
|
|
91
|
+
chunks.push(lines.slice(start, i).join("\n"));
|
|
92
|
+
start = i;
|
|
93
|
+
scanner.startChunk();
|
|
104
94
|
}
|
|
95
|
+
scanner.feed(line, 0);
|
|
105
96
|
}
|
|
97
|
+
if (scanner.refs) return [text];
|
|
106
98
|
chunks.push(lines.slice(start).join("\n"));
|
|
107
99
|
return chunks;
|
|
108
100
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The line scanner both markdown splitters share (`splitMarkdown` and the
|
|
3
|
+
* streaming `MarkdownStream`): where a chunk may start, and the block state a
|
|
4
|
+
* line leaves behind. Internal to the chat area.
|
|
5
|
+
*
|
|
6
|
+
* A chunk starts at a line after a blank line outside every block that spans
|
|
7
|
+
* blanks: a fence (core's `parseFenceOpen` / `isFenceClose`), an HTML block that
|
|
8
|
+
* only ends on its end marker (CommonMark types 1 to 5: `<pre>`, `<!--`, …). The
|
|
9
|
+
* line must start at column 0 and must not be a list item: an indented line
|
|
10
|
+
* may continue a list item, and a list item after a blank may continue a loose
|
|
11
|
+
* list. Everything else a blank line ends, so each chunk parses on its own as
|
|
12
|
+
* it would inside the whole text.
|
|
13
|
+
*
|
|
14
|
+
* Link reference and footnote definitions are the exception: one later in the
|
|
15
|
+
* text changes how earlier blocks parse. A text that holds one (or a line that
|
|
16
|
+
* looks like one) parses whole.
|
|
17
|
+
*/
|
|
18
|
+
import { FenceOpen } from "zidane/chat/pure";
|
|
19
|
+
/**
|
|
20
|
+
* Whether a chunk can start at `line`, the line after a candidate blank line:
|
|
21
|
+
* it starts at column 0 and is not a list item. `undefined` while that depends
|
|
22
|
+
* on characters still to come (`-` may become `- item` or `-1`).
|
|
23
|
+
*
|
|
24
|
+
* @param line - The line, or what has arrived of it.
|
|
25
|
+
* @param complete - The line is whole (its newline arrived, or the text ended).
|
|
26
|
+
*/
|
|
27
|
+
export declare function opensChunk(line: string, complete: boolean): boolean | undefined;
|
|
28
|
+
/** Whether `line` may be a definition, read outside every block. */
|
|
29
|
+
export declare function isDefinitionLine(line: string): boolean;
|
|
30
|
+
/** The block state after each line, and whether the next line may start a chunk. */
|
|
31
|
+
export declare class BlockScanner {
|
|
32
|
+
private readonly target;
|
|
33
|
+
/** The fence open after the lines fed. */
|
|
34
|
+
fence: FenceOpen | null;
|
|
35
|
+
/** Where the open fence's line starts. */
|
|
36
|
+
fenceAt: number;
|
|
37
|
+
/** Where the open fence's line ends (its newline). */
|
|
38
|
+
fenceEnd: number;
|
|
39
|
+
/** The end marker of the open HTML block, or `null`. */
|
|
40
|
+
html: RegExp | null;
|
|
41
|
+
/** Characters since the chunk started. */
|
|
42
|
+
size: number;
|
|
43
|
+
/** The last line was blank, outside every block, past the target: the next line may start a chunk. */
|
|
44
|
+
pending: boolean;
|
|
45
|
+
/** A definition was seen. */
|
|
46
|
+
refs: boolean;
|
|
47
|
+
/** @param target - The size a chunk reaches before it may end. */
|
|
48
|
+
constructor(target: number);
|
|
49
|
+
/**
|
|
50
|
+
* Feeds one whole line.
|
|
51
|
+
*
|
|
52
|
+
* @param line - The line, without its newline.
|
|
53
|
+
* @param at - Where it starts in the text.
|
|
54
|
+
*/
|
|
55
|
+
feed(line: string, at: number): void;
|
|
56
|
+
/** A chunk starts at the next line. */
|
|
57
|
+
startChunk(): void;
|
|
58
|
+
}
|
|
59
|
+
/** Below this, a streaming reply parses whole. */
|
|
60
|
+
export declare const STREAMING_THRESHOLD = 1200;
|
|
61
|
+
/** While a reply streams, every block boundary is a chunk boundary. */
|
|
62
|
+
export declare const STREAMING_TARGET = 0;
|
|
63
|
+
/** The language a fence's info string names, as the parsed block's class does (`plaintext` for none). */
|
|
64
|
+
export declare function fenceLanguage(info: string): string;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { isFenceClose, parseFenceOpen } from "zidane/chat/pure";
|
|
2
|
+
// src/chat/headless/markdown-scan.ts
|
|
3
|
+
/** A line that may define a link reference or a footnote, after any container markers. */
|
|
4
|
+
const DEFINITION = /^(?:[ \t>]|[*+-][ \t]|\d{1,9}[.)][ \t])*\[(?:[^\]\\\n]|\\.){1,999}\]:/;
|
|
5
|
+
/** The start of an HTML block that runs past blank lines (CommonMark types 1 to 5). */
|
|
6
|
+
const HTML_START = /^ {0,3}(?:<(script|pre|style|textarea)(?=[\s>]|$)|<!--|<\?|<![a-z]|<!\[CDATA\[)/i;
|
|
7
|
+
const HTML_END_RAW = /<\/(?:script|pre|style|textarea)>/i;
|
|
8
|
+
const HTML_END_COMMENT = /-->/;
|
|
9
|
+
const HTML_END_PI = /\?>/;
|
|
10
|
+
const HTML_END_DECL = />/;
|
|
11
|
+
const HTML_END_CDATA = /\]\]>/;
|
|
12
|
+
/** The end marker of the HTML block `line` opens and does not close, or `null`. */
|
|
13
|
+
function htmlBlockOf(line) {
|
|
14
|
+
const start = HTML_START.exec(line);
|
|
15
|
+
if (!start) return null;
|
|
16
|
+
const opener = start[0].trimStart();
|
|
17
|
+
const end = start[1] ? HTML_END_RAW : opener.startsWith("<!--") ? HTML_END_COMMENT : opener.startsWith("<?") ? HTML_END_PI : opener.startsWith("<![") ? HTML_END_CDATA : HTML_END_DECL;
|
|
18
|
+
return end.test(line.slice(start[0].length)) ? null : end;
|
|
19
|
+
}
|
|
20
|
+
/** Whether `line` holds only spaces, tabs and a carriage return. */
|
|
21
|
+
function isBlank(line) {
|
|
22
|
+
for (let i = 0; i < line.length; i++) {
|
|
23
|
+
const c = line.charCodeAt(i);
|
|
24
|
+
if (c !== 32 && c !== 9 && c !== 13 && c !== 11 && c !== 12) return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
const isDigit = (c) => c !== void 0 && c >= "0" && c <= "9";
|
|
29
|
+
const isMarkerGap = (c) => c === " " || c === " " || c === "\r";
|
|
30
|
+
/**
|
|
31
|
+
* Whether a chunk can start at `line`, the line after a candidate blank line:
|
|
32
|
+
* it starts at column 0 and is not a list item. `undefined` while that depends
|
|
33
|
+
* on characters still to come (`-` may become `- item` or `-1`).
|
|
34
|
+
*
|
|
35
|
+
* @param line - The line, or what has arrived of it.
|
|
36
|
+
* @param complete - The line is whole (its newline arrived, or the text ended).
|
|
37
|
+
*/
|
|
38
|
+
function opensChunk(line, complete) {
|
|
39
|
+
const c = line[0];
|
|
40
|
+
if (c === void 0) return complete ? false : void 0;
|
|
41
|
+
if (c === " " || c === " " || c === "\r") return false;
|
|
42
|
+
if (c === "*" || c === "+" || c === "-") {
|
|
43
|
+
if (line.length > 1) return !isMarkerGap(line[1]);
|
|
44
|
+
return complete ? false : void 0;
|
|
45
|
+
}
|
|
46
|
+
if (!isDigit(c)) return true;
|
|
47
|
+
let i = 1;
|
|
48
|
+
while (i < line.length && isDigit(line[i])) i++;
|
|
49
|
+
if (i > 9) return true;
|
|
50
|
+
if (i === line.length) return complete ? true : void 0;
|
|
51
|
+
const after = line[i];
|
|
52
|
+
if (after !== "." && after !== ")") return true;
|
|
53
|
+
if (i + 1 < line.length) return !isMarkerGap(line[i + 1]);
|
|
54
|
+
return complete ? false : void 0;
|
|
55
|
+
}
|
|
56
|
+
/** Whether `line` may be a definition, read outside every block. */
|
|
57
|
+
function isDefinitionLine(line) {
|
|
58
|
+
return DEFINITION.test(line);
|
|
59
|
+
}
|
|
60
|
+
/** The block state after each line, and whether the next line may start a chunk. */
|
|
61
|
+
var BlockScanner = class {
|
|
62
|
+
target;
|
|
63
|
+
/** The fence open after the lines fed. */
|
|
64
|
+
fence = null;
|
|
65
|
+
/** Where the open fence's line starts. */
|
|
66
|
+
fenceAt = -1;
|
|
67
|
+
/** Where the open fence's line ends (its newline). */
|
|
68
|
+
fenceEnd = -1;
|
|
69
|
+
/** The end marker of the open HTML block, or `null`. */
|
|
70
|
+
html = null;
|
|
71
|
+
/** Characters since the chunk started. */
|
|
72
|
+
size = 0;
|
|
73
|
+
/** The last line was blank, outside every block, past the target: the next line may start a chunk. */
|
|
74
|
+
pending = false;
|
|
75
|
+
/** A definition was seen. */
|
|
76
|
+
refs = false;
|
|
77
|
+
/** @param target - The size a chunk reaches before it may end. */
|
|
78
|
+
constructor(target) {
|
|
79
|
+
this.target = target;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Feeds one whole line.
|
|
83
|
+
*
|
|
84
|
+
* @param line - The line, without its newline.
|
|
85
|
+
* @param at - Where it starts in the text.
|
|
86
|
+
*/
|
|
87
|
+
feed(line, at) {
|
|
88
|
+
this.size += line.length + 1;
|
|
89
|
+
if (this.fence) {
|
|
90
|
+
if (isFenceClose(line, this.fence.char, this.fence.length)) this.fence = null;
|
|
91
|
+
} else if (this.html) {
|
|
92
|
+
if (this.html.test(line)) this.html = null;
|
|
93
|
+
} else {
|
|
94
|
+
const open = parseFenceOpen(line);
|
|
95
|
+
if (open) {
|
|
96
|
+
this.fence = open;
|
|
97
|
+
this.fenceAt = at;
|
|
98
|
+
this.fenceEnd = at + line.length;
|
|
99
|
+
} else {
|
|
100
|
+
this.html = htmlBlockOf(line);
|
|
101
|
+
if (!this.html && !this.refs && isDefinitionLine(line)) this.refs = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
this.pending = !this.fence && !this.html && this.size >= this.target && isBlank(line);
|
|
105
|
+
}
|
|
106
|
+
/** A chunk starts at the next line. */
|
|
107
|
+
startChunk() {
|
|
108
|
+
this.size = 0;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
/** Below this, a streaming reply parses whole. */
|
|
112
|
+
const STREAMING_THRESHOLD = 1200;
|
|
113
|
+
/** While a reply streams, every block boundary is a chunk boundary. */
|
|
114
|
+
const STREAMING_TARGET = 0;
|
|
115
|
+
/** The language a fence's info string names, as the parsed block's class does (`plaintext` for none). */
|
|
116
|
+
function fenceLanguage(info) {
|
|
117
|
+
return /^(\w+)/.exec(info.trim().split(/\s/)[0] ?? "")?.[1] ?? "plaintext";
|
|
118
|
+
}
|
|
119
|
+
export { BlockScanner, STREAMING_TARGET, STREAMING_THRESHOLD, fenceLanguage, isDefinitionLine, opensChunk };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A streaming reply's chunks, kept up to date as text arrives instead of split
|
|
3
|
+
* again from the start on every frame.
|
|
4
|
+
*
|
|
5
|
+
* `splitMarkdown` reads the whole reply, and so did the partial-fence and
|
|
6
|
+
* partial-emphasis trims (their patterns anchor at the end, but scan the whole
|
|
7
|
+
* string to get there) and the open-fence read of the last chunk: O(L) per
|
|
8
|
+
* frame, O(L²) over a reply. A {@link MarkdownStream} keeps the scan's state
|
|
9
|
+
* (the open fence or HTML block, the closed chunks, the line not yet whole) and
|
|
10
|
+
* reads only the characters that arrived since the last frame, plus the line
|
|
11
|
+
* still arriving. Closed chunks keep their string from frame to frame, so a
|
|
12
|
+
* memoised render compares them by identity.
|
|
13
|
+
*
|
|
14
|
+
* The chunks it gives once the text is final are exactly `splitMarkdown(text,
|
|
15
|
+
* { streaming: true })`. Internal to the chat area.
|
|
16
|
+
*/
|
|
17
|
+
import { OpenFence } from "./markdown-chunks.js";
|
|
18
|
+
/** One frame of a reply. */
|
|
19
|
+
export interface MarkdownFrame {
|
|
20
|
+
/** The chunks that can no longer change. The same array until one more closes. */
|
|
21
|
+
closed: readonly string[];
|
|
22
|
+
/** The rest, held back as the trims hold it while streaming. May be empty. */
|
|
23
|
+
tail: string;
|
|
24
|
+
/** The fence the tail ends inside, while streaming (as `openFenceOf` reads it). */
|
|
25
|
+
fence: OpenFence | null;
|
|
26
|
+
}
|
|
27
|
+
/** What the stream read: deterministic counts for the tests and benches. */
|
|
28
|
+
export interface MarkdownStreamStats {
|
|
29
|
+
/** Characters read by the scan: new characters, each whole line once, and the line still arriving on each frame. */
|
|
30
|
+
scanned: number;
|
|
31
|
+
/** Frames asked for. */
|
|
32
|
+
frames: number;
|
|
33
|
+
/** Texts that did not extend the last one, so the scan started over. */
|
|
34
|
+
restarts: number;
|
|
35
|
+
}
|
|
36
|
+
/** One reply's chunks, read incrementally. Feed it the reply on each frame. */
|
|
37
|
+
export declare class MarkdownStream {
|
|
38
|
+
private text;
|
|
39
|
+
/** Where the line not yet whole starts. */
|
|
40
|
+
private lineStart;
|
|
41
|
+
/** Where the search for the next newline resumes. */
|
|
42
|
+
private searched;
|
|
43
|
+
private scanner;
|
|
44
|
+
private starts;
|
|
45
|
+
private chunks;
|
|
46
|
+
private view;
|
|
47
|
+
/** Whether a chunk starts at the line not yet whole is already decided. */
|
|
48
|
+
private decided;
|
|
49
|
+
readonly stats: MarkdownStreamStats;
|
|
50
|
+
/**
|
|
51
|
+
* The reply's chunks as of `text`.
|
|
52
|
+
*
|
|
53
|
+
* @param text - The whole reply so far. Usually the last one with more at its end; anything else starts the scan over.
|
|
54
|
+
* @param streaming - Still streaming: trim what is still arriving, and read the open fence.
|
|
55
|
+
*/
|
|
56
|
+
frame(text: string, streaming: boolean): MarkdownFrame;
|
|
57
|
+
/** The fence open at the end of the tail, `last` being its trimmed last line. */
|
|
58
|
+
private openFence;
|
|
59
|
+
private wholeLine;
|
|
60
|
+
/** A chunk starts at `at` (a line start): the one before closes, without the newline between them. */
|
|
61
|
+
private cut;
|
|
62
|
+
private closedView;
|
|
63
|
+
private restart;
|
|
64
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { BlockScanner, fenceLanguage, isDefinitionLine, opensChunk } from "./markdown-scan.js";
|
|
2
|
+
import { isFenceClose, parseFenceOpen } from "zidane/chat/pure";
|
|
3
|
+
// src/chat/headless/markdown-stream.ts
|
|
4
|
+
/** A last line of one or two backticks or tildes: a fence still arriving (`withoutPartialFence`). */
|
|
5
|
+
const PARTIAL_FENCE_LINE = /^ {0,3}(?:`{1,2}|~{1,2})$/;
|
|
6
|
+
/** A last line of emphasis markers with nothing after them (`withoutPartialEmphasis`). */
|
|
7
|
+
const PARTIAL_EMPHASIS_LINE = /^( {0,3}(?:[*+-]|\d{1,9}[.)]) +)?(?:\*{1,3}|_{1,3})$/;
|
|
8
|
+
const NONE = [];
|
|
9
|
+
/**
|
|
10
|
+
* A copy of `text` that holds nothing of the string it was cut from. A slice
|
|
11
|
+
* keeps its source alive, and the source here is the whole reply as of one
|
|
12
|
+
* frame: a closed chunk, held for the reply's life (and by the parse cache),
|
|
13
|
+
* would hold a frame's reply each. Slicing a concatenation flattens it into a
|
|
14
|
+
* string of its own first.
|
|
15
|
+
*/
|
|
16
|
+
function detach(text) {
|
|
17
|
+
return text.length < 13 ? text : `${text} `.slice(0, -1);
|
|
18
|
+
}
|
|
19
|
+
/** One reply's chunks, read incrementally. Feed it the reply on each frame. */
|
|
20
|
+
var MarkdownStream = class {
|
|
21
|
+
text = "";
|
|
22
|
+
/** Where the line not yet whole starts. */
|
|
23
|
+
lineStart = 0;
|
|
24
|
+
/** Where the search for the next newline resumes. */
|
|
25
|
+
searched = 0;
|
|
26
|
+
scanner = new BlockScanner(0);
|
|
27
|
+
starts = [0];
|
|
28
|
+
chunks = [];
|
|
29
|
+
view = NONE;
|
|
30
|
+
/** Whether a chunk starts at the line not yet whole is already decided. */
|
|
31
|
+
decided = false;
|
|
32
|
+
stats = {
|
|
33
|
+
scanned: 0,
|
|
34
|
+
frames: 0,
|
|
35
|
+
restarts: 0
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The reply's chunks as of `text`.
|
|
39
|
+
*
|
|
40
|
+
* @param text - The whole reply so far. Usually the last one with more at its end; anything else starts the scan over.
|
|
41
|
+
* @param streaming - Still streaming: trim what is still arriving, and read the open fence.
|
|
42
|
+
*/
|
|
43
|
+
frame(text, streaming) {
|
|
44
|
+
this.stats.frames++;
|
|
45
|
+
if (!text.startsWith(this.text)) this.restart();
|
|
46
|
+
this.text = text;
|
|
47
|
+
let from = this.searched;
|
|
48
|
+
for (let nl = text.indexOf("\n", from); nl !== -1; nl = text.indexOf("\n", from)) {
|
|
49
|
+
this.stats.scanned += nl + 1 - from;
|
|
50
|
+
this.wholeLine(text.slice(this.lineStart, nl));
|
|
51
|
+
this.lineStart = nl + 1;
|
|
52
|
+
from = nl + 1;
|
|
53
|
+
}
|
|
54
|
+
this.stats.scanned += text.length - from;
|
|
55
|
+
this.searched = text.length;
|
|
56
|
+
const partial = text.slice(this.lineStart);
|
|
57
|
+
this.stats.scanned += partial.length;
|
|
58
|
+
let cutAt = -1;
|
|
59
|
+
if (this.scanner.pending && !this.decided) {
|
|
60
|
+
const opens = opensChunk(partial, false);
|
|
61
|
+
if (opens !== void 0) {
|
|
62
|
+
this.decided = true;
|
|
63
|
+
if (opens) this.cut(this.lineStart);
|
|
64
|
+
} else if (!streaming && opensChunk(partial, true)) cutAt = this.lineStart;
|
|
65
|
+
}
|
|
66
|
+
const { fence, html } = this.scanner;
|
|
67
|
+
const whole = this.scanner.refs || !fence && !html && isDefinitionLine(partial) || text.length < 1200;
|
|
68
|
+
let closed = NONE;
|
|
69
|
+
let tailStart = 0;
|
|
70
|
+
if (!whole) {
|
|
71
|
+
closed = this.closedView();
|
|
72
|
+
tailStart = this.starts.at(-1);
|
|
73
|
+
if (cutAt >= 0) {
|
|
74
|
+
closed = [...closed, detach(text.slice(tailStart, cutAt - 1))];
|
|
75
|
+
tailStart = cutAt;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!streaming) return {
|
|
79
|
+
closed,
|
|
80
|
+
tail: text.slice(tailStart),
|
|
81
|
+
fence: null
|
|
82
|
+
};
|
|
83
|
+
let last = partial;
|
|
84
|
+
if (this.lineStart > 0 && PARTIAL_FENCE_LINE.test(last)) last = "";
|
|
85
|
+
else if (PARTIAL_EMPHASIS_LINE.test(last)) last = last.replace(PARTIAL_EMPHASIS_LINE, "$1");
|
|
86
|
+
const tail = last === partial ? text.slice(tailStart) : text.slice(tailStart, this.lineStart) + last;
|
|
87
|
+
return {
|
|
88
|
+
closed,
|
|
89
|
+
tail,
|
|
90
|
+
fence: this.openFence(last, tailStart)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** The fence open at the end of the tail, `last` being its trimmed last line. */
|
|
94
|
+
openFence(last, tailStart) {
|
|
95
|
+
const { text, lineStart } = this;
|
|
96
|
+
let open = this.scanner.fence;
|
|
97
|
+
let at = this.scanner.fenceAt;
|
|
98
|
+
let end = this.scanner.fenceEnd;
|
|
99
|
+
if (open) {
|
|
100
|
+
if (isFenceClose(last, open.char, open.length)) open = null;
|
|
101
|
+
} else if (!this.scanner.html) {
|
|
102
|
+
open = parseFenceOpen(last);
|
|
103
|
+
at = lineStart;
|
|
104
|
+
end = -1;
|
|
105
|
+
}
|
|
106
|
+
if (!open || open.indent !== 0) return null;
|
|
107
|
+
const opener = end < 0 ? last : text.slice(at, end);
|
|
108
|
+
const body = end < 0 ? "" : text.slice(end + 1, lineStart) + last;
|
|
109
|
+
return {
|
|
110
|
+
before: at > tailStart ? text.slice(tailStart, at - 1) : "",
|
|
111
|
+
language: fenceLanguage(opener.slice(open.length)),
|
|
112
|
+
code: body.endsWith("\n") ? body.slice(0, -1) : body
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
wholeLine(line) {
|
|
116
|
+
const at = this.lineStart;
|
|
117
|
+
if (this.scanner.pending && !this.decided && opensChunk(line, true)) this.cut(at);
|
|
118
|
+
this.decided = false;
|
|
119
|
+
this.scanner.feed(line, at);
|
|
120
|
+
this.stats.scanned += line.length;
|
|
121
|
+
}
|
|
122
|
+
/** A chunk starts at `at` (a line start): the one before closes, without the newline between them. */
|
|
123
|
+
cut(at) {
|
|
124
|
+
this.chunks.push(detach(this.text.slice(this.starts.at(-1), at - 1)));
|
|
125
|
+
this.starts.push(at);
|
|
126
|
+
this.scanner.startChunk();
|
|
127
|
+
}
|
|
128
|
+
closedView() {
|
|
129
|
+
if (this.view.length !== this.chunks.length) this.view = this.chunks.slice();
|
|
130
|
+
return this.view;
|
|
131
|
+
}
|
|
132
|
+
restart() {
|
|
133
|
+
this.stats.restarts++;
|
|
134
|
+
this.lineStart = 0;
|
|
135
|
+
this.searched = 0;
|
|
136
|
+
this.scanner = new BlockScanner(0);
|
|
137
|
+
this.starts = [0];
|
|
138
|
+
this.chunks = [];
|
|
139
|
+
this.view = NONE;
|
|
140
|
+
this.decided = false;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export { MarkdownStream };
|