react-native-css 3.0.0-preview.3 → 3.0.0-preview.4
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/commonjs/compiler/atRules.js +30 -16
- package/dist/commonjs/compiler/atRules.js.map +1 -1
- package/dist/commonjs/compiler/compiler.js +29 -19
- package/dist/commonjs/compiler/compiler.js.map +1 -1
- package/dist/commonjs/compiler/declarations.js +10 -10
- package/dist/commonjs/compiler/declarations.js.map +1 -1
- package/dist/commonjs/compiler/keyframes.js +1 -1
- package/dist/commonjs/compiler/keyframes.js.map +1 -1
- package/dist/commonjs/compiler/lightningcss-loader.js +40 -0
- package/dist/commonjs/compiler/lightningcss-loader.js.map +1 -0
- package/dist/commonjs/compiler/selector-builder.js +3 -2
- package/dist/commonjs/compiler/selector-builder.js.map +1 -1
- package/dist/commonjs/compiler/stylesheet.js +5 -7
- package/dist/commonjs/compiler/stylesheet.js.map +1 -1
- package/dist/commonjs/components/ActivityIndicator.js.map +1 -1
- package/dist/commonjs/components/Button.js.map +1 -1
- package/dist/commonjs/components/FlatList.js +4 -3
- package/dist/commonjs/components/FlatList.js.map +1 -1
- package/dist/commonjs/components/Image.js.map +1 -1
- package/dist/commonjs/components/ImageBackground.js +22 -0
- package/dist/commonjs/components/ImageBackground.js.map +1 -0
- package/dist/commonjs/components/KeyboardAvoidingView.js +19 -0
- package/dist/commonjs/components/KeyboardAvoidingView.js.map +1 -0
- package/dist/commonjs/components/Pressable.js +17 -0
- package/dist/commonjs/components/Pressable.js.map +1 -0
- package/dist/commonjs/components/ScrollView.js +18 -0
- package/dist/commonjs/components/ScrollView.js.map +1 -0
- package/dist/commonjs/components/TextInput.js +6 -1
- package/dist/commonjs/components/TextInput.js.map +1 -1
- package/dist/commonjs/components/TouchableHighlight.js +17 -0
- package/dist/commonjs/components/TouchableHighlight.js.map +1 -0
- package/dist/commonjs/components/TouchableOpacity.js +17 -0
- package/dist/commonjs/components/TouchableOpacity.js.map +1 -0
- package/dist/commonjs/components/TouchableWithoutFeedback.js +17 -0
- package/dist/commonjs/components/TouchableWithoutFeedback.js.map +1 -0
- package/dist/commonjs/components/VirtualizedList.js +20 -0
- package/dist/commonjs/components/VirtualizedList.js.map +1 -0
- package/dist/commonjs/components/index.cjs +265 -0
- package/dist/commonjs/components/index.cjs.map +1 -0
- package/dist/commonjs/components/index.js +65 -1
- package/dist/commonjs/components/index.js.map +1 -1
- package/dist/commonjs/index.js +0 -11
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/jest/index.js +1 -1
- package/dist/commonjs/jest/index.js.map +1 -1
- package/dist/commonjs/metro/index.js +7 -117
- package/dist/commonjs/metro/index.js.map +1 -1
- package/dist/commonjs/metro/metro-transformer.js +8 -1
- package/dist/commonjs/metro/metro-transformer.js.map +1 -1
- package/dist/commonjs/{native/metro.js → metro/override.js} +1 -1
- package/dist/commonjs/{native/metro.js.map → metro/override.js.map} +1 -1
- package/dist/commonjs/metro/resolver.js +11 -20
- package/dist/commonjs/metro/resolver.js.map +1 -1
- package/dist/commonjs/native/index.js +8 -8
- package/dist/commonjs/native/index.js.map +1 -1
- package/dist/commonjs/{poison.pill.js → native/react-native-css-metro-override.js} +1 -1
- package/dist/commonjs/native/react-native-css-metro-override.js.map +1 -0
- package/dist/commonjs/native/styles/calculate-props.js +1 -1
- package/dist/commonjs/native/styles/resolve.js +0 -1
- package/dist/commonjs/native/styles/resolve.js.map +1 -1
- package/dist/commonjs/native/styles/shorthands/animation.js +6 -2
- package/dist/commonjs/native/styles/shorthands/animation.js.map +1 -1
- package/dist/module/compiler/atRules.js +30 -16
- package/dist/module/compiler/atRules.js.map +1 -1
- package/dist/module/compiler/compiler.js +25 -15
- package/dist/module/compiler/compiler.js.map +1 -1
- package/dist/module/compiler/declarations.js +10 -10
- package/dist/module/compiler/declarations.js.map +1 -1
- package/dist/module/compiler/keyframes.js +1 -1
- package/dist/module/compiler/keyframes.js.map +1 -1
- package/dist/module/compiler/lightningcss-loader.js +36 -0
- package/dist/module/compiler/lightningcss-loader.js.map +1 -0
- package/dist/module/compiler/selector-builder.js +3 -2
- package/dist/module/compiler/selector-builder.js.map +1 -1
- package/dist/module/compiler/stylesheet.js +5 -7
- package/dist/module/compiler/stylesheet.js.map +1 -1
- package/dist/module/components/ActivityIndicator.js.map +1 -1
- package/dist/module/components/Button.js.map +1 -1
- package/dist/module/components/FlatList.js +4 -3
- package/dist/module/components/FlatList.js.map +1 -1
- package/dist/module/components/Image.js.map +1 -1
- package/dist/module/components/ImageBackground.js +17 -0
- package/dist/module/components/ImageBackground.js.map +1 -0
- package/dist/module/components/KeyboardAvoidingView.js +14 -0
- package/dist/module/components/KeyboardAvoidingView.js.map +1 -0
- package/dist/module/components/Pressable.js +12 -0
- package/dist/module/components/Pressable.js.map +1 -0
- package/dist/module/components/ScrollView.js +13 -0
- package/dist/module/components/ScrollView.js.map +1 -0
- package/dist/module/components/TextInput.js +6 -1
- package/dist/module/components/TextInput.js.map +1 -1
- package/dist/module/components/TouchableHighlight.js +12 -0
- package/dist/module/components/TouchableHighlight.js.map +1 -0
- package/dist/module/components/TouchableOpacity.js +12 -0
- package/dist/module/components/TouchableOpacity.js.map +1 -0
- package/dist/module/components/TouchableWithoutFeedback.js +12 -0
- package/dist/module/components/TouchableWithoutFeedback.js.map +1 -0
- package/dist/module/components/VirtualizedList.js +15 -0
- package/dist/module/components/VirtualizedList.js.map +1 -0
- package/dist/module/components/index.cjs +265 -0
- package/dist/module/components/index.cjs.map +1 -0
- package/dist/module/components/index.js +8 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/index.js +0 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/jest/index.js +1 -1
- package/dist/module/jest/index.js.map +1 -1
- package/dist/module/metro/index.js +7 -116
- package/dist/module/metro/index.js.map +1 -1
- package/dist/module/metro/metro-transformer.js +8 -1
- package/dist/module/metro/metro-transformer.js.map +1 -1
- package/dist/module/metro/override.js +4 -0
- package/dist/module/{native/metro.js.map → metro/override.js.map} +1 -1
- package/dist/module/metro/resolver.js +11 -20
- package/dist/module/metro/resolver.js.map +1 -1
- package/dist/module/native/index.js +1 -1
- package/dist/module/native/index.js.map +1 -1
- package/dist/module/{poison.pill.js → native/react-native-css-metro-override.js} +1 -1
- package/dist/module/native/react-native-css-metro-override.js.map +1 -0
- package/dist/module/native/styles/calculate-props.js +1 -1
- package/dist/module/native/styles/resolve.js +0 -1
- package/dist/module/native/styles/resolve.js.map +1 -1
- package/dist/module/native/styles/shorthands/animation.js +4 -1
- package/dist/module/native/styles/shorthands/animation.js.map +1 -1
- package/dist/typescript/commonjs/.config/eslint.config.d.mts +3 -0
- package/dist/typescript/commonjs/.config/eslint.config.d.mts.map +1 -0
- package/dist/typescript/commonjs/eslint.config.d.mts +2 -0
- package/dist/typescript/commonjs/eslint.config.d.mts.map +1 -0
- package/dist/typescript/commonjs/example/app.config.d.ts.map +1 -1
- package/dist/typescript/commonjs/example/index.d.ts +2 -0
- package/dist/typescript/commonjs/example/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/example/metro.config.d.ts +3 -0
- package/dist/typescript/commonjs/example/metro.config.d.ts.map +1 -0
- package/dist/typescript/commonjs/example/postcss.config.d.mts +7 -0
- package/dist/typescript/commonjs/example/postcss.config.d.mts.map +1 -0
- package/dist/typescript/commonjs/example/src/App.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts +1 -1
- package/dist/typescript/commonjs/src/compiler/keyframes.d.ts +1 -1
- package/dist/typescript/commonjs/src/compiler/keyframes.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/lightningcss-loader.d.ts +30 -0
- package/dist/typescript/commonjs/src/compiler/lightningcss-loader.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +2 -1
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts +3 -10
- package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/Button.d.ts +3 -10
- package/dist/typescript/commonjs/src/components/Button.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/FlatList.d.ts +3 -7
- package/dist/typescript/commonjs/src/components/FlatList.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/Image.d.ts +3 -5
- package/dist/typescript/commonjs/src/components/Image.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/ImageBackground.d.ts +6 -0
- package/dist/typescript/commonjs/src/components/ImageBackground.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/KeyboardAvoidingView.d.ts +6 -0
- package/dist/typescript/commonjs/src/components/KeyboardAvoidingView.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/Pressable.d.ts +6 -0
- package/dist/typescript/commonjs/src/components/Pressable.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/ScrollView.d.ts +6 -0
- package/dist/typescript/commonjs/src/components/ScrollView.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/TextInput.d.ts +3 -5
- package/dist/typescript/commonjs/src/components/TextInput.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/TouchableHighlight.d.ts +6 -0
- package/dist/typescript/commonjs/src/components/TouchableHighlight.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/TouchableOpacity.d.ts +6 -0
- package/dist/typescript/commonjs/src/components/TouchableOpacity.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/TouchableWithoutFeedback.d.ts +6 -0
- package/dist/typescript/commonjs/src/components/TouchableWithoutFeedback.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/VirtualizedList.d.ts +6 -0
- package/dist/typescript/commonjs/src/components/VirtualizedList.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/index.d.cts +2 -0
- package/dist/typescript/commonjs/src/components/index.d.cts.map +1 -0
- package/dist/typescript/commonjs/src/components/index.d.ts +8 -0
- package/dist/typescript/commonjs/src/components/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/index.d.ts +0 -1
- package/dist/typescript/commonjs/src/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/metro-transformer.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/override.d.ts +2 -0
- package/dist/typescript/commonjs/src/metro/override.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/metro/resolver.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/index.d.ts +1 -1
- package/dist/typescript/commonjs/src/native/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/react-native-css-metro-override.d.ts +2 -0
- package/dist/typescript/commonjs/src/native/react-native-css-metro-override.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/native/styles/resolve.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/shorthands/animation.d.ts +1 -0
- package/dist/typescript/commonjs/src/native/styles/shorthands/animation.d.ts.map +1 -1
- package/dist/typescript/module/.config/eslint.config.d.mts +3 -0
- package/dist/typescript/module/.config/eslint.config.d.mts.map +1 -0
- package/dist/typescript/module/eslint.config.d.mts +2 -0
- package/dist/typescript/module/eslint.config.d.mts.map +1 -0
- package/dist/typescript/module/example/app.config.d.ts.map +1 -1
- package/dist/typescript/module/example/index.d.ts +2 -0
- package/dist/typescript/module/example/index.d.ts.map +1 -0
- package/dist/typescript/module/example/metro.config.d.ts +3 -0
- package/dist/typescript/module/example/metro.config.d.ts.map +1 -0
- package/dist/typescript/module/example/postcss.config.d.mts +7 -0
- package/dist/typescript/module/example/postcss.config.d.mts.map +1 -0
- package/dist/typescript/module/example/src/App.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/declarations.d.ts +1 -1
- package/dist/typescript/module/src/compiler/keyframes.d.ts +1 -1
- package/dist/typescript/module/src/compiler/keyframes.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/lightningcss-loader.d.ts +30 -0
- package/dist/typescript/module/src/compiler/lightningcss-loader.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/selector-builder.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/stylesheet.d.ts +2 -1
- package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/module/src/components/ActivityIndicator.d.ts +3 -10
- package/dist/typescript/module/src/components/ActivityIndicator.d.ts.map +1 -1
- package/dist/typescript/module/src/components/Button.d.ts +3 -10
- package/dist/typescript/module/src/components/Button.d.ts.map +1 -1
- package/dist/typescript/module/src/components/FlatList.d.ts +3 -7
- package/dist/typescript/module/src/components/FlatList.d.ts.map +1 -1
- package/dist/typescript/module/src/components/Image.d.ts +3 -5
- package/dist/typescript/module/src/components/Image.d.ts.map +1 -1
- package/dist/typescript/module/src/components/ImageBackground.d.ts +6 -0
- package/dist/typescript/module/src/components/ImageBackground.d.ts.map +1 -0
- package/dist/typescript/module/src/components/KeyboardAvoidingView.d.ts +6 -0
- package/dist/typescript/module/src/components/KeyboardAvoidingView.d.ts.map +1 -0
- package/dist/typescript/module/src/components/Pressable.d.ts +6 -0
- package/dist/typescript/module/src/components/Pressable.d.ts.map +1 -0
- package/dist/typescript/module/src/components/ScrollView.d.ts +6 -0
- package/dist/typescript/module/src/components/ScrollView.d.ts.map +1 -0
- package/dist/typescript/module/src/components/TextInput.d.ts +3 -5
- package/dist/typescript/module/src/components/TextInput.d.ts.map +1 -1
- package/dist/typescript/module/src/components/TouchableHighlight.d.ts +6 -0
- package/dist/typescript/module/src/components/TouchableHighlight.d.ts.map +1 -0
- package/dist/typescript/module/src/components/TouchableOpacity.d.ts +6 -0
- package/dist/typescript/module/src/components/TouchableOpacity.d.ts.map +1 -0
- package/dist/typescript/module/src/components/TouchableWithoutFeedback.d.ts +6 -0
- package/dist/typescript/module/src/components/TouchableWithoutFeedback.d.ts.map +1 -0
- package/dist/typescript/module/src/components/VirtualizedList.d.ts +6 -0
- package/dist/typescript/module/src/components/VirtualizedList.d.ts.map +1 -0
- package/dist/typescript/module/src/components/index.d.cts +2 -0
- package/dist/typescript/module/src/components/index.d.cts.map +1 -0
- package/dist/typescript/module/src/components/index.d.ts +8 -0
- package/dist/typescript/module/src/components/index.d.ts.map +1 -1
- package/dist/typescript/module/src/index.d.ts +0 -1
- package/dist/typescript/module/src/index.d.ts.map +1 -1
- package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/index.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/metro-transformer.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/override.d.ts +2 -0
- package/dist/typescript/module/src/metro/override.d.ts.map +1 -0
- package/dist/typescript/module/src/metro/resolver.d.ts.map +1 -1
- package/dist/typescript/module/src/native/index.d.ts +1 -1
- package/dist/typescript/module/src/native/index.d.ts.map +1 -1
- package/dist/typescript/module/src/native/react-native-css-metro-override.d.ts +2 -0
- package/dist/typescript/module/src/native/react-native-css-metro-override.d.ts.map +1 -0
- package/dist/typescript/module/src/native/styles/resolve.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/animation.d.ts +1 -0
- package/dist/typescript/module/src/native/styles/shorthands/animation.d.ts.map +1 -1
- package/package.json +13 -16
- package/src/compiler/atRules.ts +30 -17
- package/src/compiler/compiler.ts +27 -16
- package/src/compiler/declarations.ts +10 -10
- package/src/compiler/keyframes.ts +2 -2
- package/src/compiler/lightningcss-loader.ts +40 -0
- package/src/compiler/selector-builder.ts +6 -2
- package/src/compiler/stylesheet.ts +5 -7
- package/src/components/ActivityIndicator.tsx +2 -2
- package/src/components/Button.tsx +2 -2
- package/src/components/FlatList.tsx +6 -5
- package/src/components/Image.tsx +2 -2
- package/src/components/ImageBackground.tsx +27 -0
- package/src/components/KeyboardAvoidingView.tsx +24 -0
- package/src/components/Pressable.tsx +17 -0
- package/src/components/ScrollView.tsx +20 -0
- package/src/components/TextInput.tsx +8 -3
- package/src/components/TouchableHighlight.tsx +22 -0
- package/src/components/TouchableOpacity.tsx +22 -0
- package/src/components/TouchableWithoutFeedback.tsx +22 -0
- package/src/components/VirtualizedList.tsx +25 -0
- package/src/components/index.cts +263 -0
- package/src/components/index.ts +17 -0
- package/src/index.ts +0 -2
- package/src/jest/index.ts +2 -1
- package/src/metro/index.ts +7 -165
- package/src/metro/metro-transformer.ts +15 -1
- package/src/metro/override.ts +1 -0
- package/src/metro/resolver.ts +20 -26
- package/src/native/index.ts +1 -2
- package/src/native/styles/calculate-props.ts +1 -1
- package/src/native/styles/resolve.ts +0 -1
- package/src/native/styles/shorthands/animation.ts +10 -2
- package/dist/commonjs/poison.pill.js.map +0 -1
- package/dist/commonjs/runtime/native/injection.js +0 -2
- package/dist/commonjs/runtime/native/injection.js.map +0 -1
- package/dist/module/native/metro.js +0 -5
- package/dist/module/poison.pill.js.map +0 -1
- package/dist/module/runtime/native/injection.js +0 -2
- package/dist/module/runtime/native/injection.js.map +0 -1
- package/dist/typescript/commonjs/src/native/metro.d.ts +0 -2
- package/dist/typescript/commonjs/src/native/metro.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/poison.pill.d.ts +0 -2
- package/dist/typescript/commonjs/src/poison.pill.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/runtime/native/injection.d.ts +0 -1
- package/dist/typescript/commonjs/src/runtime/native/injection.d.ts.map +0 -1
- package/dist/typescript/module/src/native/metro.d.ts +0 -2
- package/dist/typescript/module/src/native/metro.d.ts.map +0 -1
- package/dist/typescript/module/src/poison.pill.d.ts +0 -2
- package/dist/typescript/module/src/poison.pill.d.ts.map +0 -1
- package/dist/typescript/module/src/runtime/native/injection.d.ts +0 -1
- package/dist/typescript/module/src/runtime/native/injection.d.ts.map +0 -1
- package/src/components/index.tsx +0 -10
- package/src/native/metro.ts +0 -2
- package/src/runtime/native/injection.ts +0 -0
- /package/src/{poison.pill.ts → native/react-native-css-metro-override.ts} +0 -0
package/src/metro/index.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import { dirname, relative, sep } from "node:path";
|
|
3
2
|
import { versions } from "node:process";
|
|
4
3
|
|
|
5
|
-
import debug from "debug";
|
|
6
4
|
import type { MetroConfig } from "metro-config";
|
|
7
5
|
|
|
8
|
-
import {
|
|
9
|
-
compile,
|
|
10
|
-
type CompilerOptions,
|
|
11
|
-
type ReactNativeCssStyleSheet,
|
|
12
|
-
} from "../compiler";
|
|
13
|
-
import { getNativeInjectionCode, getWebInjectionCode } from "./injection-code";
|
|
6
|
+
import { type CompilerOptions } from "../compiler";
|
|
14
7
|
import { nativeResolver, webResolver } from "./resolver";
|
|
15
8
|
import { setupTypeScript } from "./typescript";
|
|
16
9
|
|
|
@@ -24,7 +17,10 @@ export interface WithReactNativeCSSOptions extends CompilerOptions {
|
|
|
24
17
|
hexColors?: boolean;
|
|
25
18
|
}
|
|
26
19
|
|
|
27
|
-
const
|
|
20
|
+
const metroOverrideResolution = {
|
|
21
|
+
type: "sourceFile",
|
|
22
|
+
filePath: require.resolve("./override"),
|
|
23
|
+
};
|
|
28
24
|
|
|
29
25
|
export function withReactNativeCSS<
|
|
30
26
|
T extends MetroConfig | (() => Promise<MetroConfig>),
|
|
@@ -43,11 +39,8 @@ export function withReactNativeCSS<
|
|
|
43
39
|
disableTypeScriptGeneration,
|
|
44
40
|
typescriptEnvPath,
|
|
45
41
|
globalClassNamePolyfill = false,
|
|
46
|
-
logger = defaultLogger,
|
|
47
42
|
} = options || {};
|
|
48
43
|
|
|
49
|
-
const loggerEnabled = "enabled" in logger ? logger.enabled : true;
|
|
50
|
-
|
|
51
44
|
if (disableTypeScriptGeneration !== true) {
|
|
52
45
|
setupTypeScript(typescriptEnvPath);
|
|
53
46
|
}
|
|
@@ -63,8 +56,8 @@ export function withReactNativeCSS<
|
|
|
63
56
|
...config.resolver,
|
|
64
57
|
sourceExts: [...(config?.resolver?.sourceExts || []), "css"],
|
|
65
58
|
resolveRequest: (context, moduleName, platform) => {
|
|
66
|
-
if (moduleName.includes("
|
|
67
|
-
return
|
|
59
|
+
if (moduleName.includes("react-native-css-metro-override")) {
|
|
60
|
+
return metroOverrideResolution;
|
|
68
61
|
}
|
|
69
62
|
|
|
70
63
|
const parentResolver =
|
|
@@ -86,156 +79,5 @@ export function withReactNativeCSS<
|
|
|
86
79
|
return resolved;
|
|
87
80
|
},
|
|
88
81
|
},
|
|
89
|
-
server: {
|
|
90
|
-
...config.server,
|
|
91
|
-
enhanceMiddleware(metroMiddleware, metroServer) {
|
|
92
|
-
const bundler: any = metroServer.getBundler().getBundler();
|
|
93
|
-
|
|
94
|
-
if (!bundler.__react_native_css__patched) {
|
|
95
|
-
bundler.__react_native_css__patched = true;
|
|
96
|
-
|
|
97
|
-
const nativeCSSFiles = new Map<
|
|
98
|
-
string,
|
|
99
|
-
[string, ReactNativeCssStyleSheet]
|
|
100
|
-
>();
|
|
101
|
-
const webCSSFiles = new Set<string>();
|
|
102
|
-
|
|
103
|
-
const nativeInjectionPath = require.resolve("../native/metro");
|
|
104
|
-
const nativeInjectionFilepaths = [
|
|
105
|
-
// CommonJS
|
|
106
|
-
nativeInjectionPath,
|
|
107
|
-
// ES Module
|
|
108
|
-
nativeInjectionPath.replace(
|
|
109
|
-
`dist${sep}commonjs`,
|
|
110
|
-
`dist${sep}module`,
|
|
111
|
-
),
|
|
112
|
-
// TypeScript
|
|
113
|
-
nativeInjectionPath
|
|
114
|
-
.replace(`dist${sep}commonjs`, `src`)
|
|
115
|
-
.replace(".js", ".ts"),
|
|
116
|
-
];
|
|
117
|
-
|
|
118
|
-
const webInjectionPath = require.resolve("../web/metro");
|
|
119
|
-
const webInjectionFilepaths = [
|
|
120
|
-
// CommonJS
|
|
121
|
-
webInjectionPath,
|
|
122
|
-
// ES Module
|
|
123
|
-
webInjectionPath.replace(`dist${sep}commonjs`, `dist${sep}module`),
|
|
124
|
-
// TypeScript
|
|
125
|
-
webInjectionPath
|
|
126
|
-
.replace(`dist${sep}commonjs`, `src`)
|
|
127
|
-
.replace(".js", ".ts"),
|
|
128
|
-
];
|
|
129
|
-
|
|
130
|
-
// Keep the original
|
|
131
|
-
const transformFile = bundler.transformFile.bind(bundler);
|
|
132
|
-
|
|
133
|
-
const watcher = bundler.getWatcher();
|
|
134
|
-
|
|
135
|
-
// Patch with our functionality
|
|
136
|
-
bundler.transformFile = async function (
|
|
137
|
-
filePath: string,
|
|
138
|
-
transformOptions: any,
|
|
139
|
-
fileBuffer?: Buffer,
|
|
140
|
-
) {
|
|
141
|
-
const isCss = /\.(s?css|sass)$/.test(filePath);
|
|
142
|
-
|
|
143
|
-
if (transformOptions.platform === "web") {
|
|
144
|
-
if (isCss) {
|
|
145
|
-
webCSSFiles.add(filePath);
|
|
146
|
-
} else if (webInjectionFilepaths.includes(filePath)) {
|
|
147
|
-
fileBuffer = getWebInjectionCode(Array.from(webCSSFiles));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return transformFile(filePath, transformOptions, fileBuffer);
|
|
151
|
-
} else {
|
|
152
|
-
// Handle CSS files on native platforms
|
|
153
|
-
if (isCss) {
|
|
154
|
-
const webTransform = await transformFile(
|
|
155
|
-
filePath,
|
|
156
|
-
{
|
|
157
|
-
...transformOptions,
|
|
158
|
-
// Force the platform to web for CSS files
|
|
159
|
-
platform: "web",
|
|
160
|
-
// Let the transformer know that we will handle compilation
|
|
161
|
-
customTransformOptions: {
|
|
162
|
-
...transformOptions.customTransformOptions,
|
|
163
|
-
reactNativeCSS: options,
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
fileBuffer,
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
const lastTransform = nativeCSSFiles.get(filePath);
|
|
170
|
-
const last = lastTransform?.[0];
|
|
171
|
-
const next = webTransform.output[0].data.css.code.toString();
|
|
172
|
-
|
|
173
|
-
// The CSS file has changed, we need to recompile the injection file
|
|
174
|
-
if (next !== last) {
|
|
175
|
-
nativeCSSFiles.set(filePath, [
|
|
176
|
-
next,
|
|
177
|
-
compile(next, {
|
|
178
|
-
hexColors: options?.hexColors,
|
|
179
|
-
}).stylesheet(),
|
|
180
|
-
]);
|
|
181
|
-
|
|
182
|
-
watcher.emit("change", {
|
|
183
|
-
eventsQueue: nativeInjectionFilepaths.map((filePath) => ({
|
|
184
|
-
filePath,
|
|
185
|
-
metadata: {
|
|
186
|
-
modifiedTime: Date.now(),
|
|
187
|
-
size: 1, // Can be anything
|
|
188
|
-
type: "virtual", // Can be anything
|
|
189
|
-
},
|
|
190
|
-
type: "change",
|
|
191
|
-
})),
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const nativeTransform = await transformFile(
|
|
196
|
-
filePath,
|
|
197
|
-
transformOptions,
|
|
198
|
-
fileBuffer,
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
// Tell Expo to skip caching this file
|
|
202
|
-
nativeTransform.output[0].data.css = {
|
|
203
|
-
skipCache: true,
|
|
204
|
-
// Expo requires a `code` property
|
|
205
|
-
code: "",
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
return nativeTransform;
|
|
209
|
-
} else if (nativeInjectionFilepaths.includes(filePath)) {
|
|
210
|
-
// If this is the injection file, we to swap its content with the
|
|
211
|
-
// compiled CSS files
|
|
212
|
-
fileBuffer = getNativeInjectionCode(
|
|
213
|
-
Array.from(nativeCSSFiles.keys()).map((key) =>
|
|
214
|
-
relative(dirname(filePath), key),
|
|
215
|
-
),
|
|
216
|
-
Array.from(nativeCSSFiles.values()).map(([, value]) => value),
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
if (loggerEnabled && fileBuffer) {
|
|
220
|
-
logger(`Transformed ${filePath}`);
|
|
221
|
-
logger(fileBuffer?.toString());
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return transformFile(filePath, transformOptions, fileBuffer);
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* We don't modify the middleware, we just use this function to get the metroServer
|
|
232
|
-
* So simply return the existing middleware
|
|
233
|
-
*/
|
|
234
|
-
return (
|
|
235
|
-
config.server?.enhanceMiddleware?.(metroMiddleware, metroServer) ??
|
|
236
|
-
metroMiddleware
|
|
237
|
-
);
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
82
|
};
|
|
241
83
|
}
|
|
@@ -44,5 +44,19 @@ export async function transform(
|
|
|
44
44
|
|
|
45
45
|
data = Buffer.from(getNativeInjectionCode([], [productionJS]));
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const transform = await worker.transform(
|
|
48
|
+
config,
|
|
49
|
+
projectRoot,
|
|
50
|
+
`${filePath}.js`,
|
|
51
|
+
data,
|
|
52
|
+
options,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
56
|
+
(transform as any).output[0].data.css = {
|
|
57
|
+
skipCache: true,
|
|
58
|
+
code: "",
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return transform;
|
|
48
62
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/metro/resolver.ts
CHANGED
|
@@ -24,45 +24,39 @@ export function nativeResolver(
|
|
|
24
24
|
platform: string | null,
|
|
25
25
|
): Resolution {
|
|
26
26
|
const resolution = resolver(context, moduleName, platform);
|
|
27
|
+
const isInternal = isFromThisModule(context.originModulePath);
|
|
28
|
+
const isReactNativeIndex = context.originModulePath.endsWith(
|
|
29
|
+
`react-native${sep}index.js`,
|
|
30
|
+
);
|
|
27
31
|
|
|
28
|
-
if (
|
|
29
|
-
// Don't include our internal files
|
|
30
|
-
isFromThisModule(context.originModulePath) ||
|
|
31
|
-
// Only operate on source files
|
|
32
|
-
resolution.type !== "sourceFile" ||
|
|
33
|
-
// Skip the React Native barrel file to prevent infinite recursion
|
|
34
|
-
context.originModulePath.endsWith("react-native/index.js") ||
|
|
35
|
-
// Skip anything that isn't importing a React Native component
|
|
36
|
-
!(
|
|
37
|
-
moduleName.startsWith("react-native") ||
|
|
38
|
-
moduleName.startsWith("react-native/")
|
|
39
|
-
)
|
|
40
|
-
) {
|
|
32
|
+
if (isInternal || resolution.type !== "sourceFile" || isReactNativeIndex) {
|
|
41
33
|
return resolution;
|
|
42
34
|
}
|
|
43
35
|
|
|
44
36
|
if (moduleName === "react-native") {
|
|
45
37
|
return resolver(context, `react-native-css/components`, platform);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (moduleName === "react-native-safe-area-context") {
|
|
38
|
+
} else if (moduleName === "react-native-safe-area-context") {
|
|
49
39
|
return resolver(
|
|
50
40
|
context,
|
|
51
41
|
`react-native-css/components/react-native-safe-area-context`,
|
|
52
42
|
platform,
|
|
53
43
|
);
|
|
44
|
+
} else if (
|
|
45
|
+
resolution.filePath.includes(`${sep}react-native${sep}Libraries${sep}`)
|
|
46
|
+
) {
|
|
47
|
+
const filename = basename(resolution.filePath.split(sep).at(-1) ?? "");
|
|
48
|
+
const module = filename.split(".").at(0);
|
|
49
|
+
|
|
50
|
+
if (module && allowedModules.has(module)) {
|
|
51
|
+
return resolver(
|
|
52
|
+
context,
|
|
53
|
+
`react-native-css/components/${module}`,
|
|
54
|
+
platform,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
const segments = resolution.filePath.split(sep);
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
59
|
-
const module = basename(segments.at(-1)!).split(".")[0];
|
|
60
|
-
|
|
61
|
-
if (!module || !allowedModules.has(module)) {
|
|
62
|
-
return resolution;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return resolver(context, `react-native-css/components/${module}`, platform);
|
|
59
|
+
return resolution;
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
export function webResolver(
|
package/src/native/index.ts
CHANGED
|
@@ -76,8 +76,6 @@ export const animation: StyleFunctionResolver = (
|
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
animationShortHandTuples.pop();
|
|
80
|
-
|
|
81
79
|
const nameTuple = animationShortHandTuples.find(
|
|
82
80
|
(tuple) => tuple[1] === "animationName",
|
|
83
81
|
);
|
|
@@ -121,3 +119,13 @@ export const animation: StyleFunctionResolver = (
|
|
|
121
119
|
|
|
122
120
|
return applyShorthand(animationShortHandTuples);
|
|
123
121
|
};
|
|
122
|
+
|
|
123
|
+
export const animationName: StyleFunctionResolver = (
|
|
124
|
+
resolveValue,
|
|
125
|
+
value,
|
|
126
|
+
get,
|
|
127
|
+
options,
|
|
128
|
+
) => {
|
|
129
|
+
const shorthand: any = animation(resolveValue, value, get, options);
|
|
130
|
+
return shorthand.animationName;
|
|
131
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["canWarn","process","env","NODE_ENV","Error"],"sourceRoot":"../../src","sources":["poison.pill.ts"],"mappings":";;;;;AAAA,MAAMA,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM;AAE/C,IAAIH,OAAO,EAAE;EACX,MAAM,IAAII,KAAK,CAAC;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACF","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["runtime/native/injection.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["canWarn","process","env","NODE_ENV","Error"],"sourceRoot":"../../src","sources":["poison.pill.ts"],"mappings":";;AAAA,MAAMA,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM;AAE/C,IAAIH,OAAO,EAAE;EACX,MAAM,IAAII,KAAK,CAAC;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACF;AAEA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["runtime/native/injection.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metro.d.ts","sourceRoot":"","sources":["../../../../../src/native/metro.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poison.pill.d.ts","sourceRoot":"","sources":["../../../../src/poison.pill.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=injection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injection.d.ts","sourceRoot":"","sources":["../../../../../../src/runtime/native/injection.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metro.d.ts","sourceRoot":"","sources":["../../../../../src/native/metro.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poison.pill.d.ts","sourceRoot":"","sources":["../../../../src/poison.pill.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=injection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injection.d.ts","sourceRoot":"","sources":["../../../../../../src/runtime/native/injection.ts"],"names":[],"mappings":""}
|
package/src/components/index.tsx
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "react-native";
|
|
2
|
-
|
|
3
|
-
export { ActivityIndicator } from "./ActivityIndicator";
|
|
4
|
-
export { Button } from "./Button";
|
|
5
|
-
export { FlatList } from "./FlatList";
|
|
6
|
-
export { Image } from "./Image";
|
|
7
|
-
export { Switch } from "./Switch";
|
|
8
|
-
export { Text } from "./Text";
|
|
9
|
-
export { TextInput } from "./TextInput";
|
|
10
|
-
export { View } from "./View";
|
package/src/native/metro.ts
DELETED
|
File without changes
|
|
File without changes
|