@vivix-labs/dashboard-projects 1.0.0-beta.6 → 1.0.0-beta.9

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.
@@ -83,8 +83,8 @@
83
83
  place-items: center;
84
84
  overflow: hidden;
85
85
  border-radius: 8px;
86
- background: var(--vx-surface-input);
87
- color: var(--vx-text-placeholder);
86
+ background: var(--vx-cover-background);
87
+ color: var(--vx-text-on-content-secondary);
88
88
  }
89
89
  .studio-home-cover img,
90
90
  .studio-home-cover video {
@@ -94,12 +94,10 @@
94
94
  height: 100%;
95
95
  object-fit: contain;
96
96
  }
97
- .studio-home-cover:has(img, video):not([data-cover-state=loading]) {
98
- background: #151515;
99
- }
100
97
  .studio-home-create .studio-home-cover {
101
98
  border: 1px dashed var(--vx-border-secondary);
102
99
  background: var(--vx-surface-input);
100
+ color: var(--vx-text-primary);
103
101
  }
104
102
  .studio-home-create .studio-home-cover > span {
105
103
  display: grid;
@@ -109,10 +107,6 @@
109
107
  border-radius: 4px;
110
108
  background: var(--vx-background-dialog);
111
109
  }
112
- .studio-home-view-all.vx-button {
113
- background: transparent;
114
- color: var(--vx-state-success);
115
- }
116
110
  @media (max-width: 660px) {
117
111
  .studio-home-panel {
118
112
  --home-panel-inset: 12px;
@@ -1,6 +1,164 @@
1
1
  // packages/dashboard-projects/src/client.tsx
2
2
  import * as React2 from "react";
3
+ import { z as z3 } from "vivix-studio/sdk/shared";
4
+
5
+ // packages/project-studio/dist/shared.js
6
+ import { z as z2, defineOperation } from "vivix-studio/sdk/shared";
3
7
  import { z } from "vivix-studio/sdk/shared";
8
+ var fixedRef = z.object({ storeId: z.uuid(), objectId: z.uuid(), versionId: z.uuid() }).strict();
9
+ var copy = z.string().max(8e3).default("");
10
+ var clipScript = z.object({
11
+ title: z.string().trim().min(1).max(200),
12
+ visual: copy,
13
+ voiceover: copy,
14
+ onScreenText: copy,
15
+ cta: copy,
16
+ plannedDurationMs: z.number().int().positive().nullable().default(null)
17
+ }).strict();
18
+ var adBrief = z.object({
19
+ product: copy,
20
+ category: copy,
21
+ audience: copy,
22
+ sellingPoints: copy,
23
+ channel: copy,
24
+ aspectRatio: z.string().max(40).nullable().default(null),
25
+ targetDurationMs: z.number().int().positive().nullable().default(null),
26
+ body: copy,
27
+ productRefs: z.array(fixedRef).max(100).default([]),
28
+ modelRefs: z.array(fixedRef).max(100).default([])
29
+ }).strict();
30
+ var adFilm = z.object({
31
+ title: z.string().trim().min(1).max(150),
32
+ source: fixedRef,
33
+ width: z.number().int().positive().max(8192),
34
+ height: z.number().int().positive().max(8192),
35
+ aspectRatio: z.string().regex(/^\d+:\d+$/)
36
+ }).strict();
37
+ var adStoryboard = z.object({
38
+ brief: adBrief,
39
+ films: z.array(adFilm).max(100).optional(),
40
+ clips: z.array(
41
+ z.object({
42
+ assetId: z.uuid(),
43
+ filmId: z.uuid().optional(),
44
+ script: clipScript,
45
+ edits: z.array(z.object({ sourceVersionId: z.uuid(), editRef: fixedRef }).strict()).max(200)
46
+ }).strict()
47
+ ).max(200)
48
+ }).strict().superRefine((value, context) => {
49
+ if (new Set(value.clips.map((c) => c.assetId)).size !== value.clips.length)
50
+ context.addIssue({ code: "custom", message: "A clip can appear only once in a storyboard." });
51
+ for (const clip of value.clips)
52
+ if (new Set(clip.edits.map((e) => e.sourceVersionId)).size !== clip.edits.length)
53
+ context.addIssue({
54
+ code: "custom",
55
+ message: "Each candidate has one current edit binding."
56
+ });
57
+ });
58
+ var projectType = z2.enum(["short-drama", "product-ad", "other"]);
59
+ var studioConfig = z2.object({
60
+ role: z2.enum(["project", "coordinator"]).default("project"),
61
+ projectType: projectType.optional(),
62
+ dataInstance: z2.string().min(1).default("user:data"),
63
+ apiInstance: z2.string().min(1).default("api"),
64
+ libraryInstance: z2.string().min(1).nullable().default(null),
65
+ coordinatorInstance: z2.string().min(1).optional()
66
+ }).strict();
67
+ var versionRef = z2.object({ storeId: z2.uuid(), objectId: z2.uuid(), versionId: z2.uuid() }).strict();
68
+ var tags = z2.array(z2.string().trim().min(1).max(64)).max(50).transform((x) => [...new Set(x)]).default([]);
69
+ var kind = z2.enum(["text", "image", "video", "audio", "file"]);
70
+ var projectData = z2.object({
71
+ name: z2.string().trim().min(1).max(120),
72
+ description: z2.string().max(4e3).default(""),
73
+ status: z2.enum(["draft", "active", "archived"]).default("draft"),
74
+ aspectRatio: z2.string().nullable().default(null),
75
+ projectType: projectType.optional(),
76
+ coverRef: versionRef.nullable().default(null),
77
+ briefRef: z2.object({ storeId: z2.uuid(), objectId: z2.uuid() }).strict().nullable().default(null),
78
+ tags
79
+ }).strict();
80
+ var assetData = z2.object({
81
+ projectId: z2.uuid(),
82
+ name: z2.string().trim().min(1).max(200),
83
+ kind,
84
+ purpose: z2.enum(["reference", "script", "shot", "music", "voice", "subtitle", "final", "other"]).default("other"),
85
+ origin: z2.enum(["upload", "library", "generated", "authored"]),
86
+ orderKey: z2.number().int().nullable().default(null),
87
+ tags,
88
+ lifecycle: z2.enum(["draft", "ready", "archived"]).default("draft"),
89
+ sourceRef: versionRef.nullable().default(null),
90
+ adoptedVersionId: z2.uuid().nullable().default(null)
91
+ }).strict();
92
+ var anchor = z2.discriminatedUnion("kind", [
93
+ z2.object({ kind: z2.literal("whole") }).strict(),
94
+ z2.object({
95
+ kind: z2.literal("timeRange"),
96
+ startMs: z2.number().int().nonnegative(),
97
+ endMs: z2.number().int().nonnegative()
98
+ }).strict()
99
+ ]);
100
+ var generationInput = z2.object({
101
+ targetAssetId: z2.uuid().optional(),
102
+ taskName: z2.string().trim().min(1).max(200).optional(),
103
+ context: z2.record(z2.string().min(1).max(64), z2.string().min(1).max(200)).optional(),
104
+ expectedRevision: z2.number().int().positive().optional(),
105
+ newAsset: z2.object({
106
+ name: z2.string().trim().min(1).max(200),
107
+ kind: z2.enum(["image", "video", "audio"])
108
+ }).strict().optional(),
109
+ modelId: z2.string().min(1),
110
+ capabilityId: z2.string().min(1),
111
+ prompt: z2.string().max(32e3),
112
+ parameters: z2.record(z2.string(), z2.unknown()).default({}),
113
+ outputCount: z2.number().int().min(1).max(100).default(1),
114
+ inputs: z2.array(
115
+ z2.object({
116
+ ref: versionRef,
117
+ role: z2.string().min(1),
118
+ order: z2.number().int().nonnegative(),
119
+ weight: z2.number().finite().nullable().default(null)
120
+ }).strict()
121
+ ).max(100).default([]),
122
+ baseVersionId: z2.uuid().optional(),
123
+ changeRequest: z2.string().trim().min(1).max(4e3).optional(),
124
+ preserveRequest: z2.string().max(4e3).default(""),
125
+ anchor: anchor.default({ kind: "whole" }),
126
+ retryOfTaskId: z2.uuid().optional(),
127
+ acknowledgeUnknown: z2.boolean().optional()
128
+ }).strict();
129
+ var projectSettingsInput = z2.object({
130
+ projectId: z2.uuid(),
131
+ expectedRevision: z2.number().int().positive(),
132
+ changes: projectData.pick({ name: true, description: true, tags: true, aspectRatio: true, coverRef: true }).extend({
133
+ description: projectData.shape.description.unwrap(),
134
+ tags: projectData.shape.tags.unwrap(),
135
+ aspectRatio: projectData.shape.aspectRatio.unwrap(),
136
+ coverRef: projectData.shape.coverRef.unwrap()
137
+ }).partial().strict()
138
+ }).strict();
139
+ var generationSubmitOperation = defineOperation({
140
+ id: "generation.submit",
141
+ title: "Generate",
142
+ description: "Submit one media generation without approval, retaining its paid request identity.",
143
+ input: generationInput,
144
+ output: z2.any(),
145
+ effects: ["write", "paid"],
146
+ confirm: "none"
147
+ });
148
+ var favoriteData = z2.object({ ref: versionRef }).strict();
149
+ var sqlScalar = z2.union([z2.string(), z2.number().finite(), z2.null()]);
150
+ var globalQueryInput = z2.object({
151
+ sql: z2.string().trim().min(1),
152
+ params: z2.union([z2.array(sqlScalar), z2.record(z2.string(), sqlScalar)]).optional(),
153
+ timeoutMs: z2.number().int().positive().optional(),
154
+ maxRows: z2.number().int().positive().optional(),
155
+ limit: z2.number().int().min(1).max(200).optional(),
156
+ offset: z2.number().int().nonnegative().optional(),
157
+ source: z2.enum(["projects", "assets", "tasks"]),
158
+ excludeProjectIds: z2.array(z2.uuid()).optional(),
159
+ catalog: z2.array(z2.object({ id: z2.string().min(1), name: z2.string(), available: z2.boolean() }).strict()).optional()
160
+ }).strict();
161
+ var projectListSql = "SELECT rowId, projectId, name, available, createdAt, coverRef FROM studio_projects ORDER BY createdAt DESC, rowId ASC";
4
162
 
5
163
  // packages/ui-system/dist/button.js
6
164
  import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
@@ -74,6 +232,8 @@ var iconGeometry = {
74
232
  slot: 18
75
233
  },
76
234
  "select-items": { width: 13.8681, height: 13.8667, slot: 16 },
235
+ trim: { width: 14.85, height: 14.85, slot: 16 },
236
+ crop: { width: 16.25, height: 16.25, slot: 16 },
77
237
  filter: { width: 13.2, height: 13.2, slot: 16 },
78
238
  select: {
79
239
  width: 14.6298,
@@ -218,6 +378,8 @@ var buttonVariants = {
218
378
  "text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
219
379
  "text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
220
380
  "text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
381
+ "text-plain-sm": { size: 32, appearance: "plain", shape: "text" },
382
+ "text-link-sm": { size: 32, appearance: "link", shape: "text" },
221
383
  "text-outline-sm": { size: 32, appearance: "outline", shape: "text" },
222
384
  "text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
223
385
  // The medium recipes are shared by all dialog footer actions.
@@ -266,14 +428,14 @@ import { useState } from "react";
266
428
  function CoverPreview(props) {
267
429
  return _jsx3(Preview, { ...props }, JSON.stringify([props.kind, props.src]));
268
430
  }
269
- function Preview({ className, ref, kind = "image", src, pending, iconSize = 20, children }) {
431
+ function Preview({ className, ref, kind: kind2 = "image", src, pending, iconSize = 20, children }) {
270
432
  const [mediaState, setMediaState] = useState("loading");
271
- const media = src && (kind === "image" || kind === "video");
433
+ const media = src && (kind2 === "image" || kind2 === "video");
272
434
  const state = pending ? "loading" : media ? mediaState : children ? "ready" : "empty";
273
- const iconKind = kind === "video" || kind === "audio" ? kind : kind === "text" ? "script" : "image";
435
+ const iconKind = kind2 === "video" || kind2 === "audio" ? kind2 : kind2 === "text" ? "script" : "image";
274
436
  const ready = () => setMediaState("ready");
275
437
  const failed = () => setMediaState("empty");
276
- return _jsx3("span", { ref, className: `vx-cover-preview ${className}`, "data-cover-state": state, "aria-hidden": "true", children: state === "empty" ? _jsx3(Icon, { name: `placeholder-${iconKind}`, size: iconSize }) : !pending && media ? kind === "video" ? _jsx3("video", { src, muted: true, playsInline: true, preload: "auto", onLoadedData: ready, onError: failed }) : _jsx3("img", { src, alt: "", loading: "lazy", onLoad: ready, onError: failed }) : state === "ready" ? children : null });
438
+ return _jsx3("span", { ref, className: `vx-cover-preview ${className}`, "data-cover-state": state, "aria-hidden": "true", children: state === "empty" ? _jsx3(Icon, { name: `placeholder-${iconKind}`, size: iconSize }) : !pending && media ? kind2 === "video" ? _jsx3("video", { src, muted: true, playsInline: true, preload: "auto", onLoadedData: ready, onError: failed }) : _jsx3("img", { src, alt: "", loading: "lazy", onLoad: ready, onError: failed }) : state === "ready" ? children : null });
277
439
  }
278
440
 
279
441
  // packages/ui-system/dist/segmented-control.js
@@ -296,8 +458,8 @@ import { useId as useId2, useLayoutEffect, useRef, useState as useState2 } from
296
458
  import { createPortal } from "react-dom";
297
459
 
298
460
  // packages/ui-system/dist/dialog-surface.js
299
- function createDialogSurface(anchor) {
300
- const source = anchor.ownerDocument;
461
+ function createDialogSurface(anchor2) {
462
+ const source = anchor2.ownerDocument;
301
463
  let target;
302
464
  try {
303
465
  target = source.defaultView?.top?.document ?? source;
@@ -315,19 +477,19 @@ function createDialogSurface(anchor) {
315
477
  clone.setAttribute("href", original.href);
316
478
  shadow.append(clone);
317
479
  }
318
- const theme = anchor.closest("[data-vx-theme]");
480
+ const theme = anchor2.closest("[data-vx-theme]");
319
481
  const root = target.createElement("div");
320
482
  root.dataset.vxTheme = theme?.dataset.vxTheme ?? "light";
321
483
  root.className = theme?.className ?? "";
322
484
  root.style.display = "contents";
323
- const style = source.defaultView.getComputedStyle(anchor);
485
+ const style = source.defaultView.getComputedStyle(anchor2);
324
486
  for (const name of style)
325
487
  if (name.startsWith("--"))
326
488
  root.style.setProperty(name, style.getPropertyValue(name));
327
489
  shadow.append(root);
328
490
  let container = root;
329
491
  const ancestors = [];
330
- for (let parent = anchor.parentElement; parent && parent !== theme; parent = parent.parentElement)
492
+ for (let parent = anchor2.parentElement; parent && parent !== theme; parent = parent.parentElement)
331
493
  ancestors.unshift(parent);
332
494
  for (const original of ancestors) {
333
495
  const wrapper = target.createElement("div");
@@ -344,16 +506,16 @@ function createDialogSurface(anchor) {
344
506
  }
345
507
 
346
508
  // packages/ui-system/dist/dialog.js
347
- function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default" }) {
509
+ function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default", focusTitleOnOpen = variant === "welcome" }) {
348
510
  const ref = useRef(null);
349
- const anchor = useRef(null);
511
+ const anchor2 = useRef(null);
350
512
  const [surface, setSurface] = useState2();
351
513
  const heading = useId2();
352
514
  useLayoutEffect(() => {
353
- if (!open || !anchor.current)
515
+ if (!open || !anchor2.current)
354
516
  return;
355
- const mounted = createDialogSurface(anchor.current);
356
- const active = anchor.current.getRootNode().activeElement;
517
+ const mounted = createDialogSurface(anchor2.current);
518
+ const active = anchor2.current.getRootNode().activeElement;
357
519
  setSurface(mounted?.root ?? null);
358
520
  return () => {
359
521
  mounted?.dispose();
@@ -374,6 +536,8 @@ function Dialog({ title, open, onOpenChange, children, actions, className, varia
374
536
  dialog2.close();
375
537
  };
376
538
  }, [open, surface]);
539
+ const welcome = variant === "welcome";
540
+ const closeButton = _jsx6(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) });
377
541
  const dialog = _jsxs4("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, "aria-labelledby": heading, onCancel: (event) => {
378
542
  event.preventDefault();
379
543
  event.stopPropagation();
@@ -381,8 +545,8 @@ function Dialog({ title, open, onOpenChange, children, actions, className, varia
381
545
  }, onClose: (event) => {
382
546
  if (open && event.currentTarget.isConnected && !event.currentTarget.open)
383
547
  onOpenChange(false);
384
- }, children: [_jsxs4("header", { children: [_jsx6("h2", { id: heading, children: title }), _jsx6(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) })] }), _jsx6("div", { className: "vx-dialog-body", children }), actions && _jsx6("footer", { children: actions })] });
385
- return _jsxs4(_Fragment, { children: [_jsx6("span", { ref: anchor, hidden: true }), open && (surface ? createPortal(dialog, surface) : dialog)] });
548
+ }, children: [_jsxs4("header", { children: [_jsx6("h2", { id: heading, tabIndex: focusTitleOnOpen ? -1 : void 0, autoFocus: focusTitleOnOpen, children: title }), !welcome && closeButton] }), _jsx6("div", { className: "vx-dialog-body", children }), (actions || welcome) && _jsxs4("footer", { children: [actions, welcome && closeButton] })] });
549
+ return _jsxs4(_Fragment, { children: [_jsx6("span", { ref: anchor2, hidden: true }), open && (surface ? createPortal(dialog, surface) : dialog)] });
386
550
  }
387
551
 
388
552
  // packages/dashboard-projects/src/create-project-dialog.tsx
@@ -526,9 +690,8 @@ function NewProjectDialog({
526
690
 
527
691
  // packages/dashboard-projects/src/client.tsx
528
692
  import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
529
- var Config = z.object({ studioInstance: z.string().min(1).nullable().default(null) });
693
+ var Config = z3.object({ studioInstance: z3.string().min(1).nullable().default(null) });
530
694
  var dependencies = (config) => config.studioInstance ? [config.studioInstance] : [];
531
- var projectsSql = "SELECT * FROM studio_projects ORDER BY createdAt DESC, rowId ASC";
532
695
  function decodeRef(value) {
533
696
  let item = value;
534
697
  if (typeof item === "string") {
@@ -548,21 +711,30 @@ function decodeRef(value) {
548
711
  versionId: ref.versionId
549
712
  } : null;
550
713
  }
714
+ var projectPreviews = /* @__PURE__ */ new WeakMap();
551
715
  function ProjectCover({
552
716
  client,
553
717
  row,
554
718
  pending
555
719
  }) {
556
- const coverRef = row?.available ? row.previewRef ?? row.coverRef : void 0;
720
+ const ref = decodeRef(row?.available ? row.previewRef ?? row.coverRef : void 0);
557
721
  const instanceId = client.config.studioInstance;
722
+ const key = ref && JSON.stringify([instanceId, ref.storeId, ref.objectId, ref.versionId]);
723
+ const cached = key ? projectPreviews.get(client)?.get(key) : void 0;
558
724
  const [resolved, setResolved] = React2.useState();
559
725
  React2.useEffect(() => {
560
- const ref = decodeRef(coverRef);
561
- if (!ref || !instanceId) return;
726
+ if (!ref || !instanceId || !key || cached) return;
562
727
  let active = true;
563
728
  void client.invoke({ instanceId, operationId: "global.asset" }, { ref }).then(
564
729
  ({ item }) => {
565
- if (active) setResolved(item);
730
+ if (!active) return;
731
+ if (item.previewUrl) {
732
+ const previews = projectPreviews.get(client) ?? /* @__PURE__ */ new Map();
733
+ previews.set(key, item);
734
+ if (previews.size > 64) previews.delete(previews.keys().next().value);
735
+ projectPreviews.set(client, previews);
736
+ }
737
+ setResolved(item);
566
738
  },
567
739
  () => {
568
740
  if (active) setResolved(null);
@@ -571,15 +743,16 @@ function ProjectCover({
571
743
  return () => {
572
744
  active = false;
573
745
  };
574
- }, [client, coverRef, instanceId]);
575
- const src = resolved?.previewUrl ?? row?.previewUrl;
746
+ }, [client, instanceId, key, cached]);
747
+ const preview = cached ?? resolved;
748
+ const src = preview?.previewUrl ?? row?.previewUrl;
576
749
  return /* @__PURE__ */ jsx2(
577
750
  CoverPreview,
578
751
  {
579
752
  className: "studio-home-cover",
580
753
  src: typeof src === "string" ? src : void 0,
581
- kind: String(resolved?.kind ?? row?.previewKind ?? "image"),
582
- pending: pending || Boolean(instanceId && decodeRef(coverRef) && resolved === void 0)
754
+ kind: String(preview?.kind ?? row?.previewKind ?? "image"),
755
+ pending: pending || Boolean(instanceId && ref && preview === void 0)
583
756
  }
584
757
  );
585
758
  }
@@ -605,7 +778,7 @@ function ProjectsCard({
605
778
  { instanceId: client.config.studioInstance, operationId: "global.query" },
606
779
  {
607
780
  source: "projects",
608
- sql: projectsSql,
781
+ sql: projectListSql,
609
782
  params: [],
610
783
  catalog: JSON.parse(catalogKey),
611
784
  ...hiddenKey !== "[]" && { excludeProjectIds: JSON.parse(hiddenKey) },
@@ -630,7 +803,7 @@ function ProjectsCard({
630
803
  active = false;
631
804
  };
632
805
  }, [client, ready, catalogKey, hiddenKey]);
633
- const current = catalogKey === result?.catalogKey ? result : void 0;
806
+ const current = resultKey === result?.catalogKey ? result : void 0;
634
807
  const pending = Boolean(client.config.studioInstance) && (!ready || !current);
635
808
  const list = current?.rows ?? [];
636
809
  const entries = (list.length ? list.map((row) => projects.find(({ id }) => id === row.projectId)).filter((entry) => !!entry) : projects.slice(0, 5)).map((project) => {
@@ -650,10 +823,9 @@ function ProjectsCard({
650
823
  /* @__PURE__ */ jsx2(
651
824
  Button,
652
825
  {
653
- label: "View all",
826
+ label: ready ? `View all ${projects.length}` : "View all",
654
827
  "aria-label": "View all project list",
655
- className: "studio-home-view-all",
656
- variant: "text-tonal-sm",
828
+ variant: "text-link-sm",
657
829
  onClick: openProjects
658
830
  }
659
831
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivix-labs/dashboard-projects",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.9",
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
  }