realm
Version:
Realm by MongoDB is an offline-first mobile database: an alternative to SQLite and key-value stores
79 lines • 2.77 kB
JavaScript
"use strict";
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2023 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 package_json_1 = require("realm/package.json");
const device_info_1 = require("../device-info");
const binding_1 = require("../binding");
function getDeviceName() {
if (react_native_1.Platform.OS === "ios") {
if (react_native_1.Platform.isPad) {
return "iPad";
}
else if (react_native_1.Platform.isTV) {
return "AppleTV";
}
else {
// RN doesn't support Apple Watch
return "iPhone";
}
}
else if (react_native_1.Platform.OS === "android") {
return `${react_native_1.Platform.constants.Manufacturer}:${react_native_1.Platform.constants.Brand}`;
}
else {
return "unknown";
}
}
function getDeviceVersion() {
if (react_native_1.Platform.OS === "android") {
return `${react_native_1.Platform.constants.Model}`;
}
else {
return "unknown";
}
}
function getReactNativeVersion() {
const { major, minor, patch, prerelease } = react_native_1.Platform.constants.reactNativeVersion;
const result = [major, minor, patch].join(".");
if (prerelease) {
return result + "-" + prerelease;
}
else {
return result;
}
}
(0, device_info_1.inject)({
create() {
return {
sdk: "JS",
sdkVersion: package_json_1.version,
platform: react_native_1.Platform.OS,
// Android reports a number ...
platformVersion: `${react_native_1.Platform.Version}`,
deviceName: getDeviceName(),
deviceVersion: getDeviceVersion(),
cpuArch: binding_1.binding.JsPlatformHelpers.getCpuArch(),
frameworkName: "react-native",
frameworkVersion: getReactNativeVersion(),
bundleId: package_json_1.config?.anonymizedBundleId || "unknown",
};
},
});
//# sourceMappingURL=device-info.js.map