From d9222075daaed08884491b0563fc899ee0ced731 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Wed, 29 Dec 2021 21:02:16 +0800 Subject: [PATCH 01/15] ci: add ios 15.0 testing (#2780) --- .github/workflows/ci.yml | 4 ++++ karma.conf.js | 8 +++++++- www/.gitignore | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86aa839..dac4e3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,6 +113,10 @@ jobs: name: iOS Simulator Safari 14 targetBrowser: Safari_IOS_14 xcode: /Applications/Xcode_12.4.app + - os: macos-11 + name: iOS Simulator Safari 15.0 + targetBrowser: Safari_IOS_15_0 + xcode: /Applications/Xcode_13.0.app - os: macos-11 name: iOS Simulator Safari 15 targetBrowser: Safari_IOS_15 diff --git a/karma.conf.js b/karma.conf.js index f1fd674..526deac 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -42,9 +42,15 @@ module.exports = function(config) { platform: 'iOS', sdk: '14.4' }, + Safari_IOS_15_0: { + base: 'MobileSafari', + name: 'iPhone 13', + platform: 'iOS', + sdk: '15.0' + }, Safari_IOS_15: { base: 'MobileSafari', - name: 'iPhone 8', + name: 'iPhone 13', platform: 'iOS', sdk: '15.2' }, diff --git a/www/.gitignore b/www/.gitignore index e78c007..fe89f87 100644 --- a/www/.gitignore +++ b/www/.gitignore @@ -9,3 +9,5 @@ yarn-error.log src/results.json static/tests/preview.js src/preview.js +.docusaurus +build/ From ba2b1cd8e9a9d7932675d7abffce1526a609e769 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Wed, 29 Dec 2021 22:09:32 +0800 Subject: [PATCH 02/15] fix: ios 15 font rendering crash (#2645) --- src/render/canvas/canvas-renderer.ts | 11 ++++++++++- tests/reftests/text/lang/chinese.html | 9 +++++++++ tests/reftests/text/text.html | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/render/canvas/canvas-renderer.ts b/src/render/canvas/canvas-renderer.ts index 48e7315..077ddd0 100644 --- a/src/render/canvas/canvas-renderer.ts +++ b/src/render/canvas/canvas-renderer.ts @@ -162,7 +162,7 @@ export class CanvasRenderer extends Renderer { const fontVariant = styles.fontVariant .filter((variant) => variant === 'normal' || variant === 'small-caps') .join(''); - const fontFamily = styles.fontFamily.join(', '); + const fontFamily = fixIOSSystemFonts(styles.fontFamily).join(', '); const fontSize = isDimensionToken(styles.fontSize) ? `${styles.fontSize.number}${styles.fontSize.unit}` : `${styles.fontSize.number}px`; @@ -947,3 +947,12 @@ const canvasTextAlign = (textAlign: TEXT_ALIGN): CanvasTextAlign => { return 'left'; } }; + +// see https://github.com/niklasvh/html2canvas/pull/2645 +const iOSBrokenFonts = ['-apple-system', 'system-ui']; + +const fixIOSSystemFonts = (fontFamilies: string[]): string[] => { + return /iPhone OS 15_(0|1)/.test(window.navigator.userAgent) + ? fontFamilies.filter((fontFamily) => iOSBrokenFonts.indexOf(fontFamily) === -1) + : fontFamilies; +}; diff --git a/tests/reftests/text/lang/chinese.html b/tests/reftests/text/lang/chinese.html index da5c696..9aed4d2 100644 --- a/tests/reftests/text/lang/chinese.html +++ b/tests/reftests/text/lang/chinese.html @@ -11,6 +11,13 @@ float: left; } + .apple-system { + font-family: -apple-system, Arial; + } + + .system-ui { + font-family: system-ui, Arial; + } @@ -32,5 +39,7 @@

    〔13〕 法捷耶夫(一九○一——一九五六),苏联名作家。他所作的小说《毁灭》于一九二七年出版,内容是描写苏联国内战争时期由苏联远东滨海边区工人、农民和革命知识分子所组成的一支游击队同国内反革命白卫军以及日本武装干涉军进行斗争的故事。这部小说曾由鲁迅译为汉文。

    〔14〕 见鲁迅《集外集·自嘲》(《鲁迅全集》第7卷,人民文学出版社1981年版,第147页)。

+
中文
+
中文
diff --git a/tests/reftests/text/text.html b/tests/reftests/text/text.html index ae1f46f..66e4021 100644 --- a/tests/reftests/text/text.html +++ b/tests/reftests/text/text.html @@ -149,6 +149,6 @@ [AB / CD]
Emojis 🤷🏾‍♂️👨‍👩‍👧‍👦 :)
-
Emojis with letter-spacing 🤷🏾‍♂️👨‍👩‍👧‍👦 :)
+
Emojis with letter-spacing 🤷🏾‍♂️👨‍👩‍👧‍👦 :) ❤️❤️❤️👨‍❤️‍💋‍👨👨‍❤️‍👨
From 04787ee88a1a380a57de21fff67d64702571f9c6 Mon Sep 17 00:00:00 2001 From: CI Date: Wed, 29 Dec 2021 14:11:55 +0000 Subject: [PATCH 03/15] chore(release): 1.3.4 --- CHANGELOG.md | 13 +++++++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d83c47..fd0e1e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ 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.3.4](https://github.com/niklasvh/html2canvas/compare/v1.3.3...v1.3.4) (2021-12-29) + + +### ci + +* add ios 15.0 testing (#2780) ([d922207](https://github.com/niklasvh/html2canvas/commit/d9222075daaed08884491b0563fc899ee0ced731)), closes [#2780](https://github.com/niklasvh/html2canvas/issues/2780) + +### fix + +* ios 15 font rendering crash (#2645) ([ba2b1cd](https://github.com/niklasvh/html2canvas/commit/ba2b1cd8e9a9d7932675d7abffce1526a609e769)), closes [#2645](https://github.com/niklasvh/html2canvas/issues/2645) + + + ## [1.3.3](https://github.com/niklasvh/html2canvas/compare/v1.3.2...v1.3.3) (2021-11-23) diff --git a/package-lock.json b/package-lock.json index 8448519..e296899 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "html2canvas", - "version": "1.3.3", + "version": "1.3.4", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index d540cca..f2fd973 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "module": "dist/html2canvas.esm.js", "typings": "dist/types/index.d.ts", "browser": "dist/html2canvas.js", - "version": "1.3.3", + "version": "1.3.4", "author": { "name": "Niklas von Hertzen", "email": "niklasvh@gmail.com", From 1cc853a3186853eaca00af060f651697dc3497a9 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Fri, 31 Dec 2021 15:30:18 +0800 Subject: [PATCH 04/15] fix: reduce SLICE_STACK_SIZE to 50k (#2784) --- src/css/syntax/tokenizer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css/syntax/tokenizer.ts b/src/css/syntax/tokenizer.ts index e050847..11bbb03 100644 --- a/src/css/syntax/tokenizer.ts +++ b/src/css/syntax/tokenizer.ts @@ -657,7 +657,7 @@ export class Tokenizer { } private consumeStringSlice(count: number): string { - const SLICE_STACK_SIZE = 60000; + const SLICE_STACK_SIZE = 50000; let value = ''; while (count > 0) { const amount = Math.min(SLICE_STACK_SIZE, count); From 74696faf47c07b48b9c9587db0b999da1c08a8be Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sat, 1 Jan 2022 01:57:17 +0800 Subject: [PATCH 05/15] fix: adopted stylesheets (#2785) --- src/dom/document-cloner.ts | 59 +++++++++++++++---- src/dom/node-parser.ts | 2 + .../autonomous-custom-element.js | 4 ++ .../reftests/webcomponents/webcomponents.html | 7 ++- 4 files changed, 57 insertions(+), 15 deletions(-) diff --git a/src/dom/document-cloner.ts b/src/dom/document-cloner.ts index 796e557..d2fd930 100644 --- a/src/dom/document-cloner.ts +++ b/src/dom/document-cloner.ts @@ -2,12 +2,14 @@ import {Bounds} from '../css/layout/bounds'; import { isBodyElement, isCanvasElement, + isCustomElement, isElementNode, isHTMLElementNode, isIFrameElement, isImageElement, isScriptElement, isSelectElement, + isSlotElement, isStyleElement, isSVGElementNode, isTextareaElement, @@ -63,7 +65,7 @@ export class DocumentCloner { throw new Error('Cloned element does not have an owner document'); } - this.documentElement = this.cloneNode(element.ownerDocument.documentElement) as HTMLElement; + this.documentElement = this.cloneNode(element.ownerDocument.documentElement, false) as HTMLElement; } toIFrame(ownerDocument: Document, windowSize: Bounds): Promise { @@ -160,6 +162,17 @@ export class DocumentCloner { } } + if (isCustomElement(clone)) { + return this.createCustomElementClone(clone); + } + + return clone; + } + + createCustomElementClone(node: HTMLElement): HTMLElement { + const clone = document.createElement('html2canvascustomelement'); + copyCSSStyles(node.style, clone); + return clone; } @@ -231,7 +244,20 @@ export class DocumentCloner { return clonedCanvas; } - cloneNode(node: Node): Node { + appendChildNode(clone: HTMLElement | SVGElement, child: Node, copyStyles: boolean): void { + if ( + !isElementNode(child) || + (!isScriptElement(child) && + !child.hasAttribute(IGNORE_ATTRIBUTE) && + (typeof this.options.ignoreElements !== 'function' || !this.options.ignoreElements(child))) + ) { + if (!this.options.copyStyles || !isElementNode(child) || !isStyleElement(child)) { + clone.appendChild(this.cloneNode(child, copyStyles)); + } + } + } + + cloneNode(node: Node, copyStyles: boolean): Node { if (isTextNode(node)) { return document.createTextNode(node.data); } @@ -260,16 +286,22 @@ export class DocumentCloner { const counters = this.counters.parse(new CSSParsedCounterDeclaration(this.context, style)); const before = this.resolvePseudoContent(node, clone, styleBefore, PseudoElementType.BEFORE); - for (let child = node.firstChild; child; child = child.nextSibling) { - if ( - !isElementNode(child) || - (!isScriptElement(child) && - !child.hasAttribute(IGNORE_ATTRIBUTE) && - (typeof this.options.ignoreElements !== 'function' || !this.options.ignoreElements(child))) - ) { - if (!this.options.copyStyles || !isElementNode(child) || !isStyleElement(child)) { - clone.appendChild(this.cloneNode(child)); + if (isCustomElement(node)) { + copyStyles = true; + } + + for ( + let child = node.shadowRoot ? node.shadowRoot.firstChild : node.firstChild; + child; + child = child.nextSibling + ) { + if (isElementNode(child) && isSlotElement(child) && typeof child.assignedNodes === 'function') { + const assignedNodes = child.assignedNodes() as ChildNode[]; + if (assignedNodes.length) { + assignedNodes.forEach((assignedNode) => this.appendChildNode(clone, assignedNode, copyStyles)); } + } else { + this.appendChildNode(clone, child, copyStyles); } } @@ -284,7 +316,10 @@ export class DocumentCloner { this.counters.pop(counters); - if (style && (this.options.copyStyles || isSVGElementNode(node)) && !isIFrameElement(node)) { + if ( + (style && (this.options.copyStyles || isSVGElementNode(node)) && !isIFrameElement(node)) || + copyStyles + ) { copyCSSStyles(style, clone); } diff --git a/src/dom/node-parser.ts b/src/dom/node-parser.ts index 260974e..0bae313 100644 --- a/src/dom/node-parser.ts +++ b/src/dom/node-parser.ts @@ -131,3 +131,5 @@ export const isScriptElement = (node: Element): node is HTMLScriptElement => nod export const isTextareaElement = (node: Element): node is HTMLTextAreaElement => node.tagName === 'TEXTAREA'; export const isSelectElement = (node: Element): node is HTMLSelectElement => node.tagName === 'SELECT'; export const isSlotElement = (node: Element): node is HTMLSlotElement => node.tagName === 'SLOT'; +// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name +export const isCustomElement = (node: Element): node is HTMLElement => node.tagName.indexOf('-') > 0; diff --git a/tests/reftests/webcomponents/autonomous-custom-element.js b/tests/reftests/webcomponents/autonomous-custom-element.js index 659cb56..80608f9 100644 --- a/tests/reftests/webcomponents/autonomous-custom-element.js +++ b/tests/reftests/webcomponents/autonomous-custom-element.js @@ -40,6 +40,10 @@ class AutonomousCustomElement extends HTMLElement { wrapper.appendChild(img); wrapper.appendChild(info); } + + connectedCallback() { + this.shadowRoot.adoptedStyleSheets = [sheet]; + } } customElements.define('autonomous-custom-element', AutonomousCustomElement); diff --git a/tests/reftests/webcomponents/webcomponents.html b/tests/reftests/webcomponents/webcomponents.html index cfa59f1..c4245f5 100644 --- a/tests/reftests/webcomponents/webcomponents.html +++ b/tests/reftests/webcomponents/webcomponents.html @@ -3,10 +3,11 @@ Web components tests + -
From 0476d065158c33d2020a9f602b3043e5e2f90c75 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sat, 1 Jan 2022 13:07:52 +0800 Subject: [PATCH 06/15] fix: ios text wrapping with 0 width rect (#2786) --- src/css/layout/bounds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css/layout/bounds.ts b/src/css/layout/bounds.ts index 43d1bea..2f1c150 100644 --- a/src/css/layout/bounds.ts +++ b/src/css/layout/bounds.ts @@ -17,7 +17,7 @@ export class Bounds { } static fromDOMRectList(context: Context, domRectList: DOMRectList): Bounds { - const domRect = domRectList[0]; + const domRect = Array.from(domRectList).find(rect => rect.width !== 0); return domRect ? new Bounds( domRect.x + context.windowBounds.left, From 6521a487d78172f7179f7c973c1a3af40eb92009 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sat, 1 Jan 2022 21:22:31 +0800 Subject: [PATCH 07/15] feat: use native text segmenter where available (#2782) --- src/core/features.ts | 7 ++++ src/css/layout/bounds.ts | 2 +- src/css/layout/text.ts | 51 ++++++++++++++++++++++------ src/render/canvas/canvas-renderer.ts | 9 +++-- 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/core/features.ts b/src/core/features.ts index 78514bd..64e8aea 100644 --- a/src/core/features.ts +++ b/src/core/features.ts @@ -211,5 +211,12 @@ export const FEATURES = { const value = 'withCredentials' in new XMLHttpRequest(); Object.defineProperty(FEATURES, 'SUPPORT_CORS_XHR', {value}); return value; + }, + get SUPPORT_NATIVE_TEXT_SEGMENTATION(): boolean { + 'use strict'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const value = !!(typeof Intl !== 'undefined' && (Intl as any).Segmenter); + Object.defineProperty(FEATURES, 'SUPPORT_NATIVE_TEXT_SEGMENTATION', {value}); + return value; } }; diff --git a/src/css/layout/bounds.ts b/src/css/layout/bounds.ts index 2f1c150..59da655 100644 --- a/src/css/layout/bounds.ts +++ b/src/css/layout/bounds.ts @@ -17,7 +17,7 @@ export class Bounds { } static fromDOMRectList(context: Context, domRectList: DOMRectList): Bounds { - const domRect = Array.from(domRectList).find(rect => rect.width !== 0); + const domRect = Array.from(domRectList).find((rect) => rect.width !== 0); return domRect ? new Bounds( domRect.x + context.windowBounds.left, diff --git a/src/css/layout/text.ts b/src/css/layout/text.ts index 59f0bde..0c68019 100644 --- a/src/css/layout/text.ts +++ b/src/css/layout/text.ts @@ -28,15 +28,24 @@ export const parseTextBounds = ( textList.forEach((text) => { if (styles.textDecorationLine.length || text.trim().length > 0) { if (FEATURES.SUPPORT_RANGE_BOUNDS) { - if (!FEATURES.SUPPORT_WORD_BREAKING) { - textBounds.push( - new TextBounds( - text, - Bounds.fromDOMRectList(context, createRange(node, offset, text.length).getClientRects()) - ) - ); + const clientRects = createRange(node, offset, text.length).getClientRects(); + if (clientRects.length > 1) { + const subSegments = segmentGraphemes(text); + let subOffset = 0; + subSegments.forEach((subSegment) => { + textBounds.push( + new TextBounds( + subSegment, + Bounds.fromDOMRectList( + context, + createRange(node, subOffset + offset, subSegment.length).getClientRects() + ) + ) + ); + subOffset += subSegment.length; + }); } else { - textBounds.push(new TextBounds(text, getRangeBounds(context, node, offset, text.length))); + textBounds.push(new TextBounds(text, Bounds.fromDOMRectList(context, clientRects))); } } else { const replacementNode = node.splitText(text.length); @@ -82,12 +91,32 @@ const createRange = (node: Text, offset: number, length: number): Range => { return range; }; -const getRangeBounds = (context: Context, node: Text, offset: number, length: number): Bounds => { - return Bounds.fromClientRect(context, createRange(node, offset, length).getBoundingClientRect()); +export const segmentGraphemes = (value: string): string[] => { + if (FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const segmenter = new (Intl as any).Segmenter(void 0, {granularity: 'grapheme'}); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return Array.from(segmenter.segment(value)).map((segment: any) => segment.segment); + } + + return splitGraphemes(value); +}; + +const segmentWords = (value: string, styles: CSSParsedDeclaration): string[] => { + if (FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const segmenter = new (Intl as any).Segmenter(void 0, { + granularity: 'word' + }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return Array.from(segmenter.segment(value)).map((segment: any) => segment.segment); + } + + return breakWords(value, styles); }; const breakText = (value: string, styles: CSSParsedDeclaration): string[] => { - return styles.letterSpacing !== 0 ? splitGraphemes(value) : breakWords(value, styles); + return styles.letterSpacing !== 0 ? segmentGraphemes(value) : segmentWords(value, styles); }; // https://drafts.csswg.org/css-text/#word-separator diff --git a/src/render/canvas/canvas-renderer.ts b/src/render/canvas/canvas-renderer.ts index 077ddd0..6efb648 100644 --- a/src/render/canvas/canvas-renderer.ts +++ b/src/render/canvas/canvas-renderer.ts @@ -2,7 +2,7 @@ import {ElementPaint, parseStackingContexts, StackingContext} from '../stacking- import {asString, Color, isTransparent} from '../../css/types/color'; import {ElementContainer, FLAGS} from '../../dom/element-container'; import {BORDER_STYLE} from '../../css/property-descriptors/border-style'; -import {CSSParsedDeclaration} from '../../css/index'; +import {CSSParsedDeclaration} from '../../css'; import {TextContainer} from '../../dom/text-container'; import {Path, transformPath} from '../path'; import {BACKGROUND_CLIP} from '../../css/property-descriptors/background-clip'; @@ -18,12 +18,12 @@ import { } from '../border'; import {calculateBackgroundRendering, getBackgroundValueForIndex} from '../background'; import {isDimensionToken} from '../../css/syntax/parser'; -import {TextBounds} from '../../css/layout/text'; +import {segmentGraphemes, TextBounds} from '../../css/layout/text'; import {ImageElementContainer} from '../../dom/replaced-elements/image-element-container'; import {contentBox} from '../box-sizing'; import {CanvasElementContainer} from '../../dom/replaced-elements/canvas-element-container'; import {SVGElementContainer} from '../../dom/replaced-elements/svg-element-container'; -import {ReplacedElementContainer} from '../../dom/replaced-elements/index'; +import {ReplacedElementContainer} from '../../dom/replaced-elements'; import {EffectTarget, IElementEffect, isClipEffect, isOpacityEffect, isTransformEffect} from '../effects'; import {contains} from '../../core/bitwise'; import {calculateGradientDirection, calculateRadius, processColorStops} from '../../css/types/functions/gradient'; @@ -44,7 +44,6 @@ import {PAINT_ORDER_LAYER} from '../../css/property-descriptors/paint-order'; import {Renderer} from '../renderer'; import {Context} from '../../core/context'; import {DIRECTION} from '../../css/property-descriptors/direction'; -import {splitGraphemes} from 'text-segmentation'; export type RenderConfigurations = RenderOptions & { backgroundColor: Color | null; @@ -149,7 +148,7 @@ export class CanvasRenderer extends Renderer { if (letterSpacing === 0) { this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline); } else { - const letters = splitGraphemes(text.text); + const letters = segmentGraphemes(text.text); letters.reduce((left, letter) => { this.ctx.fillText(letter, left, text.bounds.top + baseline); From 9fda3e1ede55639bfafd0657d6ead72f68f32395 Mon Sep 17 00:00:00 2001 From: CI Date: Sat, 1 Jan 2022 15:08:48 +0000 Subject: [PATCH 08/15] chore(release): 1.4.0 --- CHANGELOG.md | 15 +++++++++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd0e1e5..b15c3a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ 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.4.0](https://github.com/niklasvh/html2canvas/compare/v1.3.4...v1.4.0) (2022-01-01) + + +### feat + +* use native text segmenter where available (#2782) ([6521a48](https://github.com/niklasvh/html2canvas/commit/6521a487d78172f7179f7c973c1a3af40eb92009)), closes [#2782](https://github.com/niklasvh/html2canvas/issues/2782) + +### fix + +* adopted stylesheets (#2785) ([74696fa](https://github.com/niklasvh/html2canvas/commit/74696faf47c07b48b9c9587db0b999da1c08a8be)), closes [#2785](https://github.com/niklasvh/html2canvas/issues/2785) +* ios text wrapping with 0 width rect (#2786) ([0476d06](https://github.com/niklasvh/html2canvas/commit/0476d065158c33d2020a9f602b3043e5e2f90c75)), closes [#2786](https://github.com/niklasvh/html2canvas/issues/2786) +* reduce SLICE_STACK_SIZE to 50k (#2784) ([1cc853a](https://github.com/niklasvh/html2canvas/commit/1cc853a3186853eaca00af060f651697dc3497a9)), closes [#2784](https://github.com/niklasvh/html2canvas/issues/2784) + + + ## [1.3.4](https://github.com/niklasvh/html2canvas/compare/v1.3.3...v1.3.4) (2021-12-29) diff --git a/package-lock.json b/package-lock.json index e296899..ab3a5e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "html2canvas", - "version": "1.3.4", + "version": "1.4.0", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index f2fd973..09fea9d 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "module": "dist/html2canvas.esm.js", "typings": "dist/types/index.d.ts", "browser": "dist/html2canvas.js", - "version": "1.3.4", + "version": "1.4.0", "author": { "name": "Niklas von Hertzen", "email": "niklasvh@gmail.com", From 46db86755f064828559a4b0b37310f3ae94f5494 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sun, 2 Jan 2022 16:08:10 +0800 Subject: [PATCH 09/15] fix: source maps (#2787) --- rollup.config.ts | 2 +- tests/server.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rollup.config.ts b/rollup.config.ts index 1f85df4..13bf9a6 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -30,7 +30,7 @@ export default { // Allow json resolution json(), // Compile TypeScript files - typescript(), + typescript({ sourceMap: true, inlineSources: true }), // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs) commonjs({ include: 'node_modules/**' diff --git a/tests/server.ts b/tests/server.ts index b9f6ca6..7ed90e3 100644 --- a/tests/server.ts +++ b/tests/server.ts @@ -12,7 +12,7 @@ const mkdirp = require('mkdirp'); export const app = express(); app.use('/', serveIndex(path.resolve(__dirname, '../'), {icons: true})); -app.use('/', express.static(path.resolve(__dirname, '../'))); +app.use([/^\/src($|\/)/, '/'], express.static(path.resolve(__dirname, '../'))); export const corsApp = express(); corsApp.use('/proxy', proxy()); From 181d1b1103910d6e1b5277d5c007fc5e3006c6bf Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sun, 2 Jan 2022 16:14:27 +0800 Subject: [PATCH 10/15] feat: add support for