@tamagui/static 1.0.1-beta.56 → 1.0.1-beta.60
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/createExtractor.js +18 -1
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/patchReactNativeWeb.js +1 -1
- package/dist/cjs/patchReactNativeWeb.js.map +2 -2
- package/dist/esm/extractor/createExtractor.js +18 -1
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/patchReactNativeWeb.js +1 -1
- package/dist/esm/patchReactNativeWeb.js.map +2 -2
- package/dist/jsx/extractor/createExtractor.js +18 -1
- package/dist/jsx/patchReactNativeWeb.js +1 -1
- package/package.json +9 -7
- package/src/constants.ts +13 -0
- package/src/extractor/accessSafe.ts +18 -0
- package/src/extractor/babelParse.ts +27 -0
- package/src/extractor/buildClassName.ts +61 -0
- package/src/extractor/createEvaluator.ts +69 -0
- package/src/extractor/createExtractor.ts +1696 -0
- package/src/extractor/ensureImportingConcat.ts +39 -0
- package/src/extractor/evaluateAstNode.ts +121 -0
- package/src/extractor/extractHelpers.ts +119 -0
- package/src/extractor/extractMediaStyle.ts +190 -0
- package/src/extractor/extractToClassNames.ts +455 -0
- package/src/extractor/findTopmostFunction.ts +22 -0
- package/src/extractor/generatedUid.ts +43 -0
- package/src/extractor/getPrefixLogs.ts +6 -0
- package/src/extractor/getPropValueFromAttributes.ts +92 -0
- package/src/extractor/getSourceModule.ts +101 -0
- package/src/extractor/getStaticBindingsForScope.ts +183 -0
- package/src/extractor/hoistClassNames.ts +45 -0
- package/src/extractor/literalToAst.ts +84 -0
- package/src/extractor/loadTamagui.ts +139 -0
- package/src/extractor/logLines.ts +16 -0
- package/src/extractor/normalizeTernaries.ts +63 -0
- package/src/extractor/removeUnusedHooks.ts +76 -0
- package/src/extractor/timer.ts +18 -0
- package/src/extractor/validHTMLAttributes.ts +99 -0
- package/src/index.ts +9 -0
- package/src/patchReactNativeWeb.ts +165 -0
- package/src/types.ts +97 -0
- package/types/extractor/createExtractor.d.ts +14 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { NodePath } from '@babel/traverse'
|
|
2
|
+
import * as t from '@babel/types'
|
|
3
|
+
|
|
4
|
+
const hooks = {
|
|
5
|
+
useMedia: true,
|
|
6
|
+
useTheme: true,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function removeUnusedHooks(compFn: NodePath<any>, shouldPrintDebug: boolean | 'verbose') {
|
|
10
|
+
compFn.scope.crawl()
|
|
11
|
+
// check the top level statements
|
|
12
|
+
let bodyStatements = compFn?.get('body')
|
|
13
|
+
if (!bodyStatements) {
|
|
14
|
+
console.log('no body statemnts?', compFn)
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
if (!Array.isArray(bodyStatements)) {
|
|
18
|
+
if (bodyStatements.isFunctionExpression()) {
|
|
19
|
+
bodyStatements = bodyStatements.scope.path.get('body')
|
|
20
|
+
} else {
|
|
21
|
+
bodyStatements = bodyStatements.get('body')
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!bodyStatements || !Array.isArray(bodyStatements)) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
const statements = bodyStatements as NodePath<any>[]
|
|
28
|
+
for (const statement of statements) {
|
|
29
|
+
if (!statement.isVariableDeclaration()) {
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
const declarations = statement.get('declarations')
|
|
33
|
+
if (!Array.isArray(declarations)) {
|
|
34
|
+
continue
|
|
35
|
+
}
|
|
36
|
+
const isBindingReferenced = (name: string) => {
|
|
37
|
+
return !!statement.scope.getBinding(name)?.referenced
|
|
38
|
+
}
|
|
39
|
+
for (const declarator of declarations) {
|
|
40
|
+
const id = declarator.get('id')
|
|
41
|
+
const init = declarator.node.init
|
|
42
|
+
if (Array.isArray(id) || Array.isArray(init)) {
|
|
43
|
+
continue
|
|
44
|
+
}
|
|
45
|
+
const shouldRemove = (() => {
|
|
46
|
+
const isHook =
|
|
47
|
+
t.isCallExpression(init) && t.isIdentifier(init.callee) && hooks[init.callee.name]
|
|
48
|
+
if (!isHook) {
|
|
49
|
+
return false
|
|
50
|
+
}
|
|
51
|
+
if (t.isIdentifier(id.node)) {
|
|
52
|
+
// remove "const media = useMedia()"
|
|
53
|
+
const name = id.node.name
|
|
54
|
+
return !isBindingReferenced(name)
|
|
55
|
+
} else if (t.isObjectPattern(id.node)) {
|
|
56
|
+
// remove "const { sm } = useMedia()"
|
|
57
|
+
const propPaths = id.get('properties') as NodePath<any>[]
|
|
58
|
+
return propPaths.every((prop) => {
|
|
59
|
+
if (!prop.isObjectProperty()) return false
|
|
60
|
+
const value = prop.get('value')
|
|
61
|
+
if (Array.isArray(value) || !value.isIdentifier()) return false
|
|
62
|
+
const name = value.node.name
|
|
63
|
+
return !isBindingReferenced(name)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
return false
|
|
67
|
+
})()
|
|
68
|
+
if (shouldRemove) {
|
|
69
|
+
declarator.remove()
|
|
70
|
+
if (shouldPrintDebug) {
|
|
71
|
+
console.log(` [🪝] removed ${id.node['name'] ?? ''}`)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const timer = () => {
|
|
2
|
+
const start = Date.now()
|
|
3
|
+
let last = start
|
|
4
|
+
return {
|
|
5
|
+
mark: (name: string, print = false) => {
|
|
6
|
+
if (print) {
|
|
7
|
+
const took = Date.now() - last
|
|
8
|
+
last = Date.now()
|
|
9
|
+
console.log(`Time ${name}: ${took}ms`)
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
done: (print = false) => {
|
|
13
|
+
if (print) {
|
|
14
|
+
console.log(`Total time: ${Date.now() - start}ms`)
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export const validHTMLAttributes = {
|
|
2
|
+
autocomplete: true,
|
|
3
|
+
border: true,
|
|
4
|
+
contenteditable: true,
|
|
5
|
+
crossorigin: true,
|
|
6
|
+
dir: true,
|
|
7
|
+
draggable: true,
|
|
8
|
+
enctype: true,
|
|
9
|
+
formenctype: true,
|
|
10
|
+
formmethod: true,
|
|
11
|
+
formtarget: true,
|
|
12
|
+
inputmode: true,
|
|
13
|
+
kind: true,
|
|
14
|
+
link: true,
|
|
15
|
+
method: true,
|
|
16
|
+
preload: true,
|
|
17
|
+
referrerpolicy: true,
|
|
18
|
+
rel: true,
|
|
19
|
+
rev: true,
|
|
20
|
+
role: true,
|
|
21
|
+
sandbox: true,
|
|
22
|
+
shape: true,
|
|
23
|
+
spellcheck: true,
|
|
24
|
+
target: true,
|
|
25
|
+
translate: true,
|
|
26
|
+
type: true,
|
|
27
|
+
wrap: true,
|
|
28
|
+
'aria-autocomplete': true,
|
|
29
|
+
'aria-busy': true,
|
|
30
|
+
'aria-checked': true,
|
|
31
|
+
'aria-current': true,
|
|
32
|
+
'aria-disabled': true,
|
|
33
|
+
'aria-expanded': true,
|
|
34
|
+
'aria-haspopup': true,
|
|
35
|
+
'aria-hidden': true,
|
|
36
|
+
'aria-invalid': true,
|
|
37
|
+
'aria-polite': true,
|
|
38
|
+
'aria-modal': true,
|
|
39
|
+
'aria-multiline': true,
|
|
40
|
+
'aria-multiselectable': true,
|
|
41
|
+
'aria-orientation': true,
|
|
42
|
+
'aria-pressed': true,
|
|
43
|
+
'aria-readonly': true,
|
|
44
|
+
'aria-relevant': true,
|
|
45
|
+
'aria-required': true,
|
|
46
|
+
'aria-selected': true,
|
|
47
|
+
'aria-sort': true,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// for moving off react-native-web eventually (unused atm)
|
|
51
|
+
export const validAccessibilityAttributes = {
|
|
52
|
+
accessibilityRole: true,
|
|
53
|
+
accessibilityActiveDescendant: true,
|
|
54
|
+
accessibilityAtomic: true,
|
|
55
|
+
accessibilityAutoComplete: true,
|
|
56
|
+
accessibilityBusy: true,
|
|
57
|
+
accessibilityChecked: true,
|
|
58
|
+
accessibilityColumnCount: true,
|
|
59
|
+
accessibilityColumnIndex: true,
|
|
60
|
+
accessibilityColumnSpan: true,
|
|
61
|
+
accessibilityControls: true,
|
|
62
|
+
accessibilityCurrent: true,
|
|
63
|
+
accessibilityDescribedBy: true,
|
|
64
|
+
accessibilityDetails: true,
|
|
65
|
+
disabled: true,
|
|
66
|
+
accessibilityErrorMessage: true,
|
|
67
|
+
accessibilityExpanded: true,
|
|
68
|
+
accessibilityFlowTo: true,
|
|
69
|
+
accessibilityHasPopup: true,
|
|
70
|
+
accessibilityHidden: true,
|
|
71
|
+
accessibilityInvalid: true,
|
|
72
|
+
accessibilityKeyShortcuts: true,
|
|
73
|
+
accessibilityLabel: true,
|
|
74
|
+
accessibilityLabelledBy: true,
|
|
75
|
+
accessibilityLevel: true,
|
|
76
|
+
accessibilityLiveRegion: true,
|
|
77
|
+
accessibilityModal: true,
|
|
78
|
+
accessibilityMultiline: true,
|
|
79
|
+
accessibilityMultiSelectable: true,
|
|
80
|
+
accessibilityOrientation: true,
|
|
81
|
+
accessibilityOwns: true,
|
|
82
|
+
accessibilityPlaceholder: true,
|
|
83
|
+
accessibilityPosInSet: true,
|
|
84
|
+
accessibilityPressed: true,
|
|
85
|
+
accessibilityReadOnly: true,
|
|
86
|
+
accessibilityRequired: true,
|
|
87
|
+
accessibilityRoleDescription: true,
|
|
88
|
+
accessibilityRowCount: true,
|
|
89
|
+
accessibilityRowIndex: true,
|
|
90
|
+
accessibilityRowSpan: true,
|
|
91
|
+
accessibilitySelected: true,
|
|
92
|
+
accessibilitySetSize: true,
|
|
93
|
+
accessibilitySort: true,
|
|
94
|
+
accessibilityValueMax: true,
|
|
95
|
+
accessibilityValueMin: true,
|
|
96
|
+
accessibilityValueNow: true,
|
|
97
|
+
accessibilityValueText: true,
|
|
98
|
+
nativeID: true,
|
|
99
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
process.env.TAMAGUI_COMPILE_PROCESS = '1'
|
|
2
|
+
|
|
3
|
+
export { TamaguiOptions } from './types'
|
|
4
|
+
export { createExtractor } from './extractor/createExtractor'
|
|
5
|
+
export { literalToAst } from './extractor/literalToAst'
|
|
6
|
+
export * from './constants'
|
|
7
|
+
export * from './extractor/extractToClassNames'
|
|
8
|
+
export * from './extractor/extractHelpers'
|
|
9
|
+
export * from './patchReactNativeWeb'
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
|
|
3
|
+
import * as fs from 'fs-extra'
|
|
4
|
+
|
|
5
|
+
// were patching react-native-web so we can use some internal methods
|
|
6
|
+
// we do it this way because we need to rely on webpack or bundler config to determine cjs vs esm
|
|
7
|
+
// so we can't just require it all directly
|
|
8
|
+
// would be nice in the future to be able to eject from react-native-web entirely optionally
|
|
9
|
+
|
|
10
|
+
// keep it sync
|
|
11
|
+
export function patchReactNativeWeb(dir: string = require.resolve('react-native-web')) {
|
|
12
|
+
const rootDir = dir.replace(/[\/\\]dist.*/, '')
|
|
13
|
+
const modulePath = path.join(rootDir, 'dist', 'tamagui-exports.js')
|
|
14
|
+
const cjsPath = path.join(rootDir, 'dist', 'cjs', 'tamagui-exports.js')
|
|
15
|
+
const shouldPatchExports =
|
|
16
|
+
fs.existsSync(modulePath) &&
|
|
17
|
+
fs.readFileSync(modulePath, 'utf-8') === moduleExports &&
|
|
18
|
+
fs.existsSync(cjsPath) &&
|
|
19
|
+
fs.readFileSync(cjsPath, 'utf-8') === cjsExports
|
|
20
|
+
if (!shouldPatchExports) {
|
|
21
|
+
console.log(' | patch ' + path.relative(rootDir, modulePath))
|
|
22
|
+
console.log(' | patch ' + path.relative(rootDir, cjsPath))
|
|
23
|
+
fs.writeFileSync(modulePath, moduleExports)
|
|
24
|
+
fs.writeFileSync(cjsPath, cjsExports)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// patch to allow className prop
|
|
28
|
+
const patches = [
|
|
29
|
+
{
|
|
30
|
+
id: 'dom-props',
|
|
31
|
+
filePath: ['modules', 'createDOMProps', 'index.js'],
|
|
32
|
+
replacee: ` if (dataSet != null) {`,
|
|
33
|
+
replacer: `
|
|
34
|
+
if (props.dataSet && props.dataSet.className) {
|
|
35
|
+
const { className, ...dataSetRest } = props.dataSet
|
|
36
|
+
classList = className
|
|
37
|
+
dataSet = dataSetRest
|
|
38
|
+
}
|
|
39
|
+
if (props.dataSet && props.dataSet.id) {
|
|
40
|
+
domProps['id'] = props.dataSet.id
|
|
41
|
+
}
|
|
42
|
+
if (dataSet != null) {`,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'forward-props',
|
|
46
|
+
filePath: ['modules', 'forwardedProps', 'index.js'],
|
|
47
|
+
replacee: `dataSet: true,`,
|
|
48
|
+
replacer: `id: true, dataSet: true,`,
|
|
49
|
+
},
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
for (const { filePath, replacee, replacer } of patches) {
|
|
53
|
+
const files = [
|
|
54
|
+
path.join(rootDir, 'dist', ...filePath),
|
|
55
|
+
path.join(rootDir, 'dist', 'cjs', ...filePath),
|
|
56
|
+
]
|
|
57
|
+
for (const file of files) {
|
|
58
|
+
const contents = fs.readFileSync(file, 'utf-8')
|
|
59
|
+
if (contents.includes(replacer)) {
|
|
60
|
+
continue
|
|
61
|
+
}
|
|
62
|
+
if (!contents.includes(replacee)) {
|
|
63
|
+
console.warn(
|
|
64
|
+
`⚠️ Error: couldn't apply className patch! Maybe using incompatible react-native-web version.`,
|
|
65
|
+
{
|
|
66
|
+
replacee,
|
|
67
|
+
contents,
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
console.log(' | patch ' + path.relative(rootDir, file))
|
|
73
|
+
fs.writeFileSync(file, contents.replace(replacee, replacer))
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// if entry files not patched, patch them:
|
|
78
|
+
const moduleEntry = path.join(rootDir, 'dist', 'index.js')
|
|
79
|
+
const moduleEntrySrc = fs.readFileSync(moduleEntry, 'utf-8')
|
|
80
|
+
if (!moduleEntrySrc.includes('// tamagui-patch-v4')) {
|
|
81
|
+
fs.writeFileSync(
|
|
82
|
+
moduleEntry,
|
|
83
|
+
`${removePatch(moduleEntrySrc)}
|
|
84
|
+
|
|
85
|
+
// tamagui-patch-v4
|
|
86
|
+
import * as TExports from './tamagui-exports'
|
|
87
|
+
export const TamaguiExports = TExports
|
|
88
|
+
// tamagui-patch-end
|
|
89
|
+
`
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
const cjsEntry = path.join(rootDir, 'dist', 'cjs', 'index.js')
|
|
93
|
+
const cjsEntrySrc = fs.readFileSync(cjsEntry, 'utf-8')
|
|
94
|
+
if (!cjsEntrySrc.includes('// tamagui-patch-v4')) {
|
|
95
|
+
fs.writeFileSync(
|
|
96
|
+
cjsEntry,
|
|
97
|
+
`${removePatch(cjsEntrySrc)}
|
|
98
|
+
|
|
99
|
+
// tamagui-patch-v4
|
|
100
|
+
exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
|
|
101
|
+
// tamagui-patch-end
|
|
102
|
+
`
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function removePatch(source: string) {
|
|
108
|
+
return source.replace(/\/\/ tamagui-patch([.\s\S]*)/g, '')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// view exports/View.ts
|
|
112
|
+
const forwardedPropsObj = `{
|
|
113
|
+
...fwdProps.defaultProps,
|
|
114
|
+
...fwdProps.accessibilityProps,
|
|
115
|
+
...fwdProps.clickProps,
|
|
116
|
+
...fwdProps.focusProps,
|
|
117
|
+
...fwdProps.keyboardProps,
|
|
118
|
+
...fwdProps.mouseProps,
|
|
119
|
+
...fwdProps.touchProps,
|
|
120
|
+
...fwdProps.styleProps,
|
|
121
|
+
href: true,
|
|
122
|
+
lang: true,
|
|
123
|
+
onScroll: true,
|
|
124
|
+
onWheel: true,
|
|
125
|
+
pointerEvents: true
|
|
126
|
+
}
|
|
127
|
+
`
|
|
128
|
+
|
|
129
|
+
const moduleExports = `
|
|
130
|
+
export { atomic } from './exports/StyleSheet/compile'
|
|
131
|
+
export { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'
|
|
132
|
+
export { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'
|
|
133
|
+
export { default as i18Style } from './exports/StyleSheet/i18nStyle'
|
|
134
|
+
export { default as createDOMProps } from './modules/createDOMProps'
|
|
135
|
+
export { default as AccessibilityUtil } from './modules/AccessibilityUtil'
|
|
136
|
+
export { default as createElement } from './exports/createElement'
|
|
137
|
+
export { default as css } from './exports/StyleSheet/css'
|
|
138
|
+
export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
|
|
139
|
+
export { default as pick } from './modules/pick'
|
|
140
|
+
export { default as useElementLayout } from './modules/useElementLayout'
|
|
141
|
+
export { default as useMergeRefs } from './modules/useMergeRefs'
|
|
142
|
+
export { default as usePlatformMethods } from './modules/usePlatformMethods'
|
|
143
|
+
export { default as useResponderEvents } from './modules/useResponderEvents'
|
|
144
|
+
import * as fwdProps from './modules/forwardedProps'
|
|
145
|
+
export const forwardedProps = ${forwardedPropsObj}
|
|
146
|
+
`
|
|
147
|
+
|
|
148
|
+
const cjsExports = `
|
|
149
|
+
exports.atomic = require('./exports/StyleSheet/compile').atomic
|
|
150
|
+
exports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')
|
|
151
|
+
exports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')
|
|
152
|
+
exports.i18Style = require('./exports/StyleSheet/i18nStyle')
|
|
153
|
+
exports.createDOMProps = require('./modules/createDOMProps')
|
|
154
|
+
exports.AccessibilityUtil = require('./modules/AccessibilityUtil')
|
|
155
|
+
exports.createElement = require('./exports/createElement')
|
|
156
|
+
exports.css = require('./exports/StyleSheet/css')
|
|
157
|
+
exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
|
|
158
|
+
exports.pick = require('./modules/pick')
|
|
159
|
+
exports.useElementLayout = require('./modules/useElementLayout')
|
|
160
|
+
exports.useMergeRefs = require('./modules/useMergeRefs')
|
|
161
|
+
exports.usePlatformMethods = require('./modules/usePlatformMethods')
|
|
162
|
+
exports.useResponderEvents = require('./modules/useResponderEvents')
|
|
163
|
+
const fwdProps = require('./modules/forwardedProps')
|
|
164
|
+
exports.forwardedProps = ${forwardedPropsObj}
|
|
165
|
+
`
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { NodePath } from '@babel/traverse'
|
|
2
|
+
import * as t from '@babel/types'
|
|
3
|
+
import { PseudoStyles } from '@tamagui/core-node'
|
|
4
|
+
import { ViewStyle } from 'react-native'
|
|
5
|
+
|
|
6
|
+
export type ClassNameObject = t.StringLiteral | t.Expression
|
|
7
|
+
|
|
8
|
+
export interface CacheObject {
|
|
9
|
+
[key: string]: any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TamaguiOptions {
|
|
13
|
+
// module paths you want to compile with tamagui (for example ['tamagui'])
|
|
14
|
+
components: string[]
|
|
15
|
+
// your tamagui.config.ts
|
|
16
|
+
config?: string
|
|
17
|
+
evaluateVars?: boolean
|
|
18
|
+
importsWhitelist?: string[]
|
|
19
|
+
disable?: boolean
|
|
20
|
+
disableExtraction?: boolean
|
|
21
|
+
disableDebugAttr?: boolean
|
|
22
|
+
disableExtractInlineMedia?: boolean
|
|
23
|
+
disableExtractVariables?: boolean
|
|
24
|
+
excludeReactNativeWebExports?: string[]
|
|
25
|
+
exclude?: RegExp
|
|
26
|
+
logTimings?: boolean
|
|
27
|
+
prefixLogs?: string
|
|
28
|
+
|
|
29
|
+
// probably non user options
|
|
30
|
+
cssPath?: string
|
|
31
|
+
cssData?: any
|
|
32
|
+
deoptProps?: Set<string>
|
|
33
|
+
excludeProps?: Set<string>
|
|
34
|
+
inlineProps?: Set<string>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type ExtractedAttrAttr = {
|
|
38
|
+
type: 'attr'
|
|
39
|
+
value: t.JSXAttribute | t.JSXSpreadAttribute
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ExtractedAttrStyle = {
|
|
43
|
+
type: 'style'
|
|
44
|
+
value: ViewStyle & PseudoStyles
|
|
45
|
+
attr?: t.JSXAttribute | t.JSXSpreadAttribute
|
|
46
|
+
name?: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type ExtractedAttr =
|
|
50
|
+
| ExtractedAttrAttr
|
|
51
|
+
| { type: 'ternary'; value: Ternary }
|
|
52
|
+
| ExtractedAttrStyle
|
|
53
|
+
|
|
54
|
+
export type ExtractTagProps = {
|
|
55
|
+
attrs: ExtractedAttr[]
|
|
56
|
+
node: t.JSXOpeningElement
|
|
57
|
+
attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any
|
|
58
|
+
jsxPath: NodePath<t.JSXElement>
|
|
59
|
+
programPath: NodePath<t.Program>
|
|
60
|
+
originalNodeName: string
|
|
61
|
+
lineNumbers: string
|
|
62
|
+
filePath: string
|
|
63
|
+
isFlattened: boolean
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type ExtractorParseProps = TamaguiOptions & {
|
|
67
|
+
target: 'native' | 'html'
|
|
68
|
+
sourcePath?: string
|
|
69
|
+
shouldPrintDebug?: boolean | 'verbose'
|
|
70
|
+
onExtractTag: (props: ExtractTagProps) => void
|
|
71
|
+
getFlattenedNode: (props: { isTextView: boolean; tag: string }) => string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface Ternary {
|
|
75
|
+
test: t.Expression
|
|
76
|
+
// shorthand props that don't use hooks
|
|
77
|
+
inlineMediaQuery?: string
|
|
78
|
+
remove: Function
|
|
79
|
+
consequent: Object | null
|
|
80
|
+
alternate: Object | null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type StyleObject = {
|
|
84
|
+
property: string
|
|
85
|
+
value: string
|
|
86
|
+
className: string
|
|
87
|
+
identifier: string
|
|
88
|
+
rules: string[]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type ClassNameToStyleObj = {
|
|
92
|
+
[key: string]: StyleObject
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface PluginContext {
|
|
96
|
+
write: (path: string, rules: { [key: string]: string }) => any
|
|
97
|
+
}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { NodePath } from '@babel/traverse';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
+
import { TamaguiInternalConfig } from '@tamagui/core-node';
|
|
3
4
|
import { ExtractorParseProps } from '../types';
|
|
4
5
|
export declare type Extractor = ReturnType<typeof createExtractor>;
|
|
5
6
|
export declare function createExtractor(): {
|
|
6
|
-
getTamagui(): TamaguiInternalConfig
|
|
7
|
+
getTamagui(): TamaguiInternalConfig<import("@tamagui/core-node").CreateTokens<import("@tamagui/core-node").VariableVal>, {
|
|
8
|
+
[key: string]: Partial<import("@tamagui/core-node").TamaguiBaseTheme> & {
|
|
9
|
+
[key: string]: import("@tamagui/core-node").VariableVal;
|
|
10
|
+
};
|
|
11
|
+
}, {}, {
|
|
12
|
+
[x: string]: {
|
|
13
|
+
[key: string]: string | number;
|
|
14
|
+
};
|
|
15
|
+
}, {
|
|
16
|
+
[key: string]: string | {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
}, import("@tamagui/core-node").GenericFonts>;
|
|
7
20
|
parse: (fileOrPath: NodePath<t.Program> | t.File, { config, importsWhitelist, evaluateVars, shouldPrintDebug, sourcePath, onExtractTag, getFlattenedNode, disable, disableExtraction, disableExtractInlineMedia, disableExtractVariables, disableDebugAttr, prefixLogs, excludeProps, target, ...props }: ExtractorParseProps) => {
|
|
8
21
|
flattened: number;
|
|
9
22
|
optimized: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAGL,qBAAqB,EAQtB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EAIL,mBAAmB,EAEpB,MAAM,UAAU,CAAA;AAqCjB,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;wBAqBb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,0PAkBrC,mBAAmB;;;;;;EAqjD3B"}
|