@pkmn/engine 0.1.0-dev.526bb2e1 → 0.1.0-dev.53787794

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 (76) hide show
  1. package/LICENSE +1 -3
  2. package/README.md +87 -52
  3. package/build/pkg/addon/browser.d.ts +3 -0
  4. package/build/pkg/addon/browser.js +43 -0
  5. package/build/pkg/addon/browser.js.map +1 -0
  6. package/build/pkg/addon/node.d.ts +3 -0
  7. package/build/pkg/addon/node.js +96 -0
  8. package/build/pkg/addon/node.js.map +1 -0
  9. package/build/pkg/addon.d.ts +2 -0
  10. package/build/pkg/addon.js +35 -58
  11. package/build/pkg/addon.js.map +1 -1
  12. package/build/pkg/data/ids.json +12 -12
  13. package/build/pkg/data/layout.json +2 -2
  14. package/build/pkg/data/protocol.json +69 -12
  15. package/build/pkg/data.d.ts +27 -5
  16. package/build/pkg/data.js.map +1 -1
  17. package/build/pkg/gen1.js +3 -3
  18. package/build/pkg/gen1.js.map +1 -1
  19. package/build/pkg/index.d.ts +24 -10
  20. package/build/pkg/index.js +15 -10
  21. package/build/pkg/index.js.map +1 -1
  22. package/build/pkg/protocol.d.ts +20 -1
  23. package/build/pkg/protocol.js +123 -102
  24. package/build/pkg/protocol.js.map +1 -1
  25. package/build/tools/debug.js +36 -68
  26. package/build/tools/debug.js.map +1 -1
  27. package/build/tools/display/debug.jsx +128 -0
  28. package/build/tools/display/debug.jsx.map +1 -0
  29. package/build/tools/display/index.js +132 -0
  30. package/build/tools/display/index.js.map +1 -0
  31. package/build/tools/display/ui.jsx +349 -0
  32. package/build/tools/display/ui.jsx.map +1 -0
  33. package/build/tools/display/util.js +18 -0
  34. package/build/tools/display/util.js.map +1 -0
  35. package/build.zig +257 -117
  36. package/package.json +67 -32
  37. package/src/bin/install-pkmn-engine +31 -21
  38. package/src/bin/pkmn-debug +1 -1
  39. package/src/lib/common/array.zig +77 -0
  40. package/src/lib/common/data.zig +12 -24
  41. package/src/lib/common/debug.zig +32 -6
  42. package/src/lib/common/js.zig +4 -2
  43. package/src/lib/common/optional.zig +21 -10
  44. package/src/lib/common/options.zig +4 -0
  45. package/src/lib/common/protocol.zig +810 -327
  46. package/src/lib/common/rational.zig +125 -31
  47. package/src/lib/common/rng.zig +22 -13
  48. package/src/lib/common/util.zig +50 -1
  49. package/src/lib/gen1/calc.zig +665 -137
  50. package/src/lib/gen1/chance.zig +410 -285
  51. package/src/lib/gen1/data/moves.zig +192 -180
  52. package/src/lib/gen1/data/species.zig +3 -3
  53. package/src/lib/gen1/data/types.zig +7 -7
  54. package/src/lib/gen1/data.zig +60 -66
  55. package/src/lib/gen1/helpers.zig +94 -399
  56. package/src/lib/gen1/mechanics.zig +596 -552
  57. package/src/lib/gen2/calc.zig +161 -0
  58. package/src/lib/gen2/chance.zig +902 -0
  59. package/src/lib/gen2/data/items.zig +12 -18
  60. package/src/lib/gen2/data/moves.zig +663 -569
  61. package/src/lib/gen2/data/species.zig +1 -1
  62. package/src/lib/gen2/data/types.zig +134 -31
  63. package/src/lib/gen2/data.zig +107 -79
  64. package/src/lib/gen2/generated.zig +806 -0
  65. package/src/lib/gen2/helpers.zig +49 -25
  66. package/src/lib/gen2/mechanics.zig +3560 -12
  67. package/src/lib/{binding/node.zig → node.zig} +10 -13
  68. package/src/lib/pkmn.zig +32 -15
  69. package/src/lib/{binding/wasm.zig → wasm.zig} +2 -1
  70. package/src/tools/display/dom.ts +96 -0
  71. package/src/tools/display/ui.css +351 -0
  72. package/build/test/display.js +0 -400
  73. package/build/test/display.js.map +0 -1
  74. package/src/lib/gen1/README.md +0 -814
  75. package/src/lib/gen2/README.md +0 -309
  76. package/src/test/display/pkmn.html.tmpl +0 -368
