@capacitor/core 6.2.0 → 7.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"capacitor.js","sources":["../build/platforms.js","../build/util.js","../build/runtime.js","../build/global.js","../build/web-plugin.js","../build/core-plugins.js","../build/legacy/legacy-web-plugin-merge.js"],"sourcesContent":["const createCapacitorPlatforms = (win) => {\n const defaultPlatformMap = new Map();\n defaultPlatformMap.set('web', { name: 'web' });\n const capPlatforms = win.CapacitorPlatforms || {\n currentPlatform: { name: 'web' },\n platforms: defaultPlatformMap,\n };\n const addPlatform = (name, platform) => {\n capPlatforms.platforms.set(name, platform);\n };\n const setPlatform = (name) => {\n if (capPlatforms.platforms.has(name)) {\n capPlatforms.currentPlatform = capPlatforms.platforms.get(name);\n }\n };\n capPlatforms.addPlatform = addPlatform;\n capPlatforms.setPlatform = setPlatform;\n return capPlatforms;\n};\nconst initPlatforms = (win) => (win.CapacitorPlatforms = createCapacitorPlatforms(win));\n/**\n * @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead\n */\nexport const CapacitorPlatforms = /*#__PURE__*/ initPlatforms((typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {}));\n/**\n * @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead\n */\nexport const addPlatform = CapacitorPlatforms.addPlatform;\n/**\n * @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead\n */\nexport const setPlatform = CapacitorPlatforms.setPlatform;\n//# sourceMappingURL=platforms.js.map","export var ExceptionCode;\n(function (ExceptionCode) {\n /**\n * API is not implemented.\n *\n * This usually means the API can't be used because it is not implemented for\n * the current platform.\n */\n ExceptionCode[\"Unimplemented\"] = \"UNIMPLEMENTED\";\n /**\n * API is not available.\n *\n * This means the API can't be used right now because:\n * - it is currently missing a prerequisite, such as network connectivity\n * - it requires a particular platform or browser version\n */\n ExceptionCode[\"Unavailable\"] = \"UNAVAILABLE\";\n})(ExceptionCode || (ExceptionCode = {}));\nexport class CapacitorException extends Error {\n constructor(message, code, data) {\n super(message);\n this.message = message;\n this.code = code;\n this.data = data;\n }\n}\nexport const getPlatformId = (win) => {\n var _a, _b;\n if (win === null || win === void 0 ? void 0 : win.androidBridge) {\n return 'android';\n }\n 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) {\n return 'ios';\n }\n else {\n return 'web';\n }\n};\n//# sourceMappingURL=util.js.map","import { CapacitorException, getPlatformId, ExceptionCode } from './util';\nexport const createCapacitor = (win) => {\n var _a, _b, _c, _d, _e;\n const capCustomPlatform = win.CapacitorCustomPlatform || null;\n const cap = win.Capacitor || {};\n const Plugins = (cap.Plugins = cap.Plugins || {});\n /**\n * @deprecated Use `capCustomPlatform` instead, default functions like registerPlugin will function with the new object.\n */\n const capPlatforms = win.CapacitorPlatforms;\n const defaultGetPlatform = () => {\n return capCustomPlatform !== null\n ? capCustomPlatform.name\n : getPlatformId(win);\n };\n const getPlatform = ((_a = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _a === void 0 ? void 0 : _a.getPlatform) || defaultGetPlatform;\n const defaultIsNativePlatform = () => getPlatform() !== 'web';\n const isNativePlatform = ((_b = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _b === void 0 ? void 0 : _b.isNativePlatform) || defaultIsNativePlatform;\n const defaultIsPluginAvailable = (pluginName) => {\n const plugin = registeredPlugins.get(pluginName);\n if (plugin === null || plugin === void 0 ? void 0 : plugin.platforms.has(getPlatform())) {\n // JS implementation available for the current platform.\n return true;\n }\n if (getPluginHeader(pluginName)) {\n // Native implementation available.\n return true;\n }\n return false;\n };\n const isPluginAvailable = ((_c = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _c === void 0 ? void 0 : _c.isPluginAvailable) ||\n defaultIsPluginAvailable;\n const defaultGetPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find(h => h.name === pluginName); };\n const getPluginHeader = ((_d = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _d === void 0 ? void 0 : _d.getPluginHeader) || defaultGetPluginHeader;\n const handleError = (err) => win.console.error(err);\n const pluginMethodNoop = (_target, prop, pluginName) => {\n return Promise.reject(`${pluginName} does not have an implementation of \"${prop}\".`);\n };\n const registeredPlugins = new Map();\n const defaultRegisterPlugin = (pluginName, jsImplementations = {}) => {\n const registeredPlugin = registeredPlugins.get(pluginName);\n if (registeredPlugin) {\n console.warn(`Capacitor plugin \"${pluginName}\" already registered. Cannot register plugins twice.`);\n return registeredPlugin.proxy;\n }\n const platform = getPlatform();\n const pluginHeader = getPluginHeader(pluginName);\n let jsImplementation;\n const loadPluginImplementation = async () => {\n if (!jsImplementation && platform in jsImplementations) {\n jsImplementation =\n typeof jsImplementations[platform] === 'function'\n ? (jsImplementation = await jsImplementations[platform]())\n : (jsImplementation = jsImplementations[platform]);\n }\n else if (capCustomPlatform !== null &&\n !jsImplementation &&\n 'web' in jsImplementations) {\n jsImplementation =\n typeof jsImplementations['web'] === 'function'\n ? (jsImplementation = await jsImplementations['web']())\n : (jsImplementation = jsImplementations['web']);\n }\n return jsImplementation;\n };\n const createPluginMethod = (impl, prop) => {\n var _a, _b;\n if (pluginHeader) {\n const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find(m => prop === m.name);\n if (methodHeader) {\n if (methodHeader.rtype === 'promise') {\n return (options) => cap.nativePromise(pluginName, prop.toString(), options);\n }\n else {\n return (options, callback) => cap.nativeCallback(pluginName, prop.toString(), options, callback);\n }\n }\n else if (impl) {\n return (_a = impl[prop]) === null || _a === void 0 ? void 0 : _a.bind(impl);\n }\n }\n else if (impl) {\n return (_b = impl[prop]) === null || _b === void 0 ? void 0 : _b.bind(impl);\n }\n else {\n throw new CapacitorException(`\"${pluginName}\" plugin is not implemented on ${platform}`, ExceptionCode.Unimplemented);\n }\n };\n const createPluginMethodWrapper = (prop) => {\n let remove;\n const wrapper = (...args) => {\n const p = loadPluginImplementation().then(impl => {\n const fn = createPluginMethod(impl, prop);\n if (fn) {\n const p = fn(...args);\n remove = p === null || p === void 0 ? void 0 : p.remove;\n return p;\n }\n else {\n throw new CapacitorException(`\"${pluginName}.${prop}()\" is not implemented on ${platform}`, ExceptionCode.Unimplemented);\n }\n });\n if (prop === 'addListener') {\n p.remove = async () => remove();\n }\n return p;\n };\n // Some flair ✨\n wrapper.toString = () => `${prop.toString()}() { [capacitor code] }`;\n Object.defineProperty(wrapper, 'name', {\n value: prop,\n writable: false,\n configurable: false,\n });\n return wrapper;\n };\n const addListener = createPluginMethodWrapper('addListener');\n const removeListener = createPluginMethodWrapper('removeListener');\n const addListenerNative = (eventName, callback) => {\n const call = addListener({ eventName }, callback);\n const remove = async () => {\n const callbackId = await call;\n removeListener({\n eventName,\n callbackId,\n }, callback);\n };\n const p = new Promise(resolve => call.then(() => resolve({ remove })));\n p.remove = async () => {\n console.warn(`Using addListener() without 'await' is deprecated.`);\n await remove();\n };\n return p;\n };\n const proxy = new Proxy({}, {\n get(_, prop) {\n switch (prop) {\n // https://github.com/facebook/react/issues/20030\n case '$$typeof':\n return undefined;\n case 'toJSON':\n return () => ({});\n case 'addListener':\n return pluginHeader ? addListenerNative : addListener;\n case 'removeListener':\n return removeListener;\n default:\n return createPluginMethodWrapper(prop);\n }\n },\n });\n Plugins[pluginName] = proxy;\n registeredPlugins.set(pluginName, {\n name: pluginName,\n proxy,\n platforms: new Set([\n ...Object.keys(jsImplementations),\n ...(pluginHeader ? [platform] : []),\n ]),\n });\n return proxy;\n };\n const registerPlugin = ((_e = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _e === void 0 ? void 0 : _e.registerPlugin) || defaultRegisterPlugin;\n // Add in convertFileSrc for web, it will already be available in native context\n if (!cap.convertFileSrc) {\n cap.convertFileSrc = filePath => filePath;\n }\n cap.getPlatform = getPlatform;\n cap.handleError = handleError;\n cap.isNativePlatform = isNativePlatform;\n cap.isPluginAvailable = isPluginAvailable;\n cap.pluginMethodNoop = pluginMethodNoop;\n cap.registerPlugin = registerPlugin;\n cap.Exception = CapacitorException;\n cap.DEBUG = !!cap.DEBUG;\n cap.isLoggingEnabled = !!cap.isLoggingEnabled;\n // Deprecated props\n cap.platform = cap.getPlatform();\n cap.isNative = cap.isNativePlatform();\n return cap;\n};\nexport const initCapacitorGlobal = (win) => (win.Capacitor = createCapacitor(win));\n//# sourceMappingURL=runtime.js.map","import { legacyRegisterWebPlugin } from './legacy/legacy-web-plugin-merge';\nimport { initCapacitorGlobal } from './runtime';\nexport const Capacitor = /*#__PURE__*/ initCapacitorGlobal(typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {});\nexport const registerPlugin = Capacitor.registerPlugin;\n/**\n * @deprecated Provided for backwards compatibility for Capacitor v2 plugins.\n * Capacitor v3 plugins should import the plugin directly. This \"Plugins\"\n * export is deprecated in v3, and will be removed in v4.\n */\nexport const Plugins = Capacitor.Plugins;\n/**\n * Provided for backwards compatibility. Use the registerPlugin() API\n * instead, and provide the web plugin as the \"web\" implmenetation.\n * For example\n *\n * export const Example = registerPlugin('Example', {\n * web: () => import('./web').then(m => new m.Example())\n * })\n *\n * @deprecated Deprecated in v3, will be removed from v4.\n */\nexport const registerWebPlugin = (plugin) => legacyRegisterWebPlugin(Capacitor, plugin);\n//# sourceMappingURL=global.js.map","import { Capacitor } from './global';\nimport { ExceptionCode } from './util';\n/**\n * Base class web plugins should extend.\n */\nexport class WebPlugin {\n constructor(config) {\n this.listeners = {};\n this.retainedEventArguments = {};\n this.windowListeners = {};\n if (config) {\n // TODO: add link to upgrade guide\n console.warn(`Capacitor WebPlugin \"${config.name}\" config object was deprecated in v3 and will be removed in v4.`);\n this.config = config;\n }\n }\n addListener(eventName, listenerFunc) {\n let firstListener = false;\n const listeners = this.listeners[eventName];\n if (!listeners) {\n this.listeners[eventName] = [];\n firstListener = true;\n }\n this.listeners[eventName].push(listenerFunc);\n // If we haven't added a window listener for this event and it requires one,\n // go ahead and add it\n const windowListener = this.windowListeners[eventName];\n if (windowListener && !windowListener.registered) {\n this.addWindowListener(windowListener);\n }\n if (firstListener) {\n this.sendRetainedArgumentsForEvent(eventName);\n }\n const remove = async () => this.removeListener(eventName, listenerFunc);\n const p = Promise.resolve({ remove });\n return p;\n }\n async removeAllListeners() {\n this.listeners = {};\n for (const listener in this.windowListeners) {\n this.removeWindowListener(this.windowListeners[listener]);\n }\n this.windowListeners = {};\n }\n notifyListeners(eventName, data, retainUntilConsumed) {\n const listeners = this.listeners[eventName];\n if (!listeners) {\n if (retainUntilConsumed) {\n let args = this.retainedEventArguments[eventName];\n if (!args) {\n args = [];\n }\n args.push(data);\n this.retainedEventArguments[eventName] = args;\n }\n return;\n }\n listeners.forEach(listener => listener(data));\n }\n hasListeners(eventName) {\n return !!this.listeners[eventName].length;\n }\n registerWindowListener(windowEventName, pluginEventName) {\n this.windowListeners[pluginEventName] = {\n registered: false,\n windowEventName,\n pluginEventName,\n handler: event => {\n this.notifyListeners(pluginEventName, event);\n },\n };\n }\n unimplemented(msg = 'not implemented') {\n return new Capacitor.Exception(msg, ExceptionCode.Unimplemented);\n }\n unavailable(msg = 'not available') {\n return new Capacitor.Exception(msg, ExceptionCode.Unavailable);\n }\n async removeListener(eventName, listenerFunc) {\n const listeners = this.listeners[eventName];\n if (!listeners) {\n return;\n }\n const index = listeners.indexOf(listenerFunc);\n this.listeners[eventName].splice(index, 1);\n // If there are no more listeners for this type of event,\n // remove the window listener\n if (!this.listeners[eventName].length) {\n this.removeWindowListener(this.windowListeners[eventName]);\n }\n }\n addWindowListener(handle) {\n window.addEventListener(handle.windowEventName, handle.handler);\n handle.registered = true;\n }\n removeWindowListener(handle) {\n if (!handle) {\n return;\n }\n window.removeEventListener(handle.windowEventName, handle.handler);\n handle.registered = false;\n }\n sendRetainedArgumentsForEvent(eventName) {\n const args = this.retainedEventArguments[eventName];\n if (!args) {\n return;\n }\n delete this.retainedEventArguments[eventName];\n args.forEach(arg => {\n this.notifyListeners(eventName, arg);\n });\n }\n}\n//# sourceMappingURL=web-plugin.js.map","import { registerPlugin } from './global';\nimport { WebPlugin } from './web-plugin';\nexport const WebView = /*#__PURE__*/ registerPlugin('WebView');\n/******** END WEB VIEW PLUGIN ********/\n/******** COOKIES PLUGIN ********/\n/**\n * Safely web encode a string value (inspired by js-cookie)\n * @param str The string value to encode\n */\nconst encode = (str) => encodeURIComponent(str)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n/**\n * Safely web decode a string value (inspired by js-cookie)\n * @param str The string value to decode\n */\nconst decode = (str) => str.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent);\nexport class CapacitorCookiesPluginWeb extends WebPlugin {\n async getCookies() {\n const cookies = document.cookie;\n const cookieMap = {};\n cookies.split(';').forEach(cookie => {\n if (cookie.length <= 0)\n return;\n // Replace first \"=\" with CAP_COOKIE to prevent splitting on additional \"=\"\n let [key, value] = cookie.replace(/=/, 'CAP_COOKIE').split('CAP_COOKIE');\n key = decode(key).trim();\n value = decode(value).trim();\n cookieMap[key] = value;\n });\n return cookieMap;\n }\n async setCookie(options) {\n try {\n // Safely Encoded Key/Value\n const encodedKey = encode(options.key);\n const encodedValue = encode(options.value);\n // Clean & sanitize options\n const expires = `; expires=${(options.expires || '').replace('expires=', '')}`; // Default is \"; expires=\"\n const path = (options.path || '/').replace('path=', ''); // Default is \"path=/\"\n const domain = options.url != null && options.url.length > 0\n ? `domain=${options.url}`\n : '';\n document.cookie = `${encodedKey}=${encodedValue || ''}${expires}; path=${path}; ${domain};`;\n }\n catch (error) {\n return Promise.reject(error);\n }\n }\n async deleteCookie(options) {\n try {\n document.cookie = `${options.key}=; Max-Age=0`;\n }\n catch (error) {\n return Promise.reject(error);\n }\n }\n async clearCookies() {\n try {\n const cookies = document.cookie.split(';') || [];\n for (const cookie of cookies) {\n document.cookie = cookie\n .replace(/^ +/, '')\n .replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);\n }\n }\n catch (error) {\n return Promise.reject(error);\n }\n }\n async clearAllCookies() {\n try {\n await this.clearCookies();\n }\n catch (error) {\n return Promise.reject(error);\n }\n }\n}\nexport const CapacitorCookies = registerPlugin('CapacitorCookies', {\n web: () => new CapacitorCookiesPluginWeb(),\n});\n// UTILITY FUNCTIONS\n/**\n * Read in a Blob value and return it as a base64 string\n * @param blob The blob value to convert to a base64 string\n */\nexport const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => {\n const base64String = reader.result;\n // remove prefix \"data:application/pdf;base64,\"\n resolve(base64String.indexOf(',') >= 0\n ? base64String.split(',')[1]\n : base64String);\n };\n reader.onerror = (error) => reject(error);\n reader.readAsDataURL(blob);\n});\n/**\n * Normalize an HttpHeaders map by lowercasing all of the values\n * @param headers The HttpHeaders object to normalize\n */\nconst normalizeHttpHeaders = (headers = {}) => {\n const originalKeys = Object.keys(headers);\n const loweredKeys = Object.keys(headers).map(k => k.toLocaleLowerCase());\n const normalized = loweredKeys.reduce((acc, key, index) => {\n acc[key] = headers[originalKeys[index]];\n return acc;\n }, {});\n return normalized;\n};\n/**\n * Builds a string of url parameters that\n * @param params A map of url parameters\n * @param shouldEncode true if you should encodeURIComponent() the values (true by default)\n */\nconst buildUrlParams = (params, shouldEncode = true) => {\n if (!params)\n return null;\n const output = Object.entries(params).reduce((accumulator, entry) => {\n const [key, value] = entry;\n let encodedValue;\n let item;\n if (Array.isArray(value)) {\n item = '';\n value.forEach(str => {\n encodedValue = shouldEncode ? encodeURIComponent(str) : str;\n item += `${key}=${encodedValue}&`;\n });\n // last character will always be \"&\" so slice it off\n item.slice(0, -1);\n }\n else {\n encodedValue = shouldEncode ? encodeURIComponent(value) : value;\n item = `${key}=${encodedValue}`;\n }\n return `${accumulator}&${item}`;\n }, '');\n // Remove initial \"&\" from the reduce\n return output.substr(1);\n};\n/**\n * Build the RequestInit object based on the options passed into the initial request\n * @param options The Http plugin options\n * @param extra Any extra RequestInit values\n */\nexport const buildRequestInit = (options, extra = {}) => {\n const output = Object.assign({ method: options.method || 'GET', headers: options.headers }, extra);\n // Get the content-type\n const headers = normalizeHttpHeaders(options.headers);\n const type = headers['content-type'] || '';\n // If body is already a string, then pass it through as-is.\n if (typeof options.data === 'string') {\n output.body = options.data;\n }\n // Build request initializers based off of content-type\n else if (type.includes('application/x-www-form-urlencoded')) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(options.data || {})) {\n params.set(key, value);\n }\n output.body = params.toString();\n }\n else if (type.includes('multipart/form-data') ||\n options.data instanceof FormData) {\n const form = new FormData();\n if (options.data instanceof FormData) {\n options.data.forEach((value, key) => {\n form.append(key, value);\n });\n }\n else {\n for (const key of Object.keys(options.data)) {\n form.append(key, options.data[key]);\n }\n }\n output.body = form;\n const headers = new Headers(output.headers);\n headers.delete('content-type'); // content-type will be set by `window.fetch` to includy boundary\n output.headers = headers;\n }\n else if (type.includes('application/json') ||\n typeof options.data === 'object') {\n output.body = JSON.stringify(options.data);\n }\n return output;\n};\n// WEB IMPLEMENTATION\nexport class CapacitorHttpPluginWeb extends WebPlugin {\n /**\n * Perform an Http request given a set of options\n * @param options Options to build the HTTP request\n */\n async request(options) {\n const requestInit = buildRequestInit(options, options.webFetchExtra);\n const urlParams = buildUrlParams(options.params, options.shouldEncodeUrlParams);\n const url = urlParams ? `${options.url}?${urlParams}` : options.url;\n const response = await fetch(url, requestInit);\n const contentType = response.headers.get('content-type') || '';\n // Default to 'text' responseType so no parsing happens\n let { responseType = 'text' } = response.ok ? options : {};\n // If the response content-type is json, force the response to be json\n if (contentType.includes('application/json')) {\n responseType = 'json';\n }\n let data;\n let blob;\n switch (responseType) {\n case 'arraybuffer':\n case 'blob':\n blob = await response.blob();\n data = await readBlobAsBase64(blob);\n break;\n case 'json':\n data = await response.json();\n break;\n case 'document':\n case 'text':\n default:\n data = await response.text();\n }\n // Convert fetch headers to Capacitor HttpHeaders\n const headers = {};\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n return {\n data,\n headers,\n status: response.status,\n url: response.url,\n };\n }\n /**\n * Perform an Http GET request given a set of options\n * @param options Options to build the HTTP request\n */\n async get(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'GET' }));\n }\n /**\n * Perform an Http POST request given a set of options\n * @param options Options to build the HTTP request\n */\n async post(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'POST' }));\n }\n /**\n * Perform an Http PUT request given a set of options\n * @param options Options to build the HTTP request\n */\n async put(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'PUT' }));\n }\n /**\n * Perform an Http PATCH request given a set of options\n * @param options Options to build the HTTP request\n */\n async patch(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'PATCH' }));\n }\n /**\n * Perform an Http DELETE request given a set of options\n * @param options Options to build the HTTP request\n */\n async delete(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'DELETE' }));\n }\n}\nexport const CapacitorHttp = registerPlugin('CapacitorHttp', {\n web: () => new CapacitorHttpPluginWeb(),\n});\n/******** END HTTP PLUGIN ********/\n//# sourceMappingURL=core-plugins.js.map","export const legacyRegisterWebPlugin = (cap, webPlugin) => {\n var _a;\n const config = webPlugin.config;\n const Plugins = cap.Plugins;\n if (!(config === null || config === void 0 ? void 0 : config.name)) {\n // TODO: add link to upgrade guide\n throw new Error(`Capacitor WebPlugin is using the deprecated \"registerWebPlugin()\" function, but without the config. Please use \"registerPlugin()\" instead to register this web plugin.\"`);\n }\n // TODO: add link to upgrade guide\n console.warn(`Capacitor plugin \"${config.name}\" is using the deprecated \"registerWebPlugin()\" function`);\n if (!Plugins[config.name] || ((_a = config === null || config === void 0 ? void 0 : config.platforms) === null || _a === void 0 ? void 0 : _a.includes(cap.getPlatform()))) {\n // Add the web plugin into the plugins registry if there already isn't\n // an existing one. If it doesn't already exist, that means\n // there's no existing native implementation for it.\n // - OR -\n // If we already have a plugin registered (meaning it was defined in the native layer),\n // then we should only overwrite it if the corresponding web plugin activates on\n // a certain platform. For example: Geolocation uses the WebPlugin on Android but not iOS\n Plugins[config.name] = webPlugin;\n }\n};\n//# sourceMappingURL=legacy-web-plugin-merge.js.map"],"names":["CapacitorPlatforms","win","defaultPlatformMap","Map","set","name","capPlatforms","currentPlatform","platforms","addPlatform","platform","setPlatform","has","get","createCapacitorPlatforms","initPlatforms","globalThis","self","window","global","ExceptionCode","exports","CapacitorException","Error","constructor","message","code","data","super","this","createCapacitor","_a","_b","_c","_d","_e","capCustomPlatform","CapacitorCustomPlatform","cap","Capacitor","Plugins","getPlatform","androidBridge","webkit","messageHandlers","bridge","getPlatformId","isNativePlatform","isPluginAvailable","pluginName","plugin","registeredPlugins","getPluginHeader","PluginHeaders","find","h","registerPlugin","jsImplementations","registeredPlugin","console","warn","proxy","pluginHeader","jsImplementation","createPluginMethodWrapper","prop","remove","wrapper","args","p","async","loadPluginImplementation","then","impl","fn","bind","Unimplemented","methodHeader","methods","m","rtype","options","nativePromise","toString","callback","nativeCallback","createPluginMethod","Object","defineProperty","value","writable","configurable","addListener","removeListener","addListenerNative","eventName","call","callbackId","Promise","resolve","Proxy","_","Set","keys","convertFileSrc","filePath","handleError","err","error","pluginMethodNoop","_target","reject","Exception","DEBUG","isLoggingEnabled","isNative","initCapacitorGlobal","WebPlugin","config","listeners","retainedEventArguments","windowListeners","listenerFunc","firstListener","push","windowListener","registered","addWindowListener","sendRetainedArgumentsForEvent","removeAllListeners","listener","removeWindowListener","notifyListeners","retainUntilConsumed","forEach","hasListeners","length","registerWindowListener","windowEventName","pluginEventName","handler","event","unimplemented","msg","unavailable","Unavailable","index","indexOf","splice","handle","addEventListener","removeEventListener","arg","WebView","encode","str","encodeURIComponent","replace","decodeURIComponent","escape","decode","CapacitorCookiesPluginWeb","getCookies","cookies","document","cookie","cookieMap","split","key","trim","setCookie","encodedKey","encodedValue","expires","path","domain","url","deleteCookie","clearCookies","Date","toUTCString","clearAllCookies","CapacitorCookies","web","buildRequestInit","extra","output","assign","method","headers","type","originalKeys","map","k","toLocaleLowerCase","reduce","acc","normalizeHttpHeaders","body","includes","params","URLSearchParams","entries","FormData","form","append","Headers","delete","JSON","stringify","CapacitorHttpPluginWeb","request","requestInit","webFetchExtra","urlParams","shouldEncode","accumulator","entry","item","Array","isArray","slice","substr","buildUrlParams","shouldEncodeUrlParams","response","fetch","contentType","blob","responseType","ok","reader","FileReader","onload","base64String","result","onerror","readAsDataURL","readBlobAsBase64","json","text","status","post","put","patch","CapacitorHttp","webPlugin","legacyRegisterWebPlugin"],"mappings":";8CAAA,MAuBaA,EAJS,CAACC,GAASA,EAAID,mBAnBH,CAACC,IAC9B,MAAMC,EAAqB,IAAIC,IAC/BD,EAAmBE,IAAI,MAAO,CAAEC,KAAM,QACtC,MAAMC,EAAeL,EAAID,oBAAsB,CAC3CO,gBAAiB,CAAEF,KAAM,OACzBG,UAAWN,GAYf,OAFAI,EAAaG,YARO,CAACJ,EAAMK,KACvBJ,EAAaE,UAAUJ,IAAIC,EAAMK,EAAS,EAQ9CJ,EAAaK,YANQN,IACbC,EAAaE,UAAUI,IAAIP,KAC3BC,EAAaC,gBAAkBD,EAAaE,UAAUK,IAAIR,GAC7D,EAIEC,CAAY,EAEkCQ,CAAyBb,GAIlCc,CAAqC,oBAAfC,WAChEA,WACgB,oBAATC,KACHA,KACkB,oBAAXC,OACHA,OACkB,oBAAXC,OACHA,OACA,IAILV,EAAcT,EAAmBS,YAIjCE,EAAcX,EAAmBW,YCtC9C,IAAWS,EADcC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AQ5H,OAAOoG,OAAOpG,OAAOoG,OAAO,CAAE,EAAE1G,GAAU,CAAE2G,OAAQ,UAC3E,CAKD,YAAM,CAAO3G,GACT,OAAOpD,KAAKsL,QAAQ5H,OAAOoG,OAAOpG,OAAOoG,OAAO,CAAE,EAAE1G,GAAU,CAAE2G,OAAQ,WAC3E,EAEO,MAACyD,EAAgB7L,EAAe,gBAAiB,CACzD+H,IAAK,IAAM,IAAI2B,gOFlPehK,GG7BK,EAACZ,EAAKgN,KACzC,IAAIvN,EACJ,MAAMuF,EAASgI,EAAUhI,OACnB9E,EAAUF,EAAIE,QACpB,KAAM8E,aAAuC,EAASA,EAAOjH,MAEzD,MAAM,IAAIkB,MAAM,2KAGpBoC,QAAQC,KAAK,qBAAqB0D,EAAOjH,gEACpCmC,EAAQ8E,EAAOjH,SAAsF,QAA3E0B,EAAKuF,aAAuC,EAASA,EAAO9G,iBAA8B,IAAPuB,OAAgB,EAASA,EAAGwK,SAASjK,EAAIG,kBAQvJD,EAAQ8E,EAAOjH,MAAQiP,EAC1B,EHUwCC,CAAwBhN,EAAWW"}
1
+ {"version":3,"file":"capacitor.js","sources":["../build/platforms.js","../build/util.js","../build/runtime.js","../build/global.js","../build/web-plugin.js","../build/core-plugins.js"],"sourcesContent":["const createCapacitorPlatforms = (win) => {\n const defaultPlatformMap = new Map();\n defaultPlatformMap.set('web', { name: 'web' });\n const capPlatforms = win.CapacitorPlatforms || {\n currentPlatform: { name: 'web' },\n platforms: defaultPlatformMap,\n };\n const addPlatform = (name, platform) => {\n capPlatforms.platforms.set(name, platform);\n };\n const setPlatform = (name) => {\n if (capPlatforms.platforms.has(name)) {\n capPlatforms.currentPlatform = capPlatforms.platforms.get(name);\n }\n };\n capPlatforms.addPlatform = addPlatform;\n capPlatforms.setPlatform = setPlatform;\n return capPlatforms;\n};\nconst initPlatforms = (win) => (win.CapacitorPlatforms = createCapacitorPlatforms(win));\n/**\n * @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead\n */\nexport const CapacitorPlatforms = /*#__PURE__*/ initPlatforms((typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {}));\n/**\n * @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead\n */\nexport const addPlatform = CapacitorPlatforms.addPlatform;\n/**\n * @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead\n */\nexport const setPlatform = CapacitorPlatforms.setPlatform;\n//# sourceMappingURL=platforms.js.map","export var ExceptionCode;\n(function (ExceptionCode) {\n /**\n * API is not implemented.\n *\n * This usually means the API can't be used because it is not implemented for\n * the current platform.\n */\n ExceptionCode[\"Unimplemented\"] = \"UNIMPLEMENTED\";\n /**\n * API is not available.\n *\n * This means the API can't be used right now because:\n * - it is currently missing a prerequisite, such as network connectivity\n * - it requires a particular platform or browser version\n */\n ExceptionCode[\"Unavailable\"] = \"UNAVAILABLE\";\n})(ExceptionCode || (ExceptionCode = {}));\nexport class CapacitorException extends Error {\n constructor(message, code, data) {\n super(message);\n this.message = message;\n this.code = code;\n this.data = data;\n }\n}\nexport const getPlatformId = (win) => {\n var _a, _b;\n if (win === null || win === void 0 ? void 0 : win.androidBridge) {\n return 'android';\n }\n 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) {\n return 'ios';\n }\n else {\n return 'web';\n }\n};\n//# sourceMappingURL=util.js.map","import { CapacitorException, getPlatformId, ExceptionCode } from './util';\nexport const createCapacitor = (win) => {\n var _a, _b, _c, _d, _e;\n const capCustomPlatform = win.CapacitorCustomPlatform || null;\n const cap = win.Capacitor || {};\n const Plugins = (cap.Plugins = cap.Plugins || {});\n /**\n * @deprecated Use `capCustomPlatform` instead, default functions like registerPlugin will function with the new object.\n */\n const capPlatforms = win.CapacitorPlatforms;\n const defaultGetPlatform = () => {\n return capCustomPlatform !== null ? capCustomPlatform.name : getPlatformId(win);\n };\n const getPlatform = ((_a = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _a === void 0 ? void 0 : _a.getPlatform) || defaultGetPlatform;\n const defaultIsNativePlatform = () => getPlatform() !== 'web';\n const isNativePlatform = ((_b = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _b === void 0 ? void 0 : _b.isNativePlatform) || defaultIsNativePlatform;\n const defaultIsPluginAvailable = (pluginName) => {\n const plugin = registeredPlugins.get(pluginName);\n if (plugin === null || plugin === void 0 ? void 0 : plugin.platforms.has(getPlatform())) {\n // JS implementation available for the current platform.\n return true;\n }\n if (getPluginHeader(pluginName)) {\n // Native implementation available.\n return true;\n }\n return false;\n };\n const isPluginAvailable = ((_c = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _c === void 0 ? void 0 : _c.isPluginAvailable) || defaultIsPluginAvailable;\n const defaultGetPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find((h) => h.name === pluginName); };\n const getPluginHeader = ((_d = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _d === void 0 ? void 0 : _d.getPluginHeader) || defaultGetPluginHeader;\n const handleError = (err) => win.console.error(err);\n const registeredPlugins = new Map();\n const defaultRegisterPlugin = (pluginName, jsImplementations = {}) => {\n const registeredPlugin = registeredPlugins.get(pluginName);\n if (registeredPlugin) {\n console.warn(`Capacitor plugin \"${pluginName}\" already registered. Cannot register plugins twice.`);\n return registeredPlugin.proxy;\n }\n const platform = getPlatform();\n const pluginHeader = getPluginHeader(pluginName);\n let jsImplementation;\n const loadPluginImplementation = async () => {\n if (!jsImplementation && platform in jsImplementations) {\n jsImplementation =\n typeof jsImplementations[platform] === 'function'\n ? (jsImplementation = await jsImplementations[platform]())\n : (jsImplementation = jsImplementations[platform]);\n }\n else if (capCustomPlatform !== null && !jsImplementation && 'web' in jsImplementations) {\n jsImplementation =\n typeof jsImplementations['web'] === 'function'\n ? (jsImplementation = await jsImplementations['web']())\n : (jsImplementation = jsImplementations['web']);\n }\n return jsImplementation;\n };\n const createPluginMethod = (impl, prop) => {\n var _a, _b;\n if (pluginHeader) {\n const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find((m) => prop === m.name);\n if (methodHeader) {\n if (methodHeader.rtype === 'promise') {\n return (options) => cap.nativePromise(pluginName, prop.toString(), options);\n }\n else {\n return (options, callback) => cap.nativeCallback(pluginName, prop.toString(), options, callback);\n }\n }\n else if (impl) {\n return (_a = impl[prop]) === null || _a === void 0 ? void 0 : _a.bind(impl);\n }\n }\n else if (impl) {\n return (_b = impl[prop]) === null || _b === void 0 ? void 0 : _b.bind(impl);\n }\n else {\n throw new CapacitorException(`\"${pluginName}\" plugin is not implemented on ${platform}`, ExceptionCode.Unimplemented);\n }\n };\n const createPluginMethodWrapper = (prop) => {\n let remove;\n const wrapper = (...args) => {\n const p = loadPluginImplementation().then((impl) => {\n const fn = createPluginMethod(impl, prop);\n if (fn) {\n const p = fn(...args);\n remove = p === null || p === void 0 ? void 0 : p.remove;\n return p;\n }\n else {\n throw new CapacitorException(`\"${pluginName}.${prop}()\" is not implemented on ${platform}`, ExceptionCode.Unimplemented);\n }\n });\n if (prop === 'addListener') {\n p.remove = async () => remove();\n }\n return p;\n };\n // Some flair ✨\n wrapper.toString = () => `${prop.toString()}() { [capacitor code] }`;\n Object.defineProperty(wrapper, 'name', {\n value: prop,\n writable: false,\n configurable: false,\n });\n return wrapper;\n };\n const addListener = createPluginMethodWrapper('addListener');\n const removeListener = createPluginMethodWrapper('removeListener');\n const addListenerNative = (eventName, callback) => {\n const call = addListener({ eventName }, callback);\n const remove = async () => {\n const callbackId = await call;\n removeListener({\n eventName,\n callbackId,\n }, callback);\n };\n const p = new Promise((resolve) => call.then(() => resolve({ remove })));\n p.remove = async () => {\n console.warn(`Using addListener() without 'await' is deprecated.`);\n await remove();\n };\n return p;\n };\n const proxy = new Proxy({}, {\n get(_, prop) {\n switch (prop) {\n // https://github.com/facebook/react/issues/20030\n case '$$typeof':\n return undefined;\n case 'toJSON':\n return () => ({});\n case 'addListener':\n return pluginHeader ? addListenerNative : addListener;\n case 'removeListener':\n return removeListener;\n default:\n return createPluginMethodWrapper(prop);\n }\n },\n });\n Plugins[pluginName] = proxy;\n registeredPlugins.set(pluginName, {\n name: pluginName,\n proxy,\n platforms: new Set([...Object.keys(jsImplementations), ...(pluginHeader ? [platform] : [])]),\n });\n return proxy;\n };\n const registerPlugin = ((_e = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _e === void 0 ? void 0 : _e.registerPlugin) || defaultRegisterPlugin;\n // Add in convertFileSrc for web, it will already be available in native context\n if (!cap.convertFileSrc) {\n cap.convertFileSrc = (filePath) => filePath;\n }\n cap.getPlatform = getPlatform;\n cap.handleError = handleError;\n cap.isNativePlatform = isNativePlatform;\n cap.isPluginAvailable = isPluginAvailable;\n cap.registerPlugin = registerPlugin;\n cap.Exception = CapacitorException;\n cap.DEBUG = !!cap.DEBUG;\n cap.isLoggingEnabled = !!cap.isLoggingEnabled;\n return cap;\n};\nexport const initCapacitorGlobal = (win) => (win.Capacitor = createCapacitor(win));\n//# sourceMappingURL=runtime.js.map","import { initCapacitorGlobal } from './runtime';\nexport const Capacitor = /*#__PURE__*/ initCapacitorGlobal(typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {});\nexport const registerPlugin = Capacitor.registerPlugin;\n//# sourceMappingURL=global.js.map","import { Capacitor } from './global';\nimport { ExceptionCode } from './util';\n/**\n * Base class web plugins should extend.\n */\nexport class WebPlugin {\n constructor() {\n this.listeners = {};\n this.retainedEventArguments = {};\n this.windowListeners = {};\n }\n addListener(eventName, listenerFunc) {\n let firstListener = false;\n const listeners = this.listeners[eventName];\n if (!listeners) {\n this.listeners[eventName] = [];\n firstListener = true;\n }\n this.listeners[eventName].push(listenerFunc);\n // If we haven't added a window listener for this event and it requires one,\n // go ahead and add it\n const windowListener = this.windowListeners[eventName];\n if (windowListener && !windowListener.registered) {\n this.addWindowListener(windowListener);\n }\n if (firstListener) {\n this.sendRetainedArgumentsForEvent(eventName);\n }\n const remove = async () => this.removeListener(eventName, listenerFunc);\n const p = Promise.resolve({ remove });\n return p;\n }\n async removeAllListeners() {\n this.listeners = {};\n for (const listener in this.windowListeners) {\n this.removeWindowListener(this.windowListeners[listener]);\n }\n this.windowListeners = {};\n }\n notifyListeners(eventName, data, retainUntilConsumed) {\n const listeners = this.listeners[eventName];\n if (!listeners) {\n if (retainUntilConsumed) {\n let args = this.retainedEventArguments[eventName];\n if (!args) {\n args = [];\n }\n args.push(data);\n this.retainedEventArguments[eventName] = args;\n }\n return;\n }\n listeners.forEach((listener) => listener(data));\n }\n hasListeners(eventName) {\n return !!this.listeners[eventName].length;\n }\n registerWindowListener(windowEventName, pluginEventName) {\n this.windowListeners[pluginEventName] = {\n registered: false,\n windowEventName,\n pluginEventName,\n handler: (event) => {\n this.notifyListeners(pluginEventName, event);\n },\n };\n }\n unimplemented(msg = 'not implemented') {\n return new Capacitor.Exception(msg, ExceptionCode.Unimplemented);\n }\n unavailable(msg = 'not available') {\n return new Capacitor.Exception(msg, ExceptionCode.Unavailable);\n }\n async removeListener(eventName, listenerFunc) {\n const listeners = this.listeners[eventName];\n if (!listeners) {\n return;\n }\n const index = listeners.indexOf(listenerFunc);\n this.listeners[eventName].splice(index, 1);\n // If there are no more listeners for this type of event,\n // remove the window listener\n if (!this.listeners[eventName].length) {\n this.removeWindowListener(this.windowListeners[eventName]);\n }\n }\n addWindowListener(handle) {\n window.addEventListener(handle.windowEventName, handle.handler);\n handle.registered = true;\n }\n removeWindowListener(handle) {\n if (!handle) {\n return;\n }\n window.removeEventListener(handle.windowEventName, handle.handler);\n handle.registered = false;\n }\n sendRetainedArgumentsForEvent(eventName) {\n const args = this.retainedEventArguments[eventName];\n if (!args) {\n return;\n }\n delete this.retainedEventArguments[eventName];\n args.forEach((arg) => {\n this.notifyListeners(eventName, arg);\n });\n }\n}\n//# sourceMappingURL=web-plugin.js.map","import { registerPlugin } from './global';\nimport { WebPlugin } from './web-plugin';\nexport const WebView = /*#__PURE__*/ registerPlugin('WebView');\n/******** END WEB VIEW PLUGIN ********/\n/******** COOKIES PLUGIN ********/\n/**\n * Safely web encode a string value (inspired by js-cookie)\n * @param str The string value to encode\n */\nconst encode = (str) => encodeURIComponent(str)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n/**\n * Safely web decode a string value (inspired by js-cookie)\n * @param str The string value to decode\n */\nconst decode = (str) => str.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent);\nexport class CapacitorCookiesPluginWeb extends WebPlugin {\n async getCookies() {\n const cookies = document.cookie;\n const cookieMap = {};\n cookies.split(';').forEach((cookie) => {\n if (cookie.length <= 0)\n return;\n // Replace first \"=\" with CAP_COOKIE to prevent splitting on additional \"=\"\n let [key, value] = cookie.replace(/=/, 'CAP_COOKIE').split('CAP_COOKIE');\n key = decode(key).trim();\n value = decode(value).trim();\n cookieMap[key] = value;\n });\n return cookieMap;\n }\n async setCookie(options) {\n try {\n // Safely Encoded Key/Value\n const encodedKey = encode(options.key);\n const encodedValue = encode(options.value);\n // Clean & sanitize options\n const expires = `; expires=${(options.expires || '').replace('expires=', '')}`; // Default is \"; expires=\"\n const path = (options.path || '/').replace('path=', ''); // Default is \"path=/\"\n const domain = options.url != null && options.url.length > 0 ? `domain=${options.url}` : '';\n document.cookie = `${encodedKey}=${encodedValue || ''}${expires}; path=${path}; ${domain};`;\n }\n catch (error) {\n return Promise.reject(error);\n }\n }\n async deleteCookie(options) {\n try {\n document.cookie = `${options.key}=; Max-Age=0`;\n }\n catch (error) {\n return Promise.reject(error);\n }\n }\n async clearCookies() {\n try {\n const cookies = document.cookie.split(';') || [];\n for (const cookie of cookies) {\n document.cookie = cookie.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);\n }\n }\n catch (error) {\n return Promise.reject(error);\n }\n }\n async clearAllCookies() {\n try {\n await this.clearCookies();\n }\n catch (error) {\n return Promise.reject(error);\n }\n }\n}\nexport const CapacitorCookies = registerPlugin('CapacitorCookies', {\n web: () => new CapacitorCookiesPluginWeb(),\n});\n// UTILITY FUNCTIONS\n/**\n * Read in a Blob value and return it as a base64 string\n * @param blob The blob value to convert to a base64 string\n */\nexport const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => {\n const base64String = reader.result;\n // remove prefix \"data:application/pdf;base64,\"\n resolve(base64String.indexOf(',') >= 0 ? base64String.split(',')[1] : base64String);\n };\n reader.onerror = (error) => reject(error);\n reader.readAsDataURL(blob);\n});\n/**\n * Normalize an HttpHeaders map by lowercasing all of the values\n * @param headers The HttpHeaders object to normalize\n */\nconst normalizeHttpHeaders = (headers = {}) => {\n const originalKeys = Object.keys(headers);\n const loweredKeys = Object.keys(headers).map((k) => k.toLocaleLowerCase());\n const normalized = loweredKeys.reduce((acc, key, index) => {\n acc[key] = headers[originalKeys[index]];\n return acc;\n }, {});\n return normalized;\n};\n/**\n * Builds a string of url parameters that\n * @param params A map of url parameters\n * @param shouldEncode true if you should encodeURIComponent() the values (true by default)\n */\nconst buildUrlParams = (params, shouldEncode = true) => {\n if (!params)\n return null;\n const output = Object.entries(params).reduce((accumulator, entry) => {\n const [key, value] = entry;\n let encodedValue;\n let item;\n if (Array.isArray(value)) {\n item = '';\n value.forEach((str) => {\n encodedValue = shouldEncode ? encodeURIComponent(str) : str;\n item += `${key}=${encodedValue}&`;\n });\n // last character will always be \"&\" so slice it off\n item.slice(0, -1);\n }\n else {\n encodedValue = shouldEncode ? encodeURIComponent(value) : value;\n item = `${key}=${encodedValue}`;\n }\n return `${accumulator}&${item}`;\n }, '');\n // Remove initial \"&\" from the reduce\n return output.substr(1);\n};\n/**\n * Build the RequestInit object based on the options passed into the initial request\n * @param options The Http plugin options\n * @param extra Any extra RequestInit values\n */\nexport const buildRequestInit = (options, extra = {}) => {\n const output = Object.assign({ method: options.method || 'GET', headers: options.headers }, extra);\n // Get the content-type\n const headers = normalizeHttpHeaders(options.headers);\n const type = headers['content-type'] || '';\n // If body is already a string, then pass it through as-is.\n if (typeof options.data === 'string') {\n output.body = options.data;\n }\n // Build request initializers based off of content-type\n else if (type.includes('application/x-www-form-urlencoded')) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(options.data || {})) {\n params.set(key, value);\n }\n output.body = params.toString();\n }\n else if (type.includes('multipart/form-data') || options.data instanceof FormData) {\n const form = new FormData();\n if (options.data instanceof FormData) {\n options.data.forEach((value, key) => {\n form.append(key, value);\n });\n }\n else {\n for (const key of Object.keys(options.data)) {\n form.append(key, options.data[key]);\n }\n }\n output.body = form;\n const headers = new Headers(output.headers);\n headers.delete('content-type'); // content-type will be set by `window.fetch` to includy boundary\n output.headers = headers;\n }\n else if (type.includes('application/json') || typeof options.data === 'object') {\n output.body = JSON.stringify(options.data);\n }\n return output;\n};\n// WEB IMPLEMENTATION\nexport class CapacitorHttpPluginWeb extends WebPlugin {\n /**\n * Perform an Http request given a set of options\n * @param options Options to build the HTTP request\n */\n async request(options) {\n const requestInit = buildRequestInit(options, options.webFetchExtra);\n const urlParams = buildUrlParams(options.params, options.shouldEncodeUrlParams);\n const url = urlParams ? `${options.url}?${urlParams}` : options.url;\n const response = await fetch(url, requestInit);\n const contentType = response.headers.get('content-type') || '';\n // Default to 'text' responseType so no parsing happens\n let { responseType = 'text' } = response.ok ? options : {};\n // If the response content-type is json, force the response to be json\n if (contentType.includes('application/json')) {\n responseType = 'json';\n }\n let data;\n let blob;\n switch (responseType) {\n case 'arraybuffer':\n case 'blob':\n blob = await response.blob();\n data = await readBlobAsBase64(blob);\n break;\n case 'json':\n data = await response.json();\n break;\n case 'document':\n case 'text':\n default:\n data = await response.text();\n }\n // Convert fetch headers to Capacitor HttpHeaders\n const headers = {};\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n return {\n data,\n headers,\n status: response.status,\n url: response.url,\n };\n }\n /**\n * Perform an Http GET request given a set of options\n * @param options Options to build the HTTP request\n */\n async get(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'GET' }));\n }\n /**\n * Perform an Http POST request given a set of options\n * @param options Options to build the HTTP request\n */\n async post(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'POST' }));\n }\n /**\n * Perform an Http PUT request given a set of options\n * @param options Options to build the HTTP request\n */\n async put(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'PUT' }));\n }\n /**\n * Perform an Http PATCH request given a set of options\n * @param options Options to build the HTTP request\n */\n async patch(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'PATCH' }));\n }\n /**\n * Perform an Http DELETE request given a set of options\n * @param options Options to build the HTTP request\n */\n async delete(options) {\n return this.request(Object.assign(Object.assign({}, options), { method: 'DELETE' }));\n }\n}\nexport const CapacitorHttp = registerPlugin('CapacitorHttp', {\n web: () => new CapacitorHttpPluginWeb(),\n});\n/******** END HTTP PLUGIN ********/\n//# sourceMappingURL=core-plugins.js.map"],"names":["CapacitorPlatforms","win","defaultPlatformMap","Map","set","name","capPlatforms","currentPlatform","platforms","addPlatform","platform","setPlatform","has","get","createCapacitorPlatforms","initPlatforms","globalThis","self","window","global","ExceptionCode","exports","CapacitorException","Error","constructor","message","code","data","super","this","createCapacitor","_a","_b","_c","_d","_e","capCustomPlatform","CapacitorCustomPlatform","cap","Capacitor","Plugins","getPlatform","androidBridge","webkit","messageHandlers","bridge","getPlatformId","isNativePlatform","isPluginAvailable","pluginName","plugin","registeredPlugins","getPluginHeader","PluginHeaders","find","h","registerPlugin","jsImplementations","registeredPlugin","console","warn","proxy","pluginHeader","jsImplementation","createPluginMethodWrapper","prop","remove","wrapper","args","p","async","loadPluginImplementation","then","impl","fn","bind","Unimplemented","methodHeader","methods","m","rtype","options","nativePromise","toString","callback","nativeCallback","createPluginMethod","Object","defineProperty","value","writable","configurable","addListener","removeListener","addListenerNative","eventName","call","callbackId","Promise","resolve","Proxy","_","Set","keys","convertFileSrc","filePath","handleError","err","error","Exception","DEBUG","isLoggingEnabled","initCapacitorGlobal","WebPlugin","listeners","retainedEventArguments","windowListeners","listenerFunc","firstListener","push","windowListener","registered","addWindowListener","sendRetainedArgumentsForEvent","removeAllListeners","listener","removeWindowListener","notifyListeners","retainUntilConsumed","forEach","hasListeners","length","registerWindowListener","windowEventName","pluginEventName","handler","event","unimplemented","msg","unavailable","Unavailable","index","indexOf","splice","handle","addEventListener","removeEventListener","arg","WebView","encode","str","encodeURIComponent","replace","decodeURIComponent","escape","decode","CapacitorCookiesPluginWeb","getCookies","cookies","document","cookie","cookieMap","split","key","trim","setCookie","encodedKey","encodedValue","expires","path","domain","url","reject","deleteCookie","clearCookies","Date","toUTCString","clearAllCookies","CapacitorCookies","web","buildRequestInit","extra","output","assign","method","headers","type","originalKeys","map","k","toLocaleLowerCase","reduce","acc","normalizeHttpHeaders","body","includes","params","URLSearchParams","entries","FormData","form","append","Headers","delete","JSON","stringify","CapacitorHttpPluginWeb","request","requestInit","webFetchExtra","urlParams","shouldEncode","accumulator","entry","item","Array","isArray","slice","substr","buildUrlParams","shouldEncodeUrlParams","response","fetch","contentType","blob","responseType","ok","reader","FileReader","onload","base64String","result","onerror","readAsDataURL","readBlobAsBase64","json","text","status","post","put","patch","CapacitorHttp"],"mappings":";8CAAA,MAuBaA,EAJS,CAACC,GAASA,EAAID,mBAnBH,CAACC,IAC9B,MAAMC,EAAqB,IAAIC,IAC/BD,EAAmBE,IAAI,MAAO,CAAEC,KAAM,QACtC,MAAMC,EAAeL,EAAID,oBAAsB,CAC3CO,gBAAiB,CAAEF,KAAM,OACzBG,UAAWN,GAYf,OAFAI,EAAaG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AAOgG,OAAOhG,OAAOgG,OAAO,CAAE,EAAEtG,GAAU,CAAEuG,OAAQ,QAC3E,CAKD,WAAMwD,CAAM/J,GACR,OAAOpD,KAAKkL,QAAQxH,OAAOgG,OAAOhG,OAAOgG,OAAO,CAAE,EAAEtG,GAAU,CAAEuG,OAAQ,UAC3E,CAKD,YAAM,CAAOvG,GACT,OAAOpD,KAAKkL,QAAQxH,OAAOgG,OAAOhG,OAAOgG,OAAO,CAAE,EAAEtG,GAAU,CAAEuG,OAAQ,WAC3E,EAEO,MAACyD,EAAgBzL,EAAe,gBAAiB,CACzD2H,IAAK,IAAM,IAAI2B"}
package/dist/index.cjs.js CHANGED
@@ -44,28 +44,6 @@ const addPlatform = CapacitorPlatforms.addPlatform;
44
44
  */
