@pkmn/engine 0.1.0-dev.3ed876db → 0.1.0-dev.3f3af84c
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 +5 -4
- package/build/pkg/addon/browser.js +4 -1
- package/build/pkg/addon/browser.js.map +1 -1
- package/build/pkg/addon/node.js +3 -0
- package/build/pkg/addon/node.js.map +1 -1
- package/build/pkg/addon/wasm.js +41 -9
- package/build/pkg/addon/wasm.js.map +1 -1
- package/build/pkg/addon.d.ts +5 -5
- package/build/pkg/addon.js +8 -17
- package/build/pkg/addon.js.map +1 -1
- package/build/pkg/data/layout.json +15 -2
- package/build/pkg/data/protocol.json +23 -9
- package/build/pkg/gen1.d.ts +15 -18
- package/build/pkg/gen1.js +11 -12
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +37 -101
- package/build/pkg/index.js +6 -69
- package/build/pkg/index.js.map +1 -1
- package/build/tools/debug.js +0 -1
- package/build/tools/debug.js.map +1 -1
- package/build/tools/display/index.js +1 -0
- package/build/tools/display/index.js.map +1 -1
- package/build/tools/display/ui.jsx.map +1 -1
- package/build/tools/display/util.js +16 -1
- package/build/tools/display/util.js.map +1 -1
- package/build.zig +100 -27
- package/package.json +22 -123
- package/src/bin/install-pkmn-engine +3 -2
- package/src/lib/bindings/c.zig +255 -0
- package/src/lib/bindings/node.zig +121 -0
- package/src/lib/bindings/wasm.zig +59 -0
- package/src/lib/common/array.zig +1 -1
- package/src/lib/common/optional.zig +1 -1
- package/src/lib/common/util.zig +1 -1
- package/src/lib/gen1/calc.zig +8 -8
- package/src/lib/gen1/mechanics.zig +8 -3
- package/src/lib/gen2/mechanics.zig +19 -8
- package/src/lib/node.zig +2 -113
- package/src/lib/pkmn.zig +3 -2
- package/src/lib/wasm.zig +14 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pretty = exports.toText = void 0;
|
|
3
|
+
exports.imports = exports.pretty = exports.toText = void 0;
|
|
4
4
|
const format = (kwVal) => typeof kwVal === 'boolean' ? '' : ` ${kwVal}`;
|
|
5
5
|
const trim = (args) => {
|
|
6
6
|
while (args.length && !args[args.length - 1])
|
|
@@ -15,4 +15,19 @@ const pretty = (choice) => choice
|
|
|
15
15
|
? choice.type === 'pass' ? choice.type : `${choice.type} ${choice.data}`
|
|
16
16
|
: '???';
|
|
17
17
|
exports.pretty = pretty;
|
|
18
|
+
const imports = (memory, decoder) => ({
|
|
19
|
+
js: {
|
|
20
|
+
log(ptr, len) {
|
|
21
|
+
if (len === 0)
|
|
22
|
+
return console.log('');
|
|
23
|
+
const msg = decoder.decode(new Uint8Array(memory[0].buffer, ptr, len));
|
|
24
|
+
console.log(msg);
|
|
25
|
+
},
|
|
26
|
+
panic(ptr, len) {
|
|
27
|
+
const msg = decoder.decode(new Uint8Array(memory[0].buffer, ptr, len));
|
|
28
|
+
throw new Error('panic: ' + msg);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
exports.imports = imports;
|
|
18
33
|
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/tools/display/util.ts"],"names":[],"mappings":";;;AA2BA,MAAM,MAAM,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAe,EAAE,CAAC;AACvF,MAAM,IAAI,GAAG,CAAC,IAAc,EAAE,EAAE;IAC9B,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAAE,IAAI,CAAC,GAAG,EAAE,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,IAAgB,E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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
|
|
31
|
-
|
|
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;
|
|
@@ -100,15 +110,18 @@ pub fn build(b: *std.Build) !void {
|
|
|
100
110
|
|
|
101
111
|
const name = if (showdown) "pkmn-showdown" else "pkmn";
|
|
102
112
|
|
|
103
|
-
const pkmn = if (@hasDecl(std.Build, "CreateModuleOptions"))
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
});
|
|
112
125
|
|
|
113
126
|
var c = false;
|
|
114
127
|
if (node_headers) |headers| {
|
|
@@ -149,7 +162,18 @@ pub fn build(b: *std.Build) !void {
|
|
|
149
162
|
// rename the file ourself in install-pkmn-engine
|
|
150
163
|
b.installArtifact(lib);
|
|
151
164
|
} else if (wasm) {
|
|
152
|
-
|
|
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);
|
|
153
177
|
} else if (dynamic) {
|
|
154
178
|
const path = if (has_path) .{ .path = "src/lib/c.zig" } else b.path("src/lib/c.zig");
|
|
155
179
|
const lib = b.addSharedLibrary(if (force_pic) .{
|
|
@@ -244,7 +268,7 @@ pub fn build(b: *std.Build) !void {
|
|
|
244
268
|
b.installFile(file, b.fmt("share/pkgconfig/{s}", .{pc}));
|
|
245
269
|
}
|
|
246
270
|
|
|
247
|
-
const config = .{
|
|
271
|
+
const config: Config = .{
|
|
248
272
|
.target = target,
|
|
249
273
|
.optimize = optimize,
|
|
250
274
|
.pic = pic,
|
|
@@ -310,6 +334,7 @@ fn buildWasm(
|
|
|
310
334
|
strip: ?bool,
|
|
311
335
|
pic: ?bool,
|
|
312
336
|
wasm_stack_size: u64,
|
|
337
|
+
import: ?*std.Build.Module,
|
|
313
338
|
options: anytype,
|
|
314
339
|
) !void {
|
|
315
340
|
const entry = @hasDecl(Step.Compile, "Entry");
|
|
@@ -317,10 +342,37 @@ fn buildWasm(
|
|
|
317
342
|
.ReleaseFast, .ReleaseSafe => .ReleaseSmall,
|
|
318
343
|
else => optimize,
|
|
319
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
|
+
}
|
|
320
364
|
const freestanding = if (@hasDecl(std.Build, "resolveTargetQuery"))
|
|
321
|
-
b.resolveTargetQuery(.{
|
|
365
|
+
b.resolveTargetQuery(.{
|
|
366
|
+
.cpu_arch = .wasm32,
|
|
367
|
+
.os_tag = .freestanding,
|
|
368
|
+
.cpu_features_add = features,
|
|
369
|
+
})
|
|
322
370
|
else
|
|
323
|
-
ResolvedTarget{
|
|
371
|
+
ResolvedTarget{
|
|
372
|
+
.cpu_arch = .wasm32,
|
|
373
|
+
.os_tag = .freestanding,
|
|
374
|
+
.cpu_features_add = features,
|
|
375
|
+
};
|
|
324
376
|
const path = if (has_path) .{ .path = root_src_file } else b.path(root_src_file);
|
|
325
377
|
const bin = if (entry) bin: {
|
|
326
378
|
const exe = b.addExecutable(if (force_pic) .{
|
|
@@ -336,7 +388,11 @@ fn buildWasm(
|
|
|
336
388
|
.strip = strip,
|
|
337
389
|
.pic = pic,
|
|
338
390
|
});
|
|
339
|
-
|
|
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);
|
|
340
396
|
exe.entry = .disabled;
|
|
341
397
|
break :bin exe;
|
|
342
398
|
} else bin: {
|
|
@@ -349,6 +405,13 @@ fn buildWasm(
|
|
|
349
405
|
lib.rdynamic = true;
|
|
350
406
|
break :bin lib;
|
|
351
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
|
+
}
|
|
352
415
|
bin.stack_size = wasm_stack_size;
|
|
353
416
|
if (@hasDecl(@TypeOf(bin.*), "strip")) bin.strip = strip orelse false;
|
|
354
417
|
if (force_pic and pic orelse false) bin.force_pic = pic;
|
|
@@ -357,7 +420,7 @@ fn buildWasm(
|
|
|
357
420
|
const opt = b.findProgram(&.{"wasm-opt"}, &.{"./node_modules/.bin"}) catch null;
|
|
358
421
|
if (optimize != .Debug and opt != null) {
|
|
359
422
|
const out = b.fmt("build/lib/{s}.wasm", .{name});
|
|
360
|
-
const sh = b.addSystemCommand(&.{ opt.?, "-O4" });
|
|
423
|
+
const sh = b.addSystemCommand(&.{ opt.?, "--enable-bulk-memory", "--enable-simd", "-O4" });
|
|
361
424
|
sh.addArtifactArg(bin);
|
|
362
425
|
sh.addArg("-o");
|
|
363
426
|
if (@hasDecl(@TypeOf(sh.*), "addFileSourceArg")) {
|
|
@@ -371,6 +434,8 @@ fn buildWasm(
|
|
|
371
434
|
b.getInstallStep().dependOn(&b.addInstallArtifact(bin, .{
|
|
372
435
|
.dest_dir = .{ .override = std.Build.InstallDir{ .lib = {} } },
|
|
373
436
|
}).step);
|
|
437
|
+
} else {
|
|
438
|
+
b.installArtifact(bin);
|
|
374
439
|
}
|
|
375
440
|
}
|
|
376
441
|
|
|
@@ -457,10 +522,7 @@ const ToolConfig = struct {
|
|
|
457
522
|
};
|
|
458
523
|
|
|
459
524
|
fn tool(b: *std.Build, path: []const u8, config: ToolConfig) !?*Step.Run {
|
|
460
|
-
|
|
461
|
-
error.FileNotFound => return null,
|
|
462
|
-
else => |e| return e,
|
|
463
|
-
};
|
|
525
|
+
if (!try exists(path)) return null;
|
|
464
526
|
var name = config.tool.name orelse std.fs.path.basename(path);
|
|
465
527
|
const index = std.mem.lastIndexOfScalar(u8, name, '.');
|
|
466
528
|
if (index) |i| name = name[0..i];
|
|
@@ -502,6 +564,14 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) !?*Step.Run {
|
|
|
502
564
|
return run;
|
|
503
565
|
}
|
|
504
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
|
+
|
|
505
575
|
const ToolsStep = struct {
|
|
506
576
|
step: std.Build.Step,
|
|
507
577
|
|
|
@@ -519,16 +589,19 @@ fn detect(target: anytype) std.Target {
|
|
|
519
589
|
return (std.zig.system.NativeTargetInfo.detect(target) catch unreachable).target;
|
|
520
590
|
}
|
|
521
591
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
fn exports(b: *std.Build) ![][]const u8 {
|
|
592
|
+
pub fn exports(b: *std.Build, bytes: []const u8) ![][]const u8 {
|
|
525
593
|
var symbols = std.ArrayList([]const u8).init(b.allocator);
|
|
526
594
|
|
|
527
|
-
var it = std.mem.splitSequence(u8,
|
|
595
|
+
var it = std.mem.splitSequence(u8, bytes, "export ");
|
|
528
596
|
_ = it.next();
|
|
529
597
|
while (it.next()) |s| {
|
|
530
|
-
|
|
531
|
-
|
|
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
|
+
}
|
|
532
605
|
}
|
|
533
606
|
|
|
534
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.
|
|
3
|
+
"version": "0.1.0-dev.3f3af84c",
|
|
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.
|
|
99
|
-
"@pkmn/protocol": "^0.6.
|
|
101
|
+
"@pkmn/data": "^0.9.23",
|
|
102
|
+
"@pkmn/protocol": "^0.6.29"
|
|
100
103
|
},
|
|
101
104
|
"devDependencies": {
|
|
102
|
-
"@pkmn/eslint-config": "^
|
|
103
|
-
"@pkmn/img": "^0.2.
|
|
105
|
+
"@pkmn/eslint-config": "^9.3.0",
|
|
106
|
+
"@pkmn/img": "^0.2.33",
|
|
104
107
|
"@pkmn/sets": "^5.1.2",
|
|
105
|
-
"@pkmn/sim": "0.9.
|
|
106
|
-
"@pkmn/smogon": "^0.5.
|
|
108
|
+
"@pkmn/sim": "0.9.23",
|
|
109
|
+
"@pkmn/smogon": "^0.5.15",
|
|
107
110
|
"@types/html-minifier": "^4.0.5",
|
|
108
|
-
"@types/jest": "^29.5.
|
|
111
|
+
"@types/jest": "^29.5.14",
|
|
109
112
|
"@types/minimist": "^1.2.5",
|
|
110
113
|
"@types/mustache": "^4.2.5",
|
|
111
|
-
"@types/node": "^22.
|
|
112
|
-
"@types/react": "^18.3.
|
|
114
|
+
"@types/node": "^22.9.0",
|
|
115
|
+
"@types/react": "^18.3.12",
|
|
113
116
|
"@types/semver": "^7.5.8",
|
|
114
|
-
"@types/vscode": "^1.
|
|
115
|
-
"@vitest/coverage-v8": "^2.1.
|
|
116
|
-
"@vscode/vsce": "^3.
|
|
117
|
-
"binaryen": "^
|
|
117
|
+
"@types/vscode": "^1.95.0",
|
|
118
|
+
"@vitest/coverage-v8": "^2.1.5",
|
|
119
|
+
"@vscode/vsce": "^3.2.1",
|
|
120
|
+
"binaryen": "^120.0.0",
|
|
118
121
|
"esbuild": "^0.24.0",
|
|
119
|
-
"eslint": "
|
|
122
|
+
"eslint": "^9.15.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.
|
|
129
|
-
"vitest": "^2.1.
|
|
131
|
+
"typescript": "^5.6.3",
|
|
132
|
+
"vitest": "^2.1.5"
|
|
130
133
|
},
|
|
131
134
|
"scripts": {
|
|
132
|
-
"lint": "eslint --cache src
|
|
133
|
-
"fix": "eslint --fix src
|
|
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 =
|
|
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
|
|
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);
|