Package not found. Please check the package name and try again.
@tamagui/static 2.7.7 → 3.0.0-beta.643.1
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/check-dep-versions.cjs +355 -0
- package/dist/cjs/checkDeps.cjs +302 -0
- package/dist/cjs/compiler.cjs +286 -0
- package/dist/cjs/compilerHost.cjs +1695 -0
- package/dist/cjs/constants.cjs +33 -0
- package/dist/cjs/domStructuralPass.cjs +112 -0
- package/dist/cjs/exports.cjs +42 -0
- package/dist/cjs/extractor/addLocalExports.cjs +64 -0
- package/dist/cjs/extractor/bundle.cjs +203 -0
- package/dist/cjs/extractor/bundleConfig.cjs +747 -0
- package/dist/cjs/extractor/concatClassName.cjs +117 -0
- package/dist/cjs/extractor/detectModuleFormat.cjs +54 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.cjs +47 -0
- package/dist/cjs/extractor/esbuildTsconfigPaths.cjs +92 -0
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +38 -0
- package/dist/cjs/extractor/loadTamagui.cjs +344 -0
- package/dist/cjs/extractor/regenerateConfig.cjs +161 -0
- package/dist/cjs/extractor/watchTamaguiConfig.cjs +64 -0
- package/dist/cjs/getPragmaOptions.cjs +67 -0
- package/dist/cjs/helpers/memoize.cjs +42 -0
- package/dist/cjs/helpers/requireTamaguiCore.cjs +40 -0
- package/dist/cjs/index.cjs +34 -0
- package/dist/cjs/registerRequire.cjs +220 -0
- package/dist/cjs/server.cjs +66 -0
- package/dist/cjs/staticEvaluationIgnoredModules.cjs +86 -0
- package/dist/cjs/types.cjs +17 -0
- package/dist/cjs/zero/artifact.cjs +145 -0
- package/dist/cjs/zero/graph.cjs +209 -0
- package/dist/cjs/zero/identity.cjs +61 -0
- package/dist/cjs/zero/index.cjs +26 -0
- package/dist/cjs/zero/islands.cjs +232 -0
- package/dist/cjs/zero/options.cjs +163 -0
- package/dist/cjs/zero/ownership.cjs +79 -0
- package/dist/cjs/zero/theme.cjs +328 -0
- package/dist/cjs/zero/transform.cjs +203 -0
- package/dist/esm/check-dep-versions.mjs +329 -0
- package/dist/esm/check-dep-versions.mjs.map +1 -0
- package/dist/esm/checkDeps.mjs +279 -0
- package/dist/esm/checkDeps.mjs.map +1 -0
- package/dist/esm/compiler.mjs +255 -0
- package/dist/esm/compiler.mjs.map +1 -0
- package/dist/esm/compilerHost.mjs +1675 -0
- package/dist/esm/compilerHost.mjs.map +1 -0
- package/dist/esm/constants.mjs +7 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/domStructuralPass.mjs +92 -0
- package/dist/esm/domStructuralPass.mjs.map +1 -0
- package/dist/esm/exports.mjs +26 -0
- package/dist/esm/extractor/addLocalExports.mjs +44 -0
- package/dist/esm/extractor/addLocalExports.mjs.map +1 -0
- package/dist/esm/extractor/bundle.mjs +173 -0
- package/dist/esm/extractor/bundle.mjs.map +1 -0
- package/dist/esm/extractor/bundleConfig.mjs +706 -0
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -0
- package/dist/esm/extractor/concatClassName.mjs +96 -0
- package/dist/esm/extractor/concatClassName.mjs.map +1 -0
- package/dist/esm/extractor/detectModuleFormat.mjs +31 -0
- package/dist/esm/extractor/detectModuleFormat.mjs.map +1 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs +26 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs.map +1 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs +63 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs.map +1 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs +18 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs.map +1 -0
- package/dist/esm/extractor/loadTamagui.mjs +306 -0
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -0
- package/dist/esm/extractor/regenerateConfig.mjs +131 -0
- package/dist/esm/extractor/regenerateConfig.mjs.map +1 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs +43 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs.map +1 -0
- package/dist/esm/getPragmaOptions.mjs +46 -0
- package/dist/esm/getPragmaOptions.mjs.map +1 -0
- package/dist/esm/helpers/memoize.mjs +21 -0
- package/dist/esm/helpers/memoize.mjs.map +1 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs +19 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs.map +1 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/registerRequire.mjs +195 -0
- package/dist/esm/registerRequire.mjs.map +1 -0
- package/dist/esm/server.mjs +40 -0
- package/dist/esm/server.mjs.map +1 -0
- package/dist/esm/setup.mjs +0 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs +61 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/zero/artifact.mjs +119 -0
- package/dist/esm/zero/artifact.mjs.map +1 -0
- package/dist/esm/zero/graph.mjs +170 -0
- package/dist/esm/zero/graph.mjs.map +1 -0
- package/dist/esm/zero/identity.mjs +36 -0
- package/dist/esm/zero/identity.mjs.map +1 -0
- package/dist/esm/zero/index.mjs +15 -0
- package/dist/esm/zero/islands.mjs +197 -0
- package/dist/esm/zero/islands.mjs.map +1 -0
- package/dist/esm/zero/options.mjs +129 -0
- package/dist/esm/zero/options.mjs.map +1 -0
- package/dist/esm/zero/ownership.mjs +48 -0
- package/dist/esm/zero/ownership.mjs.map +1 -0
- package/dist/esm/zero/theme.mjs +303 -0
- package/dist/esm/zero/theme.mjs.map +1 -0
- package/dist/esm/zero/transform.mjs +177 -0
- package/dist/esm/zero/transform.mjs.map +1 -0
- package/package.json +33 -43
- package/src/check-dep-versions.ts +2 -2
- package/src/checkDeps.ts +3 -2
- package/src/compiler.ts +425 -0
- package/src/compilerHost.ts +3125 -0
- package/src/constants.ts +0 -5
- package/src/domStructuralPass.ts +170 -0
- package/src/exports.ts +3 -6
- package/src/extractor/addLocalExports.ts +49 -0
- package/src/extractor/bundle.ts +20 -35
- package/src/extractor/bundleConfig.ts +334 -187
- package/src/extractor/concatClassName.ts +13 -20
- package/src/extractor/getTamaguiConfigPathFromOptionsConfig.ts +5 -4
- package/src/extractor/loadTamagui.ts +196 -143
- package/src/extractor/regenerateConfig.ts +65 -13
- package/src/extractor/watchTamaguiConfig.ts +6 -1
- package/src/helpers/requireTamaguiCore.ts +6 -1
- package/src/registerRequire.ts +94 -132
- package/src/staticEvaluationIgnoredModules.ts +74 -0
- package/src/types.ts +2 -107
- package/src/zero/artifact.ts +142 -0
- package/src/zero/graph.ts +359 -0
- package/src/zero/identity.ts +73 -0
- package/src/zero/index.ts +8 -0
- package/src/zero/islands.ts +262 -0
- package/src/zero/options.ts +239 -0
- package/src/zero/ownership.ts +113 -0
- package/src/zero/theme.ts +478 -0
- package/src/zero/transform.ts +320 -0
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/compiler.d.ts +117 -0
- package/types/compiler.d.ts.map +1 -0
- package/types/compilerHost.d.ts +25 -0
- package/types/compilerHost.d.ts.map +1 -0
- package/types/constants.d.ts +0 -1
- package/types/constants.d.ts.map +1 -1
- package/types/domStructuralPass.d.ts +3 -0
- package/types/domStructuralPass.d.ts.map +1 -0
- package/types/exports.d.ts +3 -6
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/addLocalExports.d.ts +3 -0
- package/types/extractor/addLocalExports.d.ts.map +1 -0
- package/types/extractor/bundle.d.ts +66 -65
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +19 -4
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/esbuildAliasPlugin.d.ts.map +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts +26 -3
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchTamaguiConfig.d.ts.map +1 -1
- package/types/getPragmaOptions.d.ts +1 -1
- package/types/helpers/memoize.d.ts +1 -1
- package/types/helpers/memoize.d.ts.map +1 -1
- package/types/helpers/requireTamaguiCore.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/registerRequire.d.ts +2 -2
- package/types/registerRequire.d.ts.map +1 -1
- package/types/staticEvaluationIgnoredModules.d.ts +9 -0
- package/types/staticEvaluationIgnoredModules.d.ts.map +1 -0
- package/types/types.d.ts +2 -90
- package/types/types.d.ts.map +1 -1
- package/types/zero/artifact.d.ts +44 -0
- package/types/zero/artifact.d.ts.map +1 -0
- package/types/zero/graph.d.ts +139 -0
- package/types/zero/graph.d.ts.map +1 -0
- package/types/zero/identity.d.ts +33 -0
- package/types/zero/identity.d.ts.map +1 -0
- package/types/zero/index.d.ts +9 -0
- package/types/zero/index.d.ts.map +1 -0
- package/types/zero/islands.d.ts +56 -0
- package/types/zero/islands.d.ts.map +1 -0
- package/types/zero/options.d.ts +58 -0
- package/types/zero/options.d.ts.map +1 -0
- package/types/zero/ownership.d.ts +51 -0
- package/types/zero/ownership.d.ts.map +1 -0
- package/types/zero/theme.d.ts +83 -0
- package/types/zero/theme.d.ts.map +1 -0
- package/types/zero/transform.d.ts +53 -0
- package/types/zero/transform.d.ts.map +1 -0
- package/dist/check-dep-versions.cjs +0 -372
- package/dist/checkDeps.cjs +0 -271
- package/dist/constants.cjs +0 -51
- package/dist/exports.cjs +0 -48
- package/dist/extractor/accessSafe.cjs +0 -48
- package/dist/extractor/babelParse.cjs +0 -56
- package/dist/extractor/buildClassName.cjs +0 -86
- package/dist/extractor/bundle.cjs +0 -234
- package/dist/extractor/bundleConfig.cjs +0 -729
- package/dist/extractor/concatClassName.cjs +0 -129
- package/dist/extractor/createEvaluator.cjs +0 -88
- package/dist/extractor/createExtractor.cjs +0 -1968
- package/dist/extractor/createLogger.cjs +0 -50
- package/dist/extractor/detectModuleFormat.cjs +0 -55
- package/dist/extractor/ensureImportingConcat.cjs +0 -54
- package/dist/extractor/errors.cjs +0 -28
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -56
- package/dist/extractor/esbuildTsconfigPaths.cjs +0 -108
- package/dist/extractor/evaluateAstNode.cjs +0 -128
- package/dist/extractor/extractHelpers.cjs +0 -182
- package/dist/extractor/extractMediaStyle.cjs +0 -169
- package/dist/extractor/extractToClassNames.cjs +0 -475
- package/dist/extractor/extractToNative.cjs +0 -369
- package/dist/extractor/findTopmostFunction.cjs +0 -43
- package/dist/extractor/generatedUid.cjs +0 -58
- package/dist/extractor/getPrefixLogs.cjs +0 -31
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -85
- package/dist/extractor/getSourceModule.cjs +0 -100
- package/dist/extractor/getStaticBindingsForScope.cjs +0 -213
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +0 -41
- package/dist/extractor/hasTopLevelAwait.cjs +0 -62
- package/dist/extractor/hoistClassNames.cjs +0 -76
- package/dist/extractor/literalToAst.cjs +0 -109
- package/dist/extractor/loadFile.cjs +0 -17
- package/dist/extractor/loadTamagui.cjs +0 -373
- package/dist/extractor/logLines.cjs +0 -43
- package/dist/extractor/normalizeTernaries.cjs +0 -100
- package/dist/extractor/propsToFontFamilyCache.cjs +0 -42
- package/dist/extractor/regenerateConfig.cjs +0 -178
- package/dist/extractor/removeUnusedHooks.cjs +0 -108
- package/dist/extractor/timer.cjs +0 -52
- package/dist/extractor/validHTMLAttributes.cjs +0 -79
- package/dist/extractor/watchTamaguiConfig.cjs +0 -70
- package/dist/getPragmaOptions.cjs +0 -73
- package/dist/helpers/memoize.cjs +0 -45
- package/dist/helpers/requireTamaguiCore.cjs +0 -40
- package/dist/index.cjs +0 -42
- package/dist/registerRequire.cjs +0 -209
- package/dist/server.cjs +0 -82
- package/dist/types.cjs +0 -18
- package/dist/worker.cjs +0 -111
- package/src/extractor/accessSafe.ts +0 -22
- package/src/extractor/babelParse.ts +0 -38
- package/src/extractor/buildClassName.ts +0 -76
- package/src/extractor/createEvaluator.ts +0 -82
- package/src/extractor/createExtractor.ts +0 -2970
- package/src/extractor/createLogger.ts +0 -41
- package/src/extractor/ensureImportingConcat.ts +0 -36
- package/src/extractor/errors.ts +0 -1
- package/src/extractor/evaluateAstNode.ts +0 -136
- package/src/extractor/extractHelpers.ts +0 -211
- package/src/extractor/extractMediaStyle.ts +0 -194
- package/src/extractor/extractToClassNames.ts +0 -733
- package/src/extractor/extractToNative.ts +0 -506
- package/src/extractor/findTopmostFunction.ts +0 -24
- package/src/extractor/generatedUid.ts +0 -41
- package/src/extractor/getPrefixLogs.ts +0 -9
- package/src/extractor/getPropValueFromAttributes.ts +0 -95
- package/src/extractor/getSourceModule.ts +0 -96
- package/src/extractor/getStaticBindingsForScope.ts +0 -237
- package/src/extractor/hasTopLevelAwait.ts +0 -28
- package/src/extractor/hoistClassNames.ts +0 -52
- package/src/extractor/literalToAst.ts +0 -85
- package/src/extractor/loadFile.ts +0 -17
- package/src/extractor/logLines.ts +0 -16
- package/src/extractor/normalizeTernaries.ts +0 -89
- package/src/extractor/propsToFontFamilyCache.ts +0 -18
- package/src/extractor/removeUnusedHooks.ts +0 -83
- package/src/extractor/timer.ts +0 -25
- package/src/extractor/validHTMLAttributes.ts +0 -52
- package/src/worker.ts +0 -142
- package/types/extractor/accessSafe.d.ts +0 -3
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts +0 -5
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/buildClassName.d.ts +0 -7
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts +0 -12
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts +0 -32
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/createLogger.d.ts +0 -3
- package/types/extractor/createLogger.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts +0 -4
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/errors.d.ts +0 -3
- package/types/extractor/errors.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts +0 -3
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/extractHelpers.d.ts +0 -28
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts +0 -11
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts +0 -25
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/extractToNative.d.ts +0 -13
- package/types/extractor/extractToNative.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts +0 -4
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts +0 -5
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPrefixLogs.d.ts +0 -3
- package/types/extractor/getPrefixLogs.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -19
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts +0 -16
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts +0 -5
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hasTopLevelAwait.d.ts +0 -2
- package/types/extractor/hasTopLevelAwait.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts +0 -6
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts +0 -4
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/loadFile.d.ts +0 -1
- package/types/extractor/loadFile.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts +0 -2
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/normalizeTernaries.d.ts +0 -5
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/extractor/propsToFontFamilyCache.d.ts +0 -4
- package/types/extractor/propsToFontFamilyCache.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts +0 -3
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/extractor/timer.d.ts +0 -5
- package/types/extractor/timer.d.ts.map +0 -1
- package/types/extractor/validHTMLAttributes.d.ts +0 -52
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
- package/types/worker.d.ts +0 -46
- package/types/worker.d.ts.map +0 -1
- /package/dist/{setup.cjs → cjs/setup.cjs} +0 -0
|
@@ -1,729 +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
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
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, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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);
|
|
34
|
-
var bundleConfig_exports = {};
|
|
35
|
-
__export(bundleConfig_exports, {
|
|
36
|
-
bundleConfig: () => bundleConfig,
|
|
37
|
-
esbuildOptions: () => esbuildOptions,
|
|
38
|
-
esbuildOptionsWithPlugins: () => esbuildOptionsWithPlugins,
|
|
39
|
-
getBundledConfig: () => getBundledConfig,
|
|
40
|
-
getLoadedConfig: () => getLoadedConfig,
|
|
41
|
-
hasBundledConfigChanged: () => hasBundledConfigChanged,
|
|
42
|
-
loadComponents: () => loadComponents,
|
|
43
|
-
loadComponentsInner: () => loadComponentsInner,
|
|
44
|
-
loadComponentsInnerSync: () => loadComponentsInnerSync,
|
|
45
|
-
loadComponentsSync: () => loadComponentsSync,
|
|
46
|
-
writeTamaguiCSS: () => writeTamaguiCSS
|
|
47
|
-
});
|
|
48
|
-
module.exports = __toCommonJS(bundleConfig_exports);
|
|
49
|
-
var import_generator = __toESM(require("@babel/generator"));
|
|
50
|
-
var import_traverse = __toESM(require("@babel/traverse"));
|
|
51
|
-
var t = __toESM(require("@babel/types"));
|
|
52
|
-
var import_node_crypto = require("node:crypto");
|
|
53
|
-
var import_node_fs = require("node:fs");
|
|
54
|
-
var import_node_path = require("node:path");
|
|
55
|
-
var import_node_url = require("node:url");
|
|
56
|
-
var import_cli_color = require("@tamagui/cli-color");
|
|
57
|
-
var import_esbuild = __toESM(require("esbuild"));
|
|
58
|
-
var FS = __toESM(require("fs-extra"));
|
|
59
|
-
var import_promises = require("node:fs/promises");
|
|
60
|
-
var import_registerRequire = require("../registerRequire.cjs");
|
|
61
|
-
var import_babelParse = require("./babelParse.cjs");
|
|
62
|
-
var import_bundle = require("./bundle.cjs");
|
|
63
|
-
var import_getTamaguiConfigPathFromOptionsConfig = require("./getTamaguiConfigPathFromOptionsConfig.cjs");
|
|
64
|
-
var import_hasTopLevelAwait = require("./hasTopLevelAwait.cjs");
|
|
65
|
-
var import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs");
|
|
66
|
-
var import_detectModuleFormat = require("./detectModuleFormat.cjs");
|
|
67
|
-
const activeTempFiles = /* @__PURE__ */new Set();
|
|
68
|
-
function getDynamicEvalOutfile(name, format, contents) {
|
|
69
|
-
const ext = format === "esm" ? "mjs" : "cjs";
|
|
70
|
-
const hash = (0, import_node_crypto.createHash)("sha1").update(name).update("\0").update(format).update("\0").update(contents).digest("hex").slice(0, 10);
|
|
71
|
-
return (0, import_node_path.join)(process.cwd(), ".tamagui", `dynamic-eval-${hash}-${(0, import_node_path.basename)(name)}.${ext}`);
|
|
72
|
-
}
|
|
73
|
-
function getEsbuildStdinLoader(filePath) {
|
|
74
|
-
if (filePath.endsWith(".tsx")) return "tsx";
|
|
75
|
-
if (filePath.endsWith(".ts")) return "ts";
|
|
76
|
-
if (filePath.endsWith(".jsx")) return "jsx";
|
|
77
|
-
return "js";
|
|
78
|
-
}
|
|
79
|
-
function resolvePackageEntry(packageName, format) {
|
|
80
|
-
if (format === "cjs") {
|
|
81
|
-
return require.resolve(packageName);
|
|
82
|
-
}
|
|
83
|
-
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
84
|
-
const packageJson = JSON.parse((0, import_node_fs.readFileSync)(packageJsonPath, "utf-8"));
|
|
85
|
-
const packageRoot = (0, import_node_path.dirname)(packageJsonPath);
|
|
86
|
-
const exportEntry = packageJson.exports?.["."];
|
|
87
|
-
const esmEntry = exportEntry?.import || exportEntry?.module || exportEntry?.browser || packageJson.module;
|
|
88
|
-
if (typeof esmEntry === "string") {
|
|
89
|
-
return (0, import_node_path.join)(packageRoot, esmEntry);
|
|
90
|
-
}
|
|
91
|
-
return require.resolve(packageName);
|
|
92
|
-
}
|
|
93
|
-
function cleanupTempFiles() {
|
|
94
|
-
for (const f of activeTempFiles) {
|
|
95
|
-
try {
|
|
96
|
-
(0, import_node_fs.unlinkSync)(f);
|
|
97
|
-
} catch {}
|
|
98
|
-
}
|
|
99
|
-
activeTempFiles.clear();
|
|
100
|
-
}
|
|
101
|
-
process.on("exit", cleanupTempFiles);
|
|
102
|
-
process.on("SIGINT", () => {
|
|
103
|
-
cleanupTempFiles();
|
|
104
|
-
process.exit();
|
|
105
|
-
});
|
|
106
|
-
process.on("SIGTERM", () => {
|
|
107
|
-
cleanupTempFiles();
|
|
108
|
-
process.exit();
|
|
109
|
-
});
|
|
110
|
-
const external = ["@tamagui/core", "@tamagui/web", "react", "react-dom", "react-native-svg"];
|
|
111
|
-
const esbuildExtraOptions = {
|
|
112
|
-
define: {
|
|
113
|
-
__DEV__: `${process.env.NODE_ENV === "development"}`
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const handleEsmFeaturesPlugin = {
|
|
117
|
-
name: "handle-esm-features",
|
|
118
|
-
setup(build) {
|
|
119
|
-
const isCjs = build.initialOptions.format === "cjs" || !build.initialOptions.format;
|
|
120
|
-
build.onLoad({
|
|
121
|
-
filter: /\.(ts|tsx|js|jsx|mjs)$/
|
|
122
|
-
}, args => {
|
|
123
|
-
if (!isCjs) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
if (args.path.includes("node_modules") && !args.path.includes("@tamagui")) {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
let contents = (0, import_node_fs.readFileSync)(args.path, "utf8");
|
|
130
|
-
let modified = false;
|
|
131
|
-
if (contents.includes("import.meta.env")) {
|
|
132
|
-
contents = contents.replace(/import\.meta\.env/g, "process.env");
|
|
133
|
-
modified = true;
|
|
134
|
-
}
|
|
135
|
-
if (contents.includes("import.meta.url")) {
|
|
136
|
-
contents = contents.replace(/import\.meta\.url/g, '""');
|
|
137
|
-
modified = true;
|
|
138
|
-
}
|
|
139
|
-
if (contents.includes("import.meta.main")) {
|
|
140
|
-
contents = contents.replace(/import\.meta\.main/g, "false");
|
|
141
|
-
modified = true;
|
|
142
|
-
}
|
|
143
|
-
if ((0, import_hasTopLevelAwait.hasTopLevelAwait)(contents, args.path)) {
|
|
144
|
-
if (process.env.DEBUG?.startsWith("tamagui")) {
|
|
145
|
-
console.info(`[tamagui] stubbing file with top-level await: ${args.path}`);
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
// Keep this as an ESM-shaped stub so esbuild doesn't inline a top-level
|
|
149
|
-
// `module.exports = {}` into the parent bundle and wipe its exports.
|
|
150
|
-
contents: `// stubbed - contains top-level await
|
|
151
|
-
export default {}`,
|
|
152
|
-
loader: "js"
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
if (modified) {
|
|
156
|
-
return {
|
|
157
|
-
contents,
|
|
158
|
-
loader: args.path.endsWith(".tsx") ? "tsx" : args.path.endsWith(".ts") ? "ts" : args.path.endsWith(".jsx") ? "jsx" : "js"
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
const esbuildTransformOptions = {
|
|
166
|
-
target: "es2022",
|
|
167
|
-
format: "cjs",
|
|
168
|
-
jsx: "automatic",
|
|
169
|
-
platform: "node",
|
|
170
|
-
...esbuildExtraOptions
|
|
171
|
-
};
|
|
172
|
-
const esbuildOptions = {
|
|
173
|
-
...esbuildTransformOptions
|
|
174
|
-
};
|
|
175
|
-
const esbuildOptionsWithPlugins = {
|
|
176
|
-
...esbuildTransformOptions,
|
|
177
|
-
plugins: [handleEsmFeaturesPlugin]
|
|
178
|
-
};
|
|
179
|
-
let currentBundle = null;
|
|
180
|
-
let currentBundleKey = "";
|
|
181
|
-
let isBundling = false;
|
|
182
|
-
let lastBundle = null;
|
|
183
|
-
const waitForBundle = /* @__PURE__ */new Set();
|
|
184
|
-
function hasBundledConfigChanged() {
|
|
185
|
-
if (lastBundle === currentBundle) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
lastBundle = currentBundle;
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
let loadedConfig = null;
|
|
192
|
-
const getLoadedConfig = () => loadedConfig;
|
|
193
|
-
function getBundleKey(props) {
|
|
194
|
-
return JSON.stringify({
|
|
195
|
-
components: props.components,
|
|
196
|
-
config: props.config,
|
|
197
|
-
platform: props.platform
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
async function getBundledConfig(props, rebuild = false) {
|
|
201
|
-
const bundleKey = getBundleKey(props);
|
|
202
|
-
if (isBundling) {
|
|
203
|
-
await new Promise(res => {
|
|
204
|
-
waitForBundle.add(res);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
if (!currentBundle || currentBundleKey !== bundleKey || rebuild) {
|
|
208
|
-
return await bundleConfig(props);
|
|
209
|
-
}
|
|
210
|
-
return currentBundle;
|
|
211
|
-
}
|
|
212
|
-
global.tamaguiLastLoaded ||= 0;
|
|
213
|
-
function updateLastLoaded(config, bundleKey) {
|
|
214
|
-
global.tamaguiLastLoaded = Date.now();
|
|
215
|
-
global.tamaguiLastBundledConfig = config;
|
|
216
|
-
global.tamaguiLastBundledConfigKey = bundleKey;
|
|
217
|
-
}
|
|
218
|
-
let hasBundledOnce = false;
|
|
219
|
-
let hasLoggedBuild = false;
|
|
220
|
-
async function bundleConfig(props) {
|
|
221
|
-
const bundleKey = getBundleKey(props);
|
|
222
|
-
if (global.tamaguiLastBundledConfig && global.tamaguiLastBundledConfigKey === bundleKey && Date.now() - global.tamaguiLastLoaded < 3e3) {
|
|
223
|
-
return global.tamaguiLastBundledConfig;
|
|
224
|
-
}
|
|
225
|
-
try {
|
|
226
|
-
isBundling = true;
|
|
227
|
-
const configEntry = props.config ? (0, import_getTamaguiConfigPathFromOptionsConfig.getTamaguiConfigPathFromOptionsConfig)(props.config) : "";
|
|
228
|
-
const tmpDir = (0, import_node_path.join)(process.cwd(), ".tamagui");
|
|
229
|
-
const configFormat = configEntry ? (0, import_detectModuleFormat.detectModuleFormat)(configEntry) : "cjs";
|
|
230
|
-
const configExt = configFormat === "esm" ? ".mjs" : ".cjs";
|
|
231
|
-
const configOutPath = (0, import_node_path.join)(tmpDir, `tamagui.config${configExt}`);
|
|
232
|
-
const baseComponents = (props.components || []).filter(x => x !== "@tamagui/core");
|
|
233
|
-
const componentFormats = baseComponents.map(mod => {
|
|
234
|
-
try {
|
|
235
|
-
const pkgJson = require.resolve(mod + "/package.json");
|
|
236
|
-
const pkg = JSON.parse((0, import_node_fs.readFileSync)(pkgJson, "utf-8"));
|
|
237
|
-
return pkg.type === "module" ? "esm" : "cjs";
|
|
238
|
-
} catch {
|
|
239
|
-
return "cjs";
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
const componentOutPaths = baseComponents.map((componentModule, i) => {
|
|
243
|
-
const ext = componentFormats[i] === "esm" ? ".mjs" : ".cjs";
|
|
244
|
-
return (0, import_node_path.join)(tmpDir, `${componentModule.split(import_node_path.sep).join("-").replace(/[^a-z0-9]+/gi, "")}-components.config${ext}`);
|
|
245
|
-
});
|
|
246
|
-
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("tamagui")) {
|
|
247
|
-
console.info(`Building config entry`, configEntry);
|
|
248
|
-
}
|
|
249
|
-
let shouldBuild = !props.disableInitialBuild;
|
|
250
|
-
if (shouldBuild && props.config) {
|
|
251
|
-
const allOutFiles = [configOutPath, ...componentOutPaths];
|
|
252
|
-
try {
|
|
253
|
-
const stats = await Promise.all(allOutFiles.map(f => FS.stat(f).catch(() => null)));
|
|
254
|
-
const allExistAndRecent = stats.every(s => s !== null && Date.now() - s.mtimeMs < 3e3);
|
|
255
|
-
if (allExistAndRecent) {
|
|
256
|
-
shouldBuild = false;
|
|
257
|
-
}
|
|
258
|
-
} catch {}
|
|
259
|
-
}
|
|
260
|
-
if (shouldBuild) {
|
|
261
|
-
try {
|
|
262
|
-
await FS.ensureDir(tmpDir);
|
|
263
|
-
} catch {}
|
|
264
|
-
const start = Date.now();
|
|
265
|
-
await Promise.all([props.config ? (0, import_bundle.esbundleTamaguiConfig)({
|
|
266
|
-
entryPoints: [configEntry],
|
|
267
|
-
external,
|
|
268
|
-
outfile: configOutPath,
|
|
269
|
-
target: "node24",
|
|
270
|
-
format: configFormat,
|
|
271
|
-
...esbuildExtraOptions
|
|
272
|
-
}, props.platform || "web") : null, ...baseComponents.map((componentModule, i) => {
|
|
273
|
-
return (0, import_bundle.esbundleTamaguiConfig)({
|
|
274
|
-
entryPoints: [componentModule],
|
|
275
|
-
resolvePlatformSpecificEntries: true,
|
|
276
|
-
external,
|
|
277
|
-
outfile: componentOutPaths[i],
|
|
278
|
-
target: "node24",
|
|
279
|
-
format: componentFormats[i],
|
|
280
|
-
...esbuildExtraOptions
|
|
281
|
-
}, props.platform || "web");
|
|
282
|
-
})]);
|
|
283
|
-
if (!hasLoggedBuild && !props["_skipBuildLog"]) {
|
|
284
|
-
hasLoggedBuild = true;
|
|
285
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `
|
|
286
|
-
\u27A1 [tamagui] built config, components, prompt (${Date.now() - start}ms)`);
|
|
287
|
-
if (process.env.DEBUG?.startsWith("tamagui")) {
|
|
288
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.Dim, `
|
|
289
|
-
Config .${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), configOutPath)}
|
|
290
|
-
Components ${componentOutPaths.map(p => `.${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), p)}`).join("\n ")}
|
|
291
|
-
`);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
if (hasBundledOnce) {
|
|
296
|
-
try {
|
|
297
|
-
delete require.cache[require.resolve(configOutPath)];
|
|
298
|
-
} catch {}
|
|
299
|
-
for (const p of componentOutPaths) {
|
|
300
|
-
try {
|
|
301
|
-
delete require.cache[require.resolve(p)];
|
|
302
|
-
} catch {}
|
|
303
|
-
}
|
|
304
|
-
} else {
|
|
305
|
-
hasBundledOnce = true;
|
|
306
|
-
}
|
|
307
|
-
let out;
|
|
308
|
-
if (configFormat === "esm") {
|
|
309
|
-
out = await import((0, import_node_url.pathToFileURL)(configOutPath).href);
|
|
310
|
-
} else {
|
|
311
|
-
out = require(configOutPath);
|
|
312
|
-
}
|
|
313
|
-
let config = out.default || out || out.config;
|
|
314
|
-
if (config && config.config && !config.tokens) {
|
|
315
|
-
config = config.config;
|
|
316
|
-
}
|
|
317
|
-
if (!config) {
|
|
318
|
-
throw new Error(`No config: ${config}`);
|
|
319
|
-
}
|
|
320
|
-
if (config._isProxyWorm) {
|
|
321
|
-
throw new Error(`Got a proxied config - likely a module loading error. Set DEBUG=tamagui for details.`);
|
|
322
|
-
}
|
|
323
|
-
loadedConfig = config;
|
|
324
|
-
if (!config.parsed) {
|
|
325
|
-
const {
|
|
326
|
-
createTamagui
|
|
327
|
-
} = (0, import_requireTamaguiCore.requireTamaguiCore)(props.platform || "web");
|
|
328
|
-
config = createTamagui(config);
|
|
329
|
-
}
|
|
330
|
-
if (props.outputCSS) {
|
|
331
|
-
await writeTamaguiCSS(props.outputCSS, config);
|
|
332
|
-
}
|
|
333
|
-
let components = await loadComponents({
|
|
334
|
-
...props,
|
|
335
|
-
components: componentOutPaths
|
|
336
|
-
});
|
|
337
|
-
if (!components) {
|
|
338
|
-
throw new Error(`No components found: ${componentOutPaths.join(", ")}`);
|
|
339
|
-
}
|
|
340
|
-
for (const component of components) {
|
|
341
|
-
component.moduleName = baseComponents[componentOutPaths.indexOf(component.moduleName)] || component.moduleName;
|
|
342
|
-
if (!component.moduleName) {
|
|
343
|
-
if (process.env.DEBUG?.includes("tamagui") || process.env.IS_TAMAGUI_DEV) {
|
|
344
|
-
console.warn(`\u26A0\uFE0F no module name found: ${component.moduleName} ${JSON.stringify(baseComponents)} in ${JSON.stringify(componentOutPaths)}`);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("tamagui")) {
|
|
349
|
-
console.info("Loaded components", components);
|
|
350
|
-
}
|
|
351
|
-
const res = {
|
|
352
|
-
components,
|
|
353
|
-
nameToPaths: {},
|
|
354
|
-
tamaguiConfig: config
|
|
355
|
-
};
|
|
356
|
-
currentBundle = res;
|
|
357
|
-
currentBundleKey = bundleKey;
|
|
358
|
-
updateLastLoaded(res, bundleKey);
|
|
359
|
-
return res;
|
|
360
|
-
} catch (err) {
|
|
361
|
-
console.error(`Error bundling tamagui config: ${err?.message} (run with DEBUG=tamagui to see stack)`);
|
|
362
|
-
if (process.env.DEBUG?.includes("tamagui")) {
|
|
363
|
-
console.error(err.stack);
|
|
364
|
-
}
|
|
365
|
-
} finally {
|
|
366
|
-
isBundling = false;
|
|
367
|
-
waitForBundle.forEach(cb => cb());
|
|
368
|
-
waitForBundle.clear();
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
async function writeTamaguiCSS(outputCSS, config) {
|
|
372
|
-
const flush = async () => {
|
|
373
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [tamagui] output css: ${outputCSS}`);
|
|
374
|
-
await FS.writeFile(outputCSS, css);
|
|
375
|
-
};
|
|
376
|
-
const css = config.getCSS();
|
|
377
|
-
if (typeof css !== "string") {
|
|
378
|
-
throw new Error(`Invalid CSS: ${typeof css} ${css}`);
|
|
379
|
-
}
|
|
380
|
-
try {
|
|
381
|
-
if ((0, import_node_fs.existsSync)(outputCSS) && (await (0, import_promises.readFile)(outputCSS, "utf8")) === css) {} else {
|
|
382
|
-
await flush();
|
|
383
|
-
}
|
|
384
|
-
} catch (err) {
|
|
385
|
-
console.info("Error writing themes", err);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
async function loadComponents(props, forceExports = false) {
|
|
389
|
-
const coreComponents = getCoreComponentsSync(props);
|
|
390
|
-
const otherComponents = await loadComponentsInner(props, forceExports);
|
|
391
|
-
return [...coreComponents, ...(otherComponents || [])];
|
|
392
|
-
}
|
|
393
|
-
function loadComponentsSync(props, forceExports = false) {
|
|
394
|
-
const coreComponents = getCoreComponentsSync(props);
|
|
395
|
-
const otherComponents = loadComponentsInnerSync(props, forceExports);
|
|
396
|
-
return [...coreComponents, ...(otherComponents || [])];
|
|
397
|
-
}
|
|
398
|
-
function getCoreComponentsSync(props) {
|
|
399
|
-
const loaded = loadComponentsInnerSync({
|
|
400
|
-
...props,
|
|
401
|
-
components: ["@tamagui/core"]
|
|
402
|
-
});
|
|
403
|
-
if (!loaded) {
|
|
404
|
-
throw new Error(`Core should always load`);
|
|
405
|
-
}
|
|
406
|
-
return [{
|
|
407
|
-
...loaded[0],
|
|
408
|
-
moduleName: "@tamagui/core"
|
|
409
|
-
}];
|
|
410
|
-
}
|
|
411
|
-
async function loadComponentsInner(props, forceExports = false) {
|
|
412
|
-
const componentsModules = props.components || [];
|
|
413
|
-
const key = componentsModules.join("\0");
|
|
414
|
-
if (!forceExports && cacheComponents[key]) {
|
|
415
|
-
return cacheComponents[key];
|
|
416
|
-
}
|
|
417
|
-
const {
|
|
418
|
-
unregister
|
|
419
|
-
} = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
420
|
-
proxyWormImports: forceExports
|
|
421
|
-
});
|
|
422
|
-
try {
|
|
423
|
-
const results = [];
|
|
424
|
-
for (const name of componentsModules) {
|
|
425
|
-
const extension = (0, import_node_path.extname)(name);
|
|
426
|
-
const isLocal = Boolean(extension);
|
|
427
|
-
const isDynamic = isLocal && forceExports;
|
|
428
|
-
const format = isLocal ? (0, import_detectModuleFormat.detectModuleFormat)(name) : "cjs";
|
|
429
|
-
const fileContents = isDynamic ? (0, import_node_fs.readFileSync)(name, "utf-8") : "";
|
|
430
|
-
let loadModule = name;
|
|
431
|
-
let writtenContents = fileContents;
|
|
432
|
-
let didBabel = false;
|
|
433
|
-
const attemptLoad = async ({
|
|
434
|
-
forceExports: forceExports2 = false
|
|
435
|
-
} = {}) => {
|
|
436
|
-
if (isDynamic) {
|
|
437
|
-
writtenContents = forceExports2 ? transformAddExports((0, import_babelParse.babelParse)(esbuildit(fileContents, "modern"), name)) : fileContents;
|
|
438
|
-
loadModule = getDynamicEvalOutfile(name, format, writtenContents);
|
|
439
|
-
FS.ensureDirSync((0, import_node_path.dirname)(loadModule));
|
|
440
|
-
activeTempFiles.add(loadModule);
|
|
441
|
-
await import_esbuild.default.build({
|
|
442
|
-
...esbuildOptionsWithPlugins,
|
|
443
|
-
format,
|
|
444
|
-
outfile: loadModule,
|
|
445
|
-
stdin: {
|
|
446
|
-
contents: writtenContents,
|
|
447
|
-
resolveDir: (0, import_node_path.dirname)(name),
|
|
448
|
-
sourcefile: name,
|
|
449
|
-
loader: getEsbuildStdinLoader(name)
|
|
450
|
-
},
|
|
451
|
-
alias: {
|
|
452
|
-
"react-native": resolvePackageEntry("@tamagui/react-native-web-lite", format),
|
|
453
|
-
"@tamagui/react-native-web-lite": resolvePackageEntry("@tamagui/react-native-web-lite", format),
|
|
454
|
-
"@tamagui/react-native-web-internals": resolvePackageEntry("@tamagui/react-native-web-internals", format)
|
|
455
|
-
},
|
|
456
|
-
bundle: true,
|
|
457
|
-
packages: "external",
|
|
458
|
-
allowOverwrite: true,
|
|
459
|
-
sourcemap: false,
|
|
460
|
-
loader: import_bundle.esbuildLoaderConfig
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
if (process.env.DEBUG === "tamagui") {
|
|
464
|
-
console.info(`loadModule`, loadModule, format);
|
|
465
|
-
}
|
|
466
|
-
let moduleResult;
|
|
467
|
-
if (format === "esm") {
|
|
468
|
-
moduleResult = await import((0, import_node_url.pathToFileURL)(loadModule).href);
|
|
469
|
-
} else {
|
|
470
|
-
moduleResult = require(loadModule);
|
|
471
|
-
}
|
|
472
|
-
if (!forceExports2) {
|
|
473
|
-
(0, import_registerRequire.setRequireResult)(name, moduleResult);
|
|
474
|
-
}
|
|
475
|
-
const nameToInfo = getComponentStaticConfigByName(name, interopDefaultExport(moduleResult));
|
|
476
|
-
return {
|
|
477
|
-
moduleName: name,
|
|
478
|
-
nameToInfo
|
|
479
|
-
};
|
|
480
|
-
};
|
|
481
|
-
const dispose = () => {
|
|
482
|
-
if (isDynamic) {
|
|
483
|
-
FS.removeSync(loadModule);
|
|
484
|
-
activeTempFiles.delete(loadModule);
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
let loaded;
|
|
488
|
-
try {
|
|
489
|
-
loaded = await attemptLoad({
|
|
490
|
-
forceExports: true
|
|
491
|
-
});
|
|
492
|
-
didBabel = true;
|
|
493
|
-
} catch (err) {
|
|
494
|
-
console.info("babel err", err, writtenContents);
|
|
495
|
-
writtenContents = fileContents;
|
|
496
|
-
if (process.env.DEBUG?.startsWith("tamagui")) {
|
|
497
|
-
console.info(`Error parsing babel likely`, err);
|
|
498
|
-
}
|
|
499
|
-
try {
|
|
500
|
-
loaded = await attemptLoad({
|
|
501
|
-
forceExports: false
|
|
502
|
-
});
|
|
503
|
-
} catch (err2) {
|
|
504
|
-
if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
505
|
-
console.info(`
|
|
506
|
-
Tamagui attempted but failed to dynamically optimize components in:
|
|
507
|
-
${name}
|
|
508
|
-
`);
|
|
509
|
-
console.info(err2);
|
|
510
|
-
console.info(`At: ${loadModule}`, `
|
|
511
|
-
didBabel: ${didBabel}`, `
|
|
512
|
-
In:`, writtenContents, `
|
|
513
|
-
isDynamic: `, isDynamic);
|
|
514
|
-
}
|
|
515
|
-
loaded = [];
|
|
516
|
-
}
|
|
517
|
-
} finally {
|
|
518
|
-
dispose();
|
|
519
|
-
}
|
|
520
|
-
if (Array.isArray(loaded)) {
|
|
521
|
-
results.push(...loaded);
|
|
522
|
-
} else if (loaded) {
|
|
523
|
-
results.push(loaded);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
cacheComponents[key] = results;
|
|
527
|
-
return results;
|
|
528
|
-
} catch (err) {
|
|
529
|
-
console.info(`Tamagui error bundling components`, err.message, err.stack);
|
|
530
|
-
return null;
|
|
531
|
-
} finally {
|
|
532
|
-
unregister();
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
function loadComponentsInnerSync(props, forceExports = false) {
|
|
536
|
-
const componentsModules = props.components || [];
|
|
537
|
-
const key = componentsModules.join("\0");
|
|
538
|
-
if (!forceExports && cacheComponents[key]) {
|
|
539
|
-
return cacheComponents[key];
|
|
540
|
-
}
|
|
541
|
-
const {
|
|
542
|
-
unregister
|
|
543
|
-
} = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
544
|
-
proxyWormImports: forceExports
|
|
545
|
-
});
|
|
546
|
-
try {
|
|
547
|
-
const info = componentsModules.flatMap(name => {
|
|
548
|
-
const extension = (0, import_node_path.extname)(name);
|
|
549
|
-
const isLocal = Boolean(extension);
|
|
550
|
-
const isDynamic = isLocal && forceExports;
|
|
551
|
-
const fileContents = isDynamic ? (0, import_node_fs.readFileSync)(name, "utf-8") : "";
|
|
552
|
-
let loadModule = name;
|
|
553
|
-
let writtenContents = fileContents;
|
|
554
|
-
let didBabel = false;
|
|
555
|
-
function attemptLoad({
|
|
556
|
-
forceExports: forceExports2 = false
|
|
557
|
-
} = {}) {
|
|
558
|
-
if (isDynamic) {
|
|
559
|
-
writtenContents = forceExports2 ? transformAddExports((0, import_babelParse.babelParse)(esbuildit(fileContents, "modern"), name)) : fileContents;
|
|
560
|
-
loadModule = getDynamicEvalOutfile(name, "cjs", writtenContents);
|
|
561
|
-
FS.ensureDirSync((0, import_node_path.dirname)(loadModule));
|
|
562
|
-
activeTempFiles.add(loadModule);
|
|
563
|
-
import_esbuild.default.buildSync({
|
|
564
|
-
...esbuildOptions,
|
|
565
|
-
outfile: loadModule,
|
|
566
|
-
stdin: {
|
|
567
|
-
contents: writtenContents,
|
|
568
|
-
resolveDir: (0, import_node_path.dirname)(name),
|
|
569
|
-
sourcefile: name,
|
|
570
|
-
loader: getEsbuildStdinLoader(name)
|
|
571
|
-
},
|
|
572
|
-
alias: {
|
|
573
|
-
"react-native": resolvePackageEntry("@tamagui/react-native-web-lite", "esm"),
|
|
574
|
-
"@tamagui/react-native-web-lite": resolvePackageEntry("@tamagui/react-native-web-lite", "esm"),
|
|
575
|
-
"@tamagui/react-native-web-internals": resolvePackageEntry("@tamagui/react-native-web-internals", "esm")
|
|
576
|
-
},
|
|
577
|
-
bundle: true,
|
|
578
|
-
packages: "external",
|
|
579
|
-
allowOverwrite: true,
|
|
580
|
-
sourcemap: false,
|
|
581
|
-
loader: import_bundle.esbuildLoaderConfig
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
if (process.env.DEBUG === "tamagui") {
|
|
585
|
-
console.info(`loadModule`, loadModule, require.resolve(loadModule));
|
|
586
|
-
}
|
|
587
|
-
const moduleResult = require(loadModule);
|
|
588
|
-
if (!forceExports2) {
|
|
589
|
-
(0, import_registerRequire.setRequireResult)(name, moduleResult);
|
|
590
|
-
}
|
|
591
|
-
const nameToInfo = getComponentStaticConfigByName(name, interopDefaultExport(moduleResult));
|
|
592
|
-
return {
|
|
593
|
-
moduleName: name,
|
|
594
|
-
nameToInfo
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
const dispose = () => {
|
|
598
|
-
if (isDynamic) {
|
|
599
|
-
FS.removeSync(loadModule);
|
|
600
|
-
activeTempFiles.delete(loadModule);
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
try {
|
|
604
|
-
const res = attemptLoad({
|
|
605
|
-
forceExports: true
|
|
606
|
-
});
|
|
607
|
-
didBabel = true;
|
|
608
|
-
return res;
|
|
609
|
-
} catch (err) {
|
|
610
|
-
console.info("babel err", err, writtenContents);
|
|
611
|
-
writtenContents = fileContents;
|
|
612
|
-
if (process.env.DEBUG?.startsWith("tamagui")) {
|
|
613
|
-
console.info(`Error parsing babel likely`, err);
|
|
614
|
-
}
|
|
615
|
-
} finally {
|
|
616
|
-
dispose();
|
|
617
|
-
}
|
|
618
|
-
try {
|
|
619
|
-
return attemptLoad({
|
|
620
|
-
forceExports: false
|
|
621
|
-
});
|
|
622
|
-
} catch (err) {
|
|
623
|
-
if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
624
|
-
console.info(`
|
|
625
|
-
Tamagui attempted but failed to dynamically optimize components in:
|
|
626
|
-
${name}
|
|
627
|
-
`);
|
|
628
|
-
console.info(err);
|
|
629
|
-
console.info(`At: ${loadModule}`, `
|
|
630
|
-
didBabel: ${didBabel}`, `
|
|
631
|
-
In:`, writtenContents, `
|
|
632
|
-
isDynamic: `, isDynamic);
|
|
633
|
-
}
|
|
634
|
-
return [];
|
|
635
|
-
} finally {
|
|
636
|
-
dispose();
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
cacheComponents[key] = info;
|
|
640
|
-
return info;
|
|
641
|
-
} catch (err) {
|
|
642
|
-
console.info(`Tamagui error bundling components`, err.message, err.stack);
|
|
643
|
-
return null;
|
|
644
|
-
} finally {
|
|
645
|
-
unregister();
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
const esbuildit = (src, target) => {
|
|
649
|
-
return import_esbuild.default.transformSync(src, {
|
|
650
|
-
...esbuildTransformOptions,
|
|
651
|
-
...(target === "modern" && {
|
|
652
|
-
target: "es2022",
|
|
653
|
-
jsx: "automatic",
|
|
654
|
-
loader: "tsx",
|
|
655
|
-
platform: "neutral",
|
|
656
|
-
format: "esm"
|
|
657
|
-
})
|
|
658
|
-
}).code;
|
|
659
|
-
};
|
|
660
|
-
function getComponentStaticConfigByName(name, exported) {
|
|
661
|
-
const components = {};
|
|
662
|
-
try {
|
|
663
|
-
if (!exported || typeof exported !== "object" || Array.isArray(exported)) {
|
|
664
|
-
throw new Error(`Invalid export from package ${name}: ${typeof exported}`);
|
|
665
|
-
}
|
|
666
|
-
for (const key in exported) {
|
|
667
|
-
const found = getTamaguiComponent(key, exported[key]);
|
|
668
|
-
if (found) {
|
|
669
|
-
const {
|
|
670
|
-
Component,
|
|
671
|
-
...sc
|
|
672
|
-
} = found.staticConfig;
|
|
673
|
-
components[key] = {
|
|
674
|
-
staticConfig: sc
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
} catch (err) {
|
|
679
|
-
if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
680
|
-
console.error(`Tamagui failed getting components from ${name} (Disable error by setting environment variable TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD=1)`);
|
|
681
|
-
console.error(err);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
return components;
|
|
685
|
-
}
|
|
686
|
-
function getTamaguiComponent(name, Component) {
|
|
687
|
-
if (name[0].toUpperCase() !== name[0]) {
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
const staticConfig = Component?.staticConfig;
|
|
691
|
-
if (staticConfig) {
|
|
692
|
-
return Component;
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
function interopDefaultExport(mod) {
|
|
696
|
-
return mod?.default ?? mod;
|
|
697
|
-
}
|
|
698
|
-
const cacheComponents = {};
|
|
699
|
-
function transformAddExports(ast) {
|
|
700
|
-
const usedNames = /* @__PURE__ */new Set();
|
|
701
|
-
(0, import_traverse.default)(ast, {
|
|
702
|
-
ExportNamedDeclaration(nodePath) {
|
|
703
|
-
if (nodePath.node.specifiers) {
|
|
704
|
-
for (const spec of nodePath.node.specifiers) {
|
|
705
|
-
usedNames.add(t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
(0, import_traverse.default)(ast, {
|
|
711
|
-
VariableDeclaration(nodePath) {
|
|
712
|
-
if (!t.isProgram(nodePath.parent)) return;
|
|
713
|
-
const decs = nodePath.node.declarations;
|
|
714
|
-
if (decs.length > 1) return;
|
|
715
|
-
const [dec] = decs;
|
|
716
|
-
if (!t.isIdentifier(dec.id)) return;
|
|
717
|
-
if (!dec.init) return;
|
|
718
|
-
if (usedNames.has(dec.id.name)) return;
|
|
719
|
-
usedNames.add(dec.id.name);
|
|
720
|
-
nodePath.replaceWith(t.exportNamedDeclaration(t.variableDeclaration("let", [dec]), [t.exportSpecifier(t.identifier(dec.id.name), t.identifier(dec.id.name))]));
|
|
721
|
-
}
|
|
722
|
-
});
|
|
723
|
-
return (0, import_generator.default)(ast, {
|
|
724
|
-
concise: false,
|
|
725
|
-
filename: "test.tsx",
|
|
726
|
-
retainLines: false,
|
|
727
|
-
sourceMaps: false
|
|
728
|
-
}).code;
|
|
729
|
-
}
|