@tamagui/static 1.0.0-alpha.1 → 1.0.0-alpha.5
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/LICENSE +21 -0
- package/dist/extractor/createExtractor.js +6 -2
- package/dist/extractor/createExtractor.js.map +2 -2
- package/dist/extractor/extractHelpers.js +3 -1
- package/dist/extractor/extractHelpers.js.map +2 -2
- package/dist/index.cjs +9 -3
- package/dist/index.cjs.map +2 -2
- package/package.json +23 -22
- package/src/extractor/createExtractor.ts +7 -4
- package/src/extractor/extractHelpers.ts +12 -3
- package/types.d.ts +210 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.5",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"typings": "types.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
+
"types.d.ts",
|
|
9
10
|
"dist",
|
|
10
11
|
"src"
|
|
11
12
|
],
|
|
@@ -25,48 +26,48 @@
|
|
|
25
26
|
},
|
|
26
27
|
"license": "MIT",
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.15.5",
|
|
29
|
-
"@babel/generator": "^7.15.4",
|
|
30
|
-
"@babel/helper-plugin-utils": "^7.14.5",
|
|
31
|
-
"@babel/parser": "^7.15.7",
|
|
32
29
|
"@babel/plugin-syntax-typescript": "^7.14.5",
|
|
33
|
-
"@babel/traverse": "^7.15.4",
|
|
34
30
|
"@babel/types": "^7.15.6",
|
|
35
|
-
"@dish/babel-preset": "^0.0.6",
|
|
36
|
-
"@expo/match-media": "^0.1.0",
|
|
37
|
-
"@tamagui/build": "^1.0.0-alpha.1",
|
|
38
|
-
"@tamagui/core": "^1.0.0-alpha.1",
|
|
39
31
|
"@testing-library/react": "13.0.0-alpha.4",
|
|
40
32
|
"@types/jest": "*",
|
|
41
33
|
"@types/node": "^16.11.9",
|
|
42
34
|
"@types/react-native": "^0.64.2",
|
|
43
35
|
"@types/webpack": "^4.41.26",
|
|
44
|
-
"babel-literal-to-ast": "^2.1.0",
|
|
45
36
|
"babel-loader": "^8.2.2",
|
|
46
37
|
"css-loader": "^5.2.4",
|
|
47
|
-
"esbuild": "^0.13.12",
|
|
48
|
-
"find-cache-dir": "^3.3.1",
|
|
49
|
-
"fs-extra": "^9.0.0",
|
|
50
|
-
"invariant": "^2.2.4",
|
|
51
38
|
"jest": "^27.3.1",
|
|
52
39
|
"loader-utils": "^2.0.0",
|
|
53
|
-
"lodash": "^4.17.20",
|
|
54
40
|
"react": "*",
|
|
55
41
|
"react-dom": "*",
|
|
56
42
|
"react-test-renderer": "18.0.0-beta-149b420f6-20211119",
|
|
57
43
|
"style-loader": "^3.3.0",
|
|
58
|
-
"tamagui": "^1.0.0-alpha.1",
|
|
59
44
|
"typescript": "^4.4.4",
|
|
60
45
|
"webpack": "^5.58.1"
|
|
61
46
|
},
|
|
62
47
|
"dependencies": {
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"
|
|
48
|
+
"@babel/core": "^7.15.5",
|
|
49
|
+
"@babel/generator": "^7.15.4",
|
|
50
|
+
"@babel/helper-plugin-utils": "^7.14.5",
|
|
51
|
+
"@babel/parser": "^7.15.7",
|
|
52
|
+
"@babel/traverse": "^7.15.4",
|
|
53
|
+
"@dish/babel-preset": "^0.0.6",
|
|
54
|
+
"@expo/match-media": "^0.1.0",
|
|
55
|
+
"@tamagui/build": "^1.0.0-alpha.2",
|
|
56
|
+
"@tamagui/core": "^1.0.0-alpha.5",
|
|
57
|
+
"@tamagui/core-node": "^1.0.0-alpha.5",
|
|
58
|
+
"@tamagui/fake-react-native": "^1.0.0-alpha.2",
|
|
59
|
+
"@tamagui/helpers": "^1.0.0-alpha.5",
|
|
60
|
+
"babel-literal-to-ast": "^2.1.0",
|
|
61
|
+
"esbuild": "^0.13.12",
|
|
62
|
+
"esbuild-register": "^3.1.2",
|
|
63
|
+
"find-cache-dir": "^3.3.1",
|
|
64
|
+
"fs-extra": "^9.0.0",
|
|
65
|
+
"invariant": "^2.2.4",
|
|
66
|
+
"lodash": "^4.17.20",
|
|
67
|
+
"tamagui": "^1.0.0-alpha.5"
|
|
67
68
|
},
|
|
68
69
|
"peerDependencies": {
|
|
69
70
|
"react-native-web": "*"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "e12f14aa087c41ea5ba3933a05f33fada0be03c0"
|
|
72
73
|
}
|
|
@@ -100,6 +100,7 @@ export function createExtractor() {
|
|
|
100
100
|
*/
|
|
101
101
|
const isInternalImport = (importStr: string) =>
|
|
102
102
|
isInsideTamagui(sourcePath) && importStr[0] === '.'
|
|
103
|
+
|
|
103
104
|
const validComponents: { [key: string]: any } = Object.keys(components)
|
|
104
105
|
.filter((key) => !!components[key]?.staticConfig)
|
|
105
106
|
.reduce((obj, name) => {
|
|
@@ -399,9 +400,9 @@ export function createExtractor() {
|
|
|
399
400
|
}
|
|
400
401
|
const propName = prop.key['name']
|
|
401
402
|
if (!isStaticAttributeName(propName) && propName !== 'tag') {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
403
|
+
if (shouldPrintDebug) {
|
|
404
|
+
console.log(' not a valid style prop!', propName)
|
|
405
|
+
}
|
|
405
406
|
return false
|
|
406
407
|
}
|
|
407
408
|
return true
|
|
@@ -489,7 +490,9 @@ export function createExtractor() {
|
|
|
489
490
|
const [test, alt, cons] = conditional
|
|
490
491
|
if (!test) throw new Error(`no test`)
|
|
491
492
|
if ([alt, cons].some((side) => side && !isExtractable(side))) {
|
|
492
|
-
|
|
493
|
+
if (shouldPrintDebug) {
|
|
494
|
+
console.log('not extractable', alt, cons)
|
|
495
|
+
}
|
|
493
496
|
return attr
|
|
494
497
|
}
|
|
495
498
|
// split into individual ternaries per object property
|
|
@@ -21,7 +21,10 @@ export const attrStr = (attr: ExtractedAttr) => {
|
|
|
21
21
|
|
|
22
22
|
export const objToStr = (obj: any) => {
|
|
23
23
|
return Object.entries(obj)
|
|
24
|
-
.map(
|
|
24
|
+
.map(
|
|
25
|
+
([k, v]) =>
|
|
26
|
+
`${k}:${Array.isArray(v) ? `[...]` : v && typeof v === 'object' ? `{${objToStr(v)}}` : v}`
|
|
27
|
+
)
|
|
25
28
|
.join(', ')
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -69,7 +72,11 @@ export function findComponentName(scope) {
|
|
|
69
72
|
return componentName
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
export function isValidThemeHook(
|
|
75
|
+
export function isValidThemeHook(
|
|
76
|
+
jsxPath: NodePath<t.JSXElement>,
|
|
77
|
+
n: t.MemberExpression,
|
|
78
|
+
sourcePath: string
|
|
79
|
+
) {
|
|
73
80
|
if (!t.isIdentifier(n.object) || !t.isIdentifier(n.property)) return false
|
|
74
81
|
const bindings = jsxPath.scope.getAllBindings()
|
|
75
82
|
const binding = bindings[n.object.name]
|
|
@@ -90,4 +97,6 @@ export function isValidThemeHook(jsxPath: NodePath<t.JSXElement>, n: t.MemberExp
|
|
|
90
97
|
return true
|
|
91
98
|
}
|
|
92
99
|
|
|
93
|
-
export const isInsideTamagui = (srcName: string) =>
|
|
100
|
+
export const isInsideTamagui = (srcName: string) => {
|
|
101
|
+
return srcName.includes('/tamagui/_jsx') || srcName.includes('/core/src')
|
|
102
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v5.9.0
|
|
2
|
+
|
|
3
|
+
/// <reference types="babel__traverse" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
|
|
6
|
+
import * as t from '@babel/types';
|
|
7
|
+
|
|
8
|
+
export interface TamaguiOptions {
|
|
9
|
+
components: string[];
|
|
10
|
+
config?: string;
|
|
11
|
+
evaluateVars?: boolean;
|
|
12
|
+
importsWhitelist?: string[];
|
|
13
|
+
disableExtraction?: boolean;
|
|
14
|
+
exclude?: RegExp;
|
|
15
|
+
logTimings?: boolean;
|
|
16
|
+
cssPath?: string;
|
|
17
|
+
cssData?: any;
|
|
18
|
+
deoptProps?: Set<string>;
|
|
19
|
+
excludeProps?: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare type ExtractedAttrAttr = {
|
|
22
|
+
type: "attr";
|
|
23
|
+
value: t.JSXAttribute | t.JSXSpreadAttribute;
|
|
24
|
+
};
|
|
25
|
+
export declare type ExtractedAttrStyle = {
|
|
26
|
+
type: "style";
|
|
27
|
+
value: Object;
|
|
28
|
+
};
|
|
29
|
+
export declare type ExtractedAttr = ExtractedAttrAttr | {
|
|
30
|
+
type: "ternary";
|
|
31
|
+
value: Ternary;
|
|
32
|
+
} | ExtractedAttrStyle;
|
|
33
|
+
export declare type ExtractTagProps = {
|
|
34
|
+
attrs: ExtractedAttr[];
|
|
35
|
+
node: t.JSXOpeningElement;
|
|
36
|
+
attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any;
|
|
37
|
+
jsxPath: NodePath<t.JSXElement>;
|
|
38
|
+
programPath: NodePath<t.Program>;
|
|
39
|
+
originalNodeName: string;
|
|
40
|
+
lineNumbers: string;
|
|
41
|
+
filePath: string;
|
|
42
|
+
isFlattened: boolean;
|
|
43
|
+
};
|
|
44
|
+
export declare type ExtractorParseProps = TamaguiOptions & {
|
|
45
|
+
sourcePath?: string;
|
|
46
|
+
shouldPrintDebug?: boolean;
|
|
47
|
+
onExtractTag: (props: ExtractTagProps) => void;
|
|
48
|
+
getFlattenedNode: (props: {
|
|
49
|
+
isTextView: boolean;
|
|
50
|
+
tag: string;
|
|
51
|
+
}) => string;
|
|
52
|
+
onDidFlatten?: () => void;
|
|
53
|
+
};
|
|
54
|
+
export interface Ternary {
|
|
55
|
+
test: t.Expression;
|
|
56
|
+
inlineMediaQuery?: string;
|
|
57
|
+
remove: Function;
|
|
58
|
+
consequent: Object | null;
|
|
59
|
+
alternate: Object | null;
|
|
60
|
+
}
|
|
61
|
+
declare class Variable {
|
|
62
|
+
name: string;
|
|
63
|
+
val: string | number;
|
|
64
|
+
variable: string | number;
|
|
65
|
+
constructor({ val, name }: VariableIn);
|
|
66
|
+
}
|
|
67
|
+
export declare type VariableIn = {
|
|
68
|
+
val: string | number;
|
|
69
|
+
name: string;
|
|
70
|
+
};
|
|
71
|
+
export declare type ThemeProviderProps = {
|
|
72
|
+
themes: any;
|
|
73
|
+
defaultTheme: string;
|
|
74
|
+
disableRootThemeClass?: boolean;
|
|
75
|
+
children?: any;
|
|
76
|
+
};
|
|
77
|
+
export interface CreateTokens<Val extends number | string | Variable = number | string | Variable> {
|
|
78
|
+
font: {
|
|
79
|
+
[key: string]: GenericFont;
|
|
80
|
+
};
|
|
81
|
+
color: {
|
|
82
|
+
[key: string]: Val;
|
|
83
|
+
};
|
|
84
|
+
space: {
|
|
85
|
+
[key: string]: Val;
|
|
86
|
+
};
|
|
87
|
+
size: {
|
|
88
|
+
[key: string]: Val;
|
|
89
|
+
};
|
|
90
|
+
radius: {
|
|
91
|
+
[key: string]: Val;
|
|
92
|
+
};
|
|
93
|
+
zIndex: {
|
|
94
|
+
[key: string]: Val;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export declare type GenericTokens = CreateTokens;
|
|
98
|
+
export declare type GenericThemes = {
|
|
99
|
+
[key: string]: {
|
|
100
|
+
bg: string | Variable;
|
|
101
|
+
bg2: string | Variable;
|
|
102
|
+
bg3: string | Variable;
|
|
103
|
+
bg4: string | Variable;
|
|
104
|
+
color: string | Variable;
|
|
105
|
+
color2: string | Variable;
|
|
106
|
+
color3: string | Variable;
|
|
107
|
+
color4: string | Variable;
|
|
108
|
+
borderColor: string | Variable;
|
|
109
|
+
borderColor2: string | Variable;
|
|
110
|
+
shadowColor: string | Variable;
|
|
111
|
+
shadowColor2: string | Variable;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export declare type GenericShorthands = {};
|
|
115
|
+
export declare type GenericMedia<K extends string = string> = {
|
|
116
|
+
[key in K]: {
|
|
117
|
+
[key: string]: number | string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export declare type CreateTamaguiConfig<A extends GenericTokens, B extends GenericThemes, C extends GenericShorthands, D extends GenericMedia> = Partial<Pick<ThemeProviderProps, "defaultTheme" | "disableRootThemeClass">> & {
|
|
121
|
+
tokens: A;
|
|
122
|
+
themes: B;
|
|
123
|
+
shorthands: C;
|
|
124
|
+
media: D;
|
|
125
|
+
};
|
|
126
|
+
export declare type TamaguiInternalConfig<A extends GenericTokens = GenericTokens, B extends GenericThemes = GenericThemes, C extends GenericShorthands = GenericShorthands, D extends GenericMedia = GenericMedia> = CreateTamaguiConfig<A, B, C, D> & {
|
|
127
|
+
Provider: (props: TamaguiProviderProps) => any;
|
|
128
|
+
themeParsed: {
|
|
129
|
+
[key: string]: Variable;
|
|
130
|
+
};
|
|
131
|
+
tokensParsed: CreateTokens<Variable>;
|
|
132
|
+
themeConfig: any;
|
|
133
|
+
getCSS: () => string;
|
|
134
|
+
};
|
|
135
|
+
export declare type GenericFont = {
|
|
136
|
+
size: {
|
|
137
|
+
[key: string | number]: number | Variable;
|
|
138
|
+
};
|
|
139
|
+
lineHeight: {
|
|
140
|
+
[key: string | number]: number | Variable;
|
|
141
|
+
};
|
|
142
|
+
letterSpacing: {
|
|
143
|
+
[key: string | number]: number | Variable;
|
|
144
|
+
};
|
|
145
|
+
weight: {
|
|
146
|
+
[key: string | number]: string | Variable;
|
|
147
|
+
};
|
|
148
|
+
family: string | Variable;
|
|
149
|
+
};
|
|
150
|
+
export declare type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, "children">> & {
|
|
151
|
+
initialWindowMetrics?: any;
|
|
152
|
+
fallback?: any;
|
|
153
|
+
children?: any;
|
|
154
|
+
};
|
|
155
|
+
export declare type Extractor = ReturnType<typeof createExtractor>;
|
|
156
|
+
export declare function createExtractor(): {
|
|
157
|
+
getTamaguiConfig(): TamaguiInternalConfig<import("@tamagui/core").CreateTokens<string | number | import("@tamagui/core").Variable>, {
|
|
158
|
+
[key: string]: {
|
|
159
|
+
bg: string | import("@tamagui/core").Variable;
|
|
160
|
+
bg2: string | import("@tamagui/core").Variable;
|
|
161
|
+
bg3: string | import("@tamagui/core").Variable;
|
|
162
|
+
bg4: string | import("@tamagui/core").Variable;
|
|
163
|
+
color: string | import("@tamagui/core").Variable;
|
|
164
|
+
color2: string | import("@tamagui/core").Variable;
|
|
165
|
+
color3: string | import("@tamagui/core").Variable;
|
|
166
|
+
color4: string | import("@tamagui/core").Variable;
|
|
167
|
+
borderColor: string | import("@tamagui/core").Variable;
|
|
168
|
+
borderColor2: string | import("@tamagui/core").Variable;
|
|
169
|
+
shadowColor: string | import("@tamagui/core").Variable;
|
|
170
|
+
shadowColor2: string | import("@tamagui/core").Variable;
|
|
171
|
+
};
|
|
172
|
+
}, {}, {
|
|
173
|
+
[x: string]: {
|
|
174
|
+
[key: string]: string | number;
|
|
175
|
+
};
|
|
176
|
+
}>;
|
|
177
|
+
parse: (fileOrPath: NodePath<t.Program> | t.File, { config, importsWhitelist, evaluateVars, shouldPrintDebug, sourcePath, onExtractTag, getFlattenedNode, onDidFlatten, ...props }: ExtractorParseProps) => null | undefined;
|
|
178
|
+
};
|
|
179
|
+
export declare function literalToAst(literal: any): t.Expression;
|
|
180
|
+
export declare const CSS_FILE_NAME = "__snack.css";
|
|
181
|
+
export declare const MEDIA_SEP = "_";
|
|
182
|
+
export declare const cacheDir: any;
|
|
183
|
+
export declare const CONCAT_CLASSNAME_IMPORT = "concatClassName";
|
|
184
|
+
export declare function extractToClassNames({ loader, extractor, source, sourcePath, options, shouldPrintDebug, threaded, cssPath, }: {
|
|
185
|
+
loader: any;
|
|
186
|
+
extractor: Extractor;
|
|
187
|
+
source: string | Buffer;
|
|
188
|
+
sourcePath: string;
|
|
189
|
+
options: TamaguiOptions;
|
|
190
|
+
shouldPrintDebug: boolean;
|
|
191
|
+
cssPath: string;
|
|
192
|
+
threaded?: boolean;
|
|
193
|
+
}): null | {
|
|
194
|
+
js: string | Buffer;
|
|
195
|
+
styles: string;
|
|
196
|
+
stylesPath?: string;
|
|
197
|
+
ast: t.File;
|
|
198
|
+
map: any;
|
|
199
|
+
};
|
|
200
|
+
export declare function isPresent<T extends Object>(input: null | void | undefined | T): input is T;
|
|
201
|
+
export declare function isSimpleSpread(node: t.JSXSpreadAttribute): boolean;
|
|
202
|
+
export declare const attrStr: (attr: ExtractedAttr) => string | t.JSXIdentifier;
|
|
203
|
+
export declare const objToStr: (obj: any) => any;
|
|
204
|
+
export declare const ternaryStr: (x: Ternary) => string;
|
|
205
|
+
export declare function findComponentName(scope: any): string | undefined;
|
|
206
|
+
export declare function isValidThemeHook(jsxPath: NodePath<t.JSXElement>, n: t.MemberExpression, sourcePath: string): boolean;
|
|
207
|
+
export declare const isInsideTamagui: (srcName: string) => boolean;
|
|
208
|
+
export declare function patchReactNativeWeb(): void;
|
|
209
|
+
|
|
210
|
+
export {};
|