@hyperframes/core 0.9.102 → 0.9.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/atomicFile.d.ts +1 -0
  2. package/dist/atomicFile.js +1 -1
  3. package/dist/compiler/compositionScoping.js +3 -3
  4. package/dist/compiler/svgIdNamespacing.js +2 -2
  5. package/dist/fonts/authoredGoogleFonts.js +2 -2
  6. package/dist/fonts/deterministicFonts.js +2 -2
  7. package/dist/generated/position-edits-render-inline.js +1 -1
  8. package/dist/generated/runtime-inline.js +1 -1
  9. package/dist/hyperframe.runtime.iife.js +71 -71
  10. package/dist/index.d.ts +1 -1
  11. package/dist/runtime/domRealm.d.ts +1 -0
  12. package/dist/runtime/domRealm.js +3 -0
  13. package/dist/runtime/editing/canvasKeys.d.ts +63 -0
  14. package/dist/runtime/editing/canvasKeys.js +471 -0
  15. package/dist/runtime/editing/pausedFrames.js +7 -7
  16. package/dist/runtime/editing/removeElements.d.ts +10 -0
  17. package/dist/runtime/editing/removeElements.js +35 -0
  18. package/dist/runtime/editing/stageAct.d.ts +116 -0
  19. package/dist/runtime/editing/stageAct.js +531 -0
  20. package/dist/runtime/editing/stageGhost.d.ts +10 -0
  21. package/dist/runtime/editing/stageGhost.js +64 -0
  22. package/dist/runtime/editing/stageMeasure.d.ts +5 -0
  23. package/dist/runtime/editing/stageMeasure.js +35 -1
  24. package/dist/runtime/editing/textEdit.d.ts +14 -0
  25. package/dist/runtime/editing/textEdit.js +67 -9
  26. package/dist/runtime/editing/transformValues.d.ts +6 -0
  27. package/dist/runtime/editing/transformValues.js +39 -0
  28. package/dist/runtime/editing/watchGeometry.js +8 -8
  29. package/dist/runtime/editingGestureStart.d.ts +2 -0
  30. package/dist/runtime/editingGestureStart.js +1 -1
  31. package/dist/runtime/editingPort.d.ts +35 -3
  32. package/dist/runtime/editingPort.js +78 -16
  33. package/dist/runtime/playbackHealth.d.ts +8 -1
  34. package/dist/runtime/playbackHealth.js +118 -18
  35. package/dist/runtime/runtimePort.d.ts +21 -0
  36. package/dist/runtime/runtimePort.js +122 -0
  37. package/dist/runtime/types.d.ts +18 -0
  38. package/dist/studioPreviewMark.d.ts +1 -0
  39. package/dist/studioPreviewMark.js +1 -0
  40. package/package.json +4 -4
