@knowvah/dot-engine 2.6.9 → 2.6.10
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/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-style.d.ts +22 -0
- package/dist/common/htmltable-style.d.ts.map +1 -0
- package/dist/index.js +289 -264
- package/dist/index.js.map +4 -4
- package/dist/render.js +39 -14
- package/dist/render.js.map +4 -4
- package/package.json +1 -1
- package/src/common/htmltable-emit-fill.ts +7 -6
- package/src/common/htmltable-emit.ts +5 -22
- package/src/common/htmltable-style.ts +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knowvah/dot-engine",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.10",
|
|
4
4
|
"description": "Faithful TypeScript port of Graphviz (dot, neato, fdp, sfdp, circo, twopi, osage, patchwork) — no C: no native binary, no WASM. Oracle-verified against the C implementation, runs in the browser.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphviz",
|
|
@@ -18,7 +18,7 @@ import { FillType, PenType } from '../gvc/context.js';
|
|
|
18
18
|
import { transformPoint } from '../gvc/device.js';
|
|
19
19
|
import { resolveRenderColor } from '../render/color-resolve.js';
|
|
20
20
|
import { emitRoundedBezier } from './poly-shapes.js';
|
|
21
|
-
import {
|
|
21
|
+
import { htmlStyle } from './htmltable-style.js';
|
|
22
22
|
import {
|
|
23
23
|
BORDER_LEFT,
|
|
24
24
|
BORDER_TOP,
|
|
@@ -94,7 +94,7 @@ export interface HtmlPaint {
|
|
|
94
94
|
pen?: string;
|
|
95
95
|
/** Pen width; default 1.0 (omitted from SVG at 1.0). */
|
|
96
96
|
penWidth?: number;
|
|
97
|
-
/**
|
|
97
|
+
/** HTML STYLE string; its dashed/dotted flags map to the pen type. */
|
|
98
98
|
penStyle?: string;
|
|
99
99
|
/**
|
|
100
100
|
* Second/stop color of a gradient fill. Presence switches the fill from
|
|
@@ -137,10 +137,11 @@ export function resetHtmlFillPenWidth(): void {
|
|
|
137
137
|
htmlFillPen = 1.0;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
/** Map
|
|
140
|
+
/** Map an HTML STYLE to the C pen type: dashed wins over dotted. @see lib/common/htmltable.c:doBorder */
|
|
141
141
|
function penTypeOf(style: string | undefined): PenType {
|
|
142
|
-
|
|
143
|
-
if (
|
|
142
|
+
const st = htmlStyle(style);
|
|
143
|
+
if (st.dashed) return PenType.Dashed;
|
|
144
|
+
if (st.dotted) return PenType.Dotted;
|
|
144
145
|
return PenType.Solid;
|
|
145
146
|
}
|
|
146
147
|
|
|
@@ -277,7 +278,7 @@ export function doBorder(
|
|
|
277
278
|
// value persists and leaks into the next bgcolor fill's stroke-width.
|
|
278
279
|
htmlFillPen = border;
|
|
279
280
|
withHtmlPaint({ pen: color, penWidth: border, penStyle: style }, job, () => {
|
|
280
|
-
if (
|
|
281
|
+
if (htmlStyle(style).rounded) {
|
|
281
282
|
// C: round_corners(job, mkPts(AF,b,border), 4, {rounded}, 0) — unfilled
|
|
282
283
|
// rounded border path; emitRoundedBezier transforms the AF ring itself.
|
|
283
284
|
emitRoundedBezier(mkPts(box, border, pos), { x: 0, y: 0 }, false, { renderer, job });
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
htmlFillPenWidth, resetHtmlFillPenWidth, type HtmlPaint,
|
|
36
36
|
} from './htmltable-emit-fill.js';
|
|
37
37
|
import { emitRoundedBezier } from './poly-shapes.js';
|
|
38
|
-
import {
|
|
38
|
+
import { htmlStyle } from './htmltable-style.js';
|
|
39
39
|
import { emitHtmlRules, initHtmlAnchor, endHtmlAnchor, htmlObjImgscale } from './htmltable-emit-rules.js';
|
|
40
40
|
|
|
41
41
|
export type { PlacedHtml, PlacedCell, PlacedLine, PlacedImage };
|
|
@@ -125,7 +125,7 @@ function bgFillPaint(ctx: BgFillCtx): HtmlPaint {
|
|
|
125
125
|
if (spec === null) return { fill: ctx.bgcolor, penWidth };
|
|
126
126
|
return {
|
|
127
127
|
fill: spec[0], stop: spec[1], gradientAngle: ctx.gradientangle ?? 0,
|
|
128
|
-
radial: ctx.style
|
|
128
|
+
radial: htmlStyle(ctx.style).radial, penWidth,
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -139,7 +139,7 @@ function bgFillPaint(ctx: BgFillCtx): HtmlPaint {
|
|
|
139
139
|
function emitBgFill(ctx: BgFillCtx): void {
|
|
140
140
|
const { box, pos, border, renderer, job } = ctx;
|
|
141
141
|
withHtmlPaint(bgFillPaint(ctx), job, () => {
|
|
142
|
-
if (
|
|
142
|
+
if (htmlStyle(ctx.style).rounded) {
|
|
143
143
|
emitRoundedBezier(mkPts(box, border, pos), { x: 0, y: 0 }, true, { renderer, job });
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
@@ -258,23 +258,6 @@ export function emitHtmlImg(
|
|
|
258
258
|
*
|
|
259
259
|
* @see lib/common/htmltable.c:emit_html_cell
|
|
260
260
|
*/
|
|
261
|
-
/**
|
|
262
|
-
* True when an HTML element's STYLE declares it invisible.
|
|
263
|
-
*
|
|
264
|
-
* HTML STYLE is lexed by its OWN parser, not the node/edge one: tokens are
|
|
265
|
-
* split on space or comma, compared case-insensitively, and BOTH "INVIS" and
|
|
266
|
-
* "INVISIBLE" set the flag. (The node/edge parser splits on comma only and
|
|
267
|
-
* matches exact-case, so it cannot be reused here.)
|
|
268
|
-
* @see lib/common/htmllex.c:168 (DELIM " ,", strview_case_str_eq)
|
|
269
|
-
*/
|
|
270
|
-
function htmlStyleInvisible(style: string | undefined): boolean {
|
|
271
|
-
if (style === undefined) return false;
|
|
272
|
-
return style.split(/[ ,]+/).some((tok) => {
|
|
273
|
-
const t = tok.toUpperCase();
|
|
274
|
-
return t === 'INVIS' || t === 'INVISIBLE';
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
261
|
export function emitHtmlCell(
|
|
279
262
|
cell: PlacedCell,
|
|
280
263
|
pos: Point,
|
|
@@ -287,7 +270,7 @@ export function emitHtmlCell(
|
|
|
287
270
|
);
|
|
288
271
|
// An invisible cell emits no fill, no border and no content — only the
|
|
289
272
|
// anchor, which C opens before the gate. @see htmltable.c:emit_html_cell:643
|
|
290
|
-
if (
|
|
273
|
+
if (htmlStyle(cell.style).invisible) {
|
|
291
274
|
if (inAnchor) endHtmlAnchor(renderer, job);
|
|
292
275
|
return;
|
|
293
276
|
}
|
|
@@ -354,7 +337,7 @@ export function emitHtmlLabel(
|
|
|
354
337
|
const inAnchor = clustersLast ? false : initHtmlAnchor(anchorData, tblBox, renderer, job);
|
|
355
338
|
// An invisible TABLE suppresses its fill, ALL its cells, and its rules and
|
|
356
339
|
// border — the whole block C guards at emit_html_tbl:542.
|
|
357
|
-
const tblInvisible =
|
|
340
|
+
const tblInvisible = htmlStyle(placed.style).invisible;
|
|
358
341
|
if (!tblInvisible) {
|
|
359
342
|
if (placed.bgcolor !== undefined) {
|
|
360
343
|
emitBgFill({ bgcolor: placed.bgcolor, box: placed.box, pos, border: placed.border,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EPL-2.0
|
|
2
|
+
/**
|
|
3
|
+
* The HTML STYLE flags. C's stylefn sets an htmlstyle_t bitfield at lex time;
|
|
4
|
+
* the port keeps the legal tokens as a string (htmltable-attr-warn.ts joins
|
|
5
|
+
* them with ' ') and reads the flags back here, token by token in order, so
|
|
6
|
+
* SOLID still clears only the DOTTED/DASHED before it. HTML STYLE is not the
|
|
7
|
+
* node/edge style: tokens split on space or comma and compare
|
|
8
|
+
* case-insensitively, so `parseStyleFlags` cannot read it.
|
|
9
|
+
*
|
|
10
|
+
* @see lib/common/htmltable.h:htmlstyle_t
|
|
11
|
+
* @see lib/common/htmllex.c:stylefn (DELIM " ,", strview_case_str_eq)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** @see lib/common/htmltable.h:htmlstyle_t */
|
|
15
|
+
export interface HtmlStyle {
|
|
16
|
+
radial: boolean;
|
|
17
|
+
rounded: boolean;
|
|
18
|
+
invisible: boolean;
|
|
19
|
+
dotted: boolean;
|
|
20
|
+
dashed: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Read the htmlstyle_t flags from a kept HTML STYLE string. */
|
|
24
|
+
export function htmlStyle(style: string | undefined): HtmlStyle {
|
|
25
|
+
const s: HtmlStyle = { radial: false, rounded: false, invisible: false, dotted: false, dashed: false };
|
|
26
|
+
if (style === undefined) return s;
|
|
27
|
+
for (const tk of style.split(/[ ,]+/)) {
|
|
28
|
+
switch (tk.toUpperCase()) {
|
|
29
|
+
case 'ROUNDED': s.rounded = true; break;
|
|
30
|
+
case 'RADIAL': s.radial = true; break;
|
|
31
|
+
case 'SOLID': s.dotted = false; s.dashed = false; break;
|
|
32
|
+
case 'INVISIBLE': case 'INVIS': s.invisible = true; break;
|
|
33
|
+
case 'DOTTED': s.dotted = true; break;
|
|
34
|
+
case 'DASHED': s.dashed = true; break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return s;
|
|
38
|
+
}
|