@tamagui/static 1.0.1-beta.104 → 1.0.1-beta.107
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.
- package/dist/cjs/constants.js +4 -0
- package/dist/cjs/constants.js.map +2 -2
- package/dist/cjs/extractor/createEvaluator.js.map +1 -1
- package/dist/cjs/extractor/defaultTamaguiConfig.js +177 -0
- package/dist/cjs/extractor/defaultTamaguiConfig.js.map +7 -0
- package/dist/cjs/extractor/loadTamagui.js +45 -66
- package/dist/cjs/extractor/loadTamagui.js.map +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/require.js +99 -0
- package/dist/cjs/require.js.map +7 -0
- package/dist/esm/constants.js +3 -0
- package/dist/esm/constants.js.map +2 -2
- package/dist/esm/extractor/createEvaluator.js.map +1 -1
- package/dist/esm/extractor/defaultTamaguiConfig.js +156 -0
- package/dist/esm/extractor/defaultTamaguiConfig.js.map +7 -0
- package/dist/esm/extractor/loadTamagui.js +45 -66
- package/dist/esm/extractor/loadTamagui.js.map +2 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/require.js +74 -0
- package/dist/esm/require.js.map +7 -0
- package/dist/jsx/constants.js +3 -0
- package/dist/jsx/constants.js.map +2 -2
- package/dist/jsx/extractor/createEvaluator.js.map +1 -1
- package/dist/jsx/extractor/defaultTamaguiConfig.js +143 -0
- package/dist/jsx/extractor/defaultTamaguiConfig.js.map +7 -0
- package/dist/jsx/extractor/loadTamagui.js +45 -66
- package/dist/jsx/extractor/loadTamagui.js.map +2 -2
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/index.js.map +2 -2
- package/dist/jsx/require.js +74 -0
- package/dist/jsx/require.js.map +7 -0
- package/package.json +9 -8
- package/src/constants.ts +2 -0
- package/src/extractor/createEvaluator.ts +1 -1
- package/src/extractor/defaultTamaguiConfig.ts +150 -0
- package/src/extractor/loadTamagui.ts +50 -85
- package/src/index.ts +1 -0
- package/src/require.ts +93 -0
- package/types/constants.d.ts +1 -0
- package/types/constants.d.ts.map +1 -1
- package/types/extractor/createEvaluator.d.ts +1 -1
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/defaultTamaguiConfig.d.ts +15 -0
- package/types/extractor/defaultTamaguiConfig.d.ts.map +1 -0
- package/types/extractor/loadTamagui.d.ts +1 -1
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/require.d.ts +4 -0
- package/types/require.d.ts.map +1 -0
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
function getDefaultTamaguiConfig() {
|
|
20
|
+
const font = createFont({
|
|
21
|
+
family: "System",
|
|
22
|
+
size: {
|
|
23
|
+
1: 15
|
|
24
|
+
},
|
|
25
|
+
lineHeight: {
|
|
26
|
+
1: 15
|
|
27
|
+
},
|
|
28
|
+
transform: {},
|
|
29
|
+
weight: {
|
|
30
|
+
1: "400"
|
|
31
|
+
},
|
|
32
|
+
color: {
|
|
33
|
+
1: "$color"
|
|
34
|
+
},
|
|
35
|
+
letterSpacing: {
|
|
36
|
+
1: 0
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const size = {
|
|
40
|
+
0: 0,
|
|
41
|
+
0.25: 2,
|
|
42
|
+
0.5: 4,
|
|
43
|
+
0.75: 8,
|
|
44
|
+
1: 20,
|
|
45
|
+
1.5: 24,
|
|
46
|
+
2: 28,
|
|
47
|
+
2.5: 32,
|
|
48
|
+
3: 36,
|
|
49
|
+
3.5: 40,
|
|
50
|
+
4: 44,
|
|
51
|
+
true: 44,
|
|
52
|
+
4.5: 48,
|
|
53
|
+
5: 52,
|
|
54
|
+
5.5: 59,
|
|
55
|
+
6: 64,
|
|
56
|
+
6.5: 69,
|
|
57
|
+
7: 74,
|
|
58
|
+
7.6: 79,
|
|
59
|
+
8: 84,
|
|
60
|
+
8.5: 89,
|
|
61
|
+
9: 94,
|
|
62
|
+
9.5: 99,
|
|
63
|
+
10: 104,
|
|
64
|
+
11: 124,
|
|
65
|
+
12: 144,
|
|
66
|
+
13: 164,
|
|
67
|
+
14: 184,
|
|
68
|
+
15: 204,
|
|
69
|
+
16: 224,
|
|
70
|
+
17: 224,
|
|
71
|
+
18: 244,
|
|
72
|
+
19: 264,
|
|
73
|
+
20: 284
|
|
74
|
+
};
|
|
75
|
+
const spaces = Object.entries(size).map(([k, v]) => [
|
|
76
|
+
k,
|
|
77
|
+
Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12))
|
|
78
|
+
]);
|
|
79
|
+
const spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v]);
|
|
80
|
+
const space = __spreadValues(__spreadValues({}, Object.fromEntries(spaces)), Object.fromEntries(spacesNegative));
|
|
81
|
+
const zIndex = {
|
|
82
|
+
0: 0,
|
|
83
|
+
1: 100,
|
|
84
|
+
2: 200,
|
|
85
|
+
3: 300,
|
|
86
|
+
4: 400,
|
|
87
|
+
5: 500
|
|
88
|
+
};
|
|
89
|
+
const radius = {
|
|
90
|
+
0: 0,
|
|
91
|
+
1: 3,
|
|
92
|
+
2: 5,
|
|
93
|
+
3: 7,
|
|
94
|
+
4: 9,
|
|
95
|
+
5: 10,
|
|
96
|
+
6: 16,
|
|
97
|
+
7: 19,
|
|
98
|
+
8: 22,
|
|
99
|
+
9: 26,
|
|
100
|
+
10: 34,
|
|
101
|
+
11: 42,
|
|
102
|
+
12: 50
|
|
103
|
+
};
|
|
104
|
+
const tokens = createTokens({
|
|
105
|
+
color: {
|
|
106
|
+
white: "#fff",
|
|
107
|
+
black: "#000"
|
|
108
|
+
},
|
|
109
|
+
radius,
|
|
110
|
+
zIndex,
|
|
111
|
+
space,
|
|
112
|
+
size
|
|
113
|
+
});
|
|
114
|
+
const themes = {
|
|
115
|
+
light: {
|
|
116
|
+
background: tokens.color.white,
|
|
117
|
+
color: tokens.color.black
|
|
118
|
+
},
|
|
119
|
+
dark: {
|
|
120
|
+
background: tokens.color.black,
|
|
121
|
+
color: tokens.color.white
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return createTamagui({
|
|
125
|
+
defaultTheme: "light",
|
|
126
|
+
shouldAddPrefersColorThemes: true,
|
|
127
|
+
themeClassNameOnRoot: true,
|
|
128
|
+
shorthands,
|
|
129
|
+
fonts: {
|
|
130
|
+
heading: font,
|
|
131
|
+
body: font
|
|
132
|
+
},
|
|
133
|
+
themes,
|
|
134
|
+
tokens,
|
|
135
|
+
media: {
|
|
136
|
+
xs: { maxWidth: 660 },
|
|
137
|
+
sm: { maxWidth: 800 },
|
|
138
|
+
md: { maxWidth: 1020 },
|
|
139
|
+
lg: { maxWidth: 1280 },
|
|
140
|
+
xl: { maxWidth: 1420 },
|
|
141
|
+
xxl: { maxWidth: 1600 },
|
|
142
|
+
gtXs: { minWidth: 660 + 1 },
|
|
143
|
+
gtSm: { minWidth: 800 + 1 },
|
|
144
|
+
gtMd: { minWidth: 1020 + 1 },
|
|
145
|
+
gtLg: { minWidth: 1280 + 1 },
|
|
146
|
+
short: { maxHeight: 820 },
|
|
147
|
+
tall: { minHeight: 820 },
|
|
148
|
+
hoverNone: { hover: "none" },
|
|
149
|
+
pointerCoarse: { pointer: "coarse" }
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
export {
|
|
154
|
+
getDefaultTamaguiConfig
|
|
155
|
+
};
|
|
156
|
+
//# 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;AAAA,IACL;AAAA,IACA,WAAW,CAAC;AAAA,IACZ,QAAQ;AAAA,MACN,GAA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AM,EAAE,WAAW,IAAI;AAAA,MACvB,WAAW,EAAE,OAAO,OAAO;AAAA,MAC3B,eAAe,EAAE,SAAS,SAAS;AAAA,IACrC;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -15,6 +15,9 @@ 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 { getDefaultTamaguiConfig } from "./defaultTamaguiConfig";
|
|
18
21
|
let loadedTamagui = null;
|
|
19
22
|
function loadTamagui(props) {
|
|
20
23
|
if (loadedTamagui) {
|
|
@@ -30,85 +33,61 @@ function loadTamagui(props) {
|
|
|
30
33
|
if (typeof globalThis["__DEV__"] === "undefined") {
|
|
31
34
|
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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 {
|
|
36
|
+
registerRequire();
|
|
37
|
+
try {
|
|
38
|
+
const exp = require(configPath);
|
|
39
|
+
const tamaguiConfig = exp["default"] || exp;
|
|
40
|
+
if (!tamaguiConfig || !tamaguiConfig.parsed) {
|
|
79
41
|
const confPath = require.resolve(configPath);
|
|
80
42
|
console.log(`Received:`, tamaguiConfig);
|
|
81
43
|
throw new Error(`Can't find valid config in ${confPath}`);
|
|
82
|
-
} catch (err) {
|
|
83
|
-
throw err;
|
|
84
44
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
45
|
+
const components = {};
|
|
46
|
+
for (const moduleName of props.components) {
|
|
47
|
+
const exported = require(moduleName);
|
|
48
|
+
for (const Name in exported) {
|
|
49
|
+
const val = exported[Name];
|
|
50
|
+
const staticConfig = val == null ? void 0 : val.staticConfig;
|
|
51
|
+
if (staticConfig) {
|
|
52
|
+
const _a = staticConfig, { Component, reactNativeWebComponent } = _a, sc = __objRest(_a, ["Component", "reactNativeWebComponent"]);
|
|
53
|
+
Object.assign(components, { [Name]: { staticConfig: sc } });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
process.env.IS_STATIC = void 0;
|
|
58
|
+
createTamagui(tamaguiConfig);
|
|
59
|
+
loadedTamagui = {
|
|
60
|
+
components,
|
|
61
|
+
tamaguiConfig,
|
|
62
|
+
nameToPaths: getNameToPaths()
|
|
63
|
+
};
|
|
64
|
+
} catch (err) {
|
|
65
|
+
if (err instanceof Error) {
|
|
66
|
+
console.warn(`Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`);
|
|
67
|
+
console.log(`
|
|
68
|
+
|
|
69
|
+
${err.message}
|
|
70
|
+
|
|
71
|
+
`);
|
|
72
|
+
if (SHOULD_DEBUG) {
|
|
73
|
+
console.log(err.stack);
|
|
95
74
|
}
|
|
75
|
+
} else {
|
|
76
|
+
console.error(`Error loading tamagui.config.ts`, err);
|
|
96
77
|
}
|
|
78
|
+
return {
|
|
79
|
+
components: {},
|
|
80
|
+
tamaguiConfig: getDefaultTamaguiConfig(),
|
|
81
|
+
nameToPaths: {}
|
|
82
|
+
};
|
|
97
83
|
}
|
|
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
84
|
return loadedTamagui;
|
|
107
85
|
} catch (err) {
|
|
108
86
|
console.log("Error loading Tamagui", err);
|
|
109
87
|
throw err;
|
|
110
88
|
} finally {
|
|
111
89
|
unregister();
|
|
90
|
+
unregisterRequire();
|
|
112
91
|
}
|
|
113
92
|
}
|
|
114
93
|
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
|
|
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,
|
|
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 { 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,kBAAsD,mBAA9C,aAAW,4BAAmC,IAAP,eAAO,IAAP,CAAvC,aAAW;AACnB,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/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -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 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;AAC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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/dist/jsx/constants.js
CHANGED
|
@@ -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
|
}
|
|
@@ -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
|