-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
2,781 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
</head> | ||
|
||
<body> | ||
<div id="overlay"></div> | ||
<div id="root"></div> | ||
</body> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,46 @@ | ||
import { | ||
WebviewReceiveEvent, | ||
WebviewReceiveEventType, | ||
WebviewSendEvent, | ||
WebviewSendEventType | ||
} from '.' | ||
import { IAnalysisStep } from '../model/analysisStep' | ||
import { ISendLoginEventData } from '../model/login' | ||
import { WebviewPage } from '../model/webviewPages' | ||
import { IdeEvent, IdeEventType, JumpToCodeEvent } from './ideEvent' | ||
import { WebviewEvent, webviewEventType } from './webviewEvent' | ||
import { SendJumpToCodeEvent } from './sendEvent/jumpToCode' | ||
import { SendLoginEvent } from './sendEvent/login' | ||
|
||
export class EventManager { | ||
private sendFunc = new Function('request', 'console.log(request)') | ||
protected sendFunc = new Function('request', 'console.log(request)') | ||
|
||
constructor(private setPageState: React.Dispatch<React.SetStateAction<WebviewPage>>) { | ||
this.setEventReceiver() | ||
} | ||
|
||
private sendEvent = (req: IdeEvent): void => { | ||
private sendEvent = (req: WebviewSendEvent): void => { | ||
this.sendFunc(req) | ||
} | ||
|
||
private setEventReceiver(): void { | ||
window.addEventListener('message', event => { | ||
const eventData: WebviewEvent = event.data | ||
const eventData: WebviewReceiveEvent = event.data | ||
|
||
switch (eventData.type) { | ||
case webviewEventType.SetEmitter: | ||
case WebviewReceiveEventType.SetEmitter: | ||
this.sendFunc = new Function(eventData.emitterFunc)() | ||
break | ||
case webviewEventType.ShowPage: | ||
case WebviewReceiveEventType.ShowPage: | ||
this.setPageState(eventData.pageData) | ||
break | ||
} | ||
}) | ||
} | ||
|
||
public jumpToCode(data: IAnalysisStep): void { | ||
this.sendEvent({ type: IdeEventType.JUMP_TO_CODE, data: data } as JumpToCodeEvent) | ||
this.sendEvent({ type: WebviewSendEventType.JumpToCode, data: data } as SendJumpToCodeEvent) | ||
} | ||
|
||
public Login(data: ISendLoginEventData): void { | ||
this.sendEvent({ type: WebviewSendEventType.Login, data: data } as SendLoginEvent) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { SendLoginEvent } from './sendEvent/login' | ||
import { SendJumpToCodeEvent } from './sendEvent/jumpToCode' | ||
import { ReceiveSetEmitterEvent } from './receiveEvent/setEmitter' | ||
import { ReceiveShowPageEvent } from './receiveEvent/showPage' | ||
|
||
// Send event to the IDEs. | ||
export enum WebviewSendEventType { | ||
JumpToCode = 'SHOW_CODE', | ||
Login = 'LOGIN' | ||
} | ||
|
||
export type WebviewSendEvent = SendJumpToCodeEvent | SendLoginEvent | ||
|
||
// Receive events from the IDEs. | ||
export enum WebviewReceiveEventType { | ||
SetEmitter = 'SET_EMITTER', | ||
ShowPage = 'SHOW_DATA' | ||
} | ||
|
||
export type WebviewReceiveEvent = ReceiveShowPageEvent | ReceiveSetEmitterEvent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { ReceiveSetEmitterEvent } from './setEmitter' | ||
export { ReceiveShowPageEvent } from './showPage' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ReceiveSetEmitterEvent } from '.' | ||
import { WebviewReceiveEventType } from '..' | ||
|
||
describe('Event Types', () => { | ||
test('defines webviewEventType enum correctly', () => { | ||
expect(WebviewReceiveEventType.SetEmitter).toEqual('SET_EMITTER') | ||
}) | ||
|
||
test('defines SetEmitterEvent interface correctly', () => { | ||
const eventData: ReceiveSetEmitterEvent = { | ||
type: WebviewReceiveEventType.SetEmitter, | ||
emitterFunc: 'exampleEmitterFunc' | ||
} | ||
|
||
expect(eventData.type).toEqual(WebviewReceiveEventType.SetEmitter) | ||
expect(eventData.emitterFunc).toEqual('exampleEmitterFunc') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { WebviewReceiveEventType } from '..' | ||
|
||
export interface ReceiveSetEmitterEvent { | ||
type: WebviewReceiveEventType.SetEmitter | ||
emitterFunc: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { WebviewReceiveEventType } from '..' | ||
import { IDependencyPage } from '../../model/webviewPages' | ||
import { ReceiveShowPageEvent } from './showPage' | ||
|
||
describe('Event Types', () => { | ||
test('defines webviewEventType enum correctly', () => { | ||
expect(WebviewReceiveEventType.SetEmitter).toEqual('SET_EMITTER') | ||
}) | ||
|
||
test('defines ShowPageEvent interface correctly', () => { | ||
const eventData: ReceiveShowPageEvent = { | ||
type: WebviewReceiveEventType.ShowPage, | ||
pageData: {} as IDependencyPage | ||
} | ||
|
||
expect(eventData.type).toEqual(WebviewReceiveEventType.ShowPage) | ||
expect(eventData.pageData).toBeDefined() | ||
}) | ||
|
||
test('defines WebviewEvent union type correctly', () => { | ||
const event: ReceiveShowPageEvent = { | ||
type: WebviewReceiveEventType.ShowPage, | ||
pageData: {} as IDependencyPage | ||
} | ||
|
||
expect(event.type).toEqual(WebviewReceiveEventType.ShowPage) | ||
expect(event.pageData).toBeDefined() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { WebviewReceiveEventType } from '..' | ||
import { WebviewPage } from '../../model/webviewPages' | ||
|
||
export interface ReceiveShowPageEvent { | ||
type: WebviewReceiveEventType.ShowPage | ||
pageData: WebviewPage | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { SendJumpToCodeEvent } from './jumpToCode' | ||
export { SendLoginEvent } from './login' |
Oops, something went wrong.