@hyperframes/studio 0.9.41 → 0.9.42
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/{codec-B_mpbc4w.js → codec-CKqLGYc6.js} +1 -1
- package/dist/assets/{hyperframes-player-Dvi3I_mv.js → hyperframes-player-DoEYqOIa.js} +1 -1
- package/dist/assets/{index-B5ExwsOp.js → index-DLyQ91Ek.js} +160 -160
- package/dist/assets/{index-BrFm9Y5k.js → index-s9iqoWnr.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-MHQ57yZ6.js → pausedVideoDecoder-B-ReRg6i.js} +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.html +1 -1
- package/dist/index.js +1057 -721
- package/package.json +10 -10
- package/src/components/editor/LayersPanel.opaque.test.ts +176 -0
- package/src/components/editor/LayersPanel.tsx +41 -10
- package/src/components/editor/domEditInlineText.ts +1 -16
- package/src/components/editor/domEditingTypes.ts +7 -1
- package/src/components/editor/gestureUndoRevert.ts +18 -1
- package/src/components/editor/inlineTextStyleRange.fill.test.ts +129 -0
- package/src/components/editor/inlineTextStyleRange.test.ts +0 -82
- package/src/components/editor/layerKind.ts +2 -19
- package/src/components/editor/layersPanelSort.ts +2 -2
- package/src/components/editor/manualEdits.ts +1 -0
- package/src/components/editor/manualEditsSnapshot.ts +10 -0
- package/src/components/editor/manualOffsetDrag.test.ts +1 -1
- package/src/components/editor/manualOffsetDrag.ts +7 -1
- package/src/components/editor/marqueeCommit.ts +47 -4
- package/src/components/editor/plainTranslate.ts +35 -16
- package/src/components/editor/previewDrafts.test.ts +263 -0
- package/src/components/editor/previewDrafts.ts +73 -0
- package/src/components/editor/previewLayers.test.ts +308 -0
- package/src/components/editor/previewLayers.ts +164 -0
- package/src/components/editor/previewOverlayRects.ts +27 -0
- package/src/components/editor/previewPointerTargets.test.ts +68 -1
- package/src/components/editor/previewSelection.ts +55 -11
- package/src/components/editor/resizeDraft.ts +38 -0
- package/src/components/editor/useDomEditOverlayGestures.ts +2 -2
- package/src/components/editor/useLayerDrag.ts +1 -1
- package/src/components/nle/NLEPreview.slowBoot.test.ts +0 -1
- package/src/hooks/domEditDeleteMembers.test.ts +7 -0
- package/src/hooks/domSelectionTimelineMirror.ts +3 -1
- package/src/hooks/timelineTimingSync.ts +4 -1
- package/src/hooks/useDomSelection.ts +2 -0
- package/src/hooks/useEditorSave.test.tsx +22 -1
- package/src/hooks/useEditorSave.ts +3 -1
- package/src/hooks/usePreviewInteraction.ts +4 -1
- package/src/hooks/useProjectFileWriter.ts +7 -3
- package/src/hooks/useTimelineSelectionPreviewSync.test.tsx +30 -0
- package/src/hooks/useTimelineSelectionPreviewSync.ts +7 -2
- package/src/player/lib/layerOrdering.ts +2 -11
- package/src/player/lib/previewElements.ts +31 -0
- package/src/test-setup.ts +2 -0
- package/src/utils/gsapSoftReload.ts +1 -1
- package/src/utils/studioFileHistory.ts +1 -1
- package/src/utils/studioHelpers.ts +27 -4
- package/src/utils/studioSaveDiagnostics.test.ts +34 -0
- package/src/utils/studioSaveDiagnostics.ts +35 -6
- package/src/utils/timelineCompositionInsert.ts +3 -1
|
@@ -7,12 +7,46 @@ import {
|
|
|
7
7
|
StudioFileConflictError,
|
|
8
8
|
StudioSaveHttpError,
|
|
9
9
|
StudioSaveNetworkError,
|
|
10
|
+
createStudioSaveHttpError,
|
|
10
11
|
buildStudioSaveFailureProperties,
|
|
11
12
|
getStudioSaveStatusCode,
|
|
12
13
|
retryStudioSave,
|
|
13
14
|
trackStudioEditBlocked,
|
|
14
15
|
} from "./studioSaveDiagnostics";
|
|
15
16
|
|
|
17
|
+
describe("a file the server says is held or protected", () => {
|
|
18
|
+
// fails without the fix: the person read 'Failed to read ... (423): {"error":"file in use",...}' or no status at all.
|
|
19
|
+
it.each([
|
|
20
|
+
[423, "busy", "index.html is open in another program. Close it there, then try again."],
|
|
21
|
+
[
|
|
22
|
+
403,
|
|
23
|
+
"permission",
|
|
24
|
+
"index.html can't be changed: it is read-only or protected. Check its permissions, then try again.",
|
|
25
|
+
],
|
|
26
|
+
])("tells a %i %s in words naming the file, not the folder", async (status, why, words) => {
|
|
27
|
+
const response = new Response(JSON.stringify({ error: "x", why }), { status });
|
|
28
|
+
const error = await createStudioSaveHttpError(response, "Failed to save a/b/index.html", {
|
|
29
|
+
path: "a/b/index.html",
|
|
30
|
+
});
|
|
31
|
+
expect(error.message).toBe(words);
|
|
32
|
+
expect(error.statusCode).toBe(status);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("keeps the status and body for any other answer, and without a path", async () => {
|
|
36
|
+
const other = await createStudioSaveHttpError(
|
|
37
|
+
new Response("boom", { status: 500 }),
|
|
38
|
+
"Failed to save index.html",
|
|
39
|
+
{ path: "index.html" },
|
|
40
|
+
);
|
|
41
|
+
expect(other.message).toBe("Failed to save index.html (500): boom");
|
|
42
|
+
const noPath = await createStudioSaveHttpError(
|
|
43
|
+
new Response(JSON.stringify({ why: "busy" }), { status: 423 }),
|
|
44
|
+
"Failed to save index.html",
|
|
45
|
+
);
|
|
46
|
+
expect(noPath.message).toMatch(/^Failed to save index.html \(423\)/);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
16
50
|
describe("studio save diagnostics", () => {
|
|
17
51
|
it("preserves conflict versions and both sides for explicit recovery UI", () => {
|
|
18
52
|
const error = new StudioFileConflictError({
|
|
@@ -19,12 +19,18 @@ export interface StudioSaveFailureInput {
|
|
|
19
19
|
export class StudioSaveHttpError extends Error {
|
|
20
20
|
readonly statusCode: number;
|
|
21
21
|
readonly alreadyToasted: boolean;
|
|
22
|
+
readonly heldFile: boolean;
|
|
22
23
|
|
|
23
|
-
constructor(
|
|
24
|
+
constructor(
|
|
25
|
+
message: string,
|
|
26
|
+
statusCode: number,
|
|
27
|
+
options: { alreadyToasted?: boolean; heldFile?: boolean } = {},
|
|
28
|
+
) {
|
|
24
29
|
super(message);
|
|
25
30
|
this.name = "StudioSaveHttpError";
|
|
26
31
|
this.statusCode = statusCode;
|
|
27
32
|
this.alreadyToasted = options.alreadyToasted ?? false;
|
|
33
|
+
this.heldFile = options.heldFile ?? false;
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
|
|
@@ -188,10 +194,27 @@ export function trackStudioEditBlocked(input: StudioSaveFailureInput): void {
|
|
|
188
194
|
trackStudioEvent("edit_blocked", buildStudioSaveFailureProperties(input));
|
|
189
195
|
}
|
|
190
196
|
|
|
197
|
+
const HELD_FILE_WORDS = {
|
|
198
|
+
busy: (file: string) => `${file} is open in another program. Close it there, then try again.`,
|
|
199
|
+
permission: (file: string) =>
|
|
200
|
+
`${file} can't be changed: it is read-only or protected. Check its permissions, then try again.`,
|
|
201
|
+
} as const;
|
|
202
|
+
|
|
203
|
+
function heldFileMessage(body: string, path: string | undefined): string | null {
|
|
204
|
+
if (!path) return null;
|
|
205
|
+
try {
|
|
206
|
+
const why: unknown = (JSON.parse(body) as { why?: unknown }).why;
|
|
207
|
+
if (why !== "busy" && why !== "permission") return null;
|
|
208
|
+
return HELD_FILE_WORDS[why](path.split(/[\\/]/).pop() ?? path);
|
|
209
|
+
} catch {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
191
214
|
export async function createStudioSaveHttpError(
|
|
192
215
|
response: Response,
|
|
193
216
|
fallbackMessage: string,
|
|
194
|
-
options: { alreadyToasted?: boolean } = {},
|
|
217
|
+
options: { alreadyToasted?: boolean; path?: string } = {},
|
|
195
218
|
): Promise<StudioSaveHttpError> {
|
|
196
219
|
let body = "";
|
|
197
220
|
try {
|
|
@@ -200,12 +223,18 @@ export async function createStudioSaveHttpError(
|
|
|
200
223
|
body = "";
|
|
201
224
|
}
|
|
202
225
|
const detail = body.trim().slice(0, 300);
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
226
|
+
const held = heldFileMessage(body, options.path);
|
|
227
|
+
const message =
|
|
228
|
+
held ??
|
|
229
|
+
(detail
|
|
230
|
+
? `${fallbackMessage} (${response.status}): ${detail}`
|
|
231
|
+
: `${fallbackMessage} (${response.status})`);
|
|
232
|
+
return new StudioSaveHttpError(message, response.status, { ...options, heldFile: held !== null });
|
|
207
233
|
}
|
|
208
234
|
|
|
235
|
+
export const heldFileWords = (error: unknown): string | null =>
|
|
236
|
+
error instanceof StudioSaveHttpError && error.heldFile ? error.message : null;
|
|
237
|
+
|
|
209
238
|
export async function retryStudioSave<T>(
|
|
210
239
|
operation: (attempt: number) => Promise<T>,
|
|
211
240
|
options: {
|
|
@@ -25,7 +25,9 @@ async function insertTimelineComposition(input: {
|
|
|
25
25
|
buildProjectApiPath(input.projectId, `/files/${encodeURIComponent(input.targetPath)}`),
|
|
26
26
|
);
|
|
27
27
|
if (!current.ok) {
|
|
28
|
-
throw await createStudioSaveHttpError(current, `Failed to read ${input.targetPath}
|
|
28
|
+
throw await createStudioSaveHttpError(current, `Failed to read ${input.targetPath}`, {
|
|
29
|
+
path: input.targetPath,
|
|
30
|
+
});
|
|
29
31
|
}
|
|
30
32
|
const snapshot = (await current.json()) as { version?: string };
|
|
31
33
|
if (typeof snapshot.version !== "string") throw new Error("Missing composition file version");
|