@tamagui/static 1.0.1-beta.102 → 1.0.1-beta.105

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 (60) hide show
  1. package/dist/cjs/constants.js +4 -0
  2. package/dist/cjs/constants.js.map +2 -2
  3. package/dist/cjs/extractor/createEvaluator.js.map +1 -1
  4. package/dist/cjs/extractor/createExtractor.js +5 -39
  5. package/dist/cjs/extractor/createExtractor.js.map +2 -2
  6. package/dist/cjs/extractor/defaultTamaguiConfig.js +177 -0
  7. package/dist/cjs/extractor/defaultTamaguiConfig.js.map +7 -0
  8. package/dist/cjs/extractor/loadTamagui.js +46 -66
  9. package/dist/cjs/extractor/loadTamagui.js.map +2 -2
  10. package/dist/cjs/index.js +1 -0
  11. package/dist/cjs/index.js.map +2 -2
  12. package/dist/cjs/require.js +99 -0
  13. package/dist/cjs/require.js.map +7 -0
  14. package/dist/esm/constants.js +3 -0
  15. package/dist/esm/constants.js.map +2 -2
  16. package/dist/esm/extractor/createEvaluator.js.map +1 -1
  17. package/dist/esm/extractor/createExtractor.js +6 -41
  18. package/dist/esm/extractor/createExtractor.js.map +2 -2
  19. package/dist/esm/extractor/defaultTamaguiConfig.js +155 -0
  20. package/dist/esm/extractor/defaultTamaguiConfig.js.map +7 -0
  21. package/dist/esm/extractor/loadTamagui.js +46 -66
  22. package/dist/esm/extractor/loadTamagui.js.map +2 -2
  23. package/dist/esm/index.js +1 -0
  24. package/dist/esm/index.js.map +2 -2
  25. package/dist/esm/require.js +74 -0
  26. package/dist/esm/require.js.map +7 -0
  27. package/dist/jsx/constants.js +3 -0
  28. package/dist/jsx/constants.js.map +2 -2
  29. package/dist/jsx/extractor/createEvaluator.js.map +1 -1
  30. package/dist/jsx/extractor/createExtractor.js +6 -41
  31. package/dist/jsx/extractor/createExtractor.js.map +2 -2
  32. package/dist/jsx/extractor/defaultTamaguiConfig.js +142 -0
  33. package/dist/jsx/extractor/defaultTamaguiConfig.js.map +7 -0
  34. package/dist/jsx/extractor/loadTamagui.js +46 -66
  35. package/dist/jsx/extractor/loadTamagui.js.map +2 -2
  36. package/dist/jsx/index.js +1 -0
  37. package/dist/jsx/index.js.map +2 -2
  38. package/dist/jsx/require.js +74 -0
  39. package/dist/jsx/require.js.map +7 -0
  40. package/package.json +9 -8
  41. package/src/constants.ts +2 -0
  42. package/src/extractor/createEvaluator.ts +1 -1
  43. package/src/extractor/createExtractor.ts +4 -60
  44. package/src/extractor/defaultTamaguiConfig.ts +149 -0
  45. package/src/extractor/loadTamagui.ts +52 -85
  46. package/src/index.ts +1 -0
  47. package/src/require.ts +93 -0
  48. package/types/constants.d.ts +1 -0
  49. package/types/constants.d.ts.map +1 -1
  50. package/types/extractor/createEvaluator.d.ts +1 -1
  51. package/types/extractor/createEvaluator.d.ts.map +1 -1
  52. package/types/extractor/createExtractor.d.ts.map +1 -1
  53. package/types/extractor/defaultTamaguiConfig.d.ts +83 -0
  54. package/types/extractor/defaultTamaguiConfig.d.ts.map +1 -0
  55. package/types/extractor/loadTamagui.d.ts +1 -1
  56. package/types/extractor/loadTamagui.d.ts.map +1 -1
  57. package/types/index.d.ts +1 -0
  58. package/types/index.d.ts.map +1 -1
  59. package/types/require.d.ts +4 -0
  60. package/types/require.d.ts.map +1 -0
