@tamagui/static 1.0.1-beta.21 → 1.0.1-beta.210

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 (260) hide show
  1. package/dist/{cjs/constants.js → constants.js} +9 -4
  2. package/dist/constants.js.map +7 -0
  3. package/dist/{cjs/extractor → extractor}/accessSafe.js +14 -4
  4. package/dist/{esm/extractor → extractor}/accessSafe.js.map +2 -2
  5. package/dist/{cjs/extractor → extractor}/babelParse.js +20 -17
  6. package/dist/extractor/babelParse.js.map +7 -0
  7. package/dist/{cjs/extractor → extractor}/buildClassName.js +40 -11
  8. package/dist/extractor/buildClassName.js.map +7 -0
  9. package/dist/extractor/bundle.js +117 -0
  10. package/dist/extractor/bundle.js.map +7 -0
  11. package/dist/{cjs/extractor → extractor}/createEvaluator.js +19 -14
  12. package/dist/extractor/createEvaluator.js.map +7 -0
  13. package/dist/extractor/createExtractor.js +1645 -0
  14. package/dist/extractor/createExtractor.js.map +7 -0
  15. package/dist/{cjs/extractor → extractor}/ensureImportingConcat.js +18 -8
  16. package/dist/extractor/ensureImportingConcat.js.map +7 -0
  17. package/dist/{cjs/extractor → extractor}/evaluateAstNode.js +14 -6
  18. package/dist/{esm/extractor → extractor}/evaluateAstNode.js.map +2 -2
  19. package/dist/{cjs/extractor → extractor}/extractHelpers.js +91 -27
  20. package/dist/extractor/extractHelpers.js.map +7 -0
  21. package/dist/{cjs/extractor → extractor}/extractMediaStyle.js +49 -50
  22. package/dist/extractor/extractMediaStyle.js.map +7 -0
  23. package/dist/{cjs/extractor → extractor}/extractToClassNames.js +165 -109
  24. package/dist/extractor/extractToClassNames.js.map +7 -0
  25. package/dist/{cjs/extractor → extractor}/findTopmostFunction.js +2 -3
  26. package/dist/{esm/extractor → extractor}/findTopmostFunction.js.map +2 -2
  27. package/dist/{cjs/extractor → extractor}/generatedUid.js +9 -4
  28. package/dist/{cjs/extractor → extractor}/generatedUid.js.map +3 -3
  29. package/dist/{cjs/extractor → extractor}/getPrefixLogs.js +1 -2
  30. package/dist/extractor/getPrefixLogs.js.map +7 -0
  31. package/dist/{cjs/extractor → extractor}/getPropValueFromAttributes.js +24 -15
  32. package/dist/extractor/getPropValueFromAttributes.js.map +7 -0
  33. package/dist/{cjs/extractor → extractor}/getSourceModule.js +5 -3
  34. package/dist/{esm/extractor → extractor}/getSourceModule.js.map +2 -2
  35. package/dist/{cjs/extractor → extractor}/getStaticBindingsForScope.js +88 -38
  36. package/dist/extractor/getStaticBindingsForScope.js.map +7 -0
  37. package/dist/{cjs/extractor → extractor}/hoistClassNames.js +5 -4
  38. package/dist/{esm/extractor → extractor}/hoistClassNames.js.map +3 -3
  39. package/dist/{cjs/extractor → extractor}/literalToAst.js +26 -34
  40. package/dist/{cjs/extractor → extractor}/literalToAst.js.map +2 -2
  41. package/dist/extractor/loadFile.js +21 -0
  42. package/dist/extractor/loadFile.js.map +7 -0
  43. package/dist/extractor/loadTamagui.js +421 -0
  44. package/dist/extractor/loadTamagui.js.map +7 -0
  45. package/dist/{cjs/extractor → extractor}/logLines.js +3 -3
  46. package/dist/{cjs/extractor → extractor}/logLines.js.map +2 -2
  47. package/dist/{cjs/extractor → extractor}/normalizeTernaries.js +13 -36
  48. package/dist/extractor/normalizeTernaries.js.map +7 -0
  49. package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js +7 -5
  50. package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js.map +2 -2
  51. package/dist/{cjs/extractor → extractor}/timer.js +11 -4
  52. package/dist/extractor/timer.js.map +7 -0
  53. package/dist/{cjs/extractor → extractor}/validHTMLAttributes.js +52 -0
  54. package/dist/extractor/validHTMLAttributes.js.map +7 -0
  55. package/dist/getPragmaOptions.js +68 -0
  56. package/dist/getPragmaOptions.js.map +7 -0
  57. package/dist/helpers/memoize.js +46 -0
  58. package/dist/helpers/memoize.js.map +7 -0
  59. package/dist/{cjs/index.js → index.js} +10 -7
  60. package/dist/index.js.map +7 -0
  61. package/dist/require.js +90 -0
  62. package/dist/require.js.map +7 -0
  63. package/dist/tamagui-node/tamagui.config.js +6781 -0
  64. package/dist/{jsx/types.js → tamagui-node/tamaguicore-components.config.js} +0 -0
  65. package/dist/tamagui-node/tamaguitestdesignsystem-components.config.js +31 -0
  66. package/dist/{cjs/types.js → types.js} +1 -0
  67. package/dist/types.js.map +7 -0
  68. package/dist/webpackPlugin.js +35 -0
  69. package/dist/webpackPlugin.js.map +7 -0
  70. package/package.json +47 -35
  71. package/src/constants.ts +14 -0
  72. package/src/extractor/accessSafe.ts +18 -0
  73. package/src/extractor/babelParse.ts +28 -0
  74. package/src/extractor/buildClassName.ts +77 -0
  75. package/src/extractor/bundle.ts +110 -0
  76. package/src/extractor/createEvaluator.ts +73 -0
  77. package/src/extractor/createExtractor.ts +2133 -0
  78. package/src/extractor/ensureImportingConcat.ts +32 -0
  79. package/src/extractor/evaluateAstNode.ts +121 -0
  80. package/src/extractor/extractHelpers.ts +201 -0
  81. package/src/extractor/extractMediaStyle.ts +199 -0
  82. package/src/extractor/extractToClassNames.ts +450 -0
  83. package/src/extractor/findTopmostFunction.ts +22 -0
  84. package/src/extractor/generatedUid.ts +43 -0
  85. package/src/extractor/getPrefixLogs.ts +6 -0
  86. package/src/extractor/getPropValueFromAttributes.ts +92 -0
  87. package/src/extractor/getSourceModule.ts +101 -0
  88. package/src/extractor/getStaticBindingsForScope.ts +227 -0
  89. package/src/extractor/hoistClassNames.ts +45 -0
  90. package/src/extractor/literalToAst.ts +84 -0
  91. package/src/extractor/loadFile.ts +17 -0
  92. package/src/extractor/loadTamagui.ts +478 -0
  93. package/src/extractor/logLines.ts +16 -0
  94. package/src/extractor/normalizeTernaries.ts +63 -0
  95. package/src/extractor/removeUnusedHooks.ts +76 -0
  96. package/src/extractor/timer.ts +29 -0
  97. package/src/extractor/validHTMLAttributes.ts +99 -0
  98. package/src/getPragmaOptions.ts +53 -0
  99. package/src/helpers/memoize.ts +21 -0
  100. package/src/index.ts +11 -0
  101. package/src/require.ts +107 -0
  102. package/src/types.ts +98 -0
  103. package/src/webpackPlugin.ts +9 -0
  104. package/tamagui.tsconfig.json +5 -0
  105. package/types/constants.d.ts +1 -1
  106. package/types/extractor/babelParse.d.ts +2 -1
  107. package/types/extractor/buildClassName.d.ts +5 -2
  108. package/types/extractor/bundle.d.ts +13 -0
  109. package/types/extractor/createEvaluator.d.ts +4 -4
  110. package/types/extractor/createExtractor.d.ts +26 -11
  111. package/types/extractor/extractHelpers.d.ts +16 -4
  112. package/types/extractor/extractMediaStyle.d.ts +3 -3
  113. package/types/extractor/extractToClassNames.d.ts +5 -9
  114. package/types/extractor/getPrefixLogs.d.ts +1 -1
  115. package/types/extractor/getPropValueFromAttributes.d.ts +16 -0
  116. package/types/extractor/getStaticBindingsForScope.d.ts +2 -1
  117. package/types/extractor/loadFile.d.ts +1 -0
  118. package/types/extractor/loadTamagui.d.ts +22 -6
  119. package/types/extractor/normalizeTernaries.d.ts +1 -1
  120. package/types/extractor/validHTMLAttributes.d.ts +49 -0
  121. package/types/getPragmaOptions.d.ts +9 -0
  122. package/types/helpers/memoize.d.ts +8 -0
  123. package/types/index.d.ts +9 -7
  124. package/types/require.d.ts +4 -0
  125. package/types/types.d.ts +32 -32
  126. package/types/webpackPlugin.d.ts +4 -0
  127. package/dist/cjs/constants.js.map +0 -7
  128. package/dist/cjs/extractor/accessSafe.js.map +0 -7
  129. package/dist/cjs/extractor/babelParse.js.map +0 -7
  130. package/dist/cjs/extractor/buildClassName.js.map +0 -7
  131. package/dist/cjs/extractor/createEvaluator.js.map +0 -7
  132. package/dist/cjs/extractor/createExtractor.js +0 -1221
  133. package/dist/cjs/extractor/createExtractor.js.map +0 -7
  134. package/dist/cjs/extractor/ensureImportingConcat.js.map +0 -7
  135. package/dist/cjs/extractor/evaluateAstNode.js.map +0 -7
  136. package/dist/cjs/extractor/extractHelpers.js.map +0 -7
  137. package/dist/cjs/extractor/extractMediaStyle.js.map +0 -7
  138. package/dist/cjs/extractor/extractToClassNames.js.map +0 -7
  139. package/dist/cjs/extractor/findTopmostFunction.js.map +0 -7
  140. package/dist/cjs/extractor/getPrefixLogs.js.map +0 -7
  141. package/dist/cjs/extractor/getPropValueFromAttributes.js.map +0 -7
  142. package/dist/cjs/extractor/getSourceModule.js.map +0 -7
  143. package/dist/cjs/extractor/getStaticBindingsForScope.js.map +0 -7
  144. package/dist/cjs/extractor/hoistClassNames.js.map +0 -7
  145. package/dist/cjs/extractor/loadTamagui.js +0 -106
  146. package/dist/cjs/extractor/loadTamagui.js.map +0 -7
  147. package/dist/cjs/extractor/normalizeTernaries.js.map +0 -7
  148. package/dist/cjs/extractor/timer.js.map +0 -7
  149. package/dist/cjs/extractor/validHTMLAttributes.js.map +0 -7
  150. package/dist/cjs/index.js.map +0 -7
  151. package/dist/cjs/patchReactNativeWeb.js +0 -167
  152. package/dist/cjs/patchReactNativeWeb.js.map +0 -7
  153. package/dist/cjs/types.js.map +0 -7
  154. package/dist/esm/constants.js +0 -14
  155. package/dist/esm/constants.js.map +0 -7
  156. package/dist/esm/extractor/accessSafe.js +0 -11
  157. package/dist/esm/extractor/babelParse.js +0 -30
  158. package/dist/esm/extractor/babelParse.js.map +0 -7
  159. package/dist/esm/extractor/buildClassName.js +0 -40
  160. package/dist/esm/extractor/buildClassName.js.map +0 -7
  161. package/dist/esm/extractor/createEvaluator.js +0 -52
  162. package/dist/esm/extractor/createEvaluator.js.map +0 -7
  163. package/dist/esm/extractor/createExtractor.js +0 -1169
  164. package/dist/esm/extractor/createExtractor.js.map +0 -7
  165. package/dist/esm/extractor/ensureImportingConcat.js +0 -24
  166. package/dist/esm/extractor/ensureImportingConcat.js.map +0 -7
  167. package/dist/esm/extractor/evaluateAstNode.js +0 -94
  168. package/dist/esm/extractor/extractHelpers.js +0 -103
  169. package/dist/esm/extractor/extractHelpers.js.map +0 -7
  170. package/dist/esm/extractor/extractMediaStyle.js +0 -152
  171. package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
  172. package/dist/esm/extractor/extractToClassNames.js +0 -293
  173. package/dist/esm/extractor/extractToClassNames.js.map +0 -7
  174. package/dist/esm/extractor/findTopmostFunction.js +0 -23
  175. package/dist/esm/extractor/generatedUid.js +0 -28
  176. package/dist/esm/extractor/generatedUid.js.map +0 -7
  177. package/dist/esm/extractor/getPrefixLogs.js +0 -12
  178. package/dist/esm/extractor/getPrefixLogs.js.map +0 -7
  179. package/dist/esm/extractor/getPropValueFromAttributes.js +0 -49
  180. package/dist/esm/extractor/getPropValueFromAttributes.js.map +0 -7
  181. package/dist/esm/extractor/getSourceModule.js +0 -69
  182. package/dist/esm/extractor/getStaticBindingsForScope.js +0 -137
  183. package/dist/esm/extractor/getStaticBindingsForScope.js.map +0 -7
  184. package/dist/esm/extractor/hoistClassNames.js +0 -44
  185. package/dist/esm/extractor/literalToAst.js +0 -80
  186. package/dist/esm/extractor/literalToAst.js.map +0 -7
  187. package/dist/esm/extractor/loadTamagui.js +0 -84
  188. package/dist/esm/extractor/loadTamagui.js.map +0 -7
  189. package/dist/esm/extractor/logLines.js +0 -22
  190. package/dist/esm/extractor/logLines.js.map +0 -7
  191. package/dist/esm/extractor/normalizeTernaries.js +0 -53
  192. package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
  193. package/dist/esm/extractor/removeUnusedHooks.js +0 -80
  194. package/dist/esm/extractor/removeUnusedHooks.js.map +0 -7
  195. package/dist/esm/extractor/timer.js +0 -24
  196. package/dist/esm/extractor/timer.js.map +0 -7
  197. package/dist/esm/extractor/validHTMLAttributes.js +0 -52
  198. package/dist/esm/extractor/validHTMLAttributes.js.map +0 -7
  199. package/dist/esm/index.js +0 -14
  200. package/dist/esm/index.js.map +0 -7
  201. package/dist/esm/patchReactNativeWeb.js +0 -142
  202. package/dist/esm/patchReactNativeWeb.js.map +0 -7
  203. package/dist/esm/types.js +0 -1
  204. package/dist/esm/types.js.map +0 -7
  205. package/dist/jsx/constants.js +0 -13
  206. package/dist/jsx/extractor/accessSafe.js +0 -10
  207. package/dist/jsx/extractor/babelParse.js +0 -29
  208. package/dist/jsx/extractor/buildClassName.js +0 -39
  209. package/dist/jsx/extractor/createEvaluator.js +0 -51
  210. package/dist/jsx/extractor/createExtractor.js +0 -1168
  211. package/dist/jsx/extractor/ensureImportingConcat.js +0 -23
  212. package/dist/jsx/extractor/evaluateAstNode.js +0 -93
  213. package/dist/jsx/extractor/extractHelpers.js +0 -102
  214. package/dist/jsx/extractor/extractMediaStyle.js +0 -151
  215. package/dist/jsx/extractor/extractToClassNames.js +0 -292
  216. package/dist/jsx/extractor/findTopmostFunction.js +0 -22
  217. package/dist/jsx/extractor/generatedUid.js +0 -27
  218. package/dist/jsx/extractor/getPrefixLogs.js +0 -11
  219. package/dist/jsx/extractor/getPropValueFromAttributes.js +0 -48
  220. package/dist/jsx/extractor/getSourceModule.js +0 -68
  221. package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -136
  222. package/dist/jsx/extractor/hoistClassNames.js +0 -43
  223. package/dist/jsx/extractor/literalToAst.js +0 -79
  224. package/dist/jsx/extractor/loadTamagui.js +0 -83
  225. package/dist/jsx/extractor/logLines.js +0 -21
  226. package/dist/jsx/extractor/normalizeTernaries.js +0 -52
  227. package/dist/jsx/extractor/removeUnusedHooks.js +0 -79
  228. package/dist/jsx/extractor/timer.js +0 -23
  229. package/dist/jsx/extractor/validHTMLAttributes.js +0 -51
  230. package/dist/jsx/index.js +0 -13
  231. package/dist/jsx/patchReactNativeWeb.js +0 -141
  232. package/types/constants.d.ts.map +0 -1
  233. package/types/extractor/accessSafe.d.ts.map +0 -1
  234. package/types/extractor/babelParse.d.ts.map +0 -1
  235. package/types/extractor/buildClassName.d.ts.map +0 -1
  236. package/types/extractor/createEvaluator.d.ts.map +0 -1
  237. package/types/extractor/createExtractor.d.ts.map +0 -1
  238. package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
  239. package/types/extractor/evaluateAstNode.d.ts.map +0 -1
  240. package/types/extractor/extractHelpers.d.ts.map +0 -1
  241. package/types/extractor/extractMediaStyle.d.ts.map +0 -1
  242. package/types/extractor/extractToClassNames.d.ts.map +0 -1
  243. package/types/extractor/findTopmostFunction.d.ts.map +0 -1
  244. package/types/extractor/generatedUid.d.ts.map +0 -1
  245. package/types/extractor/getPrefixLogs.d.ts.map +0 -1
  246. package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
  247. package/types/extractor/getSourceModule.d.ts.map +0 -1
  248. package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
  249. package/types/extractor/hoistClassNames.d.ts.map +0 -1
  250. package/types/extractor/literalToAst.d.ts.map +0 -1
  251. package/types/extractor/loadTamagui.d.ts.map +0 -1
  252. package/types/extractor/logLines.d.ts.map +0 -1
  253. package/types/extractor/normalizeTernaries.d.ts.map +0 -1
  254. package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
  255. package/types/extractor/timer.d.ts.map +0 -1
  256. package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
  257. package/types/index.d.ts.map +0 -1
  258. package/types/patchReactNativeWeb.d.ts +0 -2
  259. package/types/patchReactNativeWeb.d.ts.map +0 -1
  260. package/types/types.d.ts.map +0 -1
