@hyperframes/studio 0.9.1 → 0.9.3
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/assets/{hyperframes-player-D2rjxvnX.js → hyperframes-player-BHCO0AJz.js} +1 -1
- package/dist/assets/{index-Dh1BiGcb.js → index-CWzE624c.js} +155 -155
- package/dist/assets/{index-CgtbZxHa.js → index-VhjEqQ4-.js} +1 -1
- package/dist/{chunk-CM72ZNGU.js → chunk-LBXOFI5I.js} +615 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.html +1 -1
- package/dist/index.js +42 -585
- package/dist/player.js +1 -1
- package/package.json +8 -8
- package/src/index.ts +3 -0
- package/src/player/components/studioCombo.test.ts +21 -1
- package/src/player/components/studioShortcuts.ts +14 -0
- package/src/player/hooks/useShadowPreviewReload.ts +10 -3
- package/src/player/hooks/useTimelinePlayer.shadowReload.test.ts +67 -0
- package/src/player/hooks/useTimelinePlayer.ts +2 -9
- package/src/player/sceneSwap.ts +36 -0
- package/src/utils/studioFileVersion.test.ts +15 -0
- package/src/utils/studioFileVersion.ts +7 -0
package/dist/index.js
CHANGED
|
@@ -3,11 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-C5BDT7NG.js";
|
|
4
4
|
import {
|
|
5
5
|
DOCK_PANEL_COMPONENT,
|
|
6
|
+
MAX_VISIBLE_THUMBNAIL_FRAMES,
|
|
6
7
|
PANEL_DEFINITIONS,
|
|
7
8
|
PANEL_IDS,
|
|
8
9
|
Player,
|
|
9
10
|
STUDIO_PREVIEW_FPS,
|
|
10
11
|
TIMELINE_RANGE_MARGIN_PX,
|
|
12
|
+
TIMELINE_VIEWPORT_BUDGETS,
|
|
11
13
|
announcePreviewDocumentLoaded,
|
|
12
14
|
announcePreviewPromoted,
|
|
13
15
|
applyPreviewVariablesToUrl,
|
|
@@ -15,6 +17,9 @@ import {
|
|
|
15
17
|
clampToDuration,
|
|
16
18
|
collectElementPatches,
|
|
17
19
|
computePinnedZoomPercent,
|
|
20
|
+
consumeStudioWriteToken,
|
|
21
|
+
createThumbnailKey,
|
|
22
|
+
createThumbnailRequestIdentity,
|
|
18
23
|
createTimelineResetState,
|
|
19
24
|
effectiveThumbnailMode,
|
|
20
25
|
formatFrameTime,
|
|
@@ -24,12 +29,17 @@ import {
|
|
|
24
29
|
getPinchTimelineZoomPercent,
|
|
25
30
|
getTimelinePixelsPerSecond,
|
|
26
31
|
getTimelineZoomPercent,
|
|
32
|
+
giveUpOnPreviewChange,
|
|
27
33
|
isFocusedEaseRequestCurrent,
|
|
28
34
|
isPanelId,
|
|
29
35
|
isPreviewBooted,
|
|
36
|
+
isPreviewChanging,
|
|
30
37
|
isRevealedAudioFxRequestCurrent,
|
|
31
38
|
liveTime,
|
|
39
|
+
logReload,
|
|
40
|
+
makeStudioDebugLogger,
|
|
32
41
|
markScenesStale,
|
|
42
|
+
markStudioWriteToken,
|
|
33
43
|
onPreviewContentReplaced,
|
|
34
44
|
onPreviewDocumentLoaded,
|
|
35
45
|
onPreviewPromoted,
|
|
@@ -40,21 +50,31 @@ import {
|
|
|
40
50
|
parsePreviewFacts,
|
|
41
51
|
patchElements,
|
|
42
52
|
positiveClipSpan,
|
|
53
|
+
previewReloadBegun,
|
|
43
54
|
readStudioUiPreferences,
|
|
55
|
+
requestPreviewReload,
|
|
44
56
|
sceneSwapFor,
|
|
45
57
|
secondsToFrame,
|
|
58
|
+
setPreviewReloading,
|
|
46
59
|
stepFrameTime,
|
|
60
|
+
studioExpectedFileVersion,
|
|
61
|
+
studioFileContentVersion,
|
|
62
|
+
studioFileRevision,
|
|
63
|
+
studioWriteHeaders,
|
|
47
64
|
supersededByNewerEdit,
|
|
65
|
+
swapFreshly,
|
|
48
66
|
thumbnailRevisionOf,
|
|
67
|
+
thumbnailScheduler,
|
|
49
68
|
timelineSliderToZoomPercent,
|
|
50
69
|
timelineZoomPercentToSlider,
|
|
51
70
|
useMountEffect,
|
|
52
71
|
usePlayerStore,
|
|
53
72
|
usePreviewVariablesStore,
|
|
54
73
|
whenPreviewBooted,
|
|
74
|
+
whileScriptWrites,
|
|
55
75
|
writeStudioUiPreferences,
|
|
56
76
|
zoomToSelectedClips
|
|
57
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-LBXOFI5I.js";
|
|
58
78
|
import {
|
|
59
79
|
Button,
|
|
60
80
|
ContextMenu,
|
|
@@ -356,6 +376,15 @@ function findClash(keys) {
|
|
|
356
376
|
}
|
|
357
377
|
return null;
|
|
358
378
|
}
|
|
379
|
+
function studioKeyClash(action, text, keys = current) {
|
|
380
|
+
const wanted = parseCombo(text);
|
|
381
|
+
const holds = (other) => {
|
|
382
|
+
const held = parseCombo(keys[other]);
|
|
383
|
+
return !!held && !!wanted && comboClashKey(held) === comboClashKey(wanted);
|
|
384
|
+
};
|
|
385
|
+
const keyed = Object.keys(keys);
|
|
386
|
+
return keyed.find((o) => o !== action && !sharedByDesign(action, o) && holds(o)) ?? null;
|
|
387
|
+
}
|
|
359
388
|
function resolve(overrides) {
|
|
360
389
|
const next = { ...DEFAULT_STUDIO_KEYS };
|
|
361
390
|
for (const [action, text] of Object.entries(overrides)) {
|
|
@@ -2535,63 +2564,6 @@ function resolveTimelineAssetDrop(input, clientX, clientY) {
|
|
|
2535
2564
|
};
|
|
2536
2565
|
}
|
|
2537
2566
|
|
|
2538
|
-
// src/player/lib/timelineViewportBudgets.ts
|
|
2539
|
-
var MEBIBYTE = 1024 * 1024;
|
|
2540
|
-
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
2541
|
-
var MAX_VISIBLE_THUMBNAIL_FRAMES = Math.ceil(3840 / (66 * (16 / 9)));
|
|
2542
|
-
var TIMELINE_VIEWPORT_BUDGETS = Object.freeze({
|
|
2543
|
-
directScrollSafetyPx: 8e6,
|
|
2544
|
-
rowOverscanPerSide: 2,
|
|
2545
|
-
timeOverscanViewportRatio: 0.25,
|
|
2546
|
-
maxMountedRows: 64,
|
|
2547
|
-
maxMountedClipRoots: 512,
|
|
2548
|
-
maxMountedClipRootsPerRow: 128,
|
|
2549
|
-
maxMountedTimelineDescendants: 5e3,
|
|
2550
|
-
posterMaxPhysicalWidth: 240,
|
|
2551
|
-
posterMaxPhysicalHeight: 135,
|
|
2552
|
-
posterDprCap: 1.5,
|
|
2553
|
-
richPreviewFrameCount: MAX_VISIBLE_THUMBNAIL_FRAMES,
|
|
2554
|
-
concurrentVideoDecodes: 2,
|
|
2555
|
-
concurrentMetadataJobs: 4,
|
|
2556
|
-
concurrentCompositionFetches: 2,
|
|
2557
|
-
concurrentServerPages: 1,
|
|
2558
|
-
thumbnailLoadTimeoutMs: 3e4,
|
|
2559
|
-
thumbnailCacheBytes: 64 * MEBIBYTE,
|
|
2560
|
-
sharedFrameCacheBytes: 32 * MEBIBYTE,
|
|
2561
|
-
thumbnailSourceIdleMs: 1e4,
|
|
2562
|
-
thumbnailCacheEntries: 256,
|
|
2563
|
-
thumbnailCacheEntriesPerProject: 96,
|
|
2564
|
-
metadataRegistryEntries: 512,
|
|
2565
|
-
metadataFailureTtlMs: 3e4,
|
|
2566
|
-
waveformCacheBytes: 16 * MEBIBYTE,
|
|
2567
|
-
waveformCacheEntries: 256,
|
|
2568
|
-
compositionDiskCacheBytes: 512 * MEBIBYTE,
|
|
2569
|
-
compositionDiskCacheMaxAgeMs: 14 * DAY_MS,
|
|
2570
|
-
interactionP95Ms: 50,
|
|
2571
|
-
frameIntervalP95Ms: 33.3,
|
|
2572
|
-
constrainedInteractionP95Ms: 75,
|
|
2573
|
-
constrainedFrameIntervalP95Ms: 75,
|
|
2574
|
-
ciVirtualizedInteractionP95Ms: 58.3,
|
|
2575
|
-
ciVirtualizedFrameIntervalP95Ms: 25,
|
|
2576
|
-
longTaskLimitMs: 50,
|
|
2577
|
-
constrainedLongTaskLimitMs: 300,
|
|
2578
|
-
memoryReturnToleranceRatio: 0.15,
|
|
2579
|
-
posterColdP95Ms: 750,
|
|
2580
|
-
posterCachedP95Ms: 250,
|
|
2581
|
-
constrainedPosterColdP95Ms: 1200,
|
|
2582
|
-
constrainedPosterCachedP95Ms: 400,
|
|
2583
|
-
posterCoverageRatio: 0.9,
|
|
2584
|
-
posterCoverageSettleMs: 1500,
|
|
2585
|
-
constrainedPosterCoverageSettleMs: 2500,
|
|
2586
|
-
richPreviewP95Ms: 750,
|
|
2587
|
-
constrainedRichPreviewP95Ms: 1200,
|
|
2588
|
-
supportedFixtureFallbackRatio: 0.02,
|
|
2589
|
-
scrollSamplesPerRun: 63,
|
|
2590
|
-
warmupRuns: 3,
|
|
2591
|
-
measuredRuns: 5,
|
|
2592
|
-
requiredPassingRuns: 4
|
|
2593
|
-
});
|
|
2594
|
-
|
|
2595
2567
|
// src/player/components/timelineViewportGeometry.ts
|
|
2596
2568
|
function getTimelineRenderTimeRange(viewport2, pixelsPerSecond, contentOrigin, duration) {
|
|
2597
2569
|
if (!(pixelsPerSecond > 0) || !(duration > 0) || !(viewport2.clientWidth > 0)) {
|
|
@@ -16265,407 +16237,6 @@ import { fadeGain } from "@hyperframes/core/audio-fade";
|
|
|
16265
16237
|
|
|
16266
16238
|
// src/hooks/useThumbnailLease.ts
|
|
16267
16239
|
import { useCallback as useCallback25, useLayoutEffect as useLayoutEffect8, useRef as useRef30, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
16268
|
-
|
|
16269
|
-
// src/player/lib/thumbnailScheduler.ts
|
|
16270
|
-
var PRIORITY_SCORE = {
|
|
16271
|
-
overscan: 0,
|
|
16272
|
-
visible: 1,
|
|
16273
|
-
interaction: 2
|
|
16274
|
-
};
|
|
16275
|
-
var EMPTY_SNAPSHOT = Object.freeze({ status: "idle" });
|
|
16276
|
-
function concurrencyBucket(kind) {
|
|
16277
|
-
if (kind === "video") return "video";
|
|
16278
|
-
if (kind === "composition") return "composition";
|
|
16279
|
-
return "general";
|
|
16280
|
-
}
|
|
16281
|
-
function errorFrom(reason) {
|
|
16282
|
-
return reason instanceof Error ? reason : new Error(String(reason));
|
|
16283
|
-
}
|
|
16284
|
-
function createThumbnailKey(parts) {
|
|
16285
|
-
return Object.entries(parts).filter((entry3) => entry3[1] !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(String(value))}`).join("&");
|
|
16286
|
-
}
|
|
16287
|
-
function createThumbnailRequestIdentity(request2) {
|
|
16288
|
-
return createThumbnailKey({
|
|
16289
|
-
project: request2.projectId,
|
|
16290
|
-
session: request2.sessionEpoch,
|
|
16291
|
-
request: request2.key,
|
|
16292
|
-
kind: request2.kind,
|
|
16293
|
-
rich: request2.rich ? 1 : 0
|
|
16294
|
-
});
|
|
16295
|
-
}
|
|
16296
|
-
var ThumbnailScheduler = class {
|
|
16297
|
-
entries = /* @__PURE__ */ new Map();
|
|
16298
|
-
budgets;
|
|
16299
|
-
nextLeaseId = 1;
|
|
16300
|
-
nextSequence = 1;
|
|
16301
|
-
scrolling = false;
|
|
16302
|
-
previewReloading = false;
|
|
16303
|
-
playbackActive = false;
|
|
16304
|
-
pageHidden = false;
|
|
16305
|
-
cacheBytes = 0;
|
|
16306
|
-
waveformCacheBytes = 0;
|
|
16307
|
-
activeByBucket = { video: 0, composition: 0, general: 0 };
|
|
16308
|
-
activeByKind = {
|
|
16309
|
-
video: 0,
|
|
16310
|
-
image: 0,
|
|
16311
|
-
composition: 0,
|
|
16312
|
-
waveform: 0
|
|
16313
|
-
};
|
|
16314
|
-
now;
|
|
16315
|
-
constructor(budgets = TIMELINE_VIEWPORT_BUDGETS, now2 = Date.now) {
|
|
16316
|
-
this.budgets = budgets;
|
|
16317
|
-
this.now = now2;
|
|
16318
|
-
}
|
|
16319
|
-
acquire(request2, listener2) {
|
|
16320
|
-
const scopedKey = createThumbnailRequestIdentity(request2);
|
|
16321
|
-
let entry3 = this.entries.get(scopedKey);
|
|
16322
|
-
if (entry3?.state === "error" && entry3.failedAt !== void 0 && this.now() - entry3.failedAt >= this.budgets.metadataFailureTtlMs) {
|
|
16323
|
-
this.deleteEntry(scopedKey, entry3);
|
|
16324
|
-
entry3 = this.entries.get(scopedKey);
|
|
16325
|
-
}
|
|
16326
|
-
if (!entry3) {
|
|
16327
|
-
entry3 = {
|
|
16328
|
-
request: request2,
|
|
16329
|
-
scopedKey,
|
|
16330
|
-
state: "queued",
|
|
16331
|
-
leases: /* @__PURE__ */ new Map(),
|
|
16332
|
-
listeners: /* @__PURE__ */ new Map(),
|
|
16333
|
-
controller: null,
|
|
16334
|
-
weight: 0,
|
|
16335
|
-
disposed: false,
|
|
16336
|
-
cached: false,
|
|
16337
|
-
lastAccess: this.nextSequence++,
|
|
16338
|
-
snapshot: Object.freeze({ status: "queued" }),
|
|
16339
|
-
preempted: false
|
|
16340
|
-
};
|
|
16341
|
-
this.entries.set(scopedKey, entry3);
|
|
16342
|
-
}
|
|
16343
|
-
const leaseId = this.nextLeaseId++;
|
|
16344
|
-
entry3.leases.set(leaseId, request2.priority);
|
|
16345
|
-
entry3.listeners.set(leaseId, listener2);
|
|
16346
|
-
entry3.lastAccess = this.nextSequence++;
|
|
16347
|
-
this.pump();
|
|
16348
|
-
let released2 = false;
|
|
16349
|
-
return {
|
|
16350
|
-
updatePriority: (priority) => {
|
|
16351
|
-
const current2 = this.entries.get(scopedKey);
|
|
16352
|
-
if (!current2 || !current2.leases.has(leaseId)) return;
|
|
16353
|
-
current2.leases.set(leaseId, priority);
|
|
16354
|
-
current2.lastAccess = this.nextSequence++;
|
|
16355
|
-
this.pump();
|
|
16356
|
-
},
|
|
16357
|
-
release: () => {
|
|
16358
|
-
if (released2) return;
|
|
16359
|
-
released2 = true;
|
|
16360
|
-
const current2 = this.entries.get(scopedKey);
|
|
16361
|
-
if (!current2) return;
|
|
16362
|
-
current2.leases.delete(leaseId);
|
|
16363
|
-
current2.listeners.delete(leaseId);
|
|
16364
|
-
if (current2.leases.size === 0) {
|
|
16365
|
-
if (current2.state === "queued") {
|
|
16366
|
-
this.deleteEntry(scopedKey, current2);
|
|
16367
|
-
} else if (current2.state === "loading") {
|
|
16368
|
-
current2.controller?.abort();
|
|
16369
|
-
this.deleteEntry(scopedKey, current2);
|
|
16370
|
-
} else if (current2.state === "ready" && !current2.cached) {
|
|
16371
|
-
this.deleteEntry(scopedKey, current2);
|
|
16372
|
-
}
|
|
16373
|
-
}
|
|
16374
|
-
this.evict();
|
|
16375
|
-
}
|
|
16376
|
-
};
|
|
16377
|
-
}
|
|
16378
|
-
getSnapshot(request2) {
|
|
16379
|
-
const entry3 = this.entries.get(createThumbnailRequestIdentity(request2));
|
|
16380
|
-
if (!entry3) return EMPTY_SNAPSHOT;
|
|
16381
|
-
return entry3.snapshot;
|
|
16382
|
-
}
|
|
16383
|
-
setScrolling(scrolling) {
|
|
16384
|
-
if (this.scrolling === scrolling) return;
|
|
16385
|
-
this.scrolling = scrolling;
|
|
16386
|
-
if (!scrolling) this.pump();
|
|
16387
|
-
}
|
|
16388
|
-
/** Holds composition renders while the preview loads: same server, and the preview is what the person awaits. */
|
|
16389
|
-
setPreviewReloading(reloading2) {
|
|
16390
|
-
if (this.previewReloading === reloading2) return;
|
|
16391
|
-
this.previewReloading = reloading2;
|
|
16392
|
-
if (!reloading2) {
|
|
16393
|
-
this.pump();
|
|
16394
|
-
return;
|
|
16395
|
-
}
|
|
16396
|
-
for (const entry3 of this.entries.values()) {
|
|
16397
|
-
if (entry3.state !== "loading" || entry3.request.kind !== "composition") continue;
|
|
16398
|
-
this.preempt(entry3);
|
|
16399
|
-
}
|
|
16400
|
-
}
|
|
16401
|
-
setPlaybackActive(active) {
|
|
16402
|
-
if (this.playbackActive === active) return;
|
|
16403
|
-
this.playbackActive = active;
|
|
16404
|
-
if (!active) this.pump();
|
|
16405
|
-
}
|
|
16406
|
-
setPageHidden(hidden) {
|
|
16407
|
-
if (this.pageHidden === hidden) return;
|
|
16408
|
-
this.pageHidden = hidden;
|
|
16409
|
-
if (!hidden) {
|
|
16410
|
-
this.pump();
|
|
16411
|
-
return;
|
|
16412
|
-
}
|
|
16413
|
-
for (const entry3 of this.entries.values()) {
|
|
16414
|
-
if (entry3.state === "loading") this.preempt(entry3);
|
|
16415
|
-
}
|
|
16416
|
-
}
|
|
16417
|
-
preempt(entry3) {
|
|
16418
|
-
entry3.preempted = true;
|
|
16419
|
-
entry3.controller?.abort();
|
|
16420
|
-
}
|
|
16421
|
-
/** Evict project cache entries that are no longer owned by mounted consumers. */
|
|
16422
|
-
invalidateProject(projectId) {
|
|
16423
|
-
for (const [key2, entry3] of this.entries) {
|
|
16424
|
-
if (entry3.request.projectId !== projectId) continue;
|
|
16425
|
-
if (entry3.leases.size > 0) continue;
|
|
16426
|
-
entry3.controller?.abort();
|
|
16427
|
-
this.deleteEntry(key2, entry3);
|
|
16428
|
-
}
|
|
16429
|
-
}
|
|
16430
|
-
getDiagnostics() {
|
|
16431
|
-
let queued = 0;
|
|
16432
|
-
let active = 0;
|
|
16433
|
-
let leases = 0;
|
|
16434
|
-
let cacheEntries = 0;
|
|
16435
|
-
let waveformCacheEntries = 0;
|
|
16436
|
-
for (const entry3 of this.entries.values()) {
|
|
16437
|
-
if (entry3.state === "queued") queued++;
|
|
16438
|
-
if (entry3.state === "loading") active++;
|
|
16439
|
-
if (entry3.cached) {
|
|
16440
|
-
if (entry3.request.kind === "waveform") waveformCacheEntries++;
|
|
16441
|
-
else cacheEntries++;
|
|
16442
|
-
}
|
|
16443
|
-
leases += entry3.leases.size;
|
|
16444
|
-
}
|
|
16445
|
-
return {
|
|
16446
|
-
queued,
|
|
16447
|
-
active,
|
|
16448
|
-
leases,
|
|
16449
|
-
cacheEntries,
|
|
16450
|
-
cacheBytes: this.cacheBytes,
|
|
16451
|
-
waveformCacheEntries,
|
|
16452
|
-
waveformCacheBytes: this.waveformCacheBytes,
|
|
16453
|
-
activeByKind: { ...this.activeByKind }
|
|
16454
|
-
};
|
|
16455
|
-
}
|
|
16456
|
-
pump() {
|
|
16457
|
-
if (this.pageHidden) return;
|
|
16458
|
-
const queued = Array.from(this.entries.values()).filter((entry3) => entry3.state === "queued" && entry3.leases.size > 0).sort((left, right) => {
|
|
16459
|
-
const priorityDelta = this.entryPriority(right) - this.entryPriority(left);
|
|
16460
|
-
return priorityDelta || left.lastAccess - right.lastAccess;
|
|
16461
|
-
});
|
|
16462
|
-
for (const entry3 of queued) {
|
|
16463
|
-
if (this.isHeld(entry3)) continue;
|
|
16464
|
-
const bucket = concurrencyBucket(entry3.request.kind);
|
|
16465
|
-
if (this.activeByBucket[bucket] >= this.bucketLimit(bucket)) continue;
|
|
16466
|
-
this.start(entry3, bucket);
|
|
16467
|
-
}
|
|
16468
|
-
}
|
|
16469
|
-
isHeld(entry3) {
|
|
16470
|
-
const { kind, rich } = entry3.request;
|
|
16471
|
-
if (this.scrolling && rich) return true;
|
|
16472
|
-
if (this.previewReloading && kind === "composition") return true;
|
|
16473
|
-
return this.playbackActive && kind === "video" && this.entryPriority(entry3) < PRIORITY_SCORE.interaction;
|
|
16474
|
-
}
|
|
16475
|
-
start(entry3, bucket) {
|
|
16476
|
-
entry3.state = "loading";
|
|
16477
|
-
entry3.snapshot = Object.freeze({ status: "loading" });
|
|
16478
|
-
const controller = new AbortController();
|
|
16479
|
-
entry3.controller = controller;
|
|
16480
|
-
this.activeByBucket[bucket]++;
|
|
16481
|
-
this.activeByKind[entry3.request.kind]++;
|
|
16482
|
-
let slotFree = false;
|
|
16483
|
-
const freeSlot = () => {
|
|
16484
|
-
if (slotFree) return;
|
|
16485
|
-
slotFree = true;
|
|
16486
|
-
this.activeByBucket[bucket]--;
|
|
16487
|
-
this.activeByKind[entry3.request.kind]--;
|
|
16488
|
-
queueMicrotask(() => this.pump());
|
|
16489
|
-
};
|
|
16490
|
-
controller.signal.addEventListener("abort", freeSlot, { once: true });
|
|
16491
|
-
this.notify(entry3);
|
|
16492
|
-
const pending2 = this.loadWithTimeout(entry3, controller);
|
|
16493
|
-
void pending2.then((result) => this.acceptResult(entry3, controller, result)).catch((reason) => {
|
|
16494
|
-
if (this.entries.get(entry3.scopedKey) !== entry3) return;
|
|
16495
|
-
if (controller.signal.aborted && entry3.leases.size === 0) {
|
|
16496
|
-
this.deleteEntry(entry3.scopedKey, entry3);
|
|
16497
|
-
return;
|
|
16498
|
-
}
|
|
16499
|
-
if (this.requeuePreempted(entry3)) return;
|
|
16500
|
-
entry3.state = "error";
|
|
16501
|
-
entry3.error = errorFrom(reason);
|
|
16502
|
-
entry3.failedAt = this.now();
|
|
16503
|
-
entry3.snapshot = Object.freeze({ status: "error", error: entry3.error });
|
|
16504
|
-
this.notify(entry3);
|
|
16505
|
-
this.evictFailures();
|
|
16506
|
-
}).finally(() => {
|
|
16507
|
-
if (entry3.controller === controller) entry3.controller = null;
|
|
16508
|
-
freeSlot();
|
|
16509
|
-
this.pump();
|
|
16510
|
-
});
|
|
16511
|
-
}
|
|
16512
|
-
acceptResult(entry3, controller, result) {
|
|
16513
|
-
if (controller.signal.aborted || this.entries.get(entry3.scopedKey) !== entry3) {
|
|
16514
|
-
this.safeDispose(result.dispose);
|
|
16515
|
-
this.requeuePreempted(entry3);
|
|
16516
|
-
return;
|
|
16517
|
-
}
|
|
16518
|
-
this.validateResult(result);
|
|
16519
|
-
entry3.state = "ready";
|
|
16520
|
-
entry3.value = result.value;
|
|
16521
|
-
entry3.weight = result.weight;
|
|
16522
|
-
entry3.dispose = result.dispose;
|
|
16523
|
-
this.cacheResult(entry3);
|
|
16524
|
-
entry3.snapshot = Object.freeze({ status: "ready", value: result.value });
|
|
16525
|
-
this.notify(entry3);
|
|
16526
|
-
this.evict();
|
|
16527
|
-
if (!entry3.cached && entry3.leases.size === 0) this.deleteEntry(entry3.scopedKey, entry3);
|
|
16528
|
-
}
|
|
16529
|
-
requeuePreempted(entry3) {
|
|
16530
|
-
if (!entry3.preempted || this.entries.get(entry3.scopedKey) !== entry3) return false;
|
|
16531
|
-
entry3.preempted = false;
|
|
16532
|
-
entry3.state = "queued";
|
|
16533
|
-
entry3.snapshot = Object.freeze({ status: "queued" });
|
|
16534
|
-
this.notify(entry3);
|
|
16535
|
-
return true;
|
|
16536
|
-
}
|
|
16537
|
-
validateResult(result) {
|
|
16538
|
-
if (Number.isFinite(result.weight) && result.weight >= 0) return;
|
|
16539
|
-
this.safeDispose(result.dispose);
|
|
16540
|
-
throw new RangeError("Thumbnail result weight must be finite and non-negative");
|
|
16541
|
-
}
|
|
16542
|
-
cacheResult(entry3) {
|
|
16543
|
-
const isWaveform = entry3.request.kind === "waveform";
|
|
16544
|
-
const byteBudget = isWaveform ? this.budgets.waveformCacheBytes : this.budgets.thumbnailCacheBytes;
|
|
16545
|
-
entry3.cached = !entry3.request.discardWhenReleased && entry3.weight <= byteBudget;
|
|
16546
|
-
if (!entry3.cached) return;
|
|
16547
|
-
if (isWaveform) this.waveformCacheBytes += entry3.weight;
|
|
16548
|
-
else this.cacheBytes += entry3.weight;
|
|
16549
|
-
}
|
|
16550
|
-
entryPriority(entry3) {
|
|
16551
|
-
let score = -1;
|
|
16552
|
-
for (const priority of entry3.leases.values()) {
|
|
16553
|
-
score = Math.max(score, PRIORITY_SCORE[priority]);
|
|
16554
|
-
}
|
|
16555
|
-
return score;
|
|
16556
|
-
}
|
|
16557
|
-
bucketLimit(bucket) {
|
|
16558
|
-
if (bucket === "video") return this.budgets.concurrentVideoDecodes;
|
|
16559
|
-
if (bucket === "composition") return this.budgets.concurrentCompositionFetches;
|
|
16560
|
-
return this.budgets.concurrentMetadataJobs;
|
|
16561
|
-
}
|
|
16562
|
-
evict() {
|
|
16563
|
-
this.evictPartition(false);
|
|
16564
|
-
this.evictPartition(true);
|
|
16565
|
-
}
|
|
16566
|
-
evictPartition(waveform) {
|
|
16567
|
-
const cached5 = Array.from(this.entries.values()).filter(
|
|
16568
|
-
(entry3) => entry3.cached && entry3.request.kind === "waveform" === waveform
|
|
16569
|
-
);
|
|
16570
|
-
const perProject = /* @__PURE__ */ new Map();
|
|
16571
|
-
for (const entry3 of cached5) {
|
|
16572
|
-
perProject.set(entry3.request.projectId, (perProject.get(entry3.request.projectId) ?? 0) + 1);
|
|
16573
|
-
}
|
|
16574
|
-
cached5.sort((left, right) => left.lastAccess - right.lastAccess);
|
|
16575
|
-
let cacheEntries = cached5.length;
|
|
16576
|
-
for (const entry3 of cached5) {
|
|
16577
|
-
const projectEntries = perProject.get(entry3.request.projectId) ?? 0;
|
|
16578
|
-
if (!this.isCacheOverBudget(waveform, cacheEntries, projectEntries)) continue;
|
|
16579
|
-
this.uncache(entry3);
|
|
16580
|
-
cacheEntries--;
|
|
16581
|
-
perProject.set(entry3.request.projectId, projectEntries - 1);
|
|
16582
|
-
if (entry3.leases.size === 0) this.deleteEntry(entry3.scopedKey, entry3);
|
|
16583
|
-
}
|
|
16584
|
-
}
|
|
16585
|
-
isCacheOverBudget(waveform, cacheEntries, projectEntries) {
|
|
16586
|
-
const entryBudget = waveform ? this.budgets.waveformCacheEntries : this.budgets.thumbnailCacheEntries;
|
|
16587
|
-
const byteBudget = waveform ? this.budgets.waveformCacheBytes : this.budgets.thumbnailCacheBytes;
|
|
16588
|
-
const cacheBytes = waveform ? this.waveformCacheBytes : this.cacheBytes;
|
|
16589
|
-
const projectOverBudget = !waveform && projectEntries > this.budgets.thumbnailCacheEntriesPerProject;
|
|
16590
|
-
return cacheEntries > entryBudget || cacheBytes > byteBudget || projectOverBudget;
|
|
16591
|
-
}
|
|
16592
|
-
uncache(entry3) {
|
|
16593
|
-
entry3.cached = false;
|
|
16594
|
-
if (entry3.request.kind === "waveform") this.waveformCacheBytes -= entry3.weight;
|
|
16595
|
-
else this.cacheBytes -= entry3.weight;
|
|
16596
|
-
}
|
|
16597
|
-
notify(entry3) {
|
|
16598
|
-
for (const listener2 of new Set(entry3.listeners.values())) listener2();
|
|
16599
|
-
}
|
|
16600
|
-
loadWithTimeout(entry3, controller) {
|
|
16601
|
-
let load;
|
|
16602
|
-
try {
|
|
16603
|
-
load = entry3.request.load(controller.signal);
|
|
16604
|
-
} catch (reason) {
|
|
16605
|
-
load = Promise.reject(reason);
|
|
16606
|
-
}
|
|
16607
|
-
return new Promise((resolve2, reject) => {
|
|
16608
|
-
let settled = false;
|
|
16609
|
-
const timeout = setTimeout(() => {
|
|
16610
|
-
if (settled) return;
|
|
16611
|
-
settled = true;
|
|
16612
|
-
const message = `Thumbnail load timed out after ${this.budgets.thumbnailLoadTimeoutMs}ms`;
|
|
16613
|
-
controller.abort(new DOMException(message, "TimeoutError"));
|
|
16614
|
-
reject(new Error(message));
|
|
16615
|
-
}, this.budgets.thumbnailLoadTimeoutMs);
|
|
16616
|
-
load.then(
|
|
16617
|
-
(result) => {
|
|
16618
|
-
if (settled) {
|
|
16619
|
-
this.safeDispose(result.dispose);
|
|
16620
|
-
return;
|
|
16621
|
-
}
|
|
16622
|
-
settled = true;
|
|
16623
|
-
clearTimeout(timeout);
|
|
16624
|
-
resolve2(result);
|
|
16625
|
-
},
|
|
16626
|
-
(reason) => {
|
|
16627
|
-
if (settled) return;
|
|
16628
|
-
settled = true;
|
|
16629
|
-
clearTimeout(timeout);
|
|
16630
|
-
reject(reason);
|
|
16631
|
-
}
|
|
16632
|
-
);
|
|
16633
|
-
});
|
|
16634
|
-
}
|
|
16635
|
-
deleteEntry(key2, entry3) {
|
|
16636
|
-
if (this.entries.get(key2) !== entry3) return;
|
|
16637
|
-
this.entries.delete(key2);
|
|
16638
|
-
entry3.snapshot = EMPTY_SNAPSHOT;
|
|
16639
|
-
this.notify(entry3);
|
|
16640
|
-
if (entry3.cached) {
|
|
16641
|
-
entry3.cached = false;
|
|
16642
|
-
if (entry3.request.kind === "waveform") this.waveformCacheBytes -= entry3.weight;
|
|
16643
|
-
else this.cacheBytes -= entry3.weight;
|
|
16644
|
-
}
|
|
16645
|
-
if (!entry3.disposed) {
|
|
16646
|
-
entry3.disposed = true;
|
|
16647
|
-
this.safeDispose(entry3.dispose);
|
|
16648
|
-
}
|
|
16649
|
-
entry3.listeners.clear();
|
|
16650
|
-
entry3.leases.clear();
|
|
16651
|
-
}
|
|
16652
|
-
evictFailures() {
|
|
16653
|
-
const failed2 = Array.from(this.entries.values()).filter((entry3) => entry3.state === "error" && entry3.leases.size === 0).sort((left, right) => left.lastAccess - right.lastAccess);
|
|
16654
|
-
const overflow = failed2.length - this.budgets.thumbnailCacheEntries;
|
|
16655
|
-
for (const entry3 of failed2.slice(0, Math.max(0, overflow))) {
|
|
16656
|
-
this.deleteEntry(entry3.scopedKey, entry3);
|
|
16657
|
-
}
|
|
16658
|
-
}
|
|
16659
|
-
safeDispose(dispose2) {
|
|
16660
|
-
try {
|
|
16661
|
-
dispose2?.();
|
|
16662
|
-
} catch {
|
|
16663
|
-
}
|
|
16664
|
-
}
|
|
16665
|
-
};
|
|
16666
|
-
var thumbnailScheduler = new ThumbnailScheduler();
|
|
16667
|
-
|
|
16668
|
-
// src/hooks/useThumbnailLease.ts
|
|
16669
16240
|
var IDLE = Object.freeze({ status: "idle" });
|
|
16670
16241
|
function useThumbnailLease(request2, scheduler = thumbnailScheduler) {
|
|
16671
16242
|
const requestRef = useRef30(request2);
|
|
@@ -18410,54 +17981,6 @@ function patchDocumentRootDuration(doc, contentEnd) {
|
|
|
18410
17981
|
return true;
|
|
18411
17982
|
}
|
|
18412
17983
|
|
|
18413
|
-
// src/utils/studioFileVersion.ts
|
|
18414
|
-
var WRITE_TOKEN_TTL_MS = 5 * 6e4;
|
|
18415
|
-
var studioWriteTokens = /* @__PURE__ */ new Map();
|
|
18416
|
-
function pruneStudioWriteTokens(now2) {
|
|
18417
|
-
for (const [token, createdAt] of studioWriteTokens) {
|
|
18418
|
-
if (now2 - createdAt >= WRITE_TOKEN_TTL_MS) studioWriteTokens.delete(token);
|
|
18419
|
-
}
|
|
18420
|
-
}
|
|
18421
|
-
function markStudioWriteToken(token, now2 = Date.now()) {
|
|
18422
|
-
pruneStudioWriteTokens(now2);
|
|
18423
|
-
studioWriteTokens.set(token, now2);
|
|
18424
|
-
}
|
|
18425
|
-
function consumeStudioWriteToken(token, now2 = Date.now()) {
|
|
18426
|
-
pruneStudioWriteTokens(now2);
|
|
18427
|
-
if (!token || !studioWriteTokens.has(token)) return false;
|
|
18428
|
-
studioWriteTokens.delete(token);
|
|
18429
|
-
return true;
|
|
18430
|
-
}
|
|
18431
|
-
async function studioFileContentVersion(content) {
|
|
18432
|
-
const bytes = new TextEncoder().encode(content);
|
|
18433
|
-
const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
18434
|
-
const hex = Array.from(new Uint8Array(digest2), (byte) => byte.toString(16).padStart(2, "0")).join(
|
|
18435
|
-
""
|
|
18436
|
-
);
|
|
18437
|
-
return `"sha256:${hex}"`;
|
|
18438
|
-
}
|
|
18439
|
-
async function studioExpectedFileVersion(versions, path, expectedContent) {
|
|
18440
|
-
if (expectedContent !== void 0) return studioFileContentVersion(expectedContent);
|
|
18441
|
-
return versions.get(path);
|
|
18442
|
-
}
|
|
18443
|
-
function createStudioWriteToken() {
|
|
18444
|
-
const webCrypto = globalThis.crypto;
|
|
18445
|
-
if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID();
|
|
18446
|
-
if (typeof webCrypto?.getRandomValues !== "function") {
|
|
18447
|
-
throw new Error("Web Crypto getRandomValues is required for Studio write identity");
|
|
18448
|
-
}
|
|
18449
|
-
const bytes = webCrypto.getRandomValues(new Uint8Array(16));
|
|
18450
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
18451
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
18452
|
-
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
18453
|
-
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
18454
|
-
}
|
|
18455
|
-
function studioWriteHeaders() {
|
|
18456
|
-
const token = createStudioWriteToken();
|
|
18457
|
-
markStudioWriteToken(token);
|
|
18458
|
-
return { "X-Hyperframes-Write-Token": token };
|
|
18459
|
-
}
|
|
18460
|
-
|
|
18461
17984
|
// src/hooks/gsapMutationClient.ts
|
|
18462
17985
|
var GsapPreviewConvergenceError = class extends Error {
|
|
18463
17986
|
};
|
|
@@ -32351,73 +31874,6 @@ function applyStudioRotation(element, rotation) {
|
|
|
32351
31874
|
// src/player/hooks/useShadowPreviewReload.ts
|
|
32352
31875
|
import { refusedPreviewStatus } from "@hyperframes/core/studio-preview-mark";
|
|
32353
31876
|
|
|
32354
|
-
// src/utils/studioDebug.ts
|
|
32355
|
-
function makeStudioDebugLogger(name) {
|
|
32356
|
-
let enabled = null;
|
|
32357
|
-
return (stage, data = {}) => {
|
|
32358
|
-
if (enabled === null) {
|
|
32359
|
-
try {
|
|
32360
|
-
enabled = localStorage.getItem(`hf-${name}-debug`) === "1";
|
|
32361
|
-
} catch {
|
|
32362
|
-
enabled = false;
|
|
32363
|
-
}
|
|
32364
|
-
}
|
|
32365
|
-
if (!enabled) return;
|
|
32366
|
-
const details = typeof data === "function" ? data() : data;
|
|
32367
|
-
if (!details) return;
|
|
32368
|
-
console.log(
|
|
32369
|
-
`[hf-${name}] ${JSON.stringify({ stage, t: Math.round(performance.now()), ...details })}`
|
|
32370
|
-
);
|
|
32371
|
-
};
|
|
32372
|
-
}
|
|
32373
|
-
|
|
32374
|
-
// src/utils/reloadDebug.ts
|
|
32375
|
-
var logReload = makeStudioDebugLogger("reload");
|
|
32376
|
-
|
|
32377
|
-
// src/player/previewReloading.ts
|
|
32378
|
-
var reloading = false;
|
|
32379
|
-
var reloadRequested = false;
|
|
32380
|
-
var scriptWrites = 0;
|
|
32381
|
-
var givenUp = false;
|
|
32382
|
-
var changing = () => reloading || reloadRequested || scriptWrites > 0;
|
|
32383
|
-
var noteIdle = () => {
|
|
32384
|
-
if (!changing()) givenUp = false;
|
|
32385
|
-
globalThis.document?.documentElement.toggleAttribute(
|
|
32386
|
-
"data-preview-changing",
|
|
32387
|
-
isPreviewChanging()
|
|
32388
|
-
);
|
|
32389
|
-
};
|
|
32390
|
-
function giveUpOnPreviewChange() {
|
|
32391
|
-
givenUp = changing();
|
|
32392
|
-
noteIdle();
|
|
32393
|
-
}
|
|
32394
|
-
function setPreviewReloading(next) {
|
|
32395
|
-
reloading = next;
|
|
32396
|
-
thumbnailScheduler.setPreviewReloading(next);
|
|
32397
|
-
noteIdle();
|
|
32398
|
-
}
|
|
32399
|
-
function requestPreviewReload() {
|
|
32400
|
-
reloadRequested = true;
|
|
32401
|
-
noteIdle();
|
|
32402
|
-
}
|
|
32403
|
-
function previewReloadBegun() {
|
|
32404
|
-
reloadRequested = false;
|
|
32405
|
-
noteIdle();
|
|
32406
|
-
}
|
|
32407
|
-
async function whileScriptWrites(write) {
|
|
32408
|
-
scriptWrites += 1;
|
|
32409
|
-
noteIdle();
|
|
32410
|
-
try {
|
|
32411
|
-
return await write();
|
|
32412
|
-
} finally {
|
|
32413
|
-
scriptWrites -= 1;
|
|
32414
|
-
noteIdle();
|
|
32415
|
-
}
|
|
32416
|
-
}
|
|
32417
|
-
function isPreviewChanging() {
|
|
32418
|
-
return changing() && !givenUp;
|
|
32419
|
-
}
|
|
32420
|
-
|
|
32421
31877
|
// src/player/hooks/useShadowReloadRetry.ts
|
|
32422
31878
|
import { useCallback as useCallback39, useMemo as useMemo38, useRef as useRef48 } from "react";
|
|
32423
31879
|
var READY_TIMEOUT_CAUSE = "it took too long to load";
|
|
@@ -32543,6 +31999,7 @@ function useShadowPreviewReload({
|
|
|
32543
31999
|
});
|
|
32544
32000
|
const shadowUrlRef = useRef49("");
|
|
32545
32001
|
const savesAtRequestRef = useRef49(0);
|
|
32002
|
+
const revisionAtRequestRef = useRef49(0);
|
|
32546
32003
|
const beginShadowReloadRef = useRef49(() => {
|
|
32547
32004
|
});
|
|
32548
32005
|
const retry = useShadowReloadRetry(shadowGenRef, shadowUrlRef, beginShadowReloadRef);
|
|
@@ -32607,7 +32064,8 @@ function useShadowPreviewReload({
|
|
|
32607
32064
|
"gesture",
|
|
32608
32065
|
(retry2) => afterStudioManualEditGestures(liveDoc, retry2)
|
|
32609
32066
|
);
|
|
32610
|
-
if (gestureSavesOnScreen() === savesAtRequestRef.current)
|
|
32067
|
+
if (gestureSavesOnScreen() === savesAtRequestRef.current && studioFileRevision() === revisionAtRequestRef.current)
|
|
32068
|
+
return false;
|
|
32611
32069
|
if (isStudioEditSaving()) return waitThenRetry(gen, "save", afterStudioPendingEdits);
|
|
32612
32070
|
logReload("shadow-reloaded-after-gesture-save", { gen });
|
|
32613
32071
|
const url = new URL(shadowUrlRef.current, window.location.origin);
|
|
@@ -32745,6 +32203,7 @@ function useShadowPreviewReload({
|
|
|
32745
32203
|
budgetsSpentRef.current = 0;
|
|
32746
32204
|
shadowUrlRef.current = url;
|
|
32747
32205
|
savesAtRequestRef.current = gestureSavesOnScreen();
|
|
32206
|
+
revisionAtRequestRef.current = studioFileRevision();
|
|
32748
32207
|
armReadyTimer(gen);
|
|
32749
32208
|
setPreviewSlots((prev) => planShadowReload(prev, gen, url));
|
|
32750
32209
|
setPreviewReloading(true);
|
|
@@ -33702,13 +33161,7 @@ function useTimelinePlayer({
|
|
|
33702
33161
|
const swapWouldReplaceGestureNode = !!iframe.contentDocument && isStudioManualEditGestureLiveIn(iframe.contentDocument);
|
|
33703
33162
|
if (!swap || isRefreshingRef.current || swapWouldReplaceGestureNode)
|
|
33704
33163
|
return reloadWholeFilm(url.toString());
|
|
33705
|
-
|
|
33706
|
-
(error) => {
|
|
33707
|
-
if (!isCurrent()) return;
|
|
33708
|
-
logReload("scene-swap-refused", { reason: String(error) });
|
|
33709
|
-
reloadWholeFilm(url.toString());
|
|
33710
|
-
}
|
|
33711
|
-
);
|
|
33164
|
+
swapFreshly(swap, url, isCurrent, cancel.signal, reloadWholeFilm);
|
|
33712
33165
|
}, [reloadWholeFilm, previewGeneration]);
|
|
33713
33166
|
const pauseRef = useRef50(pause);
|
|
33714
33167
|
pauseRef.current = pause;
|
|
@@ -74189,9 +73642,9 @@ var STORAGE_KEYS = {
|
|
|
74189
73642
|
answeredAt: "hyperframes-studio:feedbackAnsweredAt"
|
|
74190
73643
|
};
|
|
74191
73644
|
var SESSION_ASKED_KEY = "hyperframes-studio:feedbackAskedThisSession";
|
|
74192
|
-
var
|
|
74193
|
-
var ANSWERED_COOLDOWN_MS = 30 *
|
|
74194
|
-
var DISMISSED_COOLDOWN_MS = 7 *
|
|
73645
|
+
var DAY_MS = 864e5;
|
|
73646
|
+
var ANSWERED_COOLDOWN_MS = 30 * DAY_MS;
|
|
73647
|
+
var DISMISSED_COOLDOWN_MS = 7 * DAY_MS;
|
|
74195
73648
|
var listener = null;
|
|
74196
73649
|
function isDisabled() {
|
|
74197
73650
|
try {
|
|
@@ -102793,12 +102246,15 @@ export {
|
|
|
102793
102246
|
fieldText,
|
|
102794
102247
|
findElementBlock,
|
|
102795
102248
|
flushStudioPendingEdits,
|
|
102249
|
+
formatCombo,
|
|
102796
102250
|
formatTime,
|
|
102797
102251
|
getPersistedRenderSettings,
|
|
102798
102252
|
getStudioKeys,
|
|
102799
102253
|
liveTime,
|
|
102254
|
+
matchCombo,
|
|
102800
102255
|
mergeStyleIntoTag,
|
|
102801
102256
|
openAudioGainDialog,
|
|
102257
|
+
parseCombo,
|
|
102802
102258
|
parseStyleString,
|
|
102803
102259
|
persistRenderSettings,
|
|
102804
102260
|
playSeamTransitionLoop,
|
|
@@ -102812,6 +102268,7 @@ export {
|
|
|
102812
102268
|
revertNewestStudioPendingEdit,
|
|
102813
102269
|
setStudioKeys,
|
|
102814
102270
|
snapEngagedForTravel,
|
|
102271
|
+
studioKeyClash,
|
|
102815
102272
|
useAudioGainDialogStore,
|
|
102816
102273
|
useAudioMetersVisible,
|
|
102817
102274
|
useClipboard,
|