UNPKG

@theia/core

Version:

Theia is a cloud & desktop IDE framework implemented in TypeScript.

58 lines 2.6 kB
"use strict"; // ***************************************************************************** // Copyright (C) 2022 STMicroelectronics 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 // ***************************************************************************** Object.defineProperty(exports, "__esModule", { value: true }); exports.MsgPackExtensionManager = void 0; const msgpackr_1 = require("msgpackr"); /** * Handles the global registration of custom MsgPackR extensions * required for the default RPC communication. MsgPackR extensions * are installed globally on both ends of the communication channel. * (frontend-backend, pluginExt-pluginMain). * Is implemented as singleton as it is also used in plugin child processes which have no access to inversify. */ class MsgPackExtensionManager { constructor() { this.extensions = new Map(); } static getInstance() { return this.INSTANCE; } registerExtensions(...extensions) { extensions.forEach(extension => { if (extension.tag < 1 || extension.tag > 100) { // MsgPackR reserves the tag range 1-100 for custom extensions. throw new Error(`MsgPack extension tag should be a number from 1-100 but was '${extension.tag}'`); } if (this.extensions.has(extension.tag)) { throw new Error(`Another MsgPack extension with the tag '${extension.tag}' is already registered`); } this.extensions.set(extension.tag, extension); (0, msgpackr_1.addExtension)({ Class: extension.class, type: extension.tag, write: extension.serialize, read: extension.deserialize }); }); } getExtension(tag) { return this.extensions.get(tag); } } exports.MsgPackExtensionManager = MsgPackExtensionManager; MsgPackExtensionManager.INSTANCE = new MsgPackExtensionManager(); //# sourceMappingURL=msg-pack-extension-manager.js.map