@@ -0,0 +1,64 @@
1
+ // A removed element's ghost: its subtree, written out by the frame it leaves and stood back by the one replacing it.
2
+ // Studio relays the markup as an opaque string; only the receiving frame parses it, inert, with active parts stripped.
3
+ import { locateStageKey } from "./stageMeasure.js";
4
+ export const MAX_STAGE_GHOST_MARKUP = 65_536;
5
+ // Never run in the frame it lands in: active content, frames, navigation and imports.
6
+ const STRIPPED = "script,iframe,object,embed,frame,frameset,base,meta,link";
7
+ const ACTIVE_URL = /javascript:|data:text\/html/i;
8
+ // Its own look, read while the document it left still answers; the new one's stylesheet may have dropped its rules.
9
+ const GHOST_LOOK = [
10
+ "color",
11
+ "background-color",
12
+ "border",
13
+ "border-radius",
14
+ "font",
15
+ "letter-spacing",
16
+ "rotate",
17
+ "box-shadow",
18
+ "padding",
19
+ "display",
20
+ "place-items",
21
+ "align-items",
22
+ "justify-content",
23
+ "text-align",
24
+ ];
25
+ /** Each target's subtree as markup, its computed look written on its root; one over the cap is left out. */
26
+ export function captureStageGhosts(doc, targets) {
27
+ const view = doc.defaultView;
28
+ const ghosts = [];
29
+ for (const target of targets) {
30
+ const element = locateStageKey(doc, target);
31
+ if (!element || !view)
32
+ continue;
33
+ const clone = element.cloneNode(true);
34
+ if (!clone.style)
35
+ continue;
36
+ const look = view.getComputedStyle(element);
37
+ for (const name of GHOST_LOOK)
38
+ clone.style.setProperty(name, look.getPropertyValue(name));
39
+ clone.removeAttribute("data-hf-id");
40
+ clone.removeAttribute("id");
41
+ const markup = clone.outerHTML;
42
+ if (markup.length <= MAX_STAGE_GHOST_MARKUP)
43
+ ghosts.push({ key: target.key, markup });
44
+ }
45
+ return ghosts;
46
+ }
47
+ /** Parses relayed markup inert and strips what could run, navigate or load as a document; null unless one element. */
48
+ export function inertStageGhost(doc, markup) {
49
+ const parsed = new DOMParser().parseFromString(markup, "text/html");
50
+ const root = parsed.body.firstElementChild;
51
+ if (!root || parsed.body.children.length !== 1 || root.matches(STRIPPED))
52
+ return null;
53
+ for (const node of [...root.querySelectorAll(STRIPPED)])
54
+ node.remove();
55
+ for (const element of [root, ...root.querySelectorAll("*")])
56
+ for (const { name, value } of [...element.attributes]) {
57
+ // URL parsing ignores spaces and control characters: `java\nscript:` still runs.
58
+ const plain = [...value].filter((c) => c.charCodeAt(0) > 32).join("");
59
+ if (/^on/i.test(name) || name.toLowerCase() === "srcdoc" || ACTIVE_URL.test(plain))
60
+ element.removeAttribute(name);
61
+ }
62
+ const ghost = doc.importNode(root, true);
63
+ return ghost.style ? ghost : null;
64
+ }
@@ -31,5 +31,10 @@ export interface StageMeasureResult {
31
31
  truncated: boolean;
32
32
  }
33
33
  export declare function parseStageMeasureParams(params: unknown): StageMeasureParams | null;
34
+ export declare function paintedOnStage(element: Element): boolean;
35
+ export declare function locateStageKey(doc: Document, target: {
36
+ key: string;
37
+ hfId: string | null;
38
+ }): Element | null;
34
39
  /** Walks `doc.body` in document order up to `maxItems`, capturing layout, styles, visibility, and clip keys. */
35
40
  export declare function measureStageDocument(doc?: Document, maxItems?: number): StageMeasureResult;
@@ -109,6 +109,40 @@ function measureElement(doc, view, element, parent, key, hfId) {
109
109
  hasBackgroundImage: Boolean(bgImage && bgImage !== "none"),
110
110
  };
111
111
  }
112
+ export function paintedOnStage(element) {
113
+ const view = element.ownerDocument.defaultView;
114
+ if (!view)
115
+ return false;
116
+ return isElementVisible(element, view.getComputedStyle(element), element.getBoundingClientRect().width);
117
+ }
118
+ const escapedIdKey = (hfId) => `#${hfId.replace(/[\\>]/g, "\\$&")}`;
119
+ function unescapedKeyParts(key) {
120
+ const parts = [""];
121
+ for (let i = 0; i < key.length; i += 1) {
122
+ const c = key[i];
123
+ if (c === "\\")
124
+ parts[parts.length - 1] += key[++i] ?? "";
125
+ else if (c === ">")
126
+ parts.push("");
127
+ else
128
+ parts[parts.length - 1] += c;
129
+ }
130
+ return parts;
131
+ }
132
+ export function locateStageKey(doc, target) {
133
+ const byId = (id) => doc.querySelector(`[data-hf-id="${CSS.escape(id)}"]`);
134
+ if (target.hfId)
135
+ return byId(target.hfId);
136
+ const [anchor = "", ...steps] = unescapedKeyParts(target.key);
137
+ let element = null;
138
+ if (anchor.startsWith("#"))
139
+ element = byId(anchor.slice(1));
140
+ else if (/^\d+$/.test(anchor))
141
+ element = doc.body?.children[Number(anchor)] ?? null;
142
+ for (const step of steps)
143
+ element = element?.children[Number(step)] ?? null;
144
+ return element;
145
+ }
112
146
  /** Walks `doc.body` in document order up to `maxItems`, capturing layout, styles, visibility, and clip keys. */
113
147
  export function measureStageDocument(doc = document, maxItems = MAX_STAGE_ITEMS) {
114
148
  const view = doc.defaultView;
@@ -127,7 +161,7 @@ export function measureStageDocument(doc = document, maxItems = MAX_STAGE_ITEMS)
127
161
  }
