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

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.
@@ -1,17 +1,215 @@
1
1
  // packages/dashboard-projects/src/client.tsx
2
- import "react";
3
-
4
- // packages/studio-workbench/src/dashboard-card.tsx
5
2
  import * as React2 from "react";
6
- import { z as z2 } from "vivix-studio/sdk/shared";
3
+ import { z } from "vivix-studio/sdk/shared";
7
4
 
8
5
  // packages/ui-system/dist/button.js
9
6
  import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
10
7
 
11
8
  // packages/ui-system/dist/icon.js
12
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
+ var iconGeometry = {
11
+ add: {
12
+ width: 16,
13
+ height: 16,
14
+ slot: 16
15
+ },
16
+ check: {
17
+ width: 12,
18
+ height: 12,
19
+ slot: 12
20
+ },
21
+ "check-on-content": {
22
+ width: 12,
23
+ height: 12,
24
+ slot: 12
25
+ },
26
+ "chevron-up": {
27
+ width: 12,
28
+ height: 12,
29
+ slot: 12
30
+ },
31
+ expand: {
32
+ width: 16,
33
+ height: 16,
34
+ slot: 16
35
+ },
36
+ "chevron-down": {
37
+ width: 12,
38
+ height: 12,
39
+ slot: 12
40
+ },
41
+ clear: {
42
+ width: 14.5332,
43
+ height: 14.5332,
44
+ slot: 16
45
+ },
46
+ grid: {
47
+ width: 13.2039,
48
+ height: 13.2,
49
+ slot: 16
50
+ },
51
+ list: {
52
+ width: 13.3372,
53
+ height: 12.0039,
54
+ slot: 16
55
+ },
56
+ search: {
57
+ width: 13.2,
58
+ height: 13.2,
59
+ slot: 16
60
+ },
61
+ calendar: {
62
+ width: 16,
63
+ height: 16,
64
+ slot: 16
65
+ },
66
+ import: {
67
+ width: 16,
68
+ height: 16,
69
+ slot: 16
70
+ },
71
+ magic: {
72
+ width: 14.0625,
73
+ height: 15.5625,
74
+ slot: 18
75
+ },
76
+ "select-items": { width: 13.8681, height: 13.8667, slot: 16 },
77
+ filter: { width: 13.2, height: 13.2, slot: 16 },
78
+ select: {
79
+ width: 14.6298,
80
+ height: 16.065,
81
+ slot: 18
82
+ },
83
+ area: {
84
+ width: 16.125,
85
+ height: 16.125,
86
+ slot: 18
87
+ },
88
+ draw: {
89
+ width: 16.125,
90
+ height: 16.125,
91
+ slot: 18
92
+ },
93
+ close: {
94
+ width: 18,
95
+ height: 18,
96
+ slot: 18
97
+ },
98
+ reset: {
99
+ width: 16.35,
100
+ height: 16.35,
101
+ slot: 18
102
+ },
103
+ more: {
104
+ width: 16,
105
+ height: 16,
106
+ slot: 16
107
+ },
108
+ play: {
109
+ width: 12.381,
110
+ height: 13.2143,
111
+ slot: 20
112
+ },
113
+ pause: {
114
+ width: 14.1905,
115
+ height: 14.1905,
116
+ slot: 20
117
+ },
118
+ mute: {
119
+ width: 17.5239,
120
+ height: 14.1922,
121
+ slot: 20
122
+ },
123
+ volume: {
124
+ width: 17.5239,
125
+ height: 14.1922,
126
+ slot: 20
127
+ },
128
+ fullscreen: {
129
+ width: 20,
130
+ height: 20,
131
+ slot: 20
132
+ },
133
+ "placeholder-image": {
134
+ width: 20,
135
+ height: 20,
136
+ slot: 20
137
+ },
138
+ "placeholder-video": {
139
+ width: 17.9199,
140
+ height: 16.2506,
141
+ slot: 20
142
+ },
143
+ "placeholder-audio": {
144
+ width: 17.5017,
145
+ height: 17.4992,
146
+ slot: 20
147
+ },
148
+ "placeholder-script": {
149
+ width: 17.0834,
150
+ height: 17.0837,
151
+ slot: 20
152
+ },
153
+ export: {
154
+ width: 11.8667,
155
+ height: 13.2,
156
+ slot: 16
157
+ },
158
+ favorite: { width: 11.8667, height: 14.5333, slot: 16 },
159
+ download: { width: 13.2001, height: 13.1997, slot: 16 },
160
+ delete: { width: 13.2, height: 14.533, slot: 16 },
161
+ edit: {
162
+ width: 10.8791,
163
+ height: 12.0459,
164
+ slot: 14
165
+ },
166
+ "play-cover": {
167
+ width: 12.9167,
168
+ height: 13.7501,
169
+ slot: 20
170
+ },
171
+ "playback-play": {
172
+ width: 13.29564,
173
+ height: 14.1905,
174
+ slot: 20
175
+ },
176
+ "playback-play-large": {
177
+ width: 15.95477,
178
+ height: 17.0286,
179
+ slot: 24
180
+ },
181
+ "pause-large": {
182
+ width: 17.0286,
183
+ height: 17.0286,
184
+ slot: 24
185
+ },
186
+ "volume-large": {
187
+ width: 21.02868,
188
+ height: 17.03064,
189
+ slot: 24
190
+ },
191
+ "mute-large": {
192
+ width: 21.0286,
193
+ height: 17.0307,
194
+ slot: 24
195
+ },
196
+ "fullscreen-large": {
197
+ width: 24,
198
+ height: 24,
199
+ slot: 24
200
+ }
201
+ };
13
202
  function Icon({ name, size }) {
14
- return _jsx("span", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, style: size === void 0 ? void 0 : { "--vx-icon-size": `${size}px` } });
203
+ const geometry = iconGeometry[name];
204
+ const style = {
205
+ ...geometry && {
206
+ "--vx-icon-native-size": `${geometry.slot}px`,
207
+ "--vx-icon-width": `${geometry.width / geometry.slot * 100}%`,
208
+ "--vx-icon-height": `${geometry.height / geometry.slot * 100}%`
209
+ },
210
+ ...size === void 0 ? {} : { "--vx-icon-size": `${size}px` }
211
+ };
212
+ return _jsx("span", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, style });
15
213
  }
16
214
 
17
215
  // packages/ui-system/dist/button-variants.js
