@tamagui/static 1.0.0-alpha.1 → 1.0.0-alpha.10

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.
@@ -9,10 +9,28 @@ import path from 'path'
9
9
  // keep it sync
10
10
  export function patchReactNativeWeb() {
11
11
  const rootDir = require.resolve('react-native-web').replace(/\/dist.*/, '')
12
+ const modulePath = path.join(rootDir, 'dist', 'tamagui-exports.js')
13
+ const cjsPath = path.join(rootDir, 'dist', 'cjs', 'tamagui-exports.js')
12
14
 
13
- // write our export files
14
- fs.writeFileSync(path.join(rootDir, 'dist', 'tamagui-exports.js'), moduleExports)
15
- fs.writeFileSync(path.join(rootDir, 'dist', 'cjs', 'tamagui-exports.js'), cjsExports)
15
+ const isEqual = (() => {
16
+ let res = false
17
+ try {
18
+ res =
19
+ fs.readFileSync(modulePath, 'utf-8') === moduleExports &&
20
+ fs.readFileSync(cjsPath, 'utf-8') == cjsExports
21
+ } catch {
22
+ res = false
23
+ }
24
+ return res
25
+ })()
26
+
27
+ if (!isEqual) {
28
+ console.log('🥚 Tamagui patching react-native-web to share atomic styling primitives')
29
+ console.log(' > adding', modulePath)
30
+ console.log(' > adding', cjsPath)
31
+ fs.writeFileSync(modulePath, moduleExports)
32
+ fs.writeFileSync(cjsPath, cjsExports)
33
+ }
16
34
 
17
35
  // if entry files not patched, patch them:
18
36
  const moduleEntry = path.join(rootDir, 'dist', 'index.js')
@@ -41,8 +59,6 @@ exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
41
59
  // tamagui-patch-end
42
60
  `
43
61
  )
44
-
45
- console.log(`Tamagui patched react-native-web`)
46
62
  }
47
63
  }
48
64
 
package/src/types.ts CHANGED
@@ -15,6 +15,8 @@ export interface TamaguiOptions {
15
15
  evaluateVars?: boolean
16
16
  importsWhitelist?: string[]
17
17
  disableExtraction?: boolean
18
+ disableDebugAttr?: boolean
19
+ disableExtractInlineMedia?: boolean
18
20
  exclude?: RegExp
19
21
  logTimings?: boolean
20
22
 
@@ -30,9 +32,17 @@ export type ExtractedAttrAttr = {
30
32
  value: t.JSXAttribute | t.JSXSpreadAttribute
31
33
  }
32
34
 
33
- export type ExtractedAttrStyle = { type: 'style'; value: Object }
35
+ export type ExtractedAttrStyle = {
36
+ type: 'style'
37
+ value: Object
38
+ attr?: t.JSXAttribute | t.JSXSpreadAttribute
39
+ name?: string
40
+ }
34
41
 
35
- export type ExtractedAttr = ExtractedAttrAttr | { type: 'ternary'; value: Ternary } | ExtractedAttrStyle
42
+ export type ExtractedAttr =
43
+ | ExtractedAttrAttr
44
+ | { type: 'ternary'; value: Ternary }
45
+ | ExtractedAttrStyle
36
46
 
37
47
  export type ExtractTagProps = {
38
48
  attrs: ExtractedAttr[]
@@ -51,7 +61,6 @@ export type ExtractorParseProps = TamaguiOptions & {
51
61
  shouldPrintDebug?: boolean
52
62
  onExtractTag: (props: ExtractTagProps) => void
53
63
  getFlattenedNode: (props: { isTextView: boolean; tag: string }) => string
54
- onDidFlatten?: () => void
55
64
  }
56
65
 
57
66
  export interface Ternary {
package/types.d.ts ADDED
@@ -0,0 +1,219 @@
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
+ disableDebugAttr?: boolean;
15
+ disableExtractInlineMedia?: boolean;
16
+ exclude?: RegExp;
17
+ logTimings?: boolean;
18
+ cssPath?: string;
19
+ cssData?: any;
20
+ deoptProps?: Set<string>;
21
+ excludeProps?: string[];
22
+ }
23
+ export declare type ExtractedAttrAttr = {
24
+ type: "attr";
25
+ value: t.JSXAttribute | t.JSXSpreadAttribute;
26
+ };
27
+ export declare type ExtractedAttrStyle = {
28
+ type: "style";
29
+ value: Object;
30
+ attr?: t.JSXAttribute | t.JSXSpreadAttribute;
31
+ name?: string;
32
+ };
33
+ export declare type ExtractedAttr = ExtractedAttrAttr | {
34
+ type: "ternary";
35
+ value: Ternary;
36
+ } | ExtractedAttrStyle;
37
+ export declare type ExtractTagProps = {
38
+ attrs: ExtractedAttr[];
39
+ node: t.JSXOpeningElement;
40
+ attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any;
41
+ jsxPath: NodePath<t.JSXElement>;
42
+ programPath: NodePath<t.Program>;
43
+ originalNodeName: string;
44
+ lineNumbers: string;
45
+ filePath: string;
46
+ isFlattened: boolean;
47
+ };
48
+ export declare type ExtractorParseProps = TamaguiOptions & {
49
+ sourcePath?: string;
50
+ shouldPrintDebug?: boolean;
51
+ onExtractTag: (props: ExtractTagProps) => void;
52
+ getFlattenedNode: (props: {
53
+ isTextView: boolean;
54
+ tag: string;
55
+ }) => string;
56
+ };
57
+ export interface Ternary {
58
+ test: t.Expression;
59
+ inlineMediaQuery?: string;
60
+ remove: Function;
61
+ consequent: Object | null;
62
+ alternate: Object | null;
63
+ }
64
+ declare class Variable {
65
+ name: string;
66
+ val: string | number;
67
+ variable: string | number;
68
+ constructor({ val, name }: VariableIn);
69
+ toString(): string | number;
70
+ }
71
+ export declare type VariableIn = {
72
+ val: string | number;
73
+ name: string;
74
+ };
75
+ export declare type ThemeProviderProps = {
76
+ themes: any;
77
+ defaultTheme: string;
78
+ disableRootThemeClass?: boolean;
79
+ children?: any;
80
+ };
81
+ export interface CreateTokens<Val extends number | string | Variable = number | string | Variable> {
82
+ font: {
83
+ [key: string]: GenericFont;
84
+ };
85
+ color: {
86
+ [key: string]: Val;
87
+ };
88
+ space: {
89
+ [key: string]: Val;
90
+ };
91
+ size: {
92
+ [key: string]: Val;
93
+ };
94
+ radius: {
95
+ [key: string]: Val;
96
+ };
97
+ zIndex: {
98
+ [key: string]: Val;
99
+ };
100
+ }
101
+ export declare type GenericTokens = CreateTokens;
102
+ export declare type GenericThemes = {
103
+ [key: string]: {
104
+ bg: string | Variable;
105
+ bg2: string | Variable;
106
+ bg3: string | Variable;
107
+ bg4: string | Variable;
108
+ color: string | Variable;
109
+ color2: string | Variable;
110
+ color3: string | Variable;
111
+ color4: string | Variable;
112
+ borderColor: string | Variable;
113
+ borderColor2: string | Variable;
114
+ shadowColor: string | Variable;
115
+ shadowColor2: string | Variable;
116
+ };
117
+ };
118
+ export declare type GenericShorthands = {};
119
+ export declare type GenericMedia<K extends string = string> = {
120
+ [key in K]: {
121
+ [key: string]: number | string;
122
+ };
123
+ };
124
+ export declare type CreateTamaguiConfig<A extends GenericTokens, B extends GenericThemes, C extends GenericShorthands, D extends GenericMedia> = Partial<Pick<ThemeProviderProps, "defaultTheme" | "disableRootThemeClass">> & {
125
+ tokens: A;
126
+ themes: B;
127
+ shorthands: C;
128
+ media: D;
129
+ };
130
+ 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> & {
131
+ Provider: (props: TamaguiProviderProps) => any;
132
+ themeParsed: {
133
+ [key: string]: Variable;
134
+ };
135
+ tokensParsed: CreateTokens<Variable>;
136
+ themeConfig: any;
137
+ getCSS: () => string;
138
+ parsed: boolean;
139
+ };
140
+ export declare type GenericFont = {
141
+ size: {
142
+ [key: string | number]: number | Variable;
143
+ };
144
+ lineHeight: {
145
+ [key: string | number]: number | Variable;
146
+ };
147
+ letterSpacing: {
148
+ [key: string | number]: number | Variable;
149
+ };
150
+ weight: {
151
+ [key: string | number]: string | Variable;
152
+ };
153
+ family: string | Variable;
154
+ };
155
+ export declare type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, "children">> & {
156
+ initialWindowMetrics?: any;
157
+ fallback?: any;
158
+ children?: any;
159
+ };
160
+ export declare type Extractor = ReturnType<typeof createExtractor>;
161
+ export declare function createExtractor(): {
162
+ getTamagui(): TamaguiInternalConfig<import("@tamagui/core").CreateTokens<string | number | import("@tamagui/core").Variable>, {
163
+ [key: string]: {
164
+ bg: string | import("@tamagui/core").Variable;
165
+ bg2: string | import("@tamagui/core").Variable;
166
+ bg3: string | import("@tamagui/core").Variable;
167
+ bg4: string | import("@tamagui/core").Variable;
168
+ color: string | import("@tamagui/core").Variable;
169
+ color2: string | import("@tamagui/core").Variable;
170
+ color3: string | import("@tamagui/core").Variable;
171
+ color4: string | import("@tamagui/core").Variable;
172
+ borderColor: string | import("@tamagui/core").Variable;
173
+ borderColor2: string | import("@tamagui/core").Variable;
174
+ shadowColor: string | import("@tamagui/core").Variable;
175
+ shadowColor2: string | import("@tamagui/core").Variable;
176
+ };
177
+ }, {}, {
178
+ [x: string]: {
179
+ [key: string]: string | number;
180
+ };
181
+ }>;
182
+ parse: (fileOrPath: NodePath<t.Program> | t.File, { config, importsWhitelist, evaluateVars, shouldPrintDebug, sourcePath, onExtractTag, getFlattenedNode, disableExtraction, disableExtractInlineMedia, disableDebugAttr, ...props }: ExtractorParseProps) => {
183
+ flattened: number;
184
+ optimized: number;
185
+ modified: number;
186
+ } | null;
187
+ };
188
+ export declare function literalToAst(literal: any): t.Expression;
189
+ export declare const CSS_FILE_NAME = "__snack.css";
190
+ export declare const MEDIA_SEP = "_";
191
+ export declare const cacheDir: any;
192
+ export declare const CONCAT_CLASSNAME_IMPORT = "concatClassName";
193
+ export declare function extractToClassNames({ loader, extractor, source, sourcePath, options, shouldPrintDebug, threaded, cssPath, }: {
194
+ loader: any;
195
+ extractor: Extractor;
196
+ source: string | Buffer;
197
+ sourcePath: string;
198
+ options: TamaguiOptions;
199
+ shouldPrintDebug: boolean;
200
+ cssPath: string;
201
+ threaded?: boolean;
202
+ }): null | {
203
+ js: string | Buffer;
204
+ styles: string;
205
+ stylesPath?: string;
206
+ ast: t.File;
207
+ map: any;
208
+ };
209
+ export declare function isPresent<T extends Object>(input: null | void | undefined | T): input is T;
210
+ export declare function isSimpleSpread(node: t.JSXSpreadAttribute): boolean;
211
+ export declare const attrStr: (attr: ExtractedAttr) => string | t.JSXIdentifier;
212
+ export declare const objToStr: (obj: any) => any;
213
+ export declare const ternaryStr: (x: Ternary) => string;
214
+ export declare function findComponentName(scope: any): string | undefined;
215
+ export declare function isValidThemeHook(jsxPath: NodePath<t.JSXElement>, n: t.MemberExpression, sourcePath: string): boolean;
216
+ export declare const isInsideTamagui: (srcName: string) => boolean;
217
+ export declare function patchReactNativeWeb(): void;
218
+
219
+ export {};