tempo-sdk 0.0.45 → 0.0.51

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 (38) hide show
  1. package/dist/assets/editor.d.ts +1 -1
  2. package/dist/assets/editor.js +4 -2
  3. package/dist/assets/editor.js.map +1 -1
  4. package/dist/assets/index.d.ts +112 -24
  5. package/dist/assets/index.js +309 -1
  6. package/dist/assets/index.js.map +1 -1
  7. package/dist/assets/parser.d.ts +14 -3
  8. package/dist/assets/parser.js +7 -3
  9. package/dist/canvas/index.d.ts +1 -1
  10. package/dist/canvas/index.js +3 -2
  11. package/dist/canvas/index.js.map +1 -1
  12. package/dist/canvas/interact-projection.js +2 -1
  13. package/dist/canvas/svelte.d.ts +1 -1
  14. package/dist/canvas/svelte.js +1 -1
  15. package/dist/chunk-DI2ZFAWL.js +14 -0
  16. package/dist/chunk-DI2ZFAWL.js.map +1 -0
  17. package/dist/chunk-DX6XAXCK.js +827 -0
  18. package/dist/chunk-DX6XAXCK.js.map +1 -0
  19. package/dist/{chunk-7AJVPFFG.js → chunk-LFYKJJC5.js} +3 -3
  20. package/dist/{chunk-7AJVPFFG.js.map → chunk-LFYKJJC5.js.map} +1 -1
  21. package/dist/{chunk-IWULHYPW.js → chunk-O65OD3NA.js} +216 -19
  22. package/dist/chunk-O65OD3NA.js.map +1 -0
  23. package/dist/{chunk-7O6DPEMF.js → chunk-PULSTDX2.js} +9 -3
  24. package/dist/chunk-PULSTDX2.js.map +1 -0
  25. package/dist/{chunk-FIIU52RN.js → chunk-ZZYNOX24.js} +22 -810
  26. package/dist/chunk-ZZYNOX24.js.map +1 -0
  27. package/dist/index.js +86 -13
  28. package/dist/index.js.map +1 -1
  29. package/dist/nextjs/plugin.js +1 -1
  30. package/dist/nextjs.cjs +2 -2
  31. package/dist/nextjs.cjs.map +1 -1
  32. package/dist/nextjs.js +1 -1
  33. package/dist/{storyboard-xVaRTJAu.d.ts → storyboard-CBHki7Aw.d.ts} +2 -1
  34. package/dist/{types-B-dRoF2T.d.ts → types-C7cvcY6T.d.ts} +5 -1
  35. package/package.json +2 -2
  36. package/dist/chunk-7O6DPEMF.js.map +0 -1
  37. package/dist/chunk-FIIU52RN.js.map +0 -1
  38. package/dist/chunk-IWULHYPW.js.map +0 -1