@@ -20,6 +218,7 @@ var buttonVariants = {
20
218
  "text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
21
219
  "text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
22
220
  "text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
221
+ "text-outline-sm": { size: 32, appearance: "outline", shape: "text" },
23
222
  "text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
24
223
  // The medium recipes are shared by all dialog footer actions.
25
224
  "text-filled-md": { size: 40, appearance: "filled", shape: "text" },
@@ -54,409 +253,388 @@ function ButtonFrame({ label, variant, loading = false, width, children, disable
54
253
  const buttonStyle = "width" in spec ? { ...style, "--vx-button-width": `${spec.width}px` } : style;
55
254
  return _jsxs("button", { ...props, type, className: className ? `vx-button ${className}` : "vx-button", "data-variant": variant, "data-appearance": spec.appearance, "data-shape": spec.shape, "data-size": spec.size, "data-width": width, "data-state": loading ? "loading" : disabled ? "disabled" : "default", style: buttonStyle, disabled: disabled || loading, "aria-label": label, "aria-busy": loading || void 0, children: [_jsx2("span", { className: "vx-button-content", children }), loading && _jsx2("span", { className: "vx-button-loading", "aria-hidden": "true" })] });
56
255
  }
57
- function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, ...props }) {
58
- return _jsxs(ButtonFrame, { ...props, variant, children: [leadingIcon && _jsx2(Icon, { name: leadingIcon }), _jsx2("span", { className: "vx-button-label", children: props.label }), trailingIcon && _jsx2("span", { className: "vx-button-trailing", children: _jsx2(Icon, { name: trailingIcon }) })] });
256
+ function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, badge, ...props }) {
257
+ return _jsxs(ButtonFrame, { ...props, label: badge ? `${props.label} (${badge})` : props.label, variant, children: [leadingIcon && _jsx2(Icon, { name: leadingIcon }), _jsx2("span", { className: "vx-button-label", children: props.label }), badge !== void 0 && badge > 0 && _jsx2("span", { className: "vx-button-badge", children: badge }), trailingIcon && _jsx2("span", { className: "vx-button-trailing", children: _jsx2(Icon, { name: trailingIcon }) })] });
59
258
  }
60
259
  function IconButton({ icon, variant = "icon-ghost-sm", ...props }) {
61
260
  return _jsx2(ButtonFrame, { ...props, variant, children: _jsx2(Icon, { name: icon }) });
62
261
  }
63
262
 
263
+ // packages/ui-system/dist/cover-preview.js
264
+ import { jsx as _jsx3 } from "react/jsx-runtime";
265
+ import { useState } from "react";
266
+ function CoverPreview(props) {
267
+ return _jsx3(Preview, { ...props }, JSON.stringify([props.kind, props.src]));
268
+ }
269
+ function Preview({ className, ref, kind = "image", src, pending, iconSize = 20, children }) {
270
+ const [mediaState, setMediaState] = useState("loading");
271
+ const media = src && (kind === "image" || kind === "video");
272
+ const state = pending ? "loading" : media ? mediaState : children ? "ready" : "empty";
273
+ const iconKind = kind === "video" || kind === "audio" ? kind : kind === "text" ? "script" : "image";
274
+ const ready = () => setMediaState("ready");
275
+ 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 });
277
+ }
278
+
64
279
  // packages/ui-system/dist/segmented-control.js
65
- import { jsx as _jsx3, jsxs as _jsxs2 } from "react/jsx-runtime";
280
+ import { jsx as _jsx4, jsxs as _jsxs2 } from "react/jsx-runtime";
66
281
  import { useId } from "react";
67
282
  function SegmentedControl({ label, items, value, onValueChange, size = "medium", width = "fixed", iconOnly = false }) {
68
283
  const id = useId();
69
- return _jsx3("div", { role: "radiogroup", "aria-label": label, className: "vx-segment", "data-size": size, "data-width": width, "data-icon-only": iconOnly, children: items.map((item) => _jsxs2("label", { children: [_jsx3("input", { type: "radio", name: id, value: item.value, disabled: item.disabled, checked: item.value === value, "aria-label": item.label, onChange: () => onValueChange(item.value) }), _jsxs2("span", { className: "vx-segment-item", children: [item.icon && _jsx3(Icon, { name: item.icon }), (!iconOnly || !item.icon) && item.label] })] }, item.value)) });
284
+ return _jsx4("div", { role: "radiogroup", "aria-label": label, className: "vx-segment", "data-size": size, "data-width": width, "data-icon-only": iconOnly, children: items.map((item) => _jsxs2("label", { children: [_jsx4("input", { type: "radio", name: id, value: item.value, disabled: item.disabled, checked: item.value === value, "aria-label": item.label, onChange: () => onValueChange(item.value) }), _jsxs2("span", { className: "vx-segment-item", children: [item.icon && _jsx4(Icon, { name: item.icon }), (!iconOnly || !item.icon) && item.label] })] }, item.value)) });
70
285
  }
71
286
 
72
287
  // packages/ui-system/dist/input.js
