@peaske7/readit 0.1.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +0 -3
  2. package/biome.json +1 -1
  3. package/bun.lock +43 -185
  4. package/docs/perf-baseline.md +75 -0
  5. package/docs/superpowers/plans/2026-03-26-surgical-pruning.md +1176 -0
  6. package/e2e/perf/add-comment.spec.ts +118 -0
  7. package/e2e/perf/fixtures/generate.ts +331 -0
  8. package/e2e/perf/initial-load.spec.ts +49 -0
  9. package/e2e/perf/perf.setup.ts +23 -0
  10. package/e2e/perf/perf.teardown.ts +9 -0
  11. package/e2e/perf/scroll.spec.ts +39 -0
  12. package/e2e/perf/tab-switch.spec.ts +69 -0
  13. package/e2e/perf/text-selection.spec.ts +119 -0
  14. package/e2e/perf/utils/metrics.ts +286 -0
  15. package/e2e/perf/utils/perf-cli.ts +86 -0
  16. package/package.json +9 -18
  17. package/playwright.config.ts +12 -0
  18. package/src/App.tsx +124 -172
  19. package/src/{cli/index.ts → cli.ts} +37 -53
  20. package/src/components/ActionsMenu.tsx +6 -27
  21. package/src/components/DocumentViewer/DocumentViewer.tsx +77 -106
  22. package/src/components/DocumentViewer/MermaidDiagram.tsx +6 -7
  23. package/src/components/Header.tsx +9 -20
  24. package/src/components/InlineEditor.tsx +5 -5
  25. package/src/components/MarginNote.tsx +71 -93
  26. package/src/components/MarginNotes.tsx +7 -34
  27. package/src/components/RawModal.tsx +9 -8
  28. package/src/components/ReanchorConfirm.tsx +2 -2
  29. package/src/components/SettingsModal.tsx +11 -89
  30. package/src/components/TabBar.tsx +4 -4
  31. package/src/components/TableOfContents.tsx +5 -5
  32. package/src/components/comments/CommentInput.tsx +7 -35
  33. package/src/components/comments/CommentListItem.tsx +9 -11
  34. package/src/components/comments/CommentManager.tsx +53 -37
  35. package/src/components/comments/CommentNav.tsx +14 -14
  36. package/src/components/ui/ActionLink.tsx +14 -18
  37. package/src/components/ui/Button.tsx +42 -43
  38. package/src/components/ui/Dialog.tsx +73 -113
  39. package/src/components/ui/DropdownMenu.tsx +113 -69
  40. package/src/components/ui/Text.tsx +30 -37
  41. package/src/contexts/CommentContext.tsx +75 -106
  42. package/src/contexts/LocaleContext.tsx +45 -4
  43. package/src/contexts/PositionsContext.tsx +16 -0
  44. package/src/contexts/SettingsContext.tsx +133 -0
  45. package/src/hooks/useClickOutside.ts +0 -4
  46. package/src/hooks/useCommentNavigation.ts +6 -29
  47. package/src/hooks/useComments.ts +6 -18
  48. package/src/hooks/useDocument.ts +35 -34
  49. package/src/hooks/useHeadings.test.ts +8 -50
  50. package/src/hooks/useHeadings.ts +5 -88
  51. package/src/hooks/useScrollSpy.ts +10 -14
  52. package/src/hooks/useTextSelection.ts +1 -38
  53. package/src/lib/__fixtures__/bench-data.ts +1 -41
  54. package/src/lib/anchor.bench.ts +57 -67
  55. package/src/lib/anchor.test.ts +5 -1
  56. package/src/lib/anchor.ts +13 -93
  57. package/src/lib/comment-storage.test.ts +4 -4
  58. package/src/lib/comment-storage.ts +2 -46
  59. package/src/lib/export.ts +7 -13
  60. package/src/lib/highlight/core.test.ts +1 -1
  61. package/src/lib/highlight/dom.ts +5 -68
  62. package/src/lib/highlight/highlighter.ts +102 -262
  63. package/src/lib/highlight/resolver.ts +112 -0
  64. package/src/lib/highlight/types.ts +0 -35
  65. package/src/lib/highlight/worker.ts +45 -0
  66. package/src/lib/i18n/en.ts +1 -50
  67. package/src/lib/i18n/ja.ts +1 -50
  68. package/src/lib/i18n/types.ts +1 -49
  69. package/src/lib/margin-layout.ts +5 -27
  70. package/src/lib/positions.ts +150 -0
  71. package/src/lib/utils.ts +2 -19
  72. package/src/schema.ts +81 -0
  73. package/src/{server/index.ts → server.ts} +74 -74
  74. package/src/{store/index.ts → store.ts} +14 -46
  75. package/vite.config.ts +8 -0
  76. package/src/components/DocumentViewer/IframeContainer.tsx +0 -251
  77. package/src/components/DocumentViewer/InlineCode.tsx +0 -60
  78. package/src/components/DocumentViewer/index.ts +0 -1
  79. package/src/components/FloatingTOC.tsx +0 -61
  80. package/src/components/ShortcutCapture.tsx +0 -48
  81. package/src/components/ShortcutList.tsx +0 -198
  82. package/src/components/comments/CommentMinimap.tsx +0 -62
  83. package/src/components/ui/ActionBar.tsx +0 -16
  84. package/src/components/ui/SeparatorDot.tsx +0 -9
  85. package/src/contexts/LayoutContext.tsx +0 -88
  86. package/src/hooks/useClipboard.ts +0 -82
  87. package/src/hooks/useEditorScheme.ts +0 -51
  88. package/src/hooks/useFontPreference.ts +0 -59
  89. package/src/hooks/useKeybindings.ts +0 -108
  90. package/src/hooks/useKeyboardShortcuts.ts +0 -63
  91. package/src/hooks/useLayoutMode.ts +0 -44
  92. package/src/hooks/useLocalePreference.ts +0 -42
  93. package/src/hooks/useReanchorMode.ts +0 -33
  94. package/src/hooks/useScrollMetrics.ts +0 -56
  95. package/src/hooks/useThemePreference.ts +0 -66
  96. package/src/lib/comment-storage.bench.ts +0 -63
  97. package/src/lib/context.bench.ts +0 -41
  98. package/src/lib/context.test.ts +0 -224
  99. package/src/lib/context.ts +0 -193
  100. package/src/lib/editor-links.ts +0 -59
  101. package/src/lib/export.bench.ts +0 -35
  102. package/src/lib/highlight/colors.ts +0 -37
  103. package/src/lib/highlight/core.ts +0 -54
  104. package/src/lib/highlight/index.ts +0 -23
  105. package/src/lib/highlight/script-builder.ts +0 -485
  106. package/src/lib/html-processor.test.tsx +0 -170
  107. package/src/lib/html-processor.tsx +0 -95
  108. package/src/lib/i18n/completeness.test.ts +0 -51
  109. package/src/lib/i18n/translations.test.ts +0 -39
  110. package/src/lib/layout-constants.ts +0 -12
  111. package/src/lib/margin-layout.bench.ts +0 -28
  112. package/src/lib/scroll.test.ts +0 -118
  113. package/src/lib/scroll.ts +0 -47
  114. package/src/lib/shortcut-registry.test.ts +0 -173
  115. package/src/lib/shortcut-registry.ts +0 -209
  116. package/src/lib/utils.test.ts +0 -110
  117. package/src/store/index.test.ts +0 -242
  118. package/src/types/index.ts +0 -127