128
162
  const rawHfId = element.getAttribute("data-hf-id");
129
163
  const hfId = rawHfId ? clampValue(rawHfId) : null;
130
- const key = hfId ?? clampValue(path);
164
+ const key = clampValue(hfId ? escapedIdKey(hfId) : path);
131
165
  items.push(measureElement(doc, view, element, parent, key, hfId));
132
166
  for (let i = 0; i < element.children.length; i += 1) {
133
167
  const child = element.children[i];
@@ -8,6 +8,7 @@ export type TextEditParams = {
8
8
  handle: EditingElementHandle;
9
9
  action: "start";
10
10
  caret: Point | null;
11
+ away?: boolean;
11
12
  } | {
12
13
  handle: EditingElementHandle;
13
14
  action: "end";
@@ -48,6 +49,17 @@ export type TextEditCaret = {
48
49
  color: string;
49
50
  viewportWidth: number;
50
51
  };
52
+ export type TextEditAwayEvent = {
53
+ handle: EditingElementHandle;
54
+ button: 0 | 2;
55
+ point: Point;
56
+ viewportWidth: number;
57
+ keys: {
58
+ shiftKey: boolean;
59
+ metaKey: boolean;
60
+ ctrlKey: boolean;
61
+ };
62
+ };
51
63
  export type TextEditSelectionEvent = {
52
64
  handle: EditingElementHandle;
53
65
  selection: TextEditSelection | null;
@@ -55,8 +67,10 @@ export type TextEditSelectionEvent = {
55
67
  };
56
68
  export declare function parseTextEdit(params: unknown): TextEditParams | null;
57
69
  export declare function textEditSelectionEvent(data: unknown, version: number): TextEditSelectionEvent | null;
70
+ export declare function textEditAwayEvent(data: unknown, version: number): TextEditAwayEvent | null;
58
71
  export declare function textEditEndedEvent(data: unknown, version: number): TextEditEndedEvent | null;
59
72
  export declare function textEditResult(reply: unknown): TextEditResult | null;
73
+ export declare function isActiveTextEditTarget(target: EventTarget | null): boolean;
60
74
  /** Ends an open session with its original markup back; the agent's dispose and a page hide call it. */
61
75
  export declare function endTextEdit(): void;
62
76
  export declare function caretRangeAt(doc: Document, at: Point): Range | null;
@@ -1,8 +1,9 @@
1
1
  // `text-edit`: one in-place text editing session in the frame, for a parent that cannot script it.
2
2
  // It edits only an element it handed a handle for, and lets out nothing but text markup.
3
+ import { postOnPort } from "../runtimePort.js";
3
4
  import { EDITING_ELEMENT_HANDLE } from "../editingElement.js";
4
5
  import { elementForHandle } from "../editingHandles.js";
5
- import { isStylableElement } from "../domRealm.js";
6
+ import { isDomNode, isStylableElement } from "../domRealm.js";
6
7
  import { sanitizeRichTextChildren } from "../../utils/richTextSanitize.js";
7
8
  import { openTextEdits, isTextMarkup, MAX_EDIT_VALUE } from "./editElement.js";
8
9
  import { isEditableText } from "./textMarkup.js";
@@ -21,14 +22,22 @@ const isRecord = (value) => Object.prototype.toString.call(value) === "[object O
21
22
  const keysAre = (value, keys) => Object.keys(value).sort().join() === keys;
22
23
  const isHandle = (value) => typeof value === "string" && EDITING_ELEMENT_HANDLE.test(value);
23
24
  const isPoint = (value) => isRecord(value) && keysAre(value, "x,y") && Number.isFinite(value.x) && Number.isFinite(value.y);
25
+ function parseStart(handle, params) {
26
+ const { caret, away } = params;
27
+ if (caret !== null && !isPoint(caret))
28
+ return null;
29
+ if (keysAre(params, "action,caret,handle"))
30
+ return { handle, action: "start", caret };
31
+ if (keysAre(params, "action,away,caret,handle") && typeof away === "boolean")
32
+ return { handle, action: "start", caret, away };
33
+ return null;
34
+ }
24
35
  export function parseTextEdit(params) {
25
36
  if (!isRecord(params) || !isHandle(params.handle))
26
37
  return null;
27
38
  const { handle, action } = params;
28
- if (action === "start" && keysAre(params, "action,caret,handle")) {
29
- const { caret } = params;
30
- return caret === null || isPoint(caret) ? { handle, action, caret } : null;
31
- }
39
+ if (action === "start")
40
+ return parseStart(handle, params);
32
41
  if (action === "end" && keysAre(params, "action,handle,keep") && typeof params.keep === "boolean")
33
42
  return { handle, action, keep: params.keep };
34
43
  if (action === "style" && keysAre(params, "action,handle,style") && isStyle(params.style))
@@ -77,6 +86,21 @@ export function textEditSelectionEvent(data, version) {
77
86
  return null;
78
87
  return caret === null || isCaret(caret) ? { handle, selection, caret } : null;
79
88
  }
89
+ const isKeys = (value) => isRecord(value) &&
90
+ keysAre(value, "ctrlKey,metaKey,shiftKey") &&
91
+ Object.values(value).every((flag) => typeof flag === "boolean");
92
+ export function textEditAwayEvent(data, version) {
93
+ if (!isRecord(data) || !keysAre(data, "button,event,handle,keys,point,v,viewportWidth"))
94
+ return null;
95
+ if (data.v !== version || data.event !== "text-edit-away" || !isHandle(data.handle))
96
+ return null;
97
+ const { handle, button, point, viewportWidth, keys } = data;
98
+ if ((button !== 0 && button !== 2) || !isPoint(point) || !isKeys(keys))
99
+ return null;
100
+ if (!isFiniteNumber(viewportWidth) || viewportWidth <= 0)
101
+ return null;
102
+ return { handle, button, point, viewportWidth, keys };
103
+ }
80
104
  const isValue = (value) => value === null || (typeof value === "string" && value.length <= MAX_EDIT_VALUE);
81
105
  const isTextMarkupOrNull = (value) => value === null || (typeof value === "string" && isTextMarkup(value));
82
106
  export function textEditEndedEvent(data, version) {
@@ -101,6 +125,9 @@ export function textEditResult(reply) {
101
125
  }
102
126
  let session = null;
103
127
  const NOTHING = { applied: false, html: null, previous: null };
128
+ export function isActiveTextEditTarget(target) {
129
+ return Boolean(session && isDomNode(target) && session.element.contains(target));
130
+ }
104
131
  function clearSelectionWithin(element) {
105
132
  const selection = element.ownerDocument.defaultView?.getSelection();
106
133
  if (!selection || selection.rangeCount === 0)
@@ -268,12 +295,39 @@ function followCaret(element, open) {
268
295
  view?.removeEventListener("scroll", open.report, true);
269
296
  };
270
297
  }
298
+ function passAway(element, post) {
299
+ const doc = element.ownerDocument;
300
+ const view = doc.defaultView;
301
+ const away = (event, button) => ({
302
+ button,
303
+ point: { x: event.clientX, y: event.clientY },
304
+ viewportWidth: view?.innerWidth || 1,
305
+ keys: { shiftKey: event.shiftKey, metaKey: event.metaKey, ctrlKey: event.ctrlKey },
306
+ });
307
+ const afterTheBlurThatSaves = (send) => view?.setTimeout(send);
308
+ const onPress = (event) => {
309
+ if (event.button !== 0 || element.contains(event.target))
310
+ return;
311
+ const message = away(event, 0);
312
+ afterTheBlurThatSaves(() => post(message));
313
+ };
314
+ const onMenu = (event) => {
315
+ event.preventDefault();
316
+ post(away(event, 2));
317
+ };
318
+ doc.addEventListener("pointerdown", onPress, true);
319
+ doc.addEventListener("contextmenu", onMenu, true);
320
+ return () => {
321
+ doc.removeEventListener("pointerdown", onPress, true);
322
+ doc.removeEventListener("contextmenu", onMenu, true);
323
+ };
324
+ }
271
325
  function caretOf(open) {
272
326
  const box = open.caret.composing ? null : caretBoxIn(open.element, open.caret.side);
273
327
  const viewportWidth = open.element.ownerDocument.defaultView?.innerWidth || 1;
274
328
  return box && { ...box, color: open.caret.color, viewportWidth };
275
329
  }
276
- function start(handle, caret, port, version) {
330
+ function start(handle, caret, hostTakesAway, port, version) {
277
331
  close(false);
278
332
  const element = elementForHandle(handle);
279
333
  if (!isStylableElement(element) || !isEditableText(element))
@@ -294,7 +348,7 @@ function start(handle, caret, port, version) {
294
348
  return;
295
349
  const selection = selectionIn(editable);
296
350
  const caret = caretOf(open);
297
- port.postMessage({ v: version, event: "text-edit-selection", handle, selection, caret });
351
+ postOnPort(port, { v: version, event: "text-edit-selection", handle, selection, caret });
298
352
  },
299
353
  };
300
354
  const endInFrame = () => {
@@ -302,13 +356,17 @@ function start(handle, caret, port, version) {
302
356
  return;
303
357
  const ended = close(true);
304
358
  if (ended)
305
- port.postMessage({ v: version, event: "text-edit-ended", handle, ...ended });
359
+ postOnPort(port, { v: version, event: "text-edit-ended", handle, ...ended });
306
360
  };
307
361
  const stopListening = listen(editable, endInFrame, open.report);
308
362
  const stopFollowing = followCaret(editable, open);
363
+ const stopPassing = hostTakesAway
364
+ ? passAway(editable, (away) => postOnPort(port, { v: version, event: "text-edit-away", handle, ...away }))
365
+ : () => { };
309
366
  open.stop = () => {
310
367
  stopListening();
311
368
  stopFollowing();
369
+ stopPassing();
312
370
  };
313
371
  session = open;
314
372
  openTextEdits.add(editable);
@@ -323,7 +381,7 @@ function start(handle, caret, port, version) {
323
381
  }
324
382
  export function textEdit(params, port, version) {
325
383
  if (params.action === "start")
326
- return start(params.handle, params.caret, port, version);
384
+ return start(params.handle, params.caret, params.away === true, port, version);
327
385
  if (session?.handle !== params.handle || session.port !== port)
328
386
  return NOTHING;
329
387
  if (params.action === "style")
@@ -0,0 +1,6 @@
1
+ /** The element's own inline translate (a Studio manual offset is one) moved by `dx dy`, not replaced. */
2
+ export declare function translateBy(own: string, dx: number, dy: number): string;
3
+ /** The element's own scale (inline, else its stylesheet's) grown by `k`, not replaced. */
4
+ export declare function scaleBy(own: string, k: number): string;
5
+ /** The element's own rotate (inline, else its stylesheet's) turned `deg` further; a rotate about an axis is kept. */
6
+ export declare function rotateBy(own: string, deg: number): string;
@@ -0,0 +1,39 @@
1
+ /** A translate's parts, split at the spaces outside brackets: Studio's own is `var(--hf-studio-offset-x, 0px) ...`. */
2
+ function valueParts(value) {
3
+ const parts = [];
4
+ let [depth, start] = [0, 0];
5
+ for (let i = 0; i <= value.length; i++) {
6
+ const c = value[i];
7
+ if (c === "(")
8
+ depth += 1;
9
+ else if (c === ")")
10
+ depth -= 1;
11
+ else if ((c === undefined || c === " ") && depth === 0) {
12
+ if (i > start)
13
+ parts.push(value.slice(start, i));
14
+ start = i + 1;
15
+ }
16
+ }
17
+ return parts;
18
+ }
19
+ /** The element's own inline translate (a Studio manual offset is one) moved by `dx dy`, not replaced. */
20
+ export function translateBy(own, dx, dy) {
21
+ if (!own || own === "none")
22
+ return `${dx}px ${dy}px`;
23
+ const [x = "0px", y = "0px", ...z] = valueParts(own);
24
+ return [`calc(${x} + ${dx}px)`, `calc(${y} + ${dy}px)`, ...z].join(" ");
25
+ }
26
+ /** The element's own scale (inline, else its stylesheet's) grown by `k`, not replaced. */
27
+ export function scaleBy(own, k) {
28
+ if (!own || own === "none")
29
+ return String(k);
30
+ return valueParts(own)
31
+ .map((part) => `calc(${part} * ${k})`)
32
+ .join(" ");
33
+ }
34
+ /** The element's own rotate (inline, else its stylesheet's) turned `deg` further; a rotate about an axis is kept. */
35
+ export function rotateBy(own, deg) {
36
+ if (!own || own === "none")
37
+ return `${deg}deg`;
38
+ return /^-?[\d.]+deg$/.test(own) ? `calc(${own} + ${deg}deg)` : own;
39
+ }
@@ -1,5 +1,6 @@
1
1
  // `watch-geometry`: the frame pushes the named elements' `geometry` fields once per animation frame,
2
2
  // stamped on the clock both windows share, until an empty list, the page hiding, or the parent's release.
3
+ import { portMap, postOnPort } from "../runtimePort.js";
3
4
  import { EDITING_ELEMENT_HANDLE, MAX_DRAFT_PX, MAX_ELEMENT_ENTRIES, MAX_ELEMENT_VALUE, } from "../editingElement.js";
4
5
  import { swallow } from "../diagnostics.js";
5
6
  import { elementGeometry } from "../editingGeometry.js";
@@ -54,12 +55,12 @@ export function geometryEvent(data, version) {
54
55
  return null;
55
56
  return elements.every((e) => e === null || isGeometry(e)) ? { at, elements } : null;
56
57
  }
57
- const watches = new Map();
58
+ const watches = portMap();
58
59
  let wireVersion = 0;
59
60
  function pushTo(port, handles, at) {
60
61
  const { elements } = elementGeometry(handles, undefined);
61
62
  try {
62
- port.postMessage({ v: wireVersion, event: "geometry", at, elements });
63
+ postOnPort(port, { v: wireVersion, event: "geometry", at, elements });
63
64
  }
64
65
  catch {
65
66
  watches.delete(port);
@@ -70,8 +71,7 @@ function push() {
70
71
  observing = false;
71
72
  const at = performance.timeOrigin + performance.now();
72
73
  try {
73
- for (const [port, handles] of watches)
74
- pushTo(port, handles, at);
74
+ watches.forEach((handles, port) => pushTo(port, handles, at));
75
75
  }
76
76
  catch (err) {
77
77
  swallow("watchGeometry.push", err);
@@ -88,16 +88,16 @@ let observing = false;
88
88
  let nextFrame = 0;
89
89
  function observeThisFrame() {
90
90
  nextFrame = 0;
91
- if (!watches.size)
91
+ if (!watches.size())
92
92
  return;
93
93
  observer ??= new ResizeObserver(push);
94
94
  observer.observe(document.documentElement);
95
95
  observing = true;
96
96
  }
97
97
  function schedule() {
98
- if (watches.size && !nextFrame && !observing)
98
+ if (watches.size() && !nextFrame && !observing)
99
99
  nextFrame = requestAnimationFrame(observeThisFrame);
100
- if (watches.size)
100
+ if (watches.size())
101
101
  return;
102
102
  if (nextFrame)
103
103
  cancelAnimationFrame(nextFrame);
@@ -118,7 +118,7 @@ const stopAll = () => stopWatchingGeometry();
118
118
  export function watchGeometry(port, { handles }, version) {
119
119
  if (!handles.length)
120
120
  watches.delete(port);
121
- else if (watches.has(port) || watches.size < MAX_GEOMETRY_WATCHERS)
121
+ else if (watches.has(port) || watches.size() < MAX_GEOMETRY_WATCHERS)
122
122
  watches.set(port, handles);
123
123
  else
124
124
  throw new Error(`at most ${MAX_GEOMETRY_WATCHERS} ports may watch geometry`);
@@ -44,6 +44,8 @@ export type EditingGestureBase = {
44
44
  drawsProps?: true;
45
45
  };
46
46
  export declare function gestureBase(handle: EditingElementHandle): EditingGestureBase | null;
47
+ /** GSAP's x/y when it owns the element's position: it renders its transform, or a tween writes it. */
48
+ export declare function gsapPosition(element: Element): EditingGestureStart["gsap"];
47
49
  /** Each handle's gesture start, null as in `describe`, and the snap boxes of the page around them. */
48
50
  export declare function gestureStart(handles: readonly EditingElementHandle[]): {
49
51
  elements: Array<EditingGestureStart | null>;
@@ -129,7 +129,7 @@ export function gestureBase(handle) {
129
129
  // Read only once GSAP owns it: asking GSAP for x makes it fold a CSS translate into its transform.
130
130
  const readGsap = (element, property) => Number(window.gsap?.getProperty?.(element, property)) || 0;
131
131
  /** GSAP's x/y when it owns the element's position: it renders its transform, or a tween writes it. */
132
- function gsapPosition(element) {
132
+ export function gsapPosition(element) {
133
133
  const tweens = tweensOn(element).filter((tween) => tween.vars && carries(tween.vars, MOVES));
134
134
  if (!rendersTransform(element) && !tweens.length)
135
135
  return null;
@@ -34,7 +34,9 @@ import { type AudioMeterLevels } from "./editing/audioMeter.js";
34
34
  import { type SetAudioGroupAttributeParams } from "./editing/setAudioGroupAttribute.js";
35
35
  import { type EditElementParams, type EditElementResult } from "./editing/editElement.js";
36
36
  import { type StageMeasureParams, type StageMeasureResult } from "./editing/stageMeasure.js";
37
- import { type TextEditEndedEvent, type TextEditSelectionEvent, type TextEditParams, type TextEditResult } from "./editing/textEdit.js";
37
+ import { type StageActParams, type StageActReadyEvent, type StageActResult, type StageInputEvent } from "./editing/stageAct.js";
38
+ import { type TextEditAwayEvent, type TextEditEndedEvent, type TextEditSelectionEvent, type TextEditParams, type TextEditResult } from "./editing/textEdit.js";
39
+ import { type ArmCanvasKeysParams, type ArmCanvasKeysResult, type CanvasKeyActionEvent, type ResolveCanvasKeyActionParams, type ResolveCanvasKeyActionResult } from "./editing/canvasKeys.js";
38
40
  export { buildStableSelector, escapeCssString, getPreferredClassSelector, isEditableTextLeaf, readElementSource, readTextLayer, EDITING_ELEMENT_HANDLE, MAX_DESCRIBE_HANDLES, MAX_ELEMENT_ENTRIES, MAX_ELEMENT_TEXT, MAX_ELEMENT_VALUE, MAX_TIMELINE_TEXT, MAX_POINT_STACK, MAX_QUERY_MATCHES, MAX_SOURCE_GROUPS, isStableSelector, type EditingElementDescription, type EditingElementHandle, type EditingElementHit, type EditingElementMatch, type EditingElementSource, type EditingRect, type TextLayerRead, } from "./editingElement.js";
39
41
  export { elementCornerPoints, isElementVisibleThroughAncestors, readElementTransformSnapshot, rotationDegreesFromMatrix, snapCandidates, MAX_GEOMETRY_CHILDREN, MAX_SNAP_TARGETS, ROTATION_GATE_EPSILON_DEG, type EditingCorner, type EditingCorners, type EditingElementBox, type EditingElementGeometry, type ElementTransformSnapshot, } from "./editingGeometry.js";
40
42
  export type { EditingGestureBase, EditingGestureStart } from "./editingGestureStart.js";
@@ -42,6 +44,9 @@ export { MAX_CAPTION_TRANSFORM } from "./editing/captionTransform.js";
42
44
  export { MAX_EDIT_ENTRIES } from "./editing/editElement.js";
43
45
  export { MAX_FONT_FACES } from "./editing/textStyleReads.js";
44
46
  export { MAX_STAGE_CLIP_KEYS, MAX_STAGE_ITEMS, type StageMeasuredItem, type StageMeasureParams, type StageMeasureResult, type StageTextStart, } from "./editing/stageMeasure.js";
47
+ 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";
48
+ export { MAX_STAGE_GHOST_MARKUP, type StageActGhost } from "./editing/stageGhost.js";
49
+ export { rotateBy, scaleBy, translateBy } from "./editing/transformValues.js";
45
50
  export { MAX_SNAPSHOT_CHANNELS, MAX_SNAPSHOT_FIELDS, MAX_SNAPSHOT_TARGETS, MAX_SNAPSHOT_TEXT, MAX_SNAPSHOT_TWEENS, MAX_VARS_DEPTH, TARGET_FIELDS, TIMELINE_FIELDS, } from "./editing/gsapSnapshotLimits.js";
46
51
  export { compositionPoint, coversComposition, isDomLayerElement, isInspectableLayerElement, pointerTarget, pointerTargets, resolveAllVisualDomEditTargets, resolveLayerSelector, type EditingLocalPointer, type EditingViewport, } from "./editingTargets.js";
47
52
  export { elementZIndex, hasOnlyFormattingChildren, NON_PAINTING_TAGS, isCompositionHost, layerKindOf, type EditingLayer, type EditingStackingSibling, type LayerKind, } from "./editingLayers.js";
@@ -50,7 +55,7 @@ export declare const EDITING_PROTOCOL_VERSION: 1;
50
55
  export declare const EDITING_CONNECT = "editing-connect";
51
56
  /** Frame to parent, on the window: carries the port in its transfer list. */
52
57
  export declare const EDITING_PORT = "editing-port";
53
- 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", "stage-measure"];
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"];
54
59
  export type EditingRequestKind = (typeof EDITING_REQUEST_KINDS)[number];
55
60
  export interface EditingRuntimeSnapshot {
56
61
  /** The runtime has installed its player API. */
@@ -113,6 +118,9 @@ export type EditingDraft = {
113
118
  props?: EditingDraftProps | null;
114
119
  } | EditingDraftEnd;
115
120
  type NoParams = Record<string, never>;
121
+ export type FramePresentedParams = {
122
+ waitMs?: number;
123
+ };
116
124
  export interface EditingRequests {
117
125
  hello: {
118
126
  params: NoParams;
@@ -467,10 +475,29 @@ export interface EditingRequests {
467
475
  served: boolean;
468
476
  };
469
477
  };
478
+ "frame-presented": {
479
+ params: FramePresentedParams;
480
+ result: {
481
+ presented: boolean;
482
+ };
483
+ };
484
+ "arm-canvas-keys": {
485
+ params: ArmCanvasKeysParams;
486
+ result: ArmCanvasKeysResult;
487
+ };
488
+ "resolve-canvas-key-action": {
489
+ params: ResolveCanvasKeyActionParams;
490
+ result: ResolveCanvasKeyActionResult;
491
+ };
470
492
  "stage-measure": {
471
493
  params: StageMeasureParams;
472
494
  result: StageMeasureResult;
473
495
  };
496
+ /** Holds, draws and gives back Studio's stage acts inside the frame (`editing/stageAct.ts`). */
497
+ "stage-act": {
498
+ params: StageActParams;
499
+ result: StageActResult;
500
+ };
474
501
  }
475
502
  export type EditingParams<K extends EditingRequestKind> = EditingRequests[K]["params"];
476
503
  export type EditingResult<K extends EditingRequestKind> = EditingRequests[K]["result"];
@@ -519,7 +546,11 @@ export interface EditingPortClient {
519
546
  onKey(listener: (key: EditingKeyEvent) => void): () => void;
520
547
  onGeometry(listener: (event: EditingGeometryEvent) => void): () => void;
521
548
  onTextEditEnded(listener: (event: TextEditEndedEvent) => void): () => void;
549
+ onTextEditAway(listener: (event: TextEditAwayEvent) => void): () => void;
522
550
  onTextEditSelection(listener: (event: TextEditSelectionEvent) => void): () => void;
551
+ onCanvasKeyAction(listener: (event: CanvasKeyActionEvent) => void): () => void;
552
+ onStageActReady(listener: (event: StageActReadyEvent) => void): () => void;
553
+ onStageInput(listener: (event: StageInputEvent) => void): () => void;
523
554
  /** Rejects every pending request with `disposed` and closes the port. */
524
555
  dispose(): void;
525
556
  }
@@ -534,6 +565,7 @@ export declare function createEditingPortClient(options: {
534
565
  host?: Window;
535
566
  }): EditingPortClient;
536
567
  export { elementHome, transformWDivisor, type MotionPathHome } from "./editing/motionPathHome.js";
537
- export { caretRangeAt, takePlainTextOnly, textEditResult, type TextEditEndedEvent, type TextEditCaret, type TextEditResult, type TextEditSelection, type TextEditSelectionEvent, } from "./editing/textEdit.js";
568
+ export { MAX_CANVAS_KEY_COMBOS, type ArmCanvasKeysParams, type ArmCanvasKeysResult, type CanvasKeyActionEvent, type CanvasKeyNudgeCombo, type ResolveCanvasKeyActionParams, type ResolveCanvasKeyActionResult, } from "./editing/canvasKeys.js";
569
+ export { caretRangeAt, takePlainTextOnly, textEditResult, type TextEditAwayEvent, type TextEditEndedEvent, type TextEditCaret, type TextEditResult, type TextEditSelection, type TextEditSelectionEvent, } from "./editing/textEdit.js";
538
570
  export { caretBoxIn, caretColorOf, caretSideAfterKey, placeCaretAtEnd, type CaretBox, type CaretSide, } from "./editing/textCaret.js";
539
571
  export { parsePausedFrameAsk, PAUSED_FRAME_BYTES, PAUSED_FRAME_PARAMS, PAUSED_FRAME_SOURCES, type PausedFrameAsk, type PausedFrameAskMessage, type PausedFrameImage, type PausedFrameReply, } from "./editing/pausedFrames.js";