@tamagui/static 1.0.0-alpha.8 → 1.0.0-alpha.9
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/extractor/createExtractor.js +16 -15
- package/dist/extractor/createExtractor.js.map +2 -2
- package/dist/extractor/extractToClassNames.js +2 -4
- package/dist/extractor/extractToClassNames.js.map +2 -2
- package/dist/extractor/logLines.js +17 -0
- package/dist/extractor/logLines.js.map +7 -0
- package/dist/index.cjs +29 -19
- package/dist/index.cjs.map +3 -3
- package/package.json +4 -4
- package/src/extractor/createExtractor.ts +16 -17
- package/src/extractor/extractToClassNames.ts +2 -5
- package/src/extractor/logLines.ts +11 -0
package/dist/index.cjs
CHANGED
|
@@ -574,6 +574,19 @@ function loadTamagui(props) {
|
|
|
574
574
|
}
|
|
575
575
|
__name(loadTamagui, "loadTamagui");
|
|
576
576
|
|
|
577
|
+
// src/extractor/logLines.ts
|
|
578
|
+
var logLines = /* @__PURE__ */ __name((str) => {
|
|
579
|
+
let lines = [""];
|
|
580
|
+
const items = str.split(" ");
|
|
581
|
+
for (const item of items) {
|
|
582
|
+
if (item.length + lines[lines.length - 1].length > 100) {
|
|
583
|
+
lines.push("");
|
|
584
|
+
}
|
|
585
|
+
lines[lines.length - 1] += item + " ";
|
|
586
|
+
}
|
|
587
|
+
return lines.map((line, i) => " " + (i == 0 ? "" : " ") + line.trim()).join("\n");
|
|
588
|
+
}, "logLines");
|
|
589
|
+
|
|
577
590
|
// src/extractor/normalizeTernaries.ts
|
|
578
591
|
var import_generator2 = __toModule(require("@babel/generator"));
|
|
579
592
|
var t7 = __toModule(require("@babel/types"));
|
|
@@ -759,7 +772,9 @@ function createExtractor() {
|
|
|
759
772
|
loadedTamaguiConfig = tamaguiConfig;
|
|
760
773
|
const defaultTheme = tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]];
|
|
761
774
|
const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
|
762
|
-
const isInternalImport = /* @__PURE__ */ __name((importStr) =>
|
|
775
|
+
const isInternalImport = /* @__PURE__ */ __name((importStr) => {
|
|
776
|
+
return isInsideTamagui(sourcePath) && importStr[0] === ".";
|
|
777
|
+
}, "isInternalImport");
|
|
763
778
|
const validComponents = Object.keys(components).filter((key) => {
|
|
764
779
|
var _a2;
|
|
765
780
|
return key[0].toUpperCase() === key[0] && !!((_a2 = components[key]) == null ? void 0 : _a2.staticConfig);
|
|
@@ -1261,7 +1276,7 @@ function createExtractor() {
|
|
|
1261
1276
|
}
|
|
1262
1277
|
__name(evaluateAttribute, "evaluateAttribute");
|
|
1263
1278
|
if (shouldPrintDebug) {
|
|
1264
|
-
console.log(" - attrs (before)
|
|
1279
|
+
console.log(" - attrs (before):\n", logLines(attrs.map(attrStr).join(", ")));
|
|
1265
1280
|
}
|
|
1266
1281
|
node.attributes = attrs.filter(isAttr).map((x) => x.value);
|
|
1267
1282
|
if (couldntParse) {
|
|
@@ -1354,7 +1369,7 @@ function createExtractor() {
|
|
|
1354
1369
|
}, []);
|
|
1355
1370
|
}
|
|
1356
1371
|
if (shouldPrintDebug) {
|
|
1357
|
-
console.log(" - attrs (flattened):
|
|
1372
|
+
console.log(" - attrs (flattened): \n", logLines(attrs.map(attrStr).join(", ")));
|
|
1358
1373
|
}
|
|
1359
1374
|
attrs = attrs.reduce((acc, cur) => {
|
|
1360
1375
|
if (cur.type !== "attr" || !t9.isJSXAttribute(cur.value) || typeof cur.value.name.name !== "string") {
|
|
@@ -1372,7 +1387,7 @@ function createExtractor() {
|
|
|
1372
1387
|
return acc;
|
|
1373
1388
|
}, []);
|
|
1374
1389
|
if (shouldPrintDebug) {
|
|
1375
|
-
console.log(" - attrs (evaluated styles):
|
|
1390
|
+
console.log(" - attrs (evaluated styles): \n", logLines(attrs.map(attrStr).join(", ")));
|
|
1376
1391
|
}
|
|
1377
1392
|
let prev = null;
|
|
1378
1393
|
attrs = attrs.reduce((acc, cur) => {
|
|
@@ -1387,7 +1402,7 @@ function createExtractor() {
|
|
|
1387
1402
|
return acc;
|
|
1388
1403
|
}, []);
|
|
1389
1404
|
if (shouldPrintDebug) {
|
|
1390
|
-
console.log(" - attrs (combined \u{1F500}):
|
|
1405
|
+
console.log(" - attrs (combined \u{1F500}): \n", logLines(attrs.map(attrStr).join(", ")));
|
|
1391
1406
|
}
|
|
1392
1407
|
const getStyles = /* @__PURE__ */ __name((props2) => {
|
|
1393
1408
|
if (!props2)
|
|
@@ -1401,9 +1416,10 @@ function createExtractor() {
|
|
|
1401
1416
|
const out = postProcessStyles(props2, staticConfig, defaultTheme);
|
|
1402
1417
|
const next = (out == null ? void 0 : out.style) ?? props2;
|
|
1403
1418
|
if (shouldPrintDebug) {
|
|
1404
|
-
console.log("
|
|
1405
|
-
console.log("
|
|
1406
|
-
console.log("
|
|
1419
|
+
console.log(" getStyles props >>\n", logLines(objToStr(props2)));
|
|
1420
|
+
console.log(" getStyles next >>\n", logLines(objToStr(next)));
|
|
1421
|
+
console.log(" getStyles style >>\n", logLines(objToStr(out.style)));
|
|
1422
|
+
console.log(" getStyles viewp >>\n", logLines(objToStr(out.viewProps)));
|
|
1407
1423
|
}
|
|
1408
1424
|
if (staticConfig.validStyles) {
|
|
1409
1425
|
for (const key in next) {
|
|
@@ -1414,9 +1430,6 @@ function createExtractor() {
|
|
|
1414
1430
|
}
|
|
1415
1431
|
return next;
|
|
1416
1432
|
}, "getStyles");
|
|
1417
|
-
if (shouldPrintDebug) {
|
|
1418
|
-
console.log(" staticConfig.defaultProps", staticConfig.defaultProps);
|
|
1419
|
-
}
|
|
1420
1433
|
const completeStylesProcessed = getStyles(__spreadValues(__spreadValues({}, staticConfig.defaultProps), completeStaticProps));
|
|
1421
1434
|
const stylesToAddToInitialGroup = (0, import_lodash.difference)(Object.keys(completeStylesProcessed), Object.keys(completeStaticProps));
|
|
1422
1435
|
if (stylesToAddToInitialGroup.length) {
|
|
@@ -1433,8 +1446,8 @@ function createExtractor() {
|
|
|
1433
1446
|
}
|
|
1434
1447
|
}
|
|
1435
1448
|
if (shouldPrintDebug) {
|
|
1436
|
-
console.log("
|
|
1437
|
-
console.log("
|
|
1449
|
+
console.log(" completeStaticProps\n", logLines(objToStr(completeStaticProps)));
|
|
1450
|
+
console.log(" completeStylesProcessed\n", logLines(objToStr(completeStylesProcessed)));
|
|
1438
1451
|
}
|
|
1439
1452
|
for (const attr of attrs) {
|
|
1440
1453
|
try {
|
|
@@ -1469,7 +1482,7 @@ function createExtractor() {
|
|
|
1469
1482
|
}
|
|
1470
1483
|
}
|
|
1471
1484
|
if (shouldPrintDebug) {
|
|
1472
|
-
console.log(" - attrs (after)
|
|
1485
|
+
console.log(" - attrs (after):\n", logLines(attrs.map(attrStr).join(", ")));
|
|
1473
1486
|
}
|
|
1474
1487
|
if (shouldFlatten) {
|
|
1475
1488
|
if (shouldPrintDebug) {
|
|
@@ -1484,7 +1497,7 @@ function createExtractor() {
|
|
|
1484
1497
|
}
|
|
1485
1498
|
if (shouldPrintDebug) {
|
|
1486
1499
|
console.log(" [\u274A] inline props ", inlinePropCount, shouldDeopt ? " deopted" : "", hasSpread ? " spread" : "", "!flatten", staticConfig.neverFlatten);
|
|
1487
|
-
console.log(" - attrs (end)
|
|
1500
|
+
console.log(" - attrs (end):\n", logLines(attrs.map(attrStr).join(", ")));
|
|
1488
1501
|
}
|
|
1489
1502
|
res.optimized++;
|
|
1490
1503
|
onExtractTag({
|
|
@@ -1879,9 +1892,6 @@ function extractToClassNames({
|
|
|
1879
1892
|
case "style":
|
|
1880
1893
|
const styles2 = addStyles(attr.value);
|
|
1881
1894
|
const newClassNames = (0, import_helpers2.concatClassName)(styles2.map((x) => x.identifier).join(" "));
|
|
1882
|
-
if (shouldPrintDebug) {
|
|
1883
|
-
console.log(" classnames", newClassNames, finalClassNames);
|
|
1884
|
-
}
|
|
1885
1895
|
const existing = finalClassNames.find((x) => x.type == "StringLiteral");
|
|
1886
1896
|
if (existing) {
|
|
1887
1897
|
existing.value = `${existing.value} ${newClassNames}`;
|
|
@@ -1889,7 +1899,7 @@ function extractToClassNames({
|
|
|
1889
1899
|
finalClassNames = [...finalClassNames, t14.stringLiteral(newClassNames)];
|
|
1890
1900
|
}
|
|
1891
1901
|
if (shouldPrintDebug) {
|
|
1892
|
-
console.log(" classnames (after)", finalClassNames.map((x) => x["value"]).join(" "));
|
|
1902
|
+
console.log(" classnames (after)\n", logLines(finalClassNames.map((x) => x["value"]).join(" ")));
|
|
1893
1903
|
}
|
|
1894
1904
|
break;
|
|
1895
1905
|
case "attr":
|