autokast 0.0.0 → 0.1.1

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 (79) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +165 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +300 -0
  5. package/dist/index.d.ts +4 -0
  6. package/dist/index.js +4 -0
  7. package/dist/inspect.d.ts +26 -0
  8. package/dist/inspect.js +193 -0
  9. package/dist/record/animations.d.ts +7 -0
  10. package/dist/record/animations.js +34 -0
  11. package/dist/record/capture.d.ts +85 -0
  12. package/dist/record/capture.js +202 -0
  13. package/dist/record/cast.d.ts +142 -0
  14. package/dist/record/cast.js +680 -0
  15. package/dist/record/cursor-style.d.ts +33 -0
  16. package/dist/record/cursor-style.js +252 -0
  17. package/dist/record/defaults.d.ts +96 -0
  18. package/dist/record/defaults.js +125 -0
  19. package/dist/record/editor.d.ts +11 -0
  20. package/dist/record/editor.js +48 -0
  21. package/dist/record/frame-pump.d.ts +91 -0
  22. package/dist/record/frame-pump.js +306 -0
  23. package/dist/record/index.d.ts +11 -0
  24. package/dist/record/index.js +287 -0
  25. package/dist/record/motion.d.ts +48 -0
  26. package/dist/record/motion.js +112 -0
  27. package/dist/record/pace.d.ts +69 -0
  28. package/dist/record/pace.js +133 -0
  29. package/dist/record/random.d.ts +12 -0
  30. package/dist/record/random.js +24 -0
  31. package/dist/record/scroll.d.ts +71 -0
  32. package/dist/record/scroll.js +249 -0
  33. package/dist/record/timeline.d.ts +34 -0
  34. package/dist/record/timeline.js +44 -0
  35. package/dist/render/background.d.ts +12 -0
  36. package/dist/render/background.js +209 -0
  37. package/dist/render/browser.d.ts +46 -0
  38. package/dist/render/browser.js +223 -0
  39. package/dist/render/camera.d.ts +119 -0
  40. package/dist/render/camera.js +372 -0
  41. package/dist/render/captions.d.ts +114 -0
  42. package/dist/render/captions.js +254 -0
  43. package/dist/render/color.d.ts +23 -0
  44. package/dist/render/color.js +78 -0
  45. package/dist/render/compositor.d.ts +185 -0
  46. package/dist/render/compositor.js +656 -0
  47. package/dist/render/cursor.d.ts +85 -0
  48. package/dist/render/cursor.js +314 -0
  49. package/dist/render/cursors/shapes.d.ts +34 -0
  50. package/dist/render/cursors/shapes.js +268 -0
  51. package/dist/render/defaults.d.ts +91 -0
  52. package/dist/render/defaults.js +139 -0
  53. package/dist/render/easing.d.ts +13 -0
  54. package/dist/render/easing.js +40 -0
  55. package/dist/render/effects.d.ts +39 -0
  56. package/dist/render/effects.js +91 -0
  57. package/dist/render/encoder.d.ts +52 -0
  58. package/dist/render/encoder.js +226 -0
  59. package/dist/render/index.d.ts +19 -0
  60. package/dist/render/index.js +138 -0
  61. package/dist/render/keycaps.d.ts +67 -0
  62. package/dist/render/keycaps.js +270 -0
  63. package/dist/render/scene.d.ts +59 -0
  64. package/dist/render/scene.js +230 -0
  65. package/dist/render/source.d.ts +21 -0
  66. package/dist/render/source.js +57 -0
  67. package/dist/render/spring.d.ts +11 -0
  68. package/dist/render/spring.js +47 -0
  69. package/dist/render/stage.d.ts +59 -0
  70. package/dist/render/stage.js +91 -0
  71. package/dist/render/timeline.d.ts +70 -0
  72. package/dist/render/timeline.js +157 -0
  73. package/dist/session.d.ts +14 -0
  74. package/dist/session.js +33 -0
  75. package/dist/types.d.ts +708 -0
  76. package/dist/types.js +1 -0
  77. package/package.json +61 -3
  78. package/skills/autokast/SKILL.md +300 -0
  79. package/skills/autokast/reference/jupyterlab.md +100 -0
