import { ExportSnapshot, IosAppLaunchFlow, IosApp, IosLogin, IosPostLoginFlow } from '@igpapi/ios';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
yield* IosLogin({ username, password });
yield* IosPostLoginFlow();
yield* IosAppLaunchFlow();
return yield* ExportSnapshot;
});
const snapshot = await Effect.runPromise(Effect.provide(program, IosApp({ seed: username })));
The Instagram iOS app on a virtual device, as a
Layer: everything the package's public effects run on — the login, the launch and Direct flows, the shared mobile effects,ExportSnapshotandProtocolDiagnostics.Start from
seed(a deterministic new device) or fromsnapshot(a session exported earlier withExportSnapshot). The other options are those of the native transport and the device's network.One build is one app process. Building the layer creates the device and session state, the native transport client and the process state (navigation, telemetry, what the app keeps only in memory); everything the program changes lives in that build. Provide the layer once around the whole program, or keep it in a
ManagedRuntimeyou own: providing it to two programs separately starts two processes from the same input. Export the snapshot inside the program (or the runtime) whose state it should carry.A snapshot that cannot be restored (a damaged cookie jar or state) fails the build with
SnapshotDecodeError, an expected failure to handle — usually by logging in again. Asnapshotkey present butundefinedis not a snapshot: it is the caller's "no saved session", so the layer starts a fresh install instead of failing. Invalid options (a request timeout out of range) are a programming error and fail the build as a defect.