jaml-ui 0.14.4 → 0.17.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.
Files changed (97) hide show
  1. package/DESIGN.md +9 -11
  2. package/dist/assets.d.ts +7 -0
  3. package/dist/assets.js +11 -0
  4. package/dist/components/AnalyzerExplorer.d.ts +4 -1
  5. package/dist/components/AnalyzerExplorer.js +14 -48
  6. package/dist/components/GameCard.js +8 -7
  7. package/dist/components/JamlAestheticSelector.d.ts +4 -0
  8. package/dist/components/JamlAestheticSelector.js +6 -19
  9. package/dist/components/JamlAnalyzerFullscreen.d.ts +7 -1
  10. package/dist/components/JamlAnalyzerFullscreen.js +18 -47
  11. package/dist/components/JamlIde.js +12 -24
  12. package/dist/components/JamlIdeVisual.js +3 -56
  13. package/dist/components/JamlMapPreview.d.ts +6 -1
  14. package/dist/components/JamlMapPreview.js +99 -21
  15. package/dist/components/JamlSeedInput.d.ts +5 -0
  16. package/dist/components/JamlSeedInput.js +11 -14
  17. package/dist/components/MotelyVersionBadge.d.ts +1 -3
  18. package/dist/components/MotelyVersionBadge.js +4 -16
  19. package/dist/components/jamlMap/JamlMapEditorDemo.d.ts +8 -0
  20. package/dist/components/jamlMap/JamlMapEditorDemo.js +170 -0
  21. package/dist/components/jamlMap/JokerPicker.d.ts +7 -0
  22. package/dist/components/jamlMap/JokerPicker.js +258 -0
  23. package/dist/components/jamlMap/MysterySlot.d.ts +32 -0
  24. package/dist/components/jamlMap/MysterySlot.js +109 -0
  25. package/dist/components/jamlMap/index.d.ts +3 -0
  26. package/dist/components/jamlMap/index.js +3 -0
  27. package/dist/core.d.ts +0 -2
  28. package/dist/core.js +0 -2
  29. package/dist/decode/motelyItemDecoder.d.ts +10 -23
  30. package/dist/decode/motelyItemDecoder.js +103 -248
  31. package/dist/decode/motelySprite.d.ts +19 -0
  32. package/dist/decode/motelySprite.js +84 -0
  33. package/dist/hooks/analyzerStreamRegistry.js +30 -82
  34. package/dist/hooks/useAnalyzer.d.ts +10 -3
  35. package/dist/hooks/useAnalyzer.js +11 -6
  36. package/dist/hooks/useIntersectionObserver.d.ts +14 -0
  37. package/dist/hooks/useIntersectionObserver.js +50 -0
  38. package/dist/index.d.ts +3 -8
  39. package/dist/index.js +2 -7
  40. package/dist/motely.d.ts +2 -1
  41. package/dist/motely.js +2 -1
  42. package/dist/motelyDisplay.d.ts +4 -623
  43. package/dist/motelyDisplay.js +26 -165
  44. package/dist/r3f/Card3D.d.ts +2 -2
  45. package/dist/r3f/Card3D.js +13 -46
  46. package/dist/r3f/JimboBillboard.d.ts +10 -0
  47. package/dist/r3f/JimboBillboard.js +29 -0
  48. package/dist/r3f/JimboText3D.d.ts +9 -0
  49. package/dist/r3f/JimboText3D.js +8 -0
  50. package/dist/r3f.d.ts +2 -0
  51. package/dist/r3f.js +2 -0
  52. package/dist/render/CanvasRenderer.js +7 -171
  53. package/dist/sprites/spriteData.d.ts +1 -0
  54. package/dist/sprites/spriteData.js +1 -0
  55. package/dist/sprites/spriteMapper.d.ts +78 -1
  56. package/dist/sprites/spriteMapper.js +52 -0
  57. package/dist/ui/JimboBadge.d.ts +13 -0
  58. package/dist/ui/JimboBadge.js +8 -0
  59. package/dist/ui/JimboFloating.d.ts +8 -0
  60. package/dist/ui/JimboFloating.js +17 -0
  61. package/dist/ui/JimboToggleList.d.ts +11 -0
  62. package/dist/ui/JimboToggleList.js +5 -0
  63. package/dist/ui/codeBlock.js +2 -3
  64. package/dist/ui/footer.d.ts +4 -0
  65. package/dist/ui/footer.js +6 -4
  66. package/dist/ui/hooks.d.ts +89 -0
  67. package/dist/ui/hooks.js +551 -0
  68. package/dist/ui/jimboBackground.js +2 -131
  69. package/dist/ui/jimboCopyRow.d.ts +4 -0
  70. package/dist/ui/jimboCopyRow.js +5 -22
  71. package/dist/ui/jimboFilterBar.d.ts +1 -4
  72. package/dist/ui/jimboFilterBar.js +2 -61
  73. package/dist/ui/jimboFlankNav.d.ts +1 -2
  74. package/dist/ui/jimboFlankNav.js +5 -30
  75. package/dist/ui/jimboTabs.d.ts +1 -5
  76. package/dist/ui/jimboTabs.js +6 -41
  77. package/dist/ui/jimboText.d.ts +1 -1
  78. package/dist/ui/jimboText.js +15 -32
  79. package/dist/ui/jimboTooltip.d.ts +1 -12
  80. package/dist/ui/jimboTooltip.js +6 -82
  81. package/dist/ui/panel.d.ts +3 -1
  82. package/dist/ui/panel.js +11 -47
  83. package/dist/ui/showcase.d.ts +4 -0
  84. package/dist/ui/showcase.js +9 -36
  85. package/dist/ui/sprites.d.ts +14 -0
  86. package/dist/ui/sprites.js +54 -13
  87. package/dist/ui.d.ts +4 -0
  88. package/dist/ui.js +5 -0
  89. package/package.json +130 -122
  90. package/dist/components/JamlSpeedometer.d.ts +0 -11
  91. package/dist/components/JamlSpeedometer.js +0 -54
  92. package/dist/decode/packedBalatroItem.d.ts +0 -13
  93. package/dist/decode/packedBalatroItem.js +0 -26
  94. package/dist/hooks/loadMotelyWasm.d.ts +0 -7
  95. package/dist/hooks/loadMotelyWasm.js +0 -16
  96. package/dist/utils/itemUtils.d.ts +0 -11
  97. package/dist/utils/itemUtils.js +0 -71
