Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changepacks/changepack_log_metro_reanimated.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"changes": {
"packages/metro-plugin/package.json": "Patch"
},
"note": "`withDevupUI()` tells the compiler whether the project has react-native-reanimated, which runs `keyframes()` and the `animation*` and `transition*` props on React Native; without it, they are build errors asking to install it.",
"date": "2026-11-21T00:00:00.000Z"
}
8 changes: 8 additions & 0 deletions .changepacks/changepack_log_react_native_animations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"changes": {
"bindings/devup-ui-binding/package.json": "Patch",
"bindings/devup-ui-wasm/package.json": "Patch"
},
"note": "`codeExtractNative` compiles `keyframes()` and the `animation*` and `transition*` props for React Native on react-native-reanimated (part of #411): `keyframes()` becomes the keyframes object Reanimated reads, and an element taking an animation or a transition renders Reanimated's animated component. It takes a new `reanimated` argument telling whether the app has react-native-reanimated; without it, these are build errors asking to install it. Web output is unchanged.",
"date": "2026-11-21T00:00:00.000Z"
}
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
- feat/react-native-pressed
- feat/react-native-css
- feat/react-native-styled
- feat/react-native-states

# Pull requests and every job below run read-only. Only the `release` and
# `deploy-pages` jobs get write permissions, and they run on pushes to main
Expand Down
8 changes: 7 additions & 1 deletion apps/expo/check-bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// runtime; src/Badge.tsx is styled the same in every theme and at every
// width, so it must not use the runtime. Its buttons take press styles, which
// React Native's `Pressable` applies through a function for `style`, and its
// input a focus style, which the runtime's `Focused` applies.
// input a focus style, which the runtime's `Focused` applies. Its card fades
// in and its logo fades, which react-native-reanimated runs.
import { readdirSync, readFileSync } from 'node:fs'
import { join } from 'node:path'

