asciify-engine 4.12.1 → 4.13.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.
- package/README.md +17 -1
- package/dist/kit.cjs +1 -0
- package/dist/kit.d.cts +907 -0
- package/dist/kit.d.ts +907 -0
- package/dist/kit.js +1 -0
- package/package.json +11 -1
- package/skills/asciify-engine/SKILL.md +5 -4
- package/skills/asciify-engine/references/components.md +263 -813
- package/skills/asciify-engine/references/kit.md +426 -0
package/dist/kit.d.ts
ADDED
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
import { GlyphField, GlyphFieldOptions } from './field.js';
|
|
2
|
+
|
|
3
|
+
/** Options every kit component takes. */
|
|
4
|
+
interface KitOptions {
|
|
5
|
+
/** The field's ink: a CSS colour, a custom property name (`--brand`) or `var(--brand, #888)`. Re-read when the theme changes. */
|
|
6
|
+
ink?: string;
|
|
7
|
+
/** Raw glyph-field settings layered over the component's own look, such as `charset`, `cellSize` or `font`. */
|
|
8
|
+
look?: GlyphFieldOptions;
|
|
9
|
+
/** `true` or `false` overrides the visitor's `prefers-reduced-motion`; leave it unset to follow it. */
|
|
10
|
+
reducedMotion?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** The handle every kit component returns. Component handles add their own methods. */
|
|
13
|
+
interface KitHandle<O> {
|
|
14
|
+
/** False when WebGL2 is missing (or the field failed): the HTML is left as it was and drawing methods do nothing. */
|
|
15
|
+
readonly supported: boolean;
|
|
16
|
+
/** The underlying GPU field, for anything the kit does not cover. `null` in the fallback. */
|
|
17
|
+
readonly field: GlyphField | null;
|
|
18
|
+
/** Merges options; the next frame draws with them. */
|
|
19
|
+
update(options: Partial<O>): void;
|
|
20
|
+
/** Resumes motion after `pause()`. */
|
|
21
|
+
play(): void;
|
|
22
|
+
/** Holds the current frame and stops drawing. */
|
|
23
|
+
pause(): void;
|
|
24
|
+
/** Removes the canvas, listeners and observers, and restores the element's own markup and styles. */
|
|
25
|
+
destroy(): void;
|
|
26
|
+
}
|
|
27
|
+
interface Box {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
w: number;
|
|
31
|
+
h: number;
|
|
32
|
+
}
|
|
33
|
+
interface PaintFrame {
|
|
34
|
+
/** The source canvas, already cleared to black. White is the densest glyph; in source colour mode hue colours the glyph. */
|
|
35
|
+
pen: CanvasRenderingContext2D;
|
|
36
|
+
/** Source size in pixels. */
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
/** Canvas size in CSS pixels, and source pixels per CSS pixel. */
|
|
40
|
+
w: number;
|
|
41
|
+
h: number;
|
|
42
|
+
scale: number;
|
|
43
|
+
now: number;
|
|
44
|
+
/** Reduced motion: paint the settled state; the loop stops after this frame. */
|
|
45
|
+
still: boolean;
|
|
46
|
+
/** The page behind the element is dark (judged from the element's text colour). */
|
|
47
|
+
dark: boolean;
|
|
48
|
+
/** An element's layout box in the canvas's CSS pixels, unaffected by transforms on an ancestor. */
|
|
49
|
+
box(element: Element): Box;
|
|
50
|
+
}
|
|
51
|
+
interface SurfaceConfig {
|
|
52
|
+
host: HTMLElement;
|
|
53
|
+
/** The field look; ink comes from `ink`, so leave it out here. */
|
|
54
|
+
look: () => GlyphFieldOptions;
|
|
55
|
+
/** CSS colour or custom property for the field ink, given whether the ground is dark. */
|
|
56
|
+
ink: (dark: boolean) => string | undefined;
|
|
57
|
+
/** `over` draws above the element's content; `under` sits above its background but below its content. */
|
|
58
|
+
layer?: 'over' | 'under';
|
|
59
|
+
/** CSS pixels the canvas reaches past the element on every side. */
|
|
60
|
+
outset?: number;
|
|
61
|
+
/** Source pixels per CSS pixel (default 1), or a fixed source size from the canvas's CSS size. */
|
|
62
|
+
resolution?: number | ((w: number, h: number) => [number, number]);
|
|
63
|
+
/** Paints one frame; return true while more frames are needed. */
|
|
64
|
+
paint: (frame: PaintFrame) => boolean;
|
|
65
|
+
reducedMotion: () => boolean | undefined;
|
|
66
|
+
/** The field failed after mounting; the surface has already removed itself. */
|
|
67
|
+
onFail?: () => void;
|
|
68
|
+
/** Called when the theme changes, after the ink is re-read. */
|
|
69
|
+
onTheme?: () => void;
|
|
70
|
+
}
|
|
71
|
+
interface Surface {
|
|
72
|
+
readonly field: GlyphField;
|
|
73
|
+
readonly canvas: HTMLCanvasElement;
|
|
74
|
+
/** Starts the frame loop if it is not running. */
|
|
75
|
+
kick(): void;
|
|
76
|
+
/** Re-reads the look and ink, then kicks. */
|
|
77
|
+
refresh(): void;
|
|
78
|
+
still(): boolean;
|
|
79
|
+
dark(): boolean;
|
|
80
|
+
box(element: Element): Box;
|
|
81
|
+
play(): void;
|
|
82
|
+
pause(): void;
|
|
83
|
+
destroy(): void;
|
|
84
|
+
}
|
|
85
|
+
/** Any CSS colour as #rrggbb, or null. Custom properties are read from `from`. */
|
|
86
|
+
declare function resolveColor(token: string | undefined, from: Element, fallback?: string): string | null;
|
|
87
|
+
/**
|
|
88
|
+
* Mounts a field over or inside `host` and feeds it a canvas painted each frame. Returns null without WebGL2 or when
|
|
89
|
+
* mounting fails, having changed nothing, so the caller can keep its HTML as the fallback.
|
|
90
|
+
*/
|
|
91
|
+
declare function mountSurface(config: SurfaceConfig): Surface | null;
|
|
92
|
+
|
|
93
|
+
type BeamPalette = 'colorful' | 'mono' | 'ocean' | 'sunset' | readonly string[];
|
|
94
|
+
type BeamMode = 'rotate' | 'pulse' | 'progress';
|
|
95
|
+
interface BeamOptions extends KitOptions {
|
|
96
|
+
/** A named palette, or your own hex stops looped once round the border. `mono` draws in the ink. Default `colorful`. */
|
|
97
|
+
palette?: BeamPalette;
|
|
98
|
+
/** `rotate`: two arcs turn round the border. `pulse`: the whole border breathes. `progress`: all but dark at rest, a progress ring while work runs. */
|
|
99
|
+
mode?: BeamMode;
|
|
100
|
+
/** `dots` is a fine halftone; `glyphs` draws the light in small characters. */
|
|
101
|
+
grain?: 'dots' | 'glyphs';
|
|
102
|
+
/** Lap speed multiplier. 1 is a 2.6 second lap. */
|
|
103
|
+
speed?: number;
|
|
104
|
+
/** Faster and brighter while the pointer is over the element or it holds visible focus. Default true. */
|
|
105
|
+
hover?: boolean;
|
|
106
|
+
/** How far the glow reaches inward, in CSS px. It also stops 2px short of the element's padding. Default 18. */
|
|
107
|
+
depth?: number;
|
|
108
|
+
}
|
|
109
|
+
interface BeamHandle extends KitHandle<BeamOptions> {
|
|
110
|
+
/** Work is running, 0–1. In `progress` mode the ring grows clockwise from the top to this point; the other modes speed up as it fills. */
|
|
111
|
+
progress(value: number): void;
|
|
112
|
+
/** The light closes into a full ring, a flash sweeps once round it, a green fade settles, then the beam goes back to rest. */
|
|
113
|
+
success(): void;
|
|
114
|
+
/** Everything stops, flickers red twice and cracks into dim red fragments, which stay until `reset()` or `progress()`. */
|
|
115
|
+
error(): void;
|
|
116
|
+
/** Back to rest. */
|
|
117
|
+
reset(): void;
|
|
118
|
+
}
|
|
119
|
+
declare const BEAM_PALETTES: Record<'colorful' | 'mono' | 'ocean' | 'sunset', readonly string[]>;
|
|
120
|
+
/** 256 steps of a looped palette, each at full value with its luminance, so a pixel is one lookup. */
|
|
121
|
+
declare function beamPalette(palette: BeamPalette): Float32Array<ArrayBuffer>;
|
|
122
|
+
/**
|
|
123
|
+
* A band of light round an element's border, drawn as fine halftone dots or small characters inside the edge.
|
|
124
|
+
* The field covers the element exactly and is clipped to its computed corner radii, so nothing lands past its corners.
|
|
125
|
+
*/
|
|
126
|
+
declare function beam(element: HTMLElement, options?: BeamOptions): BeamHandle;
|
|
127
|
+
|
|
128
|
+
interface DecodeOptions extends KitOptions {
|
|
129
|
+
/** Text to draw instead of the element's own, centred and as large as fits; `\n` breaks lines. By default the element's text is drawn exactly where the browser lays it out. */
|
|
130
|
+
text?: string;
|
|
131
|
+
/** Total length in ms: the first 30% is drift alone, then the words resolve left to right. Default 900. */
|
|
132
|
+
duration?: number;
|
|
133
|
+
/** `visible` decodes when the element scrolls into view; `manual` waits for `replay()`. Default `visible`. */
|
|
134
|
+
trigger?: 'visible' | 'manual';
|
|
135
|
+
/** Decode again when the pointer enters. Default true. */
|
|
136
|
+
replayOnHover?: boolean;
|
|
137
|
+
/** `glyphs` keeps the headline in characters; `text` hands back to the crisp HTML text at the end. Default `glyphs`. */
|
|
138
|
+
settle?: 'glyphs' | 'text';
|
|
139
|
+
}
|
|
140
|
+
interface DecodeHandle extends KitHandle<DecodeOptions> {
|
|
141
|
+
/** Plays the decode again from the drift. */
|
|
142
|
+
replay(): void;
|
|
143
|
+
}
|
|
144
|
+
/** A headline that condenses out of a drifting field of characters, left to right through a flickering band. */
|
|
145
|
+
declare function decode(element: HTMLElement, options?: DecodeOptions): DecodeHandle;
|
|
146
|
+
|
|
147
|
+
interface OdometerOptions extends KitOptions {
|
|
148
|
+
/** The starting value. Default 0. */
|
|
149
|
+
value?: number;
|
|
150
|
+
/** Turns the value into the text shown. Default `toLocaleString()`. */
|
|
151
|
+
format?: (value: number) => string;
|
|
152
|
+
/** Milliseconds the first changed column rolls; each column to its right rolls `stagger` ms longer. Defaults 360 and 60. */
|
|
153
|
+
duration?: number;
|
|
154
|
+
stagger?: number;
|
|
155
|
+
/** Glyphs the columns roll through. Default `#%*+=-:`. */
|
|
156
|
+
glyphs?: string;
|
|
157
|
+
}
|
|
158
|
+
interface OdometerHandle extends KitHandle<OdometerOptions> {
|
|
159
|
+
/** Shows a new value; only the changed digits roll, leftmost first. */
|
|
160
|
+
set(value: number): void;
|
|
161
|
+
readonly value: number;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A figure in the page's own font whose changed digits roll through glyphs and land back on the crisp digit.
|
|
165
|
+
* The element's text becomes one span per character; a visually hidden live copy announces each value.
|
|
166
|
+
*/
|
|
167
|
+
declare function odometer(element: HTMLElement, options?: OdometerOptions): OdometerHandle;
|
|
168
|
+
|
|
169
|
+
interface ButtonLoadingOptions extends KitOptions {
|
|
170
|
+
/** The idle label. Default: the label element's text. */
|
|
171
|
+
text?: string;
|
|
172
|
+
/** The element holding the label text. Default: the button itself. Pass it when the button also holds an icon. */
|
|
173
|
+
label?: HTMLElement;
|
|
174
|
+
/** Put a check before the success label. Default true. */
|
|
175
|
+
check?: boolean;
|
|
176
|
+
/** Shake the button on failure (skipped under reduced motion). Default true. */
|
|
177
|
+
shake?: boolean;
|
|
178
|
+
/** A live region to announce each state in. Optional. */
|
|
179
|
+
announce?: HTMLElement;
|
|
180
|
+
}
|
|
181
|
+
type ButtonState = 'idle' | 'loading' | 'success' | 'error';
|
|
182
|
+
interface ButtonLoadingHandle extends KitHandle<ButtonLoadingOptions> {
|
|
183
|
+
/** Busy: the label decodes in, then a wave cycles each letter through glyphs until the next call. */
|
|
184
|
+
start(label?: string): void;
|
|
185
|
+
/** Decodes in the success label (with a check). */
|
|
186
|
+
succeed(label?: string): void;
|
|
187
|
+
/** Decodes in the failure label, with a short shake. */
|
|
188
|
+
fail(label?: string): void;
|
|
189
|
+
/** Back to the idle label. */
|
|
190
|
+
reset(label?: string): void;
|
|
191
|
+
readonly state: ButtonState;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A button whose label cycles through characters while its request runs, then decodes into the result.
|
|
195
|
+
* The width never changes: it grows to the widest label it has shown and holds there until `destroy()`.
|
|
196
|
+
*/
|
|
197
|
+
declare function buttonLoading(button: HTMLElement, options?: ButtonLoadingOptions): ButtonLoadingHandle;
|
|
198
|
+
|
|
199
|
+
type OrbState = 'idle' | 'loading' | 'success' | 'warning' | 'error';
|
|
200
|
+
type Outcome = 'success' | 'warning' | 'error';
|
|
201
|
+
interface StatusOrbOptions extends KitOptions {
|
|
202
|
+
/** Tint the characters with the outcome's colour. Default true. */
|
|
203
|
+
colourByState?: boolean;
|
|
204
|
+
/** Close the orbit into a ring around the mark; false leaves the bare mark. Default true. */
|
|
205
|
+
ring?: boolean;
|
|
206
|
+
/** Outcome colours: CSS colours or custom properties. Defaults read `--ascii-success`, `--ascii-warning` and `--ascii-error`. */
|
|
207
|
+
colors?: Partial<Record<Outcome, string>>;
|
|
208
|
+
}
|
|
209
|
+
interface StatusOrbHandle extends KitHandle<StatusOrbOptions> {
|
|
210
|
+
idle(): void;
|
|
211
|
+
loading(): void;
|
|
212
|
+
success(): void;
|
|
213
|
+
warning(): void;
|
|
214
|
+
error(): void;
|
|
215
|
+
readonly state: OrbState;
|
|
216
|
+
}
|
|
217
|
+
/** An orb of characters: it orbits while work runs, then closes into a ring around a check, '!' or X, tinted by the outcome. */
|
|
218
|
+
declare function statusOrb(element: HTMLElement, options?: StatusOrbOptions): StatusOrbHandle;
|
|
219
|
+
|
|
220
|
+
type SkeletonBlock = 'text' | 'photo' | 'avatar';
|
|
221
|
+
interface SkeletonOptions extends KitOptions {
|
|
222
|
+
/** Selector for the placeholder blocks inside the element. `data-block` may name the kind (`text`, `photo`, `avatar`); images default to photo. Default `[data-block]`. */
|
|
223
|
+
blocks?: string;
|
|
224
|
+
/** One shimmer sweep, in ms. Default 1250. */
|
|
225
|
+
shimmer?: number;
|
|
226
|
+
/** Each block resolves over this many ms. Default 240. */
|
|
227
|
+
resolve?: number;
|
|
228
|
+
/** Ms between blocks resolving, unless a block sets `data-delay`. Default 60. */
|
|
229
|
+
stagger?: number;
|
|
230
|
+
/** An image block develops in characters over this many ms. Default 560. */
|
|
231
|
+
develop?: number;
|
|
232
|
+
}
|
|
233
|
+
interface SkeletonHandle extends KitHandle<SkeletonOptions> {
|
|
234
|
+
/** The data has landed: each block resolves into its content. Resolves when the last one has. */
|
|
235
|
+
resolve(): Promise<void>;
|
|
236
|
+
/** Back to the shimmering skeleton, for a reload. */
|
|
237
|
+
reset(): void;
|
|
238
|
+
readonly loading: boolean;
|
|
239
|
+
}
|
|
240
|
+
/** Placeholder blocks drawn in characters with a shimmer sweeping across; on `resolve()` each block hands over to its content. */
|
|
241
|
+
declare function skeleton(element: HTMLElement, options?: SkeletonOptions): SkeletonHandle;
|
|
242
|
+
|
|
243
|
+
type PillTone = 'green' | 'amber' | 'red' | 'neutral' | 'new';
|
|
244
|
+
interface PillOptions extends KitOptions {
|
|
245
|
+
/** The tone of a pill without `data-tone`. `new` is a solid pill that takes a sheen on hover. Default `neutral`. */
|
|
246
|
+
tone?: PillTone;
|
|
247
|
+
/** A live state such as Live or Syncing: the indicator breathes and a sweep crosses the pill every few seconds. `data-live` on a pill wins. Default false. */
|
|
248
|
+
live?: boolean;
|
|
249
|
+
/** A three-character indicator on status pills, drawn over the pill's `[data-dot]` element (one is added when missing). Default true. */
|
|
250
|
+
indicator?: boolean;
|
|
251
|
+
/** A gradient sheen of characters passes once across a `new` pill when the pointer enters it. Default true. */
|
|
252
|
+
sheen?: boolean;
|
|
253
|
+
/** Glyph hues to paint, as `[r, g, b]` 0–255, for the light and dark ground. */
|
|
254
|
+
tones?: Partial<Record<'light' | 'dark', Partial<Record<PillTone, [number, number, number]>>>>;
|
|
255
|
+
}
|
|
256
|
+
interface PillHandle extends KitHandle<PillOptions> {
|
|
257
|
+
/** Runs the sheen once across one pill, or every `new` pill. */
|
|
258
|
+
sheen(pill?: HTMLElement): void;
|
|
259
|
+
/** Sets a count pill (`data-count`) to `value`; only the changed digits roll. Without `pill`, the first count pill. */
|
|
260
|
+
count(value: number | string, pill?: HTMLElement): void;
|
|
261
|
+
/** Re-reads each pill's `data-tone` and `data-live`; tone changes ease over 240ms. `update()` does this too. */
|
|
262
|
+
refresh(): void;
|
|
263
|
+
}
|
|
264
|
+
/** Glyph hues painted into the source. The field normalises each hue and takes the glyph from its brightness. */
|
|
265
|
+
declare const PILL_TONES: Record<'light' | 'dark', Record<PillTone, [number, number, number]>>;
|
|
266
|
+
/**
|
|
267
|
+
* Pills and badges with a strip of characters in their tone: a breathing live indicator, a sweep across live states, a sheen on
|
|
268
|
+
* `new` pills and rolling digits on count pills. One element gets a field under its text; a list shares one field over their common
|
|
269
|
+
* container (one WebGL context for all), with each pill's labels lifted above it.
|
|
270
|
+
*/
|
|
271
|
+
declare function pill(target: HTMLElement | Iterable<HTMLElement>, options?: PillOptions): PillHandle;
|
|
272
|
+
|
|
273
|
+
interface TabsOptions extends KitOptions {
|
|
274
|
+
/** The tab elements. Default: the tablist's `[role="tab"]` children. */
|
|
275
|
+
tabs?: string;
|
|
276
|
+
/** The tab shown first. Default: the one with `aria-selected="true"`, else 0. */
|
|
277
|
+
active?: number;
|
|
278
|
+
/** How long the indicator streams to a new tab, in ms. Default 280. */
|
|
279
|
+
duration?: number;
|
|
280
|
+
/** How the kit shows panels named by `aria-controls`: `hidden` toggles the attribute, `attribute` toggles `data-active`, `none` leaves them. Default `hidden`. */
|
|
281
|
+
panels?: 'hidden' | 'attribute' | 'none';
|
|
282
|
+
/** Wire clicks and arrow, Home and End keys, and keep `aria-selected` and roving `tabindex` in step. Default true. */
|
|
283
|
+
manage?: boolean;
|
|
284
|
+
/** Called after the active tab changes. */
|
|
285
|
+
onChange?: (index: number, tab: HTMLElement) => void;
|
|
286
|
+
}
|
|
287
|
+
interface TabsHandle extends KitHandle<TabsOptions> {
|
|
288
|
+
/** Selects a tab; the indicator streams across to it. `focus` moves keyboard focus too. */
|
|
289
|
+
select(index: number, focus?: boolean): void;
|
|
290
|
+
readonly active: number;
|
|
291
|
+
}
|
|
292
|
+
/** Segmented tabs whose active indicator is a pill of characters that streams across and condenses under the new tab. */
|
|
293
|
+
declare function tabs(tablist: HTMLElement, options?: TabsOptions): TabsHandle;
|
|
294
|
+
|
|
295
|
+
/** One update from an image provider. Either may be a Blob or a URL. */
|
|
296
|
+
interface ImageUpdate {
|
|
297
|
+
preview?: Blob | string;
|
|
298
|
+
final?: Blob | string;
|
|
299
|
+
}
|
|
300
|
+
type ImageStream = AsyncIterable<ImageUpdate> | (() => AsyncIterable<ImageUpdate>);
|
|
301
|
+
type GenerateState = 'idle' | 'generating' | 'done' | 'failed';
|
|
302
|
+
interface ImageGenerateOptions extends KitOptions {
|
|
303
|
+
/** Starts generating straight away. A function is called again by `run()` for each new request. */
|
|
304
|
+
stream?: ImageStream;
|
|
305
|
+
/** The photo that crossfades in over the field. Default: the first `<img>` inside the element. */
|
|
306
|
+
image?: HTMLImageElement | null;
|
|
307
|
+
/** Writes the elapsed time while generating, such as `4.2s`. */
|
|
308
|
+
elapsed?: HTMLElement | null;
|
|
309
|
+
/** Called on every state change. */
|
|
310
|
+
onState?: (state: GenerateState, error?: unknown) => void;
|
|
311
|
+
}
|
|
312
|
+
interface ImageGenerateHandle extends KitHandle<ImageGenerateOptions> {
|
|
313
|
+
/** Starts a request (a finished image dissolves back into the ground first). Resolves with the final state. */
|
|
314
|
+
run(stream?: ImageStream): Promise<GenerateState>;
|
|
315
|
+
/** Abandons a running request and returns to the idle ground. */
|
|
316
|
+
reset(): void;
|
|
317
|
+
readonly state: GenerateState;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* An image being generated: the field drifts with an elapsed clock, each streamed preview develops in a step sharper,
|
|
321
|
+
* then the final image, and the photo crossfades in. Works with any provider that can be wrapped as an async iterable.
|
|
322
|
+
*/
|
|
323
|
+
declare function imageGenerate(element: HTMLElement, options?: ImageGenerateOptions): ImageGenerateHandle;
|
|
324
|
+
|
|
325
|
+
type FieldPreset = 'hero' | 'notFound' | 'brand';
|
|
326
|
+
interface FieldBackgroundOptions extends KitOptions {
|
|
327
|
+
/** `hero`: a drifting ground of characters. `brand`: the same ground, denser, in the brand colour. `notFound`: the page's code set large in characters. Default `hero`. */
|
|
328
|
+
preset?: FieldPreset;
|
|
329
|
+
/** The headline block to keep clear: the ground fades out in a soft ellipse round it, so a frosted veil over it reads clean. */
|
|
330
|
+
clear?: HTMLElement | false;
|
|
331
|
+
/** The ink, one colour or one per ground. Wins over `ink`. `brand` defaults to `var(--brand)`. */
|
|
332
|
+
palette?: string | {
|
|
333
|
+
light?: string;
|
|
334
|
+
dark?: string;
|
|
335
|
+
};
|
|
336
|
+
/** `notFound` only: the characters drawn. Default `404`. */
|
|
337
|
+
text?: string;
|
|
338
|
+
/** The pointer drops a soft ring into the ground every so often (`hero` and `brand`). Default true. */
|
|
339
|
+
ripple?: boolean;
|
|
340
|
+
/** The canvas's accessible name. `notFound` defaults to its text; the grounds are decorative and hidden. */
|
|
341
|
+
label?: string;
|
|
342
|
+
}
|
|
343
|
+
interface FieldBackgroundHandle extends KitHandle<FieldBackgroundOptions> {
|
|
344
|
+
/** Sends a ring through the field from an element, a viewport point or the centre. Ripples hold off for a moment after. */
|
|
345
|
+
pulse(from?: Element | {
|
|
346
|
+
x: number;
|
|
347
|
+
y: number;
|
|
348
|
+
}, strength?: number): void;
|
|
349
|
+
/** `notFound`: the characters break apart, hang for a beat and re-form, as the next page would load. Other presets pulse. */
|
|
350
|
+
scatter(from?: Element): Promise<void>;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* A page background drawn in characters: the hero's drifting ground with a soft clear zone round the headline, the same ground in
|
|
354
|
+
* the brand colour, or a 404 set large that scatters and re-forms.
|
|
355
|
+
*/
|
|
356
|
+
declare function fieldBackground(element: HTMLElement, options?: FieldBackgroundOptions): FieldBackgroundHandle;
|
|
357
|
+
|
|
358
|
+
interface WordmarkOptions extends KitOptions {
|
|
359
|
+
/** The word drawn. Default the element's own text, which stays in the DOM, transparent, for selection and screen readers. */
|
|
360
|
+
text?: string;
|
|
361
|
+
/** The face it is set in. Default a serif: `Georgia, "Times New Roman", serif`. */
|
|
362
|
+
font?: string;
|
|
363
|
+
/** Default 600. */
|
|
364
|
+
fontWeight?: number;
|
|
365
|
+
}
|
|
366
|
+
interface WordmarkHandle extends KitHandle<WordmarkOptions> {
|
|
367
|
+
/** Sets the word again, as large as fits. */
|
|
368
|
+
setText(text: string): void;
|
|
369
|
+
readonly text: string;
|
|
370
|
+
}
|
|
371
|
+
/** A name or a word set in characters, with a trail under the pointer. */
|
|
372
|
+
declare function wordmark(element: HTMLElement, options?: WordmarkOptions): WordmarkHandle;
|
|
373
|
+
|
|
374
|
+
interface AsciiVideoOptions extends KitOptions {
|
|
375
|
+
/** A video URL, or a `<video>` element. Default the first `<video>` inside the element, which is hidden while the field draws it. */
|
|
376
|
+
src?: string | HTMLVideoElement;
|
|
377
|
+
/** Starts playing at once. Default true, or false when the visitor prefers reduced motion, which shows the first frame. */
|
|
378
|
+
autoplay?: boolean;
|
|
379
|
+
/** An image URL shown before the first frame is drawn, and in place of the video while it is paused under reduced motion. */
|
|
380
|
+
poster?: string;
|
|
381
|
+
/** The canvas's accessible name. Default `Video, drawn in characters`. */
|
|
382
|
+
label?: string;
|
|
383
|
+
}
|
|
384
|
+
interface AsciiVideoHandle extends KitHandle<AsciiVideoOptions> {
|
|
385
|
+
/** Plays when paused, pauses when playing; returns whether it now plays. */
|
|
386
|
+
toggle(): boolean;
|
|
387
|
+
readonly playing: boolean;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* A video drawn in characters, muted and looping, with play and pause. Without WebGL2 the video itself plays in the element,
|
|
391
|
+
* with the poster until it starts.
|
|
392
|
+
*/
|
|
393
|
+
declare function asciiVideo(element: HTMLElement, options?: AsciiVideoOptions): AsciiVideoHandle;
|
|
394
|
+
|
|
395
|
+
interface ArtPanelOptions extends KitOptions {
|
|
396
|
+
/** An image URL or element. Default the first `<img>` inside the panel, which is hidden while the field draws it. */
|
|
397
|
+
image?: string | HTMLImageElement;
|
|
398
|
+
/** A brand mark or caption over the art to keep clear, in a soft rectangle. */
|
|
399
|
+
clear?: HTMLElement | false;
|
|
400
|
+
/** Crop focus for the cover fit, 0–1 on each axis. Default `{ x: 0.5, y: 0.4 }`. */
|
|
401
|
+
focus?: {
|
|
402
|
+
x: number;
|
|
403
|
+
y: number;
|
|
404
|
+
};
|
|
405
|
+
/** The canvas's accessible name. Default the image's `alt`, else hidden as decoration. */
|
|
406
|
+
label?: string;
|
|
407
|
+
}
|
|
408
|
+
interface ArtPanelHandle extends KitHandle<ArtPanelOptions> {
|
|
409
|
+
/** Sends a ring through the art from an element (the submit button), a viewport point or the centre. Default strength 1. */
|
|
410
|
+
pulse(from?: Element | {
|
|
411
|
+
x: number;
|
|
412
|
+
y: number;
|
|
413
|
+
}, strength?: number): void;
|
|
414
|
+
/** While on, a lit band crosses the art again and again, characters climbing the ramp as it passes: a request is running. */
|
|
415
|
+
shimmer(on: boolean): void;
|
|
416
|
+
}
|
|
417
|
+
/** The sign-in page's art panel: an image drawn in characters, with a trail, pulses for form events and a shimmer while it waits. */
|
|
418
|
+
declare function artPanel(element: HTMLElement, options?: ArtPanelOptions): ArtPanelHandle;
|
|
419
|
+
|
|
420
|
+
interface PricingGlowOptions extends KitOptions {
|
|
421
|
+
/** A saving, such as `−25%`, set large in dots in the open space above the price. Default none. */
|
|
422
|
+
saving?: string | null;
|
|
423
|
+
/** The price element the open space ends at. Default the card's `[data-price]`. */
|
|
424
|
+
price?: Element | string;
|
|
425
|
+
/** The face the saving is set in. Default `600 … "Geist", Arial, sans-serif`. */
|
|
426
|
+
font?: string;
|
|
427
|
+
}
|
|
428
|
+
interface PricingGlowHandle extends KitHandle<PricingGlowOptions> {
|
|
429
|
+
/** A lit band crosses the card once, the halftone redrawn behind it. */
|
|
430
|
+
sweep(): Promise<void>;
|
|
431
|
+
/** Shows a saving (or none) in dots: the band sweeps the old art out and the new one in. */
|
|
432
|
+
saving(text: string | null): Promise<void>;
|
|
433
|
+
/** Sends a ring through the halftone from an element, such as the plan's button. Default strength 1.6. */
|
|
434
|
+
pulse(from?: Element | {
|
|
435
|
+
x: number;
|
|
436
|
+
y: number;
|
|
437
|
+
}, strength?: number): void;
|
|
438
|
+
}
|
|
439
|
+
/** The recommended plan's halftone glow: light from the corner, a lantern under the pointer, and the yearly saving set in dots. */
|
|
440
|
+
declare function pricingGlow(element: HTMLElement, options?: PricingGlowOptions): PricingGlowHandle;
|
|
441
|
+
|
|
442
|
+
type VoicePalette = 'mono' | 'aurora' | 'brand' | readonly string[];
|
|
443
|
+
type VoiceState = 'idle' | 'listening' | 'thinking' | 'done';
|
|
444
|
+
interface VoiceOrbOptions extends KitOptions {
|
|
445
|
+
/** `mono` draws in the ink; `aurora`, `brand` or your own hex stops tint the sphere, sliding as the voice gets louder. Default `aurora`. */
|
|
446
|
+
palette?: VoicePalette;
|
|
447
|
+
/** The starting level, 0–1. Default 0. */
|
|
448
|
+
level?: number;
|
|
449
|
+
/** Swell the element by up to 10% with the level (sets `scale`). It also sets `--ascii-level` either way. Default true. */
|
|
450
|
+
swell?: boolean;
|
|
451
|
+
}
|
|
452
|
+
interface VoiceOrbHandle extends KitHandle<VoiceOrbOptions> {
|
|
453
|
+
/** The voice's loudness, 0–1. The orb follows it with a fast attack and a slower release. */
|
|
454
|
+
level(value: number): void;
|
|
455
|
+
/** Listening: the orb follows `level()` (or the microphone). */
|
|
456
|
+
listen(): void;
|
|
457
|
+
/** Thinking: a slow low hum while the reply is worked out. Stops the microphone. */
|
|
458
|
+
think(): void;
|
|
459
|
+
/** Done: the level falls away over 420ms. Stops the microphone. */
|
|
460
|
+
done(): void;
|
|
461
|
+
/** Back to rest. Stops the microphone. */
|
|
462
|
+
idle(): void;
|
|
463
|
+
/** Asks for the microphone (only now) and listens to it. Resolves false when it is unavailable or refused. */
|
|
464
|
+
mic(): Promise<boolean>;
|
|
465
|
+
readonly state: VoiceState;
|
|
466
|
+
/** The level the orb is drawing now, after smoothing. */
|
|
467
|
+
readonly current: number;
|
|
468
|
+
}
|
|
469
|
+
declare const VOICE_PALETTES: Record<'aurora' | 'brand', readonly string[]>;
|
|
470
|
+
/** A voice orb of characters that swells with the voice, hums while thinking and settles when done. */
|
|
471
|
+
declare function voiceOrb(element: HTMLElement, options?: VoiceOrbOptions): VoiceOrbHandle;
|
|
472
|
+
|
|
473
|
+
interface CommandPaletteOptions extends KitOptions {
|
|
474
|
+
/** The button that opens the palette. Blocks fly out of it on open and back into it on close. */
|
|
475
|
+
trigger?: HTMLElement | null;
|
|
476
|
+
/** The search field inside the palette. Default: its first `input`. */
|
|
477
|
+
input?: string;
|
|
478
|
+
/** The command rows. Default `[role="option"]`. */
|
|
479
|
+
rows?: string;
|
|
480
|
+
/** Start open. Default: open unless the palette has the `hidden` attribute. */
|
|
481
|
+
open?: boolean;
|
|
482
|
+
/** ⌘K / Ctrl+K toggles the palette from anywhere on the page; `false` turns it off. Default `'k'`. */
|
|
483
|
+
hotkey?: string | false;
|
|
484
|
+
/** Wire arrow keys, Home, End, Enter, Escape, pointer hover, outside clicks and `aria-selected`. Default true. */
|
|
485
|
+
manage?: boolean;
|
|
486
|
+
/** Close after a command runs. Default true. */
|
|
487
|
+
closeOnRun?: boolean;
|
|
488
|
+
/** Called when a row is chosen with Enter or a click. */
|
|
489
|
+
onRun?: (index: number, row: HTMLElement) => void;
|
|
490
|
+
/** Called after the palette opens or closes. */
|
|
491
|
+
onOpenChange?: (open: boolean) => void;
|
|
492
|
+
}
|
|
493
|
+
interface CommandPaletteHandle extends KitHandle<CommandPaletteOptions> {
|
|
494
|
+
/** Condenses the palette out of the trigger. `focus` moves focus to the input (default true). */
|
|
495
|
+
open(focus?: boolean): void;
|
|
496
|
+
/** Dissolves the palette back into the trigger. */
|
|
497
|
+
close(): void;
|
|
498
|
+
toggle(): void;
|
|
499
|
+
/** Moves the selection; the marker glides to the row. */
|
|
500
|
+
select(index: number): void;
|
|
501
|
+
/** Runs a row as if it were clicked. */
|
|
502
|
+
run(index?: number): void;
|
|
503
|
+
readonly isOpen: boolean;
|
|
504
|
+
readonly selected: number;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* A command palette that condenses out of its trigger in blocks of characters and dissolves back into it, with a glyph marker
|
|
508
|
+
* in the selected row's gutter that glides between rows.
|
|
509
|
+
*/
|
|
510
|
+
declare function commandPalette(panel: HTMLElement, options?: CommandPaletteOptions): CommandPaletteHandle;
|
|
511
|
+
|
|
512
|
+
interface SlideToConfirmOptions extends KitOptions {
|
|
513
|
+
/** Called once the slide completes, by drag, fling, Enter, Space, End or `confirm()`. */
|
|
514
|
+
onConfirm?: () => void;
|
|
515
|
+
/** The handle. Default: the track's `[role="slider"]`, else its first child element. */
|
|
516
|
+
thumb?: string;
|
|
517
|
+
/** Text that fades as the thumb travels. Default `[data-label]`. */
|
|
518
|
+
label?: string;
|
|
519
|
+
/** Where the fill condenses into a ring and check. Default: the middle of the track. */
|
|
520
|
+
mark?: HTMLElement | null;
|
|
521
|
+
/** How far, 0–1, a release must reach to confirm. Default 0.9. */
|
|
522
|
+
threshold?: number;
|
|
523
|
+
/** Ms after confirming before the slider resets itself; 0 keeps it confirmed until `reset()`. Default 0. */
|
|
524
|
+
resetAfter?: number;
|
|
525
|
+
/** The ink the field eases to on success: a CSS colour or custom property. Default `--ascii-success`. */
|
|
526
|
+
color?: string;
|
|
527
|
+
}
|
|
528
|
+
interface SlideToConfirmHandle extends KitHandle<SlideToConfirmOptions> {
|
|
529
|
+
/** Completes the slide as if dragged to the end. */
|
|
530
|
+
confirm(): void;
|
|
531
|
+
/** Springs back to the start, unconfirmed. */
|
|
532
|
+
reset(): void;
|
|
533
|
+
readonly confirmed: boolean;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Slide to confirm: characters fill the track behind the thumb as it travels; on completion the fill condenses into a disc,
|
|
537
|
+
* opens into a ring and a check draws inside it while the ink eases to the success colour.
|
|
538
|
+
*/
|
|
539
|
+
declare function slideToConfirm(track: HTMLElement, options?: SlideToConfirmOptions): SlideToConfirmHandle;
|
|
540
|
+
|
|
541
|
+
type LikeMark = 'heart' | 'save';
|
|
542
|
+
interface LikeBurstOptions extends KitOptions {
|
|
543
|
+
/** The shape that bursts: a heart or a bookmark. Default `heart`. */
|
|
544
|
+
kind?: LikeMark;
|
|
545
|
+
/** The icon inside the button the burst grows from and lands back in. Default: its first `svg`. */
|
|
546
|
+
icon?: string;
|
|
547
|
+
/** Clicking toggles `aria-pressed`, bursting on and loosening off. `false` leaves clicks to you. Default true. */
|
|
548
|
+
manage?: boolean;
|
|
549
|
+
/** Nothing is drawn above this element's bottom edge, so the burst never covers the copy above the button. */
|
|
550
|
+
limit?: HTMLElement | null;
|
|
551
|
+
/** CSS pixels the field reaches past the button on every side. Default 40; set at mount. */
|
|
552
|
+
outset?: number;
|
|
553
|
+
/** Called after a click toggles the button. */
|
|
554
|
+
onChange?: (pressed: boolean) => void;
|
|
555
|
+
}
|
|
556
|
+
interface LikeBurstHandle extends KitHandle<LikeBurstOptions> {
|
|
557
|
+
/** The pop: the mark springs out of the icon in characters, an outline rolls out, sparks fly, and it lands back in the icon. */
|
|
558
|
+
burst(): void;
|
|
559
|
+
/** The soft undo: the filled mark loosens, sinks and thins out. */
|
|
560
|
+
undo(): void;
|
|
561
|
+
/** Sets `aria-pressed`, bursting when it turns on and loosening when it turns off. */
|
|
562
|
+
toggle(pressed?: boolean): void;
|
|
563
|
+
readonly pressed: boolean;
|
|
564
|
+
}
|
|
565
|
+
/** A like or save button that pops its mark in characters on press and loosens it on undo. */
|
|
566
|
+
declare function likeBurst(button: HTMLElement, options?: LikeBurstOptions): LikeBurstHandle;
|
|
567
|
+
|
|
568
|
+
interface BlockChartOptions extends KitOptions {
|
|
569
|
+
/** The bars, left to right. */
|
|
570
|
+
values?: readonly number[];
|
|
571
|
+
/** A name per bar, read by screen readers and passed to `onHover`. */
|
|
572
|
+
labels?: readonly string[];
|
|
573
|
+
/** The value the top of the plot stands for. Default: the largest value plus 4%. */
|
|
574
|
+
max?: number;
|
|
575
|
+
/** How long each bar grows, in ms. Default 520. */
|
|
576
|
+
duration?: number;
|
|
577
|
+
/** Ms between bars growing. Default 45 for up to 7 bars, else 9. */
|
|
578
|
+
stagger?: number;
|
|
579
|
+
/** Formats values for the screen reader table. Default `toLocaleString()`. */
|
|
580
|
+
format?: (value: number) => string;
|
|
581
|
+
/** Called as the pointer or arrow keys move onto a bar, and with `null` when they leave. */
|
|
582
|
+
onHover?: (index: number | null, value: number | null, label: string | null) => void;
|
|
583
|
+
}
|
|
584
|
+
interface BlockChartHandle extends KitHandle<BlockChartOptions> {
|
|
585
|
+
/** New values (and labels); the bars grow again. */
|
|
586
|
+
set(values: readonly number[], labels?: readonly string[]): void;
|
|
587
|
+
/** Lights one bar and dims the rest, or `null` for the resting emphasis on the last bar. */
|
|
588
|
+
highlight(index: number | null): void;
|
|
589
|
+
readonly active: number | null;
|
|
590
|
+
readonly values: readonly number[];
|
|
591
|
+
}
|
|
592
|
+
/** A bar chart drawn in columns of characters: bars grow in staggered, the last is emphasised, and hover lights one and dims the rest. */
|
|
593
|
+
declare function blockChart(element: HTMLElement, options?: BlockChartOptions): BlockChartHandle;
|
|
594
|
+
|
|
595
|
+
interface PageDissolveOptions extends KitOptions {
|
|
596
|
+
/** Where the dissolve starts: an element (such as the tab that was clicked) or a point in the container's CSS pixels. Default: top centre. */
|
|
597
|
+
origin?: HTMLElement | {
|
|
598
|
+
x: number;
|
|
599
|
+
y: number;
|
|
600
|
+
} | null;
|
|
601
|
+
/** Ms the old view takes to break up. Default 140. */
|
|
602
|
+
dissolve?: number;
|
|
603
|
+
/** Ms the new view takes to condense. Default 160. */
|
|
604
|
+
condense?: number;
|
|
605
|
+
}
|
|
606
|
+
interface PageDissolveHandle extends KitHandle<PageDissolveOptions> {
|
|
607
|
+
/**
|
|
608
|
+
* The view breaks into its own characters from `origin`, `render` swaps the content underneath, and the new view condenses
|
|
609
|
+
* out of characters. Swaps queue; each promise resolves once its view is crisp again.
|
|
610
|
+
*/
|
|
611
|
+
swap(render: () => void | Promise<void>, origin?: HTMLElement | {
|
|
612
|
+
x: number;
|
|
613
|
+
y: number;
|
|
614
|
+
} | null): Promise<void>;
|
|
615
|
+
readonly busy: boolean;
|
|
616
|
+
}
|
|
617
|
+
/** A page or panel transition: the view dissolves into characters from where the user clicked and the next view condenses in. */
|
|
618
|
+
declare function pageDissolve(container: HTMLElement, options?: PageDissolveOptions): PageDissolveHandle;
|
|
619
|
+
|
|
620
|
+
interface SwipeDeckOptions extends KitOptions {
|
|
621
|
+
/** The cards, in order. Each card's first `img` is drawn in characters. Default `[data-card]`. */
|
|
622
|
+
cards?: string;
|
|
623
|
+
/** Start again from the first card after the last. Default true. */
|
|
624
|
+
loop?: boolean;
|
|
625
|
+
/** How far, as a share of the card's width, a release must travel to fling it. Default 0.4. */
|
|
626
|
+
threshold?: number;
|
|
627
|
+
/** Corner radius of the drawn cards, in CSS px. Default: the deck's own border radius. */
|
|
628
|
+
radius?: number;
|
|
629
|
+
/** CSS pixels the field reaches past the deck for the stack and the fling. Default 56; set at mount. */
|
|
630
|
+
outset?: number;
|
|
631
|
+
/** Called after a card leaves: `dir` is 1 for right (keep), -1 for left (pass). */
|
|
632
|
+
onSwipe?: (dir: 1 | -1, index: number, card: HTMLElement) => void;
|
|
633
|
+
}
|
|
634
|
+
interface SwipeDeckHandle extends KitHandle<SwipeDeckOptions> {
|
|
635
|
+
/** Flings the top card: 1 to the right, -1 to the left. Returns false at the end of a deck that does not loop. */
|
|
636
|
+
next(dir?: 1 | -1): boolean;
|
|
637
|
+
/** The index of the top card. */
|
|
638
|
+
readonly index: number;
|
|
639
|
+
}
|
|
640
|
+
/** A deck of cards drawn in characters: drag or press the arrow keys to fling the top card, which breaks into rows of characters along the swipe. */
|
|
641
|
+
declare function swipeDeck(deck: HTMLElement, options?: SwipeDeckOptions): SwipeDeckHandle;
|
|
642
|
+
|
|
643
|
+
type CodeState = 'idle' | 'error' | 'success';
|
|
644
|
+
interface CodeInputOptions extends KitOptions {
|
|
645
|
+
/** How many characters the code has. Default 6. */
|
|
646
|
+
length?: number;
|
|
647
|
+
/** `digits` keeps only 0–9; `alphanumeric` keeps letters too, upper-cased. Default `digits`. */
|
|
648
|
+
accept?: 'digits' | 'alphanumeric';
|
|
649
|
+
/** The cells. Missing cells are created as `span[data-cell]`. Default `[data-cell]`. */
|
|
650
|
+
cells?: string;
|
|
651
|
+
/** Called once every cell is filled and has resolved. Answer with `verify(ok)`. */
|
|
652
|
+
onComplete?: (code: string) => void;
|
|
653
|
+
}
|
|
654
|
+
interface CodeInputHandle extends KitHandle<CodeInputOptions> {
|
|
655
|
+
/** `true`: the digits gather into the middle and a check draws in a ring. `false`: they break up, the row shakes, and it clears. */
|
|
656
|
+
verify(ok: boolean): void;
|
|
657
|
+
/** Empties the code and returns to idle. */
|
|
658
|
+
clear(): void;
|
|
659
|
+
readonly value: string;
|
|
660
|
+
readonly state: CodeState;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* A one-time-code field: each digit resolves out of scattered characters, the caret is a breathing column of characters,
|
|
664
|
+
* a wrong code breaks up and shakes, and a right one gathers into a check in a ring.
|
|
665
|
+
*/
|
|
666
|
+
declare function codeInput(element: HTMLElement, options?: CodeInputOptions): CodeInputHandle;
|
|
667
|
+
|
|
668
|
+
interface Toast {
|
|
669
|
+
title: string;
|
|
670
|
+
body?: string;
|
|
671
|
+
/** A node (such as an inline SVG) or a short text shown in the icon tile. */
|
|
672
|
+
icon?: Node | string;
|
|
673
|
+
/** A button beside the text, such as Undo. Clicking it dismisses the toast too. */
|
|
674
|
+
action?: {
|
|
675
|
+
label: string;
|
|
676
|
+
onClick: () => void;
|
|
677
|
+
};
|
|
678
|
+
/** Ms before it leaves on its own; 0 keeps it until dismissed. Default: the stack's `duration`. */
|
|
679
|
+
duration?: number;
|
|
680
|
+
}
|
|
681
|
+
interface ToastStackOptions extends KitOptions {
|
|
682
|
+
/** Toasts kept at once; the oldest dissolves when another arrives. Default 3. */
|
|
683
|
+
max?: number;
|
|
684
|
+
/** Ms a toast stays, unless pointed at or focused. 0 keeps every toast until dismissed. Default 6000. */
|
|
685
|
+
duration?: number;
|
|
686
|
+
/** Your own markup for a toast. Mark parts with `data-paint` (`strong`, `text`, `meta`, `tile`, `icon`, `none`) to set how they gather. */
|
|
687
|
+
render?: (toast: Toast, id: number) => HTMLElement;
|
|
688
|
+
/** Accessible name of the list. Default `Notifications`. */
|
|
689
|
+
label?: string;
|
|
690
|
+
}
|
|
691
|
+
interface ToastStackHandle extends KitHandle<ToastStackOptions> {
|
|
692
|
+
/** Adds a toast at the front, gathering out of scattered characters. Returns its id. */
|
|
693
|
+
push(toast: Toast): number;
|
|
694
|
+
/** Takes a toast out: it breaks into characters that drift up and away while the stack closes up. */
|
|
695
|
+
dismiss(id: number): void;
|
|
696
|
+
/** Dismisses every toast. */
|
|
697
|
+
clear(): void;
|
|
698
|
+
/** Ids of the toasts shown, oldest first. */
|
|
699
|
+
readonly toasts: number[];
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* A stack of toasts: each one gathers out of scattered characters, the newest in front and the rest tucked behind,
|
|
703
|
+
* fanning out while pointed at or focused. Dismissed toasts break into characters that drift up and away.
|
|
704
|
+
*/
|
|
705
|
+
declare function toastStack(container: HTMLElement, options?: ToastStackOptions): ToastStackHandle;
|
|
706
|
+
|
|
707
|
+
type ThinkingState = 'thinking' | 'streaming' | 'done';
|
|
708
|
+
interface ThinkingOptions extends KitOptions {
|
|
709
|
+
/** Line-shaped bands of drifting dots shown while thinking. Default 3. */
|
|
710
|
+
lines?: number;
|
|
711
|
+
/** An element to write the status into: `Thinking…`, then `Thought for 2s`. */
|
|
712
|
+
label?: HTMLElement | null;
|
|
713
|
+
/** The status texts. */
|
|
714
|
+
labels?: {
|
|
715
|
+
thinking?: string;
|
|
716
|
+
done?: (seconds: number) => string;
|
|
717
|
+
};
|
|
718
|
+
/** Start thinking at once. Default true; false waits for `think()`. */
|
|
719
|
+
start?: boolean;
|
|
720
|
+
/** Ms between one word and the next fading in. Default 38. */
|
|
721
|
+
stagger?: number;
|
|
722
|
+
/** A dotted rule under the finished answer. Default true. */
|
|
723
|
+
rule?: boolean;
|
|
724
|
+
}
|
|
725
|
+
interface ThinkingHandle extends KitHandle<ThinkingOptions> {
|
|
726
|
+
/** Clears the answer and thinks again, as for Regenerate. */
|
|
727
|
+
think(): void;
|
|
728
|
+
/** Writes the answer, word by word, as the dots give way. Pass a string or an async iterable of chunks. Resolves when it has settled. */
|
|
729
|
+
stream(text: string | AsyncIterable<string>): Promise<void>;
|
|
730
|
+
readonly state: ThinkingState;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* The thinking state of an assistant reply: line-shaped bands of drifting dots while the model thinks, then the answer
|
|
734
|
+
* fades in word by word as the dots give way, leaving a quiet dotted rule under it.
|
|
735
|
+
*/
|
|
736
|
+
declare function thinking(element: HTMLElement, options?: ThinkingOptions): ThinkingHandle;
|
|
737
|
+
|
|
738
|
+
type StreamState = 'idle' | 'streaming' | 'done' | 'stopped';
|
|
739
|
+
interface StreamTextOptions extends KitOptions {
|
|
740
|
+
/** A block caret after the last character: bright while writing, dim at rest. Default true. */
|
|
741
|
+
caret?: boolean;
|
|
742
|
+
/** Ms a token's first character flickers before it resolves; each following character takes `stagger` ms more. Defaults 60 and 18. */
|
|
743
|
+
settle?: number;
|
|
744
|
+
stagger?: number;
|
|
745
|
+
/** Called on every state change. */
|
|
746
|
+
onState?: (state: StreamState) => void;
|
|
747
|
+
/** Reasoning lines `reasoning()` keeps in view above the reply; older ones scroll up and fade. Default 2. */
|
|
748
|
+
reasoningLines?: number;
|
|
749
|
+
}
|
|
750
|
+
interface StreamTextHandle extends KitHandle<StreamTextOptions> {
|
|
751
|
+
/** Appends a token: its characters land as flickering glyph cells that resolve into letters, left to right. */
|
|
752
|
+
write(token: string): void;
|
|
753
|
+
/** No more tokens: resolves once the last characters have landed. */
|
|
754
|
+
done(): Promise<void>;
|
|
755
|
+
/** Lands what has been written at once and stops. */
|
|
756
|
+
stop(): void;
|
|
757
|
+
/** Adds a line to the reasoning tail above the reply. The tail collapses once the reply is done or stopped. */
|
|
758
|
+
reasoning(line: string): void;
|
|
759
|
+
/** Clears the text and the reasoning for a new reply. */
|
|
760
|
+
reset(): void;
|
|
761
|
+
readonly state: StreamState;
|
|
762
|
+
readonly text: string;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Streamed text with a glyph write head: each token lands as flickering character cells that resolve into letters left
|
|
766
|
+
* to right, with a block caret after the last one. The real text is in the DOM all along, for selection and screen readers.
|
|
767
|
+
*/
|
|
768
|
+
declare function streamText(element: HTMLElement, options?: StreamTextOptions): StreamTextHandle;
|
|
769
|
+
|
|
770
|
+
interface CompareOptions extends KitOptions {
|
|
771
|
+
/** The photo: a URL, or an `<img>` (one inside the element is used in place). */
|
|
772
|
+
image: string | HTMLImageElement;
|
|
773
|
+
/** Share of the frame showing the photo, from the left, 0–100. Default 50. */
|
|
774
|
+
position?: number;
|
|
775
|
+
/** The handle's accessible name. Default `Photo and ASCII split`. */
|
|
776
|
+
label?: string;
|
|
777
|
+
/** Called as the split moves. */
|
|
778
|
+
onChange?: (position: number) => void;
|
|
779
|
+
}
|
|
780
|
+
interface CompareHandle extends KitHandle<CompareOptions> {
|
|
781
|
+
/** Moves the split; `glide` eases it there. */
|
|
782
|
+
set(position: number, glide?: boolean): void;
|
|
783
|
+
readonly position: number;
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* A before and after slider: the photo on the left of the split and the same photo in characters, in its own colours,
|
|
787
|
+
* on the right. Drag anywhere, or use the arrow keys, Page Up and Down, Home and End on the handle.
|
|
788
|
+
*/
|
|
789
|
+
declare function compare(element: HTMLElement, options: CompareOptions): CompareHandle;
|
|
790
|
+
|
|
791
|
+
interface AccordionImage {
|
|
792
|
+
src: string;
|
|
793
|
+
/** Read with the title as the panel's accessible name. */
|
|
794
|
+
alt?: string;
|
|
795
|
+
title?: string;
|
|
796
|
+
meta?: string;
|
|
797
|
+
/** Crop focus, 0–1 on each axis. Default the centre. */
|
|
798
|
+
focus?: {
|
|
799
|
+
x: number;
|
|
800
|
+
y: number;
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
interface AccordionOptions extends KitOptions {
|
|
804
|
+
images: (string | AccordionImage)[];
|
|
805
|
+
/** The panel open at first. Default 0. */
|
|
806
|
+
open?: number;
|
|
807
|
+
/** Ms a panel takes to open. Default 280. */
|
|
808
|
+
duration?: number;
|
|
809
|
+
/** Accessible name of the group. Default `Images`. */
|
|
810
|
+
label?: string;
|
|
811
|
+
onChange?: (index: number) => void;
|
|
812
|
+
}
|
|
813
|
+
interface AccordionHandle extends KitHandle<AccordionOptions> {
|
|
814
|
+
/** Opens a panel; `focus` moves focus to it too. */
|
|
815
|
+
select(index: number, focus?: boolean): void;
|
|
816
|
+
readonly open: number;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* A strip of image panels: the open one shows its photo, the closed ones the same photos in characters. Pointing at,
|
|
820
|
+
* pressing or focusing a panel opens it, and as it opens its characters flare denser for a beat, then give way to the photo.
|
|
821
|
+
*/
|
|
822
|
+
declare function accordion(element: HTMLElement, options: AccordionOptions): AccordionHandle;
|
|
823
|
+
|
|
824
|
+
type DropState = 'empty' | 'developing' | 'done';
|
|
825
|
+
interface DroppedImage {
|
|
826
|
+
file: File | null;
|
|
827
|
+
src: string;
|
|
828
|
+
width: number;
|
|
829
|
+
height: number;
|
|
830
|
+
}
|
|
831
|
+
interface DropzoneOptions extends KitOptions {
|
|
832
|
+
/** Called once an image has been accepted and drawn. */
|
|
833
|
+
onImage?: (image: DroppedImage) => void;
|
|
834
|
+
/** Called when a file is refused: not an image, or over `maxBytes`. */
|
|
835
|
+
onError?: (message: string, file: File) => void;
|
|
836
|
+
/** Largest file accepted, in bytes. Default 10 MB. */
|
|
837
|
+
maxBytes?: number;
|
|
838
|
+
/** Ms the image takes to develop in characters. Default 720. */
|
|
839
|
+
develop?: number;
|
|
840
|
+
/** File name for `download()`. Default `<name>-ascii.png`. */
|
|
841
|
+
filename?: string;
|
|
842
|
+
}
|
|
843
|
+
interface DropzoneHandle extends KitHandle<DropzoneOptions> {
|
|
844
|
+
/** Shows an image (a URL, Blob or File), developing it in characters. */
|
|
845
|
+
setImage(src: string | Blob): Promise<void>;
|
|
846
|
+
/** Back to the empty zone. */
|
|
847
|
+
clear(): void;
|
|
848
|
+
/** Opens the file picker. */
|
|
849
|
+
pick(): void;
|
|
850
|
+
/** Saves the image as drawn in characters, as a PNG. Resolves with the Blob, or null without the field or an image. */
|
|
851
|
+
download(filename?: string): Promise<Blob | null>;
|
|
852
|
+
readonly state: DropState;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* An image dropzone whose border is a quiet ring of characters that thickens and breathes while a file is dragged over.
|
|
856
|
+
* A dropped image develops in characters, in its own colours. Any element inside with `data-dropzone="pick"`, `"clear"`
|
|
857
|
+
* or `"download"` is wired to that action. Without content of your own it adds a title, hint and Choose file button.
|
|
858
|
+
*/
|
|
859
|
+
declare function dropzone(element: HTMLElement, options?: DropzoneOptions): DropzoneHandle;
|
|
860
|
+
|
|
861
|
+
interface DisintegrateOptions extends KitOptions {
|
|
862
|
+
/** Ms the characters take to drift away. Default 620. */
|
|
863
|
+
duration?: number;
|
|
864
|
+
/** Close the row's height once the characters are on their way. Default true. */
|
|
865
|
+
collapse?: boolean;
|
|
866
|
+
/** Remove the row from the DOM at the end. Default false: it is left hidden and collapsed, for your framework to remove. */
|
|
867
|
+
remove?: boolean;
|
|
868
|
+
/** The element the field is drawn over. Default the row's parent, so the characters can drift past the row's own box. */
|
|
869
|
+
host?: HTMLElement;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Deletes a row into characters: its text and icons become glyphs that thin out from the right and drift up and away,
|
|
873
|
+
* while the row closes up. Resolves when it is done. Without WebGL2, or under reduced motion, the row closes at once.
|
|
874
|
+
*/
|
|
875
|
+
declare function disintegrate(row: HTMLElement, options?: DisintegrateOptions): Promise<void>;
|
|
876
|
+
|
|
877
|
+
type PullState = 'idle' | 'pulling' | 'refreshing' | 'done';
|
|
878
|
+
interface PullRefreshOptions extends KitOptions {
|
|
879
|
+
/** Runs the refresh. The spinner turns until its promise settles. */
|
|
880
|
+
onRefresh: () => unknown;
|
|
881
|
+
/** The element that moves down with the pull. Default the first child. */
|
|
882
|
+
content?: HTMLElement | null;
|
|
883
|
+
/** Pull distance in px that triggers a refresh on release. Default 88. */
|
|
884
|
+
threshold?: number;
|
|
885
|
+
/** What a screen reader hears. */
|
|
886
|
+
messages?: {
|
|
887
|
+
refreshing?: string;
|
|
888
|
+
done?: string;
|
|
889
|
+
failed?: string;
|
|
890
|
+
};
|
|
891
|
+
/** A selector for the rows `onRefresh` added, such as `'[data-new]'`: they resolve in from characters as the content springs back. Each row is revealed once. */
|
|
892
|
+
reveal?: string;
|
|
893
|
+
}
|
|
894
|
+
interface PullRefreshHandle extends KitHandle<PullRefreshOptions> {
|
|
895
|
+
/** Refreshes as if pulled, for a Refresh button or a keyboard shortcut. */
|
|
896
|
+
refresh(): Promise<void>;
|
|
897
|
+
/** Resolves these rows in from characters: they appear as glyphs of their own text and media, then hand over to the HTML. */
|
|
898
|
+
revealRows(rows: Iterable<Element>): void;
|
|
899
|
+
readonly state: PullState;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Pull to refresh: dragging the content down at the top gathers an orb of characters in the gap, which tightens into a
|
|
903
|
+
* ring at the threshold. Let go past it and the ring spins while `onRefresh` runs, then draws a check and springs back.
|
|
904
|
+
*/
|
|
905
|
+
declare function pullRefresh(element: HTMLElement, options: PullRefreshOptions): PullRefreshHandle;
|
|
906
|
+
|
|
907
|
+
export { type AccordionHandle, type AccordionImage, type AccordionOptions, type ArtPanelHandle, type ArtPanelOptions, type AsciiVideoHandle, type AsciiVideoOptions, BEAM_PALETTES, type BeamHandle, type BeamMode, type BeamOptions, type BeamPalette, type BlockChartHandle, type BlockChartOptions, type Box, type ButtonLoadingHandle, type ButtonLoadingOptions, type ButtonState, type CodeInputHandle, type CodeInputOptions, type CodeState, type CommandPaletteHandle, type CommandPaletteOptions, type CompareHandle, type CompareOptions, type DecodeHandle, type DecodeOptions, type DisintegrateOptions, type DropState, type DroppedImage, type DropzoneHandle, type DropzoneOptions, type FieldBackgroundHandle, type FieldBackgroundOptions, type FieldPreset, type GenerateState, type ImageGenerateHandle, type ImageGenerateOptions, type ImageStream, type ImageUpdate, type KitHandle, type KitOptions, type LikeBurstHandle, type LikeBurstOptions, type LikeMark, type OdometerHandle, type OdometerOptions, type OrbState, PILL_TONES, type PageDissolveHandle, type PageDissolveOptions, type PaintFrame, type PillHandle, type PillOptions, type PillTone, type PricingGlowHandle, type PricingGlowOptions, type PullRefreshHandle, type PullRefreshOptions, type PullState, type SkeletonBlock, type SkeletonHandle, type SkeletonOptions, type SlideToConfirmHandle, type SlideToConfirmOptions, type StatusOrbHandle, type StatusOrbOptions, type StreamState, type StreamTextHandle, type StreamTextOptions, type Surface, type SurfaceConfig, type SwipeDeckHandle, type SwipeDeckOptions, type TabsHandle, type TabsOptions, type ThinkingHandle, type ThinkingOptions, type ThinkingState, type Toast, type ToastStackHandle, type ToastStackOptions, VOICE_PALETTES, type VoiceOrbHandle, type VoiceOrbOptions, type VoicePalette, type VoiceState, type WordmarkHandle, type WordmarkOptions, accordion, artPanel, asciiVideo, beam, beamPalette, blockChart, buttonLoading, codeInput, commandPalette, compare, decode, disintegrate, dropzone, fieldBackground, imageGenerate, likeBurst, mountSurface, odometer, pageDissolve, pill, pricingGlow, pullRefresh, resolveColor, skeleton, slideToConfirm, statusOrb, streamText, swipeDeck, tabs, thinking, toastStack, voiceOrb, wordmark };
|