@hyperframes/core 0.9.79 → 0.9.80
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/editing/liveRetime.js +3 -1
- package/dist/runtime/editing/patchTween.js +3 -1
- package/dist/runtime/editing/restoreAttributes.d.ts +4 -4
- package/dist/runtime/editing/restoreAttributes.js +12 -10
- package/dist/runtime/editing/softReload.d.ts +16 -3
- package/dist/runtime/editing/softReload.js +108 -57
- package/dist/runtime/editingPort.d.ts +2 -1
- package/dist/runtime/editingPort.js +2 -14
- package/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// A saved timing edit that only moved tweens moves the live ones instead of re-running the script.
|
|
2
2
|
// Studio plans the move from the saved scripts; the frame checks its timeline matches the plan first.
|
|
3
3
|
import { RUNTIME_FILLER } from "../protocol.js";
|
|
4
|
-
import { applyTimingPlan, compositionFile, finalizeSoftReload, findGsapScriptElements, parseSavedTiming, planSavedTiming, scriptsRegistering, } from "./softReload.js";
|
|
4
|
+
import { applyTimingPlan, compositionFile, finalizeSoftReload, findGsapScriptElements, parseSavedTiming, planSavedTiming, scriptsRegistering, swapWaiting, } from "./softReload.js";
|
|
5
5
|
const same = (a, b) => Math.abs(a - b) < 1e-6;
|
|
6
6
|
const targetsMatch = (tween, selector) => {
|
|
7
7
|
const targets = tween.targets?.() ?? [];
|
|
@@ -172,6 +172,8 @@ export function parseLiveRetime(params) {
|
|
|
172
172
|
/** The frame moving its own tweens to the plan Studio made from the saved scripts, then re-seeking. */
|
|
173
173
|
export function liveRetime(params) {
|
|
174
174
|
const win = window;
|
|
175
|
+
if (swapWaiting(win))
|
|
176
|
+
return { result: "unchanged" };
|
|
175
177
|
const [script, ...extra] = scriptsRegistering(findGsapScriptElements(document), [params.key]);
|
|
176
178
|
if (!script || extra.length > 0)
|
|
177
179
|
return { result: "unchanged" };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// confidently returns false and the caller reloads. Studio runs it on a frame it can reach,
|
|
3
3
|
// a sealed frame on itself through the editing port.
|
|
4
4
|
import { applyAuthoredInlineOpacity, readStampedAuthoredOpacity } from "../../colorGrading.js";
|
|
5
|
-
import { recordLiveSet } from "./softReload.js";
|
|
5
|
+
import { recordLiveSet, swapWaiting } from "./softReload.js";
|
|
6
6
|
const SET_CHANNELS = [
|
|
7
7
|
"x",
|
|
8
8
|
"y",
|
|
@@ -321,6 +321,8 @@ export function patchTweens({ patches, seek }) {
|
|
|
321
321
|
gsap: win.gsap,
|
|
322
322
|
player: win.__player,
|
|
323
323
|
};
|
|
324
|
+
if (swapWaiting())
|
|
325
|
+
return { patched: false };
|
|
324
326
|
const renderAt = lastTweenPatch(patches);
|
|
325
327
|
const missed = patches.find(({ selector, change }, index) => {
|
|
326
328
|
if (change.kind === "global-set")
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SoftReloadRerun } from "./softReload.js";
|
|
1
2
|
/** `hf:<data-hf-id>` or `id:<id>`, the key the parent's restore diff uses. */
|
|
2
3
|
export type RestoreElementKey = string;
|
|
3
4
|
export type RestoreAttribute = [name: string, value: string];
|
|
@@ -14,6 +15,7 @@ export type RestoreAttributesParams = {
|
|
|
14
15
|
scopes: RestoreScope[];
|
|
15
16
|
scripted: boolean;
|
|
16
17
|
time: number;
|
|
18
|
+
rerun?: SoftReloadRerun;
|
|
17
19
|
};
|
|
18
20
|
export declare function parseRestoreScopes(scopes: unknown): RestoreScope[] | null;
|
|
19
21
|
export declare function parseRestoreAttributes(params: unknown): RestoreAttributesParams | null;
|
|
@@ -21,7 +23,5 @@ export type RestorePlan = [Element, drop: string[], set: RestoreAttribute[]][];
|
|
|
21
23
|
/** Each live element with the attributes it drops and sets, or null when the restore cannot apply in place. */
|
|
22
24
|
export declare function planRestore(scopes: RestoreScope[]): RestorePlan | null;
|
|
23
25
|
export declare function applyRestorePlan(plan: RestorePlan): void;
|
|
24
|
-
/** Applies the restore in place
|
|
25
|
-
export declare function
|
|
26
|
-
applied: boolean;
|
|
27
|
-
};
|
|
26
|
+
/** Applies the restore in place, or nothing: refused, or an element GSAP has parsed needs a re-run. */
|
|
27
|
+
export declare function restoreInPlace({ scopes, scripted, time, }: RestoreAttributesParams): "applied" | "refused" | "gsap-parsed";
|
|
@@ -35,8 +35,10 @@ const safeToSet = (name) => SAFE_TO_SET.has(name) || isStudioEditMark(name);
|
|
|
35
35
|
const safeToDrop = (name) => !isStudioMotionMark(name) && (safeToSet(name) || name === "loading" || name.startsWith("data-"));
|
|
36
36
|
const reapplyScriptMissing = (plan) => plan.some(([, , set]) => set.some(([name]) => REAPPLIED.has(name))) &&
|
|
37
37
|
window[STUDIO_SEEK_REAPPLY_STARTED] !== true;
|
|
38
|
-
const
|
|
39
|
-
|
|
38
|
+
const hasKeys = (value, keys) => Object.prototype.toString.call(value) === "[object Object]" &&
|
|
39
|
+
Object.keys(value)
|
|
40
|
+
.sort()
|
|
41
|
+
.join() === keys;
|
|
40
42
|
function attribute(value) {
|
|
41
43
|
if (!Array.isArray(value) || value.length !== 2)
|
|
42
44
|
return null;
|
|
@@ -49,7 +51,7 @@ function attribute(value) {
|
|
|
49
51
|
: null;
|
|
50
52
|
}
|
|
51
53
|
function element(value) {
|
|
52
|
-
if (!
|
|
54
|
+
if (!hasKeys(value, "attributes,key"))
|
|
53
55
|
return null;
|
|
54
56
|
const { key, attributes } = value;
|
|
55
57
|
if (typeof key !== "string" || key.length > MAX_KEY_LENGTH || !/^(hf|id):./.test(key))
|
|
@@ -61,7 +63,7 @@ function element(value) {
|
|
|
61
63
|
}
|
|
62
64
|
const isScopeFile = (file) => file === null || (typeof file === "string" && file.length > 0 && file.length <= MAX_KEY_LENGTH);
|
|
63
65
|
function scope(value) {
|
|
64
|
-
if (!
|
|
66
|
+
if (!hasKeys(value, "elements,file"))
|
|
65
67
|
return null;
|
|
66
68
|
const { file, elements } = value;
|
|
67
69
|
if (!isScopeFile(file) || !Array.isArray(elements) || !elements.length)
|
|
@@ -79,7 +81,7 @@ export function parseRestoreScopes(scopes) {
|
|
|
79
81
|
return count <= MAX_ELEMENTS ? parsed : null;
|
|
80
82
|
}
|
|
81
83
|
export function parseRestoreAttributes(params) {
|
|
82
|
-
if (!
|
|
84
|
+
if (!hasKeys(params, "scopes,scripted,time"))
|
|
83
85
|
return null;
|
|
84
86
|
const { scripted, time } = params;
|
|
85
87
|
if (typeof scripted !== "boolean")
|
|
@@ -167,15 +169,15 @@ function rebindAt(win, time) {
|
|
|
167
169
|
else
|
|
168
170
|
finalize();
|
|
169
171
|
}
|
|
170
|
-
/** Applies the restore in place
|
|
171
|
-
export function
|
|
172
|
+
/** Applies the restore in place, or nothing: refused, or an element GSAP has parsed needs a re-run. */
|
|
173
|
+
export function restoreInPlace({ scopes, scripted, time, }) {
|
|
172
174
|
const win = window;
|
|
173
175
|
const plan = planRestore(scopes);
|
|
174
176
|
if (!plan || typeof win.__player?.seek !== "function")
|
|
175
|
-
return
|
|
177
|
+
return "refused";
|
|
176
178
|
if (scripted && plan.some(([el]) => "_gsap" in el))
|
|
177
|
-
return
|
|
179
|
+
return "gsap-parsed";
|
|
178
180
|
applyRestorePlan(plan);
|
|
179
181
|
rebindAt(win, time);
|
|
180
|
-
return
|
|
182
|
+
return "applied";
|
|
181
183
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RestorePlan, type RestoreScope } from "./restoreAttributes.js";
|
|
1
|
+
import { type RestoreAttributesParams, type RestorePlan, type RestoreScope } from "./restoreAttributes.js";
|
|
2
2
|
export type SoftReloadWindow = Window & {
|
|
3
3
|
__timelines?: Record<string, unknown>;
|
|
4
4
|
__player?: {
|
|
@@ -10,7 +10,9 @@ export type SoftReloadWindow = Window & {
|
|
|
10
10
|
__hfForceTimelineRebind?: () => void;
|
|
11
11
|
__hfSuppressSceneMutations?: <T>(fn: () => T) => T;
|
|
12
12
|
__hfStudioManualEditsApply?: () => void;
|
|
13
|
-
|
|
13
|
+
__hfMotionPathWaiters?: [ready: () => void, failed: () => void][];
|
|
14
|
+
__hfSwapsWaiting?: number;
|
|
15
|
+
__hfTimelineGenerations?: Map<string, number>;
|
|
14
16
|
gsap?: {
|
|
15
17
|
version?: string;
|
|
16
18
|
registerPlugin?: (...plugins: unknown[]) => unknown;
|
|
@@ -23,7 +25,7 @@ export type StandaloneSet = {
|
|
|
23
25
|
selector: string;
|
|
24
26
|
props: string[];
|
|
25
27
|
};
|
|
26
|
-
export type SoftReloadResult = "applied" | "verify-failed" | "cannot-soft-reload";
|
|
28
|
+
export type SoftReloadResult = "applied" | "verify-failed" | "cannot-soft-reload" | "superseded";
|
|
27
29
|
export interface SoftReloadInput {
|
|
28
30
|
script: string;
|
|
29
31
|
/** The time to seek the rebuilt timeline to; the player's own time when absent. */
|
|
@@ -63,6 +65,9 @@ export declare function scriptsRegistering(scripts: readonly HTMLScriptElement[]
|
|
|
63
65
|
export declare function restoreAuthoredStyle(style: CSSStyleDeclaration, authored: CSSStyleDeclaration | null, tweened: Set<string>): void;
|
|
64
66
|
export declare function finalizeSoftReload(win: SoftReloadWindow, currentTime: number): void;
|
|
65
67
|
export declare function previewMotionPathUrl(doc: Document, version?: string): string;
|
|
68
|
+
export declare function swapWaiting(win?: SoftReloadWindow): boolean;
|
|
69
|
+
/** Loads and registers MotionPathPlugin ahead of the first re-run that needs it, as Studio does same-origin. */
|
|
70
|
+
export declare function preloadMotionPath(win?: SoftReloadWindow, doc?: Document): void;
|
|
66
71
|
export declare function softReloadFrame(win: SoftReloadWindow, doc: Document, input: SoftReloadInput): SoftReloadResult | Promise<SoftReloadResult>;
|
|
67
72
|
export declare const MAX_SOFT_RELOAD_SCRIPT = 1000000;
|
|
68
73
|
export type SoftReloadParams = {
|
|
@@ -76,6 +81,7 @@ export type SoftReloadParams = {
|
|
|
76
81
|
/** An undo's or redo's restored attributes, set as `restore-attributes` would before the re-run. */
|
|
77
82
|
restore: RestoreScope[];
|
|
78
83
|
};
|
|
84
|
+
export type SoftReloadRerun = Omit<SoftReloadParams, "time" | "restore">;
|
|
79
85
|
export declare function parseSavedTiming(value: unknown): SavedTiming | null;
|
|
80
86
|
export declare function parseSoftReload(params: unknown): SoftReloadParams | null;
|
|
81
87
|
/** The key Studio files an element's authored style under: its hf-id, else its id. */
|
|
@@ -84,4 +90,11 @@ export declare function authoredKey(el: Element): string | null;
|
|
|
84
90
|
export declare function softReload(params: SoftReloadParams): Promise<{
|
|
85
91
|
result: SoftReloadResult;
|
|
86
92
|
}>;
|
|
93
|
+
/** `restore-attributes` with the re-run it may need; any other key still refuses the whole request. */
|
|
94
|
+
export declare function parseRestoreAttributesRerun(params: unknown): RestoreAttributesParams | null;
|
|
95
|
+
/** An element GSAP has parsed is restored by re-running the script, in the same request that sent it. */
|
|
96
|
+
export declare function restoreAttributesOrRerun(params: RestoreAttributesParams): Promise<{
|
|
97
|
+
applied: boolean;
|
|
98
|
+
reran: boolean;
|
|
99
|
+
}>;
|
|
87
100
|
export {};
|
|
@@ -5,7 +5,7 @@ import { GSAP_BASE_URL_META, motionPathPluginUrl } from "../../gsapCdn.js";
|
|
|
5
5
|
import { applyAuthoredInlineOpacity, readStampedAuthoredOpacity } from "../../colorGrading.js";
|
|
6
6
|
import { escapeCssString } from "../editingElement.js";
|
|
7
7
|
import { applyAuthoredTiming } from "../../studioPreviewMark.js";
|
|
8
|
-
import { applyRestorePlan, parseRestoreScopes, planRestore, } from "./restoreAttributes.js";
|
|
8
|
+
import { applyRestorePlan, parseRestoreAttributes, parseRestoreScopes, planRestore, restoreInPlace, } from "./restoreAttributes.js";
|
|
9
9
|
/** The attributes the runtime derives clip windows and the film's length from. */
|
|
10
10
|
export const TIMING_ATTRIBUTES = new Set([
|
|
11
11
|
"data-start",
|
|
@@ -282,33 +282,20 @@ function resetTargetStyles(win, targets, authored) {
|
|
|
282
282
|
}
|
|
283
283
|
// Runs `ready` once the MotionPath plugin is in the frame, or `failed` when it cannot load.
|
|
284
284
|
function whenMotionPathLoaded(win, doc, ready, failed) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
win.clearInterval(poll);
|
|
295
|
-
failed();
|
|
296
|
-
}
|
|
297
|
-
}, 50);
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
win.__hfMotionPathPluginLoading = true;
|
|
285
|
+
if (win.__hfMotionPathWaiters)
|
|
286
|
+
return void win.__hfMotionPathWaiters.push([ready, failed]);
|
|
287
|
+
const waiters = [[ready, failed]];
|
|
288
|
+
win.__hfMotionPathWaiters = waiters;
|
|
289
|
+
const settle = (loaded) => {
|
|
290
|
+
win.__hfMotionPathWaiters = undefined;
|
|
291
|
+
for (const [onReady, onFailed] of waiters)
|
|
292
|
+
(loaded ? onReady : onFailed)();
|
|
293
|
+
};
|
|
301
294
|
const pluginScript = doc.createElement("script");
|
|
302
295
|
pluginScript.src = previewMotionPathUrl(doc, win.gsap?.version);
|
|
303
|
-
pluginScript.onload = () =>
|
|
304
|
-
win.__hfMotionPathPluginLoading = false;
|
|
305
|
-
ready();
|
|
306
|
-
};
|
|
296
|
+
pluginScript.onload = () => settle(Boolean(win.MotionPathPlugin));
|
|
307
297
|
// Running the script without the plugin would leave a motionPath tween that cannot play.
|
|
308
|
-
pluginScript.onerror = () =>
|
|
309
|
-
win.__hfMotionPathPluginLoading = false;
|
|
310
|
-
failed();
|
|
311
|
-
};
|
|
298
|
+
pluginScript.onerror = () => settle(false);
|
|
312
299
|
doc.head.appendChild(pluginScript);
|
|
313
300
|
}
|
|
314
301
|
/** The timeline keys the script owns and the live scripts it replaces; null when which to replace is unclear. */
|
|
@@ -343,6 +330,34 @@ function readAuthoredStyles(doc, targets, input, ownFile) {
|
|
|
343
330
|
}
|
|
344
331
|
// Re-runs the script in place of the live one registering the same `__timelines` keys, tearing down
|
|
345
332
|
// only those timelines. A promise only while it waits for the MotionPath plugin.
|
|
333
|
+
export function swapWaiting(win = window) {
|
|
334
|
+
return (win.__hfSwapsWaiting ?? 0) > 0;
|
|
335
|
+
}
|
|
336
|
+
/** Loads and registers MotionPathPlugin ahead of the first re-run that needs it, as Studio does same-origin. */
|
|
337
|
+
export function preloadMotionPath(win = window, doc = document) {
|
|
338
|
+
if (win.MotionPathPlugin || win.__hfMotionPathWaiters || !win.gsap)
|
|
339
|
+
return;
|
|
340
|
+
const register = () => win.MotionPathPlugin && win.gsap?.registerPlugin?.(win.MotionPathPlugin);
|
|
341
|
+
whenMotionPathLoaded(win, doc, register, () => { });
|
|
342
|
+
}
|
|
343
|
+
function runScript(win, doc, script) {
|
|
344
|
+
if (win.MotionPathPlugin && win.gsap?.registerPlugin)
|
|
345
|
+
win.gsap.registerPlugin(win.MotionPathPlugin);
|
|
346
|
+
const s = doc.createElement("script");
|
|
347
|
+
s.textContent = `(function(){${script}\n})();`;
|
|
348
|
+
const before = doc.body.querySelectorAll("*").length + 1;
|
|
349
|
+
doc.body.appendChild(s);
|
|
350
|
+
// A script that builds DOM builds it again on every run; only a full load starts from the file.
|
|
351
|
+
// Not seen: text-only writes, nodes put in the head or a shadow root, and nodes added later.
|
|
352
|
+
return doc.body.querySelectorAll("*").length > before;
|
|
353
|
+
}
|
|
354
|
+
function startRun(win, keys) {
|
|
355
|
+
const generations = (win.__hfTimelineGenerations ??= new Map());
|
|
356
|
+
const numbered = keys.map((key) => [key, (generations.get(key) ?? 0) + 1]);
|
|
357
|
+
for (const [key, n] of numbered)
|
|
358
|
+
generations.set(key, n);
|
|
359
|
+
return () => numbered.every(([key, n]) => generations.get(key) === n);
|
|
360
|
+
}
|
|
346
361
|
export function softReloadFrame(win, doc, input) {
|
|
347
362
|
const { script } = input;
|
|
348
363
|
const scope = reloadScope(win, doc, script);
|
|
@@ -358,42 +373,46 @@ export function softReloadFrame(win, doc, input) {
|
|
|
358
373
|
const timing = input.timing ? planSavedTiming(doc, ownFile, input.timing) : [];
|
|
359
374
|
if (timing === null)
|
|
360
375
|
return "cannot-soft-reload";
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
let builtDom = false;
|
|
364
|
-
const executeScript = () => {
|
|
365
|
-
if (win.MotionPathPlugin && win.gsap?.registerPlugin)
|
|
366
|
-
win.gsap.registerPlugin(win.MotionPathPlugin);
|
|
367
|
-
const s = doc.createElement("script");
|
|
368
|
-
s.textContent = `(function(){${script}\n})();`;
|
|
369
|
-
const before = doc.body.querySelectorAll("*").length + 1;
|
|
370
|
-
doc.body.appendChild(s);
|
|
371
|
-
// A script that builds DOM builds it again on every run; only a full load starts from the file.
|
|
372
|
-
// Not seen: text-only writes, nodes put in the head or a shadow root, and nodes added later.
|
|
373
|
-
builtDom = doc.body.querySelectorAll("*").length > before;
|
|
374
|
-
finalizeSoftReload(win, currentTime);
|
|
375
|
-
deferred?.(builtDom ? "cannot-soft-reload" : "applied");
|
|
376
|
-
};
|
|
377
|
-
const doReload = () => {
|
|
376
|
+
// The file's own state lands now, in the order requests arrive; only the timeline swap may wait.
|
|
377
|
+
if (!runSuppressed(win, () => {
|
|
378
378
|
if (input.restorePlan)
|
|
379
379
|
applyRestorePlan(input.restorePlan);
|
|
380
380
|
applyTimingPlan(timing);
|
|
381
|
-
|
|
382
|
-
resetTargetStyles(win, targets, authored);
|
|
383
|
-
forgetLiveSets(targets);
|
|
384
|
-
for (const stale of staleScripts)
|
|
385
|
-
stale.remove();
|
|
386
|
-
const needsMotionPath = /motionPath\s*[:{]/.test(script);
|
|
387
|
-
if (!needsMotionPath || win.MotionPathPlugin || !win.gsap)
|
|
388
|
-
return executeScript();
|
|
389
|
-
pending = new Promise((resolve) => (deferred = resolve));
|
|
390
|
-
whenMotionPathLoaded(win, doc, executeScript, () => deferred?.("cannot-soft-reload"));
|
|
391
|
-
};
|
|
392
|
-
if (!runSuppressed(win, doReload) || builtDom)
|
|
381
|
+
}))
|
|
393
382
|
return "cannot-soft-reload";
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
383
|
+
const current = startRun(win, targetKeys);
|
|
384
|
+
const swap = (time) => {
|
|
385
|
+
let builtDom = false;
|
|
386
|
+
const ran = runSuppressed(win, () => {
|
|
387
|
+
killTimelines(win, targetKeys);
|
|
388
|
+
resetTargetStyles(win, targets, authored);
|
|
389
|
+
forgetLiveSets(targets);
|
|
390
|
+
for (const stale of staleScripts)
|
|
391
|
+
stale.remove();
|
|
392
|
+
builtDom = runScript(win, doc, script);
|
|
393
|
+
finalizeSoftReload(win, time);
|
|
394
|
+
});
|
|
395
|
+
return ran && !builtDom;
|
|
396
|
+
};
|
|
397
|
+
const needsMotionPath = /motionPath\s*[:{]/.test(script);
|
|
398
|
+
if (!needsMotionPath || win.MotionPathPlugin || !win.gsap) {
|
|
399
|
+
if (!swap(currentTime))
|
|
400
|
+
return "cannot-soft-reload";
|
|
401
|
+
return verifyTimelinesPopulated(win, targetKeys) ? "applied" : "verify-failed";
|
|
402
|
+
}
|
|
403
|
+
win.__hfSwapsWaiting = (win.__hfSwapsWaiting ?? 0) + 1;
|
|
404
|
+
return new Promise((settle) => {
|
|
405
|
+
const end = (result) => {
|
|
406
|
+
win.__hfSwapsWaiting = (win.__hfSwapsWaiting ?? 1) - 1;
|
|
407
|
+
settle(result);
|
|
408
|
+
};
|
|
409
|
+
whenMotionPathLoaded(win, doc, () => {
|
|
410
|
+
if (!current())
|
|
411
|
+
return end("superseded");
|
|
412
|
+
const time = win.__player?.getTime?.() ?? currentTime;
|
|
413
|
+
end(swap(time) ? "applied" : "cannot-soft-reload");
|
|
414
|
+
}, () => end(current() ? "cannot-soft-reload" : "superseded"));
|
|
415
|
+
});
|
|
397
416
|
}
|
|
398
417
|
export const MAX_SOFT_RELOAD_SCRIPT = 1_000_000;
|
|
399
418
|
const MAX_SETS = 1_000;
|
|
@@ -486,3 +505,35 @@ export async function softReload(params) {
|
|
|
486
505
|
});
|
|
487
506
|
return { result };
|
|
488
507
|
}
|
|
508
|
+
/** `restore-attributes` with the re-run it may need; any other key still refuses the whole request. */
|
|
509
|
+
export function parseRestoreAttributesRerun(params) {
|
|
510
|
+
if (!isRecord(params) || !("rerun" in params))
|
|
511
|
+
return parseRestoreAttributes(params);
|
|
512
|
+
const { rerun, ...rest } = params;
|
|
513
|
+
const restore = parseRestoreAttributes(rest);
|
|
514
|
+
if (!restore)
|
|
515
|
+
return null;
|
|
516
|
+
const run = parsedRerun(rerun, restore);
|
|
517
|
+
return run ? { ...restore, rerun: run } : restore;
|
|
518
|
+
}
|
|
519
|
+
function parsedRerun(rerun, restore) {
|
|
520
|
+
if (!isRecord(rerun) || Object.keys(rerun).sort().join() !== "authored,script,sets,timing")
|
|
521
|
+
return null;
|
|
522
|
+
const run = parseSoftReload({ ...rerun, time: restore.time, restore: restore.scopes });
|
|
523
|
+
return run && { script: run.script, sets: run.sets, authored: run.authored, timing: run.timing };
|
|
524
|
+
}
|
|
525
|
+
/** An element GSAP has parsed is restored by re-running the script, in the same request that sent it. */
|
|
526
|
+
export async function restoreAttributesOrRerun(params) {
|
|
527
|
+
const outcome = restoreInPlace(params);
|
|
528
|
+
if (outcome !== "gsap-parsed" || !params.rerun)
|
|
529
|
+
return { applied: outcome === "applied", reran: false };
|
|
530
|
+
const { result } = await softReload({
|
|
531
|
+
...params.rerun,
|
|
532
|
+
time: params.time,
|
|
533
|
+
restore: params.scopes,
|
|
534
|
+
});
|
|
535
|
+
return {
|
|
536
|
+
applied: result !== "cannot-soft-reload",
|
|
537
|
+
reran: result === "applied" || result === "verify-failed",
|
|
538
|
+
};
|
|
539
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* otherwise takes straight off the frame's window, which an opaque-origin
|
|
10
10
|
* preview does not allow.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import type { RestoreAttributesParams } from "./editing/restoreAttributes.js";
|
|
13
13
|
import { type EditingGeometryEvent, type WatchGeometryParams } from "./editing/watchGeometry.js";
|
|
14
14
|
import { type EditingElementDescription, type EditingElementHandle, type EditingElementHit, type EditingElementMatch } from "./editingElement.js";
|
|
15
15
|
import type { EditingElementBox, EditingElementGeometry } from "./editingGeometry.js";
|
|
@@ -254,6 +254,7 @@ export interface EditingRequests {
|
|
|
254
254
|
params: RestoreAttributesParams;
|
|
255
255
|
result: {
|
|
256
256
|
applied: boolean;
|
|
257
|
+
reran?: boolean;
|
|
257
258
|
};
|
|
258
259
|
};
|
|
259
260
|
/** Boxes of the words of visible caption groups; a group written as plain text is split into word spans. */
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The editing channel between a preview frame and its parent: a MessagePort the
|
|
3
|
-
* runtime hands the parent once, carrying typed requests and replies. The
|
|
4
|
-
* runtime side is `editingAgent.ts`; `createEditingPortClient` is the parent
|
|
5
|
-
* side. Both import their wire types from here, so they cannot drift apart.
|
|
6
|
-
*
|
|
7
|
-
* Playback transport (play, pause, seek, rate, mute, play range) stays on the
|
|
8
|
-
* control protocol in `bridge.ts`. This channel carries the reads a parent
|
|
9
|
-
* otherwise takes straight off the frame's window, which an opaque-origin
|
|
10
|
-
* preview does not allow.
|
|
11
|
-
*/
|
|
12
|
-
import { parseRestoreAttributes } from "./editing/restoreAttributes.js";
|
|
13
1
|
import { geometryEvent, parseWatchGeometry, } from "./editing/watchGeometry.js";
|
|
14
2
|
import { EDITING_ELEMENT_HANDLE, MAX_DESCRIBE_HANDLES, } from "./editingElement.js";
|
|
15
3
|
import { parseGsapSet } from "./editing/gsapSet.js";
|
|
16
4
|
import { parsePatchTweens } from "./editing/patchTween.js";
|
|
17
|
-
import { parseSoftReload, } from "./editing/softReload.js";
|
|
5
|
+
import { parseRestoreAttributesRerun, parseSoftReload, } from "./editing/softReload.js";
|
|
18
6
|
import { parseHoldScenes, parseMarkScenesStale, parseSwapScenes, } from "./editing/scenes.js";
|
|
19
7
|
import { parseLiveRetime, } from "./editing/liveRetime.js";
|
|
20
8
|
import { wallClearTimeout, wallSetTimeout } from "./wallClock.js";
|
|
@@ -249,7 +237,7 @@ const PARAM_PARSERS = {
|
|
|
249
237
|
"gesture-start": handleList,
|
|
250
238
|
"console-errors": (params) => hasKeys(params, "from") && isOffset(params.from) ? { from: params.from } : null,
|
|
251
239
|
"watch-keys": comboList,
|
|
252
|
-
"restore-attributes":
|
|
240
|
+
"restore-attributes": parseRestoreAttributesRerun,
|
|
253
241
|
"caption-words": captionWordsParams,
|
|
254
242
|
"caption-transform": captionTransformParams,
|
|
255
243
|
"color-grading-status": parseColorGradingStatusParams,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.80",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -493,9 +493,9 @@
|
|
|
493
493
|
"linkedom": "^0.18.12",
|
|
494
494
|
"postcss": "^8.5.8",
|
|
495
495
|
"wawoff2": "^2.0.1",
|
|
496
|
-
"@hyperframes/lint": "0.9.
|
|
497
|
-
"@hyperframes/
|
|
498
|
-
"@hyperframes/
|
|
496
|
+
"@hyperframes/lint": "0.9.80",
|
|
497
|
+
"@hyperframes/parsers": "0.9.80",
|
|
498
|
+
"@hyperframes/studio-server": "0.9.80"
|
|
499
499
|
},
|
|
500
500
|
"devDependencies": {
|
|
501
501
|
"@fontsource/archivo-black": "^5.2.8",
|