From 2916ebf87cbf62231045a62ba25dad41466efb2a Mon Sep 17 00:00:00 2001 From: xushengfeng Date: Wed, 22 Jan 2025 00:07:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E8=A6=81=20=E6=9B=BF=E6=8D=A2`opencv.?= =?UTF-8?q?js`->`@techstark/opencv-js`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 ++- pnpm-lock.yaml | 75 +++++++++++++++++++++----------- src/renderer/clip/clip_window.ts | 12 ++--- 3 files changed, 59 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 0b4f29d44..9878ece6f 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "license": "GPL-3.0", "dependencies": { "@erase2d/fabric": "^1.1.6", + "@techstark/opencv-js": "4.10.0-release.1", "chroma-js": "^3.1.1", "diff-match-patch": "^1.0.5", "dkh-ui": "^0.12.4", @@ -35,7 +36,6 @@ "mp4-muxer": "^5.1.3", "node-screenshots": "^0.2.1", "onnxruntime-node": "^1.18.0", - "opencv.js": "^1.2.1", "qr-scanner-wechat": "^0.1.3", "remarkable": "^2.0.1", "sortablejs": "^1.15.2", @@ -73,6 +73,8 @@ "node-screenshots-win32-x64-msvc": "0.1.9" }, "pnpm": { - "neverBuiltDependencies": ["canvas"] + "neverBuiltDependencies": [ + "canvas" + ] } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24ef3e0da..fcc7d3a4f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,7 +4,7 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -pnpmfileChecksum: 7qyfbdpb7zu3rkrzmddjgn4j7e +pnpmfileChecksum: sha256-YuGIRPjuZ2rZwbQFg7qUZuO5gV5b1uGQUh2xFRM9OKE= importers: @@ -13,6 +13,9 @@ importers: '@erase2d/fabric': specifier: ^1.1.6 version: 1.1.6(fabric@6.4.0(canvas@2.11.2(encoding@0.1.13))) + '@techstark/opencv-js': + specifier: 4.10.0-release.1 + version: 4.10.0-release.1 chroma-js: specifier: ^3.1.1 version: 3.1.1 @@ -61,9 +64,6 @@ importers: onnxruntime-node: specifier: ^1.18.0 version: 1.20.1 - opencv.js: - specifier: ^1.2.1 - version: 1.2.1 qr-scanner-wechat: specifier: ^0.1.3 version: 0.1.3 @@ -82,28 +82,6 @@ importers: xtranslator: specifier: ^1.3.2 version: 1.3.2 - optionalDependencies: - node-screenshots-darwin-arm64: - specifier: 0.1.9 - version: 0.1.9 - node-screenshots-darwin-x64: - specifier: 0.1.9 - version: 0.1.9 - node-screenshots-linux-x64-gnu: - specifier: 0.1.9 - version: 0.1.9 - node-screenshots-linux-x64-musl: - specifier: 0.1.9 - version: 0.1.9 - node-screenshots-win32-arm64-msvc: - specifier: 0.1.9 - version: 0.1.9 - node-screenshots-win32-ia32-msvc: - specifier: 0.1.9 - version: 0.1.9 - node-screenshots-win32-x64-msvc: - specifier: 0.1.9 - version: 0.1.9 devDependencies: '@biomejs/biome': specifier: ^1.9.4 @@ -159,6 +137,28 @@ importers: xtimelog: specifier: ^1.0.5 version: 1.0.5 + optionalDependencies: + node-screenshots-darwin-arm64: + specifier: 0.1.9 + version: 0.1.9 + node-screenshots-darwin-x64: + specifier: 0.1.9 + version: 0.1.9 + node-screenshots-linux-x64-gnu: + specifier: 0.1.9 + version: 0.1.9 + node-screenshots-linux-x64-musl: + specifier: 0.1.9 + version: 0.1.9 + node-screenshots-win32-arm64-msvc: + specifier: 0.1.9 + version: 0.1.9 + node-screenshots-win32-ia32-msvc: + specifier: 0.1.9 + version: 0.1.9 + node-screenshots-win32-x64-msvc: + specifier: 0.1.9 + version: 0.1.9 packages: @@ -288,24 +288,28 @@ packages: engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] + libc: [musl] '@biomejs/cli-linux-arm64@1.9.4': resolution: {integrity: sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] + libc: [glibc] '@biomejs/cli-linux-x64-musl@1.9.4': resolution: {integrity: sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] + libc: [musl] '@biomejs/cli-linux-x64@1.9.4': resolution: {integrity: sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] + libc: [glibc] '@biomejs/cli-win32-arm64@1.9.4': resolution: {integrity: sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==} @@ -603,51 +607,61 @@ packages: resolution: {integrity: sha512-0O8ViX+QcBd3ZmGlcFTnYXZKGbFu09EhgD27tgTdGnkcYXLat4KIsBBQeKLR2xZDCXdIBAlWLkiXE1+rJpCxFw==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.31.0': resolution: {integrity: sha512-w5IzG0wTVv7B0/SwDnMYmbr2uERQp999q8FMkKG1I+j8hpPX2BYFjWe69xbhbP6J9h2gId/7ogesl9hwblFwwg==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.31.0': resolution: {integrity: sha512-JyFFshbN5xwy6fulZ8B/8qOqENRmDdEkcIMF0Zz+RsfamEW+Zabl5jAb0IozP/8UKnJ7g2FtZZPEUIAlUSX8cA==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.31.0': resolution: {integrity: sha512-kpQXQ0UPFeMPmPYksiBL9WS/BDiQEjRGMfklVIsA0Sng347H8W2iexch+IEwaR7OVSKtr2ZFxggt11zVIlZ25g==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-loongarch64-gnu@4.31.0': resolution: {integrity: sha512-pMlxLjt60iQTzt9iBb3jZphFIl55a70wexvo8p+vVFK+7ifTRookdoXX3bOsRdmfD+OKnMozKO6XM4zR0sHRrQ==} cpu: [loong64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-powerpc64le-gnu@4.31.0': resolution: {integrity: sha512-D7TXT7I/uKEuWiRkEFbed1UUYZwcJDU4vZQdPTcepK7ecPhzKOYk4Er2YR4uHKme4qDeIh6N3XrLfpuM7vzRWQ==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.31.0': resolution: {integrity: sha512-wal2Tc8O5lMBtoePLBYRKj2CImUCJ4UNGJlLwspx7QApYny7K1cUYlzQ/4IGQBLmm+y0RS7dwc3TDO/pmcneTw==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.31.0': resolution: {integrity: sha512-O1o5EUI0+RRMkK9wiTVpk2tyzXdXefHtRTIjBbmFREmNMy7pFeYXCFGbhKFwISA3UOExlo5GGUuuj3oMKdK6JQ==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.31.0': resolution: {integrity: sha512-zSoHl356vKnNxwOWnLd60ixHNPRBglxpv2g7q0Cd3Pmr561gf0HiAcUBRL3S1vPqRC17Zo2CX/9cPkqTIiai1g==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-musl@4.31.0': resolution: {integrity: sha512-ypB/HMtcSGhKUQNiFwqgdclWNRrAYDH8iMYH4etw/ZlGwiTVxBz2tDrGRrPlfZu6QjXwtd+C3Zib5pFqID97ZA==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.31.0': resolution: {integrity: sha512-JuhN2xdI/m8Hr+aVO3vspO7OQfUFO6bKLIRTAy0U15vmWjnZDLrEgCZ2s6+scAYaQVpYSh9tZtRijApw9IXyMw==} @@ -676,6 +690,9 @@ packages: resolution: {integrity: sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==} engines: {node: '>=10'} + '@techstark/opencv-js@4.10.0-release.1': + resolution: {integrity: sha512-S4XELidRiQeA0q1s9VQLo540wCxUo24r1O4C+LqZ6llX+sPCXvZCPv3Ice8dEIr0uavyZ8YZeKXSBdDgMXSXjw==} + '@tootallnate/once@2.0.0': resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} engines: {node: '>= 10'} @@ -2241,24 +2258,28 @@ packages: engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] node-screenshots-linux-x64-gnu@0.2.1: resolution: {integrity: sha512-P2h511my2JytMSAW8+uvO+lGj1BwapERWbC6i56u5WbLIy/zgT1SQwNvcZNbPE8sxb1q8pqF3MerLcftnW0f+w==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] node-screenshots-linux-x64-musl@0.1.9: resolution: {integrity: sha512-zOIv5rIpL+ndWH0XWLrJOIELxh4P96WcE1omaql2oeWleS4EGwb0VqVJLhjadiMm1YROq8nvp8Vxz850nw5XPQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] node-screenshots-linux-x64-musl@0.2.1: resolution: {integrity: sha512-+B37/VYzH86ywWyF9XkYYicyf/BTan4TADsmxPlK+a/UHHZEnp1YjEM66sBIQTIVhVhv1DC6YUv9AppBpoV9AA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] node-screenshots-win32-arm64-msvc@0.1.9: resolution: {integrity: sha512-wBw6SsRSKcLMyM3zTx38rzPJ1l5MjDvveWbacpkSkOXmlMMknhDr7wOsDM/VvbBV9RnEid6+AJ25gXc35HJrcA==} @@ -3624,6 +3645,8 @@ snapshots: dependencies: defer-to-connect: 2.0.1 + '@techstark/opencv-js@4.10.0-release.1': {} + '@tootallnate/once@2.0.0': {} '@trysound/sax@0.2.0': {} diff --git a/src/renderer/clip/clip_window.ts b/src/renderer/clip/clip_window.ts index 2e627c906..04352bdaa 100644 --- a/src/renderer/clip/clip_window.ts +++ b/src/renderer/clip/clip_window.ts @@ -337,8 +337,7 @@ function edge() { for (let i = 0; i < contours.size(); i++) { const cnt = contours.get(i); const r = cv.boundingRect(cnt); - r.type = "image"; - edgeRect.push(r); + edgeRect.push({ ...r, type: "image" }); } src.delete(); @@ -408,7 +407,8 @@ function setDefaultAction(act: setting["框选后默认操作"]) { if (!act) return; autoDo = act; if (autoDo !== "no") { - toolBarEl.els[autoDo].el.style.backgroundColor = "var(--bar-focus-color)"; + toolBarEl.els[autoDo].el.style.backgroundColor = + "var(--bar-focus-color)"; } } @@ -525,14 +525,14 @@ function long_s() { s = null; } -function startLong() { +async function startLong() { initLong(finalRect); const r = [...finalRect]; r[0] += screenPosition[nowScreenId].x; r[1] += screenPosition[nowScreenId].y; long_s(); ipcRenderer.send("clip_main_b", "long_s", r); - if (!cv) cv = require("opencv.js"); + if (!cv) cv = require("@techstark/opencv-js"); if (store.get("广截屏.模式") === "自动") { uIOhook = require("uiohook-napi").uIOhook; uIOhook.start(); @@ -2752,7 +2752,7 @@ async function fabricCopy() { if (store.get("框选.自动框选.图像识别")) { // biome-ignore lint: 为了部分引入 - var cv = require("opencv.js"); + var cv = require("@techstark/opencv-js"); } const 字体 = store.get("字体");