45
45
  const setPlatform = CapacitorPlatforms.setPlatform;
46
46
 
47
- const legacyRegisterWebPlugin = (cap, webPlugin) => {
48
- var _a;
49
- const config = webPlugin.config;
50
- const Plugins = cap.Plugins;
51
- if (!(config === null || config === void 0 ? void 0 : config.name)) {
52
- // TODO: add link to upgrade guide
53
- throw new Error(`Capacitor WebPlugin is using the deprecated "registerWebPlugin()" function, but without the config. Please use "registerPlugin()" instead to register this web plugin."`);
54
- }
55
- // TODO: add link to upgrade guide
56
- console.warn(`Capacitor plugin "${config.name}" is using the deprecated "registerWebPlugin()" function`);
57
- if (!Plugins[config.name] || ((_a = config === null || config === void 0 ? void 0 : config.platforms) === null || _a === void 0 ? void 0 : _a.includes(cap.getPlatform()))) {
58
- // Add the web plugin into the plugins registry if there already isn't
59
- // an existing one. If it doesn't already exist, that means
60
- // there's no existing native implementation for it.
61
- // - OR -
62
- // If we already have a plugin registered (meaning it was defined in the native layer),
63
- // then we should only overwrite it if the corresponding web plugin activates on
64
- // a certain platform. For example: Geolocation uses the WebPlugin on Android but not iOS
65
- Plugins[config.name] = webPlugin;
66
- }
67
- };
68
-
69
47
  exports.ExceptionCode = void 0;
