@pkmn/engine 0.1.0-dev.04a96f24 → 0.1.0-dev.059a0591

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.
Files changed (41) hide show
  1. package/README.md +5 -4
  2. package/build/pkg/addon/browser.js +4 -1
  3. package/build/pkg/addon/browser.js.map +1 -1
  4. package/build/pkg/addon/node.js +3 -0
  5. package/build/pkg/addon/node.js.map +1 -1
  6. package/build/pkg/addon/wasm.js +41 -9
  7. package/build/pkg/addon/wasm.js.map +1 -1
  8. package/build/pkg/addon.d.ts +5 -5
  9. package/build/pkg/addon.js +8 -17
  10. package/build/pkg/addon.js.map +1 -1
  11. package/build/pkg/data/layout.json +15 -2
  12. package/build/pkg/data/protocol.json +23 -9
  13. package/build/pkg/gen1.d.ts +15 -18
  14. package/build/pkg/gen1.js +11 -12
  15. package/build/pkg/gen1.js.map +1 -1
  16. package/build/pkg/index.d.ts +37 -100
  17. package/build/pkg/index.js +6 -68
  18. package/build/pkg/index.js.map +1 -1
  19. package/build/tools/debug.js +0 -1
  20. package/build/tools/debug.js.map +1 -1
  21. package/build/tools/display/index.js +1 -0
  22. package/build/tools/display/index.js.map +1 -1
  23. package/build/tools/display/ui.jsx.map +1 -1
  24. package/build/tools/display/util.js +16 -1
  25. package/build/tools/display/util.js.map +1 -1
  26. package/build.zig +118 -27
  27. package/package.json +23 -124
  28. package/src/bin/install-pkmn-engine +3 -2
  29. package/src/lib/bindings/c.zig +254 -0
  30. package/src/lib/bindings/node.zig +121 -0
  31. package/src/lib/bindings/wasm.zig +59 -0
  32. package/src/lib/common/array.zig +1 -1
  33. package/src/lib/common/optional.zig +1 -1
  34. package/src/lib/common/options.zig +2 -0
  35. package/src/lib/common/util.zig +1 -1
  36. package/src/lib/gen1/calc.zig +9 -9
  37. package/src/lib/gen1/mechanics.zig +52 -21
  38. package/src/lib/gen2/mechanics.zig +22 -11
  39. package/src/lib/node.zig +2 -113
  40. package/src/lib/pkmn.zig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AI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE;IACxE,CAAC,CAAC,KAAK,CAAC;AAFG,QAAA,MAAM,UAET;AAEH,MAAM,OAAO,GAAG,CAAC,MAA4B,EAAE,OAAoB,EAAE,EAAE,CAAC,CAAC;IAC9E,EAAE,EAAE;QACF,GAAG,CAAC,GAAW,EAAE,GAAW;YAC1B,IAAI,GAAG,KAAK,CAAC;gBAAE,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACtC,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;YACvE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QACD,KAAK,CAAC,GAAW,EAAE,GAAW;YAC5B,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC;QACnC,CAAC;KACF;CACF,CAAC,CAAC;AAZU,QAAA,OAAO,WAYjB"}
