@fairyhunter13/opentui-core 0.1.91 → 0.1.94
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/3d/SpriteResourceManager.d.ts +74 -0
- package/3d/SpriteUtils.d.ts +13 -0
- package/3d/TextureUtils.d.ts +24 -0
- package/3d/ThreeRenderable.d.ts +40 -0
- package/3d/WGPURenderer.d.ts +61 -0
- package/3d/animation/ExplodingSpriteEffect.d.ts +71 -0
- package/3d/animation/PhysicsExplodingSpriteEffect.d.ts +76 -0
- package/3d/animation/SpriteAnimator.d.ts +124 -0
- package/3d/animation/SpriteParticleGenerator.d.ts +62 -0
- package/3d/canvas.d.ts +44 -0
- package/3d/index.d.ts +12 -0
- package/3d/physics/PlanckPhysicsAdapter.d.ts +19 -0
- package/3d/physics/RapierPhysicsAdapter.d.ts +19 -0
- package/3d/physics/physics-interface.d.ts +27 -0
- package/3d.d.ts +2 -0
- package/3d.js +34042 -0
- package/3d.js.map +155 -0
- package/LICENSE +21 -0
- package/NativeSpanFeed.d.ts +41 -0
- package/Renderable.d.ts +334 -0
- package/animation/Timeline.d.ts +126 -0
- package/ansi.d.ts +13 -0
- package/buffer.d.ts +107 -0
- package/console.d.ts +143 -0
- package/edit-buffer.d.ts +98 -0
- package/editor-view.d.ts +73 -0
- package/index-e6ec7apq.js +18415 -0
- package/index-e6ec7apq.js.map +64 -0
- package/index-h066zmrb.js +12619 -0
- package/index-h066zmrb.js.map +43 -0
- package/index-ynzawt3n.js +113 -0
- package/index-ynzawt3n.js.map +10 -0
- package/index.d.ts +21 -0
- package/index.js +430 -0
- package/index.js.map +9 -0
- package/lib/KeyHandler.d.ts +61 -0
- package/lib/RGBA.d.ts +25 -0
- package/lib/ascii.font.d.ts +508 -0
- package/lib/border.d.ts +49 -0
- package/lib/bunfs.d.ts +7 -0
- package/lib/clipboard.d.ts +17 -0
- package/lib/clock.d.ts +15 -0
- package/lib/data-paths.d.ts +26 -0
- package/lib/debounce.d.ts +42 -0
- package/lib/detect-links.d.ts +6 -0
- package/lib/env.d.ts +42 -0
- package/lib/extmarks-history.d.ts +17 -0
- package/lib/extmarks.d.ts +89 -0
- package/lib/hast-styled-text.d.ts +17 -0
- package/lib/index.d.ts +21 -0
- package/lib/keymapping.d.ts +25 -0
- package/lib/objects-in-viewport.d.ts +24 -0
- package/lib/output.capture.d.ts +24 -0
- package/lib/parse.keypress-kitty.d.ts +2 -0
- package/lib/parse.keypress.d.ts +26 -0
- package/lib/parse.mouse.d.ts +30 -0
- package/lib/paste.d.ts +7 -0
- package/lib/queue.d.ts +15 -0
- package/lib/renderable.validations.d.ts +12 -0
- package/lib/scroll-acceleration.d.ts +43 -0
- package/lib/selection.d.ts +63 -0
- package/lib/singleton.d.ts +7 -0
- package/lib/stdin-parser.d.ts +76 -0
- package/lib/styled-text.d.ts +63 -0
- package/lib/terminal-capability-detection.d.ts +30 -0
- package/lib/terminal-palette.d.ts +50 -0
- package/lib/tree-sitter/assets/update.d.ts +11 -0
- package/lib/tree-sitter/client.d.ts +47 -0
- package/lib/tree-sitter/default-parsers.d.ts +2 -0
- package/lib/tree-sitter/download-utils.d.ts +21 -0
- package/lib/tree-sitter/index.d.ts +8 -0
- package/lib/tree-sitter/parser.worker.d.ts +1 -0
- package/lib/tree-sitter/parsers-config.d.ts +38 -0
- package/lib/tree-sitter/resolve-ft.d.ts +2 -0
- package/lib/tree-sitter/types.d.ts +81 -0
- package/lib/tree-sitter-styled-text.d.ts +14 -0
- package/lib/validate-dir-name.d.ts +1 -0
- package/lib/yoga.options.d.ts +32 -0
- package/package.json +51 -63
- package/parser.worker.js +869 -0
- package/parser.worker.js.map +12 -0
- package/plugins/core-slot.d.ts +72 -0
- package/plugins/registry.d.ts +38 -0
- package/plugins/types.d.ts +34 -0
- package/post/filters.d.ts +105 -0
- package/renderables/ASCIIFont.d.ts +52 -0
- package/renderables/Box.d.ts +72 -0
- package/renderables/Code.d.ts +78 -0
- package/renderables/Diff.d.ts +142 -0
- package/renderables/EditBufferRenderable.d.ts +162 -0
- package/renderables/FrameBuffer.d.ts +16 -0
- package/renderables/Input.d.ts +67 -0
- package/renderables/LineNumberRenderable.d.ts +74 -0
- package/renderables/Markdown.d.ts +173 -0
- package/renderables/ScrollBar.d.ts +77 -0
- package/renderables/ScrollBox.d.ts +124 -0
- package/renderables/Select.d.ts +115 -0
- package/renderables/Slider.d.ts +44 -0
- package/renderables/TabSelect.d.ts +96 -0
- package/renderables/Text.d.ts +36 -0
- package/renderables/TextBufferRenderable.d.ts +105 -0
- package/renderables/TextNode.d.ts +91 -0
- package/renderables/TextTable.d.ts +140 -0
- package/renderables/Textarea.d.ts +114 -0
- package/renderables/TimeToFirstDraw.d.ts +24 -0
- package/renderables/__tests__/renderable-test-utils.d.ts +12 -0
- package/renderables/composition/VRenderable.d.ts +16 -0
- package/renderables/composition/constructs.d.ts +35 -0
- package/renderables/composition/vnode.d.ts +46 -0
- package/renderables/index.d.ts +22 -0
- package/renderables/markdown-parser.d.ts +10 -0
- package/renderer.d.ts +388 -0
- package/runtime-plugin-support.d.ts +3 -0
- package/runtime-plugin-support.js +29 -0
- package/runtime-plugin-support.js.map +10 -0
- package/runtime-plugin.d.ts +11 -0
- package/runtime-plugin.js +16 -0
- package/runtime-plugin.js.map +9 -0
- package/syntax-style.d.ts +54 -0
- package/testing/manual-clock.d.ts +16 -0
- package/testing/mock-keys.d.ts +81 -0
- package/testing/mock-mouse.d.ts +38 -0
- package/testing/mock-tree-sitter-client.d.ts +23 -0
- package/testing/spy.d.ts +7 -0
- package/testing/test-recorder.d.ts +61 -0
- package/testing/test-renderer.d.ts +23 -0
- package/testing.d.ts +6 -0
- package/testing.js +675 -0
- package/testing.js.map +15 -0
- package/text-buffer-view.d.ts +42 -0
- package/text-buffer.d.ts +67 -0
- package/types.d.ts +131 -0
- package/utils.d.ts +14 -0
- package/zig-structs.d.ts +155 -0
- package/zig.d.ts +351 -0
- package/dev/keypress-debug-renderer.ts +0 -148
- package/dev/keypress-debug.ts +0 -43
- package/dev/print-env-vars.ts +0 -32
- package/dev/test-tmux-graphics-334.sh +0 -68
- package/dev/thai-debug-test.ts +0 -68
- package/docs/development.md +0 -141
- package/docs/env-vars.md +0 -140
- package/docs/getting-started.md +0 -353
- package/docs/renderables-vs-constructs.md +0 -159
- package/docs/tree-sitter.md +0 -311
- package/scripts/build.ts +0 -400
- package/scripts/publish.ts +0 -60
- package/src/3d/SpriteResourceManager.ts +0 -286
- package/src/3d/SpriteUtils.ts +0 -71
- package/src/3d/TextureUtils.ts +0 -196
- package/src/3d/ThreeRenderable.ts +0 -197
- package/src/3d/WGPURenderer.ts +0 -294
- package/src/3d/animation/ExplodingSpriteEffect.ts +0 -513
- package/src/3d/animation/PhysicsExplodingSpriteEffect.ts +0 -429
- package/src/3d/animation/SpriteAnimator.ts +0 -633
- package/src/3d/animation/SpriteParticleGenerator.ts +0 -435
- package/src/3d/canvas.ts +0 -464
- package/src/3d/index.ts +0 -12
- package/src/3d/physics/PlanckPhysicsAdapter.ts +0 -72
- package/src/3d/physics/RapierPhysicsAdapter.ts +0 -66
- package/src/3d/physics/physics-interface.ts +0 -31
- package/src/3d/shaders/supersampling.wgsl +0 -201
- package/src/3d.ts +0 -3
- package/src/NativeSpanFeed.ts +0 -300
- package/src/Renderable.ts +0 -1698
- package/src/__snapshots__/buffer.test.ts.snap +0 -28
- package/src/animation/Timeline.test.ts +0 -2709
- package/src/animation/Timeline.ts +0 -598
- package/src/ansi.ts +0 -18
- package/src/benchmark/latest-all-bench-run.json +0 -707
- package/src/benchmark/latest-async-bench-run.json +0 -336
- package/src/benchmark/latest-default-bench-run.json +0 -657
- package/src/benchmark/latest-large-bench-run.json +0 -707
- package/src/benchmark/latest-quick-bench-run.json +0 -207
- package/src/benchmark/markdown-benchmark.ts +0 -1804
- package/src/benchmark/native-span-feed-async-benchmark.ts +0 -355
- package/src/benchmark/native-span-feed-benchmark.md +0 -56
- package/src/benchmark/native-span-feed-benchmark.ts +0 -596
- package/src/benchmark/native-span-feed-compare.ts +0 -280
- package/src/benchmark/renderer-benchmark.ts +0 -754
- package/src/benchmark/text-table-benchmark.ts +0 -947
- package/src/buffer.test.ts +0 -291
- package/src/buffer.ts +0 -519
- package/src/console.test.ts +0 -612
- package/src/console.ts +0 -1255
- package/src/edit-buffer.test.ts +0 -1769
- package/src/edit-buffer.ts +0 -411
- package/src/editor-view.test.ts +0 -1032
- package/src/editor-view.ts +0 -284
- package/src/examples/ascii-font-selection-demo.ts +0 -245
- package/src/examples/assets/Water_2_M_Normal.jpg +0 -0
- package/src/examples/assets/concrete.png +0 -0
- package/src/examples/assets/crate.png +0 -0
- package/src/examples/assets/crate_emissive.png +0 -0
- package/src/examples/assets/forrest_background.png +0 -0
- package/src/examples/assets/hast-example.json +0 -1018
- package/src/examples/assets/heart.png +0 -0
- package/src/examples/assets/main_char_heavy_attack.png +0 -0
- package/src/examples/assets/main_char_idle.png +0 -0
- package/src/examples/assets/main_char_jump_end.png +0 -0
- package/src/examples/assets/main_char_jump_landing.png +0 -0
- package/src/examples/assets/main_char_jump_start.png +0 -0
- package/src/examples/assets/main_char_run_loop.png +0 -0
- package/src/examples/assets/roughness_map.jpg +0 -0
- package/src/examples/build.ts +0 -115
- package/src/examples/code-demo.ts +0 -584
- package/src/examples/console-demo.ts +0 -358
- package/src/examples/core-plugin-slots-demo.ts +0 -759
- package/src/examples/diff-demo.ts +0 -699
- package/src/examples/draggable-three-demo.ts +0 -259
- package/src/examples/editor-demo.ts +0 -322
- package/src/examples/extmarks-demo.ts +0 -204
- package/src/examples/focus-restore-demo.ts +0 -310
- package/src/examples/fonts.ts +0 -245
- package/src/examples/fractal-shader-demo.ts +0 -268
- package/src/examples/framebuffer-demo.ts +0 -674
- package/src/examples/full-unicode-demo.ts +0 -181
- package/src/examples/golden-star-demo.ts +0 -933
- package/src/examples/grayscale-buffer-demo.ts +0 -249
- package/src/examples/hast-syntax-highlighting-demo.ts +0 -129
- package/src/examples/index.ts +0 -925
- package/src/examples/input-demo.ts +0 -377
- package/src/examples/input-select-layout-demo.ts +0 -425
- package/src/examples/install.sh +0 -143
- package/src/examples/keypress-debug-demo.ts +0 -452
- package/src/examples/lib/HexList.ts +0 -122
- package/src/examples/lib/PaletteGrid.ts +0 -125
- package/src/examples/lib/standalone-keys.ts +0 -25
- package/src/examples/lib/tab-controller.ts +0 -243
- package/src/examples/lights-phong-demo.ts +0 -290
- package/src/examples/link-demo.ts +0 -220
- package/src/examples/live-state-demo.ts +0 -480
- package/src/examples/markdown-demo.ts +0 -620
- package/src/examples/mouse-interaction-demo.ts +0 -428
- package/src/examples/nested-zindex-demo.ts +0 -357
- package/src/examples/opacity-example.ts +0 -235
- package/src/examples/opentui-demo.ts +0 -1057
- package/src/examples/physx-planck-2d-demo.ts +0 -507
- package/src/examples/physx-rapier-2d-demo.ts +0 -526
- package/src/examples/relative-positioning-demo.ts +0 -323
- package/src/examples/scroll-example.ts +0 -214
- package/src/examples/scrollbox-mouse-test.ts +0 -112
- package/src/examples/scrollbox-overlay-hit-test.ts +0 -206
- package/src/examples/select-demo.ts +0 -237
- package/src/examples/shader-cube-demo.ts +0 -772
- package/src/examples/simple-layout-example.ts +0 -591
- package/src/examples/slider-demo.ts +0 -617
- package/src/examples/split-mode-demo.ts +0 -445
- package/src/examples/sprite-animation-demo.ts +0 -443
- package/src/examples/sprite-particle-generator-demo.ts +0 -486
- package/src/examples/static-sprite-demo.ts +0 -193
- package/src/examples/sticky-scroll-example.ts +0 -308
- package/src/examples/styled-text-demo.ts +0 -282
- package/src/examples/tab-select-demo.ts +0 -219
- package/src/examples/terminal-title.ts +0 -29
- package/src/examples/terminal.ts +0 -305
- package/src/examples/text-node-demo.ts +0 -416
- package/src/examples/text-selection-demo.ts +0 -377
- package/src/examples/text-table-demo.ts +0 -503
- package/src/examples/text-truncation-demo.ts +0 -481
- package/src/examples/text-wrap.ts +0 -757
- package/src/examples/texture-loading-demo.ts +0 -259
- package/src/examples/timeline-example.ts +0 -670
- package/src/examples/transparency-demo.ts +0 -241
- package/src/examples/vnode-composition-demo.ts +0 -404
- package/src/index.ts +0 -22
- package/src/lib/KeyHandler.integration.test.ts +0 -292
- package/src/lib/KeyHandler.stopPropagation.test.ts +0 -289
- package/src/lib/KeyHandler.test.ts +0 -662
- package/src/lib/KeyHandler.ts +0 -222
- package/src/lib/RGBA.test.ts +0 -984
- package/src/lib/RGBA.ts +0 -204
- package/src/lib/ascii.font.ts +0 -330
- package/src/lib/border.test.ts +0 -83
- package/src/lib/border.ts +0 -168
- package/src/lib/bunfs.test.ts +0 -27
- package/src/lib/bunfs.ts +0 -18
- package/src/lib/clipboard.test.ts +0 -41
- package/src/lib/clipboard.ts +0 -47
- package/src/lib/clock.ts +0 -31
- package/src/lib/data-paths.test.ts +0 -133
- package/src/lib/data-paths.ts +0 -109
- package/src/lib/debounce.ts +0 -106
- package/src/lib/detect-links.test.ts +0 -98
- package/src/lib/detect-links.ts +0 -56
- package/src/lib/env.test.ts +0 -228
- package/src/lib/env.ts +0 -209
- package/src/lib/extmarks-history.ts +0 -51
- package/src/lib/extmarks-multiwidth.test.ts +0 -322
- package/src/lib/extmarks.test.ts +0 -3457
- package/src/lib/extmarks.ts +0 -843
- package/src/lib/fonts/block.json +0 -405
- package/src/lib/fonts/grid.json +0 -265
- package/src/lib/fonts/huge.json +0 -741
- package/src/lib/fonts/pallet.json +0 -314
- package/src/lib/fonts/shade.json +0 -591
- package/src/lib/fonts/slick.json +0 -321
- package/src/lib/fonts/tiny.json +0 -69
- package/src/lib/hast-styled-text.ts +0 -59
- package/src/lib/index.ts +0 -21
- package/src/lib/keymapping.test.ts +0 -280
- package/src/lib/keymapping.ts +0 -87
- package/src/lib/objects-in-viewport.test.ts +0 -787
- package/src/lib/objects-in-viewport.ts +0 -153
- package/src/lib/output.capture.ts +0 -58
- package/src/lib/parse.keypress-kitty.protocol.test.ts +0 -340
- package/src/lib/parse.keypress-kitty.test.ts +0 -663
- package/src/lib/parse.keypress-kitty.ts +0 -439
- package/src/lib/parse.keypress.test.ts +0 -1849
- package/src/lib/parse.keypress.ts +0 -397
- package/src/lib/parse.mouse.test.ts +0 -552
- package/src/lib/parse.mouse.ts +0 -232
- package/src/lib/paste.ts +0 -16
- package/src/lib/queue.ts +0 -65
- package/src/lib/renderable.validations.test.ts +0 -87
- package/src/lib/renderable.validations.ts +0 -83
- package/src/lib/scroll-acceleration.ts +0 -98
- package/src/lib/selection.ts +0 -240
- package/src/lib/singleton.ts +0 -28
- package/src/lib/stdin-parser.test.ts +0 -1676
- package/src/lib/stdin-parser.ts +0 -1248
- package/src/lib/styled-text.ts +0 -178
- package/src/lib/terminal-capability-detection.test.ts +0 -202
- package/src/lib/terminal-capability-detection.ts +0 -79
- package/src/lib/terminal-palette.test.ts +0 -878
- package/src/lib/terminal-palette.ts +0 -383
- package/src/lib/tree-sitter/assets/README.md +0 -118
- package/src/lib/tree-sitter/assets/update.ts +0 -331
- package/src/lib/tree-sitter/assets.d.ts +0 -9
- package/src/lib/tree-sitter/cache.test.ts +0 -270
- package/src/lib/tree-sitter/client.test.ts +0 -1061
- package/src/lib/tree-sitter/client.ts +0 -615
- package/src/lib/tree-sitter/default-parsers.ts +0 -80
- package/src/lib/tree-sitter/download-utils.ts +0 -148
- package/src/lib/tree-sitter/index.ts +0 -28
- package/src/lib/tree-sitter/parser.worker.ts +0 -1001
- package/src/lib/tree-sitter/parsers-config.ts +0 -75
- package/src/lib/tree-sitter/resolve-ft.ts +0 -62
- package/src/lib/tree-sitter/types.ts +0 -81
- package/src/lib/tree-sitter-styled-text.test.ts +0 -1253
- package/src/lib/tree-sitter-styled-text.ts +0 -306
- package/src/lib/validate-dir-name.ts +0 -55
- package/src/lib/yoga.options.test.ts +0 -628
- package/src/lib/yoga.options.ts +0 -346
- package/src/plugins/core-slot.ts +0 -579
- package/src/plugins/registry.ts +0 -377
- package/src/plugins/types.ts +0 -46
- package/src/post/filters.ts +0 -888
- package/src/renderables/ASCIIFont.ts +0 -219
- package/src/renderables/Box.test.ts +0 -160
- package/src/renderables/Box.ts +0 -295
- package/src/renderables/Code.test.ts +0 -2062
- package/src/renderables/Code.ts +0 -357
- package/src/renderables/Diff.regression.test.ts +0 -226
- package/src/renderables/Diff.test.ts +0 -3027
- package/src/renderables/Diff.ts +0 -1209
- package/src/renderables/EditBufferRenderable.ts +0 -764
- package/src/renderables/FrameBuffer.ts +0 -47
- package/src/renderables/Input.test.ts +0 -1228
- package/src/renderables/Input.ts +0 -245
- package/src/renderables/LineNumberRenderable.ts +0 -675
- package/src/renderables/Markdown.ts +0 -1106
- package/src/renderables/ScrollBar.ts +0 -422
- package/src/renderables/ScrollBox.ts +0 -883
- package/src/renderables/Select.test.ts +0 -1010
- package/src/renderables/Select.ts +0 -523
- package/src/renderables/Slider.test.ts +0 -456
- package/src/renderables/Slider.ts +0 -347
- package/src/renderables/TabSelect.test.ts +0 -197
- package/src/renderables/TabSelect.ts +0 -455
- package/src/renderables/Text.selection-buffer.test.ts +0 -123
- package/src/renderables/Text.test.ts +0 -2660
- package/src/renderables/Text.ts +0 -147
- package/src/renderables/TextBufferRenderable.ts +0 -518
- package/src/renderables/TextNode.test.ts +0 -1058
- package/src/renderables/TextNode.ts +0 -325
- package/src/renderables/TextTable.test.ts +0 -1421
- package/src/renderables/TextTable.ts +0 -1344
- package/src/renderables/Textarea.ts +0 -732
- package/src/renderables/TimeToFirstDraw.ts +0 -89
- package/src/renderables/__snapshots__/Code.test.ts.snap +0 -13
- package/src/renderables/__snapshots__/Diff.test.ts.snap +0 -785
- package/src/renderables/__snapshots__/Text.test.ts.snap +0 -421
- package/src/renderables/__snapshots__/TextTable.test.ts.snap +0 -215
- package/src/renderables/__tests__/LineNumberRenderable.scrollbox-simple.test.ts +0 -144
- package/src/renderables/__tests__/LineNumberRenderable.scrollbox.test.ts +0 -816
- package/src/renderables/__tests__/LineNumberRenderable.test.ts +0 -1787
- package/src/renderables/__tests__/LineNumberRenderable.wrapping.test.ts +0 -85
- package/src/renderables/__tests__/Markdown.test.ts +0 -2287
- package/src/renderables/__tests__/MultiRenderable.selection.test.ts +0 -87
- package/src/renderables/__tests__/Textarea.buffer.test.ts +0 -682
- package/src/renderables/__tests__/Textarea.destroyed-events.test.ts +0 -675
- package/src/renderables/__tests__/Textarea.editing.test.ts +0 -2041
- package/src/renderables/__tests__/Textarea.error-handling.test.ts +0 -35
- package/src/renderables/__tests__/Textarea.events.test.ts +0 -738
- package/src/renderables/__tests__/Textarea.highlights.test.ts +0 -590
- package/src/renderables/__tests__/Textarea.keybinding.test.ts +0 -3149
- package/src/renderables/__tests__/Textarea.paste.test.ts +0 -357
- package/src/renderables/__tests__/Textarea.rendering.test.ts +0 -1864
- package/src/renderables/__tests__/Textarea.scroll.test.ts +0 -733
- package/src/renderables/__tests__/Textarea.selection.test.ts +0 -1590
- package/src/renderables/__tests__/Textarea.stress.test.ts +0 -670
- package/src/renderables/__tests__/Textarea.undo-redo.test.ts +0 -383
- package/src/renderables/__tests__/Textarea.visual-lines.test.ts +0 -310
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.code.test.ts.snap +0 -221
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox-simple.test.ts.snap +0 -89
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox.test.ts.snap +0 -457
- package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.test.ts.snap +0 -158
- package/src/renderables/__tests__/__snapshots__/Textarea.rendering.test.ts.snap +0 -387
- package/src/renderables/__tests__/markdown-parser.test.ts +0 -217
- package/src/renderables/__tests__/renderable-test-utils.ts +0 -60
- package/src/renderables/composition/README.md +0 -8
- package/src/renderables/composition/VRenderable.ts +0 -32
- package/src/renderables/composition/constructs.ts +0 -127
- package/src/renderables/composition/vnode.ts +0 -289
- package/src/renderables/index.ts +0 -22
- package/src/renderables/markdown-parser.ts +0 -66
- package/src/renderer.ts +0 -2363
- package/src/runtime-plugin-support.ts +0 -39
- package/src/runtime-plugin.ts +0 -144
- package/src/syntax-style.test.ts +0 -841
- package/src/syntax-style.ts +0 -264
- package/src/testing/README.md +0 -210
- package/src/testing/capture-spans.test.ts +0 -194
- package/src/testing/integration.test.ts +0 -276
- package/src/testing/manual-clock.ts +0 -106
- package/src/testing/mock-keys.test.ts +0 -1356
- package/src/testing/mock-keys.ts +0 -449
- package/src/testing/mock-mouse.test.ts +0 -218
- package/src/testing/mock-mouse.ts +0 -247
- package/src/testing/mock-tree-sitter-client.ts +0 -73
- package/src/testing/spy.ts +0 -13
- package/src/testing/test-recorder.test.ts +0 -415
- package/src/testing/test-recorder.ts +0 -145
- package/src/testing/test-renderer.ts +0 -116
- package/src/testing.ts +0 -7
- package/src/tests/__snapshots__/absolute-positioning.snapshot.test.ts.snap +0 -481
- package/src/tests/__snapshots__/renderable.snapshot.test.ts.snap +0 -19
- package/src/tests/__snapshots__/scrollbox.test.ts.snap +0 -29
- package/src/tests/absolute-positioning.snapshot.test.ts +0 -638
- package/src/tests/allocator-stats.test.ts +0 -38
- package/src/tests/destroy-during-render.test.ts +0 -200
- package/src/tests/hover-cursor.test.ts +0 -98
- package/src/tests/native-span-feed-async.test.ts +0 -173
- package/src/tests/native-span-feed-close.test.ts +0 -120
- package/src/tests/native-span-feed-coverage.test.ts +0 -227
- package/src/tests/native-span-feed-edge-cases.test.ts +0 -352
- package/src/tests/native-span-feed-use-after-free.test.ts +0 -45
- package/src/tests/opacity.test.ts +0 -123
- package/src/tests/renderable.snapshot.test.ts +0 -524
- package/src/tests/renderable.test.ts +0 -1281
- package/src/tests/renderer.console-startup.test.ts +0 -65
- package/src/tests/renderer.control.test.ts +0 -364
- package/src/tests/renderer.core-slot-binding.test.ts +0 -952
- package/src/tests/renderer.cursor.test.ts +0 -26
- package/src/tests/renderer.destroy-during-render.test.ts +0 -110
- package/src/tests/renderer.focus-restore.test.ts +0 -228
- package/src/tests/renderer.focus.test.ts +0 -251
- package/src/tests/renderer.idle.test.ts +0 -219
- package/src/tests/renderer.input.test.ts +0 -2145
- package/src/tests/renderer.kitty-flags.test.ts +0 -195
- package/src/tests/renderer.mouse.test.ts +0 -1269
- package/src/tests/renderer.palette.test.ts +0 -629
- package/src/tests/renderer.selection.test.ts +0 -49
- package/src/tests/renderer.slot-registry.test.ts +0 -649
- package/src/tests/renderer.useMouse.test.ts +0 -50
- package/src/tests/runtime-plugin-support.fixture.ts +0 -11
- package/src/tests/runtime-plugin-support.test.ts +0 -28
- package/src/tests/runtime-plugin.fixture.ts +0 -40
- package/src/tests/runtime-plugin.test.ts +0 -190
- package/src/tests/scrollbox-culling-bug.test.ts +0 -114
- package/src/tests/scrollbox-hitgrid-resize.test.ts +0 -136
- package/src/tests/scrollbox-hitgrid.test.ts +0 -909
- package/src/tests/scrollbox.test.ts +0 -1530
- package/src/tests/wrap-resize-perf.test.ts +0 -229
- package/src/tests/yoga-setters.test.ts +0 -921
- package/src/text-buffer-view.test.ts +0 -705
- package/src/text-buffer-view.ts +0 -189
- package/src/text-buffer.test.ts +0 -347
- package/src/text-buffer.ts +0 -250
- package/src/types.ts +0 -152
- package/src/utils.ts +0 -88
- package/src/zig/ansi.zig +0 -268
- package/src/zig/bench/README.md +0 -50
- package/src/zig/bench/buffer-draw-text-buffer_bench.zig +0 -887
- package/src/zig/bench/edit-buffer_bench.zig +0 -476
- package/src/zig/bench/native-span-feed_bench.zig +0 -100
- package/src/zig/bench/rope-markers_bench.zig +0 -713
- package/src/zig/bench/rope_bench.zig +0 -514
- package/src/zig/bench/styled-text_bench.zig +0 -470
- package/src/zig/bench/text-buffer-coords_bench.zig +0 -362
- package/src/zig/bench/text-buffer-view_bench.zig +0 -459
- package/src/zig/bench/text-chunk-graphemes_bench.zig +0 -273
- package/src/zig/bench/utf8_bench.zig +0 -799
- package/src/zig/bench-utils.zig +0 -431
- package/src/zig/bench.zig +0 -217
- package/src/zig/buffer.zig +0 -2223
- package/src/zig/build.zig +0 -289
- package/src/zig/build.zig.zon +0 -16
- package/src/zig/edit-buffer.zig +0 -825
- package/src/zig/editor-view.zig +0 -802
- package/src/zig/event-bus.zig +0 -13
- package/src/zig/event-emitter.zig +0 -65
- package/src/zig/file-logger.zig +0 -92
- package/src/zig/grapheme.zig +0 -599
- package/src/zig/lib.zig +0 -1834
- package/src/zig/link.zig +0 -333
- package/src/zig/logger.zig +0 -43
- package/src/zig/mem-registry.zig +0 -125
- package/src/zig/native-span-feed-bench-lib.zig +0 -7
- package/src/zig/native-span-feed.zig +0 -708
- package/src/zig/renderer.zig +0 -1386
- package/src/zig/rope.zig +0 -1220
- package/src/zig/syntax-style.zig +0 -161
- package/src/zig/terminal.zig +0 -975
- package/src/zig/test.zig +0 -70
- package/src/zig/tests/README.md +0 -18
- package/src/zig/tests/buffer_test.zig +0 -2526
- package/src/zig/tests/edit-buffer-history_test.zig +0 -271
- package/src/zig/tests/edit-buffer_test.zig +0 -1689
- package/src/zig/tests/editor-view_test.zig +0 -3299
- package/src/zig/tests/event-emitter_test.zig +0 -249
- package/src/zig/tests/grapheme_test.zig +0 -1304
- package/src/zig/tests/link_test.zig +0 -190
- package/src/zig/tests/mem-registry_test.zig +0 -473
- package/src/zig/tests/memory_leak_regression_test.zig +0 -159
- package/src/zig/tests/native-span-feed_test.zig +0 -1264
- package/src/zig/tests/renderer_test.zig +0 -1010
- package/src/zig/tests/rope-nested_test.zig +0 -712
- package/src/zig/tests/rope_fuzz_test.zig +0 -238
- package/src/zig/tests/rope_test.zig +0 -2362
- package/src/zig/tests/segment-merge.test.zig +0 -148
- package/src/zig/tests/syntax-style_test.zig +0 -557
- package/src/zig/tests/terminal_test.zig +0 -719
- package/src/zig/tests/text-buffer-drawing_test.zig +0 -3237
- package/src/zig/tests/text-buffer-highlights_test.zig +0 -666
- package/src/zig/tests/text-buffer-iterators_test.zig +0 -776
- package/src/zig/tests/text-buffer-segment_test.zig +0 -320
- package/src/zig/tests/text-buffer-selection_test.zig +0 -1035
- package/src/zig/tests/text-buffer-selection_viewport_test.zig +0 -358
- package/src/zig/tests/text-buffer-view_test.zig +0 -3649
- package/src/zig/tests/text-buffer_test.zig +0 -2191
- package/src/zig/tests/unicode-width-map.zon +0 -3909
- package/src/zig/tests/utf8_no_zwj_test.zig +0 -260
- package/src/zig/tests/utf8_test.zig +0 -4057
- package/src/zig/tests/utf8_wcwidth_cursor_test.zig +0 -267
- package/src/zig/tests/utf8_wcwidth_test.zig +0 -357
- package/src/zig/tests/word-wrap-editing_test.zig +0 -498
- package/src/zig/tests/wrap-cache-perf_test.zig +0 -113
- package/src/zig/text-buffer-iterators.zig +0 -499
- package/src/zig/text-buffer-segment.zig +0 -404
- package/src/zig/text-buffer-view.zig +0 -1371
- package/src/zig/text-buffer.zig +0 -1180
- package/src/zig/utf8.zig +0 -1948
- package/src/zig/utils.zig +0 -9
- package/src/zig-structs.ts +0 -261
- package/src/zig.ts +0 -3843
- package/tsconfig.build.json +0 -22
- package/tsconfig.json +0 -28
- /package/{src/lib/tree-sitter/assets → assets}/javascript/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/javascript/tree-sitter-javascript.wasm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown/injections.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown/tree-sitter-markdown.wasm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown_inline/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/markdown_inline/tree-sitter-markdown_inline.wasm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/typescript/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/typescript/tree-sitter-typescript.wasm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/zig/highlights.scm +0 -0
- /package/{src/lib/tree-sitter/assets → assets}/zig/tree-sitter-zig.wasm +0 -0
|
@@ -1,1106 +0,0 @@
|
|
|
1
|
-
import { Renderable, type RenderableOptions } from "../Renderable.js"
|
|
2
|
-
import { type RenderContext } from "../types.js"
|
|
3
|
-
import { SyntaxStyle, type StyleDefinition } from "../syntax-style.js"
|
|
4
|
-
import type { TextChunk } from "../text-buffer.js"
|
|
5
|
-
import { createTextAttributes } from "../utils.js"
|
|
6
|
-
import type { BorderStyle } from "../lib/border.js"
|
|
7
|
-
import type { ColorInput } from "../lib/RGBA.js"
|
|
8
|
-
import { type MarkedToken, type Token, type Tokens } from "marked"
|
|
9
|
-
import { CodeRenderable, type OnChunksCallback } from "./Code.js"
|
|
10
|
-
import {
|
|
11
|
-
TextTableRenderable,
|
|
12
|
-
type TextTableCellContent,
|
|
13
|
-
type TextTableColumnFitter,
|
|
14
|
-
type TextTableColumnWidthMode,
|
|
15
|
-
type TextTableContent,
|
|
16
|
-
} from "./TextTable.js"
|
|
17
|
-
import type { TreeSitterClient } from "../lib/tree-sitter/index.js"
|
|
18
|
-
import { parseMarkdownIncremental, type ParseState } from "./markdown-parser.js"
|
|
19
|
-
import type { OptimizedBuffer } from "../buffer.js"
|
|
20
|
-
import { detectLinks } from "../lib/detect-links.js"
|
|
21
|
-
|
|
22
|
-
export interface MarkdownTableOptions {
|
|
23
|
-
/**
|
|
24
|
-
* Strategy for sizing table columns.
|
|
25
|
-
* - "content": columns fit to intrinsic content width.
|
|
26
|
-
* - "full": columns expand to fill available width.
|
|
27
|
-
*/
|
|
28
|
-
widthMode?: TextTableColumnWidthMode
|
|
29
|
-
/**
|
|
30
|
-
* Column fitting method when shrinking constrained tables.
|
|
31
|
-
*/
|
|
32
|
-
columnFitter?: TextTableColumnFitter
|
|
33
|
-
/**
|
|
34
|
-
* Wrapping strategy for table cell content.
|
|
35
|
-
*/
|
|
36
|
-
wrapMode?: "none" | "char" | "word"
|
|
37
|
-
/**
|
|
38
|
-
* Padding applied on all sides of each table cell.
|
|
39
|
-
*/
|
|
40
|
-
cellPadding?: number
|
|
41
|
-
/**
|
|
42
|
-
* Enables/disables table border rendering.
|
|
43
|
-
*/
|
|
44
|
-
borders?: boolean
|
|
45
|
-
/**
|
|
46
|
-
* Overrides outer border visibility. Defaults to `borders`.
|
|
47
|
-
*/
|
|
48
|
-
outerBorder?: boolean
|
|
49
|
-
/**
|
|
50
|
-
* Border style for markdown tables.
|
|
51
|
-
*/
|
|
52
|
-
borderStyle?: BorderStyle
|
|
53
|
-
/**
|
|
54
|
-
* Border color for markdown tables. Defaults to conceal style color.
|
|
55
|
-
*/
|
|
56
|
-
borderColor?: ColorInput
|
|
57
|
-
/**
|
|
58
|
-
* Enables/disables selection support on markdown tables.
|
|
59
|
-
*/
|
|
60
|
-
selectable?: boolean
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface MarkdownOptions extends RenderableOptions<MarkdownRenderable> {
|
|
64
|
-
content?: string
|
|
65
|
-
syntaxStyle: SyntaxStyle
|
|
66
|
-
/** Controls concealment for markdown syntax markers in markdown text blocks. */
|
|
67
|
-
conceal?: boolean
|
|
68
|
-
/** Controls concealment inside fenced code blocks rendered by CodeRenderable. */
|
|
69
|
-
concealCode?: boolean
|
|
70
|
-
treeSitterClient?: TreeSitterClient
|
|
71
|
-
/**
|
|
72
|
-
* Enable streaming mode for incremental content updates.
|
|
73
|
-
*
|
|
74
|
-
* Semantics:
|
|
75
|
-
* - The trailing markdown block stays unstable while streaming is enabled.
|
|
76
|
-
* - Tables render all rows produced by the markdown parser (including trailing rows).
|
|
77
|
-
* - Incomplete table rows are normalized by the parser and rendered with empty cells
|
|
78
|
-
* where data is missing.
|
|
79
|
-
*
|
|
80
|
-
* Expectations:
|
|
81
|
-
* - Keep this true while chunks are still being appended.
|
|
82
|
-
* - Set this to false once streaming is complete to finalize trailing token parsing.
|
|
83
|
-
*/
|
|
84
|
-
streaming?: boolean
|
|
85
|
-
/**
|
|
86
|
-
* Options for internally rendered markdown tables.
|
|
87
|
-
*/
|
|
88
|
-
tableOptions?: MarkdownTableOptions
|
|
89
|
-
/**
|
|
90
|
-
* Custom node renderer. Return a Renderable to override default rendering,
|
|
91
|
-
* or undefined/null to use default rendering.
|
|
92
|
-
*/
|
|
93
|
-
renderNode?: (token: Token, context: RenderNodeContext) => Renderable | undefined | null
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface RenderNodeContext {
|
|
97
|
-
syntaxStyle: SyntaxStyle
|
|
98
|
-
conceal: boolean
|
|
99
|
-
concealCode: boolean
|
|
100
|
-
treeSitterClient?: TreeSitterClient
|
|
101
|
-
/** Creates default renderable for this token */
|
|
102
|
-
defaultRender: () => Renderable | null
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
interface TableContentCache {
|
|
106
|
-
content: TextTableContent
|
|
107
|
-
cellKeys: Uint32Array[]
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
interface ResolvedTableRenderableOptions {
|
|
111
|
-
columnWidthMode: TextTableColumnWidthMode
|
|
112
|
-
columnFitter: TextTableColumnFitter
|
|
113
|
-
wrapMode: "none" | "char" | "word"
|
|
114
|
-
cellPadding: number
|
|
115
|
-
border: boolean
|
|
116
|
-
outerBorder: boolean
|
|
117
|
-
showBorders: boolean
|
|
118
|
-
borderStyle: BorderStyle
|
|
119
|
-
borderColor: ColorInput
|
|
120
|
-
selectable: boolean
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const TRAILING_MARKDOWN_BLOCK_BREAKS_RE = /(?:\r?\n){2,}$/
|
|
124
|
-
|
|
125
|
-
export interface BlockState {
|
|
126
|
-
token: MarkedToken
|
|
127
|
-
tokenRaw: string // Cache raw for comparison
|
|
128
|
-
renderable: Renderable
|
|
129
|
-
tableContentCache?: TableContentCache
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export type { ParseState }
|
|
133
|
-
|
|
134
|
-
export class MarkdownRenderable extends Renderable {
|
|
135
|
-
private _content: string = ""
|
|
136
|
-
private _syntaxStyle: SyntaxStyle
|
|
137
|
-
private _conceal: boolean
|
|
138
|
-
private _concealCode: boolean
|
|
139
|
-
private _treeSitterClient?: TreeSitterClient
|
|
140
|
-
private _tableOptions?: MarkdownTableOptions
|
|
141
|
-
private _renderNode?: MarkdownOptions["renderNode"]
|
|
142
|
-
|
|
143
|
-
_parseState: ParseState | null = null
|
|
144
|
-
private _streaming: boolean = false
|
|
145
|
-
_blockStates: BlockState[] = []
|
|
146
|
-
private _styleDirty: boolean = false
|
|
147
|
-
private _linkifyMarkdownChunks: OnChunksCallback = (chunks, context) =>
|
|
148
|
-
detectLinks(chunks, {
|
|
149
|
-
content: context.content,
|
|
150
|
-
highlights: context.highlights,
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
protected _contentDefaultOptions = {
|
|
154
|
-
content: "",
|
|
155
|
-
conceal: true,
|
|
156
|
-
concealCode: false,
|
|
157
|
-
streaming: false,
|
|
158
|
-
} satisfies Partial<MarkdownOptions>
|
|
159
|
-
|
|
160
|
-
constructor(ctx: RenderContext, options: MarkdownOptions) {
|
|
161
|
-
super(ctx, {
|
|
162
|
-
...options,
|
|
163
|
-
flexDirection: "column",
|
|
164
|
-
flexShrink: options.flexShrink ?? 0,
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
this._syntaxStyle = options.syntaxStyle
|
|
168
|
-
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal
|
|
169
|
-
this._concealCode = options.concealCode ?? this._contentDefaultOptions.concealCode
|
|
170
|
-
this._content = options.content ?? this._contentDefaultOptions.content
|
|
171
|
-
this._treeSitterClient = options.treeSitterClient
|
|
172
|
-
this._tableOptions = options.tableOptions
|
|
173
|
-
this._renderNode = options.renderNode
|
|
174
|
-
this._streaming = options.streaming ?? this._contentDefaultOptions.streaming
|
|
175
|
-
|
|
176
|
-
this.updateBlocks()
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
get content(): string {
|
|
180
|
-
return this._content
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
set content(value: string) {
|
|
184
|
-
if (this.isDestroyed) return
|
|
185
|
-
if (this._content !== value) {
|
|
186
|
-
this._content = value
|
|
187
|
-
this.updateBlocks()
|
|
188
|
-
this.requestRender()
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
get syntaxStyle(): SyntaxStyle {
|
|
193
|
-
return this._syntaxStyle
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
set syntaxStyle(value: SyntaxStyle) {
|
|
197
|
-
if (this._syntaxStyle !== value) {
|
|
198
|
-
this._syntaxStyle = value
|
|
199
|
-
// Mark dirty - actual re-render happens in renderSelf
|
|
200
|
-
this._styleDirty = true
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
get conceal(): boolean {
|
|
205
|
-
return this._conceal
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
set conceal(value: boolean) {
|
|
209
|
-
if (this._conceal !== value) {
|
|
210
|
-
this._conceal = value
|
|
211
|
-
// Mark dirty - actual re-render happens in renderSelf
|
|
212
|
-
this._styleDirty = true
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
get concealCode(): boolean {
|
|
217
|
-
return this._concealCode
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
set concealCode(value: boolean) {
|
|
221
|
-
if (this._concealCode !== value) {
|
|
222
|
-
this._concealCode = value
|
|
223
|
-
// Mark dirty - actual re-render happens in renderSelf
|
|
224
|
-
this._styleDirty = true
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
get streaming(): boolean {
|
|
229
|
-
return this._streaming
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
set streaming(value: boolean) {
|
|
233
|
-
if (this.isDestroyed) return
|
|
234
|
-
if (this._streaming !== value) {
|
|
235
|
-
this._streaming = value
|
|
236
|
-
this.updateBlocks(true)
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
get tableOptions(): MarkdownTableOptions | undefined {
|
|
241
|
-
return this._tableOptions
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
set tableOptions(value: MarkdownTableOptions | undefined) {
|
|
245
|
-
this._tableOptions = value
|
|
246
|
-
this.applyTableOptionsToBlocks()
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
private getStyle(group: string): StyleDefinition | undefined {
|
|
250
|
-
// The solid reconciler applies props via setters in JSX declaration order.
|
|
251
|
-
// If `content` is set before `syntaxStyle`, updateBlocks() runs before
|
|
252
|
-
// _syntaxStyle is initialized.
|
|
253
|
-
if (!this._syntaxStyle) return undefined
|
|
254
|
-
let style = this._syntaxStyle.getStyle(group)
|
|
255
|
-
if (!style && group.includes(".")) {
|
|
256
|
-
const baseName = group.split(".")[0]
|
|
257
|
-
style = this._syntaxStyle.getStyle(baseName)
|
|
258
|
-
}
|
|
259
|
-
return style
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
private createChunk(text: string, group: string, link?: { url: string }): TextChunk {
|
|
263
|
-
const style = this.getStyle(group) || this.getStyle("default")
|
|
264
|
-
return {
|
|
265
|
-
__isChunk: true,
|
|
266
|
-
text,
|
|
267
|
-
fg: style?.fg,
|
|
268
|
-
bg: style?.bg,
|
|
269
|
-
attributes: style
|
|
270
|
-
? createTextAttributes({
|
|
271
|
-
bold: style.bold,
|
|
272
|
-
italic: style.italic,
|
|
273
|
-
underline: style.underline,
|
|
274
|
-
dim: style.dim,
|
|
275
|
-
})
|
|
276
|
-
: 0,
|
|
277
|
-
link,
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
private createDefaultChunk(text: string): TextChunk {
|
|
282
|
-
return this.createChunk(text, "default")
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
private renderInlineContent(tokens: Token[], chunks: TextChunk[]): void {
|
|
286
|
-
for (const token of tokens) {
|
|
287
|
-
this.renderInlineToken(token as MarkedToken, chunks)
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
private renderInlineToken(token: MarkedToken, chunks: TextChunk[]): void {
|
|
292
|
-
switch (token.type) {
|
|
293
|
-
case "text":
|
|
294
|
-
chunks.push(this.createDefaultChunk(token.text))
|
|
295
|
-
break
|
|
296
|
-
|
|
297
|
-
case "escape":
|
|
298
|
-
chunks.push(this.createDefaultChunk(token.text))
|
|
299
|
-
break
|
|
300
|
-
|
|
301
|
-
case "codespan":
|
|
302
|
-
if (this._conceal) {
|
|
303
|
-
chunks.push(this.createChunk(token.text, "markup.raw"))
|
|
304
|
-
} else {
|
|
305
|
-
chunks.push(this.createChunk("`", "markup.raw"))
|
|
306
|
-
chunks.push(this.createChunk(token.text, "markup.raw"))
|
|
307
|
-
chunks.push(this.createChunk("`", "markup.raw"))
|
|
308
|
-
}
|
|
309
|
-
break
|
|
310
|
-
|
|
311
|
-
case "strong":
|
|
312
|
-
if (!this._conceal) {
|
|
313
|
-
chunks.push(this.createChunk("**", "markup.strong"))
|
|
314
|
-
}
|
|
315
|
-
for (const child of token.tokens) {
|
|
316
|
-
this.renderInlineTokenWithStyle(child as MarkedToken, chunks, "markup.strong")
|
|
317
|
-
}
|
|
318
|
-
if (!this._conceal) {
|
|
319
|
-
chunks.push(this.createChunk("**", "markup.strong"))
|
|
320
|
-
}
|
|
321
|
-
break
|
|
322
|
-
|
|
323
|
-
case "em":
|
|
324
|
-
if (!this._conceal) {
|
|
325
|
-
chunks.push(this.createChunk("*", "markup.italic"))
|
|
326
|
-
}
|
|
327
|
-
for (const child of token.tokens) {
|
|
328
|
-
this.renderInlineTokenWithStyle(child as MarkedToken, chunks, "markup.italic")
|
|
329
|
-
}
|
|
330
|
-
if (!this._conceal) {
|
|
331
|
-
chunks.push(this.createChunk("*", "markup.italic"))
|
|
332
|
-
}
|
|
333
|
-
break
|
|
334
|
-
|
|
335
|
-
case "del":
|
|
336
|
-
if (!this._conceal) {
|
|
337
|
-
chunks.push(this.createChunk("~~", "markup.strikethrough"))
|
|
338
|
-
}
|
|
339
|
-
for (const child of token.tokens) {
|
|
340
|
-
this.renderInlineTokenWithStyle(child as MarkedToken, chunks, "markup.strikethrough")
|
|
341
|
-
}
|
|
342
|
-
if (!this._conceal) {
|
|
343
|
-
chunks.push(this.createChunk("~~", "markup.strikethrough"))
|
|
344
|
-
}
|
|
345
|
-
break
|
|
346
|
-
|
|
347
|
-
case "link": {
|
|
348
|
-
const linkHref = { url: token.href }
|
|
349
|
-
if (this._conceal) {
|
|
350
|
-
for (const child of token.tokens) {
|
|
351
|
-
this.renderInlineTokenWithStyle(child as MarkedToken, chunks, "markup.link.label", linkHref)
|
|
352
|
-
}
|
|
353
|
-
chunks.push(this.createChunk(" (", "markup.link", linkHref))
|
|
354
|
-
chunks.push(this.createChunk(token.href, "markup.link.url", linkHref))
|
|
355
|
-
chunks.push(this.createChunk(")", "markup.link", linkHref))
|
|
356
|
-
} else {
|
|
357
|
-
chunks.push(this.createChunk("[", "markup.link", linkHref))
|
|
358
|
-
for (const child of token.tokens) {
|
|
359
|
-
this.renderInlineTokenWithStyle(child as MarkedToken, chunks, "markup.link.label", linkHref)
|
|
360
|
-
}
|
|
361
|
-
chunks.push(this.createChunk("](", "markup.link", linkHref))
|
|
362
|
-
chunks.push(this.createChunk(token.href, "markup.link.url", linkHref))
|
|
363
|
-
chunks.push(this.createChunk(")", "markup.link", linkHref))
|
|
364
|
-
}
|
|
365
|
-
break
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
case "image": {
|
|
369
|
-
const imageHref = { url: token.href }
|
|
370
|
-
if (this._conceal) {
|
|
371
|
-
chunks.push(this.createChunk(token.text || "image", "markup.link.label", imageHref))
|
|
372
|
-
} else {
|
|
373
|
-
chunks.push(this.createChunk(")
|
|
376
|
-
chunks.push(this.createChunk(token.href, "markup.link.url", imageHref))
|
|
377
|
-
chunks.push(this.createChunk(")", "markup.link", imageHref))
|
|
378
|
-
}
|
|
379
|
-
break
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
case "br":
|
|
383
|
-
chunks.push(this.createDefaultChunk("\n"))
|
|
384
|
-
break
|
|
385
|
-
|
|
386
|
-
default:
|
|
387
|
-
if ("tokens" in token && Array.isArray(token.tokens)) {
|
|
388
|
-
this.renderInlineContent(token.tokens, chunks)
|
|
389
|
-
} else if ("text" in token && typeof token.text === "string") {
|
|
390
|
-
chunks.push(this.createDefaultChunk(token.text))
|
|
391
|
-
}
|
|
392
|
-
break
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
private renderInlineTokenWithStyle(
|
|
397
|
-
token: MarkedToken,
|
|
398
|
-
chunks: TextChunk[],
|
|
399
|
-
styleGroup: string,
|
|
400
|
-
link?: { url: string },
|
|
401
|
-
): void {
|
|
402
|
-
switch (token.type) {
|
|
403
|
-
case "text":
|
|
404
|
-
chunks.push(this.createChunk(token.text, styleGroup, link))
|
|
405
|
-
break
|
|
406
|
-
|
|
407
|
-
case "escape":
|
|
408
|
-
chunks.push(this.createChunk(token.text, styleGroup, link))
|
|
409
|
-
break
|
|
410
|
-
|
|
411
|
-
case "codespan":
|
|
412
|
-
if (this._conceal) {
|
|
413
|
-
chunks.push(this.createChunk(token.text, "markup.raw", link))
|
|
414
|
-
} else {
|
|
415
|
-
chunks.push(this.createChunk("`", "markup.raw", link))
|
|
416
|
-
chunks.push(this.createChunk(token.text, "markup.raw", link))
|
|
417
|
-
chunks.push(this.createChunk("`", "markup.raw", link))
|
|
418
|
-
}
|
|
419
|
-
break
|
|
420
|
-
|
|
421
|
-
default:
|
|
422
|
-
this.renderInlineToken(token, chunks)
|
|
423
|
-
break
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
private createMarkdownCodeRenderable(content: string, id: string, marginBottom: number = 0): CodeRenderable {
|
|
428
|
-
return new CodeRenderable(this.ctx, {
|
|
429
|
-
id,
|
|
430
|
-
content,
|
|
431
|
-
filetype: "markdown",
|
|
432
|
-
syntaxStyle: this._syntaxStyle,
|
|
433
|
-
conceal: this._conceal,
|
|
434
|
-
drawUnstyledText: false,
|
|
435
|
-
streaming: true,
|
|
436
|
-
onChunks: this._linkifyMarkdownChunks,
|
|
437
|
-
treeSitterClient: this._treeSitterClient,
|
|
438
|
-
width: "100%",
|
|
439
|
-
marginBottom,
|
|
440
|
-
})
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
private createCodeRenderable(token: Tokens.Code, id: string, marginBottom: number = 0): Renderable {
|
|
444
|
-
return new CodeRenderable(this.ctx, {
|
|
445
|
-
id,
|
|
446
|
-
content: token.text,
|
|
447
|
-
filetype: token.lang || undefined,
|
|
448
|
-
syntaxStyle: this._syntaxStyle,
|
|
449
|
-
conceal: this._concealCode,
|
|
450
|
-
drawUnstyledText: !(this._streaming && this._concealCode),
|
|
451
|
-
streaming: this._streaming,
|
|
452
|
-
treeSitterClient: this._treeSitterClient,
|
|
453
|
-
width: "100%",
|
|
454
|
-
marginBottom,
|
|
455
|
-
})
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
private applyMarkdownCodeRenderable(renderable: CodeRenderable, content: string, marginBottom: number): void {
|
|
459
|
-
renderable.content = content
|
|
460
|
-
renderable.filetype = "markdown"
|
|
461
|
-
renderable.syntaxStyle = this._syntaxStyle
|
|
462
|
-
renderable.conceal = this._conceal
|
|
463
|
-
renderable.drawUnstyledText = false
|
|
464
|
-
renderable.streaming = true
|
|
465
|
-
renderable.marginBottom = marginBottom
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
private applyCodeBlockRenderable(renderable: CodeRenderable, token: Tokens.Code, marginBottom: number): void {
|
|
469
|
-
renderable.content = token.text
|
|
470
|
-
renderable.filetype = token.lang || undefined
|
|
471
|
-
renderable.syntaxStyle = this._syntaxStyle
|
|
472
|
-
renderable.conceal = this._concealCode
|
|
473
|
-
renderable.drawUnstyledText = !(this._streaming && this._concealCode)
|
|
474
|
-
renderable.streaming = this._streaming
|
|
475
|
-
renderable.marginBottom = marginBottom
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
private shouldRenderSeparately(token: MarkedToken): boolean {
|
|
479
|
-
return token.type === "code" || token.type === "table" || token.type === "blockquote"
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
private getInterBlockMargin(token: MarkedToken, hasNextToken: boolean): number {
|
|
483
|
-
if (!hasNextToken) return 0
|
|
484
|
-
return this.shouldRenderSeparately(token) ? 1 : 0
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
private createMarkdownBlockToken(raw: string): MarkedToken {
|
|
488
|
-
return {
|
|
489
|
-
type: "paragraph",
|
|
490
|
-
raw,
|
|
491
|
-
text: raw,
|
|
492
|
-
tokens: [],
|
|
493
|
-
} as MarkedToken
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
private normalizeMarkdownBlockRaw(raw: string): string {
|
|
497
|
-
return raw.replace(TRAILING_MARKDOWN_BLOCK_BREAKS_RE, "\n")
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
private buildRenderableTokens(tokens: MarkedToken[]): MarkedToken[] {
|
|
501
|
-
if (this._renderNode) {
|
|
502
|
-
return tokens.filter((token) => token.type !== "space")
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
const renderTokens: MarkedToken[] = []
|
|
506
|
-
let markdownRaw = ""
|
|
507
|
-
|
|
508
|
-
const flushMarkdownRaw = (): void => {
|
|
509
|
-
if (markdownRaw.length === 0) return
|
|
510
|
-
const normalizedRaw = this.normalizeMarkdownBlockRaw(markdownRaw)
|
|
511
|
-
if (normalizedRaw.length > 0) {
|
|
512
|
-
renderTokens.push(this.createMarkdownBlockToken(normalizedRaw))
|
|
513
|
-
}
|
|
514
|
-
markdownRaw = ""
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
for (let i = 0; i < tokens.length; i += 1) {
|
|
518
|
-
const token = tokens[i]
|
|
519
|
-
|
|
520
|
-
if (token.type === "space") {
|
|
521
|
-
if (markdownRaw.length === 0) {
|
|
522
|
-
continue
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
let nextIndex = i + 1
|
|
526
|
-
while (nextIndex < tokens.length && tokens[nextIndex].type === "space") {
|
|
527
|
-
nextIndex += 1
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
const nextToken = tokens[nextIndex]
|
|
531
|
-
if (nextToken && !this.shouldRenderSeparately(nextToken)) {
|
|
532
|
-
markdownRaw += token.raw
|
|
533
|
-
}
|
|
534
|
-
continue
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
if (this.shouldRenderSeparately(token)) {
|
|
538
|
-
flushMarkdownRaw()
|
|
539
|
-
renderTokens.push(token)
|
|
540
|
-
continue
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
markdownRaw += token.raw
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
flushMarkdownRaw()
|
|
547
|
-
|
|
548
|
-
return renderTokens
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
private getTableRowsToRender(table: Tokens.Table): Tokens.TableCell[][] {
|
|
552
|
-
return table.rows
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
private hashString(value: string, seed: number): number {
|
|
556
|
-
let hash = seed >>> 0
|
|
557
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
558
|
-
hash ^= value.charCodeAt(i)
|
|
559
|
-
hash = Math.imul(hash, 16777619)
|
|
560
|
-
}
|
|
561
|
-
return hash >>> 0
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
private hashTableToken(token: MarkedToken, seed: number, depth: number = 0): number {
|
|
565
|
-
let hash = this.hashString(token.type, seed)
|
|
566
|
-
|
|
567
|
-
if ("raw" in token && typeof token.raw === "string") {
|
|
568
|
-
return this.hashString(token.raw, hash)
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
if ("text" in token && typeof token.text === "string") {
|
|
572
|
-
hash = this.hashString(token.text, hash)
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
if (depth < 2 && "tokens" in token && Array.isArray(token.tokens)) {
|
|
576
|
-
for (const child of token.tokens) {
|
|
577
|
-
hash = this.hashTableToken(child as MarkedToken, hash, depth + 1)
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
return hash >>> 0
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
private getTableCellKey(cell: Tokens.TableCell | undefined, isHeader: boolean): number {
|
|
585
|
-
const seed = isHeader ? 2902232141 : 1371922141
|
|
586
|
-
if (!cell) {
|
|
587
|
-
return seed
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
if (typeof cell.text === "string") {
|
|
591
|
-
return this.hashString(cell.text, seed)
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
if (Array.isArray(cell.tokens) && cell.tokens.length > 0) {
|
|
595
|
-
let hash = seed ^ cell.tokens.length
|
|
596
|
-
for (const token of cell.tokens) {
|
|
597
|
-
hash = this.hashTableToken(token as MarkedToken, hash)
|
|
598
|
-
}
|
|
599
|
-
return hash >>> 0
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
return (seed ^ 2654435769) >>> 0
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
private createTableDataCellChunks(cell: Tokens.TableCell | undefined): TextChunk[] {
|
|
606
|
-
const chunks: TextChunk[] = []
|
|
607
|
-
if (cell) {
|
|
608
|
-
this.renderInlineContent(cell.tokens, chunks)
|
|
609
|
-
}
|
|
610
|
-
return chunks.length > 0 ? chunks : [this.createDefaultChunk(" ")]
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
private createTableHeaderCellChunks(cell: Tokens.TableCell): TextChunk[] {
|
|
614
|
-
const chunks: TextChunk[] = []
|
|
615
|
-
this.renderInlineContent(cell.tokens, chunks)
|
|
616
|
-
|
|
617
|
-
const baseChunks = chunks.length > 0 ? chunks : [this.createDefaultChunk(" ")]
|
|
618
|
-
const headingStyle = this.getStyle("markup.heading") || this.getStyle("default")
|
|
619
|
-
if (!headingStyle) {
|
|
620
|
-
return baseChunks
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
const headingAttributes = createTextAttributes({
|
|
624
|
-
bold: headingStyle.bold,
|
|
625
|
-
italic: headingStyle.italic,
|
|
626
|
-
underline: headingStyle.underline,
|
|
627
|
-
dim: headingStyle.dim,
|
|
628
|
-
})
|
|
629
|
-
|
|
630
|
-
return baseChunks.map((chunk) => ({
|
|
631
|
-
...chunk,
|
|
632
|
-
fg: headingStyle.fg ?? chunk.fg,
|
|
633
|
-
bg: headingStyle.bg ?? chunk.bg,
|
|
634
|
-
attributes: headingAttributes,
|
|
635
|
-
}))
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
private buildTableContentCache(
|
|
639
|
-
table: Tokens.Table,
|
|
640
|
-
previous?: TableContentCache,
|
|
641
|
-
forceRegenerate: boolean = false,
|
|
642
|
-
): { cache: TableContentCache | null; changed: boolean } {
|
|
643
|
-
const colCount = table.header.length
|
|
644
|
-
const rowsToRender = this.getTableRowsToRender(table)
|
|
645
|
-
if (colCount === 0 || rowsToRender.length === 0) {
|
|
646
|
-
return { cache: null, changed: previous !== undefined }
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
const content: TextTableContent = []
|
|
650
|
-
const cellKeys: Uint32Array[] = []
|
|
651
|
-
const totalRows = rowsToRender.length + 1
|
|
652
|
-
|
|
653
|
-
let changed = forceRegenerate || !previous
|
|
654
|
-
|
|
655
|
-
for (let rowIndex = 0; rowIndex < totalRows; rowIndex += 1) {
|
|
656
|
-
const rowContent: TextTableCellContent[] = []
|
|
657
|
-
const rowKeys = new Uint32Array(colCount)
|
|
658
|
-
|
|
659
|
-
for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
|
|
660
|
-
const isHeader = rowIndex === 0
|
|
661
|
-
const cell = isHeader ? table.header[colIndex] : rowsToRender[rowIndex - 1]?.[colIndex]
|
|
662
|
-
const cellKey = this.getTableCellKey(cell, isHeader)
|
|
663
|
-
rowKeys[colIndex] = cellKey
|
|
664
|
-
|
|
665
|
-
const previousCellKey = previous?.cellKeys[rowIndex]?.[colIndex]
|
|
666
|
-
const previousCellContent = previous?.content[rowIndex]?.[colIndex]
|
|
667
|
-
|
|
668
|
-
if (!forceRegenerate && previousCellKey === cellKey && Array.isArray(previousCellContent)) {
|
|
669
|
-
rowContent.push(previousCellContent)
|
|
670
|
-
continue
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
changed = true
|
|
674
|
-
rowContent.push(
|
|
675
|
-
isHeader ? this.createTableHeaderCellChunks(table.header[colIndex]) : this.createTableDataCellChunks(cell),
|
|
676
|
-
)
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
content.push(rowContent)
|
|
680
|
-
cellKeys.push(rowKeys)
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
if (previous && !changed) {
|
|
684
|
-
if (previous.content.length !== content.length) {
|
|
685
|
-
changed = true
|
|
686
|
-
} else {
|
|
687
|
-
for (let rowIndex = 0; rowIndex < content.length; rowIndex += 1) {
|
|
688
|
-
if ((previous.content[rowIndex]?.length ?? 0) !== content[rowIndex].length) {
|
|
689
|
-
changed = true
|
|
690
|
-
break
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
return {
|
|
697
|
-
cache: {
|
|
698
|
-
content,
|
|
699
|
-
cellKeys,
|
|
700
|
-
},
|
|
701
|
-
changed,
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
private resolveTableRenderableOptions(): ResolvedTableRenderableOptions {
|
|
706
|
-
const borders = this._tableOptions?.borders ?? true
|
|
707
|
-
|
|
708
|
-
return {
|
|
709
|
-
columnWidthMode: this._tableOptions?.widthMode ?? "full",
|
|
710
|
-
columnFitter: this._tableOptions?.columnFitter ?? "proportional",
|
|
711
|
-
wrapMode: this._tableOptions?.wrapMode ?? "word",
|
|
712
|
-
cellPadding: this._tableOptions?.cellPadding ?? 0,
|
|
713
|
-
border: borders,
|
|
714
|
-
outerBorder: this._tableOptions?.outerBorder ?? borders,
|
|
715
|
-
showBorders: borders,
|
|
716
|
-
borderStyle: this._tableOptions?.borderStyle ?? "single",
|
|
717
|
-
borderColor: this._tableOptions?.borderColor ?? this.getStyle("conceal")?.fg ?? "#888888",
|
|
718
|
-
selectable: this._tableOptions?.selectable ?? true,
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
private applyTableRenderableOptions(
|
|
723
|
-
tableRenderable: TextTableRenderable,
|
|
724
|
-
options: ResolvedTableRenderableOptions,
|
|
725
|
-
): void {
|
|
726
|
-
tableRenderable.columnWidthMode = options.columnWidthMode
|
|
727
|
-
tableRenderable.columnFitter = options.columnFitter
|
|
728
|
-
tableRenderable.wrapMode = options.wrapMode
|
|
729
|
-
tableRenderable.cellPadding = options.cellPadding
|
|
730
|
-
tableRenderable.border = options.border
|
|
731
|
-
tableRenderable.outerBorder = options.outerBorder
|
|
732
|
-
tableRenderable.showBorders = options.showBorders
|
|
733
|
-
tableRenderable.borderStyle = options.borderStyle
|
|
734
|
-
tableRenderable.borderColor = options.borderColor
|
|
735
|
-
tableRenderable.selectable = options.selectable
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
private applyTableOptionsToBlocks(): void {
|
|
739
|
-
const options = this.resolveTableRenderableOptions()
|
|
740
|
-
let updated = false
|
|
741
|
-
|
|
742
|
-
for (const state of this._blockStates) {
|
|
743
|
-
if (state.renderable instanceof TextTableRenderable) {
|
|
744
|
-
this.applyTableRenderableOptions(state.renderable, options)
|
|
745
|
-
updated = true
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
if (updated) {
|
|
750
|
-
this.requestRender()
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
private createTextTableRenderable(
|
|
755
|
-
content: TextTableContent,
|
|
756
|
-
id: string,
|
|
757
|
-
marginBottom: number = 0,
|
|
758
|
-
): TextTableRenderable {
|
|
759
|
-
const options = this.resolveTableRenderableOptions()
|
|
760
|
-
return new TextTableRenderable(this.ctx, {
|
|
761
|
-
id,
|
|
762
|
-
content,
|
|
763
|
-
width: "100%",
|
|
764
|
-
marginBottom,
|
|
765
|
-
columnWidthMode: options.columnWidthMode,
|
|
766
|
-
columnFitter: options.columnFitter,
|
|
767
|
-
wrapMode: options.wrapMode,
|
|
768
|
-
cellPadding: options.cellPadding,
|
|
769
|
-
border: options.border,
|
|
770
|
-
outerBorder: options.outerBorder,
|
|
771
|
-
showBorders: options.showBorders,
|
|
772
|
-
borderStyle: options.borderStyle,
|
|
773
|
-
borderColor: options.borderColor,
|
|
774
|
-
selectable: options.selectable,
|
|
775
|
-
})
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
private createTableBlock(
|
|
779
|
-
table: Tokens.Table,
|
|
780
|
-
id: string,
|
|
781
|
-
marginBottom: number = 0,
|
|
782
|
-
previousCache?: TableContentCache,
|
|
783
|
-
forceRegenerate: boolean = false,
|
|
784
|
-
): { renderable: Renderable; tableContentCache?: TableContentCache } {
|
|
785
|
-
const { cache } = this.buildTableContentCache(table, previousCache, forceRegenerate)
|
|
786
|
-
|
|
787
|
-
if (!cache) {
|
|
788
|
-
return {
|
|
789
|
-
renderable: this.createMarkdownCodeRenderable(table.raw, id, marginBottom),
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
return {
|
|
794
|
-
renderable: this.createTextTableRenderable(cache.content, id, marginBottom),
|
|
795
|
-
tableContentCache: cache,
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
private createDefaultRenderable(token: MarkedToken, index: number, hasNextToken: boolean = false): Renderable | null {
|
|
800
|
-
const id = `${this.id}-block-${index}`
|
|
801
|
-
const marginBottom = this.getInterBlockMargin(token, hasNextToken)
|
|
802
|
-
|
|
803
|
-
if (token.type === "code") {
|
|
804
|
-
return this.createCodeRenderable(token, id, marginBottom)
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
if (token.type === "table") {
|
|
808
|
-
return this.createTableBlock(token, id, marginBottom).renderable
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
if (token.type === "space") {
|
|
812
|
-
return null
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
if (!token.raw) {
|
|
816
|
-
return null
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
return this.createMarkdownCodeRenderable(token.raw, id, marginBottom)
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
private updateBlockRenderable(state: BlockState, token: MarkedToken, index: number, hasNextToken: boolean): void {
|
|
823
|
-
const marginBottom = this.getInterBlockMargin(token, hasNextToken)
|
|
824
|
-
|
|
825
|
-
if (token.type === "code") {
|
|
826
|
-
this.applyCodeBlockRenderable(state.renderable as CodeRenderable, token as Tokens.Code, marginBottom)
|
|
827
|
-
return
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
if (token.type === "table") {
|
|
831
|
-
const tableToken = token as Tokens.Table
|
|
832
|
-
const { cache, changed } = this.buildTableContentCache(tableToken, state.tableContentCache)
|
|
833
|
-
|
|
834
|
-
if (!cache) {
|
|
835
|
-
if (state.renderable instanceof CodeRenderable) {
|
|
836
|
-
this.applyMarkdownCodeRenderable(state.renderable, tableToken.raw, marginBottom)
|
|
837
|
-
state.tableContentCache = undefined
|
|
838
|
-
return
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
state.renderable.destroyRecursively()
|
|
842
|
-
const fallbackRenderable = this.createMarkdownCodeRenderable(
|
|
843
|
-
tableToken.raw,
|
|
844
|
-
`${this.id}-block-${index}`,
|
|
845
|
-
marginBottom,
|
|
846
|
-
)
|
|
847
|
-
this.add(fallbackRenderable)
|
|
848
|
-
state.renderable = fallbackRenderable
|
|
849
|
-
state.tableContentCache = undefined
|
|
850
|
-
return
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
if (state.renderable instanceof TextTableRenderable) {
|
|
854
|
-
if (changed) {
|
|
855
|
-
state.renderable.content = cache.content
|
|
856
|
-
}
|
|
857
|
-
this.applyTableRenderableOptions(state.renderable, this.resolveTableRenderableOptions())
|
|
858
|
-
state.renderable.marginBottom = marginBottom
|
|
859
|
-
state.tableContentCache = cache
|
|
860
|
-
return
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
state.renderable.destroyRecursively()
|
|
864
|
-
const tableRenderable = this.createTextTableRenderable(cache.content, `${this.id}-block-${index}`, marginBottom)
|
|
865
|
-
this.add(tableRenderable)
|
|
866
|
-
state.renderable = tableRenderable
|
|
867
|
-
state.tableContentCache = cache
|
|
868
|
-
return
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
if (state.renderable instanceof CodeRenderable) {
|
|
872
|
-
this.applyMarkdownCodeRenderable(state.renderable, token.raw, marginBottom)
|
|
873
|
-
return
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
state.renderable.destroyRecursively()
|
|
877
|
-
const markdownRenderable = this.createMarkdownCodeRenderable(token.raw, `${this.id}-block-${index}`, marginBottom)
|
|
878
|
-
this.add(markdownRenderable)
|
|
879
|
-
state.renderable = markdownRenderable
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
private updateBlocks(forceTableRefresh: boolean = false): void {
|
|
883
|
-
if (this.isDestroyed) return
|
|
884
|
-
if (!this._content) {
|
|
885
|
-
this.clearBlockStates()
|
|
886
|
-
this._parseState = null
|
|
887
|
-
return
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
const trailingUnstable = this._streaming ? 2 : 0
|
|
891
|
-
this._parseState = parseMarkdownIncremental(this._content, this._parseState, trailingUnstable)
|
|
892
|
-
|
|
893
|
-
const tokens = this._parseState.tokens
|
|
894
|
-
|
|
895
|
-
// Parse failure fallback
|
|
896
|
-
if (tokens.length === 0 && this._content.length > 0) {
|
|
897
|
-
this.clearBlockStates()
|
|
898
|
-
const fallback = this.createMarkdownCodeRenderable(this._content, `${this.id}-fallback`)
|
|
899
|
-
this.add(fallback)
|
|
900
|
-
this._blockStates = [
|
|
901
|
-
{
|
|
902
|
-
token: { type: "text", raw: this._content, text: this._content } as MarkedToken,
|
|
903
|
-
tokenRaw: this._content,
|
|
904
|
-
renderable: fallback,
|
|
905
|
-
},
|
|
906
|
-
]
|
|
907
|
-
return
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
const blockTokens = this.buildRenderableTokens(tokens)
|
|
911
|
-
const lastBlockIndex = blockTokens.length - 1
|
|
912
|
-
|
|
913
|
-
let blockIndex = 0
|
|
914
|
-
for (let i = 0; i < blockTokens.length; i++) {
|
|
915
|
-
const token = blockTokens[i]
|
|
916
|
-
const hasNextToken = i < lastBlockIndex
|
|
917
|
-
const existing = this._blockStates[blockIndex]
|
|
918
|
-
|
|
919
|
-
const shouldForceRefresh = forceTableRefresh
|
|
920
|
-
|
|
921
|
-
// Same token object reference means unchanged
|
|
922
|
-
if (existing && existing.token === token) {
|
|
923
|
-
if (shouldForceRefresh) {
|
|
924
|
-
this.updateBlockRenderable(existing, token, blockIndex, hasNextToken)
|
|
925
|
-
existing.tokenRaw = token.raw
|
|
926
|
-
}
|
|
927
|
-
blockIndex++
|
|
928
|
-
continue
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
// Same content, update reference
|
|
932
|
-
if (existing && existing.tokenRaw === token.raw && existing.token.type === token.type) {
|
|
933
|
-
existing.token = token
|
|
934
|
-
if (shouldForceRefresh) {
|
|
935
|
-
this.updateBlockRenderable(existing, token, blockIndex, hasNextToken)
|
|
936
|
-
existing.tokenRaw = token.raw
|
|
937
|
-
}
|
|
938
|
-
blockIndex++
|
|
939
|
-
continue
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
// Same type, different content - update in place
|
|
943
|
-
if (existing && existing.token.type === token.type) {
|
|
944
|
-
this.updateBlockRenderable(existing, token, blockIndex, hasNextToken)
|
|
945
|
-
existing.token = token
|
|
946
|
-
existing.tokenRaw = token.raw
|
|
947
|
-
blockIndex++
|
|
948
|
-
continue
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
// Different type or new block
|
|
952
|
-
if (existing) {
|
|
953
|
-
existing.renderable.destroyRecursively()
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
let renderable: Renderable | undefined
|
|
957
|
-
let tableContentCache: TableContentCache | undefined
|
|
958
|
-
|
|
959
|
-
if (this._renderNode) {
|
|
960
|
-
const context: RenderNodeContext = {
|
|
961
|
-
syntaxStyle: this._syntaxStyle,
|
|
962
|
-
conceal: this._conceal,
|
|
963
|
-
concealCode: this._concealCode,
|
|
964
|
-
treeSitterClient: this._treeSitterClient,
|
|
965
|
-
defaultRender: () => this.createDefaultRenderable(token, blockIndex, hasNextToken),
|
|
966
|
-
}
|
|
967
|
-
const custom = this._renderNode(token, context)
|
|
968
|
-
if (custom) {
|
|
969
|
-
renderable = custom
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
if (!renderable) {
|
|
974
|
-
if (token.type === "table") {
|
|
975
|
-
const tableBlock = this.createTableBlock(
|
|
976
|
-
token,
|
|
977
|
-
`${this.id}-block-${blockIndex}`,
|
|
978
|
-
this.getInterBlockMargin(token, hasNextToken),
|
|
979
|
-
)
|
|
980
|
-
renderable = tableBlock.renderable
|
|
981
|
-
tableContentCache = tableBlock.tableContentCache
|
|
982
|
-
} else {
|
|
983
|
-
renderable = this.createDefaultRenderable(token, blockIndex, hasNextToken) ?? undefined
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
if (token.type === "table" && !tableContentCache && renderable instanceof TextTableRenderable) {
|
|
988
|
-
const { cache } = this.buildTableContentCache(token as Tokens.Table)
|
|
989
|
-
tableContentCache = cache ?? undefined
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
if (renderable) {
|
|
993
|
-
this.add(renderable)
|
|
994
|
-
this._blockStates[blockIndex] = {
|
|
995
|
-
token,
|
|
996
|
-
tokenRaw: token.raw,
|
|
997
|
-
renderable,
|
|
998
|
-
tableContentCache,
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
blockIndex++
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
while (this._blockStates.length > blockIndex) {
|
|
1005
|
-
const removed = this._blockStates.pop()!
|
|
1006
|
-
removed.renderable.destroyRecursively()
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
private clearBlockStates(): void {
|
|
1011
|
-
for (const state of this._blockStates) {
|
|
1012
|
-
state.renderable.destroyRecursively()
|
|
1013
|
-
}
|
|
1014
|
-
this._blockStates = []
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
/**
|
|
1018
|
-
* Re-render existing blocks without rebuilding the parse state or block structure.
|
|
1019
|
-
* Used when only style/conceal changes - much faster than full rebuild.
|
|
1020
|
-
*/
|
|
1021
|
-
private rerenderBlocks(): void {
|
|
1022
|
-
for (let i = 0; i < this._blockStates.length; i++) {
|
|
1023
|
-
const state = this._blockStates[i]
|
|
1024
|
-
const hasNextToken = i < this._blockStates.length - 1
|
|
1025
|
-
const marginBottom = this.getInterBlockMargin(state.token, hasNextToken)
|
|
1026
|
-
|
|
1027
|
-
if (state.token.type === "code") {
|
|
1028
|
-
this.applyCodeBlockRenderable(state.renderable as CodeRenderable, state.token as Tokens.Code, marginBottom)
|
|
1029
|
-
continue
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
if (state.token.type === "table") {
|
|
1033
|
-
const tableToken = state.token as Tokens.Table
|
|
1034
|
-
const { cache } = this.buildTableContentCache(tableToken, state.tableContentCache, true)
|
|
1035
|
-
|
|
1036
|
-
if (!cache) {
|
|
1037
|
-
if (state.renderable instanceof CodeRenderable) {
|
|
1038
|
-
this.applyMarkdownCodeRenderable(state.renderable, tableToken.raw, marginBottom)
|
|
1039
|
-
} else {
|
|
1040
|
-
state.renderable.destroyRecursively()
|
|
1041
|
-
const fallbackRenderable = this.createMarkdownCodeRenderable(
|
|
1042
|
-
tableToken.raw,
|
|
1043
|
-
`${this.id}-block-${i}`,
|
|
1044
|
-
marginBottom,
|
|
1045
|
-
)
|
|
1046
|
-
this.add(fallbackRenderable)
|
|
1047
|
-
state.renderable = fallbackRenderable
|
|
1048
|
-
}
|
|
1049
|
-
state.tableContentCache = undefined
|
|
1050
|
-
continue
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
if (state.renderable instanceof TextTableRenderable) {
|
|
1054
|
-
state.renderable.content = cache.content
|
|
1055
|
-
this.applyTableRenderableOptions(state.renderable, this.resolveTableRenderableOptions())
|
|
1056
|
-
state.renderable.marginBottom = marginBottom
|
|
1057
|
-
state.tableContentCache = cache
|
|
1058
|
-
continue
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
state.renderable.destroyRecursively()
|
|
1062
|
-
const tableRenderable = this.createTextTableRenderable(cache.content, `${this.id}-block-${i}`, marginBottom)
|
|
1063
|
-
this.add(tableRenderable)
|
|
1064
|
-
state.renderable = tableRenderable
|
|
1065
|
-
state.tableContentCache = cache
|
|
1066
|
-
continue
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
if (state.renderable instanceof CodeRenderable) {
|
|
1070
|
-
this.applyMarkdownCodeRenderable(state.renderable, state.token.raw, marginBottom)
|
|
1071
|
-
continue
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
state.renderable.destroyRecursively()
|
|
1075
|
-
const markdownRenderable = this.createMarkdownCodeRenderable(
|
|
1076
|
-
state.token.raw,
|
|
1077
|
-
`${this.id}-block-${i}`,
|
|
1078
|
-
marginBottom,
|
|
1079
|
-
)
|
|
1080
|
-
this.add(markdownRenderable)
|
|
1081
|
-
state.renderable = markdownRenderable
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
public clearCache(): void {
|
|
1086
|
-
this._parseState = null
|
|
1087
|
-
this.clearBlockStates()
|
|
1088
|
-
this.updateBlocks()
|
|
1089
|
-
this.requestRender()
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
public refreshStyles(): void {
|
|
1093
|
-
this._styleDirty = false
|
|
1094
|
-
this.rerenderBlocks()
|
|
1095
|
-
this.requestRender()
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
protected override renderSelf(buffer: OptimizedBuffer, deltaTime: number): void {
|
|
1099
|
-
// Check if style/conceal changed - re-render blocks before rendering
|
|
1100
|
-
if (this._styleDirty) {
|
|
1101
|
-
this._styleDirty = false
|
|
1102
|
-
this.rerenderBlocks()
|
|
1103
|
-
}
|
|
1104
|
-
super.renderSelf(buffer, deltaTime)
|
|
1105
|
-
}
|
|
1106
|
-
}
|