@hyperframes/core 0.9.97 → 0.9.99
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/editingPort.d.ts +9 -1
- package/dist/runtime/editingPort.js +7 -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;
|
|
@@ -46,7 +46,7 @@ export declare const EDITING_PROTOCOL_VERSION: 1;
|
|
|
46
46
|
export declare const EDITING_CONNECT = "editing-connect";
|
|
47
47
|
/** Frame to parent, on the window: carries the port in its transfer list. */
|
|
48
48
|
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"];
|
|
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", "rebind-timing", "assets-unloaded", "text-edit", "serve-paused-frames"];
|
|
50
50
|
export type EditingRequestKind = (typeof EDITING_REQUEST_KINDS)[number];
|
|
51
51
|
export interface EditingRuntimeSnapshot {
|
|
52
52
|
/** The runtime has installed its player API. */
|
|
@@ -436,6 +436,14 @@ export interface EditingRequests {
|
|
|
436
436
|
result: LiveRetimeResult;
|
|
437
437
|
};
|
|
438
438
|
};
|
|
439
|
+
"rebind-timing": {
|
|
440
|
+
params: {
|
|
441
|
+
time: number;
|
|
442
|
+
};
|
|
443
|
+
result: {
|
|
444
|
+
rebound: boolean;
|
|
445
|
+
};
|
|
446
|
+
};
|
|
439
447
|
"assets-unloaded": {
|
|
440
448
|
params: NoParams;
|
|
441
449
|
result: {
|
|
@@ -74,6 +74,7 @@ export const EDITING_REQUEST_KINDS = [
|
|
|
74
74
|
"mark-scenes-stale",
|
|
75
75
|
"swap-scenes",
|
|
76
76
|
"live-retime",
|
|
77
|
+
"rebind-timing",
|
|
77
78
|
"assets-unloaded",
|
|
78
79
|
"text-edit",
|
|
79
80
|
"serve-paused-frames",
|
|
@@ -342,6 +343,12 @@ const PARAM_PARSERS = {
|
|
|
342
343
|
"mark-scenes-stale": parseMarkScenesStale,
|
|
343
344
|
"swap-scenes": parseSwapScenes,
|
|
344
345
|
"live-retime": parseLiveRetime,
|
|
346
|
+
"rebind-timing": (params) => {
|
|
347
|
+
if (!isPlainRecord(params) || Object.keys(params).join() !== "time")
|
|
348
|
+
return null;
|
|
349
|
+
const { time } = params;
|
|
350
|
+
return typeof time === "number" && Number.isFinite(time) && time >= 0 ? { time } : null;
|
|
351
|
+
},
|
|
345
352
|
"assets-unloaded": noParams,
|
|
346
353
|
"text-edit": parseTextEdit,
|
|
347
354
|
"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.99",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -525,9 +525,9 @@
|
|
|
525
525
|
"linkedom": "^0.18.12",
|
|
526
526
|
"postcss": "^8.5.8",
|
|
527
527
|
"wawoff2": "^2.0.1",
|
|
528
|
-
"@hyperframes/lint": "0.9.
|
|
529
|
-
"@hyperframes/parsers": "0.9.
|
|
530
|
-
"@hyperframes/studio-server": "0.9.
|
|
528
|
+
"@hyperframes/lint": "0.9.99",
|
|
529
|
+
"@hyperframes/parsers": "0.9.99",
|
|
530
|
+
"@hyperframes/studio-server": "0.9.99"
|
|
531
531
|
},
|
|
532
532
|
"devDependencies": {
|
|
533
533
|
"@fontsource/archivo-black": "^5.2.8",
|