1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-25 08:33:27 +03:00
tabby/HACKING.md

148 lines
4.6 KiB
Markdown
Raw Normal View History

2017-06-21 00:28:58 +03:00
# Some background
2021-06-30 00:57:04 +03:00
Tabby is an Electron app, with the frontend written in Typescript with the help of Angular framework. It's built using Webpack.
2017-06-21 00:28:58 +03:00
# Getting started
First of all, clone this repository.
2017-06-21 00:28:58 +03:00
# Install Dependencies
- [Node.js](https://nodejs.org/en/download/) **version 15 or newer*
- [Yarn](https://yarnpkg.com/)
First, from within the `tabby` directory install the dependencies via yarn:
2017-06-21 00:28:58 +03:00
```
# macOS & Windows:
2021-02-23 15:51:48 +03:00
yarn
2021-06-27 20:08:18 +03:00
```
2017-06-21 00:28:58 +03:00
2021-06-27 20:08:18 +03:00
```
2021-07-08 23:03:03 +03:00
# Linux (Debian/Ubuntu here as an example)
2021-07-08 19:46:44 +03:00
sudo apt install libfontconfig-dev libsecret-1-dev libarchive-tools libnss3 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm1 cmake
2021-06-27 20:08:18 +03:00
yarn
```
_⚠Note: If you forked this repository, you may need to pull down the tags from this repository before installing node modules. `git pull --tags upstream master`_
Build Tabby:
2017-06-21 00:28:58 +03:00
```
2021-02-23 15:51:48 +03:00
yarn run build
2017-06-21 00:28:58 +03:00
```
Start Tabby
2017-06-21 00:28:58 +03:00
```
2021-02-23 15:51:48 +03:00
yarn start
2017-06-21 00:28:58 +03:00
```
2021-06-27 20:08:18 +03:00
# Building an installer
To build an installer, first complete a "normal" build as described above and then run:
```
node scripts/prepackage-plugins.mjs
2021-06-27 20:08:18 +03:00
node scripts/build-windows.mjs
2021-06-27 20:08:18 +03:00
# or
node scripts/build-linux.mjs
2021-06-27 20:08:18 +03:00
# or
node scripts/build-macos.mjs
2021-06-27 20:08:18 +03:00
```
The artifacts will be produced in the `dist` folder.
2017-06-21 00:28:58 +03:00
# Project layout
```
2021-06-30 00:57:04 +03:00
tabby
2017-06-21 00:28:58 +03:00
├─ app # Electron app, just the bare essentials
| ├─ src # Electron renderer code
| └─ main.js # Electron main entry point
├─ build
├─ clink # Clink distributive, for Windows
├─ scripts # Maintenance scripts
2021-06-30 00:57:04 +03:00
├─ tabby-community-color-schemes # Plugin that provides color schemes
├─ tabby-core # Plugin that provides base UI and tab management
├─ tabby-electron # Plugin that provides Electron-specific functions
├─ tabby-local # Plugin that provides local shells and profiles
├─ tabby-plugin-manager # Plugin that installs other plugins
├─ tabby-settings # Plugin that provides the settings tab
├─ tabby-terminal # Plugin that provides terminal tabs
└─ tabby-web # Plugin that provides web-specific functions
2017-06-21 00:28:58 +03:00
```
# Plugin layout
```
2021-06-30 00:57:04 +03:00
tabby-pluginname
2017-06-21 00:28:58 +03:00
├─ src # Typescript code
| ├─ components # Angular components
| | ├─ foo.component.ts # Code
| | ├─ foo.component.scss # Styles
| | └─ foo.component.pug # Template
| ├─ services # Angular services
| | └─ foo.service.ts
| ├─ api.ts # Publicly exported API
| └─ index.ts # Module entry point
├─ package.json
├─ tsconfig.json
└─ webpack.config.js
2017-06-21 00:28:58 +03:00
```
# Plugins
2021-06-30 00:57:04 +03:00
The app will load all plugins from the source checkout in the dev mode, from the user's plugins directory at all times (click `Open Plugins Directory` under `Settings` > `Plugins`) and from the directory specified by the `TABBY_PLUGINS` environment var.
2017-06-21 00:28:58 +03:00
2021-06-30 00:57:04 +03:00
Only modules whose `package.json` file contains a `tabby-plugin` keyword will be loaded.
2017-07-01 15:13:07 +03:00
2021-06-30 00:57:04 +03:00
If you're currently in your plugin's directory, start Tabby as `TABBY_PLUGINS=$(pwd) tabby --debug`
2017-07-01 15:13:07 +03:00
2017-06-21 00:28:58 +03:00
A plugin should only provide a default export, which should be a `NgModule` class (or a `NgModuleWithDependencies` where applicable). This module will be injected as a dependency to the app's root module.
```javascript
import { NgModule } from '@angular/core'
@NgModule()
export default class MyModule {
constructor () {
console.log('Angular engaged, cap\'n.')
}
}
```
Plugins provide functionality by exporting singular or multi providers:
```javascript
import { NgModule, Injectable } from '@angular/core'
2021-06-30 00:57:04 +03:00
import { ToolbarButtonProvider, ToolbarButton } from 'tabby-core'
2017-06-21 00:28:58 +03:00
@Injectable()
export class MyButtonProvider extends ToolbarButtonProvider {
2019-06-15 00:47:48 +03:00
provide (): ToolbarButton[] {
2017-06-21 00:28:58 +03:00
return [{
icon: 'star',
title: 'Foobar',
weight: 10,
click: () => {
alert('Woohoo!')
}
}]
}
}
@NgModule({
providers: [
{ provide: ToolbarButtonProvider, useClass: MyButtonProvider, multi: true },
],
})
export default class MyModule { }
```
2021-06-30 00:57:04 +03:00
See `tabby-core/src/api.ts`, `tabby-settings/src/api.ts`, `tabby-local/src/api.ts` and `tabby-terminal/src/api.ts` for the available extension points.
2021-09-07 00:38:55 +03:00
Also check out [the example plugin](https://github.com/Eugeny/tabby-clippy).
2021-06-30 00:57:04 +03:00
Publish your plugin on NPM with a `tabby-plugin` keyword to make it appear in the Plugin Manager.