@hyperframes/studio 0.9.55 → 0.9.58

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.
Files changed (42) hide show
  1. package/dist/assets/{hyperframes-player-BroIQA4E.js → hyperframes-player-B78JDyI_.js} +1 -1
  2. package/dist/assets/{index-Be7DZynj.js → index-D7ICtobF.js} +190 -190
  3. package/dist/assets/{index-CiF0D62S.js → index-ww7-RmuM.js} +1 -1
  4. package/dist/assets/{pausedVideoDecoder-RXcvblHS.js → pausedVideoDecoder-Dbe8Cmab.js} +1 -1
  5. package/dist/{chunk-JMM2CSEL.js → chunk-5EEM5WO4.js} +5 -1
  6. package/dist/index.d.ts +87 -3
  7. package/dist/index.html +1 -1
  8. package/dist/index.js +872 -778
  9. package/dist/player.js +1 -1
  10. package/package.json +8 -8
  11. package/src/components/nle/NLEPreview.test.ts +35 -3
  12. package/src/components/nle/NLEPreview.tsx +5 -4
  13. package/src/hooks/gsapRuntimePatch.ts +2 -3
  14. package/src/hooks/gsapRuntimeReaders.test.ts +5 -40
  15. package/src/hooks/gsapRuntimeReaders.ts +3 -27
  16. package/src/hooks/useExternalFileChangeCoordinator.test.tsx +20 -0
  17. package/src/hooks/useExternalFileChangeCoordinator.ts +1 -1
  18. package/src/index.ts +17 -0
  19. package/src/player/components/Player.test.ts +10 -0
  20. package/src/player/components/Player.tsx +2 -2
  21. package/src/player/components/studioShortcuts.ts +3 -2
  22. package/src/player/hooks/previewMessageRouter.manifest.test.ts +1 -0
  23. package/src/player/hooks/previewMessageRouter.test.ts +90 -12
  24. package/src/player/hooks/previewMessageRouter.ts +6 -4
  25. package/src/player/hooks/timelinePlayerTestHarness.ts +2 -0
  26. package/src/player/hooks/timelineSyncHydration.test.ts +28 -2
  27. package/src/player/hooks/timelineSyncHydration.ts +3 -7
  28. package/src/player/hooks/usePlaybackKeyboard.test.ts +107 -2
  29. package/src/player/hooks/usePlaybackKeyboard.ts +38 -1
  30. package/src/player/hooks/useShadowPreviewReload.ts +131 -14
  31. package/src/player/hooks/useTimelinePlayer.metadata.test.ts +1 -0
  32. package/src/player/hooks/useTimelinePlayer.play.test.ts +1 -0
  33. package/src/player/hooks/useTimelinePlayer.reloadStill.test.ts +241 -0
  34. package/src/player/hooks/useTimelinePlayer.seek.test.ts +3 -0
  35. package/src/player/hooks/useTimelinePlayer.ts +13 -1
  36. package/src/player/hooks/useTimelineSyncCallbacks.ts +4 -0
  37. package/src/player/lib/bridgePlayback.ts +7 -1
  38. package/src/player/lib/previewChannel.test.ts +13 -0
  39. package/src/sealedPreviewExports.test.ts +20 -0
  40. package/src/utils/externalConflictStorage.test.ts +66 -14
  41. package/src/utils/externalConflictStorage.ts +36 -82
  42. package/src/utils/gsapSoftReload.ts +2 -14
@@ -1,4 +1,5 @@
1
1
  import type { StudioFileConflictError } from "./studioSaveDiagnostics";
2
+ import { studioApiFetch } from "./studioApiFetch";
2
3
 
3
4
  interface ExternalRecoverySnapshotBase {
4
5
  projectId: string;
@@ -19,10 +20,6 @@ export interface ExternalConflictStorage {
19
20
  delete(projectId: string, filePath: string): Promise<void>;
20
21
  }
21
22
 
22
- const DB_NAME = "hyperframes-studio-external-conflicts";
23
- const DB_VERSION = 1;
24
- const STORE_NAME = "file-conflicts";
25
-
26
23
  function key(projectId: string, filePath: string): string {
27
24
  return `${projectId}\0${filePath}`;
28
25
  }
@@ -43,85 +40,46 @@ export function createMemoryExternalConflictStorage(): ExternalConflictStorage {
43
40
  };
44
41
  }
