@tamagui/static 2.0.0-rc.9 → 2.0.0

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 (186) hide show
  1. package/dist/check-dep-versions.cjs +201 -96
  2. package/dist/checkDeps.cjs +250 -46
  3. package/dist/constants.cjs +32 -30
  4. package/dist/exports.cjs +20 -13
  5. package/dist/extractor/accessSafe.cjs +25 -23
  6. package/dist/extractor/babelParse.cjs +30 -28
  7. package/dist/extractor/buildClassName.cjs +59 -35
  8. package/dist/extractor/bundle.cjs +187 -101
  9. package/dist/extractor/bundleConfig.cjs +568 -168
  10. package/dist/extractor/concatClassName.cjs +73 -32
  11. package/dist/extractor/createEvaluator.cjs +54 -41
  12. package/dist/extractor/createExtractor.cjs +1405 -574
  13. package/dist/extractor/createLogger.cjs +30 -25
  14. package/dist/extractor/detectModuleFormat.cjs +55 -0
  15. package/dist/extractor/ensureImportingConcat.cjs +31 -25
  16. package/dist/extractor/errors.cjs +12 -10
  17. package/dist/extractor/esbuildAliasPlugin.cjs +28 -16
  18. package/dist/extractor/esbuildTsconfigPaths.cjs +60 -36
  19. package/dist/extractor/evaluateAstNode.cjs +104 -59
  20. package/dist/extractor/extractHelpers.cjs +130 -67
  21. package/dist/extractor/extractMediaStyle.cjs +110 -69
  22. package/dist/extractor/extractToClassNames.cjs +337 -229
  23. package/dist/extractor/extractToNative.cjs +248 -152
  24. package/dist/extractor/findTopmostFunction.cjs +22 -13
  25. package/dist/extractor/generatedUid.cjs +39 -28
  26. package/dist/extractor/getPrefixLogs.cjs +12 -10
  27. package/dist/extractor/getPropValueFromAttributes.cjs +52 -34
  28. package/dist/extractor/getSourceModule.cjs +73 -37
  29. package/dist/extractor/getStaticBindingsForScope.cjs +131 -68
  30. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +20 -14
  31. package/dist/extractor/hasTopLevelAwait.cjs +62 -0
  32. package/dist/extractor/hoistClassNames.cjs +46 -32
  33. package/dist/extractor/literalToAst.cjs +67 -42
  34. package/dist/extractor/loadFile.cjs +9 -3
  35. package/dist/extractor/loadTamagui.cjs +151 -105
  36. package/dist/extractor/logLines.cjs +27 -19
  37. package/dist/extractor/normalizeTernaries.cjs +66 -44
  38. package/dist/extractor/propsToFontFamilyCache.cjs +15 -11
  39. package/dist/extractor/regenerateConfig.cjs +109 -81
  40. package/dist/extractor/removeUnusedHooks.cjs +73 -41
  41. package/dist/extractor/timer.cjs +23 -14
  42. package/dist/extractor/validHTMLAttributes.cjs +61 -59
  43. package/dist/extractor/watchTamaguiConfig.cjs +35 -23
  44. package/dist/getPragmaOptions.cjs +34 -19
  45. package/dist/helpers/memoize.cjs +24 -16
  46. package/dist/helpers/requireTamaguiCore.cjs +22 -15
  47. package/dist/index.cjs +26 -24
  48. package/dist/registerRequire.cjs +168 -65
  49. package/dist/server.cjs +35 -28
  50. package/dist/types.cjs +7 -5
  51. package/dist/worker.cjs +62 -40
  52. package/package.json +27 -24
  53. package/src/checkDeps.ts +305 -68
  54. package/src/exports.ts +2 -0
  55. package/src/extractor/babelParse.ts +1 -0
  56. package/src/extractor/bundle.ts +172 -40
  57. package/src/extractor/bundleConfig.ts +459 -65
  58. package/src/extractor/concatClassName.ts +37 -20
  59. package/src/extractor/createExtractor.ts +300 -30
  60. package/src/extractor/detectModuleFormat.ts +42 -0
  61. package/src/extractor/esbuildTsconfigPaths.ts +6 -1
  62. package/src/extractor/extractToClassNames.ts +15 -9
  63. package/src/extractor/extractToNative.ts +65 -32
  64. package/src/extractor/hasTopLevelAwait.ts +28 -0
  65. package/src/extractor/loadTamagui.ts +5 -4
  66. package/src/registerRequire.ts +102 -9
  67. package/types/checkDeps.d.ts.map +1 -1
  68. package/types/exports.d.ts +2 -0
  69. package/types/exports.d.ts.map +1 -1
  70. package/types/extractor/babelParse.d.ts.map +1 -1
  71. package/types/extractor/bundle.d.ts +83 -1
  72. package/types/extractor/bundle.d.ts.map +1 -1
  73. package/types/extractor/bundleConfig.d.ts +15 -2
  74. package/types/extractor/bundleConfig.d.ts.map +1 -1
  75. package/types/extractor/createExtractor.d.ts.map +1 -1
  76. package/types/extractor/detectModuleFormat.d.ts +5 -0
  77. package/types/extractor/detectModuleFormat.d.ts.map +1 -0
  78. package/types/extractor/esbuildTsconfigPaths.d.ts +8 -0
  79. package/types/extractor/esbuildTsconfigPaths.d.ts.map +1 -1
  80. package/types/extractor/extractToClassNames.d.ts.map +1 -1
  81. package/types/extractor/extractToNative.d.ts.map +1 -1
  82. package/types/extractor/hasTopLevelAwait.d.ts +2 -0
  83. package/types/extractor/hasTopLevelAwait.d.ts.map +1 -0
  84. package/types/extractor/loadTamagui.d.ts +1 -1
  85. package/types/extractor/loadTamagui.d.ts.map +1 -1
  86. package/types/registerRequire.d.ts.map +1 -1
  87. package/dist/check-dep-versions.js +0 -389
  88. package/dist/check-dep-versions.js.map +0 -6
  89. package/dist/checkDeps.js +0 -60
  90. package/dist/checkDeps.js.map +0 -6
  91. package/dist/constants.js +0 -34
  92. package/dist/constants.js.map +0 -6
  93. package/dist/exports.js +0 -34
  94. package/dist/exports.js.map +0 -6
  95. package/dist/extractor/accessSafe.js +0 -47
  96. package/dist/extractor/accessSafe.js.map +0 -6
  97. package/dist/extractor/babelParse.js +0 -59
  98. package/dist/extractor/babelParse.js.map +0 -6
  99. package/dist/extractor/buildClassName.js +0 -72
  100. package/dist/extractor/buildClassName.js.map +0 -6
  101. package/dist/extractor/bundle.js +0 -135
  102. package/dist/extractor/bundle.js.map +0 -6
  103. package/dist/extractor/bundleConfig.js +0 -352
  104. package/dist/extractor/bundleConfig.js.map +0 -6
  105. package/dist/extractor/concatClassName.js +0 -69
  106. package/dist/extractor/concatClassName.js.map +0 -6
  107. package/dist/extractor/createEvaluator.js +0 -66
  108. package/dist/extractor/createEvaluator.js.map +0 -6
  109. package/dist/extractor/createExtractor.js +0 -1212
  110. package/dist/extractor/createExtractor.js.map +0 -6
  111. package/dist/extractor/createLogger.js +0 -32
  112. package/dist/extractor/createLogger.js.map +0 -6
  113. package/dist/extractor/ensureImportingConcat.js +0 -50
  114. package/dist/extractor/ensureImportingConcat.js.map +0 -6
  115. package/dist/extractor/errors.js +0 -22
  116. package/dist/extractor/errors.js.map +0 -6
  117. package/dist/extractor/esbuildAliasPlugin.js +0 -36
  118. package/dist/extractor/esbuildAliasPlugin.js.map +0 -6
  119. package/dist/extractor/esbuildTsconfigPaths.js +0 -79
  120. package/dist/extractor/esbuildTsconfigPaths.js.map +0 -6
  121. package/dist/extractor/evaluateAstNode.js +0 -99
  122. package/dist/extractor/evaluateAstNode.js.map +0 -6
  123. package/dist/extractor/extractHelpers.js +0 -108
  124. package/dist/extractor/extractHelpers.js.map +0 -6
  125. package/dist/extractor/extractMediaStyle.js +0 -123
  126. package/dist/extractor/extractMediaStyle.js.map +0 -6
  127. package/dist/extractor/extractToClassNames.js +0 -351
  128. package/dist/extractor/extractToClassNames.js.map +0 -6
  129. package/dist/extractor/extractToNative.js +0 -286
  130. package/dist/extractor/extractToNative.js.map +0 -6
  131. package/dist/extractor/findTopmostFunction.js +0 -32
  132. package/dist/extractor/findTopmostFunction.js.map +0 -6
  133. package/dist/extractor/generatedUid.js +0 -42
  134. package/dist/extractor/generatedUid.js.map +0 -6
  135. package/dist/extractor/getPrefixLogs.js +0 -24
  136. package/dist/extractor/getPrefixLogs.js.map +0 -6
  137. package/dist/extractor/getPropValueFromAttributes.js +0 -65
  138. package/dist/extractor/getPropValueFromAttributes.js.map +0 -6
  139. package/dist/extractor/getSourceModule.js +0 -62
  140. package/dist/extractor/getSourceModule.js.map +0 -6
  141. package/dist/extractor/getStaticBindingsForScope.js +0 -145
  142. package/dist/extractor/getStaticBindingsForScope.js.map +0 -6
  143. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js +0 -32
  144. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js.map +0 -6
  145. package/dist/extractor/hoistClassNames.js +0 -63
  146. package/dist/extractor/hoistClassNames.js.map +0 -6
  147. package/dist/extractor/literalToAst.js +0 -90
  148. package/dist/extractor/literalToAst.js.map +0 -6
  149. package/dist/extractor/loadFile.js +0 -14
  150. package/dist/extractor/loadFile.js.map +0 -6
  151. package/dist/extractor/loadTamagui.js +0 -306
  152. package/dist/extractor/loadTamagui.js.map +0 -6
  153. package/dist/extractor/logLines.js +0 -30
  154. package/dist/extractor/logLines.js.map +0 -6
  155. package/dist/extractor/normalizeTernaries.js +0 -61
  156. package/dist/extractor/normalizeTernaries.js.map +0 -6
  157. package/dist/extractor/propsToFontFamilyCache.js +0 -33
  158. package/dist/extractor/propsToFontFamilyCache.js.map +0 -6
  159. package/dist/extractor/regenerateConfig.js +0 -123
  160. package/dist/extractor/regenerateConfig.js.map +0 -6
  161. package/dist/extractor/removeUnusedHooks.js +0 -72
  162. package/dist/extractor/removeUnusedHooks.js.map +0 -6
  163. package/dist/extractor/timer.js +0 -38
  164. package/dist/extractor/timer.js.map +0 -6
  165. package/dist/extractor/validHTMLAttributes.js +0 -72
  166. package/dist/extractor/validHTMLAttributes.js.map +0 -6
  167. package/dist/extractor/watchTamaguiConfig.js +0 -57
  168. package/dist/extractor/watchTamaguiConfig.js.map +0 -6
  169. package/dist/getPragmaOptions.js +0 -50
  170. package/dist/getPragmaOptions.js.map +0 -6
  171. package/dist/helpers/memoize.js +0 -33
  172. package/dist/helpers/memoize.js.map +0 -6
  173. package/dist/helpers/requireTamaguiCore.js +0 -30
  174. package/dist/helpers/requireTamaguiCore.js.map +0 -6
  175. package/dist/index.js +0 -30
  176. package/dist/index.js.map +0 -6
  177. package/dist/registerRequire.js +0 -100
  178. package/dist/registerRequire.js.map +0 -6
  179. package/dist/server.js +0 -58
  180. package/dist/server.js.map +0 -6
  181. package/dist/setup.js +0 -1
  182. package/dist/setup.js.map +0 -6
  183. package/dist/types.js +0 -14
  184. package/dist/types.js.map +0 -6
  185. package/dist/worker.js +0 -72
  186. package/dist/worker.js.map +0 -6
