@tamagui/static 1.0.0-alpha.37 → 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 -847
  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 -96
  89. package/dist/esm/extractor/extractHelpers.js.map +0 -7
  90. package/dist/esm/extractor/extractMediaStyle.js +0 -152
  91. package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
  92. package/dist/esm/extractor/extractToClassNames.js +0 -242
  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 -53
  113. package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
  114. package/dist/esm/extractor/removeUnusedHooks.js +0 -80
  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 -846
  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 -95
  133. package/dist/jsx/extractor/extractMediaStyle.js +0 -151
  134. package/dist/jsx/extractor/extractToClassNames.js +0 -241
  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 -52
  145. package/dist/jsx/extractor/removeUnusedHooks.js +0 -79
  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,48 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import generate from "@babel/generator";
4
- import * as t from "@babel/types";
5
- import { accessSafe } from "./accessSafe";
6
- function getPropValueFromAttributes(propName, attrs) {
7
- let propIndex = -1;
8
- let jsxAttr = null;
9
- for (let idx = -1, len = attrs.length; ++idx < len; ) {
10
- const attr = attrs[idx];
11
- if (t.isJSXAttribute(attr) && attr.name && attr.name.name === propName) {
12
- propIndex = idx;
13
- jsxAttr = attr;
14
- break;
15
- }
16
- }
17
- if (!jsxAttr || jsxAttr.value == null) {
18
- return null;
19
- }
20
- let propValue = jsxAttr.value;
21
- if (t.isJSXExpressionContainer(propValue)) {
22
- propValue = propValue.expression;
23
- }
24
- if (t.isJSXEmptyExpression(propValue)) {
25
- console.error("encountered JSXEmptyExpression");
26
- return null;
27
- }
28
- const applicableSpreads = attrs.filter((attr, idx) => {
29
- if (t.isJSXSpreadAttribute(attr)) {
30
- if (t.isIdentifier(attr.argument) || t.isMemberExpression(attr.argument)) {
31
- return idx > propIndex;
32
- }
33
- if (t.isLogicalExpression(attr.argument)) {
34
- return false;
35
- }
36
- throw new Error(`unsupported spread of type "${attr.argument.type}": ${generate(attr).code}`);
37
- }
38
- return false;
39
- }).map((attr) => attr.argument);
40
- if (applicableSpreads.length > 0) {
41
- propValue = applicableSpreads.reduce((acc, val) => t.logicalExpression("||", accessSafe(val, propName), acc), propValue);
42
- }
43
- return propValue;
44
- }
45
- __name(getPropValueFromAttributes, "getPropValueFromAttributes");
46
- export {
47
- getPropValueFromAttributes
48
- };
@@ -1,68 +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 getSourceModule(itemName, itemBinding) {
5
- if (!itemBinding.constant) {
6
- return null;
7
- }
8
- let sourceModule;
9
- let imported;
10
- let local;
11
- let destructured;
12
- let usesImportSyntax = false;
13
- const itemNode = itemBinding.path.node;
14
- if (t.isImportDefaultSpecifier(itemNode) || t.isImportSpecifier(itemNode)) {
15
- if (t.isImportDeclaration(itemBinding.path.parent)) {
16
- sourceModule = itemBinding.path.parent.source.value;
17
- local = itemNode.local.name;
18
- usesImportSyntax = true;
19
- if (t.isImportSpecifier(itemNode)) {
20
- imported = itemNode.imported["name"];
21
- destructured = true;
22
- } else {
23
- imported = itemNode.local.name;
24
- destructured = false;
25
- }
26
- }
27
- } else if (t.isVariableDeclarator(itemNode) && itemNode.init != null && t.isCallExpression(itemNode.init) && t.isIdentifier(itemNode.init.callee) && itemNode.init.callee.name === "require" && itemNode.init.arguments.length === 1) {
28
- const firstArg = itemNode.init.arguments[0];
29
- if (!t.isStringLiteral(firstArg)) {
30
- return null;
31
- }
32
- sourceModule = firstArg.value;
33
- if (t.isIdentifier(itemNode.id)) {
34
- local = itemNode.id.name;
35
- imported = itemNode.id.name;
36
- destructured = false;
37
- } else if (t.isObjectPattern(itemNode.id)) {
38
- for (const objProp of itemNode.id.properties) {
39
- if (t.isObjectProperty(objProp) && t.isIdentifier(objProp.value) && objProp.value.name === itemName) {
40
- local = objProp.value.name;
41
- imported = objProp.key.name;
42
- destructured = true;
43
- break;
44
- }
45
- }
46
- if (!local || !imported) {
47
- console.error("could not find prop with value `%s`", itemName);
48
- return null;
49
- }
50
- } else {
51
- console.error("Unhandled id type: %s", itemNode.id.type);
52
- return null;
53
- }
54
- } else {
55
- return null;
56
- }
57
- return {
58
- destructured,
59
- imported,
60
- local,
61
- sourceModule,
62
- usesImportSyntax
63
- };
64
- }
65
- __name(getSourceModule, "getSourceModule");
66
- export {
67
- getSourceModule
68
- };
@@ -1,127 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { dirname, extname, resolve } from "path";
4
- import * as t from "@babel/types";
5
- import { existsSync } from "fs-extra";
6
- import { evaluateAstNode } from "./evaluateAstNode";
7
- import { getSourceModule } from "./getSourceModule";
8
- const isLocalImport = /* @__PURE__ */ __name((path) => path.startsWith(".") || path.startsWith("/"), "isLocalImport");
9
- function resolveImportPath(sourcePath, path) {
10
- const sourceDir = dirname(sourcePath);
11
- if (isLocalImport(path)) {
12
- if (extname(path) === "") {
13
- path += ".js";
14
- }
15
- return resolve(sourceDir, path);
16
- }
17
- return path;
18
- }
19
- __name(resolveImportPath, "resolveImportPath");
20
- function importModule(path) {
21
- const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
22
- for (const file of filenames) {
23
- if (existsSync(file)) {
24
- return require(file);
25
- }
26
- }
27
- return null;
28
- }
29
- __name(importModule, "importModule");
30
- function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCache, shouldPrintDebug) {
31
- const bindings = scope.getAllBindings();
32
- const ret = {};
33
- if (shouldPrintDebug) {
34
- console.log(" ", Object.keys(bindings).length, "variables in scope");
35
- }
36
- const program = scope.getProgramParent().block;
37
- for (const node of program.body) {
38
- if (t.isImportDeclaration(node)) {
39
- const importPath = node.source.value;
40
- if (!node.specifiers.length)
41
- continue;
42
- if (!isLocalImport(importPath)) {
43
- continue;
44
- }
45
- const moduleName = resolveImportPath(sourcePath, importPath);
46
- const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
47
- if (!isOnWhitelist)
48
- continue;
49
- const src = importModule(moduleName);
50
- if (!src)
51
- continue;
52
- for (const specifier of node.specifiers) {
53
- if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
54
- if (typeof src[specifier.imported.name] !== "undefined") {
55
- const val = src[specifier.local.name];
56
- ret[specifier.local.name] = val;
57
- }
58
- }
59
- }
60
- }
61
- }
62
- if (!bindingCache) {
63
- throw new Error("bindingCache is a required param");
64
- }
65
- for (const k in bindings) {
66
- const binding = bindings[k];
67
- const sourceModule = getSourceModule(k, binding);
68
- if (sourceModule) {
69
- if (!sourceModule.sourceModule) {
70
- continue;
71
- }
72
- const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule);
73
- const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
74
- if (isOnWhitelist) {
75
- const src = importModule(moduleName);
76
- if (!src) {
77
- console.log(`\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`);
78
- return {};
79
- }
80
- if (sourceModule.destructured) {
81
- if (sourceModule.imported) {
82
- ret[k] = src[sourceModule.imported];
83
- }
84
- } else {
85
- ret[k] = src;
86
- }
87
- }
88
- continue;
89
- }
90
- const { parent, parentPath } = binding.path;
91
- if (!t.isVariableDeclaration(parent) || parent.kind !== "const") {
92
- continue;
93
- }
94
- const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k);
95
- if (!dec || !dec.init) {
96
- continue;
97
- }
98
- if (typeof dec.id.start !== "number" || typeof dec.id.end !== "number") {
99
- console.error("dec.id.start/end is not a number");
100
- continue;
101
- }
102
- if (!t.isIdentifier(dec.id)) {
103
- console.error("dec is not an identifier");
104
- continue;
105
- }
106
- const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`;
107
- if (bindingCache.hasOwnProperty(cacheKey)) {
108
- ret[k] = bindingCache[cacheKey];
109
- continue;
110
- }
111
- if (bindingCache.hasOwnProperty(cacheKey)) {
112
- ret[k] = bindingCache[cacheKey];
113
- continue;
114
- }
115
- try {
116
- ret[k] = evaluateAstNode(dec.init, void 0, shouldPrintDebug);
117
- bindingCache[cacheKey] = ret[k];
118
- continue;
119
- } catch (e) {
120
- }
121
- }
122
- return ret;
123
- }
124
- __name(getStaticBindingsForScope, "getStaticBindingsForScope");
125
- export {
126
- getStaticBindingsForScope
127
- };
@@ -1,43 +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 hoistClassNames(path, existing, expr) {
5
- const hoist = hoistClassNames.bind(null, path, existing);
6
- if (t.isStringLiteral(expr)) {
7
- if (expr.value.trim() === "") {
8
- return expr;
9
- }
10
- if (existing[expr.value]) {
11
- return existing[expr.value];
12
- }
13
- const identifier = replaceStringWithVariable(expr);
14
- existing[expr.value] = identifier;
15
- return identifier;
16
- }
17
- if (t.isBinaryExpression(expr)) {
18
- return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right));
19
- }
20
- if (t.isLogicalExpression(expr)) {
21
- return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right));
22
- }
23
- if (t.isConditionalExpression(expr)) {
24
- return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate));
25
- }
26
- return expr;
27
- function replaceStringWithVariable(str) {
28
- const uid = path.scope.generateUidIdentifier("cn");
29
- const parent = path.findParent((path2) => path2.isProgram());
30
- if (!parent)
31
- throw new Error(`no program?`);
32
- const variable = t.variableDeclaration("const", [
33
- t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`))
34
- ]);
35
- parent.unshiftContainer("body", variable);
36
- return uid;
37
- }
38
- __name(replaceStringWithVariable, "replaceStringWithVariable");
39
- }
40
- __name(hoistClassNames, "hoistClassNames");
41
- export {
42
- hoistClassNames
43
- };
@@ -1,33 +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 literalToAst(literal) {
5
- if (literal === null) {
6
- return t.nullLiteral();
7
- }
8
- switch (typeof literal) {
9
- case "function":
10
- throw new Error("Unsupported");
11
- case "number":
12
- return t.numericLiteral(literal);
13
- case "string":
14
- return t.stringLiteral(literal);
15
- case "boolean":
16
- return t.booleanLiteral(literal);
17
- case "undefined":
18
- return t.unaryExpression("void", t.numericLiteral(0), true);
19
- default:
20
- if (Array.isArray(literal)) {
21
- return t.arrayExpression(literal.map(literalToAst));
22
- }
23
- return t.objectExpression(Object.keys(literal).filter((k) => {
24
- return typeof literal[k] !== "undefined";
25
- }).map((k) => {
26
- return t.objectProperty(t.stringLiteral(k), literalToAst(literal[k]));
27
- }));
28
- }
29
- }
30
- __name(literalToAst, "literalToAst");
31
- export {
32
- literalToAst
33
- };
@@ -1,40 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { join } from "path";
4
- import { createTamagui } from "@tamagui/core-node";
5
- let loadedTamagui = null;
6
- function loadTamagui(props) {
7
- if (loadedTamagui) {
8
- return loadedTamagui;
9
- }
10
- process.env.IS_STATIC = "is_static";
11
- const proxyWorm = require("@tamagui/fake-react-native");
12
- const Mod = require("module");
13
- const og = Mod.prototype.require;
14
- Mod.prototype.require = function(path) {
15
- if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
16
- return proxyWorm;
17
- }
18
- return og.apply(this, arguments);
19
- };
20
- const configPath = join(process.cwd(), props.config);
21
- const tamaguiConfigExport = require(configPath);
22
- const tamaguiConfig = tamaguiConfigExport["default"] || tamaguiConfigExport;
23
- const components = {};
24
- for (const module of props.components) {
25
- const exported = require(module);
26
- Object.assign(components, exported);
27
- }
28
- process.env.IS_STATIC = void 0;
29
- Mod.prototype.require = og;
30
- createTamagui(tamaguiConfig);
31
- loadedTamagui = {
32
- components,
33
- tamaguiConfig
34
- };
35
- return loadedTamagui;
36
- }
37
- __name(loadTamagui, "loadTamagui");
38
- export {
39
- loadTamagui
40
- };
@@ -1,16 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const logLines = /* @__PURE__ */ __name((str) => {
4
- let lines = [""];
5
- const items = str.split(" ");
6
- for (const item of items) {
7
- if (item.length + lines[lines.length - 1].length > 100) {
8
- lines.push("");
9
- }
10
- lines[lines.length - 1] += item + " ";
11
- }
12
- return lines.map((line, i) => " " + (i == 0 ? "" : " ") + line.trim()).join("\n");
13
- }, "logLines");
14
- export {
15
- logLines
16
- };
@@ -1,52 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import generate from "@babel/generator";
4
- import * as t from "@babel/types";
5
- import invariant from "invariant";
6
- function normalizeTernaries(ternaries) {
7
- var _a, _b;
8
- invariant(Array.isArray(ternaries), "extractStaticTernaries expects param 1 to be an array of ternaries");
9
- if (ternaries.length === 0) {
10
- return [];
11
- }
12
- const ternariesByKey = {};
13
- for (let idx = -1, len = ternaries.length; ++idx < len; ) {
14
- const { test, consequent, alternate, remove, ...rest } = ternaries[idx];
15
- let ternaryTest = test;
16
- if (t.isExpressionStatement(test)) {
17
- ternaryTest = test.expression;
18
- }
19
- let shouldSwap = false;
20
- if (t.isUnaryExpression(test) && test.operator === "!") {
21
- ternaryTest = test.argument;
22
- shouldSwap = true;
23
- } else if (t.isBinaryExpression(test)) {
24
- if (test.operator === "!==" || test.operator === "!=") {
25
- ternaryTest = t.binaryExpression(test.operator, test.left, test.right);
26
- shouldSwap = true;
27
- }
28
- }
29
- const key = generate(ternaryTest).code;
30
- if (!ternariesByKey[key]) {
31
- ternariesByKey[key] = {
32
- ...rest,
33
- alternate: {},
34
- consequent: {},
35
- test: ternaryTest,
36
- remove
37
- };
38
- }
39
- const altStyle = (_a = shouldSwap ? consequent : alternate) != null ? _a : {};
40
- const consStyle = (_b = shouldSwap ? alternate : consequent) != null ? _b : {};
41
- Object.assign(ternariesByKey[key].alternate, altStyle);
42
- Object.assign(ternariesByKey[key].consequent, consStyle);
43
- }
44
- const ternaryExpression = Object.keys(ternariesByKey).map((key) => {
45
- return ternariesByKey[key];
46
- });
47
- return ternaryExpression;
48
- }
49
- __name(normalizeTernaries, "normalizeTernaries");
50
- export {
51
- normalizeTernaries
52
- };
@@ -1,79 +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
- const hooks = {
5
- useMedia: true,
6
- useTheme: true
7
- };
8
- function removeUnusedHooks(compFn, shouldPrintDebug) {
9
- var _a;
10
- compFn.scope.crawl();
11
- let bodyStatements = compFn == null ? void 0 : compFn.get("body");
12
- if (!bodyStatements) {
13
- console.log("no body statemnts?", compFn);
14
- return;
15
- }
16
- if (!Array.isArray(bodyStatements)) {
17
- if (bodyStatements.isFunctionExpression()) {
18
- bodyStatements = bodyStatements.scope.path.get("body");
19
- } else {
20
- bodyStatements = bodyStatements.get("body");
21
- }
22
- }
23
- if (!bodyStatements || !Array.isArray(bodyStatements)) {
24
- return;
25
- }
26
- const statements = bodyStatements;
27
- for (const statement of statements) {
28
- if (!statement.isVariableDeclaration()) {
29
- continue;
30
- }
31
- const declarations = statement.get("declarations");
32
- if (!Array.isArray(declarations)) {
33
- continue;
34
- }
35
- const isBindingReferenced = /* @__PURE__ */ __name((name) => {
36
- var _a2;
37
- return !!((_a2 = statement.scope.getBinding(name)) == null ? void 0 : _a2.referenced);
38
- }, "isBindingReferenced");
39
- for (const declarator of declarations) {
40
- const id = declarator.get("id");
41
- const init = declarator.node.init;
42
- if (Array.isArray(id) || Array.isArray(init)) {
43
- continue;
44
- }
45
- const shouldRemove = (() => {
46
- const isHook = t.isCallExpression(init) && t.isIdentifier(init.callee) && hooks[init.callee.name];
47
- if (!isHook) {
48
- return false;
49
- }
50
- if (t.isIdentifier(id.node)) {
51
- const name = id.node.name;
52
- return !isBindingReferenced(name);
53
- } else if (t.isObjectPattern(id.node)) {
54
- const propPaths = id.get("properties");
55
- return propPaths.every((prop) => {
56
- if (!prop.isObjectProperty())
57
- return false;
58
- const value = prop.get("value");
59
- if (Array.isArray(value) || !value.isIdentifier())
60
- return false;
61
- const name = value.node.name;
62
- return !isBindingReferenced(name);
63
- });
64
- }
65
- return false;
66
- })();
67
- if (shouldRemove) {
68
- declarator.remove();
69
- if (shouldPrintDebug) {
70
- console.log(` [\u{1FA9D}] removed ${(_a = id.node["name"]) != null ? _a : ""}`);
71
- }
72
- }
73
- }
74
- }
75
- }
76
- __name(removeUnusedHooks, "removeUnusedHooks");
77
- export {
78
- removeUnusedHooks
79
- };
package/dist/jsx/index.js DELETED
@@ -1,13 +0,0 @@
1
- process.env.TAMAGUI_COMPILE_PROCESS = "1";
2
- import { TamaguiOptions } from "./types";
3
- import { createExtractor } from "./extractor/createExtractor";
4
- import { literalToAst } from "./extractor/literalToAst";
5
- export * from "./constants";
6
- export * from "./extractor/extractToClassNames";
7
- export * from "./extractor/extractHelpers";
8
- export * from "./patchReactNativeWeb";
9
- export {
10
- TamaguiOptions,
11
- createExtractor,
12
- literalToAst
13
- };
@@ -1,106 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import * as fs from "fs";
4
- import path from "path";
5
- function patchReactNativeWeb() {
6
- const rootDir = require.resolve("react-native-web").replace(/\/dist.*/, "");
7
- const modulePath = path.join(rootDir, "dist", "tamagui-exports.js");
8
- const cjsPath = path.join(rootDir, "dist", "cjs", "tamagui-exports.js");
9
- const isEqual = (() => {
10
- let res = false;
11
- try {
12
- res = fs.readFileSync(modulePath, "utf-8") === moduleExports && fs.readFileSync(cjsPath, "utf-8") == cjsExports;
13
- } catch {
14
- res = false;
15
- }
16
- return res;
17
- })();
18
- if (!isEqual) {
19
- console.log("\u{1F95A} Tamagui patching react-native-web to share atomic styling primitives");
20
- console.log(" > adding", modulePath);
21
- console.log(" > adding", cjsPath);
22
- fs.writeFileSync(modulePath, moduleExports);
23
- fs.writeFileSync(cjsPath, cjsExports);
24
- }
25
- const moduleEntry = path.join(rootDir, "dist", "index.js");
26
- const moduleEntrySrc = fs.readFileSync(moduleEntry, "utf-8");
27
- if (!moduleEntrySrc.includes("// tamagui-patch-v4")) {
28
- fs.writeFileSync(moduleEntry, `${removePatch(moduleEntrySrc)}
29
-
30
- // tamagui-patch-v4
31
- import * as TExports from './tamagui-exports'
32
- export const TamaguiExports = TExports
33
- // tamagui-patch-end
34
- `);
35
- }
36
- const cjsEntry = path.join(rootDir, "dist", "cjs", "index.js");
37
- const cjsEntrySrc = fs.readFileSync(cjsEntry, "utf-8");
38
- if (!cjsEntrySrc.includes("// tamagui-patch-v4")) {
39
- fs.writeFileSync(cjsEntry, `${removePatch(cjsEntrySrc)}
40
-
41
- // tamagui-patch-v4
42
- exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
43
- // tamagui-patch-end
44
- `);
45
- }
46
- }
47
- __name(patchReactNativeWeb, "patchReactNativeWeb");
48
- function removePatch(source) {
49
- return source.replace(/\/\/ tamagui-patch([.\s\S]*)/g, "");
50
- }
51
- __name(removePatch, "removePatch");
52
- const forwardedPropsObj = `{
53
- ...fwdProps.defaultProps,
54
- ...fwdProps.accessibilityProps,
55
- ...fwdProps.clickProps,
56
- ...fwdProps.focusProps,
57
- ...fwdProps.keyboardProps,
58
- ...fwdProps.mouseProps,
59
- ...fwdProps.touchProps,
60
- ...fwdProps.styleProps,
61
- href: true,
62
- lang: true,
63
- onScroll: true,
64
- onWheel: true,
65
- pointerEvents: true
66
- }
67
- `;
68
- const moduleExports = `
69
- export { atomic } from './exports/StyleSheet/compile'
70
- export { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'
71
- export { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'
72
- export { default as i18Style } from './exports/StyleSheet/i18nStyle'
73
- export { default as createDOMProps } from './modules/createDOMProps'
74
- export { default as AccessibilityUtil } from './modules/AccessibilityUtil'
75
- export { default as createElement } from './exports/createElement'
76
- export { default as css } from './exports/StyleSheet/css'
77
- export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
78
- export { default as pick } from './modules/pick'
79
- export { default as useElementLayout } from './modules/useElementLayout'
80
- export { default as useMergeRefs } from './modules/useMergeRefs'
81
- export { default as usePlatformMethods } from './modules/usePlatformMethods'
82
- export { default as useResponderEvents } from './modules/useResponderEvents'
83
- import * as fwdProps from './modules/forwardedProps'
84
- export const forwardedProps = ${forwardedPropsObj}
85
- `;
86
- const cjsExports = `
87
- exports.atomic = require('./exports/StyleSheet/compile').atomic
88
- exports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')
89
- exports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')
90
- exports.i18Style = require('./exports/StyleSheet/i18nStyle')
91
- exports.createDOMProps = require('./modules/createDOMProps')
92
- exports.AccessibilityUtil = require('./modules/AccessibilityUtil')
93
- exports.createElement = require('./exports/createElement')
94
- exports.css = require('./exports/StyleSheet/css')
95
- exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
96
- exports.pick = require('./modules/pick')
97
- exports.useElementLayout = require('./modules/useElementLayout')
98
- exports.useMergeRefs = require('./modules/useMergeRefs')
99
- exports.usePlatformMethods = require('./modules/usePlatformMethods')
100
- exports.useResponderEvents = require('./modules/useResponderEvents')
101
- const fwdProps = require('./modules/forwardedProps')
102
- exports.forwardedProps = ${forwardedPropsObj}
103
- `;
104
- export {
105
- patchReactNativeWeb
106
- };
package/dist/jsx/types.js DELETED
File without changes
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gBAAgB,CAAA;AAI1C,eAAO,MAAM,SAAS,MAAM,CAAA;AAG5B,eAAO,MAAM,QAAQ,KAAkD,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"accessSafe.d.ts","sourceRoot":"","sources":["../../src/extractor/accessSafe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAIjC,wBAAgB,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAajF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"babelParse.d.ts","sourceRoot":"","sources":["../../src/extractor/babelParse.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,WAAW,MAAM,eAAe,CAAA;AAE5C,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,aAkBtC,CAAA;AAIF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAErD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildClassName.d.ts","sourceRoot":"","sources":["../../src/extractor/buildClassName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,eAAe,EAAE,GAClC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,aAAa,GAAG,IAAI,CAsDvC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createEvaluator.d.ts","sourceRoot":"","sources":["../../src/extractor/createEvaluator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAMlD,wBAAgB,eAAe,CAAC,EAC9B,aAAa,EACb,eAAe,EACf,UAAU,EACV,YAAY,EACZ,gBAAgB,GACjB,EAAE;IACD,aAAa,EAAE,aAAa,CAAA;IAC5B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;IACpC,gBAAgB,EAAE,OAAO,CAAA;CAC1B,OA+BY,MAAM,SAGlB;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,GAAG,OACtD,MAAM,SAOlB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,KAAK,EAAsB,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAK9E,OAAO,EAAoC,mBAAmB,EAAW,MAAM,UAAU,CAAA;AAczF,eAAO,MAAM,WAAW,eAA8B,CAAA;AActD,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;;;;;;;;wBAsBb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,+MAcrC,mBAAmB;;;;;EAojC3B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ensureImportingConcat.d.ts","sourceRoot":"","sources":["../../src/extractor/ensureImportingConcat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAMjC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAyB9D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"evaluateAstNode.d.ts","sourceRoot":"","sources":["../../src/extractor/evaluateAstNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAEjC,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,CAAC,CAAC,IAAI,GAAG,SAAS,GAAG,IAAI,EACnC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,KAAK,GAAG,EAC9B,gBAAgB,CAAC,EAAE,OAAO,GACzB,GAAG,CAkHL"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractHelpers.d.ts","sourceRoot":"","sources":["../../src/extractor/extractHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAEjC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAEjD,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC,CAE1F;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,kBAAkB,WAExD;AAED,eAAO,MAAM,OAAO,SAAU,aAAa,6BAM1C,CAAA;AAED,eAAO,MAAM,QAAQ,QAAS,GAAG,QAOhC,CAAA;AASD,eAAO,MAAM,UAAU,MAAO,OAAO,WAapC,CAAA;AAED,wBAAgB,iBAAiB,CAAC,KAAK,KAAA,sBAoBtC;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,EAC/B,CAAC,EAAE,CAAC,CAAC,gBAAgB,EACrB,UAAU,EAAE,MAAM,WAoBnB;AAED,eAAO,MAAM,eAAe,YAAa,MAAM,YAE9C,CAAA"}