@tamagui/static 1.0.1-beta.130 → 1.0.1-beta.133

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 (56) hide show
  1. package/dist/cjs/extractor/createEvaluator.js +0 -1
  2. package/dist/cjs/extractor/createEvaluator.js.map +2 -2
  3. package/dist/cjs/extractor/createExtractor.js +34 -6
  4. package/dist/cjs/extractor/createExtractor.js.map +2 -2
  5. package/dist/cjs/extractor/extractToClassNames.js +37 -7
  6. package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
  7. package/dist/cjs/extractor/getStaticBindingsForScope.js +0 -3
  8. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +2 -2
  9. package/dist/cjs/extractor/loadTamagui.js +2 -2
  10. package/dist/cjs/extractor/loadTamagui.js.map +2 -2
  11. package/dist/cjs/require.js +6 -5
  12. package/dist/cjs/require.js.map +2 -2
  13. package/dist/cjs/types.js.map +1 -1
  14. package/dist/esm/extractor/createEvaluator.js +0 -1
  15. package/dist/esm/extractor/createEvaluator.js.map +2 -2
  16. package/dist/esm/extractor/createExtractor.js +34 -6
  17. package/dist/esm/extractor/createExtractor.js.map +2 -2
  18. package/dist/esm/extractor/extractToClassNames.js +37 -7
  19. package/dist/esm/extractor/extractToClassNames.js.map +2 -2
  20. package/dist/esm/extractor/getStaticBindingsForScope.js +0 -3
  21. package/dist/esm/extractor/getStaticBindingsForScope.js.map +2 -2
  22. package/dist/esm/extractor/loadTamagui.js +1 -1
  23. package/dist/esm/extractor/loadTamagui.js.map +2 -2
  24. package/dist/esm/require.js +6 -5
  25. package/dist/esm/require.js.map +2 -2
  26. package/dist/jsx/extractor/createEvaluator.js +0 -1
  27. package/dist/jsx/extractor/createEvaluator.js.map +2 -2
  28. package/dist/jsx/extractor/createExtractor.js +34 -6
  29. package/dist/jsx/extractor/createExtractor.js.map +2 -2
  30. package/dist/jsx/extractor/extractToClassNames.js +37 -7
  31. package/dist/jsx/extractor/extractToClassNames.js.map +2 -2
  32. package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -3
  33. package/dist/jsx/extractor/getStaticBindingsForScope.js.map +2 -2
  34. package/dist/jsx/extractor/loadTamagui.js +1 -1
  35. package/dist/jsx/extractor/loadTamagui.js.map +2 -2
  36. package/dist/jsx/require.js +6 -5
  37. package/dist/jsx/require.js.map +2 -2
  38. package/package.json +13 -20
  39. package/src/extractor/createEvaluator.ts +0 -4
  40. package/src/extractor/createExtractor.ts +39 -6
  41. package/src/extractor/extractToClassNames.ts +45 -6
  42. package/src/extractor/getStaticBindingsForScope.ts +0 -3
  43. package/src/extractor/loadTamagui.ts +1 -1
  44. package/src/require.ts +7 -5
  45. package/src/types.ts +3 -1
  46. package/types/extractor/findTopmostFunction.d.ts +1 -1
  47. package/types/require.d.ts +1 -1
  48. package/types/types.d.ts +3 -1
  49. package/dist/cjs/extractor/defaultTamaguiConfig.js +0 -167
  50. package/dist/cjs/extractor/defaultTamaguiConfig.js.map +0 -7
  51. package/dist/esm/extractor/defaultTamaguiConfig.js +0 -143
  52. package/dist/esm/extractor/defaultTamaguiConfig.js.map +0 -7
  53. package/dist/jsx/extractor/defaultTamaguiConfig.js +0 -143
  54. package/dist/jsx/extractor/defaultTamaguiConfig.js.map +0 -7
  55. package/src/extractor/defaultTamaguiConfig.ts +0 -150
  56. package/types/extractor/defaultTamaguiConfig.d.ts +0 -15
