@aperture-browser/session-react 0.0.0-nightly.188.31f174a7517d → 0.0.0-nightly.190.65e8935efa3a
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/dist/headless.d.ts +4 -0
- package/dist/headless.js +36 -7
- package/dist/headless.js.map +1 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/headless.d.ts
CHANGED
|
@@ -126,6 +126,8 @@ interface UploadInProgress {
|
|
|
126
126
|
readonly name: string;
|
|
127
127
|
readonly loaded: number;
|
|
128
128
|
readonly total: number;
|
|
129
|
+
/** Bytes a second lately, once there was time enough to tell. */
|
|
130
|
+
readonly rate: number | undefined;
|
|
129
131
|
}
|
|
130
132
|
interface UploadsControl {
|
|
131
133
|
/** The files that are in the session for its browser to take. */
|
|
@@ -139,6 +141,8 @@ interface UploadsControl {
|
|
|
139
141
|
readonly upload: (files: readonly File[], onFailure?: (file: File, cause: unknown) => void) => Promise<Uploaded[]>;
|
|
140
142
|
/** Rejects with what the session answered. */
|
|
141
143
|
readonly remove: (name: string) => Promise<void>;
|
|
144
|
+
/** Gives up a file on its way, and what came of it. */
|
|
145
|
+
readonly cancel: (name: string) => void;
|
|
142
146
|
}
|
|
143
147
|
/** The session's uploads. A file put there by another member shows at the next `refresh`. */
|
|
144
148
|
declare function useUploads(enabled?: boolean): UploadsControl;
|
package/dist/headless.js
CHANGED
|
@@ -545,6 +545,8 @@ function keptOf(control) {
|
|
|
545
545
|
}
|
|
546
546
|
//#endregion
|
|
547
547
|
//#region src/hooks/use-uploads.ts
|
|
548
|
+
/** How long between the measures of a rate: shorter ones swing with each piece sent. */
|
|
549
|
+
const RATE_EVERY_MS = 1e3;
|
|
548
550
|
/** The session's uploads. A file put there by another member shows at the next `refresh`. */
|
|
549
551
|
function useUploads(enabled = true) {
|
|
550
552
|
const session = useSession();
|
|
@@ -567,25 +569,51 @@ function useUploads(enabled = true) {
|
|
|
567
569
|
asked
|
|
568
570
|
]);
|
|
569
571
|
const refresh = useCallback(() => setAsked((current) => current + 1), []);
|
|
572
|
+
const sending = useRef(/* @__PURE__ */ new Map());
|
|
570
573
|
return {
|
|
571
574
|
uploads,
|
|
572
575
|
inProgress,
|
|
573
576
|
refresh,
|
|
574
577
|
upload: useCallback(async (files, onFailure) => {
|
|
575
578
|
const put = await Promise.all(files.map(async (file) => {
|
|
576
|
-
|
|
579
|
+
let measured;
|
|
580
|
+
let rate;
|
|
581
|
+
const shown = (loaded, total) => setInProgress((current) => [...current.filter((one) => one.name !== file.name), {
|
|
577
582
|
name: file.name,
|
|
578
583
|
loaded,
|
|
579
|
-
total
|
|
584
|
+
total,
|
|
585
|
+
rate
|
|
580
586
|
}]);
|
|
581
|
-
progress(
|
|
587
|
+
const progress = (loaded, total) => {
|
|
588
|
+
const at = performance.now();
|
|
589
|
+
if (measured === void 0 || loaded < measured.loaded) measured = {
|
|
590
|
+
at,
|
|
591
|
+
loaded
|
|
592
|
+
};
|
|
593
|
+
else if (at - measured.at >= RATE_EVERY_MS) {
|
|
594
|
+
const lately = (loaded - measured.loaded) * 1e3 / (at - measured.at);
|
|
595
|
+
rate = rate === void 0 ? lately : rate * .7 + lately * .3;
|
|
596
|
+
measured = {
|
|
597
|
+
at,
|
|
598
|
+
loaded
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
shown(loaded, total);
|
|
602
|
+
};
|
|
603
|
+
shown(0, file.size);
|
|
604
|
+
sending.current.get(file.name)?.abort();
|
|
605
|
+
const aborted = new AbortController();
|
|
606
|
+
sending.current.set(file.name, aborted);
|
|
582
607
|
try {
|
|
583
|
-
return await session.upload(file, ({ loaded, total }) => progress(loaded, total));
|
|
608
|
+
return await session.upload(file, ({ loaded, total }) => progress(loaded, total), aborted.signal);
|
|
584
609
|
} catch (cause) {
|
|
585
|
-
onFailure?.(file, cause);
|
|
610
|
+
if (!aborted.signal.aborted) onFailure?.(file, cause);
|
|
586
611
|
return;
|
|
587
612
|
} finally {
|
|
588
|
-
|
|
613
|
+
if (sending.current.get(file.name) === aborted) {
|
|
614
|
+
sending.current.delete(file.name);
|
|
615
|
+
setInProgress((current) => current.filter((one) => one.name !== file.name));
|
|
616
|
+
}
|
|
589
617
|
}
|
|
590
618
|
}));
|
|
591
619
|
refresh();
|
|
@@ -597,7 +625,8 @@ function useUploads(enabled = true) {
|
|
|
597
625
|
} finally {
|
|
598
626
|
refresh();
|
|
599
627
|
}
|
|
600
|
-
}, [session, refresh])
|
|
628
|
+
}, [session, refresh]),
|
|
629
|
+
cancel: useCallback((name) => sending.current.get(name)?.abort(), [])
|
|
601
630
|
};
|
|
602
631
|
}
|
|
603
632
|
//#endregion
|
package/dist/headless.js.map
CHANGED
|
@@ -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 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 },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;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"}
|
|
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, useRef, 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 /** Bytes a second lately, once there was time enough to tell. */\n readonly rate: number | undefined;\n}\n\n/** How long between the measures of a rate: shorter ones swing with each piece sent. */\nconst RATE_EVERY_MS = 1000;\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 /** Gives up a file on its way, and what came of it. */\n readonly cancel: (name: string) => 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 const sending = useRef(new Map<string, AbortController>());\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 // Measured from what is said first: an upload that goes on says at once all that\n // came before, which was not sent now.\n let measured: { readonly at: number; readonly loaded: number } | undefined;\n let rate: number | undefined;\n const shown = (loaded: number, total: number) =>\n setInProgress((current) => [\n ...current.filter((one) => one.name !== file.name),\n { name: file.name, loaded, total, rate },\n ]);\n const progress = (loaded: number, total: number) => {\n const at = performance.now();\n // A try again starts over from what the session says it has.\n if (measured === undefined || loaded < measured.loaded) {\n measured = { at, loaded };\n } else if (at - measured.at >= RATE_EVERY_MS) {\n const lately = ((loaded - measured.loaded) * 1000) / (at - measured.at);\n rate = rate === undefined ? lately : rate * 0.7 + lately * 0.3;\n measured = { at, loaded };\n }\n shown(loaded, total);\n };\n shown(0, file.size);\n // A file of the name that is on its way already is put in its place.\n sending.current.get(file.name)?.abort();\n const aborted = new AbortController();\n sending.current.set(file.name, aborted);\n try {\n return await session.upload(\n file,\n ({ loaded, total }) => progress(loaded, total),\n aborted.signal,\n );\n } catch (cause) {\n if (!aborted.signal.aborted) {\n onFailure?.(file, cause);\n }\n return undefined;\n } finally {\n if (sending.current.get(file.name) === aborted) {\n sending.current.delete(file.name);\n setInProgress((current) => current.filter((one) => one.name !== file.name));\n }\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 const cancel = useCallback((name: string) => sending.current.get(name)?.abort(), []);\n\n return { uploads, inProgress, refresh, upload, remove, cancel };\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,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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.js
CHANGED
|
@@ -3744,7 +3744,17 @@ function SessionFiles({ uploads, request, downloads, offers, puts, sheet }) {
|
|
|
3744
3744
|
}),
|
|
3745
3745
|
/* @__PURE__ */ jsx("span", {
|
|
3746
3746
|
className: "aperture:shrink-0 aperture:text-xs aperture:text-muted-foreground aperture:tabular-nums",
|
|
3747
|
-
children: percent(file.loaded, file.total)
|
|
3747
|
+
children: file.rate === void 0 || file.rate <= 0 ? percent(file.loaded, file.total) : `${speed(file.rate)} · ${left((file.total - file.loaded) / file.rate)} · ${percent(file.loaded, file.total)}`
|
|
3748
|
+
}),
|
|
3749
|
+
/* @__PURE__ */ jsx(Button$1, {
|
|
3750
|
+
type: "button",
|
|
3751
|
+
size: "icon-xs",
|
|
3752
|
+
variant: "ghost",
|
|
3753
|
+
"aria-label": `Cancel the upload of ${file.name}`,
|
|
3754
|
+
"data-session-upload-cancel": "",
|
|
3755
|
+
className: "aperture:shrink-0",
|
|
3756
|
+
onClick: () => uploads.cancel(file.name),
|
|
3757
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
3748
3758
|
})
|
|
3749
3759
|
]
|
|
3750
3760
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -3861,6 +3871,16 @@ function giveLabel(request, chosen) {
|
|
|
3861
3871
|
if (chosen > 1) return `Give ${chosen} files`;
|
|
3862
3872
|
return request.multiple && chosen === 0 ? "Give the files" : "Give the file";
|
|
3863
3873
|
}
|
|
3874
|
+
function speed(bytesPerSecond) {
|
|
3875
|
+
const [unit, size] = bytesPerSecond >= 1024 ** 3 ? ["GB", 1024 ** 3] : bytesPerSecond >= 1024 ** 2 ? ["MB", 1024 ** 2] : ["KB", 1024];
|
|
3876
|
+
return `${Number((bytesPerSecond / size).toFixed(1))} ${unit}/s`;
|
|
3877
|
+
}
|
|
3878
|
+
function left(seconds) {
|
|
3879
|
+
const whole = Math.max(1, Math.ceil(seconds));
|
|
3880
|
+
if (whole < 60) return `${whole} s left`;
|
|
3881
|
+
const minutes = Math.ceil(whole / 60);
|
|
3882
|
+
return minutes < 60 ? `${minutes} min left` : `${Math.floor(minutes / 60)} h ${minutes % 60} min left`;
|
|
3883
|
+
}
|
|
3864
3884
|
function percent(loaded, total) {
|
|
3865
3885
|
return total <= 0 ? "0%" : `${Math.min(100, Math.round(100 * loaded / total))}%`;
|
|
3866
3886
|
}
|