@hyperframes/core 0.9.104 → 0.9.107

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.
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import type { RestoreAttributesParams } from "./editing/restoreAttributes.js";
13
13
  import { type EditingGeometryEvent, type WatchGeometryParams } from "./editing/watchGeometry.js";
14
+ import { type EditingPointerEvent, type WatchPointerParams } from "./editing/watchPointer.js";
14
15
  import { MAX_DRAFT_PX, type EditingElementDescription, type EditingElementHandle, type EditingElementHit, type EditingElementMatch } from "./editingElement.js";
15
16
  import type { EditingElementBox, EditingElementGeometry } from "./editingGeometry.js";
16
17
  import type { EditingGestureBase, EditingGestureStart } from "./editingGestureStart.js";
@@ -20,6 +21,7 @@ import type { EditingLayer, EditingStackingSibling } from "./editingLayers.js";
20
21
  import { type GsapSetParams } from "./editing/gsapSet.js";
21
22
  import { type PatchTweensParams } from "./editing/patchTween.js";
22
23
  import { type EditingDraftEnd, type EditingDraftReply } from "./editingDraftEnd.js";
24
+ import { type EditingDragChrome } from "./editing/dragChrome.js";
23
25
  import { type SoftReloadParams, type SoftReloadResult } from "./editing/softReload.js";
24
26
  import { type HoldScenesParams, type MarkScenesStaleParams, type SwapScenesParams, type SwapScenesResult } from "./editing/scenes.js";
25
27
  import { type LiveRetimeParams, type LiveRetimeResult } from "./editing/liveRetime.js";
