camox 0.9.0 → 0.10.0

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.
Files changed (43) hide show
  1. package/dist/core/components/lexical/SidebarLexicalEditor.js +2 -1
  2. package/dist/core/createApp.d.ts +231 -209
  3. package/dist/core/createApp.js +17 -17
  4. package/dist/core/createBlock.d.ts +74 -72
  5. package/dist/core/createBlock.js +274 -267
  6. package/dist/core/createLayout.d.ts +100 -80
  7. package/dist/core/createLayout.js +93 -65
  8. package/dist/features/preview/CamoxPreview.js +76 -54
  9. package/dist/features/preview/components/AddBlockSheet.js +12 -12
  10. package/dist/features/preview/components/AssetFieldEditor.js +1 -1
  11. package/dist/features/preview/components/AssetLightbox.js +1 -1
  12. package/dist/features/preview/components/AssetPickerGrid.js +1 -1
  13. package/dist/features/preview/components/BlockActionsPopover.js +26 -26
  14. package/dist/features/preview/components/BlockErrorBoundary.js +59 -0
  15. package/dist/features/preview/components/{CreatePageSheet.js → CreatePageModal.js} +16 -18
  16. package/dist/features/preview/components/{EditPageSheet.js → EditPageModal.js} +32 -25
  17. package/dist/features/preview/components/Frame.js +1 -1
  18. package/dist/features/preview/components/ItemFieldsEditor.js +134 -98
  19. package/dist/features/preview/components/LinkFieldEditor.js +166 -146
  20. package/dist/features/preview/components/PageContentSheet.js +42 -37
  21. package/dist/features/preview/components/PageLocationFieldset.js +28 -26
  22. package/dist/features/preview/components/PagePicker.js +15 -8
  23. package/dist/features/preview/components/PageTree.js +337 -351
  24. package/dist/features/preview/components/PeekedBlock.js +38 -26
  25. package/dist/features/preview/components/PreviewPanel.js +16 -2
  26. package/dist/features/preview/components/PreviewSideSheet.js +26 -42
  27. package/dist/features/preview/components/RepeatableItemsList.js +7 -7
  28. package/dist/features/preview/previewStore.js +7 -7
  29. package/dist/features/provider/CamoxProvider.js +41 -9
  30. package/dist/features/routes/ogRoute.js +2 -2
  31. package/dist/features/routes/pageRoute.js +1 -1
  32. package/dist/features/studio/components/EnvironmentMenu.js +2 -2
  33. package/dist/features/studio/components/UserButton.js +49 -34
  34. package/dist/features/vite/blockBoilerplate.js +2 -1
  35. package/dist/features/vite/definitionsSync.js +53 -22
  36. package/dist/features/vite/routeGeneration.js +1 -0
  37. package/dist/features/vite/vite.js +51 -7
  38. package/dist/lib/auth.js +6 -4
  39. package/dist/lib/use-project-room.js +25 -13
  40. package/dist/studio-overlays.css +34 -0
  41. package/dist/studio.css +1 -1
  42. package/package.json +4 -4
  43. package/skills/camox-layout/SKILL.md +34 -30
@@ -72,7 +72,7 @@ function ExternalStateSync(t0) {
72
72
  React.useEffect(t3, t4);
73
73
  return null;
74
74
  }