@@ -46,7 +46,6 @@ function createEvaluator({
46
46
  if (shouldPrintDebug) {
47
47
  console.log(" > found theme prop", key);
48
48
  }
49
- console.log("SHOULD FIND THEME (NESTED NOW)", key);
50
49
  return (0, import_core_node.createCSSVariable)(key);
51
50
  }
52
51
  if (t.isIdentifier(n) && staticNamespace.hasOwnProperty(n.name)) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/extractor/createEvaluator.ts"],
4
- "sourcesContent": ["import vm from 'vm'\n\nimport generate from '@babel/generator'\nimport { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { TamaguiConfig } from '@tamagui/core-node'\nimport { createCSSVariable } from '@tamagui/core-node'\nimport esbuild from 'esbuild'\n\nimport { FAILED_EVAL } from '../constants'\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { isValidThemeHook } from './extractHelpers'\n\nexport function createEvaluator({\n tamaguiConfig,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n}: {\n tamaguiConfig: TamaguiConfig\n staticNamespace: Record<string, any>\n sourcePath: string\n traversePath?: NodePath<t.JSXElement>\n shouldPrintDebug: boolean | 'verbose'\n}) {\n // called when evaluateAstNode encounters a dynamic-looking prop\n const evalFn = (n: t.Node) => {\n // themes\n if (\n t.isMemberExpression(n) &&\n t.isIdentifier(n.property) &&\n traversePath &&\n isValidThemeHook(traversePath, n, sourcePath)\n ) {\n const key = n.property.name\n if (shouldPrintDebug) {\n console.log(' > found theme prop', key)\n }\n console.log('SHOULD FIND THEME (NESTED NOW)', key) // tamaguiConfig.themes)\n // if (!themeKeys.has(key)) {\n // throw new Error(` > accessing non-existent theme key: ${key}`)\n // }\n return createCSSVariable(key)\n }\n // variable\n if (t.isIdentifier(n) && staticNamespace.hasOwnProperty(n.name)) {\n return staticNamespace[n.name]\n }\n const evalContext = vm.createContext(staticNamespace)\n const codeWithTypescriptAnnotations = `(${generate(n as any).code})`\n const code = esbuild\n .transformSync(codeWithTypescriptAnnotations, { loader: 'tsx' })\n .code.replace(/;\\n$/, '')\n\n if (shouldPrintDebug) {\n console.log('evaluating', code)\n }\n return vm.runInContext(code, evalContext)\n }\n\n return (n: t.Node) => {\n return evaluateAstNode(n, evalFn)\n }\n}\n\nexport function createSafeEvaluator(attemptEval: (n: t.Node) => any) {\n return (n: t.Node) => {\n try {\n return attemptEval(n)\n } catch (err) {\n return FAILED_EVAL\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AAEf,uBAAqB;AAErB,QAAmB;AAEnB,uBAAkC;AAClC,qBAAoB;AAEpB,uBAA4B;AAC5B,6BAAgC;AAChC,4BAAiC;AAE1B,yBAAyB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GAOC;AAED,QAAM,SAAS,CAAC,MAAc;AAE5B,QACE,EAAE,mBAAmB,CAAC,KACtB,EAAE,aAAa,EAAE,QAAQ,KACzB,gBACA,4CAAiB,cAAc,GAAG,UAAU,GAC5C;AACA,YAAM,MAAM,EAAE,SAAS;AACvB,UAAI,kBAAkB;AACpB,gBAAQ,IAAI,0BAA0B,GAAG;AAAA,MAC3C;AACA,cAAQ,IAAI,kCAAkC,GAAG;AAIjD,aAAO,wCAAkB,GAAG;AAAA,IAC9B;AAEA,QAAI,EAAE,aAAa,CAAC,KAAK,gBAAgB,eAAe,EAAE,IAAI,GAAG;AAC/D,aAAO,gBAAgB,EAAE;AAAA,IAC3B;AACA,UAAM,cAAc,kBAAG,cAAc,eAAe;AACpD,UAAM,gCAAgC,IAAI,8BAAS,CAAQ,EAAE;AAC7D,UAAM,OAAO,uBACV,cAAc,+BAA+B,EAAE,QAAQ,MAAM,CAAC,EAC9D,KAAK,QAAQ,QAAQ,EAAE;AAE1B,QAAI,kBAAkB;AACpB,cAAQ,IAAI,cAAc,IAAI;AAAA,IAChC;AACA,WAAO,kBAAG,aAAa,MAAM,WAAW;AAAA,EAC1C;AAEA,SAAO,CAAC,MAAc;AACpB,WAAO,4CAAgB,GAAG,MAAM;AAAA,EAClC;AACF;AAEO,6BAA6B,aAAiC;AACnE,SAAO,CAAC,MAAc;AACpB,QAAI;AACF,aAAO,YAAY,CAAC;AAAA,IACtB,SAAS,KAAP;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import vm from 'vm'\n\nimport generate from '@babel/generator'\nimport { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { TamaguiConfig } from '@tamagui/core-node'\nimport { createCSSVariable } from '@tamagui/core-node'\nimport esbuild from 'esbuild'\n\nimport { FAILED_EVAL } from '../constants'\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { isValidThemeHook } from './extractHelpers'\n\nexport function createEvaluator({\n tamaguiConfig,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n}: {\n tamaguiConfig: TamaguiConfig\n staticNamespace: Record<string, any>\n sourcePath: string\n traversePath?: NodePath<t.JSXElement>\n shouldPrintDebug: boolean | 'verbose'\n}) {\n // called when evaluateAstNode encounters a dynamic-looking prop\n const evalFn = (n: t.Node) => {\n // themes\n if (\n t.isMemberExpression(n) &&\n t.isIdentifier(n.property) &&\n traversePath &&\n isValidThemeHook(traversePath, n, sourcePath)\n ) {\n const key = n.property.name\n if (shouldPrintDebug) {\n console.log(' > found theme prop', key)\n }\n return createCSSVariable(key)\n }\n // variable\n if (t.isIdentifier(n) && staticNamespace.hasOwnProperty(n.name)) {\n return staticNamespace[n.name]\n }\n const evalContext = vm.createContext(staticNamespace)\n const codeWithTypescriptAnnotations = `(${generate(n as any).code})`\n const code = esbuild\n .transformSync(codeWithTypescriptAnnotations, { loader: 'tsx' })\n .code.replace(/;\\n$/, '')\n\n if (shouldPrintDebug) {\n console.log('evaluating', code)\n }\n return vm.runInContext(code, evalContext)\n }\n\n return (n: t.Node) => {\n return evaluateAstNode(n, evalFn)\n }\n}\n\nexport function createSafeEvaluator(attemptEval: (n: t.Node) => any) {\n return (n: t.Node) => {\n try {\n return attemptEval(n)\n } catch (err) {\n return FAILED_EVAL\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AAEf,uBAAqB;AAErB,QAAmB;AAEnB,uBAAkC;AAClC,qBAAoB;AAEpB,uBAA4B;AAC5B,6BAAgC;AAChC,4BAAiC;AAE1B,yBAAyB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GAOC;AAED,QAAM,SAAS,CAAC,MAAc;AAE5B,QACE,EAAE,mBAAmB,CAAC,KACtB,EAAE,aAAa,EAAE,QAAQ,KACzB,gBACA,4CAAiB,cAAc,GAAG,UAAU,GAC5C;AACA,YAAM,MAAM,EAAE,SAAS;AACvB,UAAI,kBAAkB;AACpB,gBAAQ,IAAI,0BAA0B,GAAG;AAAA,MAC3C;AACA,aAAO,wCAAkB,GAAG;AAAA,IAC9B;AAEA,QAAI,EAAE,aAAa,CAAC,KAAK,gBAAgB,eAAe,EAAE,IAAI,GAAG;AAC/D,aAAO,gBAAgB,EAAE;AAAA,IAC3B;AACA,UAAM,cAAc,kBAAG,cAAc,eAAe;AACpD,UAAM,gCAAgC,IAAI,8BAAS,CAAQ,EAAE;AAC7D,UAAM,OAAO,uBACV,cAAc,+BAA+B,EAAE,QAAQ,MAAM,CAAC,EAC9D,KAAK,QAAQ,QAAQ,EAAE;AAE1B,QAAI,kBAAkB;AACpB,cAAQ,IAAI,cAAc,IAAI;AAAA,IAChC;AACA,WAAO,kBAAG,aAAa,MAAM,WAAW;AAAA,EAC1C;AAEA,SAAO,CAAC,MAAc;AACpB,WAAO,4CAAgB,GAAG,MAAM;AAAA,EAClC;AACF;AAEO,6BAA6B,aAAiC;AACnE,SAAO,CAAC,MAAc;AACpB,QAAI;AACF,aAAO,YAAY,CAAC;AAAA,IACtB,SAAS,KAAP;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -730,8 +730,29 @@ function createExtractor() {
730
730
  alternate: null
731
731
  });
