Socket
Socket
Sign inDemoInstall

sprotty

Package Overview
Dependencies
Maintainers
3
Versions
237
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sprotty - npm Package Compare versions

Comparing version 0.13.0-next.f4445dd.342 to 0.13.0-next.fb23567.343

4

lib/features/routing/model.d.ts

@@ -52,3 +52,3 @@ /********************************************************************************

* The incoming edges of this connectable element. They are resolved by the index, which must
* be an `SGraphIndex`.
* be an `SGraphIndex` for efficient lookup.
*/

@@ -58,3 +58,3 @@ get incomingEdges(): FluentIterable<SEdge>;

* The outgoing edges of this connectable element. They are resolved by the index, which must
* be an `SGraphIndex`.
* be an `SGraphIndex` for efficient lookup.
*/

@@ -61,0 +61,0 @@ get outgoingEdges(): FluentIterable<SEdge>;

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

var smodel_1 = require("../../base/model/smodel");
var sgraph_1 = require("../../graph/sgraph");
var model_1 = require("../bounds/model");

@@ -146,6 +147,12 @@ var delete_1 = require("../edit/delete");

* The incoming edges of this connectable element. They are resolved by the index, which must
* be an `SGraphIndex`.
* be an `SGraphIndex` for efficient lookup.
*/
get: function () {
return this.index.getIncomingEdges(this);
var _this = this;
var index = this.index;
if (index instanceof sgraph_1.SGraphIndex) {
return index.getIncomingEdges(this);
}
var allEdges = index.all().filter(function (e) { return e instanceof sgraph_1.SEdge; });
return allEdges.filter(function (e) { return e.targetId === _this.id; });
},

@@ -158,6 +165,12 @@ enumerable: false,

* The outgoing edges of this connectable element. They are resolved by the index, which must
* be an `SGraphIndex`.
* be an `SGraphIndex` for efficient lookup.
*/
get: function () {
return this.index.getOutgoingEdges(this);
var _this = this;
var index = this.index;
if (index instanceof sgraph_1.SGraphIndex) {
return index.getOutgoingEdges(this);
}
var allEdges = index.all().filter(function (e) { return e instanceof sgraph_1.SEdge; });
return allEdges.filter(function (e) { return e.sourceId === _this.id; });
},

@@ -164,0 +177,0 @@ enumerable: false,

{
"name": "sprotty",
"version": "0.13.0-next.f4445dd.342+f4445dd",
"version": "0.13.0-next.fb23567.343+fb23567",
"description": "A next-gen framework for graphical views",

@@ -59,3 +59,3 @@ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",

"snabbdom": "^3.0.3",
"sprotty-protocol": "0.13.0-next.f4445dd.342+f4445dd",
"sprotty-protocol": "0.13.0-next.fb23567.343+fb23567",
"tinyqueue": "^2.0.3"

@@ -106,3 +106,3 @@ },

],
"gitHead": "f4445dd8ca7102bdf677a221ddc7b47a426cdd7b"
"gitHead": "fb2356790067010a3d43f742bca3980f176274e5"
}

