@nocturnium/svelte-ide 1.0.0-rc.1

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.
Files changed (330) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +251 -0
  3. package/dist/components/agents/AgentActivityPanel.svelte +565 -0
  4. package/dist/components/agents/AgentActivityPanel.svelte.d.ts +24 -0
  5. package/dist/components/agents/AgentAvatar.svelte +417 -0
  6. package/dist/components/agents/AgentAvatar.svelte.d.ts +23 -0
  7. package/dist/components/agents/AgentCursor.svelte +224 -0
  8. package/dist/components/agents/AgentCursor.svelte.d.ts +35 -0
  9. package/dist/components/agents/AgentPresenceBar.svelte +261 -0
  10. package/dist/components/agents/AgentPresenceBar.svelte.d.ts +20 -0
  11. package/dist/components/agents/index.d.ts +4 -0
  12. package/dist/components/agents/index.js +5 -0
  13. package/dist/components/ai/AIConversationList.svelte +524 -0
  14. package/dist/components/ai/AIConversationList.svelte.d.ts +17 -0
  15. package/dist/components/ai/AIEditPreview.svelte +132 -0
  16. package/dist/components/ai/AIEditPreview.svelte.d.ts +8 -0
  17. package/dist/components/ai/AIInlineEdit.svelte +155 -0
  18. package/dist/components/ai/AIInlineEdit.svelte.d.ts +10 -0
  19. package/dist/components/ai/AIMessage.svelte +239 -0
  20. package/dist/components/ai/AIMessage.svelte.d.ts +13 -0
  21. package/dist/components/ai/AIMessageActions.svelte +176 -0
  22. package/dist/components/ai/AIMessageActions.svelte.d.ts +12 -0
  23. package/dist/components/ai/AIMessageContent.svelte +355 -0
  24. package/dist/components/ai/AIMessageContent.svelte.d.ts +7 -0
  25. package/dist/components/ai/AIPanel.svelte +561 -0
  26. package/dist/components/ai/AIPanel.svelte.d.ts +7 -0
  27. package/dist/components/ai/AISuggestionWidget.svelte +132 -0
  28. package/dist/components/ai/AISuggestionWidget.svelte.d.ts +10 -0
  29. package/dist/components/ai/AIToolCallDisplay.svelte +317 -0
  30. package/dist/components/ai/AIToolCallDisplay.svelte.d.ts +12 -0
  31. package/dist/components/ai/index.d.ts +9 -0
  32. package/dist/components/ai/index.js +10 -0
  33. package/dist/components/core/Avatar.svelte +110 -0
  34. package/dist/components/core/Avatar.svelte.d.ts +12 -0
  35. package/dist/components/core/Badge.svelte +98 -0
  36. package/dist/components/core/Badge.svelte.d.ts +11 -0
  37. package/dist/components/core/Button.svelte +175 -0
  38. package/dist/components/core/Button.svelte.d.ts +18 -0
  39. package/dist/components/core/ConnectionStatus.svelte +294 -0
  40. package/dist/components/core/ConnectionStatus.svelte.d.ts +20 -0
  41. package/dist/components/core/ContextMenu.svelte +176 -0
  42. package/dist/components/core/ContextMenu.svelte.d.ts +19 -0
  43. package/dist/components/core/ErrorBoundary.svelte +277 -0
  44. package/dist/components/core/ErrorBoundary.svelte.d.ts +23 -0
  45. package/dist/components/core/Icon.svelte +107 -0
  46. package/dist/components/core/Icon.svelte.d.ts +8 -0
  47. package/dist/components/core/Input.svelte +138 -0
  48. package/dist/components/core/Input.svelte.d.ts +20 -0
  49. package/dist/components/core/Kbd.svelte +34 -0
  50. package/dist/components/core/Kbd.svelte.d.ts +7 -0
  51. package/dist/components/core/ResizeHandle.svelte +200 -0
  52. package/dist/components/core/ResizeHandle.svelte.d.ts +23 -0
  53. package/dist/components/core/Spinner.svelte +35 -0
  54. package/dist/components/core/Spinner.svelte.d.ts +7 -0
  55. package/dist/components/core/Textarea.svelte +112 -0
  56. package/dist/components/core/Textarea.svelte.d.ts +18 -0
  57. package/dist/components/core/Tooltip.svelte +103 -0
  58. package/dist/components/core/Tooltip.svelte.d.ts +11 -0
  59. package/dist/components/core/index.d.ts +13 -0
  60. package/dist/components/core/index.js +14 -0
  61. package/dist/components/editor/AIFocusLayer.svelte +430 -0
  62. package/dist/components/editor/AIFocusLayer.svelte.d.ts +32 -0
  63. package/dist/components/editor/Breadcrumbs.svelte +435 -0
  64. package/dist/components/editor/Breadcrumbs.svelte.d.ts +33 -0
  65. package/dist/components/editor/BreakpointLayer.svelte +642 -0
  66. package/dist/components/editor/BreakpointLayer.svelte.d.ts +20 -0
  67. package/dist/components/editor/CognitiveLoadMeter.svelte +324 -0
  68. package/dist/components/editor/CognitiveLoadMeter.svelte.d.ts +18 -0
  69. package/dist/components/editor/CollaborativeEditor.svelte +218 -0
  70. package/dist/components/editor/CollaborativeEditor.svelte.d.ts +32 -0
  71. package/dist/components/editor/CommandPalette.svelte +434 -0
  72. package/dist/components/editor/CommandPalette.svelte.d.ts +11 -0
  73. package/dist/components/editor/ComplexityLayer.svelte +293 -0
  74. package/dist/components/editor/ComplexityLayer.svelte.d.ts +23 -0
  75. package/dist/components/editor/ConflictZoneLayer.svelte +441 -0
  76. package/dist/components/editor/ConflictZoneLayer.svelte.d.ts +25 -0
  77. package/dist/components/editor/ContextLens.svelte +262 -0
  78. package/dist/components/editor/ContextLens.svelte.d.ts +27 -0
  79. package/dist/components/editor/CustomEditor.svelte +1242 -0
  80. package/dist/components/editor/CustomEditor.svelte.d.ts +37 -0
  81. package/dist/components/editor/DebugConsole.svelte +646 -0
  82. package/dist/components/editor/DebugConsole.svelte.d.ts +41 -0
  83. package/dist/components/editor/EchoCursorLayer.svelte +363 -0
  84. package/dist/components/editor/EchoCursorLayer.svelte.d.ts +24 -0
  85. package/dist/components/editor/Editor.svelte +61 -0
  86. package/dist/components/editor/Editor.svelte.d.ts +22 -0
  87. package/dist/components/editor/EditorGutter.svelte +119 -0
  88. package/dist/components/editor/EditorGutter.svelte.d.ts +19 -0
  89. package/dist/components/editor/EditorLines.svelte +182 -0
  90. package/dist/components/editor/EditorLines.svelte.d.ts +43 -0
  91. package/dist/components/editor/EditorPane.svelte +134 -0
  92. package/dist/components/editor/EditorPane.svelte.d.ts +9 -0
  93. package/dist/components/editor/EditorSelections.svelte +186 -0
  94. package/dist/components/editor/EditorSelections.svelte.d.ts +25 -0
  95. package/dist/components/editor/EditorTabs.svelte +170 -0
  96. package/dist/components/editor/EditorTabs.svelte.d.ts +12 -0
  97. package/dist/components/editor/FileExplorer.svelte +811 -0
  98. package/dist/components/editor/FileExplorer.svelte.d.ts +67 -0
  99. package/dist/components/editor/FileIcon.svelte +110 -0
  100. package/dist/components/editor/FileIcon.svelte.d.ts +10 -0
  101. package/dist/components/editor/FindReplace.svelte +448 -0
  102. package/dist/components/editor/FindReplace.svelte.d.ts +40 -0
  103. package/dist/components/editor/GhostBracketLayer.svelte +391 -0
  104. package/dist/components/editor/GhostBracketLayer.svelte.d.ts +24 -0
  105. package/dist/components/editor/GitBlameLayer.svelte +436 -0
  106. package/dist/components/editor/GitBlameLayer.svelte.d.ts +18 -0
  107. package/dist/components/editor/InlineDiagnosticsLayer.svelte +540 -0
  108. package/dist/components/editor/InlineDiagnosticsLayer.svelte.d.ts +35 -0
  109. package/dist/components/editor/InlineDiffLayer.svelte +337 -0
  110. package/dist/components/editor/InlineDiffLayer.svelte.d.ts +31 -0
  111. package/dist/components/editor/MinimalEditor.svelte +75 -0
  112. package/dist/components/editor/MinimalEditor.svelte.d.ts +6 -0
  113. package/dist/components/editor/MinimalEditor2.svelte +84 -0
  114. package/dist/components/editor/MinimalEditor2.svelte.d.ts +6 -0
  115. package/dist/components/editor/Minimap.svelte +327 -0
  116. package/dist/components/editor/Minimap.svelte.d.ts +34 -0
  117. package/dist/components/editor/PluginPreviewSandbox.svelte +793 -0
  118. package/dist/components/editor/PluginPreviewSandbox.svelte.d.ts +49 -0
  119. package/dist/components/editor/ProblemsPanel.svelte +628 -0
  120. package/dist/components/editor/ProblemsPanel.svelte.d.ts +25 -0
  121. package/dist/components/editor/QuickActionsMenu.svelte +403 -0
  122. package/dist/components/editor/QuickActionsMenu.svelte.d.ts +18 -0
  123. package/dist/components/editor/SnippetPalette.svelte +530 -0
  124. package/dist/components/editor/SnippetPalette.svelte.d.ts +16 -0
  125. package/dist/components/editor/StructureMap.svelte +431 -0
  126. package/dist/components/editor/StructureMap.svelte.d.ts +37 -0
  127. package/dist/components/editor/SymbolOutline.svelte +722 -0
  128. package/dist/components/editor/SymbolOutline.svelte.d.ts +44 -0
  129. package/dist/components/editor/TimelineScrubber.svelte +470 -0
  130. package/dist/components/editor/TimelineScrubber.svelte.d.ts +40 -0
  131. package/dist/components/editor/TokenRenderer.svelte +69 -0
  132. package/dist/components/editor/TokenRenderer.svelte.d.ts +15 -0
  133. package/dist/components/editor/constants.d.ts +32 -0
  134. package/dist/components/editor/constants.js +36 -0
  135. package/dist/components/editor/core/ai-awareness.d.ts +176 -0
  136. package/dist/components/editor/core/ai-awareness.js +210 -0
  137. package/dist/components/editor/core/bracket-healer.d.ts +189 -0
  138. package/dist/components/editor/core/bracket-healer.js +406 -0
  139. package/dist/components/editor/core/breakpoints.d.ts +203 -0
  140. package/dist/components/editor/core/breakpoints.js +414 -0
  141. package/dist/components/editor/core/commands.d.ts +108 -0
  142. package/dist/components/editor/core/commands.js +246 -0
  143. package/dist/components/editor/core/complexity-analyzer.d.ts +123 -0
  144. package/dist/components/editor/core/complexity-analyzer.js +376 -0
  145. package/dist/components/editor/core/conflict-predictor.d.ts +135 -0
  146. package/dist/components/editor/core/conflict-predictor.js +316 -0
  147. package/dist/components/editor/core/crdt-binding.d.ts +118 -0
  148. package/dist/components/editor/core/crdt-binding.js +286 -0
  149. package/dist/components/editor/core/diagnostics.d.ts +210 -0
  150. package/dist/components/editor/core/diagnostics.js +335 -0
  151. package/dist/components/editor/core/echo-cursor.d.ts +201 -0
  152. package/dist/components/editor/core/echo-cursor.js +267 -0
  153. package/dist/components/editor/core/folding.d.ts +124 -0
  154. package/dist/components/editor/core/folding.js +672 -0
  155. package/dist/components/editor/core/ghost-pair.d.ts +122 -0
  156. package/dist/components/editor/core/ghost-pair.js +221 -0
  157. package/dist/components/editor/core/git-blame.d.ts +170 -0
  158. package/dist/components/editor/core/git-blame.js +324 -0
  159. package/dist/components/editor/core/index.d.ts +26 -0
  160. package/dist/components/editor/core/index.js +24 -0
  161. package/dist/components/editor/core/keybindings.d.ts +79 -0
  162. package/dist/components/editor/core/keybindings.js +357 -0
  163. package/dist/components/editor/core/multi-cursor.d.ts +196 -0
  164. package/dist/components/editor/core/multi-cursor.js +521 -0
  165. package/dist/components/editor/core/navigation.d.ts +107 -0
  166. package/dist/components/editor/core/navigation.js +408 -0
  167. package/dist/components/editor/core/quick-actions.d.ts +189 -0
  168. package/dist/components/editor/core/quick-actions.js +427 -0
  169. package/dist/components/editor/core/search.d.ts +88 -0
  170. package/dist/components/editor/core/search.js +192 -0
  171. package/dist/components/editor/core/semantic-analyzer.d.ts +77 -0
  172. package/dist/components/editor/core/semantic-analyzer.js +424 -0
  173. package/dist/components/editor/core/snippet-manager.d.ts +202 -0
  174. package/dist/components/editor/core/snippet-manager.js +565 -0
  175. package/dist/components/editor/core/state.d.ts +367 -0
  176. package/dist/components/editor/core/state.js +900 -0
  177. package/dist/components/editor/core/timeline.d.ts +204 -0
  178. package/dist/components/editor/core/timeline.js +349 -0
  179. package/dist/components/editor/editor-find.d.ts +56 -0
  180. package/dist/components/editor/editor-find.js +148 -0
  181. package/dist/components/editor/editor-input.d.ts +77 -0
  182. package/dist/components/editor/editor-input.js +445 -0
  183. package/dist/components/editor/editor-multicursor.d.ts +21 -0
  184. package/dist/components/editor/editor-multicursor.js +196 -0
  185. package/dist/components/editor/editor-scroll.d.ts +14 -0
  186. package/dist/components/editor/editor-scroll.js +34 -0
  187. package/dist/components/editor/index.d.ts +15 -0
  188. package/dist/components/editor/index.js +21 -0
  189. package/dist/components/editor/languages.d.ts +62 -0
  190. package/dist/components/editor/languages.js +285 -0
  191. package/dist/components/editor/theme.d.ts +88 -0
  192. package/dist/components/editor/theme.js +139 -0
  193. package/dist/components/editor/tokenizer/base.d.ts +40 -0
  194. package/dist/components/editor/tokenizer/base.js +203 -0
  195. package/dist/components/editor/tokenizer/index.d.ts +56 -0
  196. package/dist/components/editor/tokenizer/index.js +215 -0
  197. package/dist/components/editor/tokenizer/languages/css.d.ts +17 -0
  198. package/dist/components/editor/tokenizer/languages/css.js +194 -0
  199. package/dist/components/editor/tokenizer/languages/go.d.ts +17 -0
  200. package/dist/components/editor/tokenizer/languages/go.js +220 -0
  201. package/dist/components/editor/tokenizer/languages/html.d.ts +24 -0
  202. package/dist/components/editor/tokenizer/languages/html.js +145 -0
  203. package/dist/components/editor/tokenizer/languages/javascript.d.ts +56 -0
  204. package/dist/components/editor/tokenizer/languages/javascript.js +452 -0
  205. package/dist/components/editor/tokenizer/languages/json.d.ts +12 -0
  206. package/dist/components/editor/tokenizer/languages/json.js +91 -0
  207. package/dist/components/editor/tokenizer/languages/markdown.d.ts +16 -0
  208. package/dist/components/editor/tokenizer/languages/markdown.js +156 -0
  209. package/dist/components/editor/tokenizer/languages/python.d.ts +20 -0
  210. package/dist/components/editor/tokenizer/languages/python.js +227 -0
  211. package/dist/components/editor/tokenizer/languages/svelte.d.ts +40 -0
  212. package/dist/components/editor/tokenizer/languages/svelte.js +326 -0
  213. package/dist/components/editor/tokenizer/types.d.ts +86 -0
  214. package/dist/components/editor/tokenizer/types.js +4 -0
  215. package/dist/components/layout/IDELayout.svelte +274 -0
  216. package/dist/components/layout/IDELayout.svelte.d.ts +29 -0
  217. package/dist/components/layout/StatusBar.svelte +511 -0
  218. package/dist/components/layout/StatusBar.svelte.d.ts +47 -0
  219. package/dist/components/layout/index.d.ts +2 -0
  220. package/dist/components/layout/index.js +3 -0
  221. package/dist/components/lsp/AutocompleteWidget.svelte +364 -0
  222. package/dist/components/lsp/AutocompleteWidget.svelte.d.ts +33 -0
  223. package/dist/components/lsp/DiagnosticMarker.svelte +166 -0
  224. package/dist/components/lsp/DiagnosticMarker.svelte.d.ts +19 -0
  225. package/dist/components/lsp/DiagnosticsPanel.svelte +388 -0
  226. package/dist/components/lsp/DiagnosticsPanel.svelte.d.ts +21 -0
  227. package/dist/components/lsp/HoverTooltip.svelte +274 -0
  228. package/dist/components/lsp/HoverTooltip.svelte.d.ts +24 -0
  229. package/dist/components/lsp/LSPEditor.svelte +486 -0
  230. package/dist/components/lsp/LSPEditor.svelte.d.ts +39 -0
  231. package/dist/components/lsp/SignatureHelpWidget.svelte +216 -0
  232. package/dist/components/lsp/SignatureHelpWidget.svelte.d.ts +22 -0
  233. package/dist/components/lsp/index.d.ts +6 -0
  234. package/dist/components/lsp/index.js +7 -0
  235. package/dist/components/plugins/PluginCard.svelte +153 -0
  236. package/dist/components/plugins/PluginCard.svelte.d.ts +19 -0
  237. package/dist/components/plugins/PluginPanel.svelte +280 -0
  238. package/dist/components/plugins/PluginPanel.svelte.d.ts +8 -0
  239. package/dist/components/plugins/PluginProposalForm.svelte +250 -0
  240. package/dist/components/plugins/PluginProposalForm.svelte.d.ts +6 -0
  241. package/dist/components/plugins/PluginStatusBadge.svelte +14 -0
  242. package/dist/components/plugins/PluginStatusBadge.svelte.d.ts +8 -0
  243. package/dist/components/plugins/index.d.ts +4 -0
  244. package/dist/components/plugins/index.js +5 -0
  245. package/dist/components/vfs/LockConflictDialog.svelte +705 -0
  246. package/dist/components/vfs/LockConflictDialog.svelte.d.ts +21 -0
  247. package/dist/components/vfs/LockIndicator.svelte +194 -0
  248. package/dist/components/vfs/LockIndicator.svelte.d.ts +29 -0
  249. package/dist/components/vfs/LockOverlay.svelte +344 -0
  250. package/dist/components/vfs/LockOverlay.svelte.d.ts +17 -0
  251. package/dist/components/vfs/VersionConflictDialog.svelte +549 -0
  252. package/dist/components/vfs/VersionConflictDialog.svelte.d.ts +24 -0
  253. package/dist/components/vfs/index.d.ts +4 -0
  254. package/dist/components/vfs/index.js +5 -0
  255. package/dist/crdt/awareness.d.ts +42 -0
  256. package/dist/crdt/awareness.js +109 -0
  257. package/dist/crdt/document.d.ts +101 -0
  258. package/dist/crdt/document.js +187 -0
  259. package/dist/crdt/index.d.ts +9 -0
  260. package/dist/crdt/index.js +8 -0
  261. package/dist/crdt/provider.d.ts +85 -0
  262. package/dist/crdt/provider.js +150 -0
  263. package/dist/crdt/types.d.ts +61 -0
  264. package/dist/crdt/types.js +4 -0
  265. package/dist/crdt/undo.d.ts +34 -0
  266. package/dist/crdt/undo.js +70 -0
  267. package/dist/index.d.ts +277 -0
  268. package/dist/index.js +280 -0
  269. package/dist/plugins/index.d.ts +103 -0
  270. package/dist/plugins/index.js +153 -0
  271. package/dist/services/error-handling.d.ts +95 -0
  272. package/dist/services/error-handling.js +413 -0
  273. package/dist/services/ide-integration.d.ts +83 -0
  274. package/dist/services/ide-integration.js +367 -0
  275. package/dist/services/lsp-client.d.ts +69 -0
  276. package/dist/services/lsp-client.js +667 -0
  277. package/dist/services/mock-ai.d.ts +37 -0
  278. package/dist/services/mock-ai.js +318 -0
  279. package/dist/services/optimistic.d.ts +141 -0
  280. package/dist/services/optimistic.js +367 -0
  281. package/dist/services/vfs-client.d.ts +81 -0
  282. package/dist/services/vfs-client.js +348 -0
  283. package/dist/stores/agents.svelte.d.ts +85 -0
  284. package/dist/stores/agents.svelte.js +459 -0
  285. package/dist/stores/ai-persistence.svelte.d.ts +76 -0
  286. package/dist/stores/ai-persistence.svelte.js +334 -0
  287. package/dist/stores/ai.svelte.d.ts +140 -0
  288. package/dist/stores/ai.svelte.js +383 -0
  289. package/dist/stores/collaboration.svelte.d.ts +164 -0
  290. package/dist/stores/collaboration.svelte.js +334 -0
  291. package/dist/stores/editor.svelte.d.ts +131 -0
  292. package/dist/stores/editor.svelte.js +250 -0
  293. package/dist/stores/index.d.ts +10 -0
  294. package/dist/stores/index.js +29 -0
  295. package/dist/stores/layout.svelte.d.ts +171 -0
  296. package/dist/stores/layout.svelte.js +351 -0
  297. package/dist/stores/plugin.svelte.d.ts +121 -0
  298. package/dist/stores/plugin.svelte.js +410 -0
  299. package/dist/stores/vfs.svelte.d.ts +123 -0
  300. package/dist/stores/vfs.svelte.js +680 -0
  301. package/dist/styles/theme.css +623 -0
  302. package/dist/types/agents.d.ts +127 -0
  303. package/dist/types/agents.js +5 -0
  304. package/dist/types/ai.d.ts +137 -0
  305. package/dist/types/ai.js +4 -0
  306. package/dist/types/crdt.d.ts +222 -0
  307. package/dist/types/crdt.js +5 -0
  308. package/dist/types/editor.d.ts +52 -0
  309. package/dist/types/editor.js +18 -0
  310. package/dist/types/events.d.ts +133 -0
  311. package/dist/types/events.js +4 -0
  312. package/dist/types/filesystem.d.ts +77 -0
  313. package/dist/types/filesystem.js +4 -0
  314. package/dist/types/index.d.ts +9 -0
  315. package/dist/types/index.js +12 -0
  316. package/dist/types/lsp.d.ts +691 -0
  317. package/dist/types/lsp.js +108 -0
  318. package/dist/types/plugin.d.ts +239 -0
  319. package/dist/types/plugin.js +5 -0
  320. package/dist/types/vfs.d.ts +191 -0
  321. package/dist/types/vfs.js +18 -0
  322. package/dist/utils/format.d.ts +55 -0
  323. package/dist/utils/format.js +152 -0
  324. package/dist/utils/index.d.ts +3 -0
  325. package/dist/utils/index.js +4 -0
  326. package/dist/utils/keybindings.d.ts +33 -0
  327. package/dist/utils/keybindings.js +171 -0
  328. package/dist/utils/language.d.ts +27 -0
  329. package/dist/utils/language.js +222 -0
  330. package/package.json +178 -0
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Timeline Manager
3
+ *
4
+ * Manages document history snapshots for Time Machine Scrubbing.
5
+ * Captures snapshots at regular intervals and on significant events,
6
+ * allowing users to scrub through document history.
7
+ */
8
+ /**
9
+ * Snapshot metadata
10
+ */
11
+ export interface SnapshotMetadata {
12
+ /** Author ID */
13
+ author: string;
14
+ /** Author display color */
15
+ authorColor: string;
16
+ /** Whether this was an AI change */
17
+ isAI: boolean;
18
+ /** Description of the change */
19
+ description?: string;
20
+ /** Git commit hash if applicable */
21
+ commitHash?: string;
22
+ /** Type of change */
23
+ changeType: 'edit' | 'ai-suggestion' | 'commit' | 'checkpoint' | 'save';
24
+ }
25
+ /**
26
+ * A snapshot of document state at a point in time
27
+ */
28
+ export interface TimelineSnapshot {
29
+ /** Unique snapshot ID */
30
+ id: string;
31
+ /** Timestamp when captured */
32
+ timestamp: number;
33
+ /** Document content */
34
+ content: string;
35
+ /** Snapshot metadata */
36
+ metadata: SnapshotMetadata;
37
+ /** Line count at this snapshot */
38
+ lineCount: number;
39
+ /** Diff from previous snapshot */
40
+ diffFromPrevious?: {
41
+ addedLines: number;
42
+ removedLines: number;
43
+ changedRegions: Array<{
44
+ start: number;
45
+ end: number;
46
+ }>;
47
+ };
48
+ }
49
+ /**
50
+ * Timeline state
51
+ */
52
+ export interface TimelineState {
53
+ /** All snapshots */
54
+ snapshots: TimelineSnapshot[];
55
+ /** Current playback position (0-1, where 1 is live) */
56
+ position: number;
57
+ /** Whether in playback mode */
58
+ isPlayback: boolean;
59
+ /** Playback speed multiplier */
60
+ playbackSpeed: number;
61
+ /** Whether auto-playing */
62
+ isPlaying: boolean;
63
+ }
64
+ /**
65
+ * Timeline event types
66
+ */
67
+ export type TimelineEvent = {
68
+ type: 'snapshot-added';
69
+ snapshot: TimelineSnapshot;
70
+ } | {
71
+ type: 'position-changed';
72
+ position: number;
73
+ } | {
74
+ type: 'playback-started';
75
+ } | {
76
+ type: 'playback-stopped';
77
+ };
78
+ /**
79
+ * Timeline configuration
80
+ */
81
+ export interface TimelineConfig {
82
+ /** Interval between auto-snapshots in ms (default: 30000) */
83
+ snapshotInterval: number;
84
+ /** Maximum number of snapshots to keep (default: 500) */
85
+ maxSnapshots: number;
86
+ /** Minimum lines changed to trigger snapshot (default: 5) */
87
+ minLinesForSnapshot: number;
88
+ /** Default author info */
89
+ defaultAuthor: {
90
+ id: string;
91
+ name: string;
92
+ color: string;
93
+ };
94
+ }
95
+ /**
96
+ * Timeline Manager class
97
+ */
98
+ export declare class TimelineManager {
99
+ private snapshots;
100
+ private listeners;
101
+ private config;
102
+ private snapshotTimer;
103
+ private lastContent;
104
+ private lastSnapshotTime;
105
+ constructor(config?: Partial<TimelineConfig>);
106
+ /**
107
+ * Start auto-snapshot timer
108
+ */
109
+ start(initialContent: string): void;
110
+ /**
111
+ * Stop auto-snapshot timer
112
+ */
113
+ stop(): void;
114
+ /**
115
+ * Record content change (for tracking changes between snapshots)
116
+ */
117
+ recordChange(content: string): void;
118
+ /**
119
+ * Capture a snapshot
120
+ */
121
+ captureSnapshot(content: string, metadata: SnapshotMetadata): TimelineSnapshot;
122
+ /**
123
+ * Capture snapshot on significant edit
124
+ */
125
+ captureOnEdit(content: string, author?: Partial<SnapshotMetadata>): void;
126
+ /**
127
+ * Capture snapshot for AI suggestion
128
+ */
129
+ captureAISuggestion(content: string, description: string): void;
130
+ /**
131
+ * Capture snapshot on save
132
+ */
133
+ captureOnSave(content: string): void;
134
+ /**
135
+ * Get all snapshots
136
+ */
137
+ getSnapshots(): readonly TimelineSnapshot[];
138
+ /**
139
+ * Get snapshot at normalized position (0-1)
140
+ */
141
+ getSnapshotAtPosition(position: number): TimelineSnapshot | null;
142
+ /**
143
+ * Get content at normalized position
144
+ */
145
+ getContentAtPosition(position: number): string | null;
146
+ /**
147
+ * Get snapshot by ID
148
+ */
149
+ getSnapshotById(id: string): TimelineSnapshot | undefined;
150
+ /**
151
+ * Get timeline duration in ms
152
+ */
153
+ getDuration(): number;
154
+ /**
155
+ * Get position for a timestamp
156
+ */
157
+ getPositionForTimestamp(timestamp: number): number;
158
+ /**
159
+ * Get markers for timeline UI
160
+ */
161
+ getMarkers(): Array<{
162
+ position: number;
163
+ color: string;
164
+ type: SnapshotMetadata['changeType'];
165
+ label: string;
166
+ timestamp: number;
167
+ }>;
168
+ /**
169
+ * Subscribe to timeline events
170
+ */
171
+ subscribe(listener: (event: TimelineEvent) => void): () => void;
172
+ /**
173
+ * Clear all snapshots
174
+ */
175
+ clear(): void;
176
+ /**
177
+ * Calculate diff between two content strings
178
+ */
179
+ private calculateDiff;
180
+ /**
181
+ * Prune old snapshots to stay within limit
182
+ */
183
+ private pruneSnapshots;
184
+ /**
185
+ * Emit event to listeners
186
+ */
187
+ private emit;
188
+ }
189
+ /**
190
+ * Create a timeline manager instance
191
+ */
192
+ export declare function createTimelineManager(config?: Partial<TimelineConfig>): TimelineManager;
193
+ /**
194
+ * Get the global timeline manager
195
+ */
196
+ export declare function getTimelineManager(): TimelineManager;
197
+ /**
198
+ * Format timestamp for display
199
+ */
200
+ export declare function formatTimestamp(timestamp: number): string;
201
+ /**
202
+ * Format duration for display
203
+ */
204
+ export declare function formatDuration(ms: number): string;
@@ -0,0 +1,349 @@
1
+ /**
2
+ * Timeline Manager
3
+ *
4
+ * Manages document history snapshots for Time Machine Scrubbing.
5
+ * Captures snapshots at regular intervals and on significant events,
6
+ * allowing users to scrub through document history.
7
+ */
8
+ const DEFAULT_CONFIG = {
9
+ snapshotInterval: 30000,
10
+ maxSnapshots: 500,
11
+ minLinesForSnapshot: 5,
12
+ defaultAuthor: {
13
+ id: 'local',
14
+ name: 'You',
15
+ color: '#4a9eff'
16
+ }
17
+ };
18
+ /**
19
+ * Timeline Manager class
20
+ */
21
+ export class TimelineManager {
22
+ snapshots = [];
23
+ listeners = new Set();
24
+ config;
25
+ snapshotTimer = null;
26
+ lastContent = '';
27
+ lastSnapshotTime = 0;
28
+ constructor(config = {}) {
29
+ this.config = { ...DEFAULT_CONFIG, ...config };
30
+ }
31
+ /**
32
+ * Start auto-snapshot timer
33
+ */
34
+ start(initialContent) {
35
+ this.lastContent = initialContent;
36
+ this.lastSnapshotTime = Date.now();
37
+ // Capture initial snapshot
38
+ this.captureSnapshot(initialContent, {
39
+ author: this.config.defaultAuthor.id,
40
+ authorColor: this.config.defaultAuthor.color,
41
+ isAI: false,
42
+ description: 'Initial state',
43
+ changeType: 'checkpoint'
44
+ });
45
+ // Start auto-snapshot timer
46
+ this.snapshotTimer = setInterval(() => {
47
+ if (this.lastContent) {
48
+ this.captureSnapshot(this.lastContent, {
49
+ author: this.config.defaultAuthor.id,
50
+ authorColor: this.config.defaultAuthor.color,
51
+ isAI: false,
52
+ description: 'Auto-checkpoint',
53
+ changeType: 'checkpoint'
54
+ });
55
+ }
56
+ }, this.config.snapshotInterval);
57
+ }
58
+ /**
59
+ * Stop auto-snapshot timer
60
+ */
61
+ stop() {
62
+ if (this.snapshotTimer) {
63
+ clearInterval(this.snapshotTimer);
64
+ this.snapshotTimer = null;
65
+ }
66
+ }
67
+ /**
68
+ * Record content change (for tracking changes between snapshots)
69
+ */
70
+ recordChange(content) {
71
+ this.lastContent = content;
72
+ }
73
+ /**
74
+ * Capture a snapshot
75
+ */
76
+ captureSnapshot(content, metadata) {
77
+ const now = Date.now();
78
+ const lineCount = content.split('\n').length;
79
+ // Calculate diff from previous
80
+ let diffFromPrevious;
81
+ if (this.snapshots.length > 0) {
82
+ const prevSnapshot = this.snapshots[this.snapshots.length - 1];
83
+ diffFromPrevious = this.calculateDiff(prevSnapshot.content, content);
84
+ }
85
+ const snapshot = {
86
+ id: `snapshot-${now}-${Math.random().toString(36).substr(2, 9)}`,
87
+ timestamp: now,
88
+ content,
89
+ metadata,
90
+ lineCount,
91
+ diffFromPrevious
92
+ };
93
+ this.snapshots.push(snapshot);
94
+ this.lastSnapshotTime = now;
95
+ this.lastContent = content;
96
+ // Prune old snapshots if needed
97
+ this.pruneSnapshots();
98
+ // Notify listeners
99
+ this.emit({ type: 'snapshot-added', snapshot });
100
+ return snapshot;
101
+ }
102
+ /**
103
+ * Capture snapshot on significant edit
104
+ */
105
+ captureOnEdit(content, author) {
106
+ const lineCount = content.split('\n').length;
107
+ const lastLineCount = this.snapshots.length > 0
108
+ ? this.snapshots[this.snapshots.length - 1].lineCount
109
+ : 0;
110
+ const linesDiff = Math.abs(lineCount - lastLineCount);
111
+ const timeSinceLastSnapshot = Date.now() - this.lastSnapshotTime;
112
+ // Capture if significant change or enough time passed
113
+ if (linesDiff >= this.config.minLinesForSnapshot || timeSinceLastSnapshot > 10000) {
114
+ this.captureSnapshot(content, {
115
+ author: author?.author ?? this.config.defaultAuthor.id,
116
+ authorColor: author?.authorColor ?? this.config.defaultAuthor.color,
117
+ isAI: author?.isAI ?? false,
118
+ description: author?.description ?? 'Edit',
119
+ changeType: author?.changeType ?? 'edit'
120
+ });
121
+ }
122
+ }
123
+ /**
124
+ * Capture snapshot for AI suggestion
125
+ */
126
+ captureAISuggestion(content, description) {
127
+ this.captureSnapshot(content, {
128
+ author: 'ai-assistant',
129
+ authorColor: '#a855f7',
130
+ isAI: true,
131
+ description,
132
+ changeType: 'ai-suggestion'
133
+ });
134
+ }
135
+ /**
136
+ * Capture snapshot on save
137
+ */
138
+ captureOnSave(content) {
139
+ this.captureSnapshot(content, {
140
+ author: this.config.defaultAuthor.id,
141
+ authorColor: this.config.defaultAuthor.color,
142
+ isAI: false,
143
+ description: 'Saved',
144
+ changeType: 'save'
145
+ });
146
+ }
147
+ /**
148
+ * Get all snapshots
149
+ */
150
+ getSnapshots() {
151
+ return this.snapshots;
152
+ }
153
+ /**
154
+ * Get snapshot at normalized position (0-1)
155
+ */
156
+ getSnapshotAtPosition(position) {
157
+ if (this.snapshots.length === 0)
158
+ return null;
159
+ if (position >= 1)
160
+ return this.snapshots[this.snapshots.length - 1];
161
+ if (position <= 0)
162
+ return this.snapshots[0];
163
+ const index = Math.floor(position * (this.snapshots.length - 1));
164
+ return this.snapshots[index];
165
+ }
166
+ /**
167
+ * Get content at normalized position
168
+ */
169
+ getContentAtPosition(position) {
170
+ const snapshot = this.getSnapshotAtPosition(position);
171
+ return snapshot?.content ?? null;
172
+ }
173
+ /**
174
+ * Get snapshot by ID
175
+ */
176
+ getSnapshotById(id) {
177
+ return this.snapshots.find((s) => s.id === id);
178
+ }
179
+ /**
180
+ * Get timeline duration in ms
181
+ */
182
+ getDuration() {
183
+ if (this.snapshots.length < 2)
184
+ return 0;
185
+ return this.snapshots[this.snapshots.length - 1].timestamp - this.snapshots[0].timestamp;
186
+ }
187
+ /**
188
+ * Get position for a timestamp
189
+ */
190
+ getPositionForTimestamp(timestamp) {
191
+ if (this.snapshots.length < 2)
192
+ return 1;
193
+ const start = this.snapshots[0].timestamp;
194
+ const end = this.snapshots[this.snapshots.length - 1].timestamp;
195
+ const duration = end - start;
196
+ if (duration === 0)
197
+ return 1;
198
+ return Math.max(0, Math.min(1, (timestamp - start) / duration));
199
+ }
200
+ /**
201
+ * Get markers for timeline UI
202
+ */
203
+ getMarkers() {
204
+ if (this.snapshots.length === 0)
205
+ return [];
206
+ const start = this.snapshots[0].timestamp;
207
+ const duration = this.getDuration() || 1;
208
+ return this.snapshots.map((snapshot) => ({
209
+ position: (snapshot.timestamp - start) / duration,
210
+ color: snapshot.metadata.authorColor,
211
+ type: snapshot.metadata.changeType,
212
+ label: snapshot.metadata.description || snapshot.metadata.changeType,
213
+ timestamp: snapshot.timestamp
214
+ }));
215
+ }
216
+ /**
217
+ * Subscribe to timeline events
218
+ */
219
+ subscribe(listener) {
220
+ this.listeners.add(listener);
221
+ return () => this.listeners.delete(listener);
222
+ }
223
+ /**
224
+ * Clear all snapshots
225
+ */
226
+ clear() {
227
+ this.snapshots = [];
228
+ this.lastContent = '';
229
+ this.lastSnapshotTime = 0;
230
+ }
231
+ /**
232
+ * Calculate diff between two content strings
233
+ */
234
+ calculateDiff(oldContent, newContent) {
235
+ const oldLines = oldContent.split('\n');
236
+ const newLines = newContent.split('\n');
237
+ let addedLines = 0;
238
+ let removedLines = 0;
239
+ const changedRegions = [];
240
+ // Simple line-by-line comparison
241
+ const maxLen = Math.max(oldLines.length, newLines.length);
242
+ let regionStart = -1;
243
+ for (let i = 0; i < maxLen; i++) {
244
+ const oldLine = oldLines[i] ?? '';
245
+ const newLine = newLines[i] ?? '';
246
+ if (oldLine !== newLine) {
247
+ if (regionStart === -1)
248
+ regionStart = i;
249
+ if (i >= oldLines.length)
250
+ addedLines++;
251
+ else if (i >= newLines.length)
252
+ removedLines++;
253
+ else {
254
+ // Changed line counts as both add and remove
255
+ addedLines++;
256
+ removedLines++;
257
+ }
258
+ }
259
+ else if (regionStart !== -1) {
260
+ changedRegions.push({ start: regionStart, end: i - 1 });
261
+ regionStart = -1;
262
+ }
263
+ }
264
+ if (regionStart !== -1) {
265
+ changedRegions.push({ start: regionStart, end: maxLen - 1 });
266
+ }
267
+ return { addedLines, removedLines, changedRegions };
268
+ }
269
+ /**
270
+ * Prune old snapshots to stay within limit
271
+ */
272
+ pruneSnapshots() {
273
+ if (this.snapshots.length <= this.config.maxSnapshots)
274
+ return;
275
+ // Keep first, last, and evenly distributed middle snapshots
276
+ const toRemove = this.snapshots.length - this.config.maxSnapshots;
277
+ // Remove oldest non-significant snapshots (keep checkpoints, saves, commits)
278
+ const significantTypes = ['commit', 'save', 'checkpoint'];
279
+ for (let i = 1; i < this.snapshots.length - 1 && toRemove > 0; i++) {
280
+ if (!significantTypes.includes(this.snapshots[i].metadata.changeType)) {
281
+ this.snapshots.splice(i, 1);
282
+ i--;
283
+ }
284
+ }
285
+ }
286
+ /**
287
+ * Emit event to listeners
288
+ */
289
+ emit(event) {
290
+ for (const listener of this.listeners) {
291
+ try {
292
+ listener(event);
293
+ }
294
+ catch (e) {
295
+ console.error('[TimelineManager] Listener error:', e);
296
+ }
297
+ }
298
+ }
299
+ }
300
+ /**
301
+ * Create a timeline manager instance
302
+ */
303
+ export function createTimelineManager(config) {
304
+ return new TimelineManager(config);
305
+ }
306
+ // Singleton instance
307
+ let globalTimelineManager = null;
308
+ /**
309
+ * Get the global timeline manager
310
+ */
311
+ export function getTimelineManager() {
312
+ if (!globalTimelineManager) {
313
+ globalTimelineManager = createTimelineManager();
314
+ }
315
+ return globalTimelineManager;
316
+ }
317
+ /**
318
+ * Format timestamp for display
319
+ */
320
+ export function formatTimestamp(timestamp) {
321
+ const date = new Date(timestamp);
322
+ const now = new Date();
323
+ // Same day - show time only
324
+ if (date.toDateString() === now.toDateString()) {
325
+ return date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });
326
+ }
327
+ // Different day - show date and time
328
+ return date.toLocaleString(undefined, {
329
+ month: 'short',
330
+ day: 'numeric',
331
+ hour: '2-digit',
332
+ minute: '2-digit'
333
+ });
334
+ }
335
+ /**
336
+ * Format duration for display
337
+ */
338
+ export function formatDuration(ms) {
339
+ const seconds = Math.floor(ms / 1000);
340
+ const minutes = Math.floor(seconds / 60);
341
+ const hours = Math.floor(minutes / 60);
342
+ if (hours > 0) {
343
+ return `${hours}h ${minutes % 60}m`;
344
+ }
345
+ if (minutes > 0) {
346
+ return `${minutes}m ${seconds % 60}s`;
347
+ }
348
+ return `${seconds}s`;
349
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Editor find/replace logic extracted from CustomEditor.svelte
3
+ *
4
+ * Factory function that creates all find/replace state and operations,
5
+ * accepting callbacks for things it cannot own (editor state access, DOM operations).
6
+ */
7
+ import { type SearchMatch, type Position, type Selection } from './core';
8
+ export interface EditorFindDeps {
9
+ getLines: () => readonly {
10
+ text: string;
11
+ }[];
12
+ getLineCount: () => number;
13
+ getSelection: () => Selection;
14
+ setSelection: (anchor: Position, head: Position) => void;
15
+ setCursor: (pos: Position) => void;
16
+ setContent: (content: string) => void;
17
+ scrollCursorIntoView: () => void;
18
+ focusEditor: () => void;
19
+ isReadonly: () => boolean;
20
+ }
21
+ export interface MatchRect {
22
+ top: number;
23
+ left: number;
24
+ width: number;
25
+ height: number;
26
+ isCurrent: boolean;
27
+ }
28
+ export interface ViewportInfo {
29
+ scrollTop: number;
30
+ viewportHeight: number;
31
+ }
32
+ export interface MeasurementInfo {
33
+ lineHeight: number;
34
+ charWidth: number;
35
+ gutterWidth: number;
36
+ contentPadding: number;
37
+ }
38
+ export declare function createEditorFind(deps: EditorFindDeps): {
39
+ readonly query: string;
40
+ readonly replaceText: string;
41
+ readonly caseSensitive: boolean;
42
+ readonly useRegex: boolean;
43
+ readonly matches: SearchMatch[];
44
+ readonly currentIndex: number;
45
+ setQuery: (q: string) => void;
46
+ setReplaceText: (text: string) => void;
47
+ setCaseSensitive: (value: boolean) => void;
48
+ setUseRegex: (value: boolean) => void;
49
+ updateMatches: () => void;
50
+ findNext: () => void;
51
+ findPrev: () => void;
52
+ replace: () => void;
53
+ replaceAll: () => void;
54
+ computeMatchRects: (viewport: ViewportInfo, measurements: MeasurementInfo) => MatchRect[];
55
+ };
56
+ export type EditorFind = ReturnType<typeof createEditorFind>;