@hyperframes/core 0.9.98 → 0.9.100
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/generated/runtime-inline.js +1 -1
- package/dist/hyperframe.runtime.iife.js +66 -66
- package/dist/runtime/bridge.d.ts +1 -1
- package/dist/runtime/bridge.js +9 -4
- package/dist/runtime/editing/textStyleReads.d.ts +17 -0
- package/dist/runtime/editing/textStyleReads.js +57 -0
- package/dist/runtime/editingPort.d.ts +11 -1
- package/dist/runtime/editingPort.js +9 -0
- package/dist/runtime/protocol.d.ts +7 -0
- package/dist/runtime/protocol.js +14 -1
- package/dist/runtime/types.d.ts +2 -0
- package/package.json +4 -4
package/dist/runtime/bridge.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type PreviewTarget } from "../studioPreviewMark.js";
|
|
|
2
2
|
import type { HfColorGradingTarget } from "../colorGrading.js";
|
|
3
3
|
import type { RuntimeOutboundMessage } from "./types.js";
|
|
4
4
|
type BridgeDeps = {
|
|
5
|
-
onPlay: () => void;
|
|
5
|
+
onPlay: (playSeq?: number) => void;
|
|
6
6
|
onPause: () => void;
|
|
7
7
|
onStopMedia: () => void;
|
|
8
8
|
onSeek: (timeSeconds: number, seekMode: "drag" | "commit") => void;
|
package/dist/runtime/bridge.js
CHANGED
|
@@ -2,7 +2,7 @@ import { wallSetTimeout } from "./wallClock.js";
|
|
|
2
2
|
import { swallow } from "./diagnostics.js";
|
|
3
3
|
import { isStylableElement } from "./domRealm.js";
|
|
4
4
|
import { servedToAnotherSite } from "../studioPreviewMark.js";
|
|
5
|
-
import { inspectRuntimeProtocol, runtimeProtocolFpsToNumber, runtimeProtocolMetadata, } from "./protocol.js";
|
|
5
|
+
import { inspectRuntimeProtocol, isMessageList, runtimeProtocolFpsToNumber, runtimeProtocolMetadata, } from "./protocol.js";
|
|
6
6
|
let runtimeProtocolFps = 30;
|
|
7
7
|
export function setRuntimeProtocolFps(fps) {
|
|
8
8
|
runtimeProtocolFps = Number.isFinite(fps) && fps > 0 ? fps : 30;
|
|
@@ -43,7 +43,6 @@ const FLASH_DEFAULT_DURATION_MS = 800;
|
|
|
43
43
|
const FLASH_MAX_DURATION_MS = 5000;
|
|
44
44
|
const MAX_FLASH_SELECTORS = 100;
|
|
45
45
|
const MAX_SELECTOR_LENGTH = 1000;
|
|
46
|
-
const MAX_PARENT_AUDIO_CLIPS = 1000;
|
|
47
46
|
const MAX_PARENT_AUDIO_KEY = 8192;
|
|
48
47
|
function isFiniteNumber(value) {
|
|
49
48
|
return typeof value === "number" && Number.isFinite(value);
|
|
@@ -104,7 +103,13 @@ function dispatchColorGrading(target, value, apply) {
|
|
|
104
103
|
// Each dispatcher checks its payload fields for type and range and drops the
|
|
105
104
|
// message when a field is invalid.
|
|
106
105
|
const CONTROL_HANDLERS = new Map(Object.entries({
|
|
107
|
-
play: (
|
|
106
|
+
play: (data, deps) => {
|
|
107
|
+
if (data.playSeq == null)
|
|
108
|
+
return deps.onPlay();
|
|
109
|
+
if (!isFiniteNumber(data.playSeq) || !Number.isInteger(data.playSeq) || data.playSeq < 1)
|
|
110
|
+
return;
|
|
111
|
+
deps.onPlay(data.playSeq);
|
|
112
|
+
},
|
|
108
113
|
pause: (_d, deps) => deps.onPause(),
|
|
109
114
|
"stop-media": (_d, deps) => deps.onStopMedia(),
|
|
110
115
|
seek: (data, deps) => {
|
|
@@ -124,7 +129,7 @@ const CONTROL_HANDLERS = new Map(Object.entries({
|
|
|
124
129
|
"set-web-audio-media-disabled": (data, deps) => deps.onSetWebAudioMediaDisabled(data.disabled === true),
|
|
125
130
|
"set-parent-audio": (data, deps) => {
|
|
126
131
|
const clips = data.clips;
|
|
127
|
-
if (!
|
|
132
|
+
if (!isMessageList(clips))
|
|
128
133
|
return;
|
|
129
134
|
if (!clips.every((clip) => typeof clip === "string" && clip.length <= MAX_PARENT_AUDIO_KEY))
|
|
130
135
|
return;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EditingElementHandle } from "../editingElement.js";
|
|
2
|
+
export declare const MAX_FONT_FACES = 256;
|
|
3
|
+
/** Each property's inline value, else the last same-origin rule's that matches; null for an unknown handle. */
|
|
4
|
+
export declare function authoredStyles({ handle, properties, }: {
|
|
5
|
+
handle: EditingElementHandle;
|
|
6
|
+
properties: string[];
|
|
7
|
+
}): {
|
|
8
|
+
styles: Record<string, string> | null;
|
|
9
|
+
};
|
|
10
|
+
/** The families the document's fonts draw, and each same-origin `@font-face` rule's family and src. */
|
|
11
|
+
export declare function fontFaces(): {
|
|
12
|
+
families: string[];
|
|
13
|
+
ownFaces: Array<{
|
|
14
|
+
family: string;
|
|
15
|
+
src: string;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { MAX_ELEMENT_VALUE } from "../editingElement.js";
|
|
2
|
+
import { elementForHandle } from "../editingHandles.js";
|
|
3
|
+
export const MAX_FONT_FACES = 256;
|
|
4
|
+
const cut = (value) => value.slice(0, MAX_ELEMENT_VALUE);
|
|
5
|
+
function sameOriginRules() {
|
|
6
|
+
return [...document.styleSheets].flatMap((sheet) => {
|
|
7
|
+
try {
|
|
8
|
+
return [...sheet.cssRules];
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const isStyleRule = (rule) => "selectorText" in rule;
|
|
16
|
+
const isFontFaceRule = (rule) => rule.cssText.startsWith("@font-face");
|
|
17
|
+
function matches(element, selector) {
|
|
18
|
+
try {
|
|
19
|
+
return element.matches(selector);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Each property's inline value, else the last same-origin rule's that matches; null for an unknown handle. */
|
|
26
|
+
export function authoredStyles({ handle, properties, }) {
|
|
27
|
+
const element = elementForHandle(handle);
|
|
28
|
+
if (!element)
|
|
29
|
+
return { styles: null };
|
|
30
|
+
const inline = element.style;
|
|
31
|
+
const rules = sameOriginRules().filter(isStyleRule);
|
|
32
|
+
const styles = {};
|
|
33
|
+
for (const name of properties) {
|
|
34
|
+
const ruled = rules.filter((rule) => rule.style.getPropertyValue(name) && matches(element, rule.selectorText));
|
|
35
|
+
const value = inline?.getPropertyValue(name) || ruled.at(-1)?.style.getPropertyValue(name);
|
|
36
|
+
if (value)
|
|
37
|
+
styles[name] = cut(value);
|
|
38
|
+
}
|
|
39
|
+
return { styles };
|
|
40
|
+
}
|
|
41
|
+
/** The families the document's fonts draw, and each same-origin `@font-face` rule's family and src. */
|
|
42
|
+
export function fontFaces() {
|
|
43
|
+
const families = new Set();
|
|
44
|
+
for (const face of document.fonts ?? []) {
|
|
45
|
+
if (families.size >= MAX_FONT_FACES)
|
|
46
|
+
break;
|
|
47
|
+
families.add(cut(face.family));
|
|
48
|
+
}
|
|
49
|
+
const ownFaces = sameOriginRules()
|
|
50
|
+
.filter(isFontFaceRule)
|
|
51
|
+
.slice(0, MAX_FONT_FACES)
|
|
52
|
+
.map((rule) => ({
|
|
53
|
+
family: cut(rule.style.getPropertyValue("font-family")),
|
|
54
|
+
src: cut(rule.style.getPropertyValue("src")),
|
|
55
|
+
}));
|
|
56
|
+
return { families: [...families], ownFaces };
|
|
57
|
+
}
|
|
@@ -38,6 +38,8 @@ export { buildStableSelector, escapeCssString, getPreferredClassSelector, isEdit
|
|
|
38
38
|
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";
|
|
39
39
|
export type { EditingGestureBase, EditingGestureStart } from "./editingGestureStart.js";
|
|
40
40
|
export { MAX_CAPTION_TRANSFORM } from "./editing/captionTransform.js";
|
|
41
|
+
export { MAX_EDIT_ENTRIES } from "./editing/editElement.js";
|
|
42
|
+
export { MAX_FONT_FACES } from "./editing/textStyleReads.js";
|
|
41
43
|
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";
|
|
42
44
|
export { compositionPoint, coversComposition, isDomLayerElement, isInspectableLayerElement, pointerTarget, pointerTargets, resolveAllVisualDomEditTargets, resolveLayerSelector, type EditingLocalPointer, type EditingViewport, } from "./editingTargets.js";
|
|
43
45
|
export { elementZIndex, hasOnlyFormattingChildren, NON_PAINTING_TAGS, isCompositionHost, layerKindOf, type EditingLayer, type EditingStackingSibling, type LayerKind, } from "./editingLayers.js";
|
|
@@ -46,7 +48,7 @@ export declare const EDITING_PROTOCOL_VERSION: 1;
|
|
|
46
48
|
export declare const EDITING_CONNECT = "editing-connect";
|
|
47
49
|
/** Frame to parent, on the window: carries the port in its transfer list. */
|
|
48
50
|
export declare const EDITING_PORT = "editing-port";
|
|
49
|
-
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", "assets-unloaded", "text-edit", "serve-paused-frames"];
|
|
51
|
+
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"];
|
|
50
52
|
export type EditingRequestKind = (typeof EDITING_REQUEST_KINDS)[number];
|
|
51
53
|
export interface EditingRuntimeSnapshot {
|
|
52
54
|
/** The runtime has installed its player API. */
|
|
@@ -436,6 +438,14 @@ export interface EditingRequests {
|
|
|
436
438
|
result: LiveRetimeResult;
|
|
437
439
|
};
|
|
438
440
|
};
|
|
441
|
+
"rebind-timing": {
|
|
442
|
+
params: {
|
|
443
|
+
time: number;
|
|
444
|
+
};
|
|
445
|
+
result: {
|
|
446
|
+
rebound: boolean;
|
|
447
|
+
};
|
|
448
|
+
};
|
|
439
449
|
"assets-unloaded": {
|
|
440
450
|
params: NoParams;
|
|
441
451
|
result: {
|
|
@@ -21,6 +21,8 @@ import { parseTextEdit, textEditEndedEvent, textEditSelectionEvent, } from "./ed
|
|
|
21
21
|
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, } from "./editingElement.js";
|
|
22
22
|
export { elementCornerPoints, isElementVisibleThroughAncestors, readElementTransformSnapshot, rotationDegreesFromMatrix, snapCandidates, MAX_GEOMETRY_CHILDREN, MAX_SNAP_TARGETS, ROTATION_GATE_EPSILON_DEG, } from "./editingGeometry.js";
|
|
23
23
|
export { MAX_CAPTION_TRANSFORM } from "./editing/captionTransform.js";
|
|
24
|
+
export { MAX_EDIT_ENTRIES } from "./editing/editElement.js";
|
|
25
|
+
export { MAX_FONT_FACES } from "./editing/textStyleReads.js";
|
|
24
26
|
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";
|
|
25
27
|
export { compositionPoint, coversComposition, isDomLayerElement, isInspectableLayerElement, pointerTarget, pointerTargets, resolveAllVisualDomEditTargets, resolveLayerSelector, } from "./editingTargets.js";
|
|
26
28
|
export { elementZIndex, hasOnlyFormattingChildren, NON_PAINTING_TAGS, isCompositionHost, layerKindOf, } from "./editingLayers.js";
|
|
@@ -74,6 +76,7 @@ export const EDITING_REQUEST_KINDS = [
|
|
|
74
76
|
"mark-scenes-stale",
|
|
75
77
|
"swap-scenes",
|
|
76
78
|
"live-retime",
|
|
79
|
+
"rebind-timing",
|
|
77
80
|
"assets-unloaded",
|
|
78
81
|
"text-edit",
|
|
79
82
|
"serve-paused-frames",
|
|
@@ -342,6 +345,12 @@ const PARAM_PARSERS = {
|
|
|
342
345
|
"mark-scenes-stale": parseMarkScenesStale,
|
|
343
346
|
"swap-scenes": parseSwapScenes,
|
|
344
347
|
"live-retime": parseLiveRetime,
|
|
348
|
+
"rebind-timing": (params) => {
|
|
349
|
+
if (!isPlainRecord(params) || Object.keys(params).join() !== "time")
|
|
350
|
+
return null;
|
|
351
|
+
const { time } = params;
|
|
352
|
+
return typeof time === "number" && Number.isFinite(time) && time >= 0 ? { time } : null;
|
|
353
|
+
},
|
|
345
354
|
"assets-unloaded": noParams,
|
|
346
355
|
"text-edit": parseTextEdit,
|
|
347
356
|
"serve-paused-frames": (params) => hasKeys(params, "channel") && params.channel instanceof MessagePort
|
|
@@ -28,6 +28,13 @@ export declare function playRangeHoldTime(start: number, end: number, fps: numbe
|
|
|
28
28
|
export declare function runtimeProtocolFpsToNumber(value: unknown): number | null;
|
|
29
29
|
export declare function runtimeProtocolMetadata(fps: number): RuntimeProtocolV1;
|
|
30
30
|
export declare function frameDisplayScale(frame: HTMLElement): number | null;
|
|
31
|
+
export declare const MAX_MESSAGE_LIST = 1000;
|
|
32
|
+
export type MessageListRefusal = {
|
|
33
|
+
reason: "length" | "hole";
|
|
34
|
+
length: number;
|
|
35
|
+
};
|
|
36
|
+
export declare function refuseMessageList(value: unknown[], max?: number): MessageListRefusal | null;
|
|
37
|
+
export declare function isMessageList(value: unknown, max?: number): value is unknown[];
|
|
31
38
|
export declare function inspectRuntimeProtocol(value: unknown, legacyFps?: number): RuntimeProtocolInspection;
|
|
32
39
|
declare const STAGES: readonly ["fetch", "decode", "element"];
|
|
33
40
|
export type MediaLoadStage = (typeof STAGES)[number];
|
package/dist/runtime/protocol.js
CHANGED
|
@@ -53,8 +53,21 @@ export function frameDisplayScale(frame) {
|
|
|
53
53
|
const shownWidth = frame.getBoundingClientRect().width;
|
|
54
54
|
return layoutWidth > 0 && shownWidth > 0 ? shownWidth / layoutWidth : null;
|
|
55
55
|
}
|
|
56
|
+
export const MAX_MESSAGE_LIST = 1000;
|
|
57
|
+
export function refuseMessageList(value, max = MAX_MESSAGE_LIST) {
|
|
58
|
+
if (value.length > max)
|
|
59
|
+
return { reason: "length", length: value.length };
|
|
60
|
+
for (let i = 0; i < value.length; i++) {
|
|
61
|
+
if (!(i in value))
|
|
62
|
+
return { reason: "hole", length: value.length };
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
export function isMessageList(value, max = MAX_MESSAGE_LIST) {
|
|
67
|
+
return Array.isArray(value) && refuseMessageList(value, max) === null;
|
|
68
|
+
}
|
|
56
69
|
function hasDeclaredCapabilities(value) {
|
|
57
|
-
return
|
|
70
|
+
return isMessageList(value) && value.every((capability) => typeof capability === "string");
|
|
58
71
|
}
|
|
59
72
|
export function inspectRuntimeProtocol(value, legacyFps = 30) {
|
|
60
73
|
if (typeof value !== "object" || value === null)
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ type RuntimeBridgeControlMessageBase = {
|
|
|
38
38
|
clips?: string[];
|
|
39
39
|
rate?: number;
|
|
40
40
|
at?: number;
|
|
41
|
+
playSeq?: number;
|
|
41
42
|
};
|
|
42
43
|
export type RuntimeStateMessage = {
|
|
43
44
|
source: "hf-preview";
|
|
@@ -49,6 +50,7 @@ export type RuntimeStateMessage = {
|
|
|
49
50
|
buffering: boolean;
|
|
50
51
|
muted: boolean;
|
|
51
52
|
playbackRate: number;
|
|
53
|
+
playSeq?: number;
|
|
52
54
|
};
|
|
53
55
|
export type RuntimeTimelineClipIdentity = {
|
|
54
56
|
id: string | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.100",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -525,9 +525,9 @@
|
|
|
525
525
|
"linkedom": "^0.18.12",
|
|
526
526
|
"postcss": "^8.5.8",
|
|
527
527
|
"wawoff2": "^2.0.1",
|
|
528
|
-
"@hyperframes/
|
|
529
|
-
"@hyperframes/
|
|
530
|
-
"@hyperframes/studio-server": "0.9.
|
|
528
|
+
"@hyperframes/parsers": "0.9.100",
|
|
529
|
+
"@hyperframes/lint": "0.9.100",
|
|
530
|
+
"@hyperframes/studio-server": "0.9.100"
|
|
531
531
|
},
|
|
532
532
|
"devDependencies": {
|
|
533
533
|
"@fontsource/archivo-black": "^5.2.8",
|