Files
fivenode_go/cmd
CharlesKWON 959b37e9cd feat(napi P3): PRG -> real Node/npm in-process via N-API object dispatch
hbrtl_ext/napibridge reimplements the C++ fivenode TFNModule in Go: it calls
the addon's registered C callbacks (npmRequire/npmCall/npmMethods/npmEnd) over
cgo. FN_REQUIRE(module) gets a handle, enumerates its methods, and builds a PRG
object whose method closures proxy oObj:method(args) to Node; results decode as
scalar / native array|hash / nested object handle (e.g. Buffer). The capi shim
forwards tfn_register_callbacks -> napibridge.StoreCallbacks. Calls run on the
node main thread (sync handleRequest), so the direct tfn_npm_* path needs no
marshaling.

Verified end-to-end (node -> addon -> Go libfivenode -> PRG):
- builtin: oOs:hostname()/platform()/arch() -> real values; oOs:cpus() -> native
  array, Len()=10.
- real npm: oQR:imageSync() on qr-image (which goja could NOT run) -> Buffer
  handle -> :toString("utf8") -> valid 1138-byte SVG.

Full npm is now reachable in-process. P4 (async/Promise via worker + npmAwait)
remains for async methods like qrcode.toString.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 23:04:04 +09:00
..