@@ -0,0 +1,75 @@
1
+ # Performance Baseline
2
+
3
+ Captured: 2026-03-27
4
+ Machine: Darwin 25.3.0 (Apple Silicon)
5
+ Runtime: Bun
6
+ Build: production (`bun run build`)
7
+
8
+ ## E2E Metrics (Playwright, Chromium)
9
+
10
+ ### Initial Load
11
+
12
+ | Tier | Lines | Comments | FCP | DCL | All Highlights Painted | Highlights Found |
13
+ |------|-------|----------|-----|-----|------------------------|------------------|
14
+ | medium | 1,000 | 100 | 112ms | 74ms | **886ms** | 100 |
15
+ | large | 3,000 | 200 | 368ms | 22ms | **3,247ms** | 193 |
16
+
17
+ ### Interactions
18
+
19
+ | Metric | Tier | Result |
20
+ |--------|------|--------|
21
+ | Add comment (time to new highlight) | medium | **98ms** |
22
+ | Text selection (median of 5) | medium | **9ms** |
23
+ | Tab switch (medium → medium-b, 100 → 100 comments) | medium | **414ms** |
24
+
25
+ ### Scroll Performance
26
+
27
+ | Tier | Total Scroll Time | Long Tasks (>50ms) | P50 | P95 | P99 |
28
+ |------|-------------------|-------------------|-----|-----|-----|
29
+ | medium (1000 lines, 100 comments) | 8,953ms | 0 | 0ms | 0ms | 0ms |
30
+ | large (3000 lines, 200 comments) | 25,912ms | 3 | 106ms | 121ms | 121ms |
31
+
32
+ ## Bundle Size
33
+
34
+ | Asset | Raw | Gzipped |
35
+ |-------|-----|---------|
36
+ | Main JS (index-*.js) | 667 KB | 206 KB |
37
+ | Total dist/assets/ | 6.5 MB | — |
38
+ | CSS (index-*.css) | 45 KB | — |
39
+ | CLI (cli.js) | 51 KB | — |
40
+
41
+ ### Top chunks by size
42
+
43
+ | Chunk | Size | Purpose |
44
+ |-------|------|---------|
45
+ | index-DCIQ7W07.js | 652 KB | Main app bundle |
46
+ | chunk-XZSTWKYB.js | 426 KB | Mermaid core |
47
+ | cytoscape.esm.js | 424 KB | Mermaid dependency |
48
+ | katex.js | 250 KB | Math rendering (mermaid) |
49
+ | prism.js | 146 KB | Syntax highlighter |
50
+ | architectureDiagram.js | 143 KB | Mermaid architecture |
51
+ | chunk-7R4GIKGN.js | 124 KB | Mermaid support |
52
+ | esm.js | 112 KB | Mermaid support |
53
+
54
+ ## Vitest Bench (Server-side Operations)
55
+
56
+ > Run with: `bun run bench`
57
+
58
+ Results populated after running benchmarks. See `src/lib/*.bench.ts`.
59
+
60
+ ## Key Bottlenecks (from analysis)
61
+
62
+ 1. **All Highlights Painted** is the critical metric: 886ms (medium), 3,247ms (large)
63
+ - Dominated by: react-markdown parse → React reconcile → rAF → TreeWalker → Worker → TreeWalker → DOM surgery
64
+ 2. **Tab switch** (414ms) is highlight re-application on a new document
65
+ 3. **Large doc scroll** shows 3 long tasks (106-121ms) — likely margin note position recalculation or highlight intersection
66
+ 4. **Bundle**: 667KB main + lazy mermaid (1MB+) means slow cold loads on constrained networks
67
+
68
+ ## Optimization Targets
69
+
70
+ | Change | Metric to Watch | Current | Goal |
71
+ |--------|----------------|---------|------|
72
+ | Server-side MD rendering | FCP, All Highlights Painted | 886ms / 3,247ms | <100ms / <500ms |
73
+ | CSS Custom Highlight API | All Highlights Painted, Add Comment | 886ms / 98ms | <100ms / <20ms |
74
+ | Eliminate SPA waterfall | FCP | 112ms / 368ms | <30ms |
75
+ | Drop heavy client deps | Bundle size (main JS) | 667KB | <50KB |