camox 0.78.0 → 0.80.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.
- package/dist/core/lib/artifact.d.ts +26 -1
- package/dist/core/lib/artifactData.d.ts +5 -1
- package/dist/core/lib/artifactHost.d.ts +43 -0
- package/dist/features/brand/BrandPart.js +116 -0
- package/dist/features/brand/CamoxBrand.js +758 -0
- package/dist/features/brand/VoiceGroup.js +443 -0
- package/dist/features/preview/EditablePageExperience.js +2 -2
- package/dist/features/runtime/artifactReplay.d.ts +3 -0
- package/dist/features/runtime/artifactReplay.js +4 -0
- package/dist/features/runtime/runtime.d.ts +1 -1
- package/dist/features/runtime/runtime.js +4 -4
- package/dist/features/studio/components/DraftReview.js +55 -32
- package/dist/features/studio/components/Navbar.js +9 -7
- package/dist/features/studio/routes.js +3 -3
- package/dist/features/vite/vite.js +1 -0
- package/dist/lib/queries.js +10 -6
- package/dist/lib/studio-reads.d.ts +1 -0
- package/dist/lib/studio-reads.js +6 -0
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +8 -4
- package/dist/features/memory/CamoxMemory.js +0 -747
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../defineDocument.js";
|
|
2
|
-
import "./artifactData.js";
|
|
2
|
+
import { ArtifactData } from "./artifactData.js";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import "@camox/api-contract";
|
|
5
5
|
//#region src/core/lib/artifact.d.ts
|
|
@@ -20,6 +20,16 @@ export type ArtifactFrameProps = InlineArtifactFrameProps | (ArtifactFrameAttrib
|
|
|
20
20
|
src: string;
|
|
21
21
|
srcDoc?: never;
|
|
22
22
|
});
|
|
23
|
+
/**
|
|
24
|
+
* What a public page holds in place of an artifact source: the URL the website serves its
|
|
25
|
+
* document at, named by its shell and source hashes, and its title. Frames load it by URL, so
|
|
26
|
+
* neither the page's HTML nor its hydration data carries the source, and the client renders the
|
|
27
|
+
* same frames as the server.
|
|
28
|
+
*/
|
|
29
|
+
export type ArtifactSourceReference = {
|
|
30
|
+
artifactUrl: string;
|
|
31
|
+
title: string;
|
|
32
|
+
};
|
|
23
33
|
/** What `block.Artifact` passes to its render prop, to spread onto an `<iframe>`. */
|
|
24
34
|
export type ArtifactRenderProps = ArtifactFrameProps & {
|
|
25
35
|
/** Connects the frame to the `camox` runtime inside it. */
|
|
@@ -31,5 +41,20 @@ export type ArtifactRenderProps = ArtifactFrameProps & {
|
|
|
31
41
|
/** The id of the Repeatable Item holding the artifact field, when an item's. */
|
|
32
42
|
"data-camox-item"?: string;
|
|
33
43
|
};
|
|
44
|
+
/** What an artifact's document gets from the website besides its source. */
|
|
45
|
+
export type ArtifactDocumentOptions = {
|
|
46
|
+
/** The website's font links as HTML, from `artifactFontLinks`. */
|
|
47
|
+
fontLinks?: string;
|
|
48
|
+
/** The initial Artifact Data, which the runtime exposes as `camox.data`. */
|
|
49
|
+
data?: ArtifactData;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The frame props for an artifact, with its initial Artifact Data and the website's font links.
|
|
53
|
+
* This getter is the boundary that hides how the source reaches the frame, so blocks never
|
|
54
|
+
* depend on it: a source is inlined with `srcdoc`, while a reference to one loads by URL, its
|
|
55
|
+
* initial Artifact Data in the URL's fragment.
|
|
56
|
+
*/
|
|
57
|
+
export declare function artifactFrameProps(source: string, options?: ArtifactDocumentOptions): InlineArtifactFrameProps;
|
|
58
|
+
export declare function artifactFrameProps(artifact: string | ArtifactSourceReference, options?: ArtifactDocumentOptions): ArtifactFrameProps;
|
|
34
59
|
//#endregion
|
|
35
60
|
export {};
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import { TSchema } from "@sinclair/typebox";
|
|
1
|
+
import { TSchema } from "@sinclair/typebox";
|
|
2
|
+
//#region src/core/lib/artifactData.d.ts
|
|
3
|
+
/** The values of the sibling fields and settings an artifact receives as `camox.data`. */
|
|
4
|
+
export type ArtifactData = Record<string, unknown>;
|
|
5
|
+
//#endregion
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ArtifactData } from "./artifactData.js";
|
|
2
|
+
//#region src/core/lib/artifactHost.d.ts
|
|
3
|
+
/** The studio context an artifact sees as `camox.studio`; `null` on the website. */
|
|
4
|
+
export type ArtifactStudio = {
|
|
5
|
+
editing: boolean;
|
|
6
|
+
canvas: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** What the page shares with an artifact through its runtime. */
|
|
9
|
+
export type ArtifactHostState = {
|
|
10
|
+
studio: ArtifactStudio | null;
|
|
11
|
+
/** The artifact's Artifact Data; the frame's `srcDoc` holds its initial value. */
|
|
12
|
+
data?: ArtifactData;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the artifact runs in capture mode, as in the look document (ADR 0032): its Timeline's
|
|
15
|
+
* real time never advances, and the browser `look` drives seeks it through the frame's
|
|
16
|
+
* `LOOK_ARTIFACT_CAPTURE` property. Read once, when the host connects.
|
|
17
|
+
*/
|
|
18
|
+
capture?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** How a block's artifact field sizes its frame, and what the page does for the artifact. */
|
|
21
|
+
export type ArtifactHostOptions = {
|
|
22
|
+
/** With `"content"`, the artifact reports its height through `onHeight`. */
|
|
23
|
+
size?: "fill" | "content";
|
|
24
|
+
/** Applies the height the artifact's content needs, in CSS pixels. */
|
|
25
|
+
onHeight?: (height: number) => void;
|
|
26
|
+
/** Navigates the page's client router to an internal path (with its query and hash). */
|
|
27
|
+
navigate?: (path: string) => void;
|
|
28
|
+
};
|
|
29
|
+
export type ArtifactHost = {
|
|
30
|
+
/** Shares new state with the artifact; unchanged state sends nothing. */
|
|
31
|
+
update(state: ArtifactHostState): void;
|
|
32
|
+
disconnect(): void;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Connects an artifact frame to the `camox` runtime inside it, and owns the frame's message
|
|
36
|
+
* channel (see `artifactRuntime.ts` for the protocol).
|
|
37
|
+
*
|
|
38
|
+
* The block's code may run in another realm than the frame's parent (the studio renders its
|
|
39
|
+
* preview that way), so this only goes through the frame element's own document: never the
|
|
40
|
+
* global `window`, and never `event.source`, whose identity differs across realms.
|
|
41
|
+
*/
|
|
42
|
+
export declare function connectArtifactHost(frame: HTMLIFrameElement, initialState: ArtifactHostState, options?: ArtifactHostOptions): ArtifactHost;
|
|
43
|
+
//#endregion
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/features/brand/BrandPart.tsx
|
|
5
|
+
/**
|
|
6
|
+
* One part of the Brand Section, laid out like the Settings Section's: its heading beside what it
|
|
7
|
+
* holds. The heading column stays in view while the part scrolls, with `aside` under it for what
|
|
8
|
+
* acts on the whole part.
|
|
9
|
+
*/
|
|
10
|
+
function BrandPart(t0) {
|
|
11
|
+
const $ = c(30);
|
|
12
|
+
let aside;
|
|
13
|
+
let children;
|
|
14
|
+
let description;
|
|
15
|
+
let headingRef;
|
|
16
|
+
let props;
|
|
17
|
+
let title;
|
|
18
|
+
if ($[0] !== t0) {
|
|
19
|
+
({title, description, aside, headingRef, children, ...props} = t0);
|
|
20
|
+
$[0] = t0;
|
|
21
|
+
$[1] = aside;
|
|
22
|
+
$[2] = children;
|
|
23
|
+
$[3] = description;
|
|
24
|
+
$[4] = headingRef;
|
|
25
|
+
$[5] = props;
|
|
26
|
+
$[6] = title;
|
|
27
|
+
} else {
|
|
28
|
+
aside = $[1];
|
|
29
|
+
children = $[2];
|
|
30
|
+
description = $[3];
|
|
31
|
+
headingRef = $[4];
|
|
32
|
+
props = $[5];
|
|
33
|
+
title = $[6];
|
|
34
|
+
}
|
|
35
|
+
let t1;
|
|
36
|
+
if ($[7] !== title) {
|
|
37
|
+
let t2;
|
|
38
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
39
|
+
t2 = /\W+/g;
|
|
40
|
+
$[9] = t2;
|
|
41
|
+
} else t2 = $[9];
|
|
42
|
+
t1 = title.toLowerCase().replaceAll(t2, "-");
|
|
43
|
+
$[7] = title;
|
|
44
|
+
$[8] = t1;
|
|
45
|
+
} else t1 = $[8];
|
|
46
|
+
const id = `camox-brand-${t1}`;
|
|
47
|
+
const t2 = headingRef ? -1 : void 0;
|
|
48
|
+
let t3;
|
|
49
|
+
if ($[10] !== headingRef || $[11] !== id || $[12] !== t2 || $[13] !== title) {
|
|
50
|
+
t3 = /* @__PURE__ */ jsx("h2", {
|
|
51
|
+
id,
|
|
52
|
+
ref: headingRef,
|
|
53
|
+
tabIndex: t2,
|
|
54
|
+
className: "font-semibold outline-none",
|
|
55
|
+
children: title
|
|
56
|
+
});
|
|
57
|
+
$[10] = headingRef;
|
|
58
|
+
$[11] = id;
|
|
59
|
+
$[12] = t2;
|
|
60
|
+
$[13] = title;
|
|
61
|
+
$[14] = t3;
|
|
62
|
+
} else t3 = $[14];
|
|
63
|
+
let t4;
|
|
64
|
+
if ($[15] !== description) {
|
|
65
|
+
t4 = /* @__PURE__ */ jsx("p", {
|
|
66
|
+
className: "text-muted-foreground mt-1 text-sm",
|
|
67
|
+
children: description
|
|
68
|
+
});
|
|
69
|
+
$[15] = description;
|
|
70
|
+
$[16] = t4;
|
|
71
|
+
} else t4 = $[16];
|
|
72
|
+
let t5;
|
|
73
|
+
if ($[17] !== t3 || $[18] !== t4) {
|
|
74
|
+
t5 = /* @__PURE__ */ jsxs("div", { children: [t3, t4] });
|
|
75
|
+
$[17] = t3;
|
|
76
|
+
$[18] = t4;
|
|
77
|
+
$[19] = t5;
|
|
78
|
+
} else t5 = $[19];
|
|
79
|
+
let t6;
|
|
80
|
+
if ($[20] !== aside || $[21] !== t5) {
|
|
81
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
82
|
+
className: "flex flex-col gap-4 md:sticky md:top-6 md:self-start",
|
|
83
|
+
children: [t5, aside]
|
|
84
|
+
});
|
|
85
|
+
$[20] = aside;
|
|
86
|
+
$[21] = t5;
|
|
87
|
+
$[22] = t6;
|
|
88
|
+
} else t6 = $[22];
|
|
89
|
+
let t7;
|
|
90
|
+
if ($[23] !== children) {
|
|
91
|
+
t7 = /* @__PURE__ */ jsx("div", {
|
|
92
|
+
className: "min-w-0 md:col-span-2",
|
|
93
|
+
children
|
|
94
|
+
});
|
|
95
|
+
$[23] = children;
|
|
96
|
+
$[24] = t7;
|
|
97
|
+
} else t7 = $[24];
|
|
98
|
+
let t8;
|
|
99
|
+
if ($[25] !== id || $[26] !== props || $[27] !== t6 || $[28] !== t7) {
|
|
100
|
+
t8 = /* @__PURE__ */ jsxs("section", {
|
|
101
|
+
"aria-labelledby": id,
|
|
102
|
+
className: "grid gap-6 md:grid-cols-3 md:gap-8",
|
|
103
|
+
...props,
|
|
104
|
+
children: [t6, t7]
|
|
105
|
+
});
|
|
106
|
+
$[25] = id;
|
|
107
|
+
$[26] = props;
|
|
108
|
+
$[27] = t6;
|
|
109
|
+
$[28] = t7;
|
|
110
|
+
$[29] = t8;
|
|
111
|
+
} else t8 = $[29];
|
|
112
|
+
return t8;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { BrandPart };
|