@tamagui/static 2.0.0-rc.8 → 2.0.0
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/check-dep-versions.cjs +201 -96
- package/dist/checkDeps.cjs +250 -46
- package/dist/constants.cjs +32 -30
- package/dist/exports.cjs +20 -13
- package/dist/extractor/accessSafe.cjs +25 -23
- package/dist/extractor/babelParse.cjs +30 -28
- package/dist/extractor/buildClassName.cjs +59 -35
- package/dist/extractor/bundle.cjs +187 -101
- package/dist/extractor/bundleConfig.cjs +568 -168
- package/dist/extractor/concatClassName.cjs +73 -32
- package/dist/extractor/createEvaluator.cjs +54 -41
- package/dist/extractor/createExtractor.cjs +1405 -574
- package/dist/extractor/createLogger.cjs +30 -25
- package/dist/extractor/detectModuleFormat.cjs +55 -0
- package/dist/extractor/ensureImportingConcat.cjs +31 -25
- package/dist/extractor/errors.cjs +12 -10
- package/dist/extractor/esbuildAliasPlugin.cjs +28 -16
- package/dist/extractor/esbuildTsconfigPaths.cjs +60 -36
- package/dist/extractor/evaluateAstNode.cjs +104 -59
- package/dist/extractor/extractHelpers.cjs +130 -67
- package/dist/extractor/extractMediaStyle.cjs +110 -69
- package/dist/extractor/extractToClassNames.cjs +337 -229
- package/dist/extractor/extractToNative.cjs +248 -154
- package/dist/extractor/findTopmostFunction.cjs +22 -13
- package/dist/extractor/generatedUid.cjs +39 -28
- package/dist/extractor/getPrefixLogs.cjs +12 -10
- package/dist/extractor/getPropValueFromAttributes.cjs +52 -34
- package/dist/extractor/getSourceModule.cjs +73 -37
- package/dist/extractor/getStaticBindingsForScope.cjs +131 -68
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +20 -14
- package/dist/extractor/hasTopLevelAwait.cjs +62 -0
- package/dist/extractor/hoistClassNames.cjs +46 -32
- package/dist/extractor/literalToAst.cjs +67 -42
- package/dist/extractor/loadFile.cjs +9 -3
- package/dist/extractor/loadTamagui.cjs +151 -105
- package/dist/extractor/logLines.cjs +27 -19
- package/dist/extractor/normalizeTernaries.cjs +66 -44
- package/dist/extractor/propsToFontFamilyCache.cjs +15 -11
- package/dist/extractor/regenerateConfig.cjs +109 -81
- package/dist/extractor/removeUnusedHooks.cjs +73 -41
- package/dist/extractor/timer.cjs +23 -14
- package/dist/extractor/validHTMLAttributes.cjs +61 -59
- package/dist/extractor/watchTamaguiConfig.cjs +35 -23
- package/dist/getPragmaOptions.cjs +34 -19
- package/dist/helpers/memoize.cjs +24 -16
- package/dist/helpers/requireTamaguiCore.cjs +22 -15
- package/dist/index.cjs +26 -24
- package/dist/registerRequire.cjs +168 -65
- package/dist/server.cjs +35 -28
- package/dist/types.cjs +7 -5
- package/dist/worker.cjs +62 -40
- package/package.json +27 -24
- package/src/checkDeps.ts +305 -68
- package/src/exports.ts +2 -0
- package/src/extractor/babelParse.ts +1 -0
- package/src/extractor/bundle.ts +172 -40
- package/src/extractor/bundleConfig.ts +459 -65
- package/src/extractor/concatClassName.ts +37 -20
- package/src/extractor/createExtractor.ts +300 -30
- package/src/extractor/detectModuleFormat.ts +42 -0
- package/src/extractor/esbuildTsconfigPaths.ts +6 -1
- package/src/extractor/extractToClassNames.ts +15 -9
- package/src/extractor/extractToNative.ts +66 -33
- package/src/extractor/hasTopLevelAwait.ts +28 -0
- package/src/extractor/loadTamagui.ts +5 -4
- package/src/registerRequire.ts +102 -9
- package/types/checkDeps.d.ts.map +1 -1
- package/types/exports.d.ts +2 -0
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/babelParse.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts +83 -1
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +15 -2
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/detectModuleFormat.d.ts +5 -0
- package/types/extractor/detectModuleFormat.d.ts.map +1 -0
- package/types/extractor/esbuildTsconfigPaths.d.ts +8 -0
- package/types/extractor/esbuildTsconfigPaths.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/hasTopLevelAwait.d.ts +2 -0
- package/types/extractor/hasTopLevelAwait.d.ts.map +1 -0
- package/types/extractor/loadTamagui.d.ts +1 -1
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/registerRequire.d.ts.map +1 -1
- package/dist/check-dep-versions.js +0 -389
- package/dist/check-dep-versions.js.map +0 -6
- package/dist/checkDeps.js +0 -60
- package/dist/checkDeps.js.map +0 -6
- package/dist/constants.js +0 -34
- package/dist/constants.js.map +0 -6
- package/dist/exports.js +0 -34
- package/dist/exports.js.map +0 -6
- package/dist/extractor/accessSafe.js +0 -47
- package/dist/extractor/accessSafe.js.map +0 -6
- package/dist/extractor/babelParse.js +0 -59
- package/dist/extractor/babelParse.js.map +0 -6
- package/dist/extractor/buildClassName.js +0 -72
- package/dist/extractor/buildClassName.js.map +0 -6
- package/dist/extractor/bundle.js +0 -135
- package/dist/extractor/bundle.js.map +0 -6
- package/dist/extractor/bundleConfig.js +0 -352
- package/dist/extractor/bundleConfig.js.map +0 -6
- package/dist/extractor/concatClassName.js +0 -69
- package/dist/extractor/concatClassName.js.map +0 -6
- package/dist/extractor/createEvaluator.js +0 -66
- package/dist/extractor/createEvaluator.js.map +0 -6
- package/dist/extractor/createExtractor.js +0 -1212
- package/dist/extractor/createExtractor.js.map +0 -6
- package/dist/extractor/createLogger.js +0 -32
- package/dist/extractor/createLogger.js.map +0 -6
- package/dist/extractor/ensureImportingConcat.js +0 -50
- package/dist/extractor/ensureImportingConcat.js.map +0 -6
- package/dist/extractor/errors.js +0 -22
- package/dist/extractor/errors.js.map +0 -6
- package/dist/extractor/esbuildAliasPlugin.js +0 -36
- package/dist/extractor/esbuildAliasPlugin.js.map +0 -6
- package/dist/extractor/esbuildTsconfigPaths.js +0 -79
- package/dist/extractor/esbuildTsconfigPaths.js.map +0 -6
- package/dist/extractor/evaluateAstNode.js +0 -99
- package/dist/extractor/evaluateAstNode.js.map +0 -6
- package/dist/extractor/extractHelpers.js +0 -108
- package/dist/extractor/extractHelpers.js.map +0 -6
- package/dist/extractor/extractMediaStyle.js +0 -123
- package/dist/extractor/extractMediaStyle.js.map +0 -6
- package/dist/extractor/extractToClassNames.js +0 -351
- package/dist/extractor/extractToClassNames.js.map +0 -6
- package/dist/extractor/extractToNative.js +0 -286
- package/dist/extractor/extractToNative.js.map +0 -6
- package/dist/extractor/findTopmostFunction.js +0 -32
- package/dist/extractor/findTopmostFunction.js.map +0 -6
- package/dist/extractor/generatedUid.js +0 -42
- package/dist/extractor/generatedUid.js.map +0 -6
- package/dist/extractor/getPrefixLogs.js +0 -24
- package/dist/extractor/getPrefixLogs.js.map +0 -6
- package/dist/extractor/getPropValueFromAttributes.js +0 -65
- package/dist/extractor/getPropValueFromAttributes.js.map +0 -6
- package/dist/extractor/getSourceModule.js +0 -62
- package/dist/extractor/getSourceModule.js.map +0 -6
- package/dist/extractor/getStaticBindingsForScope.js +0 -145
- package/dist/extractor/getStaticBindingsForScope.js.map +0 -6
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js +0 -32
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js.map +0 -6
- package/dist/extractor/hoistClassNames.js +0 -63
- package/dist/extractor/hoistClassNames.js.map +0 -6
- package/dist/extractor/literalToAst.js +0 -90
- package/dist/extractor/literalToAst.js.map +0 -6
- package/dist/extractor/loadFile.js +0 -14
- package/dist/extractor/loadFile.js.map +0 -6
- package/dist/extractor/loadTamagui.js +0 -306
- package/dist/extractor/loadTamagui.js.map +0 -6
- package/dist/extractor/logLines.js +0 -30
- package/dist/extractor/logLines.js.map +0 -6
- package/dist/extractor/normalizeTernaries.js +0 -61
- package/dist/extractor/normalizeTernaries.js.map +0 -6
- package/dist/extractor/propsToFontFamilyCache.js +0 -33
- package/dist/extractor/propsToFontFamilyCache.js.map +0 -6
- package/dist/extractor/regenerateConfig.js +0 -123
- package/dist/extractor/regenerateConfig.js.map +0 -6
- package/dist/extractor/removeUnusedHooks.js +0 -72
- package/dist/extractor/removeUnusedHooks.js.map +0 -6
- package/dist/extractor/timer.js +0 -38
- package/dist/extractor/timer.js.map +0 -6
- package/dist/extractor/validHTMLAttributes.js +0 -72
- package/dist/extractor/validHTMLAttributes.js.map +0 -6
- package/dist/extractor/watchTamaguiConfig.js +0 -57
- package/dist/extractor/watchTamaguiConfig.js.map +0 -6
- package/dist/getPragmaOptions.js +0 -50
- package/dist/getPragmaOptions.js.map +0 -6
- package/dist/helpers/memoize.js +0 -33
- package/dist/helpers/memoize.js.map +0 -6
- package/dist/helpers/requireTamaguiCore.js +0 -30
- package/dist/helpers/requireTamaguiCore.js.map +0 -6
- package/dist/index.js +0 -30
- package/dist/index.js.map +0 -6
- package/dist/registerRequire.js +0 -100
- package/dist/registerRequire.js.map +0 -6
- package/dist/server.js +0 -58
- package/dist/server.js.map +0 -6
- package/dist/setup.js +0 -1
- package/dist/setup.js.map +0 -6
- package/dist/types.js +0 -14
- package/dist/types.js.map +0 -6
- package/dist/worker.js +0 -72
- package/dist/worker.js.map +0 -6
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var loadTamagui_exports = {};
|
|
33
35
|
__export(loadTamagui_exports, {
|
|
34
36
|
esbuildWatchFiles: () => esbuildWatchFiles,
|
|
@@ -41,19 +43,18 @@ __export(loadTamagui_exports, {
|
|
|
41
43
|
resolveWebOrNativeSpecificEntry: () => resolveWebOrNativeSpecificEntry
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(loadTamagui_exports);
|
|
44
|
-
var import_node_path = require("node:path")
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
var import_node_path = require("node:path");
|
|
47
|
+
var import_cli_color = require("@tamagui/cli-color");
|
|
48
|
+
var import_esbuild = __toESM(require("esbuild"));
|
|
49
|
+
var esbuildWasm = __toESM(require("esbuild-wasm"));
|
|
50
|
+
var fsExtra = __toESM(require("fs-extra"));
|
|
51
|
+
var import_constants = require("../constants.cjs");
|
|
52
|
+
var import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs");
|
|
53
|
+
var import_registerRequire = require("../registerRequire.cjs");
|
|
54
|
+
var import_bundleConfig = require("./bundleConfig.cjs");
|
|
55
|
+
var import_getTamaguiConfigPathFromOptionsConfig = require("./getTamaguiConfigPathFromOptionsConfig.cjs");
|
|
56
|
+
var import_regenerateConfig = require("./regenerateConfig.cjs");
|
|
55
57
|
const getFilledOptions = propsIn => ({
|
|
56
|
-
// defaults
|
|
57
58
|
platform: "web",
|
|
58
59
|
config: "tamagui.config.ts",
|
|
59
60
|
components: ["tamagui"],
|
|
@@ -62,14 +63,20 @@ const getFilledOptions = propsIn => ({
|
|
|
62
63
|
let isLoadingPromise;
|
|
63
64
|
async function loadTamagui(propsIn) {
|
|
64
65
|
if (isLoadingPromise) return await isLoadingPromise;
|
|
65
|
-
let resolvePromise
|
|
66
|
+
let resolvePromise;
|
|
67
|
+
let rejectPromise;
|
|
66
68
|
isLoadingPromise = new Promise((res, rej) => {
|
|
67
|
-
resolvePromise = res
|
|
69
|
+
resolvePromise = res;
|
|
70
|
+
rejectPromise = rej;
|
|
68
71
|
});
|
|
69
72
|
try {
|
|
70
|
-
const props = getFilledOptions(propsIn)
|
|
71
|
-
|
|
72
|
-
if (!bundleInfo)
|
|
73
|
+
const props = getFilledOptions(propsIn);
|
|
74
|
+
const bundleInfo = await (0, import_bundleConfig.getBundledConfig)(props);
|
|
75
|
+
if (!bundleInfo) {
|
|
76
|
+
console.warn(`No bundled config generated, maybe an error in bundling. Set DEBUG=tamagui and re-run to get logs.`);
|
|
77
|
+
resolvePromise(null);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
73
80
|
await generateThemesAndLog(props);
|
|
74
81
|
const maybeTamaguiConfig = bundleInfo.tamaguiConfig;
|
|
75
82
|
if (maybeTamaguiConfig && !maybeTamaguiConfig.parsed) {
|
|
@@ -78,53 +85,71 @@ async function loadTamagui(propsIn) {
|
|
|
78
85
|
} = (0, import_requireTamaguiCore.requireTamaguiCore)(props.platform || "web");
|
|
79
86
|
bundleInfo.tamaguiConfig = createTamagui(bundleInfo.tamaguiConfig);
|
|
80
87
|
}
|
|
81
|
-
|
|
88
|
+
if (!(0, import_bundleConfig.hasBundledConfigChanged)()) {
|
|
89
|
+
resolvePromise(bundleInfo);
|
|
90
|
+
return bundleInfo;
|
|
91
|
+
}
|
|
92
|
+
await (0, import_regenerateConfig.regenerateConfig)(props, bundleInfo);
|
|
93
|
+
resolvePromise(bundleInfo);
|
|
94
|
+
return bundleInfo;
|
|
82
95
|
} catch (err) {
|
|
83
|
-
|
|
96
|
+
rejectPromise();
|
|
97
|
+
throw err;
|
|
84
98
|
} finally {
|
|
85
99
|
isLoadingPromise = null;
|
|
86
100
|
}
|
|
87
101
|
}
|
|
88
|
-
let waiting =
|
|
89
|
-
const generateThemesAndLog = async (options, force =
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
let waiting = false;
|
|
103
|
+
const generateThemesAndLog = async (options, force = false) => {
|
|
104
|
+
if (waiting) return;
|
|
105
|
+
if (!options.themeBuilder) return;
|
|
106
|
+
try {
|
|
107
|
+
waiting = true;
|
|
108
|
+
await new Promise(res => setTimeout(res, 30));
|
|
109
|
+
if (await (0, import_regenerateConfig.generateTamaguiThemes)(options, force)) {
|
|
110
|
+
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [tamagui] generated themes: ${(0, import_node_path.relative)(process.cwd(), options.themeBuilder.output)}`);
|
|
111
|
+
if (options.outputCSS) {
|
|
92
112
|
const loadedConfig = (0, import_bundleConfig.getLoadedConfig)();
|
|
93
|
-
loadedConfig
|
|
113
|
+
if (loadedConfig) await (0, import_bundleConfig.writeTamaguiCSS)(options.outputCSS, loadedConfig);
|
|
94
114
|
}
|
|
95
|
-
} finally {
|
|
96
|
-
waiting = !1;
|
|
97
115
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
} finally {
|
|
117
|
+
waiting = false;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const last = {};
|
|
121
|
+
const lastVersion = {};
|
|
122
|
+
let esbuildWasmInitialized = false;
|
|
102
123
|
async function loadTamaguiBuildConfigAsync(tamaguiOptions) {
|
|
103
|
-
const buildFilePath = tamaguiOptions?.buildFile ?? "./tamagui.build.ts"
|
|
104
|
-
|
|
124
|
+
const buildFilePath = tamaguiOptions?.buildFile ?? "./tamagui.build.ts";
|
|
125
|
+
const absolutePath = buildFilePath[0] === "." ? (0, import_node_path.join)(process.cwd(), buildFilePath) : buildFilePath;
|
|
105
126
|
if (fsExtra.existsSync(absolutePath)) try {
|
|
106
127
|
const source = await fsExtra.readFile(absolutePath, "utf-8");
|
|
107
|
-
|
|
128
|
+
if (!esbuildWasmInitialized) {
|
|
129
|
+
await esbuildWasm.initialize({});
|
|
130
|
+
esbuildWasmInitialized = true;
|
|
131
|
+
}
|
|
108
132
|
const result = await esbuildWasm.transform(source, {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
133
|
+
loader: "ts",
|
|
134
|
+
format: "cjs",
|
|
135
|
+
target: "node18",
|
|
136
|
+
sourcefile: absolutePath
|
|
137
|
+
});
|
|
138
|
+
const module2 = {
|
|
139
|
+
exports: {}
|
|
140
|
+
};
|
|
117
141
|
new Function("module", "exports", "require", "process", result.code)(module2, module2.exports, require, process);
|
|
118
142
|
const out = module2.exports.default || module2.exports;
|
|
119
|
-
if (!out || typeof out
|
|
143
|
+
if (!out || typeof out !== "object") throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
120
144
|
tamaguiOptions = {
|
|
121
145
|
...tamaguiOptions,
|
|
122
146
|
...out
|
|
123
147
|
};
|
|
124
148
|
} catch (err) {
|
|
125
|
-
|
|
149
|
+
console.error(`[tamagui] Error loading ${buildFilePath}:`, err);
|
|
150
|
+
throw err;
|
|
126
151
|
}
|
|
127
|
-
if (!tamaguiOptions) throw new Error(
|
|
152
|
+
if (!tamaguiOptions) throw new Error(`No tamagui build options found either via input props or at tamagui.build.ts`);
|
|
128
153
|
return {
|
|
129
154
|
config: "tamagui.config.ts",
|
|
130
155
|
components: ["tamagui", "@tamagui/core"],
|
|
@@ -146,7 +171,7 @@ function loadTamaguiBuildConfigSync(tamaguiOptions) {
|
|
|
146
171
|
registered.unregister();
|
|
147
172
|
}
|
|
148
173
|
}
|
|
149
|
-
if (!tamaguiOptions) throw new Error(
|
|
174
|
+
if (!tamaguiOptions) throw new Error(`No tamagui build options found either via input props or at tamagui.build.ts`);
|
|
150
175
|
return {
|
|
151
176
|
config: "tamagui.config.ts",
|
|
152
177
|
components: ["tamagui", "@tamagui/core"],
|
|
@@ -159,25 +184,29 @@ function loadTamaguiSync({
|
|
|
159
184
|
...propsIn
|
|
160
185
|
}) {
|
|
161
186
|
const key = JSON.stringify(propsIn);
|
|
162
|
-
if (last[key] && !(0, import_bundleConfig.hasBundledConfigChanged)()
|
|
187
|
+
if (last[key] && !(0, import_bundleConfig.hasBundledConfigChanged)()) {
|
|
188
|
+
if (!lastVersion[key] || lastVersion[key] === cacheKey) return last[key];
|
|
189
|
+
}
|
|
163
190
|
lastVersion[key] = cacheKey || "";
|
|
164
191
|
const props = getFilledOptions(propsIn);
|
|
165
|
-
process.env.IS_STATIC = "is_static"
|
|
192
|
+
process.env.IS_STATIC = "is_static";
|
|
193
|
+
process.env.TAMAGUI_IS_SERVER = "true";
|
|
166
194
|
const {
|
|
167
195
|
unregister
|
|
168
196
|
} = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
169
197
|
proxyWormImports: !!forceExports
|
|
170
198
|
});
|
|
171
199
|
try {
|
|
172
|
-
const devValueOG = globalThis
|
|
173
|
-
globalThis
|
|
200
|
+
const devValueOG = globalThis["__DEV__"];
|
|
201
|
+
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
174
202
|
try {
|
|
175
203
|
let tamaguiConfig = null;
|
|
176
204
|
if (propsIn.config) {
|
|
177
|
-
const configPath = (0, import_getTamaguiConfigPathFromOptionsConfig.getTamaguiConfigPathFromOptionsConfig)(propsIn.config)
|
|
178
|
-
|
|
179
|
-
if (!exp || exp._isProxyWorm) throw new Error(
|
|
180
|
-
|
|
205
|
+
const configPath = (0, import_getTamaguiConfigPathFromOptionsConfig.getTamaguiConfigPathFromOptionsConfig)(propsIn.config);
|
|
206
|
+
const exp = require(configPath);
|
|
207
|
+
if (!exp || exp._isProxyWorm) throw new Error(`Got a empty / proxied config!`);
|
|
208
|
+
tamaguiConfig = exp["default"] || exp["config"] || exp;
|
|
209
|
+
if (!tamaguiConfig || !tamaguiConfig.parsed) {
|
|
181
210
|
const confPath = require.resolve(configPath);
|
|
182
211
|
throw new Error(`Can't find valid config in ${confPath}:
|
|
183
212
|
|
|
@@ -190,9 +219,11 @@ function loadTamaguiSync({
|
|
|
190
219
|
createTamagui(tamaguiConfig);
|
|
191
220
|
}
|
|
192
221
|
}
|
|
193
|
-
const components = (0, import_bundleConfig.
|
|
194
|
-
if (!components) throw new Error(
|
|
195
|
-
process.env.DEBUG === "tamagui"
|
|
222
|
+
const components = (0, import_bundleConfig.loadComponentsSync)(props, forceExports);
|
|
223
|
+
if (!components) throw new Error(`No components loaded`);
|
|
224
|
+
if (process.env.DEBUG === "tamagui") console.info(`components`, components);
|
|
225
|
+
process.env.IS_STATIC = void 0;
|
|
226
|
+
globalThis["__DEV__"] = devValueOG;
|
|
196
227
|
const info = {
|
|
197
228
|
components,
|
|
198
229
|
tamaguiConfig,
|
|
@@ -202,18 +233,26 @@ function loadTamaguiSync({
|
|
|
202
233
|
const {
|
|
203
234
|
outputCSS
|
|
204
235
|
} = props;
|
|
205
|
-
outputCSS
|
|
236
|
+
if (outputCSS) (0, import_bundleConfig.writeTamaguiCSS)(outputCSS, tamaguiConfig);
|
|
237
|
+
(0, import_regenerateConfig.regenerateConfigSync)(props, info);
|
|
206
238
|
}
|
|
207
|
-
|
|
239
|
+
last[key] = {
|
|
208
240
|
...info,
|
|
209
|
-
cached:
|
|
210
|
-
}
|
|
241
|
+
cached: true
|
|
242
|
+
};
|
|
243
|
+
return info;
|
|
211
244
|
} catch (err) {
|
|
212
|
-
|
|
245
|
+
if (err instanceof Error) {
|
|
246
|
+
if (!import_constants.SHOULD_DEBUG && !forceExports) {
|
|
247
|
+
console.warn(`Error loading tamagui.config.ts (set DEBUG=tamagui to see full stack), running tamagui without custom config`);
|
|
248
|
+
console.info(`
|
|
213
249
|
|
|
214
250
|
${err.message}
|
|
215
251
|
|
|
216
|
-
`)
|
|
252
|
+
`);
|
|
253
|
+
} else if (import_constants.SHOULD_DEBUG) console.error(err);
|
|
254
|
+
} else console.error(`Error loading tamagui.config.ts`, err);
|
|
255
|
+
return {
|
|
217
256
|
components: [],
|
|
218
257
|
tamaguiConfig: null,
|
|
219
258
|
nameToPaths: {}
|
|
@@ -234,7 +273,7 @@ async function getOptions({
|
|
|
234
273
|
let pkgJson = {};
|
|
235
274
|
try {
|
|
236
275
|
pkgJson = await fsExtra.readJSON((0, import_node_path.join)(root, "package.json"));
|
|
237
|
-
} catch {}
|
|
276
|
+
} catch (err) {}
|
|
238
277
|
return {
|
|
239
278
|
mode: process.env.NODE_ENV === "production" ? "production" : "development",
|
|
240
279
|
root,
|
|
@@ -256,34 +295,39 @@ async function getOptions({
|
|
|
256
295
|
}
|
|
257
296
|
};
|
|
258
297
|
}
|
|
259
|
-
function resolveWebOrNativeSpecificEntry(entry) {
|
|
260
|
-
const workspaceRoot = (0, import_node_path.resolve)()
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
298
|
+
function resolveWebOrNativeSpecificEntry(entry, platform) {
|
|
299
|
+
const workspaceRoot = (0, import_node_path.resolve)();
|
|
300
|
+
const resolved = require.resolve(entry, {
|
|
301
|
+
paths: [workspaceRoot]
|
|
302
|
+
});
|
|
303
|
+
const ext = (0, import_node_path.extname)(resolved);
|
|
304
|
+
const fileName = (0, import_node_path.basename)(resolved).replace(ext, "");
|
|
305
|
+
const specificExt = (platform || "web") === "web" ? "web" : "native";
|
|
306
|
+
const specificFile = (0, import_node_path.join)((0, import_node_path.dirname)(resolved), fileName + "." + specificExt + ext);
|
|
307
|
+
if (fsExtra.existsSync(specificFile)) return specificFile;
|
|
308
|
+
return entry;
|
|
268
309
|
}
|
|
269
310
|
const defaultPaths = ["tamagui.config.ts", (0, import_node_path.join)("src", "tamagui.config.ts")];
|
|
270
|
-
let hasWarnedOnce =
|
|
311
|
+
let hasWarnedOnce = false;
|
|
271
312
|
async function getDefaultTamaguiConfigPath(root, configPath) {
|
|
272
313
|
const searchPaths = [...new Set([configPath, ...defaultPaths].filter(Boolean).map(p => (0, import_node_path.join)(root, p)))];
|
|
273
314
|
for (const path of searchPaths) if (await fsExtra.pathExists(path)) return path;
|
|
274
|
-
|
|
315
|
+
if (!hasWarnedOnce) {
|
|
316
|
+
hasWarnedOnce = true;
|
|
317
|
+
console.warn(`Warning: couldn't find tamagui.config.ts in the following paths given configuration "${configPath}":
|
|
275
318
|
${searchPaths.join(`
|
|
276
319
|
`)}
|
|
277
|
-
`)
|
|
320
|
+
`);
|
|
321
|
+
}
|
|
278
322
|
}
|
|
279
323
|
async function esbuildWatchFiles(entry, onChanged) {
|
|
280
|
-
let hasRunOnce =
|
|
324
|
+
let hasRunOnce = false;
|
|
281
325
|
const context = await import_esbuild.default.context({
|
|
282
|
-
bundle:
|
|
326
|
+
bundle: true,
|
|
283
327
|
entryPoints: [entry],
|
|
284
328
|
resolveExtensions: [".ts", ".tsx", ".js", ".mjs"],
|
|
285
329
|
logLevel: "silent",
|
|
286
|
-
write:
|
|
330
|
+
write: false,
|
|
287
331
|
alias: {
|
|
288
332
|
"@react-native/normalize-color": "@tamagui/proxy-worm",
|
|
289
333
|
"react-native-web": "@tamagui/react-native-web-lite",
|
|
@@ -300,7 +344,7 @@ async function esbuildWatchFiles(entry, onChanged) {
|
|
|
300
344
|
// },
|
|
301
345
|
// },
|
|
302
346
|
{
|
|
303
|
-
name:
|
|
347
|
+
name: `on-rebuild`,
|
|
304
348
|
setup({
|
|
305
349
|
onEnd,
|
|
306
350
|
onResolve
|
|
@@ -309,14 +353,16 @@ async function esbuildWatchFiles(entry, onChanged) {
|
|
|
309
353
|
filter: /^[^./]|^\.[^./]|^\.\.[^/]/
|
|
310
354
|
}, args => ({
|
|
311
355
|
path: args.path,
|
|
312
|
-
external:
|
|
313
|
-
}))
|
|
314
|
-
|
|
356
|
+
external: true
|
|
357
|
+
}));
|
|
358
|
+
onEnd(() => {
|
|
359
|
+
if (!hasRunOnce) hasRunOnce = true;else onChanged();
|
|
315
360
|
});
|
|
316
361
|
}
|
|
317
362
|
}]
|
|
318
363
|
});
|
|
319
|
-
|
|
364
|
+
context.watch();
|
|
365
|
+
return () => {
|
|
320
366
|
context.dispose();
|
|
321
367
|
};
|
|
322
368
|
}
|
|
@@ -3,33 +3,41 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var logLines_exports = {};
|
|
22
24
|
__export(logLines_exports, {
|
|
23
25
|
logLines: () => logLines
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(logLines_exports);
|
|
26
|
-
const prefix = " "
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const prefix = " ";
|
|
29
|
+
const logLines = (str, singleLine = false) => {
|
|
30
|
+
if (singleLine) {
|
|
31
|
+
return prefix + str.split(" ").join(`
|
|
29
32
|
${prefix}`);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
}
|
|
34
|
+
const lines = [""];
|
|
35
|
+
const items = str.split(" ");
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
if (item.length + lines[lines.length - 1].length > 85) {
|
|
38
|
+
lines.push("");
|
|
39
|
+
}
|
|
40
|
+
lines[lines.length - 1] += item + " ";
|
|
41
|
+
}
|
|
42
|
+
return lines.map((line, i) => prefix + (i == 0 ? "" : " ") + line.trim()).join("\n");
|
|
43
|
+
};
|
|
@@ -2,45 +2,50 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var normalizeTernaries_exports = {};
|
|
33
35
|
__export(normalizeTernaries_exports, {
|
|
34
36
|
normalizeTernaries: () => normalizeTernaries
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(normalizeTernaries_exports);
|
|
37
|
-
var import_generator = __toESM(require("@babel/generator"))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
var import_generator = __toESM(require("@babel/generator"));
|
|
40
|
+
var t = __toESM(require("@babel/types"));
|
|
41
|
+
var import_web = require("@tamagui/web");
|
|
42
|
+
var import_invariant = __toESM(require("invariant"));
|
|
43
|
+
var import_propsToFontFamilyCache = require("./propsToFontFamilyCache.cjs");
|
|
42
44
|
function normalizeTernaries(ternaries) {
|
|
43
|
-
|
|
45
|
+
(0, import_invariant.default)(Array.isArray(ternaries), "extractStaticTernaries expects param 1 to be an array of ternaries");
|
|
46
|
+
if (ternaries.length === 0) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
44
49
|
const ternariesByKey = {};
|
|
45
50
|
for (let idx = -1, len = ternaries.length; ++idx < len;) {
|
|
46
51
|
const {
|
|
@@ -51,23 +56,40 @@ function normalizeTernaries(ternaries) {
|
|
|
51
56
|
...rest
|
|
52
57
|
} = ternaries[idx];
|
|
53
58
|
let ternaryTest = test;
|
|
54
|
-
t.isExpressionStatement(test)
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
if (t.isExpressionStatement(test)) {
|
|
60
|
+
ternaryTest = test.expression;
|
|
61
|
+
}
|
|
62
|
+
let shouldSwap = false;
|
|
63
|
+
if (t.isUnaryExpression(test) && test.operator === "!") {
|
|
64
|
+
ternaryTest = test.argument;
|
|
65
|
+
shouldSwap = true;
|
|
66
|
+
} else if (t.isBinaryExpression(test)) {
|
|
67
|
+
if (test.operator === "!==" || test.operator === "!=") {
|
|
68
|
+
ternaryTest = t.binaryExpression(test.operator.replace("!", "="), test.left, test.right);
|
|
69
|
+
shouldSwap = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
57
72
|
const key = (0, import_generator.default)(ternaryTest).code;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
if (!ternariesByKey[key]) {
|
|
74
|
+
ternariesByKey[key] = {
|
|
75
|
+
...rest,
|
|
76
|
+
alternate: {},
|
|
77
|
+
consequent: {},
|
|
78
|
+
test: ternaryTest,
|
|
79
|
+
remove
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const altStyle = (shouldSwap ? consequent : alternate) ?? {};
|
|
83
|
+
const consStyle = (shouldSwap ? alternate : consequent) ?? {};
|
|
84
|
+
const nextAlt = ternariesByKey[key].alternate;
|
|
85
|
+
ternariesByKey[key].alternate = (0, import_web.mergeProps)(altStyle, nextAlt);
|
|
86
|
+
(0, import_propsToFontFamilyCache.forwardFontFamilyName)(altStyle, ternariesByKey[key].alternate);
|
|
69
87
|
const nextCons = ternariesByKey[key].consequent;
|
|
70
|
-
ternariesByKey[key].consequent = (0, import_web.mergeProps)(consStyle, nextCons)
|
|
88
|
+
ternariesByKey[key].consequent = (0, import_web.mergeProps)(consStyle, nextCons);
|
|
89
|
+
(0, import_propsToFontFamilyCache.forwardFontFamilyName)(consStyle, ternariesByKey[key].consequent);
|
|
71
90
|
}
|
|
72
|
-
|
|
91
|
+
const ternaryExpression = Object.keys(ternariesByKey).map(key => {
|
|
92
|
+
return ternariesByKey[key];
|
|
93
|
+
});
|
|
94
|
+
return ternaryExpression;
|
|
73
95
|
}
|
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var propsToFontFamilyCache_exports = {};
|
|
22
24
|
__export(propsToFontFamilyCache_exports, {
|
|
@@ -34,5 +36,7 @@ function getFontFamilyNameFromProps(props) {
|
|
|
34
36
|
}
|
|
35
37
|
function forwardFontFamilyName(prev, next, fallback) {
|
|
36
38
|
const ff = getFontFamilyNameFromProps(prev) || fallback;
|
|
37
|
-
|
|
39
|
+
if (ff) {
|
|
40
|
+
setPropsToFontFamily(next, ff);
|
|
41
|
+
}
|
|
38
42
|
}
|