Skip to content

feat: improve cross-runtime portability (Node/Kiln/Bun) and use standard node:fs/promises - #64

Open
candrewlee14 wants to merge 6 commits into
kitlangton:mainfrom
candrewlee14:feat/kiln-native-run
Open

candrewlee14 wants to merge 6 commits into
kitlangton:mainfrom
candrewlee14:feat/kiln-native-run

Conversation

@candrewlee14

Copy link
Copy Markdown

Overview

This PR improves cross-runtime portability for ghui across Bun, Node, and ahead-of-time compiled native runtimes (like Kiln), while preserving 100% test compatibility and zero changes to existing Bun user behavior.

Key Changes

  1. Portable Filesystem I/O:
    • Replaced Bun-specific file APIs (Bun.file, Bun.write) in themeStore.ts and workspacePreferenceFile.ts with standard node:fs/promises (readFile, writeFile, mkdir).
    • Safely resolve user configuration directories with homedir() from node:os with fallback to process.env.HOME.
  2. Multi-Runtime SQLite Cache:
    • In CacheService.ts, dynamically load @effect/sql-sqlite-bun when running under Bun, retaining native SQLite migrations and persistent caching.
    • If running in environments where Bun's proprietary SQLite engine is not present, gracefully fall back to disabledLayer rather than throwing an unhandled Cannot find module 'bun:sqlite' during startup.
  3. Runtime Guards:
    • In systemAppearance.ts, safely guard Bun.spawn so appearance detection falls back cleanly if Bun is undefined.
    • In ui/diff.ts, add a safe check for Bun.stringWidth.
  4. OpenTUI Native FFI Compatibility:
    • Support dynamic loading of @opentui/core FFI bindings across runtimes.

Verification

  • bun run typecheck: 0 errors (tsc --noEmit)
  • bun run lint: 0 warnings, 0 errors across 272 files (oxlint)
  • bun run format:check: all files formatted (oxfmt)
  • bun test: all 578 tests pass (578 pass, 0 fail across 57 files)

This branch has not been deployed

No deployments
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