Skip to content

Commit

Permalink
fix: update cli and fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ni55aN committed Aug 30, 2024
1 parent bc66a84 commit 6aa359f
Show file tree
Hide file tree
Showing 9 changed files with 2,117 additions and 1,667 deletions.
6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ node_modules
npm-debug.log
dist
docs
/coverage
.rete-cli
.sonar
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import tseslint from 'typescript-eslint';
import configs from 'rete-cli/eslint.config.mjs';
import gloals from 'globals'

export default tseslint.config(
...configs,
{
languageOptions: {
globals: {
...gloals.browser
}
}
}
)
3,694 changes: 2,063 additions & 1,631 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
"rete-area-plugin": "^2.0.0"
},
"devDependencies": {
"globals": "^15.9.0",
"rete": "^2.0.1",
"rete-area-plugin": "^2.0.0",
"rete-cli": "^1.0.2"
"rete-cli": "~2.0.0"
},
"dependencies": {
"@babel/runtime": "^7.21.0"
Expand Down
41 changes: 23 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export class MinimapPlugin<Schemes extends ExpectedScheme> extends Scope<never,
constructor(private props?: { minDistance?: number, ratio?: number, boundViewport?: boolean }) {
super('minimap')

this.ratio = this.props?.ratio || 1
this.minDistance = this.props?.minDistance || 2000
this.ratio = this.props?.ratio ?? 1
this.minDistance = this.props?.minDistance ?? 2000
this.boundViewport = Boolean(this.props?.boundViewport)
}

Expand Down Expand Up @@ -101,18 +101,21 @@ export class MinimapPlugin<Schemes extends ExpectedScheme> extends Scope<never,
}

private getNodesRect(): Rect[] {
return this.editor.getNodes().map(node => {
const view = this.area.nodeViews.get(node.id)

if (!view) return null

return {
width: node.width,
height: node.height,
left: view.position.x,
top: view.position.y
}
}).filter(Boolean) as Rect[]
return this.editor
.getNodes()
.map(node => {
const view = this.area.nodeViews.get(node.id)

if (!view) return null

return {
width: node.width,
height: node.height,
left: view.position.x,
top: view.position.y
}
})
.filter(Boolean) as Rect[]
}

private render() {
Expand All @@ -127,10 +130,12 @@ export class MinimapPlugin<Schemes extends ExpectedScheme> extends Scope<never,
width: width / transform.k,
height: height / transform.k
}
const rects = this.boundViewport ? [...nodes, viewport] : nodes
const rects = this.boundViewport
? [...nodes, viewport]
: nodes
const { origin, scale, invert } = useBoundingCoordinateSystem(rects, minDistance, ratio)

parent.emit({
void parent.emit({
type: 'render',
data: {
type: 'minimap',
Expand All @@ -152,7 +157,7 @@ export class MinimapPlugin<Schemes extends ExpectedScheme> extends Scope<never,
translate: (dx, dy) => {
const { x, y, k } = transform

this.area.area.translate(x + invert(dx) * k, y + invert(dy) * k)
void this.area.area.translate(x + invert(dx) * k, y + invert(dy) * k)
},
point: (x, y) => {
const areaCoordinatesPoint = {
Expand All @@ -164,7 +169,7 @@ export class MinimapPlugin<Schemes extends ExpectedScheme> extends Scope<never,
y: areaCoordinatesPoint.y + height / 2
}

this.area.area.translate(center.x, center.y)
void this.area.area.translate(center.x, center.y)
}
}
})
Expand Down
14 changes: 7 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export type Rect = {
width: number
height: number
left: number,
top: number
width: number
height: number
left: number
top: number
}
export type Transform = {
x: number
y: number
k: number
x: number
y: number
k: number
}
5 changes: 4 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export function nodesBoundingBox(nodes: Rect[]) {
bottom = Math.max(...bottoms)

return {
left, right, top, bottom,
left,
right,
top,
bottom,
width: right - left,
height: bottom - top
}
Expand Down
4 changes: 1 addition & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"compilerOptions": {
"strict": true
},
"extends": "rete-cli/configs/tsconfig.json",
"include": ["src"]
}

0 comments on commit 6aa359f

Please sign in to comment.