@tamagui/static 1.0.0-alpha.7 → 1.0.0-alpha.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/dist/extractor/createExtractor.js +17 -10
- package/dist/extractor/createExtractor.js.map +2 -2
- package/dist/extractor/extractToClassNames.js +1 -1
- package/dist/extractor/extractToClassNames.js.map +2 -2
- package/dist/index.cjs +19 -12
- package/dist/index.cjs.map +2 -2
- package/package.json +8 -7
- package/src/extractor/createExtractor.ts +25 -25
- package/src/extractor/extractToClassNames.ts +1 -1
- package/src/types.ts +6 -1
- package/types.d.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.8",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@types/webpack": "^4.41.26",
|
|
36
36
|
"babel-loader": "^8.2.2",
|
|
37
37
|
"css-loader": "^5.2.4",
|
|
38
|
+
"esbuild-loader": "^2.16.0",
|
|
38
39
|
"jest": "^27.3.1",
|
|
39
40
|
"loader-utils": "^2.0.0",
|
|
40
41
|
"react": "*",
|
|
@@ -52,11 +53,11 @@
|
|
|
52
53
|
"@babel/traverse": "^7.15.4",
|
|
53
54
|
"@dish/babel-preset": "^0.0.6",
|
|
54
55
|
"@expo/match-media": "^0.1.0",
|
|
55
|
-
"@tamagui/build": "^1.0.0-alpha.
|
|
56
|
-
"@tamagui/core": "^1.0.0-alpha.
|
|
57
|
-
"@tamagui/core-node": "^1.0.0-alpha.
|
|
56
|
+
"@tamagui/build": "^1.0.0-alpha.8",
|
|
57
|
+
"@tamagui/core": "^1.0.0-alpha.8",
|
|
58
|
+
"@tamagui/core-node": "^1.0.0-alpha.8",
|
|
58
59
|
"@tamagui/fake-react-native": "^1.0.0-alpha.2",
|
|
59
|
-
"@tamagui/helpers": "^1.0.0-alpha.
|
|
60
|
+
"@tamagui/helpers": "^1.0.0-alpha.8",
|
|
60
61
|
"babel-literal-to-ast": "^2.1.0",
|
|
61
62
|
"esbuild": "^0.13.12",
|
|
62
63
|
"esbuild-register": "^3.1.2",
|
|
@@ -64,10 +65,10 @@
|
|
|
64
65
|
"fs-extra": "^9.0.0",
|
|
65
66
|
"invariant": "^2.2.4",
|
|
66
67
|
"lodash": "^4.17.20",
|
|
67
|
-
"tamagui": "^1.0.0-alpha.
|
|
68
|
+
"tamagui": "^1.0.0-alpha.8"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
71
|
"react-native-web": "*"
|
|
71
72
|
},
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "ecb0afe6782276b1f2ece90320fd2748f2f05c93"
|
|
73
74
|
}
|
|
@@ -54,7 +54,7 @@ export function createExtractor() {
|
|
|
54
54
|
let hasLogged = false
|
|
55
55
|
|
|
56
56
|
return {
|
|
57
|
-
|
|
57
|
+
getTamagui() {
|
|
58
58
|
return loadedTamaguiConfig
|
|
59
59
|
},
|
|
60
60
|
parse: (
|
|
@@ -576,12 +576,12 @@ export function createExtractor() {
|
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
// shorthand media queries
|
|
579
|
-
if (
|
|
580
|
-
name[0] === '$' &&
|
|
581
|
-
t.isJSXExpressionContainer(attribute?.value) &&
|
|
579
|
+
if (name[0] === '$' && t.isJSXExpressionContainer(attribute?.value)) {
|
|
582
580
|
// allow disabling this extraction
|
|
583
|
-
|
|
584
|
-
|
|
581
|
+
if (disableExtractInlineMedia) {
|
|
582
|
+
return attr
|
|
583
|
+
}
|
|
584
|
+
|
|
585
585
|
const shortname = name.slice(1)
|
|
586
586
|
if (mediaQueryConfig[shortname]) {
|
|
587
587
|
const expression = attribute.value.expression
|
|
@@ -633,8 +633,8 @@ export function createExtractor() {
|
|
|
633
633
|
// if value can be evaluated, extract it and filter it out
|
|
634
634
|
const styleValue = attemptEvalSafe(value)
|
|
635
635
|
|
|
636
|
-
//
|
|
637
|
-
//
|
|
636
|
+
// never flatten if a prop isn't a valid static attribute
|
|
637
|
+
// only post prop-mapping
|
|
638
638
|
if (!isStaticAttributeName(name)) {
|
|
639
639
|
let keys = [name]
|
|
640
640
|
if (staticConfig.propMapper) {
|
|
@@ -664,6 +664,8 @@ export function createExtractor() {
|
|
|
664
664
|
return {
|
|
665
665
|
type: 'style',
|
|
666
666
|
value: { [name]: styleValue },
|
|
667
|
+
name,
|
|
668
|
+
attr: path.node,
|
|
667
669
|
}
|
|
668
670
|
}
|
|
669
671
|
|
|
@@ -904,29 +906,27 @@ export function createExtractor() {
|
|
|
904
906
|
if (cur.type === 'style') {
|
|
905
907
|
// TODO need to loop over initial props not just style props
|
|
906
908
|
for (const key in cur.value) {
|
|
907
|
-
const
|
|
908
|
-
!!(
|
|
909
|
-
staticConfig.ensureOverriddenProp?.[key] // || staticConfig.defaultProps?.[key]
|
|
910
|
-
)
|
|
909
|
+
const shouldEnsureOverridden = !!staticConfig.ensureOverriddenProp?.[key]
|
|
911
910
|
const isSetInAttrsAlready = attrs.some(
|
|
912
911
|
(x) =>
|
|
913
912
|
x.type === 'attr' &&
|
|
914
913
|
x.value.type === 'JSXAttribute' &&
|
|
915
914
|
x.value.name.name === key
|
|
916
915
|
)
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
916
|
+
|
|
917
|
+
if (!isSetInAttrsAlready) {
|
|
918
|
+
const isVariant = !!staticConfig.variants?.[cur.name || '']
|
|
919
|
+
if (isVariant || shouldEnsureOverridden) {
|
|
920
|
+
acc.push({
|
|
921
|
+
type: 'attr',
|
|
922
|
+
value:
|
|
923
|
+
cur.attr ||
|
|
924
|
+
t.jsxAttribute(
|
|
925
|
+
t.jsxIdentifier(key),
|
|
926
|
+
t.jsxExpressionContainer(t.nullLiteral())
|
|
927
|
+
),
|
|
928
|
+
})
|
|
929
|
+
}
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
}
|
package/src/types.ts
CHANGED
|
@@ -32,7 +32,12 @@ export type ExtractedAttrAttr = {
|
|
|
32
32
|
value: t.JSXAttribute | t.JSXSpreadAttribute
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export type ExtractedAttrStyle = {
|
|
35
|
+
export type ExtractedAttrStyle = {
|
|
36
|
+
type: 'style'
|
|
37
|
+
value: Object
|
|
38
|
+
attr?: t.JSXAttribute | t.JSXSpreadAttribute
|
|
39
|
+
name?: string
|
|
40
|
+
}
|
|
36
41
|
|
|
37
42
|
export type ExtractedAttr =
|
|
38
43
|
| ExtractedAttrAttr
|
package/types.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export declare type ExtractedAttrAttr = {
|
|
|
27
27
|
export declare type ExtractedAttrStyle = {
|
|
28
28
|
type: "style";
|
|
29
29
|
value: Object;
|
|
30
|
+
attr?: t.JSXAttribute | t.JSXSpreadAttribute;
|
|
31
|
+
name?: string;
|
|
30
32
|
};
|
|
31
33
|
export declare type ExtractedAttr = ExtractedAttrAttr | {
|
|
32
34
|
type: "ternary";
|
|
@@ -157,7 +159,7 @@ export declare type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, "chi
|
|
|
157
159
|
};
|
|
158
160
|
export declare type Extractor = ReturnType<typeof createExtractor>;
|
|
159
161
|
export declare function createExtractor(): {
|
|
160
|
-
|
|
162
|
+
getTamagui(): TamaguiInternalConfig<import("@tamagui/core").CreateTokens<string | number | import("@tamagui/core").Variable>, {
|
|
161
163
|
[key: string]: {
|
|
162
164
|
bg: string | import("@tamagui/core").Variable;
|
|
163
165
|
bg2: string | import("@tamagui/core").Variable;
|