UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

119 lines (116 loc) • 4.34 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var index_native_exports = {}; __export(index_native_exports, { Updates: () => Updates }); module.exports = __toCommonJS(index_native_exports); var import_react_native_nitro_modules = require("react-native-nitro-modules"); var import_nativeError = require("../nativeError.native.js"); var import_validate = require("./validate.native.js"); var hybrid; function native() { hybrid !== null && hybrid !== void 0 ? hybrid : hybrid = import_react_native_nitro_modules.NitroModules.createHybridObject("OneUpdates"); return hybrid; } var hasNative = import_react_native_nitro_modules.NitroModules.hasHybridObject("OneUpdates"); function disabledError(verb) { return Object.assign(new Error(`Updates.${verb}: updates are disabled in this build.`), { code: "E_UPDATES_DISABLED" }); } function toCheckResult(param) { var { type, manifestJson } = param; if (type === "available" && manifestJson !== void 0) return { type, manifest: (0, import_validate.parseUpdateManifest)(manifestJson) }; if (type === "available") throw new Error("Updates.check: available without a manifest"); return { type }; } function toFetchResult(param) { var { type, manifestJson } = param; if (type === "fetched" && manifestJson !== void 0) return { type, manifest: (0, import_validate.parseUpdateManifest)(manifestJson) }; if (type === "fetched") throw new Error("Updates.fetch: fetched without a manifest"); return { type }; } function check() { if (!hasNative) return Promise.reject(disabledError("check")); return native().check().then(toCheckResult, import_nativeError.rethrowNativeError); } function fetch() { if (!hasNative) return Promise.reject(disabledError("fetch")); return native().fetch().then(toFetchResult, import_nativeError.rethrowNativeError); } function getStaged() { if (!hasNative) return null; var stagedJson = native().getStagedJson(); return stagedJson === void 0 ? null : (0, import_validate.parseUpdateManifest)(stagedJson); } function addStagedListener(listener) { (0, import_validate.assertStagedListener)(listener); if (!hasNative) return { remove: function remove2() {} }; var remove = native().addStagedListener(function(stagedJson) { listener(stagedJson === void 0 ? null : (0, import_validate.parseUpdateManifest)(stagedJson)); }); return { remove: function remove1() { return remove(); } }; } function reload() { if (!hasNative) return Promise.reject(disabledError("reload")); return native().reload().catch(import_nativeError.rethrowNativeError); } function readUpdates() { var _running_runtimeVersion, _running_updateId; if (!hasNative) { return { isEnabled: false, runtimeVersion: null, updateId: null, isEmbeddedLaunch: false, createdAt: null, manifest: null, check, fetch, getStaged, addStagedListener, reload }; } var running = native(); var createdAt = running.createdAt; return { isEnabled: running.isEnabled, runtimeVersion: (_running_runtimeVersion = running.runtimeVersion) !== null && _running_runtimeVersion !== void 0 ? _running_runtimeVersion : null, updateId: (_running_updateId = running.updateId) !== null && _running_updateId !== void 0 ? _running_updateId : null, isEmbeddedLaunch: running.isEmbeddedLaunch, createdAt: createdAt === void 0 ? null : new Date(createdAt), manifest: running.manifestJson === void 0 ? null : (0, import_validate.parseUpdateManifest)(running.manifestJson), check, fetch, getStaged, addStagedListener, reload }; } var Updates = Object.freeze(readUpdates()); //# sourceMappingURL=index.native.js.map