@@ -1,3 +1,275 @@
1
+ import {
2
+ capture,
3
+ captureHead
4
+ } from "../chunk-DX6XAXCK.js";
5
+ import {
6
+ UNRESOLVED_VALUE
7
+ } from "../chunk-DI2ZFAWL.js";
8
+
9
+ // assets/prop-overrides.ts
10
+ function applyPropOverrides(props, edits) {
11
+ const result = { ...props };
12
+ for (const [name, value] of Object.entries(edits ?? {})) {
13
+ if (value && typeof value === "object" && Object.keys(value).length === 1 && value.__tempo_omit_prop__ === true) {
14
+ delete result[name];
15
+ } else
16
+ Object.defineProperty(result, name, {
17
+ value,
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true
21
+ });
22
+ }
23
+ return result;
24
+ }
25
+
26
+ // assets/live-preview.tsx
27
+ import {
28
+ Component,
29
+ createElement,
30
+ useEffect,
31
+ useLayoutEffect,
32
+ useRef,
33
+ useState
34
+ } from "react";
35
+
36
+ // assets/snapshot.ts
37
+ function snapshot(value) {
38
+ function copy(value2, seen, depth) {
39
+ if (value2 === null || typeof value2 === "string" || typeof value2 === "boolean")
40
+ return value2;
41
+ if (typeof value2 === "number")
42
+ return Number.isFinite(value2) ? value2 : UNRESOLVED_VALUE;
43
+ if (!value2 || typeof value2 !== "object" || depth > 16 || seen.has(value2))
44
+ return UNRESOLVED_VALUE;
45
+ if (!Array.isArray(value2) && Object.getPrototypeOf(value2) !== Object.prototype && Object.getPrototypeOf(value2) !== null)
46
+ return UNRESOLVED_VALUE;
47
+ if ("$$typeof" in value2) return UNRESOLVED_VALUE;
48
+ const next = new Set(seen).add(value2);
49
+ if (Array.isArray(value2))
50
+ return value2.map((item) => copy(item, next, depth + 1));
51
+ return Object.fromEntries(
52
+ Object.entries(value2).map(([key, child]) => [
53
+ key,
54
+ copy(child, next, depth + 1)
55
+ ])
56
+ );
57
+ }
58
+ return copy(value, /* @__PURE__ */ new Set(), 0);
59
+ }
60
+ function getComponentControlsSnapshot(component) {
61
+ return snapshot(getComponentControls(component));
62
+ }
63
+ function getAssetConfigSnapshot(component) {
64
+ return snapshot({
65
+ asset: getAssetConfig(component),
66
+ ...getComponentControls(component)
67
+ });
68
+ }
69
+
70
+ // assets/preview-snapshot.ts
71
+ function captureAssetPreview(root) {
72
+ if (!root.firstElementChild || root.querySelector("[data-tempo-projection-pending]"))
73
+ return null;
74
+ const width = root.offsetWidth;
75
+ const height = root.offsetHeight;
76
+ if (width <= 0 || height <= 0) return null;
77
+ const captured = capture(root);
78
+ const doc = root.ownerDocument.implementation.createHTMLDocument("");
79
+ for (const [name, value] of Object.entries(
80
+ captured.dom.documentElementAttributes ?? {}
81
+ ))
82
+ doc.documentElement.setAttribute(name, value);
83
+ for (const [name, value] of Object.entries(captured.dom.bodyAttributes ?? {}))
84
+ doc.body.setAttribute(name, value);
85
+ doc.head.innerHTML = captureHead(root.ownerDocument);
86
+ const base = doc.createElement("base");
87
+ base.href = root.ownerDocument.baseURI;
88
+ doc.head.prepend(base);
89
+ doc.body.innerHTML = captured.dom.html;
90
+ return {
91
+ html: `<!DOCTYPE html>${doc.documentElement.outerHTML}`,
92
+ width,
93
+ height
94
+ };
95
+ }
96
+
97
+ // assets/live-preview.tsx
98
+ import { jsx } from "react/jsx-runtime";
99
+ var ASSET_PREVIEW_MESSAGE = "tempo:asset-live-preview";
100
+ var PreviewBoundary = class extends Component {
101
+ constructor() {
102
+ super(...arguments);
103
+ this.state = {
104
+ error: null,
105
+ update: null
106
+ };
107
+ }
108
+ static getDerivedStateFromProps(props, state) {
109
+ return props.update !== state.update ? { update: props.update, error: null } : null;
110
+ }
111
+ static getDerivedStateFromError(error) {
112
+ return { error: error.message };
113
+ }
114
+ render() {
115
+ return this.state.error ? /* @__PURE__ */ jsx("p", { role: "alert", style: { padding: 12, fontSize: 12 }, children: this.state.error }) : this.props.children;
116
+ }
117
+ };
118
+ function AssetLivePreview({
119
+ component,
120
+ sessionId
121
+ }) {
122
+ const [update, setUpdate] = useState({
123
+ variant: null,
124
+ edits: {}
125
+ });
126
+ const peer = useRef(null);
127
+ const viewport = useRef(null);
128
+ const contentRoot = useRef(null);
129
+ const [fit, setFit] = useState({ width: 0, height: 0, scale: 1 });
130
+ const boundary = useRef(null);
131
+ const [captureRequest, setCaptureRequest] = useState(null);
132
+ const lastMetadata = useRef("");
133
+ useLayoutEffect(() => {
134
+ const frame = viewport.current;
135
+ const content2 = contentRoot.current;
136
+ const measure = () => {
137
+ const width = content2.offsetWidth;
138
+ const height = content2.offsetHeight;
139
+ const scale = Math.min(
140
+ 1,
141
+ Math.max(0, frame.clientWidth - 32) / (width || 1),
142
+ Math.max(0, frame.clientHeight - 32) / (height || 1)
143
+ );
144
+ setFit(
145
+ (previous) => previous.width === width && previous.height === height && previous.scale === scale ? previous : { width, height, scale }
146
+ );
147
+ };
148
+ measure();
149
+ const observer = new ResizeObserver(measure);
150
+ observer.observe(frame);
151
+ observer.observe(content2);
152
+ return () => observer.disconnect();
153
+ }, []);
154
+ const publish = () => {
155
+ if (!peer.current) return;
156
+ const metadata = getAssetConfigSnapshot(component);
157
+ const serialized = JSON.stringify(metadata);
158
+ if (lastMetadata.current === serialized) return;
159
+ lastMetadata.current = serialized;
160
+ window.parent.postMessage(
161
+ {
162
+ type: ASSET_PREVIEW_MESSAGE,
163
+ sessionId,
164
+ kind: "metadata",
165
+ metadata,
166
+ captureVersion: 1
167
+ },
168
+ peer.current.origin
169
+ );
170
+ };
171
+ const publishRef = useRef(publish);
172
+ publishRef.current = publish;
173
+ useEffect(() => {
174
+ const receive = (event) => {
175
+ if (event.source !== window.parent || event.data?.type !== ASSET_PREVIEW_MESSAGE || event.data.sessionId !== sessionId)
176
+ return;
177
+ if (event.data.kind === "connect") {
178
+ peer.current = { origin: event.origin === "null" ? "*" : event.origin };
179
+ lastMetadata.current = "";
180
+ publishRef.current();
181
+ } else if ((event.data.kind === "update" || event.data.kind === "capture") && peer.current) {
182
+ const next = event.data.update;
183
+ if (next && (next.variant === null || typeof next.variant === "string") && next.edits && typeof next.edits === "object" && !Array.isArray(next.edits)) {
184
+ setUpdate(next);
185
+ if (event.data.kind === "capture" && typeof event.data.requestId === "string")
186
+ setCaptureRequest(event.data.requestId);
187
+ }
188
+ }
189
+ };
190
+ window.addEventListener("message", receive);
191
+ window.parent.postMessage(
192
+ { type: ASSET_PREVIEW_MESSAGE, sessionId, kind: "ready" },
193
+ "*"
194
+ );
195
+ return () => window.removeEventListener("message", receive);
196
+ }, [sessionId]);
197
+ useLayoutEffect(() => {
198
+ if (!captureRequest || !peer.current) return;
199
+ const frame = requestAnimationFrame(() => {
200
+ let snapshot2 = null;
201
+ try {
202
+ if (contentRoot.current && !boundary.current?.state.error)
203
+ snapshot2 = captureAssetPreview(contentRoot.current);
204
+ } catch {
205
+ }
206
+ window.parent.postMessage(
207
+ {
208
+ type: ASSET_PREVIEW_MESSAGE,
209
+ sessionId,
210
+ kind: "captured",
211
+ requestId: captureRequest,
212
+ snapshot: snapshot2
213
+ },
214
+ peer.current.origin
215
+ );
216
+ setCaptureRequest(null);
217
+ });
218
+ return () => cancelAnimationFrame(frame);
219
+ }, [captureRequest, update, sessionId]);
220
+ useEffect(publish);
221
+ const config = getAssetConfig(component);
222
+ const variant = update.variant && Object.prototype.hasOwnProperty.call(config?.variants ?? {}, update.variant) ? config?.variants?.[update.variant] : void 0;
223
+ const render = variant && "render" in variant ? variant.render : void 0;
224
+ const content = update.variant === null ? null : render ? createElement(render) : createElement(
225
+ component,
226
+ applyPropOverrides(variant?.props ?? {}, update.edits)
227
+ );
228
+ return /* @__PURE__ */ jsx(
229
+ "div",
230
+ {
231
+ ref: viewport,
232
+ style: {
233
+ display: "flex",
234
+ alignItems: "center",
235
+ justifyContent: "center",
236
+ overflow: "hidden",
237
+ width: "100%",
238
+ height: "100%",
239
+ padding: 16,
240
+ boxSizing: "border-box"
241
+ },
242
+ children: /* @__PURE__ */ jsx(
243
+ "div",
244
+ {
245
+ style: {
246
+ position: "relative",
247
+ flexShrink: 0,
248
+ width: fit.width * fit.scale,
249
+ height: fit.height * fit.scale
250
+ },
251
+ children: /* @__PURE__ */ jsx(
252
+ "div",
253
+ {
254
+ ref: contentRoot,
255
+ style: {
256
+ position: "absolute",
257
+ top: 0,
258
+ left: 0,
259
+ width: "max-content",
260
+ height: "max-content",
261
+ transform: `scale(${fit.scale})`,
262
+ transformOrigin: "top left"
263
+ },
264
+ children: /* @__PURE__ */ jsx(PreviewBoundary, { ref: boundary, update, children: content })
265
+ }
266
+ )
267
+ }
268
+ )
269
+ }
270
+ );
271
+ }
272
+
1
273
  // assets/index.ts