package/LICENSE CHANGED
@@ -1,6 +1,4 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2021-2023 pkmn contributors
1
+ Copyright (c) 2021-2024 pkmn contributors
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
4
  this software and associated documentation files (the "Software"), to deal in
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <br />
4
4
  <br />
5
5
  <a href="https://github.com/pkmn/engine/actions/workflows/test.yml">
6
- <img alt="Test Status" src="https://github.com/pkmn/engine/workflows/Tests/badge.svg" />
6
+ <img alt="Test Status" src="https://github.com/pkmn/engine/actions/workflows/test.yml/badge.svg" />
7
7
  </a>
8
8
  <a href="#status">
9
9
  <img alt="WIP" src="https://img.shields.io/badge/status-WIP-red.svg" />
@@ -12,6 +12,14 @@
12
12
  <img alt="License" src="https://img.shields.io/badge/License-MIT-blue.svg" />
13
13
  </a>
14
14
  </p>
15
+
16
+ > [!WARNING]
17
+ > **This project is under heavy development** and currently the `main` branch contains numerous breaking
18
+ > changes which may not work and which are not fully documented. Please **wait for the forthcoming
19
+ > initial v0.1 release** before depending on this project (code from the
20
+ > [`old`](https://github.com/pkmn/engine/releases/tag/old) tag can also be used to experiment with a
21
+ > more stable version of the codebase).
22
+
15
23
  <hr />
16
24
 
17
25
  A minimal, complete, Pokémon battle simulation engine optimized for performance and
@@ -49,9 +57,11 @@ $ zig build --prefix /usr/local -Doptimize=ReleaseFast
49
57
  ```
50
58
 
51
59
  The Zig website has [installation instructions](https://ziglang.org/learn/getting-started/) which
52
- walk through how to install Zig on each platform - the engine code should work on Zig v0.11.0 dev
53
- build 3859 or greater, though tracks Zig's master branch so this may change in the future if
54
- breaking language changes are introduced:
60
+ walk through how to install Zig on each platform - the engine code should work on Zig v0.11.0,
61
+ though tracks Zig's master branch so this may change in the future if breaking language changes are
62
+ introduced. Note that **due to a [bug in the Zig
63
+ compiler](https://github.com/ziglang/zig/issues/17768), compiling with a version of Zig before
64
+ `0.12.0-dev.876+aaf46187a` is recommended for performance**.
55
65
 
56
66
  `libpkmn` can be built with `-Dshowdown` to instead produce the Pokémon Showdown compatible
57
67
  `libpkmn-showdown` library. Furthermore, protocol message logging can be enabled through `-Dlog`.
@@ -67,40 +77,65 @@ $ npm install @pkmn/engine
67
77
  ```
68
78
 
69
79
  The driver depends on being able to find compiled Node/WASM addons in
70
- `node_modules/@pkmn/engine/build/lib` in order to be useful. When you install the package a
71
- [`postinstall` lifecycle script](https://docs.npmjs.com/cli/v8/using-npm/scripts) will run
72
- [`install-pkmn-engine`](src/bin/install-pkmn-engine) which will check for a compatible `zig`
73
- compiler (see above regarding minimum version) and download one to
74
- `node_module/@pkmn/engine/build/bin` if it can't find one, as well as looking for (and downloading,
75
- if necessary) the required Node headers needed to successfully build the addons natively.
80
+ `node_modules/@pkmn/engine/build/lib` to be useful. When you install the package a [`postinstall`
81
+ lifecycle script](https://docs.npmjs.com/cli/v8/using-npm/scripts) runs
82
+ [`install-pkmn-engine`](src/bin/install-pkmn-engine) which checks for a compatible `zig` compiler
83
+ (see earlier regarding minimum version) and download one to `node_module/@pkmn/engine/build/bin` if
84
+ it can't find one, as well as looking for (and downloading, if necessary) the required Node headers
85
+ needed to successfully build the addons natively.
76
86
 
77
87
  **If you have configured `npm` to `--ignore-scripts` you must either run `npx install-pkmn-engine`
78
88
  directly or build the addons manually and place the artifacts in the expected paths.**
79
89
 
80
90
  ### `pkmn`
81
91
 
82
- Until the [Zig package manager](https://github.com/ziglang/zig/projects/4) is completed, the
83
- recommended way of using the `pkmn` package in Zig is by either copying this repository into your
84
- project or by using [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) and then
85
- adding the following to your `build.zig`:
92
+ To include `pkmn`, add it as a dependency in your project's
93
+ [`build.zig.zon`](https://github.com/ziglang/zig/blob/master/doc/build.zig.zon.md) using [Zig's
94
+ Package Management
95
+ system](https://ziglang.org/download/0.11.0/release-notes.html#Package-Management):
96
+
97
+
98
+ ```zig
99
+ .dependencies = .{
100
+ .pkmn = .{
101
+ .url = "https://github.com/pkmn/engine/archive/RELEASE.tar.gz",
102
+ },
103
+ },
104
+ ```
105
+
106
+ Replace `RELEASE` with the tag for the [release](https://github.com/pkmn/engine/releases) you wish
107
+ to use (e.g. `0.1.0` or `nightly`) or the specific hash of any commit. Next, run `zig build` and
108
+ copy the expected hash from the error message into your `build.zig.zon` alongside the `.url`:
109
+
110
+ ```sh
111
+ $ zig build
112
+ error: dependency is missing hash field
113
+ .url = "https://github.com/pkmn/engine/archive/nightly.tar.gz",
114
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115
+ note: expected .hash = "122056b93b403033cb7d9bed96a02c2eb8cc1275515976167726ada6eb4207e8ef8a",
116
+ ```
117
+
118
+ Note that this hash is **not** going to be the same as the commit hash. After adding the hash to
119
+ your `build.zig.zon` you will be able to import the `pkmn` package's build helpers into your
120
+ `build.zig`:
86
121
 
87
122
  ```zig
88
123
  const std = @import("std");
89
- const pkmn = @import("lib/pkmn/build.zig");
90
124
 
91
125
  pub fn build(b: *std.Build) void {
92
126
  ...
93
- exe.addModule("pkmn", pkmn.module(b, .{ .showdown = true, .log = true }));
127
+ const pkmn = b.dependency("pkmn", .{ .showdown = true, .log = true });
128
+ exe.root_module.addImport("pkmn", pkmn.module("pkmn"));
94
129
  ...
95
130
  }
96
131
  ```
97
132
 
98
- The engine's `build.zig` exposes a `module` function that takes an options structure to allow for
99
- configuring whether or not Pokémon Showdown compatibility mode or protocol message logging should be
100
- enabled. Alternatively, you may set options via a `pkmn_options` [root source file
133
+ The `pkmn` package can be configured with various options such as whether or not Pokémon Showdown
134
+ compatibility mode or protocol message logging should be enabled. Alternatively, you may set options
135
+ via a `pkmn_options` [root source file
101
136
  declaration](https://ziglang.org/documentation/master/#Root-Source-File). There are several
102
137
  undocumented internal options that can be tweaked as well via build or root options, though these
103
- options are not officially supported, affect correctness, and may change meaning or behavior without
138
+ options aren't officially supported, affect correctness, and may change meaning or behavior without
104
139
  warning. Use at your own risk.
105
140
 
106
141
  ```zig
@@ -112,11 +147,11 @@ pub const pkmn_options = .{ .showdown = true, .log = true };
112
147
  For each Pokémon generation, the engine provides a battle structure with two functions - a function
113
148
  to `update` the battle's state based on both players' choices and a function that defines which
114
149
  `choices` are valid at that decision point (at the beginning of a battle both player's must "pass"
115
- as their first choice in order to switch in the first member of their party). If `-Dlog` protocol
116
- logging is enabled each update will produce logs which can be decoded into a buffer (`LOGS_SIZE`
117
- constants are provided to make it easy to allocate a buffer of the correct size). Each `update` will
118
- return a result to indicate either that the battle has terminated or which types of choices will be
119
- available for each player.
150
+ as their first choice to switch in the first member of their party). If `-Dlog` protocol logging is
151
+ enabled each update produces logs which can be decoded into a buffer (`LOGS_SIZE` constants are
152
+ provided to make it easy to allocate a buffer of the correct size). Each `update` returns a result
153
+ to indicate either that the battle has terminated or which types of choices are available for each
154
+ player.
120
155
 
121
156
  Unlike [Pokémon Showdown's
122
157
  SIM-PROTOCOL](https://github.com/smogon/pokemon-showdown/blob/master/sim/SIM-PROTOCOL.md#choice-requests)
@@ -128,19 +163,19 @@ state or cause the engine to crash.**
128
163
 
129
164
  Battles may be played out from any point but to freshly initialize a battle which is yet to start
130
165
  the turn count and active Pokémon should be zeroed out (driver code should handle this for you).
131
- Most driver code should also provide helpers to make initialize a battle convenient - check the
166
+ Most driver code should also provide helpers to make initializing battle convenient - check the
132
167
  respective documentation and examples for the bindings being used. The engine's [protocol
133
168
  documentation](docs/PROTOCOL.md) goes into greater detail on the specifics of updates and the
134
169
  potential logs that may result.
135
170
 
136
171
  *The snippets below are meant to merely illustrate in broad strokes how the pkmn engine can be used
137
- \- the [`examples`](src/examples) directory contains fully commented and runnable code.*
172
+ \- the [`examples`](examples) directory contains fully commented and runnable code.*
138
173
 
139
174
  ### C
140
175
 
141
176
  [`pkmn.h`](src/include/pkmn.h) exports the C API for `libpkmn`. Symbols are all prefixed with
142
177
  `pkmn_` to avoid name collisions. If `-Dlog` is enabled and logging throws an error then the error
143
- will be encoded in the `pkmn_result` and can be checked with `pkmn_error`.
178
+ is encoded in the `pkmn_result` and can be checked with `pkmn_error`.
144
179
 
145
180
  ```c
146
181
  #include <pkmn.h>
@@ -159,19 +194,19 @@ while (!pkmn_result_type(result = pkmn_battle_update(&battle, c1, c2, &options))
159
194
  if (pkmn_error(result)) exit(1);
160
195
  ```
161
196
 
162
- [(full code)](src/examples/c/example.c)
197
+ [(full code)](examples/c/example.c)
163
198
 
164
- The C API does not export any helpers for creating or accessing the opaque battle objects - it is
199
+ The C API doesn't export any helpers for creating or accessing the opaque battle objects - it's
165
200
  instead intended to be used as the foundation for more ergonomic bindings in [other
166
201
  languages](#other) (the lack of namespaces and bit fields having an implementation-defined layout in
167
202
  C are the main contributing factors to the sparseness of what `libpkmn` chooses to expose).
168
203
 
169
204
  ### JavaScript / TypeScript
170
205
 
171
- `@pkmn/engine` depends on the [`@pkmn/data`](https://www.npmjs.com/package/@pkmn/data) which
206
+ `@pkmn/engine` depends on the [`@pkmn/data`](https://www.npmjs.com/package/@pkmn/data) package which
172
207
  requires a `Dex` implementation to be provided as well. The `Battle.create` function can be used to
173
208
  initialize a `Battle` from the beginning, or `Battle.restore` can be used to re-instantiate a battle
174
- which is in already progress. If logging is enabled the output can be turned into Pokémon Showdown
209
+ which is already in progress. If logging is enabled the output can be turned into Pokémon Showdown
175
210
  protocol via `Log.parse`.
176
211
 
177
212
  ```ts
@@ -194,20 +229,20 @@ while (!(result = battle.update(c1, c2)).type) {
194
229
  console.log(result);
195
230
  ```
196
231
 
197
- [(full code)](src/examples/js/example.ts)
232
+ [(full code)](examples/js/example.ts)
198
233
 
199
- By default, the `@pkmn/engine` package will compile the engine with `-Dshowdown`, though by running
234
+ By default, the `@pkmn/engine` package compiles the engine with `-Dshowdown`, though by running
200
235
  `install-pkmn-engine` directly and passing in `--options` you can override this default and build
201
236
  different configurations of the extension for the driver to use. The driver can support
202
237
  configurations both with and without Pokémon Showdown compatibility simultaneously if present. On
203
- update, the post-install script will attempt to rebuild whichever extensions it finds with the same
238
+ update, the post-install script attempts to rebuild whichever extensions it finds with the same
204
239
  configuration parameters that were originally used meaning updating to the newest version of the
205
240
  library should be seamless.
206
241
 
207
242
  Despite relying on the native engine code, the `@pkmn/engine` code is designed to also work in
208
243
  browsers which support [WebAssembly](https://webassembly.org/). Running `npm run start:web` from the
209
- [`examples`](src/examples/js) directory will start a server that can be used to demonstrate the
210
- engine running in the browser.
244
+ [`examples`](examples/js) directory starts a server that can be used to demonstrate the engine
245
+ running in the browser.
211
246
 
212
247
  ### Zig
213
248
 
@@ -218,7 +253,7 @@ be used when logging is enabled to allow for easily printing e.g. to standard ou
218
253
  const std = @import("std");
219
254
  const pkmn = @import("pkmn");
220
255
 
221
- var random = std.rand.DefaultPrng.init(seed).random();
256
+ var random = std.Random.DefaultPrng.init(seed).random();
222
257
  var choices: [pkmn.CHOICES_SIZE]pkmn.Choice = undefined;
223
258
 
224
259
  var battle = ...
@@ -236,11 +271,11 @@ while (result.type == .None) : (result = try battle.update(c1, c2, &options)) {
236
271
  std.debug.print("{}\n", .{result.type});
237
272
  ```
238
273
 
239
- [(full code)](src/examples/zig/example.zig)
274
+ [(full code)](examples/zig/example.zig)
240
275
 
241
276
  The Zig package also supports some APIs which are difficult to expose elsewhere such as the
242
277
  `FixedRNG` which allows you to fully specify the exact RNG frames (which can be useful for ensuring
243
- certain outcomes/effects always occur) for a battle, though doing so will change the size of the
278
+ certain outcomes/effects always occur) for a battle, though doing so changes the size of the
244
279
  `Battle` object.
245
280
 
246
281
  ### Other
@@ -251,7 +286,7 @@ simplify the process even further [`src/data`](src/data) contains JSON dumps of
251
286
  data, structure sizes and offsets, and protocol information used by the reference driver code. The
252
287
  following is a list of known `libpkmn` bindings written by developers outside of the [pkmn
253
288
  organization](https://github.com/pkmn) that may be helpful (though note that these projects may not
254
- necessarily be up-to-date/complete/correct - inclusion in this list does not imply endorsement):
289
+ necessarily be up-to-date/complete/correct - inclusion in this list doesn't imply endorsement):
255
290
 
256
291
  | Language | License | URL |
257
292
  | ---------- | --------- | ------------------------------------ |
@@ -279,7 +314,7 @@ By default, `pkmn-debug` expects to read [binary debug protocol](docs/PROTOCOL.m
279
314
  $ <cmd> | pkmn-debug > index.html
280
315
  ```
281
316
 
282
- Alternatively, if a single filename argument is passed to the `pkmn-debug` it will read from that
317
+ Alternatively, if a single filename argument is passed to the `pkmn-debug` it reads from that
283
318
  instead:
284
319
 
285
320
  ```sh
@@ -301,14 +336,14 @@ Currently, most of the foundational work from stage 0 is done:
301
336
 
302
337
  - [benchmark and integration testing](src/test) infrastructure
303
338
  - [documentation](docs) about design, research, methodology, etc
304
- - definition and implementation of the [protocol](docs/PROTOCOL.md) that will be used by the engine
339
+ - definition and implementation of the [protocol](docs/PROTOCOL.md) that's used by the engine
305
340
 
306
- **Stage 1 is currently in progress** and will see the implementation of the actual Generation I & II
341
+ **Stage 1 is currently in progress** and involves the implementation of the actual Generation I & II
307
342
  battle engines, followed by Generation III & IV in stage 2. The implementation of further Pokémon
308
- generations is in scope for the project but should not be considered as part of the immediate
309
- roadmap (i.e. exploring the options for broadening support for old generation APIs will be given
310
- higher priority than implementing more modern generations). Furthermore, implementation of modern
311
- generations is soft-blocked on the [availability of high quality
343
+ generations is in scope for the project but shouldn't be considered part of the immediate roadmap
344
+ (i.e. exploring the options for broadening support for old generation APIs is given higher priority
345
+ than implementing more modern generations). Furthermore, implementation of modern generations is
346
+ soft-blocked on the [availability of high quality
312
347
  decompilations](https://github.com/orgs/pret/repositories) of the original games in question.
313
348
 
314
349
  Certain features will always be deemed **out of scope**:
@@ -326,10 +361,10 @@ The pkmn engine is distributed under the terms of the [MIT License](LICENSE).
326
361
  [^1]: In the case of Pokémon Showdown, only bugs which stem from a misimplementation of specific
327
362
  effects are reproduced in the engine, bugs which are the result of a misunderstanding of the
328
363
  fundamental mechanics of Pokémon or which simply arise due to specific Pokémon Showdown
329
- implementation details that are not replicable without making the same (incorrect) architectural
330
- choices are not. Furthermore, the "Pokémon Showdown" code referenced by this project includes
364
+ implementation details that aren't replicable without making the same (incorrect) architectural
365
+ choices aren't. Furthermore, the "Pokémon Showdown" code referenced by this project includes
331
366
  several [patches](docs/TESTING.md#patches) to improve accuracy and smooth over some of the more
332
367
  egregious implementation issues. In practical terms, the vast majority of games played out in the
333
- pkmn engine's compatibility mode and on this patched Pokémon Showdown simulator will be the same,
334
- it is only in a well defined and documented set of circumstances where the two implementations
368
+ pkmn engine's compatibility mode and on this patched Pokémon Showdown simulator are the same,
369
+ it's only in a well defined and documented set of circumstances where the two implementations
335
370
  diverge.
@@ -0,0 +1,3 @@
1
+ import type { Argument } from '../addon';
2
+ export declare function load(showdown: boolean, addon?: Argument): Promise<WebAssembly.Exports>;
3
+ export declare function loadSync(): void;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.load = load;
4
+ exports.loadSync = loadSync;
5
+ async function load(showdown, addon) {
6
+ if (typeof addon === 'string' && addon !== 'wasm') {
7
+ throw new Error('Unable to load native addons in the browser!');
8
+ }
9
+ let wasm;
10
+ if (addon instanceof WebAssembly.Module) {
11
+ try {
12
+ wasm = (await WebAssembly.instantiate(addon));
13
+ }
14
+ catch (err) {
15
+ if (!(err instanceof Error))
16
+ throw err;
17
+ throw new Error(`Could not instantiate WASM module!\n${err.message}`);
18
+ }
19
+ }
20
+ else {
21
+ const name = `pkmn${showdown ? '-showdown' : ''}.wasm`;
22
+ try {
23
+ const response = !addon || addon === 'wasm' ? fetch(name)
24
+ : addon instanceof URL ? fetch(addon) : addon;
25
+ wasm = (await WebAssembly.instantiateStreaming(response)).instance;
26
+ }
27
+ catch (err) {
28
+ if (!(err instanceof Error))
29
+ throw err;
30
+ const message = !addon || addon === 'wasm'
31
+ ? `Could not find ${name} - did you run \`npx install-pkmn-engine\`?`
32
+ : addon instanceof URL
33
+ ? `Could not fetch WASM module from '${addon.href}'!`
34
+ : 'Could not instantiate WASM module!';
35
+ throw new Error(`${message}\n${err.message}`);
36
+ }
37
+ }
38
+ return wasm.exports;
39
+ }
40
+ function loadSync() {
41
+ throw new Error('You must `initialize` the WASM addon before using the engine!');
42
+ }
43
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@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C,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,KAAK,KAAK,MAAM;gBACxC,CAAC,CAAC,kBAAkB,IAAI,6CAA6C;gBACrE,CAAC,CAAE,KAAiC,YAAY,GAAG;oBACjD,CAAC,CAAC,qCAAsC,KAAa,CAAC,IAAI,IAAI;oBAC9D,CAAC,CAAC,oCAAoC,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC;AACtB,CAAC;AAED,SAAgB,QAAQ;IACtB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;AACnF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Argument } from '../addon';
2
+ export declare function load(showdown: boolean, addon?: Argument): Promise<any>;
3
+ export declare function loadSync(showdown: boolean): any;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.load = load;
27
+ exports.loadSync = loadSync;
28
+ const fs = __importStar(require("fs"));
29
+ const path = __importStar(require("path"));
30
+ const ROOT = path.join(__dirname, '..', '..', '..');
31
+ const LIB = path.join(ROOT, 'build', 'lib');
32
+ const NODE = [path.join(LIB, 'pkmn.node'), path.join(LIB, 'pkmn-showdown.node')];
33
+ const WASM = [path.join(LIB, 'pkmn.wasm'), path.join(LIB, 'pkmn-showdown.wasm')];
34
+ async function load(showdown, addon) {
35
+ if (addon === undefined || typeof addon === 'string' && addon !== 'wasm') {
36
+ try {
37
+ return require(!addon || addon === 'node' ? NODE[+showdown] : addon).engine;
38
+ }
39
+ catch (err) {
40
+ if (!(err instanceof Error))
41
+ return err;
42
+ if (addon && addon !== 'node') {
43
+ throw new Error(`Unable to load native addon: '${addon}'\n${err.message}`);
44
+ }
45
+ else {
46
+ throw error(NODE[+showdown], err);
47
+ }
48
+ }
49
+ }
50
+ let wasm;
51
+ if (addon === 'wasm') {
52
+ try {
53
+ wasm = (await WebAssembly.instantiate(fs.readFileSync(WASM[+showdown]))).instance;
54
+ }
55
+ catch (err) {
56
+ throw error(WASM[+showdown], err);
57
+ }
58
+ }
59
+ else if (addon instanceof WebAssembly.Module) {
60
+ try {
61
+ wasm = (await WebAssembly.instantiate(addon));
62
+ }
63
+ catch (err) {
64
+ if (!(err instanceof Error))
65
+ throw err;
66
+ throw new Error(`Could not instantiate WASM module!\n${err.message}`);
67
+ }
68
+ }
69
+ else {
70
+ try {
71
+ const response = addon instanceof Promise ? addon : fetch(addon);
72
+ wasm = (await WebAssembly.instantiateStreaming(response)).instance;
73
+ }
74
+ catch (err) {
75
+ if (!(err instanceof Error))
76
+ throw err;
77
+ throw new Error(`Could not instantiate WASM module!\n${err.message}`);
78
+ }
79
+ }
80
+ return wasm.exports;
81
+ }
82
+ function loadSync(showdown) {
83
+ try {
84
+ return require(NODE[+showdown]).engine;
85
+ }
86
+ catch {
87
+ return undefined;
88
+ }
89
+ }
90
+ function error(file, err) {
91
+ if (!(err instanceof Error))
92
+ return err;
93
+ const message = `Could not find ${path.basename(file)} addon`;
94
+ return new Error(`${message} - did you run \`npx install-pkmn-engine\`?\n${err.message}`);
95
+ }
96
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/pkg/addon/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAYA,oBAuCC;AAED,4BAMC;AA1DD,uCAAyB;AACzB,2CAA6B;AAI7B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACpD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE5C,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC;AACjF,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC;AAE1E,KAAK,UAAU,IAAI,CAAC,QAAiB,EAAE,KAAgB;IAC5D,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACzE,IAAI,CAAC;YACH,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;QAC9E,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAA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F,IAAI,GAAG,CAAC,MAAM,WAAW,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;QACrE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;gBAAE,MAAM,GAAG,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC;AACtB,CAAC;AAED,SAAgB,QAAQ,CAAC,QAAiB;IACxC,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,IAAY,EAAE,GAAY;IACvC,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACxC,MAAM,OAAO,GAAG,kBAAkB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC9D,OAAO,IAAI,KAAK,CAAC,GAAG,OAAO,gDAAgD,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAC5F,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import { Choice, Player, Result } from '.';
2
+ export type Argument = string | URL | WebAssembly.Module | Promise<Response>;
3
+ export declare function initialize(showdown: boolean, addon?: Argument): Promise<void | undefined>;
2
4
  export declare function check(showdown: boolean): void;
3
5
  export declare function supports(showdown: boolean, log?: boolean): boolean;
4
6
  export declare function update(index: number, showdown: boolean, battle: ArrayBuffer, c1?: Choice, c2?: Choice, log?: ArrayBuffer): Result;
@@ -1,78 +1,58 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.size = exports.choose = exports.choices = exports.update = exports.supports = exports.check = void 0;
27
- const path = __importStar(require("path"));
3
+ exports.initialize = initialize;
4
+ exports.check = check;
5
+ exports.supports = supports;
6
+ exports.update = update;
7
+ exports.choices = choices;
8
+ exports.choose = choose;
9
+ exports.size = size;
10
+ const node_1 = require("./addon/node");
28
11
  const _1 = require(".");
29
- const ROOT = path.join(__dirname, '..', '..');
30
- let ADDON = undefined;
31
- function load() {
32
- if (ADDON)
33
- return ADDON;
34
- let pkmn = undefined;
35
- let showdown = undefined;
36
- try {
37
- pkmn = require(path.join(ROOT, 'build', 'lib', 'pkmn.node')).engine;
38
- }
39
- catch { }
40
- try {
41
- showdown =
42
- require(path.join(ROOT, 'build', 'lib', 'pkmn-showdown.node')).engine;
12
+ const ADDONS = [];
13
+ const loading = [];
14
+ async function initialize(showdown, addon) {
15
+ if (loading[+showdown]) {
16
+ throw new Error(`Cannot call initialize more than once with showdown=${showdown}`);
43
17
  }
44
- catch { }
45
- if (!pkmn && !showdown) {
46
- throw new Error('Could not find native addons - did you run `npx install-pkmn-engine`?');
47
- }
48
- return (ADDON = [pkmn, showdown]);
18
+ loading[+showdown] = (0, node_1.load)(showdown, addon);
19
+ loading[+showdown].then(a => {
20
+ ADDONS[+showdown] = a;
21
+ }).catch(() => {
22
+ loading[+showdown] = undefined;
23
+ });
24
+ return loading[+showdown]?.then(() => { });
49
25
  }
50
26
  function check(showdown) {
51
- if (!load()[+showdown]) {
52
- const opts = ADDON[+!showdown].options.log ? ['-log'] : [];
27
+ if (!addons(showdown)[+showdown]) {
28
+ const opts = ADDONS[+!showdown].options.log ? ['-log'] : [];
53
29
  if (showdown)
54
30
  opts.push('-Dshowdown');
55
31
  throw new Error(`@pkmn/engine has ${showdown ? 'not' : 'only'} been configured to support Pokémon Showdown.` +
56
32
  `\n(running \`npx install-pkmn-engine --options='${opts.join(' ')}'\` can fix this issue).`);
57
33
  }
58
34
  }
59
- exports.check = check;
60
35
  function supports(showdown, log) {
61
- if (!load()[+showdown])
36
+ if (!addons(showdown)[+showdown])
62
37
  return false;
63
38
  if (log === undefined)
64
39
  return true;
65
- return ADDON[+showdown].options.log === log;
40
+ return ADDONS[+showdown].options.log === log;
41
+ }
42
+ function addons(showdown) {
43
+ if (ADDONS[+showdown])
44
+ return ADDONS;
45
+ // If we havem't been initialized attempt to autoload if we're on Node
46
+ ADDONS[+showdown] = (0, node_1.loadSync)(showdown);
47
+ return ADDONS;
66
48
  }
67
- exports.supports = supports;
68
49
  function update(index, showdown, battle, c1, c2, log) {
69
- return _1.Result.decode(ADDON[+showdown].bindings[index]
50
+ return _1.Result.decode(ADDONS[+showdown].bindings[index]
70
51
  .update(battle, _1.Choice.encode(c1), _1.Choice.encode(c2), log));
71
52
  }
72
- exports.update = update;
73
53
  function choices(index, showdown, battle, player, choice, buf) {
74
54
  const request = choice[0] === 'p' ? 0 : choice[0] === 'm' ? 1 : 2;
75
- const n = ADDON[+showdown].bindings[index].choices(battle, +(player !== 'p1'), request, buf);
55
+ const n = ADDONS[+showdown].bindings[index].choices(battle, +(player !== 'p1'), request, buf);
76
56
  // The top-level API signature means our hands our tied with respect to
77
57
  // writing really fast bindings here. The simplest approach would be to return
78
58
  // the ArrayBuffer the bindings populate as well as its size and only decode a
@@ -96,17 +76,14 @@ function choices(index, showdown, battle, player, choice, buf) {
96
76
  options[i] = _1.Choice.decode(data[i]);
97
77
  return options;
98
78
  }
99
- exports.choices = choices;
100
79
  function choose(index, showdown, battle, player, choice, buf, fn) {
101
80
  const request = choice[0] === 'p' ? 0 : choice[0] === 'm' ? 1 : 2;
102
- const n = ADDON[+showdown].bindings[index].choices(battle, +(player !== 'p1'), request, buf);
81
+ const n = ADDONS[+showdown].bindings[index].choices(battle, +(player !== 'p1'), request, buf);
103
82
  const data = new Uint8Array(buf);
104
83
  return _1.Choice.decode(data[fn(n)]);
105
84
  }
106
- exports.choose = choose;
107
85
  function size(index, type) {
108
- const bindings = (ADDON[1] ?? ADDON[0]).bindings[index];
86
+ const bindings = (ADDONS[1] ?? ADDONS[0]).bindings[index];
109
87
  return type[0] === 'c' ? bindings.CHOICES_SIZE : bindings.LOGS_SIZE;
110
88
  }
111
- exports.size = size;
112
89
  //# sourceMappingURL=addon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"addon.js","sourceRoot":"","sources":["../../src/pkg/addon.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,wBAAyC;AAEzC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAE9C,IAAI,KAAK,GAAoD,SAAS,CAAC;AAcvE,SAAS,IAAI;IACX,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACxB,IAAI,IAAI,GAAgC,SAAS,CAAC;IAClD,IAAI,QAAQ,GAA+B,SAAS,CAAC;IACrD,IAAI;QACF,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK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