@tamagui/static 2.0.0-rc.4 → 2.0.0-rc.40

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 (185) 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 +18 -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 +177 -101
  9. package/dist/extractor/bundleConfig.cjs +554 -167
  10. package/dist/extractor/concatClassName.cjs +41 -29
  11. package/dist/extractor/createEvaluator.cjs +54 -41
  12. package/dist/extractor/createExtractor.cjs +1400 -581
  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 -154
  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 +149 -104
  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 +38 -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 +167 -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 +26 -22
  53. package/src/checkDeps.ts +305 -68
  54. package/src/exports.ts +1 -0
  55. package/src/extractor/babelParse.ts +1 -0
  56. package/src/extractor/bundle.ts +140 -37
  57. package/src/extractor/bundleConfig.ts +435 -61
  58. package/src/extractor/createExtractor.ts +283 -48
  59. package/src/extractor/detectModuleFormat.ts +42 -0
  60. package/src/extractor/esbuildTsconfigPaths.ts +6 -1
  61. package/src/extractor/extractToClassNames.ts +15 -9
  62. package/src/extractor/extractToNative.ts +66 -33
  63. package/src/extractor/hasTopLevelAwait.ts +28 -0
  64. package/src/extractor/loadTamagui.ts +2 -2
  65. package/src/getPragmaOptions.ts +6 -1
  66. package/src/registerRequire.ts +88 -8
  67. package/types/checkDeps.d.ts.map +1 -1
  68. package/types/exports.d.ts +1 -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/getPragmaOptions.d.ts.map +1 -1
  85. package/types/registerRequire.d.ts.map +1 -1
  86. package/dist/check-dep-versions.js +0 -389
  87. package/dist/check-dep-versions.js.map +0 -6
  88. package/dist/checkDeps.js +0 -60
  89. package/dist/checkDeps.js.map +0 -6
  90. package/dist/constants.js +0 -34
  91. package/dist/constants.js.map +0 -6
  92. package/dist/exports.js +0 -34
  93. package/dist/exports.js.map +0 -6
  94. package/dist/extractor/accessSafe.js +0 -47
  95. package/dist/extractor/accessSafe.js.map +0 -6
  96. package/dist/extractor/babelParse.js +0 -59
  97. package/dist/extractor/babelParse.js.map +0 -6
  98. package/dist/extractor/buildClassName.js +0 -72
  99. package/dist/extractor/buildClassName.js.map +0 -6
  100. package/dist/extractor/bundle.js +0 -135
  101. package/dist/extractor/bundle.js.map +0 -6
  102. package/dist/extractor/bundleConfig.js +0 -352
  103. package/dist/extractor/bundleConfig.js.map +0 -6
  104. package/dist/extractor/concatClassName.js +0 -69
  105. package/dist/extractor/concatClassName.js.map +0 -6
  106. package/dist/extractor/createEvaluator.js +0 -66
  107. package/dist/extractor/createEvaluator.js.map +0 -6
  108. package/dist/extractor/createExtractor.js +0 -1215
  109. package/dist/extractor/createExtractor.js.map +0 -6
  110. package/dist/extractor/createLogger.js +0 -32
  111. package/dist/extractor/createLogger.js.map +0 -6
  112. package/dist/extractor/ensureImportingConcat.js +0 -50
  113. package/dist/extractor/ensureImportingConcat.js.map +0 -6
  114. package/dist/extractor/errors.js +0 -22
  115. package/dist/extractor/errors.js.map +0 -6
  116. package/dist/extractor/esbuildAliasPlugin.js +0 -36
  117. package/dist/extractor/esbuildAliasPlugin.js.map +0 -6
  118. package/dist/extractor/esbuildTsconfigPaths.js +0 -79
  119. package/dist/extractor/esbuildTsconfigPaths.js.map +0 -6
  120. package/dist/extractor/evaluateAstNode.js +0 -99
  121. package/dist/extractor/evaluateAstNode.js.map +0 -6
  122. package/dist/extractor/extractHelpers.js +0 -108
  123. package/dist/extractor/extractHelpers.js.map +0 -6
  124. package/dist/extractor/extractMediaStyle.js +0 -123
  125. package/dist/extractor/extractMediaStyle.js.map +0 -6
  126. package/dist/extractor/extractToClassNames.js +0 -351
  127. package/dist/extractor/extractToClassNames.js.map +0 -6
  128. package/dist/extractor/extractToNative.js +0 -286
  129. package/dist/extractor/extractToNative.js.map +0 -6
  130. package/dist/extractor/findTopmostFunction.js +0 -32
  131. package/dist/extractor/findTopmostFunction.js.map +0 -6
  132. package/dist/extractor/generatedUid.js +0 -42
  133. package/dist/extractor/generatedUid.js.map +0 -6
  134. package/dist/extractor/getPrefixLogs.js +0 -24
  135. package/dist/extractor/getPrefixLogs.js.map +0 -6
  136. package/dist/extractor/getPropValueFromAttributes.js +0 -65
  137. package/dist/extractor/getPropValueFromAttributes.js.map +0 -6
  138. package/dist/extractor/getSourceModule.js +0 -62
  139. package/dist/extractor/getSourceModule.js.map +0 -6
  140. package/dist/extractor/getStaticBindingsForScope.js +0 -145
  141. package/dist/extractor/getStaticBindingsForScope.js.map +0 -6
  142. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js +0 -32
  143. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js.map +0 -6
  144. package/dist/extractor/hoistClassNames.js +0 -63
  145. package/dist/extractor/hoistClassNames.js.map +0 -6
  146. package/dist/extractor/literalToAst.js +0 -90
  147. package/dist/extractor/literalToAst.js.map +0 -6
  148. package/dist/extractor/loadFile.js +0 -14
  149. package/dist/extractor/loadFile.js.map +0 -6
  150. package/dist/extractor/loadTamagui.js +0 -306
  151. package/dist/extractor/loadTamagui.js.map +0 -6
  152. package/dist/extractor/logLines.js +0 -30
  153. package/dist/extractor/logLines.js.map +0 -6
  154. package/dist/extractor/normalizeTernaries.js +0 -61
  155. package/dist/extractor/normalizeTernaries.js.map +0 -6
  156. package/dist/extractor/propsToFontFamilyCache.js +0 -33
  157. package/dist/extractor/propsToFontFamilyCache.js.map +0 -6
  158. package/dist/extractor/regenerateConfig.js +0 -123
  159. package/dist/extractor/regenerateConfig.js.map +0 -6
  160. package/dist/extractor/removeUnusedHooks.js +0 -72
  161. package/dist/extractor/removeUnusedHooks.js.map +0 -6
  162. package/dist/extractor/timer.js +0 -38
  163. package/dist/extractor/timer.js.map +0 -6
  164. package/dist/extractor/validHTMLAttributes.js +0 -72
  165. package/dist/extractor/validHTMLAttributes.js.map +0 -6
  166. package/dist/extractor/watchTamaguiConfig.js +0 -57
  167. package/dist/extractor/watchTamaguiConfig.js.map +0 -6
  168. package/dist/getPragmaOptions.js +0 -46
  169. package/dist/getPragmaOptions.js.map +0 -6
  170. package/dist/helpers/memoize.js +0 -33
  171. package/dist/helpers/memoize.js.map +0 -6
  172. package/dist/helpers/requireTamaguiCore.js +0 -30
  173. package/dist/helpers/requireTamaguiCore.js.map +0 -6
  174. package/dist/index.js +0 -30
  175. package/dist/index.js.map +0 -6
  176. package/dist/registerRequire.js +0 -100
  177. package/dist/registerRequire.js.map +0 -6
  178. package/dist/server.js +0 -58
  179. package/dist/server.js.map +0 -6
  180. package/dist/setup.js +0 -1
  181. package/dist/setup.js.map +0 -6
  182. package/dist/types.js +0 -14
  183. package/dist/types.js.map +0 -6
  184. package/dist/worker.js +0 -72
  185. 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 generatedUid_exports = {};
