From b5b9e1d5ecefe8f7a2cf1ef1eda43beedf3899c9 Mon Sep 17 00:00:00 2001 From: zxc <1171051090@qq.com> Date: Fri, 6 Sep 2024 21:41:43 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BE=9D=E8=B5=96=E6=9B=B4=E6=96=B0sv?= =?UTF-8?q?g-pathdata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 35 +++++++++++---- package.json | 2 +- src/utils/svgPathParser.ts | 92 -------------------------------------- 3 files changed, 28 insertions(+), 101 deletions(-) diff --git a/package-lock.json b/package-lock.json index 206f82d8..ec42c1c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "prosemirror-state": "^1.4.3", "prosemirror-view": "^1.33.9", "svg-arc-to-cubic-bezier": "^3.2.0", - "svg-pathdata": "^6.0.3", + "svg-pathdata": "^7.1.0", "tinycolor2": "^1.6.0", "tippy.js": "^6.3.7", "vue": "^3.4.34", @@ -4842,11 +4842,14 @@ "integrity": "sha512-djbJ/vZKZO+gPoSDThGNpKDO+o+bAeA4XQKovvkNCqnIS2t+S4qnLAGQhyyrulhCFRl1WWzAp0wUDV8PpTVU3g==" }, "node_modules/svg-pathdata": { - "version": "6.0.3", - "resolved": "https://registry.npmmirror.com/svg-pathdata/-/svg-pathdata-6.0.3.tgz", - "integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==", + "version": "7.1.0", + "resolved": "https://registry.npmmirror.com/svg-pathdata/-/svg-pathdata-7.1.0.tgz", + "integrity": "sha512-wrvKHXZSYZyODOj5E1l1bMTIo8sR7YCH0E4SA8IgLgMsZq4RypslpYvNSsrdg4ThD6du2KWPyVeKinkqUelGhg==", + "dependencies": { + "yerror": "^8.0.0" + }, "engines": { - "node": ">=12.0.0" + "node": ">=20.11.1" } }, "node_modules/text-extensions": { @@ -5231,6 +5234,14 @@ "node": ">=12" } }, + "node_modules/yerror": { + "version": "8.0.0", + "resolved": "https://registry.npmmirror.com/yerror/-/yerror-8.0.0.tgz", + "integrity": "sha512-FemWD5/UqNm8ffj8oZIbjWXIF2KE0mZssggYpdaQkWDDgXBQ/35PNIxEuz6/YLn9o0kOxDBNJe8x8k9ljD7k/g==", + "engines": { + "node": ">=18.16.0" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -8844,9 +8855,12 @@ "integrity": "sha512-djbJ/vZKZO+gPoSDThGNpKDO+o+bAeA4XQKovvkNCqnIS2t+S4qnLAGQhyyrulhCFRl1WWzAp0wUDV8PpTVU3g==" }, "svg-pathdata": { - "version": "6.0.3", - "resolved": "https://registry.npmmirror.com/svg-pathdata/-/svg-pathdata-6.0.3.tgz", - "integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==" + "version": "7.1.0", + "resolved": "https://registry.npmmirror.com/svg-pathdata/-/svg-pathdata-7.1.0.tgz", + "integrity": "sha512-wrvKHXZSYZyODOj5E1l1bMTIo8sR7YCH0E4SA8IgLgMsZq4RypslpYvNSsrdg4ThD6du2KWPyVeKinkqUelGhg==", + "requires": { + "yerror": "^8.0.0" + } }, "text-extensions": { "version": "2.4.0", @@ -9113,6 +9127,11 @@ "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true }, + "yerror": { + "version": "8.0.0", + "resolved": "https://registry.npmmirror.com/yerror/-/yerror-8.0.0.tgz", + "integrity": "sha512-FemWD5/UqNm8ffj8oZIbjWXIF2KE0mZssggYpdaQkWDDgXBQ/35PNIxEuz6/YLn9o0kOxDBNJe8x8k9ljD7k/g==" + }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 35c2e67e..a36904c5 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "prosemirror-state": "^1.4.3", "prosemirror-view": "^1.33.9", "svg-arc-to-cubic-bezier": "^3.2.0", - "svg-pathdata": "^6.0.3", + "svg-pathdata": "^7.1.0", "tinycolor2": "^1.6.0", "tippy.js": "^6.3.7", "vue": "^3.4.34", diff --git a/src/utils/svgPathParser.ts b/src/utils/svgPathParser.ts index 4e3e5ac8..9bcca8bb 100644 --- a/src/utils/svgPathParser.ts +++ b/src/utils/svgPathParser.ts @@ -1,98 +1,6 @@ -// @ts-ignore import { SVGPathData } from 'svg-pathdata' import arcToBezier from 'svg-arc-to-cubic-bezier' -type CommandM = { - relative: boolean - type: typeof SVGPathData.MOVE_TO - x: number - y: number -} -type CommandL = { - relative: boolean - type: typeof SVGPathData.LINE_TO - x: number - y: number -} -type CommandH = { - relative: boolean - type: typeof SVGPathData.HORIZ_LINE_TO - x: number -} -type CommandV = { - relative: boolean - type: typeof SVGPathData.VERT_LINE_TO - y: number -} -type CommandZ = { - type: typeof SVGPathData.CLOSE_PATH -} -type CommandQ = { - relative: boolean - type: typeof SVGPathData.QUAD_TO - x1: number - y1: number - x: number - y: number -} -type CommandT = { - relative: boolean - type: typeof SVGPathData.SMOOTH_QUAD_TO - x: number - y: number -} -type CommandC = { - relative: boolean - type: typeof SVGPathData.CURVE_TO - x1: number - y1: number - x2: number - y2: number - x: number - y: number -} -type CommandS = { - relative: boolean - type: typeof SVGPathData.SMOOTH_CURVE_TO - x2: number - y2: number - x: number - y: number -} -type CommandA = { - relative: boolean - type: typeof SVGPathData.ARC - rX: number - rY: number - xRot: number - sweepFlag: 0 | 1 - lArcFlag: 0 | 1 - x: number - y: number - cX?: number - cY?: number - phi1?: number - phi2?: number -} -type SVGCommand = CommandM | CommandL | CommandH | CommandV | CommandZ | CommandQ | CommandT | CommandC | CommandS | CommandA - -declare class SVGPathData { - commands: SVGCommand[] - constructor(content: string | SVGCommand[]) - static readonly CLOSE_PATH: 1 - static readonly MOVE_TO: 2 - static readonly HORIZ_LINE_TO: 4 - static readonly VERT_LINE_TO: 8 - static readonly LINE_TO: 16 - static readonly CURVE_TO: 32 - static readonly SMOOTH_CURVE_TO: 64 - static readonly QUAD_TO: 128 - static readonly SMOOTH_QUAD_TO: 256 - static readonly ARC: 512 - static readonly LINE_COMMANDS: number - static readonly DRAWING_COMMANDS: number -} - const typeMap = { 1: 'Z', 2: 'M',