Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eclipse-glsp/protocol

Package Overview
Dependencies
Maintainers
6
Versions
295
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eclipse-glsp/protocol - npm Package Compare versions

Comparing version 2.2.0-next.333 to 2.2.0-next.334

lib/utils/math-util.d.ts

7

lib/action-protocol/model-layout.d.ts

@@ -19,3 +19,3 @@ /********************************************************************************

import { Operation, RequestAction, ResponseAction } from './base-protocol';
import { Args, ElementAndAlignment, ElementAndBounds, ElementAndRoutingPoints } from './types';
import { Args, ElementAndAlignment, ElementAndBounds, ElementAndLayoutData, ElementAndRoutingPoints } from './types';
/**

@@ -63,2 +63,6 @@ * Sent from the server to the client to request bounds for the given model. The model is rendered invisibly so the bounds can

routes?: ElementAndRoutingPoints[];
/**
* The layout data of hte model elements.
*/
layoutData?: ElementAndLayoutData[];
}

@@ -73,2 +77,3 @@ export declare namespace ComputedBoundsAction {

routes?: ElementAndRoutingPoints[];
layoutData?: ElementAndLayoutData[];
}): ComputedBoundsAction;

@@ -75,0 +80,0 @@ }

@@ -76,2 +76,24 @@ /********************************************************************************

/**
* Data provided by the layouter.
*/
export interface LayoutData {
/**
* The computed minimum size of the element.
*/
computedDimensions?: Dimension;
}
/**
* The `ElementAndLayoutData` type is used to associate new layout data with a model element, which is referenced via its id.
*/
export interface ElementAndLayoutData {
/**
* The identifier of the element.
*/
elementId: string;
/**
* The data provided by the layouter.
*/
layoutData: LayoutData;
}
/**
* The `EditorContext` may be used to represent the current state of the editor for particular actions.

@@ -78,0 +100,0 @@ * It encompasses the last recorded mouse position, the list of selected elements, and may contain

@@ -20,2 +20,6 @@ /********************************************************************************

/**
* The empty bounds with valid dimensions. It has x, y, width, and height set to 0.
*/
const ZERO: Bounds;
/**
* Checks whether the inner bounds are compeletely encompassed by the outer bounds.

@@ -41,5 +45,6 @@ *

* @param right right bounds
* @param eps the epsilon for the comparison
* @returns true if the two bounds are equal
*/
function equals(left: Bounds, right: Bounds): boolean;
function equals(left: Bounds, right: Bounds, eps?: number): boolean;
/**

@@ -187,2 +192,16 @@ * Returns the x-coordinate of the left edge of the bounds.

function sortBy<T>(rankFunc: (elem: T) => number, ...bounds: T[]): T[];
/**
* Moves the bounds by the given delta.
* @param bounds the bounds to move
* @param delta the delta to move the bounds by
* @returns the moved bounds
*/
function move(bounds: Bounds, delta: Point): Bounds;
/**
* Resizes the bounds by the given delta.
* @param bounds the bounds to resize
* @param delta the delta to resize the bounds by
* @returns the resized bounds
*/
function resize(bounds: Bounds, delta: Dimension): Bounds;
}

@@ -189,0 +208,0 @@ }

@@ -22,2 +22,8 @@ "use strict";

Object.defineProperty(exports, "Bounds", { enumerable: true, get: function () { return geometry_1.Bounds; } });
geometry_1.Bounds.ZERO = Object.freeze({
x: 0,
y: 0,
width: 0,
height: 0
});
geometry_1.Bounds.encompasses = (outer, inner) => geometry_1.Bounds.includes(outer, geometry_1.Bounds.topLeft(inner)) && geometry_1.Bounds.includes(outer, geometry_1.Bounds.bottomRight(inner));

