create-asciitorium 0.1.46 → 0.1.48

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 (35) hide show
  1. package/dist/templates/base/ASCIITORIUM_REFERENCE.md +45 -30
  2. package/dist/templates/base/public/art/README.md +82 -83
  3. package/dist/templates/base/public/art/fonts/README.md +115 -0
  4. package/dist/templates/base/public/art/maps/README.md +89 -190
  5. package/dist/templates/base/public/art/materials/README.md +82 -206
  6. package/dist/templates/base/public/art/sounds/README.md +11 -0
  7. package/dist/templates/base/public/art/sprites/README.md +138 -0
  8. package/dist/templates/base/src/main.tsx +4 -4
  9. package/dist/templates/base/vite.config.ts +12 -1
  10. package/package.json +1 -1
  11. package/dist/templates/base/public/art/ART-DESIGN-SPEC.md +0 -375
  12. package/dist/templates/base/public/art/font/pencil.art +0 -168
  13. package/dist/templates/base/public/art/maps/example/README.md +0 -62
  14. package/dist/templates/base/public/art/maps/example/legend.json +0 -29
  15. package/dist/templates/base/public/art/maps/example/map.art +0 -21
  16. package/dist/templates/base/public/art/materials/bone.art +0 -11
  17. package/dist/templates/base/public/art/materials/door-wooden.art +0 -154
  18. package/dist/templates/base/public/art/materials/wall-brick.art +0 -128
  19. package/dist/templates/base/public/art/materials/wall-wireframe.art +0 -128
  20. package/dist/templates/base/public/art/sounds/door-close.mp3 +0 -0
  21. package/dist/templates/base/public/art/sounds/door-open.mp3 +0 -0
  22. package/dist/templates/base/public/art/sounds/taps.mp3 +0 -0
  23. package/dist/templates/base/public/art/sprites/asciitorium.art +0 -6
  24. package/dist/templates/base/public/art/sprites/balloon.art +0 -126
  25. package/dist/templates/base/public/art/sprites/beating-heart.art +0 -49
  26. package/dist/templates/base/public/art/sprites/castle.art +0 -4
  27. package/dist/templates/base/public/art/sprites/component-icon.art +0 -6
  28. package/dist/templates/base/public/art/sprites/eyes.art +0 -61
  29. package/dist/templates/base/public/art/sprites/firework.art +0 -58
  30. package/dist/templates/base/public/art/sprites/heart.art +0 -5
  31. package/dist/templates/base/public/art/sprites/multi-select-test.art +0 -6
  32. package/dist/templates/base/public/art/sprites/nav-basics.art +0 -5
  33. package/dist/templates/base/public/art/sprites/pyramid.art +0 -5
  34. package/dist/templates/base/public/art/sprites/welcome.art +0 -7
  35. package/dist/templates/base/src/reference-validation.tsx +0 -307
@@ -246,7 +246,7 @@ align="center" // Alignment (layout-specific)
246
246
 
247
247
  ```tsx
248
248
  <Column align="center" width="100%" gap={2}>
249
- <Art src="logo" />
249
+ <Art sprite="logo" />
250
250
  <Text>Welcome</Text>
251
251
  <Button>Start</Button>
252
252
  </Column>
@@ -808,63 +808,78 @@ const text = new State('initial');
808
808
  ### Basic Usage
809
809
 
810
810
  ```tsx
811
- // Load from file
812
- <Art src="logo" />
813
-
814
- // ASCII art from figlet font
815
- <Art font="standard" text="Hello" />
811
+ // Load sprite from file
812
+ <Art sprite="logo" />
816
813
 
817
814
  // Align center
