jaml-ui 0.8.0 → 0.10.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 (63) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +135 -135
  3. package/dist/assets.js +1 -1
  4. package/dist/components/CardFan.d.ts +22 -0
  5. package/dist/components/CardFan.js +80 -0
  6. package/dist/components/DeckSprite.d.ts +26 -0
  7. package/dist/components/DeckSprite.js +73 -0
  8. package/dist/components/JamlCodeEditor.d.ts +7 -0
  9. package/dist/components/JamlCodeEditor.js +58 -0
  10. package/dist/components/JamlIde.js +2 -14
  11. package/dist/components/JamlIdeVisual.js +4 -4
  12. package/dist/components/MotelyVersionBadge.d.ts +30 -0
  13. package/dist/components/MotelyVersionBadge.js +31 -0
  14. package/dist/hooks/searchWorkerCode.js +59 -59
  15. package/dist/index.d.ts +11 -0
  16. package/dist/index.js +11 -0
  17. package/dist/ui/footer.js +5 -5
  18. package/dist/ui/jimboBackground.d.ts +14 -0
  19. package/dist/ui/jimboBackground.js +155 -0
  20. package/dist/ui/jimboFilterBar.d.ts +25 -0
  21. package/dist/ui/jimboFilterBar.js +77 -0
  22. package/dist/ui/jimboFlankNav.d.ts +18 -0
  23. package/dist/ui/jimboFlankNav.js +43 -0
  24. package/dist/ui/jimboTabs.d.ts +25 -0
  25. package/dist/ui/jimboTabs.js +59 -0
  26. package/dist/ui/jimboText.d.ts +26 -0
  27. package/dist/ui/jimboText.js +45 -0
  28. package/dist/ui/jimboTooltip.d.ts +35 -0
  29. package/dist/ui/jimboTooltip.js +109 -0
  30. package/dist/ui/panel.js +4 -6
  31. package/dist/ui/tokens.d.ts +2 -1
  32. package/dist/ui/tokens.js +2 -0
  33. package/dist/ui.d.ts +6 -0
  34. package/dist/ui.js +6 -0
  35. package/fonts.css +5 -0
  36. package/package.json +14 -3
  37. package/dist/data/balatro-jokers.json +0 -1241
  38. package/dist/r3f/BalatroJokerMesh3D.d.ts +0 -8
  39. package/dist/r3f/BalatroJokerMesh3D.js +0 -98
  40. package/dist/r3f/BalatroJokerPreview3D.d.ts +0 -14
  41. package/dist/r3f/BalatroJokerPreview3D.js +0 -30
  42. package/dist/r3f/BalatroPlayingCard3D.d.ts +0 -22
  43. package/dist/r3f/BalatroPlayingCard3D.js +0 -62
  44. package/dist/r3f/cardConstants.d.ts +0 -16
  45. package/dist/r3f/cardConstants.js +0 -14
  46. package/dist/r3f/compositedAtlas.d.ts +0 -5
  47. package/dist/r3f/compositedAtlas.js +0 -56
  48. package/dist/r3f/gridUV.d.ts +0 -22
  49. package/dist/r3f/gridUV.js +0 -30
  50. package/dist/r3f/index.d.ts +0 -12
  51. package/dist/r3f/index.js +0 -13
  52. package/dist/r3f/jokerRegistry.d.ts +0 -28
  53. package/dist/r3f/jokerRegistry.js +0 -40
  54. package/dist/r3f/jokerTilt.d.ts +0 -8
  55. package/dist/r3f/jokerTilt.js +0 -41
  56. package/dist/r3f/magneticTilt.d.ts +0 -18
  57. package/dist/r3f/magneticTilt.js +0 -34
  58. package/dist/r3f/playingCardTypes.d.ts +0 -24
  59. package/dist/r3f/playingCardTypes.js +0 -32
  60. package/dist/r3f/playingCardVisuals.d.ts +0 -7
  61. package/dist/r3f/playingCardVisuals.js +0 -45
  62. package/dist/r3f/usePlayingCardTexture.d.ts +0 -7
  63. package/dist/r3f/usePlayingCardTexture.js +0 -92
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 pifreak
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pifreak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,135 +1,135 @@
1
- # jaml-ui
2
-
3
- React components, UI tokens, sprites, and utilities for Balatro/JAML apps.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install jaml-ui react react-dom
9
- ```
10
-
11
- ## Package exports
12
-
13
- | Entry | Contents |
14
- |-------|----------|
15
- | `jaml-ui` | Game card components, JAML IDE, Analyzer Explorer, hooks |
16
- | `jaml-ui/ui` | Jimbo design system — JimboPanel, JimboButton, JimboModal, tokens |
17
- | `jaml-ui/core` | Pure asset helpers, sprite metadata, decode utilities (no React) |
18
- | `jaml-ui/motely` | motely-wasm decode helpers (requires `motely-wasm` peer) |
19
- | `jaml-ui/r3f` | 3D card component via React Three Fiber (requires r3f peers) |
20
-
21
- ## Quick start
22
-
23
- ```tsx
24
- import { JamlGameCard, AnalyzerExplorer, JamlIde } from "jaml-ui";
25
- import { JimboPanel, JimboButton } from "jaml-ui/ui";
26
- ```
27
-
28
- ### Game card
29
-
30
- ```tsx
31
- import { JamlGameCard } from "jaml-ui";
32
-
33
- <JamlGameCard
34
- type="joker"
35
- card={{ name: "Blueprint", edition: "Foil", isEternal: true, scale: 1.5 }}
36
- />
37
- ```
38
-
39
- ### Jimbo UI (Balatro design system)
40
-
41
- ```tsx
42
- import { JimboPanel, JimboButton, JimboModal } from "jaml-ui/ui";
43
- import { JimboColorOption } from "jaml-ui/ui";
44
-
45
- <JimboPanel sway onBack={() => setOpen(false)}>
46
- <JimboButton variant="primary" onClick={handleSearch}>Search</JimboButton>
47
- </JimboPanel>
48
- ```
49
-
50
- Available variants: `primary`, `secondary`, `danger`, `back`, `ghost`
51
-
52
- ### JAML IDE
53
-
54
- ```tsx
55
- import { JamlIde } from "jaml-ui";
56
-
57
- <JamlIde
58
- jaml={jaml}
59
- onChange={setJaml}
60
- searchResults={results}
61
- onSearch={handleSearch}
62
- isSearching={isSearching}
63
- />
64
- ```
65
-
66
- ### Analyzer Explorer
67
-
68
- ```tsx
69
- import { AnalyzerExplorer } from "jaml-ui";
70
-
71
- // antes: AnalyzerAnteView[] — stream from motely-wasm createSearchContext
72
- <AnalyzerExplorer antes={antes} totalAntes={8} highlights={highlights} />
73
- ```
74
-
75
- ### JAML Map Preview
76
-
77
- ```tsx
78
- import { JamlMapPreview } from "jaml-ui";
79
-
80
- <JamlMapPreview jaml={jaml} />
81
- ```
82
-
83
- ## Asset handling
84
-
85
- By default sprites resolve from the package `assets/` directory via `import.meta.url`.
86
-
87
- Override at app startup:
88
-
89
- ```ts
90
- import { setJamlAssetBaseUrl, clearJamlAssetBaseUrl } from "jaml-ui";
91
-
92
- setJamlAssetBaseUrl("/vendor/jaml-ui/"); // custom CDN
93
- clearJamlAssetBaseUrl(); // back to default
94
- ```
95
-
96
- ## Core utilities
97
-
98
- ```ts
99
- import { SPRITE_SHEETS, getSpriteData, resolveJamlAssetUrl } from "jaml-ui/core";
100
- ```
101
-
102
- ## Motely decode helpers
103
-
104
- ```ts
105
- import { decodeMotelyItemName, motelyItemTypeName } from "jaml-ui/motely";
106
- ```
107
-
108
- ## 3D card (optional)
109
-
110
- ```bash
111
- npm install three @react-three/fiber @react-three/drei @react-spring/three
112
- ```
113
-
114
- ```tsx
115
- import { Card3D } from "jaml-ui/r3f";
116
-
117
- <Card3D itemName="Blueprint" />
118
- ```
119
-
120
- ## Next.js
121
-
122
- Import pure helpers from `jaml-ui/core` for server components. For local workspace installs add:
123
-
124
- ```ts
125
- // next.config.ts
126
- const nextConfig = { transpilePackages: ["jaml-ui"] };
127
- ```
128
-
129
- ## Peer dependencies
130
-
131
- | Peer | Required for |
132
- |------|-------------|
133
- | `react`, `react-dom` | All components |
134
- | `motely-wasm ^10 \|\| ^11 \|\| ^12` | `jaml-ui/motely`, `AnalyzerExplorer` data |
135
- | `three`, `@react-three/fiber`, `@react-three/drei`, `@react-spring/three` | `jaml-ui/r3f` only |
1
+ # jaml-ui
2
+
3
+ React components, UI tokens, sprites, and utilities for Balatro/JAML apps.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install jaml-ui react react-dom
9
+ ```
10
+
11
+ ## Package exports
12
+
13
+ | Entry | Contents |
14
+ |-------|----------|
15
+ | `jaml-ui` | Game card components, JAML IDE, Analyzer Explorer, hooks |
16
+ | `jaml-ui/ui` | Jimbo design system — JimboPanel, JimboButton, JimboModal, tokens |
17
+ | `jaml-ui/core` | Pure asset helpers, sprite metadata, decode utilities (no React) |
18
+ | `jaml-ui/motely` | motely-wasm decode helpers (requires `motely-wasm` peer) |
19
+ | `jaml-ui/r3f` | 3D card component via React Three Fiber (requires r3f peers) |
20
+
21
+ ## Quick start
22
+
23
+ ```tsx
24
+ import { JamlGameCard, AnalyzerExplorer, JamlIde } from "jaml-ui";
25
+ import { JimboPanel, JimboButton } from "jaml-ui/ui";
26
+ ```
27
+
28
+ ### Game card
29
+
30
+ ```tsx
31
+ import { JamlGameCard } from "jaml-ui";
32
+
33
+ <JamlGameCard
34
+ type="joker"
35
+ card={{ name: "Blueprint", edition: "Foil", isEternal: true, scale: 1.5 }}
36
+ />
37
+ ```
38
+
39
+ ### Jimbo UI (Balatro design system)
40
+
41
+ ```tsx
42
+ import { JimboPanel, JimboButton, JimboModal } from "jaml-ui/ui";
43
+ import { JimboColorOption } from "jaml-ui/ui";
44
+
45
+ <JimboPanel sway onBack={() => setOpen(false)}>
46
+ <JimboButton variant="primary" onClick={handleSearch}>Search</JimboButton>
47
+ </JimboPanel>
48
+ ```
49
+
50
+ Available variants: `primary`, `secondary`, `danger`, `back`, `ghost`
51
+
52
+ ### JAML IDE
53
+
54
+ ```tsx
55
+ import { JamlIde } from "jaml-ui";
56
+
57
+ <JamlIde
58
+ jaml={jaml}
59
+ onChange={setJaml}
60
+ searchResults={results}
61
+ onSearch={handleSearch}
62
+ isSearching={isSearching}
63
+ />
64
+ ```
65
+
66
+ ### Analyzer Explorer
67
+
68
+ ```tsx
69
+ import { AnalyzerExplorer } from "jaml-ui";
70
+
71
+ // antes: AnalyzerAnteView[] — stream from motely-wasm createSearchContext
72
+ <AnalyzerExplorer antes={antes} totalAntes={8} highlights={highlights} />
73
+ ```
74
+
75
+ ### JAML Map Preview
76
+
77
+ ```tsx
78
+ import { JamlMapPreview } from "jaml-ui";
79
+
80
+ <JamlMapPreview jaml={jaml} />
81
+ ```
82
+
83
+ ## Asset handling
84
+
85
+ By default sprites resolve from the package `assets/` directory via `import.meta.url`.
86
+
87
+ Override at app startup:
88
+
89
+ ```ts
90
+ import { setJamlAssetBaseUrl, clearJamlAssetBaseUrl } from "jaml-ui";
91
+
92
+ setJamlAssetBaseUrl("/vendor/jaml-ui/"); // custom CDN
93
+ clearJamlAssetBaseUrl(); // back to default
94
+ ```
95
+
96
+ ## Core utilities
97
+
98
+ ```ts
99
+ import { SPRITE_SHEETS, getSpriteData, resolveJamlAssetUrl } from "jaml-ui/core";
100
+ ```
101
+
102
+ ## Motely decode helpers
103
+
104
+ ```ts
105
+ import { decodeMotelyItemName, motelyItemTypeName } from "jaml-ui/motely";
106
+ ```
107
+
108
+ ## 3D card (optional)
109
+
110
+ ```bash
111
+ npm install three @react-three/fiber @react-three/drei @react-spring/three
112
+ ```
113
+
114
+ ```tsx
115
+ import { Card3D } from "jaml-ui/r3f";
116
+
117
+ <Card3D itemName="Blueprint" />
118
+ ```
119
+
120
+ ## Next.js
121
+
122
+ Import pure helpers from `jaml-ui/core` for server components. For local workspace installs add:
123
+
124
+ ```ts
125
+ // next.config.ts
126
+ const nextConfig = { transpilePackages: ["jaml-ui"] };
127
+ ```
128
+
129
+ ## Peer dependencies
130
+
131
+ | Peer | Required for |
132
+ |------|-------------|
133
+ | `react`, `react-dom` | All components |
134
+ | `motely-wasm ^10 \|\| ^11 \|\| ^12` | `jaml-ui/motely`, `AnalyzerExplorer` data |
135
+ | `three`, `@react-three/fiber`, `@react-three/drei`, `@react-spring/three` | `jaml-ui/r3f` only |
package/dist/assets.js CHANGED
@@ -12,7 +12,7 @@ export const JAML_ASSET_FILES = {
12
12
  };