@@ -39,3 +45,3 @@ geometry_1.Bounds.overlap = (one, other, touch) => {

};
geometry_1.Bounds.equals = (left, right) => geometry_1.Point.equals(left, right) && geometry_1.Dimension.equals(left, right);
geometry_1.Bounds.equals = (left, right, eps) => geometry_1.Point.equals(left, right, eps) && geometry_1.Dimension.equals(left, right, eps);
geometry_1.Bounds.left = (bounds) => bounds.x;

@@ -63,2 +69,4 @@ geometry_1.Bounds.centerX = (bounds) => bounds.x + (bounds.width >= 0 ? bounds.width * 0.5 : 0);

geometry_1.Bounds.from = (topLeft, bottomRight) => (Object.assign(Object.assign({}, topLeft), { width: bottomRight.x - topLeft.x, height: bottomRight.y - topLeft.y }));
geometry_1.Bounds.move = geometry_1.Bounds.translate;
geometry_1.Bounds.resize = (bounds, delta) => (Object.assign(Object.assign({}, bounds), { width: bounds.width + delta.width, height: bounds.height + delta.height }));
//# sourceMappingURL=sprotty-geometry-bounds.js.map

@@ -71,5 +71,6 @@ /********************************************************************************

* @param right the right dimension
* @param eps @param eps the epsilon for the comparison
* @returns true if the dimensions are equal, false otherwise
*/
function equals(left: Dimension, right: Dimension): boolean;
function equals(left: Dimension, right: Dimension, eps?: number): boolean;
/**

@@ -81,2 +82,8 @@ * Creates a new dimension from the given point. The `width` and `height` of the new dimension are the `x` and `y` of the point.

function fromPoint(point: Point): Dimension;
/**
* Computes the area of the given dimension.
* @param dimension the dimension
* @returns the area of the dimension
*/
function area(dimension: Dimension): number;
}

@@ -83,0 +90,0 @@ }

4

lib/sprotty-geometry-dimension.js

@@ -22,2 +22,3 @@ "use strict";

