@hyperframes/studio 0.9.2 → 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-ZrazkISK.js → hyperframes-player-BHCO0AJz.js} +1 -1
- package/dist/assets/{index-ZDVj-MKT.js → index-CWzE624c.js} +155 -155
- package/dist/assets/{index-DVDkDAQX.js → index-VhjEqQ4-.js} +1 -1
- package/dist/{chunk-CM72ZNGU.js → chunk-LBXOFI5I.js} +615 -0
- package/dist/index.html +1 -1
- package/dist/index.js +29 -585
- package/dist/player.js +1 -1
- package/package.json +8 -8
- 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,
|
|
@@ -2544,63 +2564,6 @@ function resolveTimelineAssetDrop(input, clientX, clientY) {
|
|
|
2544
2564
|
};
|
|
2545
2565
|
}
|
|
2546
2566
|
|
|
2547
|
-
// src/player/lib/timelineViewportBudgets.ts
|
|
2548
|
-
var MEBIBYTE = 1024 * 1024;
|
|
2549
|
-
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
2550
|
-
var MAX_VISIBLE_THUMBNAIL_FRAMES = Math.ceil(3840 / (66 * (16 / 9)));
|
|
2551
|
-
var TIMELINE_VIEWPORT_BUDGETS = Object.freeze({
|
|
2552
|
-
directScrollSafetyPx: 8e6,
|
|
2553
|
-
rowOverscanPerSide: 2,
|
|
2554
|
-
timeOverscanViewportRatio: 0.25,
|
|
2555
|
-
maxMountedRows: 64,
|
|
2556
|
-
maxMountedClipRoots: 512,
|
|
2557
|
-
maxMountedClipRootsPerRow: 128,
|
|
2558
|
-
maxMountedTimelineDescendants: 5e3,
|
|
2559
|
-
posterMaxPhysicalWidth: 240,
|
|
2560
|
-
posterMaxPhysicalHeight: 135,
|
|
2561
|
-
posterDprCap: 1.5,
|
|
2562
|
-
richPreviewFrameCount: MAX_VISIBLE_THUMBNAIL_FRAMES,
|
|
2563
|
-
concurrentVideoDecodes: 2,
|
|
2564
|
-
concurrentMetadataJobs: 4,
|
|
2565
|
-
concurrentCompositionFetches: 2,
|
|
2566
|
-
concurrentServerPages: 1,
|
|
2567
|
-
thumbnailLoadTimeoutMs: 3e4,
|
|
2568
|
-
thumbnailCacheBytes: 64 * MEBIBYTE,
|
|
2569
|
-
sharedFrameCacheBytes: 32 * MEBIBYTE,
|
|
2570
|
-
thumbnailSourceIdleMs: 1e4,
|
|
2571
|
-
thumbnailCacheEntries: 256,
|
|
2572
|
-
thumbnailCacheEntriesPerProject: 96,
|
|
2573
|
-
metadataRegistryEntries: 512,
|
|
2574
|
-
metadataFailureTtlMs: 3e4,
|
|
2575
|
-
waveformCacheBytes: 16 * MEBIBYTE,
|
|
2576
|
-
waveformCacheEntries: 256,
|
|
2577
|
-
compositionDiskCacheBytes: 512 * MEBIBYTE,
|
|
2578
|
-
compositionDiskCacheMaxAgeMs: 14 * DAY_MS,
|
|
2579
|
-
interactionP95Ms: 50,
|
|
2580
|
-
frameIntervalP95Ms: 33.3,
|
|
2581
|
-
constrainedInteractionP95Ms: 75,
|
|
2582
|
-
constrainedFrameIntervalP95Ms: 75,
|
|
2583
|
-
ciVirtualizedInteractionP95Ms: 58.3,
|
|
2584
|
-
ciVirtualizedFrameIntervalP95Ms: 25,
|
|
2585
|
-
longTaskLimitMs: 50,
|
|
2586
|
-
constrainedLongTaskLimitMs: 300,
|
|
2587
|
-
memoryReturnToleranceRatio: 0.15,
|
|
2588
|
-
posterColdP95Ms: 750,
|
|
2589
|
-
posterCachedP95Ms: 250,
|
|
2590
|
-
constrainedPosterColdP95Ms: 1200,
|
|
2591
|
-
constrainedPosterCachedP95Ms: 400,
|
|
2592
|
-
posterCoverageRatio: 0.9,
|
|
2593
|
-
posterCoverageSettleMs: 1500,
|
|
2594
|
-
constrainedPosterCoverageSettleMs: 2500,
|
|
2595
|
-
richPreviewP95Ms: 750,
|
|
2596
|
-
constrainedRichPreviewP95Ms: 1200,
|
|
2597
|
-
supportedFixtureFallbackRatio: 0.02,
|
|
2598
|
-
scrollSamplesPerRun: 63,
|
|
2599
|
-
warmupRuns: 3,
|
|
2600
|
-
measuredRuns: 5,
|
|
2601
|
-
requiredPassingRuns: 4
|
|
2602
|
-
});
|
|
2603
|
-
|
|
2604
2567
|
// src/player/components/timelineViewportGeometry.ts
|
|
2605
2568
|
function getTimelineRenderTimeRange(viewport2, pixelsPerSecond, contentOrigin, duration) {
|
|
2606
2569
|
if (!(pixelsPerSecond > 0) || !(duration > 0) || !(viewport2.clientWidth > 0)) {
|
|
@@ -16274,407 +16237,6 @@ import { fadeGain } from "@hyperframes/core/audio-fade";
|
|
|
16274
16237
|
|
|
16275
16238
|
// src/hooks/useThumbnailLease.ts
|
|
16276
16239
|
import { useCallback as useCallback25, useLayoutEffect as useLayoutEffect8, useRef as useRef30, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
16277
|
-
|
|
16278
|
-
// src/player/lib/thumbnailScheduler.ts
|
|
16279
|
-
var PRIORITY_SCORE = {
|
|
16280
|
-
overscan: 0,
|
|
16281
|
-
visible: 1,
|
|
16282
|
-
interaction: 2
|
|
16283
|
-
};
|
|
16284
|
-
var EMPTY_SNAPSHOT = Object.freeze({ status: "idle" });
|
|
16285
|
-
function concurrencyBucket(kind) {
|
|
16286
|
-
if (kind === "video") return "video";
|
|
16287
|
-
if (kind === "composition") return "composition";
|
|
16288
|
-
return "general";
|
|
16289
|
-
}
|
|
16290
|
-
function errorFrom(reason) {
|
|
16291
|
-
return reason instanceof Error ? reason : new Error(String(reason));
|
|
16292
|
-
}
|
|
16293
|
-
function createThumbnailKey(parts) {
|
|
16294
|
-
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("&");
|
|
16295
|
-
}
|
|
16296
|
-
function createThumbnailRequestIdentity(request2) {
|
|
16297
|
-
return createThumbnailKey({
|
|
16298
|
-
project: request2.projectId,
|
|
16299
|
-
session: request2.sessionEpoch,
|
|
16300
|
-
request: request2.key,
|
|
16301
|
-
kind: request2.kind,
|
|
16302
|
-
rich: request2.rich ? 1 : 0
|
|
16303
|
-
});
|
|
16304
|
-
}
|
|
16305
|
-
var ThumbnailScheduler = class {
|
|
16306
|
-
entries = /* @__PURE__ */ new Map();
|
|
16307
|
-
budgets;
|
|
16308
|
-
nextLeaseId = 1;
|
|
16309
|
-
nextSequence = 1;
|
|
16310
|
-
scrolling = false;
|
|
16311
|
-
previewReloading = false;
|
|
16312
|
-
playbackActive = false;
|
|
16313
|
-
pageHidden = false;
|
|
16314
|
-
cacheBytes = 0;
|
|
16315
|
-
waveformCacheBytes = 0;
|
|
16316
|
-
activeByBucket = { video: 0, composition: 0, general: 0 };
|
|
16317
|
-
activeByKind = {
|
|
16318
|
-
video: 0,
|
|
16319
|
-
image: 0,
|
|
16320
|
-
composition: 0,
|
|
16321
|
-
waveform: 0
|
|
16322
|
-
};
|
|
16323
|
-
now;
|
|
16324
|
-
constructor(budgets = TIMELINE_VIEWPORT_BUDGETS, now2 = Date.now) {
|
|
16325
|
-
this.budgets = budgets;
|
|
16326
|
-
this.now = now2;
|
|
16327
|
-
}
|
|
16328
|
-
acquire(request2, listener2) {
|
|
16329
|
-
const scopedKey = createThumbnailRequestIdentity(request2);
|
|
16330
|
-
let entry3 = this.entries.get(scopedKey);
|
|
16331
|
-
if (entry3?.state === "error" && entry3.failedAt !== void 0 && this.now() - entry3.failedAt >= this.budgets.metadataFailureTtlMs) {
|
|
16332
|
-
this.deleteEntry(scopedKey, entry3);
|
|
16333
|
-
entry3 = this.entries.get(scopedKey);
|
|
16334
|
-
}
|
|
16335
|
-
if (!entry3) {
|
|
16336
|
-
entry3 = {
|
|
16337
|
-
request: request2,
|
|
16338
|
-
scopedKey,
|
|
16339
|
-
state: "queued",
|
|
16340
|
-
leases: /* @__PURE__ */ new Map(),
|
|
16341
|
-
listeners: /* @__PURE__ */ new Map(),
|
|
16342
|
-
controller: null,
|
|
16343
|
-
weight: 0,
|
|
16344
|
-
disposed: false,
|
|
16345
|
-
cached: false,
|
|
16346
|
-
lastAccess: this.nextSequence++,
|
|
16347
|
-
snapshot: Object.freeze({ status: "queued" }),
|
|
16348
|
-
preempted: false
|
|
16349
|
-
};
|
|
16350
|
-
this.entries.set(scopedKey, entry3);
|
|
16351
|
-
}
|
|
16352
|
-
const leaseId = this.nextLeaseId++;
|
|
16353
|
-
entry3.leases.set(leaseId, request2.priority);
|
|
16354
|
-
entry3.listeners.set(leaseId, listener2);
|
|
16355
|
-
entry3.lastAccess = this.nextSequence++;
|
|
16356
|
-
this.pump();
|
|
16357
|
-
let released2 = false;
|
|
16358
|
-
return {
|
|
16359
|
-
updatePriority: (priority) => {
|
|
16360
|
-
const current2 = this.entries.get(scopedKey);
|
|
16361
|
-
if (!current2 || !current2.leases.has(leaseId)) return;
|
|
16362
|
-
current2.leases.set(leaseId, priority);
|
|
16363
|
-
current2.lastAccess = this.nextSequence++;
|
|
16364
|
-
this.pump();
|
|
16365
|
-
},
|
|
16366
|
-
release: () => {
|
|
16367
|
-
if (released2) return;
|
|
16368
|
-
released2 = true;
|
|
16369
|
-
const current2 = this.entries.get(scopedKey);
|
|
16370
|
-
if (!current2) return;
|
|
16371
|
-
current2.leases.delete(leaseId);
|
|
16372
|
-
current2.listeners.delete(leaseId);
|
|
16373
|
-
if (current2.leases.size === 0) {
|
|
16374
|
-
if (current2.state === "queued") {
|
|
16375
|
-
this.deleteEntry(scopedKey, current2);
|
|
16376
|
-
} else if (current2.state === "loading") {
|
|
16377
|
-
current2.controller?.abort();
|
|
16378
|
-
this.deleteEntry(scopedKey, current2);
|
|
16379
|
-
} else if (current2.state === "ready" && !current2.cached) {
|
|
16380
|
-
this.deleteEntry(scopedKey, current2);
|
|
16381
|
-
}
|
|
16382
|
-
}
|
|
16383
|
-
this.evict();
|
|
16384
|
-
}
|
|
16385
|
-
};
|
|
16386
|
-
}
|
|
16387
|
-
getSnapshot(request2) {
|
|
16388
|
-
const entry3 = this.entries.get(createThumbnailRequestIdentity(request2));
|
|
16389
|
-
if (!entry3) return EMPTY_SNAPSHOT;
|
|
16390
|
-
return entry3.snapshot;
|
|
16391
|
-
}
|
|
16392
|
-
setScrolling(scrolling) {
|
|
16393
|
-
if (this.scrolling === scrolling) return;
|
|
16394
|
-
this.scrolling = scrolling;
|
|
16395
|
-
if (!scrolling) this.pump();
|
|
16396
|
-
}
|
|
16397
|
-
/** Holds composition renders while the preview loads: same server, and the preview is what the person awaits. */
|
|
16398
|
-
setPreviewReloading(reloading2) {
|
|
16399
|
-
if (this.previewReloading === reloading2) return;
|
|
16400
|
-
this.previewReloading = reloading2;
|
|
16401
|
-
if (!reloading2) {
|
|
16402
|
-
this.pump();
|
|
16403
|
-
return;
|
|
16404
|
-
}
|
|
16405
|
-
for (const entry3 of this.entries.values()) {
|
|
16406
|
-
if (entry3.state !== "loading" || entry3.request.kind !== "composition") continue;
|
|
16407
|
-
this.preempt(entry3);
|
|
16408
|
-
}
|
|
16409
|
-
}
|
|
16410
|
-
setPlaybackActive(active) {
|
|
16411
|
-
if (this.playbackActive === active) return;
|
|
16412
|
-
this.playbackActive = active;
|
|
16413
|
-
if (!active) this.pump();
|
|
16414
|
-
}
|
|
16415
|
-
setPageHidden(hidden) {
|
|
16416
|
-
if (this.pageHidden === hidden) return;
|
|
16417
|
-
this.pageHidden = hidden;
|
|
16418
|
-
if (!hidden) {
|
|
16419
|
-
this.pump();
|
|
16420
|
-
return;
|
|
16421
|
-
}
|
|
16422
|
-
for (const entry3 of this.entries.values()) {
|
|
16423
|
-
if (entry3.state === "loading") this.preempt(entry3);
|
|
16424
|
-
}
|
|
16425
|
-
}
|
|
16426
|
-
preempt(entry3) {
|
|
16427
|
-
entry3.preempted = true;
|
|
16428
|
-
entry3.controller?.abort();
|
|
16429
|
-
}
|
|
16430
|
-
/** Evict project cache entries that are no longer owned by mounted consumers. */
|
|
16431
|
-
invalidateProject(projectId) {
|
|
16432
|
-
for (const [key2, entry3] of this.entries) {
|
|
16433
|
-
if (entry3.request.projectId !== projectId) continue;
|
|
16434
|
-
if (entry3.leases.size > 0) continue;
|
|
16435
|
-
entry3.controller?.abort();
|
|
16436
|
-
this.deleteEntry(key2, entry3);
|
|
16437
|
-
}
|
|
16438
|
-
}
|
|
16439
|
-
getDiagnostics() {
|
|
16440
|
-
let queued = 0;
|
|
16441
|
-
let active = 0;
|
|
16442
|
-
let leases = 0;
|
|
16443
|
-
let cacheEntries = 0;
|
|
16444
|
-
let waveformCacheEntries = 0;
|
|
16445
|
-
for (const entry3 of this.entries.values()) {
|
|
16446
|
-
if (entry3.state === "queued") queued++;
|
|
16447
|
-
if (entry3.state === "loading") active++;
|
|
16448
|
-
if (entry3.cached) {
|
|
16449
|
-
if (entry3.request.kind === "waveform") waveformCacheEntries++;
|
|
16450
|
-
else cacheEntries++;
|
|
16451
|
-
}
|
|
16452
|
-
leases += entry3.leases.size;
|
|
16453
|
-
}
|
|
16454
|
-
return {
|
|
16455
|
-
queued,
|
|
16456
|
-
active,
|
|
16457
|
-
leases,
|
|
16458
|
-
cacheEntries,
|
|
16459
|
-
cacheBytes: this.cacheBytes,
|
|
16460
|
-
waveformCacheEntries,
|
|
16461
|
-
waveformCacheBytes: this.waveformCacheBytes,
|
|
16462
|
-
activeByKind: { ...this.activeByKind }
|
|
16463
|
-
};
|
|
16464
|
-
}
|
|
16465
|
-
pump() {
|
|
16466
|
-
if (this.pageHidden) return;
|
|
16467
|
-
const queued = Array.from(this.entries.values()).filter((entry3) => entry3.state === "queued" && entry3.leases.size > 0).sort((left, right) => {
|
|
16468
|
-
const priorityDelta = this.entryPriority(right) - this.entryPriority(left);
|
|
16469
|
-
return priorityDelta || left.lastAccess - right.lastAccess;
|
|
16470
|
-
});
|
|
16471
|
-
for (const entry3 of queued) {
|
|
16472
|
-
if (this.isHeld(entry3)) continue;
|
|
16473
|
-
const bucket = concurrencyBucket(entry3.request.kind);
|
|
16474
|
-
if (this.activeByBucket[bucket] >= this.bucketLimit(bucket)) continue;
|
|
16475
|
-
this.start(entry3, bucket);
|
|
16476
|
-
}
|
|
16477
|
-
}
|
|
16478
|
-
isHeld(entry3) {
|
|
16479
|
-
const { kind, rich } = entry3.request;
|
|
16480
|
-
if (this.scrolling && rich) return true;
|
|
16481
|
-
if (this.previewReloading && kind === "composition") return true;
|
|
16482
|
-
return this.playbackActive && kind === "video" && this.entryPriority(entry3) < PRIORITY_SCORE.interaction;
|
|
16483
|
-
}
|
|
16484
|
-
start(entry3, bucket) {
|
|
16485
|
-
entry3.state = "loading";
|
|
16486
|
-
entry3.snapshot = Object.freeze({ status: "loading" });
|
|
16487
|
-
const controller = new AbortController();
|
|
16488
|
-
entry3.controller = controller;
|
|
16489
|
-
this.activeByBucket[bucket]++;
|
|
16490
|
-
this.activeByKind[entry3.request.kind]++;
|
|
16491
|
-
let slotFree = false;
|
|
16492
|
-
const freeSlot = () => {
|
|
16493
|
-
if (slotFree) return;
|
|
16494
|
-
slotFree = true;
|
|
16495
|
-
this.activeByBucket[bucket]--;
|
|
16496
|
-
this.activeByKind[entry3.request.kind]--;
|
|
16497
|
-
queueMicrotask(() => this.pump());
|
|
16498
|
-
};
|
|
16499
|
-
controller.signal.addEventListener("abort", freeSlot, { once: true });
|
|
16500
|
-
this.notify(entry3);
|
|
16501
|
-
const pending2 = this.loadWithTimeout(entry3, controller);
|
|
16502
|
-
void pending2.then((result) => this.acceptResult(entry3, controller, result)).catch((reason) => {
|
|
16503
|
-
if (this.entries.get(entry3.scopedKey) !== entry3) return;
|
|
16504
|
-
if (controller.signal.aborted && entry3.leases.size === 0) {
|
|
16505
|
-
this.deleteEntry(entry3.scopedKey, entry3);
|
|
16506
|
-
return;
|
|
16507
|
-
}
|
|
16508
|
-
if (this.requeuePreempted(entry3)) return;
|
|
16509
|
-
entry3.state = "error";
|
|
16510
|
-
entry3.error = errorFrom(reason);
|
|
16511
|
-
entry3.failedAt = this.now();
|
|
16512
|
-
entry3.snapshot = Object.freeze({ status: "error", error: entry3.error });
|
|
16513
|
-
this.notify(entry3);
|
|
16514
|
-
this.evictFailures();
|
|
16515
|
-
}).finally(() => {
|
|
16516
|
-
if (entry3.controller === controller) entry3.controller = null;
|
|
16517
|
-
freeSlot();
|
|
16518
|
-
this.pump();
|
|
16519
|
-
});
|
|
16520
|
-
}
|
|
16521
|
-
acceptResult(entry3, controller, result) {
|
|
16522
|
-
if (controller.signal.aborted || this.entries.get(entry3.scopedKey) !== entry3) {
|
|
16523
|
-
this.safeDispose(result.dispose);
|
|
16524
|
-
this.requeuePreempted(entry3);
|
|
16525
|
-
return;
|
|
16526
|
-
}
|
|
16527
|
-
this.validateResult(result);
|
|
16528
|
-
entry3.state = "ready";
|
|
16529
|
-
entry3.value = result.value;
|
|
16530
|
-
entry3.weight = result.weight;
|
|
16531
|
-
entry3.dispose = result.dispose;
|
|
16532
|
-
this.cacheResult(entry3);
|
|
16533
|
-
entry3.snapshot = Object.freeze({ status: "ready", value: result.value });
|
|
16534
|
-
this.notify(entry3);
|
|
16535
|
-
this.evict();
|
|
16536
|
-
if (!entry3.cached && entry3.leases.size === 0) this.deleteEntry(entry3.scopedKey, entry3);
|
|
16537
|
-
}
|
|
16538
|
-
requeuePreempted(entry3) {
|
|
16539
|
-
if (!entry3.preempted || this.entries.get(entry3.scopedKey) !== entry3) return false;
|
|
16540
|
-
entry3.preempted = false;
|
|
16541
|
-
entry3.state = "queued";
|
|
16542
|
-
entry3.snapshot = Object.freeze({ status: "queued" });
|
|
16543
|
-
this.notify(entry3);
|
|
16544
|
-
return true;
|
|
16545
|
-
}
|
|
16546
|
-
validateResult(result) {
|
|
16547
|
-
if (Number.isFinite(result.weight) && result.weight >= 0) return;
|
|
16548
|
-
this.safeDispose(result.dispose);
|
|
16549
|
-
throw new RangeError("Thumbnail result weight must be finite and non-negative");
|
|
16550
|
-
}
|
|
16551
|
-
cacheResult(entry3) {
|
|
16552
|
-
const isWaveform = entry3.request.kind === "waveform";
|
|
16553
|
-
const byteBudget = isWaveform ? this.budgets.waveformCacheBytes : this.budgets.thumbnailCacheBytes;
|
|
16554
|
-
entry3.cached = !entry3.request.discardWhenReleased && entry3.weight <= byteBudget;
|
|
16555
|
-
if (!entry3.cached) return;
|
|
16556
|
-
if (isWaveform) this.waveformCacheBytes += entry3.weight;
|
|
16557
|
-
else this.cacheBytes += entry3.weight;
|
|
16558
|
-
}
|
|
16559
|
-
entryPriority(entry3) {
|
|
16560
|
-
let score = -1;
|
|
16561
|
-
for (const priority of entry3.leases.values()) {
|
|
16562
|
-
score = Math.max(score, PRIORITY_SCORE[priority]);
|
|
16563
|
-
}
|
|
16564
|
-
return score;
|
|
16565
|
-
}
|
|
16566
|
-
bucketLimit(bucket) {
|
|
16567
|
-
if (bucket === "video") return this.budgets.concurrentVideoDecodes;
|
|
16568
|
-
if (bucket === "composition") return this.budgets.concurrentCompositionFetches;
|
|
16569
|
-
return this.budgets.concurrentMetadataJobs;
|
|
16570
|
-
}
|
|
16571
|
-
evict() {
|
|
16572
|
-
this.evictPartition(false);
|
|
16573
|
-
this.evictPartition(true);
|
|
16574
|
-
}
|
|
16575
|
-
evictPartition(waveform) {
|
|
16576
|
-
const cached5 = Array.from(this.entries.values()).filter(
|
|
16577
|
-
(entry3) => entry3.cached && entry3.request.kind === "waveform" === waveform
|
|
16578
|
-
);
|
|
16579
|
-
const perProject = /* @__PURE__ */ new Map();
|
|
16580
|
-
for (const entry3 of cached5) {
|
|
16581
|
-
perProject.set(entry3.request.projectId, (perProject.get(entry3.request.projectId) ?? 0) + 1);
|
|
16582
|
-
}
|
|
16583
|
-
cached5.sort((left, right) => left.lastAccess - right.lastAccess);
|
|
16584
|
-
let cacheEntries = cached5.length;
|
|
16585
|
-
for (const entry3 of cached5) {
|
|
16586
|
-
const projectEntries = perProject.get(entry3.request.projectId) ?? 0;
|
|
16587
|
-
if (!this.isCacheOverBudget(waveform, cacheEntries, projectEntries)) continue;
|
|
16588
|
-
this.uncache(entry3);
|
|
16589
|
-
cacheEntries--;
|
|
16590
|
-
perProject.set(entry3.request.projectId, projectEntries - 1);
|
|
16591
|
-
if (entry3.leases.size === 0) this.deleteEntry(entry3.scopedKey, entry3);
|
|
16592
|
-
}
|
|
16593
|
-
}
|
|
16594
|
-
isCacheOverBudget(waveform, cacheEntries, projectEntries) {
|
|
16595
|
-
const entryBudget = waveform ? this.budgets.waveformCacheEntries : this.budgets.thumbnailCacheEntries;
|
|
16596
|
-
const byteBudget = waveform ? this.budgets.waveformCacheBytes : this.budgets.thumbnailCacheBytes;
|
|
16597
|
-
const cacheBytes = waveform ? this.waveformCacheBytes : this.cacheBytes;
|
|
16598
|
-
const projectOverBudget = !waveform && projectEntries > this.budgets.thumbnailCacheEntriesPerProject;
|
|
16599
|
-
return cacheEntries > entryBudget || cacheBytes > byteBudget || projectOverBudget;
|
|
16600
|
-
}
|
|
16601
|
-
uncache(entry3) {
|
|
16602
|
-
entry3.cached = false;
|
|
16603
|
-
if (entry3.request.kind === "waveform") this.waveformCacheBytes -= entry3.weight;
|
|
16604
|
-
else this.cacheBytes -= entry3.weight;
|
|
16605
|
-
}
|
|
16606
|
-
notify(entry3) {
|
|
16607
|
-
for (const listener2 of new Set(entry3.listeners.values())) listener2();
|
|
16608
|
-
}
|
|
16609
|
-
loadWithTimeout(entry3, controller) {
|
|
16610
|
-
let load;
|
|
16611
|
-
try {
|
|
16612
|
-
load = entry3.request.load(controller.signal);
|
|
16613
|
-
} catch (reason) {
|
|
16614
|
-
load = Promise.reject(reason);
|
|
16615
|
-
}
|
|
16616
|
-
return new Promise((resolve2, reject) => {
|
|
16617
|
-
let settled = false;
|
|
16618
|
-
const timeout = setTimeout(() => {
|
|
16619
|
-
if (settled) return;
|
|
16620
|
-
settled = true;
|
|
16621
|
-
const message = `Thumbnail load timed out after ${this.budgets.thumbnailLoadTimeoutMs}ms`;
|
|
16622
|
-
controller.abort(new DOMException(message, "TimeoutError"));
|
|
16623
|
-
reject(new Error(message));
|
|
16624
|
-
}, this.budgets.thumbnailLoadTimeoutMs);
|
|
16625
|
-
load.then(
|
|
16626
|
-
(result) => {
|
|
16627
|
-
if (settled) {
|
|
16628
|
-
this.safeDispose(result.dispose);
|
|
16629
|
-
return;
|
|
16630
|
-
}
|
|
16631
|
-
settled = true;
|
|
16632
|
-
clearTimeout(timeout);
|
|
16633
|
-
resolve2(result);
|
|
16634
|
-
},
|
|
16635
|
-
(reason) => {
|
|
16636
|
-
if (settled) return;
|
|
16637
|
-
settled = true;
|
|
16638
|
-
clearTimeout(timeout);
|
|
16639
|
-
reject(reason);
|
|
16640
|
-
}
|
|
16641
|
-
);
|
|
16642
|
-
});
|
|
16643
|
-
}
|
|
16644
|
-
deleteEntry(key2, entry3) {
|
|
16645
|
-
if (this.entries.get(key2) !== entry3) return;
|
|
16646
|
-
this.entries.delete(key2);
|
|
16647
|
-
entry3.snapshot = EMPTY_SNAPSHOT;
|
|
16648
|
-
this.notify(entry3);
|
|
16649
|
-
if (entry3.cached) {
|
|
16650
|
-
entry3.cached = false;
|
|
16651
|
-
if (entry3.request.kind === "waveform") this.waveformCacheBytes -= entry3.weight;
|
|
16652
|
-
else this.cacheBytes -= entry3.weight;
|
|
16653
|
-
}
|
|
16654
|
-
if (!entry3.disposed) {
|
|
16655
|
-
entry3.disposed = true;
|
|
16656
|
-
this.safeDispose(entry3.dispose);
|
|
16657
|
-
}
|
|
16658
|
-
entry3.listeners.clear();
|
|
16659
|
-
entry3.leases.clear();
|
|
16660
|
-
}
|
|
16661
|
-
evictFailures() {
|
|
16662
|
-
const failed2 = Array.from(this.entries.values()).filter((entry3) => entry3.state === "error" && entry3.leases.size === 0).sort((left, right) => left.lastAccess - right.lastAccess);
|
|
16663
|
-
const overflow = failed2.length - this.budgets.thumbnailCacheEntries;
|
|
16664
|
-
for (const entry3 of failed2.slice(0, Math.max(0, overflow))) {
|
|
16665
|
-
this.deleteEntry(entry3.scopedKey, entry3);
|
|
16666
|
-
}
|
|
16667
|
-
}
|
|
16668
|
-
safeDispose(dispose2) {
|
|
16669
|
-
try {
|
|
16670
|
-
dispose2?.();
|
|
16671
|
-
} catch {
|
|
16672
|
-
}
|
|
16673
|
-
}
|
|
16674
|
-
};
|
|
16675
|
-
var thumbnailScheduler = new ThumbnailScheduler();
|
|
16676
|
-
|
|
16677
|
-
// src/hooks/useThumbnailLease.ts
|
|
16678
16240
|
var IDLE = Object.freeze({ status: "idle" });
|
|
16679
16241
|
function useThumbnailLease(request2, scheduler = thumbnailScheduler) {
|
|
16680
16242
|
const requestRef = useRef30(request2);
|
|
@@ -18419,54 +17981,6 @@ function patchDocumentRootDuration(doc, contentEnd) {
|
|
|
18419
17981
|
return true;
|
|
18420
17982
|
}
|
|
18421
17983
|
|
|
18422
|
-
// src/utils/studioFileVersion.ts
|
|
18423
|
-
var WRITE_TOKEN_TTL_MS = 5 * 6e4;
|
|
18424
|
-
var studioWriteTokens = /* @__PURE__ */ new Map();
|
|
18425
|
-
function pruneStudioWriteTokens(now2) {
|
|
18426
|
-
for (const [token, createdAt] of studioWriteTokens) {
|
|
18427
|
-
if (now2 - createdAt >= WRITE_TOKEN_TTL_MS) studioWriteTokens.delete(token);
|
|
18428
|
-
}
|
|
18429
|
-
}
|
|
18430
|
-
function markStudioWriteToken(token, now2 = Date.now()) {
|
|
18431
|
-
pruneStudioWriteTokens(now2);
|
|
18432
|
-
studioWriteTokens.set(token, now2);
|
|
18433
|
-
}
|
|
18434
|
-
function consumeStudioWriteToken(token, now2 = Date.now()) {
|
|
18435
|
-
pruneStudioWriteTokens(now2);
|
|
18436
|
-
if (!token || !studioWriteTokens.has(token)) return false;
|
|
18437
|
-
studioWriteTokens.delete(token);
|
|
18438
|
-
return true;
|
|
18439
|
-
}
|
|
18440
|
-
async function studioFileContentVersion(content) {
|
|
18441
|
-
const bytes = new TextEncoder().encode(content);
|
|
18442
|
-
const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
18443
|
-
const hex = Array.from(new Uint8Array(digest2), (byte) => byte.toString(16).padStart(2, "0")).join(
|
|
18444
|
-
""
|
|
18445
|
-
);
|
|
18446
|
-
return `"sha256:${hex}"`;
|
|
18447
|
-
}
|
|
18448
|
-
async function studioExpectedFileVersion(versions, path, expectedContent) {
|
|
18449
|
-
if (expectedContent !== void 0) return studioFileContentVersion(expectedContent);
|
|
18450
|
-
return versions.get(path);
|
|
18451
|
-
}
|
|
18452
|
-
function createStudioWriteToken() {
|
|
18453
|
-
const webCrypto = globalThis.crypto;
|
|
18454
|
-
if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID();
|
|
18455
|
-
if (typeof webCrypto?.getRandomValues !== "function") {
|
|
18456
|
-
throw new Error("Web Crypto getRandomValues is required for Studio write identity");
|
|
18457
|
-
}
|
|
18458
|
-
const bytes = webCrypto.getRandomValues(new Uint8Array(16));
|
|
18459
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
18460
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
18461
|
-
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
18462
|
-
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
18463
|
-
}
|
|
18464
|
-
function studioWriteHeaders() {
|
|
18465
|
-
const token = createStudioWriteToken();
|
|
18466
|
-
markStudioWriteToken(token);
|
|
18467
|
-
return { "X-Hyperframes-Write-Token": token };
|
|
18468
|
-
}
|
|
18469
|
-
|
|
18470
17984
|
// src/hooks/gsapMutationClient.ts
|
|
18471
17985
|
var GsapPreviewConvergenceError = class extends Error {
|
|
18472
17986
|
};
|
|
@@ -32360,73 +31874,6 @@ function applyStudioRotation(element, rotation) {
|
|
|
32360
31874
|
// src/player/hooks/useShadowPreviewReload.ts
|
|
32361
31875
|
import { refusedPreviewStatus } from "@hyperframes/core/studio-preview-mark";
|
|
32362
31876
|
|
|
32363
|
-
// src/utils/studioDebug.ts
|
|
32364
|
-
function makeStudioDebugLogger(name) {
|
|
32365
|
-
let enabled = null;
|
|
32366
|
-
return (stage, data = {}) => {
|
|
32367
|
-
if (enabled === null) {
|
|
32368
|
-
try {
|
|
32369
|
-
enabled = localStorage.getItem(`hf-${name}-debug`) === "1";
|
|
32370
|
-
} catch {
|
|
32371
|
-
enabled = false;
|
|
32372
|
-
}
|
|
32373
|
-
}
|
|
32374
|
-
if (!enabled) return;
|
|
32375
|
-
const details = typeof data === "function" ? data() : data;
|
|
32376
|
-
if (!details) return;
|
|
32377
|
-
console.log(
|
|
32378
|
-
`[hf-${name}] ${JSON.stringify({ stage, t: Math.round(performance.now()), ...details })}`
|
|
32379
|
-
);
|
|
32380
|
-
};
|
|
32381
|
-
}
|
|
32382
|
-
|
|
32383
|
-
// src/utils/reloadDebug.ts
|
|
32384
|
-
var logReload = makeStudioDebugLogger("reload");
|
|
32385
|
-
|
|
32386
|
-
// src/player/previewReloading.ts
|
|
32387
|
-
var reloading = false;
|
|
32388
|
-
var reloadRequested = false;
|
|
32389
|
-
var scriptWrites = 0;
|
|
32390
|
-
var givenUp = false;
|
|
32391
|
-
var changing = () => reloading || reloadRequested || scriptWrites > 0;
|
|
32392
|
-
var noteIdle = () => {
|
|
32393
|
-
if (!changing()) givenUp = false;
|
|
32394
|
-
globalThis.document?.documentElement.toggleAttribute(
|
|
32395
|
-
"data-preview-changing",
|
|
32396
|
-
isPreviewChanging()
|
|
32397
|
-
);
|
|
32398
|
-
};
|
|
32399
|
-
function giveUpOnPreviewChange() {
|
|
32400
|
-
givenUp = changing();
|
|
32401
|
-
noteIdle();
|
|
32402
|
-
}
|
|
32403
|
-
function setPreviewReloading(next) {
|
|
32404
|
-
reloading = next;
|
|
32405
|
-
thumbnailScheduler.setPreviewReloading(next);
|
|
32406
|
-
noteIdle();
|
|
32407
|
-
}
|
|
32408
|
-
function requestPreviewReload() {
|
|
32409
|
-
reloadRequested = true;
|
|
32410
|
-
noteIdle();
|
|
32411
|
-
}
|
|
32412
|
-
function previewReloadBegun() {
|
|
32413
|
-
reloadRequested = false;
|
|
32414
|
-
noteIdle();
|
|
32415
|
-
}
|
|
32416
|
-
async function whileScriptWrites(write) {
|
|
32417
|
-
scriptWrites += 1;
|
|
32418
|
-
noteIdle();
|
|
32419
|
-
try {
|
|
32420
|
-
return await write();
|
|
32421
|
-
} finally {
|
|
32422
|
-
scriptWrites -= 1;
|
|
32423
|
-
noteIdle();
|
|
32424
|
-
}
|
|
32425
|
-
}
|
|
32426
|
-
function isPreviewChanging() {
|
|
32427
|
-
return changing() && !givenUp;
|
|
32428
|
-
}
|
|
32429
|
-
|
|
32430
31877
|
// src/player/hooks/useShadowReloadRetry.ts
|
|
32431
31878
|
import { useCallback as useCallback39, useMemo as useMemo38, useRef as useRef48 } from "react";
|
|
32432
31879
|
var READY_TIMEOUT_CAUSE = "it took too long to load";
|
|
@@ -32552,6 +31999,7 @@ function useShadowPreviewReload({
|
|
|
32552
31999
|
});
|
|
32553
32000
|
const shadowUrlRef = useRef49("");
|
|
32554
32001
|
const savesAtRequestRef = useRef49(0);
|
|
32002
|
+
const revisionAtRequestRef = useRef49(0);
|
|
32555
32003
|
const beginShadowReloadRef = useRef49(() => {
|
|
32556
32004
|
});
|
|
32557
32005
|
const retry = useShadowReloadRetry(shadowGenRef, shadowUrlRef, beginShadowReloadRef);
|
|
@@ -32616,7 +32064,8 @@ function useShadowPreviewReload({
|
|
|
32616
32064
|
"gesture",
|
|
32617
32065
|
(retry2) => afterStudioManualEditGestures(liveDoc, retry2)
|
|
32618
32066
|
);
|
|
32619
|
-
if (gestureSavesOnScreen() === savesAtRequestRef.current)
|
|
32067
|
+
if (gestureSavesOnScreen() === savesAtRequestRef.current && studioFileRevision() === revisionAtRequestRef.current)
|
|
32068
|
+
return false;
|
|
32620
32069
|
if (isStudioEditSaving()) return waitThenRetry(gen, "save", afterStudioPendingEdits);
|
|
32621
32070
|
logReload("shadow-reloaded-after-gesture-save", { gen });
|
|
32622
32071
|
const url = new URL(shadowUrlRef.current, window.location.origin);
|
|
@@ -32754,6 +32203,7 @@ function useShadowPreviewReload({
|
|
|
32754
32203
|
budgetsSpentRef.current = 0;
|
|
32755
32204
|
shadowUrlRef.current = url;
|
|
32756
32205
|
savesAtRequestRef.current = gestureSavesOnScreen();
|
|
32206
|
+
revisionAtRequestRef.current = studioFileRevision();
|
|
32757
32207
|
armReadyTimer(gen);
|
|
32758
32208
|
setPreviewSlots((prev) => planShadowReload(prev, gen, url));
|
|
32759
32209
|
setPreviewReloading(true);
|
|
@@ -33711,13 +33161,7 @@ function useTimelinePlayer({
|
|
|
33711
33161
|
const swapWouldReplaceGestureNode = !!iframe.contentDocument && isStudioManualEditGestureLiveIn(iframe.contentDocument);
|
|
33712
33162
|
if (!swap || isRefreshingRef.current || swapWouldReplaceGestureNode)
|
|
33713
33163
|
return reloadWholeFilm(url.toString());
|
|
33714
|
-
|
|
33715
|
-
(error) => {
|
|
33716
|
-
if (!isCurrent()) return;
|
|
33717
|
-
logReload("scene-swap-refused", { reason: String(error) });
|
|
33718
|
-
reloadWholeFilm(url.toString());
|
|
33719
|
-
}
|
|
33720
|
-
);
|
|
33164
|
+
swapFreshly(swap, url, isCurrent, cancel.signal, reloadWholeFilm);
|
|
33721
33165
|
}, [reloadWholeFilm, previewGeneration]);
|
|
33722
33166
|
const pauseRef = useRef50(pause);
|
|
33723
33167
|
pauseRef.current = pause;
|
|
@@ -74198,9 +73642,9 @@ var STORAGE_KEYS = {
|
|
|
74198
73642
|
answeredAt: "hyperframes-studio:feedbackAnsweredAt"
|
|
74199
73643
|
};
|
|
74200
73644
|
var SESSION_ASKED_KEY = "hyperframes-studio:feedbackAskedThisSession";
|
|
74201
|
-
var
|
|
74202
|
-
var ANSWERED_COOLDOWN_MS = 30 *
|
|
74203
|
-
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;
|
|
74204
73648
|
var listener = null;
|
|
74205
73649
|
function isDisabled() {
|
|
74206
73650
|
try {
|