@tamagui/static 1.0.0-alpha.34 → 1.0.0-alpha.38

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 (173) hide show
  1. package/dist/.buildinfo +1 -0
  2. package/dist/extractor/createEvaluator.js.map +2 -2
  3. package/dist/extractor/createExtractor.js +86 -105
  4. package/dist/extractor/createExtractor.js.map +2 -2
  5. package/dist/extractor/extractHelpers.js +1 -3
  6. package/dist/extractor/extractHelpers.js.map +2 -2
  7. package/dist/extractor/extractMediaStyle.js +8 -10
  8. package/dist/extractor/extractMediaStyle.js.map +2 -2
  9. package/dist/extractor/extractToClassNames.js +20 -10
  10. package/dist/extractor/extractToClassNames.js.map +2 -2
  11. package/dist/extractor/getStaticBindingsForScope.js +7 -0
  12. package/dist/extractor/getStaticBindingsForScope.js.map +2 -2
  13. package/dist/forwardPropsList.js +140 -0
  14. package/dist/forwardPropsList.js.map +7 -0
  15. package/dist/index.cjs +133 -205
  16. package/dist/index.cjs.map +3 -3
  17. package/dist/index.js +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/patchReactNativeWeb.js +3 -30
  20. package/dist/patchReactNativeWeb.js.map +2 -2
  21. package/package.json +7 -7
  22. package/dist/cjs/constants.js +0 -33
  23. package/dist/cjs/constants.js.map +0 -7
  24. package/dist/cjs/extractor/accessSafe.js +0 -33
  25. package/dist/cjs/extractor/accessSafe.js.map +0 -7
  26. package/dist/cjs/extractor/babelParse.js +0 -52
  27. package/dist/cjs/extractor/babelParse.js.map +0 -7
  28. package/dist/cjs/extractor/buildClassName.js +0 -62
  29. package/dist/cjs/extractor/buildClassName.js.map +0 -7
  30. package/dist/cjs/extractor/createEvaluator.js +0 -73
  31. package/dist/cjs/extractor/createEvaluator.js.map +0 -7
  32. package/dist/cjs/extractor/createExtractor.js +0 -903
  33. package/dist/cjs/extractor/createExtractor.js.map +0 -7
  34. package/dist/cjs/extractor/ensureImportingConcat.js +0 -46
  35. package/dist/cjs/extractor/ensureImportingConcat.js.map +0 -7
  36. package/dist/cjs/extractor/evaluateAstNode.js +0 -116
  37. package/dist/cjs/extractor/evaluateAstNode.js.map +0 -7
  38. package/dist/cjs/extractor/extractHelpers.js +0 -118
  39. package/dist/cjs/extractor/extractHelpers.js.map +0 -7
  40. package/dist/cjs/extractor/extractMediaStyle.js +0 -187
  41. package/dist/cjs/extractor/extractMediaStyle.js.map +0 -7
  42. package/dist/cjs/extractor/extractToClassNames.js +0 -279
  43. package/dist/cjs/extractor/extractToClassNames.js.map +0 -7
  44. package/dist/cjs/extractor/findTopmostFunction.js +0 -29
  45. package/dist/cjs/extractor/findTopmostFunction.js.map +0 -7
  46. package/dist/cjs/extractor/generatedUid.js +0 -50
  47. package/dist/cjs/extractor/generatedUid.js.map +0 -7
  48. package/dist/cjs/extractor/getPropValueFromAttributes.js +0 -71
  49. package/dist/cjs/extractor/getPropValueFromAttributes.js.map +0 -7
  50. package/dist/cjs/extractor/getSourceModule.js +0 -91
  51. package/dist/cjs/extractor/getSourceModule.js.map +0 -7
  52. package/dist/cjs/extractor/getStaticBindingsForScope.js +0 -150
  53. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +0 -7
  54. package/dist/cjs/extractor/hoistClassNames.js +0 -66
  55. package/dist/cjs/extractor/hoistClassNames.js.map +0 -7
  56. package/dist/cjs/extractor/literalToAst.js +0 -56
  57. package/dist/cjs/extractor/literalToAst.js.map +0 -7
  58. package/dist/cjs/extractor/loadTamagui.js +0 -63
  59. package/dist/cjs/extractor/loadTamagui.js.map +0 -7
  60. package/dist/cjs/extractor/logLines.js +0 -23
  61. package/dist/cjs/extractor/logLines.js.map +0 -7
  62. package/dist/cjs/extractor/normalizeTernaries.js +0 -102
  63. package/dist/cjs/extractor/normalizeTernaries.js.map +0 -7
  64. package/dist/cjs/extractor/removeUnusedHooks.js +0 -101
  65. package/dist/cjs/extractor/removeUnusedHooks.js.map +0 -7
  66. package/dist/cjs/index.js +0 -37
  67. package/dist/cjs/index.js.map +0 -7
  68. package/dist/cjs/patchReactNativeWeb.js +0 -129
  69. package/dist/cjs/patchReactNativeWeb.js.map +0 -7
  70. package/dist/cjs/types.js +0 -4
  71. package/dist/cjs/types.js.map +0 -7
  72. package/dist/esm/constants.js +0 -10
  73. package/dist/esm/constants.js.map +0 -7
  74. package/dist/esm/extractor/accessSafe.js +0 -11
  75. package/dist/esm/extractor/accessSafe.js.map +0 -7
  76. package/dist/esm/extractor/babelParse.js +0 -30
  77. package/dist/esm/extractor/babelParse.js.map +0 -7
  78. package/dist/esm/extractor/buildClassName.js +0 -40
  79. package/dist/esm/extractor/buildClassName.js.map +0 -7
  80. package/dist/esm/extractor/createEvaluator.js +0 -51
  81. package/dist/esm/extractor/createEvaluator.js.map +0 -7
  82. package/dist/esm/extractor/createExtractor.js +0 -840
  83. package/dist/esm/extractor/createExtractor.js.map +0 -7
  84. package/dist/esm/extractor/ensureImportingConcat.js +0 -24
  85. package/dist/esm/extractor/ensureImportingConcat.js.map +0 -7
  86. package/dist/esm/extractor/evaluateAstNode.js +0 -94
  87. package/dist/esm/extractor/evaluateAstNode.js.map +0 -7
  88. package/dist/esm/extractor/extractHelpers.js +0 -94
  89. package/dist/esm/extractor/extractHelpers.js.map +0 -7
  90. package/dist/esm/extractor/extractMediaStyle.js +0 -151
  91. package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
  92. package/dist/esm/extractor/extractToClassNames.js +0 -240
  93. package/dist/esm/extractor/extractToClassNames.js.map +0 -7
  94. package/dist/esm/extractor/findTopmostFunction.js +0 -23
  95. package/dist/esm/extractor/findTopmostFunction.js.map +0 -7
  96. package/dist/esm/extractor/generatedUid.js +0 -28
  97. package/dist/esm/extractor/generatedUid.js.map +0 -7
  98. package/dist/esm/extractor/getPropValueFromAttributes.js +0 -49
  99. package/dist/esm/extractor/getPropValueFromAttributes.js.map +0 -7
  100. package/dist/esm/extractor/getSourceModule.js +0 -69
  101. package/dist/esm/extractor/getSourceModule.js.map +0 -7
  102. package/dist/esm/extractor/getStaticBindingsForScope.js +0 -128
  103. package/dist/esm/extractor/getStaticBindingsForScope.js.map +0 -7
  104. package/dist/esm/extractor/hoistClassNames.js +0 -44
  105. package/dist/esm/extractor/hoistClassNames.js.map +0 -7
  106. package/dist/esm/extractor/literalToAst.js +0 -34
  107. package/dist/esm/extractor/literalToAst.js.map +0 -7
  108. package/dist/esm/extractor/loadTamagui.js +0 -41
  109. package/dist/esm/extractor/loadTamagui.js.map +0 -7
  110. package/dist/esm/extractor/logLines.js +0 -17
  111. package/dist/esm/extractor/logLines.js.map +0 -7
  112. package/dist/esm/extractor/normalizeTernaries.js +0 -52
  113. package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
  114. package/dist/esm/extractor/removeUnusedHooks.js +0 -78
  115. package/dist/esm/extractor/removeUnusedHooks.js.map +0 -7
  116. package/dist/esm/index.js +0 -14
  117. package/dist/esm/index.js.map +0 -7
  118. package/dist/esm/patchReactNativeWeb.js +0 -107
  119. package/dist/esm/patchReactNativeWeb.js.map +0 -7
  120. package/dist/esm/types.js +0 -1
  121. package/dist/esm/types.js.map +0 -7
  122. package/dist/extractor/loadTamagui.js +0 -41
  123. package/dist/extractor/loadTamagui.js.map +0 -7
  124. package/dist/jsx/constants.js +0 -9
  125. package/dist/jsx/extractor/accessSafe.js +0 -10
  126. package/dist/jsx/extractor/babelParse.js +0 -29
  127. package/dist/jsx/extractor/buildClassName.js +0 -39
  128. package/dist/jsx/extractor/createEvaluator.js +0 -50
  129. package/dist/jsx/extractor/createExtractor.js +0 -839
  130. package/dist/jsx/extractor/ensureImportingConcat.js +0 -23
  131. package/dist/jsx/extractor/evaluateAstNode.js +0 -93
  132. package/dist/jsx/extractor/extractHelpers.js +0 -93
  133. package/dist/jsx/extractor/extractMediaStyle.js +0 -150
  134. package/dist/jsx/extractor/extractToClassNames.js +0 -239
  135. package/dist/jsx/extractor/findTopmostFunction.js +0 -22
  136. package/dist/jsx/extractor/generatedUid.js +0 -27
  137. package/dist/jsx/extractor/getPropValueFromAttributes.js +0 -48
  138. package/dist/jsx/extractor/getSourceModule.js +0 -68
  139. package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -127
  140. package/dist/jsx/extractor/hoistClassNames.js +0 -43
  141. package/dist/jsx/extractor/literalToAst.js +0 -33
  142. package/dist/jsx/extractor/loadTamagui.js +0 -40
  143. package/dist/jsx/extractor/logLines.js +0 -16
  144. package/dist/jsx/extractor/normalizeTernaries.js +0 -51
  145. package/dist/jsx/extractor/removeUnusedHooks.js +0 -77
  146. package/dist/jsx/index.js +0 -13
  147. package/dist/jsx/patchReactNativeWeb.js +0 -106
  148. package/dist/jsx/types.js +0 -0
  149. package/types/constants.d.ts.map +0 -1
  150. package/types/extractor/accessSafe.d.ts.map +0 -1
  151. package/types/extractor/babelParse.d.ts.map +0 -1
  152. package/types/extractor/buildClassName.d.ts.map +0 -1
  153. package/types/extractor/createEvaluator.d.ts.map +0 -1
  154. package/types/extractor/createExtractor.d.ts.map +0 -1
  155. package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
  156. package/types/extractor/evaluateAstNode.d.ts.map +0 -1
  157. package/types/extractor/extractHelpers.d.ts.map +0 -1
  158. package/types/extractor/extractMediaStyle.d.ts.map +0 -1
  159. package/types/extractor/extractToClassNames.d.ts.map +0 -1
  160. package/types/extractor/findTopmostFunction.d.ts.map +0 -1
  161. package/types/extractor/generatedUid.d.ts.map +0 -1
  162. package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
  163. package/types/extractor/getSourceModule.d.ts.map +0 -1
  164. package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
  165. package/types/extractor/hoistClassNames.d.ts.map +0 -1
  166. package/types/extractor/literalToAst.d.ts.map +0 -1
  167. package/types/extractor/loadTamagui.d.ts.map +0 -1
  168. package/types/extractor/logLines.d.ts.map +0 -1
  169. package/types/extractor/normalizeTernaries.d.ts.map +0 -1
  170. package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
  171. package/types/index.d.ts.map +0 -1
  172. package/types/patchReactNativeWeb.d.ts.map +0 -1
  173. package/types/types.d.ts.map +0 -1