Expand Down Expand Up @@ -124,6 +125,8 @@ for (const platform of ['ios', 'android']) {
'backgroundColor:"#4330d9"',
'StyleSheet',
'style:({pressed:',
'animationName:',
'transitionProperty:"opacity"',
]) {
if (!code.replaceAll(' ', '').includes(style)) {
failures.push(`${platform}/${file}: lacks ${style}`)
Expand All @@ -138,6 +141,9 @@ for (const platform of ['ios', 'android']) {
failures.push(`${platform}/${file}: bundles ${source}`)
}
}
if (!sources.some((source) => /react-native-reanimated/.test(source))) {
failures.push(`${platform}/${file}: lacks react-native-reanimated`)
}
if (!sources.some((source) => NATIVE_RUNTIME.test(source))) {
failures.push(`${platform}/${file}: lacks @devup-ui/react/native`)
}
Expand Down
4 changes: 3 additions & 1 deletion apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"@devup-ui/react": "workspace:^",
"expo": "~58.0.26",
"react": "^19.3.1",
"react-native": "0.88.1"
"react-native": "0.88.1",
"react-native-reanimated": "~4.7.1",
"react-native-worklets": "0.13.0"
},
"devDependencies": {
"@devup-ui/metro-plugin": "workspace:^",
Expand Down
12 changes: 12 additions & 0 deletions apps/expo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Flex,
Image,
Input,
keyframes,
setTheme,
Text,
useTheme,
Expand All @@ -16,6 +17,12 @@ import { Badge } from './Badge'
/** The shape both buttons share */
const button = css({ borderRadius: '8px', px: 5, py: 3 })

/** The card fading in, which react-native-reanimated runs */
const fadeIn = keyframes({
from: { opacity: 0 },
to: { opacity: 1 },
})

export function App() {
const [name, setName] = useState('')
const [count, setCount] = useState(0)
Expand All @@ -34,14 +41,19 @@ export function App() {
<Image
borderRadius="16px"
h="64px"
opacity={name ? 1 : 0.6}
src="https://reactnative.dev/img/tiny_logo.png"
transitionDuration="300ms"
transitionProperty="opacity"
w="64px"
/>
<Text color="$text" typography="title">
Devup UI on React Native
</Text>
<Badge label={`${theme ?? 'light'} theme`} />
<Box
animationDuration="400ms"
animationName={fadeIn}
bg="$card"
borderRadius="$radius"
boxShadow="$raised"
Expand Down
3 changes: 2 additions & 1 deletion bindings/argument-validation.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = function createBoundary() {
const descriptors = {
codeExtract: extraction,
codeExtractWithoutSourceMap: extraction,
codeExtractNative: 'filename:s code:s _package:s platform:s runtime:b',
codeExtractNative:
'filename:s code:s _package:s platform:s runtime:b reanimated:b',
dropSession: 'id:u',
getCss: 'file_num:n import_main_css:b',
getThemeInterface:
Expand Down
4 changes: 2 additions & 2 deletions bindings/devup-ui-binding/adapter.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ exports.createBinding = function createBinding(raw) {
Output: raw.Output,
codeExtract,
codeExtractWithoutSourceMap,
codeExtractNative: (filename, code, pkg, platform, runtime) =>
raw.extractNative(filename, code, pkg, platform, runtime),
codeExtractNative: (filename, code, pkg, platform, runtime, reanimated) =>
raw.extractNative(filename, code, pkg, platform, runtime, reanimated),
createSession: () => raw.createSession(),
dropSession: (id) => raw.dropSession(id),
exportCanonicalMap: raw.exportCanonicalMap,
Expand Down
5 changes: 4 additions & 1 deletion bindings/devup-ui-binding/index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ export function codeExtractWithoutSourceMap(
* Compile a source for React Native on `platform`: Devup UI elements become
* React Native components whose styles are hoisted into one
* `StyleSheet.create`. No CSS is emitted (`css` and `cssFile` are undefined);
* `runtime: false` makes what needs the React Native runtime a build error.
* `runtime: false` makes what needs the React Native runtime a build error,
* and `reanimated: false`, telling the app lacks react-native-reanimated,
* makes animations and transitions one.
*/
export function codeExtractNative(
filename: string,
code: string,
packageName: string,
platform: 'ios' | 'android' | 'web',
runtime: boolean,
reanimated: boolean,
): Output
/** Create an engine session with a clean state; select it before each call. */
export function createSession(): number
Expand Down
12 changes: 9 additions & 3 deletions bindings/devup-ui-binding/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,14 @@ pub fn extract_native(
package: String,
platform: String,
runtime: bool,
reanimated: bool,
) -> Result<NativeOutput> {
core::code_extract_native((&filename, &code), &package, &platform, runtime)
.map(|output| NativeOutput(Some(output)))
.map_err(|error| binding_error(env, error))
core::code_extract_native(
(&filename, &code),
&package,
&platform,
(runtime, reanimated),
)
.map(|output| NativeOutput(Some(output)))
.map_err(|error| binding_error(env, error))
}
16 changes: 10 additions & 6 deletions bindings/devup-ui-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,9 @@ pub fn code_extract_native_internal(
code: &str,
package: &str,
platform: &str,
runtime: bool,
(runtime, reanimated): (bool, bool),
) -> Result<Output, String> {
binding_core::code_extract_native((filename, code), package, platform, runtime)
binding_core::code_extract_native((filename, code), package, platform, (runtime, reanimated))
.map(Output::from)
}

Expand All @@ -744,7 +744,8 @@ pub fn code_extract_native_internal(
/// Devup UI elements become React Native components whose styles are hoisted
/// into one `StyleSheet.create`; the output has the code and its source map
/// but no CSS. `runtime: false` makes what needs the React Native runtime a
/// build error.
/// build error, and `reanimated: false`, telling the app lacks
/// react-native-reanimated, makes animations and transitions one.
#[cfg(not(tarpaulin_include))]
#[wasm_bindgen(js_name = "codeExtractNative")]
pub fn code_extract_native(
Expand All @@ -753,8 +754,10 @@ pub fn code_extract_native(
package: &str,
platform: &str,
runtime: bool,
reanimated: bool,
) -> Result<Output, JsValue> {
code_extract_native_internal(filename, code, package, platform, runtime).map_err(js_error)
code_extract_native_internal(filename, code, package, platform, (runtime, reanimated))
.map_err(js_error)
}

/// Internal function to register theme (testable without `JsValue`)
Expand Down Expand Up @@ -1067,7 +1070,7 @@ mod tests {
"import { Text } from '@devup-ui/react'\n<Text color=\"red\">Hi</Text>\n",
"@devup-ui/react",
"ios",
true,
(true, true),
)
.unwrap();
assert!(
Expand All @@ -1083,7 +1086,8 @@ mod tests {
// The sheet is not touched
assert_eq!(get_css(None, false).unwrap(), "");
assert!(
code_extract_native_internal("view.tsx", "", "@devup-ui/react", "tv", true).is_err()
code_extract_native_internal("view.tsx", "", "@devup-ui/react", "tv", (true, true))
.is_err()
);
}

Expand Down
Loading
Loading