@vitrinka/web 0.3.4 → 0.5.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/CHANGELOG.md +118 -0
- package/README.md +93 -6
- package/build/hud.d.ts +4 -1
- package/build/hud.iife.js +46 -9
- package/build/one.iife.js +1 -0
- package/build/protocol/index.d.ts +55 -4
- package/build/protocol/index.js +4 -2
- package/build/recorder/RecorderProvider.js +48 -9
- package/build/recorder/api.d.ts +25 -5
- package/build/recorder/api.js +21 -9
- package/build/recorder/attachments.d.ts +19 -0
- package/build/recorder/attachments.js +31 -0
- package/build/recorder/capture/console.d.ts +2 -0
- package/build/recorder/capture/console.js +22 -2
- package/build/recorder/capture/nav.d.ts +13 -2
- package/build/recorder/capture/nav.js +49 -11
- package/build/recorder/capture/net.d.ts +2 -0
- package/build/recorder/capture/net.js +30 -4
- package/build/recorder/control.d.ts +17 -0
- package/build/recorder/control.js +39 -2
- package/build/recorder/hud/Hud.d.ts +1 -1
- package/build/recorder/hud/Hud.js +113 -30
- package/build/recorder/hud/RecorderPill.js +6 -2
- package/build/recorder/hud/Sheet.d.ts +40 -5
- package/build/recorder/hud/Sheet.js +134 -8
- package/build/recorder/hud/attach.d.ts +26 -0
- package/build/recorder/hud/attach.js +136 -0
- package/build/recorder/hud/chords.d.ts +10 -0
- package/build/recorder/hud/chords.js +34 -0
- package/build/recorder/hud/controller.d.ts +55 -3
- package/build/recorder/hud/controller.js +1 -1
- package/build/recorder/hud/flow.d.ts +22 -1
- package/build/recorder/hud/flow.js +16 -1
- package/build/recorder/hud/host.js +2 -0
- package/build/recorder/hud/icons.d.ts +3 -0
- package/build/recorder/hud/icons.js +7 -0
- package/build/recorder/hud/layer.d.ts +4 -1
- package/build/recorder/hud/layer.js +11 -3
- package/build/recorder/hud/resize.d.ts +83 -0
- package/build/recorder/hud/resize.js +236 -0
- package/build/recorder/hud/styles.d.ts +1 -1
- package/build/recorder/hud/styles.js +38 -1
- package/build/recorder/index.d.ts +1 -0
- package/build/recorder/index.js +1 -0
- package/build/recorder/lead.d.ts +90 -0
- package/build/recorder/lead.js +404 -0
- package/build/recorder/link.d.ts +4 -1
- package/build/recorder/link.js +6 -2
- package/build/recorder/me.d.ts +7 -0
- package/build/recorder/me.js +62 -12
- package/build/recorder/one-iife.d.ts +13 -0
- package/build/recorder/one-iife.js +13 -0
- package/build/recorder/one.d.ts +170 -0
- package/build/recorder/one.js +292 -0
- package/build/recorder/page-controller.js +26 -4
- package/build/recorder/queue.d.ts +33 -3
- package/build/recorder/queue.js +409 -26
- package/build/recorder/report.d.ts +9 -0
- package/build/recorder/report.js +55 -6
- package/build/recorder/session.d.ts +33 -7
- package/build/recorder/session.js +111 -31
- package/build/recorder/state.d.ts +9 -0
- package/build/recorder/state.js +7 -0
- package/build/recorder/storage/blobs.d.ts +32 -0
- package/build/recorder/storage/blobs.js +83 -0
- package/build/recorder/storage/index.js +3 -2
- package/build/recorder/version.d.ts +3 -0
- package/build/recorder/version.js +3 -0
- package/package.json +5 -3
|
@@ -1,20 +1,61 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
|
-
* The composer sheet — the extension's hud.html, as a component:
|
|
4
|
-
* anchored to the dock (a bottom sheet on phones), a 14px textarea
|
|
5
|
-
* touch, so iOS never zooms)
|
|
3
|
+
* The composer sheet — the extension's hud.html, as a component: 440px wide
|
|
4
|
+
* by default, anchored to the dock (a bottom sheet on phones), a 14px textarea
|
|
5
|
+
* (16px on touch, so iOS never zooms) that grows with the draft up to a cap
|
|
6
|
+
* and then scrolls, a resize grip on the corner away from the dock (width
|
|
7
|
+
* and cap are HUD prefs — resize.ts), ✕ in the title row, a three-column footer
|
|
6
8
|
* (board|task · context · ↑ Send) and the hint line (hidden on touch). Enter sends, ⇧Enter newlines, Esc
|
|
7
9
|
* cancels. The DRAFT is owned by the caller so a cancel keeps it until the
|
|
8
10
|
* next send (recorder-hud-polish D3); the board|task choice resets on every
|
|
9
11
|
* open — a destination is per observation, not a mode. The bug report is the
|
|
10
12
|
* same sheet: a required description and "Mark on screen" in the board|task
|
|
11
13
|
* slot.
|
|
14
|
+
*
|
|
15
|
+
* Images (recorder attachments), only when the caller passes `images`: the
|
|
16
|
+
* paperclip beside Send picks them, an image paste on the textarea and a
|
|
17
|
+
* drop onto the sheet add them (attach.ts normalizes each), a strip of
|
|
18
|
+
* thumbnails above the footer removes them, at most `MAX_ATTACHMENTS`. Like
|
|
19
|
+
* the text, the caller owns them — and the count still preparing — so a
|
|
20
|
+
* cancel keeps them and a reopened sheet still waits. A refusal (not an
|
|
21
|
+
* image, the cap) shows in the footer's context slot — one line, so the
|
|
22
|
+
* footer never moves.
|
|
12
23
|
*/
|
|
13
|
-
import { useEffect, useRef, useState } from 'react';
|
|
14
|
-
import {
|
|
15
|
-
|
|
24
|
+
import { useEffect, useRef, useState, } from 'react';
|
|
25
|
+
import { MAX_ATTACHMENTS, normalizeAttachment, pastedName } from './attach';
|
|
26
|
+
import { ArrowUpIcon, CloseIcon, GripIcon, PaperclipIcon, SpinnerIcon } from './icons';
|
|
27
|
+
import { useSheetSize } from './resize';
|
|
28
|
+
/** How long a refusal holds the context slot. */
|
|
29
|
+
const REFUSAL_MS = 5000;
|
|
30
|
+
const errorText = (e) => (e instanceof Error ? e.message : String(e));
|
|
31
|
+
/** A stable React key per image (a name can repeat, an index shifts on remove). */
|
|
32
|
+
const keys = new WeakMap();
|
|
33
|
+
let lastKey = 0;
|
|
34
|
+
function keyOf(image) {
|
|
35
|
+
let k = keys.get(image);
|
|
36
|
+
if (k === undefined)
|
|
37
|
+
keys.set(image, (k = ++lastKey));
|
|
38
|
+
return k;
|
|
39
|
+
}
|
|
40
|
+
/** A drag that carries files (not a text selection or a link). */
|
|
41
|
+
const carriesFiles = (e) => Array.from(e.dataTransfer.types).includes('Files');
|
|
42
|
+
function Thumb({ image, onRemove }) {
|
|
43
|
+
const [src, setSrc] = useState('');
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const url = URL.createObjectURL(image.blob);
|
|
46
|
+
setSrc(url);
|
|
47
|
+
return () => URL.revokeObjectURL(url);
|
|
48
|
+
}, [image.blob]);
|
|
49
|
+
return (_jsxs("li", { className: "att", children: [src ? _jsx("img", { src: src, alt: image.name }) : null, _jsx("button", { type: "button", className: "attx", "aria-label": `Remove ${image.name}`, onClick: onRemove, children: _jsx(CloseIcon, {}) })] }));
|
|
50
|
+
}
|
|
51
|
+
export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onSend, onClose, placeholder = "what's wrong / what to refine…", required = false, onMark, marked = false, images, onImages, preparing: busy = 0, onPreparing, kind = 'note', sheetW = 0, sheetH = 0, room = 0, grip = null, onResize, onLayout, }) {
|
|
52
|
+
const pop = useRef(null);
|
|
16
53
|
const ta = useRef(null);
|
|
54
|
+
const file = useRef(null);
|
|
55
|
+
const size = useSheetSize({ sheet: pop, text: ta, width: sheetW, cap: sheetH, room, grip, onResize, onLayout });
|
|
17
56
|
const [task, setTask] = useState(false);
|
|
57
|
+
const [refusal, setRefusal] = useState('');
|
|
58
|
+
const [dropping, setDropping] = useState(false);
|
|
18
59
|
useEffect(() => {
|
|
19
60
|
const el = ta.current;
|
|
20
61
|
if (!el)
|
|
@@ -22,14 +63,95 @@ export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onS
|
|
|
22
63
|
el.focus();
|
|
23
64
|
el.setSelectionRange(el.value.length, el.value.length);
|
|
24
65
|
}, []);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!refusal)
|
|
68
|
+
return;
|
|
69
|
+
const t = setTimeout(() => setRefusal(''), REFUSAL_MS);
|
|
70
|
+
return () => clearTimeout(t);
|
|
71
|
+
}, [refusal]);
|
|
25
72
|
const empty = required && draft.trim() === '';
|
|
73
|
+
const held = images?.length ?? 0;
|
|
74
|
+
const full = held + busy >= MAX_ATTACHMENTS;
|
|
26
75
|
const send = () => {
|
|
27
|
-
if (empty) {
|
|
76
|
+
if (empty || busy > 0) {
|
|
28
77
|
ta.current?.focus();
|
|
29
78
|
return;
|
|
30
79
|
}
|
|
31
80
|
onSend(draft.trim(), task);
|
|
32
81
|
};
|
|
82
|
+
// Normalize in order (the strip keeps the order they came in); the cap is
|
|
83
|
+
// re-checked as each lands, so two quick adds never pass it. The work can
|
|
84
|
+
// outlive this sheet (a cancel mid-way): its count and its result go to
|
|
85
|
+
// the caller's draft, never to this sheet's state.
|
|
86
|
+
const attach = (files, pasted = false) => {
|
|
87
|
+
if (!onImages || !onPreparing || !files.length)
|
|
88
|
+
return;
|
|
89
|
+
const take = files.slice(0, Math.max(0, MAX_ATTACHMENTS - held - busy));
|
|
90
|
+
setRefusal(take.length < files.length ? `${MAX_ATTACHMENTS} images at most` : '');
|
|
91
|
+
if (!take.length)
|
|
92
|
+
return;
|
|
93
|
+
onPreparing((n) => n + take.length);
|
|
94
|
+
void (async () => {
|
|
95
|
+
for (const f of take) {
|
|
96
|
+
try {
|
|
97
|
+
const image = await normalizeAttachment(f, pasted ? pastedName(f) : f.name || 'image');
|
|
98
|
+
onImages((prev) => (prev.length >= MAX_ATTACHMENTS ? prev : [...prev, image]));
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
setRefusal(errorText(e));
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
onPreparing((n) => n - 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
})();
|
|
108
|
+
};
|
|
109
|
+
const remove = (image) => {
|
|
110
|
+
onImages?.((prev) => prev.filter((x) => x !== image));
|
|
111
|
+
setRefusal('');
|
|
112
|
+
ta.current?.focus();
|
|
113
|
+
};
|
|
114
|
+
const browse = () => {
|
|
115
|
+
if (full) {
|
|
116
|
+
setRefusal(`${MAX_ATTACHMENTS} images at most`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
file.current?.click();
|
|
120
|
+
};
|
|
121
|
+
// An image paste attaches; a text paste stays a text paste (an office app
|
|
122
|
+
// puts a picture of the copied cells beside their text), unless the text
|
|
123
|
+
// is only a copied file's name.
|
|
124
|
+
const onPaste = (e) => {
|
|
125
|
+
if (!onImages)
|
|
126
|
+
return;
|
|
127
|
+
const files = Array.from(e.clipboardData.files);
|
|
128
|
+
if (!files.length)
|
|
129
|
+
return;
|
|
130
|
+
const text = e.clipboardData.getData('text/plain').trim();
|
|
131
|
+
if (text && !files.some((f) => f.name && text.includes(f.name)))
|
|
132
|
+
return;
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
attach(files, true);
|
|
135
|
+
};
|
|
136
|
+
const onDragOver = (e) => {
|
|
137
|
+
if (!onImages || !carriesFiles(e))
|
|
138
|
+
return;
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
e.dataTransfer.dropEffect = 'copy';
|
|
141
|
+
setDropping(true);
|
|
142
|
+
};
|
|
143
|
+
const onDragLeave = (e) => {
|
|
144
|
+
if (!e.currentTarget.contains(e.relatedTarget))
|
|
145
|
+
setDropping(false);
|
|
146
|
+
};
|
|
147
|
+
const onDrop = (e) => {
|
|
148
|
+
if (!onImages || !carriesFiles(e))
|
|
149
|
+
return;
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
setDropping(false);
|
|
152
|
+
attach(Array.from(e.dataTransfer.files));
|
|
153
|
+
};
|
|
154
|
+
const sendb = (_jsxs("button", { type: "button", className: "sendb", "aria-disabled": empty || busy > 0 || undefined, onClick: send, children: [_jsx(ArrowUpIcon, {}), _jsx("span", { children: "Send" })] }));
|
|
33
155
|
const onKey = (e) => {
|
|
34
156
|
if (e.key === 'Escape') {
|
|
35
157
|
e.preventDefault();
|
|
@@ -42,5 +164,9 @@ export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onS
|
|
|
42
164
|
send();
|
|
43
165
|
}
|
|
44
166
|
};
|
|
45
|
-
return (_jsxs("div", { className: `pop ${className}`, style: { transformOrigin: origin }, role: "dialog", "aria-labelledby": "vt-pop-title", onKeyDown: onKey, children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "title", children: [_jsx("i", {}), _jsx("span", { id: "vt-pop-title", children: title })] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] }), _jsx("textarea", { ref: ta, placeholder: placeholder, "aria-required": required || undefined, value: draft, onChange: (e) => onDraft(e.target.value), onKeyDown: onTaKey }), _jsxs("div", { className: pick || onMark ? 'row' : 'row nodest', children: [onMark ? (_jsx("span", { className: "dest", children: _jsx("button", { type: "button", "aria-pressed": marked, onClick: onMark, children: "Mark on screen" }) })) : pick ? (_jsxs("span", { className: "dest", role: "group", "aria-label": "Where this snap lands", children: [_jsx("button", { type: "button", "aria-pressed": !task, onClick: () => setTask(false), children: "board" }), _jsx("button", { type: "button", "aria-pressed": task, onClick: () => setTask(true), children: "task" })] })) : null, _jsx("span", { className: "ctx", children: ctx }), _jsxs("button", { type: "button", className: "
|
|
167
|
+
return (_jsxs("div", { ref: pop, className: `pop compose ${className}${dropping ? ' dropping' : ''}`, style: { transformOrigin: origin, ...size.style }, role: "dialog", "aria-labelledby": "vt-pop-title", onKeyDown: onKey, ...(onImages ? { onDragEnter: onDragOver, onDragOver, onDragLeave, onDrop } : {}), children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "title", children: [_jsx("i", {}), _jsx("span", { id: "vt-pop-title", children: title })] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] }), _jsx("textarea", { ref: ta, placeholder: placeholder, "aria-required": required || undefined, value: draft, onChange: (e) => onDraft(e.target.value), onKeyDown: onTaKey, ...(onImages ? { onPaste } : {}) }), images && (images.length > 0 || busy > 0) ? (_jsxs("ul", { className: "atts", "aria-label": "Attached images", children: [images.map((image) => (_jsx(Thumb, { image: image, onRemove: () => remove(image) }, keyOf(image)))), Array.from({ length: busy }, (_, i) => (_jsx("li", { className: "att busy", "aria-label": "Preparing image", children: _jsx(SpinnerIcon, {}) }, `busy${i}`)))] })) : null, _jsxs("div", { className: pick || onMark ? 'row' : 'row nodest', children: [onMark ? (_jsx("span", { className: "dest", children: _jsx("button", { type: "button", "aria-pressed": marked, onClick: onMark, children: "Mark on screen" }) })) : pick ? (_jsxs("span", { className: "dest", role: "group", "aria-label": "Where this snap lands", children: [_jsx("button", { type: "button", "aria-pressed": !task, onClick: () => setTask(false), children: "board" }), _jsx("button", { type: "button", "aria-pressed": task, onClick: () => setTask(true), children: "task" })] })) : null, refusal ? (_jsx("span", { className: "ctx bad", title: refusal, children: refusal })) : (_jsx("span", { className: "ctx", children: ctx })), onImages ? (_jsxs("span", { className: "acts", children: [_jsx("button", { type: "button", className: "clipb", "aria-label": "Attach image", "aria-disabled": full || undefined, onClick: browse, children: _jsx(PaperclipIcon, {}) }), _jsx("input", { ref: file, type: "file", accept: "image/*", multiple: true, hidden: true, onChange: (e) => {
|
|
168
|
+
attach(Array.from(e.currentTarget.files ?? []));
|
|
169
|
+
// The same file picked again is a change too.
|
|
170
|
+
e.currentTarget.value = '';
|
|
171
|
+
} }), sendb] })) : (sendb)] }), onImages ? (_jsx("span", { className: "sr", role: "status", children: refusal })) : null, _jsx("div", { className: "hints", children: "\u21A9 send \u00B7 \u21E7\u21A9 newline \u00B7 esc cancel" }), size.grip ? (_jsx("button", { type: "button", className: "grip", "data-corner": size.grip.corner, "aria-label": `Resize ${kind}`, ...size.grip.handlers, children: _jsx(GripIcon, {}) })) : null] }));
|
|
46
172
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One picked, pasted or dropped file → a `HudAttachment` a controller ships
|
|
3
|
+
* as-is (recorder attachments). The image is decoded (an animated input keeps
|
|
4
|
+
* its first frame), drawn at a long edge ≤ 2560 px and re-encoded, so its
|
|
5
|
+
* EXIF/GPS never leave the device: WebP at 0.85; where the browser cannot
|
|
6
|
+
* encode WebP (it hands back another type) JPEG at 0.85, or PNG when the
|
|
7
|
+
* image has transparency JPEG would lose. Over 12 MiB (the `/shot` cap) it
|
|
8
|
+
* steps down until it fits. A file that is not an image is refused with a
|
|
9
|
+
* reason the sheet shows verbatim.
|
|
10
|
+
*/
|
|
11
|
+
import type { HudAttachment } from './controller';
|
|
12
|
+
/** Images one note carries from the HUD (the server takes at most 10). */
|
|
13
|
+
export declare const MAX_ATTACHMENTS = 4;
|
|
14
|
+
export declare const MAX_EDGE = 2560;
|
|
15
|
+
/** The `/shot` upload cap. */
|
|
16
|
+
export declare const MAX_ATTACHMENT_BYTES: number;
|
|
17
|
+
/** Test-only: forget what the first encode learned about WebP. */
|
|
18
|
+
export declare function __resetEncoderForTests(): void;
|
|
19
|
+
/** The name a pasted image carries: the clipboard's generic one becomes "pasted image.<ext>". */
|
|
20
|
+
export declare function pastedName(file: File): string;
|
|
21
|
+
/**
|
|
22
|
+
* Normalize one file for a note. Rejects with an `Error` whose message leads
|
|
23
|
+
* with the reason (not an image, unreadable, too large), then the file — the
|
|
24
|
+
* sheet ellipsizes a long name, never the reason.
|
|
25
|
+
*/
|
|
26
|
+
export declare function normalizeAttachment(file: Blob, name: string): Promise<HudAttachment>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** Images one note carries from the HUD (the server takes at most 10). */
|
|
2
|
+
export const MAX_ATTACHMENTS = 4;
|
|
3
|
+
export const MAX_EDGE = 2560;
|
|
4
|
+
/** The `/shot` upload cap. */
|
|
5
|
+
export const MAX_ATTACHMENT_BYTES = 12 * 1024 * 1024;
|
|
6
|
+
const QUALITY = 0.85;
|
|
7
|
+
/** Step-downs before an image counts as too large. */
|
|
8
|
+
const MAX_TRIES = 8;
|
|
9
|
+
/** null until the first encode says whether this browser writes WebP. */
|
|
10
|
+
let webp = null;
|
|
11
|
+
/** Test-only: forget what the first encode learned about WebP. */
|
|
12
|
+
export function __resetEncoderForTests() {
|
|
13
|
+
webp = null;
|
|
14
|
+
}
|
|
15
|
+
/** The name a pasted image carries: the clipboard's generic one becomes "pasted image.<ext>". */
|
|
16
|
+
export function pastedName(file) {
|
|
17
|
+
if (file.name && !/^(image|untitled)\.\w+$/i.test(file.name))
|
|
18
|
+
return file.name;
|
|
19
|
+
const ext = file.type.startsWith('image/') ? file.type.slice(6).replace('jpeg', 'jpg').replace(/\+.*$/, '') : 'png';
|
|
20
|
+
return `pasted image.${ext || 'png'}`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Normalize one file for a note. Rejects with an `Error` whose message leads
|
|
24
|
+
* with the reason (not an image, unreadable, too large), then the file — the
|
|
25
|
+
* sheet ellipsizes a long name, never the reason.
|
|
26
|
+
*/
|
|
27
|
+
export async function normalizeAttachment(file, name) {
|
|
28
|
+
if (file.type && !file.type.startsWith('image/'))
|
|
29
|
+
throw new Error(`Not an image: ${name}`);
|
|
30
|
+
let img;
|
|
31
|
+
try {
|
|
32
|
+
img = await decode(file);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.warn('vitrinka: attachment decode failed —', e);
|
|
36
|
+
throw new Error(`Unreadable image: ${name}`);
|
|
37
|
+
}
|
|
38
|
+
let out;
|
|
39
|
+
try {
|
|
40
|
+
out = await encode(img, name, mayHaveAlpha(file.type));
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
// A canvas the browser refuses to read back (a tainted SVG) or encode.
|
|
44
|
+
console.warn('vitrinka: attachment encode failed —', e);
|
|
45
|
+
throw new Error(`Could not convert: ${name}`);
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
img.close();
|
|
49
|
+
}
|
|
50
|
+
if (!out)
|
|
51
|
+
throw new Error(`Too large to attach: ${name}`);
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
/** JPEG never carries transparency; anything else may. */
|
|
55
|
+
function mayHaveAlpha(type) {
|
|
56
|
+
return type !== 'image/jpeg' && type !== 'image/jpg';
|
|
57
|
+
}
|
|
58
|
+
/** The re-encoded image, or null when even the last step-down is over the cap. */
|
|
59
|
+
async function encode(img, name, alphaInput) {
|
|
60
|
+
let scale = Math.min(1, MAX_EDGE / Math.max(img.w, img.h));
|
|
61
|
+
let alpha = null;
|
|
62
|
+
for (let tries = 0; tries < MAX_TRIES; tries++) {
|
|
63
|
+
const w = Math.max(1, Math.round(img.w * scale));
|
|
64
|
+
const h = Math.max(1, Math.round(img.h * scale));
|
|
65
|
+
const s = surface(w, h);
|
|
66
|
+
s.paint.drawImage(img.source, 0, 0, w, h);
|
|
67
|
+
let blob = webp === false ? null : await s.encode('image/webp', QUALITY);
|
|
68
|
+
if (blob && webp === null)
|
|
69
|
+
webp = blob.type === 'image/webp';
|
|
70
|
+
if (!blob || blob.type !== 'image/webp') {
|
|
71
|
+
alpha ??= alphaInput && hasAlpha(s.paint, w, h);
|
|
72
|
+
blob = alpha ? await s.encode('image/png') : await s.encode('image/jpeg', QUALITY);
|
|
73
|
+
}
|
|
74
|
+
if (!blob)
|
|
75
|
+
throw new Error('the canvas encoded nothing');
|
|
76
|
+
if (blob.size <= MAX_ATTACHMENT_BYTES)
|
|
77
|
+
return { name, blob, w, h };
|
|
78
|
+
// Bytes scale with the area: aim just under the cap, never less than half the edge a step.
|
|
79
|
+
scale *= Math.min(0.9, Math.max(0.5, Math.sqrt(MAX_ATTACHMENT_BYTES / blob.size) * 0.95));
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
/** Any pixel not fully opaque. */
|
|
84
|
+
function hasAlpha(paint, w, h) {
|
|
85
|
+
const data = paint.getImageData(0, 0, w, h).data;
|
|
86
|
+
for (let i = 3; i < data.length; i += 4)
|
|
87
|
+
if ((data[i] ?? 255) < 255)
|
|
88
|
+
return true;
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
/** An OffscreenCanvas where there is one, else a detached `<canvas>`. */
|
|
92
|
+
function surface(w, h) {
|
|
93
|
+
if (typeof OffscreenCanvas === 'function') {
|
|
94
|
+
const c = new OffscreenCanvas(w, h);
|
|
95
|
+
const paint = c.getContext('2d');
|
|
96
|
+
if (!paint)
|
|
97
|
+
throw new Error('no 2d canvas');
|
|
98
|
+
return { paint, encode: (type, quality) => c.convertToBlob({ type, ...(quality === undefined ? {} : { quality }) }) };
|
|
99
|
+
}
|
|
100
|
+
const c = document.createElement('canvas');
|
|
101
|
+
c.width = w;
|
|
102
|
+
c.height = h;
|
|
103
|
+
const paint = c.getContext('2d');
|
|
104
|
+
if (!paint)
|
|
105
|
+
throw new Error('no 2d canvas');
|
|
106
|
+
return { paint, encode: (type, quality) => new Promise((resolve) => c.toBlob(resolve, type, quality)) };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Decode upright (EXIF orientation applied, so the re-encode that drops the
|
|
110
|
+
* tag keeps the picture the right way up). `createImageBitmap` takes most
|
|
111
|
+
* types; an SVG decodes only through an `<img>`.
|
|
112
|
+
*/
|
|
113
|
+
async function decode(file) {
|
|
114
|
+
if (typeof createImageBitmap === 'function') {
|
|
115
|
+
try {
|
|
116
|
+
const bmp = await createImageBitmap(file, { imageOrientation: 'from-image' });
|
|
117
|
+
return { source: bmp, w: bmp.width, h: bmp.height, close: () => bmp.close() };
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// fall through to <img>
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const url = URL.createObjectURL(file);
|
|
124
|
+
try {
|
|
125
|
+
const el = new Image();
|
|
126
|
+
el.src = url;
|
|
127
|
+
await el.decode();
|
|
128
|
+
if (!el.naturalWidth || !el.naturalHeight)
|
|
129
|
+
throw new Error('no intrinsic size');
|
|
130
|
+
return { source: el, w: el.naturalWidth, h: el.naturalHeight, close: () => URL.revokeObjectURL(url) };
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
URL.revokeObjectURL(url);
|
|
134
|
+
throw e;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Chord = 'annotate' | 'note' | 'pause' | 'stop';
|
|
2
|
+
export type ChordKey = Pick<KeyboardEvent, 'altKey' | 'shiftKey' | 'metaKey' | 'ctrlKey' | 'code'>;
|
|
3
|
+
/** The chord a keydown is, by its physical key (⌥ rewrites `key` on a Mac); null for anything else. */
|
|
4
|
+
export declare function chordOf(e: ChordKey): Chord | null;
|
|
5
|
+
/**
|
|
6
|
+
* Bind the chords on `target` (window), capture phase — the host's shield
|
|
7
|
+
* stops a keydown from a focused HUD control before it could bubble there,
|
|
8
|
+
* and a drag leaves the handle focused. Returns the unbind.
|
|
9
|
+
*/
|
|
10
|
+
export declare function bindChords(target: EventTarget, on: (c: Chord) => void): () => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The recorder shortcuts: ⌥⇧A annotate · ⌥⇧N note · ⌥⇧P pause · ⌥⇧S stop.
|
|
3
|
+
*
|
|
4
|
+
* Only the LEADER's HUD binds them (ONE recorder D9): a keydown on `window`
|
|
5
|
+
* reaches the listeners of the page's world and the extension's alike, so a
|
|
6
|
+
* follower that bound them too would act twice. Untrusted (synthetic)
|
|
7
|
+
* keydowns are taken on purpose: Chrome hands the extension's command chords
|
|
8
|
+
* to its worker, never to the page, and the worker relays them as a
|
|
9
|
+
* synthetic keydown — `isTrusted: false` (D10). A taken chord is
|
|
10
|
+
* `preventDefault`ed, never stopped, so a host that skips `defaultPrevented`
|
|
11
|
+
* keys (forge-studio's CommandProvider) leaves it alone.
|
|
12
|
+
*/
|
|
13
|
+
import { listen } from './listen';
|
|
14
|
+
const BY_CODE = { KeyA: 'annotate', KeyN: 'note', KeyP: 'pause', KeyS: 'stop' };
|
|
15
|
+
/** The chord a keydown is, by its physical key (⌥ rewrites `key` on a Mac); null for anything else. */
|
|
16
|
+
export function chordOf(e) {
|
|
17
|
+
if (!e.altKey || !e.shiftKey || e.metaKey || e.ctrlKey)
|
|
18
|
+
return null;
|
|
19
|
+
return BY_CODE[e.code] ?? null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Bind the chords on `target` (window), capture phase — the host's shield
|
|
23
|
+
* stops a keydown from a focused HUD control before it could bubble there,
|
|
24
|
+
* and a drag leaves the handle focused. Returns the unbind.
|
|
25
|
+
*/
|
|
26
|
+
export function bindChords(target, on) {
|
|
27
|
+
return listen(target, 'keydown', (e) => {
|
|
28
|
+
const c = chordOf(e);
|
|
29
|
+
if (!c)
|
|
30
|
+
return;
|
|
31
|
+
on(c);
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
}, { capture: true });
|
|
34
|
+
}
|
|
@@ -19,6 +19,10 @@ export interface HudPrefs {
|
|
|
19
19
|
size: HudSize;
|
|
20
20
|
/** Technical details (events, queue, last sync, session id, version). */
|
|
21
21
|
verbose: boolean;
|
|
22
|
+
/** The note / annotate / report sheet's width, CSS px; 0 = the HUD's default. */
|
|
23
|
+
sheetW: number;
|
|
24
|
+
/** The cap its text box grows to before it scrolls, CSS px; 0 = the HUD's default (20 rows). */
|
|
25
|
+
sheetH: number;
|
|
22
26
|
}
|
|
23
27
|
/** Who the recorder token belongs to (`GET /api/v1/recorder/me`). */
|
|
24
28
|
export interface HudAccount {
|
|
@@ -40,7 +44,7 @@ export type HudSyncState = 'ok' | 'backlog' | 'offline' | 'dead';
|
|
|
40
44
|
export interface HudSync {
|
|
41
45
|
state: HudSyncState;
|
|
42
46
|
synced: boolean;
|
|
43
|
-
/** Items (events + rrweb chunks) not yet delivered. */
|
|
47
|
+
/** Items (events + rrweb chunks + attached images) not yet delivered. */
|
|
44
48
|
queued: number;
|
|
45
49
|
/** Of those, rrweb chunks. */
|
|
46
50
|
chunks: number;
|
|
@@ -99,6 +103,32 @@ export interface HudSnapshot {
|
|
|
99
103
|
* session, or, idle, with the last minute the host keeps. Absent = never.
|
|
100
104
|
*/
|
|
101
105
|
canReport?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* The sheets take images (paperclip, paste, drop) — the server answered
|
|
108
|
+
* `attachments: true` to the policy read. Absent or false = text only.
|
|
109
|
+
*/
|
|
110
|
+
canAttach?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* ONE recorder: another recorder leads this browser's recording — the
|
|
113
|
+
* extension, or the page's own recorder — and this HUD is its remote. The
|
|
114
|
+
* HUD hides, closes its sheet, menu, link sheet and annotate mode (the
|
|
115
|
+
* drafts and their images survive, as a cancel keeps them; the dock spot
|
|
116
|
+
* stays) and binds no shortcut. Absent = this HUD's host leads or is idle.
|
|
117
|
+
*/
|
|
118
|
+
following?: 'page' | 'extension';
|
|
119
|
+
}
|
|
120
|
+
/** The pill's inline flow face (`hud/flow.ts`), as `faceChanged` reports it. */
|
|
121
|
+
export type HudFace = 'none' | 'confirm' | 'saving' | 'saved' | 'failed';
|
|
122
|
+
/** One image a tester attached, already normalized by the HUD:
|
|
123
|
+
* re-encoded (EXIF/GPS gone), long edge ≤ 2560 px, ≤ 12 MiB. */
|
|
124
|
+
export interface HudAttachment {
|
|
125
|
+
/** The original file name ("pasted image.png" for a paste). */
|
|
126
|
+
name: string;
|
|
127
|
+
/** image/webp, image/jpeg or image/png — what /shot accepts. */
|
|
128
|
+
blob: Blob;
|
|
129
|
+
/** Pixel size after normalizing. */
|
|
130
|
+
w: number;
|
|
131
|
+
h: number;
|
|
102
132
|
}
|
|
103
133
|
/** The code half of a device link, as the link sheet paints it. */
|
|
104
134
|
export interface HudLinkCode {
|
|
@@ -126,6 +156,7 @@ export interface HudAnnotation {
|
|
|
126
156
|
selector: string;
|
|
127
157
|
/** Also file it as an intake task. */
|
|
128
158
|
task: boolean;
|
|
159
|
+
attachments?: readonly HudAttachment[];
|
|
129
160
|
}
|
|
130
161
|
/** What "Report a bug" sends from the sheet. */
|
|
131
162
|
export interface HudReport {
|
|
@@ -135,6 +166,7 @@ export interface HudReport {
|
|
|
135
166
|
rect: HudRect | null;
|
|
136
167
|
/** The marked element's selector; '' for a region or no mark. */
|
|
137
168
|
selector: string;
|
|
169
|
+
attachments?: readonly HudAttachment[];
|
|
138
170
|
}
|
|
139
171
|
/**
|
|
140
172
|
* What a stop or an idle report saved. `boardUrl` when the board already
|
|
@@ -154,14 +186,20 @@ export interface HudController {
|
|
|
154
186
|
togglePause(): Promise<void>;
|
|
155
187
|
/** Drains, then closes the session; rejects (session kept) while unreachable. */
|
|
156
188
|
stop(): Promise<HudSaved>;
|
|
157
|
-
|
|
189
|
+
/** `attachments` only when `canAttach`; with them, `text` may be empty. */
|
|
190
|
+
note(text: string, attachments?: readonly HudAttachment[]): void;
|
|
158
191
|
annotate(a: HudAnnotation): void;
|
|
159
192
|
setAnnotating(active: boolean): void;
|
|
160
193
|
link(): Promise<HudLinkFlow>;
|
|
161
194
|
unlink(): void;
|
|
162
195
|
/** Refresh `account` (and server prefs); null when unknown. Never rejects. */
|
|
163
196
|
getMe(): Promise<HudAccount | null>;
|
|
164
|
-
/**
|
|
197
|
+
/**
|
|
198
|
+
* Apply locally at once, then persist where the server keeps prefs. Never
|
|
199
|
+
* rejects. The sheet size (`sheetW`/`sheetH`, one call per resize) goes in
|
|
200
|
+
* its own PATCH: a server that predates it answers 422, and the size then
|
|
201
|
+
* stays on the device without costing size/verbose their server copy.
|
|
202
|
+
*/
|
|
165
203
|
setPrefs(patch: Partial<HudPrefs>): Promise<void>;
|
|
166
204
|
/** Fill missing board links of recents from the server. Never rejects. */
|
|
167
205
|
refreshRecents(): Promise<void>;
|
|
@@ -178,5 +216,19 @@ export interface HudController {
|
|
|
178
216
|
* without it never offers the menu row.
|
|
179
217
|
*/
|
|
180
218
|
report?(r: HudReport): Promise<HudSaved>;
|
|
219
|
+
/**
|
|
220
|
+
* ONE recorder D11: the HUD registers its own Stop flow; the controller
|
|
221
|
+
* runs it when the other side stops the recording remotely (its open sheet
|
|
222
|
+
* closes keeping the draft, annotate exits, Saving → Saved on this pill,
|
|
223
|
+
* no second confirm). Returns the unregister. A host whose HUD is not
|
|
224
|
+
* mounted stops directly. Optional.
|
|
225
|
+
*/
|
|
226
|
+
onRemoteStop?(run: () => void): () => void;
|
|
227
|
+
/**
|
|
228
|
+
* ONE recorder D7: the HUD reports its inline flow face, so the controller
|
|
229
|
+
* holds its claim as `saved` while Saving / Saved / failed shows after a
|
|
230
|
+
* stop. Optional.
|
|
231
|
+
*/
|
|
232
|
+
faceChanged?(face: HudFace): void;
|
|
181
233
|
}
|
|
182
234
|
export declare const DEFAULT_PREFS: HudPrefs;
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
* server is unreachable, a failed start). A link flow's `linked` rejects
|
|
15
15
|
* with an error NAMED `LinkExpired` or `AbortError` for those two outcomes.
|
|
16
16
|
*/
|
|
17
|
-
export const DEFAULT_PREFS = { size: 'md', verbose: false };
|
|
17
|
+
export const DEFAULT_PREFS = { size: 'md', verbose: false, sheetW: 0, sheetH: 0 };
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* └─cancel→ none └─dismiss→ none
|
|
7
7
|
* none ─ask(unlink)→ confirm ─confirm→ none (the caller unlinks)
|
|
8
8
|
* none ─send→ saving ─saved→ saved … (a bug report, `report: true`)
|
|
9
|
+
* any but saving ─stop→ saving … (a remote stop: no confirm, ONE recorder D11)
|
|
10
|
+
* none ─startFailed→ failed ─dismiss→ none (a refused or failed Start, `start: true`, D12)
|
|
11
|
+
* confirm | saved | failed ─follow→ none (another recorder leads, or let go: the pill comes back
|
|
12
|
+
* idle; a refused Start's face stays until dismissed)
|
|
9
13
|
*
|
|
10
14
|
* Saved stays until the tester dismisses it. A report's saving, saved and
|
|
11
15
|
* failed faces carry `report: true` through retries, so the pill can say
|
|
@@ -32,10 +36,13 @@ export type Flow = {
|
|
|
32
36
|
boardUrl?: string;
|
|
33
37
|
sessionId?: string;
|
|
34
38
|
report?: true;
|
|
35
|
-
}
|
|
39
|
+
}
|
|
40
|
+
/** `start`: a Start that was refused or failed — nothing to retry, only dismiss. */
|
|
41
|
+
| {
|
|
36
42
|
face: 'failed';
|
|
37
43
|
message: string;
|
|
38
44
|
report?: true;
|
|
45
|
+
start?: true;
|
|
39
46
|
};
|
|
40
47
|
export type FlowEvent = {
|
|
41
48
|
type: 'ask';
|
|
@@ -61,6 +68,20 @@ export type FlowEvent = {
|
|
|
61
68
|
message: string;
|
|
62
69
|
} | {
|
|
63
70
|
type: 'dismiss';
|
|
71
|
+
}
|
|
72
|
+
/** The other recorder stopped this one's recording (D11): straight to saving. */
|
|
73
|
+
| {
|
|
74
|
+
type: 'stop';
|
|
75
|
+
queued: number;
|
|
76
|
+
}
|
|
77
|
+
/** A Start was refused (`recorder_busy`) or failed (D12). */
|
|
78
|
+
| {
|
|
79
|
+
type: 'startFailed';
|
|
80
|
+
message: string;
|
|
81
|
+
}
|
|
82
|
+
/** This HUD became, or stopped being, the other recorder's remote: nothing stays open. */
|
|
83
|
+
| {
|
|
84
|
+
type: 'follow';
|
|
64
85
|
};
|
|
65
86
|
export declare const NO_FLOW: Flow;
|
|
66
87
|
export declare function flowReducer(flow: Flow, ev: FlowEvent): Flow;
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* └─cancel→ none └─dismiss→ none
|
|
7
7
|
* none ─ask(unlink)→ confirm ─confirm→ none (the caller unlinks)
|
|
8
8
|
* none ─send→ saving ─saved→ saved … (a bug report, `report: true`)
|
|
9
|
+
* any but saving ─stop→ saving … (a remote stop: no confirm, ONE recorder D11)
|
|
10
|
+
* none ─startFailed→ failed ─dismiss→ none (a refused or failed Start, `start: true`, D12)
|
|
11
|
+
* confirm | saved | failed ─follow→ none (another recorder leads, or let go: the pill comes back
|
|
12
|
+
* idle; a refused Start's face stays until dismissed)
|
|
9
13
|
*
|
|
10
14
|
* Saved stays until the tester dismisses it. A report's saving, saved and
|
|
11
15
|
* failed faces carry `report: true` through retries, so the pill can say
|
|
@@ -31,7 +35,8 @@ export function flowReducer(flow, ev) {
|
|
|
31
35
|
case 'send':
|
|
32
36
|
return flow.face === 'none' ? { face: 'saving', total: 0, report: true } : flow;
|
|
33
37
|
case 'retry':
|
|
34
|
-
|
|
38
|
+
// A failed Start has nothing to retry: pressing Start again is the retry.
|
|
39
|
+
return flow.face === 'failed' && !flow.start ? { face: 'saving', total: ev.queued, ...reportOf(flow) } : flow;
|
|
35
40
|
case 'saved':
|
|
36
41
|
return flow.face === 'saving'
|
|
37
42
|
? {
|
|
@@ -45,6 +50,16 @@ export function flowReducer(flow, ev) {
|
|
|
45
50
|
return flow.face === 'saving' ? { face: 'failed', message: ev.message, ...reportOf(flow) } : flow;
|
|
46
51
|
case 'dismiss':
|
|
47
52
|
return flow.face === 'saved' || flow.face === 'failed' ? NO_FLOW : flow;
|
|
53
|
+
case 'stop':
|
|
54
|
+
return flow.face === 'saving' ? flow : { face: 'saving', total: ev.queued };
|
|
55
|
+
case 'startFailed':
|
|
56
|
+
return flow.face === 'none' ? { face: 'failed', message: ev.message, start: true } : flow;
|
|
57
|
+
case 'follow':
|
|
58
|
+
// A save in flight keeps its face (it settles on its own), and so does
|
|
59
|
+
// a refused Start: it is what tells the tester why the pill steps aside.
|
|
60
|
+
if (flow.face === 'none' || flow.face === 'saving' || (flow.face === 'failed' && flow.start))
|
|
61
|
+
return flow;
|
|
62
|
+
return NO_FLOW;
|
|
48
63
|
}
|
|
49
64
|
}
|
|
50
65
|
/** Save progress 0…1 while draining `total` items of which `queued` remain; null = indeterminate. */
|
|
@@ -18,6 +18,8 @@ const SHIELDED = [
|
|
|
18
18
|
'mousedown', 'mouseup', 'mousemove', 'mouseover', 'mouseout', 'click', 'dblclick', 'auxclick',
|
|
19
19
|
'contextmenu', 'touchstart', 'touchend', 'touchmove', 'touchcancel', 'wheel',
|
|
20
20
|
'focusin', 'focusout', 'keydown', 'keyup', 'keypress',
|
|
21
|
+
// An image pasted or dropped onto a sheet is the HUD's, never the page's upload.
|
|
22
|
+
'paste', 'dragenter', 'dragover', 'dragleave', 'drop',
|
|
21
23
|
];
|
|
22
24
|
export function shield(el) {
|
|
23
25
|
for (const t of SHIELDED)
|
|
@@ -10,6 +10,9 @@ export declare function PencilIcon(): ReactElement;
|
|
|
10
10
|
export declare function AnnotateIcon(): ReactElement;
|
|
11
11
|
export declare function CloseIcon(): ReactElement;
|
|
12
12
|
export declare function ArrowUpIcon(): ReactElement;
|
|
13
|
+
export declare function PaperclipIcon(): ReactElement;
|
|
14
|
+
/** The sheet's resize grip, drawn for the bottom-right corner (CSS turns it to the others). */
|
|
15
|
+
export declare function GripIcon(): ReactElement;
|
|
13
16
|
export declare function MoreIcon(): ReactElement;
|
|
14
17
|
export declare function NewTabIcon(): ReactElement;
|
|
15
18
|
export declare function StopIcon(): ReactElement;
|
|
@@ -29,6 +29,13 @@ export function CloseIcon() {
|
|
|
29
29
|
export function ArrowUpIcon() {
|
|
30
30
|
return (_jsxs("svg", { ...base, children: [_jsx("path", { d: "M12 19V5" }), _jsx("path", { d: "m5 12 7-7 7 7" })] }));
|
|
31
31
|
}
|
|
32
|
+
export function PaperclipIcon() {
|
|
33
|
+
return (_jsx("svg", { ...base, children: _jsx("path", { d: "m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" }) }));
|
|
34
|
+
}
|
|
35
|
+
/** The sheet's resize grip, drawn for the bottom-right corner (CSS turns it to the others). */
|
|
36
|
+
export function GripIcon() {
|
|
37
|
+
return (_jsxs("svg", { ...base, children: [_jsx("path", { d: "M20 9 9 20" }), _jsx("path", { d: "M20 15l-5 5" })] }));
|
|
38
|
+
}
|
|
32
39
|
export function MoreIcon() {
|
|
33
40
|
return (_jsxs("svg", { ...base, children: [_jsx("circle", { cx: "12", cy: "12", r: "1" }), _jsx("circle", { cx: "19", cy: "12", r: "1" }), _jsx("circle", { cx: "5", cy: "12", r: "1" })] }));
|
|
34
41
|
}
|
|
@@ -46,7 +46,8 @@ export declare function hostOrigin(mount: HTMLElement): {
|
|
|
46
46
|
* A popover anchored to the dock: toward the page centre (sideways from a
|
|
47
47
|
* vertical or tucked dock), flush with the dock's outer edge, flipped and
|
|
48
48
|
* shifted so the measured `size` never leaves the viewport; it grows from
|
|
49
|
-
* the point nearest the dock.
|
|
49
|
+
* the point nearest the dock. `side` is where it opened, `room` the tallest
|
|
50
|
+
* it may stand there without covering the dock or leaving the viewport.
|
|
50
51
|
*/
|
|
51
52
|
export declare function anchoredLayer(dock: Box, size: {
|
|
52
53
|
w: number;
|
|
@@ -57,6 +58,8 @@ export declare function anchoredLayer(dock: Box, size: {
|
|
|
57
58
|
}): {
|
|
58
59
|
style: CSSProperties;
|
|
59
60
|
origin: string;
|
|
61
|
+
side: FloatSide;
|
|
62
|
+
room: number;
|
|
60
63
|
};
|
|
61
64
|
/** A phone bottom sheet: the full visual viewport, content pinned to its bottom edge. */
|
|
62
65
|
export declare function phoneLayer(origin: {
|