From 04640df3b2b350c2e83b41cba342b7671370fdb3 Mon Sep 17 00:00:00 2001 From: Lonny Wong Date: Sun, 29 Oct 2023 01:19:06 +0800 Subject: [PATCH] add dragInitTimeout option #13 --- examples/addon/package-lock.json | 68 ++++++++++++++------------ examples/browser/package-lock.json | 68 ++++++++++++++------------ examples/electron/package-lock.json | 68 ++++++++++++++------------ package-lock.json | 76 ++++++++++++++--------------- src/addon.ts | 9 ++-- src/filter.ts | 12 ++++- src/options.ts | 6 +++ test/filter.test.ts | 45 +++++++++++------ 8 files changed, 205 insertions(+), 147 deletions(-) diff --git a/examples/addon/package-lock.json b/examples/addon/package-lock.json index d5896e7..a4d122e 100644 --- a/examples/addon/package-lock.json +++ b/examples/addon/package-lock.json @@ -205,11 +205,12 @@ } }, "../../node_modules/@babel/generator": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -258,20 +259,22 @@ "license": "ISC" }, "../../node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, - "license": "MIT", "engines": { "node": ">=6.9.0" } }, "../../node_modules/@babel/helper-function-name": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -337,9 +340,10 @@ } }, "../../node_modules/@babel/helper-split-export-declaration": { - "version": "7.22.5", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, - "license": "MIT", "dependencies": { "@babel/types": "^7.22.5" }, @@ -462,9 +466,10 @@ } }, "../../node_modules/@babel/parser": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "dev": true, - "license": "MIT", "bin": { "parser": "bin/babel-parser.js" }, @@ -636,31 +641,33 @@ } }, "../../node_modules/@babel/template": { - "version": "7.22.5", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "../../node_modules/@babel/traverse": { - "version": "7.22.5", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -677,12 +684,13 @@ } }, "../../node_modules/@babel/types": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, - "license": "MIT", "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { diff --git a/examples/browser/package-lock.json b/examples/browser/package-lock.json index f4aeae9..d98a3d4 100644 --- a/examples/browser/package-lock.json +++ b/examples/browser/package-lock.json @@ -206,11 +206,12 @@ } }, "../../node_modules/@babel/generator": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -259,20 +260,22 @@ "license": "ISC" }, "../../node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, - "license": "MIT", "engines": { "node": ">=6.9.0" } }, "../../node_modules/@babel/helper-function-name": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -338,9 +341,10 @@ } }, "../../node_modules/@babel/helper-split-export-declaration": { - "version": "7.22.5", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, - "license": "MIT", "dependencies": { "@babel/types": "^7.22.5" }, @@ -463,9 +467,10 @@ } }, "../../node_modules/@babel/parser": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "dev": true, - "license": "MIT", "bin": { "parser": "bin/babel-parser.js" }, @@ -637,31 +642,33 @@ } }, "../../node_modules/@babel/template": { - "version": "7.22.5", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "../../node_modules/@babel/traverse": { - "version": "7.22.5", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -678,12 +685,13 @@ } }, "../../node_modules/@babel/types": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, - "license": "MIT", "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { diff --git a/examples/electron/package-lock.json b/examples/electron/package-lock.json index 9170aa4..8cf0581 100644 --- a/examples/electron/package-lock.json +++ b/examples/electron/package-lock.json @@ -205,11 +205,12 @@ } }, "../../node_modules/@babel/generator": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -258,20 +259,22 @@ "license": "ISC" }, "../../node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, - "license": "MIT", "engines": { "node": ">=6.9.0" } }, "../../node_modules/@babel/helper-function-name": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -337,9 +340,10 @@ } }, "../../node_modules/@babel/helper-split-export-declaration": { - "version": "7.22.5", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, - "license": "MIT", "dependencies": { "@babel/types": "^7.22.5" }, @@ -462,9 +466,10 @@ } }, "../../node_modules/@babel/parser": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "dev": true, - "license": "MIT", "bin": { "parser": "bin/babel-parser.js" }, @@ -636,31 +641,33 @@ } }, "../../node_modules/@babel/template": { - "version": "7.22.5", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "../../node_modules/@babel/traverse": { - "version": "7.22.5", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -677,12 +684,13 @@ } }, "../../node_modules/@babel/types": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, - "license": "MIT", "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { diff --git a/package-lock.json b/package-lock.json index 3392f75..b8988ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -203,12 +203,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.5.tgz", - "integrity": "sha512-+lcUbnTRhd0jOewtFSedLyiPsD5tswKkbgcezOqqWFUVNEwoUTlpPOBmvhG7OXWLR4jMdv0czPGH5XbflnD1EA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "dependencies": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -261,22 +261,22 @@ "dev": true }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -347,9 +347,9 @@ } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.5.tgz", - "integrity": "sha512-thqK5QFghPKWLhAV321lxF95yCg2K3Ob5yw+M3VHWfdia0IkPXUtoLH8x/6Fh486QUvzhb8YOWHChTVen2/PoQ==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "dependencies": { "@babel/types": "^7.22.5" @@ -485,9 +485,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", - "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -674,33 +674,33 @@ } }, "node_modules/@babel/template": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", - "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.5.tgz", - "integrity": "sha512-7DuIjPgERaNo6r+PZwItpjCZEa5vyw4eJGufeLxrPdBXBoLcCJCIasvK6pK/9DVNrLZTLFhUGqaC6X/PA007TQ==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -718,13 +718,13 @@ } }, "node_modules/@babel/types": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.5.tgz", - "integrity": "sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { diff --git a/src/addon.ts b/src/addon.ts index 8406ab6..207f9b6 100644 --- a/src/addon.ts +++ b/src/addon.ts @@ -34,10 +34,10 @@ export class TrzszAddon implements ITerminalAddon { * @param {Terminal} terminal - The xterm.js terminal */ public activate(terminal: Terminal): void { - const writeToTerminal = (data) => { + const writeToTerminal = (data: string | ArrayBuffer) => { terminal.write(typeof data === "string" ? data : new Uint8Array(data)); }; - const sendToServer = (data) => { + const sendToServer = (data: string | Uint8Array) => { if (this.socket.readyState !== 1) { return; } @@ -50,10 +50,11 @@ export class TrzszAddon implements ITerminalAddon { chooseSaveDirectory: this.options.chooseSaveDirectory, terminalColumns: terminal.cols, isWindowsShell: this.options.isWindowsShell, + dragInitTimeout: this.options.dragInitTimeout, }); this.disposables.push( - this.addSocketListener(this.socket, "message", (ev) => this.trzsz.processServerOutput(ev.data)) + this.addSocketListener(this.socket, "message", (ev) => this.trzsz.processServerOutput(ev.data)), ); this.disposables.push(terminal.onData((data) => this.trzsz.processTerminalInput(data))); this.disposables.push(terminal.onBinary((data) => this.trzsz.processBinaryInput(data))); @@ -94,7 +95,7 @@ export class TrzszAddon implements ITerminalAddon { protected addSocketListener( socket: WebSocket, type: K, - handler: (this: WebSocket, ev: WebSocketEventMap[K]) => any + handler: (this: WebSocket, ev: WebSocketEventMap[K]) => any, ): IDisposable { socket.addEventListener(type, handler); return { diff --git a/src/filter.ts b/src/filter.ts index 5314e8d..621e1d8 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -79,6 +79,7 @@ export class TrzszFilter { private chooseSaveDirectory?: () => Promise; private terminalColumns: number; private isWindowsShell: boolean; + private dragInitTimeout: number; private trzszTransfer: TrzszTransfer | null = null; private textProgressBar: TextProgressBar | null = null; private uniqueIdMaps: Map = new Map(); @@ -107,10 +108,19 @@ export class TrzszFilter { } this.sendToServer = options.sendToServer; + if (!isRunningInBrowser && !options.chooseSendFiles) { + throw new TrzszError("TrzszOptions.chooseSendFiles is required when having a node runtime environment"); + } this.chooseSendFiles = options.chooseSendFiles; + + if (!isRunningInBrowser && !options.chooseSaveDirectory) { + throw new TrzszError("TrzszOptions.chooseSaveDirectory is required when having a node runtime environment"); + } this.chooseSaveDirectory = options.chooseSaveDirectory; + this.terminalColumns = options.terminalColumns || 80; this.isWindowsShell = !!options.isWindowsShell; + this.dragInitTimeout = options.dragInitTimeout || 3000; } /** @@ -240,7 +250,7 @@ export class TrzszFilter { this.uploadFilesReject = null; } } - }, 1000); + }, this.dragInitTimeout); return new Promise((resolve, reject) => { this.uploadFilesResolve = resolve; diff --git a/src/options.ts b/src/options.ts index 4a1419b..10061b0 100644 --- a/src/options.ts +++ b/src/options.ts @@ -54,4 +54,10 @@ export interface TrzszOptions { * Is there a windows shell? Such as `cmd` and `PowerShell`. */ isWindowsShell?: boolean; + + /** + * The timeout in milliseconds for initializing drag and drop files to upload. + * Default is 3000. + */ + dragInitTimeout?: number | undefined | null; } diff --git a/test/filter.test.ts b/test/filter.test.ts index debeadd..44acff6 100644 --- a/test/filter.test.ts +++ b/test/filter.test.ts @@ -75,19 +75,25 @@ test("find trzsz magic key", async () => { test("default trzsz options for filter", () => { expect(() => new TrzszFilter(undefined)).toThrow("TrzszOptions is required"); - expect(() => new TrzszFilter({})).toThrow("writeToTerminal is required"); - expect(() => new TrzszFilter({ writeToTerminal: jest.fn() })).toThrow("sendToServer is required"); - + const options: TrzszOptions = {}; const func = jest.fn(); - const tf = new TrzszFilter({ - writeToTerminal: func, - sendToServer: func, - }); - expect((tf as any).writeToTerminal).toBe(func); - expect((tf as any).sendToServer).toBe(func); - expect((tf as any).chooseSendFiles).toBe(undefined); - expect((tf as any).chooseSaveDirectory).toBe(undefined); - expect((tf as any).terminalColumns).toBe(80); + expect(() => new TrzszFilter(options)).toThrow("writeToTerminal is required"); + options.writeToTerminal = func; + expect(() => new TrzszFilter(options)).toThrow("sendToServer is required"); + options.sendToServer = func; + expect(() => new TrzszFilter(options)).toThrow("chooseSendFiles is required"); + options.chooseSendFiles = func; + expect(() => new TrzszFilter(options)).toThrow("chooseSaveDirectory is required"); + options.chooseSaveDirectory = func; + + const filter = new TrzszFilter(options); + expect(filter.writeToTerminal).toBe(func); + expect(filter.sendToServer).toBe(func); + expect(filter.chooseSendFiles).toBe(func); + expect(filter.chooseSaveDirectory).toBe(func); + expect(filter.terminalColumns).toBe(80); + expect(filter.isWindowsShell).toBe(false); + expect(filter.dragInitTimeout).toBe(3000); }); test("custom trzsz options for filter", () => { @@ -112,6 +118,7 @@ test("process the terminal binary input", async () => { sendToServer: jest.fn(), terminalColumns: 100, }; + comm.isRunningInBrowser = true; const tf = new TrzszFilter(options); const uint8 = new Uint8Array(0x100); for (let i = 0; i < 0x100; i++) { @@ -132,10 +139,12 @@ test("trz upload files", async () => { const writeToTerminal = jest.fn(); const sendToServer = jest.fn(); const chooseSendFiles = jest.fn(); + const chooseSaveDirectory = jest.fn(); const trzsz = new TrzszFilter({ writeToTerminal: writeToTerminal, sendToServer: sendToServer, chooseSendFiles: chooseSendFiles, + chooseSaveDirectory: chooseSaveDirectory, }); chooseSendFiles.mockReturnValueOnce([testPath]); @@ -179,10 +188,12 @@ test("trz upload files", async () => { test("tsz download files", async () => { const writeToTerminal = jest.fn(); const sendToServer = jest.fn(); + const chooseSendFiles = jest.fn(); const chooseSaveDirectory = jest.fn(); const trzsz = new TrzszFilter({ writeToTerminal: writeToTerminal, sendToServer: sendToServer, + chooseSendFiles: chooseSendFiles, chooseSaveDirectory: chooseSaveDirectory, }); @@ -194,7 +205,7 @@ test("tsz download files", async () => { await sleep(100); trzsz.processServerOutput( - "#CFG:eJyrVspJzEtXslJQKqhU0lFQSipNK86sSgUKGBqYWJiamwHFSjJzU/NLS8BiBiB+bmlFPFCgoLQkPqs0LxsoUVJUmloLAF6AF9g=\n" + "#CFG:eJyrVspJzEtXslJQKqhU0lFQSipNK86sSgUKGBqYWJiamwHFSjJzU/NLS8BiBiB+bmlFPFCgoLQkPqs0LxsoUVJUmloLAF6AF9g=\n", ); trzsz.processServerOutput("#NUM:1\n"); trzsz.processServerOutput("#NAME:eJwrSS0u0SupKAEADtkDTw==\n"); @@ -231,10 +242,12 @@ test("tsz download files", async () => { test("stop transferring files", async () => { const writeToTerminal = jest.fn(); const sendToServer = jest.fn(); + const chooseSendFiles = jest.fn(); const chooseSaveDirectory = jest.fn(); const trzsz = new TrzszFilter({ writeToTerminal: writeToTerminal, sendToServer: sendToServer, + chooseSendFiles: chooseSendFiles, chooseSaveDirectory: chooseSaveDirectory, }); @@ -265,10 +278,12 @@ test("cancel upload files", async () => { const writeToTerminal = jest.fn(); const sendToServer = jest.fn(); const chooseSendFiles = jest.fn(); + const chooseSaveDirectory = jest.fn(); const trzsz = new TrzszFilter({ writeToTerminal: writeToTerminal, sendToServer: sendToServer, chooseSendFiles: chooseSendFiles, + chooseSaveDirectory: chooseSaveDirectory, }); chooseSendFiles.mockReturnValueOnce(undefined); @@ -290,10 +305,12 @@ test("cancel upload files", async () => { test("cancel download files", async () => { const writeToTerminal = jest.fn(); const sendToServer = jest.fn(); + const chooseSendFiles = jest.fn(); const chooseSaveDirectory = jest.fn(); const trzsz = new TrzszFilter({ writeToTerminal: writeToTerminal, sendToServer: sendToServer, + chooseSendFiles: chooseSendFiles, chooseSaveDirectory: chooseSaveDirectory, }); @@ -417,7 +434,7 @@ test("tsz download files in browser", async () => { await sleep(100); trzsz.processServerOutput( - "#CFG:eJyrVspJzEtXslJQKqhU0lFQSipNK86sSgUKGBqYWJiamwHFSjJzU/NLS8BiBiB+bmlFPFCgoLQkPqs0LxsoUVJUmloLAF6AF9g=\n" + "#CFG:eJyrVspJzEtXslJQKqhU0lFQSipNK86sSgUKGBqYWJiamwHFSjJzU/NLS8BiBiB+bmlFPFCgoLQkPqs0LxsoUVJUmloLAF6AF9g=\n", ); trzsz.processServerOutput("#NUM:1\n"); trzsz.processServerOutput("#NAME:eJwrSS0u0SupKAEADtkDTw==\n");