jaml-ui 0.22.4 → 0.23.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 CHANGED
@@ -1,147 +1,147 @@
1
- # jaml-ui
2
-
3
- React components, UI tokens, sprites, and utilities for Balatro/JAML apps.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install jaml-ui react react-dom
9
- ```
10
-
11
- ## Package exports
12
-
13
- | Entry | Contents |
14
- |-------|----------|
15
- | `jaml-ui` | Game card components, JAML IDE, Analyzer Explorer, 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) |
20
-
21
- ## Quick start
22
-
23
- ```tsx
24
- import { JamlGameCard, AnalyzerExplorer, JamlIde } from "jaml-ui";
25
- import { JimboPanel, JimboButton } from "jaml-ui/ui";
26
- ```
27
-
28
- ### Game card
29
-
30
- ```tsx
31
- import { JamlGameCard } from "jaml-ui";
32
-
33
- <JamlGameCard
34
- type="joker"
35
- card={{ name: "Blueprint", edition: "Foil", isEternal: true, scale: 1.5 }}
36
- />
37
- ```
38
-
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
- ### JAML IDE
53
-
54
- ```tsx
55
- import { JamlIde } from "jaml-ui";
56
-
57
- <JamlIde
58
- jaml={jaml}
59
- onChange={setJaml}
60
- searchResults={results}
61
- onSearch={handleSearch}
62
- isSearching={isSearching}
63
- />
64
- ```
65
-
66
- ### Analyzer Explorer
67
-
68
- ```tsx
69
- import { AnalyzerExplorer } from "jaml-ui";
70
-
71
- // antes: AnalyzerAnteView[] — stream from motely-wasm createSearchContext
72
- <AnalyzerExplorer antes={antes} totalAntes={8} highlights={highlights} />
73
- ```
74
-
75
- ### JAML Map Preview
76
-
77
- ```tsx
78
- import { JamlMapPreview } from "jaml-ui";
79
-
80
- <JamlMapPreview jaml={jaml} />
81
- ```
82
-
83
- ## Asset handling
84
-
85
- By default sprites resolve from the package `assets/` directory via `import.meta.url`.
86
-
87
- Override at app startup:
88
-
89
- ```ts
90
- import { setJamlAssetBaseUrl, clearJamlAssetBaseUrl } from "jaml-ui";
91
-
92
- setJamlAssetBaseUrl("/vendor/jaml-ui/"); // custom CDN
93
- clearJamlAssetBaseUrl(); // back to default
94
- ```
95
-
96
- ## Core utilities
97
-
98
- ```ts
99
- import { SPRITE_SHEETS, getSpriteData, resolveJamlAssetUrl } from "jaml-ui/core";
100
- ```
101
-
102
- ## Motely decode helpers
103
-
104
- ```ts
105
- import { decodeMotelyItemName, motelyItemTypeName } from "jaml-ui/motely";
106
- ```
107
-
108
- ## 3D card (optional)
109
-
110
- ```bash
111
- npm install three @react-three/fiber @react-three/drei @react-spring/three
112
- ```
113
-
114
- ```tsx
115
- import { Card3D } from "jaml-ui/r3f";
116
-
117
- <Card3D itemName="Blueprint" />
118
- ```
119
-
120
- ## Next.js
121
-
122
- Import pure helpers from `jaml-ui/core` for server components. For local workspace installs add:
123
-
124
- ```ts
125
- // next.config.ts
126
- const nextConfig = { transpilePackages: ["jaml-ui"] };
127
- ```
128
-
129
- ## Search Worker Architecture
130
-
131
- The library provides `useAnalyzer` to interact with `motely-wasm`'s search context natively.
132
- **Important:** As of `motely-wasm@14.3.3`, the search worker utilizes Vite's `?worker&inline` pattern. You no longer need to pass `motelyWasmUrl`.
133
-
134
- Ensure `motely-wasm` is imported and booted at the module level in your application:
135
-
136
- ```tsx
137
- import { boot } from "motely-wasm";
138
- boot(); // Call early in your application lifecycle
139
- ```
140
-
141
- ## Peer dependencies
142
-
143
- | Peer | Required for |
144
- |------|-------------|
145
- | `react`, `react-dom` | All components |
146
- | `motely-wasm ^14.3.3` | `jaml-ui/motely`, `AnalyzerExplorer`, `useAnalyzer` data |
147
- | `three`, `@react-three/fiber`, `@react-three/drei`, `@react-spring/three` | `jaml-ui/r3f` only |
1
+ # jaml-ui
2
+
3
+ React components, UI tokens, sprites, and utilities for Balatro/JAML apps.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install jaml-ui react react-dom
9
+ ```
10
+
11
+ ## Package exports
12
+
13
+ | Entry | Contents |
14
+ |-------|----------|
15
+ | `jaml-ui` | Game card components, JAML IDE, Analyzer Explorer, 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) |
20
+
21
+ ## Quick start
22
+
23
+ ```tsx
24
+ import { JamlGameCard, AnalyzerExplorer, JamlIde } from "jaml-ui";
25
+ import { JimboPanel, JimboButton } from "jaml-ui/ui";
26
+ ```
27
+
28
+ ### Game card
29
+
30
+ ```tsx
31
+ import { JamlGameCard } from "jaml-ui";
32
+
33
+ <JamlGameCard
34
+ type="joker"
35
+ card={{ name: "Blueprint", edition: "Foil", isEternal: true, scale: 1.5 }}
36
+ />
37
+ ```
38
+
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
+ ### JAML IDE
53
+
54
+ ```tsx
55
+ import { JamlIde } from "jaml-ui";
56
+
57
+ <JamlIde
58
+ jaml={jaml}
59
+ onChange={setJaml}
60
+ searchResults={results}
61
+ onSearch={handleSearch}
62
+ isSearching={isSearching}
63
+ />
64
+ ```
65
+
66
+ ### Analyzer Explorer
67
+
68
+ ```tsx
69
+ import { AnalyzerExplorer } from "jaml-ui";
70
+
71
+ // antes: AnalyzerAnteView[] — stream from motely-wasm createSearchContext
72
+ <AnalyzerExplorer antes={antes} totalAntes={8} highlights={highlights} />
73
+ ```
74
+
75
+ ### JAML Map Preview
76
+
77
+ ```tsx
78
+ import { JamlMapPreview } from "jaml-ui";
79
+
80
+ <JamlMapPreview jaml={jaml} />
81
+ ```
82
+
83
+ ## Asset handling
84
+
85
+ By default sprites resolve from the package `assets/` directory via `import.meta.url`.
86
+
87
+ Override at app startup:
88
+
89
+ ```ts
90
+ import { setJamlAssetBaseUrl, clearJamlAssetBaseUrl } from "jaml-ui";
91
+
92
+ setJamlAssetBaseUrl("/vendor/jaml-ui/"); // custom CDN
93
+ clearJamlAssetBaseUrl(); // back to default
94
+ ```
95
+
96
+ ## Core utilities
97
+
98
+ ```ts
99
+ import { SPRITE_SHEETS, getSpriteData, resolveJamlAssetUrl } from "jaml-ui/core";
100
+ ```
101
+
102
+ ## Motely decode helpers
103
+
104
+ ```ts
105
+ import { decodeMotelyItemName, motelyItemTypeName } from "jaml-ui/motely";
106
+ ```
107
+
108
+ ## 3D card (optional)
109
+
110
+ ```bash
111
+ npm install three @react-three/fiber @react-three/drei @react-spring/three
112
+ ```
113
+
114
+ ```tsx
115
+ import { Card3D } from "jaml-ui/r3f";
116
+
117
+ <Card3D itemName="Blueprint" />
118
+ ```
119
+
120
+ ## Next.js
121
+
122
+ Import pure helpers from `jaml-ui/core` for server components. For local workspace installs add:
123
+
124
+ ```ts
125
+ // next.config.ts
126
+ const nextConfig = { transpilePackages: ["jaml-ui"] };
127
+ ```
128
+
129
+ ## Search Worker Architecture
130
+
131
+ The library provides `useAnalyzer` to interact with `motely-wasm`'s search context natively.
132
+ **Important:** As of `motely-wasm@14.3.3`, the search worker utilizes Vite's `?worker&inline` pattern. You no longer need to pass `motelyWasmUrl`.
133
+
134
+ Ensure `motely-wasm` is imported and booted at the module level in your application:
135
+
136
+ ```tsx
137
+ import { boot } from "motely-wasm";
138
+ boot(); // Call early in your application lifecycle
139
+ ```
140
+
141
+ ## Peer dependencies
142
+
143
+ | Peer | Required for |
144
+ |------|-------------|
145
+ | `react`, `react-dom` | All components |
146
+ | `motely-wasm ^14.3.3` | `jaml-ui/motely`, `AnalyzerExplorer`, `useAnalyzer` data |
147
+ | `three`, `@react-three/fiber`, `@react-three/drei`, `@react-spring/three` | `jaml-ui/r3f` only |
@@ -1 +1 @@
1
- export declare const SEARCH_WORKER_CODE = "\nlet MotelyWasm = null;\nlet MotelyWasmEvents = null;\nlet Filters = null;\nlet activeSearch = null;\n\nself.addEventListener('message', async function(e) {\n const msg = e.data;\n\n if (msg.type === 'init') {\n try {\n const mod = await import(msg.url);\n await mod.default.boot();\n MotelyWasm = mod.MotelyWasm;\n MotelyWasmEvents = mod.MotelyWasmEvents;\n Filters = mod.Filters;\n self.postMessage({ type: 'ready' });\n } catch (err) {\n self.postMessage({ type: 'error', message: String(err) });\n }\n return;\n }\n\n if (msg.type === 'start') {\n if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }\n const validation = MotelyWasm.validateJaml(msg.jaml);\n if (validation !== 'valid') { self.postMessage({ type: 'error', message: validation }); return; }\n\n let rId, pId, cId;\n function cleanup() {\n MotelyWasmEvents.onResult.unsubscribeById(rId);\n MotelyWasmEvents.onProgress.unsubscribeById(pId);\n MotelyWasmEvents.onComplete.unsubscribeById(cId);\n activeSearch = null;\n }\n\n rId = MotelyWasmEvents.onResult.subscribe(function(seed, score, tallyColumns) {\n self.postMessage({ type: 'result', seed, score, tallyColumns: Array.from(tallyColumns) });\n });\n pId = MotelyWasmEvents.onProgress.subscribe(function(searched, matching) {\n self.postMessage({ type: 'progress', searched: searched.toString(), matching: matching.toString() });\n });\n cId = MotelyWasmEvents.onComplete.subscribe(function(status, searched, matched) {\n cleanup();\n self.postMessage({ type: 'complete', status, searched: searched.toString(), matched: matched.toString() });\n });\n\n try {\n const mode = msg.mode || 'random';\n\n if (mode === 'random') {\n activeSearch = MotelyWasm.startRandomSearch(msg.jaml, msg.count);\n } else if (mode === 'aesthetic') {\n activeSearch = MotelyWasm.startAestheticSearch(msg.jaml, msg.aesthetic);\n } else if (mode === 'seedList') {\n activeSearch = MotelyWasm.startSeedListSearch(msg.jaml, msg.seeds);\n } else if (mode === 'keyword') {\n activeSearch = MotelyWasm.startKeywordSearch(msg.jaml, msg.keywords, msg.padding || '');\n } else if (mode === 'sequential') {\n activeSearch = MotelyWasm.startSequentialSearch(msg.jaml, msg.batchCharCount, BigInt(msg.startBatch), BigInt(msg.endBatch));\n } else {\n self.postMessage({ type: 'error', message: 'Unknown search mode: ' + mode });\n cleanup();\n return;\n }\n } catch (err) {\n cleanup();\n self.postMessage({ type: 'error', message: String(err) });\n }\n return;\n }\n\n if (msg.type === 'stop') {\n if (activeSearch) { activeSearch.cancel(); activeSearch = null; }\n self.postMessage({ type: 'cancelled' });\n }\n\n if (msg.type === 'get_tally_labels') {\n if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }\n try {\n const labels = MotelyWasm.getTallyLabels(msg.jaml);\n self.postMessage({ type: 'tally_labels', labels });\n } catch (err) {\n self.postMessage({ type: 'error', message: String(err) });\n }\n }\n});\n";
1
+ export declare const SEARCH_WORKER_CODE = "\nlet MotelyWasm = null;\nlet MotelyWasmEvents = null;\nlet activeSearch = null;\n\nself.addEventListener('message', async function(e) {\n const msg = e.data;\n\n if (msg.type === 'init') {\n try {\n const mod = await import(msg.url);\n await mod.default.boot();\n const motely = mod.Motely;\n MotelyWasm = motely.MotelyWasm;\n MotelyWasmEvents = motely.MotelyWasmEvents;\n self.postMessage({ type: 'ready' });\n } catch (err) {\n self.postMessage({ type: 'error', message: String(err) });\n }\n return;\n }\n\n if (msg.type === 'start') {\n if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }\n const validation = MotelyWasm.validateJaml(msg.jaml);\n if (validation !== 'valid') { self.postMessage({ type: 'error', message: validation }); return; }\n\n function cleanup() {\n MotelyWasmEvents.notifyResult = () => {};\n MotelyWasmEvents.notifyProgress = () => {};\n MotelyWasmEvents.notifyComplete = () => {};\n activeSearch = null;\n }\n\n MotelyWasmEvents.notifyResult = function(seed, score, tallyColumns) {\n self.postMessage({ type: 'result', seed, score, tallyColumns: Array.from(tallyColumns) });\n };\n MotelyWasmEvents.notifyProgress = function(searched, matching) {\n self.postMessage({ type: 'progress', searched: searched.toString(), matching: matching.toString() });\n };\n MotelyWasmEvents.notifyComplete = function(status, searched, matched) {\n cleanup();\n self.postMessage({ type: 'complete', status, searched: searched.toString(), matched: matched.toString() });\n };\n\n try {\n const mode = msg.mode || 'random';\n if (mode === 'random') {\n activeSearch = MotelyWasm.startRandomSearch(msg.jaml, msg.count);\n } else if (mode === 'aesthetic') {\n activeSearch = MotelyWasm.startAestheticSearch(msg.jaml, msg.aesthetic);\n } else if (mode === 'seedList') {\n activeSearch = MotelyWasm.startSeedListSearch(msg.jaml, msg.seeds);\n } else if (mode === 'keyword') {\n activeSearch = MotelyWasm.startKeywordSearch(msg.jaml, msg.keywords, msg.padding || '');\n } else if (mode === 'sequential') {\n activeSearch = MotelyWasm.startSequentialSearch(msg.jaml, msg.batchCharCount, BigInt(msg.startBatch), BigInt(msg.endBatch));\n } else {\n self.postMessage({ type: 'error', message: 'Unknown search mode: ' + mode });\n cleanup();\n return;\n }\n } catch (err) {\n cleanup();\n self.postMessage({ type: 'error', message: String(err) });\n }\n return;\n }\n\n if (msg.type === 'stop') {\n if (activeSearch) { activeSearch.cancel(); activeSearch = null; }\n self.postMessage({ type: 'cancelled' });\n }\n\n if (msg.type === 'get_tally_labels') {\n if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }\n try {\n const labels = MotelyWasm.getTallyLabels(msg.jaml);\n self.postMessage({ type: 'tally_labels', labels: Array.from(labels) });\n } catch (err) {\n self.postMessage({ type: 'error', message: String(err) });\n }\n }\n});\n";
@@ -1,88 +1,85 @@
1
- export const SEARCH_WORKER_CODE = `
2
- let MotelyWasm = null;
3
- let MotelyWasmEvents = null;
4
- let Filters = null;
5
- let activeSearch = null;
6
-
7
- self.addEventListener('message', async function(e) {
8
- const msg = e.data;
9
-
10
- if (msg.type === 'init') {
11
- try {
12
- const mod = await import(msg.url);
13
- await mod.default.boot();
14
- MotelyWasm = mod.MotelyWasm;
15
- MotelyWasmEvents = mod.MotelyWasmEvents;
16
- Filters = mod.Filters;
17
- self.postMessage({ type: 'ready' });
18
- } catch (err) {
19
- self.postMessage({ type: 'error', message: String(err) });
20
- }
21
- return;
22
- }
23
-
24
- if (msg.type === 'start') {
25
- if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }
26
- const validation = MotelyWasm.validateJaml(msg.jaml);
27
- if (validation !== 'valid') { self.postMessage({ type: 'error', message: validation }); return; }
28
-
29
- let rId, pId, cId;
30
- function cleanup() {
31
- MotelyWasmEvents.onResult.unsubscribeById(rId);
32
- MotelyWasmEvents.onProgress.unsubscribeById(pId);
33
- MotelyWasmEvents.onComplete.unsubscribeById(cId);
34
- activeSearch = null;
35
- }
36
-
37
- rId = MotelyWasmEvents.onResult.subscribe(function(seed, score, tallyColumns) {
38
- self.postMessage({ type: 'result', seed, score, tallyColumns: Array.from(tallyColumns) });
39
- });
40
- pId = MotelyWasmEvents.onProgress.subscribe(function(searched, matching) {
41
- self.postMessage({ type: 'progress', searched: searched.toString(), matching: matching.toString() });
42
- });
43
- cId = MotelyWasmEvents.onComplete.subscribe(function(status, searched, matched) {
44
- cleanup();
45
- self.postMessage({ type: 'complete', status, searched: searched.toString(), matched: matched.toString() });
46
- });
47
-
48
- try {
49
- const mode = msg.mode || 'random';
50
-
51
- if (mode === 'random') {
52
- activeSearch = MotelyWasm.startRandomSearch(msg.jaml, msg.count);
53
- } else if (mode === 'aesthetic') {
54
- activeSearch = MotelyWasm.startAestheticSearch(msg.jaml, msg.aesthetic);
55
- } else if (mode === 'seedList') {
56
- activeSearch = MotelyWasm.startSeedListSearch(msg.jaml, msg.seeds);
57
- } else if (mode === 'keyword') {
58
- activeSearch = MotelyWasm.startKeywordSearch(msg.jaml, msg.keywords, msg.padding || '');
59
- } else if (mode === 'sequential') {
60
- activeSearch = MotelyWasm.startSequentialSearch(msg.jaml, msg.batchCharCount, BigInt(msg.startBatch), BigInt(msg.endBatch));
61
- } else {
62
- self.postMessage({ type: 'error', message: 'Unknown search mode: ' + mode });
63
- cleanup();
64
- return;
65
- }
66
- } catch (err) {
67
- cleanup();
68
- self.postMessage({ type: 'error', message: String(err) });
69
- }
70
- return;
71
- }
72
-
73
- if (msg.type === 'stop') {
74
- if (activeSearch) { activeSearch.cancel(); activeSearch = null; }
75
- self.postMessage({ type: 'cancelled' });
76
- }
77
-
78
- if (msg.type === 'get_tally_labels') {
79
- if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }
80
- try {
81
- const labels = MotelyWasm.getTallyLabels(msg.jaml);
82
- self.postMessage({ type: 'tally_labels', labels });
83
- } catch (err) {
84
- self.postMessage({ type: 'error', message: String(err) });
85
- }
86
- }
87
- });
1
+ export const SEARCH_WORKER_CODE = `
2
+ let MotelyWasm = null;
3
+ let MotelyWasmEvents = null;
4
+ let activeSearch = null;
5
+
6
+ self.addEventListener('message', async function(e) {
7
+ const msg = e.data;
8
+
9
+ if (msg.type === 'init') {
10
+ try {
11
+ const mod = await import(msg.url);
12
+ await mod.default.boot();
13
+ const motely = mod.Motely;
14
+ MotelyWasm = motely.MotelyWasm;
15
+ MotelyWasmEvents = motely.MotelyWasmEvents;
16
+ self.postMessage({ type: 'ready' });
17
+ } catch (err) {
18
+ self.postMessage({ type: 'error', message: String(err) });
19
+ }
20
+ return;
21
+ }
22
+
23
+ if (msg.type === 'start') {
24
+ if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }
25
+ const validation = MotelyWasm.validateJaml(msg.jaml);
26
+ if (validation !== 'valid') { self.postMessage({ type: 'error', message: validation }); return; }
27
+
28
+ function cleanup() {
29
+ MotelyWasmEvents.notifyResult = () => {};
30
+ MotelyWasmEvents.notifyProgress = () => {};
31
+ MotelyWasmEvents.notifyComplete = () => {};
32
+ activeSearch = null;
33
+ }
34
+
35
+ MotelyWasmEvents.notifyResult = function(seed, score, tallyColumns) {
36
+ self.postMessage({ type: 'result', seed, score, tallyColumns: Array.from(tallyColumns) });
37
+ };
38
+ MotelyWasmEvents.notifyProgress = function(searched, matching) {
39
+ self.postMessage({ type: 'progress', searched: searched.toString(), matching: matching.toString() });
40
+ };
41
+ MotelyWasmEvents.notifyComplete = function(status, searched, matched) {
42
+ cleanup();
43
+ self.postMessage({ type: 'complete', status, searched: searched.toString(), matched: matched.toString() });
44
+ };
45
+
46
+ try {
47
+ const mode = msg.mode || 'random';
48
+ if (mode === 'random') {
49
+ activeSearch = MotelyWasm.startRandomSearch(msg.jaml, msg.count);
50
+ } else if (mode === 'aesthetic') {
51
+ activeSearch = MotelyWasm.startAestheticSearch(msg.jaml, msg.aesthetic);
52
+ } else if (mode === 'seedList') {
53
+ activeSearch = MotelyWasm.startSeedListSearch(msg.jaml, msg.seeds);
54
+ } else if (mode === 'keyword') {
55
+ activeSearch = MotelyWasm.startKeywordSearch(msg.jaml, msg.keywords, msg.padding || '');
56
+ } else if (mode === 'sequential') {
57
+ activeSearch = MotelyWasm.startSequentialSearch(msg.jaml, msg.batchCharCount, BigInt(msg.startBatch), BigInt(msg.endBatch));
58
+ } else {
59
+ self.postMessage({ type: 'error', message: 'Unknown search mode: ' + mode });
60
+ cleanup();
61
+ return;
62
+ }
63
+ } catch (err) {
64
+ cleanup();
65
+ self.postMessage({ type: 'error', message: String(err) });
66
+ }
67
+ return;
68
+ }
69
+
70
+ if (msg.type === 'stop') {
71
+ if (activeSearch) { activeSearch.cancel(); activeSearch = null; }
72
+ self.postMessage({ type: 'cancelled' });
73
+ }
74
+
75
+ if (msg.type === 'get_tally_labels') {
76
+ if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }
77
+ try {
78
+ const labels = MotelyWasm.getTallyLabels(msg.jaml);
79
+ self.postMessage({ type: 'tally_labels', labels: Array.from(labels) });
80
+ } catch (err) {
81
+ self.postMessage({ type: 'error', message: String(err) });
82
+ }
83
+ }
84
+ });
88
85
  `;