@vivix-labs/short-drama-compare 1.0.0-beta.2 → 1.0.0-beta.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.
@@ -745,6 +745,41 @@
745
745
  .drama-compare-metadata dd {
746
746
  margin-bottom: 8px;
747
747
  }
748
+ .drama-compare-version {
749
+ display: flex;
750
+ align-items: center;
751
+ gap: var(--vx-space-8);
752
+ padding: 0 var(--vx-space-8) var(--vx-space-8);
753
+ color: var(--vx-text-secondary-readable);
754
+ font: var(--vx-typography-inter-14-medium);
755
+ }
756
+ .drama-compare-version select {
757
+ max-width: 100%;
758
+ min-width: 0;
759
+ padding: var(--vx-space-4) var(--vx-space-8);
760
+ }
761
+ .drama-compare-whole .drama-player {
762
+ gap: 0;
763
+ }
764
+ .drama-compare-whole .drama-player-stage {
765
+ border-end-start-radius: 0;
766
+ border-end-end-radius: 0;
767
+ }
768
+ @media (min-width: 1040px) {
769
+ .drama-compare-whole .drama-player-stage {
770
+ min-block-size: clamp(320px, calc(100dvh - 424px), 520px);
771
+ }
772
+ }
773
+ .drama-compare-whole .drama-player > .vx-playback-controls {
774
+ border-start-start-radius: 0;
775
+ border-start-end-radius: 0;
776
+ background: var(--vx-black-black);
777
+ color: var(--vx-text-on-content-primary);
778
+ --vx-button-foreground: var(--vx-text-on-content-primary);
779
+ }
780
+ .drama-compare-whole .drama-player-viewport + .vx-playback-controls {
781
+ margin-block-end: var(--vx-space-8);
782
+ }
748
783
  .drama-compare-scenes .drama-player {
749
784
  margin: 0;
750
785
  grid-template-rows: 1fr;
@@ -5,7 +5,7 @@ import { z } from "vivix-studio/sdk/shared";
5
5
  import { useState as useState12 } from "react";
6
6
 
7
7
  // packages/short-drama-compare/src/compare.tsx
8
- import { useCallback, useMemo as useMemo2, useState as useState9 } from "react";
8
+ import { useCallback, useMemo as useMemo2, useRef as useRef9, useState as useState9 } from "react";
9
9
 
10
10
  // packages/ui-system/dist/button.js
11
11
  import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
@@ -992,8 +992,11 @@ function Compare(props) {
992
992
  const [leftCutId, setLeftCutId] = useState9(episode.cuts[0]?.id);
993
993
  const [rightCutId, setRightCutId] = useState9(episode.cuts[1]?.id);
994
994
  const shot = episode.shots.find((shot2) => shot2.id === shotId) ?? episode.shots[0];
995
- const left = episode.cuts.find((cut) => cut.id === leftCutId);
996
- const right = episode.cuts.find((cut) => cut.id === rightCutId);
995
+ const focusVersion = useRef9(void 0);
996
+ const cuts = [
997
+ { side: "A", id: leftCutId, other: rightCutId, set: setLeftCutId },
998
+ { side: "B", id: rightCutId, other: leftCutId, set: setRightCutId }
999
+ ];
997
1000
  return /* @__PURE__ */ jsxs3("section", { "aria-label": "Version comparison", children: [
998
1001
  /* @__PURE__ */ jsxs3("header", { className: "drama-compare-bar", children: [
999
1002
  /* @__PURE__ */ jsxs3("h2", { children: [
@@ -1057,54 +1060,55 @@ function Compare(props) {
1057
1060
  onClick: () => props.navigate({ view: "episode", episodeId: episode.id })
1058
1061
  }
1059
1062
  )
1060
- ] }) : /* @__PURE__ */ jsxs3("div", { className: "drama-compare", children: [
1061
- /* @__PURE__ */ jsxs3("section", { "aria-label": "Episode A", children: [
1062
- /* @__PURE__ */ jsxs3("label", { children: [
1063
- "A",
1064
- /* @__PURE__ */ jsx3(
1065
- "select",
1066
- {
1067
- value: leftCutId,
1068
- onChange: (event) => setLeftCutId(event.currentTarget.value),
1069
- children: episode.cuts.map((cut) => /* @__PURE__ */ jsx3("option", { value: cut.id, disabled: cut.id === rightCutId, children: cut.title }, cut.id))
1070
- }
1071
- )
1072
- ] }),
1073
- left && /* @__PURE__ */ jsx3(
1074
- ResolvedPlayer,
1075
- {
1076
- ...props,
1077
- label: left.title,
1078
- shots: left.shots,
1079
- captureId: "episode-a"
1080
- },
1081
- left.id
1082
- )
1083
- ] }),
1084
- /* @__PURE__ */ jsxs3("section", { "aria-label": "Episode B", children: [
1085
- /* @__PURE__ */ jsxs3("label", { children: [
1086
- "B",
1087
- /* @__PURE__ */ jsx3(
1088
- "select",
1089
- {
1090
- value: rightCutId,
1091
- onChange: (event) => setRightCutId(event.currentTarget.value),
1092
- children: episode.cuts.map((cut) => /* @__PURE__ */ jsx3("option", { value: cut.id, disabled: cut.id === leftCutId, children: cut.title }, cut.id))
1093
- }
1094
- )
1095
- ] }),
1096
- right && /* @__PURE__ */ jsx3(
1097
- ResolvedPlayer,
1098
- {
1099
- ...props,
1100
- label: right.title,
1101
- shots: right.shots,
1102
- captureId: "episode-b"
1103
- },
1104
- right.id
1105
- )
1106
- ] })
1107
- ] }))
1063
+ ] }) : /* @__PURE__ */ jsx3("div", { className: "drama-compare drama-compare-whole", children: cuts.map(({ side, id, other, set }, index) => {
1064
+ const requested = episode.cuts.find((cut2) => cut2.id === id);
1065
+ const cut = requested ?? episode.cuts[index];
1066
+ const otherId = episode.cuts.find((entry) => entry.id === other)?.id ?? episode.cuts[1 - index]?.id;
1067
+ return /* @__PURE__ */ jsx3("section", { "aria-label": `Episode ${side}`, children: /* @__PURE__ */ jsx3(
1068
+ ResolvedPlayer,
1069
+ {
1070
+ ...props,
1071
+ label: cut.title,
1072
+ shots: cut.shots,
1073
+ captureId: `episode-${side.toLowerCase()}`,
1074
+ renderFilmstrip: (panel) => /* @__PURE__ */ jsxs3(Fragment2, { children: [
1075
+ /* @__PURE__ */ jsxs3("label", { className: "drama-compare-version", children: [
1076
+ /* @__PURE__ */ jsxs3("span", { children: [
1077
+ "Version ",
1078
+ side
1079
+ ] }),
1080
+ /* @__PURE__ */ jsx3(
1081
+ "select",
1082
+ {
1083
+ ref: (node) => {
1084
+ if (node && focusVersion.current === side) {
1085
+ focusVersion.current = void 0;
1086
+ node.focus({ preventScroll: true });
1087
+ }
1088
+ },
1089
+ value: cut.id,
1090
+ onChange: (event) => {
1091
+ focusVersion.current = side;
1092
+ set(event.currentTarget.value);
1093
+ },
1094
+ children: episode.cuts.map((option) => /* @__PURE__ */ jsx3(
1095
+ "option",
1096
+ {
1097
+ value: option.id,
1098
+ disabled: option.id === otherId,
1099
+ children: option.title
1100
+ },
1101
+ option.id
1102
+ ))
1103
+ }
1104
+ )
1105
+ ] }),
1106
+ panel
1107
+ ] })
1108
+ },
1109
+ cut.id
1110
+ ) }, side);
1111
+ }) }))
1108
1112
  ] });