45
42
 
46
- function openDb(): Promise<IDBDatabase> {
47
- return new Promise((resolve, reject) => {
48
- if (!globalThis.indexedDB) {
49
- reject(new Error("IndexedDB is unavailable; conflict recovery snapshot was not saved"));
50
- return;
51
- }
52
- const request = globalThis.indexedDB.open(DB_NAME, DB_VERSION);
53
- request.onupgradeneeded = () => {
54
- if (!request.result.objectStoreNames.contains(STORE_NAME)) {
55
- request.result.createObjectStore(STORE_NAME);
56
- }
57
- };
58
- request.onerror = () => reject(request.error ?? new Error("Failed to open conflict storage"));
59
- request.onsuccess = () => resolve(request.result);
60
- });
61
- }
62
-
63
- function withStore<T>(
64
- mode: IDBTransactionMode,
65
- callback: (store: IDBObjectStore) => IDBRequest<T>,
66
- ): Promise<T> {
67
- return openDb().then(
68
- (db) =>
69
- new Promise<T>((resolve, reject) => {
70
- const transaction = db.transaction(STORE_NAME, mode);
71
- const request = callback(transaction.objectStore(STORE_NAME));
72
- let result!: T;
73
- request.onerror = () => reject(request.error ?? new Error("Conflict storage failed"));
74
- request.onsuccess = () => {
75
- result = request.result;
76
- };
77
- transaction.oncomplete = () => {
78
- db.close();
79
- resolve(result);
80
- };
81
- transaction.onerror = () => {
82
- db.close();
83
- reject(transaction.error ?? new Error("Conflict storage transaction failed"));
84
- };
85
- transaction.onabort = () => {
86
- db.close();
87
- reject(transaction.error ?? new Error("Conflict storage transaction was aborted"));
88
- };
89
- }),
90
- );
43
+ function draftUrl(projectId: string, filePath: string): string {
44
+ return `/api/projects/${encodeURIComponent(projectId)}/recovery-drafts/${encodeURIComponent(filePath)}`;
91
45
  }
92
46
 
93
- function createIndexedDbExternalConflictStorage(): ExternalConflictStorage {
94
- return {
95
- async get(projectId, filePath) {
96
- return (
97
- (await withStore<ExternalConflictSnapshot | undefined>("readonly", (store) =>
98
- store.get(key(projectId, filePath)),
99
- )) ?? null
100
- );
101
- },
102
- async set(snapshot) {
103
- await withStore<IDBValidKey>("readwrite", (store) =>
104
- store.put(snapshot, key(snapshot.projectId, snapshot.filePath)),
105
- );
106
- },
107
- async delete(projectId, filePath) {
108
- await withStore<undefined>("readwrite", (store) => store.delete(key(projectId, filePath)));
109
- },
110
- };
47
+ async function draftRequest(
48
+ projectId: string,
49
+ filePath: string,
50
+ init?: RequestInit,
51
+ ): Promise<Response> {
52
+ const res = await studioApiFetch(draftUrl(projectId, filePath), init);
53
+ if (!res.ok) throw new Error(`Recovery draft storage failed (${res.status})`);
54
+ return res;
111
55
  }
112
56
 
113
- const indexedDbStorage = createIndexedDbExternalConflictStorage();
57
+ /** Kept by the project's own server: an origin-wide browser store is shared with every project on the port. */
58
+ const projectStorage: ExternalConflictStorage = {
59
+ async get(projectId, filePath) {
60
+ const { draft } = (await (await draftRequest(projectId, filePath)).json()) as {
61
+ draft: ExternalConflictSnapshot | null;
62
+ };
63
+ return draft?.projectId === projectId && draft.filePath === filePath ? draft : null;
64
+ },
65
+ async set(snapshot) {
66
+ await draftRequest(snapshot.projectId, snapshot.filePath, {
67
+ method: "PUT",
68
+ headers: { "content-type": "application/json" },
69
+ body: JSON.stringify(snapshot),
70
+ });
71
+ },
72
+ async delete(projectId, filePath) {
73
+ await draftRequest(projectId, filePath, { method: "DELETE" });
74
+ },
75
+ };
114
76
 
115
- /**
116
- * Persist a conflict before offering destructive recovery actions.
117
- * Callers must await this promise: rejection means the Studio draft was not saved durably and
118
- * must remain available in memory while the storage failure is surfaced to the user.
119
- */
77
+ /** Saved before destructive recovery is offered; on a rejection the draft stays only in memory and the user is told. */
120
78
  export async function persistExternalConflictSnapshot(
121
79
  projectId: string,
122
80
  conflict: StudioFileConflictError,
123
81
  ): Promise<void> {
124
- await indexedDbStorage.set({
82
+ await projectStorage.set({
125
83
  kind: "conflict",
126
84
  projectId,
127
85
  filePath: conflict.filePath,
@@ -132,11 +90,7 @@ export async function persistExternalConflictSnapshot(
132
90
  });
133
91
  }
134
92
 
135
- /**
136
- * Persist the final Studio candidate after its file write fails.
137
- * Callers must await this promise: rejection means the Studio draft was not saved durably and
138
- * must remain available in memory while the storage failure is surfaced to the user.
139
- */
93
+ /** Studio's final candidate after its file write failed; awaited like persistExternalConflictSnapshot. */
140
94
  export async function persistExternalFailureSnapshot(
141
95
  projectId: string,
142
96
  filePath: string,
@@ -145,7 +99,7 @@ export async function persistExternalFailureSnapshot(
145
99
  externalContent: string | null,
146
100
  error: unknown,
147
101
  ): Promise<void> {
148
- await indexedDbStorage.set({
102
+ await projectStorage.set({
149
103
  kind: "failed",
150
104
  projectId,
151
105
  filePath,
@@ -161,12 +115,12 @@ export async function loadExternalConflictSnapshot(
161
115
  projectId: string,
162
116
  filePath: string,
163
117
  ): Promise<ExternalConflictSnapshot | null> {
164
- return indexedDbStorage.get(projectId, filePath);
118
+ return projectStorage.get(projectId, filePath);
165
119
  }
166
120
 
167
121
  export async function deleteExternalConflictSnapshot(
168
122
  projectId: string,
169
123
  filePath: string,
170
124
  ): Promise<void> {
171
- await indexedDbStorage.delete(projectId, filePath);
125
+ await projectStorage.delete(projectId, filePath);
172
126
  }
@@ -1,4 +1,3 @@
1
- import { COLOR_GRADING_SOURCE_HIDDEN_ATTR } from "@hyperframes/core/color-grading";
2
1
  import { parseGsapScript } from "@hyperframes/parsers/gsap-parser";
3
2
  import { GSAP_BASE_URL_META, motionPathPluginUrl } from "@hyperframes/core/gsap-cdn";
4
3
  import { findAuthoredElement } from "./authoredSource";
@@ -464,24 +463,13 @@ export function applySoftReload(
464
463
  s.cssText = css;
465
464
  restoreAuthoredStyle(s, findAuthoredStyle(el), targets.get(el)!);
466
465
  // The restored cssText carries RUNTIME opacity, not authored opacity:
467
- // a mid-flight tween's interpolated value, or the color-grading hide
468
- // (`opacity: 0 !important`). The re-run script's tweens re-initialize
466
+ // a mid-flight tween's interpolated value. The re-run script's tweens re-initialize
469
467
  // against it — a from() captures it as its END, a to() as its START —
470
468
  // turning the transient into the tween's permanent bound (dimmed or
471
469
  // invisible elements). Put the AUTHORED inline opacity back; the seek
472
470
  // below re-renders the correct animated value either way.
473
471
  const authored = readAuthoredOpacity(el);
474
- if (authored !== null) {
475
- applyAuthoredInlineOpacity(s, authored);
476
- } else if (
477
- el.hasAttribute(COLOR_GRADING_SOURCE_HIDDEN_ATTR) &&
478
- s.getPropertyValue("opacity") === "0" &&
479
- s.getPropertyPriority("opacity") === "important"
480
- ) {
481
- // Authored value unknown, but this is definitely the grading hide —
482
- // never let a from() capture 0; fall back to the CSS cascade.
483
- s.removeProperty("opacity");
484
- }
472
+ if (authored !== null) applyAuthoredInlineOpacity(s, authored);
485
473
  }
486
474
  }
487
475
  forgetLiveSets(targets);