tempo-sdk 0.0.60 → 0.0.69
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/astro/client.d.ts +4 -0
- package/dist/assets/editor.js +1 -1
- package/dist/assets/index.d.ts +10 -63
- package/dist/assets/index.js +35 -33
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/parser.js +1 -1
- package/dist/astro/asset-preview-client.d.ts +4 -0
- package/dist/astro/asset-preview-client.js +93 -0
- package/dist/astro/asset-preview-client.js.map +1 -0
- package/dist/astro/controls.d.ts +7 -0
- package/dist/astro/controls.js +7 -0
- package/dist/astro/controls.js.map +1 -0
- package/dist/astro/document-client.d.ts +10 -0
- package/dist/astro/document-client.js +78 -0
- package/dist/astro/document-client.js.map +1 -0
- package/dist/astro/runtime.d.ts +15 -0
- package/dist/astro/runtime.js +86 -0
- package/dist/astro/runtime.js.map +1 -0
- package/dist/astro.d.ts +21 -0
- package/dist/astro.js +808 -0
- package/dist/astro.js.map +1 -0
- package/dist/canvas/astro-contract.d.ts +21 -0
- package/dist/canvas/astro-contract.js +9 -0
- package/dist/canvas/astro-contract.js.map +1 -0
- package/dist/canvas/astro.d.ts +18 -0
- package/dist/canvas/astro.js +42 -0
- package/dist/canvas/astro.js.map +1 -0
- package/dist/canvas/editor.d.ts +1 -1
- package/dist/canvas/editor.js +3 -2
- package/dist/canvas/editor.js.map +1 -1
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/index.js +40 -16
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +4 -4
- package/dist/canvas/parser.d.ts +3 -1
- package/dist/canvas/parser.js +1 -1
- package/dist/canvas/svelte.d.ts +1 -1
- package/dist/canvas/svelte.js +3 -3
- package/dist/{chunk-5BHIHP25.js → chunk-2JRAG36X.js} +37 -11
- package/dist/chunk-2JRAG36X.js.map +1 -0
- package/dist/{chunk-N2TYN3RB.js → chunk-6AAE4LYV.js} +123 -123
- package/dist/chunk-6AAE4LYV.js.map +1 -0
- package/dist/{chunk-FQSZRVSL.js → chunk-6BSLP7P3.js} +46 -5
- package/dist/chunk-6BSLP7P3.js.map +1 -0
- package/dist/{chunk-7DT5DDSH.js → chunk-6IR5JY6W.js} +106 -7
- package/dist/chunk-6IR5JY6W.js.map +1 -0
- package/dist/chunk-77DZCV5Z.js +38 -0
- package/dist/chunk-77DZCV5Z.js.map +1 -0
- package/dist/{chunk-MXKZZOLM.js → chunk-EYKOOLPL.js} +368 -32
- package/dist/chunk-EYKOOLPL.js.map +1 -0
- package/dist/chunk-F23JGM4U.js +107 -0
- package/dist/chunk-F23JGM4U.js.map +1 -0
- package/dist/chunk-FE6TYCLF.js +1514 -0
- package/dist/chunk-FE6TYCLF.js.map +1 -0
- package/dist/chunk-H6OZIX2U.js +133 -0
- package/dist/chunk-H6OZIX2U.js.map +1 -0
- package/dist/chunk-JVVHU3A7.js +1077 -0
- package/dist/chunk-JVVHU3A7.js.map +1 -0
- package/dist/{chunk-2IQD2KPS.js → chunk-KOSJXE4G.js} +3 -102
- package/dist/chunk-KOSJXE4G.js.map +1 -0
- package/dist/{chunk-TL4MGN7E.js → chunk-NSKYOKG5.js} +254 -10
- package/dist/chunk-NSKYOKG5.js.map +1 -0
- package/dist/chunk-OX2YKYSL.js +13 -0
- package/dist/chunk-OX2YKYSL.js.map +1 -0
- package/dist/{chunk-VMTQDG4U.js → chunk-PXDTH36X.js} +12 -10
- package/dist/chunk-PXDTH36X.js.map +1 -0
- package/dist/{chunk-XLEKCOB7.js → chunk-PYAJHLXO.js} +56 -1
- package/dist/chunk-PYAJHLXO.js.map +1 -0
- package/dist/{chunk-OTVBSF7U.js → chunk-Q2A46HHW.js} +17 -12
- package/dist/chunk-Q2A46HHW.js.map +1 -0
- package/dist/chunk-WTQQOLXM.js +2495 -0
- package/dist/chunk-WTQQOLXM.js.map +1 -0
- package/dist/controls-reader-SNMI2UY7.js +191 -0
- package/dist/controls-reader-SNMI2UY7.js.map +1 -0
- package/dist/controls-uCaQ3CNX.d.ts +61 -0
- package/dist/expo/plugin.cjs +16 -11
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +16 -11
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -2465
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.cjs +45 -4
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +61 -15
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +45 -4
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.d.cts +4 -4
- package/dist/nextjs.d.ts +4 -4
- package/dist/nextjs.js +1 -1
- package/dist/{storyboard-DjOF61B_.d.ts → storyboard-4YdTYq_e.d.ts} +1 -1
- package/dist/svelte.js +7 -1075
- package/dist/svelte.js.map +1 -1
- package/package.json +45 -4
- package/dist/chunk-2IQD2KPS.js.map +0 -1
- package/dist/chunk-5BHIHP25.js.map +0 -1
- package/dist/chunk-7DT5DDSH.js.map +0 -1
- package/dist/chunk-FQSZRVSL.js.map +0 -1
- package/dist/chunk-MXKZZOLM.js.map +0 -1
- package/dist/chunk-N2TYN3RB.js.map +0 -1
- package/dist/chunk-OTVBSF7U.js.map +0 -1
- package/dist/chunk-TL4MGN7E.js.map +0 -1
- package/dist/chunk-VMTQDG4U.js.map +0 -1
- package/dist/chunk-XLEKCOB7.js.map +0 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseAstroSource,
|
|
3
|
+
readAstroControls
|
|
4
|
+
} from "./chunk-FE6TYCLF.js";
|
|
5
|
+
import "./chunk-JVVHU3A7.js";
|
|
6
|
+
import "./chunk-H6OZIX2U.js";
|
|
7
|
+
import "./chunk-KOSJXE4G.js";
|
|
8
|
+
|
|
9
|
+
// astro/controls-reader.ts
|
|
10
|
+
import { existsSync, readFileSync } from "fs";
|
|
11
|
+
import { parseSync } from "oxc-parser";
|
|
12
|
+
async function readAstroControlsMetadata(file, resolve, watch, sharedFiles = []) {
|
|
13
|
+
const dependencies = /* @__PURE__ */ new Set([file]);
|
|
14
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
15
|
+
const values = /* @__PURE__ */ new Map();
|
|
16
|
+
const overlays = /* @__PURE__ */ new Map();
|
|
17
|
+
const read = async (path, exportName) => {
|
|
18
|
+
const key = `${path}#${exportName ?? "controls"}`;
|
|
19
|
+
if (visiting.has(key) || visiting.size > 16)
|
|
20
|
+
return {
|
|
21
|
+
kind: "error",
|
|
22
|
+
message: "Controls have cyclic or excessively deep imports"
|
|
23
|
+
};
|
|
24
|
+
visiting.add(key);
|
|
25
|
+
try {
|
|
26
|
+
dependencies.add(path);
|
|
27
|
+
watch(path);
|
|
28
|
+
let source = overlays.get(path) ?? readFileSync(path, "utf8");
|
|
29
|
+
if (exportName !== void 0) {
|
|
30
|
+
if (path.endsWith(".astro")) {
|
|
31
|
+
const astro = parseAstroSource(source);
|
|
32
|
+
if (astro.kind !== "ok" || !astro.frontmatter)
|
|
33
|
+
return {
|
|
34
|
+
kind: "error",
|
|
35
|
+
message: "This Astro file has no static exported constant"
|
|
36
|
+
};
|
|
37
|
+
source = source.slice(
|
|
38
|
+
astro.frontmatter.contentStart,
|
|
39
|
+
astro.frontmatter.contentEnd
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const parsed = parseSync(
|
|
43
|
+
path.endsWith(".astro") ? `${path}.ts` : path,
|
|
44
|
+
source
|
|
45
|
+
);
|
|
46
|
+
if (parsed.errors.length)
|
|
47
|
+
return {
|
|
48
|
+
kind: "error",
|
|
49
|
+
message: "Controls dependency cannot be parsed"
|
|
50
|
+
};
|
|
51
|
+
let expression;
|
|
52
|
+
for (const statement of parsed.program.body) {
|
|
53
|
+
if (statement.type === "ExportDefaultDeclaration" && exportName === "default")
|
|
54
|
+
expression = source.slice(
|
|
55
|
+
statement.declaration.start,
|
|
56
|
+
statement.declaration.end
|
|
57
|
+
);
|
|
58
|
+
if (statement.type !== "ExportNamedDeclaration") continue;
|
|
59
|
+
const declaration = statement.declaration;
|
|
60
|
+
if (declaration?.type === "VariableDeclaration" && declaration.kind === "const") {
|
|
61
|
+
for (const binding2 of declaration.declarations)
|
|
62
|
+
if (binding2.id.type === "Identifier" && binding2.id.name === exportName)
|
|
63
|
+
expression = exportName;
|
|
64
|
+
}
|
|
65
|
+
for (const specifier of statement.specifiers) {
|
|
66
|
+
const name = specifier.exported.type === "Identifier" ? specifier.exported.name : specifier.exported.value;
|
|
67
|
+
if (name !== exportName) continue;
|
|
68
|
+
const local = specifier.local.type === "Identifier" ? specifier.local.name : specifier.local.value;
|
|
69
|
+
if (statement.source) {
|
|
70
|
+
const target = await resolve(statement.source.value, path);
|
|
71
|
+
return target ? await read(target, local) : {
|
|
72
|
+
kind: "error",
|
|
73
|
+
message: `Cannot resolve ${statement.source.value}`
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
expression = local;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!expression)
|
|
80
|
+
return {
|
|
81
|
+
kind: "error",
|
|
82
|
+
message: `${exportName} is not a static exported constant`
|
|
83
|
+
};
|
|
84
|
+
let binding = "__tempoReadControls";
|
|
85
|
+
while (source.includes(binding)) binding += "_";
|
|
86
|
+
source = `---
|
|
87
|
+
import { defineAstroControls as ${binding} } from "tempo-sdk/astro/controls";
|
|
88
|
+
${source}
|
|
89
|
+
${binding}({value: ${expression}});
|
|
90
|
+
---`;
|
|
91
|
+
}
|
|
92
|
+
for (let attempt = 0; attempt < 64; attempt++) {
|
|
93
|
+
let missing;
|
|
94
|
+
const result2 = readAstroControls(source, (specifier, name) => {
|
|
95
|
+
const cacheKey = `${path}:${specifier}#${name}`;
|
|
96
|
+
if (values.has(cacheKey)) return values.get(cacheKey);
|
|
97
|
+
missing ?? (missing = { specifier, name });
|
|
98
|
+
return void 0;
|
|
99
|
+
});
|
|
100
|
+
if (!missing) return result2;
|
|
101
|
+
const target = await resolve(missing.specifier, path);
|
|
102
|
+
if (!target || target.startsWith("\0"))
|
|
103
|
+
return {
|
|
104
|
+
kind: "error",
|
|
105
|
+
message: `Cannot statically read controls import ${missing.specifier}`
|
|
106
|
+
};
|
|
107
|
+
const dependency = await read(target, missing.name);
|
|
108
|
+
if (dependency.kind === "error") return dependency;
|
|
109
|
+
values.set(
|
|
110
|
+
`${path}:${missing.specifier}#${missing.name}`,
|
|
111
|
+
dependency.controls.value
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
kind: "error",
|
|
116
|
+
message: "Controls exceed the static dependency budget"
|
|
117
|
+
};
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
kind: "error",
|
|
121
|
+
message: error instanceof Error ? error.message : String(error)
|
|
122
|
+
};
|
|
123
|
+
} finally {
|
|
124
|
+
visiting.delete(key);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
let result = await read(file), shared = false;
|
|
128
|
+
try {
|
|
129
|
+
for (const path of new Set(sharedFiles)) {
|
|
130
|
+
watch(path);
|
|
131
|
+
dependencies.add(path);
|
|
132
|
+
if (!existsSync(path)) continue;
|
|
133
|
+
const source = readFileSync(path, "utf8"), parsed = parseSync(path, source);
|
|
134
|
+
if (parsed.errors.length)
|
|
135
|
+
throw new Error("Shared component controls cannot be parsed");
|
|
136
|
+
const trusted = /* @__PURE__ */ new Set(), components = /* @__PURE__ */ new Set();
|
|
137
|
+
for (const statement of parsed.program.body)
|
|
138
|
+
if (statement.type === "ImportDeclaration") {
|
|
139
|
+
for (const binding2 of statement.specifiers) {
|
|
140
|
+
if (statement.source.value === "tempo-sdk/assets" && binding2.type === "ImportSpecifier" && (binding2.imported.type === "Identifier" ? binding2.imported.name : binding2.imported.value) === "defineControls")
|
|
141
|
+
trusted.add(binding2.local.name);
|
|
142
|
+
if (binding2.type === "ImportDefaultSpecifier" && statement.source.value.endsWith(".astro?tempo-component")) {
|
|
143
|
+
const physical = await resolve(
|
|
144
|
+
statement.source.value.replace(/\?tempo-component$/, ""),
|
|
145
|
+
path
|
|
146
|
+
);
|
|
147
|
+
if (physical === file) components.add(binding2.local.name);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const declarations = parsed.program.body.flatMap((statement) => {
|
|
152
|
+
const expression = statement.type === "ExpressionStatement" ? statement.expression : null;
|
|
153
|
+
return expression?.type === "CallExpression" && expression.callee.type === "Identifier" && trusted.has(expression.callee.name) && expression.arguments[0]?.type === "Identifier" && components.has(expression.arguments[0].name) ? [expression] : [];
|
|
154
|
+
});
|
|
155
|
+
if (!declarations.length) continue;
|
|
156
|
+
if (declarations.length > 1 || result.kind === "ok" && result.declared)
|
|
157
|
+
throw new Error(
|
|
158
|
+
"Keep one controls declaration for this Astro component; remove the duplicate shared declaration"
|
|
159
|
+
);
|
|
160
|
+
if (result.kind === "error") break;
|
|
161
|
+
const argument = declarations[0].arguments[1];
|
|
162
|
+
if (!argument)
|
|
163
|
+
throw new Error("defineControls requires a controls object");
|
|
164
|
+
let binding = "__tempoReadSharedControls";
|
|
165
|
+
while (source.includes(binding)) binding += "_";
|
|
166
|
+
overlays.set(
|
|
167
|
+
path,
|
|
168
|
+
`---
|
|
169
|
+
import {defineAstroControls as ${binding}} from "tempo-sdk/astro/controls";
|
|
170
|
+
${source}
|
|
171
|
+
${binding}(${source.slice(argument.start, argument.end)});
|
|
172
|
+
---`
|
|
173
|
+
);
|
|
174
|
+
result = await read(path);
|
|
175
|
+
shared = true;
|
|
176
|
+
}
|
|
177
|
+
} catch (error) {
|
|
178
|
+
result = {
|
|
179
|
+
kind: "error",
|
|
180
|
+
message: error instanceof Error ? error.message : String(error)
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return result.kind === "ok" ? {
|
|
184
|
+
...result.declared ? { controls: result.controls, ...shared ? { shared: true } : {} } : {},
|
|
185
|
+
dependencies: [...dependencies]
|
|
186
|
+
} : { error: result.message, dependencies: [...dependencies] };
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
readAstroControlsMetadata
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=controls-reader-SNMI2UY7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../astro/controls-reader.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { parseSync } from \"oxc-parser\";\nimport {\n parseAstroSource,\n readAstroControls,\n type AstroLiteral,\n} from \"@modules/astro-editor\";\n\n/** Resolve only the constants referenced by controls. No dynamic import or SSR execution. */\nexport async function readAstroControlsMetadata(\n file: string,\n resolve: (specifier: string, importer: string) => Promise<string | null>,\n watch: (file: string) => void,\n sharedFiles: string[] = [],\n) {\n const dependencies = new Set<string>([file]);\n const visiting = new Set<string>();\n const values = new Map<string, AstroLiteral>();\n const overlays = new Map<string, string>();\n const read = async (\n path: string,\n exportName?: string,\n ): Promise<ReturnType<typeof readAstroControls>> => {\n const key = `${path}#${exportName ?? \"controls\"}`;\n if (visiting.has(key) || visiting.size > 16)\n return {\n kind: \"error\",\n message: \"Controls have cyclic or excessively deep imports\",\n };\n visiting.add(key);\n try {\n dependencies.add(path);\n watch(path);\n let source = overlays.get(path) ?? readFileSync(path, \"utf8\");\n if (exportName !== undefined) {\n if (path.endsWith(\".astro\")) {\n const astro = parseAstroSource(source);\n if (astro.kind !== \"ok\" || !astro.frontmatter)\n return {\n kind: \"error\",\n message: \"This Astro file has no static exported constant\",\n };\n source = source.slice(\n astro.frontmatter.contentStart,\n astro.frontmatter.contentEnd,\n );\n }\n const parsed = parseSync(\n path.endsWith(\".astro\") ? `${path}.ts` : path,\n source,\n );\n if (parsed.errors.length)\n return {\n kind: \"error\",\n message: \"Controls dependency cannot be parsed\",\n };\n let expression: string | undefined;\n for (const statement of parsed.program.body) {\n if (\n statement.type === \"ExportDefaultDeclaration\" &&\n exportName === \"default\"\n )\n expression = source.slice(\n statement.declaration.start,\n statement.declaration.end,\n );\n if (statement.type !== \"ExportNamedDeclaration\") continue;\n const declaration = statement.declaration;\n if (\n declaration?.type === \"VariableDeclaration\" &&\n declaration.kind === \"const\"\n )\n for (const binding of declaration.declarations)\n if (\n binding.id.type === \"Identifier\" &&\n binding.id.name === exportName\n )\n expression = exportName;\n for (const specifier of statement.specifiers) {\n const name =\n specifier.exported.type === \"Identifier\"\n ? specifier.exported.name\n : specifier.exported.value;\n if (name !== exportName) continue;\n const local =\n specifier.local.type === \"Identifier\"\n ? specifier.local.name\n : specifier.local.value;\n if (statement.source) {\n const target = await resolve(statement.source.value, path);\n return target\n ? await read(target, local)\n : {\n kind: \"error\",\n message: `Cannot resolve ${statement.source.value}`,\n };\n }\n expression = local;\n }\n }\n if (!expression)\n return {\n kind: \"error\",\n message: `${exportName} is not a static exported constant`,\n };\n let binding = \"__tempoReadControls\";\n while (source.includes(binding)) binding += \"_\";\n source = `---\\nimport { defineAstroControls as ${binding} } from \"tempo-sdk/astro/controls\";\\n${source}\\n${binding}({value: ${expression}});\\n---`;\n }\n for (let attempt = 0; attempt < 64; attempt++) {\n let missing: { specifier: string; name: string } | undefined;\n const result = readAstroControls(source, (specifier, name) => {\n const cacheKey = `${path}:${specifier}#${name}`;\n if (values.has(cacheKey)) return values.get(cacheKey);\n missing ??= { specifier, name };\n return undefined;\n });\n if (!missing) return result;\n const target = await resolve(missing.specifier, path);\n if (!target || target.startsWith(\"\\0\"))\n return {\n kind: \"error\",\n message: `Cannot statically read controls import ${missing.specifier}`,\n };\n const dependency = await read(target, missing.name);\n if (dependency.kind === \"error\") return dependency;\n values.set(\n `${path}:${missing.specifier}#${missing.name}`,\n dependency.controls.value!,\n );\n }\n return {\n kind: \"error\",\n message: \"Controls exceed the static dependency budget\",\n };\n } catch (error) {\n return {\n kind: \"error\",\n message: error instanceof Error ? error.message : String(error),\n };\n } finally {\n visiting.delete(key);\n }\n };\n let result = await read(file),\n shared = false;\n try {\n for (const path of new Set(sharedFiles)) {\n // Watch a missing shared file too: adding the first declaration must\n // invalidate a previously unconfigured component descriptor.\n watch(path);\n dependencies.add(path);\n if (!existsSync(path)) continue;\n const source = readFileSync(path, \"utf8\"),\n parsed = parseSync(path, source);\n if (parsed.errors.length)\n throw new Error(\"Shared component controls cannot be parsed\");\n const trusted = new Set<string>(),\n components = new Set<string>();\n for (const statement of parsed.program.body)\n if (statement.type === \"ImportDeclaration\") {\n for (const binding of statement.specifiers) {\n if (\n statement.source.value === \"tempo-sdk/assets\" &&\n binding.type === \"ImportSpecifier\" &&\n (binding.imported.type === \"Identifier\"\n ? binding.imported.name\n : binding.imported.value) === \"defineControls\"\n )\n trusted.add(binding.local.name);\n if (\n binding.type === \"ImportDefaultSpecifier\" &&\n statement.source.value.endsWith(\".astro?tempo-component\")\n ) {\n const physical = await resolve(\n statement.source.value.replace(/\\?tempo-component$/, \"\"),\n path,\n );\n if (physical === file) components.add(binding.local.name);\n }\n }\n }\n const declarations = parsed.program.body.flatMap((statement) => {\n const expression =\n statement.type === \"ExpressionStatement\"\n ? statement.expression\n : null;\n return expression?.type === \"CallExpression\" &&\n expression.callee.type === \"Identifier\" &&\n trusted.has(expression.callee.name) &&\n expression.arguments[0]?.type === \"Identifier\" &&\n components.has(expression.arguments[0].name)\n ? [expression]\n : [];\n });\n if (!declarations.length) continue;\n if (declarations.length > 1 || (result.kind === \"ok\" && result.declared))\n throw new Error(\n \"Keep one controls declaration for this Astro component; remove the duplicate shared declaration\",\n );\n if (result.kind === \"error\") break;\n const argument = declarations[0]!.arguments[1];\n if (!argument)\n throw new Error(\"defineControls requires a controls object\");\n let binding = \"__tempoReadSharedControls\";\n while (source.includes(binding)) binding += \"_\";\n overlays.set(\n path,\n `---\\nimport {defineAstroControls as ${binding}} from \"tempo-sdk/astro/controls\";\\n${source}\\n${binding}(${source.slice(argument.start, argument.end)});\\n---`,\n );\n result = await read(path);\n shared = true;\n }\n } catch (error) {\n result = {\n kind: \"error\",\n message: error instanceof Error ? error.message : String(error),\n };\n }\n return result.kind === \"ok\"\n ? {\n ...(result.declared\n ? { controls: result.controls, ...(shared ? { shared: true } : {}) }\n : {}),\n dependencies: [...dependencies],\n }\n : { error: result.message, dependencies: [...dependencies] };\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,iBAAiB;AAQ1B,eAAsB,0BACpB,MACA,SACA,OACA,cAAwB,CAAC,GACzB;AACA,QAAM,eAAe,oBAAI,IAAY,CAAC,IAAI,CAAC;AAC3C,QAAM,WAAW,oBAAI,IAAY;AACjC,QAAM,SAAS,oBAAI,IAA0B;AAC7C,QAAM,WAAW,oBAAI,IAAoB;AACzC,QAAM,OAAO,OACX,MACA,eACkD;AAClD,UAAM,MAAM,GAAG,IAAI,IAAI,cAAc,UAAU;AAC/C,QAAI,SAAS,IAAI,GAAG,KAAK,SAAS,OAAO;AACvC,aAAO;AAAA,QACL,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AACF,aAAS,IAAI,GAAG;AAChB,QAAI;AACF,mBAAa,IAAI,IAAI;AACrB,YAAM,IAAI;AACV,UAAI,SAAS,SAAS,IAAI,IAAI,KAAK,aAAa,MAAM,MAAM;AAC5D,UAAI,eAAe,QAAW;AAC5B,YAAI,KAAK,SAAS,QAAQ,GAAG;AAC3B,gBAAM,QAAQ,iBAAiB,MAAM;AACrC,cAAI,MAAM,SAAS,QAAQ,CAAC,MAAM;AAChC,mBAAO;AAAA,cACL,MAAM;AAAA,cACN,SAAS;AAAA,YACX;AACF,mBAAS,OAAO;AAAA,YACd,MAAM,YAAY;AAAA,YAClB,MAAM,YAAY;AAAA,UACpB;AAAA,QACF;AACA,cAAM,SAAS;AAAA,UACb,KAAK,SAAS,QAAQ,IAAI,GAAG,IAAI,QAAQ;AAAA,UACzC;AAAA,QACF;AACA,YAAI,OAAO,OAAO;AAChB,iBAAO;AAAA,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AAM,SAAS,OAAO,SAAS,GAAG,CAAC;AAAA;AAAA,MACvJ;AACA,eAAS,MAAM,KAAK,IAAI;AACxB,eAAS;AAAA,IACX;AAAA,EACF,SAAS,OAAO;AACd,aAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,IAChE;AAAA,EACF;AACA,SAAO,OAAO,SAAS,OACnB;AAAA,IACE,GAAI,OAAO,WACP,EAAE,UAAU,OAAO,UAAU,GAAI,SAAS,EAAE,QAAQ,KAAK,IAAI,CAAC,EAAG,IACjE,CAAC;AAAA,IACL,cAAc,CAAC,GAAG,YAAY;AAAA,EAChC,IACA,EAAE,OAAO,OAAO,SAAS,cAAc,CAAC,GAAG,YAAY,EAAE;AAC/D;","names":["binding","result"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Browser-safe control definitions shared by authoring, parsing and the editor. */
|
|
2
|
+
type AssetOption = string | number | boolean;
|
|
3
|
+
type AssetControlDefinition = false | {
|
|
4
|
+
type: "text" | "boolean" | "color" | "object" | "date";
|
|
5
|
+
} | {
|
|
6
|
+
type: "number";
|
|
7
|
+
min?: number;
|
|
8
|
+
max?: number;
|
|
9
|
+
step?: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: "range";
|
|
12
|
+
min: number;
|
|
13
|
+
max: number;
|
|
14
|
+
step?: number;
|
|
15
|
+
} | {
|
|
16
|
+
type: "select" | "radio" | "inline-radio" | "check" | "inline-check" | "multi-select";
|
|
17
|
+
options?: readonly AssetOption[];
|
|
18
|
+
} | {
|
|
19
|
+
type: "file";
|
|
20
|
+
accept?: string;
|
|
21
|
+
};
|
|
22
|
+
type Choices<T> = Extract<NonNullable<T>, AssetOption>;
|
|
23
|
+
type ObjectValue<T> = Exclude<Extract<NonNullable<T>, object>, Function>;
|
|
24
|
+
/** A control must produce values the prop actually accepts. */
|
|
25
|
+
type AssetPropControl<T> = false | (string extends T ? {
|
|
26
|
+
type: "text" | "color";
|
|
27
|
+
} : never) | (boolean extends T ? {
|
|
28
|
+
type: "boolean";
|
|
29
|
+
} : never) | (number extends T ? {
|
|
30
|
+
type: "number";
|
|
31
|
+
min?: number;
|
|
32
|
+
max?: number;
|
|
33
|
+
step?: number;
|
|
34
|
+
} | {
|
|
35
|
+
type: "range";
|
|
36
|
+
min: number;
|
|
37
|
+
max: number;
|
|
38
|
+
step?: number;
|
|
39
|
+
} | {
|
|
40
|
+
type: "date";
|
|
41
|
+
} : never) | ([Choices<T>] extends [never] ? never : {
|
|
42
|
+
type: "select" | "radio" | "inline-radio";
|
|
43
|
+
options?: readonly Choices<T>[];
|
|
44
|
+
}) | (NonNullable<T> extends readonly (infer E)[] ? {
|
|
45
|
+
type: "check" | "inline-check" | "multi-select";
|
|
46
|
+
options?: readonly Choices<E>[];
|
|
47
|
+
} : never) | ([ObjectValue<T>] extends [never] ? never : {
|
|
48
|
+
type: "object";
|
|
49
|
+
}) | (string[] extends T ? {
|
|
50
|
+
type: "file";
|
|
51
|
+
accept?: string;
|
|
52
|
+
} : never);
|
|
53
|
+
/** Index signatures do not establish that a particular named prop exists. */
|
|
54
|
+
type AssetComponentProps<P> = {
|
|
55
|
+
[K in keyof P as string extends K ? never : number extends K ? never : symbol extends K ? never : K extends "key" | "ref" ? never : K]: P[K];
|
|
56
|
+
};
|
|
57
|
+
type AssetControls<P> = {
|
|
58
|
+
[K in keyof AssetComponentProps<P>]?: AssetPropControl<P[K]>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type { AssetControls as A, AssetComponentProps as a, AssetControlDefinition as b, AssetPropControl as c };
|
package/dist/expo/plugin.cjs
CHANGED
|
@@ -33,12 +33,14 @@ var import_node_path = require("path");
|
|
|
33
33
|
var import_oxc_parser = require("oxc-parser");
|
|
34
34
|
var SDK_IMPORT_SOURCES = /* @__PURE__ */ new Set([
|
|
35
35
|
"tempo-sdk/canvas",
|
|
36
|
-
"tempo-sdk/canvas/svelte"
|
|
36
|
+
"tempo-sdk/canvas/svelte",
|
|
37
|
+
"tempo-sdk/canvas/astro"
|
|
37
38
|
]);
|
|
38
39
|
var SDK_COMPONENTS = /* @__PURE__ */ new Set([
|
|
39
40
|
"Canvas",
|
|
40
41
|
"Storyboard",
|
|
41
42
|
"SvelteStoryboard",
|
|
43
|
+
"AstroStoryboard",
|
|
42
44
|
"LegacyStoryboardV1",
|
|
43
45
|
"RouteStoryboard",
|
|
44
46
|
"HtmlStoryboard"
|
|
@@ -430,7 +432,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
|
|
|
430
432
|
}
|
|
431
433
|
])
|
|
432
434
|
} : readLayout(openingElement, component);
|
|
433
|
-
const kind = component === "Storyboard" || component === "SvelteStoryboard" || component === "LegacyStoryboardV1" ? "component" : component === "RouteStoryboard" ? "route" : "html";
|
|
435
|
+
const kind = component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" ? "component" : component === "RouteStoryboard" ? "route" : "html";
|
|
434
436
|
if (!id) {
|
|
435
437
|
errors.push({
|
|
436
438
|
message: `<${component}> must include a literal "id" prop`,
|
|
@@ -445,7 +447,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
|
|
|
445
447
|
storyboardKey: id?.value ?? "",
|
|
446
448
|
displayName: name?.value ?? legacyObject?.displayName,
|
|
447
449
|
kind,
|
|
448
|
-
...component === "SvelteStoryboard" ? { uiFramework: "svelte" } : {},
|
|
450
|
+
...component === "SvelteStoryboard" ? { uiFramework: "svelte" } : component === "AstroStoryboard" ? { runtimeFramework: "astro" } : {},
|
|
449
451
|
layout: layout.value,
|
|
450
452
|
editable: Boolean(id) && layout.errors.length === 0,
|
|
451
453
|
jsxElementSpan: toSpan(element) ?? { start: 0, end: 0 },
|
|
@@ -468,7 +470,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
|
|
|
468
470
|
} : void 0,
|
|
469
471
|
errors
|
|
470
472
|
};
|
|
471
|
-
if (component === "Storyboard" || component === "SvelteStoryboard") {
|
|
473
|
+
if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard") {
|
|
472
474
|
const componentReference = readComponentReference(
|
|
473
475
|
openingElement,
|
|
474
476
|
imports,
|
|
@@ -484,7 +486,7 @@ function readStoryboard(element, component, imports, legacyObjects, source, glob
|
|
|
484
486
|
});
|
|
485
487
|
}
|
|
486
488
|
}
|
|
487
|
-
if (component === "Storyboard" || component === "SvelteStoryboard" || component === "HtmlStoryboard") {
|
|
489
|
+
if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "HtmlStoryboard") {
|
|
488
490
|
const vrt = readVrt(openingElement, errors);
|
|
489
491
|
if (vrt) {
|
|
490
492
|
if (vrt.value) {
|
|
@@ -583,12 +585,12 @@ function validateCanvasChildren(canvasElement, imports) {
|
|
|
583
585
|
child.openingElement?.name,
|
|
584
586
|
imports
|
|
585
587
|
);
|
|
586
|
-
if (component === "Storyboard" || component === "SvelteStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard") {
|
|
588
|
+
if (component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard") {
|
|
587
589
|
continue;
|
|
588
590
|
}
|
|
589
591
|
}
|
|
590
592
|
errors.push({
|
|
591
|
-
message: "<Canvas> children must be <Storyboard>, <SvelteStoryboard>, <RouteStoryboard>, <HtmlStoryboard>, or <LegacyStoryboardV1> declarations",
|
|
593
|
+
message: "<Canvas> children must be <Storyboard>, <SvelteStoryboard>, <AstroStoryboard>, <RouteStoryboard>, <HtmlStoryboard>, or <LegacyStoryboardV1> declarations",
|
|
592
594
|
span: toSpan(child),
|
|
593
595
|
kind: "structural"
|
|
594
596
|
});
|
|
@@ -960,7 +962,7 @@ function resolveMisimportedNamespaceSdkComponent(nameNode, imports, misimportedS
|
|
|
960
962
|
) ?? null;
|
|
961
963
|
}
|
|
962
964
|
function isStoryboardSdkComponent(component) {
|
|
963
|
-
return component === "Storyboard" || component === "SvelteStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard";
|
|
965
|
+
return component === "Storyboard" || component === "SvelteStoryboard" || component === "AstroStoryboard" || component === "LegacyStoryboardV1" || component === "RouteStoryboard" || component === "HtmlStoryboard";
|
|
964
966
|
}
|
|
965
967
|
function readImportedName(specifier) {
|
|
966
968
|
if (specifier.type === "ImportDefaultSpecifier") return "default";
|
|
@@ -973,7 +975,7 @@ function readImportKind(specifier) {
|
|
|
973
975
|
return "named";
|
|
974
976
|
}
|
|
975
977
|
function isSdkImportSource(source) {
|
|
976
|
-
return SDK_IMPORT_SOURCES.has(source) || source.endsWith("/tempo-sdk/canvas") || source.endsWith("/tempo-sdk/canvas/svelte");
|
|
978
|
+
return SDK_IMPORT_SOURCES.has(source) || source.endsWith("/tempo-sdk/canvas") || source.endsWith("/tempo-sdk/canvas/svelte") || source.endsWith("/tempo-sdk/canvas/astro");
|
|
977
979
|
}
|
|
978
980
|
function isWrongTempoSdkCanvasImportSource(source) {
|
|
979
981
|
return (source === "tempo-sdk" || source.startsWith("tempo-sdk/")) && !isSdkImportSource(source);
|
|
@@ -1014,7 +1016,10 @@ function walk(node, visitor, seen = /* @__PURE__ */ new Set()) {
|
|
|
1014
1016
|
// canvas-component-reference.ts
|
|
1015
1017
|
var COMPONENT_REFERENCE_ATTRIBUTE = "data-tempo-component-reference";
|
|
1016
1018
|
function moduleIdentity(file, specifier, resolved) {
|
|
1017
|
-
const
|
|
1019
|
+
const resolvedId = resolved?.get(specifier);
|
|
1020
|
+
const bundled = resolvedId?.startsWith("\0tempo:astro-component:") ? decodeURIComponent(
|
|
1021
|
+
resolvedId.slice("\0tempo:astro-component:".length, -3)
|
|
1022
|
+
) : resolvedId;
|
|
1018
1023
|
const target = bundled === void 0 ? specifier : bundled.replace(/\bt=\d{13}&?\b/, "").replace(/[?&]$/, "");
|
|
1019
1024
|
if (target.startsWith("\0")) return target;
|
|
1020
1025
|
const suffixAt = target.search(/[?#]/);
|
|
@@ -1022,7 +1027,7 @@ function moduleIdentity(file, specifier, resolved) {
|
|
|
1022
1027
|
/\\/g,
|
|
1023
1028
|
"/"
|
|
1024
1029
|
);
|
|
1025
|
-
const suffix = suffixAt < 0 ? "" : target.slice(suffixAt);
|
|
1030
|
+
const suffix = suffixAt < 0 || target.endsWith(".astro?tempo-component") ? "" : target.slice(suffixAt);
|
|
1026
1031
|
if (bundled === void 0 && path.startsWith("."))
|
|
1027
1032
|
path = (0, import_node_path.resolve)((0, import_node_path.dirname)(file), path);
|
|
1028
1033
|
if (!(0, import_node_path.isAbsolute)(path) && !/^[A-Za-z]:\//.test(path)) return target;
|