From 9c31fe35ca121127f7e9093f1bb56f4f6f247429 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 15:23:24 +0000 Subject: [PATCH 1/6] Migrate the search worker to motely-wasm 31 31 drops the static Search class. Filters load through JamlConfigLoader.check/fromJaml, JamlSearchBuilder.createSettings builds the search, progress and scored results come through callbacks, and the started search is awaited and disposed. Thrown NativeAOT exceptions are replaced by Errors.last(), so a bad filter shows the loader's reason. CancellationToken is the package's own now. Scored results carry `tallies` instead of `tally`. Blocked on jaml-ui: 4.6 imports `Analyze`, which 31 removed, so the build fails until jaml-ui publishes against 31. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KJq1K4w3RNNmNtQ214gAo1 --- package-lock.json | 18 ++- package.json | 2 +- .../blueprint/jamlView/JamlView.tsx | 14 +-- .../blueprint/jamlView/searchWorker.ts | 112 ++++++------------ 4 files changed, 52 insertions(+), 94 deletions(-) diff --git a/package-lock.json b/package-lock.json index e973426..2df4665 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "jaml-ui": "^4.6.0", "js-convert-case": "^4.2.0", "js-yaml": "^4.1.1", - "motely-wasm": "^26.0.2", + "motely-wasm": "^31.2.0", "motion": "^12.29.2", "react": "^18.0.0", "react-dom": "^18.0.0", @@ -5587,10 +5587,18 @@ } }, "node_modules/motely-wasm": { - "version": "26.0.2", - "resolved": "https://registry.npmjs.org/motely-wasm/-/motely-wasm-26.0.2.tgz", - "integrity": "sha512-74pdgvHhfcmhJhH4SCr1NG6oq5tYH2IYiQxmkuLw6hDgfYUSS1reuPuu9uAwmxkj/BfdPOZ63+yIQKh3cCh3Rg==", - "license": "MIT" + "version": "31.2.0", + "resolved": "https://registry.npmjs.org/motely-wasm/-/motely-wasm-31.2.0.tgz", + "integrity": "sha512-IIWLwawCKXXH4Iq+9LOJMOTtS1XDRt7n8UZG9xaGqF1q1cLQxS/pFhK7Fn3IUEf1vxxhj/rjVurYYRiuhyk8tw==", + "license": "MIT", + "peerDependencies": { + "@rewaffle/bootsharp-file-system": "*" + }, + "peerDependenciesMeta": { + "@rewaffle/bootsharp-file-system": { + "optional": true + } + } }, "node_modules/motion": { "version": "12.43.0", diff --git a/package.json b/package.json index 084e2e7..a35fe56 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "jaml-ui": "^4.6.0", "js-convert-case": "^4.2.0", "js-yaml": "^4.1.1", - "motely-wasm": "^26.0.2", + "motely-wasm": "^31.2.0", "motion": "^12.29.2", "react": "^18.0.0", "react-dom": "^18.0.0", diff --git a/src/components/blueprint/jamlView/JamlView.tsx b/src/components/blueprint/jamlView/JamlView.tsx index 7cd838d..e1a2771 100644 --- a/src/components/blueprint/jamlView/JamlView.tsx +++ b/src/components/blueprint/jamlView/JamlView.tsx @@ -9,7 +9,7 @@ import { jamlStakeToBlueprint, } from "../../../modules/jamlDocumentParse.ts"; import type { JamlIdeSearchResult } from "jaml-ui"; -import type { MotelySeedScore } from "motely-wasm"; +import type { MotelyScoredSeedResult } from "motely-wasm"; import type { ParsedJamlDocumentMessage, SearchConfig, @@ -85,7 +85,7 @@ export default function JamlView() { const [status, setStatus] = useState("idle"); const [error, setError] = useState(null); const [documentStatus, setDocumentStatus] = useState(null); - const [results, setResults] = useState>([]); + const [results, setResults] = useState>([]); const [stats, setStats] = useState(EMPTY_STATS); const [randomCount, setRandomCount] = useState(1_000_000); const [documentSeeds, setDocumentSeeds] = useState>([]); @@ -97,7 +97,7 @@ export default function JamlView() { const lastParsedFingerprintRef = useRef(""); // Matches accumulate here and flush to state on progress ticks and on done, // so a run with many matches doesn't re-sort on every event. - const collectedRef = useRef>([]); + const collectedRef = useRef>([]); const applyParsedDocumentRef = useRef<(doc: ParsedJamlDocumentMessage) => void>(() => {}); const isSearching = status === "running" || status === "booting"; @@ -121,12 +121,6 @@ export default function JamlView() { scope, deck: deckValue, stake: stakeValue, - batchCharacterCount: null, - providerBatchSeedCount: null, - startBatchIndex: null, - endBatchIndex: null, - autoScoreCutoff: false, - stopAfter: 0, }; setStatus("booting"); workerRef.current?.postMessage({ type: "start", config } satisfies WorkerRequest); @@ -274,7 +268,7 @@ export default function JamlView() { results.map((r) => ({ seed: r.seed, score: r.score, - tallyColumns: Array.from(r.tally), + tallyColumns: Array.from(r.tallies), tallyLabels, })), [results, tallyLabels], diff --git a/src/components/blueprint/jamlView/searchWorker.ts b/src/components/blueprint/jamlView/searchWorker.ts index 7c5daf9..ea4a1a9 100644 --- a/src/components/blueprint/jamlView/searchWorker.ts +++ b/src/components/blueprint/jamlView/searchWorker.ts @@ -1,42 +1,20 @@ -// The engine runs here, off the main thread. motely-wasm 26 is single-threaded -// and blocks whatever realm it runs in; on the UI thread that froze the tab for -// seconds at a time. In a worker the freeze is invisible — the UI stays live and +// The engine runs here, off the main thread. motely-wasm is single-threaded and +// blocks whatever realm it runs in; in a worker the UI stays live and // results/progress stream back over postMessage. -// -// This drives motely-wasm's Search directly (per Blueprint's "no wrapper modules" -// rule). The worker boundary is a thread, not an abstraction: it still calls -// Search.settings(jaml).with…().start(token) with no layer in between. import "../../../modules/uint8Base64Polyfill.ts"; import motely, { - JamlAesthetic, + CancellationToken, + Errors, + JamlConfigLoader, + JamlSearchBuilder, MotelyDeck, MotelyStake, - Search, } from "motely-wasm"; import { parseJamlDocument } from "../../../modules/jamlDocumentParse.ts"; -import type { MotelyProgress, MotelySeedScore } from "motely-wasm"; - -// CancellationToken collides at the motely-wasm package root (re-exported from -// two submodules), so the token contract start() needs is reimplemented here. -class SearchCancellationToken { - isCancellationRequested = false; - private handlers = new Set<() => void>(); - onCancellationRequested = { - subscribe: (h: () => void) => this.handlers.add(h), - unsubscribe: (h: () => void) => this.handlers.delete(h), - }; - cancel() { - if (this.isCancellationRequested) return; - this.isCancellationRequested = true; - for (const h of this.handlers) h(); - } -} +import type { IMotelySearch, MotelyProgress, MotelyScoredSeedResult } from "motely-wasm"; export type SearchScope = | { mode: "random"; count: number } - | { mode: "sequential" } - | { mode: "keyword"; keywords: Array; quickPad: boolean } - | { mode: "aesthetic"; aesthetic: JamlAesthetic; quickPad: boolean } | { mode: "seedList"; seeds: Array }; export interface SearchConfig { @@ -44,12 +22,6 @@ export interface SearchConfig { scope: SearchScope; deck: MotelyDeck | null; stake: MotelyStake | null; - batchCharacterCount: number | null; - providerBatchSeedCount: number | null; - startBatchIndex: number | null; - endBatchIndex: number | null; - autoScoreCutoff: boolean; - stopAfter: number; } export type ParsedJamlDocumentMessage = { @@ -68,7 +40,7 @@ export type WorkerRequest = export type WorkerResponse = | { type: "booting" } | { type: "running" } - | { type: "scored"; score: MotelySeedScore } + | { type: "scored"; score: MotelyScoredSeedResult } | { type: "progress"; progress: MotelyProgress } | { type: "done"; cancelled: boolean } | { type: "error"; message: string } @@ -81,64 +53,48 @@ function ensureBooted() { return bootPromise; } -let activeToken: SearchCancellationToken | null = null; +let activeToken: CancellationToken | null = null; const post = (msg: WorkerResponse) => (self as unknown as Worker).postMessage(msg); +// NativeAOT hands JS an opaque "C# exception from NativeAOT"; Errors.last() has the real message. +function errorMessage(e: unknown): string { + const message = e instanceof Error ? e.message : String(e); + return message.includes("NativeAOT") ? (Errors.last() ?? message) : message; +} + async function run(config: SearchConfig) { - const token = new SearchCancellationToken(); + const token = new CancellationToken(); activeToken = token; - - const onScored = (score: MotelySeedScore) => post({ type: "scored", score }); - const onProgress = (progress: MotelyProgress) => post({ type: "progress", progress }); - Search.onScored.subscribe(onScored); - Search.onProgress.subscribe(onProgress); + let search: IMotelySearch | null = null; try { post({ type: "booting" }); await ensureBooted(); + + const problem = JamlConfigLoader.check(config.jaml); + if (problem) throw new Error(problem); post({ type: "running" }); - let s = Search.settings(config.jaml).withProgressReportIntervalMs(250n); - - switch (config.scope.mode) { - case "random": - s = s.withRandomSearch(config.scope.count); - break; - case "sequential": - s = s.withSequentialSearch(); - break; - case "keyword": - s = s.withKeywordSearch(config.scope.keywords, config.scope.quickPad); - break; - case "aesthetic": - s = s.withAestheticSearch(config.scope.aesthetic, config.scope.quickPad); - break; - case "seedList": - s = s.withSeedList(config.scope.seeds); - break; - } + let s = JamlSearchBuilder.createSettings(JamlConfigLoader.fromJaml(config.jaml)) + .withThreadCount(1) + .withProgressReportIntervalMs(250n) + .withProgressCallback((progress) => post({ type: "progress", progress })) + .withScoredResultCallback((score) => post({ type: "scored", score })); + s = config.scope.mode === "random" + ? s.withRandomSearch(config.scope.count) + : s.withSeedList(config.scope.seeds); if (config.deck !== null) s = s.withDeck(config.deck); if (config.stake !== null) s = s.withStake(config.stake); - if (config.batchCharacterCount !== null) - s = s.withBatchCharacterCount(config.batchCharacterCount); - if (config.providerBatchSeedCount !== null) - s = s.withProviderBatchSeedCount(config.providerBatchSeedCount); - if (config.startBatchIndex !== null) - s = s.withStartBatchIndex(BigInt(config.startBatchIndex)); - if (config.endBatchIndex !== null) - s = s.withEndBatchIndex(BigInt(config.endBatchIndex)); - if (config.autoScoreCutoff) s = s.withAutoScoreCutoff(true); - if (config.stopAfter > 0) s = s.stopAfter(BigInt(config.stopAfter)); - - await s.start(token as never); + + search = s.start(token); + await search.waitForCompletionAsync(); post({ type: "done", cancelled: token.isCancellationRequested }); } catch (e) { - post({ type: "error", message: e instanceof Error ? e.message : String(e) }); + post({ type: "error", message: errorMessage(e) }); } finally { - Search.onScored.unsubscribe(onScored); - Search.onProgress.unsubscribe(onProgress); + search?.dispose(); if (activeToken === token) activeToken = null; } } @@ -151,7 +107,7 @@ self.onmessage = (ev: MessageEvent) => { try { post({ type: "documentParsed", document: parseJamlDocument(msg.text) }); } catch (e) { - post({ type: "error", message: e instanceof Error ? e.message : String(e) }); + post({ type: "error", message: errorMessage(e) }); } } }; From fd8ed8304b7864402aaf8108ca1d71cee01e76ad Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 19:53:53 +0000 Subject: [PATCH 2/6] WIP: jaml-ui 10 + motely 31, drop js-yaml and jaml-lang override Does not build yet: jaml-ui 10 has no JAML IDE. Waits for the jaml-ui release that adds it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KJq1K4w3RNNmNtQ214gAo1 --- package-lock.json | 110 +++++++++++++----- package.json | 7 +- .../blueprint/jamlView/JamlView.tsx | 14 ++- 3 files changed, 95 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2df4665..16c0985 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,9 +19,8 @@ "@tanstack/react-query": "^5.85.9", "embla-carousel-react": "^8.6.0", "immer": "^10.1.3", - "jaml-ui": "^4.6.0", + "jaml-ui": "^10.0.0", "js-convert-case": "^4.2.0", - "js-yaml": "^4.1.1", "motely-wasm": "^31.2.0", "motion": "^12.29.2", "react": "^18.0.0", @@ -33,7 +32,6 @@ "devDependencies": { "@eslint/js": "^9.39.1", "@tanstack/eslint-config": "^0.3.4", - "@types/js-yaml": "^4.0.9", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^5.0.2", @@ -364,6 +362,66 @@ "node": ">=6.9.0" } }, + "node_modules/@base-ui/react": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@base-ui/react/-/react-1.9.0.tgz", + "integrity": "sha512-S8CSYosASBKtpL8SWUfS78rFElfLijiCgA7oHOK22jCJ95FULsYyKwBNFOgudt0RA+/7yNc7F81bOvQnRgbBiQ==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.7 || ^8.0.0", + "@base-ui/utils": "0.5.0", + "@floating-ui/react-dom": "^2.1.9", + "@floating-ui/utils": "^0.2.12", + "use-sync-external-store": "^1.7.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@date-fns/tz": "^1.2.0", + "@types/react": "^17 || ^18 || ^19", + "date-fns": "^4.0.0", + "react": "^17 || ^18 || ^19", + "react-dom": "^17 || ^18 || ^19" + }, + "peerDependenciesMeta": { + "@date-fns/tz": { + "optional": true + }, + "@types/react": { + "optional": true + }, + "date-fns": { + "optional": true + } + } + }, + "node_modules/@base-ui/utils": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@base-ui/utils/-/utils-0.5.0.tgz", + "integrity": "sha512-dYGGcEttjkYiMoa5nHm8vLaJ2UcuTWxo3BFAwOYXeRg/q7UVVvA6cacEIXEs3FgBfK1CGtW1ptElqs7wsx+t9A==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.7 || ^8.0.0", + "@floating-ui/utils": "^0.2.12", + "reselect": "^5.3.0", + "use-sync-external-store": "^1.7.0" + }, + "peerDependencies": { + "@types/react": "^17 || ^18 || ^19", + "react": "^17 || ^18 || ^19", + "react-dom": "^17 || ^18 || ^19" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@bufbuild/protobuf": { "version": "2.15.0", "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.15.0.tgz", @@ -2198,13 +2256,6 @@ "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", "license": "MIT" }, - "node_modules/@types/js-yaml": { - "version": "4.0.9", - "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", - "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -2965,6 +3016,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, "license": "Python-2.0" }, "node_modules/array-buffer-byte-length": { @@ -5338,33 +5390,23 @@ } }, "node_modules/jaml-ui": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/jaml-ui/-/jaml-ui-4.6.0.tgz", - "integrity": "sha512-RzqTz/tqK5xj+SN+5HPA2Ej0xRYfg0+6GQTQuJjxQDy9APHnfIf+wS8OrM/0kXpiCZ+W1u9DcK97f3pKtK4yOQ==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/jaml-ui/-/jaml-ui-10.0.0.tgz", + "integrity": "sha512-Q7WXYAHyQDGxa9kh5HVdAKVSgkR8VdBg0kfGNlbo6CchUeMaHNngjLebi58h7wwmn1pW9X1wQzBPRUjiEzAkRw==", "license": "MIT", "dependencies": { + "@base-ui/react": "^1.9.0", "@json-render/core": "^0.20.0", "@json-render/react": "^0.20.0", - "jaml-lang": "^3.14.2", "react-icons": "^5.7.0", - "zod": "^4.5.4" - }, - "engines": { - "node": ">=18" + "zod": "^4.6.5" }, "peerDependencies": { - "motely-wasm": "^25.1.0", + "motely-wasm": "^31.1.1", "react": "^18.2.0 || ^19.0.0", "react-dom": "^18.2.0 || ^19.0.0" } }, - "node_modules/jaml-ui/node_modules/jaml-lang": { - "name": "empty-npm-package", - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/empty-npm-package/-/empty-npm-package-1.0.0.tgz", - "integrity": "sha512-q4Mq/+XO7UNDdMiPpR/LIBIW1Zl4V0Z6UT9aKGqIAnBCtCb3lvZJM1KbDbdzdC8fKflwflModfjR29Nt0EpcwA==", - "license": "ISC" - }, "node_modules/jiti": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", @@ -5391,6 +5433,7 @@ "version": "4.3.2", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "dev": true, "funding": [ { "type": "github", @@ -6420,6 +6463,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/reselect": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.3.0.tgz", + "integrity": "sha512-XGoLeRAVzUTcJ1qkxPQhDJyIZ5d6zzZD9nT7AEZOaaU9UbWclhycElmhO+VD5bFeLuzhPBaOV2oXC8uG35ZSpg==", + "license": "MIT" + }, "node_modules/resolve": { "version": "2.0.0-next.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.7.tgz", @@ -7803,6 +7852,15 @@ } } }, + "node_modules/use-sync-external-store": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.7.0.tgz", + "integrity": "sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index a35fe56..df1a783 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,8 @@ "@tanstack/react-query": "^5.85.9", "embla-carousel-react": "^8.6.0", "immer": "^10.1.3", - "jaml-ui": "^4.6.0", + "jaml-ui": "^10.0.0", "js-convert-case": "^4.2.0", - "js-yaml": "^4.1.1", "motely-wasm": "^31.2.0", "motion": "^12.29.2", "react": "^18.0.0", @@ -32,13 +31,9 @@ "vitest": "^5.0.1", "zustand": "^5.0.8" }, - "overrides": { - "jaml-lang": "npm:empty-npm-package@1.0.0" - }, "devDependencies": { "@eslint/js": "^9.39.1", "@tanstack/eslint-config": "^0.3.4", - "@types/js-yaml": "^4.0.9", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "@vitejs/plugin-react": "^5.0.2", diff --git a/src/components/blueprint/jamlView/JamlView.tsx b/src/components/blueprint/jamlView/JamlView.tsx index e1a2771..7cd838d 100644 --- a/src/components/blueprint/jamlView/JamlView.tsx +++ b/src/components/blueprint/jamlView/JamlView.tsx @@ -9,7 +9,7 @@ import { jamlStakeToBlueprint, } from "../../../modules/jamlDocumentParse.ts"; import type { JamlIdeSearchResult } from "jaml-ui"; -import type { MotelyScoredSeedResult } from "motely-wasm"; +import type { MotelySeedScore } from "motely-wasm"; import type { ParsedJamlDocumentMessage, SearchConfig, @@ -85,7 +85,7 @@ export default function JamlView() { const [status, setStatus] = useState("idle"); const [error, setError] = useState(null); const [documentStatus, setDocumentStatus] = useState(null); - const [results, setResults] = useState>([]); + const [results, setResults] = useState>([]); const [stats, setStats] = useState(EMPTY_STATS); const [randomCount, setRandomCount] = useState(1_000_000); const [documentSeeds, setDocumentSeeds] = useState>([]); @@ -97,7 +97,7 @@ export default function JamlView() { const lastParsedFingerprintRef = useRef(""); // Matches accumulate here and flush to state on progress ticks and on done, // so a run with many matches doesn't re-sort on every event. - const collectedRef = useRef>([]); + const collectedRef = useRef>([]); const applyParsedDocumentRef = useRef<(doc: ParsedJamlDocumentMessage) => void>(() => {}); const isSearching = status === "running" || status === "booting"; @@ -121,6 +121,12 @@ export default function JamlView() { scope, deck: deckValue, stake: stakeValue, + batchCharacterCount: null, + providerBatchSeedCount: null, + startBatchIndex: null, + endBatchIndex: null, + autoScoreCutoff: false, + stopAfter: 0, }; setStatus("booting"); workerRef.current?.postMessage({ type: "start", config } satisfies WorkerRequest); @@ -268,7 +274,7 @@ export default function JamlView() { results.map((r) => ({ seed: r.seed, score: r.score, - tallyColumns: Array.from(r.tallies), + tallyColumns: Array.from(r.tally), tallyLabels, })), [results, tallyLabels], From 6e35a2c9b85d4d16a2a323b8976dc8c365ebe997 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 03:17:02 +0000 Subject: [PATCH 3/6] Drop the JS glue: motely-wasm owns parsing, JamlView mounts jaml-ui's JamlIde The worker loads filters with JamlConfigLoader and searches the filter's own seeds: list when it has one, else a random sample. Deleted the js-yaml document parser, its spec, the base64 polyfill and the bundle branch in parseSeedList. Needs jaml-ui 10.1.0 (JamlIde export) on npm. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KJq1K4w3RNNmNtQ214gAo1 --- ___tests___/jamlDocument.spec.ts | 76 ------ src/components/SeedQueue.tsx | 2 +- .../blueprint/jamlView/JamlView.tsx | 227 +++++------------- .../blueprint/jamlView/searchWorker.ts | 52 ++-- src/main.jsx | 1 - src/modules/jamlDocumentParse.ts | 147 ------------ src/modules/state/store.ts | 4 - src/modules/uint8Base64Polyfill.ts | 42 ---- 8 files changed, 80 insertions(+), 471 deletions(-) delete mode 100644 ___tests___/jamlDocument.spec.ts delete mode 100644 src/modules/jamlDocumentParse.ts delete mode 100644 src/modules/uint8Base64Polyfill.ts diff --git a/___tests___/jamlDocument.spec.ts b/___tests___/jamlDocument.spec.ts deleted file mode 100644 index ae56d96..0000000 --- a/___tests___/jamlDocument.spec.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { load } from "js-yaml"; -import { describe, expect, it } from "vitest"; -import { documentLooksLikeSeedBundle, parseJamlDocument } from "../src/modules/jamlDocumentParse"; -import { parseSeedList } from "../src/modules/state/store"; - -describe("parseJamlDocument", () => { - it("splits filter clauses from a seeds list and reads deck/stake", () => { - const doc = parseJamlDocument(`name: demo -deck: Ghost -stake: White -must: - - tag: NegativeTag - antes: [1] -seeds: - - ALEEB - - PIROCKS -`); - expect(doc.name).toBe("demo"); - expect(doc.deck).toBe("Ghost"); - expect(doc.stake).toBe("White"); - expect(doc.seeds).toEqual(["ALEEB", "PIROCKS"]); - expect(doc.filterJaml).toContain("must:"); - expect(doc.filterJaml).not.toMatch(/^seeds:/m); - }); - - it("feeds parseSeedList for whole JAML uploads", () => { - const text = `deck: Red -stake: White -must: - - joker: Any - antes: [1] -seeds: - - WEEJOKER - - ALEEB -`; - expect(parseSeedList(text)).toEqual(["WEEJOKER", "ALEEB"]); - }); -}); - -describe("simpleCola fixture", () => { - it("loads 46,210 seeds without keeping them in the filter body", () => { - const alphabet = "123456789ABCDEFGHIJKLMNPQRSTUVWXYZ"; - const seeds = Array.from({ length: 46210 }, (_, i) => { - let n = i, out = ""; - for (let k = 0; k < 8; k++) { out += alphabet[n % alphabet.length]; n = Math.floor(n / alphabet.length); } - return out; - }); - const text = `name: simpleCola\ndeck: Ghost\nstake: White\nmust:\n - joker: DietCola\n antes: [1, 2]\nseeds:\n${seeds.map((x) => ` - ${x}`).join("\n")}\n`; - const started = performance.now(); - const doc = parseJamlDocument(text); - const elapsed = performance.now() - started; - expect(doc.seeds).toHaveLength(46210); - expect(doc.deck).toBe("Ghost"); - expect(doc.stake).toBe("White"); - expect(doc.filterJaml).toContain("simpleCola"); - expect(doc.filterJaml).not.toMatch(/^seeds:/m); - expect(elapsed).toBeLessThan(5000); - }); -}); - -describe("JSON filter", () => { - it("reads seeds, deck and stake off a JSON document and keeps the rest as the filter", () => { - const text = JSON.stringify({ name: "cola", deck: "Ghost", stake: "White", must: [{ joker: "DietCola", antes: [1] }], seeds: ["WEEJOKER", "aleeb"] }); - const doc = parseJamlDocument(text); - expect(doc.seeds).toEqual(["WEEJOKER", "ALEEB"]); - expect(doc.deck).toBe("Ghost"); - expect(doc.stake).toBe("White"); - expect(doc.name).toBe("cola"); - expect(load(doc.filterJaml)).toEqual({ name: "cola", deck: "Ghost", stake: "White", must: [{ joker: "DietCola", antes: [1] }] }); - }); - - it("is detected as a seed bundle", () => { - expect(documentLooksLikeSeedBundle(JSON.stringify({ must: [], seeds: ["ALEEB"] }))).toBe(true); - expect(documentLooksLikeSeedBundle(JSON.stringify({ must: [{ joker: "Blueprint" }] }))).toBe(false); - }); -}); diff --git a/src/components/SeedQueue.tsx b/src/components/SeedQueue.tsx index 7b26288..27b4a00 100644 --- a/src/components/SeedQueue.tsx +++ b/src/components/SeedQueue.tsx @@ -98,7 +98,7 @@ export function SeedQueuePanel() {