@@ -75,15 +75,23 @@ const EXPECTED: Partial<Record<string, PlatformExpectation>> = {
7575} ;
7676
7777const SIDECAR_BINARY = argv [ 2 ] === 'win' ? 'linkcode-pty.exe' : 'linkcode-pty' ;
78+ /** Node's platform name per builder platform — the token better-sqlite3 names its prebuilds by. */
79+ const NODE_PLATFORM : Partial < Record < string , string > > = {
80+ mac : 'darwin' ,
81+ win : 'win32' ,
82+ linux : 'linux' ,
83+ } ;
7884/**
79- * better-sqlite3's compiled binding, smartUnpacked beside the asar; the daemon requires it at boot.
80- * A build where @electron/rebuild silently rebuilt nothing ships the wrong CPU/ABI and every client
81- * shows "Unable to connect to the daemon" (broke every release through 0.2.1; see package-app.mts).
85+ * better-sqlite3's binding, smartUnpacked beside the asar; the daemon requires it at boot. Since
86+ * v13 it is one NAPI prebuild per platform-arch shipped in the tarball (`build/Release` is only
87+ * written when node-gyp actually compiles, which it now skips), so what breaks is the staging
88+ * prune keeping the wrong target — every client then shows "Unable to connect to the daemon".
8289 */
83- const NATIVE_BINDING = 'node_modules/better-sqlite3/build/Release/better_sqlite3.node' . replaceAll (
84- '/' ,
85- sep ,
86- ) ;
90+ function sqliteBinding ( platform : string , arch : string ) : string | null {
91+ const nodePlatform = NODE_PLATFORM [ platform ] ;
92+ if ( nodePlatform === undefined ) return null ;
93+ return `node_modules/better-sqlite3/prebuilds/${ nodePlatform } -${ arch } .node` . replaceAll ( '/' , sep ) ;
94+ }
8795/**
8896 * napi-rs platform-package triple for the target this artifact was packed for. napi-rs ships one
8997 * optional dependency per triple and installs only the host's, so a cross-packed build carries no
@@ -183,8 +191,10 @@ function readBinaryArch(file: string): 'x64' | 'arm64' | null {
183191 */
184192function verifyNativeBindings ( platform : string , resourceDir : string , problems : string [ ] ) : void {
185193 const expectedArch = resourceDir . includes ( 'arm64' ) ? 'arm64' : 'x64' ;
194+ const sqlite = sqliteBinding ( platform , expectedArch ) ;
186195 const keyring = keyringBinding ( platform , expectedArch ) ;
187- const bindings : Array < [ label : string , path : string ] > = [ [ 'better-sqlite3' , NATIVE_BINDING ] ] ;
196+ const bindings : Array < [ label : string , path : string ] > = [ ] ;
197+ if ( sqlite !== null ) bindings . push ( [ 'better-sqlite3' , sqlite ] ) ;
188198 if ( keyring !== null ) bindings . push ( [ '@napi-rs/keyring' , keyring ] ) ;
189199
190200 for ( const [ label , relative ] of bindings ) {
0 commit comments