Skip to content

Commit

Permalink
consololidated preloads into 3. Adopted the 'sail' namespace for the …
Browse files Browse the repository at this point in the history
…internal preload api
  • Loading branch information
nkolba committed Oct 16, 2022
1 parent bea7edb commit c127181
Show file tree
Hide file tree
Showing 20 changed files with 235 additions and 316 deletions.
21 changes: 2 additions & 19 deletions packages/main/src/IntentResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import { Workspace } from './workspace';
import { randomUUID } from 'crypto';
import { RUNTIME_TOPICS } from './handlers/runtime/topics';

const RESOLVER_PRELOAD = join(
__dirname,
'../../preload/dist/intentResolver/index.cjs',
);
const SYSTEM_PRELOAD = join(__dirname, '../../preload/dist/system/index.cjs');

const devTools = false;

Expand Down Expand Up @@ -45,7 +42,7 @@ export class IntentResolver {
hasShadow: true,
resizable: false,
webPreferences: {
preload: RESOLVER_PRELOAD,
preload: SYSTEM_PRELOAD,
webSecurity: true,
nodeIntegration: true,
contextIsolation: true,
Expand Down Expand Up @@ -99,22 +96,8 @@ export class IntentResolver {
options: options,
};

console.log(
'startObject',
this.id,
this.intent,
JSON.stringify(this.context),
);

console.log('startObject options', JSON.stringify(options));

this.window.webContents.send(RUNTIME_TOPICS.WINDOW_START, startObject);

console.log(
'intent resolver create',
RESOLVER_CONTENT as string,
options,
);
this.view = view;
});

