@vivix-labs/dashboard-projects 1.0.0-beta.2 → 1.0.0-beta.21
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.css +30 -26
- package/dist/client-code.js +528 -113
- package/package.json +5 -2
package/dist/client-code.css
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/* packages/dashboard-projects/src/create-project-dialog.css */
|
|
2
|
+
.studio-home-create-form {
|
|
3
|
+
display: grid;
|
|
4
|
+
gap: var(--vx-space-16);
|
|
5
|
+
}
|
|
6
|
+
.studio-home-create-field {
|
|
7
|
+
display: grid;
|
|
8
|
+
gap: var(--vx-space-8);
|
|
9
|
+
color: var(--vx-text-secondary);
|
|
10
|
+
font: var(--vx-typography-inter-14-regular);
|
|
11
|
+
}
|
|
12
|
+
.studio-home-create-form p {
|
|
13
|
+
margin: 0;
|
|
14
|
+
color: var(--vx-text-secondary-readable);
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
/* packages/dashboard-projects/src/card.css */
|
|
2
18
|
.studio-home-panel {
|
|
3
19
|
--home-panel-inset: 16px;
|
|
@@ -15,7 +31,7 @@
|
|
|
15
31
|
}
|
|
16
32
|
.studio-home-panel > header h2 {
|
|
17
33
|
margin: 0;
|
|
18
|
-
font
|
|
34
|
+
font: var(--vx-typography-inter-16-semi-bold);
|
|
19
35
|
}
|
|
20
36
|
.studio-home-grid {
|
|
21
37
|
display: grid;
|
|
@@ -23,11 +39,11 @@
|
|
|
23
39
|
gap: 8px;
|
|
24
40
|
padding: 0 var(--home-panel-inset) var(--home-panel-inset);
|
|
25
41
|
}
|
|
26
|
-
.studio-home-tile {
|
|
42
|
+
.studio-home-panel .studio-home-tile {
|
|
27
43
|
display: grid;
|
|
28
44
|
align-content: start;
|
|
29
45
|
text-align: start;
|
|
30
|
-
gap:
|
|
46
|
+
gap: var(--vx-space-8);
|
|
31
47
|
min-width: 0;
|
|
32
48
|
width: 100%;
|
|
33
49
|
color: inherit;
|
|
@@ -37,6 +53,14 @@
|
|
|
37
53
|
padding: 0;
|
|
38
54
|
cursor: pointer;
|
|
39
55
|
}
|
|
56
|
+
.studio-home-caption {
|
|
57
|
+
display: grid;
|
|
58
|
+
min-width: 0;
|
|
59
|
+
gap: var(--vx-space-4);
|
|
60
|
+
}
|
|
61
|
+
.studio-home-caption > strong {
|
|
62
|
+
font: var(--vx-typography-inter-14-semi-bold);
|
|
63
|
+
}
|
|
40
64
|
.studio-home-tile:disabled {
|
|
41
65
|
opacity: 0.5;
|
|
42
66
|
cursor: default;
|
|
@@ -59,8 +83,8 @@
|
|
|
59
83
|
place-items: center;
|
|
60
84
|
overflow: hidden;
|
|
61
85
|
border-radius: 8px;
|
|
62
|
-
background: var(--vx-
|
|
63
|
-
color: var(--vx-text-
|
|
86
|
+
background: var(--vx-cover-background);
|
|
87
|
+
color: var(--vx-text-on-content-secondary);
|
|
64
88
|
}
|
|
65
89
|
.studio-home-cover img,
|
|
66
90
|
.studio-home-cover video {
|
|
@@ -70,12 +94,10 @@
|
|
|
70
94
|
height: 100%;
|
|
71
95
|
object-fit: contain;
|
|
72
96
|
}
|
|
73
|
-
.studio-home-cover:has(img, video) {
|
|
74
|
-
background: #151515;
|
|
75
|
-
}
|
|
76
97
|
.studio-home-create .studio-home-cover {
|
|
77
98
|
border: 1px dashed var(--vx-border-secondary);
|
|
78
99
|
background: var(--vx-surface-input);
|
|
100
|
+
color: var(--vx-text-primary);
|
|
79
101
|
}
|
|
80
102
|
.studio-home-create .studio-home-cover > span {
|
|
81
103
|
display: grid;
|
|
@@ -85,24 +107,6 @@
|
|
|
85
107
|
border-radius: 4px;
|
|
86
108
|
background: var(--vx-background-dialog);
|
|
87
109
|
}
|
|
88
|
-
.studio-home-create-form {
|
|
89
|
-
display: grid;
|
|
90
|
-
gap: var(--vx-space-16);
|
|
91
|
-
}
|
|
92
|
-
.studio-home-create-field {
|
|
93
|
-
display: grid;
|
|
94
|
-
gap: var(--vx-space-8);
|
|
95
|
-
color: var(--vx-text-secondary);
|
|
96
|
-
font: var(--vx-typography-inter-14-regular);
|
|
97
|
-
}
|
|
98
|
-
.studio-home-create-form p {
|
|
99
|
-
margin: 0;
|
|
100
|
-
color: var(--vx-text-secondary-readable);
|
|
101
|
-
}
|
|
102
|
-
.studio-home-view-all.vx-button {
|
|
103
|
-
background: transparent;
|
|
104
|
-
color: var(--vx-state-success);
|
|
105
|
-
}
|
|
106
110
|
@media (max-width: 660px) {
|
|
107
111
|
.studio-home-panel {
|
|
108
112
|
--home-panel-inset: 12px;
|
package/dist/client-code.js
CHANGED
|
@@ -1,12 +1,262 @@
|
|
|
1
1
|
// packages/dashboard-projects/src/client.tsx
|
|
2
|
-
import * as
|
|
2
|
+
import * as React2 from "react";
|
|
3
|
+
import { z as z5 } from "vivix-studio/sdk/shared";
|
|
4
|
+
|
|
5
|
+
// packages/project-studio/dist/shared.js
|
|
6
|
+
import { PluginError, z as z2 } from "vivix-studio/sdk/shared";
|
|
3
7
|
import { z } from "vivix-studio/sdk/shared";
|
|
8
|
+
import { z as z4, defineOperation } from "vivix-studio/sdk/shared";
|
|
9
|
+
import { z as z3 } from "vivix-studio/sdk/shared";
|
|
10
|
+
var creditsFormat = new Intl.NumberFormat("en-US", {
|
|
11
|
+
minimumFractionDigits: 1,
|
|
12
|
+
maximumFractionDigits: 1,
|
|
13
|
+
useGrouping: false
|
|
14
|
+
});
|
|
15
|
+
var taskBilling = z.object({
|
|
16
|
+
status: z.enum(["pending", "settled", "released", "unavailable"]),
|
|
17
|
+
credits: z.string().regex(/^\d+(?:\.\d+)?$/).nullable()
|
|
18
|
+
}).strict().refine(
|
|
19
|
+
(value) => value.status === "settled" ? value.credits !== null : value.status === "released" ? value.credits === "0" : value.credits === null
|
|
20
|
+
);
|
|
21
|
+
var vivixVoiceModel = "vivix-tts-1.0";
|
|
22
|
+
var defaultVoiceOperations = ["voice.design", "voice.clone"];
|
|
23
|
+
function resolveGenerationInput(input, ctx) {
|
|
24
|
+
const defaultsToVivix = defaultVoiceOperations.some(
|
|
25
|
+
(operation) => operation === input.capabilityId
|
|
26
|
+
);
|
|
27
|
+
const modelId = input.modelId ?? (defaultsToVivix ? vivixVoiceModel : void 0);
|
|
28
|
+
if (!modelId) {
|
|
29
|
+
ctx.addIssue({
|
|
30
|
+
code: "custom",
|
|
31
|
+
path: ["modelId"],
|
|
32
|
+
message: "Select a model for this operation."
|
|
33
|
+
});
|
|
34
|
+
return z2.NEVER;
|
|
35
|
+
}
|
|
36
|
+
if (input.prompt === void 0 && !defaultsToVivix && input.capabilityId !== "voice.create") {
|
|
37
|
+
ctx.addIssue({
|
|
38
|
+
code: "custom",
|
|
39
|
+
path: ["prompt"],
|
|
40
|
+
message: "A prompt is required for this operation."
|
|
41
|
+
});
|
|
42
|
+
return z2.NEVER;
|
|
43
|
+
}
|
|
44
|
+
return { ...input, modelId, prompt: input.prompt ?? "" };
|
|
45
|
+
}
|
|
46
|
+
var fixedRef = z3.object({ storeId: z3.uuid(), objectId: z3.uuid(), versionId: z3.uuid() }).strict();
|
|
47
|
+
var copy = z3.string().max(8e3).default("");
|
|
48
|
+
var clipScript = z3.object({
|
|
49
|
+
title: z3.string().trim().min(1).max(200),
|
|
50
|
+
visual: copy,
|
|
51
|
+
voiceover: copy,
|
|
52
|
+
onScreenText: copy,
|
|
53
|
+
cta: copy,
|
|
54
|
+
plannedDurationMs: z3.number().int().positive().nullable().default(null)
|
|
55
|
+
}).strict();
|
|
56
|
+
var adBrief = z3.object({
|
|
57
|
+
product: copy,
|
|
58
|
+
category: copy,
|
|
59
|
+
audience: copy,
|
|
60
|
+
sellingPoints: copy,
|
|
61
|
+
channel: copy,
|
|
62
|
+
aspectRatio: z3.string().max(40).nullable().default(null),
|
|
63
|
+
targetDurationMs: z3.number().int().positive().nullable().default(null),
|
|
64
|
+
body: copy,
|
|
65
|
+
productRefs: z3.array(fixedRef).max(100).default([]),
|
|
66
|
+
modelRefs: z3.array(fixedRef).max(100).default([])
|
|
67
|
+
}).strict();
|
|
68
|
+
var adFilm = z3.object({
|
|
69
|
+
title: z3.string().trim().min(1).max(150),
|
|
70
|
+
source: fixedRef,
|
|
71
|
+
width: z3.number().int().positive().max(8192),
|
|
72
|
+
height: z3.number().int().positive().max(8192),
|
|
73
|
+
aspectRatio: z3.string().regex(/^\d+:\d+$/)
|
|
74
|
+
}).strict();
|
|
75
|
+
var adStoryboard = z3.object({
|
|
76
|
+
brief: adBrief,
|
|
77
|
+
films: z3.array(adFilm).max(100).optional(),
|
|
78
|
+
clips: z3.array(
|
|
79
|
+
z3.object({
|
|
80
|
+
assetId: z3.uuid(),
|
|
81
|
+
filmId: z3.uuid().optional(),
|
|
82
|
+
script: clipScript,
|
|
83
|
+
edits: z3.array(z3.object({ sourceVersionId: z3.uuid(), editRef: fixedRef }).strict()).max(200)
|
|
84
|
+
}).strict()
|
|
85
|
+
).max(200)
|
|
86
|
+
}).strict().superRefine((value, context) => {
|
|
87
|
+
if (new Set(value.clips.map((c) => c.assetId)).size !== value.clips.length)
|
|
88
|
+
context.addIssue({ code: "custom", message: "A clip can appear only once in a storyboard." });
|
|
89
|
+
for (const clip of value.clips)
|
|
90
|
+
if (new Set(clip.edits.map((e) => e.sourceVersionId)).size !== clip.edits.length)
|
|
91
|
+
context.addIssue({
|
|
92
|
+
code: "custom",
|
|
93
|
+
message: "Each candidate has one current edit binding."
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
var projectType = z4.enum(["short-drama", "product-ad", "other"]);
|
|
97
|
+
var studioConfig = z4.object({
|
|
98
|
+
role: z4.enum(["project", "coordinator"]).default("project"),
|
|
99
|
+
projectType: projectType.optional(),
|
|
100
|
+
dataInstance: z4.string().min(1).default("user:data"),
|
|
101
|
+
apiInstance: z4.string().min(1).default("api"),
|
|
102
|
+
libraryInstance: z4.string().min(1).nullable().default(null),
|
|
103
|
+
coordinatorInstance: z4.string().min(1).optional()
|
|
104
|
+
}).strict();
|
|
105
|
+
var versionRef = z4.object({ storeId: z4.uuid(), objectId: z4.uuid(), versionId: z4.uuid() }).strict();
|
|
106
|
+
var tags = z4.array(z4.string().trim().min(1).max(64)).max(50).transform((x) => [...new Set(x)]).default([]);
|
|
107
|
+
var kind = z4.enum(["text", "image", "video", "audio", "file"]);
|
|
108
|
+
var projectData = z4.object({
|
|
109
|
+
name: z4.string().trim().min(1).max(120),
|
|
110
|
+
description: z4.string().max(4e3).default(""),
|
|
111
|
+
status: z4.enum(["draft", "active", "archived"]).default("draft"),
|
|
112
|
+
aspectRatio: z4.string().nullable().default(null),
|
|
113
|
+
projectType: projectType.optional(),
|
|
114
|
+
coverRef: versionRef.nullable().default(null),
|
|
115
|
+
briefRef: z4.object({ storeId: z4.uuid(), objectId: z4.uuid() }).strict().nullable().optional().transform(() => void 0),
|
|
116
|
+
tags
|
|
117
|
+
}).strict();
|
|
118
|
+
var assetData = z4.object({
|
|
119
|
+
projectId: z4.uuid(),
|
|
120
|
+
name: z4.string().trim().min(1).max(200),
|
|
121
|
+
kind,
|
|
122
|
+
purpose: z4.enum([
|
|
123
|
+
"reference",
|
|
124
|
+
"script",
|
|
125
|
+
"shot",
|
|
126
|
+
"music",
|
|
127
|
+
"voice",
|
|
128
|
+
"speech",
|
|
129
|
+
"subtitle",
|
|
130
|
+
"final",
|
|
131
|
+
"other"
|
|
132
|
+
]).default("other"),
|
|
133
|
+
origin: z4.enum(["upload", "library", "generated", "authored"]),
|
|
134
|
+
orderKey: z4.number().int().nullable().default(null),
|
|
135
|
+
tags,
|
|
136
|
+
lifecycle: z4.enum(["draft", "ready", "archived"]).default("draft"),
|
|
137
|
+
sourceRef: versionRef.nullable().default(null),
|
|
138
|
+
adoptedVersionId: z4.uuid().nullable().default(null)
|
|
139
|
+
}).strict();
|
|
140
|
+
var storedAssetData = assetData.extend({
|
|
141
|
+
purpose: z4.union([assetData.shape.purpose, z4.literal("speech")])
|
|
142
|
+
});
|
|
143
|
+
var generationFields = z4.object({
|
|
144
|
+
targetAssetId: z4.uuid().optional(),
|
|
145
|
+
taskName: z4.string().trim().min(1).max(200).optional(),
|
|
146
|
+
context: z4.record(z4.string().min(1).max(64), z4.string().min(1).max(200)).describe(
|
|
147
|
+
"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."
|
|
148
|
+
).optional(),
|
|
149
|
+
expectedRevision: z4.number().int().positive().optional(),
|
|
150
|
+
newAsset: z4.object({
|
|
151
|
+
name: z4.string().trim().min(1).max(200),
|
|
152
|
+
kind: z4.enum(["image", "video", "audio"]),
|
|
153
|
+
purpose: assetData.shape.purpose.unwrap().optional(),
|
|
154
|
+
tags: tags.unwrap().optional()
|
|
155
|
+
}).strict().optional(),
|
|
156
|
+
modelId: z4.string().min(1),
|
|
157
|
+
capabilityId: z4.string().min(1),
|
|
158
|
+
prompt: z4.string().max(32e3).optional(),
|
|
159
|
+
voiceRef: versionRef.optional(),
|
|
160
|
+
parameters: z4.record(z4.string(), z4.unknown()).default({}),
|
|
161
|
+
outputCount: z4.number().int().min(1).max(100).default(1),
|
|
162
|
+
inputs: z4.array(
|
|
163
|
+
z4.object({
|
|
164
|
+
ref: versionRef,
|
|
165
|
+
role: z4.string().min(1),
|
|
166
|
+
order: z4.number().int().nonnegative(),
|
|
167
|
+
weight: z4.number().finite().nullable().default(null)
|
|
168
|
+
}).strict()
|
|
169
|
+
).max(100).default([]),
|
|
170
|
+
baseVersionId: z4.uuid().optional(),
|
|
171
|
+
changeRequest: z4.string().trim().min(1).max(4e3).optional(),
|
|
172
|
+
preserveRequest: z4.string().max(4e3).default(""),
|
|
173
|
+
anchor: z4.object({ kind: z4.literal("whole") }).strict().optional().describe("Deprecated whole-version selection."),
|
|
174
|
+
retryOfTaskId: z4.uuid().optional(),
|
|
175
|
+
acknowledgeUnknown: z4.boolean().optional()
|
|
176
|
+
}).strict();
|
|
177
|
+
var generationInput = generationFields.extend({
|
|
178
|
+
modelId: generationFields.shape.modelId.optional().describe("Defaults to vivix-tts-1.0 for voice.design and voice.clone.")
|
|
179
|
+
}).transform(resolveGenerationInput);
|
|
180
|
+
var projectSettingsInput = z4.object({
|
|
181
|
+
projectId: z4.uuid(),
|
|
182
|
+
expectedRevision: z4.number().int().positive(),
|
|
183
|
+
changes: projectData.pick({ name: true, description: true, tags: true, aspectRatio: true, coverRef: true }).extend({
|
|
184
|
+
description: projectData.shape.description.unwrap(),
|
|
185
|
+
tags: projectData.shape.tags.unwrap(),
|
|
186
|
+
aspectRatio: projectData.shape.aspectRatio.unwrap(),
|
|
187
|
+
coverRef: projectData.shape.coverRef.unwrap()
|
|
188
|
+
}).partial().strict()
|
|
189
|
+
}).strict();
|
|
190
|
+
function generationReceiptPredecessors() {
|
|
191
|
+
const legacy = generationFields.omit({ voiceRef: true }).extend({
|
|
192
|
+
prompt: generationFields.shape.prompt.unwrap(),
|
|
193
|
+
newAsset: generationFields.shape.newAsset.unwrap().omit({ purpose: true, tags: true }).optional(),
|
|
194
|
+
anchor: z4.discriminatedUnion("kind", [
|
|
195
|
+
z4.object({ kind: z4.literal("whole") }).strict(),
|
|
196
|
+
z4.object({
|
|
197
|
+
kind: z4.literal("timeRange"),
|
|
198
|
+
startMs: z4.number().int().nonnegative(),
|
|
199
|
+
endMs: z4.number().int().nonnegative()
|
|
200
|
+
}).strict()
|
|
201
|
+
]).default({ kind: "whole" })
|
|
202
|
+
});
|
|
203
|
+
const voice = legacy.extend({
|
|
204
|
+
prompt: legacy.shape.prompt.optional(),
|
|
205
|
+
voiceRef: versionRef.optional()
|
|
206
|
+
}).refine(
|
|
207
|
+
(input) => input.prompt !== void 0 || ["voice.clone", "voice.create"].includes(input.capabilityId)
|
|
208
|
+
).transform((input) => ({ ...input, prompt: input.prompt ?? "" }));
|
|
209
|
+
return [
|
|
210
|
+
{
|
|
211
|
+
packageVersion: "1.0.0-beta.19",
|
|
212
|
+
packageIntegrity: "e70b5c3b91d551bbd73c0b181eadbe92e71b66fbc6a642004184740a14bd4c06",
|
|
213
|
+
input: legacy
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
packageVersion: "1.0.0-beta.20",
|
|
217
|
+
packageIntegrity: "febb0e966d82d98555beab936e2d735dab3cc98d6101d19e8b692c1ebe0dbe8a",
|
|
218
|
+
input: voice
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
packageVersion: "1.0.0-beta.22",
|
|
222
|
+
packageIntegrity: "6fefdd978b7441df8598373da79d22d945587c8656de4e92b64cb615eec30afb",
|
|
223
|
+
input: voice
|
|
224
|
+
},
|
|
225
|
+
{ packageVersion: "1.0.0-beta.25", input: generationInput },
|
|
226
|
+
// The non-voice beta.22 branch used the original required prompt schema.
|
|
227
|
+
{ packageVersion: "1.0.0-beta.22", input: legacy }
|
|
228
|
+
].map((previous) => ({ ...previous, output: z4.any() }));
|
|
229
|
+
}
|
|
230
|
+
var generationSubmitOperation = defineOperation({
|
|
231
|
+
id: "generation.submit",
|
|
232
|
+
title: "Generate",
|
|
233
|
+
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.",
|
|
234
|
+
input: generationInput,
|
|
235
|
+
receiptPredecessors: generationReceiptPredecessors,
|
|
236
|
+
output: z4.any(),
|
|
237
|
+
effects: ["write", "paid"],
|
|
238
|
+
confirm: "none"
|
|
239
|
+
});
|
|
240
|
+
var favoriteData = z4.object({ ref: versionRef }).strict();
|
|
241
|
+
var sqlScalar = z4.union([z4.string(), z4.number().finite(), z4.null()]);
|
|
242
|
+
var globalQueryInput = z4.object({
|
|
243
|
+
sql: z4.string().trim().min(1),
|
|
244
|
+
params: z4.union([z4.array(sqlScalar), z4.record(z4.string(), sqlScalar)]).optional(),
|
|
245
|
+
timeoutMs: z4.number().int().positive().optional(),
|
|
246
|
+
maxRows: z4.number().int().positive().optional(),
|
|
247
|
+
limit: z4.number().int().min(1).max(200).optional(),
|
|
248
|
+
offset: z4.number().int().nonnegative().optional(),
|
|
249
|
+
source: z4.enum(["projects", "assets", "tasks"]),
|
|
250
|
+
excludeProjectIds: z4.array(z4.uuid()).optional(),
|
|
251
|
+
catalog: z4.array(z4.object({ id: z4.string().min(1), name: z4.string(), available: z4.boolean() }).strict()).optional()
|
|
252
|
+
}).strict();
|
|
253
|
+
var projectListSql = "SELECT rowId, projectId, name, available, createdAt, coverRef FROM studio_projects ORDER BY createdAt DESC, rowId ASC";
|
|
4
254
|
|
|
5
255
|
// packages/ui-system/dist/button.js
|
|
6
|
-
import { jsx as _jsx2, jsxs as
|
|
256
|
+
import { jsx as _jsx2, jsxs as _jsxs2 } from "react/jsx-runtime";
|
|
7
257
|
|
|
8
258
|
// packages/ui-system/dist/icon.js
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
259
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
260
|
var iconGeometry = {
|
|
11
261
|
add: {
|
|
12
262
|
width: 16,
|
|
@@ -73,6 +323,10 @@ var iconGeometry = {
|
|
|
73
323
|
height: 15.5625,
|
|
74
324
|
slot: 18
|
|
75
325
|
},
|
|
326
|
+
"select-items": { width: 13.8681, height: 13.8667, slot: 16 },
|
|
327
|
+
trim: { width: 14.85, height: 14.85, slot: 16 },
|
|
328
|
+
crop: { width: 16.25, height: 16.25, slot: 16 },
|
|
329
|
+
filter: { width: 13.2, height: 13.2, slot: 16 },
|
|
76
330
|
select: {
|
|
77
331
|
width: 14.6298,
|
|
78
332
|
height: 16.065,
|
|
@@ -128,6 +382,7 @@ var iconGeometry = {
|
|
|
128
382
|
height: 20,
|
|
129
383
|
slot: 20
|
|
130
384
|
},
|
|
385
|
+
"fullscreen-exit": { width: 20, height: 20, slot: 20 },
|
|
131
386
|
"placeholder-image": {
|
|
132
387
|
width: 20,
|
|
133
388
|
height: 20,
|
|
@@ -153,6 +408,9 @@ var iconGeometry = {
|
|
|
153
408
|
height: 13.2,
|
|
154
409
|
slot: 16
|
|
155
410
|
},
|
|
411
|
+
favorite: { width: 11.8667, height: 14.5333, slot: 16 },
|
|
412
|
+
download: { width: 13.2001, height: 13.1997, slot: 16 },
|
|
413
|
+
delete: { width: 13.2, height: 14.533, slot: 16 },
|
|
156
414
|
edit: {
|
|
157
415
|
width: 10.8791,
|
|
158
416
|
height: 12.0459,
|
|
@@ -194,7 +452,7 @@ var iconGeometry = {
|
|
|
194
452
|
slot: 24
|
|
195
453
|
}
|
|
196
454
|
};
|
|
197
|
-
function Icon({ name, size }) {
|
|
455
|
+
function Icon({ name, size, iconSet }) {
|
|
198
456
|
const geometry = iconGeometry[name];
|
|
199
457
|
const style = {
|
|
200
458
|
...geometry && {
|
|
@@ -204,7 +462,10 @@ function Icon({ name, size }) {
|
|
|
204
462
|
},
|
|
205
463
|
...size === void 0 ? {} : { "--vx-icon-size": `${size}px` }
|
|
206
464
|
};
|
|
207
|
-
|
|
465
|
+
if (name === "menu" || name === "relationships" || name === "color-adjust" || name === "speed") {
|
|
466
|
+
return _jsx("svg", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, "data-icon-set": iconSet === "chat" ? "chat" : void 0, style, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: name === "menu" ? _jsx("path", { d: "M3 5h14M3 10h14M3 15h14" }) : name === "color-adjust" ? _jsxs(_Fragment, { children: [_jsx("path", { d: "M3 5h3m4 0h7M3 10h8m4 0h2M3 15h3m4 0h7" }), _jsx("circle", { cx: "8", cy: "5", r: "2" }), _jsx("circle", { cx: "13", cy: "10", r: "2" }), _jsx("circle", { cx: "8", cy: "15", r: "2" })] }) : name === "speed" ? _jsxs(_Fragment, { children: [_jsx("path", { d: "M4 16a8 8 0 1 1 12 0M10 3v2M3 10h2m10 0h2M5 5l1.4 1.4M10 12l4-5" }), _jsx("circle", { cx: "10", cy: "12", r: "1.5" })] }) : _jsxs(_Fragment, { children: [_jsx("path", { d: "M8.5 6.3 5 11.7M11.5 6.3 15 11.7M6.5 14.5h7" }), _jsx("circle", { cx: "10", cy: "4", r: "2.5" }), _jsx("circle", { cx: "4", cy: "14.5", r: "2.5" }), _jsx("circle", { cx: "16", cy: "14.5", r: "2.5" })] }) });
|
|
467
|
+
}
|
|
468
|
+
return _jsx("span", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, "data-icon-set": iconSet === "chat" ? "chat" : void 0, style });
|
|
208
469
|
}
|
|
209
470
|
|
|
210
471
|
// packages/ui-system/dist/button-variants.js
|
|
@@ -213,6 +474,9 @@ var buttonVariants = {
|
|
|
213
474
|
"text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
|
|
214
475
|
"text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
|
|
215
476
|
"text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
|
|
477
|
+
"text-plain-sm": { size: 32, appearance: "plain", shape: "text" },
|
|
478
|
+
"text-link-sm": { size: 32, appearance: "link", shape: "text" },
|
|
479
|
+
"text-outline-sm": { size: 32, appearance: "outline", shape: "text" },
|
|
216
480
|
"text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
|
|
217
481
|
// The medium recipes are shared by all dialog footer actions.
|
|
218
482
|
"text-filled-md": { size: 40, appearance: "filled", shape: "text" },
|
|
@@ -233,7 +497,7 @@ var buttonVariants = {
|
|
|
233
497
|
"icon-outline-sm": { size: 32, appearance: "outline", shape: "icon" },
|
|
234
498
|
"icon-on-content": { size: 24, appearance: "on-content", shape: "icon" },
|
|
235
499
|
"icon-outline-lg": { size: 48, appearance: "outline", shape: "icon" },
|
|
236
|
-
// Compact bare action:
|
|
500
|
+
// Compact bare action: remain transparent at rest and on hover.
|
|
237
501
|
"icon-bare-xs": { size: 24, appearance: "ghost", shape: "icon" },
|
|
238
502
|
"icon-ghost-sm": { size: 32, appearance: "ghost", shape: "icon" },
|
|
239
503
|
"icon-ghost-lg": { size: 48, appearance: "ghost", shape: "icon" },
|
|
@@ -245,48 +509,74 @@ var buttonVariants = {
|
|
|
245
509
|
function ButtonFrame({ label, variant, loading = false, width, children, disabled, type = "button", style, className, ...props }) {
|
|
246
510
|
const spec = buttonVariants[variant];
|
|
247
511
|
const buttonStyle = "width" in spec ? { ...style, "--vx-button-width": `${spec.width}px` } : style;
|
|
248
|
-
return
|
|
512
|
+
return _jsxs2("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" })] });
|
|
249
513
|
}
|
|
250
|
-
function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, ...props }) {
|
|
251
|
-
return
|
|
514
|
+
function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, badge, ...props }) {
|
|
515
|
+
return _jsxs2(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 }) })] });
|
|
252
516
|
}
|
|
253
517
|
function IconButton({ icon, variant = "icon-ghost-sm", ...props }) {
|
|
254
518
|
return _jsx2(ButtonFrame, { ...props, variant, children: _jsx2(Icon, { name: icon }) });
|
|
255
519
|
}
|
|
256
520
|
|
|
521
|
+
// packages/ui-system/dist/cover-preview.js
|
|
522
|
+
import { jsx as _jsx3 } from "react/jsx-runtime";
|
|
523
|
+
import { useState } from "react";
|
|
524
|
+
function CoverPreview(props) {
|
|
525
|
+
return _jsx3(Preview, { ...props }, JSON.stringify([props.kind, props.src]));
|
|
526
|
+
}
|
|
527
|
+
function Preview({ className, ref, kind: kind2 = "image", src, pending, iconSize = 20, children }) {
|
|
528
|
+
const [mediaState, setMediaState] = useState("loading");
|
|
529
|
+
const media = src && (kind2 === "image" || kind2 === "video");
|
|
530
|
+
const state = pending ? "loading" : media ? mediaState : children ? "ready" : "empty";
|
|
531
|
+
const iconKind = kind2 === "video" || kind2 === "audio" ? kind2 : kind2 === "text" ? "script" : "image";
|
|
532
|
+
const ready = () => setMediaState("ready");
|
|
533
|
+
const failed = () => setMediaState("empty");
|
|
534
|
+
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 });
|
|
535
|
+
}
|
|
536
|
+
|
|
257
537
|
// packages/ui-system/dist/segmented-control.js
|
|
258
|
-
import { jsx as
|
|
538
|
+
import { jsx as _jsx4, jsxs as _jsxs3 } from "react/jsx-runtime";
|
|
259
539
|
import { useId } from "react";
|
|
260
540
|
function SegmentedControl({ label, items, value, onValueChange, size = "medium", width = "fixed", iconOnly = false }) {
|
|
261
541
|
const id = useId();
|
|
262
|
-
return
|
|
542
|
+
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) => _jsxs3("label", { title: iconOnly ? item.label : void 0, 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) }), _jsxs3("span", { className: "vx-segment-item", children: [item.icon && _jsx4(Icon, { name: item.icon }), (!iconOnly || !item.icon) && item.label] })] }, item.value)) });
|
|
263
543
|
}
|
|
264
544
|
|
|
265
545
|
// packages/ui-system/dist/input.js
|
|
266
|
-
import { jsx as
|
|
267
|
-
|
|
268
|
-
|
|
546
|
+
import { jsx as _jsx5, jsxs as _jsxs4 } from "react/jsx-runtime";
|
|
547
|
+
import { useEffect, useState as useState2 } from "react";
|
|
548
|
+
function TextInput({ label, value, onValueChange, size = "medium", appearance = "default", placeholder, ...props }) {
|
|
549
|
+
return _jsxs4("label", { className: "vx-field", "data-size": size, "data-appearance": appearance, children: [_jsx5("span", { children: label }), _jsx5("input", { ...props, type: "text", placeholder: placeholder ?? (props.readOnly ? void 0 : "Enter text"), value, onChange: (event) => onValueChange(event.currentTarget.value) })] });
|
|
269
550
|
}
|
|
270
551
|
|
|
271
552
|
// packages/ui-system/dist/dialog.js
|
|
272
|
-
import { jsx as
|
|
273
|
-
import { useId as useId2, useLayoutEffect, useRef, useState } from "react";
|
|
553
|
+
import { jsx as _jsx6, jsxs as _jsxs5, Fragment as _Fragment2 } from "react/jsx-runtime";
|
|
554
|
+
import { useId as useId2, useLayoutEffect, useRef, useState as useState3 } from "react";
|
|
274
555
|
import { createPortal } from "react-dom";
|
|
275
556
|
|
|
276
557
|
// packages/ui-system/dist/dialog-surface.js
|
|
277
|
-
|
|
558
|
+
var overlayOpeningEvent = "vx-overlay-opening";
|
|
559
|
+
function outerDialogDocument(anchor) {
|
|
278
560
|
const source = anchor.ownerDocument;
|
|
279
|
-
let target;
|
|
280
561
|
try {
|
|
281
|
-
target = source.defaultView?.top?.document
|
|
562
|
+
const target = source.defaultView?.top?.document;
|
|
563
|
+
return target && target !== source ? target : void 0;
|
|
282
564
|
} catch {
|
|
283
565
|
return void 0;
|
|
284
566
|
}
|
|
285
|
-
|
|
567
|
+
}
|
|
568
|
+
function createDialogSurface(anchor) {
|
|
569
|
+
const source = anchor.ownerDocument;
|
|
570
|
+
const target = outerDialogDocument(anchor);
|
|
571
|
+
if (!target)
|
|
286
572
|
return void 0;
|
|
287
573
|
const host = target.createElement("div");
|
|
288
574
|
host.dataset.studioDialogSurface = "";
|
|
289
575
|
const shadow = host.attachShadow({ mode: "open" });
|
|
576
|
+
shadow.addEventListener("beforetoggle", (event) => {
|
|
577
|
+
if (event.newState === "open" && !event.target.classList.contains("vx-toast"))
|
|
578
|
+
target.dispatchEvent(new Event(overlayOpeningEvent));
|
|
579
|
+
}, true);
|
|
290
580
|
for (const original of source.querySelectorAll('link[rel="stylesheet"], style')) {
|
|
291
581
|
const clone = original.cloneNode(true);
|
|
292
582
|
if (original.tagName === "LINK")
|
|
@@ -322,13 +612,13 @@ function createDialogSurface(anchor) {
|
|
|
322
612
|
}
|
|
323
613
|
|
|
324
614
|
// packages/ui-system/dist/dialog.js
|
|
325
|
-
function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default" }) {
|
|
615
|
+
function Dialog({ title, titleBadge, open, onOpenChange, children, actions, className, inlineWhenClosed = false, variant = "default", closeOnEscape = true, focusTitleOnOpen = variant === "welcome" }) {
|
|
326
616
|
const ref = useRef(null);
|
|
327
617
|
const anchor = useRef(null);
|
|
328
|
-
const [surface, setSurface] =
|
|
618
|
+
const [surface, setSurface] = useState3();
|
|
329
619
|
const heading = useId2();
|
|
330
620
|
useLayoutEffect(() => {
|
|
331
|
-
if (!open || !anchor.current)
|
|
621
|
+
if (inlineWhenClosed || !open || !anchor.current)
|
|
332
622
|
return;
|
|
333
623
|
const mounted = createDialogSurface(anchor.current);
|
|
334
624
|
const active = anchor.current.getRootNode().activeElement;
|
|
@@ -341,9 +631,20 @@ function Dialog({ title, open, onOpenChange, children, actions, className, varia
|
|
|
341
631
|
active.focus();
|
|
342
632
|
});
|
|
343
633
|
};
|
|
344
|
-
}, [open]);
|
|
634
|
+
}, [open, inlineWhenClosed]);
|
|
345
635
|
useLayoutEffect(() => {
|
|
346
636
|
const dialog2 = ref.current;
|
|
637
|
+
if (inlineWhenClosed && dialog2) {
|
|
638
|
+
if (open) {
|
|
639
|
+
dialog2.close();
|
|
640
|
+
dialog2.showModal();
|
|
641
|
+
} else {
|
|
642
|
+
if (dialog2.matches(":modal"))
|
|
643
|
+
dialog2.close();
|
|
644
|
+
dialog2.open = true;
|
|
645
|
+
}
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
347
648
|
if (!open || surface === void 0 || !dialog2)
|
|
348
649
|
return;
|
|
349
650
|
dialog2.showModal();
|
|
@@ -351,42 +652,24 @@ function Dialog({ title, open, onOpenChange, children, actions, className, varia
|
|
|
351
652
|
if (dialog2.open)
|
|
352
653
|
dialog2.close();
|
|
353
654
|
};
|
|
354
|
-
}, [open, surface]);
|
|
355
|
-
const
|
|
655
|
+
}, [open, surface, inlineWhenClosed]);
|
|
656
|
+
const welcome = variant === "welcome";
|
|
657
|
+
const closeButton = _jsx6(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) });
|
|
658
|
+
const dialog = _jsxs5("dialog", { ref, open: inlineWhenClosed || void 0, className: inlineWhenClosed && !open ? "vx-dialog vx-dialog-inline" : className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, role: inlineWhenClosed && !open ? "presentation" : void 0, "aria-labelledby": inlineWhenClosed && !open ? void 0 : heading, onCancel: (event) => {
|
|
356
659
|
event.preventDefault();
|
|
357
660
|
event.stopPropagation();
|
|
358
|
-
|
|
661
|
+
if (closeOnEscape)
|
|
662
|
+
onOpenChange(false);
|
|
359
663
|
}, onClose: (event) => {
|
|
360
664
|
if (open && event.currentTarget.isConnected && !event.currentTarget.open)
|
|
361
665
|
onOpenChange(false);
|
|
362
|
-
}, children: [
|
|
363
|
-
return
|
|
666
|
+
}, children: [_jsxs5("header", { hidden: inlineWhenClosed && !open, children: [_jsx6("h2", { id: heading, tabIndex: focusTitleOnOpen ? -1 : void 0, autoFocus: focusTitleOnOpen, children: title }), titleBadge, !welcome && closeButton] }), _jsx6("div", { className: "vx-dialog-body", children }), (actions || welcome) && _jsxs5("footer", { hidden: inlineWhenClosed && !open, children: [actions, welcome && closeButton] })] });
|
|
667
|
+
return _jsxs5(_Fragment2, { children: [_jsx6("span", { ref: anchor, hidden: true }), (open || inlineWhenClosed) && (surface ? createPortal(dialog, surface) : dialog)] });
|
|
364
668
|
}
|
|
365
669
|
|
|
366
|
-
// packages/dashboard-projects/src/
|
|
670
|
+
// packages/dashboard-projects/src/create-project-dialog.tsx
|
|
671
|
+
import * as React from "react";
|
|
367
672
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
368
|
-
var Config = z.object({ studioInstance: z.string().min(1).nullable().default(null) });
|
|
369
|
-
var dependencies = (config) => config.studioInstance ? [config.studioInstance] : [];
|
|
370
|
-
var projectsSql = "SELECT * FROM studio_projects ORDER BY createdAt DESC, rowId ASC";
|
|
371
|
-
function decodeRef(value) {
|
|
372
|
-
let item = value;
|
|
373
|
-
if (typeof item === "string") {
|
|
374
|
-
try {
|
|
375
|
-
item = JSON.parse(item);
|
|
376
|
-
} catch {
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) return null;
|
|
381
|
-
const ref = item;
|
|
382
|
-
return ["storeId", "objectId", "versionId"].every(
|
|
383
|
-
(key) => typeof ref[key] === "string" && /^[0-9a-f-]{36}$/i.test(ref[key])
|
|
384
|
-
) ? {
|
|
385
|
-
storeId: ref.storeId,
|
|
386
|
-
objectId: ref.objectId,
|
|
387
|
-
versionId: ref.versionId
|
|
388
|
-
} : null;
|
|
389
|
-
}
|
|
390
673
|
var projectTypes = [
|
|
391
674
|
{
|
|
392
675
|
value: "short-drama",
|
|
@@ -396,6 +679,16 @@ var projectTypes = [
|
|
|
396
679
|
{ value: "ads", label: "Product Ad", preset: "@vivix-labs/ads-workbench:ads" },
|
|
397
680
|
{ value: "table", label: "Others", preset: "@vivix-labs/studio-workbench:table" }
|
|
398
681
|
];
|
|
682
|
+
function formatErrorMessage(error) {
|
|
683
|
+
if (!(error instanceof Error)) return String(error);
|
|
684
|
+
const hint = "hint" in error && typeof error.hint === "string" ? error.hint.trim() : "";
|
|
685
|
+
const message = error.message.trim();
|
|
686
|
+
const detail = hint || message;
|
|
687
|
+
const code = "code" in error && typeof error.code === "string" ? error.code : "";
|
|
688
|
+
if (code === "INSTANCE_UNAVAILABLE" && detail && !detail.includes("vivix-studio"))
|
|
689
|
+
return `${detail} Check with: vivix-studio plugin list --scope user --json`;
|
|
690
|
+
return detail;
|
|
691
|
+
}
|
|
399
692
|
function NewProjectDialog({
|
|
400
693
|
client,
|
|
401
694
|
close,
|
|
@@ -418,7 +711,7 @@ function NewProjectDialog({
|
|
|
418
711
|
if (active) setPresets(items);
|
|
419
712
|
},
|
|
420
713
|
(error) => {
|
|
421
|
-
if (active) setStatus(error
|
|
714
|
+
if (active) setStatus(formatErrorMessage(error));
|
|
422
715
|
}
|
|
423
716
|
);
|
|
424
717
|
return () => {
|
|
@@ -428,9 +721,11 @@ function NewProjectDialog({
|
|
|
428
721
|
const selection = projectTypes.find((item) => item.value === type);
|
|
429
722
|
const placeholder = type === "table" ? "Untitled Project" : "Untitled " + selection.label;
|
|
430
723
|
const [packageName, presetId] = selection.preset.split(":");
|
|
431
|
-
const preset =
|
|
432
|
-
(
|
|
433
|
-
|
|
724
|
+
const preset = [packageName, packageName.replace("@vivix-labs/", "@vivix-studio/")].flatMap(
|
|
725
|
+
(name2) => presets?.filter(
|
|
726
|
+
(item) => item.spec.startsWith(name2 + "@") && item.spec.endsWith(":" + presetId)
|
|
727
|
+
) ?? []
|
|
728
|
+
)[0];
|
|
434
729
|
async function create() {
|
|
435
730
|
if (!preset || !client.projects?.create || busy) return;
|
|
436
731
|
const input = {
|
|
@@ -448,7 +743,7 @@ function NewProjectDialog({
|
|
|
448
743
|
onCreated(project);
|
|
449
744
|
close();
|
|
450
745
|
} catch (error) {
|
|
451
|
-
setStatus(
|
|
746
|
+
setStatus(formatErrorMessage(error));
|
|
452
747
|
} finally {
|
|
453
748
|
setBusy(false);
|
|
454
749
|
}
|
|
@@ -520,108 +815,186 @@ function NewProjectDialog({
|
|
|
520
815
|
}
|
|
521
816
|
);
|
|
522
817
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
818
|
+
|
|
819
|
+
// packages/dashboard-projects/src/client.tsx
|
|
820
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
821
|
+
var Config = z5.object({ studioInstance: z5.string().min(1).nullable().default(null) });
|
|
822
|
+
var dependencies = (config) => config.studioInstance ? [config.studioInstance] : [];
|
|
823
|
+
function decodeRef(value) {
|
|
824
|
+
let item = value;
|
|
825
|
+
if (typeof item === "string") {
|
|
826
|
+
try {
|
|
827
|
+
item = JSON.parse(item);
|
|
828
|
+
} catch {
|
|
829
|
+
return null;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return null;
|
|
833
|
+
const ref = item;
|
|
834
|
+
return ["storeId", "objectId", "versionId"].every(
|
|
835
|
+
(key) => typeof ref[key] === "string" && /^[0-9a-f-]{36}$/i.test(ref[key])
|
|
836
|
+
) ? {
|
|
837
|
+
storeId: ref.storeId,
|
|
838
|
+
objectId: ref.objectId,
|
|
839
|
+
versionId: ref.versionId
|
|
840
|
+
} : null;
|
|
527
841
|
}
|
|
842
|
+
var projectPreviews = /* @__PURE__ */ new WeakMap();
|
|
843
|
+
function ProjectCover({
|
|
844
|
+
client,
|
|
845
|
+
row,
|
|
846
|
+
pending
|
|
847
|
+
}) {
|
|
848
|
+
const ref = decodeRef(row?.available ? row.previewRef ?? row.coverRef : void 0);
|
|
849
|
+
const instanceId = client.config.studioInstance;
|
|
850
|
+
const key = ref && JSON.stringify([instanceId, ref.storeId, ref.objectId, ref.versionId]);
|
|
851
|
+
const cached = key ? projectPreviews.get(client)?.get(key) : void 0;
|
|
852
|
+
const [resolved, setResolved] = React2.useState();
|
|
853
|
+
React2.useEffect(() => {
|
|
854
|
+
if (!ref || !instanceId || !key || cached) return;
|
|
855
|
+
let active = true;
|
|
856
|
+
void client.invoke({ instanceId, operationId: "global.asset" }, { ref }).then(
|
|
857
|
+
({ item }) => {
|
|
858
|
+
if (!active) return;
|
|
859
|
+
if (item.previewUrl) {
|
|
860
|
+
const previews = projectPreviews.get(client) ?? /* @__PURE__ */ new Map();
|
|
861
|
+
previews.set(key, item);
|
|
862
|
+
if (previews.size > 64) previews.delete(previews.keys().next().value);
|
|
863
|
+
projectPreviews.set(client, previews);
|
|
864
|
+
}
|
|
865
|
+
setResolved(item);
|
|
866
|
+
},
|
|
867
|
+
() => {
|
|
868
|
+
if (active) setResolved(null);
|
|
869
|
+
}
|
|
870
|
+
);
|
|
871
|
+
return () => {
|
|
872
|
+
active = false;
|
|
873
|
+
};
|
|
874
|
+
}, [client, instanceId, key, cached]);
|
|
875
|
+
const preview = cached ?? resolved;
|
|
876
|
+
const src = preview?.previewUrl ?? row?.previewUrl;
|
|
877
|
+
return /* @__PURE__ */ jsx2(
|
|
878
|
+
CoverPreview,
|
|
879
|
+
{
|
|
880
|
+
className: "studio-home-cover",
|
|
881
|
+
src: typeof src === "string" ? src : void 0,
|
|
882
|
+
kind: String(preview?.kind ?? row?.previewKind ?? "image"),
|
|
883
|
+
pending: pending || Boolean(instanceId && ref && preview === void 0)
|
|
884
|
+
}
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
var previousProjects = /* @__PURE__ */ new WeakMap();
|
|
528
888
|
function ProjectsCard({
|
|
529
889
|
client,
|
|
530
890
|
projects,
|
|
891
|
+
hiddenProjectIds,
|
|
892
|
+
projectCovers,
|
|
531
893
|
ready,
|
|
532
894
|
openProject,
|
|
533
895
|
openProjects,
|
|
534
896
|
onProjectCreated
|
|
535
897
|
}) {
|
|
536
|
-
const [
|
|
537
|
-
const [creating, setCreating] =
|
|
898
|
+
const [result, setResult] = React2.useState(() => previousProjects.get(client));
|
|
899
|
+
const [creating, setCreating] = React2.useState(false);
|
|
900
|
+
const grid = React2.useRef(null);
|
|
901
|
+
const [columns, setColumns] = React2.useState(1);
|
|
902
|
+
React2.useLayoutEffect(() => {
|
|
903
|
+
const element = grid.current;
|
|
904
|
+
if (!element) return;
|
|
905
|
+
const measure = () => setColumns(getComputedStyle(element).gridTemplateColumns.split(" ").length);
|
|
906
|
+
measure();
|
|
907
|
+
const observer = new ResizeObserver(measure);
|
|
908
|
+
observer.observe(element);
|
|
909
|
+
return () => observer.disconnect();
|
|
910
|
+
}, []);
|
|
538
911
|
const catalogKey = JSON.stringify(projects);
|
|
539
|
-
|
|
540
|
-
|
|
912
|
+
const hiddenKey = JSON.stringify(hiddenProjectIds ?? []);
|
|
913
|
+
const resultKey = JSON.stringify([catalogKey, hiddenKey]);
|
|
914
|
+
React2.useEffect(() => {
|
|
915
|
+
const instanceId = client.config.studioInstance;
|
|
916
|
+
if (!ready || !instanceId) return;
|
|
541
917
|
let active = true;
|
|
542
|
-
|
|
543
|
-
{ instanceId
|
|
918
|
+
const loadProjects = (countColumn) => client.invoke(
|
|
919
|
+
{ instanceId, operationId: "global.query" },
|
|
544
920
|
{
|
|
545
921
|
source: "projects",
|
|
546
|
-
sql:
|
|
922
|
+
sql: projectListSql.replace("SELECT ", `SELECT ${countColumn} AS cardAssetCount, `),
|
|
547
923
|
params: [],
|
|
548
924
|
catalog: JSON.parse(catalogKey),
|
|
925
|
+
...hiddenKey !== "[]" && { excludeProjectIds: JSON.parse(hiddenKey) },
|
|
549
926
|
limit: 5,
|
|
550
927
|
timeoutMs: 8e3,
|
|
551
928
|
offset: 0
|
|
552
929
|
}
|
|
553
|
-
)
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const { item } = await client.invoke(
|
|
561
|
-
{ instanceId: client.config.studioInstance, operationId: "global.asset" },
|
|
562
|
-
{ ref }
|
|
563
|
-
);
|
|
564
|
-
return {
|
|
565
|
-
...row,
|
|
566
|
-
previewUrl: item.previewUrl ?? null,
|
|
567
|
-
previewKind: item.kind ?? null
|
|
568
|
-
};
|
|
569
|
-
} catch {
|
|
570
|
-
return row;
|
|
571
|
-
}
|
|
572
|
-
})
|
|
573
|
-
);
|
|
574
|
-
if (active) setRows(next);
|
|
930
|
+
);
|
|
931
|
+
void loadProjects("savedAssetCount").catch(() => loadProjects("assetCount")).then(
|
|
932
|
+
({ items }) => {
|
|
933
|
+
if (!active) return;
|
|
934
|
+
const result2 = { catalogKey: resultKey, rows: items };
|
|
935
|
+
previousProjects.set(client, result2);
|
|
936
|
+
setResult(result2);
|
|
575
937
|
},
|
|
576
938
|
() => {
|
|
577
|
-
if (active)
|
|
939
|
+
if (!active) return;
|
|
940
|
+
previousProjects.delete(client);
|
|
941
|
+
setResult({ catalogKey: resultKey, rows: [] });
|
|
578
942
|
}
|
|
579
943
|
);
|
|
580
944
|
return () => {
|
|
581
945
|
active = false;
|
|
582
946
|
};
|
|
583
|
-
}, [client, ready, catalogKey]);
|
|
584
|
-
const
|
|
947
|
+
}, [client, ready, catalogKey, hiddenKey]);
|
|
948
|
+
const current = resultKey === result?.catalogKey ? result : void 0;
|
|
949
|
+
const pending = Boolean(client.config.studioInstance) && (!ready || !current);
|
|
950
|
+
const list = current?.rows ?? [];
|
|
585
951
|
const entries = (list.length ? list.map((row) => projects.find(({ id }) => id === row.projectId)).filter((entry) => !!entry) : projects.slice(0, 5)).map((project) => {
|
|
586
952
|
const row = list.find((entry) => entry.projectId === project.id);
|
|
953
|
+
const cover = projectCovers?.get(project.id);
|
|
954
|
+
const previewRow = {
|
|
955
|
+
...row,
|
|
956
|
+
available: project.available,
|
|
957
|
+
coverRef: cover ? { ...cover } : row?.coverRef ?? null
|
|
958
|
+
};
|
|
587
959
|
return {
|
|
588
960
|
key: project.id,
|
|
589
|
-
row,
|
|
961
|
+
row: previewRow,
|
|
590
962
|
name: String(row?.name ?? project.name),
|
|
591
|
-
note: row?.
|
|
963
|
+
note: typeof row?.cardAssetCount === "number" ? `${row.cardAssetCount} ${row.cardAssetCount === 1 ? "asset" : "assets"}` : "",
|
|
592
964
|
enabled: project.available,
|
|
593
965
|
open: () => openProject(project.id)
|
|
594
966
|
};
|
|
595
967
|
});
|
|
596
|
-
return /* @__PURE__ */
|
|
597
|
-
/* @__PURE__ */
|
|
598
|
-
/* @__PURE__ */
|
|
599
|
-
/* @__PURE__ */
|
|
968
|
+
return /* @__PURE__ */ jsxs2("section", { className: "studio-home-panel", "aria-label": "Project List", children: [
|
|
969
|
+
/* @__PURE__ */ jsxs2("header", { children: [
|
|
970
|
+
/* @__PURE__ */ jsx2("h2", { children: "Project List" }),
|
|
971
|
+
/* @__PURE__ */ jsx2(
|
|
600
972
|
Button,
|
|
601
973
|
{
|
|
602
|
-
label: "View all",
|
|
974
|
+
label: ready ? `View all ${projects.length}` : "View all",
|
|
603
975
|
"aria-label": "View all project list",
|
|
604
|
-
|
|
605
|
-
variant: "text-tonal-sm",
|
|
976
|
+
variant: "text-link-sm",
|
|
606
977
|
onClick: openProjects
|
|
607
978
|
}
|
|
608
979
|
)
|
|
609
980
|
] }),
|
|
610
|
-
/* @__PURE__ */
|
|
611
|
-
/* @__PURE__ */
|
|
981
|
+
/* @__PURE__ */ jsxs2("div", { className: "studio-home-grid", ref: grid, children: [
|
|
982
|
+
/* @__PURE__ */ jsxs2(
|
|
612
983
|
"button",
|
|
613
984
|
{
|
|
614
985
|
type: "button",
|
|
615
986
|
className: "studio-home-tile studio-home-create",
|
|
616
987
|
onClick: () => setCreating(true),
|
|
617
988
|
children: [
|
|
618
|
-
/* @__PURE__ */
|
|
619
|
-
/* @__PURE__ */
|
|
620
|
-
|
|
989
|
+
/* @__PURE__ */ jsx2("span", { className: "studio-home-cover", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(Icon, { name: "add" }) }) }),
|
|
990
|
+
/* @__PURE__ */ jsxs2("span", { className: "studio-home-caption", children: [
|
|
991
|
+
/* @__PURE__ */ jsx2("strong", { children: "Create Project" }),
|
|
992
|
+
/* @__PURE__ */ jsx2("small", { children: "Create a local project" })
|
|
993
|
+
] })
|
|
621
994
|
]
|
|
622
995
|
}
|
|
623
996
|
),
|
|
624
|
-
entries.map(({ key, row, name, note, enabled, open }) => /* @__PURE__ */
|
|
997
|
+
entries.slice(0, columns - 1).map(({ key, row, name, note, enabled, open }) => /* @__PURE__ */ jsxs2(
|
|
625
998
|
"button",
|
|
626
999
|
{
|
|
627
1000
|
type: "button",
|
|
@@ -629,15 +1002,29 @@ function ProjectsCard({
|
|
|
629
1002
|
onClick: open,
|
|
630
1003
|
disabled: !enabled,
|
|
631
1004
|
children: [
|
|
632
|
-
/* @__PURE__ */
|
|
633
|
-
|
|
634
|
-
|
|
1005
|
+
/* @__PURE__ */ jsx2(
|
|
1006
|
+
ProjectCover,
|
|
1007
|
+
{
|
|
1008
|
+
client,
|
|
1009
|
+
row,
|
|
1010
|
+
pending: enabled && pending
|
|
1011
|
+
},
|
|
1012
|
+
JSON.stringify([
|
|
1013
|
+
client.config.studioInstance,
|
|
1014
|
+
row?.available,
|
|
1015
|
+
row?.previewRef ?? row?.coverRef
|
|
1016
|
+
])
|
|
1017
|
+
),
|
|
1018
|
+
/* @__PURE__ */ jsxs2("span", { className: "studio-home-caption", children: [
|
|
1019
|
+
/* @__PURE__ */ jsx2("strong", { title: name, children: name }),
|
|
1020
|
+
note && /* @__PURE__ */ jsx2("small", { children: note })
|
|
1021
|
+
] })
|
|
635
1022
|
]
|
|
636
1023
|
},
|
|
637
1024
|
key
|
|
638
1025
|
))
|
|
639
1026
|
] }),
|
|
640
|
-
creating && /* @__PURE__ */
|
|
1027
|
+
creating && /* @__PURE__ */ jsx2(
|
|
641
1028
|
NewProjectDialog,
|
|
642
1029
|
{
|
|
643
1030
|
client,
|
|
@@ -655,7 +1042,35 @@ function activate(client) {
|
|
|
655
1042
|
id: "projects",
|
|
656
1043
|
title: "Project List",
|
|
657
1044
|
kind: "component",
|
|
658
|
-
component: (props) => /* @__PURE__ */
|
|
1045
|
+
component: (props) => /* @__PURE__ */ jsx2(ProjectsCard, { ...props, client })
|
|
1046
|
+
});
|
|
1047
|
+
client.registerUI({
|
|
1048
|
+
id: "create-project",
|
|
1049
|
+
title: "Create Project",
|
|
1050
|
+
kind: "component",
|
|
1051
|
+
component: function ProjectCreator(props) {
|
|
1052
|
+
const [open, setOpen] = React2.useState(false);
|
|
1053
|
+
if ("close" in props) return /* @__PURE__ */ jsx2(NewProjectDialog, { client, ...props });
|
|
1054
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
1055
|
+
/* @__PURE__ */ jsx2(
|
|
1056
|
+
Button,
|
|
1057
|
+
{
|
|
1058
|
+
label: "Create Project",
|
|
1059
|
+
variant: "text-filled-sm",
|
|
1060
|
+
width: "hug",
|
|
1061
|
+
onClick: () => setOpen(true)
|
|
1062
|
+
}
|
|
1063
|
+
),
|
|
1064
|
+
open && /* @__PURE__ */ jsx2(
|
|
1065
|
+
NewProjectDialog,
|
|
1066
|
+
{
|
|
1067
|
+
client,
|
|
1068
|
+
close: () => setOpen(false),
|
|
1069
|
+
onCreated: (project) => props.onProjectCreated?.(project)
|
|
1070
|
+
}
|
|
1071
|
+
)
|
|
1072
|
+
] });
|
|
1073
|
+
}
|
|
659
1074
|
});
|
|
660
1075
|
}
|
|
661
1076
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vivix-labs/dashboard-projects",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.21",
|
|
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
|
+
}
|