tempo-sdk 0.0.89 → 0.0.93

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 (82) hide show
  1. package/dist/assets/index.js +3 -3
  2. package/dist/astro/asset-preview-client.js +3 -3
  3. package/dist/astro.js +7 -7
  4. package/dist/canvas/astro.js +3 -3
  5. package/dist/canvas/editor.js +1 -1
  6. package/dist/canvas/index.js +157 -7
  7. package/dist/canvas/index.js.map +1 -1
  8. package/dist/canvas/interact-projection.js +4 -4
  9. package/dist/canvas/parser.js +1 -1
  10. package/dist/canvas/svelte.js +12 -4
  11. package/dist/canvas/svelte.js.map +1 -1
  12. package/dist/canvas/vue.js +3 -3
  13. package/dist/{chunk-DNERBE7A.js → chunk-3L4RRKC3.js} +17 -11
  14. package/dist/chunk-3L4RRKC3.js.map +1 -0
  15. package/dist/{chunk-2ZQMVAFM.js → chunk-6SOP4XU6.js} +98 -33
  16. package/dist/chunk-6SOP4XU6.js.map +1 -0
  17. package/dist/{chunk-Y72PIE3I.js → chunk-AFXE462X.js} +5 -4
  18. package/dist/{chunk-Y72PIE3I.js.map → chunk-AFXE462X.js.map} +1 -1
  19. package/dist/{chunk-DMT5MRMS.js → chunk-BQPKOVI5.js} +4 -3
  20. package/dist/{chunk-DMT5MRMS.js.map → chunk-BQPKOVI5.js.map} +1 -1
  21. package/dist/{chunk-I5MJ342V.js → chunk-CVUNZBRV.js} +3 -3
  22. package/dist/{chunk-H6OZIX2U.js → chunk-FGWGY3G3.js} +27 -3
  23. package/dist/chunk-FGWGY3G3.js.map +1 -0
  24. package/dist/{chunk-NXPP3CSM.js → chunk-FZVJVL3T.js} +2 -2
  25. package/dist/{chunk-GZ6KY7ZF.js → chunk-GHNHPVEI.js} +2 -2
  26. package/dist/{chunk-GZ6KY7ZF.js.map → chunk-GHNHPVEI.js.map} +1 -1
  27. package/dist/{chunk-3XEEVCM3.js → chunk-HNNZM2XM.js} +127 -66
  28. package/dist/chunk-HNNZM2XM.js.map +1 -0
  29. package/dist/{chunk-5M45Z7K6.js → chunk-LEBVQBDH.js} +83 -51
  30. package/dist/chunk-LEBVQBDH.js.map +1 -0
  31. package/dist/{chunk-X5ORR3FI.js → chunk-M7OOVEAR.js} +7 -7
  32. package/dist/chunk-MU7S7NU7.js +183 -0
  33. package/dist/chunk-MU7S7NU7.js.map +1 -0
  34. package/dist/{chunk-3JR2JRSV.js → chunk-N5MWY4H6.js} +2 -2
  35. package/dist/{chunk-3JR2JRSV.js.map → chunk-N5MWY4H6.js.map} +1 -1
  36. package/dist/{chunk-5VIBKVFO.js → chunk-U66QI3EN.js} +28 -18
  37. package/dist/chunk-U66QI3EN.js.map +1 -0
  38. package/dist/{chunk-XN2K7GED.js → chunk-XB6GU4CE.js} +32 -8
  39. package/dist/{chunk-XN2K7GED.js.map → chunk-XB6GU4CE.js.map} +1 -1
  40. package/dist/{chunk-SLAZCXFE.js → chunk-Y7EHQREO.js} +2 -2
  41. package/dist/{chunk-SLAZCXFE.js.map → chunk-Y7EHQREO.js.map} +1 -1
  42. package/dist/{controls-reader-Z7OQWYWQ.js → controls-reader-5MFHYBZZ.js} +4 -4
  43. package/dist/expo/plugin.cjs +97 -32
  44. package/dist/expo/plugin.cjs.map +1 -1
  45. package/dist/expo/plugin.js +1 -1
  46. package/dist/expo-babel-plugin.cjs +97 -32
  47. package/dist/expo-babel-plugin.cjs.map +1 -1
  48. package/dist/expo-babel-plugin.d.cts +2 -0
  49. package/dist/expo-babel-plugin.d.ts +2 -0
  50. package/dist/expo-babel-plugin.js +1 -1
  51. package/dist/index.d.ts +2 -0
  52. package/dist/index.js +6 -6
  53. package/dist/nextjs/plugin.cjs +1 -1
  54. package/dist/nextjs/plugin.cjs.map +1 -1
  55. package/dist/nextjs/plugin.js +1 -1
  56. package/dist/nextjs-loader.cjs +126 -37
  57. package/dist/nextjs-loader.cjs.map +1 -1
  58. package/dist/nextjs.cjs +1 -1
  59. package/dist/nextjs.cjs.map +1 -1
  60. package/dist/nextjs.d.cts +2 -0
  61. package/dist/nextjs.d.ts +2 -0
  62. package/dist/nextjs.js +1 -1
  63. package/dist/nuxt/runtime/identity.js +1 -1
  64. package/dist/nuxt.js +230 -53
  65. package/dist/nuxt.js.map +1 -1
  66. package/dist/svelte.js +99 -24
  67. package/dist/svelte.js.map +1 -1
  68. package/dist/vue.js +120 -22
  69. package/dist/vue.js.map +1 -1
  70. package/package.json +1 -1
  71. package/dist/chunk-2ZQMVAFM.js.map +0 -1
  72. package/dist/chunk-3XEEVCM3.js.map +0 -1
  73. package/dist/chunk-5M45Z7K6.js.map +0 -1
  74. package/dist/chunk-5VIBKVFO.js.map +0 -1
  75. package/dist/chunk-DNERBE7A.js.map +0 -1
  76. package/dist/chunk-H6BQZOAW.js +0 -121
  77. package/dist/chunk-H6BQZOAW.js.map +0 -1
  78. package/dist/chunk-H6OZIX2U.js.map +0 -1
  79. /package/dist/{chunk-I5MJ342V.js.map → chunk-CVUNZBRV.js.map} +0 -0
  80. /package/dist/{chunk-NXPP3CSM.js.map → chunk-FZVJVL3T.js.map} +0 -0
  81. /package/dist/{chunk-X5ORR3FI.js.map → chunk-M7OOVEAR.js.map} +0 -0
  82. /package/dist/{controls-reader-Z7OQWYWQ.js.map → controls-reader-5MFHYBZZ.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tempoExpoBabelPlugin
3
- } from "../chunk-2ZQMVAFM.js";
3
+ } from "../chunk-6SOP4XU6.js";
4
4
  export {
5
5
  tempoExpoBabelPlugin as default,
6
6
  tempoExpoBabelPlugin
@@ -1090,10 +1090,11 @@ function readStringAttribute(openingElement, name) {
1090
1090
  attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
1091
1091
  };
1092
1092
  }
