Skip to content

Commit

Permalink
Merge branch 'main-capacitor5' into merge-cap2
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
#	src/plugin/core/Plugin.ts
#	src/plugin/factory.ts
  • Loading branch information
maximzhemerenko committed Aug 31, 2024
2 parents c23ea0d + f06b4f8 commit c33cd4c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spryrocks/capacitor-socket-connection-plugin",
"version": "2.3.0-alpha.5",
"version": "2.3.0-alpha.6",
"description": "Capacitor Socket Connection Plugin",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
17 changes: 17 additions & 0 deletions src/plugin/core/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,20 @@ export type Plugin = {
};

export {Plugins};

type PluginImplementation = unknown;
type PluginRegistration = () => PluginImplementation;

type CreatePlugin = <TPlugin>(
pluginName: string,
options?: {web?: PluginRegistration},
) => TPlugin;

export const createPlugin: CreatePlugin = <TPlugin>(
pluginName: string,
options?: {web?: PluginRegistration},
): TPlugin => {
return registerPlugin<TPlugin>(pluginName, {web: options?.web});
};

export {Plugin};
17 changes: 1 addition & 16 deletions src/plugin/factory.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
import {Plugin, Plugins} from './core/index';
import {createPlugin, Plugin} from './core/index';
import type {ICapacitorSocketConnectionDefinitions} from './definitions';

const pluginName = 'CapacitorSocketConnectionPlugin';

export type PluginImplementation = unknown;
export type PluginRegistration = () => PluginImplementation;

export type CreatePlugin = <TPlugin>(
pluginName: string,
options?: {web?: PluginRegistration},
) => TPlugin;

export const createPlugin: CreatePlugin = <TPlugin>(
pluginName: string,
_?: {web?: PluginRegistration},
): TPlugin => {
return Plugins[pluginName] as TPlugin;
};

const plugin = createPlugin<ICapacitorSocketConnectionDefinitions & Plugin>(pluginName);

export {plugin as NativePlugin};

0 comments on commit c33cd4c

Please sign in to comment.