tempo-sdk 0.0.89 → 0.0.92
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/dist/astro.js +7 -7
- package/dist/canvas/editor.js +1 -1
- package/dist/canvas/parser.js +1 -1
- package/dist/canvas/svelte.js +9 -1
- package/dist/canvas/svelte.js.map +1 -1
- package/dist/{chunk-2ZQMVAFM.js → chunk-6SOP4XU6.js} +98 -33
- package/dist/chunk-6SOP4XU6.js.map +1 -0
- package/dist/{chunk-Y72PIE3I.js → chunk-AFXE462X.js} +5 -4
- package/dist/{chunk-Y72PIE3I.js.map → chunk-AFXE462X.js.map} +1 -1
- package/dist/{chunk-DMT5MRMS.js → chunk-BQPKOVI5.js} +4 -3
- package/dist/{chunk-DMT5MRMS.js.map → chunk-BQPKOVI5.js.map} +1 -1
- package/dist/{chunk-SLAZCXFE.js → chunk-FENUT2N2.js} +2 -2
- package/dist/{chunk-SLAZCXFE.js.map → chunk-FENUT2N2.js.map} +1 -1
- package/dist/{chunk-H6OZIX2U.js → chunk-FGWGY3G3.js} +27 -3
- package/dist/chunk-FGWGY3G3.js.map +1 -0
- package/dist/{chunk-X5ORR3FI.js → chunk-KQSOE4KZ.js} +7 -7
- package/dist/chunk-MU7S7NU7.js +183 -0
- package/dist/chunk-MU7S7NU7.js.map +1 -0
- package/dist/{chunk-GZ6KY7ZF.js → chunk-RZ3TG6MV.js} +2 -2
- package/dist/{chunk-GZ6KY7ZF.js.map → chunk-RZ3TG6MV.js.map} +1 -1
- package/dist/{chunk-3JR2JRSV.js → chunk-TWW2DL7E.js} +2 -2
- package/dist/{chunk-3JR2JRSV.js.map → chunk-TWW2DL7E.js.map} +1 -1
- package/dist/{chunk-5VIBKVFO.js → chunk-U66QI3EN.js} +28 -18
- package/dist/chunk-U66QI3EN.js.map +1 -0
- package/dist/{controls-reader-Z7OQWYWQ.js → controls-reader-5MFHYBZZ.js} +4 -4
- package/dist/expo/plugin.cjs +97 -32
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +97 -32
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.d.cts +2 -0
- package/dist/expo-babel-plugin.d.ts +2 -0
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -6
- package/dist/nextjs/plugin.cjs +1 -1
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +126 -37
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +1 -1
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.d.cts +2 -0
- package/dist/nextjs.d.ts +2 -0
- package/dist/nextjs.js +1 -1
- package/dist/nuxt/runtime/identity.js +1 -1
- package/dist/nuxt.js +230 -53
- package/dist/nuxt.js.map +1 -1
- package/dist/svelte.js +99 -24
- package/dist/svelte.js.map +1 -1
- package/dist/vue.js +120 -22
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2ZQMVAFM.js.map +0 -1
- package/dist/chunk-5VIBKVFO.js.map +0 -1
- package/dist/chunk-H6BQZOAW.js +0 -121
- package/dist/chunk-H6BQZOAW.js.map +0 -1
- package/dist/chunk-H6OZIX2U.js.map +0 -1
- /package/dist/{chunk-X5ORR3FI.js.map → chunk-KQSOE4KZ.js.map} +0 -0
- /package/dist/{controls-reader-Z7OQWYWQ.js.map → controls-reader-5MFHYBZZ.js.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseAstroSource,
|
|
3
3
|
readAstroControls
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-U66QI3EN.js";
|
|
5
5
|
import "./chunk-EGRHWZRV.js";
|
|
6
6
|
import "./chunk-JVVHU3A7.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-FGWGY3G3.js";
|
|
8
|
+
import "./chunk-MU7S7NU7.js";
|
|
9
9
|
|
|
10
10
|
// astro/controls-reader.ts
|
|
11
11
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -189,4 +189,4 @@ ${binding}(${source.slice(argument.start, argument.end)});
|
|
|
189
189
|
export {
|
|
190
190
|
readAstroControlsMetadata
|
|
191
191
|
};
|
|
192
|
-
//# sourceMappingURL=controls-reader-
|
|
192
|
+
//# sourceMappingURL=controls-reader-5MFHYBZZ.js.map
|
package/dist/expo/plugin.cjs
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
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
|
|
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(
|
|
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
|
|
1398
|
-
|
|
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
|
-
|
|
1409
|
-
|
|
1410
|
-
if (
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
if (
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
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
|
|
1421
|
-
|
|
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
|
-
|
|
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,
|