@@ -0,0 +1,155 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { createFont, createTamagui, createTokens } from "@tamagui/core-node";
18
+ import { shorthands } from "@tamagui/shorthands";
19
+ const font = createFont({
20
+ family: "System",
21
+ size: {
22
+ 1: 15
23
+ },
24
+ lineHeight: {
25
+ 1: 15
26
+ },
27
+ transform: {},
28
+ weight: {
29
+ 1: "400"
30
+ },
31
+ color: {
32
+ 1: "$color"
33
+ },
34
+ letterSpacing: {
35
+ 1: 0
36
+ }
37
+ });
38
+ const size = {
39
+ 0: 0,
40
+ 0.25: 2,
41
+ 0.5: 4,
42
+ 0.75: 8,
43
+ 1: 20,
44
+ 1.5: 24,
45
+ 2: 28,
46
+ 2.5: 32,
47
+ 3: 36,
48
+ 3.5: 40,
49
+ 4: 44,
50
+ true: 44,
51
+ 4.5: 48,
52
+ 5: 52,
53
+ 5.5: 59,
54
+ 6: 64,
55
+ 6.5: 69,
56
+ 7: 74,
57
+ 7.6: 79,
58
+ 8: 84,
59
+ 8.5: 89,
60
+ 9: 94,
61
+ 9.5: 99,
62
+ 10: 104,
63
+ 11: 124,
64
+ 12: 144,
65
+ 13: 164,
66
+ 14: 184,
67
+ 15: 204,
68
+ 16: 224,
69
+ 17: 224,
70
+ 18: 244,
71
+ 19: 264,
72
+ 20: 284
73
+ };
74
+ const spaces = Object.entries(size).map(([k, v]) => [
75
+ k,
76
+ Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12))
77
+ ]);
78
+ const spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v]);
79
+ const space = __spreadValues(__spreadValues({}, Object.fromEntries(spaces)), Object.fromEntries(spacesNegative));
80
+ const zIndex = {
81
+ 0: 0,
82
+ 1: 100,
83
+ 2: 200,
84
+ 3: 300,
85
+ 4: 400,
86
+ 5: 500
87
+ };
88
+ const radius = {
89
+ 0: 0,
90
+ 1: 3,
91
+ 2: 5,
92
+ 3: 7,
93
+ 4: 9,
94
+ 5: 10,
95
+ 6: 16,
96
+ 7: 19,
97
+ 8: 22,
98
+ 9: 26,
99
+ 10: 34,
100
+ 11: 42,
101
+ 12: 50
102
+ };
103
+ const tokens = createTokens({
104
+ color: {
105
+ white: "#fff",
106
+ black: "#000"
107
+ },
108
+ radius,
109
+ zIndex,
110
+ space,
111
+ size
112
+ });
113
+ const themes = {
114
+ light: {
115
+ background: tokens.color.white,
116
+ color: tokens.color.black
117
+ },
118
+ dark: {
119
+ background: tokens.color.black,
120
+ color: tokens.color.white
121
+ }
122
+ };
123
+ const config = createTamagui({
124
+ defaultTheme: "light",
125
+ shouldAddPrefersColorThemes: true,
126
+ themeClassNameOnRoot: true,
127
+ shorthands,
128
+ fonts: {
129
+ heading: font,
130
+ body: font
131
+ },
132
+ themes,
133
+ tokens,
134
+ media: {
135
+ xs: { maxWidth: 660 },
136
+ sm: { maxWidth: 800 },
137
+ md: { maxWidth: 1020 },
138
+ lg: { maxWidth: 1280 },
139
+ xl: { maxWidth: 1420 },
140
+ xxl: { maxWidth: 1600 },
141
+ gtXs: { minWidth: 660 + 1 },
142
+ gtSm: { minWidth: 800 + 1 },
143
+ gtMd: { minWidth: 1020 + 1 },
144
+ gtLg: { minWidth: 1280 + 1 },
145
+ short: { maxHeight: 820 },
146
+ tall: { minHeight: 820 },
147
+ hoverNone: { hover: "none" },
148
+ pointerCoarse: { pointer: "coarse" }
149
+ }
150
+ });
151
+ export {
152
+ config,
153
+ tokens
154
+ };
155
+ //# sourceMappingURL=defaultTamaguiConfig.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/extractor/defaultTamaguiConfig.ts"],
4
+ "sourcesContent": ["import { TamaguiInternalConfig, createFont, createTamagui, createTokens } from '@tamagui/core-node'\nimport { shorthands } from '@tamagui/shorthands'\n\n// basic fallback theme just to have compiler load in decent tate\n\nconst font = createFont({\n family: 'System',\n size: {\n 1: 15,\n },\n lineHeight: {\n 1: 15,\n },\n transform: {},\n weight: {\n 1: '400',\n },\n color: {\n 1: '$color',\n },\n letterSpacing: {\n 1: 0,\n },\n})\n\nconst size = {\n 0: 0,\n 0.25: 2,\n 0.5: 4,\n 0.75: 8,\n 1: 20,\n 1.5: 24,\n 2: 28,\n 2.5: 32,\n 3: 36,\n 3.5: 40,\n 4: 44,\n true: 44,\n 4.5: 48,\n 5: 52,\n 5.5: 59,\n 6: 64,\n 6.5: 69,\n 7: 74,\n 7.6: 79,\n 8: 84,\n 8.5: 89,\n 9: 94,\n 9.5: 99,\n 10: 104,\n 11: 124,\n 12: 144,\n 13: 164,\n 14: 184,\n 15: 204,\n 16: 224,\n 17: 224,\n 18: 244,\n 19: 264,\n 20: 284,\n}\n\nconst spaces = Object.entries(size).map(([k, v]) => [\n k,\n Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12)),\n])\n\nconst spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v])\n\nconst space = {\n ...Object.fromEntries(spaces),\n ...Object.fromEntries(spacesNegative),\n} as any\n\nconst zIndex = {\n 0: 0,\n 1: 100,\n 2: 200,\n 3: 300,\n 4: 400,\n 5: 500,\n}\n\nconst radius = {\n 0: 0,\n 1: 3,\n 2: 5,\n 3: 7,\n 4: 9,\n 5: 10,\n 6: 16,\n 7: 19,\n 8: 22,\n 9: 26,\n 10: 34,\n 11: 42,\n 12: 50,\n}\n\nexport const tokens = createTokens({\n color: {\n white: '#fff',\n black: '#000',\n },\n radius,\n zIndex,\n space,\n size,\n})\n\nconst themes = {\n light: {\n background: tokens.color.white,\n color: tokens.color.black,\n },\n dark: {\n background: tokens.color.black,\n color: tokens.color.white,\n },\n}\n\nexport const config = createTamagui({\n defaultTheme: 'light',\n shouldAddPrefersColorThemes: true,\n themeClassNameOnRoot: true,\n shorthands,\n fonts: {\n heading: font,\n body: font,\n },\n themes,\n tokens,\n media: {\n xs: { maxWidth: 660 },\n sm: { maxWidth: 800 },\n md: { maxWidth: 1020 },\n lg: { maxWidth: 1280 },\n xl: { maxWidth: 1420 },\n xxl: { maxWidth: 1600 },\n gtXs: { minWidth: 660 + 1 },\n gtSm: { minWidth: 800 + 1 },\n gtMd: { minWidth: 1020 + 1 },\n gtLg: { minWidth: 1280 + 1 },\n short: { maxHeight: 820 },\n tall: { minHeight: 820 },\n hoverNone: { hover: 'none' },\n pointerCoarse: { pointer: 'coarse' },\n },\n}) as TamaguiInternalConfig\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;AACA;AAIA,MAAM,OAAO,WAAW;AAAA,EACtB,QAAQ;AAAA,EACR,MAAM;AAAA,IACJ,GAAG;AAAA,EACL;AAAA,EACA,YAAY;AAAA,IACV,GAAG;AAAA,EACL;AAAA,EACA,WAAW,CAAC;AAAA,EACZ,QAAQ;AAAA,IACN,GAAG;AAAA,EACL;AAAA,EACA,OAAO;AAAA,IACL,GAAG;AAAA,EACL;AAAA,EACA,eAAe;AAAA,IACb,GAAG;AAAA,EACL;AACF,CAAC;AAED,MAAM,OAAO;AAAA,EACX,GAAG;AAAA,EACH,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,MAAM;AAAA,EACN,KAAK;AAAA,EACL,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,SAAS,OAAO,Q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EACA,OAAO;AAAA,IACL,IAAI,EAAE,UAAU,IAAI;AAAA,IACpB,IAAI,EAAE,UAAU,IAAI;AAAA,IACpB,IAAI,EAAE,UAAU,KAAK;AAAA,IACrB,IAAI,EAAE,UAAU,KAAK;AAAA,IACrB,IAAI,EAAE,UAAU,KAAK;AAAA,IACrB,KAAK,EAAE,UAAU,KAAK;AAAA,IACtB,MAAM,EAAE,UAAU,MAAM,EAAE;AAAA,IAC1B,MAAM,EAAE,UAAU,MAAM,EAAE;AAAA,IAC1B,MAAM,EAAE,UAAU,OAAO,EAAE;AAAA,IAC3B,MAAM,EAAE,UAAU,OAAO,EAAE;AAAA,IAC3B,OAAO,EAAE,WAAW,IAAI;AAAA,IACxB,MAAM,EAAE,WAAW,IAAI;AAAA,IACvB,WAAW,EAAE,OAAO,OAAO;AAAA,IAC3B,eAAe,EAAE,SAAS,SAAS;AAAA,EACrC;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -15,8 +15,12 @@ var __objRest = (source, exclude) => {
15
15
  };