73
- import { jsx as _jsx4, jsxs as _jsxs3 } from "react/jsx-runtime";
74
- function TextInput({ label, value, onValueChange, size = "medium", ...props }) {
75
- return _jsxs3("label", { className: "vx-field", "data-size": size, children: [_jsx4("span", { children: label }), _jsx4("input", { ...props, type: "text", value, onChange: (event) => onValueChange(event.currentTarget.value) })] });
288
+ import { jsx as _jsx5, jsxs as _jsxs3 } from "react/jsx-runtime";
289
+ function TextInput({ label, value, onValueChange, size = "medium", appearance = "default", ...props }) {
290
+ return _jsxs3("label", { className: "vx-field", "data-size": size, "data-appearance": appearance, children: [_jsx5("span", { children: label }), _jsx5("input", { ...props, type: "text", value, onChange: (event) => onValueChange(event.currentTarget.value) })] });
76
291
  }
77
292
 
78
293
  // packages/ui-system/dist/dialog.js
79
- import { jsx as _jsx5, jsxs as _jsxs4 } from "react/jsx-runtime";
80
- import { useEffect, useId as useId2, useLayoutEffect, useRef } from "react";
81
- function Dialog({ title, open, onOpenChange, children, actions, className }) {
294
+ import { jsx as _jsx6, jsxs as _jsxs4, Fragment as _Fragment } from "react/jsx-runtime";
295
+ import { useId as useId2, useLayoutEffect, useRef, useState as useState2 } from "react";
296
+ import { createPortal } from "react-dom";
297
+
298
+ // packages/ui-system/dist/dialog-surface.js
299
+ function createDialogSurface(anchor) {
300
+ const source = anchor.ownerDocument;
301
+ let target;
302
+ try {
303
+ target = source.defaultView?.top?.document ?? source;
304
+ } catch {
305
+ return void 0;
306
+ }
307
+ if (target === source)
308
+ return void 0;
309
+ const host = target.createElement("div");
310
+ host.dataset.studioDialogSurface = "";
311
+ const shadow = host.attachShadow({ mode: "open" });
312
+ for (const original of source.querySelectorAll('link[rel="stylesheet"], style')) {
313
+ const clone = original.cloneNode(true);
314
+ if (original.tagName === "LINK")
315
+ clone.setAttribute("href", original.href);
316
+ shadow.append(clone);
317
+ }
318
+ const theme = anchor.closest("[data-vx-theme]");
319
+ const root = target.createElement("div");
320
+ root.dataset.vxTheme = theme?.dataset.vxTheme ?? "light";
321
+ root.className = theme?.className ?? "";
322
+ root.style.display = "contents";
323
+ const style = source.defaultView.getComputedStyle(anchor);
324
+ for (const name of style)
325
+ if (name.startsWith("--"))
326
+ root.style.setProperty(name, style.getPropertyValue(name));
327
+ shadow.append(root);
328
+ let container = root;
329
+ const ancestors = [];
330
+ for (let parent = anchor.parentElement; parent && parent !== theme; parent = parent.parentElement)
331
+ ancestors.unshift(parent);
332
+ for (const original of ancestors) {
333
+ const wrapper = target.createElement("div");
334
+ wrapper.className = original.className;
335
+ for (const { name, value } of original.attributes)
336
+ if (name.startsWith("data-"))
337
+ wrapper.setAttribute(name, value);
338
+ wrapper.style.display = "contents";
339
+ container.append(wrapper);
340
+ container = wrapper;
341
+ }
342
+ target.body.append(host);
343
+ return { root: container, dispose: () => host.remove() };
344
+ }
345
+
346
+ // packages/ui-system/dist/dialog.js
347
+ function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default" }) {
82
348
  const ref = useRef(null);
349
+ const anchor = useRef(null);
350
+ const [surface, setSurface] = useState2();
83
351
  const heading = useId2();
84
- useEffect(() => {
85
- const dialog = ref.current;
86
- if (!dialog || dialog.open === open)
352
+ useLayoutEffect(() => {
353
+ if (!open || !anchor.current)
87
354
  return;
88
- if (open)
89
- dialog.showModal();
90
- else
91
- dialog.close();
355
+ const mounted = createDialogSurface(anchor.current);
356
+ const active = anchor.current.getRootNode().activeElement;
357
+ setSurface(mounted?.root ?? null);
358
+ return () => {
359
+ mounted?.dispose();
360
+ setSurface(void 0);
361
+ queueMicrotask(() => {
362
+ if (active?.isConnected)
363
+ active.focus();
364
+ });
365
+ };
92
366
  }, [open]);
93
367
  useLayoutEffect(() => {
94
- const dialog = ref.current;
368
+ const dialog2 = ref.current;
369
+ if (!open || surface === void 0 || !dialog2)
370
+ return;
371
+ dialog2.showModal();
95
372
  return () => {
96
- if (dialog?.open)
97
- dialog.close();
373
+ if (dialog2.open)
374
+ dialog2.close();
98
375
  };
99
- }, []);
100
- return _jsxs4("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "aria-labelledby": heading, onCancel: (event) => {
376
+ }, [open, surface]);
377
+ const dialog = _jsxs4("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, "aria-labelledby": heading, onCancel: (event) => {
101
378
  event.preventDefault();
102
379
  event.stopPropagation();
103
380
  onOpenChange(false);
104
381
  }, onClose: (event) => {
105
- if (open && !event.currentTarget.open)
382
+ if (open && event.currentTarget.isConnected && !event.currentTarget.open)
106
383
  onOpenChange(false);
107
- }, children: [_jsxs4("header", { children: [_jsx5("h2", { id: heading, children: title }), _jsx5(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) })] }), _jsx5("div", { className: "vx-dialog-body", children }), actions && _jsx5("footer", { children: actions })] });
108
- }
109
-
110
- // packages/studio-workbench/src/query-view.ts
111
- import { z } from "vivix-studio/sdk/shared";
112
- var pageSources = ["projects", "assets", "tasks"];
113
- var columnName = z.string().min(1).max(200).refine((value) => !/[\u0000-\u001f]/.test(value));
114
- var scalar = z.union([z.null(), z.string(), z.number().finite()]);
115
- var customViewSchema = z.object({
116
- source: z.enum(pageSources),
117
- projectId: z.uuid().optional(),
118
- name: z.string().trim().min(1).max(120),
119
- sql: z.string().trim().min(1).max(32e3),
120
- params: z.union([z.array(scalar), z.record(z.string(), scalar)]).default([]),
121
- columns: z.array(
122
- z.object({
123
- path: columnName,
124
- label: z.string().min(1).max(120).optional(),
125
- width: z.number().int().min(80).max(600).default(140),
126
- visible: z.boolean().default(true),
127
- format: z.enum(["text", "categories", "date", "json"]).default("text"),
128
- role: z.enum(["name", "preview", "state", "project"]).optional()
129
- }).strict()
130
- ).min(1).max(60).refine(
131
- (columns) => new Set(columns.map((c) => c.path)).size === columns.length,
132
- "Column names must be unique."
133
- ),
134
- identity: z.object({
135
- row: columnName.default("rowId"),
136
- project: columnName.default("projectId"),
137
- ref: columnName.default("ref"),
138
- outputs: columnName.default("outputRefs")
139
- }).strict().default({ row: "rowId", project: "projectId", ref: "ref", outputs: "outputRefs" })
140
- }).strict();
141
- var column = (path, label, width = 140, extra = {}) => ({ path, label, width, visible: true, format: "text", ...extra });
142
- function defaultSql(source, favorites = false) {
143
- if (source === "projects")
144
- return "SELECT * FROM studio_projects ORDER BY createdAt DESC, rowId ASC";
145
- const table = favorites ? "studio_asset_versions" : `studio_${source}`;
146
- return `SELECT a.*, p.name AS projectName, p.available AS projectAvailable FROM ${table} AS a LEFT JOIN studio_projects AS p ON p.projectId = a.projectId${favorites ? " WHERE a.favorite = 1" : ""} ORDER BY a.createdAt DESC, a.rowId ASC`;
147
- }
148
- function defaultView(source) {
149
- const columns = source === "projects" ? [
150
- column("previewUrl", "Preview", 120, { role: "preview" }),
151
- column("name", "Project title", 260, { role: "name" }),
152
- column("assetCount", "Assets", 120),
153
- column("available", "Available", 120),
154
- column("createdAt", "Created Time", 160, { format: "date" })
155
- ] : source === "assets" ? [
156
- column("previewUrl", "Preview", 120, { role: "preview" }),
157
- column("name", "Asset", 240, { role: "name" }),
158
- column("kind", "Format", 100),
159
- column("prompt", "Prompt", 280),
160
- column("projectName", "Project", 180, { role: "project" }),
161
- column("modelId", "Model", 160),
162
- column("createdAt", "Created Time", 160, { format: "date" }),
163
- column("purpose", "Purpose", 140, { visible: false })
164
- ] : [
165
- column("previewUrl", "Preview", 120, { role: "preview" }),
166
- column("name", "Task", 260, { role: "name" }),
167
- column("state", "Status", 180, { role: "state" }),
168
- column("costLabel", "Actual cost", 180),
169
- column("kind", "Format", 100),
170
- column("prompt", "Prompt", 280),
171
- column("projectName", "Project", 200, { role: "project" }),
172
- column("modelId", "Model", 160),
173
- column("createdAt", "Created Time", 160, { format: "date" })
174
- ];
175
- return {
176
- id: `default:${source}`,
177
- revision: 0,
178
- view: customViewSchema.parse({
179
- source,
180
- name: "All",
181
- sql: defaultSql(source),
182
- columns
183
- })
184
- };
185
- }
186
- function decodeRef(value) {
187
- let item = value;
188
- if (typeof item === "string") {
189
- try {
190
- item = JSON.parse(item);
191
- } catch {
192
- return null;
193
- }
194
- }
195
- if (!item || typeof item !== "object" || Array.isArray(item)) return null;
196
- const ref = item;
197
- return ["storeId", "objectId", "versionId"].every(
198
- (key) => typeof ref[key] === "string" && /^[0-9a-f-]{36}$/i.test(ref[key])
199
- ) ? {
200
- storeId: ref.storeId,
201
- objectId: ref.objectId,
202
- versionId: ref.versionId
203
- } : null;
204
- }
205
- function rowRef(row, view) {
206
- return decodeRef(row[view.identity.ref]);
207
- }
208
-
209
- // packages/studio-workbench/src/text-preview.ts
210
- async function readTextPreview(response, signal, maxBytes = 128 * 1024) {
211
- if (!response.ok || !response.body) throw Error("The text preview could not be loaded.");
212
- const reader = response.body.getReader();
213
- const decoder = new TextDecoder();
214
- let text = "", used = 0, truncated = false;
215
- const cancel = () => {
216
- void reader.cancel(signal.reason).catch(() => void 0);
217
- };
218
- signal.addEventListener("abort", cancel, { once: true });
219
- try {
220
- while (true) {
221
- signal.throwIfAborted();
222
- const chunk = await reader.read();
223
- signal.throwIfAborted();
224
- if (chunk.done) break;
225
- const remaining = maxBytes - used;
226
- text += decoder.decode(chunk.value.subarray(0, remaining), { stream: true });
227
- used += Math.min(remaining, chunk.value.byteLength);
228
- if (chunk.value.byteLength > remaining) {
229
- truncated = true;
230
- break;
231
- }
232
- }
233
- text += decoder.decode();
234
- return { text, truncated };
235
- } finally {
236
- signal.removeEventListener("abort", cancel);
237
- await reader.cancel().catch(() => void 0);
238
- reader.releaseLock();
239
- }
240
- }
241
-
242
- // packages/studio-workbench/src/studio-glyph.tsx
243
- import "react";
244
- import { jsx } from "react/jsx-runtime";
245
- var paths = {
246
- projects: [
247
- "M6.66803 5.83333H10.0023M10.0023 5.83333H13.9617C15.7177 5.83333 16.5958 5.83333 17.2265 6.25466C17.4995 6.43706 17.734 6.67143 17.9164 6.94441C18.2448 7.43568 18.3173 8.07703 18.3333 9.16667M10.0023 5.83333L9.47426 4.7776C9.03683 3.90298 8.63709 3.0226 7.66768 2.65917C7.2431 2.5 6.75807 2.5 5.78802 2.5C4.27388 2.5 3.51681 2.5 2.94874 2.81693C2.54379 3.04285 2.20966 3.37689 1.98368 3.78172C1.66667 4.34964 1.66667 5.1065 1.66667 6.62023V9.16667C1.66667 13.095 1.66667 15.0592 2.88739 16.2796C4.10811 17.5 6.07283 17.5 10.0023 17.5",
248
- "M15 16.4773C16.4728 16.4773 17.6667 15.2562 17.6667 13.75C17.6667 12.2438 16.4728 11.0227 15 11.0227M15 16.4773C13.5272 16.4773 12.3333 15.2562 12.3333 13.75C12.3333 12.2438 13.5272 11.0227 15 11.0227M15 16.4773V17.5M15 11.0227V10M12.5761 12.2624L11.667 11.7045M18.3333 15.7955L17.4243 15.2376M17.4239 12.2624L18.333 11.7045M11.6667 15.7955L12.5757 15.2376"
249
- ],
250
- assets: [
251
- "M2.5 2.5H17.5C17.9602 2.5 18.3333 2.8731 18.3333 3.33333V5.83333C18.3333 6.29357 17.9602 6.66667 17.5 6.66667H2.5C2.03976 6.66667 1.66667 6.29357 1.66667 5.83333V3.33333C1.66667 2.8731 2.03976 2.5 2.5 2.5Z",
252
- "M3.33333 6.66667V15.8333C3.33333 16.2754 3.50893 16.6993 3.82149 17.0118C4.13405 17.3244 4.55797 17.5 5 17.5H15C15.442 17.5 15.866 17.3244 16.1785 17.0118C16.4911 16.6993 16.6667 16.2754 16.6667 15.8333V6.66667",
253
- "M8.33333 10H11.6667"
254
- ],
255
- tasks: [
256
- "M15.75 7.41667C15.75 8.58344 15.75 9.16683 15.5229 9.61248C15.3232 10.0045 15.0045 10.3232 14.6125 10.5229C14.1668 10.75 13.5834 10.75 12.4167 10.75H4.08333C2.91656 10.75 2.33317 10.75 1.88752 10.5229C1.49552 10.3232 1.17681 10.0045 0.977071 9.61248C0.750001 9.16683 0.750001 8.58344 0.750001 7.41667",
257
- "M3.25 7.41667H13.25M3.25 4.08333H13.25M3.25 0.75H13.25"
258
- ],
259
- panel: [
260
- "M2.08333 10C2.08333 6.26805 2.08333 4.40207 3.2427 3.2427C4.40207 2.08333 6.26805 2.08333 10 2.08333C13.7319 2.08333 15.5979 2.08333 16.7573 3.2427C17.9167 4.40207 17.9167 6.26805 17.9167 10C17.9167 13.7319 17.9167 15.5979 16.7573 16.7573C15.5979 17.9167 13.7319 17.9167 10 17.9167C6.26805 17.9167 4.40207 17.9167 3.2427 16.7573C2.08333 15.5979 2.08333 13.7319 2.08333 10Z",
261
- "M7.06381 6.69231L7.09951 13.3523"
262
- ],
263
- favorite: [
264
- "M0.600003 5.73835V11.2539C0.600003 12.7911 0.600003 13.5597 1.11523 13.8349C2.11298 14.3676 3.98454 12.5901 4.87334 12.0549C5.38881 11.7446 5.64654 11.5894 5.93334 11.5894C6.22013 11.5894 6.47787 11.7446 6.99333 12.0549C7.88214 12.5901 9.75369 14.3676 10.7514 13.8349C11.2667 13.5597 11.2667 12.7911 11.2667 11.2539V5.73835C11.2667 3.31611 11.2667 2.10499 10.4856 1.3525C9.70457 0.600001 8.44749 0.600001 5.93334 0.600001C3.41918 0.600001 2.1621 0.600001 1.38105 1.3525C0.600003 2.10499 0.600003 3.31611 0.600003 5.73835Z"
265
- ]
266
- };
267
- function StudioGlyph({ name }) {
268
- return /* @__PURE__ */ jsx(
269
- "svg",
270
- {
271
- className: "studio-glyph",
272
- "aria-hidden": "true",
273
- width: "20",
274
- height: "20",
275
- viewBox: name === "tasks" ? "0 0 16.5 11.5" : name === "favorite" ? "0 0 11.8667 14.5333" : "0 0 20 20",
276
- fill: "none",
277
- stroke: "currentColor",
278
- strokeWidth: name === "favorite" ? 1.2 : 1.5,
279
- strokeLinecap: "round",
280
- strokeLinejoin: "round",
281
- children: paths[name].map((d, index) => /* @__PURE__ */ jsx("path", { d }, index))
282
- }
283
- );
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)] });
284
386
  }
