@eclipse-glsp/client
Version:
A sprotty-based client for GLSP
104 lines • 5.84 kB
JavaScript
;
/********************************************************************************
* Copyright (c) 2023-2025 EclipseSource 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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.STANDALONE_MODULE_CONFIG = exports.STANDALONE_MODULES = exports.LayoutKeyListener = exports.FallbackActionHandler = exports.standaloneDefaultModule = void 0;
const sprotty_1 = require("@eclipse-glsp/sprotty");
const inversify_1 = require("inversify");
const shortcuts_module_1 = require("./base/shortcuts/shortcuts-module");
const resize_module_1 = require("./features/change-bounds/resize/resize-module");
const copy_paste_modules_1 = require("./features/copy-paste/copy-paste-modules");
const export_modules_1 = require("./features/export/export-modules");
const save_module_1 = require("./features/save/save-module");
const search_palette_module_1 = require("./features/search-palette/search-palette-module");
const select_module_1 = require("./features/select/select-module");
const undo_redo_module_1 = require("./features/undo-redo/undo-redo-module");
const validation_modules_1 = require("./features/validation/validation-modules");
const viewport_modules_1 = require("./features/viewport/viewport-modules");
exports.standaloneDefaultModule = new sprotty_1.FeatureModule((bind, unbind, isBound, rebind) => {
const context = { bind, unbind, isBound, rebind };
bind(FallbackActionHandler).toSelf().inSingletonScope();
(0, sprotty_1.configureActionHandler)(context, sprotty_1.MessageAction.KIND, FallbackActionHandler);
(0, sprotty_1.configureActionHandler)(context, sprotty_1.StartProgressAction.KIND, FallbackActionHandler);
(0, sprotty_1.configureActionHandler)(context, sprotty_1.UpdateProgressAction.KIND, FallbackActionHandler);
(0, sprotty_1.configureActionHandler)(context, sprotty_1.EndProgressAction.KIND, FallbackActionHandler);
(0, sprotty_1.bindAsService)(context, sprotty_1.TYPES.KeyListener, LayoutKeyListener);
}, { featureId: Symbol('standaloneDefault') });
/**
* A fallback action handler for actions sent by features that are currently not supported by
* default in the standalone context. Unhandled actions will be simply forwarded to the {@link ILogger}.
*/
let FallbackActionHandler = class FallbackActionHandler {
handle(action) {
this.logger.log(this, 'Unhandled action received:', action);
}
};
exports.FallbackActionHandler = FallbackActionHandler;
__decorate([
(0, inversify_1.inject)(sprotty_1.TYPES.ILogger),
__metadata("design:type", Object)
], FallbackActionHandler.prototype, "logger", void 0);
exports.FallbackActionHandler = FallbackActionHandler = __decorate([
(0, inversify_1.injectable)()
], FallbackActionHandler);
let LayoutKeyListener = class LayoutKeyListener extends sprotty_1.KeyListener {
keyDown(_element, event) {
if ((0, sprotty_1.matchesKeystroke)(event, 'KeyL', 'ctrlCmd', 'shift')) {
return [sprotty_1.TriggerLayoutAction.create()];
}
return [];
}
};
exports.LayoutKeyListener = LayoutKeyListener;
exports.LayoutKeyListener = LayoutKeyListener = __decorate([
(0, inversify_1.injectable)()
], LayoutKeyListener);
/**
* Configuration of all `standalone` modules.
*
* Standalone modules compose additional features/services that are intended for the standalone deployment of GLSP (i.e. plain webapp)
* When integrated into an application frame (e.g Theia/VS Code) this module is typically omitted and/or replaced
* with an application native module.
*
* Typically standalone modules built on top of (i.e require ) a default module and are therefore conditionally loaded if the
* required default modules have been loaded beforehand.
*/
exports.STANDALONE_MODULES = [
viewport_modules_1.standaloneViewportModule,
copy_paste_modules_1.standaloneCopyPasteModule,
validation_modules_1.standaloneMarkerNavigatorModule,
select_module_1.standaloneSelectModule,
export_modules_1.standaloneExportModule,
exports.standaloneDefaultModule,
shortcuts_module_1.standaloneShortcutsModule,
resize_module_1.standaloneResizeModule,
search_palette_module_1.standaloneSearchPaletteModule,
save_module_1.saveModule,
undo_redo_module_1.undoRedoModule
];
exports.STANDALONE_MODULE_CONFIG = {
add: [...exports.STANDALONE_MODULES]
};
//# sourceMappingURL=standalone-modules.js.map