@peaske7/readit 0.2.1 → 0.3.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.
- package/dist/.vite/manifest.json +1111 -0
- package/dist/assets/_basePickBy-BMMA4Tou.js +1 -0
- package/dist/assets/_baseUniq-D40qku1I.js +1 -0
- package/dist/assets/arc-Ckg65iy8.js +1 -0
- package/dist/assets/architecture-YZFGNWBL-Dv3EY0zV.js +1 -0
- package/dist/assets/architectureDiagram-Q4EWVU46-ClRss4cm.js +36 -0
- package/dist/assets/array-Bjz-wYpJ.js +1 -0
- package/dist/assets/blockDiagram-DXYQGD6D-CBcFvoK1.js +132 -0
- package/dist/assets/c4Diagram-AHTNJAMY-D4d3ZLam.js +10 -0
- package/dist/assets/channel-D9EJxDy_.js +1 -0
- package/dist/assets/chunk-2KRD3SAO-DaFfaCGO.js +1 -0
- package/dist/assets/chunk-336JU56O-yLEQoF0v.js +2 -0
- package/dist/assets/chunk-426QAEUC-Uyzd4wAA.js +1 -0
- package/dist/assets/chunk-4BX2VUAB-DRuTD7x5.js +1 -0
- package/dist/assets/chunk-4TB4RGXK-3xbpIi_o.js +206 -0
- package/dist/assets/chunk-55IACEB6-BExiaAoD.js +1 -0
- package/dist/assets/chunk-5FUZZQ4R-DatVvHnF.js +62 -0
- package/dist/assets/chunk-5PVQY5BW-BKgvrGh8.js +2 -0
- package/dist/assets/chunk-67CJDMHE-DMt8LNEX.js +1 -0
- package/dist/assets/chunk-7N4EOEYR-CzLGefVf.js +1 -0
- package/dist/assets/chunk-AA7GKIK3-B6GFAk4U.js +1 -0
- package/dist/assets/chunk-BSJP7CBP-BK29yehL.js +1 -0
- package/dist/assets/chunk-CIAEETIT-D7hBXImP.js +1 -0
- package/dist/assets/chunk-Dlc7tRH4.js +1 -0
- package/dist/assets/chunk-EDXVE4YY-PYJdlmyH.js +1 -0
- package/dist/assets/chunk-ENJZ2VHE-DUHKBv6x.js +10 -0
- package/dist/assets/chunk-FMBD7UC4-2FWyCCAV.js +15 -0
- package/dist/assets/chunk-FOC6F5B3-DKFHrt4K.js +1 -0
- package/dist/assets/chunk-ICPOFSXX-Bh__D0ec.js +122 -0
- package/dist/assets/chunk-K5T4RW27-D51O7IkG.js +94 -0
- package/dist/assets/chunk-KGLVRYIC-DMHSCH4T.js +1 -0
- package/dist/assets/chunk-LIHQZDEY-C2aANxt9.js +1 -0
- package/dist/assets/chunk-ORNJ4GCN-Db_37NRX.js +1 -0
- package/dist/assets/chunk-OYMX7WX6-BltXOJLJ.js +231 -0
- package/dist/assets/chunk-QZHKN3VN-8Lcg9gti.js +1 -0
- package/dist/assets/chunk-U2HBQHQK-ByS6tilY.js +70 -0
- package/dist/assets/chunk-X2U36JSP-Bm-4Gqg_.js +1 -0
- package/dist/assets/chunk-XPW4576I-Bqbompq4.js +32 -0
- package/dist/assets/chunk-YZCP3GAM-CsC0imPb.js +1 -0
- package/dist/assets/chunk-ZZ45TVLE-CG-CqfPC.js +1 -0
- package/dist/assets/classDiagram-6PBFFD2Q-Jy1uFUk4.js +1 -0
- package/dist/assets/classDiagram-v2-HSJHXN6E-ChiLl3rR.js +1 -0
- package/dist/assets/clone-BBjvuERA.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-q90QeGKv.js +1 -0
- package/dist/assets/cytoscape.esm-BfXff3fb.js +321 -0
- package/dist/assets/dagre-KV5264BT-BQWiLFJB.js +4 -0
- package/dist/assets/dagre-nn_aIZ2E.js +1 -0
- package/dist/assets/defaultLocale-BwmRmqJp.js +1 -0
- package/dist/assets/diagram-5BDNPKRD-CJa7Y97H.js +10 -0
- package/dist/assets/diagram-G4DWMVQ6-tVQGBWfY.js +24 -0
- package/dist/assets/diagram-MMDJMWI5-CpimFldm.js +43 -0
- package/dist/assets/diagram-TYMM5635-D11WQVgy.js +24 -0
- package/dist/assets/dist-BNz65Ibc.js +1 -0
- package/dist/assets/erDiagram-SMLLAGMA-C2bLd0jS.js +85 -0
- package/dist/assets/flowDiagram-DWJPFMVM-Kw3fOOLT.js +162 -0
- package/dist/assets/ganttDiagram-T4ZO3ILL-fyMhyE2X.js +292 -0
- package/dist/assets/gitGraph-7Q5UKJZL-BGFRt2qs.js +1 -0
- package/dist/assets/gitGraphDiagram-UUTBAWPF-D4JoiOvg.js +106 -0
- package/dist/assets/graphlib-DGcD9J2L.js +1 -0
- package/dist/assets/index-Cow3qpoq.css +2 -0
- package/dist/assets/index-DUf7okYi.js +14 -0
- package/dist/assets/info-OMHHGYJF-DI6-Z9vh.js +1 -0
- package/dist/assets/infoDiagram-42DDH7IO-D1ZkeMBy.js +2 -0
- package/dist/assets/init-TPm5RB77.js +1 -0
- package/dist/assets/isArrayLikeObject-69BLnVNM.js +1 -0
- package/dist/assets/isEmpty-DUS28g5f.js +1 -0
- package/dist/assets/ishikawaDiagram-UXIWVN3A-Dv8hzjZB.js +70 -0
- package/dist/assets/journeyDiagram-VCZTEJTY-COeB7F5r.js +139 -0
- package/dist/assets/kanban-definition-6JOO6SKY-BbYmxCYU.js +89 -0
- package/dist/assets/katex-5SGEXwpi.js +261 -0
- package/dist/assets/line-_v2NGEdn.js +1 -0
- package/dist/assets/linear-CXMqTN8N.js +1 -0
- package/dist/assets/mermaid-config-C8a4L22x.js +1 -0
- package/dist/assets/mermaid-parser.core-CFmphzPP.js +4 -0
- package/dist/assets/mermaid.core-DnHAupTp.js +11 -0
- package/dist/assets/mindmap-definition-QFDTVHPH-D7_lIep7.js +96 -0
- package/dist/assets/ordinal-D7l-8DAO.js +1 -0
- package/dist/assets/packet-4T2RLAQJ-DidW3JFc.js +1 -0
- package/dist/assets/path-BVpCanzE.js +1 -0
- package/dist/assets/pie-ZZUOXDRM-Bff2e5hg.js +1 -0
- package/dist/assets/pieDiagram-DEJITSTG-DDvYHCT_.js +30 -0
- package/dist/assets/quadrantDiagram-34T5L4WZ-DcLcIrdi.js +7 -0
- package/dist/assets/radar-PYXPWWZC-CsdZBH3M.js +1 -0
- package/dist/assets/requirementDiagram-MS252O5E-DLX6ld7D.js +84 -0
- package/dist/assets/rough.esm-BoTisKeL.js +1 -0
- package/dist/assets/sankeyDiagram-XADWPNL6-D-1GtsHM.js +10 -0
- package/dist/assets/sequenceDiagram-FGHM5R23-Bwxs0YQg.js +157 -0
- package/dist/assets/src-CrmkjRpa.js +1 -0
- package/dist/assets/stateDiagram-FHFEXIEX-DW7rOcnQ.js +1 -0
- package/dist/assets/stateDiagram-v2-QKLJ7IA2-Jm-24vQ2.js +1 -0
- package/dist/assets/timeline-definition-GMOUNBTQ-DVdHyzxS.js +120 -0
- package/dist/assets/treeView-SZITEDCU-DPKseaET.js +1 -0
- package/dist/assets/treemap-W4RFUUIX-DH-7GZe_.js +1 -0
- package/dist/assets/vennDiagram-DHZGUBPP-DJaC6xmI.js +34 -0
- package/dist/assets/wardley-RL74JXVD-AgyXyBN5.js +1 -0
- package/dist/assets/wardleyDiagram-NUSXRM2D-CTKERPKv.js +20 -0
- package/dist/assets/xychartDiagram-5P7HB3ND-BuExiLXc.js +7 -0
- package/{index.html → dist/index.html} +2 -1
- package/dist/index.js +2539 -0
- package/package.json +11 -1
- package/.agents/skills/remotion-best-practices/SKILL.md +0 -61
- package/.agents/skills/remotion-best-practices/rules/3d.md +0 -86
- package/.agents/skills/remotion-best-practices/rules/animations.md +0 -27
- package/.agents/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +0 -178
- package/.agents/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +0 -100
- package/.agents/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +0 -108
- package/.agents/skills/remotion-best-practices/rules/assets.md +0 -78
- package/.agents/skills/remotion-best-practices/rules/audio-visualization.md +0 -198
- package/.agents/skills/remotion-best-practices/rules/audio.md +0 -169
- package/.agents/skills/remotion-best-practices/rules/calculate-metadata.md +0 -134
- package/.agents/skills/remotion-best-practices/rules/can-decode.md +0 -75
- package/.agents/skills/remotion-best-practices/rules/charts.md +0 -120
- package/.agents/skills/remotion-best-practices/rules/compositions.md +0 -154
- package/.agents/skills/remotion-best-practices/rules/display-captions.md +0 -184
- package/.agents/skills/remotion-best-practices/rules/extract-frames.md +0 -229
- package/.agents/skills/remotion-best-practices/rules/ffmpeg.md +0 -38
- package/.agents/skills/remotion-best-practices/rules/fonts.md +0 -152
- package/.agents/skills/remotion-best-practices/rules/get-audio-duration.md +0 -58
- package/.agents/skills/remotion-best-practices/rules/get-video-dimensions.md +0 -68
- package/.agents/skills/remotion-best-practices/rules/get-video-duration.md +0 -60
- package/.agents/skills/remotion-best-practices/rules/gifs.md +0 -141
- package/.agents/skills/remotion-best-practices/rules/images.md +0 -134
- package/.agents/skills/remotion-best-practices/rules/import-srt-captions.md +0 -69
- package/.agents/skills/remotion-best-practices/rules/light-leaks.md +0 -73
- package/.agents/skills/remotion-best-practices/rules/lottie.md +0 -70
- package/.agents/skills/remotion-best-practices/rules/maps.md +0 -412
- package/.agents/skills/remotion-best-practices/rules/measuring-dom-nodes.md +0 -34
- package/.agents/skills/remotion-best-practices/rules/measuring-text.md +0 -140
- package/.agents/skills/remotion-best-practices/rules/parameters.md +0 -109
- package/.agents/skills/remotion-best-practices/rules/sequencing.md +0 -118
- package/.agents/skills/remotion-best-practices/rules/sfx.md +0 -26
- package/.agents/skills/remotion-best-practices/rules/subtitles.md +0 -36
- package/.agents/skills/remotion-best-practices/rules/tailwind.md +0 -11
- package/.agents/skills/remotion-best-practices/rules/text-animations.md +0 -20
- package/.agents/skills/remotion-best-practices/rules/timing.md +0 -179
- package/.agents/skills/remotion-best-practices/rules/transcribe-captions.md +0 -70
- package/.agents/skills/remotion-best-practices/rules/transitions.md +0 -197
- package/.agents/skills/remotion-best-practices/rules/transparent-videos.md +0 -106
- package/.agents/skills/remotion-best-practices/rules/trimming.md +0 -51
- package/.agents/skills/remotion-best-practices/rules/videos.md +0 -171
- package/.agents/skills/remotion-best-practices/rules/voiceover.md +0 -99
- package/.agents/skills/simple/SKILL.md +0 -52
- package/.agents/skills/vercel-react-best-practices/AGENTS.md +0 -3254
- package/.agents/skills/vercel-react-best-practices/README.md +0 -123
- package/.agents/skills/vercel-react-best-practices/SKILL.md +0 -141
- package/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +0 -55
- package/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +0 -42
- package/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +0 -39
- package/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +0 -38
- package/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +0 -80
- package/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +0 -51
- package/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +0 -28
- package/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +0 -99
- package/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +0 -59
- package/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +0 -31
- package/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +0 -49
- package/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +0 -35
- package/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +0 -50
- package/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +0 -74
- package/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +0 -71
- package/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +0 -48
- package/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +0 -56
- package/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +0 -107
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +0 -80
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +0 -28
- package/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +0 -70
- package/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +0 -32
- package/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +0 -50
- package/.agents/skills/vercel-react-best-practices/rules/js-flatmap-filter.md +0 -60
- package/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +0 -45
- package/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +0 -37
- package/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +0 -49
- package/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +0 -82
- package/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +0 -24
- package/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +0 -57
- package/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +0 -26
- package/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +0 -47
- package/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +0 -40
- package/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +0 -38
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +0 -46
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +0 -82
- package/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +0 -30
- package/.agents/skills/vercel-react-best-practices/rules/rendering-resource-hints.md +0 -85
- package/.agents/skills/vercel-react-best-practices/rules/rendering-script-defer-async.md +0 -68
- package/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +0 -28
- package/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +0 -75
- package/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +0 -39
- package/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +0 -45
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +0 -40
- package/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +0 -29
- package/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +0 -74
- package/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +0 -58
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +0 -38
- package/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +0 -44
- package/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +0 -45
- package/.agents/skills/vercel-react-best-practices/rules/rerender-no-inline-components.md +0 -82
- package/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +0 -35
- package/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +0 -40
- package/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +0 -73
- package/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +0 -73
- package/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +0 -96
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +0 -41
- package/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +0 -76
- package/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +0 -65
- package/.agents/skills/vercel-react-best-practices/rules/server-hoist-static-io.md +0 -142
- package/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +0 -83
- package/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +0 -38
- package/.claude/CLAUDE.md +0 -184
- package/.claude/commands/review.md +0 -120
- package/.claude/commands/sync-docs.md +0 -71
- package/.claude/roadmap.md +0 -121
- package/.claude/rules/style-guide.md +0 -830
- package/.claude/settings.json +0 -18
- package/.claude/user-stories.md +0 -333
- package/AGENTS.md +0 -68
- package/Makefile +0 -32
- package/biome.json +0 -79
- package/bun.lock +0 -854
- package/bunfig.toml +0 -2
- package/docs/design.md +0 -563
- package/docs/perf-baseline.md +0 -130
- package/docs/plans/2026-03-13-client-mode-design.md +0 -86
- package/docs/plans/2026-03-13-client-mode-plan.md +0 -605
- package/docs/plans/2026-03-13-keyboard-shortcuts-design.md +0 -129
- package/docs/plans/2026-03-13-keyboard-shortcuts-plan.md +0 -1471
- package/docs/plans/2026-03-13-multi-document-design.md +0 -183
- package/docs/plans/2026-03-13-performance-benchmarks-design.md +0 -121
- package/docs/superpowers/plans/2026-03-26-surgical-pruning.md +0 -1176
- package/docs/superpowers/specs/2026-03-27-go-server-rewrite-design.md +0 -284
- package/e2e/comments.spec.ts +0 -81
- package/e2e/document-load.spec.ts +0 -32
- package/e2e/export.spec.ts +0 -58
- package/e2e/fixtures/sample.md +0 -7
- package/e2e/perf/add-comment.spec.ts +0 -116
- package/e2e/perf/fixtures/generate.ts +0 -327
- package/e2e/perf/initial-load.spec.ts +0 -49
- package/e2e/perf/perf.setup.ts +0 -23
- package/e2e/perf/perf.teardown.ts +0 -9
- package/e2e/perf/screenshot-final.png +0 -0
- package/e2e/perf/scroll.spec.ts +0 -39
- package/e2e/perf/tab-switch.spec.ts +0 -69
- package/e2e/perf/text-selection.spec.ts +0 -119
- package/e2e/perf/utils/metrics.ts +0 -350
- package/e2e/perf/utils/perf-cli.ts +0 -86
- package/e2e/persistence-file.spec.ts +0 -357
- package/e2e/utils/cli.ts +0 -84
- package/e2e/utils/selection.ts +0 -79
- package/go/cmd/readit/main.go +0 -416
- package/go/go.mod +0 -20
- package/go/go.sum +0 -41
- package/go/internal/server/anchor.go +0 -302
- package/go/internal/server/anchor_test.go +0 -111
- package/go/internal/server/comments.go +0 -390
- package/go/internal/server/documents.go +0 -113
- package/go/internal/server/embed.go +0 -17
- package/go/internal/server/headings.go +0 -33
- package/go/internal/server/headings_test.go +0 -75
- package/go/internal/server/htmltext.go +0 -123
- package/go/internal/server/markdown.go +0 -157
- package/go/internal/server/markdown_bench_test.go +0 -42
- package/go/internal/server/markdown_test.go +0 -79
- package/go/internal/server/server.go +0 -453
- package/go/internal/server/server_bench_test.go +0 -122
- package/go/internal/server/settings.go +0 -110
- package/go/internal/server/sse.go +0 -140
- package/go/internal/server/storage.go +0 -275
- package/go/internal/server/storage_test.go +0 -118
- package/go/internal/server/template.go +0 -66
- package/go/internal/server/types.go +0 -101
- package/go/internal/server/watcher.go +0 -74
- package/lefthook.yml +0 -8
- package/nvim-readit/lua/readit/health.lua +0 -64
- package/nvim-readit/lua/readit/init.lua +0 -463
- package/nvim-readit/plugin/readit.lua +0 -19
- package/playwright.config.ts +0 -34
- package/skills-lock.json +0 -20
- package/src/App.svelte +0 -881
- package/src/cli.ts +0 -881
- package/src/components/ActionsMenu.svelte +0 -95
- package/src/components/CommentBadge.svelte +0 -67
- package/src/components/CommentErrorBanner.svelte +0 -33
- package/src/components/CommentInput.svelte +0 -75
- package/src/components/CommentListItem.svelte +0 -95
- package/src/components/CommentManager.svelte +0 -129
- package/src/components/CommentNav.svelte +0 -109
- package/src/components/DocumentViewer.svelte +0 -218
- package/src/components/FloatingComment.svelte +0 -107
- package/src/components/Header.svelte +0 -76
- package/src/components/InlineEditor.svelte +0 -72
- package/src/components/MarginNote.svelte +0 -167
- package/src/components/MarginNotesContainer.svelte +0 -33
- package/src/components/RawModal.svelte +0 -126
- package/src/components/ReanchorConfirm.svelte +0 -30
- package/src/components/SettingsModal.svelte +0 -220
- package/src/components/ShortcutCapture.svelte +0 -82
- package/src/components/ShortcutList.svelte +0 -145
- package/src/components/TabBar.svelte +0 -52
- package/src/components/TableOfContents.svelte +0 -125
- package/src/components/ui/ActionLink.svelte +0 -40
- package/src/components/ui/Button.svelte +0 -53
- package/src/components/ui/Dialog.svelte +0 -97
- package/src/components/ui/DropdownMenu.svelte +0 -85
- package/src/components/ui/DropdownMenuItem.svelte +0 -38
- package/src/components/ui/DropdownMenuSeparator.svelte +0 -11
- package/src/components/ui/Text.svelte +0 -42
- package/src/env.d.ts +0 -6
- package/src/index.css +0 -754
- package/src/lib/__fixtures__/bench-data.ts +0 -114
- package/src/lib/anchor.bench.ts +0 -91
- package/src/lib/anchor.test.ts +0 -527
- package/src/lib/anchor.ts +0 -381
- package/src/lib/comment-storage.bench.ts +0 -49
- package/src/lib/comment-storage.test.ts +0 -632
- package/src/lib/comment-storage.ts +0 -222
- package/src/lib/export.bench.ts +0 -21
- package/src/lib/export.ts +0 -36
- package/src/lib/headings.test.ts +0 -103
- package/src/lib/headings.ts +0 -44
- package/src/lib/highlight/core.test.ts +0 -93
- package/src/lib/highlight/dom.ts +0 -187
- package/src/lib/highlight/highlight-registry.ts +0 -221
- package/src/lib/highlight/highlight.bench.ts +0 -92
- package/src/lib/highlight/highlighter.ts +0 -247
- package/src/lib/highlight/resolver.ts +0 -38
- package/src/lib/highlight/types.ts +0 -17
- package/src/lib/html-text.test.ts +0 -162
- package/src/lib/html-text.ts +0 -161
- package/src/lib/i18n/en.ts +0 -116
- package/src/lib/i18n/index.ts +0 -3
- package/src/lib/i18n/ja.ts +0 -118
- package/src/lib/i18n/translations.ts +0 -27
- package/src/lib/i18n/types.ts +0 -122
- package/src/lib/margin-layout.bench.ts +0 -61
- package/src/lib/margin-layout.ts +0 -71
- package/src/lib/markdown-renderer.test.ts +0 -154
- package/src/lib/markdown-renderer.ts +0 -177
- package/src/lib/mermaid-config.ts +0 -38
- package/src/lib/mermaid-renderer.ts +0 -162
- package/src/lib/mermaid-worker.ts +0 -60
- package/src/lib/positions.ts +0 -157
- package/src/lib/shortcut-registry.ts +0 -244
- package/src/lib/utils.ts +0 -15
- package/src/main.ts +0 -16
- package/src/schema.ts +0 -92
- package/src/server.ts +0 -1220
- package/src/stores/app.svelte.ts +0 -231
- package/src/stores/locale.svelte.ts +0 -46
- package/src/stores/settings.svelte.ts +0 -90
- package/src/stores/shortcuts.svelte.ts +0 -104
- package/src/stores/ui.svelte.ts +0 -12
- package/src/template.ts +0 -104
- package/src/test-setup.ts +0 -48
- package/svelte.config.js +0 -5
- package/test.md +0 -74
- package/tsconfig.cli.json +0 -12
- package/tsconfig.json +0 -20
- package/vite.config.ts +0 -47
- package/vitest.config.ts +0 -15
- package/vscode-readit/.mcp.json +0 -7
- package/vscode-readit/.vscodeignore +0 -7
- package/vscode-readit/bun.lock +0 -78
- package/vscode-readit/icon.svg +0 -10
- package/vscode-readit/package.json +0 -110
- package/vscode-readit/src/extension.ts +0 -117
- package/vscode-readit/src/server-manager.ts +0 -272
- package/vscode-readit/src/webview-provider.ts +0 -204
- package/vscode-readit/tsconfig.json +0 -20
package/src/lib/i18n/types.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
export const Locales = {
|
|
2
|
-
JA: "ja",
|
|
3
|
-
EN: "en",
|
|
4
|
-
} as const;
|
|
5
|
-
|
|
6
|
-
export type Locale = (typeof Locales)[keyof typeof Locales];
|
|
7
|
-
|
|
8
|
-
export interface Translations {
|
|
9
|
-
// App
|
|
10
|
-
"app.loading": string;
|
|
11
|
-
"app.noDocuments": string;
|
|
12
|
-
"app.noDocumentsHintPrefix": string;
|
|
13
|
-
"app.noDocumentsHintSuffix": string;
|
|
14
|
-
"app.footer": string;
|
|
15
|
-
|
|
16
|
-
// Header
|
|
17
|
-
"header.selectTextToReanchor": string;
|
|
18
|
-
|
|
19
|
-
// Actions menu
|
|
20
|
-
"actions.ariaLabel": string;
|
|
21
|
-
"actions.settings": string;
|
|
22
|
-
"actions.reload": string;
|
|
23
|
-
"actions.copyAll": string;
|
|
24
|
-
"actions.exportJson": string;
|
|
25
|
-
"actions.viewRaw": string;
|
|
26
|
-
|
|
27
|
-
// Settings
|
|
28
|
-
"settings.title": string;
|
|
29
|
-
"settings.theme": string;
|
|
30
|
-
"settings.font": string;
|
|
31
|
-
"settings.language": string;
|
|
32
|
-
"settings.theme.system": string;
|
|
33
|
-
"settings.theme.light": string;
|
|
34
|
-
"settings.theme.dark": string;
|
|
35
|
-
"settings.font.serif": string;
|
|
36
|
-
"settings.font.sansSerif": string;
|
|
37
|
-
|
|
38
|
-
// Comment input
|
|
39
|
-
"comment.placeholder": string;
|
|
40
|
-
"comment.cancel": string;
|
|
41
|
-
"comment.addNote": string;
|
|
42
|
-
"comment.highlight": string;
|
|
43
|
-
|
|
44
|
-
// Margin note
|
|
45
|
-
"marginNote.addNote": string;
|
|
46
|
-
"marginNote.delete": string;
|
|
47
|
-
"marginNote.edit": string;
|
|
48
|
-
"marginNote.copy": string;
|
|
49
|
-
|
|
50
|
-
// Comment manager
|
|
51
|
-
"commentManager.unresolved": string;
|
|
52
|
-
"commentManager.deleteAllConfirm": string;
|
|
53
|
-
"commentManager.delete": string;
|
|
54
|
-
"commentManager.cancel": string;
|
|
55
|
-
"commentManager.copyAllTitle": string;
|
|
56
|
-
"commentManager.deleteAllTitle": string;
|
|
57
|
-
"commentManager.noComments": string;
|
|
58
|
-
|
|
59
|
-
// Comment list item
|
|
60
|
-
"commentList.edit": string;
|
|
61
|
-
"commentList.delete": string;
|
|
62
|
-
"commentList.goTo": string;
|
|
63
|
-
"commentList.reanchor": string;
|
|
64
|
-
"commentList.unresolved": string;
|
|
65
|
-
|
|
66
|
-
// Comment nav
|
|
67
|
-
"commentNav.previous": string;
|
|
68
|
-
"commentNav.next": string;
|
|
69
|
-
"commentNav.of": string;
|
|
70
|
-
|
|
71
|
-
// Inline editor
|
|
72
|
-
"editor.save": string;
|
|
73
|
-
"editor.cancel": string;
|
|
74
|
-
|
|
75
|
-
// Reanchor confirm
|
|
76
|
-
"reanchor.question": string;
|
|
77
|
-
"reanchor.confirm": string;
|
|
78
|
-
"reanchor.cancel": string;
|
|
79
|
-
|
|
80
|
-
// Raw comments modal
|
|
81
|
-
"rawModal.title": string;
|
|
82
|
-
"rawModal.copyTitle": string;
|
|
83
|
-
"rawModal.loading": string;
|
|
84
|
-
"rawModal.noComments": string;
|
|
85
|
-
"rawModal.copiedToClipboard": string;
|
|
86
|
-
"rawModal.failedToCopy": string;
|
|
87
|
-
|
|
88
|
-
// Toast messages
|
|
89
|
-
"toast.copied": string;
|
|
90
|
-
"toast.copiedAllComments": string;
|
|
91
|
-
|
|
92
|
-
// Comment badge
|
|
93
|
-
"commentBadge.title": string;
|
|
94
|
-
"commentBadge.titlePlural": string;
|
|
95
|
-
|
|
96
|
-
// Keyboard shortcuts
|
|
97
|
-
"shortcuts.title": string;
|
|
98
|
-
"shortcutGroup.copy": string;
|
|
99
|
-
"shortcutGroup.navigate": string;
|
|
100
|
-
"shortcutGroup.other": string;
|
|
101
|
-
"shortcuts.resetToDefaults": string;
|
|
102
|
-
"shortcuts.enableDisable": string;
|
|
103
|
-
"shortcutCapture.pressKeys": string;
|
|
104
|
-
"shortcutCapture.reserved": string;
|
|
105
|
-
"shortcutCapture.ariaLabel": string;
|
|
106
|
-
"shortcut.copyAll.label": string;
|
|
107
|
-
"shortcut.copyAll.description": string;
|
|
108
|
-
"shortcut.copyAllRaw.label": string;
|
|
109
|
-
"shortcut.copyAllRaw.description": string;
|
|
110
|
-
"shortcut.navigateNext.label": string;
|
|
111
|
-
"shortcut.navigateNext.description": string;
|
|
112
|
-
"shortcut.navigatePrevious.label": string;
|
|
113
|
-
"shortcut.navigatePrevious.description": string;
|
|
114
|
-
"shortcut.copySelectionRaw.label": string;
|
|
115
|
-
"shortcut.copySelectionRaw.description": string;
|
|
116
|
-
"shortcut.copySelectionLLM.label": string;
|
|
117
|
-
"shortcut.copySelectionLLM.description": string;
|
|
118
|
-
"shortcut.clearSelection.label": string;
|
|
119
|
-
"shortcut.clearSelection.description": string;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export type TranslationKey = keyof Translations;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { bench, describe } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
COMMENTS_1,
|
|
4
|
-
COMMENTS_10,
|
|
5
|
-
COMMENTS_50,
|
|
6
|
-
} from "./__fixtures__/bench-data";
|
|
7
|
-
import { resolveMarginNotePositions } from "./margin-layout";
|
|
8
|
-
|
|
9
|
-
function makeHighlightPositions(
|
|
10
|
-
commentIds: string[],
|
|
11
|
-
spacing: number,
|
|
12
|
-
): Record<string, number> {
|
|
13
|
-
const positions: Record<string, number> = {};
|
|
14
|
-
for (let i = 0; i < commentIds.length; i++) {
|
|
15
|
-
positions[commentIds[i]] = i * spacing;
|
|
16
|
-
}
|
|
17
|
-
return positions;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe("resolveMarginNotePositions — well-spaced", () => {
|
|
21
|
-
bench("1 comment", () => {
|
|
22
|
-
const ids = COMMENTS_1.map((c) => c.id);
|
|
23
|
-
const positions = makeHighlightPositions(ids, 300);
|
|
24
|
-
resolveMarginNotePositions(ids, positions, undefined);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
bench("10 comments", () => {
|
|
28
|
-
const ids = COMMENTS_10.map((c) => c.id);
|
|
29
|
-
const positions = makeHighlightPositions(ids, 300);
|
|
30
|
-
resolveMarginNotePositions(ids, positions, undefined);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
bench("50 comments", () => {
|
|
34
|
-
const ids = COMMENTS_50.map((c) => c.id);
|
|
35
|
-
const positions = makeHighlightPositions(ids, 300);
|
|
36
|
-
resolveMarginNotePositions(ids, positions, undefined);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe("resolveMarginNotePositions — clustered", () => {
|
|
41
|
-
bench("10 comments, 10px apart", () => {
|
|
42
|
-
const ids = COMMENTS_10.map((c) => c.id);
|
|
43
|
-
const positions = makeHighlightPositions(ids, 10);
|
|
44
|
-
resolveMarginNotePositions(ids, positions, undefined);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
bench("50 comments, 10px apart", () => {
|
|
48
|
-
const ids = COMMENTS_50.map((c) => c.id);
|
|
49
|
-
const positions = makeHighlightPositions(ids, 10);
|
|
50
|
-
resolveMarginNotePositions(ids, positions, undefined);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("resolveMarginNotePositions — with input zone", () => {
|
|
55
|
-
bench("50 comments, input at middle", () => {
|
|
56
|
-
const ids = COMMENTS_50.map((c) => c.id);
|
|
57
|
-
const positions = makeHighlightPositions(ids, 100);
|
|
58
|
-
const midpoint = 25 * 100;
|
|
59
|
-
resolveMarginNotePositions(ids, positions, midpoint);
|
|
60
|
-
});
|
|
61
|
-
});
|
package/src/lib/margin-layout.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
const MARGIN_NOTE_MIN_GAP_PX = 150;
|
|
2
|
-
const COMMENT_INPUT_HEIGHT_PX = 160;
|
|
3
|
-
|
|
4
|
-
interface NotePosition {
|
|
5
|
-
commentId: string;
|
|
6
|
-
top: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function resolveMarginNotePositions(
|
|
10
|
-
commentIds: string[],
|
|
11
|
-
highlightPositions: Record<string, number>,
|
|
12
|
-
pendingSelectionTop: number | undefined,
|
|
13
|
-
): Map<string, number> {
|
|
14
|
-
const positions: NotePosition[] = commentIds
|
|
15
|
-
.filter((id) => id in highlightPositions)
|
|
16
|
-
.map((id) => ({
|
|
17
|
-
commentId: id,
|
|
18
|
-
top: highlightPositions[id],
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
positions.sort((a, b) => a.top - b.top);
|
|
22
|
-
|
|
23
|
-
if (pendingSelectionTop !== null && pendingSelectionTop !== undefined) {
|
|
24
|
-
const inputStart = pendingSelectionTop;
|
|
25
|
-
const inputEnd = pendingSelectionTop + COMMENT_INPUT_HEIGHT_PX;
|
|
26
|
-
|
|
27
|
-
for (const pos of positions) {
|
|
28
|
-
const noteBottom = pos.top + MARGIN_NOTE_MIN_GAP_PX;
|
|
29
|
-
|
|
30
|
-
const overlaps = noteBottom > inputStart && pos.top < inputEnd;
|
|
31
|
-
|
|
32
|
-
if (overlaps) {
|
|
33
|
-
if (pos.top < inputStart) {
|
|
34
|
-
pos.top = Math.max(0, inputStart - MARGIN_NOTE_MIN_GAP_PX);
|
|
35
|
-
} else {
|
|
36
|
-
pos.top = inputEnd;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
positions.sort((a, b) => a.top - b.top);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const inputStartForOverlap = pendingSelectionTop ?? Infinity;
|
|
44
|
-
const inputEndForOverlap =
|
|
45
|
-
pendingSelectionTop != null
|
|
46
|
-
? pendingSelectionTop + COMMENT_INPUT_HEIGHT_PX
|
|
47
|
-
: Infinity;
|
|
48
|
-
|
|
49
|
-
for (let i = positions.length - 2; i >= 0; i--) {
|
|
50
|
-
const curr = positions[i];
|
|
51
|
-
const next = positions[i + 1];
|
|
52
|
-
if (next.top >= inputStartForOverlap) continue;
|
|
53
|
-
if (next.top - curr.top < MARGIN_NOTE_MIN_GAP_PX) {
|
|
54
|
-
curr.top = Math.max(0, next.top - MARGIN_NOTE_MIN_GAP_PX);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
for (let i = 1; i < positions.length; i++) {
|
|
59
|
-
const prev = positions[i - 1];
|
|
60
|
-
const curr = positions[i];
|
|
61
|
-
if (curr.top - prev.top < MARGIN_NOTE_MIN_GAP_PX) {
|
|
62
|
-
let newTop = prev.top + MARGIN_NOTE_MIN_GAP_PX;
|
|
63
|
-
if (newTop >= inputStartForOverlap && newTop < inputEndForOverlap) {
|
|
64
|
-
newTop = inputEndForOverlap;
|
|
65
|
-
}
|
|
66
|
-
curr.top = newTop;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return new Map(positions.map((p) => [p.commentId, p.top]));
|
|
71
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { JSDOM } from "jsdom";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { renderMarkdown } from "./markdown-renderer";
|
|
4
|
-
|
|
5
|
-
const SAMPLE_MARKDOWN = `# Hello World
|
|
6
|
-
|
|
7
|
-
This is a paragraph with **bold** and *italic* text.
|
|
8
|
-
|
|
9
|
-
## Code Example
|
|
10
|
-
|
|
11
|
-
\`\`\`typescript
|
|
12
|
-
function hello() {
|
|
13
|
-
return "world";
|
|
14
|
-
}
|
|
15
|
-
\`\`\`
|
|
16
|
-
|
|
17
|
-
Some text after the code block.
|
|
18
|
-
|
|
19
|
-
- Item 1
|
|
20
|
-
- Item 2
|
|
21
|
-
- Item 3
|
|
22
|
-
|
|
23
|
-
### Table
|
|
24
|
-
|
|
25
|
-
| Name | Value |
|
|
26
|
-
|------|-------|
|
|
27
|
-
| foo | bar |
|
|
28
|
-
| baz | qux |
|
|
29
|
-
|
|
30
|
-
> A blockquote with some text.
|
|
31
|
-
|
|
32
|
-
Final paragraph.
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const SAMPLE_WITH_MERMAID = `# Diagrams
|
|
36
|
-
|
|
37
|
-
\`\`\`mermaid
|
|
38
|
-
graph TD
|
|
39
|
-
A --> B
|
|
40
|
-
\`\`\`
|
|
41
|
-
|
|
42
|
-
After mermaid.
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
describe("renderMarkdown", () => {
|
|
46
|
-
it("renders basic markdown to HTML", async () => {
|
|
47
|
-
const { html } = await renderMarkdown(SAMPLE_MARKDOWN);
|
|
48
|
-
|
|
49
|
-
expect(html).toContain("<h1");
|
|
50
|
-
expect(html).toContain("Hello World");
|
|
51
|
-
expect(html).toContain("<strong>bold</strong>");
|
|
52
|
-
expect(html).toContain("<em>italic</em>");
|
|
53
|
-
expect(html).toContain("<h2");
|
|
54
|
-
expect(html).toContain("Code Example");
|
|
55
|
-
expect(html).toContain("<h3");
|
|
56
|
-
expect(html).toContain("Table");
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("extracts headings with correct IDs", async () => {
|
|
60
|
-
const { headings } = await renderMarkdown(SAMPLE_MARKDOWN);
|
|
61
|
-
|
|
62
|
-
expect(headings).toEqual([
|
|
63
|
-
{ id: "hello-world", text: "Hello World", level: 1 },
|
|
64
|
-
{ id: "code-example", text: "Code Example", level: 2 },
|
|
65
|
-
{ id: "table", text: "Table", level: 3 },
|
|
66
|
-
]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("injects heading IDs into HTML", async () => {
|
|
70
|
-
const { html } = await renderMarkdown(SAMPLE_MARKDOWN);
|
|
71
|
-
|
|
72
|
-
expect(html).toContain('id="hello-world"');
|
|
73
|
-
expect(html).toContain('id="code-example"');
|
|
74
|
-
expect(html).toContain('id="table"');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("syntax-highlights code blocks with shiki", async () => {
|
|
78
|
-
const { html } = await renderMarkdown(SAMPLE_MARKDOWN);
|
|
79
|
-
|
|
80
|
-
expect(html).toContain("shiki");
|
|
81
|
-
expect(html).toContain("hello");
|
|
82
|
-
expect(html).toContain("world");
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("leaves mermaid blocks for client-side hydration", async () => {
|
|
86
|
-
const { html } = await renderMarkdown(SAMPLE_WITH_MERMAID);
|
|
87
|
-
|
|
88
|
-
expect(html).toContain('class="language-mermaid"');
|
|
89
|
-
expect(html).toContain("graph TD");
|
|
90
|
-
expect(html).not.toMatch(/class="shiki[^"]*"[^>]*>.*graph TD/s);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("renders GFM tables", async () => {
|
|
94
|
-
const { html } = await renderMarkdown(SAMPLE_MARKDOWN);
|
|
95
|
-
|
|
96
|
-
expect(html).toContain("<table>");
|
|
97
|
-
expect(html).toContain("<th>");
|
|
98
|
-
expect(html).toContain("foo");
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("renders lists", async () => {
|
|
102
|
-
const { html } = await renderMarkdown(SAMPLE_MARKDOWN);
|
|
103
|
-
|
|
104
|
-
expect(html).toContain("<ul>");
|
|
105
|
-
expect(html).toContain("<li>");
|
|
106
|
-
expect(html).toContain("Item 1");
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("renders blockquotes", async () => {
|
|
110
|
-
const { html } = await renderMarkdown(SAMPLE_MARKDOWN);
|
|
111
|
-
|
|
112
|
-
expect(html).toContain("<blockquote>");
|
|
113
|
-
expect(html).toContain("A blockquote with some text.");
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("handles duplicate headings", async () => {
|
|
117
|
-
const md = `## Section\n\n## Section\n\n## Section\n`;
|
|
118
|
-
const { headings } = await renderMarkdown(md);
|
|
119
|
-
|
|
120
|
-
expect(headings).toEqual([
|
|
121
|
-
{ id: "section", text: "Section", level: 2 },
|
|
122
|
-
{ id: "section-1", text: "Section", level: 2 },
|
|
123
|
-
{ id: "section-2", text: "Section", level: 2 },
|
|
124
|
-
]);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe("text offset conformance", () => {
|
|
129
|
-
it("rendered HTML has proper block structure for text offset extraction", async () => {
|
|
130
|
-
const { html } = await renderMarkdown(SAMPLE_MARKDOWN);
|
|
131
|
-
|
|
132
|
-
const dom = new JSDOM(html);
|
|
133
|
-
const doc = dom.window.document;
|
|
134
|
-
|
|
135
|
-
const paragraphs = doc.querySelectorAll("p");
|
|
136
|
-
expect(paragraphs.length).toBeGreaterThan(0);
|
|
137
|
-
|
|
138
|
-
const h1 = doc.querySelector("h1");
|
|
139
|
-
expect(h1?.id).toBe("hello-world");
|
|
140
|
-
expect(h1?.textContent).toBe("Hello World");
|
|
141
|
-
|
|
142
|
-
const pres = doc.querySelectorAll("pre");
|
|
143
|
-
expect(pres.length).toBeGreaterThan(0);
|
|
144
|
-
|
|
145
|
-
const lis = doc.querySelectorAll("li");
|
|
146
|
-
expect(lis.length).toBe(3);
|
|
147
|
-
|
|
148
|
-
const trs = doc.querySelectorAll("tr");
|
|
149
|
-
expect(trs.length).toBeGreaterThan(0);
|
|
150
|
-
|
|
151
|
-
const blockquote = doc.querySelector("blockquote");
|
|
152
|
-
expect(blockquote).not.toBeNull();
|
|
153
|
-
});
|
|
154
|
-
});
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import MarkdownIt from "markdown-it";
|
|
2
|
-
import type { BundledLanguage, BundledTheme, HighlighterGeneric } from "shiki";
|
|
3
|
-
import { type Heading, parseMarkdownHeadings } from "./headings";
|
|
4
|
-
import { renderMermaidBlocks } from "./mermaid-renderer";
|
|
5
|
-
|
|
6
|
-
const SHIKI_LANGUAGES: BundledLanguage[] = [
|
|
7
|
-
"bash",
|
|
8
|
-
"css",
|
|
9
|
-
"diff",
|
|
10
|
-
"go",
|
|
11
|
-
"graphql",
|
|
12
|
-
"javascript",
|
|
13
|
-
"json",
|
|
14
|
-
"jsx",
|
|
15
|
-
"markdown",
|
|
16
|
-
"python",
|
|
17
|
-
"rust",
|
|
18
|
-
"sql",
|
|
19
|
-
"tsx",
|
|
20
|
-
"typescript",
|
|
21
|
-
"yaml",
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
const SHIKI_THEME: BundledTheme = "one-dark-pro";
|
|
25
|
-
|
|
26
|
-
let shikiInstance: HighlighterGeneric<BundledLanguage, BundledTheme> | null =
|
|
27
|
-
null;
|
|
28
|
-
let shikiPromise: Promise<
|
|
29
|
-
HighlighterGeneric<BundledLanguage, BundledTheme>
|
|
30
|
-
> | null = null;
|
|
31
|
-
|
|
32
|
-
export async function getShiki(): Promise<
|
|
33
|
-
HighlighterGeneric<BundledLanguage, BundledTheme>
|
|
34
|
-
> {
|
|
35
|
-
if (shikiInstance) return shikiInstance;
|
|
36
|
-
if (shikiPromise) return shikiPromise;
|
|
37
|
-
|
|
38
|
-
shikiPromise = import("shiki").then(async ({ createHighlighter }) => {
|
|
39
|
-
const highlighter = await createHighlighter({
|
|
40
|
-
themes: [SHIKI_THEME],
|
|
41
|
-
langs: SHIKI_LANGUAGES,
|
|
42
|
-
});
|
|
43
|
-
shikiInstance = highlighter;
|
|
44
|
-
return highlighter;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return shikiPromise;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function createMarkdownRenderer(
|
|
51
|
-
shiki: HighlighterGeneric<BundledLanguage, BundledTheme>,
|
|
52
|
-
): MarkdownIt {
|
|
53
|
-
const md = new MarkdownIt({
|
|
54
|
-
html: true, // Allow raw HTML (matches rehype-raw behavior)
|
|
55
|
-
linkify: true,
|
|
56
|
-
typographer: false,
|
|
57
|
-
highlight(code: string, lang: string): string {
|
|
58
|
-
if (lang === "mermaid") {
|
|
59
|
-
return `<pre><code class="language-mermaid">${md.utils.escapeHtml(code)}</code></pre>`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const language = normalizeLanguage(lang);
|
|
63
|
-
|
|
64
|
-
if (language && shiki.getLoadedLanguages().includes(language)) {
|
|
65
|
-
return shiki.codeToHtml(code, {
|
|
66
|
-
lang: language,
|
|
67
|
-
theme: SHIKI_THEME,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return `<pre class="shiki"><code>${md.utils.escapeHtml(code)}</code></pre>`;
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return md;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function normalizeLanguage(lang: string): BundledLanguage | undefined {
|
|
79
|
-
const aliases: Record<string, BundledLanguage> = {
|
|
80
|
-
sh: "bash",
|
|
81
|
-
shell: "bash",
|
|
82
|
-
js: "javascript",
|
|
83
|
-
ts: "typescript",
|
|
84
|
-
py: "python",
|
|
85
|
-
rs: "rust",
|
|
86
|
-
yml: "yaml",
|
|
87
|
-
md: "markdown",
|
|
88
|
-
};
|
|
89
|
-
const normalized = lang.toLowerCase().trim();
|
|
90
|
-
if (SHIKI_LANGUAGES.includes(normalized as BundledLanguage)) {
|
|
91
|
-
return normalized as BundledLanguage;
|
|
92
|
-
}
|
|
93
|
-
return aliases[normalized];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function injectHeadingIds(html: string, headings: Heading[]): string {
|
|
97
|
-
let headingIdx = 0;
|
|
98
|
-
|
|
99
|
-
return html.replace(
|
|
100
|
-
/<(h[1-6])([^>]*)>([\s\S]*?)<\/\1>/gi,
|
|
101
|
-
(match, tag: string, attrs: string, content: string) => {
|
|
102
|
-
if (headingIdx >= headings.length) return match;
|
|
103
|
-
|
|
104
|
-
const heading = headings[headingIdx];
|
|
105
|
-
headingIdx++;
|
|
106
|
-
|
|
107
|
-
if (/\bid\s*=/.test(attrs)) return match;
|
|
108
|
-
|
|
109
|
-
return `<${tag} id="${heading.id}"${attrs}>${content}</${tag}>`;
|
|
110
|
-
},
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
interface RenderResult {
|
|
115
|
-
html: string;
|
|
116
|
-
headings: Heading[];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const MERMAID_BLOCK_RE =
|
|
120
|
-
/<pre><code class="language-mermaid">([\s\S]*?)<\/code><\/pre>/g;
|
|
121
|
-
|
|
122
|
-
function unescapeHtml(str: string): string {
|
|
123
|
-
return str
|
|
124
|
-
.replace(/&/g, "&")
|
|
125
|
-
.replace(/</g, "<")
|
|
126
|
-
.replace(/>/g, ">")
|
|
127
|
-
.replace(/"/g, '"');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async function replaceMermaidBlocks(html: string): Promise<string> {
|
|
131
|
-
MERMAID_BLOCK_RE.lastIndex = 0;
|
|
132
|
-
const matches: { fullMatch: string; code: string; index: number }[] = [];
|
|
133
|
-
|
|
134
|
-
let match: RegExpExecArray | null = MERMAID_BLOCK_RE.exec(html);
|
|
135
|
-
while (match !== null) {
|
|
136
|
-
matches.push({
|
|
137
|
-
fullMatch: match[0],
|
|
138
|
-
code: unescapeHtml(match[1]),
|
|
139
|
-
index: match.index,
|
|
140
|
-
});
|
|
141
|
-
match = MERMAID_BLOCK_RE.exec(html);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (matches.length === 0) return html;
|
|
145
|
-
|
|
146
|
-
const codes = matches.map((m) => m.code);
|
|
147
|
-
const svgs = await renderMermaidBlocks(codes);
|
|
148
|
-
|
|
149
|
-
// Replace in reverse order to preserve string indices
|
|
150
|
-
for (let i = matches.length - 1; i >= 0; i--) {
|
|
151
|
-
const svg = svgs[i];
|
|
152
|
-
if (svg !== null) {
|
|
153
|
-
const { fullMatch, index } = matches[i];
|
|
154
|
-
const replacement = `<div class="mermaid-container">${svg}</div>`;
|
|
155
|
-
html =
|
|
156
|
-
html.slice(0, index) +
|
|
157
|
-
replacement +
|
|
158
|
-
html.slice(index + fullMatch.length);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return html;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export async function renderMarkdown(content: string): Promise<RenderResult> {
|
|
166
|
-
const shiki = await getShiki();
|
|
167
|
-
const md = createMarkdownRenderer(shiki);
|
|
168
|
-
|
|
169
|
-
const headings = parseMarkdownHeadings(content);
|
|
170
|
-
|
|
171
|
-
let html = md.render(content);
|
|
172
|
-
|
|
173
|
-
html = injectHeadingIds(html, headings);
|
|
174
|
-
html = await replaceMermaidBlocks(html);
|
|
175
|
-
|
|
176
|
-
return { html, headings };
|
|
177
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export const MERMAID_THEME = {
|
|
2
|
-
fontSize: "16px",
|
|
3
|
-
primaryColor: "rgba(245, 222, 160, 0.8)",
|
|
4
|
-
primaryTextColor: "#3f3f46",
|
|
5
|
-
primaryBorderColor: "#c9a84a",
|
|
6
|
-
secondaryColor: "rgba(168, 196, 228, 0.6)",
|
|
7
|
-
secondaryTextColor: "#3f3f46",
|
|
8
|
-
secondaryBorderColor: "#5b7fa8",
|
|
9
|
-
tertiaryColor: "rgba(170, 210, 170, 0.6)",
|
|
10
|
-
tertiaryTextColor: "#3f3f46",
|
|
11
|
-
tertiaryBorderColor: "#5a9a62",
|
|
12
|
-
background: "#ffffff",
|
|
13
|
-
mainBkg: "#ffffff",
|
|
14
|
-
textColor: "#3f3f46",
|
|
15
|
-
lineColor: "#a1a1aa",
|
|
16
|
-
nodeBkg: "rgba(245, 222, 160, 0.6)",
|
|
17
|
-
nodeBorder: "#c9a84a",
|
|
18
|
-
clusterBkg: "rgba(250, 250, 250, 0.8)",
|
|
19
|
-
clusterBorder: "#e4e4e7",
|
|
20
|
-
actorBkg: "rgba(168, 196, 228, 0.5)",
|
|
21
|
-
actorBorder: "#5b7fa8",
|
|
22
|
-
actorTextColor: "#3f3f46",
|
|
23
|
-
signalColor: "#3f3f46",
|
|
24
|
-
signalTextColor: "#3f3f46",
|
|
25
|
-
noteBkgColor: "rgba(245, 222, 160, 0.5)",
|
|
26
|
-
noteBorderColor: "#c9a84a",
|
|
27
|
-
noteTextColor: "#3f3f46",
|
|
28
|
-
} as const;
|
|
29
|
-
|
|
30
|
-
export function getMermaidInitConfig() {
|
|
31
|
-
return {
|
|
32
|
-
startOnLoad: false,
|
|
33
|
-
theme: "base" as const,
|
|
34
|
-
securityLevel: "strict" as const,
|
|
35
|
-
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
36
|
-
themeVariables: MERMAID_THEME,
|
|
37
|
-
};
|
|
38
|
-
}
|