@@ -2,33 +2,35 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var extractHelpers_exports = {};
33
35
  __export(extractHelpers_exports, {
34
36
  attrStr: () => attrStr,
@@ -47,73 +49,134 @@ __export(extractHelpers_exports, {
47
49
  ternaryStr: () => ternaryStr
48
50
  });
49
51
  module.exports = __toCommonJS(extractHelpers_exports);
50
- var import_node_path = require("node:path"),
51
- import_generator = __toESM(require("@babel/generator")),
52
- t = __toESM(require("@babel/types")),
53
- import_find_root = __toESM(require("find-root")),
54
- import_memoize = require("../helpers/memoize.cjs");
52
+ var import_node_path = require("node:path");
53
+ var import_generator = __toESM(require("@babel/generator"));
54
+ var t = __toESM(require("@babel/types"));
55
+ var import_find_root = __toESM(require("find-root"));
56
+ var import_memoize = require("../helpers/memoize.cjs");
55
57
  function isPresent(input) {
56
58
  return input != null;
57
59
  }
58
60
  function isSimpleSpread(node) {
59
61
  return t.isIdentifier(node.argument) || t.isMemberExpression(node.argument);
60
62
  }
61
- const attrStr = attr => attr ? attr.type === "attr" ? getNameAttr(attr.value) : attr.type === "ternary" ? `...${ternaryStr(attr.value)}` : `${attr.type}(${objToStr(attr.value)})` : "",
62
- objToStr = (obj, spacer = ", ") => obj ? `{${Object.entries(obj).map(([k, v]) => `${k}:${Array.isArray(v) ? "[...]" : v && typeof v == "object" ? `${objToStr(v, ",")}` : JSON.stringify(v)}`).join(spacer)}}` : `${obj}`,
63
- getNameAttr = attr => t.isJSXSpreadAttribute(attr) ? `...${attr.argument.name}` : "name" in attr ? attr.name.name : `unknown-${attr.type}`,
64
- ternaryStr = x => ["ternary(", t.isIdentifier(x.test) ? x.test.name : t.isMemberExpression(x.test) ? [x.test.object.name, x.test.property.name] :
63
+ const attrStr = attr => {
64
+ return !attr ? "" : attr.type === "attr" ? getNameAttr(attr.value) : attr.type === "ternary" ? `...${ternaryStr(attr.value)}` : `${attr.type}(${objToStr(attr.value)})`;
65
+ };
66
+ const objToStr = (obj, spacer = ", ") => {
67
+ if (!obj) {
68
+ return `${obj}`;
69
+ }
70
+ return `{${Object.entries(obj).map(([k, v]) => `${k}:${Array.isArray(v) ? `[...]` : v && typeof v === "object" ? `${objToStr(v, ",")}` : JSON.stringify(v)}`).join(spacer)}}`;
71
+ };
72
+ const getNameAttr = attr => {
73
+ if (t.isJSXSpreadAttribute(attr)) {
74
+ return `...${attr.argument["name"]}`;
75
+ }
76
+ return "name" in attr ? attr.name.name : `unknown-${attr["type"]}`;
77
+ };
78
+ const ternaryStr = x => {
79
+ const conditional = t.isIdentifier(x.test) ? x.test.name : t.isMemberExpression(x.test) ? [x.test.object["name"], x.test.property["name"]] :
65
80
  // @ts-ignore
66
- (0, import_generator.default)(x.test).code, isFilledObj(x.consequent) ? ` ? ${objToStr(x.consequent)}` : " ? \u{1F6AB}", isFilledObj(x.alternate) ? ` : ${objToStr(x.alternate)}` : " : \u{1F6AB}", ")"].flat().join(""),
67
- isFilledObj = obj => obj && Object.keys(obj).length;
81
+ (0, import_generator.default)(x.test).code;
82
+ return ["ternary(", conditional, isFilledObj(x.consequent) ? ` ? ${objToStr(x.consequent)}` : " ? \u{1F6AB}", isFilledObj(x.alternate) ? ` : ${objToStr(x.alternate)}` : " : \u{1F6AB}", ")"].flat().join("");
83
+ };
84
+ const isFilledObj = obj => obj && Object.keys(obj).length;
68
85
  function findComponentName(scope) {
86
+ const componentName = "";
69
87
  let cur = scope.path;
70
- for (; cur.parentPath && !t.isProgram(cur.parentPath.parent);) cur = cur.parentPath;
88
+ while (cur.parentPath && !t.isProgram(cur.parentPath.parent)) {
89
+ cur = cur.parentPath;
90
+ }
71
91
  let node = cur.parent;
72
- if (t.isExportNamedDeclaration(node) && (node = node.declaration), t.isVariableDeclaration(node)) {
92
+ if (t.isExportNamedDeclaration(node)) {
93
+ node = node.declaration;
94
+ }
95
+ if (t.isVariableDeclaration(node)) {
73
96
  const [dec] = node.declarations;
74
- if (t.isVariableDeclarator(dec) && t.isIdentifier(dec.id)) return dec.id.name;
97
+ if (t.isVariableDeclarator(dec) && t.isIdentifier(dec.id)) {
98
+ return dec.id.name;
99
+ }
100
+ }
101
+ if (t.isFunctionDeclaration(node)) {
102
+ return node.id?.name;
75
103
  }
76
- return t.isFunctionDeclaration(node) ? node.id?.name : "";
104
+ return componentName;
77
105
  }
78
106
  function isValidThemeHook(props, jsxPath, n, sourcePath) {
79
- if (!t.isIdentifier(n.object) || !t.isIdentifier(n.property)) return !1;
80
- const binding = jsxPath.scope.getAllBindings()[n.object.name];
81
- if (!binding?.path || !binding.path.isVariableDeclarator()) return !1;
107
+ if (!t.isIdentifier(n.object) || !t.isIdentifier(n.property)) return false;
108
+ const bindings = jsxPath.scope.getAllBindings();
109
+ const binding = bindings[n.object.name];
110
+ if (!binding?.path) return false;
111
+ if (!binding.path.isVariableDeclarator()) return false;
82
112
  const init = binding.path.node.init;
83
- if (!init || !t.isCallExpression(init) || !t.isIdentifier(init.callee) || init.callee.name !== "useTheme") return !1;
113
+ if (!init || !t.isCallExpression(init)) return false;
114
+ if (!t.isIdentifier(init.callee)) return false;
115
+ if (init.callee.name !== "useTheme") return false;
84
116
  const importNode = binding.scope.getBinding("useTheme")?.path.parent;
85
- return !(!t.isImportDeclaration(importNode) || sourcePath && !isValidImport(props, sourcePath));
117
+ if (!t.isImportDeclaration(importNode)) return false;
118
+ if (sourcePath && !isValidImport(props, sourcePath)) {
119
+ return false;
120
+ }
121
+ return true;
86
122
  }
87
- const isInsideComponentPackage = (props, moduleName) => getValidComponentsPaths(props).some(path => moduleName.startsWith(path)),
88
- isComponentPackage = (props, srcName) => getValidComponentsPaths(props).some(path => srcName.startsWith(path));
123
+ const isInsideComponentPackage = (props, moduleName) => {
124
+ return getValidComponentsPaths(props).some(path => {
125
+ return moduleName.startsWith(path);
126
+ });
127
+ };
128
+ const isComponentPackage = (props, srcName) => {
129
+ return getValidComponentsPaths(props).some(path => {
130
+ return srcName.startsWith(path);
131
+ });
132
+ };
89
133
  function getValidComponent(props, moduleName, componentName) {
90
- if (componentName[0].toUpperCase() !== componentName[0]) return !1;
134
+ if (componentName[0].toUpperCase() !== componentName[0]) {
135
+ return false;
136
+ }
91
137
  for (const loaded of props.allLoadedComponents) {
92
138
  if (!loaded) continue;
93
- const isInModule = moduleName === "*" || moduleName.startsWith(loaded.moduleName),
94
- foundComponent = loaded.nameToInfo[componentName];
95
- if (isInModule && foundComponent) return foundComponent;
139
+ const isInModule = moduleName === "*" || moduleName.startsWith(loaded.moduleName);
140
+ const foundComponent = loaded.nameToInfo[componentName];
141
+ if (isInModule && foundComponent) {
142
+ return foundComponent;
143
+ }
96
144
  }
97
145
  return null;
98
146
  }
99
147
  const isValidModule = (props, moduleName) => {
100
- if (typeof moduleName != "string") throw new Error("No module name");
101
- const isLocal = moduleName.startsWith(".");
102
- return {
103
- isLocal,
104
- isValid: isLocal ? isInsideComponentPackage(props, moduleName) : isComponentPackage(props, moduleName)
105
- };
106
- },
107
- getValidImport = (props, moduleName, componentName) => {
108
- const {
109
- isValid,
110
- isLocal
111
- } = isValidModule(props, moduleName);
112
- return !isValid || !componentName ? null : getValidComponent(props, isLocal ? "*" : moduleName, componentName) || null;
113
- },
114
- isValidImport = (props, moduleName, componentName) => componentName ? !!getValidImport(props, moduleName, componentName) : isValidModule(props, moduleName).isValid,
115
- getValidComponentPackages = (0, import_memoize.memoize)(props => [... /* @__PURE__ */new Set(["@tamagui/core", "tamagui", ...(props.components || [])])]),
116
- getValidComponentsPaths = (0, import_memoize.memoize)(props => getValidComponentPackages(props).flatMap(pkg => {
148
+ if (typeof moduleName !== "string") {
149
+ throw new Error(`No module name`);
150
+ }
151
+ const isLocal = moduleName.startsWith(".");
152
+ return {
153
+ isLocal,
154
+ isValid: isLocal ? isInsideComponentPackage(props, moduleName) : isComponentPackage(props, moduleName)
155
+ };
156
+ };
157
+ const getValidImport = (props, moduleName, componentName) => {
158
+ const {
159
+ isValid,
160
+ isLocal
161
+ } = isValidModule(props, moduleName);
162
+ if (!isValid || !componentName) {
163
+ return null;
164
+ }
165
+ return getValidComponent(props, isLocal ? "*" : moduleName, componentName) || null;
166
+ };
167
+ const isValidImport = (props, moduleName, componentName) => {
168
+ if (!componentName) {
169
+ return isValidModule(props, moduleName).isValid;
170
+ }
171
+ return Boolean(getValidImport(props, moduleName, componentName));
172
+ };
173
+ const getValidComponentPackages = (0, import_memoize.memoize)(props => {
174
+ return [... /* @__PURE__ */new Set(["@tamagui/core", "tamagui", ...(props.components || [])])];
175
+ });
176
+ const getValidComponentsPaths = (0, import_memoize.memoize)(props => {
177
+ return getValidComponentPackages(props).flatMap(pkg => {
117
178
  const root = (0, import_find_root.default)(pkg);
118
- return [(0, import_node_path.basename)(root), pkg].filter(Boolean);
119
- }));
179
+ const based = (0, import_node_path.basename)(root);
180
+ return [based, pkg].filter(Boolean);
181
+ });
182
+ });
@@ -2,76 +2,98 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var extractMediaStyle_exports = {};
33
35
  __export(extractMediaStyle_exports, {
34
36
  extractMediaStyle: () => extractMediaStyle,
35
37
  isValidMediaCall: () => isValidMediaCall
36
38
  });
37
39
  module.exports = __toCommonJS(extractMediaStyle_exports);
38
- var t = __toESM(require("@babel/types")),
39
- core = __toESM(require("@tamagui/core")),
40
- import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs"),
41
- import_extractHelpers = require("./extractHelpers.cjs");
42
- function extractMediaStyle(props, ternary, jsxPath, tamaguiConfig, sourcePath, importance = 0, shouldPrintDebug = !1) {
40
+ var t = __toESM(require("@babel/types"));
41
+ var core = __toESM(require("@tamagui/core"));
42
+ var import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs");
43
+ var import_extractHelpers = require("./extractHelpers.cjs");
44
+ function extractMediaStyle(props, ternary, jsxPath, tamaguiConfig, sourcePath, importance = 0, shouldPrintDebug = false) {
43
45
  const {
44
- getCSSStylesAtomic
45
- } = (0, import_requireTamaguiCore.requireTamaguiCore)("web"),
46
- mt = getMediaQueryTernary(props, ternary, jsxPath, sourcePath);
47
- if (!mt) return null;
46
+ getCSSStylesAtomic
47
+ } = (0, import_requireTamaguiCore.requireTamaguiCore)("web");
48
+ const mt = getMediaQueryTernary(props, ternary, jsxPath, sourcePath);
49
+ if (!mt) {
50
+ return null;
51
+ }
48
52
  const {
49
53
  key
50
54
  } = mt;
51
- if (!tamaguiConfig.media[key]) return console.error(`Media query "${key}" not found: ${Object.keys(tamaguiConfig.media)}`), null;
52
- const getStyleObj = (styleObj, negate = !1) => styleObj ? {
55
+ const mq = tamaguiConfig.media[key];
56
+ if (!mq) {
57
+ console.error(`Media query "${key}" not found: ${Object.keys(tamaguiConfig.media)}`);
58
+ return null;
59
+ }
60
+ const getStyleObj = (styleObj, negate = false) => {
61
+ return styleObj ? {
53
62
  styleObj,
54
63
  negate
55
- } : null,
56
- styleOpts = [getStyleObj(ternary.consequent, !1), getStyleObj(ternary.alternate, !0)].filter(import_extractHelpers.isPresent);
57
- if (shouldPrintDebug && !styleOpts.length) return console.info(" media query, no styles?"), null;
58
- const mediaKeyPrecendence = Object.keys(tamaguiConfig.media).reduce((acc, cur, i) => (acc[cur] = new Array(importance + 1).fill(":root").join(""), acc), {});
64
+ } : null;
65
+ };
66
+ const styleOpts = [getStyleObj(ternary.consequent, false), getStyleObj(ternary.alternate, true)].filter(import_extractHelpers.isPresent);
67
+ if (shouldPrintDebug && !styleOpts.length) {
68
+ console.info(" media query, no styles?");
69
+ return null;
70
+ }
71
+ const mediaKeys = Object.keys(tamaguiConfig.media);
72
+ const mediaKeyPrecendence = mediaKeys.reduce((acc, cur, i) => {
73
+ acc[cur] = new Array(importance + 1).fill(":root").join("");
74
+ return acc;
75
+ }, {});
59
76
  let mediaStyles = [];
60
77
  for (const {
61
78
  styleObj,
62
79
  negate
63
80
  } of styleOpts) {
64
- const singleMediaStyles = getCSSStylesAtomic(styleObj).map(style => {
65
- const mediaStyle = core.createMediaStyle(style, key, tamaguiConfig.media, !0, negate),
66
- className = `.${mediaStyle[core.StyleObjectIdentifier]}`;
81
+ const styles = getCSSStylesAtomic(styleObj);
82
+ const singleMediaStyles = styles.map(style => {
83
+ const mediaStyle = core.createMediaStyle(style, key, tamaguiConfig.media, true, negate);
84
+ const className = `.${mediaStyle[core.StyleObjectIdentifier]}`;
67
85
  return {
68
86
  ...mediaStyle,
69
87
  className
70
88
  };
71
89
  });
72
- shouldPrintDebug === "verbose" && console.info(" media styles:", importance, styleObj, singleMediaStyles.map(x => x[core.StyleObjectIdentifier]).join(", ")), mediaStyles = [...mediaStyles, ...singleMediaStyles];
90
+ if (shouldPrintDebug === "verbose") {
91
+ console.info(" media styles:", importance, styleObj, singleMediaStyles.map(x => x[core.StyleObjectIdentifier]).join(", "));
92
+ }
93
+ mediaStyles = [...mediaStyles, ...singleMediaStyles];
73
94
  }
74
- return ternary.remove(), {
95
+ ternary.remove();
96
+ return {
75
97
  mediaStyles,
76
98
  ternaryWithoutMedia: mt.ternaryWithoutMedia
77
99
  };
@@ -79,40 +101,52 @@ function extractMediaStyle(props, ternary, jsxPath, tamaguiConfig, sourcePath, i
79
101
  function getMediaQueryTernary(props, ternary, jsxPath, sourcePath) {
80
102
  if (t.isLogicalExpression(ternary.test) && ternary.test.operator === "&&") {
81
103
  const mediaLeft = getMediaInfoFromExpression(props, ternary.test.left, jsxPath, sourcePath, ternary.inlineMediaQuery);
82
- if (mediaLeft) return {
83
- ...mediaLeft,
84
- ternaryWithoutMedia: {
85
- ...ternary,
86
- test: ternary.test.right
87
- }
88
- };
104
+ if (mediaLeft) {
105
+ return {
106
+ ...mediaLeft,
107
+ ternaryWithoutMedia: {
108
+ ...ternary,
109
+ test: ternary.test.right
110
+ }
111
+ };
112
+ }
89
113
  }
90
114
  const result = getMediaInfoFromExpression(props, ternary.test, jsxPath, sourcePath, ternary.inlineMediaQuery);
91
- return result ? {
92
- ...result,
93
- ternaryWithoutMedia: null
94
- } : null;
115
+ if (result) {
116
+ return {
117
+ ...result,
118
+ ternaryWithoutMedia: null
119
+ };
120
+ }
121
+ return null;
95
122
  }
96
123
  function getMediaInfoFromExpression(props, test, jsxPath, sourcePath, inlineMediaQuery) {
97
- if (inlineMediaQuery) return {
98
- key: inlineMediaQuery,
99
- bindingName: inlineMediaQuery
100
- };
124
+ if (inlineMediaQuery) {
125
+ return {
126
+ key: inlineMediaQuery,
127
+ bindingName: inlineMediaQuery
128
+ };
129
+ }
101
130
  if (t.isMemberExpression(test) && t.isIdentifier(test.object) && t.isIdentifier(test.property)) {
102
- const name = test.object.name,
103
- key = test.property.name,
104
- binding = jsxPath.scope.getAllBindings()[name];
105
- if (!binding) return !1;
131
+ const name = test.object["name"];
132
+ const key = test.property["name"];
133
+ const bindings = jsxPath.scope.getAllBindings();
134
+ const binding = bindings[name];
135
+ if (!binding) return false;
106
136
  const bindingNode = binding.path?.node;
107
- return !t.isVariableDeclarator(bindingNode) || !bindingNode.init || !isValidMediaCall(props, jsxPath, bindingNode.init, sourcePath) ? !1 : {
137
+ if (!t.isVariableDeclarator(bindingNode) || !bindingNode.init) return false;
138
+ if (!isValidMediaCall(props, jsxPath, bindingNode.init, sourcePath)) return false;
139
+ return {
108
140
  key,
109
141
  bindingName: name
110
142
  };
111
143
  }
112
144
  if (t.isIdentifier(test)) {
113
- const key = test.name,
114
- node = jsxPath.scope.getBinding(test.name)?.path?.node;
115
- return !t.isVariableDeclarator(node) || !node.init || !isValidMediaCall(props, jsxPath, node.init, sourcePath) ? !1 : {
145
+ const key = test.name;
146
+ const node = jsxPath.scope.getBinding(test.name)?.path?.node;
147
+ if (!t.isVariableDeclarator(node)) return false;
148
+ if (!node.init || !isValidMediaCall(props, jsxPath, node.init, sourcePath)) return false;
149
+ return {
116
150
  key,
117
151
  bindingName: key
118
152
  };
@@ -120,9 +154,16 @@ function getMediaInfoFromExpression(props, test, jsxPath, sourcePath, inlineMedi
120
154
  return null;
121
155
  }
122
156
  function isValidMediaCall(props, jsxPath, init, sourcePath) {
123
- if (!init || !t.isCallExpression(init) || !t.isIdentifier(init.callee) || init.callee.name !== "useMedia") return !1;
124
- const mediaBinding = jsxPath.scope.getAllBindings().useMedia;
125
- if (!mediaBinding) return !1;
157
+ if (!init || !t.isCallExpression(init)) return false;
158
+ if (!t.isIdentifier(init.callee)) return false;
159
+ if (init.callee.name !== "useMedia") return false;
160
+ const bindings = jsxPath.scope.getAllBindings();
161
+ const mediaBinding = bindings["useMedia"];
162
+ if (!mediaBinding) return false;
126
163
  const useMediaImport = mediaBinding.path.parent;
127
- return !(!t.isImportDeclaration(useMediaImport) || !(0, import_extractHelpers.isValidImport)(props, sourcePath));
164
+ if (!t.isImportDeclaration(useMediaImport)) return false;
165
+ if (!(0, import_extractHelpers.isValidImport)(props, sourcePath)) {
166
+ return false;
167
+ }
168
+ return true;
128
169
  }