feat(deno): Deno runtime support#1060
Draft
lu-zero wants to merge 12 commits into
Draft
Conversation
Bare `import ... with { type: "file" }` and direct Worker
construction are Bun-specific. Route asset path resolution through
resolveBundledFilePath() and worker creation through PlatformWorker
so tree-sitter operates correctly across runtimes.
The native package loader, FFI backend, and tree-sitter parser initialization all used top-level await with Bun-specific import patterns. Replace with synchronous require for FFI, conditional exports for native packages, and deferred async loading for parsers so the package works under Node.js and Deno in addition to Bun. Issue anomalyco#2
The tree-sitter WASM still loaded via a direct import that only Bun's bundler resolves; route it through resolveBundledFilePath alongside the other bundled assets so Node and Deno builds work. Tighten toBigIntPointer to reject negative bigints and out-of-range numeric values. Bad pointers now throw at the conversion boundary instead of reaching the FFI backend as invalid addresses. The Zig render lib uses the validated toPointer helper for buffer reads.
The encodeUnicode result pointer was non-nullable, so empty input had no clean representation. Make the output pointer nullable, short-circuit zero-length input to a null result, and accept the null/zero pair in freeUnicode so callers can encode and free unconditionally.
Root deno.json with sloppy-imports and test tasks. Core deno.json maps bun:ffi → bun-compat 0.4.2, bun:test → @std/testing bdd shim, @opentui/core → src, and node: builtins. Bun-test shim delegates to @std/testing/bdd, @std/expect, @std/expect/fn with spyOn compat and auto-installs bun-compat for globalThis.Bun. Solid deno.json maps solid-js to npm: specifiers. Add jsx-runtime.ts for Deno-compatible JSX transformation.
…fallback
Use { type: "module" } in Worker constructor for Deno compat.
Fall back from with { type: "wasm" } to URL-based WASM
resolution. Clear dispose timeout on worker response. Stop
worker before clearing callbacks. Guard handleWorkerMessage
against destroyed state. Call preventDefault on worker error.
Add bun:ffi fallback when node:ffi unavailable (bun-compat).
bun-compat sets globalThis.Bun under Deno, so checking for its
presence alone incorrectly triggers the with { type: "file" }
import path. Use process.versions.bun to distinguish the real
Bun runtime from the compat shim.
Fix @opentui/core/testing path (testing.ts not testing/index.ts). Add solid-js/jsx-runtime mapping to local jsx-runtime.ts.
Member
|
Thanks for this — but you're a bit too early. We need to go through refactoring to support |
Contributor
Author
|
I'll rebase on top of the node:ffi support once it is ready then :) |
Member
I may cherry pick a couple of the the things you have here, tbh. I think the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Deno runtime support to opentui, building on top of the
debun-urlsbranch (PR #1027). With this, opentui core runs under Deno with native FFI, tree-sitter highlighting, and test infrastructure.What's included
deno.jsonwith sloppy-imports anddeno task test:core/test:soliddeno.jsonimport map:bun:ffi→bun-compat@0.4.2,bun:test→@std/testingshim,@opentui/core→ src, node: builtinsbun-test.tsshim delegating to@std/testing/bdd,@std/expect,@std/expect/fnwithspyOn/mockImplementationcompatibility and auto-installingbun-compatforglobalThis.Bundeno.jsonwithnpm:solid-jsspecifiers andjsx-runtimemappingjsx-runtime.tsfor Deno-compatible JSX transformation{ type: "module" }) for Deno compatwith { type: "wasm" }toimport.meta.resolve+ URLbun:ffifallback whennode:ffiis unavailable (bun-compat)isBunRuntimecheck inresolveBundledFilePathto distinguish real Bun from bun-compat shimimport.meta.urlTest results
Deno: 225 passed (1349 steps), 3 failed
Bun.serve(Bun-only test)Bun: 58/58 pass (no regressions)
How to test
Dependencies
debun-urls(PR core: remove Bun-specific runtime dependencies #1027) — should be merged firstbun-compat@0.4.2+(published to jsr.io)Known limitations
--no-checkneeded (type errors from Deno stdlib mismatches)