@tamagui/static 1.0.1-beta.190 → 1.0.1-beta.191

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 (40) hide show
  1. package/dist/constants.js +0 -3
  2. package/dist/constants.js.map +2 -2
  3. package/dist/extractor/buildClassName.js +20 -5
  4. package/dist/extractor/buildClassName.js.map +2 -2
  5. package/dist/extractor/createEvaluator.js +3 -3
  6. package/dist/extractor/createEvaluator.js.map +2 -2
  7. package/dist/extractor/createExtractor.js +63 -46
  8. package/dist/extractor/createExtractor.js.map +3 -3
  9. package/dist/extractor/ensureImportingConcat.js +4 -8
  10. package/dist/extractor/ensureImportingConcat.js.map +2 -2
  11. package/dist/extractor/extractHelpers.js +37 -9
  12. package/dist/extractor/extractHelpers.js.map +3 -3
  13. package/dist/extractor/extractMediaStyle.js +11 -11
  14. package/dist/extractor/extractMediaStyle.js.map +2 -2
  15. package/dist/extractor/extractToClassNames.js +5 -17
  16. package/dist/extractor/extractToClassNames.js.map +2 -2
  17. package/dist/extractor/getStaticBindingsForScope.js +3 -3
  18. package/dist/extractor/getStaticBindingsForScope.js.map +2 -2
  19. package/dist/extractor/loadTamagui.js +4 -4
  20. package/dist/extractor/loadTamagui.js.map +2 -2
  21. package/dist/types.js.map +1 -1
  22. package/package.json +16 -14
  23. package/src/constants.ts +0 -1
  24. package/src/extractor/buildClassName.ts +20 -4
  25. package/src/extractor/createEvaluator.ts +5 -5
  26. package/src/extractor/createExtractor.ts +42 -30
  27. package/src/extractor/ensureImportingConcat.ts +4 -11
  28. package/src/extractor/extractHelpers.ts +41 -7
  29. package/src/extractor/extractMediaStyle.ts +17 -10
  30. package/src/extractor/extractToClassNames.ts +6 -20
  31. package/src/extractor/getStaticBindingsForScope.ts +4 -4
  32. package/src/extractor/loadTamagui.ts +6 -6
  33. package/src/types.ts +5 -2
  34. package/types/constants.d.ts +0 -1
  35. package/types/extractor/buildClassName.d.ts +4 -1
  36. package/types/extractor/createEvaluator.d.ts +3 -3
  37. package/types/extractor/createExtractor.d.ts +1 -1
  38. package/types/extractor/extractHelpers.d.ts +5 -3
  39. package/types/extractor/extractMediaStyle.d.ts +3 -3
  40. package/types/types.d.ts +4 -2
package/dist/constants.js CHANGED
@@ -24,7 +24,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
25
  var constants_exports = {};