285
387
 
286
- // packages/studio-workbench/src/dashboard-card.tsx
287
- import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
288
- var Config = z2.object({ studioInstance: z2.string().min(1).nullable().default(null) });
289
- var dashboardAssetsSql = `SELECT a.* FROM studio_assets AS a
290
- ORDER BY (json_extract(a.metadata, '$.homeFeatured') IS NOT NULL) DESC,
291
- ROW_NUMBER() OVER (
292
- PARTITION BY a.projectId, a.kind, a.purpose ORDER BY a.createdAt DESC, a.rowId ASC
293
- ), a.createdAt DESC, a.rowId ASC`;
294
- function featuredRole(row) {
295
- const metadata = row?.metadata;
296
- return metadata && typeof metadata === "object" && "homeFeatured" in metadata ? metadata.homeFeatured : void 0;
297
- }
298
- function sampleAssets(items) {
299
- const chosen = /* @__PURE__ */ new Set();
300
- for (const [role, kind, purpose] of [
301
- ["character", "image", "reference"],
302
- ["video", "video", "shot"],
303
- ["scene", "image", "shot"],
304
- ["script", "text", "script"],
305
- ["audio", "audio", "voice"]
306
- ]) {
307
- const asset = items.find((row) => featuredRole(row) === role && row.kind === kind) ?? items.find((row) => row.kind === kind && row.purpose === purpose && !chosen.has(row));
308
- if (asset) chosen.add(asset);
309
- }
310
- for (const row of items) if (row.kind !== "text" || row.purpose === "script") chosen.add(row);
311
- return [...chosen].slice(0, 5);
312
- }
388
+ // packages/dashboard-projects/src/create-project-dialog.tsx
389
+ import * as React from "react";
390
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
313
391
  var projectTypes = [
314
392
  {
315
393
  value: "short-drama",
316
394
  label: "Short Drama",
317
395
  preset: "@vivix-labs/short-drama-workbench:short-drama"
318
396
  },
319
- { value: "ads", label: "Product Ad", preset: "@vivix-labs/studio-workbench:ads" },
320
- { value: "table", label: "Other", preset: "@vivix-labs/studio-workbench:table" }
397
+ { value: "ads", label: "Product Ad", preset: "@vivix-labs/ads-workbench:ads" },
398
+ { value: "table", label: "Others", preset: "@vivix-labs/studio-workbench:table" }
321
399
  ];
