@hyperframes/core 0.9.63 → 0.9.65
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/compiler/compositionScoping.d.ts +2 -0
- package/dist/compiler/compositionScoping.js +36 -7
- package/dist/compiler/inlineSubCompositions.d.ts +5 -0
- package/dist/compiler/inlineSubCompositions.js +14 -8
- package/dist/figma/bindings.js +7 -6
- package/dist/figma/index.d.ts +2 -1
- package/dist/figma/index.js +2 -1
- package/dist/figma/manifest.d.ts +2 -0
- package/dist/figma/manifest.js +13 -4
- package/dist/figma/mediaIndex.d.ts +2 -3
- package/dist/figma/mediaIndex.js +15 -17
- package/dist/figma/projectFiles.d.ts +16 -0
- package/dist/figma/projectFiles.js +81 -0
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/runtime/bridge.d.ts +2 -0
- package/dist/runtime/bridge.js +22 -0
- package/dist/runtime/editing/gsapSnapshot.d.ts +43 -0
- package/dist/runtime/editing/gsapSnapshot.js +169 -0
- package/dist/runtime/editing/gsapSnapshotLimits.d.ts +6 -0
- package/dist/runtime/editing/gsapSnapshotLimits.js +6 -0
- package/dist/runtime/editing/motionPathHome.d.ts +19 -0
- package/dist/runtime/editing/motionPathHome.js +85 -0
- package/dist/runtime/editingPort.d.ts +15 -1
- package/dist/runtime/editingPort.js +8 -0
- package/dist/runtime/types.d.ts +4 -2
- package/dist/studioPreviewMark.d.ts +8 -0
- package/dist/studioPreviewMark.js +33 -0
- package/package.json +4 -4
package/dist/runtime/bridge.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PreviewTarget } from "../studioPreviewMark.js";
|
|
1
2
|
import type { HfColorGradingTarget } from "../colorGrading.js";
|
|
2
3
|
import type { RuntimeOutboundMessage } from "./types.js";
|
|
3
4
|
type BridgeDeps = {
|
|
@@ -26,6 +27,7 @@ type BridgeDeps = {
|
|
|
26
27
|
onSetCopiesAhead?: (on: boolean) => void;
|
|
27
28
|
onRetryPreviewCopies?: () => void;
|
|
28
29
|
onRequestPreviewFacts?: () => void;
|
|
30
|
+
onScrubAudio?: (target: PreviewTarget | null, time: number | null, volume: number) => void;
|
|
29
31
|
getCanonicalFps: () => number;
|
|
30
32
|
};
|
|
31
33
|
export declare function setRuntimeProtocolFps(fps: number): void;
|
package/dist/runtime/bridge.js
CHANGED
|
@@ -66,6 +66,27 @@ function isGradingTarget(value) {
|
|
|
66
66
|
isOptionalBoundedString(target.selector) &&
|
|
67
67
|
(target.selectorIndex == null || isFiniteNumber(target.selectorIndex)));
|
|
68
68
|
}
|
|
69
|
+
function isScrubTarget(value) {
|
|
70
|
+
if (value === null)
|
|
71
|
+
return true;
|
|
72
|
+
if (typeof value !== "object" || Array.isArray(value))
|
|
73
|
+
return false;
|
|
74
|
+
const target = value;
|
|
75
|
+
return (isBoundedString(target.id) &&
|
|
76
|
+
isOptionalBoundedString(target.hfId) &&
|
|
77
|
+
isOptionalBoundedString(target.domId) &&
|
|
78
|
+
isOptionalBoundedString(target.sourceFile));
|
|
79
|
+
}
|
|
80
|
+
function dispatchScrubAudio(data, deps) {
|
|
81
|
+
const target = data.target ?? null;
|
|
82
|
+
if (!isScrubTarget(target))
|
|
83
|
+
return;
|
|
84
|
+
if (data.time === null)
|
|
85
|
+
return deps.onScrubAudio?.(target, null, 0);
|
|
86
|
+
if (!isFiniteNumber(data.time) || !isFiniteNumber(data.volume))
|
|
87
|
+
return;
|
|
88
|
+
deps.onScrubAudio?.(target, Math.max(0, data.time), Math.max(0, Math.min(1, data.volume)));
|
|
89
|
+
}
|
|
69
90
|
function dispatchColorGrading(target, value, apply) {
|
|
70
91
|
const resolvedTarget = target ?? null;
|
|
71
92
|
if (isGradingTarget(resolvedTarget))
|
|
@@ -129,6 +150,7 @@ const CONTROL_HANDLERS = new Map(Object.entries({
|
|
|
129
150
|
"enable-pick-mode": (_d, deps) => deps.onEnablePickMode(),
|
|
130
151
|
"disable-pick-mode": (_d, deps) => deps.onDisablePickMode(),
|
|
131
152
|
"flash-elements": (data) => handleFlashElements(data),
|
|
153
|
+
"scrub-audio": dispatchScrubAudio,
|
|
132
154
|
"set-runtime-data": (data, deps) => {
|
|
133
155
|
if (typeof data.channel === "string")
|
|
134
156
|
deps.onSetRuntimeData?.(data.channel, data.payload, data.requestId);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { EditingElementHandle } from "../editingElement.js";
|
|
2
|
+
export type SnapshotValue = number | string | boolean | null | SnapshotValue[] | {
|
|
3
|
+
[key: string]: SnapshotValue;
|
|
4
|
+
};
|
|
5
|
+
export interface GsapSnapshotTween {
|
|
6
|
+
targets: EditingElementHandle[];
|
|
7
|
+
/** The tween's vars; functions, elements and other live objects are left out. */
|
|
8
|
+
vars: Record<string, SnapshotValue>;
|
|
9
|
+
start: number;
|
|
10
|
+
duration: number;
|
|
11
|
+
from: boolean;
|
|
12
|
+
initted: boolean;
|
|
13
|
+
/** GSAP's parse of each channel: start `s` and change `c`. */
|
|
14
|
+
parsed: Array<{
|
|
15
|
+
p: string;
|
|
16
|
+
s: number;
|
|
17
|
+
c: number;
|
|
18
|
+
}>;
|
|
19
|
+
/** A keyframed tween's steps, timed within the tween. */
|
|
20
|
+
parts: GsapSnapshotTween[];
|
|
21
|
+
}
|
|
22
|
+
export interface GsapSnapshotTimeline {
|
|
23
|
+
id: string;
|
|
24
|
+
time: number | null;
|
|
25
|
+
defaultEase: string | null;
|
|
26
|
+
tweens: GsapSnapshotTween[];
|
|
27
|
+
}
|
|
28
|
+
export interface GsapSnapshotTarget {
|
|
29
|
+
handle: EditingElementHandle;
|
|
30
|
+
id: string;
|
|
31
|
+
className: string;
|
|
32
|
+
/** GSAP's current value of each channel a tween animates, and of x and y. */
|
|
33
|
+
values: Record<string, number>;
|
|
34
|
+
}
|
|
35
|
+
export interface GsapSnapshot {
|
|
36
|
+
/** The player's time when read; null without a player. */
|
|
37
|
+
time: number | null;
|
|
38
|
+
defaultEase: string | null;
|
|
39
|
+
timelines: GsapSnapshotTimeline[];
|
|
40
|
+
targets: GsapSnapshotTarget[];
|
|
41
|
+
}
|
|
42
|
+
/** Every tween on the frame's timelines, after any seek in flight has painted. Throws past a bound. */
|
|
43
|
+
export declare function gsapSnapshot(): Promise<GsapSnapshot>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { handleFor } from "../editingHandles.js";
|
|
2
|
+
import { isPlainRecord } from "../editingPort.js";
|
|
3
|
+
import { isElementNode } from "../domRealm.js";
|
|
4
|
+
import { MAX_SNAPSHOT_CHANNELS, MAX_SNAPSHOT_FIELDS, MAX_SNAPSHOT_TARGETS, MAX_SNAPSHOT_TEXT, MAX_SNAPSHOT_TWEENS, MAX_VARS_DEPTH, } from "./gsapSnapshotLimits.js";
|
|
5
|
+
const VARS_SKIP = new Set([
|
|
6
|
+
"ease",
|
|
7
|
+
"easeEach",
|
|
8
|
+
"duration",
|
|
9
|
+
"delay",
|
|
10
|
+
"stagger",
|
|
11
|
+
"overwrite",
|
|
12
|
+
"data",
|
|
13
|
+
"id",
|
|
14
|
+
]);
|
|
15
|
+
class SnapshotBound extends Error {
|
|
16
|
+
constructor(what) {
|
|
17
|
+
super(`the preview's GSAP state is past the snapshot bound on ${what}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Every text the snapshot carries, keys and ids included, is held to the text bound. */
|
|
21
|
+
function capped(value) {
|
|
22
|
+
if (value.length > MAX_SNAPSHOT_TEXT)
|
|
23
|
+
throw new SnapshotBound("text length");
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
const text = (value) => (typeof value === "string" ? capped(value) : null);
|
|
27
|
+
const finite = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
28
|
+
/** Every tween on the frame's timelines, after any seek in flight has painted. Throws past a bound. */
|
|
29
|
+
export async function gsapSnapshot() {
|
|
30
|
+
const frame = window;
|
|
31
|
+
await frame.__hfWaitForSeekCompletion?.();
|
|
32
|
+
const gsap = frame.gsap;
|
|
33
|
+
const reader = new SnapshotReader();
|
|
34
|
+
const timelines = [];
|
|
35
|
+
for (const [id, live] of Object.entries(frame.__timelines ?? {})) {
|
|
36
|
+
if (typeof live?.getChildren !== "function")
|
|
37
|
+
continue;
|
|
38
|
+
const tweens = live.getChildren(true).filter((child) => typeof child.targets === "function");
|
|
39
|
+
if (timelines.length >= MAX_SNAPSHOT_TWEENS)
|
|
40
|
+
throw new SnapshotBound("timelines");
|
|
41
|
+
timelines.push({
|
|
42
|
+
id: capped(id),
|
|
43
|
+
time: typeof live.time === "function" ? finite(live.time()) : null,
|
|
44
|
+
defaultEase: text(live.vars?.defaults?.ease),
|
|
45
|
+
tweens: tweens.map((tween) => reader.tween(tween)),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const time = frame.__player?.getTime?.();
|
|
49
|
+
return {
|
|
50
|
+
time: typeof time === "number" && Number.isFinite(time) ? time : null,
|
|
51
|
+
defaultEase: text(gsap?.defaults?.().ease),
|
|
52
|
+
timelines,
|
|
53
|
+
targets: reader.targets(gsap),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
class SnapshotReader {
|
|
57
|
+
tweens = 0;
|
|
58
|
+
fields = 0;
|
|
59
|
+
channels = new Map();
|
|
60
|
+
tween(live) {
|
|
61
|
+
if (++this.tweens > MAX_SNAPSHOT_TWEENS)
|
|
62
|
+
throw new SnapshotBound("tweens");
|
|
63
|
+
const elements = (live.targets?.() ?? []).filter(isElementNode);
|
|
64
|
+
const vars = this.plain(live.vars, 0);
|
|
65
|
+
const parsed = parsedChannels(live._pt);
|
|
66
|
+
const parts = (live.timeline?.getChildren?.() ?? []).map((part) => this.tween(part));
|
|
67
|
+
for (const element of elements)
|
|
68
|
+
this.note(element, vars, parsed, parts);
|
|
69
|
+
const record = isPlainRecord(vars) ? vars : {};
|
|
70
|
+
return { targets: elements.map(handleFor), vars: record, ...timing(live), parsed, parts };
|
|
71
|
+
}
|
|
72
|
+
targets(gsap) {
|
|
73
|
+
if (this.channels.size > MAX_SNAPSHOT_TARGETS)
|
|
74
|
+
throw new SnapshotBound("targets");
|
|
75
|
+
return [...this.channels].map(([element, channels]) => {
|
|
76
|
+
if (channels.size > MAX_SNAPSHOT_CHANNELS)
|
|
77
|
+
throw new SnapshotBound("channels");
|
|
78
|
+
const values = {};
|
|
79
|
+
for (const channel of channels) {
|
|
80
|
+
const value = Number(gsap?.getProperty?.(element, channel));
|
|
81
|
+
if (Number.isFinite(value))
|
|
82
|
+
values[channel] = value;
|
|
83
|
+
}
|
|
84
|
+
const className = element.getAttribute("class") ?? "";
|
|
85
|
+
if (className.length > MAX_SNAPSHOT_TEXT)
|
|
86
|
+
throw new SnapshotBound("class names");
|
|
87
|
+
return { handle: handleFor(element), id: capped(element.id), className, values };
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
note(element, vars, parsed, parts) {
|
|
91
|
+
const channels = this.channels.get(element) ?? new Set(["x", "y"]);
|
|
92
|
+
this.channels.set(element, channels);
|
|
93
|
+
const steps = isPlainRecord(vars) ? [vars, ...stepsOf(vars.keyframes)] : [];
|
|
94
|
+
for (const step of steps)
|
|
95
|
+
for (const [key, value] of Object.entries(step))
|
|
96
|
+
if (!VARS_SKIP.has(key) && isChannelValue(value))
|
|
97
|
+
channels.add(key);
|
|
98
|
+
for (const { p } of [...parsed, ...parts.flatMap((part) => part.parsed)])
|
|
99
|
+
channels.add(p);
|
|
100
|
+
}
|
|
101
|
+
plain(value, depth) {
|
|
102
|
+
if (++this.fields > MAX_SNAPSHOT_FIELDS)
|
|
103
|
+
throw new SnapshotBound("tween fields");
|
|
104
|
+
if (Array.isArray(value))
|
|
105
|
+
return this.list(value, depth);
|
|
106
|
+
if (isLiteralRecord(value))
|
|
107
|
+
return this.record(value, depth);
|
|
108
|
+
return scalar(value);
|
|
109
|
+
}
|
|
110
|
+
list(value, depth) {
|
|
111
|
+
nested(depth);
|
|
112
|
+
return value.map((item) => this.plain(item, depth + 1) ?? null);
|
|
113
|
+
}
|
|
114
|
+
record(value, depth) {
|
|
115
|
+
nested(depth);
|
|
116
|
+
const out = {};
|
|
117
|
+
for (const [key, item] of Object.entries(value)) {
|
|
118
|
+
const kept = this.plain(item, depth + 1);
|
|
119
|
+
if (kept !== undefined)
|
|
120
|
+
out[capped(key)] = kept;
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function timing(live) {
|
|
126
|
+
return {
|
|
127
|
+
start: finite(live.startTime?.()),
|
|
128
|
+
duration: finite(live.duration?.()),
|
|
129
|
+
from: Boolean(live._from),
|
|
130
|
+
initted: Boolean(live._initted),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// GSAP puts live objects on a tween's vars (`parent` is its timeline), and they reach the whole graph.
|
|
134
|
+
const isLiteralRecord = (value) => isPlainRecord(value) && [Object.prototype, null].includes(Object.getPrototypeOf(value));
|
|
135
|
+
function nested(depth) {
|
|
136
|
+
if (depth >= MAX_VARS_DEPTH)
|
|
137
|
+
throw new SnapshotBound("nesting");
|
|
138
|
+
}
|
|
139
|
+
/** A value kept as is; functions, elements and other live objects are left out. */
|
|
140
|
+
function scalar(value) {
|
|
141
|
+
if (typeof value === "number")
|
|
142
|
+
return Number.isFinite(value) ? value : undefined;
|
|
143
|
+
if (typeof value !== "string")
|
|
144
|
+
return typeof value === "boolean" || value === null ? value : undefined;
|
|
145
|
+
return capped(value);
|
|
146
|
+
}
|
|
147
|
+
/** A step's value, or an object-of-arrays keyframe's list of them. */
|
|
148
|
+
const isChannelValue = (value) => typeof value === "number" || typeof value === "string" || Array.isArray(value);
|
|
149
|
+
/** Keyframe steps in any of GSAP's forms; an object of arrays is its own one step. */
|
|
150
|
+
function stepsOf(keyframes) {
|
|
151
|
+
if (Array.isArray(keyframes))
|
|
152
|
+
return keyframes.filter(isPlainRecord);
|
|
153
|
+
if (!isPlainRecord(keyframes))
|
|
154
|
+
return [];
|
|
155
|
+
return [keyframes, ...Object.values(keyframes).filter(isPlainRecord)];
|
|
156
|
+
}
|
|
157
|
+
/** The tween's property tweens, CSSPlugin's nested ones included, in chain order; a node seen before ends a chain. */
|
|
158
|
+
function parsedChannels(first, seen = new Set()) {
|
|
159
|
+
const out = [];
|
|
160
|
+
for (let node = first; node && !seen.has(node); node = node._next) {
|
|
161
|
+
seen.add(node);
|
|
162
|
+
if (typeof node.p === "string" && typeof node.s === "number" && typeof node.c === "number")
|
|
163
|
+
out.push({ p: capped(node.p), s: node.s, c: node.c });
|
|
164
|
+
out.push(...parsedChannels(node.d?._pt, seen));
|
|
165
|
+
if (out.length > MAX_SNAPSHOT_CHANNELS)
|
|
166
|
+
throw new SnapshotBound("parsed channels");
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const MAX_SNAPSHOT_TWEENS = 2048;
|
|
2
|
+
export declare const MAX_SNAPSHOT_TARGETS = 512;
|
|
3
|
+
export declare const MAX_SNAPSHOT_CHANNELS = 64;
|
|
4
|
+
export declare const MAX_SNAPSHOT_FIELDS = 100000;
|
|
5
|
+
export declare const MAX_SNAPSHOT_TEXT = 4096;
|
|
6
|
+
export declare const MAX_VARS_DEPTH = 6;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The layer's centre with no animation, its size, and how far its centre moves per px it grows. */
|
|
2
|
+
export type MotionPathHome = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
ax: number;
|
|
8
|
+
ay: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function elementHome(el: HTMLElement): MotionPathHome;
|
|
11
|
+
export declare function transformWDivisor(el: HTMLElement): number;
|
|
12
|
+
export interface MotionPathFrameHome {
|
|
13
|
+
home: MotionPathHome | null;
|
|
14
|
+
/** 1/m44 of the element's own transform: how much a depth element magnifies its path. */
|
|
15
|
+
perspective: number;
|
|
16
|
+
visible: boolean;
|
|
17
|
+
plugin: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function motionPathHome(selector: string): MotionPathFrameHome;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isHtmlElement } from "../domRealm.js";
|
|
2
|
+
import { isElementVisibleThroughAncestors } from "../editingGeometry.js";
|
|
3
|
+
const computedTransform = (el) => el.ownerDocument?.defaultView?.getComputedStyle(el).transform ?? "none";
|
|
4
|
+
function matrixTranslate(transform) {
|
|
5
|
+
const match = /(matrix3d|matrix)\(([^)]+)\)/.exec(transform);
|
|
6
|
+
const values = match?.[2]?.split(",") ?? [];
|
|
7
|
+
return match?.[1] === "matrix3d" ? [values[12], values[13]] : [values[4], values[5]];
|
|
8
|
+
}
|
|
9
|
+
function transformTranslate(el) {
|
|
10
|
+
const [x, y] = matrixTranslate(computedTransform(el));
|
|
11
|
+
return { x: Number(x) || 0, y: Number(y) || 0 };
|
|
12
|
+
}
|
|
13
|
+
function cssTranslate(el) {
|
|
14
|
+
const raw = el.ownerDocument?.defaultView?.getComputedStyle(el).translate ?? "none";
|
|
15
|
+
const [x = "0", y = "0"] = raw === "none" ? [] : raw.split(" ");
|
|
16
|
+
const px = (v, size) => v.endsWith("%") ? (Number.parseFloat(v) / 100) * size : Number.parseFloat(v) || 0;
|
|
17
|
+
return [px(x, el.offsetWidth), px(y, el.offsetHeight)];
|
|
18
|
+
}
|
|
19
|
+
/** Centre shift per px grown: 0.5 from a set left/top, -0.5 from a set right/bottom, plus the percent.
|
|
20
|
+
* ponytail: in-flow layers get 0 (layout may centre them); read their anchor if one draws off. */
|
|
21
|
+
function growShares(el, px, py) {
|
|
22
|
+
const style = el.ownerDocument?.defaultView?.getComputedStyle(el);
|
|
23
|
+
if (!style || !/^(absolute|fixed)$/.test(style.position))
|
|
24
|
+
return { ax: 0, ay: 0 };
|
|
25
|
+
const map = el.computedStyleMap?.();
|
|
26
|
+
const auto = (side) => String(map?.get(side) ?? "") === "auto";
|
|
27
|
+
const share = (start, end) => (auto(start) && !auto(end) ? -0.5 : 0.5);
|
|
28
|
+
return { ax: share("left", "right") + px, ay: share("top", "bottom") + py };
|
|
29
|
+
}
|
|
30
|
+
export function elementHome(el) {
|
|
31
|
+
let left = 0;
|
|
32
|
+
let top = 0;
|
|
33
|
+
let node = el;
|
|
34
|
+
while (node) {
|
|
35
|
+
left += node.offsetLeft;
|
|
36
|
+
top += node.offsetTop;
|
|
37
|
+
// Ancestor transforms (a group wrapper GSAP moved) shift where the layer renders; its own
|
|
38
|
+
// transform is the animated offset the path itself draws, so it is left out.
|
|
39
|
+
if (node !== el) {
|
|
40
|
+
const t = transformTranslate(node);
|
|
41
|
+
left += t.x;
|
|
42
|
+
top += t.y;
|
|
43
|
+
}
|
|
44
|
+
const parent = node.offsetParent;
|
|
45
|
+
if (!parent || parent.hasAttribute("data-composition-id"))
|
|
46
|
+
break;
|
|
47
|
+
node = parent;
|
|
48
|
+
}
|
|
49
|
+
// A translate composes once GSAP has parsed the layer; before, its parse sums translate and transform,
|
|
50
|
+
// makes minus half the size xPercent -50 and folds the rest into x, which a path sets (_parseTransform).
|
|
51
|
+
const cache = el._gsap;
|
|
52
|
+
const parsed = cache !== undefined && "x" in cache && !cache.uncache;
|
|
53
|
+
const [tx, ty] = cssTranslate(el);
|
|
54
|
+
const share = (cached, t, size) => parsed ? (Number(cached) || 0) / 100 : t && Math.round(size / 2) === Math.round(-t) ? -0.5 : 0;
|
|
55
|
+
const own = parsed ? { x: 0, y: 0 } : transformTranslate(el);
|
|
56
|
+
const [px, py] = [
|
|
57
|
+
share(cache?.xPercent, tx + own.x, el.offsetWidth),
|
|
58
|
+
share(cache?.yPercent, ty + own.y, el.offsetHeight),
|
|
59
|
+
];
|
|
60
|
+
const x = left + el.offsetWidth * (0.5 + px) + (parsed ? tx : 0);
|
|
61
|
+
const y = top + el.offsetHeight * (0.5 + py) + (parsed ? ty : 0);
|
|
62
|
+
const { ax, ay } = growShares(el, px, py);
|
|
63
|
+
return { x, y, w: el.offsetWidth, h: el.offsetHeight, ax, ay };
|
|
64
|
+
}
|
|
65
|
+
// A depth element (matrix3d m44) renders 1/m44 larger, so its path's offsets travel 1/m44 further on screen.
|
|
66
|
+
export function transformWDivisor(el) {
|
|
67
|
+
const t = el.ownerDocument?.defaultView?.getComputedStyle(el).transform;
|
|
68
|
+
if (!t || !t.startsWith("matrix3d("))
|
|
69
|
+
return 1;
|
|
70
|
+
const v = t.slice("matrix3d(".length, -1).split(",");
|
|
71
|
+
const w = Number.parseFloat(v[15] ?? "");
|
|
72
|
+
return Number.isFinite(w) && w > 0 ? w : 1;
|
|
73
|
+
}
|
|
74
|
+
export function motionPathHome(selector) {
|
|
75
|
+
const plugin = Boolean(window.MotionPathPlugin);
|
|
76
|
+
const element = document.querySelector(selector);
|
|
77
|
+
if (!isHtmlElement(element))
|
|
78
|
+
return { home: null, perspective: 1, visible: true, plugin };
|
|
79
|
+
return {
|
|
80
|
+
home: elementHome(element),
|
|
81
|
+
perspective: 1 / transformWDivisor(element),
|
|
82
|
+
visible: isElementVisibleThroughAncestors(element),
|
|
83
|
+
plugin,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -14,6 +14,8 @@ import { type EditingGeometryEvent, type WatchGeometryParams } from "./editing/w
|
|
|
14
14
|
import { type EditingElementDescription, type EditingElementHandle, type EditingElementHit, type EditingElementMatch } from "./editingElement.js";
|
|
15
15
|
import type { EditingElementBox, EditingElementGeometry } from "./editingGeometry.js";
|
|
16
16
|
import type { EditingGestureStart } from "./editingGestureStart.js";
|
|
17
|
+
import type { GsapSnapshot } from "./editing/gsapSnapshot.js";
|
|
18
|
+
import type { MotionPathFrameHome } from "./editing/motionPathHome.js";
|
|
17
19
|
import type { EditingLayer } from "./editingLayers.js";
|
|
18
20
|
import type { RuntimeTimelineMessage } from "./types.js";
|
|
19
21
|
import { type CaptionWordBox, type CaptionWordsParams } from "./editing/captionWords.js";
|
|
@@ -28,6 +30,7 @@ export { buildStableSelector, escapeCssString, getPreferredClassSelector, readEl
|
|
|
28
30
|
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";
|
|
29
31
|
export type { EditingGestureStart } from "./editingGestureStart.js";
|
|
30
32
|
export { MAX_CAPTION_TRANSFORM } from "./editing/captionTransform.js";
|
|
33
|
+
export { MAX_SNAPSHOT_CHANNELS, MAX_SNAPSHOT_FIELDS, MAX_SNAPSHOT_TARGETS, MAX_SNAPSHOT_TEXT, MAX_SNAPSHOT_TWEENS, MAX_VARS_DEPTH, } from "./editing/gsapSnapshotLimits.js";
|
|
31
34
|
export { compositionPoint, coversComposition, isDomLayerElement, isInspectableLayerElement, pointerTarget, pointerTargets, resolveAllVisualDomEditTargets, resolveLayerSelector, type EditingLocalPointer, type EditingViewport, } from "./editingTargets.js";
|
|
32
35
|
export { elementZIndex, hasOnlyFormattingChildren, isCompositionHost, layerKindOf, type EditingLayer, type LayerKind, } from "./editingLayers.js";
|
|
33
36
|
export { composeElementTransform, individualRotateDegrees, type PlanarTransformOps, } from "./elementTransform.js";
|
|
@@ -36,7 +39,7 @@ export declare const EDITING_PROTOCOL_VERSION: 1;
|
|
|
36
39
|
export declare const EDITING_CONNECT = "editing-connect";
|
|
37
40
|
/** Frame to parent, on the window: carries the port in its transfer list. */
|
|
38
41
|
export declare const EDITING_PORT = "editing-port";
|
|
39
|
-
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", "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"];
|
|
42
|
+
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", "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"];
|
|
40
43
|
export type EditingRequestKind = (typeof EDITING_REQUEST_KINDS)[number];
|
|
41
44
|
export interface EditingRuntimeSnapshot {
|
|
42
45
|
/** The runtime has installed its player API. */
|
|
@@ -289,6 +292,16 @@ export interface EditingRequests {
|
|
|
289
292
|
changed: boolean;
|
|
290
293
|
};
|
|
291
294
|
};
|
|
295
|
+
"gsap-snapshot": {
|
|
296
|
+
params: NoParams;
|
|
297
|
+
result: GsapSnapshot;
|
|
298
|
+
};
|
|
299
|
+
"motion-path-home": {
|
|
300
|
+
params: {
|
|
301
|
+
selector: string;
|
|
302
|
+
};
|
|
303
|
+
result: MotionPathFrameHome;
|
|
304
|
+
};
|
|
292
305
|
}
|
|
293
306
|
export type EditingParams<K extends EditingRequestKind> = EditingRequests[K]["params"];
|
|
294
307
|
export type EditingResult<K extends EditingRequestKind> = EditingRequests[K]["result"];
|
|
@@ -347,3 +360,4 @@ export declare function createEditingPortClient(options: {
|
|
|
347
360
|
timeoutMs?: number;
|
|
348
361
|
host?: Window;
|
|
349
362
|
}): EditingPortClient;
|
|
363
|
+
export { elementHome, transformWDivisor, type MotionPathHome } from "./editing/motionPathHome.js";
|
|
@@ -25,6 +25,7 @@ import { parseSetAudioGroupAttribute, } from "./editing/setAudioGroupAttribute.j
|
|
|
25
25
|
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, } from "./editingElement.js";
|
|
26
26
|
export { elementCornerPoints, isElementVisibleThroughAncestors, readElementTransformSnapshot, rotationDegreesFromMatrix, snapCandidates, MAX_GEOMETRY_CHILDREN, MAX_SNAP_TARGETS, ROTATION_GATE_EPSILON_DEG, } from "./editingGeometry.js";
|
|
27
27
|
export { MAX_CAPTION_TRANSFORM } from "./editing/captionTransform.js";
|
|
28
|
+
export { MAX_SNAPSHOT_CHANNELS, MAX_SNAPSHOT_FIELDS, MAX_SNAPSHOT_TARGETS, MAX_SNAPSHOT_TEXT, MAX_SNAPSHOT_TWEENS, MAX_VARS_DEPTH, } from "./editing/gsapSnapshotLimits.js";
|
|
28
29
|
export { compositionPoint, coversComposition, isDomLayerElement, isInspectableLayerElement, pointerTarget, pointerTargets, resolveAllVisualDomEditTargets, resolveLayerSelector, } from "./editingTargets.js";
|
|
29
30
|
export { elementZIndex, hasOnlyFormattingChildren, isCompositionHost, layerKindOf, } from "./editingLayers.js";
|
|
30
31
|
export { composeElementTransform, individualRotateDegrees, } from "./elementTransform.js";
|
|
@@ -61,6 +62,8 @@ export const EDITING_REQUEST_KINDS = [
|
|
|
61
62
|
"document-markup",
|
|
62
63
|
"set-audio-group-attribute",
|
|
63
64
|
"assign-audio-group",
|
|
65
|
+
"gsap-snapshot",
|
|
66
|
+
"motion-path-home",
|
|
64
67
|
];
|
|
65
68
|
export const MAX_DRAFT_PX = 100_000;
|
|
66
69
|
export const MAX_WATCHED_KEYS = 32;
|
|
@@ -224,6 +227,10 @@ const PARAM_PARSERS = {
|
|
|
224
227
|
"document-markup": noParams,
|
|
225
228
|
"set-audio-group-attribute": parseSetAudioGroupAttribute,
|
|
226
229
|
"assign-audio-group": parseAssignAudioGroup,
|
|
230
|
+
"gsap-snapshot": noParams,
|
|
231
|
+
"motion-path-home": (params) => hasKeys(params, "selector") && isSelector(params.selector)
|
|
232
|
+
? { selector: params.selector }
|
|
233
|
+
: null,
|
|
227
234
|
};
|
|
228
235
|
/** Validates one request off the wire. Never throws: anything unusable becomes a typed error. */
|
|
229
236
|
export function parseEditingRequest(data) {
|
|
@@ -400,3 +407,4 @@ export function createEditingPortClient(options) {
|
|
|
400
407
|
},
|
|
401
408
|
};
|
|
402
409
|
}
|
|
410
|
+
export { elementHome, transformWDivisor } from "./editing/motionPathHome.js";
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HfColorGradingTarget } from "../colorGrading.js";
|
|
2
|
+
import type { PreviewTarget } from "../studioPreviewMark.js";
|
|
2
3
|
import type { RuntimeAnalyticsEvent } from "./analytics.js";
|
|
3
4
|
import type { AudioFades } from "../audioFade.js";
|
|
4
5
|
import type { RateSpec } from "../speedRamp.js";
|
|
@@ -9,7 +10,7 @@ export type RuntimeJson = string | number | boolean | null | RuntimeJson[] | {
|
|
|
9
10
|
import type { HyperframeControlAction } from "../inline-scripts/runtimeContract.js";
|
|
10
11
|
import type { HyperframePickerElementInfo } from "../inline-scripts/pickerApi.js";
|
|
11
12
|
import type { RuntimeProtocolV1 } from "./protocol.js";
|
|
12
|
-
type RuntimeBridgeControlActionBase = HyperframeControlAction | "tick" | "set-volume" | "set-media-output-muted" | "set-native-media-sync-disabled" | "set-web-audio-media-disabled" | "set-idle-heartbeat" | "set-display-scale" | "set-preview-quality" | "set-copies-ahead" | "retry-preview-copies" | "request-preview-facts" | "set-root-duration" | "set-play-range" | "stop-media" | "flash-elements";
|
|
13
|
+
type RuntimeBridgeControlActionBase = HyperframeControlAction | "tick" | "set-volume" | "set-media-output-muted" | "set-native-media-sync-disabled" | "set-web-audio-media-disabled" | "set-idle-heartbeat" | "set-display-scale" | "set-preview-quality" | "set-copies-ahead" | "retry-preview-copies" | "request-preview-facts" | "set-root-duration" | "set-play-range" | "stop-media" | "flash-elements" | "scrub-audio";
|
|
13
14
|
type RuntimeBridgeControlMessageBase = {
|
|
14
15
|
source: "hf-parent";
|
|
15
16
|
type: "control";
|
|
@@ -27,7 +28,8 @@ type RuntimeBridgeControlMessageBase = {
|
|
|
27
28
|
level?: number;
|
|
28
29
|
on?: boolean;
|
|
29
30
|
playbackRate?: number;
|
|
30
|
-
target?: HfColorGradingTarget | string | null;
|
|
31
|
+
target?: HfColorGradingTarget | PreviewTarget | string | null;
|
|
32
|
+
time?: number | null;
|
|
31
33
|
grading?: RuntimeJson;
|
|
32
34
|
compare?: RuntimeJson;
|
|
33
35
|
seekMode?: "drag" | "commit";
|
|
@@ -32,3 +32,11 @@ export declare function serviceWorkerScriptFetch(headers: {
|
|
|
32
32
|
serviceWorker?: string | string[];
|
|
33
33
|
fetchDest?: string | string[];
|
|
34
34
|
}): boolean;
|
|
35
|
+
export interface PreviewTarget {
|
|
36
|
+
hfId?: string;
|
|
37
|
+
domId?: string;
|
|
38
|
+
id: string;
|
|
39
|
+
sourceFile?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function previewElementSourceFile(el: Element): string | undefined;
|
|
42
|
+
export declare function previewElementFinder(doc: Document, selector?: string): (target: PreviewTarget) => Element | null;
|
|
@@ -79,3 +79,36 @@ export function dropServiceWorkers() {
|
|
|
79
79
|
export function serviceWorkerScriptFetch(headers) {
|
|
80
80
|
return headers.serviceWorker === "script" || headers.fetchDest === "serviceworker";
|
|
81
81
|
}
|
|
82
|
+
export function previewElementSourceFile(el) {
|
|
83
|
+
const ownerRoot = el.parentElement?.closest("[data-composition-id]");
|
|
84
|
+
return (ownerRoot?.getAttribute("data-composition-file") ??
|
|
85
|
+
ownerRoot?.getAttribute("data-composition-src") ??
|
|
86
|
+
undefined);
|
|
87
|
+
}
|
|
88
|
+
export function previewElementFinder(doc, selector = "[data-hf-id], [id]") {
|
|
89
|
+
const byKey = new Map();
|
|
90
|
+
const add = (key, node) => {
|
|
91
|
+
const nodes = byKey.get(key);
|
|
92
|
+
if (nodes)
|
|
93
|
+
nodes.push(node);
|
|
94
|
+
else
|
|
95
|
+
byKey.set(key, [node]);
|
|
96
|
+
};
|
|
97
|
+
for (const node of doc.querySelectorAll(selector)) {
|
|
98
|
+
const hfId = node.getAttribute("data-hf-id");
|
|
99
|
+
const id = node.getAttribute("id");
|
|
100
|
+
if (hfId)
|
|
101
|
+
add(`hf:${hfId}`, node);
|
|
102
|
+
if (id)
|
|
103
|
+
add(`id:${id}`, node);
|
|
104
|
+
}
|
|
105
|
+
return (target) => {
|
|
106
|
+
const matches = [
|
|
107
|
+
...((target.hfId && byKey.get(`hf:${target.hfId}`)) || []),
|
|
108
|
+
...(byKey.get(`id:${target.domId ?? target.id}`) ?? []),
|
|
109
|
+
];
|
|
110
|
+
return (matches.find((node) => previewElementSourceFile(node) === target.sourceFile) ??
|
|
111
|
+
matches[0] ??
|
|
112
|
+
null);
|
|
113
|
+
};
|
|
114
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.65",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -465,9 +465,9 @@
|
|
|
465
465
|
"linkedom": "^0.18.12",
|
|
466
466
|
"postcss": "^8.5.8",
|
|
467
467
|
"wawoff2": "^2.0.1",
|
|
468
|
-
"@hyperframes/lint": "0.9.
|
|
469
|
-
"@hyperframes/
|
|
470
|
-
"@hyperframes/
|
|
468
|
+
"@hyperframes/lint": "0.9.65",
|
|
469
|
+
"@hyperframes/studio-server": "0.9.65",
|
|
470
|
+
"@hyperframes/parsers": "0.9.65"
|
|
471
471
|
},
|
|
472
472
|
"devDependencies": {
|
|
473
473
|
"@fontsource/archivo-black": "^5.2.8",
|