UNPKG

@eclipse-glsp/protocol

Version:

The protocol definition for client-server communication in GLSP

42 lines 2.57 kB
"use strict"; /******************************************************************************** * Copyright (c) 2024 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 ********************************************************************************/ /* eslint-disable @typescript-eslint/no-shadow */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Dimension = void 0; const geometry_1 = require("sprotty-protocol/lib/utils/geometry"); Object.defineProperty(exports, "Dimension", { enumerable: true, get: function () { return geometry_1.Dimension; } }); const math_util_1 = require("./utils/math-util"); const type_util_1 = require("./utils/type-util"); geometry_1.Dimension.ZERO = Object.freeze({ width: 0, height: 0 }); geometry_1.Dimension.is = (dimension) => type_util_1.AnyObject.is(dimension) && (0, type_util_1.hasNumberProp)(dimension, 'width') && (0, type_util_1.hasNumberProp)(dimension, 'height'); geometry_1.Dimension.center = (d) => ({ x: d.width * 0.5, y: d.height * 0.5 }); geometry_1.Dimension.add = (d, a) => ({ width: d.width + a.width, height: d.height + a.height }); geometry_1.Dimension.subtract = (d, a) => ({ width: d.width - a.width, height: d.height - a.height }); geometry_1.Dimension.multiplyMeasure = (d, m) => ({ width: d.width * m, height: d.height * m }); geometry_1.Dimension.divideMeasure = (d, m) => ({ width: d.width / m, height: d.height / m }); geometry_1.Dimension.map = (dimension, callbackfn) => ({ ...dimension, width: callbackfn(dimension.width, 'width'), height: callbackfn(dimension.height, 'height') }); geometry_1.Dimension.equals = (left, right, eps) => (0, math_util_1.equalUpTo)(left.width, right.width, eps) && (0, math_util_1.equalUpTo)(left.height, right.height, eps); geometry_1.Dimension.fromPoint = (point) => ({ width: point.x, height: point.y }); geometry_1.Dimension.area = (dimension) => dimension.width * dimension.height; //# sourceMappingURL=sprotty-geometry-dimension.js.map