@tioniq/sceniq 0.0.0-stage → 0.1.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.
@@ -0,0 +1,590 @@
1
+ import { IDisposable, Disposiq } from '@tioniq/disposiq';
2
+ import { EventObserver, Var, VarOrVal } from '@tioniq/eventiq';
3
+ import { P as Point, R as RectBounds, j as Drawable, V as View, S as Size, q as PointerObserver, A as AddExternalElementOptions } from './rect-bounds-Bd7-7ERA.js';
4
+
5
+ /**
6
+ * Keyboard input of a focusable element. Nothing is prevented by default: Tab, browser shortcuts and
7
+ * typing keep working, and a handler calls {@link KeyboardObserveEvent.preventDefault} only for the
8
+ * keys it handles.
9
+ */
10
+ declare class KeyboardObserver implements IDisposable {
11
+ private readonly _listeners;
12
+ readonly onKeyDown: EventObserver<KeyboardObserveEvent>;
13
+ readonly onKeyUp: EventObserver<KeyboardObserveEvent>;
14
+ constructor(element: HTMLElement);
15
+ /** Removes every key listener, whoever still subscribes; nothing is raised afterwards. The scene calls it. */
16
+ dispose(): void;
17
+ }
18
+ interface KeyboardObserveEvent {
19
+ readonly altKey: boolean;
20
+ readonly ctrlKey: boolean;
21
+ readonly shiftKey: boolean;
22
+ readonly metaKey: boolean;
23
+ readonly key: string;
24
+ readonly code: string;
25
+ /** Whether the key is held down and this event is an auto-repeat. */
26
+ readonly repeat: boolean;
27
+ /** Marks the key as handled: the browser's own action for it is not taken. */
28
+ preventDefault(): void;
29
+ readonly defaultPrevented: boolean;
30
+ }
31
+
32
+ /**
33
+ * An easing: maps linear progress from 0 to 1 to eased progress. Overshooting easings may leave the
34
+ * range on the way. The usual ones are in {@link animationInterpolators}.
35
+ */
36
+ declare abstract class AnimationInterpolator {
37
+ abstract interpolate(progress: number): number;
38
+ }
39
+ declare class LinearInterpolator extends AnimationInterpolator {
40
+ interpolate(progress: number): number;
41
+ }
42
+ declare class EaseInInterpolator extends AnimationInterpolator {
43
+ interpolate(progress: number): number;
44
+ }
45
+ declare class EaseOutInterpolator extends AnimationInterpolator {
46
+ interpolate(progress: number): number;
47
+ }
48
+ declare class EaseInOutInterpolator extends AnimationInterpolator {
49
+ interpolate(progress: number): number;
50
+ }
51
+ declare class BounceInterpolator extends AnimationInterpolator {
52
+ interpolate(t: number): number;
53
+ }
54
+ declare class OvershootInterpolator extends AnimationInterpolator {
55
+ private readonly _tension;
56
+ constructor(tension: number);
57
+ interpolate(progress: number): number;
58
+ }
59
+ /** Ready-made easings for {@link tween}, camera animations and {@link FrameScheduler.animate}. */
60
+ declare const animationInterpolators: {
61
+ linear: LinearInterpolator;
62
+ easeIn: EaseInInterpolator;
63
+ easeOut: EaseOutInterpolator;
64
+ easeInOut: EaseInOutInterpolator;
65
+ bounce: BounceInterpolator;
66
+ overshoot: OvershootInterpolator;
67
+ };
68
+
69
+ interface FrameSchedulerOptions {
70
+ /**
71
+ * Asks for `callback` to run before the next frame. Defaults to `requestAnimationFrame`, read when
72
+ * a frame is first needed, so creating a scheduler touches no DOM. Tests and non-browser hosts pass
73
+ * their own.
74
+ */
75
+ readonly requestFrame?: (callback: () => void) => unknown;
76
+ /**
77
+ * Receives an error thrown while a frame ran: by a scheduled action, a frame listener, an
78
+ * animation step, or a view's layout or drawing. Default `console.error`. The frame carries on with
79
+ * everything else.
80
+ */
81
+ readonly onError?: (error: unknown) => void;
82
+ }
83
+ /**
84
+ * Runs frames on demand: a frame is requested only when something is scheduled or someone holds the
85
+ * loop, so an idle scene costs nothing.
86
+ *
87
+ * Every {@link Scene} and {@link Surface} draws and animates through one scheduler. By default they
88
+ * all share {@link defaultScheduler}, so every scene on the page draws in the same frame; pass
89
+ * `scheduler` in their options to give a scene its own loop (for example to drive it by hand in tests).
90
+ */
91
+ declare class FrameScheduler {
92
+ private readonly _onUpdate;
93
+ private readonly _reportError;
94
+ private readonly _actions;
95
+ private readonly _requestFrame;
96
+ private _autoUpdate;
97
+ /** Holders of the frame loop (see acquireAutoUpdate); the loop runs while any holds it. */
98
+ private _holders;
99
+ private _scheduled;
100
+ private _updating;
101
+ /**
102
+ * Receives errors thrown while a frame runs (see {@link FrameSchedulerOptions.onError}). Default
103
+ * `console.error`.
104
+ */
105
+ onError: (error: unknown) => void;
106
+ constructor(options?: FrameSchedulerOptions);
107
+ /** Hands an error to {@link onError}; an error thrown by the handler itself goes to the console. */
108
+ reportError(error: unknown): void;
109
+ get updating(): boolean;
110
+ /**
111
+ * Raised once per frame, after the actions passed to {@link scheduleUpdate}. Scenes draw here. A
112
+ * listener that throws is reported to {@link onError} and does not stop the others.
113
+ */
114
+ get onUpdate(): EventObserver<void>;
115
+ /** Whether a frame is requested after every frame: the flag is set, or someone holds the loop. */
116
+ get autoUpdate(): boolean;
117
+ set autoUpdate(value: boolean);
118
+ /** How many hold the frame loop now. */
119
+ get holders(): number;
120
+ /**
121
+ * Keeps the frame loop running until the returned release is called. Every animation holds it for
122
+ * its own life, so the first of two overlapping animations to finish does not stop the frames the
123
+ * other still needs. Releasing twice does nothing.
124
+ */
125
+ acquireAutoUpdate(): () => void;
126
+ /** Requests a frame, running `action` at its start. Requests made before the frame share it. */
127
+ scheduleUpdate(action?: () => void): void;
128
+ /**
129
+ * Runs `callback` once per frame with the eased progress from 0 to 1 over `duration` milliseconds,
130
+ * holding the frame loop meanwhile. Disposing the result stops it early. A callback that throws
131
+ * stops the animation (without `onFinished`) and is reported to {@link onError}.
132
+ */
133
+ animate(callback: (progress: number) => void, options?: {
134
+ readonly duration?: number;
135
+ readonly interpolate?: (progress: number) => number;
136
+ readonly onFinished?: () => void;
137
+ readonly now?: () => number;
138
+ }): {
139
+ dispose(): void;
140
+ };
141
+ private _update;
142
+ }
143
+ /** The scheduler every scene and surface uses unless given another. */
144
+ declare const defaultScheduler: FrameScheduler;
145
+
146
+ interface CameraOptions {
147
+ /** Device pixels per CSS pixel. The matrix includes it, so world units are CSS pixels at zoom 1. */
148
+ dpr?: Var<number>;
149
+ /** The frame loop animations run on. Defaults to {@link defaultScheduler}. */
150
+ scheduler?: FrameScheduler;
151
+ }
152
+ interface ZoomData {
153
+ zoom: number;
154
+ anchor?: Point;
155
+ }
156
+ type ZoomInterceptor = (data: ZoomData, currentZoom: number) => ZoomData | void | "ignore";
157
+ /**
158
+ * The view transform of a {@link Surface}: a mutable matrix from world coordinates to the surface's
159
+ * device pixels. It includes the device pixel ratio, so `currentZoom` 1 shows one world unit per CSS
160
+ * pixel. Zoom anchors are in world coordinates; {@link cssToWorld} converts a CSS-pixel
161
+ * position (such as a pointer event's) to one.
162
+ */
163
+ declare class Camera implements IDisposable {
164
+ private readonly _onMatrixChanged;
165
+ private readonly _zoom;
166
+ private readonly _matrix;
167
+ private readonly _zoomInterceptors;
168
+ private readonly _context;
169
+ private readonly _dpr;
170
+ private readonly _scheduler;
171
+ private readonly _disposables;
172
+ private _animation;
173
+ /** The inverse of the matrix, computed when first needed after a change. */
174
+ private _inverse;
175
+ /** @param context The context whose canvas the camera shows; its size is the screen. */
176
+ constructor(context: CanvasRenderingContext2D, options?: CameraOptions);
177
+ dispose(): void;
178
+ get onMatrixChanged(): EventObserver<DOMMatrixReadOnly>;
179
+ /**
180
+ * How many CSS pixels one world unit takes on screen: 1 at the start. The device pixel ratio is
181
+ * never part of it (the matrix has it on top). Derived from the matrix after every change, however
182
+ * the camera was moved.
183
+ */
184
+ get currentZoom(): Var<number>;
185
+ /**
186
+ * World to the surface's device pixels, the device pixel ratio included. Read-only: change it with
187
+ * {@link setMatrix}, {@link zoom} or {@link pan}, so listeners hear of it.
188
+ */
189
+ get matrix(): DOMMatrixReadOnly;
190
+ get dpr(): Var<number>;
191
+ /** Device pixels to world: the inverse of {@link Camera.matrix}, kept until the matrix changes. */
192
+ get inverseMatrix(): DOMMatrixReadOnly;
193
+ /** The frame loop the camera's animations run on. */
194
+ get scheduler(): FrameScheduler;
195
+ /** Whether an animation of this camera is running. */
196
+ get animating(): boolean;
197
+ /** Stops the running animation, if any, where it is. Pan and zoom controls call it when touched. */
198
+ stopAnimation(): void;
199
+ addZoomInterceptor(interceptor: ZoomInterceptor): Disposiq;
200
+ /**
201
+ * Multiplies the zoom by `zoom` about `anchor` (world coordinates; the world origin by default),
202
+ * after the zoom interceptors (`minZoom`/`maxZoom` among them) had their say. False when nothing
203
+ * changed.
204
+ */
205
+ zoom(zoom: number, anchor?: Point): boolean;
206
+ /**
207
+ * Replaces the matrix (device pixels, the device pixel ratio included, like {@link Camera.matrix}). A zoom
208
+ * outside the interceptors' limits is brought within them about the middle of the screen.
209
+ */
210
+ setMatrix(matrix: DOMMatrixReadOnly): void;
211
+ /** Sets the zoom to `zoom` about `anchor` (world coordinates), within the interceptors' limits. */
212
+ zoomTo(zoom: number, anchor?: Point): boolean;
213
+ pan(delta: Point): void;
214
+ /** After the matrix's scale changed: the zoom follows from it, then listeners hear of it. */
215
+ private _changed;
216
+ panTo(point: Point): void;
217
+ panCenterTo(point: Point): void;
218
+ panCenterToAnimated(point: Point, animationOptions?: CameraAnimationOptions): IDisposable;
219
+ zoomToAnimated(zoom: number, options?: CameraZoomAnimationOptions): IDisposable;
220
+ /** Shows world point `center` in the middle of the screen at `zoom`, in one step. */
221
+ setView(center: Point, zoom: number): void;
222
+ /**
223
+ * Moves to `center` and `zoom` over time: the centre moves in a straight line and the zoom changes
224
+ * by the same factor every frame, so zooming far in or out looks even. Starting another animation, or
225
+ * {@link stopAnimation}, stops it.
226
+ */
227
+ flyTo(center: Point, zoom: number, options?: CameraAnimationOptions): IDisposable;
228
+ /**
229
+ * The centre and zoom that fit `rect` (world units) on screen, inside `padding` CSS pixels, within
230
+ * the zoom interceptors' limits (those of `attachZoomPan`'s `minZoom` and `maxZoom` among them).
231
+ */
232
+ viewForBounds(rect: RectBounds, padding?: CameraPadding): {
233
+ center: Point;
234
+ zoom: number;
235
+ };
236
+ /**
237
+ * Zooms and pans so `rect` (world units) fills the screen inside `padding`. With `animate` it flies
238
+ * there (see {@link flyTo}); the result stops the animation. The zoom stays within the interceptors'
239
+ * limits and `maxZoom`, so fitting a single point does not zoom in forever.
240
+ */
241
+ fitBounds(rect: RectBounds, options?: FitBoundsOptions): IDisposable;
242
+ /** `zoom` brought within the zoom interceptors' limits, as `zoom()` would bring it. */
243
+ limitZoom(zoom: number): number;
244
+ getCurrentPan(): Point;
245
+ getScreenCenter(): Point;
246
+ getScreenCenterWorld(): Point;
247
+ getCurrentEnd(): Point;
248
+ /** A point in CSS pixels from the surface's top-left (a pointer event's position) in world coordinates. */
249
+ cssToWorld(point: Point): Point;
250
+ /** A point in the surface's device pixels in world coordinates. */
251
+ deviceToWorld(point: Point): Point;
252
+ /** A world point in CSS pixels from the surface's top-left. */
253
+ worldToCss(point: Point): Point;
254
+ /** A world point in the surface's device pixels. */
255
+ worldToDevice(point: Point): Point;
256
+ private _animate;
257
+ }
258
+ /** Room kept clear at the screen's edges, in CSS pixels: one number for all four, or each side. */
259
+ type CameraPadding = number | {
260
+ readonly top?: number;
261
+ readonly right?: number;
262
+ readonly bottom?: number;
263
+ readonly left?: number;
264
+ };
265
+ interface FitBoundsOptions {
266
+ /** Room kept clear at the edges, in CSS pixels. Default 0. */
267
+ readonly padding?: CameraPadding;
268
+ /** Flies there instead of jumping: true for half a second, eased, or the animation's options. */
269
+ readonly animate?: boolean | CameraAnimationOptions;
270
+ /** The largest zoom to use, so a tiny rectangle is not blown up. */
271
+ readonly maxZoom?: number;
272
+ }
273
+ interface CameraZoomAnimationOptions extends CameraAnimationOptions {
274
+ readonly anchor?: Point;
275
+ }
276
+ interface CameraAnimationOptions {
277
+ readonly interpolator?: AnimationInterpolator;
278
+ readonly onFinished?: () => void;
279
+ readonly duration?: number;
280
+ /** Animates even when the user prefers reduced motion; by default such a user gets the end at once. */
281
+ readonly ignoreReducedMotion?: boolean;
282
+ }
283
+ declare function createMinMaxZoomInterceptor(minZoom: number | undefined, maxZoom: number | undefined): ZoomInterceptor;
284
+
285
+ interface LayerOptions {
286
+ /**
287
+ * Skips laying out a view that has not changed since its last layout and lies well off screen,
288
+ * instead of laying out every view on every frame. For layers of views placed in scene
289
+ * coordinates whose bounds do not depend on the camera (zoom-dependent sizes come through
290
+ * variables, which mark the view changed).
291
+ */
292
+ readonly skipOffscreenLayout?: boolean;
293
+ }
294
+
295
+ /**
296
+ * An ordered list of views and drawables painted into one offscreen bitmap of a {@link Surface}.
297
+ * The layer repaints completely when any component changed, a component's visibility changed, or the
298
+ * camera moved; otherwise the surface reuses its last bitmap.
299
+ */
300
+ declare class Layer implements IDisposable {
301
+ private readonly context;
302
+ private readonly _name;
303
+ private readonly _canvas;
304
+ private readonly _components;
305
+ /** The components by what they paint, so removing one does not search the list. */
306
+ private readonly _byItem;
307
+ private readonly _onInvalidate;
308
+ private _previousTransform;
309
+ private readonly _skipOffscreenLayout;
310
+ private _disposed;
311
+ /** `layoutEpoch()` when the layer last painted: a newer epoch means its layouts may be stale. */
312
+ private _paintedEpoch;
313
+ /** Something changed since the last frame: the layer must lay out and check its components. */
314
+ private _changed;
315
+ constructor(canvas: Surface, context: CanvasRenderingContext2D, _name: string, options?: LayerOptions);
316
+ get name(): string;
317
+ get onInvalidate(): EventObserver<void>;
318
+ /** The surface this layer belongs to. */
319
+ get surface(): Surface;
320
+ /** Adds a component; the same as {@link addComponent}. */
321
+ add(item: Drawable | View, order?: VarOrVal<number>): Disposiq;
322
+ addComponent(item: Drawable | View, order?: VarOrVal<number>): Disposiq;
323
+ /** Adds many components; disposing the result removes them all in one pass. */
324
+ addComponents(items: (Drawable | View)[], order?: VarOrVal<number>): Disposiq;
325
+ removeComponent(item: Drawable | View): void;
326
+ /** Removes many components in one pass over the list, with one invalidation. */
327
+ removeComponents(items: Iterable<Drawable | View>): void;
328
+ /** Whether {@link dispose} was called. */
329
+ get disposed(): boolean;
330
+ /**
331
+ * Removes the layer from its surface, detaches every component (views stop following their
332
+ * variables and their `onMounted` cleanups run) and releases the layer's bitmap. A surface disposes
333
+ * its layers when it is disposed or when {@link Surface.removeLayer} removes one.
334
+ */
335
+ dispose(): void;
336
+ private _throwIfDisposed;
337
+ invalidateForce(): void;
338
+ private _invalidate;
339
+ private _layoutAndPaint;
340
+ private _canDraw;
341
+ private _reportError;
342
+ private _addComponent;
343
+ }
344
+
345
+ interface SurfaceOptions {
346
+ name?: string;
347
+ /** Device pixels per CSS pixel; a scene passes its own. */
348
+ dpr?: VarOrVal<number>;
349
+ /** The frame loop this surface's animations run on. Defaults to {@link defaultScheduler}. */
350
+ scheduler?: FrameScheduler;
351
+ }
352
+ interface CreateLayerOptions extends LayerOptions {
353
+ /** Whether the layer follows the surface's camera (default) or stays fixed in screen space. */
354
+ attachCamera?: boolean;
355
+ name?: string;
356
+ }
357
+ /**
358
+ * An offscreen drawing area placed in a {@link Scene}, with its own {@link Camera} and ordered
359
+ * {@link Layer}s. A scene composites its surfaces every frame; a surface whose layers did not change is
360
+ * not redrawn.
361
+ *
362
+ * Every layer is a full-resolution offscreen bitmap, so memory grows with the number of layers.
363
+ */
364
+ declare class Surface implements IDisposable {
365
+ private readonly _disposables;
366
+ private readonly _layers;
367
+ private readonly _parentScenes;
368
+ private readonly _onInvalidate;
369
+ private readonly _onDispose;
370
+ private readonly _onDraw;
371
+ private readonly _cursorPosition;
372
+ private readonly _context;
373
+ private readonly _camera;
374
+ private readonly _size;
375
+ private readonly _dpr;
376
+ private readonly _name;
377
+ private readonly _scheduler;
378
+ /** Zoom-level picks shared by all of this surface's layers. */
379
+ private readonly _zoomLevels;
380
+ private _previousPointerTarget;
381
+ private _dirty;
382
+ constructor(options?: SurfaceOptions);
383
+ get name(): string;
384
+ get context(): CanvasRenderingContext2D;
385
+ get camera(): Camera;
386
+ get scheduler(): FrameScheduler;
387
+ get dpr(): Var<number>;
388
+ get size(): Var<Size>;
389
+ /** Sets the size in device pixels, rounded down to whole pixels as a canvas is. */
390
+ set size(value: Size);
391
+ get layers(): ReadonlyArray<Layer>;
392
+ /**
393
+ * How far a point of the scene is from the middle of what this surface shows, in half-diagonals of
394
+ * the surface: 0 at the middle, 1 at a corner, more off screen.
395
+ */
396
+ viewDistance(x: number, y: number): number;
397
+ get disposed(): boolean;
398
+ get onInvalidate(): EventObserver;
399
+ /** Raised after every redraw of this surface. */
400
+ get onDraw(): EventObserver;
401
+ get onDispose(): EventObserver;
402
+ /** The last pointer position over this surface, in world coordinates. */
403
+ get cursorPosition(): Var<Point>;
404
+ get keyboardObserver(): KeyboardObserver;
405
+ createLayer(order?: number, options?: CreateLayerOptions): Layer;
406
+ /** Removes a layer created by {@link createLayer} and disposes it (see {@link Layer.dispose}). */
407
+ removeLayer(layer: Layer): void;
408
+ /** Makes every layer lay out and paint again on the next frame, as after a font finished loading. */
409
+ invalidateLayers(): void;
410
+ /**
411
+ * Calls `callback` every frame with the eased progress from 0 to 1, for `time` milliseconds
412
+ * (default 1000). Disposing the result stops it early.
413
+ */
414
+ animate(callback: (progress: number) => void, optionsOrTime?: number | {
415
+ time?: number;
416
+ interpolator?: AnimationInterpolator;
417
+ onFinished?: () => void;
418
+ }): Disposiq;
419
+ dispose(): void;
420
+ private _redraw;
421
+ }
422
+
423
+ interface SceneOptions {
424
+ /** The frame loop the scene draws on. Defaults to {@link defaultScheduler}, shared by every scene. */
425
+ readonly scheduler?: FrameScheduler;
426
+ /**
427
+ * The CSS `touch-action` set on the canvas. Default `"none"`, so touch drags and pinches reach the
428
+ * scene instead of scrolling or zooming the page. Null leaves the canvas's own style alone.
429
+ */
430
+ readonly touchAction?: string | null;
431
+ /** Captures a pointer that goes down on the canvas, so a drag continues outside it. Default true. */
432
+ readonly pointerCapture?: boolean;
433
+ /** Focuses the canvas when a pointer goes down on it, so it receives keys. Default true. */
434
+ readonly focusOnPointerDown?: boolean;
435
+ /** How far (CSS pixels) a pointer may move between down and up and still click a view. Default 5. */
436
+ readonly clickSlop?: number;
437
+ /** See {@link Scene.clickDelay}. Default 0: clicks are delivered at once. */
438
+ readonly clickDelay?: number;
439
+ }
440
+ /**
441
+ * The root of a drawing: owns a DOM `<canvas>`, keeps its bitmap matched to its CSS size and the
442
+ * device pixel ratio, observes its pointer and keyboard input, and composites its {@link Surface}s
443
+ * whenever one of them changed.
444
+ *
445
+ * Constructing a scene attaches listeners to the canvas, the window and `document.fonts`;
446
+ * {@link dispose} removes them all.
447
+ */
448
+ declare class Scene implements IDisposable {
449
+ private readonly _context;
450
+ private readonly _disposables;
451
+ private readonly _surfaces;
452
+ private readonly _measurer;
453
+ private readonly _keyboardObserver;
454
+ private readonly _pointerObserver;
455
+ private readonly _scheduler;
456
+ private readonly _dpr;
457
+ /** Multiplies the device pixel ratio while an export draws the scene larger. */
458
+ private readonly _exportScale;
459
+ private readonly _onFrame;
460
+ private _frame;
461
+ /** Something changed since the last composite; a clean scene draws nothing in a frame. */
462
+ private _dirty;
463
+ private readonly _size;
464
+ private readonly _focusOnPointerDown;
465
+ private _activeEventCursor;
466
+ private _defaultCursor;
467
+ /** Set while more than one pointer is down: a gesture, not a press, so views get no input. */
468
+ private _gesture;
469
+ private readonly _clickSlop;
470
+ private _clickDelay;
471
+ /** A click held back by clickDelay, waiting to see whether a second press makes a double-click. */
472
+ private _pendingClick;
473
+ /** Where the current press went down (CSS pixels), for the click it may make. */
474
+ private _pressPosition;
475
+ /** The current press is the second of a double-click: its click is dropped. */
476
+ private _swallowClick;
477
+ /** Logs what every frame drew to the console. */
478
+ debug: boolean;
479
+ constructor(_context: CanvasRenderingContext2D, options?: SceneOptions);
480
+ /** The canvas's size in device pixels. */
481
+ get size(): Var<Size>;
482
+ get dpr(): Var<number>;
483
+ get scheduler(): FrameScheduler;
484
+ /**
485
+ * Raised after every frame the scene draws, with what it drew and how long it took: for a frame
486
+ * counter, a stats overlay (see {@link FrameStatsMonitor}) or a performance test. Not raised for frames
487
+ * in which nothing changed, because none are drawn.
488
+ */
489
+ get onFrame(): EventObserver<FrameInfo>;
490
+ /**
491
+ * The scene as a picture: drawn again at `scale` times its pixels (default 1: as on screen, device
492
+ * pixel ratio included), then encoded. Views see a larger device pixel ratio while it draws, so text,
493
+ * strokes and cached bitmaps are sharp at the larger size. The canvas on the page is put back before
494
+ * this returns, so nothing flickers. Images still loading are drawn as they are at that moment.
495
+ */
496
+ toBlob(options?: SceneExportOptions): Promise<Blob>;
497
+ /** The scene as a data URL; see {@link toBlob}. */
498
+ toDataURL(options?: SceneExportOptions): string;
499
+ /** Draws the scene at an export scale into a new canvas and puts the page's canvas back. */
500
+ private _renderCopy;
501
+ get container(): HTMLCanvasElement;
502
+ get surfaces(): ReadonlyArray<Surface>;
503
+ get keyboardObserver(): KeyboardObserver;
504
+ get pointerObserver(): PointerObserver;
505
+ /** The cursor shown when no view under the pointer asks for one. */
506
+ get cursor(): string;
507
+ set cursor(value: string);
508
+ /** Creates a surface that follows this scene's DPR and scheduler, and adds it. */
509
+ createSurface(options?: SurfaceCreateOptions): Surface;
510
+ removeSurface(surface: Surface): void;
511
+ /**
512
+ * Where a surface lies in the scene, in device pixels; null when it is not in this scene. Input
513
+ * controllers use it to map pointer positions into the surface.
514
+ */
515
+ surfaceBounds(surface: Surface): RectBounds | null;
516
+ /**
517
+ * Adds a surface, placed at `rect` in device pixels (following it when it is a variable), or over
518
+ * the whole scene when `rect` is not given.
519
+ */
520
+ addSurface(surface: Surface, order?: number, rect?: VarOrVal<RectBounds>): void;
521
+ /**
522
+ * Milliseconds a view's click is held back to tell it from a double-click: a second press near it
523
+ * within that time makes a double-click, and neither click reaches the views. 0 (the default)
524
+ * delivers clicks at once. `attachZoomPan` with `doubleClickZoom` sets it, so a double-click zooms
525
+ * without also clicking what is under the pointer twice.
526
+ */
527
+ get clickDelay(): number;
528
+ set clickDelay(value: number);
529
+ /** Delivers a click at once, or holds it back for clickDelay. */
530
+ private _deliverClick;
531
+ /** Delivers a held click now (a press elsewhere means it was a single click). */
532
+ private _flushPendingClick;
533
+ /** A press begins: if it is the second of a double-click, the held click and its own are dropped. */
534
+ private _onPress;
535
+ /**
536
+ * Requests a frame in which the scene composites its surfaces again; surfaces that did not change
537
+ * are composited from their last bitmap. A scene nothing changed in draws nothing in a frame, even
538
+ * when other scenes on the same scheduler do.
539
+ */
540
+ redraw(): void;
541
+ addExternalPointerElement(element: HTMLElement, options?: AddExternalElementOptions): Disposiq;
542
+ simulateMouseLeave(): void;
543
+ dispose(): void;
544
+ private _draw;
545
+ private _initPointerEvents;
546
+ }
547
+ interface SceneExportOptions {
548
+ /** How many times the scene's pixels to draw. Default 1. Reduced if the browser could not hold it. */
549
+ readonly scale?: number;
550
+ /** The image type, `"image/png"` (default), `"image/jpeg"` or `"image/webp"`. */
551
+ readonly type?: string;
552
+ /** For JPEG and WebP: 0 to 1. */
553
+ readonly quality?: number;
554
+ /** A colour filled under the scene; by default what the scene leaves clear stays transparent. */
555
+ readonly background?: string;
556
+ }
557
+ /** What one frame drew. */
558
+ interface FrameInfo {
559
+ /** Counts the frames the scene drew, from 1. */
560
+ readonly frame: number;
561
+ /** When the frame started, from `performance.now()`. */
562
+ readonly startTime: number;
563
+ /** How long the scene took to draw, in milliseconds. */
564
+ readonly time: number;
565
+ readonly surfaces: readonly FrameSurfaceInfo[];
566
+ /** The names of the layers drawn again in this frame (the others reused their bitmaps). */
567
+ readonly redrawnLayers: readonly string[];
568
+ }
569
+ interface FrameSurfaceInfo {
570
+ readonly name: string;
571
+ /** False when the surface reused its last bitmap. */
572
+ readonly drawn: boolean;
573
+ readonly time: number;
574
+ readonly layers: readonly FrameLayerInfo[];
575
+ }
576
+ interface FrameLayerInfo {
577
+ readonly name: string;
578
+ /** False when the layer reused its last bitmap. */
579
+ readonly drawn: boolean;
580
+ readonly time: number;
581
+ readonly components: number;
582
+ }
583
+ interface SurfaceCreateOptions {
584
+ order?: number;
585
+ name?: string;
586
+ /** Where the surface lies in the scene, in device pixels. Defaults to the whole scene. */
587
+ rect?: VarOrVal<RectBounds>;
588
+ }
589
+
590
+ export { AnimationInterpolator as A, BounceInterpolator as B, Camera as C, EaseInInterpolator as E, FrameScheduler as F, type KeyboardObserveEvent as K, Layer as L, OvershootInterpolator as O, Scene as S, type ZoomData as Z, Surface as a, type CameraAnimationOptions as b, type CameraOptions as c, type CameraPadding as d, type CameraZoomAnimationOptions as e, type CreateLayerOptions as f, EaseInOutInterpolator as g, EaseOutInterpolator as h, type FitBoundsOptions as i, type FrameInfo as j, type FrameLayerInfo as k, type FrameSchedulerOptions as l, type FrameSurfaceInfo as m, KeyboardObserver as n, type LayerOptions as o, LinearInterpolator as p, type SceneExportOptions as q, type SceneOptions as r, type SurfaceCreateOptions as s, type SurfaceOptions as t, type ZoomInterceptor as u, animationInterpolators as v, createMinMaxZoomInterceptor as w, defaultScheduler as x };