jaml-ui 0.31.0 → 0.32.2

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 (98) hide show
  1. package/README.md +193 -61
  2. package/assets/fonts/README.md +14 -0
  3. package/assets/fonts/m6x11.ttf +0 -0
  4. package/assets/fonts/m6x11plus.ttf +0 -0
  5. package/dist/.gitkeep +0 -0
  6. package/dist/assets/searchPoolWorker-Ck5flXVS.js +40 -0
  7. package/dist/assets/searchPoolWorker-Ck5flXVS.js.map +1 -0
  8. package/dist/assets.d.ts +1 -1
  9. package/dist/chunks/{assets-D80i9sMq.js → assets-Bb6wV80_.js} +3 -3
  10. package/dist/chunks/assets-Bb6wV80_.js.map +1 -0
  11. package/dist/chunks/jamlSeeds-3ILzc_rj.js +66 -0
  12. package/dist/chunks/jamlSeeds-3ILzc_rj.js.map +1 -0
  13. package/dist/chunks/motelyItemFormats-CNrFzcCI.js +1836 -0
  14. package/dist/chunks/motelyItemFormats-CNrFzcCI.js.map +1 -0
  15. package/dist/chunks/{searchPoolWorker-DUope_8B.js → searchPoolWorker-gPdRA_pa.js} +2 -2
  16. package/dist/chunks/searchPoolWorker-gPdRA_pa.js.map +1 -0
  17. package/dist/chunks/{spriteMapper-C4_5G1Z6.js → spriteMapper-CajFGgUU.js} +2 -2
  18. package/dist/chunks/spriteMapper-CajFGgUU.js.map +1 -0
  19. package/dist/chunks/tokens-Qrhlekc4.js.map +1 -1
  20. package/dist/chunks/{ui-DRov81qO.js → ui-CgjJDJdZ.js} +1346 -1195
  21. package/dist/chunks/ui-CgjJDJdZ.js.map +1 -0
  22. package/dist/components/CardFan.d.ts +0 -9
  23. package/dist/components/JamlAestheticSelector.d.ts +3 -3
  24. package/dist/components/JamlIde.d.ts +1 -4
  25. package/dist/components/JamlSeedSpinner.d.ts +3 -1
  26. package/dist/components/Jamlyzer.d.ts +5 -8
  27. package/dist/components/MotelyHello.d.ts +5 -0
  28. package/dist/components/SeedFinderApp.d.ts +7 -0
  29. package/dist/components/StandardCard.d.ts +14 -0
  30. package/dist/components/cardEnums.d.ts +48 -0
  31. package/dist/components/jamlMap/JokerPicker.d.ts +2 -1
  32. package/dist/components/jamlMap/MysterySlot.d.ts +2 -1
  33. package/dist/core.d.ts +1 -0
  34. package/dist/core.js +7 -7
  35. package/dist/core.js.map +1 -1
  36. package/dist/hooks/useAnalyzer.d.ts +1 -1
  37. package/dist/hooks/useSearchPool.d.ts +1 -1
  38. package/dist/index.d.ts +6 -4
  39. package/dist/index.js +3870 -3591
  40. package/dist/index.js.map +1 -1
  41. package/dist/lib/data/constants.d.ts +3 -3
  42. package/dist/lib/jaml/jamlData.d.ts +1 -0
  43. package/dist/lib/jaml/jamlSchema.d.ts +10 -60
  44. package/dist/lib/jaml/jamlSeeds.d.ts +7 -0
  45. package/dist/lib/types.d.ts +3 -2
  46. package/dist/motely.d.ts +1 -2
  47. package/dist/motely.js +125 -1999
  48. package/dist/motely.js.map +1 -1
  49. package/dist/r3f.js +1 -1
  50. package/dist/r3f.js.map +1 -1
  51. package/dist/ui/JimboBadge.d.ts +1 -1
  52. package/dist/ui/{footer.d.ts → JimboBalatroFooter.d.ts} +4 -2
  53. package/dist/ui/JimboCopyButton.d.ts +27 -0
  54. package/dist/ui/JimboDeckAndStakeSelectorModal.d.ts +30 -0
  55. package/dist/ui/JimboIconButton.d.ts +8 -3
  56. package/dist/ui/JimboInlineEdit.d.ts +16 -0
  57. package/dist/ui/JimboListItem.d.ts +11 -0
  58. package/dist/ui/JimboPanelSplitter.d.ts +8 -0
  59. package/dist/ui/JimboSeedCopyChip.d.ts +16 -0
  60. package/dist/ui/JimboSelect.d.ts +15 -3
  61. package/dist/ui/JimboSpinner.d.ts +18 -0
  62. package/dist/ui/JimboStepper.d.ts +19 -7
  63. package/dist/ui/JimboValueBadge.d.ts +19 -0
  64. package/dist/ui/codeBlock.d.ts +4 -0
  65. package/dist/ui/hooks.d.ts +30 -3
  66. package/dist/ui/jimbo.css +1 -1
  67. package/dist/ui/jimboApp.d.ts +2 -2
  68. package/dist/ui/jimboBackground.d.ts +12 -5
  69. package/dist/ui/jimboCopyRow.d.ts +2 -2
  70. package/dist/ui/jimboInset.d.ts +3 -3
  71. package/dist/ui/jimboLayout.d.ts +25 -0
  72. package/dist/ui/jimboLink.d.ts +12 -0
  73. package/dist/ui/jimboTabs.d.ts +6 -6
  74. package/dist/ui/jimboText.d.ts +2 -3
  75. package/dist/ui.d.ts +12 -4
  76. package/dist/ui.js +3 -3
  77. package/fonts.css +20 -5
  78. package/package.json +7 -6
  79. package/assets/fonts/m6x11plusplus.otf +0 -0
  80. package/dist/assets/searchPoolWorker-BPJ3Mf0o.js +0 -40
  81. package/dist/assets/searchPoolWorker-BPJ3Mf0o.js.map +0 -1
  82. package/dist/chunks/Layer-Ckd_T6Fw.js +0 -17
  83. package/dist/chunks/Layer-Ckd_T6Fw.js.map +0 -1
  84. package/dist/chunks/assets-D80i9sMq.js.map +0 -1
  85. package/dist/chunks/runtime-C-It0krH.js +0 -10
  86. package/dist/chunks/runtime-C-It0krH.js.map +0 -1
  87. package/dist/chunks/searchPoolWorker-DUope_8B.js.map +0 -1
  88. package/dist/chunks/spriteMapper-C4_5G1Z6.js.map +0 -1
  89. package/dist/chunks/ui-DRov81qO.js.map +0 -1
  90. package/dist/components/CardList.d.ts +0 -8
  91. package/dist/components/Standardcard.d.ts +0 -18
  92. package/dist/config.d.ts +0 -10
  93. package/dist/fonts/m6x11plus.otf +0 -0
  94. package/dist/hooks/useMotelyRuntime.d.ts +0 -11
  95. package/dist/providers/MotelyProvider.d.ts +0 -11
  96. package/dist/ui/JimboFloating.d.ts +0 -8
  97. package/dist/ui/PanelSplitter.d.ts +0 -8
  98. package/jaml.schema.json +0 -1219
