// Where the worklet's storage comes from.
//
// On the phone bare-kit passes EXACTLY the args the shell gives, so Bare.argv is
// [storage] (react-native-bare-kit shared/BareKitModule.cc: bare_worklet_start(
// ..., args.size(), args)). On a desktop `bare lib/worklet.js <storage>` gives
// [runtime, script, storage]. 0.1.0 required argv.length > 1 -- true only on a
// desktop -- so on the phone the worklet loaded and then never started.
export function storageFromArgv (argv) {
if (!Array.isArray(argv)) return null
if (argv.length === 1) return argv[0] || null // phone
if (argv.length >= 3) return argv[argv.length - 1] // desktop: runtime, script, storage
return null // desktop, no storage given
}