@@ -36,3 +36,3 @@ /********************************************************************************

import { IdPostprocessor } from "./views/id-postprocessor";
import { configureCommand, CommandActionHandlerInitializer } from "./commands/command-registration";
import { configureCommand, CommandActionHandlerInitializer } from "./commands/command-registration";
import { CssClassPostprocessor } from "./views/css-class-postprocessor";

@@ -39,0 +39,0 @@ import { ToolManager, DefaultToolsEnablingKeyListener, ToolManagerActionHandler } from "./tool-manager/tool-manager";

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

export interface IModelFactory {
createElement(schema: SModelElementSchema | SModelElement, parent?: SParentElement): SChildElement
createElement(schema: SModelElementSchema | SModelElement, parent?: SParentElement): SChildElement
createRoot(schema: SModelRootSchema | SModelRoot): SModelRoot
createRoot(schema: SModelRootSchema | SModelRoot): SModelRoot

@@ -45,3 +45,3 @@ createSchema(element: SModelElement): SModelElementSchema

createElement(schema: SModelElementSchema | SModelElement, parent?: SParentElement): SChildElement {
createElement(schema: SModelElementSchema | SModelElement, parent?: SParentElement): SChildElement {
let child: SChildElement;

@@ -59,3 +59,3 @@ if (this.registry.hasKey(schema.type)) {

createRoot(schema: SModelRootSchema | SModelRoot): SModelRoot {
createRoot(schema: SModelRootSchema | SModelRoot): SModelRoot {
let root: SModelRoot;

@@ -62,0 +62,0 @@ if (this.registry.hasKey(schema.type)) {

@@ -117,3 +117,3 @@ /********************************************************************************

protected getDx(hAlign: HAlignment, bounds: Bounds, maxWidth: number): number {
protected getDx(hAlign: HAlignment, bounds: Bounds, maxWidth: number): number {
switch (hAlign) {

@@ -129,3 +129,3 @@ case 'left':

protected getDy(vAlign: VAlignment, bounds: Bounds, maxHeight: number): number {
protected getDy(vAlign: VAlignment, bounds: Bounds, maxHeight: number): number {
switch (vAlign) {

@@ -152,3 +152,3 @@ case 'top':

const allOptions: T[] = [];
while (current !== undefined) {
while (current !== undefined) {
const layoutOptions = (current as any).layoutOptions;

@@ -155,0 +155,0 @@ if (layoutOptions !== undefined)

@@ -26,3 +26,3 @@ /********************************************************************************

import { ConsoleLogger } from '../../utils/logging';
import { Dimension } from '../../utils/geometry';
import { Dimension } from '../../utils/geometry';
import { layoutableChildFeature } from './model';

@@ -29,0 +29,0 @@ import { TYPES } from '../../base/types';

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

import { AbstractLayoutOptions, VAlignment } from './layout-options';
import { BoundsData } from './hidden-bounds-updater';
import { BoundsData } from './hidden-bounds-updater';
import { LayoutContainer, isLayoutableChild } from './model';

@@ -25,0 +25,0 @@ import { StatefulLayouter } from './layout';

@@ -19,5 +19,5 @@ /********************************************************************************

export type HAlignment = 'left' | 'center' | 'right';
export type HAlignment = 'left' | 'center' | 'right';
export type VAlignment = 'top' | 'center' | 'bottom';
export type VAlignment = 'top' | 'center' | 'bottom';

@@ -24,0 +24,0 @@ export interface AbstractLayoutOptions extends JsonMap {

@@ -21,3 +21,3 @@ /********************************************************************************

import { CommandExecutionContext } from "../../base/commands/command";
import { BoundsAware } from './model';
import { BoundsAware } from './model';

@@ -24,0 +24,0 @@ export interface ResolvedElementResize {

@@ -26,3 +26,3 @@ /********************************************************************************

import { ConsoleLogger } from '../../utils/logging';
import { Dimension } from '../../utils/geometry';
import { Dimension } from '../../utils/geometry';
import boundsModule from './di.config';

@@ -29,0 +29,0 @@ import { Container } from 'inversify';

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

import { AbstractLayoutOptions, HAlignment, VAlignment } from './layout-options';
import { BoundsData } from './hidden-bounds-updater';
import { BoundsData } from './hidden-bounds-updater';
import { LayoutContainer, isLayoutableChild } from './model';

@@ -25,0 +25,0 @@ import { StatefulLayouter } from './layout';

@@ -26,3 +26,3 @@ /********************************************************************************

import { ConsoleLogger } from '../../utils/logging';
import { Dimension } from '../../utils/geometry';
import { Dimension } from '../../utils/geometry';
import { Container } from 'inversify';

@@ -29,0 +29,0 @@ import boundsModule from './di.config';

@@ -22,5 +22,5 @@ /********************************************************************************

import { AbstractLayoutOptions, HAlignment } from './layout-options';
import { BoundsData } from './hidden-bounds-updater';
import { BoundsData } from './hidden-bounds-updater';
import { LayoutContainer, isLayoutableChild } from './model';
import { StatefulLayouter } from './layout';
import { StatefulLayouter } from './layout';

@@ -27,0 +27,0 @@ export interface VBoxLayoutOptions extends AbstractLayoutOptions {

@@ -35,3 +35,3 @@ /********************************************************************************

export type SIssueSeverity = 'error' | 'warning' | 'info';
export type SIssueSeverity = 'error' | 'warning' | 'info';

@@ -38,0 +38,0 @@ export class SIssueMarker extends SDecoration {

@@ -69,3 +69,3 @@ /********************************************************************************

protected getRotatedAlignment(element: EdgeLayoutable & SModelElement & BoundsAware, placement: EdgePlacement, flip: boolean) {
protected getRotatedAlignment(element: EdgeLayoutable & SModelElement & BoundsAware, placement: EdgePlacement, flip: boolean) {
let x = isAlignable(element) ? element.alignment.x : 0;

@@ -115,3 +115,3 @@ let y = isAlignable(element) ? element.alignment.y : 0;

const allPlacements: EdgePlacement[] = [];
while (current !== undefined) {
while (current !== undefined) {
const placement = (current as any).edgePlacement;

@@ -129,3 +129,3 @@ if (placement !== undefined)

protected getAlignment(label: EdgeLayoutable & SModelElement & BoundsAware, placement: EdgePlacement, angle: number): Point {
protected getAlignment(label: EdgeLayoutable & SModelElement & BoundsAware, placement: EdgePlacement, angle: number): Point {
const bounds = label.bounds;

@@ -132,0 +132,0 @@ const x = isAlignable(label) ? label.alignment.x - bounds.width : 0;

@@ -64,3 +64,3 @@ /********************************************************************************

constructor(@inject(TYPES.Action) protected readonly action: DeleteElementAction) {
constructor(@inject(TYPES.Action) protected readonly action: DeleteElementAction) {
super();

@@ -67,0 +67,0 @@ }

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

import { injectable } from 'inversify';
import { injectable } from 'inversify';
import { Action, CollapseExpandAction as ProtocolCollapseExpandAction, CollapseExpandAllAction as ProtocolCollapseExpandAllAction} from 'sprotty-protocol/lib/actions';

@@ -63,5 +63,5 @@ import { SButton } from '../button/model';

if (expandable !== undefined) {
return [ ProtocolCollapseExpandAction.create({
expandIds: expandable.expanded ? [] : [ expandable.id ],
collapseIds: expandable.expanded ? [ expandable.id ] : []
return [ ProtocolCollapseExpandAction.create({
expandIds: expandable.expanded ? [] : [ expandable.id ],
collapseIds: expandable.expanded ? [ expandable.id ] : []
})];

@@ -68,0 +68,0 @@ } else {

@@ -28,3 +28,3 @@ /********************************************************************************

if (openableTarget !== undefined) {
return [ OpenAction.create(openableTarget.id) ];
return [ OpenAction.create(openableTarget.id) ];
}

@@ -31,0 +31,0 @@ return [];

@@ -91,3 +91,3 @@ /********************************************************************************

pointAt(edge: SRoutableElement, t: number): Point | undefined {
pointAt(edge: SRoutableElement, t: number): Point | undefined {
const segments = this.calculateSegment(edge, t);

@@ -100,3 +100,3 @@ if (!segments)

derivativeAt(edge: SRoutableElement, t: number): Point | undefined {
derivativeAt(edge: SRoutableElement, t: number): Point | undefined {
const segments = this.calculateSegment(edge, t);

@@ -112,4 +112,4 @@ if (!segments)

protected calculateSegment(edge: SRoutableElement, t: number): { segmentStart: Point, segmentEnd: Point, lambda: number} | undefined {
if (t < 0 || t > 1)
protected calculateSegment(edge: SRoutableElement, t: number): { segmentStart: Point, segmentEnd: Point, lambda: number} | undefined {
if (t < 0 || t > 1)
return undefined;

@@ -122,3 +122,3 @@ const routedPoints = this.route(edge);

for (let i = 0; i < routedPoints.length - 1; ++i) {
segmentLengths[i] = Point.euclideanDistance(routedPoints[i], routedPoints[i + 1]);
segmentLengths[i] = Point.euclideanDistance(routedPoints[i], routedPoints[i + 1]);
totalLength += segmentLengths[i];

@@ -131,3 +131,3 @@ }

// avoid division by (almost) zero
if (segmentLengths[i] > 1E-8) {
if (segmentLengths[i] > 1E-8) {
if (newLength >= tAsLenght) {

@@ -162,3 +162,3 @@ const lambda = Math.max(0, (tAsLenght - currentLenght)) / segmentLengths[i];

getHandlePosition(edge: SRoutableElement, route: RoutedPoint[], handle: SRoutingHandle): Point | undefined {
getHandlePosition(edge: SRoutableElement, route: RoutedPoint[], handle: SRoutingHandle): Point | undefined {
switch (handle.kind) {

@@ -186,3 +186,3 @@ case 'source':

protected abstract getInnerHandlePosition(edge: SRoutableElement, route: RoutedPoint[], handle: SRoutingHandle): Point | undefined;
protected abstract getInnerHandlePosition(edge: SRoutableElement, route: RoutedPoint[], handle: SRoutingHandle): Point | undefined;

@@ -264,3 +264,3 @@ protected findRouteSegment(edge: SRoutableElement, route: RoutedPoint[], handleIndex: number): { start?: Point, end?: Point } {

sourceAnchors: DefaultAnchors, targetAnchors: DefaultAnchors): boolean {
if (routingPoints.length === 0 || edge.source instanceof SDanglingAnchor || edge.target instanceof SDanglingAnchor) {
if (routingPoints.length === 0 || edge.source instanceof SDanglingAnchor || edge.target instanceof SDanglingAnchor) {
const options = this.getOptions(edge);

@@ -379,3 +379,3 @@ const corners = this.calculateDefaultCorners(edge, sourceAnchors, targetAnchors, options);

protected getSelfEdgeIndex(edge: SRoutableElement): number {
if (!edge.source || edge.source !== edge.target)
if (!edge.source || edge.source !== edge.target)
return -1;

@@ -382,0 +382,0 @@ return edge.source.outgoingEdges

@@ -61,4 +61,4 @@ /********************************************************************************

override get(routerKind: string, anchorKind?: string): IAnchorComputer {
return super.get(`${routerKind}:${anchorKind || this.defaultAnchorKind}`);
return super.get(`${routerKind}:${anchorKind || this.defaultAnchorKind}`);
}
}

@@ -82,4 +82,4 @@ /********************************************************************************

let outline: Line | undefined = undefined;
let refLine: Line | undefined = undefined;
let outline: Line | undefined = undefined;
let refLine: Line | undefined = undefined;
if (refPoint.x >= bounds.x && refPoint.x <= bounds.x + bounds.width) {

@@ -92,3 +92,3 @@ if (bounds.x + 0.5 * bounds.width >= refPoint.x) {

outline = new PointToPointLine({ x: bounds.x, y: c.y }, { x: c.x, y: bounds.y + bounds.height });
} else {
} else {
refLine = new PointToPointLine(refPoint, { x: refPoint.x, y: c.y });

@@ -95,0 +95,0 @@ if (refPoint.y < c.y)

@@ -102,3 +102,3 @@ /********************************************************************************

protected getFraction(kind: RoutingHandleKind): number | undefined {
protected getFraction(kind: RoutingHandleKind): number | undefined {
switch (kind) {

@@ -110,3 +110,3 @@ case 'manhattan-50%': return 0.5;

protected applyInnerHandleMoves(edge: SRoutableElement, moves: ResolvedHandleMove[]) {
protected applyInnerHandleMoves(edge: SRoutableElement, moves: ResolvedHandleMove[]) {
const route = this.route(edge);

@@ -251,3 +251,3 @@ const routingPoints = edge.routingPoints;

const nearestSide = otherAnchors.getNearestSide(refPoint);
isHorizontal = nearestSide === Side.TOP || nearestSide === Side.BOTTOM;
isHorizontal = nearestSide === Side.TOP || nearestSide === Side.BOTTOM;
}

@@ -306,3 +306,3 @@ if (isHorizontal) {

return selfEdge;
const bestAnchors = this.getBestConnectionAnchors(edge, sourceAnchors, targetAnchors, options);
const bestAnchors = this.getBestConnectionAnchors(edge, sourceAnchors, targetAnchors, options);
const sourceSide = bestAnchors.source;

@@ -309,0 +309,0 @@ const targetSide = bestAnchors.target;

@@ -18,6 +18,7 @@ /********************************************************************************

import 'mocha';
import { expect } from "chai";
import { expect } from 'chai';
import { SModelRoot } from '../../base/model/smodel';
import { SShapeElement } from '../bounds/model';
import { SRoutableElement, getAbsoluteRouteBounds } from './model';
import { SEdge, SGraph, SNode } from '../../graph/sgraph';

@@ -54,1 +55,58 @@ describe('getAbsoluteRouteBounds', () => {

}
describe('SConnectableElement', () => {
function createModel(type: 'root' | 'graph'): SModelRoot {
const root = type === 'graph' ? new SGraph() : new SModelRoot();
const node1 = new SNode();
node1.id = 'node1';
root.add(node1);
const node2 = new SNode();
node2.id = 'node2';
root.add(node2);
const node3 = new SNode();
node3.id = 'node3';
root.add(node3);
const node4 = new SNode();
node4.id = 'node4';
root.add(node4);
const edge1 = new SEdge();
edge1.id = 'edge1';
edge1.sourceId = node1.id;
edge1.targetId = node2.id;
root.add(edge1);
const edge2 = new SEdge();
edge2.id = 'edge2';
edge2.sourceId = node3.id;
edge2.targetId = node4.id;
root.add(edge2);
return root;
}
it('should compute outgoing edges with SGraph', () => {
const model = createModel('graph');
const edges = Array.from((model.children[0] as SNode).outgoingEdges);
expect(edges).to.have.length(1);
expect(edges[0].id).to.equal('edge1');
});
it('should compute incoming edges with SGraph', () => {
const model = createModel('graph');
const edges = Array.from((model.children[1] as SNode).incomingEdges);
expect(edges).to.have.length(1);
expect(edges[0].id).to.equal('edge1');
});
it('should compute outgoing edges with SModelRoot', () => {
const model = createModel('root');
const edges = Array.from((model.children[0] as SNode).outgoingEdges);
expect(edges).to.have.length(1);
expect(edges[0].id).to.equal('edge1');
});
it('should compute incoming edges with SModelRoot', () => {
const model = createModel('root');
const edges = Array.from((model.children[1] as SNode).incomingEdges);
expect(edges).to.have.length(1);
expect(edges[0].id).to.equal('edge1');
});
});

@@ -115,6 +115,11 @@ /********************************************************************************

* The incoming edges of this connectable element. They are resolved by the index, which must
* be an `SGraphIndex`.
* be an `SGraphIndex` for efficient lookup.
*/
get incomingEdges(): FluentIterable<SEdge> {
return (this.index as SGraphIndex).getIncomingEdges(this);
const index = this.index;
if (index instanceof SGraphIndex) {
return index.getIncomingEdges(this);
}
const allEdges = index.all().filter(e => e instanceof SEdge) as FluentIterable<SEdge>;
return allEdges.filter(e => e.targetId === this.id);
}

