This commit is contained in:
魏啾
2024-04-30 18:07:59 +08:00
parent b72c4d7af1
commit 56863dd624
1369 changed files with 156460 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentCloner = void 0;
var DocumentCloner = /** @class */ (function () {
function DocumentCloner() {
this.clonedReferenceElement = {
ownerDocument: {
defaultView: {
pageXOffset: 12,
pageYOffset: 34
}
}
};
}
DocumentCloner.prototype.toIFrame = function () {
return Promise.resolve({});
};
DocumentCloner.destroy = function () {
return true;
};
return DocumentCloner;
}());
exports.DocumentCloner = DocumentCloner;
//# sourceMappingURL=document-cloner.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"document-cloner.js","sourceRoot":"","sources":["../../../../src/dom/__mocks__/document-cloner.ts"],"names":[],"mappings":";;;AAAA;IAGI;QACI,IAAI,CAAC,sBAAsB,GAAG;YAC1B,aAAa,EAAE;gBACX,WAAW,EAAE;oBACT,WAAW,EAAE,EAAE;oBACf,WAAW,EAAE,EAAE;iBAClB;aACJ;SACW,CAAC;IACrB,CAAC;IAED,iCAAQ,GAAR;QACI,OAAO,OAAO,CAAC,OAAO,CAAC,EAAuB,CAAC,CAAC;IACpD,CAAC;IAEM,sBAAO,GAAd;QACI,OAAO,IAAI,CAAC;IAChB,CAAC;IACL,qBAAC;AAAD,CAAC,AArBD,IAqBC;AArBY,wCAAc"}

View File