Expand Down
1 change: 1 addition & 0 deletions packages/main/src/handlers/fdc3/1.2/raiseIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@finos/fdc3';
import { getRuntime } from '/@/index';
import { View } from '/@/view';
import fetch from 'electron-fetch';
import { RuntimeMessage } from '/@/handlers/runtimeMessage';
import {
DirectoryApp,
Expand Down
7 changes: 4 additions & 3 deletions packages/main/src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import { TOPICS, TOOLBAR_HEIGHT } from './constants';
import { FDC3_TOPICS } from '/@/handlers/fdc3/1.2/topics';
import { join } from 'path';
import { randomUUID } from 'crypto';
import { RUNTIME_TOPICS } from './handlers/runtime/topics';

const VIEW_PRELOAD = join(__dirname, '../../preload/dist/view/index.cjs');

const HOME_PRELOAD = join(__dirname, '../../preload/dist/homeView/index.cjs');
const HOME_PRELOAD = join(__dirname, '../../preload/dist/systemView/index.cjs');

export class View {
constructor(url?: string | null, config?: ViewConfig, parent?: Workspace) {
Expand Down Expand Up @@ -102,7 +103,7 @@ export class View {
//listen for reloads and reset id
this.content.webContents.on('devtools-reload-page', () => {
this.content.webContents.once('did-finish-load', () => {
this.content.webContents.send(FDC3_TOPICS.START, {
this.content.webContents.send(RUNTIME_TOPICS.WINDOW_START, {
id: this.id,
directory: this.directoryData || null,
});
Expand All @@ -114,7 +115,7 @@ export class View {
//to do: ensure directory entry and new location match up!
this.content.webContents.on('did-navigate', () => {
this.content.webContents.once('did-finish-load', () => {
this.content.webContents.send(FDC3_TOPICS.START, {
this.content.webContents.send(RUNTIME_TOPICS.WINDOW_START, {
id: this.id,
directory: this.directoryData || null,
});
Expand Down
11 changes: 7 additions & 4 deletions packages/main/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import { randomUUID } from 'crypto';
import { RUNTIME_TOPICS } from './handlers/runtime/topics';
import { FDC3_TOPICS } from './handlers/fdc3/1.2/topics';

const SYSTEM_PRELOAD = join(__dirname, '../../preload/dist/system/index.cjs');

/*
const CHANNEL_PICKER_PRELOAD = join(
__dirname,
'../../preload/dist/channelPicker/index.cjs',
Expand All @@ -33,7 +36,7 @@ const CHANNEL_PICKER_PRELOAD = join(
const SEARCH_RESULTS_PRELOAD = join(
__dirname,
'../../preload/dist/searchResults/index.cjs',
);
);*/

const CHANNEL_WINDOW_WIDTH = 140;
const CHANNEL_WINDOW_HEIGHT = 100;
Expand All @@ -48,7 +51,7 @@ export class Workspace {
width: DEFAULT_WINDOW_WIDTH,
webPreferences: {
webviewTag: false, // The webview tag is not recommended. Consider alternatives like iframe or Electron's BrowserView. https://www.electronjs.org/docs/latest/api/webview-tag#warning
preload: join(__dirname, '../../preload/dist/frame/index.cjs'),
preload: SYSTEM_PRELOAD,
nodeIntegration: true,
},
});
Expand Down Expand Up @@ -435,7 +438,7 @@ export class Workspace {
webSecurity: true,
nodeIntegration: true,
contextIsolation: true,
preload: SEARCH_RESULTS_PRELOAD,
preload: SYSTEM_PRELOAD,
devTools: true,
},
});
Expand Down Expand Up @@ -482,7 +485,7 @@ export class Workspace {
webSecurity: true,
nodeIntegration: true,
contextIsolation: true,
preload: CHANNEL_PICKER_PRELOAD,
preload: SYSTEM_PRELOAD,
devTools: true,
},
});
Expand Down
6 changes: 1 addition & 5 deletions packages/preload/exposedInMainWorld.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
interface Window {
readonly agentChannelPicker: { joinChannel: (channel: string) => void; hideWindow: () => void; leaveChannel: () => void; };
readonly versions: NodeJS.ProcessVersions;
readonly agentFrame: { isConnected: () => boolean; selectTab: (selectedId: string) => void; tearOutTab: (tabId: string) => void; openToolsMenu: (clientX: number, clientY: number) => void; isReady: () => void; newTab: () => void; openChannelPicker: (mouseX: number, mouseY: number) => void; hideResultsWindow: () => void; searchDirectory: (query: string) => void; dropTab: (frameTarget: boolean) => void; tabDragStart: (selected: string) => void; closeTab: (tabId: string) => void; };
readonly home: { getApps: () => Promise<unknown>; };
readonly fdc3: import("/Users/nicholaskolba/connectifi/electron-fdc3/node_modules/@finos/fdc3/dist/api/DesktopAgent").DesktopAgent;
readonly agentResolver: { resolveIntent: (data: any) => void; };
readonly agentSearch: { selectResult: (selection: string) => void; };
readonly sail: { isConnected: () => boolean; isReady: () => void; joinChannel: (channel: string) => void; leaveChannel: () => void; hideWindow: () => void; resolveIntent: (data: any) => void; versions: NodeJS.ProcessVersions; getApps: () => Promise<unknown>; tabs: { select: (selectedId: string) => void; tearOut: (tabId: string) => void; new: () => void; drop: (frameTarget: boolean) => void; dragStart: (selected: string) => void; close: (tabId: string) => void; }; menu: { openTools: (clientX: number, clientY: number) => void; openChannelPicker: (mouseX: number, mouseY: number) => void; }; search: { hideResultsWindow: () => void; searchDirectory: (query: string) => void; selectResult: (selection: string) => void; }; };
}
63 changes: 0 additions & 63 deletions packages/preload/src/channelPicker/index.ts

This file was deleted.

59 changes: 0 additions & 59 deletions packages/preload/src/homeView/api.ts

This file was deleted.

35 changes: 0 additions & 35 deletions packages/preload/src/intentResolver/index.ts

This file was deleted.

37 changes: 0 additions & 37 deletions packages/preload/src/searchResults/index.ts

This file was deleted.

Loading

0 comments on commit c127181

Please sign in to comment.