@@ -124,6 +129,11 @@

* The outgoing edges of this connectable element. They are resolved by the index, which must
* be an `SGraphIndex`.
* be an `SGraphIndex` for efficient lookup.
*/
get outgoingEdges(): FluentIterable<SEdge> {
return (this.index as SGraphIndex).getOutgoingEdges(this);
const index = this.index;
if (index instanceof SGraphIndex) {
return index.getOutgoingEdges(this);
}
const allEdges = index.all().filter(e => e instanceof SEdge) as FluentIterable<SEdge>;
return allEdges.filter(e => e.sourceId === this.id);
}

@@ -136,3 +146,3 @@

export type RoutingHandleKind = 'junction' | 'line' | 'source' | 'target' | 'manhattan-50%' |
export type RoutingHandleKind = 'junction' | 'line' | 'source' | 'target' | 'manhattan-50%' |
'bezier-control-after' | 'bezier-control-before' | 'bezier-junction' | 'bezier-add' | 'bezier-remove';

@@ -139,0 +149,0 @@

@@ -118,3 +118,3 @@ /********************************************************************************

protected boundsInViewport(element: SModelElement, bounds: Bounds, viewport: SModelRoot & Viewport): Bounds {
protected boundsInViewport(element: SModelElement, bounds: Bounds, viewport: SModelRoot & Viewport): Bounds {
if (element instanceof SChildElement && element.parent !== viewport)

@@ -121,0 +121,0 @@ return this.boundsInViewport(element.parent, element.parent.localToParent(bounds) as Bounds, viewport);

@@ -103,3 +103,3 @@ /********************************************************************************

handle(action: Action): void | ICommand | Action {
handle(action: Action): void | ICommand | Action {
const forwardToServer = this.handleLocally(action);

@@ -218,3 +218,3 @@ if (forwardToServer)

commitModel(newRoot: SModelRootSchema): Promise<SModelRootSchema> | SModelRootSchema {
commitModel(newRoot: SModelRootSchema): Promise<SModelRootSchema> | SModelRootSchema {
const previousRoot = this.currentRoot;

@@ -221,0 +221,0 @@ this.currentRoot = newRoot;

@@ -72,3 +72,3 @@ /********************************************************************************

*/
abstract commitModel(newRoot: SModelRootSchema): Promise<SModelRootSchema> | SModelRootSchema;
abstract commitModel(newRoot: SModelRootSchema): Promise<SModelRootSchema> | SModelRootSchema;
}

@@ -102,3 +102,3 @@

protected applyBounds(element: SModelElementSchema, newPosition: Point | undefined, newSize: Dimension) {
protected applyBounds(element: SModelElementSchema, newPosition: Point | undefined, newSize: Dimension) {
const e = element as any;

@@ -105,0 +105,0 @@ if (newPosition)

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