@@ -0,0 +1,530 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.copyCSSStyles = exports.DocumentCloner = void 0;
var node_parser_1 = require("./node-parser");
var parser_1 = require("../css/syntax/parser");
var counter_1 = require("../css/types/functions/counter");
var list_style_type_1 = require("../css/property-descriptors/list-style-type");
var index_1 = require("../css/index");
var quotes_1 = require("../css/property-descriptors/quotes");
var debugger_1 = require("../core/debugger");
var IGNORE_ATTRIBUTE = 'data-html2canvas-ignore';
var DocumentCloner = /** @class */ (function () {
function DocumentCloner(context, element, options) {
this.context = context;
this.options = options;
this.scrolledElements = [];
this.referenceElement = element;
this.counters = new counter_1.CounterState();
this.quoteDepth = 0;
if (!element.ownerDocument) {
throw new Error('Cloned element does not have an owner document');
}
this.documentElement = this.cloneNode(element.ownerDocument.documentElement, false);
}
DocumentCloner.prototype.toIFrame = function (ownerDocument, windowSize) {
var _this = this;
var iframe = createIFrameContainer(ownerDocument, windowSize);
if (!iframe.contentWindow) {
return Promise.reject("Unable to find iframe window");
}
var scrollX = ownerDocument.defaultView.pageXOffset;
var scrollY = ownerDocument.defaultView.pageYOffset;
var cloneWindow = iframe.contentWindow;
var documentClone = cloneWindow.document;
/* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
if window url is about:blank, we can assign the url to current by writing onto the document
*/
var iframeLoad = iframeLoader(iframe).then(function () { return __awaiter(_this, void 0, void 0, function () {
var onclone, referenceElement;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.scrolledElements.forEach(restoreNodeScroll);
if (cloneWindow) {
cloneWindow.scrollTo(windowSize.left, windowSize.top);
if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent) &&
(cloneWindow.scrollY !== windowSize.top || cloneWindow.scrollX !== windowSize.left)) {
this.context.logger.warn('Unable to restore scroll position for cloned document');
this.context.windowBounds = this.context.windowBounds.add(cloneWindow.scrollX - windowSize.left, cloneWindow.scrollY - windowSize.top, 0, 0);
}
}
onclone = this.options.onclone;
referenceElement = this.clonedReferenceElement;
if (typeof referenceElement === 'undefined') {
return [2 /*return*/, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")];
}
if (!(documentClone.fonts && documentClone.fonts.ready)) return [3 /*break*/, 2];
return [4 /*yield*/, documentClone.fonts.ready];
case 1:
_a.sent();
_a.label = 2;
case 2:
if (!/(AppleWebKit)/g.test(navigator.userAgent)) return [3 /*break*/, 4];
return [4 /*yield*/, imagesReady(documentClone)];
case 3:
_a.sent();
_a.label = 4;
case 4:
if (typeof onclone === 'function') {
return [2 /*return*/, Promise.resolve()
.then(function () { return onclone(documentClone, referenceElement); })
.then(function () { return iframe; })];
}
return [2 /*return*/, iframe];
}
});
}); });
documentClone.open();
documentClone.write(serializeDoctype(document.doctype) + "<html></html>");
// Chrome scrolls the parent document for some reason after the write to the cloned window???
restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
documentClone.close();
return iframeLoad;
};
DocumentCloner.prototype.createElementClone = function (node) {
if (debugger_1.isDebugging(node, 2 /* CLONE */)) {
debugger;
}
if (node_parser_1.isCanvasElement(node)) {
return this.createCanvasClone(node);
}
if (node_parser_1.isVideoElement(node)) {
return this.createVideoClone(node);
}
if (node_parser_1.isStyleElement(node)) {
return this.createStyleClone(node);
}
var clone = node.cloneNode(false);
if (node_parser_1.isImageElement(clone)) {
if (node_parser_1.isImageElement(node) && node.currentSrc && node.currentSrc !== node.src) {
clone.src = node.currentSrc;
clone.srcset = '';
}
if (clone.loading === 'lazy') {
clone.loading = 'eager';
}
}
if (node_parser_1.isCustomElement(clone)) {
return this.createCustomElementClone(clone);
}
return clone;
};
DocumentCloner.prototype.createCustomElementClone = function (node) {
var clone = document.createElement('html2canvascustomelement');
exports.copyCSSStyles(node.style, clone);
return clone;
};
DocumentCloner.prototype.createStyleClone = function (node) {
try {
var sheet = node.sheet;
if (sheet && sheet.cssRules) {
var css = [].slice.call(sheet.cssRules, 0).reduce(function (css, rule) {
if (rule && typeof rule.cssText === 'string') {
return css + rule.cssText;
}
return css;
}, '');
var style = node.cloneNode(false);
style.textContent = css;
return style;
}
}
catch (e) {
// accessing node.sheet.cssRules throws a DOMException
this.context.logger.error('Unable to access cssRules property', e);
if (e.name !== 'SecurityError') {
throw e;
}
}
return node.cloneNode(false);
};
DocumentCloner.prototype.createCanvasClone = function (canvas) {
var _a;
if (this.options.inlineImages && canvas.ownerDocument) {
var img = canvas.ownerDocument.createElement('img');
try {
img.src = canvas.toDataURL();
return img;
}
catch (e) {
this.context.logger.info("Unable to inline canvas contents, canvas is tainted", canvas);
}
}
var clonedCanvas = canvas.cloneNode(false);
try {
clonedCanvas.width = canvas.width;
clonedCanvas.height = canvas.height;
var ctx = canvas.getContext('2d');
var clonedCtx = clonedCanvas.getContext('2d');
if (clonedCtx) {
if (!this.options.allowTaint && ctx) {
clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
}
else {
var gl = (_a = canvas.getContext('webgl2')) !== null && _a !== void 0 ? _a : canvas.getContext('webgl');
if (gl) {
var attribs = gl.getContextAttributes();
if ((attribs === null || attribs === void 0 ? void 0 : attribs.preserveDrawingBuffer) === false) {
this.context.logger.warn('Unable to clone WebGL context as it has preserveDrawingBuffer=false', canvas);
}
}
clonedCtx.drawImage(canvas, 0, 0);
}
}
return clonedCanvas;
}
catch (e) {
this.context.logger.info("Unable to clone canvas as it is tainted", canvas);
}
return clonedCanvas;
};
DocumentCloner.prototype.createVideoClone = function (video) {
var canvas = video.ownerDocument.createElement('canvas');
canvas.width = video.offsetWidth;
canvas.height = video.offsetHeight;
var ctx = canvas.getContext('2d');
try {
if (ctx) {
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
if (!this.options.allowTaint) {
ctx.getImageData(0, 0, canvas.width, canvas.height);
}
}
return canvas;
}
catch (e) {
this.context.logger.info("Unable to clone video as it is tainted", video);
}
var blankCanvas = video.ownerDocument.createElement('canvas');
blankCanvas.width = video.offsetWidth;
blankCanvas.height = video.offsetHeight;
return blankCanvas;
};
DocumentCloner.prototype.appendChildNode = function (clone, child, copyStyles) {
if (!node_parser_1.isElementNode(child) ||
(!node_parser_1.isScriptElement(child) &&
!child.hasAttribute(IGNORE_ATTRIBUTE) &&
(typeof this.options.ignoreElements !== 'function' || !this.options.ignoreElements(child)))) {
if (!this.options.copyStyles || !node_parser_1.isElementNode(child) || !node_parser_1.isStyleElement(child)) {
clone.appendChild(this.cloneNode(child, copyStyles));
}
}
};
DocumentCloner.prototype.cloneChildNodes = function (node, clone, copyStyles) {
var _this = this;
for (var child = node.shadowRoot ? node.shadowRoot.firstChild : node.firstChild; child; child = child.nextSibling) {
if (node_parser_1.isElementNode(child) && node_parser_1.isSlotElement(child) && typeof child.assignedNodes === 'function') {
var assignedNodes = child.assignedNodes();
if (assignedNodes.length) {
assignedNodes.forEach(function (assignedNode) { return _this.appendChildNode(clone, assignedNode, copyStyles); });
}
}
else {
this.appendChildNode(clone, child, copyStyles);
}
}
};
DocumentCloner.prototype.cloneNode = function (node, copyStyles) {
if (node_parser_1.isTextNode(node)) {
return document.createTextNode(node.data);
}
if (!node.ownerDocument) {
return node.cloneNode(false);
}
var window = node.ownerDocument.defaultView;
if (window && node_parser_1.isElementNode(node) && (node_parser_1.isHTMLElementNode(node) || node_parser_1.isSVGElementNode(node))) {
var clone = this.createElementClone(node);
clone.style.transitionProperty = 'none';
var style = window.getComputedStyle(node);
var styleBefore = window.getComputedStyle(node, ':before');
var styleAfter = window.getComputedStyle(node, ':after');
if (this.referenceElement === node && node_parser_1.isHTMLElementNode(clone)) {
this.clonedReferenceElement = clone;
}
if (node_parser_1.isBodyElement(clone)) {
createPseudoHideStyles(clone);
}
var counters = this.counters.parse(new index_1.CSSParsedCounterDeclaration(this.context, style));
var before = this.resolvePseudoContent(node, clone, styleBefore, PseudoElementType.BEFORE);
if (node_parser_1.isCustomElement(node)) {
copyStyles = true;
}
if (!node_parser_1.isVideoElement(node)) {
this.cloneChildNodes(node, clone, copyStyles);
}
if (before) {
clone.insertBefore(before, clone.firstChild);
}
var after = this.resolvePseudoContent(node, clone, styleAfter, PseudoElementType.AFTER);
if (after) {
clone.appendChild(after);
}
this.counters.pop(counters);
if ((style && (this.options.copyStyles || node_parser_1.isSVGElementNode(node)) && !node_parser_1.isIFrameElement(node)) ||
copyStyles) {
exports.copyCSSStyles(style, clone);
}
if (node.scrollTop !== 0 || node.scrollLeft !== 0) {
this.scrolledElements.push([clone, node.scrollLeft, node.scrollTop]);
}
if ((node_parser_1.isTextareaElement(node) || node_parser_1.isSelectElement(node)) &&
(node_parser_1.isTextareaElement(clone) || node_parser_1.isSelectElement(clone))) {
clone.value = node.value;
}
return clone;
}
return node.cloneNode(false);
};
DocumentCloner.prototype.resolvePseudoContent = function (node, clone, style, pseudoElt) {
var _this = this;
if (!style) {
return;
}
var value = style.content;
var document = clone.ownerDocument;
if (!document || !value || value === 'none' || value === '-moz-alt-content' || style.display === 'none') {
return;
}
this.counters.parse(new index_1.CSSParsedCounterDeclaration(this.context, style));
var declaration = new index_1.CSSParsedPseudoDeclaration(this.context, style);
var anonymousReplacedElement = document.createElement('html2canvaspseudoelement');
exports.copyCSSStyles(style, anonymousReplacedElement);
declaration.content.forEach(function (token) {
if (token.type === 0 /* STRING_TOKEN */) {
anonymousReplacedElement.appendChild(document.createTextNode(token.value));
}
else if (token.type === 22 /* URL_TOKEN */) {
var img = document.createElement('img');
img.src = token.value;
img.style.opacity = '1';
anonymousReplacedElement.appendChild(img);
}
else if (token.type === 18 /* FUNCTION */) {
if (token.name === 'attr') {
var attr = token.values.filter(parser_1.isIdentToken);
if (attr.length) {
anonymousReplacedElement.appendChild(document.createTextNode(node.getAttribute(attr[0].value) || ''));
}
}
else if (token.name === 'counter') {
var _a = token.values.filter(parser_1.nonFunctionArgSeparator), counter = _a[0], counterStyle = _a[1];
if (counter && parser_1.isIdentToken(counter)) {
var counterState = _this.counters.getCounterValue(counter.value);
var counterType = counterStyle && parser_1.isIdentToken(counterStyle)
? list_style_type_1.listStyleType.parse(_this.context, counterStyle.value)
: 3 /* DECIMAL */;
anonymousReplacedElement.appendChild(document.createTextNode(counter_1.createCounterText(counterState, counterType, false)));
}
}
else if (token.name === 'counters') {
var _b = token.values.filter(parser_1.nonFunctionArgSeparator), counter = _b[0], delim = _b[1], counterStyle = _b[2];
if (counter && parser_1.isIdentToken(counter)) {
var counterStates = _this.counters.getCounterValues(counter.value);
var counterType_1 = counterStyle && parser_1.isIdentToken(counterStyle)
? list_style_type_1.listStyleType.parse(_this.context, counterStyle.value)
: 3 /* DECIMAL */;
var separator = delim && delim.type === 0 /* STRING_TOKEN */ ? delim.value : '';
var text = counterStates
.map(function (value) { return counter_1.createCounterText(value, counterType_1, false); })
.join(separator);
anonymousReplacedElement.appendChild(document.createTextNode(text));
}
}
else {
// console.log('FUNCTION_TOKEN', token);
}
}
else if (token.type === 20 /* IDENT_TOKEN */) {
switch (token.value) {
case 'open-quote':
anonymousReplacedElement.appendChild(document.createTextNode(quotes_1.getQuote(declaration.quotes, _this.quoteDepth++, true)));
break;
case 'close-quote':
anonymousReplacedElement.appendChild(document.createTextNode(quotes_1.getQuote(declaration.quotes, --_this.quoteDepth, false)));
break;
default:
// safari doesn't parse string tokens correctly because of lack of quotes
anonymousReplacedElement.appendChild(document.createTextNode(token.value));
}
}
});
anonymousReplacedElement.className = PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
var newClassName = pseudoElt === PseudoElementType.BEFORE
? " " + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE
: " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
if (node_parser_1.isSVGElementNode(clone)) {
clone.className.baseValue += newClassName;
}
else {
clone.className += newClassName;
}
return anonymousReplacedElement;
};
DocumentCloner.destroy = function (container) {
if (container.parentNode) {
container.parentNode.removeChild(container);
return true;
}
return false;
};
return DocumentCloner;
}());
exports.DocumentCloner = DocumentCloner;
var PseudoElementType;
(function (PseudoElementType) {
PseudoElementType[PseudoElementType["BEFORE"] = 0] = "BEFORE";
PseudoElementType[PseudoElementType["AFTER"] = 1] = "AFTER";
})(PseudoElementType || (PseudoElementType = {}));
var createIFrameContainer = function (ownerDocument, bounds) {
var cloneIframeContainer = ownerDocument.createElement('iframe');
cloneIframeContainer.className = 'html2canvas-container';
cloneIframeContainer.style.visibility = 'hidden';
cloneIframeContainer.style.position = 'fixed';
cloneIframeContainer.style.left = '-10000px';
cloneIframeContainer.style.top = '0px';
cloneIframeContainer.style.border = '0';
cloneIframeContainer.width = bounds.width.toString();
cloneIframeContainer.height = bounds.height.toString();
cloneIframeContainer.scrolling = 'no'; // ios won't scroll without it
cloneIframeContainer.setAttribute(IGNORE_ATTRIBUTE, 'true');
ownerDocument.body.appendChild(cloneIframeContainer);
return cloneIframeContainer;
};
var imageReady = function (img) {
return new Promise(function (resolve) {
if (img.complete) {
resolve();
return;
}
if (!img.src) {
resolve();
return;
}
img.onload = resolve;
img.onerror = resolve;
});
};
var imagesReady = function (document) {
return Promise.all([].slice.call(document.images, 0).map(imageReady));
};
var iframeLoader = function (iframe) {
return new Promise(function (resolve, reject) {
var cloneWindow = iframe.contentWindow;
if (!cloneWindow) {
return reject("No window assigned for iframe");
}
var documentClone = cloneWindow.document;
cloneWindow.onload = iframe.onload = function () {
cloneWindow.onload = iframe.onload = null;
var interval = setInterval(function () {
if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') {
clearInterval(interval);
resolve(iframe);
}
}, 50);
};
});
};
var ignoredStyleProperties = [
'all',
'd',
'content' // Safari shows pseudoelements if content is set
];
var copyCSSStyles = function (style, target) {
// Edge does not provide value for cssText
for (var i = style.length - 1; i >= 0; i--) {
var property = style.item(i);
if (ignoredStyleProperties.indexOf(property) === -1) {
target.style.setProperty(property, style.getPropertyValue(property));
}
}
return target;
};
exports.copyCSSStyles = copyCSSStyles;
var serializeDoctype = function (doctype) {
var str = '';
if (doctype) {
str += '<!DOCTYPE ';
if (doctype.name) {
str += doctype.name;
}
if (doctype.internalSubset) {
str += doctype.internalSubset;
}
if (doctype.publicId) {
str += "\"" + doctype.publicId + "\"";
}
if (doctype.systemId) {
str += "\"" + doctype.systemId + "\"";
}
str += '>';
}
return str;
};
var restoreOwnerScroll = function (ownerDocument, x, y) {
if (ownerDocument &&
ownerDocument.defaultView &&
(x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset)) {
ownerDocument.defaultView.scrollTo(x, y);
}
};
var restoreNodeScroll = function (_a) {
var element = _a[0], x = _a[1], y = _a[2];
element.scrollLeft = x;
element.scrollTop = y;
};
var PSEUDO_BEFORE = ':before';
var PSEUDO_AFTER = ':after';
var PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = '___html2canvas___pseudoelement_before';
var PSEUDO_HIDE_ELEMENT_CLASS_AFTER = '___html2canvas___pseudoelement_after';
var PSEUDO_HIDE_ELEMENT_STYLE = "{\n content: \"\" !important;\n display: none !important;\n}";
var createPseudoHideStyles = function (body) {
createStyles(body, "." + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + PSEUDO_BEFORE + PSEUDO_HIDE_ELEMENT_STYLE + "\n ." + PSEUDO_HIDE_ELEMENT_CLASS_AFTER + PSEUDO_AFTER + PSEUDO_HIDE_ELEMENT_STYLE);
};
var createStyles = function (body, styles) {
var document = body.ownerDocument;
if (document) {
var style = document.createElement('style');
style.textContent = styles;
body.appendChild(style);
}
};
//# sourceMappingURL=document-cloner.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ElementContainer = void 0;
var index_1 = require("../css/index");
var bounds_1 = require("../css/layout/bounds");
var node_parser_1 = require("./node-parser");
var debugger_1 = require("../core/debugger");
var ElementContainer = /** @class */ (function () {
function ElementContainer(context, element) {
this.context = context;
this.textNodes = [];
this.elements = [];
this.flags = 0;
if (debugger_1.isDebugging(element, 3 /* PARSE */)) {
debugger;
}
this.styles = new index_1.CSSParsedDeclaration(context, window.getComputedStyle(element, null));
if (node_parser_1.isHTMLElementNode(element)) {
if (this.styles.animationDuration.some(function (duration) { return duration > 0; })) {
element.style.animationDuration = '0s';
}
if (this.styles.transform !== null) {
// getBoundingClientRect takes transforms into account
element.style.transform = 'none';
}
}
this.bounds = bounds_1.parseBounds(this.context, element);
if (debugger_1.isDebugging(element, 4 /* RENDER */)) {
this.flags |= 16 /* DEBUG_RENDER */;
}
}
return ElementContainer;
}());
exports.ElementContainer = ElementContainer;
//# sourceMappingURL=element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"element-container.js","sourceRoot":"","sources":["../../../src/dom/element-container.ts"],"names":[],"mappings":";;;AAAA,sCAAkD;AAElD,+CAAyD;AACzD,6CAAgD;AAEhD,6CAA2D;AAS3D;IAOI,0BAA+B,OAAgB,EAAE,OAAgB;QAAlC,YAAO,GAAP,OAAO,CAAS;QALtC,cAAS,GAAoB,EAAE,CAAC;QAChC,aAAQ,GAAuB,EAAE,CAAC;QAE3C,UAAK,GAAG,CAAC,CAAC;QAGN,IAAI,sBAAW,CAAC,OAAO,gBAAqB,EAAE;YAC1C,QAAQ,CAAC;SACZ;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,4BAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QAExF,IAAI,+BAAiB,CAAC,OAAO,CAAC,EAAE;YAC5B,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAC,QAAQ,IAAK,OAAA,QAAQ,GAAG,CAAC,EAAZ,CAAY,CAAC,EAAE;gBAChE,OAAO,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;aAC1C;YAED,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,IAAI,EAAE;gBAChC,sDAAsD;gBACtD,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;aACpC;SACJ;QAED,IAAI,CAAC,MAAM,GAAG,oBAAW,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAEjD,IAAI,sBAAW,CAAC,OAAO,iBAAsB,EAAE;YAC3C,IAAI,CAAC,KAAK,yBAAsB,CAAC;SACpC;IACL,CAAC;IACL,uBAAC;AAAD,CAAC,AA/BD,IA+BC;AA/BY,4CAAgB"}