70
48
  (function (ExceptionCode) {
71
49
  /**
@@ -115,9 +93,7 @@ const createCapacitor = (win) => {
115
93
  */
116
94
  const capPlatforms = win.CapacitorPlatforms;
117
95
  const defaultGetPlatform = () => {
118
- return capCustomPlatform !== null
119
- ? capCustomPlatform.name
120
- : getPlatformId(win);
96
+ return capCustomPlatform !== null ? capCustomPlatform.name : getPlatformId(win);
121
97
  };
122
98
  const getPlatform = ((_a = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _a === void 0 ? void 0 : _a.getPlatform) || defaultGetPlatform;
123
99
  const defaultIsNativePlatform = () => getPlatform() !== 'web';
@@ -134,14 +110,10 @@ const createCapacitor = (win) => {
134
110
  }
135
111
  return false;
136
112
  };
137
- const isPluginAvailable = ((_c = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _c === void 0 ? void 0 : _c.isPluginAvailable) ||
138
- defaultIsPluginAvailable;
139
- const defaultGetPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find(h => h.name === pluginName); };
113
+ const isPluginAvailable = ((_c = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _c === void 0 ? void 0 : _c.isPluginAvailable) || defaultIsPluginAvailable;
114
+ const defaultGetPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find((h) => h.name === pluginName); };
140
115
  const getPluginHeader = ((_d = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _d === void 0 ? void 0 : _d.getPluginHeader) || defaultGetPluginHeader;
141
116
  const handleError = (err) => win.console.error(err);
142
- const pluginMethodNoop = (_target, prop, pluginName) => {
143
- return Promise.reject(`${pluginName} does not have an implementation of "${prop}".`);
144
- };
145
117
  const registeredPlugins = new Map();
146
118
  const defaultRegisterPlugin = (pluginName, jsImplementations = {}) => {
147
119
  const registeredPlugin = registeredPlugins.get(pluginName);
@@ -159,9 +131,7 @@ const createCapacitor = (win) => {
159
131
  ? (jsImplementation = await jsImplementations[platform]())
160
132
  : (jsImplementation = jsImplementations[platform]);
161
133
  }
162
- else if (capCustomPlatform !== null &&
163
- !jsImplementation &&
164
- 'web' in jsImplementations) {
134
+ else if (capCustomPlatform !== null && !jsImplementation && 'web' in jsImplementations) {
165
135
  jsImplementation =
166
136
  typeof jsImplementations['web'] === 'function'
167
137
  ? (jsImplementation = await jsImplementations['web']())
@@ -172,7 +142,7 @@ const createCapacitor = (win) => {
172
142
  const createPluginMethod = (impl, prop) => {
173
143
  var _a, _b;
174
144
  if (pluginHeader) {
175
- const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find(m => prop === m.name);
145
+ const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find((m) => prop === m.name);
176
146
  if (methodHeader) {
177
147
  if (methodHeader.rtype === 'promise') {
178
148
  return (options) => cap.nativePromise(pluginName, prop.toString(), options);
@@ -195,7 +165,7 @@ const createCapacitor = (win) => {
195
165
  const createPluginMethodWrapper = (prop) => {
196
166
  let remove;
197
167
  const wrapper = (...args) => {
198
- const p = loadPluginImplementation().then(impl => {
168
+ const p = loadPluginImplementation().then((impl) => {
199
169
  const fn = createPluginMethod(impl, prop);
200
170
  if (fn) {
201
171
  const p = fn(...args);
@@ -231,7 +201,7 @@ const createCapacitor = (win) => {
231
201
  callbackId,
232
202
  }, callback);
233
203
  };
234
- const p = new Promise(resolve => call.then(() => resolve({ remove })));
204
+ const p = new Promise((resolve) => call.then(() => resolve({ remove })));
235
205
  p.remove = async () => {
236
206
  console.warn(`Using addListener() without 'await' is deprecated.`);
237
207
  await remove();
@@ -259,30 +229,23 @@ const createCapacitor = (win) => {
259
229
  registeredPlugins.set(pluginName, {
260
230
  name: pluginName,
261
231
  proxy,
262
- platforms: new Set([
263
- ...Object.keys(jsImplementations),
264
- ...(pluginHeader ? [platform] : []),
265
- ]),
232
+ platforms: new Set([...Object.keys(jsImplementations), ...(pluginHeader ? [platform] : [])]),
266
233
  });
267
234
  return proxy;
268
235
  };
269
236
  const registerPlugin = ((_e = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _e === void 0 ? void 0 : _e.registerPlugin) || defaultRegisterPlugin;
270
237
  // Add in convertFileSrc for web, it will already be available in native context
271
238
  if (!cap.convertFileSrc) {
272
- cap.convertFileSrc = filePath => filePath;
239
+ cap.convertFileSrc = (filePath) => filePath;
273
240
  }
274
241
  cap.getPlatform = getPlatform;
275
242
  cap.handleError = handleError;
276
243
  cap.isNativePlatform = isNativePlatform;
277
244
  cap.isPluginAvailable = isPluginAvailable;
278
- cap.pluginMethodNoop = pluginMethodNoop;
279
245
  cap.registerPlugin = registerPlugin;
280
246
  cap.Exception = CapacitorException;
281
247
  cap.DEBUG = !!cap.DEBUG;
282
248
  cap.isLoggingEnabled = !!cap.isLoggingEnabled;
283
- // Deprecated props
284
- cap.platform = cap.getPlatform();
285
- cap.isNative = cap.isNativePlatform();
286
249
  return cap;
287
250
  };
288
251
  const initCapacitorGlobal = (win) => (win.Capacitor = createCapacitor(win));
@@ -297,38 +260,15 @@ const Capacitor = /*#__PURE__*/ initCapacitorGlobal(typeof globalThis !== 'undef
297
260
  ? global
298
261
  : {});
299
262
  const registerPlugin = Capacitor.registerPlugin;
300
- /**
301
- * @deprecated Provided for backwards compatibility for Capacitor v2 plugins.
302
- * Capacitor v3 plugins should import the plugin directly. This "Plugins"
303
- * export is deprecated in v3, and will be removed in v4.
304
- */
305
- const Plugins = Capacitor.Plugins;
306
- /**
307
- * Provided for backwards compatibility. Use the registerPlugin() API
308
- * instead, and provide the web plugin as the "web" implmenetation.
309
- * For example
310
- *
311
- * export const Example = registerPlugin('Example', {
312
- * web: () => import('./web').then(m => new m.Example())
313
- * })
314
- *
315
- * @deprecated Deprecated in v3, will be removed from v4.
316
- */
317
- const registerWebPlugin = (plugin) => legacyRegisterWebPlugin(Capacitor, plugin);
318
263
 
319
264
  /**
320
265
  * Base class web plugins should extend.
321
266
  */
322
267
  class WebPlugin {
323
- constructor(config) {
268
+ constructor() {
324
269
  this.listeners = {};
325
270
  this.retainedEventArguments = {};
326
271
  this.windowListeners = {};
327
- if (config) {
328
- // TODO: add link to upgrade guide
329
- console.warn(`Capacitor WebPlugin "${config.name}" config object was deprecated in v3 and will be removed in v4.`);
330
- this.config = config;
331
- }
332
272
  }
333
273
  addListener(eventName, listenerFunc) {
334
274
  let firstListener = false;
@@ -371,7 +311,7 @@ class WebPlugin {
371
311
  }
372
312
  return;
373
313
  }
374
- listeners.forEach(listener => listener(data));
314
+ listeners.forEach((listener) => listener(data));
375
315
  }
376
316
  hasListeners(eventName) {
377
317
  return !!this.listeners[eventName].length;
@@ -381,7 +321,7 @@ class WebPlugin {
381
321
  registered: false,
382
322
  windowEventName,
383
323
  pluginEventName,
384
- handler: event => {
324
+ handler: (event) => {
385
325
  this.notifyListeners(pluginEventName, event);
386
326
  },
387
327
  };
@@ -422,7 +362,7 @@ class WebPlugin {
422
362
  return;
423
363
  }
424
364
  delete this.retainedEventArguments[eventName];
425
- args.forEach(arg => {
365
+ args.forEach((arg) => {
426
366
  this.notifyListeners(eventName, arg);
427
367
  });
428
368
  }
@@ -447,7 +387,7 @@ class CapacitorCookiesPluginWeb extends WebPlugin {
447
387
  async getCookies() {
448
388
  const cookies = document.cookie;
449
389
  const cookieMap = {};
450
- cookies.split(';').forEach(cookie => {
390
+ cookies.split(';').forEach((cookie) => {
451
391
  if (cookie.length <= 0)
452
392
  return;
453
393
  // Replace first "=" with CAP_COOKIE to prevent splitting on additional "="
@@ -466,9 +406,7 @@ class CapacitorCookiesPluginWeb extends WebPlugin {
466
406
  // Clean & sanitize options
467
407
  const expires = `; expires=${(options.expires || '').replace('expires=', '')}`; // Default is "; expires="
468
408
  const path = (options.path || '/').replace('path=', ''); // Default is "path=/"
469
- const domain = options.url != null && options.url.length > 0
470
- ? `domain=${options.url}`
471
- : '';
409
+ const domain = options.url != null && options.url.length > 0 ? `domain=${options.url}` : '';
472
410
  document.cookie = `${encodedKey}=${encodedValue || ''}${expires}; path=${path}; ${domain};`;
473
411
  }
474
412
  catch (error) {
@@ -487,9 +425,7 @@ class CapacitorCookiesPluginWeb extends WebPlugin {
487
425
  try {
488
426
  const cookies = document.cookie.split(';') || [];
489
427
  for (const cookie of cookies) {
490
- document.cookie = cookie
491
- .replace(/^ +/, '')
492
- .replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);
428
+ document.cookie = cookie.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);
493
429
  }
494
430
  }
495
431
  catch (error) {
@@ -518,9 +454,7 @@ const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {
518
454
  reader.onload = () => {
519
455
  const base64String = reader.result;
520
456
  // remove prefix "data:application/pdf;base64,"
521
- resolve(base64String.indexOf(',') >= 0
522
- ? base64String.split(',')[1]
523
- : base64String);
457
+ resolve(base64String.indexOf(',') >= 0 ? base64String.split(',')[1] : base64String);
524
458
  };
525
459
  reader.onerror = (error) => reject(error);
526
460
  reader.readAsDataURL(blob);
@@ -531,7 +465,7 @@ const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {
531
465
  */
532
466
  const normalizeHttpHeaders = (headers = {}) => {
533
467
  const originalKeys = Object.keys(headers);
534
- const loweredKeys = Object.keys(headers).map(k => k.toLocaleLowerCase());
468
+ const loweredKeys = Object.keys(headers).map((k) => k.toLocaleLowerCase());
535
469
  const normalized = loweredKeys.reduce((acc, key, index) => {
536
470
  acc[key] = headers[originalKeys[index]];
537
471
  return acc;
@@ -552,7 +486,7 @@ const buildUrlParams = (params, shouldEncode = true) => {
552
486
  let item;
553
487
  if (Array.isArray(value)) {
554
488
  item = '';
555
- value.forEach(str => {
489
+ value.forEach((str) => {
556
490
  encodedValue = shouldEncode ? encodeURIComponent(str) : str;
557
491
  item += `${key}=${encodedValue}&`;
558
492
  });
@@ -590,8 +524,7 @@ const buildRequestInit = (options, extra = {}) => {
590
524
  }
591
525
  output.body = params.toString();
592
526
  }
593
- else if (type.includes('multipart/form-data') ||
594
- options.data instanceof FormData) {
527
+ else if (type.includes('multipart/form-data') || options.data instanceof FormData) {
595
528
  const form = new FormData();
596
529
  if (options.data instanceof FormData) {
597
530
  options.data.forEach((value, key) => {
@@ -608,8 +541,7 @@ const buildRequestInit = (options, extra = {}) => {
608
541
  headers.delete('content-type'); // content-type will be set by `window.fetch` to includy boundary
609
542
  output.headers = headers;
610
543
  }
611
- else if (type.includes('application/json') ||
612
- typeof options.data === 'object') {
544
+ else if (type.includes('application/json') || typeof options.data === 'object') {
613
545
  output.body = JSON.stringify(options.data);
614
546
  }
615
547
  return output;
@@ -706,12 +638,10 @@ exports.CapacitorCookies = CapacitorCookies;
706
638
  exports.CapacitorException = CapacitorException;
707
639
  exports.CapacitorHttp = CapacitorHttp;
708
640
  exports.CapacitorPlatforms = CapacitorPlatforms;
709
- exports.Plugins = Plugins;
710
641
  exports.WebPlugin = WebPlugin;
711
642
  exports.WebView = WebView;
712
643
  exports.addPlatform = addPlatform;
713
644
  exports.buildRequestInit = buildRequestInit;
714
645
  exports.registerPlugin = registerPlugin;
715
- exports.registerWebPlugin = registerWebPlugin;
716
646
  exports.setPlatform = setPlatform;
717
647
  //# sourceMappingURL=index.cjs.js.map