tempo-sdk 0.0.99 → 0.0.101
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/README.md +3 -403
- package/dist/assets/editor.d.ts +43 -65
- package/dist/assets/editor.js +1 -573
- package/dist/assets/index.d.ts +11 -61
- package/dist/assets/index.js +1 -338
- package/dist/assets/parser.d.ts +68 -78
- package/dist/assets/parser.js +1 -33
- package/dist/astro/asset-preview-client.d.ts +3 -2
- package/dist/astro/asset-preview-client.js +1 -93
- package/dist/astro/controls.d.ts +1 -3
- package/dist/astro/controls.js +1 -7
- package/dist/astro/document-client.d.ts +5 -6
- package/dist/astro/document-client.js +1 -78
- package/dist/astro/runtime.d.ts +23 -11
- package/dist/astro/runtime.js +1 -86
- package/dist/astro.d.ts +19 -13
- package/dist/astro.js +1 -818
- package/dist/canvas/astro-contract.d.ts +0 -3
- package/dist/canvas/astro-contract.js +1 -9
- package/dist/canvas/astro.d.ts +3 -4
- package/dist/canvas/astro.js +1 -42
- package/dist/canvas/editor.d.ts +187 -183
- package/dist/canvas/editor.js +1 -1094
- package/dist/canvas/flutter-preview.d.ts +0 -1
- package/dist/canvas/flutter-preview.js +1 -9
- package/dist/canvas/index.d.ts +46 -100
- package/dist/canvas/index.js +1 -3926
- package/dist/canvas/interact-projection.d.ts +7 -5
- package/dist/canvas/interact-projection.js +1 -12
- package/dist/canvas/parser.d.ts +10 -303
- package/dist/canvas/parser.js +1 -30
- package/dist/canvas/svelte.d.ts +6 -7
- package/dist/canvas/svelte.js +1 -91
- package/dist/canvas/vue.d.ts +9 -49
- package/dist/canvas/vue.js +1 -264
- package/dist/chunk-FH6TMWFA.js +1 -0
- package/dist/chunk-GQIOB5SV.js +1 -0
- package/dist/chunk-HBQ7FFH7.js +1 -0
- package/dist/chunk-JRJOWLCN.js +1 -0
- package/dist/chunk-M3GN2KUH.js +1 -0
- package/dist/chunk-MPIHFFML.js +1 -0
- package/dist/chunk-N2V6XXRK.js +1 -0
- package/dist/chunk-QNVQ7U2W.js +1 -0
- package/dist/chunk-T5TY3U2H.js +1 -0
- package/dist/chunk-TK37FQAR.js +1 -0
- package/dist/chunk-XO2BSHWM.js +1 -0
- package/dist/chunk-XUSV3KOD.js +1 -0
- package/dist/chunk-YRBEBVG4.js +1 -0
- package/dist/{controls-uCaQ3CNX.d.ts → controls-DKslABtM.d.ts} +0 -3
- package/dist/expo/plugin.cjs +1 -1928
- package/dist/expo/plugin.js +1 -8
- package/dist/expo-babel-plugin.cjs +1 -1928
- package/dist/expo-babel-plugin.d.cts +46 -40
- package/dist/expo-babel-plugin.d.ts +46 -40
- package/dist/expo-babel-plugin.js +1 -8
- package/dist/flutter-preview-path.d.ts +23 -7
- package/dist/flutter-preview-path.js +1 -16
- package/dist/index.d.ts +33 -45
- package/dist/index.js +1 -20
- package/dist/nextjs/plugin.cjs +1 -413
- package/dist/nextjs/plugin.js +1 -7
- package/dist/nextjs-loader.cjs +1 -2277
- package/dist/nextjs.cjs +1 -484
- package/dist/nextjs.d.cts +2 -58
- package/dist/nextjs.d.ts +2 -58
- package/dist/nextjs.js +1 -17
- package/dist/nuxt/runtime/identity.d.ts +2 -4
- package/dist/nuxt/runtime/identity.js +1 -18
- package/dist/nuxt.d.ts +31 -92
- package/dist/nuxt.js +1 -5854
- package/dist/{page-DwLnOM5d.d.ts → page-Bc8PekIX.d.ts} +1 -5
- package/dist/parser.d-MO5ciJ5n.d.ts +236 -0
- package/dist/{storyboard-CMJVBSXn.d.ts → storyboard.contract.d-UQ4MUYN5.d.ts} +3 -25
- package/dist/svelte.d.ts +8 -18
- package/dist/svelte.js +1 -917
- package/dist/types-CfUgM2w4.d.ts +57 -0
- package/dist/v1-client-compat-n0E0XxuX.d.ts +5 -0
- package/dist/vue.d.ts +17 -58
- package/dist/vue.js +1 -1501
- package/package.json +12 -62
- package/dist/assets/editor.js.map +0 -1
- package/dist/assets/index.js.map +0 -1
- package/dist/assets/parser.js.map +0 -1
- package/dist/astro/asset-preview-client.js.map +0 -1
- package/dist/astro/controls.js.map +0 -1
- package/dist/astro/document-client.js.map +0 -1
- package/dist/astro/runtime.js.map +0 -1
- package/dist/astro.js.map +0 -1
- package/dist/canvas/astro-contract.js.map +0 -1
- package/dist/canvas/astro.js.map +0 -1
- package/dist/canvas/editor.js.map +0 -1
- package/dist/canvas/flutter-preview.js.map +0 -1
- package/dist/canvas/index.js.map +0 -1
- package/dist/canvas/interact-projection.js.map +0 -1
- package/dist/canvas/parser.js.map +0 -1
- package/dist/canvas/svelte.js.map +0 -1
- package/dist/canvas/vue.js.map +0 -1
- package/dist/chunk-27WT3XUG.js +0 -455
- package/dist/chunk-27WT3XUG.js.map +0 -1
- package/dist/chunk-5HIIF354.js +0 -67
- package/dist/chunk-5HIIF354.js.map +0 -1
- package/dist/chunk-65B52AR7.js +0 -11
- package/dist/chunk-65B52AR7.js.map +0 -1
- package/dist/chunk-6HYKKP5N.js +0 -2658
- package/dist/chunk-6HYKKP5N.js.map +0 -1
- package/dist/chunk-6SOP4XU6.js +0 -1891
- package/dist/chunk-6SOP4XU6.js.map +0 -1
- package/dist/chunk-AFXE462X.js +0 -1253
- package/dist/chunk-AFXE462X.js.map +0 -1
- package/dist/chunk-BQPKOVI5.js +0 -115
- package/dist/chunk-BQPKOVI5.js.map +0 -1
- package/dist/chunk-CYDF4LYJ.js +0 -342
- package/dist/chunk-CYDF4LYJ.js.map +0 -1
- package/dist/chunk-CYQE3TLC.js +0 -37
- package/dist/chunk-CYQE3TLC.js.map +0 -1
- package/dist/chunk-DI2ZFAWL.js +0 -14
- package/dist/chunk-DI2ZFAWL.js.map +0 -1
- package/dist/chunk-EGRHWZRV.js +0 -1
- package/dist/chunk-EGRHWZRV.js.map +0 -1
- package/dist/chunk-FGWGY3G3.js +0 -157
- package/dist/chunk-FGWGY3G3.js.map +0 -1
- package/dist/chunk-HOBTDB6G.js +0 -112
- package/dist/chunk-HOBTDB6G.js.map +0 -1
- package/dist/chunk-I7VF4ZOV.js +0 -630
- package/dist/chunk-I7VF4ZOV.js.map +0 -1
- package/dist/chunk-JVVHU3A7.js +0 -1077
- package/dist/chunk-JVVHU3A7.js.map +0 -1
- package/dist/chunk-MIXQVPDH.js +0 -8606
- package/dist/chunk-MIXQVPDH.js.map +0 -1
- package/dist/chunk-MU7S7NU7.js +0 -183
- package/dist/chunk-MU7S7NU7.js.map +0 -1
- package/dist/chunk-OX2YKYSL.js +0 -13
- package/dist/chunk-OX2YKYSL.js.map +0 -1
- package/dist/chunk-PYAJHLXO.js +0 -903
- package/dist/chunk-PYAJHLXO.js.map +0 -1
- package/dist/chunk-SGN7BDRE.js +0 -16
- package/dist/chunk-SGN7BDRE.js.map +0 -1
- package/dist/chunk-SGTGDLOX.js +0 -285
- package/dist/chunk-SGTGDLOX.js.map +0 -1
- package/dist/chunk-T364NBR3.js +0 -1440
- package/dist/chunk-T364NBR3.js.map +0 -1
- package/dist/chunk-U66QI3EN.js +0 -1524
- package/dist/chunk-U66QI3EN.js.map +0 -1
- package/dist/chunk-WTXOWQ7N.js +0 -47
- package/dist/chunk-WTXOWQ7N.js.map +0 -1
- package/dist/chunk-X5DJKVBT.js +0 -1308
- package/dist/chunk-X5DJKVBT.js.map +0 -1
- package/dist/chunk-ZT7HJ6YU.js +0 -38
- package/dist/chunk-ZT7HJ6YU.js.map +0 -1
- package/dist/chunk-ZW26VZHX.js +0 -3169
- package/dist/chunk-ZW26VZHX.js.map +0 -1
- package/dist/controls-reader-5MFHYBZZ.js +0 -192
- package/dist/controls-reader-5MFHYBZZ.js.map +0 -1
- package/dist/expo/plugin.cjs.map +0 -1
- package/dist/expo/plugin.js.map +0 -1
- package/dist/expo-babel-plugin.cjs.map +0 -1
- package/dist/expo-babel-plugin.js.map +0 -1
- package/dist/flutter-preview-path.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/nextjs/plugin.cjs.map +0 -1
- package/dist/nextjs/plugin.js.map +0 -1
- package/dist/nextjs-loader.cjs.map +0 -1
- package/dist/nextjs.cjs.map +0 -1
- package/dist/nextjs.js.map +0 -1
- package/dist/nuxt/runtime/identity.js.map +0 -1
- package/dist/nuxt.js.map +0 -1
- package/dist/svelte.js.map +0 -1
- package/dist/types-C8OIU-kc.d.ts +0 -106
- package/dist/v1-client-compat-qxaXEDm_.d.ts +0 -23
- package/dist/vue.js.map +0 -1
package/dist/assets/index.js
CHANGED
|
@@ -1,338 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
captureAssetPreview
|
|
3
|
-
} from "../chunk-ZT7HJ6YU.js";
|
|
4
|
-
import {
|
|
5
|
-
UNRESOLVED_VALUE
|
|
6
|
-
} from "../chunk-DI2ZFAWL.js";
|
|
7
|
-
import "../chunk-I7VF4ZOV.js";
|
|
8
|
-
import "../chunk-T364NBR3.js";
|
|
9
|
-
|
|
10
|
-
// assets/controls.ts
|
|
11
|
-
function normalizeAssetControl(control) {
|
|
12
|
-
return control && (control.type === "radio" || control.type === "inline-radio") ? { ...control, type: "select" } : control;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// assets/prop-overrides.ts
|
|
16
|
-
function applyPropOverrides(props, edits) {
|
|
17
|
-
const result = { ...props };
|
|
18
|
-
for (const [name, value] of Object.entries(edits ?? {})) {
|
|
19
|
-
if (value && typeof value === "object" && Object.keys(value).length === 1 && value.__tempo_omit_prop__ === true) {
|
|
20
|
-
delete result[name];
|
|
21
|
-
} else
|
|
22
|
-
Object.defineProperty(result, name, {
|
|
23
|
-
value,
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// assets/live-preview.tsx
|
|
33
|
-
import {
|
|
34
|
-
Component,
|
|
35
|
-
createElement,
|
|
36
|
-
useEffect,
|
|
37
|
-
useLayoutEffect,
|
|
38
|
-
useRef,
|
|
39
|
-
useState
|
|
40
|
-
} from "react";
|
|
41
|
-
|
|
42
|
-
// assets/snapshot.ts
|
|
43
|
-
function snapshot(value) {
|
|
44
|
-
function copy(value2, seen, depth) {
|
|
45
|
-
if (value2 === null || typeof value2 === "string" || typeof value2 === "boolean")
|
|
46
|
-
return value2;
|
|
47
|
-
if (typeof value2 === "number")
|
|
48
|
-
return Number.isFinite(value2) ? value2 : UNRESOLVED_VALUE;
|
|
49
|
-
if (!value2 || typeof value2 !== "object" || depth > 16 || seen.has(value2))
|
|
50
|
-
return UNRESOLVED_VALUE;
|
|
51
|
-
if (!Array.isArray(value2) && Object.getPrototypeOf(value2) !== Object.prototype && Object.getPrototypeOf(value2) !== null)
|
|
52
|
-
return UNRESOLVED_VALUE;
|
|
53
|
-
if ("$$typeof" in value2) return UNRESOLVED_VALUE;
|
|
54
|
-
const next = new Set(seen).add(value2);
|
|
55
|
-
if (Array.isArray(value2))
|
|
56
|
-
return value2.map((item) => copy(item, next, depth + 1));
|
|
57
|
-
return Object.fromEntries(
|
|
58
|
-
Object.entries(value2).map(([key, child]) => [
|
|
59
|
-
key,
|
|
60
|
-
copy(child, next, depth + 1)
|
|
61
|
-
])
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
return copy(value, /* @__PURE__ */ new Set(), 0);
|
|
65
|
-
}
|
|
66
|
-
function getComponentControlsSnapshot(component) {
|
|
67
|
-
return snapshot(getComponentControls(component));
|
|
68
|
-
}
|
|
69
|
-
function getAssetConfigSnapshot(component) {
|
|
70
|
-
return snapshot({
|
|
71
|
-
asset: getAssetConfig(component),
|
|
72
|
-
...getComponentControls(component)
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// assets/live-preview.tsx
|
|
77
|
-
import { jsx } from "react/jsx-runtime";
|
|
78
|
-
var ASSET_PREVIEW_MESSAGE = "tempo:asset-live-preview";
|
|
79
|
-
var PreviewBoundary = class extends Component {
|
|
80
|
-
constructor() {
|
|
81
|
-
super(...arguments);
|
|
82
|
-
this.state = {
|
|
83
|
-
error: null,
|
|
84
|
-
update: null
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
static getDerivedStateFromProps(props, state) {
|
|
88
|
-
return props.update !== state.update ? { update: props.update, error: null } : null;
|
|
89
|
-
}
|
|
90
|
-
static getDerivedStateFromError(error) {
|
|
91
|
-
return { error: error.message };
|
|
92
|
-
}
|
|
93
|
-
render() {
|
|
94
|
-
return this.state.error ? /* @__PURE__ */ jsx("p", { role: "alert", style: { padding: 12, fontSize: 12 }, children: this.state.error }) : this.props.children;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
function AssetLivePreview({
|
|
98
|
-
component,
|
|
99
|
-
sessionId
|
|
100
|
-
}) {
|
|
101
|
-
const [update, setUpdate] = useState({
|
|
102
|
-
variant: null,
|
|
103
|
-
edits: {}
|
|
104
|
-
});
|
|
105
|
-
const peer = useRef(null);
|
|
106
|
-
const viewport = useRef(null);
|
|
107
|
-
const contentRoot = useRef(null);
|
|
108
|
-
const [fit, setFit] = useState({ width: 0, height: 0, scale: 1 });
|
|
109
|
-
const boundary = useRef(null);
|
|
110
|
-
const [captureRequest, setCaptureRequest] = useState(null);
|
|
111
|
-
const lastMetadata = useRef("");
|
|
112
|
-
useLayoutEffect(() => {
|
|
113
|
-
const frame = viewport.current;
|
|
114
|
-
const content2 = contentRoot.current;
|
|
115
|
-
const measure = () => {
|
|
116
|
-
const width = content2.offsetWidth;
|
|
117
|
-
const height = content2.offsetHeight;
|
|
118
|
-
const scale = Math.min(
|
|
119
|
-
1,
|
|
120
|
-
Math.max(0, frame.clientWidth - 32) / (width || 1),
|
|
121
|
-
Math.max(0, frame.clientHeight - 32) / (height || 1)
|
|
122
|
-
);
|
|
123
|
-
setFit(
|
|
124
|
-
(previous) => previous.width === width && previous.height === height && previous.scale === scale ? previous : { width, height, scale }
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
measure();
|
|
128
|
-
const observer = new ResizeObserver(measure);
|
|
129
|
-
observer.observe(frame);
|
|
130
|
-
observer.observe(content2);
|
|
131
|
-
return () => observer.disconnect();
|
|
132
|
-
}, []);
|
|
133
|
-
const publish = () => {
|
|
134
|
-
if (!peer.current) return;
|
|
135
|
-
const metadata = getAssetConfigSnapshot(component);
|
|
136
|
-
const serialized = JSON.stringify(metadata);
|
|
137
|
-
if (lastMetadata.current === serialized) return;
|
|
138
|
-
lastMetadata.current = serialized;
|
|
139
|
-
window.parent.postMessage(
|
|
140
|
-
{
|
|
141
|
-
type: ASSET_PREVIEW_MESSAGE,
|
|
142
|
-
sessionId,
|
|
143
|
-
kind: "metadata",
|
|
144
|
-
metadata,
|
|
145
|
-
captureVersion: 1
|
|
146
|
-
},
|
|
147
|
-
peer.current.origin
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
const publishRef = useRef(publish);
|
|
151
|
-
publishRef.current = publish;
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
const receive = (event) => {
|
|
154
|
-
if (event.source !== window.parent || event.data?.type !== ASSET_PREVIEW_MESSAGE || event.data.sessionId !== sessionId)
|
|
155
|
-
return;
|
|
156
|
-
if (event.data.kind === "connect") {
|
|
157
|
-
peer.current = { origin: event.origin === "null" ? "*" : event.origin };
|
|
158
|
-
lastMetadata.current = "";
|
|
159
|
-
publishRef.current();
|
|
160
|
-
} else if ((event.data.kind === "update" || event.data.kind === "capture") && peer.current) {
|
|
161
|
-
const next = event.data.update;
|
|
162
|
-
if (next && (next.variant === null || typeof next.variant === "string") && next.edits && typeof next.edits === "object" && !Array.isArray(next.edits)) {
|
|
163
|
-
setUpdate(next);
|
|
164
|
-
if (event.data.kind === "capture" && typeof event.data.requestId === "string")
|
|
165
|
-
setCaptureRequest(event.data.requestId);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
window.addEventListener("message", receive);
|
|
170
|
-
window.parent.postMessage(
|
|
171
|
-
{ type: ASSET_PREVIEW_MESSAGE, sessionId, kind: "ready" },
|
|
172
|
-
"*"
|
|
173
|
-
);
|
|
174
|
-
return () => window.removeEventListener("message", receive);
|
|
175
|
-
}, [sessionId]);
|
|
176
|
-
useLayoutEffect(() => {
|
|
177
|
-
if (!captureRequest || !peer.current) return;
|
|
178
|
-
const frame = requestAnimationFrame(() => {
|
|
179
|
-
let snapshot2 = null;
|
|
180
|
-
try {
|
|
181
|
-
if (contentRoot.current && !boundary.current?.state.error)
|
|
182
|
-
snapshot2 = captureAssetPreview(contentRoot.current);
|
|
183
|
-
} catch {
|
|
184
|
-
}
|
|
185
|
-
window.parent.postMessage(
|
|
186
|
-
{
|
|
187
|
-
type: ASSET_PREVIEW_MESSAGE,
|
|
188
|
-
sessionId,
|
|
189
|
-
kind: "captured",
|
|
190
|
-
requestId: captureRequest,
|
|
191
|
-
snapshot: snapshot2
|
|
192
|
-
},
|
|
193
|
-
peer.current.origin
|
|
194
|
-
);
|
|
195
|
-
setCaptureRequest(null);
|
|
196
|
-
});
|
|
197
|
-
return () => cancelAnimationFrame(frame);
|
|
198
|
-
}, [captureRequest, update, sessionId]);
|
|
199
|
-
useEffect(publish);
|
|
200
|
-
const config = getAssetConfig(component);
|
|
201
|
-
const variant = update.variant && Object.prototype.hasOwnProperty.call(config?.variants ?? {}, update.variant) ? config?.variants?.[update.variant] : void 0;
|
|
202
|
-
const render = variant && "render" in variant ? variant.render : void 0;
|
|
203
|
-
const content = update.variant === null ? null : render ? createElement(render) : createElement(
|
|
204
|
-
component,
|
|
205
|
-
applyPropOverrides(variant?.props ?? {}, update.edits)
|
|
206
|
-
);
|
|
207
|
-
return /* @__PURE__ */ jsx(
|
|
208
|
-
"div",
|
|
209
|
-
{
|
|
210
|
-
ref: viewport,
|
|
211
|
-
style: {
|
|
212
|
-
display: "flex",
|
|
213
|
-
alignItems: "center",
|
|
214
|
-
justifyContent: "center",
|
|
215
|
-
overflow: "hidden",
|
|
216
|
-
width: "100%",
|
|
217
|
-
height: "100%",
|
|
218
|
-
padding: 16,
|
|
219
|
-
boxSizing: "border-box"
|
|
220
|
-
},
|
|
221
|
-
children: /* @__PURE__ */ jsx(
|
|
222
|
-
"div",
|
|
223
|
-
{
|
|
224
|
-
style: {
|
|
225
|
-
position: "relative",
|
|
226
|
-
flexShrink: 0,
|
|
227
|
-
width: fit.width * fit.scale,
|
|
228
|
-
height: fit.height * fit.scale
|
|
229
|
-
},
|
|
230
|
-
children: /* @__PURE__ */ jsx(
|
|
231
|
-
"div",
|
|
232
|
-
{
|
|
233
|
-
ref: contentRoot,
|
|
234
|
-
style: {
|
|
235
|
-
position: "absolute",
|
|
236
|
-
top: 0,
|
|
237
|
-
left: 0,
|
|
238
|
-
width: "max-content",
|
|
239
|
-
height: "max-content",
|
|
240
|
-
transform: `scale(${fit.scale})`,
|
|
241
|
-
transformOrigin: "top left"
|
|
242
|
-
},
|
|
243
|
-
children: /* @__PURE__ */ jsx(PreviewBoundary, { ref: boundary, update, children: content })
|
|
244
|
-
}
|
|
245
|
-
)
|
|
246
|
-
}
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// assets/index.ts
|
|
253
|
-
var TEMPO_ASSET_CONFIG_PROPERTY = "__tempoAssetConfig";
|
|
254
|
-
function defineAsset(component, config) {
|
|
255
|
-
try {
|
|
256
|
-
Object.defineProperty(component, TEMPO_ASSET_CONFIG_PROPERTY, {
|
|
257
|
-
value: config,
|
|
258
|
-
enumerable: false,
|
|
259
|
-
configurable: true,
|
|
260
|
-
writable: false
|
|
261
|
-
});
|
|
262
|
-
} catch {
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
function getAssetConfig(component) {
|
|
266
|
-
if (typeof component !== "function" && typeof component !== "object" || component === null) {
|
|
267
|
-
return void 0;
|
|
268
|
-
}
|
|
269
|
-
const config = component[TEMPO_ASSET_CONFIG_PROPERTY];
|
|
270
|
-
return config === void 0 ? config : config;
|
|
271
|
-
}
|
|
272
|
-
var TEMPO_CONTROLS_CONFIG_PROPERTY = "__tempoControlsConfig";
|
|
273
|
-
function defineControls(component, controls) {
|
|
274
|
-
const registration = {
|
|
275
|
-
controls: Object.fromEntries(
|
|
276
|
-
Object.entries(controls).map(([name, control]) => [
|
|
277
|
-
name,
|
|
278
|
-
normalizeAssetControl(control)
|
|
279
|
-
])
|
|
280
|
-
)
|
|
281
|
-
};
|
|
282
|
-
let registrations;
|
|
283
|
-
try {
|
|
284
|
-
const previous = component[TEMPO_CONTROLS_CONFIG_PROPERTY];
|
|
285
|
-
registrations = previous ?? /* @__PURE__ */ new Set();
|
|
286
|
-
registrations.add(registration);
|
|
287
|
-
Object.defineProperty(component, TEMPO_CONTROLS_CONFIG_PROPERTY, {
|
|
288
|
-
value: registrations,
|
|
289
|
-
enumerable: false,
|
|
290
|
-
configurable: true
|
|
291
|
-
});
|
|
292
|
-
} catch {
|
|
293
|
-
return () => {
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
return () => registrations.delete(registration);
|
|
297
|
-
}
|
|
298
|
-
function getComponentControls(component) {
|
|
299
|
-
if (!component || typeof component !== "function" && typeof component !== "object")
|
|
300
|
-
return {};
|
|
301
|
-
const registrations = component[TEMPO_CONTROLS_CONFIG_PROPERTY];
|
|
302
|
-
const astro = component.__tempoAstroControls;
|
|
303
|
-
if (astro && (astro.controls || astro.error)) {
|
|
304
|
-
if (registrations?.size && (!astro.shared || registrations.size > 1))
|
|
305
|
-
return {
|
|
306
|
-
error: "Keep one controls declaration for this Astro component; remove the duplicate shared declaration."
|
|
307
|
-
};
|
|
308
|
-
return {
|
|
309
|
-
...astro,
|
|
310
|
-
...astro.controls && {
|
|
311
|
-
controls: Object.fromEntries(
|
|
312
|
-
Object.entries(astro.controls).map(([name, control]) => [
|
|
313
|
-
name,
|
|
314
|
-
normalizeAssetControl(control)
|
|
315
|
-
])
|
|
316
|
-
)
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
if (!registrations?.size) return {};
|
|
321
|
-
if (registrations.size > 1)
|
|
322
|
-
return {
|
|
323
|
-
error: "Multiple defineControls declarations for this component. Keep one declaration in the component file or tempo/controls.ts; remove the duplicate."
|
|
324
|
-
};
|
|
325
|
-
return registrations.values().next().value ?? {};
|
|
326
|
-
}
|
|
327
|
-
export {
|
|
328
|
-
AssetLivePreview,
|
|
329
|
-
TEMPO_ASSET_CONFIG_PROPERTY,
|
|
330
|
-
TEMPO_CONTROLS_CONFIG_PROPERTY,
|
|
331
|
-
defineAsset,
|
|
332
|
-
defineControls,
|
|
333
|
-
getAssetConfig,
|
|
334
|
-
getAssetConfigSnapshot,
|
|
335
|
-
getComponentControls,
|
|
336
|
-
getComponentControlsSnapshot
|
|
337
|
-
};
|
|
338
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i}from"../chunk-GQIOB5SV.js";import"../chunk-JRJOWLCN.js";import"../chunk-XO2BSHWM.js";import"../chunk-M3GN2KUH.js";import"../chunk-FH6TMWFA.js";import"../chunk-XUSV3KOD.js";export{a as AssetLivePreview,d as TEMPO_ASSET_CONFIG_PROPERTY,g as TEMPO_CONTROLS_CONFIG_PROPERTY,e as defineAsset,h as defineControls,f as getAssetConfig,c as getAssetConfigSnapshot,i as getComponentControls,b as getComponentControlsSnapshot};
|
package/dist/assets/parser.d.ts
CHANGED
|
@@ -1,95 +1,85 @@
|
|
|
1
|
-
import { P as ParsedAssetReference, a as AssetSourceSpan, b as AssetExportKind, c as AssetParseError, d as ParsedAssetFile } from '../types-
|
|
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-
|
|
1
|
+
import { P as ParsedAssetReference, a as AssetSourceSpan, b as AssetExportKind, c as AssetParseError, d as ParsedAssetFile } from '../types-CfUgM2w4.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-CfUgM2w4.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
errors: AssetParseError[];
|
|
9
|
-
}): ParsedAssetFile;
|
|
10
|
-
/**
|
|
11
|
-
* Editor-support: parse and return the raw oxc program. A file with syntax
|
|
12
|
-
* errors returns `program: null` plus structural `unparseable_source` errors
|
|
13
|
-
* — a recovered AST has untrustworthy spans, so both parser and editor fail
|
|
14
|
-
* closed on it.
|
|
15
|
-
*/
|
|
16
|
-
declare function parseAssetProgram(filePath: string, source: string): {
|
|
4
|
+
declare function parseAssetFile$1(
|
|
5
|
+
filePath: string,
|
|
6
|
+
source: string,
|
|
7
|
+
parsed?: {
|
|
17
8
|
program: any | null;
|
|
18
9
|
errors: AssetParseError[];
|
|
10
|
+
},
|
|
11
|
+
): ParsedAssetFile;
|
|
12
|
+
declare function parseAssetProgram$1(
|
|
13
|
+
filePath: string,
|
|
14
|
+
source: string,
|
|
15
|
+
): {
|
|
16
|
+
program: any | null;
|
|
17
|
+
errors: AssetParseError[];
|
|
19
18
|
};
|
|
20
|
-
/** One comment's text (delimiters stripped) and source span. */
|
|
21
19
|
type SourceComment = {
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
value: string;
|
|
21
|
+
span: AssetSourceSpan;
|
|
24
22
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* from a broken AST are untrustworthy, so callers must treat the file as
|
|
30
|
-
* uninspectable rather than comment-free.
|
|
31
|
-
*/
|
|
32
|
-
declare function readSourceComments(filePath: string, source: string): SourceComment[] | null;
|
|
23
|
+
declare function readSourceComments$1(
|
|
24
|
+
filePath: string,
|
|
25
|
+
source: string,
|
|
26
|
+
): SourceComment[] | null;
|
|
33
27
|
type AssetImportInfo = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* Namespace imports are excluded — they cannot name one component. */
|
|
44
|
-
referenceableImports: Map<string, ParsedAssetReference>;
|
|
45
|
-
/** Span of every import declaration, in source order (editor placement). */
|
|
46
|
-
importDeclarationSpans: AssetSourceSpan[];
|
|
47
|
-
/** `defineAsset` imports using a wrong tempo-sdk-family specifier. The span
|
|
48
|
-
* covers the source string literal, quotes included. */
|
|
49
|
-
misimports: {
|
|
50
|
-
source: string;
|
|
51
|
-
span: AssetSourceSpan;
|
|
52
|
-
}[];
|
|
28
|
+
trustedDefineControlsNames?: Set<string>;
|
|
29
|
+
trustedDefineAssetNames: Set<string>;
|
|
30
|
+
importedBindings: Map<string, string>;
|
|
31
|
+
referenceableImports: Map<string, ParsedAssetReference>;
|
|
32
|
+
importDeclarationSpans: AssetSourceSpan[];
|
|
33
|
+
misimports: {
|
|
34
|
+
source: string;
|
|
35
|
+
span: AssetSourceSpan;
|
|
36
|
+
}[];
|
|
53
37
|
};
|
|
54
|
-
declare function readAssetImports(program: any): AssetImportInfo;
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
declare function readAssetImports$1(program: any): AssetImportInfo;
|
|
39
|
+
declare function parseControlsFile$1(
|
|
40
|
+
filePath: string,
|
|
41
|
+
source: string,
|
|
42
|
+
parsed?: {
|
|
57
43
|
program: any | null;
|
|
58
44
|
errors: AssetParseError[];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
45
|
+
},
|
|
46
|
+
): {
|
|
47
|
+
bindingName: string;
|
|
48
|
+
reference?: ParsedAssetReference;
|
|
49
|
+
exportKind: AssetExportKind;
|
|
50
|
+
start: number;
|
|
51
|
+
end: number;
|
|
65
52
|
}[];
|
|
66
53
|
type AssetTopLevelBinding = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
statementSpan: AssetSourceSpan;
|
|
71
|
-
exportKind: AssetExportKind;
|
|
54
|
+
name: string;
|
|
55
|
+
statementSpan: AssetSourceSpan;
|
|
56
|
+
exportKind: AssetExportKind;
|
|
72
57
|
};
|
|
73
58
|
type AssetTopLevelScope = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
bindings: Map<string, AssetTopLevelBinding>;
|
|
77
|
-
/** Top-level names bound only via destructuring patterns or uninitialized
|
|
78
|
-
* declarators — they exist, but defineAsset cannot target them; kept so
|
|
79
|
-
* error messages can say why. */
|
|
80
|
-
nonSimpleNames: Set<string>;
|
|
59
|
+
bindings: Map<string, AssetTopLevelBinding>;
|
|
60
|
+
nonSimpleNames: Set<string>;
|
|
81
61
|
};
|
|
82
|
-
declare function collectTopLevelScope(program: any): AssetTopLevelScope;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
declare function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
declare
|
|
93
|
-
declare
|
|
62
|
+
declare function collectTopLevelScope$1(program: any): AssetTopLevelScope;
|
|
63
|
+
declare function hasTopLevelDefineAssetCallFor$1(
|
|
64
|
+
program: any,
|
|
65
|
+
trustedNames: Set<string>,
|
|
66
|
+
bindingName: string,
|
|
67
|
+
): boolean;
|
|
68
|
+
declare function collectIdentifierNames$1(program: any): Set<string>;
|
|
69
|
+
declare function unwrapTsExpression$1(node: any): any;
|
|
70
|
+
declare function toSourceSpan$1(node: any): AssetSourceSpan | undefined;
|
|
71
|
+
|
|
72
|
+
declare const parseAssetFile: typeof parseAssetFile$1;
|
|
73
|
+
declare const parseAssetProgram: typeof parseAssetProgram$1;
|
|
74
|
+
declare const readSourceComments: typeof readSourceComments$1;
|
|
75
|
+
declare const readAssetImports: typeof readAssetImports$1;
|
|
76
|
+
declare const parseControlsFile: typeof parseControlsFile$1;
|
|
77
|
+
declare const collectTopLevelScope: typeof collectTopLevelScope$1;
|
|
78
|
+
declare const hasTopLevelDefineAssetCallFor: typeof hasTopLevelDefineAssetCallFor$1;
|
|
79
|
+
declare const collectIdentifierNames: typeof collectIdentifierNames$1;
|
|
80
|
+
declare const unwrapTsExpression: typeof unwrapTsExpression$1;
|
|
81
|
+
declare const toSourceSpan: typeof toSourceSpan$1;
|
|
82
|
+
|
|
83
|
+
declare const ASSET_SDK_IMPORT_SOURCE = "tempo-sdk/assets";
|
|
94
84
|
|
|
95
85
|
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 };
|
package/dist/assets/parser.js
CHANGED
|
@@ -1,33 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ASSET_SDK_IMPORT_SOURCE,
|
|
3
|
-
collectIdentifierNames,
|
|
4
|
-
collectTopLevelScope,
|
|
5
|
-
hasTopLevelDefineAssetCallFor,
|
|
6
|
-
parseAssetFile,
|
|
7
|
-
parseAssetProgram,
|
|
8
|
-
parseControlsFile,
|
|
9
|
-
readAssetImports,
|
|
10
|
-
readSourceComments,
|
|
11
|
-
toSourceSpan,
|
|
12
|
-
unwrapTsExpression
|
|
13
|
-
} from "../chunk-PYAJHLXO.js";
|
|
14
|
-
import {
|
|
15
|
-
UNRESOLVED_VALUE,
|
|
16
|
-
isUnresolvedValue
|
|
17
|
-
} from "../chunk-DI2ZFAWL.js";
|
|
18
|
-
export {
|
|
19
|
-
ASSET_SDK_IMPORT_SOURCE,
|
|
20
|
-
UNRESOLVED_VALUE,
|
|
21
|
-
collectIdentifierNames,
|
|
22
|
-
collectTopLevelScope,
|
|
23
|
-
hasTopLevelDefineAssetCallFor,
|
|
24
|
-
isUnresolvedValue,
|
|
25
|
-
parseAssetFile,
|
|
26
|
-
parseAssetProgram,
|
|
27
|
-
parseControlsFile,
|
|
28
|
-
readAssetImports,
|
|
29
|
-
readSourceComments,
|
|
30
|
-
toSourceSpan,
|
|
31
|
-
unwrapTsExpression
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=parser.js.map
|
|
1
|
+
import{b as e}from"../chunk-QNVQ7U2W.js";import{a as s,b as t}from"../chunk-JRJOWLCN.js";import"../chunk-XUSV3KOD.js";var r=e("assets/parser","parseAssetFile"),a=e("assets/parser","parseAssetProgram"),p=e("assets/parser","readSourceComments"),n=e("assets/parser","readAssetImports"),c=e("assets/parser","parseControlsFile"),l=e("assets/parser","collectTopLevelScope"),m=e("assets/parser","hasTopLevelDefineAssetCallFor"),i=e("assets/parser","collectIdentifierNames"),C=e("assets/parser","unwrapTsExpression"),f=e("assets/parser","toSourceSpan"),x="tempo-sdk/assets";export{x as ASSET_SDK_IMPORT_SOURCE,s as UNRESOLVED_VALUE,i as collectIdentifierNames,l as collectTopLevelScope,m as hasTopLevelDefineAssetCallFor,t as isUnresolvedValue,r as parseAssetFile,a as parseAssetProgram,c as parseControlsFile,n as readAssetImports,p as readSourceComments,f as toSourceSpan,C as unwrapTsExpression};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare function startAstroAssetPreview$1(): void;
|
|
2
|
+
|
|
3
|
+
declare const startAstroAssetPreview: typeof startAstroAssetPreview$1;
|
|
3
4
|
|
|
4
5
|
export { startAstroAssetPreview };
|
|
@@ -1,93 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
captureAssetPreview
|
|
3
|
-
} from "../chunk-ZT7HJ6YU.js";
|
|
4
|
-
import "../chunk-I7VF4ZOV.js";
|
|
5
|
-
import "../chunk-T364NBR3.js";
|
|
6
|
-
|
|
7
|
-
// astro/asset-preview-client.ts
|
|
8
|
-
var messageType = "tempo:asset-live-preview";
|
|
9
|
-
function startAstroAssetPreview() {
|
|
10
|
-
const meta = document.querySelector(
|
|
11
|
-
'meta[name="tempo-astro-asset-preview"]'
|
|
12
|
-
);
|
|
13
|
-
if (!meta) return;
|
|
14
|
-
const { sessionId, metadata } = JSON.parse(meta.content);
|
|
15
|
-
let peer;
|
|
16
|
-
const send = (kind, detail = {}) => window.parent.postMessage(
|
|
17
|
-
{ type: messageType, sessionId, kind, ...detail },
|
|
18
|
-
peer ?? "*"
|
|
19
|
-
);
|
|
20
|
-
const captureKey = `tempo:astro-capture:${sessionId}`;
|
|
21
|
-
async function capture(requestId) {
|
|
22
|
-
await document.fonts.ready;
|
|
23
|
-
await Promise.all(
|
|
24
|
-
[...document.images].map((image) => image.decode().catch(() => {
|
|
25
|
-
}))
|
|
26
|
-
);
|
|
27
|
-
const deadline = performance.now() + 1e4;
|
|
28
|
-
while (document.querySelector("script[data-island-id]") || [...document.querySelectorAll("astro-island[ssr]")].some((island) => {
|
|
29
|
-
const client = island.getAttribute("client");
|
|
30
|
-
if (client === "media") {
|
|
31
|
-
try {
|
|
32
|
-
return matchMedia(
|
|
33
|
-
JSON.parse(island.getAttribute("opts") ?? "{}").value
|
|
34
|
-
).matches;
|
|
35
|
-
} catch {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (client === "visible")
|
|
40
|
-
return [...island.children].some((child) => {
|
|
41
|
-
const rect = child.getBoundingClientRect();
|
|
42
|
-
return rect.bottom > 0 && rect.right > 0 && rect.top < innerHeight && rect.left < innerWidth && (rect.width > 0 || rect.height > 0);
|
|
43
|
-
});
|
|
44
|
-
return true;
|
|
45
|
-
})) {
|
|
46
|
-
if (performance.now() > deadline) {
|
|
47
|
-
send("captured", { requestId, snapshot: null });
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
await new Promise(requestAnimationFrame);
|
|
51
|
-
}
|
|
52
|
-
await new Promise(requestAnimationFrame);
|
|
53
|
-
send("captured", {
|
|
54
|
-
requestId,
|
|
55
|
-
snapshot: captureAssetPreview(document.body)
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
window.addEventListener("message", (event) => {
|
|
59
|
-
const data = event.data;
|
|
60
|
-
if (event.source !== window.parent || data?.type !== messageType || data.sessionId !== sessionId)
|
|
61
|
-
return;
|
|
62
|
-
if (data.kind === "connect") {
|
|
63
|
-
peer = event.origin === "null" ? "*" : event.origin;
|
|
64
|
-
send("metadata", { metadata, captureVersion: 1 });
|
|
65
|
-
const pending = sessionStorage.getItem(captureKey);
|
|
66
|
-
if (pending) {
|
|
67
|
-
sessionStorage.removeItem(captureKey);
|
|
68
|
-
void capture(pending);
|
|
69
|
-
}
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (!peer || peer !== "*" && event.origin !== peer || !["update", "capture"].includes(data.kind))
|
|
73
|
-
return;
|
|
74
|
-
const update = data.update;
|
|
75
|
-
if (!update || !(update.variant === null || typeof update.variant === "string") || !update.edits || typeof update.edits !== "object" || Array.isArray(update.edits))
|
|
76
|
-
return;
|
|
77
|
-
const json = JSON.stringify(update);
|
|
78
|
-
if (json.length > 64e3) return;
|
|
79
|
-
const url = new URL(location.href);
|
|
80
|
-
if (url.searchParams.get("__tempo_asset_update") !== json) {
|
|
81
|
-
if (data.kind === "capture" && typeof data.requestId === "string")
|
|
82
|
-
sessionStorage.setItem(captureKey, data.requestId);
|
|
83
|
-
url.searchParams.set("__tempo_asset_update", json);
|
|
84
|
-
location.replace(url);
|
|
85
|
-
} else if (data.kind === "capture" && typeof data.requestId === "string")
|
|
86
|
-
void capture(data.requestId);
|
|
87
|
-
});
|
|
88
|
-
send("ready");
|
|
89
|
-
}
|
|
90
|
-
export {
|
|
91
|
-
startAstroAssetPreview
|
|
92
|
-
};
|
|
93
|
-
//# sourceMappingURL=asset-preview-client.js.map
|
|
1
|
+
import{a as e}from"../chunk-MPIHFFML.js";import"../chunk-XO2BSHWM.js";import{a as t}from"../chunk-XUSV3KOD.js";var o=t(((...r)=>e("astro/asset-preview-client").startAstroAssetPreview(...r)),"startAstroAssetPreview");export{o as startAstroAssetPreview};
|
package/dist/astro/controls.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { A as AssetControls } from '../controls-
|
|
1
|
+
import { A as AssetControls } from '../controls-DKslABtM.js';
|
|
2
2
|
|
|
3
|
-
/** Describe this Astro file's props. Tempo reads this declaration statically;
|
|
4
|
-
* it never executes the component frontmatter to discover controls. */
|
|
5
3
|
declare function defineAstroControls<Props extends object>(_controls: AssetControls<Props>): void;
|
|
6
4
|
|
|
7
5
|
export { defineAstroControls };
|
package/dist/astro/controls.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ViteHotContext } from 'vite/types/hot.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
declare
|
|
8
|
-
declare function startAstroDocumentClient(hot: ViteHotContext | undefined): void;
|
|
3
|
+
declare function needsAstroDocumentReload$1(document: Document, paths: readonly string[]): boolean;
|
|
4
|
+
declare function startAstroDocumentClient$1(hot: ViteHotContext | undefined): void;
|
|
5
|
+
|
|
6
|
+
declare const needsAstroDocumentReload: typeof needsAstroDocumentReload$1;
|
|
7
|
+
declare const startAstroDocumentClient: typeof startAstroDocumentClient$1;
|
|
9
8
|
|
|
10
9
|
export { needsAstroDocumentReload, startAstroDocumentClient };
|