@capacitor/core
Advanced tools
Comparing version 7.0.0-alpha.1 to 7.0.0-alpha.2
/*! Capacitor: https://capacitorjs.com/ - MIT License */ | ||
var capacitorExports=function(e){"use strict";const t=(e=>e.CapacitorPlatforms=(e=>{const t=new Map;t.set("web",{name:"web"});const n=e.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:t};return n.addPlatform=(e,t)=>{n.platforms.set(e,t)},n.setPlatform=e=>{n.platforms.has(e)&&(n.currentPlatform=n.platforms.get(e))},n})(e))("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}),n=t.addPlatform,r=t.setPlatform;var i;e.ExceptionCode=void 0,(i=e.ExceptionCode||(e.ExceptionCode={})).Unimplemented="UNIMPLEMENTED",i.Unavailable="UNAVAILABLE";class o extends Error{constructor(e,t,n){super(e),this.message=e,this.code=t,this.data=n}}const s=t=>{var n,r,i,s,a;const l=t.CapacitorCustomPlatform||null,d=t.Capacitor||{},c=d.Plugins=d.Plugins||{},u=t.CapacitorPlatforms,m=(null===(n=null==u?void 0:u.currentPlatform)||void 0===n?void 0:n.getPlatform)||(()=>null!==l?l.name:(e=>{var t,n;return(null==e?void 0:e.androidBridge)?"android":(null===(n=null===(t=null==e?void 0:e.webkit)||void 0===t?void 0:t.messageHandlers)||void 0===n?void 0:n.bridge)?"ios":"web"})(t)),p=(null===(r=null==u?void 0:u.currentPlatform)||void 0===r?void 0:r.isNativePlatform)||(()=>"web"!==m()),f=(null===(i=null==u?void 0:u.currentPlatform)||void 0===i?void 0:i.isPluginAvailable)||(e=>{const t=h.get(e);return!!(null==t?void 0:t.platforms.has(m()))||!!g(e)}),g=(null===(s=null==u?void 0:u.currentPlatform)||void 0===s?void 0:s.getPluginHeader)||(e=>{var t;return null===(t=d.PluginHeaders)||void 0===t?void 0:t.find((t=>t.name===e))}),h=new Map,w=(null===(a=null==u?void 0:u.currentPlatform)||void 0===a?void 0:a.registerPlugin)||((t,n={})=>{const r=h.get(t);if(r)return console.warn(`Capacitor plugin "${t}" already registered. Cannot register plugins twice.`),r.proxy;const i=m(),s=g(t);let a;const u=r=>{let c;const u=(...u)=>{const m=(async()=>(!a&&i in n?a=a="function"==typeof n[i]?await n[i]():n[i]:null!==l&&!a&&"web"in n&&(a=a="function"==typeof n.web?await n.web():n.web),a))().then((n=>{const a=((n,r)=>{var a,l;if(!s){if(n)return null===(l=n[r])||void 0===l?void 0:l.bind(n);throw new o(`"${t}" plugin is not implemented on ${i}`,e.ExceptionCode.Unimplemented)}{const e=null==s?void 0:s.methods.find((e=>r===e.name));if(e)return"promise"===e.rtype?e=>d.nativePromise(t,r.toString(),e):(e,n)=>d.nativeCallback(t,r.toString(),e,n);if(n)return null===(a=n[r])||void 0===a?void 0:a.bind(n)}})(n,r);if(a){const e=a(...u);return c=null==e?void 0:e.remove,e}throw new o(`"${t}.${r}()" is not implemented on ${i}`,e.ExceptionCode.Unimplemented)}));return"addListener"===r&&(m.remove=async()=>c()),m};return u.toString=()=>`${r.toString()}() { [capacitor code] }`,Object.defineProperty(u,"name",{value:r,writable:!1,configurable:!1}),u},p=u("addListener"),f=u("removeListener"),w=(e,t)=>{const n=p({eventName:e},t),r=async()=>{const r=await n;f({eventName:e,callbackId:r},t)},i=new Promise((e=>n.then((()=>e({remove:r})))));return i.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await r()},i},v=new Proxy({},{get(e,t){switch(t){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return s?w:p;case"removeListener":return f;default:return u(t)}}});return c[t]=v,h.set(t,{name:t,proxy:v,platforms:new Set([...Object.keys(n),...s?[i]:[]])}),v});return d.convertFileSrc||(d.convertFileSrc=e=>e),d.getPlatform=m,d.handleError=e=>t.console.error(e),d.isNativePlatform=p,d.isPluginAvailable=f,d.pluginMethodNoop=(e,t,n)=>Promise.reject(`${n} does not have an implementation of "${t}".`),d.registerPlugin=w,d.Exception=o,d.DEBUG=!!d.DEBUG,d.isLoggingEnabled=!!d.isLoggingEnabled,d.platform=d.getPlatform(),d.isNative=d.isNativePlatform(),d},a=(e=>e.Capacitor=s(e))("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}),l=a.registerPlugin,d=a.Plugins;class c{constructor(e){this.listeners={},this.retainedEventArguments={},this.windowListeners={},e&&(console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`),this.config=e)}addListener(e,t){let n=!1;this.listeners[e]||(this.listeners[e]=[],n=!0),this.listeners[e].push(t);const r=this.windowListeners[e];r&&!r.registered&&this.addWindowListener(r),n&&this.sendRetainedArgumentsForEvent(e);return Promise.resolve({remove:async()=>this.removeListener(e,t)})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,n){const r=this.listeners[e];if(r)r.forEach((e=>e(t)));else if(n){let n=this.retainedEventArguments[e];n||(n=[]),n.push(t),this.retainedEventArguments[e]=n}}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:e=>{this.notifyListeners(t,e)}}}unimplemented(t="not implemented"){return new a.Exception(t,e.ExceptionCode.Unimplemented)}unavailable(t="not available"){return new a.Exception(t,e.ExceptionCode.Unavailable)}async removeListener(e,t){const n=this.listeners[e];if(!n)return;const r=n.indexOf(t);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach((t=>{this.notifyListeners(e,t)})))}}const u=l("WebView"),m=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),p=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class f extends c{async getCookies(){const e=document.cookie,t={};return e.split(";").forEach((e=>{if(e.length<=0)return;let[n,r]=e.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");n=p(n).trim(),r=p(r).trim(),t[n]=r})),t}async setCookie(e){try{const t=m(e.key),n=m(e.value),r=`; expires=${(e.expires||"").replace("expires=","")}`,i=(e.path||"/").replace("path=",""),o=null!=e.url&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${n||""}${r}; path=${i}; ${o};`}catch(e){return Promise.reject(e)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(e){return Promise.reject(e)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${(new Date).toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}const g=l("CapacitorCookies",{web:()=>new f}),h=(e,t={})=>{const n=Object.assign({method:e.method||"GET",headers:e.headers},t),r=((e={})=>{const t=Object.keys(e);return Object.keys(e).map((e=>e.toLocaleLowerCase())).reduce(((n,r,i)=>(n[r]=e[t[i]],n)),{})})(e.headers)["content-type"]||"";if("string"==typeof e.data)n.body=e.data;else if(r.includes("application/x-www-form-urlencoded")){const t=new URLSearchParams;for(const[n,r]of Object.entries(e.data||{}))t.set(n,r);n.body=t.toString()}else if(r.includes("multipart/form-data")||e.data instanceof FormData){const t=new FormData;if(e.data instanceof FormData)e.data.forEach(((e,n)=>{t.append(n,e)}));else for(const n of Object.keys(e.data))t.append(n,e.data[n]);n.body=t;const r=new Headers(n.headers);r.delete("content-type"),n.headers=r}else(r.includes("application/json")||"object"==typeof e.data)&&(n.body=JSON.stringify(e.data));return n};class w extends c{async request(e){const t=h(e,e.webFetchExtra),n=((e,t=!0)=>e?Object.entries(e).reduce(((e,n)=>{const[r,i]=n;let o,s;return Array.isArray(i)?(s="",i.forEach((e=>{o=t?encodeURIComponent(e):e,s+=`${r}=${o}&`})),s.slice(0,-1)):(o=t?encodeURIComponent(i):i,s=`${r}=${o}`),`${e}&${s}`}),"").substr(1):null)(e.params,e.shouldEncodeUrlParams),r=n?`${e.url}?${n}`:e.url,i=await fetch(r,t),o=i.headers.get("content-type")||"";let s,a,{responseType:l="text"}=i.ok?e:{};switch(o.includes("application/json")&&(l="json"),l){case"arraybuffer":case"blob":a=await i.blob(),s=await(async e=>new Promise(((t,n)=>{const r=new FileReader;r.onload=()=>{const e=r.result;t(e.indexOf(",")>=0?e.split(",")[1]:e)},r.onerror=e=>n(e),r.readAsDataURL(e)})))(a);break;case"json":s=await i.json();break;default:s=await i.text()}const d={};return i.headers.forEach(((e,t)=>{d[t]=e})),{data:s,headers:d,status:i.status,url:i.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}const v=l("CapacitorHttp",{web:()=>new w});return e.Capacitor=a,e.CapacitorCookies=g,e.CapacitorException=o,e.CapacitorHttp=v,e.CapacitorPlatforms=t,e.Plugins=d,e.WebPlugin=c,e.WebView=u,e.addPlatform=n,e.buildRequestInit=h,e.registerPlugin=l,e.registerWebPlugin=e=>((e,t)=>{var n;const r=t.config,i=e.Plugins;if(!(null==r?void 0:r.name))throw new Error('Capacitor WebPlugin is using the deprecated "registerWebPlugin()" function, but without the config. Please use "registerPlugin()" instead to register this web plugin."');console.warn(`Capacitor plugin "${r.name}" is using the deprecated "registerWebPlugin()" function`),i[r.name]&&!(null===(n=null==r?void 0:r.platforms)||void 0===n?void 0:n.includes(e.getPlatform()))||(i[r.name]=t)})(a,e),e.setPlatform=r,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var capacitorExports=function(e){"use strict";const t=(e=>e.CapacitorPlatforms=(e=>{const t=new Map;t.set("web",{name:"web"});const n=e.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:t};return n.addPlatform=(e,t)=>{n.platforms.set(e,t)},n.setPlatform=e=>{n.platforms.has(e)&&(n.currentPlatform=n.platforms.get(e))},n})(e))("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}),n=t.addPlatform,r=t.setPlatform;var s;e.ExceptionCode=void 0,(s=e.ExceptionCode||(e.ExceptionCode={})).Unimplemented="UNIMPLEMENTED",s.Unavailable="UNAVAILABLE";class i extends Error{constructor(e,t,n){super(e),this.message=e,this.code=t,this.data=n}}const o=t=>{var n,r,s,o,a;const l=t.CapacitorCustomPlatform||null,d=t.Capacitor||{},c=d.Plugins=d.Plugins||{},u=t.CapacitorPlatforms,m=(null===(n=null==u?void 0:u.currentPlatform)||void 0===n?void 0:n.getPlatform)||(()=>null!==l?l.name:(e=>{var t,n;return(null==e?void 0:e.androidBridge)?"android":(null===(n=null===(t=null==e?void 0:e.webkit)||void 0===t?void 0:t.messageHandlers)||void 0===n?void 0:n.bridge)?"ios":"web"})(t)),p=(null===(r=null==u?void 0:u.currentPlatform)||void 0===r?void 0:r.isNativePlatform)||(()=>"web"!==m()),f=(null===(s=null==u?void 0:u.currentPlatform)||void 0===s?void 0:s.isPluginAvailable)||(e=>{const t=w.get(e);return!!(null==t?void 0:t.platforms.has(m()))||!!h(e)}),h=(null===(o=null==u?void 0:u.currentPlatform)||void 0===o?void 0:o.getPluginHeader)||(e=>{var t;return null===(t=d.PluginHeaders)||void 0===t?void 0:t.find((t=>t.name===e))}),w=new Map,g=(null===(a=null==u?void 0:u.currentPlatform)||void 0===a?void 0:a.registerPlugin)||((t,n={})=>{const r=w.get(t);if(r)return console.warn(`Capacitor plugin "${t}" already registered. Cannot register plugins twice.`),r.proxy;const s=m(),o=h(t);let a;const u=r=>{let c;const u=(...u)=>{const m=(async()=>(!a&&s in n?a=a="function"==typeof n[s]?await n[s]():n[s]:null!==l&&!a&&"web"in n&&(a=a="function"==typeof n.web?await n.web():n.web),a))().then((n=>{const a=((n,r)=>{var a,l;if(!o){if(n)return null===(l=n[r])||void 0===l?void 0:l.bind(n);throw new i(`"${t}" plugin is not implemented on ${s}`,e.ExceptionCode.Unimplemented)}{const e=null==o?void 0:o.methods.find((e=>r===e.name));if(e)return"promise"===e.rtype?e=>d.nativePromise(t,r.toString(),e):(e,n)=>d.nativeCallback(t,r.toString(),e,n);if(n)return null===(a=n[r])||void 0===a?void 0:a.bind(n)}})(n,r);if(a){const e=a(...u);return c=null==e?void 0:e.remove,e}throw new i(`"${t}.${r}()" is not implemented on ${s}`,e.ExceptionCode.Unimplemented)}));return"addListener"===r&&(m.remove=async()=>c()),m};return u.toString=()=>`${r.toString()}() { [capacitor code] }`,Object.defineProperty(u,"name",{value:r,writable:!1,configurable:!1}),u},p=u("addListener"),f=u("removeListener"),g=(e,t)=>{const n=p({eventName:e},t),r=async()=>{const r=await n;f({eventName:e,callbackId:r},t)},s=new Promise((e=>n.then((()=>e({remove:r})))));return s.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await r()},s},v=new Proxy({},{get(e,t){switch(t){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return o?g:p;case"removeListener":return f;default:return u(t)}}});return c[t]=v,w.set(t,{name:t,proxy:v,platforms:new Set([...Object.keys(n),...o?[s]:[]])}),v});return d.convertFileSrc||(d.convertFileSrc=e=>e),d.getPlatform=m,d.handleError=e=>t.console.error(e),d.isNativePlatform=p,d.isPluginAvailable=f,d.registerPlugin=g,d.Exception=i,d.DEBUG=!!d.DEBUG,d.isLoggingEnabled=!!d.isLoggingEnabled,d},a=(e=>e.Capacitor=o(e))("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}),l=a.registerPlugin;class d{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,t){let n=!1;this.listeners[e]||(this.listeners[e]=[],n=!0),this.listeners[e].push(t);const r=this.windowListeners[e];r&&!r.registered&&this.addWindowListener(r),n&&this.sendRetainedArgumentsForEvent(e);return Promise.resolve({remove:async()=>this.removeListener(e,t)})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,n){const r=this.listeners[e];if(r)r.forEach((e=>e(t)));else if(n){let n=this.retainedEventArguments[e];n||(n=[]),n.push(t),this.retainedEventArguments[e]=n}}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:e=>{this.notifyListeners(t,e)}}}unimplemented(t="not implemented"){return new a.Exception(t,e.ExceptionCode.Unimplemented)}unavailable(t="not available"){return new a.Exception(t,e.ExceptionCode.Unavailable)}async removeListener(e,t){const n=this.listeners[e];if(!n)return;const r=n.indexOf(t);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach((t=>{this.notifyListeners(e,t)})))}}const c=l("WebView"),u=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),m=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class p extends d{async getCookies(){const e=document.cookie,t={};return e.split(";").forEach((e=>{if(e.length<=0)return;let[n,r]=e.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");n=m(n).trim(),r=m(r).trim(),t[n]=r})),t}async setCookie(e){try{const t=u(e.key),n=u(e.value),r=`; expires=${(e.expires||"").replace("expires=","")}`,s=(e.path||"/").replace("path=",""),i=null!=e.url&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${n||""}${r}; path=${s}; ${i};`}catch(e){return Promise.reject(e)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(e){return Promise.reject(e)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${(new Date).toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}const f=l("CapacitorCookies",{web:()=>new p}),h=(e,t={})=>{const n=Object.assign({method:e.method||"GET",headers:e.headers},t),r=((e={})=>{const t=Object.keys(e);return Object.keys(e).map((e=>e.toLocaleLowerCase())).reduce(((n,r,s)=>(n[r]=e[t[s]],n)),{})})(e.headers)["content-type"]||"";if("string"==typeof e.data)n.body=e.data;else if(r.includes("application/x-www-form-urlencoded")){const t=new URLSearchParams;for(const[n,r]of Object.entries(e.data||{}))t.set(n,r);n.body=t.toString()}else if(r.includes("multipart/form-data")||e.data instanceof FormData){const t=new FormData;if(e.data instanceof FormData)e.data.forEach(((e,n)=>{t.append(n,e)}));else for(const n of Object.keys(e.data))t.append(n,e.data[n]);n.body=t;const r=new Headers(n.headers);r.delete("content-type"),n.headers=r}else(r.includes("application/json")||"object"==typeof e.data)&&(n.body=JSON.stringify(e.data));return n};class w extends d{async request(e){const t=h(e,e.webFetchExtra),n=((e,t=!0)=>e?Object.entries(e).reduce(((e,n)=>{const[r,s]=n;let i,o;return Array.isArray(s)?(o="",s.forEach((e=>{i=t?encodeURIComponent(e):e,o+=`${r}=${i}&`})),o.slice(0,-1)):(i=t?encodeURIComponent(s):s,o=`${r}=${i}`),`${e}&${o}`}),"").substr(1):null)(e.params,e.shouldEncodeUrlParams),r=n?`${e.url}?${n}`:e.url,s=await fetch(r,t),i=s.headers.get("content-type")||"";let o,a,{responseType:l="text"}=s.ok?e:{};switch(i.includes("application/json")&&(l="json"),l){case"arraybuffer":case"blob":a=await s.blob(),o=await(async e=>new Promise(((t,n)=>{const r=new FileReader;r.onload=()=>{const e=r.result;t(e.indexOf(",")>=0?e.split(",")[1]:e)},r.onerror=e=>n(e),r.readAsDataURL(e)})))(a);break;case"json":o=await s.json();break;default:o=await s.text()}const d={};return s.headers.forEach(((e,t)=>{d[t]=e})),{data:o,headers:d,status:s.status,url:s.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}const g=l("CapacitorHttp",{web:()=>new w});return e.Capacitor=a,e.CapacitorCookies=f,e.CapacitorException=i,e.CapacitorHttp=g,e.CapacitorPlatforms=t,e.WebPlugin=d,e.WebView=c,e.addPlatform=n,e.buildRequestInit=h,e.registerPlugin=l,e.setPlatform=r,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
//# sourceMappingURL=capacitor.js.map |
@@ -47,24 +47,2 @@ /*! Capacitor: https://capacitorjs.com/ - MIT License */ | ||
const legacyRegisterWebPlugin = (cap, webPlugin) => { | ||
var _a; | ||
const config = webPlugin.config; | ||
const Plugins = cap.Plugins; | ||
if (!(config === null || config === void 0 ? void 0 : config.name)) { | ||
// TODO: add link to upgrade guide | ||
throw new Error(`Capacitor WebPlugin is using the deprecated "registerWebPlugin()" function, but without the config. Please use "registerPlugin()" instead to register this web plugin."`); | ||
} | ||
// TODO: add link to upgrade guide | ||
console.warn(`Capacitor plugin "${config.name}" is using the deprecated "registerWebPlugin()" function`); | ||
if (!Plugins[config.name] || ((_a = config === null || config === void 0 ? void 0 : config.platforms) === null || _a === void 0 ? void 0 : _a.includes(cap.getPlatform()))) { | ||
// Add the web plugin into the plugins registry if there already isn't | ||
// an existing one. If it doesn't already exist, that means | ||
// there's no existing native implementation for it. | ||
// - OR - | ||
// If we already have a plugin registered (meaning it was defined in the native layer), | ||
// then we should only overwrite it if the corresponding web plugin activates on | ||
// a certain platform. For example: Geolocation uses the WebPlugin on Android but not iOS | ||
Plugins[config.name] = webPlugin; | ||
} | ||
}; | ||
exports.ExceptionCode = void 0; | ||
@@ -140,5 +118,2 @@ (function (ExceptionCode) { | ||
const handleError = (err) => win.console.error(err); | ||
const pluginMethodNoop = (_target, prop, pluginName) => { | ||
return Promise.reject(`${pluginName} does not have an implementation of "${prop}".`); | ||
}; | ||
const registeredPlugins = new Map(); | ||
@@ -272,3 +247,2 @@ const defaultRegisterPlugin = (pluginName, jsImplementations = {}) => { | ||
cap.isPluginAvailable = isPluginAvailable; | ||
cap.pluginMethodNoop = pluginMethodNoop; | ||
cap.registerPlugin = registerPlugin; | ||
@@ -278,5 +252,2 @@ cap.Exception = CapacitorException; | ||
cap.isLoggingEnabled = !!cap.isLoggingEnabled; | ||
// Deprecated props | ||
cap.platform = cap.getPlatform(); | ||
cap.isNative = cap.isNativePlatform(); | ||
return cap; | ||
@@ -296,20 +267,2 @@ }; | ||
const registerPlugin = Capacitor.registerPlugin; | ||
/** | ||
* @deprecated Provided for backwards compatibility for Capacitor v2 plugins. | ||
* Capacitor v3 plugins should import the plugin directly. This "Plugins" | ||
* export is deprecated in v3, and will be removed in v4. | ||
*/ | ||
const Plugins = Capacitor.Plugins; | ||
/** | ||
* Provided for backwards compatibility. Use the registerPlugin() API | ||
* instead, and provide the web plugin as the "web" implmenetation. | ||
* For example | ||
* | ||
* export const Example = registerPlugin('Example', { | ||
* web: () => import('./web').then(m => new m.Example()) | ||
* }) | ||
* | ||
* @deprecated Deprecated in v3, will be removed from v4. | ||
*/ | ||
const registerWebPlugin = (plugin) => legacyRegisterWebPlugin(Capacitor, plugin); | ||
@@ -320,11 +273,6 @@ /** | ||
class WebPlugin { | ||
constructor(config) { | ||
constructor() { | ||
this.listeners = {}; | ||
this.retainedEventArguments = {}; | ||
this.windowListeners = {}; | ||
if (config) { | ||
// TODO: add link to upgrade guide | ||
console.warn(`Capacitor WebPlugin "${config.name}" config object was deprecated in v3 and will be removed in v4.`); | ||
this.config = config; | ||
} | ||
} | ||
@@ -699,3 +647,2 @@ addListener(eventName, listenerFunc) { | ||
exports.CapacitorPlatforms = CapacitorPlatforms; | ||
exports.Plugins = Plugins; | ||
exports.WebPlugin = WebPlugin; | ||
@@ -706,4 +653,3 @@ exports.WebView = WebView; | ||
exports.registerPlugin = registerPlugin; | ||
exports.registerWebPlugin = registerWebPlugin; | ||
exports.setPlatform = setPlatform; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -43,24 +43,2 @@ /*! Capacitor: https://capacitorjs.com/ - MIT License */ | ||
const legacyRegisterWebPlugin = (cap, webPlugin) => { | ||
var _a; | ||
const config = webPlugin.config; | ||
const Plugins = cap.Plugins; | ||
if (!(config === null || config === void 0 ? void 0 : config.name)) { | ||
// TODO: add link to upgrade guide | ||
throw new Error(`Capacitor WebPlugin is using the deprecated "registerWebPlugin()" function, but without the config. Please use "registerPlugin()" instead to register this web plugin."`); | ||
} | ||
// TODO: add link to upgrade guide | ||
console.warn(`Capacitor plugin "${config.name}" is using the deprecated "registerWebPlugin()" function`); | ||
if (!Plugins[config.name] || ((_a = config === null || config === void 0 ? void 0 : config.platforms) === null || _a === void 0 ? void 0 : _a.includes(cap.getPlatform()))) { | ||
// Add the web plugin into the plugins registry if there already isn't | ||
// an existing one. If it doesn't already exist, that means | ||
// there's no existing native implementation for it. | ||
// - OR - | ||
// If we already have a plugin registered (meaning it was defined in the native layer), | ||
// then we should only overwrite it if the corresponding web plugin activates on | ||
// a certain platform. For example: Geolocation uses the WebPlugin on Android but not iOS | ||
Plugins[config.name] = webPlugin; | ||
} | ||
}; | ||
var ExceptionCode; | ||
@@ -136,5 +114,2 @@ (function (ExceptionCode) { | ||
const handleError = (err) => win.console.error(err); | ||
const pluginMethodNoop = (_target, prop, pluginName) => { | ||
return Promise.reject(`${pluginName} does not have an implementation of "${prop}".`); | ||
}; | ||
const registeredPlugins = new Map(); | ||
@@ -268,3 +243,2 @@ const defaultRegisterPlugin = (pluginName, jsImplementations = {}) => { | ||
cap.isPluginAvailable = isPluginAvailable; | ||
cap.pluginMethodNoop = pluginMethodNoop; | ||
cap.registerPlugin = registerPlugin; | ||
@@ -274,5 +248,2 @@ cap.Exception = CapacitorException; | ||
cap.isLoggingEnabled = !!cap.isLoggingEnabled; | ||
// Deprecated props | ||
cap.platform = cap.getPlatform(); | ||
cap.isNative = cap.isNativePlatform(); | ||
return cap; | ||
@@ -292,20 +263,2 @@ }; | ||
const registerPlugin = Capacitor.registerPlugin; | ||
/** | ||
* @deprecated Provided for backwards compatibility for Capacitor v2 plugins. | ||
* Capacitor v3 plugins should import the plugin directly. This "Plugins" | ||
* export is deprecated in v3, and will be removed in v4. | ||
*/ | ||
const Plugins = Capacitor.Plugins; | ||
/** | ||
* Provided for backwards compatibility. Use the registerPlugin() API | ||
* instead, and provide the web plugin as the "web" implmenetation. | ||
* For example | ||
* | ||
* export const Example = registerPlugin('Example', { | ||
* web: () => import('./web').then(m => new m.Example()) | ||
* }) | ||
* | ||
* @deprecated Deprecated in v3, will be removed from v4. | ||
*/ | ||
const registerWebPlugin = (plugin) => legacyRegisterWebPlugin(Capacitor, plugin); | ||
@@ -316,11 +269,6 @@ /** | ||
class WebPlugin { | ||
constructor(config) { | ||
constructor() { | ||
this.listeners = {}; | ||
this.retainedEventArguments = {}; | ||
this.windowListeners = {}; | ||
if (config) { | ||
// TODO: add link to upgrade guide | ||
console.warn(`Capacitor WebPlugin "${config.name}" config object was deprecated in v3 and will be removed in v4.`); | ||
this.config = config; | ||
} | ||
} | ||
@@ -690,3 +638,3 @@ addListener(eventName, listenerFunc) { | ||
export { Capacitor, CapacitorCookies, CapacitorException, CapacitorHttp, CapacitorPlatforms, ExceptionCode, Plugins, WebPlugin, WebView, addPlatform, buildRequestInit, registerPlugin, registerWebPlugin, setPlatform }; | ||
export { Capacitor, CapacitorCookies, CapacitorException, CapacitorHttp, CapacitorPlatforms, ExceptionCode, WebPlugin, WebView, addPlatform, buildRequestInit, registerPlugin, setPlatform }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@capacitor/core", | ||
"version": "7.0.0-alpha.1", | ||
"version": "7.0.0-alpha.2", | ||
"description": "Capacitor: Cross-platform apps with JavaScript and the web", | ||
@@ -5,0 +5,0 @@ "homepage": "https://capacitorjs.com", |
@@ -1,2 +0,1 @@ | ||
import type { PluginRegistry } from './legacy/legacy-definitions'; | ||
import type { CapacitorException } from './util'; | ||
@@ -38,21 +37,2 @@ export interface CapacitorGlobal { | ||
isLoggingEnabled?: boolean; | ||
/** | ||
* @deprecated Plugins should be imported instead. Deprecated in | ||
* v3 and Capacitor.Plugins property definition will not be exported in v4. | ||
*/ | ||
Plugins: PluginRegistry; | ||
/** | ||
* Called when a plugin method is not available. Defaults to console | ||
* logging a warning. Provided for backwards compatibility. | ||
* @deprecated Deprecated in v3, will be removed from v4 | ||
*/ | ||
pluginMethodNoop: (target: any, key: PropertyKey, pluginName: string) => Promise<never>; | ||
/** | ||
* @deprecated Use `isNativePlatform()` instead | ||
*/ | ||
isNative?: boolean; | ||
/** | ||
* @deprecated Use `getPlatform()` instead | ||
*/ | ||
platform?: string; | ||
} | ||
@@ -59,0 +39,0 @@ /** |
@@ -1,21 +0,2 @@ | ||
import type { WebPlugin } from './web-plugin'; | ||
export declare const Capacitor: import("./definitions").CapacitorGlobal; | ||
export declare const registerPlugin: import("./definitions").RegisterPlugin; | ||
/** | ||
* @deprecated Provided for backwards compatibility for Capacitor v2 plugins. | ||
* Capacitor v3 plugins should import the plugin directly. This "Plugins" | ||
* export is deprecated in v3, and will be removed in v4. | ||
*/ | ||
export declare const Plugins: import(".").PluginRegistry; | ||
/** | ||
* Provided for backwards compatibility. Use the registerPlugin() API | ||
* instead, and provide the web plugin as the "web" implmenetation. | ||
* For example | ||
* | ||
* export const Example = registerPlugin('Example', { | ||
* web: () => import('./web').then(m => new m.Example()) | ||
* }) | ||
* | ||
* @deprecated Deprecated in v3, will be removed from v4. | ||
*/ | ||
export declare const registerWebPlugin: (plugin: WebPlugin) => void; |
export type { CapacitorGlobal, PermissionState, Plugin, PluginCallback, PluginImplementations, PluginListenerHandle, PluginResultData, PluginResultError, } from './definitions'; | ||
export { CapacitorPlatforms, addPlatform, setPlatform } from './platforms'; | ||
export { Capacitor, registerPlugin } from './global'; | ||
export { WebPlugin, WebPluginConfig, ListenerCallback } from './web-plugin'; | ||
export { WebPlugin, ListenerCallback } from './web-plugin'; | ||
export { CapacitorCookies, CapacitorHttp, WebView, buildRequestInit } from './core-plugins'; | ||
export type { ClearCookieOptions, DeleteCookieOptions, SetCookieOptions, HttpHeaders, HttpOptions, HttpParams, HttpResponse, HttpResponseType, WebViewPath, WebViewPlugin, } from './core-plugins'; | ||
export { CapacitorException, ExceptionCode } from './util'; | ||
export { Plugins, registerWebPlugin } from './global'; | ||
export type { CallbackID, CancellableCallback, ISODateString, PluginConfig, PluginRegistry, } from './legacy/legacy-definitions'; |
@@ -7,6 +7,2 @@ import type { PluginListenerHandle, Plugin } from './definitions'; | ||
export declare class WebPlugin implements Plugin { | ||
/** | ||
* @deprecated WebPluginConfig deprecated in v3 and will be removed in v4. | ||
*/ | ||
config?: WebPluginConfig; | ||
protected listeners: { | ||
@@ -21,3 +17,2 @@ [eventName: string]: ListenerCallback[]; | ||
}; | ||
constructor(config?: WebPluginConfig); | ||
addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle>; | ||
@@ -42,14 +37,1 @@ removeAllListeners(): Promise<void>; | ||
} | ||
/** | ||
* @deprecated Deprecated in v3, removing in v4. | ||
*/ | ||
export interface WebPluginConfig { | ||
/** | ||
* @deprecated Deprecated in v3, removing in v4. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* @deprecated Deprecated in v3, removing in v4. | ||
*/ | ||
platforms?: string[]; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
370481
21
3296