View File

@@ -0,0 +1,30 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.LIElementContainer = void 0;
var element_container_1 = require("../element-container");
var LIElementContainer = /** @class */ (function (_super) {
__extends(LIElementContainer, _super);
function LIElementContainer(context, element) {
var _this = _super.call(this, context, element) || this;
_this.value = element.value;
return _this;
}
return LIElementContainer;
}(element_container_1.ElementContainer));
exports.LIElementContainer = LIElementContainer;
//# sourceMappingURL=li-element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"li-element-container.js","sourceRoot":"","sources":["../../../../src/dom/elements/li-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0DAAsD;AAEtD;IAAwC,sCAAgB;IAGpD,4BAAY,OAAgB,EAAE,OAAsB;QAApD,YACI,kBAAM,OAAO,EAAE,OAAO,CAAC,SAE1B;QADG,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;;IAC/B,CAAC;IACL,yBAAC;AAAD,CAAC,AAPD,CAAwC,oCAAgB,GAOvD;AAPY,gDAAkB"}

View File

@@ -0,0 +1,31 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.OLElementContainer = void 0;
var element_container_1 = require("../element-container");
var OLElementContainer = /** @class */ (function (_super) {
__extends(OLElementContainer, _super);
function OLElementContainer(context, element) {
var _this = _super.call(this, context, element) || this;
_this.start = element.start;
_this.reversed = typeof element.reversed === 'boolean' && element.reversed === true;
return _this;
}
return OLElementContainer;
}(element_container_1.ElementContainer));
exports.OLElementContainer = OLElementContainer;
//# sourceMappingURL=ol-element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ol-element-container.js","sourceRoot":"","sources":["../../../../src/dom/elements/ol-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0DAAsD;AAEtD;IAAwC,sCAAgB;IAIpD,4BAAY,OAAgB,EAAE,OAAyB;QAAvD,YACI,kBAAM,OAAO,EAAE,OAAO,CAAC,SAG1B;QAFG,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,KAAI,CAAC,QAAQ,GAAG,OAAO,OAAO,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;;IACvF,CAAC;IACL,yBAAC;AAAD,CAAC,AATD,CAAwC,oCAAgB,GASvD;AATY,gDAAkB"}

