@tamagui/static 1.0.1-rc.5.1 → 1.0.1-rc.7

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.
@@ -206,7 +206,9 @@ function createExtractor({ logger = console } = { logger: console }) {
206
206
  });
207
207
  const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
208
208
  if (Object.keys(components).length === 0) {
209
- console.warn(`Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)`);
209
+ console.warn(
210
+ `Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)`
211
+ );
210
212
  if (process.env.DEBUG === "tamagui") {
211
213
  console.log(`components`, Object.keys(components), components);
212
214
  }
@@ -243,7 +245,9 @@ function createExtractor({ logger = console } = { logger: console }) {
243
245
  );
244
246
  if (shouldPrintDebug === "verbose") {
245
247
  logger.info(
246
- `import ${names.join(", ")} from ${moduleName} isValidComponent ${isValidComponent}`
248
+ `import ${names.join(
249
+ ", "
250
+ )} from ${moduleName} isValidComponent ${isValidComponent}`
247
251
  );
248
252
  }
249
253
  if (isValidComponent) {
@@ -253,7 +257,9 @@ function createExtractor({ logger = console } = { logger: console }) {
253
257
  }
254
258
  }
255
259
  if (shouldPrintDebug) {
256
- logger.info(`file: ${sourcePath} ${JSON.stringify({ doesUseValidImport, hasImportedTheme })}`);
260
+ logger.info(
261
+ `file: ${sourcePath} ${JSON.stringify({ doesUseValidImport, hasImportedTheme })}`
262
+ );
257
263
  }
258
264
  if (!doesUseValidImport) {
259
265
  return null;
@@ -265,7 +271,11 @@ function createExtractor({ logger = console } = { logger: console }) {
265
271
  if (!importDeclaration) {
266
272
  return null;
267
273
  }
268
- return (0, import_extractHelpers.getValidImport)(propsWithFileInfo, importDeclaration.source.value, componentName);
274
+ return (0, import_extractHelpers.getValidImport)(
275
+ propsWithFileInfo,
276
+ importDeclaration.source.value,
277
+ componentName
278
+ );
269
279
  }
270
280
  tm.mark("import-check", !!shouldPrintDebug);
271
281
  let couldntParse = false;
@@ -379,7 +389,9 @@ function createExtractor({ logger = console } = { logger: console }) {
379
389
  continue;
380
390
  }
381
391
  const val = classNames[cn];
382
- definition.properties.push(t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val)));
392
+ definition.properties.push(
393
+ t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val))
394
+ );
383
395
  }
