Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature!: move snack runtime URLs to snack-content and add EAS Update URLs #527

Merged

Conversation

byCedric
Copy link
Member

@byCedric byCedric commented Jan 10, 2024

Why

Part of ENG-11039

Since the Snack Runtime URL is generated and used in various places of Snack, let's centralize this. Note, that these URLs are automatically generated through the snack-sdk's (new Snack()).url property.

⚠️ One bigger change in these URLs is that we will mostly be using Snack hashes, or the ID for a saved hash. Previously, we used a combination of @owner-name/snack-name.

Usage

import { createSnackRuntimeUrl, parseSnackRuntimeUrl } from 'snack-content'; // or `snack-sdk`, we re-export them

// This link can be opened directly in Expo Go, it's prefixed with `exp://<URL>`
// All parameters are optional, as there are quite a few combinations to make
const canBeOpenedInExpoGo = createSnackRuntimeUrl({
  snack: 'snack-hash',
  channel: 'xyz!s',
  sdkVersion: '50.0.0', // Or just the major version as number: `50`
});

// This is used in the Snack Runtime, to load the right data with either classic or EAS Updates
// Note, we do return the `sdkVersion` if defined, but once this is executed from Snack Runtime,
// it already loaded the right sdk version
const { snack, channel } = parseSnackRuntimeUrl(initialUrl);

// If you need to create/parse the newer/older URL format specifically, you can also use these methods
// Be aware that we will slowly move over to the newer URL format, and these methods may be refactored into the ones above
import {
  createEASUpdateSnackRuntimeUrl,
  parseEASUpdateSnackRuntimeUrl,
  createClassicUpdateSnackRuntimeUrl,
  parseClassicUpdateSnackRuntimeUrl
} from 'snack-content';

How

  • Add Snack Runtime URL helpers to snack-content
  • Update snack-sdk to use this, and re-export these helpers
  • Use snack-content URL helpers in Snack Runtime
  • Fix issue with appending testTransport query parameter in Snack Website

Test Plan

See added tests, full testing can only be done once we have SDK 50 merged.

@byCedric byCedric requested a review from Kudo January 10, 2024 19:53
@byCedric byCedric merged commit e46845a into main Jan 11, 2024
25 checks passed
@byCedric byCedric deleted the @bycedric/snack-content/centralize-runtime-url-generation branch January 11, 2024 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant