Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core)!: Remove deprecated plugin methods/properties #7749

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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