sprotty-vscode
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -26,2 +26,6 @@ /******************************************************************************** | ||
export declare function isActionMessage(object: any): object is ActionMessage; | ||
export interface WebviewReadyMessage { | ||
readyMessage: string; | ||
} | ||
export declare function isWebviewReadyMessage(object: any): object is WebviewReadyMessage; | ||
export interface SprottyDiagramIdentifier { | ||
@@ -28,0 +32,0 @@ clientId: string; |
@@ -27,2 +27,6 @@ "use strict"; | ||
exports.isActionMessage = isActionMessage; | ||
function isWebviewReadyMessage(object) { | ||
return object !== undefined && object.hasOwnProperty('readyMessage'); | ||
} | ||
exports.isWebviewReadyMessage = isWebviewReadyMessage; | ||
function isDiagramIdentifier(object) { | ||
@@ -29,0 +33,0 @@ return object !== undefined && object.hasOwnProperty('clientId') && object.hasOwnProperty('diagramType') && object.hasOwnProperty('uri'); |
@@ -24,4 +24,4 @@ /******************************************************************************** | ||
protected connect(): Promise<void>; | ||
protected startConversation(): void; | ||
protected sendDiagramIdentifier(): Promise<void>; | ||
protected receiveFromWebview(message: any): void; | ||
} |
@@ -85,3 +85,3 @@ "use strict"; | ||
_this.disposables.push(_this.extension.onAcceptFromLanguageServer(function (message) { return _this.sendToWebview(message); })); | ||
_super.prototype.startConversation.call(_this); | ||
_super.prototype.sendDiagramIdentifier.call(_this); | ||
}); | ||
@@ -92,4 +92,8 @@ return [2 /*return*/]; | ||
}; | ||
SprottyLanguageWebview.prototype.startConversation = function () { | ||
// defer first message until language client is ready | ||
SprottyLanguageWebview.prototype.sendDiagramIdentifier = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
}; | ||
@@ -96,0 +100,0 @@ SprottyLanguageWebview.prototype.receiveFromWebview = function (message) { |
@@ -17,3 +17,3 @@ /******************************************************************************** | ||
import * as vscode from 'vscode'; | ||
import { ActionMessage, SprottyDiagramIdentifier, Action } from './protocol'; | ||
import { ActionMessage, SprottyDiagramIdentifier, Action, WebviewReadyMessage } from './protocol'; | ||
import { SprottyVscodeExtension } from './sprotty-vscode-extension'; | ||
@@ -35,5 +35,7 @@ export interface SprottyWebviewOptions { | ||
readonly diagramPanel: vscode.WebviewPanel; | ||
readonly webviewReady: Promise<WebviewReadyMessage>; | ||
protected messageQueue: (ActionMessage | SprottyDiagramIdentifier)[]; | ||
protected disposables: vscode.Disposable[]; | ||
constructor(options: SprottyWebviewOptions); | ||
protected resolveWebviewReady(message: WebviewReadyMessage): void; | ||
protected createTitle(): string; | ||
@@ -43,3 +45,3 @@ protected createWebviewPanel(): vscode.WebviewPanel; | ||
protected connect(): Promise<void>; | ||
protected startConversation(): void; | ||
protected sendDiagramIdentifier(): Promise<void>; | ||
protected receiveFromWebview(message: any): void; | ||
@@ -46,0 +48,0 @@ protected sendToWebview(message: any): void; |
@@ -57,3 +57,5 @@ "use strict"; | ||
function SprottyWebview(options) { | ||
var _this = this; | ||
this.options = options; | ||
this.webviewReady = new Promise(function (resolve) { return _this.resolveWebviewReady; }); | ||
this.messageQueue = []; | ||
@@ -69,2 +71,4 @@ this.disposables = []; | ||
} | ||
SprottyWebview.prototype.resolveWebviewReady = function (message) { | ||
}; | ||
SprottyWebview.prototype.createTitle = function () { | ||
@@ -108,3 +112,3 @@ if (this.diagramIdentifier.uri) | ||
this.disposables.push(this.diagramPanel.webview.onDidReceiveMessage(function (message) { return _this.receiveFromWebview(message); })); | ||
this.startConversation(); | ||
this.sendDiagramIdentifier(); | ||
return [2 /*return*/]; | ||
@@ -114,4 +118,14 @@ }); | ||
}; | ||
SprottyWebview.prototype.startConversation = function () { | ||
this.sendToWebview(this.diagramIdentifier); | ||
SprottyWebview.prototype.sendDiagramIdentifier = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.webviewReady]; | ||
case 1: | ||
_a.sent(); | ||
this.sendToWebview(this.diagramIdentifier); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
@@ -121,2 +135,4 @@ SprottyWebview.prototype.receiveFromWebview = function (message) { | ||
this.accept(message.action); | ||
else if (protocol_1.isWebviewReadyMessage(message)) | ||
this.resolveWebviewReady(message); | ||
}; | ||
@@ -123,0 +139,0 @@ SprottyWebview.prototype.sendToWebview = function (message) { |
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"engines": { | ||
@@ -13,0 +13,0 @@ "vscode": "^1.27.2" |
@@ -40,4 +40,12 @@ /******************************************************************************** | ||
///////////////////////////////////// | ||
// diagram identifier | ||
// initial handshake | ||
export interface WebviewReadyMessage { | ||
readyMessage: string | ||
} | ||
export function isWebviewReadyMessage(object: any): object is WebviewReadyMessage { | ||
return object !== undefined && object.hasOwnProperty('readyMessage'); | ||
} | ||
export interface SprottyDiagramIdentifier { | ||
@@ -44,0 +52,0 @@ clientId: string, |
@@ -37,7 +37,7 @@ /******************************************************************************** | ||
this.disposables.push(this.extension.onAcceptFromLanguageServer(message => this.sendToWebview(message))); | ||
super.startConversation(); | ||
super.sendDiagramIdentifier(); | ||
}); | ||
} | ||
protected startConversation() { | ||
protected async sendDiagramIdentifier() { | ||
// defer first message until language client is ready | ||
@@ -44,0 +44,0 @@ } |
@@ -18,3 +18,3 @@ /******************************************************************************** | ||
import * as vscode from 'vscode'; | ||
import { ActionMessage, isActionMessage, SprottyDiagramIdentifier, Action, isDiagramIdentifier } from './protocol'; | ||
import { ActionMessage, isActionMessage, SprottyDiagramIdentifier, Action, isDiagramIdentifier, isWebviewReadyMessage, WebviewReadyMessage } from './protocol'; | ||
import { SprottyVscodeExtension } from './sprotty-vscode-extension'; | ||
@@ -39,2 +39,3 @@ | ||
readonly diagramPanel: vscode.WebviewPanel; | ||
readonly webviewReady = new Promise<WebviewReadyMessage>((resolve) => this.resolveWebviewReady); | ||
@@ -54,2 +55,5 @@ protected messageQueue: (ActionMessage | SprottyDiagramIdentifier)[] = []; | ||
protected resolveWebviewReady(message: WebviewReadyMessage) { | ||
} | ||
protected createTitle(): string { | ||
@@ -112,6 +116,7 @@ if (this.diagramIdentifier.uri) | ||
this.disposables.push(this.diagramPanel.webview.onDidReceiveMessage(message => this.receiveFromWebview(message))); | ||
this.startConversation(); | ||
this.sendDiagramIdentifier(); | ||
} | ||
protected startConversation() { | ||
protected async sendDiagramIdentifier() { | ||
await this.webviewReady; | ||
this.sendToWebview(this.diagramIdentifier); | ||
@@ -123,2 +128,4 @@ } | ||
this.accept(message.action); | ||
else if (isWebviewReadyMessage(message)) | ||
this.resolveWebviewReady(message); | ||
} | ||
@@ -125,0 +132,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71132
1188