Deploying to gh-pages from @ 7c3269bdbe 🚀

This commit is contained in:
niklasvh 2022-01-22 16:55:25 +00:00
commit 81ce7ed71b
1620 changed files with 36474 additions and 0 deletions

20
404.html Normal file

File diff suppressed because one or more lines are too long

20
404/index.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,20 @@
/*!
* html2canvas 1.4.1 <https://html2canvas.hertzen.com>
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
* Released under MIT License
*/
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

File diff suppressed because one or more lines are too long

1
CNAME Normal file
View File

@ -0,0 +1 @@
html2canvas.hertzen.com

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
/*!
* domready (c) Dustin Diaz 2014 - License MIT
* ie10 fix - Mikael Kristiansson 2019
*/

File diff suppressed because one or more lines are too long

1
chunk-map.json Normal file
View File

@ -0,0 +1 @@
{"polyfill":["/polyfill-4f949977b89e47e8576f.js"],"app":["/app-532b4c1a6df06237bd2e.js"],"component---src-pages-404-js":["/component---src-pages-404-js-0c4f1c878dc0fb27bca7.js"],"component---src-pages-index-js":["/component---src-pages-index-js-ac7dfc2c623f77e8734c.js"],"component---src-templates-docs-js":["/component---src-templates-docs-js-95b487188feee354982e.js"]}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
/*!
Copyright (c) 2015 Jed Watson.
Based on code that is Copyright 2013-2015, Facebook, Inc.
All rights reserved.
*/

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{w2l6:function(t,e,n){"use strict";n.r(e),function(t){n("q1tI");var l=n("Bl7J");e.default=function(){return t.createElement(l.a,null,t.createElement("h1",null,"NOT FOUND"),t.createElement("p",null,"You just hit a route that doesn't exist... the sadness."))}}.call(this,n("iMUK"))}}]);
//# sourceMappingURL=component---src-pages-404-js-0c4f1c878dc0fb27bca7.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["webpack:///./src/pages/404.js"],"names":["NotFoundPage"],"mappings":"2FAAA,6CASeA,UANM,kBACjB,gBAAC,IAAD,KACI,uCACA,uF","file":"component---src-pages-404-js-0c4f1c878dc0fb27bca7.js","sourcesContent":["import React from 'react';\nimport Layout from '../components/layout';\n\nconst NotFoundPage = () =>\n <Layout>\n <h1>NOT FOUND</h1>\n <p>You just hit a route that doesn&#39;t exist... the sadness.</p>\n </Layout>;\n\nexport default NotFoundPage;\n"],"sourceRoot":""}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

35
configuration.md Normal file
View File

@ -0,0 +1,35 @@
---
title: "Options"
description: "Explore the different configuration options available for html2canvas"
previousUrl: "/getting-started"
previousTitle: "Getting Started"
nextUrl: "/features"
nextTitle: "Features"
---
These are all of the available configuration options.
| Name | Default | Description |
| ------------- | :------: | ----------- |
| allowTaint | `false` | Whether to allow cross-origin images to taint the canvas
| backgroundColor | `#ffffff` | Canvas background color, if none is specified in DOM. Set `null` for transparent
| canvas | `null` | Existing `canvas` element to use as a base for drawing on
| foreignObjectRendering | `false` | Whether to use ForeignObject rendering if the browser supports it
| imageTimeout | `15000` | Timeout for loading an image (in milliseconds). Set to `0` to disable timeout.
| ignoreElements | `(element) => false` | Predicate function which removes the matching elements from the render.
| logging | `true` | Enable logging for debug purposes
| onclone | `null` | Callback function which is called when the Document has been cloned for rendering, can be used to modify the contents that will be rendered without affecting the original source document.
| proxy | `null` | Url to the [proxy](/proxy/) which is to be used for loading cross-origin images. If left empty, cross-origin images won't be loaded.
| removeContainer | `true` | Whether to cleanup the cloned DOM elements html2canvas creates temporarily
| scale | `window.devicePixelRatio` | The scale to use for rendering. Defaults to the browsers device pixel ratio.
| useCORS | `false` | Whether to attempt to load images from a server using CORS
| width | `Element` width | The width of the `canvas`
| height | `Element` height | The height of the `canvas`
| x | `Element` x-offset | Crop canvas x-coordinate
| y | `Element` y-offset| Crop canvas y-coordinate
| scrollX | `Element` scrollX | The x-scroll position to used when rendering element, (for example if the Element uses `position: fixed`)
| scrollY | `Element` scrollY | The y-scroll position to used when rendering element, (for example if the Element uses `position: fixed`)
| windowWidth | `Window.innerWidth` | Window width to use when rendering `Element`, which may affect things like Media queries
| windowHeight | `Window.innerHeight` | Window height to use when rendering `Element`, which may affect things like Media queries
If you wish to exclude certain `Element`s from getting rendered, you can add a `data-html2canvas-ignore` attribute to those elements and html2canvas will exclude them from the rendering.

132
configuration/index.html Normal file

File diff suppressed because one or more lines are too long

7822
dist/html2canvas.esm.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/html2canvas.esm.js.map vendored Normal file

File diff suppressed because one or more lines are too long

7830
dist/html2canvas.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/html2canvas.js.map vendored Normal file

File diff suppressed because one or more lines are too long

20
dist/html2canvas.min.js vendored Normal file

File diff suppressed because one or more lines are too long

144
dist/lib/__tests__/index.js vendored Normal file
View File

@ -0,0 +1,144 @@
"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 });
var index_1 = require("../index");
var canvas_renderer_1 = require("../render/canvas/canvas-renderer");
var document_cloner_1 = require("../dom/document-cloner");
var color_1 = require("../css/types/color");
jest.mock('../core/logger');
jest.mock('../css/layout/bounds');
jest.mock('../dom/document-cloner');
jest.mock('../dom/node-parser', function () {
return {
isBodyElement: function () { return false; },
isHTMLElement: function () { return false; },
parseTree: jest.fn().mockImplementation(function () {
return { styles: {} };
})
};
});
jest.mock('../render/stacking-context');
jest.mock('../render/canvas/canvas-renderer');
describe('html2canvas', function () {
var element = {
ownerDocument: {
defaultView: {
pageXOffset: 12,
pageYOffset: 34
}
}
};
it('should render with an element', function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
document_cloner_1.DocumentCloner.destroy = jest.fn().mockReturnValue(true);
return [4 /*yield*/, index_1.default(element)];
case 1:
_a.sent();
expect(canvas_renderer_1.CanvasRenderer).toHaveBeenLastCalledWith(expect.objectContaining({
cache: expect.any(Object),
logger: expect.any(Object),
windowBounds: expect.objectContaining({ left: 12, top: 34 })
}), expect.objectContaining({
backgroundColor: 0xffffffff,
scale: 1,
height: 50,
width: 200,
x: 0,
y: 0,
canvas: undefined
}));
expect(document_cloner_1.DocumentCloner.destroy).toBeCalled();
return [2 /*return*/];
}
});
}); });
it('should have transparent background with backgroundColor: null', function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, index_1.default(element, { backgroundColor: null })];
case 1:
_a.sent();
expect(canvas_renderer_1.CanvasRenderer).toHaveBeenLastCalledWith(expect.anything(), expect.objectContaining({
backgroundColor: color_1.COLORS.TRANSPARENT
}));
return [2 /*return*/];
}
});
}); });
it('should use existing canvas when given as option', function () { return __awaiter(void 0, void 0, void 0, function () {
var canvas;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
canvas = {};
return [4 /*yield*/, index_1.default(element, { canvas: canvas })];
case 1:
_a.sent();
expect(canvas_renderer_1.CanvasRenderer).toHaveBeenLastCalledWith(expect.anything(), expect.objectContaining({
canvas: canvas
}));
return [2 /*return*/];
}
});
}); });
it('should not remove cloned window when removeContainer: false', function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
document_cloner_1.DocumentCloner.destroy = jest.fn();
return [4 /*yield*/, index_1.default(element, { removeContainer: false })];
case 1:
_a.sent();
expect(canvas_renderer_1.CanvasRenderer).toHaveBeenLastCalledWith(expect.anything(), expect.objectContaining({
backgroundColor: 0xffffffff,
scale: 1,
height: 50,
width: 200,
x: 0,
y: 0,
canvas: undefined
}));
expect(document_cloner_1.DocumentCloner.destroy).not.toBeCalled();
return [2 /*return*/];
}
});
}); });
});
//# sourceMappingURL=index.js.map

1
dist/lib/__tests__/index.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/__tests__/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAAmC;AAEnC,oEAAgE;AAChE,0DAAsD;AACtD,4CAA0C;AAE1C,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAC5B,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAClC,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AACpC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;IAC5B,OAAO;QACH,aAAa,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;QAC1B,aAAa,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;QAC1B,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC;YACpC,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,CAAC;QACxB,CAAC,CAAC;KACL,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;AACxC,IAAI,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;AAE9C,QAAQ,CAAC,aAAa,EAAE;IACpB,IAAM,OAAO,GAAG;QACZ,aAAa,EAAE;YACX,WAAW,EAAE;gBAC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AEH,EAAE,CAAC,iDAAiD,EAAE;;;;;oBAC5C,MAAM,GAAG,EAAuB,CAAC;oBACvC,qBAAM,eAAW,CAAC,OAAO,EAAE,EAAC,MAAM,QAAA,EAAC,CAAC,EAAA;;oBAApC,SAAoC,CAAC;oBACrC,MAAM,CAAC,gCAAc,CAAC,CAAC,wBAAwB,CAC3C,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,gBAAgB,CAAC;wBACpB,MAAM,QAAA;qBACT,CAAC,CACL,CAAC;;;;SACL,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE;;;;oBAC9D,gCAAc,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;oBACnC,qBAAM,eAAW,CAAC,OAAO,EAAE,EAAC,eAAe,EAAE,KAAK,EAAC,CAAC,EAAA;;oBAApD,SAAoD,CAAC;oBACrD,MAAM,CAAC,gCAAc,CAAC,CAAC,wBAAwB,CAC3C,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,gBAAgB,CAAC;wBACpB,eAAe,EAAE,UAAU;wBAC3B,KAAK,EAAE,CAAC;wBACR,MAAM,EAAE,EAAE;wBACV,KAAK,EAAE,GAAG;wBACV,CAAC,EAAE,CAAC;wBACJ,CAAC,EAAE,CAAC;wBACJ,MAAM,EAAE,SAAS;qBACpB,CAAC,CACL,CAAC;oBACF,MAAM,CAAC,gCAAc,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;;;;SACnD,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CacheStorage = void 0;
var CacheStorage = /** @class */ (function () {
function CacheStorage() {
}
return CacheStorage;
}());
exports.CacheStorage = CacheStorage;
//# sourceMappingURL=cache-storage.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"cache-storage.js","sourceRoot":"","sources":["../../../../src/core/__mocks__/cache-storage.ts"],"names":[],"mappings":";;;AAAA;IAAA;IAA2B,CAAC;IAAD,mBAAC;AAAD,CAAC,AAA5B,IAA4B;AAAf,oCAAY"}

22
dist/lib/core/__mocks__/context.js vendored Normal file
View File

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Context = void 0;
var logger_1 = require("./logger");
var Context = /** @class */ (function () {
function Context() {
var _this = this;
this.logger = logger_1.logger;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this._cache = {};
this.cache = {
addImage: jest.fn().mockImplementation(function (src) {
var result = Promise.resolve();
_this._cache[src] = result;
return result;
})
};
}
return Context;
}());
exports.Context = Context;
//# sourceMappingURL=context.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/core/__mocks__/context.ts"],"names":[],"mappings":";;;AAAA,mCAAwC;AAExC;IAOI;QAAA,iBAQC;QAdQ,WAAM,GAAW,eAAM,CAAC;QACjC,8DAA8D;QACrD,WAAM,GAAkC,EAAE,CAAC;QAKhD,IAAI,CAAC,KAAK,GAAG;YACT,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,UAAC,GAAW;gBAC/C,IAAM,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;gBACjC,KAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;gBAC1B,OAAO,MAAM,CAAC;YAClB,CAAC,CAAC;SACL,CAAC;IACN,CAAC;IACL,cAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,0BAAO"}

12
dist/lib/core/__mocks__/features.js vendored Normal file
View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FEATURES = void 0;
exports.FEATURES = {
SUPPORT_RANGE_BOUNDS: true,
SUPPORT_SVG_DRAWING: true,
SUPPORT_FOREIGNOBJECT_DRAWING: true,
SUPPORT_CORS_IMAGES: true,
SUPPORT_RESPONSE_TYPE: true,
SUPPORT_CORS_XHR: true
};
//# sourceMappingURL=features.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../../../src/core/__mocks__/features.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACpB,oBAAoB,EAAE,IAAI;IAC1B,mBAAmB,EAAE,IAAI;IACzB,6BAA6B,EAAE,IAAI;IACnC,mBAAmB,EAAE,IAAI;IACzB,qBAAqB,EAAE,IAAI;IAC3B,gBAAgB,EAAE,IAAI;CACzB,CAAC"}

