Switch from tslint to eslint

This commit is contained in:
Tom Z?hner
2020-09-06 17:52:12 +02:00
parent 2f5c90534e
commit 42147535f1
52 changed files with 1055 additions and 456 deletions
+10
View File
@@ -0,0 +1,10 @@
# don't ever lint node_modules
node_modules
# don't lint build output
dist
# don't lint nyc coverage output
coverage
# don't lint samples
samples
# don't lint test code
test
+14
View File
@@ -0,0 +1,14 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
"@typescript-eslint/no-explicit-any": "off"
}
};
+2 -2
View File
@@ -3,14 +3,14 @@
coverage/
samples/
test/
vendor/
webpack/
.editorconfig
.eslintignore
.eslintrc.js
.gitignore
.nojekyll
.travis.yml
travis-verify-build.sh
.gitattributes
tslint.json
tsconfig.json
typewiz.json
Generated Vendored
+2 -5
View File
@@ -746,7 +746,6 @@ var Helper = /** @class */ (function () {
}
Helper.log = function (message) {
if (isLoggingEnabled) {
// tslint:disable-next-line:no-console
console.log(message);
}
};
@@ -1860,7 +1859,7 @@ var Region = /** @class */ (function (_super) {
var scanLine = void 0;
for (var i = 0; i < rectCnt; i++) {
var r = new _Primitives__WEBPACK_IMPORTED_MODULE_1__["RectL"](reader);
if (scanLine == null || scanLine.top !== r.top || scanLine.bottom !== r.bottom) {
if (!!scanLine || scanLine.top !== r.top || scanLine.bottom !== r.bottom) {
scanLine = new Scan(r);
_this.scans.push(scanLine);
}
@@ -2460,7 +2459,6 @@ var Pen = /** @class */ (function (_super) {
if (reader != null) {
if (style != null) {
// LogPenEx
var bitmapInfo = style;
_this.style = reader.readUint32() & 0xFF;
_this.width = reader.readUint32();
_this.brush = new Brush(reader);
@@ -3453,9 +3451,8 @@ var GDIContext = /** @class */ (function () {
opts.stroke = "#" + pen.color.toHex(); // TODO: pen style
opts["stroke-width"] = pen.width;
opts["stroke-miterlimit"] = this.state.miterlimit;
var dotWidth = void 0;
opts["stroke-linecap"] = "round";
dotWidth = 1;
var dotWidth = 1;
opts["stroke-linejoin"] = "round";
var dashWidth = opts["stroke-width"] * 4;
var dotSpacing = opts["stroke-width"] * 2;
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+12 -11
View File
@@ -344,7 +344,6 @@ var Helper = /** @class */ (function () {
}
Helper.log = function (message) {
if (isLoggingEnabled) {
// tslint:disable-next-line:no-console
console.log(message);
}
};
@@ -682,7 +681,7 @@ var Parser = /** @class */ (function () {
else if (value instanceof _Containers__WEBPACK_IMPORTED_MODULE_4__["HexText"]) {
// Looking for current fonttbl charset
var codepage = this.parser.codepage;
if (value.chp.hasOwnProperty("fontfamily")) {
if (Object.prototype.hasOwnProperty.call(value.chp, "fontfamily")) {
var idx = value.chp.fontfamily;
// Code page 42 isn't a real code page and shouldn't appear here
if (this.inst._fonts !== undefined && this.inst._fonts[idx] != null
@@ -921,7 +920,7 @@ var Parser = /** @class */ (function () {
var ch = this.readChar();
if (!_Helper__WEBPACK_IMPORTED_MODULE_1__["Helper"]._isalpha(ch)) {
// 8 bit character encoded as hexadecimal
if (ch === "\'") {
if (ch === "'") {
var hex = this.readChar() + this.readChar();
param = _Helper__WEBPACK_IMPORTED_MODULE_1__["Helper"]._parseHex(hex);
if (isNaN(param)) {
@@ -7965,7 +7964,7 @@ var RenderChp = /** @class */ (function () {
if (this._chp.italic) {
el.style.fontStyle = "italic";
}
if (this._chp.hasOwnProperty("fontfamily") && doc._fonts[this._chp.fontfamily]) {
if (Object.prototype.hasOwnProperty.call(this._chp, "fontfamily") && doc._fonts[this._chp.fontfamily]) {
var fontFamily = doc._fonts[this._chp.fontfamily].fontname.replace(";", "");
if (fontFamily !== "Symbol") {
el.style.fontFamily = fontFamily;
@@ -8549,7 +8548,6 @@ SOFTWARE.
// tslint:disable-next-line:variable-name
var Destinations = {
rtf: _RtfDestination__WEBPACK_IMPORTED_MODULE_6__["RtfDestination"],
info: _MetaDestinations__WEBPACK_IMPORTED_MODULE_4__["InfoDestination"],
@@ -8878,18 +8876,18 @@ var FieldHyperlink = /** @class */ (function (_super) {
return this._url;
};
FieldHyperlink.prototype.renderFieldBegin = function (field, rtf, records) {
var self = this;
var _this = this;
if (records > 0) {
rtf.addIns(function (renderer) {
var inst = renderer._doc;
var create = function () {
return renderer.buildHyperlinkElement(self._url);
return renderer.buildHyperlinkElement(_this._url);
};
var container;
if (inst._settings.onHyperlink != null) {
container = inst._settings.onHyperlink(create, {
url: function () {
return self.url();
return this.url();
},
});
}
@@ -8948,7 +8946,7 @@ var FldinstDestination = /** @class */ (function (_super) {
// backup
var hook = inst._settings.onPicture;
inst._settings.onPicture = null;
// tslint:disable-next-line:prefer-const
// eslint-disable-next-line prefer-const
var _a = pict_1.apply(true), isLegacy = _a.isLegacy, element = _a.element;
// restore
inst._settings.onPicture = hook;
@@ -9002,6 +9000,7 @@ var FldinstDestination = /** @class */ (function (_super) {
this.parser._asyncTasks.push(promise);
return promise;
}
break;
default:
_Helper__WEBPACK_IMPORTED_MODULE_0__["Helper"].log("[fldinst]: unknown field type: " + fieldType);
break;
@@ -9939,18 +9938,20 @@ var RtfDestination = /** @class */ (function (_super) {
RtfDestination.prototype._addFormatIns = function (ptype, props) {
_Helper__WEBPACK_IMPORTED_MODULE_0__["Helper"].log("[rtf] update " + ptype);
switch (ptype) {
case "chp":
case "chp": {
var rchp_1 = new _renderer_RenderChp__WEBPACK_IMPORTED_MODULE_1__["RenderChp"](new _Containers__WEBPACK_IMPORTED_MODULE_3__["Chp"](props));
this.inst.addIns(function (renderer) {
renderer.setChp(rchp_1);
});
break;
case "pap":
}
case "pap": {
var rpap_1 = new _renderer_RenderPap__WEBPACK_IMPORTED_MODULE_2__["RenderPap"](new _Containers__WEBPACK_IMPORTED_MODULE_3__["Pap"](props));
this.inst.addIns(function (renderer) {
renderer.setPap(rpap_1);
});
break;
}
}
};
RtfDestination.prototype._genericFormatSetNoParam = function (ptype, prop, val) {
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
Generated Vendored
-1
View File
@@ -811,7 +811,6 @@ var Helper = /** @class */ (function () {
}
Helper.log = function (message) {
if (isLoggingEnabled) {
// tslint:disable-next-line:no-console
console.log(message);
}
};
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+630 -53
View File
@@ -231,6 +231,47 @@
"to-fast-properties": "^2.0.0"
}
},
"@eslint/eslintrc": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz",
"integrity": "sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==",
"dev": true,
"requires": {
"ajv": "^6.12.4",
"debug": "^4.1.1",
"espree": "^7.3.0",
"globals": "^12.1.0",
"ignore": "^4.0.6",
"import-fresh": "^3.2.1",
"js-yaml": "^3.13.1",
"lodash": "^4.17.19",
"minimatch": "^3.0.4",
"strip-json-comments": "^3.1.1"
},
"dependencies": {
"globals": {
"version": "12.4.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz",
"integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==",
"dev": true,
"requires": {
"type-fest": "^0.8.1"
}
},
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
},
"strip-json-comments": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true
}
}
},
"@istanbuljs/load-nyc-config": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
@@ -366,6 +407,135 @@
"integrity": "sha512-Wk7nG1JSaMfMpoMJDKUsWYugliB2Vy55pdjLpmLixeyMi7HizW2I/9QoxsPCkXl3dO+ZOVqPumKaDUv5zJu2uQ==",
"dev": true
},
"@typescript-eslint/eslint-plugin": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.0.1.tgz",
"integrity": "sha512-pQZtXupCn11O4AwpYVUX4PDFfmIJl90ZgrEBg0CEcqlwvPiG0uY81fimr1oMFblZnpKAq6prrT9a59pj1x58rw==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "4.0.1",
"@typescript-eslint/scope-manager": "4.0.1",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
},
"tsutils": {
"version": "3.17.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
}
}
},
"@typescript-eslint/experimental-utils": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.0.1.tgz",
"integrity": "sha512-gAqOjLiHoED79iYTt3F4uSHrYmg/GPz/zGezdB0jAdr6S6gwNiR/j7cTZ8nREKVzMVKLd9G3xbg1sV9GClW3sw==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/scope-manager": "4.0.1",
"@typescript-eslint/types": "4.0.1",
"@typescript-eslint/typescript-estree": "4.0.1",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
},
"dependencies": {
"eslint-scope": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz",
"integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==",
"dev": true,
"requires": {
"esrecurse": "^4.1.0",
"estraverse": "^4.1.1"
}
}
}
},
"@typescript-eslint/parser": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.0.1.tgz",
"integrity": "sha512-1+qLmXHNAWSQ7RB6fdSQszAiA7JTwzakj5cNYjBTUmpH2cqilxMZEIV+DRKjVZs8NzP3ALmKexB0w/ExjcK9Iw==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "4.0.1",
"@typescript-eslint/types": "4.0.1",
"@typescript-eslint/typescript-estree": "4.0.1",
"debug": "^4.1.1"
}
},
"@typescript-eslint/scope-manager": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.0.1.tgz",
"integrity": "sha512-u3YEXVJ8jsj7QCJk3om0Y457fy2euEOkkzxIB/LKU3MdyI+FJ2gI0M4aKEaXzwCSfNDiZ13a3lDo5DVozc+XLQ==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.0.1",
"@typescript-eslint/visitor-keys": "4.0.1"
}
},
"@typescript-eslint/types": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.0.1.tgz",
"integrity": "sha512-S+gD3fgbkZYW2rnbjugNMqibm9HpEjqZBZkTiI3PwbbNGWmAcxolWIUwZ0SKeG4Dy2ktpKKaI/6+HGYVH8Qrlg==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.0.1.tgz",
"integrity": "sha512-zGzleORFXrRWRJAMLTB2iJD1IZbCPkg4hsI8mGdpYlKaqzvKYSEWVAYh14eauaR+qIoZVWrXgYSXqLtTlxotiw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.0.1",
"@typescript-eslint/visitor-keys": "4.0.1",
"debug": "^4.1.1",
"globby": "^11.0.1",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
},
"tsutils": {
"version": "3.17.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
}
}
},
"@typescript-eslint/visitor-keys": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.0.1.tgz",
"integrity": "sha512-yBSqd6FjnTzbg5RUy9J+9kJEyQjTI34JdGMJz+9ttlJzLCnGkBikxw+N5n2VDcc3CesbIEJ0MnZc5uRYnrEnCw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.0.1",
"eslint-visitor-keys": "^2.0.0"
}
},
"@webassemblyjs/ast": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz",
@@ -585,6 +755,12 @@
"acorn-walk": "^7.1.1"
}
},
"acorn-jsx": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz",
"integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==",
"dev": true
},
"acorn-walk": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz",
@@ -879,6 +1055,12 @@
"integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=",
"dev": true
},
"astral-regex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz",
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
"dev": true
},
"async": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz",
@@ -1259,12 +1441,6 @@
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
"dev": true
},
"builtin-modules": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
"dev": true
},
"builtin-status-codes": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz",
@@ -1331,6 +1507,12 @@
"write-file-atomic": "^3.0.0"
}
},
"callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"dev": true
},
"camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
@@ -2227,6 +2409,15 @@
"buffer-indexof": "^1.0.0"
}
},
"doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
"integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==",
"dev": true,
"requires": {
"esutils": "^2.0.2"
}
},
"domain-browser": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
@@ -2339,6 +2530,15 @@
"tapable": "^1.0.0"
}
},
"enquirer": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
"integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",
"dev": true,
"requires": {
"ansi-colors": "^4.1.1"
}
},
"errno": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
@@ -2497,6 +2697,200 @@
}
}
},
"eslint": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.8.1.tgz",
"integrity": "sha512-/2rX2pfhyUG0y+A123d0ccXtMm7DV7sH1m3lk9nk2DZ2LReq39FXHueR9xZwshE5MdfSf0xunSaMWRqyIA6M1w==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"@eslint/eslintrc": "^0.1.3",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
"debug": "^4.0.1",
"doctrine": "^3.0.0",
"enquirer": "^2.3.5",
"eslint-scope": "^5.1.0",
"eslint-utils": "^2.1.0",
"eslint-visitor-keys": "^1.3.0",
"espree": "^7.3.0",
"esquery": "^1.2.0",
"esutils": "^2.0.2",
"file-entry-cache": "^5.0.1",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^5.0.0",
"globals": "^12.1.0",
"ignore": "^4.0.6",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
"js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
"lodash": "^4.17.19",
"minimatch": "^3.0.4",
"natural-compare": "^1.4.0",
"optionator": "^0.9.1",
"progress": "^2.0.0",
"regexpp": "^3.1.0",
"semver": "^7.2.1",
"strip-ansi": "^6.0.0",
"strip-json-comments": "^3.1.0",
"table": "^5.2.3",
"text-table": "^0.2.0",
"v8-compile-cache": "^2.0.3"
},
"dependencies": {
"ansi-regex": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true
},
"ansi-styles": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
"integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
"dev": true,
"requires": {
"@types/color-name": "^1.1.1",
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
"dev": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"eslint-scope": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz",
"integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==",
"dev": true,
"requires": {
"esrecurse": "^4.1.0",
"estraverse": "^4.1.1"
}
},
"eslint-visitor-keys": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
"dev": true
},
"globals": {
"version": "12.4.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz",
"integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==",
"dev": true,
"requires": {
"type-fest": "^0.8.1"
}
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
},
"levn": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
"integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
"dev": true,
"requires": {
"prelude-ls": "^1.2.1",
"type-check": "~0.4.0"
}
},
"optionator": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
"integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==",
"dev": true,
"requires": {
"deep-is": "^0.1.3",
"fast-levenshtein": "^2.0.6",
"levn": "^0.4.1",
"prelude-ls": "^1.2.1",
"type-check": "^0.4.0",
"word-wrap": "^1.2.3"
}
},
"prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"dev": true
},
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
},
"strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
"dev": true,
"requires": {
"ansi-regex": "^5.0.0"
}
},
"strip-json-comments": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}
},
"type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
"integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
"dev": true,
"requires": {
"prelude-ls": "^1.2.1"
}
}
}
},
"eslint-scope": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz",
@@ -2507,12 +2901,71 @@
"estraverse": "^4.1.1"
}
},
"eslint-utils": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
},
"dependencies": {
"eslint-visitor-keys": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
"dev": true
}
}
},
"eslint-visitor-keys": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz",
"integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==",
"dev": true
},
"espree": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/espree/-/espree-7.3.0.tgz",
"integrity": "sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw==",
"dev": true,
"requires": {
"acorn": "^7.4.0",
"acorn-jsx": "^5.2.0",
"eslint-visitor-keys": "^1.3.0"
},
"dependencies": {
"eslint-visitor-keys": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
"dev": true
}
}
},
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true
},
"esquery": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz",
"integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==",
"dev": true,
"requires": {
"estraverse": "^5.1.0"
},
"dependencies": {
"estraverse": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz",
"integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==",
"dev": true
}
}
},
"esrecurse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
@@ -2942,6 +3395,15 @@
"integrity": "sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw==",
"dev": true
},
"file-entry-cache": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
"integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==",
"dev": true,
"requires": {
"flat-cache": "^2.0.1"
}
},
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
@@ -3136,6 +3598,34 @@
"is-buffer": "~2.0.3"
}
},
"flat-cache": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz",
"integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==",
"dev": true,
"requires": {
"flatted": "^2.0.0",
"rimraf": "2.6.3",
"write": "1.0.3"
},
"dependencies": {
"rimraf": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
"dev": true,
"requires": {
"glob": "^7.1.3"
}
}
}
},
"flatted": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz",
"integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==",
"dev": true
},
"flush-write-stream": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz",
@@ -3262,6 +3752,12 @@
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"functional-red-black-tree": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true
},
"gensync": {
"version": "1.0.0-beta.1",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz",
@@ -3829,6 +4325,24 @@
"integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==",
"dev": true
},
"import-fresh": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz",
"integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==",
"dev": true,
"requires": {
"parent-module": "^1.0.0",
"resolve-from": "^4.0.0"
},
"dependencies": {
"resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"dev": true
}
}
},
"import-local": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz",
@@ -4464,6 +4978,12 @@
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true
},
"json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
"integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=",
"dev": true
},
"json-stringify-safe": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
@@ -5060,6 +5580,12 @@
"to-regex": "^3.0.1"
}
},
"natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"dev": true
},
"negotiator": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
@@ -5647,6 +6173,15 @@
"readable-stream": "^2.1.5"
}
},
"parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"dev": true,
"requires": {
"callsites": "^3.0.0"
}
},
"parse-asn1": {
"version": "5.1.6",
"resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz",
@@ -5863,6 +6398,12 @@
"fromentries": "^1.2.0"
}
},
"progress": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
"dev": true
},
"promise-inflight": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz",
@@ -6210,6 +6751,12 @@
}
}
},
"regexpp": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz",
"integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==",
"dev": true
},
"release-zalgo": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz",
@@ -6688,6 +7235,17 @@
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true
},
"slice-ansi": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz",
"integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.0",
"astral-regex": "^1.0.0",
"is-fullwidth-code-point": "^2.0.0"
}
},
"snapdragon": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
@@ -7304,6 +7862,46 @@
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
"dev": true
},
"table": {
"version": "5.4.6",
"resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz",
"integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==",
"dev": true,
"requires": {
"ajv": "^6.10.2",
"lodash": "^4.17.14",
"slice-ansi": "^2.1.0",
"string-width": "^3.0.0"
},
"dependencies": {
"ansi-regex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"dev": true
},
"string-width": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
"integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
"dev": true,
"requires": {
"emoji-regex": "^7.0.1",
"is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^5.1.0"
}
},
"strip-ansi": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
"dev": true,
"requires": {
"ansi-regex": "^4.1.0"
}
}
}
},
"tapable": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz",
@@ -7546,6 +8144,12 @@
"minimatch": "^3.0.4"
}
},
"text-table": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
"through2": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
@@ -7674,53 +8278,6 @@
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
"dev": true
},
"tslint": {
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz",
"integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"builtin-modules": "^1.1.1",
"chalk": "^2.3.0",
"commander": "^2.12.1",
"diff": "^4.0.1",
"glob": "^7.1.1",
"js-yaml": "^3.13.1",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.3",
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.13.0",
"tsutils": "^2.29.0"
},
"dependencies": {
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dev": true,
"requires": {
"minimist": "^1.2.5"
}
},
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true
}
}
},
"tsutils": {
"version": "2.29.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"tty-browserify": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
@@ -9172,6 +9729,26 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"write": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz",
"integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==",
"dev": true,
"requires": {
"mkdirp": "^0.5.1"
},
"dependencies": {
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dev": true,
"requires": {
"minimist": "^1.2.5"
}
}
}
},
"write-file-atomic": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz",
+6 -4
View File
@@ -5,8 +5,8 @@
"main": "index.js",
"types": "./dist/src",
"scripts": {
"lint": "tslint --project tsconfig.json",
"fix": "tslint --project tsconfig.json --fix",
"lint": "eslint ./src",
"fix": "eslint ./src --fix",
"clean": "rimraf dist",
"build": "npm run clean && webpack --config webpack/development.config.js --progress && webpack --config webpack/production.config.js --progress",
"watch": "npm run clean && webpack-dev-server --config webpack/development.config.js --progress",
@@ -33,17 +33,19 @@
},
"homepage": "https://github.com/tbluemel/rtf.js#readme",
"devDependencies": {
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"chai": "^4.2.0",
"chai-html": "^1.3.0",
"copy-webpack-plugin": "^6.1.0",
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
"coveralls": "^3.1.0",
"eslint": "^7.8.1",
"jsdom": "^16.4.0",
"mocha": "^8.1.3",
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"ts-loader": "^8.0.3",
"tslint": "^6.1.3",
"typescript": "^4.0.2",
"typewiz-core": "^1.2.4",
"typewiz-webpack": "^1.2.4",
+14 -13
View File
@@ -29,14 +29,15 @@ import { Blob } from "./Blob";
import { EMFJSError, Helper } from "./Helper";
export class BitmapBase {
public getWidth() {
public getWidth(): number {
throw new EMFJSError("getWidth not implemented");
}
public getHeight() {
public getHeight(): number {
throw new EMFJSError("getHeight not implemented");
}
}
export class BitmapCoreHeader {
public width: number;
public height: number;
@@ -53,7 +54,7 @@ export class BitmapCoreHeader {
this.bitcount = reader.readUint16();
}
public colors() {
public colors(): number {
return this.bitcount <= 8 ? 1 << this.bitcount : 0;
}
}
@@ -86,7 +87,7 @@ export class BitmapInfoHeader {
this.clrimportant = reader.readUint32();
}
public colors() {
public colors(): number {
if (this.clrused !== 0) {
return this.clrused < 256 ? this.clrused : 256;
} else {
@@ -111,7 +112,7 @@ export class BitmapInfo extends BitmapBase {
} else {
this._header = new BitmapInfoHeader(reader, false);
const masks = (this._header as BitmapInfoHeader).compression
=== Helper.GDI.BitmapCompression.BI_BITFIELDS ? 3 : 0;
=== Helper.GDI.BitmapCompression.BI_BITFIELDS ? 3 : 0;
if (hdrsize <= Helper.GDI.BITMAPINFOHEADER_SIZE + (masks * 4)) {
this._infosize = Helper.GDI.BITMAPINFOHEADER_SIZE + (masks * 4);
}
@@ -119,19 +120,19 @@ export class BitmapInfo extends BitmapBase {
}
}
public getWidth() {
public getWidth(): number {
return this._header.width;
}
public getHeight() {
public getHeight(): number {
return Math.abs(this._header.height);
}
public infosize() {
public infosize(): number {
return this._infosize;
}
public header() {
public header(): BitmapCoreHeader | BitmapInfoHeader {
return this._header;
}
}
@@ -150,11 +151,11 @@ export class DIBitmap extends BitmapBase {
this._info = new BitmapInfo(reader, true);
}
public getWidth() {
public getWidth(): number {
return this._info.getWidth();
}
public getHeight() {
public getHeight(): number {
return this._info.getHeight();
}
@@ -162,7 +163,7 @@ export class DIBitmap extends BitmapBase {
return this._location.header.size + this._location.data.size;
}
public makeBitmapFileHeader() {
public makeBitmapFileHeader(): string {
const buf = new ArrayBuffer(14);
const view = new Uint8Array(buf);
view[0] = 0x42;
@@ -172,7 +173,7 @@ export class DIBitmap extends BitmapBase {
return Helper._blobToBinary(view);
}
public base64ref() {
public base64ref(): string {
const prevpos = this._reader.pos;
this._reader.seek(this._offset);
let mime = "image/bmp";
+13 -13
View File
@@ -44,18 +44,18 @@ export class Blob {
}
}
public eof() {
public eof(): boolean {
return this.pos >= this.data.length;
}
public seek(newpos: number) {
public seek(newpos: number): void {
if (newpos < 0 || newpos > this.data.length) {
throw new EMFJSError("Invalid seek position");
}
this.pos = newpos;
}
public skip(cnt: number) {
public skip(cnt: number): void {
const newPos = this.pos + cnt;
if (newPos > this.data.length) {
throw new EMFJSError("Unexpected end of file");
@@ -63,7 +63,7 @@ export class Blob {
this.pos = newPos;
}
public readBinary(cnt: number) {
public readBinary(cnt: number): string {
const end = this.pos + cnt;
if (end > this.data.length) {
throw new EMFJSError("Unexpected end of file");
@@ -75,18 +75,18 @@ export class Blob {
return ret;
}
public readInt8() {
public readInt8(): number {
if (this.pos + 1 > this.data.length) {
throw new EMFJSError("Unexpected end of file");
}
return this.data[this.pos++];
}
public readUint8() {
public readUint8(): number {
return this.readInt8() >>> 0;
}
public readInt32() {
public readInt32(): number {
if (this.pos + 4 > this.data.length) {
throw new EMFJSError("Unexpected end of file");
}
@@ -97,11 +97,11 @@ export class Blob {
return val;
}
public readUint32() {
public readUint32(): number {
return this.readInt32() >>> 0;
}
public readUint16() {
public readUint16(): number {
if (this.pos + 2 > this.data.length) {
throw new EMFJSError("Unexpected end of file");
}
@@ -110,7 +110,7 @@ export class Blob {
return val;
}
public readInt16() {
public readInt16(): number {
let val = this.readUint16();
if (val > 32767) {
val -= 65536;
@@ -118,7 +118,7 @@ export class Blob {
return val;
}
public readString(length: number) {
public readString(length: number): string {
if (this.pos + length > this.data.length) {
throw new EMFJSError("Unexpected end of file");
}
@@ -129,7 +129,7 @@ export class Blob {
return ret;
}
public readNullTermString(maxSize: number) {
public readNullTermString(maxSize: number): string {
let ret = "";
if (maxSize > 0) {
maxSize--;
@@ -147,7 +147,7 @@ export class Blob {
return ret;
}
public readFixedSizeUnicodeString(fixedSizeChars: number) {
public readFixedSizeUnicodeString(fixedSizeChars: number): string {
let ret = "";
for (let i = 0; i < fixedSizeChars; i++) {
const charCode = this.readUint16();
+2 -2
View File
@@ -116,7 +116,7 @@ export class EmfHeader {
}
}
public toString() {
public toString(): string {
return "{bounds: " + this.bounds.toString() + ", frame: " + this.frame.toString()
+ ", description: " + this.description + "}";
}
@@ -584,7 +584,7 @@ export class EMFRecords {
}
}
public play(gdi: GDIContext) {
public play(gdi: GDIContext): void {
const len = this._records.length;
for (let i = 0; i < len; i++) {
this._records[i](gdi);
+43 -43
View File
@@ -38,6 +38,7 @@ export interface ISelectedStyle {
font?: Font;
region?: Region;
path?: Path;
[key: string]: Obj;
}
@@ -53,11 +54,11 @@ export class Path extends Obj {
}
}
public clone() {
public clone(): Path {
return new Path(null, this);
}
public toString() {
public toString(): string {
return "{[path]}";
}
}
@@ -244,47 +245,47 @@ export class GDIContext {
this.objects = {};
}
public setMapMode(mode: number) {
public setMapMode(mode: number): void {
Helper.log("[gdi] setMapMode: mode=" + mode);
this.state.mapmode = mode;
this.state._svggroup = null;
}
public setWindowOrgEx(x: number, y: number) {
public setWindowOrgEx(x: number, y: number): void {
Helper.log("[gdi] setWindowOrgEx: x=" + x + " y=" + y);
this.state.wx = x;
this.state.wy = y;
this.state._svggroup = null;
}
public setWindowExtEx(x: number, y: number) {
public setWindowExtEx(x: number, y: number): void {
Helper.log("[gdi] setWindowExtEx: x=" + x + " y=" + y);
this.state.ww = x;
this.state.wh = y;
this.state._svggroup = null;
}
public setViewportOrgEx(x: number, y: number) {
public setViewportOrgEx(x: number, y: number): void {
Helper.log("[gdi] setViewportOrgEx: x=" + x + " y=" + y);
this.state.vx = x;
this.state.vy = y;
this.state._svggroup = null;
}
public setViewportExtEx(x: number, y: number) {
public setViewportExtEx(x: number, y: number): void {
Helper.log("[gdi] setViewportExtEx: x=" + x + " y=" + y);
this.state.vw = x;
this.state.vh = y;
this.state._svggroup = null;
}
public setBrushOrgEx(origin: PointL) {
public setBrushOrgEx(origin: PointL): void {
Helper.log("[gdi] setBrushOrgEx: x=" + origin.x + " y=" + origin.y);
this.state.nextbrx = origin.x;
this.state.nextbry = origin.y;
}
public saveDC() {
public saveDC(): void {
Helper.log("[gdi] saveDC");
const prevstate = this.state;
this.state = new GDIContextState(this.state);
@@ -292,7 +293,7 @@ export class GDIContext {
this.state._svggroup = null;
}
public restoreDC(saved: number) {
public restoreDC(saved: number): void {
Helper.log("[gdi] restoreDC: saved=" + saved);
if (this.statestack.length > 1) {
if (saved === -1) {
@@ -309,11 +310,11 @@ export class GDIContext {
this.state._svggroup = null;
}
public setStretchBltMode(stretchMode: number) {
public setStretchBltMode(stretchMode: number): void {
Helper.log("[gdi] setStretchBltMode: stretchMode=" + stretchMode);
}
public rectangle(rect: RectL, rw: number, rh: number) {
public rectangle(rect: RectL, rw: number, rh: number): void {
Helper.log("[gdi] rectangle: rect=" + rect.toString() + " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
const bottom = this._todevY(rect.bottom);
@@ -330,7 +331,7 @@ export class GDIContext {
this._svg.rect(this.state._svggroup, left, top, right - left, bottom - top, rw / 2, rh / 2, opts);
}
public lineTo(x: number, y: number) {
public lineTo(x: number, y: number): void {
Helper.log("[gdi] lineTo: x=" + x + " y=" + y + " with pen " + this.state.selected.pen.toString());
const toX = this._todevX(x);
const toY = this._todevY(y);
@@ -348,7 +349,7 @@ export class GDIContext {
this._svg.line(this.state._svggroup, fromX, fromY, toX, toY, opts);
}
public moveToEx(x: number, y: number) {
public moveToEx(x: number, y: number): void {
Helper.log("[gdi] moveToEx: x=" + x + " y=" + y);
this.state.x = x;
this.state.y = y;
@@ -358,7 +359,7 @@ export class GDIContext {
}
}
public polygon(points: PointS[] | PointL[], bounds: RectL, first: boolean) {
public polygon(points: PointS[] | PointL[], bounds: RectL, first: boolean): void {
Helper.log("[gdi] polygon: points=" + points + " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
const pts = [];
@@ -376,7 +377,7 @@ export class GDIContext {
this._svg.polygon(this.state._svggroup, pts, opts);
}
public polyPolygon(polygons: PointS[][] | PointL[][], bounds: RectL) {
public polyPolygon(polygons: PointS[][] | PointL[][], bounds: RectL): void {
Helper.log("[gdi] polyPolygon: polygons.length=" + polygons.length
+ " with pen " + this.state.selected.pen.toString() + " and brush " + this.state.selected.brush.toString());
@@ -386,7 +387,7 @@ export class GDIContext {
}
}
public polyline(isLineTo: boolean, points: PointS[], bounds: RectL) {
public polyline(isLineTo: boolean, points: PointS[], bounds: RectL): void {
Helper.log("[gdi] polyline: isLineTo=" + isLineTo.toString() + ", points=" + points
+ ", bounds=" + bounds.toString() + " with pen " + this.state.selected.pen.toString());
const pts: number[][] = [];
@@ -423,7 +424,7 @@ export class GDIContext {
}
}
public polybezier(isPolyBezierTo: boolean, points: PointS[], bounds: RectL) {
public polybezier(isPolyBezierTo: boolean, points: PointS[], bounds: RectL): void {
Helper.log("[gdi] polybezier: isPolyBezierTo=" + isPolyBezierTo.toString() + ", points=" + points
+ ", bounds=" + bounds.toString() + " with pen " + this.state.selected.pen.toString());
const pts = [];
@@ -463,11 +464,11 @@ export class GDIContext {
}
}
public selectClipPath(rgnMode: number) {
public selectClipPath(rgnMode: number): void {
Helper.log("[gdi] selectClipPath: rgnMode=0x" + rgnMode.toString(16));
}
public selectClipRgn(rgnMode: number, region: Region) {
public selectClipRgn(rgnMode: number, region: Region): void {
Helper.log("[gdi] selectClipRgn: rgnMode=0x" + rgnMode.toString(16));
if (rgnMode === Helper.GDI.RegionMode.RGN_COPY) {
this.state.selected.region = region;
@@ -483,53 +484,53 @@ export class GDIContext {
this.state._svgclipChanged = true;
}
public offsetClipRgn(offset: PointL) {
public offsetClipRgn(offset: PointL): void {
Helper.log("[gdi] offsetClipRgn: offset=" + offset.toString());
this._getClipRgn().offset(offset.x, offset.y);
}
public setTextAlign(textAlignmentMode: number) {
public setTextAlign(textAlignmentMode: number): void {
Helper.log("[gdi] setTextAlign: textAlignmentMode=0x" + textAlignmentMode.toString(16));
this.state.textalign = textAlignmentMode;
}
public setMiterLimit(miterLimit: number) {
public setMiterLimit(miterLimit: number): void {
Helper.log("[gdi] setMiterLimit: miterLimit=" + miterLimit);
this.state.miterlimit = miterLimit;
}
public setBkMode(bkMode: number) {
public setBkMode(bkMode: number): void {
Helper.log("[gdi] setBkMode: bkMode=0x" + bkMode.toString(16));
this.state.bkmode = bkMode;
}
public setBkColor(bkColor: ColorRef) {
public setBkColor(bkColor: ColorRef): void {
Helper.log("[gdi] setBkColor: bkColor=" + bkColor.toString());
this.state.bkcolor = bkColor;
this.state._svgtextbkfilter = null;
}
public setPolyFillMode(polyFillMode: number) {
public setPolyFillMode(polyFillMode: number): void {
Helper.log("[gdi] setPolyFillMode: polyFillMode=" + polyFillMode);
this.state.polyfillmode = polyFillMode;
}
public createBrush(index: number, brush: Brush) {
public createBrush(index: number, brush: Brush): void {
const idx = this._storeObject(brush, index);
Helper.log("[gdi] createBrush: brush=" + brush.toString() + " with handle " + idx);
}
public createPen(index: number, pen: Pen) {
public createPen(index: number, pen: Pen): void {
const idx = this._storeObject(pen, index);
Helper.log("[gdi] createPen: pen=" + pen.toString() + " width handle " + idx);
}
public createPenEx(index: number, pen: Pen) {
public createPenEx(index: number, pen: Pen): void {
const idx = this._storeObject(pen, index);
Helper.log("[gdi] createPenEx: pen=" + pen.toString() + " width handle " + idx);
}
public selectObject(objIdx: number, checkType: string) {
public selectObject(objIdx: number, checkType: string): void {
const obj = this._getObject(objIdx);
if (obj != null && (checkType == null || obj.type === checkType)) {
this._selectObject(obj);
@@ -541,14 +542,14 @@ export class GDIContext {
}
}
public abortPath() {
public abortPath(): void {
Helper.log("[gdi] abortPath");
if (this._svgPath != null) {
this._svgPath = null;
}
}
public beginPath() {
public beginPath(): void {
Helper.log("[gdi] beginPath");
if (this._svgPath != null) {
@@ -558,7 +559,7 @@ export class GDIContext {
this._svgPath = this._svg.createPath();
}
public closeFigure() {
public closeFigure(): void {
Helper.log("[gdi] closeFigure");
if (this._svgPath == null) {
throw new EMFJSError("No path bracket: cannot close figure");
@@ -567,7 +568,7 @@ export class GDIContext {
this._svgPath.close();
}
public fillPath(bounds: RectL) {
public fillPath(bounds: RectL): void {
Helper.log("[gdi] fillPath");
if (this.state.selected.path == null) {
throw new EMFJSError("No path selected");
@@ -581,7 +582,7 @@ export class GDIContext {
this.state.selected.path = null;
}
public strokePath(bounds: RectL) {
public strokePath(bounds: RectL): void {
Helper.log("[gdi] strokePath");
if (this.state.selected.path == null) {
throw new EMFJSError("No path selected");
@@ -595,7 +596,7 @@ export class GDIContext {
this.state.selected.path = null;
}
public endPath() {
public endPath(): void {
Helper.log("[gdi] endPath");
if (this._svgPath == null) {
throw new EMFJSError("No path bracket: cannot end path");
@@ -606,12 +607,12 @@ export class GDIContext {
this._svgPath = null;
}
public deleteObject(objIdx: number) {
public deleteObject(objIdx: number): void {
const ret = this._deleteObject(objIdx);
Helper.log("[gdi] deleteObject: objIdx=" + objIdx + (ret ? " deleted object" : "[invalid index]"));
}
private _pushGroup() {
private _pushGroup(): void {
if (this.state._svggroup == null || this.state._svgclipChanged) {
this.state._svgclipChanged = false;
this.state._svgtextbkfilter = null;
@@ -849,18 +850,17 @@ export class GDIContext {
const pen = this.state.selected.pen;
if (pen.style !== Helper.GDI.PenStyle.PS_NULL) {
opts.stroke = "#" + pen.color.toHex(); // TODO: pen style
opts["stroke-width"] = pen.width;
opts["stroke-width"] = pen.width;
opts["stroke-miterlimit"] = this.state.miterlimit;
let dotWidth;
opts["stroke-linecap"] = "round";
dotWidth = 1;
const dotWidth = 1;
opts["stroke-linejoin"] = "round";
const dashWidth = opts["stroke-width"] * 4;
const dotSpacing = opts["stroke-width"] * 2;
const dashWidth = opts["stroke-width"] * 4;
const dotSpacing = opts["stroke-width"] * 2;
switch (pen.style) {
case Helper.GDI.PenStyle.PS_DASH:
opts["stroke-dasharray"] = [dashWidth, dotSpacing].toString();
+6 -6
View File
@@ -33,7 +33,8 @@ export class EMFJSError extends Error {
}
let isLoggingEnabled = true;
export function loggingEnabled(enabled: boolean) {
export function loggingEnabled(enabled: boolean): void {
isLoggingEnabled = enabled;
}
@@ -322,25 +323,24 @@ export class Helper {
public static _uniqueId = 0;
public static log(message: string) {
public static log(message: string): void {
if (isLoggingEnabled) {
// tslint:disable-next-line:no-console
console.log(message);
}
}
public static _makeUniqueId(prefix: string) {
public static _makeUniqueId(prefix: string): string {
return "EMFJS_" + prefix + (this._uniqueId++);
}
public static _writeUint32Val(uint8arr: Uint8Array, pos: number, val: number) {
public static _writeUint32Val(uint8arr: Uint8Array, pos: number, val: number): void {
uint8arr[pos++] = val & 0xff;
uint8arr[pos++] = (val >>> 8) & 0xff;
uint8arr[pos++] = (val >>> 16) & 0xff;
uint8arr[pos++] = (val >>> 24) & 0xff;
}
public static _blobToBinary(blob: Uint8Array) {
public static _blobToBinary(blob: Uint8Array): string {
let ret = "";
const len = blob.length;
for (let i = 0; i < len; i++) {
+11 -11
View File
@@ -42,11 +42,11 @@ export class PointS {
}
}
public clone() {
public clone(): PointS {
return new PointS(null, this.x, this.y);
}
public toString() {
public toString(): string {
return "{x: " + this.x + ", y: " + this.y + "}";
}
}
@@ -65,11 +65,11 @@ export class PointL {
}
}
public clone() {
public clone(): PointL {
return new PointL(null, this.x, this.y);
}
public toString() {
public toString(): string {
return "{x: " + this.x + ", y: " + this.y + "}";
}
}
@@ -94,20 +94,20 @@ export class RectL {
}
}
public clone() {
public clone(): RectL {
return new RectL(null, this.left, this.top, this.right, this.bottom);
}
public toString() {
public toString(): string {
return "{left: " + this.left + ", top: " + this.top + ", right: " + this.right
+ ", bottom: " + this.bottom + "}";
}
public empty() {
public empty(): boolean {
return this.left >= this.right || this.top >= this.bottom;
}
public intersect(rectL: RectL) {
public intersect(rectL: RectL): null | RectL {
if (this.empty() || rectL.empty()) {
return null;
}
@@ -134,11 +134,11 @@ export class SizeL {
}
}
public clone() {
public clone(): SizeL {
return new SizeL(null, this.cx, this.cy);
}
public toString() {
public toString(): string {
return "{cx: " + this.cx + ", cy: " + this.cy + "}";
}
}
@@ -154,7 +154,7 @@ export class Obj {
throw new EMFJSError("clone not implemented");
}
public toString() {
public toString(): string {
throw new EMFJSError("toString not implemented");
}
}
+13 -13
View File
@@ -53,7 +53,7 @@ export class Region extends Obj {
let scanLine;
for (let i = 0; i < rectCnt; i++) {
const r = new RectL(reader);
if (scanLine == null || scanLine.top !== r.top || scanLine.bottom !== r.bottom) {
if (!!scanLine || scanLine.top !== r.top || scanLine.bottom !== r.bottom) {
scanLine = new Scan(r);
this.scans.push(scanLine);
} else {
@@ -79,18 +79,18 @@ export class Region extends Obj {
}
}
public clone() {
public clone(): Region {
return new Region(null, this);
}
public toString() {
public toString(): string {
const _complexity = ["null", "simple", "complex"];
return "{complexity: " + _complexity[this.complexity]
+ " bounds: " + (this.bounds != null ? this.bounds.toString() : "[none]")
+ " #scans: " + (this.scans != null ? this.scans.length : "[none]") + "}";
}
public _updateComplexity() {
public _updateComplexity(): void {
if (this.bounds == null) {
this.complexity = 0;
this.scans = null;
@@ -115,7 +115,7 @@ export class Region extends Obj {
}
}
public subtract(rect: RectL) {
public subtract(rect: RectL): void {
Helper.log("[emf] Region " + this.toString() + " subtract " + rect.toString());
if (this.bounds != null) {
@@ -242,7 +242,7 @@ export class Region extends Obj {
Helper.log("[emf] Region subtraction -> " + this.toString());
}
public intersect(rect: RectL) {
public intersect(rect: RectL): void {
Helper.log("[emf] Region " + this.toString() + " intersect with " + rect.toString());
if (this.bounds != null) {
this.bounds = this.bounds.intersect(rect);
@@ -302,7 +302,7 @@ export class Region extends Obj {
Helper.log("[emf] Region intersection -> " + this.toString());
}
public offset(offX: number, offY: number) {
public offset(offX: number, offY: number): void {
if (this.bounds != null) {
this.bounds.left += offX;
this.bounds.top += offY;
@@ -328,7 +328,7 @@ export class Region extends Obj {
}
}
export function CreateSimpleRegion(left: number, top: number, right: number, bottom: number) {
export function CreateSimpleRegion(left: number, top: number, right: number, bottom: number): Region {
const rgn = new Region(null, null);
rgn.bounds = new RectL(null, left, top, right, bottom);
rgn._updateComplexity();
@@ -338,7 +338,7 @@ export function CreateSimpleRegion(left: number, top: number, right: number, bot
export class Scan {
public top: number;
public bottom: number;
public scanlines: {left: number, right: number}[];
public scanlines: { left: number, right: number }[];
constructor(r: RectL, copy?: Scan) {
if (r != null) {
@@ -356,15 +356,15 @@ export class Scan {
}
}
public clone() {
public clone(): Scan {
return new Scan(null, this);
}
public append(r: RectL) {
public append(r: RectL): void {
this.scanlines.push({left: r.left, right: r.right});
}
public subtract(left: number, right: number) {
public subtract(left: number, right: number): boolean {
let i;
// Keep everything on the left side
@@ -409,7 +409,7 @@ export class Scan {
return this.scanlines.length > 0;
}
public intersect(left: number, right: number) {
public intersect(left: number, right: number): boolean {
// Get rid of anything that falls entirely outside to the left
for (let i = 0; i < this.scanlines.length; i++) {
const scanline = this.scanlines[i];
+1 -1
View File
@@ -107,7 +107,7 @@ export class EMF {
this._records = new EMFRecords(reader, this._hdrsize);
}
public render(gdi: GDIContext) {
public render(gdi: GDIContext): void {
this._records.play(gdi);
}
}
+16 -16
View File
@@ -30,7 +30,7 @@ import { Blob } from "./Blob";
import { Helper } from "./Helper";
import { Obj, PointL } from "./Primitives";
export class ColorRef {
export class ColorRef {
public r: number;
public g: number;
public b: number;
@@ -48,16 +48,16 @@ export class ColorRef {
}
}
public clone() {
public clone(): ColorRef {
return new ColorRef(null, this.r, this.g, this.b);
}
public toHex() {
public toHex(): string {
const rgb = (this.r << 16) | (this.g << 8) | this.b;
return (0x1000000 + rgb).toString(16).slice(1);
}
public toString() {
public toString(): string {
return "{r: " + this.r + ", g: " + this.g + ", b: " + this.b + "}";
}
}
@@ -138,11 +138,11 @@ export class Font extends Obj {
}
}
public clone() {
public clone(): Font {
return new Font(null, this);
}
public toString() {
public toString(): string {
return JSON.stringify(this);
}
}
@@ -154,8 +154,10 @@ export class Brush extends Obj {
public dibpatternpt: DIBitmap;
public hatchstyle: number;
constructor(reader: Blob, copy?: {style?: number, color?: ColorRef, pattern?: DIBitmap,
dibpatternpt?: DIBitmap, hatchstyle?: number}) {
constructor(reader: Blob, copy?: {
style?: number, color?: ColorRef, pattern?: DIBitmap,
dibpatternpt?: DIBitmap, hatchstyle?: number
}) {
super("brush");
if (reader != null) {
const start = reader.pos;
@@ -198,11 +200,11 @@ export class Brush extends Obj {
}
}
public clone() {
public clone(): Brush {
return new Brush(null, this);
}
public toString() {
public toString(): string {
let ret = "{style: " + this.style;
switch (this.style) {
case Helper.GDI.BrushStyle.BS_SOLID:
@@ -217,19 +219,17 @@ export class Brush extends Obj {
}
export class Pen extends Obj {
public style: number | {header: {off: number, size: number}, data: {off: number, size: number}};
public style: number | { header: { off: number, size: number }, data: { off: number, size: number } };
public width: number;
public brush: Brush;
public color: ColorRef;
constructor(reader: Blob, style?: number | {header: {off: number, size: number}, data: {off: number, size: number}},
constructor(reader: Blob, style?: number | { header: { off: number, size: number }, data: { off: number, size: number } },
width?: number, color?: ColorRef, brush?: Brush) {
super("pen");
if (reader != null) {
if (style != null) {
// LogPenEx
const bitmapInfo = style;
this.style = reader.readUint32() & 0xFF;
this.width = reader.readUint32();
this.brush = new Brush(reader);
@@ -253,12 +253,12 @@ export class Pen extends Obj {
}
}
public clone() {
public clone(): Pen {
return new Pen(null, this.style, this.width, this.color != null ? this.color.clone() : null,
this.brush != null ? this.brush.clone() : null);
}
public toString() {
public toString(): string {
return "{style: " + this.style + ", width: " + this.width
+ ", color: " + (this.color != null ? this.color.toString() : "none") + "}";
}
+4 -4
View File
@@ -32,11 +32,11 @@ import { Renderer } from "./renderer/Renderer";
export class Document {
public _settings: ISettings;
public _meta: {[key: string]: any};
public _meta: { [key: string]: any };
public _fonts: FonttblDestinationSub[];
public _colors: IColor[];
public _autoColor: number;
public _stylesheets: {index: number, name: string}[];
public _stylesheets: { index: number, name: string }[];
public _ins: (string | ((renderer: Renderer) => void))[];
constructor(settings: ISettings) {
@@ -49,7 +49,7 @@ export class Document {
this._ins = [];
}
public _lookupColor(idx: number) {
public _lookupColor(idx: number): null | IColor {
if (idx === 0) {
if (this._autoColor == null) {
return null;
@@ -62,7 +62,7 @@ export class Document {
return this._colors[idx];
}
public addIns(ins: string | ((renderer: Renderer) => void)) {
public addIns(ins: string | ((renderer: Renderer) => void)): void {
this._ins.push(ins);
}
+8 -6
View File
@@ -27,10 +27,10 @@ SOFTWARE.
import { Document } from "./Document";
import { RTFJSError } from "./Helper";
import { Parser } from "./parser/Parser";
import {IContainerElement, Renderer} from "./renderer/Renderer";
import { IContainerElement, Renderer } from "./renderer/Renderer";
export interface ISettings {
onHyperlink?(create: () => HTMLElement, hyperlink: {url: () => string}): IContainerElement;
onHyperlink?(create: () => HTMLElement, hyperlink: { url: () => string }): IContainerElement;
/**
* Callback which is called with information about the type of picture and a function to render it.
@@ -40,10 +40,12 @@ export interface ISettings {
* @param create A function which returns the result of rendering the picture.
* @return The {HTMLElement} you want to display
*/
onPicture?(isLegacy: null|boolean, create: () => HTMLElement): HTMLElement;
onPicture?(isLegacy: null | boolean, create: () => HTMLElement): HTMLElement;
onImport?(relUrls: string, callback: (data: {error?: Error, keyword?: string, blob?: ArrayBuffer,
width?: number, height?: number}) => void): void;
onImport?(relUrls: string, callback: (data: {
error?: Error, keyword?: string, blob?: ArrayBuffer,
width?: number, height?: number
}) => void): void;
}
export class DocumentFacade {
@@ -58,7 +60,7 @@ export class DocumentFacade {
this._parsed = parser.parse();
}
public metadata() {
public metadata(): { [key: string]: any } {
return this._document._meta;
}
+27 -27
View File
@@ -34,7 +34,8 @@ export class RTFJSError extends Error {
}
let isLoggingEnabled = true;
export function loggingEnabled(enabled: boolean) {
export function loggingEnabled(enabled: boolean): void {
isLoggingEnabled = enabled;
}
@@ -90,9 +91,8 @@ export class Helper {
DOUBLE: "dbch",
};
public static log(message: string) {
public static log(message: string): void {
if (isLoggingEnabled) {
// tslint:disable-next-line:no-console
console.log(message);
}
}
@@ -102,7 +102,7 @@ export class Helper {
for (let i = 0; i < len; i++) {
const ch = str.charCodeAt(i);
if (!((ch >= this._A && ch <= this._Z) ||
(ch >= this._a && ch <= this._z))) {
(ch >= this._a && ch <= this._z))) {
return false;
}
}
@@ -125,8 +125,8 @@ export class Helper {
for (let i = 0; i < len; i++) {
const ch = str.charCodeAt(i);
if (!((ch >= this._0 && ch <= this._9) ||
(ch >= this._a && ch <= this._f) ||
(ch >= this._A && ch <= this._F))) {
(ch >= this._a && ch <= this._f) ||
(ch >= this._A && ch <= this._F))) {
return NaN;
}
}
@@ -178,23 +178,23 @@ export class Helper {
return this._charsetMap[idx.toString()];
}
public static _mapColorTheme(name: string) {
public static _mapColorTheme(name: string): null {
return this._colorThemeMap[name];
}
public static _colorToStr(color: IColor) {
public static _colorToStr(color: IColor): string {
return "rgb(" + color.r + "," + color.g + "," + color.b + ")";
}
public static _twipsToPt(twips: number) {
public static _twipsToPt(twips: number): number {
return Math.floor(twips / 20);
}
public static _twipsToPx(twips: number) {
public static _twipsToPx(twips: number): number {
return Math.floor(twips / 20 * 96 / 72);
}
public static _pxToTwips(px: number) {
public static _pxToTwips(px: number): number {
return Math.floor(px * 20 * 72 / 96);
}
@@ -207,21 +207,21 @@ export class Helper {
private static _0 = "0".charCodeAt(0);
private static _9 = "9".charCodeAt(0);
private static _charsetMap: {[key: string]: number} = {
0: 1252, // ANSI_CHARSET
2: 42, // Symbol (this is not a real charset, CP_SYMBOL maps unicode characters into a different range)
77: 10000, // Mac Roman
78: 10001, // Mac Shift Jis
79: 10003, // Mac Hangul
80: 10008, // Mac GB2312
81: 10002, // Mac Big5
83: 10005, // Mac Hebrew
84: 10004, // Mac Arabic
85: 10006, // Mac Greek
86: 10081, // Mac Turkish
87: 10021, // Mac Thai
88: 10029, // Mac East Europe
89: 10007, // Mac Russian
private static _charsetMap: { [key: string]: number } = {
0: 1252, // ANSI_CHARSET
2: 42, // Symbol (this is not a real charset, CP_SYMBOL maps unicode characters into a different range)
77: 10000, // Mac Roman
78: 10001, // Mac Shift Jis
79: 10003, // Mac Hangul
80: 10008, // Mac GB2312
81: 10002, // Mac Big5
83: 10005, // Mac Hebrew
84: 10004, // Mac Arabic
85: 10006, // Mac Greek
86: 10081, // Mac Turkish
87: 10021, // Mac Thai
88: 10029, // Mac East Europe
89: 10007, // Mac Russian
128: 932, // SHIFTJIS_CHARSET
129: 949, // HANGEUL_CHARSET
130: 1361, // JOHAB_CHARSET
@@ -240,7 +240,7 @@ export class Helper {
255: 850, // OEM
};
private static _colorThemeMap: {[key: string]: null} = {
private static _colorThemeMap: { [key: string]: null } = {
// TODO
maindarkone: null,
mainlightone: null,
+2 -2
View File
@@ -128,7 +128,7 @@ export class Parser {
} else if (value instanceof HexText) {
// Looking for current fonttbl charset
let codepage = this.parser.codepage;
if (value.chp.hasOwnProperty("fontfamily")) {
if (Object.prototype.hasOwnProperty.call(value.chp, "fontfamily")) {
const idx = value.chp.fontfamily;
// Code page 42 isn't a real code page and shouldn't appear here
if (this.inst._fonts !== undefined && this.inst._fonts[idx] != null
@@ -386,7 +386,7 @@ export class Parser {
let ch = this.readChar();
if (!Helper._isalpha(ch)) {
// 8 bit character encoded as hexadecimal
if (ch === "\'") {
if (ch === "'") {
const hex = this.readChar() + this.readChar();
param = Helper._parseHex(hex);
@@ -52,7 +52,7 @@ export class ColortblDestination extends DestinationBase {
this.inst = inst;
}
public appendText(text: string) {
public appendText(text: string): void {
const len = text.length;
for (let i = 0; i < len; i++) {
if (text[i] !== ";") {
@@ -74,7 +74,7 @@ export class ColortblDestination extends DestinationBase {
}
}
public handleKeyword(keyword: string, param: number) {
public handleKeyword(keyword: string, param: number): boolean {
if (this._current == null) {
this._startNewColor();
}
@@ -107,7 +107,7 @@ export class ColortblDestination extends DestinationBase {
return false;
}
public apply() {
public apply(): void {
Helper.log("[colortbl] apply()");
if (this._autoIndex == null) {
this._autoIndex = 0;
@@ -137,7 +137,7 @@ export class ColortblDestination extends DestinationBase {
return this._current;
}
private _validateColorValueRange(keyword: string, param: number) {
private _validateColorValueRange(keyword: string, param: number): number {
if (param == null) {
throw new RTFJSError(keyword + " has no param");
}
@@ -39,12 +39,19 @@ export abstract class DestinationFactory<T extends IDestination> {
export interface IDestination {
_name: string;
setMetadata?(metaprop: string, metavalue: any): void;
apply?(): void;
appendText?(text: string): void;
sub?(): IDestination;
handleKeyword?(keyword: string, param: number): void | boolean;
handleBlob?(blob: ArrayBuffer): void;
[key: string]: any;
}
@@ -79,7 +86,7 @@ export class DestinationTextBase implements IDestination {
this.text = "";
}
public appendText(text: string) {
public appendText(text: string): void {
this.text += text;
}
}
@@ -95,19 +102,19 @@ export abstract class DestinationFormattedTextBase implements IDestination {
this._records = [];
}
public appendText(text: string) {
public appendText(text: string): void {
this._records.push((rtf: RtfDestination) => {
rtf.appendText(text);
});
}
public handleKeyword(keyword: string, param: number) {
public handleKeyword(keyword: string, param: number): void {
this._records.push((rtf: RtfDestination) => {
return rtf.handleKeyword(keyword, param);
});
}
public apply() {
public apply(): void {
const rtf = findParentDestination(this.parser, "rtf") as any as RtfDestination;
if (rtf == null) {
throw new RTFJSError("IDestination " + this._name + " is not child of rtf destination");
@@ -138,6 +145,7 @@ export abstract class DestinationFormattedTextBase implements IDestination {
export interface IGenericPropertyDestination extends IDestination {
apply(): void;
}
export class GenericPropertyDestinationFactory extends DestinationFactory<IGenericPropertyDestination> {
constructor(parentdest: string, metaprop: string) {
super();
@@ -167,6 +175,7 @@ export class GenericPropertyDestinationFactory extends DestinationFactory<IGener
export interface IGenericSubTextPropertyDestination extends IDestination {
apply(): void;
}
export class GenericSubTextPropertyDestinationFactory extends DestinationFactory<IGenericSubTextPropertyDestination> {
constructor(name: string, parentDest: string, propOrFunc: string) {
super();
@@ -197,13 +206,10 @@ export class GenericSubTextPropertyDestinationFactory extends DestinationFactory
}
}
// tslint:disable-next-line:no-empty-interface
export interface IRequiredDestination extends IDestination {
}
export class RequiredDestinationFactory extends DestinationFactory<IRequiredDestination> {
export class RequiredDestinationFactory extends DestinationFactory<IDestination> {
constructor(name: string) {
super();
this.class = class extends DestinationBase implements IRequiredDestination {
this.class = class extends DestinationBase implements IDestination {
constructor() {
super(name);
}
@@ -42,7 +42,6 @@ import { PictDestination, PictGroupDestinationFactory } from "./PictDestinations
import { RtfDestination } from "./RtfDestination";
import { StylesheetDestination } from "./StylesheetDestination";
// tslint:disable-next-line:variable-name
export const Destinations
: {[key: string]
: ((new (parser: GlobalState, inst: Document, name: string, param: number) => any)
@@ -54,7 +54,7 @@ export class FieldDestination extends DestinationBase {
this._result = null;
}
public apply() {
public apply(): void {
if (!this._haveInst) {
throw new RTFJSError("IField has no fldinst destination");
}
@@ -63,7 +63,7 @@ export class FieldDestination extends DestinationBase {
// throw new RTFJSError("IField has no fldrslt destination");
}
public setInst(inst: IField | Promise<IField | null>) {
public setInst(inst: IField | Promise<IField | null>): void {
this._haveInst = true;
if (this._parsedInst != null) {
throw new RTFJSError("IField cannot have multiple fldinst destinations");
@@ -80,11 +80,11 @@ export class FieldDestination extends DestinationBase {
}
}
public getInst() {
public getInst(): IField {
return this._parsedInst;
}
public setResult(inst: FldrsltDestination) {
public setResult(inst: FldrsltDestination): void {
if (this._result != null) {
throw new RTFJSError("IField cannot have multiple fldrslt destinations");
}
@@ -99,7 +99,7 @@ export class FieldBase {
this._fldinst = fldinst;
}
public renderFieldEnd(field: FieldDestination, rtf: RtfDestination, records: number) {
public renderFieldEnd(field: FieldDestination, rtf: RtfDestination, records: number): void {
if (records > 0) {
rtf.addIns((renderer) => {
renderer.popContainer();
@@ -116,24 +116,23 @@ export class FieldHyperlink extends FieldBase {
this._url = data;
}
public url() {
public url(): string {
return this._url;
}
public renderFieldBegin(field: FieldDestination, rtf: RtfDestination, records: number) {
const self = this;
public renderFieldBegin(field: FieldDestination, rtf: RtfDestination, records: number): boolean {
if (records > 0) {
rtf.addIns((renderer) => {
const inst = renderer._doc;
const create = () => {
return renderer.buildHyperlinkElement(self._url);
return renderer.buildHyperlinkElement(this._url);
};
let container;
if (inst._settings.onHyperlink != null) {
container = inst._settings.onHyperlink(create,
{
url() {
return self.url();
return this.url();
},
});
} else {
@@ -161,7 +160,7 @@ export class FldinstDestination extends DestinationTextBase {
this.inst = inst;
}
public apply() {
public apply(): void {
const field = findParentDestination(this.parser, "field") as FieldDestination;
if (field == null) {
throw new RTFJSError("fldinst destination must be child of field destination");
@@ -194,7 +193,7 @@ export class FldinstDestination extends DestinationTextBase {
const hook = inst._settings.onPicture;
inst._settings.onPicture = null;
// tslint:disable-next-line:prefer-const
// eslint-disable-next-line prefer-const
let {isLegacy, element} = pict.apply(true);
// restore
@@ -253,6 +252,7 @@ export class FldinstDestination extends DestinationTextBase {
this.parser._asyncTasks.push(promise);
return promise;
}
break;
default:
Helper.log("[fldinst]: unknown field type: " + fieldType);
break;
@@ -266,7 +266,7 @@ export class FldrsltDestination extends DestinationFormattedTextBase {
super(parser, "fldrslt");
}
public apply() {
public apply(): void {
const field = findParentDestination(this.parser, "field") as FieldDestination;
if (field != null) {
field.setResult(this);
@@ -275,7 +275,7 @@ export class FldrsltDestination extends DestinationFormattedTextBase {
super.apply();
}
public renderBegin(rtf: RtfDestination, records: number) {
public renderBegin(rtf: RtfDestination, records: number): boolean {
const field = findParentDestination(this.parser, "field") as FieldDestination;
if (field != null) {
const inst = field.getInst();
@@ -286,7 +286,7 @@ export class FldrsltDestination extends DestinationFormattedTextBase {
return false;
}
public renderEnd(rtf: RtfDestination, records: number) {
public renderEnd(rtf: RtfDestination, records: number): void {
const field = findParentDestination(this.parser, "field") as FieldDestination;
if (field != null) {
const inst = field.getInst();
@@ -51,7 +51,7 @@ export class FonttblDestinationSub extends DestinationBase {
this.charset = null;
}
public handleKeyword(keyword: string, param: number) {
public handleKeyword(keyword: string, param: number): boolean {
switch (keyword) {
case "f":
this.index = param;
@@ -110,7 +110,7 @@ export class FonttblDestinationSub extends DestinationBase {
return false;
}
public appendText(text: string) {
public appendText(text: string): void {
if (this.fontname == null) {
this.fontname = text;
} else {
@@ -118,7 +118,7 @@ export class FonttblDestinationSub extends DestinationBase {
}
}
public apply() {
public apply(): void {
if (this.index == null) {
throw new RTFJSError("No font index provided");
}
@@ -129,7 +129,7 @@ export class FonttblDestinationSub extends DestinationBase {
delete this._fonttbl;
}
public setAltFontName(name: string) {
public setAltFontName(name: string): void {
this.altfontname = name;
}
}
@@ -146,11 +146,11 @@ export class FonttblDestination extends DestinationBase {
this.inst = inst;
}
public sub() {
public sub(): FonttblDestinationSub {
return new FonttblDestinationSub(this);
}
public apply() {
public apply(): void {
Helper.log("[fonttbl] apply()");
for (const idx in this._fonts) {
Helper.log("[fonttbl][" + idx + "] index = " + this._fonts[idx].fontname
@@ -160,19 +160,19 @@ export class FonttblDestination extends DestinationBase {
delete this._fonts;
}
public appendText(text: string) {
public appendText(text: string): void {
this._sub.appendText(text);
this._sub.apply();
}
public handleKeyword(keyword: string, param: number) {
public handleKeyword(keyword: string, param: number): void {
if (keyword === "f") {
this._sub = this.sub();
}
this._sub.handleKeyword(keyword, param);
}
public addSub(sub: FonttblDestinationSub) {
public addSub(sub: FonttblDestinationSub): void {
this._fonts[sub.index] = sub;
}
}
@@ -45,14 +45,14 @@ export class InfoDestination extends DestinationBase {
this.inst = inst;
}
public apply() {
public apply(): void {
for (const prop in this._metadata) {
this.inst._meta[prop] = this._metadata[prop];
}
delete this._metadata;
}
public setMetadata(prop: string, val: any) {
public setMetadata(prop: string, val: any): void {
this._metadata[prop] = val;
}
}
@@ -61,6 +61,7 @@ export class PictDestination extends DestinationTextBase {
private _blob: ArrayBuffer;
private parser: GlobalState;
private inst: Document;
[key: string]: any;
private _pictHandlers: { [key: string]: (param: number) => void } = {
@@ -70,8 +71,10 @@ export class PictDestination extends DestinationTextBase {
pichgoal: this._setPropValueRequired("_displaysize", "height"),
};
private _pictTypeHandler: { [key: string]
: string | ((param?: number) => { load: () => any, render: (img: any) => Element }) } = {
private _pictTypeHandler: {
[key: string]
: string | ((param?: number) => { load: () => any, render: (img: any) => Element })
} = {
emfblip: (() => {
if (typeof EMFJS !== "undefined") {
return () => {
@@ -161,7 +164,7 @@ export class PictDestination extends DestinationTextBase {
this.inst = inst;
}
public handleKeyword(keyword: string, param: number) {
public handleKeyword(keyword: string, param: number): boolean {
const handler = this._pictHandlers[keyword];
if (handler != null) {
handler(param);
@@ -194,11 +197,11 @@ export class PictDestination extends DestinationTextBase {
return false;
}
public handleBlob(blob: ArrayBuffer) {
public handleBlob(blob: ArrayBuffer): void {
this._blob = blob;
}
public apply(rendering = false) {
public apply(rendering = false): { isLegacy: boolean, element: HTMLElement } {
if (this._type == null) {
throw new RTFJSError("Picture type unknown or not specified");
}
@@ -248,13 +251,13 @@ export class PictDestination extends DestinationTextBase {
if (this.inst._settings.onPicture != null) {
this.inst.addIns((renderer) => {
const elem = this.inst._settings.onPicture(isLegacy, () => {
return doRender(renderer, true);
});
if (elem != null) {
renderer.appendElement(elem);
}
const elem = this.inst._settings.onPicture(isLegacy, () => {
return doRender(renderer, true);
});
if (elem != null) {
renderer.appendElement(elem);
}
});
} else {
return {
isLegacy,
@@ -288,13 +291,13 @@ export class PictDestination extends DestinationTextBase {
if (this.inst._settings.onPicture != null) {
this.inst.addIns((renderer) => {
const elem = this.inst._settings.onPicture(isLegacy, () => {
return doRender(renderer, true);
});
if (elem != null) {
renderer.appendElement(elem);
}
const elem = this.inst._settings.onPicture(isLegacy, () => {
return doRender(renderer, true);
});
if (elem != null) {
renderer.appendElement(elem);
}
});
} else {
return {
isLegacy,
@@ -141,20 +141,20 @@ export class RtfDestination extends DestinationBase {
this.inst = inst;
}
public addIns(func: (renderer: Renderer) => void) {
public addIns(func: (renderer: Renderer) => void): void {
this.inst.addIns(func);
}
public appendText(text: string) {
public appendText(text: string): void {
Helper.log("[rtf] output: " + text);
this.inst.addIns(text);
}
public sub() {
public sub(): void {
Helper.log("[rtf].sub()");
}
public handleKeyword(keyword: string, param: number) {
public handleKeyword(keyword: string, param: number): boolean {
const handler = this._charFormatHandlers[keyword];
if (handler != null) {
handler(param);
@@ -163,7 +163,7 @@ export class RtfDestination extends DestinationBase {
return false;
}
public apply() {
public apply(): void {
Helper.log("[rtf] apply()");
for (const prop in this._metadata) {
this.inst._meta[prop] = this._metadata[prop];
@@ -171,7 +171,7 @@ export class RtfDestination extends DestinationBase {
delete this._metadata;
}
public setMetadata(prop: string, val: any) {
public setMetadata(prop: string, val: any): void {
this._metadata[prop] = val;
}
@@ -184,18 +184,20 @@ export class RtfDestination extends DestinationBase {
private _addFormatIns(ptype: string, props: Chp | Pap) {
Helper.log("[rtf] update " + ptype);
switch (ptype) {
case "chp":
case "chp": {
const rchp = new RenderChp(new Chp(props as Chp));
this.inst.addIns((renderer) => {
renderer.setChp(rchp);
});
break;
case "pap":
}
case "pap": {
const rpap = new RenderPap(new Pap(props as Pap));
this.inst.addIns((renderer) => {
renderer.setPap(rpap);
});
break;
}
}
}
@@ -44,7 +44,7 @@ export class StylesheetDestinationSub extends DestinationBase {
this.handler = this._handleKeywordCommon("paragraph");
}
public handleKeyword(keyword: string, param: number) {
public handleKeyword(keyword: string, param: number): boolean {
switch (keyword) {
case "s":
this.index = param;
@@ -69,7 +69,7 @@ export class StylesheetDestinationSub extends DestinationBase {
return this.handler(keyword, param);
}
public appendText(text: string) {
public appendText(text: string): void {
if (this.name == null) {
this.name = text;
} else {
@@ -77,7 +77,7 @@ export class StylesheetDestinationSub extends DestinationBase {
}
}
public apply() {
public apply(): void {
this._stylesheet.addSub({
index: this.index,
name: this.name,
@@ -103,11 +103,11 @@ export class StylesheetDestination extends DestinationBase {
this.inst = inst;
}
public sub() {
public sub(): StylesheetDestinationSub {
return new StylesheetDestinationSub(this);
}
public apply() {
public apply(): void {
Helper.log("[stylesheet] apply()");
for (const idx in this._stylesheets) {
Helper.log("[stylesheet] [" + idx + "] name: " + this._stylesheets[idx].name);
@@ -116,7 +116,7 @@ export class StylesheetDestination extends DestinationBase {
delete this._stylesheets;
}
public addSub(sub: { index: number, name: string }) {
public addSub(sub: { index: number, name: string }): void {
// Some documents will redefine stylesheets
// if (this._stylesheets[sub.index] != null)
// throw new RTFJSError("Cannot redefine stylesheet with index " + sub.index);
+2 -2
View File
@@ -35,7 +35,7 @@ export class RenderChp {
this._chp = chp;
}
public apply(doc: Document, el: HTMLElement) {
public apply(doc: Document, el: HTMLElement): void {
Helper.log("[rtf] RenderChp: " + el.textContent);
Helper.log("[rtf] RenderChp apply: " + JSON.stringify(this._chp));
if (this._chp.bold) {
@@ -44,7 +44,7 @@ export class RenderChp {
if (this._chp.italic) {
el.style.fontStyle = "italic";
}
if (this._chp.hasOwnProperty("fontfamily") && doc._fonts[this._chp.fontfamily]) {
if (Object.prototype.hasOwnProperty.call(this._chp, "fontfamily") && doc._fonts[this._chp.fontfamily]) {
const fontFamily = doc._fonts[this._chp.fontfamily].fontname.replace(";", "");
if (fontFamily !== "Symbol") {
el.style.fontFamily = fontFamily;
+1 -1
View File
@@ -36,7 +36,7 @@ export class RenderPap {
this._pap = pap;
}
public apply(doc: Document, el: HTMLElement, rchp: RenderChp, ismaindiv: boolean) {
public apply(doc: Document, el: HTMLElement, rchp: RenderChp, ismaindiv: boolean): void {
Helper.log("[rtf] RenderPap apply:" + (rchp != null ? " chp=" + JSON.stringify(rchp._chp) : "")
+ " pap=" + JSON.stringify(this._pap) + " ismaindiv=" + ismaindiv);
if (ismaindiv) {
+10 -10
View File
@@ -55,7 +55,7 @@ export class Renderer {
this._curcont = [];
}
public pushContainer(contel: IContainerElement) {
public pushContainer(contel: IContainerElement): void {
if (this._curpar == null) {
this.startPar();
}
@@ -73,7 +73,7 @@ export class Renderer {
}
}
public popContainer() {
public popContainer(): void {
const contel = this._curcont.pop();
if (contel == null) {
throw new RTFJSError("No container on rendering stack");
@@ -86,7 +86,7 @@ export class Renderer {
return link;
}
public _appendToPar(el: HTMLElement, newsubpar?: boolean) {
public _appendToPar(el: HTMLElement, newsubpar?: boolean): void {
if (this._curpar == null) {
this.startPar();
}
@@ -118,7 +118,7 @@ export class Renderer {
}
}
public startPar() {
public startPar(): void {
this._curpar = document.createElement("div");
if (this._curRPap != null) {
this._curRPap.apply(this._doc, this._curpar, this._curRChp, true);
@@ -129,15 +129,15 @@ export class Renderer {
this._dom.push(this._curpar);
}
public lineBreak() {
public lineBreak(): void {
this._appendToPar(null, true);
}
public setChp(rchp: RenderChp) {
public setChp(rchp: RenderChp): void {
this._curRChp = rchp;
}
public setPap(rpap: RenderPap) {
public setPap(rpap: RenderPap): void {
this._curRPap = rpap;
if (this._cursubpar != null) {
this._curRPap.apply(this._doc, this._cursubpar, null, false);
@@ -148,7 +148,7 @@ export class Renderer {
}
}
public appendElement(element: HTMLElement) {
public appendElement(element: HTMLElement): void {
this._appendToPar(element);
}
@@ -160,7 +160,7 @@ export class Renderer {
return element;
}
public renderedPicture(element: HTMLElement) {
public renderedPicture(element: HTMLElement): void {
this._appendToPar(this.buildRenderedPicture(element));
}
@@ -180,7 +180,7 @@ export class Renderer {
}
}
public picture(mime: string, data: string) {
public picture(mime: string, data: string): void {
this._appendToPar(this.buildPicture(mime, data));
}
+1 -1
View File
@@ -205,7 +205,7 @@ export class SVG {
return ellipseElement;
}
public path(parent: SVGElement, builder: SVGPathBuilder, settings?: any) {
public path(parent: SVGElement, builder: SVGPathBuilder, settings?: any): SVGPathElement {
const pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
pathElement.setAttribute("d", builder.path());
this._appendSettings(settings, pathElement);
+15 -15
View File
@@ -28,11 +28,11 @@ import { Blob } from "./Blob";
import { Helper, WMFJSError } from "./Helper";
export class BitmapBase {
public getWidth() {
public getWidth(): number {
throw new WMFJSError("getWidth not implemented");
}
public getHeight() {
public getHeight(): number {
throw new WMFJSError("getHeight not implemented");
}
}
@@ -53,7 +53,7 @@ export class BitmapCoreHeader {
this.bitcount = reader.readUint16();
}
public colors() {
public colors(): number {
return this.bitcount <= 8 ? 1 << this.bitcount : 0;
}
}
@@ -86,7 +86,7 @@ export class BitmapInfoHeader {
this.clrimportant = reader.readUint32();
}
public colors() {
public colors(): number {
if (this.clrused !== 0) {
return this.clrused < 256 ? this.clrused : 256;
} else {
@@ -123,19 +123,19 @@ export class BitmapInfo extends BitmapBase {
}
}
public getWidth() {
public getWidth(): number {
return this._header.width;
}
public getHeight() {
public getHeight(): number {
return Math.abs(this._header.height);
}
public infosize() {
public infosize(): number {
return this._infosize;
}
public header() {
public header(): BitmapCoreHeader | BitmapInfoHeader {
return this._header;
}
}
@@ -154,21 +154,21 @@ export class DIBitmap extends BitmapBase {
this._info = new BitmapInfo(reader, true);
}
public getWidth() {
public getWidth(): number {
return this._info.getWidth();
}
public getHeight() {
public getHeight(): number {
return this._info.getHeight();
}
public base64ref() {
public base64ref(): string {
const prevpos = this._reader.pos;
this._reader.seek(this._offset);
let mime = "image/bmp";
const header = this._info.header();
let data;
if (header instanceof BitmapInfoHeader && header.compression != null) {
if (header instanceof BitmapInfoHeader && header.compression != null) {
switch (header.compression) {
case Helper.GDI.BitmapCompression.BI_JPEG:
mime = "data:image/jpeg";
@@ -253,15 +253,15 @@ export class Bitmap16 extends BitmapBase {
}
}
public getWidth() {
public getWidth(): number {
return this.width;
}
public getHeight() {
public getHeight(): number {
return this.height;
}
public clone() {
public clone(): Bitmap16 {
return new Bitmap16(null, this);
}
}
+12 -12
View File
@@ -43,18 +43,18 @@ export class Blob {
}
}
public eof() {
public eof(): boolean {
return this.pos >= this.data.length;
}
public seek(newpos: number) {
public seek(newpos: number): void {
if (newpos < 0 || newpos > this.data.length) {
throw new WMFJSError("Invalid seek position");
}
this.pos = newpos;
}
public skip(cnt: number) {
public skip(cnt: number): void {
const newPos = this.pos + cnt;
if (newPos > this.data.length) {
throw new WMFJSError("Unexpected end of file");
@@ -62,7 +62,7 @@ export class Blob {
this.pos = newPos;
}
public readBinary(cnt: number) {
public readBinary(cnt: number): string {
const end = this.pos + cnt;
if (end > this.data.length) {
throw new WMFJSError("Unexpected end of file");
@@ -74,18 +74,18 @@ export class Blob {
return ret;
}
public readInt8() {
public readInt8(): number {
if (this.pos + 1 > this.data.length) {
throw new WMFJSError("Unexpected end of file");
}
return this.data[this.pos++];
}
public readUint8() {
public readUint8(): number {
return this.readInt8() >>> 0;
}
public readInt32() {
public readInt32(): number {
if (this.pos + 4 > this.data.length) {
throw new WMFJSError("Unexpected end of file");
}
@@ -96,11 +96,11 @@ export class Blob {
return val;
}
public readUint32() {
public readUint32(): number {
return this.readInt32() >>> 0;
}
public readUint16() {
public readUint16(): number {
if (this.pos + 2 > this.data.length) {
throw new WMFJSError("Unexpected end of file");
}
@@ -109,7 +109,7 @@ export class Blob {
return val;
}
public readInt16() {
public readInt16(): number {
let val = this.readUint16();
if (val > 32767) {
val -= 65536;
@@ -117,7 +117,7 @@ export class Blob {
return val;
}
public readString(length: number) {
public readString(length: number): string {
if (this.pos + length > this.data.length) {
throw new WMFJSError("Unexpected end of file");
}
@@ -128,7 +128,7 @@ export class Blob {
return ret;
}
public readNullTermString(maxSize: number) {
public readNullTermString(maxSize: number): string {
let ret = "";
if (maxSize > 0) {
maxSize--;
+47 -46
View File
@@ -24,7 +24,7 @@ SOFTWARE.
*/
import { SVG } from "../util/SVG";
import { SVG } from "../util";
import { DIBitmap } from "./Bitmap";
import { Blob } from "./Blob";
import { Helper, WMFJSError } from "./Helper";
@@ -38,6 +38,7 @@ export interface ISelectedStyle {
font?: Font;
palette?: Palette;
region?: Region;
[key: string]: Obj;
}
@@ -133,12 +134,12 @@ export class GDIContextState {
export class GDIContext {
private _svg: SVG;
private _svgdefs: SVGDefsElement;
private _svgPatterns: {[key: string]: Brush};
private _svgClipPaths: {[key: string]: Region};
private _svgPatterns: { [key: string]: Brush };
private _svgClipPaths: { [key: string]: Region };
private defObjects: ISelectedStyle;
private state: GDIContextState;
private statestack: GDIContextState[];
private objects: {[key: string]: Obj};
private objects: { [key: string]: Obj };
constructor(svg: SVG) {
this._svg = svg;
@@ -159,55 +160,55 @@ export class GDIContext {
this.objects = {};
}
public setMapMode(mode: number) {
public setMapMode(mode: number): void {
Helper.log("[gdi] setMapMode: mode=" + mode);
this.state.mapmode = mode;
this.state._svggroup = null;
}
public setWindowOrg(x: number, y: number) {
public setWindowOrg(x: number, y: number): void {
Helper.log("[gdi] setWindowOrg: x=" + x + " y=" + y);
this.state.wx = x;
this.state.wy = y;
this.state._svggroup = null;
}
public setWindowExt(x: number, y: number) {
public setWindowExt(x: number, y: number): void {
Helper.log("[gdi] setWindowExt: x=" + x + " y=" + y);
this.state.ww = x;
this.state.wh = y;
this.state._svggroup = null;
}
public offsetWindowOrg(offX: number, offY: number) {
public offsetWindowOrg(offX: number, offY: number): void {
Helper.log("[gdi] offsetWindowOrg: offX=" + offX + " offY=" + offY);
this.state.wx += offX;
this.state.wy += offY;
this.state._svggroup = null;
}
public setViewportOrg(x: number, y: number) {
public setViewportOrg(x: number, y: number): void {
Helper.log("[gdi] setViewportOrg: x=" + x + " y=" + y);
this.state.vx = x;
this.state.vy = y;
this.state._svggroup = null;
}
public setViewportExt(x: number, y: number) {
public setViewportExt(x: number, y: number): void {
Helper.log("[gdi] setViewportExt: x=" + x + " y=" + y);
this.state.vw = x;
this.state.vh = y;
this.state._svggroup = null;
}
public offsetViewportOrg(offX: number, offY: number) {
public offsetViewportOrg(offX: number, offY: number): void {
Helper.log("[gdi] offsetViewportOrg: offX=" + offX + " offY=" + offY);
this.state.vx += offX;
this.state.vy += offY;
this.state._svggroup = null;
}
public saveDC() {
public saveDC(): void {
Helper.log("[gdi] saveDC");
const prevstate = this.state;
this.state = new GDIContextState(this.state);
@@ -215,7 +216,7 @@ export class GDIContext {
this.state._svggroup = null;
}
public restoreDC(saved: number) {
public restoreDC(saved: number): void {
Helper.log("[gdi] restoreDC: saved=" + saved);
if (this.statestack.length > 1) {
if (saved === -1) {
@@ -232,17 +233,17 @@ export class GDIContext {
this.state._svggroup = null;
}
public escape(func: number, blob: Blob, offset: number, count: number) {
public escape(func: number, blob: Blob, offset: number, count: number): void {
Helper.log("[gdi] escape: func=" + func + " offset=" + offset + " count=" + count);
}
public setStretchBltMode(stretchMode: number) {
public setStretchBltMode(stretchMode: number): void {
Helper.log("[gdi] setStretchBltMode: stretchMode=" + stretchMode);
}
public stretchDib(srcX: number, srcY: number, srcW: number, srcH: number,
dstX: number, dstY: number, dstW: number, dstH: number,
rasterOp: number, colorUsage: number, dib: DIBitmap) {
rasterOp: number, colorUsage: number, dib: DIBitmap): void {
Helper.log("[gdi] stretchDib: srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH
+ " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH
+ " rasterOp=0x" + rasterOp.toString(16));
@@ -263,7 +264,7 @@ export class GDIContext {
public stretchDibBits(srcX: number, srcY: number, srcW: number, srcH: number,
dstX: number, dstY: number, dstW: number, dstH: number,
rasterOp: number, dib: DIBitmap) {
rasterOp: number, dib: DIBitmap): void {
Helper.log("[gdi] stretchDibBits: srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH
+ " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH
+ " rasterOp=0x" + rasterOp.toString(16));
@@ -283,7 +284,7 @@ export class GDIContext {
this._svg.image(this.state._svggroup, dstX, dstY, dstW, dstH, dib.base64ref());
}
public rectangle(rect: Rect, rw: number, rh: number) {
public rectangle(rect: Rect, rw: number, rh: number): void {
Helper.log("[gdi] rectangle: rect=" + rect.toString() + " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
const bottom = this._todevY(rect.bottom);
@@ -300,7 +301,7 @@ export class GDIContext {
this._svg.rect(this.state._svggroup, left, top, right - left, bottom - top, rw / 2, rh / 2, opts);
}
public textOut(x: number, y: number, text: string) {
public textOut(x: number, y: number, text: string): void {
Helper.log("[gdi] textOut: x=" + x + " y=" + y + " text=" + text
+ " with font " + this.state.selected.font.toString());
x = this._todevX(x);
@@ -327,7 +328,7 @@ export class GDIContext {
this._svg.text(this.state._svggroup, x, y, text, opts);
}
public extTextOut(x: number, y: number, text: string, fwOpts: number, rect: Rect, dx: number[]) {
public extTextOut(x: number, y: number, text: string, fwOpts: number, rect: Rect, dx: number[]): void {
Helper.log("[gdi] extTextOut: x=" + x + " y=" + y + " text=" + text
+ " with font " + this.state.selected.font.toString());
x = this._todevX(x);
@@ -354,7 +355,7 @@ export class GDIContext {
this._svg.text(this.state._svggroup, x, y, text, opts);
}
public lineTo(x: number, y: number) {
public lineTo(x: number, y: number): void {
Helper.log("[gdi] lineTo: x=" + x + " y=" + y + " with pen " + this.state.selected.pen.toString());
const toX = this._todevX(x);
const toY = this._todevY(y);
@@ -372,13 +373,13 @@ export class GDIContext {
this._svg.line(this.state._svggroup, fromX, fromY, toX, toY, opts);
}
public moveTo(x: number, y: number) {
public moveTo(x: number, y: number): void {
Helper.log("[gdi] moveTo: x=" + x + " y=" + y);
this.state.x = x;
this.state.y = y;
}
public polygon(points: PointS[], first: boolean) {
public polygon(points: PointS[], first: boolean): void {
Helper.log("[gdi] polygon: points=" + points + " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
const pts = [];
@@ -397,7 +398,7 @@ export class GDIContext {
this._svg.polygon(this.state._svggroup, pts, opts);
}
public polyPolygon(polygons: PointS[][]) {
public polyPolygon(polygons: PointS[][]): void {
Helper.log("[gdi] polyPolygon: polygons.length=" + polygons.length
+ " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
@@ -408,7 +409,7 @@ export class GDIContext {
}
}
public polyline(points: PointS[]) {
public polyline(points: PointS[]): void {
Helper.log("[gdi] polyline: points=" + points + " with pen " + this.state.selected.pen.toString());
const pts = [];
for (let i = 0; i < points.length; i++) {
@@ -421,7 +422,7 @@ export class GDIContext {
this._svg.polyline(this.state._svggroup, pts, opts);
}
public ellipse(rect: Rect) {
public ellipse(rect: Rect): void {
Helper.log("[gdi] ellipse: rect=" + rect.toString() + " with pen " + this.state.selected.pen.toString()
+ " and brush " + this.state.selected.brush.toString());
const bottom = this._todevY(rect.bottom);
@@ -436,78 +437,78 @@ export class GDIContext {
this._svg.ellipse(this.state._svggroup, left + width2, top + height2, width2, height2, opts);
}
public excludeClipRect(rect: Rect) {
public excludeClipRect(rect: Rect): void {
Helper.log("[gdi] excludeClipRect: rect=" + rect.toString());
this._getClipRgn().subtract(rect);
}
public intersectClipRect(rect: Rect) {
public intersectClipRect(rect: Rect): void {
Helper.log("[gdi] intersectClipRect: rect=" + rect.toString());
this._getClipRgn().intersect(rect);
}
public offsetClipRgn(offX: number, offY: number) {
public offsetClipRgn(offX: number, offY: number): void {
Helper.log("[gdi] offsetClipRgn: offX=" + offX + " offY=" + offY);
this._getClipRgn().offset(offX, offY);
}
public setTextAlign(textAlignmentMode: number) {
public setTextAlign(textAlignmentMode: number): void {
Helper.log("[gdi] setTextAlign: textAlignmentMode=0x" + textAlignmentMode.toString(16));
this.state.textalign = textAlignmentMode;
}
public setBkMode(bkMode: number) {
public setBkMode(bkMode: number): void {
Helper.log("[gdi] setBkMode: bkMode=0x" + bkMode.toString(16));
this.state.bkmode = bkMode;
}
public setTextColor(textColor: ColorRef) {
public setTextColor(textColor: ColorRef): void {
Helper.log("[gdi] setTextColor: textColor=" + textColor.toString());
this.state.textcolor = textColor;
}
public setBkColor(bkColor: ColorRef) {
public setBkColor(bkColor: ColorRef): void {
Helper.log("[gdi] setBkColor: bkColor=" + bkColor.toString());
this.state.bkcolor = bkColor;
this.state._svgtextbkfilter = null;
}
public setPolyFillMode(polyFillMode: number) {
public setPolyFillMode(polyFillMode: number): void {
Helper.log("[gdi] setPolyFillMode: polyFillMode=" + polyFillMode);
this.state.polyfillmode = polyFillMode;
}
public createBrush(brush: Brush) {
public createBrush(brush: Brush): void {
const idx = this._storeObject(brush);
Helper.log("[gdi] createBrush: brush=" + brush.toString() + " with handle " + idx);
}
public createFont(font: Font) {
public createFont(font: Font): void {
const idx = this._storeObject(font);
Helper.log("[gdi] createFont: font=" + font.toString() + " with handle " + idx);
}
public createPen(pen: Pen) {
public createPen(pen: Pen): void {
const idx = this._storeObject(pen);
Helper.log("[gdi] createPen: pen=" + pen.toString() + " width handle " + idx);
}
public createPalette(palette: Palette) {
public createPalette(palette: Palette): void {
const idx = this._storeObject(palette);
Helper.log("[gdi] createPalette: palette=" + palette.toString() + " width handle " + idx);
}
public createRegion(region: Region) {
public createRegion(region: Region): void {
const idx = this._storeObject(region);
Helper.log("[gdi] createRegion: region=" + region.toString() + " width handle " + idx);
}
public createPatternBrush(patternBrush: Brush) {
public createPatternBrush(patternBrush: Brush): void {
const idx = this._storeObject(patternBrush);
Helper.log("[gdi] createRegion: region=" + patternBrush.toString() + " width handle " + idx);
}
public selectObject(objIdx: number, checkType: string) {
public selectObject(objIdx: number, checkType: string): void {
const obj = this._getObject(objIdx);
if (obj != null && (checkType == null || obj.type === checkType)) {
this._selectObject(obj);
@@ -519,7 +520,7 @@ export class GDIContext {
}
}
public deleteObject(objIdx: number) {
public deleteObject(objIdx: number): void {
const ret = this._deleteObject(objIdx);
Helper.log("[gdi] deleteObject: objIdx=" + objIdx + (ret ? " deleted object" : "[invalid index]"));
}
@@ -590,7 +591,7 @@ export class GDIContext {
this._svg.rect(sclip, this._todevX(region.bounds.left), this._todevY(region.bounds.top),
this._todevW(region.bounds.right - region.bounds.left),
this._todevH(region.bounds.bottom - region.bounds.top),
{ "fill": "black", "stroke-width": 0 });
{"fill": "black", "stroke-width": 0});
break;
case 2:
for (let i = 0; i < region.scans.length; i++) {
@@ -599,7 +600,7 @@ export class GDIContext {
const scanline = scan.scanlines[j];
this._svg.rect(sclip, this._todevX(scanline.left), this._todevY(scan.top),
this._todevW(scanline.right - scanline.left), this._todevH(scan.bottom - scan.top),
{ "fill": "black", "stroke-width": 0 });
{"fill": "black", "stroke-width": 0});
}
}
break;
@@ -736,7 +737,7 @@ export class GDIContext {
if (usePen) {
const pen = this.state.selected.pen;
if (pen.style !== Helper.GDI.PenStyle.PS_NULL) {
opts.stroke = "#" + pen.color.toHex(), // TODO: pen style
opts.stroke = "#" + pen.color.toHex(), // TODO: pen style
opts["stroke-width"] = this._todevW(pen.width.x); // TODO: is .y ever used?
let dotWidth;
@@ -760,7 +761,7 @@ export class GDIContext {
}
const dashWidth = opts["stroke-width"] * 4;
const dotSpacing = opts["stroke-width"] * 2;
const dotSpacing = opts["stroke-width"] * 2;
switch (pen.style) {
case Helper.GDI.PenStyle.PS_DASH:
opts["stroke-dasharray"] = [dashWidth, dotSpacing].toString();
+6 -6
View File
@@ -32,7 +32,8 @@ export class WMFJSError extends Error {
}
let isLoggingEnabled = true;
export function loggingEnabled(enabled: boolean) {
export function loggingEnabled(enabled: boolean): void {
isLoggingEnabled = enabled;
}
@@ -269,25 +270,24 @@ export class Helper {
};
public static _uniqueId = 0;
public static log(message: string) {
public static log(message: string): void {
if (isLoggingEnabled) {
// tslint:disable-next-line:no-console
console.log(message);
}
}
public static _makeUniqueId(prefix: string) {
public static _makeUniqueId(prefix: string): string {
return "wmfjs_" + prefix + (this._uniqueId++);
}
public static _writeUint32Val(uint8arr: Uint8Array, pos: number, val: number) {
public static _writeUint32Val(uint8arr: Uint8Array, pos: number, val: number): void {
uint8arr[pos++] = val & 0xff;
uint8arr[pos++] = (val >>> 8) & 0xff;
uint8arr[pos++] = (val >>> 16) & 0xff;
uint8arr[pos++] = (val >>> 24) & 0xff;
}
public static _blobToBinary(blob: Uint8Array) {
public static _blobToBinary(blob: Uint8Array): string {
let ret = "";
const len = blob.length;
for (let i = 0; i < len; i++) {
+7 -7
View File
@@ -41,11 +41,11 @@ export class PointS {
}
}
public clone() {
public clone(): PointS {
return new PointS(null, this.x, this.y);
}
public toString() {
public toString(): string {
return "{x: " + this.x + ", y: " + this.y + "}";
}
}
@@ -70,20 +70,20 @@ export class Rect {
}
}
public clone() {
public clone(): Rect {
return new Rect(null, this.left, this.top, this.right, this.bottom);
}
public toString() {
public toString(): string {
return "{left: " + this.left + ", top: " + this.top + ", right: " + this.right
+ ", bottom: " + this.bottom + "}";
}
public empty() {
public empty(): boolean {
return this.left >= this.right || this.top >= this.bottom;
}
public intersect(rect: Rect) {
public intersect(rect: Rect): null | Rect {
if (this.empty() || rect.empty()) {
return null;
}
@@ -107,7 +107,7 @@ export class Obj {
throw new WMFJSError("clone not implemented");
}
public toString() {
public toString(): string {
throw new WMFJSError("toString not implemented");
}
}
+14 -14
View File
@@ -73,18 +73,18 @@ export class Region extends Obj {
}
}
public clone() {
public clone(): Region {
return new Region(null, this);
}
public toString() {
public toString(): string {
const _complexity = ["null", "simple", "complex"];
return "{complexity: " + _complexity[this.complexity]
+ " bounds: " + (this.bounds != null ? this.bounds.toString() : "[none]")
+ " #scans: " + (this.scans != null ? this.scans.length : "[none]") + "}";
}
public _updateComplexity() {
public _updateComplexity(): void {
if (this.bounds == null) {
this.complexity = 0;
this.scans = null;
@@ -109,7 +109,7 @@ export class Region extends Obj {
}
}
public subtract(rect: Rect) {
public subtract(rect: Rect): void {
Helper.log("[wmf] Region " + this.toString() + " subtract " + rect.toString());
if (this.bounds != null) {
@@ -120,7 +120,7 @@ export class Region extends Obj {
// We need to create scanlines now. Simplest method is to fake one scan line
// that equals the simple region and re-use the same logic as for complex regions
this.scans = [];
this.scans.push( new Scan(null, null, this.bounds.top, this.bounds.bottom,
this.scans.push(new Scan(null, null, this.bounds.top, this.bounds.bottom,
[{left: this.bounds.left, right: this.bounds.right}]));
this.complexity = 2;
}
@@ -236,7 +236,7 @@ export class Region extends Obj {
Helper.log("[wmf] Region subtraction -> " + this.toString());
}
public intersect(rect: Rect) {
public intersect(rect: Rect): void {
Helper.log("[wmf] Region " + this.toString() + " intersect with " + rect.toString());
if (this.bounds != null) {
this.bounds = this.bounds.intersect(rect);
@@ -296,7 +296,7 @@ export class Region extends Obj {
Helper.log("[wmf] Region intersection -> " + this.toString());
}
public offset(offX: number, offY: number) {
public offset(offX: number, offY: number): void {
if (this.bounds != null) {
this.bounds.left += offX;
this.bounds.top += offY;
@@ -322,7 +322,7 @@ export class Region extends Obj {
}
}
export function CreateSimpleRegion(left: number, top: number, right: number, bottom: number) {
export function CreateSimpleRegion(left: number, top: number, right: number, bottom: number): Region {
const rgn = new Region(null, null);
rgn.bounds = new Rect(null, left, top, right, bottom);
rgn._updateComplexity();
@@ -332,10 +332,10 @@ export function CreateSimpleRegion(left: number, top: number, right: number, bot
export class Scan {
public top: number;
public bottom: number;
public scanlines: {left: number, right: number}[];
public scanlines: { left: number, right: number }[];
constructor(reader: Blob, copy?: Scan, top?: number, bottom?: number,
scanlines?: {left: number, right: number}[]) {
scanlines?: { left: number, right: number }[]) {
if (reader != null) {
const cnt = reader.readUint16();
this.top = reader.readUint16();
@@ -362,11 +362,11 @@ export class Scan {
}
}
public clone() {
public clone(): Scan {
return new Scan(null, this);
}
public subtract(left: number, right: number) {
public subtract(left: number, right: number): boolean {
let i;
// Keep everything on the left side
@@ -411,7 +411,7 @@ export class Scan {
return this.scanlines.length > 0;
}
public intersect(left: number, right: number) {
public intersect(left: number, right: number): boolean {
// Get rid of anything that falls entirely outside to the left
for (let i = 0; i < this.scanlines.length; i++) {
const scanline = this.scanlines[i];
@@ -450,7 +450,7 @@ export class Scan {
return this.scanlines.length > 0;
}
public toString() {
public toString(): string {
return "{ #scanlines: " + this.scanlines.length + "}";
}
}
+2 -2
View File
@@ -121,7 +121,7 @@ export class WMFRect16 {
this.bottom = reader.readInt16();
}
public toString() {
public toString(): string {
return "{left: " + this.left + ", top: " + this.top + ", right: " + this.right
+ ", bottom: " + this.bottom + "}";
}
@@ -154,7 +154,7 @@ export class WMF {
this._records = new WMFRecords(reader, this._hdrsize);
}
public render(gdi: GDIContext) {
public render(gdi: GDIContext): void {
this._records.play(gdi);
}
}
+12 -12
View File
@@ -47,16 +47,16 @@ export class ColorRef {
}
}
public clone() {
public clone(): ColorRef {
return new ColorRef(null, this.r, this.g, this.b);
}
public toHex() {
public toHex(): string {
const rgb = (this.r << 16) | (this.g << 8) | this.b;
return (0x1000000 + rgb).toString(16).slice(1);
}
public toString() {
public toString(): string {
return "{r: " + this.r + ", g: " + this.g + ", b: " + this.b + "}";
}
}
@@ -137,11 +137,11 @@ export class Font extends Obj {
}
}
public clone() {
public clone(): Font {
return new Font(null, this);
}
public toString() {
public toString(): string {
return JSON.stringify(this);
}
}
@@ -211,11 +211,11 @@ export class Brush extends Obj {
}
}
public clone() {
public clone(): Brush {
return new Brush(null, this);
}
public toString() {
public toString(): string {
let ret = "{style: " + this.style;
switch (this.style) {
case Helper.GDI.BrushStyle.BS_SOLID:
@@ -257,11 +257,11 @@ export class Pen extends Obj {
}
}
public clone() {
public clone(): Pen {
return new Pen(null, this.style, this.width.clone(), this.color.clone(), this.linecap, this.join);
}
public toString() {
public toString(): string {
return "{style: " + this.style + ", width: " + this.width.toString() + ", color: " + this.color.toString()
+ ", linecap: " + this.linecap + ", join: " + this.join + "}";
}
@@ -287,7 +287,7 @@ export class PaletteEntry {
}
}
public clone() {
public clone(): PaletteEntry {
return new PaletteEntry(null, this);
}
}
@@ -316,11 +316,11 @@ export class Palette extends Obj {
}
}
public clone() {
public clone(): Palette {
return new Palette(null, this);
}
public toString() {
public toString(): string {
return "{ #entries: " + this.entries.length + "}"; // TODO
}
}
+1 -1
View File
@@ -502,7 +502,7 @@ export class WMFRecords {
}
}
public play(gdi: GDIContext) {
public play(gdi: GDIContext): void {
const len = this._records.length;
for (let i = 0; i < len; i++) {
this._records[i](gdi);
-15
View File
@@ -1,15 +0,0 @@
{
"extends": "tslint:recommended",
"rules": {
"indent": [true, "spaces", 4],
"max-classes-per-file": false,
"no-bitwise": false,
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"],
"object-literal-sort-keys": false,
"prefer-for-of": false,
// to be enabled eventually
"forin": false
},
"defaultSeverity": "error"
}