818
- <Art src="banner" align="center" />
815
+ <Art sprite="banner" align="center" />
819
816
  ```
820
817
 
821
818
  ### Props
822
819
 
823
- | Prop | Type | Default | Description |
824
- | -------- | ------------------------------- | -------- | -------------------------------- |
825
- | `src` | `string` | - | Art file name (from art/ folder) |
826
- | `font` | `string` | - | Figlet font name |
827
- | `text` | `string` | - | Text to render with font |
828
- | `width` | `number \| 'auto'` | `'auto'` | Component width |
829
- | `height` | `number \| 'auto'` | `'auto'` | Component height |
830
- | `align` | `'left' \| 'center' \| 'right'` | `'left'` | Horizontal alignment |
831
- | `border` | `boolean` | `false` | Show border |
820
+ | Prop | Type | Default | Description |
821
+ | -------- | ------------------------------- | -------- | ------------------------------------ |
822
+ | `sprite` | `string` | - | Sprite file name (from art/sprites/) |
823
+ | `width` | `number \| 'auto'` | `'auto'` | Component width |
824
+ | `height` | `number \| 'auto'` | `'auto'` | Component height |
825
+ | `align` | `'left' \| 'center' \| 'right'` | `'left'` | Horizontal alignment |
826
+ | `border` | `boolean` | `false` | Show border |
832
827
 
833
828
  ### Common Patterns
834
829
 
835
- **Pattern 1: Logo from File**
830
+ **Pattern 1: Static Sprite**
836
831
 
837
832
  ```tsx
838
- // Loads from art/logo.art
839
- <Art src="logo" align="center" />
833
+ // Loads from art/sprites/logo.art
834
+ <Art sprite="logo" align="center" />
840
835
  ```
841
836
 
842
- **Pattern 2: Generated ASCII Text**
837
+ **Pattern 2: Animated Sprite**
843
838
 
844
839
  ```tsx
845
- <Art font="standard" text="Game Over" align="center" />
840
+ // Loads animated art (auto-plays)
841
+ <Art sprite="beating-heart" width={20} />
846
842
  ```
847
843
 
848
- **Pattern 3: Animated Sprite**
844
+
845
+
846
+ ## Banner
847
+
848
+ ### Basic Usage
849
849
 
850
850
  ```tsx
851
- // Loads animated art (auto-plays)
852
- <Art src="beating-heart" width={20} />
851
+ // Render text with font
852
+ <Banner font="standard" text="Hello" />
853
+
854
+ // Align center
855
+ <Banner font="shadows" text="Game Over" align="center" />
853
856
  ```
854
857
 
855
- ### Common Mistakes
858
+ ### Props
856
859
 
857
- **WRONG** - Using both src and font
860
+ | Prop | Type | Default | Description |
861
+ | --------------- | ------------------------------- | -------- | --------------------------------- |
862
+ | `font` | `string` | - | Font name (from art/fonts/) |
863
+ | `text` | `string \| State<string>` | - | Text to render with font |
864
+ | `letterSpacing` | `number` | `0` | Additional spacing between chars |
865
+ | `width` | `number \| 'auto'` | `'auto'` | Component width |
866
+ | `height` | `number \| 'auto'` | `'auto'` | Component height |
867
+ | `align` | `'left' \| 'center' \| 'right'` | `'left'` | Horizontal alignment |
868
+ | `border` | `boolean` | `false` | Show border |
869
+
870
+ ### Common Patterns
871
+
872
+ **Pattern 1: Title Screen**
858
873
 
859
874
  ```tsx
860
- <Art src="logo" font="standard" /> // Conflicting props
875
+ <Banner font="shadows" text="asciitorium" align="center" />
861
876
  ```
862
877
 
863
- **CORRECT** - Use one or the other
878
+ **Pattern 2: Reactive Text**
864
879
 
865
880
  ```tsx
