From a3643cb38f3121cb57cda4e2410bf349d5dfa045 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 18 May 2020 03:33:15 -0400 Subject: [PATCH 1/5] dependency upgrades --- package-lock.json | 244 ++++++++++++++++++++++------------------------ package.json | 16 +-- 2 files changed, 125 insertions(+), 135 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6ac9b390..082cdf38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1279,9 +1279,9 @@ } }, "@cypress/browserify-preprocessor": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/@cypress/browserify-preprocessor/-/browserify-preprocessor-2.2.3.tgz", - "integrity": "sha512-NjumJpUlWeolsGICIseYblCRYsQDQA01W1ZxPcWZkG1hK01EI1HxMtX7fBnyeg2jY/i1xjrZV27PczmdGKAhXQ==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@cypress/browserify-preprocessor/-/browserify-preprocessor-2.2.4.tgz", + "integrity": "sha512-kMjkIFe6qka8Tkm9N3BrMB+Nn7WEAHIzEd3gfVoDL17Tr40xyOnKGuMhEkff1scd3RV3bjQxwQ9BQ6kI2nToAQ==", "dev": true, "requires": { "@babel/core": "7.4.5", @@ -1472,12 +1472,12 @@ } }, "@cypress/code-coverage": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/@cypress/code-coverage/-/code-coverage-3.7.2.tgz", - "integrity": "sha512-DEcM8kcObqwX9LoS2aLU1JYm8MQG66WSjBbt/mtq8IuzXTVEeAwfd8ctDrRs9vaDPGqttqpTdcpumhnwIAC95Q==", + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/@cypress/code-coverage/-/code-coverage-3.7.4.tgz", + "integrity": "sha512-qOiPYzamTQ81mETMzz5A/72MxQWnz93R60TN2v0o2XbUkBws5yxkLSoKjhBdYmunrOttKlZ/H7TY7EQsOwXi1g==", "dev": true, "requires": { - "@cypress/browserify-preprocessor": "2.2.3", + "@cypress/browserify-preprocessor": "2.2.4", "debug": "4.1.1", "execa": "4.0.1", "globby": "11.0.0", @@ -1711,9 +1711,9 @@ } }, "@cypress/webpack-preprocessor": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@cypress/webpack-preprocessor/-/webpack-preprocessor-5.2.0.tgz", - "integrity": "sha512-uvo0FfKL+rIXrBGS6qPIaJRD8euK+t6YoZvrTuLPnStprzlgeGfSCnCDUEMJZqFk9LwBd1NtOop+J7qNuv74ng==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/@cypress/webpack-preprocessor/-/webpack-preprocessor-5.2.1.tgz", + "integrity": "sha512-rv3ypUoqnm6Z3EJcTk8I12NDyKVMKD9/Yy/+9OLspBzWZh+1NWEiZV4FI/1t1Mt6fm66n+MsG7w3eGnQMgukfg==", "dev": true, "requires": { "bluebird": "3.7.1", @@ -2075,6 +2075,13 @@ "requires": { "event-loop-spinner": "1.1.0", "typescript": "3.8.3" + }, + "dependencies": { + "typescript": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", + "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==" + } } }, "@snyk/ruby-semver": { @@ -2131,11 +2138,10 @@ "dev": true }, "@types/agent-base": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@types/agent-base/-/agent-base-4.2.0.tgz", - "integrity": "sha512-8mrhPstU+ZX0Ugya8tl5DsDZ1I5ZwQzbL/8PA0z8Gj0k9nql7nkaMzmPVLj+l/nixWaliXi+EBiLA8bptw3z7Q==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@types/agent-base/-/agent-base-4.2.1.tgz", + "integrity": "sha512-GRmnDTq6ajyRyT8Ybg4IVVOyYqqFIAR4Zo9L+fdMAP+IJxd0nlTV99/IelJCBF629WOj6MpE9ohLHYCmkeJqRA==", "requires": { - "@types/events": "*", "@types/node": "*" } }, @@ -2184,11 +2190,6 @@ "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", "dev": true }, - "@types/events": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", - "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==" - }, "@types/gl-vec2": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@types/gl-vec2/-/gl-vec2-1.3.0.tgz", @@ -2210,9 +2211,9 @@ } }, "@types/js-yaml": { - "version": "3.12.3", - "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-3.12.3.tgz", - "integrity": "sha512-otRe77JNNWzoVGLKw8TCspKswRoQToys4tuL6XYVBFxjgeM0RUrx7m3jkaTdxILxeGry3zM8mGYkGXMeQ02guA==" + "version": "3.12.4", + "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-3.12.4.tgz", + "integrity": "sha512-fYMgzN+9e28R81weVN49inn/u798ruU91En1ZnGvSZzCRc5jXx9B2EDhlRaWmcO1RIxFHL8AajRXzxDuJu93+A==" }, "@types/json-schema": { "version": "7.0.4", @@ -2228,9 +2229,9 @@ "optional": true }, "@types/lodash": { - "version": "4.14.150", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.150.tgz", - "integrity": "sha512-kMNLM5JBcasgYscD9x/Gvr6lTAv2NVgsKtet/hm93qMyf/D1pt+7jeEZklKJKxMVmXjxbRVQQGfqDSfipYCO6w==", + "version": "4.14.151", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.151.tgz", + "integrity": "sha512-Zst90IcBX5wnwSu7CAS0vvJkTjTELY4ssKbHiTnGcJgi170uiS8yQDdc3v6S77bRqYQIN1App5a1Pc2lceE5/g==", "dev": true }, "@types/minimatch": { @@ -2246,9 +2247,9 @@ "dev": true }, "@types/node": { - "version": "13.13.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.5.tgz", - "integrity": "sha512-3ySmiBYJPqgjiHA7oEaIo2Rzz0HrOZ7yrNO5HWyaE5q0lQ3BppDZ3N53Miz8bw2I7gh1/zir2MGVZBvpb1zq9g==" + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.1.tgz", + "integrity": "sha512-FAYBGwC+W6F9+huFIDtn43cpy7+SzG+atzRiTfdp3inUKL2hXnd4rG8hylJLIh4+hqrQy1P17kvJByE/z825hA==" }, "@types/prop-types": { "version": "15.7.3", @@ -2272,9 +2273,9 @@ "integrity": "sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ==" }, "@types/sinon": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-9.0.0.tgz", - "integrity": "sha512-v2TkYHkts4VXshMkcmot/H+ERZ2SevKa10saGaJPGCJ8vh3lKrC4u663zYEeRZxep+VbG6YRDtQ6gVqw9dYzPA==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-9.0.1.tgz", + "integrity": "sha512-vqWk3K1HYJExooYgORUdiGX1EdCWQxPi7P/OEIetdaJn4jNvEYoRRGLG/HwomtbzZ4IP9Syz2k4N50CItv6w6g==", "dev": true, "requires": { "@types/sinonjs__fake-timers": "*" @@ -2311,13 +2312,12 @@ } }, "@typescript-eslint/eslint-plugin": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.24.0.tgz", - "integrity": "sha512-wJRBeaMeT7RLQ27UQkDFOu25MqFOBus8PtOa9KaT5ZuxC1kAsd7JEHqWt4YXuY9eancX0GK9C68i5OROnlIzBA==", + "version": "2.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.33.0.tgz", + "integrity": "sha512-QV6P32Btu1sCI/kTqjTNI/8OpCYyvlGjW5vD8MpTIg+HGE5S88HtT1G+880M4bXlvXj/NjsJJG0aGcVh0DdbeQ==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "2.24.0", - "eslint-utils": "^1.4.3", + "@typescript-eslint/experimental-utils": "2.33.0", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", "tsutils": "^3.17.1" @@ -2332,14 +2332,26 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.24.0.tgz", - "integrity": "sha512-DXrwuXTdVh3ycNCMYmWhUzn/gfqu9N0VzNnahjiDJvcyhfBy4gb59ncVZVxdp5XzBC77dCncu0daQgOkbvPwBw==", + "version": "2.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.33.0.tgz", + "integrity": "sha512-qzPM2AuxtMrRq78LwyZa8Qn6gcY8obkIrBs1ehqmQADwkYzTE1Pb4y2W+U3rE/iFkSWcWHG2LS6MJfj6SmHApg==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.24.0", - "eslint-scope": "^5.0.0" + "@typescript-eslint/typescript-estree": "2.33.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + }, + "dependencies": { + "eslint-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz", + "integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + } } }, "@typescript-eslint/parser": { @@ -2408,9 +2420,9 @@ } }, "@typescript-eslint/typescript-estree": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.24.0.tgz", - "integrity": "sha512-RJ0yMe5owMSix55qX7Mi9V6z2FDuuDpN6eR5fzRJrp+8in9UF41IGNQHbg5aMK4/PjVaEQksLvz0IA8n+Mr/FA==", + "version": "2.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.33.0.tgz", + "integrity": "sha512-d8rY6/yUxb0+mEwTShCQF2zYQdLlqihukNfG9IUlLYz5y1CH6G/9XYbrxQLq3Z14RNvkCC6oe+OcFlyUpwUbkg==", "dev": true, "requires": { "debug": "^4.1.1", @@ -2418,7 +2430,7 @@ "glob": "^7.1.6", "is-glob": "^4.0.1", "lodash": "^4.17.15", - "semver": "^6.3.0", + "semver": "^7.3.2", "tsutils": "^3.17.1" }, "dependencies": { @@ -2430,6 +2442,12 @@ "requires": { "ms": "^2.1.1" } + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true } } }, @@ -5470,9 +5488,9 @@ } }, "eslint-plugin-import": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.1.tgz", - "integrity": "sha512-qQHgFOTjguR+LnYRoToeZWT62XM55MBVXObHM6SKFd1VzDcX/vqT1kAz8ssqigh5eMj8qXcRoXXGZpPP6RfdCw==", + "version": "2.20.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.2.tgz", + "integrity": "sha512-FObidqpXrR8OnCh4iNsxy+WACztJLXAHBO5hK79T1Hc77PgQZkyDGA5Ag9xAvRpglvLNxhH/zSmZ70/pZ31dHg==", "dev": true, "requires": { "array-includes": "^3.0.3", @@ -6006,9 +6024,9 @@ "dev": true }, "fastq": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.7.0.tgz", - "integrity": "sha512-YOadQRnHd5q6PogvAR/x62BGituF2ufiEA6s8aavQANw5YKHERI4AREboX6KotzP8oX2klxYF2wcV/7bn1clfQ==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz", + "integrity": "sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==", "dev": true, "requires": { "reusify": "^1.0.4" @@ -7054,12 +7072,6 @@ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz", "integrity": "sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==", "dev": true - }, - "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true } } }, @@ -9517,9 +9529,9 @@ } }, "open": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/open/-/open-7.0.3.tgz", - "integrity": "sha512-sP2ru2v0P290WFfv49Ap8MF6PkzGNnGlAwHweB4WR4mr5d2d0woiCluUeJ218w7/+PmoBy9JmYgD5A4mLcWOFA==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/open/-/open-7.0.4.tgz", + "integrity": "sha512-brSA+/yq+b08Hsr4c8fsEW2CRzk1BmfN3SAK/5VCHQ9bdoZJ4qa/+AfR0xHjlbbZUyPkUHs1b8x1RqdyZdkVqQ==", "requires": { "is-docker": "^2.0.0", "is-wsl": "^2.1.1" @@ -10858,6 +10870,12 @@ "integrity": "sha512-IifbusYiQBpUxxFJkR3wTU68xzBN0+bxCScEaKMjBvAQERg6FnTTc1F17rseLb1tjmkJ23730AXpFI0c47FgAg==", "dev": true }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, "slice-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", @@ -11003,9 +11021,9 @@ } }, "snyk": { - "version": "1.320.2", - "resolved": "https://registry.npmjs.org/snyk/-/snyk-1.320.2.tgz", - "integrity": "sha512-PfXY83G/3j+gBOt2EbMFWL/MVb6QJK+XE1l2CL5hlqzyeQp/tVVCI4RNNg0h+itzHfffVQCuAPRxbh1ijU8BEg==", + "version": "1.321.0", + "resolved": "https://registry.npmjs.org/snyk/-/snyk-1.321.0.tgz", + "integrity": "sha512-0uczPo7A/XD5g8HZwfmO3kwp4QUtuuHelg97O9JcnfLT7Hh6RoyJuuBdEmIECgdCIFZXVV9kAfMAAs6hpgOXsA==", "requires": { "@snyk/cli-interface": "2.6.0", "@snyk/configstore": "^3.2.0-rc1", @@ -11037,12 +11055,12 @@ "snyk-go-plugin": "1.14.0", "snyk-gradle-plugin": "3.2.7", "snyk-module": "1.9.1", - "snyk-mvn-plugin": "2.15.1", + "snyk-mvn-plugin": "2.15.2", "snyk-nodejs-lockfile-parser": "1.22.0", - "snyk-nuget-plugin": "1.17.0", + "snyk-nuget-plugin": "1.18.1", "snyk-php-plugin": "1.9.0", "snyk-policy": "1.14.1", - "snyk-python-plugin": "1.17.0", + "snyk-python-plugin": "1.17.1", "snyk-resolve": "1.0.1", "snyk-resolve-deps": "4.4.0", "snyk-sbt-plugin": "2.11.0", @@ -11181,9 +11199,9 @@ } }, "snyk-mvn-plugin": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/snyk-mvn-plugin/-/snyk-mvn-plugin-2.15.1.tgz", - "integrity": "sha512-QxgS+DpPrGZVI41rNXWC2vUHy1pAC1n7lLts5+ospQZtIWAUo2JAo+M6Qp4L/CD4tuG9bMXNXaCrAQNgemHGLA==", + "version": "2.15.2", + "resolved": "https://registry.npmjs.org/snyk-mvn-plugin/-/snyk-mvn-plugin-2.15.2.tgz", + "integrity": "sha512-2TTRizQxfUrA9w0pjxxsvGE+FgFSgog2wwpm378jNiKAZazGgV0txVMM4CoZJMz/tbUmzaJSS8DMQe1C7wlBFQ==", "requires": { "@snyk/cli-interface": "2.5.0", "@snyk/java-call-graph-builder": "1.8.1", @@ -11236,71 +11254,42 @@ } }, "snyk-nuget-plugin": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/snyk-nuget-plugin/-/snyk-nuget-plugin-1.17.0.tgz", - "integrity": "sha512-t7iZ87LBhCK6P2/mJsQh7Dmk3J9zd+IHL4yoSK95Iyk/gP8r++DZijoRHEXy8BlS+eOtSAj1vgCYvv2eAmG28w==", + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/snyk-nuget-plugin/-/snyk-nuget-plugin-1.18.1.tgz", + "integrity": "sha512-Bq+IzbyewxIrUhgdFaDKS5wCNixERC7QBitKsZGM3uCOr9fJM8rr5qg5SS9UIU7eyeKvzuVO/V1yDzjo1cKvUw==", "requires": { "@snyk/lodash": "4.17.15-patch", - "debug": "^3.1.0", + "debug": "^4.1.1", "dotnet-deps-parser": "4.10.0", - "jszip": "3.1.5", + "jszip": "3.3.0", "snyk-paket-parser": "1.6.0", - "tslib": "^1.9.3", + "tslib": "^1.11.2", "xml2js": "^0.4.17" }, "dependencies": { - "core-js": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.3.0.tgz", - "integrity": "sha1-+rg/uwstjchfpjbEudNMdUIMbWU=" - }, - "es6-promise": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz", - "integrity": "sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y=" - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "jszip": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.5.tgz", - "integrity": "sha512-5W8NUaFRFRqTOL7ZDDrx5qWHJyBXy6velVudIzQUSoqAAYqzSh2Z7/m0Rf1QbmQJccegD0r+YZxBjzqoBiEeJQ==", + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "requires": { - "core-js": "~2.3.0", - "es6-promise": "~3.0.2", - "lie": "~3.1.0", - "pako": "~1.0.2", - "readable-stream": "~2.0.6" + "ms": "^2.1.1" } }, - "lie": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", - "integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=", + "jszip": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.3.0.tgz", + "integrity": "sha512-EJ9k766htB1ZWnsV5ZMDkKLgA+201r/ouFF8R2OigVjVdcm2rurcBrrdXaeqBJbqnUVMko512PYmlncBKE1Huw==", "requires": { - "immediate": "~3.0.5" + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "set-immediate-shim": "~1.0.1" } }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" - }, - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" - } + "tslib": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", + "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" } } }, @@ -11385,9 +11374,9 @@ } }, "snyk-python-plugin": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/snyk-python-plugin/-/snyk-python-plugin-1.17.0.tgz", - "integrity": "sha512-EKdVOUlvhiVpXA5TeW8vyxYVqbITAfT+2AbL2ZRiiUNLP5ae+WiNYaPy7aB5HAS9IKBKih+IH8Ag65Xu1IYSYA==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/snyk-python-plugin/-/snyk-python-plugin-1.17.1.tgz", + "integrity": "sha512-KKklat9Hfbj4hw2y63LRhgmziYzmyRt+cSuzN5KDmBSAGYck0EAoPDtNpJXjrIs1kPNz28EXnE6NDnadXnOjiQ==", "requires": { "@snyk/cli-interface": "^2.0.3", "tmp": "0.0.33" @@ -12421,9 +12410,10 @@ } }, "typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", - "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==" + "version": "3.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.2.tgz", + "integrity": "sha512-q2ktq4n/uLuNNShyayit+DTobV2ApPEo/6so68JaD5ojvc/6GClBipedB9zNWYxRSAlZXAe405Rlijzl6qDiSw==", + "dev": true }, "umd": { "version": "3.0.3", diff --git a/package.json b/package.json index 639da6bf..207420f2 100644 --- a/package.json +++ b/package.json @@ -15,17 +15,17 @@ "@babel/preset-env": "^7.9.6", "@babel/preset-typescript": "^7.9.0", "@babel/runtime": "^7.9.6", - "@cypress/code-coverage": "^3.7.2", - "@cypress/webpack-preprocessor": "^5.2.0", + "@cypress/code-coverage": "^3.7.4", + "@cypress/webpack-preprocessor": "^5.2.1", "@std/esm": "^0.26.0", "@types/chai": "^4.2.11", "@types/gl-vec2": "^1.3.0", - "@types/lodash": "^4.14.150", + "@types/lodash": "^4.14.151", "@types/mocha": "^5.2.7", "@types/react": "^16.9.35", - "@types/sinon": "^9.0.0", + "@types/sinon": "^9.0.1", "@types/sinon-chai": "^3.2.4", - "@typescript-eslint/eslint-plugin": "^2.24.0", + "@typescript-eslint/eslint-plugin": "^2.33.0", "babel-loader": "^8.1.0", "babel-plugin-add-module-exports": "^1.0.2", "babel-plugin-istanbul": "^6.0.0", @@ -35,7 +35,7 @@ "cypress": "^4.5.0", "eslint": "^6.8.0", "eslint-config-airbnb-typescript": "^7.2.1", - "eslint-plugin-import": "^2.20.1", + "eslint-plugin-import": "^2.20.2", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.20.0", "mocha": "^5.2.0", @@ -45,7 +45,7 @@ "source-map-loader": "^0.2.4", "ts-mocha": "^7.0.0", "ts-node": "^8.10.1", - "typescript": "^3.8.3", + "typescript": "^3.9.2", "webpack": "^4.43.0", "webpack-cli": "^3.3.11" }, @@ -138,7 +138,7 @@ "lodash": "^4.17.15", "ndarray": "^1.0.19", "ndarray-linear-interpolate": "^1.0.0", - "snyk": "^1.320.2" + "snyk": "^1.321.0" }, "snyk": true, "nyc": { From 7e736d615aee099ead9b67fcf735838da19ffd27 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 18 May 2020 03:38:06 -0400 Subject: [PATCH 2/5] fix CameraAccess module to work expectedly in Node, add tests - These are considered bug fixes, not breaking changes. I'm sorry if they break something on your end. :) - CameraAccess will throw an Error not a String if getUserMedia fails for some reason other than getUserMedia not being supported - in environments where getUserMedia and/or enumerateDevices are not supported, the promises will reject properly with an Error - fairly sizeable cleanup of lint warnings in mediaDevices and camera_access - add node and browser tests for mediaDevices, add node tests for camera_access modules --- cypress/integration/browser.spec.ts | 3 +- src/common/mediaDevices.ts | 12 ++++- src/common/test/browser/mediaDevices.spec.ts | 24 ++++++++++ src/common/test/node/mediaDevices.spec.ts | 24 ++++++++++ src/input/camera_access.ts | 17 ++++---- src/input/test/browser/camera_access.spec.ts | 34 +++++++++------ src/input/test/node/camera_access.spec.ts | 46 ++++++++++++++++++++ 7 files changed, 136 insertions(+), 24 deletions(-) create mode 100644 src/common/test/browser/mediaDevices.spec.ts create mode 100644 src/common/test/node/mediaDevices.spec.ts create mode 100644 src/input/test/node/camera_access.spec.ts diff --git a/cypress/integration/browser.spec.ts b/cypress/integration/browser.spec.ts index da9b49be..3b5edafc 100644 --- a/cypress/integration/browser.spec.ts +++ b/cypress/integration/browser.spec.ts @@ -2,4 +2,5 @@ window.ENV = { development: true, production: false, node: false }; import '../../src/analytics/test/browser/result_collector.spec'; import '../../src/input/test/browser/exif_helper.spec'; -import '../../src/input/test/browser/camera_access.spec'; \ No newline at end of file +import '../../src/input/test/browser/camera_access.spec'; +import '../../src/common/test/browser/mediaDevices.spec'; diff --git a/src/common/mediaDevices.ts b/src/common/mediaDevices.ts index 04fcd699..8b852369 100644 --- a/src/common/mediaDevices.ts +++ b/src/common/mediaDevices.ts @@ -1,7 +1,15 @@ export function enumerateDevices(): Promise> { - return navigator?.mediaDevices?.enumerateDevices?.() ?? Promise.reject(new Error('enumerateDevices is not defined')); + try { + return navigator.mediaDevices.enumerateDevices(); + } catch (err) { + return Promise.reject(new Error('enumerateDevices is not defined')); + } } export function getUserMedia(constraints: MediaStreamConstraints): Promise { - return navigator?.mediaDevices?.getUserMedia(constraints) ?? Promise.reject(new Error('getUserMedia is not defined')); + try { + return navigator.mediaDevices.getUserMedia(constraints); + } catch (err) { + return Promise.reject(new Error('getUserMedia is not defined')); + } } diff --git a/src/common/test/browser/mediaDevices.spec.ts b/src/common/test/browser/mediaDevices.spec.ts new file mode 100644 index 00000000..07caf342 --- /dev/null +++ b/src/common/test/browser/mediaDevices.spec.ts @@ -0,0 +1,24 @@ +import { describe, it } from 'mocha'; +import { expect } from 'chai'; +import { enumerateDevices, getUserMedia } from '../../mediaDevices'; + +describe('mediaDevices (browser)', () => { + describe('enumerateDevices', () => { + it('TODO: rejects with an error if enumerateDevices is not supported in browser version'); + it('returns a Promise', () => { + expect(enumerateDevices()).to.be.a('Promise'); + }); + it('resolves with an Array of InputDeviceInfo', async () => { + const d = await enumerateDevices(); + expect(d).to.be.an('Array').of.length.greaterThan(1); + console.warn('* d=', d); + expect(d[0]).to.be.an.instanceof(InputDeviceInfo); + }); + }); + describe('getUserMedia', () => { + it('TODO: rejects with an error if getUserMedia is not supported'); + it('returns a Promise', () => { + expect(getUserMedia({})).to.be.a('Promise'); + }); + }); +}); diff --git a/src/common/test/node/mediaDevices.spec.ts b/src/common/test/node/mediaDevices.spec.ts new file mode 100644 index 00000000..25dd896e --- /dev/null +++ b/src/common/test/node/mediaDevices.spec.ts @@ -0,0 +1,24 @@ +import { describe, it } from 'mocha'; +import { expect } from 'chai'; +import { enumerateDevices, getUserMedia } from '../../mediaDevices'; + +describe('mediaDevices (node)', () => { + it('enumerateDevices rejects', async () => { + try { + const x = await enumerateDevices(); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions,no-unused-expressions + expect(x).to.not.exist; + } catch (err) { + expect(err.message).to.equal('enumerateDevices is not defined'); + } + }); + it('getUserMedia rejects', async () => { + try { + const x = await getUserMedia({}); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions,no-unused-expressions + expect(x).to.not.exist; + } catch (err) { + expect(err.message).to.equal('getUserMedia is not defined'); + } + }); +}); diff --git a/src/input/camera_access.ts b/src/input/camera_access.ts index 03b35001..20da2fa4 100644 --- a/src/input/camera_access.ts +++ b/src/input/camera_access.ts @@ -2,7 +2,7 @@ import { pick } from 'lodash'; import { getUserMedia, enumerateDevices } from '../common/mediaDevices'; import { QuaggaBuildEnvironment, MediaTrackConstraintsWithDeprecated } from '../../type-definitions/quagga'; -declare var ENV: QuaggaBuildEnvironment; // webpack injects ENV +declare const ENV: QuaggaBuildEnvironment; // webpack injects ENV let streamRef: MediaStream | null; @@ -10,7 +10,7 @@ function waitForVideo(video: HTMLVideoElement): Promise { return new Promise((resolve, reject) => { let attempts = 10; - function checkVideo() { + function checkVideo(): void { if (attempts > 0) { if (video.videoWidth > 10 && video.videoHeight > 10) { if (ENV.development) { @@ -21,7 +21,7 @@ function waitForVideo(video: HTMLVideoElement): Promise { window.setTimeout(checkVideo, 500); } } else { - reject('Unable to play video stream. Is webcam working?'); + reject(new Error('Unable to play video stream. Is webcam working?')); } attempts--; } @@ -41,6 +41,7 @@ async function initCamera(video: HTMLVideoElement, constraints: MediaStreamConst video.setAttribute('autoplay', 'true'); video.setAttribute('muted', 'true'); video.setAttribute('playsinline', 'true'); // not listed on MDN... + // eslint-disable-next-line no-param-reassign video.srcObject = stream; video.addEventListener('loadedmetadata', () => { video.play(); @@ -86,26 +87,26 @@ function getActiveTrack(): MediaStreamTrack | null { return null; } const tracks = streamRef.getVideoTracks(); - return tracks && tracks.length && tracks[0] || null; + return tracks && tracks?.length ? tracks[0] : null; } /** * Used for accessing information about the active stream track and available video devices. */ const QuaggaJSCameraAccess = { - request: async function(video: HTMLVideoElement, videoConstraints?: MediaTrackConstraintsWithDeprecated): Promise { + async request(video: HTMLVideoElement, videoConstraints?: MediaTrackConstraintsWithDeprecated): Promise { const newConstraints = await pickConstraints(videoConstraints); return initCamera(video, newConstraints); }, - release: function(): void { - var tracks = streamRef && streamRef.getVideoTracks(); + release(): void { + const tracks = streamRef && streamRef.getVideoTracks(); if (tracks && tracks.length) { tracks[0].stop(); } streamRef = null; }, enumerateVideoDevices, - getActiveStreamLabel: function(): string { + getActiveStreamLabel(): string { const track = getActiveTrack(); return track ? track.label : ''; }, diff --git a/src/input/test/browser/camera_access.spec.ts b/src/input/test/browser/camera_access.spec.ts index aa1cccda..5408e908 100644 --- a/src/input/test/browser/camera_access.spec.ts +++ b/src/input/test/browser/camera_access.spec.ts @@ -1,20 +1,22 @@ -import CameraAccess, { pickConstraints } from '../../camera_access'; -import { describe, it } from 'mocha'; +import { describe, it, after } from 'mocha'; import { expect } from 'chai'; -import { MediaTrackConstraintsWithDeprecated } from '../../../../type-definitions/quagga'; +import CameraAccess, { pickConstraints } from '../../camera_access'; +import { MediaTrackConstraintsWithDeprecated } from '../../../../type-definitions/quagga.d'; const Quagga = { CameraAccess }; -describe('CameraAccess', () => { +describe('CameraAccess (browser)', () => { + // TODO: move pickConstraints tests into "universal" test, no reason it shouldn't work in node, even if you wouldn't use it. + // TODO: consider moving the entire CameraAccess section to a separate library describe('pickConstraints', () => { it('should return the given constraints if no facingMode is defined', async () => { - const givenConstraints = {width: 180}; + const givenConstraints = { width: 180 }; const actualConstraints = await pickConstraints(givenConstraints); expect(actualConstraints.video).to.deep.equal(givenConstraints); }); it('should return the given constraints if deviceId is defined', async () => { - const givenConstraints = {width: 180, deviceId: '4343'}; + const givenConstraints = { width: 180, deviceId: '4343' }; const actualConstraints = await pickConstraints(givenConstraints); expect(actualConstraints.video).to.deep.equal(givenConstraints); }); @@ -68,9 +70,13 @@ describe('CameraAccess', () => { expect(constraints.height).to.equal(240); expect(constraints.facingMode).to.equal('user'); expect(constraints.aspectRatio).to.equal(2); - expect(constraints.facing).to.be.undefined; - expect(constraints.minAspectRatio).to.be.undefined; - expect(constraints.maxAspectRatio).to.be.undefined; + /* eslint-disable no-unused-expressions */ + /* eslint-disable @typescript-eslint/no-unused-expressions */ + expect(constraints.facing).to.not.exist; + expect(constraints.minAspectRatio).to.not.exist; + expect(constraints.maxAspectRatio).to.not.exist; + /* eslint-enable no-unused-expressions */ + /* eslint-enable @typescript-eslint/no-unused-expressions */ }); it('will fail on NotAllowedError', async () => { @@ -79,21 +85,23 @@ describe('CameraAccess', () => { const video = document.createElement('video'); try { const x = await Quagga.CameraAccess.request(video, { width: 320, height: 240 }); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions,no-unused-expressions expect(x).to.not.exist; - } catch(err) { + } catch (err) { expect(err).to.be.an.instanceOf(DOMException); expect(err.name).to.equal('NotAllowedError'); } }); - it('fails eventually on unacceptable video size', async function() { + it('fails eventually on unacceptable video size', async function () { this.timeout(10000); after(() => Quagga.CameraAccess.release()); const video = document.createElement('video'); try { - const x = await Quagga.CameraAccess.request(video, { width: 5, height: 5}); + const x = await Quagga.CameraAccess.request(video, { width: 5, height: 5 }); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions,no-unused-expressions expect(x).to.not.exist; - } catch(err) { + } catch (err) { expect(err).to.equal('Unable to play video stream. Is webcam working?'); } }); diff --git a/src/input/test/node/camera_access.spec.ts b/src/input/test/node/camera_access.spec.ts new file mode 100644 index 00000000..a208e3c0 --- /dev/null +++ b/src/input/test/node/camera_access.spec.ts @@ -0,0 +1,46 @@ +import { describe, it } from 'mocha'; +import { expect } from 'chai'; +import CameraAccess from '../../camera_access'; + +const Quagga = { CameraAccess }; + +describe('CameraAccess (node)', () => { + describe('enumerateVideoDevices', () => { + it('rejects', async () => { + try { + const x = await Quagga.CameraAccess.enumerateVideoDevices(); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions,no-unused-expressions + expect(x).to.not.exist; + } catch (err) { + expect(err.message).to.equal('enumerateDevices is not defined'); + } + }); + }); + + describe('request', () => { + it('rejects', async () => { + try { + // @ts-expect-error + const x = await Quagga.CameraAccess.request(null, {}); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions,no-unused-expressions + expect(x).to.not.exist; + } catch (err) { + expect(err.message).to.equal('getUserMedia is not defined'); + } + }); + }); + + describe('release', () => { + it('works (no-op)', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions,no-unused-expressions + expect(Quagga.CameraAccess.release).to.not.throw; + }); + }); + + describe('getActiveStreamLabel', () => { + it('no active stream', () => { + const x = Quagga.CameraAccess.getActiveStreamLabel(); + expect(x).to.equal(''); + }); + }); +}); From ab90e6cf3dfcfb48f89fe3d6a9c224b634638e26 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 18 May 2020 03:42:08 -0400 Subject: [PATCH 3/5] fix lint warnings in result_collector and tests for result_collector --- package.json | 2 +- src/analytics/result_collector.ts | 42 +++++---- .../test/browser/result_collector.spec.ts | 85 ++++++++++--------- 3 files changed, 71 insertions(+), 58 deletions(-) diff --git a/package.json b/package.json index 207420f2..c7f959df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ericblade/quagga2", - "version": "1.0.4", + "version": "1.0.5", "description": "An advanced barcode-scanner written in JavaScript", "main": "lib/quagga.js", "types": "type-definitions/quagga.d.ts", diff --git a/src/analytics/result_collector.ts b/src/analytics/result_collector.ts index 9a9b62ec..1944e13f 100644 --- a/src/analytics/result_collector.ts +++ b/src/analytics/result_collector.ts @@ -1,38 +1,48 @@ import ImageDebug from '../common/image_debug'; -import { QuaggaJSCodeResult, QuaggaJSResultCollector, QuaggaJSResultCollectorFilterFunction, XYSize, QuaggaImageData } from '../../type-definitions/quagga'; +import { + QuaggaJSCodeResult, + QuaggaJSResultCollector, + QuaggaJSResultCollectorFilterFunction, + XYSize, + QuaggaImageData, +} from '../../type-definitions/quagga.d'; -function contains(codeResult: QuaggaJSCodeResult, list: Array) { - if (!list) return false; - return list.some((item) => { +function contains(codeResult: QuaggaJSCodeResult, list: Array): boolean { + return list && list.some((item) => { const keys = Object.keys(item) as Array; return keys.every((key) => item[key] === codeResult[key]); }); } -function passesFilter(codeResult: QuaggaJSCodeResult, filter: QuaggaJSResultCollectorFilterFunction | undefined) { - if (typeof filter === 'function') { - return filter(codeResult); - } - return true; +function passesFilter( + codeResult: QuaggaJSCodeResult, + filter: QuaggaJSResultCollectorFilterFunction | undefined, +): boolean { + return typeof filter === 'function' ? filter(codeResult) : true; +} + +interface ResultCollector { + addResult: (data: QuaggaImageData, imageSize: XYSize, codeResult: QuaggaJSCodeResult) => void; + getResults: () => Array; } export default { - create: function(config: QuaggaJSResultCollector) { + create(config: QuaggaJSResultCollector): ResultCollector { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d') as CanvasRenderingContext2D; - const results:Array = []; + const results: Array = []; let capacity = config.capacity ?? 20; const capture = config.capture === true; - function matchesConstraints(codeResult: QuaggaJSCodeResult) { - return capacity + function matchesConstraints(codeResult: QuaggaJSCodeResult): boolean { + return !!capacity && codeResult && !contains(codeResult, config.blacklist as Array) && passesFilter(codeResult, config.filter); } - + return { - addResult: function(data: QuaggaImageData, imageSize: XYSize, codeResult: QuaggaJSCodeResult) { + addResult(data: QuaggaImageData, imageSize: XYSize, codeResult: QuaggaJSCodeResult): void { const result: any = { }; // this is 'any' to avoid having to construct a whole QuaggaJSCodeResult :| if (matchesConstraints(codeResult)) { capacity--; @@ -46,7 +56,7 @@ export default { results.push(result); } }, - getResults: function() { + getResults(): Array { return results; }, }; diff --git a/src/analytics/test/browser/result_collector.spec.ts b/src/analytics/test/browser/result_collector.spec.ts index d71c90da..60e32dbf 100644 --- a/src/analytics/test/browser/result_collector.spec.ts +++ b/src/analytics/test/browser/result_collector.spec.ts @@ -1,11 +1,14 @@ -/// - -import ResultCollector from '../../result_collector'; -import ImageDebug from '../../../common/image_debug'; -import { XYSize, QuaggaJSResultCollector, QuaggaJSCodeResult } from '../../../../type-definitions/quagga'; -// import { describe, beforeEach, afterEach, it } from 'mocha'; import { expect } from 'chai'; import sinon, { SinonSpy } from 'sinon'; +import { + describe, + beforeEach, + afterEach, + it, +} from 'mocha'; +import ResultCollector from '../../result_collector'; +import ImageDebug from '../../../common/image_debug'; +import { XYSize, QuaggaJSResultCollector, QuaggaJSCodeResult } from '../../../../type-definitions/quagga.d'; interface MockCanvas { getContext(): {}; @@ -18,24 +21,24 @@ let canvasMock: MockCanvas; let imageSize: XYSize; let config: QuaggaJSResultCollector; -describe("Result Collector", () => { - beforeEach(function() { - imageSize = {x: 320, y: 240}; +describe('Result Collector', () => { + beforeEach(() => { + imageSize = { x: 320, y: 240 }; config = { capture: true, capacity: 20, - blacklist: [{code: "3574660239843", format: "ean_13"}], - filter: function() { + blacklist: [{ code: '3574660239843', format: 'ean_13' }], + filter(): boolean { return true; - } + }, }; canvasMock = { - getContext: function() { + getContext(): {} { return {}; }, toDataURL: sinon.spy(), width: 0, - height: 0 + height: 0, }; sinon.stub(document, 'createElement').callsFake((type) => { if (type === 'canvas') { @@ -45,74 +48,74 @@ describe("Result Collector", () => { }); }); - afterEach(function() { + afterEach(() => { (document.createElement as SinonSpy).restore(); }); - describe('create', function () { - it("should return a new collector", function() { + describe('create', () => { + it('should return a new collector', () => { ResultCollector.create(config); - expect( (document.createElement as SinonSpy).calledOnce).to.be.equal(true); - expect( (document.createElement as SinonSpy).getCall(0).args[0]).to.equal("canvas"); + expect((document.createElement as SinonSpy).calledOnce).to.be.equal(true); + expect((document.createElement as SinonSpy).getCall(0).args[0]).to.equal('canvas'); }); }); - describe('addResult', function() { - beforeEach(function() { - sinon.stub(ImageDebug, 'drawImage').callsFake(() => { return true; }); + describe('addResult', () => { + beforeEach(() => { + sinon.stub(ImageDebug, 'drawImage').callsFake(() => true); }); - afterEach(function() { + afterEach(() => { (ImageDebug.drawImage as SinonSpy).restore(); }); - it("should not add result if capacity is full", function(){ + it('should not add result if capacity is full', () => { config.capacity = 1; - var collector = ResultCollector.create(config); + const collector = ResultCollector.create(config); collector.addResult([], imageSize, {}); collector.addResult([], imageSize, {}); collector.addResult([], imageSize, {}); expect(collector.getResults()).to.have.length(1); }); - it("should only add results which match constraints", function() { + it('should only add results which match constraints', () => { const collector = ResultCollector.create(config); - collector.addResult([], imageSize, {code: "423423443", format: "ean_13"}); - collector.addResult([], imageSize, {code: "3574660239843", format: "ean_13"}); - collector.addResult([], imageSize, {code: "3574660239843", format: "code_128"}); + collector.addResult([], imageSize, { code: '423423443', format: 'ean_13' }); + collector.addResult([], imageSize, { code: '3574660239843', format: 'ean_13' }); + collector.addResult([], imageSize, { code: '3574660239843', format: 'code_128' }); const results = collector.getResults(); expect(results).to.have.length(2); - results.forEach(function(result: QuaggaJSCodeResult) { + results.forEach((result: QuaggaJSCodeResult) => { expect(result).not.to.deep.equal(config.blacklist![0]); }); }); - it("should add result if no filter is set", function() { + it('should add result if no filter is set', () => { delete config.filter; - var collector = ResultCollector.create(config); + const collector = ResultCollector.create(config); - collector.addResult([], imageSize, {code: "423423443", format: "ean_13"}); + collector.addResult([], imageSize, { code: '423423443', format: 'ean_13' }); expect(collector.getResults()).to.have.length(1); }); - it("should not add results if filter returns false", function() { - config.filter = () => (false); - var collector = ResultCollector.create(config); + it('should not add results if filter returns false', () => { + config.filter = (): boolean => (false); + const collector = ResultCollector.create(config); - collector.addResult([], imageSize, {code: "423423443", format: "ean_13"}); + collector.addResult([], imageSize, { code: '423423443', format: 'ean_13' }); expect(collector.getResults()).to.have.length(0); }); - it("should add result if no blacklist is set", function() { + it('should add result if no blacklist is set', () => { delete config.blacklist; - var collector = ResultCollector.create(config); + const collector = ResultCollector.create(config); - collector.addResult([], imageSize, {code: "3574660239843", format: "ean_13"}); + collector.addResult([], imageSize, { code: '3574660239843', format: 'ean_13' }); expect(collector.getResults()).to.have.length(1); }); }); -}) +}); From 33944f355717d16f04a556d173e671ce132654dd Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 18 May 2020 03:56:48 -0400 Subject: [PATCH 4/5] fix lint errors in external type-defs (quagga.d.ts) --- type-definitions/quagga.d.ts | 90 +++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 28 deletions(-) diff --git a/type-definitions/quagga.d.ts b/type-definitions/quagga.d.ts index 44b2e362..59b024a7 100644 --- a/type-definitions/quagga.d.ts +++ b/type-definitions/quagga.d.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-classes-per-file */ // Type definitions for QuaggaJS v0.12.1 (2017-10-19) // Project: http://serratus.github.io/quaggaJS/ // Definitions by: Cam Birch, Peter Horwood aka Madman Pierre, Dan Manastireanu @@ -11,61 +12,92 @@ export default Quagga; // TODO: fill this in from cv_utils#imageRef export type ImageRef = { - x: number, - y: number, -} + x: number; + y: number; +}; -export type SparseImageWrapper = { data: TypedArray | Array | null, size: ImageRef }; +export type SparseImageWrapper = { + data: TypedArray | Array | null; + size: ImageRef; +}; export interface WrapperIndexMapping { x: Array; y: Array; } +// eslint-disable-next-line @typescript-eslint/class-name-casing export interface moment { - m00: number, - m01: number, - m10: number, - m11: number, - m02: number, - m20: number, - theta: number, - rad: number, - vec?: Array + m00: number; + m01: number; + m10: number; + m11: number; + m02: number; + m20: number; + theta: number; + rad: number; + vec?: Array; } -export interface ImageWrapper { +export class ImageWrapper { data: TypedArray | Array; + size: XYSize; + indexMapping?: WrapperIndexMapping; - constructor(size: XYSize, data?: TypedArray | Array, ArrayType?: TypedArrayConstructor | ArrayConstructor, initialize?: boolean): ImageWrapper; + + constructor( + size: XYSize, + data?: TypedArray | Array, + ArrayType?: TypedArrayConstructor | ArrayConstructor, + initialize?: boolean + ); + inImageWithBorder(imgRef: ImageRef, border: number): boolean; + subImageAsCopy(imageWrapper: ImageWrapper, from: XYSize): ImageWrapper; + get(x: number, y: number): number; + getSafe(x: number, y: number): number; + set(x: number, y: number, value: number): ImageWrapper; + zeroBorder(): ImageWrapper; + moments(labelcount: any): Array; + getAsRGBA(scale?: number): Uint8ClampedArray; + show(canvas: HTMLCanvasElement, scale?: number): void; + overlay(canvas: HTMLCanvasElement, scale: number, from: XYSize): void; } -export interface SubImage { +export class SubImage { I: ImageWrapper | SparseImageWrapper; + data: ImageWrapper['data']; + originalSize: ImageRef; + from: ImageRef; + size: ImageRef; - constructor(from: ImageRef, size: ImageRef, I: SparseImageWrapper): SubImage; + + constructor(from: ImageRef, size: ImageRef, I: SparseImageWrapper); + get(x: number, y: number): number; + show(canvas: HTMLCanvasElement, scale: number): void; + updateData(image: ImageWrapper): void; + updateFrom(from: ImageRef): void; } export type XYSize = { - x: number, - y: number, + x: number; + y: number; }; export type QuaggaImageData = Array; @@ -167,12 +199,12 @@ export interface QuaggaJSStatic { canvas: { ctx: { image: CanvasRenderingContext2D; - overlay: CanvasRenderingContext2D + overlay: CanvasRenderingContext2D; }; dom: { image: HTMLCanvasElement; - overlay: HTMLCanvasElement - } + overlay: HTMLCanvasElement; + }; }; CameraAccess: QuaggaJSCameraAccess; @@ -215,7 +247,7 @@ export interface QuaggaJSDebugDrawPath { def: QuaggaJSxyDef, ctx: CanvasRenderingContext2D, style: QuaggaJSStyle - ): void + ): void; } /** @@ -227,7 +259,7 @@ export interface QuaggaJSDebugDrawRect { size: QuaggaJSRectSize, ctx: CanvasRenderingContext2D, style: QuaggaJSStyle - ): void + ): void; } /** @@ -331,8 +363,9 @@ export interface QuaggaJSResultCollectorFilterFunction { * empty. */ export interface QuaggaJSResultObject { + // eslint-disable-next-line @typescript-eslint/camelcase codeResult: QuaggaJSResultObject_CodeResult; - barcodes?: Array + barcodes?: Array; line: { x: number; y: number; @@ -344,6 +377,7 @@ export interface QuaggaJSResultObject { frame?: string; } +// eslint-disable-next-line @typescript-eslint/camelcase,@typescript-eslint/class-name-casing export interface QuaggaJSResultObject_CodeResult { code: string | null; start: number; @@ -393,7 +427,7 @@ export interface QuaggaJSConfigObject { */ type?: InputStreamType; - target?: Element | string, + target?: Element | string; constraints?: MediaTrackConstraints; @@ -557,7 +591,7 @@ export interface QuaggaJSConfigObject { */ showBB?: boolean; }; - } + }; }; } @@ -565,7 +599,7 @@ export interface QuaggaJSReaderConfig { format: string; config: { supplements: string[]; - } + }; } export interface MediaTrackConstraintsWithDeprecated extends MediaTrackConstraints { From bdf81a288b1250d2a9465fbf28761b9af574d65d Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 18 May 2020 04:30:23 -0400 Subject: [PATCH 5/5] fix broken camera_access test --- src/input/test/browser/camera_access.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input/test/browser/camera_access.spec.ts b/src/input/test/browser/camera_access.spec.ts index 5408e908..bfe8e900 100644 --- a/src/input/test/browser/camera_access.spec.ts +++ b/src/input/test/browser/camera_access.spec.ts @@ -102,7 +102,7 @@ describe('CameraAccess (browser)', () => { // eslint-disable-next-line @typescript-eslint/no-unused-expressions,no-unused-expressions expect(x).to.not.exist; } catch (err) { - expect(err).to.equal('Unable to play video stream. Is webcam working?'); + expect(err.message).to.equal('Unable to play video stream. Is webcam working?'); } }); // TODO: need to add a test for no support in browser to straight up fail