mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
52a03c76b6 | |||
439e365ea8 | |||
e29af58661 | |||
171585491d | |||
99b8182991 | |||
a4a3ce8a2e | |||
084017a673 | |||
4555940d0b |
40
.github/workflows/ci.yml
vendored
40
.github/workflows/ci.yml
vendored
@ -309,3 +309,43 @@ jobs:
|
||||
FOLDER: docs
|
||||
SINGLE_COMMIT: true
|
||||
CLEAN: true
|
||||
diff-reftests:
|
||||
runs-on: ubuntu-latest
|
||||
name: Diff reftest screenshots
|
||||
needs: browser-test
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
# npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
${{ runner.os }}-build-
|
||||
${{ runner.os }}-
|
||||
- name: Npm install
|
||||
run: npm ci
|
||||
- name: Checkout current snapshots
|
||||
run: git checkout origin/gh-pages results
|
||||
- name: Download test results
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: reftest-results
|
||||
path: tmp/reftests
|
||||
- name: Run diff
|
||||
run: npm run reftests-diff
|
||||
continue-on-error: true
|
||||
- name: Upload diff
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: snapshot-diffs
|
||||
path: tmp/snapshot-diffs
|
||||
|
25
CHANGELOG.md
25
CHANGELOG.md
@ -2,6 +2,31 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [1.1.2](https://github.com/niklasvh/html2canvas/compare/v1.1.1...v1.1.2) (2021-07-13)
|
||||
|
||||
|
||||
### ci
|
||||
|
||||
* implement screenshot diffing (#2571) ([e29af58](https://github.com/niklasvh/html2canvas/commit/e29af586618125bbad10ad6bee3d69fddbc5d22a)), closes [#2571](https://github.com/niklasvh/html2canvas/issues/2571)
|
||||
|
||||
### fix
|
||||
|
||||
* logger unique names (#2575) ([1715854](https://github.com/niklasvh/html2canvas/commit/171585491dd1bee4f30691328bd22e978f3ac79e)), closes [#2575](https://github.com/niklasvh/html2canvas/issues/2575)
|
||||
* text-shadow position with baseline (#2576) ([439e365](https://github.com/niklasvh/html2canvas/commit/439e365ea8c703b528778a268dcfc3bf9ccad6a9)), closes [#2576](https://github.com/niklasvh/html2canvas/issues/2576)
|
||||
|
||||
|
||||
|
||||
## [1.1.1](https://github.com/niklasvh/html2canvas/compare/v1.1.0...v1.1.1) (2021-07-12)
|
||||
|
||||
|
||||
### fix
|
||||
|
||||
* allow proxy url with parameters (#2100) ([a4a3ce8](https://github.com/niklasvh/html2canvas/commit/a4a3ce8a2eb6a4f43f1bc9a7935eb16f2b98a3cd)), closes [#2100](https://github.com/niklasvh/html2canvas/issues/2100)
|
||||
* crash on background-size with calc() (fix #2469) (#2569) ([084017a](https://github.com/niklasvh/html2canvas/commit/084017a67319a993d73c6bdf612dd8532f1b8dbe)), closes [#2469](https://github.com/niklasvh/html2canvas/issues/2469) [#2569](https://github.com/niklasvh/html2canvas/issues/2569)
|
||||
* handle unhandled promise rejections (#2568) ([4555940](https://github.com/niklasvh/html2canvas/commit/4555940d0bc17b7fd9327dd0164c382a3dbf1858)), closes [#2568](https://github.com/niklasvh/html2canvas/issues/2568)
|
||||
|
||||
|
||||
|
||||
# [1.1.0](https://github.com/niklasvh/html2canvas/compare/v1.0.0...v1.1.0) (2021-07-11)
|
||||
|
||||
|
||||
|
266
package-lock.json
generated
266
package-lock.json
generated
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "html2canvas",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"css-line-break": "1.1.1"
|
||||
@ -23,6 +23,7 @@
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/glob": "^7.1.1",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/jest-image-snapshot": "^4.3.1",
|
||||
"@types/karma": "^6.3.0",
|
||||
"@types/mocha": "^8.2.3",
|
||||
"@types/node": "^16.3.1",
|
||||
@ -49,6 +50,7 @@
|
||||
"glob": "7.1.3",
|
||||
"html2canvas-proxy": "1.0.1",
|
||||
"jest": "^27.0.6",
|
||||
"jest-image-snapshot": "^4.5.1",
|
||||
"jquery": "^3.5.1",
|
||||
"js-polyfills": "^0.1.42",
|
||||
"karma": "^6.3.2",
|
||||
@ -3758,6 +3760,17 @@
|
||||
"pretty-format": "^26.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/jest-image-snapshot": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest-image-snapshot/-/jest-image-snapshot-4.3.1.tgz",
|
||||
"integrity": "sha512-WDdUruGF14C53axe/mNDgQP2YIhtcwXrwmmVP8eOGyfNTVD+FbxWjWR7RTU+lzEy4K6V6+z7nkVDm/auI/r3xQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/jest": "*",
|
||||
"@types/pixelmatch": "*",
|
||||
"ssim.js": "^3.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/jest/node_modules/@jest/types": {
|
||||
"version": "26.6.2",
|
||||
"resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz",
|
||||
@ -3962,6 +3975,15 @@
|
||||
"integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/pixelmatch": {
|
||||
"version": "5.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/pixelmatch/-/pixelmatch-5.2.4.tgz",
|
||||
"integrity": "sha512-HDaSHIAv9kwpMN7zlmwfTv6gax0PiporJOipcrGsVNF3Ba+kryOZc0Pio5pn6NhisgWr7TaajlPEKTbTAypIBQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/platform": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/platform/-/platform-1.3.4.tgz",
|
||||
@ -12886,6 +12908,12 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/glur": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glur/-/glur-1.1.2.tgz",
|
||||
"integrity": "sha1-8g6jbbEDv8KSNDkh8fkeg8NGdok=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/graceful-fs": {
|
||||
"version": "4.2.6",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
|
||||
@ -12978,6 +13006,18 @@
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/has-ansi": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
|
||||
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/has-flag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||
@ -15313,6 +15353,105 @@
|
||||
"node": ">=8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-image-snapshot": {
|
||||
"version": "4.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jest-image-snapshot/-/jest-image-snapshot-4.5.1.tgz",
|
||||
"integrity": "sha512-0YkgupgkkCx0wIZkxvqs/oNiUT0X0d2WTpUhaAp+Dy6CpqBUZMRTIZo4KR1f+dqmx6WXrLCvecjnHLIsLkI+gQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"chalk": "^1.1.3",
|
||||
"get-stdin": "^5.0.1",
|
||||
"glur": "^1.1.2",
|
||||
"lodash": "^4.17.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"pixelmatch": "^5.1.0",
|
||||
"pngjs": "^3.4.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"ssim.js": "^3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.14.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"jest": ">=20 <=27"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-image-snapshot/node_modules/ansi-styles": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
|
||||
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-image-snapshot/node_modules/chalk": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ansi-styles": "^2.2.1",
|
||||
"escape-string-regexp": "^1.0.2",
|
||||
"has-ansi": "^2.0.0",
|
||||
"strip-ansi": "^3.0.0",
|
||||
"supports-color": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-image-snapshot/node_modules/get-stdin": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz",
|
||||
"integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-image-snapshot/node_modules/pixelmatch": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-5.2.1.tgz",
|
||||
"integrity": "sha512-WjcAdYSnKrrdDdqTcVEY7aB7UhhwjYQKYhHiBXdJef0MOaQeYpUdQ+iVyBLa5YBKS8MPVPPMX7rpOByISLpeEQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"pngjs": "^4.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"pixelmatch": "bin/pixelmatch"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-image-snapshot/node_modules/pixelmatch/node_modules/pngjs": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-4.0.1.tgz",
|
||||
"integrity": "sha512-rf5+2/ioHeQxR6IxuYNYGFytUyG3lma/WW1nsmjeHlWwtb2aByla6dkVc8pmJ9nplzkTA0q2xx7mMWrOTqT4Gg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-image-snapshot/node_modules/rimraf": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"glob": "^7.1.3"
|
||||
},
|
||||
"bin": {
|
||||
"rimraf": "bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-image-snapshot/node_modules/supports-color": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
|
||||
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-jasmine2": {
|
||||
"version": "27.0.6",
|
||||
"resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-27.0.6.tgz",
|
||||
@ -22207,6 +22346,12 @@
|
||||
"tweetnacl": "~0.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ssim.js": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/ssim.js/-/ssim.js-3.5.0.tgz",
|
||||
"integrity": "sha512-Aj6Jl2z6oDmgYFFbQqK7fght19bXdOxY7Tj03nF+03M9gCBAjeIiO8/PlEGMfKDwYpw4q6iBqVq2YuREorGg/g==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ssri": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.2.tgz",
|
||||
@ -28773,6 +28918,17 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@types/jest-image-snapshot": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest-image-snapshot/-/jest-image-snapshot-4.3.1.tgz",
|
||||
"integrity": "sha512-WDdUruGF14C53axe/mNDgQP2YIhtcwXrwmmVP8eOGyfNTVD+FbxWjWR7RTU+lzEy4K6V6+z7nkVDm/auI/r3xQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/jest": "*",
|
||||
"@types/pixelmatch": "*",
|
||||
"ssim.js": "^3.1.1"
|
||||
}
|
||||
},
|
||||
"@types/json-schema": {
|
||||
"version": "7.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.8.tgz",
|
||||
@ -28825,6 +28981,15 @@
|
||||
"integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/pixelmatch": {
|
||||
"version": "5.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/pixelmatch/-/pixelmatch-5.2.4.tgz",
|
||||
"integrity": "sha512-HDaSHIAv9kwpMN7zlmwfTv6gax0PiporJOipcrGsVNF3Ba+kryOZc0Pio5pn6NhisgWr7TaajlPEKTbTAypIBQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/platform": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/platform/-/platform-1.3.4.tgz",
|
||||
@ -36075,6 +36240,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"glur": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glur/-/glur-1.1.2.tgz",
|
||||
"integrity": "sha1-8g6jbbEDv8KSNDkh8fkeg8NGdok=",
|
||||
"dev": true
|
||||
},
|
||||
"graceful-fs": {
|
||||
"version": "4.2.6",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
|
||||
@ -36145,6 +36316,15 @@
|
||||
"function-bind": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"has-ansi": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
|
||||
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||
@ -37990,6 +38170,82 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"jest-image-snapshot": {
|
||||
"version": "4.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jest-image-snapshot/-/jest-image-snapshot-4.5.1.tgz",
|
||||
"integrity": "sha512-0YkgupgkkCx0wIZkxvqs/oNiUT0X0d2WTpUhaAp+Dy6CpqBUZMRTIZo4KR1f+dqmx6WXrLCvecjnHLIsLkI+gQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^1.1.3",
|
||||
"get-stdin": "^5.0.1",
|
||||
"glur": "^1.1.2",
|
||||
"lodash": "^4.17.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"pixelmatch": "^5.1.0",
|
||||
"pngjs": "^3.4.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"ssim.js": "^3.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-styles": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
|
||||
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
|
||||
"dev": true
|
||||
},
|
||||
"chalk": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^2.2.1",
|
||||
"escape-string-regexp": "^1.0.2",
|
||||
"has-ansi": "^2.0.0",
|
||||
"strip-ansi": "^3.0.0",
|
||||
"supports-color": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"get-stdin": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz",
|
||||
"integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=",
|
||||
"dev": true
|
||||
},
|
||||
"pixelmatch": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-5.2.1.tgz",
|
||||
"integrity": "sha512-WjcAdYSnKrrdDdqTcVEY7aB7UhhwjYQKYhHiBXdJef0MOaQeYpUdQ+iVyBLa5YBKS8MPVPPMX7rpOByISLpeEQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"pngjs": "^4.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"pngjs": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-4.0.1.tgz",
|
||||
"integrity": "sha512-rf5+2/ioHeQxR6IxuYNYGFytUyG3lma/WW1nsmjeHlWwtb2aByla6dkVc8pmJ9nplzkTA0q2xx7mMWrOTqT4Gg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"glob": "^7.1.3"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
|
||||
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"jest-jasmine2": {
|
||||
"version": "27.0.6",
|
||||
"resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-27.0.6.tgz",
|
||||
@ -43377,6 +43633,12 @@
|
||||
"tweetnacl": "~0.14.0"
|
||||
}
|
||||
},
|
||||
"ssim.js": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/ssim.js/-/ssim.js-3.5.0.tgz",
|
||||
"integrity": "sha512-Aj6Jl2z6oDmgYFFbQqK7fght19bXdOxY7Tj03nF+03M9gCBAjeIiO8/PlEGMfKDwYpw4q6iBqVq2YuREorGg/g==",
|
||||
"dev": true
|
||||
},
|
||||
"ssri": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.2.tgz",
|
||||
|
@ -6,7 +6,7 @@
|
||||
"module": "dist/html2canvas.esm.js",
|
||||
"typings": "dist/types/index.d.ts",
|
||||
"browser": "dist/html2canvas.js",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.2",
|
||||
"author": {
|
||||
"name": "Niklas von Hertzen",
|
||||
"email": "niklasvh@gmail.com",
|
||||
@ -35,6 +35,7 @@
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/glob": "^7.1.1",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/jest-image-snapshot": "^4.3.1",
|
||||
"@types/karma": "^6.3.0",
|
||||
"@types/mocha": "^8.2.3",
|
||||
"@types/node": "^16.3.1",
|
||||
@ -61,6 +62,7 @@
|
||||
"glob": "7.1.3",
|
||||
"html2canvas-proxy": "1.0.1",
|
||||
"jest": "^27.0.6",
|
||||
"jest-image-snapshot": "^4.5.1",
|
||||
"jquery": "^3.5.1",
|
||||
"js-polyfills": "^0.1.42",
|
||||
"karma": "^6.3.2",
|
||||
@ -107,6 +109,7 @@
|
||||
"lint": "eslint src/**/*.ts --max-warnings 0",
|
||||
"test": "npm run lint && npm run unittest && npm run karma",
|
||||
"unittest": "jest",
|
||||
"reftests-diff": "mkdirp tmp/snapshots && jest --roots=tests --testMatch=**/reftest-diff.ts",
|
||||
"karma": "ts-node tests/karma",
|
||||
"watch": "rollup -c rollup.config.ts -w",
|
||||
"watch:unittest": "mocha --require ts-node/register --watch-extensions ts -w src/**/__tests__/*.ts",
|
||||
|
@ -87,7 +87,9 @@ export class Cache {
|
||||
}
|
||||
|
||||
if (isBlobImage(src) || isRenderable(src)) {
|
||||
this._cache[src] = this.loadImage(src);
|
||||
(this._cache[src] = this.loadImage(src)).catch(() => {
|
||||
// prevent unhandled rejection
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -178,7 +180,8 @@ export class Cache {
|
||||
};
|
||||
|
||||
xhr.onerror = reject;
|
||||
xhr.open('GET', `${proxy}?url=${encodeURIComponent(src)}&responseType=${responseType}`);
|
||||
const queryString = proxy.indexOf('?') > -1 ? '&' : '?';
|
||||
xhr.open('GET', `${proxy}${queryString}url=${encodeURIComponent(src)}&responseType=${responseType}`);
|
||||
|
||||
if (responseType !== 'text' && xhr instanceof XMLHttpRequest) {
|
||||
xhr.responseType = responseType;
|
||||
|
@ -29,7 +29,12 @@ if (typeof window !== 'undefined') {
|
||||
CacheStorage.setContext(window);
|
||||
}
|
||||
|
||||
let instanceCount = 1;
|
||||
|
||||
const renderElement = async (element: HTMLElement, opts: Partial<Options>): Promise<HTMLCanvasElement> => {
|
||||
if (typeof element !== 'object') {
|
||||
return Promise.reject('Invalid element provided as first argument');
|
||||
}
|
||||
const ownerDocument = element.ownerDocument;
|
||||
|
||||
if (!ownerDocument) {
|
||||
@ -42,7 +47,7 @@ const renderElement = async (element: HTMLElement, opts: Partial<Options>): Prom
|
||||
throw new Error(`Document is not attached to a Window`);
|
||||
}
|
||||
|
||||
const instanceName = (Math.round(Math.random() * 1000) + Date.now()).toString(16);
|
||||
const instanceName = `#${instanceCount++}`;
|
||||
|
||||
const {width, height, left, top} =
|
||||
isBodyElement(element) || isHTMLElement(element) ? parseDocumentSize(ownerDocument) : parseBounds(element);
|
||||
|
@ -91,6 +91,10 @@ export const calculateBackgroundSize = (
|
||||
): [number, number] => {
|
||||
const [first, second] = size;
|
||||
|
||||
if (!first) {
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
if (isLengthPercentage(first) && second && isLengthPercentage(second)) {
|
||||
return [getAbsoluteValue(first, bounds.width), getAbsoluteValue(second, bounds.height)];
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ export class CanvasRenderer {
|
||||
this.ctx.shadowOffsetY = textShadow.offsetY.number * this.options.scale;
|
||||
this.ctx.shadowBlur = textShadow.blur.number;
|
||||
|
||||
this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
|
||||
this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline);
|
||||
});
|
||||
|
||||
this.ctx.shadowColor = '';
|
||||
|
32
tests/reftest-diff.ts
Normal file
32
tests/reftest-diff.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import {sync} from 'glob';
|
||||
import {resolve, basename} from 'path';
|
||||
import {existsSync, promises} from 'fs';
|
||||
import {toMatchImageSnapshot} from 'jest-image-snapshot';
|
||||
|
||||
const resultsDir = resolve(__dirname, '../results');
|
||||
const customSnapshotsDir = resolve(__dirname, '../tmp/snapshots');
|
||||
const customDiffDir = resolve(__dirname, '../tmp/snapshot-diffs');
|
||||
|
||||
expect.extend({toMatchImageSnapshot});
|
||||
|
||||
describe('Image diff', () => {
|
||||
const files: string[] = sync('../tmp/reftests/**/*.png', {
|
||||
cwd: __dirname,
|
||||
root: resolve(__dirname, '../../')
|
||||
}).filter((path) => existsSync(resolve(resultsDir, basename(path))));
|
||||
|
||||
it.each(files.map((path) => basename(path)))('%s', async (filename) => {
|
||||
const previous = resolve(resultsDir, filename);
|
||||
const previousSnap = resolve(customSnapshotsDir, `${filename}-snap.png`);
|
||||
await promises.copyFile(previous, previousSnap);
|
||||
const updated = resolve(__dirname, '../tmp/reftests/', filename);
|
||||
const buffer = await promises.readFile(updated);
|
||||
|
||||
// @ts-ignore
|
||||
expect(buffer).toMatchImageSnapshot({
|
||||
customSnapshotsDir,
|
||||
customSnapshotIdentifier: () => filename,
|
||||
customDiffDir
|
||||
});
|
||||
});
|
||||
});
|
@ -61,6 +61,7 @@
|
||||
<div style='background-size: auto;'></div>
|
||||
</div>
|
||||
<div class="container" style="padding: 10px; background-size: contain; background-origin: content-box; background-clip: content-box"></div>
|
||||
<div class="container" style="background-size: calc(100% - 10px)"></div>
|
||||
<div class="sliver">
|
||||
<div></div>
|
||||
</div>
|
||||
|
@ -2,10 +2,21 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>iframe test</title>
|
||||
<script>
|
||||
h2cOptions = {useCORS: true, proxy: null};
|
||||
</script>
|
||||
<script type="text/javascript" src="../test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div style="background: cornflowerblue; padding: 20px; width: 200px;">Parent document content</div>
|
||||
<iframe src="/tests/assets/iframe/frame1.html" width="500" height="500"></iframe>
|
||||
<iframe
|
||||
title="Github"
|
||||
src="https://ghbtns.com/github-btn.html?user=niklasvh&repo=html2canvas&type=star&count=true&size=large"
|
||||
frameBorder="0"
|
||||
scrolling="0"
|
||||
width="160px"
|
||||
height="30px"
|
||||
></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -24,6 +24,10 @@ var REFTEST = window.location.search.indexOf('reftest') !== -1;
|
||||
])
|
||||
.forEach(appendScript);
|
||||
|
||||
window.addEventListener("unhandledrejection", function(event) {
|
||||
console.info('UNHANDLED PROMISE REJECTION:', event);
|
||||
});
|
||||
|
||||
window.onload = function() {
|
||||
(function($) {
|
||||
$.fn.html2canvas = function(options) {
|
||||
|
@ -86,6 +86,11 @@ testList
|
||||
throw new Error('Window not found for iframe');
|
||||
}
|
||||
|
||||
contentWindow.addEventListener('unhandledrejection', (event) => {
|
||||
console.error(event.reason);
|
||||
throw new Error(`unhandledrejection: ${JSON.stringify(event.reason)}`);
|
||||
});
|
||||
|
||||
const canvas: HTMLCanvasElement = await contentWindow
|
||||
// @ts-ignore
|
||||
.html2canvas(contentWindow.forceElement || contentWindow.document.documentElement, {
|
||||
|
200
www/package-lock.json
generated
200
www/package-lock.json
generated
@ -23,7 +23,7 @@
|
||||
"gatsby-transformer-remark": "^2.3.8",
|
||||
"glamor": "^2.20.40",
|
||||
"gzip-size": "^5.0.0",
|
||||
"html2canvas": "^1.0.0-alpha.12",
|
||||
"html2canvas": "file:../",
|
||||
"mkdirp": "^0.5.1",
|
||||
"prismjs": "^1.16.0",
|
||||
"react": "^16.8.6",
|
||||
@ -34,6 +34,88 @@
|
||||
"typography-theme-github": "^0.16.19"
|
||||
}
|
||||
},
|
||||
"..": {
|
||||
"version": "1.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"css-line-break": "1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.4.3",
|
||||
"@babel/core": "^7.4.3",
|
||||
"@babel/preset-env": "^7.4.3",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"@rollup/plugin-commonjs": "^19.0.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^13.0.0",
|
||||
"@rollup/plugin-typescript": "^8.2.1",
|
||||
"@types/chai": "^4.1.7",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/glob": "^7.1.1",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/karma": "^6.3.0",
|
||||
"@types/mocha": "^8.2.3",
|
||||
"@types/node": "^16.3.1",
|
||||
"@types/platform": "^1.3.4",
|
||||
"@types/promise-polyfill": "^6.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
||||
"@typescript-eslint/parser": "^4.28.2",
|
||||
"appium-ios-simulator": "^3.10.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-loader": "^8.0.5",
|
||||
"babel-plugin-add-module-exports": "^1.0.2",
|
||||
"babel-plugin-dev-expression": "^0.2.1",
|
||||
"base64-arraybuffer": "0.2.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"chai": "4.1.1",
|
||||
"chromeless": "^1.5.2",
|
||||
"cors": "^2.8.5",
|
||||
"es6-promise": "^4.2.8",
|
||||
"eslint": "^7.30.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "3.4.0",
|
||||
"express": "^4.17.1",
|
||||
"filenamify-url": "1.0.0",
|
||||
"glob": "7.1.3",
|
||||
"html2canvas-proxy": "1.0.1",
|
||||
"jest": "^27.0.6",
|
||||
"jquery": "^3.5.1",
|
||||
"js-polyfills": "^0.1.42",
|
||||
"karma": "^6.3.2",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-edge-launcher": "^0.4.2",
|
||||
"karma-firefox-launcher": "^2.1.0",
|
||||
"karma-ie-launcher": "^1.0.0",
|
||||
"karma-junit-reporter": "^2.0.1",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-safarinative-launcher": "^1.1.0",
|
||||
"karma-sauce-launcher": "^2.0.2",
|
||||
"mocha": "^9.0.2",
|
||||
"node-simctl": "^5.3.0",
|
||||
"platform": "^1.3.6",
|
||||
"prettier": "^2.3.2",
|
||||
"replace-in-file": "^3.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.53.1",
|
||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||
"serve-index": "^1.9.1",
|
||||
"slash": "1.0.0",
|
||||
"standard-version": "^8.0.2",
|
||||
"ts-jest": "^27.0.3",
|
||||
"ts-loader": "^8.3.0",
|
||||
"ts-node": "^10.1.0",
|
||||
"tslib": "^2.3.0",
|
||||
"typescript": "^4.3.5",
|
||||
"uglify-js": "^3.13.10",
|
||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||
"webpack": "^4.46.0",
|
||||
"webpack-cli": "^3.3.12",
|
||||
"yargs": "^17.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@ardatan/aggregate-error": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@ardatan/aggregate-error/-/aggregate-error-0.0.6.tgz",
|
||||
@ -3692,14 +3774,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/base64-arraybuffer": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
|
||||
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=",
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
@ -5512,14 +5586,6 @@
|
||||
"isobject": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/css-line-break": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-1.0.1.tgz",
|
||||
"integrity": "sha1-GfIGOjPpX7KDG4ZEbAuAwYivRQo=",
|
||||
"dependencies": {
|
||||
"base64-arraybuffer": "^0.1.5"
|
||||
}
|
||||
},
|
||||
"node_modules/css-loader": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-1.0.1.tgz",
|
||||
@ -12365,15 +12431,8 @@
|
||||
"integrity": "sha512-SaGhCDPXJVNrQyKMtKy24q6IMdXg5FCPN3z+xizxw9l+oXQw5fOoaj/ERU5KqWhSYhXtW5bWthlDbTDLBhJQrA=="
|
||||
},
|
||||
"node_modules/html2canvas": {
|
||||
"version": "1.0.0-alpha.12",
|
||||
"resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.0.0-alpha.12.tgz",
|
||||
"integrity": "sha1-OxmS48mz9WBjw1/WIElPN+uohRM=",
|
||||
"dependencies": {
|
||||
"css-line-break": "1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
"resolved": "..",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/htmlparser2": {
|
||||
"version": "3.10.1",
|
||||
@ -26395,11 +26454,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"base64-arraybuffer": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
|
||||
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg="
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
@ -27888,14 +27942,6 @@
|
||||
"isobject": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"css-line-break": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-1.0.1.tgz",
|
||||
"integrity": "sha1-GfIGOjPpX7KDG4ZEbAuAwYivRQo=",
|
||||
"requires": {
|
||||
"base64-arraybuffer": "^0.1.5"
|
||||
}
|
||||
},
|
||||
"css-loader": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-1.0.1.tgz",
|
||||
@ -33223,11 +33269,79 @@
|
||||
"integrity": "sha512-SaGhCDPXJVNrQyKMtKy24q6IMdXg5FCPN3z+xizxw9l+oXQw5fOoaj/ERU5KqWhSYhXtW5bWthlDbTDLBhJQrA=="
|
||||
},
|
||||
"html2canvas": {
|
||||
"version": "1.0.0-alpha.12",
|
||||
"resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.0.0-alpha.12.tgz",
|
||||
"integrity": "sha1-OxmS48mz9WBjw1/WIElPN+uohRM=",
|
||||
"version": "file:..",
|
||||
"requires": {
|
||||
"css-line-break": "1.0.1"
|
||||
"@babel/cli": "^7.4.3",
|
||||
"@babel/core": "^7.4.3",
|
||||
"@babel/preset-env": "^7.4.3",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"@rollup/plugin-commonjs": "^19.0.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^13.0.0",
|
||||
"@rollup/plugin-typescript": "^8.2.1",
|
||||
"@types/chai": "^4.1.7",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/glob": "^7.1.1",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/karma": "^6.3.0",
|
||||
"@types/mocha": "^8.2.3",
|
||||
"@types/node": "^16.3.1",
|
||||
"@types/platform": "^1.3.4",
|
||||
"@types/promise-polyfill": "^6.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
||||
"@typescript-eslint/parser": "^4.28.2",
|
||||
"appium-ios-simulator": "^3.10.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-loader": "^8.0.5",
|
||||
"babel-plugin-add-module-exports": "^1.0.2",
|
||||
"babel-plugin-dev-expression": "^0.2.1",
|
||||
"base64-arraybuffer": "0.2.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"chai": "4.1.1",
|
||||
"chromeless": "^1.5.2",
|
||||
"cors": "^2.8.5",
|
||||
"css-line-break": "1.1.1",
|
||||
"es6-promise": "^4.2.8",
|
||||
"eslint": "^7.30.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "3.4.0",
|
||||
"express": "^4.17.1",
|
||||
"filenamify-url": "1.0.0",
|
||||
"glob": "7.1.3",
|
||||
"html2canvas-proxy": "1.0.1",
|
||||
"jest": "^27.0.6",
|
||||
"jquery": "^3.5.1",
|
||||
"js-polyfills": "^0.1.42",
|
||||
"karma": "^6.3.2",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-edge-launcher": "^0.4.2",
|
||||
"karma-firefox-launcher": "^2.1.0",
|
||||
"karma-ie-launcher": "^1.0.0",
|
||||
"karma-junit-reporter": "^2.0.1",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-safarinative-launcher": "^1.1.0",
|
||||
"karma-sauce-launcher": "^2.0.2",
|
||||
"mocha": "^9.0.2",
|
||||
"node-simctl": "^5.3.0",
|
||||
"platform": "^1.3.6",
|
||||
"prettier": "^2.3.2",
|
||||
"replace-in-file": "^3.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.53.1",
|
||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||
"serve-index": "^1.9.1",
|
||||
"slash": "1.0.0",
|
||||
"standard-version": "^8.0.2",
|
||||
"ts-jest": "^27.0.3",
|
||||
"ts-loader": "^8.3.0",
|
||||
"ts-node": "^10.1.0",
|
||||
"tslib": "^2.3.0",
|
||||
"typescript": "^4.3.5",
|
||||
"uglify-js": "^3.13.10",
|
||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||
"webpack": "^4.46.0",
|
||||
"webpack-cli": "^3.3.12",
|
||||
"yargs": "^17.0.1"
|
||||
}
|
||||
},
|
||||
"htmlparser2": {
|
||||
|
@ -19,7 +19,7 @@
|
||||
"gatsby-transformer-remark": "^2.3.8",
|
||||
"glamor": "^2.20.40",
|
||||
"gzip-size": "^5.0.0",
|
||||
"html2canvas": "^1.0.0-alpha.12",
|
||||
"html2canvas": "file:../",
|
||||
"mkdirp": "^0.5.1",
|
||||
"prismjs": "^1.16.0",
|
||||
"react": "^16.8.6",
|
||||
|
Reference in New Issue
Block a user