View File

@@ -0,0 +1,31 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SelectElementContainer = void 0;
var element_container_1 = require("../element-container");
var SelectElementContainer = /** @class */ (function (_super) {
__extends(SelectElementContainer, _super);
function SelectElementContainer(context, element) {
var _this = _super.call(this, context, element) || this;
var option = element.options[element.selectedIndex || 0];
_this.value = option ? option.text || '' : '';
return _this;
}
return SelectElementContainer;
}(element_container_1.ElementContainer));
exports.SelectElementContainer = SelectElementContainer;
//# sourceMappingURL=select-element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"select-element-container.js","sourceRoot":"","sources":["../../../../src/dom/elements/select-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0DAAsD;AAEtD;IAA4C,0CAAgB;IAExD,gCAAY,OAAgB,EAAE,OAA0B;QAAxD,YACI,kBAAM,OAAO,EAAE,OAAO,CAAC,SAG1B;QAFG,IAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC;QAC3D,KAAI,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;;IACjD,CAAC;IACL,6BAAC;AAAD,CAAC,AAPD,CAA4C,oCAAgB,GAO3D;AAPY,wDAAsB"}

View File

@@ -0,0 +1,30 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextareaElementContainer = void 0;
var element_container_1 = require("../element-container");
var TextareaElementContainer = /** @class */ (function (_super) {
__extends(TextareaElementContainer, _super);
function TextareaElementContainer(context, element) {
var _this = _super.call(this, context, element) || this;
_this.value = element.value;
return _this;
}
return TextareaElementContainer;
}(element_container_1.ElementContainer));
exports.TextareaElementContainer = TextareaElementContainer;
//# sourceMappingURL=textarea-element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"textarea-element-container.js","sourceRoot":"","sources":["../../../../src/dom/elements/textarea-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0DAAsD;AAEtD;IAA8C,4CAAgB;IAE1D,kCAAY,OAAgB,EAAE,OAA4B;QAA1D,YACI,kBAAM,OAAO,EAAE,OAAO,CAAC,SAE1B;QADG,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;;IAC/B,CAAC;IACL,+BAAC;AAAD,CAAC,AAND,CAA8C,oCAAgB,GAM7D;AANY,4DAAwB"}

