@knowvah/dot-engine 2.6.9 → 2.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/html-entities.d.ts +13 -5
- package/dist/common/html-entities.d.ts.map +1 -1
- package/dist/common/htmltable-emit-fill.d.ts +1 -1
- package/dist/common/htmltable-emit-fill.d.ts.map +1 -1
- package/dist/common/htmltable-emit.d.ts +8 -0
- package/dist/common/htmltable-emit.d.ts.map +1 -1
- package/dist/common/htmltable-lex-chardata.d.ts +9 -0
- package/dist/common/htmltable-lex-chardata.d.ts.map +1 -1
- package/dist/common/htmltable-style.d.ts +22 -0
- package/dist/common/htmltable-style.d.ts.map +1 -0
- package/dist/index.js +345 -284
- package/dist/index.js.map +4 -4
- package/dist/render.js +95 -34
- package/dist/render.js.map +4 -4
- package/package.json +1 -1
- package/src/common/html-entities.ts +77 -25
- package/src/common/htmltable-emit-fill.ts +7 -6
- package/src/common/htmltable-emit.ts +5 -22
- package/src/common/htmltable-lex-chardata.ts +42 -8
- package/src/common/htmltable-style.ts +38 -0
package/dist/render.js
CHANGED
|
@@ -5955,28 +5955,46 @@ var HTML_ENTITIES = {
|
|
|
5955
5955
|
"zwj": 8205,
|
|
5956
5956
|
"zwnj": 8204
|
|
5957
5957
|
};
|
|
5958
|
-
var
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5958
|
+
var ENTITY_NAME_LENGTH_MAX = 8;
|
|
5959
|
+
function numericEntity(s, at) {
|
|
5960
|
+
const hex = s[at + 1] === "x" || s[at + 1] === "X";
|
|
5961
|
+
const digit = hex ? /^[0-9A-Fa-f]$/ : /^[0-9]$/;
|
|
5962
|
+
let n = 0;
|
|
5963
|
+
let i = hex ? 2 : 1;
|
|
5964
|
+
for (; i < 8; i++) {
|
|
5965
|
+
const c = s[at + i] ?? "";
|
|
5966
|
+
if (!digit.test(c)) break;
|
|
5967
|
+
n = n * (hex ? 16 : 10) + parseInt(c, 16);
|
|
5968
|
+
}
|
|
5969
|
+
if (i < 8 && s[at + i] === ";") return { value: n, next: at + i + 1 };
|
|
5970
|
+
return { value: 0, next: at };
|
|
5971
|
+
}
|
|
5972
|
+
function namedEntity(s, at) {
|
|
5973
|
+
for (let i = 0; i < ENTITY_NAME_LENGTH_MAX; i++) {
|
|
5974
|
+
const c = s[at + i];
|
|
5975
|
+
if (c === void 0 || c === "\0") break;
|
|
5976
|
+
if (c === ";") {
|
|
5977
|
+
const key = s.slice(at, at + i);
|
|
5978
|
+
if (Object.hasOwn(HTML_ENTITIES, key)) return { value: HTML_ENTITIES[key], next: at + i + 1 };
|
|
5979
|
+
break;
|
|
5980
|
+
}
|
|
5981
|
+
}
|
|
5982
|
+
return { value: 0, next: at };
|
|
5969
5983
|
}
|
|
5970
|
-
function
|
|
5971
|
-
|
|
5972
|
-
return BASIC_ENTITIES[body] ?? HTML_ENTITIES[body] ?? null;
|
|
5984
|
+
function htmlEntity(s, at) {
|
|
5985
|
+
return s[at] === "#" ? numericEntity(s, at) : namedEntity(s, at);
|
|
5973
5986
|
}
|
|
5974
5987
|
function htmlEntityUTF8(s) {
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5988
|
+
let amp = s.indexOf("&");
|
|
5989
|
+
if (amp < 0) return s;
|
|
5990
|
+
let out = "";
|
|
5991
|
+
let from = 0;
|
|
5992
|
+
for (; amp >= 0; amp = s.indexOf("&", from)) {
|
|
5993
|
+
const e = htmlEntity(s, amp + 1);
|
|
5994
|
+
out += s.slice(from, amp) + (e.value ? String.fromCodePoint(e.value) : "&");
|
|
5995
|
+
from = e.next;
|
|
5996
|
+
}
|
|
5997
|
+
return out + s.slice(from);
|
|
5980
5998
|
}
|
|
5981
5999
|
|
|
5982
6000
|
// src/common/htmltable-lex-attvalue.ts
|
|
@@ -6370,8 +6388,26 @@ function releaseXb(st, first) {
|
|
|
6370
6388
|
function cleanText(decoded) {
|
|
6371
6389
|
return decoded.replace(/[\x00-\x1f]/g, "");
|
|
6372
6390
|
}
|
|
6391
|
+
var XML_PREDEFINED = { lt: "<", gt: ">", amp: "&", quot: '"', apos: "'" };
|
|
6392
|
+
var SCAN_ENTITY_MIN = 2;
|
|
6393
|
+
var SCAN_ENTITY_MAX = 8;
|
|
6394
|
+
var TEXT_REF = /&(#x[0-9A-Fa-f]+|#[0-9]+|[^&;]+);/g;
|
|
6395
|
+
function textRefValue(ref, body) {
|
|
6396
|
+
if (body[0] === "#") {
|
|
6397
|
+
const v = charRefNumber(ref);
|
|
6398
|
+
return v < 0 ? ref : String.fromCodePoint(v);
|
|
6399
|
+
}
|
|
6400
|
+
const n = body.length;
|
|
6401
|
+
if (n >= SCAN_ENTITY_MIN && n <= SCAN_ENTITY_MAX && Object.hasOwn(HTML_ENTITIES, body)) {
|
|
6402
|
+
return String.fromCodePoint(HTML_ENTITIES[body]);
|
|
6403
|
+
}
|
|
6404
|
+
return Object.hasOwn(XML_PREDEFINED, body) ? XML_PREDEFINED[body] : ref;
|
|
6405
|
+
}
|
|
6406
|
+
function decodeTextRefs(raw) {
|
|
6407
|
+
return raw.indexOf("&") < 0 ? raw : raw.replace(TEXT_REF, textRefValue);
|
|
6408
|
+
}
|
|
6373
6409
|
function textTokens(raw) {
|
|
6374
|
-
return charDataTokens(
|
|
6410
|
+
return charDataTokens(decodeTextRefs(raw));
|
|
6375
6411
|
}
|
|
6376
6412
|
function charDataTokens(decoded) {
|
|
6377
6413
|
const clean = cleanText(decoded);
|
|
@@ -11292,6 +11328,37 @@ function underlineDraw(ring, coord, filled, ctx) {
|
|
|
11292
11328
|
renderShapePolyline([ring[2], ring[3]], coord, ctx);
|
|
11293
11329
|
}
|
|
11294
11330
|
|
|
11331
|
+
// src/common/htmltable-style.ts
|
|
11332
|
+
function htmlStyle(style2) {
|
|
11333
|
+
const s = { radial: false, rounded: false, invisible: false, dotted: false, dashed: false };
|
|
11334
|
+
if (style2 === void 0) return s;
|
|
11335
|
+
for (const tk of style2.split(/[ ,]+/)) {
|
|
11336
|
+
switch (tk.toUpperCase()) {
|
|
11337
|
+
case "ROUNDED":
|
|
11338
|
+
s.rounded = true;
|
|
11339
|
+
break;
|
|
11340
|
+
case "RADIAL":
|
|
11341
|
+
s.radial = true;
|
|
11342
|
+
break;
|
|
11343
|
+
case "SOLID":
|
|
11344
|
+
s.dotted = false;
|
|
11345
|
+
s.dashed = false;
|
|
11346
|
+
break;
|
|
11347
|
+
case "INVISIBLE":
|
|
11348
|
+
case "INVIS":
|
|
11349
|
+
s.invisible = true;
|
|
11350
|
+
break;
|
|
11351
|
+
case "DOTTED":
|
|
11352
|
+
s.dotted = true;
|
|
11353
|
+
break;
|
|
11354
|
+
case "DASHED":
|
|
11355
|
+
s.dashed = true;
|
|
11356
|
+
break;
|
|
11357
|
+
}
|
|
11358
|
+
}
|
|
11359
|
+
return s;
|
|
11360
|
+
}
|
|
11361
|
+
|
|
11295
11362
|
// src/common/htmltable-emit-rules.ts
|
|
11296
11363
|
function emitHtmlRules(ctx) {
|
|
11297
11364
|
withHtmlPaint({ fill: ctx.color, pen: ctx.color, penWidth: 1 }, ctx.job, () => {
|
|
@@ -11438,14 +11505,14 @@ function bgFillPaint(ctx) {
|
|
|
11438
11505
|
fill: spec[0],
|
|
11439
11506
|
stop: spec[1],
|
|
11440
11507
|
gradientAngle: ctx.gradientangle ?? 0,
|
|
11441
|
-
radial: ctx.style
|
|
11508
|
+
radial: htmlStyle(ctx.style).radial,
|
|
11442
11509
|
penWidth
|
|
11443
11510
|
};
|
|
11444
11511
|
}
|
|
11445
11512
|
function emitBgFill(ctx) {
|
|
11446
11513
|
const { box, pos, border: border2, renderer, job } = ctx;
|
|
11447
11514
|
withHtmlPaint(bgFillPaint(ctx), job, () => {
|
|
11448
|
-
if (
|
|
11515
|
+
if (htmlStyle(ctx.style).rounded) {
|
|
11449
11516
|
emitRoundedBezier(mkPts(box, border2, pos), { x: 0, y: 0 }, true, { renderer, job });
|
|
11450
11517
|
return;
|
|
11451
11518
|
}
|
|
@@ -11511,13 +11578,6 @@ function emitHtmlImg(img, pos, renderer, job) {
|
|
|
11511
11578
|
}
|
|
11512
11579
|
renderer.usershape?.(img.src, b, job);
|
|
11513
11580
|
}
|
|
11514
|
-
function htmlStyleInvisible(style2) {
|
|
11515
|
-
if (style2 === void 0) return false;
|
|
11516
|
-
return style2.split(/[ ,]+/).some((tok) => {
|
|
11517
|
-
const t = tok.toUpperCase();
|
|
11518
|
-
return t === "INVIS" || t === "INVISIBLE";
|
|
11519
|
-
});
|
|
11520
|
-
}
|
|
11521
11581
|
function emitHtmlCell(cell2, pos, renderer, job) {
|
|
11522
11582
|
const inAnchor = initHtmlAnchor(
|
|
11523
11583
|
{ href: cell2.href, title: cell2.title, target: cell2.target, id: cell2.id },
|
|
@@ -11525,7 +11585,7 @@ function emitHtmlCell(cell2, pos, renderer, job) {
|
|
|
11525
11585
|
renderer,
|
|
11526
11586
|
job
|
|
11527
11587
|
);
|
|
11528
|
-
if (
|
|
11588
|
+
if (htmlStyle(cell2.style).invisible) {
|
|
11529
11589
|
if (inAnchor) endHtmlAnchor(renderer, job);
|
|
11530
11590
|
return;
|
|
11531
11591
|
}
|
|
@@ -11561,7 +11621,7 @@ function emitHtmlLabel(placed, pos, renderer, job) {
|
|
|
11561
11621
|
const tblBox = absBox(placed.box, pos);
|
|
11562
11622
|
const clustersLast = (job.flags & EMIT_CLUSTERS_LAST) !== 0;
|
|
11563
11623
|
const inAnchor = clustersLast ? false : initHtmlAnchor(anchorData, tblBox, renderer, job);
|
|
11564
|
-
const tblInvisible =
|
|
11624
|
+
const tblInvisible = htmlStyle(placed.style).invisible;
|
|
11565
11625
|
if (!tblInvisible) {
|
|
11566
11626
|
if (placed.bgcolor !== void 0) {
|
|
11567
11627
|
emitBgFill({
|
|
@@ -20933,8 +20993,9 @@ function resetHtmlFillPenWidth() {
|
|
|
20933
20993
|
htmlFillPen = 1;
|
|
20934
20994
|
}
|
|
20935
20995
|
function penTypeOf(style2) {
|
|
20936
|
-
|
|
20937
|
-
if (
|
|
20996
|
+
const st = htmlStyle(style2);
|
|
20997
|
+
if (st.dashed) return 1 /* Dashed */;
|
|
20998
|
+
if (st.dotted) return 2 /* Dotted */;
|
|
20938
20999
|
return 3 /* Solid */;
|
|
20939
21000
|
}
|
|
20940
21001
|
function withHtmlPaint(paint, job, drawFn) {
|
|
@@ -21001,7 +21062,7 @@ function doBorder(spec, renderer, job) {
|
|
|
21001
21062
|
const { box, pos, border: border2, color, sides: sides2, style: style2 } = spec;
|
|
21002
21063
|
htmlFillPen = border2;
|
|
21003
21064
|
withHtmlPaint({ pen: color, penWidth: border2, penStyle: style2 }, job, () => {
|
|
21004
|
-
if (
|
|
21065
|
+
if (htmlStyle(style2).rounded) {
|
|
21005
21066
|
emitRoundedBezier(mkPts(box, border2, pos), { x: 0, y: 0 }, false, { renderer, job });
|
|
21006
21067
|
return;
|
|
21007
21068
|
}
|