sprotty-vscode
Advanced tools
Comparing version 0.0.21 to 0.1.0-alpha.f2e375b2
@@ -21,1 +21,2 @@ /******************************************************************************** | ||
export * from './sprotty-vscode-language-extension'; | ||
export * from 'sprotty-vscode-protocol'; |
@@ -26,2 +26,3 @@ "use strict"; | ||
__export(require("./sprotty-vscode-language-extension")); | ||
__export(require("sprotty-vscode-protocol")); | ||
//# sourceMappingURL=index.js.map |
@@ -17,21 +17,3 @@ /******************************************************************************** | ||
import { NotificationType, Location } from 'vscode-languageclient'; | ||
export interface Action { | ||
readonly kind: string; | ||
} | ||
export declare function isAction(object?: any): object is Action; | ||
export interface ActionMessage { | ||
clientId: string; | ||
action: Action; | ||
} | ||
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 { | ||
clientId: string; | ||
diagramType: string; | ||
uri: string; | ||
} | ||
export declare function isDiagramIdentifier(object: any): object is SprottyDiagramIdentifier; | ||
import { ActionMessage } from 'sprotty-vscode-protocol'; | ||
export declare const acceptMessageType: NotificationType<ActionMessage, void>; | ||
@@ -38,0 +20,0 @@ export declare const didCloseMessageType: NotificationType<string, void>; |
@@ -19,18 +19,2 @@ "use strict"; | ||
var vscode_languageclient_1 = require("vscode-languageclient"); | ||
function isAction(object) { | ||
return object !== undefined && object.hasOwnProperty('kind') && typeof (object['kind']) === 'string'; | ||
} | ||
exports.isAction = isAction; | ||
function isActionMessage(object) { | ||
return object !== undefined && object.hasOwnProperty('clientId') && object.hasOwnProperty('action'); | ||
} | ||
exports.isActionMessage = isActionMessage; | ||
function isWebviewReadyMessage(object) { | ||
return object !== undefined && object.hasOwnProperty('readyMessage'); | ||
} | ||
exports.isWebviewReadyMessage = isWebviewReadyMessage; | ||
function isDiagramIdentifier(object) { | ||
return object !== undefined && object.hasOwnProperty('clientId') && object.hasOwnProperty('diagramType') && object.hasOwnProperty('uri'); | ||
} | ||
exports.isDiagramIdentifier = isDiagramIdentifier; | ||
///////////////////////////////////// | ||
@@ -37,0 +21,0 @@ // LSP extensions |
@@ -31,6 +31,7 @@ "use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -68,2 +69,3 @@ }); | ||
var protocol_1 = require("./protocol"); | ||
var sprotty_vscode_protocol_1 = require("sprotty-vscode-protocol"); | ||
var sprotty_vscode_language_extension_1 = require("./sprotty-vscode-language-extension"); | ||
@@ -102,3 +104,3 @@ var sprotty_webview_1 = require("./sprotty-webview"); | ||
_super.prototype.receiveFromWebview.call(this, message); | ||
if (protocol_1.isActionMessage(message)) | ||
if (sprotty_vscode_protocol_1.isActionMessage(message)) | ||
this.extension.languageClient.sendNotification(protocol_1.acceptMessageType, message); | ||
@@ -105,0 +107,0 @@ }; |
@@ -17,3 +17,3 @@ /******************************************************************************** | ||
import * as vscode from 'vscode'; | ||
import { SprottyDiagramIdentifier } from './protocol'; | ||
import { SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { SprottyWebview } from './sprotty-webview'; | ||
@@ -20,0 +20,0 @@ export declare abstract class SprottyVscodeExtension { |
@@ -17,6 +17,6 @@ "use strict"; | ||
********************************************************************************/ | ||
var __values = (this && this.__values) || function (o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
return { | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
@@ -27,2 +27,3 @@ if (o && i >= o.length) o = void 0; | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
@@ -29,0 +30,0 @@ var __read = (this && this.__read) || function (o, n) { |
@@ -18,3 +18,4 @@ /******************************************************************************** | ||
import { Emitter, LanguageClient } from 'vscode-languageclient'; | ||
import { ActionMessage, OpenInTextEditorMessage, SprottyDiagramIdentifier } from './protocol'; | ||
import { OpenInTextEditorMessage } from './protocol'; | ||
import { ActionMessage, SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { SprottyVscodeExtension } from './sprotty-vscode-extension'; | ||
@@ -21,0 +22,0 @@ export declare abstract class SprottyVscodeLanguageExtension extends SprottyVscodeExtension { |
@@ -16,4 +16,5 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action, ActionMessage, SprottyDiagramIdentifier, WebviewReadyMessage } from 'sprotty-vscode-protocol'; | ||
import * as vscode from 'vscode'; | ||
import { ActionMessage, SprottyDiagramIdentifier, Action, WebviewReadyMessage } from './protocol'; | ||
import { ActionHandler } from './action-handler'; | ||
import { SprottyVscodeExtension } from './sprotty-vscode-extension'; | ||
@@ -35,2 +36,3 @@ export interface SprottyWebviewOptions { | ||
readonly diagramPanel: vscode.WebviewPanel; | ||
readonly actionHandlers: Map<string, ActionHandler>; | ||
protected resolveWebviewReady: (message: WebviewReadyMessage) => void; | ||
@@ -50,2 +52,3 @@ protected readonly webviewReady: Promise<WebviewReadyMessage>; | ||
accept(action: Action): void; | ||
addActionHandler(actionHandlerConstructor: new (webview: SprottyWebview) => ActionHandler): void; | ||
} |
"use strict"; | ||
/******************************************************************************** | ||
* Copyright (c) 2018 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -53,4 +39,19 @@ }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/******************************************************************************** | ||
* Copyright (c) 2018 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
var sprotty_vscode_protocol_1 = require("sprotty-vscode-protocol"); | ||
var vscode = require("vscode"); | ||
var protocol_1 = require("./protocol"); | ||
var SprottyWebview = /** @class */ (function () { | ||
@@ -60,2 +61,3 @@ function SprottyWebview(options) { | ||
this.options = options; | ||
this.actionHandlers = new Map(); | ||
this.webviewReady = new Promise(function (resolve) { return _this.resolveWebviewReady = resolve; }); | ||
@@ -129,9 +131,9 @@ this.messageQueue = []; | ||
SprottyWebview.prototype.receiveFromWebview = function (message) { | ||
if (protocol_1.isActionMessage(message)) | ||
if (sprotty_vscode_protocol_1.isActionMessage(message)) | ||
this.accept(message.action); | ||
else if (protocol_1.isWebviewReadyMessage(message)) | ||
else if (sprotty_vscode_protocol_1.isWebviewReadyMessage(message)) | ||
this.resolveWebviewReady(message); | ||
}; | ||
SprottyWebview.prototype.sendToWebview = function (message) { | ||
if (protocol_1.isActionMessage(message) || protocol_1.isDiagramIdentifier(message)) { | ||
if (sprotty_vscode_protocol_1.isActionMessage(message) || sprotty_vscode_protocol_1.isDiagramIdentifier(message)) { | ||
if (this.diagramPanel.visible) | ||
@@ -150,3 +152,10 @@ this.diagramPanel.webview.postMessage(message); | ||
SprottyWebview.prototype.accept = function (action) { | ||
var actionHandler = this.actionHandlers.get(action.kind); | ||
if (actionHandler) | ||
actionHandler.handleAction(action); | ||
}; | ||
SprottyWebview.prototype.addActionHandler = function (actionHandlerConstructor) { | ||
var actionHandler = new actionHandlerConstructor(this); | ||
this.actionHandlers.set(actionHandler.kind, actionHandler); | ||
}; | ||
SprottyWebview.viewCount = 0; | ||
@@ -153,0 +162,0 @@ return SprottyWebview; |
{ | ||
"name": "sprotty-vscode", | ||
"version": "0.0.21", | ||
"version": "0.1.0-alpha.f2e375b2", | ||
"displayName": "Sprotty VSCode Integration", | ||
@@ -36,7 +36,7 @@ "description": "Glue code to integrate Sprotty diagrams in VSCode extensions (extension part)", | ||
"engines": { | ||
"vscode": "^1.27.2" | ||
"vscode": "^1.27.2" | ||
}, | ||
"files": [ | ||
"lib", | ||
"src" | ||
"lib", | ||
"src" | ||
], | ||
@@ -46,20 +46,23 @@ "main": "lib/index", | ||
"dependencies": { | ||
"path": "^0.12.7", | ||
"vscode": "^1.1.21", | ||
"vscode-languageclient": "^5.1.0-next.9", | ||
"vscode-languageserver": "^5.1.0-next.9" | ||
"path": "^0.12.7", | ||
"sprotty-vscode-protocol": "^0.1.0-alpha.f2e375b2", | ||
"vscode": "^1.1.21", | ||
"vscode-languageclient": "^5.1.0-next.9", | ||
"vscode-languageserver": "^5.1.0-next.9" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^8.0.0", | ||
"rimraf": "^2.6.3", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.3" | ||
"@types/node": "^8.0.0", | ||
"rimraf": "^2.6.3", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.3" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf lib", | ||
"build": "tsc", | ||
"watch": "tsc -w", | ||
"lint": "tslint -c ./tslint.json --project ./tsconfig.json", | ||
"prepare": "node ./node_modules/vscode/bin/install && yarn build" | ||
"clean": "rimraf lib sprotty-vscode*.tgz", | ||
"build": "tsc", | ||
"watch": "tsc -w", | ||
"lint": "tslint -c ./tslint.json --project ./tsconfig.json", | ||
"prepare": "node ../node_modules/vscode/bin/install && yarn clean && yarn build", | ||
"link:install": "yarn link", | ||
"link:uninstall": "yarn unlink" | ||
} | ||
} |
@@ -22,1 +22,2 @@ /******************************************************************************** | ||
export * from './sprotty-vscode-language-extension'; | ||
export * from 'sprotty-vscode-protocol'; |
@@ -18,45 +18,5 @@ /******************************************************************************** | ||
import { NotificationType, Location } from 'vscode-languageclient'; | ||
import { ActionMessage } from 'sprotty-vscode-protocol'; | ||
///////////////////////////////////// | ||
// sprotty action messages | ||
export interface Action { | ||
readonly kind: string | ||
} | ||
export function isAction(object?: any): object is Action { | ||
return object !== undefined && object.hasOwnProperty('kind') && typeof(object['kind']) === 'string'; | ||
} | ||
export interface ActionMessage { | ||
clientId: string | ||
action: Action | ||
} | ||
export function isActionMessage(object: any): object is ActionMessage { | ||
return object !== undefined && object.hasOwnProperty('clientId') && object.hasOwnProperty('action'); | ||
} | ||
///////////////////////////////////// | ||
// initial handshake | ||
export interface WebviewReadyMessage { | ||
readyMessage: string | ||
} | ||
export function isWebviewReadyMessage(object: any): object is WebviewReadyMessage { | ||
return object !== undefined && object.hasOwnProperty('readyMessage'); | ||
} | ||
export interface SprottyDiagramIdentifier { | ||
clientId: string, | ||
diagramType: string, | ||
uri: string | ||
} | ||
export function isDiagramIdentifier(object: any): object is SprottyDiagramIdentifier { | ||
return object !== undefined && object.hasOwnProperty('clientId') && object.hasOwnProperty('diagramType') && object.hasOwnProperty('uri'); | ||
} | ||
///////////////////////////////////// | ||
// LSP extensions | ||
@@ -63,0 +23,0 @@ |
@@ -17,3 +17,4 @@ /******************************************************************************** | ||
import { acceptMessageType, isActionMessage } from './protocol'; | ||
import { acceptMessageType } from './protocol'; | ||
import { isActionMessage } from 'sprotty-vscode-protocol'; | ||
import { SprottyVscodeLanguageExtension } from './sprotty-vscode-language-extension'; | ||
@@ -20,0 +21,0 @@ import { SprottyWebview, SprottyWebviewOptions } from './sprotty-webview'; |
@@ -19,3 +19,3 @@ /******************************************************************************** | ||
import * as vscode from 'vscode'; | ||
import { Action, SprottyDiagramIdentifier } from './protocol'; | ||
import { Action, SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { SprottyWebview } from './sprotty-webview'; | ||
@@ -22,0 +22,0 @@ |
@@ -19,3 +19,4 @@ /******************************************************************************** | ||
import { Emitter, LanguageClient } from 'vscode-languageclient'; | ||
import { acceptMessageType, ActionMessage, didCloseMessageType, OpenInTextEditorMessage, openInTextEditorMessageType, SprottyDiagramIdentifier } from './protocol'; | ||
import { acceptMessageType, didCloseMessageType, OpenInTextEditorMessage, openInTextEditorMessageType } from './protocol'; | ||
import { ActionMessage, SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; | ||
import { SprottyVscodeExtension } from './sprotty-vscode-extension'; | ||
@@ -22,0 +23,0 @@ |
@@ -16,7 +16,17 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { | ||
Action, | ||
ActionMessage, | ||
isActionMessage, | ||
isDiagramIdentifier, | ||
isWebviewReadyMessage, | ||
SprottyDiagramIdentifier, | ||
WebviewReadyMessage, | ||
} from 'sprotty-vscode-protocol'; | ||
import * as vscode from 'vscode'; | ||
import * as vscode from 'vscode'; | ||
import { ActionMessage, isActionMessage, SprottyDiagramIdentifier, Action, isDiagramIdentifier, isWebviewReadyMessage, WebviewReadyMessage } from './protocol'; | ||
import { ActionHandler } from './action-handler'; | ||
import { SprottyVscodeExtension } from './sprotty-vscode-extension'; | ||
export interface SprottyWebviewOptions { | ||
@@ -39,2 +49,3 @@ extension: SprottyVscodeExtension | ||
readonly diagramPanel: vscode.WebviewPanel; | ||
readonly actionHandlers = new Map<string, ActionHandler>(); | ||
@@ -145,3 +156,11 @@ protected resolveWebviewReady: (message: WebviewReadyMessage) => void; | ||
accept(action: Action) { | ||
const actionHandler = this.actionHandlers.get(action.kind); | ||
if (actionHandler) | ||
actionHandler.handleAction(action); | ||
} | ||
addActionHandler(actionHandlerConstructor: new(webview: SprottyWebview) => ActionHandler) { | ||
const actionHandler = new actionHandlerConstructor(this); | ||
this.actionHandlers.set(actionHandler.kind, actionHandler); | ||
} | ||
} |
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
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
123014
42
1774
5
7
+ Addedsprotty-vscode-protocol@0.1.0-alpha.f2e375b2(transitive)