1109
1113
  }
1110
1114
  var compareSlots = ["A", "B", "C", "D"];
@@ -1295,7 +1299,10 @@ function ResolvedPlayer({
1295
1299
  [shots, assets]
1296
1300
  );
1297
1301
  const resolved = useRequest(read);
1298
- if (!resolved?.data) return /* @__PURE__ */ jsx3(LoadMessage, { error: resolved?.error });
1302
+ if (!resolved?.data) {
1303
+ const message = /* @__PURE__ */ jsx3(LoadMessage, { error: resolved?.error });
1304
+ return resolved?.error && renderFilmstrip ? renderFilmstrip(message) : message;
1305
+ }
1299
1306
  return /* @__PURE__ */ jsx3(
1300
1307
  SequencePlayer,
1301
1308
  {
@@ -1346,7 +1353,7 @@ async function resolvePreview(assets, ref) {
1346
1353
  }
1347
1354
 
1348
1355
  // packages/short-drama-compare/src/production-view.tsx
1349
- import { useCallback as useCallback2, useEffect as useEffect6, useRef as useRef9, useState as useState11 } from "react";
1356
+ import { useCallback as useCallback2, useEffect as useEffect6, useRef as useRef10, useState as useState11 } from "react";
1350
1357
 
1351
1358
  // packages/short-drama-compare/src/episode-create.tsx
1352
1359
  import { useId as useId5, useState as useState10 } from "react";
@@ -1427,7 +1434,7 @@ function ProductionData({
1427
1434
  const [busy, setBusy] = useState11(false);
1428
1435
  const [failure, setFailure] = useState11("");
1429
1436
  const [creatingEpisode, setCreatingEpisode] = useState11(false);
1430
- const writing = useRef9(false);
1437
+ const writing = useRef10(false);
1431
1438
  const read = useCallback2(
1432
1439
  () => client.invoke({ instanceId, operationId: "production.get" }, {}),
1433
1440
  [client, instanceId]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivix-labs/short-drama-compare",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -19,4 +19,4 @@
19
19
  "react": "^19.0.0",
20
20
  "react-dom": "^19.0.0"
21
21
  }
22
- }
22
+ }