866
- <Art src="logo" /> // From file
867
- <Art font="standard" text="Title" /> // Generated
881
+ const score = new State(0);
882
+ <Banner font="pixel" text={score} letterSpacing={1} />
868
883
  ```
869
884
 
870
885
 
@@ -1,115 +1,114 @@
1
1
  # Art Directory
2
2
 
3
- This directory contains ASCII art assets for a project. It is organized into subfolders for maps, materials, and sprites. Each file uses plain text or JSON for easy editing and integration.
3
+ This directory contains asciitorium art assets for the asciitorium framework. They are organized into categories: fonts, maps, materials, sounds, and sprites.
4
4
 
5
- ## Asset Loading and Caching
5
+ ## Asset Resolution and Library Assets
6
6
 
7
- **IMPORTANT:** All assets are automatically loaded and cached by `AssetManager` using reactive `State` objects. When developing components that use assets:
7
+ The asciitorium framework uses a **fallback resolution system** for assets:
8
8
 
9
- ### For Component Developers
9
+ 1. **Project Assets First**: `public/art/{type}/{name}.art` in your project
10
+ 2. **Library Assets Fallback**: `node_modules/asciitorium/public/art/{type}/{name}.art`
10
11
 
11
- **✅ DO:**
12
- - Use `AssetManager.getMapState(name)` to get a reactive State for maps
13
- - Use `AssetManager.getMaterialState(name)` to get a reactive State for materials
14
- - Subscribe to the returned State to react to loading completion or changes
15
- - Use `GameWorld.getMapState()` when working with GameWorld instances
16
- - Share State references across components - the cache handles deduplication
12
+ This means you automatically have access to all library assets without copying them!
17
13
 
18
- **❌ DON'T:**
19
- - Create local caches in components (Map, Set, plain objects)
20
- - Use the legacy non-reactive methods (`getMap()`, `getMaterial()`) for new code
21
- - Load the same asset multiple times - AssetManager caches automatically
22
- - Store asset data in component properties - subscribe to State instead
14
+ ### Using Library Assets
23
15
 
24
- ### Example Usage
16
+ The asciitorium library includes starter assets:
17
+
18
+ **Materials**: `wall-brick`, `wall-wireframe`, `bone`, `door-wooden`
19
+ **Sprites**: `beating-heart`, `balloon`, `castle`, `eyes`, `firework`, `heart`, `pyramid`, `welcome`, and more
20
+ **Fonts**: `marker`, `pencil`, `pixel`, `shadows`
21
+ **Maps**: `example` (with legend)
22
+ **Sounds**: `door-open.mp3`, `door-close.mp3`, `taps.mp3`
23
+
24
+ Simply reference them by name - no need to copy files:
25
25
 
26
26
  ```typescript
27
- // Correct: Use reactive State from AssetManager
28
- const materialState = AssetManager.getMaterialState('brick-wall');
29
-
30
- // Subscribe to get the value when loaded
31
- materialState.subscribe((material) => {
32
- if (material) {
33
- // Material is loaded, use it
34
- console.log('Material loaded:', material);
35
- }
36
- });
37
-
38
- // Check current value (may be null if still loading)
39
- if (materialState.value) {
40
- // Material already loaded from cache
41
- }
42
-
43
- // ✅ Correct: GameWorld automatically uses AssetManager's State cache
44
- const gameWorld = new GameWorld({ mapName: 'dungeon' });
45
- gameWorld.getMapState().subscribe((mapAsset) => {
46
- // Automatically updates when map loads
47
- });
48
-
49
- // ❌ Wrong: Don't create your own cache
50
- class MyComponent {
51
- private myCache: Map<string, Material> = new Map(); // DON'T DO THIS!
52
- }
27
+ import { AssetManager, Art, Banner } from 'asciitorium';
28
+
29
+ // Use library sprite
30
+ <Art sprite="beating-heart" />
31
+
32
+ // Use library font
33
+ <Banner font="shadows" text="Hello" />
34
+
35
+ // Use library material (in map legend)
36
+ const materialAsset = await AssetManager.getMaterial('wall-brick');
53
37
  ```
54
38
 
55
- ### Architecture Benefits
39
+ ### Customizing Assets
56
40
 
57
- - **Single source of truth**: AssetManager is the only cache
58
- - **Automatic updates**: Components react when assets load or change
59
- - **Memory efficient**: One copy of each asset shared across all components
60
- - **Hot-reload ready**: Asset changes propagate automatically to all subscribers
61
- - **No manual cache management**: State handles all invalidation and updates
41
+ **To use library asset as-is**: Just reference it by name (nothing to do!)
62
42
 
63
- ## Directory Structure
43
+ **To customize a library asset**:
44
+ 1. Copy the asset from `node_modules/asciitorium/public/art/{type}/{name}.art`
45
+ 2. Paste into your project's `public/art/{type}/{name}.art`
46
+ 3. Edit as desired
47
+ 4. Your version now takes precedence over the library version
48
+
49
+ **To create custom assets**:
50
+ 1. Create a new `.art` file in `public/art/{type}/{custom-name}.art`
51
+ 2. Follow the format documented in the type-specific README
52
+ 3. Reference by name in your code
64
53
 
54
+ ### Asset Updates
55
+
56
+ When you run `npm update asciitorium`:
57
+ - Library assets are automatically updated in `node_modules/asciitorium/public/art/`
58
+ - Your project assets in `public/art/` are never touched
59
+ - Any library assets you haven't overridden get the latest improvements
60
+ - Any assets you've copied to your project stay as-is (your responsibility to update)
61
+
62
+ **Best Practice**: Only copy library assets to your project if you need to customize them. Use library assets directly whenever possible to benefit from automatic updates.
63
+
64
+ ### Listing Available Library Assets
65
+
66
+ To see all available library assets, check:
65
67
  ```bash