16
16
  import { join } from "path";
17
17
  import { createTamagui } from "@tamagui/core-node";
18
+ import { SHOULD_DEBUG } from "../constants";
19
+ import { getNameToPaths, registerRequire, unregisterRequire } from "../require";
20
+ import { config as defaultTamaguiConfig } from "./defaultTamaguiConfig";
18
21
  let loadedTamagui = null;
19
22
  function loadTamagui(props) {
23
+ console.trace("load", !!loadedTamagui);
20
24
  if (loadedTamagui) {
21
25
  return loadedTamagui;
22
26
  }
@@ -30,85 +34,61 @@ function loadTamagui(props) {
30
34
  if (typeof globalThis["__DEV__"] === "undefined") {
31
35
  globalThis["__DEV__"] = process.env.NODE_ENV === "development";
32
36
  }
33
- const proxyWorm = require("@tamagui/proxy-worm");
34
- const rnw = require("react-native-web");
35
- const Mod = require("module");
36
- const og = Mod.prototype.require;
37
- const nameToPaths = {};
38
- Mod.prototype.require = function(path) {
39
- var _a2;
40
- if (path.endsWith(".css")) {
41
- return {};
42
- }
43
- if (path === "@gorhom/bottom-sheet" || path.startsWith("react-native-reanimated") || path === "expo-linear-gradient") {
44
- return proxyWorm;
45
- }
46
- if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
47
- return rnw;
48
- }
49
- try {
50
- const out = og.apply(this, arguments);
51
- if (!nameToPaths[path]) {
52
- if (out && typeof out === "object") {
53
- for (const key in out) {
54
- try {
55
- const conf = (_a2 = out[key]) == null ? void 0 : _a2.staticConfig;
56
- if (conf) {
57
- if (conf.componentName) {
58
- nameToPaths[conf.componentName] ??= /* @__PURE__ */ new Set();
59
- const fullName = path.startsWith(".") ? join(`${this.path.replace(/dist(\/cjs)?/, "src")}`, path) : path;
60
- nameToPaths[conf.componentName].add(fullName);
61
- } else {
62
- }
63
- }
64
- } catch {
65
- }
66
- }
67
- }
68
- }
69
- return out;
70
- } catch (err) {
71
- console.error("Tamagui error loading file:\n", path, err.message, "\n", err.stack);
72
- process.exit(1);
73
- }
74
- };
75
- const exp = require(configPath);
76
- const tamaguiConfig = exp["default"] || exp;
77
- if (!tamaguiConfig || !tamaguiConfig.parsed) {
78
- try {
37
+ registerRequire();
38
+ try {
39
+ const exp = require(configPath);
40
+ const tamaguiConfig = exp["default"] || exp;
41
+ if (!tamaguiConfig || !tamaguiConfig.parsed) {
79
42
  const confPath = require.resolve(configPath);
80
43
  console.log(`Received:`, tamaguiConfig);
81
44
  throw new Error(`Can't find valid config in ${confPath}`);
82
- } catch (err) {
83
- throw err;
84
45
  }
85
- }
86
- const components = {};
87
- for (const moduleName of props.components) {
88
- const exported = require(moduleName);
89
- for (const Name in exported) {
90
- const val = exported[Name];
91
- const staticConfig = val == null ? void 0 : val.staticConfig;
92
- if (staticConfig) {
93
- const _a = staticConfig, { Component, reactNativeWebComponent } = _a, sc = __objRest(_a, ["Component", "reactNativeWebComponent"]);
94
- Object.assign(components, { [Name]: { staticConfig: sc } });
46
+ const components = {};
47
+ for (const moduleName of props.components) {
48
+ const exported = require(moduleName);
49
+ for (const Name in exported) {
50
+ const val = exported[Name];
51
+ const staticConfig = val == null ? void 0 : val.staticConfig;
52
+ if (staticConfig) {
53
+ const _a = staticConfig, { Component, reactNativeWebComponent } = _a, sc = __objRest(_a, ["Component", "reactNativeWebComponent"]);
54
+ Object.assign(components, { [Name]: { staticConfig: sc } });
55
+ }
56
+ }
57
+ }
58
+ process.env.IS_STATIC = void 0;
59
+ createTamagui(tamaguiConfig);
60
+ loadedTamagui = {
61
+ components,
62
+ tamaguiConfig,
63
+ nameToPaths: getNameToPaths()
64
+ };
65
+ } catch (err) {
66
+ if (err instanceof Error) {
67
+ console.warn(`Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`);
68
+ console.log(`
69
+
70
+ ${err.message}
71
+
72
+ `);
73
+ if (SHOULD_DEBUG) {
74
+ console.log(err.stack);
95
75
  }
76
+ } else {
77
+ console.error(`Error loading tamagui.config.ts`, err);
96
78
  }
79
+ return {
80
+ components: {},
81
+ tamaguiConfig: defaultTamaguiConfig,
82
+ nameToPaths: {}
83
+ };
97
84
  }
98
- process.env.IS_STATIC = void 0;
99
- Mod.prototype.require = og;
100
- createTamagui(tamaguiConfig);
101
- loadedTamagui = {
102
- components,
103
- tamaguiConfig,
104
- nameToPaths
105
- };
106
85
  return loadedTamagui;
107
86
  } catch (err) {
108
87
  console.log("Error loading Tamagui", err);
109
88
  throw err;
110
89
  } finally {
111
90
  unregister();
91
+ unregisterRequire();
112
92
  }
113
93
  }
114
94
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/extractor/loadTamagui.ts"],
4
- "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig, TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core'\nimport { createTamagui } from '@tamagui/core-node'\n\nlet loadedTamagui: any = null\n\ntype NameToPaths = {\n [key: string]: Set<string>\n}\n\nexport type TamaguiProjectInfo = {\n components: Record<string, TamaguiComponent>\n tamaguiConfig: TamaguiInternalConfig\n nameToPaths: NameToPaths\n}\n\nexport function loadTamagui(props: { components: string[]; config: string }): TamaguiProjectInfo {\n if (loadedTamagui) {\n return loadedTamagui\n }\n\n const configPath = join(process.cwd(), props.config)\n\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n\n try {\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n // @ts-ignore\n if (typeof globalThis['__DEV__'] === 'undefined') {\n // @ts-ignore\n globalThis['__DEV__'] = process.env.NODE_ENV === 'development'\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const Mod = require('module')\n const og = Mod.prototype.require\n const nameToPaths: NameToPaths = {}\n\n Mod.prototype.require = function (path: string) {\n if (path.endsWith('.css')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error('Tamagui error loading file:\\n', path, err.message, '\\n', err.stack)\n // avoid infinite loops\n process.exit(1)\n }\n }\n\n // import config\n const exp = require(configPath)\n const tamaguiConfig = (exp['default'] || exp) as TamaguiInternalConfig\n\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n try {\n const confPath = require.resolve(configPath)\n console.log(`Received:`, tamaguiConfig)\n throw new Error(`Can't find valid config in ${confPath}`)\n } catch (err) {\n throw err\n }\n }\n\n // import components\n const components = {}\n for (const moduleName of props.components) {\n const exported = require(moduleName)\n for (const Name in exported) {\n const val = exported[Name]\n const staticConfig = val?.staticConfig as StaticConfig | undefined\n if (staticConfig) {\n // remove non-stringifyable\n const { Component, reactNativeWebComponent, ...sc } = staticConfig\n Object.assign(components, { [Name]: { staticConfig: sc } })\n }\n }\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n Mod.prototype.require = og\n\n // set up core-node\n createTamagui(tamaguiConfig as any)\n\n loadedTamagui = {\n components,\n tamaguiConfig,\n nameToPaths,\n }\n\n return loadedTamagui\n } catch (err) {\n console.log('Error loading Tamagui', err)\n throw err\n } finally {\n unregister()\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;AAAA;AAGA;AAEA,IAAI,gBAAqB;AAYlB,qBAAqB,OAAqE;AAC/F,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,MAAM,MAAM;AAEnD,QAAM,EAAE,eAAe,QAAQ,4BAA4B,EAAE,SAAS;AAAA,IACpE,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAED,MAAI;AAGF,YAAQ,IAAI,YAAY;AAExB,QAAI,OAAO,WAAW,eAAe,aAAa;AAEhD,iBAAW,aAAa,QAAQ,IAAI,aAAa;AAAA,IACnD;AAEA,UAAM,YAAY,QAAQ,qBAAqB;AAC/C,UAAM,MAAM,QAAQ,kBAAkB;AACtC,UAAM,MAAM,QAAQ,QAAQ;AAC5B,UAAM,KAAK,IAAI,UAAU;AACzB,UAAM,cAA2B,CAAC;AAElC,QAAI,UAAU,UAAU,SAAU,MAAc;AA7CpD;AA8CM,UAAI,KAAK,SAAS,MAAM,GAAG;AACzB,eAAO,CAAC;AAAA,MACV;AACA,UACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,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rB,cAAM,eAAe,2BAAK;AAC1B,YAAI,cAAc;AAEhB,gBAAsD,mBAA9C,aAAW,4BAAmC,IAAP,eAAO,IAAP,CAAvC,aAAW;AACnB,iBAAO,OAAO,YAAY,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,EAAE,CAAC;AAAA,QAC5D;AAAA,MACF;AAAA,IACF;AAGA,YAAQ,IAAI,YAAY;AACxB,QAAI,UAAU,UAAU;AAGxB,kBAAc,aAAoB;AAElC,oBAAgB;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,WAAO;AAAA,EACT,SAAS,KAAP;AACA,YAAQ,IAAI,yBAAyB,GAAG;AACxC,UAAM;AAAA,EACR,UAAE;AACA,eAAW;AAAA,EACb;AACF;",
4
+ "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig, TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core-node'\nimport { createTamagui } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from '../constants'\nimport { getNameToPaths, registerRequire, unregisterRequire } from '../require'\nimport { config as defaultTamaguiConfig } from './defaultTamaguiConfig'\n\nlet loadedTamagui: any = null\n\ntype NameToPaths = {\n [key: string]: Set<string>\n}\n\nexport type TamaguiProjectInfo = {\n components: Record<string, TamaguiComponent>\n tamaguiConfig: TamaguiInternalConfig\n nameToPaths: NameToPaths\n}\n\nexport function loadTamagui(props: { components: string[]; config: string }): TamaguiProjectInfo {\n console.trace('load', !!loadedTamagui)\n\n if (loadedTamagui) {\n return loadedTamagui\n }\n\n const configPath = join(process.cwd(), props.config)\n\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n\n try {\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n // @ts-ignore\n if (typeof globalThis['__DEV__'] === 'undefined') {\n // @ts-ignore\n globalThis['__DEV__'] = process.env.NODE_ENV === 'development'\n }\n\n registerRequire()\n\n try {\n // import config\n const exp = require(configPath)\n const tamaguiConfig = (exp['default'] || exp) as TamaguiInternalConfig\n\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n const confPath = require.resolve(configPath)\n console.log(`Received:`, tamaguiConfig)\n throw new Error(`Can't find valid config in ${confPath}`)\n }\n\n // import components\n const components = {}\n for (const moduleName of props.components) {\n const exported = require(moduleName)\n for (const Name in exported) {\n const val = exported[Name]\n const staticConfig = val?.staticConfig as StaticConfig | undefined\n if (staticConfig) {\n // remove non-stringifyable\n const { Component, reactNativeWebComponent, ...sc } = staticConfig\n Object.assign(components, { [Name]: { staticConfig: sc } })\n }\n }\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n\n // set up core-node\n createTamagui(tamaguiConfig as any)\n\n loadedTamagui = {\n components,\n tamaguiConfig,\n nameToPaths: getNameToPaths(),\n }\n } catch (err) {\n if (err instanceof Error) {\n console.warn(\n `Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`\n )\n console.log(`\\n\\n ${err.message}\\n\\n`)\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n } else {\n console.error(`Error loading tamagui.config.ts`, err)\n }\n return {\n components: {},\n tamaguiConfig: defaultTamaguiConfig,\n nameToPaths: {},\n }\n }\n\n return loadedTamagui\n } catch (err) {\n console.log('Error loading Tamagui', err)\n throw err\n } finally {\n unregister()\n unregisterRequire()\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAGA;AAEA;AACA;AACA;AAEA,IAAI,gBAAqB;AAYlB,qBAAqB,OAAqE;AAC/F,UAAQ,MAAM,QAAQ,CAAC,CAAC,aAAa;AAErC,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,MAAM,MAAM;AAEnD,QAAM,EAAE,eAAe,QAAQ,4BAA4B,EAAE,SAAS;AAAA,IACpE,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAED,MAAI;A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EACT,SAAS,KAAP;AACA,YAAQ,IAAI,yBAAyB,GAAG;AACxC,UAAM;AAAA,EACR,UAAE;AACA,eAAW;AACX,sBAAkB;AAAA,EACpB;AACF;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
@@ -7,6 +7,7 @@ export * from "./extractor/extractToClassNames";
7
7
  export * from "./extractor/extractHelpers";
8
8
  export * from "@tamagui/patch-rnw";
9
9
  export * from "./extractor/loadTamagui";
10
+ export * from "./require";
10
11
  export {
11
12
  TamaguiOptions,
12
13
  createExtractor,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["process.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport { TamaguiOptions } from './types'\nexport { createExtractor } from './extractor/createExtractor'\nexport { literalToAst } from './extractor/literalToAst'\nexport * from './constants'\nexport * from './extractor/extractToClassNames'\nexport * from './extractor/extractHelpers'\nexport * from '@tamagui/patch-rnw'\nexport * from './extractor/loadTamagui'\n"],
5
- "mappings": "AAAA,QAAQ,IAAI,0BAA0B;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;",
4
+ "sourcesContent": ["process.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport { TamaguiOptions } from './types'\nexport { createExtractor } from './extractor/createExtractor'\nexport { literalToAst } from './extractor/literalToAst'\nexport * from './constants'\nexport * from './extractor/extractToClassNames'\nexport * from './extractor/extractHelpers'\nexport * from '@tamagui/patch-rnw'\nexport * from './extractor/loadTamagui'\nexport * from './require'\n"],
5
+ "mappings": "AAAA,QAAQ,IAAI,0BAA0B;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,74 @@
1
+ import { join } from "path";
2
+ import { SHOULD_DEBUG } from "./constants";
3
+ const nameToPaths = {};
4
+ const Mod = require("module");
5
+ const og = Mod.prototype.require;
6
+ globalThis["ogRequire"] = og;
7
+ const getNameToPaths = () => nameToPaths;
8
+ let tries = 0;
9
+ setInterval(() => {
10
+ tries = 0;
11
+ }, 500);
12
+ function registerRequire() {
13
+ if (Mod.prototype.require !== globalThis["ogRequire"]) {
14
+ console.warn("didnt unregister before re-registering");
15
+ process.exit(1);
16
+ }
17
+ const proxyWorm = require("@tamagui/proxy-worm");
18
+ const rnw = require("react-native-web");
19
+ Mod.prototype.require = function(path) {
20
+ var _a;
21
+ if (SHOULD_DEBUG) {
22
+ console.log("tamagui require", path);
23
+ }
24
+ if (path.endsWith(".css")) {
25
+ return {};
26
+ }
27
+ if (path === "@gorhom/bottom-sheet" || path.startsWith("react-native-reanimated") || path === "expo-linear-gradient") {
28
+ return proxyWorm;
29
+ }
30
+ if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
31
+ return rnw;
32
+ }
33
+ try {
34
+ const out = og.apply(this, arguments);
35
+ if (!nameToPaths[path]) {
36
+ if (out && typeof out === "object") {
37
+ for (const key in out) {
38
+ try {
39
+ const conf = (_a = out[key]) == null ? void 0 : _a.staticConfig;
40
+ if (conf) {
41
+ if (conf.componentName) {
42
+ nameToPaths[conf.componentName] ??= /* @__PURE__ */ new Set();
43
+ const fullName = path.startsWith(".") ? join(`${this.path.replace(/dist(\/cjs)?/, "src")}`, path) : path;
44
+ nameToPaths[conf.componentName].add(fullName);
45
+ } else {
46
+ }
47
+ }
48
+ } catch {
49
+ }
50
+ }
51
+ }
52
+ }
53
+ return out;
54
+ } catch (err) {
55
+ console.error(`Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)
56
+ `, err.message);
57
+ if (SHOULD_DEBUG) {
58
+ console.log(err.stack);
59
+ }
60
+ if (++tries > 10) {
61
+ process.exit(1);
62
+ }
63
+ }
64
+ };
65
+ }
66
+ function unregisterRequire() {
67
+ Mod.prototype.require = og;
68
+ }
69
+ export {
70
+ getNameToPaths,
71
+ registerRequire,
72
+ unregisterRequire
73
+ };
74
+ //# sourceMappingURL=require.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/require.ts"],
4
+ "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Mod = require('module')\nconst og = Mod.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 500)\n\nexport function registerRequire() {\n if (Mod.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n\n Mod.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n // return og('react-native-web')\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)\\n`,\n err.message\n )\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n if (++tries > 10) {\n // avoid infinite loops\n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AAK,eAAe,IAAI,QAAQ;AAAA,gBAC9C,OAAO;AAAA,gBAEP;AAAA,cACF;AAAA,YACF,QAAE;AAAA,YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,cAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,OACN;AACA,UAAI,cAAc;AAChB,gBAAQ,IAAI,IAAI,KAAK;AAAA,MACvB;AACA,UAAI,EAAE,QAAQ,IAAI;AAEhB,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,6BAA6B;AAClC,MAAI,UAAU,UAAU;AAC1B;",
6
+ "names": []
7
+ }
@@ -1,14 +1,17 @@
1
+ var _a;
1
2
  import findCacheDir from "find-cache-dir";
2
3
  const CSS_FILE_NAME = "__snack.css";
3
4
  const MEDIA_SEP = "_";
4
5
  const cacheDir = findCacheDir({ name: "tamagui", create: true });
5
6
  const FAILED_EVAL = Symbol("failed_style_eval");
6
7
  const CONCAT_CLASSNAME_IMPORT = "concatClassName";
8
+ const SHOULD_DEBUG = process.env.DEBUG === "*" || ((_a = process.env.DEBUG) == null ? void 0 : _a.startsWith("tamagui"));
7
9
  export {
8
10
  CONCAT_CLASSNAME_IMPORT,
9
11
  CSS_FILE_NAME,
10
12
  FAILED_EVAL,
11
13
  MEDIA_SEP,
14
+ SHOULD_DEBUG,
12
15
  cacheDir
13
16
  };
14
17
  //# sourceMappingURL=constants.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/constants.ts"],
4
- "sourcesContent": ["import findCacheDir from 'find-cache-dir'\n\nexport const CSS_FILE_NAME = '__snack.css'\n\n// ENSURE THIS ISNT THE SAME AS THE SEPARATOR USED FOR STYLE KEYS\n// SEE matching one in concatClassName\nexport const MEDIA_SEP = '_'\n\n// ensure cache dir\nexport const cacheDir = findCacheDir({ name: 'tamagui', create: true })\n\nexport const FAILED_EVAL = Symbol('failed_style_eval')\nexport const CONCAT_CLASSNAME_IMPORT = 'concatClassName'\n"],
5
- "mappings": "AAAA;AAEO,MAAM,gBAAgB;AAItB,MAAM,YAAY;AAGlB,MAAM,WAAW,aAAa,EAAE,MAAM,WAAW,QAAQ,KAAK,CAAC;AAE/D,MAAM,cAAc,OAAO,mBAAmB;AAC9C,MAAM,0BAA0B;",
4
+ "sourcesContent": ["import findCacheDir from 'find-cache-dir'\n\nexport const CSS_FILE_NAME = '__snack.css'\n\n// ENSURE THIS ISNT THE SAME AS THE SEPARATOR USED FOR STYLE KEYS\n// SEE matching one in concatClassName\nexport const MEDIA_SEP = '_'\n\n// ensure cache dir\nexport const cacheDir = findCacheDir({ name: 'tamagui', create: true })\n\nexport const FAILED_EVAL = Symbol('failed_style_eval')\nexport const CONCAT_CLASSNAME_IMPORT = 'concatClassName'\n\nexport const SHOULD_DEBUG = process.env.DEBUG === '*' || process.env.DEBUG?.startsWith('tamagui')\n"],
5
+ "mappings": "AAAA;AAAA;AAEO,MAAM,gBAAgB;AAItB,MAAM,YAAY;AAGlB,MAAM,WAAW,aAAa,EAAE,MAAM,WAAW,QAAQ,KAAK,CAAC;AAE/D,MAAM,cAAc,OAAO,mBAAmB;AAC9C,MAAM,0BAA0B;AAEhC,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,eAAQ,IAAI,UAAZ,mBAAmB,WAAW;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/extractor/createEvaluator.ts"],
4
- "sourcesContent": ["import vm from 'vm'\n\nimport generate from '@babel/generator'\nimport { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { TamaguiConfig } from '@tamagui/core'\nimport { createCSSVariable } from '@tamagui/core-node'\nimport esbuild from 'esbuild'\n\nimport { FAILED_EVAL } from '../constants'\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { isValidThemeHook } from './extractHelpers'\n\nexport function createEvaluator({\n tamaguiConfig,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n}: {\n tamaguiConfig: TamaguiConfig\n staticNamespace: Record<string, any>\n sourcePath: string\n traversePath?: NodePath<t.JSXElement>\n shouldPrintDebug: boolean | 'verbose'\n}) {\n // called when evaluateAstNode encounters a dynamic-looking prop\n const evalFn = (n: t.Node) => {\n // themes\n if (\n t.isMemberExpression(n) &&\n t.isIdentifier(n.property) &&\n traversePath &&\n isValidThemeHook(traversePath, n, sourcePath)\n ) {\n const key = n.property.name\n if (shouldPrintDebug) {\n console.log(' > found theme prop', key)\n }\n console.log('SHOULD FIND THEME (NESTED NOW)', key) // tamaguiConfig.themes)\n // if (!themeKeys.has(key)) {\n // throw new Error(` > accessing non-existent theme key: ${key}`)\n // }\n return createCSSVariable(key)\n }\n // variable\n if (t.isIdentifier(n) && staticNamespace.hasOwnProperty(n.name)) {\n return staticNamespace[n.name]\n }\n const evalContext = vm.createContext(staticNamespace)\n const codeWithTypescriptAnnotations = `(${generate(n as any).code})`\n const code = esbuild\n .transformSync(codeWithTypescriptAnnotations, { loader: 'tsx' })\n .code.replace(/;\\n$/, '')\n\n if (shouldPrintDebug) {\n console.log('evaluating', code)\n }\n return vm.runInContext(code, evalContext)\n }\n\n return (n: t.Node) => {\n return evaluateAstNode(n, evalFn)\n }\n}\n\nexport function createSafeEvaluator(attemptEval: (n: t.Node) => any) {\n return (n: t.Node) => {\n try {\n return attemptEval(n)\n } catch (err) {\n return FAILED_EVAL\n }\n }\n}\n"],
4
+ "sourcesContent": ["import vm from 'vm'\n\nimport generate from '@babel/generator'\nimport { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { TamaguiConfig } from '@tamagui/core-node'\nimport { createCSSVariable } from '@tamagui/core-node'\nimport esbuild from 'esbuild'\n\nimport { FAILED_EVAL } from '../constants'\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { isValidThemeHook } from './extractHelpers'\n\nexport function createEvaluator({\n tamaguiConfig,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n}: {\n tamaguiConfig: TamaguiConfig\n staticNamespace: Record<string, any>\n sourcePath: string\n traversePath?: NodePath<t.JSXElement>\n shouldPrintDebug: boolean | 'verbose'\n}) {\n // called when evaluateAstNode encounters a dynamic-looking prop\n const evalFn = (n: t.Node) => {\n // themes\n if (\n t.isMemberExpression(n) &&\n t.isIdentifier(n.property) &&\n traversePath &&\n isValidThemeHook(traversePath, n, sourcePath)\n ) {\n const key = n.property.name\n if (shouldPrintDebug) {\n console.log(' > found theme prop', key)\n }\n console.log('SHOULD FIND THEME (NESTED NOW)', key) // tamaguiConfig.themes)\n // if (!themeKeys.has(key)) {\n // throw new Error(` > accessing non-existent theme key: ${key}`)\n // }\n return createCSSVariable(key)\n }\n // variable\n if (t.isIdentifier(n) && staticNamespace.hasOwnProperty(n.name)) {\n return staticNamespace[n.name]\n }\n const evalContext = vm.createContext(staticNamespace)\n const codeWithTypescriptAnnotations = `(${generate(n as any).code})`\n const code = esbuild\n .transformSync(codeWithTypescriptAnnotations, { loader: 'tsx' })\n .code.replace(/;\\n$/, '')\n\n if (shouldPrintDebug) {\n console.log('evaluating', code)\n }\n return vm.runInContext(code, evalContext)\n }\n\n return (n: t.Node) => {\n return evaluateAstNode(n, evalFn)\n }\n}\n\nexport function createSafeEvaluator(attemptEval: (n: t.Node) => any) {\n return (n: t.Node) => {\n try {\n return attemptEval(n)\n } catch (err) {\n return FAILED_EVAL\n }\n }\n}\n"],
5
5
  "mappings": "AAAA;AAEA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAEO,yBAAyB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GAOC;AAED,QAAM,SAAS,CAAC,MAAc;AAE5B,QACE,EAAE,mBAAmB,CAAC,KACtB,EAAE,aAAa,EAAE,QAAQ,KACzB,gBACA,iBAAiB,cAAc,GAAG,UAAU,GAC5C;AACA,YAAM,MAAM,EAAE,SAAS;AACvB,UAAI,kBAAkB;AACpB,gBAAQ,IAAI,0BAA0B,GAAG;AAAA,MAC3C;AACA,cAAQ,IAAI,kCAAkC,GAAG;AAIjD,aAAO,kBAAkB,GAAG;AAAA,IAC9B;AAEA,QAAI,EAAE,aAAa,CAAC,KAAK,gBAAgB,eAAe,EAAE,IAAI,GAAG;AAC/D,aAAO,gBAAgB,EAAE;AAAA,IAC3B;AACA,UAAM,cAAc,GAAG,cAAc,eAAe;AACpD,UAAM,gCAAgC,IAAI,SAAS,CAAQ,EAAE;AAC7D,UAAM,OAAO,QACV,cAAc,+BAA+B,EAAE,QAAQ,MAAM,CAAC,EAC9D,KAAK,QAAQ,QAAQ,EAAE;AAE1B,QAAI,kBAAkB;AACpB,cAAQ,IAAI,cAAc,IAAI;AAAA,IAChC;AACA,WAAO,GAAG,aAAa,MAAM,WAAW;AAAA,EAC1C;AAEA,SAAO,CAAC,MAAc;AACpB,WAAO,gBAAgB,GAAG,MAAM;AAAA,EAClC;AACF;AAEO,6BAA6B,aAAiC;AACnE,SAAO,CAAC,MAAc;AACpB,QAAI;AACF,aAAO,YAAY,CAAC;AAAA,IACtB,SAAS,KAAP;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -8,10 +8,8 @@ import {
8
8
  getStylesAtomic,
9
9
  mediaQueryConfig,
10
10
  proxyThemeVariables,
11
- pseudoDescriptors,
12
- stylePropsTransform
11
+ pseudoDescriptors
13
12
  } from "@tamagui/core-node";