@@ -0,0 +1,99 @@
1
+ export const validHTMLAttributes = {
2
+ autocomplete: true,
3
+ border: true,
4
+ contenteditable: true,
5
+ crossorigin: true,
6
+ dir: true,
7
+ draggable: true,
8
+ enctype: true,
9
+ formenctype: true,
10
+ formmethod: true,
11
+ formtarget: true,
12
+ inputmode: true,
13
+ kind: true,
14
+ link: true,
15
+ method: true,
16
+ preload: true,
17
+ referrerpolicy: true,
18
+ rel: true,
19
+ rev: true,
20
+ role: true,
21
+ sandbox: true,
22
+ shape: true,
23
+ spellcheck: true,
24
+ target: true,
25
+ translate: true,
26
+ type: true,
27
+ wrap: true,
28
+ 'aria-autocomplete': true,
29
+ 'aria-busy': true,
30
+ 'aria-checked': true,
31
+ 'aria-current': true,
32
+ 'aria-disabled': true,
33
+ 'aria-expanded': true,
34
+ 'aria-haspopup': true,
35
+ 'aria-hidden': true,
36
+ 'aria-invalid': true,
37
+ 'aria-polite': true,
38
+ 'aria-modal': true,
39
+ 'aria-multiline': true,
40
+ 'aria-multiselectable': true,
41
+ 'aria-orientation': true,
42
+ 'aria-pressed': true,
43
+ 'aria-readonly': true,
44
+ 'aria-relevant': true,
45
+ 'aria-required': true,
46
+ 'aria-selected': true,
47
+ 'aria-sort': true,
48
+ }
49
+
50
+ // for moving off react-native-web eventually (unused atm)
51
+ export const validAccessibilityAttributes = {
52
+ accessibilityRole: true,
53
+ accessibilityActiveDescendant: true,
54
+ accessibilityAtomic: true,
55
+ accessibilityAutoComplete: true,
56
+ accessibilityBusy: true,
57
+ accessibilityChecked: true,
58
+ accessibilityColumnCount: true,
59
+ accessibilityColumnIndex: true,
60
+ accessibilityColumnSpan: true,
61
+ accessibilityControls: true,
62
+ accessibilityCurrent: true,
63
+ accessibilityDescribedBy: true,
64
+ accessibilityDetails: true,
65
+ disabled: true,
66
+ accessibilityErrorMessage: true,
67
+ accessibilityExpanded: true,
68
+ accessibilityFlowTo: true,
69
+ accessibilityHasPopup: true,
70
+ accessibilityHidden: true,
71
+ accessibilityInvalid: true,
72
+ accessibilityKeyShortcuts: true,
73
+ accessibilityLabel: true,
74
+ accessibilityLabelledBy: true,
75
+ accessibilityLevel: true,
76
+ accessibilityLiveRegion: true,
77
+ accessibilityModal: true,
78
+ accessibilityMultiline: true,
79
+ accessibilityMultiSelectable: true,
80
+ accessibilityOrientation: true,
81
+ accessibilityOwns: true,
82
+ accessibilityPlaceholder: true,
83
+ accessibilityPosInSet: true,
84
+ accessibilityPressed: true,
85
+ accessibilityReadOnly: true,
86
+ accessibilityRequired: true,
87
+ accessibilityRoleDescription: true,
88
+ accessibilityRowCount: true,
89
+ accessibilityRowIndex: true,
90
+ accessibilityRowSpan: true,
91
+ accessibilitySelected: true,
92
+ accessibilitySetSize: true,
93
+ accessibilitySort: true,
94
+ accessibilityValueMax: true,
95
+ accessibilityValueMin: true,
96
+ accessibilityValueNow: true,
97
+ accessibilityValueText: true,
98
+ nativeID: true,
99
+ }
@@ -0,0 +1,53 @@
1
+ export function getPragmaOptions({
2
+ source,
3
+ path,
4
+ disableCommentCheck,
5
+ }: {
6
+ source: string
7
+ path: string
8
+ disableCommentCheck?: boolean
9
+ }) {
10
+ if (!disableCommentCheck && !source.startsWith('//') && !source.startsWith('/*')) {
11
+ return {
12
+ shouldPrintDebug: false,
13
+ shouldDisable: false,
14
+ }
15
+ }
16
+
17
+ let shouldPrintDebug: boolean | 'verbose' = false
18
+ let shouldDisable = false
19
+
20
+ // try and avoid too much parsing but sometimes esbuild adds helpers above..
21
+ const firstLine = source.slice(0, 800).split('\n')[0]
22
+
23
+ if (firstLine.includes('tamagui-ignore')) {
24
+ shouldDisable = true
25
+ }
26
+
27
+ if (firstLine.includes('debug')) {
28
+ shouldPrintDebug = true
29
+ }
30
+
31
+ if (firstLine.includes('debug-verbose')) {
32
+ shouldPrintDebug = 'verbose'
33
+ }
34
+
35
+ if (process.env.TAMAGUI_DEBUG_FILE) {
36
+ if (path.includes(process.env.TAMAGUI_DEBUG_FILE)) {
37
+ shouldPrintDebug = 'verbose'
38
+ }
39
+ }
40
+
41
+ if (process.env.DEBUG?.includes('tamagui')) {
42
+ shouldPrintDebug = true
43
+ }
44
+
45
+ if (process.env.DEBUG?.includes('tamagui-verbose')) {
46
+ shouldPrintDebug = 'verbose'
47
+ }
48
+
49
+ return {
50
+ shouldPrintDebug,
51
+ shouldDisable,
52
+ }
53
+ }
@@ -0,0 +1,21 @@
1
+ // @ts-nocheck
2
+ export function memoize(func?: Function, resolver?: any) {
3
+ if (typeof func !== 'function' || (resolver != null && typeof resolver !== 'function')) {
4
+ throw new TypeError('Expected a function')
5
+ }
6
+ const memoized = function (...args) {
7
+ const key = resolver ? resolver.apply(this, args) : args[0]
8
+ const cache = memoized.cache
9
+
10
+ if (cache.has(key)) {
11
+ return cache.get(key)
12
+ }
13
+ const result = func.apply(this, args)
14
+ memoized.cache = cache.set(key, result) || cache
15
+ return result
16
+ }
17
+ memoized.cache = new (memoize.Cache || Map)()
18
+ return memoized
19
+ }
20
+
21
+ memoize.Cache = Map
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ process.env.TAMAGUI_COMPILE_PROCESS = '1'
2
+
3
+ export { TamaguiOptions } from './types.js'
4
+ export { createExtractor } from './extractor/createExtractor.js'
5
+ export { literalToAst } from './extractor/literalToAst.js'
6
+ export * from './constants.js'
7
+ export * from './extractor/extractToClassNames.js'
8
+ export * from './extractor/extractHelpers.js'
9
+ export * from './extractor/loadTamagui.js'
10
+ export * from './require.js'
11
+ export * from './getPragmaOptions.js'
package/src/require.ts ADDED
@@ -0,0 +1,107 @@
1
+ import { relative, sep } from 'path'
2
+
3
+ import { SHOULD_DEBUG } from './constants.js'
4
+
5
+ const nameToPaths = {}
6
+ const Module = require('module')
7
+ const og = Module.prototype.require
8
+ globalThis['ogRequire'] = og
9
+
10
+ export const getNameToPaths = () => nameToPaths
11
+
12
+ export function registerRequire() {
13
+ if (Module.prototype.require !== globalThis['ogRequire']) {
14
+ // eslint-disable-next-line no-console
15
+ console.warn('didnt unregister before re-registering')
16
+ process.exit(1)
17
+ }
18
+
19
+ const proxyWorm = require('@tamagui/proxy-worm')
20
+ // TODO can swap with react-native-web-lite
21
+ const rnw = require('react-native-web')
22
+ const core = require('@tamagui/core-node')
23
+
24
+ Module.prototype.require = function (path: string) {
25
+ if (SHOULD_DEBUG) {
26
+ // eslint-disable-next-line no-console
27
+ console.log('tamagui:require', path)
28
+ }
29
+ if (/\.(gif|jpe?g|png|svg|ttf|otf|woff2?|bmp|webp)$/.test(path)) {
30
+ return {}
31
+ }
32
+ if (
33
+ path === '@gorhom/bottom-sheet' ||
34
+ path.startsWith('react-native-reanimated') ||
35
+ path === 'expo-linear-gradient' ||
36
+ path === '@expo/vector-icons'
37
+ ) {
38
+ return proxyWorm
39
+ }
40
+ if (
41
+ path.startsWith('react-native') &&
42
+ // allow our rnw.tsx imports through
43
+ !path.startsWith('react-native-web/dist/cjs/exports'.replace(/\//g, sep))
44
+ ) {
45
+ return rnw
46
+ }
47
+ if (path === '@tamagui/core') {
48
+ return core
49
+ }
50
+ try {
51
+ const out = og.apply(this, arguments)
52
+ // only for studio disable for now
53
+ // if (!nameToPaths[path]) {
54
+ // if (out && typeof out === 'object') {
55
+ // for (const key in out) {
56
+ // try {
57
+ // const conf = out[key]?.staticConfig as StaticConfig
58
+ // if (conf) {
59
+ // if (conf.componentName) {
60
+ // nameToPaths[conf.componentName] ??= new Set()
61
+ // const fullName = path.startsWith('.')
62
+ // ? join(`${this.path.replace(/dist(\/cjs)?/, 'src')}`, path)
63
+ // : path
64
+ // nameToPaths[conf.componentName].add(fullName)
65
+ // } else {
66
+ // // console.log('no name component', path)
67
+ // }
68
+ // }
69
+ // } catch {
70
+ // // ok
71
+ // }
72
+ // }
73
+ // }
74
+ // }
75
+ return out
76
+ } catch (err: any) {
77
+ /**
78
+ * Allow errors to happen, we're just reading config and components but sometimes external modules cause problems
79
+ * We can't fix every problem, so just swap them out with proxyWorm which is a sort of generic object that can be read.
80
+ */
81
+
82
+ if (process.env.DEBUG?.startsWith('tamagui')) {
83
+ // eslint-disable-next-line no-console
84
+ console.error(
85
+ `Tamagui failed loading the pre-built tamagui.config.ts
86
+
87
+ ${err.message}
88
+ ${err.stack}
89
+
90
+ You can see if it loads in the node repl:
91
+
92
+ require("./${relative(process.cwd(), path)}").default
93
+
94
+ `
95
+ )
96
+ }
97
+
98
+ return proxyWorm
99
+ }
100
+ }
101
+
102
+ return Module.prototype.require
103
+ }
104
+
105
+ export function unregisterRequire() {
106
+ Module.prototype.require = og
107
+ }
package/src/types.ts ADDED
@@ -0,0 +1,98 @@
1
+ import type { NodePath } from '@babel/traverse'
2
+ import * as t from '@babel/types'
3
+ import type { PseudoStyles, StaticConfig } from '@tamagui/core-node'
4
+ import type { StyleObject } from '@tamagui/helpers'
5
+ import type { TamaguiOptions } from '@tamagui/helpers-node'
6
+ import type { ViewStyle } from 'react-native'
7
+
8
+ import { LoadedComponents } from './index'
9
+
10
+ export type { TamaguiOptions } from '@tamagui/helpers-node'
11
+
12
+ export type { StyleObject } from '@tamagui/helpers'
13
+
14
+ export type ClassNameObject = t.StringLiteral | t.Expression
15
+
16
+ export interface CacheObject {
17
+ [key: string]: any
18
+ }
19
+
20
+ export interface LogOptions {
21
+ clear?: boolean
22
+ timestamp?: boolean
23
+ error?: Error | null
24
+ }
25
+
26
+ export interface Logger {
27
+ info(msg: string, options?: LogOptions): void
28
+ warn(msg: string, options?: LogOptions): void
29
+ error(msg: string, options?: LogOptions): void
30
+ }
31
+
32
+ export type ExtractorOptions = {
33
+ logger?: Logger
34
+ }
35
+
36
+ export type ExtractedAttrAttr = {
37
+ type: 'attr'
38
+ value: t.JSXAttribute | t.JSXSpreadAttribute
39
+ }
40
+
41
+ export type ExtractedAttrStyle = {
42
+ type: 'style'
43
+ value: ViewStyle & PseudoStyles
44
+ attr?: t.JSXAttribute | t.JSXSpreadAttribute
45
+ name?: string
46
+ }
47
+
48
+ export type ExtractedAttr =
49
+ | ExtractedAttrAttr
50
+ | { type: 'ternary'; value: Ternary }
51
+ | ExtractedAttrStyle
52
+
53
+ export type ExtractTagProps = {
54
+ parserProps: TamaguiOptionsWithFileInfo
55
+ attrs: ExtractedAttr[]
56
+ node: t.JSXOpeningElement
57
+ attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any
58
+ jsxPath: NodePath<t.JSXElement>
59
+ programPath: NodePath<t.Program>
60
+ originalNodeName: string
61
+ lineNumbers: string
62
+ filePath: string
63
+ isFlattened: boolean
64
+ completeProps: Record<string, any>
65
+ staticConfig: StaticConfig
66
+ }
67
+
68
+ export type TamaguiOptionsWithFileInfo = TamaguiOptions & {
69
+ sourcePath: string
70
+ allLoadedComponents: LoadedComponents[]
71
+ }
72
+
73
+ export type ExtractorParseProps = Omit<TamaguiOptionsWithFileInfo, 'allLoadedComponents'> & {
74
+ target: 'native' | 'html'
75
+ shouldPrintDebug?: boolean | 'verbose'
76
+ onExtractTag: (props: ExtractTagProps) => void
77
+ getFlattenedNode?: (props: { isTextView: boolean; tag: string }) => string
78
+ extractStyledDefinitions?: boolean
79
+ // identifer, rule
80
+ onStyleRule?: (identifier: string, rules: string[]) => void
81
+ }
82
+
83
+ export interface Ternary {
84
+ test: t.Expression
85
+ // shorthand props that don't use hooks
86
+ inlineMediaQuery?: string
87
+ remove: Function
88
+ consequent: Object | null
89
+ alternate: Object | null
90
+ }
91
+
92
+ export type ClassNameToStyleObj = {
93
+ [key: string]: StyleObject
94
+ }
95
+
96
+ export interface PluginContext {
97
+ write: (path: string, rules: { [key: string]: string }) => any
98
+ }
@@ -0,0 +1,9 @@
1
+ const pluginName = 'TamaguiWebpackPlugin'
2
+
3
+ export class TamaguiWebpackPlugin {
4
+ apply(compiler) {
5
+ compiler.hooks.run.tap(pluginName, (compilation) => {
6
+ // console.log('The webpack build process is starting!');
7
+ })
8
+ }
9
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx"
4
+ }
5
+ }
@@ -2,5 +2,5 @@ export declare const CSS_FILE_NAME = "__snack.css";
2
2
  export declare const MEDIA_SEP = "_";
3
3
  export declare const cacheDir: any;
4
4
  export declare const FAILED_EVAL: unique symbol;
5
- export declare const CONCAT_CLASSNAME_IMPORT = "concatClassName";
5
+ export declare const SHOULD_DEBUG: boolean | undefined;
6
6
  //# sourceMappingURL=constants.d.ts.map
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import * as babelParser from '@babel/parser';
3
+ import * as t from '@babel/types';
3
4
  export declare const parserOptions: babelParser.ParserOptions;
4
- export declare function babelParse(code: string | Buffer): any;
5
+ export declare function babelParse(code: string | Buffer): t.File;
5
6
  //# sourceMappingURL=babelParse.d.ts.map
@@ -1,4 +1,7 @@
1
1
  import * as t from '@babel/types';
2
- import { ClassNameObject } from '../types';
3
- export declare function buildClassName(classNameObjects: ClassNameObject[]): t.Expression | t.StringLiteral | null;
2
+ import type { ClassNameObject } from '../types.js';
3
+ declare type Builder = (objects: ClassNameObject[], extras?: string) => t.Expression | t.StringLiteral | null;
4
+ export declare const buildClassName: Builder;
5
+ export declare const buildClassNameLogic: Builder;
6
+ export {};
4
7
  //# sourceMappingURL=buildClassName.d.ts.map
@@ -0,0 +1,13 @@
1
+ import esbuild from 'esbuild';
2
+ /**
3
+ * For internal loading of new files
4
+ */
5
+ declare type Props = Omit<Partial<esbuild.BuildOptions>, 'entryPoints'> & {
6
+ outfile: string;
7
+ entryPoints: string[];
8
+ resolvePlatformSpecificEntries?: boolean;
9
+ };
10
+ export declare function bundle(props: Props, aliases?: Record<string, string>): Promise<esbuild.BuildResult>;
11
+ export declare function bundleSync(props: Props, aliases?: Record<string, string>): esbuild.BuildResult;
12
+ export {};
13
+ //# sourceMappingURL=bundle.d.ts.map
@@ -1,11 +1,11 @@
1
1
  import { NodePath } from '@babel/traverse';
2
2
  import * as t from '@babel/types';
3
- import type { TamaguiConfig } from '@tamagui/core';
4
- export declare function createEvaluator({ tamaguiConfig, staticNamespace, sourcePath, traversePath, shouldPrintDebug, }: {
5
- tamaguiConfig: TamaguiConfig;
3
+ import { TamaguiOptionsWithFileInfo } from '../types.js';
4
+ export declare function createEvaluator({ props, staticNamespace, sourcePath, traversePath, shouldPrintDebug, }: {
5
+ props: TamaguiOptionsWithFileInfo;
6
6
  staticNamespace: Record<string, any>;
7
7
  sourcePath: string;
8
- traversePath: NodePath<t.JSXElement>;
8
+ traversePath?: NodePath<t.JSXElement>;
9
9
  shouldPrintDebug: boolean | 'verbose';
10
10
  }): (n: t.Node) => any;
11
11
  export declare function createSafeEvaluator(attemptEval: (n: t.Node) => any): (n: t.Node) => any;
@@ -1,29 +1,44 @@
1
1
  import { NodePath } from '@babel/traverse';
2
2
  import * as t from '@babel/types';
3
- import { TamaguiInternalConfig } from '@tamagui/core-node';
4
- import { ExtractorParseProps } from '../types';
3
+ import type { ExtractorOptions, ExtractorParseProps, TamaguiOptions } from '../types.js';
4
+ import { cleanupBeforeExit } from './getStaticBindingsForScope.js';
5
+ import { TamaguiProjectInfo } from './loadTamagui.js';
5
6
  export declare type Extractor = ReturnType<typeof createExtractor>;
6
- export declare function createExtractor(): {
7
- getTamagui(): TamaguiInternalConfig<import("@tamagui/core-node").CreateTokens<import("@tamagui/core-node").VariableVal>, {
7
+ declare type FileOrPath = NodePath<t.Program> | t.File;
8
+ export declare function createExtractor({ logger }?: ExtractorOptions): {
9
+ options: {
10
+ logger: import("../types.js").Logger;
11
+ };
12
+ cleanupBeforeExit: typeof cleanupBeforeExit;
13
+ loadTamagui: (props: TamaguiOptions) => Promise<TamaguiProjectInfo>;
14
+ loadTamaguiSync: (props: TamaguiOptions) => TamaguiProjectInfo;
15
+ getTamagui(): import("@tamagui/core-node").TamaguiInternalConfig<import("@tamagui/core-node").CreateTokens<import("@tamagui/core-node").VariableVal>, {
8
16
  [key: string]: Partial<import("@tamagui/core-node").TamaguiBaseTheme> & {
9
17
  [key: string]: import("@tamagui/core-node").VariableVal;
10
18
  };
11
- }, {}, {
12
- [x: string]: {
19
+ }, import("@tamagui/core-node").GenericShorthands, {
20
+ [key: string]: {
13
21
  [key: string]: string | number;
14
22
  };
15
23
  }, {
16
- [key: string]: string | {
24
+ [key: string]: string | any[] | {
17
25
  [key: string]: any;
18
26
  };
19
- }, {
20
- [key: string]: import("@tamagui/core-node").GenericFont<string | number>;
21
- }>;
22
- parse: (fileOrPath: NodePath<t.Program> | t.File, { config, importsWhitelist, evaluateVars, shouldPrintDebug, sourcePath, onExtractTag, getFlattenedNode, disable, disableExtraction, disableExtractInlineMedia, disableExtractVariables, disableDebugAttr, prefixLogs, excludeProps, ...props }: ExtractorParseProps) => {
27
+ }, import("@tamagui/core-node").GenericFonts> | undefined;
28
+ parseSync: (f: FileOrPath, props: ExtractorParseProps) => {
29
+ styled: number;
23
30
  flattened: number;
24
31
  optimized: number;
25
32
  modified: number;
26
33
  found: number;
27
34
  } | null;
35
+ parse: (f: FileOrPath, props: ExtractorParseProps) => Promise<{
36
+ styled: number;
37
+ flattened: number;
38
+ optimized: number;
39
+ modified: number;
40
+ found: number;
41
+ } | null>;
28
42
  };
43
+ export {};
29
44
  //# sourceMappingURL=createExtractor.d.ts.map
@@ -1,12 +1,24 @@
1
1
  import type { NodePath } from '@babel/traverse';
2
2
  import * as t from '@babel/types';
3
- import { ExtractedAttr, Ternary } from '../types';
3
+ import type { ExtractedAttr, TamaguiOptionsWithFileInfo, Ternary } from '../types.js';
4
4
  export declare function isPresent<T extends Object>(input: null | void | undefined | T): input is T;
5
5
  export declare function isSimpleSpread(node: t.JSXSpreadAttribute): boolean;
6
- export declare const attrStr: (attr?: ExtractedAttr | undefined) => string | t.JSXIdentifier;
6
+ export declare const attrStr: (attr?: ExtractedAttr) => string | t.JSXIdentifier;
7
7
  export declare const objToStr: (obj: any, spacer?: string) => any;
8
8
  export declare const ternaryStr: (x: Ternary) => string;
9
9
  export declare function findComponentName(scope: any): string | undefined;
10
- export declare function isValidThemeHook(jsxPath: NodePath<t.JSXElement>, n: t.MemberExpression, sourcePath: string): boolean;
11
- export declare const isInsideTamagui: (srcName: string) => boolean;
10
+ export declare function isValidThemeHook(props: TamaguiOptionsWithFileInfo, jsxPath: NodePath<t.JSXElement>, n: t.MemberExpression, sourcePath: string): boolean;
11
+ export declare const isInsideComponentPackage: (props: TamaguiOptionsWithFileInfo, moduleName: string) => any;
12
+ export declare const isComponentPackage: (props: TamaguiOptionsWithFileInfo, srcName: string) => any;
13
+ export declare function getValidComponent(props: TamaguiOptionsWithFileInfo, moduleName: string, componentName: string): false | {
14
+ staticConfig: import("@tamagui/core-node").StaticConfigParsed;
15
+ } | null;
16
+ export declare const isValidModule: (props: TamaguiOptionsWithFileInfo, moduleName: string) => {
17
+ isLocal: boolean;
18
+ isValid: any;
19
+ };
20
+ export declare const getValidImport: (props: TamaguiOptionsWithFileInfo, moduleName: string, componentName?: string) => {
21
+ staticConfig: import("@tamagui/core-node").StaticConfigParsed;
22
+ } | null;
23
+ export declare const isValidImport: (props: TamaguiOptionsWithFileInfo, moduleName: string, componentName?: string) => any;
12
24
  //# sourceMappingURL=extractHelpers.d.ts.map
@@ -1,10 +1,10 @@
1
1
  import { NodePath } from '@babel/traverse';
2
2
  import * as t from '@babel/types';
3
3
  import { TamaguiInternalConfig } from '@tamagui/core-node';
4
- import { StyleObject, Ternary } from '../types';
5
- export declare function extractMediaStyle(ternary: Ternary, jsxPath: NodePath<t.JSXElement>, tamaguiConfig: TamaguiInternalConfig, sourcePath: string, importance?: number, shouldPrintDebug?: boolean | 'verbose'): {
4
+ import type { TamaguiOptionsWithFileInfo, Ternary } from '../types.js';
5
+ export declare function extractMediaStyle(props: TamaguiOptionsWithFileInfo, ternary: Ternary, jsxPath: NodePath<t.JSXElement>, tamaguiConfig: TamaguiInternalConfig, sourcePath: string, importance?: number, shouldPrintDebug?: boolean | 'verbose'): {
6
6
  mediaStyles: StyleObject[];
7
7
  ternaryWithoutMedia: Ternary | null;
8
8
  } | null;
9
- export declare function isValidMediaCall(jsxPath: NodePath<t.JSXElement>, init: t.Expression, sourcePath: string): boolean;
9
+ export declare function isValidMediaCall(props: TamaguiOptionsWithFileInfo, jsxPath: NodePath<t.JSXElement>, init: t.Expression, sourcePath: string): boolean;
10
10
  //# sourceMappingURL=extractMediaStyle.d.ts.map
@@ -1,8 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import * as t from '@babel/types';
3
- import { LoaderContext } from 'webpack';
4
- import { TamaguiOptions } from '../types';
5
- import { Extractor } from './createExtractor';
3
+ import type { TamaguiOptions } from '../types.js';
4
+ import { Extractor } from './createExtractor.js';
6
5
  export declare type ExtractedResponse = {
7
6
  js: string | Buffer;
8
7
  styles: string;
@@ -10,15 +9,12 @@ export declare type ExtractedResponse = {
10
9
  ast: t.File;
11
10
  map: any;
12
11
  };
13
- export declare function extractToClassNames({ loader, extractor, source, sourcePath, options, shouldPrintDebug, cssLoaderPath, threaded, cssPath, }: {
14
- loader: LoaderContext<any>;
15
- cssLoaderPath: string;
12
+ export declare type ExtractToClassNamesProps = {
16
13
  extractor: Extractor;
17
14
  source: string | Buffer;
18
15
  sourcePath: string;
19
16
  options: TamaguiOptions;
20
17
  shouldPrintDebug: boolean | 'verbose';
21
- cssPath: string;
22
- threaded?: boolean;
23
- }): ExtractedResponse | null;
18
+ };
19
+ export declare function extractToClassNames({ extractor, source, sourcePath, options, shouldPrintDebug, }: ExtractToClassNamesProps): Promise<ExtractedResponse | null>;
24
20
  //# sourceMappingURL=extractToClassNames.d.ts.map
@@ -1,3 +1,3 @@
1
- import { TamaguiOptions } from '../types';
1
+ import { TamaguiOptions } from '../types.js';
2
2
  export declare function getPrefixLogs(options?: TamaguiOptions): string;
3
3
  //# sourceMappingURL=getPrefixLogs.d.ts.map
@@ -1,3 +1,19 @@
1
1
  import * as t from '@babel/types';
2
+ /**
3
+ * getPropValueFromAttributes gets a prop by name from a list of attributes and accounts for potential spread operators.
4
+ * Here's an example. Given this component:
5
+ * ```
6
+ * <Block coolProp="wow" {...spread1} neatProp="ok" {...spread2} />```
7
+ * getPropValueFromAttributes will return the following:
8
+ * - for propName `coolProp`:
9
+ * ```
10
+ * accessSafe(spread1, 'coolProp') || accessSafe(spread2, 'coolProp') || 'wow'```
11
+ * - for propName `neatProp`:
12
+ * ```
13
+ * accessSafe(spread2, 'neatProp') || 'ok'```
14
+ * - for propName `notPresent`: `null`
15
+ *
16
+ * The returned value should (obviously) be placed after spread operators.
17
+ */
2
18
  export declare function getPropValueFromAttributes(propName: string, attrs: (t.JSXAttribute | t.JSXSpreadAttribute)[]): t.Expression | null;
3
19
  //# sourceMappingURL=getPropValueFromAttributes.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import { NodePath } from '@babel/traverse';
2
2
  import * as t from '@babel/types';
3
- export declare function getStaticBindingsForScope(scope: NodePath<t.JSXElement>['scope'], whitelist: string[] | undefined, sourcePath: string, bindingCache: Record<string, string | null>, shouldPrintDebug: boolean | 'verbose'): Record<string, any>;
3
+ export declare function cleanupBeforeExit(): void;
4
+ export declare function getStaticBindingsForScope(scope: NodePath<t.JSXElement>['scope'], whitelist: string[] | undefined, sourcePath: string, bindingCache: Record<string, string | null>, shouldPrintDebug: boolean | 'verbose'): Promise<Record<string, any>>;
4
5
  //# sourceMappingURL=getStaticBindingsForScope.d.ts.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=loadFile.d.ts.map