33
35
  __export(generatedUid_exports, {
34
36
  generateUid: () => generateUid
@@ -36,12 +38,21 @@ __export(generatedUid_exports, {
36
38
  module.exports = __toCommonJS(generatedUid_exports);
37
39
  var t = __toESM(require("@babel/types"));
38
40
  function generateUid(scope, name) {
39
- if (typeof scope != "object") throw "generateUid expects a scope object as its first parameter";
40
- if (!(typeof name == "string" && name !== "")) throw "generateUid expects a valid name as its second parameter";
41
+ if (!(typeof scope === "object")) throw "generateUid expects a scope object as its first parameter";
42
+ if (!(typeof name === "string" && name !== "")) throw "generateUid expects a valid name as its second parameter";
41
43
  name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
42
- let uid,
43
- i = 0;
44
- do i > 1 ? uid = name + i : uid = name, i++; while (scope.hasLabel(uid) || scope.hasBinding(uid) || scope.hasGlobal(uid) || scope.hasReference(uid));
44
+ let uid;
45
+ let i = 0;
46
+ do {
47
+ if (i > 1) {
48
+ uid = name + i;
49
+ } else {
50
+ uid = name;
51
+ }
52
+ i++;
53
+ } while (scope.hasLabel(uid) || scope.hasBinding(uid) || scope.hasGlobal(uid) || scope.hasReference(uid));
45
54
  const program = scope.getProgramParent();
46
- return program.references[uid] = !0, program.uids[uid] = !0, uid;
55
+ program.references[uid] = true;
56
+ program.uids[uid] = true;
57
+ return uid;
47
58
  }
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var getPrefixLogs_exports = {};
22
24
  __export(getPrefixLogs_exports, {
@@ -2,66 +2,84 @@ 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 getPropValueFromAttributes_exports = {};
33
35
  __export(getPropValueFromAttributes_exports, {
34
36
  getPropValueFromAttributes: () => getPropValueFromAttributes
35
37
  });
36
38
  module.exports = __toCommonJS(getPropValueFromAttributes_exports);
37
- var import_generator = __toESM(require("@babel/generator")),
38
- t = __toESM(require("@babel/types")),
39
- import_accessSafe = require("./accessSafe.cjs");
39
+ var import_generator = __toESM(require("@babel/generator"));
40
+ var t = __toESM(require("@babel/types"));
41
+ var import_accessSafe = require("./accessSafe.cjs");
40
42
  function getPropValueFromAttributes(propName, attrs) {
41
- let propIndex = -1,
42
- jsxAttr = null;
43
+ let propIndex = -1;
44
+ let jsxAttr = null;
43
45
  for (let idx = -1, len = attrs.length; ++idx < len;) {
44
46
  const attr = attrs[idx];
45
47
  if (t.isJSXAttribute(attr) && attr.name && attr.name.name === propName) {
46
- propIndex = idx, jsxAttr = attr;
48
+ propIndex = idx;
49
+ jsxAttr = attr;
47
50
  break;
48
51
  }
49
52
  }
50
- if (!jsxAttr || jsxAttr.value == null) return null;
53
+ if (!jsxAttr || jsxAttr.value == null) {
54
+ return null;
55
+ }
51
56
  let propValue = jsxAttr.value;
52
- if (t.isJSXExpressionContainer(propValue) && (propValue = propValue.expression), t.isJSXEmptyExpression(propValue)) return console.error("encountered JSXEmptyExpression"), null;
57
+ if (t.isJSXExpressionContainer(propValue)) {
58
+ propValue = propValue.expression;
59
+ }
60
+ if (t.isJSXEmptyExpression(propValue)) {
61
+ console.error("encountered JSXEmptyExpression");
62
+ return null;
63
+ }
53
64
  const applicableSpreads = attrs.filter(
54
65
  // 1. idx is greater than propValue prop index
55
66
  // 2. attr is a spread operator
56
67
  (attr, idx) => {
57
68
  if (t.isJSXSpreadAttribute(attr)) {
58
- if (t.isIdentifier(attr.argument) || t.isMemberExpression(attr.argument)) return idx > propIndex;
59
- if (t.isLogicalExpression(attr.argument)) return !1;
69
+ if (t.isIdentifier(attr.argument) || t.isMemberExpression(attr.argument)) {
70
+ return idx > propIndex;
71
+ }
72
+ if (t.isLogicalExpression(attr.argument)) {
73
+ return false;
74
+ }
60
75
  throw new Error(`unsupported spread of type "${attr.argument.type}": ${
61
76
  // @ts-ignore
62
77
  (0, import_generator.default)(attr).code}`);
63
78
  }
64
- return !1;
79
+ return false;
65
80
  }).map(attr => attr.argument);
66
- return applicableSpreads.length > 0 && (propValue = applicableSpreads.reduce((acc, val) => t.logicalExpression("||", (0, import_accessSafe.accessSafe)(val, propName), acc), propValue)), propValue;
81
+ if (applicableSpreads.length > 0) {
82
+ propValue = applicableSpreads.reduce((acc, val) => t.logicalExpression("||", (0, import_accessSafe.accessSafe)(val, propName), acc), propValue);
83
+ }
84
+ return propValue;
67
85
  }
@@ -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 getSourceModule_exports = {};
33
35
  __export(getSourceModule_exports, {
34
36
  getSourceModule: () => getSourceModule
@@ -36,24 +38,58 @@ __export(getSourceModule_exports, {
36
38
  module.exports = __toCommonJS(getSourceModule_exports);
37
39
  var t = __toESM(require("@babel/types"));
38
40
  function getSourceModule(itemName, itemBinding) {
39
- if (!itemBinding.constant) return null;
40
- let sourceModule,
41
- imported,
42
- local,
43
- destructured,
44
- usesImportSyntax = !1;
41
+ if (!itemBinding.constant) {
42
+ return null;
43
+ }
44
+ let sourceModule;
45
+ let imported;
46
+ let local;
47
+ let destructured;
48
+ let usesImportSyntax = false;
45
49
  const itemNode = itemBinding.path.node;
46
- if (t.isImportDefaultSpecifier(itemNode) || t.isImportSpecifier(itemNode)) t.isImportDeclaration(itemBinding.path.parent) && (sourceModule = itemBinding.path.parent.source.value, local = itemNode.local.name, usesImportSyntax = !0, t.isImportSpecifier(itemNode) ? (imported = itemNode.imported.name, destructured = !0) : (imported = itemNode.local.name, destructured = !1));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) {
50
+ if (t.isImportDefaultSpecifier(itemNode) || t.isImportSpecifier(itemNode)) {
51
+ if (t.isImportDeclaration(itemBinding.path.parent)) {
52
+ sourceModule = itemBinding.path.parent.source.value;
53
+ local = itemNode.local.name;
54
+ usesImportSyntax = true;
55
+ if (t.isImportSpecifier(itemNode)) {
56
+ imported = itemNode.imported["name"];
57
+ destructured = true;
58
+ } else {
59
+ imported = itemNode.local.name;
60
+ destructured = false;
61
+ }
62
+ }
63
+ } 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) {
47
64
  const firstArg = itemNode.init.arguments[0];
48
- if (!t.isStringLiteral(firstArg)) return null;
49
- if (sourceModule = firstArg.value, t.isIdentifier(itemNode.id)) local = itemNode.id.name, imported = itemNode.id.name, destructured = !1;else if (t.isObjectPattern(itemNode.id)) {
50
- for (const objProp of itemNode.id.properties) if (t.isObjectProperty(objProp) && t.isIdentifier(objProp.value) && objProp.value.name === itemName) {
51
- local = objProp.value.name, imported = objProp.key.name, destructured = !0;
52
- break;
65
+ if (!t.isStringLiteral(firstArg)) {
66
+ return null;
67
+ }
68
+ sourceModule = firstArg.value;
69
+ if (t.isIdentifier(itemNode.id)) {
70
+ local = itemNode.id.name;
71
+ imported = itemNode.id.name;
72
+ destructured = false;
73
+ } else if (t.isObjectPattern(itemNode.id)) {
74
+ for (const objProp of itemNode.id.properties) {
75
+ if (t.isObjectProperty(objProp) && t.isIdentifier(objProp.value) && objProp.value.name === itemName) {
76
+ local = objProp.value.name;
77
+ imported = objProp.key.name;
78
+ destructured = true;
79
+ break;
80
+ }
81
+ }
82
+ if (!local || !imported) {
83
+ console.error("could not find prop with value `%s`", itemName);
84
+ return null;
53
85
  }
54
- if (!local || !imported) return console.error("could not find prop with value `%s`", itemName), null;
55
- } else return console.error("Unhandled id type: %s", itemNode.id.type), null;
56
- } else return null;
86
+ } else {
87
+ console.error("Unhandled id type: %s", itemNode.id.type);
88
+ return null;
89
+ }
90
+ } else {
91
+ return null;
92
+ }
57
93
  return {
58
94
  destructured,
59
95
  imported,
@@ -2,129 +2,191 @@ 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 getStaticBindingsForScope_exports = {};
33
35
  __export(getStaticBindingsForScope_exports, {
34
36
  cleanupBeforeExit: () => cleanupBeforeExit,
35
37
  getStaticBindingsForScope: () => getStaticBindingsForScope
36
38
  });
37
39
  module.exports = __toCommonJS(getStaticBindingsForScope_exports);
38
- var import_node_child_process = require("node:child_process"),
39
- import_node_path = require("node:path"),
40
- t = __toESM(require("@babel/types")),
41
- import_evaluateAstNode = require("./evaluateAstNode.cjs"),
42
- import_getSourceModule = require("./getSourceModule.cjs");
40
+ var import_node_child_process = require("node:child_process");
41
+ var import_node_path = require("node:path");
42
+ var t = __toESM(require("@babel/types"));
43
+ var import_evaluateAstNode = require("./evaluateAstNode.cjs");
44
+ var import_getSourceModule = require("./getSourceModule.cjs");
43
45
  const isLocalImport = path => path.startsWith(".") || path.startsWith("/");
44
46
  function resolveImportPath(sourcePath, path) {
45
47
  const sourceDir = (0, import_node_path.dirname)(sourcePath);
46
- return isLocalImport(path) ? ((0, import_node_path.extname)(path) === "" && (path += ""), (0, import_node_path.resolve)(sourceDir, path)) : path;
48
+ if (isLocalImport(path)) {
49
+ if ((0, import_node_path.extname)(path) === "") {
50
+ path += "";
51
+ }
52
+ return (0, import_node_path.resolve)(sourceDir, path);
53
+ }
54
+ return path;
47
55
  }
48
- const cache = /* @__PURE__ */new Map(),
49
- pending = /* @__PURE__ */new Map(),
50
- loadCmd = `${(0, import_node_path.join)(__dirname, "loadFile.js")}`;
51
- let exited = !1,
52
- child = null;
56
+ const cache = /* @__PURE__ */new Map();
57
+ const pending = /* @__PURE__ */new Map();
58
+ const loadCmd = `${(0, import_node_path.join)(__dirname, "loadFile.js")}`;
59
+ let exited = false;
60
+ let child = null;
53
61
  function forkChild() {
54
62
  child = (0, import_node_child_process.fork)(loadCmd, [], {
55
63
  execArgv: ["-r", "esbuild-register"],
56
- detached: !1,
64
+ detached: false,
57
65
  stdio: "ignore"
58
66
  });
59
67
  }
60
68
  function cleanupBeforeExit() {
61
- exited || child && (child.removeAllListeners(), child.unref(), child.disconnect(), child.kill(), exited = !0);
69
+ if (exited) return;
70
+ if (!child) return;
71
+ child.removeAllListeners();
72
+ child.unref();
73
+ child.disconnect();
74
+ child.kill();
75
+ exited = true;
62
76
  }
63
77
  process.once("SIGTERM", cleanupBeforeExit);
64
78
  process.once("SIGINT", cleanupBeforeExit);
65
79
  process.once("beforeExit", cleanupBeforeExit);
66
80
  function importModule(path) {
67
- if (child || forkChild(), pending.has(path)) return pending.get(path);
81
+ if (!child) {
82
+ forkChild();
83
+ }
84
+ if (pending.has(path)) {
85
+ return pending.get(path);
86
+ }
68
87
  const promise = new Promise((res, rej) => {
69
88
  if (!child) return;
70
- if (cache.size > 2e3 && cache.clear(), cache.has(path)) return cache.get(path);
89
+ if (cache.size > 2e3) {
90
+ cache.clear();
91
+ }
92
+ if (cache.has(path)) {
93
+ return cache.get(path);
94
+ }
71
95
  const listener = msg => {
72
- if (!child || !msg || typeof msg != "string") return;
96
+ if (!child) return;
97
+ if (!msg) return;
98
+ if (typeof msg !== "string") return;
73
99
  if (msg[0] === "-") {
74
100
  rej(new Error(msg.slice(1)));
75
101
  return;
76
102
  }
77
103
  child.removeListener("message", listener);
78
104
  const val = JSON.parse(msg);
79
- cache.set(path, val), res(val);
105
+ cache.set(path, val);
106
+ res(val);
80
107
  };
81
- child.once("message", listener), child.send(`${path.replace(".js", "")}`);
108
+ child.once("message", listener);
109
+ child.send(`${path.replace(".js", "")}`);
82
110
  }).finally(() => {
83
111
  pending.delete(path);
84
112
  });
85
- return pending.set(path, promise), promise;
113
+ pending.set(path, promise);
114
+ return promise;
86
115
  }
87
116
  async function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCache, shouldPrintDebug) {
88
- const bindings = scope.getAllBindings(),
89
- ret = {},
90
- program = scope.getProgramParent().block;
91
- for (const node of program.body) if (t.isImportDeclaration(node)) {
92
- const importPath = node.source.value;
93
- if (!node.specifiers.length || !isLocalImport(importPath)) continue;
94
- const moduleName = resolveImportPath(sourcePath, importPath);
95
- if (!whitelist.some(test => moduleName.endsWith(test))) continue;
96
- try {
97
- const src = await importModule(moduleName);
98
- if (!src) continue;
99
- for (const specifier of node.specifiers) if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported) && typeof src[specifier.imported.name] < "u") {
100
- const val = src[specifier.local.name];
101
- ret[specifier.local.name] = val;
117
+ const bindings = scope.getAllBindings();
118
+ const ret = {};
119
+ if (shouldPrintDebug) {}
120
+ const program = scope.getProgramParent().block;
121
+ for (const node of program.body) {
122
+ if (t.isImportDeclaration(node)) {
123
+ const importPath = node.source.value;
124
+ if (!node.specifiers.length) continue;
125
+ if (!isLocalImport(importPath)) {
126
+ continue;
127
+ }
128
+ const moduleName = resolveImportPath(sourcePath, importPath);
129
+ const isOnWhitelist = whitelist.some(test => moduleName.endsWith(test));
130
+ if (!isOnWhitelist) continue;
131
+ try {
132
+ const src = await importModule(moduleName);
133
+ if (!src) continue;
134
+ for (const specifier of node.specifiers) {
135
+ if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
136
+ if (typeof src[specifier.imported.name] !== "undefined") {
137
+ const val = src[specifier.local.name];
138
+ ret[specifier.local.name] = val;
139
+ }
140
+ }
141
+ }
142
+ } catch (err) {
143
+ if (shouldPrintDebug) {
144
+ console.warn(` | Skipping partial evaluation of constant file: ${moduleName} (DEBUG=tamagui for more)`);
145
+ } else if (process.env.DEBUG?.startsWith("tamagui")) {
146
+ console.info(`Error in partial evaluation`, err.message, err.stack);
147
+ }
102
148
  }
103
- } catch (err) {
104
- shouldPrintDebug ? console.warn(` | Skipping partial evaluation of constant file: ${moduleName} (DEBUG=tamagui for more)`) : process.env.DEBUG?.startsWith("tamagui") && console.info("Error in partial evaluation", err.message, err.stack);
105
149
  }
106
150
  }
107
- if (!bindingCache) throw new Error("BindingCache is a required param");
151
+ if (!bindingCache) {
152
+ throw new Error("BindingCache is a required param");
153
+ }
108
154
  for (const k in bindings) {
109
- const binding = bindings[k],
110
- sourceModule = (0, import_getSourceModule.getSourceModule)(k, binding);
155
+ const binding = bindings[k];
156
+ const sourceModule = (0, import_getSourceModule.getSourceModule)(k, binding);
111
157
  if (sourceModule) {
112
- if (!sourceModule.sourceModule) continue;
158
+ if (!sourceModule.sourceModule) {
159
+ continue;
160
+ }
113
161
  const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule);
114
- if (whitelist.some(test => moduleName.endsWith(test))) {
162
+ const isOnWhitelist = whitelist.some(test => moduleName.endsWith(test));
163
+ if (isOnWhitelist) {
115
164
  const src = importModule(moduleName);
116
- if (!src) return console.info(` | \u26A0\uFE0F Missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`), {};
117
- sourceModule.destructured ? sourceModule.imported && (ret[k] = src[sourceModule.imported]) : ret[k] = src;
165
+ if (!src) {
166
+ console.info(` | \u26A0\uFE0F Missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`);
167
+ return {};
168
+ }
169
+ if (sourceModule.destructured) {
170
+ if (sourceModule.imported) {
171
+ ret[k] = src[sourceModule.imported];
172
+ }
173
+ } else {
174
+ ret[k] = src;
175
+ }
118
176
  }
119
177
  continue;
120
178
  }
121
179
  const {
122
180
  parent
123
181
  } = binding.path;
124
- if (!t.isVariableDeclaration(parent) || parent.kind !== "const") continue;
182
+ if (!t.isVariableDeclaration(parent) || parent.kind !== "const") {
183
+ continue;
184
+ }
125
185
  const dec = parent.declarations.find(d => t.isIdentifier(d.id) && d.id.name === k);
126
- if (!dec || !dec.init) continue;
127
- if (typeof dec.id.start != "number" || typeof dec.id.end != "number") {
186
+ if (!dec || !dec.init) {
187
+ continue;
188
+ }
189
+ if (typeof dec.id.start !== "number" || typeof dec.id.end !== "number") {
128
190
  console.error("dec.id.start/end is not a number");
129
191
  continue;
130
192
  }
@@ -142,7 +204,8 @@ async function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bind
142
204
  continue;
143
205
  }
144
206
  try {
145
- ret[k] = (0, import_evaluateAstNode.evaluateAstNode)(dec.init, void 0, shouldPrintDebug), bindingCache[cacheKey] = ret[k];
207
+ ret[k] = (0, import_evaluateAstNode.evaluateAstNode)(dec.init, void 0, shouldPrintDebug);
208
+ bindingCache[cacheKey] = ret[k];
146
209
  continue;
147
210
  } catch {}
148
211
  }