Skip to content
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
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
patreon: zen_browser
ko_fi: zen_browser
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# plugin
📦 A plugin library interface for typescript projects
# Plugin Library Interface

📦 A plugin library interface for TypeScript projects.
40 changes: 24 additions & 16 deletions lib/main.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export interface IZenPlugin {
name: string;
version: string;
Expand Down Expand Up @@ -37,23 +36,31 @@ export interface ISandboxedTab {
readonly isSelected: boolean;
}

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 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 IPluginEvent<T extends IPluginEventKey> = (props: IPluginEventProps<T>) => void;

export type IPluginEvents = {
[K in IPluginEventKey]?: IPluginEvent<K>;
};
Expand All @@ -69,6 +76,7 @@ export type IPluginContextMenu = {
};

export type IPluginSettings = IPluginSetting[];

export default IZenPlugin;

// API
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down