26
26
  __export(constants_exports, {
27
- CONCAT_CLASSNAME_IMPORT: () => CONCAT_CLASSNAME_IMPORT,
28
27
  CSS_FILE_NAME: () => CSS_FILE_NAME,
29
28
  FAILED_EVAL: () => FAILED_EVAL,
30
29
  MEDIA_SEP: () => MEDIA_SEP,
@@ -38,11 +37,9 @@ const CSS_FILE_NAME = "__snack.css";
38
37
  const MEDIA_SEP = "_";
39
38
  const cacheDir = (0, import_find_cache_dir.default)({ name: "tamagui", create: true });
40
39
  const FAILED_EVAL = Symbol("failed_style_eval");
41
- const CONCAT_CLASSNAME_IMPORT = "concatClassName";
42
40
  const SHOULD_DEBUG = process.env.DEBUG === "*" || ((_a = process.env.DEBUG) == null ? void 0 : _a.startsWith("tamagui"));
43
41
  // Annotate the CommonJS export names for ESM import in node:
44
42
  0 && (module.exports = {
45
- CONCAT_CLASSNAME_IMPORT,
46
43
  CSS_FILE_NAME,
47
44
  FAILED_EVAL,
48
45
  MEDIA_SEP,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/constants.ts"],
4
- "sourcesContent": ["import findCacheDir from 'find-cache-dir'\n\nexport const CSS_FILE_NAME = '__snack.css'\n\n// ENSURE THIS ISNT THE SAME AS THE SEPARATOR USED FOR STYLE KEYS\n// SEE matching one in concatClassName\nexport const MEDIA_SEP = '_'\n\n// ensure cache dir\nexport const cacheDir = findCacheDir({ name: 'tamagui', create: true })\n\nexport const FAILED_EVAL = Symbol('failed_style_eval')\nexport const CONCAT_CLASSNAME_IMPORT = 'concatClassName'\n\nexport const SHOULD_DEBUG = process.env.DEBUG === '*' || process.env.DEBUG?.startsWith('tamagui')\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAyB;AAAzB;AAEO,MAAM,gBAAgB;AAItB,MAAM,YAAY;AAGlB,MAAM,eAAW,sBAAAA,SAAa,EAAE,MAAM,WAAW,QAAQ,KAAK,CAAC;AAE/D,MAAM,cAAc,OAAO,mBAAmB;AAC9C,MAAM,0BAA0B;AAEhC,MAAM,eAAe,QAAQ,IAAI,UAAU,SAAO,aAAQ,IAAI,UAAZ,mBAAmB,WAAW;",
4
+ "sourcesContent": ["import findCacheDir from 'find-cache-dir'\n\nexport const CSS_FILE_NAME = '__snack.css'\n\n// ENSURE THIS ISNT THE SAME AS THE SEPARATOR USED FOR STYLE KEYS\n// SEE matching one in concatClassName\nexport const MEDIA_SEP = '_'\n\n// ensure cache dir\nexport const cacheDir = findCacheDir({ name: 'tamagui', create: true })\n\nexport const FAILED_EVAL = Symbol('failed_style_eval')\n\nexport const SHOULD_DEBUG = process.env.DEBUG === '*' || process.env.DEBUG?.startsWith('tamagui')\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAyB;AAAzB;AAEO,MAAM,gBAAgB;AAItB,MAAM,YAAY;AAGlB,MAAM,eAAW,sBAAAA,SAAa,EAAE,MAAM,WAAW,QAAQ,KAAK,CAAC;AAE/D,MAAM,cAAc,OAAO,mBAAmB;AAE9C,MAAM,eAAe,QAAQ,IAAI,UAAU,SAAO,aAAQ,IAAI,UAAZ,mBAAmB,WAAW;",
6
6
  "names": ["findCacheDir"]
7
7
  }
@@ -24,12 +24,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
25
  var buildClassName_exports = {};
26
26
  __export(buildClassName_exports, {
27
- buildClassName: () => buildClassName
27
+ buildClassName: () => buildClassName,
28
+ buildClassNameLogic: () => buildClassNameLogic
28
29
  });
29
30
  module.exports = __toCommonJS(buildClassName_exports);
30
31
  var t = __toESM(require("@babel/types"));
31
- function buildClassName(classNameObjects) {
32
- return classNameObjects.reduce((acc, val) => {
32
+ var import_helpers = require("@tamagui/helpers");
33
+ const buildClassName = (objectsIn, extras = "") => {
34
+ let objects = buildClassNameLogic(objectsIn);
35
+ if (!objects)
36
+ return null;
37
+ if (t.isStringLiteral(objects)) {
38
+ objects.value = (0, import_helpers.concatClassName)(objects.value);
39
+ objects.value = `${extras} ${objects.value}`;
40
+ } else {
41
+ objects = t.binaryExpression("+", t.stringLiteral(extras), objects);
42
+ }
43
+ return objects;
44
+ };
45
+ const buildClassNameLogic = (objects) => {
46
+ return objects.reduce((acc, val) => {
33
47
  if (acc == null) {
34
48
  if (t.isConditionalExpression(val) || t.isStringLiteral(val) || t.isNumericLiteral(val)) {
35
49
  return val;
@@ -71,9 +85,10 @@ function buildClassName(classNameObjects) {
71
85
  }
72
86
  return t.binaryExpression("+", acc, inner);
73
87
  }, null);
74
- }
88
+ };
75
89
  // Annotate the CommonJS export names for ESM import in node:
76
90
  0 && (module.exports = {
77
- buildClassName
91
+ buildClassName,
92
+ buildClassNameLogic
78
93
  });
79
94
  //# sourceMappingURL=buildClassName.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/extractor/buildClassName.ts"],
4
- "sourcesContent": ["import * as t from '@babel/types'\n\nimport type { ClassNameObject } from '../types.js'\n\nexport function buildClassName(\n classNameObjects: ClassNameObject[]\n): t.Expression | t.StringLiteral | null {\n return classNameObjects.reduce<t.Expression | null>((acc, val) => {\n if (acc == null) {\n if (\n // pass conditional expressions through\n t.isConditionalExpression(val) ||\n // pass non-null literals through\n t.isStringLiteral(val) ||\n t.isNumericLiteral(val)\n ) {\n return val\n }\n return t.logicalExpression('||', val, t.stringLiteral(''))\n }\n\n let inner: t.Expression\n if (t.isStringLiteral(val)) {\n if (t.isStringLiteral(acc)) {\n // join adjacent string literals\n return t.stringLiteral(`${acc.value} ${val.value}`)\n }\n inner = t.stringLiteral(` ${val.value}`)\n } else if (t.isLiteral(val)) {\n inner = t.binaryExpression('+', t.stringLiteral(' '), val)\n } else if (t.isConditionalExpression(val) || t.isBinaryExpression(val)) {\n if (t.isStringLiteral(acc)) {\n return t.binaryExpression('+', t.stringLiteral(`${acc.value} `), val)\n }\n inner = t.binaryExpression('+', t.stringLiteral(' '), val)\n } else if (t.isIdentifier(val) || t.isMemberExpression(val)) {\n // identifiers and member expressions make for reasonable ternaries\n inner = t.conditionalExpression(\n val,\n t.binaryExpression('+', t.stringLiteral(' '), val),\n t.stringLiteral('')\n )\n } else {\n if (t.isStringLiteral(acc)) {\n return t.binaryExpression(\n '+',\n t.stringLiteral(`${acc.value} `),\n t.logicalExpression('||', val, t.stringLiteral(''))\n )\n }\n // use a logical expression for more complex prop values\n inner = t.binaryExpression(\n '+',\n t.stringLiteral(' '),\n t.logicalExpression('||', val, t.stringLiteral(''))\n )\n }\n\n return t.binaryExpression('+', acc, inner)\n }, null)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAmB;AAIZ,SAAS,eACd,kBACuC;AACvC,SAAO,iBAAiB,OAA4B,CAAC,KAAK,QAAQ;AAChE,QAAI,OAAO,MAAM;AACf,UAEE,EAAE,wBAAwB,GAAG,KAE7B,EAAE,gBAAgB,GAAG,KACrB,EAAE,iBAAiB,GAAG,GACtB;AACA,eAAO;AAAA,MACT;AACA,aAAO,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc,EAAE,CAAC;AAAA,IAC3D;AAEA,QAAI;AACJ,QAAI,EAAE,g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pers'\n\nimport type { ClassNameObject } from '../types.js'\n\ntype Builder = (\n objects: ClassNameObject[],\n extras?: string\n) => t.Expression | t.StringLiteral | null\n\nexport const buildClassName: Builder = (objectsIn, extras = '') => {\n let objects = buildClassNameLogic(objectsIn)\n if (!objects) return null\n if (t.isStringLiteral(objects)) {\n objects.value = concatClassName(objects.value)\n objects.value = `${extras} ${objects.value}`\n } else {\n objects = t.binaryExpression('+', t.stringLiteral(extras), objects)\n }\n return objects\n}\n\nexport const buildClassNameLogic: Builder = (objects) => {\n return objects.reduce<t.Expression | null>((acc, val) => {\n if (acc == null) {\n if (\n // pass conditional expressions through\n t.isConditionalExpression(val) ||\n // pass non-null literals through\n t.isStringLiteral(val) ||\n t.isNumericLiteral(val)\n ) {\n return val\n }\n return t.logicalExpression('||', val, t.stringLiteral(''))\n }\n\n let inner: t.Expression\n if (t.isStringLiteral(val)) {\n if (t.isStringLiteral(acc)) {\n // join adjacent string literals\n return t.stringLiteral(`${acc.value} ${val.value}`)\n }\n inner = t.stringLiteral(` ${val.value}`)\n } else if (t.isLiteral(val)) {\n inner = t.binaryExpression('+', t.stringLiteral(' '), val)\n } else if (t.isConditionalExpression(val) || t.isBinaryExpression(val)) {\n if (t.isStringLiteral(acc)) {\n return t.binaryExpression('+', t.stringLiteral(`${acc.value} `), val)\n }\n inner = t.binaryExpression('+', t.stringLiteral(' '), val)\n } else if (t.isIdentifier(val) || t.isMemberExpression(val)) {\n // identifiers and member expressions make for reasonable ternaries\n inner = t.conditionalExpression(\n val,\n t.binaryExpression('+', t.stringLiteral(' '), val),\n t.stringLiteral('')\n )\n } else {\n if (t.isStringLiteral(acc)) {\n return t.binaryExpression(\n '+',\n t.stringLiteral(`${acc.value} `),\n t.logicalExpression('||', val, t.stringLiteral(''))\n )\n }\n // use a logical expression for more complex prop values\n inner = t.binaryExpression(\n '+',\n t.stringLiteral(' '),\n t.logicalExpression('||', val, t.stringLiteral(''))\n )\n }\n\n return t.binaryExpression('+', acc, inner)\n }, null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GAAG;AAAA,MACtE;AACA,cAAQ,EAAE,iBAAiB,KAAK,EAAE,cAAc,GAAG,GAAG,GAAG;AAAA,IAC3D,WAAW,EAAE,aAAa,GAAG,KAAK,EAAE,mBAAmB,GAAG,GAAG;AAE3D,cAAQ,EAAE;AAAA,QACR;AAAA,QACA,EAAE,iBAAiB,KAAK,EAAE,cAAc,GAAG,GAAG,GAAG;AAAA,QACjD,EAAE,cAAc,EAAE;AAAA,MACpB;AAAA,IACF,OAAO;AACL,UAAI,EAAE,gBAAgB,GAAG,GAAG;AAC1B,eAAO,EAAE;AAAA,UACP;AAAA,UACA,EAAE,cAAc,GAAG,IAAI,QAAQ;AAAA,UAC/B,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc,EAAE,CAAC;AAAA,QACpD;AAAA,MACF;AAEA,cAAQ,EAAE;AAAA,QACR;AAAA,QACA,EAAE,cAAc,GAAG;AAAA,QACnB,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc,EAAE,CAAC;AAAA,MACpD;AAAA,IACF;AAEA,WAAO,EAAE,iBAAiB,KAAK,KAAK,KAAK;AAAA,EAC3C,GAAG,IAAI;AACT;",
6
6
  "names": []
7
7
  }
@@ -37,21 +37,21 @@ var import_constants = require("../constants.js");
37
37
  var import_evaluateAstNode = require("./evaluateAstNode.js");
38
38
  var import_extractHelpers = require("./extractHelpers.js");
39
39
  function createEvaluator({
40
- tamaguiConfig,
40
+ props,
41
41
  staticNamespace,
42
42
  sourcePath,
43
43
  traversePath,
44
44
  shouldPrintDebug
45
45
  }) {
46
46
  const evalFn = (n) => {
47
- if (t.isMemberExpression(n) && t.isIdentifier(n.property) && traversePath && (0, import_extractHelpers.isValidThemeHook)(traversePath, n, sourcePath)) {
47
+ if (t.isMemberExpression(n) && t.isIdentifier(n.property) && traversePath && (0, import_extractHelpers.isValidThemeHook)(props, traversePath, n, sourcePath)) {
48
48
  const key = n.property.name;
49
49
  if (shouldPrintDebug) {
50
50
  console.log(" > found theme prop", key);
51
51
  }
52
52
  return (0, import_core_node.createCSSVariable)(key);
53
53
  }
54
- if (t.isIdentifier(n) && staticNamespace.hasOwnProperty(n.name)) {
54
+ if (t.isIdentifier(n) && typeof staticNamespace[n.name] !== "undefined") {
55
55
  return staticNamespace[n.name];
56
56
  }
57
57
  const evalContext = import_vm.default.createContext(staticNamespace);
@@ -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.js'\nimport { evaluateAstNode } from './evaluateAstNode.js'\nimport { isValidThemeHook } from './extractHelpers.js'\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 // eslint-disable-next-line no-console\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 // eslint-disable-next-line no-console\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,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AAED,QAAM,SAAS,CAAC,MAAc;AAE5B,QACE,EAAE,mBAAmB,CAAC,KACtB,EAAE,aAAa,EAAE,QAAQ,KACzB,oBACA,wCAAiB,cAAc,GAAG,UAAU,GAC5C;AACA,YAAM,MAAM,EAAE,SAAS;AACvB,UAAI,kBAAkB;AAEpB,gBAAQ,IAAI,0BAA0B,GAAG;AAAA,MAC3C;AACA,iBAAO,oCAAkB,GAAG;AAAA,IAC9B;AAEA,QAAI,EAAE,aAAa,CAAC,KAAK,gBAAgB,eAAe,EAAE,IAAI,GAAG;AAC/D,aAAO,gBAAgB,EAAE;AAAA,IAC3B;AACA,UAAM,cAAc,UAAAA,QAAG,cAAc,eAAe;AACpD,UAAM,gCAAgC,QAAI,iBAAAC,SAAS,CAAQ,EAAE;AAC7D,UAAM,OAAO,eAAAC,QACV,cAAc,+BAA+B,EAAE,QAAQ,MAAM,CAAC,EAC9D,KAAK,QAAQ,QAAQ,EAAE;AAE1B,QAAI,kBAAkB;AAEpB,cAAQ,IAAI,cAAc,IAAI;AAAA,IAChC;AACA,WAAO,UAAAF,QAAG,aAAa,MAAM,WAAW;AAAA,EAC1C;AAEA,SAAO,CAAC,MAAc;AACpB,eAAO,wCAAgB,GAAG,MAAM;AAAA,EAClC;AACF;AAEO,SAAS,oBAAoB,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 { createCSSVariable } from '@tamagui/core-node'\nimport esbuild from 'esbuild'\n\nimport { FAILED_EVAL } from '../constants.js'\nimport { TamaguiOptionsWithFileInfo } from '../types.js'\nimport { evaluateAstNode } from './evaluateAstNode.js'\nimport { isValidThemeHook } from './extractHelpers.js'\n\nexport function createEvaluator({\n props,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n}: {\n props: TamaguiOptionsWithFileInfo\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(props, traversePath, n, sourcePath)\n ) {\n const key = n.property.name\n if (shouldPrintDebug) {\n // eslint-disable-next-line no-console\n console.log(' > found theme prop', key)\n }\n return createCSSVariable(key)\n }\n // variable\n if (t.isIdentifier(n) && typeof staticNamespace[n.name] !== 'undefined') {\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 // eslint-disable-next-line no-console\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;AACnB,uBAAkC;AAClC,qBAAoB;AAEpB,uBAA4B;AAE5B,6BAAgC;AAChC,4BAAiC;AAE1B,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AAED,QAAM,SAAS,CAAC,MAAc;AAE5B,QACE,EAAE,mBAAmB,CAAC,KACtB,EAAE,aAAa,EAAE,QAAQ,KACzB,oBACA,wCAAiB,OAAO,cAAc,GAAG,UAAU,GACnD;AACA,YAAM,MAAM,EAAE,SAAS;AACvB,UAAI,kBAAkB;AAEpB,gBAAQ,IAAI,0BAA0B,GAAG;AAAA,MAC3C;AACA,iBAAO,oCAAkB,GAAG;AAAA,IAC9B;AAEA,QAAI,EAAE,aAAa,CAAC,KAAK,OAAO,gBAAgB,EAAE,UAAU,aAAa;AACvE,aAAO,gBAAgB,EAAE;AAAA,IAC3B;AACA,UAAM,cAAc,UAAAA,QAAG,cAAc,eAAe;AACpD,UAAM,gCAAgC,QAAI,iBAAAC,SAAS,CAAQ,EAAE;AAC7D,UAAM,OAAO,eAAAC,QACV,cAAc,+BAA+B,EAAE,QAAQ,MAAM,CAAC,EAC9D,KAAK,QAAQ,QAAQ,EAAE;AAE1B,QAAI,kBAAkB;AAEpB,cAAQ,IAAI,cAAc,IAAI;AAAA,IAChC;AACA,WAAO,UAAAF,QAAG,aAAa,MAAM,WAAW;AAAA,EAC1C;AAEA,SAAO,CAAC,MAAc;AACpB,eAAO,wCAAgB,GAAG,MAAM;AAAA,EAClC;AACF;AAEO,SAAS,oBAAoB,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": ["vm", "generate", "esbuild"]
7
7
  }
@@ -131,7 +131,7 @@ function createExtractor({ logger = console } = { logger: console }) {
131
131
  prefixLogs,
132
132
  excludeProps,
133
133
  target,
134
- ...props
134
+ ...restProps
135
135
  } = options;
136
136
  let shouldPrintDebug = options.shouldPrintDebug || false;
137
137
  if (disable) {
@@ -146,6 +146,10 @@ function createExtractor({ logger = console } = { logger: console }) {
146
146
  const isTargetingHTML = target === "html";
147
147
  const ogDebug = shouldPrintDebug;
148
148
  const tm = (0, import_timer.timer)();
149
+ const propsWithFileInfo = {
150
+ ...options,
151
+ sourcePath
152
+ };
149
153
  if (shouldPrintDebug === "verbose") {
150
154
  console.log("tamagui.config.ts:", { components, config });
151
155
  }
@@ -163,9 +167,6 @@ function createExtractor({ logger = console } = { logger: console }) {
163
167
  }
164
168
  });
165
169
  const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
166
- const isInternalImport = (importStr) => {
167
- return (0, import_extractHelpers.isInsideTamagui)(sourcePath) && importStr[0] === ".";
168
- };
169
170
  const validComponents = Object.keys(components).filter((key) => {
170
171
  var _a;
171
172
  return key[0].toUpperCase() === key[0] && !!((_a = components[key]) == null ? void 0 : _a.staticConfig);
@@ -189,9 +190,9 @@ function createExtractor({ logger = console } = { logger: console }) {
189
190
  continue;
190
191
  const node = "node" in bodyPath ? bodyPath.node : bodyPath;
191
192
  const from = node.source.value;
192
- const isValidImport = props.components.includes(from) || isInternalImport(from) || from === "@tamagui/core" || from === "tamagui";
193
+ const valid = (0, import_extractHelpers.isValidImport)(propsWithFileInfo, from);
193
194
  if (extractStyledDefinitions) {
194
- if (isValidImport) {
195
+ if (valid) {
195
196
  if (node.specifiers.some((specifier) => {
196
197
  return specifier.local.name === "styled";
197
198
  })) {
@@ -200,7 +201,7 @@ function createExtractor({ logger = console } = { logger: console }) {
200
201
  }
201
202
  }
202
203
  }
203
- if (isValidImport) {
204
+ if (valid) {
204
205
  const names = node.specifiers.map((specifier) => specifier.local.name);
205
206
  const isValidComponent = names.some((name) => !!(validComponents[name] || validHooks[name]));
206
207
  if (shouldPrintDebug === "verbose") {
@@ -237,20 +238,20 @@ function createExtractor({ logger = console } = { logger: console }) {
237
238
  };
238
239
  callTraverse({
239
240
  Program: {
240
- enter(path) {
241
- programPath = path;
241
+ enter(path2) {
242
+ programPath = path2;
242
243
  }
243
244
  },
244
- CallExpression(path) {
245
+ CallExpression(path2) {
245
246
  var _a, _b;
246
247
  if (disable || disableExtraction || extractStyledDefinitions === false) {
247
248
  return;
248
249
  }
249
- if (!t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled") {
250
+ if (!t.isIdentifier(path2.node.callee) || path2.node.callee.name !== "styled") {
250
251
  return;
251
252
  }
252
- const name = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown";
253
- const definition = path.node.arguments[1];
253
+ const name = t.isVariableDeclarator(path2.parent) && t.isIdentifier(path2.parent.id) ? path2.parent.id.name : "unknown";
254
+ const definition = path2.node.arguments[1];
254
255
  if (!name || !definition || !t.isObjectExpression(definition)) {
255
256
  return;
256
257
  }
@@ -273,11 +274,13 @@ function createExtractor({ logger = console } = { logger: console }) {
273
274
  logger.info([`Loaded`, Object.keys(out2.components).join(", "), !!Component].join(" "));
274
275
  }
275
276
  } catch (err) {
276
- logger.info(
277
- `${(0, import_getPrefixLogs.getPrefixLogs)(
278
- options
279
- )} skip optimize styled(${name}), unable to pre-process (DEBUG=tamagui for more)`
280
- );
277
+ if (shouldPrintDebug) {
278
+ logger.info(
279
+ `${(0, import_getPrefixLogs.getPrefixLogs)(
280
+ options
281
+ )} skip optimize styled(${name}), unable to pre-process (DEBUG=tamagui for more)`
282
+ );
283
+ }
281
284
  if (process.env.DEBUG === "tamagui") {
282
285
  logger.info(
283
286
  ` Disable this with "disableExtractFoundComponents" in your build-time configuration.
@@ -302,14 +305,14 @@ function createExtractor({ logger = console } = { logger: console }) {
302
305
  const skipped = [];
303
306
  const styles = {};
304
307
  const staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(
305
- path.scope,
308
+ path2.scope,
306
309
  importsWhitelist,
307
310
  sourcePath,
308
311
  bindingCache,
309
312
  shouldPrintDebug
310
313
  );
311
314
  const attemptEval = !evaluateVars ? import_evaluateAstNode.evaluateAstNode : (0, import_createEvaluator.createEvaluator)({
312
- tamaguiConfig,
315
+ props: options,
313
316
  staticNamespace,
314
317
  sourcePath,
315
318
  shouldPrintDebug
@@ -379,18 +382,32 @@ function createExtractor({ logger = console } = { logger: console }) {
379
382
  const binding = traversePath.scope.getBinding(node.name.name);
380
383
  if (binding) {
381
384
  if (!t.isImportDeclaration(binding.path.parent)) {
385
+ if (shouldPrintDebug) {
386
+ logger.info(` - Binding not import declaration, skip`);
387
+ }
382
388
  return;
383
389
  }
384
390
  const source = binding.path.parent.source;
385
- if (!props.components.includes(source.value) && !isInternalImport(source.value)) {
391
+ if (!(0, import_extractHelpers.isValidImport)(propsWithFileInfo, source.value)) {
392
+ if (shouldPrintDebug) {
393
+ logger.info(` - Binding not internal import or from components ${source.value}`);
394
+ }
386
395
  return;
387
396
  }
388
397
  if (!validComponents[binding.identifier.name]) {
398
+ if (shouldPrintDebug) {
399
+ logger.info(
400
+ ` - Binding not valid component (binding.identifier.name) ${binding.identifier.name}`
401
+ );
402
+ }
389
403
  return;
390
404
  }
391
405
  }
392
406
  const component = validComponents[node.name.name];
393
407
  if (!component || !component.staticConfig) {
408
+ if (shouldPrintDebug) {
409
+ logger.info(` - No Tamagui conf on this: ${node.name.name}`);
410
+ }
394
411
  return;
395
412
  }
396
413
  const originalNodeName = node.name.name;
@@ -438,8 +455,8 @@ function createExtractor({ logger = console } = { logger: console }) {
438
455
  return;
439
456
  }
440
457
  try {
441
- let evaluateAttribute2 = function(path) {
442
- const attribute = path.node;
458
+ let evaluateAttribute2 = function(path2) {
459
+ const attribute = path2.node;
443
460
  const attr = { type: "attr", value: attribute };
444
461
  if (t.isJSXSpreadAttribute(attribute)) {
445
462
  const arg = attribute.argument;
@@ -528,9 +545,9 @@ function createExtractor({ logger = console } = { logger: console }) {
528
545
  }
529
546
  const [value, valuePath] = (() => {
530
547
  if (t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
531
- return [attribute.value.expression, path.get("value")];
548
+ return [attribute.value.expression, path2.get("value")];
532
549
  } else {
533
- return [attribute.value, path.get("value")];
550
+ return [attribute.value, path2.get("value")];
534
551
  }
535
552
  })();
536
553
  const remove = () => {
@@ -546,7 +563,7 @@ function createExtractor({ logger = console } = { logger: console }) {
546
563
  if (name === "tag") {
547
564
  return {
548
565
  type: "attr",
549
- value: path.node
566
+ value: path2.node
550
567
  };
551
568
  }
552
569
  if (disableExtractVariables === true) {
@@ -605,10 +622,10 @@ function createExtractor({ logger = console } = { logger: console }) {
605
622
  type: "style",
606
623
  value: { [key]: styleValue },
607
624
  name: key,
608
- attr: path.node
625
+ attr: path2.node
609
626
  };
610
627
  }
611
- if (import_validHTMLAttributes.validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-")) {
628
+ if (import_validHTMLAttributes.validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-") || key === "__source" || key === "__self") {
612
629
  return attr;
613
630
  }
614
631
  if (shouldPrintDebug) {
@@ -644,7 +661,7 @@ function createExtractor({ logger = console } = { logger: console }) {
644
661
  type: "style",
645
662
  value: { [name]: styleValue },
646
663
  name,
647
- attr: path.node
664
+ attr: path2.node
648
665
  };
649
666
  } else {
650
667
  if (variants[name]) {
@@ -899,8 +916,8 @@ function createExtractor({ logger = console } = { logger: console }) {
899
916
  const isTextView = staticConfig.isText || false;
900
917
  const validStyles = (staticConfig == null ? void 0 : staticConfig.validStyles) ?? {};
901
918
  let tagName = staticConfig.defaultProps.tag ?? (isTextView ? "span" : "div");
902
- traversePath.get("openingElement").get("attributes").forEach((path) => {
903
- const attr = path.node;
919
+ traversePath.get("openingElement").get("attributes").forEach((path2) => {
920
+ const attr = path2.node;
904
921
  if (t.isJSXSpreadAttribute(attr))
905
922
  return;
906
923
  if (attr.name.name !== "tag")
@@ -912,12 +929,12 @@ function createExtractor({ logger = console } = { logger: console }) {
912
929
  });
913
930
  const flatNode = getFlattenedNode == null ? void 0 : getFlattenedNode({ isTextView, tag: tagName });
914
931
  const inlineProps = /* @__PURE__ */ new Set([
915
- ...props.inlineProps || [],
932
+ ...restProps.inlineProps || [],
916
933
  ...staticConfig.inlineProps || []
917
934
  ]);
918
935
  const deoptProps = /* @__PURE__ */ new Set([
919
936
  "animation",
920
- ...props.deoptProps || [],
937
+ ...restProps.deoptProps || [],
921
938
  ...staticConfig.deoptProps || []
922
939
  ]);
923
940
  const inlineWhenUnflattened = /* @__PURE__ */ new Set([...staticConfig.inlineWhenUnflattened || []]);
@@ -929,7 +946,7 @@ function createExtractor({ logger = console } = { logger: console }) {
929
946
  shouldPrintDebug
930
947
  );
931
948
  const attemptEval = !evaluateVars ? import_evaluateAstNode.evaluateAstNode : (0, import_createEvaluator.createEvaluator)({
932
- tamaguiConfig,
949
+ props: options,
933
950
  staticNamespace,
934
951
  sourcePath,
935
952
  traversePath,
@@ -940,8 +957,8 @@ function createExtractor({ logger = console } = { logger: console }) {
940
957
  logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`);
941
958
  }
942
959
  const flattenedAttrs = [];
943
- traversePath.get("openingElement").get("attributes").forEach((path) => {
944
- const attr = path.node;
960
+ traversePath.get("openingElement").get("attributes").forEach((path2) => {
961
+ const attr = path2.node;
945
962
  if (!t.isJSXSpreadAttribute(attr)) {
946
963
  flattenedAttrs.push(attr);
947
964
  return;
@@ -995,13 +1012,13 @@ function createExtractor({ logger = console } = { logger: console }) {
995
1012
  const variantValues = /* @__PURE__ */ new Map();
996
1013
  let hasSetOptimized = false;
997
1014
  const inlineWhenUnflattenedOGVals = {};
998
- attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
1015
+ attrs = traversePath.get("openingElement").get("attributes").flatMap((path2) => {
999
1016
  var _a2;
1000
1017
  try {
1001
- const res2 = evaluateAttribute2(path);
1018
+ const res2 = evaluateAttribute2(path2);
1002
1019
  tm.mark("jsx-element-evaluate-attr", !!shouldPrintDebug);
1003
1020
  if (!res2) {
1004
- path.remove();
1021
+ path2.remove();
1005
1022
  }
1006
1023
  return res2;
1007
1024
  } catch (err) {
@@ -1014,13 +1031,13 @@ function createExtractor({ logger = console } = { logger: console }) {
1014
1031
  ].join(" ")
1015
1032
  );
1016
1033
  if (shouldPrintDebug === "verbose") {
1017
- logger.info(`node ${(_a2 = path.node) == null ? void 0 : _a2.type}`);
1034
+ logger.info(`node ${(_a2 = path2.node) == null ? void 0 : _a2.type}`);
1018
1035
  }
1019
1036
  }
1020
1037
  inlined.set(`${Math.random()}`, "spread");
1021
1038
  return {
1022
1039
  type: "attr",
1023
- value: path.node
1040
+ value: path2.node
1024
1041
  };
1025
1042
  }
1026
1043
  }).flat(4).filter(import_extractHelpers.isPresent);
@@ -1375,24 +1392,24 @@ function createExtractor({ logger = console } = { logger: console }) {
1375
1392
  logger.info([" - foundStaticProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(foundStaticProps))].join(" "));
1376
1393
  logger.info([" - completeProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeProps))].join(" "));
1377
1394
  }
1378
- const getStyles = (props2, debugName = "") => {
1379
- if (!props2 || !Object.keys(props2).length) {
1395
+ const getStyles = (props, debugName = "") => {
1396
+ if (!props || !Object.keys(props).length) {
1380
1397
  if (shouldPrintDebug)
1381
1398
  logger.info([" getStyles() no props"].join(" "));
1382
1399
  return {};
1383
1400
  }
1384
1401
  if (excludeProps && !!excludeProps.size) {
1385
- for (const key in props2) {
1402
+ for (const key in props) {
1386
1403
  if (excludeProps.has(key)) {
1387
1404
  if (shouldPrintDebug)
1388
1405
  logger.info([" delete excluded", key].join(" "));
1389
- delete props2[key];
1406
+ delete props[key];
1390
1407
  }
1391
1408
  }
1392
1409
  }
1393
1410
  try {
1394
1411
  const out = (0, import_core_node.getSplitStyles)(
1395
- props2,
1412
+ props,
1396
1413
  staticConfig,
1397
1414
  defaultTheme,
1398
1415
  {