@tamagui/static 1.0.1-beta.190 → 1.0.1-beta.191
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/constants.js +0 -3
- package/dist/constants.js.map +2 -2
- package/dist/extractor/buildClassName.js +20 -5
- package/dist/extractor/buildClassName.js.map +2 -2
- package/dist/extractor/createEvaluator.js +3 -3
- package/dist/extractor/createEvaluator.js.map +2 -2
- package/dist/extractor/createExtractor.js +63 -46
- package/dist/extractor/createExtractor.js.map +3 -3
- package/dist/extractor/ensureImportingConcat.js +4 -8
- package/dist/extractor/ensureImportingConcat.js.map +2 -2
- package/dist/extractor/extractHelpers.js +37 -9
- package/dist/extractor/extractHelpers.js.map +3 -3
- package/dist/extractor/extractMediaStyle.js +11 -11
- package/dist/extractor/extractMediaStyle.js.map +2 -2
- package/dist/extractor/extractToClassNames.js +5 -17
- package/dist/extractor/extractToClassNames.js.map +2 -2
- package/dist/extractor/getStaticBindingsForScope.js +3 -3
- package/dist/extractor/getStaticBindingsForScope.js.map +2 -2
- package/dist/extractor/loadTamagui.js +4 -4
- package/dist/extractor/loadTamagui.js.map +2 -2
- package/dist/types.js.map +1 -1
- package/package.json +16 -14
- package/src/constants.ts +0 -1
- package/src/extractor/buildClassName.ts +20 -4
- package/src/extractor/createEvaluator.ts +5 -5
- package/src/extractor/createExtractor.ts +42 -30
- package/src/extractor/ensureImportingConcat.ts +4 -11
- package/src/extractor/extractHelpers.ts +41 -7
- package/src/extractor/extractMediaStyle.ts +17 -10
- package/src/extractor/extractToClassNames.ts +6 -20
- package/src/extractor/getStaticBindingsForScope.ts +4 -4
- package/src/extractor/loadTamagui.ts +6 -6
- package/src/types.ts +5 -2
- package/types/constants.d.ts +0 -1
- package/types/extractor/buildClassName.d.ts +4 -1
- package/types/extractor/createEvaluator.d.ts +3 -3
- package/types/extractor/createExtractor.d.ts +1 -1
- package/types/extractor/extractHelpers.d.ts +5 -3
- package/types/extractor/extractMediaStyle.d.ts +3 -3
- package/types/types.d.ts +4 -2
|
@@ -7,9 +7,8 @@ import * as t from '@babel/types'
|
|
|
7
7
|
import { getStylesAtomic } from '@tamagui/core-node'
|
|
8
8
|
import { concatClassName } from '@tamagui/helpers'
|
|
9
9
|
import invariant from 'invariant'
|
|
10
|
-
import { ViewStyle } from 'react-native'
|
|
10
|
+
import type { ViewStyle } from 'react-native'
|
|
11
11
|
|
|
12
|
-
import { CONCAT_CLASSNAME_IMPORT } from '../constants.js'
|
|
13
12
|
import type { ClassNameObject, StyleObject, TamaguiOptions, Ternary } from '../types.js'
|
|
14
13
|
import { babelParse } from './babelParse.js'
|
|
15
14
|
import { buildClassName } from './buildClassName.js'
|
|
@@ -86,9 +85,9 @@ export async function extractToClassNames({
|
|
|
86
85
|
let hasFlattened = false
|
|
87
86
|
|
|
88
87
|
const res = await extractor.parse(ast, {
|
|
89
|
-
sourcePath,
|
|
90
88
|
shouldPrintDebug,
|
|
91
89
|
...options,
|
|
90
|
+
sourcePath,
|
|
92
91
|
target: 'html',
|
|
93
92
|
extractStyledDefinitions: true,
|
|
94
93
|
onStyleRule(identifier, rules) {
|
|
@@ -224,6 +223,7 @@ export async function extractToClassNames({
|
|
|
224
223
|
}
|
|
225
224
|
case 'ternary': {
|
|
226
225
|
const mediaExtraction = extractMediaStyle(
|
|
226
|
+
{ ...options, sourcePath },
|
|
227
227
|
attr.value,
|
|
228
228
|
jsxPath,
|
|
229
229
|
extractor.getTamagui()!,
|
|
@@ -323,16 +323,7 @@ export async function extractToClassNames({
|
|
|
323
323
|
})()
|
|
324
324
|
|
|
325
325
|
// inserts the _cn variable and uses it for className
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (names) {
|
|
329
|
-
if (t.isStringLiteral(names)) {
|
|
330
|
-
names.value = concatClassName(names.value)
|
|
331
|
-
names.value = `${extraClassNames} ${names.value}`
|
|
332
|
-
} else {
|
|
333
|
-
names = t.binaryExpression('+', t.stringLiteral(extraClassNames), names)
|
|
334
|
-
}
|
|
335
|
-
}
|
|
326
|
+
const names = buildClassName(finalClassNames, extraClassNames)
|
|
336
327
|
|
|
337
328
|
const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null
|
|
338
329
|
let expr = nameExpr
|
|
@@ -346,7 +337,7 @@ export async function extractToClassNames({
|
|
|
346
337
|
const simpleSpreads = attrs.filter(
|
|
347
338
|
(x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)
|
|
348
339
|
)
|
|
349
|
-
expr = t.callExpression(t.identifier(
|
|
340
|
+
expr = t.callExpression(t.identifier('concatClassName'), [
|
|
350
341
|
expr,
|
|
351
342
|
...simpleSpreads.map((val) => val.value['argument']),
|
|
352
343
|
])
|
|
@@ -369,13 +360,8 @@ export async function extractToClassNames({
|
|
|
369
360
|
cssMap.set(className, val)
|
|
370
361
|
}
|
|
371
362
|
} else if (rules.length) {
|
|
372
|
-
if (rules.length > 1) {
|
|
373
|
-
// eslint-disable-next-line no-console
|
|
374
|
-
console.log(' rules error', { rules })
|
|
375
|
-
throw new Error(`Shouldn't have more than one rule`)
|
|
376
|
-
}
|
|
377
363
|
cssMap.set(className, {
|
|
378
|
-
css: rules
|
|
364
|
+
css: rules.join('\n'),
|
|
379
365
|
commentTexts: [comment],
|
|
380
366
|
})
|
|
381
367
|
}
|
|
@@ -120,14 +120,14 @@ export async function getStaticBindingsForScope(
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
} catch (err: any) {
|
|
123
|
-
if (
|
|
124
|
-
// eslint-disable-next-line no-console
|
|
125
|
-
console.log(`Error in partial evaluation`, err.message, err.stack)
|
|
126
|
-
} else {
|
|
123
|
+
if (shouldPrintDebug) {
|
|
127
124
|
// eslint-disable-next-line no-console
|
|
128
125
|
console.warn(
|
|
129
126
|
` | Skipping partial evaluation of constant file: ${moduleName} (DEBUG=tamagui for more)`
|
|
130
127
|
)
|
|
128
|
+
} else if (process.env.DEBUG?.startsWith('tamagui')) {
|
|
129
|
+
// eslint-disable-next-line no-console
|
|
130
|
+
console.log(`Error in partial evaluation`, err.message, err.stack)
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -63,7 +63,7 @@ export async function loadTamagui(props: Props): Promise<TamaguiProjectInfo> {
|
|
|
63
63
|
const external = ['@tamagui/core', '@tamagui/core-node', 'react', 'react-dom']
|
|
64
64
|
const configEntry = props.config ? join(process.cwd(), props.config) : ''
|
|
65
65
|
|
|
66
|
-
if (process.env.DEBUG?.startsWith('tamagui')) {
|
|
66
|
+
if (process.env.NODE_ENV === 'development' && process.env.DEBUG?.startsWith('tamagui')) {
|
|
67
67
|
console.log(`Building config entry`, configEntry)
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -104,10 +104,6 @@ Tamagui built config and components:`
|
|
|
104
104
|
}),
|
|
105
105
|
])
|
|
106
106
|
|
|
107
|
-
if (process.env.DEBUG?.startsWith('tamagui')) {
|
|
108
|
-
console.log(`Built configs`)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
107
|
const coreNode = require('@tamagui/core-node')
|
|
112
108
|
|
|
113
109
|
registerRequire(props.bubbleErrors)
|
|
@@ -122,6 +118,10 @@ Tamagui built config and components:`
|
|
|
122
118
|
...(includesCore && gatherTamaguiComponentInfo([coreNode])),
|
|
123
119
|
}
|
|
124
120
|
|
|
121
|
+
if (process.env.NODE_ENV === 'development' && process.env.DEBUG?.startsWith('tamagui')) {
|
|
122
|
+
console.log('Loaded components', components)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
125
|
cache[key] = {
|
|
126
126
|
components,
|
|
127
127
|
nameToPaths: {},
|
|
@@ -269,7 +269,7 @@ export function loadTamaguiSync(props: Props): TamaguiProjectInfo {
|
|
|
269
269
|
|
|
270
270
|
// set up core-node
|
|
271
271
|
if (tamaguiConfig) {
|
|
272
|
-
createTamagui(tamaguiConfig)
|
|
272
|
+
createTamagui(tamaguiConfig as any)
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
cache[key] = {
|
package/src/types.ts
CHANGED
|
@@ -62,9 +62,12 @@ export type ExtractTagProps = {
|
|
|
62
62
|
staticConfig: StaticConfig
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export type
|
|
65
|
+
export type TamaguiOptionsWithFileInfo = TamaguiOptions & {
|
|
66
|
+
sourcePath: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type ExtractorParseProps = TamaguiOptionsWithFileInfo & {
|
|
66
70
|
target: 'native' | 'html'
|
|
67
|
-
sourcePath?: string
|
|
68
71
|
shouldPrintDebug?: boolean | 'verbose'
|
|
69
72
|
onExtractTag: (props: ExtractTagProps) => void
|
|
70
73
|
getFlattenedNode?: (props: { isTextView: boolean; tag: string }) => string
|
package/types/constants.d.ts
CHANGED
|
@@ -2,6 +2,5 @@ export declare const CSS_FILE_NAME = "__snack.css";
|
|
|
2
2
|
export declare const MEDIA_SEP = "_";
|
|
3
3
|
export declare const cacheDir: any;
|
|
4
4
|
export declare const FAILED_EVAL: unique symbol;
|
|
5
|
-
export declare const CONCAT_CLASSNAME_IMPORT = "concatClassName";
|
|
6
5
|
export declare const SHOULD_DEBUG: boolean | undefined;
|
|
7
6
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
2
|
import type { ClassNameObject } from '../types.js';
|
|
3
|
-
|
|
3
|
+
declare type Builder = (objects: ClassNameObject[], extras?: string) => t.Expression | t.StringLiteral | null;
|
|
4
|
+
export declare const buildClassName: Builder;
|
|
5
|
+
export declare const buildClassNameLogic: Builder;
|
|
6
|
+
export {};
|
|
4
7
|
//# sourceMappingURL=buildClassName.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NodePath } from '@babel/traverse';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
-
import
|
|
4
|
-
export declare function createEvaluator({
|
|
5
|
-
|
|
3
|
+
import { TamaguiOptionsWithFileInfo } from '../types.js';
|
|
4
|
+
export declare function createEvaluator({ props, staticNamespace, sourcePath, traversePath, shouldPrintDebug, }: {
|
|
5
|
+
props: TamaguiOptionsWithFileInfo;
|
|
6
6
|
staticNamespace: Record<string, any>;
|
|
7
7
|
sourcePath: string;
|
|
8
8
|
traversePath?: NodePath<t.JSXElement>;
|
|
@@ -16,7 +16,7 @@ export declare function createExtractor({ logger }?: ExtractorOptions): {
|
|
|
16
16
|
[key: string]: Partial<import("@tamagui/core-node").TamaguiBaseTheme> & {
|
|
17
17
|
[key: string]: import("@tamagui/core-node").VariableVal;
|
|
18
18
|
};
|
|
19
|
-
},
|
|
19
|
+
}, import("@tamagui/core-node").GenericShorthands, {
|
|
20
20
|
[key: string]: {
|
|
21
21
|
[key: string]: string | number;
|
|
22
22
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { NodePath } from '@babel/traverse';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
-
import type { ExtractedAttr, Ternary } from '../types.js';
|
|
3
|
+
import type { ExtractedAttr, TamaguiOptionsWithFileInfo, Ternary } from '../types.js';
|
|
4
4
|
export declare function isPresent<T extends Object>(input: null | void | undefined | T): input is T;
|
|
5
5
|
export declare function isSimpleSpread(node: t.JSXSpreadAttribute): boolean;
|
|
6
6
|
export declare const attrStr: (attr?: ExtractedAttr) => string | t.JSXIdentifier;
|
|
7
7
|
export declare const objToStr: (obj: any, spacer?: string) => any;
|
|
8
8
|
export declare const ternaryStr: (x: Ternary) => string;
|
|
9
9
|
export declare function findComponentName(scope: any): string | undefined;
|
|
10
|
-
export declare function isValidThemeHook(jsxPath: NodePath<t.JSXElement>, n: t.MemberExpression, sourcePath: string): boolean;
|
|
11
|
-
export declare const
|
|
10
|
+
export declare function isValidThemeHook(props: TamaguiOptionsWithFileInfo, jsxPath: NodePath<t.JSXElement>, n: t.MemberExpression, sourcePath: string): boolean;
|
|
11
|
+
export declare const isInsideComponentPackage: (props: TamaguiOptionsWithFileInfo, srcName: string) => boolean;
|
|
12
|
+
export declare const isComponentPackage: (props: TamaguiOptionsWithFileInfo, srcName: string) => boolean;
|
|
13
|
+
export declare const isValidImport: (props: TamaguiOptionsWithFileInfo, srcName: string) => boolean;
|
|
12
14
|
//# sourceMappingURL=extractHelpers.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NodePath } from '@babel/traverse';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
3
|
import { TamaguiInternalConfig } from '@tamagui/core-node';
|
|
4
|
-
import type { Ternary } from '../types.js';
|
|
5
|
-
export declare function extractMediaStyle(ternary: Ternary, jsxPath: NodePath<t.JSXElement>, tamaguiConfig: TamaguiInternalConfig, sourcePath: string, importance?: number, shouldPrintDebug?: boolean | 'verbose'): {
|
|
4
|
+
import type { TamaguiOptionsWithFileInfo, Ternary } from '../types.js';
|
|
5
|
+
export declare function extractMediaStyle(props: TamaguiOptionsWithFileInfo, ternary: Ternary, jsxPath: NodePath<t.JSXElement>, tamaguiConfig: TamaguiInternalConfig, sourcePath: string, importance?: number, shouldPrintDebug?: boolean | 'verbose'): {
|
|
6
6
|
mediaStyles: StyleObject[];
|
|
7
7
|
ternaryWithoutMedia: Ternary | null;
|
|
8
8
|
} | null;
|
|
9
|
-
export declare function isValidMediaCall(jsxPath: NodePath<t.JSXElement>, init: t.Expression, sourcePath: string): boolean;
|
|
9
|
+
export declare function isValidMediaCall(props: TamaguiOptionsWithFileInfo, jsxPath: NodePath<t.JSXElement>, init: t.Expression, sourcePath: string): boolean;
|
|
10
10
|
//# sourceMappingURL=extractMediaStyle.d.ts.map
|
package/types/types.d.ts
CHANGED
|
@@ -50,9 +50,11 @@ export declare type ExtractTagProps = {
|
|
|
50
50
|
completeProps: Record<string, any>;
|
|
51
51
|
staticConfig: StaticConfig;
|
|
52
52
|
};
|
|
53
|
-
export declare type
|
|
53
|
+
export declare type TamaguiOptionsWithFileInfo = TamaguiOptions & {
|
|
54
|
+
sourcePath: string;
|
|
55
|
+
};
|
|
56
|
+
export declare type ExtractorParseProps = TamaguiOptionsWithFileInfo & {
|
|
54
57
|
target: 'native' | 'html';
|
|
55
|
-
sourcePath?: string;
|
|
56
58
|
shouldPrintDebug?: boolean | 'verbose';
|
|
57
59
|
onExtractTag: (props: ExtractTagProps) => void;
|
|
58
60
|
getFlattenedNode?: (props: {
|