@tamagui/static 1.88.21 → 1.88.23
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/esm/constants.native.js +4 -37
- package/dist/esm/constants.native.js.map +2 -2
- package/dist/esm/extractor/accessSafe.native.js +3 -32
- package/dist/esm/extractor/accessSafe.native.js.map +1 -1
- package/dist/esm/extractor/babelParse.native.js +3 -33
- package/dist/esm/extractor/babelParse.native.js.map +1 -1
- package/dist/esm/extractor/buildClassName.native.js +3 -33
- package/dist/esm/extractor/buildClassName.native.js.map +1 -1
- package/dist/esm/extractor/bundle.native.js +14 -39
- package/dist/esm/extractor/bundle.native.js.map +2 -2
- package/dist/esm/extractor/bundleConfig.native.js +36 -59
- package/dist/esm/extractor/bundleConfig.native.js.map +2 -2
- package/dist/esm/extractor/createEvaluator.native.js +12 -37
- package/dist/esm/extractor/createEvaluator.native.js.map +2 -2
- package/dist/esm/extractor/createExtractor.native.js +86 -87
- package/dist/esm/extractor/createExtractor.native.js.map +2 -2
- package/dist/esm/extractor/ensureImportingConcat.native.js +3 -32
- package/dist/esm/extractor/ensureImportingConcat.native.js.map +1 -1
- package/dist/esm/extractor/esbuildAliasPlugin.native.js +2 -23
- package/dist/esm/extractor/esbuildAliasPlugin.native.js.map +1 -1
- package/dist/esm/extractor/evaluateAstNode.native.js +3 -32
- package/dist/esm/extractor/evaluateAstNode.native.js.map +1 -1
- package/dist/esm/extractor/extractHelpers.native.js +11 -49
- package/dist/esm/extractor/extractHelpers.native.js.map +2 -2
- package/dist/esm/extractor/extractMediaStyle.native.js +10 -37
- package/dist/esm/extractor/extractMediaStyle.native.js.map +1 -1
- package/dist/esm/extractor/extractToClassNames.native.js +30 -43
- package/dist/esm/extractor/extractToClassNames.native.js.map +2 -2
- package/dist/esm/extractor/findTopmostFunction.native.js +2 -23
- package/dist/esm/extractor/findTopmostFunction.native.js.map +1 -1
- package/dist/esm/extractor/generateTamaguiStudioConfig.native.js +18 -45
- package/dist/esm/extractor/generateTamaguiStudioConfig.native.js.map +2 -2
- package/dist/esm/extractor/generatedUid.native.js +3 -32
- package/dist/esm/extractor/generatedUid.native.js.map +1 -1
- package/dist/esm/extractor/getPrefixLogs.native.js +2 -23
- package/dist/esm/extractor/getPrefixLogs.native.js.map +1 -1
- package/dist/esm/extractor/getPropValueFromAttributes.native.js +7 -34
- package/dist/esm/extractor/getPropValueFromAttributes.native.js.map +2 -2
- package/dist/esm/extractor/getSourceModule.native.js +3 -32
- package/dist/esm/extractor/getSourceModule.native.js.map +1 -1
- package/dist/esm/extractor/getStaticBindingsForScope.native.js +13 -39
- package/dist/esm/extractor/getStaticBindingsForScope.native.js.map +1 -1
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.js +4 -25
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.native.js.map +1 -1
- package/dist/esm/extractor/hoistClassNames.native.js +3 -32
- package/dist/esm/extractor/hoistClassNames.native.js.map +1 -1
- package/dist/esm/extractor/literalToAst.native.js +3 -33
- package/dist/esm/extractor/literalToAst.native.js.map +1 -1
- package/dist/esm/extractor/loadFile.native.js +0 -1
- package/dist/esm/extractor/loadFile.native.js.map +1 -1
- package/dist/esm/extractor/loadTamagui.native.js +60 -73
- package/dist/esm/extractor/loadTamagui.native.js.map +2 -2
- package/dist/esm/extractor/logLines.native.js +2 -23
- package/dist/esm/extractor/logLines.native.js.map +1 -1
- package/dist/esm/extractor/normalizeTernaries.native.js +7 -34
- package/dist/esm/extractor/normalizeTernaries.native.js.map +2 -2
- package/dist/esm/extractor/propsToFontFamilyCache.native.js +2 -25
- package/dist/esm/extractor/propsToFontFamilyCache.native.js.map +1 -1
- package/dist/esm/extractor/removeUnusedHooks.native.js +3 -32
- package/dist/esm/extractor/removeUnusedHooks.native.js.map +1 -1
- package/dist/esm/extractor/timer.native.js +2 -23
- package/dist/esm/extractor/timer.native.js.map +1 -1
- package/dist/esm/extractor/validHTMLAttributes.native.js +2 -23
- package/dist/esm/extractor/validHTMLAttributes.native.js.map +1 -1
- package/dist/esm/getPragmaOptions.native.js +2 -23
- package/dist/esm/getPragmaOptions.native.js.map +1 -1
- package/dist/esm/helpers/memoize.native.js +2 -23
- package/dist/esm/helpers/memoize.native.js.map +1 -1
- package/dist/esm/helpers/requireTamaguiCore.native.js +2 -23
- package/dist/esm/helpers/requireTamaguiCore.native.js.map +1 -1
- package/dist/esm/index.native.js +3 -22
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/minifyCSS.native.js +6 -34
- package/dist/esm/minifyCSS.native.js.map +2 -2
- package/dist/esm/registerRequire.native.js +6 -28
- package/dist/esm/registerRequire.native.js.map +1 -1
- package/dist/esm/server.native.js +5 -34
- package/dist/esm/server.native.js.map +2 -2
- package/dist/esm/setup.native.js +0 -1
- package/dist/esm/setup.native.js.map +1 -1
- package/dist/esm/static.native.js +12 -39
- package/dist/esm/static.native.js.map +1 -1
- package/dist/esm/types.native.js +0 -14
- package/dist/esm/types.native.js.map +2 -2
- package/dist/esm/webpackPlugin.native.js +2 -23
- package/dist/esm/webpackPlugin.native.js.map +1 -1
- package/package.json +14 -14
@@ -1,33 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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 createEvaluator_exports = {};
|
25
|
-
__export(createEvaluator_exports, {
|
26
|
-
createEvaluator: () => createEvaluator,
|
27
|
-
createSafeEvaluator: () => createSafeEvaluator
|
28
|
-
});
|
29
|
-
module.exports = __toCommonJS(createEvaluator_exports);
|
30
|
-
var import_vm = __toESM(require("vm")), import_generator = __toESM(require("@babel/generator")), t = __toESM(require("@babel/types")), import_esbuild = __toESM(require("esbuild")), import_constants = require("../constants"), import_evaluateAstNode = require("./evaluateAstNode");
|
1
|
+
import vm from "vm";
|
2
|
+
import generate from "@babel/generator";
|
3
|
+
import * as t from "@babel/types";
|
4
|
+
import esbuild from "esbuild";
|
5
|
+
import { FAILED_EVAL } from "../constants";
|
6
|
+
import { evaluateAstNode } from "./evaluateAstNode";
|
31
7
|
function createEvaluator({
|
32
8
|
props,
|
33
9
|
staticNamespace,
|
@@ -38,23 +14,22 @@ function createEvaluator({
|
|
38
14
|
const evalFn = (n) => {
|
39
15
|
if (t.isIdentifier(n) && typeof staticNamespace[n.name] < "u")
|
40
16
|
return staticNamespace[n.name];
|
41
|
-
const evalContext =
|
42
|
-
return shouldPrintDebug && console.info("evaluating", code),
|
17
|
+
const evalContext = vm.createContext(staticNamespace), codeWithTypescriptAnnotations = `(${generate(n).code})`, code = esbuild.transformSync(codeWithTypescriptAnnotations, { loader: "tsx" }).code.replace(/;\n$/, "");
|
18
|
+
return shouldPrintDebug && console.info("evaluating", code), vm.runInContext(code, evalContext);
|
43
19
|
};
|
44
|
-
return (n) =>
|
20
|
+
return (n) => evaluateAstNode(n, evalFn);
|
45
21
|
}
|
46
22
|
function createSafeEvaluator(attemptEval) {
|
47
23
|
return (n) => {
|
48
24
|
try {
|
49
25
|
return attemptEval(n);
|
50
26
|
} catch {
|
51
|
-
return
|
27
|
+
return FAILED_EVAL;
|
52
28
|
}
|
53
29
|
};
|
54
30
|
}
|
55
|
-
|
56
|
-
0 && (module.exports = {
|
31
|
+
export {
|
57
32
|
createEvaluator,
|
58
33
|
createSafeEvaluator
|
59
|
-
}
|
34
|
+
};
|
60
35
|
//# sourceMappingURL=createEvaluator.js.map
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/extractor/createEvaluator.ts"],
|
4
|
-
"mappings": "
|
5
|
-
"names": [
|
4
|
+
"mappings": "AAAA,OAAO,QAAQ;AAEf,OAAO,cAAc;AAErB,YAAY,OAAO;AACnB,OAAO,aAAa;AAEpB,SAAS,mBAAmB;AAE5B,SAAS,uBAAuB;AAEzB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AAED,QAAM,SAAS,CAAC,MAAc;AAE5B,QAAI,EAAE,aAAa,CAAC,KAAK,OAAO,gBAAgB,EAAE,IAAI,IAAM;AAC1D,aAAO,gBAAgB,EAAE,IAAI;AAE/B,UAAM,cAAc,GAAG,cAAc,eAAe,GAE9C,gCAAgC,IAAI,SAAS,CAAQ,EAAE,IAAI,KAC3D,OAAO,QACV,cAAc,+BAA+B,EAAE,QAAQ,MAAM,CAAC,EAC9D,KAAK,QAAQ,QAAQ,EAAE;AAE1B,WAAI,oBACF,QAAQ,KAAK,cAAc,IAAI,GAE1B,GAAG,aAAa,MAAM,WAAW;AAAA,EAC1C;AAEA,SAAO,CAAC,MACC,gBAAgB,GAAG,MAAM;AAEpC;AAEO,SAAS,oBAAoB,aAAiC;AACnE,SAAO,CAAC,MAAc;AACpB,QAAI;AACF,aAAO,YAAY,CAAC;AAAA,IACtB,QAAc;AACZ,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
5
|
+
"names": []
|
6
6
|
}
|
@@ -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
|
+
import { basename, relative } from "path";
|
2
|
+
import traverse from "@babel/traverse";
|
3
|
+
import * as t from "@babel/types";
|
4
|
+
import { Color, colorLog } from "@tamagui/cli-color";
|
5
|
+
import { createDOMProps } from "react-native-web-internals";
|
6
|
+
import { FAILED_EVAL } from "../constants";
|
7
|
+
import { requireTamaguiCore } from "../helpers/requireTamaguiCore";
|
8
|
+
import { createEvaluator, createSafeEvaluator } from "./createEvaluator";
|
9
|
+
import { evaluateAstNode } from "./evaluateAstNode";
|
10
|
+
import {
|
11
|
+
attrStr,
|
12
|
+
findComponentName,
|
13
|
+
getValidComponent,
|
14
|
+
getValidComponentsPaths,
|
15
|
+
getValidImport,
|
16
|
+
isPresent,
|
17
|
+
isValidImport,
|
18
|
+
objToStr
|
19
|
+
} from "./extractHelpers";
|
20
|
+
import { findTopmostFunction } from "./findTopmostFunction";
|
21
|
+
import { cleanupBeforeExit, getStaticBindingsForScope } from "./getStaticBindingsForScope";
|
22
|
+
import { literalToAst } from "./literalToAst";
|
23
|
+
import { loadTamagui, loadTamaguiSync } from "./loadTamagui";
|
24
|
+
import { logLines } from "./logLines";
|
25
|
+
import { normalizeTernaries } from "./normalizeTernaries";
|
26
|
+
import { setPropsToFontFamily } from "./propsToFontFamilyCache";
|
27
|
+
import { removeUnusedHooks } from "./removeUnusedHooks";
|
28
|
+
import { timer } from "./timer";
|
29
|
+
import { validHTMLAttributes } from "./validHTMLAttributes";
|
30
30
|
const UNTOUCHED_PROPS = {
|
31
31
|
key: !0,
|
32
32
|
style: !0,
|
@@ -66,16 +66,16 @@ 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 || (projectInfo =
|
69
|
+
return isFullyDisabled(props) ? null : projectInfo || (projectInfo = loadTamaguiSync(props));
|
70
70
|
}
|
71
71
|
async function load(props) {
|
72
|
-
return isFullyDisabled(props) ? null : projectInfo || (projectInfo = await
|
72
|
+
return isFullyDisabled(props) ? null : projectInfo || (projectInfo = await loadTamagui(props));
|
73
73
|
}
|
74
74
|
return {
|
75
75
|
options: {
|
76
76
|
logger
|
77
77
|
},
|
78
|
-
cleanupBeforeExit
|
78
|
+
cleanupBeforeExit,
|
79
79
|
loadTamagui: load,
|
80
80
|
loadTamaguiSync: loadSync,
|
81
81
|
getTamagui() {
|
@@ -122,7 +122,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
122
122
|
propMapper,
|
123
123
|
proxyThemeVariables,
|
124
124
|
pseudoDescriptors
|
125
|
-
} =
|
125
|
+
} = requireTamaguiCore(platform2);
|
126
126
|
let shouldPrintDebug = options.shouldPrintDebug || !1;
|
127
127
|
if (disable === !0 || Array.isArray(disable) && disable.includes(sourcePath))
|
128
128
|
return null;
|
@@ -141,7 +141,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
141
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
142
|
(_b = staticConfig.variants) != null && _b[name] || (_c = projectInfo == null ? void 0 : projectInfo.tamaguiConfig) != null && _c.shorthands[name] || name[0] === "$" && mediaQueryConfig[name.slice(1)]);
|
143
143
|
}
|
144
|
-
const isTargetingHTML = platform2 === "web", ogDebug = shouldPrintDebug, tm =
|
144
|
+
const isTargetingHTML = platform2 === "web", ogDebug = shouldPrintDebug, tm = timer(), propsWithFileInfo = {
|
145
145
|
...options,
|
146
146
|
sourcePath,
|
147
147
|
allLoadedComponents: components ? [...components] : []
|
@@ -173,7 +173,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
173
173
|
`allLoadedComponent modules ${propsWithFileInfo.allLoadedComponents.map((k) => k.moduleName).join(", ")}`
|
174
174
|
), logger.info(
|
175
175
|
`valid import paths: ${JSON.stringify(
|
176
|
-
|
176
|
+
getValidComponentsPaths(propsWithFileInfo)
|
177
177
|
)}`
|
178
178
|
));
|
179
179
|
let doesUseValidImport = !1, hasImportedTheme = !1;
|
@@ -181,20 +181,20 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
181
181
|
for (const bodyPath of body) {
|
182
182
|
if (bodyPath.type !== "ImportDeclaration")
|
183
183
|
continue;
|
184
|
-
const node = "node" in bodyPath ? bodyPath.node : bodyPath, moduleName = node.source.value, valid =
|
184
|
+
const node = "node" in bodyPath ? bodyPath.node : bodyPath, moduleName = node.source.value, valid = isValidImport(propsWithFileInfo, moduleName);
|
185
185
|
if (valid && importDeclarations.push(node), shouldPrintDebug === "verbose" && logger.info(` - import ${moduleName} ${valid}`), extractStyledDefinitions && valid && node.specifiers.some((specifier) => specifier.local.name === "styled")) {
|
186
186
|
doesUseValidImport = !0;
|
187
187
|
break;
|
188
188
|
}
|
189
189
|
if (valid) {
|
190
190
|
const names = node.specifiers.map((specifier) => specifier.local.name), isValidComponent = names.some(
|
191
|
-
(name) => !!(
|
191
|
+
(name) => !!(isValidImport(propsWithFileInfo, moduleName, name) || validHooks[name])
|
192
192
|
);
|
193
193
|
if (shouldPrintDebug === "verbose" && logger.info(
|
194
194
|
` - import ${isValidComponent ? "\u2705" : "\u21E3"} - ${names.join(
|
195
195
|
", "
|
196
196
|
)} from '${moduleName}' - (valid: ${JSON.stringify(
|
197
|
-
|
197
|
+
getValidComponentsPaths(propsWithFileInfo)
|
198
198
|
)})`
|
199
199
|
), isValidComponent) {
|
200
200
|
doesUseValidImport = !0;
|
@@ -211,7 +211,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
211
211
|
const importDeclaration = importDeclarations.find(
|
212
212
|
(dec) => dec.specifiers.some((spec) => spec.local.name === componentName)
|
213
213
|
);
|
214
|
-
return importDeclaration ?
|
214
|
+
return importDeclaration ? getValidImport(
|
215
215
|
propsWithFileInfo,
|
216
216
|
importDeclaration.source.value,
|
217
217
|
componentName
|
@@ -219,7 +219,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
219
219
|
}
|
220
220
|
tm.mark("import-check", !!shouldPrintDebug);
|
221
221
|
let couldntParse = !1;
|
222
|
-
const modifiedComponents = /* @__PURE__ */ new Set(), bindingCache = {}, callTraverse = (a) => fileOrPath.type === "File" ? (
|
222
|
+
const modifiedComponents = /* @__PURE__ */ new Set(), bindingCache = {}, callTraverse = (a) => fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a), shouldDisableExtraction = disableExtraction === !0 || Array.isArray(disableExtraction) && disableExtraction.includes(sourcePath);
|
223
223
|
let programPath = null;
|
224
224
|
const res = {
|
225
225
|
styled: 0,
|
@@ -254,7 +254,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
254
254
|
shouldPrintDebug && logger.info(
|
255
255
|
`Unknown component: ${variableName} = styled(${parentName}) attempting dynamic load: ${sourcePath}`
|
256
256
|
);
|
257
|
-
const out2 =
|
257
|
+
const out2 = loadTamaguiSync({
|
258
258
|
forceExports: !0,
|
259
259
|
components: [sourcePath],
|
260
260
|
cacheKey: version
|
@@ -268,8 +268,8 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
268
268
|
...out2.components
|
269
269
|
], Component = out2.components.flatMap((x) => x.nameToInfo[variableName] ?? [])[0], !out2.cached) {
|
270
270
|
const foundNames = (_a2 = out2.components) == null ? void 0 : _a2.map((x) => Object.keys(x.nameToInfo).join(", ")).join(", ").trim();
|
271
|
-
foundNames &&
|
272
|
-
|
271
|
+
foundNames && colorLog(
|
272
|
+
Color.FgYellow,
|
273
273
|
` | Tamagui found dynamic components: ${foundNames}`
|
274
274
|
);
|
275
275
|
}
|
@@ -295,18 +295,18 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
295
295
|
"focusStyle",
|
296
296
|
"hoverStyle",
|
297
297
|
"pressStyle"
|
298
|
-
]), skipped = /* @__PURE__ */ new Set(), styles = {}, staticNamespace =
|
298
|
+
]), skipped = /* @__PURE__ */ new Set(), styles = {}, staticNamespace = getStaticBindingsForScope(
|
299
299
|
path.scope,
|
300
300
|
importsWhitelist,
|
301
301
|
sourcePath,
|
302
302
|
bindingCache,
|
303
303
|
shouldPrintDebug
|
304
|
-
), attemptEval = evaluateVars ?
|
304
|
+
), attemptEval = evaluateVars ? createEvaluator({
|
305
305
|
props: propsWithFileInfo,
|
306
306
|
staticNamespace,
|
307
307
|
sourcePath,
|
308
308
|
shouldPrintDebug
|
309
|
-
}) :
|
309
|
+
}) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
|
310
310
|
for (const property of definition.properties) {
|
311
311
|
if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || // TODO make pseudos and variants work
|
312
312
|
// skip pseudos
|
@@ -316,7 +316,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
316
316
|
continue;
|
317
317
|
}
|
318
318
|
const out2 = attemptEvalSafe(property.value);
|
319
|
-
out2 ===
|
319
|
+
out2 === FAILED_EVAL ? skipped.add(property) : styles[property.key.name] = out2;
|
320
320
|
}
|
321
321
|
const out = getSplitStyles(
|
322
322
|
styles,
|
@@ -358,27 +358,27 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
358
358
|
JSXElement(traversePath) {
|
359
359
|
var _a2;
|
360
360
|
tm.mark("jsx-element", !!shouldPrintDebug);
|
361
|
-
const node = traversePath.node.openingElement, ogAttributes = node.attributes.map((attr) => ({ ...attr })), componentName =
|
361
|
+
const node = traversePath.node.openingElement, ogAttributes = node.attributes.map((attr) => ({ ...attr })), componentName = findComponentName(traversePath.scope), closingElement = traversePath.node.closingElement;
|
362
362
|
if (shouldPrintDebug && logger.info(` start ${node.name}`), closingElement && t.isJSXMemberExpression(closingElement == null ? void 0 : closingElement.name) || !t.isJSXIdentifier(node.name)) {
|
363
363
|
shouldPrintDebug && logger.info(" skip non-identifier element");
|
364
364
|
return;
|
365
365
|
}
|
366
366
|
const binding = traversePath.scope.getBinding(node.name.name);
|
367
367
|
let moduleName = "";
|
368
|
-
if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !
|
368
|
+
if (binding && t.isImportDeclaration(binding.path.parent) && (moduleName = binding.path.parent.source.value, !isValidImport(propsWithFileInfo, moduleName, binding.identifier.name))) {
|
369
369
|
shouldPrintDebug && logger.info(
|
370
370
|
` - Binding for ${componentName} not internal import or from components ${binding.identifier.name} in ${moduleName}`
|
371
371
|
);
|
372
372
|
return;
|
373
373
|
}
|
374
|
-
const component =
|
374
|
+
const component = getValidComponent(propsWithFileInfo, moduleName, node.name.name);
|
375
375
|
if (!component || !component.staticConfig) {
|
376
376
|
shouldPrintDebug && logger.info(` - No Tamagui conf on this: ${node.name.name}`);
|
377
377
|
return;
|
378
378
|
}
|
379
379
|
const originalNodeName = node.name.name;
|
380
380
|
res.found++;
|
381
|
-
const filePath = `./${
|
381
|
+
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(
|
382
382
|
(n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug"
|
383
383
|
).map((n) => n.value === null ? !0 : t.isStringLiteral(n.value) ? n.value.value : !1)[0];
|
384
384
|
if (debugPropValue && (shouldPrintDebug = debugPropValue), shouldPrintDebug && (logger.info(`
|
@@ -398,7 +398,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
398
398
|
), node.attributes.unshift(
|
399
399
|
t.jsxAttribute(
|
400
400
|
t.jsxIdentifier("data-at"),
|
401
|
-
t.stringLiteral(`${
|
401
|
+
t.stringLiteral(`${basename(filePath)}:${lineNumbers}`)
|
402
402
|
)
|
403
403
|
)), shouldDisableExtraction) {
|
404
404
|
shouldPrintDebug === "verbose" && console.info(" Extraction disabled");
|
@@ -488,7 +488,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
488
488
|
const styleValue = attemptEvalSafe(value);
|
489
489
|
if (!variants[name] && !isValidStyleKey(name, staticConfig)) {
|
490
490
|
let keys = [name], out = null;
|
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 =
|
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 = createDOMProps(isTextView ? "span" : "div", out), delete out.className), keys = Object.keys(out));
|
492
492
|
let didInline = !1;
|
493
493
|
const attributes = keys.map((key) => {
|
494
494
|
const val = out[key];
|
@@ -497,12 +497,12 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
497
497
|
value: { [key]: styleValue },
|
498
498
|
name: key,
|
499
499
|
attr: path.node
|
500
|
-
} :
|
500
|
+
} : validHTMLAttributes[key] || key.startsWith("aria-") || key.startsWith("data-") || // this is debug stuff added by vite / new jsx transform
|
501
501
|
key === "__source" || key === "__self" ? attr : (shouldPrintDebug && logger.info(" ! inlining, non-static " + key), didInline = !0, inlined.set(key, val), val);
|
502
502
|
});
|
503
503
|
return didInline ? (shouldPrintDebug && logger.info(` bailing flattening due to attributes ${attributes}`), attr) : attributes;
|
504
504
|
}
|
505
|
-
if (styleValue !==
|
505
|
+
if (styleValue !== FAILED_EVAL)
|
506
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), {
|
507
507
|
type: "style",
|
508
508
|
value: { [name]: styleValue },
|
@@ -514,12 +514,12 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
514
514
|
const { operator, left, right } = value, lVal = attemptEvalSafe(left), rVal = attemptEvalSafe(right);
|
515
515
|
if (shouldPrintDebug && logger.info(
|
516
516
|
` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`
|
517
|
-
), lVal !==
|
517
|
+
), lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
|
518
518
|
const ternary = addBinaryConditional(operator, left, right);
|
519
519
|
if (ternary)
|
520
520
|
return ternary;
|
521
521
|
}
|
522
|
-
if (rVal !==
|
522
|
+
if (rVal !== FAILED_EVAL && t.isConditionalExpression(left)) {
|
523
523
|
const ternary = addBinaryConditional(operator, right, left);
|
524
524
|
if (ternary)
|
525
525
|
return ternary;
|
@@ -714,19 +714,19 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
714
714
|
...tamaguiConfig != null && tamaguiConfig.animations.isReactNative ? ["enterStyle", "exitStyle"] : []
|
715
715
|
]), inlineWhenUnflattened = /* @__PURE__ */ new Set([
|
716
716
|
...staticConfig.inlineWhenUnflattened || []
|
717
|
-
]), staticNamespace =
|
717
|
+
]), staticNamespace = getStaticBindingsForScope(
|
718
718
|
traversePath.scope,
|
719
719
|
importsWhitelist,
|
720
720
|
sourcePath,
|
721
721
|
bindingCache,
|
722
722
|
shouldPrintDebug
|
723
|
-
), attemptEval = evaluateVars ?
|
723
|
+
), attemptEval = evaluateVars ? createEvaluator({
|
724
724
|
props: propsWithFileInfo,
|
725
725
|
staticNamespace,
|
726
726
|
sourcePath,
|
727
727
|
traversePath,
|
728
728
|
shouldPrintDebug
|
729
|
-
}) :
|
729
|
+
}) : evaluateAstNode, attemptEvalSafe = createSafeEvaluator(attemptEval);
|
730
730
|
if (shouldPrintDebug && logger.info(` staticNamespace ${Object.keys(staticNamespace).join(", ")}`), couldntParse)
|
731
731
|
return;
|
732
732
|
tm.mark("jsx-element-flattened", !!shouldPrintDebug);
|
@@ -767,16 +767,16 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
767
767
|
value: path.node
|
768
768
|
};
|
769
769
|
}
|
770
|
-
}).flat(4).filter(
|
770
|
+
}).flat(4).filter(isPresent), shouldPrintDebug && logger.info(
|
771
771
|
[` - attrs (before):
|
772
|
-
`,
|
772
|
+
`, logLines(attrs.map(attrStr).join(", "))].join(" ")
|
773
773
|
), couldntParse || shouldDeopt) {
|
774
774
|
shouldPrintDebug && logger.info(
|
775
775
|
[" avoid optimizing:", { couldntParse, shouldDeopt }].join(" ")
|
776
776
|
), node.attributes = ogAttributes;
|
777
777
|
return;
|
778
778
|
}
|
779
|
-
const parentFn =
|
779
|
+
const parentFn = findTopmostFunction(traversePath);
|
780
780
|
parentFn && modifiedComponents.add(parentFn);
|
781
781
|
const hasSpread = attrs.some(
|
782
782
|
(x) => x.type === "attr" && t.isJSXSpreadAttribute(x.value)
|
@@ -816,7 +816,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
816
816
|
t.objectExpression(
|
817
817
|
Object.keys(value).filter((k) => typeof value[k] < "u").map((k) => t.objectProperty(
|
818
818
|
t.identifier(k),
|
819
|
-
|
819
|
+
literalToAst(value[k])
|
820
820
|
))
|
821
821
|
)
|
822
822
|
)
|
@@ -833,7 +833,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
833
833
|
attrs = attrs.reduce((out, cur) => {
|
834
834
|
const next = attrs[attrs.indexOf(cur) + 1];
|
835
835
|
if (cur.type === "ternary" && ternaries.push(cur.value), (!next || next.type !== "ternary") && ternaries.length) {
|
836
|
-
const normalized =
|
836
|
+
const normalized = normalizeTernaries(ternaries).map(
|
837
837
|
({ alternate, consequent, ...rest }) => ({
|
838
838
|
type: "ternary",
|
839
839
|
value: {
|
@@ -882,7 +882,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
882
882
|
[
|
883
883
|
" flatten?",
|
884
884
|
shouldFlatten,
|
885
|
-
|
885
|
+
objToStr({
|
886
886
|
hasSpread,
|
887
887
|
shouldDeopt,
|
888
888
|
canFlattenProps,
|
@@ -902,7 +902,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
902
902
|
}
|
903
903
|
shouldPrintDebug && logger.info(
|
904
904
|
[` - attrs (flattened):
|
905
|
-
`,
|
905
|
+
`, logLines(attrs.map(attrStr).join(", "))].join(
|
906
906
|
" "
|
907
907
|
)
|
908
908
|
);
|
@@ -919,7 +919,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
919
919
|
if (t.isJSXSpreadAttribute(cur.value) || !t.isJSXIdentifier(cur.value.name))
|
920
920
|
continue;
|
921
921
|
const key2 = cur.value.name.name, value = attemptEvalSafe(cur.value.value || t.booleanLiteral(!0));
|
922
|
-
value !==
|
922
|
+
value !== FAILED_EVAL && mergeToEnd2(foundStaticProps, key2, value);
|
923
923
|
}
|
924
924
|
}
|
925
925
|
const completeProps = {};
|
@@ -946,7 +946,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
946
946
|
);
|
947
947
|
if (out && isTargetingHTML) {
|
948
948
|
const cn = out.className;
|
949
|
-
out =
|
949
|
+
out = createDOMProps(isTextView ? "span" : "div", out), out.className = cn;
|
950
950
|
}
|
951
951
|
shouldPrintDebug && logger.info([" - expanded variant", name, out].join(" "));
|
952
952
|
for (const key2 in out) {
|
@@ -961,7 +961,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
961
961
|
value: t.jsxAttribute(
|
962
962
|
t.jsxIdentifier(key2),
|
963
963
|
t.jsxExpressionContainer(
|
964
|
-
typeof value2 == "string" ? t.stringLiteral(value2) :
|
964
|
+
typeof value2 == "string" ? t.stringLiteral(value2) : literalToAst(value2)
|
965
965
|
)
|
966
966
|
)
|
967
967
|
});
|
@@ -982,7 +982,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
982
982
|
}), acc) : (acc.push(cur), acc);
|
983
983
|
}, []), tm.mark("jsx-element-expanded", !!shouldPrintDebug), shouldPrintDebug && logger.info(
|
984
984
|
[` - attrs (expanded):
|
985
|
-
`,
|
985
|
+
`, logLines(attrs.map(attrStr).join(", "))].join(
|
986
986
|
" "
|
987
987
|
)
|
988
988
|
);
|
@@ -1020,10 +1020,10 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1020
1020
|
return options.experimentalFlattenThemesOnNative && usedThemeKeys.size > 0 && Object.entries(props).forEach(([key, value]) => {
|
1021
1021
|
usedThemeKeys.has(value) && (outProps[key] = value);
|
1022
1022
|
}), shouldPrintDebug && (logger.info(`(${debugName})`), logger.info(`
|
1023
|
-
getProps (props in): ${
|
1023
|
+
getProps (props in): ${logLines(objToStr(props))}`), logger.info(
|
1024
1024
|
`
|
1025
|
-
getProps (outProps): ${
|
1026
|
-
)), out.fontFamily && (
|
1025
|
+
getProps (outProps): ${logLines(objToStr(outProps))}`
|
1026
|
+
)), out.fontFamily && (setPropsToFontFamily(outProps, out.fontFamily), shouldPrintDebug && logger.info(`
|
1027
1027
|
\u{1F4AC} new font fam: ${out.fontFamily}`)), outProps;
|
1028
1028
|
} catch (err) {
|
1029
1029
|
return logger.info(["error", err.message, err.stack].join(" ")), {};
|
@@ -1045,7 +1045,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1045
1045
|
value: t.jsxAttribute(
|
1046
1046
|
t.jsxIdentifier(key),
|
1047
1047
|
t.jsxExpressionContainer(
|
1048
|
-
typeof value == "string" ? t.stringLiteral(value) :
|
1048
|
+
typeof value == "string" ? t.stringLiteral(value) : literalToAst(value)
|
1049
1049
|
)
|
1050
1050
|
)
|
1051
1051
|
}), acc.push(cur), acc;
|
@@ -1057,7 +1057,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1057
1057
|
[
|
1058
1058
|
` - attrs (combined \u{1F500}):
|
1059
1059
|
`,
|
1060
|
-
|
1060
|
+
logLines(attrs.map(attrStr).join(", "))
|
1061
1061
|
].join(" ")
|
1062
1062
|
);
|
1063
1063
|
let getStyleError = null;
|
@@ -1066,15 +1066,15 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1066
1066
|
switch (shouldPrintDebug && console.info(` Processing ${attr.type}:`), attr.type) {
|
1067
1067
|
case "ternary": {
|
1068
1068
|
const a = getProps(attr.value.alternate, !1, "ternary.alternate"), c = getProps(attr.value.consequent, !1, "ternary.consequent");
|
1069
|
-
a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([" => tern ",
|
1069
|
+
a && (attr.value.alternate = a), c && (attr.value.consequent = c), shouldPrintDebug && logger.info([" => tern ", attrStr(attr)].join(" "));
|
1070
1070
|
continue;
|
1071
1071
|
}
|
1072
1072
|
case "style": {
|
1073
1073
|
const styles = getProps(attr.value, !1, "style");
|
1074
1074
|
styles && (attr.value = styles), shouldPrintDebug && logger.info(
|
1075
|
-
[" * styles (in)",
|
1075
|
+
[" * styles (in)", logLines(objToStr(attr.value))].join(" ")
|
1076
1076
|
), shouldPrintDebug && logger.info(
|
1077
|
-
[" * styles (out)",
|
1077
|
+
[" * styles (out)", logLines(objToStr(styles))].join(" ")
|
1078
1078
|
);
|
1079
1079
|
continue;
|
1080
1080
|
}
|
@@ -1086,14 +1086,14 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1086
1086
|
const value = attemptEvalSafe(
|
1087
1087
|
attr.value.value || t.booleanLiteral(!0)
|
1088
1088
|
);
|
1089
|
-
if (value !==
|
1089
|
+
if (value !== FAILED_EVAL) {
|
1090
1090
|
const outProps = getProps({ [key]: value }, !0, `attr.${key}`), outKey = Object.keys(outProps)[0];
|
1091
1091
|
if (outKey) {
|
1092
1092
|
const outVal = outProps[outKey];
|
1093
1093
|
attr.value = t.jsxAttribute(
|
1094
1094
|
t.jsxIdentifier(outKey),
|
1095
1095
|
t.jsxExpressionContainer(
|
1096
|
-
typeof outVal == "string" ? t.stringLiteral(outVal) :
|
1096
|
+
typeof outVal == "string" ? t.stringLiteral(outVal) : literalToAst(outVal)
|
1097
1097
|
)
|
1098
1098
|
);
|
1099
1099
|
}
|
@@ -1107,7 +1107,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1107
1107
|
[
|
1108
1108
|
` - attrs (ternaries/combined):
|
1109
1109
|
`,
|
1110
|
-
|
1110
|
+
logLines(attrs.map(attrStr).join(", "))
|
1111
1111
|
].join(" ")
|
1112
1112
|
), tm.mark("jsx-element-styles", !!shouldPrintDebug), getStyleError)
|
1113
1113
|
return logger.info([" \u26A0\uFE0F postprocessing error, deopt", getStyleError].join(" ")), node.attributes = ogAttributes, null;
|
@@ -1158,7 +1158,7 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1158
1158
|
staticConfig.neverFlatten ? "neverFlatten" : ""
|
1159
1159
|
].join(" ")
|
1160
1160
|
), logger.info(` - shouldFlatten/isFlattened: ${shouldFlatten}`), logger.info(` - attrs (end):
|
1161
|
-
${
|
1161
|
+
${logLines(attrs.map(attrStr).join(", "))}`)), onExtractTag({
|
1162
1162
|
parserProps: propsWithFileInfo,
|
1163
1163
|
attrs,
|
1164
1164
|
node,
|
@@ -1185,13 +1185,12 @@ function createExtractor({ logger = console, platform = "web" } = { logger: cons
|
|
1185
1185
|
const all = Array.from(modifiedComponents);
|
1186
1186
|
shouldPrintDebug && logger.info(` [\u{1FA9D}] hook check ${all.length}`);
|
1187
1187
|
for (const comp of all)
|
1188
|
-
|
1188
|
+
removeUnusedHooks(comp, shouldPrintDebug);
|
1189
1189
|
}
|
1190
1190
|
return tm.done(shouldPrintDebug === "verbose"), res;
|
1191
1191
|
}
|
1192
1192
|
}
|
1193
|
-
|
1194
|
-
0 && (module.exports = {
|
1193
|
+
export {
|
1195
1194
|
createExtractor
|
1196
|
-
}
|
1195
|
+
};
|
1197
1196
|
//# sourceMappingURL=createExtractor.js.map
|