diff --git a/bridge/bin/build.js b/bridge/bin/build.js index bd47e57..32726cd 100644 --- a/bridge/bin/build.js +++ b/bridge/bin/build.js @@ -35,7 +35,7 @@ const argv = await yargs() }) .option("node-version", { describe: "Node.js version to target", - default: "16" + default: "22" }) .conflicts("use-pkg", "package") .parse(process.argv); @@ -111,7 +111,7 @@ async function build() { * Workaround for pkg asset detection * https://github.com/thibauts/node-castv2/issues/46 */ - assets: "../../node_modules/castv2/lib/cast_channel.proto" + assets: "../../../node_modules/castv2/lib/cast_channel.proto" } }; diff --git a/bridge/src/bridge/components/cast/deviceBrowser.ts b/bridge/src/bridge/components/cast/deviceBrowser.ts index 844b1b6..9d58bcb 100644 --- a/bridge/src/bridge/components/cast/deviceBrowser.ts +++ b/bridge/src/bridge/components/cast/deviceBrowser.ts @@ -1,5 +1,5 @@ import { EventEmitter } from "events"; -import { DnsSdBrowser } from "../../../dns_sd"; +import { DnsSdBrowser } from "../../../dns_sd/index"; import type { ReceiverDevice } from "../../messagingTypes"; /** diff --git a/bridge/src/dns_sd/index.ts b/bridge/src/dns_sd/index.ts index 7afb4cc..8811cd3 100644 --- a/bridge/src/dns_sd/index.ts +++ b/bridge/src/dns_sd/index.ts @@ -1,6 +1,20 @@ +import path from "path"; import { EventEmitter } from "events"; -const native = require("bindings")("dns_sd"); +let native: any; +if ((process as any).pkg) { + // Seems to be some breaking change with the way bindings paths are resolved + // in @yao-pkg/pkg, so use `process.dlopen` directly when running in a pkg + // bundle. + native = { exports: {} } as any; + process.dlopen( + native, + path.join(path.dirname(process.execPath), "dns_sd.node") + ); + native = native.exports; +} else { + native = require("bindings")("dns_sd"); +} export interface Service { /** Service instance name */