Update capacitor version

This commit is contained in:
Pieter Vander Vennet 2025-07-06 20:20:48 +02:00
parent 91155bce0a
commit f3b3a86b32
610 changed files with 28718 additions and 7101 deletions

View file

@ -41,10 +41,7 @@
var resultantId = id;
// Its a relative path, so lop off the last portion and add the id (minus "./")
if (id.charAt(0) === '.') {
resultantId =
module.id.slice(0, module.id.lastIndexOf(SEPARATOR)) +
SEPARATOR +
id.slice(2);
resultantId = module.id.slice(0, module.id.lastIndexOf(SEPARATOR)) + SEPARATOR + id.slice(2);
}
return require(resultantId);
};
@ -58,8 +55,7 @@
if (!modules[id]) {
throw 'module ' + id + ' not found';
} else if (id in inProgressModules) {
var cycle =
requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
throw 'Cycle in require graph: ' + cycle;
}
if (modules[id].factory) {
@ -207,7 +203,7 @@
* bNoDetach is required for events which cause an exception which needs to be caught in native code
*/
fireDocumentEvent: function (type, data, bNoDetach) {
var evt = Capacitor.createEvent(type, data);
var evt = window.Capacitor.createEvent(type, data);
if (typeof documentEventHandlers[type] !== 'undefined') {
if (bNoDetach) {
documentEventHandlers[type].fire(evt);
@ -225,7 +221,7 @@
}
},
fireWindowEvent: function (type, data) {
var evt = Capacitor.createEvent(type, data);
var evt = window.Capacitor.createEvent(type, data);
if (typeof windowEventHandlers[type] !== 'undefined') {
setTimeout(function () {
windowEventHandlers[type].fire(evt);
@ -259,13 +255,7 @@
* Called by native code when returning successful result from an action.
*/
callbackSuccess: function (callbackId, args) {
cordova.callbackFromNative(
callbackId,
true,
args.status,
[args.message],
args.keepCallback,
);
cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
},
/**
@ -274,25 +264,13 @@
callbackError: function (callbackId, args) {
// TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
// Derive success from status.
cordova.callbackFromNative(
callbackId,
false,
args.status,
[args.message],
args.keepCallback,
);
cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
},
/**
* Called by native code when returning the result from an action.
*/
callbackFromNative: function (
callbackId,
isSuccess,
status,
args,
keepCallback,
) {
callbackFromNative: function (callbackId, isSuccess, status, args, keepCallback) {
try {
var callback = cordova.callbacks[callbackId];
if (callback) {
@ -314,13 +292,7 @@
}
}
} catch (err) {
var msg =
'Error in ' +
(isSuccess ? 'Success' : 'Error') +
' callbackId: ' +
callbackId +
' : ' +
err;
var msg = 'Error in ' + (isSuccess ? 'Success' : 'Error') + ' callbackId: ' + callbackId + ' : ' + err;
console && console.log && console.log(msg);
cordova.fireWindowEvent('cordovacallbackerror', { message: msg });
throw err;
@ -418,10 +390,7 @@
};
base64.toArrayBuffer = function (str) {
var decodedStr =
typeof atob !== 'undefined'
? atob(str)
: Buffer.from(str, 'base64').toString('binary'); // eslint-disable-line no-undef
var decodedStr = typeof atob !== 'undefined' ? atob(str) : Buffer.from(str, 'base64').toString('binary'); // eslint-disable-line no-undef
var arrayBuffer = new ArrayBuffer(decodedStr.length);
var array = new Uint8Array(arrayBuffer);
for (var i = 0, len = decodedStr.length; i < len; i++) {
@ -437,8 +406,7 @@
* platforms tested.
*/
var b64_6bit =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var b64_6bit = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var b64_12bit;
var b64_12bitTable = function () {
@ -527,35 +495,20 @@
if (clobber) {
// Clobber if it doesn't exist.
if (typeof parent[key] === 'undefined') {
assignOrWrapInDeprecateGetter(
parent,
key,
result,
obj.deprecated,
);
assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
} else if (typeof obj.path !== 'undefined') {
// If merging, merge properties onto parent, otherwise, clobber.
if (merge) {
recursiveMerge(parent[key], result);
} else {
assignOrWrapInDeprecateGetter(
parent,
key,
result,
obj.deprecated,
);
assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
}
}
result = parent[key];
} else {
// Overwrite if not currently defined.
if (typeof parent[key] === 'undefined') {
assignOrWrapInDeprecateGetter(
parent,
key,
result,
obj.deprecated,
);
assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
} else {
// Set result to what already exists, so we can build children into it if they exist.
result = parent[key];
@ -566,13 +519,7 @@
include(result, obj.children, clobber, merge);
}
} catch (e) {
utils.alert(
'Exception building Cordova JS globals: ' +
e +
' for key "' +
key +
'"',
);
utils.alert('Exception building Cordova JS globals: ' + e + ' for key "' + key + '"');
}
});
}
@ -591,10 +538,7 @@
// If the target object is a constructor override off prototype.
clobber(target.prototype, prop, src[prop]);
} else {
if (
typeof src[prop] === 'object' &&
typeof target[prop] === 'object'
) {
if (typeof src[prop] === 'object' && typeof target[prop] === 'object') {
recursiveMerge(target[prop], src[prop]);
} else {
clobber(target, prop, src[prop]);
@ -737,13 +681,9 @@
};
function checkSubscriptionArgument(argument) {
if (
typeof argument !== 'function' &&
typeof argument.handleEvent !== 'function'
) {
if (typeof argument !== 'function' && typeof argument.handleEvent !== 'function') {
throw new Error(
'Must provide a function or an EventListener object ' +
'implementing the handleEvent interface.',
'Must provide a function or an EventListener object ' + 'implementing the handleEvent interface.',
);
}
}
@ -755,17 +695,11 @@
* and a guid that can be used to stop subscribing to the channel.
* Returns the guid.
*/
Channel.prototype.subscribe = function (
eventListenerOrFunction,
eventListener,
) {
Channel.prototype.subscribe = function (eventListenerOrFunction, eventListener) {
checkSubscriptionArgument(eventListenerOrFunction);
var handleEvent, guid;
if (
eventListenerOrFunction &&
typeof eventListenerOrFunction === 'object'
) {
if (eventListenerOrFunction && typeof eventListenerOrFunction === 'object') {
// Received an EventListener object implementing the handleEvent interface
handleEvent = eventListenerOrFunction.handleEvent;
eventListener = eventListenerOrFunction;
@ -808,10 +742,7 @@
checkSubscriptionArgument(eventListenerOrFunction);
var handleEvent, guid, handler;
if (
eventListenerOrFunction &&
typeof eventListenerOrFunction === 'object'
) {
if (eventListenerOrFunction && typeof eventListenerOrFunction === 'object') {
// Received an EventListener object implementing the handleEvent interface
handleEvent = eventListenerOrFunction.handleEvent;
} else {
@ -1013,11 +944,7 @@
};
if (window.androidBridge) {
window.androidBridge.postMessage(JSON.stringify(command));
} else if (
window.webkit &&
window.webkit.messageHandlers &&
window.webkit.messageHandlers.bridge
) {
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.bridge) {
window.webkit.messageHandlers.bridge.postMessage(command);
}
};
@ -1043,13 +970,7 @@
var actionArgs = command[3];
var callbacks = cordova.callbacks[callbackId] || {};
execProxy(
callbacks.success,
callbacks.fail,
service,
action,
actionArgs,
);
execProxy(callbacks.success, callbacks.fail, service, action, actionArgs);
commandString = commandQueue.shift();
}
@ -1107,23 +1028,11 @@
return json;
};
capacitorExec.nativeCallback = function (
callbackId,
status,
message,
keepCallback,
debug,
) {
capacitorExec.nativeCallback = function (callbackId, status, message, keepCallback, debug) {
var success = status === 0 || status === 1;
var args = convertMessageToArgsNativeToJs(message);
Promise.resolve().then(function () {
cordova.callbackFromNative(
callbackId,
success,
status,
args,
keepCallback,
); // eslint-disable-line
cordova.callbackFromNative(callbackId, success, status, args, keepCallback); // eslint-disable-line
});
};
@ -1186,9 +1095,7 @@
},
get: function (service, action) {
return CommandProxyMap[service]
? CommandProxyMap[service][action]
: null;
return CommandProxyMap[service] ? CommandProxyMap[service][action] : null;
},
};
});
@ -1202,10 +1109,7 @@
var pluginloader = require('cordova/pluginloader');
var utils = require('cordova/utils');
var platformInitChannelsArray = [
channel.onNativeReady,
channel.onPluginsReady,
];
var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
function logUnfiredChannels(arr) {
for (var i = 0; i < arr.length; ++i) {
@ -1255,14 +1159,10 @@
channel.onPause = cordova.addDocumentEventHandler('pause');
channel.onResume = cordova.addDocumentEventHandler('resume');
channel.onActivated = cordova.addDocumentEventHandler('activated');
channel.onDeviceReady =
cordova.addStickyDocumentEventHandler('deviceready');
channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
// Listen for DOMContentLoaded and notify our channel subscribers.
if (
document.readyState === 'complete' ||
document.readyState === 'interactive'
) {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
channel.onDOMContentLoaded.fire();
} else {
document.addEventListener(
@ -1328,12 +1228,7 @@
deprecationMap = {};
};
function addEntry(
strategy,
moduleName,
symbolPath,
opt_deprecationMessage,
) {
function addEntry(strategy, moduleName, symbolPath, opt_deprecationMessage) {
if (!(moduleName in moduleMap)) {
throw new Error('Module ' + moduleName + ' does not exist.');
}
@ -1344,11 +1239,7 @@
}
// Note: Android 2.3 does have Function.bind().
exports.clobbers = function (
moduleName,
symbolPath,
opt_deprecationMessage,
) {
exports.clobbers = function (moduleName, symbolPath, opt_deprecationMessage) {
addEntry('c', moduleName, symbolPath, opt_deprecationMessage);
};
@ -1356,11 +1247,7 @@
addEntry('m', moduleName, symbolPath, opt_deprecationMessage);
};
exports.defaults = function (
moduleName,
symbolPath,
opt_deprecationMessage,
) {
exports.defaults = function (moduleName, symbolPath, opt_deprecationMessage) {
addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
};
@ -1399,10 +1286,7 @@
var deprecationMsg =
symbolPath in deprecationMap
? 'Access made to deprecated symbol: ' +
symbolPath +
'. ' +
deprecationMsg
? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg
: null;
var parentObj = prepareNamespace(namespace, context);
var target = parentObj[lastName];
@ -1413,12 +1297,7 @@
if (!(symbolPath in origSymbols)) {
origSymbols[symbolPath] = target;
}
builder.assignOrWrapInDeprecateGetter(
parentObj,
lastName,
module,
deprecationMsg,
);
builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
}
}
};
@ -1441,7 +1320,7 @@
define('cordova/platform', function (require, exports, module) {
module.exports = {
id: Capacitor.platform,
id: window.Capacitor.getPlatform(),
bootstrap: function () {
require('cordova/channel').onNativeReady.fire();
},
@ -1578,12 +1457,7 @@
* Does a deep clone of the object.
*/
utils.clone = function (obj) {
if (
!obj ||
typeof obj === 'function' ||
utils.isDate(obj) ||
typeof obj !== 'object'
) {
if (!obj || typeof obj === 'function' || utils.isDate(obj) || typeof obj !== 'object') {
return obj;
}
@ -1602,11 +1476,7 @@
// https://issues.apache.org/jira/browse/CB-11522 'unknown' type may be returned in
// custom protocol activation case on Windows Phone 8.1 causing "No such interface supported" exception
// on cloning.
if (
(!(i in retVal) || retVal[i] !== obj[i]) &&
typeof obj[i] !== 'undefined' &&
typeof obj[i] !== 'unknown'
) {
if ((!(i in retVal) || retVal[i] !== obj[i]) && typeof obj[i] !== 'undefined' && typeof obj[i] !== 'unknown') {
// eslint-disable-line valid-typeof
retVal[i] = utils.clone(obj[i]);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -3,69 +3,6 @@
Object.defineProperty(exports, '__esModule', { value: true });
const createCapacitorPlatforms = (win) => {
const defaultPlatformMap = new Map();
defaultPlatformMap.set('web', { name: 'web' });
const capPlatforms = win.CapacitorPlatforms || {
currentPlatform: { name: 'web' },
platforms: defaultPlatformMap,
};
const addPlatform = (name, platform) => {
capPlatforms.platforms.set(name, platform);
};
const setPlatform = (name) => {
if (capPlatforms.platforms.has(name)) {
capPlatforms.currentPlatform = capPlatforms.platforms.get(name);
}
};
capPlatforms.addPlatform = addPlatform;
capPlatforms.setPlatform = setPlatform;
return capPlatforms;
};
const initPlatforms = (win) => (win.CapacitorPlatforms = createCapacitorPlatforms(win));
/**
* @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead
*/
const CapacitorPlatforms = /*#__PURE__*/ initPlatforms((typeof globalThis !== 'undefined'
? globalThis
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: {}));
/**
* @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead
*/
const addPlatform = CapacitorPlatforms.addPlatform;
/**
* @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead
*/
const setPlatform = CapacitorPlatforms.setPlatform;
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;
(function (ExceptionCode) {
/**
@ -106,23 +43,14 @@ const getPlatformId = (win) => {
};
const createCapacitor = (win) => {
var _a, _b, _c, _d, _e;
const capCustomPlatform = win.CapacitorCustomPlatform || null;
const cap = win.Capacitor || {};
const Plugins = (cap.Plugins = cap.Plugins || {});
/**
* @deprecated Use `capCustomPlatform` instead, default functions like registerPlugin will function with the new object.
*/
const capPlatforms = win.CapacitorPlatforms;
const defaultGetPlatform = () => {
return capCustomPlatform !== null
? capCustomPlatform.name
: getPlatformId(win);
const getPlatform = () => {
return capCustomPlatform !== null ? capCustomPlatform.name : getPlatformId(win);
};
const getPlatform = ((_a = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _a === void 0 ? void 0 : _a.getPlatform) || defaultGetPlatform;
const defaultIsNativePlatform = () => getPlatform() !== 'web';
const isNativePlatform = ((_b = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _b === void 0 ? void 0 : _b.isNativePlatform) || defaultIsNativePlatform;
const defaultIsPluginAvailable = (pluginName) => {
const isNativePlatform = () => getPlatform() !== 'web';
const isPluginAvailable = (pluginName) => {
const plugin = registeredPlugins.get(pluginName);
if (plugin === null || plugin === void 0 ? void 0 : plugin.platforms.has(getPlatform())) {
// JS implementation available for the current platform.
@ -134,16 +62,10 @@ const createCapacitor = (win) => {
}
return false;
};
const isPluginAvailable = ((_c = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _c === void 0 ? void 0 : _c.isPluginAvailable) ||
defaultIsPluginAvailable;
const defaultGetPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find(h => h.name === pluginName); };
const getPluginHeader = ((_d = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _d === void 0 ? void 0 : _d.getPluginHeader) || defaultGetPluginHeader;
const getPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find((h) => h.name === pluginName); };
const handleError = (err) => win.console.error(err);
const pluginMethodNoop = (_target, prop, pluginName) => {
return Promise.reject(`${pluginName} does not have an implementation of "${prop}".`);
};
const registeredPlugins = new Map();
const defaultRegisterPlugin = (pluginName, jsImplementations = {}) => {
const registerPlugin = (pluginName, jsImplementations = {}) => {
const registeredPlugin = registeredPlugins.get(pluginName);
if (registeredPlugin) {
console.warn(`Capacitor plugin "${pluginName}" already registered. Cannot register plugins twice.`);
@ -159,9 +81,7 @@ const createCapacitor = (win) => {
? (jsImplementation = await jsImplementations[platform]())
: (jsImplementation = jsImplementations[platform]);
}
else if (capCustomPlatform !== null &&
!jsImplementation &&
'web' in jsImplementations) {
else if (capCustomPlatform !== null && !jsImplementation && 'web' in jsImplementations) {
jsImplementation =
typeof jsImplementations['web'] === 'function'
? (jsImplementation = await jsImplementations['web']())
@ -172,7 +92,7 @@ const createCapacitor = (win) => {
const createPluginMethod = (impl, prop) => {
var _a, _b;
if (pluginHeader) {
const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find(m => prop === m.name);
const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find((m) => prop === m.name);
if (methodHeader) {
if (methodHeader.rtype === 'promise') {
return (options) => cap.nativePromise(pluginName, prop.toString(), options);
@ -195,7 +115,7 @@ const createCapacitor = (win) => {
const createPluginMethodWrapper = (prop) => {
let remove;
const wrapper = (...args) => {
const p = loadPluginImplementation().then(impl => {
const p = loadPluginImplementation().then((impl) => {
const fn = createPluginMethod(impl, prop);
if (fn) {
const p = fn(...args);
@ -231,7 +151,7 @@ const createCapacitor = (win) => {
callbackId,
}, callback);
};
const p = new Promise(resolve => call.then(() => resolve({ remove })));
const p = new Promise((resolve) => call.then(() => resolve({ remove })));
p.remove = async () => {
console.warn(`Using addListener() without 'await' is deprecated.`);
await remove();
@ -259,30 +179,22 @@ const createCapacitor = (win) => {
registeredPlugins.set(pluginName, {
name: pluginName,
proxy,
platforms: new Set([
...Object.keys(jsImplementations),
...(pluginHeader ? [platform] : []),
]),
platforms: new Set([...Object.keys(jsImplementations), ...(pluginHeader ? [platform] : [])]),
});
return proxy;
};
const registerPlugin = ((_e = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _e === void 0 ? void 0 : _e.registerPlugin) || defaultRegisterPlugin;
// Add in convertFileSrc for web, it will already be available in native context
if (!cap.convertFileSrc) {
cap.convertFileSrc = filePath => filePath;
cap.convertFileSrc = (filePath) => filePath;
}
cap.getPlatform = getPlatform;
cap.handleError = handleError;
cap.isNativePlatform = isNativePlatform;
cap.isPluginAvailable = isPluginAvailable;
cap.pluginMethodNoop = pluginMethodNoop;
cap.registerPlugin = registerPlugin;
cap.Exception = CapacitorException;
cap.DEBUG = !!cap.DEBUG;
cap.isLoggingEnabled = !!cap.isLoggingEnabled;
// Deprecated props
cap.platform = cap.getPlatform();
cap.isNative = cap.isNativePlatform();
return cap;
};
const initCapacitorGlobal = (win) => (win.Capacitor = createCapacitor(win));
@ -297,38 +209,15 @@ const Capacitor = /*#__PURE__*/ initCapacitorGlobal(typeof globalThis !== 'undef
? global
: {});
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);
/**
* Base class web plugins should extend.
*/
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;
}
}
addListener(eventName, listenerFunc) {
let firstListener = false;
@ -371,17 +260,18 @@ class WebPlugin {
}
return;
}
listeners.forEach(listener => listener(data));
listeners.forEach((listener) => listener(data));
}
hasListeners(eventName) {
return !!this.listeners[eventName].length;
var _a;
return !!((_a = this.listeners[eventName]) === null || _a === void 0 ? void 0 : _a.length);
}
registerWindowListener(windowEventName, pluginEventName) {
this.windowListeners[pluginEventName] = {
registered: false,
windowEventName,
pluginEventName,
handler: event => {
handler: (event) => {
this.notifyListeners(pluginEventName, event);
},
};
@ -422,7 +312,7 @@ class WebPlugin {
return;
}
delete this.retainedEventArguments[eventName];
args.forEach(arg => {
args.forEach((arg) => {
this.notifyListeners(eventName, arg);
});
}
@ -447,7 +337,7 @@ class CapacitorCookiesPluginWeb extends WebPlugin {
async getCookies() {
const cookies = document.cookie;
const cookieMap = {};
cookies.split(';').forEach(cookie => {
cookies.split(';').forEach((cookie) => {
if (cookie.length <= 0)
return;
// Replace first "=" with CAP_COOKIE to prevent splitting on additional "="
@ -466,9 +356,7 @@ class CapacitorCookiesPluginWeb extends WebPlugin {
// Clean & sanitize options
const expires = `; expires=${(options.expires || '').replace('expires=', '')}`; // Default is "; expires="
const path = (options.path || '/').replace('path=', ''); // Default is "path=/"
const domain = options.url != null && options.url.length > 0
? `domain=${options.url}`
: '';
const domain = options.url != null && options.url.length > 0 ? `domain=${options.url}` : '';
document.cookie = `${encodedKey}=${encodedValue || ''}${expires}; path=${path}; ${domain};`;
}
catch (error) {
@ -487,9 +375,7 @@ class CapacitorCookiesPluginWeb extends WebPlugin {
try {
const cookies = document.cookie.split(';') || [];
for (const cookie of cookies) {
document.cookie = cookie
.replace(/^ +/, '')
.replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);
document.cookie = cookie.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);
}
}
catch (error) {
@ -518,9 +404,7 @@ const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {
reader.onload = () => {
const base64String = reader.result;
// remove prefix "data:application/pdf;base64,"
resolve(base64String.indexOf(',') >= 0
? base64String.split(',')[1]
: base64String);
resolve(base64String.indexOf(',') >= 0 ? base64String.split(',')[1] : base64String);
};
reader.onerror = (error) => reject(error);
reader.readAsDataURL(blob);
@ -531,7 +415,7 @@ const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {
*/
const normalizeHttpHeaders = (headers = {}) => {
const originalKeys = Object.keys(headers);
const loweredKeys = Object.keys(headers).map(k => k.toLocaleLowerCase());
const loweredKeys = Object.keys(headers).map((k) => k.toLocaleLowerCase());
const normalized = loweredKeys.reduce((acc, key, index) => {
acc[key] = headers[originalKeys[index]];
return acc;
@ -552,7 +436,7 @@ const buildUrlParams = (params, shouldEncode = true) => {
let item;
if (Array.isArray(value)) {
item = '';
value.forEach(str => {
value.forEach((str) => {
encodedValue = shouldEncode ? encodeURIComponent(str) : str;
item += `${key}=${encodedValue}&`;
});
@ -590,8 +474,7 @@ const buildRequestInit = (options, extra = {}) => {
}
output.body = params.toString();
}
else if (type.includes('multipart/form-data') ||
options.data instanceof FormData) {
else if (type.includes('multipart/form-data') || options.data instanceof FormData) {
const form = new FormData();
if (options.data instanceof FormData) {
options.data.forEach((value, key) => {
@ -608,8 +491,7 @@ const buildRequestInit = (options, extra = {}) => {
headers.delete('content-type'); // content-type will be set by `window.fetch` to includy boundary
output.headers = headers;
}
else if (type.includes('application/json') ||
typeof options.data === 'object') {
else if (type.includes('application/json') || typeof options.data === 'object') {
output.body = JSON.stringify(options.data);
}
return output;
@ -705,13 +587,8 @@ exports.Capacitor = Capacitor;
exports.CapacitorCookies = CapacitorCookies;
exports.CapacitorException = CapacitorException;
exports.CapacitorHttp = CapacitorHttp;
exports.CapacitorPlatforms = CapacitorPlatforms;
exports.Plugins = Plugins;
exports.WebPlugin = WebPlugin;
exports.WebView = WebView;
exports.addPlatform = addPlatform;
exports.buildRequestInit = buildRequestInit;
exports.registerPlugin = registerPlugin;
exports.registerWebPlugin = registerWebPlugin;
exports.setPlatform = setPlatform;
//# sourceMappingURL=index.cjs.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,67 +1,4 @@
/*! Capacitor: https://capacitorjs.com/ - MIT License */
const createCapacitorPlatforms = (win) => {
const defaultPlatformMap = new Map();
defaultPlatformMap.set('web', { name: 'web' });
const capPlatforms = win.CapacitorPlatforms || {
currentPlatform: { name: 'web' },
platforms: defaultPlatformMap,
};
const addPlatform = (name, platform) => {
capPlatforms.platforms.set(name, platform);
};
const setPlatform = (name) => {
if (capPlatforms.platforms.has(name)) {
capPlatforms.currentPlatform = capPlatforms.platforms.get(name);
}
};
capPlatforms.addPlatform = addPlatform;
capPlatforms.setPlatform = setPlatform;
return capPlatforms;
};
const initPlatforms = (win) => (win.CapacitorPlatforms = createCapacitorPlatforms(win));
/**
* @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead
*/
const CapacitorPlatforms = /*#__PURE__*/ initPlatforms((typeof globalThis !== 'undefined'
? globalThis
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: {}));
/**
* @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead
*/
const addPlatform = CapacitorPlatforms.addPlatform;
/**
* @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead
*/
const setPlatform = CapacitorPlatforms.setPlatform;
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;
(function (ExceptionCode) {
/**
@ -102,23 +39,14 @@ const getPlatformId = (win) => {
};
const createCapacitor = (win) => {
var _a, _b, _c, _d, _e;
const capCustomPlatform = win.CapacitorCustomPlatform || null;
const cap = win.Capacitor || {};
const Plugins = (cap.Plugins = cap.Plugins || {});
/**
* @deprecated Use `capCustomPlatform` instead, default functions like registerPlugin will function with the new object.
*/
const capPlatforms = win.CapacitorPlatforms;
const defaultGetPlatform = () => {
return capCustomPlatform !== null
? capCustomPlatform.name
: getPlatformId(win);
const getPlatform = () => {
return capCustomPlatform !== null ? capCustomPlatform.name : getPlatformId(win);
};
const getPlatform = ((_a = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _a === void 0 ? void 0 : _a.getPlatform) || defaultGetPlatform;
const defaultIsNativePlatform = () => getPlatform() !== 'web';
const isNativePlatform = ((_b = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _b === void 0 ? void 0 : _b.isNativePlatform) || defaultIsNativePlatform;
const defaultIsPluginAvailable = (pluginName) => {
const isNativePlatform = () => getPlatform() !== 'web';
const isPluginAvailable = (pluginName) => {
const plugin = registeredPlugins.get(pluginName);
if (plugin === null || plugin === void 0 ? void 0 : plugin.platforms.has(getPlatform())) {
// JS implementation available for the current platform.
@ -130,16 +58,10 @@ const createCapacitor = (win) => {
}
return false;
};
const isPluginAvailable = ((_c = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _c === void 0 ? void 0 : _c.isPluginAvailable) ||
defaultIsPluginAvailable;
const defaultGetPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find(h => h.name === pluginName); };
const getPluginHeader = ((_d = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _d === void 0 ? void 0 : _d.getPluginHeader) || defaultGetPluginHeader;
const getPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find((h) => h.name === pluginName); };
const handleError = (err) => win.console.error(err);
const pluginMethodNoop = (_target, prop, pluginName) => {
return Promise.reject(`${pluginName} does not have an implementation of "${prop}".`);
};
const registeredPlugins = new Map();
const defaultRegisterPlugin = (pluginName, jsImplementations = {}) => {
const registerPlugin = (pluginName, jsImplementations = {}) => {
const registeredPlugin = registeredPlugins.get(pluginName);
if (registeredPlugin) {
console.warn(`Capacitor plugin "${pluginName}" already registered. Cannot register plugins twice.`);
@ -155,9 +77,7 @@ const createCapacitor = (win) => {
? (jsImplementation = await jsImplementations[platform]())
: (jsImplementation = jsImplementations[platform]);
}
else if (capCustomPlatform !== null &&
!jsImplementation &&
'web' in jsImplementations) {
else if (capCustomPlatform !== null && !jsImplementation && 'web' in jsImplementations) {
jsImplementation =
typeof jsImplementations['web'] === 'function'
? (jsImplementation = await jsImplementations['web']())
@ -168,7 +88,7 @@ const createCapacitor = (win) => {
const createPluginMethod = (impl, prop) => {
var _a, _b;
if (pluginHeader) {
const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find(m => prop === m.name);
const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find((m) => prop === m.name);
if (methodHeader) {
if (methodHeader.rtype === 'promise') {
return (options) => cap.nativePromise(pluginName, prop.toString(), options);
@ -191,7 +111,7 @@ const createCapacitor = (win) => {
const createPluginMethodWrapper = (prop) => {
let remove;
const wrapper = (...args) => {
const p = loadPluginImplementation().then(impl => {
const p = loadPluginImplementation().then((impl) => {
const fn = createPluginMethod(impl, prop);
if (fn) {
const p = fn(...args);
@ -227,7 +147,7 @@ const createCapacitor = (win) => {
callbackId,
}, callback);
};
const p = new Promise(resolve => call.then(() => resolve({ remove })));
const p = new Promise((resolve) => call.then(() => resolve({ remove })));
p.remove = async () => {
console.warn(`Using addListener() without 'await' is deprecated.`);
await remove();
@ -255,30 +175,22 @@ const createCapacitor = (win) => {
registeredPlugins.set(pluginName, {
name: pluginName,
proxy,
platforms: new Set([
...Object.keys(jsImplementations),
...(pluginHeader ? [platform] : []),
]),
platforms: new Set([...Object.keys(jsImplementations), ...(pluginHeader ? [platform] : [])]),
});
return proxy;
};
const registerPlugin = ((_e = capPlatforms === null || capPlatforms === void 0 ? void 0 : capPlatforms.currentPlatform) === null || _e === void 0 ? void 0 : _e.registerPlugin) || defaultRegisterPlugin;
// Add in convertFileSrc for web, it will already be available in native context
if (!cap.convertFileSrc) {
cap.convertFileSrc = filePath => filePath;
cap.convertFileSrc = (filePath) => filePath;
}
cap.getPlatform = getPlatform;
cap.handleError = handleError;
cap.isNativePlatform = isNativePlatform;
cap.isPluginAvailable = isPluginAvailable;
cap.pluginMethodNoop = pluginMethodNoop;
cap.registerPlugin = registerPlugin;
cap.Exception = CapacitorException;
cap.DEBUG = !!cap.DEBUG;
cap.isLoggingEnabled = !!cap.isLoggingEnabled;
// Deprecated props
cap.platform = cap.getPlatform();
cap.isNative = cap.isNativePlatform();
return cap;
};
const initCapacitorGlobal = (win) => (win.Capacitor = createCapacitor(win));
@ -293,38 +205,15 @@ const Capacitor = /*#__PURE__*/ initCapacitorGlobal(typeof globalThis !== 'undef
? global
: {});
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);
/**
* Base class web plugins should extend.
*/
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;
}
}
addListener(eventName, listenerFunc) {
let firstListener = false;
@ -367,17 +256,18 @@ class WebPlugin {
}
return;
}
listeners.forEach(listener => listener(data));
listeners.forEach((listener) => listener(data));
}
hasListeners(eventName) {
return !!this.listeners[eventName].length;
var _a;
return !!((_a = this.listeners[eventName]) === null || _a === void 0 ? void 0 : _a.length);
}
registerWindowListener(windowEventName, pluginEventName) {
this.windowListeners[pluginEventName] = {
registered: false,
windowEventName,
pluginEventName,
handler: event => {
handler: (event) => {
this.notifyListeners(pluginEventName, event);
},
};
@ -418,7 +308,7 @@ class WebPlugin {
return;
}
delete this.retainedEventArguments[eventName];
args.forEach(arg => {
args.forEach((arg) => {
this.notifyListeners(eventName, arg);
});
}
@ -443,7 +333,7 @@ class CapacitorCookiesPluginWeb extends WebPlugin {
async getCookies() {
const cookies = document.cookie;
const cookieMap = {};
cookies.split(';').forEach(cookie => {
cookies.split(';').forEach((cookie) => {
if (cookie.length <= 0)
return;
// Replace first "=" with CAP_COOKIE to prevent splitting on additional "="
@ -462,9 +352,7 @@ class CapacitorCookiesPluginWeb extends WebPlugin {
// Clean & sanitize options
const expires = `; expires=${(options.expires || '').replace('expires=', '')}`; // Default is "; expires="
const path = (options.path || '/').replace('path=', ''); // Default is "path=/"
const domain = options.url != null && options.url.length > 0
? `domain=${options.url}`
: '';
const domain = options.url != null && options.url.length > 0 ? `domain=${options.url}` : '';
document.cookie = `${encodedKey}=${encodedValue || ''}${expires}; path=${path}; ${domain};`;
}
catch (error) {
@ -483,9 +371,7 @@ class CapacitorCookiesPluginWeb extends WebPlugin {
try {
const cookies = document.cookie.split(';') || [];
for (const cookie of cookies) {
document.cookie = cookie
.replace(/^ +/, '')
.replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);
document.cookie = cookie.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);
}
}
catch (error) {
@ -514,9 +400,7 @@ const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {
reader.onload = () => {
const base64String = reader.result;
// remove prefix "data:application/pdf;base64,"
resolve(base64String.indexOf(',') >= 0
? base64String.split(',')[1]
: base64String);
resolve(base64String.indexOf(',') >= 0 ? base64String.split(',')[1] : base64String);
};
reader.onerror = (error) => reject(error);
reader.readAsDataURL(blob);
@ -527,7 +411,7 @@ const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {
*/
const normalizeHttpHeaders = (headers = {}) => {
const originalKeys = Object.keys(headers);
const loweredKeys = Object.keys(headers).map(k => k.toLocaleLowerCase());
const loweredKeys = Object.keys(headers).map((k) => k.toLocaleLowerCase());
const normalized = loweredKeys.reduce((acc, key, index) => {
acc[key] = headers[originalKeys[index]];
return acc;
@ -548,7 +432,7 @@ const buildUrlParams = (params, shouldEncode = true) => {
let item;
if (Array.isArray(value)) {
item = '';
value.forEach(str => {
value.forEach((str) => {
encodedValue = shouldEncode ? encodeURIComponent(str) : str;
item += `${key}=${encodedValue}&`;
});
@ -586,8 +470,7 @@ const buildRequestInit = (options, extra = {}) => {
}
output.body = params.toString();
}
else if (type.includes('multipart/form-data') ||
options.data instanceof FormData) {
else if (type.includes('multipart/form-data') || options.data instanceof FormData) {
const form = new FormData();
if (options.data instanceof FormData) {
options.data.forEach((value, key) => {
@ -604,8 +487,7 @@ const buildRequestInit = (options, extra = {}) => {
headers.delete('content-type'); // content-type will be set by `window.fetch` to includy boundary
output.headers = headers;
}
else if (type.includes('application/json') ||
typeof options.data === 'object') {
else if (type.includes('application/json') || typeof options.data === 'object') {
output.body = JSON.stringify(options.data);
}
return output;
@ -697,5 +579,5 @@ const CapacitorHttp = registerPlugin('CapacitorHttp', {
});
/******** END HTTP PLUGIN ********/
export { Capacitor, CapacitorCookies, CapacitorException, CapacitorHttp, CapacitorPlatforms, ExceptionCode, Plugins, WebPlugin, WebView, addPlatform, buildRequestInit, registerPlugin, registerWebPlugin, setPlatform };
export { Capacitor, CapacitorCookies, CapacitorException, CapacitorHttp, ExceptionCode, WebPlugin, WebView, buildRequestInit, registerPlugin };
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "@capacitor/core",
"version": "6.1.2",
"version": "7.4.1",
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
"homepage": "https://capacitorjs.com",
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",

View file

@ -1,5 +1,4 @@
import type { CapacitorGlobal, PluginCallback, PluginResultData, PluginResultError } from './definitions';
import type { CapacitorPlatformsInstance } from './platforms';
export interface PluginHeaderMethod {
readonly name: string;
readonly rtype?: 'promise' | 'callback';
@ -126,10 +125,6 @@ export interface WindowCapacitor {
CapacitorHttpAndroidInterface?: any;
CapacitorWebFetch?: any;
CapacitorWebXMLHttpRequest?: any;
/**
* @deprecated Use `CapacitorCustomPlatform` instead
*/
CapacitorPlatforms?: CapacitorPlatformsInstance;
CapacitorCustomPlatform?: CapacitorCustomPlatformInstance;
Ionic?: {
WebView?: {

View file

@ -1,4 +1,3 @@
import type { PluginRegistry } from './legacy/legacy-definitions';
import type { CapacitorException } from './util';
export interface CapacitorGlobal {
/**
@ -35,25 +34,6 @@ export interface CapacitorGlobal {
removeListener?: (pluginName: string, callbackId: string, eventName: string, callback: PluginCallback) => void;
DEBUG?: boolean;
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;
}
/**
* Register plugin implementations with Capacitor.

View file

@ -1,21 +1,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;

View file

@ -1,9 +1,6 @@
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 { CapacitorCookies, CapacitorHttp, WebView, buildRequestInit, } from './core-plugins';
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';

View file

@ -1,37 +0,0 @@
/**
* @deprecated
*/
export interface PluginRegistry {
[pluginName: string]: {
[prop: string]: any;
};
}
/**
* @deprecated
*/
export interface PluginConfig {
id: string;
name: string;
}
/**
* @deprecated
*/
export type ISODateString = string;
/**
* @deprecated
*/
export type CallbackID = string;
/**
* CancellableCallback is a simple wrapper that a method will
* return to make it easy to cancel any repeated callback the method
* might have set up. For example: a geolocation watch.
* @deprecated
*/
export interface CancellableCallback {
/**
* The cancel function for this method
*
* @deprecated
*/
cancel: (...args: any[]) => any;
}

View file

@ -1,3 +0,0 @@
import type { CapacitorGlobal } from '../definitions';
import type { WebPlugin } from '../web-plugin';
export declare const legacyRegisterWebPlugin: (cap: CapacitorGlobal, webPlugin: WebPlugin) => void;

View file

@ -1,28 +0,0 @@
import type { PluginImplementations } from './definitions';
import type { PluginHeader } from './definitions-internal';
export interface CapacitorPlatform {
name: string;
getPlatform?(): string;
isPluginAvailable?(pluginName: string): boolean;
getPluginHeader?(pluginName: string): PluginHeader | undefined;
registerPlugin?(pluginName: string, jsImplementations: PluginImplementations): any;
isNativePlatform?(): boolean;
}
export interface CapacitorPlatformsInstance {
currentPlatform: CapacitorPlatform;
platforms: Map<string, CapacitorPlatform>;
addPlatform(name: string, platform: CapacitorPlatform): void;
setPlatform(name: string): void;
}
/**
* @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead
*/
export declare const CapacitorPlatforms: CapacitorPlatformsInstance;
/**
* @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead
*/
export declare const addPlatform: (name: string, platform: CapacitorPlatform) => void;
/**
* @deprecated Set `CapacitorCustomPlatform` on the window object prior to runtime executing in the web app instead
*/
export declare const setPlatform: (name: string) => void;

View file

@ -4,10 +4,6 @@ import type { CapacitorException } from './util';
* Base class web plugins should extend.
*/
export declare class WebPlugin implements Plugin {
/**
* @deprecated WebPluginConfig deprecated in v3 and will be removed in v4.
*/
config?: WebPluginConfig;
protected listeners: {
[eventName: string]: ListenerCallback[];
};
@ -17,7 +13,6 @@ export declare class WebPlugin implements Plugin {
protected windowListeners: {
[eventName: string]: WindowListenerHandle;
};
constructor(config?: WebPluginConfig);
addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle>;
removeAllListeners(): Promise<void>;
protected notifyListeners(eventName: string, data: any, retainUntilConsumed?: boolean): void;
@ -37,16 +32,3 @@ export interface WindowListenerHandle {
pluginEventName: string;
handler: (event: any) => 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[];
}