@fairyhunter13/opentui-core 0.1.114 → 0.1.115
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 +34041 -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 +111 -0
- package/console.d.ts +144 -0
- package/edit-buffer.d.ts +98 -0
- package/editor-view.d.ts +73 -0
- package/index-j4m38kjn.js +411 -0
- package/index-j4m38kjn.js.map +10 -0
- package/index-tse8gzh0.js +20614 -0
- package/index-tse8gzh0.js.map +67 -0
- package/index-vv2jcd4r.js +12299 -0
- package/index-vv2jcd4r.js.map +42 -0
- package/index.d.ts +23 -0
- package/index.js +478 -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 +51 -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 +87 -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 +53 -0
- package/lib/tree-sitter/resolve-ft.d.ts +5 -0
- package/lib/tree-sitter/types.d.ts +82 -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 +50 -62
- package/parser.worker.js +899 -0
- package/parser.worker.js.map +12 -0
- package/plugins/core-slot.d.ts +72 -0
- package/plugins/registry.d.ts +42 -0
- package/plugins/types.d.ts +34 -0
- package/post/effects.d.ts +147 -0
- package/post/filters.d.ts +65 -0
- package/post/matrices.d.ts +20 -0
- package/renderables/ASCIIFont.d.ts +52 -0
- package/renderables/Box.d.ts +81 -0
- package/renderables/Code.d.ts +78 -0
- package/renderables/Diff.d.ts +142 -0
- package/renderables/EditBufferRenderable.d.ts +237 -0
- package/renderables/FrameBuffer.d.ts +16 -0
- package/renderables/Input.d.ts +67 -0
- package/renderables/LineNumberRenderable.d.ts +78 -0
- package/renderables/Markdown.d.ts +185 -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 +47 -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 +63 -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 +23 -0
- package/renderables/markdown-parser.d.ts +10 -0
- package/renderer.d.ts +419 -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 +16 -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 +17 -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 +697 -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 +139 -0
- package/utils.d.ts +14 -0
- package/zig-structs.d.ts +155 -0
- package/zig.d.ts +353 -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 -144
- 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 -70
- 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 -1704
- 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/attenuation-benchmark.ts +0 -81
- package/src/benchmark/colormatrix-benchmark.ts +0 -128
- package/src/benchmark/gain-benchmark.ts +0 -80
- 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 -1796
- 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 -948
- package/src/buffer.test.ts +0 -291
- package/src/buffer.ts +0 -554
- package/src/console.test.ts +0 -612
- package/src/console.ts +0 -1254
- 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 -924
- 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 -701
- package/src/examples/draggable-three-demo.ts +0 -259
- package/src/examples/editor-demo.ts +0 -322
- package/src/examples/extmarks-demo.ts +0 -196
- 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 -241
- 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 -926
- 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 -725
- 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 -623
- package/src/examples/physx-rapier-2d-demo.ts +0 -655
- 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 -1015
- 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 -453
- 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 -400
- package/src/examples/vnode-composition-demo.ts +0 -404
- package/src/examples/wide-grapheme-overlay-demo.ts +0 -280
- package/src/index.ts +0 -24
- 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 -170
- 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 -35
- 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 -317
- package/src/lib/keymapping.ts +0 -115
- 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 -2290
- package/src/lib/stdin-parser.ts +0 -1810
- 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 -334
- package/src/lib/tree-sitter/assets.d.ts +0 -9
- package/src/lib/tree-sitter/cache.test.ts +0 -273
- package/src/lib/tree-sitter/client.test.ts +0 -1165
- package/src/lib/tree-sitter/client.ts +0 -607
- package/src/lib/tree-sitter/default-parsers.ts +0 -86
- 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 -1042
- package/src/lib/tree-sitter/parsers-config.ts +0 -81
- package/src/lib/tree-sitter/resolve-ft.test.ts +0 -55
- package/src/lib/tree-sitter/resolve-ft.ts +0 -189
- package/src/lib/tree-sitter/types.ts +0 -82
- 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 -402
- package/src/plugins/types.ts +0 -46
- package/src/post/effects.ts +0 -930
- package/src/post/filters.ts +0 -489
- package/src/post/matrices.ts +0 -288
- package/src/renderables/ASCIIFont.ts +0 -219
- package/src/renderables/Box.test.ts +0 -205
- package/src/renderables/Box.ts +0 -326
- 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 -3101
- package/src/renderables/Diff.ts +0 -1211
- package/src/renderables/EditBufferRenderable.test.ts +0 -288
- package/src/renderables/EditBufferRenderable.ts +0 -1166
- package/src/renderables/FrameBuffer.ts +0 -47
- package/src/renderables/Input.test.ts +0 -1228
- package/src/renderables/Input.ts +0 -247
- package/src/renderables/LineNumberRenderable.ts +0 -724
- package/src/renderables/Markdown.ts +0 -1393
- package/src/renderables/ScrollBar.ts +0 -422
- package/src/renderables/ScrollBox.ts +0 -883
- package/src/renderables/Select.test.ts +0 -1033
- package/src/renderables/Select.ts +0 -524
- package/src/renderables/Slider.test.ts +0 -456
- package/src/renderables/Slider.ts +0 -342
- 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 -430
- 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 -1865
- package/src/renderables/__tests__/LineNumberRenderable.wrapping.test.ts +0 -85
- package/src/renderables/__tests__/Markdown.code-colors.test.ts +0 -242
- package/src/renderables/__tests__/Markdown.test.ts +0 -2518
- 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 -1866
- 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 -23
- package/src/renderables/markdown-parser.ts +0 -66
- package/src/renderer.ts +0 -2681
- package/src/runtime-plugin-support.ts +0 -39
- package/src/runtime-plugin.ts +0 -615
- package/src/syntax-style.test.ts +0 -841
- package/src/syntax-style.ts +0 -257
- 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 -117
- package/src/testing/mock-keys.test.ts +0 -1378
- package/src/testing/mock-keys.ts +0 -457
- 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 -132
- 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/destroy-on-exit.fixture.ts +0 -36
- package/src/tests/destroy-on-exit.test.ts +0 -41
- 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.clock.test.ts +0 -158
- package/src/tests/renderer.console-startup.test.ts +0 -185
- package/src/tests/renderer.control.test.ts +0 -425
- 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 -147
- package/src/tests/renderer.focus-restore.test.ts +0 -257
- package/src/tests/renderer.focus.test.ts +0 -294
- package/src/tests/renderer.idle.test.ts +0 -219
- package/src/tests/renderer.input.test.ts +0 -2237
- package/src/tests/renderer.kitty-flags.test.ts +0 -195
- package/src/tests/renderer.mouse.test.ts +0 -1274
- 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 -684
- package/src/tests/renderer.useMouse.test.ts +0 -47
- package/src/tests/runtime-plugin-node-modules-cycle.fixture.ts +0 -76
- package/src/tests/runtime-plugin-node-modules-mjs.fixture.ts +0 -43
- package/src/tests/runtime-plugin-node-modules-no-bare-rewrite.fixture.ts +0 -67
- package/src/tests/runtime-plugin-node-modules-package-type-cache.fixture.ts +0 -72
- package/src/tests/runtime-plugin-node-modules-runtime-specifier.fixture.ts +0 -44
- package/src/tests/runtime-plugin-node-modules-scoped-package-bare-rewrite.fixture.ts +0 -85
- package/src/tests/runtime-plugin-path-alias.fixture.ts +0 -43
- package/src/tests/runtime-plugin-resolve-roots.fixture.ts +0 -65
- package/src/tests/runtime-plugin-support.fixture.ts +0 -11
- package/src/tests/runtime-plugin-support.test.ts +0 -19
- package/src/tests/runtime-plugin-windows-file-url.fixture.ts +0 -30
- package/src/tests/runtime-plugin.fixture.ts +0 -40
- package/src/tests/runtime-plugin.test.ts +0 -354
- 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 -276
- 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 -161
- 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-methods.zig +0 -211
- package/src/zig/buffer.zig +0 -2281
- 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 -1854
- 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 -1393
- package/src/zig/rope.zig +0 -1220
- package/src/zig/syntax-style.zig +0 -161
- package/src/zig/terminal.zig +0 -987
- package/src/zig/test.zig +0 -72
- package/src/zig/tests/README.md +0 -18
- package/src/zig/tests/buffer-methods_test.zig +0 -1109
- package/src/zig/tests/buffer_test.zig +0 -2557
- 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 -1017
- 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 -754
- 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 -3884
- package/tsconfig.build.json +0 -24
- package/tsconfig.json +0 -27
- /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,708 +0,0 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
|
|
3
|
-
pub const CallbackFn = fn (stream_ptr: usize, event_id: u32, arg0: usize, arg1: u64) callconv(.c) void;
|
|
4
|
-
|
|
5
|
-
pub const GrowthPolicy = enum(u8) {
|
|
6
|
-
grow = 0,
|
|
7
|
-
block = 1,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
pub const Options = extern struct {
|
|
11
|
-
chunk_size: u32,
|
|
12
|
-
initial_chunks: u32,
|
|
13
|
-
max_bytes: u64,
|
|
14
|
-
growth_policy: u8,
|
|
15
|
-
auto_commit_on_full: u8,
|
|
16
|
-
span_queue_capacity: u32,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
pub const Stats = extern struct {
|
|
20
|
-
bytes_written: u64,
|
|
21
|
-
spans_committed: u64,
|
|
22
|
-
chunks: u32,
|
|
23
|
-
pending_spans: u32,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const Chunk = struct {
|
|
27
|
-
ptr: [*]u8,
|
|
28
|
-
len: u32,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
pub const SpanInfo = extern struct {
|
|
32
|
-
chunk_ptr: usize,
|
|
33
|
-
offset: u32,
|
|
34
|
-
len: u32,
|
|
35
|
-
chunk_index: u32,
|
|
36
|
-
reserved: u32,
|
|
37
|
-
|
|
38
|
-
pub fn slice(self: SpanInfo) []u8 {
|
|
39
|
-
const base: [*]u8 = @ptrFromInt(self.chunk_ptr);
|
|
40
|
-
const start: usize = @intCast(self.offset);
|
|
41
|
-
const length: usize = @intCast(self.len);
|
|
42
|
-
return base[start .. start + length];
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const SpanRing = struct {
|
|
47
|
-
buffer: []SpanInfo,
|
|
48
|
-
capacity: u32,
|
|
49
|
-
head: u32,
|
|
50
|
-
tail: u32,
|
|
51
|
-
|
|
52
|
-
pub fn count(self: *SpanRing) u32 {
|
|
53
|
-
return self.tail -% self.head;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
pub fn push(self: *SpanRing, stream: *Stream, span: SpanInfo, notify: *bool) StreamError!void {
|
|
57
|
-
const capacity = self.capacity;
|
|
58
|
-
const head = self.head;
|
|
59
|
-
var tail = self.tail;
|
|
60
|
-
const queued = tail -% head;
|
|
61
|
-
|
|
62
|
-
if (queued >= capacity) {
|
|
63
|
-
return StreamError.NoSpace;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const index = tail % capacity;
|
|
67
|
-
self.buffer[index] = span;
|
|
68
|
-
tail +%= 1;
|
|
69
|
-
self.tail = tail;
|
|
70
|
-
const new_count = queued + 1;
|
|
71
|
-
|
|
72
|
-
stream.stats.pending_spans = new_count;
|
|
73
|
-
if (stream.attached and stream.callback != null) {
|
|
74
|
-
if (queued < notify_threshold_default and new_count >= notify_threshold_default) {
|
|
75
|
-
notify.* = true;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
pub fn popMany(self: *SpanRing, out: []SpanInfo) u32 {
|
|
81
|
-
const available = self.tail -% self.head;
|
|
82
|
-
if (available == 0) return 0;
|
|
83
|
-
const to_read: u32 = if (available < out.len) @intCast(available) else @intCast(out.len);
|
|
84
|
-
|
|
85
|
-
var i: u32 = 0;
|
|
86
|
-
while (i < to_read) : (i += 1) {
|
|
87
|
-
const index = (self.head +% i) % self.capacity;
|
|
88
|
-
out[i] = self.buffer[index];
|
|
89
|
-
}
|
|
90
|
-
self.head +%= to_read;
|
|
91
|
-
return to_read;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
pub const ReserveInfo = extern struct {
|
|
96
|
-
ptr: usize,
|
|
97
|
-
len: u32,
|
|
98
|
-
reserved: u32,
|
|
99
|
-
|
|
100
|
-
pub fn slice(self: ReserveInfo) []u8 {
|
|
101
|
-
const base: [*]u8 = @ptrFromInt(self.ptr);
|
|
102
|
-
const length: usize = @intCast(self.len);
|
|
103
|
-
return base[0..length];
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
pub const Stream = struct {
|
|
108
|
-
allocator: std.mem.Allocator,
|
|
109
|
-
options: Options,
|
|
110
|
-
chunks: std.ArrayList(Chunk),
|
|
111
|
-
current_chunk_index: usize,
|
|
112
|
-
write_offset: usize,
|
|
113
|
-
pending_chunk_index: usize,
|
|
114
|
-
pending_offset: usize,
|
|
115
|
-
pending_len: usize,
|
|
116
|
-
reserved_active: bool,
|
|
117
|
-
reserved_chunk_index: usize,
|
|
118
|
-
reserved_offset: usize,
|
|
119
|
-
reserved_len: usize,
|
|
120
|
-
attached: bool,
|
|
121
|
-
callback: ?*const CallbackFn,
|
|
122
|
-
closed: bool,
|
|
123
|
-
span_ring: SpanRing,
|
|
124
|
-
state_buffer: []u8,
|
|
125
|
-
state_capacity: u32,
|
|
126
|
-
stats: Stats,
|
|
127
|
-
|
|
128
|
-
pub fn create(allocator: std.mem.Allocator, options: ?Options) StreamError!*Stream {
|
|
129
|
-
const opts = normalizeOptions(options orelse defaultOptions());
|
|
130
|
-
const stream = allocator.create(Stream) catch return StreamError.OutOfMemory;
|
|
131
|
-
stream.* = .{
|
|
132
|
-
.allocator = allocator,
|
|
133
|
-
.options = opts,
|
|
134
|
-
.chunks = std.ArrayList(Chunk).empty,
|
|
135
|
-
.current_chunk_index = 0,
|
|
136
|
-
.write_offset = 0,
|
|
137
|
-
.pending_chunk_index = 0,
|
|
138
|
-
.pending_offset = 0,
|
|
139
|
-
.pending_len = 0,
|
|
140
|
-
.reserved_active = false,
|
|
141
|
-
.reserved_chunk_index = 0,
|
|
142
|
-
.reserved_offset = 0,
|
|
143
|
-
.reserved_len = 0,
|
|
144
|
-
.attached = false,
|
|
145
|
-
.callback = null,
|
|
146
|
-
.closed = false,
|
|
147
|
-
.span_ring = .{
|
|
148
|
-
.buffer = &[_]SpanInfo{},
|
|
149
|
-
.capacity = 0,
|
|
150
|
-
.head = 0,
|
|
151
|
-
.tail = 0,
|
|
152
|
-
},
|
|
153
|
-
.state_buffer = &[_]u8{},
|
|
154
|
-
.state_capacity = 0,
|
|
155
|
-
.stats = .{
|
|
156
|
-
.bytes_written = 0,
|
|
157
|
-
.spans_committed = 0,
|
|
158
|
-
.chunks = 0,
|
|
159
|
-
.pending_spans = 0,
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
errdefer stream.destroy();
|
|
164
|
-
|
|
165
|
-
const ring_capacity = opts.span_queue_capacity;
|
|
166
|
-
const ring_buffer = allocator.alloc(SpanInfo, ring_capacity) catch return StreamError.OutOfMemory;
|
|
167
|
-
stream.span_ring = .{
|
|
168
|
-
.buffer = ring_buffer,
|
|
169
|
-
.capacity = ring_capacity,
|
|
170
|
-
.head = 0,
|
|
171
|
-
.tail = 0,
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
try stream.ensureStateCapacity(@intCast(opts.initial_chunks));
|
|
175
|
-
|
|
176
|
-
const initial = @as(usize, opts.initial_chunks);
|
|
177
|
-
var i: usize = 0;
|
|
178
|
-
while (i < initial) : (i += 1) {
|
|
179
|
-
try stream.addChunkLocked();
|
|
180
|
-
}
|
|
181
|
-
stream.stats.chunks = @intCast(stream.chunks.items.len);
|
|
182
|
-
return stream;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
pub fn attach(self: *Stream) StreamError!void {
|
|
186
|
-
if (self.closed) return StreamError.Invalid;
|
|
187
|
-
|
|
188
|
-
var notify = false;
|
|
189
|
-
var queued: u32 = 0;
|
|
190
|
-
defer self.finish(notify, queued);
|
|
191
|
-
|
|
192
|
-
self.attached = true;
|
|
193
|
-
if (self.callback == null) return;
|
|
194
|
-
|
|
195
|
-
self.emitStateBuffer();
|
|
196
|
-
|
|
197
|
-
for (self.chunks.items) |chunk| {
|
|
198
|
-
self.emitChunkAdded(chunk);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
queued = self.span_ring.count();
|
|
202
|
-
if (queued > 0) {
|
|
203
|
-
notify = true;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
pub fn setCallback(self: *Stream, cb: ?*const CallbackFn) void {
|
|
208
|
-
self.callback = cb;
|
|
209
|
-
if (cb == null or !self.attached) return;
|
|
210
|
-
|
|
211
|
-
self.emitStateBuffer();
|
|
212
|
-
for (self.chunks.items) |chunk| {
|
|
213
|
-
self.emitChunkAdded(chunk);
|
|
214
|
-
}
|
|
215
|
-
const queued = self.span_ring.count();
|
|
216
|
-
if (queued > 0) {
|
|
217
|
-
self.emitDataAvailable(queued);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
pub fn write(self: *Stream, data: []const u8) StreamError!void {
|
|
222
|
-
if (self.closed) return StreamError.Invalid;
|
|
223
|
-
if (data.len == 0) return;
|
|
224
|
-
if (self.reserved_active) return StreamError.Busy;
|
|
225
|
-
|
|
226
|
-
var notify = false;
|
|
227
|
-
// finish() must run on success and error so committed spans notify.
|
|
228
|
-
defer self.finish(notify, 0);
|
|
229
|
-
|
|
230
|
-
var remaining = data.len;
|
|
231
|
-
var src_index: usize = 0;
|
|
232
|
-
const auto_commit = self.options.auto_commit_on_full != 0;
|
|
233
|
-
const chunk_len = self.options.chunk_size;
|
|
234
|
-
|
|
235
|
-
while (remaining > 0) {
|
|
236
|
-
var available = @as(usize, chunk_len) - self.write_offset;
|
|
237
|
-
if (available == 0) {
|
|
238
|
-
if (self.pending_len > 0) {
|
|
239
|
-
try self.commitLocked(¬ify);
|
|
240
|
-
}
|
|
241
|
-
try self.ensureWritableChunkLocked();
|
|
242
|
-
available = @as(usize, chunk_len);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (remaining > available and !auto_commit) {
|
|
246
|
-
return StreamError.NoSpace;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const to_write = if (remaining < available) remaining else available;
|
|
250
|
-
if (self.pending_len == 0) {
|
|
251
|
-
self.pending_chunk_index = self.current_chunk_index;
|
|
252
|
-
self.pending_offset = self.write_offset;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const chunk = self.chunks.items[self.current_chunk_index];
|
|
256
|
-
@memcpy(chunk.ptr[self.write_offset .. self.write_offset + to_write], data[src_index .. src_index + to_write]);
|
|
257
|
-
|
|
258
|
-
self.write_offset += to_write;
|
|
259
|
-
self.pending_len += to_write;
|
|
260
|
-
self.stats.bytes_written += @as(u64, to_write);
|
|
261
|
-
src_index += to_write;
|
|
262
|
-
remaining -= to_write;
|
|
263
|
-
|
|
264
|
-
if (self.write_offset == @as(usize, chunk_len) and auto_commit) {
|
|
265
|
-
try self.commitLocked(¬ify);
|
|
266
|
-
if (remaining > 0) {
|
|
267
|
-
try self.ensureWritableChunkLocked();
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
pub fn reserve(self: *Stream, min_len: u32) StreamError!ReserveInfo {
|
|
274
|
-
if (self.closed) return StreamError.Invalid;
|
|
275
|
-
return self.reserveLocked(min_len);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
pub fn commitReserved(self: *Stream, len: u32) StreamError!void {
|
|
279
|
-
if (self.closed) return StreamError.Invalid;
|
|
280
|
-
|
|
281
|
-
var notify = false;
|
|
282
|
-
defer self.finish(notify, 0);
|
|
283
|
-
try self.commitReservedLocked(len, ¬ify);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
pub fn commit(self: *Stream) StreamError!void {
|
|
287
|
-
if (self.closed) return StreamError.Invalid;
|
|
288
|
-
var notify = false;
|
|
289
|
-
defer self.finish(notify, 0);
|
|
290
|
-
if (self.reserved_active) return StreamError.Busy;
|
|
291
|
-
try self.commitLocked(¬ify);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
pub fn getStats(self: *Stream) Stats {
|
|
295
|
-
var out: Stats = undefined;
|
|
296
|
-
out = self.stats;
|
|
297
|
-
return out;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/// Apply only runtime-safe options; creation-time fields are ignored.
|
|
301
|
-
pub fn setOptions(self: *Stream, options: Options) StreamError!void {
|
|
302
|
-
if (self.closed) return StreamError.Invalid;
|
|
303
|
-
self.options.max_bytes = options.max_bytes;
|
|
304
|
-
self.options.growth_policy = options.growth_policy;
|
|
305
|
-
self.options.auto_commit_on_full = options.auto_commit_on_full;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
pub fn close(self: *Stream) StreamError!void {
|
|
309
|
-
var notify = false;
|
|
310
|
-
if (self.closed) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
if (self.reserved_active) {
|
|
314
|
-
return StreamError.Busy;
|
|
315
|
-
}
|
|
316
|
-
if (self.pending_len > 0) {
|
|
317
|
-
try self.commitLocked(¬ify);
|
|
318
|
-
}
|
|
319
|
-
self.closed = true;
|
|
320
|
-
self.attached = false;
|
|
321
|
-
self.finish(notify, 0);
|
|
322
|
-
self.emitClosed();
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
pub fn destroy(self: *Stream) void {
|
|
326
|
-
if (!self.closed) {
|
|
327
|
-
_ = self.close() catch {};
|
|
328
|
-
}
|
|
329
|
-
for (self.chunks.items) |chunk| {
|
|
330
|
-
self.allocator.free(chunk.ptr[0..@as(usize, chunk.len)]);
|
|
331
|
-
}
|
|
332
|
-
self.chunks.deinit(self.allocator);
|
|
333
|
-
if (self.span_ring.capacity > 0) {
|
|
334
|
-
self.allocator.free(self.span_ring.buffer);
|
|
335
|
-
}
|
|
336
|
-
if (self.state_capacity > 0) {
|
|
337
|
-
self.allocator.free(self.state_buffer);
|
|
338
|
-
}
|
|
339
|
-
self.allocator.destroy(self);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
pub fn drainSpans(self: *Stream, out: []SpanInfo) u32 {
|
|
343
|
-
if (out.len == 0) return 0;
|
|
344
|
-
const count = self.span_ring.popMany(out);
|
|
345
|
-
self.stats.pending_spans = self.span_ring.count();
|
|
346
|
-
return count;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
pub fn hasPendingSpans(self: *Stream) bool {
|
|
350
|
-
return self.span_ring.count() > 0;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
pub fn stateBuffer(self: *Stream) []u8 {
|
|
354
|
-
return self.state_buffer;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
pub fn markChunkFree(self: *Stream, chunk_index: u32) void {
|
|
358
|
-
if (chunk_index < self.state_capacity) {
|
|
359
|
-
self.state_buffer[chunk_index] -|= 1;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
pub fn markSpanConsumed(self: *Stream, span: SpanInfo) void {
|
|
364
|
-
self.markChunkFree(span.chunk_index);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
pub fn finish(self: *Stream, notify: bool, queued_override: u32) void {
|
|
368
|
-
if (notify and self.callback != null) {
|
|
369
|
-
const queued = if (queued_override != 0)
|
|
370
|
-
queued_override
|
|
371
|
-
else
|
|
372
|
-
self.span_ring.count();
|
|
373
|
-
if (queued > 0) self.emitDataAvailable(queued);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
fn ensureStateCapacity(self: *Stream, required: u32) StreamError!void {
|
|
378
|
-
if (required <= self.state_capacity) return;
|
|
379
|
-
var new_capacity: u32 = if (self.state_capacity == 0) 1 else self.state_capacity;
|
|
380
|
-
while (new_capacity < required) : (new_capacity *= 2) {}
|
|
381
|
-
const new_buffer = self.allocator.alloc(u8, new_capacity) catch return StreamError.OutOfMemory;
|
|
382
|
-
@memset(new_buffer, 0);
|
|
383
|
-
if (self.state_capacity > 0) {
|
|
384
|
-
std.mem.copyForwards(u8, new_buffer[0..self.state_capacity], self.state_buffer);
|
|
385
|
-
self.allocator.free(self.state_buffer);
|
|
386
|
-
}
|
|
387
|
-
self.state_buffer = new_buffer;
|
|
388
|
-
self.state_capacity = new_capacity;
|
|
389
|
-
if (self.attached and self.callback != null) {
|
|
390
|
-
self.emitStateBuffer();
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
fn isChunkFree(self: *Stream, index: usize) bool {
|
|
395
|
-
if (index >= self.state_capacity) return true;
|
|
396
|
-
return self.state_buffer[index] == 0;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
pub fn commitLocked(self: *Stream, notify: *bool) StreamError!void {
|
|
400
|
-
if (self.pending_len == 0) return;
|
|
401
|
-
const chunk = self.chunks.items[self.pending_chunk_index];
|
|
402
|
-
const info = SpanInfo{
|
|
403
|
-
.chunk_ptr = @intFromPtr(chunk.ptr),
|
|
404
|
-
.offset = @intCast(self.pending_offset),
|
|
405
|
-
.len = @intCast(self.pending_len),
|
|
406
|
-
.chunk_index = @intCast(self.pending_chunk_index),
|
|
407
|
-
.reserved = 0,
|
|
408
|
-
};
|
|
409
|
-
try self.span_ring.push(self, info, notify);
|
|
410
|
-
if (self.pending_chunk_index < self.state_capacity) {
|
|
411
|
-
self.state_buffer[self.pending_chunk_index] +|= 1;
|
|
412
|
-
// Avoid refcount saturation, which can corrupt data.
|
|
413
|
-
if (self.state_buffer[self.pending_chunk_index] == 255) {
|
|
414
|
-
self.write_offset = self.options.chunk_size;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
self.stats.spans_committed += 1;
|
|
418
|
-
self.pending_len = 0;
|
|
419
|
-
self.pending_offset = self.write_offset;
|
|
420
|
-
self.pending_chunk_index = self.current_chunk_index;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
pub fn reserveLocked(self: *Stream, min_len: u32) StreamError!ReserveInfo {
|
|
424
|
-
if (self.reserved_active) return StreamError.Busy;
|
|
425
|
-
if (self.pending_len != 0) return StreamError.Busy;
|
|
426
|
-
|
|
427
|
-
try self.ensureWritableChunkLocked();
|
|
428
|
-
|
|
429
|
-
const chunk = self.chunks.items[self.current_chunk_index];
|
|
430
|
-
const available = @as(usize, chunk.len) - self.write_offset;
|
|
431
|
-
if (available < min_len) return StreamError.NoSpace;
|
|
432
|
-
|
|
433
|
-
self.reserved_active = true;
|
|
434
|
-
self.reserved_chunk_index = self.current_chunk_index;
|
|
435
|
-
self.reserved_offset = self.write_offset;
|
|
436
|
-
self.reserved_len = available;
|
|
437
|
-
|
|
438
|
-
return .{
|
|
439
|
-
.ptr = @intFromPtr(chunk.ptr + self.write_offset),
|
|
440
|
-
.len = @intCast(available),
|
|
441
|
-
.reserved = 0,
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
pub fn commitReservedLocked(self: *Stream, len: u32, notify: *bool) StreamError!void {
|
|
446
|
-
if (!self.reserved_active) return StreamError.Invalid;
|
|
447
|
-
if (len > self.reserved_len) return StreamError.NoSpace;
|
|
448
|
-
|
|
449
|
-
self.pending_chunk_index = self.reserved_chunk_index;
|
|
450
|
-
self.pending_offset = self.reserved_offset;
|
|
451
|
-
self.pending_len = len;
|
|
452
|
-
self.write_offset = self.reserved_offset + len;
|
|
453
|
-
self.reserved_active = false;
|
|
454
|
-
self.reserved_len = 0;
|
|
455
|
-
|
|
456
|
-
self.stats.bytes_written += @as(u64, len);
|
|
457
|
-
|
|
458
|
-
try self.commitLocked(notify);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
fn addChunkLocked(self: *Stream) StreamError!void {
|
|
462
|
-
const chunk_size: u32 = self.options.chunk_size;
|
|
463
|
-
const max_bytes = self.options.max_bytes;
|
|
464
|
-
const allocated = @as(u64, self.chunks.items.len) * @as(u64, chunk_size);
|
|
465
|
-
if (max_bytes != 0 and allocated + @as(u64, chunk_size) > max_bytes) {
|
|
466
|
-
return StreamError.MaxBytes;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// Grow state buffer first to keep chunk/refcount in sync on failure.
|
|
470
|
-
try self.ensureStateCapacity(@as(u32, @intCast(self.chunks.items.len)) + 1);
|
|
471
|
-
|
|
472
|
-
const mem = self.allocator.alloc(u8, chunk_size) catch return StreamError.OutOfMemory;
|
|
473
|
-
errdefer self.allocator.free(mem);
|
|
474
|
-
const chunk = Chunk{ .ptr = mem.ptr, .len = chunk_size };
|
|
475
|
-
self.chunks.append(self.allocator, chunk) catch return StreamError.OutOfMemory;
|
|
476
|
-
self.stats.chunks = @intCast(self.chunks.items.len);
|
|
477
|
-
if (self.attached and self.callback != null) {
|
|
478
|
-
self.emitChunkAdded(chunk);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
fn ensureWritableChunkLocked(self: *Stream) StreamError!void {
|
|
483
|
-
const total = self.chunks.items.len;
|
|
484
|
-
if (total == 0) return StreamError.Invalid;
|
|
485
|
-
|
|
486
|
-
var attempts: usize = 0;
|
|
487
|
-
var index = self.current_chunk_index % total;
|
|
488
|
-
while (attempts < total) : (attempts += 1) {
|
|
489
|
-
if (self.isChunkFree(index)) {
|
|
490
|
-
self.current_chunk_index = index;
|
|
491
|
-
self.write_offset = 0;
|
|
492
|
-
self.pending_chunk_index = index;
|
|
493
|
-
self.pending_offset = 0;
|
|
494
|
-
self.pending_len = 0;
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
index = (index + 1) % total;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (self.options.growth_policy == @intFromEnum(GrowthPolicy.block)) {
|
|
501
|
-
return StreamError.NoSpace;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
try self.addChunkLocked();
|
|
505
|
-
const new_total = self.chunks.items.len;
|
|
506
|
-
if (new_total == 0) return StreamError.Invalid;
|
|
507
|
-
self.current_chunk_index = new_total - 1;
|
|
508
|
-
self.write_offset = 0;
|
|
509
|
-
self.pending_chunk_index = self.current_chunk_index;
|
|
510
|
-
self.pending_offset = 0;
|
|
511
|
-
self.pending_len = 0;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
fn emitChunkAdded(self: *Stream, chunk: Chunk) void {
|
|
515
|
-
if (self.callback) |cb| {
|
|
516
|
-
cb(@intFromPtr(self), Event.ChunkAdded, @intFromPtr(chunk.ptr), chunk.len);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
fn emitDataAvailable(self: *Stream, count: u32) void {
|
|
521
|
-
if (self.callback) |cb| {
|
|
522
|
-
cb(@intFromPtr(self), Event.DataAvailable, count, 0);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
fn emitStateBuffer(self: *Stream) void {
|
|
527
|
-
if (self.callback) |cb| {
|
|
528
|
-
cb(@intFromPtr(self), Event.StateBuffer, @intFromPtr(self.state_buffer.ptr), self.state_capacity);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
fn emitClosed(self: *Stream) void {
|
|
533
|
-
if (self.callback) |cb| {
|
|
534
|
-
cb(@intFromPtr(self), Event.Closed, 0, 0);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
pub const default_pattern = "\x1b[32mnative-span-feed\x1b[0m\n";
|
|
540
|
-
const span_queue_capacity_default: u32 = 4096;
|
|
541
|
-
const notify_threshold_default: u32 = 1;
|
|
542
|
-
|
|
543
|
-
pub const EventId = enum(u32) {
|
|
544
|
-
ChunkAdded = 2,
|
|
545
|
-
Closed = 5,
|
|
546
|
-
Error = 6,
|
|
547
|
-
DataAvailable = 7,
|
|
548
|
-
StateBuffer = 8,
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
const Event = struct {
|
|
552
|
-
pub const ChunkAdded: u32 = @intFromEnum(EventId.ChunkAdded);
|
|
553
|
-
pub const Closed: u32 = @intFromEnum(EventId.Closed);
|
|
554
|
-
pub const Error: u32 = @intFromEnum(EventId.Error);
|
|
555
|
-
pub const DataAvailable: u32 = @intFromEnum(EventId.DataAvailable);
|
|
556
|
-
pub const StateBuffer: u32 = @intFromEnum(EventId.StateBuffer);
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
pub const Status = struct {
|
|
560
|
-
pub const ok: i32 = 0;
|
|
561
|
-
pub const err_no_space: i32 = -1;
|
|
562
|
-
pub const err_max_bytes: i32 = -2;
|
|
563
|
-
pub const err_invalid: i32 = -3;
|
|
564
|
-
pub const err_alloc: i32 = -4;
|
|
565
|
-
pub const err_busy: i32 = -5;
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
pub const StreamError = error{
|
|
569
|
-
NoSpace,
|
|
570
|
-
MaxBytes,
|
|
571
|
-
Invalid,
|
|
572
|
-
OutOfMemory,
|
|
573
|
-
Busy,
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
pub fn defaultOptions() Options {
|
|
577
|
-
return .{
|
|
578
|
-
.chunk_size = 64 * 1024,
|
|
579
|
-
.initial_chunks = 2,
|
|
580
|
-
.max_bytes = 0,
|
|
581
|
-
.growth_policy = @intFromEnum(GrowthPolicy.grow),
|
|
582
|
-
.auto_commit_on_full = 1,
|
|
583
|
-
.span_queue_capacity = 0,
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
pub fn normalizeOptions(opts: Options) Options {
|
|
588
|
-
var out = opts;
|
|
589
|
-
if (out.chunk_size == 0) out.chunk_size = 64 * 1024;
|
|
590
|
-
if (out.initial_chunks == 0) out.initial_chunks = 1;
|
|
591
|
-
if (out.span_queue_capacity == 0) out.span_queue_capacity = span_queue_capacity_default;
|
|
592
|
-
return out;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
fn errorToStatus(err: StreamError) i32 {
|
|
596
|
-
return switch (err) {
|
|
597
|
-
StreamError.NoSpace => Status.err_no_space,
|
|
598
|
-
StreamError.MaxBytes => Status.err_max_bytes,
|
|
599
|
-
StreamError.Invalid => Status.err_invalid,
|
|
600
|
-
StreamError.OutOfMemory => Status.err_alloc,
|
|
601
|
-
StreamError.Busy => Status.err_busy,
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
pub fn createNativeSpanFeedWithAllocator(allocator: std.mem.Allocator, options_ptr: ?*const Options) ?*Stream {
|
|
606
|
-
const opts = normalizeOptions(if (options_ptr) |p| p.* else defaultOptions());
|
|
607
|
-
return Stream.create(allocator, opts) catch null;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
pub export fn streamSetCallback(stream: ?*Stream, callback: ?*const CallbackFn) void {
|
|
611
|
-
if (stream == null) return;
|
|
612
|
-
stream.?.setCallback(callback);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
pub export fn attachNativeSpanFeed(stream: ?*Stream) i32 {
|
|
616
|
-
if (stream == null) return Status.err_invalid;
|
|
617
|
-
const s = stream.?;
|
|
618
|
-
s.attach() catch |err| return errorToStatus(err);
|
|
619
|
-
return Status.ok;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
pub export fn streamClose(stream: ?*Stream) i32 {
|
|
623
|
-
if (stream == null) return Status.err_invalid;
|
|
624
|
-
const s = stream.?;
|
|
625
|
-
s.close() catch |err| return errorToStatus(err);
|
|
626
|
-
return Status.ok;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
pub export fn destroyNativeSpanFeed(stream: ?*Stream) void {
|
|
630
|
-
if (stream == null) return;
|
|
631
|
-
const s = stream.?;
|
|
632
|
-
s.destroy();
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
/// Copy API: copies len bytes from src_ptr into the stream's chunk pool.
|
|
636
|
-
/// Handles spanning across multiple chunks automatically. If auto_commit_on_full
|
|
637
|
-
/// is enabled, commits and emits DataAvailable each time a chunk fills.
|
|
638
|
-
/// Best for producers that already have data in a buffer (formatted output,
|
|
639
|
-
/// serialized messages, file contents).
|
|
640
|
-
/// When auto_commit_on_full is disabled, writes are all-or-nothing per
|
|
641
|
-
/// chunk boundary: a write that fits in the remaining space succeeds,
|
|
642
|
-
/// but a write that would exceed it returns err_no_space without writing
|
|
643
|
-
/// any bytes. A write that exactly fills the chunk succeeds; the next
|
|
644
|
-
/// write will move to a new chunk (committing the full one first).
|
|
645
|
-
pub export fn streamWrite(stream: ?*Stream, src_ptr: ?*const u8, len: usize) i32 {
|
|
646
|
-
if (stream == null or src_ptr == null) return Status.err_invalid;
|
|
647
|
-
const s = stream.?;
|
|
648
|
-
if (len == 0) return Status.ok;
|
|
649
|
-
const src = @as([*]const u8, @ptrCast(src_ptr.?))[0..len];
|
|
650
|
-
s.write(src) catch |err| return errorToStatus(err);
|
|
651
|
-
return Status.ok;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/// Commits the pending span accumulated by streamWrite and emits DataAvailable.
|
|
655
|
-
/// Only needed when auto_commit_on_full is disabled or to flush a partially
|
|
656
|
-
/// filled chunk.
|
|
657
|
-
pub export fn streamCommit(stream: ?*Stream) i32 {
|
|
658
|
-
if (stream == null) return Status.err_invalid;
|
|
659
|
-
const s = stream.?;
|
|
660
|
-
s.commit() catch |err| return errorToStatus(err);
|
|
661
|
-
return Status.ok;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/// Zero-copy API: returns a pointer and available length for direct writes
|
|
665
|
-
/// into the current chunk's memory. The caller writes directly into this
|
|
666
|
-
/// region (no memcpy) and then calls streamCommitReserved with the number
|
|
667
|
-
/// of bytes actually written.
|
|
668
|
-
/// Best for producers that can format output in place (e.g., serializing
|
|
669
|
-
/// directly into the chunk buffer). Only one reservation can be active at
|
|
670
|
-
/// a time; the stream is locked until streamCommitReserved is called.
|
|
671
|
-
/// Returns at most one chunk's worth of available space.
|
|
672
|
-
pub export fn streamReserve(stream: ?*Stream, min_len: u32, out_ptr: ?*ReserveInfo) i32 {
|
|
673
|
-
if (stream == null or out_ptr == null) return Status.err_invalid;
|
|
674
|
-
const s = stream.?;
|
|
675
|
-
const info = s.reserve(min_len) catch |err| return errorToStatus(err);
|
|
676
|
-
out_ptr.?.* = info;
|
|
677
|
-
return Status.ok;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
/// Commits len bytes of the previously reserved region and emits DataAvailable.
|
|
681
|
-
/// Must be called after streamReserve. len must not exceed the reserved length.
|
|
682
|
-
pub export fn streamCommitReserved(stream: ?*Stream, len: u32) i32 {
|
|
683
|
-
if (stream == null) return Status.err_invalid;
|
|
684
|
-
const s = stream.?;
|
|
685
|
-
s.commitReserved(len) catch |err| return errorToStatus(err);
|
|
686
|
-
return Status.ok;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
pub export fn streamSetOptions(stream: ?*Stream, options_ptr: ?*const Options) i32 {
|
|
690
|
-
if (stream == null or options_ptr == null) return Status.err_invalid;
|
|
691
|
-
const s = stream.?;
|
|
692
|
-
s.setOptions(options_ptr.?.*) catch |err| return errorToStatus(err);
|
|
693
|
-
return Status.ok;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
pub export fn streamGetStats(stream: ?*Stream, stats_ptr: ?*Stats) i32 {
|
|
697
|
-
if (stream == null or stats_ptr == null) return Status.err_invalid;
|
|
698
|
-
const s = stream.?;
|
|
699
|
-
stats_ptr.?.* = s.getStats();
|
|
700
|
-
return Status.ok;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
pub export fn streamDrainSpans(stream: ?*Stream, out_ptr: ?*SpanInfo, max_spans: u32) u32 {
|
|
704
|
-
if (stream == null or out_ptr == null or max_spans == 0) return 0;
|
|
705
|
-
const s = stream.?;
|
|
706
|
-
const out = @as([*]SpanInfo, @ptrCast(out_ptr.?))[0..max_spans];
|
|
707
|
-
return s.drainSpans(out);
|
|
708
|
-
}
|