2
274
  var TEMPO_ASSET_CONFIG_PROPERTY = "__tempoAssetConfig";
3
275
  function defineAsset(component, config) {
@@ -18,9 +290,45 @@ function getAssetConfig(component) {
18
290
  const config = component[TEMPO_ASSET_CONFIG_PROPERTY];
19
291
  return config === void 0 ? config : config;
20
292
  }
293
+ var TEMPO_CONTROLS_CONFIG_PROPERTY = "__tempoControlsConfig";
294
+ function defineControls(component, controls) {
295
+ const registration = { controls };
296
+ let registrations;
297
+ try {
298
+ const previous = component[TEMPO_CONTROLS_CONFIG_PROPERTY];
299
+ registrations = previous ?? /* @__PURE__ */ new Set();
300
+ registrations.add(registration);
301
+ Object.defineProperty(component, TEMPO_CONTROLS_CONFIG_PROPERTY, {
302
+ value: registrations,
303
+ enumerable: false,
304
+ configurable: true
305
+ });
306
+ } catch {
307
+ return () => {
308
+ };
309
+ }
310
+ return () => registrations.delete(registration);
311
+ }
312
+ function getComponentControls(component) {
313
+ if (!component || typeof component !== "function" && typeof component !== "object")
314
+ return {};
315
+ const registrations = component[TEMPO_CONTROLS_CONFIG_PROPERTY];
316
+ if (!registrations?.size) return {};
317
+ if (registrations.size > 1)
318
+ return {
319
+ error: "Multiple defineControls declarations for this component. Keep one declaration in the component file or tempo/controls.ts; remove the duplicate."
320
+ };
321
+ return registrations.values().next().value ?? {};
322
+ }
21
323
  export {
324
+ AssetLivePreview,
22
325
  TEMPO_ASSET_CONFIG_PROPERTY,
326
+ TEMPO_CONTROLS_CONFIG_PROPERTY,
23
327
  defineAsset,
24
- getAssetConfig
328
+ defineControls,
329
+ getAssetConfig,
330
+ getAssetConfigSnapshot,
331
+ getComponentControls,
332
+ getComponentControlsSnapshot
25
333
  };
26
334
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../assets/index.ts"],"sourcesContent":["/**\n * tempo-sdk/assets — runtime authoring surface for asset declarations.\n *\n * `defineAsset(Component, { ... })` marks a component (or canvas component)\n * as a design asset: library membership, usage instructions, and named prop\n * variants. Tempo reads these declarations STATICALLY (tempo-sdk/assets/parser)\n * — this runtime attach exists so a future version can also read live config\n * values from a running module without an authoring change.\n *\n * This subpath must stay browser-safe (no node imports): user component\n * files import it from app code, unlike the root entry's Vite plugin.\n * See specs/asset-libraries.md §2.\n */\nimport type { ComponentProps, ComponentType } from \"react\";\n\n/** Property key `defineAsset` attaches its config under. Non-enumerable so it\n * never leaks into spreads or serialization of the component value. */\nexport const TEMPO_ASSET_CONFIG_PROPERTY = \"__tempoAssetConfig\";\n\nexport type AssetVariant<P> = {\n /** Must satisfy the component's prop types — the user's own typecheck is\n * the validator; the static parser never re-derives prop requirements. */\n props: P;\n};\n\nexport type AssetVariants<P> = Record<string, AssetVariant<P>>;\n\nexport type AssetConfigBase = {\n /** What this asset is and when to reach for it — and when not (e.g. \"form\n * submits, CTAs — not navigation (use Link)\"). Shown on the asset detail\n * page and returned by the asset MCP tools. */\n usageInstructions?: string;\n /** Library names this asset belongs to. Arbitrary non-empty strings; a\n * library exists iff some asset names it. Unset/empty = library-less\n * (still an asset, still shown in the Assets tab). */\n libraries?: string[];\n};\n\n/**\n * `variants` is required exactly when the component has required props: a\n * variant is what makes such a component renderable in the Assets surface.\n * `{} extends P` is true only when P has no required keys.\n */\nexport type AssetConfig<C extends ComponentType<any>> = AssetConfigBase &\n ({} extends ComponentProps<C>\n ? { variants?: AssetVariants<ComponentProps<C>> }\n : { variants: AssetVariants<ComponentProps<C>> });\n\n/**\n * Declare a component or canvas as a design asset.\n *\n * Two supported shapes, both top-level statements. The preferred one is a\n * reference declaration in the canvas that curates the component — the\n * declaring canvas becomes the component's linked canvas:\n *\n * import { Button } from \"@/components/Button\";\n *\n * defineAsset(Button, {\n * usageInstructions: \"form submits, CTAs — not navigation (use Link)\",\n * variants: { Primary: { props: { label: \"Buy now\" } } },\n * });\n *\n * The legacy shape — the same statement in the file that defines the\n * component, placed after its definition — keeps working:\n *\n * export const Button = ({ label }: ButtonProps) => <button>{label}</button>;\n *\n * defineAsset(Button, {\n * libraries: [\"core\"],\n * variants: { Primary: { props: { label: \"Buy now\" } } },\n * });\n *\n * Returns void deliberately: `export default defineAsset(App, {...})` would\n * turn the export into a call expression and break React Fast Refresh's\n * component-only export analysis, so the wrapper form is a type error.\n */\nexport function defineAsset<C extends ComponentType<any>>(\n component: C,\n config: AssetConfig<C>,\n): void {\n try {\n // Re-runs on every hot update, re-attaching the current config —\n // configurable so the redefinition is legal.\n Object.defineProperty(component, TEMPO_ASSET_CONFIG_PROPERTY, {\n value: config,\n enumerable: false,\n configurable: true,\n writable: false,\n });\n } catch {\n // Frozen or exotic component values must never crash the user's app.\n }\n}\n\n/** Loosely-typed read shape: callers of getAssetConfig don't know the\n * component's prop types. */\nexport type ReadAssetConfig = AssetConfigBase & {\n variants?: AssetVariants<Record<string, unknown>>;\n};\n\n/** Read a config previously attached by `defineAsset`, if any. */\nexport function getAssetConfig(component: unknown): ReadAssetConfig | undefined {\n if (\n (typeof component !== \"function\" && typeof component !== \"object\") ||\n component === null\n ) {\n return undefined;\n }\n const config = (component as Record<string, unknown>)[\n TEMPO_ASSET_CONFIG_PROPERTY\n ];\n return config === undefined ? (config as undefined) : (config as ReadAssetConfig);\n}\n"],"mappings":";AAiBO,IAAM,8BAA8B;AA2DpC,SAAS,YACd,WACA,QACM;AACN,MAAI;AAGF,WAAO,eAAe,WAAW,6BAA6B;AAAA,MAC5D,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,IACZ,CAAC;AAAA,EACH,QAAQ;AAAA,EAER;AACF;AASO,SAAS,eAAe,WAAiD;AAC9E,MACG,OAAO,cAAc,cAAc,OAAO,cAAc,YACzD,cAAc,MACd;AACA,WAAO;AAAA,EACT;AACA,QAAM,SAAU,UACd,2BACF;AACA,SAAO,WAAW,SAAa,SAAwB;AACzD;","names":[]}
1
+ {"version":3,"sources":["../../assets/prop-overrides.ts","../../assets/live-preview.tsx","../../assets/snapshot.ts","../../assets/preview-snapshot.ts","../../assets/index.ts"],"sourcesContent":["/** Internal, JSON-safe omission marker. Never emitted as a component prop. */\nexport const OMIT_ASSET_PROP = { __tempo_omit_prop__: true } as const;\n\nexport function applyPropOverrides<T>(\n props: Readonly<Record<string, T>>,\n edits?: Readonly<Record<string, T>>,\n): Record<string, T> {\n const result = { ...props };\n for (const [name, value] of Object.entries(edits ?? {})) {\n if (\n value &&\n typeof value === \"object\" &&\n Object.keys(value).length === 1 &&\n (value as Record<string, unknown>).__tempo_omit_prop__ === true\n ) {\n delete result[name];\n } else\n Object.defineProperty(result, name, {\n value,\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n return result;\n}\n","import { applyPropOverrides } from \"./prop-overrides\";\nimport {\n Component,\n createElement,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type ComponentType,\n type ReactNode,\n} from \"react\";\nimport {\n getAssetConfig,\n type AssetDefinitionVariant,\n} from \"./index\";\nimport { getAssetConfigSnapshot } from \"./snapshot\";\nimport { captureAssetPreview } from \"./preview-snapshot\";\n\nexport const ASSET_PREVIEW_MESSAGE = \"tempo:asset-live-preview\";\n\nexport type AssetLivePreviewUpdate = {\n variant: string | null;\n edits: Record<string, unknown>;\n};\n\nclass PreviewBoundary extends Component<\n {\n children: ReactNode;\n update: AssetLivePreviewUpdate;\n },\n { error: string | null; update: AssetLivePreviewUpdate | null }\n> {\n state = {\n error: null as string | null,\n update: null as AssetLivePreviewUpdate | null,\n };\n static getDerivedStateFromProps(\n props: { update: AssetLivePreviewUpdate },\n state: { update: AssetLivePreviewUpdate | null },\n ) {\n return props.update !== state.update\n ? { update: props.update, error: null }\n : null;\n }\n static getDerivedStateFromError(error: Error) {\n return { error: error.message };\n }\n render() {\n return this.state.error ? (\n <p role=\"alert\" style={{ padding: 12, fontSize: 12 }}>\n {this.state.error}\n </p>\n ) : (\n this.props.children\n );\n }\n}\n\n/** One mounted component, driven by its editor. No file writes or captures on\n * variant/prop changes. Imports and source updates remain owned by Vite. */\nexport function AssetLivePreview({\n component,\n sessionId,\n}: {\n component: ComponentType<any>;\n sessionId: string;\n}) {\n const [update, setUpdate] = useState<AssetLivePreviewUpdate>({\n variant: null,\n edits: {},\n });\n const peer = useRef<{ origin: string } | null>(null);\n const viewport = useRef<HTMLDivElement>(null);\n const contentRoot = useRef<HTMLDivElement>(null);\n const [fit, setFit] = useState({ width: 0, height: 0, scale: 1 });\n const boundary = useRef<PreviewBoundary>(null);\n const [captureRequest, setCaptureRequest] = useState<string | null>(null);\n const lastMetadata = useRef(\"\");\n useLayoutEffect(() => {\n const frame = viewport.current!;\n const content = contentRoot.current!;\n const measure = () => {\n // Measure layout dimensions, not the transformed preview. The same\n // 16px inset and no-upscaling rule apply to its cached screenshot.\n const width = content.offsetWidth;\n const height = content.offsetHeight;\n const scale = Math.min(\n 1,\n Math.max(0, frame.clientWidth - 32) / (width || 1),\n Math.max(0, frame.clientHeight - 32) / (height || 1),\n );\n setFit((previous) =>\n previous.width === width &&\n previous.height === height &&\n previous.scale === scale\n ? previous\n : { width, height, scale },\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(frame);\n observer.observe(content);\n return () => observer.disconnect();\n }, []);\n const publish = () => {\n if (!peer.current) return;\n const metadata = getAssetConfigSnapshot(component);\n const serialized = JSON.stringify(metadata);\n if (lastMetadata.current === serialized) return;\n lastMetadata.current = serialized;\n window.parent.postMessage(\n {\n type: ASSET_PREVIEW_MESSAGE,\n sessionId,\n kind: \"metadata\",\n metadata,\n captureVersion: 1,\n },\n peer.current.origin,\n );\n };\n const publishRef = useRef(publish);\n publishRef.current = publish;\n useEffect(() => {\n const receive = (event: MessageEvent) => {\n if (\n event.source !== window.parent ||\n event.data?.type !== ASSET_PREVIEW_MESSAGE ||\n event.data.sessionId !== sessionId\n )\n return;\n if (event.data.kind === \"connect\") {\n peer.current = { origin: event.origin === \"null\" ? \"*\" : event.origin };\n lastMetadata.current = \"\";\n publishRef.current();\n } else if (\n (event.data.kind === \"update\" || event.data.kind === \"capture\") &&\n peer.current\n ) {\n const next = event.data.update;\n if (\n next &&\n (next.variant === null || typeof next.variant === \"string\") &&\n next.edits &&\n typeof next.edits === \"object\" &&\n !Array.isArray(next.edits)\n ) {\n setUpdate(next);\n if (\n event.data.kind === \"capture\" &&\n typeof event.data.requestId === \"string\"\n )\n setCaptureRequest(event.data.requestId);\n }\n }\n };\n window.addEventListener(\"message\", receive);\n // The parent may have received iframe.load before this lazy storyboard mounted.\n window.parent.postMessage(\n { type: ASSET_PREVIEW_MESSAGE, sessionId, kind: \"ready\" },\n \"*\",\n );\n return () => window.removeEventListener(\"message\", receive);\n }, [sessionId]);\n useLayoutEffect(() => {\n if (!captureRequest || !peer.current) return;\n // Capture after React has committed the EXACT props from the request, even\n // when Insert follows the last keystroke before its update message arrived.\n const frame = requestAnimationFrame(() => {\n let snapshot = null;\n try {\n if (contentRoot.current && !boundary.current?.state.error)\n snapshot = captureAssetPreview(contentRoot.current);\n } catch {\n // Snapshotting is an optimization; an unusual DOM must not block Add.\n }\n window.parent.postMessage(\n {\n type: ASSET_PREVIEW_MESSAGE,\n sessionId,\n kind: \"captured\",\n requestId: captureRequest,\n snapshot,\n },\n peer.current!.origin,\n );\n setCaptureRequest(null);\n });\n return () => cancelAnimationFrame(frame);\n }, [captureRequest, update, sessionId]);\n // A hot update can change metadata without changing the component identity.\n useEffect(publish);\n const config = getAssetConfig(component);\n const variant = (\n update.variant &&\n Object.prototype.hasOwnProperty.call(config?.variants ?? {}, update.variant)\n ? config?.variants?.[update.variant]\n : undefined\n ) as AssetDefinitionVariant<Record<string, unknown>> | undefined;\n const render =\n variant && \"render\" in variant ? variant.render : undefined;\n const content =\n update.variant === null\n ? null\n : render\n ? createElement(render)\n : createElement(\n component,\n applyPropOverrides(variant?.props ?? {}, update.edits),\n );\n return (\n <div\n ref={viewport}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n width: \"100%\",\n height: \"100%\",\n padding: 16,\n boxSizing: \"border-box\",\n }}\n >\n <div\n style={{\n position: \"relative\",\n flexShrink: 0,\n width: fit.width * fit.scale,\n height: fit.height * fit.scale,\n }}\n >\n <div\n ref={contentRoot}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"max-content\",\n height: \"max-content\",\n transform: `scale(${fit.scale})`,\n transformOrigin: \"top left\",\n }}\n >\n <PreviewBoundary ref={boundary} update={update}>\n {content}\n </PreviewBoundary>\n </div>\n </div>\n </div>\n );\n}\n","import { getAssetConfig, getComponentControls } from \"./index\";\nimport { UNRESOLVED_VALUE, type StaticValue } from \"./types\";\n\n/** Browser-side metadata transport. Unsupported values stay visible; JSON must\n * never silently drop a function, JSX child, cyclic object, or undefined prop. */\nfunction snapshot(value: unknown): StaticValue {\n function copy(value: unknown, seen: Set<object>, depth: number): StaticValue {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\"\n )\n return value;\n if (typeof value === \"number\")\n return Number.isFinite(value) ? value : UNRESOLVED_VALUE;\n if (!value || typeof value !== \"object\" || depth > 16 || seen.has(value))\n return UNRESOLVED_VALUE;\n if (\n !Array.isArray(value) &&\n Object.getPrototypeOf(value) !== Object.prototype &&\n Object.getPrototypeOf(value) !== null\n )\n return UNRESOLVED_VALUE;\n if (\"$$typeof\" in value) return UNRESOLVED_VALUE;\n const next = new Set(seen).add(value);\n if (Array.isArray(value))\n return value.map((item) => copy(item, next, depth + 1));\n return Object.fromEntries(\n Object.entries(value).map(([key, child]) => [\n key,\n copy(child, next, depth + 1),\n ]),\n );\n }\n return copy(value, new Set(), 0);\n}\n\nexport function getComponentControlsSnapshot(component: unknown): StaticValue {\n return snapshot(getComponentControls(component));\n}\nexport function getAssetConfigSnapshot(component: unknown): StaticValue {\n return snapshot({\n asset: getAssetConfig(component),\n ...getComponentControls(component),\n });\n}\n","import { capture } from \"../../../modules/iframe-projection/html/capture\";\nimport { captureHead } from \"../../../modules/iframe-projection/html/watch-head\";\n\n/** Rendered markup, not React state or executable code. Source identities are\n * rebound by the editor only after it knows where the insertion will land. */\nexport type AssetPreviewSnapshot = {\n html: string;\n width: number;\n height: number;\n};\n\n/** One cold read on insert/drag, never a second continuous projection watch. */\nexport function captureAssetPreview(\n root: HTMLElement,\n): AssetPreviewSnapshot | null {\n if (\n !root.firstElementChild ||\n root.querySelector(\"[data-tempo-projection-pending]\")\n )\n return null;\n // The preview may be scaled down to fit its window. Insertion keeps the\n // component's natural layout size and captures only its inner markup.\n const width = root.offsetWidth;\n const height = root.offsetHeight;\n if (width <= 0 || height <= 0) return null;\n const captured = capture(root);\n const doc = root.ownerDocument.implementation.createHTMLDocument(\"\");\n for (const [name, value] of Object.entries(\n captured.dom.documentElementAttributes ?? {},\n ))\n doc.documentElement.setAttribute(name, value);\n for (const [name, value] of Object.entries(captured.dom.bodyAttributes ?? {}))\n doc.body.setAttribute(name, value);\n doc.head.innerHTML = captureHead(root.ownerDocument);\n const base = doc.createElement(\"base\");\n base.href = root.ownerDocument.baseURI;\n doc.head.prepend(base);\n doc.body.innerHTML = captured.dom.html;\n return {\n html: `<!DOCTYPE html>${doc.documentElement.outerHTML}`,\n width,\n height,\n };\n}\n","/**\n * tempo-sdk/assets — runtime authoring surface for asset declarations.\n *\n * `defineAsset(Component, { ... })` marks a component (or canvas component)\n * as a design asset: library membership, usage instructions, and named prop\n * variants. `defineControls` independently describes prop editors. Tempo\n * discovers assets statically and reads explicit controls from the running\n * component. Source analysis supplies prop types and portable JSX for insertion.\n *\n * This subpath must stay browser-safe (no node imports): user component\n * files import it from app code, unlike the root entry's Vite plugin.\n * See specs/asset-libraries.md §2.\n */\nimport type { ComponentProps, ComponentType, ReactNode } from \"react\";\nimport type { AssetComponentProps, AssetControls } from \"./controls\";\nexport { AssetLivePreview } from \"./live-preview\";\nexport type {\n AssetControlDefinition,\n AssetControls,\n AssetPropControl,\n} from \"./controls\";\n\n/** Property key `defineAsset` attaches its config under. Non-enumerable so it\n * never leaks into spreads or serialization of the component value. */\nexport const TEMPO_ASSET_CONFIG_PROPERTY = \"__tempoAssetConfig\";\n\nexport type AssetVariant<P> = {\n /** Must satisfy the component's prop types. Kept required for source\n * compatibility with the original public asset-reader contract. */\n props: P;\n};\n\nexport type AssetRenderVariant = {\n props?: never;\n render: () => ReactNode;\n};\n\nexport type AssetDefinitionVariant<P> =\n | (AssetVariant<P> & { render?: never })\n | AssetRenderVariant;\n\nexport type AssetVariants<P> = Record<string, AssetVariant<P>>;\n\nexport type AssetConfigBase = {\n /** What this asset is and when to reach for it — and when not (e.g. \"form\n * submits, CTAs — not navigation (use Link)\"). Shown on the asset detail\n * page and returned by the asset MCP tools. */\n usageInstructions?: string;\n /** Library names this asset belongs to. Arbitrary non-empty strings; a\n * library exists iff some asset names it. Unset/empty = library-less\n * (still an asset, still shown in the Assets tab). */\n libraries?: string[];\n};\n\n/**\n * `variants` is required exactly when the component has required props. This\n * preserves the public reader guarantees from the first published asset API.\n * `defineAsset` also accepts metadata-only and render-only declarations through\n * its additive authoring input below.\n */\nexport type AssetConfig<C extends ComponentType<any>> = AssetConfigBase &\n ({} extends ComponentProps<C>\n ? { variants?: AssetVariants<ComponentProps<C>> }\n : { variants: AssetVariants<ComponentProps<C>> });\n\nexport type AssetDefinitionConfig<C extends ComponentType<any>> =\n AssetConfigBase & {\n variants?: Record<string, AssetDefinitionVariant<ComponentProps<C>>>;\n };\n\n/**\n * Declare a component or canvas as a design asset.\n *\n * Two supported shapes, both top-level statements. Prefer a declaration in a\n * canvas that curates the component — the\n * declaring canvas becomes the component's linked canvas:\n *\n * import { Button } from \"@/components/Button\";\n *\n * defineAsset(Button, {\n * usageInstructions: \"form submits, CTAs — not navigation (use Link)\",\n * variants: { Primary: { props: { label: \"Buy now\" } } },\n * });\n *\n * A legacy shape is the same statement in the file that defines the\n * component, placed after its definition — keeps working:\n *\n * export const Button = ({ label }: ButtonProps) => <button>{label}</button>;\n *\n * defineAsset(Button, {\n * libraries: [\"core\"],\n * variants: { Primary: { props: { label: \"Buy now\" } } },\n * });\n *\n * Returns void deliberately: `export default defineAsset(App, {...})` would\n * turn the export into a call expression and break React Fast Refresh's\n * component-only export analysis, so the wrapper form is a type error.\n */\nexport function defineAsset<C extends ComponentType<any>>(\n component: C,\n config: AssetDefinitionConfig<C>,\n): void {\n try {\n // Re-runs on every hot update, re-attaching the current config —\n // configurable so the redefinition is legal.\n Object.defineProperty(component, TEMPO_ASSET_CONFIG_PROPERTY, {\n value: config,\n enumerable: false,\n configurable: true,\n writable: false,\n });\n } catch {\n // Frozen or exotic component values must never crash the user's app.\n }\n}\n\n/** Loosely-typed read shape: callers of getAssetConfig don't know the\n * component's prop types. */\nexport type ReadAssetConfig = AssetConfigBase & {\n variants?: AssetVariants<Record<string, unknown>>;\n};\n\n/** Read a config previously attached by `defineAsset`, if any. */\nexport function getAssetConfig(\n component: unknown,\n): ReadAssetConfig | undefined {\n if (\n (typeof component !== \"function\" && typeof component !== \"object\") ||\n component === null\n ) {\n return undefined;\n }\n const config = (component as Record<string, unknown>)[\n TEMPO_ASSET_CONFIG_PROPERTY\n ];\n return config === undefined\n ? (config as undefined)\n : (config as ReadAssetConfig);\n}\n\nexport {\n getAssetConfigSnapshot,\n getComponentControlsSnapshot,\n} from \"./snapshot\";\n\nexport type ComponentControls<P> = AssetControls<P>;\nexport type ComponentControlsTarget = {\n filePath: string;\n name: string;\n exportName?: string;\n};\nexport const TEMPO_CONTROLS_CONFIG_PROPERTY = \"__tempoControlsConfig\";\n\ntype ControlsRegistration = {\n controls: Record<string, import(\"./controls\").AssetControlDefinition>;\n};\n\n/** Describe real prop editors once, independently of assets and libraries.\n * New components keep this call in their own file. Existing components may use\n * tempo/controls.ts to avoid editing app source. Both work across every canvas.\n * Legacy canvas declarations remain supported.\n * The returned cleanup is used by Tempo's development transform during HMR.\n */\nexport function defineControls<\n C extends ComponentType<any>,\n const Controls extends AssetControls<ComponentProps<NoInfer<C>>>,\n>(\n component: C,\n controls: Controls &\n Record<\n Exclude<\n keyof Controls,\n keyof AssetComponentProps<ComponentProps<NoInfer<C>>>\n >,\n never\n >,\n): () => void {\n const registration = { controls } as ControlsRegistration;\n let registrations: Set<ControlsRegistration>;\n try {\n const previous = (component as unknown as Record<string, unknown>)[\n TEMPO_CONTROLS_CONFIG_PROPERTY\n ] as Set<ControlsRegistration> | undefined;\n registrations = previous ?? new Set();\n registrations.add(registration);\n Object.defineProperty(component, TEMPO_CONTROLS_CONFIG_PROPERTY, {\n value: registrations,\n enumerable: false,\n configurable: true,\n });\n } catch {\n /* Frozen components still render; use a local wrapper to attach controls. */\n return () => {};\n }\n return () => registrations.delete(registration);\n}\n\nexport function getComponentControls(component: unknown): {\n controls?: Record<string, import(\"./controls\").AssetControlDefinition>;\n error?: string;\n} {\n if (\n !component ||\n (typeof component !== \"function\" && typeof component !== \"object\")\n )\n return {};\n const registrations = (component as Record<string, unknown>)[\n TEMPO_CONTROLS_CONFIG_PROPERTY\n ] as Set<ControlsRegistration> | undefined;\n if (!registrations?.size) return {};\n if (registrations.size > 1)\n return {\n error:\n \"Multiple defineControls declarations for this component. Keep one declaration in the component file or tempo/controls.ts; remove the duplicate.\",\n };\n return registrations.values().next().value ?? {};\n}\n"],"mappings":";;;;;;;;;AAGO,SAAS,mBAC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,MACP,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB,CAAC;AAAA,EACH,QAAQ;AAEN,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACA,SAAO,MAAM,cAAc,OAAO,YAAY;AAChD;AAEO,SAAS,qBAAqB,WAGnC;AACA,MACE,CAAC,aACA,OAAO,cAAc,cAAc,OAAO,cAAc;AAEzD,WAAO,CAAC;AACV,QAAM,gBAAiB,UACrB,8BACF;AACA,MAAI,CAAC,eAAe,KAAM,QAAO,CAAC;AAClC,MAAI,cAAc,OAAO;AACvB,WAAO;AAAA,MACL,OACE;AAAA,IACJ;AACF,SAAO,cAAc,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC;AACjD;","names":["value","content","snapshot"]}
@@ -1,5 +1,5 @@
1
- import { P as ParsedAssetReference, a as AssetSourceSpan, b as AssetExportKind, c as ParsedAssetFile, d as AssetParseError } from '../types-B-dRoF2T.js';
2
- export { A as AssetEditFailureCode, e as AssetParseErrorCode, f as AssetSpans, g as ParsedAssetDeclaration, h as ParsedAssetVariant, S as StaticValue, U as UNRESOLVED_VALUE, i as UnresolvedValue, j as isUnresolvedValue } from '../types-B-dRoF2T.js';
1
+ import { P as ParsedAssetReference, a as AssetSourceSpan, b as AssetExportKind, c as ParsedAssetFile, d as AssetParseError } from '../types-C7cvcY6T.js';
2
+ export { A as AssetEditFailureCode, e as AssetParseErrorCode, f as AssetSpans, g as ParsedAssetDeclaration, h as ParsedAssetVariant, S as StaticValue, U as UNRESOLVED_VALUE, i as UnresolvedValue, j as isUnresolvedValue } from '../types-C7cvcY6T.js';
3
3
 
