Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,14 @@ differs from tsgo itself — file an issue with a minimal repro.

### Missing native bridge

Error mentioning `bridge.dylib` / `bridge.so` / `bridge.dll` / "unsupported platform" →
see [Platform support](#platform-support) (build from source, or use a `link:` install
built with `npm run setup`).
"bridge shared library not found" → see [Platform support](#platform-support) (build
from source, or use a `link:` install built with `npm run setup`).

"bridge.node was built for typescript-native-bridge X, this bundle is Y" → the loaded
native bridge comes from another release (typically a stale
`@typescript-native-bridge/<platform>-<arch>` left in a package-manager store). Reinstall
so the platform package matches the main package; from a source checkout, run
`npm run build:bridge`.

### Debug a slow run

Expand Down
96 changes: 48 additions & 48 deletions patches/typescript-go/0001-bridge-inplace.patch

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion patches/typescript-go/0002-osvfs-executable-fallback.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/internal/vfs/osvfs/os.go b/internal/vfs/osvfs/os.go
index 7db6f338b..a2b8c5bb9 100644
index 7db6f338b8..a2b8c5bb98 100644
--- a/internal/vfs/osvfs/os.go
+++ b/internal/vfs/osvfs/os.go
@@ -60,7 +60,12 @@ var isFileSystemCaseSensitive = func() bool {
Expand Down
10 changes: 5 additions & 5 deletions patches/typescript-go/0004-api-surface.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/_packages/native-preview/src/api/async/api.ts b/_packages/native-preview/src/api/async/api.ts
index 1c8b5d7f0..a131f9ea7 100644
index 1c8b5d7f0f..a131f9ea70 100644
--- a/_packages/native-preview/src/api/async/api.ts
+++ b/_packages/native-preview/src/api/async/api.ts
@@ -49,6 +49,7 @@ import type {
Expand Down Expand Up @@ -1815,7 +1815,7 @@ index 1c8b5d7f0..a131f9ea7 100644

get hasRestParameter(): boolean {
diff --git a/_packages/native-preview/src/api/sync/api.ts b/_packages/native-preview/src/api/sync/api.ts
index 1a0296ac7..25b87f6ad 100644
index 1a0296ac77..25b87f6ad0 100644
--- a/_packages/native-preview/src/api/sync/api.ts
+++ b/_packages/native-preview/src/api/sync/api.ts
@@ -62,6 +62,8 @@ import type {
Expand Down Expand Up @@ -4381,7 +4381,7 @@ index 1a0296ac7..25b87f6ad 100644

get hasRestParameter(): boolean {
diff --git a/_packages/native-preview/test/sync/api.test.ts b/_packages/native-preview/test/sync/api.test.ts
index 6a90030eb..fc58b512a 100644
index 6a90030eb2..fc58b512a8 100644
--- a/_packages/native-preview/test/sync/api.test.ts
+++ b/_packages/native-preview/test/sync/api.test.ts
@@ -3459,6 +3459,38 @@ export * from "./inner";
Expand Down Expand Up @@ -4424,7 +4424,7 @@ index 6a90030eb..fc58b512a 100644
const docFiles = {
"/tsconfig.json": JSON.stringify({ compilerOptions: { strict: true } }),
diff --git a/internal/api/proto.go b/internal/api/proto.go
index 0917c385d..8f640c977 100644
index 0917c385d6..8f640c9775 100644
--- a/internal/api/proto.go
+++ b/internal/api/proto.go
@@ -67,37 +67,81 @@ const (
Expand Down Expand Up @@ -6195,7 +6195,7 @@ index 0917c385d..8f640c977 100644
type GetProjectDiagnosticsParams struct {
Snapshot SnapshotID `json:"snapshot"`
diff --git a/internal/api/session.go b/internal/api/session.go
index 7e29c44b6..eb237f5b4 100644
index 7e29c44b6f..eb237f5b4f 100644
--- a/internal/api/session.go
+++ b/internal/api/session.go
@@ -3,6 +3,7 @@ package api
Expand Down
2 changes: 1 addition & 1 deletion patches/typescript-go/0005-noembed-lib-path.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/internal/bundled/noembed.go b/internal/bundled/noembed.go
index 39b204b45..5f0052499 100644
index 39b204b450..5f0052499f 100644
--- a/internal/bundled/noembed.go
+++ b/internal/bundled/noembed.go
@@ -6,6 +6,7 @@ import (
Expand Down
14 changes: 14 additions & 0 deletions patches/typescript-go/overlay/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@ func startOrphanWatchdog() {
})
}

// bridgeVersion is the typescript-native-bridge package version this binary
// was built from, stamped by tools/build-bridge.js (-ldflags -X). The JS
// loader refuses a bridge whose stamp differs from its own package.json: a
// stale platform package would otherwise pair one release's JS with
// another's wire format and fail far from the cause.
var bridgeVersion string

// BridgeVersion returns bridgeVersion as a malloc'd string the shim frees.
//
//export BridgeVersion
func BridgeVersion() *C.char {
return C.CString(bridgeVersion)
}

// BridgeSetLibPath hands the JS host's bundled-lib dir to Go — the only
// channel that reaches Go from every host thread (issue #37: worker
// process.env writes never touch the environ Go reads, so an env-var
Expand Down
5 changes: 5 additions & 0 deletions patches/typescript-go/overlay/bridge/napi_shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static void pin_module_in_process(void) {
// cgo-exported Go entry points (bridge.go).
struct BridgeText { char* data; long long kind; };
struct BridgeBinary { void* data; long long len; unsigned long long handle; long long kind; };
extern char* BridgeVersion(void);
extern char* BridgeSetLibPath(char* dir);
extern long long BridgeNewSession(char* cwd);
extern struct BridgeText BridgeCall(int64_t session, char* method, char* paramsJson);
Expand Down Expand Up @@ -529,6 +530,10 @@ NAPI_MODULE_INIT() {
napi_throw_error(env, NULL, "tnb bridge: out of memory");
return NULL;
}
// `version`: the build stamp the JS loader checks before any other call.
char* version = BridgeVersion();
napi_set_named_property(env, exports, "version", js_string(env, version));
free(version);
set_fn(env, exports, "setLibPath", fn_set_lib_path);
set_fn(env, exports, "newSession", fn_new_session);
set_fn(env, exports, "call", fn_call);
Expand Down
Loading
Loading