75
- function SidebarLexicalEditor({ value, onChange, onFocus, onBlur }) {
75
+ function SidebarLexicalEditor({ id, value, onChange, onFocus, onBlur }) {
76
76
  const timerRef = React.useRef(null);
77
77
  const onChangeRef = React.useRef(onChange);
78
78
  onChangeRef.current = onChange;
@@ -98,6 +98,7 @@ function SidebarLexicalEditor({ value, onChange, onFocus, onBlur }) {
98
98
  children: [
99
99
  /* @__PURE__ */ jsx(RichTextPlugin, {
100
100
  contentEditable: /* @__PURE__ */ jsx(ContentEditable, {
101
+ id,
101
102
  className: cn(INPUT_BASE_STYLES, INPUT_FOCUS_STYLES, "flex min-h-[80px] w-full px-3 py-2"),
102
103
  onFocus,
103
104
  onBlur
@@ -15,16 +15,6 @@ declare function createApp({
15
15
  layouts
16
16
  }: CreateAppOptions): {
17
17
  getBlocks(): {
18
- Component: ({
19
- blockData,
20
- mode,
21
- isFirstBlock,
22
- showAddBlockTop,
23
- showAddBlockBottom,
24
- addBlockAfterPosition
25
- }: BlockComponentProps<{
26
- [x: string]: unknown;
27
- }>) => _$react_jsx_runtime0.JSX.Element;
28
18
  Detached: ({
29
19
  children
30
20
  }: {
@@ -286,65 +276,67 @@ declare function createApp({
286
276
  }, index: number) => React.ReactNode;
287
277
  }) => _$react_jsx_runtime0.JSX.Element;
288
278
  useSetting: <K extends string>(name: K) => unknown;
289
- id: string;
290
- title: string;
291
- description: string;
292
- contentSchema: {
293
- type: "object";
279
+ _internal: {
280
+ Component: ({
281
+ blockData,
282
+ mode,
283
+ isFirstBlock,
284
+ showAddBlockTop,
285
+ showAddBlockBottom,
286
+ addBlockAfterPosition
287
+ }: BlockComponentProps<{
288
+ [x: string]: unknown;
289
+ }>) => _$react_jsx_runtime0.JSX.Element;
290
+ id: string;
294
291
  title: string;
295
292
  description: string;
296
- properties: Record<string, _$_sinclair_typebox0.TSchema>;
297
- required: string[];
298
- toMarkdown: readonly string[];
299
- };
300
- settingsSchema: {
301
- type: "object";
302
- properties: Record<string, _$_sinclair_typebox0.TSchema>;
303
- required: string[];
304
- } | undefined;
305
- getInitialBundle: () => {
306
- content: Record<string, unknown>;
307
- settings: {
308
- [x: string]: unknown;
293
+ contentSchema: {
294
+ type: "object";
295
+ title: string;
296
+ description: string;
297
+ properties: Record<string, _$_sinclair_typebox0.TSchema>;
298
+ required: string[];
299
+ toMarkdown: readonly string[];
309
300
  };
310
- repeatableItems: RepeatableItemSeed[];
311
- };
312
- getInitialContent: () => {
313
- [x: string]: unknown;
314
- };
315
- getInitialSettings: () => {
316
- [x: string]: unknown;
317
- };
318
- getPeekBundle: () => {
319
- block: {
320
- id: number;
321
- pageId: null;
322
- layoutId: null;
323
- type: string;
301
+ settingsSchema: {
302
+ type: "object";
303
+ properties: Record<string, _$_sinclair_typebox0.TSchema>;
304
+ required: string[];
305
+ } | undefined;
306
+ layoutOnly: boolean;
307
+ getInitialBundle: () => {
324
308
  content: Record<string, unknown>;
325
- settings: Record<string, unknown>;
326
- placement: null;
327
- summary: string;
328
- position: string;
329
- createdAt: number;
330
- updatedAt: number;
309
+ settings: {
310
+ [x: string]: unknown;
311
+ };
312
+ repeatableItems: RepeatableItemSeed[];
313
+ };
314
+ getInitialContent: () => {
315
+ [x: string]: unknown;
316
+ };
317
+ getInitialSettings: () => {
318
+ [x: string]: unknown;
319
+ };
320
+ getPeekBundle: () => {
321
+ block: {
322
+ id: number;
323
+ pageId: null;
324
+ layoutId: null;
325
+ type: string;
326
+ content: Record<string, unknown>;
327
+ settings: Record<string, unknown>;
328
+ placement: null;
329
+ summary: string;
330
+ position: string;
331
+ createdAt: number;
332
+ updatedAt: number;
333
+ };
334
+ repeatableItems: PeekItem[];
335
+ files: never[];
331
336
  };
332
- repeatableItems: PeekItem[];
333
- files: never[];
334
337
  };
335
- layoutOnly: boolean;
336
338
  }[];
337
339
  getBlockById(id: string): {
338
- Component: ({
339
- blockData,
340
- mode,
341
- isFirstBlock,
342
- showAddBlockTop,
343
- showAddBlockBottom,
344
- addBlockAfterPosition
345
- }: BlockComponentProps<{
346
- [x: string]: unknown;
347
- }>) => _$react_jsx_runtime0.JSX.Element;
348
340
  Detached: ({
349
341
  children
350
342
  }: {
@@ -606,171 +598,201 @@ declare function createApp({
606
598
  }, index: number) => React.ReactNode;
607
599
  }) => _$react_jsx_runtime0.JSX.Element;
608
600
  useSetting: <K extends string>(name: K) => unknown;
609
- id: string;
610
- title: string;
611
- description: string;
612
- contentSchema: {
613
- type: "object";
601
+ _internal: {
602
+ Component: ({
603
+ blockData,
604
+ mode,
605
+ isFirstBlock,
606
+ showAddBlockTop,
607
+ showAddBlockBottom,
608
+ addBlockAfterPosition
609
+ }: BlockComponentProps<{
610
+ [x: string]: unknown;
611
+ }>) => _$react_jsx_runtime0.JSX.Element;
612
+ id: string;
614
613
  title: string;
615
614
  description: string;
616
- properties: Record<string, _$_sinclair_typebox0.TSchema>;
617
- required: string[];
618
- toMarkdown: readonly string[];
619
- };
620
- settingsSchema: {
621
- type: "object";
622
- properties: Record<string, _$_sinclair_typebox0.TSchema>;
623
- required: string[];
624
- } | undefined;
625
- getInitialBundle: () => {
626
- content: Record<string, unknown>;
627
- settings: {
615
+ contentSchema: {
616
+ type: "object";
617
+ title: string;
618
+ description: string;
619
+ properties: Record<string, _$_sinclair_typebox0.TSchema>;
620
+ required: string[];
621
+ toMarkdown: readonly string[];
622
+ };
623
+ settingsSchema: {
624
+ type: "object";
625
+ properties: Record<string, _$_sinclair_typebox0.TSchema>;
626
+ required: string[];
627
+ } | undefined;
628
+ layoutOnly: boolean;
629
+ getInitialBundle: () => {
630
+ content: Record<string, unknown>;
631
+ settings: {
632
+ [x: string]: unknown;
633
+ };
634
+ repeatableItems: RepeatableItemSeed[];
635
+ };
636
+ getInitialContent: () => {
628
637
  [x: string]: unknown;
629
638
  };
630
- repeatableItems: RepeatableItemSeed[];
639
+ getInitialSettings: () => {
640
+ [x: string]: unknown;
641
+ };
642
+ getPeekBundle: () => {
643
+ block: {
644
+ id: number;
645
+ pageId: null;
646
+ layoutId: null;
647
+ type: string;
648
+ content: Record<string, unknown>;
649
+ settings: Record<string, unknown>;
650
+ placement: null;
651
+ summary: string;
652
+ position: string;
653
+ createdAt: number;
654
+ updatedAt: number;
655
+ };
656
+ repeatableItems: PeekItem[];
657
+ files: never[];
658
+ };
631
659
  };
632
- getInitialContent: () => {
633
- [x: string]: unknown;
660
+ } | undefined;
661
+ getLayouts(): {
662
+ BeforeBlocks: {
663
+ (): _$react_jsx_runtime0.JSX.Element;
664
+ displayName: string;
634
665
  };
635
- getInitialSettings: () => {
636
- [x: string]: unknown;
666
+ AfterBlocks: {
667
+ (): _$react_jsx_runtime0.JSX.Element;
668
+ displayName: string;
637
669
  };
638
- getPeekBundle: () => {
639
- block: {
640
- id: number;
641
- pageId: null;
642
- layoutId: null;
670
+ _internal: {
671
+ id: string;
672
+ title: string;
673
+ description: string;
674
+ buildMetaTitle: (params: {
675
+ pageMetaTitle: string;
676
+ projectName: string;
677
+ pageFullPath: string;
678
+ }) => string;
679
+ buildOgImage: ((params: OgImageParams) => Promise<Response>) | undefined;
680
+ blockDefinitions: ({
643
681
  type: string;
644
682
  content: Record<string, unknown>;
645
683
  settings: Record<string, unknown>;
646
- placement: null;
647
- summary: string;
648
- position: string;
649
- createdAt: number;
650
- updatedAt: number;
651
- };
652
- repeatableItems: PeekItem[];
653
- files: never[];
654
- };
655
- layoutOnly: boolean;
656
- } | undefined;
657
- getLayouts(): {
658
- id: string;
659
- title: string;
660
- description: string;
661
- buildMetaTitle: (params: {
662
- pageMetaTitle: string;
663
- projectName: string;
664
- pageFullPath: string;
665
- }) => string;
666
- buildOgImage: ((params: OgImageParams) => Promise<Response>) | undefined;
667
- blockDefinitions: ({
668
- type: string;
669
- content: Record<string, unknown>;
670
- settings: Record<string, unknown>;
671
- repeatableItems: {
672
- tempId: string;
673
- parentTempId: string | null;
674
- fieldName: string;
675
- content: Record<string, unknown>;
676
- position: string;
677
- }[];
678
- placement: "before";
679
- } | {
680
- type: string;
681
- content: Record<string, unknown>;
682
- settings: Record<string, unknown>;
683
- repeatableItems: {
684
- tempId: string;
685
- parentTempId: string | null;
686
- fieldName: string;
684
+ repeatableItems: {
685
+ tempId: string;
686
+ parentTempId: string | null;
687
+ fieldName: string;
688
+ content: Record<string, unknown>;
689
+ position: string;
690
+ }[];
691
+ placement: "before";
692
+ } | {
693
+ type: string;
687
694
  content: Record<string, unknown>;
688
- position: string;
689
- }[];
690
- placement: "after";
691
- })[];
692
- initialBlockBundles: {
693
- type: string;
694
- content: Record<string, unknown>;
695
- settings: Record<string, unknown>;
696
- repeatableItems: {
697
- tempId: string;
698
- parentTempId: string | null;
699
- fieldName: string;
695
+ settings: Record<string, unknown>;
696
+ repeatableItems: {
697
+ tempId: string;
698
+ parentTempId: string | null;
699
+ fieldName: string;
700
+ content: Record<string, unknown>;
701
+ position: string;
702
+ }[];
703
+ placement: "after";
704
+ })[];
705
+ initialBlockBundles: {
706
+ type: string;
700
707
  content: Record<string, unknown>;
701
- position: string;
702
- }[];
703
- }[] | undefined;
704
- component: _$react.ComponentType<{
705
- children: React.ReactNode;
706
- }>;
707
- Provider: ({
708
- layoutBlocks,
709
- children
710
- }: {
711
- layoutBlocks: Record<string, LayoutBlockData>;
712
- children: React.ReactNode;
713
- }) => _$react_jsx_runtime0.JSX.Element;
714
- blocks: Record<string, React.ComponentType>;
708
+ settings: Record<string, unknown>;
709
+ repeatableItems: {
710
+ tempId: string;
711
+ parentTempId: string | null;
712
+ fieldName: string;
713
+ content: Record<string, unknown>;
714
+ position: string;
715
+ }[];
716
+ }[] | undefined;
717
+ component: _$react.ComponentType<{
718
+ children: React.ReactNode;
719
+ }>;
720
+ Provider: ({
721
+ layoutBlocks,
722
+ children
723
+ }: {
724
+ layoutBlocks: Record<string, LayoutBlockData>;
725
+ children: React.ReactNode;
726
+ }) => _$react_jsx_runtime0.JSX.Element;
727
+ };
715
728
  }[];
716
729
  getLayoutById(id: string): {
717
- id: string;
718
- title: string;
719
- description: string;
720
- buildMetaTitle: (params: {
721
- pageMetaTitle: string;
722
- projectName: string;
723
- pageFullPath: string;
724
- }) => string;
725
- buildOgImage: ((params: OgImageParams) => Promise<Response>) | undefined;
726
- blockDefinitions: ({
727
- type: string;
728
- content: Record<string, unknown>;
729
- settings: Record<string, unknown>;
730
- repeatableItems: {
731
- tempId: string;
732
- parentTempId: string | null;
733
- fieldName: string;
730
+ BeforeBlocks: {
731
+ (): _$react_jsx_runtime0.JSX.Element;
732
+ displayName: string;
733
+ };
734
+ AfterBlocks: {
735
+ (): _$react_jsx_runtime0.JSX.Element;
736
+ displayName: string;
737
+ };
738
+ _internal: {
739
+ id: string;
740
+ title: string;
741
+ description: string;
742
+ buildMetaTitle: (params: {
743
+ pageMetaTitle: string;
744
+ projectName: string;
745
+ pageFullPath: string;
746
+ }) => string;
747
+ buildOgImage: ((params: OgImageParams) => Promise<Response>) | undefined;
748
+ blockDefinitions: ({
749
+ type: string;
734
750
  content: Record<string, unknown>;
735
- position: string;
736
- }[];
737
- placement: "before";
738
- } | {
739
- type: string;
740
- content: Record<string, unknown>;
741
- settings: Record<string, unknown>;
742
- repeatableItems: {
743
- tempId: string;
744
- parentTempId: string | null;
745
- fieldName: string;
751
+ settings: Record<string, unknown>;
752
+ repeatableItems: {
753
+ tempId: string;
754
+ parentTempId: string | null;
755
+ fieldName: string;
756
+ content: Record<string, unknown>;
757
+ position: string;
758
+ }[];
759
+ placement: "before";
760
+ } | {
761
+ type: string;
746
762
  content: Record<string, unknown>;
747
- position: string;
748
- }[];
749
- placement: "after";
750
- })[];
751
- initialBlockBundles: {
752
- type: string;
753
- content: Record<string, unknown>;
754
- settings: Record<string, unknown>;
755
- repeatableItems: {
756
- tempId: string;
757
- parentTempId: string | null;
758
- fieldName: string;
763
+ settings: Record<string, unknown>;
764
+ repeatableItems: {
765
+ tempId: string;
766
+ parentTempId: string | null;
767
+ fieldName: string;
768
+ content: Record<string, unknown>;
769
+ position: string;
770
+ }[];
771
+ placement: "after";
772
+ })[];
773
+ initialBlockBundles: {
774
+ type: string;
759
775
  content: Record<string, unknown>;
760
- position: string;
761
- }[];
762
- }[] | undefined;
763
- component: _$react.ComponentType<{
764
- children: React.ReactNode;
765
- }>;
766
- Provider: ({
767
- layoutBlocks,
768
- children
769
- }: {
770
- layoutBlocks: Record<string, LayoutBlockData>;
771
- children: React.ReactNode;
772
- }) => _$react_jsx_runtime0.JSX.Element;
773
- blocks: Record<string, React.ComponentType>;
776
+ settings: Record<string, unknown>;
777
+ repeatableItems: {
778
+ tempId: string;
779
+ parentTempId: string | null;
780
+ fieldName: string;
781
+ content: Record<string, unknown>;
782
+ position: string;
783
+ }[];
784
+ }[] | undefined;
785
+ component: _$react.ComponentType<{
786
+ children: React.ReactNode;
787
+ }>;
788
+ Provider: ({
789
+ layoutBlocks,
790
+ children
791
+ }: {
792
+ layoutBlocks: Record<string, LayoutBlockData>;
793
+ children: React.ReactNode;
794
+ }) => _$react_jsx_runtime0.JSX.Element;
795
+ };
774
796
  } | undefined;
775
797
  getSerializableDefinitions(): {
776
798
  blockId: string;
@@ -2,12 +2,12 @@
2
2
  function createApp({ blocks, layouts = [] }) {
3
3
  const blocksMap = /* @__PURE__ */ new Map();
4
4
  const layoutsMap = /* @__PURE__ */ new Map();
5
- for (const block of blocks) blocksMap.set(block.id, block);
6
- for (const layout of layouts) layoutsMap.set(layout.id, layout);
7
- const layoutsWithInitialBlocks = layouts.filter((l) => l.initialBlockBundles);
5
+ for (const block of blocks) blocksMap.set(block._internal.id, block);
6
+ for (const layout of layouts) layoutsMap.set(layout._internal.id, layout);
7
+ const layoutsWithInitialBlocks = layouts.filter((l) => l._internal.initialBlockBundles);
8
8
  if (layoutsWithInitialBlocks.length > 1) {
9
- const ids = layoutsWithInitialBlocks.map((l) => `"${l.id}"`).join(", ");
10
- throw new Error(`[camox] Only one layout can define initialBlocks, but found ${layoutsWithInitialBlocks.length}: ${ids}`);
9
+ const ids = layoutsWithInitialBlocks.map((l) => `"${l._internal.id}"`).join(", ");
10
+ throw new Error(`[camox] Only one layout can define blocks.initial, but found ${layoutsWithInitialBlocks.length}: ${ids}`);
11
11
  }
12
12
  return {
13
13
  getBlocks() {
@@ -24,32 +24,32 @@ function createApp({ blocks, layouts = [] }) {
24
24
  },
25
25
  getSerializableDefinitions() {
26
26
  return Array.from(blocksMap.values()).map((block) => ({
27
- blockId: block.id,
28
- title: block.title,
29
- description: block.description,
30
- contentSchema: block.contentSchema,
31
- settingsSchema: block.settingsSchema,
32
- layoutOnly: block.layoutOnly || void 0
27
+ blockId: block._internal.id,
28
+ title: block._internal.title,
29
+ description: block._internal.description,
30
+ contentSchema: block._internal.contentSchema,
31
+ settingsSchema: block._internal.settingsSchema,
32
+ layoutOnly: block._internal.layoutOnly || void 0
33
33
  }));
34
34
  },
35
35
  getSerializableLayoutDefinitions() {
36
36
  return Array.from(layoutsMap.values()).map((layout) => ({
37
- layoutId: layout.id,
38
- description: layout.description,
39
- blocks: layout.blockDefinitions
37
+ layoutId: layout._internal.id,
38
+ description: layout._internal.description,
39
+ blocks: layout._internal.blockDefinitions
40
40
  }));
41
41
  },
42
42
  getInitialPageBundles() {
43
43
  const layout = layoutsWithInitialBlocks[0];
44
44
  if (layout) return {
45
- layoutId: layout.id,
46
- blocks: layout.initialBlockBundles,
45
+ layoutId: layout._internal.id,
46
+ blocks: layout._internal.initialBlockBundles,
47
47
  hasInitialBlocks: true
48
48
  };
49
49
  const fallback = layouts[0];
50
50
  if (!fallback) return null;
51
51
  return {
52
- layoutId: fallback.id,
52
+ layoutId: fallback._internal.id,
53
53
  blocks: [],
54
54
  hasInitialBlocks: false
55
55
  };