@tamagui/static 1.115.1 → 1.115.3
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.js +389 -0
- package/dist/checkDeps.js +26 -0
- package/dist/{constants.cjs → constants.js} +14 -29
- package/dist/exports.js +33 -0
- package/dist/extractor/accessSafe.js +47 -0
- package/dist/extractor/babelParse.js +59 -0
- package/dist/extractor/buildClassName.js +72 -0
- package/dist/extractor/bundle.js +133 -0
- package/dist/extractor/bundleConfig.js +350 -0
- package/dist/extractor/{createEvaluator.cjs → createEvaluator.js} +21 -37
- package/dist/extractor/createExtractor.js +1217 -0
- package/dist/extractor/createLogger.js +32 -0
- package/dist/extractor/ensureImportingConcat.js +50 -0
- package/dist/extractor/esbuildAliasPlugin.js +36 -0
- package/dist/extractor/evaluateAstNode.js +99 -0
- package/dist/extractor/extractHelpers.js +109 -0
- package/dist/extractor/extractMediaStyle.js +123 -0
- package/dist/extractor/extractToClassNames.js +291 -0
- package/dist/extractor/extractToNative.js +319 -0
- package/dist/extractor/findTopmostFunction.js +32 -0
- package/dist/extractor/generatedUid.js +42 -0
- package/dist/extractor/getPrefixLogs.js +23 -0
- package/dist/extractor/getPropValueFromAttributes.js +65 -0
- package/dist/extractor/getSourceModule.js +66 -0
- package/dist/extractor/{getStaticBindingsForScope.cjs → getStaticBindingsForScope.js} +61 -66
- package/dist/extractor/{getTamaguiConfigPathFromOptionsConfig.cjs → getTamaguiConfigPathFromOptionsConfig.js} +11 -16
- package/dist/extractor/{hoistClassNames.cjs → hoistClassNames.js} +32 -31
- package/dist/extractor/{literalToAst.cjs → literalToAst.js} +44 -38
- package/dist/extractor/{loadFile.cjs → loadFile.js} +6 -3
- package/dist/extractor/{loadTamagui.cjs → loadTamagui.js} +78 -99
- package/dist/extractor/logLines.js +30 -0
- package/dist/extractor/{normalizeTernaries.cjs → normalizeTernaries.js} +29 -38
- package/dist/extractor/{propsToFontFamilyCache.cjs → propsToFontFamilyCache.js} +14 -18
- package/dist/extractor/regenerateConfig.js +111 -0
- package/dist/extractor/{removeUnusedHooks.cjs → removeUnusedHooks.js} +27 -31
- package/dist/extractor/{timer.cjs → timer.js} +11 -16
- package/dist/extractor/{validHTMLAttributes.cjs → validHTMLAttributes.js} +11 -16
- package/dist/extractor/{watchTamaguiConfig.cjs → watchTamaguiConfig.js} +29 -30
- package/dist/{getPragmaOptions.cjs → getPragmaOptions.js} +17 -22
- package/dist/helpers/memoize.js +33 -0
- package/dist/helpers/requireTamaguiCore.js +30 -0
- package/dist/index.js +30 -0
- package/dist/registerRequire.js +96 -0
- package/dist/{server.cjs → server.js} +21 -38
- package/dist/setup.js +1 -0
- package/dist/types.js +14 -0
- package/package.json +16 -16
- package/dist/check-dep-versions.cjs +0 -267
- package/dist/checkDeps.cjs +0 -32
- package/dist/exports.cjs +0 -40
- package/dist/extractor/accessSafe.cjs +0 -46
- package/dist/extractor/babelParse.cjs +0 -54
- package/dist/extractor/buildClassName.cjs +0 -62
- package/dist/extractor/bundle.cjs +0 -146
- package/dist/extractor/bundleConfig.cjs +0 -322
- package/dist/extractor/createExtractor.cjs +0 -1008
- package/dist/extractor/createLogger.cjs +0 -45
- package/dist/extractor/ensureImportingConcat.cjs +0 -48
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -44
- package/dist/extractor/evaluateAstNode.cjs +0 -83
- package/dist/extractor/extractHelpers.cjs +0 -120
- package/dist/extractor/extractMediaStyle.cjs +0 -129
- package/dist/extractor/extractToClassNames.cjs +0 -254
- package/dist/extractor/extractToNative.cjs +0 -274
- package/dist/extractor/findTopmostFunction.cjs +0 -34
- package/dist/extractor/generatedUid.cjs +0 -47
- package/dist/extractor/getPrefixLogs.cjs +0 -28
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -67
- package/dist/extractor/getSourceModule.cjs +0 -68
- package/dist/extractor/logLines.cjs +0 -35
- package/dist/extractor/regenerateConfig.cjs +0 -144
- package/dist/helpers/memoize.cjs +0 -37
- package/dist/helpers/requireTamaguiCore.cjs +0 -33
- package/dist/index.cjs +0 -40
- package/dist/registerRequire.cjs +0 -102
- package/dist/setup.cjs +0 -0
- package/dist/types.cjs +0 -16
- /package/dist/{check-dep-versions.cjs.map → check-dep-versions.js.map} +0 -0
- /package/dist/{checkDeps.cjs.map → checkDeps.js.map} +0 -0
- /package/dist/{constants.cjs.map → constants.js.map} +0 -0
- /package/dist/{exports.cjs.map → exports.js.map} +0 -0
- /package/dist/extractor/{accessSafe.cjs.map → accessSafe.js.map} +0 -0
- /package/dist/extractor/{babelParse.cjs.map → babelParse.js.map} +0 -0
- /package/dist/extractor/{buildClassName.cjs.map → buildClassName.js.map} +0 -0
- /package/dist/extractor/{bundle.cjs.map → bundle.js.map} +0 -0
- /package/dist/extractor/{bundleConfig.cjs.map → bundleConfig.js.map} +0 -0
- /package/dist/extractor/{createEvaluator.cjs.map → createEvaluator.js.map} +0 -0
- /package/dist/extractor/{createExtractor.cjs.map → createExtractor.js.map} +0 -0
- /package/dist/extractor/{createLogger.cjs.map → createLogger.js.map} +0 -0
- /package/dist/extractor/{ensureImportingConcat.cjs.map → ensureImportingConcat.js.map} +0 -0
- /package/dist/extractor/{esbuildAliasPlugin.cjs.map → esbuildAliasPlugin.js.map} +0 -0
- /package/dist/extractor/{evaluateAstNode.cjs.map → evaluateAstNode.js.map} +0 -0
- /package/dist/extractor/{extractHelpers.cjs.map → extractHelpers.js.map} +0 -0
- /package/dist/extractor/{extractMediaStyle.cjs.map → extractMediaStyle.js.map} +0 -0
- /package/dist/extractor/{extractToClassNames.cjs.map → extractToClassNames.js.map} +0 -0
- /package/dist/extractor/{extractToNative.cjs.map → extractToNative.js.map} +0 -0
- /package/dist/extractor/{findTopmostFunction.cjs.map → findTopmostFunction.js.map} +0 -0
- /package/dist/extractor/{generatedUid.cjs.map → generatedUid.js.map} +0 -0
- /package/dist/extractor/{getPrefixLogs.cjs.map → getPrefixLogs.js.map} +0 -0
- /package/dist/extractor/{getPropValueFromAttributes.cjs.map → getPropValueFromAttributes.js.map} +0 -0
- /package/dist/extractor/{getSourceModule.cjs.map → getSourceModule.js.map} +0 -0
- /package/dist/extractor/{getStaticBindingsForScope.cjs.map → getStaticBindingsForScope.js.map} +0 -0
- /package/dist/extractor/{getTamaguiConfigPathFromOptionsConfig.cjs.map → getTamaguiConfigPathFromOptionsConfig.js.map} +0 -0
- /package/dist/extractor/{hoistClassNames.cjs.map → hoistClassNames.js.map} +0 -0
- /package/dist/extractor/{literalToAst.cjs.map → literalToAst.js.map} +0 -0
- /package/dist/extractor/{loadFile.cjs.map → loadFile.js.map} +0 -0
- /package/dist/extractor/{loadTamagui.cjs.map → loadTamagui.js.map} +0 -0
- /package/dist/extractor/{logLines.cjs.map → logLines.js.map} +0 -0
- /package/dist/extractor/{normalizeTernaries.cjs.map → normalizeTernaries.js.map} +0 -0
- /package/dist/extractor/{propsToFontFamilyCache.cjs.map → propsToFontFamilyCache.js.map} +0 -0
- /package/dist/extractor/{regenerateConfig.cjs.map → regenerateConfig.js.map} +0 -0
- /package/dist/extractor/{removeUnusedHooks.cjs.map → removeUnusedHooks.js.map} +0 -0
- /package/dist/extractor/{timer.cjs.map → timer.js.map} +0 -0
- /package/dist/extractor/{validHTMLAttributes.cjs.map → validHTMLAttributes.js.map} +0 -0
- /package/dist/extractor/{watchTamaguiConfig.cjs.map → watchTamaguiConfig.js.map} +0 -0
- /package/dist/{getPragmaOptions.cjs.map → getPragmaOptions.js.map} +0 -0
- /package/dist/helpers/{memoize.cjs.map → memoize.js.map} +0 -0
- /package/dist/helpers/{requireTamaguiCore.cjs.map → requireTamaguiCore.js.map} +0 -0
- /package/dist/{index.cjs.map → index.js.map} +0 -0
- /package/dist/{registerRequire.cjs.map → registerRequire.js.map} +0 -0
- /package/dist/{server.cjs.map → server.js.map} +0 -0
- /package/dist/{setup.cjs.map → setup.js.map} +0 -0
- /package/dist/{types.cjs.map → types.js.map} +0 -0
@@ -1,146 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all) __defProp(target, name, {
|
9
|
-
get: all[name],
|
10
|
-
enumerable: !0
|
11
|
-
});
|
12
|
-
},
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
15
|
-
get: () => from[key],
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
17
|
-
});
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
26
|
-
value: mod,
|
27
|
-
enumerable: !0
|
28
|
-
}) : target, mod)),
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
30
|
-
value: !0
|
31
|
-
}), mod);
|
32
|
-
var bundle_exports = {};
|
33
|
-
__export(bundle_exports, {
|
34
|
-
esbuildIgnoreFilesRegex: () => esbuildIgnoreFilesRegex,
|
35
|
-
esbuildLoaderConfig: () => esbuildLoaderConfig,
|
36
|
-
esbundleTamaguiConfig: () => esbundleTamaguiConfig
|
37
|
-
});
|
38
|
-
module.exports = __toCommonJS(bundle_exports);
|
39
|
-
var import_node_path = require("node:path"),
|
40
|
-
import_esbuild = __toESM(require("esbuild")),
|
41
|
-
FS = __toESM(require("fs-extra")),
|
42
|
-
import_esbuildAliasPlugin = require("./esbuildAliasPlugin.cjs"),
|
43
|
-
import_loadTamagui = require("./loadTamagui.cjs");
|
44
|
-
const esbuildLoaderConfig = {
|
45
|
-
".js": "jsx",
|
46
|
-
".png": "dataurl",
|
47
|
-
".jpg": "dataurl",
|
48
|
-
".jpeg": "dataurl",
|
49
|
-
".svg": "dataurl",
|
50
|
-
".gif": "dataurl",
|
51
|
-
".webp": "dataurl",
|
52
|
-
".woff2": "dataurl",
|
53
|
-
".woff": "dataurl",
|
54
|
-
".eot": "dataurl",
|
55
|
-
".otf": "dataurl",
|
56
|
-
".ttf": "dataurl",
|
57
|
-
".mp4": "file",
|
58
|
-
".mpeg4": "file",
|
59
|
-
".mov": "file",
|
60
|
-
".avif": "file",
|
61
|
-
".wmv": "file",
|
62
|
-
".webm": "file",
|
63
|
-
".wav": "file",
|
64
|
-
".aac": "file",
|
65
|
-
".ogg": "file",
|
66
|
-
".flac": "file"
|
67
|
-
},
|
68
|
-
dataExtensions = Object.keys(esbuildLoaderConfig).filter(k => esbuildLoaderConfig[k] === "file" || esbuildLoaderConfig[k] === "dataurl").map(k => k.slice(1)),
|
69
|
-
esbuildIgnoreFilesRegex = new RegExp(`.(${dataExtensions.join("|")})$`, "i");
|
70
|
-
function getESBuildConfig({
|
71
|
-
entryPoints,
|
72
|
-
resolvePlatformSpecificEntries,
|
73
|
-
...options
|
74
|
-
}, platform, aliases) {
|
75
|
-
return process.env.DEBUG?.startsWith("tamagui") && console.info("Building", entryPoints), {
|
76
|
-
bundle: !0,
|
77
|
-
entryPoints: resolvePlatformSpecificEntries ? entryPoints.map(import_loadTamagui.resolveWebOrNativeSpecificEntry) : entryPoints,
|
78
|
-
format: "cjs",
|
79
|
-
target: "node16",
|
80
|
-
jsx: "transform",
|
81
|
-
jsxFactory: "react",
|
82
|
-
allowOverwrite: !0,
|
83
|
-
keepNames: !0,
|
84
|
-
resolveExtensions: [".web.tsx", ".web.ts", ".web.jsx", ".web.js", ".tsx", ".ts", ".jsx", ".js"],
|
85
|
-
platform: "node",
|
86
|
-
tsconfigRaw: {
|
87
|
-
compilerOptions: {
|
88
|
-
jsx: "react-jsx"
|
89
|
-
}
|
90
|
-
},
|
91
|
-
loader: esbuildLoaderConfig,
|
92
|
-
logLevel: "warning",
|
93
|
-
plugins: [{
|
94
|
-
name: "external",
|
95
|
-
setup(build) {
|
96
|
-
build.onResolve({
|
97
|
-
filter: /@tamagui\/core/
|
98
|
-
}, args => ({
|
99
|
-
path: platform === "native" ? "@tamagui/core/native" : "@tamagui/core",
|
100
|
-
external: !0
|
101
|
-
})), build.onResolve({
|
102
|
-
filter: /react-native\/package.json$/
|
103
|
-
}, args => ({
|
104
|
-
path: "react-native/package.json",
|
105
|
-
external: !0
|
106
|
-
})), build.onResolve({
|
107
|
-
filter: /@tamagui\/web/
|
108
|
-
}, args => ({
|
109
|
-
path: platform === "native" ? "@tamagui/core/native" : "@tamagui/core",
|
110
|
-
external: !0
|
111
|
-
})), build.onResolve({
|
112
|
-
filter: /^(react-native|react-native\/.*)$/
|
113
|
-
}, args => ({
|
114
|
-
path: "@tamagui/react-native-web-lite",
|
115
|
-
external: !0
|
116
|
-
})), build.onResolve({
|
117
|
-
filter: /react-native-reanimated/
|
118
|
-
}, args => ({
|
119
|
-
path: "react-native-reanimated",
|
120
|
-
external: !0
|
121
|
-
}));
|
122
|
-
}
|
123
|
-
}, (0, import_esbuildAliasPlugin.esbuildAliasPlugin)({
|
124
|
-
...aliases
|
125
|
-
})],
|
126
|
-
...options
|
127
|
-
};
|
128
|
-
}
|
129
|
-
async function esbundleTamaguiConfig(props, platform, aliases) {
|
130
|
-
await asyncLock(props);
|
131
|
-
const config = getESBuildConfig(props, platform, aliases);
|
132
|
-
return await import_esbuild.default.build(config);
|
133
|
-
}
|
134
|
-
async function asyncLock(props) {
|
135
|
-
const lockFile = (0, import_node_path.join)((0, import_node_path.dirname)(props.outfile), (0, import_node_path.basename)(props.outfile, ".lock")),
|
136
|
-
lockStat = await FS.stat(lockFile).catch(() => {});
|
137
|
-
if ((lockStat ? (/* @__PURE__ */new Date()).getTime() - new Date(lockStat.mtime).getTime() : Number.POSITIVE_INFINITY) < 500) {
|
138
|
-
process.env.DEBUG?.startsWith("tamagui") && console.info("Waiting for existing build", props.entryPoints);
|
139
|
-
let tries = 5;
|
140
|
-
for (; tries--;) {
|
141
|
-
if (await FS.pathExists(props.outfile)) return;
|
142
|
-
await new Promise(res => setTimeout(res, 50));
|
143
|
-
}
|
144
|
-
}
|
145
|
-
FS.writeFile(lockFile, "");
|
146
|
-
}
|
@@ -1,322 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all) __defProp(target, name, {
|
9
|
-
get: all[name],
|
10
|
-
enumerable: !0
|
11
|
-
});
|
12
|
-
},
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
15
|
-
get: () => from[key],
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
17
|
-
});
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
26
|
-
value: mod,
|
27
|
-
enumerable: !0
|
28
|
-
}) : target, mod)),
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
30
|
-
value: !0
|
31
|
-
}), mod);
|
32
|
-
var bundleConfig_exports = {};
|
33
|
-
__export(bundleConfig_exports, {
|
34
|
-
bundleConfig: () => bundleConfig,
|
35
|
-
esbuildOptions: () => esbuildOptions,
|
36
|
-
getBundledConfig: () => getBundledConfig,
|
37
|
-
getLoadedConfig: () => getLoadedConfig,
|
38
|
-
hasBundledConfigChanged: () => hasBundledConfigChanged,
|
39
|
-
loadComponents: () => loadComponents,
|
40
|
-
loadComponentsInner: () => loadComponentsInner,
|
41
|
-
writeTamaguiCSS: () => writeTamaguiCSS
|
42
|
-
});
|
43
|
-
module.exports = __toCommonJS(bundleConfig_exports);
|
44
|
-
var import_generator = __toESM(require("@babel/generator")),
|
45
|
-
import_traverse = __toESM(require("@babel/traverse")),
|
46
|
-
t = __toESM(require("@babel/types")),
|
47
|
-
import_node_fs = require("node:fs"),
|
48
|
-
import_node_path = require("node:path"),
|
49
|
-
import_cli_color = require("@tamagui/cli-color"),
|
50
|
-
import_esbuild = __toESM(require("esbuild")),
|
51
|
-
FS = __toESM(require("fs-extra")),
|
52
|
-
import_promises = require("node:fs/promises"),
|
53
|
-
import_registerRequire = require("../registerRequire.cjs"),
|
54
|
-
import_babelParse = require("./babelParse.cjs"),
|
55
|
-
import_bundle = require("./bundle.cjs"),
|
56
|
-
import_getTamaguiConfigPathFromOptionsConfig = require("./getTamaguiConfigPathFromOptionsConfig.cjs");
|
57
|
-
const external = ["@tamagui/core", "@tamagui/web", "react", "react-dom", "react-native-svg"],
|
58
|
-
esbuildExtraOptions = {
|
59
|
-
define: {
|
60
|
-
__DEV__: `${process.env.NODE_ENV === "development"}`
|
61
|
-
}
|
62
|
-
},
|
63
|
-
esbuildOptions = {
|
64
|
-
target: "es2018",
|
65
|
-
format: "cjs",
|
66
|
-
jsx: "automatic",
|
67
|
-
platform: "node",
|
68
|
-
...esbuildExtraOptions
|
69
|
-
};
|
70
|
-
let currentBundle = null,
|
71
|
-
isBundling = !1,
|
72
|
-
lastBundle = null;
|
73
|
-
const waitForBundle = /* @__PURE__ */new Set();
|
74
|
-
function hasBundledConfigChanged() {
|
75
|
-
return lastBundle === currentBundle ? !1 : (lastBundle = currentBundle, !0);
|
76
|
-
}
|
77
|
-
let loadedConfig = null;
|
78
|
-
const getLoadedConfig = () => loadedConfig;
|
79
|
-
async function getBundledConfig(props, rebuild = !1) {
|
80
|
-
if (isBundling) await new Promise(res => {
|
81
|
-
waitForBundle.add(res);
|
82
|
-
});else if (!currentBundle || rebuild) return await bundleConfig(props);
|
83
|
-
return currentBundle;
|
84
|
-
}
|
85
|
-
global.tamaguiLastLoaded ||= 0;
|
86
|
-
function updateLastLoaded(config) {
|
87
|
-
global.tamaguiLastLoaded = Date.now(), global.tamaguiLastBundledConfig = config;
|
88
|
-
}
|
89
|
-
let hasBundledOnce = !1;
|
90
|
-
async function bundleConfig(props) {
|
91
|
-
if (global.tamaguiLastBundledConfig && Date.now() - global.tamaguiLastLoaded < 3e3) return global.tamaguiLastBundledConfig;
|
92
|
-
try {
|
93
|
-
isBundling = !0;
|
94
|
-
const configEntry = props.config ? (0, import_getTamaguiConfigPathFromOptionsConfig.getTamaguiConfigPathFromOptionsConfig)(props.config) : "",
|
95
|
-
tmpDir = (0, import_node_path.join)(process.cwd(), ".tamagui"),
|
96
|
-
configOutPath = (0, import_node_path.join)(tmpDir, "tamagui.config.cjs"),
|
97
|
-
baseComponents = (props.components || []).filter(x => x !== "@tamagui/core"),
|
98
|
-
componentOutPaths = baseComponents.map(componentModule => (0, import_node_path.join)(tmpDir, `${componentModule.split(import_node_path.sep).join("-").replace(/[^a-z0-9]+/gi, "")}-components.config.cjs`));
|
99
|
-
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("tamagui") && console.info("Building config entry", configEntry), !props.disableInitialBuild) {
|
100
|
-
try {
|
101
|
-
await FS.ensureDir(tmpDir);
|
102
|
-
} catch {}
|
103
|
-
const start = Date.now();
|
104
|
-
await Promise.all([props.config ? (0, import_bundle.esbundleTamaguiConfig)({
|
105
|
-
entryPoints: [configEntry],
|
106
|
-
external,
|
107
|
-
outfile: configOutPath,
|
108
|
-
target: "node16",
|
109
|
-
...esbuildExtraOptions
|
110
|
-
}, props.platform || "web") : null, ...baseComponents.map((componentModule, i) => (0, import_bundle.esbundleTamaguiConfig)({
|
111
|
-
entryPoints: [componentModule],
|
112
|
-
resolvePlatformSpecificEntries: !0,
|
113
|
-
external,
|
114
|
-
outfile: componentOutPaths[i],
|
115
|
-
target: "node16",
|
116
|
-
...esbuildExtraOptions
|
117
|
-
}, props.platform || "web"))]), (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `
|
118
|
-
\u27A1 [tamagui] built config and components (${Date.now() - start}ms)`), process.env.DEBUG?.startsWith("tamagui") && (0, import_cli_color.colorLog)(import_cli_color.Color.Dim, `
|
119
|
-
Config .${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), configOutPath)}
|
120
|
-
Components ${[...componentOutPaths.map(p => `.${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), p)}`)].join(`
|
121
|
-
`)}
|
122
|
-
`);
|
123
|
-
}
|
124
|
-
let out;
|
125
|
-
const {
|
126
|
-
unregister
|
127
|
-
} = (0, import_registerRequire.registerRequire)(props.platform || "web");
|
128
|
-
try {
|
129
|
-
if (hasBundledOnce) for (const key in require.cache) /(core|web)[\/\\]dist/.test(key) || delete require.cache[key];else hasBundledOnce = !0;
|
130
|
-
out = require(configOutPath);
|
131
|
-
} catch (err) {
|
132
|
-
throw err;
|
133
|
-
} finally {
|
134
|
-
unregister();
|
135
|
-
}
|
136
|
-
let config = out.default || out || out.config;
|
137
|
-
if (config && config.config && !config.tokens && (config = config.config), !config) throw new Error(`No config: ${config}`);
|
138
|
-
loadedConfig = config, props.outputCSS && (await writeTamaguiCSS(props.outputCSS, config));
|
139
|
-
let components = loadComponents({
|
140
|
-
...props,
|
141
|
-
components: componentOutPaths
|
142
|
-
});
|
143
|
-
if (!components) throw new Error(`No components found: ${componentOutPaths.join(", ")}`);
|
144
|
-
for (const component of components) component.moduleName = baseComponents[componentOutPaths.indexOf(component.moduleName)] || component.moduleName, component.moduleName || (process.env.DEBUG?.includes("tamagui") || process.env.IS_TAMAGUI_DEV) && console.warn(`\u26A0\uFE0F no module name found: ${component.moduleName} ${JSON.stringify(baseComponents)} in ${JSON.stringify(componentOutPaths)}`);
|
145
|
-
process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("tamagui") && console.info("Loaded components", components);
|
146
|
-
const res = {
|
147
|
-
components,
|
148
|
-
nameToPaths: {},
|
149
|
-
tamaguiConfig: config
|
150
|
-
};
|
151
|
-
return currentBundle = res, updateLastLoaded(res), res;
|
152
|
-
} catch (err) {
|
153
|
-
console.error(`Error bundling tamagui config: ${err?.message} (run with DEBUG=tamagui to see stack)`), process.env.DEBUG?.includes("tamagui") && console.error(err.stack);
|
154
|
-
} finally {
|
155
|
-
isBundling = !1, waitForBundle.forEach(cb => cb()), waitForBundle.clear();
|
156
|
-
}
|
157
|
-
}
|
158
|
-
async function writeTamaguiCSS(outputCSS, config) {
|
159
|
-
const flush = async () => {
|
160
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [tamagui] output css: ${outputCSS}`), await FS.writeFile(outputCSS, css);
|
161
|
-
},
|
162
|
-
css = config.getCSS();
|
163
|
-
try {
|
164
|
-
(0, import_node_fs.existsSync)(outputCSS) && (await (0, import_promises.readFile)(outputCSS, "utf8")) === css || (await flush());
|
165
|
-
} catch (err) {
|
166
|
-
console.info("Error writing themes", err);
|
167
|
-
}
|
168
|
-
}
|
169
|
-
function loadComponents(props, forceExports = !1) {
|
170
|
-
const coreComponents = getCoreComponents(props),
|
171
|
-
otherComponents = loadComponentsInner(props, forceExports);
|
172
|
-
return [...coreComponents, ...(otherComponents || [])];
|
173
|
-
}
|
174
|
-
function getCoreComponents(props) {
|
175
|
-
const loaded = loadComponentsInner({
|
176
|
-
...props,
|
177
|
-
components: ["@tamagui/core"]
|
178
|
-
});
|
179
|
-
if (!loaded) throw new Error("Core should always load");
|
180
|
-
return [{
|
181
|
-
...loaded[0],
|
182
|
-
moduleName: "@tamagui/core"
|
183
|
-
}];
|
184
|
-
}
|
185
|
-
function loadComponentsInner(props, forceExports = !1) {
|
186
|
-
const componentsModules = props.components || [],
|
187
|
-
key = componentsModules.join("");
|
188
|
-
if (!forceExports && cacheComponents[key]) return cacheComponents[key];
|
189
|
-
const {
|
190
|
-
unregister
|
191
|
-
} = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
192
|
-
proxyWormImports: forceExports
|
193
|
-
});
|
194
|
-
try {
|
195
|
-
const info = componentsModules.flatMap(name => {
|
196
|
-
const isDynamic = !!(0, import_node_path.extname)(name) && forceExports,
|
197
|
-
fileContents = isDynamic ? (0, import_node_fs.readFileSync)(name, "utf-8") : "",
|
198
|
-
loadModule = isDynamic ? (0, import_node_path.join)((0, import_node_path.dirname)(name), `.tamagui-dynamic-eval-${(0, import_node_path.basename)(name)}.tsx`) : name;
|
199
|
-
let writtenContents = fileContents,
|
200
|
-
didBabel = !1;
|
201
|
-
function attemptLoad({
|
202
|
-
forceExports: forceExports2 = !1
|
203
|
-
} = {}) {
|
204
|
-
isDynamic && (writtenContents = forceExports2 ? transformAddExports((0, import_babelParse.babelParse)(esbuildit(fileContents, "modern"), name)) : fileContents, FS.writeFileSync(loadModule, writtenContents), import_esbuild.default.buildSync({
|
205
|
-
...esbuildOptions,
|
206
|
-
entryPoints: [loadModule],
|
207
|
-
outfile: loadModule,
|
208
|
-
alias: {
|
209
|
-
"react-native": require.resolve("@tamagui/react-native-web-lite")
|
210
|
-
},
|
211
|
-
bundle: !0,
|
212
|
-
packages: "external",
|
213
|
-
allowOverwrite: !0,
|
214
|
-
// logLevel: 'silent',
|
215
|
-
sourcemap: !1,
|
216
|
-
loader: import_bundle.esbuildLoaderConfig
|
217
|
-
})), process.env.DEBUG === "tamagui" && console.info("loadModule", loadModule, require.resolve(loadModule));
|
218
|
-
const moduleResult = require(loadModule);
|
219
|
-
forceExports2 || (0, import_registerRequire.setRequireResult)(name, moduleResult);
|
220
|
-
const nameToInfo = getComponentStaticConfigByName(name, interopDefaultExport(moduleResult));
|
221
|
-
return {
|
222
|
-
moduleName: name,
|
223
|
-
nameToInfo
|
224
|
-
};
|
225
|
-
}
|
226
|
-
const dispose = () => {
|
227
|
-
isDynamic && FS.removeSync(loadModule);
|
228
|
-
};
|
229
|
-
try {
|
230
|
-
const res = attemptLoad({
|
231
|
-
forceExports: !0
|
232
|
-
});
|
233
|
-
return didBabel = !0, res;
|
234
|
-
} catch (err) {
|
235
|
-
console.info("babel err", err, writtenContents), writtenContents = fileContents, process.env.DEBUG?.startsWith("tamagui") && console.info("Error parsing babel likely", err);
|
236
|
-
} finally {
|
237
|
-
dispose();
|
238
|
-
}
|
239
|
-
try {
|
240
|
-
return attemptLoad({
|
241
|
-
forceExports: !1
|
242
|
-
});
|
243
|
-
} catch (err) {
|
244
|
-
return process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD && (console.info(`
|
245
|
-
|
246
|
-
Tamagui attempted but failed to dynamically optimize components in:
|
247
|
-
${name}
|
248
|
-
`), console.info(err), console.info(`At: ${loadModule}`, `
|
249
|
-
didBabel: ${didBabel}`, `
|
250
|
-
In:`, writtenContents, `
|
251
|
-
isDynamic: `, isDynamic)), [];
|
252
|
-
} finally {
|
253
|
-
dispose();
|
254
|
-
}
|
255
|
-
});
|
256
|
-
return cacheComponents[key] = info, info;
|
257
|
-
} catch (err) {
|
258
|
-
return console.info("Tamagui error bundling components", err.message, err.stack), null;
|
259
|
-
} finally {
|
260
|
-
unregister();
|
261
|
-
}
|
262
|
-
}
|
263
|
-
const esbuildit = (src, target) => import_esbuild.default.transformSync(src, {
|
264
|
-
...esbuildOptions,
|
265
|
-
...(target === "modern" && {
|
266
|
-
target: "es2022",
|
267
|
-
jsx: "automatic",
|
268
|
-
loader: "tsx",
|
269
|
-
platform: "neutral",
|
270
|
-
format: "esm"
|
271
|
-
})
|
272
|
-
}).code;
|
273
|
-
function getComponentStaticConfigByName(name, exported) {
|
274
|
-
const components = {};
|
275
|
-
try {
|
276
|
-
if (!exported || typeof exported != "object" || Array.isArray(exported)) throw new Error(`Invalid export from package ${name}: ${typeof exported}`);
|
277
|
-
for (const key in exported) {
|
278
|
-
const found = getTamaguiComponent(key, exported[key]);
|
279
|
-
if (found) {
|
280
|
-
const {
|
281
|
-
Component,
|
282
|
-
...sc
|
283
|
-
} = found.staticConfig;
|
284
|
-
components[key] = {
|
285
|
-
staticConfig: sc
|
286
|
-
};
|
287
|
-
}
|
288
|
-
}
|
289
|
-
} catch (err) {
|
290
|
-
process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD && (console.error(`Tamagui failed getting components from ${name} (Disable error by setting environment variable TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD=1)`), console.error(err));
|
291
|
-
}
|
292
|
-
return components;
|
293
|
-
}
|
294
|
-
function getTamaguiComponent(name, Component) {
|
295
|
-
if (name[0].toUpperCase() !== name[0]) return;
|
296
|
-
if (Component?.staticConfig) return Component;
|
297
|
-
}
|
298
|
-
function interopDefaultExport(mod) {
|
299
|
-
return mod?.default ?? mod;
|
300
|
-
}
|
301
|
-
const cacheComponents = {};
|
302
|
-
function transformAddExports(ast) {
|
303
|
-
const usedNames = /* @__PURE__ */new Set();
|
304
|
-
return (0, import_traverse.default)(ast, {
|
305
|
-
ExportNamedDeclaration(nodePath) {
|
306
|
-
if (nodePath.node.specifiers) for (const spec of nodePath.node.specifiers) usedNames.add(t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value);
|
307
|
-
}
|
308
|
-
}), (0, import_traverse.default)(ast, {
|
309
|
-
VariableDeclaration(nodePath) {
|
310
|
-
if (!t.isProgram(nodePath.parent)) return;
|
311
|
-
const decs = nodePath.node.declarations;
|
312
|
-
if (decs.length > 1) return;
|
313
|
-
const [dec] = decs;
|
314
|
-
t.isIdentifier(dec.id) && dec.init && (usedNames.has(dec.id.name) || (usedNames.add(dec.id.name), nodePath.replaceWith(t.exportNamedDeclaration(t.variableDeclaration("let", [dec]), [t.exportSpecifier(t.identifier(dec.id.name), t.identifier(dec.id.name))]))));
|
315
|
-
}
|
316
|
-
}), (0, import_generator.default)(ast, {
|
317
|
-
concise: !1,
|
318
|
-
filename: "test.tsx",
|
319
|
-
retainLines: !1,
|
320
|
-
sourceMaps: !1
|
321
|
-
}).code;
|
322
|
-
}
|