@spotlab/range 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +63 -2
- package/dist/errors.d.ts +43 -0
- package/dist/generated/constants.d.ts +6 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +672 -0
- package/dist/init.d.ts +14 -0
- package/dist/types.d.ts +21 -0
- package/package.json +54 -3
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instantiate the range wasm module. Idempotent: subsequent calls return the
|
|
3
|
+
* same promise. Retryable after a failure: a rejected `initRange()` clears
|
|
4
|
+
* its memoized promise, so a later call attempts instantiation again rather
|
|
5
|
+
* than re-throwing a cached rejection.
|
|
6
|
+
*
|
|
7
|
+
* Every other function export in this package throws
|
|
8
|
+
* {@link RangeNotInitializedError} until this has resolved. `RANKS`, `SUITS`,
|
|
9
|
+
* and `COMBOS` are static data generated from the Rust crate and need no
|
|
10
|
+
* initialization.
|
|
11
|
+
*/
|
|
12
|
+
export declare function initRange(): Promise<void>;
|
|
13
|
+
/** @internal guard called at the top of every export other than `initRange`. */
|
|
14
|
+
export declare function assertInitialized(fnName: string): void;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A canonical 4-character hand token (e.g. `AsKd`), branded so a bare `string`
|
|
3
|
+
* cannot be passed where a validated hand is required. Mirrors the Rust
|
|
4
|
+
* crate's `Hand` newtype.
|
|
5
|
+
*
|
|
6
|
+
* Type-only: the brand has no runtime presence, so importing this package
|
|
7
|
+
* pulls in no validation library. Values come branded from this package's
|
|
8
|
+
* own exports (`parseRange`, `handsOfCombo`, ...); a consumer holding a token
|
|
9
|
+
* it has validated itself can cast (`token as Hand`).
|
|
10
|
+
*/
|
|
11
|
+
export type Hand = string & {
|
|
12
|
+
readonly __brand: "Hand";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A single concrete hand mapped to its weight in `[0, 1]`. Mirrors the Rust
|
|
16
|
+
* crate's `HandFrequency` wire type.
|
|
17
|
+
*/
|
|
18
|
+
export type HandFrequency = {
|
|
19
|
+
hand: Hand;
|
|
20
|
+
frequency: number;
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spotlab/range",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "A poker range-string parser and serializer, compiled from Rust to wasm: combo/hand grammar, canonical hand tokens, and weighted-range arithmetic.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/mAAdhaTTah/spotlab",
|
|
10
|
+
"directory": "packages/range"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/mAAdhaTTah/spotlab/tree/main/packages/range#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/mAAdhaTTah/spotlab/issues"
|
|
15
|
+
},
|
|
16
|
+
"author": "James DiGioia",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"poker",
|
|
19
|
+
"range",
|
|
20
|
+
"parser",
|
|
21
|
+
"wasm",
|
|
22
|
+
"texas-holdem"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "^6.0.0",
|
|
40
|
+
"vite": "^8.3.1",
|
|
41
|
+
"vite-plugin-dts": "^5.1.2",
|
|
42
|
+
"vitest": "^4.1.4"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build:wasm": "wasm-pack build ../../crates/spotlab-range-wasm --release --target web --out-name range --out-dir ../../packages/range/src/wasm",
|
|
49
|
+
"build:inline": "node scripts/inline-wasm.mjs",
|
|
50
|
+
"build:strip-wasm-url-fallback": "node scripts/strip-wasm-url-fallback.mjs",
|
|
51
|
+
"build:vite": "vite build",
|
|
52
|
+
"build:size": "node scripts/check-size.mjs",
|
|
53
|
+
"build": "pnpm build:wasm && pnpm build:inline && pnpm build:strip-wasm-url-fallback && pnpm typecheck && pnpm build:vite && pnpm build:size",
|
|
54
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
55
|
+
"test": "vitest run"
|
|
56
|
+
}
|
|
6
57
|
}
|