@eclipse-glsp/protocol
Advanced tools
Comparing version 2.2.0-next.326 to 2.2.0-next.328
@@ -22,4 +22,6 @@ /******************************************************************************** | ||
export * from './sprotty-actions'; | ||
export * from './sprotty-geometry-bounds'; | ||
export * from './sprotty-geometry-dimension'; | ||
export * from './sprotty-geometry-point'; | ||
export * from './utils'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -38,4 +38,6 @@ "use strict"; | ||
__exportStar(require("./sprotty-actions"), exports); | ||
__exportStar(require("./sprotty-geometry-bounds"), exports); | ||
__exportStar(require("./sprotty-geometry-dimension"), exports); | ||
__exportStar(require("./sprotty-geometry-point"), exports); | ||
__exportStar(require("./utils"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -17,5 +17,13 @@ /******************************************************************************** | ||
import { Point } from 'sprotty-protocol/lib/utils/geometry'; | ||
import { Movement, Vector } from './utils'; | ||
declare module 'sprotty-protocol/lib/utils/geometry' { | ||
namespace Point { | ||
function is(point: any): point is Point; | ||
/** | ||
* The absolute variant of that point, i.e., each coordinate uses its absolute value. | ||
* | ||
* @param point the point | ||
*/ | ||
function isOrigin(point: Point): boolean; | ||
/** | ||
* Type guard to check if a point is valid. For a point to be valid it needs to be defined and have valid x and y coordinates. | ||
@@ -26,2 +34,62 @@ * | ||
function isValid(point?: Point): point is Point; | ||
/** | ||
* The absolute variant of that point, i.e., each coordinate uses its absolute value. | ||
* | ||
* @param point the point | ||
*/ | ||
function abs(point: Point): Point; | ||
/** | ||
* Applys a uniform scaling on the given point with respect to the origin. | ||
* Functionally, this divides both coordinates by the given scalar. | ||
* | ||
* @param point the point to be scaled | ||
* @param scalar The factor by which the point schould be scaled | ||
*/ | ||
function divideScalar(point: Point, scalar: number): Point; | ||
/** | ||
* Applys a uniform scaling on the given point with respect to the origin. | ||
* Functionally, this multiplies both coordinates by the given scalar. | ||
* | ||
* @param point the point to be scaled | ||
* @param scalar The factor by which the point schould be scaled | ||
*/ | ||
function multiplyScalar(point: Point, scalar: number): Point; | ||
/** | ||
* Applies the given function to the `x` and `y` coordinate of the given point to create a new point. | ||
* | ||
* @param point source point | ||
* @param callbackfn function applied to the `x` and `y` coordinate of the given point to create a new point | ||
* @returns new point | ||
*/ | ||
function map<T extends Point>(point: T, callbackfn: (value: number, key: keyof Point) => number): T; | ||
/** | ||
* Snaps the given point to the nearest point on the given grid. | ||
* | ||
* @param point point to be snapped | ||
* @param grid grid | ||
* @param gridOrigin grid origin | ||
* @returns a point on the given grid that is closest tot he given point | ||
*/ | ||
function snapToGrid(point: Point, grid: Point, gridOrigin?: Point): Point; | ||
/** | ||
* Computes a vector from the given `from` point to the `to` point. | ||
* @param from the starting point | ||
* @param to the end point | ||
* @returns the vector from `from` to `to` | ||
*/ | ||
function vector(from: Point, to: Point): Vector; | ||
/** | ||
* Computes the movement from the given `from` point to the `to` point. | ||
* @param from the starting point | ||
* @param to the end point | ||
* @returns the movement from `from` to `to` | ||
*/ | ||
function move(from: Point, to: Point): Movement; | ||
/** | ||
* Computes the movement from the given `from` point in the given `vector` direction. | ||
* @param from the starting point | ||
* @param vector the vector direction | ||
* @returns the movement from `from` in the `vector` direction | ||
*/ | ||
function moveTowards(from: Point, vector: Vector): Movement; | ||
} | ||
@@ -28,0 +96,0 @@ } |
@@ -22,3 +22,32 @@ "use strict"; | ||
Object.defineProperty(exports, "Point", { enumerable: true, get: function () { return geometry_1.Point; } }); | ||
const utils_1 = require("./utils"); | ||
geometry_1.Point.is = (point) => utils_1.AnyObject.is(point) && (0, utils_1.hasNumberProp)(point, 'x') && (0, utils_1.hasNumberProp)(point, 'y'); | ||
geometry_1.Point.isOrigin = (point) => geometry_1.Point.equals(point, geometry_1.Point.ORIGIN); | ||
geometry_1.Point.isValid = (point) => point !== undefined && !isNaN(point.x) && !isNaN(point.y); | ||
geometry_1.Point.abs = (point) => geometry_1.Point.map(point, Math.abs); | ||
geometry_1.Point.divideScalar = (point, scalar) => geometry_1.Point.map(point, coordinate => coordinate / scalar); | ||
geometry_1.Point.multiplyScalar = (point, scalar) => geometry_1.Point.map(point, coordinate => coordinate * scalar); | ||
geometry_1.Point.map = (point, callbackfn) => (Object.assign(Object.assign({}, point), { x: callbackfn(point.x, 'x'), y: callbackfn(point.y, 'y') })); | ||
geometry_1.Point.snapToGrid = (point, grid, gridOrigin) => { | ||
if (gridOrigin) { | ||
// move point relative to grid origin and then restore after snapping | ||
const relative = geometry_1.Point.subtract(point, gridOrigin); | ||
const snapped = geometry_1.Point.snapToGrid(relative, grid); | ||
return geometry_1.Point.add(gridOrigin, snapped); | ||
} | ||
else { | ||
return { x: Math.round(point.x / grid.x) * grid.x, y: Math.round(point.y / grid.y) * grid.y }; | ||
} | ||
}; | ||
geometry_1.Point.vector = (from, to) => geometry_1.Point.subtract(to, from); | ||
geometry_1.Point.move = (from, to) => { | ||
const vector = geometry_1.Point.vector(from, to); | ||
const direction = utils_1.Vector.direction(vector); | ||
return { from, to, vector, direction }; | ||
}; | ||
geometry_1.Point.moveTowards = (from, vector) => { | ||
const to = geometry_1.Point.add(from, vector); | ||
const dir = utils_1.Vector.direction(vector); | ||
return { from, to, vector, direction: dir }; | ||
}; | ||
//# sourceMappingURL=sprotty-geometry-point.js.map |
@@ -19,3 +19,6 @@ /******************************************************************************** | ||
export * from './event'; | ||
export * from './geometry-movement'; | ||
export * from './geometry-util'; | ||
export * from './geometry-vector'; | ||
export * from './type-util'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -35,2 +35,5 @@ "use strict"; | ||
__exportStar(require("./event"), exports); | ||
__exportStar(require("./geometry-movement"), exports); | ||
__exportStar(require("./geometry-util"), exports); | ||
__exportStar(require("./geometry-vector"), exports); | ||
// we do not export test-util to avoid a dependency on test frameworks such as chai | ||
@@ -37,0 +40,0 @@ // however, adopters can still access the file by accessing it through the complete path |
{ | ||
"name": "@eclipse-glsp/protocol", | ||
"version": "2.2.0-next.326+43b1470", | ||
"version": "2.2.0-next.328+c2ca345", | ||
"description": "The protocol definition for client-server communication in GLSP", | ||
@@ -39,3 +39,4 @@ "keywords": [ | ||
"build": "tsc -b", | ||
"clean": "rimraf lib *.tsbuildinfo coverage .nyc_output ", | ||
"clean": "rimraf lib *.tsbuildinfo coverage .nyc_output", | ||
"generate:index": "glsp generateIndex src -f", | ||
"lint": "eslint --ext .ts,.tsx ./src", | ||
@@ -61,3 +62,3 @@ "test": "mocha --config ../../.mocharc \"./src/**/*.spec.?(ts|tsx)\"", | ||
}, | ||
"gitHead": "43b14705d06f9b42eccc78108951ebd04198471e" | ||
"gitHead": "c2ca34551f9d9268eae3be66de23e3782e880af1" | ||
} |
/******************************************************************************** | ||
* Copyright (c) 2023 EclipseSource and others. | ||
* Copyright (c) 2023-2024 EclipseSource and others. | ||
* | ||
@@ -58,3 +58,6 @@ * This program and the accompanying materials are made available under the | ||
constructor(protected url: string, options?: GLSPWebSocketOptions) { | ||
constructor( | ||
protected url: string, | ||
options?: GLSPWebSocketOptions | ||
) { | ||
this.options = Object.assign(this.options, options); | ||
@@ -61,0 +64,0 @@ } |
@@ -18,3 +18,2 @@ /******************************************************************************** | ||
export * from './client-server-protocol'; | ||
export * from './di'; | ||
export * from './model'; | ||
@@ -25,2 +24,1 @@ export * from './re-exports'; | ||
export * from './utils'; | ||
@@ -19,5 +19,2 @@ /******************************************************************************** | ||
export * from './event'; | ||
// we do not export test-util to avoid a dependency on test frameworks such as chai | ||
// however, adopters can still access the file by accessing it through the complete path | ||
// export * from './test-util'; | ||
export * from './type-util'; |
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 8 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 8 instances in 1 package
1396574
414
21441