tempo-sdk 0.0.99 → 0.0.102

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 (170) hide show
  1. package/README.md +3 -403
  2. package/dist/assets/editor.d.ts +43 -65
  3. package/dist/assets/editor.js +1 -573
  4. package/dist/assets/index.d.ts +11 -61
  5. package/dist/assets/index.js +1 -338
  6. package/dist/assets/parser.d.ts +68 -78
  7. package/dist/assets/parser.js +1 -33
  8. package/dist/astro/asset-preview-client.d.ts +3 -2
  9. package/dist/astro/asset-preview-client.js +1 -93
  10. package/dist/astro/controls.d.ts +1 -3
  11. package/dist/astro/controls.js +1 -7
  12. package/dist/astro/document-client.d.ts +5 -6
  13. package/dist/astro/document-client.js +1 -78
  14. package/dist/astro/runtime.d.ts +23 -11
  15. package/dist/astro/runtime.js +1 -86
  16. package/dist/astro.d.ts +19 -13
  17. package/dist/astro.js +1 -818
  18. package/dist/canvas/astro-contract.d.ts +0 -3
  19. package/dist/canvas/astro-contract.js +1 -9
  20. package/dist/canvas/astro.d.ts +3 -4
  21. package/dist/canvas/astro.js +1 -42
  22. package/dist/canvas/editor.d.ts +187 -183
  23. package/dist/canvas/editor.js +1 -1094
  24. package/dist/canvas/flutter-preview.d.ts +0 -1
  25. package/dist/canvas/flutter-preview.js +1 -9
  26. package/dist/canvas/index.d.ts +46 -100
  27. package/dist/canvas/index.js +1 -3926
  28. package/dist/canvas/interact-projection.d.ts +7 -5
  29. package/dist/canvas/interact-projection.js +1 -12
  30. package/dist/canvas/parser.d.ts +10 -303
  31. package/dist/canvas/parser.js +1 -30
  32. package/dist/canvas/svelte.d.ts +6 -7
  33. package/dist/canvas/svelte.js +1 -91
  34. package/dist/canvas/vue.d.ts +9 -49
  35. package/dist/canvas/vue.js +1 -264
  36. package/dist/chunk-CXCUJCXD.js +1 -0
  37. package/dist/chunk-FH6TMWFA.js +1 -0
  38. package/dist/chunk-FL7FSJSL.js +1 -0
  39. package/dist/chunk-GQIOB5SV.js +1 -0
  40. package/dist/chunk-HBQ7FFH7.js +1 -0
  41. package/dist/chunk-JRJOWLCN.js +1 -0
  42. package/dist/chunk-LJCBFTMP.js +1 -0
  43. package/dist/chunk-M3GN2KUH.js +1 -0
  44. package/dist/chunk-MPIHFFML.js +1 -0
  45. package/dist/chunk-T5TY3U2H.js +1 -0
  46. package/dist/chunk-XO2BSHWM.js +1 -0
  47. package/dist/chunk-XUSV3KOD.js +1 -0
  48. package/dist/chunk-ZXBMP6RV.js +1 -0
  49. package/dist/{controls-uCaQ3CNX.d.ts → controls-DKslABtM.d.ts} +0 -3
  50. package/dist/expo/plugin.cjs +1 -1928
  51. package/dist/expo/plugin.js +1 -8
  52. package/dist/expo-babel-plugin.cjs +1 -1928
  53. package/dist/expo-babel-plugin.d.cts +46 -40
  54. package/dist/expo-babel-plugin.d.ts +46 -40
  55. package/dist/expo-babel-plugin.js +1 -8
  56. package/dist/flutter-preview-path.d.ts +23 -7
  57. package/dist/flutter-preview-path.js +1 -16
  58. package/dist/index.d.ts +33 -45
  59. package/dist/index.js +1 -20
  60. package/dist/nextjs/plugin.cjs +1 -413
  61. package/dist/nextjs/plugin.js +1 -7
  62. package/dist/nextjs-loader.cjs +1 -2277
  63. package/dist/nextjs.cjs +1 -484
  64. package/dist/nextjs.d.cts +2 -58
  65. package/dist/nextjs.d.ts +2 -58
  66. package/dist/nextjs.js +1 -17
  67. package/dist/nuxt/runtime/identity.d.ts +2 -4
  68. package/dist/nuxt/runtime/identity.js +1 -18
  69. package/dist/nuxt.d.ts +31 -92
  70. package/dist/nuxt.js +1 -5854
  71. package/dist/{page-DwLnOM5d.d.ts → page-Bc8PekIX.d.ts} +1 -5
  72. package/dist/parser.d-MO5ciJ5n.d.ts +236 -0
  73. package/dist/{storyboard-CMJVBSXn.d.ts → storyboard.contract.d-UQ4MUYN5.d.ts} +3 -25
  74. package/dist/svelte.d.ts +8 -18
  75. package/dist/svelte.js +1 -917
  76. package/dist/types-CfUgM2w4.d.ts +57 -0
  77. package/dist/v1-client-compat-n0E0XxuX.d.ts +5 -0
  78. package/dist/vue.d.ts +17 -58
  79. package/dist/vue.js +1 -1501
  80. package/package.json +12 -62
  81. package/dist/assets/editor.js.map +0 -1
  82. package/dist/assets/index.js.map +0 -1
  83. package/dist/assets/parser.js.map +0 -1
  84. package/dist/astro/asset-preview-client.js.map +0 -1
  85. package/dist/astro/controls.js.map +0 -1
  86. package/dist/astro/document-client.js.map +0 -1
  87. package/dist/astro/runtime.js.map +0 -1
  88. package/dist/astro.js.map +0 -1
  89. package/dist/canvas/astro-contract.js.map +0 -1
  90. package/dist/canvas/astro.js.map +0 -1
  91. package/dist/canvas/editor.js.map +0 -1
  92. package/dist/canvas/flutter-preview.js.map +0 -1
  93. package/dist/canvas/index.js.map +0 -1
  94. package/dist/canvas/interact-projection.js.map +0 -1
  95. package/dist/canvas/parser.js.map +0 -1
  96. package/dist/canvas/svelte.js.map +0 -1
  97. package/dist/canvas/vue.js.map +0 -1
  98. package/dist/chunk-27WT3XUG.js +0 -455
  99. package/dist/chunk-27WT3XUG.js.map +0 -1
  100. package/dist/chunk-5HIIF354.js +0 -67
  101. package/dist/chunk-5HIIF354.js.map +0 -1
  102. package/dist/chunk-65B52AR7.js +0 -11
  103. package/dist/chunk-65B52AR7.js.map +0 -1
  104. package/dist/chunk-6HYKKP5N.js +0 -2658
  105. package/dist/chunk-6HYKKP5N.js.map +0 -1
  106. package/dist/chunk-6SOP4XU6.js +0 -1891
  107. package/dist/chunk-6SOP4XU6.js.map +0 -1
  108. package/dist/chunk-AFXE462X.js +0 -1253
  109. package/dist/chunk-AFXE462X.js.map +0 -1
  110. package/dist/chunk-BQPKOVI5.js +0 -115
  111. package/dist/chunk-BQPKOVI5.js.map +0 -1
  112. package/dist/chunk-CYDF4LYJ.js +0 -342
  113. package/dist/chunk-CYDF4LYJ.js.map +0 -1
  114. package/dist/chunk-CYQE3TLC.js +0 -37
  115. package/dist/chunk-CYQE3TLC.js.map +0 -1
  116. package/dist/chunk-DI2ZFAWL.js +0 -14
  117. package/dist/chunk-DI2ZFAWL.js.map +0 -1
  118. package/dist/chunk-EGRHWZRV.js +0 -1
  119. package/dist/chunk-EGRHWZRV.js.map +0 -1
  120. package/dist/chunk-FGWGY3G3.js +0 -157
  121. package/dist/chunk-FGWGY3G3.js.map +0 -1
  122. package/dist/chunk-HOBTDB6G.js +0 -112
  123. package/dist/chunk-HOBTDB6G.js.map +0 -1
  124. package/dist/chunk-I7VF4ZOV.js +0 -630
  125. package/dist/chunk-I7VF4ZOV.js.map +0 -1
  126. package/dist/chunk-JVVHU3A7.js +0 -1077
  127. package/dist/chunk-JVVHU3A7.js.map +0 -1
  128. package/dist/chunk-MIXQVPDH.js +0 -8606
  129. package/dist/chunk-MIXQVPDH.js.map +0 -1
  130. package/dist/chunk-MU7S7NU7.js +0 -183
  131. package/dist/chunk-MU7S7NU7.js.map +0 -1
  132. package/dist/chunk-OX2YKYSL.js +0 -13
  133. package/dist/chunk-OX2YKYSL.js.map +0 -1
  134. package/dist/chunk-PYAJHLXO.js +0 -903
  135. package/dist/chunk-PYAJHLXO.js.map +0 -1
  136. package/dist/chunk-SGN7BDRE.js +0 -16
  137. package/dist/chunk-SGN7BDRE.js.map +0 -1
  138. package/dist/chunk-SGTGDLOX.js +0 -285
  139. package/dist/chunk-SGTGDLOX.js.map +0 -1
  140. package/dist/chunk-T364NBR3.js +0 -1440
  141. package/dist/chunk-T364NBR3.js.map +0 -1
  142. package/dist/chunk-U66QI3EN.js +0 -1524
  143. package/dist/chunk-U66QI3EN.js.map +0 -1
  144. package/dist/chunk-WTXOWQ7N.js +0 -47
  145. package/dist/chunk-WTXOWQ7N.js.map +0 -1
  146. package/dist/chunk-X5DJKVBT.js +0 -1308
  147. package/dist/chunk-X5DJKVBT.js.map +0 -1
  148. package/dist/chunk-ZT7HJ6YU.js +0 -38
  149. package/dist/chunk-ZT7HJ6YU.js.map +0 -1
  150. package/dist/chunk-ZW26VZHX.js +0 -3169
  151. package/dist/chunk-ZW26VZHX.js.map +0 -1
  152. package/dist/controls-reader-5MFHYBZZ.js +0 -192
  153. package/dist/controls-reader-5MFHYBZZ.js.map +0 -1
  154. package/dist/expo/plugin.cjs.map +0 -1
  155. package/dist/expo/plugin.js.map +0 -1
  156. package/dist/expo-babel-plugin.cjs.map +0 -1
  157. package/dist/expo-babel-plugin.js.map +0 -1
  158. package/dist/flutter-preview-path.js.map +0 -1
  159. package/dist/index.js.map +0 -1
  160. package/dist/nextjs/plugin.cjs.map +0 -1
  161. package/dist/nextjs/plugin.js.map +0 -1
  162. package/dist/nextjs-loader.cjs.map +0 -1
  163. package/dist/nextjs.cjs.map +0 -1
  164. package/dist/nextjs.js.map +0 -1
  165. package/dist/nuxt/runtime/identity.js.map +0 -1
  166. package/dist/nuxt.js.map +0 -1
  167. package/dist/svelte.js.map +0 -1
  168. package/dist/types-C8OIU-kc.d.ts +0 -106
  169. package/dist/v1-client-compat-qxaXEDm_.d.ts +0 -23
  170. package/dist/vue.js.map +0 -1
