@vivix-labs/short-drama-compare 1.0.0-beta.21 → 1.0.0-beta.22
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/client-code.js +489 -135
- package/package.json +4 -1
package/dist/client-code.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// packages/short-drama-compare/src/client.tsx
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as z6 } from "vivix-studio/sdk/shared";
|
|
3
3
|
|
|
4
4
|
// packages/short-drama-compare/src/compare-view.tsx
|
|
5
|
-
import { useState as
|
|
5
|
+
import { useEffect as useEffect10, useState as useState16 } from "react";
|
|
6
|
+
import { z as z5 } from "vivix-studio/sdk/shared";
|
|
6
7
|
|
|
7
8
|
// packages/short-drama-compare/src/compare.tsx
|
|
8
|
-
import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
9
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState13 } from "react";
|
|
9
10
|
|
|
10
11
|
// packages/ui-system/dist/button.js
|
|
11
12
|
import { jsx as _jsx2, jsxs as _jsxs2 } from "react/jsx-runtime";
|
|
@@ -375,14 +376,14 @@ import { useState as useState3 } from "react";
|
|
|
375
376
|
function CoverPreview(props) {
|
|
376
377
|
return _jsx6(Preview, { ...props }, JSON.stringify([props.kind, props.src]));
|
|
377
378
|
}
|
|
378
|
-
function Preview({ className, ref, kind = "image", src, pending, iconSize = 20, children }) {
|
|
379
|
+
function Preview({ className, ref, kind: kind2 = "image", src, pending, iconSize = 20, children }) {
|
|
379
380
|
const [mediaState, setMediaState] = useState3("loading");
|
|
380
|
-
const media = src && (
|
|
381
|
+
const media = src && (kind2 === "image" || kind2 === "video");
|
|
381
382
|
const state = pending ? "loading" : media ? mediaState : children ? "ready" : "empty";
|
|
382
|
-
const iconKind =
|
|
383
|
+
const iconKind = kind2 === "video" || kind2 === "audio" ? kind2 : kind2 === "text" ? "script" : "image";
|
|
383
384
|
const ready = () => setMediaState("ready");
|
|
384
385
|
const failed = () => setMediaState("empty");
|
|
385
|
-
return _jsx6("span", { ref, className: `vx-cover-preview ${className}`, "data-cover-state": state, "aria-hidden": "true", children: state === "empty" ? _jsx6(Icon, { name: `placeholder-${iconKind}`, size: iconSize }) : !pending && media ?
|
|
386
|
+
return _jsx6("span", { ref, className: `vx-cover-preview ${className}`, "data-cover-state": state, "aria-hidden": "true", children: state === "empty" ? _jsx6(Icon, { name: `placeholder-${iconKind}`, size: iconSize }) : !pending && media ? kind2 === "video" ? _jsx6("video", { src, muted: true, playsInline: true, preload: "auto", onLoadedData: ready, onError: failed }) : _jsx6("img", { src, alt: "", loading: "lazy", onLoad: ready, onError: failed }) : state === "ready" ? children : null });
|
|
386
387
|
}
|
|
387
388
|
|
|
388
389
|
// packages/ui-system/dist/input.js
|
|
@@ -968,6 +969,290 @@ function episodeSeriesNumber(episodes, episode2) {
|
|
|
968
969
|
) + 1;
|
|
969
970
|
}
|
|
970
971
|
|
|
972
|
+
// packages/project-studio/dist/shared.js
|
|
973
|
+
import { PluginError, z as z2 } from "vivix-studio/sdk/shared";
|
|
974
|
+
import { z as z3 } from "vivix-studio/sdk/shared";
|
|
975
|
+
import { z as z4, defineOperation } from "vivix-studio/sdk/shared";
|
|
976
|
+
import { z as z32 } from "vivix-studio/sdk/shared";
|
|
977
|
+
var creditsFormat = new Intl.NumberFormat("en-US", {
|
|
978
|
+
minimumFractionDigits: 1,
|
|
979
|
+
maximumFractionDigits: 1,
|
|
980
|
+
useGrouping: false
|
|
981
|
+
});
|
|
982
|
+
var taskBilling = z3.object({
|
|
983
|
+
status: z3.enum(["pending", "settled", "released", "unavailable"]),
|
|
984
|
+
credits: z3.string().regex(/^\d+(?:\.\d+)?$/).nullable()
|
|
985
|
+
}).strict().refine(
|
|
986
|
+
(value) => value.status === "settled" ? value.credits !== null : value.status === "released" ? value.credits === "0" : value.credits === null
|
|
987
|
+
);
|
|
988
|
+
var estimateIdentity = z2.object({
|
|
989
|
+
origin: z2.url(),
|
|
990
|
+
personId: z2.string().min(1),
|
|
991
|
+
workspaceId: z2.string().min(1)
|
|
992
|
+
}).strict();
|
|
993
|
+
var vivixVoiceModel = "vivix-tts-1.0";
|
|
994
|
+
var defaultVoiceOperations = ["voice.design", "voice.clone"];
|
|
995
|
+
function resolveGenerationInput(input, ctx) {
|
|
996
|
+
const defaultsToVivix = defaultVoiceOperations.some(
|
|
997
|
+
(operation) => operation === input.capabilityId
|
|
998
|
+
);
|
|
999
|
+
const modelId = input.modelId ?? (defaultsToVivix ? vivixVoiceModel : void 0);
|
|
1000
|
+
if (!modelId) {
|
|
1001
|
+
ctx.addIssue({
|
|
1002
|
+
code: "custom",
|
|
1003
|
+
path: ["modelId"],
|
|
1004
|
+
message: "Select a model for this operation."
|
|
1005
|
+
});
|
|
1006
|
+
return z2.NEVER;
|
|
1007
|
+
}
|
|
1008
|
+
if (input.prompt === void 0 && !defaultsToVivix && input.capabilityId !== "voice.create") {
|
|
1009
|
+
ctx.addIssue({
|
|
1010
|
+
code: "custom",
|
|
1011
|
+
path: ["prompt"],
|
|
1012
|
+
message: "A prompt is required for this operation."
|
|
1013
|
+
});
|
|
1014
|
+
return z2.NEVER;
|
|
1015
|
+
}
|
|
1016
|
+
return { ...input, modelId, prompt: input.prompt ?? "" };
|
|
1017
|
+
}
|
|
1018
|
+
var fixedRef = z32.object({ storeId: z32.uuid(), objectId: z32.uuid(), versionId: z32.uuid() }).strict();
|
|
1019
|
+
var copy = z32.string().max(8e3).default("");
|
|
1020
|
+
var clipScript = z32.object({
|
|
1021
|
+
title: z32.string().trim().min(1).max(200),
|
|
1022
|
+
visual: copy,
|
|
1023
|
+
voiceover: copy,
|
|
1024
|
+
onScreenText: copy,
|
|
1025
|
+
cta: copy,
|
|
1026
|
+
plannedDurationMs: z32.number().int().positive().nullable().default(null)
|
|
1027
|
+
}).strict();
|
|
1028
|
+
var adBrief = z32.object({
|
|
1029
|
+
product: copy,
|
|
1030
|
+
category: copy,
|
|
1031
|
+
audience: copy,
|
|
1032
|
+
sellingPoints: copy,
|
|
1033
|
+
channel: copy,
|
|
1034
|
+
aspectRatio: z32.string().max(40).nullable().default(null),
|
|
1035
|
+
targetDurationMs: z32.number().int().positive().nullable().default(null),
|
|
1036
|
+
body: copy,
|
|
1037
|
+
productRefs: z32.array(fixedRef).max(100).default([]),
|
|
1038
|
+
modelRefs: z32.array(fixedRef).max(100).default([])
|
|
1039
|
+
}).strict();
|
|
1040
|
+
var adFilm = z32.object({
|
|
1041
|
+
title: z32.string().trim().min(1).max(150),
|
|
1042
|
+
source: fixedRef,
|
|
1043
|
+
width: z32.number().int().positive().max(8192),
|
|
1044
|
+
height: z32.number().int().positive().max(8192),
|
|
1045
|
+
aspectRatio: z32.string().regex(/^\d+:\d+$/)
|
|
1046
|
+
}).strict();
|
|
1047
|
+
var adStoryboard = z32.object({
|
|
1048
|
+
brief: adBrief,
|
|
1049
|
+
films: z32.array(adFilm).max(100).optional(),
|
|
1050
|
+
clips: z32.array(
|
|
1051
|
+
z32.object({
|
|
1052
|
+
assetId: z32.uuid(),
|
|
1053
|
+
filmId: z32.uuid().optional(),
|
|
1054
|
+
script: clipScript,
|
|
1055
|
+
edits: z32.array(z32.object({ sourceVersionId: z32.uuid(), editRef: fixedRef }).strict()).max(200)
|
|
1056
|
+
}).strict()
|
|
1057
|
+
).max(200)
|
|
1058
|
+
}).strict().superRefine((value, context) => {
|
|
1059
|
+
if (new Set(value.clips.map((c) => c.assetId)).size !== value.clips.length)
|
|
1060
|
+
context.addIssue({ code: "custom", message: "A clip can appear only once in a storyboard." });
|
|
1061
|
+
for (const clip of value.clips)
|
|
1062
|
+
if (new Set(clip.edits.map((e) => e.sourceVersionId)).size !== clip.edits.length)
|
|
1063
|
+
context.addIssue({
|
|
1064
|
+
code: "custom",
|
|
1065
|
+
message: "Each candidate has one current edit binding."
|
|
1066
|
+
});
|
|
1067
|
+
});
|
|
1068
|
+
var projectType = z4.enum(["short-drama", "product-ad", "other"]);
|
|
1069
|
+
var studioConfig = z4.object({
|
|
1070
|
+
role: z4.enum(["project", "coordinator"]).default("project"),
|
|
1071
|
+
projectType: projectType.optional(),
|
|
1072
|
+
dataInstance: z4.string().min(1).default("user:data"),
|
|
1073
|
+
apiInstance: z4.string().min(1).default("api"),
|
|
1074
|
+
libraryInstance: z4.string().min(1).nullable().default(null),
|
|
1075
|
+
coordinatorInstance: z4.string().min(1).optional()
|
|
1076
|
+
}).strict();
|
|
1077
|
+
var versionRef = z4.object({ storeId: z4.uuid(), objectId: z4.uuid(), versionId: z4.uuid() }).strict();
|
|
1078
|
+
var assetAspectRatios = [
|
|
1079
|
+
"16:9",
|
|
1080
|
+
"9:16",
|
|
1081
|
+
"1:1",
|
|
1082
|
+
"4:3",
|
|
1083
|
+
"3:4",
|
|
1084
|
+
"2:3",
|
|
1085
|
+
"3:2",
|
|
1086
|
+
"21:9"
|
|
1087
|
+
];
|
|
1088
|
+
function assetAspectRatio(payload) {
|
|
1089
|
+
const parameters = payload?.generation?.parameters;
|
|
1090
|
+
for (const value of [
|
|
1091
|
+
parameters?.aspectRatio,
|
|
1092
|
+
parameters?.aspect_ratio,
|
|
1093
|
+
parameters?.["aspect-ratio"]
|
|
1094
|
+
]) {
|
|
1095
|
+
if (typeof value !== "string") continue;
|
|
1096
|
+
const match = /^\s*([1-9]\d*)\s*[:/]\s*([1-9]\d*)\s*$/.exec(value);
|
|
1097
|
+
if (match) return `${match[1]}:${match[2]}`;
|
|
1098
|
+
}
|
|
1099
|
+
const width = Number(payload?.width);
|
|
1100
|
+
const height = Number(payload?.height);
|
|
1101
|
+
if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width <= 0 || height <= 0)
|
|
1102
|
+
return void 0;
|
|
1103
|
+
return assetAspectRatios.find((label) => {
|
|
1104
|
+
const [w, h] = label.split(":").map(Number);
|
|
1105
|
+
return Math.abs(width / height / (w / h) - 1) <= 0.02;
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
var tags = z4.array(z4.string().trim().min(1).max(64)).max(50).transform((x) => [...new Set(x)]).default([]);
|
|
1109
|
+
var kind = z4.enum(["text", "image", "video", "audio", "file"]);
|
|
1110
|
+
var projectData = z4.object({
|
|
1111
|
+
name: z4.string().trim().min(1).max(120),
|
|
1112
|
+
description: z4.string().max(4e3).default(""),
|
|
1113
|
+
status: z4.enum(["draft", "active", "archived"]).default("draft"),
|
|
1114
|
+
aspectRatio: z4.string().nullable().default(null),
|
|
1115
|
+
projectType: projectType.optional(),
|
|
1116
|
+
coverRef: versionRef.nullable().default(null),
|
|
1117
|
+
briefRef: z4.object({ storeId: z4.uuid(), objectId: z4.uuid() }).strict().nullable().optional().transform(() => void 0),
|
|
1118
|
+
tags
|
|
1119
|
+
}).strict();
|
|
1120
|
+
var assetData = z4.object({
|
|
1121
|
+
projectId: z4.uuid(),
|
|
1122
|
+
name: z4.string().trim().min(1).max(200),
|
|
1123
|
+
kind,
|
|
1124
|
+
purpose: z4.enum([
|
|
1125
|
+
"reference",
|
|
1126
|
+
"script",
|
|
1127
|
+
"shot",
|
|
1128
|
+
"music",
|
|
1129
|
+
"voice",
|
|
1130
|
+
"speech",
|
|
1131
|
+
"subtitle",
|
|
1132
|
+
"final",
|
|
1133
|
+
"other"
|
|
1134
|
+
]).default("other"),
|
|
1135
|
+
origin: z4.enum(["upload", "library", "generated", "authored"]),
|
|
1136
|
+
orderKey: z4.number().int().nullable().default(null),
|
|
1137
|
+
tags,
|
|
1138
|
+
lifecycle: z4.enum(["draft", "ready", "archived"]).default("draft"),
|
|
1139
|
+
sourceRef: versionRef.nullable().default(null),
|
|
1140
|
+
adoptedVersionId: z4.uuid().nullable().default(null)
|
|
1141
|
+
}).strict();
|
|
1142
|
+
var storedAssetData = assetData.extend({
|
|
1143
|
+
purpose: z4.union([assetData.shape.purpose, z4.literal("speech")])
|
|
1144
|
+
});
|
|
1145
|
+
var generationFields = z4.object({
|
|
1146
|
+
targetAssetId: z4.uuid().optional(),
|
|
1147
|
+
taskName: z4.string().trim().min(1).max(200).optional(),
|
|
1148
|
+
context: z4.record(z4.string().min(1).max(64), z4.string().min(1).max(200)).describe(
|
|
1149
|
+
"Owning-domain binding stored with the task. Short drama passes { episodeId, shotId } so the finished take attaches to that shot; production.generateShot sets it automatically."
|
|
1150
|
+
).optional(),
|
|
1151
|
+
expectedRevision: z4.number().int().positive().optional(),
|
|
1152
|
+
newAsset: z4.object({
|
|
1153
|
+
name: z4.string().trim().min(1).max(200),
|
|
1154
|
+
kind: z4.enum(["image", "video", "audio"]),
|
|
1155
|
+
purpose: assetData.shape.purpose.unwrap().optional(),
|
|
1156
|
+
tags: tags.unwrap().optional()
|
|
1157
|
+
}).strict().optional(),
|
|
1158
|
+
modelId: z4.string().min(1),
|
|
1159
|
+
capabilityId: z4.string().min(1),
|
|
1160
|
+
prompt: z4.string().max(32e3).optional(),
|
|
1161
|
+
voiceRef: versionRef.optional(),
|
|
1162
|
+
parameters: z4.record(z4.string(), z4.unknown()).default({}),
|
|
1163
|
+
outputCount: z4.number().int().min(1).max(100).default(1),
|
|
1164
|
+
inputs: z4.array(
|
|
1165
|
+
z4.object({
|
|
1166
|
+
ref: versionRef,
|
|
1167
|
+
role: z4.string().min(1),
|
|
1168
|
+
order: z4.number().int().nonnegative(),
|
|
1169
|
+
weight: z4.number().finite().nullable().default(null)
|
|
1170
|
+
}).strict()
|
|
1171
|
+
).max(100).default([]),
|
|
1172
|
+
baseVersionId: z4.uuid().optional(),
|
|
1173
|
+
changeRequest: z4.string().trim().min(1).max(4e3).optional(),
|
|
1174
|
+
preserveRequest: z4.string().max(4e3).default(""),
|
|
1175
|
+
anchor: z4.object({ kind: z4.literal("whole") }).strict().optional().describe("Deprecated whole-version selection."),
|
|
1176
|
+
retryOfTaskId: z4.uuid().optional(),
|
|
1177
|
+
acknowledgeUnknown: z4.boolean().optional()
|
|
1178
|
+
}).strict();
|
|
1179
|
+
var generationInput = generationFields.extend({
|
|
1180
|
+
modelId: generationFields.shape.modelId.optional().describe("Defaults to vivix-tts-1.0 for voice.design and voice.clone.")
|
|
1181
|
+
}).transform(resolveGenerationInput);
|
|
1182
|
+
var projectSettingsInput = z4.object({
|
|
1183
|
+
projectId: z4.uuid(),
|
|
1184
|
+
expectedRevision: z4.number().int().positive(),
|
|
1185
|
+
changes: projectData.pick({ name: true, description: true, tags: true, aspectRatio: true, coverRef: true }).extend({
|
|
1186
|
+
description: projectData.shape.description.unwrap(),
|
|
1187
|
+
tags: projectData.shape.tags.unwrap(),
|
|
1188
|
+
aspectRatio: projectData.shape.aspectRatio.unwrap(),
|
|
1189
|
+
coverRef: projectData.shape.coverRef.unwrap()
|
|
1190
|
+
}).partial().strict()
|
|
1191
|
+
}).strict();
|
|
1192
|
+
function generationReceiptPredecessors() {
|
|
1193
|
+
const legacy = generationFields.omit({ voiceRef: true }).extend({
|
|
1194
|
+
prompt: generationFields.shape.prompt.unwrap(),
|
|
1195
|
+
newAsset: generationFields.shape.newAsset.unwrap().omit({ purpose: true, tags: true }).optional(),
|
|
1196
|
+
anchor: z4.discriminatedUnion("kind", [
|
|
1197
|
+
z4.object({ kind: z4.literal("whole") }).strict(),
|
|
1198
|
+
z4.object({
|
|
1199
|
+
kind: z4.literal("timeRange"),
|
|
1200
|
+
startMs: z4.number().int().nonnegative(),
|
|
1201
|
+
endMs: z4.number().int().nonnegative()
|
|
1202
|
+
}).strict()
|
|
1203
|
+
]).default({ kind: "whole" })
|
|
1204
|
+
});
|
|
1205
|
+
const voice = legacy.extend({
|
|
1206
|
+
prompt: legacy.shape.prompt.optional(),
|
|
1207
|
+
voiceRef: versionRef.optional()
|
|
1208
|
+
}).refine(
|
|
1209
|
+
(input) => input.prompt !== void 0 || ["voice.clone", "voice.create"].includes(input.capabilityId)
|
|
1210
|
+
).transform((input) => ({ ...input, prompt: input.prompt ?? "" }));
|
|
1211
|
+
return [
|
|
1212
|
+
{
|
|
1213
|
+
packageVersion: "1.0.0-beta.19",
|
|
1214
|
+
packageIntegrity: "e70b5c3b91d551bbd73c0b181eadbe92e71b66fbc6a642004184740a14bd4c06",
|
|
1215
|
+
input: legacy
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
packageVersion: "1.0.0-beta.20",
|
|
1219
|
+
packageIntegrity: "febb0e966d82d98555beab936e2d735dab3cc98d6101d19e8b692c1ebe0dbe8a",
|
|
1220
|
+
input: voice
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
packageVersion: "1.0.0-beta.22",
|
|
1224
|
+
packageIntegrity: "6fefdd978b7441df8598373da79d22d945587c8656de4e92b64cb615eec30afb",
|
|
1225
|
+
input: voice
|
|
1226
|
+
},
|
|
1227
|
+
{ packageVersion: "1.0.0-beta.25", input: generationInput },
|
|
1228
|
+
// The non-voice beta.22 branch used the original required prompt schema.
|
|
1229
|
+
{ packageVersion: "1.0.0-beta.22", input: legacy }
|
|
1230
|
+
].map((previous) => ({ ...previous, output: z4.any() }));
|
|
1231
|
+
}
|
|
1232
|
+
var generationSubmitOperation = defineOperation({
|
|
1233
|
+
id: "generation.submit",
|
|
1234
|
+
title: "Generate",
|
|
1235
|
+
description: "Submit one media generation without approval, retaining its paid request identity. Pass context with the owning domain identifiers; without it the output is only stored in the media library.",
|
|
1236
|
+
input: generationInput,
|
|
1237
|
+
receiptPredecessors: generationReceiptPredecessors,
|
|
1238
|
+
output: z4.any(),
|
|
1239
|
+
effects: ["write", "paid"],
|
|
1240
|
+
confirm: "none"
|
|
1241
|
+
});
|
|
1242
|
+
var favoriteData = z4.object({ ref: versionRef }).strict();
|
|
1243
|
+
var sqlScalar = z4.union([z4.string(), z4.number().finite(), z4.null()]);
|
|
1244
|
+
var globalQueryInput = z4.object({
|
|
1245
|
+
sql: z4.string().trim().min(1),
|
|
1246
|
+
params: z4.union([z4.array(sqlScalar), z4.record(z4.string(), sqlScalar)]).optional(),
|
|
1247
|
+
timeoutMs: z4.number().int().positive().optional(),
|
|
1248
|
+
maxRows: z4.number().int().positive().optional(),
|
|
1249
|
+
limit: z4.number().int().min(1).max(200).optional(),
|
|
1250
|
+
offset: z4.number().int().nonnegative().optional(),
|
|
1251
|
+
source: z4.enum(["projects", "assets", "tasks"]),
|
|
1252
|
+
excludeProjectIds: z4.array(z4.uuid()).optional(),
|
|
1253
|
+
catalog: z4.array(z4.object({ id: z4.string().min(1), name: z4.string(), available: z4.boolean() }).strict()).optional()
|
|
1254
|
+
}).strict();
|
|
1255
|
+
|
|
971
1256
|
// packages/short-drama-compare/src/sequence-player.tsx
|
|
972
1257
|
import { useEffect as useEffect7, useMemo, useRef as useRef7, useState as useState11 } from "react";
|
|
973
1258
|
|
|
@@ -991,6 +1276,7 @@ function SequencePlayer({
|
|
|
991
1276
|
title: title2,
|
|
992
1277
|
clips,
|
|
993
1278
|
pending = false,
|
|
1279
|
+
allowStillPlayback = true,
|
|
994
1280
|
initialShotId,
|
|
995
1281
|
showFilmstrip = true,
|
|
996
1282
|
onEdit,
|
|
@@ -1034,6 +1320,7 @@ function SequencePlayer({
|
|
|
1034
1320
|
setSeekRevision((revision2) => revision2 + 1);
|
|
1035
1321
|
}
|
|
1036
1322
|
function togglePlay() {
|
|
1323
|
+
if (!canPlay) return;
|
|
1037
1324
|
setShowCover(false);
|
|
1038
1325
|
if (!playing && position >= duration) seek(0);
|
|
1039
1326
|
setPlaying(!playing);
|
|
@@ -1044,7 +1331,7 @@ function SequencePlayer({
|
|
|
1044
1331
|
if (active.end >= duration) setPlaying(false);
|
|
1045
1332
|
}
|
|
1046
1333
|
useEffect7(() => {
|
|
1047
|
-
if (!active || !playing || active.src) return;
|
|
1334
|
+
if (!allowStillPlayback || !active || !playing || active.src) return;
|
|
1048
1335
|
const start = performance.now();
|
|
1049
1336
|
const initial = positionRef.current;
|
|
1050
1337
|
let frame = requestAnimationFrame(function tick(now) {
|
|
@@ -1054,7 +1341,7 @@ function SequencePlayer({
|
|
|
1054
1341
|
else if (next >= duration) setPlaying(false);
|
|
1055
1342
|
});
|
|
1056
1343
|
return () => cancelAnimationFrame(frame);
|
|
1057
|
-
}, [active, duration, playing, seekRevision]);
|
|
1344
|
+
}, [active, allowStillPlayback, duration, playing, seekRevision]);
|
|
1058
1345
|
useEffect7(() => {
|
|
1059
1346
|
const element = video.current;
|
|
1060
1347
|
if (!element || !active) return;
|
|
@@ -1113,7 +1400,7 @@ function SequencePlayer({
|
|
|
1113
1400
|
/* @__PURE__ */ jsx("p", { role: "status", children: pending ? "Loading preview\u2026" : mediaMessage ?? "This shot has no video or storyboard still yet." }),
|
|
1114
1401
|
onEdit && /* @__PURE__ */ jsx(Button, { label: "Open shot", width: "hug", onClick: () => onEdit(active.id) })
|
|
1115
1402
|
] });
|
|
1116
|
-
const canPlay = !videoFailed && (videoCount > 0 || stillCount > 0);
|
|
1403
|
+
const canPlay = !videoFailed && (videoCount > 0 || allowStillPlayback && stillCount > 0);
|
|
1117
1404
|
const withCover = showCover && (canPlay || pending) && cover;
|
|
1118
1405
|
const artwork = cover?.artwork !== failedArtwork ? cover?.artwork : void 0;
|
|
1119
1406
|
const filmstrip = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1248,6 +1535,7 @@ function LoadMessage({ error, onRetry }) {
|
|
|
1248
1535
|
|
|
1249
1536
|
// packages/short-drama-compare/src/compare.tsx
|
|
1250
1537
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1538
|
+
import { createElement } from "react";
|
|
1251
1539
|
var compareSlots = ["A", "B", "C", "D"];
|
|
1252
1540
|
function Compare(props) {
|
|
1253
1541
|
const { episode: episode2, mutate, busy } = props;
|
|
@@ -1255,7 +1543,12 @@ function Compare(props) {
|
|
|
1255
1543
|
const selectionKey = episode2 && shot2 ? JSON.stringify([episode2.id, shot2.id]) : void 0;
|
|
1256
1544
|
const choices = selectionKey && props.candidateChoices[selectionKey] || [];
|
|
1257
1545
|
const candidates = (episode2?.shots ?? []).flatMap(
|
|
1258
|
-
(scene) => scene.takes.map((take2) => ({
|
|
1546
|
+
(scene) => scene.takes.map((take2, index) => ({
|
|
1547
|
+
scene,
|
|
1548
|
+
take: take2,
|
|
1549
|
+
label: `Take ${index + 1} \xB7 ${take2.title}`,
|
|
1550
|
+
key: JSON.stringify([scene.id, take2.id])
|
|
1551
|
+
}))
|
|
1259
1552
|
);
|
|
1260
1553
|
const available = candidates.filter(
|
|
1261
1554
|
(entry) => entry.scene.id === shot2?.id && !choices.includes(entry.key)
|
|
@@ -1282,6 +1575,25 @@ function Compare(props) {
|
|
|
1282
1575
|
return /* @__PURE__ */ jsxs3("section", { "aria-label": "Version comparison", children: [
|
|
1283
1576
|
/* @__PURE__ */ jsxs3("header", { className: "drama-compare-bar", children: [
|
|
1284
1577
|
/* @__PURE__ */ jsx3("h2", { children: "Compare" }),
|
|
1578
|
+
episode2 && shot2 && /* @__PURE__ */ jsxs3("label", { children: [
|
|
1579
|
+
"Each Scene",
|
|
1580
|
+
/* @__PURE__ */ jsx3(
|
|
1581
|
+
"select",
|
|
1582
|
+
{
|
|
1583
|
+
value: shot2.id,
|
|
1584
|
+
onChange: (event) => props.navigate({
|
|
1585
|
+
view: "compare",
|
|
1586
|
+
episodeId: episode2.id,
|
|
1587
|
+
shotId: event.currentTarget.value
|
|
1588
|
+
}),
|
|
1589
|
+
children: episode2.shots.map((scene, index) => /* @__PURE__ */ jsxs3("option", { value: scene.id, children: [
|
|
1590
|
+
index + 1,
|
|
1591
|
+
". ",
|
|
1592
|
+
scene.title
|
|
1593
|
+
] }, scene.id))
|
|
1594
|
+
}
|
|
1595
|
+
)
|
|
1596
|
+
] }),
|
|
1285
1597
|
!episode2 && /* @__PURE__ */ jsx3(
|
|
1286
1598
|
Button,
|
|
1287
1599
|
{
|
|
@@ -1306,18 +1618,18 @@ function Compare(props) {
|
|
|
1306
1618
|
const replacements = candidates.filter((candidate) => candidate !== entry).map((candidate) => ({
|
|
1307
1619
|
id: candidate.key,
|
|
1308
1620
|
preview: /* @__PURE__ */ jsx3(TakeCover, { assets: props.assets, take: candidate.take }),
|
|
1309
|
-
label: (slots.includes(candidate) ? "Swap with " : "") + candidate.scene.title + " \xB7 " + candidate.
|
|
1621
|
+
label: (slots.includes(candidate) ? "Swap with " : "") + candidate.scene.title + " \xB7 " + candidate.label,
|
|
1310
1622
|
onSelect: () => choose(index, candidate)
|
|
1311
1623
|
}));
|
|
1312
1624
|
return /* @__PURE__ */ jsxs3("section", { "aria-label": `Candidate ${side}`, className: "drama-compare-column", children: [
|
|
1313
|
-
entry ? /* @__PURE__ */
|
|
1625
|
+
entry ? /* @__PURE__ */ createElement(
|
|
1314
1626
|
CandidatePlayer,
|
|
1315
1627
|
{
|
|
1316
1628
|
...props,
|
|
1317
1629
|
shot: entry.scene,
|
|
1630
|
+
key: entry.key,
|
|
1318
1631
|
take: entry.take,
|
|
1319
|
-
captureId: `candidate-${side}
|
|
1320
|
-
cover: true
|
|
1632
|
+
captureId: `candidate-${side}`
|
|
1321
1633
|
}
|
|
1322
1634
|
) : /* @__PURE__ */ jsx3("div", { className: "drama-compare-empty", children: shot2 && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1323
1635
|
/* @__PURE__ */ jsx3("p", { children: "No video selected" }),
|
|
@@ -1333,7 +1645,7 @@ function Compare(props) {
|
|
|
1333
1645
|
] }) }),
|
|
1334
1646
|
/* @__PURE__ */ jsxs3("div", { className: "drama-compare-heading", children: [
|
|
1335
1647
|
/* @__PURE__ */ jsxs3("div", { children: [
|
|
1336
|
-
/* @__PURE__ */ jsx3("h3", { children:
|
|
1648
|
+
/* @__PURE__ */ jsx3("h3", { children: entry?.label ?? `Candidate ${side}` }),
|
|
1337
1649
|
/* @__PURE__ */ jsxs3("span", { children: [
|
|
1338
1650
|
episode2 && `Episode ${episodeSeriesNumber(props.episodes, episode2)} \xB7 ${episodeVersionLabel(episode2)}`,
|
|
1339
1651
|
take2 && scene?.selectedTakeId === take2.id ? " \xB7 Selected" : ""
|
|
@@ -1413,150 +1725,147 @@ function CandidateMetadata({
|
|
|
1413
1725
|
() => (take2 && assets.version?.(take2.ref)) ?? Promise.resolve(null),
|
|
1414
1726
|
[assets, take2]
|
|
1415
1727
|
);
|
|
1416
|
-
const
|
|
1417
|
-
const
|
|
1728
|
+
const [attempt, retry] = useState13(0);
|
|
1729
|
+
const details = useRequest(read, attempt);
|
|
1730
|
+
const version = details?.data;
|
|
1731
|
+
const missing = take2 && !details ? "Loading\u2026" : details?.error ? "Unavailable" : "--";
|
|
1732
|
+
const aspect = assetAspectRatio({ ...version, generation: { parameters: version?.parameters } });
|
|
1733
|
+
const format = [aspect, version?.resolution].map((value) => typeof value === "string" ? value.trim() : "").filter(Boolean).join(" \xB7 ");
|
|
1418
1734
|
return /* @__PURE__ */ jsxs3("dl", { className: "drama-compare-metadata", children: [
|
|
1419
1735
|
/* @__PURE__ */ jsx3("dt", { children: "Shot" }),
|
|
1420
1736
|
/* @__PURE__ */ jsx3("dd", { children: scene?.trim() || "--" }),
|
|
1421
1737
|
/* @__PURE__ */ jsx3("dt", { children: "Model" }),
|
|
1422
|
-
/* @__PURE__ */ jsx3("dd", { children: version?.modelId?.trim() ||
|
|
1738
|
+
/* @__PURE__ */ jsx3("dd", { children: version?.modelId?.trim() || missing }),
|
|
1423
1739
|
/* @__PURE__ */ jsx3("dt", { children: "Format" }),
|
|
1424
|
-
/* @__PURE__ */ jsx3("dd", { children: format ||
|
|
1740
|
+
/* @__PURE__ */ jsx3("dd", { children: format || missing }),
|
|
1425
1741
|
/* @__PURE__ */ jsx3("dt", { children: "Duration" }),
|
|
1426
|
-
/* @__PURE__ */ jsx3("dd", { children: take2 ? `${formatDurationSeconds(take2.durationMs)} s` : "--" })
|
|
1742
|
+
/* @__PURE__ */ jsx3("dd", { children: take2 ? `${formatDurationSeconds(take2.durationMs)} s` : "--" }),
|
|
1743
|
+
details?.error && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1744
|
+
/* @__PURE__ */ jsx3("dt", { children: "Version details" }),
|
|
1745
|
+
/* @__PURE__ */ jsx3("dd", { children: /* @__PURE__ */ jsx3(
|
|
1746
|
+
Button,
|
|
1747
|
+
{
|
|
1748
|
+
label: "Retry details",
|
|
1749
|
+
variant: "text-link-sm",
|
|
1750
|
+
width: "hug",
|
|
1751
|
+
onClick: () => retry((value) => value + 1)
|
|
1752
|
+
}
|
|
1753
|
+
) })
|
|
1754
|
+
] })
|
|
1427
1755
|
] });
|
|
1428
1756
|
}
|
|
1429
1757
|
function CandidatePlayer({
|
|
1430
1758
|
shot: shot2,
|
|
1431
1759
|
take: take2,
|
|
1432
|
-
|
|
1433
|
-
|
|
1760
|
+
assets,
|
|
1761
|
+
captureId,
|
|
1762
|
+
registerTarget,
|
|
1763
|
+
episode: episode2,
|
|
1764
|
+
revision: revision2
|
|
1434
1765
|
}) {
|
|
1766
|
+
const [attempt, setAttempt] = useState13(0);
|
|
1767
|
+
const video = usePreview(assets, take2.ref, attempt);
|
|
1768
|
+
const still = usePreview(assets, shot2.still, attempt);
|
|
1769
|
+
const src = video?.url;
|
|
1770
|
+
const poster = still?.url;
|
|
1771
|
+
const issue = video?.issue ?? (src ? void 0 : still?.issue);
|
|
1435
1772
|
const clips = useMemo2(
|
|
1436
1773
|
() => [
|
|
1437
1774
|
{
|
|
1438
1775
|
id: shot2.id,
|
|
1439
1776
|
title: shot2.title,
|
|
1440
|
-
durationMs: take2
|
|
1441
|
-
|
|
1442
|
-
|
|
1777
|
+
durationMs: take2.durationMs,
|
|
1778
|
+
src,
|
|
1779
|
+
poster,
|
|
1780
|
+
mediaIssue: issue
|
|
1443
1781
|
}
|
|
1444
1782
|
],
|
|
1445
|
-
[shot2.id, shot2.title,
|
|
1446
|
-
);
|
|
1447
|
-
return /* @__PURE__ */ jsx3(
|
|
1448
|
-
ResolvedPlayer,
|
|
1449
|
-
{
|
|
1450
|
-
...props,
|
|
1451
|
-
label: take2?.title ?? shot2.title,
|
|
1452
|
-
shots: clips,
|
|
1453
|
-
cover: cover ? { title: take2?.title ?? shot2.title } : void 0,
|
|
1454
|
-
showFilmstrip: false
|
|
1455
|
-
},
|
|
1456
|
-
take2?.id ?? shot2.id
|
|
1783
|
+
[shot2.id, shot2.title, take2.durationMs, src, poster, issue]
|
|
1457
1784
|
);
|
|
1785
|
+
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1786
|
+
/* @__PURE__ */ jsx3(
|
|
1787
|
+
SequencePlayer,
|
|
1788
|
+
{
|
|
1789
|
+
title: take2.title,
|
|
1790
|
+
clips,
|
|
1791
|
+
pending: !video,
|
|
1792
|
+
allowStillPlayback: false,
|
|
1793
|
+
cover: { title: take2.title },
|
|
1794
|
+
showFilmstrip: false,
|
|
1795
|
+
decorate: (clip, content) => {
|
|
1796
|
+
const ref = clip.src ? take2.ref : clip.poster ? shot2.still : void 0;
|
|
1797
|
+
if (!ref || !episode2) return content;
|
|
1798
|
+
return /* @__PURE__ */ jsx3(
|
|
1799
|
+
CaptureTarget,
|
|
1800
|
+
{
|
|
1801
|
+
registerTarget,
|
|
1802
|
+
target: {
|
|
1803
|
+
kind: "media",
|
|
1804
|
+
id: `${captureId}:${episode2.id}:${clip.id}:${ref.versionId}`,
|
|
1805
|
+
label: clip.src ? `${clip.title} \xB7 ${take2.title}` : clip.title,
|
|
1806
|
+
revision: revision2,
|
|
1807
|
+
ref,
|
|
1808
|
+
episodeId: episode2.id,
|
|
1809
|
+
shotId: clip.id,
|
|
1810
|
+
takeId: clip.src ? take2.id : void 0
|
|
1811
|
+
},
|
|
1812
|
+
children: content
|
|
1813
|
+
}
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
),
|
|
1818
|
+
video?.issue && /* @__PURE__ */ jsx3(
|
|
1819
|
+
Button,
|
|
1820
|
+
{
|
|
1821
|
+
label: "Retry preview",
|
|
1822
|
+
variant: "text-link-sm",
|
|
1823
|
+
width: "hug",
|
|
1824
|
+
onClick: () => setAttempt((value) => value + 1)
|
|
1825
|
+
}
|
|
1826
|
+
)
|
|
1827
|
+
] });
|
|
1458
1828
|
}
|
|
1459
|
-
function
|
|
1460
|
-
|
|
1461
|
-
registerTarget,
|
|
1462
|
-
episode: episode2,
|
|
1463
|
-
revision: revision2,
|
|
1464
|
-
label,
|
|
1465
|
-
shots,
|
|
1466
|
-
captureId,
|
|
1467
|
-
initialShotId,
|
|
1468
|
-
showFilmstrip,
|
|
1469
|
-
onEdit,
|
|
1470
|
-
renderFilmstrip,
|
|
1471
|
-
cover,
|
|
1472
|
-
startPlaying
|
|
1473
|
-
}) {
|
|
1829
|
+
function usePreview(assets, ref, attempt) {
|
|
1830
|
+
const storeId = ref?.storeId, objectId = ref?.objectId, versionId = ref?.versionId;
|
|
1474
1831
|
const read = useCallback2(
|
|
1475
|
-
() =>
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
resolvePreview(assets, shot2.still)
|
|
1480
|
-
]);
|
|
1481
|
-
return {
|
|
1482
|
-
id: shot2.id,
|
|
1483
|
-
title: shot2.title,
|
|
1484
|
-
durationMs: shot2.durationMs,
|
|
1485
|
-
src: video.url,
|
|
1486
|
-
poster: still.url,
|
|
1487
|
-
mediaIssue: video.issue ?? (video.url ? void 0 : still.issue)
|
|
1488
|
-
};
|
|
1489
|
-
})
|
|
1832
|
+
() => resolvePreview(
|
|
1833
|
+
assets,
|
|
1834
|
+
storeId && objectId && versionId ? { storeId, objectId, versionId } : void 0,
|
|
1835
|
+
attempt
|
|
1490
1836
|
),
|
|
1491
|
-
[
|
|
1492
|
-
);
|
|
1493
|
-
const resolved = useRequest(read);
|
|
1494
|
-
const pending = !resolved?.data && !resolved?.error;
|
|
1495
|
-
const provisional = useMemo2(
|
|
1496
|
-
() => shots.map(({ id: id2, title: title2, durationMs: durationMs2, still, take: take2 }) => ({
|
|
1497
|
-
id: id2,
|
|
1498
|
-
title: title2,
|
|
1499
|
-
durationMs: durationMs2,
|
|
1500
|
-
poster: still && assets.previewUrl?.(still),
|
|
1501
|
-
src: take2 && assets.previewUrl?.(take2.ref)
|
|
1502
|
-
})),
|
|
1503
|
-
[shots, assets]
|
|
1504
|
-
);
|
|
1505
|
-
return /* @__PURE__ */ jsx3(
|
|
1506
|
-
SequencePlayer,
|
|
1507
|
-
{
|
|
1508
|
-
title: label,
|
|
1509
|
-
clips: resolved?.data ?? provisional,
|
|
1510
|
-
pending,
|
|
1511
|
-
initialShotId,
|
|
1512
|
-
onEdit,
|
|
1513
|
-
showFilmstrip,
|
|
1514
|
-
renderFilmstrip,
|
|
1515
|
-
cover,
|
|
1516
|
-
startPlaying,
|
|
1517
|
-
decorate: (clip, content) => {
|
|
1518
|
-
const shot2 = shots.find((shot3) => shot3.id === clip.id);
|
|
1519
|
-
const ref = clip.src ? shot2?.take?.ref : clip.poster ? shot2?.still : void 0;
|
|
1520
|
-
if (!ref || !episode2) return content;
|
|
1521
|
-
return /* @__PURE__ */ jsx3(
|
|
1522
|
-
CaptureTarget,
|
|
1523
|
-
{
|
|
1524
|
-
registerTarget,
|
|
1525
|
-
target: {
|
|
1526
|
-
kind: "media",
|
|
1527
|
-
id: `${captureId}:${episode2.id}:${clip.id}:${ref.versionId}`,
|
|
1528
|
-
label: shot2?.take && clip.src ? `${clip.title} \xB7 ${shot2.take.title}` : clip.title,
|
|
1529
|
-
revision: revision2,
|
|
1530
|
-
ref,
|
|
1531
|
-
episodeId: episode2.id,
|
|
1532
|
-
shotId: clip.id,
|
|
1533
|
-
takeId: clip.src ? shot2?.take?.id : void 0
|
|
1534
|
-
},
|
|
1535
|
-
children: content
|
|
1536
|
-
}
|
|
1537
|
-
);
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1837
|
+
[assets, storeId, objectId, versionId, attempt]
|
|
1540
1838
|
);
|
|
1839
|
+
const cached = ref && assets.previewUrl?.(ref);
|
|
1840
|
+
return useRequest(read)?.data ?? (cached ? { url: cached, issue: void 0 } : void 0);
|
|
1541
1841
|
}
|
|
1542
|
-
async function resolvePreview(assets, ref) {
|
|
1842
|
+
async function resolvePreview(assets, ref, attempt) {
|
|
1543
1843
|
if (!ref) return {};
|
|
1844
|
+
let timer;
|
|
1544
1845
|
try {
|
|
1545
|
-
const
|
|
1846
|
+
const request = attempt ? assets.resolve(ref) : assets.loadPreview?.(ref) ?? assets.resolve(ref);
|
|
1847
|
+
const url = await Promise.race([
|
|
1848
|
+
request,
|
|
1849
|
+
new Promise((done) => {
|
|
1850
|
+
timer = setTimeout(() => done(null), 3e4);
|
|
1851
|
+
})
|
|
1852
|
+
]);
|
|
1546
1853
|
return url ? { url } : { issue: "unavailable" };
|
|
1547
1854
|
} catch (error) {
|
|
1548
1855
|
const denied = typeof error === "object" && error !== null && "code" in error && error.code === "ACCESS_DENIED";
|
|
1549
1856
|
return {
|
|
1550
1857
|
issue: denied ? "permission" : "unavailable"
|
|
1551
1858
|
};
|
|
1859
|
+
} finally {
|
|
1860
|
+
clearTimeout(timer);
|
|
1552
1861
|
}
|
|
1553
1862
|
}
|
|
1554
1863
|
|
|
1555
1864
|
// packages/short-drama-compare/src/production-view.tsx
|
|
1556
|
-
import { useCallback as useCallback3, useEffect as useEffect9, useEffectEvent, useRef as useRef9, useState as
|
|
1865
|
+
import { useCallback as useCallback3, useEffect as useEffect9, useEffectEvent, useRef as useRef9, useState as useState15 } from "react";
|
|
1557
1866
|
|
|
1558
1867
|
// packages/short-drama-compare/src/episode-create.tsx
|
|
1559
|
-
import { useId as useId3, useState as
|
|
1868
|
+
import { useId as useId3, useState as useState14 } from "react";
|
|
1560
1869
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1561
1870
|
function CreateEpisode({
|
|
1562
1871
|
mutate,
|
|
@@ -1565,9 +1874,9 @@ function CreateEpisode({
|
|
|
1565
1874
|
onClose,
|
|
1566
1875
|
onCreated
|
|
1567
1876
|
}) {
|
|
1568
|
-
const [title2, setTitle] =
|
|
1569
|
-
const [error, setError] =
|
|
1570
|
-
const [episodeId] =
|
|
1877
|
+
const [title2, setTitle] = useState14(`Episode ${number}`);
|
|
1878
|
+
const [error, setError] = useState14("");
|
|
1879
|
+
const [episodeId] = useState14(() => crypto.randomUUID());
|
|
1571
1880
|
const formId = useId3();
|
|
1572
1881
|
return /* @__PURE__ */ jsx4(
|
|
1573
1882
|
Dialog,
|
|
@@ -1640,11 +1949,11 @@ function ProductionData({
|
|
|
1640
1949
|
},
|
|
1641
1950
|
[viewSnapshots, productionKey, onProductionRead]
|
|
1642
1951
|
);
|
|
1643
|
-
const [request, setRequest] =
|
|
1644
|
-
const [changed, setChanged] =
|
|
1645
|
-
const [busy, setBusy] =
|
|
1646
|
-
const [failure, setFailure] =
|
|
1647
|
-
const [creatingEpisode, setCreatingEpisode] =
|
|
1952
|
+
const [request, setRequest] = useState15(0);
|
|
1953
|
+
const [changed, setChanged] = useState15();
|
|
1954
|
+
const [busy, setBusy] = useState15(false);
|
|
1955
|
+
const [failure, setFailure] = useState15("");
|
|
1956
|
+
const [creatingEpisode, setCreatingEpisode] = useState15(false);
|
|
1648
1957
|
const writing = useRef9(false);
|
|
1649
1958
|
const read = useCallback3(
|
|
1650
1959
|
() => client.invoke({ instanceId, operationId: "production.get" }, {}).then(saveSnapshot),
|
|
@@ -1823,20 +2132,65 @@ function ProductionData({
|
|
|
1823
2132
|
|
|
1824
2133
|
// packages/short-drama-compare/src/compare-view.tsx
|
|
1825
2134
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1826
|
-
import { createElement } from "react";
|
|
2135
|
+
import { createElement as createElement2 } from "react";
|
|
2136
|
+
var savedSlots = z5.record(
|
|
2137
|
+
z5.string(),
|
|
2138
|
+
z5.array(
|
|
2139
|
+
z5.string().nullable().transform((slot) => slot ?? void 0)
|
|
2140
|
+
).max(4)
|
|
2141
|
+
);
|
|
2142
|
+
var sessionSchema = z5.object({
|
|
2143
|
+
slots: savedSlots,
|
|
2144
|
+
scene: z5.object({ episodeId: z5.string(), shotId: z5.string() }).optional()
|
|
2145
|
+
});
|
|
1827
2146
|
function CompareView(props) {
|
|
1828
|
-
const
|
|
2147
|
+
const storageKey = JSON.stringify([
|
|
2148
|
+
"short-drama.compare",
|
|
2149
|
+
props.client.project.id,
|
|
2150
|
+
props.instanceId ?? "production"
|
|
2151
|
+
]);
|
|
2152
|
+
return /* @__PURE__ */ jsx6(ProjectComparison, { ...props, storageKey }, storageKey);
|
|
2153
|
+
}
|
|
2154
|
+
function ProjectComparison({ storageKey, ...props }) {
|
|
2155
|
+
const [session, setSession] = useState16(() => {
|
|
2156
|
+
try {
|
|
2157
|
+
return sessionSchema.parse(JSON.parse(sessionStorage.getItem(storageKey) ?? "null"));
|
|
2158
|
+
} catch {
|
|
2159
|
+
return { slots: {} };
|
|
2160
|
+
}
|
|
2161
|
+
});
|
|
2162
|
+
const { episodeId, shotId } = props.route;
|
|
2163
|
+
useEffect10(() => {
|
|
2164
|
+
if (episodeId && shotId)
|
|
2165
|
+
setSession(
|
|
2166
|
+
(prior) => prior.scene?.episodeId === episodeId && prior.scene.shotId === shotId ? prior : { ...prior, scene: { episodeId, shotId } }
|
|
2167
|
+
);
|
|
2168
|
+
}, [episodeId, shotId]);
|
|
2169
|
+
useEffect10(() => {
|
|
2170
|
+
try {
|
|
2171
|
+
sessionStorage.setItem(storageKey, JSON.stringify(session));
|
|
2172
|
+
} catch {
|
|
2173
|
+
}
|
|
2174
|
+
}, [storageKey, session]);
|
|
2175
|
+
const restoreScene = !shotId && (!episodeId || episodeId === session.scene?.episodeId);
|
|
2176
|
+
const route = restoreScene ? { ...props.route, ...session.scene } : props.route;
|
|
2177
|
+
const slots = { ...session.slots, ...props.compareChoices?.slots };
|
|
2178
|
+
function update(key, choices) {
|
|
2179
|
+
setSession((prior) => ({ ...prior, slots: { ...prior.slots, [key]: choices } }));
|
|
2180
|
+
props.compareChoices?.update(key, choices);
|
|
2181
|
+
}
|
|
1829
2182
|
return /* @__PURE__ */ jsx6(
|
|
1830
2183
|
ProductionData,
|
|
1831
2184
|
{
|
|
1832
2185
|
...props,
|
|
1833
|
-
|
|
2186
|
+
route,
|
|
2187
|
+
render: (view) => /* @__PURE__ */ createElement2(
|
|
1834
2188
|
Compare,
|
|
1835
2189
|
{
|
|
1836
2190
|
...view,
|
|
1837
2191
|
key: view.episode?.id,
|
|
1838
|
-
candidateChoices:
|
|
1839
|
-
onCandidateChoices:
|
|
2192
|
+
candidateChoices: slots,
|
|
2193
|
+
onCandidateChoices: update
|
|
1840
2194
|
}
|
|
1841
2195
|
)
|
|
1842
2196
|
}
|
|
@@ -1845,7 +2199,7 @@ function CompareView(props) {
|
|
|
1845
2199
|
|
|
1846
2200
|
// packages/short-drama-compare/src/client.tsx
|
|
1847
2201
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1848
|
-
var Config =
|
|
2202
|
+
var Config = z6.object({ instanceId: z6.string().min(1).default("production") }).strict();
|
|
1849
2203
|
var dependencies = (config) => [config.instanceId];
|
|
1850
2204
|
function activate(client) {
|
|
1851
2205
|
client.registerUI({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vivix-labs/short-drama-compare",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -18,5 +18,8 @@
|
|
|
18
18
|
"vivix-studio": ">=2.2.0",
|
|
19
19
|
"react": "^19.0.0",
|
|
20
20
|
"react-dom": "^19.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@vivix-labs/project-studio": "workspace:*"
|
|
21
24
|
}
|
|
22
25
|
}
|