24
dist/lib/core/__mocks__/logger.js vendored Normal file
View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.logger = exports.Logger = void 0;
var Logger = /** @class */ (function () {
function Logger() {
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
Logger.prototype.debug = function () { };
// eslint-disable-next-line @typescript-eslint/no-empty-function
Logger.create = function () { };
// eslint-disable-next-line @typescript-eslint/no-empty-function
Logger.destroy = function () { };
Logger.getInstance = function () {
return exports.logger;
};
// eslint-disable-next-line @typescript-eslint/no-empty-function
Logger.prototype.info = function () { };
// eslint-disable-next-line @typescript-eslint/no-empty-function
Logger.prototype.error = function () { };
return Logger;
}());
exports.Logger = Logger;
exports.logger = new Logger();
//# sourceMappingURL=logger.js.map

1
dist/lib/core/__mocks__/logger.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../src/core/__mocks__/logger.ts"],"names":[],"mappings":";;;AAAA;IAAA;IAmBA,CAAC;IAlBG,gEAAgE;IAChE,sBAAK,GAAL,cAAe,CAAC;IAEhB,gEAAgE;IACzD,aAAM,GAAb,cAAuB,CAAC;IAExB,gEAAgE;IACzD,cAAO,GAAd,cAAwB,CAAC;IAElB,kBAAW,GAAlB;QACI,OAAO,cAAM,CAAC;IAClB,CAAC;IAED,gEAAgE;IAChE,qBAAI,GAAJ,cAAc,CAAC;IAEf,gEAAgE;IAChE,sBAAK,GAAL,cAAe,CAAC;IACpB,aAAC;AAAD,CAAC,AAnBD,IAmBC;AAnBY,wBAAM;AAqBN,QAAA,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC"}

420
dist/lib/core/__tests__/cache-storage.js vendored Normal file
View File

@ -0,0 +1,420 @@
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
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 });
var assert_1 = require("assert");
var features_1 = require("../features");
var cache_storage_1 = require("../cache-storage");
var context_1 = require("../context");
var bounds_1 = require("../../css/layout/bounds");
var proxy = 'http://example.com/proxy';
var createMockContext = function (origin, opts) {
if (opts === void 0) { opts = {}; }
var context = {
location: {
href: origin
},
document: {
createElement: function (_name) {
var _href = '';
return {
set href(value) {
_href = value;
},
get href() {
return _href;
},
get protocol() {
return new URL(_href).protocol;
},
get hostname() {
return new URL(_href).hostname;
},
get port() {
return new URL(_href).port;
}
};
}
}
};
cache_storage_1.CacheStorage.setContext(context);
return new context_1.Context(__assign({ logging: false, imageTimeout: 0, useCORS: false, allowTaint: false, proxy: proxy }, opts), new bounds_1.Bounds(0, 0, 0, 0));
};
var images = [];
var xhr = [];
var sleep = function (timeout) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, timeout); })];
case 1: return [2 /*return*/, _a.sent()];
}
}); }); };
var ImageMock = /** @class */ (function () {
function ImageMock() {
images.push(this);
}
return ImageMock;
}());
var XMLHttpRequestMock = /** @class */ (function () {
function XMLHttpRequestMock() {
this.sent = false;
this.status = 500;
this.timeout = 5000;
xhr.push(this);
}
XMLHttpRequestMock.prototype.load = function (status, response) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.response = response;
this.status = status;
if (this.onload) {
this.onload();
}
return [4 /*yield*/, sleep(0)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
XMLHttpRequestMock.prototype.open = function (method, url) {
this.method = method;
this.url = url;
};
XMLHttpRequestMock.prototype.send = function () {
this.sent = true;
};
return XMLHttpRequestMock;
}());
Object.defineProperty(global, 'Image', { value: ImageMock, writable: true });
Object.defineProperty(global, 'XMLHttpRequest', {
value: XMLHttpRequestMock,
writable: true
});
var setFeatures = function (opts) {
if (opts === void 0) { opts = {}; }
var defaults = {
SUPPORT_SVG_DRAWING: true,
SUPPORT_CORS_IMAGES: true,
SUPPORT_CORS_XHR: true,
SUPPORT_RESPONSE_TYPE: false
};
Object.keys(defaults).forEach(function (key) {
Object.defineProperty(features_1.FEATURES, key, {
value: typeof opts[key] === 'boolean' ? opts[key] : defaults[key],
writable: true
});
});
};
describe('cache-storage', function () {
beforeEach(function () { return setFeatures(); });
afterEach(function () {
xhr.splice(0, xhr.length);
images.splice(0, images.length);
});
it('addImage adds images to cache', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com', { proxy: null }).cache;
return [4 /*yield*/, cache.addImage('http://example.com/test.jpg')];
case 1:
_a.sent();
return [4 /*yield*/, cache.addImage('http://example.com/test2.jpg')];
case 2:
_a.sent();
assert_1.deepStrictEqual(images.length, 2);
assert_1.deepStrictEqual(images[0].src, 'http://example.com/test.jpg');
assert_1.deepStrictEqual(images[1].src, 'http://example.com/test2.jpg');
return [2 /*return*/];
}
});
}); });
it('addImage should not add duplicate entries', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com').cache;
return [4 /*yield*/, cache.addImage('http://example.com/test.jpg')];
case 1:
_a.sent();
return [4 /*yield*/, cache.addImage('http://example.com/test.jpg')];
case 2:
_a.sent();
assert_1.deepStrictEqual(images.length, 1);
assert_1.deepStrictEqual(images[0].src, 'http://example.com/test.jpg');
return [2 /*return*/];
}
});
}); });
describe('svg', function () {
it('should add svg images correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com').cache;
return [4 /*yield*/, cache.addImage('http://example.com/test.svg')];
case 1:
_a.sent();
return [4 /*yield*/, cache.addImage('http://example.com/test2.svg')];
case 2:
_a.sent();
assert_1.deepStrictEqual(images.length, 2);
assert_1.deepStrictEqual(images[0].src, 'http://example.com/test.svg');
assert_1.deepStrictEqual(images[1].src, 'http://example.com/test2.svg');
return [2 /*return*/];
}
});
}); });
it('should omit svg images if not supported', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
setFeatures({ SUPPORT_SVG_DRAWING: false });
cache = createMockContext('http://example.com').cache;
return [4 /*yield*/, cache.addImage('http://example.com/test.svg')];
case 1:
_a.sent();
return [4 /*yield*/, cache.addImage('http://example.com/test2.svg')];
case 2:
_a.sent();
assert_1.deepStrictEqual(images.length, 0);
return [2 /*return*/];
}
});
}); });
});
describe('cross-origin', function () {
it('addImage should not add images it cannot load/render', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com', {
proxy: undefined
}).cache;
return [4 /*yield*/, cache.addImage('http://html2canvas.hertzen.com/test.jpg')];
case 1:
_a.sent();
assert_1.deepStrictEqual(images.length, 0);
return [2 /*return*/];
}
});
}); });
it('addImage should add images if tainting enabled', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com', {
allowTaint: true,
proxy: undefined
}).cache;
return [4 /*yield*/, cache.addImage('http://html2canvas.hertzen.com/test.jpg')];
case 1:
_a.sent();
assert_1.deepStrictEqual(images.length, 1);
assert_1.deepStrictEqual(images[0].src, 'http://html2canvas.hertzen.com/test.jpg');
assert_1.deepStrictEqual(images[0].crossOrigin, undefined);
return [2 /*return*/];
}
});
}); });
it('addImage should add images if cors enabled', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com', { useCORS: true }).cache;
return [4 /*yield*/, cache.addImage('http://html2canvas.hertzen.com/test.jpg')];
case 1:
_a.sent();
assert_1.deepStrictEqual(images.length, 1);
assert_1.deepStrictEqual(images[0].src, 'http://html2canvas.hertzen.com/test.jpg');
assert_1.deepStrictEqual(images[0].crossOrigin, 'anonymous');
return [2 /*return*/];
}
});
}); });
it('addImage should not add images if cors enabled but not supported', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
setFeatures({ SUPPORT_CORS_IMAGES: false });
cache = createMockContext('http://example.com', {
useCORS: true,
proxy: undefined
}).cache;
return [4 /*yield*/, cache.addImage('http://html2canvas.hertzen.com/test.jpg')];
case 1:
_a.sent();
assert_1.deepStrictEqual(images.length, 0);
return [2 /*return*/];
}
});
}); });
it('addImage should not add images to proxy if cors enabled', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com', { useCORS: true }).cache;
return [4 /*yield*/, cache.addImage('http://html2canvas.hertzen.com/test.jpg')];
case 1:
_a.sent();
assert_1.deepStrictEqual(images.length, 1);
assert_1.deepStrictEqual(images[0].src, 'http://html2canvas.hertzen.com/test.jpg');
assert_1.deepStrictEqual(images[0].crossOrigin, 'anonymous');
return [2 /*return*/];
}
});
}); });
it('addImage should use proxy ', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com').cache;
return [4 /*yield*/, cache.addImage('http://html2canvas.hertzen.com/test.jpg')];
case 1:
_a.sent();
assert_1.deepStrictEqual(xhr.length, 1);
assert_1.deepStrictEqual(xhr[0].url, proxy + "?url=" + encodeURIComponent('http://html2canvas.hertzen.com/test.jpg') + "&responseType=text");
return [4 /*yield*/, xhr[0].load(200, '<data response>')];
case 2:
_a.sent();
assert_1.deepStrictEqual(images.length, 1);
assert_1.deepStrictEqual(images[0].src, '<data response>');
return [2 /*return*/];
}
});
}); });
it('proxy should respect imageTimeout', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com', {
imageTimeout: 10
}).cache;
return [4 /*yield*/, cache.addImage('http://html2canvas.hertzen.com/test.jpg')];
case 1:
_a.sent();
assert_1.deepStrictEqual(xhr.length, 1);
assert_1.deepStrictEqual(xhr[0].url, proxy + "?url=" + encodeURIComponent('http://html2canvas.hertzen.com/test.jpg') + "&responseType=text");
assert_1.deepStrictEqual(xhr[0].timeout, 10);
if (xhr[0].ontimeout) {
xhr[0].ontimeout();
}
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, cache.match('http://html2canvas.hertzen.com/test.jpg')];
case 3:
_a.sent();
assert_1.fail('Expected result to timeout');
return [3 /*break*/, 5];
case 4:
e_1 = _a.sent();
return [3 /*break*/, 5];
case 5: return [2 /*return*/];
}
});
}); });
});
it('match should return cache entry', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com').cache;
return [4 /*yield*/, cache.addImage('http://example.com/test.jpg')];
case 1:
_a.sent();
if (images[0].onload) {
images[0].onload();
}
return [4 /*yield*/, cache.match('http://example.com/test.jpg')];
case 2:
response = _a.sent();
assert_1.deepStrictEqual(response.src, 'http://example.com/test.jpg');
return [2 /*return*/];
}
});
}); });
it('image should respect imageTimeout', function () { return __awaiter(void 0, void 0, void 0, function () {
var cache, e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cache = createMockContext('http://example.com', { imageTimeout: 10 }).cache;
cache.addImage('http://example.com/test.jpg');
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, cache.match('http://example.com/test.jpg')];
case 2:
_a.sent();
assert_1.fail('Expected result to timeout');
return [3 /*break*/, 4];
case 3:
e_2 = _a.sent();
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
}); });
});
//# sourceMappingURL=cache-storage.js.map

File diff suppressed because one or more lines are too long

28
dist/lib/core/__tests__/logger.js vendored Normal file
View File

@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var logger_1 = require("../logger");
describe('logger', function () {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var infoSpy;
beforeEach(function () {
infoSpy = jest.spyOn(console, 'info').mockImplementation(function () {
// do nothing
});
});
afterEach(function () {
infoSpy.mockRestore();
});
it('should call console.info when logger enabled', function () {
var id = Math.random().toString();
var logger = new logger_1.Logger({ id: id, enabled: true });
logger.info('testing');
expect(infoSpy).toHaveBeenLastCalledWith(id, expect.stringMatching(/\d+ms/), 'testing');
});
it("shouldn't call console.info when logger disabled", function () {
var id = Math.random().toString();
var logger = new logger_1.Logger({ id: id, enabled: false });
logger.info('testing');
expect(infoSpy).not.toHaveBeenCalled();
});
});
//# sourceMappingURL=logger.js.map

1
dist/lib/core/__tests__/logger.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../src/core/__tests__/logger.ts"],"names":[],"mappings":";;AAAA,oCAAiC;AAEjC,QAAQ,CAAC,QAAQ,EAAE;IACf,8DAA8D;IAC9D,IAAI,OAAY,CAAC;IAEjB,UAAU,CAAC;QACP,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC;YACrD,aAAa;QACjB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC;QACN,OAAO,CAAC,WAAW,EAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE;QAC/C,IAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAM,MAAM,GAAG,IAAI,eAAM,CAAC,EAAC,EAAE,IAAA,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvB,MAAM,CAAC,OAAO,CAAC,CAAC,wBAAwB,CAAC,EAAE,EAAE,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE;QACnD,IAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAM,MAAM,GAAG,IAAI,eAAM,CAAC,EAAC,EAAE,IAAA,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC,CAAC;QAChD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvB,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

6
dist/lib/core/bitwise.js vendored Normal file
View File

@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.contains = void 0;
var contains = function (bit, value) { return (bit & value) !== 0; };
exports.contains = contains;
//# sourceMappingURL=bitwise.js.map

1
dist/lib/core/bitwise.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"bitwise.js","sourceRoot":"","sources":["../../../src/core/bitwise.ts"],"names":[],"mappings":";;;AAAO,IAAM,QAAQ,GAAG,UAAC,GAAW,EAAE,KAAa,IAAc,OAAA,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,EAAnB,CAAmB,CAAC;AAAxE,QAAA,QAAQ,YAAgE"}

198
dist/lib/core/cache-storage.js vendored Normal file
View File