732
732
  });
733
+ }, splitVariants2 = function(style) {
734
+ var _a2;
735
+ const variants2 = {};
736
+ const styles = {};
737
+ for (const key in style) {
738
+ if ((_a2 = staticConfig.variants) == null ? void 0 : _a2[key]) {
739
+ variants2[key] = style[key];
740
+ } else {
741
+ styles[key] = style[key];
742
+ }
743
+ }
744
+ return {
745
+ variants: variants2,
746
+ styles
747
+ };
748
+ }, expandStylesWithoutVariants2 = function(style) {
749
+ const { variants: variants2, styles } = splitVariants2(style);
750
+ return {
751
+ ...(0, import_core_node.expandStyles)(styles),
752
+ ...variants2
753
+ };
733
754
  }, mergeStyles2 = function(prev2, nextIn) {
734
- const next = (0, import_core_node.expandStyles)(nextIn);
755
+ const next = expandStylesWithoutVariants2(nextIn);
735
756
  for (const key in next) {
736
757
  if (import_core_node.pseudoDescriptors[key]) {
737
758
  prev2[key] = prev2[key] || {};
@@ -746,7 +767,7 @@ function createExtractor() {
746
767
  }
747
768
  }
748
769
  };
749
- var evaluateAttribute = evaluateAttribute2, isExtractable = isExtractable2, createTernariesFromObjectProperties = createTernariesFromObjectProperties2, mergeStyles = mergeStyles2;
770
+ var evaluateAttribute = evaluateAttribute2, isExtractable = isExtractable2, createTernariesFromObjectProperties = createTernariesFromObjectProperties2, splitVariants = splitVariants2, expandStylesWithoutVariants = expandStylesWithoutVariants2, mergeStyles = mergeStyles2;
750
771
  node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
751
772
  if (shouldPrintDebug) {
752
773
  console.log("\n");
@@ -929,7 +950,8 @@ function createExtractor() {
929
950
  const themeVal = inlined.get("theme");
930
951
  inlined.delete("theme");
931
952
  for (const [key] of [...inlined]) {
932
- if (INLINE_EXTRACTABLE[key] || ((_a = staticConfig.variants) == null ? void 0 : _a[key])) {
953
+ const isExtractableVariant = ((_a = staticConfig.variants) == null ? void 0 : _a[key]) && variantValues.has(key);
954
+ if (INLINE_EXTRACTABLE[key] || isExtractableVariant) {
933
955
  inlined.delete(key);
934
956
  }
935
957
  }
@@ -1022,7 +1044,7 @@ function createExtractor() {
1022
1044
  if (cur.type === "style") {
1023
1045
  foundStaticProps = {
1024
1046
  ...foundStaticProps,
1025
- ...(0, import_core_node.expandStyles)(cur.value)
1047
+ ...expandStylesWithoutVariants2(cur.value)
1026
1048
  };
1027
1049
  continue;
1028
1050
  }
@@ -1262,14 +1284,18 @@ function createExtractor() {
1262
1284
  }
1263
1285
  }
1264
1286
  if (!shouldFlatten) {
1265
- if (Object.keys(inlineWhenUnflattenedOGVals).length) {
1287
+ if (inlineWhenUnflattened.size) {
1266
1288
  for (const [index, attr] of attrs.entries()) {
1267
1289
  if (attr.type === "style") {
1268
1290
  for (const key in attr.value) {
1291
+ if (!inlineWhenUnflattened.has(key))
1292
+ continue;
1269
1293
  const val = inlineWhenUnflattenedOGVals[key];
1270
1294
  if (val) {
1271
1295
  delete attr.value[key];
1272
1296
  attrs.splice(index - 1, 0, val.attr);
1297
+ } else {
1298
+ delete attr.value[key];
1273
1299
  }
1274
1300
  }
1275
1301
  }
@@ -1299,7 +1325,9 @@ function createExtractor() {
1299
1325
  jsxPath: traversePath,
1300
1326
  originalNodeName,
1301
1327
  isFlattened: shouldFlatten,
1302
- programPath
1328
+ programPath,
1329
+ completeProps,
1330
+ staticConfig
1303
1331
  });
1304
1332
  } finally {
1305
1333
  if (debugPropValue) {