142
node_modules/html2canvas/dist/lib/dom/node-parser.js generated vendored Normal file
View File

@@ -0,0 +1,142 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCustomElement = exports.isSlotElement = exports.isSelectElement = exports.isTextareaElement = exports.isScriptElement = exports.isStyleElement = exports.isIFrameElement = exports.isImageElement = exports.isVideoElement = exports.isCanvasElement = exports.isBodyElement = exports.isSVGElement = exports.isHTMLElement = exports.isInputElement = exports.isOLElement = exports.isLIElement = exports.isSVGElementNode = exports.isHTMLElementNode = exports.isElementNode = exports.isTextNode = exports.parseTree = void 0;
var element_container_1 = require("./element-container");
var text_container_1 = require("./text-container");
var image_element_container_1 = require("./replaced-elements/image-element-container");
var canvas_element_container_1 = require("./replaced-elements/canvas-element-container");
var svg_element_container_1 = require("./replaced-elements/svg-element-container");
var li_element_container_1 = require("./elements/li-element-container");
var ol_element_container_1 = require("./elements/ol-element-container");
var input_element_container_1 = require("./replaced-elements/input-element-container");
var select_element_container_1 = require("./elements/select-element-container");
var textarea_element_container_1 = require("./elements/textarea-element-container");
var iframe_element_container_1 = require("./replaced-elements/iframe-element-container");
var LIST_OWNERS = ['OL', 'UL', 'MENU'];
var parseNodeTree = function (context, node, parent, root) {
for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
nextNode = childNode.nextSibling;
if (exports.isTextNode(childNode) && childNode.data.trim().length > 0) {
parent.textNodes.push(new text_container_1.TextContainer(context, childNode, parent.styles));
}
else if (exports.isElementNode(childNode)) {
if (exports.isSlotElement(childNode) && childNode.assignedNodes) {
childNode.assignedNodes().forEach(function (childNode) { return parseNodeTree(context, childNode, parent, root); });
}
else {
var container = createContainer(context, childNode);
if (container.styles.isVisible()) {
if (createsRealStackingContext(childNode, container, root)) {
container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
}
else if (createsStackingContext(container.styles)) {
container.flags |= 2 /* CREATES_STACKING_CONTEXT */;
}
if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
container.flags |= 8 /* IS_LIST_OWNER */;
}
parent.elements.push(container);
childNode.slot;
if (childNode.shadowRoot) {
parseNodeTree(context, childNode.shadowRoot, container, root);
}
else if (!exports.isTextareaElement(childNode) &&
!exports.isSVGElement(childNode) &&
!exports.isSelectElement(childNode)) {
parseNodeTree(context, childNode, container, root);
}
}
}
}
}
};
var createContainer = function (context, element) {
if (exports.isImageElement(element)) {
return new image_element_container_1.ImageElementContainer(context, element);
}
if (exports.isCanvasElement(element)) {
return new canvas_element_container_1.CanvasElementContainer(context, element);
}
if (exports.isSVGElement(element)) {
return new svg_element_container_1.SVGElementContainer(context, element);
}
if (exports.isLIElement(element)) {
return new li_element_container_1.LIElementContainer(context, element);
}
if (exports.isOLElement(element)) {
return new ol_element_container_1.OLElementContainer(context, element);
}
if (exports.isInputElement(element)) {
return new input_element_container_1.InputElementContainer(context, element);
}
if (exports.isSelectElement(element)) {
return new select_element_container_1.SelectElementContainer(context, element);
}
if (exports.isTextareaElement(element)) {
return new textarea_element_container_1.TextareaElementContainer(context, element);
}
if (exports.isIFrameElement(element)) {
return new iframe_element_container_1.IFrameElementContainer(context, element);
}
return new element_container_1.ElementContainer(context, element);
};
var parseTree = function (context, element) {
var container = createContainer(context, element);
container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
parseNodeTree(context, element, container, container);
return container;
};
exports.parseTree = parseTree;
var createsRealStackingContext = function (node, container, root) {
return (container.styles.isPositionedWithZIndex() ||
container.styles.opacity < 1 ||
container.styles.isTransformed() ||
(exports.isBodyElement(node) && root.styles.isTransparent()));
};
var createsStackingContext = function (styles) { return styles.isPositioned() || styles.isFloating(); };
var isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };
exports.isTextNode = isTextNode;
var isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
exports.isElementNode = isElementNode;
var isHTMLElementNode = function (node) {
return exports.isElementNode(node) && typeof node.style !== 'undefined' && !exports.isSVGElementNode(node);
};
exports.isHTMLElementNode = isHTMLElementNode;
var isSVGElementNode = function (element) {
return typeof element.className === 'object';
};
exports.isSVGElementNode = isSVGElementNode;
var isLIElement = function (node) { return node.tagName === 'LI'; };
exports.isLIElement = isLIElement;
var isOLElement = function (node) { return node.tagName === 'OL'; };
exports.isOLElement = isOLElement;
var isInputElement = function (node) { return node.tagName === 'INPUT'; };
exports.isInputElement = isInputElement;
var isHTMLElement = function (node) { return node.tagName === 'HTML'; };
exports.isHTMLElement = isHTMLElement;
var isSVGElement = function (node) { return node.tagName === 'svg'; };
exports.isSVGElement = isSVGElement;
var isBodyElement = function (node) { return node.tagName === 'BODY'; };
exports.isBodyElement = isBodyElement;
var isCanvasElement = function (node) { return node.tagName === 'CANVAS'; };
exports.isCanvasElement = isCanvasElement;
var isVideoElement = function (node) { return node.tagName === 'VIDEO'; };
exports.isVideoElement = isVideoElement;
var isImageElement = function (node) { return node.tagName === 'IMG'; };
exports.isImageElement = isImageElement;
var isIFrameElement = function (node) { return node.tagName === 'IFRAME'; };
exports.isIFrameElement = isIFrameElement;
var isStyleElement = function (node) { return node.tagName === 'STYLE'; };
exports.isStyleElement = isStyleElement;
var isScriptElement = function (node) { return node.tagName === 'SCRIPT'; };
exports.isScriptElement = isScriptElement;
var isTextareaElement = function (node) { return node.tagName === 'TEXTAREA'; };
exports.isTextareaElement = isTextareaElement;
var isSelectElement = function (node) { return node.tagName === 'SELECT'; };
exports.isSelectElement = isSelectElement;
var isSlotElement = function (node) { return node.tagName === 'SLOT'; };
exports.isSlotElement = isSlotElement;
// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
var isCustomElement = function (node) { return node.tagName.indexOf('-') > 0; };
exports.isCustomElement = isCustomElement;
//# sourceMappingURL=node-parser.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanvasElementContainer = void 0;
var element_container_1 = require("../element-container");
var CanvasElementContainer = /** @class */ (function (_super) {
__extends(CanvasElementContainer, _super);
function CanvasElementContainer(context, canvas) {
var _this = _super.call(this, context, canvas) || this;
_this.canvas = canvas;
_this.intrinsicWidth = canvas.width;
_this.intrinsicHeight = canvas.height;
return _this;
}
return CanvasElementContainer;
}(element_container_1.ElementContainer));
exports.CanvasElementContainer = CanvasElementContainer;
//# sourceMappingURL=canvas-element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"canvas-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/canvas-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0DAAsD;AAGtD;IAA4C,0CAAgB;IAKxD,gCAAY,OAAgB,EAAE,MAAyB;QAAvD,YACI,kBAAM,OAAO,EAAE,MAAM,CAAC,SAIzB;QAHG,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,KAAI,CAAC,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;QACnC,KAAI,CAAC,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;;IACzC,CAAC;IACL,6BAAC;AAAD,CAAC,AAXD,CAA4C,oCAAgB,GAW3D;AAXY,wDAAsB"}