@ -0,0 +1,198 @@
"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.Cache = exports.CacheStorage = void 0;
var features_1 = require("./features");
var CacheStorage = /** @class */ (function () {
function CacheStorage() {
}
CacheStorage.getOrigin = function (url) {
var link = CacheStorage._link;
if (!link) {
return 'about:blank';
}
link.href = url;
link.href = link.href; // IE9, LOL! - http://jsfiddle.net/niklasvh/2e48b/
return link.protocol + link.hostname + link.port;
};
CacheStorage.isSameOrigin = function (src) {
return CacheStorage.getOrigin(src) === CacheStorage._origin;
};
CacheStorage.setContext = function (window) {
CacheStorage._link = window.document.createElement('a');
CacheStorage._origin = CacheStorage.getOrigin(window.location.href);
};
CacheStorage._origin = 'about:blank';
return CacheStorage;
}());
exports.CacheStorage = CacheStorage;
var Cache = /** @class */ (function () {
function Cache(context, _options) {
this.context = context;
this._options = _options;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this._cache = {};
}
Cache.prototype.addImage = function (src) {
var result = Promise.resolve();
if (this.has(src)) {
return result;
}
if (isBlobImage(src) || isRenderable(src)) {
(this._cache[src] = this.loadImage(src)).catch(function () {
// prevent unhandled rejection
});
return result;
}
return result;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Cache.prototype.match = function (src) {
return this._cache[src];
};
Cache.prototype.loadImage = function (key) {
return __awaiter(this, void 0, void 0, function () {
var isSameOrigin, useCORS, useProxy, src;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
isSameOrigin = CacheStorage.isSameOrigin(key);
useCORS = !isInlineImage(key) && this._options.useCORS === true && features_1.FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;
useProxy = !isInlineImage(key) &&
!isSameOrigin &&
!isBlobImage(key) &&
typeof this._options.proxy === 'string' &&
features_1.FEATURES.SUPPORT_CORS_XHR &&
!useCORS;
if (!isSameOrigin &&
this._options.allowTaint === false &&
!isInlineImage(key) &&
!isBlobImage(key) &&
!useProxy &&
!useCORS) {
return [2 /*return*/];
}
src = key;
if (!useProxy) return [3 /*break*/, 2];
return [4 /*yield*/, this.proxy(src)];
case 1:
src = _a.sent();
_a.label = 2;
case 2:
this.context.logger.debug("Added image " + key.substring(0, 256));
return [4 /*yield*/, new Promise(function (resolve, reject) {
var img = new Image();
img.onload = function () { return resolve(img); };
img.onerror = reject;
//ios safari 10.3 taints canvas with data urls unless crossOrigin is set to anonymous
if (isInlineBase64Image(src) || useCORS) {
img.crossOrigin = 'anonymous';
}
img.src = src;
if (img.complete === true) {
// Inline XML images may fail to parse, throwing an Error later on
setTimeout(function () { return resolve(img); }, 500);
}
if (_this._options.imageTimeout > 0) {
setTimeout(function () { return reject("Timed out (" + _this._options.imageTimeout + "ms) loading image"); }, _this._options.imageTimeout);
}
})];
case 3: return [2 /*return*/, _a.sent()];
}
});
});
};
Cache.prototype.has = function (key) {
return typeof this._cache[key] !== 'undefined';
};
Cache.prototype.keys = function () {
return Promise.resolve(Object.keys(this._cache));
};
Cache.prototype.proxy = function (src) {
var _this = this;
var proxy = this._options.proxy;
if (!proxy) {
throw new Error('No proxy defined');
}
var key = src.substring(0, 256);
return new Promise(function (resolve, reject) {
var responseType = features_1.FEATURES.SUPPORT_RESPONSE_TYPE ? 'blob' : 'text';
var xhr = new XMLHttpRequest();
xhr.onload = function () {
if (xhr.status === 200) {
if (responseType === 'text') {
resolve(xhr.response);
}
else {
var reader_1 = new FileReader();
reader_1.addEventListener('load', function () { return resolve(reader_1.result); }, false);
reader_1.addEventListener('error', function (e) { return reject(e); }, false);
reader_1.readAsDataURL(xhr.response);
}
}
else {
reject("Failed to proxy resource " + key + " with status code " + xhr.status);
}
};
xhr.onerror = reject;
var queryString = proxy.indexOf('?') > -1 ? '&' : '?';
xhr.open('GET', "" + proxy + queryString + "url=" + encodeURIComponent(src) + "&responseType=" + responseType);
if (responseType !== 'text' && xhr instanceof XMLHttpRequest) {
xhr.responseType = responseType;
}
if (_this._options.imageTimeout) {
var timeout_1 = _this._options.imageTimeout;
xhr.timeout = timeout_1;
xhr.ontimeout = function () { return reject("Timed out (" + timeout_1 + "ms) proxying " + key); };
}
xhr.send();
});
};
return Cache;
}());
exports.Cache = Cache;
var INLINE_SVG = /^data:image\/svg\+xml/i;
var INLINE_BASE64 = /^data:image\/.*;base64,/i;
var INLINE_IMG = /^data:image\/.*/i;
var isRenderable = function (src) { return features_1.FEATURES.SUPPORT_SVG_DRAWING || !isSVG(src); };
var isInlineImage = function (src) { return INLINE_IMG.test(src); };
var isInlineBase64Image = function (src) { return INLINE_BASE64.test(src); };
var isBlobImage = function (src) { return src.substr(0, 4) === 'blob'; };
var isSVG = function (src) { return src.substr(-3).toLowerCase() === 'svg' || INLINE_SVG.test(src); };
//# sourceMappingURL=cache-storage.js.map

1
dist/lib/core/cache-storage.js.map vendored Normal file

File diff suppressed because one or more lines are too long

18
dist/lib/core/context.js vendored Normal file
View File

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Context = void 0;
var logger_1 = require("./logger");
var cache_storage_1 = require("./cache-storage");
var Context = /** @class */ (function () {
function Context(options, windowBounds) {
var _a;
this.windowBounds = windowBounds;
this.instanceName = "#" + Context.instanceCount++;
this.logger = new logger_1.Logger({ id: this.instanceName, enabled: options.logging });
this.cache = (_a = options.cache) !== null && _a !== void 0 ? _a : new cache_storage_1.Cache(this, options);
}
Context.instanceCount = 1;
return Context;
}());
exports.Context = Context;
//# sourceMappingURL=context.js.map

1
dist/lib/core/context.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/core/context.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,iDAAuD;AAQvD;IAOI,iBAAY,OAAuB,EAAS,YAAoB;;QAApB,iBAAY,GAAZ,YAAY,CAAQ;QAN/C,iBAAY,GAAG,MAAI,OAAO,CAAC,aAAa,EAAI,CAAC;QAO1D,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,EAAC,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,KAAK,GAAG,MAAA,OAAO,CAAC,KAAK,mCAAI,IAAI,qBAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IALc,qBAAa,GAAG,CAAC,CAAC;IAMrC,cAAC;CAAA,AAXD,IAWC;AAXY,0BAAO"}

25
dist/lib/core/debugger.js vendored Normal file
View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isDebugging = void 0;
var elementDebuggerAttribute = 'data-html2canvas-debug';
var getElementDebugType = function (element) {
var attribute = element.getAttribute(elementDebuggerAttribute);
switch (attribute) {
case 'all':
return 1 /* ALL */;
case 'clone':
return 2 /* CLONE */;
case 'parse':
return 3 /* PARSE */;
case 'render':
return 4 /* RENDER */;
default:
return 0 /* NONE */;
}
};
var isDebugging = function (element, type) {
var elementType = getElementDebugType(element);
return elementType === 1 /* ALL */ || type === elementType;
};
exports.isDebugging = isDebugging;
//# sourceMappingURL=debugger.js.map

1
dist/lib/core/debugger.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../../../src/core/debugger.ts"],"names":[],"mappings":";;;AAAA,IAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAS1D,IAAM,mBAAmB,GAAG,UAAC,OAAgB;IACzC,IAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC,CAAC;IACjE,QAAQ,SAAS,EAAE;QACf,KAAK,KAAK;YACN,mBAAwB;QAC5B,KAAK,OAAO;YACR,qBAA0B;QAC9B,KAAK,OAAO;YACR,qBAA0B;QAC9B,KAAK,QAAQ;YACT,sBAA2B;QAC/B;YACI,oBAAyB;KAChC;AACL,CAAC,CAAC;AAEK,IAAM,WAAW,GAAG,UAAC,OAAgB,EAAE,IAA2C;IACrF,IAAM,WAAW,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,WAAW,gBAAqB,IAAI,IAAI,KAAK,WAAW,CAAC;AACpE,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB"}

193
dist/lib/core/features.js vendored Normal file
View File

@ -0,0 +1,193 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FEATURES = exports.loadSerializedSVG = exports.createForeignObjectSVG = void 0;
var css_line_break_1 = require("css-line-break");
var testRangeBounds = function (document) {
var TEST_HEIGHT = 123;
if (document.createRange) {
var range = document.createRange();
if (range.getBoundingClientRect) {
var testElement = document.createElement('boundtest');
testElement.style.height = TEST_HEIGHT + "px";
testElement.style.display = 'block';
document.body.appendChild(testElement);
range.selectNode(testElement);
var rangeBounds = range.getBoundingClientRect();
var rangeHeight = Math.round(rangeBounds.height);
document.body.removeChild(testElement);
if (rangeHeight === TEST_HEIGHT) {
return true;
}
}
}
return false;
};
var testIOSLineBreak = function (document) {
var testElement = document.createElement('boundtest');
testElement.style.width = '50px';
testElement.style.display = 'block';
testElement.style.fontSize = '12px';
testElement.style.letterSpacing = '0px';
testElement.style.wordSpacing = '0px';
document.body.appendChild(testElement);
var range = document.createRange();
testElement.innerHTML = typeof ''.repeat === 'function' ? '&#128104;'.repeat(10) : '';
var node = testElement.firstChild;
var textList = css_line_break_1.toCodePoints(node.data).map(function (i) { return css_line_break_1.fromCodePoint(i); });
var offset = 0;
var prev = {};
// ios 13 does not handle range getBoundingClientRect line changes correctly #2177
var supports = textList.every(function (text, i) {
range.setStart(node, offset);
range.setEnd(node, offset + text.length);
var rect = range.getBoundingClientRect();
offset += text.length;
var boundAhead = rect.x > prev.x || rect.y > prev.y;
prev = rect;
if (i === 0) {
return true;
}
return boundAhead;
});
document.body.removeChild(testElement);
return supports;
};
var testCORS = function () { return typeof new Image().crossOrigin !== 'undefined'; };
var testResponseType = function () { return typeof new XMLHttpRequest().responseType === 'string'; };
var testSVG = function (document) {
var img = new Image();
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
if (!ctx) {
return false;
}
img.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
try {
ctx.drawImage(img, 0, 0);
canvas.toDataURL();
}
catch (e) {
return false;
}
return true;
};
var isGreenPixel = function (data) {
return data[0] === 0 && data[1] === 255 && data[2] === 0 && data[3] === 255;
};
var testForeignObject = function (document) {
var canvas = document.createElement('canvas');
var size = 100;
canvas.width = size;
canvas.height = size;
var ctx = canvas.getContext('2d');
if (!ctx) {
return Promise.reject(false);
}
ctx.fillStyle = 'rgb(0, 255, 0)';
ctx.fillRect(0, 0, size, size);
var img = new Image();
var greenImageSrc = canvas.toDataURL();
img.src = greenImageSrc;
var svg = exports.createForeignObjectSVG(size, size, 0, 0, img);
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, size, size);
return exports.loadSerializedSVG(svg)
.then(function (img) {
ctx.drawImage(img, 0, 0);
var data = ctx.getImageData(0, 0, size, size).data;
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, size, size);
var node = document.createElement('div');
node.style.backgroundImage = "url(" + greenImageSrc + ")";
node.style.height = size + "px";
// Firefox 55 does not render inline <img /> tags
return isGreenPixel(data)
? exports.loadSerializedSVG(exports.createForeignObjectSVG(size, size, 0, 0, node))
: Promise.reject(false);
})
.then(function (img) {
ctx.drawImage(img, 0, 0);
// Edge does not render background-images
return isGreenPixel(ctx.getImageData(0, 0, size, size).data);
})
.catch(function () { return false; });
};
var createForeignObjectSVG = function (width, height, x, y, node) {
var xmlns = 'http://www.w3.org/2000/svg';
var svg = document.createElementNS(xmlns, 'svg');
var foreignObject = document.createElementNS(xmlns, 'foreignObject');
svg.setAttributeNS(null, 'width', width.toString());
svg.setAttributeNS(null, 'height', height.toString());
foreignObject.setAttributeNS(null, 'width', '100%');
foreignObject.setAttributeNS(null, 'height', '100%');
foreignObject.setAttributeNS(null, 'x', x.toString());
foreignObject.setAttributeNS(null, 'y', y.toString());
foreignObject.setAttributeNS(null, 'externalResourcesRequired', 'true');
svg.appendChild(foreignObject);
foreignObject.appendChild(node);
return svg;
};
exports.createForeignObjectSVG = createForeignObjectSVG;
var loadSerializedSVG = function (svg) {
return new Promise(function (resolve, reject) {
var img = new Image();
img.onload = function () { return resolve(img); };
img.onerror = reject;
img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg));
});
};
exports.loadSerializedSVG = loadSerializedSVG;
exports.FEATURES = {
get SUPPORT_RANGE_BOUNDS() {
'use strict';
var value = testRangeBounds(document);
Object.defineProperty(exports.FEATURES, 'SUPPORT_RANGE_BOUNDS', { value: value });
return value;
},
get SUPPORT_WORD_BREAKING() {
'use strict';
var value = exports.FEATURES.SUPPORT_RANGE_BOUNDS && testIOSLineBreak(document);
Object.defineProperty(exports.FEATURES, 'SUPPORT_WORD_BREAKING', { value: value });
return value;
},
get SUPPORT_SVG_DRAWING() {
'use strict';
var value = testSVG(document);
Object.defineProperty(exports.FEATURES, 'SUPPORT_SVG_DRAWING', { value: value });
return value;
},
get SUPPORT_FOREIGNOBJECT_DRAWING() {
'use strict';
var value = typeof Array.from === 'function' && typeof window.fetch === 'function'
? testForeignObject(document)
: Promise.resolve(false);
Object.defineProperty(exports.FEATURES, 'SUPPORT_FOREIGNOBJECT_DRAWING', { value: value });
return value;
},
get SUPPORT_CORS_IMAGES() {
'use strict';
var value = testCORS();
Object.defineProperty(exports.FEATURES, 'SUPPORT_CORS_IMAGES', { value: value });
return value;
},
get SUPPORT_RESPONSE_TYPE() {
'use strict';
var value = testResponseType();
Object.defineProperty(exports.FEATURES, 'SUPPORT_RESPONSE_TYPE', { value: value });
return value;
},
get SUPPORT_CORS_XHR() {
'use strict';
var value = 'withCredentials' in new XMLHttpRequest();
Object.defineProperty(exports.FEATURES, 'SUPPORT_CORS_XHR', { value: value });
return value;
},
get SUPPORT_NATIVE_TEXT_SEGMENTATION() {
'use strict';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var value = !!(typeof Intl !== 'undefined' && Intl.Segmenter);
Object.defineProperty(exports.FEATURES, 'SUPPORT_NATIVE_TEXT_SEGMENTATION', { value: value });
return value;
}
};
//# sourceMappingURL=features.js.map