@@ -0,0 +1,254 @@
1
+ import { createCanvas } from '@napi-rs/canvas';
2
+ import { rgba } from "./color.js";
3
+ import { clamp, easing, smoothstep } from "./easing.js";
4
+ /**
5
+ * Timing of the caption band and text, in output milliseconds.
6
+ */
7
+ export const BAND_DURATION = 700;
8
+ export const MERGE_GAP = 600;
9
+ const REVEAL_DELAY = 400;
10
+ const REVEAL = 640;
11
+ const EXIT = 240;
12
+ const SWAP_GAP = 120;
13
+ const CLOSE_DELAY = 120;
14
+ const MIN_SHOW = 300;
15
+ /**
16
+ * Time to read one line, in milliseconds: the rule of the default caption duration.
17
+ */
18
+ const READ_BASE = 1500;
19
+ const READ_PER_CHAR = 55;
20
+ /**
21
+ * Plans caption cues and band groups. Captions within MERGE_GAP of each other share
22
+ * one open band and only swap their text. `split` breaks the text of a caption into
23
+ * lines: a caption shows one line at a time, and its lines share its duration.
24
+ */
25
+ export function planCaptions(events, split = (text) => [text]) {
26
+ const cues = [];
27
+ const groups = [];
28
+ const sorted = events.filter((e) => e.text.trim()).sort((a, b) => a.out - b.out);
29
+ let last = null;
30
+ for (const e of sorted) {
31
+ const lines = split(e.text.trim());
32
+ const tones = parseCaption(e.text).flatMap((word) => word.runs.map((run) => run.strong));
33
+ const emphasis = tones.includes(true) && tones.includes(false);
34
+ const spans = lineDurations(lines, Math.max(0, e.duration));
35
+ let start = e.out;
36
+ lines.forEach((text, i) => {
37
+ const end = start + spans[i];
38
+ let textIn;
39
+ if (last && start - last.end <= MERGE_GAP) {
40
+ last.textOut = Math.max(last.textIn + MIN_SHOW, Math.min(last.textOut, start));
41
+ textIn = Math.max(start, last.textOut + SWAP_GAP);
42
+ }
43
+ else {
44
+ groups.push({ open: start, close: 0 });
45
+ textIn = start + REVEAL_DELAY;
46
+ }
47
+ last = { text, emphasis, start, end, textIn, textOut: Math.max(textIn + MIN_SHOW, end) };
48
+ cues.push(last);
49
+ groups[groups.length - 1].close = last.textOut + CLOSE_DELAY;
50
+ start = end;
51
+ });
52
+ }
53
+ return { cues, groups };
54
+ }
55
+ /**
56
+ * Shares the duration of a caption between its lines. Each line but the last stays for
57
+ * the time to read it, and the last line gets the rest. When the duration is too short
58
+ * for that, all lines get less time in the same proportion.
59
+ */
60
+ function lineDurations(lines, duration) {
61
+ const read = lines.map((line) => READ_BASE + READ_PER_CHAR * line.replaceAll('**', '').length);
62
+ const total = read.reduce((sum, time) => sum + time, 0);
63
+ if (total > duration)
64
+ return read.map((time) => (time * duration) / total);
65
+ const last = read.length - 1;
66
+ return read.map((time, i) => (i < last ? time : duration - (total - time)));
67
+ }
68
+ const bandEase = easing('smooth');
69
+ /**
70
+ * How far the band is open at output time `t`, 0 to 1 (already eased).
71
+ */
72
+ export function bandAt(groups, t) {
73
+ let p = 0;
74
+ for (const g of groups) {
75
+ const open = bandEase((t - g.open) / BAND_DURATION);
76
+ const close = 1 - bandEase((t - g.close) / BAND_DURATION);
77
+ p = Math.max(p, Math.min(open, close));
78
+ }
79
+ return p;
80
+ }
81
+ export function bandTrack(times, groups) {
82
+ return Float64Array.from({ length: times.length }, (_, i) => bandAt(groups, times[i]));
83
+ }
84
+ /**
85
+ * Line height of a caption, in font sizes.
86
+ */
87
+ export const LINE_HEIGHT = 1.18;
88
+ /**
89
+ * Share of the window width that a caption can take.
90
+ */
91
+ export const CAPTION_WIDTH = 0.72;
92
+ /**
93
+ * Shape of the reveal, in font sizes: width of the soft edge, blur of the text in it,
94
+ * and the distance the text settles. DIM is the tone of the words outside the emphasis.
95
+ */
96
+ const SOFT = 4.4;
97
+ const BLUR = 0.15;
98
+ const SETTLE = 0.14;
99
+ const DIM = 0.62;
100
+ /**
101
+ * Splits caption text into words. `**` starts and ends the emphasis and is not shown.
102
+ */
103
+ export function parseCaption(text) {
104
+ const words = [];
105
+ let strong = false;
106
+ for (const raw of text.split(/\s+/).filter(Boolean)) {
107
+ const runs = [];
108
+ raw.split('**').forEach((part, i) => {
109
+ if (i > 0)
110
+ strong = !strong;
111
+ if (part)
112
+ runs.push({ text: part, strong });
113
+ });
114
+ if (runs.length)
115
+ words.push({ text: runs.map((run) => run.text).join(''), runs });
116
+ }
117
+ return words;
118
+ }
119
+ const join = (words) => words.map((word) => word.text).join(' ');
120
+ /**
121
+ * Breaks caption text into lines no wider than `maxWidth`, each with its `**` marks: the
122
+ * fewest lines, of about the same width. `measure(text, fontSize)` returns a width in
123
+ * pixels. A word wider than `maxWidth` has a line of its own.
124
+ */
125
+ export function splitCaption(text, measure, maxWidth, fontSize) {
126
+ const words = parseCaption(text);
127
+ const fill = (limit) => {
128
+ const lines = [];
129
+ for (const word of words) {
130
+ const line = lines.at(-1);
131
+ if (line && measure(join([...line, word]), fontSize) <= limit)
132
+ line.push(word);
133
+ else
134
+ lines.push([word]);
135
+ }
136
+ return lines;
137
+ };
138
+ const count = fill(maxWidth).length;
139
+ let narrow = 0;
140
+ let wide = maxWidth;
141
+ for (let i = 0; i < 12 && count > 1; i++) {
142
+ const limit = (narrow + wide) / 2;
143
+ if (fill(limit).length > count)
144
+ narrow = limit;
145
+ else
146
+ wide = limit;
147
+ }
148
+ const marked = (word) => word.runs.map((run) => (run.strong ? `**${run.text}**` : run.text)).join('');
149
+ return fill(wide).map((line) => line.map(marked).join(' '));
150
+ }
151
+ /**
152
+ * Lays out one line of caption text. The font shrinks only when the line is wider than
153
+ * `maxWidth`, which `splitCaption` prevents for all text but one very long word.
154
+ */
155
+ export function layoutCaption(text, measure, maxWidth, fontSize) {
156
+ const words = parseCaption(text);
157
+ const line = join(words);
158
+ const natural = measure(line, fontSize);
159
+ const size = natural > maxWidth ? (fontSize * maxWidth) / natural : fontSize;
160
+ const runs = [];
161
+ let before = '';
162
+ for (const word of words) {
163
+ for (const run of word.runs) {
164
+ runs.push({ ...run, x: before ? measure(before, size) : 0 });
165
+ before += run.text;
166
+ }
167
+ before += ' ';
168
+ }
169
+ return { fontSize: size, text: line, width: measure(line, size), runs };
170
+ }
171
+ const easeOutQuart = (t) => 1 - (1 - clamp(t, 0, 1)) ** 4;
172
+ const easeOutCubic = (t) => 1 - (1 - clamp(t, 0, 1)) ** 3;
173
+ const sweep = easing('smooth');
174
+ export function captionFont(style, size) {
175
+ return `500 ${size}px "${style.family}"`;
176
+ }
177
+ /**
178
+ * Tracking for a font size: -1.5% of the size for the text.
179
+ */
180
+ export function tracking(size) {
181
+ return `${(-0.015 * size).toFixed(3)}px`;
182
+ }
183
+ /**
184
+ * Width of text in the caption font, for `splitCaption` and `layoutCaption`.
185
+ */
186
+ export function captionMeasure(family) {
187
+ const context = createCanvas(4, 4).getContext('2d');
188
+ return (text, size) => {
189
+ context.font = captionFont({ family }, size);
190
+ context.letterSpacing = tracking(size);
191
+ return context.measureText(text).width;
192
+ };
193
+ }
194
+ /**
195
+ * Draws a caption line with its top-left corner at (x, top) in output pixels. The text
196
+ * comes into focus from left to right: behind a soft edge that crosses the line it is
197
+ * sharp, inside the edge it is blurred and faint. Words outside the emphasis have a lower
198
+ * tone. On exit the line goes out of focus and fades with a small upward drift.
199
+ */
200
+ export function drawCaption(ctx, cue, line, style, x, top, t) {
201
+ if (t < cue.textIn || t > cue.textOut + EXIT)
202
+ return;
203
+ const size = line.fontSize;
204
+ const soft = SOFT * size;
205
+ const p = clamp((t - cue.textIn) / REVEAL, 0, 1);
206
+ const exit = clamp((t - cue.textOut) / EXIT, 0, 1);
207
+ const alpha = style.color.a * (1 - smoothstep(0, 1, exit));
208
+ const edge = x + sweep(p) * (line.width + soft);
209
+ const shift = (1 - easeOutQuart(p) - easeOutCubic(exit)) * SETTLE * size;
210
+ const baseline = top + size * 0.93 + shift;
211
+ ctx.save();
212
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
213
+ ctx.textBaseline = 'alphabetic';
214
+ ctx.textAlign = 'left';
215
+ ctx.font = captionFont(style, size);
216
+ ctx.letterSpacing = tracking(size);
217
+ // Each stop is a position across the soft edge (0 to 1) and a share of the tone.
218
+ const draw = (blur, stops) => {
219
+ ctx.filter = blur > 0.01 ? `blur(${blur.toFixed(2)}px)` : 'none';
220
+ for (const run of line.runs) {
221
+ const tone = alpha * (cue.emphasis && !run.strong ? DIM : 1);
222
+ if (stops) {
223
+ const gradient = ctx.createLinearGradient(edge - soft, 0, edge, 0);
224
+ for (const [at, share] of stops)
225
+ gradient.addColorStop(at, rgba(style.color, tone * share));
226
+ ctx.fillStyle = gradient;
227
+ }
228
+ else {
229
+ ctx.fillStyle = rgba(style.color, tone);
230
+ }
231
+ ctx.fillText(run.text, x + run.x, baseline);
232
+ }
233
+ };
234
+ if (p >= 1) {
235
+ draw(exit * exit * 2 * BLUR * size);
236
+ }
237
+ else {
238
+ draw(0, [
239
+ [0, 1],
240
+ [0.35, 0],
241
+ ]);
242
+ draw(0.35 * BLUR * size, [
243
+ [0, 0],
244
+ [0.3, 0.9],
245
+ [0.65, 0],
246
+ ]);
247
+ draw(BLUR * size, [
248
+ [0.3, 0],
249
+ [0.65, 0.7],
250
+ [1, 0],
251
+ ]);
252
+ }
253
+ ctx.restore();
254
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * An sRGB color with channels in 0-255 and alpha in 0-1.
3
+ */
4
+ export interface Rgba {
5
+ r: number;
6
+ g: number;
7
+ b: number;
8
+ a: number;
9
+ }
10
+ /**
11
+ * Parses `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()` and `rgba()`. Returns null for
12
+ * other syntaxes (the canvas still accepts them where the color is used as is).
13
+ */
14
+ export declare function parseColor(input: string): Rgba | null;
15
+ export declare function rgba(c: Rgba, alpha?: number): string;
16
+ /**
17
+ * Mixes two colors in OKLab, which keeps blends free of muddy or grey midpoints.
18
+ */
19
+ export declare function mixOklab(a: Rgba, b: Rgba, t: number): Rgba;
20
+ /**
21
+ * Relative luminance, 0 (black) to 1 (white).
22
+ */
23
+ export declare function luminance(c: Rgba): number;
@@ -0,0 +1,78 @@
1
+ const NAMED = {
2
+ black: '#000000',
3
+ white: '#ffffff',
4
+ transparent: '#00000000',
5
+ };
6
+ /**
7
+ * Parses `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()` and `rgba()`. Returns null for
8
+ * other syntaxes (the canvas still accepts them where the color is used as is).
9
+ */
10
+ export function parseColor(input) {
11
+ const s = (NAMED[input.trim().toLowerCase()] ?? input).trim();
12
+ if (s.startsWith('#')) {
13
+ let hex = s.slice(1);
14
+ if (hex.length === 3 || hex.length === 4)
15
+ hex = [...hex].map((c) => c + c).join('');
16
+ if (!/^[0-9a-f]{6}([0-9a-f]{2})?$/i.test(hex))
17
+ return null;
18
+ const n = (i) => parseInt(hex.slice(i, i + 2), 16);
19
+ return { r: n(0), g: n(2), b: n(4), a: hex.length === 8 ? n(6) / 255 : 1 };
20
+ }
21
+ const m = /^rgba?\(([^)]+)\)$/i.exec(s);
22
+ if (!m)
23
+ return null;
24
+ const parts = m[1]
25
+ .split(/[\s,/]+/)
26
+ .filter(Boolean)
27
+ .map(Number);
28
+ if (parts.length < 3 || parts.some((v) => Number.isNaN(v)))
29
+ return null;
30
+ return { r: parts[0], g: parts[1], b: parts[2], a: parts[3] ?? 1 };
31
+ }
32
+ export function rgba(c, alpha = c.a) {
33
+ const ch = (v) => Math.round(Math.min(255, Math.max(0, v)));
34
+ return `rgba(${ch(c.r)}, ${ch(c.g)}, ${ch(c.b)}, ${Math.min(1, Math.max(0, alpha)).toFixed(4)})`;
35
+ }
36
+ const toLinear = (v) => {
37
+ const c = v / 255;
38
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
39
+ };
40
+ const fromLinear = (v) => 255 * (v <= 0.0031308 ? 12.92 * v : 1.055 * Math.max(0, v) ** (1 / 2.4) - 0.055);
41
+ function toOklab(c) {
42
+ const r = toLinear(c.r);
43
+ const g = toLinear(c.g);
44
+ const b = toLinear(c.b);
45
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
46
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
47
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
48
+ return [
49
+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
50
+ 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
51
+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
52
+ ];
53
+ }
54
+ function fromOklab([L, A, B], a) {
55
+ const l = (L + 0.3963377774 * A + 0.2158037573 * B) ** 3;
56
+ const m = (L - 0.1055613458 * A - 0.0638541728 * B) ** 3;
57
+ const s = (L - 0.0894841775 * A - 1.291485548 * B) ** 3;
58
+ return {
59
+ r: fromLinear(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
60
+ g: fromLinear(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
61
+ b: fromLinear(-0.0041960863 * l - 0.7034186182 * m + 1.707614701 * s),
62
+ a,
63
+ };
64
+ }
65
+ /**
66
+ * Mixes two colors in OKLab, which keeps blends free of muddy or grey midpoints.
67
+ */
68
+ export function mixOklab(a, b, t) {
69
+ const la = toOklab(a);
70
+ const lb = toOklab(b);
71
+ return fromOklab([la[0] + (lb[0] - la[0]) * t, la[1] + (lb[1] - la[1]) * t, la[2] + (lb[2] - la[2]) * t], a.a + (b.a - a.a) * t);
72
+ }
73
+ /**
74
+ * Relative luminance, 0 (black) to 1 (white).
75
+ */
76
+ export function luminance(c) {
77
+ return 0.2126 * toLinear(c.r) + 0.7152 * toLinear(c.g) + 0.0722 * toLinear(c.b);
78
+ }
@@ -0,0 +1,185 @@
1
+ import { type Canvas, type Image } from '@napi-rs/canvas';
2
+ import type { CursorStyle, Rect, Size, SpotlightEvent } from '../types.ts';
3
+ import type { CameraState } from './camera.ts';
4
+ import { type CaptionCue } from './captions.ts';
5
+ import type { ClickMark } from './cursor.ts';
6
+ import type { ResolvedOptions } from './defaults.ts';
7
+ import { type KeyCue } from './keycaps.ts';
8
+ import { type BandLayout, type StageTransform } from './stage.ts';
9
+ import type { TimedEvent } from './timeline.ts';
10
+ import { type Address } from './browser.ts';
11
+ /**
12
+ * Placement of the frame at rest, in output pixels.
13
+ */
14
+ export interface Layout {
15
+ size: Size;
16
+ unit: number;
17
+ viewport: Size;
18
+ /**
19
+ * Window box: the title bar (if any) plus the content.
20
+ */
21
+ window: Rect;
22
+ content: Rect;
23
+ bar: number;
24
+ radius: number;
25
+ padding: number;
26
+ /**
27
+ * Output pixels per CSS pixel at rest.
28
+ */
29
+ k: number;
30
+ }
31
+ /**
32
+ * The content box is the largest box with the viewport aspect ratio inside the padded
33
+ * output. Its width snaps to whole pixels so that, when the ratio allows, both edges land
34
+ * on pixel boundaries.
35
+ */
36
+ export declare function computeLayout(options: ResolvedOptions, viewport: Size): Layout;
37
+ export interface CursorFrame {
38
+ x: number;
39
+ y: number;
40
+ style: CursorStyle;
41
+ previousStyle: CursorStyle;
42
+ styleMix: number;
43
+ press: number;
44
+ opacity: number;
45
+ /**
46
+ * Lean about the hotspot, in radians.
47
+ */
48
+ angle: number;
49
+ }
50
+ export interface FrameInput {
51
+ /**
52
+ * Output time in milliseconds, for text animations.
53
+ */
54
+ t: number;
55
+ /**
56
+ * How far the caption band is open, 0 to 1, and the stage transform it gives.
57
+ */
58
+ band: number;
59
+ stage: StageTransform;
60
+ camera: CameraState;
61
+ image: Image | null;
62
+ cursor: CursorFrame | null;
63
+ /**
64
+ * Cursor positions across the shutter, for cursor motion blur.
65
+ */
66
+ cursorTrail?: {
67
+ x: number;
68
+ y: number;
69
+ }[];
70
+ clicks: {
71
+ mark: ClickMark;
72
+ age: number;
73
+ }[];
74
+ spotlights: {
75
+ event: TimedEvent<SpotlightEvent>;
76
+ amount: number;
77
+ }[];
78
+ captions: CaptionCue[];
79
+ keys: KeyCue[];
80
+ /**
81
+ * Text of the address bar, for the browser frame.
82
+ */
83
+ address?: Address;
84
+ }
85
+ /**
86
+ * Draws output frames. The background and the frame shadow are rendered once; the
87
+ * camera transform then moves the frame, while the background stays fixed.
88
+ */
89
+ export declare class Compositor {
90
+ readonly canvas: Canvas;
91
+ readonly layout: Layout;
92
+ private readonly options;
93
+ private readonly ctx;
94
+ private readonly background;
95
+ private readonly base;
96
+ private readonly shadow;
97
+ private readonly click;
98
+ private readonly clickColors;
99
+ private readonly probe;
100
+ private accumulator;
101
+ private cursorLayer;
102
+ private sprite;
103
+ private spriteKey;
104
+ private readonly band;
105
+ private moving;
106
+ private movingKey;
107
+ private lastKey;
108
+ private overlay;
109
+ private overlayKey;
110
+ private readonly captionStyle;
111
+ private readonly captionLines;
112
+ private readonly keyThemes;
113
+ constructor(options: ResolvedOptions, layout: Layout, background: Canvas, band?: BandLayout | null);
114
+ /**
115
+ * Mean luminance of the background in a rectangle.
116
+ */
117
+ private backgroundLuminance;
118
+ private renderShadow;
119
+ /**
120
+ * True when the color of a click still needs `prepareClick`.
121
+ */
122
+ needsClickColor(mark: ClickMark): boolean;
123
+ /**
124
+ * Picks the adaptive click color from the page brightness under the click, in the
125
+ * frame captured when the button went down.
126
+ */
127
+ prepareClick(mark: ClickMark, image: Image | null): void;
128
+ private clickColor;
129
+ /**
130
+ * Renders one frame into `canvas`. The stage transform (caption band) and the camera
131
+ * combine into one frame matrix; content points map with the matching content matrix.
132
+ */
133
+ draw(input: FrameInput): void;
134
+ /**
135
+ * The content matrix (CSS pixels to output: scale `ks`, offset `ex`, `ey`) and the frame
136
+ * matrix (rest layout to output: scale `fa`, offset `fe`, `ff`): plain affine maps of the
137
+ * camera state and the stage.
138
+ */
139
+ private matrices;
140
+ /**
141
+ * Background and frame shadow. At rest this is one cached image; for a frame matrix
142
+ * that repeats (a still camera with the band open) it is cached on its second use.
143
+ */
144
+ private drawBase;
145
+ /**
146
+ * Redraws the wallpaper over the band where a zoomed frame overflows into it, with a
147
+ * feathered edge. At rest the frame never overflows, so its shadow stays visible.
148
+ */
149
+ private drawBandCover;
150
+ private captionLayout;
151
+ private drawCaptionCue;
152
+ /**
153
+ * Keycaps sit centered in the padding at rest; with the caption band open on their side
154
+ * they move into the band, right-aligned with the frame.
155
+ */
156
+ private keysBox;
157
+ needsKeyTheme(cue: KeyCue): boolean;
158
+ /**
159
+ * Picks light or dark caps from what is behind them when they appear: the page when
160
+ * the zoomed frame covers their place, the wallpaper otherwise.
161
+ */
162
+ prepareKeys(cue: KeyCue, input: FrameInput): void;
163
+ private drawKeys;
164
+ /**
165
+ * Renders several sub-frame inputs across the shutter and averages them (camera
166
+ * motion blur). The average runs in a float16 canvas, so it adds no banding.
167
+ */
168
+ drawBlurred(inputs: FrameInput[]): void;
169
+ /**
170
+ * Cursor motion blur: the average of the cursor at its positions across the shutter.
171
+ * The cursor (fill, outline, shadow) is drawn once into a sprite, which is added with
172
+ * premultiplied weights 1/N into a float16 layer, so the smear keeps its brightness.
173
+ */
174
+ private drawCursorTrail;
175
+ /**
176
+ * First free x on the bar after the window buttons.
177
+ */
178
+ private barLeft;
179
+ private drawChrome;
180
+ /**
181
+ * Hairlines that define the window edge: dark outside for light backgrounds, a faint
182
+ * light rim inside for dark content.
183
+ */
184
+ private drawEdges;
185
+ }