@tamagui/static 1.0.0-beta.200 → 1.0.0-beta.204
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/constants.js +8 -0
- package/dist/cjs/extractor/accessSafe.js +4 -0
- package/dist/cjs/extractor/babelParse.js +5 -0
- package/dist/cjs/extractor/babelParse.js.map +2 -2
- package/dist/cjs/extractor/buildClassName.js +4 -0
- package/dist/cjs/extractor/createEvaluator.js +5 -0
- package/dist/cjs/extractor/createExtractor.js +840 -772
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/ensureImportingConcat.js +4 -0
- package/dist/cjs/extractor/evaluateAstNode.js +4 -0
- package/dist/cjs/extractor/extractHelpers.js +11 -0
- package/dist/cjs/extractor/extractMediaStyle.js +7 -2
- package/dist/cjs/extractor/extractMediaStyle.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.js +19 -10
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/cjs/extractor/findTopmostFunction.js +4 -0
- package/dist/cjs/extractor/generatedUid.js +4 -0
- package/dist/cjs/extractor/getPrefixLogs.js +4 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js +4 -0
- package/dist/cjs/extractor/getSourceModule.js +4 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js +4 -0
- package/dist/cjs/extractor/hoistClassNames.js +4 -0
- package/dist/cjs/extractor/literalToAst.js +5 -0
- package/dist/cjs/extractor/loadTamagui.js +67 -47
- package/dist/cjs/extractor/loadTamagui.js.map +2 -2
- package/dist/cjs/extractor/logLines.js +4 -0
- package/dist/cjs/extractor/normalizeTernaries.js +4 -0
- package/dist/cjs/extractor/removeUnusedHooks.js +4 -0
- package/dist/cjs/extractor/timer.js +46 -0
- package/dist/cjs/extractor/timer.js.map +7 -0
- package/dist/cjs/extractor/validHTMLAttributes.js +4 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/patchReactNativeWeb.js +23 -7
- package/dist/cjs/patchReactNativeWeb.js.map +2 -2
- package/dist/esm/extractor/babelParse.js.map +2 -2
- package/dist/esm/extractor/createExtractor.js +850 -785
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/extractMediaStyle.js +2 -2
- package/dist/esm/extractor/extractMediaStyle.js.map +2 -2
- package/dist/esm/extractor/extractToClassNames.js +15 -10
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/extractor/loadTamagui.js +63 -47
- package/dist/esm/extractor/loadTamagui.js.map +2 -2
- package/dist/esm/extractor/timer.js +24 -0
- package/dist/esm/extractor/timer.js.map +7 -0
- package/dist/esm/patchReactNativeWeb.js +19 -7
- package/dist/esm/patchReactNativeWeb.js.map +2 -2
- package/dist/jsx/extractor/createExtractor.js +850 -785
- package/dist/jsx/extractor/extractMediaStyle.js +2 -2
- package/dist/jsx/extractor/extractToClassNames.js +15 -10
- package/dist/jsx/extractor/loadTamagui.js +63 -47
- package/dist/jsx/extractor/timer.js +23 -0
- package/dist/jsx/patchReactNativeWeb.js +19 -7
- package/package.json +23 -23
- package/types/extractor/babelParse.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts +2 -0
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +1 -1
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts +2 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/timer.d.ts +5 -0
- package/types/extractor/timer.d.ts.map +1 -0
- package/types/patchReactNativeWeb.d.ts.map +1 -1
|
@@ -53,6 +53,7 @@ __export(createExtractor_exports, {
|
|
|
53
53
|
createExtractor: () => createExtractor
|
|
54
54
|
});
|
|
55
55
|
module.exports = __toCommonJS(createExtractor_exports);
|
|
56
|
+
var import_path = require("path");
|
|
56
57
|
var import_traverse = __toESM(require("@babel/traverse"));
|
|
57
58
|
var t = __toESM(require("@babel/types"));
|
|
58
59
|
var import_core_node = require("@tamagui/core-node");
|
|
@@ -68,6 +69,7 @@ var import_loadTamagui = require("./loadTamagui");
|
|
|
68
69
|
var import_logLines = require("./logLines");
|
|
69
70
|
var import_normalizeTernaries = require("./normalizeTernaries");
|
|
70
71
|
var import_removeUnusedHooks = require("./removeUnusedHooks");
|
|
72
|
+
var import_timer = require("./timer");
|
|
71
73
|
var import_validHTMLAttributes = require("./validHTMLAttributes");
|
|
72
74
|
const UNTOUCHED_PROPS = {
|
|
73
75
|
key: true,
|
|
@@ -90,11 +92,11 @@ const validHooks = {
|
|
|
90
92
|
};
|
|
91
93
|
const createTernary = /* @__PURE__ */ __name((x) => x, "createTernary");
|
|
92
94
|
function createExtractor() {
|
|
95
|
+
if (!process.env.TAMAGUI_TARGET) {
|
|
96
|
+
console.log('\u26A0\uFE0F Please set process.env.TAMAGUI_TARGET to either "web" or "native"');
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
93
99
|
const shouldAddDebugProp = !process.env.npm_package_dependencies_next && process.env.TAMAGUI_TARGET !== "native" && process.env.IDENTIFY_TAGS !== "false" && (process.env.NODE_ENV === "development" || process.env.DEBUG || process.env.IDENTIFY_TAGS);
|
|
94
|
-
require("esbuild-register/dist/node").register({
|
|
95
|
-
target: "es2019",
|
|
96
|
-
format: "cjs"
|
|
97
|
-
});
|
|
98
100
|
let loadedTamaguiConfig;
|
|
99
101
|
let hasLogged = false;
|
|
100
102
|
return {
|
|
@@ -142,12 +144,18 @@ function createExtractor() {
|
|
|
142
144
|
if (!Array.isArray(props.components)) {
|
|
143
145
|
throw new Error(`Must provide components array with list of Tamagui component modules`);
|
|
144
146
|
}
|
|
147
|
+
const ogDebug = shouldPrintDebug;
|
|
148
|
+
const tm = (0, import_timer.timer)();
|
|
145
149
|
const { components, tamaguiConfig } = (0, import_loadTamagui.loadTamagui)({
|
|
146
150
|
config,
|
|
147
151
|
components: props.components || ["tamagui"]
|
|
148
152
|
});
|
|
153
|
+
if (shouldPrintDebug === "verbose") {
|
|
154
|
+
console.log("tamagui.config.ts:", { components, config });
|
|
155
|
+
}
|
|
156
|
+
tm.mark("load-tamagui", shouldPrintDebug === "verbose");
|
|
149
157
|
loadedTamaguiConfig = tamaguiConfig;
|
|
150
|
-
const defaultTheme = tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]];
|
|
158
|
+
const defaultTheme = (0, import_core_node.proxyThemeVariables)(tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]]);
|
|
151
159
|
const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
|
152
160
|
const isInternalImport = /* @__PURE__ */ __name((importStr) => {
|
|
153
161
|
return (0, import_extractHelpers.isInsideTamagui)(sourcePath) && importStr[0] === ".";
|
|
@@ -159,6 +167,9 @@ function createExtractor() {
|
|
|
159
167
|
obj[name] = components[name];
|
|
160
168
|
return obj;
|
|
161
169
|
}, {});
|
|
170
|
+
if (shouldPrintDebug === "verbose") {
|
|
171
|
+
console.log("validComponents", Object.keys(validComponents));
|
|
172
|
+
}
|
|
162
173
|
let doesUseValidImport = false;
|
|
163
174
|
let hasImportedTheme = false;
|
|
164
175
|
for (const bodyPath of body) {
|
|
@@ -166,11 +177,16 @@ function createExtractor() {
|
|
|
166
177
|
continue;
|
|
167
178
|
const node = "node" in bodyPath ? bodyPath.node : bodyPath;
|
|
168
179
|
const from = node.source.value;
|
|
169
|
-
|
|
170
|
-
|
|
180
|
+
const isValidImport = props.components.includes(from) || isInternalImport(from);
|
|
181
|
+
if (isValidImport) {
|
|
182
|
+
const isValidComponent = node.specifiers.some((specifier) => {
|
|
171
183
|
const name = specifier.local.name;
|
|
172
184
|
return validComponents[name] || validHooks[name];
|
|
173
|
-
})
|
|
185
|
+
});
|
|
186
|
+
if (shouldPrintDebug === "verbose") {
|
|
187
|
+
console.log("import from", from, { isValidComponent });
|
|
188
|
+
}
|
|
189
|
+
if (isValidComponent) {
|
|
174
190
|
doesUseValidImport = true;
|
|
175
191
|
break;
|
|
176
192
|
}
|
|
@@ -182,6 +198,7 @@ function createExtractor() {
|
|
|
182
198
|
if (!doesUseValidImport) {
|
|
183
199
|
return null;
|
|
184
200
|
}
|
|
201
|
+
tm.mark("import-check", shouldPrintDebug === "verbose");
|
|
185
202
|
let couldntParse = false;
|
|
186
203
|
const modifiedComponents = /* @__PURE__ */ new Set();
|
|
187
204
|
const bindingCache = {};
|
|
@@ -203,6 +220,7 @@ function createExtractor() {
|
|
|
203
220
|
},
|
|
204
221
|
JSXElement(traversePath) {
|
|
205
222
|
var _a2, _b2, _c;
|
|
223
|
+
tm.mark("jsx-element", shouldPrintDebug === "verbose");
|
|
206
224
|
const node = traversePath.node.openingElement;
|
|
207
225
|
const ogAttributes = node.attributes;
|
|
208
226
|
const componentName = (0, import_extractHelpers.findComponentName)(traversePath.scope);
|
|
@@ -229,912 +247,957 @@ function createExtractor() {
|
|
|
229
247
|
}
|
|
230
248
|
const originalNodeName = node.name.name;
|
|
231
249
|
res.found++;
|
|
232
|
-
|
|
233
|
-
console.log(`
|
|
234
|
-
<${originalNodeName} />`);
|
|
235
|
-
}
|
|
236
|
-
const filePath = sourcePath.replace(process.cwd(), ".");
|
|
250
|
+
const filePath = `./${(0, import_path.relative)(process.cwd(), sourcePath)}`;
|
|
237
251
|
const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
if (disableExtraction) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const { staticConfig } = component;
|
|
253
|
-
const isTextView = staticConfig.isText || false;
|
|
254
|
-
const validStyles = (staticConfig == null ? void 0 : staticConfig.validStyles) ?? {};
|
|
255
|
-
function isValidStyleKey(name) {
|
|
256
|
-
var _a3;
|
|
257
|
-
return !!(!!validStyles[name] || !!import_core_node.pseudos[name] || ((_a3 = staticConfig.variants) == null ? void 0 : _a3[name]) || tamaguiConfig.shorthands[name] || (name[0] === "$" ? !!import_core_node.mediaQueryConfig[name.slice(1)] : false));
|
|
258
|
-
}
|
|
259
|
-
__name(isValidStyleKey, "isValidStyleKey");
|
|
260
|
-
let tagName = ((_a2 = staticConfig.defaultProps) == null ? void 0 : _a2.tag) ?? (isTextView ? "span" : "div");
|
|
261
|
-
traversePath.get("openingElement").get("attributes").forEach((path) => {
|
|
262
|
-
const attr = path.node;
|
|
263
|
-
if (t.isJSXSpreadAttribute(attr))
|
|
264
|
-
return;
|
|
265
|
-
if (attr.name.name !== "tag")
|
|
266
|
-
return;
|
|
267
|
-
const val = attr.value;
|
|
268
|
-
if (!t.isStringLiteral(val))
|
|
269
|
-
return;
|
|
270
|
-
tagName = val.value;
|
|
271
|
-
});
|
|
272
|
-
const flatNode = getFlattenedNode({ isTextView, tag: tagName });
|
|
273
|
-
const inlineProps = /* @__PURE__ */ new Set([
|
|
274
|
-
...props.inlineProps || [],
|
|
275
|
-
...staticConfig.inlineProps || []
|
|
276
|
-
]);
|
|
277
|
-
const deoptProps = /* @__PURE__ */ new Set([
|
|
278
|
-
...props.deoptProps || [],
|
|
279
|
-
...staticConfig.deoptProps || []
|
|
280
|
-
]);
|
|
281
|
-
const staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug);
|
|
282
|
-
const attemptEval = !evaluateVars ? import_evaluateAstNode.evaluateAstNode : (0, import_createEvaluator.createEvaluator)({
|
|
283
|
-
tamaguiConfig,
|
|
284
|
-
staticNamespace,
|
|
285
|
-
sourcePath,
|
|
286
|
-
traversePath,
|
|
287
|
-
shouldPrintDebug
|
|
288
|
-
});
|
|
289
|
-
const attemptEvalSafe = (0, import_createEvaluator.createSafeEvaluator)(attemptEval);
|
|
290
|
-
if (shouldPrintDebug) {
|
|
291
|
-
console.log(" staticNamespace", Object.keys(staticNamespace).join(", "));
|
|
252
|
+
const tagId = [componentName, `${node.name.name}`, `${filePath}:${lineNumbers}`].filter(Boolean);
|
|
253
|
+
const debugPropValue = node.attributes.filter((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug").map((n) => {
|
|
254
|
+
if (n.value === null)
|
|
255
|
+
return true;
|
|
256
|
+
if (t.isStringLiteral(n.value))
|
|
257
|
+
return n.value.value;
|
|
258
|
+
return false;
|
|
259
|
+
})[0];
|
|
260
|
+
if (debugPropValue) {
|
|
261
|
+
shouldPrintDebug = debugPropValue;
|
|
292
262
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (arg !== void 0) {
|
|
311
|
-
try {
|
|
312
|
-
if (typeof arg !== "object" || arg == null) {
|
|
313
|
-
if (shouldPrintDebug) {
|
|
314
|
-
console.log(" non object or null arg", arg);
|
|
315
|
-
}
|
|
316
|
-
flattenedAttrs.push(attr);
|
|
317
|
-
} else {
|
|
318
|
-
for (const k in arg) {
|
|
319
|
-
const value = arg[k];
|
|
320
|
-
if (!value && typeof value === "object") {
|
|
321
|
-
console.log("shouldnt we handle this?", k, value, arg);
|
|
322
|
-
continue;
|
|
263
|
+
try {
|
|
264
|
+
let isValidStyleKey = function(name) {
|
|
265
|
+
var _a3;
|
|
266
|
+
return !!(!!validStyles[name] || !!import_core_node.pseudos[name] || ((_a3 = staticConfig.variants) == null ? void 0 : _a3[name]) || tamaguiConfig.shorthands[name] || (name[0] === "$" ? !!import_core_node.mediaQueryConfig[name.slice(1)] : false));
|
|
267
|
+
}, evaluateAttribute = function(path) {
|
|
268
|
+
const attribute = path.node;
|
|
269
|
+
const attr = { type: "attr", value: attribute };
|
|
270
|
+
if (t.isJSXSpreadAttribute(attribute)) {
|
|
271
|
+
const arg = attribute.argument;
|
|
272
|
+
const conditional = t.isConditionalExpression(arg) ? [arg.test, arg.consequent, arg.alternate] : t.isLogicalExpression(arg) && arg.operator === "&&" ? [arg.left, arg.right, null] : null;
|
|
273
|
+
if (conditional) {
|
|
274
|
+
const [test, alt, cons] = conditional;
|
|
275
|
+
if (!test)
|
|
276
|
+
throw new Error(`no test`);
|
|
277
|
+
if ([alt, cons].some((side) => side && !isExtractable(side))) {
|
|
278
|
+
if (shouldPrintDebug) {
|
|
279
|
+
console.log("not extractable", alt, cons);
|
|
323
280
|
}
|
|
324
|
-
|
|
281
|
+
return attr;
|
|
325
282
|
}
|
|
283
|
+
return [
|
|
284
|
+
...createTernariesFromObjectProperties(test, alt) || [],
|
|
285
|
+
...cons && createTernariesFromObjectProperties(t.unaryExpression("!", test), cons) || []
|
|
286
|
+
].map((ternary) => ({
|
|
287
|
+
type: "ternary",
|
|
288
|
+
value: ternary
|
|
289
|
+
}));
|
|
326
290
|
}
|
|
327
|
-
} catch (err) {
|
|
328
|
-
console.warn("cant parse spread, caught err", err);
|
|
329
|
-
couldntParse = true;
|
|
330
291
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (staticConfig.defaultProps) {
|
|
338
|
-
for (const key in staticConfig.defaultProps) {
|
|
339
|
-
if (isValidStyleKey(key)) {
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
const serialize = require("babel-literal-to-ast");
|
|
343
|
-
const val = staticConfig.defaultProps[key];
|
|
344
|
-
try {
|
|
345
|
-
const serializedDefaultProp = serialize(val);
|
|
346
|
-
node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier(key), typeof val === "string" ? t.stringLiteral(val) : t.jsxExpressionContainer(serializedDefaultProp)));
|
|
347
|
-
} catch (err) {
|
|
348
|
-
console.warn(`\u26A0\uFE0F Error evaluating default prop for component ${node.name.name}, prop ${key}
|
|
349
|
-
error: ${err}
|
|
350
|
-
value:`, val, "\n defaultProps:", staticConfig.defaultProps);
|
|
292
|
+
if (t.isJSXSpreadAttribute(attribute) || !attribute.name || typeof attribute.name.name !== "string") {
|
|
293
|
+
if (shouldPrintDebug) {
|
|
294
|
+
console.log(" ! inlining, spread attr");
|
|
295
|
+
}
|
|
296
|
+
inlined.set(`${Math.random()}`, "spread");
|
|
297
|
+
return attr;
|
|
351
298
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
|
|
359
|
-
try {
|
|
360
|
-
const res2 = evaluateAttribute(path);
|
|
361
|
-
if (!res2) {
|
|
362
|
-
path.remove();
|
|
299
|
+
const name = attribute.name.name;
|
|
300
|
+
if (excludeProps == null ? void 0 : excludeProps.has(name)) {
|
|
301
|
+
if (shouldPrintDebug) {
|
|
302
|
+
console.log(" excluding prop", name);
|
|
303
|
+
}
|
|
304
|
+
return null;
|
|
363
305
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
306
|
+
if (inlineProps.has(name)) {
|
|
307
|
+
inlined.set(name, name);
|
|
308
|
+
if (shouldPrintDebug) {
|
|
309
|
+
console.log(" ! inlining, inline prop", name);
|
|
310
|
+
}
|
|
311
|
+
return attr;
|
|
369
312
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}).flat(4).filter(import_extractHelpers.isPresent);
|
|
376
|
-
if (shouldPrintDebug) {
|
|
377
|
-
console.log(" - attrs (before):\n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
378
|
-
}
|
|
379
|
-
function evaluateAttribute(path) {
|
|
380
|
-
const attribute = path.node;
|
|
381
|
-
const attr = { type: "attr", value: attribute };
|
|
382
|
-
if (t.isJSXSpreadAttribute(attribute)) {
|
|
383
|
-
const arg = attribute.argument;
|
|
384
|
-
const conditional = t.isConditionalExpression(arg) ? [arg.test, arg.consequent, arg.alternate] : t.isLogicalExpression(arg) && arg.operator === "&&" ? [arg.left, arg.right, null] : null;
|
|
385
|
-
if (conditional) {
|
|
386
|
-
const [test, alt, cons] = conditional;
|
|
387
|
-
if (!test)
|
|
388
|
-
throw new Error(`no test`);
|
|
389
|
-
if ([alt, cons].some((side) => side && !isExtractable(side))) {
|
|
390
|
-
if (shouldPrintDebug) {
|
|
391
|
-
console.log("not extractable", alt, cons);
|
|
392
|
-
}
|
|
393
|
-
return attr;
|
|
313
|
+
if (deoptProps.has(name)) {
|
|
314
|
+
shouldDeopt = true;
|
|
315
|
+
inlined.set(name, name);
|
|
316
|
+
if (shouldPrintDebug) {
|
|
317
|
+
console.log(" ! inlining, deopted prop", name);
|
|
394
318
|
}
|
|
395
|
-
return
|
|
396
|
-
...createTernariesFromObjectProperties(test, alt) || [],
|
|
397
|
-
...cons && createTernariesFromObjectProperties(t.unaryExpression("!", test), cons) || []
|
|
398
|
-
].map((ternary) => ({
|
|
399
|
-
type: "ternary",
|
|
400
|
-
value: ternary
|
|
401
|
-
}));
|
|
319
|
+
return attr;
|
|
402
320
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (shouldPrintDebug) {
|
|
406
|
-
console.log(" ! inlining, spread attr");
|
|
321
|
+
if (UNTOUCHED_PROPS[name]) {
|
|
322
|
+
return attr;
|
|
407
323
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
const name = attribute.name.name;
|
|
412
|
-
if (excludeProps == null ? void 0 : excludeProps.has(name)) {
|
|
413
|
-
if (shouldPrintDebug) {
|
|
414
|
-
console.log(" excluding prop", name);
|
|
324
|
+
if (INLINE_EXTRACTABLE[name]) {
|
|
325
|
+
inlined.set(name, INLINE_EXTRACTABLE[name]);
|
|
326
|
+
return attr;
|
|
415
327
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (inlineProps.has(name)) {
|
|
419
|
-
inlined.set(name, name);
|
|
420
|
-
if (shouldPrintDebug) {
|
|
421
|
-
console.log(" ! inlining, inline prop", name);
|
|
328
|
+
if (name.startsWith("data-")) {
|
|
329
|
+
return attr;
|
|
422
330
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
331
|
+
if (name[0] === "$" && t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
|
|
332
|
+
if (disableExtractInlineMedia) {
|
|
333
|
+
return attr;
|
|
334
|
+
}
|
|
335
|
+
const shortname = name.slice(1);
|
|
336
|
+
if (import_core_node.mediaQueryConfig[shortname]) {
|
|
337
|
+
const expression = attribute.value.expression;
|
|
338
|
+
if (!t.isJSXEmptyExpression(expression)) {
|
|
339
|
+
const ternaries2 = createTernariesFromObjectProperties(t.stringLiteral(shortname), expression, {
|
|
340
|
+
inlineMediaQuery: shortname
|
|
341
|
+
});
|
|
342
|
+
if (ternaries2) {
|
|
343
|
+
return ternaries2.map((value2) => ({
|
|
344
|
+
type: "ternary",
|
|
345
|
+
value: value2
|
|
346
|
+
}));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
430
350
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
351
|
+
const [value, valuePath] = (() => {
|
|
352
|
+
if (t.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
|
|
353
|
+
return [attribute.value.expression, path.get("value")];
|
|
354
|
+
} else {
|
|
355
|
+
return [attribute.value, path.get("value")];
|
|
356
|
+
}
|
|
357
|
+
})();
|
|
358
|
+
const remove = /* @__PURE__ */ __name(() => {
|
|
359
|
+
Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove();
|
|
360
|
+
}, "remove");
|
|
361
|
+
if (name === "ref") {
|
|
362
|
+
if (shouldPrintDebug) {
|
|
363
|
+
console.log(" ! inlining, ref", name);
|
|
364
|
+
}
|
|
365
|
+
inlined.set("ref", "ref");
|
|
445
366
|
return attr;
|
|
446
367
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
368
|
+
if (name === "tag") {
|
|
369
|
+
return {
|
|
370
|
+
type: "attr",
|
|
371
|
+
value: path.node
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
if (disableExtractVariables) {
|
|
375
|
+
if (value) {
|
|
376
|
+
if (value.type === "StringLiteral" && value.value[0] === "$") {
|
|
377
|
+
if (shouldPrintDebug) {
|
|
378
|
+
console.log(` ! inlining, native disable extract: ${name} =`, value.value);
|
|
379
|
+
}
|
|
380
|
+
inlined.set(name, true);
|
|
381
|
+
return attr;
|
|
459
382
|
}
|
|
460
383
|
}
|
|
461
384
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return [attribute.value.expression, path.get("value")];
|
|
466
|
-
} else {
|
|
467
|
-
return [attribute.value, path.get("value")];
|
|
468
|
-
}
|
|
469
|
-
})();
|
|
470
|
-
const remove = /* @__PURE__ */ __name(() => {
|
|
471
|
-
Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove();
|
|
472
|
-
}, "remove");
|
|
473
|
-
if (name === "ref") {
|
|
474
|
-
if (shouldPrintDebug) {
|
|
475
|
-
console.log(" ! inlining, ref", name);
|
|
385
|
+
if (name === "theme") {
|
|
386
|
+
inlined.set("theme", attr.value);
|
|
387
|
+
return attr;
|
|
476
388
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
389
|
+
const styleValue = attemptEvalSafe(value);
|
|
390
|
+
if (!isValidStyleKey(name)) {
|
|
391
|
+
let keys = [name];
|
|
392
|
+
let out = null;
|
|
393
|
+
if (staticConfig.propMapper) {
|
|
394
|
+
out = staticConfig.propMapper(name, styleValue, defaultTheme, staticConfig.defaultProps, "auto");
|
|
395
|
+
if (out) {
|
|
396
|
+
out = import_core_node.rnw.createDOMProps(isTextView ? "span" : "div", out);
|
|
397
|
+
delete out.className;
|
|
398
|
+
keys = Object.keys(out);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
let didInline = false;
|
|
402
|
+
const attributes = keys.map((key) => {
|
|
403
|
+
const val = out[key];
|
|
404
|
+
if (isValidStyleKey(key)) {
|
|
405
|
+
return {
|
|
406
|
+
type: "style",
|
|
407
|
+
value: { [name]: styleValue },
|
|
408
|
+
name,
|
|
409
|
+
attr: path.node
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
if (import_validHTMLAttributes.validHTMLAttributes[key]) {
|
|
413
|
+
return attr;
|
|
414
|
+
}
|
|
489
415
|
if (shouldPrintDebug) {
|
|
490
|
-
console.log(
|
|
416
|
+
console.log(" ! inlining, non-static", key);
|
|
417
|
+
}
|
|
418
|
+
didInline = true;
|
|
419
|
+
inlined.set(key, val);
|
|
420
|
+
return val;
|
|
421
|
+
});
|
|
422
|
+
if (didInline) {
|
|
423
|
+
if (shouldPrintDebug) {
|
|
424
|
+
console.log(" bailing flattening due to attributes", attributes);
|
|
491
425
|
}
|
|
492
|
-
inlined.set(name, true);
|
|
493
426
|
return attr;
|
|
494
427
|
}
|
|
428
|
+
return attributes;
|
|
495
429
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
let didInline = false;
|
|
510
|
-
const attributes = keys.map((key) => {
|
|
511
|
-
const val = out[key];
|
|
512
|
-
if (isValidStyleKey(key)) {
|
|
430
|
+
if (styleValue !== import_constants.FAILED_EVAL) {
|
|
431
|
+
if (isValidStyleKey(name)) {
|
|
432
|
+
if (shouldPrintDebug) {
|
|
433
|
+
console.log(` style: ${name} =`, styleValue);
|
|
434
|
+
}
|
|
435
|
+
if (!(name in staticConfig.defaultProps)) {
|
|
436
|
+
if (!hasSetOptimized) {
|
|
437
|
+
res.optimized++;
|
|
438
|
+
hasSetOptimized = true;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
513
441
|
return {
|
|
514
442
|
type: "style",
|
|
515
443
|
value: { [name]: styleValue },
|
|
516
444
|
name,
|
|
517
445
|
attr: path.node
|
|
518
446
|
};
|
|
447
|
+
} else {
|
|
448
|
+
inlined.set(name, true);
|
|
449
|
+
return attr;
|
|
519
450
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
type: "attr",
|
|
523
|
-
value: t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer((0, import_literalToAst.literalToAst)(val)))
|
|
524
|
-
};
|
|
525
|
-
}
|
|
451
|
+
}
|
|
452
|
+
if (t.isBinaryExpression(value)) {
|
|
526
453
|
if (shouldPrintDebug) {
|
|
527
|
-
console.log(
|
|
454
|
+
console.log(` binary expression ${name} = `, value);
|
|
528
455
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
});
|
|
533
|
-
if (didInline) {
|
|
534
|
-
console.log("we inlined something off", { attributes });
|
|
535
|
-
return attr;
|
|
536
|
-
}
|
|
537
|
-
return attributes;
|
|
538
|
-
}
|
|
539
|
-
if (styleValue !== import_constants.FAILED_EVAL) {
|
|
540
|
-
if (isValidStyleKey(name)) {
|
|
456
|
+
const { operator, left, right } = value;
|
|
457
|
+
const lVal = attemptEvalSafe(left);
|
|
458
|
+
const rVal = attemptEvalSafe(right);
|
|
541
459
|
if (shouldPrintDebug) {
|
|
542
|
-
console.log(`
|
|
460
|
+
console.log(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`);
|
|
543
461
|
}
|
|
544
|
-
if (
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
462
|
+
if (lVal !== import_constants.FAILED_EVAL && t.isConditionalExpression(right)) {
|
|
463
|
+
const ternary = addBinaryConditional(operator, left, right);
|
|
464
|
+
if (ternary)
|
|
465
|
+
return ternary;
|
|
466
|
+
}
|
|
467
|
+
if (rVal !== import_constants.FAILED_EVAL && t.isConditionalExpression(left)) {
|
|
468
|
+
const ternary = addBinaryConditional(operator, right, left);
|
|
469
|
+
if (ternary)
|
|
470
|
+
return ternary;
|
|
471
|
+
}
|
|
472
|
+
if (shouldPrintDebug) {
|
|
473
|
+
console.log(` evalBinaryExpression cant extract`);
|
|
549
474
|
}
|
|
550
|
-
return {
|
|
551
|
-
type: "style",
|
|
552
|
-
value: { [name]: styleValue },
|
|
553
|
-
name,
|
|
554
|
-
attr: path.node
|
|
555
|
-
};
|
|
556
|
-
} else {
|
|
557
475
|
inlined.set(name, true);
|
|
558
476
|
return attr;
|
|
559
477
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
const lVal = attemptEvalSafe(left);
|
|
567
|
-
const rVal = attemptEvalSafe(right);
|
|
568
|
-
if (shouldPrintDebug) {
|
|
569
|
-
console.log(` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`);
|
|
570
|
-
}
|
|
571
|
-
if (lVal !== import_constants.FAILED_EVAL && t.isConditionalExpression(right)) {
|
|
572
|
-
const ternary = addBinaryConditional(operator, left, right);
|
|
573
|
-
if (ternary)
|
|
574
|
-
return ternary;
|
|
575
|
-
}
|
|
576
|
-
if (rVal !== import_constants.FAILED_EVAL && t.isConditionalExpression(left)) {
|
|
577
|
-
const ternary = addBinaryConditional(operator, right, left);
|
|
578
|
-
if (ternary)
|
|
579
|
-
return ternary;
|
|
478
|
+
const staticConditional = getStaticConditional(value);
|
|
479
|
+
if (staticConditional) {
|
|
480
|
+
if (shouldPrintDebug === "verbose") {
|
|
481
|
+
console.log(` static conditional ${name}`, value);
|
|
482
|
+
}
|
|
483
|
+
return { type: "ternary", value: staticConditional };
|
|
580
484
|
}
|
|
581
|
-
|
|
582
|
-
|
|
485
|
+
const staticLogical = getStaticLogical(value);
|
|
486
|
+
if (staticLogical) {
|
|
487
|
+
if (shouldPrintDebug === "verbose") {
|
|
488
|
+
console.log(` static ternary ${name} = `, value);
|
|
489
|
+
}
|
|
490
|
+
return { type: "ternary", value: staticLogical };
|
|
583
491
|
}
|
|
584
492
|
inlined.set(name, true);
|
|
585
|
-
return attr;
|
|
586
|
-
}
|
|
587
|
-
const staticConditional = getStaticConditional(value);
|
|
588
|
-
if (staticConditional) {
|
|
589
493
|
if (shouldPrintDebug) {
|
|
590
|
-
console.log(`
|
|
494
|
+
console.log(` ! inline no match ${name}`, value);
|
|
591
495
|
}
|
|
592
|
-
return
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
console.log(` static ternary ${name} = `, value);
|
|
598
|
-
}
|
|
599
|
-
return { type: "ternary", value: staticLogical };
|
|
600
|
-
}
|
|
601
|
-
inlined.set(name, true);
|
|
602
|
-
if (shouldPrintDebug) {
|
|
603
|
-
console.log(` ! inline no match ${name}`, value);
|
|
604
|
-
}
|
|
605
|
-
return attr;
|
|
606
|
-
function addBinaryConditional(operator, staticExpr, cond) {
|
|
607
|
-
if (getStaticConditional(cond)) {
|
|
608
|
-
const alt = attemptEval(t.binaryExpression(operator, staticExpr, cond.alternate));
|
|
609
|
-
const cons = attemptEval(t.binaryExpression(operator, staticExpr, cond.consequent));
|
|
610
|
-
if (shouldPrintDebug) {
|
|
611
|
-
console.log(" binaryConditional", cond.test, cons, alt);
|
|
612
|
-
}
|
|
613
|
-
return {
|
|
614
|
-
type: "ternary",
|
|
615
|
-
value: {
|
|
616
|
-
test: cond.test,
|
|
617
|
-
remove,
|
|
618
|
-
alternate: { [name]: alt },
|
|
619
|
-
consequent: { [name]: cons }
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
return null;
|
|
624
|
-
}
|
|
625
|
-
__name(addBinaryConditional, "addBinaryConditional");
|
|
626
|
-
function getStaticConditional(value2) {
|
|
627
|
-
if (t.isConditionalExpression(value2)) {
|
|
628
|
-
try {
|
|
629
|
-
if (shouldPrintDebug) {
|
|
630
|
-
console.log("attempt", value2.alternate, value2.consequent);
|
|
631
|
-
}
|
|
632
|
-
const aVal = attemptEval(value2.alternate);
|
|
633
|
-
const cVal = attemptEval(value2.consequent);
|
|
496
|
+
return attr;
|
|
497
|
+
function addBinaryConditional(operator, staticExpr, cond) {
|
|
498
|
+
if (getStaticConditional(cond)) {
|
|
499
|
+
const alt = attemptEval(t.binaryExpression(operator, staticExpr, cond.alternate));
|
|
500
|
+
const cons = attemptEval(t.binaryExpression(operator, staticExpr, cond.consequent));
|
|
634
501
|
if (shouldPrintDebug) {
|
|
635
|
-
|
|
636
|
-
console.log(" static ternary", type, cVal, aVal);
|
|
502
|
+
console.log(" binaryConditional", cond.test, cons, alt);
|
|
637
503
|
}
|
|
638
504
|
return {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
505
|
+
type: "ternary",
|
|
506
|
+
value: {
|
|
507
|
+
test: cond.test,
|
|
508
|
+
remove,
|
|
509
|
+
alternate: { [name]: alt },
|
|
510
|
+
consequent: { [name]: cons }
|
|
511
|
+
}
|
|
643
512
|
};
|
|
644
|
-
} catch (err) {
|
|
645
|
-
if (shouldPrintDebug) {
|
|
646
|
-
console.log(" cant eval ternary", err.message);
|
|
647
|
-
}
|
|
648
513
|
}
|
|
514
|
+
return null;
|
|
649
515
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
function getStaticLogical(value2) {
|
|
654
|
-
if (t.isLogicalExpression(value2)) {
|
|
655
|
-
if (value2.operator === "&&") {
|
|
516
|
+
__name(addBinaryConditional, "addBinaryConditional");
|
|
517
|
+
function getStaticConditional(value2) {
|
|
518
|
+
if (t.isConditionalExpression(value2)) {
|
|
656
519
|
try {
|
|
657
|
-
const
|
|
520
|
+
const aVal = attemptEval(value2.alternate);
|
|
521
|
+
const cVal = attemptEval(value2.consequent);
|
|
658
522
|
if (shouldPrintDebug) {
|
|
659
|
-
|
|
523
|
+
const type = value2.test.type;
|
|
524
|
+
console.log(" static ternary", type, cVal, aVal);
|
|
660
525
|
}
|
|
661
526
|
return {
|
|
662
|
-
test: value2.
|
|
527
|
+
test: value2.test,
|
|
663
528
|
remove,
|
|
664
|
-
consequent: { [name]:
|
|
665
|
-
alternate:
|
|
529
|
+
consequent: { [name]: cVal },
|
|
530
|
+
alternate: { [name]: aVal }
|
|
666
531
|
};
|
|
667
532
|
} catch (err) {
|
|
668
533
|
if (shouldPrintDebug) {
|
|
669
|
-
console.log("
|
|
534
|
+
console.log(" cant eval ternary", err.message);
|
|
670
535
|
}
|
|
671
536
|
}
|
|
672
537
|
}
|
|
538
|
+
return null;
|
|
673
539
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
540
|
+
__name(getStaticConditional, "getStaticConditional");
|
|
541
|
+
function getStaticLogical(value2) {
|
|
542
|
+
if (t.isLogicalExpression(value2)) {
|
|
543
|
+
if (value2.operator === "&&") {
|
|
544
|
+
try {
|
|
545
|
+
const val = attemptEval(value2.right);
|
|
546
|
+
if (shouldPrintDebug) {
|
|
547
|
+
console.log(" staticLogical", value2.left, name, val);
|
|
548
|
+
}
|
|
549
|
+
return {
|
|
550
|
+
test: value2.left,
|
|
551
|
+
remove,
|
|
552
|
+
consequent: { [name]: val },
|
|
553
|
+
alternate: null
|
|
554
|
+
};
|
|
555
|
+
} catch (err) {
|
|
556
|
+
if (shouldPrintDebug) {
|
|
557
|
+
console.log(" cant static eval logical", err);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return null;
|
|
684
563
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
564
|
+
__name(getStaticLogical, "getStaticLogical");
|
|
565
|
+
}, isExtractable = function(obj) {
|
|
566
|
+
return t.isObjectExpression(obj) && obj.properties.every((prop) => {
|
|
567
|
+
if (!t.isObjectProperty(prop)) {
|
|
568
|
+
console.log("not object prop", prop);
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
const propName = prop.key["name"];
|
|
572
|
+
if (!isValidStyleKey(propName) && propName !== "tag") {
|
|
573
|
+
if (shouldPrintDebug) {
|
|
574
|
+
console.log(" not a valid style prop!", propName);
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
689
577
|
}
|
|
690
|
-
return
|
|
578
|
+
return true;
|
|
579
|
+
});
|
|
580
|
+
}, createTernariesFromObjectProperties = function(test, side, ternaryPartial = {}) {
|
|
581
|
+
if (!side) {
|
|
582
|
+
return null;
|
|
691
583
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
}
|
|
695
|
-
__name(isExtractable, "isExtractable");
|
|
696
|
-
function createTernariesFromObjectProperties(test, side, ternaryPartial = {}) {
|
|
697
|
-
if (!side) {
|
|
698
|
-
return null;
|
|
699
|
-
}
|
|
700
|
-
if (!isExtractable(side)) {
|
|
701
|
-
throw new Error("not extractable");
|
|
702
|
-
}
|
|
703
|
-
return side.properties.flatMap((property) => {
|
|
704
|
-
if (!t.isObjectProperty(property)) {
|
|
705
|
-
throw new Error("expected object property");
|
|
584
|
+
if (!isExtractable(side)) {
|
|
585
|
+
throw new Error("not extractable");
|
|
706
586
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
if (
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
if (
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
})
|
|
587
|
+
return side.properties.flatMap((property) => {
|
|
588
|
+
if (!t.isObjectProperty(property)) {
|
|
589
|
+
throw new Error("expected object property");
|
|
590
|
+
}
|
|
591
|
+
if (t.isIdentifier(property.key)) {
|
|
592
|
+
const key = property.key.name;
|
|
593
|
+
const mediaQueryKey = key.slice(1);
|
|
594
|
+
const isMediaQuery = key[0] === "$" && import_core_node.mediaQueryConfig[mediaQueryKey];
|
|
595
|
+
if (isMediaQuery) {
|
|
596
|
+
if (t.isExpression(property.value)) {
|
|
597
|
+
const ternaries2 = createTernariesFromObjectProperties(t.stringLiteral(mediaQueryKey), property.value, {
|
|
598
|
+
inlineMediaQuery: mediaQueryKey
|
|
599
|
+
});
|
|
600
|
+
if (ternaries2) {
|
|
601
|
+
return ternaries2.map((value) => __spreadProps(__spreadValues(__spreadValues({}, ternaryPartial), value), {
|
|
602
|
+
test: t.logicalExpression("&&", value.test, test)
|
|
603
|
+
}));
|
|
604
|
+
} else {
|
|
605
|
+
console.log("\u26A0\uFE0F no ternaries?", property);
|
|
606
|
+
}
|
|
720
607
|
} else {
|
|
721
|
-
console.log("\u26A0\uFE0F
|
|
608
|
+
console.log("\u26A0\uFE0F not expression", property);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (t.isConditionalExpression(property.value)) {
|
|
613
|
+
const [truthy, falsy] = [
|
|
614
|
+
t.objectExpression([t.objectProperty(property.key, property.value.consequent)]),
|
|
615
|
+
t.objectExpression([t.objectProperty(property.key, property.value.alternate)])
|
|
616
|
+
].map((x) => attemptEval(x));
|
|
617
|
+
return [
|
|
618
|
+
createTernary(__spreadProps(__spreadValues({
|
|
619
|
+
remove() {
|
|
620
|
+
}
|
|
621
|
+
}, ternaryPartial), {
|
|
622
|
+
test: t.logicalExpression("&&", test, property.value.test),
|
|
623
|
+
consequent: truthy,
|
|
624
|
+
alternate: null
|
|
625
|
+
})),
|
|
626
|
+
createTernary(__spreadProps(__spreadValues({}, ternaryPartial), {
|
|
627
|
+
test: t.logicalExpression("&&", test, t.unaryExpression("!", property.value.test)),
|
|
628
|
+
consequent: falsy,
|
|
629
|
+
alternate: null,
|
|
630
|
+
remove() {
|
|
631
|
+
}
|
|
632
|
+
}))
|
|
633
|
+
];
|
|
634
|
+
}
|
|
635
|
+
const obj = t.objectExpression([t.objectProperty(property.key, property.value)]);
|
|
636
|
+
const consequent = attemptEval(obj);
|
|
637
|
+
return createTernary(__spreadProps(__spreadValues({
|
|
638
|
+
remove() {
|
|
639
|
+
}
|
|
640
|
+
}, ternaryPartial), {
|
|
641
|
+
test,
|
|
642
|
+
consequent,
|
|
643
|
+
alternate: null
|
|
644
|
+
}));
|
|
645
|
+
});
|
|
646
|
+
}, mergeStyles = function(prev2, next) {
|
|
647
|
+
for (const key in next) {
|
|
648
|
+
if (import_core_node.pseudos[key]) {
|
|
649
|
+
prev2[key] = prev2[key] || {};
|
|
650
|
+
if (shouldPrintDebug) {
|
|
651
|
+
if (!next[key] || !prev2[key]) {
|
|
652
|
+
console.log("warn: missing", key, prev2, next);
|
|
722
653
|
}
|
|
723
|
-
} else {
|
|
724
|
-
console.log("\u26A0\uFE0F not expression", property);
|
|
725
654
|
}
|
|
655
|
+
Object.assign(prev2[key], next[key]);
|
|
656
|
+
} else {
|
|
657
|
+
prev2[key] = next[key];
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
__name(isValidStyleKey, "isValidStyleKey");
|
|
662
|
+
__name(evaluateAttribute, "evaluateAttribute");
|
|
663
|
+
__name(isExtractable, "isExtractable");
|
|
664
|
+
__name(createTernariesFromObjectProperties, "createTernariesFromObjectProperties");
|
|
665
|
+
__name(mergeStyles, "mergeStyles");
|
|
666
|
+
node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
|
|
667
|
+
if (shouldPrintDebug) {
|
|
668
|
+
console.log("\n");
|
|
669
|
+
console.log("\x1B[33m%s\x1B[0m", `${tagId[0]} | ${tagId[2]} -------------------`);
|
|
670
|
+
console.log("\x1B[1m", "\x1B[32m", `<${originalNodeName} />`);
|
|
671
|
+
}
|
|
672
|
+
if (shouldAddDebugProp && !disableDebugAttr) {
|
|
673
|
+
res.modified++;
|
|
674
|
+
node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier("data-is"), t.stringLiteral(tagId.join(" "))));
|
|
675
|
+
}
|
|
676
|
+
const shouldLog = !hasLogged;
|
|
677
|
+
if (shouldLog) {
|
|
678
|
+
const prefix = " |";
|
|
679
|
+
console.log(prefixLogs || prefix, " total \xB7 optimized \xB7 flattened ");
|
|
680
|
+
hasLogged = true;
|
|
681
|
+
}
|
|
682
|
+
if (disableExtraction) {
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
const { staticConfig } = component;
|
|
686
|
+
const isTextView = staticConfig.isText || false;
|
|
687
|
+
const validStyles = (staticConfig == null ? void 0 : staticConfig.validStyles) ?? {};
|
|
688
|
+
let tagName = ((_a2 = staticConfig.defaultProps) == null ? void 0 : _a2.tag) ?? (isTextView ? "span" : "div");
|
|
689
|
+
traversePath.get("openingElement").get("attributes").forEach((path) => {
|
|
690
|
+
const attr = path.node;
|
|
691
|
+
if (t.isJSXSpreadAttribute(attr))
|
|
692
|
+
return;
|
|
693
|
+
if (attr.name.name !== "tag")
|
|
694
|
+
return;
|
|
695
|
+
const val = attr.value;
|
|
696
|
+
if (!t.isStringLiteral(val))
|
|
697
|
+
return;
|
|
698
|
+
tagName = val.value;
|
|
699
|
+
});
|
|
700
|
+
const flatNode = getFlattenedNode({ isTextView, tag: tagName });
|
|
701
|
+
const inlineProps = /* @__PURE__ */ new Set([
|
|
702
|
+
...props.inlineProps || [],
|
|
703
|
+
...staticConfig.inlineProps || []
|
|
704
|
+
]);
|
|
705
|
+
const deoptProps = /* @__PURE__ */ new Set([
|
|
706
|
+
"animation",
|
|
707
|
+
...props.deoptProps || [],
|
|
708
|
+
...staticConfig.deoptProps || []
|
|
709
|
+
]);
|
|
710
|
+
const staticNamespace = (0, import_getStaticBindingsForScope.getStaticBindingsForScope)(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug);
|
|
711
|
+
const attemptEval = !evaluateVars ? import_evaluateAstNode.evaluateAstNode : (0, import_createEvaluator.createEvaluator)({
|
|
712
|
+
tamaguiConfig,
|
|
713
|
+
staticNamespace,
|
|
714
|
+
sourcePath,
|
|
715
|
+
traversePath,
|
|
716
|
+
shouldPrintDebug
|
|
717
|
+
});
|
|
718
|
+
const attemptEvalSafe = (0, import_createEvaluator.createSafeEvaluator)(attemptEval);
|
|
719
|
+
if (shouldPrintDebug) {
|
|
720
|
+
console.log(" staticNamespace", Object.keys(staticNamespace).join(", "));
|
|
721
|
+
}
|
|
722
|
+
const flattenedAttrs = [];
|
|
723
|
+
traversePath.get("openingElement").get("attributes").forEach((path) => {
|
|
724
|
+
const attr = path.node;
|
|
725
|
+
if (!t.isJSXSpreadAttribute(attr)) {
|
|
726
|
+
flattenedAttrs.push(attr);
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
let arg;
|
|
730
|
+
try {
|
|
731
|
+
arg = attemptEval(attr.argument);
|
|
732
|
+
} catch (e) {
|
|
733
|
+
if (shouldPrintDebug) {
|
|
734
|
+
console.log(" couldnt parse spread", e.message);
|
|
726
735
|
}
|
|
736
|
+
flattenedAttrs.push(attr);
|
|
737
|
+
return;
|
|
727
738
|
}
|
|
728
|
-
if (
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
return [
|
|
734
|
-
createTernary(__spreadProps(__spreadValues({
|
|
735
|
-
remove() {
|
|
739
|
+
if (arg !== void 0) {
|
|
740
|
+
try {
|
|
741
|
+
if (typeof arg !== "object" || arg == null) {
|
|
742
|
+
if (shouldPrintDebug) {
|
|
743
|
+
console.log(" non object or null arg", arg);
|
|
736
744
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
remove() {
|
|
745
|
+
flattenedAttrs.push(attr);
|
|
746
|
+
} else {
|
|
747
|
+
for (const k in arg) {
|
|
748
|
+
const value = arg[k];
|
|
749
|
+
if (!value && typeof value === "object") {
|
|
750
|
+
console.log("shouldnt we handle this?", k, value, arg);
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
flattenedAttrs.push(t.jsxAttribute(t.jsxIdentifier(k), t.jsxExpressionContainer((0, import_literalToAst.literalToAst)(value))));
|
|
747
754
|
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
const consequent = attemptEval(obj);
|
|
753
|
-
return createTernary(__spreadProps(__spreadValues({
|
|
754
|
-
remove() {
|
|
755
|
+
}
|
|
756
|
+
} catch (err) {
|
|
757
|
+
console.warn("cant parse spread, caught err", err);
|
|
758
|
+
couldntParse = true;
|
|
755
759
|
}
|
|
756
|
-
}
|
|
757
|
-
test,
|
|
758
|
-
consequent,
|
|
759
|
-
alternate: null
|
|
760
|
-
}));
|
|
760
|
+
}
|
|
761
761
|
});
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
node.attributes = attrs.filter(isAttr).map((x) => x.value);
|
|
765
|
-
if (couldntParse || shouldDeopt) {
|
|
766
|
-
if (shouldPrintDebug) {
|
|
767
|
-
console.log(` avoid optimizing:`, { couldntParse, shouldDeopt });
|
|
762
|
+
if (couldntParse) {
|
|
763
|
+
return;
|
|
768
764
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
765
|
+
tm.mark("jsx-element-flattened", shouldPrintDebug === "verbose");
|
|
766
|
+
node.attributes = flattenedAttrs;
|
|
767
|
+
if (staticConfig.defaultProps) {
|
|
768
|
+
for (const key in staticConfig.defaultProps) {
|
|
769
|
+
if (isValidStyleKey(key)) {
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
const serialize = require("babel-literal-to-ast");
|
|
773
|
+
const val = staticConfig.defaultProps[key];
|
|
774
|
+
try {
|
|
775
|
+
const serializedDefaultProp = serialize(val);
|
|
776
|
+
node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier(key), typeof val === "string" ? t.stringLiteral(val) : t.jsxExpressionContainer(serializedDefaultProp)));
|
|
777
|
+
} catch (err) {
|
|
778
|
+
console.warn(`\u26A0\uFE0F Error evaluating default prop for component ${node.name.name}, prop ${key}
|
|
779
|
+
error: ${err}
|
|
780
|
+
value:`, val, "\n defaultProps:", staticConfig.defaultProps);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
781
783
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
value: __spreadProps(__spreadValues({}, rest), {
|
|
788
|
-
alternate: alternate || null,
|
|
789
|
-
consequent: consequent || null
|
|
790
|
-
})
|
|
791
|
-
};
|
|
792
|
-
});
|
|
784
|
+
let attrs = [];
|
|
785
|
+
let shouldDeopt = false;
|
|
786
|
+
const inlined = /* @__PURE__ */ new Map();
|
|
787
|
+
let hasSetOptimized = false;
|
|
788
|
+
attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
|
|
793
789
|
try {
|
|
794
|
-
|
|
795
|
-
|
|
790
|
+
const res2 = evaluateAttribute(path);
|
|
791
|
+
tm.mark("jsx-element-evaluate-attr", shouldPrintDebug === "verbose");
|
|
792
|
+
if (!res2) {
|
|
793
|
+
path.remove();
|
|
794
|
+
}
|
|
795
|
+
return res2;
|
|
796
|
+
} catch (err) {
|
|
796
797
|
if (shouldPrintDebug) {
|
|
797
|
-
console.log(
|
|
798
|
+
console.log("Error extracting attribute", err.message, err.stack);
|
|
799
|
+
console.log("node", path.node);
|
|
798
800
|
}
|
|
799
|
-
|
|
801
|
+
return {
|
|
802
|
+
type: "attr",
|
|
803
|
+
value: path.node
|
|
804
|
+
};
|
|
800
805
|
}
|
|
806
|
+
}).flat(4).filter(import_extractHelpers.isPresent);
|
|
807
|
+
if (shouldPrintDebug) {
|
|
808
|
+
console.log(" - attrs (before):\n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
801
809
|
}
|
|
802
|
-
|
|
803
|
-
|
|
810
|
+
node.attributes = attrs.filter(isAttr).map((x) => x.value);
|
|
811
|
+
if (couldntParse || shouldDeopt) {
|
|
812
|
+
if (shouldPrintDebug) {
|
|
813
|
+
console.log(` avoid optimizing:`, { couldntParse, shouldDeopt });
|
|
814
|
+
}
|
|
815
|
+
node.attributes = ogAttributes;
|
|
816
|
+
return;
|
|
804
817
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
const completeStaticProps = __spreadValues({}, Object.keys(attrs).reduce((acc, index) => {
|
|
809
|
-
const cur = attrs[index];
|
|
810
|
-
if (cur.type === "style") {
|
|
811
|
-
Object.assign(acc, cur.value);
|
|
818
|
+
const parentFn = (0, import_findTopmostFunction.findTopmostFunction)(traversePath);
|
|
819
|
+
if (parentFn) {
|
|
820
|
+
modifiedComponents.add(parentFn);
|
|
812
821
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
822
|
+
let ternaries = [];
|
|
823
|
+
attrs = attrs.reduce((out, cur) => {
|
|
824
|
+
const next = attrs[attrs.indexOf(cur) + 1];
|
|
825
|
+
if (cur.type === "ternary") {
|
|
826
|
+
ternaries.push(cur.value);
|
|
816
827
|
}
|
|
817
|
-
if (!
|
|
818
|
-
|
|
828
|
+
if ((!next || next.type !== "ternary") && ternaries.length) {
|
|
829
|
+
const normalized = (0, import_normalizeTernaries.normalizeTernaries)(ternaries).map((_a3) => {
|
|
830
|
+
var _b3 = _a3, { alternate, consequent } = _b3, rest = __objRest(_b3, ["alternate", "consequent"]);
|
|
831
|
+
return {
|
|
832
|
+
type: "ternary",
|
|
833
|
+
value: __spreadProps(__spreadValues({}, rest), {
|
|
834
|
+
alternate: alternate || null,
|
|
835
|
+
consequent: consequent || null
|
|
836
|
+
})
|
|
837
|
+
};
|
|
838
|
+
});
|
|
839
|
+
try {
|
|
840
|
+
return [...out, ...normalized];
|
|
841
|
+
} finally {
|
|
842
|
+
if (shouldPrintDebug) {
|
|
843
|
+
console.log(` normalizeTernaries (${ternaries.length} => ${normalized.length})`);
|
|
844
|
+
}
|
|
845
|
+
ternaries = [];
|
|
846
|
+
}
|
|
819
847
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
if (value === import_constants.FAILED_EVAL) {
|
|
823
|
-
return acc;
|
|
848
|
+
if (cur.type === "ternary") {
|
|
849
|
+
return out;
|
|
824
850
|
}
|
|
825
|
-
|
|
851
|
+
out.push(cur);
|
|
852
|
+
return out;
|
|
853
|
+
}, []).flat();
|
|
854
|
+
const hasSpread = node.attributes.some((x) => t.isJSXSpreadAttribute(x));
|
|
855
|
+
const hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every((x) => x.type === "JSXText"));
|
|
856
|
+
let themeVal = inlined.get("theme");
|
|
857
|
+
inlined.delete("theme");
|
|
858
|
+
const allOtherPropsExtractable = [...inlined].every(([k, v]) => INLINE_EXTRACTABLE[k]);
|
|
859
|
+
const shouldWrapThme = allOtherPropsExtractable && !!themeVal;
|
|
860
|
+
const canFlattenProps = inlined.size === 0 || shouldWrapThme || allOtherPropsExtractable;
|
|
861
|
+
let shouldFlatten = !shouldDeopt && canFlattenProps && !hasSpread && staticConfig.neverFlatten !== true && (staticConfig.neverFlatten === "jsx" ? hasOnlyStringChildren : true);
|
|
862
|
+
if (shouldPrintDebug) {
|
|
863
|
+
console.log(" - flatten?", (0, import_extractHelpers.objToStr)({ hasSpread, shouldDeopt, shouldFlatten, canFlattenProps, shouldWrapThme, allOtherPropsExtractable, hasOnlyStringChildren }));
|
|
826
864
|
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
const hasOnlyStringChildren = !hasSpread && (node.selfClosing || traversePath.node.children && traversePath.node.children.every((x) => x.type === "JSXText"));
|
|
831
|
-
const themeVal = inlined.get("theme");
|
|
832
|
-
inlined.delete("theme");
|
|
833
|
-
const allOtherPropsExtractable = [...inlined].every(([k, v]) => INLINE_EXTRACTABLE[k]);
|
|
834
|
-
const shouldWrapInnerTheme = !!(hasOnlyStringChildren && themeVal);
|
|
835
|
-
const canFlattenProps = inlined.size === 0 || allOtherPropsExtractable && shouldWrapInnerTheme || allOtherPropsExtractable;
|
|
836
|
-
let shouldFlatten = !shouldDeopt && canFlattenProps && !hasSpread && staticConfig.neverFlatten !== true && (staticConfig.neverFlatten === "jsx" ? hasOnlyStringChildren : true);
|
|
837
|
-
if (shouldWrapInnerTheme) {
|
|
838
|
-
const parents = traversePath.parentPath.node;
|
|
839
|
-
if (!t.isJSXElement(parents) && !t.isJSXFragment(parents)) {
|
|
840
|
-
shouldFlatten = false;
|
|
841
|
-
} else {
|
|
842
|
-
if (typeof themeVal === "string") {
|
|
843
|
-
if (!hasImportedTheme) {
|
|
844
|
-
hasImportedTheme = true;
|
|
845
|
-
programPath.node.body.push(t.importDeclaration([t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))], t.stringLiteral("@tamagui/core")));
|
|
846
|
-
}
|
|
847
|
-
const children = parents.children;
|
|
848
|
-
parents.children = [
|
|
849
|
-
t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
|
|
850
|
-
t.jsxAttribute(t.jsxIdentifier("name"), t.stringLiteral(`${themeVal}`))
|
|
851
|
-
]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), children)
|
|
852
|
-
];
|
|
853
|
-
} else {
|
|
865
|
+
if (shouldFlatten && shouldWrapThme) {
|
|
866
|
+
if (shouldPrintDebug) {
|
|
867
|
+
console.log(" - wrapping theme", allOtherPropsExtractable, themeVal);
|
|
854
868
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
if (!isValidStyleKey(key)) {
|
|
860
|
-
return;
|
|
869
|
+
attrs = attrs.filter((x) => x.type === "attr" && t.isJSXAttribute(x.value) && x.value.name.name === "theme" ? false : true);
|
|
870
|
+
if (!hasImportedTheme) {
|
|
871
|
+
hasImportedTheme = true;
|
|
872
|
+
programPath.node.body.push(t.importDeclaration([t.importSpecifier(t.identifier("_TamaguiTheme"), t.identifier("Theme"))], t.stringLiteral("@tamagui/core")));
|
|
861
873
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
874
|
+
traversePath.replaceWith(t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier("_TamaguiTheme"), [
|
|
875
|
+
t.jsxAttribute(t.jsxIdentifier("name"), themeVal.value)
|
|
876
|
+
]), t.jsxClosingElement(t.jsxIdentifier("_TamaguiTheme")), [traversePath.node]));
|
|
877
|
+
}
|
|
878
|
+
if (shouldFlatten && staticConfig.defaultProps) {
|
|
879
|
+
const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap((key) => {
|
|
880
|
+
if (!isValidStyleKey(key)) {
|
|
881
|
+
return [];
|
|
882
|
+
}
|
|
883
|
+
const value = staticConfig.defaultProps[key];
|
|
866
884
|
const name = tamaguiConfig.shorthands[key] || key;
|
|
867
|
-
|
|
885
|
+
if (value === void 0) {
|
|
886
|
+
console.warn(`\u26A0\uFE0F Error evaluating default style for component, prop ${key} ${value}`);
|
|
887
|
+
shouldDeopt = true;
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
const attr = {
|
|
868
891
|
type: "style",
|
|
869
892
|
name,
|
|
870
|
-
value
|
|
893
|
+
value: { [name]: value }
|
|
871
894
|
};
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
895
|
+
return attr;
|
|
896
|
+
});
|
|
897
|
+
if (defaultStyleAttrs.length) {
|
|
898
|
+
attrs = [...defaultStyleAttrs, ...attrs];
|
|
876
899
|
}
|
|
877
|
-
});
|
|
878
|
-
if (defaultStyleAttrs.length) {
|
|
879
|
-
attrs = [...defaultStyleAttrs, ...attrs];
|
|
880
900
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
901
|
+
if (shouldDeopt) {
|
|
902
|
+
node.attributes = ogAttributes;
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
const ensureOverridden = {};
|
|
906
|
+
if (!shouldFlatten) {
|
|
907
|
+
for (const cur of attrs) {
|
|
908
|
+
if (cur.type === "style") {
|
|
909
|
+
for (const key in cur.value) {
|
|
910
|
+
const shouldEnsureOverridden = !!((_b2 = staticConfig.ensureOverriddenProp) == null ? void 0 : _b2[key]);
|
|
911
|
+
const isSetInAttrsAlready = attrs.some((x) => x.type === "attr" && x.value.type === "JSXAttribute" && x.value.name.name === key);
|
|
912
|
+
if (!isSetInAttrsAlready) {
|
|
913
|
+
const isVariant = !!((_c = staticConfig.variants) == null ? void 0 : _c[cur.name || ""]);
|
|
914
|
+
if (isVariant || shouldEnsureOverridden) {
|
|
915
|
+
ensureOverridden[key] = true;
|
|
916
|
+
}
|
|
897
917
|
}
|
|
898
918
|
}
|
|
899
919
|
}
|
|
900
920
|
}
|
|
901
921
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
console.log(" - ensureOverriden:", Object.keys(ensureOverridden).join(", "));
|
|
906
|
-
}
|
|
907
|
-
attrs = attrs.reduce((acc, cur) => {
|
|
908
|
-
if (!cur) {
|
|
909
|
-
return acc;
|
|
922
|
+
if (shouldPrintDebug) {
|
|
923
|
+
console.log(" - attrs (flattened): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
924
|
+
console.log(" - ensureOverriden:", Object.keys(ensureOverridden).join(", "));
|
|
910
925
|
}
|
|
911
|
-
|
|
912
|
-
if (
|
|
913
|
-
|
|
926
|
+
attrs = attrs.reduce((acc, cur) => {
|
|
927
|
+
if (!cur) {
|
|
928
|
+
return acc;
|
|
929
|
+
}
|
|
930
|
+
if (cur.type === "attr" && !t.isJSXSpreadAttribute(cur.value)) {
|
|
931
|
+
if (shouldFlatten) {
|
|
932
|
+
if (cur.value.name.name === "tag") {
|
|
933
|
+
return acc;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (cur.type !== "style") {
|
|
938
|
+
acc.push(cur);
|
|
939
|
+
return acc;
|
|
940
|
+
}
|
|
941
|
+
let key = Object.keys(cur.value)[0];
|
|
942
|
+
const value = cur.value[key];
|
|
943
|
+
const fullKey = tamaguiConfig.shorthands[key];
|
|
944
|
+
if (fullKey) {
|
|
945
|
+
cur.value = { [fullKey]: value };
|
|
946
|
+
key = fullKey;
|
|
947
|
+
}
|
|
948
|
+
if (disableExtractVariables) {
|
|
949
|
+
if (value[0] === "$") {
|
|
950
|
+
if (shouldPrintDebug) {
|
|
951
|
+
console.log(` keeping variable inline: ${key} =`, value);
|
|
952
|
+
}
|
|
953
|
+
acc.push({
|
|
954
|
+
type: "attr",
|
|
955
|
+
value: t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(t.stringLiteral(value)))
|
|
956
|
+
});
|
|
914
957
|
return acc;
|
|
915
958
|
}
|
|
916
959
|
}
|
|
917
|
-
}
|
|
918
|
-
if (cur.type !== "style") {
|
|
919
960
|
acc.push(cur);
|
|
920
961
|
return acc;
|
|
962
|
+
}, []);
|
|
963
|
+
tm.mark("jsx-element-expanded", shouldPrintDebug === "verbose");
|
|
964
|
+
if (shouldPrintDebug) {
|
|
965
|
+
console.log(" - attrs (expanded): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
921
966
|
}
|
|
922
|
-
let
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
967
|
+
let prev = null;
|
|
968
|
+
attrs = attrs.reduce((acc, cur) => {
|
|
969
|
+
if (cur.type === "style") {
|
|
970
|
+
const key = Object.keys(cur.value)[0];
|
|
971
|
+
const value = cur.value[key];
|
|
972
|
+
const shouldKeepOriginalAttr = !shouldFlatten && !validStyles[key] && !import_core_node.pseudos[key] && !key.startsWith("data-");
|
|
973
|
+
if (shouldKeepOriginalAttr) {
|
|
974
|
+
if (shouldPrintDebug) {
|
|
975
|
+
console.log(" - keeping as non-style", key);
|
|
976
|
+
}
|
|
977
|
+
prev = cur;
|
|
978
|
+
acc.push({
|
|
979
|
+
type: "attr",
|
|
980
|
+
value: t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(typeof value === "string" ? t.stringLiteral(value) : (0, import_literalToAst.literalToAst)(value)))
|
|
981
|
+
});
|
|
982
|
+
acc.push(cur);
|
|
983
|
+
return acc;
|
|
933
984
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
}, []);
|
|
944
|
-
if (shouldPrintDebug) {
|
|
945
|
-
console.log(" - attrs (expanded): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
946
|
-
}
|
|
947
|
-
let prev = null;
|
|
948
|
-
function mergeStyles(prev2, next) {
|
|
949
|
-
for (const key in next) {
|
|
950
|
-
if (import_core_node.pseudos[key]) {
|
|
951
|
-
prev2[key] = prev2[key] || {};
|
|
952
|
-
Object.assign(prev2[key], next[key]);
|
|
953
|
-
} else {
|
|
954
|
-
prev2[key] = next[key];
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
__name(mergeStyles, "mergeStyles");
|
|
959
|
-
attrs = attrs.reduce((acc, cur) => {
|
|
960
|
-
if (cur.type === "style") {
|
|
961
|
-
const key = Object.keys(cur.value)[0];
|
|
962
|
-
const value = cur.value[key];
|
|
963
|
-
const shouldKeepOriginalAttr = !shouldFlatten && !validStyles[key] && !import_core_node.pseudos[key] && !key.startsWith("data-");
|
|
964
|
-
if (shouldKeepOriginalAttr) {
|
|
965
|
-
if (shouldPrintDebug) {
|
|
966
|
-
console.log(" - keeping as non-style", key);
|
|
985
|
+
if (ensureOverridden[key]) {
|
|
986
|
+
acc.push({
|
|
987
|
+
type: "attr",
|
|
988
|
+
value: cur.attr || t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(t.nullLiteral()))
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
if ((prev == null ? void 0 : prev.type) === "style") {
|
|
992
|
+
mergeStyles(prev.value, cur.value);
|
|
993
|
+
return acc;
|
|
967
994
|
}
|
|
968
|
-
prev = cur;
|
|
969
|
-
acc.push({
|
|
970
|
-
type: "attr",
|
|
971
|
-
value: t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(typeof value === "string" ? t.stringLiteral(value) : (0, import_literalToAst.literalToAst)(value)))
|
|
972
|
-
});
|
|
973
|
-
acc.push(cur);
|
|
974
|
-
return acc;
|
|
975
995
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
996
|
+
prev = cur;
|
|
997
|
+
acc.push(cur);
|
|
998
|
+
return acc;
|
|
999
|
+
}, []);
|
|
1000
|
+
const state = {
|
|
1001
|
+
noClassNames: true,
|
|
1002
|
+
focus: false,
|
|
1003
|
+
hover: false,
|
|
1004
|
+
mounted: true,
|
|
1005
|
+
press: false,
|
|
1006
|
+
pressIn: false
|
|
1007
|
+
};
|
|
1008
|
+
const completeStaticProps = Object.keys(attrs).reduce((acc, index) => {
|
|
1009
|
+
const cur = attrs[index];
|
|
1010
|
+
if (cur.type === "style") {
|
|
1011
|
+
(0, import_core_node.normalizeStyleObject)(cur.value);
|
|
1012
|
+
Object.assign(acc, cur.value);
|
|
981
1013
|
}
|
|
982
|
-
if (
|
|
983
|
-
|
|
984
|
-
|
|
1014
|
+
if (cur.type === "attr") {
|
|
1015
|
+
if (t.isJSXSpreadAttribute(cur.value)) {
|
|
1016
|
+
return acc;
|
|
1017
|
+
}
|
|
1018
|
+
if (!t.isJSXIdentifier(cur.value.name)) {
|
|
1019
|
+
return acc;
|
|
1020
|
+
}
|
|
1021
|
+
const key = cur.value.name.name;
|
|
1022
|
+
const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
|
|
1023
|
+
if (value === import_constants.FAILED_EVAL) {
|
|
1024
|
+
return acc;
|
|
1025
|
+
}
|
|
1026
|
+
acc[key] = value;
|
|
985
1027
|
}
|
|
1028
|
+
return acc;
|
|
1029
|
+
}, {});
|
|
1030
|
+
const completeProps = __spreadValues(__spreadValues({}, staticConfig.defaultProps), completeStaticProps);
|
|
1031
|
+
if (shouldPrintDebug) {
|
|
1032
|
+
console.log(" - attrs (combined \u{1F500}): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
1033
|
+
console.log(" - defaultProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(staticConfig.defaultProps)));
|
|
1034
|
+
console.log(" - completeStaticProps: \n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeStaticProps)));
|
|
986
1035
|
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
for (const key in props2) {
|
|
1001
|
-
if (excludeProps.has(key)) {
|
|
1002
|
-
delete props2[key];
|
|
1036
|
+
const getStyles = /* @__PURE__ */ __name((props2, debugName = "") => {
|
|
1037
|
+
if (!props2 || !Object.keys(props2).length) {
|
|
1038
|
+
if (shouldPrintDebug)
|
|
1039
|
+
console.log(" getStyles() no props");
|
|
1040
|
+
return {};
|
|
1041
|
+
}
|
|
1042
|
+
if (excludeProps && !!excludeProps.size) {
|
|
1043
|
+
for (const key in props2) {
|
|
1044
|
+
if (excludeProps.has(key)) {
|
|
1045
|
+
if (shouldPrintDebug)
|
|
1046
|
+
console.log(" delete excluded", key);
|
|
1047
|
+
delete props2[key];
|
|
1048
|
+
}
|
|
1003
1049
|
}
|
|
1004
1050
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1051
|
+
try {
|
|
1052
|
+
const out = (0, import_core_node.getSplitStyles)(props2, staticConfig, defaultTheme, __spreadProps(__spreadValues({}, state), {
|
|
1053
|
+
fallbackProps: completeProps
|
|
1054
|
+
}));
|
|
1055
|
+
const outStyle = __spreadValues(__spreadValues({}, out.style), out.pseudos);
|
|
1056
|
+
if (staticConfig.validStyles) {
|
|
1057
|
+
for (const key in outStyle) {
|
|
1058
|
+
if (!staticConfig.validStyles[key] && !import_core_node.pseudos[key] && !/(hover|focus|press)Style$/.test(key)) {
|
|
1059
|
+
if (shouldPrintDebug)
|
|
1060
|
+
console.log(" delete invalid style", key);
|
|
1061
|
+
delete outStyle[key];
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
if (shouldPrintDebug) {
|
|
1066
|
+
console.log(` getStyles ${debugName} (props):
|
|
1012
1067
|
`, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(props2)));
|
|
1013
|
-
|
|
1068
|
+
console.log(` getStyles ${debugName} (out.viewProps):
|
|
1014
1069
|
`, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(out.viewProps)));
|
|
1015
|
-
|
|
1070
|
+
console.log(` getStyles ${debugName} (out.style):
|
|
1016
1071
|
`, (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(outStyle || {}), true));
|
|
1017
|
-
}
|
|
1018
|
-
for (const key in outStyle) {
|
|
1019
|
-
if (staticConfig.validStyles) {
|
|
1020
|
-
if (!staticConfig.validStyles[key] && !import_core_node.pseudos[key]) {
|
|
1021
|
-
delete outStyle[key];
|
|
1022
1072
|
}
|
|
1073
|
+
return outStyle;
|
|
1074
|
+
} catch (err) {
|
|
1075
|
+
console.log("error", err.message, err.stack);
|
|
1076
|
+
return {};
|
|
1077
|
+
}
|
|
1078
|
+
}, "getStyles");
|
|
1079
|
+
const completeStylesProcessed = getStyles(completeProps, "completeStylesProcessed");
|
|
1080
|
+
if (!completeStylesProcessed) {
|
|
1081
|
+
throw new Error(`Impossible, no styles`);
|
|
1082
|
+
}
|
|
1083
|
+
const stylesToAddToInitialGroup = shouldFlatten ? (0, import_lodash.difference)(Object.keys(completeStylesProcessed), Object.keys(completeStaticProps)) : [];
|
|
1084
|
+
if (stylesToAddToInitialGroup.length) {
|
|
1085
|
+
const toAdd = (0, import_lodash.pick)(completeStylesProcessed, ...stylesToAddToInitialGroup);
|
|
1086
|
+
const firstGroup = attrs.find((x) => x.type === "style");
|
|
1087
|
+
if (shouldPrintDebug) {
|
|
1088
|
+
console.log(" toAdd", (0, import_extractHelpers.objToStr)(toAdd));
|
|
1089
|
+
}
|
|
1090
|
+
if (!firstGroup) {
|
|
1091
|
+
attrs.unshift({ type: "style", value: toAdd });
|
|
1092
|
+
} else {
|
|
1093
|
+
Object.assign(firstGroup.value, toAdd);
|
|
1023
1094
|
}
|
|
1024
1095
|
}
|
|
1025
|
-
return outStyle;
|
|
1026
|
-
}, "getStyles");
|
|
1027
|
-
const completeStylesProcessed = getStyles(__spreadValues(__spreadValues({}, staticConfig.defaultProps), completeStaticProps), "completeStylesProcessed");
|
|
1028
|
-
if (!completeStylesProcessed) {
|
|
1029
|
-
throw new Error(`Impossible, no styles`);
|
|
1030
|
-
}
|
|
1031
|
-
const stylesToAddToInitialGroup = shouldFlatten ? (0, import_lodash.difference)(Object.keys(completeStylesProcessed), Object.keys(completeStaticProps)) : [];
|
|
1032
|
-
if (stylesToAddToInitialGroup.length) {
|
|
1033
|
-
const toAdd = (0, import_lodash.pick)(completeStylesProcessed, ...stylesToAddToInitialGroup);
|
|
1034
|
-
const firstGroup = attrs.find((x) => x.type === "style");
|
|
1035
1096
|
if (shouldPrintDebug) {
|
|
1036
|
-
console.log("
|
|
1097
|
+
console.log(" -- stylesToAddToInitialGroup", stylesToAddToInitialGroup.join(", "), { shouldFlatten });
|
|
1098
|
+
console.log(" -- completeStaticProps:\n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeStaticProps)));
|
|
1099
|
+
console.log(" -- completeStylesProcessed:\n", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(completeStylesProcessed)));
|
|
1037
1100
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1101
|
+
let getStyleError = null;
|
|
1102
|
+
for (const attr of attrs) {
|
|
1103
|
+
try {
|
|
1104
|
+
if (shouldPrintDebug)
|
|
1105
|
+
console.log(" *", (0, import_extractHelpers.attrStr)(attr));
|
|
1106
|
+
switch (attr.type) {
|
|
1107
|
+
case "ternary":
|
|
1108
|
+
const a = getStyles(attr.value.alternate, "ternary.alternate");
|
|
1109
|
+
const c = getStyles(attr.value.consequent, "ternary.consequent");
|
|
1110
|
+
if (a)
|
|
1111
|
+
attr.value.alternate = a;
|
|
1112
|
+
if (c)
|
|
1113
|
+
attr.value.consequent = c;
|
|
1114
|
+
if (shouldPrintDebug)
|
|
1115
|
+
console.log(" => tern ", (0, import_extractHelpers.attrStr)(attr));
|
|
1116
|
+
continue;
|
|
1117
|
+
case "style":
|
|
1118
|
+
if (shouldPrintDebug)
|
|
1119
|
+
console.log(" * styles in", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(attr.value)));
|
|
1120
|
+
const styles = getStyles(attr.value, "style");
|
|
1121
|
+
if (shouldPrintDebug)
|
|
1122
|
+
console.log(" * styles out", (0, import_logLines.logLines)((0, import_extractHelpers.objToStr)(styles)));
|
|
1123
|
+
if (styles) {
|
|
1124
|
+
attr.value = Object.fromEntries(Object.keys(styles).map((k) => [k, completeStylesProcessed[k]]));
|
|
1125
|
+
}
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1128
|
+
} catch (err) {
|
|
1129
|
+
getStyleError = err;
|
|
1130
|
+
}
|
|
1042
1131
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
if (
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
attr.value.consequent = c;
|
|
1062
|
-
if (shouldPrintDebug)
|
|
1063
|
-
console.log(" => tern ", (0, import_extractHelpers.attrStr)(attr));
|
|
1064
|
-
continue;
|
|
1065
|
-
case "style":
|
|
1066
|
-
const styles = getStyles(attr.value, "style");
|
|
1067
|
-
if (styles) {
|
|
1068
|
-
attr.value = Object.fromEntries(Object.keys(styles).map((k) => [k, completeStylesProcessed[k]]));
|
|
1069
|
-
} else {
|
|
1070
|
-
console.warn("?????????");
|
|
1132
|
+
tm.mark("jsx-element-styles", shouldPrintDebug === "verbose");
|
|
1133
|
+
if (getStyleError) {
|
|
1134
|
+
console.log(" \u26A0\uFE0F postprocessing error, deopt", getStyleError);
|
|
1135
|
+
node.attributes = ogAttributes;
|
|
1136
|
+
return node;
|
|
1137
|
+
}
|
|
1138
|
+
const existingStyleKeys = /* @__PURE__ */ new Set();
|
|
1139
|
+
for (let i = attrs.length - 1; i >= 0; i--) {
|
|
1140
|
+
const attr = attrs[i];
|
|
1141
|
+
if (shouldFlatten && canFlattenProps) {
|
|
1142
|
+
if (attr.type === "attr") {
|
|
1143
|
+
if (t.isJSXAttribute(attr.value)) {
|
|
1144
|
+
if (t.isJSXIdentifier(attr.value.name)) {
|
|
1145
|
+
const name = attr.value.name.name;
|
|
1146
|
+
if (INLINE_EXTRACTABLE[name]) {
|
|
1147
|
+
attr.value.name.name = INLINE_EXTRACTABLE[name];
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1071
1150
|
}
|
|
1072
|
-
|
|
1151
|
+
}
|
|
1073
1152
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
console.log(" \u26A0\uFE0F postprocessing error, deopt", getStyleError);
|
|
1080
|
-
node.attributes = ogAttributes;
|
|
1081
|
-
return node;
|
|
1082
|
-
}
|
|
1083
|
-
const existingStyleKeys = /* @__PURE__ */ new Set();
|
|
1084
|
-
for (let i = attrs.length - 1; i >= 0; i--) {
|
|
1085
|
-
const attr = attrs[i];
|
|
1086
|
-
if (shouldFlatten && canFlattenProps) {
|
|
1087
|
-
if (attr.type === "attr") {
|
|
1088
|
-
if (t.isJSXAttribute(attr.value)) {
|
|
1089
|
-
if (t.isJSXIdentifier(attr.value.name)) {
|
|
1090
|
-
const name = attr.value.name.name;
|
|
1091
|
-
if (INLINE_EXTRACTABLE[name]) {
|
|
1092
|
-
attr.value.name.name = INLINE_EXTRACTABLE[name];
|
|
1153
|
+
if (attr.type === "style") {
|
|
1154
|
+
for (const key in attr.value) {
|
|
1155
|
+
if (existingStyleKeys.has(key)) {
|
|
1156
|
+
if (shouldPrintDebug) {
|
|
1157
|
+
console.log(" >> delete existing", key);
|
|
1093
1158
|
}
|
|
1159
|
+
delete attr.value[key];
|
|
1160
|
+
} else {
|
|
1161
|
+
existingStyleKeys.add(key);
|
|
1094
1162
|
}
|
|
1095
1163
|
}
|
|
1096
1164
|
}
|
|
1097
1165
|
}
|
|
1098
|
-
if (
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1166
|
+
if (shouldFlatten) {
|
|
1167
|
+
if (shouldPrintDebug) {
|
|
1168
|
+
console.log(" [\u2705] flattening", originalNodeName, flatNode);
|
|
1169
|
+
}
|
|
1170
|
+
node.name.name = flatNode;
|
|
1171
|
+
res.flattened++;
|
|
1172
|
+
if (closingElement) {
|
|
1173
|
+
closingElement.name.name = flatNode;
|
|
1105
1174
|
}
|
|
1106
1175
|
}
|
|
1107
|
-
}
|
|
1108
|
-
if (shouldPrintDebug) {
|
|
1109
|
-
console.log(" - attrs (after):\n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
1110
|
-
}
|
|
1111
|
-
if (shouldFlatten) {
|
|
1112
1176
|
if (shouldPrintDebug) {
|
|
1113
|
-
console.log(
|
|
1177
|
+
console.log(` \u274A\u274A inline props (${inlined.size}):`, shouldDeopt ? " deopted" : "", hasSpread ? " has spread" : "", staticConfig.neverFlatten ? "neverFlatten" : "");
|
|
1178
|
+
console.log(" - attrs (end):\n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
1114
1179
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1180
|
+
onExtractTag({
|
|
1181
|
+
attrs,
|
|
1182
|
+
node,
|
|
1183
|
+
lineNumbers,
|
|
1184
|
+
filePath,
|
|
1185
|
+
attemptEval,
|
|
1186
|
+
jsxPath: traversePath,
|
|
1187
|
+
originalNodeName,
|
|
1188
|
+
isFlattened: shouldFlatten,
|
|
1189
|
+
programPath
|
|
1190
|
+
});
|
|
1191
|
+
} catch (err) {
|
|
1192
|
+
throw err;
|
|
1193
|
+
} finally {
|
|
1194
|
+
if (debugPropValue) {
|
|
1195
|
+
shouldPrintDebug = ogDebug;
|
|
1119
1196
|
}
|
|
1120
1197
|
}
|
|
1121
|
-
if (shouldPrintDebug) {
|
|
1122
|
-
console.log(` \u274A\u274A inline props (${inlined.size}):`, shouldDeopt ? " deopted" : "", hasSpread ? " has spread" : "", staticConfig.neverFlatten ? "neverFlatten" : "");
|
|
1123
|
-
console.log(" - attrs (end):\n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", ")));
|
|
1124
|
-
}
|
|
1125
|
-
onExtractTag({
|
|
1126
|
-
attrs,
|
|
1127
|
-
node,
|
|
1128
|
-
lineNumbers,
|
|
1129
|
-
filePath,
|
|
1130
|
-
attemptEval,
|
|
1131
|
-
jsxPath: traversePath,
|
|
1132
|
-
originalNodeName,
|
|
1133
|
-
isFlattened: shouldFlatten,
|
|
1134
|
-
programPath
|
|
1135
|
-
});
|
|
1136
1198
|
}
|
|
1137
1199
|
});
|
|
1200
|
+
tm.mark("jsx-done", shouldPrintDebug === "verbose");
|
|
1138
1201
|
if (modifiedComponents.size) {
|
|
1139
1202
|
const all = Array.from(modifiedComponents);
|
|
1140
1203
|
if (shouldPrintDebug) {
|
|
@@ -1144,9 +1207,14 @@ function createExtractor() {
|
|
|
1144
1207
|
(0, import_removeUnusedHooks.removeUnusedHooks)(comp, shouldPrintDebug);
|
|
1145
1208
|
}
|
|
1146
1209
|
}
|
|
1210
|
+
tm.done(shouldPrintDebug === "verbose");
|
|
1147
1211
|
return res;
|
|
1148
1212
|
}
|
|
1149
1213
|
};
|
|
1150
1214
|
}
|
|
1151
1215
|
__name(createExtractor, "createExtractor");
|
|
1216
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1217
|
+
0 && (module.exports = {
|
|
1218
|
+
createExtractor
|
|
1219
|
+
});
|
|
1152
1220
|
//# sourceMappingURL=createExtractor.js.map
|