{"name":"expo-modules-jsi","version":"57.0.2","keywords":["expo","modules","jsi","expo-modules","react-native"],"author":{"name":"650 Industries, Inc."},"license":"MIT","_id":"expo-modules-jsi@57.0.2","maintainers":[{"name":"ide","email":"ide+npm@jameside.com"},{"name":"brentvatne","email":"brentvatne@gmail.com"},{"name":"expoadmin","email":"support@expo.io"},{"name":"exponent","email":"exponent.team@gmail.com"},{"name":"bycedric","email":"me@bycedric.com"},{"name":"kudochien","email":"ckchien@gmail.com"},{"name":"alanhughes","email":"hughesno1@gmail.com"},{"name":"tsapeta","email":"npm@tsapeta.com"},{"name":"expo-bot","email":"brent+expobotnpm@expo.io"},{"name":"philpl","email":"phil@kitten.sh"},{"name":"wschurman","email":"wschurman@gmail.com"}],"homepage":"https://github.com/expo/expo/tree/main/packages/expo-modules-jsi","bugs":{"url":"https://github.com/expo/expo/issues"},"dist":{"shasum":"12d5a80a291d0a063a886718ed452284994b964c","tarball":"http://registry-npm.ywwl.com/expo-modules-jsi/download/expo-modules-jsi-57.0.2.tgz","fileCount":90,"integrity":"sha512-yu6i8KdgZC/ZHMN4k90pwhxo/RaDDo1TqYOuFUNCQR0YjOeyMleN6LmicJKtLHoE/QdRYzjFUFsQXb5Qy/Sf2Q==","signatures":[{"sig":"MEYCIQCygEm1ux9f3hKqiCyC3qTRbFagX+Db2oAN3RA8i8OkRAIhAMBBaM5ETGZKtUEIIIjIlpIiv3jyVRQrgkvTx+eMnCak","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":545845,"size":124641,"noattachment":false,"key":"/expo-modules-jsi/-/expo-modules-jsi-57.0.2.tgz"},"main":"index.js","_from":"file:expo-modules-jsi-57.0.2.tgz","exports":{".":{"default":"./index.js"},"./package.json":"./package.json"},"gitHead":"70af1caf83d8a324b46e02e18cd5c8c4e310da20","scripts":{"test":"apple/scripts/test.sh","build":"apple/scripts/build-xcframework.sh","swift:lint":"../../scripts/swift-format.sh --lint","swift:format":"../../scripts/swift-format.sh"},"_npmUser":{"name":"alanhughes","email":"hughesno1@gmail.com"},"_resolved":"/private/var/folders/n0/qjsqltys22x39clpr979wq7h0000gn/T/776064209b293ee1fae2d3634ca145e3/expo-modules-jsi-57.0.2.tgz","_integrity":"sha512-yu6i8KdgZC/ZHMN4k90pwhxo/RaDDo1TqYOuFUNCQR0YjOeyMleN6LmicJKtLHoE/QdRYzjFUFsQXb5Qy/Sf2Q==","repository":{"url":"git+https://github.com/expo/expo.git","type":"git","directory":"packages/expo-modules-jsi"},"_npmVersion":"11.11.0","description":"The JavaScript Interface for Expo Modules","directories":{},"sideEffects":[],"_nodeVersion":"22.17.0","dependencies":{},"publishConfig":{"executableFiles":["./apple/scripts/build-xcframework.sh","./apple/scripts/create-stub-xcframework.sh","./apple/scripts/generate-modulemap.sh","./apple/scripts/test.sh"]},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{},"peerDependencies":{"react-native":"*"},"_npmOperationalInternal":{"tmp":"tmp/expo-modules-jsi_57.0.2_1784107159356_0.2580451859466588","host":"s3://npm-registry-packages-npm-production"},"readme":"<p>\n  <a href=\"https://docs.expo.dev/modules/\">\n    <img\n      src=\"../../.github/resources/expo-modules-jsi.svg\"\n      alt=\"expo-modules-jsi\"\n      height=\"64\" />\n  </a>\n</p>\n\n`expo-modules-jsi` provides type-safe Swift bindings to React Native's JSI (JavaScript Interface) C++ library. It lets native Swift code interact with the JavaScript runtime (Hermes) through a Swift-first API and is the foundation that newer parts of [`expo-modules-core`](../expo-modules-core) build on.\n\nThis package has no JavaScript runtime code. It is consumed natively on Apple platforms via CocoaPods or Swift Package Manager, and the npm package only exists so the native sources can be autolinked into your app.\n\n# Installation\n\nThis package is not meant to be installed directly. It ships as a transitive native dependency of [`expo-modules-core`](../expo-modules-core), which is included in any Expo project. Adding it to your app's `package.json` is unnecessary and unsupported.\n\n# Public API\n\n- `JavaScriptRuntime`: entry point for evaluating scripts, scheduling work on the JS thread, and creating values.\n- `JavaScriptValue`, `JavaScriptObject`, `JavaScriptArray`, `JavaScriptFunction`, `JavaScriptArrayBuffer`, `JavaScriptTypedArray`, `JavaScriptPromise`, `JavaScriptBigInt`, `JavaScriptError`, `JavaScriptWeakObject`: non-copyable (`~Copyable`) wrappers around their JSI counterparts.\n- `JavaScriptRef<T>`: turns any of the above into a reference type for use in escaping closures and containers.\n- `JavaScriptCallback`: a JavaScript function that native code can keep and call later from any thread, waiting for the result, awaiting it, or not waiting at all. It keeps the function alive until it's released, and throws once the runtime is gone.\n- `JavaScriptRepresentable`: protocol for converting Swift types to and from JS values, with default implementations for primitives, `String`, `Array`, `Dictionary` and `Optional`.\n- `JavaScriptDecodable`, `JavaScriptEncodable` and their `JavaScriptCodable` composition: coding layer with conformances for stdlib types, `Data`, `Date` and `Task`. `JavaScriptUndefined` is the codable native counterpart of `undefined`.\n- `@JavaScriptActor`: global actor that enforces JS-thread isolation at compile time. Its executor is synchronous (no thread hopping), so code must be placed on the JS thread externally, with `runtime.schedule()` or `runtime.execute()`.\n- Error bridging: `capturingCppErrors()` converts C++ exceptions into Swift errors, and `CppError` provides thread-safe C++ exception storage.\n\n# Swift and C++ configuration\n\n- **Swift 6** language mode (`swiftLanguageModes: [.v6]`), which implies complete concurrency checking\n- **C++20** standard\n- **Platforms:** iOS 16.4+, tvOS 16.4+, macOS 13.4+\n- **Library evolution** enabled for binary framework distribution\n- Upcoming Swift features: `NonisolatedNonsendingByDefault`, `InferIsolatedConformances`\n\nC++ interoperability is enabled with `.interoperabilityMode(.Cxx)`, and `apple/APINotes/jsi.apinotes` controls how individual JSI types surface in Swift.\n\n# Building\n\nThe package can't be consumed from sources directly: it relies on Swift/C++ interop, which is a per-target compiler setting. Source distribution would force every Expo module that depends on it, and transitively the host app, to enable Swift/C++ interop too, which is invasive and significantly increases build times for each module. Instead, the sources are compiled into a binary `ExpoModulesJSI.xcframework` that consumers link against, so Swift/C++ interop stays contained inside this package.\n\nThe build is wired up in `apple/ExpoModulesJSI.podspec`:\n\n- A `script_phase` runs `apple/scripts/build-xcframework.sh` before headers on every build of the host app. The script invokes SPM under the hood, applies hash-based caching to skip rebuilds when sources haven't changed, and produces additive per-platform slices in `apple/Products/ExpoModulesJSI.xcframework`.\n- A `prepare_command` runs `apple/scripts/create-stub-xcframework.sh` so CocoaPods generates the \"Copy XCFrameworks\" and \"Embed Pods Frameworks\" build phases even before the real xcframework exists.\n- The xcframework is declared as `vendored_frameworks`, so dependents see it as a regular binary dependency with no interop flags of their own.\n\nYou can also build the package directly:\n\n```sh\npnpm build:xcframework   # rebuild the xcframework outside of a Pods install\npnpm clean               # remove local build caches and artifacts\n```\n\n# Testing\n\nTests live in `apple/Tests/` and use the Swift Testing framework. Benchmarks live in `apple/Benchmarks/` and are gated on an environment variable, so a regular test run builds but skips them.\n\n```sh\npnpm test:integration    # run the test suite on an iOS Simulator\npnpm benchmark           # run the benchmarks in the Release configuration\n```\n\nBoth run against an installed host app's `Pods` directory, which defaults to `apps/bare-expo`. Set `PODS_ROOT` to point at a different one and `DESTINATION` to choose another xcodebuild destination. Extra arguments are forwarded to `xcodebuild`, for example `pnpm test:integration -only-testing Tests/JavaScriptValueTests`.\n\n# Using JSI types from a module\n\nModule authors don't import `ExpoModulesJSI` directly. `expo-modules-core` re-exports its types, so `import ExpoModulesCore` is enough. The Expo Modules API marshals JSI values automatically when you declare them in a `ModuleDefinition`:\n\n```swift\nimport ExpoModulesCore\n\npublic class MyModule: Module {\n  public func definition() -> ModuleDefinition {\n    Name(\"MyModule\")\n\n    Function(\"printString\") { (value: JavaScriptValue) in\n      print(value.getString())\n    }\n  }\n}\n```\n\nFor lower-level access, reach the runtime through the module's `appContext`. Calls into JSI must happen on the JS thread, so wrap them in `execute` (synchronous, returns a value) or `schedule` (asynchronous, fire and forget):\n\n```swift\nAsyncFunction(\"evaluate\") { (source: String) -> Int in\n  guard let appContext else {\n    throw Exceptions.AppContextLost()\n  }\n  let runtime = try appContext.runtime\n\n  return try runtime.execute {\n    try runtime.eval(source).getInt()\n  }\n}\n```\n\n# Contributing\n\nContributions are very welcome! Please refer to the guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).\n","publish_time":1784107159490,"_cnpm_publish_time":1784107159490,"dist-tags":{"canary":"58.0.0-canary-20260909-ea7a89a","canary-sdk-56":"56.0.8-canary-20260701-9100865","latest":"58.0.22","next":"58.0.14","sdk-56":"56.0.14","sdk-57":"57.1.3"}}