@tamagui/static 1.46.1 → 1.47.0
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/extractor/bundleConfig.js.map +1 -1
- package/dist/cjs/extractor/createExtractor.js +54 -69
- package/dist/cjs/extractor/createExtractor.js.map +1 -1
- package/dist/esm/extractor/bundleConfig.js.map +1 -1
- package/dist/esm/extractor/createExtractor.js +55 -69
- package/dist/esm/extractor/createExtractor.js.map +1 -1
- package/package.json +15 -15
- package/src/extractor/bundleConfig.ts +5 -5
- package/src/extractor/createExtractor.ts +65 -72
- package/types/extractor/bundleConfig.d.ts +2 -2
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/extractHelpers.d.ts +2 -2
|
@@ -7,10 +7,17 @@ import {
|
|
|
7
7
|
expandStylesAndRemoveNullishValues,
|
|
8
8
|
getSplitStyles,
|
|
9
9
|
mediaQueryConfig,
|
|
10
|
+
propMapper,
|
|
10
11
|
proxyThemeVariables,
|
|
11
12
|
pseudoDescriptors,
|
|
12
13
|
} from '@tamagui/core-node'
|
|
13
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
GetStyleState,
|
|
16
|
+
PseudoStyles,
|
|
17
|
+
SplitStyleProps,
|
|
18
|
+
StaticConfig,
|
|
19
|
+
TamaguiComponentState,
|
|
20
|
+
} from '@tamagui/web'
|
|
14
21
|
import type { ViewStyle } from 'react-native'
|
|
15
22
|
import { createDOMProps } from 'react-native-web-internals'
|
|
16
23
|
|
|
@@ -66,17 +73,6 @@ const INLINE_EXTRACTABLE = {
|
|
|
66
73
|
}),
|
|
67
74
|
}
|
|
68
75
|
|
|
69
|
-
const defaultComponentState = {
|
|
70
|
-
focus: false,
|
|
71
|
-
hover: false,
|
|
72
|
-
unmounted: true,
|
|
73
|
-
press: false,
|
|
74
|
-
pressIn: false,
|
|
75
|
-
resolveVariablesAs: 'variable',
|
|
76
|
-
noClassNames: false,
|
|
77
|
-
isAnimated: false,
|
|
78
|
-
} as const
|
|
79
|
-
|
|
80
76
|
const validHooks = {
|
|
81
77
|
useMedia: true,
|
|
82
78
|
useTheme: true,
|
|
@@ -102,6 +98,20 @@ export function createExtractor(
|
|
|
102
98
|
process.exit(1)
|
|
103
99
|
}
|
|
104
100
|
|
|
101
|
+
const componentState: TamaguiComponentState = {
|
|
102
|
+
focus: false,
|
|
103
|
+
hover: false,
|
|
104
|
+
unmounted: true,
|
|
105
|
+
press: false,
|
|
106
|
+
pressIn: false,
|
|
107
|
+
} as const
|
|
108
|
+
|
|
109
|
+
const styleProps: SplitStyleProps = {
|
|
110
|
+
resolveVariablesAs: process.env.TAMAGUI_TARGET === 'native' ? 'value' : 'variable',
|
|
111
|
+
noClassNames: false,
|
|
112
|
+
isAnimated: false,
|
|
113
|
+
}
|
|
114
|
+
|
|
105
115
|
const shouldAddDebugProp =
|
|
106
116
|
// really basic disable this for next.js because it messes with ssr
|
|
107
117
|
!process.env.npm_package_dependencies_next &&
|
|
@@ -202,7 +212,7 @@ export function createExtractor(
|
|
|
202
212
|
return null
|
|
203
213
|
}
|
|
204
214
|
|
|
205
|
-
function isValidStyleKey(name: string, staticConfig:
|
|
215
|
+
function isValidStyleKey(name: string, staticConfig: StaticConfig) {
|
|
206
216
|
if (!projectInfo) {
|
|
207
217
|
throw new Error(`Tamagui extractor not loaded yet`)
|
|
208
218
|
}
|
|
@@ -416,10 +426,6 @@ export function createExtractor(
|
|
|
416
426
|
found: 0,
|
|
417
427
|
}
|
|
418
428
|
|
|
419
|
-
const themeState =
|
|
420
|
-
// TODO
|
|
421
|
-
{ theme: defaultTheme, name: '' }
|
|
422
|
-
|
|
423
429
|
callTraverse({
|
|
424
430
|
// @ts-ignore
|
|
425
431
|
Program: {
|
|
@@ -588,8 +594,10 @@ export function createExtractor(
|
|
|
588
594
|
const out = getSplitStyles(
|
|
589
595
|
styles,
|
|
590
596
|
Component.staticConfig,
|
|
591
|
-
|
|
592
|
-
|
|
597
|
+
defaultTheme,
|
|
598
|
+
'',
|
|
599
|
+
componentState,
|
|
600
|
+
styleProps,
|
|
593
601
|
undefined,
|
|
594
602
|
undefined,
|
|
595
603
|
undefined,
|
|
@@ -768,12 +776,13 @@ export function createExtractor(
|
|
|
768
776
|
|
|
769
777
|
try {
|
|
770
778
|
const { staticConfig } = component
|
|
779
|
+
const defaultProps = { ...(staticConfig.defaultProps || {}) }
|
|
771
780
|
const variants = staticConfig.variants || {}
|
|
772
781
|
const isTextView = staticConfig.isText || false
|
|
773
782
|
const validStyles = staticConfig?.validStyles ?? {}
|
|
774
783
|
|
|
775
784
|
// find tag="a" tag="main" etc dom indicators
|
|
776
|
-
let tagName =
|
|
785
|
+
let tagName = defaultProps.tag ?? (isTextView ? 'span' : 'div')
|
|
777
786
|
traversePath
|
|
778
787
|
.get('openingElement')
|
|
779
788
|
.get('attributes')
|
|
@@ -882,12 +891,13 @@ export function createExtractor(
|
|
|
882
891
|
classNames: {},
|
|
883
892
|
style: {},
|
|
884
893
|
theme: defaultTheme,
|
|
885
|
-
viewProps:
|
|
894
|
+
viewProps: defaultProps,
|
|
886
895
|
conf: tamaguiConfig!,
|
|
887
|
-
curProps:
|
|
888
|
-
props:
|
|
889
|
-
|
|
890
|
-
|
|
896
|
+
curProps: defaultProps,
|
|
897
|
+
props: defaultProps,
|
|
898
|
+
componentState,
|
|
899
|
+
styleProps: {
|
|
900
|
+
...styleProps,
|
|
891
901
|
resolveVariablesAs: 'auto',
|
|
892
902
|
},
|
|
893
903
|
debug: shouldPrintDebug,
|
|
@@ -1127,7 +1137,7 @@ export function createExtractor(
|
|
|
1127
1137
|
|
|
1128
1138
|
// for now passing empty props {}, a bit odd, need to at least document
|
|
1129
1139
|
// for now we don't expose custom components so just noting behavior
|
|
1130
|
-
out =
|
|
1140
|
+
out = propMapper(name, styleValue, propMapperStyleState)
|
|
1131
1141
|
|
|
1132
1142
|
if (out) {
|
|
1133
1143
|
if (!Array.isArray(out)) {
|
|
@@ -1204,7 +1214,7 @@ export function createExtractor(
|
|
|
1204
1214
|
if (shouldPrintDebug) {
|
|
1205
1215
|
logger.info(` style: ${name} = ${styleValue}`)
|
|
1206
1216
|
}
|
|
1207
|
-
if (!(name in
|
|
1217
|
+
if (!(name in defaultProps)) {
|
|
1208
1218
|
if (!hasSetOptimized) {
|
|
1209
1219
|
res.optimized++
|
|
1210
1220
|
hasSetOptimized = true
|
|
@@ -1655,28 +1665,26 @@ export function createExtractor(
|
|
|
1655
1665
|
|
|
1656
1666
|
// only if we flatten, ensure the default styles are there
|
|
1657
1667
|
if (shouldFlatten) {
|
|
1658
|
-
const defaultStyleAttrs = Object.keys(
|
|
1659
|
-
(key)
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
value: { [name]: value },
|
|
1676
|
-
}
|
|
1677
|
-
return attr
|
|
1668
|
+
const defaultStyleAttrs = Object.keys(defaultProps).flatMap((key) => {
|
|
1669
|
+
if (!isValidStyleKey(key, staticConfig)) {
|
|
1670
|
+
return []
|
|
1671
|
+
}
|
|
1672
|
+
const value = defaultProps[key]
|
|
1673
|
+
const name = tamaguiConfig?.shorthands[key] || key
|
|
1674
|
+
if (value === undefined) {
|
|
1675
|
+
logger.warn(
|
|
1676
|
+
`⚠️ Error evaluating default style for component, prop ${key} ${value}`
|
|
1677
|
+
)
|
|
1678
|
+
shouldDeopt = true
|
|
1679
|
+
return
|
|
1680
|
+
}
|
|
1681
|
+
const attr: ExtractedAttrStyle = {
|
|
1682
|
+
type: 'style',
|
|
1683
|
+
name,
|
|
1684
|
+
value: { [name]: value },
|
|
1678
1685
|
}
|
|
1679
|
-
|
|
1686
|
+
return attr
|
|
1687
|
+
}) as ExtractedAttr[]
|
|
1680
1688
|
|
|
1681
1689
|
if (defaultStyleAttrs.length) {
|
|
1682
1690
|
attrs = [...defaultStyleAttrs, ...attrs]
|
|
@@ -1699,16 +1707,6 @@ export function createExtractor(
|
|
|
1699
1707
|
)
|
|
1700
1708
|
}
|
|
1701
1709
|
|
|
1702
|
-
const state = {
|
|
1703
|
-
noClassNames: false,
|
|
1704
|
-
focus: false,
|
|
1705
|
-
hover: false,
|
|
1706
|
-
unmounted: false, // TODO match logic in createComponent
|
|
1707
|
-
press: false,
|
|
1708
|
-
pressIn: false,
|
|
1709
|
-
isAnimated: false,
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
1710
|
function mergeToEnd(obj: Object, key: string, val: any) {
|
|
1713
1711
|
if (key in obj) {
|
|
1714
1712
|
delete obj[key]
|
|
@@ -1767,9 +1765,9 @@ export function createExtractor(
|
|
|
1767
1765
|
|
|
1768
1766
|
// must preserve exact order
|
|
1769
1767
|
const completeProps = {}
|
|
1770
|
-
for (const key in
|
|
1768
|
+
for (const key in defaultProps) {
|
|
1771
1769
|
if (!(key in foundStaticProps)) {
|
|
1772
|
-
completeProps[key] =
|
|
1770
|
+
completeProps[key] = defaultProps[key]
|
|
1773
1771
|
}
|
|
1774
1772
|
}
|
|
1775
1773
|
for (const key in foundStaticProps) {
|
|
@@ -1797,11 +1795,7 @@ export function createExtractor(
|
|
|
1797
1795
|
}
|
|
1798
1796
|
|
|
1799
1797
|
let out = Object.fromEntries(
|
|
1800
|
-
|
|
1801
|
-
name,
|
|
1802
|
-
variantValues.get(name),
|
|
1803
|
-
styleState
|
|
1804
|
-
) || []
|
|
1798
|
+
propMapper(name, variantValues.get(name), styleState) || []
|
|
1805
1799
|
)
|
|
1806
1800
|
if (out && isTargetingHTML) {
|
|
1807
1801
|
const cn = out.className
|
|
@@ -1959,10 +1953,7 @@ export function createExtractor(
|
|
|
1959
1953
|
].join(' ')
|
|
1960
1954
|
)
|
|
1961
1955
|
logger.info(
|
|
1962
|
-
[
|
|
1963
|
-
' - defaultProps: \n',
|
|
1964
|
-
logLines(objToStr(staticConfig.defaultProps)),
|
|
1965
|
-
].join(' ')
|
|
1956
|
+
[' - defaultProps: \n', logLines(objToStr(defaultProps))].join(' ')
|
|
1966
1957
|
)
|
|
1967
1958
|
// prettier-ignore
|
|
1968
1959
|
logger.info([' - foundStaticProps: \n', logLines(objToStr(foundStaticProps))].join(' '))
|
|
@@ -1994,9 +1985,11 @@ export function createExtractor(
|
|
|
1994
1985
|
const out = getSplitStyles(
|
|
1995
1986
|
props,
|
|
1996
1987
|
staticConfig,
|
|
1997
|
-
|
|
1988
|
+
defaultTheme,
|
|
1989
|
+
'',
|
|
1990
|
+
componentState,
|
|
1998
1991
|
{
|
|
1999
|
-
...
|
|
1992
|
+
...styleProps,
|
|
2000
1993
|
fallbackProps: completeProps,
|
|
2001
1994
|
},
|
|
2002
1995
|
undefined,
|
|
@@ -2110,7 +2103,7 @@ export function createExtractor(
|
|
|
2110
2103
|
if (shouldFlatten) {
|
|
2111
2104
|
attrs.unshift({
|
|
2112
2105
|
type: 'style',
|
|
2113
|
-
value: getProps(
|
|
2106
|
+
value: getProps(defaultProps) as any,
|
|
2114
2107
|
})
|
|
2115
2108
|
}
|
|
2116
2109
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StaticConfig, TamaguiInternalConfig } from '@tamagui/web';
|
|
2
2
|
import { TamaguiOptions } from '../types';
|
|
3
3
|
type NameToPaths = {
|
|
4
4
|
[key: string]: Set<string>;
|
|
@@ -6,7 +6,7 @@ type NameToPaths = {
|
|
|
6
6
|
export type LoadedComponents = {
|
|
7
7
|
moduleName: string;
|
|
8
8
|
nameToInfo: Record<string, {
|
|
9
|
-
staticConfig:
|
|
9
|
+
staticConfig: StaticConfig;
|
|
10
10
|
}>;
|
|
11
11
|
};
|
|
12
12
|
export type TamaguiProjectInfo = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleConfig.d.ts","sourceRoot":"","sources":["../../src/extractor/bundleConfig.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"bundleConfig.d.ts","sourceRoot":"","sources":["../../src/extractor/bundleConfig.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAKvE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAOzC,KAAK,WAAW,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAChB,MAAM,EACN;QACE,YAAY,EAAE,YAAY,CAAA;KAC3B,CACF,CAAA;CACF,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC/B,aAAa,CAAC,EAAE,qBAAqB,CAAA;IACrC,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B,CAAA;AAiBD,eAAO,MAAM,cAAc;;;;;;;;CAMK,CAAA;AAEhC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;AAQxF,wBAAgB,uBAAuB,YAMtC;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,UAAQ;;;;sBAS5E;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,cAAc;;;;eA0JvD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,GAAG,gBAAgB,EAAE,CA8H/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAGA,OAAiB,EAAE,QAAQ,EAAmB,MAAM,iBAAiB,CAAA;AACrE,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAGA,OAAiB,EAAE,QAAQ,EAAmB,MAAM,iBAAiB,CAAA;AACrE,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAoBjC,OAAO,KAAK,EAGV,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EAGf,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAcnD,OAAO,EAAE,iBAAiB,EAA6B,MAAM,6BAA6B,CAAA;AAmC1F,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;AAQ9C,wBAAgB,eAAe,CAC7B,EAAE,MAAgB,EAAE,GAAE,gBAAsC;;;;;yBA0CjC,cAAc;6BAPhB,cAAc;;mBAwBtB,UAAU,SAAS,mBAAmB;;;;;;;eAIpC,UAAU,SAAS,mBAAmB;;;;;;;EAwjE1D"}
|
|
@@ -11,14 +11,14 @@ export declare function isValidThemeHook(props: TamaguiOptionsWithFileInfo, jsxP
|
|
|
11
11
|
export declare const isInsideComponentPackage: (props: TamaguiOptionsWithFileInfo, moduleName: string) => any;
|
|
12
12
|
export declare const isComponentPackage: (props: TamaguiOptionsWithFileInfo, srcName: string) => any;
|
|
13
13
|
export declare function getValidComponent(props: TamaguiOptionsWithFileInfo, moduleName: string, componentName: string): false | {
|
|
14
|
-
staticConfig: import("@tamagui/web").
|
|
14
|
+
staticConfig: import("@tamagui/web").StaticConfig;
|
|
15
15
|
} | null;
|
|
16
16
|
export declare const isValidModule: (props: TamaguiOptionsWithFileInfo, moduleName: string) => {
|
|
17
17
|
isLocal: boolean;
|
|
18
18
|
isValid: any;
|
|
19
19
|
};
|
|
20
20
|
export declare const getValidImport: (props: TamaguiOptionsWithFileInfo, moduleName: string, componentName?: string) => {
|
|
21
|
-
staticConfig: import("@tamagui/web").
|
|
21
|
+
staticConfig: import("@tamagui/web").StaticConfig;
|
|
22
22
|
} | null;
|
|
23
23
|
export declare const isValidImport: (props: TamaguiOptionsWithFileInfo, moduleName: string, componentName?: string) => any;
|
|
24
24
|
export declare const getValidComponentsPaths: {
|