react-native-unistyles 3.0.0-nightly-20250213 → 3.0.0-nightly-20250215
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/cxx/hybridObjects/HybridShadowRegistry.cpp +1 -4
- package/cxx/parser/Parser.cpp +3 -3
- package/lib/typescript/src/types/stylesheet.d.ts +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/package.json +19 -9
- package/plugin/index.d.ts +51 -18
- package/plugin/index.js +785 -178
- package/src/types/stylesheet.ts +1 -1
- package/plugin/consts.js +0 -63
- package/plugin/exotic.js +0 -54
- package/plugin/import.js +0 -51
- package/plugin/ref.js +0 -11
- package/plugin/stylesheet.js +0 -565
- package/plugin/variants.js +0 -66
package/src/types/stylesheet.ts
CHANGED
@@ -62,7 +62,7 @@ export type UnistylesValues = FlatUnistylesValues & {
|
|
62
62
|
} & VariantsAndCompoundVariants & {
|
63
63
|
[propName in NestedKeys]?: UnistyleNestedStyles[propName]
|
64
64
|
} & {
|
65
|
-
_web?: CSSProperties & CustomClassName & {
|
65
|
+
_web?: ToDeepUnistyles<CSSProperties> & CustomClassName & {
|
66
66
|
[propName in Pseudo]?: ToDeepUnistyles<CSSProperties>
|
67
67
|
}
|
68
68
|
}
|
package/plugin/consts.js
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
const REACT_NATIVE_COMPONENT_NAMES = [
|
2
|
-
'ActivityIndicator',
|
3
|
-
'View',
|
4
|
-
'Text',
|
5
|
-
'Image',
|
6
|
-
'ImageBackground',
|
7
|
-
'KeyboardAvoidingView',
|
8
|
-
'Pressable',
|
9
|
-
'ScrollView',
|
10
|
-
'FlatList',
|
11
|
-
'SectionList',
|
12
|
-
'Switch',
|
13
|
-
'TextInput',
|
14
|
-
'RefreshControl',
|
15
|
-
'TouchableHighlight',
|
16
|
-
'TouchableOpacity',
|
17
|
-
'VirtualizedList',
|
18
|
-
'Animated'
|
19
|
-
// Modal - there is no exposed native handle
|
20
|
-
// TouchableWithoutFeedback - can't accept a ref
|
21
|
-
]
|
22
|
-
|
23
|
-
// auto replace RN imports to Unistyles imports under these paths
|
24
|
-
// our implementation simply borrows 'ref' to register it in ShadowRegistry
|
25
|
-
// so we won't affect anyone's implementation
|
26
|
-
const REPLACE_WITH_UNISTYLES_PATHS = [
|
27
|
-
'react-native-reanimated/src/component',
|
28
|
-
'react-native-gesture-handler/src/components'
|
29
|
-
]
|
30
|
-
|
31
|
-
// this is more powerful API as it allows to convert unmatched imports to Unistyles
|
32
|
-
// { path: string, imports: Array<{ name: string, isDefault: boolean, path: string, mapTo: string }> }
|
33
|
-
// path => node_modules path
|
34
|
-
// imports:
|
35
|
-
// name? <- target import name if isDefault is false
|
36
|
-
// isDefault <- is the import default?
|
37
|
-
// path <- path to the target import
|
38
|
-
// mapTo <- name of the Unistyles component
|
39
|
-
const REPLACE_WITH_UNISTYLES_EXOTIC_PATHS = []
|
40
|
-
|
41
|
-
// this list will additionally detect React Native direct imports
|
42
|
-
const NATIVE_COMPONENTS_PATHS = {
|
43
|
-
imports: [
|
44
|
-
{
|
45
|
-
name: 'NativeText',
|
46
|
-
isDefault: false,
|
47
|
-
path: 'react-native/Libraries/Text/TextNativeComponent',
|
48
|
-
mapTo: 'NativeText'
|
49
|
-
},
|
50
|
-
{
|
51
|
-
isDefault: true,
|
52
|
-
path: 'react-native/Libraries/Components/View/ViewNativeComponent',
|
53
|
-
mapTo: 'NativeView'
|
54
|
-
}
|
55
|
-
]
|
56
|
-
}
|
57
|
-
|
58
|
-
module.exports = {
|
59
|
-
NATIVE_COMPONENTS_PATHS,
|
60
|
-
REACT_NATIVE_COMPONENT_NAMES,
|
61
|
-
REPLACE_WITH_UNISTYLES_PATHS,
|
62
|
-
REPLACE_WITH_UNISTYLES_EXOTIC_PATHS
|
63
|
-
}
|
package/plugin/exotic.js
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
function handleExoticImport(t, path, state, exoticImport) {
|
2
|
-
const specifiers = path.node.specifiers
|
3
|
-
const source = path.node.source
|
4
|
-
|
5
|
-
if (path.node.importKind !== 'value') {
|
6
|
-
return
|
7
|
-
}
|
8
|
-
|
9
|
-
specifiers.forEach(specifier => {
|
10
|
-
for (const rule of exoticImport.imports) {
|
11
|
-
const hasMatchingImportType = (!rule.isDefault && t.isImportSpecifier(specifier)) || (rule.isDefault && t.isImportDefaultSpecifier(specifier))
|
12
|
-
const hasMatchingImportName = rule.isDefault || (!rule.isDefault && rule.name === specifier.local.name)
|
13
|
-
const hasMatchingPath = rule.path === source.value
|
14
|
-
|
15
|
-
if (!hasMatchingImportType || !hasMatchingImportName || !hasMatchingPath) {
|
16
|
-
continue
|
17
|
-
}
|
18
|
-
|
19
|
-
if (t.isImportDefaultSpecifier(specifier)) {
|
20
|
-
const newImport = t.importDeclaration(
|
21
|
-
[t.importDefaultSpecifier(t.identifier(specifier.local.name))],
|
22
|
-
t.stringLiteral(state.opts.isLocal
|
23
|
-
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
|
24
|
-
: `react-native-unistyles/components/native/${rule.mapTo}`
|
25
|
-
)
|
26
|
-
)
|
27
|
-
|
28
|
-
path.replaceWith(newImport)
|
29
|
-
} else {
|
30
|
-
const newImport = t.importDeclaration(
|
31
|
-
[t.importSpecifier(t.identifier(rule.mapTo), t.identifier(rule.mapTo))],
|
32
|
-
t.stringLiteral(state.opts.isLocal
|
33
|
-
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
|
34
|
-
: `react-native-unistyles/components/native/${rule.mapTo}`
|
35
|
-
)
|
36
|
-
)
|
37
|
-
|
38
|
-
path.node.specifiers = specifiers.filter(s => s !== specifier)
|
39
|
-
|
40
|
-
if (path.node.specifiers.length === 0) {
|
41
|
-
path.replaceWith(newImport)
|
42
|
-
} else {
|
43
|
-
path.insertBefore(newImport)
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
return
|
48
|
-
}
|
49
|
-
})
|
50
|
-
}
|
51
|
-
|
52
|
-
module.exports = {
|
53
|
-
handleExoticImport
|
54
|
-
}
|
package/plugin/import.js
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
/** @param {import('./index').UnistylesPluginPass} state */
|
2
|
-
function addUnistylesImport(t, path, state) {
|
3
|
-
const localNames = Object.keys(state.reactNativeImports)
|
4
|
-
const names = Object.values(state.reactNativeImports)
|
5
|
-
const pairs = Object.entries(state.reactNativeImports)
|
6
|
-
const nodesToRemove = []
|
7
|
-
|
8
|
-
// remove rn-imports
|
9
|
-
path.node.body.forEach(node => {
|
10
|
-
// user might have multiple imports like import type, import
|
11
|
-
if (t.isImportDeclaration(node) && node.source.value === 'react-native') {
|
12
|
-
node.specifiers = node.specifiers.filter(specifier => !localNames.some(name => name === specifier.local.name))
|
13
|
-
|
14
|
-
if (node.specifiers.length === 0) {
|
15
|
-
nodesToRemove.push(node)
|
16
|
-
}
|
17
|
-
}
|
18
|
-
})
|
19
|
-
|
20
|
-
// remove RNWeb imports
|
21
|
-
names.forEach(name => {
|
22
|
-
const rnWebImport = path.node.body.find(node => t.isImportDeclaration(node) && node.source.value === `react-native-web/dist/exports/${name}`)
|
23
|
-
|
24
|
-
if (rnWebImport) {
|
25
|
-
rnWebImport.specifiers = []
|
26
|
-
}
|
27
|
-
})
|
28
|
-
|
29
|
-
// import components from react-native-unistyles
|
30
|
-
pairs.forEach(([localName, name]) => {
|
31
|
-
const newImport = t.importDeclaration(
|
32
|
-
[t.importSpecifier(t.identifier(localName), t.identifier(name))],
|
33
|
-
t.stringLiteral(state.opts.isLocal
|
34
|
-
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/src/components/native/${name}`)
|
35
|
-
: `react-native-unistyles/components/native/${name}`
|
36
|
-
)
|
37
|
-
)
|
38
|
-
|
39
|
-
path.node.body.unshift(newImport)
|
40
|
-
})
|
41
|
-
|
42
|
-
// cleanup
|
43
|
-
nodesToRemove.forEach(node => path.node.body.splice(path.node.body.indexOf(node), 1))
|
44
|
-
}
|
45
|
-
|
46
|
-
const isInsideNodeModules = state => state.file.opts.filename.includes('node_modules')
|
47
|
-
|
48
|
-
module.exports = {
|
49
|
-
isInsideNodeModules,
|
50
|
-
addUnistylesImport
|
51
|
-
}
|
package/plugin/ref.js
DELETED