Skip to content

Commit

Permalink
feat: Changed imports from @foblex/core to @foblex/mediator, @foblex/…
Browse files Browse the repository at this point in the history
…platform, @foblex/2d
  • Loading branch information
siarheihuzarevich committed Sep 13, 2024
1 parent 64018c4 commit 30a60da
Show file tree
Hide file tree
Showing 237 changed files with 431 additions and 938 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
"@foblex/core": "1.2.6",
"@foblex/f-docs": "1.3.0",
"@foblex/platform": "1.0.3",
"@foblex/mediator": "1.1.0",
"@foblex/2d": "1.1.0",
"dagre": "^0.8.5",
"elkjs": "^0.9.3",
"express": "^4.18.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
IFConnectionBuilderRequest,
IFConnectionBuilderResponse
} from '@foblex/flow';
import { IPoint, PointExtensions } from '@foblex/core';
import { IPoint, PointExtensions } from '@foblex/2d';


class OffsetStraightBuilder implements IFConnectionBuilder {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core';
import { EFConnectableSide, FCanvasComponent, FFlowComponent, FFlowModule } from '@foblex/flow';
import * as dagre from "dagre";
import { GuidExtensions, IPoint, PointExtensions } from '@foblex/core';
import { IPoint, PointExtensions } from '@foblex/2d';
import { GuidExtensions } from '@foblex/core';
import { graphlib } from 'dagre';
import Graph = graphlib.Graph;
import { FCheckboxComponent } from '@foblex/f-docs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, ViewChild } from '@angular/core';
import { EFConnectableSide, FCanvasComponent, FFlowComponent, FFlowModule } from '@foblex/flow';
import { GuidExtensions, PointExtensions } from '@foblex/core';
import { PointExtensions } from '@foblex/2d';
import { GuidExtensions } from '@foblex/core';
import { FCheckboxComponent } from '@foblex/f-docs';

@Component({
Expand Down
2 changes: 2 additions & 0 deletions projects/f-flow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"@angular/core": ">=12.0.0",
"@foblex/platform": "1.0.3",
"@foblex/core": "1.2.6",
"@foblex/mediator": "1.1.0",
"@foblex/2d": "1.1.0",
"rxjs": ">=6.6.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing';
import { FDraggableDataContext } from '../../f-draggable';
import { FFlowMediator } from '../../infrastructure';
import { FMediator } from '@foblex/mediator';
import { ClearSelectionRequest } from './clear-selection.request';
import { setupTestModule } from '../test-setup';
import { ClearSelectionExecution } from './clear-selection.execution';
Expand All @@ -17,12 +17,12 @@ export const MOCK_SELECTABLE_ITEM: ISelectable = {

describe('ClearSelectionExecution', () => {
let fDraggableDataContext: FDraggableDataContext;
let fMediator: FFlowMediator;
let fMediator: FMediator;

beforeEach(() => {
setupTestModule([ ClearSelectionExecution ]);
fDraggableDataContext = TestBed.inject(FDraggableDataContext) as jasmine.SpyObj<FDraggableDataContext>;
fMediator = TestBed.inject(FFlowMediator) as jasmine.SpyObj<FFlowMediator>;
fMediator = TestBed.inject(FMediator) as jasmine.SpyObj<FMediator>;
});

it('should deselect all selected items and clear the selectedItems array when clearSelection is called through FMediator', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ClearSelectionRequest } from './clear-selection.request';
import { Injectable } from '@angular/core';
import { FExecutionRegister, IExecution } from '../../infrastructure';
import { FExecutionRegister, IExecution } from '@foblex/mediator';
import { FDraggableDataContext } from '../../f-draggable';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { CreateConnectionMarkersRequest } from './create-connection-markers-request';
import { FConnectionBase, FMarkerBase } from '../../f-connection';
import { FExecutionRegister, IExecution } from '../../infrastructure';
import { FExecutionRegister, IExecution } from '@foblex/mediator';
import { BrowserService } from '@foblex/platform';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class CreateRoundedRectFromElementRequest {
constructor(
public element: HTMLElement | SVGElement,
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Injectable } from '@angular/core';
import { CreateRoundedRectFromElementRequest } from './create-rounded-rect-from-element-request';
import { FExecutionRegister, IExecution } from '@foblex/mediator';
import { BrowserService } from '@foblex/platform';
import { RoundedRect, RectExtensions } from '@foblex/2d';

@Injectable()
@FExecutionRegister(CreateRoundedRectFromElementRequest)
export class CreateRoundedRectFromElementExecution implements IExecution<CreateRoundedRectFromElementRequest, RoundedRect> {

constructor(
private fBrowser: BrowserService
) {
}

public handle(request: CreateRoundedRectFromElementRequest): RoundedRect {
return this.setRadiusFromElement(RoundedRect.fromRect(RectExtensions.fromElement(request.element)), request.element);
}

private setRadiusFromElement(rect: RoundedRect, element: HTMLElement | SVGElement): RoundedRect {
const styles = this.getComputedStyle(element);
rect.radius1 = this.toPixels(styles.borderTopLeftRadius, element, styles.fontSize);
rect.radius2 = this.toPixels(styles.borderTopRightRadius, element, styles.fontSize);
rect.radius3 = this.toPixels(styles.borderBottomRightRadius, element, styles.fontSize);
rect.radius4 = this.toPixels(styles.borderBottomLeftRadius, element, styles.fontSize);
return rect;
}

private getComputedStyle(element: HTMLElement | SVGElement): CSSStyleDeclaration {
return this.fBrowser.window.getComputedStyle(element);
}

private toPixels(value: string, element: HTMLElement | SVGElement, fontSize: string): number {
return this.fBrowser.toPixels(value, element.clientWidth, element.clientHeight, fontSize) || 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './create-rounded-rect-from-element.execution';

export * from './create-rounded-rect-from-element-request';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EmitTransformChangesRequest } from './emit-transform-changes.request';
import { Injectable } from '@angular/core';
import { FExecutionRegister, IExecution } from '../../infrastructure';
import { FExecutionRegister, IExecution } from '@foblex/mediator';
import { FTransformStore } from '../../f-storage';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable } from '@angular/core';
import { IRect, ITransformModel, RectExtensions } from '@foblex/core';
import { IRect, ITransformModel, RectExtensions } from '@foblex/2d';
import { ISelectableWithRect } from './i-selectable-with-rect';
import { GetCanBeSelectedItemsRequest } from './get-can-be-selected-items-request';
import { FNodeBase } from '../../f-node';
import { FConnectionBase } from '../../f-connection';
import { FExecutionRegister, FFlowMediator, IExecution } from '../../infrastructure';
import { FExecutionRegister, FMediator, IExecution } from '@foblex/mediator';
import { FComponentsStore } from '../../f-storage';
import { FDraggableDataContext } from '../../f-draggable';
import { GetElementRectInFlowRequest } from '../get-element-rect-in-flow';
Expand All @@ -28,7 +28,7 @@ export class GetCanBeSelectedItemsExecution implements IExecution<void, ISelecta
constructor(
private fComponentsStore: FComponentsStore,
private fDraggableDataContext: FDraggableDataContext,
private fMediator: FFlowMediator,
private fMediator: FMediator,
) {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IRect } from '@foblex/core';
import { IRect } from '@foblex/2d';
import { ISelectable } from '../../f-connection';

export interface ISelectableWithRect {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { TestBed } from '@angular/core/testing';
import { GetConnectionLineExecution } from './get-connection-line.execution';
import { GetConnectionLineRequest } from './get-connection-line.request';
import { ILine, PointExtensions } from '@foblex/core';
import { EFConnectionBehavior } from '../../f-connection';
import { RoundedRect } from '../intersections';
import { EFConnectableSide } from '../../f-connectors';
import { setupTestModule } from '../test-setup';
import { FFlowMediator } from '../../infrastructure';
import { FMediator } from '@foblex/mediator';
import { RoundedRect, ILine, PointExtensions } from '@foblex/2d';

describe('GetConnectionLineExecution', () => {
let fMediator: FFlowMediator;
let fMediator: FMediator;

beforeEach(() => {
setupTestModule([ GetConnectionLineExecution ]);
fMediator = TestBed.inject(FFlowMediator) as jasmine.SpyObj<FFlowMediator>;
fMediator = TestBed.inject(FMediator) as jasmine.SpyObj<FMediator>;
});

it('should handle floating behavior correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ILine, IPoint, IRect, Line, Point } from '@foblex/core';
import { GetConnectionLineRequest } from './get-connection-line.request';
import { Injectable } from '@angular/core';
import { EFConnectionBehavior } from '../../f-connection';
import { EFConnectableSide } from '../../f-connectors';
import { FExecutionRegister, IExecution } from '../../infrastructure';
import { IntersectionFinder, IRoundedRect } from '../intersections';
import { FExecutionRegister, IExecution } from '@foblex/mediator';
import { GetIntersections, ILine, IPoint, IRect, IRoundedRect, Line, Point } from '@foblex/2d';

@Injectable()
@FExecutionRegister(GetConnectionLineRequest)
Expand All @@ -24,8 +23,8 @@ export class GetConnectionLineExecution implements IExecution<GetConnectionLineR
}

private floatingBehavior(payload: GetConnectionLineRequest): ILine {
const fromResult = IntersectionFinder.getIntersections(payload.outputRect.gravityCenter, payload.inputRect.gravityCenter, payload.outputRect)[ 0 ];
const toResult = IntersectionFinder.getIntersections(payload.inputRect.gravityCenter, payload.outputRect.gravityCenter, payload.inputRect)[ 0 ];
const fromResult = GetIntersections.getRoundedRectIntersections(payload.outputRect.gravityCenter, payload.inputRect.gravityCenter, payload.outputRect)[ 0 ];
const toResult = GetIntersections.getRoundedRectIntersections(payload.inputRect.gravityCenter, payload.outputRect.gravityCenter, payload.inputRect)[ 0 ];
return new Line(
fromResult ? fromResult : payload.outputRect.gravityCenter,
toResult ? toResult : payload.inputRect.gravityCenter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { EFConnectionBehavior } from '../../f-connection';
import { EFConnectableSide } from '../../f-connectors';
import { IConnectorShape } from '../intersections';
import { IRoundedRect } from '@foblex/2d';

export class GetConnectionLineRequest {

constructor(
public outputRect: IConnectorShape,
public inputRect: IConnectorShape,
public outputRect: IRoundedRect,
public inputRect: IRoundedRect,
public behavior: EFConnectionBehavior | string,
public outputSide: EFConnectableSide,
public inputSide: EFConnectableSide,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { GetDeepChildrenNodesAndGroupsRequest } from './get-deep-children-nodes-and-groups.request';
import { FComponentsStore } from '../../f-storage';
import { FNodeBase } from '../../f-node';
import { FExecutionRegister, IExecution } from '../../infrastructure';
import { FExecutionRegister, IExecution } from '@foblex/mediator';

@Injectable()
@FExecutionRegister(GetDeepChildrenNodesAndGroupsRequest)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import {
IPoint, ISize,
ITransformModel,
Point,
SizeExtensions
} from '@foblex/core';
import { Injectable } from '@angular/core';
import { GetElementRectInFlowRequest } from './get-element-rect-in-flow-request';
import { FExecutionRegister, IExecution } from '../../infrastructure';
import { FExecutionRegister, FMediator, IExecution } from '@foblex/mediator';
import { FComponentsStore } from '../../f-storage';
import { IRoundedRect, RoundedRect } from '../intersections';
import { BrowserService } from '@foblex/platform';
import { IRoundedRect, RoundedRect, IPoint, ISize, Point, SizeExtensions, ITransformModel } from '@foblex/2d';
import { CreateRoundedRectFromElementRequest } from '../create-rounded-rect-from-element';

@Injectable()
@FExecutionRegister(GetElementRectInFlowRequest)
Expand All @@ -25,12 +19,12 @@ export class GetElementRectInFlowExecution implements IExecution<GetElementRectI

constructor(
private fComponentsStore: FComponentsStore,
private fBrowser: BrowserService
private fMediator: FMediator
) {
}

public handle(request: GetElementRectInFlowRequest): IRoundedRect {
const systemRect = RoundedRect.fromElement(request.element, this.fBrowser);
const systemRect = this.fMediator.send<IRoundedRect>(new CreateRoundedRectFromElementRequest(request.element));
const position = this.transformElementPositionInFlow(systemRect);
const size = this.transformElementSizeInFlow(systemRect);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EFConnectableSide } from '../../f-connectors';
import { IRoundedRect } from '../intersections';
import { IRoundedRect } from '@foblex/2d';

export class GetInputRectInFlowResponse {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Injectable } from '@angular/core';
import { FExecutionRegister, FFlowMediator, IExecution } from '../../infrastructure';
import { FExecutionRegister, FMediator, IExecution } from '@foblex/mediator';
import { GetInputRectInFlowRequest } from './get-input-rect-in-flow-request';
import { FComponentsStore } from '../../f-storage';
import { GetInputRectInFlowResponse } from './get-input-rect-in-flow-response';
import { InputNotFound } from '../../errors';
import { GetElementRectInFlowRequest } from '../get-element-rect-in-flow';
import { IRoundedRect } from '../intersections';
import { IRoundedRect } from '@foblex/2d';

@Injectable()
@FExecutionRegister(GetInputRectInFlowRequest)
export class GetInputRectInFlowExecution implements IExecution<GetInputRectInFlowRequest, GetInputRectInFlowResponse> {

constructor(
private fComponentsStore: FComponentsStore,
private fMediator: FFlowMediator,
private fMediator: FMediator,
) {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IRect, RectExtensions } from '@foblex/core';
import { IRect, RectExtensions } from '@foblex/2d';
import { GetNodesRectRequest } from './get-nodes-rect.request';
import { Injectable } from '@angular/core';
import { FComponentsStore } from '../../f-storage';
import { FExecutionRegister, IExecution } from '../../infrastructure';
import { FExecutionRegister, IExecution } from '@foblex/mediator';
import { FNodeBase } from '../../f-node';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EFConnectableSide } from '../../f-connectors';
import { IRoundedRect } from '../intersections';
import { IRoundedRect } from '@foblex/2d';

export class GetOutputRectInFlowResponse {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Injectable } from '@angular/core';
import { FExecutionRegister, FFlowMediator, IExecution } from '../../infrastructure';
import { FExecutionRegister, FMediator, IExecution } from '@foblex/mediator';
import { GetOutputRectInFlowRequest } from './get-output-rect-in-flow-request';
import { FComponentsStore } from '../../f-storage';
import { GetOutputRectInFlowResponse } from './get-output-rect-in-flow-response';
import { OutputNotFound } from '../../errors';
import { GetElementRectInFlowRequest } from '../get-element-rect-in-flow';
import { IRoundedRect } from '../intersections';
import { IRoundedRect } from '@foblex/2d';

@Injectable()
@FExecutionRegister(GetOutputRectInFlowRequest)
export class GetOutputRectInFlowExecution implements IExecution<GetOutputRectInFlowRequest, GetOutputRectInFlowResponse> {

constructor(
private fComponentsStore: FComponentsStore,
private fMediator: FFlowMediator,
private fMediator: FMediator,
) {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IPoint } from '@foblex/core';
import { IPoint } from '@foblex/2d';

export class GetPositionInFlowRequest {
constructor(
Expand Down
Loading

0 comments on commit 30a60da

Please sign in to comment.