1
dist/lib/core/features.js.map vendored Normal file

File diff suppressed because one or more lines are too long

88
dist/lib/core/logger.js vendored Normal file
View File

@ -0,0 +1,88 @@
"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = void 0;
var Logger = /** @class */ (function () {
function Logger(_a) {
var id = _a.id, enabled = _a.enabled;
this.id = id;
this.enabled = enabled;
this.start = Date.now();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Logger.prototype.debug = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (this.enabled) {
// eslint-disable-next-line no-console
if (typeof window !== 'undefined' && window.console && typeof console.debug === 'function') {
// eslint-disable-next-line no-console
console.debug.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
}
else {
this.info.apply(this, args);
}
}
};
Logger.prototype.getTime = function () {
return Date.now() - this.start;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Logger.prototype.info = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (this.enabled) {
// eslint-disable-next-line no-console
if (typeof window !== 'undefined' && window.console && typeof console.info === 'function') {
// eslint-disable-next-line no-console
console.info.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
}
}
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Logger.prototype.warn = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (this.enabled) {
// eslint-disable-next-line no-console
if (typeof window !== 'undefined' && window.console && typeof console.warn === 'function') {
// eslint-disable-next-line no-console
console.warn.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
}
else {
this.info.apply(this, args);
}
}
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Logger.prototype.error = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (this.enabled) {
// eslint-disable-next-line no-console
if (typeof window !== 'undefined' && window.console && typeof console.error === 'function') {
// eslint-disable-next-line no-console
console.error.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
}
else {
this.info.apply(this, args);
}
}
};
Logger.instances = {};
return Logger;
}());
exports.Logger = Logger;
//# sourceMappingURL=logger.js.map

1
dist/lib/core/logger.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/core/logger.ts"],"names":[],"mappings":";;;;;;;;AAKA;IAOI,gBAAY,EAA4B;YAA3B,EAAE,QAAA,EAAE,OAAO,aAAA;QACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED,8DAA8D;IAC9D,sBAAK,GAAL;QAAM,cAAkB;aAAlB,UAAkB,EAAlB,qBAAkB,EAAlB,IAAkB;YAAlB,yBAAkB;;QACpB,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,sCAAsC;YACtC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,OAAO,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU,EAAE;gBACxF,sCAAsC;gBACtC,OAAO,CAAC,KAAK,OAAb,OAAO,iBAAO,IAAI,CAAC,EAAE,EAAK,IAAI,CAAC,OAAO,EAAE,OAAI,GAAK,IAAI,GAAE;aAC1D;iBAAM;gBACH,IAAI,CAAC,IAAI,OAAT,IAAI,EAAS,IAAI,EAAE;aACtB;SACJ;IACL,CAAC;IAED,wBAAO,GAAP;QACI,OA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KAAK,UAAU,EAAE;gBACxF,sCAAsC;gBACtC,OAAO,CAAC,KAAK,OAAb,OAAO,iBAAO,IAAI,CAAC,EAAE,EAAK,IAAI,CAAC,OAAO,EAAE,OAAI,GAAK,IAAI,GAAE;aAC1D;iBAAM;gBACH,IAAI,CAAC,IAAI,OAAT,IAAI,EAAS,IAAI,EAAE;aACtB;SACJ;IACL,CAAC;IAhEM,gBAAS,GAA4B,EAAE,CAAC;IAiEnD,aAAC;CAAA,AAlED,IAkEC;AAlEY,wBAAM"}

5
dist/lib/core/util.js vendored Normal file
View File

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SMALL_IMAGE = void 0;
exports.SMALL_IMAGE = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
//# sourceMappingURL=util.js.map

1
dist/lib/core/util.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/core/util.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,gFAAgF,CAAC"}

3
dist/lib/css/IPropertyDescriptor.js vendored Normal file
View File

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

View File

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

3
dist/lib/css/ITypeDescriptor.js vendored Normal file
View File

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

1
dist/lib/css/ITypeDescriptor.js.map vendored Normal file
View File

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

216
dist/lib/css/index.js vendored Normal file
View File

@ -0,0 +1,216 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CSSParsedCounterDeclaration = exports.CSSParsedPseudoDeclaration = exports.CSSParsedDeclaration = void 0;
var background_clip_1 = require("./property-descriptors/background-clip");
var background_color_1 = require("./property-descriptors/background-color");
var background_image_1 = require("./property-descriptors/background-image");
var background_origin_1 = require("./property-descriptors/background-origin");
var background_position_1 = require("./property-descriptors/background-position");
var background_repeat_1 = require("./property-descriptors/background-repeat");
var background_size_1 = require("./property-descriptors/background-size");
var border_color_1 = require("./property-descriptors/border-color");
var border_radius_1 = require("./property-descriptors/border-radius");
var border_style_1 = require("./property-descriptors/border-style");
var border_width_1 = require("./property-descriptors/border-width");
var color_1 = require("./property-descriptors/color");
var direction_1 = require("./property-descriptors/direction");
var display_1 = require("./property-descriptors/display");
var float_1 = require("./property-descriptors/float");
var letter_spacing_1 = require("./property-descriptors/letter-spacing");
var line_break_1 = require("./property-descriptors/line-break");
var line_height_1 = require("./property-descriptors/line-height");
var list_style_image_1 = require("./property-descriptors/list-style-image");
var list_style_position_1 = require("./property-descriptors/list-style-position");
var list_style_type_1 = require("./property-descriptors/list-style-type");
var margin_1 = require("./property-descriptors/margin");
var overflow_1 = require("./property-descriptors/overflow");
var overflow_wrap_1 = require("./property-descriptors/overflow-wrap");
var padding_1 = require("./property-descriptors/padding");
var text_align_1 = require("./property-descriptors/text-align");
var position_1 = require("./property-descriptors/position");
var text_shadow_1 = require("./property-descriptors/text-shadow");
var text_transform_1 = require("./property-descriptors/text-transform");
var transform_1 = require("./property-descriptors/transform");
var transform_origin_1 = require("./property-descriptors/transform-origin");
var visibility_1 = require("./property-descriptors/visibility");
var word_break_1 = require("./property-descriptors/word-break");
var z_index_1 = require("./property-descriptors/z-index");
var parser_1 = require("./syntax/parser");
var tokenizer_1 = require("./syntax/tokenizer");
var color_2 = require("./types/color");
var angle_1 = require("./types/angle");
var image_1 = require("./types/image");
var time_1 = require("./types/time");
var opacity_1 = require("./property-descriptors/opacity");
var text_decoration_color_1 = require("./property-descriptors/text-decoration-color");
var text_decoration_line_1 = require("./property-descriptors/text-decoration-line");
var length_percentage_1 = require("./types/length-percentage");
var font_family_1 = require("./property-descriptors/font-family");
var font_size_1 = require("./property-descriptors/font-size");
var length_1 = require("./types/length");
var font_weight_1 = require("./property-descriptors/font-weight");
var font_variant_1 = require("./property-descriptors/font-variant");
var font_style_1 = require("./property-descriptors/font-style");
var bitwise_1 = require("../core/bitwise");
var content_1 = require("./property-descriptors/content");
var counter_increment_1 = require("./property-descriptors/counter-increment");
var counter_reset_1 = require("./property-descriptors/counter-reset");
var duration_1 = require("./property-descriptors/duration");
var quotes_1 = require("./property-descriptors/quotes");
var box_shadow_1 = require("./property-descriptors/box-shadow");
var paint_order_1 = require("./property-descriptors/paint-order");
var webkit_text_stroke_color_1 = require("./property-descriptors/webkit-text-stroke-color");
var webkit_text_stroke_width_1 = require("./property-descriptors/webkit-text-stroke-width");
var CSSParsedDeclaration = /** @class */ (function () {
function CSSParsedDeclaration(context, declaration) {
var _a, _b;
this.animationDuration = parse(context, duration_1.duration, declaration.animationDuration);
this.backgroundClip = parse(context, background_clip_1.backgroundClip, declaration.backgroundClip);
this.backgroundColor = parse(context, background_color_1.backgroundColor, declaration.backgroundColor);
this.backgroundImage = parse(context, background_image_1.backgroundImage, declaration.backgroundImage);
this.backgroundOrigin = parse(context, background_origin_1.backgroundOrigin, declaration.backgroundOrigin);
this.backgroundPosition = parse(context, background_position_1.backgroundPosition, declaration.backgroundPosition);
this.backgroundRepeat = parse(context, background_repeat_1.backgroundRepeat, declaration.backgroundRepeat);
this.backgroundSize = parse(context, background_size_1.backgroundSize, declaration.backgroundSize);
this.borderTopColor = parse(context, border_color_1.borderTopColor, declaration.borderTopColor);
this.borderRightColor = parse(context, border_color_1.borderRightColor, declaration.borderRightColor);
this.borderBottomColor = parse(context, border_color_1.borderBottomColor, declaration.borderBottomColor);
this.borderLeftColor = parse(context, border_color_1.borderLeftColor, declaration.borderLeftColor);
this.borderTopLeftRadius = parse(context, border_radius_1.borderTopLeftRadius, declaration.borderTopLeftRadius);
this.borderTopRightRadius = parse(context, border_radius_1.borderTopRightRadius, declaration.borderTopRightRadius);
this.borderBottomRightRadius = parse(context, border_radius_1.borderBottomRightRadius, declaration.borderBottomRightRadius);
this.borderBottomLeftRadius = parse(context, border_radius_1.borderBottomLeftRadius, declaration.borderBottomLeftRadius);
this.borderTopStyle = parse(context, border_style_1.borderTopStyle, declaration.borderTopStyle);
this.borderRightStyle = parse(context, border_style_1.borderRightStyle, declaration.borderRightStyle);
this.borderBottomStyle = parse(context, border_style_1.borderBottomStyle, declaration.borderBottomStyle);
this.borderLeftStyle = parse(context, border_style_1.borderLeftStyle, declaration.borderLeftStyle);
this.borderTopWidth = parse(context, border_width_1.borderTopWidth, declaration.borderTopWidth);
this.borderRightWidth = parse(context, border_width_1.borderRightWidth, declaration.borderRightWidth);
this.borderBottomWidth = parse(context, border_width_1.borderBottomWidth, declaration.borderBottomWidth);
this.borderLeftWidth = parse(context, border_width_1.borderLeftWidth, declaration.borderLeftWidth);
this.boxShadow = parse(context, box_shadow_1.boxShadow, declaration.boxShadow);
this.color = parse(context, color_1.color, declaration.color);
this.direction = parse(context, direction_1.direction, declaration.direction);
this.display = parse(context, display_1.display, declaration.display);
this.float = parse(context, float_1.float, declaration.cssFloat);
this.fontFamily = parse(context, font_family_1.fontFamily, declaration.fontFamily);
this.fontSize = parse(context, font_size_1.fontSize, declaration.fontSize);
this.fontStyle = parse(context, font_style_1.fontStyle, declaration.fontStyle);
this.fontVariant = parse(context, font_variant_1.fontVariant, declaration.fontVariant);
this.fontWeight = parse(context, font_weight_1.fontWeight, declaration.fontWeight);
this.letterSpacing = parse(context, letter_spacing_1.letterSpacing, declaration.letterSpacing);
this.lineBreak = parse(context, line_break_1.lineBreak, declaration.lineBreak);
this.lineHeight = parse(context, line_height_1.lineHeight, declaration.lineHeight);
this.listStyleImage = parse(context, list_style_image_1.listStyleImage, declaration.listStyleImage);
this.listStylePosition = parse(context, list_style_position_1.listStylePosition, declaration.listStylePosition);
this.listStyleType = parse(context, list_style_type_1.listStyleType, declaration.listStyleType);
this.marginTop = parse(context, margin_1.marginTop, declaration.marginTop);
this.marginRight = parse(context, margin_1.marginRight, declaration.marginRight);
this.marginBottom = parse(context, margin_1.marginBottom, declaration.marginBottom);
this.marginLeft = parse(context, margin_1.marginLeft, declaration.marginLeft);
this.opacity = parse(context, opacity_1.opacity, declaration.opacity);
var overflowTuple = parse(context, overflow_1.overflow, declaration.overflow);
this.overflowX = overflowTuple[0];
this.overflowY = overflowTuple[overflowTuple.length > 1 ? 1 : 0];
this.overflowWrap = parse(context, overflow_wrap_1.overflowWrap, declaration.overflowWrap);
this.paddingTop = parse(context, padding_1.paddingTop, declaration.paddingTop);
this.paddingRight = parse(context, padding_1.paddingRight, declaration.paddingRight);
this.paddingBottom = parse(context, padding_1.paddingBottom, declaration.paddingBottom);
this.paddingLeft = parse(context, padding_1.paddingLeft, declaration.paddingLeft);
this.paintOrder = parse(context, paint_order_1.paintOrder, declaration.paintOrder);
this.position = parse(context, position_1.position, declaration.position);
this.textAlign = parse(context, text_align_1.textAlign, declaration.textAlign);
this.textDecorationColor = parse(context, text_decoration_color_1.textDecorationColor, (_a = declaration.textDecorationColor) !== null && _a !== void 0 ? _a : declaration.color);
this.textDecorationLine = parse(context, text_decoration_line_1.textDecorationLine, (_b = declaration.textDecorationLine) !== null && _b !== void 0 ? _b : declaration.textDecoration);
this.textShadow = parse(context, text_shadow_1.textShadow, declaration.textShadow);
this.textTransform = parse(context, text_transform_1.textTransform, declaration.textTransform);
this.transform = parse(context, transform_1.transform, declaration.transform);
this.transformOrigin = parse(context, transform_origin_1.transformOrigin, declaration.transformOrigin);
this.visibility = parse(context, visibility_1.visibility, declaration.visibility);
this.webkitTextStrokeColor = parse(context, webkit_text_stroke_color_1.webkitTextStrokeColor, declaration.webkitTextStrokeColor);
this.webkitTextStrokeWidth = parse(context, webkit_text_stroke_width_1.webkitTextStrokeWidth, declaration.webkitTextStrokeWidth);
this.wordBreak = parse(context, word_break_1.wordBreak, declaration.wordBreak);
this.zIndex = parse(context, z_index_1.zIndex, declaration.zIndex);
}
CSSParsedDeclaration.prototype.isVisible = function () {
return this.display > 0 && this.opacity > 0 && this.visibility === 0 /* VISIBLE */;
};
CSSParsedDeclaration.prototype.isTransparent = function () {
return color_2.isTransparent(this.backgroundColor);
};
CSSParsedDeclaration.prototype.isTransformed = function () {
return this.transform !== null;
};
CSSParsedDeclaration.prototype.isPositioned = function () {
return this.position !== 0 /* STATIC */;
};
CSSParsedDeclaration.prototype.isPositionedWithZIndex = function () {
return this.isPositioned() && !this.zIndex.auto;
};
CSSParsedDeclaration.prototype.isFloating = function () {
return this.float !== 0 /* NONE */;
};
CSSParsedDeclaration.prototype.isInlineLevel = function () {
return (bitwise_1.contains(this.display, 4 /* INLINE */) ||
bitwise_1.contains(this.display, 33554432 /* INLINE_BLOCK */) ||
bitwise_1.contains(this.display, 268435456 /* INLINE_FLEX */) ||
bitwise_1.contains(this.display, 536870912 /* INLINE_GRID */) ||
bitwise_1.contains(this.display, 67108864 /* INLINE_LIST_ITEM */) ||
bitwise_1.contains(this.display, 134217728 /* INLINE_TABLE */));
};
return CSSParsedDeclaration;
}());
exports.CSSParsedDeclaration = CSSParsedDeclaration;
var CSSParsedPseudoDeclaration = /** @class */ (function () {
function CSSParsedPseudoDeclaration(context, declaration) {
this.content = parse(context, content_1.content, declaration.content);
this.quotes = parse(context, quotes_1.quotes, declaration.quotes);
}
return CSSParsedPseudoDeclaration;
}());
exports.CSSParsedPseudoDeclaration = CSSParsedPseudoDeclaration;
var CSSParsedCounterDeclaration = /** @class */ (function () {
function CSSParsedCounterDeclaration(context, declaration) {
this.counterIncrement = parse(context, counter_increment_1.counterIncrement, declaration.counterIncrement);
this.counterReset = parse(context, counter_reset_1.counterReset, declaration.counterReset);
}
return CSSParsedCounterDeclaration;
}());
exports.CSSParsedCounterDeclaration = CSSParsedCounterDeclaration;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var parse = function (context, descriptor, style) {
var tokenizer = new tokenizer_1.Tokenizer();
var value = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue;
tokenizer.write(value);
var parser = new parser_1.Parser(tokenizer.read());
switch (descriptor.type) {
case 2 /* IDENT_VALUE */:
var token = parser.parseComponentValue();
return descriptor.parse(context, parser_1.isIdentToken(token) ? token.value : descriptor.initialValue);
case 0 /* VALUE */:
return descriptor.parse(context, parser.parseComponentValue());
case 1 /* LIST */:
return descriptor.parse(context, parser.parseComponentValues());
case 4 /* TOKEN_VALUE */:
return parser.parseComponentValue();
case 3 /* TYPE_VALUE */:
switch (descriptor.format) {
case 'angle':
return angle_1.angle.parse(context, parser.parseComponentValue());
case 'color':
return color_2.color.parse(context, parser.parseComponentValue());
case 'image':
return image_1.image.parse(context, parser.parseComponentValue());
case 'length':
var length_2 = parser.parseComponentValue();
return length_1.isLength(length_2) ? length_2 : length_percentage_1.ZERO_LENGTH;
case 'length-percentage':
var value_1 = parser.parseComponentValue();
return length_percentage_1.isLengthPercentage(value_1) ? value_1 : length_percentage_1.ZERO_LENGTH;
case 'time':
return time_1.time.parse(context, parser.parseComponentValue());
}
break;
}
};
//# sourceMappingURL=index.js.map

