Docs / Platform support

Platform support

Android, iOS, New Architecture, React Native Web, Metro, and browser requirements.

Capability matrix

CapabilityAndroidiOSReact Native Web
File-path APIsYesYesNo
Binary-data APIsNoNoYes
Progress / cooperative cancelNative jobsNative jobsAbortSignal
Input / output limitsNative jobsNative jobsBinary options
Patch metadataFile pathFile pathBinary input
Byte-for-byte verificationTemporary fileTemporary fileIn-memory result
Legacy bridgeYesYesN/A
TurboModule / New ArchitectureYesYesN/A
Background executionSerial executorSerialized workerModule Web Worker
Patch formatENDSLEY/BSDIFF43ENDSLEY/BSDIFF43ENDSLEY/BSDIFF43

The example application uses React Native 0.86.0 and exercises the New Architecture on Android API 24/31 and iOS Simulator. Direct compatibility fixtures compile the package against React Native 0.73.11 and 0.74.7; the 0.73 fixture also preserves the legacy-architecture boundary, while the full example provides the current RN 0.86 build gate. React Native 0.82 and newer are New Architecture only. These are tested versions, not a promise that every intermediate or future release is compatible.

Android

Android selects a New Architecture package implementation based on the React Native minor version:

  • React Native 0.73 uses the compatible TurboReactPackage source set.
  • React Native 0.74 and newer use BaseReactPackage.
  • Legacy architecture builds use the classic ReactPackage implementation.

Native operations run on a module-owned single-thread executor. Jobs add a registry for queued/active cancellation, rate-limited progress events, limits, and cleanup. The packaged C code is built with CMake and invoked through JNI. inspectPatch reads only the patch header. verifyPatch applies into a cache file, compares it with the expected path in bounded chunks, and removes the temporary output before resolving.

iOS

iOS autolinking registers BsDiffPatch for both architectures. New Architecture codegen maps the module through modulesProvider, and the module returns a generated TurboModule instance when RCT_NEW_ARCH_ENABLED is set.

Module methods use a serial dispatch queue so a job is registered before a following cancellation request is handled. Patch work runs asynchronously on a separate serial worker queue, keeping the bridge responsive while preserving the shared C library's single-operation boundary. The job registry is cancelled and cleaned when the module is invalidated. Metadata inspection reads only 24 header bytes. Verification writes to a unique file under the system temporary directory and removes it on every exit path.

React Native Web

Standalone browser and desktop WebView applications should import the explicit ESM entry react-native-bs-diff-patch/web. Its Worker graph uses the Node-free web/bsdiffpatch.browser.mjs; the /toolkit entry is also ESM-only. The root package's browser condition remains available for existing React Native Web consumers. See Web and desktop WebView SDK for resource and CSP requirements.

The package has two Web entry mechanisms:

  • browser points standard browser-aware bundlers to web/index.mjs.
  • src/index.web.ts ensures Metro's platform resolver selects the Web API even
  • though React Native gives the react-native package field higher priority.

The browser must support:

  • WebAssembly.
  • Module Web Workers.
  • ArrayBuffer and typed arrays.
  • Blob.arrayBuffer() when Blob inputs are used.
  • AbortController when operation cancellation is used.

Webpack and Vite understand the standard new Worker(new URL(..., import.meta.url), { type: 'module' }) pattern. A Metro Web setup must preserve module-worker URLs in its Web serializer.

The Web entry is browser-oriented rather than a Node.js filesystem adapter. It does not make native file-path APIs available in the browser. startDiff and startPatch use binary inputs on Web; the separate package ./node entry provides release-side filesystem operations.

Calls without an AbortSignal share a module Worker and initialized WebAssembly module. Calls with a signal receive a dedicated Worker so cancellation is isolated to that operation. Both paths serialize work inside their Worker; callers should still enforce an application memory budget. Blob and File inputs use read-only WORKERFS mounts to avoid a full main-thread copy. inspectPatch does not start a Worker. verifyPatch first validates metadata, then uses the same Worker path as patchBytes and discards the restored buffer after comparing it with the expected input.

Server-side rendering

Importing the Web entry does not create a worker. Calling diffBytes or patchBytes in an environment without Worker rejects with EUNSUPPORTED. Invoke the binary APIs only in browser/client code.

Patch exchange

Patch bytes are portable across Android, iOS, and Web. File access, transport, storage, integrity verification, and final replacement remain application responsibilities. See Production recipes for a safe exchange sequence.