From d73e7486701eeaf65ebf16de4a41ad160a7bd0c6 Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Tue, 7 May 2024 15:15:26 +0200 Subject: [PATCH] refactor: upgrade to Expo SDK 51 (#577) * refactor(runtime): upgrade to Expo SDK `51.0.0-preview.4` * refactor(runtime): drop root `expo` prefix in `app.json` * refactor(runtime): update `react-native` patch * refactor(snack-content): add Expo SDK 51 * refactor(snack-sdk): add Expo SDK 51 * refactor(website): configure new Appetize apps * refactor(website): configure new Expo SDK * fix(snack-content): use the proper `expo` version for 51 * refactor(runtime): use `experiments.baseUrl` for web exports instead of workaround * refactor(runtime): use `appVersion` with major Expo SDK version instead of `sdkVersion` * feature(snack-content): add support for `appVersion` urls starting from SDK 51 * chore(website): enable SDK 51 in dropdown * refactor: revert `appVersion` changes to rely on `sdkVersion` for now * refactor(runtime): upgrade to Expo SDK `51.0.0` * refactor(snack-content): upgrade to Expo SDK `51.0.0` * refactor(snack-sdk): upgrade to Expo SDK `51.0.0` * test(snack-sdk): update snapshot test --- .github/workflows/runtime.yml | 24 +- .../snack-content/src/__tests__/urls-test.ts | 20 +- packages/snack-content/src/sdks/index.ts | 35 + packages/snack-content/src/sdks/types.ts | 2 +- packages/snack-content/src/urls.ts | 4 +- .../__fixtures__/bundledNativeModules.json | 105 + .../snack-sdk/src/__fixtures__/snackager.ts | 4 + .../__snapshots__/dependencies-test.ts.snap | 32 +- .../src/__tests__/dependencies-test.ts | 6 +- runtime/.gitignore | 1 + runtime/app.config.js | 42 + runtime/app.json | 64 +- runtime/metro.config.js | 20 - runtime/package.json | 52 +- ...0.73.6.patch => react-native+0.74.1.patch} | 0 runtime/web/deploy-script.js | 53 +- runtime/yarn.lock | 1976 ++++++++--------- website/src/client/configs/constants.tsx | 22 + website/src/client/configs/sdk.tsx | 3 +- 19 files changed, 1200 insertions(+), 1265 deletions(-) create mode 100644 runtime/app.config.js delete mode 100644 runtime/metro.config.js rename runtime/patches/{react-native+0.73.6.patch => react-native+0.74.1.patch} (100%) diff --git a/.github/workflows/runtime.yml b/.github/workflows/runtime.yml index 0b989093..6e0b651e 100644 --- a/.github/workflows/runtime.yml +++ b/.github/workflows/runtime.yml @@ -70,7 +70,9 @@ jobs: name: runtime-staging url: https://staging.expo.dev/@exponent/snack env: - EXPO_PUBLIC_SNACK_ENV: staging + EXPO_PROJECT_ID: 2dce2748-c51f-4865-bae0-392af794d60a # Configure the EAS Update project + EXPO_PUBLIC_SNACK_ENV: staging # Configure Snack to use staging endpoints + EXPO_STAGING: 'true' # Configure Expo tooling to use staging endpoints steps: - name: 🏗 Setup repository uses: actions/checkout@v3 @@ -85,15 +87,6 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.SNACK_RUNTIME_AWS_STAGING_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.SNACK_RUNTIME_AWS_STAGING_SECRET }} - - name: 👷 Configure EAS Update for staging - if: ${{ contains('all native', github.event.inputs.platform) }} - run: | - eas init --id 2dce2748-c51f-4865-bae0-392af794d60a --force - eas update:configure - env: - EXPO_TOKEN: ${{ secrets.SNACK_RUNTIME_EXPO_STAGING }} - EXPO_STAGING: 'true' - - name: 📱 Deploy native runtime if: ${{ contains('all native', github.event.inputs.platform) }} run: yarn deploy:staging @@ -121,7 +114,8 @@ jobs: name: runtime-production url: https://expo.dev/@exponent/snack env: - EXPO_PUBLIC_SNACK_ENV: production + EXPO_PROJECT_ID: 933fd9c0-1666-11e7-afca-d980795c5824 # Configure the EAS Update project + EXPO_PUBLIC_SNACK_ENV: production # Configure Snack to use production endpoints steps: - name: 🏗 Setup repository uses: actions/checkout@v3 @@ -136,14 +130,6 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.SNACK_RUNTIME_AWS_PRODUCTION_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.SNACK_RUNTIME_AWS_PRODUCTION_SECRET }} - - name: 👷 Configure EAS Update for production - if: ${{ contains('all native', github.event.inputs.platform) }} - run: | - eas init --id 933fd9c0-1666-11e7-afca-d980795c5824 --force - eas update:configure - env: - EXPO_TOKEN: ${{ secrets.SNACK_RUNTIME_EXPO_PRODUCTION }} - - name: 📱 Deploy native runtime if: ${{ contains('all native', github.event.inputs.platform) }} run: yarn deploy:prod diff --git a/packages/snack-content/src/__tests__/urls-test.ts b/packages/snack-content/src/__tests__/urls-test.ts index e2323018..e41ff024 100644 --- a/packages/snack-content/src/__tests__/urls-test.ts +++ b/packages/snack-content/src/__tests__/urls-test.ts @@ -5,34 +5,34 @@ const channel = 'AsZ12sasd11G'; describe(createRuntimeUrl, () => { it('returns url with only "sdkVersion"', () => { - expect(createRuntimeUrl({ sdkVersion: '69.0.0' })).toMatchInlineSnapshot( - `"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A69.0.0&channel-name=production"`, + expect(createRuntimeUrl({ sdkVersion: '50.0.0' })).toMatchInlineSnapshot( + `"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A50.0.0&channel-name=production"`, ); }); it(`returns url with "sdkVersion" and "snack"`, () => { - expect(createRuntimeUrl({ sdkVersion: '69.0.0', snack })).toMatchInlineSnapshot( - `"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A69.0.0&channel-name=production&snack=xxxxxx"`, + expect(createRuntimeUrl({ sdkVersion: '49.0.0', snack })).toMatchInlineSnapshot( + `"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A49.0.0&channel-name=production&snack=xxxxxx"`, ); }); it(`returns url with "sdkVersion" and "channel"`, () => { - expect(createRuntimeUrl({ sdkVersion: '69.0.0', channel })).toMatchInlineSnapshot( - `"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A69.0.0&channel-name=production&snack-channel=AsZ12sasd11G"`, + expect(createRuntimeUrl({ sdkVersion: '48.0.0', channel })).toMatchInlineSnapshot( + `"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A48.0.0&channel-name=production&snack-channel=AsZ12sasd11G"`, ); }); it(`returns url with "sdkVersion", "snack", and "channel"`, () => { - expect(createRuntimeUrl({ sdkVersion: '69.0.0', snack, channel })).toMatchInlineSnapshot( - `"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A69.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`, + expect(createRuntimeUrl({ sdkVersion: '50.0.0', snack, channel })).toMatchInlineSnapshot( + `"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A50.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`, ); }); it(`returns url with "sdkVersion", "snack", and "channel" using custom "endpoint"`, () => { expect( - createRuntimeUrl({ sdkVersion: '69.0.0', snack, channel, endpoint: 'u-dev.expo.test/xxx' }), + createRuntimeUrl({ sdkVersion: '49.0.0', snack, channel, endpoint: 'u-dev.expo.test/xxx' }), ).toMatchInlineSnapshot( - `"exp://u-dev.expo.test/xxx?runtime-version=exposdk%3A69.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`, + `"exp://u-dev.expo.test/xxx?runtime-version=exposdk%3A49.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`, ); }); }); diff --git a/packages/snack-content/src/sdks/index.ts b/packages/snack-content/src/sdks/index.ts index f8d6245a..921f7b90 100644 --- a/packages/snack-content/src/sdks/index.ts +++ b/packages/snack-content/src/sdks/index.ts @@ -113,6 +113,41 @@ const sdks: { [version: string]: SDKSpec } = { }, deprecatedModules: {}, }, + '51.0.0': { + version: '^51.0.0', + coreModules: { + ...assets, + expo: '~51.0.0', + react: '18.2.0', + 'react-dom': '*', + 'react-native': '0.74.1', + 'react-native-web': '*', + // Used by @shopify/react-native-skia, on web only + // See runtime/src/NativeModules/ReactNativeSkia.tsx for more info + '@shopify/react-native-skia/lib/module/web': '*', + }, + bundledModules: { + 'expo-asset': '*', + 'expo-font': '*', + 'react-native-gesture-handler': '*', + 'react-native-safe-area-context': '*', + '@expo/vector-icons': '*', + 'expo-constants': '*', + 'expo-file-system': '*', + 'expo-updates': '*', + '@react-native-async-storage/async-storage': '*', + 'react-native-reanimated': '*', + 'expo-router': '*', + 'expo-router/stack': '*', + 'expo-router/tabs': '*', + 'expo-router/drawer': '*', + 'expo-router/html': '*', + 'expo-router/head': '*', + 'expo-router/entry': '*', + 'react-native-pager-view': '*', + }, + deprecatedModules: {}, + }, }; export default sdks; diff --git a/packages/snack-content/src/sdks/types.ts b/packages/snack-content/src/sdks/types.ts index af2d8eeb..a5bc0923 100644 --- a/packages/snack-content/src/sdks/types.ts +++ b/packages/snack-content/src/sdks/types.ts @@ -1,7 +1,7 @@ /** * Version of the Expo SDK to use (e.g. "48.0.0"). */ -export type SDKVersion = '48.0.0' | '49.0.0' | '50.0.0'; +export type SDKVersion = '48.0.0' | '49.0.0' | '50.0.0' | '51.0.0'; /** @internal */ export type SDKSpec = { diff --git a/packages/snack-content/src/urls.ts b/packages/snack-content/src/urls.ts index 2f957f9f..06b5bdb2 100644 --- a/packages/snack-content/src/urls.ts +++ b/packages/snack-content/src/urls.ts @@ -38,7 +38,7 @@ export function createRuntimeUrl(options: RuntimeUrlInfo & RuntimeUrlOptions): s parameters.set('runtime-version', `exposdk:${options.sdkVersion}`); parameters.set('channel-name', 'production'); - // Add the Snack reference + // Add the Snack references if (options.snack) parameters.set('snack', options.snack); if (options.channel) parameters.set('snack-channel', options.channel); @@ -59,7 +59,7 @@ export function parseRuntimeUrl(uri: string | URL): RuntimeUrlInfo | null { const snack = url.searchParams.get('snack') ?? undefined; const channel = url.searchParams.get('snack-channel') ?? undefined; const runtimeVersion = url.searchParams.get('runtime-version'); - const [, sdkVersion] = runtimeVersion?.match(/exposdk:([0-9]+\.[0-9]+\.[0-9]+)/) ?? []; + const [, sdkVersion] = runtimeVersion?.match(/(?:exposdk:)?([0-9]+\.[0-9]+\.[0-9]+)/) ?? []; if (!sdkVersion) { return null; diff --git a/packages/snack-sdk/src/__fixtures__/bundledNativeModules.json b/packages/snack-sdk/src/__fixtures__/bundledNativeModules.json index 2c370385..b86649d2 100644 --- a/packages/snack-sdk/src/__fixtures__/bundledNativeModules.json +++ b/packages/snack-sdk/src/__fixtures__/bundledNativeModules.json @@ -422,5 +422,110 @@ "@shopify/react-native-skia": "0.1.221", "@shopify/flash-list": "1.6.3", "@sentry/react-native": "5.19.1" + }, + "^51.0.0": { + "@expo/vector-icons": "^14.0.0", + "@react-native-async-storage/async-storage": "1.23.1", + "@react-native-community/datetimepicker": "7.7.0", + "@react-native-masked-view/masked-view": "0.3.1", + "@react-native-community/netinfo": "11.3.1", + "@react-native-community/slider": "4.5.2", + "@react-native-community/viewpager": "5.0.11", + "@react-native-picker/picker": "2.7.5", + "@react-native-segmented-control/segmented-control": "2.5.2", + "@stripe/stripe-react-native": "0.37.2", + "expo-analytics-amplitude": "~11.3.0", + "expo-app-auth": "~11.1.0", + "expo-app-loader-provider": "~8.0.0", + "expo-apple-authentication": "~6.4.1", + "expo-application": "~5.9.1", + "expo-asset": "~10.0.6", + "expo-auth-session": "~5.5.2", + "expo-av": "~14.0.3", + "expo-background-fetch": "~12.0.1", + "expo-barcode-scanner": "~13.0.1", + "expo-battery": "~8.0.1", + "expo-blur": "~13.0.2", + "expo-brightness": "~12.0.1", + "expo-build-properties": "~0.12.1", + "expo-calendar": "~13.0.3", + "expo-camera": "~15.0.3", + "expo-cellular": "~6.0.2", + "expo-checkbox": "~3.0.0", + "expo-clipboard": "~6.0.3", + "expo-constants": "~16.0.1", + "expo-contacts": "~13.0.3", + "expo-crypto": "~13.0.2", + "expo-dev-client": "~4.0.10", + "expo-device": "~6.0.2", + "expo-document-picker": "~12.0.1", + "expo-face-detector": "~12.7.1", + "expo-file-system": "~17.0.1", + "expo-font": "~12.0.4", + "expo-gl": "~14.0.2", + "expo-google-app-auth": "~8.3.0", + "expo-haptics": "~13.0.1", + "expo-image": "~1.12.8", + "expo-image-loader": "~4.7.0", + "expo-image-manipulator": "~12.0.3", + "expo-image-picker": "~15.0.4", + "expo-intent-launcher": "~11.0.1", + "expo-insights": "~0.7.0", + "expo-keep-awake": "~13.0.1", + "expo-linear-gradient": "~13.0.2", + "expo-linking": "~6.3.1", + "expo-local-authentication": "~14.0.1", + "expo-localization": "~15.0.3", + "expo-location": "~17.0.1", + "expo-mail-composer": "~13.0.1", + "expo-media-library": "~16.0.3", + "expo-module-template": "~10.14.6", + "expo-modules-core": "~1.12.9", + "expo-navigation-bar": "~3.0.4", + "expo-network": "~6.0.1", + "expo-notifications": "~0.28.1", + "expo-print": "~13.0.1", + "expo-random": "~14.0.1", + "expo-router": "~3.5.9", + "expo-screen-capture": "~6.0.1", + "expo-screen-orientation": "~7.0.3", + "expo-secure-store": "~13.0.1", + "expo-sensors": "~13.0.5", + "expo-sharing": "~12.0.1", + "expo-sms": "~12.0.1", + "expo-speech": "~12.0.1", + "expo-splash-screen": "~0.27.4", + "expo-sqlite": "~14.0.3", + "expo-status-bar": "~1.12.1", + "expo-store-review": "~7.0.2", + "expo-symbols": "~0.1.4", + "expo-system-ui": "~3.0.4", + "expo-task-manager": "~11.8.1", + "expo-tracking-transparency": "~4.0.2", + "expo-updates": "~0.25.8", + "expo-video-thumbnails": "~8.0.0", + "expo-web-browser": "~13.0.3", + "jest-expo": "~51.0.1", + "lottie-react-native": "6.7.0", + "react": "18.2.0", + "react-dom": "18.2.0", + "react-native": "0.74.1", + "react-native-web": "~0.19.10", + "react-native-gesture-handler": "~2.16.1", + "react-native-get-random-values": "~1.11.0", + "react-native-maps": "1.14.0", + "react-native-pager-view": "6.3.0", + "react-native-reanimated": "3.10.0", + "react-native-screens": "3.31.1", + "react-native-safe-area-context": "4.10.1", + "react-native-svg": "15.2.0-rc.0", + "react-native-view-shot": "3.8.0", + "react-native-webview": "13.8.6", + "sentry-expo": "~7.0.0", + "unimodules-app-loader": "~4.6.0", + "unimodules-image-loader-interface": "~6.1.0", + "@shopify/react-native-skia": "1.2.3", + "@shopify/flash-list": "1.6.4", + "@sentry/react-native": "~5.22.0" } } diff --git a/packages/snack-sdk/src/__fixtures__/snackager.ts b/packages/snack-sdk/src/__fixtures__/snackager.ts index 7ccb83f3..6e9c8b2c 100644 --- a/packages/snack-sdk/src/__fixtures__/snackager.ts +++ b/packages/snack-sdk/src/__fixtures__/snackager.ts @@ -69,6 +69,10 @@ const config: SnackagerConfig = { version: '13.10.5', peerDependencies, }, + 'expo-av@~14.0.2': { + version: '14.0.2', + peerDependencies, + }, '@react-navigation/native@5.1.1': { peerDependencies, }, diff --git a/packages/snack-sdk/src/__tests__/__snapshots__/dependencies-test.ts.snap b/packages/snack-sdk/src/__tests__/__snapshots__/dependencies-test.ts.snap index a2ae1181..57cd0341 100644 --- a/packages/snack-sdk/src/__tests__/__snapshots__/dependencies-test.ts.snap +++ b/packages/snack-sdk/src/__tests__/__snapshots__/dependencies-test.ts.snap @@ -12,7 +12,7 @@ Object { }, "expo-font": Object { "version": "8.1.0", - "wantedVersion": "~11.4.0", + "wantedVersion": "~11.10.3", }, "react-native-paper": Object { "handle": "snackager-1/react-native-paper@3.10.1", @@ -108,27 +108,27 @@ Object { "@react-navigation/stack", "@react-navigation/drawer", ], - "wantedVersion": "~2.12.0", + "wantedVersion": "~2.14.0", }, "react-native-reanimated": Object { "dependents": Array [ "@react-navigation/drawer", ], - "wantedVersion": "~3.3.0", + "wantedVersion": "~3.6.2", }, "react-native-safe-area-context": Object { "dependents": Array [ "@react-navigation/stack", "@react-navigation/drawer", ], - "wantedVersion": "4.6.3", + "wantedVersion": "4.8.2", }, "react-native-screens": Object { "dependents": Array [ "@react-navigation/stack", "@react-navigation/drawer", ], - "wantedVersion": "~3.22.0", + "wantedVersion": "~3.29.0", }, } `; @@ -136,8 +136,8 @@ Object { exports[`dependencies resolves * after enabling 1`] = ` Object { "expo-constants": Object { - "version": "~14.4.2", - "wantedVersion": "~14.4.2", + "version": "~15.4.6", + "wantedVersion": "~15.4.6", }, } `; @@ -145,8 +145,8 @@ Object { exports[`dependencies resolves * to wanted version 1`] = ` Object { "expo-constants": Object { - "version": "~14.4.2", - "wantedVersion": "~14.4.2", + "version": "~15.4.6", + "wantedVersion": "~15.4.6", }, } `; @@ -176,7 +176,7 @@ Object { }, "expo-font": Object { "version": "~10.0.4", - "wantedVersion": "~11.4.0", + "wantedVersion": "~11.10.3", }, "react-native-paper": Object { "handle": "snackager-1/react-native-paper@3.10.1", @@ -206,13 +206,13 @@ Object { exports[`dependencies updates preloaded module version when changing SDK version 1`] = ` Object { "expo-av": Object { - "handle": "snackager-1/expo-av@13.4.1", + "handle": "snackager-1/expo-av@13.10.5", "peerDependencies": Object { "react": "*", "react-native": "*", }, - "version": "~13.4.1", - "wantedVersion": "~13.4.1", + "version": "~13.10.5", + "wantedVersion": "~13.10.5", }, } `; @@ -220,13 +220,13 @@ Object { exports[`dependencies updates preloaded module version when changing SDK version 2`] = ` Object { "expo-av": Object { - "handle": "snackager-1/expo-av@13.10.5", + "error": [Error: Failed to resolve dependency 'expo-av@~14.0.3' (Package 'expo-av@~14.0.3' not found in the registry)], "peerDependencies": Object { "react": "*", "react-native": "*", }, - "version": "~13.10.5", - "wantedVersion": "~13.10.5", + "version": "~14.0.3", + "wantedVersion": "~14.0.3", }, } `; diff --git a/packages/snack-sdk/src/__tests__/dependencies-test.ts b/packages/snack-sdk/src/__tests__/dependencies-test.ts index 93e97f2d..dd7cedcb 100644 --- a/packages/snack-sdk/src/__tests__/dependencies-test.ts +++ b/packages/snack-sdk/src/__tests__/dependencies-test.ts @@ -6,9 +6,9 @@ import Snack from './snack-sdk'; // A set of SDK versions to test against. // When upgrading SDK version, make sure to update this list. const sdkVersions: { [key: string]: SDKVersion } = { - prev: '48.0.0', - current: '49.0.0', - next: '50.0.0', + prev: '49.0.0', + current: '50.0.0', + next: '51.0.0', }; describe('dependencies', () => { diff --git a/runtime/.gitignore b/runtime/.gitignore index c613cb5f..2781f386 100644 --- a/runtime/.gitignore +++ b/runtime/.gitignore @@ -1,2 +1,3 @@ .expo/ web-build/ +dist/ diff --git a/runtime/app.config.js b/runtime/app.config.js new file mode 100644 index 00000000..834dacd1 --- /dev/null +++ b/runtime/app.config.js @@ -0,0 +1,42 @@ +const assert = require('assert'); +const { version: expoVersion } = require('expo/package.json'); +const { string } = require('getenv'); +const { major } = require('semver'); + +/** + * @param {object} params + * @param {import('expo/config').ExpoConfig} params.config + * @returns {import('expo/config').ExpoConfig} + */ +module.exports = ({ config }) => { + // Set web export prefix major Expo SDK version. + // This is used to properly host the web build on Snack's S3 hosting. + config.experiments ||= {}; + config.experiments.baseUrl = `/v2/${major(expoVersion)}`; + + const projectId = string('EXPO_PROJECT_ID', null); + + // Dynamically configure the EAS project ID, if not configured yet. + if (!config.extra?.eas?.projectId) { + assert(projectId, 'Environment variable "EXPO_PROJECT_ID" is required'); + + config.extra ||= {}; + config.extra.eas ||= {}; + config.extra.eas.projectId = projectId; + } + + // Dynamically configure the EAS endpoint, if not configured yet. + if (!config.updates?.url) { + assert(projectId, 'Environment variable "EXPO_PROJECT_ID" is required'); + + config.updates ||= {}; + + if (string('EXPO_PUBLIC_SNACK_ENV') === 'staging') { + config.updates.url = `https://staging-u.expo.dev/${projectId}`; + } else { + config.updates.url = `https://u.expo.dev/${projectId}`; + } + } + + return config; +}; diff --git a/runtime/app.json b/runtime/app.json index 66db1a1b..2ebdbacd 100644 --- a/runtime/app.json +++ b/runtime/app.json @@ -1,42 +1,30 @@ { "name": "Snack", - "expo": { - "name": "Snack", - "description": "Write code in Expo's online editor and instantly use it on your phone", - "scheme": "snack", - "owner": "exponent", - "slug": "snack", - "version": "1.0.0", - "primaryColor": "#000", - "icon": "./assets/icon.png", - "notification": { - "icon": "./assets/notification-icon.png", - "color": "#000000" - }, - "splash": { - "image": "./assets/splash.png" - }, - "developmentClient": { - "silentLaunch": true - }, - "platforms": [ - "android", - "ios", - "web" - ], - "assetBundlePatterns": [ - "**/*" - ], - "web": { - "favicon": "./assets/favicon.png", - "bundler": "metro" - }, - "plugins": [ - "expo-font", - "expo-router" - ], - "runtimeVersion": { - "policy": "sdkVersion" - } + "description": "Write code in Expo's online editor and instantly use it on your phone", + "scheme": "snack", + "owner": "exponent", + "slug": "snack", + "version": "1.0.0", + "primaryColor": "#000", + "icon": "./assets/icon.png", + "notification": { + "icon": "./assets/notification-icon.png", + "color": "#000000" + }, + "splash": { + "image": "./assets/splash.png" + }, + "developmentClient": { + "silentLaunch": true + }, + "platforms": ["android", "ios", "web"], + "assetBundlePatterns": ["**/*"], + "web": { + "favicon": "./assets/favicon.png", + "bundler": "metro" + }, + "plugins": ["expo-font", "expo-router", "expo-asset"], + "runtimeVersion": { + "policy": "sdkVersion" } } diff --git a/runtime/metro.config.js b/runtime/metro.config.js deleted file mode 100644 index 7217c19a..00000000 --- a/runtime/metro.config.js +++ /dev/null @@ -1,20 +0,0 @@ -// Learn more https://docs.expo.dev/guides/customizing-metro -const { getDefaultConfig } = require('expo/metro-config'); -const { boolish } = require('getenv'); - -const config = getDefaultConfig(__dirname); - -// Workaround for paths hosting web on a subdirectory (https:///v2//) -if (boolish('SNACK_EXPORT_WEB', false)) { - const expoVersion = require('expo/package.json').version; - const semver = require('semver'); - - config.transformer.publicPath = `/v2/${semver.major(expoVersion)}/assets`; - - // Error: While trying to resolve module `@socket.io/component-emitter` from file `/runtime/node_modules/socket.io-parser/build/esm/index.js`, - // the package `/runtime/node_modules/@socket.io/component-emitter/package.json` was successfully found. - // However, this package itself specifies a `main` module field that could not be resolved - config.resolver.sourceExts.push('mjs'); -} - -module.exports = config; diff --git a/runtime/package.json b/runtime/package.json index 4ec4fa7e..db6a4c97 100644 --- a/runtime/package.json +++ b/runtime/package.json @@ -21,7 +21,7 @@ "dependencies": { "@babel/polyfill": "^7.8.3", "@expo/vector-icons": "^14.0.0", - "@react-native-async-storage/async-storage": "1.21.0", + "@react-native-async-storage/async-storage": "1.23.1", "@react-navigation/drawer": "^6.6.2", "@react-navigation/native": "^6.1.6", "assert": "^2.1.0", @@ -29,30 +29,30 @@ "canvaskit-wasm": "0.38.0", "diff": "^5.0.0", "escape-string-regexp": "^5.0.0", - "expo": "~50.0.17", - "expo-asset": "~9.0.2", - "expo-barcode-scanner": "~12.9.3", - "expo-constants": "~15.4.6", - "expo-file-system": "~16.0.9", - "expo-font": "~11.10.3", - "expo-keep-awake": "~12.8.2", - "expo-linking": "~6.2.2", - "expo-random": "~13.6.0", - "expo-router": "~3.4.8", - "expo-splash-screen": "~0.26.4", - "expo-status-bar": "~1.11.1", - "expo-updates": "~0.24.12", + "expo": "51.0.0", + "expo-asset": "~10.0.6", + "expo-barcode-scanner": "~13.0.1", + "expo-constants": "~16.0.1", + "expo-file-system": "~17.0.1", + "expo-font": "~12.0.4", + "expo-keep-awake": "~13.0.1", + "expo-linking": "~6.3.1", + "expo-random": "~14.0.1", + "expo-router": "~3.5.9", + "expo-splash-screen": "~0.27.4", + "expo-status-bar": "~1.12.1", + "expo-updates": "~0.25.8", "path": "^0.12.7", "prop-types": "^15.7.2", "pubnub": "^7.2.0", "react": "18.2.0", "react-dom": "18.2.0", - "react-native": "0.73.6", - "react-native-gesture-handler": "~2.14.0", - "react-native-pager-view": "6.2.3", - "react-native-reanimated": "~3.6.2", - "react-native-safe-area-context": "4.8.2", - "react-native-screens": "~3.29.0", + "react-native": "0.74.1", + "react-native-gesture-handler": "~2.16.1", + "react-native-pager-view": "6.3.0", + "react-native-reanimated": "3.10.0", + "react-native-safe-area-context": "4.10.1", + "react-native-screens": "3.31.1", "react-native-view-shot": "3.8.0", "react-native-web": "~0.19.6", "snack-babel-standalone": "file:../packages/snack-babel-standalone", @@ -62,26 +62,26 @@ "source-map": "0.6.1" }, "devDependencies": { - "@babel/core": "^7.20.0", + "@babel/core": "^7.24.0", "@expo/spawn-async": "^1.7.2", "@types/diff": "^5.0.0", "@types/jest": "^26.0.24", "@types/pubnub": "^7.2.0", - "@types/react": "~18.2.45", - "@types/react-dom": "~18.0.10", + "@types/react": "~18.2.79", + "@types/react-dom": "~18.2.25", "@types/react-native": "~0.70.6", - "babel-preset-expo": "^10.0.0", + "babel-preset-expo": "~11.0.0", "eslint": "^8.56.0", "eslint-config-universe": "^12.0.0", "getenv": "^1.0.0", "jest": "^29.2.1", - "jest-expo": "~50.0.4", + "jest-expo": "~51.0.1", "patch-package": "^6.4.7", "postinstall-postinstall": "^2.1.0", "prettier": "^3.2.4", "s3-deploy": "^1.4.0", "semver": "^7.5.1", - "typescript": "^5.3.0" + "typescript": "~5.3.3" }, "eslintConfig": { "extends": "universe/native", diff --git a/runtime/patches/react-native+0.73.6.patch b/runtime/patches/react-native+0.74.1.patch similarity index 100% rename from runtime/patches/react-native+0.73.6.patch rename to runtime/patches/react-native+0.74.1.patch diff --git a/runtime/web/deploy-script.js b/runtime/web/deploy-script.js index 539e630b..bfd43db6 100644 --- a/runtime/web/deploy-script.js +++ b/runtime/web/deploy-script.js @@ -1,6 +1,5 @@ const spawnAsync = require('@expo/spawn-async'); const expoVersion = require('expo/package.json').version; -const fs = require('fs/promises'); const path = require('path'); const semver = require('semver'); @@ -13,8 +12,6 @@ async function run() { const exportDir = './web-build'; await exportWeb({ workingDir, exportDir }); - await patchBundleImportPath({ workingDir, exportDir }); - await patchFaviconImportPath({ workingDir, exportDir }); await uploadWeb({ workingDir, exportDir }); } @@ -32,10 +29,6 @@ async function exportWeb(options) { { cwd: options.workingDir, stdio: process.env.CI ? 'inherit' : 'ignore', - env: { - ...process.env, - SNACK_EXPORT_WEB: 'true', - }, }, ); console.log( @@ -43,50 +36,6 @@ async function exportWeb(options) { ); } -/** - * Fix the bundle path import in the `dist/index.html` export. - * This is required because the Snack Runtime is hosted in S3 under subfolders. - * We need to convert `