Skip to content

Commit

Permalink
Merge branch 'figma#52'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChugunovRoman committed Aug 22, 2019
2 parents b20413c + 5147ab6 commit d2d94da
Show file tree
Hide file tree
Showing 65 changed files with 3,347 additions and 858 deletions.
File renamed without changes.
72 changes: 72 additions & 0 deletions @types/Common/menu.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
declare namespace Menu {
/**
* Import Electron types
*/
type _MenuItemConstructorOptions = import('electron').MenuItemConstructorOptions;
type _MenuItem = import('electron').MenuItem;
type _BrowserWindow = import('electron').BrowserWindow;

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

type Params = ParamsId | ParamsAction | ParamsCommand;
type MenuItem = Items.MenuName & Items.PluginItem & Items.Separator & Items.Submenu & Items.Menu & Items.StringKey;

type MenuAction = {
type: string;
};

type PluginMenuItem = PluginMenuItemOptions & _MenuItemConstructorOptions;

namespace Items {
interface MenuName {
type: string;
key: string;
string: string;
plugin: string;
}

interface Separator {
type: 'separator';
}
interface Submenu {
type: 'submenu'
name: string;
submenu: [MenuName & Separator & Submenu & Menu & PluginItem & StringKey];
}
interface Menu {
disabled?: boolean;
type: 'run-menu-action';
menuAction: MenuAction;
name: MenuName
}
interface PluginItem {
type: 'plugin-name';
plugin: string;
}
interface StringKey {
type: 'string-key';
string: string;
}
}

interface PluginMenuItemOptions {
pluginMenuAction?: MenuAction;
}

interface ParamsId {
id: string;
click?: NativeClick | CutsomClick
}
interface ParamsAction {
action: string;
click?: NativeClick | CutsomClick
}
interface ParamsCommand {
command: string;
click?: NativeClick | CutsomClick
}
}
8 changes: 8 additions & 0 deletions @types/Main/extension.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare namespace Extensions {
interface Extension {
id: number;
path: string;
lastKnownName: string;
manifestPath: string;
}
}
10 changes: 10 additions & 0 deletions @types/Main/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
declare namespace MenuState {
interface State {
[name: string]: boolean;
}

interface MenuStateParams {
actionState?: State;
pluginMenuData?: Menu.MenuItem[];
}
}
6 changes: 6 additions & 0 deletions @types/Main/request.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare namespace Request {
interface Responce {
url: string;
data: string;
}
}
12 changes: 12 additions & 0 deletions @types/Main/resources.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
declare namespace Resources {
interface File {
name: string;
data: Promise<string | void>;
}

interface Page {
url: string;
data: string;
links: string[];
}
}
1 change: 1 addition & 0 deletions @types/renderer/index.d.ts → @types/Renderer/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
fileBrowser: boolean;

postMessage(name: string, args?: any, transferList?: Transferable[]): void;
registerCallback(name: string, args: any, callback: Function): void;
promiseMessage(name: string, args?: any, transferList?: Transferable[]): Promise<void>
setMessageHandler(handler: Function): void;
};
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions @types/Renderer/webApi.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare namespace WepApi {
interface SetPluginMenuDataProps {
data: Menu.MenuItem[];
}
}
29 changes: 0 additions & 29 deletions @types/common/menu.d.ts

This file was deleted.

15 changes: 0 additions & 15 deletions @types/fonts.d.ts

This file was deleted.

108 changes: 68 additions & 40 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,79 @@ declare namespace Electron {
}

