Jsi

作者 software-mansion-labse3f00cdb3494無授權條款291 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫10 天前更新

React Native JSI (JavaScript Interface) — C++ API for interacting with the JS runtime. Use whenever the user asks about or writes C++ code that touches JSI types or patterns: jsi::Runtime, jsi::Value, jsi::Object, jsi::Function, jsi::Array, jsi::ArrayBuffer, jsi::String, jsi::Symbol, jsi::BigInt, jsi::PropNameID, jsi::HostObject, jsi::HostFunction, jsi::NativeState, jsi::WeakObject, jsi::Scope, JSIException, JSINativeException, JSError, HostFunctionType, createFromHostFunction, getHostObject, setNativeState, evaluateJavaScript, queueMicrotask, drainMicrotasks, setRuntimeData, getRuntimeData, ISerialization, rt.global(), jsi.h, jsi-inl.h, JSI binding, C++ native module, calling JS from C++, calling C++ from JS, HostObject destructor, shared_ptr, CallInvoker, invokeAsync, folly::dynamic with JSI, zero-copy ArrayBuffer, TurboModule C++ layer, Nitro Module, jsi::WithRuntimeDecorator, or any question about the boundary between C++ and the JavaScript engine in React Native.

AI 產生的概覽

為撰寫連接原生程式碼與 JavaScript 引擎的 React Native JSI C++ 程式碼提供參考指引。

功能
此技能提供 React Native JavaScript 介面(JSI)的參考文件,JSI 是用來讀寫 JS 值、呼叫 JS 函式,以及向 JS 暴露 C++ 物件的 C++ API。內容涵蓋核心型別、型別轉換與序列化、執行緒與安全、非同步呼叫模式、效能、安裝範本、模組方案、C++ 記憶體模式,以及除錯。它要求代理每個問題最多載入一個參考檔案,並優先選擇最相符的檔案。
適用情境
當使用者詢問或撰寫涉及 JSI 型別或模式的 C++ 程式碼時使用,例如 jsi::Runtime、jsi::Value、HostObject、HostFunction 或 ArrayBuffer。它也適用於有關 React Native 中 C++ 與 JavaScript 邊界、TurboModule 或 Nitro Module 的 C++ 層,以及 JSI 當機或陷阱的問題。
執行需求
沒有指令碼;僅包含說明與參考 Markdown 檔案。除了代理讀取隨附的參考檔案外,不需要任何套件、認證或網路存取。

React Native JSI

The JavaScript Interface (JSI) is a C++ API that lets native code interact directly with the JavaScript engine — reading and writing JS values, calling JS functions, and exposing C++ objects to JS — without going through the old async bridge.

References

Load at most one reference file per question. Prefer the most specific match.

FileLoad when question is about
overview.mdJSI architecture, why rt.global(), sync vs async model, why some methods take Runtime&, event loop absence, queueMicrotask/drainMicrotasks, setRuntimeData/getRuntimeData, evaluateJavaScript caveat, prototype manipulation
core-types.mdJSI type system: Value, PropNameID, HostFunction, HostObject, NativeState, WeakObject, Array, ArrayBuffer, BigInt, Scope — constructors, ownership, lifetimes, GC behavior
casting-and-serialization.mdThe get/as naming convention, getPropertyAsObject/getPropertyAsFunction, string encoding (createFromAscii vs createFromUtf8), zero-copy string access, C++↔JS type mapping, createFromJsonUtf8, folly::dynamic, ISerialization
threading-safety.mdSingle-thread rule, write operations from multiple threads, JSI object destruction order, Value non-copyable + shared_ptr pattern, hot reload / bundle reload pitfalls, WithRuntimeDecorator<AroundLock>
calling-js-and-async.mdInstalling HostFunction bindings, calling JS functions from C++, callWithThis, callAsConstructor (JS Set / Map / Promise), invokeAsync + CallInvoker, Promise resolve/reject patterns, JSIException hierarchy
performance.mdBatching sequential calls, caching PropNameID, zero-copy ArrayBuffer via MutableBuffer, setExternalMemoryPressure, Scope in tight loops, avoiding evaluateJavaScript for function calls
setup-and-templates.mdInstalling a JSI binding in Android (FBJNI, JSIModulePackage) and iOS (ObjC++ .mm), library scaffolding templates, JSI vs TurboModules vs Nitro Modules
module-approaches.mdChoosing between Pure JSI, TurboModules, Nitro Modules, or a pure C++ core with thin adapter — decision tree, trade-offs, boilerplate comparison
cpp-memory-patterns.mdC++ memory for JS developers: unique_ptr, shared_ptr, std::move, lambda captures, RAII, circular ownership, the GC boundary between JS heap and native heap
debugging-and-pitfalls.mdCrash traces, symbolication (c++filt, addr2line, atos, ndk-stack), ASan, common JSI crash patterns, pre-ship checklist

來源與署名

來源:software-mansion-labs/skills位於skills/react-native-best-practices/references/jsi提交e3f00cd

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架