jaml-ui 0.22.0 → 0.22.1

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.
@@ -24,7 +24,7 @@ export interface AnalyzerLive {
24
24
  deck: string;
25
25
  stake: string;
26
26
  }
27
- export declare function useAnalyzer(runtime: MotelyRuntime): {
27
+ export declare function useAnalyzer(runtime: MotelyRuntime | null): {
28
28
  antes: AnalyzerAnteView[];
29
29
  status: AnalyzerStatus;
30
30
  error: string | null;
@@ -3,7 +3,6 @@ import { useState, useCallback } from "react";
3
3
  import { extractVisualJamlItems } from "../utils/jamlMapPreview.js";
4
4
  import { motelyItemDisplayNameFromValue } from "../motelyDisplay.js";
5
5
  export function useAnalyzer(runtime) {
6
- const { MotelyWasm, Motely } = runtime;
7
6
  const [antes, setAntes] = useState([]);
8
7
  const [status, setStatus] = useState("idle");
9
8
  const [error, setError] = useState(null);
@@ -11,6 +10,12 @@ export function useAnalyzer(runtime) {
11
10
  const [tallyColumns, setTallyColumns] = useState([]);
12
11
  const [tallyLabels, setTallyLabels] = useState([]);
13
12
  const analyze = useCallback(async (seed, deck, stake, jaml) => {
13
+ if (!runtime) {
14
+ setError("motely-wasm runtime not ready");
15
+ setStatus("error");
16
+ return;
17
+ }
18
+ const { MotelyWasm, Motely } = runtime;
14
19
  setAntes([]);
15
20
  setLive(null);
16
21
  setTallyColumns([]);
@@ -77,7 +82,7 @@ export function useAnalyzer(runtime) {
77
82
  setError(e instanceof Error ? e.message : String(e));
78
83
  setStatus("error");
79
84
  }
80
- }, [MotelyWasm, Motely]);
85
+ }, [runtime]);
81
86
  const clearError = useCallback(() => {
82
87
  setError(null);
83
88
  setStatus((s) => (s === "error" ? "idle" : s));
@@ -3,7 +3,7 @@ export interface MotelyRuntime {
3
3
  MotelyWasm: typeof MotelyWasmType;
4
4
  Motely: typeof MotelyEnumsType;
5
5
  }
6
- export declare function useSeedAnalyzer(runtime: MotelyRuntime, seed: string | null): {
6
+ export declare function useSeedAnalyzer(runtime: MotelyRuntime | null, seed: string | null): {
7
7
  data: Analysis.MotelyLegacyTextAnalyzer | null | undefined;
8
8
  loading: boolean;
9
9
  error: string | null;
@@ -5,7 +5,7 @@ export function useSeedAnalyzer(runtime, seed) {
5
5
  const [loading, setLoading] = useState(false);
6
6
  const [error, setError] = useState(null);
7
7
  useEffect(() => {
8
- if (!seed || seed === "LOCKED") {
8
+ if (!seed || seed === "LOCKED" || !runtime) {
9
9
  setData(null);
10
10
  return;
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaml-ui",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
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",