66
- public/art/
67
- ├─ maps/
68
- └─ example/
69
- ├─ map.art
70
- └─ legend.json
71
-
72
- ├─ materials/
73
- │ ├─ brick-wall.art
74
- │ └─ wooden-door.art
75
-
76
- ├─ sprites/
77
- ├─ giant-rat.art
78
- └─ wolf.art
68
+ ls node_modules/asciitorium/public/art/materials/
69
+ ls node_modules/asciitorium/public/art/sprites/
70
+ ls node_modules/asciitorium/public/art/fonts/
71
+ ls node_modules/asciitorium/public/art/maps/
72
+ ls node_modules/asciitorium/public/art/sounds/
79
73
  ```
80
74
 
81
- ## maps/
75
+ Or view the latest assets in the [asciitorium repository](https://github.com/tgruby/asciitorium/tree/main/packages/asciitorium/public/art).
82
76
 
83
- Contains map layouts and legends for game environments. Maps are typically stored as text files with ASCII characters representing different terrain types, while legend files (JSON format) define what each character represents, including visual assets, collision properties, and gameplay entity types.
77
+ ## Asset Loading
84
78
 
85
- **Contents:**
79
+ Assets are automatically loaded and cached by `AssetManager` using reactive
80
+ `State` objects. The AssetManager provides a single source of truth with
81
+ automatic caching and updates.
86
82
 
87
- - `example/` - Sample map directory containing:
88
- - `map.art` - ASCII representation of the map layout
89
- - `legend.json` - Character-to-entity mapping with visual assets, collision, and behavior definitions
83
+ ## Directory Structure
84
+
85
+ ``` bash
86
+ art/
87
+ ├── fonts/ # ASCII font definitions
88
+ ├── maps/ # Game map layouts with legends
89
+ ├── materials/ # Wall textures and environmental materials
90
+ ├── sounds/ # Audio files (MP3)
91
+ └── sprites/ # Animated character and object sprites
92
+ ```
90
93
 
91
- See [maps/README.md](maps/README.md) for detailed information on map file format, legend properties, and the entity/variant system.
94
+ ## Subdirectories
92
95
 
93
- ## materials/
96
+ ### [fonts/](fonts/README.md)
94
97
 
95
- Includes ASCII representations of various materials and textures that can be used in game environments. Materials define layered visual representations at different distances (here, near, middle, far) and can include proximity-based sound effects and ambient events.
98
+ ASCII font definitions for `Banner` component rendering. See the fonts README for file format details.
96
99
 
97
- **Contents:**
100
+ ### [maps/](maps/README.md)
98
101
 
99
- - `brick-wall.art` - ASCII pattern for brick wall textures
100
- - `bone.art` - Ground-placed bone material with placement metadata
101
- - `door-on-brick.art` - Door material overlaid on brick wall background
102
- - `wireframe-wall.art` - Complex wireframe demonstrating layered perspective rendering
102
+ Map layouts paired with legend metadata define the position of terrain and entities. See the maps README for format specifications and the entity system.
103
103
 
104
- See [materials/README.md](materials/README.md) for detailed information on material file format, layer system, placement properties, and the relationship between materials and legend entities.
104
+ ### [materials/](materials/README.md)
105
105
 
106
- ## sprites/
106
+ Materials are used for `FirstPersonView` textures with layered depth rendering (here, near, middle, far). Materials can include placement metadata and sound effects. See the materials README for layer syntax and properties.
107
107
 
108
- Stores animated sprite files for characters, creatures, and other game entities. Sprites support multiple frames with configurable timing and can be referenced by legend entities for dynamic visual representation.
108
+ ### [sounds/](sounds/README.md)
109
109
 
110
- **Contents:**
110
+ Audio files in MP3 format used throughout the application. See the sounds README for usage details.
111
111
 
112
- - `giant-rat.art` - ASCII sprite for giant rat creature
113
- - `wolf.art` - ASCII sprite for wolf creature
112
+ ### [sprites/](sprites/README.md)
114
113
 
115
- Sprites are referenced in map legends via the `asset` property and can be combined with entity types to define interactive game objects.
114
+ Static or animated ASCII art with frame timing are in the sprites directory. They can be added using the `Art` component. See the sprites README for animation format details.
@@ -0,0 +1,115 @@
1
+ # Asciitorium Fonts
2
+
3
+ > **Note**: This directory is empty by default. The asciitorium library includes starter assets in `node_modules/asciitorium/public/art/fonts/` that are automatically available without copying. See the main [art/README.md](../README.md) for details on using and customizing library assets.
4
+
5
+ This directory contains ASCII font files for the **Banner** component. Fonts
6
+ allow you to display large, stylized text using ASCII art characters.
7
+
8
+ ## Font File Format
9
+
10
+ Font files use the `.art` extension and follow a structured format with metadata
11
+ separators:
12
+
13
+ ### File Structure
14
+
15
+ ``` txt
16
+ § {"kind":"font"}
17
+ ¶ {"character":"A"}
18
+ ╭─╮
19
+ │ │
20
+ ├─┤
21
+ ╵ ╵
22
+
23
+ ¶ {"character":"a"}
24
+
25
+ ╭─╮
26
+ ╭─┤
27
+ ╰─╰
28
+
29
+ ¶ {"character":["b", "B"]}
30
+
31
+ ├─╮
32
+ │ │
33
+ ╯─╯
34
+ ```
35
+
36
+ ### Key Components
37
+
38
+ 1. **File Header** (`§` separator)
39
+ - Must start with `§ {"kind":"font"}`
40
+ - Indicates this is a font asset
41
+
42
+ 2. **Glyph Sections** (`¶` separator)
43
+ - Each glyph begins with `¶ {"character":"x"}` where `x` is the character
44
+ - Character can be a single string: `"a"`
45
+ - Or an array for multiple mappings: `["b", "B"]` (both lowercase and
46
+ uppercase)
47
+ - Glyph content follows immediately after the metadata line
48
+
49
+ 3. **Glyph Content**
50
+ - ASCII art representation of the character
51
+ - Each glyph can be any width/height
52
+ - Vertical positioning is preserved (blank lines matter!)
53
+ - Maximum font height is determined by the tallest glyph
54
+
55
+ **Tips:**
56
+
57
+ - Empty lines within glyphs are preserved to maintain vertical alignment
58
+ - The first line after the glyph metadata is part of the character (no automatic
59
+ trimming)
60
+ - Map multiple characters to the same glyph using arrays:
61
+ `{"character":["a","A"]}`
62
+ - All glyphs should have consistent height for best results (pad with empty
63
+ lines if needed)
64
+
65
+ ## Using Fonts in Your App
66
+
67
+ ### Basic Usage
68
+
69
+ ```tsx
70
+ <Banner font="pencil" text="asciitorium" />
71
+ ```
72
+
73
+ ### With Letter Spacing
74
+
75
+ ```tsx
76
+ <Banner font="marker" text="HELLO" letterSpacing={1} />
77
+ ```
78
+
79
+ ### With Reactive State
80
+
81
+ ```tsx
82
+ import { State } from 'asciitorium';
83
+
84
+ const titleText = new State<string>("Welcome");
85
+
86
+ <Banner font="shadows" text={titleText} align="center" />
87
+ ```
88
+
89
+ ### Available Props
90
+
91
+ - `font` (required): Name of the font file (without `.art` extension)
92
+ - `text`: String or `State<string>` to render
93
+ - `letterSpacing`: Additional spacing between characters (default: 0)
94
+ - Plus all standard component props: `position`, `border`, `align`, `style`,
95
+ etc.
96
+
97
+ ## Technical Details
98
+
99
+ ### Loading
100
+
101
+ Fonts are loaded asynchronously via the `AssetManager`:
102
+
103
+ ```typescript
104
+ const fontAsset = await AssetManager.getFont('myfont');
105
+ ```
106
+
107
+ ### Caching
108
+
109
+ Font assets are cached on first load - subsequent uses of the same font reuse
110
+ the cached data.
111
+
112
+ ### Fallback Rendering
113
+
114
+ If a character is not found in the font, the Banner component renders the
115
+ character itself as a single-width glyph on the top line.