mons-rust 0.1.133 → 0.2.0
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 +88 -46
- package/mons-rust-internal.cjs +1 -0
- package/mons-rust.d.ts +65 -65
- package/mons-rust.js +33 -1583
- package/package.json +6 -4
- package/mons-rust_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,46 +1,88 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
# Mons TypeScript engine
|
|
2
|
+
|
|
3
|
+
The Mons rules engine is implemented in strict TypeScript and distributed as two
|
|
4
|
+
dependency-free npm packages:
|
|
5
|
+
|
|
6
|
+
- `mons-web` is an ES module for browsers and bundlers.
|
|
7
|
+
- `mons-rust` is the existing CommonJS package for Node.js. Its historical package
|
|
8
|
+
name is unchanged for compatibility.
|
|
9
|
+
|
|
10
|
+
Both packages expose the same 23 named game APIs and the same TypeScript declarations.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { GameVariant, MonsGameModel } from "mons-web";
|
|
14
|
+
|
|
15
|
+
const game = MonsGameModel.new(GameVariant.Classic);
|
|
16
|
+
const output = game.process_input_fen("l10,5;l9,4");
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
const { GameVariant, MonsGameModel } = require("mons-rust");
|
|
21
|
+
|
|
22
|
+
const game = MonsGameModel.new(GameVariant.Classic);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Migrating `mons-web` initialization
|
|
26
|
+
|
|
27
|
+
`mons-web` no longer has a default initializer or an `initSync` export. Remove the
|
|
28
|
+
default import and initialization call; named imports are ready to use immediately.
|
|
29
|
+
The generated `InitInput`, `SyncInitInput`, and `InitOutput` TypeScript types are
|
|
30
|
+
removed with those loaders.
|
|
31
|
+
|
|
32
|
+
```diff
|
|
33
|
+
-import initMonsWeb, { MonsGameModel } from "mons-web";
|
|
34
|
+
-await initMonsWeb();
|
|
35
|
+
+import { MonsGameModel } from "mons-web";
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The named API is otherwise preserved, including enum values, FEN formats, model
|
|
39
|
+
classes, event ordering, random automoves, and smart-automove preferences.
|
|
40
|
+
|
|
41
|
+
Incoming strings retain the previous runtime normalization: unpaired UTF-16
|
|
42
|
+
surrogates become U+FFFD before parsing or echoing. One intentional error-policy
|
|
43
|
+
change applies to malformed data: native `RuntimeError("unreachable")` traps from
|
|
44
|
+
invalid UTF-8 slice boundaries or genuine board/location bounds failures are
|
|
45
|
+
deterministic TypeScript `RangeError`s. Wrapped location indices that resolve inside
|
|
46
|
+
the board remain compatible aliases.
|
|
47
|
+
|
|
48
|
+
Published JavaScript targets ES2020. The Node package uses Node's built-in performance
|
|
49
|
+
and cryptographic-random services directly; the browser package uses the corresponding
|
|
50
|
+
`globalThis` APIs. Node.js 22.13 through 22.x, or Node.js 24 or newer, is required
|
|
51
|
+
only for repository development and release tooling.
|
|
52
|
+
|
|
53
|
+
## Validation
|
|
54
|
+
|
|
55
|
+
Install the workspace with Node.js 22.13 through 22.x, or Node.js 24 or newer, and
|
|
56
|
+
run the standard checks:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
npm ci --engine-strict
|
|
60
|
+
npm run format:check
|
|
61
|
+
npm run lint
|
|
62
|
+
npm run typecheck
|
|
63
|
+
npm run build
|
|
64
|
+
npm test
|
|
65
|
+
npm run test:automove-parity
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Run `./scripts/run-rules-tests.sh` with no options to replay the deterministic
|
|
69
|
+
compressed stream of 699,994 canonical unique rules transitions recovered from
|
|
70
|
+
699,999 historical raw fixtures. The command validates and streams the corpus without
|
|
71
|
+
unpacking or rewriting it.
|
|
72
|
+
|
|
73
|
+
Run `node ./scripts/check-complete-games.cjs` to validate the immutable public corpus
|
|
74
|
+
of 1,527 complete real-player games. Run `npm run test:complete-games` to replay all
|
|
75
|
+
25,185 turns and 169,480 inputs through the TypeScript engine across all 12 variants.
|
|
76
|
+
|
|
77
|
+
## Release
|
|
78
|
+
|
|
79
|
+
Run `./publish.sh --check-only` to execute the complete Node-only validation, build
|
|
80
|
+
both package tarballs, and perform npm dry runs without publishing. Publishing is an
|
|
81
|
+
explicit release operation: run `./publish.sh` from a clean worktree only when both
|
|
82
|
+
packages should be released to the `latest` tag.
|
|
83
|
+
|
|
84
|
+
A real publish acquires the transient `mons-npm-publish-lock` tag on `origin`, or on
|
|
85
|
+
the shared remote named by `MONS_PUBLISH_LOCK_REMOTE`. All publishers must use this
|
|
86
|
+
script and the same remote for the lock to serialize releases across hosts. If a
|
|
87
|
+
process terminates without releasing the tag, the script prints inspection and
|
|
88
|
+
lease-protected stale-lock recovery commands.
|