@@ -1,4 +1,9 @@
1
+ import type { Motely as MotelyT, MotelyWasm as MotelyWasmT } from "motely-wasm";
1
2
  import type { AnalyzerAnteView } from "../components/AnalyzerExplorer.js";
3
+ export interface MotelyRuntime {
4
+ MotelyWasm: typeof MotelyWasmT;
5
+ Motely: typeof MotelyT;
6
+ }
2
7
  export type AnalyzerStatus = "idle" | "running" | "done" | "error";
3
8
  export type MotelyJsRunState = {
4
9
  voucherBitfield: number;
@@ -13,19 +18,21 @@ export type MotelyJsRunState = {
13
18
  * `createShopItemStream(ante, runState, ...)`.
14
19
  */
15
20
  export interface AnalyzerLive {
16
- ctx: any;
17
- Motely: any;
21
+ ctx: ReturnType<typeof MotelyWasmT.createSearchContext>;
22
+ Motely: typeof MotelyT;
18
23
  runStates: Record<number, MotelyJsRunState>;
19
24
  desiredNames: ReadonlySet<string>;
20
25
  seed: string;
21
26
  deck: string;
22
27
  stake: string;
23
28
  }
24
- export declare function useAnalyzer(motelyWasmUrl: string): {
29
+ export declare function useAnalyzer(motelyRuntime: MotelyRuntime): {
25
30
  antes: AnalyzerAnteView[];
26
31
  status: AnalyzerStatus;
27
32
  error: string | null;
28
33
  analyze: (seed: string, deck: string, stake: string, jaml?: string) => Promise<void>;
29
34
  clearError: () => void;
30
35
  live: AnalyzerLive | null;
36
+ tallyColumns: number[][];
37
+ tallyLabels: string[];
31
38
  };
@@ -1,20 +1,23 @@
1
1
  "use client";
2
2
  import { useState, useCallback } from "react";
3
- import { loadMotelyWasm } from "./loadMotelyWasm.js";
4
3
  import { extractVisualJamlItems } from "../utils/jamlMapPreview.js";
5
4
  import { motelyItemDisplayNameFromValue } from "../motelyDisplay.js";
6
- export function useAnalyzer(motelyWasmUrl) {
5
+ export function useAnalyzer(motelyRuntime) {
7
6
  const [antes, setAntes] = useState([]);
8
7
  const [status, setStatus] = useState("idle");
9
8
  const [error, setError] = useState(null);
10
9
  const [live, setLive] = useState(null);
10
+ const [tallyColumns, setTallyColumns] = useState([]);
11
+ const [tallyLabels, setTallyLabels] = useState([]);
11
12
  const analyze = useCallback(async (seed, deck, stake, jaml) => {
12
13
  setAntes([]);
13
14
  setLive(null);
15
+ setTallyColumns([]);
16
+ setTallyLabels([]);
14
17
  setStatus("running");
15
18
  setError(null);
16
19
  try {
17
- const { MotelyWasm, Motely } = await loadMotelyWasm(motelyWasmUrl);
20
+ const { MotelyWasm, Motely } = motelyRuntime;
18
21
  const deckEnum = Motely.MotelyDeck[deck] ?? Motely.MotelyDeck.Red;
19
22
  const stakeEnum = Motely.MotelyStake[stake] ?? Motely.MotelyStake.White;
20
23
  const desiredNames = new Set();
@@ -23,13 +26,15 @@ export function useAnalyzer(motelyWasmUrl) {
23
26
  for (const item of [...groups.must, ...groups.should]) {
24
27
  desiredNames.add(item.value.toLowerCase());
25
28
  }
29
+ const labels = MotelyWasm.getTallyLabels(jaml);
30
+ setTallyLabels(labels);
26
31
  }
27
32
  const ctx = MotelyWasm.createSearchContext(seed, deckEnum, stakeEnum);
28
33
  const bossStream = ctx.createBossStream();
29
34
  let runState = { voucherBitfield: 0, bossBitfield: 0 };
30
35
  const results = [];
31
36
  const runStates = {};
32
- for (let ante = 1; ante <= 8; ante++) {
37
+ for (let ante = 1; ante <= 39; ante++) {
33
38
  const bossResult = ctx.getNextBossForAnte(bossStream, ante, runState);
34
39
  const bossName = Motely.MotelyBossBlind[bossResult.boss] ?? `Unknown(${bossResult.boss})`;
35
40
  runState = bossResult.runState;
@@ -72,10 +77,10 @@ export function useAnalyzer(motelyWasmUrl) {
72
77
  setError(e instanceof Error ? e.message : String(e));
73
78
  setStatus("error");
74
79
  }
75
- }, [motelyWasmUrl]);
80
+ }, [motelyRuntime]);
76
81
  const clearError = useCallback(() => {
77
82
  setError(null);
78
83
  setStatus((s) => (s === "error" ? "idle" : s));
79
84
  }, []);
80
- return { antes, status, error, analyze, clearError, live };
85
+ return { antes, status, error, analyze, clearError, live, tallyColumns, tallyLabels };
81
86
  }
@@ -0,0 +1,14 @@
1
+ export interface UseIntersectionObserverOptions extends IntersectionObserverInit {
2
+ freezeOnceVisible?: boolean;
3
+ }
4
+ /**
5
+ * Encapsulates IntersectionObserver logic.
6
+ */
7
+ export declare function useIntersectionObserver(options?: UseIntersectionObserverOptions): {
8
+ ref: (node: Element | null) => void;
9
+ entry: IntersectionObserverEntry | null;
10
+ };
11
+ /**
12
+ * Specialization for infinite scroll / sentinel patterns.
13
+ */
14
+ export declare function useInfiniteScroll(onVisible: () => void, options?: IntersectionObserverInit, active?: boolean): (node: Element | null) => void;
@@ -0,0 +1,50 @@
1
+ import { useEffect, useRef, useState, useCallback } from "react";
2
+ /**
3
+ * Encapsulates IntersectionObserver logic.
4
+ */
5
+ export function useIntersectionObserver(options = {}) {
6
+ const [entry, setEntry] = useState(null);
7
+ const [node, setNode] = useState(null);
8
+ const observer = useRef(null);
9
+ const ref = useCallback((node) => {
10
+ setNode(node);
11
+ }, []);
12
+ useEffect(() => {
13
+ if (!node)
14
+ return;
15
+ if (observer.current)
16
+ observer.current.disconnect();
17
+ const { freezeOnceVisible, ...init } = options;
18
+ observer.current = new IntersectionObserver(([entry]) => {
19
+ setEntry(entry);
20
+ if (freezeOnceVisible && entry.isIntersecting && observer.current) {
21
+ observer.current.disconnect();
22
+ }
23
+ }, init);
24
+ observer.current.observe(node);
25
+ return () => {
26
+ if (observer.current)
27
+ observer.current.disconnect();
28
+ };
29
+ }, [node, options.root, options.rootMargin, options.threshold, options.freezeOnceVisible]);
30
+ return { ref, entry };
31
+ }
32
+ /**
33
+ * Specialization for infinite scroll / sentinel patterns.
34
+ */
35
+ export function useInfiniteScroll(onVisible, options = {}, active = true) {
36
+ const onVisibleRef = useRef(onVisible);
37
+ onVisibleRef.current = onVisible;
38
+ const { ref, entry } = useIntersectionObserver({
39
+ ...options,
40
+ threshold: options.threshold ?? 0.1,
41
+ });
42
+ useEffect(() => {
43
+ if (!active || !entry)
44
+ return;
45
+ if (entry.isIntersecting) {
46
+ onVisibleRef.current();
47
+ }
48
+ }, [entry, active]);
49
+ return ref;
50
+ }
package/dist/index.d.ts CHANGED
@@ -9,12 +9,7 @@ export { JamlMapPreview, type JamlMapPreviewProps } from "./components/JamlMapPr
9
9
  export { JamlIde, type JamlIdeProps, type JamlIdeSearchResult, type JamlVisualFilter, type JamlVisualClause, type JamlZone, } from "./components/JamlIde.js";
10
10
  export { JamlIdeVisual, type JamlIdeVisualProps, } from "./components/JamlIdeVisual.js";
11
11
  export { JamlCodeEditor, type JamlCodeEditorProps, } from "./components/JamlCodeEditor.js";
12
- export { JimboText, type JimboTextProps, type JimboTextTone, type JimboTextSize, } from "./ui/jimboText.js";
13
- export { JimboTabs, JimboVerticalTabs, type JimboTabItem, type JimboTabsProps, } from "./ui/jimboTabs.js";
14
- export { JimboFlankNav, type JimboFlankNavProps, } from "./ui/jimboFlankNav.js";
15
- export { JimboFilterBar, type JimboFilterBarProps, type JimboFilterSortOption, } from "./ui/jimboFilterBar.js";
16
- export { JimboBackground } from "./ui/jimboBackground.js";
17
- export { JimboTooltip, type JimboTooltipProps, type JimboTooltipMode, type JimboTooltipPlacement, } from "./ui/jimboTooltip.js";
12
+ export * from "./ui.js";
18
13
  export { JamlIdeToolbar, type JamlIdeMode, type JamlIdeToolbarProps, } from "./components/JamlIdeToolbar.js";
19
14
  export { CardList, type CardListProps } from "./components/CardList.js";
20
15
  export { CardFan, type CardFanProps } from "./components/CardFan.js";
@@ -24,7 +19,7 @@ export { MotelyVersionBadge, type MotelyVersionBadgeProps, type MotelyCapabiliti
24
19
  export { extractVisualJamlItems, type JamlPreviewGroups, type JamlPreviewItem, type JamlPreviewSection, type JamlPreviewVisualType, } from "./utils/jamlMapPreview.js";
25
20
  export { useMotelyStream, type StreamItem, type StreamState } from "./hooks/useShopStream.js";
26
21
  export { useSearch, type SearchResult, type SearchStatus, type UseSearchState, } from "./hooks/useSearch.js";
27
- export { useAnalyzer, type AnalyzerStatus, type AnalyzerLive, type MotelyJsRunState, } from "./hooks/useAnalyzer.js";
28
- export { JamlSpeedometer, type JamlSpeedometerProps, } from "./components/JamlSpeedometer.js";
22
+ export { useAnalyzer, type AnalyzerStatus, type AnalyzerLive, type MotelyRuntime, type MotelyJsRunState, } from "./hooks/useAnalyzer.js";
29
23
  export { JamlAestheticSelector, type JamlAestheticSelectorProps, type JamlAestheticOption, } from "./components/JamlAestheticSelector.js";
30
24
  export { JamlSeedInput, type JamlSeedInputProps, } from "./components/JamlSeedInput.js";
25
+ export { JamlMapEditorDemo, JokerPicker, MysterySlot, type JamlMapEditorDemoProps, type JokerPickerProps, type JokerRarity, type MysterySlotProps, type SlotCategory, type SlotSelection, } from "./components/jamlMap/index.js";
package/dist/index.js CHANGED
@@ -10,12 +10,7 @@ export { JamlMapPreview } from "./components/JamlMapPreview.js";
10
10
  export { JamlIde, } from "./components/JamlIde.js";
11
11
  export { JamlIdeVisual, } from "./components/JamlIdeVisual.js";
12
12
  export { JamlCodeEditor, } from "./components/JamlCodeEditor.js";
13
- export { JimboText, } from "./ui/jimboText.js";
14
- export { JimboTabs, JimboVerticalTabs, } from "./ui/jimboTabs.js";
15
- export { JimboFlankNav, } from "./ui/jimboFlankNav.js";
16
- export { JimboFilterBar, } from "./ui/jimboFilterBar.js";
17
- export { JimboBackground } from "./ui/jimboBackground.js";
18
- export { JimboTooltip, } from "./ui/jimboTooltip.js";
13
+ export * from "./ui.js";
19
14
  export { JamlIdeToolbar, } from "./components/JamlIdeToolbar.js";
20
15
  export { CardList } from "./components/CardList.js";
21
16
  export { CardFan } from "./components/CardFan.js";
@@ -26,6 +21,6 @@ export { extractVisualJamlItems, } from "./utils/jamlMapPreview.js";
26
21
  export { useMotelyStream } from "./hooks/useShopStream.js";
27
22
  export { useSearch, } from "./hooks/useSearch.js";
28
23
  export { useAnalyzer, } from "./hooks/useAnalyzer.js";
29
- export { JamlSpeedometer, } from "./components/JamlSpeedometer.js";
30
24
  export { JamlAestheticSelector, } from "./components/JamlAestheticSelector.js";
31
25
  export { JamlSeedInput, } from "./components/JamlSeedInput.js";
26
+ export { JamlMapEditorDemo, JokerPicker, MysterySlot, } from "./components/jamlMap/index.js";
package/dist/motely.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { decodeMotelyItem, decodeMotelyItemToJamlCard, motelyItemTypeName, motelyItemCategory, motelyItemDisplayName, motelyItemRenderCategory, motelyItemEditionName, motelyItemSealName, motelyItemEnhancementName, motelyStandardcardRankName, motelyStandardcardSuitName, decodeMotelyItemName, resolveMotelyItemType, warmMotelyItemCache, motelyItemCacheSize, type DecodedMotelyItem, type MotelyItemInput, type MotelyJamlCard, type MotelyRenderableCategory, type MotelyRuntimeItem, } from "./decode/motelyItemDecoder.js";
2
- export { MOTELY_DISPLAY_SCHEMA, motelyBossDisplayName, motelyBossDisplayNameFromKey, motelyBossKeyFromDisplayName, motelyBoosterPackDisplayName, motelyBoosterPackDisplayNameFromKey, motelyBoosterPackKeyFromDisplayName, motelyItemDisplayNameFromKey, motelyItemDisplayNameFromValue, motelyTagDisplayName, motelyTagDisplayNameFromKey, motelyTagKeyFromDisplayName, motelyVoucherDisplayName, motelyVoucherDisplayNameFromKey, motelyVoucherKeyFromDisplayName, type MotelyBoosterPackKey, type MotelyBossKey, type MotelyDisplaySchema, type MotelyTagKey, type MotelyVoucherKey, } from "./motelyDisplay.js";
2
+ export { motelyItemToSprite, getMotelySpriteByName, type MotelySpriteData, } from "./decode/motelySprite.js";
3
+ export { motelyBossDisplayName, motelyBossDisplayNameFromKey, motelyBoosterPackDisplayName, motelyBoosterPackDisplayNameFromKey, motelyItemDisplayNameFromKey, motelyItemDisplayNameFromValue, motelyTagDisplayName, motelyTagDisplayNameFromKey, motelyVoucherDisplayName, motelyVoucherDisplayNameFromKey, } from "./motelyDisplay.js";
package/dist/motely.js CHANGED
@@ -1,3 +1,4 @@
1
1
  "use client";
2
2
  export { decodeMotelyItem, decodeMotelyItemToJamlCard, motelyItemTypeName, motelyItemCategory, motelyItemDisplayName, motelyItemRenderCategory, motelyItemEditionName, motelyItemSealName, motelyItemEnhancementName, motelyStandardcardRankName, motelyStandardcardSuitName, decodeMotelyItemName, resolveMotelyItemType, warmMotelyItemCache, motelyItemCacheSize, } from "./decode/motelyItemDecoder.js";
3
- export { MOTELY_DISPLAY_SCHEMA, motelyBossDisplayName, motelyBossDisplayNameFromKey, motelyBossKeyFromDisplayName, motelyBoosterPackDisplayName, motelyBoosterPackDisplayNameFromKey, motelyBoosterPackKeyFromDisplayName, motelyItemDisplayNameFromKey, motelyItemDisplayNameFromValue, motelyTagDisplayName, motelyTagDisplayNameFromKey, motelyTagKeyFromDisplayName, motelyVoucherDisplayName, motelyVoucherDisplayNameFromKey, motelyVoucherKeyFromDisplayName, } from "./motelyDisplay.js";
3
+ export { motelyItemToSprite, getMotelySpriteByName, } from "./decode/motelySprite.js";
4
+ export { motelyBossDisplayName, motelyBossDisplayNameFromKey, motelyBoosterPackDisplayName, motelyBoosterPackDisplayNameFromKey, motelyItemDisplayNameFromKey, motelyItemDisplayNameFromValue, motelyTagDisplayName, motelyTagDisplayNameFromKey, motelyVoucherDisplayName, motelyVoucherDisplayNameFromKey, } from "./motelyDisplay.js";