14
- import { difference, pick } from "lodash";
15
13
  import { FAILED_EVAL } from "../constants";
16
14
  import { createEvaluator, createSafeEvaluator } from "./createEvaluator";
17
15
  import { evaluateAstNode } from "./evaluateAstNode";
@@ -252,10 +250,8 @@ function createExtractor() {
252
250
  console.log("Exctacting styled()", styles, out, "to", atomics);
253
251
  }
254
252
  for (const atomic of atomics) {
255
- for (const rule of atomic.rules) {
256
- out.rulesToInsert = out.rulesToInsert || [];
257
- out.rulesToInsert.push([atomic.identifier, rule]);
258
- }
253
+ out.rulesToInsert = out.rulesToInsert || [];
254
+ out.rulesToInsert.push(atomic);
259
255
  classNames[atomic.property] = atomic.identifier;
260
256
  }
261
257
  definition.properties = skipped;
@@ -267,8 +263,8 @@ function createExtractor() {
267
263
  definition.properties.push(t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val)));
268
264
  }
269
265
  if (out.rulesToInsert) {
270
- for (const [identifier, rule] of out.rulesToInsert) {
271
- onStyleRule == null ? void 0 : onStyleRule(identifier, [rule]);
266
+ for (const { identifier, rules } of out.rulesToInsert) {
267
+ onStyleRule == null ? void 0 : onStyleRule(identifier, rules);
272
268
  }
273
269
  }
274
270
  res.styled++;
@@ -277,7 +273,7 @@ function createExtractor() {
277
273
  }
278
274
  },
