@knowvah/dot-engine 1.1.0 → 1.2.0
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/README.md +48 -17
- package/dist/api.js +24 -0
- package/dist/api.js.map +2 -2
- package/dist/common/arrows.d.ts.map +1 -1
- package/dist/common/edge-label-init.d.ts.map +1 -1
- package/dist/common/htmltable-emit.d.ts +0 -8
- package/dist/common/htmltable-emit.d.ts.map +1 -1
- package/dist/common/ps-fontalias.d.ts +22 -9
- package/dist/common/ps-fontalias.d.ts.map +1 -1
- package/dist/common/splines-clip.d.ts.map +1 -1
- package/dist/gvc/device.d.ts.map +1 -1
- package/dist/gvc/job.d.ts +4 -0
- package/dist/gvc/job.d.ts.map +1 -1
- package/dist/index.js +1981 -1533
- package/dist/index.js.map +4 -4
- package/dist/layout/dot/index.d.ts +1 -1
- package/dist/layout/dot/index.d.ts.map +1 -1
- package/dist/layout/sfdp/init.d.ts.map +1 -1
- package/dist/model/graph.d.ts +24 -0
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/parser/builder.d.ts +32 -0
- package/dist/parser/builder.d.ts.map +1 -1
- package/dist/render/dot/agwrite.d.ts +186 -0
- package/dist/render/dot/agwrite.d.ts.map +1 -0
- package/dist/render/dot/attrs.d.ts +220 -0
- package/dist/render/dot/attrs.d.ts.map +1 -0
- package/dist/render/dot/edge-draw.d.ts +60 -0
- package/dist/render/dot/edge-draw.d.ts.map +1 -0
- package/dist/render/dot/types.d.ts +28 -0
- package/dist/render/dot/types.d.ts.map +1 -0
- package/dist/render/dot/xdot-ops.d.ts +206 -0
- package/dist/render/dot/xdot-ops.d.ts.map +1 -0
- package/dist/render/dot.d.ts +58 -277
- package/dist/render/dot.d.ts.map +1 -1
- package/dist/render/map.d.ts +14 -1
- package/dist/render/map.d.ts.map +1 -1
- package/dist/render/svg-graph.d.ts.map +1 -1
- package/dist/render.js +1942 -1494
- package/dist/render.js.map +4 -4
- package/package.json +3 -1
- package/src/common/arrows.ts +17 -4
- package/src/common/edge-label-init.ts +9 -2
- package/src/common/htmltable-emit.ts +36 -8
- package/src/common/poly-gencode.ts +8 -8
- package/src/common/ps-fontalias.ts +80 -49
- package/src/common/splines-clip.ts +36 -10
- package/src/gvc/device.ts +18 -6
- package/src/gvc/job.ts +4 -0
- package/src/layout/dot/index.ts +37 -5
- package/src/layout/sfdp/init.ts +11 -0
- package/src/model/graph.ts +26 -0
- package/src/parser/builder.ts +90 -5
- package/src/render/dot/agwrite.ts +506 -0
- package/src/render/dot/attrs.ts +437 -0
- package/src/render/dot/edge-draw.ts +203 -0
- package/src/render/dot/types.ts +32 -0
- package/src/render/dot/xdot-ops.ts +432 -0
- package/src/render/dot.ts +114 -1131
- package/src/render/map.ts +18 -1
- package/src/render/svg-graph.ts +4 -0
- package/src/render/svg-helpers.ts +1 -1
package/src/render/map.ts
CHANGED
|
@@ -167,10 +167,27 @@ function isEscapeAt(bytes: Uint8Array, i: number): boolean {
|
|
|
167
167
|
return c !== undefined && 'EGHLNTlnr\\"'.includes(String.fromCharCode(c));
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Canonicalize an attribute value for printing — cgraph's `agstrcanon`, which
|
|
172
|
+
* DISPATCHES on the html flag before falling back to the plain-string scan.
|
|
173
|
+
*
|
|
174
|
+
* An HTML-like value (`label=<<table…>>`) is emitted angle-bracket delimited
|
|
175
|
+
* and VERBATIM: no quoting, and no escaping of the `"` inside its markup.
|
|
176
|
+
* Routing it through `agstrcanonText` instead produces a quoted string with
|
|
177
|
+
* every attribute quote backslash-escaped, and leaks the port's marker byte.
|
|
178
|
+
*
|
|
179
|
+
* @see lib/cgraph/write.c:219 agstrcanon · :209 agcanonhtmlstr
|
|
180
|
+
*/
|
|
181
|
+
export function agstrcanon(arg: string): string {
|
|
182
|
+
if (isHtmlValue(arg)) return '<' + htmlValueContent(arg) + '>';
|
|
183
|
+
return agstrcanonText(arg);
|
|
184
|
+
}
|
|
185
|
+
|
|
170
186
|
/** The needs-quotes / numeral / escape state scan of `_agstrcanon`, over UTF-8
|
|
171
187
|
* BYTES (C iterates bytes: cnt counts bytes for line breaking, and non-ascii
|
|
172
188
|
* bytes are id chars). Returns the quoted buffer or the untouched input.
|
|
173
|
-
*
|
|
189
|
+
* NOTE: this is `_agstrcanon`, the non-html half — call `agstrcanon` unless you
|
|
190
|
+
* know the value cannot be html. @see lib/cgraph/write.c:_agstrcanon */
|
|
174
191
|
export function agstrcanonText(arg: string): string {
|
|
175
192
|
if (arg.length === 0) return '""';
|
|
176
193
|
const bytes = new TextEncoder().encode(arg);
|
package/src/render/svg-graph.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { svgGraphId, svgGraphClass } from './svg-id.js';
|
|
|
22
22
|
import { parseGradientSpec } from '../common/htmltable-emit-fill.js';
|
|
23
23
|
import { findStopColor, parseStyleFlags } from '../common/style-resolve.js';
|
|
24
24
|
import { cround } from '../common/arith.js';
|
|
25
|
+
import { FontnameKind } from '../model/layoutParams.js';
|
|
25
26
|
import {
|
|
26
27
|
emitLinearGradient,
|
|
27
28
|
emitRadialGradient,
|
|
@@ -323,6 +324,9 @@ function emitBgcolorBackground(g: Graph, bb: Box, bgcolorAttr: string | undefine
|
|
|
323
324
|
export function svgBeginGraph(g: Graph, job: RenderJob): void {
|
|
324
325
|
job.devscale = { x: 1, y: -1 };
|
|
325
326
|
job.directed = g.kind === 'directed' || g.kind === 'strict-directed';
|
|
327
|
+
// C reads GD_fontnames(job->gvc->g) at each span; the port carries it on the
|
|
328
|
+
// job, set here alongside the other root-graph-derived fields.
|
|
329
|
+
job.fontnames = g.info.fontnames ?? FontnameKind.NativeFonts;
|
|
326
330
|
// GD_drawing(root)->id — used as the `<gid>_` prefix for non-root object ids.
|
|
327
331
|
job.drawingId = g.attrs.get('id') ?? '';
|
|
328
332
|
job.write(SVG_XML_DECL);
|
|
@@ -330,7 +330,7 @@ export function svgTextspan(pos: Point, span: TextSpan, job: RenderJob): void {
|
|
|
330
330
|
job.write('" y="');
|
|
331
331
|
job.printDouble(y);
|
|
332
332
|
job.write('"');
|
|
333
|
-
const ff = fontFamilyAttrs(span.fontName);
|
|
333
|
+
const ff = fontFamilyAttrs(span.fontName, job.fontnames);
|
|
334
334
|
if (ff !== null) job.write(ff.attrs);
|
|
335
335
|
else job.write(' font-family="' + escapeXml(span.fontName ?? 'Times,serif') + '"');
|
|
336
336
|
emitFontAttrs(span.fontFlags, job, ff ?? { weight: false, style: false });
|