react-native-unistyles 3.0.0-beta.6 → 3.0.0-beta.8
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/README.md +19 -0
- package/android/CMakeLists.txt +2 -1
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +4 -0
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +29 -2
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +4 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +5 -0
- package/cxx/common/Helpers.h +85 -0
- package/cxx/core/HashGenerator.cpp +1 -1
- package/cxx/core/HostUnistyle.cpp +28 -4
- package/cxx/core/HostUnistyle.h +1 -0
- package/cxx/core/UnistyleWrapper.h +6 -6
- package/cxx/core/UnistylesCommitHook.cpp +20 -17
- package/cxx/core/UnistylesMountHook.cpp +2 -2
- package/cxx/core/UnistylesMountHook.h +1 -4
- package/cxx/core/UnistylesRegistry.cpp +8 -6
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +2 -5
- package/cxx/hybridObjects/HybridStyleSheet.cpp +1 -1
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +5 -1
- package/cxx/parser/Parser.cpp +79 -14
- package/cxx/shadowTree/ShadowTrafficController.h +10 -4
- package/cxx/shadowTree/ShadowTreeManager.cpp +38 -35
- package/lib/commonjs/components/native/Animated.js +2 -2
- package/lib/commonjs/components/native/Animated.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.js +29 -33
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/NativeText.native.js.map +1 -1
- package/lib/commonjs/components/native/NativeView.native.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.js +1 -1
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +17 -10
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +5 -5
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +5 -1
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +5 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +3 -3
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/core/warn.js +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +2 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +18 -9
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +1 -1
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js +1 -1
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/useServerUnistyles.js +2 -2
- package/lib/commonjs/server/useServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.native.js +3 -3
- package/lib/commonjs/specs/index.native.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +4 -4
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/boxShadow.js +4 -4
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js +3 -3
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/convert/object/transform.js +1 -1
- package/lib/commonjs/web/convert/object/transform.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/index.js +1 -1
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/registry.js +1 -1
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +1 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +1 -1
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/common.js +1 -1
- package/lib/commonjs/web/utils/unistyle.js +5 -5
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/native/Animated.js +2 -2
- package/lib/module/components/native/Animated.js.map +1 -1
- package/lib/module/components/native/ImageBackground.js +29 -33
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/NativeText.native.js.map +1 -1
- package/lib/module/components/native/NativeView.native.js.map +1 -1
- package/lib/module/components/native/Pressable.js +1 -1
- package/lib/module/components/native/Pressable.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js +17 -10
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +3 -3
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +5 -1
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +5 -1
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +3 -3
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/warn.js +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.js +2 -2
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +19 -10
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +1 -1
- package/lib/module/hooks/useMedia.native.js.map +1 -1
- package/lib/module/mq.js.map +1 -1
- package/lib/module/server/getServerUnistyles.js +1 -1
- package/lib/module/server/getServerUnistyles.js.map +1 -1
- package/lib/module/server/hydrateServerUnistyles.js +1 -1
- package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/module/server/resetServerUnistyles.js +1 -1
- package/lib/module/server/resetServerUnistyles.js.map +1 -1
- package/lib/module/server/useServerUnistyles.js +2 -2
- package/lib/module/server/useServerUnistyles.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +1 -1
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.native.js +4 -4
- package/lib/module/specs/index.native.js.map +1 -1
- package/lib/module/web/convert/index.js +5 -5
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/boxShadow.js +2 -2
- package/lib/module/web/convert/object/boxShadow.js.map +1 -1
- package/lib/module/web/convert/object/filter.js +3 -3
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/convert/object/transform.js +1 -1
- package/lib/module/web/convert/object/transform.js.map +1 -1
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/index.js +1 -1
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/registry.js +1 -1
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +1 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +1 -1
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/common.js +1 -1
- package/lib/module/web/utils/unistyle.js +5 -5
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +2 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/mq.d.ts +1 -1
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +5 -5
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.native.d.ts +4 -4
- package/lib/typescript/src/specs/index.native.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +2 -2
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +1 -1
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +5 -5
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/types.d.ts +1 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts +2 -2
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +1 -1
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +2 -2
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +2 -2
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +19 -19
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +1 -17
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/unistylesOnLoad.kt +35 -0
- package/nitrogen/generated/android/unistyles+autolinking.cmake +16 -0
- package/nitrogen/generated/ios/Unistyles+autolinking.rb +2 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +0 -1
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +3 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +2 -3
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +18 -18
- package/nitrogen/generated/shared/c++/ColorScheme.hpp +1 -1
- package/nitrogen/generated/shared/c++/Dimensions.hpp +2 -1
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/Insets.hpp +2 -1
- package/nitrogen/generated/shared/c++/Orientation.hpp +1 -1
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +1 -1
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +2 -1
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +2 -1
- package/package.json +31 -19
- package/plugin/index.d.ts +51 -18
- package/plugin/index.js +791 -189
- package/src/components/native/Animated.tsx +2 -2
- package/src/components/native/ImageBackground.tsx +6 -7
- package/src/components/native/NativeText.native.tsx +1 -1
- package/src/components/native/NativeView.native.tsx +1 -1
- package/src/components/native/Pressable.native.tsx +22 -12
- package/src/components/native/Pressable.tsx +1 -1
- package/src/core/createUnistylesElement.native.tsx +6 -1
- package/src/core/createUnistylesElement.tsx +3 -3
- package/src/core/createUnistylesImageBackground.tsx +6 -1
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +4 -4
- package/src/core/warn.ts +1 -1
- package/src/core/withUnistyles/withUnistyles.native.tsx +47 -19
- package/src/core/withUnistyles/withUnistyles.tsx +4 -4
- package/src/hooks/useMedia.native.ts +1 -1
- package/src/mq.ts +1 -1
- package/src/server/getServerUnistyles.tsx +1 -1
- package/src/server/hydrateServerUnistyles.ts +1 -1
- package/src/server/resetServerUnistyles.ts +1 -1
- package/src/server/useServerUnistyles.tsx +2 -2
- package/src/specs/ShadowRegistry/index.ts +1 -0
- package/src/specs/StatusBar/index.ts +1 -1
- package/src/specs/StyleSheet/index.ts +3 -3
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
- package/src/specs/UnistylesRuntime/index.ts +5 -5
- package/src/specs/index.native.ts +4 -4
- package/src/types/breakpoints.ts +2 -2
- package/src/types/core.ts +1 -1
- package/src/types/stylesheet.ts +5 -5
- package/src/web/convert/index.ts +5 -5
- package/src/web/convert/object/boxShadow.ts +2 -2
- package/src/web/convert/object/filter.ts +3 -3
- package/src/web/convert/object/transform.ts +2 -2
- package/src/web/convert/types.ts +1 -1
- package/src/web/convert/utils.ts +2 -2
- package/src/web/create.ts +1 -1
- package/src/web/index.ts +3 -3
- package/src/web/registry.ts +2 -2
- package/src/web/runtime.ts +2 -2
- package/src/web/shadowRegistry.ts +2 -2
- package/src/web/state.ts +4 -4
- package/src/web/utils/common.ts +1 -1
- package/src/web/utils/unistyle.ts +6 -6
- package/plugin/common.js +0 -142
- 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 -239
- package/plugin/variants.js +0 -66
package/src/web/convert/types.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { FilterFunction, TextStyle, ViewStyle } from 'react-native'
|
2
|
-
import type { ToDeepUnistyles } from '../../types/stylesheet'
|
3
2
|
import type { UnionToIntersection } from '../../types'
|
3
|
+
import type { ToDeepUnistyles } from '../../types/stylesheet'
|
4
4
|
|
5
5
|
export type ShadowOffset = ToDeepUnistyles<{ width: number, height: number }>
|
6
6
|
|
package/src/web/convert/utils.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
// based on react-native-web normalizer
|
2
2
|
// https://github.com/necolas/react-native-web
|
3
3
|
import normalizeColors from '@react-native/normalize-colors'
|
4
|
-
import { BOX_SHADOW_STYLES, TEXT_SHADOW_STYLES, type AllShadow, type AllShadowKeys, type Filters } from './types'
|
5
|
-
import type { TransformStyles } from '../../types/core'
|
6
4
|
import type { BoxShadowValue } from 'react-native'
|
5
|
+
import type { TransformStyles } from '../../types/core'
|
6
|
+
import { type AllShadow, type AllShadowKeys, BOX_SHADOW_STYLES, type Filters, TEXT_SHADOW_STYLES } from './types'
|
7
7
|
|
8
8
|
export const isTransform = (key: string, value: any): value is Array<TransformStyles> => key === 'transform' && Array.isArray(value)
|
9
9
|
|
package/src/web/create.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { StyleSheet, StyleSheetWithSuperPowers } from '../types/stylesheet'
|
2
2
|
import { UnistylesWeb } from './index'
|
3
3
|
import { assignSecrets, error, removeInlineStyles } from './utils'
|
4
4
|
|
package/src/web/index.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
import { deepMergeObjects } from '../utils'
|
1
|
+
import type { UnistylesShadowRegistry as NativeUnistylesShadowRegistry } from '../specs/ShadowRegistry'
|
3
2
|
import type { StyleSheet as NativeStyleSheet } from '../specs/StyleSheet'
|
4
3
|
import type { Runtime as NativeUnistylesRuntime } from '../specs/UnistylesRuntime'
|
5
|
-
import
|
4
|
+
import { deepMergeObjects } from '../utils'
|
5
|
+
import { create } from './create'
|
6
6
|
import { UnistylesServices } from './services'
|
7
7
|
import { isServer } from './utils'
|
8
8
|
|
package/src/web/registry.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
import type { UnistyleDependency, UnistylesMiniRuntime } from '../specs'
|
1
2
|
import type { UnistylesTheme, UnistylesValues } from '../types'
|
2
3
|
import type { StyleSheet, StyleSheetWithSuperPowers } from '../types/stylesheet'
|
3
|
-
import { generateHash, extractUnistyleDependencies, error } from './utils'
|
4
|
-
import type { UnistylesMiniRuntime, UnistyleDependency } from '../specs'
|
5
4
|
import { CSSState } from './css'
|
6
5
|
import type { UnistylesServices } from './types'
|
6
|
+
import { error, extractUnistyleDependencies, generateHash } from './utils'
|
7
7
|
|
8
8
|
export class UnistylesRegistry {
|
9
9
|
private readonly stylesheets = new Map<StyleSheetWithSuperPowers<StyleSheet>, StyleSheet>()
|
package/src/web/runtime.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import { UnistyleDependency } from '../specs/NativePlatform'
|
2
|
-
import { ColorScheme, Orientation, type AppTheme, type AppThemeName } from '../specs/types'
|
3
2
|
import type { UnistylesMiniRuntime } from '../specs/UnistylesRuntime'
|
3
|
+
import { type AppTheme, type AppThemeName, ColorScheme, Orientation } from '../specs/types'
|
4
4
|
import { WebContentSizeCategory } from '../types'
|
5
5
|
import { NavigationBar, StatusBar } from './mock'
|
6
|
-
import { error, isServer, schemeToTheme } from './utils'
|
7
6
|
import type { UnistylesServices } from './types'
|
7
|
+
import { error, isServer, schemeToTheme } from './utils'
|
8
8
|
|
9
9
|
export class UnistylesRuntime {
|
10
10
|
lightMedia = this.getLightMedia()
|
@@ -1,9 +1,9 @@
|
|
1
|
+
import { UnistyleDependency } from '../specs'
|
1
2
|
import type { UnistylesTheme, UnistylesValues } from '../types'
|
2
3
|
import { deepMergeObjects } from '../utils'
|
4
|
+
import type { UnistylesServices } from './types'
|
3
5
|
import { extractSecrets, extractUnistyleDependencies } from './utils'
|
4
6
|
import { getVariants } from './variants'
|
5
|
-
import type { UnistylesServices } from './types'
|
6
|
-
import { UnistyleDependency } from '../specs'
|
7
7
|
|
8
8
|
export class UnistylesShadowRegistry {
|
9
9
|
// MOCKS
|
package/src/web/state.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import type { UnistylesTheme } from '../types'
|
2
|
-
import type { UnistylesConfig } from '../specs/StyleSheet'
|
3
|
-
import type { AppBreakpoint, AppTheme, AppThemeName } from '../specs/types'
|
4
1
|
import type { UnistylesBreakpoints, UnistylesThemes } from '../global'
|
5
|
-
import { error, hyphenate, isServer, schemeToTheme } from './utils'
|
6
2
|
import { UnistyleDependency } from '../specs/NativePlatform'
|
3
|
+
import type { UnistylesConfig } from '../specs/StyleSheet'
|
4
|
+
import type { AppBreakpoint, AppTheme, AppThemeName } from '../specs/types'
|
5
|
+
import type { UnistylesTheme } from '../types'
|
7
6
|
import type { UnionToIntersection } from '../types'
|
8
7
|
import type { UnistylesServices } from './types'
|
8
|
+
import { error, hyphenate, isServer, schemeToTheme } from './utils'
|
9
9
|
|
10
10
|
type UnistylesSettings = Partial<UnionToIntersection<Required<UnistylesConfig>['settings']>>
|
11
11
|
|
package/src/web/utils/common.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
+
import type { UnistylesBreakpoints } from '../../global'
|
2
|
+
import { isUnistylesMq, parseMq } from '../../mq'
|
1
3
|
import type { UnistyleDependency } from '../../specs/NativePlatform'
|
2
4
|
import { ColorScheme, Orientation } from '../../specs/types'
|
3
5
|
import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet'
|
4
|
-
import { isUnistylesMq, parseMq } from '../../mq'
|
5
|
-
import { keyInObject, reduceObject } from './common'
|
6
|
-
import type { UnistylesBreakpoints } from '../../global'
|
7
6
|
import { UnistylesWeb } from '../index'
|
7
|
+
import { keyInObject, reduceObject } from './common'
|
8
8
|
|
9
9
|
export const schemeToTheme = (scheme: ColorScheme) => {
|
10
10
|
switch (scheme) {
|
@@ -27,9 +27,9 @@ export const assignSecrets = <T>(object: T, secrets: UnistyleSecrets) => {
|
|
27
27
|
const secretsId = Math.random().toString(36).slice(8)
|
28
28
|
|
29
29
|
// @ts-expect-error assign hidden secrets
|
30
|
-
object[`
|
30
|
+
object[`unistyles_${secretsId}`] = {}
|
31
31
|
// @ts-expect-error assign hidden secrets
|
32
|
-
Object.defineProperties(object[`
|
32
|
+
Object.defineProperties(object[`unistyles_${secretsId}`], reduceObject(secrets, secret => ({
|
33
33
|
value: secret,
|
34
34
|
enumerable: false,
|
35
35
|
configurable: true
|
@@ -43,7 +43,7 @@ export const extractSecrets = (object: any) => {
|
|
43
43
|
return undefined
|
44
44
|
}
|
45
45
|
|
46
|
-
const [, secrets] = Object.entries(object).find(([key]) => key.startsWith('
|
46
|
+
const [, secrets] = Object.entries(object).find(([key]) => key.startsWith('unistyles_')) ?? []
|
47
47
|
|
48
48
|
if (!secrets) {
|
49
49
|
return undefined
|
package/plugin/common.js
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
function getIdentifierNameFromExpression(t, memberExpression) {
|
2
|
-
if (t.isMemberExpression(memberExpression)) {
|
3
|
-
if (memberExpression.computed) {
|
4
|
-
return [
|
5
|
-
getIdentifierNameFromExpression(t, memberExpression.property),
|
6
|
-
getIdentifierNameFromExpression(t, memberExpression.object)
|
7
|
-
].flat()
|
8
|
-
}
|
9
|
-
|
10
|
-
const object = memberExpression.object
|
11
|
-
|
12
|
-
// If the object is an Identifier, return its name
|
13
|
-
if (t.isIdentifier(object)) {
|
14
|
-
return [object.name]
|
15
|
-
}
|
16
|
-
|
17
|
-
// If the object is another MemberExpression, recursively get the identifier
|
18
|
-
if (t.isMemberExpression(object)) {
|
19
|
-
return getIdentifierNameFromExpression(t, object).flat()
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
if (t.isBinaryExpression(memberExpression)) {
|
24
|
-
return [
|
25
|
-
getIdentifierNameFromExpression(t, memberExpression.left),
|
26
|
-
getIdentifierNameFromExpression(t, memberExpression.right)
|
27
|
-
].flat()
|
28
|
-
}
|
29
|
-
|
30
|
-
if (t.isCallExpression(memberExpression)) {
|
31
|
-
return getIdentifierNameFromExpression(t, memberExpression.callee)
|
32
|
-
}
|
33
|
-
|
34
|
-
if (t.isConditionalExpression(memberExpression)) {
|
35
|
-
return [
|
36
|
-
getIdentifierNameFromExpression(t, memberExpression.test.left),
|
37
|
-
getIdentifierNameFromExpression(t, memberExpression.test.right),
|
38
|
-
getIdentifierNameFromExpression(t, memberExpression.alternate),
|
39
|
-
getIdentifierNameFromExpression(t, memberExpression.consequent),
|
40
|
-
getIdentifierNameFromExpression(t, memberExpression.test)
|
41
|
-
].flat()
|
42
|
-
}
|
43
|
-
|
44
|
-
if (t.isArrayExpression(memberExpression)) {
|
45
|
-
return memberExpression.elements.map(expression => getIdentifierNameFromExpression(t, expression)).flat()
|
46
|
-
}
|
47
|
-
|
48
|
-
if (t.isArrowFunctionExpression(memberExpression)) {
|
49
|
-
return memberExpression.body.properties.map(prop => getIdentifierNameFromExpression(t, prop.value)).flat()
|
50
|
-
}
|
51
|
-
|
52
|
-
if (t.isTemplateLiteral(memberExpression)) {
|
53
|
-
return memberExpression.expressions.map(expression => getIdentifierNameFromExpression(t, expression)).flat()
|
54
|
-
}
|
55
|
-
|
56
|
-
if (t.isObjectExpression(memberExpression)) {
|
57
|
-
return memberExpression.properties
|
58
|
-
.filter(property => t.isObjectProperty(property))
|
59
|
-
.flatMap(property => getIdentifierNameFromExpression(t, property.value))
|
60
|
-
}
|
61
|
-
|
62
|
-
if (t.isUnaryExpression(memberExpression)) {
|
63
|
-
return getIdentifierNameFromExpression(t, memberExpression.argument.object)
|
64
|
-
}
|
65
|
-
|
66
|
-
return []
|
67
|
-
}
|
68
|
-
|
69
|
-
function getSecondPropertyName(t, memberExpression) {
|
70
|
-
if (t.isUnaryExpression(memberExpression)) {
|
71
|
-
return getSecondPropertyName(t, memberExpression.argument.object)
|
72
|
-
}
|
73
|
-
|
74
|
-
if (t.isConditionalExpression(memberExpression)) {
|
75
|
-
return [
|
76
|
-
getSecondPropertyName(t, memberExpression.test.left),
|
77
|
-
getSecondPropertyName(t, memberExpression.test.right),
|
78
|
-
getSecondPropertyName(t, memberExpression.alternate),
|
79
|
-
getSecondPropertyName(t, memberExpression.consequent),
|
80
|
-
getSecondPropertyName(t, memberExpression.test)
|
81
|
-
].flat()
|
82
|
-
}
|
83
|
-
|
84
|
-
if (t.isTemplateLiteral(memberExpression)) {
|
85
|
-
return memberExpression.expressions.map(expression => getSecondPropertyName(t, expression)).flat()
|
86
|
-
}
|
87
|
-
|
88
|
-
if (t.isBinaryExpression(memberExpression)) {
|
89
|
-
return [
|
90
|
-
getSecondPropertyName(t, memberExpression.left),
|
91
|
-
getSecondPropertyName(t, memberExpression.right)
|
92
|
-
].flat()
|
93
|
-
}
|
94
|
-
|
95
|
-
if (t.isObjectExpression(memberExpression)) {
|
96
|
-
return memberExpression.properties
|
97
|
-
.filter(property => t.isObjectProperty(property))
|
98
|
-
.flatMap(property => getSecondPropertyName(t, property.value))
|
99
|
-
}
|
100
|
-
|
101
|
-
if (t.isArrayExpression(memberExpression)) {
|
102
|
-
return memberExpression.elements.map(expression => getSecondPropertyName(t, expression)).flat()
|
103
|
-
}
|
104
|
-
|
105
|
-
if (!t.isMemberExpression(memberExpression)) {
|
106
|
-
return []
|
107
|
-
}
|
108
|
-
|
109
|
-
let current = memberExpression.computed
|
110
|
-
? memberExpression.property
|
111
|
-
: memberExpression
|
112
|
-
let propertyName = null
|
113
|
-
|
114
|
-
while (t.isMemberExpression(current)) {
|
115
|
-
propertyName = current.property
|
116
|
-
current = current.object
|
117
|
-
}
|
118
|
-
|
119
|
-
// special case for IME
|
120
|
-
if (propertyName && t.isIdentifier(propertyName) && propertyName.name === 'insets') {
|
121
|
-
if (t.isIdentifier(memberExpression.property) && memberExpression.property.name === "ime") {
|
122
|
-
return [memberExpression.property.name]
|
123
|
-
}
|
124
|
-
|
125
|
-
return [propertyName.name]
|
126
|
-
}
|
127
|
-
|
128
|
-
if (propertyName && t.isIdentifier(propertyName)) {
|
129
|
-
return [propertyName.name]
|
130
|
-
}
|
131
|
-
|
132
|
-
if (propertyName) {
|
133
|
-
return [propertyName.value]
|
134
|
-
}
|
135
|
-
|
136
|
-
return []
|
137
|
-
}
|
138
|
-
|
139
|
-
module.exports = {
|
140
|
-
getIdentifierNameFromExpression,
|
141
|
-
getSecondPropertyName
|
142
|
-
}
|
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/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