1
dist/lib/css/index.js.map vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseBounds = exports.Bounds = void 0;
exports.Bounds = jest.requireActual('../bounds').Bounds;
var parseBounds = function () {
return new exports.Bounds(0, 0, 200, 50);
};
exports.parseBounds = parseBounds;
//# sourceMappingURL=bounds.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"bounds.js","sourceRoot":"","sources":["../../../../../src/css/layout/__mocks__/bounds.ts"],"names":[],"mappings":";;;AAAc,QAAA,MAAM,GAAI,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,QAAC;AACjD,IAAM,WAAW,GAAG;IACvB,OAAO,IAAI,cAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB"}

42
dist/lib/css/layout/bounds.js vendored Normal file
View File

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseDocumentSize = exports.parseBounds = exports.Bounds = void 0;
var Bounds = /** @class */ (function () {
function Bounds(left, top, width, height) {
this.left = left;
this.top = top;
this.width = width;
this.height = height;
}
Bounds.prototype.add = function (x, y, w, h) {
return new Bounds(this.left + x, this.top + y, this.width + w, this.height + h);
};
Bounds.fromClientRect = function (context, clientRect) {
return new Bounds(clientRect.left + context.windowBounds.left, clientRect.top + context.windowBounds.top, clientRect.width, clientRect.height);
};
Bounds.fromDOMRectList = function (context, domRectList) {
var domRect = Array.from(domRectList).find(function (rect) { return rect.width !== 0; });
return domRect
? new Bounds(domRect.left + context.windowBounds.left, domRect.top + context.windowBounds.top, domRect.width, domRect.height)
: Bounds.EMPTY;
};
Bounds.EMPTY = new Bounds(0, 0, 0, 0);
return Bounds;
}());
exports.Bounds = Bounds;
var parseBounds = function (context, node) {
return Bounds.fromClientRect(context, node.getBoundingClientRect());
};
exports.parseBounds = parseBounds;
var parseDocumentSize = function (document) {
var body = document.body;
var documentElement = document.documentElement;
if (!body || !documentElement) {
throw new Error("Unable to get document size");
}
var width = Math.max(Math.max(body.scrollWidth, documentElement.scrollWidth), Math.max(body.offsetWidth, documentElement.offsetWidth), Math.max(body.clientWidth, documentElement.clientWidth));
var height = Math.max(Math.max(body.scrollHeight, documentElement.scrollHeight), Math.max(body.offsetHeight, documentElement.offsetHeight), Math.max(body.clientHeight, documentElement.clientHeight));
return new Bounds(0, 0, width, height);
};
exports.parseDocumentSize = parseDocumentSize;
//# sourceMappingURL=bounds.js.map

1
dist/lib/css/layout/bounds.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"bounds.js","sourceRoot":"","sources":["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AAC,CAAC;AAC3C,CAAC,CAAC;AApBW,QAAA,iBAAiB,qBAoB5B"}

137
dist/lib/css/layout/text.js vendored Normal file
View File