13
13
  const assetKeyByFileName = Object.fromEntries(Object.entries(JAML_ASSET_FILES).map(([key, fileName]) => [fileName, key]));
14
14
  // Keep in lockstep with package.json version. Upload assets to this path when publishing.
15
- const JAML_UI_VERSION = "0.8.0";
15
+ const JAML_UI_VERSION = "0.10.0";
16
16
  const CDN_BASE = `https://cdn.seedfinder.app/jaml-ui/${JAML_UI_VERSION}/assets/`;
17
17
  const defaultAssetUrls = {
18
18
  deck: `${CDN_BASE}${JAML_ASSET_FILES.deck}`,
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ export interface CardFanProps {
3
+ /** Total number of cards to render (used when `cards` is not provided). */
4
+ count?: number;
5
+ /** Array of cards as "rank_suit" strings (e.g. ["2_C", "10_H", "A_S"]). Takes priority over `count`. */
6
+ cards?: string[];
7
+ /** Optional label below the fan. */
8
+ label?: string;
9
+ showLabel?: boolean;
10
+ className?: string;
11
+ style?: React.CSSProperties;
12
+ }
13
+ /**
14
+ * Parabolic card fan with rotation + arc overlap. Ported from weejoker's
15
+ * CardFan.tsx. Uses mathematical transforms (inline style, not Tailwind)
16
+ * to produce the authentic Balatro spread: cards overlap toward the
17
+ * center, tilt outward, sit higher at the edges.
18
+ *
19
+ * Sizing, overlap, and max rotation auto-scale with card count so full
20
+ * 52-card decks render cleanly and tiny 3-card hands look deliberate.
21
+ */
22
+ export declare function CardFan({ count, cards, className, style, label, showLabel }: CardFanProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,80 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { RealPlayingCard } from './PlayingCard.js';
4
+ import { JimboColorOption } from '../ui/tokens.js';
5
+ import { JimboText } from '../ui/jimboText.js';
6
+ const RANK_MAP = {
7
+ '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9', '10': '10',
8
+ J: 'Jack', Q: 'Queen', K: 'King', A: 'Ace',
9
+ };
10
+ const SUIT_MAP = {
11
+ H: 'Hearts', C: 'Clubs', D: 'Diamonds', S: 'Spades',
12
+ };
13
+ function parseJamlCard(input) {
14
+ const [r, s] = input.split('_');
15
+ return {
16
+ rank: RANK_MAP[r] ?? '2',
17
+ suit: SUIT_MAP[s] ?? 'Clubs',
18
+ };
19
+ }
20
+ /**
21
+ * Parabolic card fan with rotation + arc overlap. Ported from weejoker's
22
+ * CardFan.tsx. Uses mathematical transforms (inline style, not Tailwind)
23
+ * to produce the authentic Balatro spread: cards overlap toward the
24
+ * center, tilt outward, sit higher at the edges.
25
+ *
26
+ * Sizing, overlap, and max rotation auto-scale with card count so full
27
+ * 52-card decks render cleanly and tiny 3-card hands look deliberate.
28
+ */
29
+ export function CardFan({ count = 0, cards, className = '', style, label, showLabel = true }) {
30
+ const displayCount = cards ? cards.length : count;
31
+ const cardSize = displayCount > 40 ? 46
32
+ : displayCount > 30 ? 32
33
+ : displayCount > 12 ? 36
34
+ : displayCount > 8 ? 42
35
+ : displayCount > 5 ? 48
36
+ : 54;
37
+ const overlap = displayCount > 40 ? 0.88
38
+ : displayCount > 30 ? 0.85
39
+ : displayCount > 15 ? 0.75
40
+ : displayCount > 6 ? 0.60
41
+ : 0.45;
42
+ const cardSpacing = cardSize * (1 - overlap);
43
+ const maxRotation = displayCount > 40 ? 40
44
+ : displayCount > 20 ? 30
45
+ : displayCount > 10 ? 15
46
+ : 25;
47
+ const cardsHeight = 120;
48
+ return (_jsxs("div", { className: className, style: {
49
+ display: 'flex',
50
+ flexDirection: 'column',
51
+ alignItems: 'center',
52
+ gap: 4,
53
+ ...style,
54
+ }, children: [_jsx("div", { style: { position: 'relative', width: '100%', height: cardsHeight }, children: displayCount > 0 ? (Array.from({ length: displayCount }).map((_, i) => {
55
+ const centerIndex = (displayCount - 1) / 2;
56
+ const offset = i - centerIndex;
57
+ const xPos = offset * cardSpacing;
58
+ // Parabolic lift — outer cards sit higher than center (bowed upward)
59
+ const yOffset = Math.pow(Math.abs(offset / (centerIndex || 1)), 2) * (displayCount > 20 ? 20 : 10);
60
+ const rotation = (offset / (centerIndex || 1)) * maxRotation;
61
+ const parsed = cards ? parseJamlCard(cards[i]) : { rank: '2', suit: 'Clubs' };
62
+ return (_jsx("div", { style: {
63
+ position: 'absolute',
64
+ left: '50%',
65
+ bottom: 0,
66
+ transform: `translateX(calc(-50% + ${xPos}px)) translateY(${yOffset}px) rotate(${rotation}deg)`,
67
+ transformOrigin: 'bottom center',
68
+ zIndex: i,
69
+ }, children: _jsx(RealPlayingCard, { rank: parsed.rank, suit: parsed.suit, size: cardSize, style: { filter: `drop-shadow(0 2px 3px ${JimboColorOption.BLACK}66)` } }) }, i));
70
+ })) : (_jsx("div", { style: {
71
+ display: 'flex',
72
+ alignItems: 'center',
73
+ justifyContent: 'center',
74
+ width: '100%',
75
+ height: '100%',
76
+ background: `${JimboColorOption.WHITE}0d`,
77
+ border: `1px solid ${JimboColorOption.WHITE}0d`,
78
+ borderRadius: 8,
79
+ }, children: _jsx(JimboText, { size: "xs", uppercase: true, tone: "grey", children: "Deck Empty" }) })) }), label && showLabel ? _jsx(JimboText, { size: "xs", uppercase: true, tone: "grey", children: label }) : null] }));
80
+ }
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ export declare const DECK_SPRITE_POS: Record<string, {
3
+ x: number;
4
+ y: number;
5
+ }>;
6
+ export declare const STAKE_SPRITE_POS: Record<string, {
7
+ x: number;
8
+ y: number;
9
+ }>;
10
+ export interface DeckSpriteProps {
11
+ /** Deck name — case-insensitive, "Deck" suffix tolerated (e.g. "Erratic Deck" → "erratic"). */
12
+ deck: string;
13
+ /** Optional stake name to overlay its sticker on the deck. */
14
+ stake?: string;
15
+ /** Rendered width in pixels. Height is scaled proportionally from the 142x190 sprite. */
16
+ size?: number;
17
+ className?: string;
18
+ style?: React.CSSProperties;
19
+ }
20
+ /**
21
+ * Balatro deck box sprite — optionally overlaid with a stake sticker.
22
+ * Draws from the Enhancers.png atlas (deck thumbnails live in the bottom
23
+ * two rows) and stickers.png for the stake band. Uses jaml-ui's
24
+ * `resolveJamlAssetUrl` so consumers can override the CDN base.
25
+ */
26
+ export declare function DeckSprite({ deck, stake, size, className, style }: DeckSpriteProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,73 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { resolveJamlAssetUrl } from '../assets.js';
4
+ export const DECK_SPRITE_POS = {
5
+ red: { x: 0, y: 0 },
6
+ nebula: { x: 3, y: 0 },
7
+ locked: { x: 4, y: 0 },
8
+ blue: { x: 0, y: 2 },
9
+ yellow: { x: 1, y: 2 },
10
+ green: { x: 2, y: 2 },
11
+ black: { x: 3, y: 2 },
12
+ plasma: { x: 4, y: 2 },
13
+ ghost: { x: 6, y: 2 },
14
+ magic: { x: 0, y: 3 },
15
+ checkered: { x: 1, y: 3 },
16
+ erratic: { x: 2, y: 3 },
17
+ abandoned: { x: 3, y: 3 },
18
+ painted: { x: 4, y: 3 },
19
+ challenge: { x: 0, y: 4 },
20
+ anaglyph: { x: 2, y: 4 },
21
+ zodiac: { x: 3, y: 4 },
22
+ };
23
+ export const STAKE_SPRITE_POS = {
24
+ white: { x: 1, y: 0 },
25
+ red: { x: 2, y: 0 },
26
+ green: { x: 3, y: 0 },
27
+ blue: { x: 4, y: 0 },
28
+ black: { x: 0, y: 1 },
29
+ purple: { x: 1, y: 1 },
30
+ orange: { x: 2, y: 1 },
31
+ gold: { x: 3, y: 1 },
32
+ };
33
+ const SPRITE_WIDTH = 142;
34
+ const SPRITE_HEIGHT = 190;
35
+ const DECK_COLS = 7;
36
+ const DECK_ROWS = 5;
37
+ const STICKER_COLS = 5;
38
+ const STICKER_ROWS = 3;
39
+ /**
40
+ * Balatro deck box sprite — optionally overlaid with a stake sticker.
41
+ * Draws from the Enhancers.png atlas (deck thumbnails live in the bottom
42
+ * two rows) and stickers.png for the stake band. Uses jaml-ui's
43
+ * `resolveJamlAssetUrl` so consumers can override the CDN base.
44
+ */
45
+ export function DeckSprite({ deck, stake, size = 50, className = '', style }) {
46
+ const deckKey = (deck || 'erratic').toLowerCase().replace(/\s*deck$/, '').trim();
47
+ const deckPos = DECK_SPRITE_POS[deckKey] ?? DECK_SPRITE_POS.erratic;
48
+ const stakePos = stake ? STAKE_SPRITE_POS[stake.toLowerCase().replace(/\s*stake$/, '').trim()] : null;
49
+ const scale = size / SPRITE_WIDTH;
50
+ const displayHeight = SPRITE_HEIGHT * scale;
51
+ return (_jsxs("div", { className: className, style: {
52
+ position: 'relative',
53
+ width: size,
54
+ height: displayHeight,
55
+ ...style,
56
+ }, children: [_jsx("div", { style: {
57
+ position: 'absolute',
58
+ inset: 0,
59
+ backgroundImage: `url(${resolveJamlAssetUrl('enhancers')})`,
60
+ backgroundSize: `${DECK_COLS * 100}% ${DECK_ROWS * 100}%`,
61
+ backgroundPosition: `${(deckPos.x / (DECK_COLS - 1)) * 100}% ${(deckPos.y / (DECK_ROWS - 1)) * 100}%`,
62
+ backgroundRepeat: 'no-repeat',
63
+ imageRendering: 'pixelated',
64
+ } }), stakePos ? (_jsx("div", { style: {
65
+ position: 'absolute',
66
+ inset: 0,
67
+ backgroundImage: `url(${resolveJamlAssetUrl('stickers')})`,
68
+ backgroundSize: `${STICKER_COLS * 100}% ${STICKER_ROWS * 100}%`,
69
+ backgroundPosition: `${(stakePos.x / (STICKER_COLS - 1)) * 100}% ${(stakePos.y / (STICKER_ROWS - 1)) * 100}%`,
70
+ backgroundRepeat: 'no-repeat',
71
+ imageRendering: 'pixelated',
72
+ } })) : null] }));
73
+ }
@@ -0,0 +1,7 @@
1
+ export interface JamlCodeEditorProps {
2
+ value: string;
3
+ onChange: (value: string) => void;
4
+ placeholder?: string;
5
+ minHeight?: number;
6
+ }
7
+ export declare function JamlCodeEditor({ value, onChange, minHeight, }: JamlCodeEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import Editor from "@monaco-editor/react";
4
+ import { JimboColorOption } from "../ui/tokens.js";
5
+ // Monaco needs hex strings for its colors API. We strip the leading `#` from
6
+ // JimboColor tokens where Monaco expects raw hex for syntax rules (token
7
+ // foreground), and pass the full `#...` form for UI colors. Alpha suffix
8
+ // (e.g. WHITE + "20") is valid for Monaco colors but not for rules.
9
+ const hex = (token) => token.replace(/^#/, "");
10
+ const defineBalatroTheme = (monaco) => {
11
+ monaco.editor.defineTheme("jaml-balatro-dark", {
12
+ base: "vs-dark",
13
+ inherit: true,
14
+ rules: [
15
+ { token: "comment", foreground: hex(JimboColorOption.GREY), fontStyle: "italic" },
16
+ { token: "keyword", foreground: hex(JimboColorOption.RED) },
17
+ { token: "string", foreground: hex(JimboColorOption.GOLD_TEXT) },
18
+ { token: "number", foreground: hex(JimboColorOption.BLUE) },
19
+ { token: "type", foreground: hex(JimboColorOption.GREEN_TEXT) },
20
+ ],
21
+ colors: {
22
+ "editor.background": JimboColorOption.DARKEST,
23
+ "editor.foreground": JimboColorOption.WHITE,
24
+ "editorLineNumber.foreground": JimboColorOption.GREY,
25
+ "editorLineNumber.activeForeground": JimboColorOption.GOLD_TEXT,
26
+ "editor.selectionBackground": `${JimboColorOption.WHITE}20`,
27
+ "editor.inactiveSelectionBackground": `${JimboColorOption.WHITE}10`,
28
+ "editor.lineHighlightBackground": `${JimboColorOption.BLACK}20`,
29
+ "editorCursor.foreground": JimboColorOption.GOLD_TEXT,
30
+ "editorWidget.background": JimboColorOption.DARK_GREY,
31
+ "editorWidget.border": `${JimboColorOption.WHITE}20`,
32
+ "editorWidget.foreground": JimboColorOption.WHITE,
33
+ "list.activeSelectionBackground": JimboColorOption.GOLD,
34
+ "list.activeSelectionForeground": JimboColorOption.DARKEST,
35
+ "list.hoverBackground": JimboColorOption.PANEL_EDGE,
36
+ "list.hoverForeground": JimboColorOption.WHITE,
37
+ "list.focusBackground": JimboColorOption.GOLD,
38
+ "list.focusForeground": JimboColorOption.DARKEST,
39
+ },
40
+ });
41
+ };
42
+ export function JamlCodeEditor({ value, onChange, minHeight = 320, }) {
43
+ return (_jsx("div", { style: { width: "100%", minHeight, background: JimboColorOption.DARKEST }, children: _jsx(Editor, { height: `${minHeight}px`, defaultLanguage: "yaml", value: value, theme: "jaml-balatro-dark", onChange: (next) => onChange(next ?? ""), beforeMount: defineBalatroTheme, options: {
44
+ minimap: { enabled: false },
45
+ scrollBeyondLastLine: false,
46
+ fontSize: 13,
47
+ lineHeight: 22,
48
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
49
+ lineNumbers: "on",
50
+ automaticLayout: true,
51
+ padding: { top: 12, bottom: 12 },
52
+ wordWrap: "on",
53
+ formatOnPaste: true,
54
+ formatOnType: true,
55
+ renderLineHighlight: "line",
56
+ scrollbar: { verticalScrollbarSize: 8, horizontalScrollbarSize: 8 },
57
+ } }) }));
58
+ }
@@ -4,6 +4,7 @@ import { useMemo, useState } from "react";
4
4
  import { JamlMapPreview } from "./JamlMapPreview.js";
5
5
  import { JamlIdeToolbar } from "./JamlIdeToolbar.js";
6
6
  import { JamlIdeVisual } from "./JamlIdeVisual.js";
7
+ import { JamlCodeEditor } from "./JamlCodeEditor.js";
7
8
  import { JimboColorOption } from "../ui/tokens.js";
8
9
  import { jamlTextToVisualFilter, visualFilterToJamlText } from "../utils/jamlVisualFilter.js";
9
10
  function TallyBar({ value, max }) {
@@ -156,18 +157,5 @@ export function JamlIde({ jaml, defaultJaml, onChange, defaultMode = "code", sea
156
157
  padding: "10px 14px",
157
158
  borderBottom: `1px solid ${JimboColorOption.PANEL_EDGE}`,
158
159
  background: JimboColorOption.TEAL_GREY,
159
- }, children: [_jsxs("div", { children: [_jsx("div", { style: { fontSize: 14, fontWeight: 800, fontFamily: "m6x11plus, monospace", color: JimboColorOption.GOLD_TEXT }, children: title }), _jsx("div", { style: { fontSize: 11, color: JimboColorOption.GREY }, children: "Jimbo's Ante Markup Language" })] }), actions ? _jsx("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: actions }) : null] }), _jsx(JamlIdeToolbar, { mode: mode, onModeChange: setMode, resultCount: results.length, onSearch: onSearch, isSearching: isSearching }), _jsxs("div", { style: { flex: 1, minHeight: 0, overflow: "auto", background: JimboColorOption.DARKEST }, children: [mode === "visual" ? (_jsx(JamlIdeVisual, { filter: activeFilter, onChange: handleVisualFilterChange })) : null, mode === "code" ? (_jsx("textarea", { title: "JAML IDE Editor", value: text, onChange: (event) => handleTextChange(event.target.value), placeholder: codePlaceholder, spellCheck: false, autoCapitalize: "off", autoCorrect: "off", style: {
160
- width: "100%",
161
- minHeight: 320,
162
- resize: "vertical",
163
- border: 0,
164
- outline: 0,
165
- padding: 16,
166
- background: "transparent",
167
- color: JimboColorOption.WHITE,
168
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
169
- fontSize: 13,
170
- lineHeight: 1.7,
171
- boxSizing: "border-box",
172
- } })) : null, mode === "map" ? _jsx(JamlMapPreview, { jaml: text }) : null, mode === "results" ? (_jsx("div", { style: { padding: 12 }, children: _jsx(ResultsView, { results: results }) })) : null] })] }));
160
+ }, children: [_jsxs("div", { children: [_jsx("div", { style: { fontSize: 14, fontWeight: 800, fontFamily: "m6x11plus, monospace", color: JimboColorOption.GOLD_TEXT }, children: title }), _jsx("div", { style: { fontSize: 11, color: JimboColorOption.GREY }, children: "Jimbo's Ante Markup Language" })] }), actions ? _jsx("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: actions }) : null] }), _jsx(JamlIdeToolbar, { mode: mode, onModeChange: setMode, resultCount: results.length, onSearch: onSearch, isSearching: isSearching }), _jsxs("div", { style: { flex: 1, minHeight: 0, overflow: "auto", background: JimboColorOption.DARKEST }, children: [mode === "visual" ? (_jsx(JamlIdeVisual, { filter: activeFilter, onChange: handleVisualFilterChange })) : null, mode === "code" ? (_jsx(JamlCodeEditor, { value: text, onChange: handleTextChange, placeholder: codePlaceholder })) : null, mode === "map" ? _jsx(JamlMapPreview, { jaml: text }) : null, mode === "results" ? (_jsx("div", { style: { padding: 12 }, children: _jsx(ResultsView, { results: results }) })) : null] })] }));
173
161
  }