@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.
- 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/createExtractor.js +5 -39
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/defaultTamaguiConfig.js +177 -0
- package/dist/cjs/extractor/defaultTamaguiConfig.js.map +7 -0
- package/dist/cjs/extractor/loadTamagui.js +46 -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/createExtractor.js +6 -41
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/defaultTamaguiConfig.js +155 -0
- package/dist/esm/extractor/defaultTamaguiConfig.js.map +7 -0
- package/dist/esm/extractor/loadTamagui.js +46 -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/createExtractor.js +6 -41
- package/dist/jsx/extractor/createExtractor.js.map +2 -2
- package/dist/jsx/extractor/defaultTamaguiConfig.js +142 -0
- package/dist/jsx/extractor/defaultTamaguiConfig.js.map +7 -0
- package/dist/jsx/extractor/loadTamagui.js +46 -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/createExtractor.ts +4 -60
- package/src/extractor/defaultTamaguiConfig.ts +149 -0
- package/src/extractor/loadTamagui.ts +52 -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/createExtractor.d.ts.map +1 -1
- package/types/extractor/defaultTamaguiConfig.d.ts +83 -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,177 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
var defaultTamaguiConfig_exports = {};
|
|
33
|
+
__export(defaultTamaguiConfig_exports, {
|
|
34
|
+
config: () => config,
|
|
35
|
+
tokens: () => tokens
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(defaultTamaguiConfig_exports);
|
|
38
|
+
var import_core_node = require("@tamagui/core-node");
|
|
39
|
+
var import_shorthands = require("@tamagui/shorthands");
|
|
40
|
+
const font = (0, import_core_node.createFont)({
|
|
41
|
+
family: "System",
|
|
42
|
+
size: {
|
|
43
|
+
1: 15
|
|
44
|
+
},
|
|
45
|
+
lineHeight: {
|
|
46
|
+
1: 15
|
|
47
|
+
},
|
|
48
|
+
transform: {},
|
|
49
|
+
weight: {
|
|
50
|
+
1: "400"
|
|
51
|
+
},
|
|
52
|
+
color: {
|
|
53
|
+
1: "$color"
|
|
54
|
+
},
|
|
55
|
+
letterSpacing: {
|
|
56
|
+
1: 0
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const size = {
|
|
60
|
+
0: 0,
|
|
61
|
+
0.25: 2,
|
|
62
|
+
0.5: 4,
|
|
63
|
+
0.75: 8,
|
|
64
|
+
1: 20,
|
|
65
|
+
1.5: 24,
|
|
66
|
+
2: 28,
|
|
67
|
+
2.5: 32,
|
|
68
|
+
3: 36,
|
|
69
|
+
3.5: 40,
|
|
70
|
+
4: 44,
|
|
71
|
+
true: 44,
|
|
72
|
+
4.5: 48,
|
|
73
|
+
5: 52,
|
|
74
|
+
5.5: 59,
|
|
75
|
+
6: 64,
|
|
76
|
+
6.5: 69,
|
|
77
|
+
7: 74,
|
|
78
|
+
7.6: 79,
|
|
79
|
+
8: 84,
|
|
80
|
+
8.5: 89,
|
|
81
|
+
9: 94,
|
|
82
|
+
9.5: 99,
|
|
83
|
+
10: 104,
|
|
84
|
+
11: 124,
|
|
85
|
+
12: 144,
|
|
86
|
+
13: 164,
|
|
87
|
+
14: 184,
|
|
88
|
+
15: 204,
|
|
89
|
+
16: 224,
|
|
90
|
+
17: 224,
|
|
91
|
+
18: 244,
|
|
92
|
+
19: 264,
|
|
93
|
+
20: 284
|
|
94
|
+
};
|
|
95
|
+
const spaces = Object.entries(size).map(([k, v]) => [
|
|
96
|
+
k,
|
|
97
|
+
Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12))
|
|
98
|
+
]);
|
|
99
|
+
const spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v]);
|
|
100
|
+
const space = __spreadValues(__spreadValues({}, Object.fromEntries(spaces)), Object.fromEntries(spacesNegative));
|
|
101
|
+
const zIndex = {
|
|
102
|
+
0: 0,
|
|
103
|
+
1: 100,
|
|
104
|
+
2: 200,
|
|
105
|
+
3: 300,
|
|
106
|
+
4: 400,
|
|
107
|
+
5: 500
|
|
108
|
+
};
|
|
109
|
+
const radius = {
|
|
110
|
+
0: 0,
|
|
111
|
+
1: 3,
|
|
112
|
+
2: 5,
|
|
113
|
+
3: 7,
|
|
114
|
+
4: 9,
|
|
115
|
+
5: 10,
|
|
116
|
+
6: 16,
|
|
117
|
+
7: 19,
|
|
118
|
+
8: 22,
|
|
119
|
+
9: 26,
|
|
120
|
+
10: 34,
|
|
121
|
+
11: 42,
|
|
122
|
+
12: 50
|
|
123
|
+
};
|
|
124
|
+
const tokens = (0, import_core_node.createTokens)({
|
|
125
|
+
color: {
|
|
126
|
+
white: "#fff",
|
|
127
|
+
black: "#000"
|
|
128
|
+
},
|
|
129
|
+
radius,
|
|
130
|
+
zIndex,
|
|
131
|
+
space,
|
|
132
|
+
size
|
|
133
|
+
});
|
|
134
|
+
const themes = {
|
|
135
|
+
light: {
|
|
136
|
+
background: tokens.color.white,
|
|
137
|
+
color: tokens.color.black
|
|
138
|
+
},
|
|
139
|
+
dark: {
|
|
140
|
+
background: tokens.color.black,
|
|
141
|
+
color: tokens.color.white
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const config = (0, import_core_node.createTamagui)({
|
|
145
|
+
defaultTheme: "light",
|
|
146
|
+
shouldAddPrefersColorThemes: true,
|
|
147
|
+
themeClassNameOnRoot: true,
|
|
148
|
+
shorthands: import_shorthands.shorthands,
|
|
149
|
+
fonts: {
|
|
150
|
+
heading: font,
|
|
151
|
+
body: font
|
|
152
|
+
},
|
|
153
|
+
themes,
|
|
154
|
+
tokens,
|
|
155
|
+
media: {
|
|
156
|
+
xs: { maxWidth: 660 },
|
|
157
|
+
sm: { maxWidth: 800 },
|
|
158
|
+
md: { maxWidth: 1020 },
|
|
159
|
+
lg: { maxWidth: 1280 },
|
|
160
|
+
xl: { maxWidth: 1420 },
|
|
161
|
+
xxl: { maxWidth: 1600 },
|
|
162
|
+
gtXs: { minWidth: 660 + 1 },
|
|
163
|
+
gtSm: { minWidth: 800 + 1 },
|
|
164
|
+
gtMd: { minWidth: 1020 + 1 },
|
|
165
|
+
gtLg: { minWidth: 1280 + 1 },
|
|
166
|
+
short: { maxHeight: 820 },
|
|
167
|
+
tall: { minHeight: 820 },
|
|
168
|
+
hoverNone: { hover: "none" },
|
|
169
|
+
pointerCoarse: { pointer: "coarse" }
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
173
|
+
0 && (module.exports = {
|
|
174
|
+
config,
|
|
175
|
+
tokens
|
|
176
|
+
});
|
|
177
|
+
//# 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": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -36,8 +36,12 @@ __export(loadTamagui_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(loadTamagui_exports);
|
|
37
37
|
var import_path = require("path");
|
|
38
38
|
var import_core_node = require("@tamagui/core-node");
|
|
39
|
+
var import_constants = require("../constants");
|
|
40
|
+
var import_require = require("../require");
|
|
41
|
+
var import_defaultTamaguiConfig = require("./defaultTamaguiConfig");
|
|
39
42
|
let loadedTamagui = null;
|
|
40
43
|
function loadTamagui(props) {
|
|
44
|
+
console.trace("load", !!loadedTamagui);
|
|
41
45
|
if (loadedTamagui) {
|
|
42
46
|
return loadedTamagui;
|
|
43
47
|
}
|
|
@@ -51,85 +55,61 @@ function loadTamagui(props) {
|
|
|
51
55
|
if (typeof globalThis["__DEV__"] === "undefined") {
|
|
52
56
|
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
53
57
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Mod.prototype.require = function(path) {
|
|
60
|
-
var _a2, _b;
|
|
61
|
-
if (path.endsWith(".css")) {
|
|
62
|
-
return {};
|
|
63
|
-
}
|
|
64
|
-
if (path === "@gorhom/bottom-sheet" || path.startsWith("react-native-reanimated") || path === "expo-linear-gradient") {
|
|
65
|
-
return proxyWorm;
|
|
66
|
-
}
|
|
67
|
-
if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
|
|
68
|
-
return rnw;
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
const out = og.apply(this, arguments);
|
|
72
|
-
if (!nameToPaths[path]) {
|
|
73
|
-
if (out && typeof out === "object") {
|
|
74
|
-
for (const key in out) {
|
|
75
|
-
try {
|
|
76
|
-
const conf = (_a2 = out[key]) == null ? void 0 : _a2.staticConfig;
|
|
77
|
-
if (conf) {
|
|
78
|
-
if (conf.componentName) {
|
|
79
|
-
nameToPaths[_b = conf.componentName] ?? (nameToPaths[_b] = /* @__PURE__ */ new Set());
|
|
80
|
-
const fullName = path.startsWith(".") ? (0, import_path.join)(`${this.path.replace(/dist(\/cjs)?/, "src")}`, path) : path;
|
|
81
|
-
nameToPaths[conf.componentName].add(fullName);
|
|
82
|
-
} else {
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} catch {
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return out;
|
|
91
|
-
} catch (err) {
|
|
92
|
-
console.error("Tamagui error loading file:\n", path, err.message, "\n", err.stack);
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const exp = require(configPath);
|
|
97
|
-
const tamaguiConfig = exp["default"] || exp;
|
|
98
|
-
if (!tamaguiConfig || !tamaguiConfig.parsed) {
|
|
99
|
-
try {
|
|
58
|
+
(0, import_require.registerRequire)();
|
|
59
|
+
try {
|
|
60
|
+
const exp = require(configPath);
|
|
61
|
+
const tamaguiConfig = exp["default"] || exp;
|
|
62
|
+
if (!tamaguiConfig || !tamaguiConfig.parsed) {
|
|
100
63
|
const confPath = require.resolve(configPath);
|
|
101
64
|
console.log(`Received:`, tamaguiConfig);
|
|
102
65
|
throw new Error(`Can't find valid config in ${confPath}`);
|
|
103
|
-
} catch (err) {
|
|
104
|
-
throw err;
|
|
105
66
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
67
|
+
const components = {};
|
|
68
|
+
for (const moduleName of props.components) {
|
|
69
|
+
const exported = require(moduleName);
|
|
70
|
+
for (const Name in exported) {
|
|
71
|
+
const val = exported[Name];
|
|
72
|
+
const staticConfig = val == null ? void 0 : val.staticConfig;
|
|
73
|
+
if (staticConfig) {
|
|
74
|
+
const _a = staticConfig, { Component, reactNativeWebComponent } = _a, sc = __objRest(_a, ["Component", "reactNativeWebComponent"]);
|
|
75
|
+
Object.assign(components, { [Name]: { staticConfig: sc } });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
process.env.IS_STATIC = void 0;
|
|
80
|
+
(0, import_core_node.createTamagui)(tamaguiConfig);
|
|
81
|
+
loadedTamagui = {
|
|
82
|
+
components,
|
|
83
|
+
tamaguiConfig,
|
|
84
|
+
nameToPaths: (0, import_require.getNameToPaths)()
|
|
85
|
+
};
|
|
86
|
+
} catch (err) {
|
|
87
|
+
if (err instanceof Error) {
|
|
88
|
+
console.warn(`Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`);
|
|
89
|
+
console.log(`
|
|
90
|
+
|
|
91
|
+
${err.message}
|
|
92
|
+
|
|
93
|
+
`);
|
|
94
|
+
if (import_constants.SHOULD_DEBUG) {
|
|
95
|
+
console.log(err.stack);
|
|
116
96
|
}
|
|
97
|
+
} else {
|
|
98
|
+
console.error(`Error loading tamagui.config.ts`, err);
|
|
117
99
|
}
|
|
100
|
+
return {
|
|
101
|
+
components: {},
|
|
102
|
+
tamaguiConfig: import_defaultTamaguiConfig.config,
|
|
103
|
+
nameToPaths: {}
|
|
104
|
+
};
|
|
118
105
|
}
|
|
119
|
-
process.env.IS_STATIC = void 0;
|
|
120
|
-
Mod.prototype.require = og;
|
|
121
|
-
(0, import_core_node.createTamagui)(tamaguiConfig);
|
|
122
|
-
loadedTamagui = {
|
|
123
|
-
components,
|
|
124
|
-
tamaguiConfig,
|
|
125
|
-
nameToPaths
|
|
126
|
-
};
|
|
127
106
|
return loadedTamagui;
|
|
128
107
|
} catch (err) {
|
|
129
108
|
console.log("Error loading Tamagui", err);
|
|
130
109
|
throw err;
|
|
131
110
|
} finally {
|
|
132
111
|
unregister();
|
|
112
|
+
(0, import_require.unregisterRequire)();
|
|
133
113
|
}
|
|
134
114
|
}
|
|
135
115
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAGrB,uBAA8B;AAE9B,IAAI,gBAAqB;AAYlB,qBAAqB,OAAqE;AAC/F,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,sBAAK,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 { 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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAGrB,uBAA8B;AAE9B,uBAA6B;AAC7B,qBAAmE;AACnE,kCAA+C;AAE/C,IAAI,gBAAqB;AAYlB,qBAAqB,OAAqE;AAC/F,UAAQ,MAAM,QAAQ,CAAC,CAAC,aAAa;AAErC,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,sBAAK,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,wCAAgB;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,0CAAc,aAAoB;AAElC,sBAAgB;AAAA,QACd;AAAA,QACA;AAAA,QACA,aAAa,mCAAe;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,+BAAc;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;AAAA,QACf,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,0CAAkB;AAAA,EACpB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __reExport(src_exports, require("./extractor/extractToClassNames"), module.expor
|
|
|
31
31
|
__reExport(src_exports, require("./extractor/extractHelpers"), module.exports);
|
|
32
32
|
__reExport(src_exports, require("@tamagui/patch-rnw"), module.exports);
|
|
33
33
|
__reExport(src_exports, require("./extractor/loadTamagui"), module.exports);
|
|
34
|
+
__reExport(src_exports, require("./require"), module.exports);
|
|
34
35
|
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
35
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
37
|
0 && (module.exports = {
|
package/dist/cjs/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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA+B;AAC/B,6BAAgC;AAChC,0BAA6B;AAC7B,wBAAc,wBALd;AAMA,wBAAc,4CANd;AAOA,wBAAc,uCAPd;AAQA,wBAAc,+BARd;AASA,wBAAc,oCATd;AAAA,QAAQ,IAAI,0BAA0B;",
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA+B;AAC/B,6BAAgC;AAChC,0BAA6B;AAC7B,wBAAc,wBALd;AAMA,wBAAc,4CANd;AAOA,wBAAc,uCAPd;AAQA,wBAAc,+BARd;AASA,wBAAc,oCATd;AAUA,wBAAc,sBAVd;AAAA,QAAQ,IAAI,0BAA0B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var require_exports = {};
|
|
19
|
+
__export(require_exports, {
|
|
20
|
+
getNameToPaths: () => getNameToPaths,
|
|
21
|
+
registerRequire: () => registerRequire,
|
|
22
|
+
unregisterRequire: () => unregisterRequire
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(require_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_constants = require("./constants");
|
|
27
|
+
const nameToPaths = {};
|
|
28
|
+
const Mod = require("module");
|
|
29
|
+
const og = Mod.prototype.require;
|
|
30
|
+
globalThis["ogRequire"] = og;
|
|
31
|
+
const getNameToPaths = () => nameToPaths;
|
|
32
|
+
let tries = 0;
|
|
33
|
+
setInterval(() => {
|
|
34
|
+
tries = 0;
|
|
35
|
+
}, 500);
|
|
36
|
+
function registerRequire() {
|
|
37
|
+
if (Mod.prototype.require !== globalThis["ogRequire"]) {
|
|
38
|
+
console.warn("didnt unregister before re-registering");
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
const proxyWorm = require("@tamagui/proxy-worm");
|
|
42
|
+
const rnw = require("react-native-web");
|
|
43
|
+
Mod.prototype.require = function(path) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
if (import_constants.SHOULD_DEBUG) {
|
|
46
|
+
console.log("tamagui require", path);
|
|
47
|
+
}
|
|
48
|
+
if (path.endsWith(".css")) {
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
if (path === "@gorhom/bottom-sheet" || path.startsWith("react-native-reanimated") || path === "expo-linear-gradient") {
|
|
52
|
+
return proxyWorm;
|
|
53
|
+
}
|
|
54
|
+
if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
|
|
55
|
+
return rnw;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const out = og.apply(this, arguments);
|
|
59
|
+
if (!nameToPaths[path]) {
|
|
60
|
+
if (out && typeof out === "object") {
|
|
61
|
+
for (const key in out) {
|
|
62
|
+
try {
|
|
63
|
+
const conf = (_a = out[key]) == null ? void 0 : _a.staticConfig;
|
|
64
|
+
if (conf) {
|
|
65
|
+
if (conf.componentName) {
|
|
66
|
+
nameToPaths[_b = conf.componentName] ?? (nameToPaths[_b] = /* @__PURE__ */ new Set());
|
|
67
|
+
const fullName = path.startsWith(".") ? (0, import_path.join)(`${this.path.replace(/dist(\/cjs)?/, "src")}`, path) : path;
|
|
68
|
+
nameToPaths[conf.componentName].add(fullName);
|
|
69
|
+
} else {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error(`Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)
|
|
80
|
+
`, err.message);
|
|
81
|
+
if (import_constants.SHOULD_DEBUG) {
|
|
82
|
+
console.log(err.stack);
|
|
83
|
+
}
|
|
84
|
+
if (++tries > 10) {
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function unregisterRequire() {
|
|
91
|
+
Mod.prototype.require = og;
|
|
92
|
+
}
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
getNameToPaths,
|
|
96
|
+
registerRequire,
|
|
97
|
+
unregisterRequire
|
|
98
|
+
});
|
|
99
|
+
//# 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAIrB,uBAA6B;AAE7B,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,+BAAc;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,mCAAY,KAAK,kBAAjB,mBAAoC,oBAAI,IAAI;AAC5C,wBAAM,WAAW,KAAK,WAAW,GAAG,IAChC,sBAAK,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,+BAAc;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/esm/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
|
}
|
|
@@ -39,10 +39,8 @@ import {
|
|
|
39
39
|
getStylesAtomic,
|
|
40
40
|
mediaQueryConfig,
|
|
41
41
|
proxyThemeVariables,
|
|
42
|
-
pseudoDescriptors
|
|
43
|
-
stylePropsTransform
|
|
42
|
+
pseudoDescriptors
|
|
44
43
|
} from "@tamagui/core-node";
|
|
45
|
-
import { difference, pick } from "lodash";
|
|
46
44
|
import { FAILED_EVAL } from "../constants";
|
|
47
45
|
import { createEvaluator, createSafeEvaluator } from "./createEvaluator";
|
|
48
46
|
import { evaluateAstNode } from "./evaluateAstNode";
|
|
@@ -299,10 +297,8 @@ function createExtractor() {
|
|
|
299
297
|
console.log("Exctacting styled()", styles, out, "to", atomics);
|
|
300
298
|
}
|
|
301
299
|
for (const atomic of atomics) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
out.rulesToInsert.push([atomic.identifier, rule]);
|
|
305
|
-
}
|
|
300
|
+
out.rulesToInsert = out.rulesToInsert || [];
|
|
301
|
+
out.rulesToInsert.push(atomic);
|
|
306
302
|
classNames[atomic.property] = atomic.identifier;
|
|
307
303
|
}
|
|
308
304
|
definition.properties = skipped;
|
|
@@ -314,8 +310,8 @@ function createExtractor() {
|
|
|
314
310
|
definition.properties.push(t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val)));
|
|
315
311
|
}
|
|
316
312
|
if (out.rulesToInsert) {
|
|
317
|
-
for (const
|
|
318
|
-
onStyleRule == null ? void 0 : onStyleRule(identifier,
|
|
313
|
+
for (const { identifier, rules } of out.rulesToInsert) {
|
|
314
|
+
onStyleRule == null ? void 0 : onStyleRule(identifier, rules);
|
|
319
315
|
}
|
|
320
316
|
}
|
|
321
317
|
res.styled++;
|
|
@@ -324,7 +320,7 @@ function createExtractor() {
|
|
|
324
320
|
}
|
|
325
321
|
},
|
|
326
322
|
JSXElement(traversePath) {
|
|
327
|
-
var _a2, _b2, _c
|
|
323
|
+
var _a2, _b2, _c;
|
|
328
324
|
tm.mark("jsx-element", shouldPrintDebug === "verbose");
|
|
329
325
|
const node = traversePath.node.openingElement;
|
|
330
326
|
const ogAttributes = node.attributes;
|
|
@@ -773,16 +769,6 @@ function createExtractor() {
|
|
|
773
769
|
prev2[key] = next[key];
|
|
774
770
|
}
|
|
775
771
|
}
|
|
776
|
-
}, omitInvalidStyles = function(style) {
|
|
777
|
-
if (staticConfig.validStyles) {
|
|
778
|
-
for (const key in style) {
|
|
779
|
-
if (stylePropsTransform[key] || !staticConfig.validStyles[key] && !pseudoDescriptors[key] && !/(hoverStyle|focusStyle|pressStyle)$/.test(key)) {
|
|
780
|
-
if (shouldPrintDebug)
|
|
781
|
-
console.log(" delete invalid style", key);
|
|
782
|
-
delete style[key];
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
772
|
};
|
|
787
773
|
node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
|
|
788
774
|
if (shouldPrintDebug) {
|
|
@@ -1224,24 +1210,6 @@ function createExtractor() {
|
|
|
1224
1210
|
if (!completeStyles) {
|
|
1225
1211
|
throw new Error(`Impossible, no styles`);
|
|
1226
1212
|
}
|
|
1227
|
-
const addInitialStyleKeys = shouldFlatten ? difference(Object.keys(completeStyles), Object.keys(foundStaticProps)) : [];
|
|
1228
|
-
if (addInitialStyleKeys.length) {
|
|
1229
|
-
const toAdd = pick(completeStyles, ...addInitialStyleKeys);
|
|
1230
|
-
const firstGroup = attrs.find((x) => x.type === "style");
|
|
1231
|
-
if (shouldPrintDebug) {
|
|
1232
|
-
console.log(" toAdd", objToStr(toAdd));
|
|
1233
|
-
}
|
|
1234
|
-
if (!firstGroup) {
|
|
1235
|
-
attrs.unshift({ type: "style", value: toAdd });
|
|
1236
|
-
} else {
|
|
1237
|
-
omitInvalidStyles(firstGroup.value);
|
|
1238
|
-
Object.assign(firstGroup.value, toAdd);
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
if (shouldPrintDebug) {
|
|
1242
|
-
if (shouldFlatten)
|
|
1243
|
-
console.log(" -- addInitialStyleKeys", addInitialStyleKeys.join(", "));
|
|
1244
|
-
}
|
|
1245
1213
|
let getStyleError = null;
|
|
1246
1214
|
for (const attr of attrs) {
|
|
1247
1215
|
try {
|
|
@@ -1291,9 +1259,6 @@ function createExtractor() {
|
|
|
1291
1259
|
if (INLINE_EXTRACTABLE[name]) {
|
|
1292
1260
|
attr.value.name.name = INLINE_EXTRACTABLE[name];
|
|
1293
1261
|
}
|
|
1294
|
-
if ((_d = staticConfig.variants) == null ? void 0 : _d[name]) {
|
|
1295
|
-
const expanded = getStyles({});
|
|
1296
|
-
}
|
|
1297
1262
|
}
|
|
1298
1263
|
}
|
|
1299
1264
|
}
|