View File

@@ -0,0 +1,55 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.IFrameElementContainer = void 0;
var element_container_1 = require("../element-container");
var node_parser_1 = require("../node-parser");
var color_1 = require("../../css/types/color");
var IFrameElementContainer = /** @class */ (function (_super) {
__extends(IFrameElementContainer, _super);
function IFrameElementContainer(context, iframe) {
var _this = _super.call(this, context, iframe) || this;
_this.src = iframe.src;
_this.width = parseInt(iframe.width, 10) || 0;
_this.height = parseInt(iframe.height, 10) || 0;
_this.backgroundColor = _this.styles.backgroundColor;
try {
if (iframe.contentWindow &&
iframe.contentWindow.document &&
iframe.contentWindow.document.documentElement) {
_this.tree = node_parser_1.parseTree(context, iframe.contentWindow.document.documentElement);
// http://www.w3.org/TR/css3-background/#special-backgrounds
var documentBackgroundColor = iframe.contentWindow.document.documentElement
? color_1.parseColor(context, getComputedStyle(iframe.contentWindow.document.documentElement).backgroundColor)
: color_1.COLORS.TRANSPARENT;
var bodyBackgroundColor = iframe.contentWindow.document.body
? color_1.parseColor(context, getComputedStyle(iframe.contentWindow.document.body).backgroundColor)
: color_1.COLORS.TRANSPARENT;
_this.backgroundColor = color_1.isTransparent(documentBackgroundColor)
? color_1.isTransparent(bodyBackgroundColor)
? _this.styles.backgroundColor
: bodyBackgroundColor
: documentBackgroundColor;
}
}
catch (e) { }
return _this;
}
return IFrameElementContainer;
}(element_container_1.ElementContainer));
exports.IFrameElementContainer = IFrameElementContainer;
//# sourceMappingURL=iframe-element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"iframe-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/iframe-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD,8CAAyC;AACzC,+CAA+E;AAG/E;IAA4C,0CAAgB;IAOxD,gCAAY,OAAgB,EAAE,MAAyB;QAAvD,YACI,kBAAM,OAAO,EAAE,MAAM,CAAC,SAkCzB;QAjCG,KAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QACtB,KAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QAC7C,KAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QAC/C,KAAI,CAAC,eAAe,GAAG,KAAI,CAAC,MAAM,CAAC,eAAe,CAAC;QACnD,IAAI;YACA,IACI,MAAM,CAAC,aAAa;gBACpB,MAAM,CAAC,aAAa,CAAC,QAAQ;gBAC7B,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe,EAC/C;gBACE,KAAI,CAAC,IAAI,GAAG,uBAAS,CAAC,OAAO,EAAE,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;gBAE9E,4DAA4D;gBAC5D,IAAM,uBAAuB,GAAG,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe;oBACzE,CAAC,CAAC,kBAAU,CACN,OAAO,EACP,gBAAgB,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,eAAyB,CAC5F;oBACH,CAAC,CAAC,cAAM,CAAC,WAAW,CAAC;gBACzB,IAAM,mBAAmB,GAAG,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI;oBAC1D,CAAC,CAAC,kBAAU,CACN,OAAO,EACP,gBAAgB,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,eAAyB,CACjF;oBACH,CAAC,CAAC,cAAM,CAAC,WAAW,CAAC;gBAEzB,KAAI,CAAC,eAAe,GAAG,qBAAa,CAAC,uBAAuB,CAAC;oBACzD,CAAC,CAAC,qBAAa,CAAC,mBAAmB,CAAC;wBAChC,CAAC,CAAC,KAAI,CAAC,MAAM,CAAC,eAAe;wBAC7B,CAAC,CAAC,mBAAmB;oBACzB,CAAC,CAAC,uBAAuB,CAAC;aACjC;SACJ;QAAC,OAAO,CAAC,EAAE,GAAE;;IAClB,CAAC;IACL,6BAAC;AAAD,CAAC,AA3CD,CAA4C,oCAAgB,GA2C3D;AA3CY,wDAAsB"}

