@tamagui/static 2.6.2 → 2.6.3
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/extractor/concatClassName.cjs +8 -0
- package/dist/extractor/createExtractor.cjs +17 -5
- package/dist/extractor/normalizeTernaries.cjs +5 -1
- package/package.json +15 -15
- package/src/extractor/concatClassName.ts +8 -0
- package/src/extractor/createExtractor.ts +34 -6
- package/src/extractor/normalizeTernaries.ts +5 -2
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/normalizeTernaries.d.ts +2 -0
- package/types/extractor/normalizeTernaries.d.ts.map +1 -1
|
@@ -44,6 +44,14 @@ function concatClassName(_cn) {
|
|
|
44
44
|
for (let i = numNames - 1; i >= 0; i--) {
|
|
45
45
|
const name = names[i];
|
|
46
46
|
if (!name || name === " ") continue;
|
|
47
|
+
if (name.startsWith("font_")) {
|
|
48
|
+
if (usedPrefixes.has("fontFamily")) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
usedPrefixes.add("fontFamily");
|
|
52
|
+
final = name + " " + final;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
47
55
|
if (name[0] !== "_") {
|
|
48
56
|
final = name + " " + final;
|
|
49
57
|
continue;
|
|
@@ -1477,6 +1477,13 @@ function createExtractor({
|
|
|
1477
1477
|
out.push(cur);
|
|
1478
1478
|
return out;
|
|
1479
1479
|
}, []).flat();
|
|
1480
|
+
const ternaryBranchProps = /* @__PURE__ */new Map();
|
|
1481
|
+
const allTernaries = attrs.flatMap(attr => attr.type === "ternary" ? attr.value : []);
|
|
1482
|
+
if (allTernaries.length > 1) {
|
|
1483
|
+
for (const ternary of (0, import_normalizeTernaries.normalizeTernaries)(allTernaries)) {
|
|
1484
|
+
ternaryBranchProps.set((0, import_normalizeTernaries.getTernaryKey)(ternary.test), ternary);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1480
1487
|
if (themeVal) {
|
|
1481
1488
|
if (!programPath) {
|
|
1482
1489
|
console.warn(`No program path found, avoiding importing flattening / importing theme in ${sourcePath}`);
|
|
@@ -1610,7 +1617,7 @@ function createExtractor({
|
|
|
1610
1617
|
logger.info([" - attrs (expanded): \n", (0, import_logLines.logLines)(attrs.map(import_extractHelpers.attrStr).join(", "))].join(" "));
|
|
1611
1618
|
}
|
|
1612
1619
|
let prev = null;
|
|
1613
|
-
const getProps = (props, includeProps = false, debugName = "") => {
|
|
1620
|
+
const getProps = (props, includeProps = false, debugName = "", branchProps) => {
|
|
1614
1621
|
if (!props) {
|
|
1615
1622
|
if (shouldPrintDebug) logger.info([" getProps() no props"].join(" "));
|
|
1616
1623
|
return {};
|
|
@@ -1626,6 +1633,10 @@ function createExtractor({
|
|
|
1626
1633
|
const before = process.env.IS_STATIC;
|
|
1627
1634
|
process.env.IS_STATIC = "is_static";
|
|
1628
1635
|
try {
|
|
1636
|
+
const fallbackProps = branchProps ? {
|
|
1637
|
+
...completeProps,
|
|
1638
|
+
...branchProps
|
|
1639
|
+
} : completeProps;
|
|
1629
1640
|
let extractedMediaLikeProps = null;
|
|
1630
1641
|
let propsForSplit = props;
|
|
1631
1642
|
for (const k in props) {
|
|
@@ -1647,7 +1658,7 @@ function createExtractor({
|
|
|
1647
1658
|
const out = getSplitStyles(propsForSplit, staticConfig, defaultTheme, "", componentState, {
|
|
1648
1659
|
...styleProps,
|
|
1649
1660
|
noClass: true,
|
|
1650
|
-
fallbackProps
|
|
1661
|
+
fallbackProps,
|
|
1651
1662
|
...(platform2 === "native" && {
|
|
1652
1663
|
resolveValues: "except-theme"
|
|
1653
1664
|
})
|
|
@@ -1659,7 +1670,7 @@ function createExtractor({
|
|
|
1659
1670
|
const blockOut = getSplitStyles(block, staticConfig, defaultTheme, "", componentState, {
|
|
1660
1671
|
...styleProps,
|
|
1661
1672
|
noClass: true,
|
|
1662
|
-
fallbackProps
|
|
1673
|
+
fallbackProps
|
|
1663
1674
|
}, void 0, void 0, void 0, void 0, false, debugPropValue || shouldPrintDebug);
|
|
1664
1675
|
if (blockOut) {
|
|
1665
1676
|
extractedMediaLikeProps[k] = {
|
|
@@ -1758,8 +1769,9 @@ function createExtractor({
|
|
|
1758
1769
|
switch (attr.type) {
|
|
1759
1770
|
case "ternary":
|
|
1760
1771
|
{
|
|
1761
|
-
const
|
|
1762
|
-
const
|
|
1772
|
+
const branchProps = ternaryBranchProps.get((0, import_normalizeTernaries.getTernaryKey)(attr.value.test));
|
|
1773
|
+
const a = getProps(attr.value.alternate, false, "ternary.alternate", branchProps?.alternate);
|
|
1774
|
+
const c = getProps(attr.value.consequent, false, "ternary.consequent", branchProps?.consequent);
|
|
1763
1775
|
if (a) attr.value.alternate = a;
|
|
1764
1776
|
if (c) attr.value.consequent = c;
|
|
1765
1777
|
if (shouldPrintDebug) logger.info([" => tern ", (0, import_extractHelpers.attrStr)(attr)].join(" "));
|
|
@@ -33,6 +33,7 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
33
33
|
}), mod);
|
|
34
34
|
var normalizeTernaries_exports = {};
|
|
35
35
|
__export(normalizeTernaries_exports, {
|
|
36
|
+
getTernaryKey: () => getTernaryKey,
|
|
36
37
|
normalizeTernaries: () => normalizeTernaries
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(normalizeTernaries_exports);
|
|
@@ -41,6 +42,9 @@ var t = __toESM(require("@babel/types"));
|
|
|
41
42
|
var import_web = require("@tamagui/web");
|
|
42
43
|
var import_invariant = __toESM(require("invariant"));
|
|
43
44
|
var import_propsToFontFamilyCache = require("./propsToFontFamilyCache.cjs");
|
|
45
|
+
function getTernaryKey(test) {
|
|
46
|
+
return (0, import_generator.default)(test).code;
|
|
47
|
+
}
|
|
44
48
|
function normalizeTernaries(ternaries) {
|
|
45
49
|
(0, import_invariant.default)(Array.isArray(ternaries), "extractStaticTernaries expects param 1 to be an array of ternaries");
|
|
46
50
|
if (ternaries.length === 0) {
|
|
@@ -69,7 +73,7 @@ function normalizeTernaries(ternaries) {
|
|
|
69
73
|
shouldSwap = true;
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
const key = (
|
|
76
|
+
const key = getTernaryKey(ternaryTest);
|
|
73
77
|
if (!ternariesByKey[key]) {
|
|
74
78
|
ternariesByKey[key] = {
|
|
75
79
|
...rest,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"@babel/template": "^7.25.0",
|
|
51
51
|
"@babel/traverse": "^7.25.4",
|
|
52
52
|
"@babel/types": "^7.25.4",
|
|
53
|
-
"@tamagui/cli-color": "2.6.
|
|
54
|
-
"@tamagui/config-default": "2.6.
|
|
55
|
-
"@tamagui/core": "2.6.
|
|
56
|
-
"@tamagui/fake-react-native": "2.6.
|
|
57
|
-
"@tamagui/generate-themes": "2.6.
|
|
58
|
-
"@tamagui/helpers": "2.6.
|
|
59
|
-
"@tamagui/helpers-node": "2.6.
|
|
60
|
-
"@tamagui/proxy-worm": "2.6.
|
|
61
|
-
"@tamagui/react-native-web-internals": "2.6.
|
|
62
|
-
"@tamagui/react-native-web-lite": "2.6.
|
|
63
|
-
"@tamagui/shorthands": "2.6.
|
|
64
|
-
"@tamagui/types": "2.6.
|
|
65
|
-
"@tamagui/web": "2.6.
|
|
53
|
+
"@tamagui/cli-color": "2.6.3",
|
|
54
|
+
"@tamagui/config-default": "2.6.3",
|
|
55
|
+
"@tamagui/core": "2.6.3",
|
|
56
|
+
"@tamagui/fake-react-native": "2.6.3",
|
|
57
|
+
"@tamagui/generate-themes": "2.6.3",
|
|
58
|
+
"@tamagui/helpers": "2.6.3",
|
|
59
|
+
"@tamagui/helpers-node": "2.6.3",
|
|
60
|
+
"@tamagui/proxy-worm": "2.6.3",
|
|
61
|
+
"@tamagui/react-native-web-internals": "2.6.3",
|
|
62
|
+
"@tamagui/react-native-web-lite": "2.6.3",
|
|
63
|
+
"@tamagui/shorthands": "2.6.3",
|
|
64
|
+
"@tamagui/types": "2.6.3",
|
|
65
|
+
"@tamagui/web": "2.6.3",
|
|
66
66
|
"babel-literal-to-ast": "^2.1.0",
|
|
67
67
|
"browserslist": "^4.28.1",
|
|
68
68
|
"check-dependency-version-consistency": "^4.1.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@babel/plugin-syntax-typescript": "^7.25.4",
|
|
82
|
-
"@tamagui/build": "2.6.
|
|
82
|
+
"@tamagui/build": "2.6.3",
|
|
83
83
|
"@types/babel__core": "^7.20.5",
|
|
84
84
|
"@types/find-root": "^1.1.2",
|
|
85
85
|
"@types/node": "^22.1.0",
|
|
@@ -32,6 +32,14 @@ export function concatClassName(_cn: Record<string, any> | null | undefined): st
|
|
|
32
32
|
const name = names[i]
|
|
33
33
|
|
|
34
34
|
if (!name || name === ' ') continue
|
|
35
|
+
if (name.startsWith('font_')) {
|
|
36
|
+
if (usedPrefixes.has('fontFamily')) {
|
|
37
|
+
continue
|
|
38
|
+
}
|
|
39
|
+
usedPrefixes.add('fontFamily')
|
|
40
|
+
final = name + ' ' + final
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
35
43
|
if (name[0] !== '_') {
|
|
36
44
|
// not snack style (todo slightly stronger heuristic)
|
|
37
45
|
final = name + ' ' + final
|
|
@@ -46,7 +46,7 @@ import { cleanupBeforeExit, getStaticBindingsForScope } from './getStaticBinding
|
|
|
46
46
|
import { literalToAst } from './literalToAst'
|
|
47
47
|
import { loadTamagui, loadTamaguiSync } from './loadTamagui'
|
|
48
48
|
import { logLines } from './logLines'
|
|
49
|
-
import { normalizeTernaries } from './normalizeTernaries'
|
|
49
|
+
import { getTernaryKey, normalizeTernaries } from './normalizeTernaries'
|
|
50
50
|
import { setPropsToFontFamily } from './propsToFontFamilyCache'
|
|
51
51
|
import { timer } from './timer'
|
|
52
52
|
import { validHTMLAttributes } from './validHTMLAttributes'
|
|
@@ -2129,6 +2129,16 @@ export function createExtractor(
|
|
|
2129
2129
|
}, [])
|
|
2130
2130
|
.flat()
|
|
2131
2131
|
|
|
2132
|
+
const ternaryBranchProps = new Map<string, Ternary>()
|
|
2133
|
+
const allTernaries = attrs.flatMap((attr) =>
|
|
2134
|
+
attr.type === 'ternary' ? attr.value : []
|
|
2135
|
+
)
|
|
2136
|
+
if (allTernaries.length > 1) {
|
|
2137
|
+
for (const ternary of normalizeTernaries(allTernaries)) {
|
|
2138
|
+
ternaryBranchProps.set(getTernaryKey(ternary.test), ternary)
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2132
2142
|
// wrap theme around children on flatten
|
|
2133
2143
|
// account for shouldFlatten could change w the above block "if (disableExtractVariables)"
|
|
2134
2144
|
if (themeVal) {
|
|
@@ -2397,7 +2407,8 @@ export function createExtractor(
|
|
|
2397
2407
|
const getProps = (
|
|
2398
2408
|
props: object | null,
|
|
2399
2409
|
includeProps = false,
|
|
2400
|
-
debugName = ''
|
|
2410
|
+
debugName = '',
|
|
2411
|
+
branchProps?: object | null
|
|
2401
2412
|
) => {
|
|
2402
2413
|
if (!props) {
|
|
2403
2414
|
if (shouldPrintDebug) logger.info([' getProps() no props'].join(' '))
|
|
@@ -2415,6 +2426,10 @@ export function createExtractor(
|
|
|
2415
2426
|
const before = process.env.IS_STATIC
|
|
2416
2427
|
process.env.IS_STATIC = 'is_static'
|
|
2417
2428
|
try {
|
|
2429
|
+
const fallbackProps = branchProps
|
|
2430
|
+
? { ...completeProps, ...branchProps }
|
|
2431
|
+
: completeProps
|
|
2432
|
+
|
|
2418
2433
|
// $group-* / $theme-* keys carry block-form style objects that
|
|
2419
2434
|
// getSplitStyles drops in static mode (no parent group context,
|
|
2420
2435
|
// no theme value to read). Pluck them out so the atomic-CSS
|
|
@@ -2453,7 +2468,7 @@ export function createExtractor(
|
|
|
2453
2468
|
{
|
|
2454
2469
|
...styleProps,
|
|
2455
2470
|
noClass: true,
|
|
2456
|
-
fallbackProps
|
|
2471
|
+
fallbackProps,
|
|
2457
2472
|
...(platform === 'native' && {
|
|
2458
2473
|
resolveValues: 'except-theme',
|
|
2459
2474
|
}),
|
|
@@ -2484,7 +2499,7 @@ export function createExtractor(
|
|
|
2484
2499
|
{
|
|
2485
2500
|
...styleProps,
|
|
2486
2501
|
noClass: true,
|
|
2487
|
-
fallbackProps
|
|
2502
|
+
fallbackProps,
|
|
2488
2503
|
},
|
|
2489
2504
|
undefined,
|
|
2490
2505
|
undefined,
|
|
@@ -2641,8 +2656,21 @@ export function createExtractor(
|
|
|
2641
2656
|
|
|
2642
2657
|
switch (attr.type) {
|
|
2643
2658
|
case 'ternary': {
|
|
2644
|
-
const
|
|
2645
|
-
|
|
2659
|
+
const branchProps = ternaryBranchProps.get(
|
|
2660
|
+
getTernaryKey(attr.value.test)
|
|
2661
|
+
)
|
|
2662
|
+
const a = getProps(
|
|
2663
|
+
attr.value.alternate,
|
|
2664
|
+
false,
|
|
2665
|
+
'ternary.alternate',
|
|
2666
|
+
branchProps?.alternate
|
|
2667
|
+
)
|
|
2668
|
+
const c = getProps(
|
|
2669
|
+
attr.value.consequent,
|
|
2670
|
+
false,
|
|
2671
|
+
'ternary.consequent',
|
|
2672
|
+
branchProps?.consequent
|
|
2673
|
+
)
|
|
2646
2674
|
if (a) attr.value.alternate = a
|
|
2647
2675
|
if (c) attr.value.consequent = c
|
|
2648
2676
|
if (shouldPrintDebug)
|
|
@@ -5,6 +5,10 @@ import invariant from 'invariant'
|
|
|
5
5
|
import type { Ternary } from '../types'
|
|
6
6
|
import { forwardFontFamilyName } from './propsToFontFamilyCache'
|
|
7
7
|
|
|
8
|
+
export function getTernaryKey(test: t.Node) {
|
|
9
|
+
return generate(test).code
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
export function normalizeTernaries(ternaries: Ternary[]) {
|
|
9
13
|
invariant(
|
|
10
14
|
Array.isArray(ternaries),
|
|
@@ -43,8 +47,7 @@ export function normalizeTernaries(ternaries: Ternary[]) {
|
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
const key = generate(ternaryTest as any).code
|
|
50
|
+
const key = getTernaryKey(ternaryTest)
|
|
48
51
|
|
|
49
52
|
if (!ternariesByKey[key]) {
|
|
50
53
|
ternariesByKey[key] = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,iBAAiB,CAAA;AAEhE,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAmBjC,OAAO,KAAK,EAGV,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EAGf,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAoB,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAc1E,OAAO,EAAE,iBAAiB,EAA6B,MAAM,6BAA6B,CAAA;AAwB1F,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAE1D,KAAK,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AA6C9C,wBAAgB,eAAe,CAC7B,EAAE,MAAgB,EAAE,QAAgB,EAAE,GAAE,gBAAsC;;;;;yBAsJnD,cAAc;6BAPhB,cAAc;;mBAwBtB,UAAU,SAAS,mBAAmB;;;;;;;eAKpC,UAAU,SAAS,mBAAmB;;;;;;;
|
|
1
|
+
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,iBAAiB,CAAA;AAEhE,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAmBjC,OAAO,KAAK,EAGV,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EAGf,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAoB,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAc1E,OAAO,EAAE,iBAAiB,EAA6B,MAAM,6BAA6B,CAAA;AAwB1F,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAE1D,KAAK,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AA6C9C,wBAAgB,eAAe,CAC7B,EAAE,MAAgB,EAAE,QAAgB,EAAE,GAAE,gBAAsC;;;;;yBAsJnD,cAAc;6BAPhB,cAAc;;mBAwBtB,UAAU,SAAS,mBAAmB;;;;;;;eAKpC,UAAU,SAAS,mBAAmB;;;;;;;EA+kF1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeTernaries.d.ts","sourceRoot":"","sources":["../../src/extractor/normalizeTernaries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalizeTernaries.d.ts","sourceRoot":"","sources":["../../src/extractor/normalizeTernaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAGjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGvC,wBAAgB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,UAEzC;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,aAkEtD"}
|