@hyperframes/core 0.9.41 → 0.9.43

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.
@@ -14,4 +14,7 @@ export declare function renameWithRetryAsync(from: string, to: string, options?:
14
14
  rename?: (from: string, to: string) => Promise<void>;
15
15
  copy?: (from: string, to: string) => Promise<void>;
16
16
  }): Promise<void>;
17
+ export declare function retryWindowsHold<T>(operation: () => T, options?: {
18
+ platform?: NodeJS.Platform;
19
+ }): Promise<T>;
17
20
  export {};
@@ -79,3 +79,16 @@ export async function renameWithRetryAsync(from, to, options = {}) {
79
79
  }
80
80
  }
81
81
  }
82
+ export async function retryWindowsHold(operation, options = {}) {
83
+ const platform = options.platform ?? process.platform;
84
+ for (let attempt = 0;; attempt++) {
85
+ try {
86
+ return operation();
87
+ }
88
+ catch (error) {
89
+ if (!isWindowsHold(error, platform) || attempt >= BACKOFF_MS.length)
90
+ throw error;
91
+ await new Promise((resolve) => setTimeout(resolve, BACKOFF_MS[attempt]));
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Gesture drafts for the editing channel. A parent that cannot script the frame draws a drag or a
3
+ * resize here, on the element's inline style, so the preview moves with the pointer. What the
4
+ * element had before its first draft is kept until the parent ends the draft or the frame loads again.
5
+ */
6
+ import { type StylableElement as Styled } from "./domRealm.js";
7
+ import type { EditingDraft } from "./editingPort.js";
8
+ export declare function computedTranslateAxes(element: Styled): string[];
9
+ export declare function movedTranslate([x, y, z]: string[], offset: {
10
+ x: number;
11
+ y: number;
12
+ }): string;
13
+ /** Applies each draft in order; one for an element this load no longer has is skipped. */
14
+ export declare function drawDrafts(drafts: readonly EditingDraft[]): {
15
+ drawn: number;
16
+ };
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Gesture drafts for the editing channel. A parent that cannot script the frame draws a drag or a
3
+ * resize here, on the element's inline style, so the preview moves with the pointer. What the
4
+ * element had before its first draft is kept until the parent ends the draft or the frame loads again.
5
+ */
6
+ import { isStylableElement } from "./domRealm.js";
7
+ import { elementForHandle } from "./editingHandles.js";
8
+ const SIZE_PROPERTIES = [
9
+ "box-sizing",
10
+ "width",
11
+ "height",
12
+ "min-width",
13
+ "min-height",
14
+ "max-width",
15
+ "max-height",
16
+ ];
17
+ const DRAWN = ["translate", ...SIZE_PROPERTIES];
18
+ const before = new WeakMap();
19
+ /** "calc(50% + 2px) 4px" as its top-level parts. */
20
+ function axes(value) {
21
+ const parts = [];
22
+ let depth = 0;
23
+ let part = "";
24
+ for (const char of value.trim()) {
25
+ depth += char === "(" ? 1 : char === ")" ? -1 : 0;
26
+ if (/\s/.test(char) && depth === 0) {
27
+ if (part)
28
+ parts.push(part);
29
+ part = "";
30
+ }
31
+ else
32
+ part += char;
33
+ }
34
+ if (part)
35
+ parts.push(part);
36
+ return parts;
37
+ }
38
+ /** The side a translate's % takes a share of: the box `transform-box` names. */
39
+ function percentSide(computed, size) {
40
+ const [a, b] = size === "width" ? ["left", "right"] : ["top", "bottom"];
41
+ const n = (name) => Number.parseFloat(computed.getPropertyValue(name)) || 0;
42
+ const pad = n(`padding-${a}`) + n(`padding-${b}`) + n(`border-${a}-width`) + n(`border-${b}-width`);
43
+ const content = n(size) - (computed.getPropertyValue("box-sizing") === "border-box" ? pad : 0);
44
+ const box = computed.getPropertyValue("transform-box");
45
+ return box === "content-box" || box === "fill-box" ? content : content + pad;
46
+ }
47
+ /** Each % as the px it is now, so a resize drawn with it does not move the element again. */
48
+ function percentAsPx(axis, side) {
49
+ return axis.replace(/(-?\d*\.?\d+(?:e[-+]?\d+)?)%/gi, (_, n) => `${(Number(n) * side) / 100}px`);
50
+ }
51
+ export function computedTranslateAxes(element) {
52
+ const computed = getComputedStyle(element);
53
+ const translate = computed.getPropertyValue("translate");
54
+ if (!translate || translate === "none")
55
+ return [];
56
+ const sides = [percentSide(computed, "width"), percentSide(computed, "height")];
57
+ return axes(translate).map((axis, i) => (i < 2 ? percentAsPx(axis, sides[i]) : axis));
58
+ }
59
+ function beforeOf(element) {
60
+ let saved = before.get(element);
61
+ if (!saved) {
62
+ const { style } = element;
63
+ saved = {
64
+ inline: DRAWN.map((name) => [
65
+ name,
66
+ style.getPropertyValue(name),
67
+ style.getPropertyPriority(name),
68
+ ]),
69
+ translate: computedTranslateAxes(element),
70
+ };
71
+ before.set(element, saved);
72
+ }
73
+ return saved;
74
+ }
75
+ function restore(element, names) {
76
+ for (const [name, value, priority] of before.get(element)?.inline ?? []) {
77
+ if (!names.includes(name))
78
+ continue;
79
+ if (value)
80
+ element.style.setProperty(name, value, priority);
81
+ else
82
+ element.style.removeProperty(name);
83
+ }
84
+ }
85
+ export function movedTranslate([x = "0px", y = "0px", z], offset) {
86
+ return `calc(${x} + ${offset.x}px) calc(${y} + ${offset.y}px)${z ? ` ${z}` : ""}`;
87
+ }
88
+ function drawTranslate(element, offset) {
89
+ element.style.setProperty("translate", movedTranslate(beforeOf(element).translate, offset));
90
+ }
91
+ function drawSize(element, size) {
92
+ beforeOf(element);
93
+ const { style } = element;
94
+ style.setProperty("box-sizing", "border-box");
95
+ style.setProperty("width", `${size.width}px`);
96
+ style.setProperty("height", `${size.height}px`);
97
+ for (const name of ["min-width", "min-height"])
98
+ style.setProperty(name, "0px");
99
+ for (const name of ["max-width", "max-height"])
100
+ style.setProperty(name, "none");
101
+ }
102
+ function apply(element, draft) {
103
+ if ("end" in draft) {
104
+ if (draft.end === "restore")
105
+ restore(element, DRAWN);
106
+ before.delete(element);
107
+ return;
108
+ }
109
+ if (draft.translate)
110
+ drawTranslate(element, draft.translate);
111
+ else
112
+ restore(element, ["translate"]);
113
+ if (draft.size)
114
+ drawSize(element, draft.size);
115
+ else
116
+ restore(element, SIZE_PROPERTIES);
117
+ }
118
+ /** Applies each draft in order; one for an element this load no longer has is skipped. */
119
+ export function drawDrafts(drafts) {
120
+ let drawn = 0;
121
+ for (const draft of drafts) {
122
+ const element = elementForHandle(draft.handle);
123
+ if (!isStylableElement(element))
124
+ continue;
125
+ apply(element, draft);
126
+ drawn++;
127
+ }
128
+ return { drawn };
129
+ }
@@ -46,6 +46,14 @@ export declare function rotationDegreesFromMatrix(matrix: Pick<DOMMatrix, "a" |
46
46
  * then anchored by matching their bounding box to the element's real one. Null when unmeasurable.
47
47
  */
48
48
  export declare function elementCornerPoints(win: Window, element: HTMLElement, { matrix, cs }: ElementTransformSnapshot): EditingCorners | null;
49
+ export declare function boxOf(element: HTMLElement, memo: Map<HTMLElement, DOMMatrix | null>): EditingElementBox;
50
+ export declare const MAX_SNAP_TARGETS = 80;
51
+ /**
52
+ * The elements a moved box can snap to, in document order below `root`: each rendered element
53
+ * outside `exclude`, not a nested composition's host, and not in a subtree that is hidden. Once
54
+ * `max` are found no further subtree is entered; the children of one being walked are all listed.
55
+ */
56
+ export declare function snapCandidates(root: Element, exclude: ReadonlySet<Element>, max?: number): HTMLElement[];
49
57
  /** One entry per handle, null as in `describe`, and the boxes of `children`'s descendants. */
50
58
  export declare function elementGeometry(handles: readonly EditingElementHandle[], children: EditingElementHandle | undefined): {
51
59
  elements: Array<EditingElementGeometry | null>;
@@ -142,7 +142,7 @@ function clipPathOf(element) {
142
142
  const finiteCorners = (corners) => corners && Object.values(corners).every((p) => Number.isFinite(p.x) && Number.isFinite(p.y))
143
143
  ? corners
144
144
  : null;
145
- function boxOf(element, memo) {
145
+ export function boxOf(element, memo) {
146
146
  const transform = readElementTransformSnapshot(window, element, memo);
147
147
  const turned = transform ? rotationDegreesFromMatrix(transform.matrix) : 0;
148
148
  const angle = Math.abs(turned) < ROTATION_GATE_EPSILON_DEG ? 0 : turned;
@@ -155,6 +155,34 @@ function boxOf(element, memo) {
155
155
  clipPath: clipPathOf(element),
156
156
  };
157
157
  }
158
+ export const MAX_SNAP_TARGETS = 80;
159
+ const NOT_SNAPPED = new Set(["script", "style", "link", "meta", "base", "template", "br", "wbr"]);
160
+ /**
161
+ * The elements a moved box can snap to, in document order below `root`: each rendered element
162
+ * outside `exclude`, not a nested composition's host, and not in a subtree that is hidden. Once
163
+ * `max` are found no further subtree is entered; the children of one being walked are all listed.
164
+ */
165
+ export function snapCandidates(root, exclude, max = MAX_SNAP_TARGETS) {
166
+ const found = [];
167
+ const visible = new Map();
168
+ const visit = (parent) => {
169
+ if (found.length >= max)
170
+ return;
171
+ for (const child of Array.from(parent.children)) {
172
+ if (NOT_SNAPPED.has(child.tagName.toLowerCase()))
173
+ continue;
174
+ if (child.hasAttribute("data-composition-id") || exclude.has(child))
175
+ continue;
176
+ const element = child;
177
+ if (!isElementVisibleThroughAncestors(element, visible))
178
+ continue;
179
+ found.push(element);
180
+ visit(element);
181
+ }
182
+ };
183
+ visit(root);
184
+ return found;
185
+ }
158
186
  /** One entry per handle, null as in `describe`, and the boxes of `children`'s descendants. */
159
187
  export function elementGeometry(handles, children) {
160
188
  const memo = new Map();
@@ -0,0 +1,27 @@
1
+ import type { EditingElementHandle } from "./editingElement.js";
2
+ import { type EditingElementBox, type EditingElementGeometry } from "./editingGeometry.js";
3
+ export interface EditingGestureStart extends EditingElementGeometry {
4
+ /** The transform-free border box a resize grows from. */
5
+ layout: {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ /** Frame px its centre moves per px of translate, columns `a, b` (x) and `c, d` (y); null when it does not move measurably. */
10
+ move: {
11
+ a: number;
12
+ b: number;
13
+ c: number;
14
+ d: number;
15
+ } | null;
16
+ /** Set when GSAP owns its position: its x/y now, and whether a tween with a duration moves it. */
17
+ gsap: {
18
+ x: number;
19
+ y: number;
20
+ moving: boolean;
21
+ } | null;
22
+ }
23
+ /** Each handle's gesture start, null as in `describe`, and the snap boxes of the page around them. */
24
+ export declare function gestureStart(handles: readonly EditingElementHandle[]): {
25
+ elements: Array<EditingGestureStart | null>;
26
+ snap: EditingElementBox[];
27
+ };
@@ -0,0 +1,100 @@
1
+ /**
2
+ * What a drag or resize needs from the frame as it starts, in one read for the editing channel: each
3
+ * pressed element's overlay geometry, layout size, how far it moves per px of translate, and GSAP's
4
+ * x/y when GSAP owns its position; and the boxes it can snap to. A parent that cannot script the
5
+ * frame takes these here rather than off the elements.
6
+ */
7
+ import { isStylableElement } from "./domRealm.js";
8
+ import { computedTranslateAxes, movedTranslate } from "./editingDraft.js";
9
+ import { boxOf, elementGeometry, snapCandidates, MAX_SNAP_TARGETS, } from "./editingGeometry.js";
10
+ import { elementForHandle } from "./editingHandles.js";
11
+ const PROBE_PX = 100;
12
+ const MIN_PROBE_RESPONSE = 0.01;
13
+ /**
14
+ * Frame px the element's centre moves per px of translate a draft draws, one column per axis
15
+ * (`a, b` for x, `c, d` for y): every transform above it applied. Null when it has no box or does
16
+ * not move measurably. Its inline translate is put back as it was.
17
+ */
18
+ function measureMoveResponse(element) {
19
+ const { style } = element;
20
+ const value = style.getPropertyValue("translate");
21
+ const priority = style.getPropertyPriority("translate");
22
+ const base = computedTranslateAxes(element);
23
+ const centre = (offset) => {
24
+ style.setProperty("translate", movedTranslate(base, offset));
25
+ const { left, top, width, height } = element.getBoundingClientRect();
26
+ return width > 0 || height > 0 ? { x: left + width / 2, y: top + height / 2 } : null;
27
+ };
28
+ try {
29
+ const origin = centre({ x: 0, y: 0 });
30
+ const alongX = centre({ x: PROBE_PX, y: 0 });
31
+ const alongY = centre({ x: 0, y: PROBE_PX });
32
+ if (!origin || !alongX || !alongY)
33
+ return null;
34
+ const column = (p) => ({
35
+ x: (p.x - origin.x) / PROBE_PX,
36
+ y: (p.y - origin.y) / PROBE_PX,
37
+ });
38
+ const [x, y] = [column(alongX), column(alongY)];
39
+ const usable = (p) => Number.isFinite(p.x) && Number.isFinite(p.y) && Math.hypot(p.x, p.y) >= MIN_PROBE_RESPONSE;
40
+ return usable(x) && usable(y) ? { a: x.x, b: x.y, c: y.x, d: y.y } : null;
41
+ }
42
+ finally {
43
+ if (value)
44
+ style.setProperty("translate", value, priority);
45
+ else
46
+ style.removeProperty("translate");
47
+ }
48
+ }
49
+ // The channels Studio's move route and drag commit read as GSAP moving an element.
50
+ const POSITION = ["x", "y", "xPercent", "yPercent", "left", "top", "translateX", "translateY"];
51
+ const MOVES = [...POSITION, "motionPath"];
52
+ function carries(vars, channels) {
53
+ if (channels.some((channel) => channel in vars))
54
+ return true;
55
+ const keyframes = vars.keyframes;
56
+ if (!keyframes || typeof keyframes !== "object")
57
+ return false;
58
+ const steps = Array.isArray(keyframes) ? keyframes : [keyframes, ...Object.values(keyframes)];
59
+ return steps.some((step) => !!step &&
60
+ typeof step === "object" &&
61
+ channels.some((channel) => Object.prototype.hasOwnProperty.call(step, channel)));
62
+ }
63
+ function tweensOn(element) {
64
+ const timelines = Object.values(window.__timelines ?? {});
65
+ return timelines.flatMap((timeline) => (timeline?.getChildren?.(true) ?? []).filter((tween) => (tween.targets?.() ?? []).some((target) => target === element || (!!element.id && target?.id === element.id))));
66
+ }
67
+ /** GSAP's x/y when it owns the element's position: it renders its transform, or a tween writes it. */
68
+ function gsapPosition(element) {
69
+ const tweens = tweensOn(element).filter((tween) => tween.vars && carries(tween.vars, MOVES));
70
+ const renders = !!element._gsap?.renderTransform;
71
+ if (!renders && !tweens.length)
72
+ return null;
73
+ // Read only now: asking GSAP for x makes it fold a CSS translate into its transform.
74
+ const read = (axis) => Number(window.gsap?.getProperty?.(element, axis)) || 0;
75
+ const moving = tweens.some((tween) => (tween.duration?.() ?? 0) > 0);
76
+ return { x: read("x"), y: read("y"), moving };
77
+ }
78
+ /** Each handle's gesture start, null as in `describe`, and the snap boxes of the page around them. */
79
+ export function gestureStart(handles) {
80
+ const pressed = handles.map(elementForHandle);
81
+ const { elements } = elementGeometry(handles, undefined);
82
+ const starts = elements.map((geometry, i) => {
83
+ const element = pressed[i];
84
+ if (!geometry || !isStylableElement(element))
85
+ return null;
86
+ const { offsetWidth = 0, offsetHeight = 0 } = element;
87
+ return {
88
+ ...geometry,
89
+ layout: { width: offsetWidth, height: offsetHeight },
90
+ move: measureMoveResponse(element),
91
+ gsap: gsapPosition(element),
92
+ };
93
+ });
94
+ const root = document.querySelector("[data-composition-id]") ?? document.documentElement;
95
+ const exclude = new Set(pressed.filter((element) => !!element));
96
+ const memo = new Map();
97
+ const candidates = snapCandidates(root, exclude).slice(0, MAX_SNAP_TARGETS);
98
+ const snap = candidates.map((element) => boxOf(element, memo));
99
+ return { elements: starts, snap };
100
+ }
@@ -4,6 +4,7 @@
4
4
  * the maps are module state, and an entry goes once its element is garbage-collected.
5
5
  */
6
6
  import { type EditingElementDescription, type EditingElementHandle, type EditingElementHit, type EditingElementMatch } from "./editingElement.js";
7
+ export declare function handleFor(element: Element): EditingElementHandle;
7
8
  /** The live element in this document behind `handle`, else null. */
8
9
  export declare function elementForHandle(handle: EditingElementHandle): Element | null;
9
10
  /** How many elements hold a live entry; for tests of the bound. */
@@ -15,7 +15,7 @@ const collected = new FinalizationRegistry((n) => {
15
15
  elements.delete(n);
16
16
  });
17
17
  let lastNumber = 0;
18
- function handleFor(element) {
18
+ export function handleFor(element) {
19
19
  let n = numbers.get(element);
20
20
  if (n === undefined) {
21
21
  n = ++lastNumber;
@@ -0,0 +1,24 @@
1
+ import { type EditingElementHandle } from "./editingElement.js";
2
+ export type LayerKind = "image" | "video" | "audio" | "vector" | "group" | "text" | "shape";
3
+ export interface EditingLayer {
4
+ handle: EditingElementHandle;
5
+ depth: number;
6
+ childCount: number;
7
+ zIndex: number;
8
+ kind: LayerKind;
9
+ }
10
+ export declare function isCompositionHost(el: Element): boolean;
11
+ export declare function hasOnlyFormattingChildren(element: HTMLElement): boolean;
12
+ /** What a Layers row tells a person an element is: its media tag, a group, text, or else a shape. */
13
+ export declare function layerKindOf(el: Element, hasChildren: boolean): LayerKind;
14
+ /** The inline `z-index`, else the computed one; 0 for `auto` or none. */
15
+ export declare function elementZIndex(element: HTMLElement): number;
16
+ /**
17
+ * `layers`: the composition's layers, or the drilled-into group's when `group` names one, from the
18
+ * `offset`th on. A `group` this page no longer has lists nothing, so Studio can leave the drill-in.
19
+ */
20
+ export declare function layersOf(group?: EditingElementHandle, offset?: number): {
21
+ layers: EditingLayer[];
22
+ truncated: boolean;
23
+ missingGroup: boolean;
24
+ };
@@ -0,0 +1,102 @@
1
+ /** The Layers walk `layers` answers; Studio walks a frame it scripts by the same rules. */
2
+ import { isRichTextFormattingTag } from "../utils/richTextSanitize.js";
3
+ import { isClipHiddenByRuntime } from "../studioPreviewMark.js";
4
+ import { MAX_QUERY_MATCHES } from "./editingElement.js";
5
+ import { elementForHandle, handleFor } from "./editingHandles.js";
6
+ import { isDomLayerElement } from "./editingTargets.js";
7
+ import { isElementNode } from "./domRealm.js";
8
+ export function isCompositionHost(el) {
9
+ return el.hasAttribute("data-composition-src") || el.hasAttribute("data-composition-file");
10
+ }
11
+ export function hasOnlyFormattingChildren(element) {
12
+ for (const child of Array.from(element.children)) {
13
+ if (!isRichTextFormattingTag(child.tagName))
14
+ return false;
15
+ if (child.namespaceURI !== "http://www.w3.org/1999/xhtml")
16
+ return false;
17
+ // Formatting nests, and a structural child hidden inside a span is still structural.
18
+ if (!hasOnlyFormattingChildren(child))
19
+ return false;
20
+ }
21
+ return true;
22
+ }
23
+ /** What a Layers row tells a person an element is: its media tag, a group, text, or else a shape. */
24
+ export function layerKindOf(el, hasChildren) {
25
+ const tag = el.tagName.toLowerCase();
26
+ if (tag === "img" || tag === "picture")
27
+ return "image";
28
+ if (tag === "video")
29
+ return "video";
30
+ if (tag === "audio")
31
+ return "audio";
32
+ if (tag === "svg")
33
+ return "vector";
34
+ if (el.hasAttribute("data-hf-group") || isCompositionHost(el))
35
+ return "group";
36
+ if (hasOnlyFormattingChildren(el) && el.textContent?.trim())
37
+ return "text";
38
+ return hasChildren ? "group" : "shape";
39
+ }
40
+ /** The inline `z-index`, else the computed one; 0 for `auto` or none. */
41
+ export function elementZIndex(element) {
42
+ const inline = element.style?.zIndex;
43
+ if (inline && inline !== "auto") {
44
+ const parsed = parseInt(inline, 10);
45
+ if (Number.isFinite(parsed))
46
+ return parsed;
47
+ }
48
+ const value = element.ownerDocument?.defaultView?.getComputedStyle(element).zIndex;
49
+ if (!value || value === "auto")
50
+ return 0;
51
+ const parsed = parseInt(value, 10);
52
+ return Number.isFinite(parsed) ? parsed : 0;
53
+ }
54
+ const layerChildren = (el) => Array.from(el.children).filter((child) => isElementNode(child) && isDomLayerElement(child)).length;
55
+ /** Every layer under `roots`, in document order, with its depth among layers. */
56
+ function walkLayers(roots, max = Number.POSITIVE_INFINITY) {
57
+ const layers = [];
58
+ let truncated = false;
59
+ const visit = (el, depth) => {
60
+ if (truncated || isClipHiddenByRuntime(el))
61
+ return;
62
+ const layer = isDomLayerElement(el);
63
+ if (layer) {
64
+ if (layers.length === max) {
65
+ truncated = true;
66
+ return;
67
+ }
68
+ layers.push({ element: el, depth, childCount: layerChildren(el) });
69
+ }
70
+ for (const child of Array.from(el.children)) {
71
+ if (isElementNode(child))
72
+ visit(child, layer ? depth + 1 : depth);
73
+ }
74
+ };
75
+ for (const root of roots)
76
+ if (isElementNode(root))
77
+ visit(root, 0);
78
+ return { layers, truncated };
79
+ }
80
+ /**
81
+ * `layers`: the composition's layers, or the drilled-into group's when `group` names one, from the
82
+ * `offset`th on. A `group` this page no longer has lists nothing, so Studio can leave the drill-in.
83
+ */
84
+ export function layersOf(group, offset = 0) {
85
+ const scope = group ? elementForHandle(group) : null;
86
+ if (group && !scope)
87
+ return { layers: [], truncated: false, missingGroup: true };
88
+ const root = document.querySelector("[data-composition-id]") ?? document.documentElement;
89
+ const roots = scope ? Array.from(scope.children) : root ? [root] : [];
90
+ const walk = walkLayers(roots, offset + MAX_QUERY_MATCHES);
91
+ return {
92
+ truncated: walk.truncated,
93
+ missingGroup: false,
94
+ layers: walk.layers.slice(offset).map(({ element, depth, childCount }) => ({
95
+ handle: handleFor(element),
96
+ depth,
97
+ childCount,
98
+ zIndex: elementZIndex(element),
99
+ kind: layerKindOf(element, childCount > 0),
100
+ })),
101
+ };
102
+ }
@@ -11,17 +11,21 @@
11
11
  */
12
12
  import { type EditingElementDescription, type EditingElementHandle, type EditingElementHit, type EditingElementMatch } from "./editingElement.js";
13
13
  import type { EditingElementBox, EditingElementGeometry } from "./editingGeometry.js";
14
+ import type { EditingGestureStart } from "./editingGestureStart.js";
15
+ import type { EditingLayer } from "./editingLayers.js";
14
16
  import type { RuntimeTimelineMessage } from "./types.js";
15
17
  export { buildStableSelector, escapeCssString, getPreferredClassSelector, readElementSource, EDITING_ELEMENT_HANDLE, MAX_DESCRIBE_HANDLES, MAX_ELEMENT_ENTRIES, MAX_ELEMENT_TEXT, MAX_ELEMENT_VALUE, MAX_POINT_STACK, MAX_QUERY_MATCHES, MAX_SOURCE_GROUPS, type EditingElementDescription, type EditingElementHandle, type EditingElementHit, type EditingElementMatch, type EditingElementSource, type EditingRect, } from "./editingElement.js";
16
- export { elementCornerPoints, isElementVisibleThroughAncestors, readElementTransformSnapshot, rotationDegreesFromMatrix, MAX_GEOMETRY_CHILDREN, ROTATION_GATE_EPSILON_DEG, type EditingCorner, type EditingCorners, type EditingElementBox, type EditingElementGeometry, type ElementTransformSnapshot, } from "./editingGeometry.js";
18
+ 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";
19
+ export type { EditingGestureStart } from "./editingGestureStart.js";
17
20
  export { compositionPoint, coversComposition, isDomLayerElement, isInspectableLayerElement, pointerTarget, pointerTargets, resolveAllVisualDomEditTargets, resolveLayerSelector, type EditingLocalPointer, type EditingViewport, } from "./editingTargets.js";
21
+ export { elementZIndex, hasOnlyFormattingChildren, isCompositionHost, layerKindOf, type EditingLayer, type LayerKind, } from "./editingLayers.js";
18
22
  export { composeElementTransform, individualRotateDegrees, type PlanarTransformOps, } from "./elementTransform.js";
19
23
  export declare const EDITING_PROTOCOL_VERSION: 1;
20
24
  /** Parent to frame, on the window: asks the runtime for the port. */
21
25
  export declare const EDITING_CONNECT = "editing-connect";
22
26
  /** Frame to parent, on the window: carries the port in its transfer list. */
23
27
  export declare const EDITING_PORT = "editing-port";
24
- export declare const EDITING_REQUEST_KINDS: readonly ["hello", "runtime-snapshot", "wait-for-seek", "set-loop-start", "computed-styles", "elements-at-point", "pointer-targets", "describe", "ancestors", "query", "geometry"];
28
+ export declare const EDITING_REQUEST_KINDS: readonly ["hello", "runtime-snapshot", "wait-for-seek", "set-loop-start", "computed-styles", "elements-at-point", "pointer-targets", "describe", "ancestors", "query", "geometry", "layers", "draft", "gesture-start"];
25
29
  export type EditingRequestKind = (typeof EDITING_REQUEST_KINDS)[number];
26
30
  export interface EditingRuntimeSnapshot {
27
31
  /** The runtime has installed its player API. */
@@ -33,6 +37,22 @@ export interface EditingRuntimeSnapshot {
33
37
  /** `[childId, parentId]` for each nested clip in the runtime's clip tree. */
34
38
  clipParents: Array<[string, string]>;
35
39
  }
40
+ export declare const MAX_DRAFT_PX = 100000;
41
+ /** A gesture's draft on one element: null puts that part back; `end` keeps what is drawn or restores. */
42
+ export type EditingDraft = {
43
+ handle: EditingElementHandle;
44
+ translate: {
45
+ x: number;
46
+ y: number;
47
+ } | null;
48
+ size: {
49
+ width: number;
50
+ height: number;
51
+ } | null;
52
+ } | {
53
+ handle: EditingElementHandle;
54
+ end: "keep" | "restore";
55
+ };
36
56
  type NoParams = Record<string, never>;
37
57
  export interface EditingRequests {
38
58
  hello: {
@@ -135,6 +155,37 @@ export interface EditingRequests {
135
155
  children: EditingElementBox[] | null;
136
156
  };
137
157
  };
158
+ /** The Layers walk from `offset`, MAX_QUERY_MATCHES at a time, scoped to a drilled-into `group`;
159
+ * `missingGroup` says this page has no such group, and lists nothing. */
160
+ layers: {
161
+ params: {
162
+ group?: EditingElementHandle;
163
+ offset?: number;
164
+ };
165
+ result: {
166
+ layers: EditingLayer[];
167
+ truncated: boolean;
168
+ missingGroup: boolean;
169
+ };
170
+ };
171
+ /** Gesture drafts in order, up to MAX_DESCRIBE_HANDLES; `drawn` counts the elements still here. */
172
+ draft: {
173
+ params: {
174
+ drafts: EditingDraft[];
175
+ };
176
+ result: {
177
+ drawn: number;
178
+ };
179
+ };
180
+ "gesture-start": {
181
+ params: {
182
+ handles: EditingElementHandle[];
183
+ };
184
+ result: {
185
+ elements: Array<EditingGestureStart | null>;
186
+ snap: EditingElementBox[];
187
+ };
188
+ };
138
189
  }
139
190
  export type EditingParams<K extends EditingRequestKind> = EditingRequests[K]["params"];
140
191
  export type EditingResult<K extends EditingRequestKind> = EditingRequests[K]["result"];