UNPKG

@vscode/sync-api-common

Version:

An RPC implementation between Web and NodeJS workers that works sync

29 lines (28 loc) 1.2 kB
"use strict"; /* -------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MessageConnection = void 0; const ral_1 = __importDefault(require("../common/ral")); const messageConnection_1 = require("../common/messageConnection"); class MessageConnection extends messageConnection_1.BaseMessageConnection { port; constructor(port) { super(); this.port = port; } postMessage(message, transferList) { this.port.postMessage(message, transferList); } listen() { this.port.on('message', (value) => { this.handleMessage(value).catch((0, ral_1.default)().console.error); }); } } exports.MessageConnection = MessageConnection;