camox 0.57.0 → 0.58.1
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/core/createBlock.js +6 -2
- package/dist/core/lib/artifact.d.ts +14 -4
- package/dist/core/lib/artifact.js +57 -16
- package/dist/core/lib/artifactRuntime.js +4 -2
- package/dist/features/runtime/artifactDocuments.js +58 -0
- package/dist/features/runtime/artifactSources.js +36 -2
- package/dist/features/runtime/runtime.js +30 -12
- package/dist/features/runtime/runtimeRoutes.d.ts +6 -5
- package/dist/features/runtime/runtimeRoutes.js +12 -5
- package/dist/features/studio/components/DraftsControl.js +60 -134
- package/dist/features/studio/components/ReviewDraftSheet.js +52 -4
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/dist/features/studio/components/RenameDraftDialog.js +0 -206
|
@@ -6,14 +6,13 @@ import { reads, useReadQuery } from "../../../lib/studio-reads.js";
|
|
|
6
6
|
import { cn } from "../../../lib/utils.js";
|
|
7
7
|
import { studioStore } from "../studioStore.js";
|
|
8
8
|
import { draftLabel, plural, timeAgo } from "../draftLabel.js";
|
|
9
|
-
import { RenameDraftDialog } from "./RenameDraftDialog.js";
|
|
10
9
|
import { DeleteDraftDialog, ReviewDraftSheet, useLeaveDraft } from "./ReviewDraftSheet.js";
|
|
11
10
|
import { c } from "react/compiler-runtime";
|
|
12
11
|
import * as React from "react";
|
|
13
12
|
import { useSelector } from "@xstate/store-react";
|
|
14
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
14
|
import { Button } from "@camox/ui/button";
|
|
16
|
-
import { ChevronsUpDown
|
|
15
|
+
import { ChevronsUpDown } from "lucide-react";
|
|
17
16
|
import { toast } from "@camox/ui/toaster";
|
|
18
17
|
import { Badge } from "@camox/ui/badge";
|
|
19
18
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@camox/ui/dropdown-menu";
|
|
@@ -103,7 +102,7 @@ function useDrafts() {
|
|
|
103
102
|
* still names what the studio is viewing.
|
|
104
103
|
*/
|
|
105
104
|
function DraftPicker(t0) {
|
|
106
|
-
const $ = c(
|
|
105
|
+
const $ = c(52);
|
|
107
106
|
const { disabled: t1 } = t0;
|
|
108
107
|
const disabled = t1 === void 0 ? false : t1;
|
|
109
108
|
const { draftScope, draftId, developmentMode, projectId, list, current } = useDrafts();
|
|
@@ -111,8 +110,6 @@ function DraftPicker(t0) {
|
|
|
111
110
|
const leaveDraft = useLeaveDraft();
|
|
112
111
|
const review = useSelector(studioStore, _temp);
|
|
113
112
|
const deleting = useSelector(studioStore, _temp2);
|
|
114
|
-
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
115
|
-
const [renaming, setRenaming] = React.useState(null);
|
|
116
113
|
let t2;
|
|
117
114
|
let t3;
|
|
118
115
|
if ($[0] !== draftScope) {
|
|
@@ -273,13 +270,7 @@ function DraftPicker(t0) {
|
|
|
273
270
|
})]
|
|
274
271
|
})
|
|
275
272
|
}),
|
|
276
|
-
regular.map(
|
|
277
|
-
draft: listed_0,
|
|
278
|
-
onRename: () => {
|
|
279
|
-
setMenuOpen(false);
|
|
280
|
-
setRenaming(listed_0);
|
|
281
|
-
}
|
|
282
|
-
}, listed_0.id))
|
|
273
|
+
regular.map(_temp7)
|
|
283
274
|
] })
|
|
284
275
|
})] })
|
|
285
276
|
});
|
|
@@ -291,70 +282,50 @@ function DraftPicker(t0) {
|
|
|
291
282
|
$[39] = t18;
|
|
292
283
|
} else t18 = $[39];
|
|
293
284
|
let t19;
|
|
294
|
-
if ($[40] !==
|
|
295
|
-
t19 = /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
$[40] = menuOpen;
|
|
301
|
-
$[41] = t17;
|
|
302
|
-
$[42] = t18;
|
|
303
|
-
$[43] = t19;
|
|
304
|
-
} else t19 = $[43];
|
|
285
|
+
if ($[40] !== t17 || $[41] !== t18) {
|
|
286
|
+
t19 = /* @__PURE__ */ jsxs(DropdownMenu, { children: [t17, t18] });
|
|
287
|
+
$[40] = t17;
|
|
288
|
+
$[41] = t18;
|
|
289
|
+
$[42] = t19;
|
|
290
|
+
} else t19 = $[42];
|
|
305
291
|
let t20;
|
|
306
|
-
if ($[44] !==
|
|
307
|
-
t20 = projectId && /* @__PURE__ */ jsx(
|
|
308
|
-
projectId,
|
|
309
|
-
draft: renaming,
|
|
310
|
-
onOpenChange: (open) => {
|
|
311
|
-
if (!open) setRenaming(null);
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
$[44] = projectId;
|
|
315
|
-
$[45] = renaming;
|
|
316
|
-
$[46] = t20;
|
|
317
|
-
} else t20 = $[46];
|
|
318
|
-
let t21;
|
|
319
|
-
if ($[47] !== deleting || $[48] !== draftId || $[49] !== leaveDraft || $[50] !== projectId || $[51] !== review) {
|
|
320
|
-
t21 = draftId && projectId && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ReviewDraftSheet, {
|
|
292
|
+
if ($[43] !== deleting || $[44] !== draftId || $[45] !== leaveDraft || $[46] !== projectId || $[47] !== review) {
|
|
293
|
+
t20 = draftId && projectId && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ReviewDraftSheet, {
|
|
321
294
|
projectId,
|
|
322
295
|
draftId,
|
|
323
296
|
open: review.open,
|
|
324
297
|
startRenaming: review.startRenaming,
|
|
325
|
-
onOpenChange:
|
|
298
|
+
onOpenChange: _temp8
|
|
326
299
|
}), /* @__PURE__ */ jsx(DeleteDraftDialog, {
|
|
327
300
|
projectId,
|
|
328
301
|
open: deleting,
|
|
329
|
-
onOpenChange:
|
|
302
|
+
onOpenChange: _temp9,
|
|
330
303
|
onDeleted: leaveDraft
|
|
331
304
|
})] });
|
|
332
|
-
$[
|
|
333
|
-
$[
|
|
334
|
-
$[
|
|
335
|
-
$[
|
|
336
|
-
$[
|
|
337
|
-
$[
|
|
338
|
-
} else
|
|
339
|
-
let
|
|
340
|
-
if ($[
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
} else t22 = $[56];
|
|
351
|
-
return t22;
|
|
305
|
+
$[43] = deleting;
|
|
306
|
+
$[44] = draftId;
|
|
307
|
+
$[45] = leaveDraft;
|
|
308
|
+
$[46] = projectId;
|
|
309
|
+
$[47] = review;
|
|
310
|
+
$[48] = t20;
|
|
311
|
+
} else t20 = $[48];
|
|
312
|
+
let t21;
|
|
313
|
+
if ($[49] !== t19 || $[50] !== t20) {
|
|
314
|
+
t21 = /* @__PURE__ */ jsxs(Fragment, { children: [t19, t20] });
|
|
315
|
+
$[49] = t19;
|
|
316
|
+
$[50] = t20;
|
|
317
|
+
$[51] = t21;
|
|
318
|
+
} else t21 = $[51];
|
|
319
|
+
return t21;
|
|
320
|
+
}
|
|
321
|
+
function _temp9(open_0) {
|
|
322
|
+
if (!open_0) studioStore.send({ type: "closeDeleteDraftDialog" });
|
|
352
323
|
}
|
|
353
|
-
function _temp8(
|
|
354
|
-
if (!
|
|
324
|
+
function _temp8(open) {
|
|
325
|
+
if (!open) studioStore.send({ type: "closeReviewDraftSheet" });
|
|
355
326
|
}
|
|
356
|
-
function _temp7(
|
|
357
|
-
|
|
327
|
+
function _temp7(listed_0) {
|
|
328
|
+
return /* @__PURE__ */ jsx(DraftItem, { draft: listed_0 }, listed_0.id);
|
|
358
329
|
}
|
|
359
330
|
function _temp6(listed) {
|
|
360
331
|
return listed.kind === "regular";
|
|
@@ -405,7 +376,7 @@ function PendingChanges() {
|
|
|
405
376
|
t3 = /* @__PURE__ */ jsxs(Button, {
|
|
406
377
|
type: "button",
|
|
407
378
|
"aria-label": t1,
|
|
408
|
-
onClick:
|
|
379
|
+
onClick: _temp10,
|
|
409
380
|
children: ["Review changes", t2]
|
|
410
381
|
});
|
|
411
382
|
$[4] = t1;
|
|
@@ -414,7 +385,7 @@ function PendingChanges() {
|
|
|
414
385
|
} else t3 = $[6];
|
|
415
386
|
return t3;
|
|
416
387
|
}
|
|
417
|
-
function
|
|
388
|
+
function _temp10() {
|
|
418
389
|
return studioStore.send({ type: "openReviewDraftSheet" });
|
|
419
390
|
}
|
|
420
391
|
/**
|
|
@@ -443,7 +414,7 @@ function useDraftsActions(t0) {
|
|
|
443
414
|
],
|
|
444
415
|
groupLabel: "Drafts",
|
|
445
416
|
checkIfAvailable: () => inDraft,
|
|
446
|
-
execute:
|
|
417
|
+
execute: _temp11
|
|
447
418
|
},
|
|
448
419
|
{
|
|
449
420
|
id: "delete-draft",
|
|
@@ -455,7 +426,7 @@ function useDraftsActions(t0) {
|
|
|
455
426
|
],
|
|
456
427
|
groupLabel: "Drafts",
|
|
457
428
|
checkIfAvailable: () => inDraft,
|
|
458
|
-
execute:
|
|
429
|
+
execute: _temp12
|
|
459
430
|
},
|
|
460
431
|
{
|
|
461
432
|
id: "rename-draft",
|
|
@@ -463,7 +434,7 @@ function useDraftsActions(t0) {
|
|
|
463
434
|
aliases: ["Name draft"],
|
|
464
435
|
groupLabel: "Drafts",
|
|
465
436
|
checkIfAvailable: () => inDraft && !developmentMode,
|
|
466
|
-
execute:
|
|
437
|
+
execute: _temp13
|
|
467
438
|
},
|
|
468
439
|
{
|
|
469
440
|
id: "switch-to-live",
|
|
@@ -489,7 +460,7 @@ function useDraftsActions(t0) {
|
|
|
489
460
|
groupLabel: "Drafts",
|
|
490
461
|
checkIfAvailable: () => others.length > 0,
|
|
491
462
|
hasChildren: true,
|
|
492
|
-
execute:
|
|
463
|
+
execute: _temp14
|
|
493
464
|
},
|
|
494
465
|
...others.map((other) => ({
|
|
495
466
|
id: `${SWITCH_TO_DRAFT_ID}-${other.id}`,
|
|
@@ -497,7 +468,7 @@ function useDraftsActions(t0) {
|
|
|
497
468
|
label: `Switch to "${draftLabel(other)}"`,
|
|
498
469
|
aliases: [other.createdBy.name],
|
|
499
470
|
groupLabel: "Drafts",
|
|
500
|
-
checkIfAvailable:
|
|
471
|
+
checkIfAvailable: _temp15,
|
|
501
472
|
execute: () => switchTo(other.id)
|
|
502
473
|
}))
|
|
503
474
|
];
|
|
@@ -508,7 +479,7 @@ function useDraftsActions(t0) {
|
|
|
508
479
|
return () => {
|
|
509
480
|
actionsStore.send({
|
|
510
481
|
type: "unregisterManyActions",
|
|
511
|
-
ids: actions.map(
|
|
482
|
+
ids: actions.map(_temp16)
|
|
512
483
|
});
|
|
513
484
|
};
|
|
514
485
|
};
|
|
@@ -532,23 +503,23 @@ function useDraftsActions(t0) {
|
|
|
532
503
|
}
|
|
533
504
|
React.useEffect(t1, t2);
|
|
534
505
|
}
|
|
535
|
-
function
|
|
506
|
+
function _temp16(a) {
|
|
536
507
|
return a.id;
|
|
537
508
|
}
|
|
538
|
-
function
|
|
509
|
+
function _temp15() {
|
|
539
510
|
return true;
|
|
540
511
|
}
|
|
541
|
-
function
|
|
542
|
-
function
|
|
512
|
+
function _temp14() {}
|
|
513
|
+
function _temp13() {
|
|
543
514
|
return studioStore.send({
|
|
544
515
|
type: "openReviewDraftSheet",
|
|
545
516
|
startRenaming: true
|
|
546
517
|
});
|
|
547
518
|
}
|
|
548
|
-
function
|
|
519
|
+
function _temp12() {
|
|
549
520
|
return studioStore.send({ type: "openDeleteDraftDialog" });
|
|
550
521
|
}
|
|
551
|
-
function
|
|
522
|
+
function _temp11() {
|
|
552
523
|
return studioStore.send({ type: "openReviewDraftSheet" });
|
|
553
524
|
}
|
|
554
525
|
/** Who published Live last and when: a member, a release, or nobody yet. */
|
|
@@ -557,11 +528,10 @@ function liveLine(live) {
|
|
|
557
528
|
const by = live.publishedBy ? live.publishedBy.name : "a release";
|
|
558
529
|
return `Published ${timeAgo(live.publishedAt)} by ${by}`;
|
|
559
530
|
}
|
|
560
|
-
/** A draft to switch to
|
|
531
|
+
/** A draft to switch to. */
|
|
561
532
|
function DraftItem(t0) {
|
|
562
|
-
const $ = c(
|
|
563
|
-
const { draft
|
|
564
|
-
const keep = _temp16;
|
|
533
|
+
const $ = c(18);
|
|
534
|
+
const { draft } = t0;
|
|
565
535
|
const t1 = draft.id;
|
|
566
536
|
let t2;
|
|
567
537
|
if ($[0] !== draft) {
|
|
@@ -620,61 +590,17 @@ function DraftItem(t0) {
|
|
|
620
590
|
$[14] = t8;
|
|
621
591
|
} else t8 = $[14];
|
|
622
592
|
let t9;
|
|
623
|
-
if ($[15] !== draft) {
|
|
624
|
-
t9 =
|
|
625
|
-
$[15] = draft;
|
|
626
|
-
$[16] = t9;
|
|
627
|
-
} else t9 = $[16];
|
|
628
|
-
const t10 = `Rename "${t9}"`;
|
|
629
|
-
let t11;
|
|
630
|
-
if ($[17] !== onRename) {
|
|
631
|
-
t11 = (event_0) => {
|
|
632
|
-
keep(event_0);
|
|
633
|
-
onRename();
|
|
634
|
-
};
|
|
635
|
-
$[17] = onRename;
|
|
636
|
-
$[18] = t11;
|
|
637
|
-
} else t11 = $[18];
|
|
638
|
-
let t12;
|
|
639
|
-
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
640
|
-
t12 = /* @__PURE__ */ jsx(Pencil, {});
|
|
641
|
-
$[19] = t12;
|
|
642
|
-
} else t12 = $[19];
|
|
643
|
-
let t13;
|
|
644
|
-
if ($[20] !== t10 || $[21] !== t11) {
|
|
645
|
-
t13 = /* @__PURE__ */ jsx(Button, {
|
|
646
|
-
type: "button",
|
|
647
|
-
variant: "ghost",
|
|
648
|
-
size: "icon-xs",
|
|
649
|
-
"aria-label": t10,
|
|
650
|
-
className: "opacity-0 group-data-highlighted/draft-item:opacity-100 focus-visible:opacity-100",
|
|
651
|
-
onPointerDown: keep,
|
|
652
|
-
onPointerUp: keep,
|
|
653
|
-
onMouseUp: keep,
|
|
654
|
-
onClick: t11,
|
|
655
|
-
children: t12
|
|
656
|
-
});
|
|
657
|
-
$[20] = t10;
|
|
658
|
-
$[21] = t11;
|
|
659
|
-
$[22] = t13;
|
|
660
|
-
} else t13 = $[22];
|
|
661
|
-
let t14;
|
|
662
|
-
if ($[23] !== draft.id || $[24] !== t13 || $[25] !== t8) {
|
|
663
|
-
t14 = /* @__PURE__ */ jsxs(DropdownMenuRadioItem, {
|
|
593
|
+
if ($[15] !== draft.id || $[16] !== t8) {
|
|
594
|
+
t9 = /* @__PURE__ */ jsx(DropdownMenuRadioItem, {
|
|
664
595
|
value: t1,
|
|
665
596
|
closeOnClick: true,
|
|
666
|
-
|
|
667
|
-
children: [t8, t13]
|
|
597
|
+
children: t8
|
|
668
598
|
});
|
|
669
|
-
$[
|
|
670
|
-
$[
|
|
671
|
-
$[
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
return t14;
|
|
675
|
-
}
|
|
676
|
-
function _temp16(event) {
|
|
677
|
-
return event.stopPropagation();
|
|
599
|
+
$[15] = draft.id;
|
|
600
|
+
$[16] = t8;
|
|
601
|
+
$[17] = t9;
|
|
602
|
+
} else t9 = $[17];
|
|
603
|
+
return t9;
|
|
678
604
|
}
|
|
679
605
|
|
|
680
606
|
//#endregion
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { getDraftReadClient } from "../../../lib/api-client.js";
|
|
1
2
|
import { useDraftScope } from "../../../lib/draft-scope.js";
|
|
2
|
-
import { reads, useReadQuery } from "../../../lib/studio-reads.js";
|
|
3
|
+
import { reads, useReadQuery, useStudioCache } from "../../../lib/studio-reads.js";
|
|
3
4
|
import { cn } from "../../../lib/utils.js";
|
|
4
5
|
import { draftMutations } from "../../../lib/queries.js";
|
|
5
6
|
import { previewStore } from "../../preview/previewStore.js";
|
|
6
7
|
import { localeLabel } from "../localeOptions.js";
|
|
7
8
|
import { draftLabel, plural, timeAgo } from "../draftLabel.js";
|
|
8
|
-
import { useRenameDraft } from "./RenameDraftDialog.js";
|
|
9
9
|
import { useShowInCanvas } from "../showInCanvas.js";
|
|
10
10
|
import { c } from "react/compiler-runtime";
|
|
11
11
|
import * as React from "react";
|
|
@@ -981,6 +981,54 @@ function useLeaveDraft() {
|
|
|
981
981
|
return t0;
|
|
982
982
|
}
|
|
983
983
|
/**
|
|
984
|
+
* Renames a regular draft, whichever draft the studio views: the request names the draft it
|
|
985
|
+
* renames. A blank name clears it, so the draft shows its computed label again.
|
|
986
|
+
*/
|
|
987
|
+
function useRenameDraft(projectId) {
|
|
988
|
+
const $ = c(8);
|
|
989
|
+
const studioCache = useStudioCache();
|
|
990
|
+
let t0;
|
|
991
|
+
if ($[0] !== projectId) {
|
|
992
|
+
t0 = (t1) => {
|
|
993
|
+
const { draftId, name } = t1;
|
|
994
|
+
return getDraftReadClient(draftId).drafts.rename({
|
|
995
|
+
projectId,
|
|
996
|
+
name
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
$[0] = projectId;
|
|
1000
|
+
$[1] = t0;
|
|
1001
|
+
} else t0 = $[1];
|
|
1002
|
+
let t1;
|
|
1003
|
+
if ($[2] !== projectId || $[3] !== studioCache) {
|
|
1004
|
+
t1 = (renamed) => {
|
|
1005
|
+
studioCache.set(reads.draft({
|
|
1006
|
+
projectId,
|
|
1007
|
+
draftId: renamed.id
|
|
1008
|
+
}), renamed);
|
|
1009
|
+
studioCache.invalidate(reads.draftList({ projectId }));
|
|
1010
|
+
};
|
|
1011
|
+
$[2] = projectId;
|
|
1012
|
+
$[3] = studioCache;
|
|
1013
|
+
$[4] = t1;
|
|
1014
|
+
} else t1 = $[4];
|
|
1015
|
+
let t2;
|
|
1016
|
+
if ($[5] !== t0 || $[6] !== t1) {
|
|
1017
|
+
t2 = {
|
|
1018
|
+
mutationFn: t0,
|
|
1019
|
+
onSuccess: t1,
|
|
1020
|
+
onError: _temp10
|
|
1021
|
+
};
|
|
1022
|
+
$[5] = t0;
|
|
1023
|
+
$[6] = t1;
|
|
1024
|
+
$[7] = t2;
|
|
1025
|
+
} else t2 = $[7];
|
|
1026
|
+
return useMutation(t2);
|
|
1027
|
+
}
|
|
1028
|
+
function _temp10(error) {
|
|
1029
|
+
return toast.error(error.message || "Could not rename the draft");
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
984
1032
|
* The draft's name in the review's header, renamed in place by any member (#203), like a page
|
|
985
1033
|
* nickname in the Canvas Inspector: a title whose border shows on hover or focus, without
|
|
986
1034
|
* moving the text. An unnamed draft shows its computed label until focused. Saves on Enter or
|
|
@@ -1545,7 +1593,7 @@ function DeleteDraftDialog(t0) {
|
|
|
1545
1593
|
onOpenChange(false);
|
|
1546
1594
|
onDeleted(ended);
|
|
1547
1595
|
},
|
|
1548
|
-
onError:
|
|
1596
|
+
onError: _temp11
|
|
1549
1597
|
};
|
|
1550
1598
|
$[1] = onDeleted;
|
|
1551
1599
|
$[2] = onOpenChange;
|
|
@@ -1624,7 +1672,7 @@ function DeleteDraftDialog(t0) {
|
|
|
1624
1672
|
} else t10 = $[25];
|
|
1625
1673
|
return t10;
|
|
1626
1674
|
}
|
|
1627
|
-
function
|
|
1675
|
+
function _temp11(error) {
|
|
1628
1676
|
return toast.error(error.message || "Could not delete the draft");
|
|
1629
1677
|
}
|
|
1630
1678
|
|
package/dist/package.js
CHANGED