384
396
  if (out.rulesToInsert) {
385
397
  for (const { identifier, rules } of out.rulesToInsert) {
@@ -413,7 +425,9 @@ function createExtractor({ logger = console } = { logger: console }) {
413
425
  modulePath = binding.path.parent.source.value;
414
426
  if (!(0, import_extractHelpers.isValidImport)(propsWithFileInfo, modulePath, binding.identifier.name)) {
415
427
  if (shouldPrintDebug) {
416
- logger.info(` - Binding not internal import or from components ${modulePath}`);
428
+ logger.info(
429
+ ` - Binding not internal import or from components ${modulePath}`
430
+ );
417
431
  }
418
432
  return;
419
433
  }
@@ -488,7 +502,10 @@ function createExtractor({ logger = console } = { logger: console }) {
488
502
  }
489
503
  return [
490
504
  ...createTernariesFromObjectProperties2(test, alt) || [],
491
- ...cons && createTernariesFromObjectProperties2(t.unaryExpression("!", test), cons) || []
505
+ ...cons && createTernariesFromObjectProperties2(
506
+ t.unaryExpression("!", test),
507
+ cons
508
+ ) || []
492
509
  ].map((ternary) => ({
493
510
  type: "ternary",
494
511
  value: ternary
@@ -589,7 +606,10 @@ function createExtractor({ logger = console } = { logger: console }) {
589
606
  if (value.type === "StringLiteral" && value.value[0] === "$") {
590
607
  if (shouldPrintDebug) {
591
608
  logger.info(
592
- [` ! inlining, native disable extract: ${name} =`, value.value].join(" ")
609
+ [
610
+ ` ! inlining, native disable extract: ${name} =`,
611
+ value.value
612
+ ].join(" ")
593
613
  );
594
614
  }
595
615
  inlined.set(name, true);
@@ -698,7 +718,9 @@ function createExtractor({ logger = console } = { logger: console }) {
698
718
  const lVal = attemptEvalSafe(left);
699
719
  const rVal = attemptEvalSafe(right);
700
720
  if (shouldPrintDebug) {
701
- logger.info(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`);
721
+ logger.info(
722
+ ` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`
723
+ );
702
724
  }
703
725
  if (lVal !== import_constants.FAILED_EVAL && t.isConditionalExpression(right)) {
704
726
  const ternary = addBinaryConditional(operator, left, right);
@@ -737,8 +759,12 @@ function createExtractor({ logger = console } = { logger: console }) {
737
759
  return attr;
738
760
  function addBinaryConditional(operator, staticExpr, cond) {
739
761
  if (getStaticConditional(cond)) {
740
- const alt = attemptEval(t.binaryExpression(operator, staticExpr, cond.alternate));
741
- const cons = attemptEval(t.binaryExpression(operator, staticExpr, cond.consequent));
762
+ const alt = attemptEval(
763
+ t.binaryExpression(operator, staticExpr, cond.alternate)
764
+ );
765
+ const cons = attemptEval(
766
+ t.binaryExpression(operator, staticExpr, cond.consequent)
767
+ );
742
768
  if (shouldPrintDebug) {
743
769
  logger.info([" binaryConditional", cond.test, cons, alt].join(" "));
744
770
  }
@@ -855,8 +881,12 @@ function createExtractor({ logger = console } = { logger: console }) {
855
881
  }
856
882
  if (t.isConditionalExpression(property.value)) {
857
883
  const [truthy, falsy] = [
858
- t.objectExpression([t.objectProperty(property.key, property.value.consequent)]),
859
- t.objectExpression([t.objectProperty(property.key, property.value.alternate)])
884
+ t.objectExpression([
885
+ t.objectProperty(property.key, property.value.consequent)
886
+ ]),
887
+ t.objectExpression([
888
+ t.objectProperty(property.key, property.value.alternate)
889
+ ])
860
890
  ].map((x) => attemptEval(x));
861
891
  return [
862
892
  createTernary({
@@ -881,7 +911,9 @@ function createExtractor({ logger = console } = { logger: console }) {
881
911
  })
882
912
  ];
883
913
  }
884
- const obj = t.objectExpression([t.objectProperty(property.key, property.value)]);
914
+ const obj = t.objectExpression([
915
+ t.objectProperty(property.key, property.value)
916
+ ]);
885
917
  const consequent = attemptEval(obj);
886
918
  return createTernary({
887
919
  remove() {
@@ -956,7 +988,9 @@ function createExtractor({ logger = console } = { logger: console }) {
956
988
  ...restProps.deoptProps || [],
957
989
  ...staticConfig.deoptProps || []
958
990
  ]);
959
- const inlineWhenUnflattened = /* @__PURE__ */ new Set([...staticConfig.inlineWhenUnflattened || []]);
991
+ const inlineWhenUnflattened = /* @__PURE__ */ new Set([
992
+ ...staticConfig.inlineWhenUnflattened || []
993
+ ]);
960
994
  const staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(
961
995
  traversePath.scope,
962
996
  importsWhitelist,
@@ -1067,7 +1101,9 @@ function createExtractor({ logger = console } = { logger: console }) {
1067
1101
  }
1068
1102
  if (couldntParse || shouldDeopt) {
1069
1103
  if (shouldPrintDebug) {
1070
- logger.info([` avoid optimizing:`, { couldntParse, shouldDeopt }].join(" "));
1104
+ logger.info(
1105
+ [` avoid optimizing:`, { couldntParse, shouldDeopt }].join(" ")
1106
+ );
1071
1107
  }
1072
1108
  node.attributes = ogAttributes;
1073
1109
  return;
@@ -1162,7 +1198,12 @@ function createExtractor({ logger = console } = { logger: console }) {
1162
1198
  hasImportedTheme = true;
1163
1199
  programPath.node.body.push(
1164
1200
  t.importDeclaration(
1165
- [t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))],
1201
+ [
1202
+ t.importSpecifier(
1203
+ t.identifier("_TamaguiTheme"),
1204
+ t.identifier("Theme")
1205
+ )
1206
+ ],
1166
1207
  t.stringLiteral("@tamagui/core")
1167
1208
  )
1168
1209
  );
@@ -1179,38 +1220,44 @@ function createExtractor({ logger = console } = { logger: console }) {
1179
1220
  }
1180
1221
  }
1181
1222
  if (shouldFlatten) {
1182
- const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {
1183
- if (!isValidStyleKey(key, staticConfig)) {
1184
- return [];
1185
- }
1186
- const value = staticConfig.defaultProps[key];
1187
- const name = tamaguiConfig.shorthands[key] || key;
1188
- if (value === void 0) {
1189
- logger.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`);
1190
- shouldDeopt = true;
1191
- return;
1223
+ const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap(
1224
+ (key) => {
1225
+ if (!isValidStyleKey(key, staticConfig)) {
1226
+ return [];
1227
+ }
1228
+ const value = staticConfig.defaultProps[key];
1229
+ const name = tamaguiConfig.shorthands[key] || key;
1230
+ if (value === void 0) {
1231
+ logger.warn(
1232
+ `\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`
1233
+ );
1234
+ shouldDeopt = true;
1235
+ return;
1236
+ }
1237
+ const attr = {
1238
+ type: "style",
1239
+ name,
1240
+ value: { [name]: value }
1241
+ };
1242
+ return attr;
1192
1243
  }
1193
- const attr = {
1194
- type: "style",
1195
- name,
1196
- value: { [name]: value }
1197
- };
1198
- return attr;
1199
- });
1244
+ );
1200
1245
  if (defaultStyleAttrs.length) {
1201
1246
  attrs = [...defaultStyleAttrs, ...attrs];
1202
1247
  }
1203
1248
  }
1204
1249
  if (shouldDeopt || !shouldFlatten) {
1205
1250
  if (shouldPrintDebug) {
1206
- logger.info(`Deopting`);
1251
+ logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`);
1207
1252
  }
1208
1253
  node.attributes = ogAttributes;
1209
1254
  return;
1210
1255
  }
1211
1256
  if (shouldPrintDebug) {
1212
1257
  logger.info(
1213
- [" - attrs (flattened): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" ")
1258
+ [" - attrs (flattened): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(
1259
+ " "
1260
+ )
1214
1261
  );
1215
1262
  }
1216
1263
  const state = {
@@ -1345,7 +1392,9 @@ function createExtractor({ logger = console } = { logger: console }) {
1345
1392
  tm.mark("jsx-element-expanded", !!shouldPrintDebug);
1346
1393
  if (shouldPrintDebug) {
1347
1394
  logger.info(
1348
- [" - attrs (expanded): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" ")
1395
+ [" - attrs (expanded): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(
1396
+ " "
1397
+ )
1349
1398
  );
1350
1399
  }
1351
1400
  let prev = null;
@@ -1382,13 +1431,21 @@ function createExtractor({ logger = console } = { logger: console }) {
1382
1431
  }, []);
1383
1432
  if (shouldPrintDebug) {
1384
1433
  logger.info(
1385
- [" - attrs (combined \u{1F500}): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" ")
1434
+ [
1435
+ " - attrs (combined \u{1F500}): \n",
1436
+ (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))
1437
+ ].join(" ")
1386
1438
  );
1387
1439
  logger.info(
1388
- [" - defaultProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(staticConfig.defaultProps))].join(" ")
1440
+ [
1441
+ " - defaultProps: \n",
1442
+ (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(staticConfig.defaultProps))
1443
+ ].join(" ")
1389
1444
  );
1390
1445
  logger.info([" - foundStaticProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(foundStaticProps))].join(" "));
1391
- logger.info([" - completeProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeProps))].join(" "));
1446
+ logger.info(
1447
+ [" - completeProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeProps))].join(" ")
1448
+ );
1392
1449
  }
1393
1450
  const getStyles = (props, debugName = "") => {
1394
1451
  if (!props || !Object.keys(props).length) {