4
4
  /** The one module specifier `defineAsset` may be imported from. */
5
5
  declare const ASSET_SDK_IMPORT_SOURCE = "tempo-sdk/assets";
@@ -28,6 +28,9 @@ type SourceComment = {
28
28
  */
29
29
  declare function readSourceComments(filePath: string, source: string): SourceComment[] | null;
30
30
  type AssetImportInfo = {
31
+ /** Added after the original public parser contract; optional so existing
32
+ * callers can continue constructing `AssetImportInfo` object literals. */
33
+ trustedDefineControlsNames?: Set<string>;
31
34
  /** Local names bound to `defineAsset` imported from tempo-sdk/assets. */
32
35
  trustedDefineAssetNames: Set<string>;
33
36
  /** Every value-import local name → its module specifier. */
@@ -46,6 +49,14 @@ type AssetImportInfo = {
46
49
  }[];
47
50
  };
48
51
  declare function readAssetImports(program: any): AssetImportInfo;
52
+ /** Discover control owners without evaluating their config or requiring an asset. */
53
+ declare function parseControlsFile(filePath: string, source: string): {
54
+ bindingName: string;
55
+ reference?: ParsedAssetReference;
56
+ exportKind: AssetExportKind;
57
+ start: number;
58
+ end: number;
59
+ }[];
49
60
  type AssetTopLevelBinding = {
50
61
  name: string;
51
62
  /** Whole top-level statement declaring the binding, export keyword
@@ -75,4 +86,4 @@ declare function collectIdentifierNames(program: any): Set<string>;
75
86
  declare function unwrapTsExpression(node: any): any;
76
87
  declare function toSourceSpan(node: any): AssetSourceSpan | undefined;
77
88
 
78
- export { ASSET_SDK_IMPORT_SOURCE, AssetExportKind, type AssetImportInfo, AssetParseError, AssetSourceSpan, type AssetTopLevelBinding, type AssetTopLevelScope, ParsedAssetFile, ParsedAssetReference, type SourceComment, collectIdentifierNames, collectTopLevelScope, hasTopLevelDefineAssetCallFor, parseAssetFile, parseAssetProgram, readAssetImports, readSourceComments, toSourceSpan, unwrapTsExpression };
89
+ export { ASSET_SDK_IMPORT_SOURCE, AssetExportKind, type AssetImportInfo, AssetParseError, AssetSourceSpan, type AssetTopLevelBinding, type AssetTopLevelScope, ParsedAssetFile, ParsedAssetReference, type SourceComment, collectIdentifierNames, collectTopLevelScope, hasTopLevelDefineAssetCallFor, parseAssetFile, parseAssetProgram, parseControlsFile, readAssetImports, readSourceComments, toSourceSpan, unwrapTsExpression };
@@ -1,17 +1,20 @@
1
1
  import {
2
2
  ASSET_SDK_IMPORT_SOURCE,
3
- UNRESOLVED_VALUE,
4
3
  collectIdentifierNames,
5
4
  collectTopLevelScope,
6
5
  hasTopLevelDefineAssetCallFor,
7
- isUnresolvedValue,
8
6
  parseAssetFile,
9
7
  parseAssetProgram,
8
+ parseControlsFile,
10
9
  readAssetImports,
11
10
  readSourceComments,
12
11
  toSourceSpan,
13
12
  unwrapTsExpression
14
- } from "../chunk-IWULHYPW.js";
13
+ } from "../chunk-O65OD3NA.js";
14
+ import {
15
+ UNRESOLVED_VALUE,
16
+ isUnresolvedValue
17
+ } from "../chunk-DI2ZFAWL.js";
15
18
  export {
16
19
  ASSET_SDK_IMPORT_SOURCE,
17
20
  UNRESOLVED_VALUE,
@@ -21,6 +24,7 @@ export {
21
24
  isUnresolvedValue,
22
25
  parseAssetFile,
23
26
  parseAssetProgram,
27
+ parseControlsFile,
24
28
  readAssetImports,
25
29
  readSourceComments,
26
30
  toSourceSpan,
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, ComponentType } from 'react';
3
- export { H as HtmlStoryboard, L as LegacyStoryboardV1, R as RouteStoryboard, S as Storyboard, a as StoryboardLayout, b as StoryboardSlot, c as StoryboardVrtConfig, d as StoryboardVrtIgnoreRegion } from '../storyboard-xVaRTJAu.js';
3
+ export { H as HtmlStoryboard, L as LegacyStoryboardV1, R as RouteStoryboard, S as Storyboard, a as StoryboardLayout, b as StoryboardSlot, c as StoryboardVrtConfig, d as StoryboardVrtIgnoreRegion } from '../storyboard-CBHki7Aw.js';
4
4
  import '../page-xi1aI5a7.js';
5
5
 
6
6
  declare function getCanvasStoryboardRenderId(canvasPath: string, storyboardId: string): string;
@@ -17,15 +17,16 @@ import {
17
17
  useActiveState,
18
18
  useRenderErrorRecovery,
19
19
  useRequiredCanvasHost
20
- } from "../chunk-7O6DPEMF.js";
20
+ } from "../chunk-PULSTDX2.js";
21
21
  import {
22
22
  installTempoInteractProjectionSource
23
- } from "../chunk-FIIU52RN.js";
23
+ } from "../chunk-ZZYNOX24.js";
24
24
  import {
25
25
  TEMPO_INTERACT_FRAME_NAME,
26
26
  isTempoInteractFrameName
27
27
  } from "../chunk-65B52AR7.js";
28
28
  import "../chunk-57KAYXHF.js";
29
+ import "../chunk-DX6XAXCK.js";
29
30
 
30
31
  // canvas/canvas-host.tsx
31
32
  import {