Object.defineProperty(exports, "Dimension", { enumerable: true, get: function () { return geometry_1.Dimension; } });
const math_util_1 = require("./utils/math-util");
geometry_1.Dimension.ZERO = Object.freeze({

@@ -33,4 +34,5 @@ width: 0,

geometry_1.Dimension.map = (dimension, callbackfn) => (Object.assign(Object.assign({}, dimension), { width: callbackfn(dimension.width, 'width'), height: callbackfn(dimension.height, 'height') }));
geometry_1.Dimension.equals = (left, right) => left.width === right.width && left.height === right.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

@@ -20,2 +20,6 @@ /********************************************************************************

namespace Point {
/**
* Type guard to check if the given object is a point.
* @param point the object to be checked
*/
function is(point: any): point is Point;

@@ -35,2 +39,9 @@ /**

/**
* Checks whether the given points are equal up to a certain epsilon.
* @param one the first point
* @param other the second point
* @param eps @param eps the epsilon for the comparison
*/
function equals(one: Point, other: Point, eps?: number): boolean;
/**
* The absolute variant of that point, i.e., each coordinate uses its absolute value.

@@ -37,0 +48,0 @@ *

@@ -23,2 +23,3 @@ "use strict";

const utils_1 = require("./utils");
const math_util_1 = require("./utils/math-util");
geometry_1.Point.is = (point) => utils_1.AnyObject.is(point) && (0, utils_1.hasNumberProp)(point, 'x') && (0, utils_1.hasNumberProp)(point, 'y');

@@ -53,2 +54,3 @@ geometry_1.Point.isOrigin = (point) => geometry_1.Point.equals(point, geometry_1.Point.ORIGIN);

};
geometry_1.Point.equals = (one, other, eps) => (0, math_util_1.equalUpTo)(one.x, other.x, eps) && (0, math_util_1.equalUpTo)(one.y, other.y, eps);
//# sourceMappingURL=sprotty-geometry-point.js.map

@@ -22,3 +22,4 @@ /********************************************************************************

export * from './geometry-vector';
export * from './math-util';
export * from './type-util';
//# sourceMappingURL=index.d.ts.map

@@ -38,3 +38,4 @@ "use strict";

__exportStar(require("./geometry-vector"), exports);
__exportStar(require("./math-util"), exports);
__exportStar(require("./type-util"), exports);
//# sourceMappingURL=index.js.map

@@ -62,2 +62,4 @@ /********************************************************************************

export type TypeGuard<T> = (element: any) => element is T;
/** Utility function to combine two type guards */
export declare function typeGuard<T, G>(one: TypeGuard<T>, other: TypeGuard<G>): TypeGuard<T & G>;
/**

@@ -64,0 +66,0 @@ * Utility function that create a typeguard function for a given class constructor.

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.hasArrayProp = exports.hasFunctionProp = exports.hasObjectProp = exports.hasNumberProp = exports.hasBooleanProp = exports.hasStringProp = exports.call = exports.toTypeGuard = exports.AnyObject = void 0;
exports.hasArrayProp = exports.hasFunctionProp = exports.hasObjectProp = exports.hasNumberProp = exports.hasBooleanProp = exports.hasStringProp = exports.call = exports.toTypeGuard = exports.typeGuard = exports.AnyObject = void 0;
var AnyObject;

@@ -33,2 +33,7 @@ (function (AnyObject) {

})(AnyObject || (exports.AnyObject = AnyObject = {}));
/** Utility function to combine two type guards */
function typeGuard(one, other) {
return (element) => one(element) && other(element);
}
exports.typeGuard = typeGuard;
/**

@@ -35,0 +40,0 @@ * Utility function that create a typeguard function for a given class constructor.

{
"name": "@eclipse-glsp/protocol",
"version": "2.2.0-next.333+50b1e85",
"version": "2.2.0-next.334+a0e5612",
"description": "The protocol definition for client-server communication in GLSP",

@@ -61,3 +61,3 @@ "keywords": [

},
"gitHead": "50b1e85e8d2acf2fc73a2280dcb0151d617e0286"
"gitHead": "a0e5612080a868a3c742d5cabab717a44e300f67"
}

@@ -20,3 +20,3 @@ /********************************************************************************

import { Action, Operation, RequestAction, ResponseAction } from './base-protocol';
import { Args, ElementAndAlignment, ElementAndBounds, ElementAndRoutingPoints } from './types';
import { Args, ElementAndAlignment, ElementAndBounds, ElementAndLayoutData, ElementAndRoutingPoints } from './types';

@@ -83,2 +83,7 @@ /**

routes?: ElementAndRoutingPoints[];
/**
* The layout data of hte model elements.
*/
layoutData?: ElementAndLayoutData[];
}

@@ -100,2 +105,3 @@

routes?: ElementAndRoutingPoints[];
layoutData?: ElementAndLayoutData[];
} = {}