@@ -42,6 +44,7 @@ export { elementCornerPoints, isElementVisibleThroughAncestors, readElementTrans
42
44
  export type { EditingGestureBase, EditingGestureStart } from "./editingGestureStart.js";
43
45
  export { MAX_CAPTION_TRANSFORM } from "./editing/captionTransform.js";
44
46
  export { MAX_EDIT_ENTRIES } from "./editing/editElement.js";
47
+ export { MAX_DRAG_CHROME_BYTES, MAX_DRAG_CHROME_NODES, parseDragChrome, type EditingDragChrome, type EditingDragChromeNode, } from "./editing/dragChrome.js";
45
48
  export { MAX_FONT_FACES } from "./editing/textStyleReads.js";
46
49
  export { MAX_STAGE_CLIP_KEYS, MAX_STAGE_ITEMS, type StageMeasuredItem, type StageMeasureParams, type StageMeasureResult, type StageTextStart, } from "./editing/stageMeasure.js";
47
50
  export { isStageColour, MAX_STAGE_ACTS, readStageActHeld, readStageRect, STAGE_ACT_BORROWS, STAGE_ACT_STYLES, type StageActBorrow, type StageActDraw, type StageActElementHold, type StageActGhostHold, type StageActHeld, type StageActHold, type StageActParams, type StageActReadyEvent, type StageActRect, type StageActResult, type StageActStyle, type StageActTarget, type StageInputEvent, } from "./editing/stageAct.js";
@@ -51,11 +54,14 @@ export { MAX_SNAPSHOT_CHANNELS, MAX_SNAPSHOT_FIELDS, MAX_SNAPSHOT_TARGETS, MAX_S
51
54
  export { compositionPoint, coversComposition, isDomLayerElement, isInspectableLayerElement, pointerTarget, pointerTargets, resolveAllVisualDomEditTargets, resolveLayerSelector, type EditingLocalPointer, type EditingViewport, } from "./editingTargets.js";
52
55
  export { elementZIndex, hasOnlyFormattingChildren, NON_PAINTING_TAGS, isCompositionHost, layerKindOf, type EditingLayer, type EditingStackingSibling, type LayerKind, } from "./editingLayers.js";
53
56
  export declare const EDITING_PROTOCOL_VERSION: 1;
57
+ export declare const DRAFT_CHROME = "draft-chrome";
54
58
  /** Parent to frame, on the window: asks the runtime for the port. */
55
59
  export declare const EDITING_CONNECT = "editing-connect";
60
+ export declare const PAGE_SHOWN = "page-shown";
61
+ export declare const PAGE_LEFT = "page-left";
56
62
  /** Frame to parent, on the window: carries the port in its transfer list. */
57
63
  export declare const EDITING_PORT = "editing-port";
58
- export declare const EDITING_REQUEST_KINDS: readonly ["hello", "runtime-snapshot", "wait-for-seek", "set-loop-start", "computed-styles", "authored-styles", "font-faces", "elements-at-point", "pointer-targets", "describe", "ancestors", "query", "geometry", "layers", "draft", "gesture-start", "gesture-base", "console-errors", "watch-keys", "restore-attributes", "caption-words", "caption-transform", "color-grading-status", "color-grading-previews", "color-grading-playback", "watch-geometry", "audio-meter", "document-markup", "set-audio-group-attribute", "assign-audio-group", "gsap-snapshot", "motion-path-home", "max-z-index", "crop-lift", "edit-element", "remove-elements", "stacking-family", "gsap-set", "patch-tweens", "soft-reload", "hold-scenes", "mark-scenes-stale", "swap-scenes", "live-retime", "rebind-timing", "assets-unloaded", "text-edit", "serve-paused-frames", "frame-presented", "arm-canvas-keys", "resolve-canvas-key-action", "stage-measure", "stage-act"];
64
+ export declare const EDITING_REQUEST_KINDS: readonly ["hello", "runtime-snapshot", "wait-for-seek", "set-loop-start", "computed-styles", "authored-styles", "font-faces", "elements-at-point", "pointer-targets", "describe", "ancestors", "query", "geometry", "layers", "draft", "gesture-start", "gesture-base", "console-errors", "watch-keys", "restore-attributes", "caption-words", "caption-transform", "color-grading-status", "color-grading-previews", "color-grading-playback", "watch-geometry", "watch-pointer", "audio-meter", "document-markup", "set-audio-group-attribute", "assign-audio-group", "gsap-snapshot", "motion-path-home", "max-z-index", "crop-lift", "edit-element", "remove-elements", "stacking-family", "gsap-set", "patch-tweens", "soft-reload", "hold-scenes", "mark-scenes-stale", "swap-scenes", "live-retime", "rebind-timing", "assets-unloaded", "text-edit", "serve-paused-frames", "frame-presented", "arm-canvas-keys", "resolve-canvas-key-action", "stage-measure", "stage-act"];
59
65
  export type EditingRequestKind = (typeof EDITING_REQUEST_KINDS)[number];
60
66
  export interface EditingRuntimeSnapshot {
61
67
  /** The runtime has installed its player API. */
@@ -127,6 +133,7 @@ export interface EditingRequests {
127
133
  result: {
128
134
  version: typeof EDITING_PROTOCOL_VERSION;
129
135
  kinds: string[];
136
+ accepts?: string[];
130
137
  };
131
138
  };
132
139
  "runtime-snapshot": {
@@ -259,10 +266,11 @@ export interface EditingRequests {
259
266
  missingGroup: boolean;
260
267
  };
261
268
  };
262
- /** Gesture drafts in order, up to MAX_DESCRIBE_HANDLES; `drawn` counts the elements still here. */
269
+ /** Gesture drafts in order, up to MAX_DESCRIBE_HANDLES, and the chrome painted with them (null clears it). */
263
270
  draft: {
264
271
  params: {
265
272
  drafts: EditingDraft[];
273
+ chrome?: EditingDragChrome;
266
274
  };
267
275
  result: EditingDraftReply & {
268
276
  gsapSetTakesDrafts?: true;
@@ -333,6 +341,12 @@ export interface EditingRequests {
333
341
  watching: number;
334
342
  };
335
343
  };
344
+ "watch-pointer": {
345
+ params: WatchPointerParams;
346
+ result: {
347
+ watching: boolean;
348
+ };
349
+ };
336
350
  "audio-meter": {
337
351
  params: {
338
352
  on: boolean;
@@ -545,6 +559,7 @@ export interface EditingPortClient {
545
559
  /** Calls `listener` with each key the frame forwards for `watch-keys`; returns the unsubscribe. */
546
560
  onKey(listener: (key: EditingKeyEvent) => void): () => void;
547
561
  onGeometry(listener: (event: EditingGeometryEvent) => void): () => void;
562
+ onPointerTargets(listener: (event: EditingPointerEvent) => void): () => void;
548
563
  onTextEditEnded(listener: (event: TextEditEndedEvent) => void): () => void;
549
564
  onTextEditAway(listener: (event: TextEditAwayEvent) => void): () => void;
550
565
  onTextEditSelection(listener: (event: TextEditSelectionEvent) => void): () => void;
@@ -563,6 +578,7 @@ export declare function createEditingPortClient(options: {
563
578
  iframe: HTMLIFrameElement;
564
579
  timeoutMs?: number;
565
580
  host?: Window;
581
+ gate?: Promise<boolean>;
566
582
  }): EditingPortClient;
567
583
  export { elementHome, transformWDivisor, type MotionPathHome } from "./editing/motionPathHome.js";
568
584
  export { MAX_CANVAS_KEY_COMBOS, type ArmCanvasKeysParams, type ArmCanvasKeysResult, type CanvasKeyActionEvent, type CanvasKeyNudgeCombo, type ResolveCanvasKeyActionParams, type ResolveCanvasKeyActionResult, } from "./editing/canvasKeys.js";
@@ -1,8 +1,10 @@
1
1
  import { geometryEvent, parseWatchGeometry, } from "./editing/watchGeometry.js";
2
+ import { parseWatchPointer, pointerEvent, } from "./editing/watchPointer.js";
2
3
  import { EDITING_ELEMENT_HANDLE, MAX_DESCRIBE_HANDLES, MAX_DRAFT_PX, } from "./editingElement.js";
3
4
  import { parseGsapSet } from "./editing/gsapSet.js";
4
5
  import { parsePatchTweensRequest } from "./editing/patchTween.js";
5
6
  import { parseDraftEnd } from "./editingDraftEnd.js";
7
+ import { parseDragChrome } from "./editing/dragChrome.js";
6
8
  import { parseRestoreAttributesRerun, parseSoftReload, } from "./editing/softReload.js";
7
9
  import { parseHoldScenes, parseMarkScenesStale, parseSwapScenes, } from "./editing/scenes.js";
8
10
  import { parseLiveRetime, } from "./editing/liveRetime.js";
@@ -25,6 +27,7 @@ export { buildStableSelector, escapeCssString, getPreferredClassSelector, isEdit
25
27
  export { elementCornerPoints, isElementVisibleThroughAncestors, readElementTransformSnapshot, rotationDegreesFromMatrix, snapCandidates, MAX_GEOMETRY_CHILDREN, MAX_SNAP_TARGETS, ROTATION_GATE_EPSILON_DEG, } from "./editingGeometry.js";
26
28
  export { MAX_CAPTION_TRANSFORM } from "./editing/captionTransform.js";
27
29
  export { MAX_EDIT_ENTRIES } from "./editing/editElement.js";
30
+ export { MAX_DRAG_CHROME_BYTES, MAX_DRAG_CHROME_NODES, parseDragChrome, } from "./editing/dragChrome.js";
28
31
  export { MAX_FONT_FACES } from "./editing/textStyleReads.js";
29
32
  export { MAX_STAGE_CLIP_KEYS, MAX_STAGE_ITEMS, } from "./editing/stageMeasure.js";
30
33
  export { isStageColour, MAX_STAGE_ACTS, readStageActHeld, readStageRect, STAGE_ACT_BORROWS, STAGE_ACT_STYLES, } from "./editing/stageAct.js";
@@ -34,8 +37,11 @@ export { MAX_SNAPSHOT_CHANNELS, MAX_SNAPSHOT_FIELDS, MAX_SNAPSHOT_TARGETS, MAX_S
34
37
  export { compositionPoint, coversComposition, isDomLayerElement, isInspectableLayerElement, pointerTarget, pointerTargets, resolveAllVisualDomEditTargets, resolveLayerSelector, } from "./editingTargets.js";
35
38
  export { elementZIndex, hasOnlyFormattingChildren, NON_PAINTING_TAGS, isCompositionHost, layerKindOf, } from "./editingLayers.js";
36
39
  export const EDITING_PROTOCOL_VERSION = 1;
40
+ export const DRAFT_CHROME = "draft-chrome";
37
41
  /** Parent to frame, on the window: asks the runtime for the port. */
38
42
  export const EDITING_CONNECT = "editing-connect";
43
+ export const PAGE_SHOWN = "page-shown";
44
+ export const PAGE_LEFT = "page-left";
39
45
  /** Frame to parent, on the window: carries the port in its transfer list. */
40
46
  export const EDITING_PORT = "editing-port";
41
47
  export const EDITING_REQUEST_KINDS = [
@@ -65,6 +71,7 @@ export const EDITING_REQUEST_KINDS = [
65
71
  "color-grading-previews",
66
72
  "color-grading-playback",
67
73
  "watch-geometry",
74
+ "watch-pointer",
68
75
  "audio-meter",
69
76
  "document-markup",
70
77
  "set-audio-group-attribute",
@@ -257,14 +264,22 @@ function gsapSetWithDrafts(params) {
257
264
  return parseGsapSet(params);
258
265
  const { drafts, ...set } = params;
259
266
  const parsed = parseGsapSet(set);
260
- const drawn = draftList({ drafts });
267
+ const drawn = draftsOnly({ drafts });
261
268
  return parsed && drawn ? { ...parsed, drafts: drawn.drafts } : null;
262
269
  }
263
270
  function draftList(params) {
271
+ if (!isPlainRecord(params) || !("chrome" in params))
272
+ return draftsOnly(params);
273
+ const { chrome, ...rest } = params;
274
+ const drawn = draftsOnly(rest, true);
275
+ const parsed = parseDragChrome(chrome);
276
+ return drawn && parsed !== undefined ? { ...drawn, chrome: parsed } : null;
277
+ }
278
+ function draftsOnly(params, chromeOnly = false) {
264
279
  if (!hasKeys(params, "drafts") || !Array.isArray(params.drafts))
265
280
  return null;
266
281
  const { drafts } = params;
267
- if (!drafts.length || drafts.length > MAX_DESCRIBE_HANDLES)
282
+ if ((!drafts.length && !chromeOnly) || drafts.length > MAX_DESCRIBE_HANDLES)
268
283
  return null;
269
284
  const parsed = drafts.map(draftEntry);
270
285
  return parsed.includes(null) ? null : { drafts: parsed };
@@ -351,6 +366,7 @@ const PARAM_PARSERS = {
351
366
  "color-grading-previews": parseColorGradingPreviewsParams,
352
367
  "color-grading-playback": parseColorGradingPlaybackParams,
353
368
  "watch-geometry": parseWatchGeometry,
369
+ "watch-pointer": parseWatchPointer,
354
370
  "audio-meter": parseAudioMeter,
355
371
  "document-markup": noParams,
356
372
  "set-audio-group-attribute": parseSetAudioGroupAttribute,
@@ -459,10 +475,11 @@ const portsTaken = new WeakSet();
459
475
  * that frame sends. Replies are data from the frame, so callers validate results.
460
476
  */
461
477
  export function createEditingPortClient(options) {
462
- const { iframe, timeoutMs = EDITING_REQUEST_TIMEOUT_MS, host = window } = options;
478
+ const { iframe, timeoutMs = EDITING_REQUEST_TIMEOUT_MS, host = window, gate } = options;
463
479
  const pending = new Map();
464
480
  const keyListeners = new Set();
465
481
  const geometryListeners = new Set();
482
+ const pointerListeners = new Set();
466
483
  const textEditListeners = new Set();
467
484
  const awayListeners = new Set();
468
485
  const selectionListeners = new Set();
@@ -470,6 +487,7 @@ export function createEditingPortClient(options) {
470
487
  const stageReadyListeners = new Set();
471
488
  const stageInputListeners = new Set();
472
489
  let watchedGeometry = false;
490
+ let watchedPointer = false;
473
491
  let port = null;
474
492
  let disposed = false;
475
493
  let lastId = 0;
@@ -495,6 +513,7 @@ export function createEditingPortClient(options) {
495
513
  const pushRoutes = [
496
514
  pushRoute(keyListeners, (d) => d.v === v && d.event === "key" && keyEvent(d.key)),
497
515
  pushRoute(geometryListeners, (d) => geometryEvent(d, v)),
516
+ pushRoute(pointerListeners, (d) => pointerEvent(d, v)),
498
517
  pushRoute(textEditListeners, (d) => textEditEndedEvent(d, v)),
499
518
  pushRoute(awayListeners, (d) => textEditAwayEvent(d, v)),
500
519
  pushRoute(selectionListeners, (d) => textEditSelectionEvent(d, v)),
@@ -531,9 +550,17 @@ export function createEditingPortClient(options) {
531
550
  port.onmessage = onReply;
532
551
  resolveReady();
533
552
  };
534
- host.addEventListener("message", onWindowMessage);
535
- connect();
536
- return {
553
+ const start = () => {
554
+ if (disposed)
555
+ return;
556
+ host.addEventListener("message", onWindowMessage);
557
+ connect();
558
+ };
559
+ if (gate)
560
+ void gate.then((open) => (open ? start() : client.dispose()));
561
+ else
562
+ start();
563
+ const client = {
537
564
  ready,
538
565
  request(kind, params, requestOptions) {
539
566
  if (disposed)
@@ -541,6 +568,8 @@ export function createEditingPortClient(options) {
541
568
  const id = ++lastId;
542
569
  if (kind === "watch-geometry")
543
570
  watchedGeometry = true;
571
+ if (kind === "watch-pointer")
572
+ watchedPointer = true;
544
573
  const limit = requestOptions?.timeoutMs ?? Math.max(timeoutMs, clientWaitPastFrameDeadline(kind, params));
545
574
  const result = new Promise((resolve, reject) => {
546
575
  const timer = wallSetTimeout(() => settle(id, { error: new EditingPortError("timeout", `${kind} timed out`) }), limit);
@@ -568,6 +597,10 @@ export function createEditingPortClient(options) {
568
597
  geometryListeners.add(listener);
569
598
  return () => geometryListeners.delete(listener);
570
599
  },
600
+ onPointerTargets(listener) {
601
+ pointerListeners.add(listener);
602
+ return () => pointerListeners.delete(listener);
603
+ },
571
604
  onTextEditEnded(listener) {
572
605
  textEditListeners.add(listener);
573
606
  return () => textEditListeners.delete(listener);
@@ -598,6 +631,7 @@ export function createEditingPortClient(options) {
598
631
  disposed = true;
599
632
  keyListeners.clear();
600
633
  geometryListeners.clear();
634
+ pointerListeners.clear();
601
635
  textEditListeners.clear();
602
636
  awayListeners.clear();
603
637
  selectionListeners.clear();
@@ -609,6 +643,10 @@ export function createEditingPortClient(options) {
609
643
  const stop = { kind: "watch-geometry", params: { handles: [] } };
610
644
  port?.postMessage({ v: EDITING_PROTOCOL_VERSION, id: ++lastId, ...stop });
611
645
  }
646
+ if (watchedPointer) {
647
+ const stop = { kind: "watch-pointer", params: { point: null } };
648
+ port?.postMessage({ v: EDITING_PROTOCOL_VERSION, id: ++lastId, ...stop });
649
+ }
612
650
  port?.close();
613
651
  rejectReady(new EditingPortError("disposed", "client disposed"));
614
652
  for (const id of [...pending.keys()]) {
@@ -616,6 +654,7 @@ export function createEditingPortClient(options) {
616
654
  }
617
655
  },
618
656
  };
657
+ return client;
619
658
  }
620
659
  export { elementHome, transformWDivisor } from "./editing/motionPathHome.js";
621
660
  export { MAX_CANVAS_KEY_COMBOS, } from "./editing/canvasKeys.js";
@@ -166,7 +166,7 @@ function holdShownFrame(el) {
166
166
  const still = stillOf(el);
167
167
  if (!still)
168
168
  return;
169
- heldPosters.set(el, { poster: el.getAttribute("poster"), since: performance.now() });
169
+ heldPosters.set(el, { poster: pagePoster(el), since: performance.now() });
170
170
  el.setAttribute("poster", still);
171
171
  const letGo = () => {
172
172
  for (const type of RELEASE_EVENTS)
@@ -306,6 +306,9 @@ export function isRenderMode(el) {
306
306
  return isVideoElement(el) && !!findInjectedRenderFrame(el);
307
307
  }
308
308
  const stills = new WeakSet();
309
+ // The poster each still put up (its URL, or a sealed frame's data URL), and the hold a sealed fetch belongs to.
310
+ const stillPosters = new WeakMap();
311
+ const stillHolds = new WeakMap();
309
312
  /** While a file the browser cannot play is being copied, its own frame at the playhead stands in as the poster. */
310
313
  function showStill(el, originalSrc, variant, box, light) {
311
314
  const at = sourceTimeAtPlayhead(el);
@@ -314,10 +317,48 @@ function showStill(el, originalSrc, variant, box, light) {
314
317
  const url = new URL(appendProxyParam(originalSrc, variant, box, light), document.baseURI);
315
318
  url.searchParams.set(PREVIEW_PROXY_STILL_PARAM, at.toFixed(1));
316
319
  stills.add(el);
317
- el.setAttribute("poster", url.href);
320
+ if (window.origin !== "null")
321
+ return putUpStill(el, url.href);
322
+ // A sealed frame's poster load can wait behind its other loads; its fetch goes out at once.
323
+ const hold = {};
324
+ stillHolds.set(el, hold);
325
+ void fetch(url.href)
326
+ .then((res) => (res.ok ? dataUrlOf(res) : null))
327
+ .then((still) => {
328
+ if (still && stillHolds.get(el) === hold && !el.hasAttribute("poster"))
329
+ putUpStill(el, still);
330
+ })
331
+ .catch((err) => swallow("runtime.mediaProxy.still", err));
332
+ }
333
+ // A data URL, like the held frame's own still: nothing to release on any way the clip goes. Encoded natively.
334
+ async function dataUrlOf(res) {
335
+ const type = res.headers.get("content-type") ?? "image/jpeg";
336
+ const blob = new Blob([await res.arrayBuffer()], { type });
337
+ return new Promise((resolve, reject) => {
338
+ const reader = new FileReader();
339
+ reader.onload = () => resolve(String(reader.result));
340
+ reader.onerror = () => reject(reader.error);
341
+ reader.readAsDataURL(blob);
342
+ });
343
+ }
344
+ function putUpStill(el, poster) {
345
+ stillPosters.set(el, poster);
346
+ el.setAttribute("poster", poster);
347
+ }
348
+ /** The poster as the page set it: none while the runtime's own still is up. */
349
+ function pagePoster(el) {
350
+ const poster = el.getAttribute("poster");
351
+ return poster !== null && poster === stillPosters.get(el) ? null : poster;
318
352
  }
319
353
  function dropStill(el) {
320
- if (stills.delete(el))
354
+ if (!stills.delete(el))
355
+ return;
356
+ stillHolds.delete(el);
357
+ const poster = stillPosters.get(el);
358
+ stillPosters.delete(el);
359
+ if (poster === undefined)
360
+ return;
361
+ if (el.getAttribute("poster") === poster)
321
362
  el.removeAttribute("poster");
322
363
  }
323
364
  function appendProxyParam(src, variant, box, light = false, retry = false) {
@@ -473,10 +514,40 @@ async function makeCopy(el, job, scale) {
473
514
  // The shown size may have grown while this copy was being made.
474
515
  if (displayScale !== null)
475
516
  keepSized(el, displayScale);
476
- return new Promise((landed) => {
477
- el.addEventListener("loadeddata", landed, { once: true });
478
- el.addEventListener("error", landed, { once: true });
479
- }).then(() => dropStill(el));
517
+ return copyLoadEnds(el, proxiedSrc).then(() => dropStill(el));
518
+ }
519
+ const ENDS_A_LOAD = ["loadeddata", "error", "abort", "emptied"];
520
+ const leaving = new Map();
521
+ let leavingObserver = null;
522
+ /** Settles once the copy draws or fails, the clip loads something else, or it leaves the page. */
523
+ function copyLoadEnds(el, href) {
524
+ return new Promise((ended) => {
525
+ const end = (event) => {
526
+ const restarted = event?.type === "abort" || event?.type === "emptied";
527
+ if (restarted && el.getAttribute("src") === href)
528
+ return;
529
+ for (const type of ENDS_A_LOAD)
530
+ el.removeEventListener(type, end);
531
+ if (leaving.get(el) === end)
532
+ leaving.delete(el);
533
+ if (leaving.size === 0) {
534
+ leavingObserver?.disconnect();
535
+ leavingObserver = null;
536
+ }
537
+ ended();
538
+ };
539
+ for (const type of ENDS_A_LOAD)
540
+ el.addEventListener(type, end);
541
+ leaving.set(el, end);
542
+ if (leavingObserver || typeof MutationObserver === "undefined")
543
+ return;
544
+ leavingObserver = new MutationObserver(() => {
545
+ for (const [clip, left] of leaving)
546
+ if (!clip.isConnected)
547
+ left();
548
+ });
549
+ leavingObserver.observe(document, { childList: true, subtree: true });
550
+ });
480
551
  }
481
552
  /**
482
553
  * Swap `el` to its alpha-aware proxy URL, evict stale per-source sync state, and
@@ -24,6 +24,7 @@ export declare const STUDIO_PREVIEW_ERRORS = "__hfPreviewErrors";
24
24
  export declare const STUDIO_PREVIEW_ERROR_MESSAGE = "preview-error";
25
25
  export declare const STUDIO_PREVIEW_ERROR_KINDS = "__hfPreviewErrorKinds";
26
26
  export declare const STUDIO_PREVIEW_RETRY_AFTER = "__hfPreviewRetryAfter";
27
+ export declare const STUDIO_PREVIEW_PAGE_DEADLINE_MS = 120000;
27
28
  export declare function previewConsoleErrorText(args: readonly unknown[]): string | null;
28
29
  export declare const refusedPreviewMessage: (status: number) => string;
29
30
  export declare function refusedPreviewStatus(message: string): number | null;
@@ -52,6 +52,7 @@ export const STUDIO_PREVIEW_ERRORS = "__hfPreviewErrors";
52
52
  export const STUDIO_PREVIEW_ERROR_MESSAGE = "preview-error";
53
53
  export const STUDIO_PREVIEW_ERROR_KINDS = "__hfPreviewErrorKinds";
54
54
  export const STUDIO_PREVIEW_RETRY_AFTER = "__hfPreviewRetryAfter";
55
+ export const STUDIO_PREVIEW_PAGE_DEADLINE_MS = 120_000;
55
56
  export function previewConsoleErrorText(args) {
56
57
  const text = args.map((a) => (a instanceof Error ? a.message : String(a))).join(" ");
57
58
  return text.includes("favicon") ? null : text;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/core",
3
- "version": "0.9.104",
3
+ "version": "0.9.107",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -525,9 +525,9 @@
525
525
  "linkedom": "^0.18.12",
526
526
  "postcss": "^8.5.8",
527
527
  "wawoff2": "^2.0.1",
528
- "@hyperframes/lint": "0.9.104",
529
- "@hyperframes/studio-server": "0.9.104",
530
- "@hyperframes/parsers": "0.9.104"
528
+ "@hyperframes/parsers": "0.9.107",
529
+ "@hyperframes/lint": "0.9.107",
530
+ "@hyperframes/studio-server": "0.9.107"
531
531
  },
532
532
  "devDependencies": {
533
533
  "@fontsource/archivo-black": "^5.2.8",