Skip to content

Add Node and Bun support to the TypeScript client#217

Open
just-be-dev wants to merge 3 commits into
mainfrom
add-node-support
Open

Add Node and Bun support to the TypeScript client#217
just-be-dev wants to merge 3 commits into
mainfrom
add-node-support

Conversation

@just-be-dev
Copy link
Copy Markdown
Owner

@just-be-dev just-be-dev commented Jun 4, 2026

So, I've wanted to use this project outside of the deno ecosystem for a bit and it's high time to land a change to support both node and bun. Honestly, there's not really much of a dependency on deno to begin with. From a runtime perspective it's nice to have URL dependencies in a webview script but it's certainly not required. I'm not using FFI in this project at all given the binary approach (which I'm generally happy with). So, yeah. I still need to do the manual publishing of the package to NPM and setup the OIDC publishing step.

AI Summary

Reworks the Deno client into a cross-runtime TypeScript client that works on Node (>= 20.9), Deno, and Bun, published to both JSR (@justbe/webview, unchanged) and npm (@just-be/webview, new). Existing Deno/JSR consumers are unaffected — same package name, version, exports, and permission behavior.

Client changes (src/clients/deno/src/clients/typescript/)

  • main.ts uses node: builtins everywhere (child_process, fs/promises, path, events), which all three runtimes support natively. Web streams became Node streams, with a persistent streaming TextDecoder (also fixes a latent bug where multi-byte UTF-8 chars split across chunks would corrupt).
  • New runtime.ts holds the only runtime-conditional code: getEnv() preserves Deno's permission-guard behavior (no prompt without --allow-env), plus platformOs()/platformArch() normalizers.
  • New logger.ts replaces @bcheidemann/tracing + @instrument() decorators — that dep is JSR-only (npm packages can't depend on JSR-scoped packages), and TC39 decorators can't run on Node from raw TS. Same LOG_LEVEL env contract; per-method span traces are gone.
  • Public API is unchanged.

Packaging & CI

  • New package.json / tsdown build / tsconfig.npm.json for the npm artifact (ESM + d.ts). The tsconfig is deliberately not named tsconfig.json — Deno 2.4 picks that up and it breaks deno check.
  • deno.json sets nodeModulesDir: "none" so Deno and npm don't fight over node_modules.
  • publish-deno.ymlpublish-typescript-jsr.yml (logic unchanged, incl. deno-v* tags); new publish-typescript-npm.yml mirrors the version-gated pattern and publishes with --provenance.
  • mise: :deno tasks renamed to :ts; new example:node, example:bun, verify-publish:npm, lint:ts-npm tasks; node + bun added to tools.
  • Codegen now emits import { z } from "zod" (bare specifier); sync-versions.ts keeps package.json version locked to deno.json.

Verification

  • Deno: deno lint, deno check, deno publish --dry-run, live smoke test (spawn → setTitle/getTitle round-trip → dispose) ✅
  • Node: tsc typecheck, tsdown build, live smoke via tsx, tarball installed in a scratch project with zero registry config ✅
  • Bun: live smoke test ✅
  • mise run lint, npm pack contents, codegen idempotency ✅

Before npm publishing works

  1. Add an NPM_TOKEN repo secret with publish rights to the @just-be scope.
  2. The first @just-be/webview publish may need to be done manually to claim the name.

🤖 Generated with Claude Code

just-be-dev and others added 3 commits June 3, 2026 23:08
Rework the Deno client into a cross-runtime TypeScript client that works
on Node (>= 20.9), Deno, and Bun, published to both JSR (@justbe/webview)
and npm (@just-be/webview).

- Rename src/clients/deno -> src/clients/typescript
- Replace Deno.* APIs with node: builtins (child_process, fs, path,
  events); the only runtime-conditional code is a small getEnv shim that
  preserves Deno's permission-guard behavior
- Drop the JSR-only @bcheidemann/tracing dep and @Instrument decorators
  in favor of a minimal internal logger honoring LOG_LEVEL
- Add npm packaging (package.json, tsdown build, tsconfig.npm.json) and
  a version-gated npm publish workflow
- Rename :deno mise tasks to :ts, add example:node and example:bun tasks
- Keep deno.json name/version/exports unchanged so JSR consumers are
  unaffected

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant