jaml-ui 0.22.4 → 0.22.5
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/hooks/searchWorkerCode.d.ts +1 -1
- package/dist/hooks/searchWorkerCode.js +13 -16
- package/dist/hooks/useSearch.js +1 -86
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SEARCH_WORKER_CODE = "\nlet MotelyWasm = null;\nlet MotelyWasmEvents = null;\nlet
|
|
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,7 +1,6 @@
|
|
|
1
1
|
export const SEARCH_WORKER_CODE = `
|
|
2
2
|
let MotelyWasm = null;
|
|
3
3
|
let MotelyWasmEvents = null;
|
|
4
|
-
let Filters = null;
|
|
5
4
|
let activeSearch = null;
|
|
6
5
|
|
|
7
6
|
self.addEventListener('message', async function(e) {
|
|
@@ -11,9 +10,9 @@ self.addEventListener('message', async function(e) {
|
|
|
11
10
|
try {
|
|
12
11
|
const mod = await import(msg.url);
|
|
13
12
|
await mod.default.boot();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const motely = mod.Motely;
|
|
14
|
+
MotelyWasm = motely.MotelyWasm;
|
|
15
|
+
MotelyWasmEvents = motely.MotelyWasmEvents;
|
|
17
16
|
self.postMessage({ type: 'ready' });
|
|
18
17
|
} catch (err) {
|
|
19
18
|
self.postMessage({ type: 'error', message: String(err) });
|
|
@@ -26,28 +25,26 @@ self.addEventListener('message', async function(e) {
|
|
|
26
25
|
const validation = MotelyWasm.validateJaml(msg.jaml);
|
|
27
26
|
if (validation !== 'valid') { self.postMessage({ type: 'error', message: validation }); return; }
|
|
28
27
|
|
|
29
|
-
let rId, pId, cId;
|
|
30
28
|
function cleanup() {
|
|
31
|
-
MotelyWasmEvents.
|
|
32
|
-
MotelyWasmEvents.
|
|
33
|
-
MotelyWasmEvents.
|
|
29
|
+
MotelyWasmEvents.notifyResult = () => {};
|
|
30
|
+
MotelyWasmEvents.notifyProgress = () => {};
|
|
31
|
+
MotelyWasmEvents.notifyComplete = () => {};
|
|
34
32
|
activeSearch = null;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
MotelyWasmEvents.notifyResult = function(seed, score, tallyColumns) {
|
|
38
36
|
self.postMessage({ type: 'result', seed, score, tallyColumns: Array.from(tallyColumns) });
|
|
39
|
-
}
|
|
40
|
-
|
|
37
|
+
};
|
|
38
|
+
MotelyWasmEvents.notifyProgress = function(searched, matching) {
|
|
41
39
|
self.postMessage({ type: 'progress', searched: searched.toString(), matching: matching.toString() });
|
|
42
|
-
}
|
|
43
|
-
|
|
40
|
+
};
|
|
41
|
+
MotelyWasmEvents.notifyComplete = function(status, searched, matched) {
|
|
44
42
|
cleanup();
|
|
45
43
|
self.postMessage({ type: 'complete', status, searched: searched.toString(), matched: matched.toString() });
|
|
46
|
-
}
|
|
44
|
+
};
|
|
47
45
|
|
|
48
46
|
try {
|
|
49
47
|
const mode = msg.mode || 'random';
|
|
50
|
-
|
|
51
48
|
if (mode === 'random') {
|
|
52
49
|
activeSearch = MotelyWasm.startRandomSearch(msg.jaml, msg.count);
|
|
53
50
|
} else if (mode === 'aesthetic') {
|
|
@@ -79,7 +76,7 @@ self.addEventListener('message', async function(e) {
|
|
|
79
76
|
if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }
|
|
80
77
|
try {
|
|
81
78
|
const labels = MotelyWasm.getTallyLabels(msg.jaml);
|
|
82
|
-
self.postMessage({ type: 'tally_labels', labels });
|
|
79
|
+
self.postMessage({ type: 'tally_labels', labels: Array.from(labels) });
|
|
83
80
|
} catch (err) {
|
|
84
81
|
self.postMessage({ type: 'error', message: String(err) });
|
|
85
82
|
}
|
package/dist/hooks/useSearch.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useState, useCallback, useRef, useEffect } from "react";
|
|
3
|
+
import { SEARCH_WORKER_CODE } from "./searchWorkerCode.js";
|
|
3
4
|
const INITIAL_STATE = {
|
|
4
5
|
results: [],
|
|
5
6
|
totalSearched: 0n,
|
|
@@ -9,92 +10,6 @@ const INITIAL_STATE = {
|
|
|
9
10
|
seedsPerSecond: 0,
|
|
10
11
|
tallyLabels: [],
|
|
11
12
|
};
|
|
12
|
-
const SEARCH_WORKER_CODE = `
|
|
13
|
-
let MotelyWasm = null;
|
|
14
|
-
let MotelyWasmEvents = null;
|
|
15
|
-
let activeSearch = null;
|
|
16
|
-
|
|
17
|
-
self.addEventListener('message', async function(e) {
|
|
18
|
-
const msg = e.data;
|
|
19
|
-
|
|
20
|
-
if (msg.type === 'init') {
|
|
21
|
-
try {
|
|
22
|
-
const mod = await import(msg.url);
|
|
23
|
-
await mod.default.boot();
|
|
24
|
-
const motely = mod.Motely;
|
|
25
|
-
MotelyWasm = motely.MotelyWasm;
|
|
26
|
-
MotelyWasmEvents = motely.MotelyWasmEvents;
|
|
27
|
-
self.postMessage({ type: 'ready' });
|
|
28
|
-
} catch (err) {
|
|
29
|
-
self.postMessage({ type: 'error', message: String(err) });
|
|
30
|
-
}
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (msg.type === 'start') {
|
|
35
|
-
if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }
|
|
36
|
-
const validation = MotelyWasm.validateJaml(msg.jaml);
|
|
37
|
-
if (validation !== 'valid') { self.postMessage({ type: 'error', message: validation }); return; }
|
|
38
|
-
|
|
39
|
-
function cleanup() {
|
|
40
|
-
MotelyWasmEvents.notifyResult = () => {};
|
|
41
|
-
MotelyWasmEvents.notifyProgress = () => {};
|
|
42
|
-
MotelyWasmEvents.notifyComplete = () => {};
|
|
43
|
-
activeSearch = null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
MotelyWasmEvents.notifyResult = function(seed, score, tallyColumns) {
|
|
47
|
-
self.postMessage({ type: 'result', seed, score, tallyColumns: Array.from(tallyColumns) });
|
|
48
|
-
};
|
|
49
|
-
MotelyWasmEvents.notifyProgress = function(searched, matching) {
|
|
50
|
-
self.postMessage({ type: 'progress', searched: searched.toString(), matching: matching.toString() });
|
|
51
|
-
};
|
|
52
|
-
MotelyWasmEvents.notifyComplete = function(status, searched, matched) {
|
|
53
|
-
cleanup();
|
|
54
|
-
self.postMessage({ type: 'complete', status, searched: searched.toString(), matched: matched.toString() });
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
const mode = msg.mode || 'random';
|
|
59
|
-
|
|
60
|
-
if (mode === 'random') {
|
|
61
|
-
activeSearch = MotelyWasm.startRandomSearch(msg.jaml, msg.count);
|
|
62
|
-
} else if (mode === 'aesthetic') {
|
|
63
|
-
activeSearch = MotelyWasm.startAestheticSearch(msg.jaml, msg.aesthetic);
|
|
64
|
-
} else if (mode === 'seedList') {
|
|
65
|
-
activeSearch = MotelyWasm.startSeedListSearch(msg.jaml, msg.seeds);
|
|
66
|
-
} else if (mode === 'keyword') {
|
|
67
|
-
activeSearch = MotelyWasm.startKeywordSearch(msg.jaml, msg.keywords, msg.padding || '');
|
|
68
|
-
} else if (mode === 'sequential') {
|
|
69
|
-
activeSearch = MotelyWasm.startSequentialSearch(msg.jaml, msg.batchCharCount, BigInt(msg.startBatch), BigInt(msg.endBatch));
|
|
70
|
-
} else {
|
|
71
|
-
self.postMessage({ type: 'error', message: 'Unknown search mode: ' + mode });
|
|
72
|
-
cleanup();
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
} catch (err) {
|
|
76
|
-
cleanup();
|
|
77
|
-
self.postMessage({ type: 'error', message: String(err) });
|
|
78
|
-
}
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (msg.type === 'stop') {
|
|
83
|
-
if (activeSearch) { activeSearch.cancel(); activeSearch = null; }
|
|
84
|
-
self.postMessage({ type: 'cancelled' });
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (msg.type === 'get_tally_labels') {
|
|
88
|
-
if (!MotelyWasm) { self.postMessage({ type: 'error', message: 'Not initialized' }); return; }
|
|
89
|
-
try {
|
|
90
|
-
const labels = MotelyWasm.getTallyLabels(msg.jaml);
|
|
91
|
-
self.postMessage({ type: 'tally_labels', labels: Array.from(labels) });
|
|
92
|
-
} catch (err) {
|
|
93
|
-
self.postMessage({ type: 'error', message: String(err) });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
`;
|
|
98
13
|
function createWorker() {
|
|
99
14
|
const blob = new Blob([SEARCH_WORKER_CODE], { type: "application/javascript" });
|
|
100
15
|
return new Worker(URL.createObjectURL(blob), { type: "module" });
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { extractVisualJamlItems, type JamlPreviewGroups, type JamlPreviewItem, t
|
|
|
22
22
|
export { useMotelyStream, type StreamItem, type StreamState } from "./hooks/useShopStream.js";
|
|
23
23
|
export { useSearch, type SearchResult, type SearchStatus, type UseSearchState, } from "./hooks/useSearch.js";
|
|
24
24
|
export { useAnalyzer, type AnalyzerStatus, type AnalyzerLive, type MotelyJsRunState, } from "./hooks/useAnalyzer.js";
|
|
25
|
+
export { SEARCH_WORKER_CODE } from "./hooks/searchWorkerCode.js";
|
|
25
26
|
export { setMotelyEnums as setMotelyDisplayEnums } from "./motelyDisplay.js";
|
|
26
27
|
export { setMotelyEnums as setMotelyDecoderEnums } from "./decode/motelyItemDecoder.js";
|
|
27
28
|
export { JamlAestheticSelector, type JamlAestheticSelectorProps, type JamlAestheticOption, } from "./components/JamlAestheticSelector.js";
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export { extractVisualJamlItems, } from "./utils/jamlMapPreview.js";
|
|
|
23
23
|
export { useMotelyStream } from "./hooks/useShopStream.js";
|
|
24
24
|
export { useSearch, } from "./hooks/useSearch.js";
|
|
25
25
|
export { useAnalyzer, } from "./hooks/useAnalyzer.js";
|
|
26
|
+
export { SEARCH_WORKER_CODE } from "./hooks/searchWorkerCode.js";
|
|
26
27
|
// Setter pattern for motely-wasm runtime enums. Consumers boot motely-wasm
|
|
27
28
|
// and call setMotelyEnums(Motely) once after boot so display/decoder helpers
|
|
28
29
|
// can resolve enum keys without statically importing motely-wasm.
|