@pkmn/engine 0.1.0-dev.a1fcc5d9 → 0.1.0-dev.a27b3ff3
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/LICENSE +1 -1
- package/README.md +51 -5
- package/build/pkg/addon/browser.d.ts +1 -1
- package/build/pkg/addon/browser.js +6 -2
- package/build/pkg/addon/browser.js.map +1 -1
- package/build/pkg/addon/node.js +22 -8
- package/build/pkg/addon/node.js.map +1 -1
- package/build/pkg/addon/wasm.d.ts +2 -0
- package/build/pkg/addon/wasm.js +53 -0
- package/build/pkg/addon/wasm.js.map +1 -0
- package/build/pkg/addon.d.ts +24 -4
- 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 +28 -19
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +37 -100
- package/build/pkg/index.js +23 -75
- package/build/pkg/index.js.map +1 -1
- package/build/tools/debug.js +18 -9
- package/build/tools/debug.js.map +1 -1
- package/build/tools/display/debug.jsx +18 -7
- package/build/tools/display/debug.jsx.map +1 -1
- package/build/tools/display/index.js +35 -15
- package/build/tools/display/index.js.map +1 -1
- package/build/tools/display/ui.jsx +17 -7
- 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 +198 -85
- package/package.json +29 -125
- package/src/bin/install-pkmn-engine +3 -2
- package/src/lib/bindings/c.zig +255 -0
- package/src/lib/bindings/node.zig +117 -0
- package/src/lib/bindings/wasm.zig +59 -0
- package/src/lib/common/array.zig +1 -1
- package/src/lib/common/js.zig +1 -5
- package/src/lib/common/napi.zig +4 -0
- package/src/lib/common/optional.zig +1 -1
- package/src/lib/common/options.zig +2 -0
- package/src/lib/common/protocol.zig +4 -8
- package/src/lib/common/rational.zig +281 -270
- package/src/lib/common/rng.zig +1 -3
- package/src/lib/common/util.zig +17 -2
- package/src/lib/gen1/calc.zig +52 -69
- package/src/lib/gen1/chance.zig +34 -18
- package/src/lib/gen1/data/moves.zig +2 -4
- package/src/lib/gen1/data/species.zig +1 -3
- package/src/lib/gen1/data/types.zig +2 -3
- package/src/lib/gen1/data.zig +7 -11
- package/src/lib/gen1/helpers.zig +4 -10
- package/src/lib/gen1/mechanics.zig +76 -51
- package/src/lib/gen2/calc.zig +10 -18
- package/src/lib/gen2/data/items.zig +1 -3
- package/src/lib/gen2/data/moves.zig +2 -4
- package/src/lib/gen2/data/species.zig +1 -3
- package/src/lib/gen2/data/types.zig +7 -5
- package/src/lib/gen2/data.zig +14 -17
- package/src/lib/gen2/generated.zig +18 -23
- package/src/lib/gen2/helpers.zig +5 -12
- package/src/lib/gen2/mechanics.zig +42 -39
- package/src/lib/node.zig +4 -121
- package/src/lib/pkmn.zig +7 -2
- package/src/lib/wasm.zig +13 -9
- package/src/tools/display/dom.ts +5 -8
- package/src/tools/display/ui.css +0 -5
package/build.zig
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
1
|
const builtin = @import("builtin");
|
|
2
|
+
const std = @import("std");
|
|
3
3
|
|
|
4
4
|
pub const Options = struct {
|
|
5
5
|
showdown: ?bool = null,
|
|
@@ -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;
|
|
@@ -63,7 +73,8 @@ pub fn build(b: *std.Build) !void {
|
|
|
63
73
|
std.debug.assert(std.mem.eql(u8, repository.first(), "github"));
|
|
64
74
|
|
|
65
75
|
const fast = try std.SemanticVersion.parse("0.12.0-dev.866+3a47bc715");
|
|
66
|
-
|
|
76
|
+
const patched = std.mem.endsWith(u8, builtin.zig_version_string, "patched");
|
|
77
|
+
if (optimize != .Debug and fast.order(builtin.zig_version) == .lt and !patched) {
|
|
67
78
|
std.log.warn("Release builds are ~10-20% slower than before Zig " ++
|
|
68
79
|
"v0.12.0-dev.866+3a47bc715 due to ziglang/zig#17768", .{});
|
|
69
80
|
}
|
|
@@ -73,6 +84,7 @@ pub fn build(b: *std.Build) !void {
|
|
|
73
84
|
const log = b.option(bool, "log", "Enable protocol message logging") orelse false;
|
|
74
85
|
const chance = b.option(bool, "chance", "Enable update probability tracking") orelse false;
|
|
75
86
|
const calc = b.option(bool, "calc", "Enable damage calculator support") orelse false;
|
|
87
|
+
const extra = b.option([]const []const u8, "option", "Enable extra option");
|
|
76
88
|
|
|
77
89
|
const options = b.addOptions();
|
|
78
90
|
options.addOption(?bool, "showdown", showdown);
|
|
@@ -80,17 +92,37 @@ pub fn build(b: *std.Build) !void {
|
|
|
80
92
|
options.addOption(?bool, "chance", chance);
|
|
81
93
|
options.addOption(?bool, "calc", calc);
|
|
82
94
|
|
|
95
|
+
if (extra) |opts| {
|
|
96
|
+
for (opts) |opt| {
|
|
97
|
+
if (std.mem.indexOfScalar(u8, opt, '=')) |i| {
|
|
98
|
+
options.addOption(?bool, opt[0..i], if (std.mem.eql(u8, opt[i + 1 ..], "true"))
|
|
99
|
+
true
|
|
100
|
+
else if (std.mem.eql(u8, opt[i + 1 ..], "false"))
|
|
101
|
+
false
|
|
102
|
+
else {
|
|
103
|
+
std.log.err("Invalid option: {s}\n", .{opt});
|
|
104
|
+
return error.InvalidOption;
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
options.addOption(?bool, opt, true);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
83
112
|
const name = if (showdown) "pkmn-showdown" else "pkmn";
|
|
84
113
|
|
|
85
|
-
const pkmn = if (@hasDecl(std.Build, "CreateModuleOptions"))
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
const pkmn: ?*std.Build.Module = if (@hasDecl(std.Build, "CreateModuleOptions"))
|
|
115
|
+
null
|
|
116
|
+
else
|
|
117
|
+
b.addModule("pkmn", .{
|
|
118
|
+
.root_source_file = if (has_path)
|
|
119
|
+
.{ .path = "src/lib/pkmn.zig" }
|
|
120
|
+
else
|
|
121
|
+
b.path("src/lib/pkmn.zig"),
|
|
122
|
+
.optimize = optimize,
|
|
123
|
+
.target = target,
|
|
124
|
+
.imports = &.{.{ .name = "build_options", .module = options.createModule() }},
|
|
125
|
+
});
|
|
94
126
|
|
|
95
127
|
var c = false;
|
|
96
128
|
if (node_headers) |headers| {
|
|
@@ -131,73 +163,18 @@ pub fn build(b: *std.Build) !void {
|
|
|
131
163
|
// rename the file ourself in install-pkmn-engine
|
|
132
164
|
b.installArtifact(lib);
|
|
133
165
|
} else if (wasm) {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
.name = name,
|
|
147
|
-
.root_source_file = path,
|
|
148
|
-
.optimize = mode,
|
|
149
|
-
.target = freestanding,
|
|
150
|
-
} else .{
|
|
151
|
-
.name = name,
|
|
152
|
-
.root_source_file = path,
|
|
153
|
-
.optimize = mode,
|
|
154
|
-
.target = freestanding,
|
|
155
|
-
.strip = strip,
|
|
156
|
-
.pic = pic,
|
|
157
|
-
});
|
|
158
|
-
(if (root_module) exe.root_module else exe).export_symbol_names = &[_][]const u8{
|
|
159
|
-
"SHOWDOWN",
|
|
160
|
-
"LOG",
|
|
161
|
-
"CHANCE",
|
|
162
|
-
"CALC",
|
|
163
|
-
"GEN1_CHOICES_SIZE",
|
|
164
|
-
"GEN1_LOGS_SIZE",
|
|
165
|
-
};
|
|
166
|
-
exe.entry = .disabled;
|
|
167
|
-
break :bin exe;
|
|
168
|
-
} else bin: {
|
|
169
|
-
const lib = b.addSharedLibrary(.{
|
|
170
|
-
.name = name,
|
|
171
|
-
.root_source_file = path,
|
|
172
|
-
.optimize = mode,
|
|
173
|
-
.target = freestanding,
|
|
174
|
-
});
|
|
175
|
-
lib.rdynamic = true;
|
|
176
|
-
break :bin lib;
|
|
177
|
-
};
|
|
178
|
-
bin.stack_size = wasm_stack_size;
|
|
179
|
-
if (@hasDecl(@TypeOf(bin.*), "strip")) bin.strip = strip orelse false;
|
|
180
|
-
if (force_pic and pic orelse false) bin.force_pic = pic;
|
|
181
|
-
(if (root_module) bin.root_module else bin).addOptions("build_options", options);
|
|
182
|
-
|
|
183
|
-
const opt = b.findProgram(&.{"wasm-opt"}, &.{"./node_modules/.bin"}) catch null;
|
|
184
|
-
if (optimize != .Debug and opt != null) {
|
|
185
|
-
const out = b.fmt("build/lib/{s}.wasm", .{name});
|
|
186
|
-
const sh = b.addSystemCommand(&.{ opt.?, "-O4" });
|
|
187
|
-
sh.addArtifactArg(bin);
|
|
188
|
-
sh.addArg("-o");
|
|
189
|
-
if (@hasDecl(@TypeOf(sh.*), "addFileSourceArg")) {
|
|
190
|
-
sh.addFileSourceArg(if (has_path) .{ .path = out } else b.path(out));
|
|
191
|
-
} else {
|
|
192
|
-
sh.addFileArg(if (has_path) .{ .path = out } else b.path(out));
|
|
193
|
-
}
|
|
194
|
-
b.getInstallStep().dependOn(&sh.step);
|
|
195
|
-
if (!entry) b.installArtifact(bin);
|
|
196
|
-
} else if (entry) {
|
|
197
|
-
b.getInstallStep().dependOn(&b.addInstallArtifact(bin, .{
|
|
198
|
-
.dest_dir = .{ .override = std.Build.InstallDir{ .lib = {} } },
|
|
199
|
-
}).step);
|
|
200
|
-
}
|
|
166
|
+
const path = "src/lib/wasm.zig";
|
|
167
|
+
try buildWasm(b, name, path, optimize, strip, pic, wasm_stack_size, null, options);
|
|
168
|
+
} else if (demo) {
|
|
169
|
+
const path = "src/tools/demo.zig";
|
|
170
|
+
const n = if (showdown) "demo-showdown" else "demo";
|
|
171
|
+
const mod = pkmn orelse module(b, .{
|
|
172
|
+
.showdown = showdown,
|
|
173
|
+
.log = log,
|
|
174
|
+
.chance = chance,
|
|
175
|
+
.calc = calc,
|
|
176
|
+
});
|
|
177
|
+
try buildWasm(b, n, path, optimize, strip, pic, wasm_stack_size, mod, options);
|
|
201
178
|
} else if (dynamic) {
|
|
202
179
|
const path = if (has_path) .{ .path = "src/lib/c.zig" } else b.path("src/lib/c.zig");
|
|
203
180
|
const lib = b.addSharedLibrary(if (force_pic) .{
|
|
@@ -292,7 +269,7 @@ pub fn build(b: *std.Build) !void {
|
|
|
292
269
|
b.installFile(file, b.fmt("share/pkgconfig/{s}", .{pc}));
|
|
293
270
|
}
|
|
294
271
|
|
|
295
|
-
const config = .{
|
|
272
|
+
const config: Config = .{
|
|
296
273
|
.target = target,
|
|
297
274
|
.optimize = optimize,
|
|
298
275
|
.pic = pic,
|
|
@@ -350,6 +327,119 @@ pub fn build(b: *std.Build) !void {
|
|
|
350
327
|
}
|
|
351
328
|
}
|
|
352
329
|
|
|
330
|
+
fn buildWasm(
|
|
331
|
+
b: *std.Build,
|
|
332
|
+
name: []const u8,
|
|
333
|
+
root_src_file: []const u8,
|
|
334
|
+
optimize: std.builtin.OptimizeMode,
|
|
335
|
+
strip: ?bool,
|
|
336
|
+
pic: ?bool,
|
|
337
|
+
wasm_stack_size: u64,
|
|
338
|
+
import: ?*std.Build.Module,
|
|
339
|
+
options: anytype,
|
|
340
|
+
) !void {
|
|
341
|
+
const entry = @hasDecl(Step.Compile, "Entry");
|
|
342
|
+
const mode = switch (optimize) {
|
|
343
|
+
.ReleaseFast, .ReleaseSafe => .ReleaseSmall,
|
|
344
|
+
else => optimize,
|
|
345
|
+
};
|
|
346
|
+
// https://webassembly.org/features/
|
|
347
|
+
var features = std.Target.wasm.featureSet(&.{
|
|
348
|
+
.atomics,
|
|
349
|
+
.bulk_memory,
|
|
350
|
+
// .exception_handling,
|
|
351
|
+
.extended_const,
|
|
352
|
+
// .half_precision,
|
|
353
|
+
// .multimemory,
|
|
354
|
+
.mutable_globals,
|
|
355
|
+
.nontrapping_fptoint,
|
|
356
|
+
.reference_types,
|
|
357
|
+
// .relaxed_simd,
|
|
358
|
+
.sign_ext,
|
|
359
|
+
.simd128,
|
|
360
|
+
// .tail_call,
|
|
361
|
+
});
|
|
362
|
+
if (builtin.zig_version.order(try std.SemanticVersion.parse("0.12.0")) != .lt) {
|
|
363
|
+
features.addFeature(@intFromEnum(std.Target.wasm.Feature.multivalue));
|
|
364
|
+
}
|
|
365
|
+
const freestanding = if (@hasDecl(std.Build, "resolveTargetQuery"))
|
|
366
|
+
b.resolveTargetQuery(.{
|
|
367
|
+
.cpu_arch = .wasm32,
|
|
368
|
+
.os_tag = .freestanding,
|
|
369
|
+
.cpu_features_add = features,
|
|
370
|
+
})
|
|
371
|
+
else
|
|
372
|
+
ResolvedTarget{
|
|
373
|
+
.cpu_arch = .wasm32,
|
|
374
|
+
.os_tag = .freestanding,
|
|
375
|
+
.cpu_features_add = features,
|
|
376
|
+
};
|
|
377
|
+
const path = if (has_path) .{ .path = root_src_file } else b.path(root_src_file);
|
|
378
|
+
const bin = if (entry) bin: {
|
|
379
|
+
const exe = b.addExecutable(if (force_pic) .{
|
|
380
|
+
.name = name,
|
|
381
|
+
.root_source_file = path,
|
|
382
|
+
.optimize = mode,
|
|
383
|
+
.target = freestanding,
|
|
384
|
+
} else .{
|
|
385
|
+
.name = name,
|
|
386
|
+
.root_source_file = path,
|
|
387
|
+
.optimize = mode,
|
|
388
|
+
.target = freestanding,
|
|
389
|
+
.strip = strip,
|
|
390
|
+
.pic = pic,
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
var file = try std.fs.cwd().openFile(root_src_file, .{});
|
|
394
|
+
defer file.close();
|
|
395
|
+
const bytes = try file.readToEndAlloc(b.allocator, std.math.maxInt(usize));
|
|
396
|
+
(if (root_module) exe.root_module else exe).export_symbol_names = try exports(b, bytes);
|
|
397
|
+
exe.entry = .disabled;
|
|
398
|
+
break :bin exe;
|
|
399
|
+
} else bin: {
|
|
400
|
+
const lib = b.addSharedLibrary(.{
|
|
401
|
+
.name = name,
|
|
402
|
+
.root_source_file = path,
|
|
403
|
+
.optimize = mode,
|
|
404
|
+
.target = freestanding,
|
|
405
|
+
});
|
|
406
|
+
lib.rdynamic = true;
|
|
407
|
+
break :bin lib;
|
|
408
|
+
};
|
|
409
|
+
if (import) |i| {
|
|
410
|
+
if (root_module) {
|
|
411
|
+
bin.root_module.addImport("pkmn", i);
|
|
412
|
+
} else {
|
|
413
|
+
bin.addModule("pkmn", i);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
bin.stack_size = wasm_stack_size;
|
|
417
|
+
if (@hasDecl(@TypeOf(bin.*), "strip")) bin.strip = strip orelse false;
|
|
418
|
+
if (force_pic and pic orelse false) bin.force_pic = pic;
|
|
419
|
+
(if (root_module) bin.root_module else bin).addOptions("build_options", options);
|
|
420
|
+
|
|
421
|
+
const opt = b.findProgram(&.{"wasm-opt"}, &.{"./node_modules/.bin"}) catch null;
|
|
422
|
+
if (optimize != .Debug and opt != null) {
|
|
423
|
+
const out = b.fmt("build/lib/{s}.wasm", .{name});
|
|
424
|
+
const sh = b.addSystemCommand(&.{ opt.?, "--enable-bulk-memory", "--enable-simd", "-O4" });
|
|
425
|
+
sh.addArtifactArg(bin);
|
|
426
|
+
sh.addArg("-o");
|
|
427
|
+
if (@hasDecl(@TypeOf(sh.*), "addFileSourceArg")) {
|
|
428
|
+
sh.addFileSourceArg(if (has_path) .{ .path = out } else b.path(out));
|
|
429
|
+
} else {
|
|
430
|
+
sh.addFileArg(if (has_path) .{ .path = out } else b.path(out));
|
|
431
|
+
}
|
|
432
|
+
b.getInstallStep().dependOn(&sh.step);
|
|
433
|
+
if (!entry) b.installArtifact(bin);
|
|
434
|
+
} else if (entry) {
|
|
435
|
+
b.getInstallStep().dependOn(&b.addInstallArtifact(bin, .{
|
|
436
|
+
.dest_dir = .{ .override = std.Build.InstallDir{ .lib = {} } },
|
|
437
|
+
}).step);
|
|
438
|
+
} else {
|
|
439
|
+
b.installArtifact(bin);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
353
443
|
fn maybeStrip(
|
|
354
444
|
b: *std.Build,
|
|
355
445
|
artifact: *Step.Compile,
|
|
@@ -433,10 +523,7 @@ const ToolConfig = struct {
|
|
|
433
523
|
};
|
|
434
524
|
|
|
435
525
|
fn tool(b: *std.Build, path: []const u8, config: ToolConfig) !?*Step.Run {
|
|
436
|
-
|
|
437
|
-
error.FileNotFound => return null,
|
|
438
|
-
else => |e| return e,
|
|
439
|
-
};
|
|
526
|
+
if (!try exists(path)) return null;
|
|
440
527
|
var name = config.tool.name orelse std.fs.path.basename(path);
|
|
441
528
|
const index = std.mem.lastIndexOfScalar(u8, name, '.');
|
|
442
529
|
if (index) |i| name = name[0..i];
|
|
@@ -478,6 +565,14 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) !?*Step.Run {
|
|
|
478
565
|
return run;
|
|
479
566
|
}
|
|
480
567
|
|
|
568
|
+
fn exists(path: []const u8) !bool {
|
|
569
|
+
std.fs.cwd().access(path, .{}) catch |err| switch (err) {
|
|
570
|
+
error.FileNotFound => return false,
|
|
571
|
+
else => |e| return e,
|
|
572
|
+
};
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
|
|
481
576
|
const ToolsStep = struct {
|
|
482
577
|
step: std.Build.Step,
|
|
483
578
|
|
|
@@ -494,3 +589,21 @@ fn detect(target: anytype) std.Target {
|
|
|
494
589
|
if (@hasField(@TypeOf(target), "result")) return target.result;
|
|
495
590
|
return (std.zig.system.NativeTargetInfo.detect(target) catch unreachable).target;
|
|
496
591
|
}
|
|
592
|
+
|
|
593
|
+
pub fn exports(b: *std.Build, bytes: []const u8) ![][]const u8 {
|
|
594
|
+
var symbols = std.ArrayList([]const u8).init(b.allocator);
|
|
595
|
+
|
|
596
|
+
var it = std.mem.splitSequence(u8, bytes, "export ");
|
|
597
|
+
_ = it.next();
|
|
598
|
+
while (it.next()) |s| {
|
|
599
|
+
if (std.mem.startsWith(u8, s, "const ")) {
|
|
600
|
+
const i = std.mem.indexOf(u8, s[6..], " ").?;
|
|
601
|
+
try symbols.append(s[6 .. 6 + i]);
|
|
602
|
+
} else { // "fn "
|
|
603
|
+
const i = std.mem.indexOf(u8, s[3..], "(").?;
|
|
604
|
+
try symbols.append(s[3 .. 3 + i]);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
return symbols.items;
|
|
609
|
+
}
|
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.a27b3ff3",
|
|
4
4
|
"description": "A minimal, complete, Pokémon battle simulation engine optimized for performance",
|
|
5
5
|
"repository": "github:pkmn/engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
"build/pkg/addon/node.d.ts",
|
|
22
22
|
"build/pkg/addon/node.js.map",
|
|
23
23
|
"build/pkg/addon/node.js",
|
|
24
|
+
"build/pkg/addon/wasm.d.ts",
|
|
25
|
+
"build/pkg/addon/wasm.js.map",
|
|
26
|
+
"build/pkg/addon/wasm.js",
|
|
24
27
|
"build/pkg/data.d.ts",
|
|
25
28
|
"build/pkg/data.js.map",
|
|
26
29
|
"build/pkg/data.js",
|
|
@@ -46,11 +49,15 @@
|
|
|
46
49
|
"build/tools/display/ui.jsx",
|
|
47
50
|
"build/tools/display/util.js.map",
|
|
48
51
|
"build/tools/display/util.js",
|
|
52
|
+
"src/lib/bindings/c.zig",
|
|
53
|
+
"src/lib/bindings/node.zig",
|
|
54
|
+
"src/lib/bindings/wasm.zig",
|
|
49
55
|
"src/lib/common/array.zig",
|
|
50
56
|
"src/lib/common/battle.zig",
|
|
51
57
|
"src/lib/common/data.zig",
|
|
52
58
|
"src/lib/common/debug.zig",
|
|
53
59
|
"src/lib/common/js.zig",
|
|
60
|
+
"src/lib/common/napi.zig",
|
|
54
61
|
"src/lib/common/optional.zig",
|
|
55
62
|
"src/lib/common/options.zig",
|
|
56
63
|
"src/lib/common/protocol.zig",
|
|
@@ -92,41 +99,42 @@
|
|
|
92
99
|
"access": "public"
|
|
93
100
|
},
|
|
94
101
|
"dependencies": {
|
|
95
|
-
"@pkmn/data": "^0.9.
|
|
96
|
-
"@pkmn/protocol": "^0.6.
|
|
102
|
+
"@pkmn/data": "^0.9.31",
|
|
103
|
+
"@pkmn/protocol": "^0.6.31"
|
|
97
104
|
},
|
|
98
105
|
"devDependencies": {
|
|
99
|
-
"@pkmn/eslint-config": "^
|
|
100
|
-
"@pkmn/img": "^0.2.
|
|
106
|
+
"@pkmn/eslint-config": "^9.7.0",
|
|
107
|
+
"@pkmn/img": "^0.2.36",
|
|
101
108
|
"@pkmn/sets": "^5.1.2",
|
|
102
|
-
"@pkmn/sim": "0.9.
|
|
109
|
+
"@pkmn/sim": "0.9.31",
|
|
110
|
+
"@pkmn/smogon": "^0.5.19",
|
|
103
111
|
"@types/html-minifier": "^4.0.5",
|
|
104
|
-
"@types/jest": "^29.5.
|
|
112
|
+
"@types/jest": "^29.5.14",
|
|
105
113
|
"@types/minimist": "^1.2.5",
|
|
106
114
|
"@types/mustache": "^4.2.5",
|
|
107
|
-
"@types/node": "^22.
|
|
108
|
-
"@types/react": "
|
|
115
|
+
"@types/node": "^22.13.9",
|
|
116
|
+
"@types/react": "<=18",
|
|
109
117
|
"@types/semver": "^7.5.8",
|
|
110
|
-
"@types/vscode": "^1.
|
|
111
|
-
"@vitest/coverage-v8": "^
|
|
112
|
-
"@vscode/vsce": "^3.
|
|
113
|
-
"binaryen": "^
|
|
114
|
-
"esbuild": "^0.
|
|
115
|
-
"eslint": "
|
|
118
|
+
"@types/vscode": "^1.97.0",
|
|
119
|
+
"@vitest/coverage-v8": "^3.0.7",
|
|
120
|
+
"@vscode/vsce": "^3.2.2",
|
|
121
|
+
"binaryen": "^122.0.0",
|
|
122
|
+
"esbuild": "^0.25.0",
|
|
123
|
+
"eslint": "^9.21.0",
|
|
116
124
|
"html-minifier": "^4.0.0",
|
|
117
125
|
"json-stringify-pretty-compact": "3.0.0",
|
|
118
126
|
"minimist": "^1.2.8",
|
|
119
127
|
"mustache": "^4.2.0",
|
|
120
|
-
"semver": "^7.
|
|
128
|
+
"semver": "^7.7.1",
|
|
121
129
|
"source-map-support": "^0.5.21",
|
|
122
|
-
"table": "^6.
|
|
130
|
+
"table": "^6.9.0",
|
|
123
131
|
"trakr": "^0.2.0",
|
|
124
|
-
"typescript": "^5.
|
|
125
|
-
"vitest": "^
|
|
132
|
+
"typescript": "^5.8.2",
|
|
133
|
+
"vitest": "^3.0.7"
|
|
126
134
|
},
|
|
127
135
|
"scripts": {
|
|
128
|
-
"lint": "eslint --cache src
|
|
129
|
-
"fix": "eslint --fix src
|
|
136
|
+
"lint": "eslint --cache src",
|
|
137
|
+
"fix": "eslint --fix src",
|
|
130
138
|
"compile": "tsc -p .",
|
|
131
139
|
"build": "npm run compile",
|
|
132
140
|
"test": "vitest src/pkg",
|
|
@@ -140,109 +148,5 @@
|
|
|
140
148
|
"integration": "npm run compile && node build/test/integration",
|
|
141
149
|
"extension": "npm -C src/tools/vscode run build",
|
|
142
150
|
"postinstall": "node src/bin/install-pkmn-engine"
|
|
143
|
-
},
|
|
144
|
-
"eslintConfig": {
|
|
145
|
-
"extends": "@pkmn",
|
|
146
|
-
"ignorePatterns": [
|
|
147
|
-
"dist/",
|
|
148
|
-
"node_modules/",
|
|
149
|
-
"examples/zig",
|
|
150
|
-
"build/",
|
|
151
|
-
"extension.js"
|
|
152
|
-
],
|
|
153
|
-
"env": {
|
|
154
|
-
"es6": true,
|
|
155
|
-
"node": true,
|
|
156
|
-
"browser": true
|
|
157
|
-
},
|
|
158
|
-
"overrides": [
|
|
159
|
-
{
|
|
160
|
-
"files": [
|
|
161
|
-
"**/*.ts"
|
|
162
|
-
],
|
|
163
|
-
"parserOptions": {
|
|
164
|
-
"project": [
|
|
165
|
-
"./tsconfig.json",
|
|
166
|
-
"./examples/js/tsconfig.json"
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"files": [
|
|
172
|
-
"src/pkg/index.ts",
|
|
173
|
-
"src/test/integration.ts"
|
|
174
|
-
],
|
|
175
|
-
"rules": {
|
|
176
|
-
"no-control-regex": "off",
|
|
177
|
-
"@typescript-eslint/no-empty-interface": "off",
|
|
178
|
-
"@typescript-eslint/no-shadow": "off",
|
|
179
|
-
"@typescript-eslint/no-unsafe-declaration-merging": "off"
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
"files": [
|
|
184
|
-
"src/pkg/addon/node.ts"
|
|
185
|
-
],
|
|
186
|
-
"rules": {
|
|
187
|
-
"@typescript-eslint/no-var-requires": "off"
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"files": [
|
|
192
|
-
"src/test/benchmark*.ts"
|
|
193
|
-
],
|
|
194
|
-
"rules": {
|
|
195
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
196
|
-
"@typescript-eslint/no-redundant-type-constituents": "off"
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
"files": [
|
|
201
|
-
"src/pkg/protocol.test.ts"
|
|
202
|
-
],
|
|
203
|
-
"rules": {
|
|
204
|
-
"jest/no-standalone-expect": "off",
|
|
205
|
-
"jest/no-conditional-expect": "off"
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
"files": [
|
|
210
|
-
"src/test/*.test.ts"
|
|
211
|
-
],
|
|
212
|
-
"rules": {
|
|
213
|
-
"jest/no-standalone-expect": "off"
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
"files": [
|
|
218
|
-
"src/test/showdown/**"
|
|
219
|
-
],
|
|
220
|
-
"rules": {
|
|
221
|
-
"jest/expect-expect": [
|
|
222
|
-
"warn",
|
|
223
|
-
{
|
|
224
|
-
"assertFunctionNames": [
|
|
225
|
-
"expect",
|
|
226
|
-
"expectLog",
|
|
227
|
-
"verify"
|
|
228
|
-
]
|
|
229
|
-
}
|
|
230
|
-
]
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
"files": [
|
|
235
|
-
"src/tools/generate.ts"
|
|
236
|
-
],
|
|
237
|
-
"rules": {
|
|
238
|
-
"@typescript-eslint/restrict-template-expressions": [
|
|
239
|
-
"error",
|
|
240
|
-
{
|
|
241
|
-
"allowBoolean": true
|
|
242
|
-
}
|
|
243
|
-
]
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
]
|
|
247
151
|
}
|
|
248
152
|
}
|
|
@@ -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);
|