@@ -102,0 +108,0 @@ ): ComputedBoundsAction {

@@ -85,2 +85,26 @@ /********************************************************************************

/**
* Data provided by the layouter.
*/
export interface LayoutData {
/**
* The computed minimum size of the element.
*/
computedDimensions?: Dimension;
}
/**
* The `ElementAndLayoutData` type is used to associate new layout data with a model element, which is referenced via its id.
*/
export interface ElementAndLayoutData {
/**
* The identifier of the element.
*/
elementId: string;
/**
* The data provided by the layouter.
*/
layoutData: LayoutData;
}
/**
* The `EditorContext` may be used to represent the current state of the editor for particular actions.

@@ -87,0 +111,0 @@ * It encompasses the last recorded mouse position, the list of selected elements, and may contain

@@ -17,3 +17,3 @@ /********************************************************************************

import { expect } from 'chai';
import { Point } from 'sprotty-protocol';
import { Dimension, Point } from 'sprotty-protocol';
import { Bounds } from './sprotty-geometry-bounds';

@@ -288,2 +288,34 @@

});
describe('move', () => {
it('should move the bounds by the given delta', () => {
const bounds: Bounds = { x: 10, y: 20, width: 100, height: 200 };
const delta: Point = { x: 10, y: 20 };
const result = Bounds.move(bounds, delta);
expect(result).to.deep.equal({ x: 20, y: 40, width: 100, height: 200 });
});
it('should move the bounds by the given delta with negative values', () => {
const bounds: Bounds = { x: 10, y: 20, width: 100, height: 200 };
const delta: Point = { x: -10, y: -20 };
const result = Bounds.move(bounds, delta);
expect(result).to.deep.equal({ x: 0, y: 0, width: 100, height: 200 });
});
});
describe('resize', () => {
it('should resize the bounds by the given delta', () => {
const bounds: Bounds = { x: 10, y: 20, width: 100, height: 200 };
const delta: Dimension = { width: 10, height: 20 };
const result = Bounds.resize(bounds, delta);
expect(result).to.deep.equal({ x: 10, y: 20, width: 110, height: 220 });
});
it('should resize the bounds by the given delta with negative values', () => {
const bounds: Bounds = { x: 10, y: 20, width: 100, height: 200 };
const delta: Dimension = { width: -10, height: -20 };
const result = Bounds.resize(bounds, delta);
expect(result).to.deep.equal({ x: 10, y: 20, width: 90, height: 180 });
});
});
});

@@ -23,2 +23,7 @@ /********************************************************************************

/**
* The empty bounds with valid dimensions. It has x, y, width, and height set to 0.
*/
const ZERO: Bounds;
/**
* Checks whether the inner bounds are compeletely encompassed by the outer bounds.

@@ -46,5 +51,6 @@ *

* @param right right bounds
* @param eps the epsilon for the comparison
* @returns true if the two bounds are equal
*/
function equals(left: Bounds, right: Bounds): boolean;
function equals(left: Bounds, right: Bounds, eps?: number): boolean;

@@ -214,5 +220,28 @@ /**

function sortBy<T>(rankFunc: (elem: T) => number, ...bounds: T[]): T[];
/**
* Moves the bounds by the given delta.
* @param bounds the bounds to move
* @param delta the delta to move the bounds by
* @returns the moved bounds
*/
function move(bounds: Bounds, delta: Point): Bounds;
/**
* Resizes the bounds by the given delta.
* @param bounds the bounds to resize
* @param delta the delta to resize the bounds by
* @returns the resized bounds
*/
function resize(bounds: Bounds, delta: Dimension): Bounds;
}
}
(Bounds as any).ZERO = Object.freeze({
x: 0,
y: 0,
width: 0,
height: 0
});
Bounds.encompasses = (outer: Bounds, inner: Bounds): boolean =>

@@ -237,3 +266,4 @@ Bounds.includes(outer, Bounds.topLeft(inner)) && Bounds.includes(outer, Bounds.bottomRight(inner));

Bounds.equals = (left: Bounds, right: Bounds): boolean => Point.equals(left, right) && Dimension.equals(left, right);
Bounds.equals = (left: Bounds, right: Bounds, eps?: number): boolean =>
Point.equals(left, right, eps) && Dimension.equals(left, right, eps);

@@ -288,2 +318,10 @@ Bounds.left = (bounds: Bounds): number => bounds.x;

Bounds.move = Bounds.translate;
Bounds.resize = (bounds: Bounds, delta: Dimension): Bounds => ({
...bounds,
width: bounds.width + delta.width,
height: bounds.height + delta.height
});
export { Bounds };

