@tamagui/static 1.0.1-beta.103 → 1.0.1-beta.106

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 +45 -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 +156 -0
  20. package/dist/esm/extractor/defaultTamaguiConfig.js.map +7 -0
  21. package/dist/esm/extractor/loadTamagui.js +45 -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 +143 -0
  33. package/dist/jsx/extractor/defaultTamaguiConfig.js.map +7 -0
  34. package/dist/jsx/extractor/loadTamagui.js +45 -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 +150 -0
  45. package/src/extractor/loadTamagui.ts +50 -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 +15 -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,143 @@
1
+ import { createFont, createTamagui, createTokens } from "@tamagui/core-node";
2
+ import { shorthands } from "@tamagui/shorthands";
3
+ function getDefaultTamaguiConfig() {
4
+ const font = createFont({
5
+ family: "System",
6
+ size: {
7
+ 1: 15
8
+ },
9
+ lineHeight: {
10
+ 1: 15
11
+ },
12
+ transform: {},
13
+ weight: {
14
+ 1: "400"
15
+ },
16
+ color: {
17
+ 1: "$color"
18
+ },
19
+ letterSpacing: {
20
+ 1: 0
21
+ }
22
+ });
23
+ const size = {
24
+ 0: 0,
25
+ 0.25: 2,
26
+ 0.5: 4,
27
+ 0.75: 8,
28
+ 1: 20,
29
+ 1.5: 24,
30
+ 2: 28,
31
+ 2.5: 32,
32
+ 3: 36,
33
+ 3.5: 40,
34
+ 4: 44,
35
+ true: 44,
36
+ 4.5: 48,
37
+ 5: 52,
38
+ 5.5: 59,
39
+ 6: 64,
40
+ 6.5: 69,
41
+ 7: 74,
42
+ 7.6: 79,
43
+ 8: 84,
44
+ 8.5: 89,
45
+ 9: 94,
46
+ 9.5: 99,
47
+ 10: 104,
48
+ 11: 124,
49
+ 12: 144,
50
+ 13: 164,
51
+ 14: 184,
52
+ 15: 204,
53
+ 16: 224,
54
+ 17: 224,
55
+ 18: 244,
56
+ 19: 264,
57
+ 20: 284
58
+ };
59
+ const spaces = Object.entries(size).map(([k, v]) => [
60
+ k,
61
+ Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12))
62
+ ]);
63
+ const spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v]);
64
+ const space = {
65
+ ...Object.fromEntries(spaces),
66
+ ...Object.fromEntries(spacesNegative)
67
+ };
68
+ const zIndex = {
69
+ 0: 0,
70
+ 1: 100,
71
+ 2: 200,
72
+ 3: 300,
73
+ 4: 400,
74
+ 5: 500
75
+ };
76
+ const radius = {
77
+ 0: 0,
78
+ 1: 3,
79
+ 2: 5,
80
+ 3: 7,
81
+ 4: 9,
82
+ 5: 10,
83
+ 6: 16,
84
+ 7: 19,
85
+ 8: 22,
86
+ 9: 26,
87
+ 10: 34,
88
+ 11: 42,
89
+ 12: 50
90
+ };
91
+ const tokens = createTokens({
92
+ color: {
93
+ white: "#fff",
94
+ black: "#000"
95
+ },
96
+ radius,
97
+ zIndex,
98
+ space,
99
+ size
100
+ });
101
+ const themes = {
102
+ light: {
103
+ background: tokens.color.white,
104
+ color: tokens.color.black
105
+ },
106
+ dark: {
107
+ background: tokens.color.black,
108
+ color: tokens.color.white
109
+ }
110
+ };
111
+ return createTamagui({
112
+ defaultTheme: "light",
113
+ shouldAddPrefersColorThemes: true,
114
+ themeClassNameOnRoot: true,
115
+ shorthands,
116
+ fonts: {
117
+ heading: font,
118
+ body: font
119
+ },
120
+ themes,
121
+ tokens,
122
+ media: {
123
+ xs: { maxWidth: 660 },
124
+ sm: { maxWidth: 800 },
125
+ md: { maxWidth: 1020 },
126
+ lg: { maxWidth: 1280 },
127
+ xl: { maxWidth: 1420 },
128
+ xxl: { maxWidth: 1600 },
129
+ gtXs: { minWidth: 660 + 1 },
130
+ gtSm: { minWidth: 800 + 1 },
131
+ gtMd: { minWidth: 1020 + 1 },
132
+ gtLg: { minWidth: 1280 + 1 },
133
+ short: { maxHeight: 820 },
134
+ tall: { minHeight: 820 },
135
+ hoverNone: { hover: "none" },
136
+ pointerCoarse: { pointer: "coarse" }
137
+ }
138
+ });
139
+ }
140
+ export {
141
+ getDefaultTamaguiConfig
142
+ };
143
+ //# 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\nexport function getDefaultTamaguiConfig() {\n const 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\n const 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\n const 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\n const spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v])\n\n const space = {\n ...Object.fromEntries(spaces),\n ...Object.fromEntries(spacesNegative),\n } as any\n\n const zIndex = {\n 0: 0,\n 1: 100,\n 2: 200,\n 3: 300,\n 4: 400,\n 5: 500,\n }\n\n const 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\n const tokens = createTokens({\n color: {\n white: '#fff',\n black: '#000',\n },\n radius,\n zIndex,\n space,\n size,\n })\n\n const 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\n return 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}\n"],
5
+ "mappings": "AAAA;AACA;AAGO,mCAAmC;AACxC,QAAM,OAAO,WAAW;AAAA,IACtB,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,GAAG;AAAA,IACL;AAAA,IACA,YAAY;AAAA,MACV,GAAG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AO,EAAE;AAAA,MAC3B,MAAM,EAAE,UAAU,OAAO,EAAE;AAAA,MAC3B,OAAO,EAAE,WAAW,IAAI;AAAA,MACxB,MAAM,EAAE,WAAW,IAAI;AAAA,MACvB,WAAW,EAAE,OAAO,OAAO;AAAA,MAC3B,eAAe,EAAE,SAAS,SAAS;AAAA,IACrC;AAAA,EACF,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -1,5 +1,8 @@
1
1
  import { join } from "path";
