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.
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.Usage
How
snack-content
snack-sdk
to use this, and re-export these helperssnack-content
URL helpers in Snack RuntimetestTransport
query parameter in Snack WebsiteTest Plan
See added tests, full testing can only be done once we have SDK 50 merged.