Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/improsocial/impro
An extensible Bluesky client for web impro.social
Something went wrong. Try again.
JavaScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727var __defProp = Object.defineProperty;var __getOwnPropNames = Object.getOwnPropertyNames;var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;};var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true });};
// node_modules/@capacitor/core/dist/index.jsvar ExceptionCode, CapacitorException, getPlatformId, createCapacitor, initCapacitorGlobal, Capacitor, registerPlugin, WebPlugin, WebView, encode, decode, CapacitorCookiesPluginWeb, CapacitorCookies, readBlobAsBase64, normalizeHttpHeaders, buildUrlParams, buildRequestInit, CapacitorHttpPluginWeb, CapacitorHttp;var init_dist = __esm({ "node_modules/@capacitor/core/dist/index.js"() { (function(ExceptionCode2) { ExceptionCode2["Unimplemented"] = "UNIMPLEMENTED"; ExceptionCode2["Unavailable"] = "UNAVAILABLE"; })(ExceptionCode || (ExceptionCode = {})); CapacitorException = class extends Error { constructor(message, code, data) { super(message); this.message = message; this.code = code; this.data = data; } }; getPlatformId = (win) => { var _a, _b; if (win === null || win === void 0 ? void 0 : win.androidBridge) { return "android"; } else if ((_b = (_a = win === null || win === void 0 ? void 0 : win.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.bridge) { return "ios"; } else { return "web"; } }; createCapacitor = (win) => { const capCustomPlatform = win.CapacitorCustomPlatform || null; const cap = win.Capacitor || {}; const Plugins = cap.Plugins = cap.Plugins || {}; const getPlatform = () => { return capCustomPlatform !== null ? capCustomPlatform.name : getPlatformId(win); }; const isNativePlatform = () => getPlatform() !== "web"; const isPluginAvailable = (pluginName) => { const plugin = registeredPlugins.get(pluginName); if (plugin === null || plugin === void 0 ? void 0 : plugin.platforms.has(getPlatform())) { return true; } if (getPluginHeader(pluginName)) { return true; } return false; }; const getPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find((h) => h.name === pluginName); }; const handleError = (err) => win.console.error(err); const registeredPlugins = /* @__PURE__ */ new Map(); const registerPlugin2 = (pluginName, jsImplementations = {}) => { const registeredPlugin = registeredPlugins.get(pluginName); if (registeredPlugin) { console.warn(`Capacitor plugin "${pluginName}" already registered. Cannot register plugins twice.`); return registeredPlugin.proxy; } const platform = getPlatform(); const pluginHeader = getPluginHeader(pluginName); let jsImplementation; const loadPluginImplementation = async () => { if (!jsImplementation && platform in jsImplementations) { jsImplementation = typeof jsImplementations[platform] === "function" ? jsImplementation = await jsImplementations[platform]() : jsImplementation = jsImplementations[platform]; } else if (capCustomPlatform !== null && !jsImplementation && "web" in jsImplementations) { jsImplementation = typeof jsImplementations["web"] === "function" ? jsImplementation = await jsImplementations["web"]() : jsImplementation = jsImplementations["web"]; } return jsImplementation; }; const createPluginMethod = (impl, prop) => { var _a, _b; if (pluginHeader) { const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find((m) => prop === m.name); if (methodHeader) { if (methodHeader.rtype === "promise") { return (options) => cap.nativePromise(pluginName, prop.toString(), options); } else { return (options, callback) => cap.nativeCallback(pluginName, prop.toString(), options, callback); } } else if (impl) { return (_a = impl[prop]) === null || _a === void 0 ? void 0 : _a.bind(impl); } } else if (impl) { return (_b = impl[prop]) === null || _b === void 0 ? void 0 : _b.bind(impl); } else { throw new CapacitorException(`"${pluginName}" plugin is not implemented on ${platform}`, ExceptionCode.Unimplemented); } }; const createPluginMethodWrapper = (prop) => { let remove; const wrapper = (...args) => { const p = loadPluginImplementation().then((impl) => { const fn = createPluginMethod(impl, prop); if (fn) { const p2 = fn(...args); remove = p2 === null || p2 === void 0 ? void 0 : p2.remove; return p2; } else { throw new CapacitorException(`"${pluginName}.${prop}()" is not implemented on ${platform}`, ExceptionCode.Unimplemented); } }); if (prop === "addListener") { p.remove = async () => remove(); } return p; }; wrapper.toString = () => `${prop.toString()}() { [capacitor code] }`; Object.defineProperty(wrapper, "name", { value: prop, writable: false, configurable: false }); return wrapper; }; const addListener = createPluginMethodWrapper("addListener"); const removeListener = createPluginMethodWrapper("removeListener"); const addListenerNative = (eventName, callback) => { const call = addListener({ eventName }, callback); const remove = async () => { const callbackId = await call; removeListener({ eventName, callbackId }, callback); }; const p = new Promise((resolve) => call.then(() => resolve({ remove }))); p.remove = async () => { console.warn(`Using addListener() without 'await' is deprecated.`); await remove(); }; return p; }; const proxy = new Proxy({}, { get(_, prop) { switch (prop) { // https://github.com/facebook/react/issues/20030 case "$$typeof": return void 0; case "toJSON": return () => ({}); case "addListener": return pluginHeader ? addListenerNative : addListener; case "removeListener": return removeListener; default: return createPluginMethodWrapper(prop); } } }); Plugins[pluginName] = proxy; registeredPlugins.set(pluginName, { name: pluginName, proxy, platforms: /* @__PURE__ */ new Set([...Object.keys(jsImplementations), ...pluginHeader ? [platform] : []]) }); return proxy; }; if (!cap.convertFileSrc) { cap.convertFileSrc = (filePath) => filePath; } cap.getPlatform = getPlatform; cap.handleError = handleError; cap.isNativePlatform = isNativePlatform; cap.isPluginAvailable = isPluginAvailable; cap.registerPlugin = registerPlugin2; cap.Exception = CapacitorException; cap.DEBUG = !!cap.DEBUG; cap.isLoggingEnabled = !!cap.isLoggingEnabled; return cap; }; initCapacitorGlobal = (win) => win.Capacitor = createCapacitor(win); Capacitor = /* @__PURE__ */ initCapacitorGlobal(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {}); registerPlugin = Capacitor.registerPlugin; WebPlugin = class { constructor() { this.listeners = {}; this.retainedEventArguments = {}; this.windowListeners = {}; } addListener(eventName, listenerFunc) { let firstListener = false; const listeners = this.listeners[eventName]; if (!listeners) { this.listeners[eventName] = []; firstListener = true; } this.listeners[eventName].push(listenerFunc); const windowListener = this.windowListeners[eventName]; if (windowListener && !windowListener.registered) { this.addWindowListener(windowListener); } if (firstListener) { this.sendRetainedArgumentsForEvent(eventName); } const remove = async () => this.removeListener(eventName, listenerFunc); const p = Promise.resolve({ remove }); return p; } async removeAllListeners() { this.listeners = {}; for (const listener in this.windowListeners) { this.removeWindowListener(this.windowListeners[listener]); } this.windowListeners = {}; } notifyListeners(eventName, data, retainUntilConsumed) { const listeners = this.listeners[eventName]; if (!listeners) { if (retainUntilConsumed) { let args = this.retainedEventArguments[eventName]; if (!args) { args = []; } args.push(data); this.retainedEventArguments[eventName] = args; } return; } listeners.forEach((listener) => listener(data)); } hasListeners(eventName) { var _a; return !!((_a = this.listeners[eventName]) === null || _a === void 0 ? void 0 : _a.length); } registerWindowListener(windowEventName, pluginEventName) { this.windowListeners[pluginEventName] = { registered: false, windowEventName, pluginEventName, handler: (event) => { this.notifyListeners(pluginEventName, event); } }; } unimplemented(msg = "not implemented") { return new Capacitor.Exception(msg, ExceptionCode.Unimplemented); } unavailable(msg = "not available") { return new Capacitor.Exception(msg, ExceptionCode.Unavailable); } async removeListener(eventName, listenerFunc) { const listeners = this.listeners[eventName]; if (!listeners) { return; } const index = listeners.indexOf(listenerFunc); this.listeners[eventName].splice(index, 1); if (!this.listeners[eventName].length) { this.removeWindowListener(this.windowListeners[eventName]); } } addWindowListener(handle) { window.addEventListener(handle.windowEventName, handle.handler); handle.registered = true; } removeWindowListener(handle) { if (!handle) { return; } window.removeEventListener(handle.windowEventName, handle.handler); handle.registered = false; } sendRetainedArgumentsForEvent(eventName) { const args = this.retainedEventArguments[eventName]; if (!args) { return; } delete this.retainedEventArguments[eventName]; args.forEach((arg) => { this.notifyListeners(eventName, arg); }); } }; WebView = /* @__PURE__ */ registerPlugin("WebView"); encode = (str) => encodeURIComponent(str).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); decode = (str) => str.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent); CapacitorCookiesPluginWeb = class extends WebPlugin { async getCookies() { const cookies = document.cookie; const cookieMap = {}; cookies.split(";").forEach((cookie) => { if (cookie.length <= 0) return; let [key, value] = cookie.replace(/=/, "CAP_COOKIE").split("CAP_COOKIE"); key = decode(key).trim(); value = decode(value).trim(); cookieMap[key] = value; }); return cookieMap; } async setCookie(options) { try { const encodedKey = encode(options.key); const encodedValue = encode(options.value); const expires = `; expires=${(options.expires || "").replace("expires=", "")}`; const path = (options.path || "/").replace("path=", ""); const domain = options.url != null && options.url.length > 0 ? `domain=${options.url}` : ""; document.cookie = `${encodedKey}=${encodedValue || ""}${expires}; path=${path}; ${domain};`; } catch (error) { return Promise.reject(error); } } async deleteCookie(options) { try { document.cookie = `${options.key}=; Max-Age=0`; } catch (error) { return Promise.reject(error); } } async clearCookies() { try { const cookies = document.cookie.split(";") || []; for (const cookie of cookies) { document.cookie = cookie.replace(/^ +/, "").replace(/=.*/, `=;expires=${(/* @__PURE__ */ new Date()).toUTCString()};path=/`); } } catch (error) { return Promise.reject(error); } } async clearAllCookies() { try { await this.clearCookies(); } catch (error) { return Promise.reject(error); } } }; CapacitorCookies = registerPlugin("CapacitorCookies", { web: () => new CapacitorCookiesPluginWeb() }); readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = () => { const base64String = reader.result; resolve(base64String.indexOf(",") >= 0 ? base64String.split(",")[1] : base64String); }; reader.onerror = (error) => reject(error); reader.readAsDataURL(blob); }); normalizeHttpHeaders = (headers = {}) => { const originalKeys = Object.keys(headers); const loweredKeys = Object.keys(headers).map((k) => k.toLocaleLowerCase()); const normalized = loweredKeys.reduce((acc, key, index) => { acc[key] = headers[originalKeys[index]]; return acc; }, {}); return normalized; }; buildUrlParams = (params, shouldEncode = true) => { if (!params) return null; const output = Object.entries(params).reduce((accumulator, entry) => { const [key, value] = entry; let encodedValue; let item; if (Array.isArray(value)) { item = ""; value.forEach((str) => { encodedValue = shouldEncode ? encodeURIComponent(str) : str; item += `${key}=${encodedValue}&`; }); item.slice(0, -1); } else { encodedValue = shouldEncode ? encodeURIComponent(value) : value; item = `${key}=${encodedValue}`; } return `${accumulator}&${item}`; }, ""); return output.substr(1); }; buildRequestInit = (options, extra = {}) => { const output = Object.assign({ method: options.method || "GET", headers: options.headers }, extra); const headers = normalizeHttpHeaders(options.headers); const type = headers["content-type"] || ""; if (typeof options.data === "string") { output.body = options.data; } else if (type.includes("application/x-www-form-urlencoded")) { const params = new URLSearchParams(); for (const [key, value] of Object.entries(options.data || {})) { params.set(key, value); } output.body = params.toString(); } else if (type.includes("multipart/form-data") || options.data instanceof FormData) { const form = new FormData(); if (options.data instanceof FormData) { options.data.forEach((value, key) => { form.append(key, value); }); } else { for (const key of Object.keys(options.data)) { form.append(key, options.data[key]); } } output.body = form; const headers2 = new Headers(output.headers); headers2.delete("content-type"); output.headers = headers2; } else if (type.includes("application/json") || typeof options.data === "object") { output.body = JSON.stringify(options.data); } return output; }; CapacitorHttpPluginWeb = class extends WebPlugin { /** * Perform an Http request given a set of options * @param options Options to build the HTTP request */ async request(options) { const requestInit = buildRequestInit(options, options.webFetchExtra); const urlParams = buildUrlParams(options.params, options.shouldEncodeUrlParams); const url = urlParams ? `${options.url}?${urlParams}` : options.url; const response = await fetch(url, requestInit); const contentType = response.headers.get("content-type") || ""; let { responseType = "text" } = response.ok ? options : {}; if (contentType.includes("application/json")) { responseType = "json"; } let data; let blob; switch (responseType) { case "arraybuffer": case "blob": blob = await response.blob(); data = await readBlobAsBase64(blob); break; case "json": data = await response.json(); break; case "document": case "text": default: data = await response.text(); } const headers = {}; response.headers.forEach((value, key) => { headers[key] = value; }); return { data, headers, status: response.status, url: response.url }; } /** * Perform an Http GET request given a set of options * @param options Options to build the HTTP request */ async get(options) { return this.request(Object.assign(Object.assign({}, options), { method: "GET" })); } /** * Perform an Http POST request given a set of options * @param options Options to build the HTTP request */ async post(options) { return this.request(Object.assign(Object.assign({}, options), { method: "POST" })); } /** * Perform an Http PUT request given a set of options * @param options Options to build the HTTP request */ async put(options) { return this.request(Object.assign(Object.assign({}, options), { method: "PUT" })); } /** * Perform an Http PATCH request given a set of options * @param options Options to build the HTTP request */ async patch(options) { return this.request(Object.assign(Object.assign({}, options), { method: "PATCH" })); } /** * Perform an Http DELETE request given a set of options * @param options Options to build the HTTP request */ async delete(options) { return this.request(Object.assign(Object.assign({}, options), { method: "DELETE" })); } }; CapacitorHttp = registerPlugin("CapacitorHttp", { web: () => new CapacitorHttpPluginWeb() }); }});
// node_modules/@capacitor/app/dist/esm/web.jsvar web_exports = {};__export(web_exports, { AppWeb: () => AppWeb});var AppWeb;var init_web = __esm({ "node_modules/@capacitor/app/dist/esm/web.js"() { init_dist(); AppWeb = class extends WebPlugin { constructor() { super(); this.handleVisibilityChange = () => { const data = { isActive: document.hidden !== true }; this.notifyListeners("appStateChange", data); if (document.hidden) { this.notifyListeners("pause", null); } else { this.notifyListeners("resume", null); } }; document.addEventListener("visibilitychange", this.handleVisibilityChange, false); } exitApp() { throw this.unimplemented("Not implemented on web."); } async getInfo() { throw this.unimplemented("Not implemented on web."); } async getLaunchUrl() { return { url: "" }; } async getState() { return { isActive: document.hidden !== true }; } async minimizeApp() { throw this.unimplemented("Not implemented on web."); } async toggleBackButtonHandler() { throw this.unimplemented("Not implemented on web."); } }; }});
// node_modules/@capacitor/browser/dist/esm/web.jsvar web_exports2 = {};__export(web_exports2, { Browser: () => Browser, BrowserWeb: () => BrowserWeb});var BrowserWeb, Browser;var init_web2 = __esm({ "node_modules/@capacitor/browser/dist/esm/web.js"() { init_dist(); BrowserWeb = class extends WebPlugin { constructor() { super(); this._lastWindow = null; } async open(options) { this._lastWindow = window.open(options.url, options.windowName || "_blank"); } async close() { return new Promise((resolve, reject) => { if (this._lastWindow != null) { this._lastWindow.close(); this._lastWindow = null; resolve(); } else { reject("No active window to close!"); } }); } }; Browser = new BrowserWeb(); }});
// node_modules/@capacitor/haptics/dist/esm/definitions.jsvar ImpactStyle, NotificationType;var init_definitions = __esm({ "node_modules/@capacitor/haptics/dist/esm/definitions.js"() { (function(ImpactStyle2) { ImpactStyle2["Heavy"] = "HEAVY"; ImpactStyle2["Medium"] = "MEDIUM"; ImpactStyle2["Light"] = "LIGHT"; })(ImpactStyle || (ImpactStyle = {})); (function(NotificationType2) { NotificationType2["Success"] = "SUCCESS"; NotificationType2["Warning"] = "WARNING"; NotificationType2["Error"] = "ERROR"; })(NotificationType || (NotificationType = {})); }});
// node_modules/@capacitor/haptics/dist/esm/web.jsvar web_exports3 = {};__export(web_exports3, { HapticsWeb: () => HapticsWeb});var HapticsWeb;var init_web3 = __esm({ "node_modules/@capacitor/haptics/dist/esm/web.js"() { init_dist(); init_definitions(); HapticsWeb = class extends WebPlugin { constructor() { super(...arguments); this.selectionStarted = false; } async impact(options) { const pattern = this.patternForImpact(options === null || options === void 0 ? void 0 : options.style); this.vibrateWithPattern(pattern); } async notification(options) { const pattern = this.patternForNotification(options === null || options === void 0 ? void 0 : options.type); this.vibrateWithPattern(pattern); } async vibrate(options) { const duration = (options === null || options === void 0 ? void 0 : options.duration) || 300; this.vibrateWithPattern([duration]); } async selectionStart() { this.selectionStarted = true; } async selectionChanged() { if (this.selectionStarted) { this.vibrateWithPattern([70]); } } async selectionEnd() { this.selectionStarted = false; } patternForImpact(style = ImpactStyle.Heavy) { if (style === ImpactStyle.Medium) { return [43]; } else if (style === ImpactStyle.Light) { return [20]; } return [61]; } patternForNotification(type = NotificationType.Success) { if (type === NotificationType.Warning) { return [30, 40, 30, 50, 60]; } else if (type === NotificationType.Error) { return [27, 45, 50]; } return [35, 65, 21]; } vibrateWithPattern(pattern) { if (navigator.vibrate) { navigator.vibrate(pattern); } else { throw this.unavailable("Browser does not support the vibrate API"); } } }; }});
// node_modules/@capacitor/app/dist/esm/index.jsinit_dist();var App = registerPlugin("App", { web: () => Promise.resolve().then(() => (init_web(), web_exports)).then((m) => new m.AppWeb())});
// node_modules/@capacitor/browser/dist/esm/index.jsinit_dist();var Browser2 = registerPlugin("Browser", { web: () => Promise.resolve().then(() => (init_web2(), web_exports2)).then((m) => new m.BrowserWeb())});
// clientLibs/capacitorPlugins.jsinit_dist();
// node_modules/@capacitor/haptics/dist/esm/index.jsinit_dist();init_definitions();var Haptics = registerPlugin("Haptics", { web: () => Promise.resolve().then(() => (init_web3(), web_exports3)).then((m) => new m.HapticsWeb())});
// node_modules/@capacitor/status-bar/dist/esm/index.jsinit_dist();
// node_modules/@capacitor/status-bar/dist/esm/definitions.jsvar Style;(function(Style2) { Style2["Dark"] = "DARK"; Style2["Light"] = "LIGHT"; Style2["Default"] = "DEFAULT";})(Style || (Style = {}));var Animation;(function(Animation2) { Animation2["None"] = "NONE"; Animation2["Slide"] = "SLIDE"; Animation2["Fade"] = "FADE";})(Animation || (Animation = {}));var StatusBarAnimation = Animation;var StatusBarStyle = Style;
// node_modules/@capacitor/status-bar/dist/esm/index.jsvar StatusBar = registerPlugin("StatusBar");export { Animation, App, Browser2 as Browser, Capacitor, CapacitorCookies, CapacitorException, CapacitorHttp, ExceptionCode, Haptics, ImpactStyle, NotificationType, StatusBar, StatusBarAnimation, StatusBarStyle, Style, WebPlugin, WebView, buildRequestInit, registerPlugin};/*! Bundled license information:
@capacitor/core/dist/index.js: (*! Capacitor: https://capacitorjs.com/ - MIT License *)*/