@tamagui/static 1.88.1 → 1.88.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/constants.js +1 -11
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/extractor/accessSafe.js +0 -4
- package/dist/cjs/extractor/babelParse.js +0 -5
- package/dist/cjs/extractor/buildClassName.js +0 -5
- package/dist/cjs/extractor/bundle.js +2 -8
- package/dist/cjs/extractor/bundle.js.map +1 -1
- package/dist/cjs/extractor/bundleConfig.js +8 -19
- package/dist/cjs/extractor/bundleConfig.js.map +1 -1
- package/dist/cjs/extractor/createEvaluator.js +0 -5
- package/dist/cjs/extractor/createExtractor.js +23 -32
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/createExtractor.native.js +2 -2
- package/dist/cjs/extractor/createExtractor.native.js.map +1 -1
- package/dist/cjs/extractor/ensureImportingConcat.js +0 -4
- package/dist/cjs/extractor/esbuildAliasPlugin.js +0 -4
- package/dist/cjs/extractor/evaluateAstNode.js +0 -4
- package/dist/cjs/extractor/extractHelpers.js +3 -22
- package/dist/cjs/extractor/extractHelpers.js.map +1 -1
- package/dist/cjs/extractor/extractMediaStyle.js +2 -8
- package/dist/cjs/extractor/extractMediaStyle.js.map +1 -1
- package/dist/cjs/extractor/extractToClassNames.js +4 -9
- package/dist/cjs/extractor/extractToClassNames.js.map +1 -1
- package/dist/cjs/extractor/findTopmostFunction.js +0 -4
- package/dist/cjs/extractor/generateTamaguiStudioConfig.js +2 -10
- package/dist/cjs/extractor/generateTamaguiStudioConfig.js.map +1 -1
- package/dist/cjs/extractor/generatedUid.js +0 -4
- package/dist/cjs/extractor/getPrefixLogs.js +1 -5
- package/dist/cjs/extractor/getPrefixLogs.js.map +1 -1
- package/dist/cjs/extractor/getPropValueFromAttributes.js +0 -4
- package/dist/cjs/extractor/getSourceModule.js +0 -4
- package/dist/cjs/extractor/getStaticBindingsForScope.js +1 -7
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +1 -1
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.js +0 -4
- package/dist/cjs/extractor/hoistClassNames.js +0 -4
- package/dist/cjs/extractor/literalToAst.js +1 -6
- package/dist/cjs/extractor/literalToAst.js.map +1 -1
- package/dist/cjs/extractor/loadFile.js +3 -4
- package/dist/cjs/extractor/loadFile.js.map +1 -1
- package/dist/cjs/extractor/loadTamagui.js +3 -13
- package/dist/cjs/extractor/loadTamagui.js.map +1 -1
- package/dist/cjs/extractor/logLines.js +0 -4
- package/dist/cjs/extractor/normalizeTernaries.js +0 -4
- package/dist/cjs/extractor/propsToFontFamilyCache.js +0 -6
- package/dist/cjs/extractor/removeUnusedHooks.js +2 -9
- package/dist/cjs/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/cjs/extractor/timer.js +0 -4
- package/dist/cjs/extractor/validHTMLAttributes.js +0 -4
- package/dist/cjs/getPragmaOptions.js +1 -6
- package/dist/cjs/getPragmaOptions.js.map +1 -1
- package/dist/cjs/getPragmaOptions.native.js +1 -1
- package/dist/cjs/getPragmaOptions.native.js.map +1 -1
- package/dist/cjs/helpers/memoize.js +0 -4
- package/dist/cjs/helpers/requireTamaguiCore.js +0 -4
- package/dist/cjs/index.js +0 -5
- package/dist/cjs/minifyCSS.js +0 -4
- package/dist/cjs/registerRequire.js +2 -10
- package/dist/cjs/registerRequire.js.map +1 -1
- package/dist/cjs/server.js +0 -4
- package/dist/cjs/static.js +0 -12
- package/dist/cjs/webpackPlugin.js +0 -4
- package/dist/esm/constants.native.js +39 -4
- package/dist/esm/constants.native.js.map +2 -2
- package/dist/esm/extractor/accessSafe.native.js +32 -3
- package/dist/esm/extractor/accessSafe.native.js.map +1 -1
- package/dist/esm/extractor/babelParse.native.js +33 -3
- package/dist/esm/extractor/babelParse.native.js.map +1 -1
- package/dist/esm/extractor/buildClassName.native.js +33 -3
- package/dist/esm/extractor/buildClassName.native.js.map +1 -1
- package/dist/esm/extractor/bundle.native.js +43 -16
- package/dist/esm/extractor/bundle.native.js.map +2 -2
- package/dist/esm/extractor/bundleConfig.native.js +69 -44
- package/dist/esm/extractor/bundleConfig.native.js.map +2 -2
- package/dist/esm/extractor/createEvaluator.native.js +37 -12
- package/dist/esm/extractor/createEvaluator.native.js.map +2 -2
- package/dist/esm/extractor/createExtractor.native.js +115 -109
- package/dist/esm/extractor/createExtractor.native.js.map +2 -2
- package/dist/esm/extractor/ensureImportingConcat.native.js +32 -3
- package/dist/esm/extractor/ensureImportingConcat.native.js.map +1 -1
- package/dist/esm/extractor/esbuildAliasPlugin.native.js +23 -2
- package/dist/esm/extractor/esbuildAliasPlugin.native.js.map +1 -1
- package/dist/esm/extractor/evaluateAstNode.native.js +32 -3
- package/dist/esm/extractor/evaluateAstNode.native.js.map +1 -1
- package/dist/esm/extractor/extractHelpers.native.js +54 -14
- package/dist/esm/extractor/extractHelpers.native.js.map +2 -2
- package/dist/esm/extractor/extractMediaStyle.native.js +40 -12
- package/dist/esm/extractor/extractMediaStyle.native.js.map +1 -1
- package/dist/esm/extractor/extractToClassNames.native.js +48 -34
- package/dist/esm/extractor/extractToClassNames.native.js.map +2 -2
- package/dist/esm/extractor/findTopmostFunction.native.js +23 -2
- package/dist/esm/extractor/findTopmostFunction.native.js.map +1 -1
- package/dist/esm/extractor/generateTamaguiStudioConfig.native.js +49 -20
- package/dist/esm/extractor/generateTamaguiStudioConfig.native.js.map +2 -2
- package/dist/esm/extractor/generatedUid.native.js +32 -3
- package/dist/esm/extractor/generatedUid.native.js.map +1 -1
- package/dist/esm/extractor/getPrefixLogs.native.js +24 -3
- package/dist/esm/extractor/getPrefixLogs.native.js.map +1 -1
- package/dist/esm/extractor/getPropValueFromAttributes.native.js +34 -7
- package/dist/esm/extractor/getPropValueFromAttributes.native.js.map +2 -2
- package/dist/esm/extractor/getSourceModule.native.js +32 -3
- package/dist/esm/extractor/getSourceModule.native.js.map +1 -1
- package/dist/esm/extractor/getStaticBindingsForScope.native.js +41 -14
- package/dist/esm/extractor/getStaticBindingsForScope.native.js.map +1 -1
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.js +25 -4
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.js.map +1 -1
- package/dist/esm/extractor/hoistClassNames.native.js +32 -3
- package/dist/esm/extractor/hoistClassNames.native.js.map +1 -1
- package/dist/esm/extractor/literalToAst.native.js +34 -4
- package/dist/esm/extractor/literalToAst.native.js.map +1 -1
- package/dist/esm/extractor/loadFile.native.js +5 -3
- package/dist/esm/extractor/loadFile.native.js.map +1 -1
- package/dist/esm/extractor/loadTamagui.native.js +77 -63
- package/dist/esm/extractor/loadTamagui.native.js.map +2 -2
- package/dist/esm/extractor/logLines.native.js +23 -2
- package/dist/esm/extractor/logLines.native.js.map +1 -1
- package/dist/esm/extractor/normalizeTernaries.native.js +34 -7
- package/dist/esm/extractor/normalizeTernaries.native.js.map +2 -2
- package/dist/esm/extractor/propsToFontFamilyCache.native.js +25 -2
- package/dist/esm/extractor/propsToFontFamilyCache.native.js.map +1 -1
- package/dist/esm/extractor/removeUnusedHooks.native.js +37 -5
- package/dist/esm/extractor/removeUnusedHooks.native.js.map +1 -1
- package/dist/esm/extractor/timer.native.js +23 -2
- package/dist/esm/extractor/timer.native.js.map +1 -1
- package/dist/esm/extractor/validHTMLAttributes.native.js +23 -2
- package/dist/esm/extractor/validHTMLAttributes.native.js.map +1 -1
- package/dist/esm/getPragmaOptions.native.js +25 -3
- package/dist/esm/getPragmaOptions.native.js.map +1 -1
- package/dist/esm/helpers/memoize.native.js +23 -2
- package/dist/esm/helpers/memoize.native.js.map +1 -1
- package/dist/esm/helpers/requireTamaguiCore.native.js +23 -2
- package/dist/esm/helpers/requireTamaguiCore.native.js.map +1 -1
- package/dist/esm/index.native.js +22 -3
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/minifyCSS.native.js +34 -6
- package/dist/esm/minifyCSS.native.js.map +2 -2
- package/dist/esm/registerRequire.native.js +32 -8
- package/dist/esm/registerRequire.native.js.map +1 -1
- package/dist/esm/server.native.js +34 -5
- package/dist/esm/server.native.js.map +2 -2
- package/dist/esm/setup.native.js +1 -0
- package/dist/esm/setup.native.js.map +1 -1
- package/dist/esm/static.native.js +39 -12
- package/dist/esm/static.native.js.map +1 -1
- package/dist/esm/types.native.js +14 -0
- package/dist/esm/types.native.js.map +2 -2
- package/dist/esm/webpackPlugin.native.js +23 -2
- package/dist/esm/webpackPlugin.native.js.map +1 -1
- package/package.json +14 -14
@@ -1,32 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
return to;
|
15
|
+
};
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
22
|
+
mod
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
24
|
+
var createExtractor_exports = {};
|
25
|
+
__export(createExtractor_exports, {
|
26
|
+
createExtractor: () => createExtractor
|
27
|
+
});
|
28
|
+
module.exports = __toCommonJS(createExtractor_exports);
|
29
|
+
var import_path = require("path"), import_traverse = __toESM(require("@babel/traverse")), t = __toESM(require("@babel/types")), import_cli_color = require("@tamagui/cli-color"), import_react_native_web_internals = require("react-native-web-internals"), import_constants = require("../constants"), import_requireTamaguiCore = require("../helpers/requireTamaguiCore"), import_createEvaluator = require("./createEvaluator"), import_evaluateAstNode = require("./evaluateAstNode"), import_extractHelpers = require("./extractHelpers"), import_findTopmostFunction = require("./findTopmostFunction"), import_getStaticBindingsForScope = require("./getStaticBindingsForScope"), import_literalToAst = require("./literalToAst"), import_loadTamagui = require("./loadTamagui"), import_logLines = require("./logLines"), import_normalizeTernaries = require("./normalizeTernaries"), import_propsToFontFamilyCache = require("./propsToFontFamilyCache"), import_removeUnusedHooks = require("./removeUnusedHooks"), import_timer = require("./timer"), import_validHTMLAttributes = require("./validHTMLAttributes");
|
30
30
|
const UNTOUCHED_PROPS = {
|
31
31
|
key: !0,
|
32
32
|
style: !0,
|
@@ -66,20 +66,20 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
66
66
|
);
|
67
67
|
let projectInfo = null;
|
68
68
|
function loadSync(props) {
|
69
|
-
return isFullyDisabled(props) ? null : projectInfo
|
69
|
+
return isFullyDisabled(props) ? null : projectInfo || (projectInfo = (0, import_loadTamagui.loadTamaguiSync)(props));
|
70
70
|
}
|
71
71
|
async function load(props) {
|
72
|
-
return isFullyDisabled(props) ? null : projectInfo
|
72
|
+
return isFullyDisabled(props) ? null : projectInfo || (projectInfo = await (0, import_loadTamagui.loadTamagui)(props));
|
73
73
|
}
|
74
74
|
return {
|
75
75
|
options: {
|
76
76
|
logger
|
77
77
|
},
|
78
|
-
cleanupBeforeExit,
|
78
|
+
cleanupBeforeExit: import_getStaticBindingsForScope.cleanupBeforeExit,
|
79
79
|
loadTamagui: load,
|
80
80
|
loadTamaguiSync: loadSync,
|
81
81
|
getTamagui() {
|
82
|
-
return projectInfo
|
82
|
+
return projectInfo == null ? void 0 : projectInfo.tamaguiConfig;
|
83
83
|
},
|
84
84
|
parseSync: (f, props) => {
|
85
85
|
const projectInfo2 = loadSync(props);
|
@@ -91,6 +91,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
91
91
|
}
|
92
92
|
};
|
93
93
|
function parseWithConfig({ components, tamaguiConfig }, fileOrPath, options) {
|
94
|
+
var _a;
|
94
95
|
const {
|
95
96
|
config = "tamagui.config.ts",
|
96
97
|
importsWhitelist = ["constants.js"],
|
@@ -121,7 +122,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
121
122
|
propMapper,
|
122
123
|
proxyThemeVariables,
|
123
124
|
pseudoDescriptors
|
124
|
-
} = requireTamaguiCore(platform2);
|
125
|
+
} = (0, import_requireTamaguiCore.requireTamaguiCore)(platform2);
|
125
126
|
let shouldPrintDebug = options.shouldPrintDebug || !1;
|
126
127
|
if (disable === !0 || Array.isArray(disable) && disable.includes(sourcePath))
|
127
128
|
return null;
|
@@ -134,12 +135,13 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
134
135
|
)}`
|
135
136
|
), null;
|
136
137
|
function isValidStyleKey(name, staticConfig) {
|
138
|
+
var _a2, _b, _c;
|
137
139
|
if (!projectInfo)
|
138
140
|
throw new Error("Tamagui extractor not loaded yet");
|
139
|
-
return platform2 === "native" && name[0] === "$" && mediaQueryConfig[name.slice(1)] ? !1 : !!(staticConfig.validStyles
|
140
|
-
staticConfig.variants
|
141
|
+
return platform2 === "native" && name[0] === "$" && mediaQueryConfig[name.slice(1)] ? !1 : !!((_a2 = staticConfig.validStyles) != null && _a2[name] || pseudoDescriptors[name] || // dont disable variants or else you lose many things flattening
|
142
|
+
(_b = staticConfig.variants) != null && _b[name] || (_c = projectInfo == null ? void 0 : projectInfo.tamaguiConfig) != null && _c.shorthands[name] || name[0] === "$" && mediaQueryConfig[name.slice(1)]);
|
141
143
|
}
|
142
|
-
const isTargetingHTML = platform2 === "web", ogDebug = shouldPrintDebug, tm = timer(), propsWithFileInfo = {
|
144
|
+
const isTargetingHTML = platform2 === "web", ogDebug = shouldPrintDebug, tm = (0, import_timer.timer)(), propsWithFileInfo = {
|
143
145
|
...options,
|
144
146
|
sourcePath,
|
145
147
|
allLoadedComponents: components ? [...components] : []
|
@@ -149,16 +151,16 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
149
151
|
"loaded components:",
|
150
152
|
propsWithFileInfo.allLoadedComponents.map((comp) => Object.keys(comp.nameToInfo).join(", ")).join(", ")
|
151
153
|
].join(" ")
|
152
|
-
), process.env.DEBUG
|
154
|
+
), (_a = process.env.DEBUG) != null && _a.startsWith("tamagui") && logger.info(
|
153
155
|
[
|
154
156
|
"loaded:",
|
155
157
|
propsWithFileInfo.allLoadedComponents.map((x) => x.moduleName)
|
156
158
|
].join(`
|
157
159
|
`)
|
158
|
-
)), tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig
|
160
|
+
)), tm.mark("load-tamagui", !!shouldPrintDebug), isFullyDisabled(options) || tamaguiConfig != null && tamaguiConfig.themes || (console.error(
|
159
161
|
'\u26D4\uFE0F Error: Missing "themes" in your tamagui.config file, this may be due to duplicated dependency versions. Try out https://github.com/bmish/check-dependency-version-consistency to see if there are mis-matches, or search your lockfile.'
|
160
162
|
), console.info(" Got config:", tamaguiConfig), process.exit(0));
|
161
|
-
const firstThemeName = Object.keys(tamaguiConfig
|
163
|
+
const firstThemeName = Object.keys((tamaguiConfig == null ? void 0 : tamaguiConfig.themes) || {})[0], firstTheme = (tamaguiConfig == null ? void 0 : tamaguiConfig.themes[firstThemeName]) || {};
|
162
164
|
(!firstTheme || typeof firstTheme != "object") && (console.error("Missing theme, an error occurred when importing your config"), console.info("Got config:", tamaguiConfig), console.info("Looking for theme:", firstThemeName), process.exit(0));
|
163
165
|
const proxiedTheme = proxyThemeVariables(firstTheme), themeAccessListeners = /* @__PURE__ */ new Set(), defaultTheme = new Proxy(proxiedTheme, {
|
164
166
|
get(target, key) {
|
@@ -171,7 +173,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
171
173
|
`allLoadedComponent modules ${propsWithFileInfo.allLoadedComponents.map((k) => k.moduleName).join(", ")}`
|
172
174
|
), logger.info(
|
173
175
|
`valid import paths: ${JSON.stringify(
|
174
|
-
getValidComponentsPaths(propsWithFileInfo)
|
176
|
+
(0, import_extractHelpers.getValidComponentsPaths)(propsWithFileInfo)
|
175
177
|
)}`
|
176
178
|
));
|
177
179
|
let doesUseValidImport = !1, hasImportedTheme = !1;
|
@@ -179,20 +181,20 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
179
181
|
for (const bodyPath of body) {
|
180
182
|
if (bodyPath.type !== "ImportDeclaration")
|
181
183
|
continue;
|
182
|
-
const node = "node" in bodyPath ? bodyPath.node : bodyPath, moduleName = node.source.value, valid = isValidImport(propsWithFileInfo, moduleName);
|
184
|
+
const node = "node" in bodyPath ? bodyPath.node : bodyPath, moduleName = node.source.value, valid = (0, import_extractHelpers.isValidImport)(propsWithFileInfo, moduleName);
|
183
185
|
if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(` - import ${moduleName} ${valid}`), extractStyledDefinitions && valid && node.specifiers.some((specifier) => specifier.local.name === "styled")) {
|
184
186
|
doesUseValidImport = !0;
|
185
187
|
break;
|
186
188
|
}
|
187
189
|
if (valid) {
|
188
190
|
const names = node.specifiers.map((specifier) => specifier.local.name), isValidComponent = names.some(
|
189
|
-
(name) => !!(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name])
|
191
|
+
(name) => !!((0, import_extractHelpers.isValidImport)(propsWithFileInfo, moduleName, name) || validHooks[name])
|
190
192
|
);
|
191
193
|
if (shouldPrintDebug === "verbose" && logger.info(
|
192
194
|
` - import ${isValidComponent ? "\u2705" : "\u21E3"} - ${names.join(
|
193
195
|
", "
|
194
196
|
)} from '${moduleName}' - (valid: ${JSON.stringify(
|
195
|
-
getValidComponentsPaths(propsWithFileInfo)
|
197
|
+
(0, import_extractHelpers.getValidComponentsPaths)(propsWithFileInfo)
|
196
198
|
)})`
|
197
199
|
), isValidComponent) {
|
198
200
|
doesUseValidImport = !0;
|
@@ -209,7 +211,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
209
211
|
const importDeclaration = importDeclarations.find(
|
210
212
|
(dec) => dec.specifiers.some((spec) => spec.local.name === componentName)
|
211
213
|
);
|
212
|
-
return importDeclaration ? getValidImport(
|
214
|
+
return importDeclaration ? (0, import_extractHelpers.getValidImport)(
|
213
215
|
propsWithFileInfo,
|
214
216
|
importDeclaration.source.value,
|
215
217
|
componentName
|
@@ -217,7 +219,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
217
219
|
}
|
218
220
|
tm.mark("import-check", !!shouldPrintDebug);
|
219
221
|
let couldntParse = !1;
|
220
|
-
const modifiedComponents = /* @__PURE__ */ new Set(), bindingCache = {}, callTraverse = (a) => fileOrPath.type === "File" ?
|
222
|
+
const modifiedComponents = /* @__PURE__ */ new Set(), bindingCache = {}, callTraverse = (a) => fileOrPath.type === "File" ? (0, import_traverse.default)(fileOrPath, a) : fileOrPath.traverse(a), shouldDisableExtraction = disableExtraction === !0 || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath);
|
221
223
|
let programPath = null;
|
222
224
|
const res = {
|
223
225
|
styled: 0,
|
@@ -235,6 +237,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
235
237
|
},
|
236
238
|
// styled() calls
|
237
239
|
CallExpression(path) {
|
240
|
+
var _a2, _b;
|
238
241
|
if (disable || shouldDisableExtraction || extractStyledDefinitions === !1 || !t.isIdentifier(path.node.callee) || path.node.callee.name !== "styled")
|
239
242
|
return;
|
240
243
|
const variableName = t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id) ? path.parent.id.name : "unknown", parentNode = path.node.arguments[0];
|
@@ -251,12 +254,12 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
251
254
|
shouldPrintDebug && logger.info(
|
252
255
|
`Unknown component: ${variableName} = styled(${parentName}) attempting dynamic load: ${sourcePath}`
|
253
256
|
);
|
254
|
-
const out2 = loadTamaguiSync({
|
257
|
+
const out2 = (0, import_loadTamagui.loadTamaguiSync)({
|
255
258
|
forceExports: !0,
|
256
259
|
components: [sourcePath],
|
257
260
|
cacheKey: version
|
258
261
|
});
|
259
|
-
if (!out2
|
262
|
+
if (!(out2 != null && out2.components)) {
|
260
263
|
shouldPrintDebug && logger.info(`Couldn't load, got ${out2}`);
|
261
264
|
return;
|
262
265
|
}
|
@@ -264,9 +267,9 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
264
267
|
...propsWithFileInfo.allLoadedComponents,
|
265
268
|
...out2.components
|
266
269
|
], Component = out2.components.flatMap((x) => x.nameToInfo[variableName] ?? [])[0], !out2.cached) {
|
267
|
-
const foundNames = out2.components
|
268
|
-
foundNames && colorLog(
|
269
|
-
Color.FgYellow,
|
270
|
+
const foundNames = (_a2 = out2.components) == null ? void 0 : _a2.map((x) => Object.keys(x.nameToInfo).join(", ")).join(", ").trim();
|
271
|
+
foundNames && (0, import_cli_color.colorLog)(
|
272
|
+
import_cli_color.Color.FgYellow,
|
270
273
|
` | Tamagui found dynamic components: ${foundNames}`
|
271
274
|
);
|
272
275
|
}
|
@@ -292,28 +295,28 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
292
295
|
"focusStyle",
|
293
296
|
"hoverStyle",
|
294
297
|
"pressStyle"
|
295
|
-
]), skipped = /* @__PURE__ */ new Set(), styles = {}, staticNamespace = getStaticBindingsForScope(
|
298
|
+
]), skipped = /* @__PURE__ */ new Set(), styles = {}, staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(
|
296
299
|
path.scope,
|
297
300
|
importsWhitelist,
|
298
301
|
sourcePath,
|
299
302
|
bindingCache,
|
300
303
|
shouldPrintDebug
|
301
|
-
), attemptEval = evaluateVars ? createEvaluator({
|
304
|
+
), attemptEval = evaluateVars ? (0, import_createEvaluator.createEvaluator)({
|
302
305
|
props: propsWithFileInfo,
|
303
306
|
staticNamespace,
|
304
307
|
sourcePath,
|
305
308
|
shouldPrintDebug
|
306
|
-
}) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
|
309
|
+
}) : import_evaluateAstNode.evaluateAstNode, attemptEvalSafe = (0, import_createEvaluator.createSafeEvaluator)(attemptEval);
|
307
310
|
for (const property of definition.properties) {
|
308
311
|
if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || // TODO make pseudos and variants work
|
309
312
|
// skip pseudos
|
310
313
|
pseudoDescriptors[property.key.name] || // skip variants
|
311
|
-
Component.staticConfig.variants
|
314
|
+
(_b = Component.staticConfig.variants) != null && _b[property.key.name] || componentSkipProps.has(property.key.name)) {
|
312
315
|
skipped.add(property);
|
313
316
|
continue;
|
314
317
|
}
|
315
318
|
const out2 = attemptEvalSafe(property.value);
|
316
|
-
out2 === FAILED_EVAL ? skipped.add(property) : styles[property.key.name] = out2;
|
319
|
+
out2 === import_constants.FAILED_EVAL ? skipped.add(property) : styles[property.key.name] = out2;
|
317
320
|
}
|
318
321
|
const out = getSplitStyles(
|
319
322
|
styles,
|
@@ -349,32 +352,33 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
349
352
|
return value ? t.objectProperty(t.stringLiteral(key), t.stringLiteral(value)) : prop;
|
350
353
|
}), out.rulesToInsert)
|
351
354
|
for (const { identifier, rules } of out.rulesToInsert)
|
352
|
-
onStyleRule
|
355
|
+
onStyleRule == null || onStyleRule(identifier, rules);
|
353
356
|
res.styled++, shouldPrintDebug && logger.info(`Extracted styled(${variableName})`);
|
354
357
|
},
|
355
358
|
JSXElement(traversePath) {
|
359
|
+
var _a2;
|
356
360
|
tm.mark("jsx-element", !!shouldPrintDebug);
|
357
|
-
const node = traversePath.node.openingElement, ogAttributes = node.attributes.map((attr) => ({ ...attr })), componentName = findComponentName(traversePath.scope), closingElement = traversePath.node.closingElement;
|
358
|
-
if (shouldPrintDebug && logger.info(` start ${node.name}`), closingElement && t.isJSXMemberExpression(closingElement
|
361
|
+
const node = traversePath.node.openingElement, ogAttributes = node.attributes.map((attr) => ({ ...attr })), componentName = (0, import_extractHelpers.findComponentName)(traversePath.scope), closingElement = traversePath.node.closingElement;
|
362
|
+
if (shouldPrintDebug && logger.info(` start ${node.name}`), closingElement && t.isJSXMemberExpression(closingElement == null ? void 0 : closingElement.name) || !t.isJSXIdentifier(node.name)) {
|
359
363
|
shouldPrintDebug && logger.info(" skip non-identifier element");
|
360
364
|
return;
|
361
365
|
}
|
362
366
|
const binding = traversePath.scope.getBinding(node.name.name);
|
363
367
|
let moduleName = "";
|
364
|
-
if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !isValidImport(propsWithFileInfo, moduleName, binding.identifier.name))) {
|
368
|
+
if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !(0, import_extractHelpers.isValidImport)(propsWithFileInfo, moduleName, binding.identifier.name))) {
|
365
369
|
shouldPrintDebug && logger.info(
|
366
370
|
` - Binding for ${componentName} not internal import or from components ${binding.identifier.name} in ${moduleName}`
|
367
371
|
);
|
368
372
|
return;
|
369
373
|
}
|
370
|
-
const component = getValidComponent(propsWithFileInfo, moduleName, node.name.name);
|
374
|
+
const component = (0, import_extractHelpers.getValidComponent)(propsWithFileInfo, moduleName, node.name.name);
|
371
375
|
if (!component || !component.staticConfig) {
|
372
376
|
shouldPrintDebug && logger.info(` - No Tamagui conf on this: ${node.name.name}`);
|
373
377
|
return;
|
374
378
|
}
|
375
379
|
const originalNodeName = node.name.name;
|
376
380
|
res.found++;
|
377
|
-
const filePath = `./${relative(process.cwd(), sourcePath)}`, lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "", codePosition = `${filePath}:${lineNumbers}`, debugPropValue = node.attributes.filter(
|
381
|
+
const filePath = `./${(0, import_path.relative)(process.cwd(), sourcePath)}`, lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "", codePosition = `${filePath}:${lineNumbers}`, debugPropValue = node.attributes.filter(
|
378
382
|
(n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug"
|
379
383
|
).map((n) => n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1)[0];
|
380
384
|
if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(`
|
@@ -394,7 +398,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
394
398
|
), node.attributes.unshift(
|
395
399
|
t.jsxAttribute(
|
396
400
|
t.jsxIdentifier("data-at"),
|
397
|
-
t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)
|
401
|
+
t.stringLiteral(`${(0, import_path.basename)(filePath)}:${lineNumbers}`)
|
398
402
|
)
|
399
403
|
)), shouldDisableExtraction) {
|
400
404
|
shouldPrintDebug === "verbose" && console.info(" Extraction disabled");
|
@@ -430,7 +434,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
430
434
|
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name != "string")
|
431
435
|
return shouldPrintDebug && logger.info(" ! inlining, spread attr"), inlined.set(`${Math.random()}`, "spread"), attr;
|
432
436
|
const name = attribute.name.name;
|
433
|
-
if (excludeProps
|
437
|
+
if (excludeProps != null && excludeProps.has(name))
|
434
438
|
return shouldPrintDebug && logger.info([" excluding prop", name].join(" ")), null;
|
435
439
|
if (inlineProps.has(name))
|
436
440
|
return inlined.set(name, name), shouldPrintDebug && logger.info([" ! inlining, inline prop", name].join(" ")), attr;
|
@@ -440,7 +444,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
440
444
|
return inlined.set(name, INLINE_EXTRACTABLE[name]), attr;
|
441
445
|
if (name.startsWith("data-"))
|
442
446
|
return attr;
|
443
|
-
if (name[0] === "$" && t.isJSXExpressionContainer(attribute
|
447
|
+
if (name[0] === "$" && t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
|
444
448
|
const shortname = name.slice(1);
|
445
449
|
if (mediaQueryConfig[shortname]) {
|
446
450
|
if (platform2 === "native" && (shouldDeopt = !0), disableExtractInlineMedia)
|
@@ -462,7 +466,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
462
466
|
}
|
463
467
|
}
|
464
468
|
}
|
465
|
-
const [value, valuePath] = t.isJSXExpressionContainer(attribute
|
469
|
+
const [value, valuePath] = t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value) ? [attribute.value.expression, path.get("value")] : [attribute.value, path.get("value")], remove = () => {
|
466
470
|
Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove();
|
467
471
|
};
|
468
472
|
if (name === "ref")
|
@@ -484,7 +488,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
484
488
|
const styleValue = attemptEvalSafe(value);
|
485
489
|
if (!variants[name] && !isValidStyleKey(name, staticConfig)) {
|
486
490
|
let keys = [name], out = null;
|
487
|
-
out = propMapper(name, styleValue, propMapperStyleState), out && (Array.isArray(out) ? (out = Object.fromEntries(out), keys = Object.keys(out)) : (logger.warn("Error expected array but got", out), couldntParse = !0, shouldDeopt = !0)), out && (isTargetingHTML && (out = createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
|
491
|
+
out = propMapper(name, styleValue, propMapperStyleState), out && (Array.isArray(out) ? (out = Object.fromEntries(out), keys = Object.keys(out)) : (logger.warn("Error expected array but got", out), couldntParse = !0, shouldDeopt = !0)), out && (isTargetingHTML && (out = (0, import_react_native_web_internals.createDOMProps)(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
|
488
492
|
let didInline = !1;
|
489
493
|
const attributes = keys.map((key) => {
|
490
494
|
const val = out[key];
|
@@ -493,12 +497,12 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
493
497
|
value: { [key]: styleValue },
|
494
498
|
name: key,
|
495
499
|
attr: path.node
|
496
|
-
} : validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
|
500
|
+
} : import_validHTMLAttributes.validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
|
497
501
|
key === "__source" || key === "__self" ? attr : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key), didInline = !0, inlined.set(key, val), val);
|
498
502
|
});
|
499
503
|
return didInline ? (shouldPrintDebug && logger.info(` bailing flattening due to attributes ${attributes}`), attr) : attributes;
|
500
504
|
}
|
501
|
-
if (styleValue !== FAILED_EVAL)
|
505
|
+
if (styleValue !== import_constants.FAILED_EVAL)
|
502
506
|
return inlineWhenUnflattened.has(name) && (inlineWhenUnflattenedOGVals[name] = { styleValue, attr }), isValidStyleKey(name, staticConfig) ? (shouldPrintDebug && logger.info(` style: ${name} = ${styleValue}`), name in defaultProps || hasSetOptimized || (res.optimized++, hasSetOptimized = !0), {
|
503
507
|
type: "style",
|
504
508
|
value: { [name]: styleValue },
|
@@ -510,12 +514,12 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
510
514
|
const { operator, left, right } = value, lVal = attemptEvalSafe(left), rVal = attemptEvalSafe(right);
|
511
515
|
if (shouldPrintDebug && logger.info(
|
512
516
|
` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`
|
513
|
-
), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
|
517
|
+
), lVal !== import_constants.FAILED_EVAL && t.isConditionalExpression(right)) {
|
514
518
|
const ternary = addBinaryConditional(operator, left, right);
|
515
519
|
if (ternary)
|
516
520
|
return ternary;
|
517
521
|
}
|
518
|
-
if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
|
522
|
+
if (rVal !== import_constants.FAILED_EVAL && t.isConditionalExpression(left)) {
|
519
523
|
const ternary = addBinaryConditional(operator, right, left);
|
520
524
|
if (ternary)
|
521
525
|
return ternary;
|
@@ -687,7 +691,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
687
691
|
pseudoDescriptors[key] ? (prev2[key] = prev2[key] || {}, Object.assign(prev2[key], next[key])) : mergeToEnd2(prev2, key, next[key]);
|
688
692
|
};
|
689
693
|
var evaluateAttribute = evaluateAttribute2, isStaticObject = isStaticObject2, createTernariesFromObjectProperties = createTernariesFromObjectProperties2, mergeToEnd = mergeToEnd2, normalizeStyleWithoutVariants = normalizeStyleWithoutVariants2, mergeStyles = mergeStyles2;
|
690
|
-
const { staticConfig } = component, defaultProps = { ...staticConfig.defaultProps || {} }, variants = staticConfig.variants || {}, isTextView = staticConfig.isText || !1, validStyles = staticConfig
|
694
|
+
const { staticConfig } = component, defaultProps = { ...staticConfig.defaultProps || {} }, variants = staticConfig.variants || {}, isTextView = staticConfig.isText || !1, validStyles = (staticConfig == null ? void 0 : staticConfig.validStyles) ?? {};
|
691
695
|
let tagName = defaultProps.tag ?? (isTextView ? "span" : "div");
|
692
696
|
traversePath.get("openingElement").get("attributes").forEach((path) => {
|
693
697
|
const attr = path.node;
|
@@ -696,7 +700,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
696
700
|
const val = attr.value;
|
697
701
|
t.isStringLiteral(val) && (tagName = val.value);
|
698
702
|
}), shouldPrintDebug === "verbose" && console.info(` Start tag ${tagName}`);
|
699
|
-
const flatNode = getFlattenedNode
|
703
|
+
const flatNode = getFlattenedNode == null ? void 0 : getFlattenedNode({ isTextView, tag: tagName }), inlineProps = /* @__PURE__ */ new Set([
|
700
704
|
// adding some always inline props
|
701
705
|
"dataSet",
|
702
706
|
...restProps.inlineProps || [],
|
@@ -707,22 +711,22 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
707
711
|
"disableOptimization",
|
708
712
|
...isTargetingHTML ? [] : ["pressStyle", "focusStyle"],
|
709
713
|
// when using a non-CSS driver, de-opt on enterStyle/exitStyle
|
710
|
-
...tamaguiConfig
|
714
|
+
...tamaguiConfig != null && tamaguiConfig.animations.isReactNative ? ["enterStyle", "exitStyle"] : []
|
711
715
|
]), inlineWhenUnflattened = /* @__PURE__ */ new Set([
|
712
716
|
...staticConfig.inlineWhenUnflattened || []
|
713
|
-
]), staticNamespace = getStaticBindingsForScope(
|
717
|
+
]), staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(
|
714
718
|
traversePath.scope,
|
715
719
|
importsWhitelist,
|
716
720
|
sourcePath,
|
717
721
|
bindingCache,
|
718
722
|
shouldPrintDebug
|
719
|
-
), attemptEval = evaluateVars ? createEvaluator({
|
723
|
+
), attemptEval = evaluateVars ? (0, import_createEvaluator.createEvaluator)({
|
720
724
|
props: propsWithFileInfo,
|
721
725
|
staticNamespace,
|
722
726
|
sourcePath,
|
723
727
|
traversePath,
|
724
728
|
shouldPrintDebug
|
725
|
-
}) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
|
729
|
+
}) : import_evaluateAstNode.evaluateAstNode, attemptEvalSafe = (0, import_createEvaluator.createSafeEvaluator)(attemptEval);
|
726
730
|
if (shouldPrintDebug && logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`), couldntParse)
|
727
731
|
return;
|
728
732
|
tm.mark("jsx-element-flattened", !!shouldPrintDebug);
|
@@ -747,6 +751,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
747
751
|
debug: shouldPrintDebug
|
748
752
|
};
|
749
753
|
if (attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
|
754
|
+
var _a3;
|
750
755
|
try {
|
751
756
|
const res2 = evaluateAttribute2(path);
|
752
757
|
return tm.mark("jsx-element-evaluate-attr", !!shouldPrintDebug), res2 || path.remove(), res2;
|
@@ -757,21 +762,21 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
757
762
|
err.message,
|
758
763
|
shouldPrintDebug === "verbose" ? err.stack : ""
|
759
764
|
].join(" ")
|
760
|
-
), shouldPrintDebug === "verbose" && logger.info(`node ${path.node
|
765
|
+
), shouldPrintDebug === "verbose" && logger.info(`node ${(_a3 = path.node) == null ? void 0 : _a3.type}`)), inlined.set(`${Math.random()}`, "spread"), {
|
761
766
|
type: "attr",
|
762
767
|
value: path.node
|
763
768
|
};
|
764
769
|
}
|
765
|
-
}).flat(4).filter(isPresent), shouldPrintDebug && logger.info(
|
770
|
+
}).flat(4).filter(import_extractHelpers.isPresent), shouldPrintDebug && logger.info(
|
766
771
|
[` - attrs (before):
|
767
|
-
`, logLines(attrs.map(attrStr).join(", "))].join(" ")
|
772
|
+
`, (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" ")
|
768
773
|
), couldntParse || shouldDeopt) {
|
769
774
|
shouldPrintDebug && logger.info(
|
770
775
|
[" avoid optimizing:", { couldntParse, shouldDeopt }].join(" ")
|
771
776
|
), node.attributes = ogAttributes;
|
772
777
|
return;
|
773
778
|
}
|
774
|
-
const parentFn = findTopmostFunction(traversePath);
|
779
|
+
const parentFn = (0, import_findTopmostFunction.findTopmostFunction)(traversePath);
|
775
780
|
parentFn && modifiedComponents.add(parentFn);
|
776
781
|
const hasSpread = attrs.some(
|
777
782
|
(x) => x.type === "attr" && t.isJSXSpreadAttribute(x.value)
|
@@ -779,7 +784,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
779
784
|
let themeVal = inlined.get("theme");
|
780
785
|
platform2 !== "native" && inlined.delete("theme");
|
781
786
|
for (const [key] of [...inlined]) {
|
782
|
-
const isStaticObjectVariant = staticConfig.variants
|
787
|
+
const isStaticObjectVariant = ((_a2 = staticConfig.variants) == null ? void 0 : _a2[key]) && variantValues.has(key);
|
783
788
|
(INLINE_EXTRACTABLE[key] || isStaticObjectVariant) && inlined.delete(key);
|
784
789
|
}
|
785
790
|
const canFlattenProps = inlined.size === 0;
|
@@ -797,7 +802,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
797
802
|
return platform2 === "native" && (shouldFlatten = !1, skipMap = !0, inlined.set("theme", { value: t.stringLiteral(value) })), themeVal = { value: t.stringLiteral(value) }, [];
|
798
803
|
if (!isValidStyleKey(key, staticConfig))
|
799
804
|
return [];
|
800
|
-
const name = tamaguiConfig
|
805
|
+
const name = (tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[key]) || key;
|
801
806
|
if (value === void 0) {
|
802
807
|
logger.warn(
|
803
808
|
`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`
|
@@ -811,7 +816,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
811
816
|
t.objectExpression(
|
812
817
|
Object.keys(value).filter((k) => typeof value[k] < "u").map((k) => t.objectProperty(
|
813
818
|
t.identifier(k),
|
814
|
-
literalToAst(value[k])
|
819
|
+
(0, import_literalToAst.literalToAst)(value[k])
|
815
820
|
))
|
816
821
|
)
|
817
822
|
)
|
@@ -828,7 +833,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
828
833
|
attrs = attrs.reduce((out, cur) => {
|
829
834
|
const next = attrs[attrs.indexOf(cur) + 1];
|
830
835
|
if (cur.type === "ternary" && ternaries.push(cur.value), (!next || next.type !== "ternary") && ternaries.length) {
|
831
|
-
const normalized = normalizeTernaries(ternaries).map(
|
836
|
+
const normalized = (0, import_normalizeTernaries.normalizeTernaries)(ternaries).map(
|
832
837
|
({ alternate, consequent, ...rest }) => ({
|
833
838
|
type: "ternary",
|
834
839
|
value: {
|
@@ -877,7 +882,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
877
882
|
[
|
878
883
|
" flatten?",
|
879
884
|
shouldFlatten,
|
880
|
-
objToStr({
|
885
|
+
(0, import_extractHelpers.objToStr)({
|
881
886
|
hasSpread,
|
882
887
|
shouldDeopt,
|
883
888
|
canFlattenProps,
|
@@ -897,7 +902,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
897
902
|
}
|
898
903
|
shouldPrintDebug && logger.info(
|
899
904
|
[` - attrs (flattened):
|
900
|
-
`, logLines(attrs.map(attrStr).join(", "))].join(
|
905
|
+
`, (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(
|
901
906
|
" "
|
902
907
|
)
|
903
908
|
);
|
@@ -914,7 +919,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
914
919
|
if (t.isJSXSpreadAttribute(cur.value) || !t.isJSXIdentifier(cur.value.name))
|
915
920
|
continue;
|
916
921
|
const key2 = cur.value.name.name, value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
|
917
|
-
value !== FAILED_EVAL && mergeToEnd2(foundStaticProps, key2, value);
|
922
|
+
value !== import_constants.FAILED_EVAL && mergeToEnd2(foundStaticProps, key2, value);
|
918
923
|
}
|
919
924
|
}
|
920
925
|
const completeProps = {};
|
@@ -941,7 +946,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
941
946
|
);
|
942
947
|
if (out && isTargetingHTML) {
|
943
948
|
const cn = out.className;
|
944
|
-
out = createDOMProps(isTextView ? "span" : "div", out), out.className = cn;
|
949
|
+
out = (0, import_react_native_web_internals.createDOMProps)(isTextView ? "span" : "div", out), out.className = cn;
|
945
950
|
}
|
946
951
|
shouldPrintDebug && logger.info([" - expanded variant", name, out].join(" "));
|
947
952
|
for (const key2 in out) {
|
@@ -956,7 +961,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
956
961
|
value: t.jsxAttribute(
|
957
962
|
t.jsxIdentifier(key2),
|
958
963
|
t.jsxExpressionContainer(
|
959
|
-
typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)
|
964
|
+
typeof value2 == "string" ? t.stringLiteral(value2) : (0, import_literalToAst.literalToAst)(value2)
|
960
965
|
)
|
961
966
|
)
|
962
967
|
});
|
@@ -967,7 +972,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
967
972
|
if (cur.type !== "style")
|
968
973
|
return acc.push(cur), acc;
|
969
974
|
let key = Object.keys(cur.value)[0];
|
970
|
-
const value = cur.value[key], fullKey = tamaguiConfig
|
975
|
+
const value = cur.value[key], fullKey = tamaguiConfig == null ? void 0 : tamaguiConfig.shorthands[key];
|
971
976
|
return fullKey && (cur.value = { [fullKey]: value }, key = fullKey), disableExtractVariables && value[0] === "$" && (usedThemeKeys.has(key) || usedThemeKeys.has(fullKey)) ? (shouldPrintDebug && logger.info([` keeping variable inline: ${key} =`, value].join(" ")), acc.push({
|
972
977
|
type: "attr",
|
973
978
|
value: t.jsxAttribute(
|
@@ -977,7 +982,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
977
982
|
}), acc) : (acc.push(cur), acc);
|
978
983
|
}, []), tm.mark("jsx-element-expanded", !!shouldPrintDebug), shouldPrintDebug && logger.info(
|
979
984
|
[` - attrs (expanded):
|
980
|
-
`, logLines(attrs.map(attrStr).join(", "))].join(
|
985
|
+
`, (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(
|
981
986
|
" "
|
982
987
|
)
|
983
988
|
);
|
@@ -985,7 +990,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
985
990
|
const getProps = (props, includeProps = !1, debugName = "") => {
|
986
991
|
if (!props)
|
987
992
|
return shouldPrintDebug && logger.info([" getProps() no props"].join(" ")), {};
|
988
|
-
if (excludeProps
|
993
|
+
if (excludeProps != null && excludeProps.size)
|
989
994
|
for (const key in props)
|
990
995
|
excludeProps.has(key) && (shouldPrintDebug && logger.info([" delete excluded", key].join(" ")), delete props[key]);
|
991
996
|
try {
|
@@ -1015,10 +1020,10 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1015
1020
|
return options.experimentalFlattenThemesOnNative && usedThemeKeys.size > 0 && Object.entries(props).forEach(([key, value]) => {
|
1016
1021
|
usedThemeKeys.has(value) && (outProps[key] = value);
|
1017
1022
|
}), shouldPrintDebug && (logger.info(`(${debugName})`), logger.info(`
|
1018
|
-
getProps (props in): ${logLines(objToStr(props))}`), logger.info(
|
1023
|
+
getProps (props in): ${(0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(props))}`), logger.info(
|
1019
1024
|
`
|
1020
|
-
getProps (outProps): ${logLines(objToStr(outProps))}`
|
1021
|
-
)), out.fontFamily && (setPropsToFontFamily(outProps, out.fontFamily), shouldPrintDebug && logger.info(`
|
1025
|
+
getProps (outProps): ${(0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(outProps))}`
|
1026
|
+
)), out.fontFamily && ((0, import_propsToFontFamilyCache.setPropsToFontFamily)(outProps, out.fontFamily), shouldPrintDebug && logger.info(`
|
1022
1027
|
\u{1F4AC} new font fam: ${out.fontFamily}`)), outProps;
|
1023
1028
|
} catch (err) {
|
1024
1029
|
return logger.info(["error", err.message, err.stack].join(" ")), {};
|
@@ -1040,11 +1045,11 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1040
1045
|
value: t.jsxAttribute(
|
1041
1046
|
t.jsxIdentifier(key),
|
1042
1047
|
t.jsxExpressionContainer(
|
1043
|
-
typeof value == "string" ? t.stringLiteral(value) : literalToAst(value)
|
1048
|
+
typeof value == "string" ? t.stringLiteral(value) : (0, import_literalToAst.literalToAst)(value)
|
1044
1049
|
)
|
1045
1050
|
)
|
1046
1051
|
}), acc.push(cur), acc;
|
1047
|
-
if (prev
|
1052
|
+
if ((prev == null ? void 0 : prev.type) === "style")
|
1048
1053
|
return mergeStyles2(prev.value, cur.value), acc;
|
1049
1054
|
}
|
1050
1055
|
return prev = cur, acc.push(cur), acc;
|
@@ -1052,7 +1057,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1052
1057
|
[
|
1053
1058
|
` - attrs (combined \u{1F500}):
|
1054
1059
|
`,
|
1055
|
-
logLines(attrs.map(attrStr).join(", "))
|
1060
|
+
(0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))
|
1056
1061
|
].join(" ")
|
1057
1062
|
);
|
1058
1063
|
let getStyleError = null;
|
@@ -1061,15 +1066,15 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1061
1066
|
switch (shouldPrintDebug && console.info(` Processing ${attr.type}:`), attr.type) {
|
1062
1067
|
case "ternary": {
|
1063
1068
|
const a = getProps(attr.value.alternate, !1, "ternary.alternate"), c = getProps(attr.value.consequent, !1, "ternary.consequent");
|
1064
|
-
a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([" => tern ", attrStr(attr)].join(" "));
|
1069
|
+
a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([" => tern ", (0, import_extractHelpers.attrStr)(attr)].join(" "));
|
1065
1070
|
continue;
|
1066
1071
|
}
|
1067
1072
|
case "style": {
|
1068
1073
|
const styles = getProps(attr.value, !1, "style");
|
1069
1074
|
styles && (attr.value = styles), shouldPrintDebug && logger.info(
|
1070
|
-
[" * styles (in)", logLines(objToStr(attr.value))].join(" ")
|
1075
|
+
[" * styles (in)", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(attr.value))].join(" ")
|
1071
1076
|
), shouldPrintDebug && logger.info(
|
1072
|
-
[" * styles (out)", logLines(objToStr(styles))].join(" ")
|
1077
|
+
[" * styles (out)", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(styles))].join(" ")
|
1073
1078
|
);
|
1074
1079
|
continue;
|
1075
1080
|
}
|
@@ -1081,14 +1086,14 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1081
1086
|
const value = attemptEvalSafe(
|
1082
1087
|
attr.value.value || t.booleanLiteral(!0)
|
1083
1088
|
);
|
1084
|
-
if (value !== FAILED_EVAL) {
|
1089
|
+
if (value !== import_constants.FAILED_EVAL) {
|
1085
1090
|
const outProps = getProps({ [key]: value }, !0, `attr.${key}`), outKey = Object.keys(outProps)[0];
|
1086
1091
|
if (outKey) {
|
1087
1092
|
const outVal = outProps[outKey];
|
1088
1093
|
attr.value = t.jsxAttribute(
|
1089
1094
|
t.jsxIdentifier(outKey),
|
1090
1095
|
t.jsxExpressionContainer(
|
1091
|
-
typeof outVal == "string" ? t.stringLiteral(outVal) : literalToAst(outVal)
|
1096
|
+
typeof outVal == "string" ? t.stringLiteral(outVal) : (0, import_literalToAst.literalToAst)(outVal)
|
1092
1097
|
)
|
1093
1098
|
);
|
1094
1099
|
}
|
@@ -1102,7 +1107,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1102
1107
|
[
|
1103
1108
|
` - attrs (ternaries/combined):
|
1104
1109
|
`,
|
1105
|
-
logLines(attrs.map(attrStr).join(", "))
|
1110
|
+
(0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))
|
1106
1111
|
].join(" ")
|
1107
1112
|
), tm.mark("jsx-element-styles", !!shouldPrintDebug), getStyleError)
|
1108
1113
|
return logger.info([" \u26A0\uFE0F postprocessing error, deopt", getStyleError].join(" ")), node.attributes = ogAttributes, null;
|
@@ -1153,7 +1158,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1153
1158
|
staticConfig.neverFlatten ? "neverFlatten" : ""
|
1154
1159
|
].join(" ")
|
1155
1160
|
), logger.info(` - shouldFlatten/isFlattened: ${shouldFlatten}`), logger.info(` - attrs (end):
|
1156
|
-
${logLines(attrs.map(attrStr).join(", "))}`)), onExtractTag({
|
1161
|
+
${(0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))}`)), onExtractTag({
|
1157
1162
|
parserProps: propsWithFileInfo,
|
1158
1163
|
attrs,
|
1159
1164
|
node,
|
@@ -1180,12 +1185,13 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1180
1185
|
const all = Array.from(modifiedComponents);
|
1181
1186
|
shouldPrintDebug && logger.info(` [\u{1FA9D}] hook check ${all.length}`);
|
1182
1187
|
for (const comp of all)
|
1183
|
-
removeUnusedHooks(comp, shouldPrintDebug);
|
1188
|
+
(0, import_removeUnusedHooks.removeUnusedHooks)(comp, shouldPrintDebug);
|
1184
1189
|
}
|
1185
1190
|
return tm.done(shouldPrintDebug === "verbose"), res;
|
1186
1191
|
}
|
1187
1192
|
}
|
1188
|
-
export
|
1193
|
+
// Annotate the CommonJS export names for ESM import in node:
|
1194
|
+
0 && (module.exports = {
|
1189
1195
|
createExtractor
|
1190
|
-
};
|
1196
|
+
});
|
1191
1197
|
//# sourceMappingURL=createExtractor.js.map
|