@eclipse-glsp/protocol
Advanced tools
Comparing version 2.2.0-next.336 to 2.2.0-next.337
@@ -17,3 +17,3 @@ /******************************************************************************** | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { GModelRootSchema } from '..'; | ||
import { GModelRootSchema } from '../model'; | ||
import { Operation, RequestAction, ResponseAction } from './base-protocol'; | ||
@@ -20,0 +20,0 @@ import { Args, ElementAndAlignment, ElementAndBounds, ElementAndLayoutData, ElementAndRoutingPoints } from './types'; |
@@ -24,2 +24,7 @@ /******************************************************************************** | ||
/** | ||
* Type guard to check if the given object is a bound. | ||
* @param bounds the object to be checked | ||
*/ | ||
function is(bounds: any): bounds is Bounds; | ||
/** | ||
* Checks whether the inner bounds are compeletely encompassed by the outer bounds. | ||
@@ -185,2 +190,15 @@ * | ||
/** | ||
* Creates a new point from the given bounds by removing the `width` and `height` of the bounds. | ||
* This is the same as the top-left point but this method may carry more semantics. | ||
* @param bounds the bounds | ||
* @returns new point | ||
*/ | ||
function position(bounds: Bounds): Point; | ||
/** | ||
* Creates a new dimension from the given bounds by removing the `x` and `y` of the bounds. | ||
* @param bounds the bounds | ||
* @returns new dimension | ||
*/ | ||
function dimension(bounds: Bounds): Dimension; | ||
/** | ||
* Sorts the given bounds by the given rank function. | ||
@@ -187,0 +205,0 @@ * @param rankFunc the rank function |
@@ -22,2 +22,5 @@ "use strict"; | ||
Object.defineProperty(exports, "Bounds", { enumerable: true, get: function () { return geometry_1.Bounds; } }); | ||
const sprotty_geometry_dimension_1 = require("./sprotty-geometry-dimension"); | ||
const sprotty_geometry_point_1 = require("./sprotty-geometry-point"); | ||
const utils_1 = require("./utils"); | ||
geometry_1.Bounds.ZERO = Object.freeze({ | ||
@@ -29,2 +32,7 @@ x: 0, | ||
}); | ||
geometry_1.Bounds.is = (bounds) => utils_1.AnyObject.is(bounds) && | ||
(0, utils_1.hasNumberProp)(bounds, 'x') && | ||
(0, utils_1.hasNumberProp)(bounds, 'y') && | ||
(0, utils_1.hasNumberProp)(bounds, 'width') && | ||
(0, utils_1.hasNumberProp)(bounds, 'height'); | ||
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)); | ||
@@ -46,3 +54,3 @@ geometry_1.Bounds.overlap = (one, other, touch) => { | ||
}; | ||
geometry_1.Bounds.equals = (left, right, eps) => geometry_1.Point.equals(left, right, eps) && geometry_1.Dimension.equals(left, right, eps); | ||
geometry_1.Bounds.equals = (left, right, eps) => sprotty_geometry_point_1.Point.equals(left, right, eps) && sprotty_geometry_dimension_1.Dimension.equals(left, right, eps); | ||
geometry_1.Bounds.left = (bounds) => bounds.x; | ||
@@ -70,4 +78,6 @@ 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.position = geometry_1.Bounds.topLeft; | ||
geometry_1.Bounds.dimension = (bounds) => ({ width: bounds.width, height: bounds.height }); | ||
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 |
@@ -24,2 +24,7 @@ /******************************************************************************** | ||
/** | ||
* Type guard to check if the given object is a bound. | ||
* @param dimension the object to be checked | ||
*/ | ||
function is(dimension: any): dimension is Dimension; | ||
/** | ||
* Applies the given function to the `width` and `height` of the given dimensional object to create a new dimensional object. | ||
@@ -26,0 +31,0 @@ * |
@@ -22,2 +22,3 @@ "use strict"; | ||
Object.defineProperty(exports, "Dimension", { enumerable: true, get: function () { return geometry_1.Dimension; } }); | ||
const utils_1 = require("./utils"); | ||
const math_util_1 = require("./utils/math-util"); | ||
@@ -28,2 +29,3 @@ geometry_1.Dimension.ZERO = Object.freeze({ | ||
}); | ||
geometry_1.Dimension.is = (dimension) => utils_1.AnyObject.is(dimension) && (0, utils_1.hasNumberProp)(dimension, 'width') && (0, utils_1.hasNumberProp)(dimension, 'height'); | ||
geometry_1.Dimension.center = (d) => ({ x: d.width * 0.5, y: d.height * 0.5 }); | ||
@@ -30,0 +32,0 @@ geometry_1.Dimension.add = (d, a) => ({ width: d.width + a.width, height: d.height + a.height }); |
@@ -17,3 +17,4 @@ /******************************************************************************** | ||
import { Point } from 'sprotty-protocol/lib/utils/geometry'; | ||
import { Movement, Vector } from './utils'; | ||
import { Movement } from './utils/geometry-movement'; | ||
import { Vector } from './utils/geometry-vector'; | ||
declare module 'sprotty-protocol/lib/utils/geometry' { | ||
@@ -20,0 +21,0 @@ namespace Point { |
@@ -22,5 +22,6 @@ "use strict"; | ||
Object.defineProperty(exports, "Point", { enumerable: true, get: function () { return geometry_1.Point; } }); | ||
const utils_1 = require("./utils"); | ||
const geometry_vector_1 = require("./utils/geometry-vector"); | ||
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'); | ||
const type_util_1 = require("./utils/type-util"); | ||
geometry_1.Point.is = (point) => type_util_1.AnyObject.is(point) && (0, type_util_1.hasNumberProp)(point, 'x') && (0, type_util_1.hasNumberProp)(point, 'y'); | ||
geometry_1.Point.isOrigin = (point) => geometry_1.Point.equals(point, geometry_1.Point.ORIGIN); | ||
@@ -46,3 +47,3 @@ geometry_1.Point.isValid = (point) => point !== undefined && !isNaN(point.x) && !isNaN(point.y); | ||
const vector = geometry_1.Point.vector(from, to); | ||
const direction = utils_1.Vector.direction(vector); | ||
const direction = geometry_vector_1.Vector.direction(vector); | ||
return { from, to, vector, direction }; | ||
@@ -52,3 +53,3 @@ }; | ||
const to = geometry_1.Point.add(from, vector); | ||
const dir = utils_1.Vector.direction(vector); | ||
const dir = geometry_vector_1.Vector.direction(vector); | ||
return { from, to, vector, direction: dir }; | ||
@@ -55,0 +56,0 @@ }; |
@@ -16,3 +16,3 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Point } from 'sprotty-protocol/lib/utils/geometry'; | ||
import { Point } from '../sprotty-geometry-point'; | ||
import { Direction } from './geometry-util'; | ||
@@ -19,0 +19,0 @@ import { Vector } from './geometry-vector'; |
@@ -19,3 +19,3 @@ "use strict"; | ||
exports.Movement = void 0; | ||
const geometry_1 = require("sprotty-protocol/lib/utils/geometry"); | ||
const sprotty_geometry_point_1 = require("../sprotty-geometry-point"); | ||
const geometry_vector_1 = require("./geometry-vector"); | ||
@@ -33,4 +33,4 @@ const type_util_1 = require("./type-util"); | ||
Movement.ZERO = Object.freeze({ | ||
from: geometry_1.Point.ORIGIN, | ||
to: geometry_1.Point.ORIGIN, | ||
from: sprotty_geometry_point_1.Point.ORIGIN, | ||
to: sprotty_geometry_point_1.Point.ORIGIN, | ||
vector: geometry_vector_1.Vector.ZERO, | ||
@@ -47,5 +47,5 @@ direction: [] | ||
(0, type_util_1.hasObjectProp)(obj, 'from') && | ||
geometry_1.Point.is(obj.from) && | ||
sprotty_geometry_point_1.Point.is(obj.from) && | ||
(0, type_util_1.hasObjectProp)(obj, 'to') && | ||
geometry_1.Point.is(obj.to) && | ||
sprotty_geometry_point_1.Point.is(obj.to) && | ||
(0, type_util_1.hasObjectProp)(obj, 'vector') && | ||
@@ -81,3 +81,3 @@ geometry_vector_1.Vector.is(obj.to) && | ||
function equals(left, right) { | ||
return geometry_1.Point.equals(left.from, right.from) && geometry_1.Point.equals(left.to, right.to) && geometry_vector_1.Vector.equals(left.vector, right.vector); | ||
return sprotty_geometry_point_1.Point.equals(left.from, right.from) && sprotty_geometry_point_1.Point.equals(left.to, right.to) && geometry_vector_1.Vector.equals(left.vector, right.vector); | ||
} | ||
@@ -84,0 +84,0 @@ Movement.equals = equals; |
{ | ||
"name": "@eclipse-glsp/protocol", | ||
"version": "2.2.0-next.336+c45d827", | ||
"version": "2.2.0-next.337+7e31831", | ||
"description": "The protocol definition for client-server communication in GLSP", | ||
@@ -61,3 +61,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "c45d827fdd923e2009d1814bd939df80bce4fb66" | ||
"gitHead": "7e31831c46d2105422fc0b37d10fb48993d1045f" | ||
} |
@@ -17,3 +17,3 @@ /******************************************************************************** | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { GModelRootSchema } from '..'; | ||
import { GModelRootSchema } from '../model'; | ||
import { hasArrayProp, hasObjectProp } from '../utils/type-util'; | ||
@@ -20,0 +20,0 @@ import { Action, Operation, RequestAction, ResponseAction } from './base-protocol'; |
@@ -21,2 +21,16 @@ /******************************************************************************** | ||
describe('Bounds', () => { | ||
describe('is', () => { | ||
it('should return true if the given object is a bounds', () => { | ||
const bounds: Bounds = { x: 0, y: 0, width: 100, height: 100 }; | ||
const result = Bounds.is(bounds); | ||
expect(result).to.be.true; | ||
}); | ||
it('should return false if the given object is not a bounds', () => { | ||
const bounds = { y: 0, width: 100, height: 100 }; | ||
const result = Bounds.is(bounds); | ||
expect(result).to.be.false; | ||
}); | ||
}); | ||
describe('encompasses', () => { | ||
@@ -278,2 +292,18 @@ it('should return true if the outer bounds completely encompass the inner bounds', () => { | ||
describe('position', () => { | ||
it('should return the position of the bounds', () => { | ||
const bounds: Bounds = { x: 10, y: 20, width: 30, height: 40 }; | ||
const result = Bounds.position(bounds); | ||
expect(result).to.deep.equal({ x: 10, y: 20 }); | ||
}); | ||
}); | ||
describe('dimension', () => { | ||
it('should create a new dimension from the given bounds', () => { | ||
const bounds = { x: 10, y: 20, width: 30, height: 40 }; | ||
const dimension = Bounds.dimension(bounds); | ||
expect(dimension).to.deep.equal({ width: 30, height: 40 }); | ||
}); | ||
}); | ||
describe('sortBy', () => { | ||
@@ -280,0 +310,0 @@ it('should sort the bounds based on the rank function', () => { |
@@ -18,3 +18,6 @@ /******************************************************************************** | ||
import { Bounds, Dimension, Point } from 'sprotty-protocol/lib/utils/geometry'; | ||
import { Bounds } from 'sprotty-protocol/lib/utils/geometry'; | ||
import { Dimension } from './sprotty-geometry-dimension'; | ||
import { Point } from './sprotty-geometry-point'; | ||
import { AnyObject, hasNumberProp } from './utils'; | ||
@@ -29,2 +32,8 @@ declare module 'sprotty-protocol/lib/utils/geometry' { | ||
/** | ||
* Type guard to check if the given object is a bound. | ||
* @param bounds the object to be checked | ||
*/ | ||
function is(bounds: any): bounds is Bounds; | ||
/** | ||
* Checks whether the inner bounds are compeletely encompassed by the outer bounds. | ||
@@ -214,2 +223,17 @@ * | ||
/** | ||
* Creates a new point from the given bounds by removing the `width` and `height` of the bounds. | ||
* This is the same as the top-left point but this method may carry more semantics. | ||
* @param bounds the bounds | ||
* @returns new point | ||
*/ | ||
function position(bounds: Bounds): Point; | ||
/** | ||
* Creates a new dimension from the given bounds by removing the `x` and `y` of the bounds. | ||
* @param bounds the bounds | ||
* @returns new dimension | ||
*/ | ||
function dimension(bounds: Bounds): Dimension; | ||
/** | ||
* Sorts the given bounds by the given rank function. | ||
@@ -247,2 +271,9 @@ * @param rankFunc the rank function | ||
Bounds.is = (bounds: any): bounds is Bounds => | ||
AnyObject.is(bounds) && | ||
hasNumberProp(bounds, 'x') && | ||
hasNumberProp(bounds, 'y') && | ||
hasNumberProp(bounds, 'width') && | ||
hasNumberProp(bounds, 'height'); | ||
Bounds.encompasses = (outer: Bounds, inner: Bounds): boolean => | ||
@@ -318,2 +349,6 @@ Bounds.includes(outer, Bounds.topLeft(inner)) && Bounds.includes(outer, Bounds.bottomRight(inner)); | ||
Bounds.position = Bounds.topLeft; | ||
Bounds.dimension = (bounds: Bounds): Dimension => ({ width: bounds.width, height: bounds.height }); | ||
Bounds.move = Bounds.translate; | ||
@@ -320,0 +355,0 @@ |
@@ -20,2 +20,20 @@ /******************************************************************************** | ||
describe('Dimension', () => { | ||
describe('ZERO', () => { | ||
it('should have width and height set to 0', () => { | ||
expect(Dimension.ZERO).to.deep.equal({ width: 0, height: 0 }); | ||
}); | ||
}); | ||
describe('is', () => { | ||
it('should return true if the given object is a dimension', () => { | ||
const dimension: Dimension = { width: 10, height: 20 }; | ||
expect(Dimension.is(dimension)).to.be.true; | ||
}); | ||
it('should return false if the given object is not a dimension', () => { | ||
const dimension = { height: 20 }; | ||
expect(Dimension.is(dimension)).to.be.false; | ||
}); | ||
}); | ||
describe('map', () => { | ||
@@ -22,0 +40,0 @@ it('should apply the given function to width and height', () => { |
@@ -19,2 +19,3 @@ /******************************************************************************** | ||
import { Dimension, Point } from 'sprotty-protocol/lib/utils/geometry'; | ||
import { AnyObject, hasNumberProp } from './utils'; | ||
import { equalUpTo } from './utils/math-util'; | ||
@@ -30,2 +31,8 @@ | ||
/** | ||
* Type guard to check if the given object is a bound. | ||
* @param dimension the object to be checked | ||
*/ | ||
function is(dimension: any): dimension is Dimension; | ||
/** | ||
* Applies the given function to the `width` and `height` of the given dimensional object to create a new dimensional object. | ||
@@ -38,2 +45,3 @@ * | ||
function map<T extends Dimension>(dimension: T, callbackfn: (value: number, key: keyof Dimension) => number): T; | ||
/** | ||
@@ -110,2 +118,4 @@ * Returns the center point of the given dimension. | ||
Dimension.is = (dimension: any): dimension is Dimension => | ||
AnyObject.is(dimension) && hasNumberProp(dimension, 'width') && hasNumberProp(dimension, 'height'); | ||
Dimension.center = (d: Dimension): Point => ({ x: d.width * 0.5, y: d.height * 0.5 }); | ||
@@ -112,0 +122,0 @@ Dimension.add = (d: Dimension, a: Dimension): Dimension => ({ width: d.width + a.width, height: d.height + a.height }); |
@@ -19,4 +19,6 @@ /******************************************************************************** | ||
import { Point } from 'sprotty-protocol/lib/utils/geometry'; | ||
import { AnyObject, Movement, Vector, hasNumberProp } from './utils'; | ||
import { Movement } from './utils/geometry-movement'; | ||
import { Vector } from './utils/geometry-vector'; | ||
import { equalUpTo } from './utils/math-util'; | ||
import { AnyObject, hasNumberProp } from './utils/type-util'; | ||
@@ -23,0 +25,0 @@ declare module 'sprotty-protocol/lib/utils/geometry' { |
@@ -17,3 +17,3 @@ /******************************************************************************** | ||
import { Point } from 'sprotty-protocol/lib/utils/geometry'; | ||
import { Point } from '../sprotty-geometry-point'; | ||
import { Direction } from './geometry-util'; | ||
@@ -20,0 +20,0 @@ import { Vector } from './geometry-vector'; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 12 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 12 instances in 1 package
1115458
19441