From 36b3729a2b4daa3dc1d49062340f570696ff4081 Mon Sep 17 00:00:00 2001
From: Braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Sun, 15 May 2022 17:28:15 +0200
Subject: [PATCH] chore: update pathfinding edge pkg
---
.../{src/shims-vue.d.ts => env.d.ts} | 3 +
packages/pathfinding-edge/package.json | 4 +-
.../src/arrow/PerfectArrow.vue | 89 ++++++++++---------
.../pathfinding-edge/src/auto-imports.d.ts | 50 ++++++++++-
.../src/edge/PathFindingEdge.vue | 81 ++++++++---------
.../pathfinding-edge/src/edge/drawSvgPath.ts | 7 +-
packages/pathfinding-edge/src/vite-env.d.ts | 2 -
packages/pathfinding-edge/tsconfig.json | 30 ++-----
packages/pathfinding-edge/tsconfig.node.json | 11 +++
packages/pathfinding-edge/vite.config.ts | 2 +-
10 files changed, 168 insertions(+), 111 deletions(-)
rename packages/pathfinding-edge/{src/shims-vue.d.ts => env.d.ts} (71%)
delete mode 100644 packages/pathfinding-edge/src/vite-env.d.ts
create mode 100644 packages/pathfinding-edge/tsconfig.node.json
diff --git a/packages/pathfinding-edge/src/shims-vue.d.ts b/packages/pathfinding-edge/env.d.ts
similarity index 71%
rename from packages/pathfinding-edge/src/shims-vue.d.ts
rename to packages/pathfinding-edge/env.d.ts
index 8337a1d5..a63bfc73 100644
--- a/packages/pathfinding-edge/src/shims-vue.d.ts
+++ b/packages/pathfinding-edge/env.d.ts
@@ -1,3 +1,6 @@
+///
+///
+
declare module '*.vue' {
import type { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/ban-types
diff --git a/packages/pathfinding-edge/package.json b/packages/pathfinding-edge/package.json
index d43ad45c..499f13f4 100644
--- a/packages/pathfinding-edge/package.json
+++ b/packages/pathfinding-edge/package.json
@@ -20,7 +20,8 @@
"scripts": {
"prepare": "ts-patch install -s",
"dev": "vite",
- "build": "yarn prepare && vite build && vue-tsc --declaration --emitDeclarationOnly && tsc",
+ "build": "vite build",
+ "types": "yarn prepare && vue-tsc --declaration --emitDeclarationOnly && shx rm -rf tmp",
"postbuild": "shx rm -rf tmp",
"prepublishOnly": "yarn build",
"test": "exit 0;",
@@ -28,6 +29,7 @@
"lint": "yarn lint:js"
},
"dependencies": {
+ "@braks/vue-flow": "^0.4.10",
"@vueuse/core": "^8.4.2",
"pathfinding": "^0.4.18",
"perfect-arrows": "^0.3.7"
diff --git a/packages/pathfinding-edge/src/arrow/PerfectArrow.vue b/packages/pathfinding-edge/src/arrow/PerfectArrow.vue
index e04daaeb..19573558 100644
--- a/packages/pathfinding-edge/src/arrow/PerfectArrow.vue
+++ b/packages/pathfinding-edge/src/arrow/PerfectArrow.vue
@@ -1,47 +1,50 @@
+
+
| DefineComponent
- props?: EdgeTextProps
- }
- labelStyle?: any
- labelShowBg?: boolean
- labelBgStyle?: any
- labelBgPadding?: [number, number]
- labelBgBorderRadius?: number
- style?: CSSProperties
- markerEnd?: string
- markerStart?: string
- data?: any
- sourceHandleId?: string
- targetHandleId?: string
-}
-
-const props = withDefaults(defineProps(), {
- selected: false,
- sourcePosition: Position.Bottom,
- targetPosition: Position.Top,
- labelStyle: () => ({}),
- labelShowBg: true,
- labelBgStyle: () => ({}),
-})
+const props = withDefaults(
+ defineProps<{
+ nodes: GraphNode[]
+ id: string
+ source: string
+ target: string
+ sourceX: number
+ sourceY: number
+ targetX: number
+ targetY: number
+ selected?: boolean
+ animated?: boolean
+ sourcePosition: Position
+ targetPosition: Position
+ label?:
+ | string
+ | {
+ component: Component | DefineComponent
+ props?: EdgeTextProps
+ }
+ labelStyle?: any
+ labelShowBg?: boolean
+ labelBgStyle?: any
+ labelBgPadding?: [number, number]
+ labelBgBorderRadius?: number
+ style?: CSSProperties
+ markerEnd?: string
+ markerStart?: string
+ data?: any
+ sourceHandleId?: string
+ targetHandleId?: string
+ }>(),
+ {
+ selected: false,
+ sourcePosition: Position.Bottom,
+ targetPosition: Position.Top,
+ labelStyle: () => ({}),
+ labelShowBg: true,
+ labelBgStyle: () => ({}),
+ },
+)
const nodePadding = 10
const graphPadding = 20
diff --git a/packages/pathfinding-edge/src/edge/drawSvgPath.ts b/packages/pathfinding-edge/src/edge/drawSvgPath.ts
index 2b4fafa5..30b8462c 100644
--- a/packages/pathfinding-edge/src/edge/drawSvgPath.ts
+++ b/packages/pathfinding-edge/src/edge/drawSvgPath.ts
@@ -1,8 +1,9 @@
-/**
- * Draws a SVG path from a list of points, using straight lines.
- */
import type { XYPosition } from '@braks/vue-flow'
+/**
+ * Draws an SVG path from a list of points, using straight lines.
+ */
+
const getMidPoint = (Ax: number, Ay: number, Bx: number, By: number) => {
const Zx = (Ax - Bx) / 2 + Bx
const Zy = (Ay - By) / 2 + By
diff --git a/packages/pathfinding-edge/src/vite-env.d.ts b/packages/pathfinding-edge/src/vite-env.d.ts
deleted file mode 100644
index 8cee1517..00000000
--- a/packages/pathfinding-edge/src/vite-env.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-///
-///
diff --git a/packages/pathfinding-edge/tsconfig.json b/packages/pathfinding-edge/tsconfig.json
index da3def3c..a1b6ebe7 100644
--- a/packages/pathfinding-edge/tsconfig.json
+++ b/packages/pathfinding-edge/tsconfig.json
@@ -1,15 +1,9 @@
{
"compilerOptions": {
- "outDir": "./tmp",
"baseUrl": ".",
"module": "ESNext",
- "target": "es2020",
- "lib": [
- "DOM",
- "ESNext"
- ],
- "declaration": true,
- "declarationDir": "./dist",
+ "target": "es2017",
+ "lib": ["DOM", "ESNext"],
"strict": true,
"esModuleInterop": true,
"incremental": false,
@@ -19,24 +13,18 @@
"noUnusedLocals": false,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
- "types": [
- "vite/client"
- ],
+ "declaration": true,
+ "declarationDir": "./dist",
+ "types": ["vite/client", "vue/macros"],
"paths": {
- "~/*": [
- "src/*"
- ]
+ "~/*": ["src/*"]
},
"plugins": [
// Transform paths in output .d.ts files (Include this line if you output declarations files)
{ "transform": "typescript-transform-paths", "afterDeclarations": true }
]
},
- "include": ["src/**/*"],
- "exclude": [
- "node_modules",
- "build",
- "dist",
- "examples"
- ]
+ "include": ["./src"],
+ "exclude": ["node_modules", "dist"],
+ "references": [{ "path": "./tsconfig.node.json" }]
}
diff --git a/packages/pathfinding-edge/tsconfig.node.json b/packages/pathfinding-edge/tsconfig.node.json
new file mode 100644
index 00000000..6dacac71
--- /dev/null
+++ b/packages/pathfinding-edge/tsconfig.node.json
@@ -0,0 +1,11 @@
+{
+ "compilerOptions": {
+ "composite": true,
+ "module": "esnext",
+ "moduleResolution": "node",
+ "resolveJsonModule": true,
+ "allowSyntheticDefaultImports": true
+ },
+ "include": ["vite.config.ts"],
+ "files": ["package.json"]
+}
diff --git a/packages/pathfinding-edge/vite.config.ts b/packages/pathfinding-edge/vite.config.ts
index 92620ed9..5b882d57 100644
--- a/packages/pathfinding-edge/vite.config.ts
+++ b/packages/pathfinding-edge/vite.config.ts
@@ -42,6 +42,6 @@ export default defineConfig({
}),
],
optimizeDeps: {
- include: ['vue', '@vueuse/core'],
+ include: ['@braks/vue-flow', 'vue', '@vueuse/core'],
},
})