@@ -1,183 +0,0 @@
1
- // ../../modules/annotation/source-version.ts
2
- function sourceVersionHash(content) {
3
- let djb2 = 5381;
4
- let sdbm = 0;
5
- for (let i = 0; i < content.length; i++) {
6
- const c = content.charCodeAt(i);
7
- djb2 = (djb2 << 5) + djb2 ^ c;
8
- sdbm = c + (sdbm << 6) + (sdbm << 16) - sdbm | 0;
9
- }
10
- return toHex8(djb2) + toHex8(sdbm);
11
- }
12
- function toHex8(n) {
13
- return (n >>> 0).toString(16).padStart(8, "0");
14
- }
15
-
16
- // ../../modules/annotation/literal-expression.ts
17
- function unwrapLiteralExpression(node) {
18
- let current = node;
19
- while ([
20
- "ParenthesizedExpression",
21
- "TSAsExpression",
22
- "TSSatisfiesExpression",
23
- "TSTypeAssertion",
24
- "TSNonNullExpression",
25
- "TSInstantiationExpression"
26
- ].includes(current.type)) {
27
- const expression = current.expression;
28
- if (!expression) break;
29
- current = expression;
30
- }
31
- return current;
32
- }
33
- function readLiteralExpression(node) {
34
- const value = unwrapLiteralExpression(node);
35
- if (["Literal", "StringLiteral", "NumericLiteral", "BooleanLiteral"].includes(
36
- value.type
37
- )) {
38
- if (typeof value.value === "string" || typeof value.value === "boolean")
39
- return value.value;
40
- if (typeof value.value === "number" && Number.isFinite(value.value))
41
- return value.value;
42
- }
43
- if (value.type === "TemplateLiteral") {
44
- const expressions = value.expressions;
45
- const quasis = value.quasis;
46
- if (expressions.length === 0 && quasis.length === 1 && typeof quasis[0]?.value.cooked === "string")
47
- return quasis[0].value.cooked;
48
- }
49
- if (value.type === "UnaryExpression" && (value.operator === "-" || value.operator === "+")) {
50
- const argument = readLiteralExpression(value.argument);
51
- if (typeof argument === "number")
52
- return value.operator === "-" ? -argument : argument;
53
- }
54
- if (value.type === "BinaryExpression" && ["+", "-", "*", "/"].includes(value.operator)) {
55
- const left = readLiteralExpression(value.left);
56
- const right = readLiteralExpression(value.right);
57
- if (typeof left !== "number" || typeof right !== "number") return null;
58
- const result = value.operator === "+" ? left + right : value.operator === "-" ? left - right : value.operator === "*" ? left * right : left / right;
59
- return Number.isFinite(result) ? result : null;
60
- }
61
- return null;
62
- }
63
- function literalJsxChild(node) {
64
- if (node.type !== "JSXExpressionContainer") return null;
65
- const root = unwrapLiteralExpression(
66
- node.expression
67
- );
68
- return root.type === "JSXElement" ? root : null;
69
- }
70
- function literalPropertyName(key, computed = false) {
71
- if (!computed && key.type === "Identifier")
72
- return typeof key.name === "string" ? key.name : null;
73
- const value = readLiteralExpression(key);
74
- return typeof value === "string" || typeof value === "number" ? String(value) : null;
75
- }
76
-
77
- // ../../modules/annotation/expression-facts.ts
78
- var EXPRESSION_FACTS_ATTRIBUTE = "data-tempo-expr";
79
- var DYNAMIC_SLOT_FACT = "#slot";
80
- function expressionFacts(element, parentType, isStaticJsxChild = false) {
81
- const opening = element.openingElement;
82
- const attributes = opening.attributes;
83
- const facts = [];
84
- if (!isStaticJsxChild && parentType !== "JSXElement" && parentType !== "JSXFragment")
85
- facts.push(DYNAMIC_SLOT_FACT);
86
- const last = /* @__PURE__ */ new Map();
87
- attributes.forEach((attribute, index) => {
88
- const name = attributeName(attribute);
89
- if (name !== null) last.set(name, index);
90
- });
91
- let lastSpread = -1;
92
- attributes.forEach((attribute, index) => {
93
- if (attribute.type === "JSXSpreadAttribute") lastSpread = index;
94
- });
95
- for (const [name, index] of last) {
96
- if (unstamped(name)) continue;
97
- const overridden = index < lastSpread;
98
- const value = attributes[index].value;
99
- if (value === null) continue;
100
- if (name === "style" && !overridden) {
101
- facts.push(...styleFacts(value));
102
- continue;
103
- }
104
- if (overridden) facts.push(name);
105
- else if (name === "className" && isClassHelperCall(value)) continue;
106
- else if (!isLiteralValue(value)) facts.push(name);
107
- }
108
- if (facts.length > 0) return facts.join(" ");
109
- return lastSpread >= 0 ? "" : void 0;
110
- }
111
- function attributeName(attribute) {
112
- if (attribute.type !== "JSXAttribute") return null;
113
- const name = attribute.name;
114
- if (name.type === "JSXIdentifier") return name.name;
115
- if (name.type === "JSXNamespacedName") {
116
- const namespace = name.namespace.name;
117
- return `${namespace}:${name.name.name}`;
118
- }
119
- return null;
120
- }
121
- function unstamped(name) {
122
- return name === "key" || name.startsWith("data-tempo-");
123
- }
124
- function styleFacts(value) {
125
- const expression = value.type === "JSXExpressionContainer" ? unwrap(value.expression) : value;
126
- if (expression.type !== "ObjectExpression") return ["style"];
127
- const properties = expression.properties;
128
- const last = /* @__PURE__ */ new Map();
129
- properties.forEach((property, index) => {
130
- const key = styleKey(property);
131
- if (key !== null) last.set(key, index);
132
- });
133
- const facts = [];
134
- for (const [key, index] of last) {
135
- const property = properties[index];
136
- const overridden = properties.slice(index + 1).some(
137
- (later) => later.type === "SpreadElement" || later.computed && styleKey(later) === null
138
- );
139
- const literal = property.type !== "ObjectMethod" && !property.shorthand && isLiteral(property.value);
140
- if (overridden || !literal) facts.push(`style.${key}`);
141
- }
142
- return facts;
143
- }
144
- function styleKey(property) {
145
- const isProperty = property.type === "Property" || property.type === "ObjectProperty" || property.type === "ObjectMethod";
146
- if (!isProperty) return null;
147
- return literalPropertyName(property.key, Boolean(property.computed));
148
- }
149
- function isLiteralValue(value) {
150
- if (value.type === "Literal" || value.type === "StringLiteral") return true;
151
- if (value.type !== "JSXExpressionContainer") return false;
152
- return isLiteral(value.expression);
153
- }
154
- var CLASS_HELPERS = /* @__PURE__ */ new Set(["cn", "clsx", "twMerge", "cx", "classNames"]);
155
- function isClassHelperCall(value) {
156
- if (value.type !== "JSXExpressionContainer") return false;
157
- const call = value.expression;
158
- if (call.type !== "CallExpression") return false;
159
- const callee = call.callee;
160
- if (callee.type !== "Identifier" || !CLASS_HELPERS.has(callee.name))
161
- return false;
162
- return call.arguments.every(
163
- (argument) => (argument.type === "Literal" || argument.type === "StringLiteral") && typeof argument.value === "string" || argument.type === "TemplateLiteral" && argument.expressions.length === 0
164
- );
165
- }
166
- function isLiteral(node) {
167
- return readLiteralExpression(node) !== null;
168
- }
169
- function unwrap(node) {
170
- return unwrapLiteralExpression(node);
171
- }
172
-
173
- export {
174
- unwrapLiteralExpression,
175
- readLiteralExpression,
176
- literalJsxChild,
177
- literalPropertyName,
178
- EXPRESSION_FACTS_ATTRIBUTE,
179
- DYNAMIC_SLOT_FACT,
180
- expressionFacts,
181
- sourceVersionHash
182
- };
183
- //# sourceMappingURL=chunk-MU7S7NU7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../modules/annotation/source-version.ts","../../../modules/annotation/literal-expression.ts","../../../modules/annotation/expression-facts.ts"],"sourcesContent":["/**\n * Canvas source-version identity.\n *\n * `sourceVersionHash` maps the exact text of a source file to a 16-hex-character\n * token identifying that content. It is the version stamp the canvas edit/\n * reconcile loop uses to answer \"has the host caught up to write W?\": the SDK\n * JSX transforms stamp `data-tempo-source-version` with the hash of the source\n * they annotate, and the write pipeline (`applyWrites` → `sourceVersionsByFile`)\n * reports the hash of the exact bytes it wrote. A captured element's stamp is\n * compared for EQUALITY against a write's version — never ordered, never\n * subtracted, never used as a high-water mark. Two identical contents MUST\n * produce the same token; two different contents MUST (for identity purposes)\n * produce different tokens.\n *\n * Because coverage is an equality test across independently-computed hashes,\n * every producer of a version — this function's callers in the vite/next/expo\n * transforms and in `applyWrites` — MUST route through THIS function so the\n * tokens are bit-identical. Changing the algorithm requires changing it for all\n * producers in lockstep, or old stamps and new write-versions stop matching.\n *\n * The token concatenates two independent 32-bit rolling hashes over the string's\n * UTF-16 code units — djb2 and sdbm — each rendered as unsigned 8-char hex. Two\n * independent hash families make an accidental collision between distinct source\n * contents vanishingly unlikely for version-identity use, while the function\n * stays dependency-free and single-pass (fast enough to run once per file per\n * transform on the devserver hot path).\n */\nexport function sourceVersionHash(content: string): string {\n let djb2 = 5381;\n let sdbm = 0;\n for (let i = 0; i < content.length; i++) {\n const c = content.charCodeAt(i);\n // djb2: hash * 33 ^ c. The trailing `^ c` keeps the value inside 32-bit\n // signed range every iteration, so no explicit coercion is needed.\n djb2 = ((djb2 << 5) + djb2) ^ c;\n // sdbm: c + hash*65599. The final term is an arithmetic subtraction, so\n // coerce back to a 32-bit int each step to prevent float drift.\n sdbm = (c + (sdbm << 6) + (sdbm << 16) - sdbm) | 0;\n }\n return toHex8(djb2) + toHex8(sdbm);\n}\n\n/** Render a 32-bit value as unsigned, zero-padded 8-char lowercase hex. */\nfunction toHex8(n: number): string {\n return (n >>> 0).toString(16).padStart(8, \"0\");\n}\n","/** Syntax-only reading shared by source annotations and checked writers. */\nexport function unwrapLiteralExpression<T extends { type: string }>(\n node: T,\n): T {\n let current = node;\n while (\n [\n \"ParenthesizedExpression\",\n \"TSAsExpression\",\n \"TSSatisfiesExpression\",\n \"TSTypeAssertion\",\n \"TSNonNullExpression\",\n \"TSInstantiationExpression\",\n ].includes(current.type)\n ) {\n const expression = (current as T & { expression?: T }).expression;\n if (!expression) break;\n current = expression;\n }\n return current;\n}\n\n/** No names, calls or interpolation: only authored scalar values, with numeric literal arithmetic folded. */\nexport function readLiteralExpression(node: {\n type: string;\n [key: string]: unknown;\n}): string | number | boolean | null {\n const value = unwrapLiteralExpression(node);\n if (\n [\"Literal\", \"StringLiteral\", \"NumericLiteral\", \"BooleanLiteral\"].includes(\n value.type,\n )\n ) {\n if (typeof value.value === \"string\" || typeof value.value === \"boolean\")\n return value.value;\n if (typeof value.value === \"number\" && Number.isFinite(value.value))\n return value.value;\n }\n if (value.type === \"TemplateLiteral\") {\n const expressions = value.expressions as unknown[];\n const quasis = value.quasis as { value: { cooked?: string | null } }[];\n if (\n expressions.length === 0 &&\n quasis.length === 1 &&\n typeof quasis[0]?.value.cooked === \"string\"\n )\n return quasis[0].value.cooked;\n }\n if (\n value.type === \"UnaryExpression\" &&\n (value.operator === \"-\" || value.operator === \"+\")\n ) {\n const argument = readLiteralExpression(value.argument as typeof node);\n if (typeof argument === \"number\")\n return value.operator === \"-\" ? -argument : argument;\n }\n // `16 / 9` names nothing: arithmetic on numeric literals is as fixed as\n // `-10`. Numbers only, so `\"16\" + \"/9\"` stays an expression, and a\n // non-finite result (`16 / 0`) is not a value a writer could spell.\n if (\n value.type === \"BinaryExpression\" &&\n [\"+\", \"-\", \"*\", \"/\"].includes(value.operator as string)\n ) {\n const left = readLiteralExpression(value.left as typeof node);\n const right = readLiteralExpression(value.right as typeof node);\n if (typeof left !== \"number\" || typeof right !== \"number\") return null;\n const result =\n value.operator === \"+\"\n ? left + right\n : value.operator === \"-\"\n ? left - right\n : value.operator === \"*\"\n ? left * right\n : left / right;\n return Number.isFinite(result) ? result : null;\n }\n return null;\n}\n\n/** A braced, unconditional JSX element is still exactly one authored child. */\nexport function literalJsxChild<T extends { type: string }>(node: T): T | null {\n if (node.type !== \"JSXExpressionContainer\") return null;\n const root = unwrapLiteralExpression(\n (node as T & { expression: T }).expression,\n );\n return root.type === \"JSXElement\" ? root : null;\n}\n\n/** A property name that the written syntax determines without evaluating code. */\nexport function literalPropertyName(\n key: { type: string; [key: string]: unknown },\n computed = false,\n): string | null {\n if (!computed && key.type === \"Identifier\")\n return typeof key.name === \"string\" ? key.name : null;\n const value = readLiteralExpression(key);\n return typeof value === \"string\" || typeof value === \"number\"\n ? String(value)\n : null;\n}\n","/**\n * Expression facts: which parts of one JSX element's source are runtime\n * expressions, stamped as `data-tempo-expr` so the canvas can know before an\n * edit that the edit's operand is not literal source.\n *\n * The value is a space-separated token list. Each token is a fact, never a\n * decision:\n * - `#slot`: the element is not an unconditional JSX child, for example a\n * `.map` callback, conditional, return or prop value. A braced element with\n * only parentheses/type wrappers is a literal child. The `#` keeps this\n * fact apart from attribute names.\n * - `<name>`: the attribute is written at the callsite and its value is an\n * expression, or a later spread may override it.\n * - `style` alone: the style value is not an object literal, or a later\n * spread may override it. Every style key is then an expression.\n * - `style.<key>`: that key of a style object literal is an expression, a\n * shorthand, or a later spread or computed key may override it.\n *\n * A fact is written only when the file proves it, and exactly where the\n * checked writer refuses (`main/literal-writes.ts` planAttribute and\n * planInlineStyles, `astParentKind` for the slot; pinned cell by cell in\n * `literal-writes.expression-facts.test.ts`). Both read JSX in order:\n * - a spread (or a computed key in a style object) overrides only what comes\n * before it, so an attribute or key before one is a fact and one after it\n * is not;\n * - of repeated occurrences the last renders, so only the last is judged\n * and the writer edits that one.\n * What the file leaves open, such as an attribute absent at a callsite with\n * a spread, gets no token.\n *\n * Works on oxc (ESTree) and Babel JSX trees alike.\n */\n\nimport {\n readLiteralExpression,\n unwrapLiteralExpression,\n literalPropertyName,\n} from \"./literal-expression\";\nexport {\n readLiteralExpression,\n unwrapLiteralExpression,\n literalJsxChild,\n literalPropertyName,\n} from \"./literal-expression\";\n\nexport const EXPRESSION_FACTS_ATTRIBUTE = \"data-tempo-expr\";\nexport const DYNAMIC_SLOT_FACT = \"#slot\";\n\ntype Node = { type: string; [key: string]: unknown };\n\n/**\n * The stamp for one element, or undefined when there is nothing to write.\n * An element with a spread attribute always gets a stamp, empty when it has\n * no fact: annotations land after every spread, so its own value replaces\n * one a caller's props would otherwise carry onto it.\n */\nexport function expressionFacts(\n element: unknown,\n parentType: string | null,\n isStaticJsxChild = false,\n): string | undefined {\n const opening = (element as { openingElement: { attributes: Node[] } })\n .openingElement;\n const attributes = opening.attributes;\n const facts: string[] = [];\n if (\n !isStaticJsxChild &&\n parentType !== \"JSXElement\" &&\n parentType !== \"JSXFragment\"\n )\n facts.push(DYNAMIC_SLOT_FACT);\n\n // The writer reads an attribute's last occurrence, so only that one counts.\n const last = new Map<string, number>();\n attributes.forEach((attribute, index) => {\n const name = attributeName(attribute);\n if (name !== null) last.set(name, index);\n });\n let lastSpread = -1;\n attributes.forEach((attribute, index) => {\n if (attribute.type === \"JSXSpreadAttribute\") lastSpread = index;\n });\n for (const [name, index] of last) {\n if (unstamped(name)) continue;\n const overridden = index < lastSpread;\n const value = attributes[index]!.value as Node | null;\n // A bare attribute is `true`, not an expression.\n if (value === null) continue;\n if (name === \"style\" && !overridden) {\n facts.push(...styleFacts(value));\n continue;\n }\n if (overridden) facts.push(name);\n else if (name === \"className\" && isClassHelperCall(value)) continue;\n else if (!isLiteralValue(value)) facts.push(name);\n }\n\n if (facts.length > 0) return facts.join(\" \");\n return lastSpread >= 0 ? \"\" : undefined;\n}\n\n/** The facts one stamp holds, the inverse of `expressionFacts`. No stamp\n * holds none. */\nexport function stampedFacts(stamp: string | undefined): ReadonlySet<string> {\n return new Set((stamp ?? \"\").split(\" \").filter(Boolean));\n}\n\nfunction attributeName(attribute: Node): string | null {\n if (attribute.type !== \"JSXAttribute\") return null;\n const name = attribute.name as Node;\n if (name.type === \"JSXIdentifier\") return name.name as string;\n if (name.type === \"JSXNamespacedName\") {\n const namespace = (name.namespace as Node).name as string;\n return `${namespace}:${(name.name as Node).name as string}`;\n }\n return null;\n}\n\n/** Props the stamp leaves out: Tempo's own annotations, and `key`, which\n * the canvas reads from the layer. A handler, `ref` or `children` is\n * stamped although no canvas edit writes it: it renders no DOM attribute,\n * so this is where the canvas learns that an element is not plain rich\n * text (review2 r2 R3-A: un-bold of `<b onClick={f}>` deleted the handler). */\nfunction unstamped(name: string): boolean {\n return name === \"key\" || name.startsWith(\"data-tempo-\");\n}\n\nfunction styleFacts(value: Node): string[] {\n const expression =\n value.type === \"JSXExpressionContainer\"\n ? unwrap(value.expression as Node)\n : value;\n if (expression.type !== \"ObjectExpression\") return [\"style\"];\n const properties = expression.properties as Node[];\n const last = new Map<string, number>();\n properties.forEach((property, index) => {\n const key = styleKey(property);\n if (key !== null) last.set(key, index);\n });\n const facts: string[] = [];\n for (const [key, index] of last) {\n const property = properties[index]!;\n const overridden = properties\n .slice(index + 1)\n .some(\n (later) =>\n later.type === \"SpreadElement\" ||\n (later.computed && styleKey(later) === null),\n );\n const literal =\n property.type !== \"ObjectMethod\" &&\n !property.shorthand &&\n isLiteral(property.value as Node);\n if (overridden || !literal) facts.push(`style.${key}`);\n }\n return facts;\n}\n\n/** A fixed property name, including a literal written inside brackets. */\nfunction styleKey(property: Node): string | null {\n const isProperty =\n property.type === \"Property\" ||\n property.type === \"ObjectProperty\" ||\n property.type === \"ObjectMethod\";\n if (!isProperty) return null;\n return literalPropertyName(property.key as Node, Boolean(property.computed));\n}\n\n/** An attribute value the writer can rewrite in place: a JSX string, or a\n * container holding one literal. */\nfunction isLiteralValue(value: Node): boolean {\n if (value.type === \"Literal\" || value.type === \"StringLiteral\") return true;\n if (value.type !== \"JSXExpressionContainer\") return false;\n return isLiteral(value.expression as Node);\n}\n\n/** The class-list helpers whose literal arguments are the className. */\nconst CLASS_HELPERS = new Set([\"cn\", \"clsx\", \"twMerge\", \"cx\", \"classNames\"]);\n\n/** `className={cn(\"a\", \"b\")}`: a class helper called with only string\n * literals and templates without `${}`, the call the writer edits argument\n * by argument. The stamp cannot see imports or scope, so it leaves those to\n * the checked writer, which refuses a helper the file does not import. */\nfunction isClassHelperCall(value: Node): boolean {\n if (value.type !== \"JSXExpressionContainer\") return false;\n const call = value.expression as Node;\n if (call.type !== \"CallExpression\") return false;\n const callee = call.callee as Node;\n if (callee.type !== \"Identifier\" || !CLASS_HELPERS.has(callee.name as string))\n return false;\n return (call.arguments as Node[]).every(\n (argument) =>\n ((argument.type === \"Literal\" || argument.type === \"StringLiteral\") &&\n typeof argument.value === \"string\") ||\n (argument.type === \"TemplateLiteral\" &&\n (argument.expressions as unknown[]).length === 0),\n );\n}\n\n/** The writer's scalar literal, including constant templates and type wrappers. */\nfunction isLiteral(node: Node): boolean {\n return readLiteralExpression(node) !== null;\n}\n\nfunction unwrap(node: Node): Node {\n return unwrapLiteralExpression(node);\n}\n"],"mappings":";AA2BO,SAAS,kBAAkB,SAAyB;AACzD,MAAI,OAAO;AACX,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,IAAI,QAAQ,WAAW,CAAC;AAG9B,YAAS,QAAQ,KAAK,OAAQ;AAG9B,WAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,OAAQ;AAAA,EACnD;AACA,SAAO,OAAO,IAAI,IAAI,OAAO,IAAI;AACnC;AAGA,SAAS,OAAO,GAAmB;AACjC,UAAQ,MAAM,GAAG,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAC/C;;;AC5CO,SAAS,wBACd,MACG;AACH,MAAI,UAAU;AACd,SACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,SAAS,QAAQ,IAAI,GACvB;AACA,UAAM,aAAc,QAAmC;AACvD,QAAI,CAAC,WAAY;AACjB,cAAU;AAAA,EACZ;AACA,SAAO;AACT;AAGO,SAAS,sBAAsB,MAGD;AACnC,QAAM,QAAQ,wBAAwB,IAAI;AAC1C,MACE,CAAC,WAAW,iBAAiB,kBAAkB,gBAAgB,EAAE;AAAA,IAC/D,MAAM;AAAA,EACR,GACA;AACA,QAAI,OAAO,MAAM,UAAU,YAAY,OAAO,MAAM,UAAU;AAC5D,aAAO,MAAM;AACf,QAAI,OAAO,MAAM,UAAU,YAAY,OAAO,SAAS,MAAM,KAAK;AAChE,aAAO,MA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AM3E,SAAS,kBAAkB,OAAsB;AAC/C,MAAI,MAAM,SAAS,yBAA0B,QAAO;AACpD,QAAM,OAAO,MAAM;AACnB,MAAI,KAAK,SAAS,iBAAkB,QAAO;AAC3C,QAAM,SAAS,KAAK;AACpB,MAAI,OAAO,SAAS,gBAAgB,CAAC,cAAc,IAAI,OAAO,IAAc;AAC1E,WAAO;AACT,SAAQ,KAAK,UAAqB;AAAA,IAChC,CAAC,cACG,SAAS,SAAS,aAAa,SAAS,SAAS,oBACjD,OAAO,SAAS,UAAU,YAC3B,SAAS,SAAS,qBAChB,SAAS,YAA0B,WAAW;AAAA,EACrD;AACF;AAGA,SAAS,UAAU,MAAqB;AACtC,SAAO,sBAAsB,IAAI,MAAM;AACzC;AAEA,SAAS,OAAO,MAAkB;AAChC,SAAO,wBAAwB,IAAI;AACrC;","names":[]}
@@ -1,13 +0,0 @@
1
- // canvas/astro-contract.ts
2
- function astroStoryboardPath(canvasPath, storyboardId) {
3
- return `/__tempo/astro/${encodeURIComponent(canvasPath)}/${encodeURIComponent(storyboardId)}`;
4
- }
5
- function isAstroComponent(value) {
6
- return !!value && typeof value === "object" && value.kind === "astro-component" && typeof value.module === "string";
7
- }
8
-
9
- export {
10
- astroStoryboardPath,
11
- isAstroComponent
12
- };
13
- //# sourceMappingURL=chunk-OX2YKYSL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../canvas/astro-contract.ts"],"sourcesContent":["/** Browser-safe descriptors. They contain no component factory or server imports. */\nexport type AstroJson =\n | string\n | number\n | boolean\n | null\n | AstroJson[]\n | { [key: string]: AstroJson };\n\nexport interface AstroComponent<\n Props extends object = Record<string, AstroJson>,\n> {\n readonly kind: \"astro-component\";\n readonly module: string;\n /** Type-only props carried by an authored descriptor. */\n readonly propsType?: Props;\n readonly __tempoAstroControls?: {\n controls?: Record<string, unknown>;\n error?: string;\n dependencies?: string[];\n shared?: boolean;\n };\n}\n\n/** Stable addressing shared by the application, desktop and capture runners. */\nexport function astroStoryboardPath(\n canvasPath: string,\n storyboardId: string,\n): string {\n // Each segment stays opaque; no component paths or supplied source enter the URL.\n return `/__tempo/astro/${encodeURIComponent(canvasPath)}/${encodeURIComponent(storyboardId)}`;\n}\n\nexport function isAstroComponent(value: unknown): value is AstroComponent {\n return (\n !!value &&\n typeof value === \"object\" &&\n (value as AstroComponent).kind === \"astro-component\" &&\n typeof (value as AstroComponent).module === \"string\"\n );\n}\n"],"mappings":";AAyBO,SAAS,oBACd,YACA,cACQ;AAER,SAAO,kBAAkB,mBAAmB,UAAU,CAAC,IAAI,mBAAmB,YAAY,CAAC;AAC7F;AAEO,SAAS,iBAAiB,OAAyC;AACxE,SACE,CAAC,CAAC,SACF,OAAO,UAAU,YAChB,MAAyB,SAAS,qBACnC,OAAQ,MAAyB,WAAW;AAEhD;","names":[]}