322
- function NewProjectDialog({ close }) {
323
- const [type, setType] = React2.useState(projectTypes[0].value);
324
- const [name, setName] = React2.useState("");
325
- const [status, setStatus] = React2.useState("");
400
+ function NewProjectDialog({
401
+ client,
402
+ close,
403
+ onCreated
404
+ }) {
405
+ const [type, setType] = React.useState(projectTypes[0].value);
406
+ const [name, setName] = React.useState("");
407
+ const [status, setStatus] = React.useState("");
408
+ const [presets, setPresets] = React.useState();
409
+ const [busy, setBusy] = React.useState(false);
410
+ const request = React.useRef(void 0);
411
+ React.useEffect(() => {
412
+ let active = true;
413
+ if (!client.projects?.presets || !client.projects.create) {
414
+ setStatus("Update Studio CLI to create projects from Home.");
415
+ return;
416
+ }
417
+ void client.projects.presets().then(
418
+ (items) => {
419
+ if (active) setPresets(items);
420
+ },
421
+ (error) => {
422
+ if (active) setStatus(error.message);
423
+ }
424
+ );
425
+ return () => {
426
+ active = false;
427
+ };
428
+ }, [client]);
326
429
  const selection = projectTypes.find((item) => item.value === type);
327
430
  const placeholder = type === "table" ? "Untitled Project" : "Untitled " + selection.label;
328
- const prompt = [
329
- `Create a local Vivix Studio project named ${JSON.stringify(name.trim() || placeholder)} from the installed ${selection.preset} preset.`,
330
- "Use the profile of my current Studio workbench. Run vivix-studio preset list --json and check vivix-studio project init --help. Create it with project init --preset in a new empty local folder, then open the project in Studio."
331
- ].join("\n");
332
- return /* @__PURE__ */ jsx2(
431
+ const [packageName, presetId] = selection.preset.split(":");
432
+ const preset = [packageName, packageName.replace("@vivix-labs/", "@vivix-studio/")].flatMap(
433
+ (name2) => presets?.filter(
434
+ (item) => item.spec.startsWith(name2 + "@") && item.spec.endsWith(":" + presetId)
435
+ ) ?? []
436
+ )[0];
437
+ async function create() {
438
+ if (!preset || !client.projects?.create || busy) return;
439
+ const input = {
440
+ name: name.trim() || placeholder,
441
+ preset: preset.spec,
442
+ trust: true,
443
+ allowAccess: [...preset.requiredAccess]
444
+ };
445
+ const intent = JSON.stringify(input);
446
+ if (request.current?.intent !== intent) request.current = { intent, id: crypto.randomUUID() };
447
+ setBusy(true);
448
+ setStatus("");
449
+ try {
450
+ const project = await client.projects.create({ ...input, requestId: request.current.id });
451
+ onCreated(project);
452
+ close();
453
+ } catch (error) {
454
+ setStatus(error instanceof Error ? error.message : String(error));
455
+ } finally {
456
+ setBusy(false);
457
+ }
458
+ }
459
+ return /* @__PURE__ */ jsx(
333
460
  Dialog,
334
461
  {
335
- title: "Create Project",
462
+ title: "Create Projects",
336
463
  open: true,
464
+ variant: "create-project",
337
465
  className: "studio-home-dialog",
338
- onOpenChange: (open) => !open && close(),
466
+ onOpenChange: (open) => !open && !busy && close(),
339
467
  actions: /* @__PURE__ */ jsxs(Fragment, { children: [
340
- /* @__PURE__ */ jsx2(Button, { label: "Cancel", variant: "text-tonal-sm", onClick: close }),
341
- /* @__PURE__ */ jsx2(
468
+ /* @__PURE__ */ jsx(
342
469
  Button,
343
470
  {
344
- label: "Copy Prompt",
345
- onClick: async () => {
346
- try {
347
- await navigator.clipboard.writeText(prompt);
348
- setStatus("Prompt copied. Paste it into your Agent chat.");
349
- } catch {
350
- setStatus("Select and copy the prompt below.");
351
- }
352
- }
471
+ label: "Cancel",
472
+ variant: "text-tonal-lg",
473
+ width: "hug",
474
+ disabled: busy,
475
+ onClick: close
476
+ }
477
+ ),
478
+ /* @__PURE__ */ jsx(
479
+ Button,
480
+ {
481
+ label: busy ? "Creating\u2026" : "Create Project",
482
+ variant: "text-filled-lg",
483
+ width: "hug",
484
+ disabled: busy || !preset,
485
+ onClick: () => void create()
353
486
  }
354
487
  )
355
488
  ] }),
356
489
  children: /* @__PURE__ */ jsxs("div", { className: "studio-home-create-form", children: [
357
- /* @__PURE__ */ jsx2("strong", { children: "Project type" }),
358
- /* @__PURE__ */ jsx2(
359
- SegmentedControl,
360
- {
361
- label: "Project type",
362
- value: type,
363
- items: projectTypes,
364
- onValueChange: setType
365
- }
366
- ),
367
- /* @__PURE__ */ jsx2(
490
+ /* @__PURE__ */ jsxs("div", { className: "studio-home-create-field", children: [
491
+ /* @__PURE__ */ jsx("span", { children: "Project type" }),
492
+ /* @__PURE__ */ jsx(
493
+ SegmentedControl,
494
+ {
495
+ label: "Project type",
496
+ size: "large",
497
+ width: "full",
498
+ value: type,
499
+ items: projectTypes.map((item) => ({ ...item, disabled: busy })),
500
+ onValueChange: setType
501
+ }
502
+ )
503
+ ] }),
504
+ /* @__PURE__ */ jsx(
368
505
  TextInput,
369
506
  {
370
507
  label: "Project name",
508
+ size: "large",
371
509
  value: name,
372
510
  onValueChange: setName,
373
511
  maxLength: 100,
374
- placeholder
512
+ disabled: busy,
513
+ placeholder: "Enter project name"
375
514
  }
376
515
  ),
377
- /* @__PURE__ */ jsx2("p", { children: "Copy a prompt for your agent to create and open the project." }),
378
- status && /* @__PURE__ */ jsx2("p", { role: "status", children: status }),
379
- status.startsWith("Select") && /* @__PURE__ */ jsx2("textarea", { "aria-label": "Project prompt", readOnly: true, value: prompt })
516
+ presets && !preset && /* @__PURE__ */ jsxs("p", { role: "alert", children: [
517
+ "Install the ",
518
+ selection.label,
519
+ " preset to create this project."
520
+ ] }),
521
+ status && /* @__PURE__ */ jsx("p", { role: "alert", children: status })
380
522
  ] })
381
523
  }
382
524
  );
383
525
  }
384
- function Cover({ row, kind }) {
385
- const [failed, setFailed] = React2.useState(false);
386
- const source = typeof row?.previewUrl === "string" && !failed ? row.previewUrl : void 0;
387
- const script = kind === "assets" && row?.kind === "text" && row?.purpose === "script";
388
- const [excerpt, setExcerpt] = React2.useState("");
526
+
527
+ // packages/dashboard-projects/src/client.tsx
528
+ 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) });
530
+ var dependencies = (config) => config.studioInstance ? [config.studioInstance] : [];
531
+ var projectsSql = "SELECT * FROM studio_projects ORDER BY createdAt DESC, rowId ASC";
532
+ function decodeRef(value) {
533
+ let item = value;
534
+ if (typeof item === "string") {
535
+ try {
536
+ item = JSON.parse(item);
537
+ } catch {
538
+ return null;
539
+ }
540
+ }
541
+ if (!item || typeof item !== "object" || Array.isArray(item)) return null;
542
+ const ref = item;
543
+ return ["storeId", "objectId", "versionId"].every(
544
+ (key) => typeof ref[key] === "string" && /^[0-9a-f-]{36}$/i.test(ref[key])
545
+ ) ? {
546
+ storeId: ref.storeId,
547
+ objectId: ref.objectId,
548
+ versionId: ref.versionId
549
+ } : null;
550
+ }
551
+ function ProjectCover({
552
+ client,
553
+ row,
554
+ pending
555
+ }) {
556
+ const coverRef = row?.available ? row.previewRef ?? row.coverRef : void 0;
557
+ const instanceId = client.config.studioInstance;
558
+ const [resolved, setResolved] = React2.useState();
389
559
  React2.useEffect(() => {
390
- if (!script || !source) return;
391
- const controller = new AbortController();
392
- if (new URL(source, window.location.origin).origin !== window.location.origin) return;
393
- void fetch(source, { signal: controller.signal }).then((response) => readTextPreview(response, controller.signal, 1024)).then(({ text }) => setExcerpt(text.trim())).catch(() => void 0);
394
- return () => controller.abort();
395
- }, [script, source]);
396
- return /* @__PURE__ */ jsx2("span", { className: "studio-home-cover", "aria-hidden": "true", children: source && (kind === "projects" ? row?.previewKind : row?.kind) === "video" ? /* @__PURE__ */ jsx2("video", { src: source, muted: true, playsInline: true, preload: "auto", onError: () => setFailed(true) }) : source && (kind === "projects" || row?.kind === "image") ? /* @__PURE__ */ jsx2("img", { src: source, alt: "", loading: "lazy", onError: () => setFailed(true) }) : excerpt ? /* @__PURE__ */ jsx2("span", { className: "studio-home-script-preview", children: excerpt }) : row?.kind === "audio" ? /* @__PURE__ */ jsx2(Icon, { name: "sound-file", size: 32 }) : /* @__PURE__ */ jsx2(StudioGlyph, { name: kind }) });
560
+ const ref = decodeRef(coverRef);
561
+ if (!ref || !instanceId) return;
562
+ let active = true;
563
+ void client.invoke({ instanceId, operationId: "global.asset" }, { ref }).then(
564
+ ({ item }) => {
565
+ if (active) setResolved(item);
566
+ },
567
+ () => {
568
+ if (active) setResolved(null);
569
+ }
570
+ );
571
+ return () => {
572
+ active = false;
573
+ };
574
+ }, [client, coverRef, instanceId]);
575
+ const src = resolved?.previewUrl ?? row?.previewUrl;
576
+ return /* @__PURE__ */ jsx2(
577
+ CoverPreview,
578
+ {
579
+ className: "studio-home-cover",
580
+ 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)
583
+ }
584
+ );
397
585
  }