279
275
  JSXElement(traversePath) {
280
- var _a, _b, _c, _d, _e, _f;
276
+ var _a, _b, _c, _d, _e;
281
277
  tm.mark("jsx-element", shouldPrintDebug === "verbose");
282
278
  const node = traversePath.node.openingElement;
283
279
  const ogAttributes = node.attributes;
@@ -729,16 +725,6 @@ function createExtractor() {
729
725
  prev2[key] = next[key];
730
726
  }
731
727
  }
732
- }, omitInvalidStyles = function(style) {
733
- if (staticConfig.validStyles) {
734
- for (const key in style) {
735
- if (stylePropsTransform[key] || !staticConfig.validStyles[key] && !pseudoDescriptors[key] && !/(hoverStyle|focusStyle|pressStyle)$/.test(key)) {
736
- if (shouldPrintDebug)
737
- console.log(" delete invalid style", key);
738
- delete style[key];
739
- }
740
- }
741
- }
742
728
  };
743
729
  node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
744
730
  if (shouldPrintDebug) {
@@ -1188,24 +1174,6 @@ function createExtractor() {
1188
1174
  if (!completeStyles) {
1189
1175
  throw new Error(`Impossible, no styles`);
1190
1176
  }
1191
- const addInitialStyleKeys = shouldFlatten ? difference(Object.keys(completeStyles), Object.keys(foundStaticProps)) : [];
1192
- if (addInitialStyleKeys.length) {
1193
- const toAdd = pick(completeStyles, ...addInitialStyleKeys);
1194
- const firstGroup = attrs.find((x) => x.type === "style");
1195
- if (shouldPrintDebug) {
1196
- console.log(" toAdd", objToStr(toAdd));
1197
- }
1198
- if (!firstGroup) {
1199
- attrs.unshift({ type: "style", value: toAdd });
1200
- } else {
1201
- omitInvalidStyles(firstGroup.value);
1202
- Object.assign(firstGroup.value, toAdd);
1203
- }
1204
- }
1205
- if (shouldPrintDebug) {
1206
- if (shouldFlatten)
1207
- console.log(" -- addInitialStyleKeys", addInitialStyleKeys.join(", "));
1208
- }
1209
1177
  let getStyleError = null;
1210
1178
  for (const attr of attrs) {
1211
1179
  try {
@@ -1255,9 +1223,6 @@ function createExtractor() {
1255
1223
  if (INLINE_EXTRACTABLE[name]) {
1256
1224
  attr.value.name.name = INLINE_EXTRACTABLE[name];
1257
1225
  }
1258
- if ((_f = staticConfig.variants) == null ? void 0 : _f[name]) {
1259
- const expanded = getStyles({});
1260
- }
1261
1226
  }
1262
1227
  }
1263
1228
  }