@aperture-browser/session-react 1.0.0-beta.1 → 1.0.0-beta.3

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.
@@ -152,13 +152,15 @@ interface SessionConnection {
152
152
  }
153
153
  /**
154
154
  * Connects to a session for as long as the component is mounted. Another address, name or
155
- * first way of the picture makes another connection.
155
+ * first way of the picture makes another connection; another first tab is the one a
156
+ * connection made after it starts with.
156
157
  */
157
158
  declare function useConnectedSession({
158
159
  url,
159
160
  token,
160
161
  name,
161
- pixels
162
+ pixels,
163
+ tab
162
164
  }: ConnectOptions): SessionConnection;
163
165
  interface SessionProviderProps {
164
166
  readonly session: Session;
package/dist/headless.js CHANGED
@@ -4,17 +4,21 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/session.tsx
5
5
  /**
6
6
  * Connects to a session for as long as the component is mounted. Another address, name or
7
- * first way of the picture makes another connection.
7
+ * first way of the picture makes another connection; another first tab is the one a
8
+ * connection made after it starts with.
8
9
  */
9
- function useConnectedSession({ url, token, name, pixels }) {
10
+ function useConnectedSession({ url, token, name, pixels, tab }) {
10
11
  const [session, setSession] = useState(null);
11
12
  const [attempt, setAttempt] = useState(0);
13
+ const firstTab = useRef(tab);
14
+ firstTab.current = tab;
12
15
  useEffect(() => {
13
16
  const connected = connect$1({
14
17
  url,
15
18
  token,
16
19
  name,
17
- pixels
20
+ pixels,
21
+ tab: firstTab.current
18
22
  });
19
23
  setSession(connected);
20
24
  return () => {
@@ -194,9 +198,6 @@ function SessionViewport({ className, style, children }) {
194
198
  const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);
195
199
  const shown = watched === void 0 ? void 0 : way;
196
200
  const agrees = watched !== void 0 && drawn.width > 0 && sameShape(drawn, watched);
197
- /** The picture's pixels to a logical pixel of its target, when the two last agreed. */
198
- const density = useRef(1);
199
- if (agrees) density.current = drawn.width / watched.width;
200
201
  const awaited = watched !== void 0 && drawn.width > 0 && !agrees ? `${watched.id} ${watched.width}x${watched.height}` : void 0;
201
202
  const [overdue, setOverdue] = useState(void 0);
202
203
  useEffect(() => {
@@ -205,10 +206,8 @@ function SessionViewport({ className, style, children }) {
205
206
  return () => clearTimeout(waiting);
206
207
  }, [awaited]);
207
208
  const settled = awaited === void 0 || awaited === overdue;
208
- const box = watched === void 0 ? void 0 : pictureBox(stage, settled ? watched : {
209
- width: drawn.width / density.current,
210
- height: drawn.height / density.current
211
- });
209
+ const place = watched === void 0 ? void 0 : pictureBox(stage, watched);
210
+ const box = place === void 0 || settled ? place : shapedIn(place, drawn);
212
211
  const picture = (visible) => ({
213
212
  display: visible ? "block" : "none",
214
213
  flex: "none",
@@ -283,6 +282,14 @@ function sameShape(one, other) {
283
282
  const ratio = one.width / one.height * (other.height / other.width);
284
283
  return Math.abs(ratio - 1) < .01;
285
284
  }
285
+ /** The largest size of a shape that fits a place. */
286
+ function shapedIn(place, shape) {
287
+ const scale = Math.min(place.width / shape.width, place.height / shape.height);
288
+ return {
289
+ width: Math.floor(shape.width * scale),
290
+ height: Math.floor(shape.height * scale)
291
+ };
292
+ }
286
293
  /** The place the picture of a target has in a stage: its own size, or smaller to fit. */
287
294
  function pictureBox(stage, target) {
288
295
  if (target.width <= 0 || target.height <= 0) return {
@@ -1 +1 @@
1
- {"version":3,"file":"headless.js","names":["connect"],"sources":["../src/session.tsx","../src/components/session-viewport.tsx","../src/hooks/use-actions.ts","../src/hooks/use-address.ts","../src/hooks/use-stored.ts","../src/hooks/use-fit.ts","../src/hooks/use-recordings.ts","../src/hooks/use-uploads.ts","../src/hooks/use-timeline.ts"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\nimport {\n connect,\n type ConnectOptions,\n type HeldTab,\n type Member,\n type Role,\n type Session,\n type Snapshot,\n type Target,\n} from \"@aperture-browser/session-client\";\n\nexport interface SessionConnection {\n /** None until the page has mounted, and none between two connections. */\n readonly session: Session | null;\n /** Ends the connection there is and makes a new one: a closed connection does not come back. */\n readonly reconnect: () => void;\n}\n\n/**\n * Connects to a session for as long as the component is mounted. Another address, name or\n * first way of the picture makes another connection.\n */\nexport function useConnectedSession({\n url,\n token,\n name,\n pixels,\n}: ConnectOptions): SessionConnection {\n const [session, setSession] = useState<Session | null>(null);\n const [attempt, setAttempt] = useState(0);\n\n useEffect(() => {\n const connected = connect({ url, token, name, pixels });\n setSession(connected);\n return () => {\n setSession(null);\n connected.close();\n };\n }, [url, token, name, pixels, attempt]);\n\n return useMemo(\n () => ({\n session,\n reconnect: () => setAttempt((current) => current + 1),\n }),\n [session],\n );\n}\n\ninterface SessionContextValue {\n readonly session: Session;\n readonly reconnect: (() => void) | undefined;\n}\n\nconst SessionContext = createContext<SessionContextValue | null>(null);\n\nexport interface SessionProviderProps {\n readonly session: Session;\n /** Offered where the connection is closed, when there is a way to make another. */\n readonly reconnect?: (() => void) | undefined;\n readonly children?: ReactNode;\n}\n\nexport function SessionProvider({ session, reconnect, children }: SessionProviderProps) {\n const value = useMemo(() => ({ session, reconnect }), [session, reconnect]);\n return <SessionContext.Provider value={value}>{children}</SessionContext.Provider>;\n}\n\nfunction useSessionContext(): SessionContextValue {\n const value = useContext(SessionContext);\n if (value === null) {\n throw new Error(\"The session's components are used outside a SessionProvider\");\n }\n return value;\n}\n\nexport function useSession(): Session {\n return useSessionContext().session;\n}\n\nexport function useReconnect(): (() => void) | undefined {\n return useSessionContext().reconnect;\n}\n\nexport function useSessionSnapshot(): Snapshot {\n const session = useSession();\n return useSyncExternalStore(session.subscribe, session.getSnapshot, session.getSnapshot);\n}\n\n/** The target that is watched. */\nexport function useWatchedTarget(): Target | undefined {\n const snapshot = useSessionSnapshot();\n return snapshot.targets.find((target) => target.tab === snapshot.selected);\n}\n\nexport type LeaseState =\n /** The role lets this member watch only. */\n | \"view-only\"\n /** Nobody holds the watched tab: whoever gives it input holds it. */\n | \"free\"\n | \"yours\"\n /** This member holds the tab and another asks for it. */\n | \"asked-of-you\"\n | \"theirs\"\n /** Another holds the tab and this member has asked for it. */\n | \"you-asked\"\n /** Another holds the tab and a third member has asked for it. */\n | \"theirs-asked\";\n\nexport interface Lease {\n readonly state: LeaseState;\n /** The member this client is, once the session told. */\n readonly you: Member | undefined;\n readonly role: Role | undefined;\n /** Whether this member's role lets it give input and change the session's tabs. */\n readonly givesInput: boolean;\n readonly held: HeldTab | undefined;\n readonly holder: Member | undefined;\n readonly asker: Member | undefined;\n}\n\n/** Who holds the lease of the watched tab, and what this member may do about it. */\nexport function useLease(): Lease {\n const snapshot = useSessionSnapshot();\n const { presence } = snapshot;\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const you = presence?.members.find((member) => member.id === presence.you);\n const held = presence?.held.find((one) => one.tab === watched?.tab);\n const holder = presence?.members.find((member) => member.id === held?.holder);\n const asker = presence?.members.find((member) => member.id === held?.askedBy);\n const role = you?.role;\n // A member whose role the session has not told yet is not held back: the session refuses\n // what the role does not allow.\n const givesInput = role !== \"view\";\n\n let state: LeaseState = \"free\";\n if (!givesInput) {\n state = \"view-only\";\n } else if (held === undefined || presence === undefined) {\n state = \"free\";\n } else if (held.holder === presence.you) {\n state = held.askedBy === undefined ? \"yours\" : \"asked-of-you\";\n } else if (held.askedBy === presence.you) {\n state = \"you-asked\";\n } else {\n state = held.askedBy === undefined ? \"theirs\" : \"theirs-asked\";\n }\n\n return { state, you, role, givesInput, held, holder, asker };\n}\n","import { useEffect, useRef, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\n\nexport interface SessionViewportProps {\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n /** Laid over the picture, such as the connection's state. */\n readonly children?: ReactNode;\n}\n\nconst PICTURE_WITHIN_MS = 1000;\n/** How long after the room for the picture last changed it counts as still changing. */\nconst RESIZED_AFTER_MS = 200;\nconst SETTLING_BLUR_PX = 6;\nconst SETTLING_FADE_MS = 160;\n\ninterface Size {\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * The watched target's picture, and its input: the pointer, the wheel, the keyboard, the\n * clipboard and what is dropped on it. The picture is shown at the target's own size, and\n * smaller where the stage has no room for that.\n */\nexport function SessionViewport({ className, style, children }: SessionViewportProps) {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const stageRef = useRef<HTMLDivElement>(null);\n const videoRef = useRef<HTMLVideoElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const keysRef = useRef<HTMLTextAreaElement>(null);\n const [stage, setStage] = useState<Size>({ width: 0, height: 0 });\n /** The size of the picture that is drawn now, in its own pixels. */\n const [drawn, setDrawn] = useState<Size>({ width: 0, height: 0 });\n /** Whether the room for the picture is being changed, as by dragging the window's edge. */\n const [resizing, setResizing] = useState(false);\n const way = snapshot.picture.way;\n\n useEffect(() => {\n const surfaces = {\n video: videoRef.current,\n canvas: canvasRef.current,\n keys: keysRef.current,\n stage: stageRef.current,\n };\n if (\n surfaces.video === null ||\n surfaces.canvas === null ||\n surfaces.keys === null ||\n surfaces.stage === null\n ) {\n return undefined;\n }\n return session.attach({\n video: surfaces.video,\n canvas: surfaces.canvas,\n keys: surfaces.keys,\n stage: surfaces.stage,\n });\n }, [session]);\n\n useEffect(() => {\n const element = stageRef.current;\n if (element === null) {\n return undefined;\n }\n let settling: ReturnType<typeof setTimeout> | undefined;\n const measure = () => {\n const next = { width: element.clientWidth, height: element.clientHeight };\n setStage((before) => {\n // The first measure is no change of size, and neither is one that measures the same.\n if (before.width > 0 && (before.width !== next.width || before.height !== next.height)) {\n setResizing(true);\n clearTimeout(settling);\n settling = setTimeout(() => setResizing(false), RESIZED_AFTER_MS);\n }\n return next;\n });\n };\n measure();\n const sizes = new ResizeObserver(measure);\n sizes.observe(element);\n return () => {\n sizes.disconnect();\n clearTimeout(settling);\n };\n }, []);\n\n useEffect(() => {\n const video = videoRef.current;\n const canvas = canvasRef.current;\n if (video === null || canvas === null) {\n return undefined;\n }\n const measure = () => {\n const size =\n way === \"video\"\n ? { width: video.videoWidth, height: video.videoHeight }\n : { width: canvas.width, height: canvas.height };\n setDrawn((before) =>\n before.width === size.width && before.height === size.height ? before : size,\n );\n };\n measure();\n video.addEventListener(\"resize\", measure);\n video.addEventListener(\"loadedmetadata\", measure);\n // A canvas says nothing when what is drawn into it changes its size.\n const sizes = new MutationObserver(measure);\n sizes.observe(canvas, { attributes: true, attributeFilter: [\"width\", \"height\"] });\n return () => {\n video.removeEventListener(\"resize\", measure);\n video.removeEventListener(\"loadedmetadata\", measure);\n sizes.disconnect();\n };\n }, [way]);\n\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const shown = watched === undefined ? undefined : way;\n // The picture of another tab, or of this one at another size, comes a moment after the\n // session says which tab is watched and how large it is. Until what is drawn has the\n // shape of what is watched, the picture has the place of what is drawn: a window that\n // is dragged larger is some sizes ahead of its picture all the while, and a place kept\n // from before the drag would hold each picture that comes to the shape of the first.\n const agrees = watched !== undefined && drawn.width > 0 && sameShape(drawn, watched);\n /** The picture's pixels to a logical pixel of its target, when the two last agreed. */\n const density = useRef(1);\n if (agrees) {\n density.current = drawn.width / watched.width;\n }\n const awaited =\n watched !== undefined && drawn.width > 0 && !agrees\n ? `${watched.id} ${watched.width}x${watched.height}`\n : undefined;\n // A picture that does not come is not waited for longer than this.\n const [overdue, setOverdue] = useState<string | undefined>(undefined);\n useEffect(() => {\n if (awaited === undefined) {\n return undefined;\n }\n const waiting = setTimeout(() => setOverdue(awaited), PICTURE_WITHIN_MS);\n return () => clearTimeout(waiting);\n }, [awaited]);\n const settled = awaited === undefined || awaited === overdue;\n const box =\n watched === undefined\n ? undefined\n : pictureBox(\n stage,\n settled\n ? watched\n : {\n width: drawn.width / density.current,\n height: drawn.height / density.current,\n },\n );\n\n const picture = (visible: boolean): CSSProperties => ({\n display: visible ? \"block\" : \"none\",\n flex: \"none\",\n width: box?.width,\n height: box?.height,\n outline: \"none\",\n // A touch that drags is the session's pointer, not a scroll of this page.\n touchAction: \"none\",\n cursor: snapshot.cursor,\n // While its room changes and until the picture of the new size is there, what is\n // drawn is stretched or stale: softened, it reads as settling and not as broken.\n filter: resizing || !settled ? `blur(${SETTLING_BLUR_PX}px)` : \"none\",\n transition: `filter ${SETTLING_FADE_MS}ms ease-out`,\n });\n\n return (\n <div\n ref={stageRef}\n className={className}\n data-aperture-stage=\"\"\n // For whatever stands in for the picture until there is one.\n data-aperture-drawn={drawn.width > 0 ? \"\" : undefined}\n style={{\n position: \"relative\",\n display: \"flex\",\n flex: \"1 1 0%\",\n minWidth: 0,\n minHeight: 0,\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n ...style,\n }}\n >\n <video\n ref={videoRef}\n data-aperture-surface=\"video\"\n tabIndex={-1}\n autoPlay\n muted\n playsInline\n style={picture(shown === \"video\")}\n />\n <canvas\n ref={canvasRef}\n data-aperture-surface=\"canvas\"\n tabIndex={-1}\n style={picture(shown === \"frames\" || shown === \"tiles\")}\n />\n <textarea\n ref={keysRef}\n data-aperture-surface=\"keys\"\n aria-label=\"Keyboard of the session\"\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n style={{\n position: \"absolute\",\n left: 0,\n bottom: 0,\n width: 1,\n height: 1,\n padding: 0,\n border: 0,\n opacity: 0,\n resize: \"none\",\n // A phone zooms into a field whose text is smaller than this.\n fontSize: 16,\n }}\n />\n {children}\n </div>\n );\n}\n\n/** Whether two sizes have the same proportions, give or take a pixel's rounding. */\nfunction sameShape(one: Size, other: Size): boolean {\n if (one.height <= 0 || other.height <= 0) {\n return false;\n }\n const ratio = (one.width / one.height) * (other.height / other.width);\n return Math.abs(ratio - 1) < 0.01;\n}\n\n/** The place the picture of a target has in a stage: its own size, or smaller to fit. */\nexport function pictureBox(stage: Size, target: Size): Size {\n if (target.width <= 0 || target.height <= 0) {\n return { width: 0, height: 0 };\n }\n const scale = Math.min(1, stage.width / target.width, stage.height / target.height);\n return {\n width: Math.floor(target.width * scale),\n height: Math.floor(target.height * scale),\n };\n}\n","import { useCallback } from \"react\";\nimport type { Target } from \"@aperture-browser/session-client\";\nimport { useLease, useSession, useSessionSnapshot } from \"../session.tsx\";\n\nexport interface TabSound {\n /** The tab plays something now. */\n readonly sounds: boolean;\n /** The tab is muted for this client. */\n readonly muted: boolean;\n readonly toggle: () => void;\n}\n\n/** A tab's sound, as this client hears it. */\nexport function useTabSound(target: Target | undefined): TabSound {\n const session = useSession();\n const muted = useSessionSnapshot().muted.includes(target?.tab ?? -1);\n const tab = target?.tab;\n const toggle = useCallback(() => {\n if (tab !== undefined) {\n session.setMuted(tab, !muted);\n }\n }, [session, tab, muted]);\n return { sounds: target?.sounds ?? false, muted, toggle };\n}\n\nexport interface InputState {\n readonly open: boolean;\n /** This member may open, close and take tabs elsewhere, and give them another size. */\n readonly changes: boolean;\n /** This member may give the watched tab input. */\n readonly gives: boolean;\n}\n\n/** What this member may do in the session now. */\nexport function useInputState(): InputState {\n const snapshot = useSessionSnapshot();\n const lease = useLease();\n const open = snapshot.connection.state === \"open\";\n return {\n open,\n changes: open && snapshot.features.tabs.write,\n gives: open && lease.givesInput && snapshot.selected !== undefined,\n };\n}\n","import { useState } from \"react\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\n\nexport interface AddressControl {\n /** What the address field shows: what is typed, or the watched tab's address. */\n readonly value: string;\n /** Whether this member may take the watched tab elsewhere. */\n readonly navigates: boolean;\n readonly type: (value: string) => void;\n /** Lets go of what was typed and not sent. */\n readonly reset: () => void;\n /** Takes the watched tab to what was typed; false when that is nothing. */\n readonly submit: (value: string) => boolean;\n}\n\n/** The watched tab's address, as a field to type another into. */\nexport function useAddress(): AddressControl {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const [draft, setDraft] = useState<{ tab: number | undefined; url: string } | null>(null);\n // What was typed and not sent belongs to the tab it was typed for.\n const typed = draft !== null && draft.tab === watched?.tab ? draft.url : null;\n\n return {\n value: typed ?? watched?.url ?? \"\",\n navigates:\n snapshot.connection.state === \"open\" && snapshot.features.tabs.write && watched !== undefined,\n type: (url) => setDraft({ tab: watched?.tab, url }),\n reset: () => setDraft(null),\n submit: (value) => {\n const url = value.trim();\n if (url === \"\") {\n return false;\n }\n session.go({ url: addressOf(url) });\n setDraft(null);\n return true;\n },\n };\n}\n\n/** What is typed into an address field as a URL: an address as it is, anything else a search. */\nexport function addressOf(value: string): string {\n if (isLocalHost(value)) {\n return `http://${value}`;\n }\n if (\n /^[a-z][a-z0-9+.-]*:\\/\\//iu.test(value) ||\n /^(?:about|chrome|devtools|data|file|view-source):/iu.test(value)\n ) {\n return value;\n }\n if (isLikelyHost(value)) {\n return `https://${value}`;\n }\n return `https://www.google.com/search?q=${encodeURIComponent(value)}`;\n}\n\nfunction isLocalHost(value: string): boolean {\n return (\n /^localhost(?::\\d+)?(?:[/?#].*)?$/iu.test(value) ||\n /^127(?:\\.\\d{1,3}){3}(?::\\d+)?(?:[/?#].*)?$/u.test(value) ||\n /^[a-z0-9-]+:\\d+(?:[/?#].*)?$/iu.test(value)\n );\n}\n\nfunction isLikelyHost(value: string): boolean {\n return !/\\s/u.test(value) && /^[a-z0-9-]+(?:\\.[a-z0-9-]+)+(?:[/:?#].*)?$/iu.test(value);\n}\n","import { useCallback, useSyncExternalStore } from \"react\";\n\n/** What each key holds now, as it was read or last set, for all who use the key. */\nconst values = new Map<string, unknown>();\nconst listeners = new Map<string, Set<() => void>>();\n\nfunction read(key: string): unknown {\n if (!values.has(key)) {\n let stored: unknown;\n try {\n const text = window.localStorage.getItem(key);\n stored = text === null ? undefined : JSON.parse(text);\n } catch {\n // Storage that is unavailable gives the default.\n stored = undefined;\n }\n values.set(key, stored);\n }\n return values.get(key);\n}\n\n/**\n * A choice this browser remembers, the same for everything on the page that uses the key.\n * It lasts for the page where storage is unavailable.\n */\nexport function useStored<Value>(\n key: string,\n fallback: Value,\n valid: (value: unknown) => value is Value,\n): readonly [Value, (value: Value) => void] {\n const subscribe = useCallback(\n (listener: () => void) => {\n const heard = listeners.get(key) ?? new Set();\n listeners.set(key, heard);\n heard.add(listener);\n return () => {\n heard.delete(listener);\n };\n },\n [key],\n );\n const stored = useSyncExternalStore(\n subscribe,\n () => read(key),\n () => undefined,\n );\n // What another version wrote gives the default.\n const value = valid(stored) ? stored : fallback;\n\n const store = useCallback(\n (next: Value) => {\n values.set(key, next);\n try {\n window.localStorage.setItem(key, JSON.stringify(next));\n } catch {\n // Kept for this page only.\n }\n for (const listener of listeners.get(key) ?? []) {\n listener();\n }\n },\n [key],\n );\n\n return [value, store];\n}\n","import { useEffect, useRef } from \"react\";\nimport type { Session } from \"@aperture-browser/session-client\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useStored } from \"./use-stored.ts\";\n\nconst FIT_KEY = \"aperture.session.fit\";\n\nconst isBoolean = (value: unknown): value is boolean => typeof value === \"boolean\";\n\n/**\n * Has the viewport fit the window, unless that was switched off when this browser was last\n * here, and remembers when it is switched on or off. `follows` is false where the embedder\n * wants targets left at the size they have.\n */\nexport function useRememberedFit(follows = true) {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const [remembered, remember] = useStored(FIT_KEY, true, isBoolean);\n const applied = useRef<Session | undefined>(undefined);\n const ready =\n follows &&\n snapshot.connection.state === \"open\" &&\n snapshot.selected !== undefined &&\n snapshot.features.tabs.write;\n\n useEffect(() => {\n if (!ready) {\n return;\n }\n if (applied.current !== session) {\n applied.current = session;\n if (remembered && !snapshot.fit) {\n // The tab may be someone's at work in it: its size waits for this member's turn.\n session.setViewport(\"fit\", { whenFree: true });\n }\n return;\n }\n if (snapshot.fit !== remembered) {\n remember(snapshot.fit);\n }\n }, [ready, session, snapshot.fit, remembered, remember]);\n}\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type {\n EditRecording,\n Recording,\n Screenshot,\n StartRecording,\n} from \"@aperture-browser/session-client\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\n\n/** How often the recordings are asked for while one is being made or edited. */\nconst BUSY_EVERY_MS = 2000;\n/** How often otherwise: a recording may be started by the session's automation too. */\nconst IDLE_EVERY_MS = 15_000;\n\nexport interface RecordingsControl {\n /** Newest first. */\n readonly recordings: readonly Recording[];\n /** Newest first. */\n readonly screenshots: readonly Screenshot[];\n /** A start or a stop is on its way. */\n readonly busy: boolean;\n readonly refresh: () => void;\n /** Rejects with what the session answered. */\n readonly start: (options?: StartRecording) => Promise<Recording>;\n /** Stops a recording; its edit is made with `options`. */\n readonly stop: (id: string, options?: EditRecording) => Promise<Recording>;\n /** Makes the edit of a stopped recording again, with other options. */\n readonly edit: (id: string, options?: EditRecording) => Promise<Recording>;\n /** Takes a screenshot of a target and keeps it in the session's files. */\n readonly takeScreenshot: (tab: number) => Promise<Screenshot>;\n}\n\nexport const recordingRuns = (recording: Recording) => recording.state === \"recording\";\n\nexport const recordingIsEdited = (recording: Recording) => recording.edit?.state === \"editing\";\n\n/**\n * The session's recordings and screenshots. The live protocol does not tell of them, so they are asked for\n * again and again: often while one runs or is edited, seldom otherwise.\n */\nexport function useRecordings(enabled = true): RecordingsControl {\n const session = useSession();\n const open = useSessionSnapshot().connection.state === \"open\" && enabled;\n const [recordings, setRecordings] = useState<readonly Recording[]>([]);\n const [screenshots, setScreenshots] = useState<readonly Screenshot[]>([]);\n const [busy, setBusy] = useState(false);\n const [asked, setAsked] = useState(0);\n const active = recordings.some((one) => recordingRuns(one) || recordingIsEdited(one));\n const latest = useRef(0);\n\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n let ended = false;\n const ask = () => {\n latest.current += 1;\n const turn = latest.current;\n session.recordings.list().then(\n (listed) => {\n // An answer that was overtaken by a later one tells what is no longer so.\n if (!ended && turn === latest.current) {\n setRecordings(listed.toSorted((a, b) => b.started_at_ms - a.started_at_ms));\n }\n },\n () => {\n // The list stays as it was: the next turn asks again.\n },\n );\n session.screenshots.list().then(\n (listed) => {\n if (!ended && turn === latest.current) {\n setScreenshots(listed);\n }\n },\n () => {},\n );\n };\n ask();\n const timer = setInterval(ask, active ? BUSY_EVERY_MS : IDLE_EVERY_MS);\n return () => {\n ended = true;\n clearInterval(timer);\n };\n }, [session, open, active, asked]);\n\n const refresh = useCallback(() => setAsked((current) => current + 1), []);\n\n const start = useCallback(\n async (options?: StartRecording) => {\n setBusy(true);\n try {\n return await session.recordings.start(options);\n } finally {\n setBusy(false);\n refresh();\n }\n },\n [session, refresh],\n );\n\n const stop = useCallback(\n async (id: string, options?: EditRecording) => {\n setBusy(true);\n try {\n return await session.recordings.stop(id, options);\n } finally {\n setBusy(false);\n refresh();\n }\n },\n [session, refresh],\n );\n\n const edit = useCallback(\n async (id: string, options?: EditRecording) => {\n try {\n return await session.recordings.edit(id, options);\n } finally {\n refresh();\n }\n },\n [session, refresh],\n );\n\n const takeScreenshot = useCallback(\n async (tab: number) => {\n try {\n return await session.screenshots.take(tab);\n } finally {\n refresh();\n }\n },\n [session, refresh],\n );\n\n return { recordings, screenshots, busy, refresh, start, stop, edit, takeScreenshot };\n}\n\n/** Something the session kept of a tab: a recording that ended, or a screenshot. */\nexport type Kept =\n | {\n readonly kind: \"recording\";\n readonly id: string;\n readonly at: number;\n readonly recording: Recording;\n }\n | {\n readonly kind: \"screenshot\";\n readonly id: string;\n readonly at: number;\n readonly screenshot: Screenshot;\n };\n\n/** The recordings that ended and the screenshots as one list, newest first. */\nexport function keptOf(control: RecordingsControl): readonly Kept[] {\n const recordings = control.recordings\n .filter((recording) => !recordingRuns(recording))\n .map(\n (recording): Kept => ({\n kind: \"recording\",\n id: recording.id,\n at: recording.started_at_ms,\n recording,\n }),\n );\n const screenshots = control.screenshots.map(\n (screenshot): Kept => ({\n kind: \"screenshot\",\n id: screenshot.id,\n at: screenshot.taken_at_ms,\n screenshot,\n }),\n );\n return [...recordings, ...screenshots].toSorted((left, right) => right.at - left.at);\n}\n","import { useCallback, useEffect, useState } from \"react\";\nimport type { Uploaded } from \"@aperture-browser/session-client\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\n\n/** A file on its way into the session. */\nexport interface UploadInProgress {\n readonly name: string;\n readonly loaded: number;\n readonly total: number;\n}\n\nexport interface UploadsControl {\n /** The files that are in the session for its browser to take. */\n readonly uploads: readonly Uploaded[];\n readonly inProgress: readonly UploadInProgress[];\n readonly refresh: () => void;\n /**\n * Puts files into the session. Gives those that got there; `onFailure` hears of each\n * that did not.\n */\n readonly upload: (\n files: readonly File[],\n onFailure?: (file: File, cause: unknown) => void,\n ) => Promise<Uploaded[]>;\n /** Rejects with what the session answered. */\n readonly remove: (name: string) => Promise<void>;\n}\n\n/** The session's uploads. A file put there by another member shows at the next `refresh`. */\nexport function useUploads(enabled = true): UploadsControl {\n const session = useSession();\n const open = useSessionSnapshot().connection.state === \"open\" && enabled;\n const [uploads, setUploads] = useState<readonly Uploaded[]>([]);\n const [inProgress, setInProgress] = useState<readonly UploadInProgress[]>([]);\n const [asked, setAsked] = useState(0);\n\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n let ended = false;\n session.uploads().then(\n (listed) => {\n if (!ended) {\n setUploads(listed.toSorted((a, b) => a.name.localeCompare(b.name)));\n }\n },\n () => {\n // The list stays as it was until it is asked for again.\n },\n );\n return () => {\n ended = true;\n };\n }, [session, open, asked]);\n\n const refresh = useCallback(() => setAsked((current) => current + 1), []);\n\n const upload = useCallback(\n async (files: readonly File[], onFailure?: (file: File, cause: unknown) => void) => {\n const put = await Promise.all(\n files.map(async (file) => {\n const progress = (loaded: number, total: number) =>\n setInProgress((current) => [\n ...current.filter((one) => one.name !== file.name),\n { name: file.name, loaded, total },\n ]);\n progress(0, file.size);\n try {\n return await session.upload(file, ({ loaded, total }) => progress(loaded, total));\n } catch (cause) {\n onFailure?.(file, cause);\n return undefined;\n } finally {\n setInProgress((current) => current.filter((one) => one.name !== file.name));\n }\n }),\n );\n refresh();\n return put.filter((one) => one !== undefined);\n },\n [session, refresh],\n );\n\n const remove = useCallback(\n async (name: string) => {\n try {\n await session.removeUpload(name);\n } finally {\n refresh();\n }\n },\n [session, refresh],\n );\n\n return { uploads, inProgress, refresh, upload, remove };\n}\n","import { useEffect, useState } from \"react\";\nimport type { Recording } from \"@aperture-browser/session-client\";\nimport { useSession } from \"../session.tsx\";\n\n/** A stretch of the raw video the edit kept, and how much faster it plays there. */\nexport interface TimelinePiece {\n readonly raw_start_ms: number;\n readonly raw_end_ms: number;\n readonly speed: number;\n readonly edited_start_ms: number;\n}\n\n/** Something that happened while the recording ran, in the raw video's time and the edit's. */\nexport interface TimelineEvent {\n /** `call` for a tool of the automation, `press`, `move`, `wheel`, `caption` and so on. */\n readonly kind: string;\n readonly at_ms: number;\n readonly end_ms: number;\n readonly edited_at_ms: number;\n readonly edited_end_ms: number;\n readonly [field: string]: unknown;\n}\n\n/** A recording's timeline, as the session writes it next to the edit. */\nexport interface RecordingTimeline {\n readonly duration_ms: number;\n readonly edited_duration_ms: number;\n /** The video's size in pixels. */\n readonly width: number;\n readonly height: number;\n readonly map: readonly TimelinePiece[];\n readonly events: readonly TimelineEvent[];\n readonly events_dropped: number;\n}\n\nconst isTimeline = (value: unknown): value is RecordingTimeline => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const { duration_ms, map, events } = value as Record<string, unknown>;\n return typeof duration_ms === \"number\" && Array.isArray(map) && Array.isArray(events);\n};\n\n/** The timeline of a recording whose edit is made; none before, and where there is no edit. */\nexport function useRecordingTimeline(\n recording: Recording | undefined,\n): RecordingTimeline | undefined {\n const session = useSession();\n const file = recording?.edit?.timeline ?? undefined;\n // An edit that was made again has the file of the one before.\n const made = recording?.edit?.made_at_ms ?? 0;\n const [read, setRead] = useState<\n { file: string; made: number; timeline: RecordingTimeline } | undefined\n >();\n\n useEffect(() => {\n if (file === undefined) {\n return undefined;\n }\n const asking = new AbortController();\n fetch(session.fileUrl(file), { signal: asking.signal, cache: \"no-store\" })\n .then((answer) => (answer.ok ? answer.json() : undefined))\n .then(\n (timeline: unknown) => {\n if (isTimeline(timeline)) {\n setRead({ file, made, timeline });\n }\n },\n () => {\n // Shown without a timeline.\n },\n );\n return () => asking.abort();\n }, [session, file, made]);\n\n return read?.file === file && read?.made === made ? read?.timeline : undefined;\n}\n"],"mappings":";;;;;;;;AA+BA,SAAgB,oBAAoB,EAClC,KACA,OACA,MACA,UACoC;CACpC,MAAM,CAAC,SAAS,cAAc,SAAyB,IAAI;CAC3D,MAAM,CAAC,SAAS,cAAc,SAAS,CAAC;CAExC,gBAAgB;EACd,MAAM,YAAYA,UAAQ;GAAE;GAAK;GAAO;GAAM;EAAO,CAAC;EACtD,WAAW,SAAS;EACpB,aAAa;GACX,WAAW,IAAI;GACf,UAAU,MAAM;EAClB;CACF,GAAG;EAAC;EAAK;EAAO;EAAM;EAAQ;CAAO,CAAC;CAEtC,OAAO,eACE;EACL;EACA,iBAAiB,YAAY,YAAY,UAAU,CAAC;CACtD,IACA,CAAC,OAAO,CACV;AACF;AAOA,MAAM,iBAAiB,cAA0C,IAAI;AASrE,SAAgB,gBAAgB,EAAE,SAAS,WAAW,YAAkC;CACtF,MAAM,QAAQ,eAAe;EAAE;EAAS;CAAU,IAAI,CAAC,SAAS,SAAS,CAAC;CAC1E,OAAO,oBAAC,eAAe,UAAhB;EAAgC;EAAQ;CAAkC,CAAA;AACnF;AAEA,SAAS,oBAAyC;CAChD,MAAM,QAAQ,WAAW,cAAc;CACvC,IAAI,UAAU,MACZ,MAAM,IAAI,MAAM,6DAA6D;CAE/E,OAAO;AACT;AAEA,SAAgB,aAAsB;CACpC,OAAO,kBAAkB,CAAC,CAAC;AAC7B;AAEA,SAAgB,eAAyC;CACvD,OAAO,kBAAkB,CAAC,CAAC;AAC7B;AAEA,SAAgB,qBAA+B;CAC7C,MAAM,UAAU,WAAW;CAC3B,OAAO,qBAAqB,QAAQ,WAAW,QAAQ,aAAa,QAAQ,WAAW;AACzF;;AAGA,SAAgB,mBAAuC;CACrD,MAAM,WAAW,mBAAmB;CACpC,OAAO,S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AM,QAAQ,GAAG,KAAK,MAAM,QAAQ,MAAM;AACtF;;AAGA,SAAgB,qBACd,WAC+B;CAC/B,MAAM,UAAU,WAAW;CAC3B,MAAM,OAAO,WAAW,MAAM,YAAY,KAAA;CAE1C,MAAM,OAAO,WAAW,MAAM,cAAc;CAC5C,MAAM,CAAC,MAAM,WAAW,SAEtB;CAEF,gBAAgB;EACd,IAAI,SAAS,KAAA,GACX;EAEF,MAAM,SAAS,IAAI,gBAAgB;EACnC,MAAM,QAAQ,QAAQ,IAAI,GAAG;GAAE,QAAQ,OAAO;GAAQ,OAAO;EAAW,CAAC,CAAC,CACvE,MAAM,WAAY,OAAO,KAAK,OAAO,KAAK,IAAI,KAAA,CAAU,CAAC,CACzD,MACE,aAAsB;GACrB,IAAI,WAAW,QAAQ,GACrB,QAAQ;IAAE;IAAM;IAAM;GAAS,CAAC;EAEpC,SACM,CAEN,CACF;EACF,aAAa,OAAO,MAAM;CAC5B,GAAG;EAAC;EAAS;EAAM;CAAI,CAAC;CAExB,OAAO,MAAM,SAAS,QAAQ,MAAM,SAAS,OAAO,MAAM,WAAW,KAAA;AACvE"}
1
+ {"version":3,"file":"headless.js","names":["connect"],"sources":["../src/session.tsx","../src/components/session-viewport.tsx","../src/hooks/use-actions.ts","../src/hooks/use-address.ts","../src/hooks/use-stored.ts","../src/hooks/use-fit.ts","../src/hooks/use-recordings.ts","../src/hooks/use-uploads.ts","../src/hooks/use-timeline.ts"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\nimport {\n connect,\n type ConnectOptions,\n type HeldTab,\n type Member,\n type Role,\n type Session,\n type Snapshot,\n type Target,\n} from \"@aperture-browser/session-client\";\n\nexport interface SessionConnection {\n /** None until the page has mounted, and none between two connections. */\n readonly session: Session | null;\n /** Ends the connection there is and makes a new one: a closed connection does not come back. */\n readonly reconnect: () => void;\n}\n\n/**\n * Connects to a session for as long as the component is mounted. Another address, name or\n * first way of the picture makes another connection; another first tab is the one a\n * connection made after it starts with.\n */\nexport function useConnectedSession({\n url,\n token,\n name,\n pixels,\n tab,\n}: ConnectOptions): SessionConnection {\n const [session, setSession] = useState<Session | null>(null);\n const [attempt, setAttempt] = useState(0);\n const firstTab = useRef(tab);\n firstTab.current = tab;\n\n useEffect(() => {\n const connected = connect({ url, token, name, pixels, tab: firstTab.current });\n setSession(connected);\n return () => {\n setSession(null);\n connected.close();\n };\n }, [url, token, name, pixels, attempt]);\n\n return useMemo(\n () => ({\n session,\n reconnect: () => setAttempt((current) => current + 1),\n }),\n [session],\n );\n}\n\ninterface SessionContextValue {\n readonly session: Session;\n readonly reconnect: (() => void) | undefined;\n}\n\nconst SessionContext = createContext<SessionContextValue | null>(null);\n\nexport interface SessionProviderProps {\n readonly session: Session;\n /** Offered where the connection is closed, when there is a way to make another. */\n readonly reconnect?: (() => void) | undefined;\n readonly children?: ReactNode;\n}\n\nexport function SessionProvider({ session, reconnect, children }: SessionProviderProps) {\n const value = useMemo(() => ({ session, reconnect }), [session, reconnect]);\n return <SessionContext.Provider value={value}>{children}</SessionContext.Provider>;\n}\n\nfunction useSessionContext(): SessionContextValue {\n const value = useContext(SessionContext);\n if (value === null) {\n throw new Error(\"The session's components are used outside a SessionProvider\");\n }\n return value;\n}\n\nexport function useSession(): Session {\n return useSessionContext().session;\n}\n\nexport function useReconnect(): (() => void) | undefined {\n return useSessionContext().reconnect;\n}\n\nexport function useSessionSnapshot(): Snapshot {\n const session = useSession();\n return useSyncExternalStore(session.subscribe, session.getSnapshot, session.getSnapshot);\n}\n\n/** The target that is watched. */\nexport function useWatchedTarget(): Target | undefined {\n const snapshot = useSessionSnapshot();\n return snapshot.targets.find((target) => target.tab === snapshot.selected);\n}\n\nexport type LeaseState =\n /** The role lets this member watch only. */\n | \"view-only\"\n /** Nobody holds the watched tab: whoever gives it input holds it. */\n | \"free\"\n | \"yours\"\n /** This member holds the tab and another asks for it. */\n | \"asked-of-you\"\n | \"theirs\"\n /** Another holds the tab and this member has asked for it. */\n | \"you-asked\"\n /** Another holds the tab and a third member has asked for it. */\n | \"theirs-asked\";\n\nexport interface Lease {\n readonly state: LeaseState;\n /** The member this client is, once the session told. */\n readonly you: Member | undefined;\n readonly role: Role | undefined;\n /** Whether this member's role lets it give input and change the session's tabs. */\n readonly givesInput: boolean;\n readonly held: HeldTab | undefined;\n readonly holder: Member | undefined;\n readonly asker: Member | undefined;\n}\n\n/** Who holds the lease of the watched tab, and what this member may do about it. */\nexport function useLease(): Lease {\n const snapshot = useSessionSnapshot();\n const { presence } = snapshot;\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const you = presence?.members.find((member) => member.id === presence.you);\n const held = presence?.held.find((one) => one.tab === watched?.tab);\n const holder = presence?.members.find((member) => member.id === held?.holder);\n const asker = presence?.members.find((member) => member.id === held?.askedBy);\n const role = you?.role;\n // A member whose role the session has not told yet is not held back: the session refuses\n // what the role does not allow.\n const givesInput = role !== \"view\";\n\n let state: LeaseState = \"free\";\n if (!givesInput) {\n state = \"view-only\";\n } else if (held === undefined || presence === undefined) {\n state = \"free\";\n } else if (held.holder === presence.you) {\n state = held.askedBy === undefined ? \"yours\" : \"asked-of-you\";\n } else if (held.askedBy === presence.you) {\n state = \"you-asked\";\n } else {\n state = held.askedBy === undefined ? \"theirs\" : \"theirs-asked\";\n }\n\n return { state, you, role, givesInput, held, holder, asker };\n}\n","import { useEffect, useRef, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\n\nexport interface SessionViewportProps {\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n /** Laid over the picture, such as the connection's state. */\n readonly children?: ReactNode;\n}\n\nconst PICTURE_WITHIN_MS = 1000;\n/** How long after the room for the picture last changed it counts as still changing. */\nconst RESIZED_AFTER_MS = 200;\nconst SETTLING_BLUR_PX = 6;\nconst SETTLING_FADE_MS = 160;\n\ninterface Size {\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * The watched target's picture, and its input: the pointer, the wheel, the keyboard, the\n * clipboard and what is dropped on it. The picture is shown at the target's own size, and\n * smaller where the stage has no room for that.\n */\nexport function SessionViewport({ className, style, children }: SessionViewportProps) {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const stageRef = useRef<HTMLDivElement>(null);\n const videoRef = useRef<HTMLVideoElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const keysRef = useRef<HTMLTextAreaElement>(null);\n const [stage, setStage] = useState<Size>({ width: 0, height: 0 });\n /** The size of the picture that is drawn now, in its own pixels. */\n const [drawn, setDrawn] = useState<Size>({ width: 0, height: 0 });\n /** Whether the room for the picture is being changed, as by dragging the window's edge. */\n const [resizing, setResizing] = useState(false);\n const way = snapshot.picture.way;\n\n useEffect(() => {\n const surfaces = {\n video: videoRef.current,\n canvas: canvasRef.current,\n keys: keysRef.current,\n stage: stageRef.current,\n };\n if (\n surfaces.video === null ||\n surfaces.canvas === null ||\n surfaces.keys === null ||\n surfaces.stage === null\n ) {\n return undefined;\n }\n return session.attach({\n video: surfaces.video,\n canvas: surfaces.canvas,\n keys: surfaces.keys,\n stage: surfaces.stage,\n });\n }, [session]);\n\n useEffect(() => {\n const element = stageRef.current;\n if (element === null) {\n return undefined;\n }\n let settling: ReturnType<typeof setTimeout> | undefined;\n const measure = () => {\n const next = { width: element.clientWidth, height: element.clientHeight };\n setStage((before) => {\n // The first measure is no change of size, and neither is one that measures the same.\n if (before.width > 0 && (before.width !== next.width || before.height !== next.height)) {\n setResizing(true);\n clearTimeout(settling);\n settling = setTimeout(() => setResizing(false), RESIZED_AFTER_MS);\n }\n return next;\n });\n };\n measure();\n const sizes = new ResizeObserver(measure);\n sizes.observe(element);\n return () => {\n sizes.disconnect();\n clearTimeout(settling);\n };\n }, []);\n\n useEffect(() => {\n const video = videoRef.current;\n const canvas = canvasRef.current;\n if (video === null || canvas === null) {\n return undefined;\n }\n const measure = () => {\n const size =\n way === \"video\"\n ? { width: video.videoWidth, height: video.videoHeight }\n : { width: canvas.width, height: canvas.height };\n setDrawn((before) =>\n before.width === size.width && before.height === size.height ? before : size,\n );\n };\n measure();\n video.addEventListener(\"resize\", measure);\n video.addEventListener(\"loadedmetadata\", measure);\n // A canvas says nothing when what is drawn into it changes its size.\n const sizes = new MutationObserver(measure);\n sizes.observe(canvas, { attributes: true, attributeFilter: [\"width\", \"height\"] });\n return () => {\n video.removeEventListener(\"resize\", measure);\n video.removeEventListener(\"loadedmetadata\", measure);\n sizes.disconnect();\n };\n }, [way]);\n\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const shown = watched === undefined ? undefined : way;\n // The picture of another tab, or of this one at another size, comes a moment after the\n // session says which tab is watched and how large it is. Until what is drawn has the\n // shape of what is watched, it keeps its own shape within the place of what is watched:\n // a window that is dragged larger is some sizes ahead of its picture all the while, and\n // a place kept from before the drag would hold each picture that comes to the shape of\n // the first. Its size is not the drawn one's: a picture may have more or fewer pixels to\n // a pixel of its tab from one frame to the next, and one that is sent smaller would be\n // shown smaller, away from where the tab is pressed.\n const agrees = watched !== undefined && drawn.width > 0 && sameShape(drawn, watched);\n const awaited =\n watched !== undefined && drawn.width > 0 && !agrees\n ? `${watched.id} ${watched.width}x${watched.height}`\n : undefined;\n // A picture that does not come is not waited for longer than this.\n const [overdue, setOverdue] = useState<string | undefined>(undefined);\n useEffect(() => {\n if (awaited === undefined) {\n return undefined;\n }\n const waiting = setTimeout(() => setOverdue(awaited), PICTURE_WITHIN_MS);\n return () => clearTimeout(waiting);\n }, [awaited]);\n const settled = awaited === undefined || awaited === overdue;\n const place = watched === undefined ? undefined : pictureBox(stage, watched);\n const box = place === undefined || settled ? place : shapedIn(place, drawn);\n\n const picture = (visible: boolean): CSSProperties => ({\n display: visible ? \"block\" : \"none\",\n flex: \"none\",\n width: box?.width,\n height: box?.height,\n outline: \"none\",\n // A touch that drags is the session's pointer, not a scroll of this page.\n touchAction: \"none\",\n cursor: snapshot.cursor,\n // While its room changes and until the picture of the new size is there, what is\n // drawn is stretched or stale: softened, it reads as settling and not as broken.\n filter: resizing || !settled ? `blur(${SETTLING_BLUR_PX}px)` : \"none\",\n transition: `filter ${SETTLING_FADE_MS}ms ease-out`,\n });\n\n return (\n <div\n ref={stageRef}\n className={className}\n data-aperture-stage=\"\"\n // For whatever stands in for the picture until there is one.\n data-aperture-drawn={drawn.width > 0 ? \"\" : undefined}\n style={{\n position: \"relative\",\n display: \"flex\",\n flex: \"1 1 0%\",\n minWidth: 0,\n minHeight: 0,\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n ...style,\n }}\n >\n <video\n ref={videoRef}\n data-aperture-surface=\"video\"\n tabIndex={-1}\n autoPlay\n muted\n playsInline\n style={picture(shown === \"video\")}\n />\n <canvas\n ref={canvasRef}\n data-aperture-surface=\"canvas\"\n tabIndex={-1}\n style={picture(shown === \"frames\" || shown === \"tiles\")}\n />\n <textarea\n ref={keysRef}\n data-aperture-surface=\"keys\"\n aria-label=\"Keyboard of the session\"\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n style={{\n position: \"absolute\",\n left: 0,\n bottom: 0,\n width: 1,\n height: 1,\n padding: 0,\n border: 0,\n opacity: 0,\n resize: \"none\",\n // A phone zooms into a field whose text is smaller than this.\n fontSize: 16,\n }}\n />\n {children}\n </div>\n );\n}\n\n/** Whether two sizes have the same proportions, give or take a pixel's rounding. */\nfunction sameShape(one: Size, other: Size): boolean {\n if (one.height <= 0 || other.height <= 0) {\n return false;\n }\n const ratio = (one.width / one.height) * (other.height / other.width);\n return Math.abs(ratio - 1) < 0.01;\n}\n\n/** The largest size of a shape that fits a place. */\nfunction shapedIn(place: Size, shape: Size): Size {\n const scale = Math.min(place.width / shape.width, place.height / shape.height);\n return {\n width: Math.floor(shape.width * scale),\n height: Math.floor(shape.height * scale),\n };\n}\n\n/** The place the picture of a target has in a stage: its own size, or smaller to fit. */\nexport function pictureBox(stage: Size, target: Size): Size {\n if (target.width <= 0 || target.height <= 0) {\n return { width: 0, height: 0 };\n }\n const scale = Math.min(1, stage.width / target.width, stage.height / target.height);\n return {\n width: Math.floor(target.width * scale),\n height: Math.floor(target.height * scale),\n };\n}\n","import { useCallback } from \"react\";\nimport type { Target } from \"@aperture-browser/session-client\";\nimport { useLease, useSession, useSessionSnapshot } from \"../session.tsx\";\n\nexport interface TabSound {\n /** The tab plays something now. */\n readonly sounds: boolean;\n /** The tab is muted for this client. */\n readonly muted: boolean;\n readonly toggle: () => void;\n}\n\n/** A tab's sound, as this client hears it. */\nexport function useTabSound(target: Target | undefined): TabSound {\n const session = useSession();\n const muted = useSessionSnapshot().muted.includes(target?.tab ?? -1);\n const tab = target?.tab;\n const toggle = useCallback(() => {\n if (tab !== undefined) {\n session.setMuted(tab, !muted);\n }\n }, [session, tab, muted]);\n return { sounds: target?.sounds ?? false, muted, toggle };\n}\n\nexport interface InputState {\n readonly open: boolean;\n /** This member may open, close and take tabs elsewhere, and give them another size. */\n readonly changes: boolean;\n /** This member may give the watched tab input. */\n readonly gives: boolean;\n}\n\n/** What this member may do in the session now. */\nexport function useInputState(): InputState {\n const snapshot = useSessionSnapshot();\n const lease = useLease();\n const open = snapshot.connection.state === \"open\";\n return {\n open,\n changes: open && snapshot.features.tabs.write,\n gives: open && lease.givesInput && snapshot.selected !== undefined,\n };\n}\n","import { useState } from \"react\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\n\nexport interface AddressControl {\n /** What the address field shows: what is typed, or the watched tab's address. */\n readonly value: string;\n /** Whether this member may take the watched tab elsewhere. */\n readonly navigates: boolean;\n readonly type: (value: string) => void;\n /** Lets go of what was typed and not sent. */\n readonly reset: () => void;\n /** Takes the watched tab to what was typed; false when that is nothing. */\n readonly submit: (value: string) => boolean;\n}\n\n/** The watched tab's address, as a field to type another into. */\nexport function useAddress(): AddressControl {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const [draft, setDraft] = useState<{ tab: number | undefined; url: string } | null>(null);\n // What was typed and not sent belongs to the tab it was typed for.\n const typed = draft !== null && draft.tab === watched?.tab ? draft.url : null;\n\n return {\n value: typed ?? watched?.url ?? \"\",\n navigates:\n snapshot.connection.state === \"open\" && snapshot.features.tabs.write && watched !== undefined,\n type: (url) => setDraft({ tab: watched?.tab, url }),\n reset: () => setDraft(null),\n submit: (value) => {\n const url = value.trim();\n if (url === \"\") {\n return false;\n }\n session.go({ url: addressOf(url) });\n setDraft(null);\n return true;\n },\n };\n}\n\n/** What is typed into an address field as a URL: an address as it is, anything else a search. */\nexport function addressOf(value: string): string {\n if (isLocalHost(value)) {\n return `http://${value}`;\n }\n if (\n /^[a-z][a-z0-9+.-]*:\\/\\//iu.test(value) ||\n /^(?:about|chrome|devtools|data|file|view-source):/iu.test(value)\n ) {\n return value;\n }\n if (isLikelyHost(value)) {\n return `https://${value}`;\n }\n return `https://www.google.com/search?q=${encodeURIComponent(value)}`;\n}\n\nfunction isLocalHost(value: string): boolean {\n return (\n /^localhost(?::\\d+)?(?:[/?#].*)?$/iu.test(value) ||\n /^127(?:\\.\\d{1,3}){3}(?::\\d+)?(?:[/?#].*)?$/u.test(value) ||\n /^[a-z0-9-]+:\\d+(?:[/?#].*)?$/iu.test(value)\n );\n}\n\nfunction isLikelyHost(value: string): boolean {\n return !/\\s/u.test(value) && /^[a-z0-9-]+(?:\\.[a-z0-9-]+)+(?:[/:?#].*)?$/iu.test(value);\n}\n","import { useCallback, useSyncExternalStore } from \"react\";\n\n/** What each key holds now, as it was read or last set, for all who use the key. */\nconst values = new Map<string, unknown>();\nconst listeners = new Map<string, Set<() => void>>();\n\nfunction read(key: string): unknown {\n if (!values.has(key)) {\n let stored: unknown;\n try {\n const text = window.localStorage.getItem(key);\n stored = text === null ? undefined : JSON.parse(text);\n } catch {\n // Storage that is unavailable gives the default.\n stored = undefined;\n }\n values.set(key, stored);\n }\n return values.get(key);\n}\n\n/**\n * A choice this browser remembers, the same for everything on the page that uses the key.\n * It lasts for the page where storage is unavailable.\n */\nexport function useStored<Value>(\n key: string,\n fallback: Value,\n valid: (value: unknown) => value is Value,\n): readonly [Value, (value: Value) => void] {\n const subscribe = useCallback(\n (listener: () => void) => {\n const heard = listeners.get(key) ?? new Set();\n listeners.set(key, heard);\n heard.add(listener);\n return () => {\n heard.delete(listener);\n };\n },\n [key],\n );\n const stored = useSyncExternalStore(\n subscribe,\n () => read(key),\n () => undefined,\n );\n // What another version wrote gives the default.\n const value = valid(stored) ? stored : fallback;\n\n const store = useCallback(\n (next: Value) => {\n values.set(key, next);\n try {\n window.localStorage.setItem(key, JSON.stringify(next));\n } catch {\n // Kept for this page only.\n }\n for (const listener of listeners.get(key) ?? []) {\n listener();\n }\n },\n [key],\n );\n\n return [value, store];\n}\n","import { useEffect, useRef } from \"react\";\nimport type { Session } from \"@aperture-browser/session-client\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useStored } from \"./use-stored.ts\";\n\nconst FIT_KEY = \"aperture.session.fit\";\n\nconst isBoolean = (value: unknown): value is boolean => typeof value === \"boolean\";\n\n/**\n * Has the viewport fit the window, unless that was switched off when this browser was last\n * here, and remembers when it is switched on or off. `follows` is false where the embedder\n * wants targets left at the size they have.\n */\nexport function useRememberedFit(follows = true) {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const [remembered, remember] = useStored(FIT_KEY, true, isBoolean);\n const applied = useRef<Session | undefined>(undefined);\n const ready =\n follows &&\n snapshot.connection.state === \"open\" &&\n snapshot.selected !== undefined &&\n snapshot.features.tabs.write;\n\n useEffect(() => {\n if (!ready) {\n return;\n }\n if (applied.current !== session) {\n applied.current = session;\n if (remembered && !snapshot.fit) {\n // The tab may be someone's at work in it: its size waits for this member's turn.\n session.setViewport(\"fit\", { whenFree: true });\n }\n return;\n }\n if (snapshot.fit !== remembered) {\n remember(snapshot.fit);\n }\n }, [ready, session, snapshot.fit, remembered, remember]);\n}\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type {\n EditRecording,\n Recording,\n Screenshot,\n StartRecording,\n} from \"@aperture-browser/session-client\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\n\n/** How often the recordings are asked for while one is being made or edited. */\nconst BUSY_EVERY_MS = 2000;\n/** How often otherwise: a recording may be started by the session's automation too. */\nconst IDLE_EVERY_MS = 15_000;\n\nexport interface RecordingsControl {\n /** Newest first. */\n readonly recordings: readonly Recording[];\n /** Newest first. */\n readonly screenshots: readonly Screenshot[];\n /** A start or a stop is on its way. */\n readonly busy: boolean;\n readonly refresh: () => void;\n /** Rejects with what the session answered. */\n readonly start: (options?: StartRecording) => Promise<Recording>;\n /** Stops a recording; its edit is made with `options`. */\n readonly stop: (id: string, options?: EditRecording) => Promise<Recording>;\n /** Makes the edit of a stopped recording again, with other options. */\n readonly edit: (id: string, options?: EditRecording) => Promise<Recording>;\n /** Takes a screenshot of a target and keeps it in the session's files. */\n readonly takeScreenshot: (tab: number) => Promise<Screenshot>;\n}\n\nexport const recordingRuns = (recording: Recording) => recording.state === \"recording\";\n\nexport const recordingIsEdited = (recording: Recording) => recording.edit?.state === \"editing\";\n\n/**\n * The session's recordings and screenshots. The live protocol does not tell of them, so they are asked for\n * again and again: often while one runs or is edited, seldom otherwise.\n */\nexport function useRecordings(enabled = true): RecordingsControl {\n const session = useSession();\n const open = useSessionSnapshot().connection.state === \"open\" && enabled;\n const [recordings, setRecordings] = useState<readonly Recording[]>([]);\n const [screenshots, setScreenshots] = useState<readonly Screenshot[]>([]);\n const [busy, setBusy] = useState(false);\n const [asked, setAsked] = useState(0);\n const active = recordings.some((one) => recordingRuns(one) || recordingIsEdited(one));\n const latest = useRef(0);\n\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n let ended = false;\n const ask = () => {\n latest.current += 1;\n const turn = latest.current;\n session.recordings.list().then(\n (listed) => {\n // An answer that was overtaken by a later one tells what is no longer so.\n if (!ended && turn === latest.current) {\n setRecordings(listed.toSorted((a, b) => b.started_at_ms - a.started_at_ms));\n }\n },\n () => {\n // The list stays as it was: the next turn asks again.\n },\n );\n session.screenshots.list().then(\n (listed) => {\n if (!ended && turn === latest.current) {\n setScreenshots(listed);\n }\n },\n () => {},\n );\n };\n ask();\n const timer = setInterval(ask, active ? BUSY_EVERY_MS : IDLE_EVERY_MS);\n return () => {\n ended = true;\n clearInterval(timer);\n };\n }, [session, open, active, asked]);\n\n const refresh = useCallback(() => setAsked((current) => current + 1), []);\n\n const start = useCallback(\n async (options?: StartRecording) => {\n setBusy(true);\n try {\n return await session.recordings.start(options);\n } finally {\n setBusy(false);\n refresh();\n }\n },\n [session, refresh],\n );\n\n const stop = useCallback(\n async (id: string, options?: EditRecording) => {\n setBusy(true);\n try {\n return await session.recordings.stop(id, options);\n } finally {\n setBusy(false);\n refresh();\n }\n },\n [session, refresh],\n );\n\n const edit = useCallback(\n async (id: string, options?: EditRecording) => {\n try {\n return await session.recordings.edit(id, options);\n } finally {\n refresh();\n }\n },\n [session, refresh],\n );\n\n const takeScreenshot = useCallback(\n async (tab: number) => {\n try {\n return await session.screenshots.take(tab);\n } finally {\n refresh();\n }\n },\n [session, refresh],\n );\n\n return { recordings, screenshots, busy, refresh, start, stop, edit, takeScreenshot };\n}\n\n/** Something the session kept of a tab: a recording that ended, or a screenshot. */\nexport type Kept =\n | {\n readonly kind: \"recording\";\n readonly id: string;\n readonly at: number;\n readonly recording: Recording;\n }\n | {\n readonly kind: \"screenshot\";\n readonly id: string;\n readonly at: number;\n readonly screenshot: Screenshot;\n };\n\n/** The recordings that ended and the screenshots as one list, newest first. */\nexport function keptOf(control: RecordingsControl): readonly Kept[] {\n const recordings = control.recordings\n .filter((recording) => !recordingRuns(recording))\n .map(\n (recording): Kept => ({\n kind: \"recording\",\n id: recording.id,\n at: recording.started_at_ms,\n recording,\n }),\n );\n const screenshots = control.screenshots.map(\n (screenshot): Kept => ({\n kind: \"screenshot\",\n id: screenshot.id,\n at: screenshot.taken_at_ms,\n screenshot,\n }),\n );\n return [...recordings, ...screenshots].toSorted((left, right) => right.at - left.at);\n}\n","import { useCallback, useEffect, useState } from \"react\";\nimport type { Uploaded } from \"@aperture-browser/session-client\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\n\n/** A file on its way into the session. */\nexport interface UploadInProgress {\n readonly name: string;\n readonly loaded: number;\n readonly total: number;\n}\n\nexport interface UploadsControl {\n /** The files that are in the session for its browser to take. */\n readonly uploads: readonly Uploaded[];\n readonly inProgress: readonly UploadInProgress[];\n readonly refresh: () => void;\n /**\n * Puts files into the session. Gives those that got there; `onFailure` hears of each\n * that did not.\n */\n readonly upload: (\n files: readonly File[],\n onFailure?: (file: File, cause: unknown) => void,\n ) => Promise<Uploaded[]>;\n /** Rejects with what the session answered. */\n readonly remove: (name: string) => Promise<void>;\n}\n\n/** The session's uploads. A file put there by another member shows at the next `refresh`. */\nexport function useUploads(enabled = true): UploadsControl {\n const session = useSession();\n const open = useSessionSnapshot().connection.state === \"open\" && enabled;\n const [uploads, setUploads] = useState<readonly Uploaded[]>([]);\n const [inProgress, setInProgress] = useState<readonly UploadInProgress[]>([]);\n const [asked, setAsked] = useState(0);\n\n useEffect(() => {\n if (!open) {\n return undefined;\n }\n let ended = false;\n session.uploads().then(\n (listed) => {\n if (!ended) {\n setUploads(listed.toSorted((a, b) => a.name.localeCompare(b.name)));\n }\n },\n () => {\n // The list stays as it was until it is asked for again.\n },\n );\n return () => {\n ended = true;\n };\n }, [session, open, asked]);\n\n const refresh = useCallback(() => setAsked((current) => current + 1), []);\n\n const upload = useCallback(\n async (files: readonly File[], onFailure?: (file: File, cause: unknown) => void) => {\n const put = await Promise.all(\n files.map(async (file) => {\n const progress = (loaded: number, total: number) =>\n setInProgress((current) => [\n ...current.filter((one) => one.name !== file.name),\n { name: file.name, loaded, total },\n ]);\n progress(0, file.size);\n try {\n return await session.upload(file, ({ loaded, total }) => progress(loaded, total));\n } catch (cause) {\n onFailure?.(file, cause);\n return undefined;\n } finally {\n setInProgress((current) => current.filter((one) => one.name !== file.name));\n }\n }),\n );\n refresh();\n return put.filter((one) => one !== undefined);\n },\n [session, refresh],\n );\n\n const remove = useCallback(\n async (name: string) => {\n try {\n await session.removeUpload(name);\n } finally {\n refresh();\n }\n },\n [session, refresh],\n );\n\n return { uploads, inProgress, refresh, upload, remove };\n}\n","import { useEffect, useState } from \"react\";\nimport type { Recording } from \"@aperture-browser/session-client\";\nimport { useSession } from \"../session.tsx\";\n\n/** A stretch of the raw video the edit kept, and how much faster it plays there. */\nexport interface TimelinePiece {\n readonly raw_start_ms: number;\n readonly raw_end_ms: number;\n readonly speed: number;\n readonly edited_start_ms: number;\n}\n\n/** Something that happened while the recording ran, in the raw video's time and the edit's. */\nexport interface TimelineEvent {\n /** `call` for a tool of the automation, `press`, `move`, `wheel`, `caption` and so on. */\n readonly kind: string;\n readonly at_ms: number;\n readonly end_ms: number;\n readonly edited_at_ms: number;\n readonly edited_end_ms: number;\n readonly [field: string]: unknown;\n}\n\n/** A recording's timeline, as the session writes it next to the edit. */\nexport interface RecordingTimeline {\n readonly duration_ms: number;\n readonly edited_duration_ms: number;\n /** The video's size in pixels. */\n readonly width: number;\n readonly height: number;\n readonly map: readonly TimelinePiece[];\n readonly events: readonly TimelineEvent[];\n readonly events_dropped: number;\n}\n\nconst isTimeline = (value: unknown): value is RecordingTimeline => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const { duration_ms, map, events } = value as Record<string, unknown>;\n return typeof duration_ms === \"number\" && Array.isArray(map) && Array.isArray(events);\n};\n\n/** The timeline of a recording whose edit is made; none before, and where there is no edit. */\nexport function useRecordingTimeline(\n recording: Recording | undefined,\n): RecordingTimeline | undefined {\n const session = useSession();\n const file = recording?.edit?.timeline ?? undefined;\n // An edit that was made again has the file of the one before.\n const made = recording?.edit?.made_at_ms ?? 0;\n const [read, setRead] = useState<\n { file: string; made: number; timeline: RecordingTimeline } | undefined\n >();\n\n useEffect(() => {\n if (file === undefined) {\n return undefined;\n }\n const asking = new AbortController();\n fetch(session.fileUrl(file), { signal: asking.signal, cache: \"no-store\" })\n .then((answer) => (answer.ok ? answer.json() : undefined))\n .then(\n (timeline: unknown) => {\n if (isTimeline(timeline)) {\n setRead({ file, made, timeline });\n }\n },\n () => {\n // Shown without a timeline.\n },\n );\n return () => asking.abort();\n }, [session, file, made]);\n\n return read?.file === file && read?.made === made ? read?.timeline : undefined;\n}\n"],"mappings":";;;;;;;;;AAiCA,SAAgB,oBAAoB,EAClC,KACA,OACA,MACA,QACA,OACoC;CACpC,MAAM,CAAC,SAAS,cAAc,SAAyB,IAAI;CAC3D,MAAM,CAAC,SAAS,cAAc,SAAS,CAAC;CACxC,MAAM,WAAW,OAAO,GAAG;CAC3B,SAAS,UAAU;CAEnB,gBAAgB;EACd,MAAM,YAAYA,UAAQ;GAAE;GAAK;GAAO;GAAM;GAAQ,KAAK,SAAS;EAAQ,CAAC;EAC7E,WAAW,SAAS;EACpB,aAAa;GACX,WAAW,IAAI;GACf,UAAU,MAAM;EAClB;CACF,GAAG;EAAC;EAAK;EAAO;EAAM;EAAQ;CAAO,CAAC;CAEtC,OAAO,eACE;EACL;EACA,iBAAiB,YAAY,YAAY,UAAU,CAAC;CACtD,IACA,CAAC,OAAO,CACV;AACF;AAOA,MAAM,iBAAiB,cAA0C,IAAI;AASrE,SAAgB,gBAAgB,EAAE,SAAS,WAAW,YAAkC;CACtF,MAAM,QAAQ,eAAe;EAAE;EAAS;CAAU,IAAI,CAAC,SAAS,SAAS,CAAC;CAC1E,OAAO,oBAAC,eAAe,UAAhB;EAAgC;EAAQ;CAAkC,CAAA;AACnF;AAEA,SAAS,oBAAyC;CAChD,MAAM,QAAQ,WAAW,cAAc;CACvC,IAAI,UAAU,MACZ,MAAM,IAAI,MAAM,6DAA6D;CAE/E,OAAO;AACT;AAEA,SAAgB,aAAsB;CACpC,OAAO,kBAAkB,CAAC,CAAC;AAC7B;AAEA,SAAgB,eAAyC;CACvD,OAAO,kBAAkB,C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9C,GACA,CAAC,SAAS,OAAO,CAcyB;EAAG,QAXhC,YACb,OAAO,SAAiB;GACtB,IAAI;IACF,MAAM,QAAQ,aAAa,IAAI;GACjC,UAAU;IACR,QAAQ;GACV;EACF,GACA,CAAC,SAAS,OAAO,CAGiC;CAAE;AACxD;;;AC7DA,MAAM,cAAc,UAA+C;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO;CAET,MAAM,EAAE,aAAa,KAAK,WAAW;CACrC,OAAO,OAAO,gBAAgB,YAAY,MAAM,QAAQ,GAAG,KAAK,MAAM,QAAQ,MAAM;AACtF;;AAGA,SAAgB,qBACd,WAC+B;CAC/B,MAAM,UAAU,WAAW;CAC3B,MAAM,OAAO,WAAW,MAAM,YAAY,KAAA;CAE1C,MAAM,OAAO,WAAW,MAAM,cAAc;CAC5C,MAAM,CAAC,MAAM,WAAW,SAEtB;CAEF,gBAAgB;EACd,IAAI,SAAS,KAAA,GACX;EAEF,MAAM,SAAS,IAAI,gBAAgB;EACnC,MAAM,QAAQ,QAAQ,IAAI,GAAG;GAAE,QAAQ,OAAO;GAAQ,OAAO;EAAW,CAAC,CAAC,CACvE,MAAM,WAAY,OAAO,KAAK,OAAO,KAAK,IAAI,KAAA,CAAU,CAAC,CACzD,MACE,aAAsB;GACrB,IAAI,WAAW,QAAQ,GACrB,QAAQ;IAAE;IAAM;IAAM;GAAS,CAAC;EAEpC,SACM,CAEN,CACF;EACF,aAAa,OAAO,MAAM;CAC5B,GAAG;EAAC;EAAS;EAAM;CAAI,CAAC;CAExB,OAAO,MAAM,SAAS,QAAQ,MAAM,SAAS,OAAO,MAAM,WAAW,KAAA;AACvE"}
package/dist/index.d.ts CHANGED
@@ -64,7 +64,11 @@ declare function groupContributions(contributions: readonly WorkbenchContributio
64
64
  //#region src/features.d.ts
65
65
  /** The parts of the workbench an embedder may leave out. All are shown unless said. */
66
66
  interface SessionFeatures {
67
- /** The tab strip. */
67
+ /**
68
+ * The tab strip, and the ways to another tab and to a new one. Without, the workbench
69
+ * shows the one tab it watches, as for whoever is let see one tab alone: what the title
70
+ * bar has besides the tabs is in the toolbar, and a tab that is gone is said to be closed.
71
+ */
68
72
  readonly tabs?: boolean;
69
73
  /** Back, forward and reload. */
70
74
  readonly navigation?: boolean;
@@ -210,6 +214,7 @@ declare function ApertureSession({
210
214
  token,
211
215
  name,
212
216
  pixels,
217
+ tab,
213
218
  features,
214
219
  theme,
215
220
  onThemeChange,
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { AppWindow, ArrowDownToLine, ArrowLeft, ArrowRight, ArrowUpFromLine, Bot, Camera, Check, CheckIcon, ChevronLeft, ChevronLeftIcon, ChevronRight, ChevronRightIcon, Circle, CircleAlert, CircleCheck, CircleCheckIcon, ClipboardList, ClipboardPaste, Copy, Download, ExternalLink, Eye, FileIcon, Film, FolderOpen, Gauge, Globe2, Hand, History, Hourglass, Image, Images, InfoIcon, Keyboard, Layers2, Link2, Loader2, Loader2Icon, Maximize2, Monitor, MoreHorizontal, MoreVertical, MousePointer2, OctagonXIcon, PanelRight, Paperclip, Pause, Pencil, Play, Plus, Radio, RefreshCw, RotateCcw, Scissors, Search, Smartphone, Square, SunMoon, TextSelect, Trash2, TriangleAlertIcon, Undo2, Unplug, Volume2, VolumeX, X, XIcon } from "lucide-react";
7
7
  import { useTheme } from "next-themes";
8
8
  import { Toaster, toast } from "sonner";
9
+ import { useHotkey } from "@tanstack/react-hotkeys";
9
10
  import { Drawer } from "@base-ui/react/drawer";
10
11
  import { Menu } from "@base-ui/react/menu";
11
12
  import { clsx } from "clsx";
@@ -181,17 +182,18 @@ function WorkbenchProvider({ features: given, contributions, fit = true, appeara
181
182
  * gets none of it; a menu or dialog that is open keeps its own Escape.
182
183
  */
183
184
  function useEscapeEndsDrawing(drawing, setDrawing) {
184
- useEffect(() => {
185
- if (!drawing) return;
186
- const onKey = (event) => {
187
- if (event.key !== "Escape" || event.target instanceof Element && event.target.closest("[role=menu], [role=dialog], [role=listbox]") !== null) return;
188
- event.preventDefault();
189
- event.stopPropagation();
190
- setDrawing(false);
191
- };
192
- window.addEventListener("keydown", onKey, true);
193
- return () => window.removeEventListener("keydown", onKey, true);
194
- }, [drawing, setDrawing]);
185
+ useHotkey("Escape", (event) => {
186
+ if (event.target instanceof Element && event.target.closest("[role=menu], [role=dialog], [role=listbox]") !== null) return;
187
+ event.preventDefault();
188
+ event.stopPropagation();
189
+ setDrawing(false);
190
+ }, {
191
+ enabled: drawing,
192
+ capture: true,
193
+ preventDefault: false,
194
+ stopPropagation: false,
195
+ conflictBehavior: "allow"
196
+ });
195
197
  }
196
198
  function useWorkbench() {
197
199
  const value = useContext(WorkbenchContext);
@@ -885,12 +887,13 @@ function useAct() {
885
887
  function PageLinkItems() {
886
888
  const session = useSession();
887
889
  const link = useSessionSnapshot().menu?.link;
890
+ const { features } = useWorkbench();
888
891
  const act = useAct();
889
892
  if (link === void 0) return null;
890
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(DropdownMenuItem, {
893
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [features.tabs ? /* @__PURE__ */ jsxs(DropdownMenuItem, {
891
894
  onClick: act(() => session.go({ url: link }, { newTab: true })),
892
895
  children: [/* @__PURE__ */ jsx(ExternalLink, {}), "Open link in new tab"]
893
- }), /* @__PURE__ */ jsxs(DropdownMenuItem, {
896
+ }) : null, /* @__PURE__ */ jsxs(DropdownMenuItem, {
894
897
  onClick: act(() => copyTextHere(session, link, "Link copied")),
895
898
  children: [/* @__PURE__ */ jsx(Link2, {}), "Copy link address"]
896
899
  })] });
@@ -903,10 +906,10 @@ function PagePictureItems() {
903
906
  const act = useAct();
904
907
  if (image === void 0) return null;
905
908
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
906
- /* @__PURE__ */ jsxs(DropdownMenuItem, {
909
+ features.tabs ? /* @__PURE__ */ jsxs(DropdownMenuItem, {
907
910
  onClick: act(() => session.go({ url: image }, { newTab: true })),
908
911
  children: [/* @__PURE__ */ jsx(ExternalLink, {}), "Open picture in new tab"]
909
- }),
912
+ }) : null,
910
913
  features.access.clipboard.read ? /* @__PURE__ */ jsxs(DropdownMenuItem, {
911
914
  onClick: act(() => session.copyPicture(image)),
912
915
  children: [/* @__PURE__ */ jsx(Image, {}), "Copy picture"]
@@ -1210,7 +1213,7 @@ function InputGroup({ className, ...props }) {
1210
1213
  return /* @__PURE__ */ jsx("div", {
1211
1214
  "data-slot": "input-group",
1212
1215
  role: "group",
1213
- className: cn("aperture:group/input-group aperture:relative aperture:flex aperture:h-8 aperture:w-full aperture:min-w-0 aperture:items-center aperture:rounded-lg aperture:border aperture:border-input aperture:transition-colors aperture:outline-none aperture:in-data-[slot=combobox-content]:focus-within:border-inherit aperture:in-data-[slot=combobox-content]:focus-within:ring-0 aperture:has-disabled:bg-input/50 aperture:has-disabled:opacity-50 aperture:has-[[data-slot=input-group-control]:focus-visible]:border-ring aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-3 aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 aperture:has-[[data-slot][aria-invalid=true]]:border-destructive aperture:has-[[data-slot][aria-invalid=true]]:ring-3 aperture:has-[[data-slot][aria-invalid=true]]:ring-destructive/20 aperture:has-[>[data-align=block-end]]:h-auto aperture:has-[>[data-align=block-end]]:flex-col aperture:has-[>[data-align=block-start]]:h-auto aperture:has-[>[data-align=block-start]]:flex-col aperture:has-[>textarea]:h-auto aperture:dark:bg-input/30 aperture:dark:has-disabled:bg-input/80 aperture:dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 aperture:has-[>[data-align=block-end]]:[&>input]:pt-3 aperture:has-[>[data-align=block-start]]:[&>input]:pb-3 aperture:has-[>[data-align=inline-end]]:[&>input]:pr-1.5 aperture:has-[>[data-align=inline-start]]:[&>input]:pl-1.5", className),
1216
+ className: cn("aperture:group/input-group aperture:relative aperture:flex aperture:h-8 aperture:w-full aperture:min-w-0 aperture:items-center aperture:rounded-lg aperture:border aperture:border-input aperture:transition-colors aperture:outline-none aperture:in-data-[slot=combobox-content]:focus-within:border-inherit aperture:in-data-[slot=combobox-content]:focus-within:ring-0 aperture:has-[[data-slot=input-group-control]:disabled]:bg-input/50 aperture:has-[[data-slot=input-group-control]:disabled]:opacity-50 aperture:has-[[data-slot=input-group-control]:focus-visible]:border-ring aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-3 aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 aperture:has-[[data-slot][aria-invalid=true]]:border-destructive aperture:has-[[data-slot][aria-invalid=true]]:ring-3 aperture:has-[[data-slot][aria-invalid=true]]:ring-destructive/20 aperture:has-[>[data-align=block-end]]:h-auto aperture:has-[>[data-align=block-end]]:flex-col aperture:has-[>[data-align=block-start]]:h-auto aperture:has-[>[data-align=block-start]]:flex-col aperture:has-[>textarea]:h-auto aperture:dark:bg-input/30 aperture:dark:has-[[data-slot=input-group-control]:disabled]:bg-input/80 aperture:dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 aperture:has-[>[data-align=block-end]]:[&>input]:pt-3 aperture:has-[>[data-align=block-start]]:[&>input]:pb-3 aperture:has-[>[data-align=inline-end]]:[&>input]:pr-1.5 aperture:has-[>[data-align=inline-start]]:[&>input]:pl-1.5", className),
1214
1217
  ...props
1215
1218
  });
1216
1219
  }
@@ -1465,7 +1468,9 @@ const ROLES$1 = {
1465
1468
  /** Who is in the session, as the old workbench showed its collaborators. */
1466
1469
  function SessionPresence() {
1467
1470
  const session = useSession();
1468
- const { presence } = useSessionSnapshot();
1471
+ const snapshot = useSessionSnapshot();
1472
+ const follows = useWorkbench().features.tabs;
1473
+ const { presence } = snapshot;
1469
1474
  if (presence === void 0 || presence.members.length === 0) return null;
1470
1475
  const holds = (member) => presence.held.some((held) => held.holder === member.id);
1471
1476
  const members = presence.members.toSorted((left, right) => {
@@ -1479,7 +1484,7 @@ function SessionPresence() {
1479
1484
  const button = (member) => /* @__PURE__ */ jsx(MemberButton, {
1480
1485
  member,
1481
1486
  presence,
1482
- onFollow: session.follow
1487
+ onFollow: follows ? session.follow : void 0
1483
1488
  }, member.id);
1484
1489
  return /* @__PURE__ */ jsxs("div", {
1485
1490
  "data-session-presence": "",
@@ -1527,10 +1532,10 @@ function MemberButton({ member, presence, onFollow }) {
1527
1532
  held.length === 0 ? void 0 : `holds tab ${held.map((one) => one.tab).join(", ")}`,
1528
1533
  follower ? "follows you" : void 0,
1529
1534
  followed ? "you follow them · click to stop" : void 0,
1530
- !you && !followed ? "click to follow them" : void 0
1535
+ !you && !followed && onFollow !== void 0 ? "click to follow them" : void 0
1531
1536
  ].filter((part) => part !== void 0).join(" · ");
1532
1537
  return /* @__PURE__ */ jsxs(Tooltip$1, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
1533
- render: you ? /* @__PURE__ */ jsx("span", {
1538
+ render: you || onFollow === void 0 ? /* @__PURE__ */ jsx("span", {
1534
1539
  className: "aperture:inline-flex aperture:size-7 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-full",
1535
1540
  "aria-label": label
1536
1541
  }) : /* @__PURE__ */ jsx(Button$1, {
@@ -2009,16 +2014,15 @@ function TabPreviewPicture({ target }) {
2009
2014
  //#region src/components/browser-toolbar.tsx
2010
2015
  /** The workbench's first row: the tab strip, and who is in the session. */
2011
2016
  function WorkbenchTitlebar() {
2012
- const { features, contributions } = useWorkbench();
2017
+ const { features } = useWorkbench();
2013
2018
  const open = useSessionSnapshot().connection.state === "open";
2014
- const contributed = contributions.some((one) => one.slot.startsWith("titlebar."));
2015
- if (useShortWindow() || !features.tabs && !features.presence && !contributed) return null;
2019
+ if (useOneRow()) return null;
2016
2020
  return /* @__PURE__ */ jsxs("div", {
2017
2021
  "data-workbench-titlebar": "",
2018
2022
  className: "aperture:flex aperture:h-8 aperture:min-w-0 aperture:shrink-0 aperture:items-stretch aperture:border-b aperture:bg-muted/35 aperture:pointer-coarse:h-10",
2019
2023
  children: [
2020
2024
  /* @__PURE__ */ jsx(WorkbenchSlot, { name: "titlebar.start" }),
2021
- features.tabs ? /* @__PURE__ */ jsx(BrowserTabStrip, {}) : /* @__PURE__ */ jsx("div", { className: "aperture:min-w-0 aperture:flex-1" }),
2025
+ /* @__PURE__ */ jsx(BrowserTabStrip, {}),
2022
2026
  features.presence && open ? /* @__PURE__ */ jsx(SessionPresence, {}) : null,
2023
2027
  /* @__PURE__ */ jsx(WorkbenchSlot, { name: "titlebar.end" })
2024
2028
  ]
@@ -2039,6 +2043,15 @@ function useCrowdedToolbar() {
2039
2043
  /** Below this width the toolbar keeps the address bar its room by showing fewer buttons. */
2040
2044
  const COMPACT_BELOW = 520;
2041
2045
  /**
2046
+ * Whether the workbench has the one row of the toolbar, which then has what the title
2047
+ * bar has besides the tabs: in a window too short for two, and where there is no strip of
2048
+ * tabs, as for one who sees one tab alone.
2049
+ */
2050
+ function useOneRow() {
2051
+ const { features } = useWorkbench();
2052
+ return useShortWindow() || !features.tabs;
2053
+ }
2054
+ /**
2042
2055
  * The workbench's second row: navigation, the address, and the buttons at its end. Without
2043
2056
  * children it is the usual arrangement of its parts.
2044
2057
  */
@@ -2049,7 +2062,8 @@ function WorkbenchToolbar({ children }) {
2049
2062
  const open = useSessionSnapshot().connection.state === "open";
2050
2063
  const connecting = useSessionSnapshot().connection.state === "connecting";
2051
2064
  const short = useShortWindow();
2052
- if (!(children !== void 0 || features.navigation || features.addressBar || features.menus || short || contributions.some((one) => one.slot === "toolbar.start" || one.slot === "toolbar.end"))) return null;
2065
+ const oneRow = useOneRow();
2066
+ if (!(children !== void 0 || features.navigation || features.addressBar || features.menus || oneRow && features.presence || contributions.some((one) => oneRow ? one.slot.startsWith("toolbar.") || one.slot.startsWith("titlebar.") : one.slot.startsWith("toolbar.")))) return null;
2053
2067
  return /* @__PURE__ */ jsx(CompactContext.Provider, {
2054
2068
  value: compact,
2055
2069
  children: /* @__PURE__ */ jsx("div", {
@@ -2057,17 +2071,18 @@ function WorkbenchToolbar({ children }) {
2057
2071
  "data-workbench-toolbar": "",
2058
2072
  "data-compact": compact ? "" : void 0,
2059
2073
  "data-short": short ? "" : void 0,
2060
- className: "aperture:flex aperture:h-9 aperture:min-w-0 aperture:shrink-0 aperture:items-center aperture:gap-1 aperture:border-b aperture:bg-background aperture:px-1.5 aperture:pointer-coarse:h-11 aperture:data-short:pl-0",
2074
+ "data-flush": oneRow && contributions.some((one) => one.slot === "titlebar.start") ? "" : void 0,
2075
+ className: "aperture:flex aperture:h-9 aperture:min-w-0 aperture:shrink-0 aperture:items-center aperture:gap-1 aperture:border-b aperture:bg-background aperture:px-1.5 aperture:pointer-coarse:h-11 aperture:data-flush:pl-0",
2061
2076
  children: children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2062
- short ? /* @__PURE__ */ jsx(WorkbenchSlot, { name: "titlebar.start" }) : null,
2077
+ oneRow ? /* @__PURE__ */ jsx(WorkbenchSlot, { name: "titlebar.start" }) : null,
2063
2078
  short && features.tabs ? /* @__PURE__ */ jsx(TabsMenu, {}) : null,
2064
2079
  /* @__PURE__ */ jsx(WorkbenchSlot, { name: "toolbar.start" }),
2065
2080
  features.navigation ? /* @__PURE__ */ jsx(NavigationButtons, {}) : null,
2066
2081
  features.addressBar ? /* @__PURE__ */ jsx(AddressBar, {}) : /* @__PURE__ */ jsx("div", { className: "aperture:min-w-0 aperture:flex-1" }),
2067
2082
  connecting ? /* @__PURE__ */ jsx(Loader2, { className: "aperture:size-4 aperture:shrink-0 aperture:animate-spin aperture:text-muted-foreground" }) : null,
2068
2083
  /* @__PURE__ */ jsx(WorkbenchSlot, { name: "toolbar.end" }),
2069
- short && features.presence && open ? /* @__PURE__ */ jsx(SessionPresence, {}) : null,
2070
- short ? /* @__PURE__ */ jsx(WorkbenchSlot, { name: "titlebar.end" }) : null,
2084
+ oneRow && features.presence && open ? /* @__PURE__ */ jsx(SessionPresence, {}) : null,
2085
+ oneRow ? /* @__PURE__ */ jsx(WorkbenchSlot, { name: "titlebar.end" }) : null,
2071
2086
  features.menus ? /* @__PURE__ */ jsx(ToolbarActions, {}) : null
2072
2087
  ] })
2073
2088
  })
@@ -4606,7 +4621,8 @@ function trace(context, points) {
4606
4621
  * what is contributed to `viewport`.
4607
4622
  */
4608
4623
  function BrowserViewport({ className }) {
4609
- const showLease = useWorkbench().features.presence;
4624
+ const { features } = useWorkbench();
4625
+ const showLease = features.presence;
4610
4626
  const session = useSession();
4611
4627
  const snapshot = useSessionSnapshot();
4612
4628
  const reconnect = useReconnect();
@@ -4647,9 +4663,9 @@ function BrowserViewport({ className }) {
4647
4663
  variant: "icon",
4648
4664
  children: /* @__PURE__ */ jsx(AppWindow, {})
4649
4665
  }),
4650
- /* @__PURE__ */ jsx(EmptyTitle, { children: "No tabs" }),
4651
- /* @__PURE__ */ jsx(EmptyDescription, { children: "The session's browser has no tab open." })
4652
- ] }), snapshot.features.tabs.write ? /* @__PURE__ */ jsx(EmptyContent, { children: /* @__PURE__ */ jsxs(Button$1, {
4666
+ /* @__PURE__ */ jsx(EmptyTitle, { children: features.tabs ? "No tabs" : "This tab was closed" }),
4667
+ /* @__PURE__ */ jsx(EmptyDescription, { children: features.tabs ? "The session's browser has no tab open." : "There is nothing more to see here." })
4668
+ ] }), features.tabs && snapshot.features.tabs.write ? /* @__PURE__ */ jsx(EmptyContent, { children: /* @__PURE__ */ jsxs(Button$1, {
4653
4669
  type: "button",
4654
4670
  size: "sm",
4655
4671
  onClick: () => session.newTab(),
@@ -5218,7 +5234,7 @@ function eventLabel(event) {
5218
5234
  default: return event.kind;
5219
5235
  }
5220
5236
  }
5221
- /** Pointer moves and wheel turns no further apart than this are one run of them. */
5237
+ /** Pointer moves, wheel turns and keys no further apart than this are one run of them. */
5222
5238
  const RUN_GAP_MS = 300;
5223
5239
  /** The stretches the edit sped up or cut, in the time of the video that plays. */
5224
5240
  function stretches(timeline, raw) {
@@ -5263,11 +5279,13 @@ function Track({ duration, time, timeline, raw, onSeek }) {
5263
5279
  const span = (event) => raw ? [event.at_ms, event.end_ms] : [event.edited_at_ms, event.edited_end_ms];
5264
5280
  const events = timeline?.events ?? [];
5265
5281
  const calls = events.filter((event) => event.kind === "call");
5266
- const marks = events.filter((event) => ![
5267
- "call",
5282
+ const runKinds = [
5268
5283
  "move",
5269
- "wheel"
5270
- ].includes(event.kind));
5284
+ "wheel",
5285
+ "key",
5286
+ "input"
5287
+ ];
5288
+ const marks = events.filter((event) => event.kind !== "call" && !runKinds.includes(event.kind));
5271
5289
  const runs = (kind, label) => {
5272
5290
  const found = [];
5273
5291
  for (const event of events) {
@@ -5283,7 +5301,12 @@ function Track({ duration, time, timeline, raw, onSeek }) {
5283
5301
  }
5284
5302
  return found;
5285
5303
  };
5286
- const moves = [...runs("move", "pointer moves"), ...runs("wheel", "scroll")];
5304
+ const moves = [
5305
+ ...runs("move", "pointer moves"),
5306
+ ...runs("wheel", "scroll"),
5307
+ ...runs("key", "typing"),
5308
+ ...runs("input", "input")
5309
+ ];
5287
5310
  const marked = timeline === void 0 ? [] : stretches(timeline, raw);
5288
5311
  const msAt = (clientX) => {
5289
5312
  const box = trackRef.current?.getBoundingClientRect();
@@ -6135,6 +6158,7 @@ function PeopleButton({ rail, onOpen }) {
6135
6158
  function PeopleSheet({ side, open, onOpenChange }) {
6136
6159
  const session = useSession();
6137
6160
  const { presence } = useSessionSnapshot();
6161
+ const follows = useWorkbench().features.tabs;
6138
6162
  const last = useRef(presence);
6139
6163
  if (presence !== void 0) last.current = presence;
6140
6164
  const told = presence ?? last.current;
@@ -6182,7 +6206,7 @@ function PeopleSheet({ side, open, onOpenChange }) {
6182
6206
  children: said.join(" · ")
6183
6207
  })]
6184
6208
  }),
6185
- member.id === told?.you ? null : /* @__PURE__ */ jsx(Button$1, {
6209
+ member.id === told?.you || !follows ? null : /* @__PURE__ */ jsx(Button$1, {
6186
6210
  type: "button",
6187
6211
  variant: followed ? "secondary" : "outline",
6188
6212
  "aria-pressed": followed,
@@ -6298,12 +6322,13 @@ function useDarkTheme(theme) {
6298
6322
  * The workbench of one session: connects to it, shows it, and ends the connection when
6299
6323
  * unmounted. Needs `@aperture-browser/session-react/styles.css`.
6300
6324
  */
6301
- function ApertureSession({ url, token, name, pixels, features, theme = "system", onThemeChange, className, onSession, ...workbench }) {
6325
+ function ApertureSession({ url, token, name, pixels, tab, features, theme = "system", onThemeChange, className, onSession, ...workbench }) {
6302
6326
  const { session, reconnect } = useConnectedSession({
6303
6327
  url,
6304
6328
  token,
6305
6329
  name,
6306
- pixels
6330
+ pixels,
6331
+ tab
6307
6332
  });
6308
6333
  useEffect(() => {
6309
6334
  if (session === null || onSession === void 0) return;