@ -0,0 +1,137 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.segmentGraphemes = exports.parseTextBounds = exports.TextBounds = void 0;
var css_line_break_1 = require("css-line-break");
var text_segmentation_1 = require("text-segmentation");
var bounds_1 = require("./bounds");
var features_1 = require("../../core/features");
var TextBounds = /** @class */ (function () {
function TextBounds(text, bounds) {
this.text = text;
this.bounds = bounds;
}
return TextBounds;
}());
exports.TextBounds = TextBounds;
var parseTextBounds = function (context, value, styles, node) {
var textList = breakText(value, styles);
var textBounds = [];
var offset = 0;
textList.forEach(function (text) {
if (styles.textDecorationLine.length || text.trim().length > 0) {
if (features_1.FEATURES.SUPPORT_RANGE_BOUNDS) {
var clientRects = createRange(node, offset, text.length).getClientRects();
if (clientRects.length > 1) {
var subSegments = exports.segmentGraphemes(text);
var subOffset_1 = 0;
subSegments.forEach(function (subSegment) {
textBounds.push(new TextBounds(subSegment, bounds_1.Bounds.fromDOMRectList(context, createRange(node, subOffset_1 + offset, subSegment.length).getClientRects())));
subOffset_1 += subSegment.length;
});
}
else {
textBounds.push(new TextBounds(text, bounds_1.Bounds.fromDOMRectList(context, clientRects)));
}
}
else {
var replacementNode = node.splitText(text.length);
textBounds.push(new TextBounds(text, getWrapperBounds(context, node)));
node = replacementNode;
}
}
else if (!features_1.FEATURES.SUPPORT_RANGE_BOUNDS) {
node = node.splitText(text.length);
}
offset += text.length;
});
return textBounds;
};
exports.parseTextBounds = parseTextBounds;
var getWrapperBounds = function (context, node) {
var ownerDocument = node.ownerDocument;
if (ownerDocument) {
var wrapper = ownerDocument.createElement('html2canvaswrapper');
wrapper.appendChild(node.cloneNode(true));
var parentNode = node.parentNode;
if (parentNode) {
parentNode.replaceChild(wrapper, node);
var bounds = bounds_1.parseBounds(context, wrapper);
if (wrapper.firstChild) {
parentNode.replaceChild(wrapper.firstChild, wrapper);
}
return bounds;
}
}
return bounds_1.Bounds.EMPTY;
};
var createRange = function (node, offset, length) {
var ownerDocument = node.ownerDocument;
if (!ownerDocument) {
throw new Error('Node has no owner document');
}
var range = ownerDocument.createRange();
range.setStart(node, offset);
range.setEnd(node, offset + length);
return range;
};
var segmentGraphemes = function (value) {
if (features_1.FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var segmenter = new Intl.Segmenter(void 0, { granularity: 'grapheme' });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return Array.from(segmenter.segment(value)).map(function (segment) { return segment.segment; });
}
return text_segmentation_1.splitGraphemes(value);
};
exports.segmentGraphemes = segmentGraphemes;
var segmentWords = function (value, styles) {
if (features_1.FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var segmenter = new Intl.Segmenter(void 0, {
granularity: 'word'
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return Array.from(segmenter.segment(value)).map(function (segment) { return segment.segment; });
}
return breakWords(value, styles);
};
var breakText = function (value, styles) {
return styles.letterSpacing !== 0 ? exports.segmentGraphemes(value) : segmentWords(value, styles);
};
// https://drafts.csswg.org/css-text/#word-separator
var wordSeparators = [0x0020, 0x00a0, 0x1361, 0x10100, 0x10101, 0x1039, 0x1091];
var breakWords = function (str, styles) {
var breaker = css_line_break_1.LineBreaker(str, {
lineBreak: styles.lineBreak,
wordBreak: styles.overflowWrap === "break-word" /* BREAK_WORD */ ? 'break-word' : styles.wordBreak
});
var words = [];
var bk;
var _loop_1 = function () {
if (bk.value) {
var value = bk.value.slice();
var codePoints = css_line_break_1.toCodePoints(value);
var word_1 = '';
codePoints.forEach(function (codePoint) {
if (wordSeparators.indexOf(codePoint) === -1) {
word_1 += css_line_break_1.fromCodePoint(codePoint);
}
else {
if (word_1.length) {
words.push(word_1);
}
words.push(css_line_break_1.fromCodePoint(codePoint));
word_1 = '';
}
});
if (word_1.length) {
words.push(word_1);
}
}
};
while (!(bk = breaker.next()).done) {
_loop_1();
}
return words;
};
//# sourceMappingURL=text.js.map

1
dist/lib/css/layout/text.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../../src/css/layout/text.ts"],"names":[],"mappings":";;;AAEA,iDAAwE;AACxE,uDAAiD;AACjD,mCAA6C;AAC7C,gDAA6C;AAG7C;IAII,oBAAY,IAAY,EAAE,MAAc;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IACL,iBAAC;AAAD,CAAC,AARD,IAQC;AARY,gCAAU;AAUhB,IAAM,eAAe,GAAG,UAC3B,OAAgB,EAChB,KAAa,EACb,MAA4B,EAC5B,IAAU;IAEV,IAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC1C,IAAM,UAAU,GAAiB,EAAE,CAAC;IACpC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,QAAQ,CAAC,OAAO,CAAC,UAAC,IAAI;QAClB,IAAI,MAAM,CAAC,kBAAkB,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5D,IAAI,mBAAQ,CAAC,oBAAoB,EAAE;gBAC/B,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,CAAC;gBAC5E,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;oBACxB,IAAM,WAAW,GAAG,wBAAgB,CAAC,IAAI,CAAC,CAAC;oBAC3C,IAAI,WAAS,GAAG,CAAC,CAAC;oBAClB,WAAW,CAAC,OAAO,CAAC,UAAC,UAAU;wBAC3B,UAAU,CAAC,IAAI,CACX,IAAI,UAAU,CACV,UAAU,EACV,eAAM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AK,EAAE,CAAC;YAC/B,IAAM,UAAU,GAAG,6BAAY,CAAC,KAAK,CAAC,CAAC;YACvC,IAAI,MAAI,GAAG,EAAE,CAAC;YACd,UAAU,CAAC,OAAO,CAAC,UAAC,SAAS;gBACzB,IAAI,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE;oBAC1C,MAAI,IAAI,8BAAa,CAAC,SAAS,CAAC,CAAC;iBACpC;qBAAM;oBACH,IAAI,MAAI,CAAC,MAAM,EAAE;wBACb,KAAK,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;qBACpB;oBACD,KAAK,CAAC,IAAI,CAAC,8BAAa,CAAC,SAAS,CAAC,CAAC,CAAC;oBACrC,MAAI,GAAG,EAAE,CAAC;iBACb;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,MAAI,CAAC,MAAM,EAAE;gBACb,KAAK,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC;aACpB;SACJ;;IApBL,OAAO,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI;;KAqBjC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC"}

View File

@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var assert_1 = require("assert");
var parser_1 = require("../../syntax/parser");
var background_image_1 = require("../background-image");
var color_1 = require("../../types/color");
var angle_1 = require("../../types/angle");
jest.mock('../../../core/context');
var context_1 = require("../../../core/context");
jest.mock('../../../core/features');
var backgroundImageParse = function (context, value) {
return background_image_1.backgroundImage.parse(context, parser_1.Parser.parseValues(value));
};
describe('property-descriptors', function () {
var context;
beforeEach(function () {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
context = new context_1.Context({}, {});
});
describe('background-image', function () {
it('none', function () {
assert_1.deepStrictEqual(backgroundImageParse(context, 'none'), []);
expect(context.cache.addImage).not.toHaveBeenCalled();
});
it('url(test.jpg), url(test2.jpg)', function () {
assert_1.deepStrictEqual(backgroundImageParse(context, 'url(http://example.com/test.jpg), url(http://example.com/test2.jpg)'), [
{ url: 'http://example.com/test.jpg', type: 0 /* URL */ },
{ url: 'http://example.com/test2.jpg', type: 0 /* URL */ }
]);
expect(context.cache.addImage).toHaveBeenCalledWith('http://example.com/test.jpg');
expect(context.cache.addImage).toHaveBeenCalledWith('http://example.com/test2.jpg');
});
it("linear-gradient(to bottom, rgba(255,255,0,0.5), rgba(0,0,255,0.5)), url('https://html2canvas.hertzen.com')", function () {
return assert_1.deepStrictEqual(backgroundImageParse(context, "linear-gradient(to bottom, rgba(255,255,0,0.5), rgba(0,0,255,0.5)), url('https://html2canvas.hertzen.com')"), [
{
angle: angle_1.deg(180),
type: 1 /* LINEAR_GRADIENT */,
stops: [
{ color: color_1.pack(255, 255, 0, 0.5), stop: null },
{ color: color_1.pack(0, 0, 255, 0.5), stop: null }
]
},
{ url: 'https://html2canvas.hertzen.com', type: 0 /* URL */ }
]);
});
});
});
//# sourceMappingURL=background-tests.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"background-tests.js","sourceRoot":"","sources":["../../../../../src/css/property-descriptors/__tests__/background-tests.ts"],"names":[],"mappings":";;AAAA,iCAAuC;AACvC,8CAA2C;AAC3C,wDAAoD;AAEpD,2CAAuC;AACvC,2CAAsC;AAEtC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnC,iDAA8C;AAE9C,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAEpC,IAAM,oBAAoB,GAAG,UAAC,OAAgB,EAAE,KAAa;IACzD,OAAA,kCAAe,CAAC,KAAK,CAAC,OAAO,EAAE,eAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAAzD,CAAyD,CAAC;AAE9D,QAAQ,CAAC,sBAAsB,EAAE;IAC7B,IAAI,OAAgB,CAAC;IACrB,UAAU,CAAC;QACP,8DAA8D;QAC9D,OAAO,GAAG,IAAI,iBAAO,CAAC,EAAS,EAA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,IAAI,aAAkB,EAAC;aACnE,CACJ;QAhBD,CAgBC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var assert_1 = require("assert");
var parser_1 = require("../../syntax/parser");
var font_family_1 = require("../font-family");
var fontFamilyParse = function (value) { return font_family_1.fontFamily.parse({}, parser_1.Parser.parseValues(value)); };
describe('property-descriptors', function () {
describe('font-family', function () {
it('sans-serif', function () { return assert_1.deepEqual(fontFamilyParse('sans-serif'), ['sans-serif']); });
it('great fonts 40 library', function () {
return assert_1.deepEqual(fontFamilyParse('great fonts 40 library'), ["'great fonts 40 library'"]);
});
it('preferred font, "quoted fallback font", font', function () {
return assert_1.deepEqual(fontFamilyParse('preferred font, "quoted fallback font", font'), [
"'preferred font'",
"'quoted fallback font'",
'font'
]);
});
it("'escaping test\\'s font'", function () {
return assert_1.deepEqual(fontFamilyParse("'escaping test\\'s font'"), ["'escaping test's font'"]);
});
});
});
//# sourceMappingURL=font-family.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"font-family.js","sourceRoot":"","sources":["../../../../../src/css/property-descriptors/__tests__/font-family.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AACjC,8CAA2C;AAC3C,8CAA0C;AAG1C,IAAM,eAAe,GAAG,UAAC,KAAa,IAAK,OAAA,wBAAU,CAAC,KAAK,CAAC,EAAa,EAAE,eAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAA1D,CAA0D,CAAC;AAEtG,QAAQ,CAAC,sBAAsB,EAAE;IAC7B,QAAQ,CAAC,aAAa,EAAE;QACpB,EAAE,CAAC,YAAY,EAAE,cAAM,OAAA,kBAAS,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,EAAxD,CAAwD,CAAC,CAAC;QAEjF,EAAE,CAAC,wBAAwB,EAAE;YACzB,OAAA,kBAAS,CAAC,eAAe,CAAC,wBAAwB,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAC;QAAlF,CAAkF,CAAC,CAAC;QAExF,EAAE,CAAC,8CAA8C,EAAE;YAC/C,OAAA,kBAAS,CAAC,eAAe,CAAC,8CAA8C,CAAC,EAAE;gBACvE,kBAAkB;gBAClB,wBAAwB;gBACxB,MAAM;aACT,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,0BAA0B,EAAE;YAC3B,OAAA,kBAAS,CAAC,eAAe,CAAC,0BAA0B,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC;QAAlF,CAAkF,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var assert_1 = require("assert");
var parser_1 = require("../../syntax/parser");
var paint_order_1 = require("../paint-order");
var paintOrderParse = function (value) { return paint_order_1.paintOrder.parse({}, parser_1.Parser.parseValues(value)); };
describe('property-descriptors', function () {
describe('paint-order', function () {
it('none', function () {
return assert_1.deepStrictEqual(paintOrderParse('none'), [
0 /* FILL */,
1 /* STROKE */,
2 /* MARKERS */
]);
});
it('EMPTY', function () {
return assert_1.deepStrictEqual(paintOrderParse(''), [
0 /* FILL */,
1 /* STROKE */,
2 /* MARKERS */
]);
});
it('other values', function () {
return assert_1.deepStrictEqual(paintOrderParse('other values'), [
0 /* FILL */,
1 /* STROKE */,
2 /* MARKERS */
]);
});
it('normal', function () {
return assert_1.deepStrictEqual(paintOrderParse('normal'), [
0 /* FILL */,
1 /* STROKE */,
2 /* MARKERS */
]);
});
it('stroke', function () {
return assert_1.deepStrictEqual(paintOrderParse('stroke'), [
1 /* STROKE */,
0 /* FILL */,
2 /* MARKERS */
]);
});
it('fill', function () {
return assert_1.deepStrictEqual(paintOrderParse('fill'), [
0 /* FILL */,
1 /* STROKE */,
2 /* MARKERS */
]);
});
it('markers', function () {
return assert_1.deepStrictEqual(paintOrderParse('markers'), [
2 /* MARKERS */,
0 /* FILL */,
1 /* STROKE */
]);
});
it('stroke fill', function () {
return assert_1.deepStrictEqual(paintOrderParse('stroke fill'), [
1 /* STROKE */,
0 /* FILL */,
2 /* MARKERS */
]);
});
it('markers stroke', function () {
return assert_1.deepStrictEqual(paintOrderParse('markers stroke'), [
2 /* MARKERS */,
1 /* STROKE */,
0 /* FILL */
]);
});
it('markers stroke fill', function () {
return assert_1.deepStrictEqual(paintOrderParse('markers stroke fill'), [
2 /* MARKERS */,
1 /* STROKE */,
0 /* FILL */
]);
});
it('stroke fill markers', function () {
return assert_1.deepStrictEqual(paintOrderParse('stroke fill markers'), [
1 /* STROKE */,
0 /* FILL */,
2 /* MARKERS */
]);
});
});
});
//# sourceMappingURL=paint-order.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"paint-order.js","sourceRoot":"","sources":["../../../../../src/css/property-descriptors/__tests__/paint-order.ts"],"names":[],"mappings":";;AAAA,iCAAuC;AACvC,8CAA2C;AAC3C,8CAA6D;AAG7D,IAAM,eAAe,GAAG,UAAC,KAAa,IAAK,OAAA,wBAAU,CAAC,KAAK,CAAC,EAAa,EAAE,eAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAA1D,CAA0D,CAAC;AAEtG,QAAQ,CAAC,sBAAsB,EAAE;IAC7B,QAAQ,CAAC,aAAa,EAAE;QACpB,EAAE,CAAC,MAAM,EAAE;YACP,OAAA,wBAAe,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE;;;;aAIxC,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,OAAO,EAAE;YACR,OAAA,wBAAe,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE;;;;aAIpC,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,cAAc,EAAE;YACf,OAAA,wBAAe,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE;;;;aAIhD,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,QAAQ,EAAE;YACT,OAAA,wBAAe,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;;;;aAI1C,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,QAAQ,EAAE;YACT,OAAA,wBAAe,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;;;;aAI1C,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,MAAM,EAAE;YACP,OAAA,wBAAe,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE;;;;aAIxC,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,SAAS,EAAE;YACV,OAAA,wBAAe,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE;;;;aAI3C,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,aAAa,EAAE;YACd,OAAA,wBAAe,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE;;;;aAI/C,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,gBAAgB,EAAE;YACjB,OAAA,wBAAe,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE;;;;aAIlD,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,qBAAqB,EAAE;YACtB,OAAA,wBAAe,CAAC,eAAe,CAAC,qBAAqB,CAAC,EAAE;;;;aAIvD,CAAC;QAJF,CAIE,CAAC,CAAC;QAER,EAAE,CAAC,qBAAqB,EAAE;YACtB,OAAA,wBAAe,CAAC,eAAe,CAAC,qBAAqB,CAAC,EAAE;;;;aAIvD,CAAC;QAJF,CAIE,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var assert_1 = require("assert");
var parser_1 = require("../../syntax/parser");
var color_1 = require("../../types/color");
var text_shadow_1 = require("../text-shadow");
var tokenizer_1 = require("../../syntax/tokenizer");
var length_percentage_1 = require("../../types/length-percentage");
var textShadowParse = function (value) { return text_shadow_1.textShadow.parse({}, parser_1.Parser.parseValues(value)); };
var colorParse = function (value) { return color_1.color.parse({}, parser_1.Parser.parseValue(value)); };
var dimension = function (number, unit) { return ({
flags: tokenizer_1.FLAG_INTEGER,
number: number,
unit: unit,
type: 15 /* DIMENSION_TOKEN */
}); };
describe('property-descriptors', function () {
describe('text-shadow', function () {
it('none', function () { return assert_1.deepStrictEqual(textShadowParse('none'), []); });
it('1px 1px 2px pink', function () {
return assert_1.deepStrictEqual(textShadowParse('1px 1px 2px pink'), [
{
color: colorParse('pink'),
offsetX: dimension(1, 'px'),
offsetY: dimension(1, 'px'),
blur: dimension(2, 'px')
}
]);
});
it('#fc0 1px 0 10px', function () {
return assert_1.deepStrictEqual(textShadowParse('#fc0 1px 0 10px'), [
{
color: colorParse('#fc0'),
offsetX: dimension(1, 'px'),
offsetY: length_percentage_1.ZERO_LENGTH,
blur: dimension(10, 'px')
}
]);
});
it('5px 5px #558abb', function () {
return assert_1.deepStrictEqual(textShadowParse('5px 5px #558abb'), [
{
color: colorParse('#558abb'),
offsetX: dimension(5, 'px'),
offsetY: dimension(5, 'px'),
blur: length_percentage_1.ZERO_LENGTH
}
]);
});
it('white 2px 5px', function () {
return assert_1.deepStrictEqual(textShadowParse('white 2px 5px'), [
{
color: colorParse('#fff'),
offsetX: dimension(2, 'px'),
offsetY: dimension(5, 'px'),
blur: length_percentage_1.ZERO_LENGTH
}
]);
});
it('white 2px 5px', function () {
return assert_1.deepStrictEqual(textShadowParse('5px 10px'), [
{
color: color_1.COLORS.TRANSPARENT,
offsetX: dimension(5, 'px'),
offsetY: dimension(10, 'px'),
blur: length_percentage_1.ZERO_LENGTH
}
]);
});
it('1px 1px 2px red, 0 0 1em blue, 0 0 2em blue', function () {
return assert_1.deepStrictEqual(textShadowParse('1px 1px 2px red, 0 0 1em blue, 0 0 2em blue'), [
{
color: colorParse('red'),
offsetX: dimension(1, 'px'),
offsetY: dimension(1, 'px'),
blur: dimension(2, 'px')
},
{
color: colorParse('blue'),
offsetX: length_percentage_1.ZERO_LENGTH,
offsetY: length_percentage_1.ZERO_LENGTH,
blur: dimension(1, 'em')
},
{
color: colorParse('blue'),
offsetX: length_percentage_1.ZERO_LENGTH,
offsetY: length_percentage_1.ZERO_LENGTH,
blur: dimension(2, 'em')
}
]);
});
});
});
//# sourceMappingURL=text-shadow.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"text-shadow.js","sourceRoot":"","sources":["../../../../../src/css/property-descriptors/__tests__/text-shadow.ts"],"names":[],"mappings":";;AAAA,iCAAuC;AACvC,8CAA2C;AAC3C,2CAAgD;AAChD,8CAA0C;AAC1C,oDAA+E;AAC/E,mEAA0D;AAG1D,IAAM,eAAe,GAAG,UAAC,KAAa,IAAK,OAAA,wBAAU,CAAC,KAAK,CAAC,EAAa,EAAE,eAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAA1D,CAA0D,CAAC;AACtG,IAAM,UAAU,GAAG,UAAC,KAAa,IAAK,OAAA,aAAK,CAAC,KAAK,CAAC,EAAa,EAAE,eAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAApD,CAAoD,CAAC;AAC3F,IAAM,SAAS,GAAG,UAAC,MAAc,EAAE,IAAY,IAAqB,OAAA,CAAC;IACjE,KAAK,EAAE,wBAAY;IACnB,MAAM,QAAA;IACN,IAAI,MAAA;IACJ,IAAI,0BAA2B;CAClC,CAAC,EALkE,CAKlE,CAAC;AAEH,QAAQ,CAAC,sBAAsB,EAAE;IAC7B,QAAQ,CAAC,aAAa,EAAE;QACpB,EAAE,CAAC,MAAM,EAAE,cAAM,OAAA,wBAAe,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,EAA5C,CAA4C,CAAC,CAAC;QAE/D,EAAE,CAAC,kBAAkB,EAAE;YACnB,OAAA,wBAAe,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE;gBACjD;oBACI,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,EAAE;YAChB,OAAA,wBAAe,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE;gBACzC;oBACI,KAAK,EAAE,cAAM,CAAC,WAAW;oBACzB,OAAO,EAAE,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;oBAC3B,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC;oBAC5B,IAAI,EAAE,+BAAW;iBACpB;aACJ,CAAC;QAPF,CAOE,CAAC,CAAC;QAER,EAAE,CAAC,6CAA6C,EAAE;YAC9C,OAAA,wBAAe,CAAC,eAAe,CAAC,6CAA6C,CAAC,EAAE;gBAC5E;oBACI,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC;oBACxB,OAAO,EAAE,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;oBAC3B,OAAO,EAAE,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;oBAC3B,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;iBAC3B;gBACD;oBACI,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC;oBACzB,OAAO,EAAE,+BAAW;oBACpB,OAAO,EAAE,+BAAW;oBACpB,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;iBAC3B;gBACD;oBACI,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC;oBACzB,OAAO,EAAE,+BAAW;oBACpB,OAAO,EAAE,+BAAW;oBACpB,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;iBAC3B;aACJ,CAAC;QAnBF,CAmBE,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var transform_1 = require("../transform");
var parser_1 = require("../../syntax/parser");
var assert_1 = require("assert");
var parseValue = function (value) { return transform_1.transform.parse({}, parser_1.Parser.parseValue(value)); };
describe('property-descriptors', function () {
describe('transform', function () {
it('none', function () { return assert_1.deepStrictEqual(parseValue('none'), null); });
it('matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)', function () {
return assert_1.deepStrictEqual(parseValue('matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)'), [1, 2, 3, 4, 5, 6]);
});
it('matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)', function () {
return assert_1.deepStrictEqual(parseValue('matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'), [1, 0, 0, 1, 0, 0]);
});
});
});
//# sourceMappingURL=transform-tests.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"transform-tests.js","sourceRoot":"","sources":["../../../../../src/css/property-descriptors/__tests__/transform-tests.ts"],"names":[],"mappings":";;AAAA,0CAAuC;AACvC,8CAA2C;AAC3C,iCAAuC;AAEvC,IAAM,UAAU,GAAG,UAAC,KAAa,IAAK,OAAA,qBAAS,CAAC,KAAK,CAAC,EAAa,EAAE,eAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAxD,CAAwD,CAAC;AAE/F,QAAQ,CAAC,sBAAsB,EAAE;IAC7B,QAAQ,CAAC,WAAW,EAAE;QAClB,EAAE,CAAC,MAAM,EAAE,cAAM,OAAA,wBAAe,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAzC,CAAyC,CAAC,CAAC;QAC5D,EAAE,CAAC,sCAAsC,EAAE;YACvC,OAAA,wBAAe,CAAC,UAAU,CAAC,sCAAsC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAAvF,CAAuF,CAAC,CAAC;QAC7F,EAAE,CAAC,0DAA0D,EAAE;YAC3D,OAAA,wBAAe,CACX,UAAU,CAAC,0DAA0D,CAAC,EACtE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CACrB;QAHD,CAGC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backgroundClip = void 0;
var parser_1 = require("../syntax/parser");
exports.backgroundClip = {
name: 'background-clip',
initialValue: 'border-box',
prefix: false,
type: 1 /* LIST */,
parse: function (_context, tokens) {
return tokens.map(function (token) {
if (parser_1.isIdentToken(token)) {
switch (token.value) {
case 'padding-box':
return 1 /* PADDING_BOX */;
case 'content-box':
return 2 /* CONTENT_BOX */;
}
}
return 0 /* BORDER_BOX */;
});
}
};
//# sourceMappingURL=background-clip.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"background-clip.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/background-clip.ts"],"names":[],"mappings":";;;AACA,2CAAwD;AAU3C,QAAA,cAAc,GAA4C;IACnE,IAAI,EAAE,iBAAiB;IACvB,YAAY,EAAE,YAAY;IAC1B,MAAM,EAAE,KAAK;IACb,IAAI,cAAoC;IACxC,KAAK,EAAE,UAAC,QAAiB,EAAE,MAAkB;QACzC,OAAO,MAAM,CAAC,GAAG,CAAC,UAAC,KAAK;YACpB,IAAI,qBAAY,CAAC,KAAK,CAAC,EAAE;gBACrB,QAAQ,KAAK,CAAC,KAAK,EAAE;oBACjB,KAAK,aAAa;wBACd,2BAAmC;oBACvC,KAAK,aAAa;wBACd,2BAAmC;iBAC1C;aACJ;YACD,0BAAkC;QACtC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"}

View File

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backgroundColor = void 0;
exports.backgroundColor = {
name: "background-color",
initialValue: 'transparent',
prefix: false,
type: 3 /* TYPE_VALUE */,
format: 'color'
};
//# sourceMappingURL=background-color.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"background-color.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/background-color.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAiC;IACzD,IAAI,EAAE,kBAAkB;IACxB,YAAY,EAAE,aAAa;IAC3B,MAAM,EAAE,KAAK;IACb,IAAI,oBAA0C;IAC9C,MAAM,EAAE,OAAO;CAClB,CAAC"}

View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backgroundImage = void 0;
var image_1 = require("../types/image");
var parser_1 = require("../syntax/parser");
exports.backgroundImage = {
name: 'background-image',
initialValue: 'none',
type: 1 /* LIST */,
prefix: false,
parse: function (context, tokens) {
if (tokens.length === 0) {
return [];
}
var first = tokens[0];
if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
return [];
}
return tokens
.filter(function (value) { return parser_1.nonFunctionArgSeparator(value) && image_1.isSupportedImage(value); })
.map(function (value) { return image_1.image.parse(context, value); });
}
};
//# sourceMappingURL=background-image.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"background-image.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/background-image.ts"],"names":[],"mappings":";;;AACA,wCAAkE;AAElE,2CAAmE;AAGtD,QAAA,eAAe,GAAyC;IACjE,IAAI,EAAE,kBAAkB;IACxB,YAAY,EAAE,MAAM;IACpB,IAAI,cAAoC;IACxC,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,UAAC,OAAgB,EAAE,MAAkB;QACxC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,OAAO,EAAE,CAAC;SACb;QAED,IAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAExB,IAAI,KAAK,CAAC,IAAI,yBAA0B,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM,EAAE;YAChE,OAAO,EAAE,CAAC;SACb;QAED,OAAO,MAAM;aACR,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,gCAAuB,CAAC,KAAK,CAAC,IAAI,wBAAgB,CAAC,KAAK,CAAC,EAAzD,CAAyD,CAAC;aAC5E,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,aAAK,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,EAA3B,CAA2B,CAAC,CAAC;IACrD,CAAC;CACJ,CAAC"}

View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backgroundOrigin = void 0;
var parser_1 = require("../syntax/parser");
exports.backgroundOrigin = {
name: 'background-origin',
initialValue: 'border-box',
prefix: false,
type: 1 /* LIST */,
parse: function (_context, tokens) {
return tokens.map(function (token) {
if (parser_1.isIdentToken(token)) {
switch (token.value) {
case 'padding-box':
return 1 /* PADDING_BOX */;
case 'content-box':
return 2 /* CONTENT_BOX */;
}
}
return 0 /* BORDER_BOX */;
});
}
};
//# sourceMappingURL=background-origin.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"background-origin.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/background-origin.ts"],"names":[],"mappings":";;;AACA,2CAAwD;AAW3C,QAAA,gBAAgB,GAA8C;IACvE,IAAI,EAAE,mBAAmB;IACzB,YAAY,EAAE,YAAY;IAC1B,MAAM,EAAE,KAAK;IACb,IAAI,cAAoC;IACxC,KAAK,EAAE,UAAC,QAAiB,EAAE,MAAkB;QACzC,OAAO,MAAM,CAAC,GAAG,CAAC,UAAC,KAAK;YACpB,IAAI,qBAAY,CAAC,KAAK,CAAC,EAAE;gBACrB,QAAQ,KAAK,CAAC,KAAK,EAAE;oBACjB,KAAK,aAAa;wBACd,2BAAqC;oBACzC,KAAK,aAAa;wBACd,2BAAqC;iBAC5C;aACJ;YACD,0BAAoC;QACxC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"}

View File

@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backgroundPosition = void 0;
var parser_1 = require("../syntax/parser");
var length_percentage_1 = require("../types/length-percentage");
exports.backgroundPosition = {
name: 'background-position',
initialValue: '0% 0%',
type: 1 /* LIST */,
prefix: false,
parse: function (_context, tokens) {
return parser_1.parseFunctionArgs(tokens)
.map(function (values) { return values.filter(length_percentage_1.isLengthPercentage); })
.map(length_percentage_1.parseLengthPercentageTuple);
}
};
//# sourceMappingURL=background-position.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"background-position.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/background-position.ts"],"names":[],"mappings":";;;AACA,2CAA6D;AAC7D,gEAAiH;AAMpG,QAAA,kBAAkB,GAAgD;IAC3E,IAAI,EAAE,qBAAqB;IAC3B,YAAY,EAAE,OAAO;IACrB,IAAI,cAAoC;IACxC,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,UAAC,QAAiB,EAAE,MAAkB;QACzC,OAAO,0BAAiB,CAAC,MAAM,CAAC;aAC3B,GAAG,CAAC,UAAC,MAAkB,IAAK,OAAA,MAAM,CAAC,MAAM,CAAC,sCAAkB,CAAC,EAAjC,CAAiC,CAAC;aAC9D,GAAG,CAAC,8CAA0B,CAAC,CAAC;IACzC,CAAC;CACJ,CAAC"}

View File

@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backgroundRepeat = void 0;
var parser_1 = require("../syntax/parser");
exports.backgroundRepeat = {
name: 'background-repeat',
initialValue: 'repeat',
prefix: false,
type: 1 /* LIST */,
parse: function (_context, tokens) {
return parser_1.parseFunctionArgs(tokens)
.map(function (values) {
return values
.filter(parser_1.isIdentToken)
.map(function (token) { return token.value; })
.join(' ');
})
.map(parseBackgroundRepeat);
}
};
var parseBackgroundRepeat = function (value) {
switch (value) {
case 'no-repeat':
return 1 /* NO_REPEAT */;
case 'repeat-x':
case 'repeat no-repeat':
return 2 /* REPEAT_X */;
case 'repeat-y':
case 'no-repeat repeat':
return 3 /* REPEAT_Y */;
case 'repeat':
default:
return 0 /* REPEAT */;
}
};
//# sourceMappingURL=background-repeat.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"background-repeat.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/background-repeat.ts"],"names":[],"mappings":";;;AACA,2CAA2E;AAW9D,QAAA,gBAAgB,GAA8C;IACvE,IAAI,EAAE,mBAAmB;IACzB,YAAY,EAAE,QAAQ;IACtB,MAAM,EAAE,KAAK;IACb,IAAI,cAAoC;IACxC,KAAK,EAAE,UAAC,QAAiB,EAAE,MAAkB;QACzC,OAAO,0BAAiB,CAAC,MAAM,CAAC;aAC3B,GAAG,CAAC,UAAC,MAAM;YACR,OAAA,MAAM;iBACD,MAAM,CAAC,qBAAY,CAAC;iBACpB,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,KAAK,EAAX,CAAW,CAAC;iBAC3B,IAAI,CAAC,GAAG,CAAC;QAHd,CAGc,CACjB;aACA,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACpC,CAAC;CACJ,CAAC;AAEF,IAAM,qBAAqB,GAAG,UAAC,KAAa;IACxC,QAAQ,KAAK,EAAE;QACX,KAAK,WAAW;YACZ,yBAAmC;QACvC,KAAK,UAAU,CAAC;QAChB,KAAK,kBAAkB;YACnB,wBAAkC;QACtC,KAAK,UAAU,CAAC;QAChB,KAAK,kBAAkB;YACnB,wBAAkC;QACtC,KAAK,QAAQ,CAAC;QACd;YACI,sBAAgC;KACvC;AACL,CAAC,CAAC"}

View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backgroundSize = exports.BACKGROUND_SIZE = void 0;
var parser_1 = require("../syntax/parser");
var length_percentage_1 = require("../types/length-percentage");
var BACKGROUND_SIZE;
(function (BACKGROUND_SIZE) {
BACKGROUND_SIZE["AUTO"] = "auto";
BACKGROUND_SIZE["CONTAIN"] = "contain";
BACKGROUND_SIZE["COVER"] = "cover";
})(BACKGROUND_SIZE = exports.BACKGROUND_SIZE || (exports.BACKGROUND_SIZE = {}));
exports.backgroundSize = {
name: 'background-size',
initialValue: '0',
prefix: false,
type: 1 /* LIST */,
parse: function (_context, tokens) {
return parser_1.parseFunctionArgs(tokens).map(function (values) { return values.filter(isBackgroundSizeInfoToken); });
}
};
var isBackgroundSizeInfoToken = function (value) {
return parser_1.isIdentToken(value) || length_percentage_1.isLengthPercentage(value);
};
//# sourceMappingURL=background-size.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"background-size.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/background-size.ts"],"names":[],"mappings":";;;AACA,2CAA2E;AAC3E,gEAAgF;AAIhF,IAAY,eAIX;AAJD,WAAY,eAAe;IACvB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,kCAAe,CAAA;AACnB,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AAKY,QAAA,cAAc,GAA4C;IACnE,IAAI,EAAE,iBAAiB;IACvB,YAAY,EAAE,GAAG;IACjB,MAAM,EAAE,KAAK;IACb,IAAI,cAAoC;IACxC,KAAK,EAAE,UAAC,QAAiB,EAAE,MAAkB;QACzC,OAAO,0BAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,MAAM,CAAC,yBAAyB,CAAC,EAAxC,CAAwC,CAAC,CAAC;IAC/F,CAAC;CACJ,CAAC;AAEF,IAAM,yBAAyB,GAAG,UAAC,KAAe;IAC9C,OAAA,qBAAY,CAAC,KAAK,CAAC,IAAI,sCAAkB,CAAC,KAAK,CAAC;AAAhD,CAAgD,CAAC"}

View File

@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.borderLeftColor = exports.borderBottomColor = exports.borderRightColor = exports.borderTopColor = void 0;
var borderColorForSide = function (side) { return ({
name: "border-" + side + "-color",
initialValue: 'transparent',
prefix: false,
type: 3 /* TYPE_VALUE */,
format: 'color'
}); };
exports.borderTopColor = borderColorForSide('top');
exports.borderRightColor = borderColorForSide('right');
exports.borderBottomColor = borderColorForSide('bottom');
exports.borderLeftColor = borderColorForSide('left');
//# sourceMappingURL=border-color.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"border-color.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/border-color.ts"],"names":[],"mappings":";;;AACA,IAAM,kBAAkB,GAAG,UAAC,IAAY,IAAmC,OAAA,CAAC;IACxE,IAAI,EAAE,YAAU,IAAI,WAAQ;IAC5B,YAAY,EAAE,aAAa;IAC3B,MAAM,EAAE,KAAK;IACb,IAAI,oBAA0C;IAC9C,MAAM,EAAE,OAAO;CAClB,CAAC,EANyE,CAMzE,CAAC;AAEU,QAAA,cAAc,GAAiC,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACzE,QAAA,gBAAgB,GAAiC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAC7E,QAAA,iBAAiB,GAAiC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AAC/E,QAAA,eAAe,GAAiC,kBAAkB,CAAC,MAAM,CAAC,CAAC"}

View File

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.borderBottomLeftRadius = exports.borderBottomRightRadius = exports.borderTopRightRadius = exports.borderTopLeftRadius = void 0;
var length_percentage_1 = require("../types/length-percentage");
var borderRadiusForSide = function (side) { return ({
name: "border-radius-" + side,
initialValue: '0 0',
prefix: false,
type: 1 /* LIST */,
parse: function (_context, tokens) {
return length_percentage_1.parseLengthPercentageTuple(tokens.filter(length_percentage_1.isLengthPercentage));
}
}); };
exports.borderTopLeftRadius = borderRadiusForSide('top-left');
exports.borderTopRightRadius = borderRadiusForSide('top-right');
exports.borderBottomRightRadius = borderRadiusForSide('bottom-right');
exports.borderBottomLeftRadius = borderRadiusForSide('bottom-left');
//# sourceMappingURL=border-radius.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"border-radius.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/border-radius.ts"],"names":[],"mappings":";;;AAEA,gEAAiH;AAIjH,IAAM,mBAAmB,GAAG,UAAC,IAAY,IAA4C,OAAA,CAAC;IAClF,IAAI,EAAE,mBAAiB,IAAM;IAC7B,YAAY,EAAE,KAAK;IACnB,MAAM,EAAE,KAAK;IACb,IAAI,cAAoC;IACxC,KAAK,EAAE,UAAC,QAAiB,EAAE,MAAkB;QACzC,OAAA,8CAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,sCAAkB,CAAC,CAAC;IAA7D,CAA6D;CACpE,CAAC,EAPmF,CAOnF,CAAC;AAEU,QAAA,mBAAmB,GAA0C,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC7F,QAAA,oBAAoB,GAA0C,mBAAmB,CAAC,WAAW,CAAC,CAAC;AAC/F,QAAA,uBAAuB,GAA0C,mBAAmB,CAAC,cAAc,CAAC,CAAC;AACrG,QAAA,sBAAsB,GAA0C,mBAAmB,CAAC,aAAa,CAAC,CAAC"}

View File

@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.borderLeftStyle = exports.borderBottomStyle = exports.borderRightStyle = exports.borderTopStyle = void 0;
var borderStyleForSide = function (side) { return ({
name: "border-" + side + "-style",
initialValue: 'solid',
prefix: false,
type: 2 /* IDENT_VALUE */,
parse: function (_context, style) {
switch (style) {
case 'none':
return 0 /* NONE */;
case 'dashed':
return 2 /* DASHED */;
case 'dotted':
return 3 /* DOTTED */;
case 'double':
return 4 /* DOUBLE */;
}
return 1 /* SOLID */;
}
}); };
exports.borderTopStyle = borderStyleForSide('top');
exports.borderRightStyle = borderStyleForSide('right');
exports.borderBottomStyle = borderStyleForSide('bottom');
exports.borderLeftStyle = borderStyleForSide('left');
//# sourceMappingURL=border-style.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"border-style.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/border-style.ts"],"names":[],"mappings":";;;AAUA,IAAM,kBAAkB,GAAG,UAAC,IAAY,IAAkD,OAAA,CAAC;IACvF,IAAI,EAAE,YAAU,IAAI,WAAQ;IAC5B,YAAY,EAAE,OAAO;IACrB,MAAM,EAAE,KAAK;IACb,IAAI,qBAA2C;IAC/C,KAAK,EAAE,UAAC,QAAiB,EAAE,KAAa;QACpC,QAAQ,KAAK,EAAE;YACX,KAAK,MAAM;gBACP,oBAAyB;YAC7B,KAAK,QAAQ;gBACT,sBAA2B;YAC/B,KAAK,QAAQ;gBACT,sBAA2B;YAC/B,KAAK,QAAQ;gBACT,sBAA2B;SAClC;QACD,qBAA0B;IAC9B,CAAC;CACJ,CAAC,EAlBwF,CAkBxF,CAAC;AAEU,QAAA,cAAc,GAAgD,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACxF,QAAA,gBAAgB,GAAgD,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAC5F,QAAA,iBAAiB,GAAgD,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AAC9F,QAAA,eAAe,GAAgD,kBAAkB,CAAC,MAAM,CAAC,CAAC"}

View File

@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.borderLeftWidth = exports.borderBottomWidth = exports.borderRightWidth = exports.borderTopWidth = void 0;
var parser_1 = require("../syntax/parser");
var borderWidthForSide = function (side) { return ({
name: "border-" + side + "-width",
initialValue: '0',
type: 0 /* VALUE */,
prefix: false,
parse: function (_context, token) {
if (parser_1.isDimensionToken(token)) {
return token.number;
}
return 0;
}
}); };
exports.borderTopWidth = borderWidthForSide('top');
exports.borderRightWidth = borderWidthForSide('right');
exports.borderBottomWidth = borderWidthForSide('bottom');
exports.borderLeftWidth = borderWidthForSide('left');
//# sourceMappingURL=border-width.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"border-width.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/border-width.ts"],"names":[],"mappings":";;;AACA,2CAA4D;AAE5D,IAAM,kBAAkB,GAAG,UAAC,IAAY,IAAuC,OAAA,CAAC;IAC5E,IAAI,EAAE,YAAU,IAAI,WAAQ;IAC5B,YAAY,EAAE,GAAG;IACjB,IAAI,eAAqC;IACzC,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,UAAC,QAAiB,EAAE,KAAe;QACtC,IAAI,yBAAgB,CAAC,KAAK,CAAC,EAAE;YACzB,OAAO,KAAK,CAAC,MAAM,CAAC;SACvB;QACD,OAAO,CAAC,CAAC;IACb,CAAC;CACJ,CAAC,EAX6E,CAW7E,CAAC;AAEU,QAAA,cAAc,GAAqC,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAC7E,QAAA,gBAAgB,GAAqC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACjF,QAAA,iBAAiB,GAAqC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACnF,QAAA,eAAe,GAAqC,kBAAkB,CAAC,MAAM,CAAC,CAAC"}

View File

@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.boxShadow = void 0;
var parser_1 = require("../syntax/parser");
var length_percentage_1 = require("../types/length-percentage");
var color_1 = require("../types/color");
var length_1 = require("../types/length");
exports.boxShadow = {
name: 'box-shadow',
initialValue: 'none',
type: 1 /* LIST */,
prefix: false,
parse: function (context, tokens) {
if (tokens.length === 1 && parser_1.isIdentWithValue(tokens[0], 'none')) {
return [];
}
return parser_1.parseFunctionArgs(tokens).map(function (values) {
var shadow = {
color: 0x000000ff,
offsetX: length_percentage_1.ZERO_LENGTH,
offsetY: length_percentage_1.ZERO_LENGTH,
blur: length_percentage_1.ZERO_LENGTH,
spread: length_percentage_1.ZERO_LENGTH,
inset: false
};
var c = 0;
for (var i = 0; i < values.length; i++) {
var token = values[i];
if (parser_1.isIdentWithValue(token, 'inset')) {
shadow.inset = true;
}
else if (length_1.isLength(token)) {
if (c === 0) {
shadow.offsetX = token;
}
else if (c === 1) {
shadow.offsetY = token;
}
else if (c === 2) {
shadow.blur = token;
}
else {
shadow.spread = token;
}
c++;
}
else {
shadow.color = color_1.color.parse(context, token);
}
}
return shadow;
});
}
};
//# sourceMappingURL=box-shadow.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"box-shadow.js","sourceRoot":"","sources":["../../../../src/css/property-descriptors/box-shadow.ts"],"names":[],"mappings":";;;AACA,2CAA+E;AAC/E,gEAAuD;AACvD,wCAA4C;AAC5C,0CAAiD;AAapC,QAAA,SAAS,GAAuC;IACzD,IAAI,EAAE,YAAY;IAClB,YAAY,EAAE,MAAM;IACpB,IAAI,cAAoC;IACxC,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,UAAC,OAAgB,EAAE,MAAkB;QACxC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,yBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE;YAC5D,OAAO,EAAE,CAAC;SACb;QAED,OAAO,0BAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,UAAC,MAAkB;YACpD,IAAM,MAAM,GAAkB;gBAC1B,KAAK,EAAE,UAAU;gBACjB,OAAO,EAAE,+BAAW;gBACpB,OAAO,EAAE,+BAAW;gBACpB,IAAI,EAAE,+BAAW;gBACjB,MAAM,EAAE,+BAAW;gBACnB,KAAK,EAAE,KAAK;aACf,CAAC;YACF,IAAI,CAAC,GAAG,CAAC,CAAC;YACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpC,IAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;gBACxB,IAAI,yBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE;oBAClC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;iBACvB;qBAAM,IAAI,iBAAQ,CAAC,KAAK,CAAC,EAAE;oBACxB,IAAI,CAAC,KAAK,CAAC,EAAE;wBACT,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;qBAC1B;yBAAM,IAAI,CAAC,KAAK,CAAC,EAAE;wBAChB,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;qBAC1B;yBAAM,IAA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