2
2
  import { createTamagui } from "@tamagui/core-node";
3
+ import { SHOULD_DEBUG } from "../constants";
4
+ import { getNameToPaths, registerRequire, unregisterRequire } from "../require";
5
+ import { getDefaultTamaguiConfig } from "./defaultTamaguiConfig";
3
6
  let loadedTamagui = null;
4
7
  function loadTamagui(props) {
5
8
  if (loadedTamagui) {
@@ -15,85 +18,61 @@ function loadTamagui(props) {
15
18
  if (typeof globalThis["__DEV__"] === "undefined") {
16
19
  globalThis["__DEV__"] = process.env.NODE_ENV === "development";
17
20
  }
18
- const proxyWorm = require("@tamagui/proxy-worm");
19
- const rnw = require("react-native-web");
20
- const Mod = require("module");
21
- const og = Mod.prototype.require;
22
- const nameToPaths = {};
23
- Mod.prototype.require = function(path) {
24
- var _a, _b, _c;
25
- if (path.endsWith(".css")) {
26
- return {};
27
- }
28
- if (path === "@gorhom/bottom-sheet" || path.startsWith("react-native-reanimated") || path === "expo-linear-gradient") {
29
- return proxyWorm;
30
- }
31
- if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
32
- return rnw;
33
- }
34
- try {
35
- const out = og.apply(this, arguments);
36
- if (!nameToPaths[path]) {
37
- if (out && typeof out === "object") {
38
- for (const key in out) {
39
- try {
40
- const conf = (_a = out[key]) == null ? void 0 : _a.staticConfig;
41
- if (conf) {
42
- if (conf.componentName) {
43
- (_c = nameToPaths[_b = conf.componentName]) != null ? _c : nameToPaths[_b] = /* @__PURE__ */ new Set();
44
- const fullName = path.startsWith(".") ? join(`${this.path.replace(/dist(\/cjs)?/, "src")}`, path) : path;
45
- nameToPaths[conf.componentName].add(fullName);
46
- } else {
47
- }
48
- }
49
- } catch {
50
- }
51
- }
52
- }
53
- }
54
- return out;
55
- } catch (err) {
56
- console.error("Tamagui error loading file:\n", path, err.message, "\n", err.stack);
57
- process.exit(1);
58
- }
59
- };
60
- const exp = require(configPath);
61
- const tamaguiConfig = exp["default"] || exp;
62
- if (!tamaguiConfig || !tamaguiConfig.parsed) {
63
- try {
21
+ registerRequire();
22
+ try {
23
+ const exp = require(configPath);
24
+ const tamaguiConfig = exp["default"] || exp;
25
+ if (!tamaguiConfig || !tamaguiConfig.parsed) {
64
26
  const confPath = require.resolve(configPath);
65
27
  console.log(`Received:`, tamaguiConfig);
66
28
  throw new Error(`Can't find valid config in ${confPath}`);
67
- } catch (err) {
68
- throw err;
69
29
  }
70
- }
71
- const components = {};
72
- for (const moduleName of props.components) {
73
- const exported = require(moduleName);
74
- for (const Name in exported) {
75
- const val = exported[Name];
76
- const staticConfig = val == null ? void 0 : val.staticConfig;
77
- if (staticConfig) {
78
- const { Component, reactNativeWebComponent, ...sc } = staticConfig;
79
- Object.assign(components, { [Name]: { staticConfig: sc } });
30
+ const components = {};
31
+ for (const moduleName of props.components) {
32
+ const exported = require(moduleName);
33
+ for (const Name in exported) {
34
+ const val = exported[Name];
35
+ const staticConfig = val == null ? void 0 : val.staticConfig;
36
+ if (staticConfig) {
37
+ const { Component, reactNativeWebComponent, ...sc } = staticConfig;
38
+ Object.assign(components, { [Name]: { staticConfig: sc } });
39
+ }
40
+ }
41
+ }
42
+ process.env.IS_STATIC = void 0;
43
+ createTamagui(tamaguiConfig);
44
+ loadedTamagui = {
45
+ components,
46
+ tamaguiConfig,
47
+ nameToPaths: getNameToPaths()
48
+ };
49
+ } catch (err) {
50
+ if (err instanceof Error) {
51
+ console.warn(`Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`);
52
+ console.log(`
53
+
54
+ ${err.message}
55
+
56
+ `);
57
+ if (SHOULD_DEBUG) {
58
+ console.log(err.stack);
80
59
  }
60
+ } else {
61
+ console.error(`Error loading tamagui.config.ts`, err);
81
62
  }
63
+ return {
64
+ components: {},
65
+ tamaguiConfig: getDefaultTamaguiConfig(),
66
+ nameToPaths: {}
67
+ };
82
68
  }
83
- process.env.IS_STATIC = void 0;
84
- Mod.prototype.require = og;
85
- createTamagui(tamaguiConfig);
86
- loadedTamagui = {
87
- components,
88
- tamaguiConfig,
89
- nameToPaths
90
- };
91
69
  return loadedTamagui;
92
70
  } catch (err) {
93
71
  console.log("Error loading Tamagui", err);
94
72
  throw err;
95
73
  } finally {
96
74
  unregister();
75
+ unregisterRequire();
97
76
  }
98
77
  }
99
78
  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 T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} 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 { getDefaultTamaguiConfig } 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 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: getDefaultTamaguiConfig(),\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,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,oBAAgB;AAEhB,QAAI;AAEF,YAAM,MAAM,QAAQ,UAAU;AAC9B,YAAM,gBAAiB,IAAI,cAAc;AAEzC,UAAI,CAAC,iBAAiB,CAAC,cAAc,QAAQ;AAC3C,cAAM,WAA2B,AAAhB,QAAQ,QAAQ;AACjC,gBAAQ,IAAI,aAAa,aAAa;AACtC,cAAM,IAAI,MAAM,8BAA8B,UAAU;AAAA,MAC1D;AAGA,YAAM,aAAa,CAAC;AACpB,iBAAW,cAAc,MAAM,YAAY;AACzC,cAAM,WAAW,QAAQ,UAAU;AACnC,mBAAW,QAAQ,UAAU;AAC3B,gBAAM,MAAM,SAAS;AACrB,gBAAM,eAAe,2BAAK;AAC1B,cAAI,cAAc;AAEhB,kBAAM,EAAE,WAAW,4BAA4B,OAAO;AACtD,mBAAO,OAAO,YAAY,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,EAAE,CAAC;AAAA,UAC5D;AAAA,QACF;AAAA,MACF;AAGA,cAAQ,IAAI,YAAY;AAGxB,oBAAc,aAAoB;AAElC,sBAAgB;AAAA,QACd;AAAA,QACA;AAAA,QACA,aAAa,eAAe;AAAA,MAC9B;AAAA,IACF,SAAS,KAAP;AACA,UAAI,eAAe,OAAO;AACxB,gBAAQ,KACN,8GACF;AACA,gBAAQ,IAAI;AAAA;AAAA,MAAW,IAAI;AAAA;AAAA,CAAa;AACxC,YAAI,cAAc;AAChB,kBAAQ,IAAI,IAAI,KAAK;AAAA,QACvB;AAAA,MACF,OAAO;AACL,gBAAQ,MAAM,mCAAmC,GAAG;AAAA,MACtD;AACA,aAAO;AAAA,QACL,YAAY,CAAC;AAAA,QACb,eAAe,wBAAwB;AAAA,QACvC,aAAa,CAAC;AAAA,MAChB;AAAA,IACF;AAEA,WAAO;AAAA,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/jsx/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, _b, _c;
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
+ (_c = nameToPaths[_b = conf.componentName]) != null ? _c : nameToPaths[_b] = /* @__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 process.exit(1)\n }\n }\n }\n}\n\nexport function unregisterRequire() {\n Mod.prototype.require = og\n}\n"],
5
+ "mappings": "AAAA;AAIA;AAEA,MAAM,cAAc,CAAC;AACrB,MAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAM,KAAK,IAAI,UAAU;AACzB,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAEpC,IAAI,QAAQ;AACZ,YAAY,MAAM;AAChB,UAAQ;AACV,GAAG,GAAG;AAEC,2BAA2B;AAChC,MAAI,IAAI,UAAU,YAAY,WAAW,cAAc;AACrD,YAAQ,KAAK,wCAAwC;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,QAAQ,qBAAqB;AAC/C,QAAM,MAAM,QAAQ,kBAAkB;AAEtC,MAAI,UAAU,UAAU,SAAU,MAAc;AA3BlD;AA4BI,QAAI,cAAc;AAChB,cAAQ,IAAI,mBAAmB,IAAI;AAAA,IACrC;AACA,QAAI,KAAK,SAAS,MAAM,GAAG;AACzB,aAAO,CAAC;AAAA,IACV;AACA,QACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,wBACT;AACA,aAAO;AAAA,IACT;AACA,QACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,mCAAmC,GACpD;AACA,aAAO;AAAA,IAET;AACA,QAAI;AACF,YAAM,MAAM,GAAG,MAAM,MAAM,SAAS;AACpC,UAAI,CAAC,YAAY,OAAO;AACtB,YAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,qBAAW,OAAO,KAAK;AACrB,gBAAI;AACF,oBAAM,OAAO,UAAI,SAAJ,mBAAU;AACvB,kBAAI,MAAM;AACR,oBAAI,KAAK,eAAe;AACtB,yCAAY,KAAK,mBAAjB,8BAAoC,oBAAI,IAAI;AAC5C,wBAAM,WAAW,KAAK,WAAW,GAAG,IAChC,KAAK,GAAG,KAAK,KAAK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,8BAAY,KAAK,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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/static",
3
- "version": "1.0.1-beta.103",
3
+ "version": "1.0.1-beta.106",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -38,12 +38,13 @@
38
38
  "@babel/parser": "^7.15.7",
39
39
  "@babel/traverse": "^7.15.4",
40
40
  "@expo/match-media": "^0.3.0",
41
- "@tamagui/build": "^1.0.1-beta.103",
42
- "@tamagui/core-node": "^1.0.1-beta.103",
43
- "@tamagui/fake-react-native": "^1.0.1-beta.103",
44
- "@tamagui/helpers": "^1.0.1-beta.103",
45
- "@tamagui/patch-rnw": "^1.0.1-beta.103",
46
- "@tamagui/proxy-worm": "^1.0.1-beta.103",
41
+ "@tamagui/build": "^1.0.1-beta.106",
42
+ "@tamagui/core-node": "^1.0.1-beta.106",
43
+ "@tamagui/fake-react-native": "^1.0.1-beta.106",
44
+ "@tamagui/helpers": "^1.0.1-beta.106",
45
+ "@tamagui/patch-rnw": "^1.0.1-beta.106",
46
+ "@tamagui/proxy-worm": "^1.0.1-beta.106",
47
+ "@tamagui/shorthands": "^1.0.1-beta.106",
47
48
  "babel-literal-to-ast": "^2.1.0",
48
49
  "esbuild": "^0.14.48",
49
50
  "esbuild-register": "^3.3.2",
@@ -51,7 +52,7 @@
51
52
  "fs-extra": "^10.1.0",
52
53
  "invariant": "^2.2.4",
53
54
  "lodash": "^4.17.21",
54
- "tamagui": "^1.0.1-beta.103"
55
+ "tamagui": "^1.0.1-beta.106"
55
56
  },
56
57
  "devDependencies": {
57
58
  "@babel/plugin-syntax-typescript": "^7.14.5",
package/src/constants.ts CHANGED
@@ -11,3 +11,5 @@ export const cacheDir = findCacheDir({ name: 'tamagui', create: true })
11
11
 
12
12
  export const FAILED_EVAL = Symbol('failed_style_eval')
13
13
  export const CONCAT_CLASSNAME_IMPORT = 'concatClassName'
14
+
15
+ export const SHOULD_DEBUG = process.env.DEBUG === '*' || process.env.DEBUG?.startsWith('tamagui')
@@ -3,7 +3,7 @@ import vm from 'vm'
3
3
  import generate from '@babel/generator'
4
4
  import { NodePath } from '@babel/traverse'
5
5
  import * as t from '@babel/types'
6
- import type { TamaguiConfig } from '@tamagui/core'
6
+ import type { TamaguiConfig } from '@tamagui/core-node'
7
7
  import { createCSSVariable } from '@tamagui/core-node'
8
8
  import esbuild from 'esbuild'
9
9
 
@@ -13,9 +13,7 @@ import {
13
13
  mediaQueryConfig,
14
14
  proxyThemeVariables,
15
15
  pseudoDescriptors,
16
- stylePropsTransform,
17
16
  } from '@tamagui/core-node'
18
- import { difference, pick } from 'lodash'
19
17
  import type { ViewStyle } from 'react-native'
20
18
 
21
19
  import { FAILED_EVAL } from '../constants'
@@ -371,10 +369,8 @@ export function createExtractor() {
371
369
  }
372
370
 
373
371
  for (const atomic of atomics) {
374
- for (const rule of atomic.rules) {
375
- out.rulesToInsert = out.rulesToInsert || []
376
- out.rulesToInsert.push([atomic.identifier, rule])
377
- }
372
+ out.rulesToInsert = out.rulesToInsert || []
373
+ out.rulesToInsert.push(atomic)
378
374
  classNames[atomic.property] = atomic.identifier
379
375
  }
380
376
 
@@ -391,8 +387,8 @@ export function createExtractor() {
391
387
  }
392
388
 
393
389
  if (out.rulesToInsert) {
394
- for (const [identifier, rule] of out.rulesToInsert) {
395
- onStyleRule?.(identifier, [rule])
390
+ for (const { identifier, rules } of out.rulesToInsert) {
391
+ onStyleRule?.(identifier, rules)
396
392
  }
397
393
  }
398
394
 
@@ -1706,22 +1702,6 @@ export function createExtractor() {
1706
1702
  }
1707
1703
  }
1708
1704
 
1709
- function omitInvalidStyles(style: any) {
1710
- if (staticConfig.validStyles) {
1711
- for (const key in style) {
1712
- if (
1713
- stylePropsTransform[key] ||
1714
- (!staticConfig.validStyles[key] &&
1715
- !pseudoDescriptors[key] &&
1716
- !/(hoverStyle|focusStyle|pressStyle)$/.test(key))
1717
- ) {
1718
- if (shouldPrintDebug) console.log(' delete invalid style', key)
1719
- delete style[key]
1720
- }
1721
- }
1722
- }
1723
- }
1724
-
1725
1705
  // used to ensure we pass the entire prop bundle to getStyles
1726
1706
  const completeStyles = getStyles(completeProps, 'completeStyles')
1727
1707
 
@@ -1729,33 +1709,6 @@ export function createExtractor() {
1729
1709
  throw new Error(`Impossible, no styles`)
1730
1710
  }
1731
1711
 
1732
- // any extra styles added in postprocess should be added to first group as they wont be overriden
1733
- const addInitialStyleKeys = shouldFlatten
1734
- ? difference(Object.keys(completeStyles), Object.keys(foundStaticProps))
1735
- : []
1736
-
1737
- if (addInitialStyleKeys.length) {
1738
- const toAdd = pick(completeStyles, ...addInitialStyleKeys)
1739
- const firstGroup = attrs.find((x) => x.type === 'style')
1740
- if (shouldPrintDebug) {
1741
- console.log(' toAdd', objToStr(toAdd))
1742
- }
1743
- if (!firstGroup) {
1744
- attrs.unshift({ type: 'style', value: toAdd })
1745
- } else {
1746
- // because were adding fully processed, remove any unprocessed from first group
1747
- omitInvalidStyles(firstGroup.value)
1748
- Object.assign(firstGroup.value, toAdd)
1749
- }
1750
- }
1751
-
1752
- if (shouldPrintDebug) {
1753
- // prettier-ignore
1754
- if (shouldFlatten) console.log(' -- addInitialStyleKeys', addInitialStyleKeys.join(', '))
1755
- // prettier-ignore
1756
- // console.log(' -- completeStyles:\n', logLines(objToStr(completeStyles)))
1757
- }
1758
-
1759
1712
  let getStyleError: any = null
1760
1713
 
1761
1714
  // fix up ternaries, combine final style values
@@ -1815,15 +1768,6 @@ export function createExtractor() {
1815
1768
  // map to HTML only name
1816
1769
  attr.value.name.name = INLINE_EXTRACTABLE[name]
1817
1770
  }
1818
-
1819
- // if flattening expand turn variants into styles
1820
- if (staticConfig.variants?.[name]) {
1821
- const expanded = getStyles({})
1822
- // attrs[i] = {
1823
- // type: 'style',
1824
- // value:
1825
- // }
1826
- }
1827
1771
  }
1828
1772
  }
1829
1773
  }