View File

@@ -0,0 +1,33 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageElementContainer = void 0;
var element_container_1 = require("../element-container");
var ImageElementContainer = /** @class */ (function (_super) {
__extends(ImageElementContainer, _super);
function ImageElementContainer(context, img) {
var _this = _super.call(this, context, img) || this;
_this.src = img.currentSrc || img.src;
_this.intrinsicWidth = img.naturalWidth;
_this.intrinsicHeight = img.naturalHeight;
_this.context.cache.addImage(_this.src);
return _this;
}
return ImageElementContainer;
}(element_container_1.ElementContainer));
exports.ImageElementContainer = ImageElementContainer;
//# sourceMappingURL=image-element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"image-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/image-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0DAAsD;AAGtD;IAA2C,yCAAgB;IAKvD,+BAAY,OAAgB,EAAE,GAAqB;QAAnD,YACI,kBAAM,OAAO,EAAE,GAAG,CAAC,SAKtB;QAJG,KAAI,CAAC,GAAG,GAAG,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,GAAG,CAAC;QACrC,KAAI,CAAC,cAAc,GAAG,GAAG,CAAC,YAAY,CAAC;QACvC,KAAI,CAAC,eAAe,GAAG,GAAG,CAAC,aAAa,CAAC;QACzC,KAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAI,CAAC,GAAG,CAAC,CAAC;;IAC1C,CAAC;IACL,4BAAC;AAAD,CAAC,AAZD,CAA2C,oCAAgB,GAY1D;AAZY,sDAAqB"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/index.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,102 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.InputElementContainer = exports.INPUT_COLOR = exports.PASSWORD = exports.RADIO = exports.CHECKBOX = void 0;
var element_container_1 = require("../element-container");
var bounds_1 = require("../../css/layout/bounds");
var CHECKBOX_BORDER_RADIUS = [
{
type: 15 /* DIMENSION_TOKEN */,
flags: 0,
unit: 'px',
number: 3
}
];
var RADIO_BORDER_RADIUS = [
{
type: 16 /* PERCENTAGE_TOKEN */,
flags: 0,
number: 50
}
];
var reformatInputBounds = function (bounds) {
if (bounds.width > bounds.height) {
return new bounds_1.Bounds(bounds.left + (bounds.width - bounds.height) / 2, bounds.top, bounds.height, bounds.height);
}
else if (bounds.width < bounds.height) {
return new bounds_1.Bounds(bounds.left, bounds.top + (bounds.height - bounds.width) / 2, bounds.width, bounds.width);
}
return bounds;
};
var getInputValue = function (node) {
var value = node.type === exports.PASSWORD ? new Array(node.value.length + 1).join('\u2022') : node.value;
return value.length === 0 ? node.placeholder || '' : value;
};
exports.CHECKBOX = 'checkbox';
exports.RADIO = 'radio';
exports.PASSWORD = 'password';
exports.INPUT_COLOR = 0x2a2a2aff;
var InputElementContainer = /** @class */ (function (_super) {
__extends(InputElementContainer, _super);
function InputElementContainer(context, input) {
var _this = _super.call(this, context, input) || this;
_this.type = input.type.toLowerCase();
_this.checked = input.checked;
_this.value = getInputValue(input);
if (_this.type === exports.CHECKBOX || _this.type === exports.RADIO) {
_this.styles.backgroundColor = 0xdededeff;
_this.styles.borderTopColor =
_this.styles.borderRightColor =
_this.styles.borderBottomColor =
_this.styles.borderLeftColor =
0xa5a5a5ff;
_this.styles.borderTopWidth =
_this.styles.borderRightWidth =
_this.styles.borderBottomWidth =
_this.styles.borderLeftWidth =
1;
_this.styles.borderTopStyle =
_this.styles.borderRightStyle =
_this.styles.borderBottomStyle =
_this.styles.borderLeftStyle =
1 /* SOLID */;
_this.styles.backgroundClip = [0 /* BORDER_BOX */];
_this.styles.backgroundOrigin = [0 /* BORDER_BOX */];
_this.bounds = reformatInputBounds(_this.bounds);
}
switch (_this.type) {
case exports.CHECKBOX:
_this.styles.borderTopRightRadius =
_this.styles.borderTopLeftRadius =
_this.styles.borderBottomRightRadius =
_this.styles.borderBottomLeftRadius =
CHECKBOX_BORDER_RADIUS;
break;
case exports.RADIO:
_this.styles.borderTopRightRadius =
_this.styles.borderTopLeftRadius =
_this.styles.borderBottomRightRadius =
_this.styles.borderBottomLeftRadius =
RADIO_BORDER_RADIUS;
break;
}
return _this;
}
return InputElementContainer;
}(element_container_1.ElementContainer));
exports.InputElementContainer = InputElementContainer;
//# sourceMappingURL=input-element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"input-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/input-element-container.ts"],"names":[],"mappings":"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"}