@@ -86,2 +86,23 @@ /********************************************************************************

});
it('should return false if the dimensions have different width', () => {
const dimension1: Dimension = { width: 10, height: 20 };
const dimension2: Dimension = { width: 5, height: 20 };
const isEqual = Dimension.equals(dimension1, dimension2);
expect(isEqual).to.be.false;
});
it('should return false if the dimensions have different height', () => {
const dimension1: Dimension = { width: 10, height: 20 };
const dimension2: Dimension = { width: 10, height: 10 };
const isEqual = Dimension.equals(dimension1, dimension2);
expect(isEqual).to.be.false;
});
it('should consider epsilon', () => {
const dimension1: Dimension = { width: 10, height: 20 };
const dimension2: Dimension = { width: 10.0001, height: 20.0001 };
const isEqual = Dimension.equals(dimension1, dimension2, 0.001);
expect(isEqual).to.be.true;
});
});

@@ -96,2 +117,10 @@

});
describe('area', () => {
it('should compute the area of the dimension', () => {
const dimension: Dimension = { width: 10, height: 20 };
const area = Dimension.area(dimension);
expect(area).to.equal(200);
});
});
});

@@ -19,2 +19,3 @@ /********************************************************************************

import { Dimension, Point } from 'sprotty-protocol/lib/utils/geometry';
import { equalUpTo } from './utils/math-util';

@@ -81,5 +82,6 @@ declare module 'sprotty-protocol/lib/utils/geometry' {

* @param right the right dimension
* @param eps @param eps the epsilon for the comparison
* @returns true if the dimensions are equal, false otherwise
*/
function equals(left: Dimension, right: Dimension): boolean;
function equals(left: Dimension, right: Dimension, eps?: number): boolean;

@@ -92,2 +94,9 @@ /**

function fromPoint(point: Point): Dimension;
/**
* Computes the area of the given dimension.
* @param dimension the dimension
* @returns the area of the dimension
*/
function area(dimension: Dimension): number;
}

@@ -112,5 +121,7 @@ }

});
Dimension.equals = (left: Dimension, right: Dimension): boolean => left.width === right.width && left.height === right.height;
Dimension.equals = (left: Dimension, right: Dimension, eps?: number): boolean =>
equalUpTo(left.width, right.width, eps) && equalUpTo(left.height, right.height, eps);
Dimension.fromPoint = (point: Point): Dimension => ({ width: point.x, height: point.y });
Dimension.area = (dimension: Dimension): number => dimension.width * dimension.height;
export { Dimension };

@@ -116,2 +116,16 @@ /********************************************************************************

});
describe('equals', () => {
it('returns true for equal points', () => {
expect(Point.equals({ x: 1, y: 2 }, { x: 1, y: 2 })).to.be.true;
});
it('returns false for different points', () => {
expect(Point.equals({ x: 1, y: 2 }, { x: 1, y: 3 })).to.be.false;
});
it('returns true up to an epsilon', () => {
expect(Point.equals({ x: 1, y: 2 }, { x: 1.0001, y: 2.0001 }, 0.001)).to.be.true;
});
});
});

@@ -20,5 +20,10 @@ /********************************************************************************

import { AnyObject, Movement, Vector, hasNumberProp } from './utils';
import { equalUpTo } from './utils/math-util';
declare module 'sprotty-protocol/lib/utils/geometry' {
namespace Point {
/**
* Type guard to check if the given object is a point.
* @param point the object to be checked
*/
function is(point: any): point is Point;

@@ -37,3 +42,12 @@ /**

function isValid(point?: Point): point is Point;
/**
* Checks whether the given points are equal up to a certain epsilon.
* @param one the first point
* @param other the second point
* @param eps @param eps the epsilon for the comparison
*/
function equals(one: Point, other: Point, eps?: number): boolean;
/**
* The absolute variant of that point, i.e., each coordinate uses its absolute value.

@@ -140,2 +154,4 @@ *

Point.equals = (one: Point, other: Point, eps?: number): boolean => equalUpTo(one.x, other.x, eps) && equalUpTo(one.y, other.y, eps);
export { Point };

@@ -22,2 +22,3 @@ /********************************************************************************

export * from './geometry-vector';
export * from './math-util';
export * from './type-util';

@@ -72,2 +72,7 @@ /********************************************************************************

/** Utility function to combine two type guards */
export function typeGuard<T, G>(one: TypeGuard<T>, other: TypeGuard<G>): TypeGuard<T & G> {
return (element: any): element is T & G => one(element) && other(element);
}
/**

@@ -74,0 +79,0 @@ * Utility function that create a typeguard function for a given class constructor.

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc