ascii-things 0.0.0-stage → 1.0.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 (164) hide show
  1. package/LICENSE +21 -0
  2. package/MIGRATION.md +249 -0
  3. package/NOTICE +11 -0
  4. package/README.md +985 -2
  5. package/dist/ants.d.ts +19 -0
  6. package/dist/ants.js +2 -0
  7. package/dist/ants.js.map +1 -0
  8. package/dist/chunk-32ZC7XXT.js +2 -0
  9. package/dist/chunk-32ZC7XXT.js.map +1 -0
  10. package/dist/chunk-3O4YNUUM.js +2 -0
  11. package/dist/chunk-3O4YNUUM.js.map +1 -0
  12. package/dist/chunk-4F2MKE5K.js +2 -0
  13. package/dist/chunk-4F2MKE5K.js.map +1 -0
  14. package/dist/chunk-5FCF3R4B.js +2 -0
  15. package/dist/chunk-5FCF3R4B.js.map +1 -0
  16. package/dist/chunk-5XGN7UAV.js +2 -0
  17. package/dist/chunk-5XGN7UAV.js.map +1 -0
  18. package/dist/chunk-6S5JLIAV.js +1 -0
  19. package/dist/chunk-6S5JLIAV.js.map +1 -0
  20. package/dist/chunk-77QBCK4K.js +2 -0
  21. package/dist/chunk-77QBCK4K.js.map +1 -0
  22. package/dist/chunk-7JNZTQKH.js +2 -0
  23. package/dist/chunk-7JNZTQKH.js.map +1 -0
  24. package/dist/chunk-BENX7EUO.js +2 -0
  25. package/dist/chunk-BENX7EUO.js.map +1 -0
  26. package/dist/chunk-DTHJUH5D.js +2 -0
  27. package/dist/chunk-DTHJUH5D.js.map +1 -0
  28. package/dist/chunk-EBKTOUAL.js +2 -0
  29. package/dist/chunk-EBKTOUAL.js.map +1 -0
  30. package/dist/chunk-EQEYQLJH.js +1 -0
  31. package/dist/chunk-EQEYQLJH.js.map +1 -0
  32. package/dist/chunk-F4EYKBHM.js +1 -0
  33. package/dist/chunk-F4EYKBHM.js.map +1 -0
  34. package/dist/chunk-JCUPHORL.js +2 -0
  35. package/dist/chunk-JCUPHORL.js.map +1 -0
  36. package/dist/chunk-JR6CTL7L.js +2 -0
  37. package/dist/chunk-JR6CTL7L.js.map +1 -0
  38. package/dist/chunk-NVD6PC7T.js +2 -0
  39. package/dist/chunk-NVD6PC7T.js.map +1 -0
  40. package/dist/chunk-OMCXFXIR.js +459 -0
  41. package/dist/chunk-OMCXFXIR.js.map +1 -0
  42. package/dist/chunk-RQMHYZD3.js +2 -0
  43. package/dist/chunk-RQMHYZD3.js.map +1 -0
  44. package/dist/chunk-S6UKFA3Q.js +4 -0
  45. package/dist/chunk-S6UKFA3Q.js.map +1 -0
  46. package/dist/chunk-URLVTEFL.js +2 -0
  47. package/dist/chunk-URLVTEFL.js.map +1 -0
  48. package/dist/chunk-XCA6CK56.js +2 -0
  49. package/dist/chunk-XCA6CK56.js.map +1 -0
  50. package/dist/chunk-XTFRZHOS.js +1 -0
  51. package/dist/chunk-XTFRZHOS.js.map +1 -0
  52. package/dist/chunk-YZIICIA7.js +2 -0
  53. package/dist/chunk-YZIICIA7.js.map +1 -0
  54. package/dist/chunk-ZIWM52UK.js +2 -0
  55. package/dist/chunk-ZIWM52UK.js.map +1 -0
  56. package/dist/city.d.ts +19 -0
  57. package/dist/city.js +2 -0
  58. package/dist/city.js.map +1 -0
  59. package/dist/core-react.d.ts +25 -0
  60. package/dist/core-react.js +2 -0
  61. package/dist/core-react.js.map +1 -0
  62. package/dist/core.d.ts +41 -0
  63. package/dist/core.js +2 -0
  64. package/dist/core.js.map +1 -0
  65. package/dist/dither-element.d.ts +21 -0
  66. package/dist/dither-element.js +2 -0
  67. package/dist/dither-element.js.map +1 -0
  68. package/dist/dither-react.d.ts +20 -0
  69. package/dist/dither-react.js +2 -0
  70. package/dist/dither-react.js.map +1 -0
  71. package/dist/dither.d.ts +84 -0
  72. package/dist/dither.js +2 -0
  73. package/dist/dither.js.map +1 -0
  74. package/dist/dog.d.ts +41 -0
  75. package/dist/dog.js +2 -0
  76. package/dist/dog.js.map +1 -0
  77. package/dist/element.d.ts +168 -0
  78. package/dist/element.js +8 -0
  79. package/dist/element.js.map +1 -0
  80. package/dist/engine-Bq8gMSQm.d.ts +11 -0
  81. package/dist/engine-BqAEaQLl.d.ts +29 -0
  82. package/dist/engine-CtkS480M.d.ts +11 -0
  83. package/dist/engine-DBOMhTS0.d.ts +11 -0
  84. package/dist/engine-DLM4B-W8.d.ts +11 -0
  85. package/dist/engine-MhOJLNlx.d.ts +11 -0
  86. package/dist/engine-UgaNbhyJ.d.ts +11 -0
  87. package/dist/engine-YMub_Kvu.d.ts +232 -0
  88. package/dist/engine-hLtoRpjI.d.ts +46 -0
  89. package/dist/engine-krPys4Wy.d.ts +43 -0
  90. package/dist/engine-pzotIzS_.d.ts +45 -0
  91. package/dist/engine-tG50-GPi.d.ts +46 -0
  92. package/dist/fireflies.d.ts +19 -0
  93. package/dist/fireflies.js +2 -0
  94. package/dist/fireflies.js.map +1 -0
  95. package/dist/grid-CI2dvWp5.d.ts +62 -0
  96. package/dist/image-element.d.ts +19 -0
  97. package/dist/image-element.js +5 -0
  98. package/dist/image-element.js.map +1 -0
  99. package/dist/image-react.d.ts +18 -0
  100. package/dist/image-react.js +2 -0
  101. package/dist/image-react.js.map +1 -0
  102. package/dist/image.d.ts +53 -0
  103. package/dist/image.js +2 -0
  104. package/dist/image.js.map +1 -0
  105. package/dist/index.d.ts +40 -0
  106. package/dist/index.js +2 -0
  107. package/dist/index.js.map +1 -0
  108. package/dist/jellyfish.d.ts +39 -0
  109. package/dist/jellyfish.js +2 -0
  110. package/dist/jellyfish.js.map +1 -0
  111. package/dist/koi.d.ts +19 -0
  112. package/dist/koi.js +2 -0
  113. package/dist/koi.js.map +1 -0
  114. package/dist/lagoon.d.ts +15 -0
  115. package/dist/lagoon.js +2 -0
  116. package/dist/lagoon.js.map +1 -0
  117. package/dist/options-B47cv7lv.d.ts +6 -0
  118. package/dist/options-B6NScoKH.d.ts +6 -0
  119. package/dist/options-BBDYdFml.d.ts +21 -0
  120. package/dist/options-Be3UhUBN.d.ts +6 -0
  121. package/dist/options-BhwqiHlq.d.ts +193 -0
  122. package/dist/options-BxpXlomj.d.ts +150 -0
  123. package/dist/options-C1h2jdKY.d.ts +141 -0
  124. package/dist/options-C5Gw3rMc.d.ts +6 -0
  125. package/dist/options-Dk4czW33.d.ts +170 -0
  126. package/dist/options-UESOnDM5.d.ts +6 -0
  127. package/dist/options-knGG2iXD.d.ts +6 -0
  128. package/dist/options-mA4O7qzW.d.ts +27 -0
  129. package/dist/palette-DNwp3W5f.d.ts +32 -0
  130. package/dist/react.d.ts +152 -0
  131. package/dist/react.js +2 -0
  132. package/dist/react.js.map +1 -0
  133. package/dist/rendering.d.ts +24 -0
  134. package/dist/rendering.js +2 -0
  135. package/dist/rendering.js.map +1 -0
  136. package/dist/rng-KMb93uev.d.ts +16 -0
  137. package/dist/robots.d.ts +33 -0
  138. package/dist/robots.js +2 -0
  139. package/dist/robots.js.map +1 -0
  140. package/dist/runtime-BY09iO9D.d.ts +142 -0
  141. package/dist/scene-ywOYwjHq.d.ts +56 -0
  142. package/dist/servers.d.ts +19 -0
  143. package/dist/servers.js +2 -0
  144. package/dist/servers.js.map +1 -0
  145. package/dist/sharks.d.ts +116 -0
  146. package/dist/sharks.js +2 -0
  147. package/dist/sharks.js.map +1 -0
  148. package/dist/starlings.d.ts +19 -0
  149. package/dist/starlings.js +2 -0
  150. package/dist/starlings.js.map +1 -0
  151. package/dist/ui.css +894 -0
  152. package/dist/ui.d.ts +201 -0
  153. package/dist/ui.js +2 -0
  154. package/dist/ui.js.map +1 -0
  155. package/dist/webgl-element.d.ts +21 -0
  156. package/dist/webgl-element.js +2 -0
  157. package/dist/webgl-element.js.map +1 -0
  158. package/dist/webgl-react.d.ts +21 -0
  159. package/dist/webgl-react.js +2 -0
  160. package/dist/webgl-react.js.map +1 -0
  161. package/dist/webgl.d.ts +127 -0
  162. package/dist/webgl.js +2 -0
  163. package/dist/webgl.js.map +1 -0
  164. package/package.json +230 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ascii-things contributors
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/MIGRATION.md ADDED
@@ -0,0 +1,249 @@
1
+ # Migrating to ascii-things 1.0
2
+
3
+ **Status: release candidate (`1.0.0-rc.0`).** 1.0.0 has not been published.
4
+ `0.5.0` is the baseline for this guide.
5
+
6
+ 1.0 freezes the public API described here. The goal is a boring upgrade: if you
7
+ only use documented exports, moving from `0.5.0` to `1.0.0` should not require
8
+ code changes.
9
+
10
+ ## Compatibility promise
11
+
12
+ - The package follows semantic versioning after `1.0.0`.
13
+ - Public JavaScript exports, type exports, package subpaths, and documented
14
+ attributes/props are covered by the freeze.
15
+ - Breaking changes require a major release.
16
+ - Deprecations are announced in a minor release and remain available until the
17
+ next major release.
18
+ - Modules under `src/` that are not listed in the public surface table are
19
+ implementation details. Importing them is unsupported, even if a bundler can
20
+ resolve them.
21
+ - Building from source requires Node 22 or newer. The browser runtime has no
22
+ Node dependency.
23
+
24
+ ## Upgrade checklist
25
+
26
+ 1. Install the new version:
27
+
28
+ ```sh
29
+ npm install ascii-things@1
30
+ ```
31
+
32
+ 2. If you use the React UI layer, keep the stylesheet import:
33
+
34
+ ```ts
35
+ import "ascii-things/ui.css";
36
+ ```
37
+
38
+ 3. Remove any workarounds that assumed `onReady`, `paused`, `fontFamily`,
39
+ `aspectRatio`, `palette="auto"`, or `trigger()` were unavailable.
40
+ 4. Re-run your own tests, especially anything that snapshots canvas markup or
41
+ asserts the old 0.4 limitations.
42
+
43
+ There are no required API migrations from `0.5.0` to `1.0.0`.
44
+
45
+ ## Shared scene API
46
+
47
+ Every scene returns an engine that implements `SceneHandle`:
48
+
49
+ ```ts
50
+ import { createDog } from "ascii-things/dog";
51
+
52
+ const canvas = document.querySelector("canvas")!;
53
+ const scene = createDog(canvas, {
54
+ palette: "auto",
55
+ seed: 7,
56
+ paused: true,
57
+ });
58
+
59
+ scene.resume();
60
+ scene.setOptions({ calm: true });
61
+ scene.trigger("throwBall", canvas.clientWidth * 0.6, canvas.clientHeight * 0.6);
62
+
63
+ const stats = scene.getStats();
64
+ console.log(stats.fps, stats.cells);
65
+
66
+ scene.destroy();
67
+ ```
68
+
69
+ ```ts
70
+ interface SceneHandle<S extends SceneStats = SceneStats> {
71
+ pause(): void;
72
+ resume(): void;
73
+ resize(): void;
74
+ setOptions(options: Partial<SceneOptions>): void;
75
+ trigger(action: SceneAction, x: number, y: number): void;
76
+ getStats(): S;
77
+ destroy(): void;
78
+ }
79
+ ```
80
+
81
+ `SceneOptions` covers the shared controls: `seed`, `columns`, `speed`,
82
+ `interactive`, `maxDpr`, `maxCells`, `adaptiveQuality`, `calm`, `palette`,
83
+ `label`, `paused`, and `fontFamily`. Scene-specific options such as rosters,
84
+ counts, scales, and `spread` remain on each scene's options type.
85
+
86
+ ## Signature actions
87
+
88
+ Each scene has one named action and also accepts the shared `trigger()` call.
89
+
90
+ | Scene | Named action | `trigger()` name |
91
+ | --- | --- | --- |
92
+ | Sharks | `splash(x, y)` | `"splash"` |
93
+ | Robots | `dispatch(x, y)` | `"dispatch"` |
94
+ | Jellyfish | `shockwave(x, y)` | `"shockwave"` |
95
+ | Robot dog | `throwBall(x, y)` | `"throwBall"` |
96
+
97
+ Coordinates are canvas-local CSS pixels. `trigger()` ignores action names that
98
+ do not belong to that scene. Pointer clicks invoke the same action when
99
+ `interactive` is enabled.
100
+
101
+ ## Palettes
102
+
103
+ ```ts
104
+ import type { PaletteChoice } from "ascii-things";
105
+
106
+ const palette: PaletteChoice = "auto";
107
+ ```
108
+
109
+ `PaletteChoice` is a palette name, a full custom `Palette`, or `"auto"`.
110
+ `"auto"` resolves to `paper` when the host prefers a light colour scheme and
111
+ `abyss` otherwise. During SSR it resolves to `abyss`.
112
+
113
+ The automatic choice is resolved when applied, not through a live media-query
114
+ subscription. Call `setOptions({ palette: "auto" })` after a theme change if you
115
+ want the scene to re-resolve it.
116
+
117
+ ## React
118
+
119
+ The React adapters are exported from `ascii-things/react`:
120
+
121
+ ```tsx
122
+ import { AsciiDog } from "ascii-things/react";
123
+ import type { SceneHandle } from "ascii-things";
124
+
125
+ export function Hero() {
126
+ return (
127
+ <AsciiDog
128
+ palette="auto"
129
+ seed={7}
130
+ aspectRatio="4 / 3"
131
+ paused={false}
132
+ onReady={(scene: SceneHandle) => {
133
+ scene.trigger("throwBall", 320, 220);
134
+ }}
135
+ />
136
+ );
137
+ }
138
+ ```
139
+
140
+ - `onReady(scene)` provides the imperative handle after each engine mount.
141
+ - `id`, `className`, `style`, `width`, `height`, and `aspectRatio` are
142
+ forwarded.
143
+ - Arbitrary `ref`, `aria-*`, and `data-*` forwarding is not part of the 1.0
144
+ contract. Put those on a wrapper element instead.
145
+ - `paused` and `fontFamily` are live options; changing them updates the engine.
146
+ - The component renders a canvas during SSR but creates the engine in an
147
+ effect. Canvas work never runs on the server.
148
+
149
+ ## Custom elements
150
+
151
+ Import the registration module once on the client:
152
+
153
+ ```ts
154
+ import "ascii-things/element";
155
+ ```
156
+
157
+ ```html
158
+ <ascii-dog
159
+ palette="auto"
160
+ aspect-ratio="4 / 3"
161
+ paused
162
+ font-family="ui-monospace, monospace"
163
+ label="A live ASCII robot dog test yard"
164
+ ></ascii-dog>
165
+ ```
166
+
167
+ The `ascii-ready` event is bubbling and composed. It carries the live handle:
168
+
169
+ ```ts
170
+ document.querySelector("ascii-dog")?.addEventListener("ascii-ready", (event) => {
171
+ const scene = (event as CustomEvent).detail.scene;
172
+ scene.trigger("throwBall", 320, 220);
173
+ });
174
+ ```
175
+
176
+ The event fires during mount, so attach the listener before appending the
177
+ element if you need to catch the first mount. Attribute changes remount the
178
+ engine.
179
+
180
+ ## UI layer
181
+
182
+ The optional UI layer is plain React and plain CSS:
183
+
184
+ ```tsx
185
+ import {
186
+ AsciiStage,
187
+ AsciiPrompt,
188
+ AsciiReadout,
189
+ AsciiSceneTabs,
190
+ AsciiDogHero,
191
+ } from "ascii-things/ui";
192
+ import "ascii-things/ui.css";
193
+ ```
194
+
195
+ It has no Tailwind requirement and no runtime dependency beyond React. Style it
196
+ with the `--ascii-*` custom properties documented in the UI guide.
197
+
198
+ ## Public surface
199
+
200
+ Runtime exports are frozen by `src/api.test.ts`. Type exports are part of the
201
+ same contract.
202
+
203
+ | Entry | Runtime exports | Key types |
204
+ | --- | --- | --- |
205
+ | `ascii-things` | `createSharks`, `createRobots`, `createJellyfish`, `createDog`, engines, renderers, worlds, palettes, helpers | `SceneOptions`, `SceneStats`, `SceneHandle`, `SceneAction`, `SceneReady`, scene option types |
206
+ | `ascii-things/sharks` | `createSharks`, `OceanEngine`, `World`, `AsciiRenderer`, palette/RNG/grid helpers | `AsciiSharksOptions`, `OceanStats`, `Palette`, `PaletteChoice` |
207
+ | `ascii-things/robots` | `createRobots`, `RobotEngine`, `RobotWorld`, `RobotRenderer` | `AsciiRobotsOptions`, `RobotStats` |
208
+ | `ascii-things/jellyfish` | `createJellyfish`, `JellyfishEngine`, `JellyfishWorld`, `JellyfishRenderer` | `AsciiJellyfishOptions`, `JellyfishStats` |
209
+ | `ascii-things/dog` | `createDog`, `DogEngine`, `DogWorld`, `DogRenderer` | `AsciiDogOptions`, `DogStats` |
210
+ | `ascii-things/starlings`, `ascii-things/fireflies`, `ascii-things/ants`, `ascii-things/koi`, `ascii-things/city`, `ascii-things/servers` | `createStarlings`, `createFireflies`, `createAnts`, `createKoi`, `createCity`, `createServers` and their engines, worlds, and renderers | ambient option and stats types |
211
+ | `ascii-things/image` | `imageToAscii`, `pixelsToAscii`, `renderAsciiImage`, `ASCII_CHARSETS` | `AsciiImageOptions`, `AsciiImageResult`, `AsciiImageSource`, `AsciiImageCharset` |
212
+ | `ascii-things/image/react` | `AsciiImage` | `AsciiImageProps` |
213
+ | `ascii-things/image/element` | `AsciiImageElement` | custom-element detail types |
214
+ | `ascii-things/dither` | `DitherField`, `ditherThreshold`, `shouldDither`, `DITHER_MATRICES`, `DITHER_DEFAULTS` | `DitherFieldOptions`, `DitherMatrixName` |
215
+ | `ascii-things/dither/react` | `AsciiDither` | `AsciiDitherProps` |
216
+ | `ascii-things/dither/element` | `AsciiDitherElement` | custom-element attributes |
217
+ | `ascii-things/webgl` | `AsciiSurfaceEngine`, `resolveGlyphs`, `glyphIndex`, `parseColor`, `surfaceCell`, `SURFACE_DEFAULTS` | `AsciiSurfaceOptions` |
218
+ | `ascii-things/webgl/react` | `AsciiSurface` | `AsciiSurfaceProps` |
219
+ | `ascii-things/webgl/element` | `AsciiSurfaceElement` | custom-element attributes |
220
+ | `ascii-things/react` | `AsciiSharks`, `AsciiRobots`, `AsciiJellyfish`, `AsciiDog`, `AsciiOcean` | component prop types |
221
+ | `ascii-things/element` | `AsciiSharksElement`, `AsciiRobotsElement`, `AsciiJellyfishElement`, `AsciiDogElement` | custom-element detail types |
222
+ | `ascii-things/ui` | `AsciiStage`, `AsciiPrompt`, `AsciiReadout`, `AsciiSceneTabs`, `AsciiDogHero` | UI prop types |
223
+ | `ascii-things/ui.css` | stylesheet | CSS variables |
224
+
225
+ ## SSR notes
226
+
227
+ - `ascii-things/react` and `ascii-things/ui` are safe to import and render on
228
+ the server. They emit static markup and do not touch `window`.
229
+ - Engines and custom elements require a browser environment. Register custom
230
+ elements only in client code.
231
+ - `palette="auto"` falls back to `abyss` during SSR, so the first client render
232
+ can differ if the host prefers light mode. Set an explicit palette if the
233
+ server and client markup must match exactly.
234
+ - Use `onReady` or `ascii-ready` rather than reaching into a canvas after
235
+ hydration.
236
+
237
+ ## 1.0 release gates
238
+
239
+ - [x] Public runtime export snapshot for every entrypoint.
240
+ - [x] Server-render smoke tests for React and UI components.
241
+ - [x] Shared API, actions, palettes, and composition props documented.
242
+ - [x] Final accessibility and SSR audit pass.
243
+ - [x] `npm run check:all` and `npm run test:e2e`.
244
+ - [x] Docs build and migration guide included in the tarball.
245
+ - [x] Clean-install smoke test from `npm pack`.
246
+ - [ ] Version, changelog, and release notes approved.
247
+
248
+ Until those gates are complete, treat this document and the package as a
249
+ release candidate, not a published 1.0.
package/NOTICE ADDED
@@ -0,0 +1,11 @@
1
+ ascii-things
2
+
3
+ Copyright (c) 2026 ascii-things contributors
4
+
5
+ This project is derived from ascii-sharks by stackedlol
6
+ (https://github.com/stackedlol/ascii-sharks). The original shark simulation and
7
+ procedural ASCII rendering are by the original author. ascii-things adds the
8
+ library API, packaging, palettes, seeded worlds, accessibility options,
9
+ framework adapters, and the robot scene.
10
+
11
+ Licensed under the MIT License. See LICENSE.