Skip to content

Commit

Permalink
refactor(core)!: Remove deprecated plugin methods/properties (#7749)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Nov 18, 2024
1 parent 8b01b2b commit 33bfcbc
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 398 deletions.
16 changes: 0 additions & 16 deletions core/src/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { PluginRegistry } from './legacy/legacy-definitions';
import type { CapacitorException } from './util';

export interface CapacitorGlobal {
Expand Down Expand Up @@ -44,21 +43,6 @@ export interface CapacitorGlobal {

DEBUG?: boolean;
isLoggingEnabled?: boolean;

// Deprecated in v3, will be removed from v4

/**
* @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>;
}

/**
Expand Down
22 changes: 0 additions & 22 deletions core/src/global.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { legacyRegisterWebPlugin } from './legacy/legacy-web-plugin-merge';
import { initCapacitorGlobal } from './runtime';
import type { WebPlugin } from './web-plugin';

export const Capacitor = /*#__PURE__*/ initCapacitorGlobal(
typeof globalThis !== 'undefined'
Expand All @@ -15,23 +13,3 @@ export const Capacitor = /*#__PURE__*/ initCapacitorGlobal(
);

export 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.
*/
export 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.
*/
export const registerWebPlugin = (plugin: WebPlugin): void => legacyRegisterWebPlugin(Capacitor, plugin);
14 changes: 1 addition & 13 deletions core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export { CapacitorPlatforms, addPlatform, setPlatform } from './platforms';
export { Capacitor, registerPlugin } from './global';

// Base WebPlugin
export { WebPlugin, WebPluginConfig, ListenerCallback } from './web-plugin';
export { WebPlugin, ListenerCallback } from './web-plugin';

// Core Plugins APIs
export { CapacitorCookies, CapacitorHttp, WebView, buildRequestInit } from './core-plugins';
Expand All @@ -38,15 +38,3 @@ export type {

// Constants
export { CapacitorException, ExceptionCode } from './util';

// Legacy Global APIs
export { Plugins, registerWebPlugin } from './global';

// Legacy Type Definitions
export type {
CallbackID,
CancellableCallback,
ISODateString,
PluginConfig,
PluginRegistry,
} from './legacy/legacy-definitions';
41 changes: 0 additions & 41 deletions core/src/legacy/legacy-definitions.ts

This file was deleted.

28 changes: 0 additions & 28 deletions core/src/legacy/legacy-web-plugin-merge.ts

This file was deleted.

5 changes: 0 additions & 5 deletions core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ export const createCapacitor = (win: WindowCapacitor): CapacitorInstance => {

const handleError = (err: Error) => win.console.error(err);

const pluginMethodNoop = (_target: any, prop: PropertyKey, pluginName: string) => {
return Promise.reject(`${pluginName} does not have an implementation of "${prop as any}".`);
};

const registeredPlugins = new Map<string, RegisteredPlugin>();

const defaultRegisterPlugin = (pluginName: string, jsImplementations: PluginImplementations = {}): any => {
Expand Down Expand Up @@ -214,7 +210,6 @@ export const createCapacitor = (win: WindowCapacitor): CapacitorInstance => {
cap.handleError = handleError;
cap.isNativePlatform = isNativePlatform;
cap.isPluginAvailable = isPluginAvailable;
cap.pluginMethodNoop = pluginMethodNoop;
cap.registerPlugin = registerPlugin;
cap.Exception = CapacitorException;
cap.DEBUG = !!cap.DEBUG;
Expand Down
180 changes: 0 additions & 180 deletions core/src/tests/legacy.spec.ts

This file was deleted.

Loading

0 comments on commit 33bfcbc

Please sign in to comment.