Skip to content

Commit

Permalink
Release 0.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ChugunovRoman committed Aug 3, 2019
2 parents e7dcac6 + b70f80e commit b20413c
Show file tree
Hide file tree
Showing 16 changed files with 155 additions and 115 deletions.
29 changes: 29 additions & 0 deletions @types/common/menu.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
declare namespace Menu {
/**
* Import Electron types
*/
type _MenuItemConstructorOptions = import('electron').MenuItemConstructorOptions;
type _MenuItem = import('electron').MenuItem;
type _BrowserWindow = import('electron').BrowserWindow;

type NativeClick = (item: _MenuItem, window: _BrowserWindow, event: Event) => void;
type CutsomClick = (item: _MenuItemConstructorOptions, window: _BrowserWindow, event: Event) => void;

interface ParamsId {
id: string;
click?: NativeClick | CutsomClick
}
interface ParamsAction {
action: string;
click?: NativeClick | CutsomClick
}
interface ParamsCommand {
command: string;
click?: NativeClick | CutsomClick
}

/**
* Public types
*/
type Params = ParamsId | ParamsAction | ParamsCommand;
}
16 changes: 16 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ declare namespace Electron {
app: App;
}

interface MenuItem {
click: (item: MenuItemConstructorOptions, window: BrowserWindow, event: Event) => void;
}

interface App extends EventEmitter {
on(event: 'updateActionState', listener: (state: Object) => void): this;
once(event: 'updateActionState', listener: (state: Object) => void): this;
Expand Down Expand Up @@ -39,4 +43,16 @@ declare namespace Electron {
addListener(event: 'setDisableFonts', listener: (disabled: boolean) => void): this;
removeListener(event: 'setDisableFonts', listener: (disabled: boolean) => void): this;
}

interface IpcMain extends EventEmitter {
on(channel: string, listener: Function): this;
once(channel: string, listener: Function): this;
removeAllListeners(channel: string): this;
removeListener(channel: string, listener: Function): this;

on(channel: 'setTitle', listener: (event: Event, title: string, id: number) => void): this;
once(channel: 'setTitle', listener: (event: Event, title: string, id: number) => void): this;
removeAllListeners(channel: 'setTitle'): this;
removeListener(channel: 'setTitle', listener: (event: Event, title: string, id: number) => void): this;
}
}
4 changes: 2 additions & 2 deletions @types/renderer/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
version: number;
fileBrowser: boolean;

postMessage(name: string, args?: any, transferList?: Array<string>): void;
promiseMessage(name: string, args?: any, transferList?: Array<string>): Promise<void>
postMessage(name: string, args?: any, transferList?: Transferable[]): void;
promiseMessage(name: string, args?: any, transferList?: Transferable[]): Promise<void>
setMessageHandler(handler: Function): void;
};

Expand Down
70 changes: 35 additions & 35 deletions config/builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,41 @@
"systemIntegration": "doNotAsk"
},

"snap": {
"plugs": [
{
"personal-files": {
"interface": "personal-files",
"allow-auto-connection": true,
// "allow-sandbox": true,
"read": [
"$HOME/.config",
"$HOME/.fonts",
"$HOME/.local/share/fonts",
"$HOME/snap/figma-linux/x1/.config/figma-linux/Settings"
],
"write": [
"$HOME/.config",
"$HOME/.fonts",
"$HOME/.local/share/fonts",
"$HOME/snap/figma-linux/x1/.config/figma-linux/Settings"
]
}
},
"desktop",
"desktop-legacy",
"home",
"x11",
"unity7",
"browser-support",
"network",
"gsettings",
"pulseaudio",
"opengl",
"gsettings",
"block-devices"
]
},
// "snap": {
// "plugs": [
// {
// "personal-files": {
// "interface": "personal-files",
// "allow-auto-connection": true,
// // "allow-sandbox": true,
// "read": [
// "$HOME/.config",
// "$HOME/.fonts",
// "$HOME/.local/share/fonts",
// "$HOME/snap/figma-linux/x1/.config/figma-linux/Settings"
// ],
// "write": [
// "$HOME/.config",
// "$HOME/.fonts",
// "$HOME/.local/share/fonts",
// "$HOME/snap/figma-linux/x1/.config/figma-linux/Settings"
// ]
// }
// },
// "desktop",
// "desktop-legacy",
// "home",
// "x11",
// "unity7",
// "browser-support",
// "network",
// "gsettings",
// "pulseaudio",
// "opengl",
// "gsettings",
// "block-devices"
// ]
// },

