UNPKG

one

Version:

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

67 lines (66 loc) • 2.36 kB
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 browser_exports = {}; __export(browser_exports, { Browser: () => Browser }); module.exports = __toCommonJS(browser_exports); var import_validate = require("./validate.cjs"); function blocked(verb) { const error = new Error(`${verb}: the browser blocked the popup. Open it from a user gesture.`); error.code = "E_BROWSER_BLOCKED"; return error; } function open(url, options = {}) { (0, import_validate.assertBrowserUrl)(url, "Browser.open"); (0, import_validate.assertOpenOptions)(options, "Browser.open"); return openPage(url); } async function openPage(url) { if (typeof window === "undefined") return { type: "opened" }; const opened = window.open(url, "_blank"); if (!opened) throw blocked("Browser.open"); opened.opener = null; return { type: "opened" }; } async function dismiss() { return { type: "dismiss" }; } function openAuthSession(url, redirectUrl, options = {}) { (0, import_validate.assertBrowserUrl)(url, "Browser.openAuthSession"); (0, import_validate.assertRedirectUrl)(redirectUrl, "Browser.openAuthSession"); (0, import_validate.assertAuthOptions)(options, "Browser.openAuthSession"); return Promise.reject(new Error("Browser.openAuthSession needs an iOS or Android build")); } function dismissAuthSession() {} function warmup(_browserPackage) { return Promise.resolve(false); } function mayLaunchUrl(url, _browserPackage) { (0, import_validate.assertBrowserUrl)(url, "Browser.mayLaunchUrl"); return Promise.resolve(false); } const Browser = Object.freeze({ open, dismiss, openAuthSession, dismissAuthSession, warmup, mayLaunchUrl });