interface App extends EventEmitter {
on(event: 'updateActionState', listener: (state: Object) => void): this;
once(event: 'updateActionState', listener: (state: Object) => void): this;
addListener(event: 'updateActionState', listener: (state: Object) => void): this;
removeListener(event: 'updateActionState', listener: (state: Object) => void): this;

on(event: 'handleCommand', listener: (command: string) => void): this;
once(event: 'handleCommand', listener: (command: string) => void): this;
addListener(event: 'handleCommand', listener: (command: string) => void): this;
removeListener(event: 'handleCommand', listener: (command: string) => void): this;

on(event: 'updateFigmaUiScale', listener: (scale: number) => void): this;
once(event: 'updateFigmaUiScale', listener: (scale: number) => void): this;
addListener(event: 'updateFigmaUiScale', listener: (scale: number) => void): this;
removeListener(event: 'updateFigmaUiScale', listener: (scale: number) => void): this;

on(event: 'updatePanelScale', listener: (scale: number) => void): this;
once(event: 'updatePanelScale', listener: (scale: number) => void): this;
addListener(event: 'updatePanelScale', listener: (scale: number) => void): this;
removeListener(event: 'updatePanelScale', listener: (scale: number) => void): this;

on(event: 'setHideMainMenu', listener: (hide: boolean) => void): this;
once(event: 'setHideMainMenu', listener: (hide: boolean) => void): this;
addListener(event: 'setHideMainMenu', listener: (hide: boolean) => void): this;
removeListener(event: 'setHideMainMenu', listener: (hide: boolean) => void): this;

on(event: 'setDisableMainMenu', listener: (disabled: boolean) => void): this;
once(event: 'setDisableMainMenu', listener: (disabled: boolean) => void): this;
addListener(event: 'setDisableMainMenu', listener: (disabled: boolean) => void): this;
removeListener(event: 'setDisableMainMenu', listener: (disabled: boolean) => void): this;

on(event: 'setDisableFonts', listener: (disabled: boolean) => void): this;
once(event: 'setDisableFonts', listener: (disabled: boolean) => void): this;
addListener(event: 'setDisableFonts', listener: (disabled: boolean) => void): this;
removeListener(event: 'setDisableFonts', listener: (disabled: boolean) => void): this;
on(event: 'handle-command', listener: (command: string) => void): this;
once(event: 'handle-command', listener: (command: string) => void): this;
addListener(event: 'handle-command', listener: (command: string) => void): this;
removeListener(event: 'handle-command', listener: (command: string) => void): this;
emit(event: 'handle-command', command: string): boolean;

on(event: 'handle-page-command', listener: (item: any, window: BrowserWindow) => void): this;
once(event: 'handle-page-command', listener: (item: any, window: BrowserWindow) => void): this;
addListener(event: 'handle-page-command', listener: (item: any, window: BrowserWindow) => void): this;
removeListener(event: 'handle-page-command', listener: (item: any, window: BrowserWindow) => void): this;
emit(event: 'handle-page-command', item: any, window: BrowserWindow): boolean;

on(event: 'update-figma-ui-scale', listener: (scale: number) => void): this;
once(event: 'update-figma-ui-scale', listener: (scale: number) => void): this;
addListener(event: 'update-figma-ui-scale', listener: (scale: number) => void): this;
removeListener(event: 'update-figma-ui-scale', listener: (scale: number) => void): this;
emit(event: 'update-figma-ui-scale', scale: number): boolean;

on(event: 'update-panel-scale', listener: (scale: number) => void): this;
once(event: 'update-panel-scale', listener: (scale: number) => void): this;
addListener(event: 'update-panel-scale', listener: (scale: number) => void): this;
removeListener(event: 'update-panel-scale', listener: (scale: number) => void): this;
emit(event: 'update-panel-scale', scale: number): boolean;

on(event: 'set-hide-main-menu', listener: (hide: boolean) => void): this;
once(event: 'set-hide-main-menu', listener: (hide: boolean) => void): this;
addListener(event: 'set-hide-main-menu', listener: (hide: boolean) => void): this;
removeListener(event: 'set-hide-main-menu', listener: (hide: boolean) => void): this;
emit(event: 'set-hide-main-menu', hide: boolean): boolean;

on(event: 'set-disable-main-menu', listener: (disabled: boolean) => void): this;
once(event: 'set-disable-main-menu', listener: (disabled: boolean) => void): this;
addListener(event: 'set-disable-main-menu', listener: (disabled: boolean) => void): this;
removeListener(event: 'set-disable-main-menu', listener: (disabled: boolean) => void): this;
emit(event: 'set-disable-main-menu', disabled: boolean): boolean;

on(event: 'set-disable-fonts', listener: (disabled: boolean) => void): this;
once(event: 'set-disable-fonts', listener: (disabled: boolean) => void): this;
addListener(event: 'set-disable-fonts', listener: (disabled: boolean) => void): this;
removeListener(event: 'set-disable-fonts', listener: (disabled: boolean) => void): this;
emit(event: 'set-disable-fonts', disabled: boolean): boolean;

on(event: 'os-menu-invalidated', listener: (dependencies: MenuState.MenuStateParams) => void): this;
once(event: 'os-menu-invalidated', listener: (dependencies: MenuState.MenuStateParams) => void): this;
addListener(event: 'os-menu-invalidated', listener: (dependencies: MenuState.MenuStateParams) => void): this;
removeListener(event: 'os-menu-invalidated', listener: (dependencies: MenuState.MenuStateParams) => void): this;
emit(event: 'os-menu-invalidated', dependencies: MenuState.MenuStateParams): boolean;

on(event: 'log', listener: (data: any) => void): this;
once(event: 'log', listener: (data: any) => void): this;
addListener(event: 'log', listener: (data: any) => void): this;
removeListener(event: 'log', listener: (data: any) => void): this;
emit(event: 'log', data: any): boolean;
}