"linux": {
"description": "Unofficial desktop application for linux",
Expand Down
43 changes: 21 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "figma-linux",
"version": "0.5.1",
"version": "0.5.3",
"description": "Figma is the first interface design tool based in the browser, making it easier for teams to create software.",
"main": "src/main/index.js",
"repository": "git@github.com:ChugunovRoman/figma-linux.git",
Expand All @@ -12,7 +12,8 @@
"start": "electron dist/main/main.js",
"build": "rm -rf ./dist; electron-webpack app; rm -rf dist/main/dest dist/renderer/dest dist/**/*.map dist/**/*.bak dist/renderer/index.html dist/.renderer-index-template.html dist/package-lock.json",
"builder": "electron-builder --config=config/builder.json -l",
"pack": "rm -rf build/installers && npm run build && npm run builder"
"pack": "rm -rf build/installers && npm run build && npm run builder",
"postinstall": "npm i figma-linux-bindings"
},
"electronWebpack": {
"main": {
Expand All @@ -24,8 +25,8 @@
},
"dependencies": {
"electron-devtools-installer": "^2.2.4",
"electron-settings": "^3.2.0",
"figma-linux-bindings": "^0.1.15",
"electron-settings": "github:ChugunovRoman/electron-settings#figma-linux",
"figma-linux-bindings": "^0.1.18",
"mobx": "^5.6.0",
"mobx-react": "^5.4.2",
"mobx-state-router": "^4.0.3",
Expand Down Expand Up @@ -53,7 +54,7 @@
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.5.2",
"css-loader": "^0.28.11",
"electron": "^4.1.5",
"electron": "^4.2.8",
"electron-builder": "^20.40.2",
"electron-rebuild": "^1.8.2",
"electron-webpack": "^2.6.1",
Expand All @@ -65,7 +66,7 @@
"sass-loader": "^7.0.3",
"style-loader": "^0.21.0",
"ts-loader": "^4.4.2",
"typescript": "^2.9.2",
"typescript": "^3.5.3",
"webpack": "^4.14.0",
"webpack-cli": "2.1.5"
},
Expand Down
2 changes: 1 addition & 1 deletion src/main/Commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export default class Commander {
private constructor() {}

public static exec(id: string, ...args: any[]) {
commands().get(id)(args);
commands().get(id)(...args);
}
}
2 changes: 0 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import appInit from "./App";
// Catch unhandling unexpected exceptions
process.on('uncaughtException', (error: Error) => {
console.error(`uncaughtException: `, error);
process.exit(1)
});

// Catch unhandling rejected promises
process.on('unhandledRejection', (reason: any) => {
console.error(`unhandledRejection: `, reason);
process.exit(1)
});

appInit();
10 changes: 10 additions & 0 deletions src/main/window/Tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ export default class Tabs {

public static getAll = (): Array<E.BrowserView> => Tabs.tabs;

public static getByWebContentId = (id: number): E.BrowserView | undefined => {
for (const tab of Tabs.tabs) {
if (tab.webContents.id === id) {
return tab;
}
}

return undefined;
};

}
25 changes: 6 additions & 19 deletions src/main/window/WindowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,6 @@ class WindowManager {
return WindowManager._instance;
}

reloadAllWindows = () => { }

getZoom = (): Promise<number> => new Promise((resolve) => {
this.mainWindow.webContents.getZoomFactor(z => resolve(z));
});

setZoom = (zoom: number) => {
const tabs = Tabs.getAll();

this.mainWindow.webContents.setZoomFactor(zoom);

tabs.forEach(t => t.webContents.setZoomFactor(zoom));
};

openUrl = (url: string) => {
if (/figma:\/\//.test(url)) {
this.addTab('loadContetnt.js', url.replace(/figma:\//, Const.HOMEPAGE));
Expand Down Expand Up @@ -173,13 +159,14 @@ class WindowManager {
E.ipcMain.on(Const.CLOSEALLTAB, () => {
console.log('Close all tab');
});
E.ipcMain.on('setTitle', (event, title) => {
const tab = Tabs.getByWebContentId(event.sender.id);

E.ipcMain.on(Const.SETTITLE, (event: Event, title: string) => {
const view = this.mainWindow.getBrowserView();

if (!view) return;
if (!tab) {
return;
}

this.mainWindow.webContents.send(Const.SETTITLE, { id: view.id, title })
this.mainWindow.webContents.send(Const.SETTITLE, { id: tab.id, title })
});
E.ipcMain.on(Const.SETTABURL, (event: Event, url: string) => {
const view = this.mainWindow.getBrowserView();
Expand Down

0 comments on commit b20413c

Please sign in to comment.