398
- function DataCard({
586
+ var previousProjects = /* @__PURE__ */ new WeakMap();
587
+ function ProjectsCard({
399
588
  client,
400
589
  projects,
590
+ hiddenProjectIds,
401
591
  ready,
402
- source,
403
- title,
404
592
  openProject,
405
593
  openProjects,
406
- openAssets
594
+ onProjectCreated
407
595
  }) {
408
- const [state, setState] = React2.useState();
596
+ const [result, setResult] = React2.useState(() => previousProjects.get(client));
409
597
  const [creating, setCreating] = React2.useState(false);
410
598
  const catalogKey = JSON.stringify(projects);
411
- const view = React2.useMemo(() => defaultView(source).view, [source]);
599
+ const hiddenKey = JSON.stringify(hiddenProjectIds ?? []);
600
+ const resultKey = JSON.stringify([catalogKey, hiddenKey]);
412
601
  React2.useEffect(() => {
413
602
  if (!ready || !client.config.studioInstance) return;
414
603
  let active = true;
415
604
  void client.invoke(
416
605
  { instanceId: client.config.studioInstance, operationId: "global.query" },
417
606
  {
418
- source,
419
- sql: source === "assets" ? dashboardAssetsSql : view.sql,
420
- params: view.params,
607
+ source: "projects",
608
+ sql: projectsSql,
609
+ params: [],
421
610
  catalog: JSON.parse(catalogKey),
422
- limit: source === "assets" ? 24 : 5,
611
+ ...hiddenKey !== "[]" && { excludeProjectIds: JSON.parse(hiddenKey) },
612
+ limit: 5,
423
613
  timeoutMs: 8e3,
424
614
  offset: 0
425
615
  }
426
616
  ).then(
427
- async ({ items }) => {
428
- const rows2 = source === "projects" ? await Promise.all(
429
- items.map(async (row) => {
430
- const ref = decodeRef(row.previewRef ?? row.coverRef);
431
- if (!ref || !row.available) return row;
432
- try {
433
- const { item } = await client.invoke(
434
- { instanceId: client.config.studioInstance, operationId: "global.asset" },
435
- { ref }
436
- );
437
- return {
438
- ...row,
439
- previewUrl: item.previewUrl ?? null,
440
- previewKind: item.kind ?? null
441
- };
442
- } catch {
443
- return row;
444
- }
445
- })
446
- ) : sampleAssets(items);
447
- if (active) setState({ rows: rows2 });
617
+ ({ items }) => {
618
+ if (!active) return;
619
+ const result2 = { catalogKey: resultKey, rows: items };
620
+ previousProjects.set(client, result2);
621
+ setResult(result2);
448
622
  },
449
623
  () => {
450
- if (active) setState({ rows: [], error: true });
624
+ if (!active) return;
625
+ previousProjects.delete(client);
626
+ setResult({ catalogKey: resultKey, rows: [] });
451
627
  }
452
628
  );
453
629
  return () => {
454
630
  active = false;
455
631
  };
456
- }, [client, ready, catalogKey, source, view]);
457
- const rows = state?.rows ?? [];
458
- const entries = source === "projects" ? (rows.length ? rows.map((row) => projects.find(({ id }) => id === row.projectId)).filter((entry) => !!entry) : projects.slice(0, 5)).map((project) => {
459
- const row = rows.find((entry) => entry.projectId === project.id);
632
+ }, [client, ready, catalogKey, hiddenKey]);
633
+ const current = catalogKey === result?.catalogKey ? result : void 0;
634
+ const pending = Boolean(client.config.studioInstance) && (!ready || !current);
635
+ const list = current?.rows ?? [];
636
+ const entries = (list.length ? list.map((row) => projects.find(({ id }) => id === row.projectId)).filter((entry) => !!entry) : projects.slice(0, 5)).map((project) => {
637
+ const row = list.find((entry) => entry.projectId === project.id);
460
638
  return {
461
639
  key: project.id,
462
640
  row,
@@ -465,33 +643,23 @@ function DataCard({
465
643
  enabled: project.available,
466
644
  open: () => openProject(project.id)
467
645
  };
468
- }) : rows.map((row) => {
469
- const ref = rowRef(row, view);
470
- return {
471
- key: String(row.rowId),
472
- row,
473
- name: String(row.name ?? "Asset"),
474
- note: featuredRole(row) === "character" ? "Character \xB7 Turnaround" : row.purpose === "script" ? "Script" : String(row.kind ?? "").replace(/^./, (first) => first.toUpperCase()),
475
- enabled: !!ref,
476
- open: () => ref && openAssets(ref)
477
- };
478
646
  });
479
- return /* @__PURE__ */ jsxs("section", { className: "studio-home-panel", "aria-label": title, children: [
480
- /* @__PURE__ */ jsxs("header", { children: [
481
- /* @__PURE__ */ jsx2("h2", { children: title }),
647
+ return /* @__PURE__ */ jsxs2("section", { className: "studio-home-panel", "aria-label": "Project List", children: [
648
+ /* @__PURE__ */ jsxs2("header", { children: [
649
+ /* @__PURE__ */ jsx2("h2", { children: "Project List" }),
482
650
  /* @__PURE__ */ jsx2(
483
651
  Button,
484
652
  {
485
653
  label: "View all",
486
- "aria-label": "View all " + title.toLowerCase(),
654
+ "aria-label": "View all project list",
487
655
  className: "studio-home-view-all",
488
656
  variant: "text-tonal-sm",
489
- onClick: source === "projects" ? openProjects : () => openAssets()
657
+ onClick: openProjects
490
658
  }
491
659
  )
492
660
  ] }),
493
- entries.length || source === "projects" ? /* @__PURE__ */ jsxs("div", { className: "studio-home-grid", children: [
494
- source === "projects" && /* @__PURE__ */ jsxs(
661
+ /* @__PURE__ */ jsxs2("div", { className: "studio-home-grid", children: [
662
+ /* @__PURE__ */ jsxs2(
495
663
  "button",
496
664
  {
497
665
  type: "button",
@@ -499,12 +667,14 @@ function DataCard({
499
667
  onClick: () => setCreating(true),
500
668
  children: [
501
669
  /* @__PURE__ */ jsx2("span", { className: "studio-home-cover", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(Icon, { name: "add" }) }) }),
502
- /* @__PURE__ */ jsx2("strong", { children: "Create Project" }),
503
- /* @__PURE__ */ jsx2("small", { children: "Create a local project" })
670
+ /* @__PURE__ */ jsxs2("span", { className: "studio-home-caption", children: [
671
+ /* @__PURE__ */ jsx2("strong", { children: "Create Project" }),
672
+ /* @__PURE__ */ jsx2("small", { children: "Create a local project" })
673
+ ] })
504
674
  ]
505
675
  }
506
676
  ),
507
- entries.map(({ key, row, name, note, enabled, open }) => /* @__PURE__ */ jsxs(
677
+ entries.map(({ key, row, name, note, enabled, open }) => /* @__PURE__ */ jsxs2(
508
678
  "button",
509
679
  {
510
680
  type: "button",
@@ -512,27 +682,75 @@ function DataCard({
512
682
  onClick: open,
513
683
  disabled: !enabled,
514
684
  children: [
515
- /* @__PURE__ */ jsx2(Cover, { row, kind: source }, String(row?.previewUrl ?? "")),
516
- /* @__PURE__ */ jsx2("strong", { title: name, children: name }),
517
- note && /* @__PURE__ */ jsx2("small", { children: note })
685
+ /* @__PURE__ */ jsx2(
686
+ ProjectCover,
687
+ {
688
+ client,
689
+ row,
690
+ pending: enabled && pending
691
+ },
692
+ JSON.stringify([
693
+ client.config.studioInstance,
694
+ row?.available,
695
+ row?.previewRef ?? row?.coverRef
696
+ ])
697
+ ),
698
+ /* @__PURE__ */ jsxs2("span", { className: "studio-home-caption", children: [
699
+ /* @__PURE__ */ jsx2("strong", { title: name, children: name }),
700
+ note && /* @__PURE__ */ jsx2("small", { children: note })
701
+ ] })
518
702
  ]
519
703
  },
520
704
  key
521
705
  ))
522
- ] }) : /* @__PURE__ */ jsx2("p", { className: "studio-home-empty", role: "status", children: !client.config.studioInstance || state?.error ? `${title} unavailable.` : !state ? "Loading\u2026" : "No assets yet." }),
523
- creating && /* @__PURE__ */ jsx2(NewProjectDialog, { close: () => setCreating(false) })
706
+ ] }),
707
+ creating && /* @__PURE__ */ jsx2(
708
+ NewProjectDialog,
709
+ {
710
+ client,
711
+ close: () => setCreating(false),
712
+ onCreated: (project) => {
713
+ if (onProjectCreated) onProjectCreated(project);
714
+ else openProject(project.id);
715
+ }
716
+ }
717
+ )
524
718
  ] });
525
719
  }
526
-
527
- // packages/dashboard-projects/src/client.tsx
528
- import { jsx as jsx3 } from "react/jsx-runtime";
529
- var dependencies = (config) => config.studioInstance ? [config.studioInstance] : [];
530
720
  function activate(client) {
531
721
  client.registerUI({
532
722
  id: "projects",
533
723
  title: "Project List",
534
724
  kind: "component",
535
- component: (props) => /* @__PURE__ */ jsx3(DataCard, { ...props, client, source: "projects", title: "Project List" })
725
+ component: (props) => /* @__PURE__ */ jsx2(ProjectsCard, { ...props, client })
726
+ });
727
+ client.registerUI({
728
+ id: "create-project",
729
+ title: "Create Project",
730
+ kind: "component",
731
+ component: function ProjectCreator(props) {
732
+ const [open, setOpen] = React2.useState(false);
733
+ if ("close" in props) return /* @__PURE__ */ jsx2(NewProjectDialog, { client, ...props });
734
+ return /* @__PURE__ */ jsxs2(Fragment2, { children: [
735
+ /* @__PURE__ */ jsx2(
736
+ Button,
737
+ {
738
+ label: "Create Project",
739
+ variant: "text-filled-sm",
740
+ width: "hug",
741
+ onClick: () => setOpen(true)
742
+ }
743
+ ),
744
+ open && /* @__PURE__ */ jsx2(
745
+ NewProjectDialog,
746
+ {
747
+ client,
748
+ close: () => setOpen(false),
749
+ onCreated: (project) => props.onProjectCreated?.(project)
750
+ }
751
+ )
752
+ ] });
753
+ }
536
754
  });
537
755
  }
538
756
  export {