1093
- const expression = unwrapAttributeExpression(value);
1094
- if (expression?.type === "Literal" && typeof expression.value === "string") {
1093
+ const expression = unwrapTsExpression(unwrapAttributeExpression(value));
1094
+ const fixed = expression?.type === "Literal" && typeof expression.value === "string" ? expression.value : expression?.type === "TemplateLiteral" && (expression.expressions?.length ?? 0) === 0 && expression.quasis?.length === 1 && typeof expression.quasis[0]?.value?.cooked === "string" ? expression.quasis[0].value.cooked : null;
1095
+ if (fixed !== null) {
1095
1096
  return {
1096
- value: expression.value,
1097
+ value: fixed,
1097
1098
  valueSpan: toSpan(expression) ?? toSpan(attribute) ?? { start: 0, end: 0 },
1098
1099
  attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
1099
1100
  };
@@ -1329,14 +1330,75 @@ var import_pluginutils = require("@rollup/pluginutils");
1329
1330
  var import_node_fs3 = require("fs");
1330
1331
  var import_node_path3 = require("path");
1331
1332
 
1333
+ // ../../modules/annotation/literal-expression.ts
1334
+ function unwrapLiteralExpression(node) {
1335
+ let current = node;
1336
+ while ([
1337
+ "ParenthesizedExpression",
1338
+ "TSAsExpression",
1339
+ "TSSatisfiesExpression",
1340
+ "TSTypeAssertion",
1341
+ "TSNonNullExpression",
1342
+ "TSInstantiationExpression"
1343
+ ].includes(current.type)) {
1344
+ const expression = current.expression;
1345
+ if (!expression) break;
1346
+ current = expression;
1347
+ }
1348
+ return current;
1349
+ }
1350
+ function readLiteralExpression(node) {
1351
+ const value = unwrapLiteralExpression(node);
1352
+ if (["Literal", "StringLiteral", "NumericLiteral", "BooleanLiteral"].includes(
1353
+ value.type
1354
+ )) {
1355
+ if (typeof value.value === "string" || typeof value.value === "boolean")
1356
+ return value.value;
1357
+ if (typeof value.value === "number" && Number.isFinite(value.value))
1358
+ return value.value;
1359
+ }
1360
+ if (value.type === "TemplateLiteral") {
1361
+ const expressions = value.expressions;
1362
+ const quasis = value.quasis;
1363
+ if (expressions.length === 0 && quasis.length === 1 && typeof quasis[0]?.value.cooked === "string")
1364
+ return quasis[0].value.cooked;
1365
+ }
1366
+ if (value.type === "UnaryExpression" && (value.operator === "-" || value.operator === "+")) {
1367
+ const argument = readLiteralExpression(value.argument);
1368
+ if (typeof argument === "number")
1369
+ return value.operator === "-" ? -argument : argument;
1370
+ }
1371
+ if (value.type === "BinaryExpression" && ["+", "-", "*", "/"].includes(value.operator)) {
1372
+ const left = readLiteralExpression(value.left);
1373
+ const right = readLiteralExpression(value.right);
1374
+ if (typeof left !== "number" || typeof right !== "number") return null;
1375
+ const result = value.operator === "+" ? left + right : value.operator === "-" ? left - right : value.operator === "*" ? left * right : left / right;
1376
+ return Number.isFinite(result) ? result : null;
1377
+ }
1378
+ return null;
1379
+ }
1380
+ function literalJsxChild(node) {
1381
+ if (node.type !== "JSXExpressionContainer") return null;
1382
+ const root = unwrapLiteralExpression(
1383
+ node.expression
1384
+ );
1385
+ return root.type === "JSXElement" ? root : null;
1386
+ }
1387
+ function literalPropertyName(key, computed = false) {
1388
+ if (!computed && key.type === "Identifier")
1389
+ return typeof key.name === "string" ? key.name : null;
1390
+ const value = readLiteralExpression(key);
1391
+ return typeof value === "string" || typeof value === "number" ? String(value) : null;
1392
+ }
1393
+
1332
1394
  // ../../modules/annotation/expression-facts.ts
1333
1395
  var EXPRESSION_FACTS_ATTRIBUTE = "data-tempo-expr";
1334
1396
  var DYNAMIC_SLOT_FACT = "#slot";
1335
- function expressionFacts(element, parentType) {
1397
+ function expressionFacts(element, parentType, isStaticJsxChild = false) {
1336
1398
  const opening = element.openingElement;
1337
1399
  const attributes = opening.attributes;
1338
1400
  const facts = [];
1339
- if (parentType !== "JSXElement" && parentType !== "JSXFragment")
1401
+ if (!isStaticJsxChild && parentType !== "JSXElement" && parentType !== "JSXFragment")
1340
1402
  facts.push(DYNAMIC_SLOT_FACT);
1341
1403
  const last = /* @__PURE__ */ new Map();
1342
1404
  attributes.forEach((attribute, index) => {
@@ -1356,7 +1418,9 @@ function expressionFacts(element, parentType) {
1356
1418
  facts.push(...styleFacts(value));
1357
1419
  continue;
1358
1420
  }
1359
- if (overridden || !isLiteralValue(value)) facts.push(name);
1421
+ if (overridden) facts.push(name);
1422
+ else if (name === "className" && isClassHelperCall(value)) continue;
1423
+ else if (!isLiteralValue(value)) facts.push(name);
1360
1424
  }
1361
1425
  if (facts.length > 0) return facts.join(" ");
1362
1426
  return lastSpread >= 0 ? "" : void 0;
@@ -1386,7 +1450,9 @@ function styleFacts(value) {
1386
1450
  const facts = [];
1387
1451
  for (const [key, index] of last) {
1388
1452
  const property = properties[index];
1389
- const overridden = properties.slice(index + 1).some((later) => later.type === "SpreadElement" || later.computed);
1453
+ const overridden = properties.slice(index + 1).some(
1454
+ (later) => later.type === "SpreadElement" || later.computed && styleKey(later) === null
1455
+ );
1390
1456
  const literal = property.type !== "ObjectMethod" && !property.shorthand && isLiteral(property.value);
1391
1457
  if (overridden || !literal) facts.push(`style.${key}`);
1392
1458
  }
@@ -1394,38 +1460,31 @@ function styleFacts(value) {
1394
1460
  }
1395
1461
  function styleKey(property) {
1396
1462
  const isProperty = property.type === "Property" || property.type === "ObjectProperty" || property.type === "ObjectMethod";
1397
- if (!isProperty || property.computed) return null;
1398
- const key = property.key;
1399
- if (key.type === "Identifier") return key.name;
1400
- const isString = (key.type === "Literal" || key.type === "StringLiteral") && typeof key.value === "string";
1401
- return isString ? key.value : null;
1463
+ if (!isProperty) return null;
1464
+ return literalPropertyName(property.key, Boolean(property.computed));
1402
1465
  }
1403
1466
  function isLiteralValue(value) {
1404
1467
  if (value.type === "Literal" || value.type === "StringLiteral") return true;
1405
1468
  if (value.type !== "JSXExpressionContainer") return false;
1406
1469
  return isLiteral(value.expression);
1407
1470
  }
1408
- function isLiteral(node) {
1409
- const current = unwrap(node);
1410
- if (current.type === "UnaryExpression") {
1411
- const signed = current.operator === "-" || current.operator === "+";
1412
- return signed && isNumber(current.argument);
1413
- }
1414
- if (isNumber(current)) return true;
1415
- if (current.type === "StringLiteral" || current.type === "BooleanLiteral")
1416
- return true;
1417
- const value = current.value;
1418
- return current.type === "Literal" && (typeof value === "string" || typeof value === "boolean");
1471
+ var CLASS_HELPERS = /* @__PURE__ */ new Set(["cn", "clsx", "twMerge", "cx", "classNames"]);
1472
+ function isClassHelperCall(value) {
1473
+ if (value.type !== "JSXExpressionContainer") return false;
1474
+ const call = value.expression;
1475
+ if (call.type !== "CallExpression") return false;
1476
+ const callee = call.callee;
1477
+ if (callee.type !== "Identifier" || !CLASS_HELPERS.has(callee.name))
1478
+ return false;
1479
+ return call.arguments.every(
1480
+ (argument) => (argument.type === "Literal" || argument.type === "StringLiteral") && typeof argument.value === "string" || argument.type === "TemplateLiteral" && argument.expressions.length === 0
1481
+ );
1419
1482
  }
1420
- function isNumber(node) {
1421
- const numeric = node.type === "Literal" || node.type === "NumericLiteral";
1422
- return numeric && typeof node.value === "number" && Number.isFinite(node.value);
1483
+ function isLiteral(node) {
1484
+ return readLiteralExpression(node) !== null;
1423
1485
  }
1424
1486
  function unwrap(node) {
1425
- let current = node;
1426
- while (current.type === "ParenthesizedExpression")
1427
- current = current.expression;
1428
- return current;
1487
+ return unwrapLiteralExpression(node);
1429
1488
  }
1430
1489
 
1431
1490
  // ../../modules/annotation/source-version.ts
@@ -1516,7 +1575,8 @@ function computeTempoAnnotatedProps(params) {
1516
1575
  ...info.parentType !== void 0 && !hasJsxAttribute(info, EXPRESSION_FACTS_ATTRIBUTE) ? {
1517
1576
  [EXPRESSION_FACTS_ATTRIBUTE]: expressionFacts(
1518
1577
  info.element,
1519
- info.parentType
1578
+ info.parentType,
1579
+ info.isStaticJsxChild
1520
1580
  )
1521
1581
  } : {}
1522
1582
  };
@@ -1822,10 +1882,15 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
1822
1882
  const element = elementPath.node;
1823
1883
  const tagName = getBabelTagName(element.openingElement.name);
1824
1884
  if (FRAGMENT_TAG_NAMES.has(tagName)) return;
1885
+ let container = elementPath.parentPath;
1886
+ while (container && unwrapLiteralExpression(container.node) === element)
1887
+ container = container.parentPath;
1888
+ const isStaticJsxChild = !!container && literalJsxChild(container.node) === element && (container.parent.type === "JSXElement" || container.parent.type === "JSXFragment");
1825
1889
  const info = {
1826
1890
  element,
1827
1891
  tagName,
1828
- parentType: elementPath.parent.type
1892
+ parentType: elementPath.parent.type,
1893
+ isStaticJsxChild
1829
1894
  };
1830
1895
  const props = computeTempoAnnotatedProps({
1831
1896
  info,