This commit is contained in:
blu3 2025-02-07 13:03:05 +03:00 committed by GitHub
commit c6fde6dfff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 36 additions and 19 deletions

2
.github/FUNDING.yml vendored Normal file
View file

@ -0,0 +1,2 @@
patreon: zen_browser
ko_fi: zen_browser

6
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2024 Zen Browser
Copyright (c) 2025 Zen Browser
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1,2 +1,3 @@
# plugin
📦 A plugin library interface for typescript projects
# Plugin Library Interface
📦 A plugin library interface for TypeScript projects.

38
lib/main.d.ts vendored
View file

@ -1,4 +1,3 @@
export interface IZenPlugin {
name: string;
version: string;
@ -37,23 +36,31 @@ export interface ISandboxedTab {
readonly isSelected: boolean;
}
export type IPluginEventKey = "onInit" | "onUnload" | "onTabChange" | "onTabClose"
| "onTabOpen" | "onWorkspaceChange" | "onWorkspaceClose"
| "onWorkspaceOpen" | "onPreferencesChange";
export type IPluginEventKey =
| "onInit"
| "onUnload"
| "onTabChange"
| "onTabClose"
| "onTabOpen"
| "onWorkspaceChange"
| "onWorkspaceClose"
| "onWorkspaceOpen"
| "onPreferencesChange";
export type IPluginEventProps<T extends IPluginEventKey> =
T extends "onInit" ? { }
: T extends "onUnload" ? { }
: T extends "onTabChange" ? { tabId: string }
: T extends "onTabClose" ? { tabId: string }
: T extends "onTabOpen" ? { tabId: string }
: T extends "onWorkspaceChange" ? { workspace: IWorkspace }
: T extends "onWorkspaceClose" ? { workspace: IWorkspace }
: T extends "onWorkspaceOpen" ? { workspace: IWorkspace }
: T extends "onPreferencesChange" ? { settings: IPluginSettings }
: never;
export type IPluginEventProps<T extends IPluginEventKey> =
T extends "onInit" ? {} :
T extends "onUnload" ? {} :
T extends "onTabChange" ? { tabId: string } :
T extends "onTabClose" ? { tabId: string } :
T extends "onTabOpen" ? { tabId: string } :
T extends "onWorkspaceChange" ? { workspace: IWorkspace } :
T extends "onWorkspaceClose" ? { workspace: IWorkspace } :
T extends "onWorkspaceOpen" ? { workspace: IWorkspace } :
T extends "onPreferencesChange" ? { settings: IPluginSettings } :
never;
export type IPluginEvent<T extends IPluginEventKey> = (props: IPluginEventProps<T>) => void;
export type IPluginEvents = {
[K in IPluginEventKey]?: IPluginEvent<K>;
};
@ -69,6 +76,7 @@ export type IPluginContextMenu = {
};
export type IPluginSettings = IPluginSetting[];
export default IZenPlugin;
// API

View file

@ -1,7 +1,7 @@
{
"name": "plugin",
"version": "1.0.0",
"description": "📦 A plugin library interface for typescript projects",
"description": "📦 A plugin library interface for TypeScript projects",
"types": "./lib/main.d.ts",
"repository": {
"type": "git",