singularity-forge/packages/native/src
Tom Boucher 97d589c200 fix: graceful fallback when native addon is unavailable on unsupported platforms (#1225)
* fix: graceful fallback when native addon is unavailable on unsupported platforms

On platforms without a pre-built native binary (e.g., win32-arm64),
the native loader threw at import time, crashing the entire application.

Now returns a Proxy object that:
- Allows the import to succeed (no startup crash)
- Throws per-function when a native function is actually called
- Individual consumers (GSD parser bridge, fuzzy find, autocomplete)
  already wrap native calls in try/catch and fall back to JS
  implementations

Also exports nativeAvailable boolean for consumers that want to check
upfront. Prints a one-line warning to stderr on startup.

GSD is now fully functional on unsupported platforms — just slower for
file parsing, grep, and fuzzy search.

Fixes #1223

* fix: remove __nativeUnavailable from exported type to fix TS2352 cast errors

The __nativeUnavailable boolean property on the native type caused
TS2352 errors in consumers that cast native as Record<string, Function>
(ast/index.ts, diff/index.ts, gsd-parser/index.ts).

Replaced with a module-level _loadedSuccessfully flag and exported
nativeAvailable boolean. The proxy no longer needs a sentinel property.
2026-03-18 13:28:01 -06:00
..
__tests__ perf: optimize discovery and interactive hot paths 2026-03-14 16:03:44 -05:00
ast feat: add native ast module with ast-grep structural search and rewrite 2026-03-13 13:02:29 -06:00
clipboard feat: add native clipboard module with arboard backend (#228) 2026-03-13 12:48:27 -06:00
diff feat: add native Rust diff engine for edit tool 2026-03-13 14:11:40 -06:00
fd perf: optimize discovery and interactive hot paths 2026-03-14 16:03:44 -05:00
glob fix: resolve TypeScript build errors in glob callback type and hashline test import 2026-03-13 13:47:33 -06:00
grep perf: optimize discovery and interactive hot paths 2026-03-14 16:03:44 -05:00
gsd-parser feat: add native Rust GSD file parser for .gsd/ directory parsing 2026-03-13 14:12:17 -06:00
highlight feat: add syntect-based syntax highlighting module to native engine (#227) 2026-03-13 12:47:02 -06:00
html feat: add html-to-markdown native module 2026-03-13 12:40:42 -06:00
image feat: add native image module — decode, encode, and resize via Rust image crate 2026-03-13 12:51:49 -06:00
json-parse feat: opus 4.6 1M default, model selector UX, Discord onboarding (#290) 2026-03-14 08:43:56 -06:00
ps feat: add cross-platform process tree kill module (ps) (#225) 2026-03-13 12:43:50 -06:00
stream-process feat: native Rust bash stream processor for single-pass chunk processing (#271) 2026-03-13 16:34:17 -06:00
text feat: add ANSI-aware text measurement and slicing native module 2026-03-13 12:42:42 -06:00
truncate feat: native Rust output truncation module (#268) 2026-03-13 16:48:49 -06:00
ttsr feat: add native Rust TTSR regex engine via RegexSet 2026-03-13 13:57:12 -06:00
xxhash Fix execute-task loop detection: adaptive reconciliation instead of hard stop (#342) 2026-03-14 07:26:10 -06:00
index.ts Fix execute-task loop detection: adaptive reconciliation instead of hard stop (#342) 2026-03-14 07:26:10 -06:00
native.ts fix: graceful fallback when native addon is unavailable on unsupported platforms (#1225) 2026-03-18 13:28:01 -06:00