diff --git a/examples/expo-universal/.gitignore b/examples/expo-universal/.gitignore new file mode 100644 index 0000000..6623142 --- /dev/null +++ b/examples/expo-universal/.gitignore @@ -0,0 +1,20 @@ +node_modules/ +.expo/ +dist/ +npm-debug.* +*.jks +*.p8 +*.p12 +*.key +*.mobileprovision +*.orig.* +web-build/ + +# macOS +.DS_Store + +# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb +# The following patterns were generated by expo-cli + +expo-env.d.ts +# @end expo-cli \ No newline at end of file diff --git a/examples/expo-universal/README.md b/examples/expo-universal/README.md new file mode 100644 index 0000000..cd4feb8 --- /dev/null +++ b/examples/expo-universal/README.md @@ -0,0 +1,50 @@ +# Welcome to your Expo app 👋 + +This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app). + +## Get started + +1. Install dependencies + + ```bash + npm install + ``` + +2. Start the app + + ```bash + npx expo start + ``` + +In the output, you'll find options to open the app in a + +- [development build](https://docs.expo.dev/develop/development-builds/introduction/) +- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/) +- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/) +- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo + +You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction). + +## Get a fresh project + +When you're ready, run: + +```bash +npm run reset-project +``` + +This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing. + +## Learn more + +To learn more about developing your project with Expo, look at the following resources: + +- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides). +- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web. + +## Join the community + +Join our community of developers creating universal apps. + +- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute. +- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions. diff --git a/examples/expo-universal/app.json b/examples/expo-universal/app.json new file mode 100644 index 0000000..b5b0cf7 --- /dev/null +++ b/examples/expo-universal/app.json @@ -0,0 +1,21 @@ +{ + "expo": { + "name": "expo-universal", + "slug": "expo-universal", + "version": "1.0.0", + "orientation": "portrait", + "scheme": "myapp", + "userInterfaceStyle": "automatic", + "ios": { + "supportsTablet": true + }, + "web": { + "bundler": "metro", + "output": "static" + }, + "plugins": ["expo-router"], + "experiments": { + "typedRoutes": true + } + } +} diff --git a/examples/expo-universal/babel.config.js b/examples/expo-universal/babel.config.js new file mode 100644 index 0000000..9d89e13 --- /dev/null +++ b/examples/expo-universal/babel.config.js @@ -0,0 +1,6 @@ +module.exports = function (api) { + api.cache(true); + return { + presets: ['babel-preset-expo'], + }; +}; diff --git a/examples/expo-universal/bun.lockb b/examples/expo-universal/bun.lockb new file mode 100755 index 0000000..10fabde Binary files /dev/null and b/examples/expo-universal/bun.lockb differ diff --git a/examples/expo-universal/metro.config.js b/examples/expo-universal/metro.config.js new file mode 100644 index 0000000..c91c823 --- /dev/null +++ b/examples/expo-universal/metro.config.js @@ -0,0 +1,21 @@ +const path = require('node:path') + +// Learn more https://docs.expo.io/guides/customizing-metro +const { getDefaultConfig } = require('expo/metro-config') + +/** @type {import('expo/metro-config').MetroConfig} */ +const config = getDefaultConfig(__dirname) + +const ALIASES = { + '@stylexjs/stylex': path.join(__dirname, 'src/lib/stylex'), +} + +config.resolver.resolveRequest = (context, moduleName, platform) => { + return context.resolveRequest( + context, + ALIASES[moduleName] ?? moduleName, + platform + ) +} + +module.exports = config diff --git a/examples/expo-universal/package.json b/examples/expo-universal/package.json new file mode 100644 index 0000000..49d35ce --- /dev/null +++ b/examples/expo-universal/package.json @@ -0,0 +1,51 @@ +{ + "name": "expo-universal", + "main": "expo-router/entry", + "version": "1.0.0", + "scripts": { + "start": "expo start", + "reset-project": "node ./scripts/reset-project.js", + "android": "expo start --android", + "ios": "expo start --ios", + "web": "expo start --web", + "test": "jest --watchAll", + "lint": "expo lint" + }, + "jest": { + "preset": "jest-expo" + }, + "dependencies": { + "@expo/vector-icons": "^14.0.2", + "@nanocss/nanocss": "^0.0.3", + "@react-navigation/native": "^6.0.2", + "expo": "~51.0.28", + "expo-constants": "~16.0.2", + "expo-font": "~12.0.9", + "expo-linking": "~6.3.1", + "expo-router": "~3.5.23", + "expo-splash-screen": "~0.27.5", + "expo-status-bar": "~1.12.1", + "expo-system-ui": "~3.0.7", + "expo-web-browser": "~13.0.3", + "react": "18.2.0", + "react-dom": "18.2.0", + "react-native": "0.74.5", + "react-native-gesture-handler": "~2.16.1", + "react-native-reanimated": "~3.10.1", + "react-native-safe-area-context": "4.10.5", + "react-native-screens": "3.31.1", + "react-native-web": "~0.19.10", + "react-strict-dom": "^0.0.24" + }, + "devDependencies": { + "@babel/core": "^7.20.0", + "@types/jest": "^29.5.12", + "@types/react": "~18.2.45", + "@types/react-test-renderer": "^18.0.7", + "jest": "^29.2.1", + "jest-expo": "~51.0.3", + "react-test-renderer": "18.2.0", + "typescript": "~5.3.3" + }, + "private": true +} diff --git a/examples/expo-universal/src/app/+html.tsx b/examples/expo-universal/src/app/+html.tsx new file mode 100644 index 0000000..68afa1c --- /dev/null +++ b/examples/expo-universal/src/app/+html.tsx @@ -0,0 +1,38 @@ +import { ScrollViewStyleReset } from 'expo-router/html' +import { type PropsWithChildren } from 'react' +import { styleSheet } from '../lib/stylex' + +/** + * This file is web-only and used to configure the root HTML for every web page during static rendering. + * The contents of this function only run in Node.js environments and do not have access to the DOM or browser APIs. + */ +export default function Root({ children }: PropsWithChildren) { + return ( + +
+ + + + + + {children} + + ) +} + +const responsiveBackground = ` +body { + background-color: #fff; +} +@media (prefers-color-scheme: dark) { + body { + background-color: #000; + } +}` diff --git a/examples/expo-universal/src/app/_layout.tsx b/examples/expo-universal/src/app/_layout.tsx new file mode 100644 index 0000000..606a764 --- /dev/null +++ b/examples/expo-universal/src/app/_layout.tsx @@ -0,0 +1,2 @@ +import { Stack } from 'expo-router' +export default Stack diff --git a/examples/expo-universal/src/app/index.tsx b/examples/expo-universal/src/app/index.tsx new file mode 100644 index 0000000..4e74c51 --- /dev/null +++ b/examples/expo-universal/src/app/index.tsx @@ -0,0 +1,35 @@ +import { html, css } from 'react-strict-dom' +import { colors } from '../styles/colors.stylex' + +export default function Home() { + return ( +