View File

@@ -0,0 +1 @@
//# sourceMappingURL=pseudo-elements.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pseudo-elements.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/pseudo-elements.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,38 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SVGElementContainer = void 0;
var element_container_1 = require("../element-container");
var bounds_1 = require("../../css/layout/bounds");
var SVGElementContainer = /** @class */ (function (_super) {
__extends(SVGElementContainer, _super);
function SVGElementContainer(context, img) {
var _this = _super.call(this, context, img) || this;
var s = new XMLSerializer();
var bounds = bounds_1.parseBounds(context, img);
img.setAttribute('width', bounds.width + "px");
img.setAttribute('height', bounds.height + "px");
_this.svg = "data:image/svg+xml," + encodeURIComponent(s.serializeToString(img));
_this.intrinsicWidth = img.width.baseVal.value;
_this.intrinsicHeight = img.height.baseVal.value;
_this.context.cache.addImage(_this.svg);
return _this;
}
return SVGElementContainer;
}(element_container_1.ElementContainer));
exports.SVGElementContainer = SVGElementContainer;
//# sourceMappingURL=svg-element-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"svg-element-container.js","sourceRoot":"","sources":["../../../../src/dom/replaced-elements/svg-element-container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0DAAsD;AACtD,kDAAoD;AAGpD;IAAyC,uCAAgB;IAKrD,6BAAY,OAAgB,EAAE,GAAkB;QAAhD,YACI,kBAAM,OAAO,EAAE,GAAG,CAAC,SAWtB;QAVG,IAAM,CAAC,GAAG,IAAI,aAAa,EAAE,CAAC;QAC9B,IAAM,MAAM,GAAG,oBAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACzC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAK,MAAM,CAAC,KAAK,OAAI,CAAC,CAAC;QAC/C,GAAG,CAAC,YAAY,CAAC,QAAQ,EAAK,MAAM,CAAC,MAAM,OAAI,CAAC,CAAC;QAEjD,KAAI,CAAC,GAAG,GAAG,wBAAsB,kBAAkB,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAG,CAAC;QAChF,KAAI,CAAC,cAAc,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAC9C,KAAI,CAAC,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAEhD,KAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAI,CAAC,GAAG,CAAC,CAAC;;IAC1C,CAAC;IACL,0BAAC;AAAD,CAAC,AAlBD,CAAyC,oCAAgB,GAkBxD;AAlBY,kDAAmB"}

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextContainer = void 0;
var text_1 = require("../css/layout/text");
var TextContainer = /** @class */ (function () {
function TextContainer(context, node, styles) {
this.text = transform(node.data, styles.textTransform);
this.textBounds = text_1.parseTextBounds(context, this.text, styles, node);
}
return TextContainer;
}());
exports.TextContainer = TextContainer;
var transform = function (text, transform) {
switch (transform) {
case 1 /* LOWERCASE */:
return text.toLowerCase();
case 3 /* CAPITALIZE */:
return text.replace(CAPITALIZE, capitalize);
case 2 /* UPPERCASE */:
return text.toUpperCase();
default:
return text;
}
};
var CAPITALIZE = /(^|\s|:|-|\(|\))([a-z])/g;
var capitalize = function (m, p1, p2) {
if (m.length > 0) {
return p1 + p2.toUpperCase();
}
return m;
};
//# sourceMappingURL=text-container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"text-container.js","sourceRoot":"","sources":["../../../src/dom/text-container.ts"],"names":[],"mappings":";;;AAEA,2CAA+D;AAG/D;IAII,uBAAY,OAAgB,EAAE,IAAU,EAAE,MAA4B;QAClE,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,GAAG,sBAAe,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC;IACL,oBAAC;AAAD,CAAC,AARD,IAQC;AARY,sCAAa;AAU1B,IAAM,SAAS,GAAG,UAAC,IAAY,EAAE,SAAyB;IACtD,QAAQ,SAAS,EAAE;QACf;YACI,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9B;YACI,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAChD;YACI,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9B;YACI,OAAO,IAAI,CAAC;KACnB;AACL,CAAC,CAAC;AAEF,IAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,IAAM,UAAU,GAAG,UAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IACjD,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QACd,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;KAChC;IAED,OAAO,CAAC,CAAC;AACb,CAAC,CAAC"}