UNPKG

realm

Version:

Realm by MongoDB is an offline-first mobile database: an alternative to SQLite and key-value stores

52 lines 2.34 kB
"use strict"; //////////////////////////////////////////////////////////////////////////// // // Copyright 2024 Realm Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////// Object.defineProperty(exports, "__esModule", { value: true }); const react_native_1 = require("react-native"); const binding_1 = require("../binding"); const assert_1 = require("../../assert"); const expo_go_detection_1 = require("./expo-go-detection"); try { const RealmNativeModule = react_native_1.TurboModuleRegistry.getEnforcing("Realm"); const nativeModule = RealmNativeModule.initialize(); // Inject the native module into the binding assert_1.assert.object(nativeModule, "nativeModule"); (0, binding_1.injectNativeModule)(nativeModule, { Int64: (global.HermesInternal ? binding_1.NativeBigInt : binding_1.PolyfilledBigInt), WeakRef: class WeakRef { native; constructor(obj) { // eslint-disable-next-line @typescript-eslint/no-explicit-any -- See "createWeakRef" protocol in the jsi bindgen template this.native = nativeModule.createWeakRef(obj); } deref() { // eslint-disable-next-line @typescript-eslint/no-explicit-any -- See "createWeakRef" protocol in the jsi bindgen template return nativeModule.lockWeakRef(this.native); } }, }); } catch (err) { if ((0, expo_go_detection_1.isExpoGo)()) { throw new expo_go_detection_1.RealmInExpoGoError(); } else { throw new Error("Could not find the Realm binary. Please consult our troubleshooting guide: https://www.mongodb.com/docs/realm-sdks/js/latest/#md:troubleshooting-missing-binary"); } } //# sourceMappingURL=binding.js.map