mons-rules 0.2.0 → 0.2.3
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 +21 -69
- package/dist/mons-rules.js +1 -0
- package/mons-rules.d.ts +27 -250
- package/package.json +36 -12
- package/mons-rules.js +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# Mons rules engine
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
The module exposes 23 named game APIs with matching TypeScript declarations.
|
|
3
|
+
`mons-rules` is the dependency-free TypeScript rules engine for Super Metal Mons.
|
|
4
|
+
Its single ES module works in browsers, Web Workers, Node.js, and Firebase Cloud
|
|
5
|
+
Functions.
|
|
8
6
|
|
|
9
7
|
```ts
|
|
10
8
|
import { GameVariant, MonsGameModel } from "mons-rules";
|
|
@@ -19,81 +17,35 @@ const { GameVariant, MonsGameModel } = require("mons-rules");
|
|
|
19
17
|
const game = MonsGameModel.new(GameVariant.Classic);
|
|
20
18
|
```
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```diff
|
|
27
|
-
-import * as Mons from "mons-web";
|
|
28
|
-
+import * as Mons from "mons-rules";
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
```diff
|
|
32
|
-
-const Mons = require("mons-rust");
|
|
33
|
-
+const Mons = require("mons-rules");
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
The module has no default initializer or `initSync` export. Remove the default
|
|
37
|
-
import and initialization call; named imports are ready to use immediately. The
|
|
38
|
-
generated `InitInput`, `SyncInitInput`, and `InitOutput` TypeScript types are removed
|
|
39
|
-
with those loaders.
|
|
40
|
-
|
|
41
|
-
```diff
|
|
42
|
-
-import initMonsWeb, { MonsGameModel } from "mons-web";
|
|
43
|
-
-await initMonsWeb();
|
|
44
|
-
+import { MonsGameModel } from "mons-rules";
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
The named API is otherwise preserved, including enum values, FEN formats, model
|
|
48
|
-
classes, event ordering, random automoves, and smart-automove preferences.
|
|
49
|
-
|
|
50
|
-
Incoming strings retain the previous runtime normalization: unpaired UTF-16
|
|
51
|
-
surrogates become U+FFFD before parsing or echoing. One intentional error-policy
|
|
52
|
-
change applies to malformed data: native `RuntimeError("unreachable")` traps from
|
|
53
|
-
invalid UTF-8 slice boundaries or genuine board/location bounds failures are
|
|
54
|
-
deterministic TypeScript `RangeError`s. Wrapped location indices that resolve inside
|
|
55
|
-
the board remain compatible aliases.
|
|
56
|
-
|
|
57
|
-
Published JavaScript targets ES2020 and uses the Web-standard
|
|
58
|
-
`globalThis.performance` and `globalThis.crypto` APIs in every runtime. Node.js 22.13
|
|
59
|
-
through 22.x, or Node.js 24 or newer, is required for Node consumers, repository
|
|
60
|
-
development, and release tooling. These versions support loading the same ES module
|
|
61
|
-
through either `import` or `require`.
|
|
20
|
+
Published JavaScript targets ES2020 and uses the Web-standard `performance` and
|
|
21
|
+
`crypto` globals. Node.js 22.13 through 22.x, or Node.js 24 or newer, is required for
|
|
22
|
+
Node consumers and repository tooling.
|
|
62
23
|
|
|
63
24
|
## Validation
|
|
64
25
|
|
|
65
|
-
Install
|
|
66
|
-
run the standard checks:
|
|
26
|
+
Install dependencies and run the complete local gate:
|
|
67
27
|
|
|
68
28
|
```sh
|
|
69
29
|
npm ci --engine-strict
|
|
70
|
-
npm run
|
|
71
|
-
npm run lint
|
|
72
|
-
npm run typecheck
|
|
73
|
-
npm run build
|
|
74
|
-
npm test
|
|
75
|
-
npm run test:automove-parity
|
|
30
|
+
npm run check
|
|
76
31
|
```
|
|
77
32
|
|
|
78
|
-
|
|
79
|
-
compressed
|
|
80
|
-
|
|
81
|
-
|
|
33
|
+
The check streams and replays 699,994 canonical rules transitions without unpacking
|
|
34
|
+
the compressed corpus. It also validates 89 public API edge cases, 39 deterministic
|
|
35
|
+
automove decisions, and 1,527 complete real-player games containing 25,185 turns and
|
|
36
|
+
169,480 inputs across all 12 variants.
|
|
82
37
|
|
|
83
38
|
Run `node ./scripts/check-complete-games.cjs` to validate the immutable public corpus
|
|
84
|
-
|
|
85
|
-
25,185 turns and 169,480 inputs through the TypeScript engine across all 12 variants.
|
|
39
|
+
without replaying it. Run `npm run test:complete-games` for the full engine replay.
|
|
86
40
|
|
|
87
41
|
## Release
|
|
88
42
|
|
|
89
|
-
Run
|
|
90
|
-
`
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
`latest
|
|
43
|
+
Run `npm run bump` to increment the patch version in `package.json` and
|
|
44
|
+
`package-lock.json`, then commit the release change. Run
|
|
45
|
+
`npm run publish -- --check-only` to validate the unpublished version and perform an
|
|
46
|
+
npm dry run. Run `npm run publish` from a clean worktree to publish that version to
|
|
47
|
+
`latest`.
|
|
94
48
|
|
|
95
|
-
A real publish
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
process terminates without releasing the tag, the script prints inspection and
|
|
99
|
-
lease-protected stale-lock recovery commands.
|
|
49
|
+
A real publish uses the transient `mons-npm-publish-lock` tag on `origin`, or the
|
|
50
|
+
shared remote named by `MONS_PUBLISH_LOCK_REMOTE`, to serialize releases across
|
|
51
|
+
hosts. The script prints lease-protected recovery instructions if cleanup fails.
|