Skip to content
THE OTA MANUALCore architecture
Verifiedv0.1.0 ↗

Native pre-boot architecture ​

ota-nativescript hooks into official NativeScript 9.1 startup points on both platforms so bundle selection, binary-upgrade checks and crash-recovery accounting execute before V8 starts.

Jolt Interactive Lab

OTA Delivery & Atomic Switch

IMMUTABLEembedded/appActive on boot
SANDBOXstaging/ota-vue-v2
0 files · 0 KB
RELEASE releases/ota-vue-v2/app Waiting for staging

Native pre-boot selects the immutable store-shipped bundle

Before V8 starts, CortexOtaBootstrapper (iOS) / OtaAndroidPlugin (Android) read state.json and boot the untouched embedded bundle.

// active pointer: embedded/app
{
  "confirmedReleaseId": null,
  "stagedReleaseId": null,
  "pendingLaunch": null
}

Platform comparison ​

AxisiOS (@nativescript/ios 9.1.1)Android (@nativescript/android 9.1.3)
Hook pointNS_SWIFTUI_BOOT = 1 in plugin build.xcconfig suppresses internal/main.m; CortexOtaMain.m calls CortexOtaBootstrapper before NativeScript.runMainApplication.OtaAndroidPlugin registered via com.tns.internal.Plugin <meta-data>, invoked by RuntimeHelper.initRuntime before asset extraction and V8 startup.
Storage rootLibrary/Application Support/com.getcortexlabs.ota (marked NSURLIsExcludedFromBackupKey).context.getFilesDir()/ota (app-private internal storage; allowBackup="false" recommended).
Embedded fallbackImmutable Bundle.main.resourcePath inside the signed .app bundle.Extracted from APK assets/app into files/ota/embedded/app once per APK fingerprint.
Bundle switchingPasses the selected directory (or Bundle.main.resourcePath) as Config.BaseDir.Atomically flips files/app via POSIX symlink (Os.symlink to temp link + Os.rename over files/app).
Native cryptoApple CryptoKit (Curve25519.Signing.PublicKey, streaming SHA256) in CortexOtaCrypto.swift.Google Tink 1.15.0 (Ed25519Verify) + streaming MessageDigest("SHA-256") in OtaCrypto.java.
Config deliveryafter-prepare writes CortexOtaConfigBase64 + CortexOtaRuntimeContract into Info.plist.after-prepare writes assets/cortex_ota_config.json into APK assets.

Both NativeScript's module loader and @nativescript/core's knownFolders.currentApp() resolve relative paths (~/assets/..., ~/fonts/..., dynamic import(...) chunks and new Worker(...)) from the active app root.

Because Config.BaseDir on iOS and the atomic files/app symlink on Android point both V8 and knownFolders.currentApp() at the exact same release directory, entry modules (.mjs/.js), lazy Webpack chunks, web workers, fonts and images always load atomically from one consistent release snapshot.

Entry resolution for NativeScript 9.1 Webpack 5 and Vite 8 ​

NativeScript 9.1 Webpack 5 and @nativescript/vite 8.x (Rolldown) emit native ES module graphs (bundle.mjs, vendor.mjs, dynamic chunks, activity.android.mjs and assets/*.worker-*.js) while writing extensionless "main": "bundle" (or ./bundle.mjs) in app/package.json. Both native bootstrappers and ota-ns pack strip leading ./ and resolve main, ${main}.mjs and ${main}.js.

Because Config.BaseDir on iOS and the files/app symlink on Android align V8's module root with knownFolders.currentApp(), dynamic import(...) chunks, require(esm), ns: runtime built-ins (ns:util), web workers, and Android V8 codeCache .cache files all stay isolated per release.

Content-addressed local reuse (#17) ​

During staging, StagingManager indexes regular, non-symlink files from already-verified local directories (active release, confirmed release, staged release, and embedded app bundle). Before downloading a file over HTTP, it checks candidates matching exact byte size and verified sha256 (path match first, then size match for renamed Rollup chunks):

  • iOS: copies verified local files with NSFileManager copyItemAtPath:toPath: (APFS copy-on-write cloning — zero extra flash blocks and full isolation from deleting older releases).
  • Android: copies bytes directly into the private staging/<tmp-id>/app directory (no hard links or symlinks), keeping garbage collection of older releases completely independent.
  • If a local candidate fails SHA-256 verification or copy fails, staging transparently falls back to HTTP download, and verifyStagedBundleDirectory still audits 100% of the assembled staging folder before atomic promotion.

Storage layout on disk ​

text
<ota-root>/
├── state.json                  # Atomic rename-swapped BootState
├── embedded/                   # (Android only) immutable APK assets/app extraction
│   └── app/
├── staging/                    # Isolated download & verification sandbox (wiped on failure)
│   └── <candidateReleaseId>/
└── releases/                   # Verified immutable releases (GC keeps active + lastConfirmed + staged)
    └── <releaseId>/
        ├── manifest.json
        └── app/
            ├── package.json
            ├── bundle.mjs
            ├── vendor.mjs
            ├── ota-vue-lazy.mjs
            ├── src_ota_worker_ts.mjs
            ├── assets/
            └── fonts/