ventiws 1.0.0-beta.3 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@ observable behaviour rather than its source. ventiws is not affiliated with the
12
12
  as the pinned contract, credited in
13
13
  [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
14
14
 
15
- **ventiws is at `1.0.0-beta.3`.** The surface may change between beta
15
+ **ventiws is at `1.0.0-beta.5`.** The surface may change between beta
16
16
  releases. What "beta" means here is bounded: the `ws` compatibility
17
17
  contract is tracked row by row in
18
18
  [COMPATIBILITY.md](COMPATIBILITY.md), and the four places ventiws knowingly
package/dist/index.cjs CHANGED
@@ -2,11 +2,34 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
+ //#region \0rolldown/runtime.js
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ //#endregion
5
27
  const require_logging = require("./logging.cjs");
6
28
  let node_http = require("node:http");
7
29
  let node_fs = require("node:fs");
8
30
  let node_module = require("node:module");
9
31
  let node_process = require("node:process");
32
+ node_process = __toESM(node_process, 1);
10
33
  let node_path = require("node:path");
11
34
  let node_url = require("node:url");
12
35
  let node_child_process = require("node:child_process");
@@ -15,53 +38,82 @@ let node_crypto = require("node:crypto");
15
38
  let node_https = require("node:https");
16
39
  let node_stream = require("node:stream");
17
40
  //#region src/binding/addon-error.ts
18
- function unloadableAddonMessage(path, platform, arch) {
19
- return `ventiws: the native addon at ${path} was found but could not be loaded, so it was built for a different ${platform}-${arch} or against a different libc. In a checkout the fix is "pnpm build:binding"; in an install, a package built for this platform. The loader's own error is the cause.`;
41
+ function runtimeHint(runtime) {
42
+ if (runtime === "deno") return " Deno loads native addons only from a local node_modules and the load needs --allow-ffi and --allow-read.";
43
+ if (runtime === "bun") return " Bun installs the optional binding with bun install.";
44
+ return "";
20
45
  }
21
- function missingAddonMessage(root, platform, arch, target, published) {
22
- const host = `${platform}-${arch}`;
23
- if (root === void 0) return `ventiws: the package layout is broken -- there is no package.json above the native addon, so the artifact for ${host} cannot be located. Reinstalling ventiws should restore it.`;
24
- if (target === void 0) return `ventiws: no published native addon for ${host}, so nothing was installed to load. A published ventiws ships a binary for ${published.join(", ")}. In a checkout, the fix is "pnpm build:binding", which builds the addon for this machine.`;
25
- return `ventiws: the native addon for ${target} is not installed under ${root}. It is an optional dependency, so npm skipped it for ${host}; an install that resolves no binary for this host needs a reinstall, and a checkout needs "pnpm build:binding".`;
46
+ function unloadableAddonMessage(path, platform, arch, runtime = "node") {
47
+ return `ventiws: the native addon at ${path} was found but could not be loaded, so it was built for a different ${platform}-${arch} or against a different libc. In a checkout the fix is "pnpm build:binding"; in an install, a package built for this platform. The loader's own error is the cause.` + runtimeHint(runtime);
26
48
  }
27
- //#endregion
28
- //#region src/binding/target.ts
29
- const ADDON_SCOPE = "@ventiws";
30
- const PUBLISHED_TARGETS = [
31
- "linux-x64-gnu",
32
- "linux-arm64-gnu",
33
- "linux-x64-musl",
34
- "darwin-x64",
35
- "darwin-arm64"
36
- ];
37
- function bindingPackageName(target) {
38
- return `${ADDON_SCOPE}/binding-${target}`;
39
- }
40
- function addonTarget(nodePlatform, nodeArch) {
41
- if (nodePlatform === "darwin") return darwinTarget(nodeArch);
42
- if (nodePlatform !== "linux") return void 0;
43
- const libc = isMuslLibc() ? "musl" : "gnu";
44
- if (nodeArch === "x64") return `linux-x64-${libc}`;
45
- if (nodeArch === "arm64" && libc === "gnu") return "linux-arm64-gnu";
46
- }
47
- function darwinTarget(nodeArch) {
48
- if (nodeArch === "x64") return "darwin-x64";
49
- if (nodeArch === "arm64") return "darwin-arm64";
50
- }
51
- function isMuslLibc() {
49
+ function missingAddonMessage(root, platform, arch, target, published, runtime = "node") {
50
+ const host = `${platform}-${arch}`;
51
+ if (root === void 0) return `ventiws: the package layout is broken -- there is no package.json above the native addon, so the artifact for ${host} cannot be located. Reinstalling ventiws should restore it.` + runtimeHint(runtime);
52
+ if (target === void 0) return `ventiws: no published native addon for ${host}, so nothing was installed to load. A published ventiws ships a binary for ${published.join(", ")}. In a checkout, the fix is "pnpm build:binding", which builds the addon for this machine.` + runtimeHint(runtime);
53
+ return `ventiws: the native addon for ${target} is not installed under ${root}. It is an optional dependency, so npm skipped it for ${host}; an install that resolves no binary for this host needs a reinstall, and a checkout needs "pnpm build:binding".` + runtimeHint(runtime);
54
+ }
55
+ //#endregion
56
+ //#region src/binding/runtime.ts
57
+ function runtimeGlobals() {
58
+ return globalThis;
59
+ }
60
+ function runtimeName() {
61
+ const versions = node_process.default.versions;
62
+ const globals = runtimeGlobals();
63
+ if (globals.Deno !== void 0 || versions.deno !== void 0) return "deno";
64
+ if (globals.Bun !== void 0 || versions.bun !== void 0) return "bun";
65
+ if (versions.node !== void 0) return "node";
66
+ return "unknown";
67
+ }
68
+ //#endregion
69
+ //#region src/binding/open.ts
70
+ const require$2 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
71
+ const DLOPEN_FLAGS = 0;
72
+ function openAddon(path) {
73
+ if (runtimeName() === "deno") return denoAddon(path);
74
+ return require$2(path);
75
+ }
76
+ function denoAddon(path) {
77
+ const addon = { exports: {} };
78
+ node_process.default.dlopen(addon, path, DLOPEN_FLAGS);
79
+ return addon.exports;
80
+ }
81
+ //#endregion
82
+ //#region src/binding/host-libc.ts
83
+ function hostLibc() {
84
+ if (node_process.default.platform !== "linux") return "gnu";
85
+ const declared = denoLibc() ?? reportLibc();
86
+ if (declared !== void 0) return declared;
87
+ return probeMusl() ? "musl" : "gnu";
88
+ }
89
+ function denoLibc() {
90
+ const build = runtimeGlobals().Deno?.build;
91
+ const marker = `${build?.env ?? ""} ${build?.target ?? ""}`;
92
+ if (marker.includes("musl")) return "musl";
93
+ if (marker.includes("gnu")) return "gnu";
94
+ }
95
+ function reportLibc() {
52
96
  const facts = reportFacts();
53
- if (facts?.glibcVersionRuntime !== void 0) return false;
54
- if (isMuslSharedObject(facts?.sharedObjects)) return true;
55
- return probeMuslBinary();
97
+ if (facts === void 0) return void 0;
98
+ if (facts.glibcVersionRuntime !== void 0) return "gnu";
99
+ if (isMuslSharedObject(facts.sharedObjects)) return "musl";
56
100
  }
57
101
  function reportFacts() {
58
- if (typeof process.report?.getReport !== "function") return void 0;
59
- const report = asRecord(asRecord(process.report.getReport()));
60
- if (report === void 0) return void 0;
102
+ try {
103
+ const report = node_process.default.report;
104
+ if (report === void 0 || typeof report.getReport !== "function") return void 0;
105
+ return narrowReport(report.getReport());
106
+ } catch {
107
+ return;
108
+ }
109
+ }
110
+ function narrowReport(raw) {
111
+ const record = asRecord(raw);
112
+ if (record === void 0) return void 0;
61
113
  const facts = {};
62
- const glibc = asRecord(report.header)?.glibcVersionRuntime;
114
+ const glibc = asRecord(record.header)?.glibcVersionRuntime;
63
115
  if (typeof glibc === "string") facts.glibcVersionRuntime = glibc;
64
- const objects = report.sharedObjects;
116
+ const objects = record.sharedObjects;
65
117
  if (Array.isArray(objects)) facts.sharedObjects = objects.filter((entry) => typeof entry === "string");
66
118
  return facts;
67
119
  }
@@ -81,13 +133,21 @@ function isMuslSharedObject(sharedObjects) {
81
133
  if (sharedObjects === void 0) return false;
82
134
  return sharedObjects.some((entry) => entry.includes("libc.musl-") || entry.includes("ld-musl-"));
83
135
  }
84
- function probeMuslBinary() {
136
+ function probeMusl() {
137
+ if (hasMuslLoader()) return true;
85
138
  try {
86
139
  return (0, node_fs.readFileSync)("/usr/bin/ldd", "utf8").includes("musl");
87
140
  } catch {
88
141
  return probeLddVersion();
89
142
  }
90
143
  }
144
+ function hasMuslLoader() {
145
+ try {
146
+ return (0, node_fs.readdirSync)("/lib").some((entry) => entry.startsWith("ld-musl-"));
147
+ } catch {
148
+ return false;
149
+ }
150
+ }
91
151
  function probeLddVersion() {
92
152
  try {
93
153
  return (0, node_child_process.execFileSync)("ldd", ["--version"], { encoding: "utf8" }).includes("musl");
@@ -95,8 +155,31 @@ function probeLddVersion() {
95
155
  return false;
96
156
  }
97
157
  }
158
+ //#endregion
159
+ //#region src/binding/target.ts
160
+ const ADDON_SCOPE = "@ventiws";
161
+ const PUBLISHED_TARGETS = [
162
+ "linux-x64-gnu",
163
+ "linux-arm64-gnu",
164
+ "linux-x64-musl",
165
+ "darwin-x64",
166
+ "darwin-arm64"
167
+ ];
168
+ function bindingPackageName(target) {
169
+ return `${ADDON_SCOPE}/binding-${target}`;
170
+ }
171
+ function addonTarget(nodePlatform, nodeArch, libc) {
172
+ if (nodePlatform === "darwin") return darwinTarget(nodeArch);
173
+ if (nodePlatform !== "linux") return void 0;
174
+ if (nodeArch === "x64") return `linux-x64-${libc}`;
175
+ if (nodeArch === "arm64" && libc === "gnu") return "linux-arm64-gnu";
176
+ }
177
+ function darwinTarget(nodeArch) {
178
+ if (nodeArch === "x64") return "darwin-x64";
179
+ if (nodeArch === "arm64") return "darwin-arm64";
180
+ }
98
181
  function hostAddonTarget() {
99
- return addonTarget(node_process.platform, node_process.arch);
182
+ return addonTarget(node_process.platform, node_process.arch, hostLibc());
100
183
  }
101
184
  //#endregion
102
185
  //#region src/binding/load.ts
@@ -107,10 +190,17 @@ const checkoutPath = [
107
190
  "ventiws.node"
108
191
  ];
109
192
  const legacyPath = ["dist", "ventiws.node"];
193
+ function pathExists(path) {
194
+ try {
195
+ return (0, node_fs.existsSync)(path);
196
+ } catch {
197
+ return false;
198
+ }
199
+ }
110
200
  function findPackageRoot(start) {
111
201
  let current = start;
112
202
  while (current !== void 0) {
113
- if ((0, node_fs.existsSync)((0, node_path.join)(current, "package.json"))) return current;
203
+ if (pathExists((0, node_path.join)(current, "package.json"))) return current;
114
204
  const parent = (0, node_path.dirname)(current);
115
205
  current = parent === current ? void 0 : parent;
116
206
  }
@@ -121,12 +211,12 @@ function packageRoot() {
121
211
  function checkoutArtifact(root) {
122
212
  if (root === void 0) return void 0;
123
213
  const candidate = (0, node_path.join)(root, ...checkoutPath);
124
- return (0, node_fs.existsSync)(candidate) ? candidate : void 0;
214
+ return pathExists(candidate) ? candidate : void 0;
125
215
  }
126
216
  function legacyArtifact(root) {
127
217
  if (root === void 0) return void 0;
128
218
  const candidate = (0, node_path.join)(root, ...legacyPath);
129
- return (0, node_fs.existsSync)(candidate) ? candidate : void 0;
219
+ return pathExists(candidate) ? candidate : void 0;
130
220
  }
131
221
  function installedBinding(target) {
132
222
  try {
@@ -145,20 +235,20 @@ function resolveAddon() {
145
235
  const root = packageRoot();
146
236
  const target = hostAddonTarget();
147
237
  const checkout = checkoutArtifact(root);
148
- if (checkout !== void 0) return requireAddon$1(checkout);
238
+ if (checkout !== void 0) return loadArtifact(checkout);
149
239
  if (target !== void 0) {
150
240
  const installed = installedBinding(target);
151
- if (installed !== void 0) return requireAddon$1(installed);
241
+ if (installed !== void 0) return loadArtifact(installed);
152
242
  }
153
243
  const legacy = legacyArtifact(root);
154
- if (legacy !== void 0) return requireAddon$1(legacy);
155
- throw new Error(missingAddonMessage(root, node_process.platform, node_process.arch, target, PUBLISHED_TARGETS));
244
+ if (legacy !== void 0) return loadArtifact(legacy);
245
+ throw new Error(missingAddonMessage(root, node_process.platform, node_process.arch, target, PUBLISHED_TARGETS, runtimeName()));
156
246
  }
157
- function requireAddon$1(path) {
247
+ function loadArtifact(path) {
158
248
  try {
159
- return require$1(path);
249
+ return openAddon(path);
160
250
  } catch (cause) {
161
- throw Object.assign(new Error(unloadableAddonMessage(path, node_process.platform, node_process.arch)), { cause });
251
+ throw Object.assign(new Error(unloadableAddonMessage(path, node_process.platform, node_process.arch, runtimeName())), { cause });
162
252
  }
163
253
  }
164
254
  //#endregion
@@ -385,7 +475,7 @@ function trackClient(state, socket) {
385
475
  }
386
476
  //#endregion
387
477
  //#region package.json
388
- var version = "1.0.0-beta.3";
478
+ var version = "1.0.0-beta.5";
389
479
  //#endregion
390
480
  //#region src/logging/lifecycle.ts
391
481
  const CONTROL = /\p{Cc}/gu;
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { fatal, info, ready, warn } from "./logging.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { STATUS_CODES, createServer, request } from "node:http";
4
- import { existsSync, readFileSync } from "node:fs";
5
- import { arch, platform } from "node:process";
4
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
5
+ import process$1, { arch, platform } from "node:process";
6
6
  import { dirname, join } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { execFileSync } from "node:child_process";
@@ -11,53 +11,82 @@ import { createHash, randomBytes } from "node:crypto";
11
11
  import { request as request$1 } from "node:https";
12
12
  import { Duplex } from "node:stream";
13
13
  //#region src/binding/addon-error.ts
14
- function unloadableAddonMessage(path, platform, arch) {
15
- return `ventiws: the native addon at ${path} was found but could not be loaded, so it was built for a different ${platform}-${arch} or against a different libc. In a checkout the fix is "pnpm build:binding"; in an install, a package built for this platform. The loader's own error is the cause.`;
14
+ function runtimeHint(runtime) {
15
+ if (runtime === "deno") return " Deno loads native addons only from a local node_modules and the load needs --allow-ffi and --allow-read.";
16
+ if (runtime === "bun") return " Bun installs the optional binding with bun install.";
17
+ return "";
16
18
  }
17
- function missingAddonMessage(root, platform, arch, target, published) {
18
- const host = `${platform}-${arch}`;
19
- if (root === void 0) return `ventiws: the package layout is broken -- there is no package.json above the native addon, so the artifact for ${host} cannot be located. Reinstalling ventiws should restore it.`;
20
- if (target === void 0) return `ventiws: no published native addon for ${host}, so nothing was installed to load. A published ventiws ships a binary for ${published.join(", ")}. In a checkout, the fix is "pnpm build:binding", which builds the addon for this machine.`;
21
- return `ventiws: the native addon for ${target} is not installed under ${root}. It is an optional dependency, so npm skipped it for ${host}; an install that resolves no binary for this host needs a reinstall, and a checkout needs "pnpm build:binding".`;
22
- }
23
- //#endregion
24
- //#region src/binding/target.ts
25
- const ADDON_SCOPE = "@ventiws";
26
- const PUBLISHED_TARGETS = [
27
- "linux-x64-gnu",
28
- "linux-arm64-gnu",
29
- "linux-x64-musl",
30
- "darwin-x64",
31
- "darwin-arm64"
32
- ];
33
- function bindingPackageName(target) {
34
- return `${ADDON_SCOPE}/binding-${target}`;
19
+ function unloadableAddonMessage(path, platform, arch, runtime = "node") {
20
+ return `ventiws: the native addon at ${path} was found but could not be loaded, so it was built for a different ${platform}-${arch} or against a different libc. In a checkout the fix is "pnpm build:binding"; in an install, a package built for this platform. The loader's own error is the cause.` + runtimeHint(runtime);
35
21
  }
36
- function addonTarget(nodePlatform, nodeArch) {
37
- if (nodePlatform === "darwin") return darwinTarget(nodeArch);
38
- if (nodePlatform !== "linux") return void 0;
39
- const libc = isMuslLibc() ? "musl" : "gnu";
40
- if (nodeArch === "x64") return `linux-x64-${libc}`;
41
- if (nodeArch === "arm64" && libc === "gnu") return "linux-arm64-gnu";
42
- }
43
- function darwinTarget(nodeArch) {
44
- if (nodeArch === "x64") return "darwin-x64";
45
- if (nodeArch === "arm64") return "darwin-arm64";
46
- }
47
- function isMuslLibc() {
22
+ function missingAddonMessage(root, platform, arch, target, published, runtime = "node") {
23
+ const host = `${platform}-${arch}`;
24
+ if (root === void 0) return `ventiws: the package layout is broken -- there is no package.json above the native addon, so the artifact for ${host} cannot be located. Reinstalling ventiws should restore it.` + runtimeHint(runtime);
25
+ if (target === void 0) return `ventiws: no published native addon for ${host}, so nothing was installed to load. A published ventiws ships a binary for ${published.join(", ")}. In a checkout, the fix is "pnpm build:binding", which builds the addon for this machine.` + runtimeHint(runtime);
26
+ return `ventiws: the native addon for ${target} is not installed under ${root}. It is an optional dependency, so npm skipped it for ${host}; an install that resolves no binary for this host needs a reinstall, and a checkout needs "pnpm build:binding".` + runtimeHint(runtime);
27
+ }
28
+ //#endregion
29
+ //#region src/binding/runtime.ts
30
+ function runtimeGlobals() {
31
+ return globalThis;
32
+ }
33
+ function runtimeName() {
34
+ const versions = process$1.versions;
35
+ const globals = runtimeGlobals();
36
+ if (globals.Deno !== void 0 || versions.deno !== void 0) return "deno";
37
+ if (globals.Bun !== void 0 || versions.bun !== void 0) return "bun";
38
+ if (versions.node !== void 0) return "node";
39
+ return "unknown";
40
+ }
41
+ //#endregion
42
+ //#region src/binding/open.ts
43
+ const require$1 = createRequire(import.meta.url);
44
+ const DLOPEN_FLAGS = 0;
45
+ function openAddon(path) {
46
+ if (runtimeName() === "deno") return denoAddon(path);
47
+ return require$1(path);
48
+ }
49
+ function denoAddon(path) {
50
+ const addon = { exports: {} };
51
+ process$1.dlopen(addon, path, DLOPEN_FLAGS);
52
+ return addon.exports;
53
+ }
54
+ //#endregion
55
+ //#region src/binding/host-libc.ts
56
+ function hostLibc() {
57
+ if (process$1.platform !== "linux") return "gnu";
58
+ const declared = denoLibc() ?? reportLibc();
59
+ if (declared !== void 0) return declared;
60
+ return probeMusl() ? "musl" : "gnu";
61
+ }
62
+ function denoLibc() {
63
+ const build = runtimeGlobals().Deno?.build;
64
+ const marker = `${build?.env ?? ""} ${build?.target ?? ""}`;
65
+ if (marker.includes("musl")) return "musl";
66
+ if (marker.includes("gnu")) return "gnu";
67
+ }
68
+ function reportLibc() {
48
69
  const facts = reportFacts();
49
- if (facts?.glibcVersionRuntime !== void 0) return false;
50
- if (isMuslSharedObject(facts?.sharedObjects)) return true;
51
- return probeMuslBinary();
70
+ if (facts === void 0) return void 0;
71
+ if (facts.glibcVersionRuntime !== void 0) return "gnu";
72
+ if (isMuslSharedObject(facts.sharedObjects)) return "musl";
52
73
  }
53
74
  function reportFacts() {
54
- if (typeof process.report?.getReport !== "function") return void 0;
55
- const report = asRecord(asRecord(process.report.getReport()));
56
- if (report === void 0) return void 0;
75
+ try {
76
+ const report = process$1.report;
77
+ if (report === void 0 || typeof report.getReport !== "function") return void 0;
78
+ return narrowReport(report.getReport());
79
+ } catch {
80
+ return;
81
+ }
82
+ }
83
+ function narrowReport(raw) {
84
+ const record = asRecord(raw);
85
+ if (record === void 0) return void 0;
57
86
  const facts = {};
58
- const glibc = asRecord(report.header)?.glibcVersionRuntime;
87
+ const glibc = asRecord(record.header)?.glibcVersionRuntime;
59
88
  if (typeof glibc === "string") facts.glibcVersionRuntime = glibc;
60
- const objects = report.sharedObjects;
89
+ const objects = record.sharedObjects;
61
90
  if (Array.isArray(objects)) facts.sharedObjects = objects.filter((entry) => typeof entry === "string");
62
91
  return facts;
63
92
  }
@@ -77,13 +106,21 @@ function isMuslSharedObject(sharedObjects) {
77
106
  if (sharedObjects === void 0) return false;
78
107
  return sharedObjects.some((entry) => entry.includes("libc.musl-") || entry.includes("ld-musl-"));
79
108
  }
80
- function probeMuslBinary() {
109
+ function probeMusl() {
110
+ if (hasMuslLoader()) return true;
81
111
  try {
82
112
  return readFileSync("/usr/bin/ldd", "utf8").includes("musl");
83
113
  } catch {
84
114
  return probeLddVersion();
85
115
  }
86
116
  }
117
+ function hasMuslLoader() {
118
+ try {
119
+ return readdirSync("/lib").some((entry) => entry.startsWith("ld-musl-"));
120
+ } catch {
121
+ return false;
122
+ }
123
+ }
87
124
  function probeLddVersion() {
88
125
  try {
89
126
  return execFileSync("ldd", ["--version"], { encoding: "utf8" }).includes("musl");
@@ -91,8 +128,31 @@ function probeLddVersion() {
91
128
  return false;
92
129
  }
93
130
  }
131
+ //#endregion
132
+ //#region src/binding/target.ts
133
+ const ADDON_SCOPE = "@ventiws";
134
+ const PUBLISHED_TARGETS = [
135
+ "linux-x64-gnu",
136
+ "linux-arm64-gnu",
137
+ "linux-x64-musl",
138
+ "darwin-x64",
139
+ "darwin-arm64"
140
+ ];
141
+ function bindingPackageName(target) {
142
+ return `${ADDON_SCOPE}/binding-${target}`;
143
+ }
144
+ function addonTarget(nodePlatform, nodeArch, libc) {
145
+ if (nodePlatform === "darwin") return darwinTarget(nodeArch);
146
+ if (nodePlatform !== "linux") return void 0;
147
+ if (nodeArch === "x64") return `linux-x64-${libc}`;
148
+ if (nodeArch === "arm64" && libc === "gnu") return "linux-arm64-gnu";
149
+ }
150
+ function darwinTarget(nodeArch) {
151
+ if (nodeArch === "x64") return "darwin-x64";
152
+ if (nodeArch === "arm64") return "darwin-arm64";
153
+ }
94
154
  function hostAddonTarget() {
95
- return addonTarget(platform, arch);
155
+ return addonTarget(platform, arch, hostLibc());
96
156
  }
97
157
  //#endregion
98
158
  //#region src/binding/load.ts
@@ -103,10 +163,17 @@ const checkoutPath = [
103
163
  "ventiws.node"
104
164
  ];
105
165
  const legacyPath = ["dist", "ventiws.node"];
166
+ function pathExists(path) {
167
+ try {
168
+ return existsSync(path);
169
+ } catch {
170
+ return false;
171
+ }
172
+ }
106
173
  function findPackageRoot(start) {
107
174
  let current = start;
108
175
  while (current !== void 0) {
109
- if (existsSync(join(current, "package.json"))) return current;
176
+ if (pathExists(join(current, "package.json"))) return current;
110
177
  const parent = dirname(current);
111
178
  current = parent === current ? void 0 : parent;
112
179
  }
@@ -117,12 +184,12 @@ function packageRoot() {
117
184
  function checkoutArtifact(root) {
118
185
  if (root === void 0) return void 0;
119
186
  const candidate = join(root, ...checkoutPath);
120
- return existsSync(candidate) ? candidate : void 0;
187
+ return pathExists(candidate) ? candidate : void 0;
121
188
  }
122
189
  function legacyArtifact(root) {
123
190
  if (root === void 0) return void 0;
124
191
  const candidate = join(root, ...legacyPath);
125
- return existsSync(candidate) ? candidate : void 0;
192
+ return pathExists(candidate) ? candidate : void 0;
126
193
  }
127
194
  function installedBinding(target) {
128
195
  try {
@@ -141,20 +208,20 @@ function resolveAddon() {
141
208
  const root = packageRoot();
142
209
  const target = hostAddonTarget();
143
210
  const checkout = checkoutArtifact(root);
144
- if (checkout !== void 0) return requireAddon$1(checkout);
211
+ if (checkout !== void 0) return loadArtifact(checkout);
145
212
  if (target !== void 0) {
146
213
  const installed = installedBinding(target);
147
- if (installed !== void 0) return requireAddon$1(installed);
214
+ if (installed !== void 0) return loadArtifact(installed);
148
215
  }
149
216
  const legacy = legacyArtifact(root);
150
- if (legacy !== void 0) return requireAddon$1(legacy);
151
- throw new Error(missingAddonMessage(root, platform, arch, target, PUBLISHED_TARGETS));
217
+ if (legacy !== void 0) return loadArtifact(legacy);
218
+ throw new Error(missingAddonMessage(root, platform, arch, target, PUBLISHED_TARGETS, runtimeName()));
152
219
  }
153
- function requireAddon$1(path) {
220
+ function loadArtifact(path) {
154
221
  try {
155
- return require(path);
222
+ return openAddon(path);
156
223
  } catch (cause) {
157
- throw Object.assign(new Error(unloadableAddonMessage(path, platform, arch)), { cause });
224
+ throw Object.assign(new Error(unloadableAddonMessage(path, platform, arch, runtimeName())), { cause });
158
225
  }
159
226
  }
160
227
  //#endregion
@@ -381,7 +448,7 @@ function trackClient(state, socket) {
381
448
  }
382
449
  //#endregion
383
450
  //#region package.json
384
- var version = "1.0.0-beta.3";
451
+ var version = "1.0.0-beta.5";
385
452
  //#endregion
386
453
  //#region src/logging/lifecycle.ts
387
454
  const CONTROL = /\p{Cc}/gu;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ventiws",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.5",
4
4
  "description": "A drop-in replacement for ws for Node.js, built on the first-party µWebZockets Zig engine via napi-zig.",
5
5
  "homepage": "https://github.com/farbenbuilds/ventiws#readme",
6
6
  "bugs": {
@@ -34,10 +34,10 @@
34
34
  "node": ">=22.12.0"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@ventiws/binding-darwin-arm64": "1.0.0-beta.3",
38
- "@ventiws/binding-darwin-x64": "1.0.0-beta.3",
39
- "@ventiws/binding-linux-arm64-gnu": "1.0.0-beta.3",
40
- "@ventiws/binding-linux-x64-gnu": "1.0.0-beta.3",
41
- "@ventiws/binding-linux-x64-musl": "1.0.0-beta.3"
37
+ "@ventiws/binding-darwin-arm64": "1.0.0-beta.5",
38
+ "@ventiws/binding-darwin-x64": "1.0.0-beta.5",
39
+ "@ventiws/binding-linux-arm64-gnu": "1.0.0-beta.5",
40
+ "@ventiws/binding-linux-x64-gnu": "1.0.0-beta.5",
41
+ "@ventiws/binding-linux-x64-musl": "1.0.0-beta.5"
42
42
  }
43
43
  }