package/README.md CHANGED
@@ -1,30 +1,104 @@
1
1
  # jaml-ui
2
2
 
3
- React components, UI tokens, sprites, and utilities for Balatro/JAML apps.
3
+ React components, UI tokens, sprites, and utilities for Balatro/JAML seed-finder apps.
4
+
5
+ Wraps [motely-wasm](https://www.npmjs.com/package/motely-wasm) — the Bootsharp-built WebAssembly port of the C# Motely seed engine — and ships a Balatro-styled design system called **Jimbo**.
4
6
 
5
7
  ## Install
6
8
 
7
9
  ```bash
8
- npm install jaml-ui react react-dom
10
+ npm install jaml-ui motely-wasm react react-dom
9
11
  ```
10
12
 
13
+ The CSS is loaded automatically as a side-effect import. No PostCSS, no Tailwind, no config.
14
+
15
+ ## Boot motely-wasm before rendering
16
+
17
+ `motely-wasm` is a Bootsharp module. Boot it once at app startup, before React mounts. Two requirements:
18
+
19
+ 1. Top-level `await bootsharp.boot(<bin path>)` in your entry point.
20
+ 2. The `motely-wasm/bin/*` files must be served at that path. Copy them into your `public/` (Vite) or wire a static route (Next.js).
21
+
22
+ ```ts
23
+ // src/main.tsx
24
+ import "jaml-ui/jimbo.css"; // already side-effect-imported by jaml-ui; safe either way
25
+ import { createRoot } from "react-dom/client";
26
+ import bootsharp from "motely-wasm";
27
+ import App from "./App";
28
+
29
+ await bootsharp.boot("/motely-wasm/bin");
30
+ createRoot(document.getElementById("root")!).render(<App />);
31
+ ```
32
+
33
+ Vite serves `/motely-wasm/bin` if you copy `node_modules/motely-wasm/bin` into `public/motely-wasm/bin/`. See `examples/seed-finder` for a working setup.
34
+
35
+ > If you can't use top-level await (legacy Webpack, server components), the hooks (`useSearch`, `useAnalyzer`, `useJamlLibrary`) inline a Standby-guard and will boot lazily on first call. The top-level pattern is still preferred — it removes the boot wait from the first interaction.
36
+
37
+ ## Quick start — a real seed finder in ~30 lines
38
+
39
+ ```tsx
40
+ import { useState } from "react";
41
+ import { JamlIde, useSearch, type JamlIdeSearchResult } from "jaml-ui";
42
+
43
+ const STARTER_JAML = `must:\n - joker: Blueprint\n antes: [1,2,3,4,5,6,7,8]\ndeck: Red\nstake: White\n`;
44
+
45
+ export default function App() {
46
+ const [jaml, setJaml] = useState(STARTER_JAML);
47
+ const search = useSearch();
48
+
49
+ const results: JamlIdeSearchResult[] = search.results.map((r) => ({
50
+ seed: r.seed,
51
+ score: r.score,
52
+ tallyColumns: r.tallyColumns,
53
+ }));
54
+
55
+ return (
56
+ <JamlIde
57
+ jaml={jaml}
58
+ onChange={setJaml}
59
+ searchResults={results}
60
+ isSearching={search.status === "running"}
61
+ onSearch={() => search.startAesthetic(jaml, /* aesthetic */ 0)}
62
+ />
63
+ );
64
+ }
65
+ ```
66
+
67
+ That's the whole integration. `useSearch` handles boot guarding, search lifecycle, progress events, and result accumulation; `JamlIde` renders the editor, visual filter, results column, and toolbar.
68
+
11
69
  ## Package exports
12
70
 
13
- | Entry | Contents |
14
- | ----- | -------- |
15
- | `jaml-ui` | Game card components, JAML IDE, hooks |
16
- | `jaml-ui/ui` | Jimbo design system — JimboPanel, JimboButton, JimboModal, tokens |
17
- | `jaml-ui/core` | Pure asset helpers, sprite metadata, decode utilities (no React) |
18
- | `jaml-ui/motely` | motely-wasm decode helpers (requires `motely-wasm` peer) |
19
- | `jaml-ui/r3f` | 3D card component via React Three Fiber (requires r3f peers) |
71
+ Five subpath entries, each a barrel. The public API is exactly what they re-export.
20
72
 
21
- ## Quick start
73
+ | Entry | What's in it | When you import it |
74
+ | ----- | ------------ | ------------------ |
75
+ | `jaml-ui` | Game cards, JAML IDE, search hooks | The default surface — most apps only need this |
76
+ | `jaml-ui/ui` | Jimbo design system (JimboPanel, JimboButton, JimboModal, tokens) | Building custom Balatro-styled UI |
77
+ | `jaml-ui/core` | Sprite metadata, asset URLs, canvas `Layer` — pure, **no React, no motely-wasm** | Next.js server components, server-side rendering |
78
+ | `jaml-ui/motely` | Re-exports `bootsharp` + `Motely` from motely-wasm, plus item-decode helpers and `useJamlLibrary` | Direct motely-wasm access, file-system mount |
79
+ | `jaml-ui/r3f` | 3D card via React Three Fiber | Optional, has its own peer deps |
22
80
 
23
81
  ```tsx
24
- import { JamlGameCard, JamlIde } from "jaml-ui";
25
- import { JimboPanel, JimboButton } from "jaml-ui/ui";
82
+ import { JamlGameCard, useSearch } from "jaml-ui";
83
+ import { JimboPanel, JimboButton, JimboColorOption } from "jaml-ui/ui";
84
+ import { resolveJamlAssetUrl, SPRITE_SHEETS } from "jaml-ui/core";
85
+ import { Motely, decodeMotelyItemName } from "jaml-ui/motely";
86
+ ```
87
+
88
+ ## Examples
89
+
90
+ | Path | What it shows |
91
+ | ---- | ------------- |
92
+ | `examples/seed-finder` | End-to-end Vite app: boots motely-wasm, renders `JamlIde`, runs real searches. Copy it, point it at your published `jaml-ui`, ship. |
93
+
94
+ ```bash
95
+ cd examples/seed-finder
96
+ pnpm install
97
+ pnpm dev
26
98
  ```
27
99
 
100
+ ## Core components
101
+
28
102
  ### Game card
29
103
 
30
104
  ```tsx
@@ -36,21 +110,10 @@ import { JamlGameCard } from "jaml-ui";
36
110
  />
37
111
  ```
38
112
 
39
- ### Jimbo UI (Balatro design system)
40
-
41
- ```tsx
42
- import { JimboPanel, JimboButton, JimboModal } from "jaml-ui/ui";
43
- import { JimboColorOption } from "jaml-ui/ui";
44
-
45
- <JimboPanel sway onBack={() => setOpen(false)}>
46
- <JimboButton variant="primary" onClick={handleSearch}>Search</JimboButton>
47
- </JimboPanel>
48
- ```
49
-
50
- Available variants: `primary`, `secondary`, `danger`, `back`, `ghost`
51
-
52
113
  ### JAML IDE
53
114
 
115
+ The full editor — code view, visual filter, results column, toolbar — in one component:
116
+
54
117
  ```tsx
55
118
  import { JamlIde } from "jaml-ui";
56
119
 
@@ -63,7 +126,15 @@ import { JamlIde } from "jaml-ui";
63
126
  />
64
127
  ```
65
128
 
66
- ### JAML Map Preview
129
+ ### Standalone code editor
130
+
131
+ ```tsx
132
+ import { JamlCodeEditor } from "jaml-ui";
133
+
134
+ <JamlCodeEditor value={jaml} onChange={setJaml} />
135
+ ```
136
+
137
+ ### JAML map preview
67
138
 
68
139
  ```tsx
69
140
  import { JamlMapPreview } from "jaml-ui";
@@ -71,73 +142,134 @@ import { JamlMapPreview } from "jaml-ui";
71
142
  <JamlMapPreview jaml={jaml} />
72
143
  ```
73
144
 
74
- ## Core utilities
145
+ ### Jimbo UI primitives
75
146
 
76
- ```ts
77
- import { SPRITE_SHEETS, getSpriteData, resolveJamlAssetUrl } from "jaml-ui/core";
147
+ ```tsx
148
+ import { JimboPanel, JimboButton, JimboModal } from "jaml-ui/ui";
149
+
150
+ <JimboPanel sway onBack={() => setOpen(false)}>
151
+ <JimboButton variant="primary" onClick={handleSearch}>Search</JimboButton>
152
+ </JimboPanel>
78
153
  ```
79
154
 
80
- ## Motely decode helpers
155
+ Button variants: `primary`, `secondary`, `danger`, `back`, `ghost`.
156
+
157
+ ## Hooks
158
+
159
+ All hooks lazily boot motely-wasm on first call if you skipped the top-level `bootsharp.boot()`.
160
+
161
+ ### `useSearch()` — run JAML filter searches
81
162
 
82
163
  ```ts
83
- import { decodeMotelyItemName, motelyItemTypeName } from "jaml-ui/motely";
164
+ import { useSearch } from "jaml-ui";
165
+
166
+ const {
167
+ results, // SearchResult[]
168
+ status, // "idle" | "running" | "completed" | "cancelled" | "error"
169
+ totalSearched, // bigint
170
+ matchingSeeds, // bigint
171
+ seedsPerSecond, // number
172
+ error, // string | null
173
+ startAesthetic, // (jaml, aesthetic) => Promise<void>
174
+ startSeedList, // (jaml, seeds[]) => Promise<void>
175
+ startRandom, // (jaml, count) => Promise<void>
176
+ cancel,
177
+ reset,
178
+ clearError,
179
+ } = useSearch();
84
180
  ```
85
181
 
86
- ## 3D card (optional)
182
+ ### `useAnalyzer()` analyze a known seed
87
183
 
88
- ```bash
89
- npm install three @react-three/fiber @react-three/drei @react-spring/three
184
+ ```ts
185
+ import { useAnalyzer } from "jaml-ui";
186
+ const { status, result, error, analyze } = useAnalyzer();
187
+ await analyze(jaml, "ALEEB");
90
188
  ```
91
189
 
190
+ ### `useSearchPool()` — multi-worker parallel search
191
+
192
+ For long searches, spreads work across a pool of web workers.
193
+
194
+ ### `useJamlLibrary()` — browser file picker for `.jaml` files
195
+
92
196
  ```tsx
93
- import { Card3D } from "jaml-ui/r3f";
197
+ import { useJamlLibrary } from "jaml-ui/motely";
94
198
 
95
- <Card3D itemName="Blueprint" />
199
+ const library = useJamlLibrary();
200
+ await library.mount(); // prompts user to pick a folder
201
+ const source = await library.loadFile(library.files[0]);
202
+ await library.saveFile("filters/example.jaml", source);
96
203
  ```
97
204
 
98
- ## Next.js
205
+ Requires `@rewaffle/bootsharp-file-system` (optional peer). When absent, `status === "unsupported"`.
99
206
 
100
- Import pure helpers from `jaml-ui/core` for server components. For local workspace installs add:
207
+ ## Core utilities (no React)
101
208
 
102
209
  ```ts
103
- // next.config.ts
104
- const nextConfig = { transpilePackages: ["jaml-ui"] };
210
+ import { SPRITE_SHEETS, getSpriteData, resolveJamlAssetUrl, Layer } from "jaml-ui/core";
105
211
  ```
106
212
 
107
- ## Search Worker Architecture
213
+ `resolveJamlAssetUrl(key)` returns a bundled asset URL — Vite imports the PNGs at build time, so consumers don't have to wire any base URL.
108
214
 
109
- The library provides `useSearch` and `useAnalyzer` helpers that use `motely-wasm`'s Bootsharp-generated ES module directly. Bootsharp handles the runtime bridge: import the generated package, boot the package `bin/` directory, then call `Motely`.
215
+ ## Motely decode helpers
110
216
 
111
217
  ```ts
112
- import bootsharp, { Motely } from "motely-wasm";
218
+ import {
219
+ decodeMotelyItem,
220
+ decodeMotelyItemName,
221
+ motelyItemDisplayName,
222
+ motelyItemTypeName,
223
+ } from "jaml-ui/motely";
224
+ ```
113
225
 
114
- await bootsharp.boot("/motely-wasm/bin");
115
- const status = Motely.validateJaml(jaml);
226
+ ## 3D card (optional)
227
+
228
+ ```bash
229
+ npm install three @react-three/fiber @react-three/drei @react-spring/three
116
230
  ```
117
231
 
118
232
  ```tsx
119
- import { useSearch, useJamlLibrary } from "jaml-ui/motely";
233
+ import { Card3D } from "jaml-ui/r3f";
120
234
 
121
- // result: { seed: string, score: number, tallyColumns?: number[] }
235
+ <Card3D itemName="Blueprint" />
122
236
  ```
123
237
 
124
- `useJamlLibrary` wires Bootsharp.FileSystem when `@rewaffle/bootsharp-file-system` is available, letting browser users pick a local JAML folder and read/write files through Motely's generated WASM API:
238
+ ## Next.js
125
239
 
126
- ```tsx
127
- const library = useJamlLibrary();
128
- await library.mount();
240
+ - Use `jaml-ui/core` from server components — it has no React and no motely-wasm imports.
241
+ - Use `jaml-ui` / `jaml-ui/motely` only from client components (mark the file with `"use client"`).
242
+ - Serve `motely-wasm/bin` at `/motely-wasm/bin` via a public folder or a catch-all route, then call `await bootsharp.boot("/motely-wasm/bin")` from a client component or your client entry script.
243
+ - If you're consuming this as a workspace package:
129
244
 
130
- const source = await library.loadFile(library.files[0]);
131
- await library.saveFile("filters/example.jaml", source);
132
- ```
245
+ ```ts
246
+ // next.config.ts
247
+ const nextConfig = { transpilePackages: ["jaml-ui"] };
248
+ ```
133
249
 
134
250
  ## Peer dependencies
135
251
 
136
- | Peer | Required for |
137
- | ---- | ------------ |
138
- | `react`, `react-dom` | All components |
139
- | `react-icons` | Components that render icons (optional peer) |
140
- | `@rewaffle/bootsharp-file-system` | Optional JAML library folder mount support |
141
- | `three`, `@react-three/fiber`, `@react-three/drei`, `@react-spring/three` | `jaml-ui/r3f` only |
252
+ | Peer | Required for | Optional? |
253
+ | ---- | ------------ | --------- |
254
+ | `react`, `react-dom` | All components | No |
255
+ | `motely-wasm` | All search/analyzer/decode functionality | No (direct dep) |
256
+ | `react-icons` | Components that render icons | Yes |
257
+ | `@rewaffle/bootsharp-file-system` | `useJamlLibrary` folder mount | Yes |
258
+ | `three`, `@react-three/fiber`, `@react-three/drei`, `@react-spring/three` | `jaml-ui/r3f` only | Yes |
259
+
260
+ ## Troubleshooting
261
+
262
+ - **"Motely is not initialized"** — you didn't call `bootsharp.boot()` before rendering, and the lazy guard hasn't fired yet. Add `await bootsharp.boot("/motely-wasm/bin")` to your entry point.
263
+ - **`404 /motely-wasm/bin/...`** — copy `node_modules/motely-wasm/bin/` into `public/motely-wasm/bin/` (Vite) or add a static route (Next.js).
264
+ - **CSS not applied** — make sure you imported from `jaml-ui` or `jaml-ui/ui` at least once. Both pull in `jimbo.css` as a side effect. If your bundler strips side-effect imports, add `import "jaml-ui/jimbo.css"`.
265
+ - **Storybook hangs on boot** — Storybook's `staticDirs` already serves `motely-wasm/bin`; see `.storybook/main.ts` for the pattern.
266
+
267
+ ## Fonts
268
+
269
+ Jimbo UI uses **m6x11** and **m6x11plus** (`.ttf` in `assets/fonts/`). Fonts by [Daniel Linssen](https://managore.itch.io/) — free to use with attribution. If you ship an app that shows this UI, include that credit in your README or notices.
270
+
271
+ Code blocks use **JetBrains Mono** / system monospace via `--j-font-code`, not the pixel fonts.
272
+
273
+ ## License
142
274
 
143
- `motely-wasm` is a direct dependency (currently `^17.7.0`) it ships with `jaml-ui` rather than as a peer, but is externalized from the bundle so consumers control how the Bootsharp runtime is served (see *Search Worker Architecture* above).
275
+ MIT see [LICENSE](LICENSE). Font files are separate third-party assets; attribution to Daniel Linssen is required when redistributing or displaying the pixel fonts.
@@ -0,0 +1,14 @@
1
+ # Fonts
2
+
3
+ | File | Family | Notes |
4
+ |------|--------|--------|
5
+ | `m6x11.ttf` | `m6x11` | Base pixel font. Prefer sizes 16, 32, 48, … |
6
+ | `m6x11plus.ttf` | `m6x11plus` | Extended charset (+6 width, taller metrics). Prefer 18, 36, 54, … |
7
+
8
+ `m6x11plusplus.otf` is a legacy bundle copy; **do not use** for new work — use the `.ttf` files above.
9
+
10
+ ## Attribution
11
+
12
+ UI fonts by [Daniel Linssen](https://managore.itch.io/) — free to use with attribution.
13
+
14
+ Include credit in your app README or notices when shipping jaml-ui consumers (for example: “UI fonts by Daniel Linssen — https://managore.itch.io/”).
Binary file
Binary file
package/dist/.gitkeep ADDED
File without changes