@tamagui/static 1.0.1-rc.6 → 1.0.1-rc.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.1-rc.
|
|
3
|
+
"version": "1.0.1-rc.8",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"@babel/runtime": "^7.19.4",
|
|
37
37
|
"@babel/traverse": "^7.19.6",
|
|
38
38
|
"@expo/match-media": "^0.3.0",
|
|
39
|
-
"@tamagui/build": "^1.0.1-rc.
|
|
40
|
-
"@tamagui/cli-color": "^1.0.1-rc.
|
|
41
|
-
"@tamagui/config-default-node": "^1.0.1-rc.
|
|
42
|
-
"@tamagui/core-node": "^1.0.1-rc.
|
|
43
|
-
"@tamagui/fake-react-native": "^1.0.1-rc.
|
|
44
|
-
"@tamagui/helpers": "^1.0.1-rc.
|
|
45
|
-
"@tamagui/helpers-node": "^1.0.1-rc.
|
|
46
|
-
"@tamagui/proxy-worm": "^1.0.1-rc.
|
|
47
|
-
"@tamagui/shorthands": "^1.0.1-rc.
|
|
39
|
+
"@tamagui/build": "^1.0.1-rc.8",
|
|
40
|
+
"@tamagui/cli-color": "^1.0.1-rc.8",
|
|
41
|
+
"@tamagui/config-default-node": "^1.0.1-rc.8",
|
|
42
|
+
"@tamagui/core-node": "^1.0.1-rc.8",
|
|
43
|
+
"@tamagui/fake-react-native": "^1.0.1-rc.8",
|
|
44
|
+
"@tamagui/helpers": "^1.0.1-rc.8",
|
|
45
|
+
"@tamagui/helpers-node": "^1.0.1-rc.8",
|
|
46
|
+
"@tamagui/proxy-worm": "^1.0.1-rc.8",
|
|
47
|
+
"@tamagui/shorthands": "^1.0.1-rc.8",
|
|
48
48
|
"babel-literal-to-ast": "^2.1.0",
|
|
49
49
|
"esbuild": "^0.15.11",
|
|
50
50
|
"esbuild-register": "^3.3.3",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"fs-extra": "^10.1.0",
|
|
54
54
|
"invariant": "^2.2.4",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
|
-
"react-native-web-internals": "^1.0.1-rc.
|
|
57
|
-
"react-native-web-lite": "^1.0.1-rc.
|
|
56
|
+
"react-native-web-internals": "^1.0.1-rc.8",
|
|
57
|
+
"react-native-web-lite": "^1.0.1-rc.8"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@babel/plugin-syntax-typescript": "^7.18.6",
|
|
61
61
|
"@babel/types": "^7.19.4",
|
|
62
62
|
"@dish/babel-preset": "^0.0.6",
|
|
63
|
-
"@tamagui/test-design-system": "^1.0.1-rc.
|
|
63
|
+
"@tamagui/test-design-system": "^1.0.1-rc.8",
|
|
64
64
|
"@testing-library/react": "^13.4.0",
|
|
65
65
|
"@types/babel__generator": "^7.6.4",
|
|
66
66
|
"@types/babel__traverse": "^7.18.2",
|
|
@@ -38,7 +38,10 @@ import {
|
|
|
38
38
|
objToStr,
|
|
39
39
|
} from './extractHelpers.js'
|
|
40
40
|
import { findTopmostFunction } from './findTopmostFunction.js'
|
|
41
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
cleanupBeforeExit,
|
|
43
|
+
getStaticBindingsForScope,
|
|
44
|
+
} from './getStaticBindingsForScope.js'
|
|
42
45
|
import { literalToAst } from './literalToAst.js'
|
|
43
46
|
import { TamaguiProjectInfo, loadTamagui, loadTamaguiSync } from './loadTamagui.js'
|
|
44
47
|
import { logLines } from './logLines.js'
|
|
@@ -79,7 +82,9 @@ type FileOrPath = NodePath<t.Program> | t.File
|
|
|
79
82
|
|
|
80
83
|
let hasLoggedBaseInfo = false
|
|
81
84
|
|
|
82
|
-
export function createExtractor(
|
|
85
|
+
export function createExtractor(
|
|
86
|
+
{ logger = console }: ExtractorOptions = { logger: console }
|
|
87
|
+
) {
|
|
83
88
|
if (!process.env.TAMAGUI_TARGET) {
|
|
84
89
|
console.log('⚠️ Please set process.env.TAMAGUI_TARGET to either "web" or "native"')
|
|
85
90
|
process.exit(1)
|
|
@@ -90,7 +95,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
90
95
|
!process.env.npm_package_dependencies_next &&
|
|
91
96
|
process.env.TAMAGUI_TARGET !== 'native' &&
|
|
92
97
|
process.env.IDENTIFY_TAGS !== 'false' &&
|
|
93
|
-
(process.env.NODE_ENV === 'development' ||
|
|
98
|
+
(process.env.NODE_ENV === 'development' ||
|
|
99
|
+
process.env.DEBUG ||
|
|
100
|
+
process.env.IDENTIFY_TAGS)
|
|
94
101
|
|
|
95
102
|
let projectInfo: TamaguiProjectInfo | null = null
|
|
96
103
|
|
|
@@ -260,10 +267,13 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
260
267
|
})
|
|
261
268
|
|
|
262
269
|
// @ts-ignore
|
|
263
|
-
const body =
|
|
270
|
+
const body =
|
|
271
|
+
fileOrPath.type === 'Program' ? fileOrPath.get('body') : fileOrPath.program.body
|
|
264
272
|
|
|
265
273
|
if (Object.keys(components).length === 0) {
|
|
266
|
-
console.warn(
|
|
274
|
+
console.warn(
|
|
275
|
+
`Warning: Tamagui didn't find any valid components (DEBUG=tamagui for more)`
|
|
276
|
+
)
|
|
267
277
|
if (process.env.DEBUG === 'tamagui') {
|
|
268
278
|
console.log(`components`, Object.keys(components), components)
|
|
269
279
|
}
|
|
@@ -310,7 +320,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
310
320
|
)
|
|
311
321
|
if (shouldPrintDebug === 'verbose') {
|
|
312
322
|
logger.info(
|
|
313
|
-
`import ${names.join(
|
|
323
|
+
`import ${names.join(
|
|
324
|
+
', '
|
|
325
|
+
)} from ${moduleName} isValidComponent ${isValidComponent}`
|
|
314
326
|
)
|
|
315
327
|
}
|
|
316
328
|
if (isValidComponent) {
|
|
@@ -321,7 +333,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
321
333
|
}
|
|
322
334
|
|
|
323
335
|
if (shouldPrintDebug) {
|
|
324
|
-
logger.info(
|
|
336
|
+
logger.info(
|
|
337
|
+
`file: ${sourcePath} ${JSON.stringify({ doesUseValidImport, hasImportedTheme })}`
|
|
338
|
+
)
|
|
325
339
|
}
|
|
326
340
|
|
|
327
341
|
if (!doesUseValidImport) {
|
|
@@ -335,7 +349,11 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
335
349
|
if (!importDeclaration) {
|
|
336
350
|
return null
|
|
337
351
|
}
|
|
338
|
-
return getValidImport(
|
|
352
|
+
return getValidImport(
|
|
353
|
+
propsWithFileInfo,
|
|
354
|
+
importDeclaration.source.value,
|
|
355
|
+
componentName
|
|
356
|
+
)
|
|
339
357
|
}
|
|
340
358
|
|
|
341
359
|
tm.mark('import-check', !!shouldPrintDebug)
|
|
@@ -564,7 +582,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
564
582
|
continue
|
|
565
583
|
}
|
|
566
584
|
const val = classNames[cn]
|
|
567
|
-
definition.properties.push(
|
|
585
|
+
definition.properties.push(
|
|
586
|
+
t.objectProperty(t.stringLiteral(cn), t.stringLiteral(val))
|
|
587
|
+
)
|
|
568
588
|
}
|
|
569
589
|
|
|
570
590
|
if (out.rulesToInsert) {
|
|
@@ -589,7 +609,10 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
589
609
|
const closingElement = traversePath.node.closingElement
|
|
590
610
|
|
|
591
611
|
// skip non-identifier opening elements (member expressions, etc.)
|
|
592
|
-
if (
|
|
612
|
+
if (
|
|
613
|
+
t.isJSXMemberExpression(closingElement?.name) ||
|
|
614
|
+
!t.isJSXIdentifier(node.name)
|
|
615
|
+
) {
|
|
593
616
|
return
|
|
594
617
|
}
|
|
595
618
|
|
|
@@ -607,7 +630,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
607
630
|
modulePath = binding.path.parent.source.value
|
|
608
631
|
if (!isValidImport(propsWithFileInfo, modulePath, binding.identifier.name)) {
|
|
609
632
|
if (shouldPrintDebug) {
|
|
610
|
-
logger.info(
|
|
633
|
+
logger.info(
|
|
634
|
+
` - Binding not internal import or from components ${modulePath}`
|
|
635
|
+
)
|
|
611
636
|
}
|
|
612
637
|
return
|
|
613
638
|
}
|
|
@@ -637,7 +662,8 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
637
662
|
// debug just one
|
|
638
663
|
const debugPropValue = node.attributes
|
|
639
664
|
.filter(
|
|
640
|
-
(n) =>
|
|
665
|
+
(n) =>
|
|
666
|
+
t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === 'debug'
|
|
641
667
|
)
|
|
642
668
|
// @ts-ignore
|
|
643
669
|
.map((n: t.JSXAttribute) => {
|
|
@@ -653,7 +679,8 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
653
679
|
if (shouldPrintDebug) {
|
|
654
680
|
logger.info('\n')
|
|
655
681
|
logger.info(
|
|
656
|
-
`\x1b[33m%s\x1b[0m ` +
|
|
682
|
+
`\x1b[33m%s\x1b[0m ` +
|
|
683
|
+
`${componentName} | ${codePosition} -------------------`
|
|
657
684
|
)
|
|
658
685
|
// prettier-ignore
|
|
659
686
|
logger.info(['\x1b[1m', '\x1b[32m', `<${originalNodeName} />`, disableDebugAttr ? '' : '🐛'].join(' '))
|
|
@@ -717,7 +744,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
717
744
|
...(staticConfig.deoptProps || []),
|
|
718
745
|
])
|
|
719
746
|
|
|
720
|
-
const inlineWhenUnflattened = new Set([
|
|
747
|
+
const inlineWhenUnflattened = new Set([
|
|
748
|
+
...(staticConfig.inlineWhenUnflattened || []),
|
|
749
|
+
])
|
|
721
750
|
|
|
722
751
|
// Generate scope object at this level
|
|
723
752
|
const staticNamespace = getStaticBindingsForScope(
|
|
@@ -907,7 +936,10 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
907
936
|
return [
|
|
908
937
|
...(createTernariesFromObjectProperties(test, alt) || []),
|
|
909
938
|
...((cons &&
|
|
910
|
-
createTernariesFromObjectProperties(
|
|
939
|
+
createTernariesFromObjectProperties(
|
|
940
|
+
t.unaryExpression('!', test),
|
|
941
|
+
cons
|
|
942
|
+
)) ||
|
|
911
943
|
[]),
|
|
912
944
|
].map((ternary) => ({
|
|
913
945
|
type: 'ternary',
|
|
@@ -1013,7 +1045,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1013
1045
|
})()
|
|
1014
1046
|
|
|
1015
1047
|
const remove = () => {
|
|
1016
|
-
Array.isArray(valuePath)
|
|
1048
|
+
Array.isArray(valuePath)
|
|
1049
|
+
? valuePath.map((p) => p.remove())
|
|
1050
|
+
: valuePath.remove()
|
|
1017
1051
|
}
|
|
1018
1052
|
|
|
1019
1053
|
if (name === 'ref') {
|
|
@@ -1037,7 +1071,10 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1037
1071
|
if (value.type === 'StringLiteral' && value.value[0] === '$') {
|
|
1038
1072
|
if (shouldPrintDebug) {
|
|
1039
1073
|
logger.info(
|
|
1040
|
-
[
|
|
1074
|
+
[
|
|
1075
|
+
` ! inlining, native disable extract: ${name} =`,
|
|
1076
|
+
value.value,
|
|
1077
|
+
].join(' ')
|
|
1041
1078
|
)
|
|
1042
1079
|
}
|
|
1043
1080
|
inlined.set(name, true)
|
|
@@ -1183,7 +1220,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1183
1220
|
const lVal = attemptEvalSafe(left)
|
|
1184
1221
|
const rVal = attemptEvalSafe(right)
|
|
1185
1222
|
if (shouldPrintDebug) {
|
|
1186
|
-
logger.info(
|
|
1223
|
+
logger.info(
|
|
1224
|
+
` evalBinaryExpression lVal ${String(lVal)}, rVal ${String(rVal)}`
|
|
1225
|
+
)
|
|
1187
1226
|
}
|
|
1188
1227
|
if (lVal !== FAILED_EVAL && t.isConditionalExpression(right)) {
|
|
1189
1228
|
const ternary = addBinaryConditional(operator, left, right)
|
|
@@ -1234,8 +1273,12 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1234
1273
|
cond: t.ConditionalExpression
|
|
1235
1274
|
): ExtractedAttr | null {
|
|
1236
1275
|
if (getStaticConditional(cond)) {
|
|
1237
|
-
const alt = attemptEval(
|
|
1238
|
-
|
|
1276
|
+
const alt = attemptEval(
|
|
1277
|
+
t.binaryExpression(operator, staticExpr, cond.alternate)
|
|
1278
|
+
)
|
|
1279
|
+
const cons = attemptEval(
|
|
1280
|
+
t.binaryExpression(operator, staticExpr, cond.consequent)
|
|
1281
|
+
)
|
|
1239
1282
|
if (shouldPrintDebug) {
|
|
1240
1283
|
logger.info([' binaryConditional', cond.test, cons, alt].join(' '))
|
|
1241
1284
|
}
|
|
@@ -1378,8 +1421,12 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1378
1421
|
if (t.isConditionalExpression(property.value)) {
|
|
1379
1422
|
// merge up into the parent conditional, split into two
|
|
1380
1423
|
const [truthy, falsy] = [
|
|
1381
|
-
t.objectExpression([
|
|
1382
|
-
|
|
1424
|
+
t.objectExpression([
|
|
1425
|
+
t.objectProperty(property.key, property.value.consequent),
|
|
1426
|
+
]),
|
|
1427
|
+
t.objectExpression([
|
|
1428
|
+
t.objectProperty(property.key, property.value.alternate),
|
|
1429
|
+
]),
|
|
1383
1430
|
].map((x) => attemptEval(x))
|
|
1384
1431
|
return [
|
|
1385
1432
|
createTernary({
|
|
@@ -1402,7 +1449,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1402
1449
|
}),
|
|
1403
1450
|
]
|
|
1404
1451
|
}
|
|
1405
|
-
const obj = t.objectExpression([
|
|
1452
|
+
const obj = t.objectExpression([
|
|
1453
|
+
t.objectProperty(property.key, property.value),
|
|
1454
|
+
])
|
|
1406
1455
|
const consequent = attemptEval(obj)
|
|
1407
1456
|
return createTernary({
|
|
1408
1457
|
remove() {},
|
|
@@ -1416,7 +1465,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1416
1465
|
|
|
1417
1466
|
if (couldntParse || shouldDeopt) {
|
|
1418
1467
|
if (shouldPrintDebug) {
|
|
1419
|
-
logger.info(
|
|
1468
|
+
logger.info(
|
|
1469
|
+
[` avoid optimizing:`, { couldntParse, shouldDeopt }].join(' ')
|
|
1470
|
+
)
|
|
1420
1471
|
}
|
|
1421
1472
|
node.attributes = ogAttributes
|
|
1422
1473
|
return
|
|
@@ -1490,7 +1541,8 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1490
1541
|
}
|
|
1491
1542
|
|
|
1492
1543
|
for (const [key] of [...inlined]) {
|
|
1493
|
-
const isStaticObjectVariant =
|
|
1544
|
+
const isStaticObjectVariant =
|
|
1545
|
+
staticConfig.variants?.[key] && variantValues.has(key)
|
|
1494
1546
|
if (INLINE_EXTRACTABLE[key] || isStaticObjectVariant) {
|
|
1495
1547
|
inlined.delete(key)
|
|
1496
1548
|
}
|
|
@@ -1545,7 +1597,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1545
1597
|
|
|
1546
1598
|
// remove theme attribute from flattened node
|
|
1547
1599
|
attrs = attrs.filter((x) =>
|
|
1548
|
-
x.type === 'attr' &&
|
|
1600
|
+
x.type === 'attr' &&
|
|
1601
|
+
t.isJSXAttribute(x.value) &&
|
|
1602
|
+
x.value.name.name === 'theme'
|
|
1549
1603
|
? false
|
|
1550
1604
|
: true
|
|
1551
1605
|
)
|
|
@@ -1555,7 +1609,12 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1555
1609
|
hasImportedTheme = true
|
|
1556
1610
|
programPath.node.body.push(
|
|
1557
1611
|
t.importDeclaration(
|
|
1558
|
-
[
|
|
1612
|
+
[
|
|
1613
|
+
t.importSpecifier(
|
|
1614
|
+
t.identifier('_TamaguiTheme'),
|
|
1615
|
+
t.identifier('Theme')
|
|
1616
|
+
),
|
|
1617
|
+
],
|
|
1559
1618
|
t.stringLiteral('@tamagui/core')
|
|
1560
1619
|
)
|
|
1561
1620
|
)
|
|
@@ -1575,24 +1634,28 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1575
1634
|
|
|
1576
1635
|
// only if we flatten, ensure the default styles are there
|
|
1577
1636
|
if (shouldFlatten) {
|
|
1578
|
-
const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap(
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1637
|
+
const defaultStyleAttrs = Object.keys(staticConfig.defaultProps).flatMap(
|
|
1638
|
+
(key) => {
|
|
1639
|
+
if (!isValidStyleKey(key, staticConfig)) {
|
|
1640
|
+
return []
|
|
1641
|
+
}
|
|
1642
|
+
const value = staticConfig.defaultProps[key]
|
|
1643
|
+
const name = tamaguiConfig.shorthands[key] || key
|
|
1644
|
+
if (value === undefined) {
|
|
1645
|
+
logger.warn(
|
|
1646
|
+
`⚠️ Error evaluating default style for component, prop ${key} ${value}`
|
|
1647
|
+
)
|
|
1648
|
+
shouldDeopt = true
|
|
1649
|
+
return
|
|
1650
|
+
}
|
|
1651
|
+
const attr: ExtractedAttrStyle = {
|
|
1652
|
+
type: 'style',
|
|
1653
|
+
name,
|
|
1654
|
+
value: { [name]: value },
|
|
1655
|
+
}
|
|
1656
|
+
return attr
|
|
1593
1657
|
}
|
|
1594
|
-
|
|
1595
|
-
}) as ExtractedAttr[]
|
|
1658
|
+
) as ExtractedAttr[]
|
|
1596
1659
|
|
|
1597
1660
|
if (defaultStyleAttrs.length) {
|
|
1598
1661
|
attrs = [...defaultStyleAttrs, ...attrs]
|
|
@@ -1601,7 +1664,7 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1601
1664
|
|
|
1602
1665
|
if (shouldDeopt || !shouldFlatten) {
|
|
1603
1666
|
if (shouldPrintDebug) {
|
|
1604
|
-
logger.info(`Deopting`)
|
|
1667
|
+
logger.info(`Deopting ${shouldDeopt} ${shouldFlatten}`)
|
|
1605
1668
|
}
|
|
1606
1669
|
node.attributes = ogAttributes
|
|
1607
1670
|
return
|
|
@@ -1609,7 +1672,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1609
1672
|
|
|
1610
1673
|
if (shouldPrintDebug) {
|
|
1611
1674
|
logger.info(
|
|
1612
|
-
[' - attrs (flattened): \n', logLines(attrs.map(attrStr).join(', '))].join(
|
|
1675
|
+
[' - attrs (flattened): \n', logLines(attrs.map(attrStr).join(', '))].join(
|
|
1676
|
+
' '
|
|
1677
|
+
)
|
|
1613
1678
|
)
|
|
1614
1679
|
}
|
|
1615
1680
|
|
|
@@ -1746,7 +1811,10 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1746
1811
|
// finally we have all styles + expansions, lets see if we need to skip
|
|
1747
1812
|
// any and keep them as attrs
|
|
1748
1813
|
if (disableExtractVariables) {
|
|
1749
|
-
if (
|
|
1814
|
+
if (
|
|
1815
|
+
value[0] === '$' &&
|
|
1816
|
+
(usedThemeKeys.has(key) || usedThemeKeys.has(fullKey))
|
|
1817
|
+
) {
|
|
1750
1818
|
if (shouldPrintDebug) {
|
|
1751
1819
|
logger.info([` keeping variable inline: ${key} =`, value].join(' '))
|
|
1752
1820
|
}
|
|
@@ -1768,7 +1836,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1768
1836
|
tm.mark('jsx-element-expanded', !!shouldPrintDebug)
|
|
1769
1837
|
if (shouldPrintDebug) {
|
|
1770
1838
|
logger.info(
|
|
1771
|
-
[' - attrs (expanded): \n', logLines(attrs.map(attrStr).join(', '))].join(
|
|
1839
|
+
[' - attrs (expanded): \n', logLines(attrs.map(attrStr).join(', '))].join(
|
|
1840
|
+
' '
|
|
1841
|
+
)
|
|
1772
1842
|
)
|
|
1773
1843
|
}
|
|
1774
1844
|
|
|
@@ -1799,7 +1869,10 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1799
1869
|
}
|
|
1800
1870
|
}
|
|
1801
1871
|
|
|
1802
|
-
function mergeStyles(
|
|
1872
|
+
function mergeStyles(
|
|
1873
|
+
prev: ViewStyle & PseudoStyles,
|
|
1874
|
+
nextIn: ViewStyle & PseudoStyles
|
|
1875
|
+
) {
|
|
1803
1876
|
const next = expandStylesWithoutVariants(nextIn)
|
|
1804
1877
|
for (const key in next) {
|
|
1805
1878
|
// merge pseudos
|
|
@@ -1840,7 +1913,9 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1840
1913
|
value: t.jsxAttribute(
|
|
1841
1914
|
t.jsxIdentifier(key),
|
|
1842
1915
|
t.jsxExpressionContainer(
|
|
1843
|
-
typeof value === 'string'
|
|
1916
|
+
typeof value === 'string'
|
|
1917
|
+
? t.stringLiteral(value)
|
|
1918
|
+
: literalToAst(value)
|
|
1844
1919
|
)
|
|
1845
1920
|
),
|
|
1846
1921
|
})
|
|
@@ -1861,14 +1936,22 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1861
1936
|
|
|
1862
1937
|
if (shouldPrintDebug) {
|
|
1863
1938
|
logger.info(
|
|
1864
|
-
[
|
|
1939
|
+
[
|
|
1940
|
+
' - attrs (combined 🔀): \n',
|
|
1941
|
+
logLines(attrs.map(attrStr).join(', ')),
|
|
1942
|
+
].join(' ')
|
|
1865
1943
|
)
|
|
1866
1944
|
logger.info(
|
|
1867
|
-
[
|
|
1945
|
+
[
|
|
1946
|
+
' - defaultProps: \n',
|
|
1947
|
+
logLines(objToStr(staticConfig.defaultProps)),
|
|
1948
|
+
].join(' ')
|
|
1868
1949
|
)
|
|
1869
1950
|
// prettier-ignore
|
|
1870
1951
|
logger.info([' - foundStaticProps: \n', logLines(objToStr(foundStaticProps))].join(' '))
|
|
1871
|
-
logger.info(
|
|
1952
|
+
logger.info(
|
|
1953
|
+
[' - completeProps: \n', logLines(objToStr(completeProps))].join(' ')
|
|
1954
|
+
)
|
|
1872
1955
|
}
|
|
1873
1956
|
|
|
1874
1957
|
// post process
|
|
@@ -1947,7 +2030,8 @@ export function createExtractor({ logger = console }: ExtractorOptions = { logge
|
|
|
1947
2030
|
const c = getStyles(attr.value.consequent, 'ternary.consequent')
|
|
1948
2031
|
if (a) attr.value.alternate = a
|
|
1949
2032
|
if (c) attr.value.consequent = c
|
|
1950
|
-
if (shouldPrintDebug)
|
|
2033
|
+
if (shouldPrintDebug)
|
|
2034
|
+
logger.info([' => tern ', attrStr(attr)].join(' '))
|
|
1951
2035
|
continue
|
|
1952
2036
|
}
|
|
1953
2037
|
case 'style': {
|