interface IpcMain extends EventEmitter {
on(channel: string, listener: Function): this;
once(channel: string, listener: Function): this;
on(channel: string, listener: (event: Event, args: any) => void): this;
once(channel: string, listener: (event: Event, args: any) => void): this;
removeAllListeners(channel: string): this;
removeListener(channel: string, listener: Function): this;
removeListener(channel: string, listener: (event: Event, args: any) => void): 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;
on(channel: 'setTitle', listener: (event: Event, title: string) => void): this;
once(channel: 'setTitle', listener: (event: Event, title: string) => void): this;
removeAllListeners(channel: 'setTitle'): this;
removeListener(channel: 'setTitle', listener: (event: Event, title: string, id: number) => void): this;
removeListener(channel: 'setTitle', listener: (event: Event, title: string) => void): this;

on(channel: 'setPluginMenuData', listener: (event: Event, pluginMenu: Menu.MenuItem[]) => void): this;
once(channel: 'setPluginMenuData', listener: (event: Event, pluginMenu: Menu.MenuItem[]) => void): this;
removeAllListeners(channel: 'setPluginMenuData'): this;
removeListener(channel: 'setPluginMenuData', listener: (event: Event, pluginMenu: Menu.MenuItem[]) => void): this;
}

interface RequestHeaders {
[name: string]: string;
}
}
5 changes: 3 additions & 2 deletions config/webpack.config.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ const main = {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', 'node'],

alias: {
Components: path.resolve(rootFolder, 'src/renderer/components'),
// Components: path.resolve(rootFolder, 'src/renderer/components'),
Middleware: path.resolve(rootFolder, 'src/middleware'),
Store: path.resolve(rootFolder, 'src/renderer/stores'),
// Store: path.resolve(rootFolder, 'src/renderer/stores'),
Const: path.resolve(rootFolder, 'src/constants'),
Main: path.resolve(rootFolder, 'src/main'),
Utils: path.resolve(rootFolder, 'src/utils')
}
},
Expand Down
3 changes: 2 additions & 1 deletion config/webpack.config.renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const render = {
entry: {
'../middleware/loadMainContetnt': path.resolve(rootFolder, 'src/middleware/loadMainContetnt.ts'),
'../middleware/loadContetnt': path.resolve(rootFolder, 'src/middleware/loadContetnt.ts'),
'../middleware/webApi': path.resolve(rootFolder, 'src/middleware/webApi.ts')
// '../middleware/webApi': path.resolve(rootFolder, 'src/middleware/webApi.ts')
},

module: {
Expand All @@ -27,6 +27,7 @@ const render = {
Middleware: path.resolve(rootFolder, 'src/middleware'),
Store: path.resolve(rootFolder, 'src/renderer/stores'),
Const: path.resolve(rootFolder, 'src/constants'),
Main: path.resolve(rootFolder, 'src/main'),
Utils: path.resolve(rootFolder, 'src/utils')
}
},
Expand Down
Loading

0 comments on commit d2d94da

Please sign in to comment.