jaml-ui 2.1.0 → 2.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/dist/assets/searchPoolWorker-BVUnMwk8.js +2 -0
- package/dist/assets/searchPoolWorker-BVUnMwk8.js.map +1 -0
- package/dist/chunks/{runtime-DAQf1WrX.js → runtime-Dx5VPTsV.js} +374 -365
- package/dist/chunks/{runtime-DAQf1WrX.js.map → runtime-Dx5VPTsV.js.map} +1 -1
- package/dist/chunks/{searchPoolWorker-BO7D6obp.js → searchPoolWorker-Dx7DqN-S.js} +2 -2
- package/dist/chunks/searchPoolWorker-Dx7DqN-S.js.map +1 -0
- package/dist/chunks/{ui-BXbEyxHZ.js → ui-vpt-ySR1.js} +521 -521
- package/dist/chunks/ui-vpt-ySR1.js.map +1 -0
- package/dist/components/Jamlyzer.d.ts +8 -0
- package/dist/hooks/useAnalyzer.d.ts +15 -0
- package/dist/hooks/useSearch.d.ts +4 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4557 -4117
- package/dist/index.js.map +1 -1
- package/dist/lib/hooks/useSeedAnalyzer.d.ts +17 -0
- package/dist/lib/motely/runtime.d.ts +6 -0
- package/dist/motely.js +21 -21
- package/dist/ui.js +2 -2
- package/package.json +3 -3
- package/dist/assets/searchPoolWorker-BgC_66wv.js +0 -2
- package/dist/assets/searchPoolWorker-BgC_66wv.js.map +0 -1
- package/dist/chunks/searchPoolWorker-BO7D6obp.js.map +0 -1
- package/dist/chunks/ui-BXbEyxHZ.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Program as MotelyNamespace } from 'motely-wasm/motely/wasm';
|
|
2
|
+
import { JamlyzerSnapshot } from 'motely-wasm/motely/analysis';
|
|
3
|
+
type MotelyApi = typeof MotelyNamespace;
|
|
4
|
+
/** Per-seed result shape, reassembled from the split motely-wasm 21.1 API
|
|
5
|
+
* (the old jamlyzer(config) bundled score + analysis per seed). */
|
|
6
|
+
export interface SeedAnalyzerResult {
|
|
7
|
+
seed: string;
|
|
8
|
+
score: number;
|
|
9
|
+
tallies: number[];
|
|
10
|
+
analysis: JamlyzerSnapshot;
|
|
11
|
+
}
|
|
12
|
+
export declare function useSeedAnalyzer(motely: MotelyApi | null, seed: string | null, jaml?: string): {
|
|
13
|
+
data: SeedAnalyzerResult | null;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { MotelyScoredSeedResult } from 'motely-wasm/motely';
|
|
1
2
|
export type MotelyRuntimeStatus = "idle" | "booting" | "ready" | "error";
|
|
3
|
+
export type JimmolateProbe = (result: MotelyScoredSeedResult) => boolean;
|
|
4
|
+
/** Swap the active Jimmolate predicate. Safe before or after boot. */
|
|
5
|
+
export declare function setJimmolateProbe(pred: JimmolateProbe): void;
|
|
6
|
+
/** Reset the probe to pass-through (the engine's default: every survivor matches). */
|
|
7
|
+
export declare function clearJimmolateProbe(): void;
|
|
2
8
|
export declare const MOTELY_BIN_PATH = "/motely-wasm/bin";
|
|
3
9
|
/** True once the optional File System extension was bound before boot. */
|
|
4
10
|
export declare function isFileSystemReady(): boolean;
|
package/dist/motely.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { f as e, g as t, r as n, t as r, x as i } from "./chunks/spriteMapper-C8uYedXB.js";
|
|
3
|
-
import {
|
|
3
|
+
import { _ as a, a as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, p as h, r as g, s as _, t as v, u as y, v as b, w as x, y as S } from "./chunks/runtime-Dx5VPTsV.js";
|
|
4
4
|
import { useCallback as C, useState as w } from "react";
|
|
5
5
|
import { Program as T, Program as E } from "motely-wasm/motely/wasm";
|
|
6
6
|
import D from "motely-wasm";
|
|
7
7
|
import { PermissionMode as O } from "motely-wasm/bootsharp/file-system";
|
|
8
8
|
//#region src/decode/motelySprite.ts
|
|
9
9
|
function k(a) {
|
|
10
|
-
let o =
|
|
10
|
+
let o = _(a);
|
|
11
11
|
if (!o) return null;
|
|
12
12
|
if (o.category === "playing" && o.rank && o.suit) {
|
|
13
13
|
let n = e[o.rank], r = t[o.suit];
|
|
@@ -21,15 +21,15 @@ function k(a) {
|
|
|
21
21
|
category: "playing"
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
let
|
|
25
|
-
if (!
|
|
26
|
-
let
|
|
27
|
-
return
|
|
28
|
-
atlasPath: i(
|
|
29
|
-
gridCol:
|
|
30
|
-
gridRow:
|
|
31
|
-
gridCols:
|
|
32
|
-
gridRows:
|
|
24
|
+
let s = n(o.displayName);
|
|
25
|
+
if (!s) return null;
|
|
26
|
+
let c = r[s.type];
|
|
27
|
+
return c ? {
|
|
28
|
+
atlasPath: i(c.assetKey),
|
|
29
|
+
gridCol: s.pos.x,
|
|
30
|
+
gridRow: s.pos.y,
|
|
31
|
+
gridCols: c.cols,
|
|
32
|
+
gridRows: c.rows,
|
|
33
33
|
displayName: o.displayName,
|
|
34
34
|
category: o.category
|
|
35
35
|
} : null;
|
|
@@ -98,7 +98,7 @@ function V(e) {
|
|
|
98
98
|
return e;
|
|
99
99
|
}
|
|
100
100
|
function H(e) {
|
|
101
|
-
return
|
|
101
|
+
return x[e & 65535]?.displayName ?? `item#${e}`;
|
|
102
102
|
}
|
|
103
103
|
//#endregion
|
|
104
104
|
//#region src/hooks/useJamlLibrary.ts
|
|
@@ -106,19 +106,19 @@ function U(e) {
|
|
|
106
106
|
return e instanceof Error ? e.message : String(e);
|
|
107
107
|
}
|
|
108
108
|
function W() {
|
|
109
|
-
let [e, t] = w("idle"), [n, r] = w(null), [i, a] = w([]), [
|
|
109
|
+
let [e, t] = w("idle"), [n, r] = w(null), [i, a] = w([]), [s, c] = w(null), l = C(() => {
|
|
110
110
|
n && a((e) => [...e]);
|
|
111
111
|
}, [n]);
|
|
112
112
|
return {
|
|
113
113
|
status: e,
|
|
114
114
|
rootId: n,
|
|
115
115
|
files: i,
|
|
116
|
-
error:
|
|
116
|
+
error: s,
|
|
117
117
|
mount: C(async () => {
|
|
118
|
-
t("mounting"),
|
|
118
|
+
t("mounting"), c(null);
|
|
119
119
|
try {
|
|
120
|
-
if (await g(), !
|
|
121
|
-
t("unsupported"),
|
|
120
|
+
if (await g(), !o()) {
|
|
121
|
+
t("unsupported"), c(U(f() ?? "Bootsharp FileSystem package is not available."));
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
124
|
let e = await T.pickRoot({
|
|
@@ -131,11 +131,11 @@ function W() {
|
|
|
131
131
|
}
|
|
132
132
|
r(await T.mountRoot(e, { mode: O.ReadWrite })), a([]), t("ready");
|
|
133
133
|
} catch (e) {
|
|
134
|
-
t("error"),
|
|
134
|
+
t("error"), c(U(e));
|
|
135
135
|
}
|
|
136
136
|
}, []),
|
|
137
137
|
unmount: C(async () => {
|
|
138
|
-
n && (await g(), await T.unmountRoot(n), r(null), a([]), t(
|
|
138
|
+
n && (await g(), await T.unmountRoot(n), r(null), a([]), t(o() ? "idle" : "unsupported"));
|
|
139
139
|
}, [n]),
|
|
140
140
|
loadFile: C(async (e) => {
|
|
141
141
|
if (!n) throw Error("JAML library is not mounted.");
|
|
@@ -145,10 +145,10 @@ function W() {
|
|
|
145
145
|
if (!n) throw Error("JAML library is not mounted.");
|
|
146
146
|
await g(), await T.writeTextFile(n, e, t), a((t) => (t.includes(e) ? t : [...t, e]).sort((e, t) => e.localeCompare(t)));
|
|
147
147
|
}, [n]),
|
|
148
|
-
refresh:
|
|
148
|
+
refresh: l
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
//#endregion
|
|
152
|
-
export {
|
|
152
|
+
export { v as MOTELY_BIN_PATH, E as Motely, D as bootsharp, _ as decodeMotelyItem, s as decodeMotelyItemName, p as decodeMotelyItemToJamlCard, g as ensureMotelyReady, A as getMotelySpriteByName, z as motelyBoosterPackDisplayName, B as motelyBoosterPackDisplayNameFromKey, N as motelyBossDisplayName, P as motelyBossDisplayNameFromKey, y as motelyItemCategory, c as motelyItemDisplayName, V as motelyItemDisplayNameFromKey, H as motelyItemDisplayNameFromValue, l as motelyItemEditionName, h as motelyItemEnhancementName, m as motelyItemRenderCategory, d as motelyItemSealName, k as motelyItemToSprite, u as motelyItemTypeName, a as motelyStandardcardRankName, b as motelyStandardcardSuitName, L as motelyTagDisplayName, R as motelyTagDisplayNameFromKey, F as motelyVoucherDisplayName, I as motelyVoucherDisplayNameFromKey, S as resolveMotelyItemType, W as useJamlLibrary };
|
|
153
153
|
|
|
154
154
|
//# sourceMappingURL=motely.js.map
|
package/dist/ui.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, O as h, P as g, Q as _, R as v, S as y, T as b, U as x, V as S, W as C, X as w, Y as T, Z as E, _ as D, a as O, b as k, c as A, ct as j, d as M, et as N, f as P, g as F, h as I, i as L, it as R, j as z, k as B, l as V, lt as H, m as U, n as W, nt as G, o as K, p as q, q as J, r as Y, rt as X, s as Z, st as Q, t as $, tt as ee, u as te, v as ne, w as re, x as ie, y as ae, z as oe } from "./chunks/ui-
|
|
3
|
-
export { G as DeckSprite, Q as JIMBO_ANIMATIONS,
|
|
2
|
+
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, O as h, P as g, Q as _, R as v, S as y, T as b, U as x, V as S, W as C, X as w, Y as T, Z as E, _ as D, a as O, b as k, c as A, ct as j, d as M, et as N, f as P, g as F, h as I, i as L, it as R, j as z, k as B, l as V, lt as H, m as U, n as W, nt as G, o as K, p as q, q as J, r as Y, rt as X, s as Z, st as Q, t as $, tt as ee, u as te, v as ne, w as re, x as ie, y as ae, z as oe } from "./chunks/ui-vpt-ySR1.js";
|
|
3
|
+
export { G as DeckSprite, Q as JIMBO_ANIMATIONS, Z as JamlEditor, ie as JimboApp, y as JimboAppFooter, r as JimboAppScroll, S as JimboBackButton, t as JimboBackground, l as JimboBadge, b as JimboBalatroFooter, c as JimboButton, i as JimboCodeBlock, j as JimboColorOption, h as JimboCopyButton, re as JimboCopyRow, A as JimboDeckAndStakeSelectorModal, $ as JimboDualChip, z as JimboFilterBar, o as JimboFlankNav, v as JimboIconButton, U as JimboInfoCard, I as JimboInfoCardAside, F as JimboInfoCardBody, D as JimboInfoCardSub, ne as JimboInfoCardTitle, f as JimboInlineEdit, x as JimboInnerPanel, K as JimboInputModal, te as JimboInset, a as JimboLink, oe as JimboListItem, C as JimboModal, s as JimboPanel, V as JimboPanelSpinner, d as JimboPicker, J as JimboPickerEmpty, u as JimboPickerGrid, T as JimboPickerHint, w as JimboPickerItem, E as JimboPickerPair, _ as JimboPickerSearch, e as JimboPickerSection, M as JimboRow, ae as JimboSectionHeader, g as JimboSeedCopyChip, O as JimboSelect, W as JimboSlider, m as JimboSpinner, X as JimboSprite, P as JimboStack, q as JimboStatGrid, L as JimboStepper, n as JimboTabs, ee as JimboText, N as JimboTextInput, p as JimboToggleList, B as JimboTooltip, Y as JimboValueBadge, k as JimboWordmark, R as StakeSprite, H as withAlpha };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jaml-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Balatro rendering components, sprite metadata, and optional Motely helpers for React apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"author": "pifreak",
|
|
72
72
|
"license": "MIT",
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"motely-wasm": ">=21.
|
|
74
|
+
"motely-wasm": ">=21.1.0",
|
|
75
75
|
"react": "^18.2.0 || ^19.0.0",
|
|
76
76
|
"react-dom": "^18.2.0 || ^19.0.0",
|
|
77
77
|
"react-icons": ">=5.0.0"
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
106
106
|
"eslint-plugin-storybook": "^10.4.2",
|
|
107
107
|
"globals": "^17.6.0",
|
|
108
|
-
"motely-wasm": "^21.
|
|
108
|
+
"motely-wasm": "^21.1.0",
|
|
109
109
|
"playwright": "^1.60.0",
|
|
110
110
|
"react": "^19.2.6",
|
|
111
111
|
"react-dom": "^19.2.6",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Program as e}from"motely-wasm/motely/wasm";import t from"motely-wasm";import{IFileMounter as n}from"motely-wasm/bootsharp/file-system";let r=null;async function i(){if(r)return r;if(t.getStatus()===t.BootStatus.Standby)return r=(async()=>{try{(await import(`@rewaffle/bootsharp-file-system`)).init(n)}catch{}await t.boot()})(),r}const a=globalThis;let o=null,s=[],c=0;function l(){for(let e of s)e();s=[]}function u(){l();let t=e=>{a.postMessage({type:`result`,workerIndex:c,seed:e.seed,score:e.score,tallyColumns:Array.from(e.tallies)})};e.onScoredResult.subscribe(t),s.push(()=>e.onScoredResult.unsubscribe(t));let n=e=>{a.postMessage({type:`progress`,workerIndex:c,searched:Number(e.seedsSearched),matching:Number(e.matchingSeeds),percent:e.percentComplete,seedsPerMs:e.seedsPerMillisecond})};e.onProgress.subscribe(n),s.push(()=>e.onProgress.unsubscribe(n));let r=e=>{a.postMessage({type:`match`,workerIndex:c,seed:e})};e.onSeedMatch.subscribe(r),s.push(()=>e.onSeedMatch.unsubscribe(r))}function d(e,t){return typeof t.deck==`number`&&(e.deck=t.deck),typeof t.stake==`number`&&(e.stake=t.stake),e}function f(t){let n=d(e.fromJaml(t.jaml),t);switch(t.mode){case`aesthetic`:return e.runAestheticSearch(n,t.aesthetic??0);case`seedlist`:return n.seeds=t.seeds??[],e.runSeedListSearch(n);case`random`:{let r=typeof t.count==`number`&&t.count>0?t.count:0;return e.runRandomSearch(n,r)}case`sequential`:{let r=typeof t.startBatchIndex==`string`?BigInt(t.startBatchIndex):void 0,i=typeof t.endBatchIndex==`string`?BigInt(t.endBatchIndex):void 0,a=typeof t.batchCharacterCount==`number`?t.batchCharacterCount:void 0;return e.runSequentialSearch(n,r,i,a)}default:return e.runAestheticSearch(n,0)}}a.onmessage=async e=>{let t=e.data;if(t.type===`stop`){o?.cancel(),l(),a.postMessage({type:`cancelled`,workerIndex:c});return}if(t.type===`start`){c=t.workerIndex;try{await i(),u();try{let e=f(t);o=e,a.postMessage({type:`complete`,workerIndex:c,status:e.isCompleted?`Completed`:`Cancelled`,total:Number(e.totalSeedsSearched),matched:Number(e.matchingSeeds)})}finally{l(),o=null}}catch(e){l(),o=null,a.postMessage({type:`error`,workerIndex:c,message:e instanceof Error?e.message:String(e)})}}},a.postMessage({type:`ready`});
|
|
2
|
-
//# sourceMappingURL=searchPoolWorker-BgC_66wv.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchPoolWorker-BgC_66wv.js","names":[],"sources":["../../src/lib/motely/runtime.ts","../../src/hooks/searchPoolWorker.ts"],"sourcesContent":["import bootsharp from \"motely-wasm\";\nimport { IFileMounter } from \"motely-wasm/bootsharp/file-system\";\n\nexport type MotelyRuntimeStatus = \"idle\" | \"booting\" | \"ready\" | \"error\";\n\n// NOTE(motely-wasm 21): the Jimmolate probe ([Import] `Motely.jimmolateProbe` +\n// `enableJimmolate()`) was removed from the engine, so the pre-boot dispatcher\n// that lived here is gone with it. See git history if the engine regains it.\n\n// Must match the path the host serves motely-wasm's bin/ at.\n// Used by main-thread hooks, workers, and Storybook staticDir alike.\n// The Storybook staticDir in .storybook/main.ts serves it here.\n// Next.js consumers must serve it at this path too (e.g. via a catch-all route).\n// A bare \"/bin\" would 404 in every deployment context.\nexport const MOTELY_BIN_PATH = \"/motely-wasm/bin\";\n\n// File System extension (optional peer `@rewaffle/bootsharp-file-system`).\n//\n// fs.init() binds the IFileMounter [Import], which — like the Jimmolate probe\n// above and EVERY Bootsharp [Import] — must be assigned BEFORE boot()\n// (Bootsharp docs: extensions/file-system). The package is an OPTIONAL peer, so\n// we dynamically import it and swallow its absence: consumers without it simply\n// get no library mount (useJamlLibrary reports status \"unsupported\").\n//\n// This MUST live in the one centralized boot path, not in a component effect.\n// ~8 callers (useSearch, the workers, useAnalyzer, Jamlyzer, …) each trigger\n// boot via ensureMotelyReady(); whichever fires first wins. If fs.init() sat in\n// useJamlLibrary's useEffect it would lose that race and the mounter would never\n// be bound pre-boot — which is exactly why the library mount silently failed.\nlet fileSystemReady = false;\nlet fileSystemError: unknown = null;\n\n/** True once the optional File System extension was bound before boot. */\nexport function isFileSystemReady(): boolean {\n return fileSystemReady;\n}\n\n/** The error from a failed or absent File System init, if any. */\nexport function getFileSystemError(): unknown {\n return fileSystemError;\n}\n\n// Single boot promise: fs.init() (pre-boot) → boot(), run exactly once and\n// awaited by every caller, so the ordering holds no matter who boots first.\nlet bootPromise: Promise<void> | null = null;\n\nexport async function ensureMotelyReady(): Promise<void> {\n if (bootPromise) return bootPromise;\n if (bootsharp.getStatus() !== bootsharp.BootStatus.Standby) return;\n bootPromise = (async () => {\n // Pre-boot: bind the optional File System mounter if it's installed.\n try {\n // @vite-ignore — optional peer; may be absent on disk. Keep it a\n // runtime import() so Vite's dev import-analysis (Storybook, demo)\n // doesn't try to resolve it at transform time and hard-fail. When\n // missing it throws here and is swallowed → status \"unsupported\".\n // (The library build externalizes it via PEER_EXTERNALS regardless.)\n const fs = await import(/* @vite-ignore */ \"@rewaffle/bootsharp-file-system\");\n fs.init(IFileMounter);\n fileSystemReady = true;\n } catch (error) {\n fileSystemError = error;\n }\n // motely-wasm is an EMBEDDED build (the runtime is inlined into the JS as\n // base64 — see dist/generated/resources.g.mjs), so boot() takes no args and\n // needs no served binaries. The old boot(\"/motely-wasm/bin\") was leftover\n // sideloaded config and 404'd in every context.\n await bootsharp.boot();\n })();\n return bootPromise;\n}\n","/// <reference lib=\"webworker\" />\n\n// Pool worker. Each instance boots its own motely-wasm runtime (single-threaded\n// per Bootsharp 0.8 post-#203 — no SAB, no COOP/COEP). The owning `useSearchPool`\n// hook is responsible for partitioning the input space and assigning each worker\n// a disjoint slice via the fields on PoolStartMessage. This worker just runs\n// what it is told.\nimport { Program as Motely } from \"motely-wasm/motely/wasm\";\nimport type { IMotelySearch, MotelyProgress, MotelyScoredSeedResult } from \"motely-wasm/motely\";\nimport type { MotelyDeck, MotelyStake } from \"motely-wasm/motely/enums\";\nimport type { JamlAesthetic, JamlConfig } from \"motely-wasm/motely/filters/jaml\";\nimport { ensureMotelyReady } from \"../lib/motely/runtime.js\";\n\nconst self = globalThis as typeof globalThis & DedicatedWorkerGlobalScope;\n\nexport type PoolSearchMode = \"random\" | \"seedlist\" | \"sequential\" | \"aesthetic\";\n\nexport interface PoolStartMessage {\n type: \"start\";\n workerIndex: number;\n workerCount: number;\n mode: PoolSearchMode;\n jaml: string;\n count?: number;\n seeds?: string[];\n batchCharacterCount?: number;\n startBatchIndex?: string;\n endBatchIndex?: string;\n aesthetic?: number;\n deck?: number;\n stake?: number;\n predicateStr?: string;\n}\n\nexport interface PoolStopMessage {\n type: \"stop\";\n}\n\nexport type PoolInboundMessage = PoolStartMessage | PoolStopMessage;\n\nexport interface PoolReadyMessage {\n type: \"ready\";\n}\n\nexport interface PoolResultMessage {\n type: \"result\";\n workerIndex: number;\n seed: string;\n score: number;\n tallyColumns: number[];\n}\n\nexport interface PoolMatchMessage {\n type: \"match\";\n workerIndex: number;\n seed: string;\n}\n\nexport interface PoolProgressMessage {\n type: \"progress\";\n workerIndex: number;\n searched: number;\n matching: number;\n percent: number;\n seedsPerMs: number;\n}\n\nexport interface PoolCompleteMessage {\n type: \"complete\";\n workerIndex: number;\n status: \"Completed\" | \"Cancelled\";\n total: number;\n matched: number;\n}\n\nexport interface PoolCancelledMessage {\n type: \"cancelled\";\n workerIndex: number;\n}\n\nexport interface PoolErrorMessage {\n type: \"error\";\n workerIndex: number;\n message: string;\n}\n\nexport type PoolOutboundMessage =\n | PoolReadyMessage\n | PoolResultMessage\n | PoolMatchMessage\n | PoolProgressMessage\n | PoolCompleteMessage\n | PoolCancelledMessage\n | PoolErrorMessage;\n\nlet currentSearch: IMotelySearch | null = null;\nlet unsubscribers: Array<() => void> = [];\nlet workerIndex = 0;\n\nfunction detachListeners(): void {\n for (const off of unsubscribers) off();\n unsubscribers = [];\n}\n\nfunction attachListeners(): void {\n detachListeners();\n\n const onResult = (result: MotelyScoredSeedResult) => {\n self.postMessage({\n type: \"result\",\n workerIndex,\n seed: result.seed,\n score: result.score,\n tallyColumns: Array.from(result.tallies),\n } satisfies PoolResultMessage);\n };\n Motely.onScoredResult.subscribe(onResult);\n unsubscribers.push(() => Motely.onScoredResult.unsubscribe(onResult));\n\n const onProgress = (progress: MotelyProgress) => {\n self.postMessage({\n type: \"progress\",\n workerIndex,\n searched: Number(progress.seedsSearched),\n matching: Number(progress.matchingSeeds),\n percent: progress.percentComplete,\n seedsPerMs: progress.seedsPerMillisecond,\n } satisfies PoolProgressMessage);\n };\n Motely.onProgress.subscribe(onProgress);\n unsubscribers.push(() => Motely.onProgress.unsubscribe(onProgress));\n\n const onSeedMatch = (seed: string) => {\n self.postMessage({\n type: \"match\",\n workerIndex,\n seed,\n } satisfies PoolMatchMessage);\n };\n Motely.onSeedMatch.subscribe(onSeedMatch);\n unsubscribers.push(() => Motely.onSeedMatch.unsubscribe(onSeedMatch));\n}\n\n// deck/stake are config fields now; the worker is single-threaded, so the old\n// withThreadCount(1) is dropped (it was a no-op here).\nfunction applyCommonOverrides(config: JamlConfig, message: PoolStartMessage): JamlConfig {\n if (typeof message.deck === \"number\") {\n config.deck = message.deck as MotelyDeck;\n }\n if (typeof message.stake === \"number\") {\n config.stake = message.stake as MotelyStake;\n }\n return config;\n}\n\n// motely-wasm 21: Program.run*Search executes synchronously to completion and\n// returns the finished IMotelySearch — this RUNS the search, not just configures.\nfunction runConfigured(message: PoolStartMessage): IMotelySearch {\n const config = applyCommonOverrides(Motely.fromJaml(message.jaml), message);\n\n switch (message.mode) {\n case \"aesthetic\":\n return Motely.runAestheticSearch(config, (message.aesthetic ?? 0) as JamlAesthetic);\n case \"seedlist\": {\n config.seeds = message.seeds ?? [];\n return Motely.runSeedListSearch(config);\n }\n case \"random\": {\n const count = typeof message.count === \"number\" && message.count > 0 ? message.count : 0;\n return Motely.runRandomSearch(config, count);\n }\n case \"sequential\": {\n const start = typeof message.startBatchIndex === \"string\" ? BigInt(message.startBatchIndex) : undefined;\n const end = typeof message.endBatchIndex === \"string\" ? BigInt(message.endBatchIndex) : undefined;\n const batchChars = typeof message.batchCharacterCount === \"number\" ? message.batchCharacterCount : undefined;\n return Motely.runSequentialSearch(config, start, end, batchChars);\n }\n default:\n return Motely.runAestheticSearch(config, 0 as JamlAesthetic);\n }\n}\n\nself.onmessage = async (event: MessageEvent) => {\n const data = event.data as PoolInboundMessage;\n\n if (data.type === \"stop\") {\n currentSearch?.cancel();\n detachListeners();\n self.postMessage({ type: \"cancelled\", workerIndex } satisfies PoolCancelledMessage);\n return;\n }\n\n if (data.type !== \"start\") return;\n\n workerIndex = data.workerIndex;\n\n try {\n await ensureMotelyReady();\n\n // NOTE(motely-wasm 21): the jimmolate predicate API is gone from the\n // engine; `predicateStr` is ignored. See git history to revive it.\n attachListeners();\n\n try {\n const search = runConfigured(data);\n currentSearch = search;\n self.postMessage({\n type: \"complete\",\n workerIndex,\n status: search.isCompleted ? \"Completed\" : \"Cancelled\",\n total: Number(search.totalSeedsSearched),\n matched: Number(search.matchingSeeds),\n } satisfies PoolCompleteMessage);\n } finally {\n detachListeners();\n currentSearch = null;\n }\n } catch (error) {\n detachListeners();\n currentSearch = null;\n self.postMessage({\n type: \"error\",\n workerIndex,\n message: error instanceof Error ? error.message : String(error),\n } satisfies PoolErrorMessage);\n }\n};\n\nself.postMessage({ type: \"ready\" } satisfies PoolReadyMessage);\n"],"mappings":"8IA6BA,IAeI,EAAoC,KAExC,eAAsB,GAAm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