@@ -1,102 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
26
- var __objRest = (source, exclude) => {
27
- var target = {};
28
- for (var prop in source)
29
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
30
- target[prop] = source[prop];
31
- if (source != null && __getOwnPropSymbols)
32
- for (var prop of __getOwnPropSymbols(source)) {
33
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
34
- target[prop] = source[prop];
35
- }
36
- return target;
37
- };
38
- var __export = (target, all) => {
39
- __markAsModule(target);
40
- for (var name in all)
41
- __defProp(target, name, { get: all[name], enumerable: true });
42
- };
43
- var __reExport = (target, module2, desc) => {
44
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
45
- for (let key of __getOwnPropNames(module2))
46
- if (!__hasOwnProp.call(target, key) && key !== "default")
47
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
48
- }
49
- return target;
50
- };
51
- var __toModule = (module2) => {
52
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
53
- };
54
- __export(exports, {
55
- normalizeTernaries: () => normalizeTernaries
56
- });
57
- var import_generator = __toModule(require("@babel/generator"));
58
- var t = __toModule(require("@babel/types"));
59
- var import_invariant = __toModule(require("invariant"));
60
- function normalizeTernaries(ternaries) {
61
- (0, import_invariant.default)(Array.isArray(ternaries), "extractStaticTernaries expects param 1 to be an array of ternaries");
62
- if (ternaries.length === 0) {
63
- return [];
64
- }
65
- const ternariesByKey = {};
66
- for (let idx = -1, len = ternaries.length; ++idx < len; ) {
67
- const _a = ternaries[idx], { test, consequent, alternate, remove } = _a, rest = __objRest(_a, ["test", "consequent", "alternate", "remove"]);
68
- let ternaryTest = test;
69
- if (t.isExpressionStatement(test)) {
70
- ternaryTest = test.expression;
71
- }
72
- let shouldSwap = false;
73
- if (t.isUnaryExpression(test) && test.operator === "!") {
74
- ternaryTest = test.argument;
75
- shouldSwap = true;
76
- } else if (t.isBinaryExpression(test)) {
77
- if (test.operator === "!==" || test.operator === "!=") {
78
- ternaryTest = t.binaryExpression(test.operator, test.left, test.right);
79
- shouldSwap = true;
80
- }
81
- }
82
- const key = (0, import_generator.default)(ternaryTest).code;
83
- if (!ternariesByKey[key]) {
84
- ternariesByKey[key] = __spreadProps(__spreadValues({}, rest), {
85
- alternate: {},
86
- consequent: {},
87
- test: ternaryTest,
88
- remove
89
- });
90
- }
91
- const altStyle = (shouldSwap ? consequent : alternate) ?? {};
92
- const consStyle = (shouldSwap ? alternate : consequent) ?? {};
93
- Object.assign(ternariesByKey[key].alternate, altStyle);
94
- Object.assign(ternariesByKey[key].consequent, consStyle);
95
- }
96
- const ternaryExpression = Object.keys(ternariesByKey).map((key) => {
97
- return ternariesByKey[key];
98
- });
99
- return ternaryExpression;
100
- }
101
- __name(normalizeTernaries, "normalizeTernaries");
102
- //# sourceMappingURL=normalizeTernaries.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/normalizeTernaries.ts"],
4
- "sourcesContent": ["import generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport invariant from 'invariant'\n\nimport { Ternary } from '../types'\n\nexport function normalizeTernaries(ternaries: Ternary[]) {\n invariant(Array.isArray(ternaries), 'extractStaticTernaries expects param 1 to be an array of ternaries')\n\n if (ternaries.length === 0) {\n return []\n }\n\n const ternariesByKey: { [key: string]: Ternary } = {}\n\n for (let idx = -1, len = ternaries.length; ++idx < len; ) {\n const { test, consequent, alternate, remove, ...rest } = ternaries[idx]\n\n let ternaryTest = test\n\n // strip parens\n if (t.isExpressionStatement(test)) {\n ternaryTest = (test as any).expression\n }\n\n // convert `!thing` to `thing` with swapped consequent and alternate\n let shouldSwap = false\n if (t.isUnaryExpression(test) && test.operator === '!') {\n ternaryTest = test.argument\n shouldSwap = true\n } else if (t.isBinaryExpression(test)) {\n if (test.operator === '!==' || test.operator === '!=') {\n ternaryTest = t.binaryExpression(test.operator, test.left, test.right)\n shouldSwap = true\n }\n }\n\n const key = generate(ternaryTest).code\n\n if (!ternariesByKey[key]) {\n ternariesByKey[key] = {\n ...rest,\n alternate: {},\n consequent: {},\n test: ternaryTest,\n remove,\n }\n }\n const altStyle = (shouldSwap ? consequent : alternate) ?? {}\n const consStyle = (shouldSwap ? alternate : consequent) ?? {}\n Object.assign(ternariesByKey[key].alternate, altStyle)\n Object.assign(ternariesByKey[key].consequent, consStyle)\n }\n\n const ternaryExpression = Object.keys(ternariesByKey).map((key) => {\n return ternariesByKey[key]\n })\n\n return ternaryExpression\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,uBAAqB;AACrB,QAAmB;AACnB,uBAAsB;AAIf,4BAA4B,WAAsB;AACvD,gCAAU,MAAM,QAAQ,YAAY;AAEpC,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA;AAGT,QAAM,iBAA6C;AAEnD,WAAS,MAAM,IAAI,MAAM,UAAU,QAAQ,EAAE,MAAM,OAAO;AACxD,UAAyD,eAAU,MAA3D,QAAM,YAAY,WAAW,WAAoB,IAAT,iBAAS,IAAT,CAAxC,QAAM,cAAY,aAAW;AAErC,QAAI,cAAc;AAGlB,QAAI,EAAE,sBAAsB,OAAO;AACjC,oBAAe,KAAa;AAAA;AAI9B,QAAI,aAAa;AACjB,QAAI,EAAE,kBAAkB,SAAS,KAAK,aAAa,KAAK;AACtD,oBAAc,KAAK;AACnB,mBAAa;AAAA,eACJ,EAAE,mBAAmB,OAAO;AACrC,UAAI,KAAK,aAAa,SAAS,KAAK,aAAa,MAAM;AACrD,sBAAc,EAAE,iBAAiB,KAAK,UAAU,KAAK,MAAM,KAAK;AAChE,qBAAa;AAAA;AAAA;AAIjB,UAAM,MAAM,8BAAS,aAAa;AAElC,QAAI,CAAC,eAAe,MAAM;AACxB,qBAAe,OAAO,iCACjB,OADiB;AAAA,QAEpB,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,MAAM;AAAA,QACN;AAAA;AAAA;AAGJ,UAAM,WAAY,cAAa,aAAa,cAAc;AAC1D,UAAM,YAAa,cAAa,YAAY,eAAe;AAC3D,WAAO,OAAO,eAAe,KAAK,WAAW;AAC7C,WAAO,OAAO,eAAe,KAAK,YAAY;AAAA;AAGhD,QAAM,oBAAoB,OAAO,KAAK,gBAAgB,IAAI,CAAC,QAAQ;AACjE,WAAO,eAAe;AAAA;AAGxB,SAAO;AAAA;AApDO;",
6
- "names": []
7
- }
@@ -1,101 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- __markAsModule(target);
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
13
- };
14
- var __reExport = (target, module2, desc) => {
15
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
16
- for (let key of __getOwnPropNames(module2))
17
- if (!__hasOwnProp.call(target, key) && key !== "default")
18
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
19
- }
20
- return target;
21
- };
22
- var __toModule = (module2) => {
23
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
24
- };
25
- __export(exports, {
26
- removeUnusedHooks: () => removeUnusedHooks
27
- });
28
- var t = __toModule(require("@babel/types"));
29
- const hooks = {
30
- useMedia: true,
31
- useTheme: true
32
- };
33
- function removeUnusedHooks(compFn, shouldPrintDebug) {
34
- compFn.scope.crawl();
35
- let bodyStatements = compFn == null ? void 0 : compFn.get("body");
36
- if (!bodyStatements) {
37
- console.log("no body statemnts?", compFn);
38
- return;
39
- }
40
- if (!Array.isArray(bodyStatements)) {
41
- if (bodyStatements.isFunctionExpression()) {
42
- bodyStatements = bodyStatements.scope.path.get("body");
43
- } else {
44
- bodyStatements = bodyStatements.get("body");
45
- }
46
- }
47
- if (!bodyStatements || !Array.isArray(bodyStatements)) {
48
- return;
49
- }
50
- const statements = bodyStatements;
51
- for (const statement of statements) {
52
- if (!statement.isVariableDeclaration()) {
53
- continue;
54
- }
55
- const declarations = statement.get("declarations");
56
- if (!Array.isArray(declarations)) {
57
- continue;
58
- }
59
- const isBindingReferenced = /* @__PURE__ */ __name((name) => {
60
- var _a;
61
- return !!((_a = statement.scope.getBinding(name)) == null ? void 0 : _a.referenced);
62
- }, "isBindingReferenced");
63
- for (const declarator of declarations) {
64
- const id = declarator.get("id");
65
- const init = declarator.node.init;
66
- if (Array.isArray(id) || Array.isArray(init)) {
67
- continue;
68
- }
69
- const shouldRemove = (() => {
70
- const isHook = t.isCallExpression(init) && t.isIdentifier(init.callee) && hooks[init.callee.name];
71
- if (!isHook) {
72
- return false;
73
- }
74
- if (t.isIdentifier(id.node)) {
75
- const name = id.node.name;
76
- return !isBindingReferenced(name);
77
- } else if (t.isObjectPattern(id.node)) {
78
- const propPaths = id.get("properties");
79
- return propPaths.every((prop) => {
80
- if (!prop.isObjectProperty())
81
- return false;
82
- const value = prop.get("value");
83
- if (Array.isArray(value) || !value.isIdentifier())
84
- return false;
85
- const name = value.node.name;
86
- return !isBindingReferenced(name);
87
- });
88
- }
89
- return false;
90
- })();
91
- if (shouldRemove) {
92
- declarator.remove();
93
- if (shouldPrintDebug) {
94
- console.log(` [\u{1FA9D}] removed ${id.node["name"] ?? ""}`);
95
- }
96
- }
97
- }
98
- }
99
- }
100
- __name(removeUnusedHooks, "removeUnusedHooks");
101
- //# sourceMappingURL=removeUnusedHooks.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/removeUnusedHooks.ts"],
4
- "sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\n\nconst hooks = {\n useMedia: true,\n useTheme: true,\n}\n\nexport function removeUnusedHooks(compFn: NodePath<any>, shouldPrintDebug: boolean) {\n compFn.scope.crawl()\n // check the top level statements\n let bodyStatements = compFn?.get('body')\n if (!bodyStatements) {\n console.log('no body statemnts?', compFn)\n return\n }\n if (!Array.isArray(bodyStatements)) {\n if (bodyStatements.isFunctionExpression()) {\n bodyStatements = bodyStatements.scope.path.get('body')\n } else {\n bodyStatements = bodyStatements.get('body')\n }\n }\n if (!bodyStatements || !Array.isArray(bodyStatements)) {\n return\n }\n const statements = bodyStatements as NodePath<any>[]\n for (const statement of statements) {\n if (!statement.isVariableDeclaration()) {\n continue\n }\n const declarations = statement.get('declarations')\n if (!Array.isArray(declarations)) {\n continue\n }\n const isBindingReferenced = (name: string) => {\n return !!statement.scope.getBinding(name)?.referenced\n }\n for (const declarator of declarations) {\n const id = declarator.get('id')\n const init = declarator.node.init\n if (Array.isArray(id) || Array.isArray(init)) {\n continue\n }\n const shouldRemove = (() => {\n const isHook =\n t.isCallExpression(init) && t.isIdentifier(init.callee) && hooks[init.callee.name]\n if (!isHook) {\n return false\n }\n if (t.isIdentifier(id.node)) {\n // remove \"const media = useMedia()\"\n const name = id.node.name\n return !isBindingReferenced(name)\n } else if (t.isObjectPattern(id.node)) {\n // remove \"const { sm } = useMedia()\"\n const propPaths = id.get('properties') as NodePath<any>[]\n return propPaths.every((prop) => {\n if (!prop.isObjectProperty()) return false\n const value = prop.get('value')\n if (Array.isArray(value) || !value.isIdentifier()) return false\n const name = value.node.name\n return !isBindingReferenced(name)\n })\n }\n return false\n })()\n if (shouldRemove) {\n declarator.remove()\n if (shouldPrintDebug) {\n console.log(` [\uD83E\uDE9D] removed ${id.node['name'] ?? ''}`)\n }\n }\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AACA,QAAmB;AAEnB,MAAM,QAAQ;AAAA,EACZ,UAAU;AAAA,EACV,UAAU;AAAA;AAGL,2BAA2B,QAAuB,kBAA2B;AAClF,SAAO,MAAM;AAEb,MAAI,iBAAiB,iCAAQ,IAAI;AACjC,MAAI,CAAC,gBAAgB;AACnB,YAAQ,IAAI,sBAAsB;AAClC;AAAA;AAEF,MAAI,CAAC,MAAM,QAAQ,iBAAiB;AAClC,QAAI,eAAe,wBAAwB;AACzC,uBAAiB,eAAe,MAAM,KAAK,IAAI;AAAA,WAC1C;AACL,uBAAiB,eAAe,IAAI;AAAA;AAAA;AAGxC,MAAI,CAAC,kBAAkB,CAAC,MAAM,QAAQ,iBAAiB;AACrD;AAAA;AAEF,QAAM,aAAa;AACnB,aAAW,aAAa,YAAY;AAClC,QAAI,CAAC,UAAU,yBAAyB;AACtC;AAAA;AAEF,UAAM,eAAe,UAAU,IAAI;AACnC,QAAI,CAAC,MAAM,QAAQ,eAAe;AAChC;AAAA;AAEF,UAAM,sBAAsB,wBAAC,SAAiB;AAnClD;AAoCM,aAAO,CAAC,CAAC,iBAAU,MAAM,WAAW,UAA3B,mBAAkC;AAAA,OADjB;AAG5B,eAAW,cAAc,cAAc;AACrC,YAAM,KAAK,WAAW,IAAI;AAC1B,YAAM,OAAO,WAAW,KAAK;AAC7B,UAAI,MAAM,QAAQ,OAAO,MAAM,QAAQ,OAAO;AAC5C;AAAA;AAEF,YAAM,eAAgB,OAAM;AAC1B,cAAM,SACJ,EAAE,iBAAiB,SAAS,EAAE,aAAa,KAAK,WAAW,MAAM,KAAK,OAAO;AAC/E,YAAI,CAAC,QAAQ;AACX,iBAAO;AAAA;AAET,YAAI,EAAE,aAAa,GAAG,OAAO;AAE3B,gBAAM,OAAO,GAAG,KAAK;AACrB,iBAAO,CAAC,oBAAoB;AAAA,mBACnB,EAAE,gBAAgB,GAAG,OAAO;AAErC,gBAAM,YAAY,GAAG,IAAI;AACzB,iBAAO,UAAU,MAAM,CAAC,SAAS;AAC/B,gBAAI,CAAC,KAAK;AAAoB,qBAAO;AACrC,kBAAM,QAAQ,KAAK,IAAI;AACvB,gBAAI,MAAM,QAAQ,UAAU,CAAC,MAAM;AAAgB,qBAAO;AAC1D,kBAAM,OAAO,MAAM,KAAK;AACxB,mBAAO,CAAC,oBAAoB;AAAA;AAAA;AAGhC,eAAO;AAAA;AAET,UAAI,cAAc;AAChB,mBAAW;AACX,YAAI,kBAAkB;AACpB,kBAAQ,IAAI,yBAAkB,GAAG,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AA9D3C;",
6
- "names": []
7
- }
package/dist/cjs/index.js DELETED
@@ -1,37 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
- var __export = (target, all) => {
9
- __markAsModule(target);
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __reExport = (target, module2, desc) => {
14
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
15
- for (let key of __getOwnPropNames(module2))
16
- if (!__hasOwnProp.call(target, key) && key !== "default")
17
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
18
- }
19
- return target;
20
- };
21
- var __toModule = (module2) => {
22
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
23
- };
24
- __export(exports, {
25
- TamaguiOptions: () => import_types.TamaguiOptions,
26
- createExtractor: () => import_createExtractor.createExtractor,
27
- literalToAst: () => import_literalToAst.literalToAst
28
- });
29
- var import_types = __toModule(require("./types"));
30
- var import_createExtractor = __toModule(require("./extractor/createExtractor"));
31
- var import_literalToAst = __toModule(require("./extractor/literalToAst"));
32
- __reExport(exports, __toModule(require("./constants")));
33
- __reExport(exports, __toModule(require("./extractor/extractToClassNames")));
34
- __reExport(exports, __toModule(require("./extractor/extractHelpers")));
35
- __reExport(exports, __toModule(require("./patchReactNativeWeb")));
36
- process.env.TAMAGUI_COMPILE_PROCESS = "1";
37
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["process.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport { TamaguiOptions } from './types'\nexport { createExtractor } from './extractor/createExtractor'\nexport { literalToAst } from './extractor/literalToAst'\nexport * from './constants'\nexport * from './extractor/extractToClassNames'\nexport * from './extractor/extractHelpers'\nexport * from './patchReactNativeWeb'\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA+B;AAC/B,6BAAgC;AAChC,0BAA6B;AAC7B,oBAAc;AACd,oBAAc;AACd,oBAAc;AACd,oBAAc;AARd,QAAQ,IAAI,0BAA0B;",
6
- "names": []
7
- }
@@ -1,129 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- __markAsModule(target);
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
13
- };
14
- var __reExport = (target, module2, desc) => {
15
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
16
- for (let key of __getOwnPropNames(module2))
17
- if (!__hasOwnProp.call(target, key) && key !== "default")
18
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
19
- }
20
- return target;
21
- };
22
- var __toModule = (module2) => {
23
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
24
- };
25
- __export(exports, {
26
- patchReactNativeWeb: () => patchReactNativeWeb
27
- });
28
- var fs = __toModule(require("fs"));
29
- var import_path = __toModule(require("path"));
30
- function patchReactNativeWeb() {
31
- const rootDir = require.resolve("react-native-web").replace(/\/dist.*/, "");
32
- const modulePath = import_path.default.join(rootDir, "dist", "tamagui-exports.js");
33
- const cjsPath = import_path.default.join(rootDir, "dist", "cjs", "tamagui-exports.js");
34
- const isEqual = (() => {
35
- let res = false;
36
- try {
37
- res = fs.readFileSync(modulePath, "utf-8") === moduleExports && fs.readFileSync(cjsPath, "utf-8") == cjsExports;
38
- } catch {
39
- res = false;
40
- }
41
- return res;
42
- })();
43
- if (!isEqual) {
44
- console.log("\u{1F95A} Tamagui patching react-native-web to share atomic styling primitives");
45
- console.log(" > adding", modulePath);
46
- console.log(" > adding", cjsPath);
47
- fs.writeFileSync(modulePath, moduleExports);
48
- fs.writeFileSync(cjsPath, cjsExports);
49
- }
50
- const moduleEntry = import_path.default.join(rootDir, "dist", "index.js");
51
- const moduleEntrySrc = fs.readFileSync(moduleEntry, "utf-8");
52
- if (!moduleEntrySrc.includes("// tamagui-patch-v4")) {
53
- fs.writeFileSync(moduleEntry, `${removePatch(moduleEntrySrc)}
54
-
55
- // tamagui-patch-v4
56
- import * as TExports from './tamagui-exports'
57
- export const TamaguiExports = TExports
58
- // tamagui-patch-end
59
- `);
60
- }
61
- const cjsEntry = import_path.default.join(rootDir, "dist", "cjs", "index.js");
62
- const cjsEntrySrc = fs.readFileSync(cjsEntry, "utf-8");
63
- if (!cjsEntrySrc.includes("// tamagui-patch-v4")) {
64
- fs.writeFileSync(cjsEntry, `${removePatch(cjsEntrySrc)}
65
-
66
- // tamagui-patch-v4
67
- exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
68
- // tamagui-patch-end
69
- `);
70
- }
71
- }
72
- __name(patchReactNativeWeb, "patchReactNativeWeb");
73
- function removePatch(source) {
74
- return source.replace(/\/\/ tamagui-patch([.\s\S]*)/g, "");
75
- }
76
- __name(removePatch, "removePatch");
77
- const forwardedPropsObj = `{
78
- ...fwdProps.defaultProps,
79
- ...fwdProps.accessibilityProps,
80
- ...fwdProps.clickProps,
81
- ...fwdProps.focusProps,
82
- ...fwdProps.keyboardProps,
83
- ...fwdProps.mouseProps,
84
- ...fwdProps.touchProps,
85
- ...fwdProps.styleProps,
86
- href: true,
87
- lang: true,
88
- onScroll: true,
89
- onWheel: true,
90
- pointerEvents: true
91
- }
92
- `;
93
- const moduleExports = `
94
- export { atomic } from './exports/StyleSheet/compile'
95
- export { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'
96
- export { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'
97
- export { default as i18Style } from './exports/StyleSheet/i18nStyle'
98
- export { default as createDOMProps } from './modules/createDOMProps'
99
- export { default as AccessibilityUtil } from './modules/AccessibilityUtil'
100
- export { default as createElement } from './exports/createElement'
101
- export { default as css } from './exports/StyleSheet/css'
102
- export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
103
- export { default as pick } from './modules/pick'
104
- export { default as useElementLayout } from './modules/useElementLayout'
105
- export { default as useMergeRefs } from './modules/useMergeRefs'
106
- export { default as usePlatformMethods } from './modules/usePlatformMethods'
107
- export { default as useResponderEvents } from './modules/useResponderEvents'
108
- import * as fwdProps from './modules/forwardedProps'
109
- export const forwardedProps = ${forwardedPropsObj}
110
- `;
111
- const cjsExports = `
112
- exports.atomic = require('./exports/StyleSheet/compile').atomic
113
- exports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')
114
- exports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')
115
- exports.i18Style = require('./exports/StyleSheet/i18nStyle')
116
- exports.createDOMProps = require('./modules/createDOMProps')
117
- exports.AccessibilityUtil = require('./modules/AccessibilityUtil')
118
- exports.createElement = require('./exports/createElement')
119
- exports.css = require('./exports/StyleSheet/css')
120
- exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
121
- exports.pick = require('./modules/pick')
122
- exports.useElementLayout = require('./modules/useElementLayout')
123
- exports.useMergeRefs = require('./modules/useMergeRefs')
124
- exports.usePlatformMethods = require('./modules/usePlatformMethods')
125
- exports.useResponderEvents = require('./modules/useResponderEvents')
126
- const fwdProps = require('./modules/forwardedProps')
127
- exports.forwardedProps = ${forwardedPropsObj}
128
- `;
129
- //# sourceMappingURL=patchReactNativeWeb.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/patchReactNativeWeb.ts"],
4
- "sourcesContent": ["import * as fs from 'fs'\nimport path from 'path'\n\n// were patching react-native-web so we can use some internal methods\n// we do it this way because we need to rely on webpack or bundler config to determine cjs vs esm\n// so we can't just require it all directly\n// would be nice in the future to be able to eject from react-native-web entirely optionally\n\n// keep it sync\nexport function patchReactNativeWeb() {\n const rootDir = require.resolve('react-native-web').replace(/\\/dist.*/, '')\n const modulePath = path.join(rootDir, 'dist', 'tamagui-exports.js')\n const cjsPath = path.join(rootDir, 'dist', 'cjs', 'tamagui-exports.js')\n\n const isEqual = (() => {\n let res = false\n try {\n res =\n fs.readFileSync(modulePath, 'utf-8') === moduleExports &&\n fs.readFileSync(cjsPath, 'utf-8') == cjsExports\n } catch {\n res = false\n }\n return res\n })()\n\n if (!isEqual) {\n console.log('\uD83E\uDD5A Tamagui patching react-native-web to share atomic styling primitives')\n console.log(' > adding', modulePath)\n console.log(' > adding', cjsPath)\n fs.writeFileSync(modulePath, moduleExports)\n fs.writeFileSync(cjsPath, cjsExports)\n }\n\n // if entry files not patched, patch them:\n const moduleEntry = path.join(rootDir, 'dist', 'index.js')\n const moduleEntrySrc = fs.readFileSync(moduleEntry, 'utf-8')\n if (!moduleEntrySrc.includes('// tamagui-patch-v4')) {\n fs.writeFileSync(\n moduleEntry,\n `${removePatch(moduleEntrySrc)}\n\n// tamagui-patch-v4\nimport * as TExports from './tamagui-exports'\nexport const TamaguiExports = TExports\n// tamagui-patch-end\n`\n )\n }\n const cjsEntry = path.join(rootDir, 'dist', 'cjs', 'index.js')\n const cjsEntrySrc = fs.readFileSync(cjsEntry, 'utf-8')\n if (!cjsEntrySrc.includes('// tamagui-patch-v4')) {\n fs.writeFileSync(\n cjsEntry,\n `${removePatch(cjsEntrySrc)}\n\n// tamagui-patch-v4\nexports.TamaguiExports = _interopRequireDefault(require(\"./tamagui-exports\"));\n// tamagui-patch-end\n`\n )\n }\n}\n\nfunction removePatch(source: string) {\n return source.replace(/\\/\\/ tamagui-patch([.\\s\\S]*)/g, '')\n}\n\n// view exports/View.ts\nconst forwardedPropsObj = `{\n ...fwdProps.defaultProps,\n ...fwdProps.accessibilityProps,\n ...fwdProps.clickProps,\n ...fwdProps.focusProps,\n ...fwdProps.keyboardProps,\n ...fwdProps.mouseProps,\n ...fwdProps.touchProps,\n ...fwdProps.styleProps,\n href: true,\n lang: true,\n onScroll: true,\n onWheel: true,\n pointerEvents: true\n}\n`\n\nconst moduleExports = `\nexport { atomic } from './exports/StyleSheet/compile'\nexport { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'\nexport { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'\nexport { default as i18Style } from './exports/StyleSheet/i18nStyle'\nexport { default as createDOMProps } from './modules/createDOMProps'\nexport { default as AccessibilityUtil } from './modules/AccessibilityUtil'\nexport { default as createElement } from './exports/createElement'\nexport { default as css } from './exports/StyleSheet/css'\nexport { default as TextAncestorContext } from './exports/Text/TextAncestorContext'\nexport { default as pick } from './modules/pick'\nexport { default as useElementLayout } from './modules/useElementLayout'\nexport { default as useMergeRefs } from './modules/useMergeRefs'\nexport { default as usePlatformMethods } from './modules/usePlatformMethods'\nexport { default as useResponderEvents } from './modules/useResponderEvents'\nimport * as fwdProps from './modules/forwardedProps'\nexport const forwardedProps = ${forwardedPropsObj}\n`\n\nconst cjsExports = `\nexports.atomic = require('./exports/StyleSheet/compile').atomic\nexports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')\nexports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')\nexports.i18Style = require('./exports/StyleSheet/i18nStyle')\nexports.createDOMProps = require('./modules/createDOMProps')\nexports.AccessibilityUtil = require('./modules/AccessibilityUtil')\nexports.createElement = require('./exports/createElement')\nexports.css = require('./exports/StyleSheet/css')\nexports.TextAncestorContext = require('./exports/Text/TextAncestorContext')\nexports.pick = require('./modules/pick')\nexports.useElementLayout = require('./modules/useElementLayout')\nexports.useMergeRefs = require('./modules/useMergeRefs')\nexports.usePlatformMethods = require('./modules/usePlatformMethods')\nexports.useResponderEvents = require('./modules/useResponderEvents')\nconst fwdProps = require('./modules/forwardedProps')\nexports.forwardedProps = ${forwardedPropsObj}\n`\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,kBAAiB;AAQV,+BAA+B;AACpC,QAAM,UAAU,AAAgB,oCAAoB,QAAQ,YAAY;AACxE,QAAM,aAAa,oBAAK,KAAK,SAAS,QAAQ;AAC9C,QAAM,UAAU,oBAAK,KAAK,SAAS,QAAQ,OAAO;AAElD,QAAM,UAAW,OAAM;AACrB,QAAI,MAAM;AACV,QAAI;AACF,YACE,GAAG,aAAa,YAAY,aAAa,iBACzC,GAAG,aAAa,SAAS,YAAY;AAAA,YACvC;AACA,YAAM;AAAA;AAER,WAAO;AAAA;AAGT,MAAI,CAAC,SAAS;AACZ,YAAQ,IAAI;AACZ,YAAQ,IAAI,eAAe;AAC3B,YAAQ,IAAI,eAAe;AAC3B,OAAG,cAAc,YAAY;AAC7B,OAAG,cAAc,SAAS;AAAA;AAI5B,QAAM,cAAc,oBAAK,KAAK,SAAS,QAAQ;AAC/C,QAAM,iBAAiB,GAAG,aAAa,aAAa;AACpD,MAAI,CAAC,eAAe,SAAS,wBAAwB;AACnD,OAAG,cACD,aACA,GAAG,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASnB,QAAM,WAAW,oBAAK,KAAK,SAAS,QAAQ,OAAO;AACnD,QAAM,cAAc,GAAG,aAAa,UAAU;AAC9C,MAAI,CAAC,YAAY,SAAS,wBAAwB;AAChD,OAAG,cACD,UACA,GAAG,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA7CL;AAuDhB,qBAAqB,QAAgB;AACnC,SAAO,OAAO,QAAQ,iCAAiC;AAAA;AADhD;AAKT,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB1B,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAgBU;AAAA;AAGhC,MAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAgBQ;AAAA;",
6
- "names": []
7
- }
package/dist/cjs/types.js DELETED
@@ -1,4 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
3
- __markAsModule(exports);
4
- //# sourceMappingURL=types.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/types.ts"],
4
- "sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\n\nexport type ClassNameObject = t.StringLiteral | t.Expression\n\nexport interface CacheObject {\n [key: string]: any\n}\n\nexport interface TamaguiOptions {\n // module paths you want to compile with tamagui (for example ['tamagui'])\n components: string[]\n // your tamagui.config.ts\n config?: string\n evaluateVars?: boolean\n importsWhitelist?: string[]\n disableExtraction?: boolean\n disableDebugAttr?: boolean\n disableExtractInlineMedia?: boolean\n disableExtractVariables?: boolean\n exclude?: RegExp\n logTimings?: boolean\n\n // probably non user options\n cssPath?: string\n cssData?: any\n deoptProps?: Set<string>\n excludeProps?: string[]\n}\n\nexport type ExtractedAttrAttr = {\n type: 'attr'\n value: t.JSXAttribute | t.JSXSpreadAttribute\n}\n\nexport type ExtractedAttrStyle = {\n type: 'style'\n value: Object\n attr?: t.JSXAttribute | t.JSXSpreadAttribute\n name?: string\n}\n\nexport type ExtractedAttr =\n | ExtractedAttrAttr\n | { type: 'ternary'; value: Ternary }\n | ExtractedAttrStyle\n\nexport type ExtractTagProps = {\n attrs: ExtractedAttr[]\n node: t.JSXOpeningElement\n attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any\n jsxPath: NodePath<t.JSXElement>\n programPath: NodePath<t.Program>\n originalNodeName: string\n lineNumbers: string\n filePath: string\n isFlattened: boolean\n}\n\nexport type ExtractorParseProps = TamaguiOptions & {\n sourcePath?: string\n shouldPrintDebug?: boolean\n onExtractTag: (props: ExtractTagProps) => void\n getFlattenedNode: (props: { isTextView: boolean; tag: string }) => string\n}\n\nexport interface Ternary {\n test: t.Expression\n // shorthand props that don't use hooks\n inlineMediaQuery?: string\n remove: Function\n consequent: Object | null\n alternate: Object | null\n}\n\nexport type StyleObject = {\n property: string\n value: string\n className: string\n identifier: string\n rules: string[]\n}\n\nexport type ClassNameToStyleObj = {\n [key: string]: StyleObject\n}\n\nexport interface PluginContext {\n write: (path: string, rules: { [key: string]: string }) => any\n}\n"],
5
- "mappings": ";;AAAA;",
6
- "names": []
7
- }
@@ -1,10 +0,0 @@
1
- import findCacheDir from "find-cache-dir";
2
- const CSS_FILE_NAME = "__snack.css";
3
- const MEDIA_SEP = "_";
4
- const cacheDir = findCacheDir({ name: "tamagui", create: true });
5
- export {
6
- CSS_FILE_NAME,
7
- MEDIA_SEP,
8
- cacheDir
9
- };
10
- //# sourceMappingURL=constants.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 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"],
5
- "mappings": "AAAA;AAEO,MAAM,gBAAgB;AAItB,MAAM,YAAY;AAGlB,MAAM,WAAW,aAAa,EAAE,MAAM,WAAW,QAAQ;",
6
- "names": []
7
- }
@@ -1,11 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import * as t from "@babel/types";
4
- function accessSafe(obj, member) {
5
- return t.logicalExpression("&&", t.logicalExpression("&&", t.binaryExpression("===", t.unaryExpression("typeof", obj), t.stringLiteral("object")), t.binaryExpression("!==", obj, t.nullLiteral())), t.memberExpression(obj, t.identifier(member), false));
6
- }
7
- __name(accessSafe, "accessSafe");
8
- export {
9
- accessSafe
10
- };
11
- //# sourceMappingURL=accessSafe.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/accessSafe.ts"],
4
- "sourcesContent": ["import * as t from '@babel/types'\n\n// accessSafe wraps memberExpressions in object/null checks\n// TODO: inject this as a function? this gets pretty repetitive\nexport function accessSafe(obj: t.Expression, member: string): t.LogicalExpression {\n return t.logicalExpression(\n '&&',\n t.logicalExpression(\n '&&',\n // typeof obj === 'object\n t.binaryExpression('===', t.unaryExpression('typeof', obj), t.stringLiteral('object')),\n // obj !== null\n t.binaryExpression('!==', obj, t.nullLiteral())\n ),\n // obj.member\n t.memberExpression(obj, t.identifier(member), false)\n )\n}\n"],
5
- "mappings": ";;AAAA;AAIO,oBAAoB,KAAmB,QAAqC;AACjF,SAAO,EAAE,kBACP,MACA,EAAE,kBACA,MAEA,EAAE,iBAAiB,OAAO,EAAE,gBAAgB,UAAU,MAAM,EAAE,cAAc,YAE5E,EAAE,iBAAiB,OAAO,KAAK,EAAE,iBAGnC,EAAE,iBAAiB,KAAK,EAAE,WAAW,SAAS;AAAA;AAXlC;",
6
- "names": []
7
- }
@@ -1,30 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import * as babelParser from "@babel/parser";
4
- const parserOptions = Object.freeze({
5
- plugins: [
6
- "asyncGenerators",
7
- "classProperties",
8
- "dynamicImport",
9
- "functionBind",
10
- "jsx",
11
- "numericSeparator",
12
- "objectRestSpread",
13
- "optionalCatchBinding",
14
- "decorators-legacy",
15
- "typescript",
16
- "optionalChaining",
17
- "nullishCoalescingOperator"
18
- ],
19
- sourceType: "module"
20
- });
21
- const parser = babelParser.parse.bind(babelParser);
22
- function babelParse(code) {
23
- return parser(code.toString(), parserOptions);
24
- }
25
- __name(babelParse, "babelParse");
26
- export {
27
- babelParse,
28
- parserOptions
29
- };
30
- //# sourceMappingURL=babelParse.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/babelParse.ts"],
4
- "sourcesContent": ["import * as babelParser from '@babel/parser'\n\nexport const parserOptions: babelParser.ParserOptions = Object.freeze({\n plugins: [\n 'asyncGenerators',\n 'classProperties',\n 'dynamicImport',\n 'functionBind',\n 'jsx',\n 'numericSeparator',\n 'objectRestSpread',\n 'optionalCatchBinding',\n 'decorators-legacy',\n 'typescript',\n 'optionalChaining',\n 'nullishCoalescingOperator',\n // 'objectRestSpread',\n // 'dynamicImport'\n ],\n sourceType: 'module',\n})\n\nconst parser = babelParser.parse.bind(babelParser)\n\nexport function babelParse(code: string | Buffer): any {\n return parser(code.toString(), parserOptions)\n}\n"],
5
- "mappings": ";;AAAA;AAEO,MAAM,gBAA2C,OAAO,OAAO;AAAA,EACpE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAIF,YAAY;AAAA;AAGd,MAAM,SAAS,YAAY,MAAM,KAAK;AAE/B,oBAAoB,MAA4B;AACrD,SAAO,OAAO,KAAK,YAAY;AAAA;AADjB;",
6
- "names": []
7
- }
@@ -1,40 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import * as t from "@babel/types";
4
- function buildClassName(classNameObjects) {
5
- return classNameObjects.reduce((acc, val) => {
6
- if (acc == null) {
7
- if (t.isConditionalExpression(val) || t.isStringLiteral(val) || t.isNumericLiteral(val)) {
8
- return val;
9
- }
10
- return t.logicalExpression("||", val, t.stringLiteral(""));
11
- }
12
- let inner;
13
- if (t.isStringLiteral(val)) {
14
- if (t.isStringLiteral(acc)) {
15
- return t.stringLiteral(`${acc.value} ${val.value}`);
16
- }
17
- inner = t.stringLiteral(` ${val.value}`);
18
- } else if (t.isLiteral(val)) {
19
- inner = t.binaryExpression("+", t.stringLiteral(" "), val);
20
- } else if (t.isConditionalExpression(val) || t.isBinaryExpression(val)) {
21
- if (t.isStringLiteral(acc)) {
22
- return t.binaryExpression("+", t.stringLiteral(`${acc.value} `), val);
23
- }
24
- inner = t.binaryExpression("+", t.stringLiteral(" "), val);
25
- } else if (t.isIdentifier(val) || t.isMemberExpression(val)) {
26
- inner = t.conditionalExpression(val, t.binaryExpression("+", t.stringLiteral(" "), val), t.stringLiteral(""));
27
- } else {
28
- if (t.isStringLiteral(acc)) {
29
- return t.binaryExpression("+", t.stringLiteral(`${acc.value} `), t.logicalExpression("||", val, t.stringLiteral("")));
30
- }
31
- inner = t.binaryExpression("+", t.stringLiteral(" "), t.logicalExpression("||", val, t.stringLiteral("")));
32
- }
33
- return t.binaryExpression("+", acc, inner);
34
- }, null);
35
- }
36
- __name(buildClassName, "buildClassName");
37
- export {
38
- buildClassName
39
- };
40
- //# sourceMappingURL=buildClassName.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/extractor/buildClassName.ts"],
4
- "sourcesContent": ["import * as t from '@babel/types'\n\nimport { ClassNameObject } from '../types'\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;AAIO,wBACL,kBACuC;AACvC,SAAO,iBAAiB,OAA4B,CAAC,KAAK,QAAQ;AAChE,QAAI,OAAO,MAAM;AACf,UAEE,EAAE,wBAAwB,QAE1B,EAAE,gBAAgB,QAClB,EAAE,iBAAiB,MACnB;AACA,eAAO;AAAA;AAET,aAAO,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc;AAAA;AAGxD,QAAI;AACJ,QAAI,EAAE,gBAAgB,MAAM;AAC1B,UAAI,EAAE,gBAAgB,MAAM;AAE1B,eAAO,EAAE,cAAc,GAAG,IAAI,SAAS,IAAI;AAAA;AAE7C,cAAQ,EAAE,cAAc,IAAI,IAAI;AAAA,eACvB,EAAE,UAAU,MAAM;AAC3B,cAAQ,EAAE,iBAAiB,KAAK,EAAE,cAAc,MAAM;AAAA,eAC7C,EAAE,wBAAwB,QAAQ,EAAE,mBAAmB,MAAM;AACtE,UAAI,EAAE,gBAAgB,MAAM;AAC1B,eAAO,EAAE,iBAAiB,KAAK,EAAE,cAAc,GAAG,IAAI,WAAW;AAAA;AAEnE,cAAQ,EAAE,iBAAiB,KAAK,EAAE,cAAc,MAAM;AAAA,eAC7C,EAAE,aAAa,QAAQ,EAAE,mBAAmB,MAAM;AAE3D,cAAQ,EAAE,sBACR,KACA,EAAE,iBAAiB,KAAK,EAAE,cAAc,MAAM,MAC9C,EAAE,cAAc;AAAA,WAEb;AACL,UAAI,EAAE,gBAAgB,MAAM;AAC1B,eAAO,EAAE,iBACP,KACA,EAAE,cAAc,GAAG,IAAI,WACvB,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc;AAAA;AAInD,cAAQ,EAAE,iBACR,KACA,EAAE,cAAc,MAChB,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc;AAAA;AAInD,WAAO,EAAE,iBAAiB,KAAK,KAAK;AAAA,KACnC;AAAA;AAvDW;",
6
- "names": []
7
- }
@@ -1,51 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import vm from "vm";
4
- import generate from "@babel/generator";
5
- import * as t from "@babel/types";
6
- import { FAILED_EVAL } from "./createExtractor";
7
- import { evaluateAstNode } from "./evaluateAstNode";
8
- import { isValidThemeHook } from "./extractHelpers";
9
- function createEvaluator({
10
- tamaguiConfig,
11
- staticNamespace,
12
- sourcePath,
13
- traversePath,
14
- shouldPrintDebug
15
- }) {
16
- const evalFn = /* @__PURE__ */ __name((n) => {
17
- if (t.isMemberExpression(n) && t.isIdentifier(n.property) && isValidThemeHook(traversePath, n, sourcePath)) {
18
- const key = n.property.name;
19
- if (shouldPrintDebug) {
20
- console.log(" > found theme prop", key);
21
- }
22
- console.log("SHOULD FIND THEME (NESTED NOW)", key);
23
- return `var(--${key})`;
24
- }
25
- if (t.isIdentifier(n) && staticNamespace.hasOwnProperty(n.name)) {
26
- return staticNamespace[n.name];
27
- }
28
- const evalContext = vm.createContext(staticNamespace);
29
- const code = `(${generate(n).code})`;
30
- return vm.runInContext(code, evalContext);
31
- }, "evalFn");
32
- return (n) => {
33
- return evaluateAstNode(n, evalFn);
34
- };
35
- }
36
- __name(createEvaluator, "createEvaluator");
37
- function createSafeEvaluator(attemptEval) {
38
- return (n) => {
39
- try {
40
- return attemptEval(n);
41
- } catch (err) {
42
- return FAILED_EVAL;
43
- }
44
- };
45
- }
46
- __name(createSafeEvaluator, "createSafeEvaluator");
47
- export {
48
- createEvaluator,
49
- createSafeEvaluator
50
- };
51
- //# sourceMappingURL=createEvaluator.js.map