package/build.zig CHANGED
@@ -27,8 +27,14 @@ pub fn module(b: *std.Build, options: Options) *std.Build.Module {
27
27
  build_options.addOption(?bool, "chance", options.chance);
28
28
  build_options.addOption(?bool, "calc", options.calc);
29
29
 
30
- const root_source_file = .{ .cwd_relative = dirname ++ "/src/lib/pkmn.zig" };
31
- const imports = &.{.{ .name = "build_options", .module = build_options.createModule() }};
30
+ const root_source_file: std.Build.LazyPath =
31
+ .{ .cwd_relative = dirname ++ "/src/lib/pkmn.zig" };
32
+ const Import = if (@hasDecl(std.Build.Module, "Import"))
33
+ std.Build.Module.Import
34
+ else
35
+ std.Build.ModuleDependency;
36
+ const imports: []const Import =
37
+ &.{.{ .name = "build_options", .module = build_options.createModule() }};
32
38
  return b.createModule(if (@hasDecl(std.Build, "CreateModuleOptions"))
33
39
  .{ .source_file = root_source_file, .dependencies = imports }
34
40
  else
@@ -43,6 +49,10 @@ pub fn build(b: *std.Build) !void {
43
49
  const node_headers = b.option([]const u8, "node-headers", "Path to node-headers");
44
50
  const node_import_lib =
45
51
  b.option([]const u8, "node-import-library", "Path to node import library (Windows)");
52
+ const demo = if (try exists("src/tools/demo.zig"))
53
+ b.option(bool, "demo", "Build the demo library") orelse false
54
+ else
55
+ false;
46
56
  const wasm = b.option(bool, "wasm", "Build a WASM library") orelse false;
47
57
  const wasm_stack_size =
48
58
  b.option(u64, "wasm-stack-size", "The size of WASM stack") orelse std.wasm.page_size;
@@ -73,6 +83,7 @@ pub fn build(b: *std.Build) !void {
73
83
  const log = b.option(bool, "log", "Enable protocol message logging") orelse false;
74
84
  const chance = b.option(bool, "chance", "Enable update probability tracking") orelse false;
75
85
  const calc = b.option(bool, "calc", "Enable damage calculator support") orelse false;
86
+ const extra = b.option([]const []const u8, "option", "Enable extra option");
76
87
 
77
88
  const options = b.addOptions();
78
89
  options.addOption(?bool, "showdown", showdown);
@@ -80,17 +91,37 @@ pub fn build(b: *std.Build) !void {
80
91
  options.addOption(?bool, "chance", chance);
81
92
  options.addOption(?bool, "calc", calc);
82
93
 
94
+ if (extra) |opts| {
95
+ for (opts) |opt| {
96
+ if (std.mem.indexOfScalar(u8, opt, '=')) |i| {
97
+ options.addOption(?bool, opt[0..i], if (std.mem.eql(u8, opt[i + 1 ..], "true"))
98
+ true
99
+ else if (std.mem.eql(u8, opt[i + 1 ..], "false"))
100
+ false
101
+ else {
102
+ std.log.err("Invalid option: {s}\n", .{opt});
103
+ return error.InvalidOption;
104
+ });
105
+ } else {
106
+ options.addOption(?bool, opt, true);
107
+ }
108
+ }
109
+ }
110
+
83
111
  const name = if (showdown) "pkmn-showdown" else "pkmn";
84
112
 
85
- const pkmn = if (@hasDecl(std.Build, "CreateModuleOptions")) null else b.addModule("pkmn", .{
86
- .root_source_file = if (has_path)
87
- .{ .path = "src/lib/pkmn.zig" }
88
- else
89
- b.path("src/lib/pkmn.zig"),
90
- .optimize = optimize,
91
- .target = target,
92
- .imports = &.{.{ .name = "build_options", .module = options.createModule() }},
93
- });
113
+ const pkmn: ?*std.Build.Module = if (@hasDecl(std.Build, "CreateModuleOptions"))
114
+ null
115
+ else
116
+ b.addModule("pkmn", .{
117
+ .root_source_file = if (has_path)
118
+ .{ .path = "src/lib/pkmn.zig" }
119
+ else
120
+ b.path("src/lib/pkmn.zig"),
121
+ .optimize = optimize,
122
+ .target = target,
123
+ .imports = &.{.{ .name = "build_options", .module = options.createModule() }},
124
+ });
94
125
 
95
126
  var c = false;
96
127
  if (node_headers) |headers| {
@@ -131,7 +162,18 @@ pub fn build(b: *std.Build) !void {
131
162
  // rename the file ourself in install-pkmn-engine
132
163
  b.installArtifact(lib);
133
164
  } else if (wasm) {
134
- try buildWasm(b, name, "src/lib/wasm.zig", optimize, strip, pic, wasm_stack_size, options);
165
+ const path = "src/lib/wasm.zig";
166
+ try buildWasm(b, name, path, optimize, strip, pic, wasm_stack_size, null, options);
167
+ } else if (demo) {
168
+ const path = "src/tools/demo.zig";
169
+ const n = if (showdown) "demo-showdown" else "demo";
170
+ const mod = pkmn orelse module(b, .{
171
+ .showdown = showdown,
172
+ .log = log,
173
+ .chance = chance,
174
+ .calc = calc,
175
+ });
176
+ try buildWasm(b, n, path, optimize, strip, pic, wasm_stack_size, mod, options);
135
177
  } else if (dynamic) {
136
178
  const path = if (has_path) .{ .path = "src/lib/c.zig" } else b.path("src/lib/c.zig");
137
179
  const lib = b.addSharedLibrary(if (force_pic) .{
@@ -226,7 +268,7 @@ pub fn build(b: *std.Build) !void {
226
268
  b.installFile(file, b.fmt("share/pkgconfig/{s}", .{pc}));
227
269
  }
228
270
 
229
- const config = .{
271
+ const config: Config = .{
230
272
  .target = target,
231
273
  .optimize = optimize,
232
274
  .pic = pic,
@@ -292,6 +334,7 @@ fn buildWasm(
292
334
  strip: ?bool,
293
335
  pic: ?bool,
294
336
  wasm_stack_size: u64,
337
+ import: ?*std.Build.Module,
295
338
  options: anytype,
296
339
  ) !void {
297
340
  const entry = @hasDecl(Step.Compile, "Entry");
@@ -299,10 +342,37 @@ fn buildWasm(
299
342
  .ReleaseFast, .ReleaseSafe => .ReleaseSmall,
300
343
  else => optimize,
301
344
  };
345
+ // https://webassembly.org/features/
346
+ var features = std.Target.wasm.featureSet(&.{
347
+ .atomics,
348
+ .bulk_memory,
349
+ // .exception_handling,
350
+ .extended_const,
351
+ // .half_precision,
352
+ // .multimemory,
353
+ .mutable_globals,
354
+ .nontrapping_fptoint,
355
+ .reference_types,
356
+ // .relaxed_simd,
357
+ .sign_ext,
358
+ .simd128,
359
+ // .tail_call,
360
+ });
361
+ if (builtin.zig_version.order(try std.SemanticVersion.parse("0.12.0")) != .lt) {
362
+ features.addFeature(@intFromEnum(std.Target.wasm.Feature.multivalue));
363
+ }
302
364
  const freestanding = if (@hasDecl(std.Build, "resolveTargetQuery"))
303
- b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding })
365
+ b.resolveTargetQuery(.{
366
+ .cpu_arch = .wasm32,
367
+ .os_tag = .freestanding,
368
+ .cpu_features_add = features,
369
+ })
304
370
  else
305
- ResolvedTarget{ .cpu_arch = .wasm32, .os_tag = .freestanding };
371
+ ResolvedTarget{
372
+ .cpu_arch = .wasm32,
373
+ .os_tag = .freestanding,
374
+ .cpu_features_add = features,
375
+ };
306
376
  const path = if (has_path) .{ .path = root_src_file } else b.path(root_src_file);
307
377
  const bin = if (entry) bin: {
308
378
  const exe = b.addExecutable(if (force_pic) .{
@@ -318,7 +388,11 @@ fn buildWasm(
318
388
  .strip = strip,
319
389
  .pic = pic,
320
390
  });
321
- (if (root_module) exe.root_module else exe).export_symbol_names = try exports(b);
391
+
392
+ var file = try std.fs.cwd().openFile(root_src_file, .{});
393
+ defer file.close();
394
+ const bytes = try file.readToEndAlloc(b.allocator, std.math.maxInt(usize));
395
+ (if (root_module) exe.root_module else exe).export_symbol_names = try exports(b, bytes);
322
396
  exe.entry = .disabled;
323
397
  break :bin exe;
324
398
  } else bin: {
@@ -331,6 +405,13 @@ fn buildWasm(
331
405
  lib.rdynamic = true;
332
406
  break :bin lib;
333
407
  };
408
+ if (import) |i| {
409
+ if (root_module) {
410
+ bin.root_module.addImport("pkmn", i);
411
+ } else {
412
+ bin.addModule("pkmn", i);
413
+ }
414
+ }
334
415
  bin.stack_size = wasm_stack_size;
335
416
  if (@hasDecl(@TypeOf(bin.*), "strip")) bin.strip = strip orelse false;
336
417
  if (force_pic and pic orelse false) bin.force_pic = pic;
@@ -339,7 +420,7 @@ fn buildWasm(
339
420
  const opt = b.findProgram(&.{"wasm-opt"}, &.{"./node_modules/.bin"}) catch null;
340
421
  if (optimize != .Debug and opt != null) {
341
422
  const out = b.fmt("build/lib/{s}.wasm", .{name});
342
- const sh = b.addSystemCommand(&.{ opt.?, "-O4" });
423
+ const sh = b.addSystemCommand(&.{ opt.?, "--enable-bulk-memory", "--enable-simd", "-O4" });
343
424
  sh.addArtifactArg(bin);
344
425
  sh.addArg("-o");
345
426
  if (@hasDecl(@TypeOf(sh.*), "addFileSourceArg")) {
@@ -353,6 +434,8 @@ fn buildWasm(
353
434
  b.getInstallStep().dependOn(&b.addInstallArtifact(bin, .{
354
435
  .dest_dir = .{ .override = std.Build.InstallDir{ .lib = {} } },
355
436
  }).step);
437
+ } else {
438
+ b.installArtifact(bin);
356
439
  }
357
440
  }
358
441
 
@@ -439,10 +522,7 @@ const ToolConfig = struct {
439
522
  };
440
523
 
441
524
  fn tool(b: *std.Build, path: []const u8, config: ToolConfig) !?*Step.Run {
442
- std.fs.cwd().access(path, .{}) catch |err| switch (err) {
443
- error.FileNotFound => return null,
444
- else => |e| return e,
445
- };
525
+ if (!try exists(path)) return null;
446
526
  var name = config.tool.name orelse std.fs.path.basename(path);
447
527
  const index = std.mem.lastIndexOfScalar(u8, name, '.');
448
528
  if (index) |i| name = name[0..i];
@@ -484,6 +564,14 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) !?*Step.Run {
484
564
  return run;
485
565
  }
486
566
 
567
+ fn exists(path: []const u8) !bool {
568
+ std.fs.cwd().access(path, .{}) catch |err| switch (err) {
569
+ error.FileNotFound => return false,
570
+ else => |e| return e,
571
+ };
572
+ return true;
573
+ }
574
+
487
575
  const ToolsStep = struct {
488
576
  step: std.Build.Step,
489
577
 
@@ -501,16 +589,19 @@ fn detect(target: anytype) std.Target {
501
589
  return (std.zig.system.NativeTargetInfo.detect(target) catch unreachable).target;
502
590
  }
503
591
 
504
- const WASM = @embedFile("src/lib/wasm.zig");
505
-
506
- fn exports(b: *std.Build) ![][]const u8 {
592
+ pub fn exports(b: *std.Build, bytes: []const u8) ![][]const u8 {
507
593
  var symbols = std.ArrayList([]const u8).init(b.allocator);
508
594
 
509
- var it = std.mem.splitSequence(u8, WASM, "export const ");
595
+ var it = std.mem.splitSequence(u8, bytes, "export ");
510
596
  _ = it.next();
511
597
  while (it.next()) |s| {
512
- const i = std.mem.indexOf(u8, s, " ").?;
513
- try symbols.append(s[0..i]);
598
+ if (std.mem.startsWith(u8, s, "const ")) {
599
+ const i = std.mem.indexOf(u8, s[6..], " ").?;
600
+ try symbols.append(s[6 .. 6 + i]);
601
+ } else { // "fn "
602
+ const i = std.mem.indexOf(u8, s[3..], "(").?;
603
+ try symbols.append(s[3 .. 3 + i]);
604
+ }
514
605
  }
515
606
 
516
607
  return symbols.items;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/engine",
3
- "version": "0.1.0-dev.04a96f24",
3
+ "version": "0.1.0-dev.059a0591",
4
4
  "description": "A minimal, complete, Pokémon battle simulation engine optimized for performance",
5
5
  "repository": "github:pkmn/engine",
6
6
  "license": "MIT",
@@ -49,6 +49,9 @@
49
49
  "build/tools/display/ui.jsx",
50
50
  "build/tools/display/util.js.map",
51
51
  "build/tools/display/util.js",
52
+ "src/lib/bindings/c.zig",
53
+ "src/lib/bindings/node.zig",
54
+ "src/lib/bindings/wasm.zig",
52
55
  "src/lib/common/array.zig",
53
56
  "src/lib/common/battle.zig",
54
57
  "src/lib/common/data.zig",
@@ -95,28 +98,28 @@
95
98
  "access": "public"
96
99
  },
97
100
  "dependencies": {
98
- "@pkmn/data": "^0.9.17",
99
- "@pkmn/protocol": "^0.6.26"
101
+ "@pkmn/data": "^0.9.22",
102
+ "@pkmn/protocol": "^0.6.28"
100
103
  },
101
104
  "devDependencies": {
102
- "@pkmn/eslint-config": "^8.3.0",
103
- "@pkmn/img": "^0.2.32",
105
+ "@pkmn/eslint-config": "^9.1.0",
106
+ "@pkmn/img": "^0.2.33",
104
107
  "@pkmn/sets": "^5.1.2",
105
- "@pkmn/sim": "0.9.17",
106
- "@pkmn/smogon": "^0.5.13",
108
+ "@pkmn/sim": "0.9.22",
109
+ "@pkmn/smogon": "^0.5.15",
107
110
  "@types/html-minifier": "^4.0.5",
108
- "@types/jest": "^29.5.13",
111
+ "@types/jest": "^29.5.14",
109
112
  "@types/minimist": "^1.2.5",
110
113
  "@types/mustache": "^4.2.5",
111
- "@types/node": "^22.5.5",
112
- "@types/react": "^18.3.8",
114
+ "@types/node": "^22.8.7",
115
+ "@types/react": "^18.3.12",
113
116
  "@types/semver": "^7.5.8",
114
- "@types/vscode": "^1.93.0",
115
- "@vitest/coverage-v8": "^2.1.1",
116
- "@vscode/vsce": "^3.1.0",
117
- "binaryen": "^119.0.0",
118
- "esbuild": "^0.23.1",
119
- "eslint": "<=8",
117
+ "@types/vscode": "^1.95.0",
118
+ "@vitest/coverage-v8": "^2.1.4",
119
+ "@vscode/vsce": "^3.2.1",
120
+ "binaryen": "^120.0.0",
121
+ "esbuild": "^0.24.0",
122
+ "eslint": "^9.14.0",
120
123
  "html-minifier": "^4.0.0",
121
124
  "json-stringify-pretty-compact": "3.0.0",
122
125
  "minimist": "^1.2.8",
@@ -125,12 +128,12 @@
125
128
  "source-map-support": "^0.5.21",
126
129
  "table": "^6.8.2",
127
130
  "trakr": "^0.2.0",
128
- "typescript": "^5.6.2",
129
- "vitest": "^2.1.1"
131
+ "typescript": "^5.6.3",
132
+ "vitest": "^2.1.4"
130
133
  },
131
134
  "scripts": {
132
- "lint": "eslint --cache src --ext ts,js && eslint src/bin/*",
133
- "fix": "eslint --fix src --ext ts,js && eslint --fix src/bin/*",
135
+ "lint": "eslint --cache src",
136
+ "fix": "eslint --fix src",
134
137
  "compile": "tsc -p .",
135
138
  "build": "npm run compile",
136
139
  "test": "vitest src/pkg",
@@ -144,109 +147,5 @@
144
147
  "integration": "npm run compile && node build/test/integration",
145
148
  "extension": "npm -C src/tools/vscode run build",
146
149
  "postinstall": "node src/bin/install-pkmn-engine"
147
- },
148
- "eslintConfig": {
149
- "extends": "@pkmn",
150
- "ignorePatterns": [
151
- "dist/",
152
- "node_modules/",
153
- "examples/zig",
154
- "build/",
155
- "extension.js"
156
- ],
157
- "env": {
158
- "es6": true,
159
- "node": true,
160
- "browser": true
161
- },
162
- "overrides": [
163
- {
164
- "files": [
165
- "**/*.ts"
166
- ],
167
- "parserOptions": {
168
- "project": [
169
- "./tsconfig.json",
170
- "./examples/js/tsconfig.json"
171
- ]
172
- }
173
- },
174
- {
175
- "files": [
176
- "src/pkg/index.ts",
177
- "src/test/integration.ts"
178
- ],
179
- "rules": {
180
- "no-control-regex": "off",
181
- "@typescript-eslint/no-empty-interface": "off",
182
- "@typescript-eslint/no-shadow": "off",
183
- "@typescript-eslint/no-unsafe-declaration-merging": "off"
184
- }
185
- },
186
- {
187
- "files": [
188
- "src/pkg/addon/node.ts"
189
- ],
190
- "rules": {
191
- "@typescript-eslint/no-var-requires": "off"
192
- }
193
- },
194
- {
195
- "files": [
196
- "src/test/benchmark*.ts"
197
- ],
198
- "rules": {
199
- "@typescript-eslint/no-unused-vars": "off",
200
- "@typescript-eslint/no-redundant-type-constituents": "off"
201
- }
202
- },
203
- {
204
- "files": [
205
- "src/pkg/protocol.test.ts"
206
- ],
207
- "rules": {
208
- "jest/no-standalone-expect": "off",
209
- "jest/no-conditional-expect": "off"
210
- }
211
- },
212
- {
213
- "files": [
214
- "src/test/*.test.ts"
215
- ],
216
- "rules": {
217
- "jest/no-standalone-expect": "off"
218
- }
219
- },
220
- {
221
- "files": [
222
- "src/test/showdown/**"
223
- ],
224
- "rules": {
225
- "jest/expect-expect": [
226
- "warn",
227
- {
228
- "assertFunctionNames": [
229
- "expect",
230
- "expectLog",
231
- "verify"
232
- ]
233
- }
234
- ]
235
- }
236
- },
237
- {
238
- "files": [
239
- "src/tools/generate.ts"
240
- ],
241
- "rules": {
242
- "@typescript-eslint/restrict-template-expressions": [
243
- "error",
244
- {
245
- "allowBoolean": true
246
- }
247
- ]
248
- }
249
- }
250
- ]
251
150
  }
252
151
  }
@@ -257,7 +257,7 @@ const downloadImportLib = async () => {
257
257
  }
258
258
 
259
259
  const dir = path.join(ROOT, 'build', 'lib');
260
- const url = new URL('./win-x64/node.lib', process.release.headersUrl).href;
260
+ const url = process.release.libUrl;
261
261
  const dest = path.join(dir, path.basename(url));
262
262
  if (fs.existsSync(path.join(dest))) {
263
263
  log('Node import library:', dest);
@@ -325,6 +325,7 @@ const downloadImportLib = async () => {
325
325
  const libs = path.join(ROOT, 'build', 'lib');
326
326
  if (fs.existsSync(libs)) {
327
327
  for (const file of fs.readdirSync(libs)) {
328
+ if (!file.startsWith('pkmn')) continue;
328
329
  const type = path.extname(file).slice(1);
329
330
  if (type !== 'node' && type !== 'wasm') continue;
330
331
  // If we don't copy the addon before loading it Windows will return an
@@ -393,7 +394,7 @@ const downloadImportLib = async () => {
393
394
  try {
394
395
  const actual = path.join(ROOT, 'build', 'lib', `${prefix}pkmn${suffix}.node.${ext}`);
395
396
  fs.renameSync(actual, artifact);
396
- } catch (err) {
397
+ } catch {
397
398
  // ziglang/zig#19743 changed this path
398
399
  const actual = path.join(ROOT, 'build', 'bin', `${prefix}pkmn${suffix}.node.${ext}`);
399
400
  fs.renameSync(actual, artifact);